@xuanyue202/wecom 2026.3.21
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/dist/index.d.ts +632 -0
- package/dist/index.js +10993 -0
- package/dist/index.js.map +1 -0
- package/openclaw.plugin.json +72 -0
- package/package.json +123 -0
- package/skills/wecom-doc/SKILL.md +120 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
|
|
3
|
+
type WecomDmPolicy = "open" | "pairing" | "allowlist" | "disabled";
|
|
4
|
+
type WecomGroupPolicy = "open" | "allowlist" | "disabled";
|
|
5
|
+
type WecomTransportMode = "webhook" | "ws";
|
|
6
|
+
type WecomWsImageReplyMode = "native" | "markdown-url";
|
|
7
|
+
type WecomAccountConfig = {
|
|
8
|
+
name?: string;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
mode?: WecomTransportMode;
|
|
11
|
+
webhookPath?: string;
|
|
12
|
+
token?: string;
|
|
13
|
+
encodingAESKey?: string;
|
|
14
|
+
receiveId?: string;
|
|
15
|
+
botId?: string;
|
|
16
|
+
secret?: string;
|
|
17
|
+
wsUrl?: string;
|
|
18
|
+
heartbeatIntervalMs?: number;
|
|
19
|
+
reconnectInitialDelayMs?: number;
|
|
20
|
+
reconnectMaxDelayMs?: number;
|
|
21
|
+
publicBaseUrl?: string;
|
|
22
|
+
wsImageReplyMode?: WecomWsImageReplyMode;
|
|
23
|
+
welcomeText?: string;
|
|
24
|
+
dmPolicy?: WecomDmPolicy;
|
|
25
|
+
allowFrom?: string[];
|
|
26
|
+
groupPolicy?: WecomGroupPolicy;
|
|
27
|
+
groupAllowFrom?: string[];
|
|
28
|
+
requireMention?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type WecomConfig = WecomAccountConfig & {
|
|
31
|
+
accounts?: Record<string, WecomAccountConfig>;
|
|
32
|
+
defaultAccount?: string;
|
|
33
|
+
};
|
|
34
|
+
type ResolvedWecomAccount = {
|
|
35
|
+
accountId: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
configured: boolean;
|
|
39
|
+
mode: WecomTransportMode;
|
|
40
|
+
token?: string;
|
|
41
|
+
encodingAESKey?: string;
|
|
42
|
+
receiveId: string;
|
|
43
|
+
botId?: string;
|
|
44
|
+
secret?: string;
|
|
45
|
+
wsUrl: string;
|
|
46
|
+
heartbeatIntervalMs: number;
|
|
47
|
+
reconnectInitialDelayMs: number;
|
|
48
|
+
reconnectMaxDelayMs: number;
|
|
49
|
+
publicBaseUrl?: string;
|
|
50
|
+
wsImageReplyMode: WecomWsImageReplyMode;
|
|
51
|
+
config: WecomAccountConfig;
|
|
52
|
+
};
|
|
53
|
+
type WecomInboundBase = {
|
|
54
|
+
msgid?: string;
|
|
55
|
+
aibotid?: string;
|
|
56
|
+
chattype?: "single" | "group";
|
|
57
|
+
chatid?: string;
|
|
58
|
+
response_url?: string;
|
|
59
|
+
from?: {
|
|
60
|
+
userid?: string;
|
|
61
|
+
corpid?: string;
|
|
62
|
+
};
|
|
63
|
+
msgtype?: string;
|
|
64
|
+
};
|
|
65
|
+
type WecomInboundText = WecomInboundBase & {
|
|
66
|
+
msgtype: "text";
|
|
67
|
+
text?: {
|
|
68
|
+
content?: string;
|
|
69
|
+
};
|
|
70
|
+
quote?: unknown;
|
|
71
|
+
};
|
|
72
|
+
type WecomInboundVoice = WecomInboundBase & {
|
|
73
|
+
msgtype: "voice";
|
|
74
|
+
voice?: {
|
|
75
|
+
content?: string;
|
|
76
|
+
};
|
|
77
|
+
quote?: unknown;
|
|
78
|
+
};
|
|
79
|
+
type WecomInboundStreamRefresh = WecomInboundBase & {
|
|
80
|
+
msgtype: "stream";
|
|
81
|
+
stream?: {
|
|
82
|
+
id?: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
type WecomInboundEvent = WecomInboundBase & {
|
|
86
|
+
msgtype: "event";
|
|
87
|
+
create_time?: number;
|
|
88
|
+
event?: {
|
|
89
|
+
eventtype?: string;
|
|
90
|
+
[key: string]: unknown;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
type WecomInboundMessage = WecomInboundText | WecomInboundVoice | WecomInboundStreamRefresh | WecomInboundEvent | (WecomInboundBase & Record<string, unknown>);
|
|
94
|
+
|
|
95
|
+
/** 默认账户 ID */
|
|
96
|
+
declare const DEFAULT_ACCOUNT_ID = "default";
|
|
97
|
+
interface PluginConfig {
|
|
98
|
+
session?: {
|
|
99
|
+
store?: unknown;
|
|
100
|
+
};
|
|
101
|
+
channels?: {
|
|
102
|
+
wecom?: WecomConfig;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare const wecomPlugin: {
|
|
107
|
+
id: string;
|
|
108
|
+
meta: {
|
|
109
|
+
id: "wecom";
|
|
110
|
+
label: "WeCom";
|
|
111
|
+
selectionLabel: "WeCom (企业微信)";
|
|
112
|
+
docsPath: "/channels/wecom";
|
|
113
|
+
docsLabel: "wecom";
|
|
114
|
+
blurb: "企业微信智能机器人回调";
|
|
115
|
+
aliases: readonly ["wechatwork", "wework", "qywx", "企微", "企业微信"];
|
|
116
|
+
order: 85;
|
|
117
|
+
};
|
|
118
|
+
capabilities: {
|
|
119
|
+
chatTypes: readonly ["direct", "group"];
|
|
120
|
+
media: boolean;
|
|
121
|
+
reactions: boolean;
|
|
122
|
+
threads: boolean;
|
|
123
|
+
edit: boolean;
|
|
124
|
+
reply: boolean;
|
|
125
|
+
polls: boolean;
|
|
126
|
+
};
|
|
127
|
+
messaging: {
|
|
128
|
+
normalizeTarget: (raw: string) => string | undefined;
|
|
129
|
+
targetResolver: {
|
|
130
|
+
looksLikeId: (raw: string, normalized?: string) => boolean;
|
|
131
|
+
hint: string;
|
|
132
|
+
};
|
|
133
|
+
formatTargetDisplay: (params: {
|
|
134
|
+
target: string;
|
|
135
|
+
display?: string;
|
|
136
|
+
}) => string;
|
|
137
|
+
};
|
|
138
|
+
configSchema: {
|
|
139
|
+
schema: {
|
|
140
|
+
type: string;
|
|
141
|
+
additionalProperties: boolean;
|
|
142
|
+
properties: {
|
|
143
|
+
name: {
|
|
144
|
+
type: string;
|
|
145
|
+
};
|
|
146
|
+
enabled: {
|
|
147
|
+
type: string;
|
|
148
|
+
};
|
|
149
|
+
mode: {
|
|
150
|
+
type: string;
|
|
151
|
+
enum: string[];
|
|
152
|
+
default: string;
|
|
153
|
+
};
|
|
154
|
+
webhookPath: {
|
|
155
|
+
type: string;
|
|
156
|
+
};
|
|
157
|
+
token: {
|
|
158
|
+
type: string;
|
|
159
|
+
};
|
|
160
|
+
encodingAESKey: {
|
|
161
|
+
type: string;
|
|
162
|
+
};
|
|
163
|
+
receiveId: {
|
|
164
|
+
type: string;
|
|
165
|
+
};
|
|
166
|
+
botId: {
|
|
167
|
+
type: string;
|
|
168
|
+
};
|
|
169
|
+
secret: {
|
|
170
|
+
type: string;
|
|
171
|
+
};
|
|
172
|
+
wsUrl: {
|
|
173
|
+
type: string;
|
|
174
|
+
};
|
|
175
|
+
heartbeatIntervalMs: {
|
|
176
|
+
type: string;
|
|
177
|
+
minimum: number;
|
|
178
|
+
};
|
|
179
|
+
reconnectInitialDelayMs: {
|
|
180
|
+
type: string;
|
|
181
|
+
minimum: number;
|
|
182
|
+
};
|
|
183
|
+
reconnectMaxDelayMs: {
|
|
184
|
+
type: string;
|
|
185
|
+
minimum: number;
|
|
186
|
+
};
|
|
187
|
+
publicBaseUrl: {
|
|
188
|
+
type: string;
|
|
189
|
+
};
|
|
190
|
+
wsImageReplyMode: {
|
|
191
|
+
type: string;
|
|
192
|
+
enum: string[];
|
|
193
|
+
};
|
|
194
|
+
welcomeText: {
|
|
195
|
+
type: string;
|
|
196
|
+
};
|
|
197
|
+
dmPolicy: {
|
|
198
|
+
type: string;
|
|
199
|
+
enum: string[];
|
|
200
|
+
};
|
|
201
|
+
allowFrom: {
|
|
202
|
+
type: string;
|
|
203
|
+
items: {
|
|
204
|
+
type: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
groupPolicy: {
|
|
208
|
+
type: string;
|
|
209
|
+
enum: string[];
|
|
210
|
+
};
|
|
211
|
+
groupAllowFrom: {
|
|
212
|
+
type: string;
|
|
213
|
+
items: {
|
|
214
|
+
type: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
requireMention: {
|
|
218
|
+
type: string;
|
|
219
|
+
};
|
|
220
|
+
defaultAccount: {
|
|
221
|
+
type: string;
|
|
222
|
+
};
|
|
223
|
+
accounts: {
|
|
224
|
+
type: string;
|
|
225
|
+
additionalProperties: {
|
|
226
|
+
type: string;
|
|
227
|
+
additionalProperties: boolean;
|
|
228
|
+
properties: {
|
|
229
|
+
name: {
|
|
230
|
+
type: string;
|
|
231
|
+
};
|
|
232
|
+
enabled: {
|
|
233
|
+
type: string;
|
|
234
|
+
};
|
|
235
|
+
mode: {
|
|
236
|
+
type: string;
|
|
237
|
+
enum: string[];
|
|
238
|
+
default: string;
|
|
239
|
+
};
|
|
240
|
+
webhookPath: {
|
|
241
|
+
type: string;
|
|
242
|
+
};
|
|
243
|
+
token: {
|
|
244
|
+
type: string;
|
|
245
|
+
};
|
|
246
|
+
encodingAESKey: {
|
|
247
|
+
type: string;
|
|
248
|
+
};
|
|
249
|
+
receiveId: {
|
|
250
|
+
type: string;
|
|
251
|
+
};
|
|
252
|
+
botId: {
|
|
253
|
+
type: string;
|
|
254
|
+
};
|
|
255
|
+
secret: {
|
|
256
|
+
type: string;
|
|
257
|
+
};
|
|
258
|
+
wsUrl: {
|
|
259
|
+
type: string;
|
|
260
|
+
};
|
|
261
|
+
heartbeatIntervalMs: {
|
|
262
|
+
type: string;
|
|
263
|
+
minimum: number;
|
|
264
|
+
};
|
|
265
|
+
reconnectInitialDelayMs: {
|
|
266
|
+
type: string;
|
|
267
|
+
minimum: number;
|
|
268
|
+
};
|
|
269
|
+
reconnectMaxDelayMs: {
|
|
270
|
+
type: string;
|
|
271
|
+
minimum: number;
|
|
272
|
+
};
|
|
273
|
+
publicBaseUrl: {
|
|
274
|
+
type: string;
|
|
275
|
+
};
|
|
276
|
+
wsImageReplyMode: {
|
|
277
|
+
type: string;
|
|
278
|
+
enum: string[];
|
|
279
|
+
};
|
|
280
|
+
welcomeText: {
|
|
281
|
+
type: string;
|
|
282
|
+
};
|
|
283
|
+
dmPolicy: {
|
|
284
|
+
type: string;
|
|
285
|
+
enum: string[];
|
|
286
|
+
};
|
|
287
|
+
allowFrom: {
|
|
288
|
+
type: string;
|
|
289
|
+
items: {
|
|
290
|
+
type: string;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
groupPolicy: {
|
|
294
|
+
type: string;
|
|
295
|
+
enum: string[];
|
|
296
|
+
};
|
|
297
|
+
groupAllowFrom: {
|
|
298
|
+
type: string;
|
|
299
|
+
items: {
|
|
300
|
+
type: string;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
requireMention: {
|
|
304
|
+
type: string;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
reload: {
|
|
313
|
+
configPrefixes: string[];
|
|
314
|
+
};
|
|
315
|
+
config: {
|
|
316
|
+
listAccountIds: (cfg: PluginConfig) => string[];
|
|
317
|
+
resolveAccount: (cfg: PluginConfig, accountId?: string) => ResolvedWecomAccount;
|
|
318
|
+
defaultAccountId: (cfg: PluginConfig) => string;
|
|
319
|
+
setAccountEnabled: (params: {
|
|
320
|
+
cfg: PluginConfig;
|
|
321
|
+
accountId?: string;
|
|
322
|
+
enabled: boolean;
|
|
323
|
+
}) => PluginConfig;
|
|
324
|
+
deleteAccount: (params: {
|
|
325
|
+
cfg: PluginConfig;
|
|
326
|
+
accountId?: string;
|
|
327
|
+
}) => PluginConfig;
|
|
328
|
+
isConfigured: (account: ResolvedWecomAccount) => boolean;
|
|
329
|
+
describeAccount: (account: ResolvedWecomAccount) => {
|
|
330
|
+
accountId: string;
|
|
331
|
+
name: string | undefined;
|
|
332
|
+
mode: WecomTransportMode;
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
configured: boolean;
|
|
335
|
+
webhookPath: string | undefined;
|
|
336
|
+
wsUrl: string | undefined;
|
|
337
|
+
};
|
|
338
|
+
resolveAllowFrom: (params: {
|
|
339
|
+
cfg: PluginConfig;
|
|
340
|
+
accountId?: string;
|
|
341
|
+
}) => string[];
|
|
342
|
+
formatAllowFrom: (params: {
|
|
343
|
+
allowFrom: (string | number)[];
|
|
344
|
+
}) => string[];
|
|
345
|
+
};
|
|
346
|
+
groups: {
|
|
347
|
+
resolveRequireMention: (params: {
|
|
348
|
+
cfg: PluginConfig;
|
|
349
|
+
accountId?: string;
|
|
350
|
+
account?: ResolvedWecomAccount;
|
|
351
|
+
}) => boolean;
|
|
352
|
+
};
|
|
353
|
+
directory: {
|
|
354
|
+
canResolve: (params: {
|
|
355
|
+
target: string;
|
|
356
|
+
}) => boolean;
|
|
357
|
+
resolveTarget: (params: {
|
|
358
|
+
cfg: PluginConfig;
|
|
359
|
+
target: string;
|
|
360
|
+
}) => {
|
|
361
|
+
channel: string;
|
|
362
|
+
accountId?: string;
|
|
363
|
+
to: string;
|
|
364
|
+
} | null;
|
|
365
|
+
resolveTargets: (params: {
|
|
366
|
+
cfg: PluginConfig;
|
|
367
|
+
targets: string[];
|
|
368
|
+
}) => Array<{
|
|
369
|
+
channel: string;
|
|
370
|
+
accountId?: string;
|
|
371
|
+
to: string;
|
|
372
|
+
}>;
|
|
373
|
+
getTargetFormats: () => string[];
|
|
374
|
+
};
|
|
375
|
+
outbound: {
|
|
376
|
+
deliveryMode: string;
|
|
377
|
+
sendText: (params: {
|
|
378
|
+
cfg: PluginConfig;
|
|
379
|
+
accountId?: string;
|
|
380
|
+
to: string;
|
|
381
|
+
text: string;
|
|
382
|
+
sessionKey?: string;
|
|
383
|
+
runId?: string;
|
|
384
|
+
}) => Promise<{
|
|
385
|
+
channel: string;
|
|
386
|
+
ok: boolean;
|
|
387
|
+
messageId: string;
|
|
388
|
+
error?: Error;
|
|
389
|
+
}>;
|
|
390
|
+
sendMedia: (params: {
|
|
391
|
+
cfg: PluginConfig;
|
|
392
|
+
accountId?: string;
|
|
393
|
+
to: string;
|
|
394
|
+
mediaUrl: string;
|
|
395
|
+
text?: string;
|
|
396
|
+
mimeType?: string;
|
|
397
|
+
sessionKey?: string;
|
|
398
|
+
runId?: string;
|
|
399
|
+
}) => Promise<{
|
|
400
|
+
channel: string;
|
|
401
|
+
ok: boolean;
|
|
402
|
+
messageId: string;
|
|
403
|
+
error?: Error;
|
|
404
|
+
}>;
|
|
405
|
+
sendTemplateCard: (params: {
|
|
406
|
+
cfg: PluginConfig;
|
|
407
|
+
accountId?: string;
|
|
408
|
+
to: string;
|
|
409
|
+
templateCard: Record<string, unknown>;
|
|
410
|
+
}) => Promise<{
|
|
411
|
+
channel: string;
|
|
412
|
+
ok: boolean;
|
|
413
|
+
messageId: string;
|
|
414
|
+
error?: Error;
|
|
415
|
+
}>;
|
|
416
|
+
};
|
|
417
|
+
status: {
|
|
418
|
+
defaultRuntime: {
|
|
419
|
+
accountId: string;
|
|
420
|
+
running: boolean;
|
|
421
|
+
lastStartAt: null;
|
|
422
|
+
lastStopAt: null;
|
|
423
|
+
lastError: null;
|
|
424
|
+
};
|
|
425
|
+
buildAccountSnapshot: ({ account, runtime, probe }: {
|
|
426
|
+
account: ResolvedWecomAccount;
|
|
427
|
+
runtime?: Record<string, unknown>;
|
|
428
|
+
probe?: unknown;
|
|
429
|
+
}) => {
|
|
430
|
+
accountId: string;
|
|
431
|
+
name: string | undefined;
|
|
432
|
+
enabled: boolean;
|
|
433
|
+
configured: boolean;
|
|
434
|
+
linked: boolean;
|
|
435
|
+
connected: boolean;
|
|
436
|
+
running: boolean;
|
|
437
|
+
lastStartAt: number | null;
|
|
438
|
+
lastStopAt: number | null;
|
|
439
|
+
lastError: string | null;
|
|
440
|
+
lastInboundAt: number | null;
|
|
441
|
+
lastOutboundAt: number | null;
|
|
442
|
+
mode: string;
|
|
443
|
+
webhookPath: string | undefined;
|
|
444
|
+
dmPolicy: WecomDmPolicy;
|
|
445
|
+
allowFrom: string[] | undefined;
|
|
446
|
+
probe: unknown;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
gateway: {
|
|
450
|
+
startAccount: (ctx: {
|
|
451
|
+
cfg: PluginConfig;
|
|
452
|
+
runtime?: unknown;
|
|
453
|
+
abortSignal?: AbortSignal;
|
|
454
|
+
accountId: string;
|
|
455
|
+
setStatus?: (status: Record<string, unknown>) => void;
|
|
456
|
+
log?: {
|
|
457
|
+
info: (msg: string) => void;
|
|
458
|
+
error: (msg: string) => void;
|
|
459
|
+
};
|
|
460
|
+
}) => Promise<void>;
|
|
461
|
+
stopAccount: (ctx: {
|
|
462
|
+
accountId: string;
|
|
463
|
+
setStatus?: (status: Record<string, unknown>) => void;
|
|
464
|
+
}) => Promise<void>;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* 企业微信插件运行时管理
|
|
470
|
+
*/
|
|
471
|
+
interface PluginRuntime {
|
|
472
|
+
log?: (msg: string) => void;
|
|
473
|
+
error?: (msg: string) => void;
|
|
474
|
+
channel?: {
|
|
475
|
+
routing?: {
|
|
476
|
+
resolveAgentRoute?: (params: {
|
|
477
|
+
cfg: unknown;
|
|
478
|
+
channel: string;
|
|
479
|
+
accountId?: string;
|
|
480
|
+
peer: {
|
|
481
|
+
kind: string;
|
|
482
|
+
id: string;
|
|
483
|
+
};
|
|
484
|
+
}) => {
|
|
485
|
+
sessionKey: string;
|
|
486
|
+
accountId: string;
|
|
487
|
+
agentId?: string;
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
reply?: {
|
|
491
|
+
dispatchReplyFromConfig?: (params: {
|
|
492
|
+
ctx: unknown;
|
|
493
|
+
cfg: unknown;
|
|
494
|
+
dispatcher?: unknown;
|
|
495
|
+
replyOptions?: unknown;
|
|
496
|
+
}) => Promise<{
|
|
497
|
+
queuedFinal: boolean;
|
|
498
|
+
counts: {
|
|
499
|
+
final: number;
|
|
500
|
+
};
|
|
501
|
+
}>;
|
|
502
|
+
dispatchReplyWithBufferedBlockDispatcher?: (params: {
|
|
503
|
+
ctx: unknown;
|
|
504
|
+
cfg: unknown;
|
|
505
|
+
dispatcherOptions: {
|
|
506
|
+
deliver: (payload: {
|
|
507
|
+
text?: string;
|
|
508
|
+
mediaUrl?: string;
|
|
509
|
+
mediaUrls?: string[];
|
|
510
|
+
}) => Promise<void>;
|
|
511
|
+
onSkip?: (payload: unknown, info: {
|
|
512
|
+
kind: string;
|
|
513
|
+
reason: string;
|
|
514
|
+
}) => void;
|
|
515
|
+
onError?: (err: unknown, info: {
|
|
516
|
+
kind: string;
|
|
517
|
+
}) => void;
|
|
518
|
+
};
|
|
519
|
+
}) => Promise<void>;
|
|
520
|
+
finalizeInboundContext?: (ctx: unknown) => unknown;
|
|
521
|
+
createReplyDispatcher?: (params: unknown) => unknown;
|
|
522
|
+
createReplyDispatcherWithTyping?: (params: unknown) => {
|
|
523
|
+
dispatcher: unknown;
|
|
524
|
+
replyOptions?: unknown;
|
|
525
|
+
markDispatchIdle?: () => void;
|
|
526
|
+
};
|
|
527
|
+
resolveHumanDelayConfig?: (cfg: unknown, agentId?: string) => unknown;
|
|
528
|
+
resolveEnvelopeFormatOptions?: (cfg: unknown) => unknown;
|
|
529
|
+
formatAgentEnvelope?: (params: {
|
|
530
|
+
channel: string;
|
|
531
|
+
from: string;
|
|
532
|
+
previousTimestamp?: number;
|
|
533
|
+
envelope?: unknown;
|
|
534
|
+
body: string;
|
|
535
|
+
}) => string;
|
|
536
|
+
};
|
|
537
|
+
session?: {
|
|
538
|
+
resolveStorePath?: (store: unknown, params: {
|
|
539
|
+
agentId?: string;
|
|
540
|
+
}) => string | undefined;
|
|
541
|
+
readSessionUpdatedAt?: (params: {
|
|
542
|
+
storePath?: string;
|
|
543
|
+
sessionKey: string;
|
|
544
|
+
}) => number | null;
|
|
545
|
+
recordInboundSession?: (params: {
|
|
546
|
+
storePath: string;
|
|
547
|
+
sessionKey: string;
|
|
548
|
+
ctx: unknown;
|
|
549
|
+
updateLastRoute?: {
|
|
550
|
+
sessionKey: string;
|
|
551
|
+
channel: string;
|
|
552
|
+
to: string;
|
|
553
|
+
accountId?: string;
|
|
554
|
+
threadId?: string | number;
|
|
555
|
+
};
|
|
556
|
+
onRecordError?: (err: unknown) => void;
|
|
557
|
+
}) => Promise<void>;
|
|
558
|
+
};
|
|
559
|
+
text?: {
|
|
560
|
+
resolveMarkdownTableMode?: (params: {
|
|
561
|
+
cfg: unknown;
|
|
562
|
+
channel: string;
|
|
563
|
+
accountId?: string;
|
|
564
|
+
}) => unknown;
|
|
565
|
+
convertMarkdownTables?: (text: string, mode: unknown) => string;
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
system?: {
|
|
569
|
+
enqueueSystemEvent?: (message: string, options?: unknown) => void;
|
|
570
|
+
};
|
|
571
|
+
[key: string]: unknown;
|
|
572
|
+
}
|
|
573
|
+
declare function setWecomRuntime(next: PluginRuntime): void;
|
|
574
|
+
declare function getWecomRuntime(): PluginRuntime;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* @xuanyue202/wecom
|
|
578
|
+
* 企业微信渠道插件入口
|
|
579
|
+
*
|
|
580
|
+
* 导出:
|
|
581
|
+
* - wecomPlugin: ChannelPlugin 实现
|
|
582
|
+
* - DEFAULT_ACCOUNT_ID: 默认账户 ID
|
|
583
|
+
* - setWecomRuntime: 设置 Moltbot 运行时
|
|
584
|
+
*/
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Moltbot 插件 API 接口
|
|
588
|
+
*/
|
|
589
|
+
type HttpRouteMatch = "exact" | "prefix";
|
|
590
|
+
type HttpRouteAuth = "gateway" | "plugin";
|
|
591
|
+
type HttpRouteParams = {
|
|
592
|
+
path: string;
|
|
593
|
+
auth: HttpRouteAuth;
|
|
594
|
+
match?: HttpRouteMatch;
|
|
595
|
+
handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean;
|
|
596
|
+
};
|
|
597
|
+
type WecomRouteConfig = {
|
|
598
|
+
mode?: "webhook" | "ws";
|
|
599
|
+
webhookPath?: string;
|
|
600
|
+
accounts?: Record<string, {
|
|
601
|
+
mode?: "webhook" | "ws";
|
|
602
|
+
webhookPath?: string;
|
|
603
|
+
}>;
|
|
604
|
+
};
|
|
605
|
+
interface MoltbotPluginApi {
|
|
606
|
+
registerChannel: (opts: {
|
|
607
|
+
plugin: unknown;
|
|
608
|
+
}) => void;
|
|
609
|
+
registerHttpHandler?: (handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean) => void;
|
|
610
|
+
registerHttpRoute?: (params: HttpRouteParams) => void;
|
|
611
|
+
config?: {
|
|
612
|
+
channels?: {
|
|
613
|
+
wecom?: WecomRouteConfig;
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
runtime?: unknown;
|
|
617
|
+
[key: string]: unknown;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
declare const plugin: {
|
|
621
|
+
id: string;
|
|
622
|
+
name: string;
|
|
623
|
+
description: string;
|
|
624
|
+
configSchema: {
|
|
625
|
+
type: string;
|
|
626
|
+
additionalProperties: boolean;
|
|
627
|
+
properties: {};
|
|
628
|
+
};
|
|
629
|
+
register(api: MoltbotPluginApi): void;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
export { DEFAULT_ACCOUNT_ID, type MoltbotPluginApi, type ResolvedWecomAccount, type WecomConfig, type WecomInboundMessage, plugin as default, getWecomRuntime, setWecomRuntime, wecomPlugin };
|