Skip to content

Implement WebSocket handler and event system #73

Description

@2witstudios

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

Files to Create/Modify

  • src/server/ws/handler.ts (new)
  • src/server/ws/events.ts (new)
  • src/server/ws/handler.test.ts (new)

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:websocketEpic 4: WebSocket & Real-Time PushmobilePPG Mobile project

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions