@yanhaidao/wecom 2.3.160 → 2.3.180

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 (39) hide show
  1. package/README.md +235 -399
  2. package/SKILLS_CAL.md +895 -0
  3. package/SKILLS_DOC.md +2136 -0
  4. package/changelog/v2.3.18.md +22 -0
  5. package/index.ts +39 -3
  6. package/package.json +2 -3
  7. package/src/agent/handler.event-filter.test.ts +11 -0
  8. package/src/agent/handler.ts +732 -643
  9. package/src/app/account-runtime.ts +46 -20
  10. package/src/app/index.ts +19 -1
  11. package/src/capability/calendar/SKILLS_CHECKLIST.md +251 -0
  12. package/src/capability/calendar/client.ts +815 -0
  13. package/src/capability/calendar/index.ts +3 -0
  14. package/src/capability/calendar/schema.ts +417 -0
  15. package/src/capability/calendar/tool.ts +417 -0
  16. package/src/capability/calendar/types.ts +309 -0
  17. package/src/capability/doc/client.ts +567 -62
  18. package/src/capability/doc/schema.ts +419 -318
  19. package/src/capability/doc/tool.ts +1510 -1178
  20. package/src/capability/doc/types.ts +130 -14
  21. package/src/capability/mcp/index.ts +10 -0
  22. package/src/capability/mcp/schema.ts +107 -0
  23. package/src/capability/mcp/tool.ts +170 -0
  24. package/src/capability/mcp/transport.ts +394 -0
  25. package/src/channel.ts +70 -28
  26. package/src/config/schema.ts +71 -102
  27. package/src/outbound.test.ts +91 -14
  28. package/src/outbound.ts +143 -30
  29. package/src/runtime/reply-orchestrator.test.ts +35 -2
  30. package/src/runtime/reply-orchestrator.ts +14 -2
  31. package/src/runtime/session-manager.ts +20 -6
  32. package/src/runtime/source-registry.ts +165 -0
  33. package/src/transport/bot-ws/media.ts +269 -0
  34. package/src/transport/bot-ws/reply.test.ts +85 -17
  35. package/src/transport/bot-ws/reply.ts +109 -21
  36. package/src/transport/bot-ws/sdk-adapter.test.ts +64 -1
  37. package/src/transport/bot-ws/sdk-adapter.ts +88 -12
  38. package/.claude/settings.local.json +0 -11
  39. package/docs/update-content-fix.md +0 -135
