Live updates (SSE)
GET /api/stream is a server-sent events stream. The dashboard keeps one open and refetches what it shows when an event arrives. Events say what changed, never the content, so the stream leaks no run data.
curl -N http://localhost:3000/api/streamEvents
Section titled “Events”| Event | When | data |
|---|---|---|
ping |
On connect, then at least every 15 seconds | { "modulesHash": "...", "ts": "..." } |
run |
A row was written to a run’s timeline | { "id", "runId", "moduleId", "type", "stage", "ts" } |
reset |
A reconnecting client missed more than it can be sent | {}. Refetch everything. |
bye |
The stream reached its maximum age | { "reason": "max-age" }. Reconnect. |
Each run and reset frame carries an SSE id: the event id to resume from.
event: runid: 4821data: {"id":"4821","runId":"run_7f3a","moduleId":"hello","type":"gate.opened","stage":"choose","ts":"2026-11-23T14:02:39.000Z"}type is a timeline event type, for example run.started, stage.started, stage.done, stage.skipped, gate.opened, gate.decided, gate.regenerated, run.blocked, run.unblocked, run.completed, run.failed and run.rejected. Others (connector.call, artifact, progress, log, ai.*, page.fetch) appear too.
The modulesHash in ping is the SHA-1 of the sorted id@version list, the same value as GET /api/system. A change means modules were reloaded, so refetch module data.
Resuming
Section titled “Resuming”Pass the last id you saw, either as ?after=<id> or in the Last-Event-ID header (the browser’s EventSource sends it automatically on reconnect). The server sends the events after that id first. If more than 500 were missed it sends one reset instead. Without an id, you only get events from now on. A malformed id is a 400.
Limits
Section titled “Limits”- A stream ends after 30 minutes (
bye), so the client reconnects and the server re-checks its session. - At most 64 concurrent streams per process. Beyond that the endpoint returns 503 and the dashboard falls back to polling.
- The server polls the timeline table about every 750 ms while anyone is listening. It needs no database notifications. On the Cloudflare host a single
StreamHubDurable Object tails the event table once and serves every viewer. - Responses send
cache-control: no-storeandx-accel-buffering: no, so a proxy such as nginx should not buffer them.
Client sketch
Section titled “Client sketch”const es = new EventSource('/api/stream');es.addEventListener('run', (e) => { const { runId, type } = JSON.parse(e.data); if (type.startsWith('gate.')) refetchInbox();});es.addEventListener('reset', () => refetchAll());es.addEventListener('bye', () => es.close());@knetikdotdev/client has a stream helper with reconnection and polling fallback, which the dashboard uses.