Gateway protocol (WebSocket)
The Gateway WS protocol is the full control plane for Clawdbot. It is loopback-only by default and is intended for local clients (CLI, web UI, automations). If you are building a node client (iOS/Android/macOS node mode), use the Bridge protocol instead.Transport
- WebSocket, text frames with JSON payloads.
- First frame must be a
connectrequest.
Handshake (connect)
Client → Gateway:Framing
- Request:
{type:"req", id, method, params} - Response:
{type:"res", id, ok, payload|error} - Event:
{type:"event", event, payload, seq?, stateVersion?}
Versioning
PROTOCOL_VERSIONlives insrc/gateway/protocol/schema.ts.- Clients send
minProtocol+maxProtocol; the server rejects mismatches. - Schemas + models are generated from TypeBox definitions:
pnpm protocol:genpnpm protocol:gen:swiftpnpm protocol:check
Auth
- If
CLAWDBOT_GATEWAY_TOKEN(or--token) is set,connect.params.auth.tokenmust match or the socket is closed.
Scope
This protocol exposes the full gateway API (status, providers, models, chat, agent, sessions, nodes, etc.). The exact surface is defined by the TypeBox schemas insrc/gateway/protocol/schema.ts.