@sunnoy/wecom 1.1.0 → 1.2.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/README.md +81 -67
- package/README_ZH.md +81 -67
- package/crypto.js +110 -83
- package/dynamic-agent.js +70 -87
- package/image-processor.js +86 -93
- package/index.js +926 -217
- package/logger.js +48 -49
- package/package.json +1 -5
- package/stream-manager.js +316 -265
- package/utils.js +76 -238
- package/webhook.js +434 -287
- package/client.js +0 -127
package/README.md
CHANGED
|
@@ -4,24 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
`openclaw-plugin-wecom` is an Enterprise WeChat (WeCom) integration plugin developed for the [OpenClaw](https://github.com/openclaw/openclaw) framework. It enables seamless AI capabilities in Enterprise WeChat with advanced features.
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **Streaming Output**: Built on WeCom's latest AI bot streaming mechanism for smooth typewriter-style responses.
|
|
10
|
+
- **Dynamic Agent Management**: Automatically creates isolated agents per direct message user or group chat, with independent workspaces and conversation contexts.
|
|
11
|
+
- **Deep Group Chat Integration**: Supports group message parsing with @mention triggering.
|
|
12
|
+
- **Rich Message Types**: Handles text, image, voice, mixed (text+image), file, location, and link messages.
|
|
13
|
+
- **Inbound Image Decryption**: Automatically decrypts WeCom-encrypted images using AES-256-CBC for AI vision processing.
|
|
14
|
+
- **Outbound Image Support**: Automatic base64 encoding and sending of local images (screenshots, generated images) via `msg_item` API.
|
|
15
|
+
- **Message Debounce**: Rapid consecutive messages from the same user are merged into a single AI request.
|
|
16
|
+
- **Admin Users**: Configurable admin list that bypasses command allowlist and dynamic agent routing.
|
|
17
|
+
- **Command Allowlist**: Built-in commands (e.g., `/new`, `/status`) with configurable allowlist to restrict sensitive operations.
|
|
18
|
+
- **Security & Authentication**: Full support for WeCom message encryption/decryption, URL verification, and sender validation.
|
|
19
|
+
- **High-Performance Async Processing**: Asynchronous message architecture ensures responsive gateway even during long AI inference.
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
19
22
|
|
|
20
23
|
- [OpenClaw](https://github.com/openclaw/openclaw) installed (version 2026.1.30+)
|
|
21
24
|
- Enterprise WeChat admin access to create intelligent robot applications
|
|
22
25
|
- Server address accessible from Enterprise WeChat (HTTP/HTTPS)
|
|
23
26
|
|
|
24
|
-
##
|
|
27
|
+
## Installation
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
30
|
openclaw plugins install @sunnoy/wecom
|
|
@@ -33,7 +36,7 @@ This command will automatically:
|
|
|
33
36
|
- Update your OpenClaw configuration
|
|
34
37
|
- Register the plugin
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## Configuration
|
|
37
40
|
|
|
38
41
|
Add to your OpenClaw configuration file (`~/.openclaw/openclaw.json`):
|
|
39
42
|
|
|
@@ -51,6 +54,7 @@ Add to your OpenClaw configuration file (`~/.openclaw/openclaw.json`):
|
|
|
51
54
|
"enabled": true,
|
|
52
55
|
"token": "Your Token",
|
|
53
56
|
"encodingAesKey": "Your EncodingAESKey",
|
|
57
|
+
"adminUsers": ["admin-userid"],
|
|
54
58
|
"commands": {
|
|
55
59
|
"enabled": true,
|
|
56
60
|
"allowlist": ["/new", "/status", "/help", "/compact"]
|
|
@@ -67,19 +71,48 @@ Add to your OpenClaw configuration file (`~/.openclaw/openclaw.json`):
|
|
|
67
71
|
| `plugins.entries.wecom.enabled` | boolean | Yes | Enable the plugin |
|
|
68
72
|
| `channels.wecom.token` | string | Yes | WeCom bot Token |
|
|
69
73
|
| `channels.wecom.encodingAesKey` | string | Yes | WeCom message encryption key (43 chars) |
|
|
74
|
+
| `channels.wecom.adminUsers` | array | No | Admin user IDs (bypass command allowlist and dynamic routing) |
|
|
70
75
|
| `channels.wecom.commands.allowlist` | array | No | Command allowlist |
|
|
71
76
|
|
|
72
|
-
##
|
|
77
|
+
## Enterprise WeChat Configuration
|
|
73
78
|
|
|
74
79
|
1. Log in to [Enterprise WeChat Admin Console](https://work.weixin.qq.com/)
|
|
75
|
-
2. Navigate to "Application Management"
|
|
80
|
+
2. Navigate to "Application Management" > "Applications" > "Create Application" > Select "Intelligent Robot"
|
|
76
81
|
3. Configure "Receive Messages":
|
|
77
82
|
- **URL**: `https://your-domain.com/webhooks/wecom`
|
|
78
83
|
- **Token**: Match `channels.wecom.token`
|
|
79
84
|
- **EncodingAESKey**: Match `channels.wecom.encodingAesKey`
|
|
80
85
|
4. Save and enable message receiving
|
|
81
86
|
|
|
82
|
-
##
|
|
87
|
+
## Supported Message Types
|
|
88
|
+
|
|
89
|
+
| Type | Direction | Description |
|
|
90
|
+
|------|-----------|-------------|
|
|
91
|
+
| Text | Inbound/Outbound | Plain text messages |
|
|
92
|
+
| Image | Inbound/Outbound | Encrypted images (inbound are auto-decrypted); outbound via `msg_item` base64 |
|
|
93
|
+
| Voice | Inbound | Auto-transcribed by WeCom, processed as text (DM only) |
|
|
94
|
+
| Mixed | Inbound | Text + image combination messages |
|
|
95
|
+
| File | Inbound | File attachments (downloaded and passed to AI for analysis) |
|
|
96
|
+
| Location | Inbound | Location shares (converted to text description) |
|
|
97
|
+
| Link | Inbound | Shared links (title, description, URL extracted as text) |
|
|
98
|
+
|
|
99
|
+
## Admin Users
|
|
100
|
+
|
|
101
|
+
Admin users bypass the command allowlist and skip dynamic agent routing (routed to the main agent directly).
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"channels": {
|
|
106
|
+
"wecom": {
|
|
107
|
+
"adminUsers": ["user1", "user2"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Admin user IDs are case-insensitive and matched against the WeCom `userid` field.
|
|
114
|
+
|
|
115
|
+
## Dynamic Agent Routing
|
|
83
116
|
|
|
84
117
|
The plugin implements per-user/per-group agent isolation:
|
|
85
118
|
|
|
@@ -90,6 +123,7 @@ The plugin implements per-user/per-group agent isolation:
|
|
|
90
123
|
- **Group Chats**: `wecom-group-<chatId>`
|
|
91
124
|
2. OpenClaw automatically creates/reuses the corresponding agent workspace
|
|
92
125
|
3. Each user/group has independent conversation history and context
|
|
126
|
+
4. **Admin users** skip dynamic routing and use the main agent directly
|
|
93
127
|
|
|
94
128
|
### Advanced Configuration
|
|
95
129
|
|
|
@@ -135,7 +169,7 @@ To route all messages to the default agent:
|
|
|
135
169
|
}
|
|
136
170
|
```
|
|
137
171
|
|
|
138
|
-
##
|
|
172
|
+
## Command Allowlist
|
|
139
173
|
|
|
140
174
|
Prevent regular users from executing sensitive Gateway management commands through WeCom messages.
|
|
141
175
|
|
|
@@ -156,51 +190,33 @@ Prevent regular users from executing sensitive Gateway management commands throu
|
|
|
156
190
|
|
|
157
191
|
| Command | Description | Safety Level |
|
|
158
192
|
|---------|-------------|--------------|
|
|
159
|
-
| `/new` | Reset conversation, start new session |
|
|
160
|
-
| `/compact` | Compress current session context |
|
|
161
|
-
| `/help` | Show help information |
|
|
162
|
-
| `/status` | Show Agent status |
|
|
193
|
+
| `/new` | Reset conversation, start new session | User-level |
|
|
194
|
+
| `/compact` | Compress current session context | User-level |
|
|
195
|
+
| `/help` | Show help information | User-level |
|
|
196
|
+
| `/status` | Show Agent status | User-level |
|
|
163
197
|
|
|
164
|
-
>
|
|
198
|
+
> **Security Note**: Do not add `/gateway`, `/plugins`, or other management commands to the allowlist to prevent regular users from gaining Gateway instance admin privileges. Admin users configured in `adminUsers` bypass this restriction.
|
|
165
199
|
|
|
166
|
-
##
|
|
200
|
+
## Message Debounce
|
|
167
201
|
|
|
168
|
-
|
|
202
|
+
When a user sends multiple messages in rapid succession (within 2 seconds), the plugin automatically merges them into a single AI request. This prevents multiple concurrent LLM calls for the same user and provides a more coherent response.
|
|
169
203
|
|
|
170
|
-
|
|
204
|
+
- The first message's stream receives the AI response
|
|
205
|
+
- Subsequent merged messages show a notice that they have been combined
|
|
206
|
+
- Commands (messages starting with `/`) bypass debounce and are processed immediately
|
|
171
207
|
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
"plugins": {
|
|
175
|
-
"entries": {
|
|
176
|
-
"wecom": { "enabled": true } // ✅ Correct
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
**Do not** use the channel id:
|
|
183
|
-
```json
|
|
184
|
-
{
|
|
185
|
-
"plugins": {
|
|
186
|
-
"entries": {
|
|
187
|
-
"wecom": { "enabled": true } // ❌ Incorrect
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Q: Why does `openclaw doctor` report warnings?
|
|
208
|
+
## FAQ
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
### Q: How does inbound image handling work?
|
|
196
211
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
**A:** WeCom encrypts images sent by users with AES-256-CBC. The plugin automatically:
|
|
213
|
+
1. Downloads the encrypted image from WeCom's URL
|
|
214
|
+
2. Decrypts it using the configured `encodingAesKey`
|
|
215
|
+
3. Saves it locally and passes it to the AI for vision analysis
|
|
200
216
|
|
|
201
|
-
|
|
217
|
+
Mixed messages (text + images) are fully supported — text and images are extracted and sent together.
|
|
202
218
|
|
|
203
|
-
### Q: How does image sending work?
|
|
219
|
+
### Q: How does outbound image sending work?
|
|
204
220
|
|
|
205
221
|
**A:** The plugin automatically handles images generated by OpenClaw (such as browser screenshots):
|
|
206
222
|
|
|
@@ -209,18 +225,16 @@ This will automatically fix common configuration issues.
|
|
|
209
225
|
- **No configuration needed**: Works out of the box with tools like browser screenshot
|
|
210
226
|
- Images appear when the AI completes its response (streaming doesn't support incremental image sending)
|
|
211
227
|
|
|
212
|
-
**Example:**
|
|
213
|
-
```
|
|
214
|
-
User: "Take a screenshot of GitHub homepage"
|
|
215
|
-
AI: [Takes screenshot] → Image displays properly in WeCom ✅
|
|
216
|
-
```
|
|
217
|
-
|
|
218
228
|
If an image fails to process (size limit, invalid format), the text response will still be delivered and an error will be logged.
|
|
219
229
|
|
|
220
230
|
### Q: Does the bot support voice messages?
|
|
221
231
|
|
|
222
232
|
**A:** Yes! Voice messages in direct chats are automatically transcribed by WeCom and processed as text. No additional configuration needed.
|
|
223
233
|
|
|
234
|
+
### Q: Does the bot support file messages?
|
|
235
|
+
|
|
236
|
+
**A:** Yes. Files sent by users are downloaded and passed to the AI as attachments. The AI can analyze file contents (e.g., reading a PDF or parsing a code file). MIME types are auto-detected from the file extension.
|
|
237
|
+
|
|
224
238
|
### Q: How to configure auth token for public-facing OpenClaw with WeCom callbacks?
|
|
225
239
|
|
|
226
240
|
**A:** WeCom bot **does not need** OpenClaw's Gateway Auth Token.
|
|
@@ -248,7 +262,7 @@ If an image fails to process (size limit, invalid format), the text response wil
|
|
|
248
262
|
{
|
|
249
263
|
"channels": {
|
|
250
264
|
"wecom": {
|
|
251
|
-
"encodingAesKey": "..."
|
|
265
|
+
"encodingAesKey": "..."
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
}
|
|
@@ -262,7 +276,7 @@ If an image fails to process (size limit, invalid format), the text response wil
|
|
|
262
276
|
|
|
263
277
|
3. **Check for extra spaces/newlines**: Ensure no leading/trailing whitespace in the key string
|
|
264
278
|
|
|
265
|
-
##
|
|
279
|
+
## Project Structure
|
|
266
280
|
|
|
267
281
|
```
|
|
268
282
|
openclaw-plugin-wecom/
|
|
@@ -270,20 +284,20 @@ openclaw-plugin-wecom/
|
|
|
270
284
|
├── webhook.js # WeCom HTTP communication handler
|
|
271
285
|
├── dynamic-agent.js # Dynamic agent routing logic
|
|
272
286
|
├── stream-manager.js # Streaming response manager
|
|
273
|
-
├──
|
|
274
|
-
├──
|
|
287
|
+
├── image-processor.js # Image encoding/validation for msg_item
|
|
288
|
+
├── crypto.js # WeCom encryption algorithms (message + media)
|
|
275
289
|
├── logger.js # Logging module
|
|
276
|
-
├── utils.js # Utility functions
|
|
290
|
+
├── utils.js # Utility functions (TTL cache, deduplication)
|
|
277
291
|
├── package.json # npm package config
|
|
278
292
|
└── openclaw.plugin.json # OpenClaw plugin manifest
|
|
279
293
|
```
|
|
280
294
|
|
|
281
|
-
##
|
|
295
|
+
## Contributing
|
|
282
296
|
|
|
283
297
|
We welcome contributions! Please submit Issues or Pull Requests for bugs or feature suggestions.
|
|
284
298
|
|
|
285
299
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
286
300
|
|
|
287
|
-
##
|
|
301
|
+
## License
|
|
288
302
|
|
|
289
303
|
This project is licensed under the [ISC License](./LICENSE).
|
package/README_ZH.md
CHANGED
|
@@ -4,24 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
`openclaw-plugin-wecom` 是一个专为 [OpenClaw](https://github.com/openclaw/openclaw) 框架开发的企业微信(WeCom)集成插件。它允许你将强大的 AI 能力无缝接入企业微信,并支持多项高级功能。
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
## 核心特性
|
|
8
|
+
|
|
9
|
+
- **流式输出 (Streaming)**: 基于企业微信最新的 AI 机器人流式分片机制,实现流畅的打字机式回复体验。
|
|
10
|
+
- **动态 Agent 管理**: 默认按"每个私聊用户 / 每个群聊"自动创建独立 Agent。每个 Agent 拥有独立的工作区与对话上下文,实现更强的数据隔离。
|
|
11
|
+
- **群聊深度集成**: 支持群聊消息解析,可通过 @提及(At-mention)精准触发机器人响应。
|
|
12
|
+
- **丰富消息类型**: 支持文本、图片、语音、图文混排、文件、位置、链接等消息类型。
|
|
13
|
+
- **入站图片解密**: 自动解密企业微信 AES-256-CBC 加密的图片,用于 AI 视觉分析。
|
|
14
|
+
- **出站图片发送**: 自动将本地图片(截图、生成的图像)进行 base64 编码,通过 `msg_item` API 发送。
|
|
15
|
+
- **消息防抖合并**: 同一用户在短时间内(2 秒内)连续发送的多条消息会自动合并为一次 AI 请求。
|
|
16
|
+
- **管理员用户**: 可配置管理员列表,绕过指令白名单和动态 Agent 路由限制。
|
|
17
|
+
- **指令白名单**: 内置常用指令支持(如 `/new`、`/status`),并提供指令白名单配置功能。
|
|
18
|
+
- **安全与认证**: 完整支持企业微信消息加解密、URL 验证及发送者身份校验。
|
|
19
|
+
- **高性能异步处理**: 采用异步消息处理架构,确保即使在长耗时 AI 推理过程中,企业微信网关也能保持高响应性。
|
|
20
|
+
|
|
21
|
+
## 前置要求
|
|
19
22
|
|
|
20
23
|
- 已安装 [OpenClaw](https://github.com/openclaw/openclaw) (版本 2026.1.30+)
|
|
21
24
|
- 企业微信管理后台权限,可创建智能机器人应用
|
|
22
25
|
- 可从企业微信访问的服务器地址(HTTP/HTTPS)
|
|
23
26
|
|
|
24
|
-
##
|
|
27
|
+
## 安装
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
30
|
openclaw plugins install @sunnoy/wecom
|
|
@@ -33,7 +36,7 @@ openclaw plugins install @sunnoy/wecom
|
|
|
33
36
|
- 更新 OpenClaw 配置
|
|
34
37
|
- 注册插件
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## 配置
|
|
37
40
|
|
|
38
41
|
在 OpenClaw 配置文件(`~/.openclaw/openclaw.json`)中添加:
|
|
39
42
|
|
|
@@ -51,6 +54,7 @@ openclaw plugins install @sunnoy/wecom
|
|
|
51
54
|
"enabled": true,
|
|
52
55
|
"token": "你的 Token",
|
|
53
56
|
"encodingAesKey": "你的 EncodingAESKey",
|
|
57
|
+
"adminUsers": ["管理员userid"],
|
|
54
58
|
"commands": {
|
|
55
59
|
"enabled": true,
|
|
56
60
|
"allowlist": ["/new", "/status", "/help", "/compact"]
|
|
@@ -67,19 +71,48 @@ openclaw plugins install @sunnoy/wecom
|
|
|
67
71
|
| `plugins.entries.wecom.enabled` | boolean | 是 | 启用插件 |
|
|
68
72
|
| `channels.wecom.token` | string | 是 | 企业微信机器人 Token |
|
|
69
73
|
| `channels.wecom.encodingAesKey` | string | 是 | 企业微信消息加密密钥(43 位) |
|
|
74
|
+
| `channels.wecom.adminUsers` | array | 否 | 管理员用户 ID 列表(绕过指令白名单和动态路由) |
|
|
70
75
|
| `channels.wecom.commands.allowlist` | array | 否 | 允许的指令白名单 |
|
|
71
76
|
|
|
72
|
-
##
|
|
77
|
+
## 企业微信后台配置
|
|
73
78
|
|
|
74
79
|
1. 登录[企业微信管理后台](https://work.weixin.qq.com/)
|
|
75
|
-
2. 进入"应用管理"
|
|
80
|
+
2. 进入"应用管理" > "应用" > "创建应用" > 选择"智能机器人"
|
|
76
81
|
3. 在"接收消息配置"中设置:
|
|
77
82
|
- **URL**: `https://your-domain.com/webhooks/wecom`
|
|
78
83
|
- **Token**: 与 `channels.wecom.token` 一致
|
|
79
84
|
- **EncodingAESKey**: 与 `channels.wecom.encodingAesKey` 一致
|
|
80
85
|
4. 保存配置并启用消息接收
|
|
81
86
|
|
|
82
|
-
##
|
|
87
|
+
## 支持的消息类型
|
|
88
|
+
|
|
89
|
+
| 类型 | 方向 | 说明 |
|
|
90
|
+
|------|------|------|
|
|
91
|
+
| 文本 (text) | 收/发 | 纯文本消息 |
|
|
92
|
+
| 图片 (image) | 收/发 | 入站图片自动解密;出站通过 `msg_item` base64 发送 |
|
|
93
|
+
| 语音 (voice) | 收 | 企业微信自动转文字后处理(仅限私聊) |
|
|
94
|
+
| 图文混排 (mixed) | 收 | 文本 + 图片混合消息 |
|
|
95
|
+
| 文件 (file) | 收 | 文件附件(下载后传给 AI 分析) |
|
|
96
|
+
| 位置 (location) | 收 | 位置分享(转换为文本描述) |
|
|
97
|
+
| 链接 (link) | 收 | 分享链接(提取标题、描述、URL 为文本) |
|
|
98
|
+
|
|
99
|
+
## 管理员用户
|
|
100
|
+
|
|
101
|
+
管理员用户可以绕过指令白名单限制,并跳过动态 Agent 路由(直接路由到主 Agent)。
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"channels": {
|
|
106
|
+
"wecom": {
|
|
107
|
+
"adminUsers": ["user1", "user2"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
管理员用户 ID 不区分大小写,匹配企业微信的 `userid` 字段。
|
|
114
|
+
|
|
115
|
+
## 动态 Agent 路由
|
|
83
116
|
|
|
84
117
|
本插件实现"按人/按群隔离"的 Agent 管理:
|
|
85
118
|
|
|
@@ -90,6 +123,7 @@ openclaw plugins install @sunnoy/wecom
|
|
|
90
123
|
- **群聊**: `wecom-group-<chatId>`
|
|
91
124
|
2. OpenClaw 自动创建/复用对应的 Agent 工作区
|
|
92
125
|
3. 每个用户/群聊拥有独立的对话历史和上下文
|
|
126
|
+
4. **管理员用户**跳过动态路由,直接使用主 Agent
|
|
93
127
|
|
|
94
128
|
### 高级配置
|
|
95
129
|
|
|
@@ -135,7 +169,7 @@ openclaw plugins install @sunnoy/wecom
|
|
|
135
169
|
}
|
|
136
170
|
```
|
|
137
171
|
|
|
138
|
-
##
|
|
172
|
+
## 指令白名单
|
|
139
173
|
|
|
140
174
|
为防止普通用户通过企业微信消息执行敏感的 Gateway 管理指令,本插件支持**指令白名单**机制。
|
|
141
175
|
|
|
@@ -156,51 +190,33 @@ openclaw plugins install @sunnoy/wecom
|
|
|
156
190
|
|
|
157
191
|
| 指令 | 说明 | 安全级别 |
|
|
158
192
|
|------|------|----------|
|
|
159
|
-
| `/new` | 重置当前对话,开启全新会话 |
|
|
160
|
-
| `/compact` | 压缩当前会话上下文 |
|
|
161
|
-
| `/help` | 查看帮助信息 |
|
|
162
|
-
| `/status` | 查看当前 Agent 状态 |
|
|
193
|
+
| `/new` | 重置当前对话,开启全新会话 | 用户级 |
|
|
194
|
+
| `/compact` | 压缩当前会话上下文 | 用户级 |
|
|
195
|
+
| `/help` | 查看帮助信息 | 用户级 |
|
|
196
|
+
| `/status` | 查看当前 Agent 状态 | 用户级 |
|
|
163
197
|
|
|
164
|
-
>
|
|
198
|
+
> **安全提示**:不要将 `/gateway`、`/plugins` 等管理指令添加到白名单,避免普通用户获得 Gateway 实例的管理权限。配置在 `adminUsers` 中的管理员不受此限制。
|
|
165
199
|
|
|
166
|
-
##
|
|
200
|
+
## 消息防抖合并
|
|
167
201
|
|
|
168
|
-
|
|
202
|
+
当用户在短时间内(2 秒内)连续发送多条消息时,插件会自动将它们合并为一次 AI 请求。这样可以避免同一用户触发多个并发的 LLM 调用,提供更连贯的回复。
|
|
169
203
|
|
|
170
|
-
|
|
204
|
+
- 第一条消息的流式通道接收 AI 回复
|
|
205
|
+
- 后续被合并的消息会显示已合并的提示
|
|
206
|
+
- 指令消息(以 `/` 开头)不参与防抖,会立即处理
|
|
171
207
|
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
"plugins": {
|
|
175
|
-
"entries": {
|
|
176
|
-
"wecom": { "enabled": true } // ✅ 正确
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
**不要**使用 channel id:
|
|
183
|
-
```json
|
|
184
|
-
{
|
|
185
|
-
"plugins": {
|
|
186
|
-
"entries": {
|
|
187
|
-
"wecom": { "enabled": true } // ❌ 错误
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Q: 为什么 `openclaw doctor` 报告警告?
|
|
208
|
+
## 常见问题 (FAQ)
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
### Q: 入站图片是怎么处理的?
|
|
196
211
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
**A:** 企业微信使用 AES-256-CBC 加密用户发送的图片。插件会自动:
|
|
213
|
+
1. 从企业微信的 URL 下载加密图片
|
|
214
|
+
2. 使用配置的 `encodingAesKey` 解密
|
|
215
|
+
3. 保存到本地并传给 AI 进行视觉分析
|
|
200
216
|
|
|
201
|
-
|
|
217
|
+
图文混排消息也完全支持——文本和图片会一起提取并发送给 AI。
|
|
202
218
|
|
|
203
|
-
### Q:
|
|
219
|
+
### Q: 出站图片发送是如何工作的?
|
|
204
220
|
|
|
205
221
|
**A:** 插件会自动处理 OpenClaw 生成的图片(如浏览器截图):
|
|
206
222
|
|
|
@@ -209,18 +225,16 @@ openclaw doctor --fix
|
|
|
209
225
|
- **无需配置**:开箱即用,配合浏览器截图等工具自动生效
|
|
210
226
|
- 图片会在 AI 完成回复后显示(流式输出不支持增量发送图片)
|
|
211
227
|
|
|
212
|
-
**示例:**
|
|
213
|
-
```
|
|
214
|
-
用户:"帮我截个 GitHub 首页的图"
|
|
215
|
-
AI:[执行截图] → 图片在企业微信中正常显示 ✅
|
|
216
|
-
```
|
|
217
|
-
|
|
218
228
|
如果图片处理失败(超出大小限制、格式不支持等),文本回复仍会正常发送,错误信息会记录在日志中。
|
|
219
229
|
|
|
220
230
|
### Q: 机器人支持语音消息吗?
|
|
221
231
|
|
|
222
232
|
**A:** 支持!私聊中的语音消息会被企业微信自动转录为文字并作为文本处理,无需额外配置。
|
|
223
233
|
|
|
234
|
+
### Q: 机器人支持文件消息吗?
|
|
235
|
+
|
|
236
|
+
**A:** 支持。用户发送的文件会被下载并作为附件传给 AI。AI 可以分析文件内容(如读取 PDF 或解析代码文件)。MIME 类型根据文件扩展名自动检测。
|
|
237
|
+
|
|
224
238
|
### Q: OpenClaw 开放公网需要 auth token,企业微信回调如何配置?
|
|
225
239
|
|
|
226
240
|
**A:** 企业微信机器人**不需要**配置 OpenClaw 的 Gateway Auth Token。
|
|
@@ -248,7 +262,7 @@ AI:[执行截图] → 图片在企业微信中正常显示 ✅
|
|
|
248
262
|
{
|
|
249
263
|
"channels": {
|
|
250
264
|
"wecom": {
|
|
251
|
-
"encodingAesKey": "..."
|
|
265
|
+
"encodingAesKey": "..."
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
}
|
|
@@ -262,7 +276,7 @@ AI:[执行截图] → 图片在企业微信中正常显示 ✅
|
|
|
262
276
|
|
|
263
277
|
3. **检查是否有多余空格/换行**:确保密钥字符串前后没有空格或换行符
|
|
264
278
|
|
|
265
|
-
##
|
|
279
|
+
## 项目结构
|
|
266
280
|
|
|
267
281
|
```
|
|
268
282
|
openclaw-plugin-wecom/
|
|
@@ -270,20 +284,20 @@ openclaw-plugin-wecom/
|
|
|
270
284
|
├── webhook.js # 企业微信 HTTP 通信处理
|
|
271
285
|
├── dynamic-agent.js # 动态 Agent 分配逻辑
|
|
272
286
|
├── stream-manager.js # 流式回复管理
|
|
273
|
-
├──
|
|
274
|
-
├──
|
|
287
|
+
├── image-processor.js # 图片编码/校验(msg_item)
|
|
288
|
+
├── crypto.js # 企业微信加密算法(消息 + 媒体)
|
|
275
289
|
├── logger.js # 日志模块
|
|
276
|
-
├── utils.js #
|
|
290
|
+
├── utils.js # 工具函数(TTL 缓存、消息去重)
|
|
277
291
|
├── package.json # npm 包配置
|
|
278
292
|
└── openclaw.plugin.json # OpenClaw 插件清单
|
|
279
293
|
```
|
|
280
294
|
|
|
281
|
-
##
|
|
295
|
+
## 贡献规范
|
|
282
296
|
|
|
283
297
|
我们非常欢迎开发者参与贡献!如果你发现了 Bug 或有更好的功能建议,请提交 Issue 或 Pull Request。
|
|
284
298
|
|
|
285
299
|
详见 [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
286
300
|
|
|
287
|
-
##
|
|
301
|
+
## 开源协议
|
|
288
302
|
|
|
289
303
|
本项目采用 [ISC License](./LICENSE) 协议。
|