Socket.IO Gateway
createAgentGateway() attaches real-time handlers to a Socket.IO server. Clients emit agent.run or team.run and receive streaming chunks, tool events, and final output over WebSockets.
Installation
Basic Setup
Explicit wiring
Auto-discovery (zero-wiring)
Agents and teams auto-register into a globalregistry. The gateway reads from it dynamically — entities created after the gateway starts are immediately reachable.
serve:
GatewayOptions
Socket.IO server instance.
Map of agent names to Agent instances.
Map of team names to Team instances.
Mixed array of Agent and Team instances. Automatically classified. An alternative to passing
agents and teams separately.Controls live auto-discovery. Defaults to the global
registry — all auto-registered entities are available. Pass a custom Registry instance, or false to disable auto-discovery and only serve explicitly passed entities.Socket.IO namespace. Clients connect to
http://host/radaros (or your namespace).Socket.IO middleware for authentication. Call
next() to allow, or next(new Error("Unauthorized")) to reject.Toolkit instances whose tools are exposed via
tools.list event. Useful for UI tool discovery.Named tools exposed via
tools.list. Merged with toolkit tools (explicit entries take precedence).Events
Client → Server
| Event | Payload | Description |
|---|---|---|
agent.run | { name, input, sessionId?, apiKey? } | Run agent and stream response |
team.run | { name, input, sessionId?, apiKey? } | Run team (non-streaming) |
agents.list | {} | List registered agents with metadata (callback) |
teams.list | {} | List registered teams (callback) |
workflows.list | {} | List registered workflows (callback) |
registry.list | {} | List all registered entity names (callback) |
tools.list | {} | List available tools (when toolkits configured) |
tools.get | { name } | Get single tool detail |
Server → Client
| Event | Payload | Description |
|---|---|---|
agent.chunk | { chunk: string } | Streamed text chunk |
agent.tool.call | { toolName, args } | Tool call started |
agent.tool.done | { toolCallId } | Tool call finished |
agent.done | { output: { text } } | Run complete |
agent.error | { error: string } | Error occurred |
Listing Agents & Teams
Use acknowledgement callbacks to query registered entities:Real-Time Chat Example
Server:With Authentication
apiKey in the event payload or in handshake.auth:
Session Continuity
UsesessionId to maintain conversation context across multiple agent.run calls:
Voice Gateway
For real-time voice over Socket.IO, see the dedicated Voice Agents docs. ThecreateVoiceGateway() function streams audio between browser clients and VoiceAgent instances using the same Socket.IO server.
Browser Gateway
For live browser agent observation over Socket.IO, see the Browser Agents docs. ThecreateBrowserGateway() function streams screenshots, actions, and step events from BrowserAgent runs to connected clients.