@yanhaidao/wecom 2.4.120 → 2.5.110

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 (323) hide show
  1. package/README.md +4 -5
  2. package/dist/index.js +68 -0
  3. package/dist/src/accounts.js +20 -0
  4. package/dist/src/agent/handler.js +895 -0
  5. package/dist/src/agent/index.js +5 -0
  6. package/dist/src/app/account-runtime.js +216 -0
  7. package/dist/src/app/bootstrap.js +19 -0
  8. package/dist/src/app/index.js +118 -0
  9. package/dist/src/capability/agent/delivery-service.js +63 -0
  10. package/dist/src/capability/agent/fallback-policy.js +6 -0
  11. package/dist/src/capability/agent/ingress-service.js +33 -0
  12. package/dist/src/capability/agent/upstream-delivery-service.js +71 -0
  13. package/dist/src/capability/bot/dispatch-config.js +45 -0
  14. package/dist/src/capability/bot/fallback-delivery.js +147 -0
  15. package/dist/src/capability/bot/local-path-delivery.js +178 -0
  16. package/dist/src/capability/bot/sandbox-media.js +138 -0
  17. package/dist/src/capability/bot/service.js +49 -0
  18. package/dist/src/capability/bot/stream-delivery.js +321 -0
  19. package/dist/src/capability/bot/stream-finalizer.js +81 -0
  20. package/dist/src/capability/bot/stream-orchestrator.js +318 -0
  21. package/dist/src/capability/bot/types.js +1 -0
  22. package/{src/capability/calendar/client.ts → dist/src/capability/calendar/client.js} +118 -241
  23. package/{src/capability/calendar/schema.ts → dist/src/capability/calendar/schema.js} +0 -38
  24. package/dist/src/capability/calendar/tool.js +365 -0
  25. package/dist/src/capability/calendar/types.js +12 -0
  26. package/{src/capability/doc/client.ts → dist/src/capability/doc/client.js} +370 -605
  27. package/{src/capability/doc/schema.ts → dist/src/capability/doc/schema.js} +345 -394
  28. package/dist/src/capability/doc/tool.js +1556 -0
  29. package/dist/src/capability/doc/types.js +113 -0
  30. package/dist/src/capability/mcp/index.js +3 -0
  31. package/dist/src/capability/mcp/schema.js +102 -0
  32. package/dist/src/capability/mcp/tool.js +146 -0
  33. package/dist/src/capability/mcp/transport.js +293 -0
  34. package/dist/src/channel.js +224 -0
  35. package/dist/src/config/accounts.js +236 -0
  36. package/dist/src/config/derived-paths.js +31 -0
  37. package/dist/src/config/index.js +7 -0
  38. package/dist/src/config/media.js +110 -0
  39. package/dist/src/config/network.js +32 -0
  40. package/dist/src/config/routing.js +20 -0
  41. package/dist/src/config/runtime-config.js +25 -0
  42. package/dist/src/config/schema.js +4 -0
  43. package/{src/config-schema.ts → dist/src/config-schema.js} +1 -1
  44. package/dist/src/context-store.js +219 -0
  45. package/{src/crypto/aes.ts → dist/src/crypto/aes.js} +11 -28
  46. package/dist/src/crypto/index.js +9 -0
  47. package/{src/crypto/signature.ts → dist/src/crypto/signature.js} +3 -18
  48. package/{src/crypto/xml.ts → dist/src/crypto/xml.js} +3 -11
  49. package/dist/src/crypto.js +145 -0
  50. package/dist/src/domain/models.js +1 -0
  51. package/dist/src/domain/policies.js +32 -0
  52. package/{src/dynamic-agent.ts → dist/src/dynamic-agent.js} +36 -73
  53. package/dist/src/gateway-monitor.js +139 -0
  54. package/dist/src/http.js +114 -0
  55. package/{src/media.ts → dist/src/media.js} +21 -40
  56. package/dist/src/monitor/limits.js +7 -0
  57. package/dist/src/monitor/state.js +28 -0
  58. package/dist/src/monitor.js +84 -0
  59. package/dist/src/observability/audit-log.js +30 -0
  60. package/dist/src/observability/legacy-operational-event-store.js +22 -0
  61. package/dist/src/observability/raw-envelope-log.js +24 -0
  62. package/dist/src/observability/status-registry.js +9 -0
  63. package/dist/src/observability/transport-session-view.js +14 -0
  64. package/dist/src/onboarding.js +546 -0
  65. package/dist/src/outbound.js +557 -0
  66. package/dist/src/runtime/dispatcher.js +57 -0
  67. package/{src/runtime/index.ts → dist/src/runtime/index.js} +0 -1
  68. package/dist/src/runtime/outbound-intent.js +1 -0
  69. package/dist/src/runtime/reply-orchestrator.js +38 -0
  70. package/dist/src/runtime/routing-bridge.js +26 -0
  71. package/dist/src/runtime/session-manager.js +112 -0
  72. package/dist/src/runtime/source-registry.js +174 -0
  73. package/dist/src/runtime.js +1 -0
  74. package/dist/src/shared/command-auth.js +57 -0
  75. package/{src/shared/index.ts → dist/src/shared/index.js} +0 -1
  76. package/dist/src/shared/media-asset.js +65 -0
  77. package/dist/src/shared/media-service.js +59 -0
  78. package/dist/src/shared/media-types.js +1 -0
  79. package/{src/shared/xml-parser.ts → dist/src/shared/xml-parser.js} +72 -63
  80. package/dist/src/store/active-reply-store.js +41 -0
  81. package/dist/src/store/interfaces.js +1 -0
  82. package/dist/src/store/memory-store.js +33 -0
  83. package/dist/src/store/stream-batch-store.js +319 -0
  84. package/{src/target.ts → dist/src/target.js} +15 -48
  85. package/dist/src/transport/agent-api/client.js +168 -0
  86. package/dist/src/transport/agent-api/core.js +337 -0
  87. package/dist/src/transport/agent-api/delivery.js +28 -0
  88. package/dist/src/transport/agent-api/media-upload.js +4 -0
  89. package/dist/src/transport/agent-api/reply.js +24 -0
  90. package/dist/src/transport/agent-api/upstream-delivery.js +30 -0
  91. package/dist/src/transport/agent-api/upstream-media-upload.js +46 -0
  92. package/dist/src/transport/agent-api/upstream-reply.js +26 -0
  93. package/dist/src/transport/agent-callback/http-handler.js +30 -0
  94. package/dist/src/transport/agent-callback/inbound.js +4 -0
  95. package/dist/src/transport/agent-callback/reply.js +8 -0
  96. package/dist/src/transport/agent-callback/request-handler.js +189 -0
  97. package/dist/src/transport/agent-callback/session.js +15 -0
  98. package/dist/src/transport/bot-webhook/active-reply.js +27 -0
  99. package/dist/src/transport/bot-webhook/http-handler.js +31 -0
  100. package/dist/src/transport/bot-webhook/inbound-normalizer.js +496 -0
  101. package/dist/src/transport/bot-webhook/inbound.js +4 -0
  102. package/dist/src/transport/bot-webhook/message-shape.js +98 -0
  103. package/dist/src/transport/bot-webhook/protocol.js +124 -0
  104. package/dist/src/transport/bot-webhook/reply.js +9 -0
  105. package/dist/src/transport/bot-webhook/request-handler.js +285 -0
  106. package/dist/src/transport/bot-webhook/session.js +15 -0
  107. package/dist/src/transport/bot-ws/inbound.js +147 -0
  108. package/dist/src/transport/bot-ws/media.js +236 -0
  109. package/dist/src/transport/bot-ws/reply.js +310 -0
  110. package/dist/src/transport/bot-ws/sdk-adapter.js +257 -0
  111. package/dist/src/transport/bot-ws/session.js +15 -0
  112. package/dist/src/transport/http/common.js +78 -0
  113. package/dist/src/transport/http/registry.js +71 -0
  114. package/dist/src/transport/http/request-handler.js +51 -0
  115. package/{src/transport/index.ts → dist/src/transport/index.js} +2 -10
  116. package/dist/src/types/account.js +1 -0
  117. package/dist/src/types/config.js +1 -0
  118. package/dist/src/types/constants.js +28 -0
  119. package/dist/src/types/events.js +1 -0
  120. package/dist/src/types/index.js +1 -0
  121. package/dist/src/types/legacy-stream.js +1 -0
  122. package/dist/src/types/message.js +5 -0
  123. package/dist/src/types/runtime-context.js +1 -0
  124. package/dist/src/types/runtime.js +1 -0
  125. package/dist/src/types.js +1 -0
  126. package/dist/src/upstream/index.js +111 -0
  127. package/dist/src/wecom_msg_adapter/markdown_adapter.js +280 -0
  128. package/openclaw.plugin.json +15 -0
  129. package/package.json +18 -1
  130. package/.github/workflows/release.yml +0 -143
  131. package/GOVERNANCE.md +0 -26
  132. package/MENU_EVENT_CONF.md +0 -500
  133. package/MENU_EVENT_PLAN.md +0 -440
  134. package/SKILLS_CAL.md +0 -895
  135. package/SKILLS_DOC.md +0 -2288
  136. package/UPSTREAM_CONFIG.md +0 -170
  137. package/UPSTREAM_PLAN.md +0 -175
  138. package/assets/01.bot-add.png +0 -0
  139. package/assets/01.bot-setp2.png +0 -0
  140. package/assets/01.image.jpg +0 -0
  141. package/assets/02.agent.add.png +0 -0
  142. package/assets/02.agent.api-set.png +0 -0
  143. package/assets/02.image.jpg +0 -0
  144. package/assets/03.agent.page.png +0 -0
  145. package/assets/03.bot.page.png +0 -0
  146. package/assets/link-me.jpg +0 -0
  147. package/assets/register.png +0 -0
  148. package/changelog/v2.2.28.md +0 -70
  149. package/changelog/v2.3.10.md +0 -17
  150. package/changelog/v2.3.11.md +0 -19
  151. package/changelog/v2.3.12.md +0 -25
  152. package/changelog/v2.3.13.md +0 -19
  153. package/changelog/v2.3.14.md +0 -48
  154. package/changelog/v2.3.15.md +0 -15
  155. package/changelog/v2.3.16.md +0 -11
  156. package/changelog/v2.3.18.md +0 -22
  157. package/changelog/v2.3.19.md +0 -73
  158. package/changelog/v2.3.2.md +0 -28
  159. package/changelog/v2.3.26.md +0 -21
  160. package/changelog/v2.3.27.md +0 -33
  161. package/changelog/v2.3.4.md +0 -20
  162. package/changelog/v2.3.9.md +0 -22
  163. package/changelog/v2.4.12.md +0 -37
  164. package/compat-single-account.md +0 -148
  165. package/index.test.ts +0 -38
  166. package/scripts/test-proxy.ts +0 -70
  167. package/scripts/wecom/README.md +0 -123
  168. package/scripts/wecom/menu-click-help.js +0 -59
  169. package/scripts/wecom/menu-click-help.py +0 -55
  170. package/src/accounts.ts +0 -34
  171. package/src/agent/api-client.upload.test.ts +0 -109
  172. package/src/agent/event-router.test.ts +0 -421
  173. package/src/agent/event-router.ts +0 -272
  174. package/src/agent/handler.event-filter.test.ts +0 -135
  175. package/src/agent/handler.ts +0 -1250
  176. package/src/agent/index.ts +0 -12
  177. package/src/agent/script-runner.ts +0 -186
  178. package/src/agent/test-fixtures/invalid-json-script.mjs +0 -1
  179. package/src/agent/test-fixtures/reply-event-script.mjs +0 -29
  180. package/src/agent/test-fixtures/reply-event-script.py +0 -17
  181. package/src/app/account-runtime.ts +0 -276
  182. package/src/app/bootstrap.ts +0 -29
  183. package/src/app/index.ts +0 -192
  184. package/src/capability/agent/delivery-service.ts +0 -87
  185. package/src/capability/agent/fallback-policy.ts +0 -13
  186. package/src/capability/agent/ingress-service.ts +0 -38
  187. package/src/capability/agent/upstream-delivery-service.ts +0 -96
  188. package/src/capability/bot/dispatch-config.ts +0 -47
  189. package/src/capability/bot/fallback-delivery.ts +0 -178
  190. package/src/capability/bot/local-path-delivery.ts +0 -215
  191. package/src/capability/bot/sandbox-media.test.ts +0 -221
  192. package/src/capability/bot/sandbox-media.ts +0 -176
  193. package/src/capability/bot/service.ts +0 -56
  194. package/src/capability/bot/stream-delivery.ts +0 -379
  195. package/src/capability/bot/stream-finalizer.ts +0 -120
  196. package/src/capability/bot/stream-orchestrator.ts +0 -371
  197. package/src/capability/bot/types.ts +0 -8
  198. package/src/capability/calendar/SKILLS_CHECKLIST.md +0 -251
  199. package/src/capability/calendar/tool.ts +0 -417
  200. package/src/capability/calendar/types.ts +0 -309
  201. package/src/capability/doc/tool.ts +0 -1629
  202. package/src/capability/doc/types.ts +0 -792
  203. package/src/capability/mcp/index.ts +0 -10
  204. package/src/capability/mcp/schema.ts +0 -107
  205. package/src/capability/mcp/tool.ts +0 -174
  206. package/src/capability/mcp/transport.ts +0 -394
  207. package/src/channel.config.test.ts +0 -180
  208. package/src/channel.lifecycle.test.ts +0 -255
  209. package/src/channel.meta.test.ts +0 -26
  210. package/src/channel.ts +0 -256
  211. package/src/config/accounts.resolve.test.ts +0 -75
  212. package/src/config/accounts.ts +0 -312
  213. package/src/config/derived-paths.test.ts +0 -111
  214. package/src/config/derived-paths.ts +0 -41
  215. package/src/config/index.ts +0 -22
  216. package/src/config/media.test.ts +0 -113
  217. package/src/config/media.ts +0 -139
  218. package/src/config/network.ts +0 -20
  219. package/src/config/routing.test.ts +0 -88
  220. package/src/config/routing.ts +0 -26
  221. package/src/config/runtime-config.ts +0 -46
  222. package/src/config/schema.ts +0 -144
  223. package/src/context-store.ts +0 -297
  224. package/src/crypto/index.ts +0 -24
  225. package/src/crypto.test.ts +0 -32
  226. package/src/crypto.ts +0 -176
  227. package/src/domain/models.ts +0 -7
  228. package/src/domain/policies.ts +0 -36
  229. package/src/dynamic-agent.account-scope.test.ts +0 -17
  230. package/src/gateway-monitor.ts +0 -181
  231. package/src/http.ts +0 -137
  232. package/src/media.test.ts +0 -82
  233. package/src/monitor/limits.ts +0 -7
  234. package/src/monitor/state.queue.test.ts +0 -185
  235. package/src/monitor/state.ts +0 -34
  236. package/src/monitor.active.test.ts +0 -245
  237. package/src/monitor.inbound-filter.test.ts +0 -63
  238. package/src/monitor.integration.test.ts +0 -208
  239. package/src/monitor.ts +0 -121
  240. package/src/monitor.webhook.test.ts +0 -774
  241. package/src/observability/audit-log.ts +0 -48
  242. package/src/observability/legacy-operational-event-store.ts +0 -36
  243. package/src/observability/raw-envelope-log.ts +0 -28
  244. package/src/observability/status-registry.ts +0 -13
  245. package/src/observability/transport-session-view.ts +0 -14
  246. package/src/onboarding.test.ts +0 -336
  247. package/src/onboarding.ts +0 -704
  248. package/src/outbound.test.ts +0 -1271
  249. package/src/outbound.ts +0 -746
  250. package/src/runtime/dispatcher.ts +0 -71
  251. package/src/runtime/outbound-intent.ts +0 -4
  252. package/src/runtime/reply-orchestrator.test.ts +0 -71
  253. package/src/runtime/reply-orchestrator.ts +0 -67
  254. package/src/runtime/routing-bridge.test.ts +0 -115
  255. package/src/runtime/routing-bridge.ts +0 -44
  256. package/src/runtime/session-manager.test.ts +0 -174
  257. package/src/runtime/session-manager.ts +0 -139
  258. package/src/runtime/source-registry.ts +0 -249
  259. package/src/runtime.ts +0 -14
  260. package/src/shared/command-auth.ts +0 -87
  261. package/src/shared/media-asset.ts +0 -78
  262. package/src/shared/media-service.test.ts +0 -111
  263. package/src/shared/media-service.ts +0 -84
  264. package/src/shared/media-types.ts +0 -5
  265. package/src/shared/xml-parser.test.ts +0 -50
  266. package/src/store/active-reply-store.ts +0 -42
  267. package/src/store/interfaces.ts +0 -11
  268. package/src/store/memory-store.ts +0 -43
  269. package/src/store/stream-batch-store.ts +0 -350
  270. package/src/transport/agent-api/client.ts +0 -277
  271. package/src/transport/agent-api/core.ts +0 -463
  272. package/src/transport/agent-api/delivery.ts +0 -41
  273. package/src/transport/agent-api/media-upload.ts +0 -11
  274. package/src/transport/agent-api/reply.ts +0 -39
  275. package/src/transport/agent-api/upstream-delivery.ts +0 -45
  276. package/src/transport/agent-api/upstream-media-upload.ts +0 -70
  277. package/src/transport/agent-api/upstream-reply.ts +0 -43
  278. package/src/transport/agent-callback/http-handler.ts +0 -47
  279. package/src/transport/agent-callback/inbound.ts +0 -5
  280. package/src/transport/agent-callback/reply.ts +0 -13
  281. package/src/transport/agent-callback/request-handler.ts +0 -244
  282. package/src/transport/agent-callback/session.ts +0 -23
  283. package/src/transport/bot-webhook/active-reply.ts +0 -39
  284. package/src/transport/bot-webhook/http-handler.ts +0 -48
  285. package/src/transport/bot-webhook/inbound-normalizer.ts +0 -371
  286. package/src/transport/bot-webhook/inbound.ts +0 -5
  287. package/src/transport/bot-webhook/message-shape.ts +0 -89
  288. package/src/transport/bot-webhook/protocol.ts +0 -148
  289. package/src/transport/bot-webhook/reply.ts +0 -15
  290. package/src/transport/bot-webhook/request-handler.ts +0 -394
  291. package/src/transport/bot-webhook/session.ts +0 -23
  292. package/src/transport/bot-ws/inbound.test.ts +0 -96
  293. package/src/transport/bot-ws/inbound.ts +0 -116
  294. package/src/transport/bot-ws/media.test.ts +0 -44
  295. package/src/transport/bot-ws/media.ts +0 -321
  296. package/src/transport/bot-ws/reply.test.ts +0 -450
  297. package/src/transport/bot-ws/reply.ts +0 -365
  298. package/src/transport/bot-ws/sdk-adapter.test.ts +0 -187
  299. package/src/transport/bot-ws/sdk-adapter.ts +0 -314
  300. package/src/transport/bot-ws/session.ts +0 -28
  301. package/src/transport/http/common.ts +0 -109
  302. package/src/transport/http/registry.ts +0 -92
  303. package/src/transport/http/request-handler.ts +0 -84
  304. package/src/types/account.ts +0 -72
  305. package/src/types/config.ts +0 -166
  306. package/src/types/constants.ts +0 -31
  307. package/src/types/events.ts +0 -21
  308. package/src/types/global.d.ts +0 -9
  309. package/src/types/index.ts +0 -17
  310. package/src/types/legacy-stream.ts +0 -50
  311. package/src/types/message.ts +0 -187
  312. package/src/types/runtime-context.ts +0 -28
  313. package/src/types/runtime.ts +0 -165
  314. package/src/types.ts +0 -41
  315. package/src/upstream/index.ts +0 -150
  316. package/src/upstream.test.ts +0 -84
  317. package/src/wecom_msg_adapter/markdown_adapter.ts +0 -331
  318. package/tsconfig.json +0 -22
  319. package/vitest.config.ts +0 -26
  320. /package/{src/capability/agent/index.ts → dist/src/capability/agent/index.js} +0 -0
  321. /package/{src/capability/bot/index.ts → dist/src/capability/bot/index.js} +0 -0
  322. /package/{src/capability/calendar/index.ts → dist/src/capability/calendar/index.js} +0 -0
  323. /package/{src/capability/index.ts → dist/src/capability/index.js} +0 -0
