@linjz/opencode-qqbot 0.3.6 → 0.3.7
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/openqq-bot.js +5 -1
- package/package.json +1 -1
- package/src/bridge.ts +3 -1
- package/src/core/inflight-journal.ts +7 -2
package/dist/openqq-bot.js
CHANGED
|
@@ -6675,6 +6675,9 @@ function classifyInflight(entry, messages) {
|
|
|
6675
6675
|
const matched = probe === "" || userText.includes(probe);
|
|
6676
6676
|
if (!matched)
|
|
6677
6677
|
return { kind: "lost" };
|
|
6678
|
+
const completed = ordered.slice(lastUserIdx + 1).some((m) => m.type === "idle");
|
|
6679
|
+
if (!completed)
|
|
6680
|
+
return { kind: "running" };
|
|
6678
6681
|
const answerParts = [];
|
|
6679
6682
|
for (let i = lastUserIdx + 1;i < ordered.length; i++) {
|
|
6680
6683
|
const m = ordered[i];
|
|
@@ -7207,8 +7210,9 @@ ${cls.answer}`);
|
|
|
7207
7210
|
settleInflight(entry.msgId);
|
|
7208
7211
|
console.log(`[bridge] 启动对账:已补投答案 msgId=${entry.msgId}`);
|
|
7209
7212
|
} else if (cls.kind === "running") {
|
|
7213
|
+
mirror.beginTurn(entry.sessionId);
|
|
7210
7214
|
await deliver(ctx, "\uD83D\uDD04 重启恢复:你之前的任务仍在执行,完成即回传结果");
|
|
7211
|
-
startBackgroundWait(entry.sessionId, ctx,
|
|
7215
|
+
startBackgroundWait(entry.sessionId, ctx, entry.at, entry.msgId);
|
|
7212
7216
|
console.log(`[bridge] 启动对账:在途任务已重挂后台等待 msgId=${entry.msgId}`);
|
|
7213
7217
|
} else if (ageMs <= redispatchMaxAgeMs()) {
|
|
7214
7218
|
settleInflight(entry.msgId);
|
package/package.json
CHANGED
package/src/bridge.ts
CHANGED
|
@@ -740,8 +740,10 @@ export function createBridge(
|
|
|
740
740
|
settleInflight(entry.msgId)
|
|
741
741
|
console.log(`[bridge] 启动对账:已补投答案 msgId=${entry.msgId}`)
|
|
742
742
|
} else if (cls.kind === "running") {
|
|
743
|
+
// 跨重启也要保持 QQ 回合同一身份:后台直答完成时,镜像不得再投摘要。
|
|
744
|
+
mirror.beginTurn(entry.sessionId)
|
|
743
745
|
await deliver(ctx, "🔄 重启恢复:你之前的任务仍在执行,完成即回传结果")
|
|
744
|
-
startBackgroundWait(entry.sessionId, ctx,
|
|
746
|
+
startBackgroundWait(entry.sessionId, ctx, entry.at, entry.msgId)
|
|
745
747
|
console.log(`[bridge] 启动对账:在途任务已重挂后台等待 msgId=${entry.msgId}`)
|
|
746
748
|
} else if (ageMs <= redispatchMaxAgeMs()) {
|
|
747
749
|
settleInflight(entry.msgId) // 旧账结清,重派回合走新账(合成 trackId)
|
|
@@ -173,8 +173,8 @@ export type InflightClass =
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* 对账分类:台账条目 × 会话历史 → 该回合的真实状态。
|
|
176
|
-
* - answered
|
|
177
|
-
* - running
|
|
176
|
+
* - answered:找到该用户消息,且其后已有 idle + assistant 正文 → 完整答案在库里没投出,补投
|
|
177
|
+
* - running:找到该用户消息但尚未 idle(无论是否已有流式正文)→ 回合在跑,重挂后台等待
|
|
178
178
|
* - lost:历史里找不到该用户消息 → 消息从未到达 opencode(网关窗口丢失),重派/通知
|
|
179
179
|
* 匹配口径:历史 user 文本包含台账原文前 50 字(prompt 会加引用前缀/附件注记,不能全等)。
|
|
180
180
|
*/
|
|
@@ -198,6 +198,11 @@ export function classifyInflight(
|
|
|
198
198
|
const matched = probe === "" || userText.includes(probe)
|
|
199
199
|
if (!matched) return { kind: "lost" }
|
|
200
200
|
|
|
201
|
+
// 有 assistant 正文 ≠ 回合完成。流式/长任务在运行中也会产生多段正文;
|
|
202
|
+
// 必须看到该用户消息之后的 idle,才允许启动补投,否则会把半截答案提前发出。
|
|
203
|
+
const completed = ordered.slice(lastUserIdx + 1).some((m) => m.type === "idle")
|
|
204
|
+
if (!completed) return { kind: "running" }
|
|
205
|
+
|
|
201
206
|
const answerParts: string[] = []
|
|
202
207
|
for (let i = lastUserIdx + 1; i < ordered.length; i++) {
|
|
203
208
|
const m = ordered[i]
|