@wu529778790/open-im 1.9.4-beta.11 → 1.9.4-beta.12

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 (3) hide show
  1. package/README.md +157 -202
  2. package/README.zh-CN.md +151 -202
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -1,24 +1,25 @@
1
1
  # open-im
2
2
 
3
- [中文](./README.zh-CN.md)
3
+ [中文文档](./README.zh-CN.md)
4
4
 
5
- Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat to Claude Code, Codex, and CodeBuddy so you can use your coding assistant remotely from a phone or chat window.
5
+ Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat to Claude Code, Codex, and CodeBuddy use your AI coding assistant from any phone or chat window.
6
6
 
7
7
  ## Features
8
8
 
9
- - Multi-platform support: Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat (WorkBuddy), with multiple platforms enabled at the same time
10
- - Multiple AI tools: Claude, Codex, and CodeBuddy
11
- - Per-platform AI routing: each IM platform can use a different AI tool, with `aiCommand` as the global default and `platforms.<name>.aiCommand` as the override
12
- - Streaming replies: relay AI output and tool execution progress in real time (DingTalk streaming is not fully supported yet)
13
- - Graphical configuration page and CLI setup flow
14
- - Isolated sessions: each user gets an independent local session, and `/new` resets it
15
- - Built-in commands: `/help`, `/new`, `/cd`, `/pwd`, `/status`
9
+ - **6 IM platforms** — Telegram, Feishu, WeCom, DingTalk, QQ, WeChat (WorkBuddy), all can run simultaneously
10
+ - **3 AI backends** Claude (Agent SDK), Codex, CodeBuddy
11
+ - **Per-platform AI routing** each IM can use a different AI tool
12
+ - **Streaming replies** real-time AI output and tool progress (platform-dependent)
13
+ - **Media support** send images, files, voice, video for AI analysis
14
+ - **Session isolation** independent sessions per user, `/new` to reset
15
+ - **Web config UI** graphical dashboard for setup and management
16
+ - **Built-in commands** — `/help`, `/new`, `/cd`, `/pwd`, `/status`, `/allow`, `/deny`
16
17
 
17
18
  ## Requirements
18
19
 
19
20
  - Node.js >= 20
20
21
  - At least one IM platform configured
21
- - Authentication completed for the AI tool you want to use
22
+ - Authentication for the AI tool you want to use
22
23
 
23
24
  ## Quick Start
24
25
 
@@ -33,114 +34,95 @@ npm install -g @wu529778790/open-im
33
34
  open-im start
