@raolin2025/claude-code-node 2.6.10 → 2.6.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.
- package/package.json +1 -1
- package/src/channel/tg-listener.js +17 -3
- package/src/core/cli.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raolin2025/claude-code-node",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.12",
|
|
4
4
|
"description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications, Telegram & QQ Bot remote programming, rich media upload, multi-account management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/core/index.js",
|
|
@@ -275,6 +275,7 @@ export class TelegramListener {
|
|
|
275
275
|
this.maxRetryDelay = 30000
|
|
276
276
|
this._lastPollError = null // 最近一次轮询错误消息(用于去抖刷屏)
|
|
277
277
|
this._lastPollErrorAt = 0 // 最近一次轮询错误时间戳
|
|
278
|
+
this._msgQueue = Promise.resolve() // 消息串行处理队列(避免阻塞轮询循环)
|
|
278
279
|
this.conversations = new ConversationState()
|
|
279
280
|
this._onMessage = null
|
|
280
281
|
this._handlers = {}
|
|
@@ -348,15 +349,17 @@ export class TelegramListener {
|
|
|
348
349
|
for (const update of data.result) {
|
|
349
350
|
this.lastUpdateId = Math.max(this.lastUpdateId, update.update_id)
|
|
350
351
|
|
|
351
|
-
//
|
|
352
|
+
// 处理回调查询(按钮点击)— 快速操作,直接 await
|
|
352
353
|
if (update.callback_query) {
|
|
353
354
|
await this._handleCallbackQuery(update.callback_query)
|
|
354
355
|
continue
|
|
355
356
|
}
|
|
356
357
|
|
|
357
|
-
// 处理消息
|
|
358
|
+
// 处理消息 — 加入串行队列异步处理,不阻塞轮询循环。
|
|
359
|
+
// 否则 AI 处理上一条消息时(可能很久),getUpdates 无法继续接收
|
|
360
|
+
// 新消息(如权限确认回复 a、/quit 等)。
|
|
358
361
|
if (update.message) {
|
|
359
|
-
|
|
362
|
+
this._enqueueMessage(update.message)
|
|
360
363
|
}
|
|
361
364
|
}
|
|
362
365
|
}
|
|
@@ -382,6 +385,17 @@ export class TelegramListener {
|
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
387
|
|
|
388
|
+
/** 将消息加入串行处理队列(不阻塞轮询循环) */
|
|
389
|
+
_enqueueMessage(msg) {
|
|
390
|
+
this._msgQueue = this._msgQueue.then(async () => {
|
|
391
|
+
try {
|
|
392
|
+
await this._handleMessage(msg)
|
|
393
|
+
} catch (e) {
|
|
394
|
+
log(`[TG] handle error: ${e.message}`)
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
}
|
|
398
|
+
|
|
385
399
|
/** 处理消息 */
|
|
386
400
|
async _handleMessage(msg) {
|
|
387
401
|
const chatId = msg.chat?.id
|
package/src/core/cli.js
CHANGED
|
@@ -611,7 +611,8 @@ const systemPrompt = cliArgs.systemPrompt || DEFAULT_SYSTEM_PROMPT
|
|
|
611
611
|
|
|
612
612
|
// 关键:来自 Telegram 的消息,如果当前正在等待远程权限确认(pendingConfirm),
|
|
613
613
|
// 则把它当作确认回复(y/n/a)处理,而不是当作新的 REPL 输入。
|
|
614
|
-
|
|
614
|
+
// 注意:/ 开头的命令优先走命令分支,不被权限确认拦截(否则 /quit、/stop 会被吞)。
|
|
615
|
+
if (source === 'telegram' && pendingConfirm && !trimmed.startsWith('/')) {
|
|
615
616
|
const confirm = pendingConfirm
|
|
616
617
|
pendingConfirm = null
|
|
617
618
|
const a = trimmed.toLowerCase()
|