@wu529778790/open-im 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -109
- package/README.zh-CN.md +266 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,70 +1,95 @@
|
|
|
1
1
|
# open-im
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Multi-platform IM bridge for AI CLI tools. Connect Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat to Claude Code, Codex, and Cursor so you can use your coding assistant remotely from a phone or chat window.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 多 AI 工具:支持 Claude、Codex、Cursor
|
|
9
|
-
- 流式输出:实时回传 AI 回复与工具执行进度(目前钉钉暂未实现流式传输)
|
|
10
|
-
- 图形化配置页面 / cli配置引导
|
|
11
|
-
- 会话隔离:每个用户独立维护本地会话,`/new` 可重置
|
|
12
|
-
- 常用命令:支持 `/help`、`/new`、`/cd`、`/pwd`、`/status`
|
|
7
|
+
## Features
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
- Multi-platform support: Telegram, Feishu, WeCom, DingTalk, QQ, and WeChat (experimental), with multiple platforms enabled at the same time
|
|
10
|
+
- Multiple AI tools: Claude, Codex, and Cursor
|
|
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`
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
15
18
|
|
|
16
19
|
- Node.js >= 20
|
|
17
|
-
-
|
|
18
|
-
-
|
|
20
|
+
- At least one IM platform configured
|
|
21
|
+
- Authentication completed for the AI tool you want to use
|
|
19
22
|
|
|
20
|
-
##
|
|
23
|
+
## Quick Start
|
|
21
24
|
|
|
22
25
|
```bash
|
|
23
26
|
npx @wu529778790/open-im start
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
Or install globally:
|
|
27
30
|
|
|
28
31
|
```bash
|
|
29
32
|
npm install -g @wu529778790/open-im
|
|
30
33
|
open-im start
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
The config file is stored at `~/.open-im/config.json` by default.
|
|
34
37
|
|
|
35
|
-
## CLI
|
|
38
|
+
## CLI Commands
|
|
36
39
|
|
|
37
|
-
|
|
|
40
|
+
| Command | Description |
|
|
38
41
|
| ---- | ---- |
|
|
39
|
-
| `open-im init` |
|
|
40
|
-
| `open-im start` |
|
|
41
|
-
| `open-im stop` |
|
|
42
|
-
| `open-im dev` |
|
|
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
|
+
|
|
47
|
+
## Graphical Config Page
|
|
48
|
+
|
|
49
|
+
- Default URL: `http://127.0.0.1:39282`
|
|
50
|
+
- `open-im start` also serves the local configuration page
|
|
51
|
+
- `open-im dev` only opens the page automatically when setup is incomplete
|
|
52
|
+
- If configuration already exists and you want to open the page manually, use `open-im start`
|
|
53
|
+
|
|
54
|
+
## Session Behavior
|
|
55
|
+
|
|
56
|
+
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.
|
|
43
57
|
|
|
44
|
-
##
|
|
58
|
+
## Configuration
|
|
45
59
|
|
|
46
|
-
-
|
|
47
|
-
- `open-im start` 会同时提供本地配置页面
|
|
48
|
-
- `open-im dev` 仅在未完成配置时自动打开页面
|
|
49
|
-
- 已有配置但想手动打开时,使用 `open-im start`
|
|
60
|
+
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`.
|
|
50
61
|
|
|
51
|
-
|
|
62
|
+
Example:
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"aiCommand": "claude",
|
|
67
|
+
"platforms": {
|
|
68
|
+
"telegram": {
|
|
69
|
+
"enabled": true,
|
|
70
|
+
"aiCommand": "codex"
|
|
71
|
+
},
|
|
72
|
+
"feishu": {
|
|
73
|
+
"enabled": true,
|
|
74
|
+
"aiCommand": "cursor"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
In that setup, Telegram uses Codex, Feishu uses Cursor, and any platform without its own `aiCommand` continues using Claude.
|
|
56
81
|
|
|
57
82
|
### Claude
|
|
58
83
|
|
|
59
|
-
Claude
|
|
84
|
+
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.
|
|
60
85
|
|
|
61
|
-
|
|
86
|
+
Load order:
|
|
62
87
|
|
|
63
|
-
1.
|
|
64
|
-
2. `~/.open-im/config.json`
|
|
65
|
-
3. `~/.claude/settings.json`
|
|
88
|
+
1. Environment variables
|
|
89
|
+
2. `env` in `~/.open-im/config.json`
|
|
90
|
+
3. `~/.claude/settings.json` or `~/.claude.json`
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
Both the official API and compatible third-party endpoints are supported:
|
|
68
93
|
|
|
69
94
|
```json
|
|
70
95
|
{
|
|
@@ -76,9 +101,9 @@ Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通
|
|
|
76
101
|
}
|
|
77
102
|
```
|
|
78
103
|
|
|
79
|
-
###
|
|
104
|
+
### Example Config File
|
|
80
105
|
|
|
81
|
-
|
|
106
|
+
The following is valid JSON and can be saved directly as `~/.open-im/config.json`:
|
|
82
107
|
|
|
83
108
|
```json
|
|
84
109
|
{
|
|
@@ -104,30 +129,35 @@ Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通
|
|
|
104
129
|
"platforms": {
|
|
105
130
|
"telegram": {
|
|
106
131
|
"enabled": true,
|
|
132
|
+
"aiCommand": "codex",
|
|
107
133
|
"proxy": "http://127.0.0.1:7890",
|
|
108
134
|
"allowedUserIds": [],
|
|
109
135
|
"botToken": "YOUR_TELEGRAM_BOT_TOKEN"
|
|
110
136
|
},
|
|
111
137
|
"feishu": {
|
|
112
138
|
"enabled": false,
|
|
139
|
+
"aiCommand": "cursor",
|
|
113
140
|
"allowedUserIds": [],
|
|
114
141
|
"appId": "YOUR_FEISHU_APP_ID",
|
|
115
142
|
"appSecret": "YOUR_FEISHU_APP_SECRET"
|
|
116
143
|
},
|
|
117
144
|
"qq": {
|
|
118
145
|
"enabled": false,
|
|
146
|
+
"aiCommand": "claude",
|
|
119
147
|
"allowedUserIds": [],
|
|
120
148
|
"appId": "YOUR_QQ_APP_ID",
|
|
121
149
|
"secret": "YOUR_QQ_APP_SECRET"
|
|
122
150
|
},
|
|
123
151
|
"wework": {
|
|
124
152
|
"enabled": false,
|
|
153
|
+
"aiCommand": "claude",
|
|
125
154
|
"allowedUserIds": [],
|
|
126
155
|
"corpId": "YOUR_WEWORK_CORP_ID",
|
|
127
156
|
"secret": "YOUR_WEWORK_SECRET"
|
|
128
157
|
},
|
|
129
158
|
"dingtalk": {
|
|
130
159
|
"enabled": false,
|
|
160
|
+
"aiCommand": "claude",
|
|
131
161
|
"allowedUserIds": [],
|
|
132
162
|
"clientId": "YOUR_DINGTALK_CLIENT_ID",
|
|
133
163
|
"clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
|
|
@@ -135,6 +165,7 @@ Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通
|
|
|
135
165
|
},
|
|
136
166
|
"wechat": {
|
|
137
167
|
"enabled": false,
|
|
168
|
+
"aiCommand": "claude",
|
|
138
169
|
"allowedUserIds": [],
|
|
139
170
|
"appId": "YOUR_WECHAT_APP_ID",
|
|
140
171
|
"appSecret": "YOUR_WECHAT_APP_SECRET"
|
|
@@ -143,92 +174,92 @@ Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通
|
|
|
143
174
|
}
|
|
144
175
|
```
|
|
145
176
|
|
|
146
|
-
###
|
|
177
|
+
### Common Environment Variables
|
|
147
178
|
|
|
148
|
-
|
|
|
179
|
+
| Variable | Description |
|
|
149
180
|
| ---- | ---- |
|
|
150
|
-
| `AI_COMMAND` |
|
|
151
|
-
| `CLAUDE_WORK_DIR` |
|
|
152
|
-
| `LOG_DIR` |
|
|
153
|
-
| `LOG_LEVEL` |
|
|
154
|
-
| `HOOK_PORT` |
|
|
155
|
-
| `CODEX_PROXY` | Codex
|
|
156
|
-
| `OPENAI_API_KEY` | Codex API
|
|
157
|
-
| `CURSOR_API_KEY` | Cursor API
|
|
158
|
-
| `TELEGRAM_BOT_TOKEN` | Telegram
|
|
159
|
-
| `TELEGRAM_PROXY` | Telegram
|
|
160
|
-
| `TELEGRAM_ALLOWED_USER_IDS` | Telegram
|
|
161
|
-
| `FEISHU_APP_ID` |
|
|
162
|
-
| `FEISHU_APP_SECRET` |
|
|
163
|
-
| `FEISHU_ALLOWED_USER_IDS` |
|
|
164
|
-
| `QQ_BOT_APPID` | QQ
|
|
165
|
-
| `QQ_BOT_SECRET` | QQ
|
|
166
|
-
| `QQ_BOT_SANDBOX` | QQ
|
|
167
|
-
| `QQ_ALLOWED_USER_IDS` | QQ
|
|
168
|
-
| `DINGTALK_CLIENT_ID` |
|
|
169
|
-
| `DINGTALK_CLIENT_SECRET` |
|
|
170
|
-
| `DINGTALK_CARD_TEMPLATE_ID` |
|
|
171
|
-
| `DINGTALK_ALLOWED_USER_IDS` |
|
|
172
|
-
| `WEWORK_CORP_ID` |
|
|
173
|
-
| `WEWORK_SECRET` |
|
|
174
|
-
| `WEWORK_WS_URL` |
|
|
175
|
-
| `WEWORK_ALLOWED_USER_IDS` |
|
|
176
|
-
| `WECHAT_APP_ID` |
|
|
177
|
-
| `WECHAT_APP_SECRET` |
|
|
178
|
-
| `WECHAT_TOKEN` |
|
|
179
|
-
| `WECHAT_GUID` |
|
|
180
|
-
| `WECHAT_USER_ID` |
|
|
181
|
-
| `WECHAT_WS_URL` |
|
|
182
|
-
| `WECHAT_ALLOWED_USER_IDS` |
|
|
183
|
-
|
|
184
|
-
###
|
|
185
|
-
|
|
186
|
-
- Telegram
|
|
187
|
-
-
|
|
188
|
-
- QQ
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
## IM
|
|
202
|
-
|
|
203
|
-
|
|
|
181
|
+
| `AI_COMMAND` | Select `claude`, `codex`, or `cursor` |
|
|
182
|
+
| `CLAUDE_WORK_DIR` | Default session working directory |
|
|
183
|
+
| `LOG_DIR` | Log directory |
|
|
184
|
+
| `LOG_LEVEL` | Log level |
|
|
185
|
+
| `HOOK_PORT` | Permission service port |
|
|
186
|
+
| `CODEX_PROXY` | Proxy used by Codex to access `chatgpt.com` |
|
|
187
|
+
| `OPENAI_API_KEY` | Codex API key, can replace `codex login` |
|
|
188
|
+
| `CURSOR_API_KEY` | Cursor API key, can replace `agent login` |
|
|
189
|
+
| `TELEGRAM_BOT_TOKEN` | Telegram bot token |
|
|
190
|
+
| `TELEGRAM_PROXY` | Telegram proxy URL |
|
|
191
|
+
| `TELEGRAM_ALLOWED_USER_IDS` | Telegram allowlist |
|
|
192
|
+
| `FEISHU_APP_ID` | Feishu app ID |
|
|
193
|
+
| `FEISHU_APP_SECRET` | Feishu app secret |
|
|
194
|
+
| `FEISHU_ALLOWED_USER_IDS` | Feishu allowlist |
|
|
195
|
+
| `QQ_BOT_APPID` | QQ bot app ID |
|
|
196
|
+
| `QQ_BOT_SECRET` | QQ bot app secret |
|
|
197
|
+
| `QQ_BOT_SANDBOX` | QQ bot sandbox mode (`1` / `true` to enable, disabled by default) |
|
|
198
|
+
| `QQ_ALLOWED_USER_IDS` | QQ allowlist |
|
|
199
|
+
| `DINGTALK_CLIENT_ID` | DingTalk client ID / AppKey |
|
|
200
|
+
| `DINGTALK_CLIENT_SECRET` | DingTalk client secret / AppSecret |
|
|
201
|
+
| `DINGTALK_CARD_TEMPLATE_ID` | DingTalk AI card template ID; enables single-message streaming replies |
|
|
202
|
+
| `DINGTALK_ALLOWED_USER_IDS` | DingTalk allowlist |
|
|
203
|
+
| `WEWORK_CORP_ID` | WeCom bot ID |
|
|
204
|
+
| `WEWORK_SECRET` | WeCom secret |
|
|
205
|
+
| `WEWORK_WS_URL` | WeCom WebSocket URL |
|
|
206
|
+
| `WEWORK_ALLOWED_USER_IDS` | WeCom allowlist |
|
|
207
|
+
| `WECHAT_APP_ID` | WeChat standard mode app ID |
|
|
208
|
+
| `WECHAT_APP_SECRET` | WeChat standard mode app secret |
|
|
209
|
+
| `WECHAT_TOKEN` | WeChat AGP mode token |
|
|
210
|
+
| `WECHAT_GUID` | WeChat AGP mode GUID |
|
|
211
|
+
| `WECHAT_USER_ID` | WeChat AGP mode user ID |
|
|
212
|
+
| `WECHAT_WS_URL` | WeChat WebSocket URL |
|
|
213
|
+
| `WECHAT_ALLOWED_USER_IDS` | WeChat allowlist |
|
|
214
|
+
|
|
215
|
+
### Platform Setup Sources
|
|
216
|
+
|
|
217
|
+
- Telegram: get the bot token from [@BotFather](https://t.me/BotFather)
|
|
218
|
+
- Feishu: create an app and enable the bot in the [Feishu Open Platform](https://open.feishu.cn/)
|
|
219
|
+
- QQ: create a bot in the [QQ Open Platform](https://bot.q.qq.com/) and get the `App ID` and `App Secret`
|
|
220
|
+
- DingTalk: create an internal enterprise app in DingTalk Open Platform, enable bot Stream Mode, and get the `Client ID` and `Client Secret`
|
|
221
|
+
- WeCom: get the bot ID and secret from the [WeCom admin console](https://work.weixin.qq.com/)
|
|
222
|
+
- WeChat: experimental, supports both standard mode and AGP/Qclaw-related settings
|
|
223
|
+
|
|
224
|
+
Notes on DingTalk: the current implementation uses a hybrid model of "Stream Mode for receiving messages + OpenAPI for sending messages".
|
|
225
|
+
|
|
226
|
+
- Plain text replies in a session are sent through `sessionWebhook`
|
|
227
|
+
- 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
|
|
228
|
+
- Startup and shutdown notifications are sent to the most recently active DingTalk conversation. After a cold start, if no DingTalk conversation has interacted with the service yet, there is no target to notify
|
|
229
|
+
|
|
230
|
+
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.
|
|
231
|
+
|
|
232
|
+
## IM Commands
|
|
233
|
+
|
|
234
|
+
| Command | Description |
|
|
204
235
|
| ---- | ---- |
|
|
205
|
-
| `/help` |
|
|
206
|
-
| `/new` |
|
|
207
|
-
| `/status` |
|
|
208
|
-
| `/cd
|
|
209
|
-
| `/pwd` |
|
|
210
|
-
| `/allow` `/y` |
|
|
211
|
-
| `/deny` `/n` |
|
|
236
|
+
| `/help` | Show help |
|
|
237
|
+
| `/new` | Start a new session |
|
|
238
|
+
| `/status` | Show AI tool, version, session directory, and session ID |
|
|
239
|
+
| `/cd <path>` | Change the session working directory |
|
|
240
|
+
| `/pwd` | Show the current session working directory |
|
|
241
|
+
| `/allow` `/y` | Approve a permission request |
|
|
242
|
+
| `/deny` `/n` | Reject a permission request |
|
|
212
243
|
|
|
213
|
-
##
|
|
244
|
+
## Troubleshooting
|
|
214
245
|
|
|
215
|
-
**Telegram
|
|
246
|
+
**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`.
|
|
216
247
|
|
|
217
|
-
**QQ
|
|
248
|
+
**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`.
|
|
218
249
|
|
|
219
|
-
**QQ
|
|
250
|
+
**QQ sends duplicate replies**: update to the latest version. This issue was fixed recently.
|
|
220
251
|
|
|
221
|
-
|
|
252
|
+
**Feishu card errors**: if card callbacks are not configured, you can use `/mode ask` or `/mode yolo` directly.
|
|
222
253
|
|
|
223
|
-
|
|
254
|
+
**WeCom notifications are not received**: the bot must receive at least one message first before it can send proactive notifications.
|
|
224
255
|
|
|
225
|
-
|
|
256
|
+
**DingTalk cannot reply**: make sure bot Stream Mode is enabled for the app, then verify `DINGTALK_CLIENT_ID`, `DINGTALK_CLIENT_SECRET`, or `platforms.dingtalk`.
|
|
226
257
|
|
|
227
|
-
|
|
258
|
+
**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.
|
|
228
259
|
|
|
229
|
-
**Cursor
|
|
260
|
+
**Cursor shows `Authentication required`**: run `agent login` first, or set `CURSOR_API_KEY` in `env`.
|
|
230
261
|
|
|
231
|
-
**Codex
|
|
262
|
+
**Codex shows `stream disconnected` or `error sending request`**: `chatgpt.com` is not reachable. Configure `tools.codex.proxy` or set `CODEX_PROXY`.
|
|
232
263
|
|
|
233
264
|
## License
|
|
234
265
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# open-im
|
|
2
|
+
|
|
3
|
+
[English](./README.md)
|
|
4
|
+
|
|
5
|
+
多平台 IM 桥接工具,把 Telegram、飞书、企业微信、钉钉、QQ、微信接到 AI CLI 工具(Claude Code、Codex、Cursor),方便在手机或聊天窗口里远程使用 AI 编程助手。
|
|
6
|
+
|
|
7
|
+
## 功能特性
|
|
8
|
+
|
|
9
|
+
- 多平台:支持 Telegram、飞书、企业微信、钉钉、QQ、微信(测试中),可同时启用
|
|
10
|
+
- 多 AI 工具:支持 Claude、Codex、Cursor
|
|
11
|
+
- 按平台分配 AI:根级 `aiCommand` 作为默认值,`platforms.<name>.aiCommand` 可为不同 IM 单独指定 AI 工具
|
|
12
|
+
- 流式输出:实时回传 AI 回复与工具执行进度(目前钉钉暂未实现流式传输)
|
|
13
|
+
- 图形化配置页面 / CLI 配置引导
|
|
14
|
+
- 会话隔离:每个用户独立维护本地会话,`/new` 可重置
|
|
15
|
+
- 常用命令:支持 `/help`、`/new`、`/cd`、`/pwd`、`/status`
|
|
16
|
+
|
|
17
|
+
## 环境要求
|
|
18
|
+
|
|
19
|
+
- Node.js >= 20
|
|
20
|
+
- 至少配置一个 IM 平台
|
|
21
|
+
- 根据所选 AI 工具完成认证
|
|
22
|
+
|
|
23
|
+
## 快速开始
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @wu529778790/open-im start
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
或全局安装:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g @wu529778790/open-im
|
|
33
|
+
open-im start
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
配置文件默认保存在 `~/.open-im/config.json`。
|
|
37
|
+
|
|
38
|
+
## CLI 命令
|
|
39
|
+
|
|
40
|
+
| 命令 | 说明 |
|
|
41
|
+
| ---- | ---- |
|
|
42
|
+
| `open-im init` | 初始化或追加配置,不启动服务 |
|
|
43
|
+
| `open-im start` | 后台运行服务 |
|
|
44
|
+
| `open-im stop` | 停止后台服务 |
|
|
45
|
+
| `open-im dev` | 前台运行(调试模式) |
|
|
46
|
+
|
|
47
|
+
## 图形化配置页面
|
|
48
|
+
|
|
49
|
+
- 默认地址:`http://127.0.0.1:39282`
|
|
50
|
+
- `open-im start` 会同时提供本地配置页面
|
|
51
|
+
- `open-im dev` 仅在未完成配置时自动打开页面
|
|
52
|
+
- 已有配置但想手动打开时,使用 `open-im start`
|
|
53
|
+
|
|
54
|
+
## 会话说明
|
|
55
|
+
|
|
56
|
+
会话上下文保存在本地 `~/.open-im/data/sessions.json`,与 IM 聊天记录本身无关。每个用户有独立会话目录和 session 信息,发送 `/new` 会重置当前 AI 会话。
|
|
57
|
+
|
|
58
|
+
## 配置说明
|
|
59
|
+
|
|
60
|
+
根级 `aiCommand` 是所有平台共用的默认 AI 工具。若某个 IM 平台需要单独绑定其他工具,可以设置 `platforms.<platform>.aiCommand`。
|
|
61
|
+
|
|
62
|
+
示例:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"aiCommand": "claude",
|
|
67
|
+
"platforms": {
|
|
68
|
+
"telegram": {
|
|
69
|
+
"enabled": true,
|
|
70
|
+
"aiCommand": "codex"
|
|
71
|
+
},
|
|
72
|
+
"feishu": {
|
|
73
|
+
"enabled": true,
|
|
74
|
+
"aiCommand": "cursor"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
这个配置下,Telegram 会走 Codex,飞书会走 Cursor,其他未单独指定 `aiCommand` 的平台仍然使用 Claude。
|
|
81
|
+
|
|
82
|
+
### Claude
|
|
83
|
+
|
|
84
|
+
Claude 默认使用 Agent SDK,不依赖本地 `claude` 可执行文件;通常只需要配置 API 凭证。
|
|
85
|
+
|
|
86
|
+
自动加载顺序:
|
|
87
|
+
|
|
88
|
+
1. 环境变量
|
|
89
|
+
2. `~/.open-im/config.json` 的 `env`
|
|
90
|
+
3. `~/.claude/settings.json` 或 `~/.claude.json`
|
|
91
|
+
|
|
92
|
+
支持官方 API,也支持第三方兼容接口:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"env": {
|
|
97
|
+
"ANTHROPIC_AUTH_TOKEN": "your-token",
|
|
98
|
+
"ANTHROPIC_BASE_URL": "https://your-api-endpoint",
|
|
99
|
+
"ANTHROPIC_MODEL": "glm-4.7"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 配置文件示例
|
|
105
|
+
|
|
106
|
+
下面示例是合法 JSON,可直接保存为 `~/.open-im/config.json`:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"aiCommand": "claude",
|
|
111
|
+
"tools": {
|
|
112
|
+
"claude": {
|
|
113
|
+
"cliPath": "claude",
|
|
114
|
+
"workDir": "D:/coding/open-im",
|
|
115
|
+
"skipPermissions": true,
|
|
116
|
+
"timeoutMs": 600000
|
|
117
|
+
},
|
|
118
|
+
"cursor": {
|
|
119
|
+
"cliPath": "agent",
|
|
120
|
+
"skipPermissions": true
|
|
121
|
+
},
|
|
122
|
+
"codex": {
|
|
123
|
+
"cliPath": "codex",
|
|
124
|
+
"workDir": "D:/coding/open-im",
|
|
125
|
+
"skipPermissions": true,
|
|
126
|
+
"proxy": "http://127.0.0.1:7890"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"platforms": {
|
|
130
|
+
"telegram": {
|
|
131
|
+
"enabled": true,
|
|
132
|
+
"aiCommand": "codex",
|
|
133
|
+
"proxy": "http://127.0.0.1:7890",
|
|
134
|
+
"allowedUserIds": [],
|
|
135
|
+
"botToken": "YOUR_TELEGRAM_BOT_TOKEN"
|
|
136
|
+
},
|
|
137
|
+
"feishu": {
|
|
138
|
+
"enabled": false,
|
|
139
|
+
"aiCommand": "cursor",
|
|
140
|
+
"allowedUserIds": [],
|
|
141
|
+
"appId": "YOUR_FEISHU_APP_ID",
|
|
142
|
+
"appSecret": "YOUR_FEISHU_APP_SECRET"
|
|
143
|
+
},
|
|
144
|
+
"qq": {
|
|
145
|
+
"enabled": false,
|
|
146
|
+
"aiCommand": "claude",
|
|
147
|
+
"allowedUserIds": [],
|
|
148
|
+
"appId": "YOUR_QQ_APP_ID",
|
|
149
|
+
"secret": "YOUR_QQ_APP_SECRET"
|
|
150
|
+
},
|
|
151
|
+
"wework": {
|
|
152
|
+
"enabled": false,
|
|
153
|
+
"aiCommand": "claude",
|
|
154
|
+
"allowedUserIds": [],
|
|
155
|
+
"corpId": "YOUR_WEWORK_CORP_ID",
|
|
156
|
+
"secret": "YOUR_WEWORK_SECRET"
|
|
157
|
+
},
|
|
158
|
+
"dingtalk": {
|
|
159
|
+
"enabled": false,
|
|
160
|
+
"aiCommand": "claude",
|
|
161
|
+
"allowedUserIds": [],
|
|
162
|
+
"clientId": "YOUR_DINGTALK_CLIENT_ID",
|
|
163
|
+
"clientSecret": "YOUR_DINGTALK_CLIENT_SECRET",
|
|
164
|
+
"cardTemplateId": "YOUR_DINGTALK_AI_CARD_TEMPLATE_ID"
|
|
165
|
+
},
|
|
166
|
+
"wechat": {
|
|
167
|
+
"enabled": false,
|
|
168
|
+
"aiCommand": "claude",
|
|
169
|
+
"allowedUserIds": [],
|
|
170
|
+
"appId": "YOUR_WECHAT_APP_ID",
|
|
171
|
+
"appSecret": "YOUR_WECHAT_APP_SECRET"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 常用环境变量
|
|
178
|
+
|
|
179
|
+
| 变量 | 说明 |
|
|
180
|
+
| ---- | ---- |
|
|
181
|
+
| `AI_COMMAND` | 选择 `claude` / `codex` / `cursor` |
|
|
182
|
+
| `CLAUDE_WORK_DIR` | 默认会话目录 |
|
|
183
|
+
| `LOG_DIR` | 日志目录 |
|
|
184
|
+
| `LOG_LEVEL` | 日志级别 |
|
|
185
|
+
| `HOOK_PORT` | 权限服务端口 |
|
|
186
|
+
| `CODEX_PROXY` | Codex 访问 `chatgpt.com` 的代理 |
|
|
187
|
+
| `OPENAI_API_KEY` | Codex API Key,可替代 `codex login` |
|
|
188
|
+
| `CURSOR_API_KEY` | Cursor API Key,可替代 `agent login` |
|
|
189
|
+
| `TELEGRAM_BOT_TOKEN` | Telegram Bot Token |
|
|
190
|
+
| `TELEGRAM_PROXY` | Telegram 代理地址 |
|
|
191
|
+
| `TELEGRAM_ALLOWED_USER_IDS` | Telegram 白名单 |
|
|
192
|
+
| `FEISHU_APP_ID` | 飞书 App ID |
|
|
193
|
+
| `FEISHU_APP_SECRET` | 飞书 App Secret |
|
|
194
|
+
| `FEISHU_ALLOWED_USER_IDS` | 飞书白名单 |
|
|
195
|
+
| `QQ_BOT_APPID` | QQ 机器人 App ID |
|
|
196
|
+
| `QQ_BOT_SECRET` | QQ 机器人 App Secret |
|
|
197
|
+
| `QQ_BOT_SANDBOX` | QQ 机器人沙箱模式(`1`/`true` 启用,默认关闭) |
|
|
198
|
+
| `QQ_ALLOWED_USER_IDS` | QQ 白名单 |
|
|
199
|
+
| `DINGTALK_CLIENT_ID` | 钉钉应用 Client ID / AppKey |
|
|
200
|
+
| `DINGTALK_CLIENT_SECRET` | 钉钉应用 Client Secret / AppSecret |
|
|
201
|
+
| `DINGTALK_CARD_TEMPLATE_ID` | 钉钉 AI 卡片模板 ID,配置后启用单条流式回复 |
|
|
202
|
+
| `DINGTALK_ALLOWED_USER_IDS` | 钉钉白名单 |
|
|
203
|
+
| `WEWORK_CORP_ID` | 企业微信 Bot ID |
|
|
204
|
+
| `WEWORK_SECRET` | 企业微信 Secret |
|
|
205
|
+
| `WEWORK_WS_URL` | 企业微信 WebSocket 地址 |
|
|
206
|
+
| `WEWORK_ALLOWED_USER_IDS` | 企业微信白名单 |
|
|
207
|
+
| `WECHAT_APP_ID` | 微信标准模式 App ID |
|
|
208
|
+
| `WECHAT_APP_SECRET` | 微信标准模式 App Secret |
|
|
209
|
+
| `WECHAT_TOKEN` | 微信 AGP 模式 Token |
|
|
210
|
+
| `WECHAT_GUID` | 微信 AGP 模式 GUID |
|
|
211
|
+
| `WECHAT_USER_ID` | 微信 AGP 模式 User ID |
|
|
212
|
+
| `WECHAT_WS_URL` | 微信 WebSocket 地址 |
|
|
213
|
+
| `WECHAT_ALLOWED_USER_IDS` | 微信白名单 |
|
|
214
|
+
|
|
215
|
+
### 平台配置来源
|
|
216
|
+
|
|
217
|
+
- Telegram:从 [@BotFather](https://t.me/BotFather) 获取 Bot Token
|
|
218
|
+
- 飞书:从 [飞书开放平台](https://open.feishu.cn/) 创建应用并启用机器人
|
|
219
|
+
- QQ:从 [QQ 开放平台](https://bot.q.qq.com/) 创建机器人,获取 `App ID` 和 `App Secret`
|
|
220
|
+
- 钉钉:从钉钉开放平台创建企业内部应用,启用机器人 Stream Mode,获取 `Client ID` 和 `Client Secret`
|
|
221
|
+
- 企业微信:从 [企业微信管理后台](https://work.weixin.qq.com/) 获取 Bot ID 和 Secret
|
|
222
|
+
- 微信:测试中,支持标准模式和 AGP/Qclaw 相关配置
|
|
223
|
+
|
|
224
|
+
说明:钉钉当前采用“Stream Mode 收消息 + OpenAPI 发送消息”的混合模式。
|
|
225
|
+
|
|
226
|
+
- 会话内普通文本回复默认走 `sessionWebhook`
|
|
227
|
+
- 若配置了 `cardTemplateId`,会尝试 AI 助理 `prepare/update/finish` 流式卡片;失败则 fallback 为普通文本(自定义机器人/普通群场景下互动卡片 API 报 `param.error`,暂不支持单条流式更新)
|
|
228
|
+
- 启动/关闭通知会发给最近一次已互动的钉钉会话;如果服务冷启动后还没有任何钉钉会话互动过,则没有可用目标可发
|
|
229
|
+
|
|
230
|
+
钉钉 AI 卡片模板:已适配官方「搜索结果卡片」模板,使用变量 `lastMessage`、`content`、`resources`、`users`、`flowStatus`。若使用该模板,无需修改模板即可实现流式更新。
|
|
231
|
+
|
|
232
|
+
## IM 内命令
|
|
233
|
+
|
|
234
|
+
| 命令 | 说明 |
|
|
235
|
+
| ---- | ---- |
|
|
236
|
+
| `/help` | 显示帮助 |
|
|
237
|
+
| `/new` | 开始新会话 |
|
|
238
|
+
| `/status` | 显示 AI 工具、版本、会话目录、会话 ID |
|
|
239
|
+
| `/cd <路径>` | 切换会话目录 |
|
|
240
|
+
| `/pwd` | 显示当前会话目录 |
|
|
241
|
+
| `/allow` `/y` | 允许权限请求 |
|
|
242
|
+
| `/deny` `/n` | 拒绝权限请求 |
|
|
243
|
+
|
|
244
|
+
## 故障排除
|
|
245
|
+
|
|
246
|
+
**Telegram 无响应**:检查网络,必要时在 Telegram 平台配置中添加 `"proxy": "http://127.0.0.1:7890"` 或设置 `TELEGRAM_PROXY`。
|
|
247
|
+
|
|
248
|
+
**QQ 无法连接**:确认机器人已在 QQ 开放平台创建并启用,检查 `QQ_BOT_APPID`、`QQ_BOT_SECRET` 或 `platforms.qq` 配置是否正确。
|
|
249
|
+
|
|
250
|
+
**QQ 重复回复**:如遇到消息重复发送,请确保使用最新版本,该问题已在近期修复。
|
|
251
|
+
|
|
252
|
+
**飞书卡片报错**:未配置卡片回调时,可直接用 `/mode ask`、`/mode yolo`。
|
|
253
|
+
|
|
254
|
+
**企业微信收不到通知**:需要先给机器人发过一条消息,后续才能收到主动通知。
|
|
255
|
+
|
|
256
|
+
**钉钉无法回复**:确认应用已启用机器人 Stream Mode,并检查 `DINGTALK_CLIENT_ID`、`DINGTALK_CLIENT_SECRET` 或 `platforms.dingtalk` 配置是否正确。
|
|
257
|
+
|
|
258
|
+
**钉钉没有流式更新**:`prepare` 失败时 fallback 为普通文本回复。自定义机器人/普通群场景下,AI 助理和互动卡片 API 均不可用,仅支持单条文本回复。
|
|
259
|
+
|
|
260
|
+
**Cursor 报 `Authentication required`**:先执行 `agent login`,或在 `env` 中设置 `CURSOR_API_KEY`。
|
|
261
|
+
|
|
262
|
+
**Codex 报 `stream disconnected` / `error sending request`**:无法访问 `chatgpt.com`,请配置 `tools.codex.proxy` 或环境变量 `CODEX_PROXY`。
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
[MIT](LICENSE)
|