@vui-design/openclaw-plugin-feishu-progress 0.2.4 → 0.2.6
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/package.json +1 -1
- package/src/index.ts +17 -15
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { FeishuClient } from './feishu-client.js';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// 常见工具名称中文映射(含 OpenClaw 内部工具名 + Claude 工具名)
|
|
4
4
|
const TOOL_LABEL: Record<string, string> = {
|
|
5
|
+
// OpenClaw 内部工具名
|
|
6
|
+
exec: '执行命令',
|
|
7
|
+
process: '执行进程',
|
|
8
|
+
read: '读取文件',
|
|
9
|
+
write: '写入文件',
|
|
10
|
+
search: '网络搜索',
|
|
11
|
+
fetch: '抓取网页',
|
|
12
|
+
// Claude 工具名
|
|
5
13
|
read_file: '读取文件',
|
|
6
14
|
write_file: '写入文件',
|
|
7
15
|
list_directory: '浏览目录',
|
|
@@ -46,28 +54,24 @@ export default {
|
|
|
46
54
|
domain: cfg.domain ?? 'feishu',
|
|
47
55
|
});
|
|
48
56
|
|
|
49
|
-
// ── 1. 收到用户消息时,记录当前会话对应的飞书
|
|
57
|
+
// ── 1. 收到用户消息时,记录当前会话对应的飞书 ID ─────────────────────────
|
|
50
58
|
api.on('message_received', async (_event: any, ctx: any) => {
|
|
51
|
-
api.logger.info(`[feishu-progress][DEBUG] message_received: channelId=${ctx.channelId} accountId=${ctx.accountId} conversationId=${ctx.conversationId}`);
|
|
52
59
|
if (ctx.channelId !== 'feishu') return;
|
|
53
60
|
if (!ctx.conversationId) return;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
// OpenClaw 内部格式为 "user:ou_xxx" / "group:oc_xxx",剥离前缀取裸 Feishu ID
|
|
62
|
+
const rawId = ctx.conversationId.includes(':')
|
|
63
|
+
? ctx.conversationId.split(':').pop()!
|
|
64
|
+
: ctx.conversationId;
|
|
65
|
+
sessionChatMap.set(ctx.accountId ?? 'default', rawId);
|
|
57
66
|
});
|
|
58
67
|
|
|
59
68
|
// ── 2. 每次工具调用前,自动推送进度到飞书 ──────────────────────────────
|
|
60
69
|
api.on('before_tool_call', async (event: any, ctx: any) => {
|
|
61
|
-
api.logger.info(`[feishu-progress][DEBUG] before_tool_call: tool=${event.toolName} agentId=${ctx.agentId} sessionKey=${ctx.sessionKey}`);
|
|
62
70
|
const key = ctx.agentId ?? ctx.sessionKey ?? 'default';
|
|
63
71
|
const chatId = sessionChatMap.get(key);
|
|
64
|
-
api.logger.info(`[feishu-progress][DEBUG] lookup: key=${key} chatId=${chatId} mapSize=${sessionChatMap.size}`);
|
|
65
72
|
if (!chatId) return;
|
|
66
|
-
|
|
67
|
-
const label = toolLabel(event.toolName);
|
|
68
73
|
try {
|
|
69
|
-
await client.sendText(chatId, `🔧 正在执行:${
|
|
70
|
-
api.logger.info(`[feishu-progress][DEBUG] sendText OK: chatId=${chatId} label=${label}`);
|
|
74
|
+
await client.sendText(chatId, `🔧 正在执行:${toolLabel(event.toolName)}`);
|
|
71
75
|
} catch (err: any) {
|
|
72
76
|
api.logger?.warn(`[feishu-progress] 推送失败: ${err?.message}`);
|
|
73
77
|
}
|
|
@@ -75,9 +79,7 @@ export default {
|
|
|
75
79
|
|
|
76
80
|
// ── 3. 任务结束后清理 session 映射 ───────────────────────────────────────
|
|
77
81
|
api.on('agent_end', async (_event: any, ctx: any) => {
|
|
78
|
-
|
|
79
|
-
api.logger.info(`[feishu-progress][DEBUG] agent_end: key=${key}`);
|
|
80
|
-
sessionChatMap.delete(key);
|
|
82
|
+
sessionChatMap.delete(ctx.agentId ?? ctx.sessionKey ?? 'default');
|
|
81
83
|
});
|
|
82
84
|
},
|
|
83
85
|
};
|