Openclaw Deployment Overview
OpenClaw uses VAGUS through natural language. The user should not need terminal commands to install, pair, or use the phone capabilities. The agent retrieves files, installs dependencies, pairs with the app, and runs MCP operations autonomously.
User interface: natural-language prompts in OpenClaw
Agent execution: command + MCP orchestration under the hood
CLI Entry: scripts/vagus-connect.js
Session Store: ~/.openclaw/vagus-session.json
Pair Endpoint: https://relay.withvagus.com/pair
WebSocket Relay: wss://relay.withvagus.com/connect/<session_token>
Natural-Language Flow
Primary UX is conversational. A typical user flow:
- User asks OpenClaw to install VAGUS from the repository URL.
- Agent fetches skill files, installs Node dependency, and registers the skill.
- Agent asks user for the code from the VAGUS Android app.
- Agent pairs, verifies capabilities, and confirms connection in plain language.
- User asks for actions in natural language (notify, open URL, send SMS, create event, read context).
Pairing is a one-time bootstrap. Subsequent requests reuse the saved session token until expired or revoked.
Prompt Cookbook
| User Says | Expected Agent Behavior |
|---|---|
Install VAGUS from https://github.com/vagus-mcp/openclaw-skill |
Install skill package, run dependency install, prompt for pairing code. |
Pair using code 584821 |
Call pair flow, persist session token, announce available resources/tools. |
Send a test notification |
Invoke notify, return success/failure naturally. |
Send an SMS to +15556667777 |
Invoke sms/send; handle approval prompts if required. |
Create a calendar event Sunday 3pm Event Name |
Map time intent to epoch ms, call calendar/create_event, report event result. |
Start screen and location subscriptions |
Run long-lived subscriptions, stream updates, and keep both active. |
This prompt-first contract is the primary documentation surface for OpenClaw operators.
User Journey
1. Install and Pair
User: Install VAGUS from https://github.com/vagus-mcp/openclaw-skill
Agent: I installed the skill. Open the VAGUS app and share your pairing code.
User: 584821
Agent: Paired successfully. I can now access phone resources and tools.
2. Ask for Context
User: Are you tracking my screen state?
Agent: Yes. Your screen is currently on and unlocked.
User: Start tracking location too.
Agent: Done. I am now streaming screen and location context.
3. Trigger Actions
User: Send a test notification.
Agent: Sent.
User: Open withvagus.com.
Agent: Opened on your phone.
User: Add an event Sunday 3pm called Event Name.
Agent: Created the event.
4. Recover from Failures
User: Send the SMS again.
Agent: The device approval timed out. Please approve on your phone and I will retry once.
User: Retry.
Agent: Sent successfully.
These transcripts are the intended user-facing interaction model in OpenClaw. CLI details remain internal.
Architecture
| Component | Responsibility | Key Behavior |
|---|---|---|
vagus-connect.js |
CLI dispatcher and JSONL output contract. | Maps subcommands to session ops and normalizes error codes. |
lib/mcp-session.js |
MCP protocol state machine. | Initialize handshake, request/response correlation, list/read/call/subscribe. |
lib/ws-transport.js |
WebSocket transport and liveness checks. | Ping every 30s; terminate on missing pong after 10s. |
lib/session-store.js |
Persist and load token metadata. | Reads/writes JSON to ~/.openclaw/vagus-session.json. |
lib/subscription-manager.js |
Tracks active subscriptions for re-subscribe flows. | Best-effort replay of subscribe calls after reconnect. |
Protocol Lifecycle
1. Pair
Client posts pairing code and receives session token.
POST https://relay.withvagus.com/pair
{"code":"ABC123"}
2. Connect + Initialize
Client opens WSS with the token and runs MCP initialization. Implementation sends compatibility variants:
initialized, notifications/initialized, and an initialized request.
connect WSS -> initialize -> initialized notifications
-> resources/list + tools/list
MCP responses and notifications now include request correlation metadata at:
metadata.requestId. This is emitted by the server for request/notification lineage.
{
"jsonrpc": "2.0",
"id": 2,
"metadata": {
"requestId": "43818824:resources/read:5545a8fa214dd67e:2c570c8b7e66e561"
},
"result": { "contents": [ ... ] }
}
3. Operate
Client executes reads, tool calls, or subscriptions. All stdout is JSONL for machine parsing.
Agent Execution Contract (Internal)
The following command interface is internal to agent implementation and diagnostics. End users should interact via natural language prompts.
Base invocation used by agent runtime:
node {baseDir}/scripts/vagus-connect.js <command> [args]
| Command | Arguments | Output Shape |
|---|---|---|
pair | <code> | paired then capabilities |
connect | none | connected then capabilities |
status | none | status object |
read | <uri> | resource object |
subscribe | <uri> | subscribed, then update stream |
unsubscribe | <uri> | unsubscribed |
call | <tool> '<json>' | result object |
list-resources | none | resources array |
list-tools | none | tools array |
disconnect | none | disconnected and deletes local session file |
Streaming Model
Subscriptions are long-running agent-managed processes. OpenClaw should keep each subscription process alive, parse JSONL updates, and stop streams only when user intent changes.
node {baseDir}/scripts/vagus-connect.js subscribe vagus://device/screen
{"type":"subscribed","uri":"vagus://device/screen"}
{"type":"update","uri":"vagus://device/screen","data":{"screen_on":true,"locked":false,"last_event":"init","ts":1772036194947}}
On reconnect, server may emit session_reconnect and replay buffered updates before resuming live events.
Raw MCP notification envelopes also include metadata.requestId.
User-facing phrasing should remain natural: for example, "I am now tracking your screen and location state."
OpenClaw JSONL output is normalized and includes MCP correlation metadata under mcp for
operational commands and streamed updates. Capture raw MCP frames only if you need full envelopes.
Resources
Core URI groups:
- Session:
vagus://session/info - Sensors:
vagus://sensors/motion,activity,activity_recognition,location,environment - Inference:
vagus://inference/attention,indoor_confidence,sleep_likelihood,notification_timing - Device:
vagus://device/connectivity,screen,battery,clipboard,notifications
For inference URIs, subscription mode generally provides better quality than cold one-shot reads.
node {baseDir}/scripts/vagus-connect.js read vagus://inference/attention
node {baseDir}/scripts/vagus-connect.js subscribe vagus://sensors/location
Tools
Call pattern:
node {baseDir}/scripts/vagus-connect.js call <tool-name> '<json-params>'
| Tool | Purpose | Required Params |
|---|---|---|
notify | Push local phone notification. | title, body |
speak | TTS playback on device. | text |
sms/send | Send SMS message. | to, body |
intent/open_url | Open URL in browser. | url |
calendar/create_event | Create calendar event. | title |
clipboard/set | Write clipboard text. | content |
haptic/pulse | Single haptic pulse. | none |
haptic/pattern | Pattern vibration. | none |
agent/set_name | Set device-side agent name. | name |
Validated Examples
node {baseDir}/scripts/vagus-connect.js call sms/send '{"to":"+15556667777","body":"Test message from VAGUS OpenClaw"}'
node {baseDir}/scripts/vagus-connect.js call intent/open_url '{"url":"https://withvagus.com"}'
node {baseDir}/scripts/vagus-connect.js call calendar/create_event '{"title":"Event Name","startTimeMs":1771772400000,"endTimeMs":1771776000000,"allDay":false}'
User Permissions (Server-Side)
Permission state is controlled by the user in the VAGUS Android app (server side), not by OpenClaw. OpenClaw can request reads/tool calls, but execution depends on enabled modules and approval outcomes.
| Control | Set By | Effect |
|---|---|---|
| Module/capability toggles | User in VAGUS app | Determines which resources/tools are exposed. |
| Runtime tool approvals | User in VAGUS app prompt | Approves or denies sensitive actions. |
| Agent identity label | agent/set_name + app context | Affects approval UI/session metadata context. |
If blocked, agent messaging should be explicit: ask the user to enable permission or approve on-device, then retry once.
Reliability and Timeouts
| Mechanism | Current Value | Where Implemented |
|---|---|---|
| MCP request timeout | 22000ms | lib/mcp-session.js |
| Initialize timeout | 20000ms | lib/mcp-session.js |
| Heartbeat interval | 30000ms | lib/ws-transport.js |
| Pong deadline | 10000ms | lib/ws-transport.js |
If no pong is received within the heartbeat deadline, the socket is force-terminated and upper layers must re-establish connection state.
Error Codes and Handling
| Code | Typical Cause | Action |
|---|---|---|
NO_COMMAND | Missing subcommand. | Use documented command shape. |
NO_SESSION | No local session file. | Run pair. |
PAIR_FAILED | Pair endpoint failed/rejected. | Check code and app connectivity. |
SESSION_EXPIRED | Token invalid/expired. | Delete session file, then re-pair. |
CONNECT_FAILED | WSS connection/initialize failure. | Check relay/network availability. |
BAD_JSON | Malformed JSON args for call. | Fix quoting and JSON payload. |
READ_FAILED | Read failed or unsupported URI. | Check active modules in session/info. |
CALL_FAILED | Tool call timeout or runtime failure. | Retry once, then inspect device approvals. |
PERMISSION_DENIED | Capability disabled or approval denied. | Enable permission or re-approve in app. |
FATAL | Unhandled client exception. | Capture logs and restart command. |
Operational Runbooks
Natural-Language Recovery Prompts
Your session expired. Please open VAGUS and share a new pairing code.I can’t reach the relay right now. Please confirm your phone has internet and VAGUS is running.This action needs permission in VAGUS. Please enable it, then I’ll retry once.
Session Repair
rm ~/.openclaw/vagus-session.json
node {baseDir}/scripts/vagus-connect.js pair <NEW_CODE>
node {baseDir}/scripts/vagus-connect.js status
Connectivity Probe
node {baseDir}/scripts/vagus-connect.js status
node {baseDir}/scripts/vagus-connect.js read vagus://session/info
node {baseDir}/scripts/vagus-connect.js list-tools
Permission Probe
node {baseDir}/scripts/vagus-connect.js call notify '{"title":"Permission Check","body":"Testing notify permission"}'
node {baseDir}/scripts/vagus-connect.js read vagus://device/notifications
Detailed schema references remain in references/mcp-resources.md,
references/mcp-tools.md, and references/troubleshooting.md.