Skip to main content
Live tells a client what changed, the moment it changes. It never holds history: a client reads over HTTP up to where Live left off (Events), then applies what Live pushes. opc uses it for every command that watches a session (opc wait, opc watch, opc -p, the interactive screen).

Open

GET /live on the API (wss://app.opencomputer.dev/api/managed-agents/computer/live), a WebSocket upgrade offering the subprotocol oc.live.v1. Without it, or without an upgrade: 426 upgrade_required. The connection needs sessions:read. The server answers with oc.live.v1 only, never the bearer subprotocol. Every frame is one JSON text message of at most 64 kB. The client’s first frame is hello; the server answers ready:
expiresAt is when the credential expires, when it does. Send {"t":"auth","token":"..."} with a fresh credential of the same person before then; a credential of anyone else closes the socket with 4003. {"t":"ping"} is answered {"t":"pong"}.

Streams

after is a cursor from an events page or an earlier range. subd carries the stream’s head. {"t":"unsub","stream":"..."} stops a stream. A connection watches at most 32 sessions; past that, error with too_many_subscriptions. Watching a session never resumes it.

Following a session

Hold one cursor per session and compare it for equality only; never read inside it.
  1. Read events over HTTP until hasMore is false, keeping the page’s cursor.
  2. sub to events:<id> with that cursor as after, and to deltas:<id> if you show text as it is written.
  3. Apply each events frame whose from is your cursor, then hold its to. One whose to is your cursor is a repeat: ignore it.
  4. On anything else (a subd or behind whose head is not your cursor, or an events frame that does not start at it), read over HTTP from your cursor, then go on.
behind is sent when a range is too large for one frame: the events are read over HTTP.

Deltas

offset is where data’s text starts in its block. When it is not the length you hold, send {"t":"block","session":"cs_...","blockId":"..."}: the answer is a delta with whole: true whose text replaces the block. Each block’s completed event (message.completed, reasoning.completed, tool.completed) carries the whole text, so a client may ignore deltas. Delta types: API schema.

Close codes

Reconnect with backoff, hello, and sub again with each session’s cursor: nothing is lost, because Live holds nothing a client cannot read over HTTP.