@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.
@@ -62,3 +62,9 @@ export declare const FILE_MAX_BYTES: number;
62
62
  export declare const ABSOLUTE_MAX_BYTES: number;
63
63
  /** 上传分片大小(字节,Base64 编码前):512KB */
64
64
  export declare const UPLOAD_CHUNK_SIZE: number;
65
+ /** 版本检查事件名称(SDK 事件监听用) */
66
+ export declare const EVENT_ENTER_CHECK_UPDATE = "event.enter_check_update";
67
+ /** 版本检查事件回复命令名称 */
68
+ export declare const CMD_ENTER_EVENT_REPLY = "ww_ai_robot_enter_event";
69
+ /** WSClient scene 参数:企微 OpenClaw 场景 */
70
+ export declare const SCENE_WECOM_OPENCLAW = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecom/wecom-openclaw-plugin",
3
- "version": "1.0.12",
3
+ "version": "1.0.13-beta.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -57,6 +57,6 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "file-type": "^21.3.0",
60
- "@wecom/aibot-node-sdk": "^1.0.2"
60
+ "@wecom/aibot-node-sdk": "^1.0.3-beta.3"
61
61
  }
62
62
  }
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: wecom-msg
3
+ description: 企业微信消息技能。提供会话列表查询、消息记录拉取和文本消息发送能力。当用户需要"查看消息"、"看聊天记录"、"发消息给某人"、"最近有什么消息"、"给群里发消息"时触发。
4
+ metadata:
5
+ {
6
+ "openclaw": { "emoji": "💬" },
7
+ }
8
+ ---
9
+
10
+ # 企业微信消息技能
11
+
12
+ > `wecom_mcp` 是一个 MCP tool,所有操作通过调用该 tool 完成。
13
+
14
+ > ⚠️ **前置条件**:首次调用 `wecom_mcp` 前,必须按 `wecom-preflight` 技能执行前置条件检查,确保工具已加入白名单。
15
+
16
+ 通过 `wecom_mcp call msg <接口名> '<json入参>'` 与企业微信消息系统交互。
17
+
18
+ ---
19
+
20
+ ## 接口列表
21
+
22
+ ### get_msg_chat_list — 获取会话列表
23
+
24
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_msg_chat_list '{"begin_time": "2026-03-11 00:00:00", "end_time": "2026-03-17 23:59:59"}'`
25
+
26
+ 按时间范围查询有消息的会话列表,支持分页。参见 [API 详情](references/api-get-msg-chat-list.md)。
27
+
28
+ ### get_messages — 拉取会话消息
29
+
30
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_messages '{"chat_type": 1, "chatid": "zhangsan", "begin_time": "2026-03-17 09:00:00", "end_time": "2026-03-17 18:00:00"}'`
31
+
32
+ 根据会话类型和 ID 拉取指定时间范围内的消息记录,支持分页。仅支持 7 天内。参见 [API 详情](references/api-get-messages.md)。
33
+
34
+ ### send_message — 发送文本消息
35
+
36
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg send_message '{"chat_type": 1, "chatid": "zhangsan", "msgtype": "text", "text": {"content": "hello world"}}'`
37
+
38
+ 向单聊或群聊发送文本消息。参见 [API 详情](references/api-send-message.md)。
39
+
40
+ ---
41
+
42
+ ## 核心规则
43
+
44
+ ### 时间范围规则
45
+ - **格式**:所有时间参数使用 `YYYY-MM-DD HH:mm:ss` 格式
46
+ - **默认范围**:用户未指定时,默认使用最近7天(当前时间往前推7天)
47
+ - **限制**:开始时间不能早于当前时间的7天前,不能晚于当前时间
48
+ - **相对时间支持**:支持"昨天"、"最近三天"等自动推算
49
+
50
+ ### chatid查找规则
51
+ - 当用户提供人名或群名而非ID时:
52
+ 1. 调用 `get_msg_chat_list` 获取会话列表
53
+ 2. 在 `chats` 中按 `chat_name` 匹配
54
+ 3. **匹配策略**:
55
+ - 精确匹配唯一结果:直接使用
56
+ - 模糊匹配多个结果:展示候选列表让用户选择
57
+ - 无匹配结果:告知用户未找到
58
+
59
+ ### userid转username
60
+ **流程**:
61
+ 1. 调用 `wecom-contact-lookup get_userlist` 获取用户列表
62
+ 2. 建立userid到username的映射关系
63
+ 3. **展示策略**:
64
+ - 精确匹配:显示username
65
+ - 无匹配:保持显示userid
66
+
67
+ ---
68
+
69
+ ## 典型工作流
70
+
71
+ ### 查看会话列表
72
+ **用户query示例**:
73
+ - "看看我最近一周有哪些聊天"
74
+ - "这几天谁给我发过消息"
75
+
76
+ **执行流程**:
77
+ 1. 确定时间范围(用户指定或默认7天)
78
+ 2. 验证时间参数有效性
79
+ 3. 调用 `get_msg_chat_list`
80
+ 4. 展示会话信息
81
+ 5. 分页提示(如有更多数据)
82
+
83
+ ### 查看聊天记录
84
+ **用户query示例**:
85
+ - "帮我看看和张三最近的聊天记录"
86
+ - "看看项目群里最近的消息"
87
+
88
+ **执行流程**:
89
+ 1. 通过chatid查找规则确定目标会话
90
+ 2. 确定时间范围
91
+ 3. 查询user name映射关系
92
+ 4. 调用 `get_messages` 拉取消息
93
+ 5. 展示消息(userid转username,链接处理)
94
+ 6. 分页提示
95
+
96
+ ### 发送消息
97
+ **用户query示例**:
98
+ - "帮我给张三发一条消息:明天会议改到下午3点"
99
+ - "在项目群里发一条消息:今天下午3点开会"
100
+
101
+ **执行流程**:
102
+ 1. 通过chatid查找规则确定目标会话
103
+ 2. 直接调用 `send_message` 发送
104
+ 3. 展示发送结果
105
+
106
+ ### 查看消息并回复
107
+ **用户query示例**:
108
+ - "看看张三给我发了什么,然后帮我回复收到"
109
+
110
+ **执行流程**:
111
+ 1. 先执行"查看聊天记录"流程
112
+ 2. 再执行"发送消息"流程
113
+
114
+ ---
115
+
116
+ ## 错误处理
117
+ - **时间范围超限**:告知用户7天限制并调整为有效范围
118
+ - **会话未找到**:明确告知用户未找到对应会话
119
+ - **API错误**:展示具体错误信息,必要时重试
120
+ - **网络问题**:HTTP错误时主动重试最多3次
@@ -0,0 +1,68 @@
1
+ # get_messages API
2
+
3
+ 根据会话类型和会话 ID,拉取指定时间范围内的消息记录。目前仅支持文本类型消息。
4
+
5
+ ## 参数说明
6
+
7
+ | 参数 | 类型 | 必填 | 说明 |
8
+ |------|------|------|------|
9
+ | `chat_type` | integer | ✅ | 会话类型,`1`-单聊,`2`-群聊 |
10
+ | `chatid` | string | ✅ | 会话 ID,单聊时为 userid,群聊时为群 ID,最大 256 字节 |
11
+ | `begin_time` | string | ✅ | 拉取开始时间,格式:`YYYY-MM-DD HH:mm:ss`,仅支持请求时刻往前 **7 天**内 |
12
+ | `end_time` | string | ✅ | 拉取结束时间,格式:`YYYY-MM-DD HH:mm:ss`,必须 ≥ `begin_time` |
13
+ | `cursor` | string | ❌ | 分页游标,首次请求不传,后续传入上次响应的 `next_cursor`,最大 256 字节 |
14
+
15
+ ## 请求示例
16
+
17
+ 单聊:
18
+
19
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_messages '{"chat_type": 1, "chatid": "zhangsan", "begin_time": "2026-03-17 09:00:00", "end_time": "2026-03-17 18:00:00"}'`
20
+
21
+ 群聊:
22
+
23
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_messages '{"chat_type": 2, "chatid": "wrxxxxxxxx", "begin_time": "2026-03-17 09:00:00", "end_time": "2026-03-17 18:00:00"}'`
24
+
25
+ 分页请求:
26
+
27
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_messages '{"chat_type": 1, "chatid": "zhangsan", "begin_time": "2026-03-17 09:00:00", "end_time": "2026-03-17 18:00:00", "cursor": "CURSOR_xxxxxx"}'`
28
+
29
+ ## 返回字段
30
+
31
+ | 字段 | 类型 | 说明 |
32
+ |------|------|------|
33
+ | `errcode` | integer | 返回码,`0` 表示成功 |
34
+ | `errmsg` | string | 错误信息 |
35
+ | `messages` | array | 消息列表 |
36
+ | `messages[].userid` | string | 消息发送者的 userid |
37
+ | `messages[].send_time` | string | 发送时间,格式:`YYYY-MM-DD HH:mm:ss` |
38
+ | `messages[].msgtype` | string | 消息类型,目前仅支持 `text` |
39
+ | `messages[].text.content` | string | 消息内容 |
40
+ | `next_cursor` | string | 分页游标,为空表示已拉取完毕 |
41
+
42
+ ## 响应示例
43
+
44
+ ```json
45
+ {
46
+ "errcode": 0,
47
+ "errmsg": "ok",
48
+ "messages": [
49
+ {
50
+ "userid": "zhangsan",
51
+ "send_time": "2026-03-17 09:30:00",
52
+ "msgtype": "text",
53
+ "text": {
54
+ "content": "你好"
55
+ }
56
+ },
57
+ {
58
+ "userid": "lisi",
59
+ "send_time": "2026-03-17 09:35:00",
60
+ "msgtype": "text",
61
+ "text": {
62
+ "content": "你好,有什么可以帮助你的?"
63
+ }
64
+ }
65
+ ],
66
+ "next_cursor": "CURSOR_xxxxxx"
67
+ }
68
+ ```
@@ -0,0 +1,58 @@
1
+ # get_msg_chat_list API
2
+
3
+ 获取指定时间范围内有消息的会话列表,支持分页查询。
4
+
5
+ ## 参数说明
6
+
7
+ | 参数 | 类型 | 必填 | 说明 |
8
+ |------|------|------|------|
9
+ | `begin_time` | string | ✅ | 拉取开始时间,格式:`YYYY-MM-DD HH:mm:ss` |
10
+ | `end_time` | string | ✅ | 拉取结束时间,格式:`YYYY-MM-DD HH:mm:ss` |
11
+ | `cursor` | string | ❌ | 分页游标,首次请求不传,后续传入上次响应的 `next_cursor`,最大长度 256 |
12
+
13
+ ## 请求示例
14
+
15
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_msg_chat_list '{"begin_time": "2026-03-11 00:00:00", "end_time": "2026-03-17 23:59:59"}'`
16
+
17
+ 分页请求:
18
+
19
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg get_msg_chat_list '{"begin_time": "2026-03-11 00:00:00", "end_time": "2026-03-17 23:59:59", "cursor": "NEXT_CURSOR"}'`
20
+
21
+ ## 返回字段
22
+
23
+ | 字段 | 类型 | 说明 |
24
+ |------|------|------|
25
+ | `errcode` | integer | 返回码,`0` 表示成功 |
26
+ | `errmsg` | string | 错误信息 |
27
+ | `chats` | array | 会话列表 |
28
+ | `chats[].chat_id` | string | 会话 ID |
29
+ | `chats[].chat_name` | string | 会话名称 |
30
+ | `chats[].last_msg_time` | string | 最后一条消息时间,格式:`YYYY-MM-DD HH:mm:ss` |
31
+ | `chats[].msg_count` | integer | 消息数量 |
32
+ | `has_more` | boolean | 是否还有更多数据 |
33
+ | `next_cursor` | string | 分页游标,用于下一次请求 |
34
+
35
+ ## 响应示例
36
+
37
+ ```json
38
+ {
39
+ "errcode": 0,
40
+ "errmsg": "ok",
41
+ "chats": [
42
+ {
43
+ "chat_id": "CHAT_ID",
44
+ "chat_name": "张三",
45
+ "last_msg_time": "2026-03-17 15:30:45",
46
+ "msg_count": 128
47
+ },
48
+ {
49
+ "chat_id": "CHAT_ID_2",
50
+ "chat_name": "项目讨论群",
51
+ "last_msg_time": "2026-03-16 09:12:33",
52
+ "msg_count": 56
53
+ }
54
+ ],
55
+ "has_more": true,
56
+ "next_cursor": "NEXT_CURSOR"
57
+ }
58
+ ```
@@ -0,0 +1,39 @@
1
+ # send_message API
2
+
3
+ 向单聊或群聊发送文本消息。
4
+
5
+ ## 参数说明
6
+
7
+ | 参数 | 类型 | 必填 | 说明 |
8
+ |------|------|------|------|
9
+ | `chat_type` | integer | ✅ | 会话类型,`1`-单聊,`2`-群聊 |
10
+ | `chatid` | string | ✅ | 会话 ID,单聊时为 userid,群聊时为群 ID,最大 256 字节 |
11
+ | `msgtype` | string | ✅ | 消息类型,目前仅支持 `text` |
12
+ | `text` | object | ✅ | 文本消息内容 |
13
+ | `text.content` | string | ✅ | 消息内容,最大 2048 字节 |
14
+
15
+ ## 请求示例
16
+
17
+ 单聊:
18
+
19
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg send_message '{"chat_type": 1, "chatid": "zhangsan", "msgtype": "text", "text": {"content": "hello world"}}'`
20
+
21
+ 群聊:
22
+
23
+ 使用 `wecom_mcp` tool 调用 `wecom_mcp call msg send_message '{"chat_type": 2, "chatid": "wrxxxxxxxx", "msgtype": "text", "text": {"content": "大家好"}}'`
24
+
25
+ ## 返回字段
26
+
27
+ | 字段 | 类型 | 说明 |
28
+ |------|------|------|
29
+ | `errcode` | integer | 返回码,`0` 表示成功 |
30
+ | `errmsg` | string | 错误信息 |
31
+
32
+ ## 响应示例
33
+
34
+ ```json
35
+ {
36
+ "errcode": 0,
37
+ "errmsg": "ok"
38
+ }
39
+ ```