ylib-wecom-openclaw-plugin 2026.4.29

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 (180) hide show
  1. package/README.md +596 -0
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +99 -0
  4. package/dist/src/accounts.d.ts +57 -0
  5. package/dist/src/accounts.js +247 -0
  6. package/dist/src/agent/api-client.d.ts +95 -0
  7. package/dist/src/agent/api-client.js +425 -0
  8. package/dist/src/agent/handler.d.ts +64 -0
  9. package/dist/src/agent/handler.js +731 -0
  10. package/dist/src/agent/index.d.ts +5 -0
  11. package/dist/src/agent/index.js +21 -0
  12. package/dist/src/agent/webhook.d.ts +25 -0
  13. package/dist/src/agent/webhook.js +294 -0
  14. package/dist/src/agent/xml.d.ts +21 -0
  15. package/dist/src/agent/xml.js +43 -0
  16. package/dist/src/channel.d.ts +5 -0
  17. package/dist/src/channel.js +815 -0
  18. package/dist/src/chat-queue.d.ts +31 -0
  19. package/dist/src/chat-queue.js +53 -0
  20. package/dist/src/config-schema.d.ts +587 -0
  21. package/dist/src/config-schema.js +146 -0
  22. package/dist/src/const.d.ts +128 -0
  23. package/dist/src/const.js +168 -0
  24. package/dist/src/dm-policy.d.ts +29 -0
  25. package/dist/src/dm-policy.js +146 -0
  26. package/dist/src/dynamic-agent.d.ts +37 -0
  27. package/dist/src/dynamic-agent.js +67 -0
  28. package/dist/src/dynamic-routing.d.ts +65 -0
  29. package/dist/src/dynamic-routing.js +62 -0
  30. package/dist/src/endpoint-dispatch.d.ts +54 -0
  31. package/dist/src/endpoint-dispatch.js +967 -0
  32. package/dist/src/endpoint-event-adapter.d.ts +15 -0
  33. package/dist/src/endpoint-event-adapter.js +427 -0
  34. package/dist/src/group-policy.d.ts +30 -0
  35. package/dist/src/group-policy.js +126 -0
  36. package/dist/src/http.d.ts +27 -0
  37. package/dist/src/http.js +168 -0
  38. package/dist/src/im-runtime-telemetry.d.ts +25 -0
  39. package/dist/src/im-runtime-telemetry.js +68 -0
  40. package/dist/src/interface.d.ts +192 -0
  41. package/dist/src/interface.js +5 -0
  42. package/dist/src/markdown-chunk.d.ts +1 -0
  43. package/dist/src/markdown-chunk.js +396 -0
  44. package/dist/src/mcp/index.d.ts +6 -0
  45. package/dist/src/mcp/index.js +28 -0
  46. package/dist/src/mcp/interceptors/biz-error.d.ts +11 -0
  47. package/dist/src/mcp/interceptors/biz-error.js +73 -0
  48. package/dist/src/mcp/interceptors/doc-auth-error.d.ts +10 -0
  49. package/dist/src/mcp/interceptors/doc-auth-error.js +235 -0
  50. package/dist/src/mcp/interceptors/index.d.ts +35 -0
  51. package/dist/src/mcp/interceptors/index.js +143 -0
  52. package/dist/src/mcp/interceptors/msg-media.d.ts +11 -0
  53. package/dist/src/mcp/interceptors/msg-media.js +201 -0
  54. package/dist/src/mcp/interceptors/smartpage-create.d.ts +30 -0
  55. package/dist/src/mcp/interceptors/smartpage-create.js +252 -0
  56. package/dist/src/mcp/interceptors/smartpage-export.d.ts +17 -0
  57. package/dist/src/mcp/interceptors/smartpage-export.js +135 -0
  58. package/dist/src/mcp/interceptors/smartsheet-upload.d.ts +22 -0
  59. package/dist/src/mcp/interceptors/smartsheet-upload.js +388 -0
  60. package/dist/src/mcp/interceptors/types.d.ts +64 -0
  61. package/dist/src/mcp/interceptors/types.js +8 -0
  62. package/dist/src/mcp/schema.d.ts +11 -0
  63. package/dist/src/mcp/schema.js +115 -0
  64. package/dist/src/mcp/tool.d.ts +63 -0
  65. package/dist/src/mcp/tool.js +318 -0
  66. package/dist/src/mcp/transport.d.ts +94 -0
  67. package/dist/src/mcp/transport.js +702 -0
  68. package/dist/src/media-handler.d.ts +55 -0
  69. package/dist/src/media-handler.js +306 -0
  70. package/dist/src/media-uploader.d.ts +142 -0
  71. package/dist/src/media-uploader.js +446 -0
  72. package/dist/src/message-parser.d.ts +104 -0
  73. package/dist/src/message-parser.js +232 -0
  74. package/dist/src/message-sender.d.ts +54 -0
  75. package/dist/src/message-sender.js +210 -0
  76. package/dist/src/monitor.d.ts +69 -0
  77. package/dist/src/monitor.js +1846 -0
  78. package/dist/src/onboarding.d.ts +8 -0
  79. package/dist/src/onboarding.js +248 -0
  80. package/dist/src/openclaw-compat.d.ts +148 -0
  81. package/dist/src/openclaw-compat.js +839 -0
  82. package/dist/src/proactive-markdown-send.d.ts +14 -0
  83. package/dist/src/proactive-markdown-send.js +205 -0
  84. package/dist/src/reqid-store.d.ts +23 -0
  85. package/dist/src/reqid-store.js +136 -0
  86. package/dist/src/runtime.d.ts +2 -0
  87. package/dist/src/runtime.js +7 -0
  88. package/dist/src/shared/command-auth.d.ts +23 -0
  89. package/dist/src/shared/command-auth.js +112 -0
  90. package/dist/src/shared/xml-parser.d.ts +46 -0
  91. package/dist/src/shared/xml-parser.js +228 -0
  92. package/dist/src/state-dir-resolve.d.ts +2 -0
  93. package/dist/src/state-dir-resolve.js +33 -0
  94. package/dist/src/state-manager.d.ts +115 -0
  95. package/dist/src/state-manager.js +413 -0
  96. package/dist/src/target.d.ts +35 -0
  97. package/dist/src/target.js +71 -0
  98. package/dist/src/template-card-manager.d.ts +55 -0
  99. package/dist/src/template-card-manager.js +316 -0
  100. package/dist/src/template-card-parser.d.ts +37 -0
  101. package/dist/src/template-card-parser.js +672 -0
  102. package/dist/src/timeout.d.ts +20 -0
  103. package/dist/src/timeout.js +57 -0
  104. package/dist/src/types/account.d.ts +29 -0
  105. package/dist/src/types/account.js +5 -0
  106. package/dist/src/types/config.d.ts +98 -0
  107. package/dist/src/types/config.js +8 -0
  108. package/dist/src/types/constants.d.ts +42 -0
  109. package/dist/src/types/constants.js +45 -0
  110. package/dist/src/types/index.d.ts +7 -0
  111. package/dist/src/types/index.js +17 -0
  112. package/dist/src/types/message.d.ts +238 -0
  113. package/dist/src/types/message.js +6 -0
  114. package/dist/src/utils.d.ts +148 -0
  115. package/dist/src/utils.js +92 -0
  116. package/dist/src/version.d.ts +2 -0
  117. package/dist/src/version.js +28 -0
  118. package/dist/src/webhook/command-auth.d.ts +47 -0
  119. package/dist/src/webhook/command-auth.js +137 -0
  120. package/dist/src/webhook/gateway.d.ts +36 -0
  121. package/dist/src/webhook/gateway.js +297 -0
  122. package/dist/src/webhook/handler.d.ts +19 -0
  123. package/dist/src/webhook/handler.js +481 -0
  124. package/dist/src/webhook/helpers.d.ts +157 -0
  125. package/dist/src/webhook/helpers.js +936 -0
  126. package/dist/src/webhook/http.d.ts +27 -0
  127. package/dist/src/webhook/http.js +168 -0
  128. package/dist/src/webhook/index.d.ts +11 -0
  129. package/dist/src/webhook/index.js +43 -0
  130. package/dist/src/webhook/media.d.ts +30 -0
  131. package/dist/src/webhook/media.js +152 -0
  132. package/dist/src/webhook/monitor.d.ts +59 -0
  133. package/dist/src/webhook/monitor.js +1672 -0
  134. package/dist/src/webhook/state.d.ts +220 -0
  135. package/dist/src/webhook/state.js +568 -0
  136. package/dist/src/webhook/target.d.ts +41 -0
  137. package/dist/src/webhook/target.js +165 -0
  138. package/dist/src/webhook/types.d.ts +348 -0
  139. package/dist/src/webhook/types.js +36 -0
  140. package/dist/src/webhook/video-frame.d.ts +13 -0
  141. package/dist/src/webhook/video-frame.js +108 -0
  142. package/openclaw.plugin.json +19 -0
  143. package/package.json +96 -0
  144. package/schema.json +534 -0
  145. package/scripts/generate-schema.mjs +33 -0
  146. package/skills/wecom-contact/SKILL.md +162 -0
  147. package/skills/wecom-doc/SKILL.md +162 -0
  148. package/skills/wecom-doc/references/create-doc.md +56 -0
  149. package/skills/wecom-doc/references/edit-doc-content.md +68 -0
  150. package/skills/wecom-doc/references/get-doc-content.md +88 -0
  151. package/skills/wecom-doc/references/smartpage-create.md +125 -0
  152. package/skills/wecom-doc/references/smartpage-export.md +160 -0
  153. package/skills/wecom-meeting/SKILL.md +441 -0
  154. package/skills/wecom-meeting/references/example-full.md +30 -0
  155. package/skills/wecom-meeting/references/example-reminder.md +46 -0
  156. package/skills/wecom-meeting/references/example-security.md +22 -0
  157. package/skills/wecom-meeting/references/response-get-meeting-info.md +148 -0
  158. package/skills/wecom-msg/SKILL.md +157 -0
  159. package/skills/wecom-msg/references/api-get-messages.md +93 -0
  160. package/skills/wecom-msg/references/api-get-msg-chat-list.md +58 -0
  161. package/skills/wecom-msg/references/api-get-msg-media.md +44 -0
  162. package/skills/wecom-msg/references/api-send-message.md +39 -0
  163. package/skills/wecom-preflight/SKILL.md +141 -0
  164. package/skills/wecom-schedule/SKILL.md +161 -0
  165. package/skills/wecom-schedule/references/api-check-availability.md +56 -0
  166. package/skills/wecom-schedule/references/api-create-schedule.md +38 -0
  167. package/skills/wecom-schedule/references/api-get-schedule-detail.md +81 -0
  168. package/skills/wecom-schedule/references/api-update-schedule.md +32 -0
  169. package/skills/wecom-schedule/references/ref-reminders.md +24 -0
  170. package/skills/wecom-send-media/SKILL.md +68 -0
  171. package/skills/wecom-send-template-card/SKILL.md +157 -0
  172. package/skills/wecom-send-template-card/references/api-template-card-types.md +358 -0
  173. package/skills/wecom-smartsheet/SKILL.md +164 -0
  174. package/skills/wecom-smartsheet/references/smartsheet-cell-value-formats.md +163 -0
  175. package/skills/wecom-smartsheet/references/smartsheet-field-types.md +44 -0
  176. package/skills/wecom-smartsheet/references/smartsheet-get-records.md +96 -0
  177. package/skills/wecom-smartsheet/references/webhook-examples.md +185 -0
  178. package/skills/wecom-smartsheet/references/webhook-fallback.md +184 -0
  179. package/skills/wecom-todo/SKILL.md +392 -0
  180. package/skills/wecom-todo/examples/workflows.md +163 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 超时控制工具模块
