@wu529778790/open-im 1.10.2 → 1.10.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +46 -138
  2. package/README.zh-CN.md +41 -127
  3. package/dist/config/types.d.ts +16 -0
  4. package/dist/config-web.js +1 -0
  5. package/dist/config.js +65 -1
  6. package/dist/constants.d.ts +10 -0
  7. package/dist/constants.js +10 -0
  8. package/dist/index.js +23 -8
  9. package/dist/logger.d.ts +15 -2
  10. package/dist/logger.js +99 -5
  11. package/dist/session/session-manager.js +6 -2
  12. package/dist/shared/ai-task.js +38 -3
  13. package/dist/telemetry/hash-user.d.ts +2 -0
  14. package/dist/telemetry/hash-user.js +5 -0
  15. package/dist/telemetry/telemetry-sanitize.d.ts +2 -0
  16. package/dist/telemetry/telemetry-sanitize.js +30 -0
  17. package/dist/telemetry/telemetry-upload.d.ts +8 -0
  18. package/dist/telemetry/telemetry-upload.js +153 -0
  19. package/package.json +1 -1
  20. package/dist/adapters/claude-sdk-adapter.test.d.ts +0 -1
  21. package/dist/adapters/claude-sdk-adapter.test.js +0 -50
  22. package/dist/channels/capabilities.test.d.ts +0 -1
  23. package/dist/channels/capabilities.test.js +0 -27
  24. package/dist/codebuddy/cli-runner.test.d.ts +0 -1
  25. package/dist/codebuddy/cli-runner.test.js +0 -67
  26. package/dist/codex/cli-runner.test.d.ts +0 -1
  27. package/dist/codex/cli-runner.test.js +0 -53
  28. package/dist/commands/normalize-command.test.d.ts +0 -1
  29. package/dist/commands/normalize-command.test.js +0 -17
  30. package/dist/config-web.test.d.ts +0 -1
  31. package/dist/config-web.test.js +0 -57
  32. package/dist/config.test.d.ts +0 -1
  33. package/dist/config.test.js +0 -38
  34. package/dist/dingtalk/client.test.d.ts +0 -1
  35. package/dist/dingtalk/client.test.js +0 -22
  36. package/dist/dingtalk/message-sender.test.d.ts +0 -1
  37. package/dist/dingtalk/message-sender.test.js +0 -136
  38. package/dist/platform/create-event-context.test.d.ts +0 -1
  39. package/dist/platform/create-event-context.test.js +0 -91
  40. package/dist/platform/handle-ai-request.test.d.ts +0 -1
  41. package/dist/platform/handle-ai-request.test.js +0 -349
  42. package/dist/platform/handle-text-flow.test.d.ts +0 -1
  43. package/dist/platform/handle-text-flow.test.js +0 -239
  44. package/dist/qq/message-sender.test.d.ts +0 -1
  45. package/dist/qq/message-sender.test.js +0 -46
  46. package/dist/queue/request-queue.test.d.ts +0 -1
  47. package/dist/queue/request-queue.test.js +0 -82
  48. package/dist/service-control.test.d.ts +0 -1
  49. package/dist/service-control.test.js +0 -47
  50. package/dist/session/session-manager.test.d.ts +0 -1
  51. package/dist/session/session-manager.test.js +0 -106
  52. package/dist/shared/ai-task.test.d.ts +0 -1
  53. package/dist/shared/ai-task.test.js +0 -200
  54. package/dist/shared/media-analysis-prompt.test.d.ts +0 -1
  55. package/dist/shared/media-analysis-prompt.test.js +0 -40
  56. package/dist/shared/media-context.test.d.ts +0 -1
  57. package/dist/shared/media-context.test.js +0 -13
  58. package/dist/shared/media-prompt.test.d.ts +0 -1
  59. package/dist/shared/media-prompt.test.js +0 -26
  60. package/dist/shared/media-storage.test.d.ts +0 -1
  61. package/dist/shared/media-storage.test.js +0 -68
  62. package/dist/shared/message-note.test.d.ts +0 -1
  63. package/dist/shared/message-note.test.js +0 -14
  64. package/dist/shared/message-title.test.d.ts +0 -1
  65. package/dist/shared/message-title.test.js +0 -19
  66. package/dist/shared/system-messages.test.d.ts +0 -1
  67. package/dist/shared/system-messages.test.js +0 -8
  68. package/dist/shared/task-cleanup.test.d.ts +0 -1
  69. package/dist/shared/task-cleanup.test.js +0 -74
  70. package/dist/shared/utils.test.d.ts +0 -1
  71. package/dist/shared/utils.test.js +0 -43
  72. package/dist/wework/event-handler.test.d.ts +0 -1
  73. package/dist/wework/event-handler.test.js +0 -103
  74. package/dist/wework/message-sender.test.d.ts +0 -1
  75. package/dist/wework/message-sender.test.js +0 -33
package/README.md CHANGED
@@ -6,20 +6,15 @@ Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, Ding
6
6
 
7
7
  ## Features
8
8
 
