-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
Parent: #204 | Priority: P0 — Blocks usable dashboard
Problem
The container creates stream tickets (UUIDs with 60s TTL in-memory) via POST /agents/:agentId/stream-ticket, and the worker handler handleContainerStreamTicket constructs stream URLs. But the actual endpoint that would consume these tickets and stream events to the browser does not exist. The AgentStream.tsx component connects via EventSource to a URL that serves nothing.
The "watch an agent work" experience — the core value proposition of the dashboard — is completely blocked by this.
What Exists
control-server.ts:POST /agents/:agentId/stream-ticket— creates tickets, stores inMap<string, {agentId, expires}>with 60s TTL and max 1000 entriesprocess-manager.ts: SSE consumers already subscribe to kilo serve/eventand track per-agent events (tool calls, completions, messages)town-container.handler.ts:handleContainerStreamTicketproxies to container and wraps result in a stream URLAgentStream.tsx: Connects viaEventSourceto the constructed URL, renders events in a scrollable log
What's Missing
A GET /agents/:agentId/stream endpoint on the control server that:
- Validates a stream ticket from the query string (
?ticket=<uuid>) - Opens an SSE connection to the client
- Subscribes to the relevant kilo serve session's event stream (already tracked in
ManagedAgent.sseConsumer) - Forwards relevant events (tool calls, assistant messages, file edits, errors) to the browser
- Sends periodic keepalive comments to prevent connection timeout
- Closes cleanly when the agent exits or the client disconnects
Implementation Approach
The process-manager.ts already has per-agent SSE consumers that receive all events from kilo serve. The new endpoint needs to:
- Add a
GET /agents/:agentId/streamroute tocontrol-server.ts - Validate the ticket, consume it (one-use)
- Create a
ReadableStreamthat subscribes to the agent's events - The existing
ManagedAgentneeds a way to register additional event listeners (besides the internal SSE consumer). A simple event emitter or callback list on theManagedAgentobject. - Format events as SSE:
event: <type>\ndata: <json>\n\n - Handle cleanup on disconnect
Acceptance Criteria
-
GET /agents/:agentId/stream?ticket=<uuid>endpoint on control server - Ticket validation and one-time consumption
- SSE stream of agent events (tool calls, messages, completions, errors)
- Periodic keepalive to prevent timeout
- Clean disconnect handling (client closes, agent exits)
-
AgentStream.tsxcomponent works end-to-end (connect → see live events) - Multiple concurrent viewers for the same agent work correctly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels