@wecom/wecom-openclaw-plugin 1.0.12 → 1.0.13-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +41 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +41 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/src/const.d.ts +6 -0
- package/package.json +2 -2
- package/skills/wecom-msg/SKILL.md +120 -0
- package/skills/wecom-msg/references/api-get-messages.md +68 -0
- package/skills/wecom-msg/references/api-get-msg-chat-list.md +58 -0
- package/skills/wecom-msg/references/api-send-message.md +39 -0
package/dist/index.cjs.js
CHANGED
|
@@ -436,6 +436,18 @@ const VOICE_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
436
436
|
const FILE_MAX_BYTES = 20 * 1024 * 1024;
|
|
437
437
|
/** 文件绝对上限(字节):超过此值无法发送,等于 FILE_MAX_BYTES */
|
|
438
438
|
const ABSOLUTE_MAX_BYTES = FILE_MAX_BYTES;
|
|
439
|
+
// ============================================================================
|
|
440
|
+
// 事件/命令名称常量
|
|
441
|
+
// ============================================================================
|
|
442
|
+
/** 版本检查事件名称(SDK 事件监听用) */
|
|
443
|
+
const EVENT_ENTER_CHECK_UPDATE = "event.enter_check_update";
|
|
444
|
+
/** 版本检查事件回复命令名称 */
|
|
445
|
+
const CMD_ENTER_EVENT_REPLY = "ww_ai_robot_enter_event";
|
|
446
|
+
// ============================================================================
|
|
447
|
+
// SDK 连接配置
|
|
448
|
+
// ============================================================================
|
|
449
|
+
/** WSClient scene 参数:企微 OpenClaw 场景 */
|
|
450
|
+
const SCENE_WECOM_OPENCLAW = 1;
|
|
439
451
|
|
|
440
452
|
/**
|
|
441
453
|
* 企业微信消息内容解析模块
|
|
@@ -1573,6 +1585,23 @@ async function cleanupAccount(accountId) {
|
|
|
1573
1585
|
}
|
|
1574
1586
|
}
|
|
1575
1587
|
|
|
1588
|
+
/** 从 package.json 中读取版本号,兼容打包产物和直接运行 .ts 两种场景 */
|
|
1589
|
+
const getVersion = () => {
|
|
1590
|
+
try {
|
|
1591
|
+
// ESM 环境使用 import.meta.url,CJS 环境使用全局 __dirname
|
|
1592
|
+
const currentDir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs.js', document.baseURI).href))));
|
|
1593
|
+
// 直接运行 .ts 时在 src/ 下,打包后在 dist/ 下,都向上一级找 package.json
|
|
1594
|
+
const pkgPath = path.resolve(currentDir, "..", "package.json");
|
|
1595
|
+
const pkg = JSON.parse(node_fs.readFileSync(pkgPath, "utf-8"));
|
|
1596
|
+
return pkg.version ?? "";
|
|
1597
|
+
}
|
|
1598
|
+
catch {
|
|
1599
|
+
return "";
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
/** 插件版本号,来源于 package.json */
|
|
1603
|
+
const PLUGIN_VERSION = getVersion();
|
|
1604
|
+
|
|
1576
1605
|
/**
|
|
1577
1606
|
* 企业微信 WebSocket 监控器主模块
|
|
1578
1607
|
*
|
|
@@ -2079,6 +2108,8 @@ async function monitorWeComProvider(options) {
|
|
|
2079
2108
|
logger,
|
|
2080
2109
|
heartbeatInterval: WS_HEARTBEAT_INTERVAL_MS,
|
|
2081
2110
|
maxReconnectAttempts: WS_MAX_RECONNECT_ATTEMPTS,
|
|
2111
|
+
scene: SCENE_WECOM_OPENCLAW,
|
|
2112
|
+
plug_version: PLUGIN_VERSION,
|
|
2082
2113
|
});
|
|
2083
2114
|
// 清理函数:确保所有资源被释放
|
|
2084
2115
|
const cleanup = async () => {
|
|
@@ -2118,6 +2149,16 @@ async function monitorWeComProvider(options) {
|
|
|
2118
2149
|
cleanup().finally(() => reject(error));
|
|
2119
2150
|
}
|
|
2120
2151
|
});
|
|
2152
|
+
// 监听版本检查事件:收到 enter_check_update 时回复当前插件版本
|
|
2153
|
+
wsClient.on(EVENT_ENTER_CHECK_UPDATE, async (frame) => {
|
|
2154
|
+
try {
|
|
2155
|
+
// runtime.log?.(`[${account.accountId}] Received enter_check_update, replying with version=${PLUGIN_VERSION}`);
|
|
2156
|
+
await wsClient.reply(frame, { version: PLUGIN_VERSION }, CMD_ENTER_EVENT_REPLY);
|
|
2157
|
+
}
|
|
2158
|
+
catch (err) {
|
|
2159
|
+
// runtime.error?.(`[${account.accountId}] Failed to reply enter_check_update: ${String(err)}`);
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
2121
2162
|
// 监听所有消息
|
|
2122
2163
|
wsClient.on("message", async (frame) => {
|
|
2123
2164
|
try {
|
|
@@ -2635,23 +2676,6 @@ const wecomPlugin = {
|
|
|
2635
2676
|
},
|
|
2636
2677
|
};
|
|
2637
2678
|
|
|
2638
|
-
/** 从 package.json 中读取版本号,兼容打包产物和直接运行 .ts 两种场景 */
|
|
2639
|
-
const getVersion = () => {
|
|
2640
|
-
try {
|
|
2641
|
-
// ESM 环境使用 import.meta.url,CJS 环境使用全局 __dirname
|
|
2642
|
-
const currentDir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs.js', document.baseURI).href))));
|
|
2643
|
-
// 直接运行 .ts 时在 src/ 下,打包后在 dist/ 下,都向上一级找 package.json
|
|
2644
|
-
const pkgPath = path.resolve(currentDir, "..", "package.json");
|
|
2645
|
-
const pkg = JSON.parse(node_fs.readFileSync(pkgPath, "utf-8"));
|
|
2646
|
-
return pkg.version ?? "";
|
|
2647
|
-
}
|
|
2648
|
-
catch {
|
|
2649
|
-
return "";
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2652
|
-
/** 插件版本号,来源于 package.json */
|
|
2653
|
-
const PLUGIN_VERSION = getVersion();
|
|
2654
|
-
|
|
2655
2679
|
/**
|
|
2656
2680
|
* MCP Streamable HTTP 传输层模块
|
|
2657
2681
|
*
|