// CONTENTS Part 08 · APIs and contracts

// PART 08

WebSocket API

Chapter 34 / 56 2 min read English Part 08 of 14

12 routes in the ws family. Inventory says whether the route is also listed in the API command catalog; Registered in is the file that mounts it.

Base URL: http://localhost:8080 — see Network Contract.

Method Path Summary Inventory Registered in
GET /ws/:param schema not modeled no botserver/src/main_module/routes/api_setup.rs
GET /ws/canvas/:param schema not modeled no botserver/crates/botcanvas/src/lib.rs
GET /ws/docs/:param schema not modeled no botserver/crates/botdocs/src/lib.rs
GET /ws/events schema not modeled no botserver/src/main_module/routes/feature_merge_platform/commerce.rs
GET /ws/events/stream schema not modeled no botserver/src/main_module/routes/feature_merge_platform/commerce.rs
GET /ws/logs schema not modeled no botserver/crates/botmonitoring/src/lib.rs

All families appear in the generated WebSocket reference.

The chat socket

The main socket is the chat pipeline’s transport (botserver/src/core/bot/ws/):

  • Handshake — GET /ws/:param upgrades the connection; the handler resolves identity from a token (cookie gb-access-token or the access_token/token query field), then a user_id query value, then a guest record — and logs which of the three it used. A shell must open the socket only after its auth call has answered; an early socket carries empty ids.
  • Frames — typed messages (see the message-type table on the Bot pipeline page): user messages (1), suggestions (4), context changes (5), and direct tool execution (6, which bypasses the LLM entirely).
  • Streaming — bot replies arrive as chunks over the same socket (ws/stream/); there is no second connection for tokens.
  • Suggestions — delivered per session from Redis (suggestions:{bot}:{session}), rendered as buttons by the suite.

Office event streams

/ws/events and /ws/events/stream carry office events (publish/subscribe for Docs/Sheet/Slides collaboration state), fed by POST /api/events/publish. /ws/canvas/:param and /ws/docs/:param are the per-document collaboration sockets of the Canvas and Docs crates. /ws/logs streams monitoring logs (botmonitoring).

Client rules worth knowing

Rule Why
Authenticate before opening the socket identity is resolved at handshake; a guest socket stays a guest
The web channel is the only suggestions/streaming surface other channels receive buffered whole messages
TOOL_EXEC (type 6) skips the model buttons run the tool’s .ast directly — no KB injection, no LLM call
Reconnect resumes from run_events the run event store is durable with documented retention

Testing

WebSocket testing belongs to the browser: the suite reflects real state (suggestions, buttons, network errors) that a raw WS client hides. Use Chrome CDP against the suite; do not validate chat behavior with wscat-style scripts.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move