Skip to content
Website ↗

Subscribe to daemon events ​

The daemon sends asynchronous events as JSON-RPC notifications. Dispatch these notifications by their method and params. Match responses that carry an id to the original request. Complete initialization first and use the negotiated version and capabilities to parse notifications. See packages/api/src/protocol.ts, packages/api/src/connection-session-events.ts, and packages/api/test/client-notification-interleave.test.ts. Session event schemas

Task board and signal bus ​

When the connection advertises bus/state and bus/subscribe, call bus/state with {} to get tasks, signal views, agents, and lastSeq. Subscribe using lastSeq + 1 as fromSeq. The daemon replays retained events starting at that inclusive sequence, then sends live events. Omitting fromSeq starts with events after the subscription is established. See busStateResponseSchema in packages/api/src/protocol.ts, replayFrom in packages/core/src/bus/events.ts, and packages/api/test/bus-subscription-pump.test.ts.

This request follows a sample snapshot with lastSeq equal to 42. Use the value from your actual snapshot. The subscription response has its own lastSeq, the watermark when the subscription was established. Track processed events using bus/event and params.seq. params.kind identifies events such as task/statusChanged and signal/deposited. See packages/api/src/bus-subscription-pump.ts and busEventNotificationSchema in packages/api/src/protocol.ts.

json
{"jsonrpc":"2.0","id":"bus-1","method":"bus/subscribe","params":{"fromSeq":43}}

Each connection supports one bus subscription. If the sequence is outside the retained window, fetch another bus/state snapshot. On an event queue overflow, the daemon attempts to send bus/dropped and closes the connection. Reconnect and obtain a fresh snapshot. See handle and #enqueueEvent in packages/api/src/bus-subscription-pump.ts and subscribe in packages/core/src/bus/events.ts.

Session progress events ​

session/event delivers progress for a bound session. The fields sessionId, turnId, seq, type, and at identify the event. Additional fields depend on the event type and protocol. Use type values such as tool/started, model/text-delta, and turn/completed to display tool activity, text, and completion. See sessionEventNotificationSchema in packages/api/src/session-event-protocol.ts and SessionEventRouter in packages/api/src/session-events.ts.

json
{"jsonrpc":"2.0","method":"session/event","params":{"sessionId":"session-example","turnId":"turn-example","seq":1,"type":"turn/started","at":1760000000}}

Use text deltas as a live preview. The router can skip some deltas when its write buffer is backed up. Build your final view from the original operation response or a supported session read, and associate events with their session and turn. In approval notifications, use approvalId to correlate the original approval. Approval closure reports approval status. See packages/api/src/session-events.ts, packages/api/src/connection-session-events.ts, and packages/api/src/approval-notice-protocol.ts.

Task progress events ​

When the connection advertises task/observe, task/event, and task/unobserve, you can observe the original events for an existing task. Replace TASK_ID with an identifier from a task query. A successful response contains taskId, status: "observing", and recovery: "task/plan". The current implementation enables this stream through its daily protocol capabilities. See packages/api/src/task-observe-rpc.ts, packages/api/src/task-observe-protocol.ts, and capabilitiesForProtocol in packages/api/src/protocol-initialization.ts.

json
{"jsonrpc":"2.0","id":"observe-1","method":"task/observe","params":{"taskId":"TASK_ID"}}

For task/event, params.taskId identifies the observed task and params.event carries the original task event shape. If events are missed, use the response's recovery method, task/plan, when the current connection supports it, to read the recorded plan. When finished, call task/unobserve with the same taskId to release the observation on this connection. See taskEventNotificationSchema and TaskObservationRequests.handle.