openclaw-client 1.1.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -5
- package/dist/client.d.ts +51 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +89 -14
- package/dist/types.d.ts +170 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +123 -14
- package/src/protocol.schema.json +801 -79
- package/src/types.ts +198 -17
package/README.md
CHANGED
|
@@ -51,6 +51,11 @@ interface OpenClawClientConfig {
|
|
|
51
51
|
clientVersion?: string; // Client version (default: '1.0.0')
|
|
52
52
|
platform?: string; // Platform name (default: 'web')
|
|
53
53
|
mode?: string; // Client mode (default: 'ui')
|
|
54
|
+
connectTimeoutMs?: number; // Timeout for connect handshake (default: 120000)
|
|
55
|
+
requestTimeoutMs?: number; // Timeout for RPC requests (default: 30000)
|
|
56
|
+
connectParams?: Partial<ConnectParams> // Static object, or...
|
|
57
|
+
| ((challenge: { nonce: string; ts: number }) => // ...function receiving challenge
|
|
58
|
+
Partial<ConnectParams> | Promise<Partial<ConnectParams>>);
|
|
54
59
|
}
|
|
55
60
|
```
|
|
56
61
|
|
|
@@ -78,9 +83,13 @@ interface OpenClawClientConfig {
|
|
|
78
83
|
- `patchSession(params): Promise<any>` - Patch session
|
|
79
84
|
- `resetSession(params): Promise<any>` - Reset session
|
|
80
85
|
- `compactSession(params): Promise<any>` - Compact session
|
|
86
|
+
- `getSessionsUsage(params?): Promise<any>` - Get session usage
|
|
81
87
|
|
|
82
88
|
**Agents**
|
|
83
89
|
- `listAgents(params?): Promise<AgentsListResult>` - List available agents
|
|
90
|
+
- `createAgent(params): Promise<AgentsCreateResult>` - Create agent
|
|
91
|
+
- `updateAgent(params): Promise<AgentsUpdateResult>` - Update agent
|
|
92
|
+
- `deleteAgent(params): Promise<AgentsDeleteResult>` - Delete agent
|
|
84
93
|
- `getAgentIdentity(params?): Promise<AgentIdentityResult>` - Get agent identity
|
|
85
94
|
- `sendToAgent(params): Promise<any>` - Send a message to agent
|
|
86
95
|
- `waitForAgent(params): Promise<any>` - Wait for agent run to complete
|
|
@@ -110,10 +119,11 @@ interface OpenClawClientConfig {
|
|
|
110
119
|
- `cancelWizard(params): Promise<any>` - Cancel wizard
|
|
111
120
|
- `getWizardStatus(params): Promise<WizardStatusResult>` - Get wizard status
|
|
112
121
|
|
|
113
|
-
**Channels**
|
|
122
|
+
**Channels & Talk**
|
|
114
123
|
- `getChannelsStatus(params?): Promise<ChannelsStatusResult>` - Get channels status
|
|
115
124
|
- `logoutChannel(params): Promise<any>` - Logout from channel
|
|
116
125
|
- `setTalkMode(params): Promise<any>` - Set talk mode
|
|
126
|
+
- `getTalkConfig(params?): Promise<TalkConfigResult>` - Get talk config
|
|
117
127
|
|
|
118
128
|
**Authentication**
|
|
119
129
|
- `startWebLogin(params?): Promise<any>` - Start web login
|
|
@@ -146,6 +156,7 @@ interface OpenClawClientConfig {
|
|
|
146
156
|
- `listDevicePairings(params?): Promise<any>` - List device pairing requests
|
|
147
157
|
- `approveDevicePairing(params): Promise<any>` - Approve device pairing
|
|
148
158
|
- `rejectDevicePairing(params): Promise<any>` - Reject device pairing
|
|
159
|
+
- `removeDevicePairing(params): Promise<any>` - Remove paired device
|
|
149
160
|
- `rotateDeviceToken(params): Promise<any>` - Rotate device token
|
|
150
161
|
- `revokeDeviceToken(params): Promise<any>` - Revoke device token
|
|
151
162
|
|
|
@@ -159,6 +170,7 @@ interface OpenClawClientConfig {
|
|
|
159
170
|
- `listNodes(params?): Promise<any>` - List nodes
|
|
160
171
|
- `describeNode(params): Promise<any>` - Describe node
|
|
161
172
|
- `invokeNode(params): Promise<any>` - Invoke node command
|
|
173
|
+
- `testPush(params): Promise<PushTestResult>` - Test push notification to node
|
|
162
174
|
|
|
163
175
|
**Logs**
|
|
164
176
|
- `getLogTail(params?): Promise<LogsTailResult>` - Get log tail
|
|
@@ -191,17 +203,60 @@ Environment variables:
|
|
|
191
203
|
- `OPENCLAW_GATEWAY_URL` - Gateway URL (default: `http://localhost:18789`)
|
|
192
204
|
- `OPENCLAW_TOKEN` - Authentication token
|
|
193
205
|
|
|
194
|
-
## Type Generation
|
|
206
|
+
## Type Generation & Client Wrapper Maintenance
|
|
195
207
|
|
|
196
|
-
This package
|
|
208
|
+
This package uses a deterministic process to keep types and client method wrappers in sync with the OpenClaw protocol schema.
|
|
197
209
|
|
|
198
|
-
|
|
210
|
+
### Step 1: Update the schema
|
|
211
|
+
|
|
212
|
+
Place the latest `protocol.schema.json` from the OpenClaw Gateway into `src/protocol.schema.json`.
|
|
213
|
+
|
|
214
|
+
### Step 2: Regenerate types
|
|
199
215
|
|
|
200
216
|
```bash
|
|
201
217
|
npm run generate:types
|
|
202
218
|
```
|
|
203
219
|
|
|
204
|
-
|
|
220
|
+
This runs `src/generate-openclaw-types.ts` which uses `json-schema-to-typescript` to compile every definition in the schema into TypeScript interfaces. The output is written to `src/types.ts` (auto-generated, do not edit manually).
|
|
221
|
+
|
|
222
|
+
### Step 3: Update client method wrappers
|
|
223
|
+
|
|
224
|
+
The method wrappers in `src/client.ts` follow a deterministic pattern derived from the type names in `src/types.ts`:
|
|
225
|
+
|
|
226
|
+
1. **Find all `*Params` types** - Each `*Params` interface represents an RPC method.
|
|
227
|
+
2. **Derive the method name** - Convert the type name to a dot-separated RPC method name:
|
|
228
|
+
- `ConfigGetParams` → `config.get`
|
|
229
|
+
- `SessionsListParams` → `sessions.list`
|
|
230
|
+
- `AgentsFilesGetParams` → `agents.files.get`
|
|
231
|
+
- `ExecApprovalsNodeSetParams` → `exec.approvals.node.set`
|
|
232
|
+
- Top-level methods like `SendParams`, `PollParams`, `WakeParams` → `send`, `poll`, `wake`
|
|
233
|
+
3. **Match result types** - If a corresponding `*Result` type exists (e.g. `AgentsListResult` for `AgentsListParams`), use it as the return type. Otherwise use `Promise<any>`.
|
|
234
|
+
4. **Choose a wrapper method name** - Use a readable camelCase name (e.g. `listSessions`, `getConfig`, `deleteAgent`).
|
|
235
|
+
5. **Default empty params** - If the `*Params` interface has no required fields (e.g. `interface ConfigGetParams {}`), default the parameter to `= {}`.
|
|
236
|
+
6. **Import and add** - Import the new Params/Result types at the top of `client.ts` and add the wrapper method.
|
|
237
|
+
|
|
238
|
+
**Skipped types:** Some `*Params` types are not RPC request methods but are used for node-side responses or event payloads (e.g. `NodeInvokeResultParams`, `NodeEventParams`). These are skipped.
|
|
239
|
+
|
|
240
|
+
### Full update workflow
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# 1. Drop in updated schema
|
|
244
|
+
cp /path/to/new/protocol.schema.json src/protocol.schema.json
|
|
245
|
+
|
|
246
|
+
# 2. Regenerate types
|
|
247
|
+
npm run generate:types
|
|
248
|
+
|
|
249
|
+
# 3. Update client wrappers (compare types.ts *Params exports against client.ts imports)
|
|
250
|
+
# - Add imports for any new *Params/*Result types
|
|
251
|
+
# - Add wrapper methods following the pattern above
|
|
252
|
+
# - Verify no existing types were removed/renamed
|
|
253
|
+
|
|
254
|
+
# 4. Build and verify
|
|
255
|
+
npm run build
|
|
256
|
+
|
|
257
|
+
# 5. Publish
|
|
258
|
+
npm publish
|
|
259
|
+
```
|
|
205
260
|
|
|
206
261
|
## Development
|
|
207
262
|
|
|
@@ -219,6 +274,39 @@ npm run build
|
|
|
219
274
|
npm publish
|
|
220
275
|
```
|
|
221
276
|
|
|
277
|
+
## Changelog
|
|
278
|
+
|
|
279
|
+
### 2.0.1
|
|
280
|
+
|
|
281
|
+
**Bug Fixes**
|
|
282
|
+
|
|
283
|
+
- **Challenge nonce now passed to `connectParams`** - The challenge received during the connect handshake was being ignored (`_challenge`). `connectParams` can now be a function that receives the challenge `{ nonce, ts }`, allowing callers to sign the nonce into `device.nonce`. Static objects still work as before (backwards compatible).
|
|
284
|
+
|
|
285
|
+
### 2.0.0
|
|
286
|
+
|
|
287
|
+
**Breaking Changes**
|
|
288
|
+
|
|
289
|
+
- **Connect handshake protocol** - The client now implements a challenge-response handshake. On connect, the gateway sends a `connect.challenge` event with a nonce before the client sends its `connect` request. This requires a compatible gateway version.
|
|
290
|
+
|
|
291
|
+
**New Features**
|
|
292
|
+
|
|
293
|
+
- **Configurable timeouts** - New `connectTimeoutMs` (default 120s) and `requestTimeoutMs` (default 30s) config options.
|
|
294
|
+
- **Connect params override** - New `connectParams` config option to merge additional fields into the handshake request (e.g. `device`, `caps`, `commands`).
|
|
295
|
+
- **New API methods:**
|
|
296
|
+
- `createAgent` / `updateAgent` / `deleteAgent` - Full agent CRUD
|
|
297
|
+
- `getSessionsUsage` - Session usage stats
|
|
298
|
+
- `getTalkConfig` - Talk configuration
|
|
299
|
+
- `removeDevicePairing` - Remove a paired device
|
|
300
|
+
- `testPush` - Test push notifications to a node
|
|
301
|
+
|
|
302
|
+
### 1.1.1
|
|
303
|
+
|
|
304
|
+
- Documentation updates.
|
|
305
|
+
|
|
306
|
+
### 1.1.0
|
|
307
|
+
|
|
308
|
+
- Initial public release with full Gateway RPC coverage.
|
|
309
|
+
|
|
222
310
|
## License
|
|
223
311
|
|
|
224
312
|
MIT
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentIdentityParams, AgentIdentityResult, AgentParams, AgentsFilesGetParams, AgentsFilesGetResult, AgentsFilesListParams, AgentsFilesListResult, AgentsFilesSetParams, AgentsFilesSetResult, AgentsListParams, AgentsListResult, AgentWaitParams, ChannelsLogoutParams, ChannelsStatusParams, ChannelsStatusResult, ChatAbortParams, ChatHistoryParams, ChatInjectParams, ChatSendParams, ConfigApplyParams, ConfigGetParams, ConfigPatchParams, ConfigSchemaParams, ConfigSchemaResponse, ConfigSetParams, ConnectParams, CronAddParams, CronJob, CronListParams, CronRemoveParams, CronRunLogEntry, CronRunParams, CronRunsParams, CronStatusParams, CronUpdateParams, DevicePairApproveParams, DevicePairListParams, DevicePairRejectParams, DeviceTokenRevokeParams, DeviceTokenRotateParams, EventFrame, ExecApprovalRequestParams, ExecApprovalResolveParams, ExecApprovalsGetParams, ExecApprovalsNodeGetParams, ExecApprovalsNodeSetParams, ExecApprovalsSetParams, ExecApprovalsSnapshot, HelloOk, LogsTailParams, LogsTailResult, ModelsListParams, ModelsListResult, NodeDescribeParams, NodeInvokeParams, NodeListParams, NodePairApproveParams, NodePairListParams, NodePairRejectParams, NodePairRequestParams, NodePairVerifyParams, NodeRenameParams, PollParams, SendParams, SessionsCompactParams, SessionsDeleteParams, SessionsListParams, SessionsPatchParams, SessionsPreviewParams, SessionsResetParams, SessionsResolveParams, SkillsBinsParams, SkillsBinsResult, SkillsInstallParams, SkillsStatusParams, SkillsUpdateParams, TalkModeParams, UpdateRunParams, WakeParams, WebLoginStartParams, WebLoginWaitParams, WizardCancelParams, WizardNextParams, WizardNextResult, WizardStartParams, WizardStartResult, WizardStatusParams, WizardStatusResult } from './types';
|
|
1
|
+
import type { AgentIdentityParams, AgentIdentityResult, AgentParams, AgentsCreateParams, AgentsCreateResult, AgentsDeleteParams, AgentsDeleteResult, AgentsFilesGetParams, AgentsFilesGetResult, AgentsFilesListParams, AgentsFilesListResult, AgentsFilesSetParams, AgentsFilesSetResult, AgentsListParams, AgentsListResult, AgentsUpdateParams, AgentsUpdateResult, AgentWaitParams, ChannelsLogoutParams, ChannelsStatusParams, ChannelsStatusResult, ChatAbortParams, ChatHistoryParams, ChatInjectParams, ChatSendParams, ConfigApplyParams, ConfigGetParams, ConfigPatchParams, ConfigSchemaParams, ConfigSchemaResponse, ConfigSetParams, ConnectParams, CronAddParams, CronJob, CronListParams, CronRemoveParams, CronRunLogEntry, CronRunParams, CronRunsParams, CronStatusParams, CronUpdateParams, DevicePairApproveParams, DevicePairListParams, DevicePairRejectParams, DevicePairRemoveParams, DeviceTokenRevokeParams, DeviceTokenRotateParams, EventFrame, ExecApprovalRequestParams, ExecApprovalResolveParams, ExecApprovalsGetParams, ExecApprovalsNodeGetParams, ExecApprovalsNodeSetParams, ExecApprovalsSetParams, ExecApprovalsSnapshot, HelloOk, LogsTailParams, LogsTailResult, ModelsListParams, ModelsListResult, NodeDescribeParams, NodeInvokeParams, NodeListParams, NodePairApproveParams, NodePairListParams, NodePairRejectParams, NodePairRequestParams, NodePairVerifyParams, NodeRenameParams, PollParams, PushTestParams, PushTestResult, SendParams, SessionsCompactParams, SessionsDeleteParams, SessionsListParams, SessionsPatchParams, SessionsPreviewParams, SessionsResetParams, SessionsResolveParams, SessionsUsageParams, SkillsBinsParams, SkillsBinsResult, SkillsInstallParams, SkillsStatusParams, SkillsUpdateParams, TalkConfigParams, TalkConfigResult, TalkModeParams, UpdateRunParams, WakeParams, WebLoginStartParams, WebLoginWaitParams, WizardCancelParams, WizardNextParams, WizardNextResult, WizardStartParams, WizardStartResult, WizardStatusParams, WizardStatusResult } from './types';
|
|
2
2
|
export interface OpenClawClientConfig {
|
|
3
3
|
gatewayUrl: string;
|
|
4
4
|
token: string;
|
|
@@ -6,6 +6,19 @@ export interface OpenClawClientConfig {
|
|
|
6
6
|
clientVersion?: string;
|
|
7
7
|
platform?: string;
|
|
8
8
|
mode?: ConnectParams['client']['mode'];
|
|
9
|
+
/** Timeout in ms for the connect handshake (default: 120000).
|
|
10
|
+
* Set this higher if device approval may take a while. */
|
|
11
|
+
connectTimeoutMs?: number;
|
|
12
|
+
/** Timeout in ms for regular RPC requests (default: 30000). */
|
|
13
|
+
requestTimeoutMs?: number;
|
|
14
|
+
/** Additional ConnectParams fields to merge into the handshake request
|
|
15
|
+
* (e.g. `device` for device identity, `caps`, `commands`).
|
|
16
|
+
* Can be a static object or a function that receives the challenge
|
|
17
|
+
* (useful for signing the nonce into `device.nonce`). */
|
|
18
|
+
connectParams?: Partial<ConnectParams> | ((challenge: {
|
|
19
|
+
nonce: string;
|
|
20
|
+
ts: number;
|
|
21
|
+
}) => Partial<ConnectParams> | Promise<Partial<ConnectParams>>);
|
|
9
22
|
}
|
|
10
23
|
export type EventListener = (event: EventFrame) => void;
|
|
11
24
|
export declare class OpenClawClient {
|
|
@@ -18,7 +31,13 @@ export declare class OpenClawClient {
|
|
|
18
31
|
private connectionId;
|
|
19
32
|
constructor(config: OpenClawClientConfig);
|
|
20
33
|
/**
|
|
21
|
-
* Connect to the OpenClaw Gateway and perform handshake
|
|
34
|
+
* Connect to the OpenClaw Gateway and perform handshake.
|
|
35
|
+
*
|
|
36
|
+
* The protocol flow is:
|
|
37
|
+
* 1. Open WebSocket connection
|
|
38
|
+
* 2. Gateway sends a `connect.challenge` event with a nonce
|
|
39
|
+
* 3. Client responds with a `connect` request (including auth token)
|
|
40
|
+
* 4. Gateway replies with `hello-ok` containing server info and snapshot
|
|
22
41
|
*/
|
|
23
42
|
connect(): Promise<HelloOk>;
|
|
24
43
|
/**
|
|
@@ -38,7 +57,8 @@ export declare class OpenClawClient {
|
|
|
38
57
|
*/
|
|
39
58
|
addEventListener(listener: EventListener): () => void;
|
|
40
59
|
/**
|
|
41
|
-
* Perform the connection handshake
|
|
60
|
+
* Perform the connection handshake after receiving the challenge.
|
|
61
|
+
* Uses connectTimeoutMs (default 120s) since device approval may take a while.
|
|
42
62
|
*/
|
|
43
63
|
private handshake;
|
|
44
64
|
/**
|
|
@@ -101,6 +121,18 @@ export declare class OpenClawClient {
|
|
|
101
121
|
* List available agents
|
|
102
122
|
*/
|
|
103
123
|
listAgents(params?: AgentsListParams): Promise<AgentsListResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Create agent
|
|
126
|
+
*/
|
|
127
|
+
createAgent(params: AgentsCreateParams): Promise<AgentsCreateResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Update agent
|
|
130
|
+
*/
|
|
131
|
+
updateAgent(params: AgentsUpdateParams): Promise<AgentsUpdateResult>;
|
|
132
|
+
/**
|
|
133
|
+
* Delete agent
|
|
134
|
+
*/
|
|
135
|
+
deleteAgent(params: AgentsDeleteParams): Promise<AgentsDeleteResult>;
|
|
104
136
|
/**
|
|
105
137
|
* Get agent identity
|
|
106
138
|
*/
|
|
@@ -141,6 +173,10 @@ export declare class OpenClawClient {
|
|
|
141
173
|
* Compact session
|
|
142
174
|
*/
|
|
143
175
|
compactSession(params: SessionsCompactParams): Promise<any>;
|
|
176
|
+
/**
|
|
177
|
+
* Get session usage
|
|
178
|
+
*/
|
|
179
|
+
getSessionsUsage(params?: SessionsUsageParams): Promise<any>;
|
|
144
180
|
/**
|
|
145
181
|
* Send a message to agent
|
|
146
182
|
*/
|
|
@@ -181,6 +217,10 @@ export declare class OpenClawClient {
|
|
|
181
217
|
* Set talk mode
|
|
182
218
|
*/
|
|
183
219
|
setTalkMode(params: TalkModeParams): Promise<any>;
|
|
220
|
+
/**
|
|
221
|
+
* Get talk config
|
|
222
|
+
*/
|
|
223
|
+
getTalkConfig(params?: TalkConfigParams): Promise<TalkConfigResult>;
|
|
184
224
|
/**
|
|
185
225
|
* Get channels status
|
|
186
226
|
*/
|
|
@@ -285,6 +325,10 @@ export declare class OpenClawClient {
|
|
|
285
325
|
* Reject device pairing
|
|
286
326
|
*/
|
|
287
327
|
rejectDevicePairing(params: DevicePairRejectParams): Promise<any>;
|
|
328
|
+
/**
|
|
329
|
+
* Remove paired device
|
|
330
|
+
*/
|
|
331
|
+
removeDevicePairing(params: DevicePairRemoveParams): Promise<any>;
|
|
288
332
|
/**
|
|
289
333
|
* Rotate device token
|
|
290
334
|
*/
|
|
@@ -345,6 +389,10 @@ export declare class OpenClawClient {
|
|
|
345
389
|
* Invoke node command
|
|
346
390
|
*/
|
|
347
391
|
invokeNode(params: NodeInvokeParams): Promise<any>;
|
|
392
|
+
/**
|
|
393
|
+
* Test push notification to node
|
|
394
|
+
*/
|
|
395
|
+
testPush(params: PushTestParams): Promise<PushTestResult>;
|
|
348
396
|
/**
|
|
349
397
|
* Update and run
|
|
350
398
|
*/
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,aAAa,EACb,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe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AAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1D;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAI5D;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/D;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAItD;;;OAGG;IACG,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;CAG9D"}
|
package/dist/client.js
CHANGED
|
@@ -17,7 +17,13 @@ export class OpenClawClient {
|
|
|
17
17
|
this.config = config;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Connect to the OpenClaw Gateway and perform handshake
|
|
20
|
+
* Connect to the OpenClaw Gateway and perform handshake.
|
|
21
|
+
*
|
|
22
|
+
* The protocol flow is:
|
|
23
|
+
* 1. Open WebSocket connection
|
|
24
|
+
* 2. Gateway sends a `connect.challenge` event with a nonce
|
|
25
|
+
* 3. Client responds with a `connect` request (including auth token)
|
|
26
|
+
* 4. Gateway replies with `hello-ok` containing server info and snapshot
|
|
21
27
|
*/
|
|
22
28
|
async connect() {
|
|
23
29
|
if (this.connected && this.ws?.readyState === WebSocket.OPEN) {
|
|
@@ -26,23 +32,44 @@ export class OpenClawClient {
|
|
|
26
32
|
// Create WebSocket connection
|
|
27
33
|
const WS = getWebSocketConstructor();
|
|
28
34
|
this.ws = new WS(this.config.gatewayUrl);
|
|
29
|
-
// Wait for connection to open
|
|
30
|
-
await new Promise((resolve, reject) => {
|
|
35
|
+
// Wait for connection to open and receive the challenge event
|
|
36
|
+
const challenge = await new Promise((resolve, reject) => {
|
|
31
37
|
if (!this.ws) {
|
|
32
38
|
reject(new Error('WebSocket not initialized'));
|
|
33
39
|
return;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const timeout = setTimeout(() => {
|
|
42
|
+
reject(new Error('Connection timeout: no challenge received'));
|
|
43
|
+
}, 15000);
|
|
44
|
+
this.ws.onerror = (error) => {
|
|
45
|
+
clearTimeout(timeout);
|
|
46
|
+
reject(error);
|
|
47
|
+
};
|
|
48
|
+
this.ws.onmessage = (event) => {
|
|
49
|
+
try {
|
|
50
|
+
const frame = JSON.parse(event.data);
|
|
51
|
+
if (frame.type === 'event' && frame.event === 'connect.challenge') {
|
|
52
|
+
clearTimeout(timeout);
|
|
53
|
+
resolve(frame.payload);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
reject(new Error('Failed to parse challenge frame'));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.ws.onopen = () => {
|
|
62
|
+
// Wait for the challenge event after connection opens
|
|
63
|
+
};
|
|
37
64
|
});
|
|
38
|
-
// Set up message handler
|
|
65
|
+
// Set up message handler for subsequent messages
|
|
39
66
|
if (this.ws) {
|
|
40
67
|
this.ws.onmessage = (event) => this.handleMessage(event);
|
|
41
68
|
this.ws.onclose = () => this.handleClose();
|
|
42
69
|
this.ws.onerror = (error) => this.handleError(error);
|
|
43
70
|
}
|
|
44
|
-
// Perform handshake
|
|
45
|
-
const result = await this.handshake();
|
|
71
|
+
// Perform handshake (send connect request after receiving challenge)
|
|
72
|
+
const result = await this.handshake(challenge);
|
|
46
73
|
this.connected = true;
|
|
47
74
|
this.connectionId = result.server.connId;
|
|
48
75
|
return result;
|
|
@@ -88,9 +115,13 @@ export class OpenClawClient {
|
|
|
88
115
|
};
|
|
89
116
|
}
|
|
90
117
|
/**
|
|
91
|
-
* Perform the connection handshake
|
|
118
|
+
* Perform the connection handshake after receiving the challenge.
|
|
119
|
+
* Uses connectTimeoutMs (default 120s) since device approval may take a while.
|
|
92
120
|
*/
|
|
93
|
-
async handshake() {
|
|
121
|
+
async handshake(challenge) {
|
|
122
|
+
const connectParams = typeof this.config.connectParams === 'function'
|
|
123
|
+
? await this.config.connectParams(challenge)
|
|
124
|
+
: (this.config.connectParams ?? {});
|
|
94
125
|
const params = {
|
|
95
126
|
minProtocol: 3,
|
|
96
127
|
maxProtocol: 3,
|
|
@@ -105,13 +136,15 @@ export class OpenClawClient {
|
|
|
105
136
|
auth: {
|
|
106
137
|
token: this.config.token,
|
|
107
138
|
},
|
|
139
|
+
...connectParams,
|
|
108
140
|
};
|
|
109
|
-
|
|
141
|
+
const connectTimeout = this.config.connectTimeoutMs ?? 120000;
|
|
142
|
+
return this.request('connect', params, connectTimeout);
|
|
110
143
|
}
|
|
111
144
|
/**
|
|
112
145
|
* Send a request and wait for response
|
|
113
146
|
*/
|
|
114
|
-
async request(method, params) {
|
|
147
|
+
async request(method, params, timeoutMs) {
|
|
115
148
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
116
149
|
throw new Error('Not connected');
|
|
117
150
|
}
|
|
@@ -124,11 +157,11 @@ export class OpenClawClient {
|
|
|
124
157
|
};
|
|
125
158
|
return new Promise((resolve, reject) => {
|
|
126
159
|
this.pending.set(id, { resolve, reject });
|
|
127
|
-
|
|
160
|
+
const effectiveTimeout = timeoutMs ?? this.config.requestTimeoutMs ?? 30000;
|
|
128
161
|
const timeout = setTimeout(() => {
|
|
129
162
|
this.pending.delete(id);
|
|
130
163
|
reject(new Error(`Request timeout: ${method}`));
|
|
131
|
-
},
|
|
164
|
+
}, effectiveTimeout);
|
|
132
165
|
// Clear timeout when promise settles
|
|
133
166
|
const originalResolve = resolve;
|
|
134
167
|
const originalReject = reject;
|
|
@@ -266,6 +299,24 @@ export class OpenClawClient {
|
|
|
266
299
|
async listAgents(params = {}) {
|
|
267
300
|
return this.request('agents.list', params);
|
|
268
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Create agent
|
|
304
|
+
*/
|
|
305
|
+
async createAgent(params) {
|
|
306
|
+
return this.request('agents.create', params);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Update agent
|
|
310
|
+
*/
|
|
311
|
+
async updateAgent(params) {
|
|
312
|
+
return this.request('agents.update', params);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Delete agent
|
|
316
|
+
*/
|
|
317
|
+
async deleteAgent(params) {
|
|
318
|
+
return this.request('agents.delete', params);
|
|
319
|
+
}
|
|
269
320
|
/**
|
|
270
321
|
* Get agent identity
|
|
271
322
|
*/
|
|
@@ -326,6 +377,12 @@ export class OpenClawClient {
|
|
|
326
377
|
async compactSession(params) {
|
|
327
378
|
return this.request('sessions.compact', params);
|
|
328
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Get session usage
|
|
382
|
+
*/
|
|
383
|
+
async getSessionsUsage(params = {}) {
|
|
384
|
+
return this.request('sessions.usage', params);
|
|
385
|
+
}
|
|
329
386
|
/**
|
|
330
387
|
* Send a message to agent
|
|
331
388
|
*/
|
|
@@ -386,6 +443,12 @@ export class OpenClawClient {
|
|
|
386
443
|
async setTalkMode(params) {
|
|
387
444
|
return this.request('talk.mode', params);
|
|
388
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Get talk config
|
|
448
|
+
*/
|
|
449
|
+
async getTalkConfig(params = {}) {
|
|
450
|
+
return this.request('talk.config', params);
|
|
451
|
+
}
|
|
389
452
|
/**
|
|
390
453
|
* Get channels status
|
|
391
454
|
*/
|
|
@@ -530,6 +593,12 @@ export class OpenClawClient {
|
|
|
530
593
|
async rejectDevicePairing(params) {
|
|
531
594
|
return this.request('device.pair.reject', params);
|
|
532
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* Remove paired device
|
|
598
|
+
*/
|
|
599
|
+
async removeDevicePairing(params) {
|
|
600
|
+
return this.request('device.pair.remove', params);
|
|
601
|
+
}
|
|
533
602
|
/**
|
|
534
603
|
* Rotate device token
|
|
535
604
|
*/
|
|
@@ -620,6 +689,12 @@ export class OpenClawClient {
|
|
|
620
689
|
async invokeNode(params) {
|
|
621
690
|
return this.request('node.invoke', params);
|
|
622
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Test push notification to node
|
|
694
|
+
*/
|
|
695
|
+
async testPush(params) {
|
|
696
|
+
return this.request('push.test', params);
|
|
697
|
+
}
|
|
623
698
|
/**
|
|
624
699
|
* Update and run
|
|
625
700
|
*/
|