## Epic 4: WebSocket & Real-Time Push — Issue 1/3 **Source:** Composite — 3-agent's terminal diff + 2-agent's watcher + 1-agent's handler ### Description WebSocket endpoint with authentication, client tracking, command dispatch, and typed event system. ### Acceptance Criteria - [ ] Single endpoint: `ws://<host>:<port>/ws?token=<token>` - [ ] Token validation from query parameter - [ ] Client set tracking with per-client subscription state - [ ] Command dispatch: `ping`, `terminal:subscribe`, `terminal:unsubscribe`, `terminal:input` - [ ] Typed discriminated union events: `manifest:updated`, `agent:status`, `terminal:output`, `error`, `pong` - [ ] Broadcast helper (send to all connected clients) - [ ] `sendEvent` helper (send to specific client) - [ ] Proper cleanup on client disconnect - [ ] Tests: connection, auth, command dispatch, event types ### Dependencies - Requires: #63 (server scaffold), #64 (auth) ### Files to Create/Modify - `src/server/ws/handler.ts` (new) - `src/server/ws/events.ts` (new) - `src/server/ws/handler.test.ts` (new)
Epic 4: WebSocket & Real-Time Push — Issue 1/3
Source: Composite — 3-agent's terminal diff + 2-agent's watcher + 1-agent's handler
Description
WebSocket endpoint with authentication, client tracking, command dispatch, and typed event system.
Acceptance Criteria
ws://<host>:<port>/ws?token=<token>ping,terminal:subscribe,terminal:unsubscribe,terminal:inputmanifest:updated,agent:status,terminal:output,error,pongsendEventhelper (send to specific client)Dependencies
Files to Create/Modify
src/server/ws/handler.ts(new)src/server/ws/events.ts(new)src/server/ws/handler.test.ts(new)