dlinkclaw-openclaw 2026.8.24-alpha.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.en.md +46 -0
- package/README.md +25 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/package.json +95 -0
- package/dist/src/account.d.ts +53 -0
- package/dist/src/account.js +394 -0
- package/dist/src/channel.d.ts +17 -0
- package/dist/src/channel.js +153 -0
- package/dist/src/client/client-manager.d.ts +4 -0
- package/dist/src/client/client-manager.js +10 -0
- package/dist/src/client/const.d.ts +37 -0
- package/dist/src/client/const.js +155 -0
- package/dist/src/client/crypto.d.ts +47 -0
- package/dist/src/client/crypto.js +260 -0
- package/dist/src/client/dl-client.d.ts +99 -0
- package/dist/src/client/dl-client.js +535 -0
- package/dist/src/client/dl-http.d.ts +27 -0
- package/dist/src/client/dl-http.js +223 -0
- package/dist/src/client/media-handler.d.ts +21 -0
- package/dist/src/client/media-handler.js +196 -0
- package/dist/src/client/message.d.ts +96 -0
- package/dist/src/client/message.js +1204 -0
- package/dist/src/client/timeout.d.ts +20 -0
- package/dist/src/client/timeout.js +36 -0
- package/dist/src/client/types.d.ts +224 -0
- package/dist/src/client/types.js +1 -0
- package/dist/src/monitor.d.ts +17 -0
- package/dist/src/monitor.js +320 -0
- package/dist/src/outbound.d.ts +4 -0
- package/dist/src/outbound.js +83 -0
- package/dist/src/policy.d.ts +42 -0
- package/dist/src/policy.js +205 -0
- package/dist/src/runtime.d.ts +9 -0
- package/dist/src/runtime.js +65 -0
- package/dist/src/services/index.d.ts +41 -0
- package/dist/src/services/index.js +225 -0
- package/dist/src/services/services.d.ts +152 -0
- package/dist/src/services/services.js +1066 -0
- package/dist/src/services/types.d.ts +391 -0
- package/dist/src/services/types.js +5 -0
- package/dist/src/services/ws-client.d.ts +174 -0
- package/dist/src/services/ws-client.js +866 -0
- package/dist/src/utils.d.ts +20 -0
- package/dist/src/utils.js +128 -0
- package/ext_capabilities/workrelay-speak/CLONE_GUIDE.md +129 -0
- package/ext_capabilities/workrelay-speak/HARDWARE.md +84 -0
- package/ext_capabilities/workrelay-speak/QWEN_GUIDE.md +151 -0
- package/ext_capabilities/workrelay-speak/README.md +79 -0
- package/ext_capabilities/workrelay-speak/__pycache__/patch-kokoro-en.cpython-312.pyc +0 -0
- package/ext_capabilities/workrelay-speak/install.sh +280 -0
- package/ext_capabilities/workrelay-speak/install.sh.bak-20260814 +376 -0
- package/ext_capabilities/workrelay-speak/manifest.json +49 -0
- package/ext_capabilities/workrelay-speak/patch-kokoro-en.py +85 -0
- package/ext_capabilities/workrelay-speak/status.sh +90 -0
- package/ext_capabilities/workrelay-speak/workrelay-tts.sh +118 -0
- package/ext_capabilities/workrelay-speak-luxtts/README.md +44 -0
- package/ext_capabilities/workrelay-speak-luxtts/install.sh +282 -0
- package/ext_capabilities/workrelay-speak-luxtts/manifest.json +49 -0
- package/ext_capabilities/workrelay-speak-luxtts/samples/45ea2e2c-0863-4966-a739-8bff8817f4c0.wav +0 -0
- package/ext_capabilities/workrelay-speak-luxtts/samples/800e5af4-cba5-441e-8003-6d36f35409e6.wav +0 -0
- package/ext_capabilities/workrelay-speak-luxtts/samples/85fafe01-d4d6-4a48-890e-9ae113f21905.wav +0 -0
- package/ext_capabilities/workrelay-speak-luxtts/samples/reference_text.txt +4 -0
- package/ext_capabilities/workrelay-speak-luxtts/samples/stone-sample-6.4s.wav +0 -0
- package/ext_capabilities/workrelay-speak-luxtts/status.sh +94 -0
- package/ext_capabilities/workrelay-speak-luxtts/workrelay-tts.sh +98 -0
- package/ext_capabilities/workrelay-transcribe/README.md +76 -0
- package/ext_capabilities/workrelay-transcribe/__pycache__/transcribe.cpython-312.pyc +0 -0
- package/ext_capabilities/workrelay-transcribe/__pycache__/transcribe_server.cpython-312.pyc +0 -0
- package/ext_capabilities/workrelay-transcribe/install.sh +207 -0
- package/ext_capabilities/workrelay-transcribe/manifest.json +42 -0
- package/ext_capabilities/workrelay-transcribe/status.sh +62 -0
- package/ext_capabilities/workrelay-transcribe/transcribe.py +56 -0
- package/ext_capabilities/workrelay-transcribe/transcribe_server.py +116 -0
- package/ext_capabilities/workrelay-transcribe/voicebox-transcribe.sh +88 -0
- package/openclaw.plugin.json +142 -0
- package/package.json +95 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw Gateway API 类型定义
|
|
3
|
+
* 用于 duolian 插件中的 claw-services
|
|
4
|
+
*/
|
|
5
|
+
import { OpenClawConfig } from "openclaw/plugin-sdk";
|
|
6
|
+
export interface ErrorShape {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
details?: unknown;
|
|
10
|
+
retryable?: boolean;
|
|
11
|
+
retryAfterMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RequestFrame {
|
|
14
|
+
type: "req";
|
|
15
|
+
id: string;
|
|
16
|
+
method: string;
|
|
17
|
+
params?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface ResponseFrame {
|
|
20
|
+
type: "res";
|
|
21
|
+
id: string;
|
|
22
|
+
ok: boolean;
|
|
23
|
+
payload?: unknown;
|
|
24
|
+
error?: ErrorShape;
|
|
25
|
+
}
|
|
26
|
+
export interface EventFrame {
|
|
27
|
+
type: "event";
|
|
28
|
+
event: string;
|
|
29
|
+
payload?: unknown;
|
|
30
|
+
seq?: number;
|
|
31
|
+
stateVersion?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface AgentIdentity {
|
|
34
|
+
name?: string;
|
|
35
|
+
theme?: string;
|
|
36
|
+
emoji?: string;
|
|
37
|
+
avatar?: string;
|
|
38
|
+
avatarUrl?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentModelConfig {
|
|
41
|
+
primary?: string;
|
|
42
|
+
fallbacks?: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface AgentInfo {
|
|
45
|
+
id: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
identity?: AgentIdentity;
|
|
48
|
+
workspace?: string;
|
|
49
|
+
model?: AgentModelConfig;
|
|
50
|
+
}
|
|
51
|
+
export interface AgentsListResponse {
|
|
52
|
+
defaultId: string;
|
|
53
|
+
mainKey: string;
|
|
54
|
+
scope: "per-sender" | "global";
|
|
55
|
+
agents: AgentInfo[];
|
|
56
|
+
}
|
|
57
|
+
export interface AskAgentParams {
|
|
58
|
+
agentId: string;
|
|
59
|
+
message: string;
|
|
60
|
+
sessionKey: string;
|
|
61
|
+
deliver?: false;
|
|
62
|
+
}
|
|
63
|
+
export interface AskAgentReply {
|
|
64
|
+
runId: string;
|
|
65
|
+
stream: 'lifecycle' | 'assistant';
|
|
66
|
+
data: Record<string, any>;
|
|
67
|
+
sessionKey: string;
|
|
68
|
+
seq: number;
|
|
69
|
+
ts: number;
|
|
70
|
+
spawnedBy?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AgentCreateParams {
|
|
73
|
+
name: string;
|
|
74
|
+
workspace?: string;
|
|
75
|
+
emoji?: string;
|
|
76
|
+
avatar?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface AgentCreateResponse {
|
|
79
|
+
ok: boolean;
|
|
80
|
+
agentId: string;
|
|
81
|
+
name: string;
|
|
82
|
+
workspace: string;
|
|
83
|
+
}
|
|
84
|
+
export interface AgentUpdateParams {
|
|
85
|
+
agentId: string;
|
|
86
|
+
name?: string;
|
|
87
|
+
workspace?: string;
|
|
88
|
+
model?: string;
|
|
89
|
+
avatar?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AgentUpdateResponse {
|
|
92
|
+
ok: boolean;
|
|
93
|
+
agentId: string;
|
|
94
|
+
}
|
|
95
|
+
export interface AgentDeleteParams {
|
|
96
|
+
agentId: string;
|
|
97
|
+
deleteFiles?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface AgentDeleteResponse {
|
|
100
|
+
ok: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface CronState {
|
|
103
|
+
nextRunAtMs: number;
|
|
104
|
+
lastRunAtMs: number;
|
|
105
|
+
lastRunStatus: string;
|
|
106
|
+
lastStatus: string;
|
|
107
|
+
lastDurationMs: number;
|
|
108
|
+
lastError?: string;
|
|
109
|
+
lastDiagnosticSummary: string;
|
|
110
|
+
lastDiagnostics?: Record<string, any>;
|
|
111
|
+
lastDeliveryStatus: string;
|
|
112
|
+
lastFailureNotificationDeliveryStatus: string;
|
|
113
|
+
consecutiveErrors: number;
|
|
114
|
+
consecutiveSkipped: number;
|
|
115
|
+
}
|
|
116
|
+
export interface CronTask {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
enabled: boolean;
|
|
120
|
+
deleteAfterRun: boolean;
|
|
121
|
+
createdAtMs: number;
|
|
122
|
+
schedule: {
|
|
123
|
+
kind: string;
|
|
124
|
+
expr: string;
|
|
125
|
+
};
|
|
126
|
+
sessionTarget: string;
|
|
127
|
+
wakeMode: string;
|
|
128
|
+
payload: {
|
|
129
|
+
kind: string;
|
|
130
|
+
message: string;
|
|
131
|
+
};
|
|
132
|
+
delivery: {
|
|
133
|
+
mode: string;
|
|
134
|
+
channel?: string;
|
|
135
|
+
to?: string;
|
|
136
|
+
bestEffort?: boolean;
|
|
137
|
+
};
|
|
138
|
+
updatedAtMs: number;
|
|
139
|
+
agentId: string;
|
|
140
|
+
state: CronState;
|
|
141
|
+
}
|
|
142
|
+
export interface CronAddParams {
|
|
143
|
+
name: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
schedule: Record<string, unknown>;
|
|
146
|
+
payload: Record<string, unknown>;
|
|
147
|
+
delivery: Record<string, unknown>;
|
|
148
|
+
sessionTarget?: string;
|
|
149
|
+
wakeMode?: string;
|
|
150
|
+
enabled?: boolean;
|
|
151
|
+
deleteAfterRun?: boolean;
|
|
152
|
+
}
|
|
153
|
+
export interface CronAddResponse {
|
|
154
|
+
ok: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface CronListResponse {
|
|
157
|
+
jobs: CronTask[];
|
|
158
|
+
total: number;
|
|
159
|
+
offset: number;
|
|
160
|
+
limit: number;
|
|
161
|
+
hasMore: boolean;
|
|
162
|
+
nextOffset: number;
|
|
163
|
+
}
|
|
164
|
+
export interface CronRemoveParams {
|
|
165
|
+
jobId: string;
|
|
166
|
+
}
|
|
167
|
+
export interface CronRemoveResponse {
|
|
168
|
+
ok: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface CronUpdateParams {
|
|
171
|
+
jobId: string;
|
|
172
|
+
patch: {
|
|
173
|
+
name?: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
schedule?: Record<string, unknown>;
|
|
176
|
+
payload?: Record<string, unknown>;
|
|
177
|
+
delivery?: Record<string, unknown>;
|
|
178
|
+
enabled?: boolean;
|
|
179
|
+
deleteAfterRun?: boolean;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export interface CronUpdateResponse {
|
|
183
|
+
ok: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface CronRunParams {
|
|
186
|
+
jobId: string;
|
|
187
|
+
}
|
|
188
|
+
export interface CronRunResponse {
|
|
189
|
+
ok: boolean;
|
|
190
|
+
runId?: string;
|
|
191
|
+
}
|
|
192
|
+
export interface HealthStatus {
|
|
193
|
+
status: "healthy" | "degraded" | "unhealthy";
|
|
194
|
+
version: string;
|
|
195
|
+
uptime: number;
|
|
196
|
+
agents: Record<string, {
|
|
197
|
+
status: string;
|
|
198
|
+
}>;
|
|
199
|
+
channels: Record<string, {
|
|
200
|
+
status: string;
|
|
201
|
+
}>;
|
|
202
|
+
memory?: {
|
|
203
|
+
used: number;
|
|
204
|
+
total: number;
|
|
205
|
+
percent: number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export interface SystemStatus {
|
|
209
|
+
gateway: {
|
|
210
|
+
version: string;
|
|
211
|
+
uptime: number;
|
|
212
|
+
status: string;
|
|
213
|
+
};
|
|
214
|
+
memory: {
|
|
215
|
+
used: number;
|
|
216
|
+
total: number;
|
|
217
|
+
percent: number;
|
|
218
|
+
};
|
|
219
|
+
agents: {
|
|
220
|
+
total: number;
|
|
221
|
+
active: number;
|
|
222
|
+
};
|
|
223
|
+
channels: {
|
|
224
|
+
total: number;
|
|
225
|
+
connected: number;
|
|
226
|
+
};
|
|
227
|
+
models: {
|
|
228
|
+
primary: string;
|
|
229
|
+
provider: string;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
export interface UsageStatus {
|
|
233
|
+
totalTokens: number;
|
|
234
|
+
totalCost: number;
|
|
235
|
+
todayTokens: number;
|
|
236
|
+
todayCost: number;
|
|
237
|
+
byModel: Record<string, {
|
|
238
|
+
tokens: number;
|
|
239
|
+
cost: number;
|
|
240
|
+
requests: number;
|
|
241
|
+
}>;
|
|
242
|
+
byAgent: Record<string, {
|
|
243
|
+
tokens: number;
|
|
244
|
+
cost: number;
|
|
245
|
+
requests: number;
|
|
246
|
+
}>;
|
|
247
|
+
}
|
|
248
|
+
export interface ClawServiceOptions {
|
|
249
|
+
cfg: OpenClawConfig;
|
|
250
|
+
channelId: string;
|
|
251
|
+
baseUrl: string;
|
|
252
|
+
gatewayUrl: string;
|
|
253
|
+
token?: string;
|
|
254
|
+
}
|
|
255
|
+
export interface AgentSummary {
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
emoji?: string;
|
|
259
|
+
model?: string;
|
|
260
|
+
workspace?: string;
|
|
261
|
+
fileCount: number;
|
|
262
|
+
lastActivity?: string;
|
|
263
|
+
sessionCount: number;
|
|
264
|
+
}
|
|
265
|
+
export interface TaskSummary {
|
|
266
|
+
id: string;
|
|
267
|
+
label: string;
|
|
268
|
+
schedule: string;
|
|
269
|
+
agentId: string;
|
|
270
|
+
agentName: string;
|
|
271
|
+
status: 'enabled' | 'disabled' | 'running';
|
|
272
|
+
nextRun?: string;
|
|
273
|
+
lastRun?: string;
|
|
274
|
+
}
|
|
275
|
+
export interface SystemSummary {
|
|
276
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
277
|
+
version: string;
|
|
278
|
+
uptime: string;
|
|
279
|
+
agentCount: number;
|
|
280
|
+
channelCount: number;
|
|
281
|
+
memoryUsage: string;
|
|
282
|
+
totalTokens: number;
|
|
283
|
+
totalCost: number;
|
|
284
|
+
}
|
|
285
|
+
export interface CmdMessage {
|
|
286
|
+
requestId: string;
|
|
287
|
+
from?: string;
|
|
288
|
+
cmd: CmdType;
|
|
289
|
+
params?: Record<string, any>;
|
|
290
|
+
timestamp: number;
|
|
291
|
+
}
|
|
292
|
+
export interface CmdResponse {
|
|
293
|
+
requestId?: string;
|
|
294
|
+
success: boolean;
|
|
295
|
+
data?: any;
|
|
296
|
+
error?: string;
|
|
297
|
+
timestamp: number;
|
|
298
|
+
}
|
|
299
|
+
export interface CmdResult {
|
|
300
|
+
apiKey: string;
|
|
301
|
+
type: 'cmd' | 'event';
|
|
302
|
+
event?: EventType;
|
|
303
|
+
payload?: any;
|
|
304
|
+
agentBrand: 'openClaw';
|
|
305
|
+
timestamp: string | number;
|
|
306
|
+
timezone: string;
|
|
307
|
+
}
|
|
308
|
+
export type CmdType = 'agent.ask' | 'agent.list' | 'agent.create' | 'agent.update' | 'agent.delete' | 'agent.get' | 'agent.stop' | 'chat.abort' | 'task.list' | 'task.create' | 'task.update' | 'task.delete' | 'task.run' | 'status.health' | 'status.system' | 'status.usage' | 'models.list' | 'sessions.list' | 'sessions.get' | 'sessions.describe' | 'sessions.resolve' | 'sessions.create' | 'sessions.archive' | 'sessions.restore' | 'sessions.delete' | 'sessions.reset' | 'sessions.patch' | 'sessions.currentModel' | 'chat.history' | 'chat.trajectory' | 'skills.status' | 'skills.search' | 'skills.detail' | 'skills.install' | 'skills.update' | 'skills.securityVerdicts' | 'cancelMessage' | 'usage.cost' | 'sessions.usage' | 'sessions.usage.logs' | 'pairing.approve' | 'artifacts.list' | 'artifacts.get' | 'artifacts.download' | 'agents.files.list' | 'agents.files.get' | 'extCapabilities.status' | 'extCapabilities.check' | 'extCapabilities.install';
|
|
309
|
+
export type ReadlineType = Extract<CmdType, 'chat.trajectory'>;
|
|
310
|
+
export interface ClawMessage {
|
|
311
|
+
type: 'res' | 'event';
|
|
312
|
+
event?: 'health' | 'connect.challenge' | 'tick' | 'agent' | 'chat' | 'cron' | 'shutdown' | 'sessions.changed' | 'presence' | 'session.message' | 'heartbeat';
|
|
313
|
+
id: string;
|
|
314
|
+
ok: boolean;
|
|
315
|
+
payload: any;
|
|
316
|
+
error?: any;
|
|
317
|
+
}
|
|
318
|
+
export type EventType = 'onTick' | 'onHealth' | 'onHandshaked' | 'onConnectState' | 'onError' | 'onAgentReply' | 'onAgentChat' | 'onChatTrajectory' | 'onCron' | 'onShutdown' | 'onSessionsChanged' | 'onSkillInstalled' | 'onSkillInstalling' | 'onSkillError' | 'onPairingRequest' | 'onPairingResult';
|
|
319
|
+
export type CmdParamsPatchSessionEntry = {
|
|
320
|
+
sessionKey: string;
|
|
321
|
+
provider?: string;
|
|
322
|
+
model: string;
|
|
323
|
+
};
|
|
324
|
+
export interface SkillInfo {
|
|
325
|
+
name: string;
|
|
326
|
+
version?: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
enabled: boolean;
|
|
329
|
+
configured: boolean;
|
|
330
|
+
eligibility?: string;
|
|
331
|
+
missingRequirements?: string[];
|
|
332
|
+
configCheck?: Record<string, any>;
|
|
333
|
+
source?: string;
|
|
334
|
+
slug?: string;
|
|
335
|
+
author?: string;
|
|
336
|
+
installs?: number;
|
|
337
|
+
category?: string;
|
|
338
|
+
}
|
|
339
|
+
export interface SkillSearchParams {
|
|
340
|
+
query?: string;
|
|
341
|
+
limit?: number;
|
|
342
|
+
}
|
|
343
|
+
export interface SkillInstallParams {
|
|
344
|
+
slug: string;
|
|
345
|
+
version?: string;
|
|
346
|
+
force?: boolean;
|
|
347
|
+
}
|
|
348
|
+
/** 工件(Artifact):Agent 在会话中操作文件产生的记录 */
|
|
349
|
+
export interface ArtifactInfo {
|
|
350
|
+
id: string;
|
|
351
|
+
type: string;
|
|
352
|
+
action: string;
|
|
353
|
+
path?: string;
|
|
354
|
+
title?: string;
|
|
355
|
+
mimeType?: string;
|
|
356
|
+
size?: number;
|
|
357
|
+
displayed: boolean;
|
|
358
|
+
timestamp: number;
|
|
359
|
+
sessionKey: string;
|
|
360
|
+
runId?: string;
|
|
361
|
+
}
|
|
362
|
+
/** artifacts.list 返回 */
|
|
363
|
+
export interface ArtifactsListResponse {
|
|
364
|
+
artifacts: ArtifactInfo[];
|
|
365
|
+
stats?: {
|
|
366
|
+
changedCount: number;
|
|
367
|
+
readCount: number;
|
|
368
|
+
artifactCount: number;
|
|
369
|
+
displayedCount: number;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/** artifacts.list / artifacts.get 参数 */
|
|
373
|
+
export interface ArtifactsQuery {
|
|
374
|
+
sessionKey?: string;
|
|
375
|
+
runId?: string;
|
|
376
|
+
taskId?: string;
|
|
377
|
+
}
|
|
378
|
+
export interface ArtifactGetParams {
|
|
379
|
+
artifactId: string;
|
|
380
|
+
}
|
|
381
|
+
export interface ArtifactDownloadParams {
|
|
382
|
+
artifactId: string;
|
|
383
|
+
}
|
|
384
|
+
/** agents.files 参数 */
|
|
385
|
+
export interface AgentFilesListParams {
|
|
386
|
+
agentId: string;
|
|
387
|
+
}
|
|
388
|
+
export interface AgentFilesGetParams {
|
|
389
|
+
agentId: string;
|
|
390
|
+
name: string;
|
|
391
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { AgentsListResponse, AgentCreateParams, AgentCreateResponse, AgentUpdateParams, AgentUpdateResponse, AgentDeleteParams, AgentDeleteResponse, CronAddParams, CronAddResponse, CronListResponse, CronRemoveParams, CronRemoveResponse, CronUpdateParams, CronUpdateResponse, CronRunParams, CronRunResponse, HealthStatus, SystemStatus, UsageStatus, AskAgentParams } from './types.js';
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
/**
|
|
4
|
+
* OpenClaw Gateway WebSocket 客户端
|
|
5
|
+
* 用于 duolian 插件内部调用 OpenClaw API
|
|
6
|
+
*/
|
|
7
|
+
export declare class WSClient extends EventEmitter {
|
|
8
|
+
private ws;
|
|
9
|
+
private readonly gatewayUrl;
|
|
10
|
+
private token?;
|
|
11
|
+
private readonly callbacks;
|
|
12
|
+
private messageId;
|
|
13
|
+
private isConnected;
|
|
14
|
+
private isHandshaked;
|
|
15
|
+
private readonly deviceConfig;
|
|
16
|
+
constructor(options: {
|
|
17
|
+
gatewayUrl: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
});
|
|
20
|
+
private log;
|
|
21
|
+
/**
|
|
22
|
+
* 连接到 OpenClaw Gateway
|
|
23
|
+
*/
|
|
24
|
+
connect(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 断开连接
|
|
27
|
+
*/
|
|
28
|
+
disconnect(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 检查是否已连接
|
|
31
|
+
*/
|
|
32
|
+
isReady(): boolean;
|
|
33
|
+
askAgent(params: AskAgentParams): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* 列出所有 Agents
|
|
36
|
+
*/
|
|
37
|
+
listAgents(): Promise<AgentsListResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* 创建新的 Agent
|
|
40
|
+
*/
|
|
41
|
+
createAgent(params: AgentCreateParams): Promise<AgentCreateResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* 更新 Agent 信息
|
|
44
|
+
*/
|
|
45
|
+
updateAgent(params: AgentUpdateParams): Promise<AgentUpdateResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* 删除 Agent
|
|
48
|
+
*/
|
|
49
|
+
deleteAgent(params: AgentDeleteParams): Promise<AgentDeleteResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* 添加定时任务
|
|
52
|
+
*/
|
|
53
|
+
addCronTask(params: CronAddParams): Promise<CronAddResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* 列出所有定时任务
|
|
56
|
+
*/
|
|
57
|
+
listCronTasks({ limit, offset }: {
|
|
58
|
+
limit: number;
|
|
59
|
+
offset: number;
|
|
60
|
+
}): Promise<CronListResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* 更新定时任务
|
|
63
|
+
*/
|
|
64
|
+
updateCronTask(params: CronUpdateParams): Promise<CronUpdateResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* 删除定时任务
|
|
67
|
+
*/
|
|
68
|
+
removeCronTask(params: CronRemoveParams): Promise<CronRemoveResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* 运行定时任务
|
|
71
|
+
*/
|
|
72
|
+
runCronTask(params: CronRunParams): Promise<CronRunResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* 获取健康状态
|
|
75
|
+
*/
|
|
76
|
+
getHealthStatus(): Promise<HealthStatus>;
|
|
77
|
+
/**
|
|
78
|
+
* 获取系统状态
|
|
79
|
+
*/
|
|
80
|
+
getSystemStatus(): Promise<SystemStatus>;
|
|
81
|
+
/**
|
|
82
|
+
* 获取使用情况统计
|
|
83
|
+
*/
|
|
84
|
+
getUsageStatus(): Promise<UsageStatus>;
|
|
85
|
+
listModels(): Promise<any>;
|
|
86
|
+
sessionsList(params: Record<string, unknown>): Promise<any>;
|
|
87
|
+
sessionsGet(params: Record<string, unknown>): Promise<any>;
|
|
88
|
+
sessionsDescribe(params: Record<string, string>): Promise<any>;
|
|
89
|
+
sessionsResolve(params: Record<string, unknown>): Promise<any>;
|
|
90
|
+
sessionReset(params: Record<string, string>): Promise<any>;
|
|
91
|
+
chatHistories(params: Record<string, string>): Promise<any>;
|
|
92
|
+
listSkills(agentId?: string): Promise<any>;
|
|
93
|
+
searchSkills(params: {
|
|
94
|
+
query?: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
}): Promise<any>;
|
|
97
|
+
getSkillDetail(slug: string): Promise<any>;
|
|
98
|
+
installSkill(slug: string, version?: string): Promise<any>;
|
|
99
|
+
updateSkillConfig(skillKey: string, enabled: boolean): Promise<any>;
|
|
100
|
+
/**
|
|
101
|
+
* 取消当前Session的Agent执行
|
|
102
|
+
* 发送 /queue interrupt 到Gateway中断活跃run
|
|
103
|
+
* @param channelId 频道ID(如 dlink),由services层传入,避免硬编码
|
|
104
|
+
* @param chatType 会话类型 direct | group,由WorkRelay客户端传入
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* 创建新会话
|
|
108
|
+
* @param params.key - 完整的 sessionKey
|
|
109
|
+
*/
|
|
110
|
+
sessionsCreate(params: {
|
|
111
|
+
key: string;
|
|
112
|
+
}): Promise<any>;
|
|
113
|
+
/**
|
|
114
|
+
* 更新会话元数据(归档/恢复等)
|
|
115
|
+
* @param params.key - sessionKey
|
|
116
|
+
* @param params.patch - 要更新的字段,如 { archived: true }
|
|
117
|
+
*/
|
|
118
|
+
sessionsPatch(params: {
|
|
119
|
+
key: string;
|
|
120
|
+
patch: Record<string, unknown>;
|
|
121
|
+
}): Promise<any>;
|
|
122
|
+
/**
|
|
123
|
+
* 删除会话
|
|
124
|
+
* @param params.key - sessionKey
|
|
125
|
+
* @param params.deleteFiles - 是否同时删除会话相关文件(貌似不支持该参数)
|
|
126
|
+
*/
|
|
127
|
+
sessionsDelete(params: {
|
|
128
|
+
key: string;
|
|
129
|
+
}): Promise<any>;
|
|
130
|
+
/** 订阅会话变更事件(需在握手成功后调用) */
|
|
131
|
+
subscribeSessions(): Promise<any>;
|
|
132
|
+
cancelSession({ sessionKey }: {
|
|
133
|
+
sessionKey: string;
|
|
134
|
+
}): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
* 发送 /stop 到Gateway,强制中止活跃run(比 /queue interrupt 更快)
|
|
137
|
+
* 对应 cmd 通道 agent.stop 指令
|
|
138
|
+
*/
|
|
139
|
+
stopSession({ sessionKey }: {
|
|
140
|
+
sessionKey: string;
|
|
141
|
+
}): Promise<any>;
|
|
142
|
+
chatAbort(params: {
|
|
143
|
+
sessionKey: string;
|
|
144
|
+
runId: string;
|
|
145
|
+
}): Promise<any>;
|
|
146
|
+
getSkillSecurityVerdicts(agentId?: string): Promise<any>;
|
|
147
|
+
getUsageCost(params: Record<string, unknown>): Promise<any>;
|
|
148
|
+
getSessionsUsage(params: Record<string, unknown>): Promise<any>;
|
|
149
|
+
getSessionsUsageLogs(params: Record<string, unknown>): Promise<any>;
|
|
150
|
+
artifactsList(params: any): Promise<any>;
|
|
151
|
+
artifactsGet(params: any): Promise<any>;
|
|
152
|
+
artifactsDownload(params: any): Promise<any>;
|
|
153
|
+
/** 列出 Agent 工作区文件(agents.files.list) */
|
|
154
|
+
agentFilesList(agentId: string): Promise<any>;
|
|
155
|
+
/** 获取 Agent 工作区文件内容(agents.files.get) */
|
|
156
|
+
agentFilesGet(agentId: string, filePath: string): Promise<any>;
|
|
157
|
+
/** 跳过 Gateway RPC,直接用 Node.js fs 读取 agent 工作区文件内容
|
|
158
|
+
* 2026-07-31 base64 fix:文本文件 utf-8,二进制文件 base64 编码避免损坏 */
|
|
159
|
+
agentFilesGetLocal(agentId: string, filePath: string): Promise<any>;
|
|
160
|
+
/** 根据扩展名判断是否文本文件 */
|
|
161
|
+
private isTextFile;
|
|
162
|
+
/** 跳过 Gateway RPC,直接用 Node.js fs 递归扫描 agent 工作区目录 */
|
|
163
|
+
agentFilesListLocal(agentId: string): Promise<any>;
|
|
164
|
+
/** 根据 agentId 推断 workspace 目录路径 */
|
|
165
|
+
private resolveWorkspaceDir;
|
|
166
|
+
/** 递归扫描工作区目录,跳过隐藏目录(.git, .clawhub, .openclaw 等) */
|
|
167
|
+
private scanWorkspaceDir;
|
|
168
|
+
private send;
|
|
169
|
+
private sendHandshake;
|
|
170
|
+
private sendRequest;
|
|
171
|
+
private handleMessage;
|
|
172
|
+
private generateId;
|
|
173
|
+
}
|
|
174
|
+
export default WSClient;
|