9
- - **Six IM platforms** — run Telegram, Feishu, WeCom, DingTalk, QQ, and WorkBuddy together
10
- - **Three AI backends** — Claude (Agent SDK), Codex, CodeBuddy
11
- - **Per-platform AI routing** — override the default tool per platform
12
- - **Streaming replies** — live AI output where the platform supports it
13
- - **Media** — images, files, voice, and video for analysis (platform-dependent)
14
- - **Session isolation** — per-user state; `/new` resets the AI session
15
- - **Web configuration** — full dashboard **bundled in the npm package** (`web/dist`), served from **`http://127.0.0.1:39282`** (same origin as the API)
16
- - **Chat commands** — `/help`, `/new`, `/sessions`, `/resume`, `/cd`, `/pwd`, `/status`, `/allow`, `/deny`
9
+ - **Six IM platforms** — Telegram, Feishu, WeCom, DingTalk, QQ, WorkBuddy
10
+ - **Three AI backends** — Claude (Agent SDK), Codex, CodeBuddy (per-platform override supported)
11
+ - **Streaming, media, sessions** — live output where supported; `/new` for a fresh AI session
12
+ - **Web UI** — dashboard bundled in the package; default **`http://127.0.0.1:39282`**
17
13
 
18
14
  ## Requirements
19
15
 
20
16
  - Node.js ≥ 20
21
- - At least one IM platform configured
22
- - Credentials for the AI tool you use
17
+ - At least one IM platform configured + credentials for your AI tool
23
18
 
24
19
  ## Quick start
25
20
 
@@ -27,118 +22,62 @@ Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, Ding
27
22
  npx @wu529778790/open-im start
28
23
  ```
29
24
 
30
- Or install globally:
25
+ Or: `npm install -g @wu529778790/open-im` then `open-im start`.
31
26
 
32
- ```bash
33
- npm install -g @wu529778790/open-im
34
- open-im start
35
- ```
36
-
37
- Configuration file: `~/.open-im/config.json`
27
+ Config: **`~/.open-im/config.json`**
38
28
 
39
29
  ## CLI
40
30
 
41
31
  | Command | Description |
42
32
  | --- | --- |
43
- | `open-im init` | Interactive setup without starting the bridge |
33
+ | `open-im init` | Interactive setup (does not start the bridge) |
44
34
  | `open-im start` | Run the bridge in the background |
45
35
  | `open-im stop` | Stop the background bridge |
46
36
  | `open-im restart` | Stop then start |
47
- | `open-im dev` | Foreground mode for debugging |
48
- | `open-im dashboard` | Keep only the local config HTTP server (no bridge) |
49
-
50
- After `start`, the CLI prints the **web dashboard** URL (`http://127.0.0.1:39282` by default, same as the API base).
51
-
52
- ## Web configuration
53
-
54
- ### Bundled dashboard (full UI)
55
-
56
- The published npm package includes **`web/dist`**. `open-im start` or `open-im dashboard` serves the **full SPA** (overview, platforms, AI, JSON, service controls) from the local HTTP server. Open **`http://127.0.0.1:<port>`** (default **39282**) in your browser; the page is **same-origin** with the API, so you usually do not need to paste a Server URL.
37
+ | `open-im dashboard` | Web config server only (no bridge) |
57
38
 
58
- - Default dashboard URL: **`http://127.0.0.1:39282`** (respects **`OPEN_IM_WEB_PORT`**)
59
- - Override the URL shown/opened by the CLI with **`OPEN_IM_PUBLIC_WEB_URL`** (e.g. behind a reverse proxy)
39
+ After `start`, the CLI prints the dashboard URL (default **`http://127.0.0.1:39282`**).
60
40
 
61
- If you install from source without running **`npm run build`** (which runs `web:build` + `tsc`), `web/dist` may be missing and **`GET /`** returns **503** until you build. Use **`npm run build:ts`** for TypeScript-only iteration (skips the web bundle).
41
+ ## Web dashboard
62
42
 
63
- ### Local HTTP service
43
+ `open-im start` and `open-im dashboard` serve the built-in SPA and **`/api/*`** on **`OPEN_IM_WEB_PORT`** (default **39282**). Open **`http://127.0.0.1:39282`** in a browser (same origin as the API). Override the displayed URL with **`OPEN_IM_PUBLIC_WEB_URL`** if behind a proxy.
64
44
 
65
- The running process listens on **`OPEN_IM_WEB_PORT`** (default **39282**):
66
-
67
- - **`GET /`** — built-in dashboard when `web/dist` is present; otherwise **503** with a short plain-text hint
68
- - **`/assets/*`** — static assets for the bundled SPA (when present)
69
- - **`/api/*`** — JSON API used by the dashboard
70
-
71
- ### Remote access
72
-
73
- For access from another host or from an HTTPS-hosted page:
74
-
75
- ```bash
76
- export OPEN_IM_WEB_HOST=0.0.0.0
77
- # Optional: skip cookie login on trusted networks (see security implications in docs)
78
- # export OPEN_IM_ALLOW_REMOTE_API=true
79
- # Optional: restrict CORS origins (comma-separated)
80
- # export OPEN_IM_CORS_ORIGINS=http://127.0.0.1:39282
81
- ```
45
+ **Remote / LAN:** `export OPEN_IM_WEB_HOST=0.0.0.0` first access from another host may show a one-time login link. Optional: **`OPEN_IM_ALLOW_REMOTE_API`**, **`OPEN_IM_CORS_ORIGINS`**.
82
46
 