3
+ *
4
+ * 为异步操作提供统一的超时保护机制
5
+ */
6
+ /**
7
+ * 为 Promise 添加超时保护
8
+ *
9
+ * @param promise - 原始 Promise
10
+ * @param timeoutMs - 超时时间(毫秒)
11
+ * @param message - 超时错误消息
12
+ * @returns 带超时保护的 Promise
13
+ */
14
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message?: string): Promise<T>;
15
+ /**
16
+ * 超时错误类型
17
+ */
18
+ export declare class TimeoutError extends Error {
19
+ constructor(message: string);
20
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * 超时控制工具模块
4
+ *
5
+ * 为异步操作提供统一的超时保护机制
6
+ */
7
+ var __extends = (this && this.__extends) || (function () {
8
+ var extendStatics = function (d, b) {
9
+ extendStatics = Object.setPrototypeOf ||
10
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12
+ return extendStatics(d, b);
13
+ };
14
+ return function (d, b) {
15
+ extendStatics(d, b);
16
+ function __() { this.constructor = d; }
17
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
+ };
19
+ })();
20
+ exports.__esModule = true;
21
+ exports.TimeoutError = exports.withTimeout = void 0;
22
+ /**
23
+ * 为 Promise 添加超时保护
24
+ *
25
+ * @param promise - 原始 Promise
26
+ * @param timeoutMs - 超时时间(毫秒)
27
+ * @param message - 超时错误消息
28
+ * @returns 带超时保护的 Promise
29
+ */
30
+ function withTimeout(promise, timeoutMs, message) {
31
+ if (timeoutMs <= 0 || !Number.isFinite(timeoutMs)) {
32
+ return promise;
33
+ }
34
+ var timeoutId;
35
+ var timeoutPromise = new Promise(function (_, reject) {
36
+ timeoutId = setTimeout(function () {
37
+ reject(new TimeoutError(message !== null && message !== void 0 ? message : "Operation timed out after " + timeoutMs + "ms"));
38
+ }, timeoutMs);
39
+ });
40
+ return Promise.race([promise, timeoutPromise])["finally"](function () {
41
+ clearTimeout(timeoutId);
42
+ });
43
+ }
44
+ exports.withTimeout = withTimeout;
45
+ /**
46
+ * 超时错误类型
47
+ */
48
+ var TimeoutError = /** @class */ (function (_super) {
49
+ __extends(TimeoutError, _super);
50
+ function TimeoutError(message) {
51
+ var _this = _super.call(this, message) || this;
52
+ _this.name = "TimeoutError";
53
+ return _this;
54
+ }
55
+ return TimeoutError;
56
+ }(Error));
57
+ exports.TimeoutError = TimeoutError;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WeCom 账号类型定义
3
+ */
4
+ import type { WecomAgentConfig, WecomNetworkConfig } from "./config.js";
5
+ /**
6
+ * 解析后的 Agent 账号
7
+ */
8
+ export declare type ResolvedAgentAccount = {
9
+ /** 账号 ID */
10
+ accountId: string;
11
+ /** 是否启用 */
12
+ enabled: boolean;
13
+ /** 是否配置完整 */
14
+ configured: boolean;
15
+ /** 企业 ID */
16
+ corpId: string;
17
+ /** 应用 Secret */
18
+ corpSecret: string;
19
+ /** 应用 ID (数字,可选) */
20
+ agentId?: number;
21
+ /** 回调 Token */
22
+ token: string;
23
+ /** 回调加密密钥 */
24
+ encodingAESKey: string;
25
+ /** 原始配置 */
26
+ config: WecomAgentConfig;
27
+ /** 网络配置(来自 channels.wecom.network) */
28
+ network?: WecomNetworkConfig;
29
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * WeCom 账号类型定义
4
+ */
5
+ exports.__esModule = true;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * WeCom 子模块配置类型定义
3
+ *
4
+ * 注意:顶层配置类型 WeComConfig 定义在 src/utils.ts 中,以平铺结构为准。
5
+ * 本文件仅定义 Agent/Bot/DM/Network/Media 等子模块的配置类型。
6
+ */
7
+ /** 媒体处理配置 */
8
+ export declare type WecomMediaConfig = {
9
+ /** 临时文件目录(未配置时使用系统临时目录)。 */
10
+ tempDir?: string;
11
+ /** 媒体临时文件保留时长(小时)。 */
12
+ retentionHours?: number;
13
+ /** 启动时是否清理过期临时文件。 */
14
+ cleanupOnStart?: boolean;
15
+ /** 入站/下载媒体大小上限(字节)。 */
16
+ maxBytes?: number;
17
+ };
18
+ /** 网络配置 */
19
+ export declare type WecomNetworkConfig = {
20
+ /** HTTP 请求超时时间(毫秒)。 */
21
+ timeoutMs?: number;
22
+ /** 网络请求重试次数。 */
23
+ retries?: number;
24
+ /** 网络请求重试间隔(毫秒)。 */
25
+ retryDelayMs?: number;
26
+ /**
27
+ * 出口代理(用于企业可信 IP 固定出口场景)。
28
+ * 示例: "http://proxy.company.local:3128"
29
+ */
30
+ egressProxyUrl?: string;
31
+ };
32
+ /**
33
+ * Bot 模式配置 (智能体)
34
+ * 用于接收 JSON 格式回调 + 流式回复
35
+ */
36
+ export declare type WecomBotConfig = {
37
+ /** 智能机器人 ID(用于 Matrix 模式二次身份确认,webhook 模式) */
38
+ aibotid?: string;
39
+ /** 回调 Token (企微后台生成,webhook 模式必填) */
40
+ token?: string;
41
+ /** 回调加密密钥 (企微后台生成,webhook 模式必填) */
42
+ encodingAESKey?: string;
43
+ /**
44
+ * BotId 列表(可选,用于审计与告警)。
45
+ * - 回调路由优先由 URL + 签名决定;botIds 不参与强制拦截。
46
+ * - 当解密后的 aibotid 不在 botIds 中时,仅记录告警日志。
47
+ */
48
+ botIds?: string[];
49
+ /** 接收者 ID (可选,用于解密校验) */
50
+ receiveId?: string;
51
+ /** 流式消息占位符 */
52
+ streamPlaceholderContent?: string;
53
+ /** 欢迎语 */
54
+ welcomeText?: string;
55
+ /** DM 策略: 'open' 允许所有人, 'pairing' 需要配对, 'allowlist' 仅允许列表, 'disabled' 禁用 */
56
+ dmPolicy?: 'open' | 'pairing' | 'allowlist' | 'disabled';
57
+ /** 允许的用户列表,为空表示允许所有人 */
58
+ allowFrom?: Array<string | number>;
59
+ /** 连接模式:固定 websocket(管理端只读;保留 webhook 仅用于历史兼容解析) */
60
+ connectionMode?: 'webhook' | 'websocket';
61
+ /** 机器人 BotID(websocket 模式必填,企微后台获取) */
62
+ botId?: string;
63
+ /** 机器人 Secret(websocket 模式必填,企微后台获取) */
64
+ secret?: string;
65
+ };
66
+ /**
67
+ * Agent 模式配置 (自建应用)
68
+ * 用于接收 XML 格式回调 + API 主动发送
69
+ */
70
+ export declare type WecomAgentConfig = {
71
+ /** 企业 ID */
72
+ corpId: string;
73
+ /** 应用 Secret */
74
+ corpSecret: string;
75
+ /** 应用 ID(可选;不填时可接收回调,但主动发送需具备该字段) */
76
+ agentId?: number | string;
77
+ /** 回调 Token (企微后台「设置API接收」) */
78
+ token: string;
79
+ /** 回调加密密钥 (企微后台「设置API接收」) */
80
+ encodingAESKey: string;
81
+ /** 欢迎语 */
82
+ welcomeText?: string;
83
+ /** DM 策略: 'open' 允许所有人, 'pairing' 需要配对, 'allowlist' 仅允许列表, 'disabled' 禁用 */
84
+ dmPolicy?: 'open' | 'pairing' | 'allowlist' | 'disabled';
85
+ /** 允许的用户列表,为空表示允许所有人 */
86
+ allowFrom?: Array<string | number>;
87
+ };
88
+ /** 动态 Agent 配置 */
89
+ export declare type WecomDynamicAgentsConfig = {
90
+ /** 是否启用动态 Agent */
91
+ enabled?: boolean;
92
+ /** 私聊:是否为每个用户创建独立 Agent */
93
+ dmCreateAgent?: boolean;
94
+ /** 群聊:是否启用动态 Agent */
95
+ groupEnabled?: boolean;
96
+ /** 管理员列表(绕过动态路由,使用主 Agent) */
97
+ adminUsers?: string[];
98
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * WeCom 子模块配置类型定义
4
+ *
5
+ * 注意:顶层配置类型 WeComConfig 定义在 src/utils.ts 中,以平铺结构为准。
6
+ * 本文件仅定义 Agent/Bot/DM/Network/Media 等子模块的配置类型。
7
+ */
8
+ exports.__esModule = true;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WeCom 双模式常量定义
3
+ */
4
+ /** 固定 Webhook 路径 */
5
+ export declare const WEBHOOK_PATHS: {
6
+ /** Bot 模式历史兼容路径(不再维护) */
7
+ readonly BOT: "/wecom";
8
+ /** Bot 模式历史备用兼容路径(不再维护) */
9
+ readonly BOT_ALT: "/wecom/bot";
10
+ /** Agent 模式历史兼容路径(不再维护) */
11
+ readonly AGENT: "/wecom/agent";
12
+ /** Bot 模式推荐路径前缀 */
13
+ readonly BOT_PLUGIN: "/plugins/wecom/bot";
14
+ /** Agent 模式推荐路径前缀 */
15
+ readonly AGENT_PLUGIN: "/plugins/wecom/agent";
16
+ };
17
+ /** 企业微信 API 端点 */
18
+ export declare const API_ENDPOINTS: {
19
+ readonly GET_TOKEN: "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
20
+ readonly SEND_MESSAGE: "https://qyapi.weixin.qq.com/cgi-bin/message/send";
21
+ readonly SEND_APPCHAT: "https://qyapi.weixin.qq.com/cgi-bin/appchat/send";
22
+ readonly UPLOAD_MEDIA: "https://qyapi.weixin.qq.com/cgi-bin/media/upload";
23
+ readonly DOWNLOAD_MEDIA: "https://qyapi.weixin.qq.com/cgi-bin/media/get";
24
+ };
25
+ /** 各类限制常量 */
26
+ export declare const LIMITS: {
27
+ /** 文本消息最大字节数 */
28
+ readonly TEXT_MAX_BYTES: 2048;
29
+ /** Token 刷新缓冲时间 (提前刷新) */
30
+ readonly TOKEN_REFRESH_BUFFER_MS: 60000;
31
+ /** HTTP 请求超时 */
32
+ readonly REQUEST_TIMEOUT_MS: 15000;
33
+ /** 最大请求体大小 */
34
+ readonly MAX_REQUEST_BODY_SIZE: number;
35
+ };
36
+ /** AES 加密常量 */
37
+ export declare const CRYPTO: {
38
+ /** PKCS#7 块大小 */
39
+ readonly PKCS7_BLOCK_SIZE: 32;
40
+ /** AES Key 长度 */
41
+ readonly AES_KEY_LENGTH: 32;
42
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * WeCom 双模式常量定义
4
+ */
5
+ exports.__esModule = true;
6
+ exports.CRYPTO = exports.LIMITS = exports.API_ENDPOINTS = exports.WEBHOOK_PATHS = void 0;
7
+ /** 固定 Webhook 路径 */
8
+ exports.WEBHOOK_PATHS = {
9
+ /** Bot 模式历史兼容路径(不再维护) */
10
+ BOT: "/wecom",
11
+ /** Bot 模式历史备用兼容路径(不再维护) */
12
+ BOT_ALT: "/wecom/bot",
13
+ /** Agent 模式历史兼容路径(不再维护) */
14
+ AGENT: "/wecom/agent",
15
+ /** Bot 模式推荐路径前缀 */
16
+ BOT_PLUGIN: "/plugins/wecom/bot",
17
+ /** Agent 模式推荐路径前缀 */
18
+ AGENT_PLUGIN: "/plugins/wecom/agent"
19
+ };
20
+ /** 企业微信 API 端点 */
21
+ exports.API_ENDPOINTS = {
22
+ GET_TOKEN: "https://qyapi.weixin.qq.com/cgi-bin/gettoken",
23
+ SEND_MESSAGE: "https://qyapi.weixin.qq.com/cgi-bin/message/send",
24
+ SEND_APPCHAT: "https://qyapi.weixin.qq.com/cgi-bin/appchat/send",
25
+ UPLOAD_MEDIA: "https://qyapi.weixin.qq.com/cgi-bin/media/upload",
26
+ DOWNLOAD_MEDIA: "https://qyapi.weixin.qq.com/cgi-bin/media/get"
27
+ };
28
+ /** 各类限制常量 */
29
+ exports.LIMITS = {
30
+ /** 文本消息最大字节数 */
31
+ TEXT_MAX_BYTES: 2048,
32
+ /** Token 刷新缓冲时间 (提前刷新) */
33
+ TOKEN_REFRESH_BUFFER_MS: 60000,
34
+ /** HTTP 请求超时 */
35
+ REQUEST_TIMEOUT_MS: 15000,
36
+ /** 最大请求体大小 */
37
+ MAX_REQUEST_BODY_SIZE: 1024 * 1024
38
+ };
39
+ /** AES 加密常量 */
40
+ exports.CRYPTO = {
41
+ /** PKCS#7 块大小 */
42
+ PKCS7_BLOCK_SIZE: 32,
43
+ /** AES Key 长度 */
44
+ AES_KEY_LENGTH: 32
45
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * WeCom 类型统一导出
3
+ */
4
+ export * from "./constants.js";
5
+ export type { WecomMediaConfig, WecomNetworkConfig, WecomBotConfig, WecomAgentConfig, } from "./config.js";
6
+ export type { ResolvedAgentAccount, } from "./account.js";
7
+ export type { WecomBotInboundBase, WecomBotInboundText, WecomBotInboundVoice, WecomBotInboundVideo, WecomBotInboundStreamRefresh, WecomBotInboundEvent, WecomBotInboundMessage, WecomAgentInboundMessage, WecomInboundQuote, WecomTemplateCard, WecomOutboundMessage, } from "./message.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * WeCom 类型统一导出
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ };
15
+ exports.__esModule = true;
16
+ // 常量
17
+ __exportStar(require("./constants.js"), exports);
@@ -0,0 +1,238 @@
1
+ /**
2
+ * WeCom 消息类型定义
3
+ * Bot 和 Agent 模式共用
4
+ */
5
+ /**
6
+ * Bot 模式入站消息基础结构 (JSON)
7
+ */
8
+ /**
9
+ * **WecomBotInboundBase (Bot 入站消息基类)**
10
+ *
11
+ * Bot 模式下 JSON 格式回调的基础字段。
12
+ * @property msgid 消息 ID
13
+ * @property aibotid 机器人 ID
14
+ * @property chattype 会话类型: "single" | "group"
15
+ * @property chatid 群聊 ID (仅群组时存在)
16
+ * @property response_url 下行回复 URL (用于被动响应转主动推送)
17
+ * @property from 发送者信息
18
+ */
19
+ export declare type WecomBotInboundBase = {
20
+ msgid?: string;
21
+ aibotid?: string;
22
+ chattype?: "single" | "group";
23
+ chatid?: string;
24
+ response_url?: string;
25
+ from?: {
26
+ userid?: string;
27
+ corpid?: string;
28
+ };
29
+ msgtype?: string;
30
+ /** 附件数量 (部分消息存在) */
31
+ attachment_count?: number;
32
+ };
33
+ export declare type WecomBotInboundText = WecomBotInboundBase & {
34
+ msgtype: "text";
35
+ text?: {
36
+ content?: string;
37
+ };
38
+ quote?: WecomInboundQuote;
39
+ };
40
+ export declare type WecomBotInboundVoice = WecomBotInboundBase & {
41
+ msgtype: "voice";
42
+ voice?: {
43
+ content?: string;
44
+ };
45
+ quote?: WecomInboundQuote;
46
+ };
47
+ export declare type WecomBotInboundVideo = WecomBotInboundBase & {
48
+ msgtype: "video";
49
+ video?: {
50
+ url?: string;
51
+ aeskey?: string;
52
+ };
53
+ quote?: WecomInboundQuote;
54
+ };
55
+ export declare type WecomBotInboundStreamRefresh = WecomBotInboundBase & {
56
+ msgtype: "stream";
57
+ stream?: {
58
+ id?: string;
59
+ };
60
+ };
61
+ export declare type WecomBotInboundEvent = WecomBotInboundBase & {
62
+ msgtype: "event";
63
+ create_time?: number;
64
+ event?: {
65
+ eventtype?: string;
66
+ [key: string]: unknown;
67
+ };
68
+ };
69
+ /**
70
+ * **WecomInboundQuote (引用消息)**
71
+ *
72
+ * 消息中引用的原始内容(如回复某条消息)。
73
+ * 支持引用文本、图片、混合类型、语音、文件等。
74
+ */
75
+ export declare type WecomInboundQuote = {
76
+ msgtype?: "text" | "image" | "mixed" | "voice" | "file" | "video";
77
+ /** 引用文本内容 */
78
+ text?: {
79
+ content?: string;
80
+ };
81
+ /** 引用图片 URL */
82
+ image?: {
83
+ url?: string;
84
+ };
85
+ /** 引用混合消息 (图文) */
86
+ mixed?: {
87
+ msg_item?: Array<{
88
+ msgtype: "text" | "image";
89
+ text?: {
90
+ content?: string;
91
+ };
92
+ image?: {
93
+ url?: string;
94
+ };
95
+ }>;
96
+ };
97
+ /** 引用语音 */
98
+ voice?: {
99
+ content?: string;
100
+ };
101
+ /** 引用文件 */
102
+ file?: {
103
+ url?: string;
104
+ };
105
+ /** 引用视频 */
106
+ video?: {
107
+ url?: string;
108
+ };
109
+ };
110
+ export declare type WecomBotInboundMessage = WecomBotInboundText | WecomBotInboundVoice | WecomBotInboundVideo | WecomBotInboundStreamRefresh | WecomBotInboundEvent | (WecomBotInboundBase & {
111
+ quote?: WecomInboundQuote;
112
+ } & Record<string, unknown>);
113
+ /**
114
+ * Agent 模式入站消息结构 (解析自 XML)
115
+ */
116
+ /**
117
+ * **WecomAgentInboundMessage (Agent 入站消息)**
118
+ *
119
+ * Agent 模式下解析自 XML 的扁平化消息结构。
120
+ * 键名保持 PascalCase (如 `ToUserName`)。
121
+ */
122
+ export declare type WecomAgentInboundMessage = {
123
+ ToUserName?: string;
124
+ FromUserName?: string;
125
+ CreateTime?: number;
126
+ MsgType?: string;
127
+ MsgId?: string;
128
+ AgentID?: number;
129
+ Content?: string;
130
+ PicUrl?: string;
131
+ MediaId?: string;
132
+ FileName?: string;
133
+ Format?: string;
134
+ Recognition?: string;
135
+ ThumbMediaId?: string;
136
+ Location_X?: number;
137
+ Location_Y?: number;
138
+ Scale?: number;
139
+ Label?: string;
140
+ Title?: string;
141
+ Description?: string;
142
+ Url?: string;
143
+ Event?: string;
144
+ EventKey?: string;
145
+ ChatId?: string;
146
+ };
147
+ /**
148
+ * 模板卡片类型
149
+ */
150
+ /**
151
+ * **WecomTemplateCard (模板卡片)**
152
+ *
153
+ * 复杂的交互式卡片结构。
154
+ * @property card_type 卡片类型: "text_notice" | "news_notice" | "button_interaction" ...
155
+ * @property source 来源信息
156
+ * @property main_title 主标题
157
+ * @property sub_title_text 副标题
158
+ * @property horizontal_content_list 水平排列的键值列表
159
+ * @property button_list 按钮列表
160
+ */
161
+ export declare type WecomTemplateCard = {
162
+ card_type: "text_notice" | "news_notice" | "button_interaction" | "vote_interaction" | "multiple_interaction";
163
+ source?: {
164
+ icon_url?: string;
165
+ desc?: string;
166
+ desc_color?: number;
167
+ };
168
+ main_title?: {
169
+ title?: string;
170
+ desc?: string;
171
+ };
172
+ task_id?: string;
173
+ button_list?: Array<{
174
+ text: string;
175
+ style?: number;
176
+ key: string;
177
+ }>;
178
+ sub_title_text?: string;
179
+ horizontal_content_list?: Array<{
180
+ keyname: string;
181
+ value?: string;
182
+ type?: number;
183
+ url?: string;
184
+ userid?: string;
185
+ }>;
186
+ card_action?: {
187
+ type: number;
188
+ url?: string;
189
+ appid?: string;
190
+ pagepath?: string;
191
+ };
192
+ action_menu?: {
193
+ desc: string;
194
+ action_list: Array<{
195
+ text: string;
196
+ key: string;
197
+ }>;
198
+ };
199
+ select_list?: Array<{
200
+ question_key: string;
201
+ title?: string;
202
+ selected_id?: string;
203
+ option_list: Array<{
204
+ id: string;
205
+ text: string;
206
+ }>;
207
+ }>;
208
+ submit_button?: {
209
+ text: string;
210
+ key: string;
211
+ };
212
+ checkbox?: {
213
+ question_key: string;
214
+ option_list: Array<{
215
+ id: string;
216
+ text: string;
217
+ is_checked?: boolean;
218
+ }>;
219
+ mode?: number;
220
+ };
221
+ };
222
+ /**
223
+ * 出站消息类型
224
+ */
225
+ export declare type WecomOutboundMessage = {
226
+ msgtype: "text";
227
+ text: {
228
+ content: string;
229
+ };
230
+ } | {
231
+ msgtype: "markdown";
232
+ markdown: {
233
+ content: string;
234
+ };
235
+ } | {
236
+ msgtype: "template_card";
237
+ template_card: WecomTemplateCard;
238
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * WeCom 消息类型定义
4
+ * Bot 和 Agent 模式共用
5
+ */
6
+ exports.__esModule = true;