Skip to content

WebSocket Protocol

Launchpad HQ uses a typed WebSocket protocol for daemon communication. All messages use literal type discriminants defined in src/shared/.

Dual WebSocket Architecture

HQ runs two WebSocket servers:

EndpointPurposeClients
/wsBrowser pub/subReact frontend
/ws/daemonDaemon protocolProject daemons

Connection Flow

Daemon                          HQ Server
  │                                │
  ├──── WebSocket Connect ────────►│
  │                                │
  │◄─── Auth Challenge ───────────┤
  │                                │
  ├──── Auth Response ────────────►│
  │     (gh auth token)            │
  │                                │
  │◄─── Auth Accepted ────────────┤
  │                                │
  ├──── Self-Registration ────────►│
  │                                │
  │◄──► Bidirectional Messages ───►│
  │                                │

Message Types

All messages are JSON objects with a type field:

Daemon → HQ

TypeDescription
auth_responseAuthentication token
registerDaemon self-registration with capabilities
project_stateGit status, branch info
copilot_sessionsActive Copilot session list
copilot_eventReal-time Copilot session event
terminal_outputTerminal PTY data
tool_resultCustom tool execution result

HQ → Daemon

TypeDescription
auth_challengeRequest authentication
auth_acceptedConfirm successful auth
prompt_injectInject a prompt into a Copilot session
session_attachAttach to a terminal session
terminal_inputSend input to a terminal
tool_invokeInvoke a custom tool

Protocol Types

Protocol types are defined in src/shared/ and shared between HQ and daemon code. Each message type uses TypeScript literal type discriminants for type-safe handling.

INFO

See src/shared/ in the source code for the complete type definitions.

Built with VitePress