workspace:{id}, session:{chatId}, …); the server validates each subscription against database membership and fans state changes out to the subscribers. Most dashboard state arrives on the workspace channel, while a few high-fanout streams (chat, mission detail, files) use narrower channels.
Cost fields on this page are
OWNER / ADMIN only. Other roles receive the same response with them left out — see Who sees cost figures.Connecting requires a short-lived JWT from
GET /api/v1/ws-token (itself session- or CLI-authenticated). The token is sent as the first message after the connection opens, not a URL query parameter — a ?token= would leak into proxy/access logs, browser history, and Referer headers. It is validated only at that point; the connection stays authenticated afterward.Connection
Authentication Flow
- Obtain a short-lived JWT token:
GET /api/v1/ws-token(requires session or CLI auth) - Open the WebSocket connection (no token in the URL)
- Send
{"type":"auth","token":"<jwt>"}as the first message; the server validates it using the same JWT validator as the REST API and closes the connection if it’s missing, invalid, or the underlying session was revoked - After that, the token is no longer needed — the connection remains authenticated
golang.org/x/net/websocket (not gorilla/websocket). Authentication is token-based. Inbound frames are capped at 64 KiB.
Message Format
All messages (client-to-server and server-to-client) are JSON.Client Messages
Server Messages
Client Message Types
subscribe
Subscribe to a channel for real-time events. Channel access is validated against workspace/crew membership in the database.unsubscribe
ping
Keep-alive ping. The server also sends periodic pings every 30 seconds.send_message
Send a chat message to an agent session.cancel_message
Cancel an in-progress agent chat response.payload.request_id (at most 128 bytes), the server answers
privately on the requesting socket. When a run of the caller’s is active on
the chat it first acknowledges the request:
cancelled:true means this explicit stop request ended the run and the
runtime confirmed the stop. A server or hub shutdown, an agent stop
(POST /agents/{id}/stop) or a natural completion never confirms it.
cancelled:false carries a reason:
Several requests for the same run — repeated on one socket or sent from
several sockets of the same user — all receive the same outcome when the run
finishes. The run’s frames (trailing text, its
done) are queued to the
requesting socket before its cancel_result, so a client that stops reading
at the result has received the whole stream. Ordinary session done events
do not confirm a cancel. Clients must match both request and session IDs.
Omitting request_id retains the existing cancellation behavior without
requesting a result. A server that predates this protocol sends neither
frame; a client can recognise it by the missing cancel_accepted.
A single-run client may also set payload.origin_only:true: cancellation then
requires the active run to have originated on this exact WebSocket. This avoids
stopping a replacement invocation that the same user started in another terminal;
ordinary chat stop intentionally permits stopping from a different socket.
Error frames
The server answers a refused or undeliverable client frame with a top-levelerror message (not a chat_event). The reason appears under both message
and error; what tells a client where to put it is the channel:
- Addressed (
"channel": "session:chat_abc123") — the error is about that conversation: a denied subscribe, a denied or malformedsend_message, a chat handler that is unavailable. Asend_messagerefusal is addressed to the session in its payload, whether or not the client setchannelon the frame it sent. - Unaddressed (
"channel": "") — a connection-level fault that names no conversation: a frame the server could not parse, or a message type it does not route. Clients must not attribute these to a chat.
chats row appears on the first send),
and the web client re-subscribes once it does; it renders an error frame only
when one terminates work it has in flight.
Channels
Channels follow the formattype:id. Access is validated against database membership when subscribing.
Channel Types
Server Event Types
Events are broadcast to channels when state changes occur. Below are the event types by channel. Most state changes fan out on the workspace channel so a single subscription drives the whole dashboard; a few high-fanout streams (chat, mission detail, files) use narrower channels. Many payloads carry only the entityid (and sometimes identifier/status)
as a refresh hint — the client is expected to refetch the full resource over
REST. The shapes below reflect what the server actually sends.
The web client keeps an explicit allowlist of event types it will dispatch
to subscribers (
VALID_REALTIME_TYPES in hooks/use-realtime.tsx) — an
unrecognized frame is dropped rather than crashing a handler that assumed a
shape it doesn’t have. A Vitest parity gate
(hooks/__tests__/realtime-allowlist-docs-parity.test.ts) reads every
workspace-channel event type documented on this page and fails if any of
them is missing from that allowlist, so this table and the client can no
longer drift apart silently (#2125). Not every allowlisted type has a
subscriber yet — registering a type only stops the client from discarding
it; wiring a consumer is separate work tracked per surface.Workspace Channel (workspace:{id})
Crews & agents
Missions, tasks & issues
Projects & milestones
Integrations & credentials
Assignments, escalations & peers
Containers & provisioning
Pipelines
Pipeline run/step events broadcast on the workspace channel (not a dedicated channel) so the Graph view can updatePipelineRunNode status
without polling. Every payload also carries pipeline_id, pipeline_slug,
and run_id.
Pages
Pages broadcast on the workspace channel. Every payload is a refresh hint — the client re-reads through the authorised path, so the per-panel permission filter lives in one place — and carries no page data of its own.Configuration & inbox
Journal Channel (journal:{id})
The journal→WS bridge forwards durably-committed journal entries onto a
dedicated, opt-in channel — journal:{workspaceId} — not the workspace
channel. A client only receives these frames if it explicitly subscribes to
journal:{workspaceId} (authorized against the same workspace membership as the
other tenant channels). Tabs that don’t subscribe pay nothing, so this is never
an unconditional firehose.
Status: realtime plumbing, no dashboard consumer yet. The authoritative
journal feed is still the SSE stream, which keeps a gap-free
Last-Event-ID
replay and server-side filtering. This channel is the foundation for later
retiring SSE, but it does not yet replace it.
Caveats to know before consuming it:
- Best-effort delivery. Under sustained backpressure the bridge drops live
frames rather than stalling the journal write path. A consumer that needs a
gap-free view must reconcile via the SSE stream’s
Last-Event-IDreplay or aGET /api/v1/journal?since=refetch on (re)connect. - Coarse server-side filtering only. High-frequency telemetry (streamed exec
output, per-sample container metrics, tracing spans, sweep bookkeeping) is
dropped at the bridge and never broadcast. Beyond that the channel is
workspace-wide: fine-grained filtering (
crew_id,entry_type,severity, …) is server-side on the SSE/REST paths but must be applied client-side here.
Crew Channel (crew:{id})
The
files:{crewId} channel exists for subscription (file change events) and
shares its access rule with crew. File-change events are broadcast on the
crew:{crewId} channel as file.event.Workbook session closure (connection control)
session_closed has no channel and carries only { artifact_id, session_ids, reason }.
Only the listed persisted editor session IDs are closed; a late control cannot
terminate a newly authorized session. It carries no
workbook content. A channel is removed only while current read access is denied; retained or
restored read access and other subscriptions remain active.
Grant removal closes the persisted editor session in the grant transaction,
so granting access again cannot revive that session ID. The host rechecks
current rights before each protected frame and drops queued frames after
revocation. Active workbook subscriptions also receive a bounded authorization
recheck every second, with one two-second budget for the entire pass; errors
fail closed. The five-second closure target is measured in regression tests.
Page Channel (page:{pageId})
kind is cells or snapshot (an import: reread the workbook); cells is the
number of cells the revision wrote. Access to the workbook Page is rechecked
before every frame, so a frame is never delivered after the recipient lost
access. A published workbook’s channel admits only its owner, the editors the
owner named and the workspace OWNER.
Mission Channel (mission:{id})
These two are mission-channel only and are not part of the workspace
allowlist: the web client subscribes to
workspace:{id} and reads the
mission.updated / task.updated counterparts there, so VALID_REALTIME_TYPES
does not register mission.status / task.status and the docs-parity gate
(which reads only the Workspace Channel tables) does not cover them. A custom
client that wants them subscribes to mission:{id} and handles them itself.Session Channel (session:{chatId})
Chat streaming events from the agent ChatHandler
Session-scoped lifecycle events
These mirror their*.updated/*.created workspace counterparts but are
scoped to the originating chat session.
Keeper Channel (keeper:{workspaceId})
Providers Channel (providers)
User Channel (user:{userId})
The identity-scoped channel. Its only producer, notification.created, was
removed with the entity-scoped in-app notifications table
(#1751). It now carries
one control event:
For “what needs my attention”, use the workspace inbox channel
(
inbox.updated) instead.
Only the user themselves may subscribe to their own
user:{userId} channel —
the authorizer grants access when the connecting user’s id equals the channel
id, with no workspace membership lookup (the channel is scoped to the identity,
not a tenant).Connection Lifecycle
- Connect — token-authenticated WebSocket upgrade
- Subscribe — client subscribes to channels (access validated per-channel)
- Receive events — server pushes events to subscribed channels
- Send messages — client can send chat messages to session channels
- Keepalive — server sends pings every 30 seconds; client can also send pings
- Disconnect — client disconnects; all channel subscriptions are cleaned up