openclaw-plugin-wecom 0.3.1 → 0.3.2
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 +140 -73
- package/README_ZH.md +132 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,78 +1,83 @@
|
|
|
1
|
-
# OpenClaw WeCom AI Bot Plugin
|
|
1
|
+
# OpenClaw WeCom (Enterprise WeChat) AI Bot Plugin
|
|
2
2
|
|
|
3
3
|
[简体中文](https://github.com/sunnoy/openclaw-plugin-wecom/blob/main/README_ZH.md) | [English](https://github.com/sunnoy/openclaw-plugin-wecom/blob/main/README.md)
|
|
4
4
|
|
|
5
|
-
`openclaw-plugin-wecom` is
|
|
5
|
+
`openclaw-plugin-wecom` is a WeCom (Enterprise WeChat) integration plugin developed for the [OpenClaw](https://github.com/openclaw/openclaw) framework. It enables seamless integration of powerful AI capabilities into WeCom with advanced features.
|
|
6
6
|
|
|
7
7
|
## ✨ Key Features
|
|
8
8
|
|
|
9
|
-
- 🌊 **Streaming Output**:
|
|
10
|
-
- 🤖 **Dynamic Agent Management**: Automatically creates
|
|
11
|
-
- 👥 **
|
|
12
|
-
- 🛠️ **
|
|
13
|
-
- 🔒 **Security
|
|
14
|
-
- ⚡ **
|
|
9
|
+
- 🌊 **Streaming Output**: Smooth typewriter-style responses using WeCom's latest AI bot streaming mechanism.
|
|
10
|
+
- 🤖 **Dynamic Agent Management**: Automatically creates independent Agents per user/group chat with isolated workspaces and conversation contexts.
|
|
11
|
+
- 👥 **Group Chat Integration**: Full support for group messages with @mention triggering.
|
|
12
|
+
- 🛠️ **Command Support**: Built-in commands (`/new`, `/status`, `/help`, `/compact`) with configurable whitelist.
|
|
13
|
+
- 🔒 **Security**: Complete support for WeCom message encryption/decryption and sender verification.
|
|
14
|
+
- ⚡ **Async Processing**: High-performance async architecture ensures gateway responsiveness during AI inference.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## 🚀 Quick Start
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
### Option 1: Docker Deployment (Recommended)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
- DM: `wxwork-dm-<userId>`
|
|
22
|
-
- Group: `wxwork-group-<chatId>`
|
|
23
|
-
2. The plugin routes the message by setting `SessionKey` to:
|
|
24
|
-
- `agent:<agentId>:<peerKind>:<peerId>`
|
|
25
|
-
3. OpenClaw extracts `<agentId>` from `SessionKey` and will automatically create / reuse the Agent workspace (typically under `~/.openclaw/workspace-<agentId>` for non-default agents).
|
|
20
|
+
This repository provides a complete Docker deployment solution with automated plugin installation.
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
```bash
|
|
23
|
+
# 1. Clone the repository
|
|
24
|
+
git clone https://github.com/sunnoy/openclaw-plugin-wecom.git
|
|
25
|
+
cd openclaw-plugin-wecom/deploy
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
# 2. Copy environment configuration
|
|
28
|
+
cp .env.example .env
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
# 3. Edit .env file with your settings
|
|
31
|
+
vim .env
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
# 4. Run deployment script
|
|
34
|
+
./deploy.sh
|
|
35
|
+
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
The deployment script automatically:
|
|
38
|
+
- Creates data directories and sets permissions
|
|
39
|
+
- Generates configuration files
|
|
40
|
+
- Starts Docker containers
|
|
41
|
+
- Installs the WeCom plugin
|
|
42
|
+
- Configures and restarts services
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
- `dm.createAgentOnFirstMessage` (boolean, default: `true`): whether DMs should use dynamic agents.
|
|
40
|
-
- `groupChat.enabled` (boolean, default: `true`): enable group chat handling.
|
|
41
|
-
- `groupChat.createAgentOnFirstMessage` (boolean, default: `true`): whether group chats should use dynamic agents.
|
|
42
|
-
- `groupChat.requireMention` (boolean, default: `true`): require an @mention to respond in groups.
|
|
43
|
-
- `groupChat.mentionPatterns` (string[], default: `["@"]`): patterns treated as “mention”.
|
|
44
|
+
#### 🌟 Deployment Highlights
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
**Custom Data Directory & Agent Workspace Paths**
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
48
|
+
The core advantage of this deployment is unified data storage in a custom path, effectively utilizing data disks:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# .env configuration example
|
|
52
|
+
OPENCLAW_DATA_DIR=/data/openclaw # Custom data directory
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
- **OpenClaw State Directory**: `/data/openclaw/`
|
|
56
|
+
- **Dynamic Agent Workspace**: `/data/openclaw/.openclaw/`
|
|
57
|
+
- **Plugin Directory**: `/data/openclaw/extensions/`
|
|
58
|
+
- **Canvas Data**: `/data/openclaw/canvas/`
|
|
59
|
+
|
|
60
|
+
Benefits:
|
|
61
|
+
- ✅ All Agent workspace data stored on data disk, avoiding system disk usage
|
|
62
|
+
- ✅ Independent Agent files for each user/group managed under unified path
|
|
63
|
+
- ✅ Easy backup, migration, and expansion
|
|
64
|
+
- ✅ Enterprise-ready deployment with independently mountable data disks
|
|
58
65
|
|
|
59
|
-
###
|
|
66
|
+
### Option 2: Manual Plugin Installation
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
Install in an existing OpenClaw environment:
|
|
62
69
|
|
|
63
70
|
```bash
|
|
64
71
|
openclaw plugins install openclaw-plugin-wecom
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
Or via npm:
|
|
68
75
|
|
|
69
76
|
```bash
|
|
70
77
|
npm install openclaw-plugin-wecom
|
|
71
78
|
```
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Add the plugin configuration to your OpenClaw configuration file (e.g., `config.json`):
|
|
80
|
+
Then add to your OpenClaw configuration:
|
|
76
81
|
|
|
77
82
|
```json
|
|
78
83
|
{
|
|
@@ -84,52 +89,114 @@ Add the plugin configuration to your OpenClaw configuration file (e.g., `config.
|
|
|
84
89
|
"channels": {
|
|
85
90
|
"wxwork": {
|
|
86
91
|
"enabled": true,
|
|
87
|
-
"token": "
|
|
88
|
-
"encodingAesKey": "
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
"token": "Your Token",
|
|
93
|
+
"encodingAesKey": "Your EncodingAESKey"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### WeCom Backend Setup
|
|
100
|
+
|
|
101
|
+
1. Create an "Intelligent Bot" in WeCom Admin Console.
|
|
102
|
+
2. Set the "Receive Message" URL to your service address (e.g., `https://your-domain.com/webhooks/wxwork`).
|
|
103
|
+
3. Enter the corresponding Token and EncodingAESKey.
|
|
104
|
+
|
|
105
|
+
## 📂 Project Structure
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
openclaw-plugin-wecom/
|
|
109
|
+
├── deploy/ # Deployment files
|
|
110
|
+
│ ├── deploy.sh # One-click deployment script
|
|
111
|
+
│ ├── docker-compose.yml # Docker Compose configuration
|
|
112
|
+
│ ├── .env.example # Environment variables template
|
|
113
|
+
│ ├── openclaw.json.base # Base configuration template
|
|
114
|
+
│ └── openclaw.json.template # Full configuration template
|
|
115
|
+
├── Dockerfile # OpenClaw image build file
|
|
116
|
+
├── local.sh # Local image build script
|
|
117
|
+
├── index.js # Plugin entry point
|
|
118
|
+
├── webhook.js # WeCom HTTP communication
|
|
119
|
+
├── dynamic-agent.js # Dynamic Agent routing
|
|
120
|
+
├── stream-manager.js # Streaming response management
|
|
121
|
+
├── crypto.js # WeCom encryption
|
|
122
|
+
└── client.js # Client logic
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 🤖 Dynamic Agent Routing
|
|
126
|
+
|
|
127
|
+
The plugin implements per-user/per-group isolation:
|
|
128
|
+
|
|
129
|
+
1. On message arrival, generates a deterministic `agentId`:
|
|
130
|
+
- DM: `wxwork-dm-<userId>`
|
|
131
|
+
- Group: `wxwork-group-<chatId>`
|
|
132
|
+
2. OpenClaw automatically creates/reuses the corresponding Agent workspace.
|
|
133
|
+
|
|
134
|
+
### Configuration Options
|
|
135
|
+
|
|
136
|
+
Under `channels.wxwork`:
|
|
137
|
+
|
|
138
|
+
| Option | Type | Default | Description |
|
|
139
|
+
|--------|------|---------|-------------|
|
|
140
|
+
| `dynamicAgents.enabled` | boolean | `true` | Enable dynamic Agents |
|
|
141
|
+
| `dm.createAgentOnFirstMessage` | boolean | `true` | Use dynamic Agent for DMs |
|
|
142
|
+
| `groupChat.enabled` | boolean | `true` | Enable group chat handling |
|
|
143
|
+
| `groupChat.requireMention` | boolean | `true` | Require @mention in groups |
|
|
144
|
+
|
|
145
|
+
To route all messages to the default Agent:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"channels": {
|
|
150
|
+
"wxwork": {
|
|
151
|
+
"dynamicAgents": { "enabled": false }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 🛠️ Command Whitelist
|
|
158
|
+
|
|
159
|
+
To prevent regular users from executing sensitive Gateway management commands via WeCom messages, this plugin supports a **command whitelist** mechanism. Only commands in the whitelist will be executed; others are ignored.
|
|
160
|
+
|
|
161
|
+
> 💡 **Note**: This configuration is already included in `deploy/openclaw.json.template` and takes effect automatically upon deployment.
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"channels": {
|
|
166
|
+
"wxwork": {
|
|
95
167
|
"commands": {
|
|
96
168
|
"enabled": true,
|
|
97
169
|
"allowlist": ["/new", "/status", "/help", "/compact"]
|
|
98
|
-
},
|
|
99
|
-
"dynamicAgents": {
|
|
100
|
-
"enabled": true
|
|
101
170
|
}
|
|
102
171
|
}
|
|
103
172
|
}
|
|
104
173
|
}
|
|
105
174
|
```
|
|
106
175
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
176
|
+
| Command | Description | Security Level |
|
|
177
|
+
|---------|-------------|----------------|
|
|
178
|
+
| `/new` | Reset conversation, start fresh | ✅ User-level |
|
|
179
|
+
| `/compact` | Compress conversation context | ✅ User-level |
|
|
180
|
+
| `/help` | Show help information | ✅ User-level |
|
|
181
|
+
| `/status` | Show Agent status | ✅ User-level |
|
|
112
182
|
|
|
113
|
-
|
|
183
|
+
> ⚠️ **Security Note**: Do not add `/gateway`, `/plugins`, or other management commands to the whitelist to prevent regular users from gaining Gateway instance admin privileges.
|
|
114
184
|
|
|
115
|
-
|
|
185
|
+
## 🏗️ Building Custom Images
|
|
116
186
|
|
|
117
|
-
|
|
118
|
-
- `/compact`: Compact session context, keeping key summaries to save tokens.
|
|
119
|
-
- `/help`: View help information.
|
|
120
|
-
- `/status`: View current Agent and plugin status.
|
|
187
|
+
To build a custom OpenClaw image:
|
|
121
188
|
|
|
122
|
-
|
|
189
|
+
```bash
|
|
190
|
+
# Build image (uses China npm mirror)
|
|
191
|
+
./local.sh v2026.1.29
|
|
123
192
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- `stream-manager.js`: Manages the state and data partitioning of streaming responses.
|
|
128
|
-
- `crypto.js`: Implementation of WeCom encryption algorithms.
|
|
193
|
+
# Build and push image
|
|
194
|
+
./local.sh v2026.1.29 push
|
|
195
|
+
```
|
|
129
196
|
|
|
130
197
|
## 🤝 Contributing
|
|
131
198
|
|
|
132
|
-
We welcome contributions!
|
|
199
|
+
We welcome contributions! Please submit Issues or Pull Requests for bugs or feature suggestions.
|
|
133
200
|
|
|
134
201
|
## 📄 License
|
|
135
202
|
|
package/README_ZH.md
CHANGED
|
@@ -2,77 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](https://github.com/sunnoy/openclaw-plugin-wecom/blob/main/README_ZH.md) | [English](https://github.com/sunnoy/openclaw-plugin-wecom/blob/main/README.md)
|
|
4
4
|
|
|
5
|
-
`openclaw-plugin-wecom` 是一个专为 [OpenClaw](https://github.com/
|
|
5
|
+
`openclaw-plugin-wecom` 是一个专为 [OpenClaw](https://github.com/openclaw/openclaw) 框架开发的企业微信(WeCom)集成插件。它允许你将强大的 AI 能力无缝接入企业微信,并支持多项高级功能。
|
|
6
6
|
|
|
7
7
|
## ✨ 核心特性
|
|
8
8
|
|
|
9
9
|
- 🌊 **流式输出 (Streaming)**: 基于企业微信最新的 AI 机器人流式分片机制,实现流畅的打字机式回复体验。
|
|
10
|
-
- 🤖 **动态 Agent 管理**:
|
|
10
|
+
- 🤖 **动态 Agent 管理**: 默认按"每个私聊用户 / 每个群聊"自动创建独立 Agent。每个 Agent 拥有独立的工作区与对话上下文,实现更强的数据隔离。
|
|
11
11
|
- 👥 **群聊深度集成**: 支持群聊消息解析,可通过 @提及(At-mention)精准触发机器人响应。
|
|
12
12
|
- 🛠️ **指令增强**: 内置常用指令支持(如 `/new` 开启新会话、`/status` 查看状态等),并提供指令白名单配置功能。
|
|
13
13
|
- 🔒 **安全与认证**: 完整支持企业微信消息加解密、URL 验证及发送者身份校验。
|
|
14
14
|
- ⚡ **高性能异步处理**: 采用异步消息处理架构,确保即使在长耗时 AI 推理过程中,企业微信网关也能保持高响应性。
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## 🚀 快速开始
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
### 方式一:Docker 一键部署(推荐)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
- 私聊:`wxwork-dm-<userId>`
|
|
22
|
-
- 群聊:`wxwork-group-<chatId>`
|
|
23
|
-
2. 插件将消息路由到该 Agent:把 `SessionKey` 设为
|
|
24
|
-
- `agent:<agentId>:<peerKind>:<peerId>`
|
|
25
|
-
3. OpenClaw 从 `SessionKey` 中提取 `<agentId>`,并自动创建/复用对应的 Agent 工作区(非默认 Agent 通常落在 `~/.openclaw/workspace-<agentId>`)。
|
|
20
|
+
本仓库提供了完整的 Docker 部署方案,包含自动化的插件安装和配置。
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
```bash
|
|
23
|
+
# 1. 克隆仓库
|
|
24
|
+
git clone https://github.com/sunnoy/openclaw-plugin-wecom.git
|
|
25
|
+
cd openclaw-plugin-wecom/deploy
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
# 2. 复制环境变量配置
|
|
28
|
+
cp .env.example .env
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
# 3. 编辑 .env 文件,填写实际配置
|
|
31
|
+
vim .env
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
# 4. 运行部署脚本
|
|
34
|
+
./deploy.sh
|
|
35
|
+
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
部署脚本会自动执行:
|
|
38
|
+
- 创建数据目录和设置权限
|
|
39
|
+
- 生成配置文件
|
|
40
|
+
- 启动 Docker 容器
|
|
41
|
+
- 安装企业微信插件
|
|
42
|
+
- 配置并重启服务
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
- `dm.createAgentOnFirstMessage`(boolean,默认:`true`):私聊是否使用动态 Agent。
|
|
40
|
-
- `groupChat.enabled`(boolean,默认:`true`):是否启用群聊处理。
|
|
41
|
-
- `groupChat.createAgentOnFirstMessage`(boolean,默认:`true`):群聊是否使用动态 Agent。
|
|
42
|
-
- `groupChat.requireMention`(boolean,默认:`true`):群聊是否必须 @ 提及才响应。
|
|
43
|
-
- `groupChat.mentionPatterns`(string[],默认:`["@"]`):哪些字符串算作“提及”。
|
|
44
|
+
#### 🌟 部署亮点
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
**自定义数据目录 & Agent Workspace 路径**
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
48
|
+
本部署方案的核心优势是将所有数据统一存储到自定义路径,有效利用数据盘:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# .env 配置示例
|
|
52
|
+
OPENCLAW_DATA_DIR=/data/openclaw # 自定义数据目录
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
- **OpenClaw 状态目录**:`/data/openclaw/`
|
|
56
|
+
- **动态 Agent Workspace**:`/data/openclaw/.openclaw/`
|
|
57
|
+
- **插件目录**:`/data/openclaw/extensions/`
|
|
58
|
+
- **Canvas 数据**:`/data/openclaw/canvas/`
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
这意味着:
|
|
61
|
+
- ✅ 所有 Agent 工作区数据存储在数据盘,避免占用系统盘空间
|
|
62
|
+
- ✅ 每个用户/群聊的独立 Agent 文件都在统一路径下管理
|
|
63
|
+
- ✅ 方便备份、迁移和扩容
|
|
64
|
+
- ✅ 适合企业级部署,数据盘可独立挂载和扩展
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
### 方式二:手动安装插件
|
|
67
|
+
|
|
68
|
+
在已有的 OpenClaw 环境中安装:
|
|
62
69
|
|
|
63
70
|
```bash
|
|
64
71
|
openclaw plugins install openclaw-plugin-wecom
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
或通过 npm:
|
|
68
75
|
|
|
69
76
|
```bash
|
|
70
77
|
npm install openclaw-plugin-wecom
|
|
71
78
|
```
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
在 OpenClaw 的配置文件(如 `config.json`)中添加插件配置:
|
|
80
|
+
然后在 OpenClaw 配置文件中添加:
|
|
76
81
|
|
|
77
82
|
```json
|
|
78
83
|
{
|
|
@@ -85,47 +90,109 @@ npm install openclaw-plugin-wecom
|
|
|
85
90
|
"wxwork": {
|
|
86
91
|
"enabled": true,
|
|
87
92
|
"token": "你的 Token",
|
|
88
|
-
"encodingAesKey": "你的 EncodingAESKey"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
"encodingAesKey": "你的 EncodingAESKey"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 企业微信后台设置
|
|
100
|
+
|
|
101
|
+
1. 在企业微信管理后台创建一个"智能机器人"。
|
|
102
|
+
2. 将机器人的"接收消息配置"中的 URL 设置为你的服务地址(例如:`https://your-domain.com/webhooks/wxwork`)。
|
|
103
|
+
3. 填入对应的 Token 和 EncodingAESKey。
|
|
104
|
+
|
|
105
|
+
## 📂 项目结构
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
openclaw-plugin-wecom/
|
|
109
|
+
├── deploy/ # 部署相关文件
|
|
110
|
+
│ ├── deploy.sh # 一键部署脚本
|
|
111
|
+
│ ├── docker-compose.yml # Docker Compose 配置
|
|
112
|
+
│ ├── .env.example # 环境变量示例
|
|
113
|
+
│ ├── openclaw.json.base # 基础配置模板
|
|
114
|
+
│ └── openclaw.json.template # 完整配置模板
|
|
115
|
+
├── Dockerfile # OpenClaw 镜像构建文件
|
|
116
|
+
├── local.sh # 本地镜像构建脚本
|
|
117
|
+
├── index.js # 插件入口
|
|
118
|
+
├── webhook.js # 企业微信 HTTP 通信处理
|
|
119
|
+
├── dynamic-agent.js # 动态 Agent 分配逻辑
|
|
120
|
+
├── stream-manager.js # 流式回复管理
|
|
121
|
+
├── crypto.js # 企业微信加密算法
|
|
122
|
+
└── client.js # 客户端逻辑
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 🤖 动态 Agent 路由
|
|
126
|
+
|
|
127
|
+
OpenClaw 会通过解析 `SessionKey` 来决定本次消息由哪个 Agent 处理。本插件实现"按人/按群隔离":
|
|
128
|
+
|
|
129
|
+
1. 企业微信消息到达后,插件生成确定性的 `agentId`:
|
|
130
|
+
- 私聊:`wxwork-dm-<userId>`
|
|
131
|
+
- 群聊:`wxwork-group-<chatId>`
|
|
132
|
+
2. OpenClaw 自动创建/复用对应的 Agent 工作区。
|
|
133
|
+
|
|
134
|
+
### 配置选项
|
|
135
|
+
|
|
136
|
+
配置在 `channels.wxwork` 下:
|
|
137
|
+
|
|
138
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
139
|
+
|--------|------|--------|------|
|
|
140
|
+
| `dynamicAgents.enabled` | boolean | `true` | 是否启用动态 Agent |
|
|
141
|
+
| `dm.createAgentOnFirstMessage` | boolean | `true` | 私聊使用动态 Agent |
|
|
142
|
+
| `groupChat.enabled` | boolean | `true` | 启用群聊处理 |
|
|
143
|
+
| `groupChat.requireMention` | boolean | `true` | 群聊必须 @ 提及才响应 |
|
|
144
|
+
|
|
145
|
+
如果需要所有消息进入默认 Agent:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"channels": {
|
|
150
|
+
"wxwork": {
|
|
151
|
+
"dynamicAgents": { "enabled": false }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 🛠️ 指令白名单
|
|
158
|
+
|
|
159
|
+
为防止普通用户通过企业微信消息执行敏感的 Gateway 管理指令,本插件支持**指令白名单**机制。只有配置在白名单中的指令才会被执行,其他指令将被忽略。
|
|
160
|
+
|
|
161
|
+
> 💡 **提示**:此配置已包含在 `deploy/openclaw.json.template` 中,部署时会自动生效。
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"channels": {
|
|
166
|
+
"wxwork": {
|
|
95
167
|
"commands": {
|
|
96
168
|
"enabled": true,
|
|
97
169
|
"allowlist": ["/new", "/status", "/help", "/compact"]
|
|
98
|
-
},
|
|
99
|
-
"dynamicAgents": {
|
|
100
|
-
"enabled": true
|
|
101
170
|
}
|
|
102
171
|
}
|
|
103
172
|
}
|
|
104
173
|
}
|
|
105
174
|
```
|
|
106
175
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
176
|
+
| 指令 | 说明 | 安全级别 |
|
|
177
|
+
|------|------|----------|
|
|
178
|
+
| `/new` | 重置当前对话,开启全新会话 | ✅ 用户级 |
|
|
179
|
+
| `/compact` | 压缩当前会话上下文 | ✅ 用户级 |
|
|
180
|
+
| `/help` | 查看帮助信息 | ✅ 用户级 |
|
|
181
|
+
| `/status` | 查看当前 Agent 状态 | ✅ 用户级 |
|
|
112
182
|
|
|
113
|
-
|
|
183
|
+
> ⚠️ **安全提示**:不要将 `/gateway`、`/plugins` 等管理指令添加到白名单,避免普通用户获得 Gateway 实例的管理权限。
|
|
114
184
|
|
|
115
|
-
|
|
185
|
+
## 🏗️ 本地构建镜像
|
|
116
186
|
|
|
117
|
-
|
|
118
|
-
- `/compact`: 压缩当前会话上下文,保留关键摘要以节省 Token。
|
|
119
|
-
- `/help`: 查看帮助信息。
|
|
120
|
-
- `/status`: 查看当前 Agent 及插件状态。
|
|
187
|
+
如果需要自定义构建 OpenClaw 镜像:
|
|
121
188
|
|
|
122
|
-
|
|
189
|
+
```bash
|
|
190
|
+
# 构建镜像(使用国内 npm 源)
|
|
191
|
+
./local.sh v2026.1.29
|
|
123
192
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- `stream-manager.js`: 管理流式回复的状态与数据分片。
|
|
128
|
-
- `crypto.js`: 企业微信加密算法实现。
|
|
193
|
+
# 构建并推送镜像
|
|
194
|
+
./local.sh v2026.1.29 push
|
|
195
|
+
```
|
|
129
196
|
|
|
130
197
|
## 🤝 贡献规范
|
|
131
198
|
|