83
- If the server is not bound to `127.0.0.1`, it may print a **one-time login URL** (`login_token=…`) for first-time browser access.
84
-
85
- ### Developing the web UI (from source)
86
-
87
- In the repository:
88
-
89
- ```bash
90
- npm run web:dev # Vite dev server; proxies /api to 127.0.0.1:39282
91
- npm run build # web:build + tsc (use before running the compiled CLI with dashboard)
92
- npm run build:ts # tsc only (no web/dist refresh)
93
- npm run web:build # web/dist only
94
- ```
95
-
96
- More detail: [CLAUDE.md](./CLAUDE.md), [AGENTS.md](./AGENTS.md).
97
-
98
- ## IM commands
47
+ ## Chat commands
99
48
 
100
49
  | Command | Description |
101
50
  | --- | --- |
102
51
  | `/help` | Help |
103
52
  | `/new` | New AI session |
104
- | `/sessions` | List session history |
105
- | `/resume <N>` | Resume a previous session by number |
106
- | `/status` | AI tool and session info |
107
- | `/cd <path>` | Change session working directory |
108
- | `/pwd` | Print working directory |
109
- | `/allow` / `/y` | Approve a permission request |
110
- | `/deny` / `/n` | Reject a permission request |
111
-
112
- ## Sessions
53
+ | `/sessions` | Session history |
54
+ | `/resume <N>` | Resume by list number |
55
+ | `/status` | AI + session info |
56
+ | `/cd` / `/pwd` | Working directory |
57
+ | `/allow` / `/y`, `/deny` / `/n` | Permission prompts |
113
58
 
114
- Sessions are stored in `~/.open-im/data/sessions.json`, separate from IM chat history. Each user has an isolated session. `/new` starts a fresh session and archives the old one. Use `/sessions` to view history and `/resume <N>` to switch back to a previous session.
59
+ Session state is stored in **`~/.open-im/data/sessions.json`** (per user, not IM chat logs).
115
60
 
116
61
  ## Configuration
117
62
 
118
- ### Per-platform AI tool
63
+ ### Per-platform AI
119
64
 
120
- Default: root `aiCommand`. Override per platform with `platforms.<name>.aiCommand`:
65
+ Default: root **`aiCommand`**. Override with **`platforms.<name>.aiCommand`**:
121
66
 
122
67
  ```json
123
68
  {
124
69
  "aiCommand": "claude",
125
70
  "platforms": {
126
- "telegram": { "enabled": true, "aiCommand": "codex" },
127
- "feishu": { "enabled": true, "aiCommand": "codex" },
128
- "qq": { "enabled": true, "aiCommand": "codebuddy" }
71
+ "telegram": { "enabled": true, "aiCommand": "codex" }
129
72
  }
130
73
  }
131
74
  ```
132
75
 
133
76
  ### Claude (Agent SDK)
134
77
 
135
- Uses the Agent SDK by default (no local `claude` binary required). Credentials load order:
136
-
137
- 1. Environment variables
138
- 2. `env` in `~/.open-im/config.json`
139
- 3. `~/.claude/settings.json` or `~/.claude.json`
78
+ No local `claude` binary required. Credentials: env → **`config.json`** `env` → **`~/.claude/settings.json`**.
140
79
 
141
- Third-party compatible endpoints:
80
+ Third-party / compatible API example:
142
81
 
143
82
  ```json
144
83
  {
@@ -150,8 +89,6 @@ Third-party compatible endpoints:
150
89
  }
151
90
  ```
152
91
 
153
- Claude inherits plugins and settings from `~/.claude/settings.json` when present.
154
-
155
92
  ### CodeBuddy
156
93
 
157
94
  ```bash
@@ -159,82 +96,53 @@ npm install -g @tencent-ai/codebuddy-code
159
96
  codebuddy login
160
97
  ```
161
98
 
162
- Useful keys: `tools.codebuddy.cliPath`, `tools.codebuddy.skipPermissions`, `tools.codebuddy.timeoutMs`. On Windows, `codebuddy` may resolve to `%AppData%\Roaming\npm\codebuddy.cmd`.
163
-
164
- ### Example `config.json`
99
+ ### Minimal `config.json` shape
165
100
 
166
101
  ```json
167
102
  {
168
103
  "aiCommand": "claude",
169
104
  "tools": {
170
- "claude": {
171
- "workDir": "/path/to/project",
172
- "skipPermissions": true,
173
- "timeoutMs": 600000
174
- },
175
- "codex": {
176
- "workDir": "/path/to/project",
177
- "skipPermissions": true,
178
- "proxy": "http://127.0.0.1:7890"
179
- },
180
- "codebuddy": {
181
- "skipPermissions": true,
182
- "timeoutMs": 600000
183
- }
105
+ "claude": { "workDir": "/path/to/project", "skipPermissions": true, "timeoutMs": 600000 }
184
106
  },
185
107
  "platforms": {
186
- "telegram": { "enabled": true, "botToken": "YOUR_TELEGRAM_BOT_TOKEN" },
187
- "feishu": { "enabled": false, "appId": "YOUR_FEISHU_APP_ID", "appSecret": "YOUR_FEISHU_APP_SECRET" },
188
- "qq": { "enabled": false, "appId": "YOUR_QQ_APP_ID", "secret": "YOUR_QQ_APP_SECRET" },
189
- "wework": { "enabled": false, "corpId": "YOUR_WEWORK_CORP_ID", "secret": "YOUR_WEWORK_SECRET" },
190
- "dingtalk": {
191
- "enabled": false,
192
- "clientId": "YOUR_DINGTALK_CLIENT_ID",
193
- "clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
194
- "cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
195
- },
196
- "workbuddy": { "enabled": false, "accessToken": "", "refreshToken": "", "userId": "" }
108
+ "telegram": { "enabled": true, "botToken": "YOUR_TELEGRAM_BOT_TOKEN" }
197
109
  }
198
110
  }
199
111
  ```
