Developer reference
Events & streaming
How live output gets from a spawned process to the UI: the event channels, the session-id routing, and the stream-json shapes the chat parses.
Event channels#
The backend emits Tauri events the frontend listens to. Each carries a session_id and a payload.
| Event | Payload | Source |
|---|---|---|
agent-output | { session_id, chunk } | Streaming chunks of an agent run. |
agent-exit | { session_id, code } | Agent process exit. |
review-output / review-exit | same shapes | The self-review agent's stream. |
term-output / term-exit | same shapes | The embedded terminal's PTY. |
Session-id routing#
A single workspace can have an agent, a review, and a terminal all streaming at once. The session_id prefix tells the UI which is which:
| Session id | Stream |
|---|---|
agent:<workspace-id> | The chat agent. |
review:<workspace-id> | The self-review agent. |
term:<workspace-id> | The terminal PTY. |
The stream-json format#
Agent runs use claude --output-format stream-json, which emits newline-delimited JSON. NeuralCode parses these event types as they arrive:
| Type | Used for |
|---|---|
system / init | Captures the model id at the start. |
assistant | Text deltas become message text; tool_use items become tool chips. |
result | The final summary, plus total cost, duration, and token usage. |
{"type":"system","subtype":"init","model":"claude-opus-4-8", ...}
{"type":"assistant","message":{"content":[
{"type":"text","text":"Reading the router…"},
{"type":"tool_use","name":"Edit","input":{"file_path":"auth/redirect.ts"}}
]}}
{"type":"result","result":"Done. Fixed the redirect.",
"total_cost_usd":0.81,"duration_ms":142000,"usage":{ ... }}Resilient parsing
The parser tolerates partial/trailing lines — a half-streamed final line simply completes on the next chunk, so rendering never breaks mid-stream. Token usage from the
result event is what feeds the Usage screen.