dsh-client-auto-continue 0.20.1 → 0.21.0
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/CHANGELOG.md +21 -0
- package/README.md +8 -6
- package/README.ru.md +8 -6
- package/README.zh.md +8 -6
- package/docs/releases/v0.20.2.md +49 -0
- package/docs/releases/v0.21.0.md +56 -0
- package/lib/client.js +16 -1
- package/lib/client.js.map +2 -2
- package/lib/index.js +236 -14
- package/lib/types/client/locales.d.ts +3 -0
- package/lib/types/client/settings-card.d.ts +1 -0
- package/lib/types/host/engine.d.ts +26 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/shared/core.d.ts +7 -0
- package/package.json +2 -2
- package/src/client/locales.ts +9 -0
- package/src/client/settings-card.tsx +5 -2
- package/src/host/engine.ts +282 -20
- package/src/index.ts +2 -0
- package/src/shared/core.ts +16 -0
package/lib/index.js
CHANGED
|
@@ -1140,6 +1140,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
|
|
|
1140
1140
|
continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。",
|
|
1141
1141
|
continueTextLoop: "继续",
|
|
1142
1142
|
continueTextInterrupted: "继续。宿主在你上一轮运行期间重启了; 重启时未完成的工具调用已按「结果未知」收尾。从中断处继续, 重试可能有副作用的操作前先核实外部状态。",
|
|
1143
|
+
continueTextQuestion: "这是宿主重启后插件自动发送的消息, 不是用户的回复。你上一步向用户提出的问题因重启中断, 用户还没有回答。请重新提出同一个问题并等待回答, 不要替用户做决定。",
|
|
1143
1144
|
guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)",
|
|
1144
1145
|
guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)",
|
|
1145
1146
|
loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)"
|
|
@@ -1150,6 +1151,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
|
|
|
1150
1151
|
continueTextSilent: "Continue. Your previous turn ended with internal reasoning only, with no message and no tool call, so nothing reached the user. Always finish a turn with a tool call or a visible answer.",
|
|
1151
1152
|
continueTextLoop: "Continue",
|
|
1152
1153
|
continueTextInterrupted: "Continue. The harness was restarted while your previous turn was still running; tool calls pending at the restart are recorded with unknown outcomes. Resume where you left off, verifying external state before retrying anything that may have side effects.",
|
|
1154
|
+
continueTextQuestion: "This message was sent automatically by the plugin after a harness restart; it is not the user's reply. The question you asked the user was cut off by the restart and has not been answered. Ask the same question again and wait for the answer; do not decide for the user.",
|
|
1153
1155
|
guardPendingText: '(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)',
|
|
1154
1156
|
guardDoneText: '(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)',
|
|
1155
1157
|
loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)"
|
|
@@ -1160,6 +1162,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
|
|
|
1160
1162
|
continueTextSilent: "Продолжай. Предыдущий ход закончился только внутренним рассуждением: ни ответа, ни вызова инструмента, поэтому пользователь ничего не увидел. Каждый ход должен заканчиваться вызовом инструмента или видимым ответом.",
|
|
1161
1163
|
continueTextLoop: "Продолжай",
|
|
1162
1164
|
continueTextInterrupted: "Продолжай. Хост перезапустился, пока предыдущий ход ещё выполнялся; вызовы инструментов, незавершённые на момент перезапуска, записаны с неизвестным результатом. Продолжай с места остановки, проверяя внешнее состояние перед повтором действий с возможными побочными эффектами.",
|
|
1165
|
+
continueTextQuestion: "Это сообщение плагин отправил автоматически после перезапуска хоста, это не ответ пользователя. Вопрос, который ты задал пользователю, прервался из-за перезапуска, и ответа на него ещё нет. Задай тот же вопрос снова и дождись ответа, не принимай решение за пользователя.",
|
|
1163
1166
|
guardPendingText: "(Предыдущий инструмент «{tool}», возможно, не завершился. Проверь его состояние перед продолжением и не запускай его повторно.)",
|
|
1164
1167
|
guardDoneText: "(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)",
|
|
1165
1168
|
loopText: "(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)"
|
|
@@ -1217,6 +1220,7 @@ function resolveConfig(section) {
|
|
|
1217
1220
|
const silentText = typeof value.continueTextSilent === "string" && value.continueTextSilent.trim() !== "" ? value.continueTextSilent : localized.continueTextSilent;
|
|
1218
1221
|
const loopText = typeof value.continueTextLoop === "string" && value.continueTextLoop.trim() !== "" ? value.continueTextLoop : localized.continueTextLoop;
|
|
1219
1222
|
const interruptedText = typeof value.continueTextInterrupted === "string" && value.continueTextInterrupted.trim() !== "" ? value.continueTextInterrupted : localized.continueTextInterrupted;
|
|
1223
|
+
const questionText = typeof value.continueTextQuestion === "string" && value.continueTextQuestion.trim() !== "" ? value.continueTextQuestion : localized.continueTextQuestion;
|
|
1220
1224
|
const guardPendingText = typeof value.guardPendingText === "string" && value.guardPendingText.trim() !== "" ? value.guardPendingText : localized.guardPendingText;
|
|
1221
1225
|
const guardDoneText = typeof value.guardDoneText === "string" && value.guardDoneText.trim() !== "" ? value.guardDoneText : localized.guardDoneText;
|
|
1222
1226
|
return {
|
|
@@ -1230,6 +1234,7 @@ function resolveConfig(section) {
|
|
|
1230
1234
|
continueTextSilent: silentText,
|
|
1231
1235
|
continueTextLoop: loopText,
|
|
1232
1236
|
continueTextInterrupted: interruptedText,
|
|
1237
|
+
continueTextQuestion: questionText,
|
|
1233
1238
|
guardTools: booleanOr(value.guardTools, DEFAULT_CONFIG.guardTools),
|
|
1234
1239
|
guardPendingText,
|
|
1235
1240
|
guardDoneText,
|
|
@@ -1645,6 +1650,7 @@ var freshState = () => ({
|
|
|
1645
1650
|
streamTail: "",
|
|
1646
1651
|
streamLastSegment: "",
|
|
1647
1652
|
streamRepeatRun: 0,
|
|
1653
|
+
streamWindow: [],
|
|
1648
1654
|
loopFired: false,
|
|
1649
1655
|
loopRetryTimer: void 0,
|
|
1650
1656
|
cooldownRetryTimer: void 0,
|
|
@@ -1781,6 +1787,7 @@ var LOOP_GUARD_CANCEL_CAUSE = {
|
|
|
1781
1787
|
var LOOP_COMPLETED_REASON = "turn/end:completed";
|
|
1782
1788
|
var LOOP_SILENT_REASON = "turn/end:loop-silent";
|
|
1783
1789
|
var MANUAL_NOTIFICATION_REASON = "manual:notification";
|
|
1790
|
+
var ASK_USER_QUESTION_TOOL = "ask_user_question";
|
|
1784
1791
|
var SWEEP_OBSERVE_BATCH = 16;
|
|
1785
1792
|
var STORED_READ_TIMEOUT_MS = 5e3;
|
|
1786
1793
|
var SWEEP_MAX_FAILURES = 3;
|
|
@@ -1824,6 +1831,8 @@ var CHILD_CAUSE_COPY = {
|
|
|
1824
1831
|
var isLoopReason = (reason) => reason === LOOP_COMPLETED_REASON || reason === LOOP_SILENT_REASON;
|
|
1825
1832
|
var STREAM_NEAR_DUPLICATE_MAX_CHARS = 2048;
|
|
1826
1833
|
var STREAM_TAIL_MAX_CHARS = 4096;
|
|
1834
|
+
var STREAM_WINDOW_SEGMENTS = 40;
|
|
1835
|
+
var STREAM_WINDOW_MAX_UNIQUE = 8;
|
|
1827
1836
|
var visibleText = (text) => text.replace(/\p{Cf}/gu, "").trim();
|
|
1828
1837
|
function snapshotSessionEvents(session) {
|
|
1829
1838
|
const compatible = session;
|
|
@@ -1936,6 +1945,50 @@ function isLoopGuardCancelReason(value) {
|
|
|
1936
1945
|
const cause = value;
|
|
1937
1946
|
return cause.kind === LOOP_GUARD_CANCEL_CAUSE.kind && cause.reason === LOOP_GUARD_CANCEL_CAUSE.reason;
|
|
1938
1947
|
}
|
|
1948
|
+
var TEMPLATE_PLACEHOLDER = /\{(?:code|message|status|tool|turn|errorCount|sessionTitle|elapsed|result)\}/;
|
|
1949
|
+
function templateParts(template) {
|
|
1950
|
+
const parts = template.split(TEMPLATE_PLACEHOLDER);
|
|
1951
|
+
return parts.join("").trim() === "" ? void 0 : parts;
|
|
1952
|
+
}
|
|
1953
|
+
function matchesParts(text, parts) {
|
|
1954
|
+
const first = parts[0] ?? "";
|
|
1955
|
+
if (parts.length === 1) return text === first;
|
|
1956
|
+
const last = parts[parts.length - 1] ?? "";
|
|
1957
|
+
if (text.length < first.length + last.length || !text.startsWith(first) || !text.endsWith(last)) return false;
|
|
1958
|
+
const end = text.length - last.length;
|
|
1959
|
+
let at = first.length;
|
|
1960
|
+
for (let i = 1; i < parts.length - 1; i += 1) {
|
|
1961
|
+
const part = parts[i] ?? "";
|
|
1962
|
+
const found = text.indexOf(part, at);
|
|
1963
|
+
if (found < 0 || found + part.length > end) return false;
|
|
1964
|
+
at = found + part.length;
|
|
1965
|
+
}
|
|
1966
|
+
return true;
|
|
1967
|
+
}
|
|
1968
|
+
function joinParts(left, separator, right) {
|
|
1969
|
+
return [...left.slice(0, -1), `${left[left.length - 1] ?? ""}${separator}${right[0] ?? ""}`, ...right.slice(1)];
|
|
1970
|
+
}
|
|
1971
|
+
var definedParts = (templates) => templates.map(templateParts).filter((parts) => parts !== void 0);
|
|
1972
|
+
var HANDOFF_SHAPES = definedParts(Object.values(HANDOFF_COPY).map((copy) => copy("{code}", "{code}")));
|
|
1973
|
+
var isHandoffText = (text) => HANDOFF_SHAPES.some((parts) => matchesParts(text, parts));
|
|
1974
|
+
function continueTextMatcher(config) {
|
|
1975
|
+
const texts = definedParts([
|
|
1976
|
+
config.continueText,
|
|
1977
|
+
config.continueTextMaxTokens,
|
|
1978
|
+
config.continueTextSilent,
|
|
1979
|
+
config.continueTextLoop,
|
|
1980
|
+
config.continueTextInterrupted,
|
|
1981
|
+
config.continueTextQuestion,
|
|
1982
|
+
config.loopText
|
|
1983
|
+
]);
|
|
1984
|
+
const guards = definedParts([config.guardPendingText, config.guardDoneText]);
|
|
1985
|
+
const shapes = texts.flatMap((text) => [text, ...guards.map((guard) => joinParts(text, " ", guard))]);
|
|
1986
|
+
return (text) => shapes.some((parts) => matchesParts(text, parts));
|
|
1987
|
+
}
|
|
1988
|
+
function messageText(content) {
|
|
1989
|
+
if (!Array.isArray(content)) return "";
|
|
1990
|
+
return content.map((block) => block?.type === "text" && typeof block.text === "string" ? block.text : "").join("");
|
|
1991
|
+
}
|
|
1939
1992
|
var LINEAGE_CACHE_LIMIT = 2e3;
|
|
1940
1993
|
var AutoContinueRunner = class {
|
|
1941
1994
|
/**
|
|
@@ -2343,8 +2396,7 @@ var AutoContinueRunner = class {
|
|
|
2343
2396
|
const state = this.state(sessionId);
|
|
2344
2397
|
if (this.tracksOutput(state, event)) {
|
|
2345
2398
|
const chunk = event.data.chunk;
|
|
2346
|
-
|
|
2347
|
-
if (visible) state.turnOutput = "visible";
|
|
2399
|
+
if (this.chunkVisible(chunk)) state.turnOutput = "visible";
|
|
2348
2400
|
else if (state.turnOutput === "empty" && chunk.type !== "usage" && chunk.type !== "finish") state.turnOutput = "silent";
|
|
2349
2401
|
}
|
|
2350
2402
|
this.onAssistantChunk(sessionId, state, event);
|
|
@@ -2361,6 +2413,9 @@ var AutoContinueRunner = class {
|
|
|
2361
2413
|
tracksOutput(state, event) {
|
|
2362
2414
|
return state.running === true && state.outputTurn === event.data.turn && event.seq > state.outputStartSeq;
|
|
2363
2415
|
}
|
|
2416
|
+
chunkVisible(chunk) {
|
|
2417
|
+
return chunk.type === "text-delta" && visibleText(chunk.text) !== "" || chunk.type === "tool-call-delta" || chunk.type === "block-end" && this.hasVisibleContent([chunk.block]) || chunk.type === "block-start" && chunk.blockType !== "reasoning" && chunk.blockType !== "text";
|
|
2418
|
+
}
|
|
2364
2419
|
/** Treat unknown block kinds conservatively: only reasoning and blank text are silent. */
|
|
2365
2420
|
hasVisibleContent(content) {
|
|
2366
2421
|
if (!Array.isArray(content)) return false;
|
|
@@ -2433,6 +2488,7 @@ var AutoContinueRunner = class {
|
|
|
2433
2488
|
const normalized = this.normalizedSegment(segment);
|
|
2434
2489
|
const config = this.getConfig();
|
|
2435
2490
|
if (normalized === "") return;
|
|
2491
|
+
if (this.noteStreamWindow(sessionId, state, normalized)) return;
|
|
2436
2492
|
if (normalized.length < config.loopShortChars) {
|
|
2437
2493
|
state.streamLastSegment = "";
|
|
2438
2494
|
state.streamRepeatRun = 0;
|
|
@@ -2452,6 +2508,25 @@ var AutoContinueRunner = class {
|
|
|
2452
2508
|
this.interruptLoop(sessionId, state);
|
|
2453
2509
|
}
|
|
2454
2510
|
}
|
|
2511
|
+
/**
|
|
2512
|
+
* 滚动窗口唯一率: 不看段长, 也不要求相邻, 所以短行交替复读(A/B/A/B)和短行
|
|
2513
|
+
* 连续复读都能命中。没有字母数字的段(分隔线、代码围栏、括号)不进窗口。
|
|
2514
|
+
* 返回 true 表示已打断。
|
|
2515
|
+
*/
|
|
2516
|
+
noteStreamWindow(sessionId, state, normalized) {
|
|
2517
|
+
if (!/[\p{L}\p{N}]/u.test(normalized)) return false;
|
|
2518
|
+
const window = state.streamWindow;
|
|
2519
|
+
window.push(normalized);
|
|
2520
|
+
if (window.length > STREAM_WINDOW_SEGMENTS) window.shift();
|
|
2521
|
+
if (window.length < STREAM_WINDOW_SEGMENTS) return false;
|
|
2522
|
+
const unique = new Set(window).size;
|
|
2523
|
+
if (unique > STREAM_WINDOW_MAX_UNIQUE) return false;
|
|
2524
|
+
this.log(
|
|
2525
|
+
`检测到流式消息内复读 ${sessionId}: 最近 ${STREAM_WINDOW_SEGMENTS} 段只有 ${unique} 种不同文本`
|
|
2526
|
+
);
|
|
2527
|
+
this.interruptLoop(sessionId, state);
|
|
2528
|
+
return state.loopFired;
|
|
2529
|
+
}
|
|
2455
2530
|
onAssistantChunk(sessionId, state, event) {
|
|
2456
2531
|
if (!this.sessionConfig(sessionId).loopGuard || !state.running || state.loopFired) return;
|
|
2457
2532
|
const chunk = this.assistantChunkText(event);
|
|
@@ -2464,7 +2539,16 @@ var AutoContinueRunner = class {
|
|
|
2464
2539
|
state.streamTail = tail;
|
|
2465
2540
|
return;
|
|
2466
2541
|
}
|
|
2467
|
-
|
|
2542
|
+
const lines = tail.split("\n");
|
|
2543
|
+
const rest = lines.pop() ?? "";
|
|
2544
|
+
for (const line of lines) {
|
|
2545
|
+
const normalized = this.normalizedSegment(line);
|
|
2546
|
+
if (normalized !== "" && this.noteStreamWindow(sessionId, state, normalized)) {
|
|
2547
|
+
state.streamTail = "";
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
state.streamTail = rest.slice(-STREAM_TAIL_MAX_CHARS);
|
|
2468
2552
|
if (/\S/u.test(tail)) {
|
|
2469
2553
|
state.streamLastSegment = "";
|
|
2470
2554
|
state.streamRepeatRun = 0;
|
|
@@ -2496,6 +2580,7 @@ var AutoContinueRunner = class {
|
|
|
2496
2580
|
if (streamTail !== "") this.noteStreamSegment(sessionId, state, streamTail);
|
|
2497
2581
|
state.streamLastSegment = "";
|
|
2498
2582
|
state.streamRepeatRun = 0;
|
|
2583
|
+
state.streamWindow = [];
|
|
2499
2584
|
this.checkLoop(sessionId, state);
|
|
2500
2585
|
}
|
|
2501
2586
|
/** 两个循环信号的公共检查; 命中且本回合未打断过则打断。 */
|
|
@@ -2558,6 +2643,7 @@ var AutoContinueRunner = class {
|
|
|
2558
2643
|
state.streamTail = "";
|
|
2559
2644
|
state.streamLastSegment = "";
|
|
2560
2645
|
state.streamRepeatRun = 0;
|
|
2646
|
+
state.streamWindow = [];
|
|
2561
2647
|
state.loopFired = false;
|
|
2562
2648
|
state.turnOutput = "empty";
|
|
2563
2649
|
state.outputTurn = event.data.turn;
|
|
@@ -2627,6 +2713,7 @@ var AutoContinueRunner = class {
|
|
|
2627
2713
|
state.streamTail = "";
|
|
2628
2714
|
state.streamLastSegment = "";
|
|
2629
2715
|
state.streamRepeatRun = 0;
|
|
2716
|
+
state.streamWindow = [];
|
|
2630
2717
|
state.tools.resetRepeat();
|
|
2631
2718
|
const cooldown = this.cooldownFor(state);
|
|
2632
2719
|
const remaining = cooldown - (Date.now() - state.lastAttemptAt);
|
|
@@ -2927,7 +3014,7 @@ var AutoContinueRunner = class {
|
|
|
2927
3014
|
* The child's own recovery mode decides; the parent only has to be alive to
|
|
2928
3015
|
* authorize the call.
|
|
2929
3016
|
*/
|
|
2930
|
-
async reviveChild(sessionId, reason, text, force) {
|
|
3017
|
+
async reviveChild(sessionId, reason, text, force, checkGoal) {
|
|
2931
3018
|
if (this.disposed || this.getConfig().paused) return;
|
|
2932
3019
|
if (!this.subagentRecoveryEnabled(sessionId)) return;
|
|
2933
3020
|
const state = this.state(sessionId);
|
|
@@ -2946,6 +3033,21 @@ var AutoContinueRunner = class {
|
|
|
2946
3033
|
return;
|
|
2947
3034
|
}
|
|
2948
3035
|
}
|
|
3036
|
+
if (checkGoal) {
|
|
3037
|
+
state.reviveInFlight = true;
|
|
3038
|
+
let held;
|
|
3039
|
+
try {
|
|
3040
|
+
held = await this.storedGoalHold(sessionId, config);
|
|
3041
|
+
} finally {
|
|
3042
|
+
state.reviveInFlight = false;
|
|
3043
|
+
}
|
|
3044
|
+
if (this.disposed) return;
|
|
3045
|
+
if (held !== void 0) {
|
|
3046
|
+
state.recovering = false;
|
|
3047
|
+
this.log(`冷恢复跳过 ${sessionId}: goal 处于 ${held}, 不替用户续跑`);
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
2949
3051
|
const parent = this.parentOf(sessionId);
|
|
2950
3052
|
if (parent === void 0 || parent === "") return;
|
|
2951
3053
|
const handoff = this.handoffText(sessionId, reason);
|
|
@@ -3125,14 +3227,21 @@ var AutoContinueRunner = class {
|
|
|
3125
3227
|
}
|
|
3126
3228
|
const template = this.templateFor(config, reason);
|
|
3127
3229
|
const text = this.buildContinueText(config, state, template);
|
|
3230
|
+
const resumesInterruption = !manualResume && !isLoopReason(reason) && !reason.startsWith("loop:") && !reason.endsWith(":silent") && !reason.includes("max-tokens");
|
|
3128
3231
|
const agent = this.ctx.agents.get(sessionId);
|
|
3129
3232
|
if (agent === void 0) {
|
|
3130
3233
|
if (this.isSubagentSession(sessionId) && this.subagentRecoveryEnabled(sessionId)) {
|
|
3131
|
-
void this.reviveChild(sessionId, reason, text, manualResume);
|
|
3234
|
+
void this.reviveChild(sessionId, reason, text, manualResume, resumesInterruption);
|
|
3132
3235
|
}
|
|
3133
3236
|
this.log(`跳过 ${sessionId}(${reason}): 无 live agent`);
|
|
3134
3237
|
return;
|
|
3135
3238
|
}
|
|
3239
|
+
const heldGoal = resumesInterruption ? this.heldGoalPhase(agent, config) : void 0;
|
|
3240
|
+
if (heldGoal !== void 0) {
|
|
3241
|
+
state.recovering = false;
|
|
3242
|
+
this.log(`跳过 ${sessionId}(${reason}): goal 处于 ${heldGoal}, 不替用户续跑`);
|
|
3243
|
+
return;
|
|
3244
|
+
}
|
|
3136
3245
|
state.lastAttemptAt = Date.now();
|
|
3137
3246
|
try {
|
|
3138
3247
|
const message = createUserMessage({
|
|
@@ -3278,15 +3387,16 @@ var AutoContinueRunner = class {
|
|
|
3278
3387
|
* - 已失败 → 不加护栏(重试工具本来就是目的)
|
|
3279
3388
|
*/
|
|
3280
3389
|
buildContinueText(config, state, template) {
|
|
3281
|
-
|
|
3390
|
+
const guard = this.currentGuard(state);
|
|
3391
|
+
const unanswered = (guard.kind === "pending" || guard.kind === "failed") && guard.tool === ASK_USER_QUESTION_TOOL;
|
|
3392
|
+
let text = fillTemplate(unanswered ? config.continueTextQuestion : template, {
|
|
3282
3393
|
facts: state.lastFailure,
|
|
3283
3394
|
tool: state.tools.lastTool(),
|
|
3284
3395
|
turn: state.lastTurn,
|
|
3285
3396
|
errorCount: state.consecutive + 1,
|
|
3286
3397
|
elapsedMs: state.lastFailureAt > 0 ? Date.now() - state.lastFailureAt : void 0
|
|
3287
3398
|
});
|
|
3288
|
-
if (!config.guardTools) return text;
|
|
3289
|
-
const guard = this.currentGuard(state);
|
|
3399
|
+
if (unanswered || !config.guardTools) return text;
|
|
3290
3400
|
if (guard.kind === "pending") {
|
|
3291
3401
|
text += ` ${fillTemplate(config.guardPendingText, { tool: guard.tool, result: guard.result })}`;
|
|
3292
3402
|
} else if (guard.kind === "done") {
|
|
@@ -3389,6 +3499,12 @@ var AutoContinueRunner = class {
|
|
|
3389
3499
|
continue;
|
|
3390
3500
|
}
|
|
3391
3501
|
}
|
|
3502
|
+
state.consecutive = Math.max(state.consecutive, this.continuationsInLog(events, config));
|
|
3503
|
+
if (state.consecutive >= config.maxConsecutive) {
|
|
3504
|
+
this.bootScannedSessions.add(session);
|
|
3505
|
+
this.log(`跳过 ${sessionId}(启动扫描): 重启前已连续自动继续 ${state.consecutive} 次, 等待用户介入或成功回合`);
|
|
3506
|
+
continue;
|
|
3507
|
+
}
|
|
3392
3508
|
candidates.push({
|
|
3393
3509
|
session,
|
|
3394
3510
|
sessionId,
|
|
@@ -3683,6 +3799,11 @@ var AutoContinueRunner = class {
|
|
|
3683
3799
|
if (events.length === 0) return;
|
|
3684
3800
|
const cause = classifyChildInterruption(events, config);
|
|
3685
3801
|
if (cause === void 0) return;
|
|
3802
|
+
const held = this.goalHold(stored.projections?.values.goal?.goal?.phase, config);
|
|
3803
|
+
if (held !== void 0) {
|
|
3804
|
+
this.log(`子会话 ${sessionId} 的 goal 处于 ${held}, 不列入 root ${rootId} 的唤醒`);
|
|
3805
|
+
return;
|
|
3806
|
+
}
|
|
3686
3807
|
const tail = events[events.length - 1];
|
|
3687
3808
|
const list = this.childInterrupts.get(rootId) ?? [];
|
|
3688
3809
|
list.push({
|
|
@@ -3738,9 +3859,14 @@ var AutoContinueRunner = class {
|
|
|
3738
3859
|
if (Date.now() - state.lastAttemptAt < this.cooldownFor(state)) return false;
|
|
3739
3860
|
const batch = children.map((child) => `${child.id}:${child.cause}`).sort().join(",");
|
|
3740
3861
|
if (this.childWoken.get(rootId) === batch) return true;
|
|
3741
|
-
if (!await this.rootAcceptsWake(rootId, deadline)) return true;
|
|
3862
|
+
if (!await this.rootAcceptsWake(rootId, config, deadline)) return true;
|
|
3742
3863
|
const agent = await this.ensureLiveAgent(rootId, deadline);
|
|
3743
3864
|
if (agent === void 0 || this.disposed) return false;
|
|
3865
|
+
const heldGoal = this.heldGoalPhase(agent, config);
|
|
3866
|
+
if (heldGoal !== void 0) {
|
|
3867
|
+
this.log(`跳过唤醒 ${rootId}: goal 处于 ${heldGoal}, 不替用户续跑`);
|
|
3868
|
+
return true;
|
|
3869
|
+
}
|
|
3744
3870
|
const text = this.buildChildResumeText(config, children);
|
|
3745
3871
|
const message = createUserMessage({
|
|
3746
3872
|
content: [{ type: "text", text }],
|
|
@@ -3756,7 +3882,7 @@ var AutoContinueRunner = class {
|
|
|
3756
3882
|
return true;
|
|
3757
3883
|
}
|
|
3758
3884
|
/** 父会话只在"干净结束"或"被宿主关闭"时接受唤醒; 用户手动停止的绝不复活。 */
|
|
3759
|
-
async rootAcceptsWake(sessionId, deadline) {
|
|
3885
|
+
async rootAcceptsWake(sessionId, config, deadline) {
|
|
3760
3886
|
const query = this.ctx.get("sessionQuery");
|
|
3761
3887
|
if (query === void 0) return false;
|
|
3762
3888
|
let events;
|
|
@@ -3787,9 +3913,14 @@ var AutoContinueRunner = class {
|
|
|
3787
3913
|
if (lastStart !== void 0 && (end === void 0 || lastStart.seq > end.seq)) return false;
|
|
3788
3914
|
if (end === void 0) return false;
|
|
3789
3915
|
const kind = readReasonKind(end.data.reason);
|
|
3790
|
-
if (kind
|
|
3791
|
-
|
|
3792
|
-
|
|
3916
|
+
if (kind !== "completed" && !(kind === "aborted" && isHostCancel(end.data.reason))) return false;
|
|
3917
|
+
const state = this.state(sessionId);
|
|
3918
|
+
state.consecutive = Math.max(state.consecutive, this.continuationsInLog(events, config));
|
|
3919
|
+
if (state.consecutive >= config.maxConsecutive) {
|
|
3920
|
+
this.log(`跳过唤醒 ${sessionId}: 重启前已连续自动继续 ${state.consecutive} 次, 等待用户介入或成功回合`);
|
|
3921
|
+
return false;
|
|
3922
|
+
}
|
|
3923
|
+
return true;
|
|
3793
3924
|
}
|
|
3794
3925
|
/** 发送需要 live agent; 存储会话沿既有物化路径拉起, 复用 preset 与模型回装。 */
|
|
3795
3926
|
async ensureLiveAgent(sessionId, deadline) {
|
|
@@ -3836,7 +3967,7 @@ var AutoContinueRunner = class {
|
|
|
3836
3967
|
*/
|
|
3837
3968
|
rearmGoal(sessionId, config) {
|
|
3838
3969
|
if (!config.resumeGoals) return;
|
|
3839
|
-
const goals = this.
|
|
3970
|
+
const goals = this.goals();
|
|
3840
3971
|
if (goals === void 0) return;
|
|
3841
3972
|
const agent = this.ctx.agents.get(sessionId);
|
|
3842
3973
|
if (agent === void 0) return;
|
|
@@ -3864,6 +3995,95 @@ var AutoContinueRunner = class {
|
|
|
3864
3995
|
);
|
|
3865
3996
|
}
|
|
3866
3997
|
}
|
|
3998
|
+
goals() {
|
|
3999
|
+
return this.ctx.get(GOALS_SERVICE_KEY);
|
|
4000
|
+
}
|
|
4001
|
+
/**
|
|
4002
|
+
* A paused or blocked goal is a decision to stop and wait; a continue sent anyway reads as the
|
|
4003
|
+
* user resuming it. `resumePausedGoals` is the user's standing permission to resume paused
|
|
4004
|
+
* goals, so it lets those through.
|
|
4005
|
+
*/
|
|
4006
|
+
heldGoalPhase(agent, config) {
|
|
4007
|
+
let phase;
|
|
4008
|
+
try {
|
|
4009
|
+
const goals = this.goals();
|
|
4010
|
+
if (goals === void 0) return void 0;
|
|
4011
|
+
phase = goals.get(agent)?.phase;
|
|
4012
|
+
} catch {
|
|
4013
|
+
return "unreadable";
|
|
4014
|
+
}
|
|
4015
|
+
return this.goalHold(phase, config);
|
|
4016
|
+
}
|
|
4017
|
+
goalHold(phase, config) {
|
|
4018
|
+
if (phase === "blocked") return phase;
|
|
4019
|
+
if (phase === "paused" && !(config.resumeGoals && config.resumePausedGoals)) return phase;
|
|
4020
|
+
return void 0;
|
|
4021
|
+
}
|
|
4022
|
+
/** `heldGoalPhase` for a session without a live agent, read from its stored goal projection. */
|
|
4023
|
+
async storedGoalHold(sessionId, config) {
|
|
4024
|
+
if (this.goals() === void 0) return void 0;
|
|
4025
|
+
const query = this.ctx.get("sessionQuery");
|
|
4026
|
+
if (query === void 0) return "unreadable";
|
|
4027
|
+
let stored;
|
|
4028
|
+
try {
|
|
4029
|
+
const observation = await this.readStored(
|
|
4030
|
+
(signal) => query.observeSession(sessionId, { projectionMode: "all", signal }),
|
|
4031
|
+
Date.now() + STORED_READ_TIMEOUT_MS
|
|
4032
|
+
);
|
|
4033
|
+
stored = observation;
|
|
4034
|
+
return this.goalHold(observation.projections?.values.goal?.goal?.phase, config);
|
|
4035
|
+
} catch (error) {
|
|
4036
|
+
if (error?.code === "SESSION_QUERY_SESSION_NOT_FOUND") return void 0;
|
|
4037
|
+
return "unreadable";
|
|
4038
|
+
} finally {
|
|
4039
|
+
stored?.[Symbol.dispose]?.();
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Continuations this plugin sent since the last message from the user, manual stop or turn
|
|
4044
|
+
* with visible output, read from the log so the consecutive cap survives a host restart.
|
|
4045
|
+
* Mirrors the in-memory count: a continuation right after a visible completion is a loop
|
|
4046
|
+
* round and does not count. With `usePluginSource` off a continuation is a `user` message
|
|
4047
|
+
* matching one of the configured continue texts, so a user message identical to one of them
|
|
4048
|
+
* is counted too; that can only stop recovery earlier, never later.
|
|
4049
|
+
*/
|
|
4050
|
+
continuationsInLog(events, config) {
|
|
4051
|
+
const ours = continueTextMatcher(config);
|
|
4052
|
+
let count = 0;
|
|
4053
|
+
let visible = false;
|
|
4054
|
+
let maintenance = false;
|
|
4055
|
+
let afterSuccess = false;
|
|
4056
|
+
for (const event of events) {
|
|
4057
|
+
if (event.type === "turn/start") {
|
|
4058
|
+
visible = false;
|
|
4059
|
+
maintenance = isMaintenanceTurnStart(event);
|
|
4060
|
+
} else if (event.type === "tool/call") {
|
|
4061
|
+
visible = true;
|
|
4062
|
+
} else if (event.type === "assistant/chunk") {
|
|
4063
|
+
if (this.chunkVisible(event.data.chunk)) visible = true;
|
|
4064
|
+
} else if (event.type === "assistant/message") {
|
|
4065
|
+
if (this.hasVisibleContent(event.data.message?.content)) visible = true;
|
|
4066
|
+
} else if (event.type === "turn/end") {
|
|
4067
|
+
if (maintenance) continue;
|
|
4068
|
+
const reason = event.data.reason;
|
|
4069
|
+
const kind = readReasonKind(reason);
|
|
4070
|
+
afterSuccess = kind === "completed" && visible;
|
|
4071
|
+
const userStop = kind === "aborted" && !isHostCancel(reason) && !isLoopGuardCancelReason(reason.reason);
|
|
4072
|
+
if (afterSuccess || userStop) count = 0;
|
|
4073
|
+
} else if (event.type === "user/message") {
|
|
4074
|
+
const source = event.data.source?.kind;
|
|
4075
|
+
const text = messageText(event.data.content);
|
|
4076
|
+
if (isHandoffText(text)) continue;
|
|
4077
|
+
if (source === AUTO_CONTINUE_SOURCE_KIND || source === "user" && ours(text)) {
|
|
4078
|
+
if (!afterSuccess) count += 1;
|
|
4079
|
+
} else if (source === "user") {
|
|
4080
|
+
count = 0;
|
|
4081
|
+
}
|
|
4082
|
+
if (source === AUTO_CONTINUE_SOURCE_KIND || source === "user") afterSuccess = false;
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
return count;
|
|
4086
|
+
}
|
|
3867
4087
|
/**
|
|
3868
4088
|
* 按会话记录的 preset 组合把存储会话恢复为 live agent(镜像会话控制
|
|
3869
4089
|
* 器的 adopt 路径: preset 挂载 + 会话已记录的模型选择回装)。模型选择
|
|
@@ -10285,6 +10505,8 @@ var settingsFields = {
|
|
|
10285
10505
|
continueTextLoop: z2.string().default(""),
|
|
10286
10506
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
10287
10507
|
continueTextInterrupted: z2.string().default(""),
|
|
10508
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
10509
|
+
continueTextQuestion: z2.string().default(""),
|
|
10288
10510
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
10289
10511
|
guardTools: z2.boolean().default(true),
|
|
10290
10512
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -75,6 +75,9 @@ export declare const zh: {
|
|
|
75
75
|
'field.continueTextInterrupted': string;
|
|
76
76
|
'field.continueTextInterruptedHint': string;
|
|
77
77
|
'default.continueTextInterrupted': "继续。宿主在你上一轮运行期间重启了; 重启时未完成的工具调用已按「结果未知」收尾。从中断处继续, 重试可能有副作用的操作前先核实外部状态。";
|
|
78
|
+
'field.continueTextQuestion': string;
|
|
79
|
+
'field.continueTextQuestionHint': string;
|
|
80
|
+
'default.continueTextQuestion': "这是宿主重启后插件自动发送的消息, 不是用户的回复。你上一步向用户提出的问题因重启中断, 用户还没有回答。请重新提出同一个问题并等待回答, 不要替用户做决定。";
|
|
78
81
|
'field.guardTools': string;
|
|
79
82
|
'field.guardToolsHint': string;
|
|
80
83
|
'field.guardPendingText': string;
|
|
@@ -27,6 +27,7 @@ export interface AutoContinueSettingsCardState extends CardShell {
|
|
|
27
27
|
continueTextLoop: CardFieldState;
|
|
28
28
|
continueTextSilent: CardFieldState;
|
|
29
29
|
continueTextInterrupted: CardFieldState;
|
|
30
|
+
continueTextQuestion: CardFieldState;
|
|
30
31
|
guardTools: CardFieldState;
|
|
31
32
|
guardPendingText: CardFieldState;
|
|
32
33
|
guardDoneText: CardFieldState;
|
|
@@ -155,6 +155,7 @@ export declare class AutoContinueRunner {
|
|
|
155
155
|
*/
|
|
156
156
|
private onHostEvent;
|
|
157
157
|
private tracksOutput;
|
|
158
|
+
private chunkVisible;
|
|
158
159
|
/** Treat unknown block kinds conservatively: only reasoning and blank text are silent. */
|
|
159
160
|
private hasVisibleContent;
|
|
160
161
|
/** 从 assistant/message 事件提取纯文本。 */
|
|
@@ -164,6 +165,12 @@ export declare class AutoContinueRunner {
|
|
|
164
165
|
private isNearDuplicateSegment;
|
|
165
166
|
private withinEditDistance;
|
|
166
167
|
private noteStreamSegment;
|
|
168
|
+
/**
|
|
169
|
+
* 滚动窗口唯一率: 不看段长, 也不要求相邻, 所以短行交替复读(A/B/A/B)和短行
|
|
170
|
+
* 连续复读都能命中。没有字母数字的段(分隔线、代码围栏、括号)不进窗口。
|
|
171
|
+
* 返回 true 表示已打断。
|
|
172
|
+
*/
|
|
173
|
+
private noteStreamWindow;
|
|
167
174
|
private onAssistantChunk;
|
|
168
175
|
private onAssistantMessage;
|
|
169
176
|
/** 两个循环信号的公共检查; 命中且本回合未打断过则打断。 */
|
|
@@ -299,6 +306,25 @@ export declare class AutoContinueRunner {
|
|
|
299
306
|
* resume 能重新 arm; paused 则是人类的显式决定。两者都默认关闭。
|
|
300
307
|
*/
|
|
301
308
|
private rearmGoal;
|
|
309
|
+
private goals;
|
|
310
|
+
/**
|
|
311
|
+
* A paused or blocked goal is a decision to stop and wait; a continue sent anyway reads as the
|
|
312
|
+
* user resuming it. `resumePausedGoals` is the user's standing permission to resume paused
|
|
313
|
+
* goals, so it lets those through.
|
|
314
|
+
*/
|
|
315
|
+
private heldGoalPhase;
|
|
316
|
+
private goalHold;
|
|
317
|
+
/** `heldGoalPhase` for a session without a live agent, read from its stored goal projection. */
|
|
318
|
+
private storedGoalHold;
|
|
319
|
+
/**
|
|
320
|
+
* Continuations this plugin sent since the last message from the user, manual stop or turn
|
|
321
|
+
* with visible output, read from the log so the consecutive cap survives a host restart.
|
|
322
|
+
* Mirrors the in-memory count: a continuation right after a visible completion is a loop
|
|
323
|
+
* round and does not count. With `usePluginSource` off a continuation is a `user` message
|
|
324
|
+
* matching one of the configured continue texts, so a user message identical to one of them
|
|
325
|
+
* is counted too; that can only stop recovery earlier, never later.
|
|
326
|
+
*/
|
|
327
|
+
private continuationsInLog;
|
|
302
328
|
/**
|
|
303
329
|
* 按会话记录的 preset 组合把存储会话恢复为 live agent(镜像会话控制
|
|
304
330
|
* 器的 adopt 路径: preset 挂载 + 会话已记录的模型选择回装)。模型选择
|
package/lib/types/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
37
37
|
continueTextLoop: z<string, string>;
|
|
38
38
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
39
39
|
continueTextInterrupted: z<string, string>;
|
|
40
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
41
|
+
continueTextQuestion: z<string, string>;
|
|
40
42
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
41
43
|
guardTools: z<boolean, boolean>;
|
|
42
44
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -120,6 +122,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
120
122
|
continueTextLoop: z<string, string>;
|
|
121
123
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
122
124
|
continueTextInterrupted: z<string, string>;
|
|
125
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
126
|
+
continueTextQuestion: z<string, string>;
|
|
123
127
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
124
128
|
guardTools: z<boolean, boolean>;
|
|
125
129
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -206,6 +210,8 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
206
210
|
continueTextLoop: z<string, string>;
|
|
207
211
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
208
212
|
continueTextInterrupted: z<string, string>;
|
|
213
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
214
|
+
continueTextQuestion: z<string, string>;
|
|
209
215
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
210
216
|
guardTools: z<boolean, boolean>;
|
|
211
217
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -289,6 +295,8 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
289
295
|
continueTextLoop: z<string, string>;
|
|
290
296
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
291
297
|
continueTextInterrupted: z<string, string>;
|
|
298
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
299
|
+
continueTextQuestion: z<string, string>;
|
|
292
300
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
293
301
|
guardTools: z<boolean, boolean>;
|
|
294
302
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -35,6 +35,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
35
35
|
readonly continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。";
|
|
36
36
|
readonly continueTextLoop: "继续";
|
|
37
37
|
readonly continueTextInterrupted: "继续。宿主在你上一轮运行期间重启了; 重启时未完成的工具调用已按「结果未知」收尾。从中断处继续, 重试可能有副作用的操作前先核实外部状态。";
|
|
38
|
+
readonly continueTextQuestion: "这是宿主重启后插件自动发送的消息, 不是用户的回复。你上一步向用户提出的问题因重启中断, 用户还没有回答。请重新提出同一个问题并等待回答, 不要替用户做决定。";
|
|
38
39
|
readonly guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)";
|
|
39
40
|
readonly guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)";
|
|
40
41
|
readonly loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)";
|
|
@@ -45,6 +46,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
45
46
|
readonly continueTextSilent: "Continue. Your previous turn ended with internal reasoning only, with no message and no tool call, so nothing reached the user. Always finish a turn with a tool call or a visible answer.";
|
|
46
47
|
readonly continueTextLoop: "Continue";
|
|
47
48
|
readonly continueTextInterrupted: "Continue. The harness was restarted while your previous turn was still running; tool calls pending at the restart are recorded with unknown outcomes. Resume where you left off, verifying external state before retrying anything that may have side effects.";
|
|
49
|
+
readonly continueTextQuestion: "This message was sent automatically by the plugin after a harness restart; it is not the user's reply. The question you asked the user was cut off by the restart and has not been answered. Ask the same question again and wait for the answer; do not decide for the user.";
|
|
48
50
|
readonly guardPendingText: "(The previous tool \"{tool}\" may not have completed. Check its state before continuing and do not run it again.)";
|
|
49
51
|
readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
|
|
50
52
|
readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
|
|
@@ -55,6 +57,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
55
57
|
readonly continueTextSilent: "Продолжай. Предыдущий ход закончился только внутренним рассуждением: ни ответа, ни вызова инструмента, поэтому пользователь ничего не увидел. Каждый ход должен заканчиваться вызовом инструмента или видимым ответом.";
|
|
56
58
|
readonly continueTextLoop: "Продолжай";
|
|
57
59
|
readonly continueTextInterrupted: "Продолжай. Хост перезапустился, пока предыдущий ход ещё выполнялся; вызовы инструментов, незавершённые на момент перезапуска, записаны с неизвестным результатом. Продолжай с места остановки, проверяя внешнее состояние перед повтором действий с возможными побочными эффектами.";
|
|
60
|
+
readonly continueTextQuestion: "Это сообщение плагин отправил автоматически после перезапуска хоста, это не ответ пользователя. Вопрос, который ты задал пользователю, прервался из-за перезапуска, и ответа на него ещё нет. Задай тот же вопрос снова и дождись ответа, не принимай решение за пользователя.";
|
|
58
61
|
readonly guardPendingText: "(Предыдущий инструмент «{tool}», возможно, не завершился. Проверь его состояние перед продолжением и не запускай его повторно.)";
|
|
59
62
|
readonly guardDoneText: "(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)";
|
|
60
63
|
readonly loopText: "(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)";
|
|
@@ -82,6 +85,8 @@ export interface AutoContinueSettings {
|
|
|
82
85
|
continueTextLoop?: string;
|
|
83
86
|
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
84
87
|
continueTextInterrupted?: string;
|
|
88
|
+
/** Text sent instead of a continue text (and its guard note) while the user has not answered the last `ask_user_question`. */
|
|
89
|
+
continueTextQuestion?: string;
|
|
85
90
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
86
91
|
guardTools?: boolean;
|
|
87
92
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -394,6 +399,8 @@ export interface SessionState {
|
|
|
394
399
|
streamLastSegment: string;
|
|
395
400
|
/** 流式消息内连续近似重复长段计数。 */
|
|
396
401
|
streamRepeatRun: number;
|
|
402
|
+
/** 流式消息最近若干段(或超长段的行)的归一化文本, 用于唯一率检测。 */
|
|
403
|
+
streamWindow: string[];
|
|
397
404
|
/** 本回合已触发过 loop guard(防重复打断)。 */
|
|
398
405
|
loopFired: boolean;
|
|
399
406
|
/** loop 重启的延迟定时器(冷却结束后再 schedule)。 */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-auto-continue",
|
|
3
3
|
"description": "Automatically resume interrupted DSH conversations, with an optional autonomous loop.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typecheck": "tsc --noEmit",
|
|
53
53
|
"docs:assets": "node scripts/build-docs-assets.mjs",
|
|
54
54
|
"test:runtime": "node tests/settings-host-live.mjs 0.1.7 && node tests/settings-host-live.mjs 0.2.0 && node tests/settings-host-live.mjs 0.2.1 && node tests/profile-compatibility.mjs 0.2.0 && node tests/profile-compatibility.mjs 0.2.1 && node tests/client-settings-services.mjs 0.2.0 && node tests/client-settings-services.mjs 0.2.1 && node tests/boot-scan-host-live.mjs 0.2.0-rc.2 && node tests/boot-scan-host-live.mjs 0.2.1 && node tests/settings-host-live.mjs 0.2.1-rc.2 && node tests/profile-compatibility.mjs 0.2.1-rc.2 && node tests/boot-scan-restart-live.mjs 0.2.1-rc.2 && node tests/boot-scan-restart-live.mjs 0.2.2-rc.1 && node tests/boot-scan-restart-live.mjs 0.2.2-rc.1 dispose && node tests/settings-host-live.mjs 0.2.1-rc.2 mixed && node tests/settings-migration.mjs",
|
|
55
|
-
"test": "node tests/echo-matching.mjs && node tests/boot-scan-stored-sweep.mjs && node tests/child-resume-scan.mjs && node tests/offline-and-loop-cap.mjs && node tests/loop-guard-progress.mjs && node tests/scan-on-boot.mjs && node tests/boot-scan-isolation.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/session-modes.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/failure-classification.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/settings-card-native.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs && node tests/maintenance-turns.mjs && node tests/publish-prerelease.mjs",
|
|
55
|
+
"test": "node tests/echo-matching.mjs && node tests/boot-scan-stored-sweep.mjs && node tests/restart-resume-guards.mjs && node tests/child-resume-scan.mjs && node tests/offline-and-loop-cap.mjs && node tests/loop-guard-progress.mjs && node tests/scan-on-boot.mjs && node tests/boot-scan-isolation.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/session-modes.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/failure-classification.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/settings-card-native.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs && node tests/maintenance-turns.mjs && node tests/publish-prerelease.mjs",
|
|
56
56
|
"prepack": "npm run build"
|
|
57
57
|
},
|
|
58
58
|
"keywords": [
|