Skip to content

Watch Mode (SSE Streaming)

Watch mode provides real-time streaming of every execution event via Server-Sent Events (SSE). This is ideal for monitoring long-running tasks, debugging agent behavior, or integrating with custom UIs.

Usage

bash
# From monorepo source (or: commander watch "...")
npx tsx packages/core/src/cliEntry.ts watch "investigate this production bug"

Streamed Events

Every event in the execution pipeline is streamed:

Event TypeDescription
task.startTask started
deliberationComplexity analysis
topology.selectTopology selected
agent.spawnAgent created
tool.callTool execution started
tool.resultTool execution completed
subtask.completeSubtask finished
verificationQuality gate check
checkpointState checkpoint saved
task.completeTask finished
task.errorError occurred

Event Format

json
{
  "type": "tool.call",
  "data": {
    "tool": "grep",
    "args": { "pattern": "deprecated", "path": "./src" },
    "agentId": "agent-3",
    "timestamp": "2026-05-23T10:30:00Z"
  }
}

Consuming Events

CLI

bash
npx tsx packages/core/src/cliEntry.ts watch "debug" | jq '.type'

JavaScript/TypeScript

typescript
const client = new CommanderClient({ provider: 'openai' });
await client.connect();

const unsub = client.onEvent((event) => {
  console.log(`[${event.type}]`, event.data);
  if (event.type === 'task.complete') {
    console.log('Result:', event.data.summary);
  }
});

const result = await client.run('debug the failing test');
await client.disconnect();

HTTP (curl)

bash
curl -N \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: text/event-stream" \
  -d '{"task": "debug the failing test", "stream": true}' \
  http://localhost:4000/execute

Use Cases

  • CI/CD pipelines — Stream events to build dashboards
  • Custom UIs — Build real-time agent monitoring interfaces
  • Debugging — Inspect every step of a complex multi-agent execution
  • Logging — Persist full execution traces for audit

MIT Licensed — Built for multi-agent orchestration.