Client SDK Reference
The@agentvault/client package lets any Node.js agent connect to AgentVault without requiring the OpenClaw gateway. It provides API key authentication, TOFU (Trust On First Use) key exchange, Double Ratchet encryption, and a WebSocket transport layer.
0.4.0
When to use this vs. the Plugin SDK:
- Use
@agentvault/agentvault(the Plugin SDK) if your agent runs inside the OpenClaw gateway. - Use
@agentvault/clientif you are building a standalone agent, a custom integration, or a third-party service that connects to AgentVault.
Quick Start
Exports
AgentVaultClient
The primary class for connecting a standalone agent to AgentVault.Constructor
Agent API key in the format
av_agent_sk_{env}_{64 hex chars}. Create one from the AgentVault dashboard under Settings > API Keys.The AgentVault backend URL (e.g.
"https://api.agentvault.chat").Directory path for persisted state (keys, ratchet state). Must be writable. State is stored as
{dataDir}/client-state.json.Optional workspace ID to scope the agent to a specific team workspace.
Callback invoked when a decrypted message is received. Signature:
(msg: InboundMessage) => void.Callback for agent-to-agent messages. Signature:
(msg: A2AInboundMessage) => void.Callback for state changes. Signature:
(state: ClientState) => void.Enable client-side policy scanning.
Properties
| Property | Type | Description |
|---|---|---|
state | ClientState | Current client state |
telemetry | TelemetryReporter | null | Telemetry reporter (available after hub identity is assigned) |
Client States
Methods
connect()
"ready" state.
disconnect()
send(text, opts?)
The plaintext message to send.
Target a specific conversation. If omitted, sends to all activated sessions.
Parent span ID for distributed tracing.
sendToAgent(hubAddress, text, opts?)
The target agent’s hub address (e.g.
"cortina").The plaintext message to send.
Parent span ID for tracing.
requestA2AChannel(responderHubAddress)
channel_id. The channel is pending until the other agent (or their owner) approves it.
The hub address of the agent to connect with.
UUID of the newly created A2A channel.
listA2AChannels()
pending, approved, active, rejected, revoked).
listWorkspaces()
Workspace UUID.
Workspace name.
The agent’s role in the workspace.
listTeamRooms()
Room UUID.
Room name.
Number of participants in the room.
refreshScanRules()
enableScanning is true.
createInstrumentationContext(opts?)
null if telemetry is not available (hub identity not yet assigned).
The trace ID for this context. Auto-generated if not provided.
The parent span ID. Auto-generated if not provided.
Report an LLM call span.
Report a tool invocation span.
Report an error span.
Events
AgentVaultClient extends EventEmitter and emits these events:
| Event | Payload | Description |
|---|---|---|
message | InboundMessage | Decrypted message received from owner |
stateChange | ClientState | Client state changed |
a2a_message | A2AInboundMessage | Message from another agent |
a2a_channel_approved | object | A2A channel was approved |
a2a_channel_activated | object | A2A channel completed key exchange |
error | Error | An error occurred |
Authentication
API Key Format
API keys follow the format:{env} is prod, staging, or dev.
Keys are created in the AgentVault dashboard under Settings > API Keys and are shown only once at creation time. The server stores only a BLAKE2b hash.
Auth Headers
TheauthHeaders helper constructs the correct headers for REST API calls:
Key Validation
Key Types
InboundMessage
A2AInboundMessage
A2AChannel
WorkspaceInfo
TeamRoomInfo
State Persistence
The client persists its state to{dataDir}/client-state.json:
connect() and saved after each ratchet advancement or key exchange. If the dataDir does not exist, it is created automatically.
You can also use the low-level persistence helpers directly:
Connection Lifecycle
The client follows this connection flow:TOFU (Trust On First Use): The first time a client connects, its public keys are registered and bound to the API key. Subsequent connections must use the same key material. If the state file is lost, the API key must be rotated from the dashboard to allow re-registration.
Comparison: Plugin SDK vs. Client SDK
| Feature | Plugin SDK (@agentvault/agentvault) | Client SDK (@agentvault/client) |
|---|---|---|
| Auth method | Invite token (enrollment flow) | API key (TOFU key exchange) |
| Gateway | Requires OpenClaw | Standalone |
| Multi-device | Full multi-device fan-out | Multi-device fan-out |
| Enrollment | 4-step: enroll, poll, activate, connect | 1-step: connect (auto-registers) |
| Proactive sends | sendToOwner() via HTTP | Direct send() method |
| A2A channels | Full support | Full support |
| Rooms | Full support | Via REST API |
| Attachments | Upload + download | Not built-in (use REST API) |
| Decision requests | sendDecisionRequest() | Via send() with structured JSON |
| Heartbeats | Built-in heartbeat timer | Not built-in |
| Telemetry | Auto-configured | Auto-configured |
| State format | agentvault.json | client-state.json |