Request
Response (SSE)
The stream is a sequence ofOutputEvent JSON payloads, one per
data: line, terminated by a session_end event.
Event types
kind | Fields | Meaning |
|---|---|---|
agent_token | text: string | A streamed assistant text delta. Concatenate to render the agent’s reply. |
thinking | text: string | A streamed thinking-mode delta (Claude). Reasoning surface, not part of the user-visible answer. |
tool_call | id, name, status: "started"|"completed"|"failed", detail?, input? | Lifecycle marker for an agent-invoked tool. |
tool_result | tool_call_id, output: any, is_error: bool | Result of a previously-started tool call. |
subagent | id, status, label | A nested agent (e.g. Claude Task tool) was spawned. |
hook | id, name, status | A custom plugin hook (e.g. PreCommit). The lifecycle hooks SessionStart, Stop, Notification are filtered out. |
usage | input_tokens, output_tokens, cache_read, cache_write | Token-usage telemetry for this turn. |
stdout | line: string | A raw stdout line that did not match any of the structured shapes above. |
stderr | line: string | A raw stderr line. Suppressed unless the final exit code is non-zero. |
session_end | exit_code: i32, duration_ms: u64 | Terminal event. After this, the SSE stream closes. |
error | message: string | Internal failure path on the gateway side (rare; followed by a non-zero session_end). |
kind
values as a no-op and continue consuming the stream until session_end.
Driver behaviour
The gateway parses each driver’s native stream-json output centrally and maps it to the unifiedOutputEvent set above. This means every
consumer (One, Connect’s Tauri UI, the CLI itself, future SDKs) gets the
same semantic stream regardless of which underlying CLI ran.
| Driver | Underlying invocation | Notes |
|---|---|---|
claude | claude --print --output-format stream-json --verbose --include-partial-messages <task> | text_delta → agent_token; thinking_delta → thinking; tool_use start/stop → tool_call; lifecycle hooks filtered; result usage → usage. |
codex | codex exec --json <task> | Single result-shaped event per turn; text field → agent_token. |
gemini | gemini --output-format stream-json --prompt <task> | text and candidates[0].content.parts[0].text → agent_token. |
echo | built-in | One agent_token carrying the task verbatim, then session_end{exit_code:0}. Reserved for tests. |