200
112
 
201
- WorkBuddy (WeChat) is easiest via `open-im init` or by editing `~/.open-im/config.json`.
113
+ Add Feishu, QQ, WeCom, DingTalk, WorkBuddy under **`platforms`** as needed. Run **`open-im init`** for a full template. WeChat (WorkBuddy) is easiest via **`open-im init`**.
202
114
 
203
115
  ### Environment variables
204
116
 
205
- **General:** `AI_COMMAND`, `CLAUDE_WORK_DIR`, `LOG_DIR`, `LOG_LEVEL`, `HOOK_PORT`, `OPEN_IM_WEB_PORT`, `OPEN_IM_WEB_HOST`, `OPEN_IM_PUBLIC_WEB_URL`, `OPEN_IM_NO_BROWSER`, `OPEN_IM_ALLOW_REMOTE_API`, `OPEN_IM_CORS_ORIGINS`
117
+ Use **`config.json`** or environment variables; the dashboard exposes common options. Typical keys: **`ANTHROPIC_*`**, **`TELEGRAM_BOT_TOKEN`**, **`OPEN_IM_WEB_PORT`**, **`OPEN_IM_WEB_HOST`**, plus platform-specific `*_APP_ID`, `*_SECRET`, `WORKBUDDY_*`, etc.
206
118
 
207
- **AI:** `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, `ANTHROPIC_MODEL`, `OPENAI_API_KEY`, `CODEX_PROXY`, `CODEBUDDY_CLI_PATH`, `CODEBUDDY_TIMEOUT_MS`, `CODEBUDDY_API_KEY`, `CODEBUDDY_AUTH_TOKEN`
119
+ ### Privacy
208
120
 
209
- **Platforms:** `TELEGRAM_BOT_TOKEN`, `TELEGRAM_PROXY`, `TELEGRAM_ALLOWED_USER_IDS`, `FEISHU_APP_ID`, `FEISHU_APP_SECRET`, `FEISHU_ALLOWED_USER_IDS`, `QQ_BOT_APPID`, `QQ_BOT_SECRET`, `QQ_BOT_SANDBOX`, `QQ_ALLOWED_USER_IDS`, `DINGTALK_CLIENT_ID`, `DINGTALK_CLIENT_SECRET`, `DINGTALK_CARD_TEMPLATE_ID`, `DINGTALK_ALLOWED_USER_IDS`, `WEWORK_CORP_ID`, `WEWORK_SECRET`, `WEWORK_WS_URL`, `WEWORK_ALLOWED_USER_IDS`, `WORKBUDDY_ACCESS_TOKEN`, `WORKBUDDY_REFRESH_TOKEN`, `WORKBUDDY_USER_ID`, `WORKBUDDY_BASE_URL`, `WORKBUDDY_ALLOWED_USER_IDS`
121
+ **Anonymous** usage information may be collected to improve reliability (no chat or prompt content). To disable: **`OPEN_IM_TELEMETRY=false`** or **`"telemetry": { "enabled": false }`** in **`config.json`**.
210
122
 
211
- ### Platform setup
123
+ ### Platform credentials
212
124
 
213
- | Platform | Where to get credentials |
125
+ | Platform | Notes |
214
126
  | --- | --- |
215
127
  | Telegram | [@BotFather](https://t.me/BotFather) |
216
- | Feishu | [Feishu Open Platform](https://open.feishu.cn/) |
128
+ | Feishu | [Open Platform](https://open.feishu.cn/) |
217
129
  | QQ | [QQ Open Platform](https://bot.q.qq.com/) |
218
- | DingTalk | DingTalk Open Platform — enable bot **Stream Mode** |
219
- | WeCom | [WeCom admin](https://work.weixin.qq.com/) |
220
- | WeChat | `open-im init` → WorkBuddy OAuth |
221
-
222
- **DingTalk:** Stream Mode (receive) + OpenAPI (send). With `cardTemplateId`, AI assistant streaming cards are used when possible; otherwise plain text. Custom bots and normal groups may only get single text replies. Startup/shutdown notices are not sent to DingTalk.
130
+ | DingTalk | Open Platform — bot **Stream Mode**; optional **`cardTemplateId`** for AI assistant cards |
131
+ | WeCom | [Admin](https://work.weixin.qq.com/) |
132
+ | WeChat | **`open-im init`** → WorkBuddy OAuth |
223
133
 
224
134
  ## Troubleshooting
225
135
 
226
136
  | Issue | What to try |
227
137
  | --- | --- |
228
- | Telegram not responding | Check network; set `proxy` / `TELEGRAM_PROXY` |
229
- | QQ cannot connect | Verify bot and `QQ_BOT_APPID` / `QQ_BOT_SECRET` |
230
- | QQ duplicate replies | Upgrade to the latest version |
231
- | Feishu card errors | Use `/mode ask` or `/mode yolo` without card callbacks |
232
- | WeCom no notifications | Send at least one message to the bot first |
233
- | DingTalk cannot reply | Enable Stream Mode; verify credentials |
234
- | DingTalk no streaming | Custom bots: plain text only; set `cardTemplateId` for AI assistant cards |
235
- | Codex `stream disconnected` | Set `tools.codex.proxy` or `CODEX_PROXY` |
236
- | CodeBuddy asks for login | Run `codebuddy login` |
237
- | WorkBuddy / WeChat | Re-run `open-im init`; tokens and binding links expire |
138
+ | Telegram / network | `proxy` or **`TELEGRAM_PROXY`** |
139
+ | QQ | Check **`QQ_BOT_APPID`** / **`QQ_BOT_SECRET`**; update if duplicate replies |
140
+ | Feishu cards | **`/mode ask`** or **`/mode yolo`** without card callbacks |
141
+ | WeCom | Send the bot a message first |
142
+ | DingTalk | Stream Mode + credentials; custom bots may be text-only |
143
+ | Codex disconnect | **`CODEX_PROXY`** or **`tools.codex.proxy`** |
144
+ | CodeBuddy login | **`codebuddy login`** |
145
+ | WorkBuddy | Re-run **`open-im init`** (tokens expire) |
238
146
 
239
147
  ## License
240
148
 
package/README.zh-CN.md CHANGED
@@ -6,20 +6,15 @@
6
6
 
7
7
  ## 功能特性
8
8
 
9
- - **六个 IM 平台** — 可同时启用多平台
10
- - **三种 AI 后端** — Claude(Agent SDK)、Codex、CodeBuddy
11
- - **按平台指定 AI** 覆盖默认 `aiCommand`
12
- - **流式输出**视平台能力实时回传
13
- - **多媒体** — 图片、文件、语音、视频(因平台而异)
14
- - **会话隔离** — 每用户独立;`/new` 重置会话
15
- - **Web 配置** — 完整仪表盘 **随 npm 包内置**(`web/dist`),由本机 `http://127.0.0.1:39282` **同源**提供
16
- - **聊天命令** — `/help`、`/new`、`/sessions`、`/resume`、`/cd`、`/pwd`、`/status`、`/allow`、`/deny`
9
+ - **六个 IM 平台** — Telegram、飞书、企业微信、钉钉、QQ、WorkBuddy
10
+ - **三种 AI 后端** — Claude(Agent SDK)、Codex、CodeBuddy(可按平台覆盖)
11
+ - **流式、多媒体、会话**视平台能力;`/new` 开启新 AI 会话
12
+ - **Web 控制台** 随包内置,默认 **`http://127.0.0.1:39282`**
17
13
 
