@dingxiang-me/openclaw-wechat 1.7.1 → 2.0.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/README.en.md +379 -11
  3. package/README.md +626 -15
  4. package/docs/channels/wecom.md +186 -6
  5. package/openclaw.plugin.json +148 -5
  6. package/package.json +9 -5
  7. package/src/core/delivery-router.js +2 -0
  8. package/src/core/stream-manager.js +13 -2
  9. package/src/core.js +96 -6
  10. package/src/wecom/account-config-core.js +2 -0
  11. package/src/wecom/account-config.js +12 -3
  12. package/src/wecom/agent-context.js +7 -1
  13. package/src/wecom/agent-dispatch-executor.js +13 -1
  14. package/src/wecom/agent-dispatch-fallback.js +23 -0
  15. package/src/wecom/agent-inbound-dispatch.js +1 -1
  16. package/src/wecom/agent-inbound-processor.js +33 -2
  17. package/src/wecom/agent-late-reply-runtime.js +31 -1
  18. package/src/wecom/agent-runtime-context.js +3 -0
  19. package/src/wecom/agent-webhook-handler.js +5 -0
  20. package/src/wecom/api-client-core.js +1 -1
  21. package/src/wecom/bot-context.js +7 -1
  22. package/src/wecom/bot-dispatch-fallback.js +34 -3
  23. package/src/wecom/bot-dispatch-handlers.js +47 -4
  24. package/src/wecom/bot-inbound-dispatch-runtime.js +10 -0
  25. package/src/wecom/bot-inbound-executor-helpers.js +51 -5
  26. package/src/wecom/bot-inbound-executor.js +34 -0
  27. package/src/wecom/bot-long-connection-manager.js +971 -0
  28. package/src/wecom/bot-reply-runtime.js +36 -6
  29. package/src/wecom/bot-runtime-context.js +3 -0
  30. package/src/wecom/bot-state-store.js +4 -5
  31. package/src/wecom/bot-webhook-dispatch.js +5 -0
  32. package/src/wecom/bot-webhook-handler.js +5 -0
  33. package/src/wecom/callback-health-diagnostics.js +86 -0
  34. package/src/wecom/channel-config-schema.js +242 -0
  35. package/src/wecom/channel-plugin.js +162 -4
  36. package/src/wecom/channel-status-state.js +150 -0
  37. package/src/wecom/command-handlers.js +6 -0
  38. package/src/wecom/command-status-text.js +35 -8
  39. package/src/wecom/doc-client.js +537 -0
  40. package/src/wecom/doc-schema.js +380 -0
  41. package/src/wecom/doc-tool.js +833 -0
  42. package/src/wecom/outbound-active-stream.js +17 -10
  43. package/src/wecom/outbound-delivery.js +49 -0
  44. package/src/wecom/plugin-account-policy-services.js +4 -1
  45. package/src/wecom/plugin-composition.js +2 -0
  46. package/src/wecom/plugin-constants.js +1 -1
  47. package/src/wecom/plugin-delivery-inbound-services.js +4 -0
  48. package/src/wecom/plugin-processing-deps.js +5 -0
  49. package/src/wecom/plugin-route-runtime-deps.js +2 -0
  50. package/src/wecom/plugin-services.js +37 -0
  51. package/src/wecom/register-runtime.js +20 -1
  52. package/src/wecom/request-parsers.js +1 -0
  53. package/src/wecom/route-registration.js +4 -1
  54. package/src/wecom/session-reset.js +168 -0
  55. package/src/wecom/text-format.js +22 -5
  56. package/src/wecom/text-inbound-scheduler.js +1 -1
  57. package/src/wecom/thinking-parser.js +74 -0
  58. package/src/wecom/voice-transcription-process.js +80 -8
  59. package/src/wecom/voice-transcription.js +11 -0
