MCPcopy Index your code
hub / github.com/AI45Lab/Code / main

Function main

sdk/node/examples/streaming/debug_sse.ts:8–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { Agent } from '../../index.js';
7
8async function main(): Promise<void> {
9 const configPath = '/Users/roylin/Desktop/code/a3s/crates/code/sdk/node/examples/streaming/test_minimax.acl';
10
11 const agent = await Agent.create(configPath);
12 const session = agent.session('.', {
13 permissionPolicy: { defaultDecision: 'allow' }, maxToolRounds: 0,
14 });
15
16 const prompt = 'Say hello in 3 words.';
17 console.log(`Prompt: "${prompt}"`);
18
19 const stream = await session.stream(prompt);
20
21 let eventCount = 0;
22
23 while (true) {
24 const result = await stream.next();
25 if (!result.value || result.done) break;
26
27 const event = result.value;
28 eventCount++;
29
30 // Log all events
31 console.log(`[${eventCount}] type="${event.type}"` +
32 (event.text ? ` text="${event.text.slice(0, 30)}..."` : '') +
33 (event.data ? ` data="${JSON.stringify(event.data)?.slice(0, 60)}..."` : '')
34 );
35
36 // Stop after 30 events to avoid flooding
37 if (eventCount >= 30) {
38 console.log('\n... (stopping after 30 events)');
39 break;
40 }
41 }
42}
43
44main().catch(err => {
45 console.error('Error:', err);

Callers 1

debug_sse.tsFile · 0.70

Calls 5

createMethod · 0.45
sessionMethod · 0.45
logMethod · 0.45
streamMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected