dsh-client-auto-continue 0.14.3 → 0.16.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 +35 -0
- package/README.md +44 -22
- package/README.zh.md +44 -22
- package/docs/releases/v0.16.0.md +75 -0
- package/docs/third-party-notices.md +19 -0
- package/lib/client.js +196 -49
- package/lib/client.js.map +2 -2
- package/lib/index.js +7776 -104
- package/lib/types/client/bridge.d.ts +4 -0
- package/lib/types/client/composer-toggle.d.ts +6 -4
- package/lib/types/client/index.d.ts +2 -2
- package/lib/types/client/locales.d.ts +21 -0
- package/lib/types/client/settings-card.d.ts +6 -4
- package/lib/types/host/engine.d.ts +29 -1
- package/lib/types/host/settings-migration.d.ts +14 -0
- package/lib/types/index.d.ts +22 -8
- package/lib/types/shared/core.d.ts +24 -1
- package/package.json +21 -13
- package/src/client/bridge.ts +43 -4
- package/src/client/composer-toggle.tsx +20 -12
- package/src/client/index.ts +5 -2
- package/src/client/locales.ts +56 -14
- package/src/client/settings-card.tsx +58 -18
- package/src/client/styles.ts +5 -1
- package/src/host/engine.ts +307 -24
- package/src/host/settings-migration.ts +117 -0
- package/src/index.ts +66 -12
- package/src/shared/core.ts +42 -1
package/lib/client.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
apply: () => apply,
|
|
30
30
|
inject: () => inject,
|
|
31
31
|
pausedSessions: () => pausedSessions,
|
|
32
|
+
readRecoveryAttempts: () => readRecoveryAttempts,
|
|
32
33
|
readTodayStats: () => readTodayStats,
|
|
33
34
|
resetTodayStats: () => resetTodayStats,
|
|
34
35
|
unpauseSession: () => unpauseSession
|
|
@@ -36,12 +37,17 @@ __export(index_exports, {
|
|
|
36
37
|
module.exports = __toCommonJS(index_exports);
|
|
37
38
|
|
|
38
39
|
// src/shared/core.ts
|
|
40
|
+
var isSessionMode = (value) => value === "default" || value === "off" || value === "recover" || value === "loop";
|
|
41
|
+
function sessionMode(modes, sessionId) {
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(modes, sessionId) && isSessionMode(modes[sessionId]) ? modes[sessionId] : "default";
|
|
43
|
+
}
|
|
39
44
|
var LOCALIZED_TEXT_DEFAULTS = {
|
|
40
45
|
zh: {
|
|
41
46
|
continueText: "继续",
|
|
42
47
|
continueTextMaxTokens: "继续",
|
|
43
48
|
continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。",
|
|
44
49
|
continueTextLoop: "继续",
|
|
50
|
+
continueTextInterrupted: "继续。宿主在你上一轮运行期间重启了; 重启时未完成的工具调用已按「结果未知」收尾。从中断处继续, 重试可能有副作用的操作前先核实外部状态。",
|
|
45
51
|
guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)",
|
|
46
52
|
guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)",
|
|
47
53
|
loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)"
|
|
@@ -51,6 +57,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
|
|
|
51
57
|
continueTextMaxTokens: "Continue",
|
|
52
58
|
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.",
|
|
53
59
|
continueTextLoop: "Continue",
|
|
60
|
+
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.",
|
|
54
61
|
guardPendingText: '(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)',
|
|
55
62
|
guardDoneText: '(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)',
|
|
56
63
|
loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)"
|
|
@@ -76,6 +83,7 @@ var DEFAULT_CONFIG = {
|
|
|
76
83
|
backoffMaxMs: 3e5,
|
|
77
84
|
notify: false,
|
|
78
85
|
paused: false,
|
|
86
|
+
sessionModes: {},
|
|
79
87
|
showComposerToggle: true,
|
|
80
88
|
loopGuard: true,
|
|
81
89
|
loopShortChars: 40,
|
|
@@ -118,11 +126,17 @@ var zh = {
|
|
|
118
126
|
"category.safety.description": "避免重复执行工具,识别并打断无效循环。",
|
|
119
127
|
"category.status.title": "状态与日志",
|
|
120
128
|
"category.status.description": "查看活动记录与暂停的会话。",
|
|
121
|
-
"field.paused": "
|
|
122
|
-
"field.showComposerToggle": "
|
|
123
|
-
"field.showComposerToggleHint": "
|
|
129
|
+
"field.paused": "全局启用自动继续",
|
|
130
|
+
"field.showComposerToggle": "在会话区显示模式选择",
|
|
131
|
+
"field.showComposerToggleHint": "默认显示。隐藏控件不会改变会话模式;点击保存后生效。",
|
|
124
132
|
"composer.label": "自动继续",
|
|
125
|
-
"composer.scope": "
|
|
133
|
+
"composer.scope": "只控制当前会话,立即保存并同步到其他标签页。关闭后也不再自动打断循环。",
|
|
134
|
+
"composer.default": "跟随默认",
|
|
135
|
+
"composer.off": "关闭",
|
|
136
|
+
"composer.recover": "仅故障恢复",
|
|
137
|
+
"composer.loop": "自主循环",
|
|
138
|
+
"composer.paused": "全局已暂停",
|
|
139
|
+
"composer.unavailable": "等待宿主连接",
|
|
126
140
|
"composer.saving": "正在保存自动继续设置…",
|
|
127
141
|
"composer.saveFailed": "保存失败,请重试",
|
|
128
142
|
"field.pausedHint": "恢复意外中断的会话。关闭并保存后,全局暂停恢复并取消已排队的继续。循环守卫独立运行;如需停止自动打断,请同时关闭循环守卫。",
|
|
@@ -134,14 +148,17 @@ var zh = {
|
|
|
134
148
|
"default.continueTextMaxTokens": LOCALIZED_TEXT_DEFAULTS.zh.continueTextMaxTokens,
|
|
135
149
|
"field.resumeSilentTurns": "续跑无输出回合",
|
|
136
150
|
"field.resumeSilentTurnsHint": "已观察到模型活动但没有可见输出时续跑;不把空回合、图片或扩展内容误判为静默,冷却与连续上限照常生效。",
|
|
137
|
-
"field.resumeCompletedTurns": "
|
|
138
|
-
"field.resumeCompletedTurnsHint": "
|
|
151
|
+
"field.resumeCompletedTurns": "默认会话模式",
|
|
152
|
+
"field.resumeCompletedTurnsHint": "用于没有单独设置模式的会话。仅故障恢复不会接力正常完成的回合;自主循环会在正常完成后继续。无输出和失败回合仍受重试预算约束。",
|
|
139
153
|
"field.continueTextLoop": "自主循环的继续文本",
|
|
140
154
|
"field.continueTextLoopHint": "自主循环每次续跑时发送的文本。",
|
|
141
155
|
"default.continueTextLoop": LOCALIZED_TEXT_DEFAULTS.zh.continueTextLoop,
|
|
142
156
|
"field.continueTextSilent": "无输出回合的继续文本",
|
|
143
157
|
"field.continueTextSilentHint": "回合只输出推理就结束时自动发送的文本, 支持与继续文本相同的占位符。",
|
|
144
158
|
"default.continueTextSilent": LOCALIZED_TEXT_DEFAULTS.zh.continueTextSilent,
|
|
159
|
+
"field.continueTextInterrupted": "宿主重启后恢复的继续文本",
|
|
160
|
+
"field.continueTextInterruptedHint": "启动扫描恢复重启中断的会话时发送的文本, 默认说明重启并提醒先核实再重试。",
|
|
161
|
+
"default.continueTextInterrupted": LOCALIZED_TEXT_DEFAULTS.zh.continueTextInterrupted,
|
|
145
162
|
"field.guardTools": "幂等护栏",
|
|
146
163
|
"field.guardToolsHint": "续跑前检查上一步工具调用: 结果未确认时提示先确认状态, 已成功时提示不要重复执行, 避免重复 commit/调 API。",
|
|
147
164
|
"field.guardPendingText": "结果未确认时的护栏文本",
|
|
@@ -157,7 +174,7 @@ var zh = {
|
|
|
157
174
|
"field.maxConsecutive": "最大连续次数",
|
|
158
175
|
"field.maxConsecutiveHint": "连续恢复尝试上限;用户介入或观察到有可见输出的成功回合后清零。正常完成后的自主循环接力不计入。",
|
|
159
176
|
"field.scanOnBoot": "启动恢复扫描",
|
|
160
|
-
"field.scanOnBootHint": "
|
|
177
|
+
"field.scanOnBootHint": "宿主启动后在扫描时间窗内等待延迟加载的中断会话,未重新加载的持久化会话也会被物化一并检查,每个已就绪会话只检查一次。",
|
|
161
178
|
"field.scanLimit": "扫描会话数",
|
|
162
179
|
"field.scanLimitHint": "每次扫描最多恢复多少个符合条件的会话,优先最近活动的会话。",
|
|
163
180
|
"field.freshMs": "扫描时间窗 (ms)",
|
|
@@ -200,6 +217,18 @@ var zh = {
|
|
|
200
217
|
"stats.byCode": "按错误码统计",
|
|
201
218
|
"stats.empty": "今天还没有自动继续记录。",
|
|
202
219
|
"stats.reset": "清零",
|
|
220
|
+
"recovery.title": "近期恢复尝试",
|
|
221
|
+
"recovery.hint": "按会话汇总宿主最近 20 次恢复提示,重启插件后清空。正常自主续跑不计入。提示已发送不代表任务已完成;若反复恢复,请检查会话并考虑交接到新会话。",
|
|
222
|
+
"recovery.empty": "尚无恢复尝试。",
|
|
223
|
+
"recovery.count": "窗口内尝试",
|
|
224
|
+
"recovery.consecutive": "最近发送时连续次数",
|
|
225
|
+
"recovery.latest": "最近原因",
|
|
226
|
+
"recovery.reason.error": "请求错误",
|
|
227
|
+
"recovery.reason.max-tokens": "输出上限",
|
|
228
|
+
"recovery.reason.silent": "无可见输出",
|
|
229
|
+
"recovery.reason.interrupted": "宿主重启中断",
|
|
230
|
+
"recovery.reason.loop-guard": "循环守卫",
|
|
231
|
+
"recovery.reason.manual": "手动立即续跑",
|
|
203
232
|
"pause.title": "已暂停会话",
|
|
204
233
|
"pause.none": "没有暂停中的会话。",
|
|
205
234
|
"pause.clearAll": "全部解除",
|
|
@@ -250,11 +279,17 @@ var en = {
|
|
|
250
279
|
"category.safety.description": "Avoid duplicate tool actions and break unproductive loops.",
|
|
251
280
|
"category.status.title": "Status and logs",
|
|
252
281
|
"category.status.description": "View activity and paused sessions.",
|
|
253
|
-
"field.paused": "
|
|
254
|
-
"field.showComposerToggle": "Show
|
|
255
|
-
"field.showComposerToggleHint": "Shown by default. Hiding the
|
|
282
|
+
"field.paused": "Enable auto-continue globally",
|
|
283
|
+
"field.showComposerToggle": "Show session mode in the composer",
|
|
284
|
+
"field.showComposerToggleHint": "Shown by default. Hiding the control does not change session modes. Click Save to apply.",
|
|
256
285
|
"composer.label": "Auto-continue",
|
|
257
|
-
"composer.scope": "
|
|
286
|
+
"composer.scope": "Only affects this session. Saved immediately and synced across tabs. Off also disables loop-guard interruptions here.",
|
|
287
|
+
"composer.default": "Follow default",
|
|
288
|
+
"composer.off": "Off",
|
|
289
|
+
"composer.recover": "Recovery only",
|
|
290
|
+
"composer.loop": "Autonomous loop",
|
|
291
|
+
"composer.paused": "Globally paused",
|
|
292
|
+
"composer.unavailable": "Waiting for host",
|
|
258
293
|
"composer.saving": "Saving auto-continue setting…",
|
|
259
294
|
"composer.saveFailed": "Could not save. Try again.",
|
|
260
295
|
"field.pausedHint": "Resume interrupted sessions. Turn off and save to pause recovery globally and cancel queued continuations. The loop guard stays active; turn it off separately to stop automatic interruptions.",
|
|
@@ -266,14 +301,17 @@ var en = {
|
|
|
266
301
|
"default.continueTextMaxTokens": LOCALIZED_TEXT_DEFAULTS.en.continueTextMaxTokens,
|
|
267
302
|
"field.resumeSilentTurns": "Resume silent turns",
|
|
268
303
|
"field.resumeSilentTurnsHint": "Resume observed model activity without visible output. No-op turns, images and extension blocks are not treated as silent; cooldown and retry limits still apply.",
|
|
269
|
-
"field.resumeCompletedTurns": "
|
|
270
|
-
"field.resumeCompletedTurnsHint": "
|
|
304
|
+
"field.resumeCompletedTurns": "Default session mode",
|
|
305
|
+
"field.resumeCompletedTurnsHint": "Applies to sessions without their own mode. Recovery only leaves normal completions alone; autonomous loop continues after them. Silent and failed turns still consume the retry budget.",
|
|
271
306
|
"field.continueTextLoop": "Continue text (autonomous loop)",
|
|
272
307
|
"field.continueTextLoopHint": "Text sent on each autonomous-loop continuation.",
|
|
273
308
|
"default.continueTextLoop": LOCALIZED_TEXT_DEFAULTS.en.continueTextLoop,
|
|
274
309
|
"field.continueTextSilent": "Continue text (silent turn)",
|
|
275
310
|
"field.continueTextSilentHint": "Text sent when a turn ends with reasoning only; same placeholders as the continue text.",
|
|
276
311
|
"default.continueTextSilent": LOCALIZED_TEXT_DEFAULTS.en.continueTextSilent,
|
|
312
|
+
"field.continueTextInterrupted": "Continue text (after harness restart)",
|
|
313
|
+
"field.continueTextInterruptedHint": "Text sent when the boot scan resumes a session interrupted by a restart; the default explains the restart and asks to verify before retrying.",
|
|
314
|
+
"default.continueTextInterrupted": LOCALIZED_TEXT_DEFAULTS.en.continueTextInterrupted,
|
|
277
315
|
"field.guardTools": "Idempotency guard",
|
|
278
316
|
"field.guardToolsHint": "Before resuming, inspect the last tool call: if its result is unconfirmed, tell the model to check state first; if it succeeded, tell it not to rerun — avoids duplicate commits / API calls.",
|
|
279
317
|
"field.guardPendingText": "Guard text (unconfirmed result)",
|
|
@@ -289,7 +327,7 @@ var en = {
|
|
|
289
327
|
"field.maxConsecutive": "Max consecutive",
|
|
290
328
|
"field.maxConsecutiveHint": "Consecutive recovery-attempt cap; resets on user intervention or an observed completion with visible output. Normal autonomous-loop handoffs are exempt.",
|
|
291
329
|
"field.scanOnBoot": "Scan on host startup",
|
|
292
|
-
"field.scanOnBootHint": "Wait for delayed interrupted sessions during the startup scan window;
|
|
330
|
+
"field.scanOnBootHint": "Wait for delayed interrupted sessions during the startup scan window; persisted sessions the host never reloaded are materialized and inspected too; each settled session is inspected once.",
|
|
293
331
|
"field.scanLimit": "Scan limit",
|
|
294
332
|
"field.scanLimitHint": "Maximum eligible sessions to recover per pass, most recently active first.",
|
|
295
333
|
"field.freshMs": "Scan window (ms)",
|
|
@@ -332,6 +370,18 @@ var en = {
|
|
|
332
370
|
"stats.byCode": "By error code",
|
|
333
371
|
"stats.empty": "No auto-continue activity today.",
|
|
334
372
|
"stats.reset": "Reset",
|
|
373
|
+
"recovery.title": "Recent recovery attempts",
|
|
374
|
+
"recovery.hint": "Per-session counts from the last 20 recovery prompts across this host, cleared when the plugin restarts. Normal autonomous continuations are excluded. A sent prompt does not mean the task finished. If recovery keeps repeating, review the conversation and consider handing off to a fresh session.",
|
|
375
|
+
"recovery.empty": "No recovery attempts yet.",
|
|
376
|
+
"recovery.count": "Attempts in window",
|
|
377
|
+
"recovery.consecutive": "Consecutive at last send",
|
|
378
|
+
"recovery.latest": "Latest reason",
|
|
379
|
+
"recovery.reason.error": "Request error",
|
|
380
|
+
"recovery.reason.max-tokens": "Output limit",
|
|
381
|
+
"recovery.reason.silent": "No visible output",
|
|
382
|
+
"recovery.reason.interrupted": "Host restart interruption",
|
|
383
|
+
"recovery.reason.loop-guard": "Loop guard",
|
|
384
|
+
"recovery.reason.manual": "Manual resume",
|
|
335
385
|
"pause.title": "Paused sessions",
|
|
336
386
|
"pause.none": "No sessions paused.",
|
|
337
387
|
"pause.clearAll": "Clear all",
|
|
@@ -407,7 +457,7 @@ var EMPTY_STATS = {
|
|
|
407
457
|
looped: 0,
|
|
408
458
|
byCode: {}
|
|
409
459
|
};
|
|
410
|
-
var state = { stats: EMPTY_STATS, paused: [] };
|
|
460
|
+
var state = { stats: EMPTY_STATS, paused: [], recoveryAttempts: [] };
|
|
411
461
|
var listeners = /* @__PURE__ */ new Set();
|
|
412
462
|
function pausedSessions() {
|
|
413
463
|
return state.paused;
|
|
@@ -415,6 +465,24 @@ function pausedSessions() {
|
|
|
415
465
|
function readTodayStats() {
|
|
416
466
|
return state.stats;
|
|
417
467
|
}
|
|
468
|
+
function readRecoveryAttempts() {
|
|
469
|
+
return state.recoveryAttempts;
|
|
470
|
+
}
|
|
471
|
+
function readSessionPolicy() {
|
|
472
|
+
return state.sessionPolicy;
|
|
473
|
+
}
|
|
474
|
+
async function setSessionMode(sessionId, mode) {
|
|
475
|
+
if (!state.sessionPolicy?.writable) throw new Error("Session settings are unavailable");
|
|
476
|
+
const response = await fetch("/api/auto-continue-action", {
|
|
477
|
+
method: "POST",
|
|
478
|
+
headers: { "content-type": "application/json" },
|
|
479
|
+
body: JSON.stringify({ action: "set-session-mode", sessionId, mode })
|
|
480
|
+
});
|
|
481
|
+
const result = await response.json();
|
|
482
|
+
if (!response.ok || result?.ok !== true || result.sessionId !== sessionId || result.mode !== mode) {
|
|
483
|
+
throw new Error("Session mode was not saved");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
418
486
|
function resetTodayStats() {
|
|
419
487
|
void postAction({ action: "reset-stats" });
|
|
420
488
|
}
|
|
@@ -439,9 +507,12 @@ async function postAction(payload) {
|
|
|
439
507
|
}
|
|
440
508
|
function handleEvent(event) {
|
|
441
509
|
if (event.type === "state") {
|
|
510
|
+
const policy = event.sessionPolicy;
|
|
442
511
|
state = {
|
|
443
512
|
stats: event.stats ?? EMPTY_STATS,
|
|
444
|
-
paused: event.paused ?? []
|
|
513
|
+
paused: event.paused ?? [],
|
|
514
|
+
recoveryAttempts: event.recoveryAttempts ?? [],
|
|
515
|
+
sessionPolicy: policy && typeof policy.modes === "object" && policy.modes !== null && !Array.isArray(policy.modes) && (policy.defaultMode === "recover" || policy.defaultMode === "loop") && typeof policy.paused === "boolean" && typeof policy.writable === "boolean" ? policy : void 0
|
|
445
516
|
};
|
|
446
517
|
for (const listener of listeners) listener();
|
|
447
518
|
} else if (event.type === "notice" && event.notice !== void 0) {
|
|
@@ -485,6 +556,11 @@ function showNotification(notice) {
|
|
|
485
556
|
function startBridge() {
|
|
486
557
|
let stopped = false;
|
|
487
558
|
let controller;
|
|
559
|
+
const disconnected = () => {
|
|
560
|
+
state = { ...state, sessionPolicy: void 0 };
|
|
561
|
+
for (const listener of listeners) listener();
|
|
562
|
+
};
|
|
563
|
+
disconnected();
|
|
488
564
|
const loop = async () => {
|
|
489
565
|
while (!stopped) {
|
|
490
566
|
controller = new AbortController();
|
|
@@ -496,7 +572,7 @@ function startBridge() {
|
|
|
496
572
|
let buffer = "";
|
|
497
573
|
for (; ; ) {
|
|
498
574
|
const { done, value } = await reader.read();
|
|
499
|
-
if (done) break;
|
|
575
|
+
if (done || stopped) break;
|
|
500
576
|
buffer += decoder.decode(value, { stream: true });
|
|
501
577
|
let idx = buffer.indexOf("\n\n");
|
|
502
578
|
while (idx !== -1) {
|
|
@@ -515,13 +591,17 @@ function startBridge() {
|
|
|
515
591
|
}
|
|
516
592
|
} catch {
|
|
517
593
|
}
|
|
518
|
-
if (!stopped)
|
|
594
|
+
if (!stopped) {
|
|
595
|
+
disconnected();
|
|
596
|
+
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
597
|
+
}
|
|
519
598
|
}
|
|
520
599
|
};
|
|
521
600
|
void loop();
|
|
522
601
|
return () => {
|
|
523
602
|
stopped = true;
|
|
524
603
|
controller?.abort();
|
|
604
|
+
disconnected();
|
|
525
605
|
};
|
|
526
606
|
}
|
|
527
607
|
|
|
@@ -727,7 +807,10 @@ var CardForm = class {
|
|
|
727
807
|
|
|
728
808
|
// src/client/styles.ts
|
|
729
809
|
var css = `
|
|
730
|
-
.dshAcComposer { display: inline-flex; align-items: center; gap: 7px; min-height: 32px;
|
|
810
|
+
.dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 32px; max-width: 100%; font: inherit; }
|
|
811
|
+
.dshAcMode { min-height: 32px; max-width: 100%; padding: 4px 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
|
|
812
|
+
.dshAcMode:disabled { opacity: .5; }
|
|
813
|
+
.dshAcMode:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
731
814
|
.dshAcComposerLabel { color: var(--dsw-alias-label-secondary); font-size: 12px; white-space: nowrap; }
|
|
732
815
|
.dshAcSwitchTarget { display: inline-flex; align-items: center; min-height: 32px; }
|
|
733
816
|
.dshAcSwitchTarget > button { position: relative; }
|
|
@@ -825,6 +908,7 @@ var css = `
|
|
|
825
908
|
.dshAcPauseList { list-style: none; margin: 0; padding: 0; }
|
|
826
909
|
.dshAcPauseList li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
|
|
827
910
|
.dshAcPauseId { flex: 1; font: 12px ui-monospace, SFMono-Regular, monospace; }
|
|
911
|
+
.dshAcRecovery { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
|
|
828
912
|
@container auto-continue-settings (max-width: 760px) {
|
|
829
913
|
.dshAcHeaderFrame { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
|
|
830
914
|
.dshAcRepositoryCopy { display: none; }
|
|
@@ -915,8 +999,8 @@ var AutoContinueSettingsCardController = class {
|
|
|
915
999
|
constructor(scope, getLocale) {
|
|
916
1000
|
this.scope = scope;
|
|
917
1001
|
this.getLocale = getLocale;
|
|
918
|
-
this.composerSaving =
|
|
919
|
-
this.composerFailed =
|
|
1002
|
+
this.composerSaving = /* @__PURE__ */ new Set();
|
|
1003
|
+
this.composerFailed = /* @__PURE__ */ new Set();
|
|
920
1004
|
this.disposed = false;
|
|
921
1005
|
this.saveSequence = 0;
|
|
922
1006
|
this.form = new CardForm(scope, [
|
|
@@ -928,6 +1012,7 @@ var AutoContinueSettingsCardController = class {
|
|
|
928
1012
|
booleanField("resumeCompletedTurns"),
|
|
929
1013
|
textField("continueTextLoop"),
|
|
930
1014
|
textField("continueTextSilent"),
|
|
1015
|
+
textField("continueTextInterrupted"),
|
|
931
1016
|
booleanField("guardTools"),
|
|
932
1017
|
textField("guardPendingText"),
|
|
933
1018
|
textField("guardDoneText"),
|
|
@@ -953,6 +1038,7 @@ var AutoContinueSettingsCardController = class {
|
|
|
953
1038
|
]);
|
|
954
1039
|
this.store = this.form.bind(() => this.projection(), createSnapshotStore);
|
|
955
1040
|
this.composer = this.form.bind(() => this.composerProjection(), createSnapshotStore);
|
|
1041
|
+
this.stopComposer = subscribeBridge(() => this.composer.set(this.composerProjection()));
|
|
956
1042
|
}
|
|
957
1043
|
projection() {
|
|
958
1044
|
return {
|
|
@@ -967,6 +1053,7 @@ var AutoContinueSettingsCardController = class {
|
|
|
967
1053
|
resumeCompletedTurns: this.form.field("resumeCompletedTurns"),
|
|
968
1054
|
continueTextLoop: this.form.field("continueTextLoop"),
|
|
969
1055
|
continueTextSilent: this.form.field("continueTextSilent"),
|
|
1056
|
+
continueTextInterrupted: this.form.field("continueTextInterrupted"),
|
|
970
1057
|
guardTools: this.form.field("guardTools"),
|
|
971
1058
|
guardPendingText: this.form.field("guardPendingText"),
|
|
972
1059
|
guardDoneText: this.form.field("guardDoneText"),
|
|
@@ -1015,37 +1102,38 @@ var AutoContinueSettingsCardController = class {
|
|
|
1015
1102
|
this.notificationFeedback = showSettingsNotification(before === after ? "saved" : after ? "enabled" : "disabled", this.getLocale(), result);
|
|
1016
1103
|
this.store.set(this.projection());
|
|
1017
1104
|
}
|
|
1018
|
-
injectComposer() {
|
|
1019
|
-
return { hooks: { autoContinueComposer: this.composer },
|
|
1105
|
+
injectComposer(sessionId) {
|
|
1106
|
+
return { hooks: { autoContinueComposer: this.composer }, sessionId, setMode: (mode) => void this.setMode(sessionId, mode) };
|
|
1020
1107
|
}
|
|
1021
1108
|
composerProjection() {
|
|
1022
1109
|
const snapshot = this.scope.getSnapshot();
|
|
1110
|
+
const policy = readSessionPolicy();
|
|
1023
1111
|
return {
|
|
1024
1112
|
visible: snapshot.status === "ready" && (snapshot.value?.showComposerToggle ?? DEFAULT_CONFIG.showComposerToggle),
|
|
1025
|
-
|
|
1026
|
-
writable: canWriteSettings(snapshot),
|
|
1027
|
-
saving: this.composerSaving,
|
|
1028
|
-
failed: this.composerFailed
|
|
1113
|
+
policy,
|
|
1114
|
+
writable: canWriteSettings(snapshot) && policy?.writable === true,
|
|
1115
|
+
saving: new Set(this.composerSaving),
|
|
1116
|
+
failed: new Set(this.composerFailed)
|
|
1029
1117
|
};
|
|
1030
1118
|
}
|
|
1031
|
-
async
|
|
1032
|
-
if (this.disposed || this.composerSaving || !this.composerProjection().writable) return;
|
|
1033
|
-
this.composerSaving
|
|
1034
|
-
this.composerFailed
|
|
1119
|
+
async setMode(sessionId, mode) {
|
|
1120
|
+
if (this.disposed || !sessionId || this.composerSaving.has(sessionId) || !this.composerProjection().writable) return;
|
|
1121
|
+
this.composerSaving.add(sessionId);
|
|
1122
|
+
this.composerFailed.delete(sessionId);
|
|
1035
1123
|
this.composer.set(this.composerProjection());
|
|
1036
1124
|
try {
|
|
1037
|
-
|
|
1038
|
-
this.composerFailed = result === false || this.composerProjection().enabled !== enabled;
|
|
1125
|
+
await setSessionMode(sessionId, mode);
|
|
1039
1126
|
} catch {
|
|
1040
|
-
this.composerFailed
|
|
1127
|
+
this.composerFailed.add(sessionId);
|
|
1041
1128
|
} finally {
|
|
1042
|
-
this.composerSaving
|
|
1129
|
+
this.composerSaving.delete(sessionId);
|
|
1043
1130
|
if (!this.disposed) this.composer.set(this.composerProjection());
|
|
1044
1131
|
}
|
|
1045
1132
|
}
|
|
1046
1133
|
/** Release this card's subscription to the provider-owned settings form. */
|
|
1047
1134
|
dispose() {
|
|
1048
1135
|
this.disposed = true;
|
|
1136
|
+
this.stopComposer();
|
|
1049
1137
|
this.form.dispose();
|
|
1050
1138
|
}
|
|
1051
1139
|
};
|
|
@@ -1057,7 +1145,7 @@ var groups = [
|
|
|
1057
1145
|
{ id: "general", fields: ["paused", "showComposerToggle", "resumeSilentTurns", "resumeCompletedTurns", "notify"] },
|
|
1058
1146
|
{ id: "recovery", fields: ["graceMs", "cooldownMs", "maxConsecutive", "classify", "retryableErrorPatterns", "backoffFactor", "backoffMaxMs"] },
|
|
1059
1147
|
{ id: "startup", fields: ["scanOnBoot", "scanLimit", "freshMs"] },
|
|
1060
|
-
{ id: "prompts", fields: ["continueText", "continueTextMaxTokens", "continueTextSilent", "continueTextLoop", "guardPendingText", "guardDoneText", "loopText"] },
|
|
1148
|
+
{ id: "prompts", fields: ["continueText", "continueTextMaxTokens", "continueTextSilent", "continueTextInterrupted", "continueTextLoop", "guardPendingText", "guardDoneText", "loopText"] },
|
|
1061
1149
|
{ id: "safety", fields: ["guardTools", "loopGuard", "loopShortChars", "loopWindowMs", "loopShortCount", "loopRepeatText", "loopToolRepeat"] },
|
|
1062
1150
|
{ id: "status", fields: ["verbose"] }
|
|
1063
1151
|
];
|
|
@@ -1066,6 +1154,7 @@ var textDefaults = {
|
|
|
1066
1154
|
continueTextMaxTokens: "default.continueTextMaxTokens",
|
|
1067
1155
|
continueTextSilent: "default.continueTextSilent",
|
|
1068
1156
|
continueTextLoop: "default.continueTextLoop",
|
|
1157
|
+
continueTextInterrupted: "default.continueTextInterrupted",
|
|
1069
1158
|
guardPendingText: "default.guardPendingText",
|
|
1070
1159
|
guardDoneText: "default.guardDoneText",
|
|
1071
1160
|
loopText: "default.loopText"
|
|
@@ -1104,7 +1193,22 @@ function SettingField({ name, id, state: state2, actions, disabled, t }) {
|
|
|
1104
1193
|
] }),
|
|
1105
1194
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcFieldControl", children: [
|
|
1106
1195
|
state2.overridden && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcReset", disabled, "aria-label": `${t("chrome.reset")}: ${label}`, onClick: () => actions.resetField(name), children: t("chrome.reset") }),
|
|
1107
|
-
|
|
1196
|
+
name === "resumeCompletedTurns" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1197
|
+
"select",
|
|
1198
|
+
{
|
|
1199
|
+
id,
|
|
1200
|
+
className: "dshAcMode",
|
|
1201
|
+
"aria-label": label,
|
|
1202
|
+
"aria-describedby": `${id}-hint`,
|
|
1203
|
+
disabled,
|
|
1204
|
+
value: String(value),
|
|
1205
|
+
onChange: (event) => actions.edit(name, event.target.value),
|
|
1206
|
+
children: [
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "false", children: t("composer.recover") }),
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "true", children: t("composer.loop") })
|
|
1209
|
+
]
|
|
1210
|
+
}
|
|
1211
|
+
) : boolean ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcSwitchTarget", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1108
1212
|
NativeSwitch,
|
|
1109
1213
|
{
|
|
1110
1214
|
label,
|
|
@@ -1132,6 +1236,8 @@ function LivePanels(props) {
|
|
|
1132
1236
|
const hasStats = stats.sent + stats.skipped + stats.recovered + stats.failed + stats.gaveUp + stats.looped > 0;
|
|
1133
1237
|
const codes = Object.entries(stats.byCode).sort((a, b) => b[1] - a[1]).slice(0, 5);
|
|
1134
1238
|
const paused = pausedSessions();
|
|
1239
|
+
const attempts = readRecoveryAttempts();
|
|
1240
|
+
const sessions = [...new Set(attempts.map((attempt) => attempt.sessionId))];
|
|
1135
1241
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1136
1242
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dshAcPanel", children: [
|
|
1137
1243
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcPanelHead", children: [
|
|
@@ -1189,6 +1295,32 @@ function LivePanels(props) {
|
|
|
1189
1295
|
] }) : null
|
|
1190
1296
|
] })
|
|
1191
1297
|
] }),
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dshAcPanel", children: [
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshAcPanelHead", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcPanelTitle", children: t("recovery.title") }) }),
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcHint", children: t("recovery.hint") }),
|
|
1301
|
+
sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcHint", children: t("recovery.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "dshAcPauseList", children: sessions.map((sessionId) => {
|
|
1302
|
+
const recent = attempts.filter((attempt) => attempt.sessionId === sessionId);
|
|
1303
|
+
const latest = recent[0];
|
|
1304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcRecovery", children: [
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcPauseId", children: sessionId }),
|
|
1306
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
1307
|
+
t("recovery.count"),
|
|
1308
|
+
": ",
|
|
1309
|
+
recent.length,
|
|
1310
|
+
" · ",
|
|
1311
|
+
t("recovery.consecutive"),
|
|
1312
|
+
": ",
|
|
1313
|
+
latest.consecutive
|
|
1314
|
+
] }),
|
|
1315
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
1316
|
+
t("recovery.latest"),
|
|
1317
|
+
": ",
|
|
1318
|
+
t(`recovery.reason.${latest.reason}`)
|
|
1319
|
+
] }),
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { className: "dshAcHint", dateTime: new Date(latest.at).toISOString(), children: new Date(latest.at).toLocaleString() })
|
|
1321
|
+
] }) }, sessionId);
|
|
1322
|
+
}) })
|
|
1323
|
+
] }),
|
|
1192
1324
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dshAcPanel", children: [
|
|
1193
1325
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcPanelHead", children: [
|
|
1194
1326
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcPanelTitle", children: t("pause.title") }),
|
|
@@ -1307,21 +1439,36 @@ function AutoContinueSettingsCard(props) {
|
|
|
1307
1439
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1308
1440
|
function AutoContinueComposerToggle(props) {
|
|
1309
1441
|
const state2 = props.useAutoContinueComposer((snapshot) => snapshot);
|
|
1310
|
-
if (!state2.visible) return null;
|
|
1311
|
-
const
|
|
1442
|
+
if (!state2.visible || !props.sessionId) return null;
|
|
1443
|
+
const saving = state2.saving.has(props.sessionId);
|
|
1444
|
+
const policy = state2.policy;
|
|
1445
|
+
const title = props.t(!policy ? "composer.unavailable" : !state2.writable ? "chrome.readOnly" : saving ? "composer.saving" : "composer.scope");
|
|
1312
1446
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dshAcComposer", title, children: [
|
|
1313
1447
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcComposerLabel", children: props.t("composer.label") }),
|
|
1314
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
1315
|
-
|
|
1448
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1449
|
+
"select",
|
|
1316
1450
|
{
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1451
|
+
className: "dshAcMode",
|
|
1452
|
+
"aria-label": props.t("composer.label"),
|
|
1453
|
+
title,
|
|
1454
|
+
disabled: !state2.writable || saving,
|
|
1455
|
+
value: sessionMode(policy?.modes ?? {}, props.sessionId),
|
|
1456
|
+
onChange: (event) => {
|
|
1457
|
+
if (isSessionMode(event.target.value)) props.setMode(event.target.value);
|
|
1458
|
+
},
|
|
1459
|
+
children: [
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("option", { value: "default", children: [
|
|
1461
|
+
props.t("composer.default"),
|
|
1462
|
+
policy ? ` (${props.t(`composer.${policy.defaultMode}`)})` : ""
|
|
1463
|
+
] }),
|
|
1464
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "off", children: props.t("composer.off") }),
|
|
1465
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "recover", children: props.t("composer.recover") }),
|
|
1466
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "loop", children: props.t("composer.loop") })
|
|
1467
|
+
]
|
|
1322
1468
|
}
|
|
1323
|
-
)
|
|
1324
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "
|
|
1469
|
+
),
|
|
1470
|
+
policy?.paused && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcComposerLabel", children: props.t("composer.paused") }),
|
|
1471
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcComposerError", role: "status", children: state2.failed.has(props.sessionId) ? props.t("composer.saveFailed") : saving ? props.t("composer.saving") : !policy ? props.t("composer.unavailable") : null })
|
|
1325
1472
|
] });
|
|
1326
1473
|
}
|
|
1327
1474
|
|
|
@@ -1369,7 +1516,7 @@ function mountSettings(ctx, scope) {
|
|
|
1369
1516
|
name: "conversation.input.left",
|
|
1370
1517
|
id: "auto-continue",
|
|
1371
1518
|
locale: NS,
|
|
1372
|
-
inject: () => controller.injectComposer()
|
|
1519
|
+
inject: (sessionId) => controller.injectComposer(sessionId)
|
|
1373
1520
|
},
|
|
1374
1521
|
AutoContinueComposerToggle
|
|
1375
1522
|
)
|