Skip to main content

Module ws

Module ws 

Source
Expand description

WebSocket agent chat handler.

Connect: ws://host:port/ws/chat?session_id=ID&name=My+Session

Protocol:

Server -> Client: {"type":"session_start","session_id":"...","name":"...","resumed":true,"message_count":42}
Client -> Server: {"type":"message","content":"Hello"}
Server -> Client: {"type":"chunk","content":"Hi! "}
Server -> Client: {"type":"tool_call","name":"shell","args":{...}}
Server -> Client: {"type":"tool_result","name":"shell","output":"..."}
Server -> Client: {"type":"done","full_response":"..."}

Query params:

  • session_id — resume or create a session (default: new UUID)
  • name — optional human-readable label for the session
  • token — bearer auth token (alternative to Authorization header)

Structs§

WsQuery

Functions§

handle_ws_chat
GET /ws/chat — WebSocket upgrade for agent chat