diff --git a/examples/dungeon-master/dm.ts b/examples/dungeon-master/dm.ts index 48c49ed..d64ec62 100644 --- a/examples/dungeon-master/dm.ts +++ b/examples/dungeon-master/dm.ts @@ -191,14 +191,17 @@ export async function chat( let response = ''; const printer = onOutput || createStreamPrinter(); - for await (const msg of session.receive()) { + let lastToolName = ''; + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; printer(msg.content); - } else if (msg.type === 'tool_call') { - console.log(`\n${COLORS.system}[Using ${msg.name}...]${COLORS.reset}`); - } else if (msg.type === 'tool_result') { - console.log(`${COLORS.system}[Done]${COLORS.reset}\n`); + lastToolName = ''; + } else if (msg.type === 'tool_call' && 'toolName' in msg) { + if (msg.toolName !== lastToolName) { + console.log(`\n${COLORS.system}[${msg.toolName}]${COLORS.reset}`); + lastToolName = msg.toolName; + } } } diff --git a/examples/economics-seminar/faculty.ts b/examples/economics-seminar/faculty.ts index 16eef41..3281f6d 100644 --- a/examples/economics-seminar/faculty.ts +++ b/examples/economics-seminar/faculty.ts @@ -176,7 +176,7 @@ Be aggressive. Be dismissive. Show intellectual contempt if warranted. You've se await session.send(prompt); let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; onOutput(msg.content); @@ -215,7 +215,7 @@ Keep it to 2-3 brutal sentences.`; await session.send(prompt); let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; onOutput(msg.content); diff --git a/examples/economics-seminar/presenter.ts b/examples/economics-seminar/presenter.ts index 204782b..4494c68 100644 --- a/examples/economics-seminar/presenter.ts +++ b/examples/economics-seminar/presenter.ts @@ -172,7 +172,7 @@ Start by announcing your chosen topic, then research it, then present.`; await session.send(prompt); let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; onOutput(msg.content); @@ -208,7 +208,7 @@ Please respond to this question. Be direct, cite evidence where relevant, and de await session.send(prompt); let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; onOutput(msg.content); diff --git a/examples/research-team/README.md b/examples/research-team/README.md index a325e28..4f01458 100644 --- a/examples/research-team/README.md +++ b/examples/research-team/README.md @@ -241,7 +241,7 @@ app.post('/research', async (req, res) => { await researcher.send(`Research: ${query}`); let result = ''; - for await (const msg of researcher.receive()) { + for await (const msg of researcher.stream()) { if (msg.type === 'assistant') result += msg.content; } diff --git a/examples/research-team/agents/analyst.ts b/examples/research-team/agents/analyst.ts index 6320f1b..64605a1 100644 --- a/examples/research-team/agents/analyst.ts +++ b/examples/research-team/agents/analyst.ts @@ -180,7 +180,7 @@ Confirm when complete.`; let success = false; let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; process.stdout.write('.'); // Progress indicator @@ -229,7 +229,7 @@ Update your memory with insights, then summarize your reflection.`; await session.send(prompt); let reflection = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { reflection += msg.content; } diff --git a/examples/research-team/agents/researcher.ts b/examples/research-team/agents/researcher.ts index 01f2f30..da8fce3 100644 --- a/examples/research-team/agents/researcher.ts +++ b/examples/research-team/agents/researcher.ts @@ -179,7 +179,7 @@ Find at least ${config.sourcesCount} high-quality sources, then confirm completi let success = false; let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; process.stdout.write('.'); // Progress indicator @@ -229,7 +229,7 @@ Update your memory blocks with any insights, then summarize your reflection.`; await session.send(prompt); let reflection = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { reflection += msg.content; } diff --git a/examples/research-team/agents/writer.ts b/examples/research-team/agents/writer.ts index d52e500..2f7158a 100644 --- a/examples/research-team/agents/writer.ts +++ b/examples/research-team/agents/writer.ts @@ -210,7 +210,7 @@ Write the complete report to the output file, then confirm completion.`; let success = false; let response = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { response += msg.content; process.stdout.write('.'); // Progress indicator @@ -264,7 +264,7 @@ Update your memory blocks, then summarize your reflection.`; await session.send(prompt); let reflection = ''; - for await (const msg of session.receive()) { + for await (const msg of session.stream()) { if (msg.type === 'assistant') { reflection += msg.content; } diff --git a/examples/research-team/teleport-example.ts b/examples/research-team/teleport-example.ts index b549c4a..16d42d8 100644 --- a/examples/research-team/teleport-example.ts +++ b/examples/research-team/teleport-example.ts @@ -67,7 +67,7 @@ async function main() { ); let researcherResponse = ''; - for await (const msg of researcher.receive()) { + for await (const msg of researcher.stream()) { if (msg.type === 'assistant') { researcherResponse += msg.content; process.stdout.write('.'); @@ -100,7 +100,7 @@ async function main() { ); let analystResponse = ''; - for await (const msg of analyst.receive()) { + for await (const msg of analyst.stream()) { if (msg.type === 'assistant') { analystResponse += msg.content; process.stdout.write('.');