-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
#338 introduced the MayorDO with a polling-based status panel. SSE through Workers is unreliable (buffering, connection drops at the edge). For real-time streaming of agent activity (tool calls, messages, completion events), we need WebSocket support.
Background
The kilo serve instances inside Cloudflare Containers already expose:
GET /event— SSE stream of all session events (message.created, message.part.updated, session.completed, etc.)- The container process manager (
process-manager.ts) already subscribes to this stream internally
The kilo web app (packages/app/src) consumes these SSE events through a sophisticated coalescing/batching system in global-sdk.tsx. The data model is:
- Session → messages → parts (text, tool calls, reasoning, patches)
- Events are scoped by
sessionIDin the payload
Proposed Architecture
kilo serve /event (SSE, inside container)
→ Container process-manager (already subscribes)
→ Forward events to MayorDO/AgentDO via RPC
→ MayorDO stores session data in KV/SQL
→ MayorDO broadcasts to WebSocket clients via DO hibernation API
→ Frontend connects via WebSocket, renders kilo-style UI
Key decisions needed:
- Session data storage: Store full session/message/part data in the DO? Or just forward events for real-time display and rely on the container for historical data?
- UI approach: Port the kilo web app's SolidJS components to React? Or build simpler React components that consume the same event protocol?
- Scope: Mayor only, or all agent types (polecat, refinery, witness)?
References
- kilo web app SSE consumer:
packages/app/src/context/global-sdk.tsx - kilo web app state model:
packages/app/src/context/global-sync/types.ts - kilo serve SSE event types:
packages/sdk/js/src/v2/gen/types.gen.ts(Event union) - Container SSE consumer:
cloudflare-gastown/container/src/sse-consumer.ts - Container process manager:
cloudflare-gastown/container/src/process-manager.ts - CF DO WebSocket hibernation: https://developers.cloudflare.com/durable-objects/api/websockets/
Part of #204
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request