18
14
  ## 环境要求
19
15
 
20
16
  - Node.js ≥ 20
21
- - 至少配置一个 IM 平台
22
- - 所选 AI 工具所需的凭证
17
+ - 至少配置一个 IM 平台 + 所选 AI 的凭证
23
18
 
24
19
  ## 快速开始
25
20
 
@@ -27,71 +22,27 @@
27
22
  npx @wu529778790/open-im start
28
23
  ```
29
24
 
30
- 或全局安装:
25
+ 或:`npm install -g @wu529778790/open-im` 后执行 `open-im start`。
31
26
 
32
- ```bash
33
- npm install -g @wu529778790/open-im
34
- open-im start
35
- ```
36
-
37
- 配置文件:`~/.open-im/config.json`
27
+ 配置:**`~/.open-im/config.json`**
38
28
 
39
29
  ## CLI 命令
40
30
 
41
31
  | 命令 | 说明 |
42
32
  | --- | --- |
43
- | `open-im init` | 交互配置,不启动桥接 |
33
+ | `open-im init` | 交互配置(不启动桥接) |
44
34
  | `open-im start` | 后台运行桥接 |
45
35
  | `open-im stop` | 停止后台服务 |
46
36
  | `open-im restart` | 重启 |
47
- | `open-im dev` | 前台调试 |
48
- | `open-im dashboard` | 仅保留本地配置 HTTP 服务(不启动桥接) |
49
-
50
- 执行 `start` 后,终端会提示 **Web 控制台** 地址(默认 **`http://127.0.0.1:39282`**,与 API 同源)。
51
-
52
- ## Web 配置
53
-
54
- ### 内置仪表盘(完整 UI)
37
+ | `open-im dashboard` | Web 配置服务(不启动桥接) |
55
38
 
56
- 发布到 npm 的包内含 **`web/dist`** 构建产物;`open-im start` `open-im dashboard` 在本机 HTTP 服务上提供 **完整 SPA**(概览、平台、AI、JSON、服务启停等)。浏览器打开 **`http://127.0.0.1:<端口>`**(默认端口 **39282**)即可,**Server URL** 与页面同源,一般无需再填。
39
+ `start` 后会提示控制台地址(默认 **`http://127.0.0.1:39282`**)。
57
40
 
58
- - 默认控制台地址:本机 **`http://127.0.0.1:39282`**(随 **`OPEN_IM_WEB_PORT`** 变化)
59
- - 若需自定义打开的链接(例如反向代理后的地址),可设置 **`OPEN_IM_PUBLIC_WEB_URL`**
41
+ ## Web 控制台
60
42
 
