Event format
All events follow the JSON-RPC 2.0 notification format with a standard structure:Always set to
"event" for all event notificationsThe specific event type (e.g.,
"session.status", "auth.flow.url")ISO 8601 timestamp when the event was emitted
Event-specific data. Structure varies by event type.
Event categories
Session events
Track AI conversation state, streaming output, and tool execution:session.status- Status updates (pending, thinking, complete)session.message.appended- New messages added to conversationsession.stream.chunk- Streaming text chunks from AIsession.tool.call.started- Tool execution beginssession.tool.call.completed- Tool execution finishessession.tool.results- Tool results availablesession.completed- Turn finishedsession.interrupted- User interrupted the turnsession.error- Error occurred during processing
Auth events
Track OAuth flows and authentication state changes:auth.flow.started- OAuth flow initiatedauth.flow.url- Browser URL available (user must open)auth.flow.device_code- Device code available (display to user)auth.flow.completed- Authentication succeededauth.flow.failed- Authentication failedstate.changed- Global state updated (auth added/removed)
Listening for events
Events arrive as NDJSON notifications on stdout. Parse each line as JSON and check formethod === "event":
Event ordering
Events are emitted in chronological order but may arrive rapidly during streaming. Your client should:- Buffer events if processing takes time
- Handle out-of-order delivery (use timestamps)
- React to session.completed to know when a turn finishes
Events are fire-and-forget notifications. The server does not expect acknowledgment responses.
Common patterns
Displaying streaming text
Tracking tool execution
Handling OAuth in headless mode
Debugging events
Enable debug logging to see all events:Related
- Session events - Complete session event reference
- Auth events - OAuth event sequences
- RPC overview - Protocol fundamentals