@@ -1,774 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from "node:http";
2
- import { Socket } from "node:net";
3
-
4
- import { describe, expect, it } from "vitest";
5
-
6
- import type { OpenClawConfig } from "openclaw/plugin-sdk";
7
-
8
- import type { ResolvedBotAccount } from "./types/index.js";
9
- import { computeWecomMsgSignature, decryptWecomEncrypted, encryptWecomPlaintext } from "./crypto.js";
10
- import { handleWecomWebhookRequest, registerAgentWebhookTarget, registerWecomWebhookTarget } from "./monitor.js";
11
-
12
- function createMockRequest(params: {
13
- method: "GET" | "POST";
14
- url: string;
15
- body?: unknown;
16
- rawBody?: string;
17
- }): IncomingMessage {
18
- const socket = new Socket();
19
- const req = new IncomingMessage(socket);
20
- req.method = params.method;
21
- req.url = params.url;
22
- if (params.method === "POST") {
23
- if (typeof params.rawBody === "string") {
24
- req.push(params.rawBody);
25
- } else {
26
- req.push(JSON.stringify(params.body ?? {}));
27
- }
28
- }
29
- req.push(null);
30
- return req;
31
- }
32
-
33
- function createMockResponse(): ServerResponse & {
34
- _getData: () => string;
35
- _getStatusCode: () => number;
36
- } {
37
- const req = new IncomingMessage(new Socket());
38
- const res = new ServerResponse(req);
39
- let data = "";
40
- res.write = (chunk: any) => {
41
- data += String(chunk);
42
- return true;
43
- };
44
- res.end = (chunk: any) => {
45
- if (chunk) data += String(chunk);
46
- return res;
47
- };
48
- (res as any)._getData = () => data;
49
- (res as any)._getStatusCode = () => res.statusCode;
50
- return res as any;
51
- }
52
-
53
- function createBotAccount(params: {
54
- accountId?: string;
55
- token: string;
56
- encodingAESKey: string;
57
- receiveId?: string;
58
- streamPlaceholderContent?: string;
59
- aibotid?: string;
60
- }): ResolvedBotAccount {
61
- return {
62
- accountId: params.accountId ?? "default",
63
- configured: true,
64
- primaryTransport: "webhook",
65
- wsConfigured: false,
66
- webhookConfigured: true,
67
- config: {
68
- streamPlaceholderContent: params.streamPlaceholderContent,
69
- aibotid: params.aibotid,
70
- webhook: {
71
- token: params.token,
72
- encodingAESKey: params.encodingAESKey,
73
- receiveId: params.receiveId ?? "",
74
- },
75
- },
76
- token: params.token,
77
- encodingAESKey: params.encodingAESKey,
78
- receiveId: params.receiveId ?? "",
79
- botId: "",
80
- secret: "",
81
- webhook: {
82
- token: params.token,
83
- encodingAESKey: params.encodingAESKey,
84
- receiveId: params.receiveId ?? "",
85
- },
86
- };
87
- }
88
-
89
- describe("handleWecomWebhookRequest", () => {
90
- const token = "test-token";
91
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
92
-
93
- it("handles GET url verification", async () => {
94
- const account = createBotAccount({
95
- token,
96
- encodingAESKey,
97
- });
98
-
99
- const unregister = registerWecomWebhookTarget({
100
- account,
101
- config: {} as OpenClawConfig,
102
- runtime: {},
103
- core: {} as any,
104
- path: "/hook",
105
- });
106
-
107
- try {
108
- const timestamp = "13500001234";
109
- const nonce = "123412323";
110
- const echostr = encryptWecomPlaintext({
111
- encodingAESKey,
112
- receiveId: "",
113
- plaintext: "ping",
114
- });
115
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt: echostr });
116
- const req = createMockRequest({
117
- method: "GET",
118
- url: `/hook?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}&echostr=${encodeURIComponent(echostr)}`,
119
- });
120
- const res = createMockResponse();
121
- const handled = await handleWecomWebhookRequest(req, res);
122
- expect(handled).toBe(true);
123
- expect(res._getStatusCode()).toBe(200);
124
- expect(res._getData()).toBe("ping");
125
- } finally {
126
- unregister();
127
- }
128
- });
129
-
130
- it("handles POST callback and returns encrypted stream placeholder", async () => {
131
- const account = createBotAccount({
132
- token,
133
- encodingAESKey,
134
- });
135
-
136
- const unregister = registerWecomWebhookTarget({
137
- account,
138
- config: {} as OpenClawConfig,
139
- runtime: {},
140
- core: {} as any,
141
- path: "/hook",
142
- });
143
-
144
- try {
145
- const timestamp = "1700000000";
146
- const nonce = "nonce";
147
- const plain = JSON.stringify({
148
- msgid: "MSGID",
149
- aibotid: "AIBOTID",
150
- chattype: "single",
151
- from: { userid: "USERID" },
152
- response_url: "RESPONSEURL",
153
- msgtype: "text",
154
- text: { content: "hello" },
155
- });
156
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
157
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
158
-
159
- const req = createMockRequest({
160
- method: "POST",
161
- url: `/hook?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
162
- body: { encrypt },
163
- });
164
- const res = createMockResponse();
165
- const handled = await handleWecomWebhookRequest(req, res);
166
- expect(handled).toBe(true);
167
- expect(res._getStatusCode()).toBe(200);
168
-
169
- const json = JSON.parse(res._getData()) as any;
170
- expect(typeof json.encrypt).toBe("string");
171
- expect(typeof json.msgsignature).toBe("string");
172
- expect(typeof json.timestamp).toBe("string");
173
- expect(typeof json.nonce).toBe("string");
174
-
175
- const replyPlain = decryptWecomEncrypted({
176
- encodingAESKey,
177
- receiveId: "",
178
- encrypt: json.encrypt,
179
- });
180
- const reply = JSON.parse(replyPlain) as any;
181
- expect(reply.msgtype).toBe("stream");
182
- expect(reply.stream?.content).toBe("1");
183
- expect(reply.stream?.finish).toBe(false);
184
- expect(typeof reply.stream?.id).toBe("string");
185
- expect(reply.stream?.id.length).toBeGreaterThan(0);
186
-
187
- const expectedSig = computeWecomMsgSignature({
188
- token,
189
- timestamp: String(json.timestamp),
190
- nonce: String(json.nonce),
191
- encrypt: String(json.encrypt),
192
- });
193
- expect(json.msgsignature).toBe(expectedSig);
194
- } finally {
195
- unregister();
196
- }
197
- });
198
-
199
- it("supports custom streamPlaceholderContent", async () => {
200
- const account = createBotAccount({
201
- token,
202
- encodingAESKey,
203
- streamPlaceholderContent: "正在思考...",
204
- });
205
-
206
- const unregister = registerWecomWebhookTarget({
207
- account,
208
- config: {} as OpenClawConfig,
209
- runtime: {},
210
- core: {} as any,
211
- path: "/hook",
212
- });
213
-
214
- try {
215
- const timestamp = "1700000001";
216
- const nonce = "nonce2";
217
- const plain = JSON.stringify({
218
- msgid: "MSGID2",
219
- aibotid: "AIBOTID",
220
- chattype: "single",
221
- from: { userid: "USERID2" },
222
- response_url: "RESPONSEURL",
223
- msgtype: "text",
224
- text: { content: "hello" },
225
- });
226
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
227
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
228
-
229
- const req = createMockRequest({
230
- method: "POST",
231
- url: `/hook?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
232
- body: { encrypt },
233
- });
234
- const res = createMockResponse();
235
- const handled = await handleWecomWebhookRequest(req, res);
236
- expect(handled).toBe(true);
237
- expect(res._getStatusCode()).toBe(200);
238
-
239
- const json = JSON.parse(res._getData()) as any;
240
- const replyPlain = decryptWecomEncrypted({
241
- encodingAESKey,
242
- receiveId: "",
243
- encrypt: json.encrypt,
244
- });
245
- const reply = JSON.parse(replyPlain) as any;
246
- expect(reply.msgtype).toBe("stream");
247
- expect(reply.stream?.content).toBe("正在思考...");
248
- expect(reply.stream?.finish).toBe(false);
249
- } finally {
250
- unregister();
251
- }
252
- });
253
-
254
- it("skips bot callbacks with missing sender and returns empty ack", async () => {
255
- const account = createBotAccount({
256
- token,
257
- encodingAESKey,
258
- });
259
-
260
- const unregister = registerWecomWebhookTarget({
261
- account,
262
- config: {} as OpenClawConfig,
263
- runtime: {},
264
- core: {} as any,
265
- path: "/hook",
266
- });
267
-
268
- try {
269
- const timestamp = "1700000001";
270
- const nonce = "nonce-missing-sender";
271
- const plain = JSON.stringify({
272
- msgid: "MSGID-MISSING-SENDER",
273
- aibotid: "AIBOTID",
274
- chattype: "single",
275
- msgtype: "text",
276
- text: { content: "hello" },
277
- });
278
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
279
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
280
-
281
- const req = createMockRequest({
282
- method: "POST",
283
- url: `/hook?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
284
- body: { encrypt },
285
- });
286
- const res = createMockResponse();
287
- const handled = await handleWecomWebhookRequest(req, res);
288
- expect(handled).toBe(true);
289
- expect(res._getStatusCode()).toBe(200);
290
-
291
- const json = JSON.parse(res._getData()) as any;
292
- const replyPlain = decryptWecomEncrypted({
293
- encodingAESKey,
294
- receiveId: "",
295
- encrypt: json.encrypt,
296
- });
297
- expect(JSON.parse(replyPlain)).toEqual({});
298
- } finally {
299
- unregister();
300
- }
301
- });
302
-
303
- it("returns a queued stream for 2, and an ack stream for merged follow-ups", async () => {
304
- const token = "TOKEN";
305
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
306
- const account: any = {
307
- accountId: "default",
308
- configured: true,
309
- token,
310
- encodingAESKey,
311
- receiveId: "",
312
- config: {
313
- streamPlaceholderContent: "正在思考...",
314
- debounceMs: 10_000,
315
- },
316
- };
317
-
318
- const unregister = registerWecomWebhookTarget({
319
- account,
320
- config: {} as OpenClawConfig,
321
- runtime: {},
322
- core: {} as any,
323
- path: "/hook-merge",
324
- });
325
-
326
- try {
327
- const timestamp = "1700000002";
328
- const nonce = "nonce-merge";
329
-
330
- const makeReq = (msgid: string) => {
331
- const plain = JSON.stringify({
332
- msgid,
333
- aibotid: "AIBOTID",
334
- chattype: "single",
335
- from: { userid: "USERID_QUEUE" },
336
- response_url: "RESPONSEURL",
337
- msgtype: "text",
338
- text: { content: "hello" },
339
- });
340
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
341
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
342
- return createMockRequest({
343
- method: "POST",
344
- url: `/hook-merge?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
345
- body: { encrypt },
346
- });
347
- };
348
-
349
- const res1 = createMockResponse();
350
- await handleWecomWebhookRequest(makeReq("MSGID-M1"), res1);
351
- const json1 = JSON.parse(res1._getData()) as any;
352
- const replyPlain1 = decryptWecomEncrypted({ encodingAESKey, receiveId: "", encrypt: json1.encrypt });
353
- const reply1 = JSON.parse(replyPlain1) as any;
354
- expect(reply1.msgtype).toBe("stream");
355
- expect(reply1.stream?.finish).toBe(false);
356
-
357
- const res2 = createMockResponse();
358
- await handleWecomWebhookRequest(makeReq("MSGID-M2"), res2);
359
- const json2 = JSON.parse(res2._getData()) as any;
360
- const replyPlain2 = decryptWecomEncrypted({ encodingAESKey, receiveId: "", encrypt: json2.encrypt });
361
- const reply2 = JSON.parse(replyPlain2) as any;
362
- expect(reply2.msgtype).toBe("stream");
363
- expect(reply2.stream?.finish).toBe(false);
364
- expect(reply2.stream?.id).not.toBe(reply1.stream?.id);
365
- expect(reply2.stream?.content).toContain("排队");
366
-
367
- const res3 = createMockResponse();
368
- await handleWecomWebhookRequest(makeReq("MSGID-M3"), res3);
369
- const json3 = JSON.parse(res3._getData()) as any;
370
- const replyPlain3 = decryptWecomEncrypted({ encodingAESKey, receiveId: "", encrypt: json3.encrypt });
371
- const reply3 = JSON.parse(replyPlain3) as any;
372
- expect(reply3.msgtype).toBe("stream");
373
- // merged follow-up should get its own ack stream (not finished yet);
374
- // it will be updated to a final hint after the merged batch completes.
375
- expect(reply3.stream?.finish).toBe(false);
376
- expect(reply3.stream?.id).not.toBe(reply1.stream?.id);
377
- expect(reply3.stream?.id).not.toBe(reply2.stream?.id);
378
- expect(reply3.stream?.content).toContain("合并");
379
- } finally {
380
- unregister();
381
- }
382
- });
383
-
384
- it("routes bot callback by explicit plugin account path", async () => {
385
- const token = "MATRIX-TOKEN";
386
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
387
-
388
- const unregisterA = registerWecomWebhookTarget({
389
- account: {
390
- accountId: "acct-a",
391
- configured: true,
392
- token,
393
- encodingAESKey,
394
- receiveId: "",
395
- config: {
396
- token,
397
- encodingAESKey,
398
- streamPlaceholderContent: "A处理中",
399
- } as any,
400
- } as any,
401
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
402
- runtime: {},
403
- core: {} as any,
404
- path: "/plugins/wecom/bot/acct-a",
405
- });
406
- const unregisterB = registerWecomWebhookTarget({
407
- account: {
408
- accountId: "acct-b",
409
- configured: true,
410
- token,
411
- encodingAESKey,
412
- receiveId: "",
413
- config: {
414
- token,
415
- encodingAESKey,
416
- streamPlaceholderContent: "B处理中",
417
- } as any,
418
- } as any,
419
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
420
- runtime: {},
421
- core: {} as any,
422
- path: "/plugins/wecom/bot/acct-b",
423
- });
424
-
425
- try {
426
- const timestamp = "1700000999";
427
- const nonce = "nonce-plugin-account";
428
- const plain = JSON.stringify({
429
- msgid: "MATRIX-MSG-1",
430
- aibotid: "BOT_B",
431
- chattype: "single",
432
- from: { userid: "USERID_B" },
433
- response_url: "RESPONSEURL",
434
- msgtype: "text",
435
- text: { content: "hello plugin account path" },
436
- });
437
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
438
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
439
- const req = createMockRequest({
440
- method: "POST",
441
- url: `/plugins/wecom/bot/acct-b?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
442
- body: { encrypt },
443
- });
444
- const res = createMockResponse();
445
- const handled = await handleWecomWebhookRequest(req, res);
446
- expect(handled).toBe(true);
447
- expect(res._getStatusCode()).toBe(200);
448
-
449
- const json = JSON.parse(res._getData()) as any;
450
- const replyPlain = decryptWecomEncrypted({
451
- encodingAESKey,
452
- receiveId: "",
453
- encrypt: json.encrypt,
454
- });
455
- const reply = JSON.parse(replyPlain) as any;
456
- expect(reply.stream?.content).toBe("B处理中");
457
- } finally {
458
- unregisterA();
459
- unregisterB();
460
- }
461
- });
462
-
463
- it("routes bot callback by explicit plugin namespace path", async () => {
464
- const token = "MATRIX-TOKEN-PLUGIN";
465
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
466
-
467
- const unregisterA = registerWecomWebhookTarget({
468
- account: {
469
- accountId: "acct-a",
470
- configured: true,
471
- token,
472
- encodingAESKey,
473
- receiveId: "",
474
- config: {
475
- token,
476
- encodingAESKey,
477
- streamPlaceholderContent: "A处理中",
478
- } as any,
479
- } as any,
480
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
481
- runtime: {},
482
- core: {} as any,
483
- path: "/plugins/wecom/bot/acct-a",
484
- });
485
- const unregisterB = registerWecomWebhookTarget({
486
- account: {
487
- accountId: "acct-b",
488
- configured: true,
489
- token,
490
- encodingAESKey,
491
- receiveId: "",
492
- config: {
493
- token,
494
- encodingAESKey,
495
- streamPlaceholderContent: "B处理中",
496
- } as any,
497
- } as any,
498
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
499
- runtime: {},
500
- core: {} as any,
501
- path: "/plugins/wecom/bot/acct-b",
502
- });
503
-
504
- try {
505
- const timestamp = "1700001000";
506
- const nonce = "nonce-matrix-plugin";
507
- const plain = JSON.stringify({
508
- msgid: "MATRIX-MSG-PLUGIN-1",
509
- aibotid: "BOT_B",
510
- chattype: "single",
511
- from: { userid: "USERID_B_PLUGIN" },
512
- response_url: "RESPONSEURL",
513
- msgtype: "text",
514
- text: { content: "hello matrix plugin path" },
515
- });
516
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
517
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
518
- const req = createMockRequest({
519
- method: "POST",
520
- url: `/plugins/wecom/bot/acct-b?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
521
- body: { encrypt },
522
- });
523
- const res = createMockResponse();
524
- const handled = await handleWecomWebhookRequest(req, res);
525
- expect(handled).toBe(true);
526
- expect(res._getStatusCode()).toBe(200);
527
-
528
- const json = JSON.parse(res._getData()) as any;
529
- const replyPlain = decryptWecomEncrypted({
530
- encodingAESKey,
531
- receiveId: "",
532
- encrypt: json.encrypt,
533
- });
534
- const reply = JSON.parse(replyPlain) as any;
535
- expect(reply.stream?.content).toBe("B处理中");
536
- } finally {
537
- unregisterA();
538
- unregisterB();
539
- }
540
- });
541
-
542
- it("handles default explicit bot path through the shared router only", async () => {
543
- const unregisterTarget = registerWecomWebhookTarget({
544
- account: createBotAccount({
545
- token,
546
- encodingAESKey,
547
- }),
548
- config: {} as OpenClawConfig,
549
- runtime: {},
550
- core: {} as any,
551
- path: "/plugins/wecom/bot/default",
552
- });
553
-
554
- try {
555
- const timestamp = "1700001002";
556
- const nonce = "nonce-default-route";
557
- const echostr = encryptWecomPlaintext({
558
- encodingAESKey,
559
- receiveId: "",
560
- plaintext: "ping",
561
- });
562
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt: echostr });
563
- const req = createMockRequest({
564
- method: "GET",
565
- url: `/plugins/wecom/bot/default?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}&echostr=${encodeURIComponent(echostr)}`,
566
- });
567
- const res = createMockResponse();
568
- const handled = await handleWecomWebhookRequest(req, res);
569
- expect(handled).toBe(true);
570
- expect(res._getStatusCode()).toBe(200);
571
- expect(res._getData()).toBe("ping");
572
- } finally {
573
- unregisterTarget();
574
- }
575
- });
576
-
577
- it("does not reject when aibotid mismatches configured value", async () => {
578
- const token = "MATRIX-TOKEN-2";
579
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
580
- const unregister = registerWecomWebhookTarget({
581
- account: {
582
- accountId: "acct-a",
583
- configured: true,
584
- token,
585
- encodingAESKey,
586
- receiveId: "",
587
- config: {
588
- token,
589
- encodingAESKey,
590
- aibotid: "BOT_ONLY",
591
- } as any,
592
- } as any,
593
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
594
- runtime: {},
595
- core: {} as any,
596
- path: "/hook-matrix-mismatch",
597
- });
598
-
599
- try {
600
- const timestamp = "1700001001";
601
- const nonce = "nonce-matrix-mismatch";
602
- const plain = JSON.stringify({
603
- msgid: "MATRIX-MSG-2",
604
- aibotid: "BOT_OTHER",
605
- chattype: "single",
606
- from: { userid: "USERID_X" },
607
- response_url: "RESPONSEURL",
608
- msgtype: "text",
609
- text: { content: "hello mismatch" },
610
- });
611
- const encrypt = encryptWecomPlaintext({ encodingAESKey, receiveId: "", plaintext: plain });
612
- const msg_signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt });
613
- const req = createMockRequest({
614
- method: "POST",
615
- url: `/hook-matrix-mismatch?msg_signature=${encodeURIComponent(msg_signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}`,
616
- body: { encrypt },
617
- });
618
- const res = createMockResponse();
619
- const handled = await handleWecomWebhookRequest(req, res);
620
- expect(handled).toBe(true);
621
- expect(res._getStatusCode()).toBe(200);
622
- } finally {
623
- unregister();
624
- }
625
- });
626
-
627
- it("rejects legacy paths and accountless plugin paths", async () => {
628
- const token = "MATRIX-TOKEN-3";
629
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
630
- const unregister = registerWecomWebhookTarget({
631
- account: {
632
- accountId: "acct-a",
633
- configured: true,
634
- token,
635
- encodingAESKey,
636
- receiveId: "",
637
- config: { token, encodingAESKey } as any,
638
- } as any,
639
- config: { channels: { wecom: { accounts: { "acct-a": { bot: {} } } } } } as OpenClawConfig,
640
- runtime: {},
641
- core: {} as any,
642
- path: "/plugins/wecom/bot/acct-a",
643
- });
644
- try {
645
- const req = createMockRequest({
646
- method: "GET",
647
- url: "/wecom/bot?timestamp=t&nonce=n&msg_signature=s&echostr=e",
648
- });
649
- const res = createMockResponse();
650
- const handled = await handleWecomWebhookRequest(req, res);
651
- expect(handled).toBe(true);
652
- expect(res._getStatusCode()).toBe(401);
653
- expect(JSON.parse(res._getData())).toMatchObject({
654
- error: "wecom_matrix_path_required",
655
- });
656
-
657
- const pluginReq = createMockRequest({
658
- method: "GET",
659
- url: "/plugins/wecom/bot?timestamp=t&nonce=n&msg_signature=s&echostr=e",
660
- });
661
- const pluginRes = createMockResponse();
662
- const pluginHandled = await handleWecomWebhookRequest(pluginReq, pluginRes);
663
- expect(pluginHandled).toBe(true);
664
- expect(pluginRes._getStatusCode()).toBe(401);
665
- expect(JSON.parse(pluginRes._getData())).toMatchObject({
666
- error: "wecom_matrix_path_required",
667
- });
668
- } finally {
669
- unregister();
670
- }
671
- });
672
-
673
- it("returns account conflict for agent GET verification when multiple accounts share token", async () => {
674
- const token = "AGENT-TOKEN";
675
- const timestamp = "1700002001";
676
- const nonce = "nonce-agent";
677
- const echostr = "ECHOSTR";
678
- const signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt: echostr });
679
-
680
- const unregisterA = registerAgentWebhookTarget({
681
- agent: {
682
- accountId: "agent-a",
683
- configured: true,
684
- corpId: "corp-a",
685
- corpSecret: "secret-a",
686
- agentId: 1001,
687
- token,
688
- encodingAESKey: "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG",
689
- config: {} as any,
690
- },
691
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
692
- runtime: {},
693
- path: "/plugins/wecom/agent/default",
694
- } as any);
695
- const unregisterB = registerAgentWebhookTarget({
696
- agent: {
697
- accountId: "agent-b",
698
- configured: true,
699
- corpId: "corp-b",
700
- corpSecret: "secret-b",
701
- agentId: 1002,
702
- token,
703
- encodingAESKey: "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG",
704
- config: {} as any,
705
- },
706
- config: { channels: { wecom: { accounts: {} } } } as OpenClawConfig,
707
- runtime: {},
708
- path: "/plugins/wecom/agent/default",
709
- } as any);
710
-
711
- try {
712
- const req = createMockRequest({
713
- method: "GET",
714
- url: `/plugins/wecom/agent/default?msg_signature=${encodeURIComponent(signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}&echostr=${encodeURIComponent(echostr)}`,
715
- });
716
- const res = createMockResponse();
717
- const handled = await handleWecomWebhookRequest(req, res);
718
- expect(handled).toBe(true);
719
- expect(res._getStatusCode()).toBe(401);
720
- expect(JSON.parse(res._getData())).toMatchObject({
721
- error: "wecom_account_conflict",
722
- });
723
- } finally {
724
- unregisterA();
725
- unregisterB();
726
- }
727
- });
728
-
729
- it("accepts default agent verification on /wecom/agent/default", async () => {
730
- const token = "AGENT-TOKEN-DEFAULT";
731
- const encodingAESKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
732
- const corpId = "corp-default";
733
- const timestamp = "1700002002";
734
- const nonce = "nonce-agent-default";
735
- const echostr = encryptWecomPlaintext({
736
- encodingAESKey,
737
- receiveId: corpId,
738
- plaintext: "echo-agent-default",
739
- });
740
- const signature = computeWecomMsgSignature({ token, timestamp, nonce, encrypt: echostr });
741
-
742
- const unregister = registerAgentWebhookTarget({
743
- agent: {
744
- accountId: "default",
745
- configured: true,
746
- callbackConfigured: true,
747
- apiConfigured: true,
748
- corpId,
749
- corpSecret: "secret-default",
750
- agentId: 1001,
751
- token,
752
- encodingAESKey,
753
- config: {} as any,
754
- },
755
- config: { channels: { wecom: {} } } as OpenClawConfig,
756
- runtimeEnv: {},
757
- path: "/wecom/agent/default",
758
- });
759
-
760
- try {
761
- const req = createMockRequest({
762
- method: "GET",
763
- url: `/wecom/agent/default?msg_signature=${encodeURIComponent(signature)}&timestamp=${encodeURIComponent(timestamp)}&nonce=${encodeURIComponent(nonce)}&echostr=${encodeURIComponent(echostr)}`,
764
- });
765
- const res = createMockResponse();
766
- const handled = await handleWecomWebhookRequest(req, res);
767
- expect(handled).toBe(true);
768
- expect(res._getStatusCode()).toBe(200);
769
- expect(res._getData()).toBe("echo-agent-default");
770
- } finally {
771
- unregister();
772
- }
773
- });
774
- });