@wu529778790/open-im 1.10.2-beta.2 → 1.10.2-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,27 +1,27 @@
1
1
  # open-im
2
2
 
3
- [中文文档](./README.zh-CN.md)
3
+ **English** · [中文](./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 — use your AI coding assistant from any phone or chat window.
5
+ Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat (WorkBuddy) 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
- - **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`
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`
17
17
 
18
18
  ## Requirements
19
19
 
20
- - Node.js >= 20
20
+ - Node.js 20
21
21
  - At least one IM platform configured
22
- - Authentication for the AI tool you want to use
22
+ - Credentials for the AI tool you use
23
23
 
24
- ## Quick Start
24
+ ## Quick start
25
25
 
26
26
  ```bash
27
27
  npx @wu529778790/open-im start
@@ -34,95 +34,109 @@ npm install -g @wu529778790/open-im
34
34
  open-im start
35
35
  ```
36
36
 
37
- Config file: `~/.open-im/config.json`
37
+ Configuration file: `~/.open-im/config.json`
38
38
 
39
- ## CLI Commands
39
+ ## CLI
40
40
 
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) |
41
+ | Command | Description |
42
+ | --- | --- |
43
+ | `open-im init` | Interactive setup without starting the bridge |
44
+ | `open-im start` | Run the bridge in the background |
45
+ | `open-im stop` | Stop the background bridge |
46
+ | `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) |
48
49
 
49
- ## Web Configuration
50
+ After `start`, the CLI prints the **web dashboard** URL (`http://127.0.0.1:39282` by default, same as the API base).
50
51
 
51
- ### Local
52
+ ## Web configuration
52
53
 
53
- Open [`http://127.0.0.1:39282`](http://127.0.0.1:39282) after starting. The dashboard includes:
54
+ ### Bundled dashboard (full UI)
54
55
 
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
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.
59
57
 
60
- > WorkBuddy (WeChat) is configured via `open-im init` or directly in `~/.open-im/config.json`.
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)
61
60
 
62
- ### Remote Server
61
+ If you install from source without running `npm run web:build`, `web/dist` may be missing and **`GET /`** falls back to a minimal landing page only.
62
+
63
+ ### Local HTTP service
64
+
65
+ The running process listens on **`OPEN_IM_WEB_PORT`** (default **39282**):
66
+
67
+ - **`GET /`** — built-in dashboard when `web/dist` is present; otherwise a minimal landing page
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:
63
74
 
64
75
  ```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
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
69
81
  ```
70
82
 
71
- If `OPEN_IM_WEB_HOST=0.0.0.0`, the server prints a one-time login URL:
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.
72
84
 
73
- ```
74
- http://your-server-ip:39282/?login_token=xxxx
75
- ```
85
+ ### Developing the web UI (from source)
76
86
 
77
- Complete setup in the browser, then start the bridge:
87
+ In the repository:
78
88
 
79
89
  ```bash
80
- open-im start
90
+ npm run web:dev # Vite dev server; proxies /api to 127.0.0.1:39282
91
+ npm run web:build # Production build → web/dist (included in `npm publish` via `files`)
81
92
  ```
82
93
 
83
- ## IM Commands
94
+ More detail: [CLAUDE.md](./CLAUDE.md), [AGENTS.md](./AGENTS.md).
95
+
96
+ ## IM commands
84
97
 
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 |
98
+ | Command | Description |
99
+ | --- | --- |
100
+ | `/help` | Help |
101
+ | `/new` | New AI session |
102
+ | `/sessions` | List session history |
103
+ | `/resume <N>` | Resume a previous session by number |
104
+ | `/status` | AI tool and session info |
105
+ | `/cd <path>` | Change session working directory |
106
+ | `/pwd` | Print working directory |
107
+ | `/allow` / `/y` | Approve a permission request |
108
+ | `/deny` / `/n` | Reject a permission request |
94
109
 
95
- ## Session Behavior
110
+ ## Sessions
96
111
 
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.
112
+ 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.
98
113
 
99
114
  ## Configuration
100
115
 
101
- ### Per-Platform AI Routing
116
+ ### Per-platform AI tool
102
117
 
103
- The root-level `aiCommand` is the default AI tool. Override per-platform with `platforms.<name>.aiCommand`:
118
+ Default: root `aiCommand`. Override per platform with `platforms.<name>.aiCommand`:
104
119
 
105
120
  ```json
106
121
  {
107
122
  "aiCommand": "claude",
108
123
  "platforms": {
109
124
  "telegram": { "enabled": true, "aiCommand": "codex" },
110
- "feishu": { "enabled": true, "aiCommand": "codex" },
111
- "qq": { "enabled": true, "aiCommand": "codebuddy" }
125
+ "feishu": { "enabled": true, "aiCommand": "codex" },
126
+ "qq": { "enabled": true, "aiCommand": "codebuddy" }
112
127
  }
113
128
  }
114
129
  ```
115
130
 
116
131
  ### Claude (Agent SDK)
117
132
 
118
- Claude uses the Agent SDK by default no local `claude` executable needed. Provide API credentials:
133
+ Uses the Agent SDK by default (no local `claude` binary required). Credentials load order:
119
134
 
120
- Credential load order:
121
- 1. Environment variables
122
- 2. `env` in `~/.open-im/config.json`
135
+ 1. Environment variables
136
+ 2. `env` in `~/.open-im/config.json`
123
137
  3. `~/.claude/settings.json` or `~/.claude.json`
