WebSocket Endpoints
| Endpoint | Client | Connection URL |
|---|---|---|
WS /ws/extension | Browser Extension | wss://zeus-api.agentspro.cn/ws/extension?client_id={client_id}&node_id={node_id} |
WS /ws/desktop | Desktop App | wss://zeus-api.agentspro.cn/ws/desktop?client_id={client_id}&node_id={node_id} |
WS /ws/web | Web Client | wss://zeus-api.agentspro.cn/ws/web?user_id={user_id} |
Connection Parameters
Browser Extension / Desktop App
Client ID. Format:
user_{user_id} (browser extension) or desktop_{user_id} (desktop app). The server automatically parses and extracts the user_id.Node ID that uniquely identifies the device. If not provided, the server auto-generates one (
ext_{user_id} or desktop_{user_id}).Web Client
User ID, used for routing messages to the correct user.
Connection Lifecycle
Message Types
1. Node Registration (register)
After connecting, browser extensions and desktop apps should send aregister message to register node information:
Client → Server:
Unique node ID
Display name for the node (defaults to “Unknown Node”)
Node type:
extension or desktopOperating system name
Operating system version
Client application version
List of node capabilities, e.g.
["browser_control", "screenshot", "file_system"]List of available tools, e.g.
["click", "type", "screenshot", "navigate"]Maximum concurrent tasks (defaults to 3)
2. Heartbeat
Nodes send periodic heartbeats to maintain connection status. The server updates the node state in NodeManager. Client → Server:Node status:
online, busy, or offline (defaults to online)Number of tasks currently being executed (defaults to 0)
3. Ping/Pong Keepalive
All three client types (Extension, Desktop, Web) support ping/pong keepalive: Client → Server:For Extension and Desktop clients,
ping messages also trigger a NodeManager heartbeat update.4. Tool Calls (JSON-RPC 2.0)
The server sends JSON-RPC 2.0 requests to nodes via WebSocket to invoke tools. This follows the MCP (Model Context Protocol) format. Server → Client (Request):Request ID (UUID), used for matching responses
Always
tools/callName of the tool to call
Tool arguments
Associated session ID (optional)
MCP Result Content Types
Each item in theresult.content array can be:
| type | Fields | Description |
|---|---|---|
text | text | Text content |
image | data, mimeType | Base64-encoded image data |
When parsing responses, the server extracts
text, image, and _screenshot fields, and maps isError to a success status. Default timeout is 60 seconds.5. Legacy MCP Response (mcp_response)
6. Status Update
Clients can send status update messages:7. Workflow Execution
Web Client Requests Workflow List
Web Client → Server:workflows_list response from the extension is automatically relayed to the web client. If the extension is not connected:
Web Client Executes Workflow
Web Client → Server:task_complete message, the server notifies the web client:
Extension Workflow Completion
Extension → Server:Default timeout for workflow execution is 300 seconds (5 minutes).
Error Handling
Connection Rejection
The server closes the connection when required parameters are missing:| Code | Reason |
|---|---|
4001 | Missing client_id (Extension/Desktop) or user_id (Web) |
Disconnection Handling
When a WebSocket connection drops, the server automatically:- Removes the connection from ConnectionManager
- Unregisters the node from NodeManager (Extension/Desktop)
- Cleans up all pending requests
ConnectionManager API
ConnectionManager is the core singleton of the WebSocket Gateway, managing the lifecycle of all connections.
Connection Management
| Method | Description |
|---|---|
connect_extension(user_id, node_id, ws, register_request?) | Register browser extension connection, optionally with registration info |
connect_desktop(user_id, node_id, ws, register_request?) | Register desktop app connection, optionally with registration info |
connect_web(user_id, ws) | Register web client connection |
disconnect_extension(user_id, node_id) | Disconnect extension and unregister node |
disconnect_desktop(user_id, node_id) | Disconnect desktop and unregister node |
disconnect_web(user_id, ws) | Disconnect web client |
Connection Queries
| Method | Description |
|---|---|
is_extension_connected(user_id, node_id?) | Check extension connection status. Without node_id, checks if user has any extension connected |
is_desktop_connected(user_id, node_id?) | Check desktop app connection status |
get_extension_node_ids(user_id) | Get list of all Extension node IDs for a user |
get_desktop_node_ids(user_id) | Get list of all Desktop node IDs for a user |
get_websocket(user_id, node_id, node_type) | Get the WebSocket connection object for a specific node |
get_stats() | Get connection statistics |
Message Sending
| Method | Description |
|---|---|
send_to_extension(user_id, message, node_id?) | Send message to browser extension. Specify node_id for a specific node, otherwise sends to first available |
send_to_desktop(user_id, message, node_id?) | Send message to desktop app. Same logic as above |
send_to_web(user_id, message) | Send message to all web client connections for the user |
Tool Calls
| Method | Description |
|---|---|
call_extension_tool(user_id, tool_name, tool_args, session_id?, node_id?, timeout=60) | Call browser extension tool and wait for response |
call_desktop_tool(user_id, tool_name, tool_args, session_id?, node_id?, timeout=60) | Call desktop app tool and wait for response |
call_tool(user_id, node_id, node_type, tool_name, tool_args, session_id?, timeout=60) | Unified tool call method, automatically routes by node_type |
execute_workflow(user_id, workflow_id, variables?, timeout=300) | Execute a workflow on the browser extension |
resolve_request(request_id, result) | Resolve a pending request (called by the message handling loop) |
Connection Stats (get_stats)
Data Structures
Multi-Node Connection Model
ConnectionManager uses nested dictionaries to manage connections, supporting multiple nodes per user:- Extension / Desktop: Each user can connect multiple nodes (multiple devices), distinguished by
node_id - Web: Each user can have multiple web client connections (multiple tabs), stored in a Set
NodeType Enum
| Value | Description |
|---|---|
extension | Browser extension node |
desktop | Desktop application node |
NodeStatus Enum
| Value | Description |
|---|---|
online | Node is online and can accept tasks |
busy | Node is busy executing tasks |
offline | Node is offline |