@wecom/wecom-openclaw-plugin 1.0.12-beta.3 → 1.0.13-beta.0
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 +109 -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/src/const.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.0.13-beta.0",
|
|
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.
|
|
60
|
+
"@wecom/aibot-node-sdk": "^1.0.3-beta.3"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
- 所有时间参数使用 `YYYY-MM-DD HH:mm:ss` 格式;用户说"昨天"、"最近一周"等相对时间时,根据当前日期推算
|
|
44
|
+
- `get_messages` 仅支持拉取请求时刻往前 **7 天**内的消息,超出需告知用户此限制
|
|
45
|
+
- 目前仅支持**文本**消息的拉取和发送;用户要求发送图片、文件等需告知不支持
|
|
46
|
+
- 发送消息内容最大 **2048 字节**
|
|
47
|
+
- 会话类型:`1`-单聊(`chatid` 为对方 userid),`2`-群聊(`chatid` 为群 ID)
|
|
48
|
+
- **chatid 查找规则**:当用户提供的是人名或群名而非 ID 时,先调用 `get_msg_chat_list` 拉取会话列表,然后在返回的 `chats` 中按 `chat_name` 进行本地筛选匹配,获取对应的 `chat_id` 作为 `chatid`。匹配策略参照:精确匹配直接使用;模糊匹配到多个结果时展示候选列表让用户选择;无匹配时告知用户未找到
|
|
49
|
+
- **发送消息前必须向用户确认**发送对象和消息内容,防止误发
|
|
50
|
+
- 分页响应中 `has_more` 为 `true` 或 `next_cursor` 不为空时,**必须告知用户还有更多数据**,询问是否继续查看
|
|
51
|
+
- `errcode != 0` 时展示 `errmsg` 中的错误信息;遇 HTTP 错误时主动重试,最多 3 次
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 典型工作流
|
|
56
|
+
|
|
57
|
+
### 查看会话列表
|
|
58
|
+
|
|
59
|
+
**经典 query 示例:**
|
|
60
|
+
- "看看我最近一周有哪些聊天"
|
|
61
|
+
- "这几天谁给我发过消息"
|
|
62
|
+
- "最近有哪些群聊活跃"
|
|
63
|
+
|
|
64
|
+
**流程:**
|
|
65
|
+
1. 根据用户意图计算时间范围(如"最近一周"→近 7 天)
|
|
66
|
+
2. 调用 `get_msg_chat_list` 获取会话列表
|
|
67
|
+
3. 展示会话名称、最后消息时间、消息数量等信息
|
|
68
|
+
4. 若 `has_more` 为 `true`,告知用户还有更多并询问是否继续
|
|
69
|
+
|
|
70
|
+
### 查看聊天记录
|
|
71
|
+
|
|
72
|
+
**经典 query 示例:**
|
|
73
|
+
- "帮我看看和张三最近的聊天记录"
|
|
74
|
+
- "看看项目群里最近的消息"
|
|
75
|
+
- "我和李四昨天聊了什么"
|
|
76
|
+
|
|
77
|
+
**流程:**
|
|
78
|
+
1. **确定 chatid**:调用 `get_msg_chat_list` 拉取会话列表,在 `chats` 中按 `chat_name` 匹配用户提供的人名/群名,获取 `chat_id`
|
|
79
|
+
- 精确匹配到唯一结果:直接使用
|
|
80
|
+
- 模糊匹配到多个结果:展示候选列表,让用户选择
|
|
81
|
+
- 无匹配结果:告知用户未找到对应会话
|
|
82
|
+
2. 根据会话类型设置 `chat_type`(单聊=`1`,群聊=`2`),调用 `get_messages` 拉取消息列表
|
|
83
|
+
3. 展示发送者、时间和消息内容;若 `next_cursor` 不为空,告知用户还有更多消息
|
|
84
|
+
|
|
85
|
+
### 发送消息
|
|
86
|
+
|
|
87
|
+
**经典 query 示例:**
|
|
88
|
+
- "帮我给张三发一条消息:明天会议改到下午3点"
|
|
89
|
+
- "在项目群里发一条消息:今天下午3点开会"
|
|
90
|
+
- "给李四回复:收到,谢谢"
|
|
91
|
+
|
|
92
|
+
**流程:**
|
|
93
|
+
1. **确定 chatid**:调用 `get_msg_chat_list` 拉取会话列表,在 `chats` 中按 `chat_name` 匹配用户提供的人名/群名,获取 `chat_id`
|
|
94
|
+
- 精确匹配到唯一结果:直接使用
|
|
95
|
+
- 模糊匹配到多个结果:展示候选列表,让用户选择
|
|
96
|
+
- 无匹配结果:告知用户未找到对应会话
|
|
97
|
+
2. **确认发送**:向用户确认发送对象和内容(如:"即将向 张三 发送:'明天会议改到下午3点',确认发送吗?")
|
|
98
|
+
3. 用户确认后调用 `send_message` 发送
|
|
99
|
+
4. 展示发送结果
|
|
100
|
+
|
|
101
|
+
### 查看消息并回复
|
|
102
|
+
|
|
103
|
+
**经典 query 示例:**
|
|
104
|
+
- "看看张三给我发了什么,然后帮我回复收到"
|
|
105
|
+
- "查看项目群消息,然后回复一下"
|
|
106
|
+
|
|
107
|
+
**流程:**
|
|
108
|
+
1. 先按"查看聊天记录"流程拉取并展示消息
|
|
109
|
+
2. 再按"发送消息"流程确认并发送回复
|
|
@@ -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
|
+
```
|