124
138
 
125
- Compatible with third-party endpoints:
139
+ Third-party compatible endpoints:
126
140
 
127
141
  ```json
128
142
  {
@@ -134,25 +148,18 @@ Compatible with third-party endpoints:
134
148
  }
135
149
  ```
136
150
 
137
- Claude automatically inherits plugins and settings from your local `~/.claude/settings.json`.
151
+ Claude inherits plugins and settings from `~/.claude/settings.json` when present.
138
152
 
139
153
  ### CodeBuddy
140
154
 
141
- Install the CLI and log in:
142
-
143
155
  ```bash
144
156
  npm install -g @tencent-ai/codebuddy-code
145
157
  codebuddy login
146
158
  ```
147
159
 
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`)
152
-
153
- On Windows, if `cliPath` is `codebuddy`, open-im also checks `AppData\Roaming\npm\codebuddy.cmd`.
160
+ Useful keys: `tools.codebuddy.cliPath`, `tools.codebuddy.skipPermissions`, `tools.codebuddy.timeoutMs`. On Windows, `codebuddy` may resolve to `%AppData%\Roaming\npm\codebuddy.cmd`.
154
161
 
155
- ### Example Config
162
+ ### Example `config.json`
156
163
 
157
164
  ```json
158
165
  {
@@ -174,128 +181,58 @@ On Windows, if `cliPath` is `codebuddy`, open-im also checks `AppData\Roaming\np
174
181
  }
175
182
  },
176
183
  "platforms": {
177
- "telegram": {
178
- "enabled": true,
179
- "botToken": "YOUR_TELEGRAM_BOT_TOKEN"
180
- },
181
- "feishu": {
182
- "enabled": false,
183
- "appId": "YOUR_FEISHU_APP_ID",
184
- "appSecret": "YOUR_FEISHU_APP_SECRET"
185
- },
186
- "qq": {
187
- "enabled": false,
188
- "appId": "YOUR_QQ_APP_ID",
189
- "secret": "YOUR_QQ_APP_SECRET"
190
- },
191
- "wework": {
192
- "enabled": false,
193
- "corpId": "YOUR_WEWORK_CORP_ID",
194
- "secret": "YOUR_WEWORK_SECRET"
195
- },
184
+ "telegram": { "enabled": true, "botToken": "YOUR_TELEGRAM_BOT_TOKEN" },
185
+ "feishu": { "enabled": false, "appId": "YOUR_FEISHU_APP_ID", "appSecret": "YOUR_FEISHU_APP_SECRET" },
186
+ "qq": { "enabled": false, "appId": "YOUR_QQ_APP_ID", "secret": "YOUR_QQ_APP_SECRET" },
187
+ "wework": { "enabled": false, "corpId": "YOUR_WEWORK_CORP_ID", "secret": "YOUR_WEWORK_SECRET" },
196
188
  "dingtalk": {
197
189
  "enabled": false,
198
190
  "clientId": "YOUR_DINGTALK_CLIENT_ID",
199
191
  "clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
200
192
  "cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
201
193
  },
202
- "workbuddy": {
203
- "enabled": false,
204
- "accessToken": "",
205
- "refreshToken": "",
206
- "userId": ""
207
- }
194
+ "workbuddy": { "enabled": false, "accessToken": "", "refreshToken": "", "userId": "" }
208
195
  }
209
196
  }
210
197
  ```
211
198
 
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
199
+ WorkBuddy (WeChat) is easiest via `open-im init` or by editing `~/.open-im/config.json`.
200
+
201
+ ### Environment variables
202
+
203
+ **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`
204
+
205
+ **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`
206
+
207
+ **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`
208
+
209
+ ### Platform setup
210
+
211
+ | Platform | Where to get credentials |
212
+ | --- | --- |
213
+ | Telegram | [@BotFather](https://t.me/BotFather) |
214
+ | Feishu | [Feishu Open Platform](https://open.feishu.cn/) |
215
+ | QQ | [QQ Open Platform](https://bot.q.qq.com/) |
216
+ | DingTalk | DingTalk Open Platform — enable bot **Stream Mode** |
217
+ | WeCom | [WeCom admin](https://work.weixin.qq.com/) |
218
+ | WeChat | `open-im init` WorkBuddy OAuth |
219
+
220
+ **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.
283
221
 
284
222
  ## Troubleshooting
285
223
 
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 |
224
+ | Issue | What to try |
225
+ | --- | --- |
226
+ | Telegram not responding | Check network; set `proxy` / `TELEGRAM_PROXY` |
227
+ | QQ cannot connect | Verify bot and `QQ_BOT_APPID` / `QQ_BOT_SECRET` |
228
+ | QQ duplicate replies | Upgrade to the latest version |
291
229
  | Feishu card errors | Use `/mode ask` or `/mode yolo` without card callbacks |
292
230
  | 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 |
231
+ | DingTalk cannot reply | Enable Stream Mode; verify credentials |
232
+ | DingTalk no streaming | Custom bots: plain text only; set `cardTemplateId` for AI assistant cards |
233
+ | Codex `stream disconnected` | Set `tools.codex.proxy` or `CODEX_PROXY` |
234
+ | CodeBuddy asks for login | Run `codebuddy login` |
235
+ | WorkBuddy / WeChat | Re-run `open-im init`; tokens and binding links expire |
299
236
 
300
237
  ## License
301
238