@@ -0,0 +1,3 @@
1
+ // Calendar Module Export
2
+ export { WecomCalendarClient } from "./client.js";
3
+ export { registerWecomCalendarTools } from "./tool.js";
@@ -0,0 +1,417 @@
1
+ // ============================================================================
2
+ // Calendar Schema (日历 JSON Schema 定义)
3
+ // 完整参考企业微信官方 API 文档:https://developer.work.weixin.qq.com/document/path/93329
4
+ // 所有参数验证规则严格遵循官方文档要求
5
+ // ============================================================================
6
+
7
+ const accountIdProperty = {
8
+ type: "string",
9
+ minLength: 1,
10
+ description: "可选:指定企业微信账号 ID",
11
+ };
12
+
13
+ // --- Calendar Properties ---
14
+
15
+ const calendarSummaryProperty = {
16
+ type: "string",
17
+ minLength: 1,
18
+ maxLength: 128,
19
+ description: "日历标题,1-128 字符",
20
+ };
21
+
22
+ const calendarColorProperty = {
23
+ type: "string",
24
+ pattern: "^#?[0-9A-Fa-f]{6}$",
25
+ description: "日历颜色,RGB 十六进制格式,如 #FF3030 或 FF3030",
26
+ };
27
+
28
+ const calendarDescriptionProperty = {
29
+ type: "string",
30
+ minLength: 0,
31
+ maxLength: 512,
32
+ description: "日历描述,0-512 字符",
33
+ };
34
+
35
+ const calendarAdminsProperty = {
36
+ type: "array",
37
+ minItems: 1,
38
+ maxItems: 3,
39
+ items: { type: "string", minLength: 1 },
40
+ description: "日历管理员 userid 列表,最多 3 人",
41
+ };
42
+
43
+ const calendarSharesEntrySchema = {
44
+ type: "object",
45
+ required: ["userid"],
46
+ properties: {
47
+ userid: { type: "string", minLength: 1, maxLength: 64, description: "成员 userid" },
48
+ permission: { type: "integer", enum: [1, 3], description: "1:可查看,3:仅查看闲忙状态" },
49
+ },
50
+ };
51
+
52
+ const calendarSharesProperty = {
53
+ type: "array",
54
+ minItems: 1,
55
+ maxItems: 2000,
56
+ items: calendarSharesEntrySchema,
57
+ description: "日历通知范围成员列表,最多 2000 人",
58
+ };
59
+
60
+ const calendarPublicRangeProperty = {
61
+ type: "object",
62
+ properties: {
63
+ userids: { type: "array", minItems: 1, maxItems: 1000, items: { type: "string" }, description: "公开的成员列表,最多 1000 个" },
64
+ partyids: { type: "array", minItems: 1, maxItems: 100, items: { type: "integer" }, description: "公开的部门列表,最多 100 个" },
65
+ },
66
+ };
67
+
68
+ // --- Schedule Properties ---
69
+
70
+ const scheduleTimeProperty = {
71
+ type: "integer",
72
+ minimum: 0,
73
+ description: "Unix 时间戳(秒)",
74
+ };
75
+
76
+ const scheduleAttendeeSchema = {
77
+ type: "object",
78
+ required: ["userid"],
79
+ properties: {
80
+ userid: { type: "string", minLength: 1, maxLength: 64, description: "日程参与者 ID,不多于 64 字节" },
81
+ },
82
+ };
83
+
84
+ const scheduleAttendeesProperty = {
85
+ type: "array",
86
+ minItems: 1,
87
+ maxItems: 1000,
88
+ items: scheduleAttendeeSchema,
89
+ description: "日程参与者列表,最多 1000 人",
90
+ };
91
+
92
+ const scheduleAdminsProperty = {
93
+ type: "array",
94
+ minItems: 1,
95
+ maxItems: 3,
96
+ items: { type: "string", minLength: 1 },
97
+ description: "日程管理员 userid 列表,最多 3 人",
98
+ };
99
+
100
+ const scheduleSummaryProperty = {
101
+ type: "string",
102
+ minLength: 0,
103
+ maxLength: 128,
104
+ description: "日程标题,0-128 字符,不填默认显示为新建事件",
105
+ };
106
+
107
+ const scheduleDescriptionProperty = {
108
+ type: "string",
109
+ minLength: 0,
110
+ maxLength: 1000,
111
+ description: "日程描述,不多于 1000 字符",
112
+ };
113
+
114
+ const scheduleLocationProperty = {
115
+ type: "string",
116
+ minLength: 0,
117
+ maxLength: 128,
118
+ description: "日程地址,不多于 128 字符",
119
+ };
120
+
121
+ // 官方严格限定的提醒时间枚举值
122
+ const scheduleRemindersSchema = {
123
+ type: "object",
124
+ properties: {
125
+ is_remind: { type: "integer", enum: [0, 1], description: "是否需要提醒,0-否,1-是" },
126
+ is_repeat: { type: "integer", enum: [0, 1], description: "是否重复日程,0-否,1-是" },
127
+ remind_before_event_secs: {
128
+ type: "integer",
129
+ enum: [0, 300, 900, 3600, 86400],
130
+ description: "日程开始前多少秒提醒,仅支持:0(事件开始时),300(5 分钟),900(15 分钟),3600(1 小时),86400(1 天)。当 is_remind=1 时有效"
131
+ },
132
+ remind_time_diffs: {
133
+ type: "array",
134
+ items: {
135
+ type: "integer",
136
+ enum: [0, -300, -900, -3600, -86400, 32400, -172800, -604800],
137
+ description: "提醒时间差值(秒):0(事件开始时),-300(-5 分钟),-900(-15 分钟),-3600(-1 小时),-86400(-1 天),32400(当天 09:00),-172800(-2 天),-604800(-1 周)"
138
+ },
139
+ description: "提醒时间与日程开始时间的差值列表,仅支持特定枚举值"
140
+ },
141
+ repeat_type: {
142
+ type: "integer",
143
+ enum: [0, 1, 2, 5, 7],
144
+ description: "重复类型:0-每日,1-每周,2-每月,5-每年,7-工作日。仅当 is_repeat=1 时有效"
145
+ },
146
+ repeat_until: { type: "integer", minimum: 0, description: "重复结束时刻,Unix 时间戳,0 或不填表示一直重复。仅当 is_repeat=1 时有效" },
147
+ is_custom_repeat: { type: "integer", enum: [0, 1], description: "是否自定义重复,0-否,1-是。仅当 is_repeat=1 时有效" },
148
+ repeat_interval: { type: "integer", minimum: 1, description: "重复间隔。仅当 is_custom_repeat=1 时有效。含义随 repeat_type 不同而不同(如 repeat_type=1 每周时,3 表示每 3 周)" },
149
+ repeat_day_of_week: {
150
+ type: "array",
151
+ items: { type: "integer", minimum: 1, maximum: 7 },
152
+ description: "每周周几重复,1-7(周一至周日)。仅当 is_custom_repeat=1 且 repeat_type=1(每周) 时有效"
153
+ },
154
+ repeat_day_of_month: {
155
+ type: "array",
156
+ items: { type: "integer", minimum: 1, maximum: 31 },
157
+ description: "每月哪几天重复,1-31。仅当 is_custom_repeat=1 且 repeat_type=2(每月) 时有效"
158
+ },
159
+ timezone: {
160
+ type: "integer",
161
+ minimum: -12,
162
+ maximum: 12,
163
+ description: "时区,UTC 偏移量,-12 到 +12,默认为北京时间东八区 (+8)"
164
+ },
165
+ },
166
+ };
167
+
168
+ const opModeSchema = {
169
+ type: "integer",
170
+ enum: [0, 1, 2],
171
+ description: "操作模式:0-全部修改/删除,1-仅修改/删除此日程,2-修改/删除将来的所有日程",
172
+ };
173
+
174
+ const opStartTimeProperty = {
175
+ type: "integer",
176
+ minimum: 0,
177
+ description: "操作起始时间,Unix 时间戳。仅当 op_mode 为 1 或 2 时有效,必须是重复日程的某次开始时间",
178
+ };
179
+
180
+ // ============================================================================
181
+ // Calendar Action Schemas (4 个)
182
+ // ============================================================================
183
+
184
+ const calendarCreateSchema = {
185
+ type: "object",
186
+ additionalProperties: false,
187
+ required: ["action", "summary", "color"],
188
+ properties: {
189
+ action: { const: "calendar_create" },
190
+ accountId: accountIdProperty,
191
+ summary: calendarSummaryProperty,
192
+ color: calendarColorProperty,
193
+ description: calendarDescriptionProperty,
194
+ admins: calendarAdminsProperty,
195
+ set_as_default: { type: "integer", enum: [0, 1], description: "是否将该日历设为默认日历,0-否,1-是(第三方应用不支持)" },
196
+ shares: calendarSharesProperty,
197
+ is_public: { type: "integer", enum: [0, 1], description: "是否公共日历,0-否,1-是" },
198
+ public_range: calendarPublicRangeProperty,
199
+ is_corp_calendar: { type: "integer", enum: [0, 1], description: "是否全员日历,0-否,1-是" },
200
+ },
201
+ };
202
+
203
+ const calendarUpdateSchema = {
204
+ type: "object",
205
+ additionalProperties: false,
206
+ required: ["action", "cal_id", "summary", "color"],
207
+ properties: {
208
+ action: { const: "calendar_update" },
209
+ accountId: accountIdProperty,
210
+ cal_id: { type: "string", minLength: 1, description: "日历 ID" },
211
+ skip_public_range: { type: "integer", enum: [0, 1], description: "是否不更新可订阅范围,0-否,1-是" },
212
+ summary: calendarSummaryProperty,
213
+ color: calendarColorProperty,
214
+ description: calendarDescriptionProperty,
215
+ admins: calendarAdminsProperty,
216
+ shares: calendarSharesProperty,
217
+ public_range: calendarPublicRangeProperty,
218
+ },
219
+ };
220
+
221
+ const calendarGetSchema = {
222
+ type: "object",
223
+ additionalProperties: false,
224
+ required: ["action", "cal_id_list"],
225
+ properties: {
226
+ action: { const: "calendar_get" },
227
+ accountId: accountIdProperty,
228
+ cal_id_list: {
229
+ type: "array",
230
+ minItems: 1,
231
+ maxItems: 1000,
232
+ items: { type: "string", minLength: 1 },
233
+ description: "日历 ID 列表,一次最多 1000 条",
234
+ },
235
+ },
236
+ };
237
+
238
+ const calendarDeleteSchema = {
239
+ type: "object",
240
+ additionalProperties: false,
241
+ required: ["action", "cal_id"],
242
+ properties: {
243
+ action: { const: "calendar_delete" },
244
+ accountId: accountIdProperty,
245
+ cal_id: { type: "string", minLength: 1, description: "日历 ID" },
246
+ },
247
+ };
248
+
249
+ // ============================================================================
250
+ // Schedule Action Schemas (7 个)
251
+ // ============================================================================
252
+
253
+ const scheduleCreateSchema = {
254
+ type: "object",
255
+ additionalProperties: false,
256
+ required: ["action", "start_time", "end_time"],
257
+ properties: {
258
+ action: { const: "schedule_create" },
259
+ accountId: accountIdProperty,
260
+ start_time: scheduleTimeProperty,
261
+ end_time: scheduleTimeProperty,
262
+ is_whole_day: { type: "integer", enum: [0, 1], description: "是否全天日程,0-否,1-是" },
263
+ summary: scheduleSummaryProperty,
264
+ description: scheduleDescriptionProperty,
265
+ location: scheduleLocationProperty,
266
+ attendees: scheduleAttendeesProperty,
267
+ admins: scheduleAdminsProperty,
268
+ reminders: scheduleRemindersSchema,
269
+ cal_id: { type: "string", minLength: 1, maxLength: 64, description: "日程所属日历 ID(第三方应用必须指定)" },
270
+ },
271
+ };
272
+
273
+ const scheduleUpdateSchema = {
274
+ type: "object",
275
+ additionalProperties: false,
276
+ required: ["action", "schedule_id", "start_time", "end_time"],
277
+ properties: {
278
+ action: { const: "schedule_update" },
279
+ accountId: accountIdProperty,
280
+ schedule_id: { type: "string", minLength: 1, description: "日程 ID" },
281
+ skip_attendees: { type: "integer", enum: [0, 1], description: "是否不更新参与人,0-否,1-是" },
282
+ op_mode: opModeSchema,
283
+ op_start_time: opStartTimeProperty,
284
+ start_time: scheduleTimeProperty,
285
+ end_time: scheduleTimeProperty,
286
+ is_whole_day: { type: "integer", enum: [0, 1] },
287
+ summary: scheduleSummaryProperty,
288
+ description: scheduleDescriptionProperty,
289
+ location: scheduleLocationProperty,
290
+ attendees: scheduleAttendeesProperty,
291
+ admins: scheduleAdminsProperty,
292
+ reminders: scheduleRemindersSchema,
293
+ },
294
+ };
295
+
296
+ const scheduleAddAttendeesSchema = {
297
+ type: "object",
298
+ additionalProperties: false,
299
+ required: ["action", "schedule_id", "attendees"],
300
+ properties: {
301
+ action: { const: "schedule_add_attendees" },
302
+ accountId: accountIdProperty,
303
+ schedule_id: { type: "string", minLength: 1, description: "日程 ID" },
304
+ attendees: scheduleAttendeesProperty,
305
+ },
306
+ };
307
+
308
+ const scheduleDelAttendeesSchema = {
309
+ type: "object",
310
+ additionalProperties: false,
311
+ required: ["action", "schedule_id", "attendees"],
312
+ properties: {
313
+ action: { const: "schedule_del_attendees" },
314
+ accountId: accountIdProperty,
315
+ schedule_id: { type: "string", minLength: 1, description: "日程 ID" },
316
+ attendees: scheduleAttendeesProperty,
317
+ },
318
+ };
319
+
320
+ const scheduleGetByCalendarSchema = {
321
+ type: "object",
322
+ additionalProperties: false,
323
+ required: ["action", "cal_id"],
324
+ properties: {
325
+ action: { const: "schedule_get_by_calendar" },
326
+ accountId: accountIdProperty,
327
+ cal_id: { type: "string", minLength: 1, description: "日历 ID" },
328
+ offset: { type: "integer", minimum: 0, description: "分页偏移量,默认 0" },
329
+ limit: { type: "integer", minimum: 1, maximum: 1000, description: "分页大小,默认 500,范围 1-1000" },
330
+ },
331
+ };
332
+
333
+ const scheduleGetSchema = {
334
+ type: "object",
335
+ additionalProperties: false,
336
+ required: ["action", "schedule_id_list"],
337
+ properties: {
338
+ action: { const: "schedule_get" },
339
+ accountId: accountIdProperty,
340
+ schedule_id_list: {
341
+ type: "array",
342
+ minItems: 1,
343
+ maxItems: 1000,
344
+ items: { type: "string", minLength: 1 },
345
+ description: "日程 ID 列表,一次最多 1000 条",
346
+ },
347
+ },
348
+ };
349
+
350
+ const scheduleDeleteSchema = {
351
+ type: "object",
352
+ additionalProperties: false,
353
+ required: ["action", "schedule_id"],
354
+ properties: {
355
+ action: { const: "schedule_delete" },
356
+ accountId: accountIdProperty,
357
+ schedule_id: { type: "string", minLength: 1, description: "日程 ID" },
358
+ op_mode: opModeSchema,
359
+ op_start_time: opStartTimeProperty,
360
+ },
361
+ };
362
+
363
+ // ============================================================================
364
+ // System Calendar Action Schemas (2 个)
365
+ // ============================================================================
366
+
367
+ const scheduleGetSystemCalidSchema = {
368
+ type: "object",
369
+ additionalProperties: false,
370
+ required: ["action", "userid"],
371
+ properties: {
372
+ action: { const: "schedule_get_system_calid" },
373
+ accountId: accountIdProperty,
374
+ userid: { type: "string", minLength: 1, description: "指定成员的 userid" },
375
+ },
376
+ };
377
+
378
+ const scheduleCreateInSystemSchema = {
379
+ type: "object",
380
+ additionalProperties: false,
381
+ required: ["action", "organizer", "start_time", "end_time"],
382
+ properties: {
383
+ action: { const: "schedule_create_in_system" },
384
+ accountId: accountIdProperty,
385
+ organizer: { type: "string", minLength: 1, description: "日程创建者 userid" },
386
+ start_time: scheduleTimeProperty,
387
+ end_time: scheduleTimeProperty,
388
+ is_whole_day: { type: "integer", enum: [0, 1] },
389
+ summary: scheduleSummaryProperty,
390
+ description: scheduleDescriptionProperty,
391
+ location: scheduleLocationProperty,
392
+ attendees: scheduleAttendeesProperty,
393
+ reminders: scheduleRemindersSchema,
394
+ },
395
+ };
396
+
397
+ // ============================================================================
398
+ // Export Schema
399
+ // ============================================================================
400
+
401
+ export const wecomCalendarToolSchema = {
402
+ oneOf: [
403
+ calendarCreateSchema,
404
+ calendarUpdateSchema,
405
+ calendarGetSchema,
406
+ calendarDeleteSchema,
407
+ scheduleCreateSchema,
408
+ scheduleUpdateSchema,
409
+ scheduleAddAttendeesSchema,
410
+ scheduleDelAttendeesSchema,
411
+ scheduleGetByCalendarSchema,
412
+ scheduleGetSchema,
413
+ scheduleDeleteSchema,
414
+ scheduleGetSystemCalidSchema,
415
+ scheduleCreateInSystemSchema,
416
+ ],
417
+ };