Server API
Only when the UI needs a capability the hub doesn’t expose.
Pipeline (always this order)
Section titled “Pipeline (always this order)”hub.js method → http.js route → web/src/lib/api.ts helper → componentSkip a layer → agents and future UIs diverge.
- Localhost only — no auth middleware projects; don’t bind
0.0.0.0unless user demands it. - REST for commands, SSE for streams — don’t invent a second event channel.
- Hub owns AgentSession — http.js should call hub, not construct sessions ad hoc.
- Keep responses JSON-small — UI can refetch; don’t dump full SDK objects unless needed.
- Errors — consistent status codes; never leave a turn without
agent_settledif you started one (see hub#failTurn).
- Express / Fastify / socket.io
- Long-lived state outside
SessionHubfor session data - Touch SSE seq/ring unless the feature is about resume (red zone)