@wu529778790/open-im 1.11.4-beta.19 → 1.11.4-beta.2
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 +0 -21
- package/dist/clawbot/client.js +11 -44
- package/dist/clawbot/message-sender.js +16 -4
- package/dist/clawbot/types.d.ts +0 -3
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -137,27 +137,6 @@ claude -c # 接上手机端的对话
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
### 语音回复(可选)
|
|
141
|
-
|
|
142
|
-
ClawBot 支持语音回复,需要 Python 3 + edge-tts:
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# 安装依赖
|
|
146
|
-
pip3 install edge-tts
|
|
147
|
-
|
|
148
|
-
# 启用语音
|
|
149
|
-
# 在管理页面 http://127.0.0.1:39282 打开 ClawBot 的「语音回复」开关
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
支持的中文声音:
|
|
153
|
-
- 晓晓(女声,温柔)
|
|
154
|
-
- 晓伊(女声,活泼)
|
|
155
|
-
- 云希(男声,年轻)
|
|
156
|
-
- 云健(男声,沉稳)
|
|
157
|
-
- 云扬(男声,专业)
|
|
158
|
-
|
|
159
|
-
> 不安装 Python 也能正常使用 open-im,语音回复是可选功能。
|
|
160
|
-
|
|
161
140
|
### 环境变量
|
|
162
141
|
|
|
163
142
|
- **`ANTHROPIC_*`** — Claude API 配置
|
package/dist/clawbot/client.js
CHANGED
|
@@ -12,8 +12,7 @@ import { createLogger } from '../logger.js';
|
|
|
12
12
|
import { jitteredDelay, isFatalReconnectError, SLOW_PROBE_MS } from '../shared/reconnect.js';
|
|
13
13
|
import { cacheContextToken } from './message-sender.js';
|
|
14
14
|
import { setClawbotContextToken, clearClawbotContextToken } from '../shared/active-chats.js';
|
|
15
|
-
import { createMediaTargetPath } from '../shared/media-storage.js';
|
|
16
|
-
import { createDecipheriv } from 'node:crypto';
|
|
15
|
+
import { decryptAes256CbcMedia, saveBufferMedia, createMediaTargetPath } from '../shared/media-storage.js';
|
|
17
16
|
import { CLAWBOT_POLL_INTERVAL_MS } from '../constants.js';
|
|
18
17
|
const log = createLogger('ClawBot');
|
|
19
18
|
const RECONNECT_DELAYS_MS = [3000, 5000, 10000, 20000, 30000];
|
|
@@ -133,10 +132,6 @@ function startPolling() {
|
|
|
133
132
|
cacheContextToken(chatId, msg.context_token);
|
|
134
133
|
setClawbotContextToken(msg.context_token);
|
|
135
134
|
}
|
|
136
|
-
// Debug: log raw item_list for image messages
|
|
137
|
-
if (extracted === '[图片]') {
|
|
138
|
-
log.info(`Image message raw item_list: ${JSON.stringify(msg.item_list).substring(0, 2000)}`);
|
|
139
|
-
}
|
|
140
135
|
// Extract and download images from message
|
|
141
136
|
const imagePaths = await extractImages(msg);
|
|
142
137
|
userMessages.push({ chatId, msgId, content: extracted, imagePaths: imagePaths.length > 0 ? imagePaths : undefined });
|
|
@@ -254,56 +249,28 @@ async function extractImages(msg) {
|
|
|
254
249
|
for (const item of msg.item_list) {
|
|
255
250
|
if (item.type !== 2 /* MessageItemType.IMAGE */)
|
|
256
251
|
continue;
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
// iLink API 使用 full_url 而非 cdn_url
|
|
260
|
-
const imageUrl = media?.full_url || media?.cdn_url;
|
|
261
|
-
if (!imageUrl) {
|
|
262
|
-
log.warn('Image item missing full_url/cdn_url');
|
|
252
|
+
const media = item.image_item?.media;
|
|
253
|
+
if (!media?.cdn_url)
|
|
263
254
|
continue;
|
|
264
|
-
}
|
|
265
255
|
try {
|
|
266
|
-
//
|
|
267
|
-
const response = await fetch(
|
|
256
|
+
// Download from CDN
|
|
257
|
+
const response = await fetch(media.cdn_url, { signal: AbortSignal.timeout(30_000) });
|
|
268
258
|
if (!response.ok) {
|
|
269
259
|
log.warn(`Image download failed: HTTP ${response.status}`);
|
|
270
260
|
continue;
|
|
271
261
|
}
|
|
272
262
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
let finalBuffer;
|
|
278
|
-
if (isJpeg || isPng) {
|
|
279
|
-
// CDN 返回的是有效图片,直接使用
|
|
280
|
-
finalBuffer = buffer;
|
|
263
|
+
// Decrypt if AES key provided
|
|
264
|
+
let decrypted;
|
|
265
|
+
if (media.aes_key) {
|
|
266
|
+
decrypted = decryptAes256CbcMedia(buffer, media.aes_key);
|
|
281
267
|
}
|
|
282
268
|
else {
|
|
283
|
-
|
|
284
|
-
const aesKeyHex = imageItem?.aeskey;
|
|
285
|
-
if (aesKeyHex && aesKeyHex.length === 32) {
|
|
286
|
-
try {
|
|
287
|
-
const keyBuf = Buffer.from(aesKeyHex, 'hex');
|
|
288
|
-
const iv = keyBuf.subarray(0, 16);
|
|
289
|
-
const decipher = createDecipheriv('aes-128-cbc', keyBuf, iv);
|
|
290
|
-
finalBuffer = Buffer.concat([decipher.update(buffer), decipher.final()]);
|
|
291
|
-
}
|
|
292
|
-
catch {
|
|
293
|
-
log.info('AES decryption failed, using raw image data');
|
|
294
|
-
finalBuffer = buffer;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
finalBuffer = buffer;
|
|
299
|
-
}
|
|
269
|
+
decrypted = buffer;
|
|
300
270
|
}
|
|
301
271
|
// Save to disk
|
|
302
272
|
const targetPath = createMediaTargetPath('.jpg', `clawbot-${Date.now()}`);
|
|
303
|
-
|
|
304
|
-
const { mkdir } = await import('node:fs/promises');
|
|
305
|
-
await mkdir('/tmp/t/open-im-images', { recursive: true });
|
|
306
|
-
await writeFile(targetPath, finalBuffer);
|
|
273
|
+
await saveBufferMedia(decrypted, targetPath);
|
|
307
274
|
paths.push(targetPath);
|
|
308
275
|
log.info(`ClawBot image saved: ${targetPath}`);
|
|
309
276
|
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { randomBytes } from 'node:crypto';
|
|
7
7
|
import { createLogger } from '../logger.js';
|
|
8
|
-
import { toReplyPlainText } from '../shared/utils.js';
|
|
8
|
+
import { splitLongContent, toReplyPlainText } from '../shared/utils.js';
|
|
9
|
+
import { MAX_CLAWBOT_MESSAGE_LENGTH } from '../constants.js';
|
|
9
10
|
import { getChannelState } from './client.js';
|
|
10
11
|
import { getActiveChatId, getClawbotContextToken } from '../shared/active-chats.js';
|
|
11
12
|
const log = createLogger('ClawBotSender');
|
|
@@ -93,9 +94,20 @@ async function postMessage(chatId, text, contextToken) {
|
|
|
93
94
|
*/
|
|
94
95
|
export async function sendTextReply(chatId, text, contextToken) {
|
|
95
96
|
const plainText = toReplyPlainText(text);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
const parts = splitLongContent(plainText, MAX_CLAWBOT_MESSAGE_LENGTH);
|
|
98
|
+
if (parts.length === 1) {
|
|
99
|
+
log.info(`Sending ClawBot reply to chatId=${chatId}, len=${plainText.length}`);
|
|
100
|
+
await postMessage(chatId, plainText, contextToken);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
log.info(`Sending ClawBot reply in ${parts.length} parts to chatId=${chatId}, totalLen=${plainText.length}`);
|
|
104
|
+
for (let i = 0; i < parts.length; i++) {
|
|
105
|
+
const partText = i === 0
|
|
106
|
+
? `${parts[i]}\n\n_(1/${parts.length})_`
|
|
107
|
+
: `_(续 ${i + 1}/${parts.length})_\n\n${parts[i]}`;
|
|
108
|
+
await postMessage(chatId, partText, contextToken);
|
|
109
|
+
log.info(`ClawBot part ${i + 1}/${parts.length} sent`);
|
|
110
|
+
}
|
|
99
111
|
}
|
|
100
112
|
/**
|
|
101
113
|
* Send error reply to a ClawBot chat.
|
package/dist/clawbot/types.d.ts
CHANGED
|
@@ -21,12 +21,9 @@ export interface TextItem {
|
|
|
21
21
|
}
|
|
22
22
|
/** Image content item */
|
|
23
23
|
export interface ImageItem {
|
|
24
|
-
aeskey?: string;
|
|
25
24
|
media?: {
|
|
26
25
|
aes_key?: string;
|
|
27
26
|
cdn_url?: string;
|
|
28
|
-
full_url?: string;
|
|
29
|
-
encrypt_query_param?: string;
|
|
30
27
|
};
|
|
31
28
|
width?: number;
|
|
32
29
|
height?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wu529778790/open-im",
|
|
3
|
-
"version": "1.11.4-beta.
|
|
3
|
+
"version": "1.11.4-beta.2",
|
|
4
4
|
"description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,13 +58,9 @@
|
|
|
58
58
|
"@sentry/node": "^10.58.0",
|
|
59
59
|
"centrifuge": "^5.5.3",
|
|
60
60
|
"dingtalk-stream": "^2.1.4",
|
|
61
|
-
"edge-tts": "^1.0.1",
|
|
62
|
-
"https-proxy-agent": "^9.1.0",
|
|
63
|
-
"node-edge-tts": "^1.2.10",
|
|
64
61
|
"prompts": "^2.4.2",
|
|
65
|
-
"say": "^0.16.0",
|
|
66
62
|
"telegraf": "^4.16.3",
|
|
67
|
-
"ws": "^8.
|
|
63
|
+
"ws": "^8.20.0"
|
|
68
64
|
},
|
|
69
65
|
"devDependencies": {
|
|
70
66
|
"@eslint/js": "^9.15.0",
|