@privateclaw/privateclaw 0.1.32 → 0.1.34
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 +16 -9
- package/dist/bridges/openclaw-agent-bridge.d.ts +7 -0
- package/dist/bridges/openclaw-agent-bridge.js +71 -25
- package/dist/bridges/openclaw-agent-bridge.js.map +1 -1
- package/dist/channel.d.ts +14 -0
- package/dist/channel.js +103 -0
- package/dist/channel.js.map +1 -0
- package/dist/cli.js +16 -2
- package/dist/cli.js.map +1 -1
- package/dist/compat/openclaw.d.ts +231 -2
- package/dist/compat/openclaw.js +1 -0
- package/dist/compat/openclaw.js.map +1 -1
- package/dist/openclaw-plugin.js +199 -4
- package/dist/openclaw-plugin.js.map +1 -1
- package/dist/pair-session.d.ts +32 -0
- package/dist/pair-session.js +115 -41
- package/dist/pair-session.js.map +1 -1
- package/dist/provider.d.ts +4 -1
- package/dist/provider.js +109 -4
- package/dist/provider.js.map +1 -1
- package/dist/session-control.d.ts +15 -1
- package/dist/session-control.js +184 -5
- package/dist/session-control.js.map +1 -1
- package/dist/types.d.ts +20 -1
- package/openclaw.plugin.json +3 -2
- package/package.json +2 -2
- package/src/bridges/openclaw-agent-bridge.test.ts +154 -0
- package/src/bridges/openclaw-agent-bridge.ts +97 -27
- package/src/channel.ts +130 -0
- package/src/cli.ts +17 -1
- package/src/compat/openclaw.ts +282 -2
- package/src/openclaw-plugin.test.ts +392 -3
- package/src/openclaw-plugin.ts +262 -3
- package/src/pair-session.test.ts +119 -0
- package/src/pair-session.ts +144 -47
- package/src/provider.test.ts +266 -0
- package/src/provider.ts +133 -4
- package/src/session-control.test.ts +87 -0
- package/src/session-control.ts +252 -5
- package/src/types.ts +23 -0
package/src/compat/openclaw.ts
CHANGED
|
@@ -65,6 +65,7 @@ export const privateClawConfigSchema = {
|
|
|
65
65
|
openclawAgentChannel: {
|
|
66
66
|
type: "string",
|
|
67
67
|
description: "Optional OpenClaw channel id forwarded to `openclaw agent`.",
|
|
68
|
+
default: "privateclaw",
|
|
68
69
|
},
|
|
69
70
|
openclawAgentLocal: {
|
|
70
71
|
type: "boolean",
|
|
@@ -87,10 +88,13 @@ export interface ReplyPayloadCompat {
|
|
|
87
88
|
text?: string;
|
|
88
89
|
mediaUrl?: string;
|
|
89
90
|
mediaUrls?: string[];
|
|
91
|
+
replyToId?: string | null;
|
|
90
92
|
isError?: boolean;
|
|
91
93
|
channelData?: Record<string, unknown>;
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
export type OpenClawConfigCompat = Record<string, unknown>;
|
|
97
|
+
|
|
94
98
|
export interface OpenClawPluginCommandContextCompat {
|
|
95
99
|
senderId?: string;
|
|
96
100
|
channel: string;
|
|
@@ -123,6 +127,282 @@ export interface OpenClawPluginLoggerCompat {
|
|
|
123
127
|
error(message: string): void;
|
|
124
128
|
}
|
|
125
129
|
|
|
130
|
+
export interface OpenClawMsgContextCompat {
|
|
131
|
+
Body?: string;
|
|
132
|
+
BodyForAgent?: string;
|
|
133
|
+
RawBody?: string;
|
|
134
|
+
CommandBody?: string;
|
|
135
|
+
BodyForCommands?: string;
|
|
136
|
+
From?: string;
|
|
137
|
+
To?: string;
|
|
138
|
+
SessionKey?: string;
|
|
139
|
+
ParentSessionKey?: string;
|
|
140
|
+
AccountId?: string;
|
|
141
|
+
MessageSid?: string;
|
|
142
|
+
MessageSidFull?: string;
|
|
143
|
+
ReplyToId?: string | null;
|
|
144
|
+
Timestamp?: number;
|
|
145
|
+
ChatType?: string;
|
|
146
|
+
ConversationLabel?: string;
|
|
147
|
+
SenderName?: string;
|
|
148
|
+
SenderId?: string;
|
|
149
|
+
Provider?: string;
|
|
150
|
+
Surface?: string;
|
|
151
|
+
CommandAuthorized?: boolean;
|
|
152
|
+
MessageThreadId?: string | number;
|
|
153
|
+
NativeChannelId?: string;
|
|
154
|
+
OriginatingChannel?: string;
|
|
155
|
+
OriginatingTo?: string;
|
|
156
|
+
ExplicitDeliverRoute?: boolean;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface OpenClawFinalizedMsgContextCompat
|
|
160
|
+
extends Omit<OpenClawMsgContextCompat, "CommandAuthorized"> {
|
|
161
|
+
CommandAuthorized: boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface OpenClawResolvedAgentRouteCompat {
|
|
165
|
+
agentId: string;
|
|
166
|
+
sessionKey: string;
|
|
167
|
+
mainSessionKey: string;
|
|
168
|
+
lastRoutePolicy?: "main" | "current" | string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface OpenClawReplyDispatchInfoCompat {
|
|
172
|
+
kind: "tool" | "block" | "final";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface OpenClawReplyDispatcherOptionsCompat {
|
|
176
|
+
deliver(
|
|
177
|
+
payload: ReplyPayloadCompat,
|
|
178
|
+
info: OpenClawReplyDispatchInfoCompat,
|
|
179
|
+
): Promise<void>;
|
|
180
|
+
onError?(error: unknown, info: OpenClawReplyDispatchInfoCompat): void;
|
|
181
|
+
onSkip?(
|
|
182
|
+
payload: ReplyPayloadCompat,
|
|
183
|
+
info: OpenClawReplyDispatchInfoCompat & { reason: string },
|
|
184
|
+
): void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface OpenClawPluginRuntimeChannelCompat {
|
|
188
|
+
reply: {
|
|
189
|
+
finalizeInboundContext<T extends Record<string, unknown>>(
|
|
190
|
+
ctx: T,
|
|
191
|
+
opts?: {
|
|
192
|
+
forceBodyForAgent?: boolean;
|
|
193
|
+
forceBodyForCommands?: boolean;
|
|
194
|
+
forceChatType?: boolean;
|
|
195
|
+
forceConversationLabel?: boolean;
|
|
196
|
+
},
|
|
197
|
+
): T & OpenClawFinalizedMsgContextCompat;
|
|
198
|
+
dispatchReplyWithBufferedBlockDispatcher(params: {
|
|
199
|
+
ctx: OpenClawMsgContextCompat | OpenClawFinalizedMsgContextCompat;
|
|
200
|
+
cfg: OpenClawConfigCompat;
|
|
201
|
+
dispatcherOptions: OpenClawReplyDispatcherOptionsCompat;
|
|
202
|
+
replyOptions?: Record<string, unknown>;
|
|
203
|
+
}): Promise<unknown>;
|
|
204
|
+
};
|
|
205
|
+
routing: {
|
|
206
|
+
resolveAgentRoute(params: {
|
|
207
|
+
cfg: OpenClawConfigCompat;
|
|
208
|
+
ctx: OpenClawMsgContextCompat | OpenClawFinalizedMsgContextCompat;
|
|
209
|
+
agentId?: string;
|
|
210
|
+
}): OpenClawResolvedAgentRouteCompat;
|
|
211
|
+
};
|
|
212
|
+
session: {
|
|
213
|
+
resolveStorePath(
|
|
214
|
+
store?: string,
|
|
215
|
+
opts?: {
|
|
216
|
+
agentId?: string;
|
|
217
|
+
env?: NodeJS.ProcessEnv;
|
|
218
|
+
},
|
|
219
|
+
): string;
|
|
220
|
+
recordInboundSession(params: {
|
|
221
|
+
storePath: string;
|
|
222
|
+
sessionKey: string;
|
|
223
|
+
ctx: OpenClawMsgContextCompat | OpenClawFinalizedMsgContextCompat;
|
|
224
|
+
groupResolution?: unknown;
|
|
225
|
+
createIfMissing?: boolean;
|
|
226
|
+
updateLastRoute?: {
|
|
227
|
+
sessionKey: string;
|
|
228
|
+
channel?: string;
|
|
229
|
+
to: string;
|
|
230
|
+
accountId?: string;
|
|
231
|
+
threadId?: string | number;
|
|
232
|
+
};
|
|
233
|
+
onRecordError(error: unknown): void;
|
|
234
|
+
}): Promise<void> | void;
|
|
235
|
+
updateLastRoute?(params: {
|
|
236
|
+
storePath: string;
|
|
237
|
+
sessionKey: string;
|
|
238
|
+
channel?: string;
|
|
239
|
+
to?: string;
|
|
240
|
+
accountId?: string;
|
|
241
|
+
threadId?: string | number;
|
|
242
|
+
deliveryContext?: {
|
|
243
|
+
channel?: string;
|
|
244
|
+
to?: string;
|
|
245
|
+
accountId?: string;
|
|
246
|
+
threadId?: string | number;
|
|
247
|
+
};
|
|
248
|
+
ctx?: OpenClawMsgContextCompat | OpenClawFinalizedMsgContextCompat;
|
|
249
|
+
groupResolution?: unknown;
|
|
250
|
+
}): Promise<void> | void;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface OpenClawPluginRuntimeCompat {
|
|
255
|
+
channel?: OpenClawPluginRuntimeChannelCompat;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface OpenClawChannelMetaCompat {
|
|
259
|
+
id: string;
|
|
260
|
+
label: string;
|
|
261
|
+
selectionLabel: string;
|
|
262
|
+
docsPath: string;
|
|
263
|
+
blurb: string;
|
|
264
|
+
docsLabel?: string;
|
|
265
|
+
order?: number;
|
|
266
|
+
aliases?: string[];
|
|
267
|
+
selectionDocsPrefix?: string;
|
|
268
|
+
selectionDocsOmitLabel?: boolean;
|
|
269
|
+
selectionExtras?: string[];
|
|
270
|
+
detailLabel?: string;
|
|
271
|
+
systemImage?: string;
|
|
272
|
+
showConfigured?: boolean;
|
|
273
|
+
quickstartAllowFrom?: boolean;
|
|
274
|
+
forceAccountBinding?: boolean;
|
|
275
|
+
preferSessionLookupForAnnounceTarget?: boolean;
|
|
276
|
+
preferOver?: string[];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface OpenClawChannelCapabilitiesCompat {
|
|
280
|
+
chatTypes: Array<"direct" | "group" | "thread">;
|
|
281
|
+
polls?: boolean;
|
|
282
|
+
reactions?: boolean;
|
|
283
|
+
edit?: boolean;
|
|
284
|
+
unsend?: boolean;
|
|
285
|
+
reply?: boolean;
|
|
286
|
+
effects?: boolean;
|
|
287
|
+
groupManagement?: boolean;
|
|
288
|
+
threads?: boolean;
|
|
289
|
+
media?: boolean;
|
|
290
|
+
nativeCommands?: boolean;
|
|
291
|
+
blockStreaming?: boolean;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface OpenClawChannelAccountSnapshotCompat {
|
|
295
|
+
accountId: string;
|
|
296
|
+
name?: string;
|
|
297
|
+
enabled?: boolean;
|
|
298
|
+
configured?: boolean;
|
|
299
|
+
linked?: boolean;
|
|
300
|
+
running?: boolean;
|
|
301
|
+
connected?: boolean;
|
|
302
|
+
lastError?: string | null;
|
|
303
|
+
lastInboundAt?: number | null;
|
|
304
|
+
lastOutboundAt?: number | null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface OpenClawChannelConfigAdapterCompat<ResolvedAccount = unknown> {
|
|
308
|
+
listAccountIds(cfg: OpenClawConfigCompat): string[];
|
|
309
|
+
resolveAccount(
|
|
310
|
+
cfg: OpenClawConfigCompat,
|
|
311
|
+
accountId?: string | null,
|
|
312
|
+
): ResolvedAccount;
|
|
313
|
+
inspectAccount?(
|
|
314
|
+
cfg: OpenClawConfigCompat,
|
|
315
|
+
accountId?: string | null,
|
|
316
|
+
): unknown;
|
|
317
|
+
defaultAccountId?(cfg: OpenClawConfigCompat): string;
|
|
318
|
+
isEnabled?(
|
|
319
|
+
account: ResolvedAccount,
|
|
320
|
+
cfg: OpenClawConfigCompat,
|
|
321
|
+
): boolean;
|
|
322
|
+
isConfigured?(
|
|
323
|
+
account: ResolvedAccount,
|
|
324
|
+
cfg: OpenClawConfigCompat,
|
|
325
|
+
): boolean | Promise<boolean>;
|
|
326
|
+
describeAccount?(
|
|
327
|
+
account: ResolvedAccount,
|
|
328
|
+
cfg: OpenClawConfigCompat,
|
|
329
|
+
): OpenClawChannelAccountSnapshotCompat;
|
|
330
|
+
resolveAllowFrom?(params: {
|
|
331
|
+
cfg: OpenClawConfigCompat;
|
|
332
|
+
accountId?: string | null;
|
|
333
|
+
}): Array<string | number> | undefined;
|
|
334
|
+
resolveDefaultTo?(params: {
|
|
335
|
+
cfg: OpenClawConfigCompat;
|
|
336
|
+
accountId?: string | null;
|
|
337
|
+
}): string | undefined;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface OpenClawOutboundDeliveryResultCompat {
|
|
341
|
+
channel: string;
|
|
342
|
+
messageId: string;
|
|
343
|
+
chatId?: string;
|
|
344
|
+
channelId?: string;
|
|
345
|
+
roomId?: string;
|
|
346
|
+
conversationId?: string;
|
|
347
|
+
timestamp?: number;
|
|
348
|
+
toJid?: string;
|
|
349
|
+
pollId?: string;
|
|
350
|
+
meta?: Record<string, unknown>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface OpenClawChannelOutboundContextCompat {
|
|
354
|
+
cfg: OpenClawConfigCompat;
|
|
355
|
+
to: string;
|
|
356
|
+
text: string;
|
|
357
|
+
mediaUrl?: string;
|
|
358
|
+
mediaLocalRoots?: readonly string[];
|
|
359
|
+
gifPlayback?: boolean;
|
|
360
|
+
replyToId?: string | null;
|
|
361
|
+
threadId?: string | number | null;
|
|
362
|
+
accountId?: string | null;
|
|
363
|
+
identity?: unknown;
|
|
364
|
+
deps?: unknown;
|
|
365
|
+
silent?: boolean;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface OpenClawChannelOutboundPayloadContextCompat
|
|
369
|
+
extends OpenClawChannelOutboundContextCompat {
|
|
370
|
+
payload: ReplyPayloadCompat;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface OpenClawChannelOutboundAdapterCompat {
|
|
374
|
+
deliveryMode: "direct" | "gateway" | "hybrid";
|
|
375
|
+
sendPayload?(
|
|
376
|
+
ctx: OpenClawChannelOutboundPayloadContextCompat,
|
|
377
|
+
): Promise<OpenClawOutboundDeliveryResultCompat>;
|
|
378
|
+
sendText?(
|
|
379
|
+
ctx: OpenClawChannelOutboundContextCompat,
|
|
380
|
+
): Promise<OpenClawOutboundDeliveryResultCompat>;
|
|
381
|
+
sendMedia?(
|
|
382
|
+
ctx: OpenClawChannelOutboundContextCompat,
|
|
383
|
+
): Promise<OpenClawOutboundDeliveryResultCompat>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export interface OpenClawChannelThreadingAdapterCompat {
|
|
387
|
+
resolveReplyToMode?(params: {
|
|
388
|
+
cfg: OpenClawConfigCompat;
|
|
389
|
+
accountId?: string | null;
|
|
390
|
+
chatType?: string | null;
|
|
391
|
+
}): "off" | "first" | "all";
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export interface OpenClawChannelPluginCompat<ResolvedAccount = unknown> {
|
|
395
|
+
id: string;
|
|
396
|
+
meta: OpenClawChannelMetaCompat;
|
|
397
|
+
capabilities: OpenClawChannelCapabilitiesCompat;
|
|
398
|
+
config: OpenClawChannelConfigAdapterCompat<ResolvedAccount>;
|
|
399
|
+
outbound?: OpenClawChannelOutboundAdapterCompat;
|
|
400
|
+
threading?: OpenClawChannelThreadingAdapterCompat;
|
|
401
|
+
commands?: {
|
|
402
|
+
skipWhenConfigEmpty?: boolean;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
126
406
|
export interface OpenClawPluginServiceCompat {
|
|
127
407
|
id: string;
|
|
128
408
|
start(params: {
|
|
@@ -163,10 +443,10 @@ export type OpenClawPluginCliRegistrarCompat = (
|
|
|
163
443
|
) => Promise<void> | void;
|
|
164
444
|
|
|
165
445
|
export interface OpenClawPluginApiCompat {
|
|
166
|
-
runtime: unknown;
|
|
446
|
+
runtime: OpenClawPluginRuntimeCompat | unknown;
|
|
167
447
|
pluginConfig?: Record<string, unknown>;
|
|
168
448
|
logger: OpenClawPluginLoggerCompat;
|
|
169
|
-
registerChannel?(params: { plugin: unknown }): void;
|
|
449
|
+
registerChannel?(params: { plugin: OpenClawChannelPluginCompat | unknown }): void;
|
|
170
450
|
registerCommand(command: OpenClawPluginCommandDefinitionCompat): void;
|
|
171
451
|
registerCli?(
|
|
172
452
|
registrar: OpenClawPluginCliRegistrarCompat,
|