61
- 若从源码安装且未执行 **`npm run build`**(内含 `web:build`),可能没有 `web/dist`,此时 **`GET /`** 会返回 **503** 直至构建完成。仅改 TypeScript 时可使用 **`npm run build:ts`** 跳过前端构建。
43
+ `open-im start` / `open-im dashboard` **`OPEN_IM_WEB_PORT`**(默认 **39282**)提供内置页面与 **`/api/*`**。浏览器打开 **`http://127.0.0.1:39282`** 即可(与 API 同源)。反向代理时可设 **`OPEN_IM_PUBLIC_WEB_URL`**。
62
44
 
63
- ### 本机 HTTP 服务
64
-
65
- 进程监听 **`OPEN_IM_WEB_PORT`**(默认 **39282**):
66
-
67
- - **`GET /`** — 有 `web/dist` 时返回内置仪表盘;否则 **503** 纯文本提示
68
- - **`/assets/*`** — 内置前端静态资源(有构建产物时)
69
- - **`/api/*`** — JSON API
70
-
71
- ### 远程访问
72
-
73
- 从其他机器或 HTTPS 页面访问时:
74
-
75
- ```bash
76
- export OPEN_IM_WEB_HOST=0.0.0.0
77
- # 可选:受信网络跳过 Cookie 登录(请自行评估风险)
78
- # export OPEN_IM_ALLOW_REMOTE_API=true
79
- # 可选:限制 CORS 来源(逗号分隔)
80
- # export OPEN_IM_CORS_ORIGINS=http://127.0.0.1:39282
81
- ```
82
-
83
- 未绑定 `127.0.0.1` 时,服务端可能打印 **一次性登录链接**(`login_token=…`)。
84
-
85
- ### 开发 Web 前端(源码仓库)
86
-
87
- ```bash
88
- npm run web:dev # Vite;将 /api 代理到 127.0.0.1:39282
89
- npm run build # web:build + tsc;发布前与日常请用此命令
90
- npm run build:ts # 仅 tsc(不更新 web/dist)
91
- npm run web:build # 仅构建 web/dist
92
- ```
93
-
94
- 更多开发说明见 [CLAUDE.md](./CLAUDE.md)、[AGENTS.md](./AGENTS.md)。
45
+ **局域网 / 远程:** `export OPEN_IM_WEB_HOST=0.0.0.0` — 首次外网访问可能需一次性登录链接。可选 **`OPEN_IM_ALLOW_REMOTE_API`**、**`OPEN_IM_CORS_ORIGINS`**。
95
46
 
96
47
  ## IM 内命令
97
48
 
@@ -99,38 +50,32 @@ npm run web:build # 仅构建 web/dist
99
50
  | --- | --- |
100
51
  | `/help` | 帮助 |
101
52
  | `/new` | 新 AI 会话 |
102
- | `/sessions` | 查看历史会话 |
103
- | `/resume <序号>` | 恢复历史会话 |
53
+ | `/sessions` | 历史会话 |
54
+ | `/resume <序号>` | 按列表序号恢复 |
104
55
  | `/status` | AI 与会话信息 |
105
- | `/cd <路径>` | 切换工作目录 |
106
- | `/pwd` | 当前目录 |
107
- | `/allow` / `/y` | 同意权限请求 |
108
- | `/deny` / `/n` | 拒绝权限请求 |
109
-
110
- ## 会话说明
56
+ | `/cd` / `/pwd` | 工作目录 |
57
+ | `/allow` / `/y`、`/deny` / `/n` | 权限确认 |
111
58
 
112
- 会话保存在 `~/.open-im/data/sessions.json`,与 IM 聊天记录无关。`/new` 创建新会话并归档旧会话。使用 `/sessions` 查看历史,`/resume <序号>` 恢复之前的会话。
59
+ 会话状态保存在 **`~/.open-im/data/sessions.json`**(按用户,与 IM 聊天记录无关)。
113
60
 
114
61
  ## 配置说明
115
62
 
116
- ### 按平台分配 AI
63
+ ### 按平台指定 AI
117
64
 
118
- 根级 `aiCommand` 为默认;用 `platforms.<name>.aiCommand` 覆盖:
65
+ 根级 **`aiCommand`** 为默认;用 **`platforms.<name>.aiCommand`** 覆盖:
119
66
 
120
67
  ```json
121
68
  {
122
69
  "aiCommand": "claude",
123
70
  "platforms": {
124
- "telegram": { "enabled": true, "aiCommand": "codex" },
125
- "feishu": { "enabled": true, "aiCommand": "codex" },
126
- "qq": { "enabled": true, "aiCommand": "codebuddy" }
71
+ "telegram": { "enabled": true, "aiCommand": "codex" }
127
72
  }
128
73
  }
129
74
  ```
130
75
 
131
76
  ### Claude(Agent SDK)
132
77
 
133
- 默认使用 Agent SDK,无需本地 `claude` 可执行文件。凭证顺序:环境变量 → `config.json``env``~/.claude/settings.json` / `~/.claude.json`。
78
+ 无需本地 `claude` 可执行文件。凭证顺序:环境变量 → **`config.json`****`env`****`~/.claude/settings.json`**。
134
79
 
