@wecom/wecom-openclaw-plugin 2026.5.25 → 2026.6.23
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/dist/src/monitor.js +25 -12
- package/package.json +1 -1
package/dist/src/monitor.js
CHANGED
|
@@ -26,6 +26,7 @@ import { downloadAndSaveImages, downloadAndSaveFiles, MediaOversizeError, } from
|
|
|
26
26
|
import { uploadAndSendMedia } from "./media-uploader.js";
|
|
27
27
|
import { parseMessageContent } from "./message-parser.js";
|
|
28
28
|
import { sendWeComReply, StreamExpiredError } from "./message-sender.js";
|
|
29
|
+
import { enqueueWeComChatTask } from "./chat-queue.js";
|
|
29
30
|
import { getDefaultMediaLocalRoots, resolveStateDir } from "./openclaw-compat.js";
|
|
30
31
|
import { getWeComRuntime } from "./runtime.js";
|
|
31
32
|
import { setWeComWebSocket, setMessageState, deleteMessageState, setReqIdForChat, setSessionChatInfo, warmupReqIdStore, startMessageStateCleanup, stopMessageStateCleanup, cleanupAccount, } from "./state-manager.js";
|
|
@@ -295,6 +296,13 @@ async function finishThinkingStream(ctx) {
|
|
|
295
296
|
finishText = "📎 文件已发送,请查收。";
|
|
296
297
|
}
|
|
297
298
|
}
|
|
299
|
+
// 兜底:本轮无任何可见产出(无文本/媒体/卡片,常见于"只发文件未带指令"
|
|
300
|
+
// 的消息被 agent 当作上下文读取后不单独回复)。此时若已开启过 thinking 流,
|
|
301
|
+
// 必须发送一个含可见字符的 finish 帧关闭它,否则该消息会一直 loading。
|
|
302
|
+
// 注意:企微会忽略纯空格等不可见内容,必须用可见字符才能真正关闭。
|
|
303
|
+
if (!finishText && state.streamId) {
|
|
304
|
+
finishText = "✅ 已收到";
|
|
305
|
+
}
|
|
298
306
|
if (finishText) {
|
|
299
307
|
// 尝试流式发送;若已知过期或发送时发现过期,统一降级为主动发送
|
|
300
308
|
let expired = state.streamExpired;
|
|
@@ -835,17 +843,17 @@ export async function monitorWeComProvider(options) {
|
|
|
835
843
|
});
|
|
836
844
|
if (!entry)
|
|
837
845
|
return;
|
|
838
|
-
//
|
|
839
|
-
//
|
|
840
|
-
//
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
846
|
+
// 按 accountId:chatId 串行排队,保证同一会话消息按序处理,
|
|
847
|
+
// 避免并发触发 OpenClaw 前台回复栅栏(ForegroundReplyFence)互相抑制
|
|
848
|
+
// 导致较早消息的流式回复被丢弃、thinking 流无法 finish 而一直 loading。
|
|
849
|
+
const { status } = enqueueWeComChatTask({
|
|
850
|
+
accountId: entry.account.accountId,
|
|
851
|
+
chatId: entry.chatId,
|
|
852
|
+
task: () => processWeComMessageNow(entry),
|
|
853
|
+
});
|
|
854
|
+
if (status === "queued") {
|
|
855
|
+
runtime.log?.(`[wecom] Chat task queued for chat=${entry.chatId} (previous task still running)`);
|
|
856
|
+
}
|
|
849
857
|
}
|
|
850
858
|
catch (err) {
|
|
851
859
|
runtime.error?.(`[${account.accountId}] Failed to process message: ${String(err)}`);
|
|
@@ -889,7 +897,12 @@ export async function monitorWeComProvider(options) {
|
|
|
889
897
|
wsClient,
|
|
890
898
|
});
|
|
891
899
|
if (entry) {
|
|
892
|
-
|
|
900
|
+
// 事件回调与普通消息共用同一会话队列,保证严格串行
|
|
901
|
+
enqueueWeComChatTask({
|
|
902
|
+
accountId: entry.account.accountId,
|
|
903
|
+
chatId: entry.chatId,
|
|
904
|
+
task: () => processWeComMessageNow(entry),
|
|
905
|
+
});
|
|
893
906
|
}
|
|
894
907
|
}
|
|
895
908
|
catch (err) {
|