@@ -0,0 +1,380 @@
1
+ const accountIdProperty = {
2
+ type: "string",
3
+ minLength: 1,
4
+ description: "可选:指定企业微信账号 ID;不填时按 agent 账号/默认账号自动选择",
5
+ };
6
+
7
+ const docTypeProperty = {
8
+ oneOf: [
9
+ {
10
+ type: "string",
11
+ enum: ["doc", "spreadsheet", "smart_table"],
12
+ },
13
+ {
14
+ type: "integer",
15
+ enum: [3, 4, 5],
16
+ },
17
+ ],
18
+ default: "doc",
19
+ description: "文档类型:doc=文档,spreadsheet=表格,smart_table=智能表格",
20
+ };
21
+
22
+ const docIdProperty = {
23
+ type: "string",
24
+ minLength: 1,
25
+ description: "文档 docid",
26
+ };
27
+
28
+ const formIdProperty = {
29
+ type: "string",
30
+ minLength: 1,
31
+ description: "收集表 formid",
32
+ };
33
+
34
+ const shareUrlProperty = {
35
+ type: "string",
36
+ minLength: 1,
37
+ description: "企业微信文档分享链接",
38
+ };
39
+
40
+ const genericObjectProperty = {
41
+ type: "object",
42
+ additionalProperties: true,
43
+ };
44
+
45
+ const nonEmptyObjectProperty = {
46
+ ...genericObjectProperty,
47
+ minProperties: 1,
48
+ };
49
+
50
+ const docMemberEntryProperty = {
51
+ oneOf: [
52
+ {
53
+ type: "string",
54
+ minLength: 1,
55
+ },
56
+ {
57
+ type: "object",
58
+ additionalProperties: true,
59
+ minProperties: 1,
60
+ },
61
+ ],
62
+ };
63
+
64
+ const docMemberEntryArrayProperty = {
65
+ type: "array",
66
+ minItems: 1,
67
+ items: docMemberEntryProperty,
68
+ };
69
+
70
+ export const wecomDocToolSchema = {
71
+ oneOf: [
72
+ {
73
+ type: "object",
74
+ additionalProperties: false,
75
+ required: ["action", "docName"],
76
+ properties: {
77
+ action: { const: "create" },
78
+ accountId: accountIdProperty,
79
+ docName: {
80
+ type: "string",
81
+ minLength: 1,
82
+ description: "文档名称",
83
+ },
84
+ docType: docTypeProperty,
85
+ spaceId: {
86
+ type: "string",
87
+ minLength: 1,
88
+ description: "可选:文档空间 ID",
89
+ },
90
+ fatherId: {
91
+ type: "string",
92
+ minLength: 1,
93
+ description: "可选:父目录 fileid;传 spaceId 时通常也应传 fatherId",
94
+ },
95
+ adminUsers: {
96
+ type: "array",
97
+ description: "可选:文档管理员 userid 列表",
98
+ items: {
99
+ type: "string",
100
+ minLength: 1,
101
+ },
102
+ },
103
+ viewers: {
104
+ ...docMemberEntryArrayProperty,
105
+ description: "可选:创建后立即授予查看权限的成员列表",
106
+ },
107
+ collaborators: {
108
+ ...docMemberEntryArrayProperty,
109
+ description: "可选:创建后立即授予协作者权限的成员列表",
110
+ },
111
+ },
112
+ },
113
+ {
114
+ type: "object",
115
+ additionalProperties: false,
116
+ required: ["action", "docId", "newName"],
117
+ properties: {
118
+ action: { const: "rename" },
119
+ accountId: accountIdProperty,
120
+ docId: docIdProperty,
121
+ newName: {
122
+ type: "string",
123
+ minLength: 1,
124
+ description: "新文档名",
125
+ },
126
+ },
127
+ },
128
+ {
129
+ type: "object",
130
+ additionalProperties: false,
131
+ required: ["action", "docId"],
132
+ properties: {
133
+ action: { const: "get_info" },
134
+ accountId: accountIdProperty,
135
+ docId: docIdProperty,
136
+ },
137
+ },
138
+ {
139
+ type: "object",
140
+ additionalProperties: false,
141
+ required: ["action", "docId"],
142
+ properties: {
143
+ action: { const: "share" },
144
+ accountId: accountIdProperty,
145
+ docId: docIdProperty,
146
+ },
147
+ },
148
+ {
149
+ type: "object",
150
+ additionalProperties: false,
151
+ required: ["action", "docId"],
152
+ properties: {
153
+ action: { const: "get_auth" },
154
+ accountId: accountIdProperty,
155
+ docId: docIdProperty,
156
+ },
157
+ },
158
+ {
159
+ type: "object",
160
+ additionalProperties: false,
161
+ required: ["action", "docId"],
162
+ properties: {
163
+ action: { const: "diagnose_auth" },
164
+ accountId: accountIdProperty,
165
+ docId: docIdProperty,
166
+ },
167
+ },
168
+ {
169
+ type: "object",
170
+ additionalProperties: false,
171
+ required: ["action", "shareUrl"],
172
+ properties: {
173
+ action: { const: "validate_share_link" },
174
+ accountId: accountIdProperty,
175
+ shareUrl: shareUrlProperty,
176
+ },
177
+ },
178
+ {
179
+ type: "object",
180
+ additionalProperties: false,
181
+ required: ["action"],
182
+ anyOf: [{ required: ["docId"] }, { required: ["formId"] }],
183
+ properties: {
184
+ action: { const: "delete" },
185
+ accountId: accountIdProperty,
186
+ docId: docIdProperty,
187
+ formId: formIdProperty,
188
+ },
189
+ },
190
+ {
191
+ type: "object",
192
+ additionalProperties: false,
193
+ required: ["action", "docId", "request"],
194
+ properties: {
195
+ action: { const: "set_join_rule" },
196
+ accountId: accountIdProperty,
197
+ docId: docIdProperty,
198
+ request: {
199
+ ...nonEmptyObjectProperty,
200
+ description: "mod_doc_join_rule 请求体。插件会自动补 docid。",
201
+ },
202
+ },
203
+ },
204
+ {
205
+ type: "object",
206
+ additionalProperties: false,
207
+ required: ["action", "docId"],
208
+ anyOf: [
209
+ { required: ["viewers"] },
210
+ { required: ["collaborators"] },
211
+ { required: ["removeViewers"] },
212
+ { required: ["removeCollaborators"] },
213
+ ],
214
+ properties: {
215
+ action: { const: "grant_access" },
216
+ accountId: accountIdProperty,
217
+ docId: docIdProperty,
218
+ viewers: {
219
+ ...docMemberEntryArrayProperty,
220
+ description: "新增查看成员列表",
221
+ },
222
+ collaborators: {
223
+ ...docMemberEntryArrayProperty,
224
+ description: "新增协作者列表",
225
+ },
226
+ removeViewers: {
227
+ ...docMemberEntryArrayProperty,
228
+ description: "移除查看成员列表",
229
+ },
230
+ removeCollaborators: {
231
+ ...docMemberEntryArrayProperty,
232
+ description: "移除协作者列表",
233
+ },
234
+ },
235
+ },
236
+ {
237
+ type: "object",
238
+ additionalProperties: false,
239
+ required: ["action", "docId", "collaborators"],
240
+ properties: {
241
+ action: { const: "add_collaborators" },
242
+ accountId: accountIdProperty,
243
+ docId: docIdProperty,
244
+ collaborators: {
245
+ ...docMemberEntryArrayProperty,
246
+ description: "要添加的协作者列表;字符串会自动按 userid 处理",
247
+ },
248
+ },
249
+ },
250
+ {
251
+ type: "object",
252
+ additionalProperties: false,
253
+ required: ["action", "docId", "request"],
254
+ properties: {
255
+ action: { const: "set_member_auth" },
256
+ accountId: accountIdProperty,
257
+ docId: docIdProperty,
258
+ request: {
259
+ ...nonEmptyObjectProperty,
260
+ description: "mod_doc_member 请求体。插件会自动补 docid。",
261
+ },
262
+ },
263
+ },
264
+ {
265
+ type: "object",
266
+ additionalProperties: false,
267
+ required: ["action", "docId", "request"],
268
+ properties: {
269
+ action: { const: "set_safety_setting" },
270
+ accountId: accountIdProperty,
271
+ docId: docIdProperty,
272
+ request: {
273
+ ...nonEmptyObjectProperty,
274
+ description: "mod_doc_safty_setting 请求体。插件会自动补 docid。",
275
+ },
276
+ },
277
+ },
278
+ {
279
+ type: "object",
280
+ additionalProperties: false,
281
+ required: ["action", "formInfo"],
282
+ properties: {
283
+ action: { const: "create_collect" },
284
+ accountId: accountIdProperty,
285
+ formInfo: {
286
+ ...nonEmptyObjectProperty,
287
+ description: "收集表 form_info 对象,至少应包含 form_title 等官方字段",
288
+ },
289
+ spaceId: {
290
+ type: "string",
291
+ minLength: 1,
292
+ description: "可选:文档空间 ID",
293
+ },
294
+ fatherId: {
295
+ type: "string",
296
+ minLength: 1,
297
+ description: "可选:父目录 fileid",
298
+ },
299
+ },
300
+ },
301
+ {
302
+ type: "object",
303
+ additionalProperties: false,
304
+ required: ["action", "oper", "formId", "formInfo"],
305
+ properties: {
306
+ action: { const: "modify_collect" },
307
+ accountId: accountIdProperty,
308
+ oper: {
309
+ type: "string",
310
+ minLength: 1,
311
+ description: "修改操作类型,按企业微信官方 modify_collect 定义填写",
312
+ },
313
+ formId: formIdProperty,
314
+ formInfo: {
315
+ ...nonEmptyObjectProperty,
316
+ description: "收集表 form_info 对象",
317
+ },
318
+ },
319
+ },
320
+ {
321
+ type: "object",
322
+ additionalProperties: false,
323
+ required: ["action", "formId"],
324
+ properties: {
325
+ action: { const: "get_form_info" },
326
+ accountId: accountIdProperty,
327
+ formId: formIdProperty,
328
+ },
329
+ },
330
+ {
331
+ type: "object",
332
+ additionalProperties: false,
333
+ required: ["action", "repeatedId"],
334
+ properties: {
335
+ action: { const: "get_form_answer" },
336
+ accountId: accountIdProperty,
337
+ repeatedId: {
338
+ type: "string",
339
+ minLength: 1,
340
+ description: "收集表提交记录 repeated_id",
341
+ },
342
+ answerIds: {
343
+ type: "array",
344
+ description: "可选:答案 ID 列表",
345
+ items: {
346
+ type: "integer",
347
+ },
348
+ },
349
+ },
350
+ },
351
+ {
352
+ type: "object",
353
+ additionalProperties: false,
354
+ required: ["action", "requests"],
355
+ properties: {
356
+ action: { const: "get_form_statistic" },
357
+ accountId: accountIdProperty,
358
+ requests: {
359
+ type: "array",
360
+ minItems: 1,
361
+ description: "统计请求列表;每项按企业微信 get_form_statistic 官方结构填写",
362
+ items: nonEmptyObjectProperty,
363
+ },
364
+ },
365
+ },
366
+ {
367
+ type: "object",
368
+ additionalProperties: false,
369
+ required: ["action", "docId"],
370
+ properties: {
371
+ action: { const: "get_sheet_properties" },
372
+ accountId: accountIdProperty,
373
+ docId: {
374
+ ...docIdProperty,
375
+ description: "在线表格 docid",
376
+ },
377
+ },
378
+ },
379
+ ],
380
+ };