135
80
  第三方兼容接口示例:
136
81
 
@@ -144,8 +89,6 @@ npm run web:build # 仅构建 web/dist
144
89
  }
145
90
  ```
146
91
 
147
- 会继承 `~/.claude/settings.json` 中的插件等配置。
148
-
149
92
  ### CodeBuddy
150
93
 
151
94
  ```bash
@@ -153,82 +96,53 @@ npm install -g @tencent-ai/codebuddy-code
153
96
  codebuddy login
154
97
  ```
155
98
 
156
- 常用项:`tools.codebuddy.cliPath`、`skipPermissions`、`timeoutMs`。Windows 下可能解析到 `%AppData%\Roaming\npm\codebuddy.cmd`。
157
-
158
- ### 配置示例
99
+ ### 最小配置结构
159
100
 
160
101
  ```json
161
102
  {
162
103
  "aiCommand": "claude",
163
104
  "tools": {
164
- "claude": {
165
- "workDir": "/path/to/project",
166
- "skipPermissions": true,
167
- "timeoutMs": 600000
168
- },
169
- "codex": {
170
- "workDir": "/path/to/project",
171
- "skipPermissions": true,
172
- "proxy": "http://127.0.0.1:7890"
173
- },
174
- "codebuddy": {
175
- "skipPermissions": true,
176
- "timeoutMs": 600000
177
- }
105
+ "claude": { "workDir": "/path/to/project", "skipPermissions": true, "timeoutMs": 600000 }
178
106
  },
179
107
  "platforms": {
180
- "telegram": { "enabled": true, "botToken": "YOUR_TELEGRAM_BOT_TOKEN" },
181
- "feishu": { "enabled": false, "appId": "YOUR_FEISHU_APP_ID", "appSecret": "YOUR_FEISHU_APP_SECRET" },
182
- "qq": { "enabled": false, "appId": "YOUR_QQ_APP_ID", "secret": "YOUR_QQ_APP_SECRET" },
183
- "wework": { "enabled": false, "corpId": "YOUR_WEWORK_CORP_ID", "secret": "YOUR_WEWORK_SECRET" },
184
- "dingtalk": {
185
- "enabled": false,
186
- "clientId": "YOUR_DINGTALK_CLIENT_ID",
187
- "clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
188
- "cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
189
- },
190
- "workbuddy": { "enabled": false, "accessToken": "", "refreshToken": "", "userId": "" }
108
+ "telegram": { "enabled": true, "botToken": "YOUR_TELEGRAM_BOT_TOKEN" }
191
109
  }
192
110
  }
