WebSocket RPC API
WebSocket RPC API
Section titled “WebSocket RPC API”Connect to ws://localhost:18790/ws for real-time streaming and event observation (pkg/protocol/).
Protocol Handshake
Section titled “Protocol Handshake”The first frame sent by the client MUST be a connect request:
{ "type": "req", "id": "1", "method": "connect", "params": { "token": "your-gateway-token-or-api-key" }}Sending Chat Messages
Section titled “Sending Chat Messages”{ "type": "req", "id": "2", "method": "chat.send", "params": { "sessionKey": "sess_default_main", "message": "Hello Agent!" }}Wire Event Frames
Section titled “Wire Event Frames”Server pushes event frames with outer type agent or chat (pkg/protocol/events.go):
- Chat Events (
event: "chat"):payload.type: "chunk"— Streaming text delta token.payload.type: "thinking"— Extended thinking / reasoning trace delta.payload.type: "message"— Completed message payload.
- Agent Lifecycle Events (
event: "agent"):payload.type: "run.started"— Agent turn initiated.payload.type: "tool.call"— Tool execution triggered.payload.type: "tool.result"— Tool execution result returned.payload.type: "run.completed"— Agent execution finalized.payload.type: "run.failed"— Agent execution error.