| 1 | import readline from 'node:readline'; |
| 2 | |
| 3 | const input = readline.createInterface({input: process.stdin}); |
| 4 | |
| 5 | input.on('line', async (line) => { |
| 6 | const prompt = line.trim(); |
| 7 | if (!prompt) return; |
| 8 | const turnId = `turn-${Date.now()}`; |
| 9 | emit({type: 'turn', turn_id: turnId}); |
| 10 | emit({type: 'prompt_trace', turn_id: turnId, prompt_trace: {totals: {total_tokens: 6840}}}); |
| 11 | emit({type: 'status', turn_id: turnId, phase: 'sampling_assistant', message: 'Sampling assistant'}); |
| 12 | await wait(120); |
| 13 | emit({type: 'tool_start', turn_id: turnId, tool: {id: 'tool-demo', name: 'vimax_narrative_planning'}}); |
| 14 | await wait(120); |
| 15 | emit({type: 'tool_progress', turn_id: turnId, tool: {name: 'vimax_narrative_planning'}, progress: {stage: 'design_storyboard', message: 'Designing storyboard'}}); |
| 16 | await wait(220); |
| 17 | emit({type: 'tool_result', turn_id: turnId, tool_result: {name: 'vimax_narrative_planning', ok: true, content: 'Narrative planning complete'}}); |
| 18 | await wait(100); |
| 19 | const assistant = `The text plan is ready for **${prompt}**.\n\nI created the script, storyboard, shot decomposition, and camera plan. Would you like to revise the plan or continue to render?`; |
| 20 | emit({type: 'token', turn_id: turnId, delta: assistant}); |
| 21 | emit({type: 'done', turn_id: turnId, assistant, tool_results: []}); |
| 22 | emit({ |
| 23 | type: 'session', |
| 24 | turn_id: turnId, |
| 25 | session: { |
| 26 | active_session_id: 'demo-session', |
| 27 | session: {session_id: 'demo-session', working_dir: '.working_dir/demo-session', stage: 'narrative_planned'}, |
| 28 | }, |
| 29 | }); |
| 30 | }); |
| 31 | |
| 32 | function emit(event) { |
| 33 | process.stdout.write(`${JSON.stringify(event)}\n`); |
| 34 | } |
| 35 | |
| 36 | function wait(milliseconds) { |
| 37 | return new Promise((resolve) => setTimeout(resolve, milliseconds)); |
| 38 | } |
| 39 |