mcp station: keep listener requests in the model context alongside the play log
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014mBuCaQSgWwqhtzsmTBQuM
This commit is contained in:
1 parent
187bc16163
commit
a88930ec4a
1 file changed
+2
-2
+2
-2
@@ -317,7 +317,7 @@ const notes=[];
|
||||
async function cookNext(){const s=await tool('dj_next',{station,history:hist,requests:notes},60000);s.voice=s.voice||(cur&&cur.s.voice);$('q').textContent='up next: '+s.title;fit();return cook(s)}
|
||||
function pauseAll(){if(cur){cur.song.pause();cur.voice&&cur.voice.pause()}$('pp').textContent='Play'}
|
||||
async function context(){const lines=hist.map((h,i)=>(i+1)+'. "'+h.title+'" ('+h.bpm+' bpm, '+h.key+'): '+(h.reaction||'played'));
|
||||
try{await rpc('ui/update-model-context',{content:[{type:'text',text:'[gandora] station "'+station+'" play log, oldest first:\\n'+lines.join('\\n')}],structuredContent:{station,history:hist}})}catch(e){log('context: '+e.message)}}
|
||||
try{await rpc('ui/update-model-context',{content:[{type:'text',text:'[gandora] station "'+station+'" play log, oldest first:\\n'+lines.join('\\n')+(notes.length?'\\nlistener requests to the DJ: '+notes.join(' | '):'')}],structuredContent:{station,history:hist,requests:notes}})}catch(e){log('context: '+e.message)}}
|
||||
function mark(r){const h=hist[hist.length-1];if(h){h.reaction=r;context()}}
|
||||
async function air(t){pauseAll();cur=t;show(t.s);hist.push({title:t.s.title,tags:t.s.tags,bpm:t.s.bpm,key:t.s.key});count++;context();
|
||||
t.song.ontimeupdate=()=>{$('pos').style.width=(100*t.song.currentTime/(t.song.duration||1))+'%'};
|
||||
@@ -332,7 +332,7 @@ if(!live.paused){live.pause();$('pp').textContent='Play'}else{live.play();$('pp'
|
||||
['🔥','💜','🕺','🌙','😴','🥱'].forEach(e=>{const b=document.createElement('button');b.textContent=e;b.title='react';b.onclick=()=>{const h=hist[hist.length-1];if(!h)return;h.reaction=((h.reaction&&h.reaction!=='played through')?h.reaction+' ':'')+e;context();b.classList.add('on');status('reacted '+e)};$('emo').appendChild(b)});
|
||||
$('djf').onsubmit=ev=>{ev.preventDefault();const v=$('dji').value.trim();if(!v)return;notes.push(v);$('dji').value='';status('DJ heard: '+v);
|
||||
if(count<MAX){nextP=cookNext();nextP.catch(e=>{log('next: '+e.message);nextP=null})}
|
||||
try{rpc('ui/update-model-context',{content:[{type:'text',text:'[gandora] station "'+station+'" listener requests to the DJ, oldest first:\\n- '+notes.join('\\n- ')}]})}catch(e){}};
|
||||
context()};
|
||||
$('up').onclick=()=>{mark('liked');$('up').textContent='Liked';$('up').classList.add('on')};
|
||||
$('down').onclick=()=>{mark('disliked, skipped');pauseAll();advance()};
|
||||
$('next').onclick=()=>{mark('skipped');pauseAll();advance()};
|
||||
|
||||
Reference in new issue
Block a user