34
35
  ```
35
36
 
36
- The config file is stored at `~/.open-im/config.json` by default.
37
+ Config file: `~/.open-im/config.json`
37
38
 
38
39
  ## CLI Commands
39
40
 
40
- | Command | Description |
41
- | ----------------- | ---------------------------------------------------------------- |
42
- | `open-im init` | Initialize or append configuration without starting the service |
43
- | `open-im start` | Run the service in the background |
44
- | `open-im stop` | Stop the background service |
45
- | `open-im dev` | Run in the foreground for development/debugging |
46
- | `open-im dashboard` | Run only the config web UI (no bridge) |
41
+ | Command | Description |
42
+ | ------------------- | -------------------------------------- |
43
+ | `open-im init` | Configure without starting the service |
44
+ | `open-im start` | Run as background service |
45
+ | `open-im stop` | Stop background service |
46
+ | `open-im dev` | Run in foreground (debugging) |
47
+ | `open-im dashboard` | Web config UI only (no bridge) |
47
48
 
48
- ## Server Deployment & Config Page
49
+ ## Web Configuration
49
50
 
50
- ### Local (with browser)
51
+ ### Local
51
52
 
52
- Open the config page at [`http://127.0.0.1:39282`](http://127.0.0.1:39282) (or the URL shown after `open-im start`). The page includes:
53
+ Open [`http://127.0.0.1:39282`](http://127.0.0.1:39282) after starting. The dashboard includes:
53
54
 
54
- - **Dashboard** Configured / Enabled platform count and service status (Idle or Running)
55
- - **Platforms** Enable and configure Telegram, Feishu, QQ, WeCom, and DingTalk (credentials, proxy, per-platform AI tool, allowed user IDs). Each platform has a “Test Configuration” button.
56
- - **AI Tooling** **General**: default AI tool (Claude / Codex / CodeBuddy), work directory, hook port, log level. **Per-tool tabs**: Claude (CLI path, timeout, proxy, config path, ANTHROPIC\_\* fields), Codex (CLI path, timeout, proxy), CodeBuddy (CLI path, timeout).
57
- - **Service control** Validate config, Save, Start bridge, Stop bridge.
55
+ - **Overview** platform count, service status
56
+ - **Platforms** enable and configure each IM (credentials, proxy, AI tool, allowed users)
57
+ - **AI Tooling** default tool, work directory, per-tool settings (CLI path, timeout, proxy, API keys)
58
+ - **Service control** validate, save, start/stop bridge
58
59
 
59
- WorkBuddy (WeChat) is not in the web UI; configure it in `~/.open-im/config.json` or via `open-im init`.
60
+ > WorkBuddy (WeChat) is configured via `open-im init` or directly in `~/.open-im/config.json`.
60
61
 
61
- - `open-im start` serves both the config page and the bridge on your local machine.
62
- - `open-im dev` opens the page automatically only when setup is incomplete.
63
- - To open the page when config already exists, you can also run `open-im dashboard` to launch the config UI only (without starting the bridge).
62
+ ### Remote Server
64
63
 
65
- ### Recommended server workflow
66
-
67
- On a remote server, the simplest and safest pattern is:
68
-
69
- 1. **Use `dashboard` to configure via browser**
70
-
71
- On the server:
72
-
73
- ```bash
74
- export OPEN_IM_NO_BROWSER=1
75
- # Optional: bind to all interfaces if you want to open from another device
76
- # export OPEN_IM_WEB_HOST=0.0.0.0
77
- open-im dashboard
78
- ```
79
-
80
- - This starts only the config web UI (no bridge yet).
81
- - If `OPEN_IM_WEB_HOST` is `0.0.0.0`, the server will print a one-time login URL like:
64
+ ```bash
65
+ export OPEN_IM_NO_BROWSER=1
66
+ # Optional: allow access from other devices
67
+ # export OPEN_IM_WEB_HOST=0.0.0.0
68
+ open-im dashboard
69
+ ```
82
70
 
83
- ```text
84
- http://your-server-ip:39282/?login_token=xxxx
85
- ```
71
+ If `OPEN_IM_WEB_HOST=0.0.0.0`, the server prints a one-time login URL:
86
72
 
87
- - Open this URL in your browser, complete all platform/AI settings, then click **Start bridge** in the web UI.
73
+ ```
74
+ http://your-server-ip:39282/?login_token=xxxx
75
+ ```
88
76
 
89
- 2. **Run the bridge as a background service**
77
+ Complete setup in the browser, then start the bridge:
90
78
 
91
- After configuration is saved, you have two options:
92
- - Start from the web UI: use the **Start bridge** button on the Service panel.
93
- - Or start from the CLI:
79
+ ```bash
80
+ open-im start
81
+ ```
94
82
 
95
- ```bash
96
- open-im start
97
- ```
83
+ ## IM Commands
98
84
 
99
- This runs the full bridge in the background using the saved config.
85
+ | Command | Description |
86
+ | ------------- | ------------------------------------ |
87
+ | `/help` | Show help |
88
+ | `/new` | Start a new AI session |
89
+ | `/status` | Show AI tool, version, session info |
90
+ | `/cd <path>` | Change session working directory |
91
+ | `/pwd` | Show current working directory |
92
+ | `/allow` `/y` | Approve a permission request |
93
+ | `/deny` `/n` | Reject a permission request |
100
94
 
101
95
  ## Session Behavior
102
96
 
103
- Session context is stored locally in `~/.open-im/data/sessions.json` and is separate from the IM chat history itself. Each user has an independent session directory and session metadata. Sending `/new` resets the current AI session.
97
+ Sessions are stored locally in `~/.open-im/data/sessions.json`, separate from IM chat history. Each user gets an independent session directory. `/new` resets the AI session.
104
98
 
105
99
  ## Configuration
106
100
 
107
- The root-level `aiCommand` is the default AI tool for all platforms. If you want a specific IM platform to use a different tool, set `platforms.<platform>.aiCommand`.
101
+ ### Per-Platform AI Routing
108
102
 
109
- Example:
103
+ The root-level `aiCommand` is the default AI tool. Override per-platform with `platforms.<name>.aiCommand`:
110
104
 
111
105
  ```json
112
106
  {
113
107
  "aiCommand": "claude",
114
108
  "platforms": {
115
- "telegram": {
116
- "enabled": true,
117
- "aiCommand": "codex"
118
- },
119
- "feishu": {
120
- "enabled": true,
121
- "aiCommand": "codex"
122
- },
123
- "qq": {
124
- "enabled": true,
125
- "aiCommand": "codebuddy"
126
- }
109
+ "telegram": { "enabled": true, "aiCommand": "codex" },
110
+ "feishu": { "enabled": true, "aiCommand": "codex" },
111
+ "qq": { "enabled": true, "aiCommand": "codebuddy" }
127
112
  }
128
113
  }
129
114
  ```
130
115
 
131
- In that setup, Telegram uses Codex, Feishu uses Codex, QQ uses CodeBuddy, and any platform without its own `aiCommand` continues using Claude.
132
-
133
- ### Claude
116
+ ### Claude (Agent SDK)
134
117
 
135
- Claude uses the Agent SDK by default and does not depend on a local `claude` executable. In most cases you only need to provide API credentials.
136
-
137
- Load order:
118
+ Claude uses the Agent SDK by default no local `claude` executable needed. Provide API credentials:
138
119
 
120
+ Credential load order:
139
121
  1. Environment variables
140
122
  2. `env` in `~/.open-im/config.json`
141
123
  3. `~/.claude/settings.json` or `~/.claude.json`
142
124
 
143
- Both the official API and compatible third-party endpoints are supported:
125
+ Compatible with third-party endpoints:
144
126
 
145
127
  ```json
146
128
  {
@@ -152,47 +134,41 @@ Both the official API and compatible third-party endpoints are supported:
152
134
  }
153
135
  ```
154
136
 
137
+ Claude automatically inherits plugins and settings from your local `~/.claude/settings.json`.
138
+
155
139
  ### CodeBuddy
156
140
 
157
- CodeBuddy uses the local CLI. Install it first, then either log in interactively or provide credentials through `env`.
141
+ Install the CLI and log in:
158
142
 
159
143
  ```bash
160
144
  npm install -g @tencent-ai/codebuddy-code
161
- codebuddy --version
162
145
  codebuddy login
163
146
  ```
164
147
 
165
- Common config keys:
148
+ Config keys:
149
+ - `tools.codebuddy.cliPath` — CLI path (default: `codebuddy`)
150
+ - `tools.codebuddy.skipPermissions` — skip permission prompts (default: `true`)
151
+ - `tools.codebuddy.timeoutMs` — execution timeout (default: `600000`)
166
152
 
167
- - `tools.codebuddy.cliPath`: CLI path, defaults to `codebuddy`
168
- - `tools.codebuddy.skipPermissions`: whether to skip permission confirmation, defaults to `true`
169
- - `tools.codebuddy.timeoutMs`: total execution timeout, defaults to `600000`
170
- - `platforms.<platform>.aiCommand`: set to `codebuddy` if that IM platform should use CodeBuddy
153
+ On Windows, if `cliPath` is `codebuddy`, open-im also checks `AppData\Roaming\npm\codebuddy.cmd`.
171
154
 
172
- On Windows, if `cliPath` is still `codebuddy`, open-im also tries common npm global locations such as `AppData\\Roaming\\npm\\codebuddy.cmd`.
173
-
174
- ### Example Config File
175
-
176
- The following is valid JSON and can be saved directly as `~/.open-im/config.json`:
155
+ ### Example Config
177
156
 
178
157
  ```json
179
158
  {
180
159
  "aiCommand": "claude",
181
160
  "tools": {
182
161
  "claude": {
183
- "cliPath": "claude",
184
- "workDir": "D:/coding/open-im",
162
+ "workDir": "/path/to/project",
185
163
  "skipPermissions": true,
186
164
  "timeoutMs": 600000
187
165
  },
188
166
  "codex": {
189
- "cliPath": "codex",
190
- "workDir": "D:/coding/open-im",
167
+ "workDir": "/path/to/project",
191
168
  "skipPermissions": true,
192
169
  "proxy": "http://127.0.0.1:7890"
193
170
  },
194
171
  "codebuddy": {
195
- "cliPath": "codebuddy",
196
172
  "skipPermissions": true,
197
173
  "timeoutMs": 600000
198
174
  }
@@ -200,44 +176,31 @@ The following is valid JSON and can be saved directly as `~/.open-im/config.json
200
176
  "platforms": {
201
177
  "telegram": {
202
178
  "enabled": true,
203
- "aiCommand": "codex",
204
- "proxy": "http://127.0.0.1:7890",
205
- "allowedUserIds": [],
206
179
  "botToken": "YOUR_TELEGRAM_BOT_TOKEN"
207
180
  },
208
181
  "feishu": {
209
182
  "enabled": false,
210
- "aiCommand": "codex",
211
- "allowedUserIds": [],
212
183
  "appId": "YOUR_FEISHU_APP_ID",
213
184
  "appSecret": "YOUR_FEISHU_APP_SECRET"
214
185
  },
215
186
  "qq": {
216
187
  "enabled": false,
217
- "aiCommand": "codebuddy",
218
- "allowedUserIds": [],
219
188
  "appId": "YOUR_QQ_APP_ID",
220
189
  "secret": "YOUR_QQ_APP_SECRET"
221
190
  },
222
191
  "wework": {
223
192
  "enabled": false,
224
- "aiCommand": "claude",
225
- "allowedUserIds": [],
226
193
  "corpId": "YOUR_WEWORK_CORP_ID",
227
194
  "secret": "YOUR_WEWORK_SECRET"
228
195
  },
229
196
  "dingtalk": {
230
197
  "enabled": false,
231
- "aiCommand": "claude",
232
- "allowedUserIds": [],
233
198
  "clientId": "YOUR_DINGTALK_CLIENT_ID",
234
199
  "clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
235
200
  "cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
236
201
  },
237
202
  "workbuddy": {
238
203
  "enabled": false,
239
- "aiCommand": "claude",
240
- "allowedUserIds": [],
241
204
  "accessToken": "",
242
205
  "refreshToken": "",
243
206
  "userId": ""
@@ -246,101 +209,93 @@ The following is valid JSON and can be saved directly as `~/.open-im/config.json
246
209
  }
247
210
  ```
248
211
 
249
- ### Common Environment Variables
250
-
251
- | Variable | Description |
252
- | ---------------------------- | ---------------------------------------------------------------------- |
253
- | `AI_COMMAND` | Select `claude`, `codex`, or `codebuddy` |
254
- | `CLAUDE_WORK_DIR` | Default session working directory |
255
- | `LOG_DIR` | Log directory |
256
- | `LOG_LEVEL` | Log level |
257
- | `HOOK_PORT` | Permission service port |
258
- | `CODEX_PROXY` | Proxy used by Codex to access `chatgpt.com` |
259
- | `OPENAI_API_KEY` | Codex API key, can replace `codex login` |
260
- | `CODEBUDDY_CLI_PATH` | Override CodeBuddy CLI path |
261
- | `CODEBUDDY_TIMEOUT_MS` | Override CodeBuddy timeout |
262
- | `CODEBUDDY_SKIP_PERMISSIONS` | Override CodeBuddy skip-permissions behavior |
263
- | `CODEBUDDY_IDLE_TIMEOUT_MS` | Abort CodeBuddy when it stays silent for too long |
264
- | `CODEBUDDY_API_KEY` | CodeBuddy API key, can replace `codebuddy login` |
265
- | `CODEBUDDY_AUTH_TOKEN` | CodeBuddy auth token, can replace `codebuddy login` |
266
- | `TELEGRAM_BOT_TOKEN` | Telegram bot token |
267
- | `TELEGRAM_PROXY` | Telegram proxy URL |
268
- | `TELEGRAM_ALLOWED_USER_IDS` | Telegram allowlist |
269
- | `FEISHU_APP_ID` | Feishu app ID |
270
- | `FEISHU_APP_SECRET` | Feishu app secret |
271
- | `FEISHU_ALLOWED_USER_IDS` | Feishu allowlist |
272
- | `QQ_BOT_APPID` | QQ bot app ID |
273
- | `QQ_BOT_SECRET` | QQ bot app secret |
274
- | `QQ_BOT_SANDBOX` | QQ bot sandbox mode (`1` / `true` to enable, disabled by default) |
275
- | `QQ_ALLOWED_USER_IDS` | QQ allowlist |
276
- | `DINGTALK_CLIENT_ID` | DingTalk client ID / AppKey |
277
- | `DINGTALK_CLIENT_SECRET` | DingTalk client secret / AppSecret |
278
- | `DINGTALK_CARD_TEMPLATE_ID` | DingTalk AI card template ID; enables single-message streaming replies |
279
- | `DINGTALK_ALLOWED_USER_IDS` | DingTalk allowlist |
280
- | `WEWORK_CORP_ID` | WeCom bot ID |
281
- | `WEWORK_SECRET` | WeCom secret |
282
- | `WEWORK_WS_URL` | WeCom WebSocket URL |
283
- | `WEWORK_ALLOWED_USER_IDS` | WeCom allowlist |
284
- | `WORKBUDDY_ACCESS_TOKEN` | WorkBuddy OAuth access token (auto-generated by `open-im init`) |
285
- | `WORKBUDDY_REFRESH_TOKEN` | WorkBuddy OAuth refresh token (auto-generated by `open-im init`) |
286
- | `WORKBUDDY_USER_ID` | WorkBuddy user ID |
287
- | `WORKBUDDY_BASE_URL` | WorkBuddy API base URL, defaults to `https://copilot.tencent.com` |
288
- | `WORKBUDDY_GUID` | WorkBuddy connection GUID (optional) |
289
- | `WORKBUDDY_WORKSPACE_PATH` | WorkBuddy workspace path (optional) |
290
- | `WORKBUDDY_ALLOWED_USER_IDS` | WorkBuddy allowlist |
291
-
292
- ### Platform Setup Sources
293
-
294
- - Telegram: get the bot token from [@BotFather](https://t.me/BotFather)
295
- - Feishu: create an app and enable the bot in the [Feishu Open Platform](https://open.feishu.cn/)
296
- - QQ: create a bot in the [QQ Open Platform](https://bot.q.qq.com/) and get the `App ID` and `App Secret`
297
- - DingTalk: create an internal enterprise app in DingTalk Open Platform, enable bot Stream Mode, and get the `Client ID` and `Client Secret`
298
- - WeCom: get the bot ID and secret from the [WeCom admin console](https://work.weixin.qq.com/)
299
- - WeChat (WorkBuddy): connects via CodeBuddy (copilot.tencent.com) Centrifuge WebSocket; run `open-im init` and select "WorkBuddy 微信客服 (WeChat KF)" to complete OAuth login and WeChat KF binding
300
-
301
- Notes on DingTalk: the current implementation uses a hybrid model of "Stream Mode for receiving messages + OpenAPI for sending messages".
302
-
303
- - Plain text replies in a session are sent through `sessionWebhook`
304
- - If `cardTemplateId` is configured, the app will try AI assistant `prepare/update/finish` streaming cards; if that fails, it falls back to plain text. In custom bot or regular group scenarios, the interactive card API may return `param.error`, so single-message streaming updates are not available there yet
305
- - Startup and shutdown notifications are not sent to DingTalk (the OpenAPI robot API does not support proactive messages in the same way). Other platforms (e.g. Telegram, Feishu, WeCom) still receive lifecycle notifications when configured
306
-
307
- DingTalk AI card templates are already compatible with the official "Search Result Card" template and use the variables `lastMessage`, `content`, `resources`, `users`, and `flowStatus`. If you use that template, no template changes are required for streaming updates.
308
-
309
- ## IM Commands
310
-
311
- | Command | Description |
312
- | ------------- | -------------------------------------------------------- |
313
- | `/help` | Show help |
314
- | `/new` | Start a new session |
315
- | `/status` | Show AI tool, version, session directory, and session ID |
316
- | `/cd <path>` | Change the session working directory |
317
- | `/pwd` | Show the current session working directory |
318
- | `/allow` `/y` | Approve a permission request |
319
- | `/deny` `/n` | Reject a permission request |
212
+ ### Environment Variables
213
+
214
+ #### General
215
+
216
+ | Variable | Description |
217
+ | ------------------- | ---------------------------------------------- |
218
+ | `AI_COMMAND` | Default AI tool (`claude` / `codex` / `codebuddy`) |
219
+ | `CLAUDE_WORK_DIR` | Default session working directory |
220
+ | `LOG_DIR` | Log directory |
221
+ | `LOG_LEVEL` | Log level |
222
+ | `HOOK_PORT` | Permission service port |
223
+
224
+ #### AI Tool Credentials
225
+
226
+ | Variable | Description |
227
+ | ---------------------------- | ------------------------------------------ |
228
+ | `ANTHROPIC_API_KEY` | Claude API key |
229
+ | `ANTHROPIC_AUTH_TOKEN` | Claude OAuth token |
230
+ | `ANTHROPIC_BASE_URL` | Claude API base URL |
231
+ | `ANTHROPIC_MODEL` | Claude model name |
232
+ | `OPENAI_API_KEY` | Codex API key |
233
+ | `CODEX_PROXY` | Codex proxy for `chatgpt.com` |
234
+ | `CODEBUDDY_CLI_PATH` | CodeBuddy CLI path |
235
+ | `CODEBUDDY_TIMEOUT_MS` | CodeBuddy timeout |
236
+ | `CODEBUDDY_API_KEY` | CodeBuddy API key |
237
+ | `CODEBUDDY_AUTH_TOKEN` | CodeBuddy auth token |
238
+
239
+ #### Platform Credentials
240
+
241
+ | Variable | Description |
242
+ | ---------------------------- | ------------------------------------------ |
243
+ | `TELEGRAM_BOT_TOKEN` | Telegram bot token |
244
+ | `TELEGRAM_PROXY` | Telegram proxy URL |
245
+ | `TELEGRAM_ALLOWED_USER_IDS` | Telegram allowed user IDs |
246
+ | `FEISHU_APP_ID` | Feishu app ID |
247
+ | `FEISHU_APP_SECRET` | Feishu app secret |
248
+ | `FEISHU_ALLOWED_USER_IDS` | Feishu allowed user IDs |
249
+ | `QQ_BOT_APPID` | QQ bot app ID |
250
+ | `QQ_BOT_SECRET` | QQ bot app secret |
251
+ | `QQ_BOT_SANDBOX` | QQ sandbox mode (`1` / `true`) |
252
+ | `QQ_ALLOWED_USER_IDS` | QQ allowed user IDs |
253
+ | `DINGTALK_CLIENT_ID` | DingTalk client ID / AppKey |
254
+ | `DINGTALK_CLIENT_SECRET` | DingTalk client secret / AppSecret |
255
+ | `DINGTALK_CARD_TEMPLATE_ID` | DingTalk AI card template ID |
256
+ | `DINGTALK_ALLOWED_USER_IDS` | DingTalk allowed user IDs |
257
+ | `WEWORK_CORP_ID` | WeCom bot ID |
258
+ | `WEWORK_SECRET` | WeCom secret |
259
+ | `WEWORK_WS_URL` | WeCom WebSocket URL |
260
+ | `WEWORK_ALLOWED_USER_IDS` | WeCom allowed user IDs |
261
+ | `WORKBUDDY_ACCESS_TOKEN` | WorkBuddy OAuth access token |
262
+ | `WORKBUDDY_REFRESH_TOKEN` | WorkBuddy OAuth refresh token |
263
+ | `WORKBUDDY_USER_ID` | WorkBuddy user ID |
264
+ | `WORKBUDDY_BASE_URL` | WorkBuddy API base URL |
265
+ | `WORKBUDDY_ALLOWED_USER_IDS` | WorkBuddy allowed user IDs |
266
+
267
+ ### Platform Setup
268
+
269
+ | Platform | Setup source |
270
+ | --------- | --------------------------------------------------------------- |
271
+ | Telegram | [@BotFather](https://t.me/BotFather) |
272
+ | Feishu | [Feishu Open Platform](https://open.feishu.cn/) |
273
+ | QQ | [QQ Open Platform](https://bot.q.qq.com/) |
274
+ | DingTalk | DingTalk Open Platform — enable bot Stream Mode |
275
+ | WeCom | [WeCom admin console](https://work.weixin.qq.com/) |
276
+ | WeChat | Run `open-im init` and select "WorkBuddy" for OAuth + binding |
277
+
278
+ **DingTalk notes:**
279
+ - Uses Stream Mode (receive) + OpenAPI (send)
280
+ - With `cardTemplateId`: AI assistant streaming cards; falls back to plain text on failure
281
+ - Custom bots and regular groups only support single text replies
282
+ - Startup/shutdown notifications are not sent to DingTalk
320
283
 
321
284
  ## Troubleshooting
322
285
 
323
- **Telegram does not respond**: check network access. If needed, add `"proxy": "http://127.0.0.1:7890"` to the Telegram platform config or set `TELEGRAM_PROXY`.
324
-
325
- **QQ cannot connect**: make sure the bot has been created and enabled in QQ Open Platform, then verify `QQ_BOT_APPID`, `QQ_BOT_SECRET`, or `platforms.qq`.
326
-
327
- **QQ sends duplicate replies**: update to the latest version. This issue was fixed recently.
328
-
329
- **Feishu card errors**: if card callbacks are not configured, you can use `/mode ask` or `/mode yolo` directly.
330
-
331
- **WeCom notifications are not received**: the bot must receive at least one message first before it can send proactive notifications.
332
-
333
- **DingTalk cannot reply**: make sure bot Stream Mode is enabled for the app, then verify `DINGTALK_CLIENT_ID`, `DINGTALK_CLIENT_SECRET`, or `platforms.dingtalk`.
334
-
335
- **DingTalk has no streaming updates**: when `prepare` fails, the app falls back to plain text replies. In custom bot or regular group scenarios, neither the AI assistant API nor the interactive card API is available, so only single plain text replies are supported.
336
-
337
- **Codex shows `stream disconnected` or `error sending request`**: `chatgpt.com` is not reachable. Configure `tools.codex.proxy` or set `CODEX_PROXY`.
338
-
339
- **CodeBuddy prompts for login**: run `codebuddy login` first. `open-im` does not read CodeBuddy login state from `~/.open-im/config.json`.
340
-
341
- **WorkBuddy cannot connect**: run `open-im init` to re-authenticate. Tokens may expire — the client will attempt auto-reconnect, but if the refresh token is invalid, a fresh login is required.
342
-
343
- **WorkBuddy WeChat KF not receiving messages**: ensure the WeChat KF binding was completed during `open-im init`. You can re-run init to generate a new binding link.
286
+ | Issue | Solution |
287
+ | ----- | -------- |
288
+ | Telegram not responding | Check network, add `proxy` or set `TELEGRAM_PROXY` |
289
+ | QQ cannot connect | Verify bot is created and `QQ_BOT_APPID` / `QQ_BOT_SECRET` are correct |
290
+ | QQ duplicate replies | Update to latest version |
291
+ | Feishu card errors | Use `/mode ask` or `/mode yolo` without card callbacks |
292
+ | WeCom no notifications | Send at least one message to the bot first |
293
+ | DingTalk cannot reply | Verify Stream Mode is enabled and credentials are correct |
294
+ | DingTalk no streaming | Custom bots only support plain text; configure `cardTemplateId` for AI assistant streaming |
295
+ | Codex `stream disconnected` | Configure `tools.codex.proxy` or `CODEX_PROXY` for `chatgpt.com` access |
296
+ | CodeBuddy asks for login | Run `codebuddy login` first |
297
+ | WorkBuddy cannot connect | Run `open-im init` to re-authenticate; tokens may expire |
298
+ | WorkBuddy WeChat not receiving | Re-run `open-im init` to generate new WeChat KF binding link |
344
299
 
345
300
  ## License
346
301
 
package/README.zh-CN.md CHANGED
@@ -2,17 +2,18 @@
2
2
 
3
3
  [English](./README.md)
4
4
 
5
- 多平台 IM 桥接工具,把 Telegram、飞书、企业微信、钉钉、QQ、微信接到 AI CLI 工具(Claude Code、Codex、CodeBuddy),方便在手机或聊天窗口里远程使用 AI 编程助手。
5
+ 多平台 IM 桥接工具,把 Telegram、飞书、企业微信、钉钉、QQ、微信接到 AI CLI 工具(Claude Code、Codex、CodeBuddy),在手机或聊天窗口远程使用 AI 编程助手。
6
6
 
7
7
  ## 功能特性
8
8
 
9
- - 多平台:支持 Telegram、飞书、企业微信、钉钉、QQ、微信(WorkBuddy),可同时启用
10
- - AI 工具:支持 ClaudeCodex、CodeBuddy
11
- - 按平台分配 AI:根级 `aiCommand` 作为默认值,`platforms.<name>.aiCommand` 可为不同 IM 单独指定 AI 工具
12
- - 流式输出:实时回传 AI 回复与工具执行进度(目前钉钉暂未实现流式传输)
13
- - 图形化配置页面 / CLI 配置引导
14
- - 会话隔离:每个用户独立维护本地会话,`/new` 可重置
15
- - 常用命令:支持 `/help`、`/new`、`/cd`、`/pwd`、`/status`
9
+ - **6 个 IM 平台** — Telegram、飞书、企业微信、钉钉、QQ、微信(WorkBuddy),可同时启用
10
+ - **3 AI 后端** Claude(Agent SDK)、Codex、CodeBuddy
11
+ - **按平台分配 AI** 每个 IM 平台可以使用不同的 AI 工具
12
+ - **流式输出** — 实时回传 AI 回复与工具执行进度(因平台而异)
13
+ - **多媒体支持** 支持发送图片、文件、语音、视频进行 AI 分析
14
+ - **会话隔离** — 每个用户独立维护本地会话,`/new` 可重置
15
+ - **Web 配置页面** — 图形化仪表板,在线管理配置
16
+ - **内置命令** — `/help`、`/new`、`/cd`、`/pwd`、`/status`、`/allow`、`/deny`
16
17
 
17
18
  ## 环境要求
18
19
 
@@ -33,120 +34,95 @@ npm install -g @wu529778790/open-im
33
34
  open-im start
34
35
  ```
35
36
 
36
- 配置文件默认保存在 `~/.open-im/config.json`。
37
+ 配置文件:`~/.open-im/config.json`
37
38
 
38
39
  ## CLI 命令
39
40
 
40
- | 命令 | 说明 |
41
- | ----------------- | ------------------------------ |
42
- | `open-im init` | 初始化或追加配置,不启动服务 |
43
- | `open-im start` | 后台运行服务 |
44
- | `open-im stop` | 停止后台服务 |
45
- | `open-im dev` | 前台运行(调试模式) |
46
- | `open-im dashboard` | 仅启动 Web 配置页(不启动桥接服务) |
41
+ | 命令 | 说明 |
42
+ | ------------------- | ------------------------------ |
43
+ | `open-im init` | 配置平台和 AI 工具,不启动服务 |
44
+ | `open-im start` | 后台运行服务 |
45
+ | `open-im stop` | 停止后台服务 |
46
+ | `open-im dev` | 前台运行(调试模式) |
47
+ | `open-im dashboard` | 仅启动 Web 配置页(不启动桥接)|
47
48
 
48
- ## 服务器部署与图形化配置
49
+ ## Web 配置页面
49
50
 
50
- ### 本机(带浏览器)使用
51
+ ### 本机使用
51
52
 
52
- 在本机直接运行:
53
+ 启动后打开 [`http://127.0.0.1:39282`](http://127.0.0.1:39282),页面包括:
53
54
 
54
- ```bash
55
- open-im start
56
- ```
57
-
58
- 然后在浏览器中打开 [`http://127.0.0.1:39282`](http://127.0.0.1:39282)(或命令行里提示的地址),页面结构如下:
59
-
60
- - **概览** – 已配置/已启用平台数量、服务状态(未启动或运行中)
61
- - **平台配置** – 启用并填写 Telegram、飞书、QQ、企业微信、钉钉的凭证(Bot Token/App ID/Secret、代理、该平台使用的 AI 工具、白名单用户 ID)。每个平台提供「校验配置」按钮
62
- - **AI 工具配置** – **公共**:默认 AI 工具(Claude / Codex / CodeBuddy)、工作目录、Hook 端口、日志级别。**分工具**:Claude(CLI 路径、超时、代理、配置路径、ANTHROPIC\_\* 等)、Codex(CLI 路径、超时、代理)、CodeBuddy(CLI 路径、超时)
63
- - **服务控制** – 校验配置、保存、启动桥接、停止桥接
64
-
65
- WorkBuddy(微信)暂不在网页中配置,如需使用请在 `~/.open-im/config.json` 中手动配置或通过 `open-im init` 引导。
55
+ - **概览** — 已配置/已启用平台数量、服务状态
56
+ - **平台配置** — 启用并填写各 IM 的凭证(Token/App ID/Secret、代理、AI 工具、白名单)
57
+ - **AI 工具配置** — 默认 AI 工具、工作目录、各工具单独设置(CLI 路径、超时、代理、API Key)
58
+ - **服务控制** — 校验配置、保存、启动/停止桥接
66
59
 
67
- - `open-im start` 会同时启动桥接服务并提供该配置页(本机场景)。
68
- - `open-im dev` 仅在未完成配置时自动打开页面。
69
- - 已有配置但想单独打开配置页时,可以使用 `open-im dashboard` 启动仅 Web 配置服务。
60
+ > WorkBuddy(微信)通过 `open-im init` 或直接编辑 `~/.open-im/config.json` 配置。
70
61
 
71
- ### 推荐的服务器端使用方式
62
+ ### 远程服务器
72
63
 
73
- 在远程服务器上,建议的最简单、安全的方式是:
74
-
75
- 1. **先通过 `dashboard` 在浏览器里完成配置**
76
-
77
- 在服务器上执行:
78
-
79
- ```bash
80
- export OPEN_IM_NO_BROWSER=1
81
- # 可选:如果希望从其他设备访问配置页,可以绑定到所有网卡
82
- # export OPEN_IM_WEB_HOST=0.0.0.0
83
- open-im dashboard
84
- ```
85
-
86
- - 这只会启动 Web 配置页,不会同时启动桥接服务。
87
- - 若设置了 `OPEN_IM_WEB_HOST=0.0.0.0`,服务端会输出一次性登录链接,例如:
64
+ ```bash
65
+ export OPEN_IM_NO_BROWSER=1
66
+ # 可选:允许从其他设备访问配置页
67
+ # export OPEN_IM_WEB_HOST=0.0.0.0
68
+ open-im dashboard
69
+ ```
88
70
 
89
- ```text
90
- http://your-server-ip:39282/?login_token=xxxx
91
- ```
71
+ 若设置了 `OPEN_IM_WEB_HOST=0.0.0.0`,服务端会输出一次性登录链接:
92
72
 
93
- - 在浏览器中打开该链接,按照页面提示完成各个平台 / AI 工具配置,最后在页面中点击 **「Start bridge」** 按钮启动桥接服务。
73
+ ```
74
+ http://your-server-ip:39282/?login_token=xxxx
75
+ ```
94
76
 
95
- 2. **后台运行桥接服务**
77
+ 在浏览器中完成配置后,启动桥接服务:
96
78
 
97
- 配置保存后,有两种启动方式:
98
- - 在 Web 页面 Service 面板中直接点击 **「Start bridge」**;
99
- - 或者在服务器上运行:
79
+ ```bash
80
+ open-im start
81
+ ```
100
82
 
101
- ```bash
102
- open-im start
103
- ```
83
+ ## IM 内命令
104
84
 
105
- 这会根据已保存的配置,在后台长期运行桥接服务。
85
+ | 命令 | 说明 |
86
+ | ------------- | ---------------------- |
87
+ | `/help` | 显示帮助 |
88
+ | `/new` | 开始新的 AI 会话 |
89
+ | `/status` | 显示 AI 工具和会话信息 |
90
+ | `/cd <路径>` | 切换会话目录 |
91
+ | `/pwd` | 显示当前会话目录 |
92
+ | `/allow` `/y` | 允许权限请求 |
93
+ | `/deny` `/n` | 拒绝权限请求 |
106
94
 
107
95
  ## 会话说明
108
96
 
109
- 会话上下文保存在本地 `~/.open-im/data/sessions.json`,与 IM 聊天记录本身无关。每个用户有独立会话目录和 session 信息,发送 `/new` 会重置当前 AI 会话。
97
+ 会话保存在本地 `~/.open-im/data/sessions.json`,与 IM 聊天记录无关。每个用户有独立的会话目录。`/new` 重置当前 AI 会话。
110
98
 
111
99
  ## 配置说明
112
100
 
113
- 根级 `aiCommand` 是所有平台共用的默认 AI 工具。若某个 IM 平台需要单独绑定其他工具,可以设置 `platforms.<platform>.aiCommand`。
101
+ ### 按平台分配 AI 工具
114
102
 
115
- 示例:
103
+ 根级 `aiCommand` 是默认 AI 工具,可通过 `platforms.<name>.aiCommand` 为不同 IM 单独指定:
116
104
 
117
105
  ```json
118
106
  {
119
107
  "aiCommand": "claude",
120
108
  "platforms": {
121
- "telegram": {
122
- "enabled": true,
123
- "aiCommand": "codex"
124
- },
125
- "feishu": {
126
- "enabled": true,
127
- "aiCommand": "codex"
128
- },
129
- "qq": {
130
- "enabled": true,
131
- "aiCommand": "codebuddy"
132
- }
109
+ "telegram": { "enabled": true, "aiCommand": "codex" },
110
+ "feishu": { "enabled": true, "aiCommand": "codex" },
111
+ "qq": { "enabled": true, "aiCommand": "codebuddy" }
133
112
  }
134
113
  }
135
114
  ```
136
115
 
137
- 这个配置下,Telegram 会走 Codex,飞书会走 Codex,QQ 会走 CodeBuddy,其他未单独指定 `aiCommand` 的平台仍然使用 Claude。
116
+ ### Claude(Agent SDK)
138
117
 
139
- ### Claude
140
-
141
- Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通常只需要配置 API 凭证。
142
-
143
- 自动加载顺序:
118
+ Claude 默认使用 Agent SDK,不需要本地 `claude` 可执行文件,只需配置 API 凭证。
144
119
 
120
+ 凭证加载顺序:
145
121
  1. 环境变量
146
122
  2. `~/.open-im/config.json` 的 `env`
147
123
  3. `~/.claude/settings.json` 或 `~/.claude.json`
148
124
 
149
- 支持官方 API,也支持第三方兼容接口:
125
+ 支持第三方兼容接口:
150
126
 
151
127
  ```json
152
128
  {
@@ -158,47 +134,41 @@ Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通
158
134
  }
159
135
  ```
160
136
 
137
+ Claude 会自动继承本地 `~/.claude/settings.json` 中的插件和配置。
138
+
161
139
  ### CodeBuddy
162
140
 
163
- CodeBuddy 依赖本地 CLI。先安装 CLI,再通过交互登录或在 `env` 中提供凭证。
141
+ 安装 CLI 并登录:
164
142
 
165
143
  ```bash
166
144
  npm install -g @tencent-ai/codebuddy-code
167
- codebuddy --version
168
145
  codebuddy login
169
146
  ```
170
147
 
171
- 常用配置项:
148
+ 配置项:
149
+ - `tools.codebuddy.cliPath` — CLI 路径(默认:`codebuddy`)
150
+ - `tools.codebuddy.skipPermissions` — 跳过权限确认(默认:`true`)
151
+ - `tools.codebuddy.timeoutMs` — 执行超时(默认:`600000`)
172
152
 
173
- - `tools.codebuddy.cliPath`:CLI 路径,默认 `codebuddy`
174
- - `tools.codebuddy.skipPermissions`:是否跳过权限确认,默认 `true`
175
- - `tools.codebuddy.timeoutMs`:总执行超时,默认 `600000`
176
- - `platforms.<platform>.aiCommand`:若某个平台要走 CodeBuddy,可设为 `codebuddy`
177
-
178
- 在 Windows 上,如果 `cliPath` 仍然是 `codebuddy`,open-im 还会自动尝试 `AppData\\Roaming\\npm\\codebuddy.cmd` 等常见全局安装路径。
153
+ Windows 上若 `cliPath` `codebuddy`,会自动尝试 `AppData\Roaming\npm\codebuddy.cmd`。
179
154
 
180
155
  ### 配置文件示例
181
156
 
182
- 下面示例是合法 JSON,可直接保存为 `~/.open-im/config.json`:
183
-
184
157
  ```json
185
158
  {
186
159
  "aiCommand": "claude",
187
160
  "tools": {
188
161
  "claude": {
189
- "cliPath": "claude",
190
- "workDir": "D:/coding/open-im",
162
+ "workDir": "/path/to/project",
191
163
  "skipPermissions": true,
192
164
  "timeoutMs": 600000
193
165
  },
194
166
  "codex": {
195
- "cliPath": "codex",
196
- "workDir": "D:/coding/open-im",
167
+ "workDir": "/path/to/project",
197
168
  "skipPermissions": true,
198
169
  "proxy": "http://127.0.0.1:7890"
199
170
  },
200
171
  "codebuddy": {
201
- "cliPath": "codebuddy",
202
172
  "skipPermissions": true,
203
173
  "timeoutMs": 600000
204
174
  }
@@ -206,44 +176,31 @@ codebuddy login
206
176
  "platforms": {
207
177
  "telegram": {
208
178
  "enabled": true,
209
- "aiCommand": "codex",
210
- "proxy": "http://127.0.0.1:7890",
211
- "allowedUserIds": [],
212
179
  "botToken": "YOUR_TELEGRAM_BOT_TOKEN"
213
180
  },
214
181
  "feishu": {
215
182
  "enabled": false,
216
- "aiCommand": "codex",
217
- "allowedUserIds": [],
218
183
  "appId": "YOUR_FEISHU_APP_ID",
219
184
  "appSecret": "YOUR_FEISHU_APP_SECRET"
220
185
  },
221
186
  "qq": {
222
187
  "enabled": false,
223
- "aiCommand": "codebuddy",
224
- "allowedUserIds": [],
225
188
  "appId": "YOUR_QQ_APP_ID",
226
189
  "secret": "YOUR_QQ_APP_SECRET"
227
190
  },
228
191
  "wework": {
229
192
  "enabled": false,
230
- "aiCommand": "claude",
231
- "allowedUserIds": [],
232
193
  "corpId": "YOUR_WEWORK_CORP_ID",
233
194
  "secret": "YOUR_WEWORK_SECRET"
234
195
  },
235
196
  "dingtalk": {
236
197
  "enabled": false,
237
- "aiCommand": "claude",
238
- "allowedUserIds": [],
239
198
  "clientId": "YOUR_DINGTALK_CLIENT_ID",
240
199
  "clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
241
200
  "cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
242
201
  },
243
202
  "workbuddy": {
244
203
  "enabled": false,
245
- "aiCommand": "claude",
246
- "allowedUserIds": [],
247
204
  "accessToken": "",
248
205
  "refreshToken": "",
249
206
  "userId": ""
@@ -252,101 +209,93 @@ codebuddy login
252
209
  }
253
210
  ```
254
211
 
255
- ### 常用环境变量
256
-
257
- | 变量 | 说明 |
258
- | ---------------------------- | ---------------------------------------------- |
259
- | `AI_COMMAND` | 选择 `claude` / `codex` / `codebuddy` |
260
- | `CLAUDE_WORK_DIR` | 默认会话目录 |
261
- | `LOG_DIR` | 日志目录 |
262
- | `LOG_LEVEL` | 日志级别 |
263
- | `HOOK_PORT` | 权限服务端口 |
264
- | `CODEX_PROXY` | Codex 访问 `chatgpt.com` 的代理 |
265
- | `OPENAI_API_KEY` | Codex API Key,可替代 `codex login` |
266
- | `CODEBUDDY_CLI_PATH` | 覆盖 CodeBuddy CLI 路径 |
267
- | `CODEBUDDY_TIMEOUT_MS` | 覆盖 CodeBuddy 超时 |
268
- | `CODEBUDDY_SKIP_PERMISSIONS` | 覆盖 CodeBuddy 的跳过权限确认行为 |
269
- | `CODEBUDDY_IDLE_TIMEOUT_MS` | CodeBuddy 长时间无输出时自动终止 |
270
- | `CODEBUDDY_API_KEY` | CodeBuddy API Key,可替代 `codebuddy login` |
271
- | `CODEBUDDY_AUTH_TOKEN` | CodeBuddy Auth Token,可替代 `codebuddy login` |
272
- | `TELEGRAM_BOT_TOKEN` | Telegram Bot Token |
273
- | `TELEGRAM_PROXY` | Telegram 代理地址 |
274
- | `TELEGRAM_ALLOWED_USER_IDS` | Telegram 白名单 |
275
- | `FEISHU_APP_ID` | 飞书 App ID |
276
- | `FEISHU_APP_SECRET` | 飞书 App Secret |
277
- | `FEISHU_ALLOWED_USER_IDS` | 飞书白名单 |
278
- | `QQ_BOT_APPID` | QQ 机器人 App ID |
279
- | `QQ_BOT_SECRET` | QQ 机器人 App Secret |
280
- | `QQ_BOT_SANDBOX` | QQ 机器人沙箱模式(`1`/`true` 启用,默认关闭) |
281
- | `QQ_ALLOWED_USER_IDS` | QQ 白名单 |
282
- | `DINGTALK_CLIENT_ID` | 钉钉应用 Client ID / AppKey |
283
- | `DINGTALK_CLIENT_SECRET` | 钉钉应用 Client Secret / AppSecret |
284
- | `DINGTALK_CARD_TEMPLATE_ID` | 钉钉 AI 卡片模板 ID,配置后启用单条流式回复 |
285
- | `DINGTALK_ALLOWED_USER_IDS` | 钉钉白名单 |
286
- | `WEWORK_CORP_ID` | 企业微信 Bot ID |
287
- | `WEWORK_SECRET` | 企业微信 Secret |
288
- | `WEWORK_WS_URL` | 企业微信 WebSocket 地址 |
289
- | `WEWORK_ALLOWED_USER_IDS` | 企业微信白名单 |
290
- | `WORKBUDDY_ACCESS_TOKEN` | WorkBuddy OAuth 访问令牌(由 `open-im init` 自动生成) |
291
- | `WORKBUDDY_REFRESH_TOKEN` | WorkBuddy OAuth 刷新令牌(由 `open-im init` 自动生成) |
292
- | `WORKBUDDY_USER_ID` | WorkBuddy 用户 ID |
293
- | `WORKBUDDY_BASE_URL` | WorkBuddy API 地址,默认 `https://copilot.tencent.com` |
294
- | `WORKBUDDY_GUID` | WorkBuddy 连接 GUID(可选) |
295
- | `WORKBUDDY_WORKSPACE_PATH` | WorkBuddy 工作区路径(可选) |
296
- | `WORKBUDDY_ALLOWED_USER_IDS` | WorkBuddy 白名单 |
212
+ ### 环境变量
213
+
214
+ #### 通用
215
+
216
+ | 变量 | 说明 |
217
+ | ----------------- | ------------------------------------------ |
218
+ | `AI_COMMAND` | 默认 AI 工具(`claude` / `codex` / `codebuddy`)|
219
+ | `CLAUDE_WORK_DIR` | 默认会话工作目录 |
220
+ | `LOG_DIR` | 日志目录 |
221
+ | `LOG_LEVEL` | 日志级别 |
222
+ | `HOOK_PORT` | 权限服务端口 |
223
+
224
+ #### AI 工具凭证
225
+
226
+ | 变量 | 说明 |
227
+ | ---------------------------- | ----------------------------- |
228
+ | `ANTHROPIC_API_KEY` | Claude API Key |
229
+ | `ANTHROPIC_AUTH_TOKEN` | Claude OAuth Token |
230
+ | `ANTHROPIC_BASE_URL` | Claude API 地址 |
231
+ | `ANTHROPIC_MODEL` | Claude 模型名称 |
232
+ | `OPENAI_API_KEY` | Codex API Key |
233
+ | `CODEX_PROXY` | Codex 访问 `chatgpt.com` 的代理|
234
+ | `CODEBUDDY_CLI_PATH` | CodeBuddy CLI 路径 |
235
+ | `CODEBUDDY_TIMEOUT_MS` | CodeBuddy 超时 |
236
+ | `CODEBUDDY_API_KEY` | CodeBuddy API Key |
237
+ | `CODEBUDDY_AUTH_TOKEN` | CodeBuddy Auth Token |
238
+
239
+ #### 平台凭证
240
+
241
+ | 变量 | 说明 |
242
+ | ---------------------------- | ----------------------------- |
243
+ | `TELEGRAM_BOT_TOKEN` | Telegram Bot Token |
244
+ | `TELEGRAM_PROXY` | Telegram 代理地址 |
245
+ | `TELEGRAM_ALLOWED_USER_IDS` | Telegram 白名单 |
246
+ | `FEISHU_APP_ID` | 飞书 App ID |
247
+ | `FEISHU_APP_SECRET` | 飞书 App Secret |
248
+ | `FEISHU_ALLOWED_USER_IDS` | 飞书白名单 |
249
+ | `QQ_BOT_APPID` | QQ 机器人 App ID |
250
+ | `QQ_BOT_SECRET` | QQ 机器人 App Secret |
251
+ | `QQ_BOT_SANDBOX` | QQ 沙箱模式(`1`/`true`) |
252
+ | `QQ_ALLOWED_USER_IDS` | QQ 白名单 |
253
+ | `DINGTALK_CLIENT_ID` | 钉钉应用 Client ID / AppKey |
254
+ | `DINGTALK_CLIENT_SECRET` | 钉钉应用 Client Secret |
255
+ | `DINGTALK_CARD_TEMPLATE_ID` | 钉钉 AI 卡片模板 ID |
256
+ | `DINGTALK_ALLOWED_USER_IDS` | 钉钉白名单 |
257
+ | `WEWORK_CORP_ID` | 企业微信 Bot ID |
258
+ | `WEWORK_SECRET` | 企业微信 Secret |
259
+ | `WEWORK_WS_URL` | 企业微信 WebSocket 地址 |
260
+ | `WEWORK_ALLOWED_USER_IDS` | 企业微信白名单 |
261
+ | `WORKBUDDY_ACCESS_TOKEN` | WorkBuddy OAuth 访问令牌 |
262
+ | `WORKBUDDY_REFRESH_TOKEN` | WorkBuddy OAuth 刷新令牌 |
263
+ | `WORKBUDDY_USER_ID` | WorkBuddy 用户 ID |
264
+ | `WORKBUDDY_BASE_URL` | WorkBuddy API 地址 |
265
+ | `WORKBUDDY_ALLOWED_USER_IDS` | WorkBuddy 白名单 |
297
266
 
298
267
  ### 平台配置来源
299
268
 
300
- - Telegram:从 [@BotFather](https://t.me/BotFather) 获取 Bot Token
301
- - 飞书:从 [飞书开放平台](https://open.feishu.cn/) 创建应用并启用机器人
302
- - QQ:从 [QQ 开放平台](https://bot.q.qq.com/) 创建机器人,获取 `App ID` 和 `App Secret`
303
- - 钉钉:从钉钉开放平台创建企业内部应用,启用机器人 Stream Mode,获取 `Client ID` 和 `Client Secret`
304
- - 企业微信:从 [企业微信管理后台](https://work.weixin.qq.com/) 获取 Bot ID 和 Secret
305
- - 微信(WorkBuddy):通过 CodeBuddy(copilot.tencent.com)Centrifuge WebSocket 接入微信客服;运行 `open-im init` 并选择 "WorkBuddy 微信客服 (WeChat KF)" 完成 OAuth 登录和微信客服绑定
306
-
307
- 说明:钉钉当前采用“Stream Mode 收消息 + OpenAPI 发送消息”的混合模式。
308
-
309
- - 会话内普通文本回复默认走 `sessionWebhook`
310
- - 若配置了 `cardTemplateId`,会尝试 AI 助理 `prepare/update/finish` 流式卡片;失败则 fallback 为普通文本(自定义机器人/普通群场景下互动卡片 API 报 `param.error`,暂不支持单条流式更新)
311
- - 启动/关闭通知不会发给钉钉(OpenAPI 机器人接口不支持主动发消息);其他已配置平台(如 Telegram、飞书、企业微信)仍会收到生命周期通知
312
-
313
- 钉钉 AI 卡片模板:已适配官方「搜索结果卡片」模板,使用变量 `lastMessage`、`content`、`resources`、`users`、`flowStatus`。若使用该模板,无需修改模板即可实现流式更新。
314
-
315
- ## IM 内命令
316
-
317
- | 命令 | 说明 |
318
- | ------------- | ------------------------------------- |
319
- | `/help` | 显示帮助 |
320
- | `/new` | 开始新会话 |
321
- | `/status` | 显示 AI 工具、版本、会话目录、会话 ID |
322
- | `/cd <路径>` | 切换会话目录 |
323
- | `/pwd` | 显示当前会话目录 |
324
- | `/allow` `/y` | 允许权限请求 |
325
- | `/deny` `/n` | 拒绝权限请求 |
269
+ | 平台 | 配置来源 |
270
+ | -------- | --------------------------------------------------------------- |
271
+ | Telegram | 从 [@BotFather](https://t.me/BotFather) 获取 Bot Token |
272
+ | 飞书 | [飞书开放平台](https://open.feishu.cn/) 创建应用并启用机器人 |
273
+ | QQ | [QQ 开放平台](https://bot.q.qq.com/) 创建机器人 |
274
+ | 钉钉 | 从钉钉开放平台创建应用,启用机器人 Stream Mode |
275
+ | 企业微信 | 从 [企业微信管理后台](https://work.weixin.qq.com/) 获取凭证 |
276
+ | 微信 | 运行 `open-im init` 并选择 "WorkBuddy" 完成 OAuth 登录和绑定 |
277
+
278
+ **钉钉说明:**
279
+ - 采用 Stream Mode 收消息 + OpenAPI 发消息的混合模式
280
+ - 配置 `cardTemplateId` 后启用 AI 助理流式卡片,失败时回退为纯文本
281
+ - 自定义机器人和普通群仅支持单条文本回复
282
+ - 启动/关闭通知不会发送到钉钉
326
283
 
327
284
  ## 故障排除
328
285
 
329
- **Telegram 无响应**:检查网络,必要时在 Telegram 平台配置中添加 `"proxy": "http://127.0.0.1:7890"` 或设置 `TELEGRAM_PROXY`。
330
-
331
- **QQ 无法连接**:确认机器人已在 QQ 开放平台创建并启用,检查 `QQ_BOT_APPID`、`QQ_BOT_SECRET` `platforms.qq` 配置是否正确。
332
-
333
- **QQ 重复回复**:如遇到消息重复发送,请确保使用最新版本,该问题已在近期修复。
334
-
335
- **飞书卡片报错**:未配置卡片回调时,可直接用 `/mode ask`、`/mode yolo`。
336
-
337
- **企业微信收不到通知**:需要先给机器人发过一条消息,后续才能收到主动通知。
338
-
339
- **钉钉无法回复**:确认应用已启用机器人 Stream Mode,并检查 `DINGTALK_CLIENT_ID`、`DINGTALK_CLIENT_SECRET` `platforms.dingtalk` 配置是否正确。
340
-
341
- **钉钉没有流式更新**:`prepare` 失败时 fallback 为普通文本回复。自定义机器人/普通群场景下,AI 助理和互动卡片 API 均不可用,仅支持单条文本回复。
342
-
343
- **Codex 报 `stream disconnected` / `error sending request`**:无法访问 `chatgpt.com`,请配置 `tools.codex.proxy` 或环境变量 `CODEX_PROXY`。
344
-
345
- **CodeBuddy 提示需要登录**:先执行 `codebuddy login`。`open-im` 不会从 `~/.open-im/config.json` 读取 CodeBuddy 的登录态。
346
-
347
- **WorkBuddy 无法连接**:重新运行 `open-im init` 登录。Token 可能过期——客户端会尝试自动重连,但如果 refresh token 失效,需要重新登录。
348
-
349
- **WorkBuddy 微信客服收不到消息**:确认在 `open-im init` 中完成了微信客服绑定。可重新运行 init 生成新的绑定链接。
286
+ | 问题 | 解决方案 |
287
+ | ------------------------ | ---------------------------------------------------------------- |
288
+ | Telegram 无响应 | 检查网络,添加 `proxy` 或设置 `TELEGRAM_PROXY` |
289
+ | QQ 无法连接 | 确认机器人已创建,检查 `QQ_BOT_APPID` / `QQ_BOT_SECRET` |
290
+ | QQ 重复回复 | 更新到最新版本 |
291
+ | 飞书卡片报错 | 未配置卡片回调时使用 `/mode ask` 或 `/mode yolo` |
292
+ | 企业微信收不到通知 | 先给机器人发一条消息 |
293
+ | 钉钉无法回复 | 确认 Stream Mode 已启用,检查凭证配置 |
294
+ | 钉钉没有流式更新 | 自定义机器人仅支持纯文本;配置 `cardTemplateId` 启用流式卡片 |
295
+ | Codex `stream disconnected` | 配置 `tools.codex.proxy` 或 `CODEX_PROXY` |
296
+ | CodeBuddy 需要登录 | 先执行 `codebuddy login` |
297
+ | WorkBuddy 无法连接 | 运行 `open-im init` 重新登录,Token 可能已过期 |
298
+ | WorkBuddy 微信收不到消息 | 重新运行 `open-im init` 生成新的微信客服绑定链接 |
350
299
 
351
300
  ## License
352
301
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.9.4-beta.11",
3
+ "version": "1.9.4-beta.12",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, CodeBuddy)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -47,11 +47,11 @@
47
47
  "dependencies": {
48
48
  "@anthropic-ai/claude-agent-sdk": "^0.2.92",
49
49
  "@larksuiteoapi/node-sdk": "^1.59.0",
50
- "centrifuge": "^5.3.0",
50
+ "centrifuge": "^5.5.3",
51
51
  "dingtalk-stream": "^2.1.4",
52
52
  "prompts": "^2.4.2",
53
53
  "telegraf": "^4.16.3",
54
- "ws": "^8.18.0"
54
+ "ws": "^8.20.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@eslint/js": "^9.15.0",
@@ -63,8 +63,8 @@
63
63
  "globals": "^15.12.0",
64
64
  "tsx": "^4.0.0",
65
65
  "typescript": "^5.0.0",
66
- "typescript-eslint": "^8.15.0",
67
- "vitest": "^4.1.0"
66
+ "typescript-eslint": "^8.58.0",
67
+ "vitest": "^4.1.2"
68
68
  },
69
69
  "engines": {
70
70
  "node": ">=20"