@wps365/openclaw-wpsxiezuo 1.6.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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +335 -0
  3. package/README_ZH-CN.md +318 -0
  4. package/bin/cli.mjs +677 -0
  5. package/dist/channel/event-crypto.d.ts +19 -0
  6. package/dist/channel/event-handlers.d.ts +61 -0
  7. package/dist/channel/event-types.d.ts +88 -0
  8. package/dist/channel/index.d.ts +8 -0
  9. package/dist/channel/plugin.d.ts +11 -0
  10. package/dist/channel/register-tool-bridge.d.ts +14 -0
  11. package/dist/channel/sdk-client-options.d.ts +24 -0
  12. package/dist/channel/sdk-helpers.d.ts +12 -0
  13. package/dist/channel/sdk-provider.d.ts +23 -0
  14. package/dist/channel/types.d.ts +324 -0
  15. package/dist/core/config.d.ts +267 -0
  16. package/dist/core/errors.d.ts +36 -0
  17. package/dist/core/index.d.ts +18 -0
  18. package/dist/core/lazy-client-store.d.ts +28 -0
  19. package/dist/core/media-utils.d.ts +27 -0
  20. package/dist/core/reaction.d.ts +29 -0
  21. package/dist/core/token-store.d.ts +34 -0
  22. package/dist/core/user-token-store.d.ts +35 -0
  23. package/dist/core/wps-client.d.ts +42 -0
  24. package/dist/index.d.ts +17 -0
  25. package/dist/index.js +33 -0
  26. package/dist/messaging/handler.d.ts +73 -0
  27. package/dist/messaging/inbound/content-parser.d.ts +17 -0
  28. package/dist/messaging/inbound/handler.d.ts +44 -0
  29. package/dist/messaging/inbound/index.d.ts +5 -0
  30. package/dist/messaging/inbound/media-prefetch.d.ts +43 -0
  31. package/dist/messaging/inbound/pairing-allow-store.d.ts +11 -0
  32. package/dist/messaging/index.d.ts +3 -0
  33. package/dist/messaging/outbound.d.ts +15 -0
  34. package/dist/session/idempotency.d.ts +8 -0
  35. package/dist/session/index.d.ts +5 -0
  36. package/dist/session/resolver.d.ts +17 -0
  37. package/dist/session/types.d.ts +37 -0
  38. package/dist/tools/oapi/calendar.d.ts +106 -0
  39. package/dist/tools/oapi/chat.d.ts +10 -0
  40. package/dist/tools/oapi/delegated-auth.d.ts +14 -0
  41. package/dist/tools/oapi/drive.d.ts +112 -0
  42. package/dist/tools/oapi/index.d.ts +24 -0
  43. package/dist/tools/oapi/media.d.ts +32 -0
  44. package/dist/tools/oapi/messaging.d.ts +10 -0
  45. package/dist/tools/oapi/todo.d.ts +96 -0
  46. package/dist/tools/oapi/user.d.ts +10 -0
  47. package/dist/tools/oauth/index.d.ts +65 -0
  48. package/openclaw.plugin.json +154 -0
  49. package/package.json +91 -0
  50. package/scripts/upgrade.sh +37 -0
  51. package/skills/wps-auth-provider.md +63 -0
  52. package/skills/wps-calendar/SKILL.md +147 -0
  53. package/skills/wps-channel-rules/SKILL.md +50 -0
  54. package/skills/wps-chat/SKILL.md +106 -0
  55. package/skills/wps-drive/SKILL.md +79 -0
  56. package/skills/wps-im-read/SKILL.md +88 -0
  57. package/skills/wps-im-send/SKILL.md +183 -0
  58. package/skills/wps-media/SKILL.md +101 -0
  59. package/skills/wps-message-handler.md +48 -0
  60. package/skills/wps-todo/SKILL.md +65 -0
  61. package/skills/wps-user/SKILL.md +105 -0
  62. package/skills/wps-xiezuo-session-mapper.md +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 WPS Xiezuo Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,335 @@