193
111
  ```
194
112
 
195
- 微信(WorkBuddy)建议用 `open-im init` 或直接编辑 `~/.open-im/config.json`。
113
+ 在 **`platforms`** 下按需补充飞书、QQ、企业微信、钉钉、WorkBuddy。完整模板请用 **`open-im init`**。微信建议 **`open-im init`** 走 WorkBuddy OAuth。
196
114
 
197
115
  ### 环境变量
198
116
 
199
- **通用:** `AI_COMMAND`、`CLAUDE_WORK_DIR`、`LOG_DIR`、`LOG_LEVEL`、`HOOK_PORT`、`OPEN_IM_WEB_PORT`、`OPEN_IM_WEB_HOST`、`OPEN_IM_PUBLIC_WEB_URL`、`OPEN_IM_NO_BROWSER`、`OPEN_IM_ALLOW_REMOTE_API`、`OPEN_IM_CORS_ORIGINS`
117
+ 可在 **`config.json`** 或环境变量中设置;控制台会展示常用项。常见:**`ANTHROPIC_*`**、**`TELEGRAM_BOT_TOKEN`**、**`OPEN_IM_WEB_PORT`**、**`OPEN_IM_WEB_HOST`**,以及各平台的 `*_APP_ID`、`*_SECRET`、`WORKBUDDY_*` 等。
200
118
 
201
- **AI:** `ANTHROPIC_API_KEY`、`ANTHROPIC_AUTH_TOKEN`、`ANTHROPIC_BASE_URL`、`ANTHROPIC_MODEL`、`OPENAI_API_KEY`、`CODEX_PROXY`、`CODEBUDDY_CLI_PATH`、`CODEBUDDY_TIMEOUT_MS`、`CODEBUDDY_API_KEY`、`CODEBUDDY_AUTH_TOKEN`
119
+ ### 隐私
202
120
 
203
- **平台:** `TELEGRAM_BOT_TOKEN`、`TELEGRAM_PROXY`、`TELEGRAM_ALLOWED_USER_IDS`、`FEISHU_APP_ID`、`FEISHU_APP_SECRET`、`FEISHU_ALLOWED_USER_IDS`、`QQ_BOT_APPID`、`QQ_BOT_SECRET`、`QQ_BOT_SANDBOX`、`QQ_ALLOWED_USER_IDS`、`DINGTALK_CLIENT_ID`、`DINGTALK_CLIENT_SECRET`、`DINGTALK_CARD_TEMPLATE_ID`、`DINGTALK_ALLOWED_USER_IDS`、`WEWORK_CORP_ID`、`WEWORK_SECRET`、`WEWORK_WS_URL`、`WEWORK_ALLOWED_USER_IDS`、`WORKBUDDY_ACCESS_TOKEN`、`WORKBUDDY_REFRESH_TOKEN`、`WORKBUDDY_USER_ID`、`WORKBUDDY_BASE_URL`、`WORKBUDDY_ALLOWED_USER_IDS`
121
+ 为改进稳定性,可能记录**匿名**运行信息(不含聊天或 prompt 内容)。若需关闭:环境变量 **`OPEN_IM_TELEMETRY=false`**,或 **`config.json`** 中 **`"telemetry": { "enabled": false }`**。
204
122
 
205
- ### 平台凭证来源
123
+ ### 平台凭证
206
124
 
207
125
  | 平台 | 说明 |
208
126
  | --- | --- |
209
127
  | Telegram | [@BotFather](https://t.me/BotFather) |
210
- | 飞书 | [飞书开放平台](https://open.feishu.cn/) |
128
+ | 飞书 | [开放平台](https://open.feishu.cn/) |
211
129
  | QQ | [QQ 开放平台](https://bot.q.qq.com/) |
212
- | 钉钉 | 开放平台创建应用,启用机器人 **Stream Mode** |
130
+ | 钉钉 | 开放平台创建应用,机器人开 **Stream Mode**;可选 **`cardTemplateId`** 走 AI 助理卡片 |
213
131
  | 企业微信 | [管理后台](https://work.weixin.qq.com/) |
214
- | 微信 | `open-im init` 选择 WorkBuddy 完成 OAuth |
215
-
216
- **钉钉:** Stream 收消息 + OpenAPI 发消息;配置 `cardTemplateId` 可用 AI 助理流式卡片,失败则回退纯文本;自定义机器人与普通群可能仅支持单条文本;启停通知不会发到钉钉。
132
+ | 微信 | **`open-im init`** WorkBuddy OAuth |
217
133
 
218
134
  ## 故障排除
219
135
 
220
136
  | 现象 | 处理 |
221
137
  | --- | --- |
222
- | Telegram 无响应 | 检查网络;配置 `proxy` / `TELEGRAM_PROXY` |
223
- | QQ 连不上 | 核对机器人与 `QQ_BOT_APPID`、`QQ_BOT_SECRET` |
224
- | QQ 重复回复 | 升级到最新版 |
225
- | 飞书卡片报错 | 未配回调时用 `/mode ask` 或 `/mode yolo` |
226
- | 企业微信无通知 | 先给机器人发一条消息 |
227
- | 钉钉无法回复 | 开启 Stream Mode;核对凭证 |
228
- | 钉钉无流式 | 自定义机器人多为纯文本;配 `cardTemplateId` 走 AI 助理卡片 |
229
- | Codex `stream disconnected` | 配置 `tools.codex.proxy` `CODEX_PROXY` |
230
- | CodeBuddy 要登录 | 先 `codebuddy login` |
231
- | WorkBuddy / 微信 | 重跑 `open-im init`;Token 与绑定链接会过期 |
138
+ | Telegram / 网络 | 配置 `proxy` **`TELEGRAM_PROXY`** |
139
+ | QQ | 核对 **`QQ_BOT_APPID`**、**`QQ_BOT_SECRET`**;重复回复请升级版本 |
140
+ | 飞书卡片 | 未配回调时用 **`/mode ask`** 或 **`/mode yolo`** |
141
+ | 企业微信 | 先给机器人发一条消息 |
142
+ | 钉钉 | 开启 Stream Mode;自定义机器人可能仅纯文本 |
143
+ | Codex 断流 | **`CODEX_PROXY`** **`tools.codex.proxy`** |
144
+ | CodeBuddy 登录 | **`codebuddy login`** |
145
+ | WorkBuddy / 微信 | 重跑 **`open-im init`**(Token 会过期) |
232
146
 
233
147
  ## License
234
148
 
@@ -38,6 +38,17 @@ export interface Config {
38
38
  skipPermissions?: boolean;
39
39
  logDir: string;
40
40
  logLevel: LogLevel;
41
+ /**
42
+ * 遥测:默认开启;关闭后不写入结构化事件、不上传。
43
+ * 环境变量:OPEN_IM_TELEMETRY、OPEN_IM_TELEMETRY_URL、OPEN_IM_TELEMETRY_TOKEN。
44
+ */
45
+ telemetry: {
46
+ enabled: boolean;
47
+ /** HTTPS 采集端完整 URL(如 https://example.com/v1/ingest) */
48
+ url?: string;
49
+ /** 可选 Bearer,与采集端一致 */
50
+ token?: string;
51
+ };
41
52
  platforms: {
42
53
  telegram?: {
43
54
  enabled: boolean;
@@ -180,4 +191,9 @@ export interface FileConfig {
180
191
  };
181
192
  logDir?: string;
182
193
  logLevel?: LogLevel;
194
+ telemetry?: {
195
+ enabled?: boolean;
196
+ url?: string;
197
+ token?: string;
198
+ };
183
199
  }
@@ -461,6 +461,7 @@ function createProbeConfig(values) {
461
461
  claudeSessionIdleTtlMinutes: 30,
462
462
  logDir: "",
463
463
  logLevel: "INFO",
464
+ telemetry: { enabled: true },
464
465
  codebuddyCliPath: "codebuddy",
465
466
  platforms: {},
466
467
  ...values,