1
+ # @wps365/openclaw-wpsxiezuo
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Node](https://img.shields.io/badge/node-%3E%3D22-brightgreen)](https://nodejs.org/)
5
+
6
+ > 中文文档:[README_ZH-CN.md](README_ZH-CN.md)
7
+
8
+ An [OpenClaw](https://openclaw.dev) native plugin that connects your AI agent to the **WPS Open Platform enterprise robot** — enabling AI-powered conversations in WPS group chats and direct messages.
9
+
10
+ > This is an **OpenClaw plugin**. Install [OpenClaw](https://openclaw.dev) first, then use this package to add the WPS channel.
11
+
12
+ ---
13
+
14
+ ## Features
15
+
16
+ - **Native integration** — follows the OpenClaw plugin spec; automatically hooks into `register` / `gateway.startAccount` lifecycle
17
+ - **Full WPS platform support** — enterprise robot Webhook / WebSocket dual-channel + full `openapi.wps.cn` OAPI coverage
18
+ - **Event-driven** — handles messages, files, @mentions, image attachment pre-fetch, and automatic OAuth token refresh
19
+ - **Smart sessions** — WPS ↔ OpenClaw session mapping, deduplication & idempotency, cross-turn context retention
20
+ - **Image understanding** — integrates with OpenClaw `tools.media.image` (host selects the model; plugin handles attachment download)
21
+ - **Cross-platform install** — a single `npx` command handles registration, config injection, and plugin allowlisting
22
+
23
+ ---
24
+
25
+ ## Architecture
26
+
27
+ ```
28
+ WPS Open Platform ──► This plugin (Webhook / WebSocket)
29
+ │ Decrypt + verify signature + idempotency
30
+ │ Session mapping + media pre-fetch
31
+
32
+ OpenClaw channelRuntime
33
+ │ Route agent + orchestrate reply
34
+
35
+ OpenClaw Agent (your AI)
36
+ │ Reply text / call tools
37
+
38
+ This plugin outbound ──► WPS Open Platform
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Requirements
44
+
45
+ | Item | Version |
46
+ |------|---------|
47
+ | Node.js | >= 22 (24 LTS recommended) |
48
+ | pnpm | >= 10 (dev only, not needed for end users) |
49
+ | OpenClaw CLI | >= 2026.3.28 |
50
+ | WPS Open Platform | App ID + App Secret |
51
+
52
+ ---
53
+
54
+ ## Quick Start
55
+
56
+ ### Option 1: Install via npm (recommended)
57
+
58
+ ```bash
59
+ # 1. Install OpenClaw (skip if already installed)
60
+ npm install -g openclaw
61
+
62
+ # 2. Run the built-in CLI with npx
63
+ npx -y @wps365/openclaw-wpsxiezuo install
64
+ ```
65
+
66
+ The CLI automatically:
67
+
68
+ 1. Checks that the OpenClaw CLI is available
69
+ 2. Prompts for `APP_ID` / `APP_SECRET` interactively
70
+ 3. Removes stale `wps` / `wps-xiezuo` config remnants
71
+ 4. Registers this npm package as an OpenClaw plugin
72
+ 5. Writes `channels.wps-xiezuo` / `plugins.allow` / `bindings` into `~/.openclaw/openclaw.json`
73
+ 6. Verifies the installation result
74
+
75
+ **Unattended / CI mode:**
76
+
77
+ ```bash
78
+ # Pass as flags
79
+ npx -y @wps365/openclaw-wpsxiezuo install --app-id <ID> --app-secret <SECRET> --yes
80
+
81
+ # Or via environment variables
82
+ WPS_APP_ID=xxx WPS_APP_SECRET=yyy \
83
+ npx -y @wps365/openclaw-wpsxiezuo install --yes
84
+ ```
85
+
86
+ **Upgrade / Update:**
87
+
88
+ ```bash
89
+ # Upgrade to latest version
90
+ npx -y @wps365/openclaw-wpsxiezuo@latest install --yes
91
+
92
+ # Or reinstall (install command cleans old config first)
93
+ npx -y @wps365/openclaw-wpsxiezuo install --yes
94
+ ```
95
+
96
+ **Install a specific version:**
97
+
98
+ ```bash
99
+ # Install version 1.6.0
100
+ npx -y @wps365/openclaw-wpsxiezuo@1.6.0 install --yes
101
+
102
+ # Install version 1.5.0
103
+ npx -y @wps365/openclaw-wpsxiezuo@1.5.0 install --yes
104
+ ```
105
+
106
+ **Uninstall:**
107
+
108
+ ```bash
109
+ npx -y @wps365/openclaw-wpsxiezuo uninstall
110
+ ```
111
+
112
+ After installation, **restart the OpenClaw gateway** and @ the bot in WPS to start chatting:
113
+
114
+ ```bash
115
+ openclaw gateway restart # or: openclaw serve
116
+ ```
117
+
118
+ > Works on macOS, Linux, and Windows. The CLI is pure Node.js — no bash dependency.
119
+
120
+ ### Option 2: Offline bundle (air-gapped / no npm access)
121
+
122
+ ```bash
123
+ # 1. Download openclaw-wps-xiezuo-bundle-vX.Y.Z.zip from the releases page
124
+ unzip openclaw-wps-xiezuo-bundle-vX.Y.Z.zip
125
+ cd openclaw-wps-xiezuo-bundle
126
+
127
+ # 2. Edit config/plugin.env with your APP_ID / APP_SECRET
128
+ $EDITOR config/plugin.env
129
+
130
+ # 3. Install (macOS / Linux)
131
+ bash scripts/install.sh
132
+ ```
133
+
134
+ The offline bundle ships with a `.tgz` identical to the npm public package.
135
+
136
+ ---
137
+
138
+ ## Configuration
139
+
140
+ ### Channel config
141
+
142
+ The plugin reads `channels.wps-xiezuo` from `~/.openclaw/openclaw.json`:
143
+
144
+ ```json
145
+ {
146
+ "channels": {
147
+ "wps-xiezuo": {
148
+ "enabled": true,
149
+ "appId": "YOUR_APP_ID",
150
+ "appSecret": "YOUR_APP_SECRET",
151
+ "baseUrl": "https://openapi.wps.cn",
152
+ "dmPolicy": "open",
153
+ "groupPolicy": "open",
154
+ "requireMention": true,
155
+ "instantAck": {
156
+ "enabled": true,
157
+ "text": "Processing, please wait..."
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ | Field | Description |
165
+ |-------|-------------|
166
+ | `appId` / `appSecret` | WPS Open Platform app credentials (required) |
167
+ | `baseUrl` | OAPI base URL, default `https://openapi.wps.cn` |
168
+ | `dmPolicy` | Direct-message policy: `open` / `pairing` / `allowlist` |
169
+ | `groupPolicy` | Group-chat policy: `open` / `allowlist` |
170
+ | `requireMention` | Whether the bot must be @mentioned in group chats |
171
+ | `instantAck` | Immediate acknowledgement message (prevents perceived timeout) |
172
+
173
+ Full schema: [`openclaw.plugin.json`](openclaw.plugin.json) → `channelConfigs.wps-xiezuo.schema`.
174
+
175
+ ### Custom AI gateway
176
+
177
+ This plugin is **model-agnostic** — the model is controlled by the OpenClaw host's `models.providers`. Example:
178
+
179
+ ```json
180
+ {
181
+ "models": {
182
+ "mode": "merge",
183
+ "providers": {
184
+ "my-provider": {
185
+ "baseUrl": "<your gateway URL>",
186
+ "apiKey": "<your key>",
187
+ "api": "openai-completions"
188
+ }
189
+ }
190
+ },
191
+ "agents": {
192
+ "defaults": { "model": { "primary": "my-provider/<model-id>" } }
193
+ }
194
+ }
195
+ ```
196
+
197
+ Merge this into `~/.openclaw/openclaw.json`.
198
+
199
+ ### Image understanding (inbound image attachments)
200
+
201
+ The plugin downloads WPS cloud attachments to local disk and exposes `MediaPath` / `MediaPaths` / `MediaType` / `MediaTypes` on the inbound context. The actual image understanding capability is provided by the OpenClaw host's `tools.media.image`; the model / gateway choice is up to the deployer.
202
+
203
+ To enable image understanding, three conditions must be met in `openclaw.json`:
204
+
205
+ ```json
206
+ {
207
+ "models": {
208
+ "providers": {
209
+ "<your-provider>": {
210
+ "models": [
211
+ { "id": "<model-id>", "input": ["text", "image"] }
212
+ ]
213
+ }
214
+ }
215
+ },
216
+ "agents": {
217
+ "defaults": { "model": "<your-provider>/<model-id>" }
218
+ },
219
+ "tools": {
220
+ "media": {
221
+ "image": {
222
+ "enabled": true,
223
+ "models": [
224
+ { "provider": "<your-provider>", "model": "<vision-model-id>" }
225
+ ]
226
+ }
227
+ }
228
+ }
229
+ }
230
+ ```
231
+
232
+ - `input: ["text", "image"]` tells the host that the provider supports image input
233
+ - `tools.media.image.enabled` defaults to `false`; must be explicitly set to `true`
234
+ - `tools.media.image.models[]` can specify a lightweight vision model; omit to use the agent default
235
+
236
+ For details on image-native multimodal pass-through vs. `[Image]` description block, see the OpenClaw docs: `nodes/media-understanding`.
237
+
238
+ **Common issues:**
239
+ - Bot replies "no image found" → check `tools.media.image.enabled` and the provider's `input` declaration
240
+ - New image receives old answer → session cross-contamination; clear `~/.openclaw/agents/<id>/sessions/sessions.json`
241
+
242
+ ---
243
+
244
+ ## Usage
245
+
246
+ ### Start and verify
247
+
248
+ ```bash
249
+ openclaw gateway start # Start the gateway
250
+ openclaw gateway logs # View logs
251
+ openclaw plugins list # List installed plugins
252
+ openclaw config get channels.wps-xiezuo # Inspect WPS channel config
253
+ openclaw doctor # Health check
254
+ ```
255
+
256
+ ### Upgrade and uninstall
257
+
258
+ ```bash
259
+ # Upgrade (npm)
260
+ npx -y @wps365/openclaw-wpsxiezuo install --yes # Overwrites with latest
261
+
262
+ # Uninstall (npm)
263
+ npx -y @wps365/openclaw-wpsxiezuo uninstall
264
+
265
+ # Uninstall (offline bundle)
266
+ cd openclaw-wps-xiezuo-bundle && bash scripts/uninstall.sh
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Troubleshooting
272
+
273
+ **1. Plugin not loaded after install**
274
+
275
+ ```bash
276
+ openclaw gateway restart
277
+ ls ~/.openclaw/extensions/wps-xiezuo # Confirm the plugin directory exists
278
+ ```
279
+
280
+ **2. Channel config not taking effect**
281
+
282
+ ```bash
283
+ openclaw config get channels.wps-xiezuo
284
+ openclaw doctor --fix
285
+ ```
286
+
287
+ **3. Tool call rejected**
288
+
289
+ ```bash
290
+ openclaw config get tools.allow
291
+ openclaw config set tools.allow '["wps_im_message_send"]'
292
+ ```
293
+
294
+ **4. View logs**
295
+
296
+ ```bash
297
+ openclaw gateway logs # Gateway log
298
+ tail -f ~/.openclaw/logs/plugins/wps-xiezuo.log # Plugin log
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Compatibility
304
+
305
+ | Item | Support |
306
+ |------|---------|
307
+ | OpenClaw | Stable channel, `>= 2026.3.28` |
308
+ | Node.js | 22 LTS, 24 (recommended) |
309
+ | OS | macOS, Linux, Windows (WSL recommended) |
310
+
311
+ ---
312
+
313
+ ## Contributors
314
+
315
+ - [@wangdong](https://github.com/wangdong)
316
+ - [@hezhijian](https://github.com/hezhijian-wps)
317
+ - [@liuxin21](https://github.com/kso-lx21)
318
+ - [@huangluyang](https://www.npmjs.com/~lukeqqi)
319
+ - [@duwei1](https://github.com/duwei1)
320
+ - [@wangzhengrui](https://github.com/wangzhengrui)
321
+ - [@liuzhifei](https://github.com/dacuotecuo)
322
+ - [@chensi](https://github.com/chensi06lj)
323
+ - [@zhangyong](https://github.com/ZhYong10)
324
+
325
+ ---
326
+
327
+ ## License
328
+
329
+ [MIT License](LICENSE)
330
+
331
+ ## Acknowledgements
332
+
333
+ - [OpenClaw](https://openclaw.dev) — AI agent framework
334
+ - [WPS Open Platform](https://open.wps.cn) — Enterprise collaboration platform
335
+ - [TypeScript](https://www.typescriptlang.org/) — Type-safe JavaScript
@@ -0,0 +1,318 @@
1
+ # @wps365/openclaw-wpsxiezuo
2
+
3
+ [License: MIT](https://opensource.org/licenses/MIT)
4
+ [Node](https://nodejs.org/)
5
+
6
+ > English version: [README.md](../blob/main/README.md)
7
+
8
+ WPS 协作 Openclaw 原生插件——把 OpenClaw AI agent 接入 WPS 开放平台企业机器人,实现群聊 / 私聊中的 AI 对话与自动化。
9
+
10
+ > 本项目是一个 **OpenClaw 插件**。先安装 [OpenClaw](https://openclaw.dev),再通过本包把 WPS 通道接入其中。
11
+
12
+ ## 功能特性
13
+
14
+ - **原生集成**:遵循 OpenClaw 插件规范,在 `register` / `gateway.startAccount` 生命周期里自动接管 WPS 通道
15
+ - **WPS 平台完整对接**:企业机器人 Webhook / WebSocket 双通道 + `openapi.wps.cn` 全量 OAPI
16
+ - **事件驱动**:消息、文件、@ 提及、图片附件预取、OAuth token 自动刷新
17
+ - **智能会话**:WPS 会话与 OpenClaw 会话映射、去重幂等、跨轮上下文保持
18
+ - **图片识别**:与 OpenClaw `tools.media.image` 联动(宿主选模型,插件负责附件下载)
19
+ - **跨平台安装**:一条 `npx` 命令完成注册、配置注入、插件白名单
20
+
21
+ ## 架构速览
22
+
23
+ ```
24
+ WPS 开放平台 ──► 本插件(webhook/WebSocket)
25
+ │ 解密 + 验签 + 幂等
26
+ │ 会话映射 + 媒体预取
27
+
28
+ OpenClaw channelRuntime
29
+ │ 路由 agent + 编排回复
30
+
31
+ OpenClaw Agent(你的 AI)
32
+ │ 回复文本 / 调用工具
33
+
34
+ 本插件 outbound ──► WPS 开放平台
35
+ ```
36
+
37
+ ## 环境要求
38
+
39
+ - Node.js **>= 22**(推荐 24 LTS)
40
+ - pnpm **>= 10**(仅本地开发需要,用户安装无需)
41
+ - OpenClaw CLI **>= 2026.3.28**
42
+ - WPS 开放平台应用的 `App ID` 与 `App Secret`
43
+
44
+ ## 快速开始
45
+
46
+ ### 方式一:通过 npm 一键安装(推荐)
47
+
48
+ ```bash
49
+ # 1. 安装 OpenClaw(已装过可跳过)
50
+ npm install -g openclaw
51
+
52
+ # 2. 用 npx 运行本包内置的 CLI
53
+ npx -y @wps365/openclaw-wpsxiezuo install
54
+ ```
55
+
56
+ CLI 会自动完成:
57
+
58
+ 1. 检查 OpenClaw CLI 是否可用
59
+ 2. 交互式输入 `APP_ID` / `APP_SECRET`
60
+ 3. 清理旧的 `wps` / `wps-xiezuo` 残留配置
61
+ 4. 将本 npm 包作为插件注册到 OpenClaw
62
+ 5. 写入 `~/.openclaw/openclaw.json` 的 `channels.wps-xiezuo` / `plugins.allow` / `bindings`
63
+ 6. 验证安装结果
64
+
65
+ 无人值守/CI 场景:
66
+
67
+ ```bash
68
+ # 参数方式
69
+ npx -y @wps365/openclaw-wpsxiezuo install --app-id <ID> --app-secret <SECRET> --yes
70
+
71
+ # 环境变量方式
72
+ WPS_APP_ID=xxx WPS_APP_SECRET=yyy \
73
+ npx -y @wps365/openclaw-wpsxiezuo install --yes
74
+ ```
75
+
76
+ **升级 / 更新:**
77
+
78
+ ```bash
79
+ # 升级到最新版本
80
+ npx -y @wps365/openclaw-wpsxiezuo@latest install --yes
81
+
82
+ # 或重新安装(install 命令会先清理旧配置)
83
+ npx -y @wps365/openclaw-wpsxiezuo install --yes
84
+ ```
85
+
86
+ **安装指定版本:**
87
+
88
+ ```bash
89
+ # 安装 1.6.0 版本
90
+ npx -y @wps365/openclaw-wpsxiezuo@1.6.0 install --yes
91
+
92
+ # 安装 1.5.0 版本
93
+ npx -y @wps365/openclaw-wpsxiezuo@1.5.0 install --yes
94
+ ```
95
+
96
+ **卸载:**
97
+
98
+ ```bash
99
+ npx -y @wps365/openclaw-wpsxiezuo uninstall
100
+ ```
101
+
102
+ 安装完成后**手动重启 OpenClaw gateway** 即可在 WPS 客户端 @ 机器人对话:
103
+
104
+ ```bash
105
+ openclaw gateway restart # 或:openclaw serve
106
+ ```
107
+
108
+ > 全平台支持(macOS / Linux / Windows)。CLI 纯 Node.js 实现,不依赖 bash。
109
+
110
+ ### 方式二:离线 bundle 安装(内网/无 npm 环境)
111
+
112
+ ```bash
113
+ # 1. 从发布页获取 openclaw-wps-xiezuo-bundle-vX.Y.Z.zip
114
+ unzip openclaw-wps-xiezuo-bundle-vX.Y.Z.zip
115
+ cd openclaw-wps-xiezuo-bundle
116
+
117
+ # 2. 编辑 config/plugin.env,填写 APP_ID / APP_SECRET
118
+ $EDITOR config/plugin.env
119
+
120
+ # 3. 安装(macOS / Linux)
121
+ bash scripts/install.sh
122
+ ```
123
+
124
+ 离线 bundle 内置 `.tgz` 与 npm 公网包同名同内容。
125
+
126
+ ## 配置说明
127
+
128
+ ### Channel 配置
129
+
130
+ 插件读取 `~/.openclaw/openclaw.json` 中的 `channels.wps-xiezuo`:
131
+
132
+ ```json
133
+ {
134
+ "channels": {
135
+ "wps-xiezuo": {
136
+ "enabled": true,
137
+ "appId": "YOUR_APP_ID",
138
+ "appSecret": "YOUR_APP_SECRET",
139
+ "baseUrl": "https://openapi.wps.cn",
140
+ "dmPolicy": "open",
141
+ "groupPolicy": "open",
142
+ "requireMention": true,
143
+ "instantAck": {
144
+ "enabled": true,
145
+ "text": "内容处理中,请稍候..."
146
+ }
147
+ }
148
+ }
149
+ }
150
+ ```
151
+
152
+
153
+ | 字段 | 说明 |
154
+ | --------------------- | ------------------------------------- |
155
+ | `appId` / `appSecret` | WPS 开放平台应用凭据(必填) |
156
+ | `baseUrl` | OAPI 基础地址,默认 `https://openapi.wps.cn` |
157
+ | `dmPolicy` | 私聊策略:`open` / `pairing` / `allowlist` |
158
+ | `groupPolicy` | 群聊策略:`open` / `allowlist` |
159
+ | `requireMention` | 群聊是否需要 @机器人才响应 |
160
+ | `instantAck` | 即时确认消息(避免长时间无响应感知) |
161
+
162
+
163
+ 完整 schema 见 [openclaw.plugin.json](openclaw.plugin.json) 中的 `channelConfigs.wps-xiezuo.schema`。
164
+
165
+ ### 自定义 AI 网关
166
+
167
+ 本插件**不绑定特定模型**——模型由 OpenClaw 宿主的 `models.providers` 决定。常见做法:
168
+
169
+ ```json
170
+ {
171
+ "models": {
172
+ "mode": "merge",
173
+ "providers": {
174
+ "my-provider": {
175
+ "baseUrl": "<你的网关地址>",
176
+ "apiKey": "<你的 key>",
177
+ "api": "openai-completions"
178
+ }
179
+ }
180
+ },
181
+ "agents": {
182
+ "defaults": { "model": { "primary": "my-provider/<model-id>" } }
183
+ }
184
+ }
185
+ ```
186
+
187
+ 合并进 `~/.openclaw/openclaw.json` 即可。
188
+
189
+ ### 图片识别(入站图片附件)
190
+
191
+ 插件只负责把 WPS 云端附件**下载到本地**并在入站 ctx 暴露 `MediaPath` / `MediaPaths` / `MediaType` / `MediaTypes`。识图能力由 OpenClaw 宿主的 `tools.media.image` 提供,模型/网关选择由部署方配置。
192
+
193
+ 要启用图片识别,`openclaw.json` 需同时满足三点:
194
+
195
+ ```json
196
+ {
197
+ "models": {
198
+ "providers": {
199
+ "<your-provider>": {
200
+ "models": [
201
+ { "id": "<model-id>", "input": ["text", "image"] }
202
+ ]
203
+ }
204
+ }
205
+ },
206
+ "agents": {
207
+ "defaults": { "model": "<your-provider>/<model-id>" }
208
+ },
209
+ "tools": {
210
+ "media": {
211
+ "image": {
212
+ "enabled": true,
213
+ "models": [
214
+ { "provider": "<your-provider>", "model": "<vision-model-id>" }
215
+ ]
216
+ }
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ - `input: ["text", "image"]` 让宿主识别该 provider 具备图像能力
223
+ - `tools.media.image.enabled` 默认关闭,必须显式 `true`
224
+ - `tools.media.image.models[]` 可另行指定轻量识图模型;省略时用 agent 默认
225
+
226
+ 详细识图行为(image-native 直传 multimodal vs 生成 `[Image]` 描述块)见 OpenClaw 官方文档 `nodes/media-understanding`。
227
+
228
+ **常见故障:**
229
+
230
+ - 机器人回"没看到图" → 检查 `tools.media.image.enabled` 与 provider 的 `input` 声明
231
+ - 新图被旧答案回复 → session 串线,清理 `~/.openclaw/agents/<id>/sessions/sessions.json` 索引
232
+
233
+ ## 使用说明
234
+
235
+ ### 启动与验证
236
+
237
+ ```bash
238
+ openclaw gateway start # 启动网关
239
+ openclaw gateway logs # 查看日志
240
+ openclaw plugins list # 查看已安装插件
241
+ openclaw config get channels.wps-xiezuo # 查看 WPS 通道配置
242
+ openclaw doctor # 健康检查
243
+ ```
244
+
245
+ ### 升级与卸载
246
+
247
+ ```bash
248
+ # 升级(npm 方式)
249
+ npx -y @wps365/openclaw-wpsxiezuo install --yes # 会覆盖安装最新版
250
+
251
+ # 卸载(npm 方式)
252
+ npx -y @wps365/openclaw-wpsxiezuo uninstall
253
+
254
+ # 卸载(离线 bundle 方式)
255
+ cd openclaw-wps-xiezuo-bundle && bash scripts/uninstall.sh
256
+ ```
257
+
258
+ ## 故障排查
259
+
260
+ **1. 安装后插件未加载**
261
+
262
+ ```bash
263
+ openclaw gateway restart
264
+ ls ~/.openclaw/extensions/wps-xiezuo # 确认插件目录存在
265
+ ```
266
+
267
+ **2. Channel 配置未生效**
268
+
269
+ ```bash
270
+ openclaw config get channels.wps-xiezuo
271
+ openclaw doctor --fix
272
+ ```
273
+
274
+ **3. 工具调用被拒绝**
275
+
276
+ ```bash
277
+ openclaw config get tools.allow
278
+ openclaw config set tools.allow '["wps_im_message_send"]'
279
+ ```
280
+
281
+ **4. 查日志**
282
+
283
+ ```bash
284
+ openclaw gateway logs # 网关日志
285
+ tail -f ~/.openclaw/logs/plugins/wps-xiezuo.log # 插件日志
286
+ ```
287
+
288
+ ## 兼容性
289
+
290
+
291
+ | 项 | 支持 |
292
+ | -------- | ---------------------------------- |
293
+ | OpenClaw | 稳定版(Stable channel),`>= 2026.3.28` |
294
+ | Node.js | 22 LTS,24(推荐) |
295
+ | 操作系统 | macOS、Linux、Windows(WSL 推荐) |
296
+
297
+
298
+ ## 贡献者
299
+ - [@wangdong](https://github.com/wangdong)
300
+ - [@hezhijian](https://github.com/hezhijian-wps)
301
+ - [@liuxin21](https://github.com/kso-lx21)
302
+ - [@huangluyang](https://www.npmjs.com/~lukeqqi)
303
+ - [@duwei1](https://github.com/duwei1)
304
+ - [@wangzhengrui](https://github.com/wangzhengrui)
305
+ - [@liuzhifei](https://github.com/dacuotecuo)
306
+ - [@chensi](https://github.com/chensi06lj)
307
+ - [@zhangyong](https://github.com/ZhYong10)
308
+
309
+ ## 许可证
310
+
311
+ MIT License - 详见 [LICENSE](LICENSE)。
312
+
313
+ ## 致谢
314
+
315
+ - [OpenClaw](https://openclaw.dev) — AI agent 框架
316
+ - [WPS 开放平台](https://open.wps.cn) — 企业协作平台
317
+ - [TypeScript](https://www.typescriptlang.org/) — 类型安全的 JavaScript
318
+