dsh-client-auto-continue 0.14.2 → 0.15.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/README.md +18 -4
- package/README.zh.md +18 -4
- package/lib/client.js +84 -12
- package/lib/client.js.map +2 -2
- package/lib/index.js +253 -21
- package/lib/types/client/bridge.d.ts +2 -0
- package/lib/types/client/dsh-store-compat.d.ts +1 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/locales.d.ts +15 -0
- package/lib/types/client/settings-card.d.ts +1 -0
- package/lib/types/client/settings-form.d.ts +3 -1
- package/lib/types/host/engine.d.ts +27 -1
- package/lib/types/index.d.ts +8 -0
- package/lib/types/shared/core.d.ts +11 -0
- package/package.json +3 -3
- package/src/client/bridge.ts +10 -2
- package/src/client/dsh-store-compat.ts +1 -1
- package/src/client/index.ts +3 -1
- package/src/client/locales.ts +34 -4
- package/src/client/settings-card.tsx +35 -3
- package/src/client/settings-form.ts +8 -3
- package/src/client/styles.ts +1 -0
- package/src/host/engine.ts +265 -19
- package/src/index.ts +3 -0
- package/src/shared/core.ts +19 -0
|
@@ -14,6 +14,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
14
14
|
readonly continueTextMaxTokens: "继续";
|
|
15
15
|
readonly continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。";
|
|
16
16
|
readonly continueTextLoop: "继续";
|
|
17
|
+
readonly continueTextInterrupted: "继续。宿主在你上一轮运行期间重启了; 重启时未完成的工具调用已按「结果未知」收尾。从中断处继续, 重试可能有副作用的操作前先核实外部状态。";
|
|
17
18
|
readonly guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)";
|
|
18
19
|
readonly guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)";
|
|
19
20
|
readonly loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)";
|
|
@@ -23,6 +24,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
23
24
|
readonly continueTextMaxTokens: "Continue";
|
|
24
25
|
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.";
|
|
25
26
|
readonly continueTextLoop: "Continue";
|
|
27
|
+
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.";
|
|
26
28
|
readonly guardPendingText: "(The previous tool \"{tool}\" may not have completed. Check its state before continuing and do not run it again.)";
|
|
27
29
|
readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
|
|
28
30
|
readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
|
|
@@ -44,6 +46,8 @@ export interface AutoContinueSettings {
|
|
|
44
46
|
continueTextSilent?: string;
|
|
45
47
|
/** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
|
|
46
48
|
continueTextLoop?: string;
|
|
49
|
+
/** Text sent when a turn is recovered after a harness restart closed it as interrupted. */
|
|
50
|
+
continueTextInterrupted?: string;
|
|
47
51
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
48
52
|
guardTools?: boolean;
|
|
49
53
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -255,6 +259,13 @@ export declare class ToolInvocationTracker {
|
|
|
255
259
|
/** 自适应退避: 同一会话连续失败时的有效冷却间隔。 */
|
|
256
260
|
export declare function effectiveCooldown(consecutive: number, base: number, factor: number, max: number): number;
|
|
257
261
|
export declare function sleep(ms: number): Promise<void>;
|
|
262
|
+
/** A sent recovery prompt, not proof that the following turn succeeded. */
|
|
263
|
+
export interface RecoveryAttempt {
|
|
264
|
+
sessionId: string;
|
|
265
|
+
at: number;
|
|
266
|
+
reason: 'error' | 'max-tokens' | 'silent' | 'interrupted' | 'loop-guard' | 'manual';
|
|
267
|
+
consecutive: number;
|
|
268
|
+
}
|
|
258
269
|
/** 一天的自动继续统计(host 单实例内存态)。 */
|
|
259
270
|
export interface DayStats {
|
|
260
271
|
/** 本地日期 YYYY-MM-DD。 */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-auto-continue",
|
|
3
3
|
"description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"build": "node build.mjs && tsc -p tsconfig.build.json",
|
|
47
47
|
"watch": "node build.mjs --watch",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"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",
|
|
50
|
-
"test": "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/manual-resume-pauses.mjs && node tests/stats-freshness.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/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs",
|
|
49
|
+
"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",
|
|
50
|
+
"test": "node tests/boot-scan-stored-sweep.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/manual-resume-pauses.mjs && node tests/stats-freshness.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/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs",
|
|
51
51
|
"prepack": "npm run build"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
package/src/client/bridge.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* paused-sessions list) consumed by the settings card's live panels.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import type { RecoveryAttempt } from '../shared/core.ts';
|
|
11
|
+
|
|
10
12
|
/** 今日统计视图(与 host 引擎的 DayStats 对应)。 */
|
|
11
13
|
export interface DayStatsView {
|
|
12
14
|
date: string;
|
|
@@ -28,6 +30,7 @@ export interface PausedSessionView {
|
|
|
28
30
|
interface BridgeState {
|
|
29
31
|
stats: DayStatsView;
|
|
30
32
|
paused: PausedSessionView[];
|
|
33
|
+
recoveryAttempts: RecoveryAttempt[];
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
interface BridgeNotice {
|
|
@@ -50,7 +53,7 @@ const EMPTY_STATS: DayStatsView = {
|
|
|
50
53
|
byCode: {},
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
let state: BridgeState = { stats: EMPTY_STATS, paused: [] };
|
|
56
|
+
let state: BridgeState = { stats: EMPTY_STATS, paused: [], recoveryAttempts: [] };
|
|
54
57
|
const listeners = new Set<() => void>();
|
|
55
58
|
|
|
56
59
|
/** 当前桥状态里的已暂停会话(卡片面板用)。 */
|
|
@@ -63,6 +66,10 @@ export function readTodayStats(): DayStatsView {
|
|
|
63
66
|
return state.stats;
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
export function readRecoveryAttempts(): RecoveryAttempt[] {
|
|
70
|
+
return state.recoveryAttempts;
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
/** 清零今日统计(经动作端点交给 host 引擎执行)。 */
|
|
67
74
|
export function resetTodayStats(): void {
|
|
68
75
|
void postAction({ action: 'reset-stats' });
|
|
@@ -94,11 +101,12 @@ async function postAction(payload: { action: string; sessionId?: string }): Prom
|
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
function handleEvent(event: { type: string; notice?: BridgeNotice; stats?: DayStatsView; paused?: PausedSessionView[] }): void {
|
|
104
|
+
function handleEvent(event: { type: string; notice?: BridgeNotice; stats?: DayStatsView; paused?: PausedSessionView[]; recoveryAttempts?: RecoveryAttempt[] }): void {
|
|
98
105
|
if (event.type === 'state') {
|
|
99
106
|
state = {
|
|
100
107
|
stats: event.stats ?? EMPTY_STATS,
|
|
101
108
|
paused: event.paused ?? [],
|
|
109
|
+
recoveryAttempts: event.recoveryAttempts ?? [],
|
|
102
110
|
};
|
|
103
111
|
for (const listener of listeners) listener();
|
|
104
112
|
} else if (event.type === 'notice' && event.notice !== undefined) {
|
|
@@ -24,7 +24,7 @@ export interface SettingsScopeSnapshot<T> {
|
|
|
24
24
|
user: unknown;
|
|
25
25
|
revision: number | undefined;
|
|
26
26
|
writable: boolean;
|
|
27
|
-
mode
|
|
27
|
+
mode?: 'host' | 'memory';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** Stable subset shared by settings scopes and DSH 0.1.7 configuration forms. */
|
package/src/client/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import { startBridge } from './bridge.ts';
|
|
28
28
|
import { AutoContinueComposerToggle } from './composer-toggle.tsx';
|
|
29
29
|
import type { SettingsScope } from './dsh-store-compat.ts';
|
|
30
|
+
import { canWriteSettings } from './settings-form.ts';
|
|
30
31
|
|
|
31
32
|
/** Dictionary namespace owned by this plugin. */
|
|
32
33
|
const NS = 'auto-continue';
|
|
@@ -66,6 +67,7 @@ export const inject = ['slots', 'locale'];
|
|
|
66
67
|
export {
|
|
67
68
|
pausedSessions,
|
|
68
69
|
readTodayStats,
|
|
70
|
+
readRecoveryAttempts,
|
|
69
71
|
resetTodayStats,
|
|
70
72
|
unpauseSession,
|
|
71
73
|
} from './bridge.ts';
|
|
@@ -122,7 +124,7 @@ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSett
|
|
|
122
124
|
const syncLocale = (): void => {
|
|
123
125
|
const active = ctx.locale.getLocale().active;
|
|
124
126
|
const snapshot = scope.getSnapshot();
|
|
125
|
-
if (
|
|
127
|
+
if (!canWriteSettings(snapshot)) return;
|
|
126
128
|
// A genuine language switch is the only thing that earns a fresh budget: the
|
|
127
129
|
// attempt count must survive matching snapshots, because the writing page's
|
|
128
130
|
// own acknowledgement arrives as a match (see above). Tracking `mirroredLocale`
|
package/src/client/locales.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const zh = {
|
|
|
43
43
|
'composer.scope': '控制当前配置下所有会话的自动继续,修改立即保存。',
|
|
44
44
|
'composer.saving': '正在保存自动继续设置…',
|
|
45
45
|
'composer.saveFailed': '保存失败,请重试',
|
|
46
|
-
'field.pausedHint': '
|
|
46
|
+
'field.pausedHint': '恢复意外中断的会话。关闭并保存后,全局暂停恢复并取消已排队的继续。循环守卫独立运行;如需停止自动打断,请同时关闭循环守卫。',
|
|
47
47
|
'field.continueText': '继续文本',
|
|
48
48
|
'field.continueTextHint': '中断后自动发送的消息内容。',
|
|
49
49
|
'default.continueText': LOCALIZED_TEXT_DEFAULTS.zh.continueText,
|
|
@@ -60,6 +60,9 @@ export const zh = {
|
|
|
60
60
|
'field.continueTextSilent': '无输出回合的继续文本',
|
|
61
61
|
'field.continueTextSilentHint': '回合只输出推理就结束时自动发送的文本, 支持与继续文本相同的占位符。',
|
|
62
62
|
'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.zh.continueTextSilent,
|
|
63
|
+
'field.continueTextInterrupted': '宿主重启后恢复的继续文本',
|
|
64
|
+
'field.continueTextInterruptedHint': '启动扫描恢复重启中断的会话时发送的文本, 默认说明重启并提醒先核实再重试。',
|
|
65
|
+
'default.continueTextInterrupted': LOCALIZED_TEXT_DEFAULTS.zh.continueTextInterrupted,
|
|
63
66
|
'field.guardTools': '幂等护栏',
|
|
64
67
|
'field.guardToolsHint': '续跑前检查上一步工具调用: 结果未确认时提示先确认状态, 已成功时提示不要重复执行, 避免重复 commit/调 API。',
|
|
65
68
|
'field.guardPendingText': '结果未确认时的护栏文本',
|
|
@@ -75,7 +78,7 @@ export const zh = {
|
|
|
75
78
|
'field.maxConsecutive': '最大连续次数',
|
|
76
79
|
'field.maxConsecutiveHint': '连续恢复尝试上限;用户介入或观察到有可见输出的成功回合后清零。正常完成后的自主循环接力不计入。',
|
|
77
80
|
'field.scanOnBoot': '启动恢复扫描',
|
|
78
|
-
'field.scanOnBootHint': '
|
|
81
|
+
'field.scanOnBootHint': '宿主启动后在扫描时间窗内等待延迟加载的中断会话,未重新加载的持久化会话也会被物化一并检查,每个已就绪会话只检查一次。',
|
|
79
82
|
'field.scanLimit': '扫描会话数',
|
|
80
83
|
'field.scanLimitHint': '每次扫描最多恢复多少个符合条件的会话,优先最近活动的会话。',
|
|
81
84
|
'field.freshMs': '扫描时间窗 (ms)',
|
|
@@ -118,6 +121,18 @@ export const zh = {
|
|
|
118
121
|
'stats.byCode': '按错误码统计',
|
|
119
122
|
'stats.empty': '今天还没有自动继续记录。',
|
|
120
123
|
'stats.reset': '清零',
|
|
124
|
+
'recovery.title': '近期恢复尝试',
|
|
125
|
+
'recovery.hint': '按会话汇总宿主最近 20 次恢复提示,重启插件后清空。正常自主续跑不计入。提示已发送不代表任务已完成;若反复恢复,请检查会话并考虑交接到新会话。',
|
|
126
|
+
'recovery.empty': '尚无恢复尝试。',
|
|
127
|
+
'recovery.count': '窗口内尝试',
|
|
128
|
+
'recovery.consecutive': '最近发送时连续次数',
|
|
129
|
+
'recovery.latest': '最近原因',
|
|
130
|
+
'recovery.reason.error': '请求错误',
|
|
131
|
+
'recovery.reason.max-tokens': '输出上限',
|
|
132
|
+
'recovery.reason.silent': '无可见输出',
|
|
133
|
+
'recovery.reason.interrupted': '宿主重启中断',
|
|
134
|
+
'recovery.reason.loop-guard': '循环守卫',
|
|
135
|
+
'recovery.reason.manual': '手动立即续跑',
|
|
121
136
|
'pause.title': '已暂停会话',
|
|
122
137
|
'pause.none': '没有暂停中的会话。',
|
|
123
138
|
'pause.clearAll': '全部解除',
|
|
@@ -180,7 +195,7 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
180
195
|
'composer.scope': 'Controls auto-continue for all sessions in this profile. Changes save immediately.',
|
|
181
196
|
'composer.saving': 'Saving auto-continue setting…',
|
|
182
197
|
'composer.saveFailed': 'Could not save. Try again.',
|
|
183
|
-
'field.pausedHint': 'Resume interrupted sessions. Turn off and save to pause recovery globally and cancel queued continuations.',
|
|
198
|
+
'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.',
|
|
184
199
|
'field.continueText': 'Continue text',
|
|
185
200
|
'field.continueTextHint': 'Message automatically sent after an interruption.',
|
|
186
201
|
'default.continueText': LOCALIZED_TEXT_DEFAULTS.en.continueText,
|
|
@@ -197,6 +212,9 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
197
212
|
'field.continueTextSilent': 'Continue text (silent turn)',
|
|
198
213
|
'field.continueTextSilentHint': 'Text sent when a turn ends with reasoning only; same placeholders as the continue text.',
|
|
199
214
|
'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.en.continueTextSilent,
|
|
215
|
+
'field.continueTextInterrupted': 'Continue text (after harness restart)',
|
|
216
|
+
'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.',
|
|
217
|
+
'default.continueTextInterrupted': LOCALIZED_TEXT_DEFAULTS.en.continueTextInterrupted,
|
|
200
218
|
'field.guardTools': 'Idempotency guard',
|
|
201
219
|
'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.',
|
|
202
220
|
'field.guardPendingText': 'Guard text (unconfirmed result)',
|
|
@@ -212,7 +230,7 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
212
230
|
'field.maxConsecutive': 'Max consecutive',
|
|
213
231
|
'field.maxConsecutiveHint': 'Consecutive recovery-attempt cap; resets on user intervention or an observed completion with visible output. Normal autonomous-loop handoffs are exempt.',
|
|
214
232
|
'field.scanOnBoot': 'Scan on host startup',
|
|
215
|
-
'field.scanOnBootHint': 'Wait for delayed interrupted sessions during the startup scan window;
|
|
233
|
+
'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.',
|
|
216
234
|
'field.scanLimit': 'Scan limit',
|
|
217
235
|
'field.scanLimitHint': 'Maximum eligible sessions to recover per pass, most recently active first.',
|
|
218
236
|
'field.freshMs': 'Scan window (ms)',
|
|
@@ -255,6 +273,18 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
255
273
|
'stats.byCode': 'By error code',
|
|
256
274
|
'stats.empty': 'No auto-continue activity today.',
|
|
257
275
|
'stats.reset': 'Reset',
|
|
276
|
+
'recovery.title': 'Recent recovery attempts',
|
|
277
|
+
'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.',
|
|
278
|
+
'recovery.empty': 'No recovery attempts yet.',
|
|
279
|
+
'recovery.count': 'Attempts in window',
|
|
280
|
+
'recovery.consecutive': 'Consecutive at last send',
|
|
281
|
+
'recovery.latest': 'Latest reason',
|
|
282
|
+
'recovery.reason.error': 'Request error',
|
|
283
|
+
'recovery.reason.max-tokens': 'Output limit',
|
|
284
|
+
'recovery.reason.silent': 'No visible output',
|
|
285
|
+
'recovery.reason.interrupted': 'Host restart interruption',
|
|
286
|
+
'recovery.reason.loop-guard': 'Loop guard',
|
|
287
|
+
'recovery.reason.manual': 'Manual resume',
|
|
258
288
|
'pause.title': 'Paused sessions',
|
|
259
289
|
'pause.none': 'No sessions paused.',
|
|
260
290
|
'pause.clearAll': 'Clear all',
|
|
@@ -16,6 +16,7 @@ import { createSnapshotStore, type SettingsScope, type SnapshotStore } from './d
|
|
|
16
16
|
import {
|
|
17
17
|
pausedSessions,
|
|
18
18
|
readTodayStats,
|
|
19
|
+
readRecoveryAttempts,
|
|
19
20
|
resetTodayStats,
|
|
20
21
|
subscribeBridge,
|
|
21
22
|
unpauseSession,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
import type { SettingsCardKey } from './locales.ts';
|
|
24
25
|
import {
|
|
25
26
|
booleanField,
|
|
27
|
+
canWriteSettings,
|
|
26
28
|
CardForm,
|
|
27
29
|
numberField,
|
|
28
30
|
textField,
|
|
@@ -51,6 +53,7 @@ export interface AutoContinueSettingsCardState extends CardShell {
|
|
|
51
53
|
resumeCompletedTurns: CardFieldState;
|
|
52
54
|
continueTextLoop: CardFieldState;
|
|
53
55
|
continueTextSilent: CardFieldState;
|
|
56
|
+
continueTextInterrupted: CardFieldState;
|
|
54
57
|
guardTools: CardFieldState;
|
|
55
58
|
guardPendingText: CardFieldState;
|
|
56
59
|
guardDoneText: CardFieldState;
|
|
@@ -110,6 +113,7 @@ export class AutoContinueSettingsCardController {
|
|
|
110
113
|
booleanField('resumeCompletedTurns'),
|
|
111
114
|
textField('continueTextLoop'),
|
|
112
115
|
textField('continueTextSilent'),
|
|
116
|
+
textField('continueTextInterrupted'),
|
|
113
117
|
booleanField('guardTools'),
|
|
114
118
|
textField('guardPendingText'),
|
|
115
119
|
textField('guardDoneText'),
|
|
@@ -150,6 +154,7 @@ export class AutoContinueSettingsCardController {
|
|
|
150
154
|
resumeCompletedTurns: this.form.field('resumeCompletedTurns'),
|
|
151
155
|
continueTextLoop: this.form.field('continueTextLoop'),
|
|
152
156
|
continueTextSilent: this.form.field('continueTextSilent'),
|
|
157
|
+
continueTextInterrupted: this.form.field('continueTextInterrupted'),
|
|
153
158
|
guardTools: this.form.field('guardTools'),
|
|
154
159
|
guardPendingText: this.form.field('guardPendingText'),
|
|
155
160
|
guardDoneText: this.form.field('guardDoneText'),
|
|
@@ -186,7 +191,7 @@ export class AutoContinueSettingsCardController {
|
|
|
186
191
|
private async save(): Promise<void> {
|
|
187
192
|
const state = this.form.shell();
|
|
188
193
|
const snapshot = this.scope.getSnapshot();
|
|
189
|
-
if (this.disposed || !state.available || !state.writable || !state.dirty || state.invalid || state.saving
|
|
194
|
+
if (this.disposed || !state.available || !state.writable || !state.dirty || state.invalid || state.saving) return;
|
|
190
195
|
const sequence = ++this.saveSequence;
|
|
191
196
|
const before = snapshot.value?.notify ?? DEFAULT_CONFIG.notify;
|
|
192
197
|
const target = this.form.field('notify').text;
|
|
@@ -212,7 +217,7 @@ export class AutoContinueSettingsCardController {
|
|
|
212
217
|
return {
|
|
213
218
|
visible: snapshot.status === 'ready' && (snapshot.value?.showComposerToggle ?? DEFAULT_CONFIG.showComposerToggle),
|
|
214
219
|
enabled: !(snapshot.value?.paused ?? DEFAULT_CONFIG.paused),
|
|
215
|
-
writable: snapshot
|
|
220
|
+
writable: canWriteSettings(snapshot),
|
|
216
221
|
saving: this.composerSaving,
|
|
217
222
|
failed: this.composerFailed,
|
|
218
223
|
};
|
|
@@ -261,7 +266,7 @@ const groups = [
|
|
|
261
266
|
{ id: 'general', fields: ['paused', 'showComposerToggle', 'resumeSilentTurns', 'resumeCompletedTurns', 'notify'] },
|
|
262
267
|
{ id: 'recovery', fields: ['graceMs', 'cooldownMs', 'maxConsecutive', 'classify', 'retryableErrorPatterns', 'backoffFactor', 'backoffMaxMs'] },
|
|
263
268
|
{ id: 'startup', fields: ['scanOnBoot', 'scanLimit', 'freshMs'] },
|
|
264
|
-
{ id: 'prompts', fields: ['continueText', 'continueTextMaxTokens', 'continueTextSilent', 'continueTextLoop', 'guardPendingText', 'guardDoneText', 'loopText'] },
|
|
269
|
+
{ id: 'prompts', fields: ['continueText', 'continueTextMaxTokens', 'continueTextSilent', 'continueTextInterrupted', 'continueTextLoop', 'guardPendingText', 'guardDoneText', 'loopText'] },
|
|
265
270
|
{ id: 'safety', fields: ['guardTools', 'loopGuard', 'loopShortChars', 'loopWindowMs', 'loopShortCount', 'loopRepeatText', 'loopToolRepeat'] },
|
|
266
271
|
{ id: 'status', fields: ['verbose'] },
|
|
267
272
|
] as const satisfies ReadonlyArray<{ id: string; fields: readonly FieldName[] }>;
|
|
@@ -269,6 +274,7 @@ type Category = typeof groups[number]['id'];
|
|
|
269
274
|
const textDefaults: Partial<Record<FieldName, SettingsCardKey>> = {
|
|
270
275
|
continueText: 'default.continueText', continueTextMaxTokens: 'default.continueTextMaxTokens',
|
|
271
276
|
continueTextSilent: 'default.continueTextSilent', continueTextLoop: 'default.continueTextLoop',
|
|
277
|
+
continueTextInterrupted: 'default.continueTextInterrupted',
|
|
272
278
|
guardPendingText: 'default.guardPendingText', guardDoneText: 'default.guardDoneText', loopText: 'default.loopText',
|
|
273
279
|
};
|
|
274
280
|
|
|
@@ -333,6 +339,8 @@ function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
|
|
|
333
339
|
.sort((a, b) => b[1] - a[1])
|
|
334
340
|
.slice(0, 5);
|
|
335
341
|
const paused = pausedSessions();
|
|
342
|
+
const attempts = readRecoveryAttempts();
|
|
343
|
+
const sessions = [...new Set(attempts.map(attempt => attempt.sessionId))];
|
|
336
344
|
return (
|
|
337
345
|
<>
|
|
338
346
|
<section className="dshAcPanel">
|
|
@@ -376,6 +384,30 @@ function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
|
|
|
376
384
|
</>
|
|
377
385
|
)}
|
|
378
386
|
</section>
|
|
387
|
+
<section className="dshAcPanel">
|
|
388
|
+
<div className="dshAcPanelHead">
|
|
389
|
+
<span className="dshAcPanelTitle">{t('recovery.title')}</span>
|
|
390
|
+
</div>
|
|
391
|
+
<p className="dshAcHint">{t('recovery.hint')}</p>
|
|
392
|
+
{sessions.length === 0 ? <p className="dshAcHint">{t('recovery.empty')}</p> : (
|
|
393
|
+
<ul className="dshAcPauseList">
|
|
394
|
+
{sessions.map(sessionId => {
|
|
395
|
+
const recent = attempts.filter(attempt => attempt.sessionId === sessionId);
|
|
396
|
+
const latest = recent[0]!;
|
|
397
|
+
return (
|
|
398
|
+
<li key={sessionId}>
|
|
399
|
+
<div className="dshAcRecovery">
|
|
400
|
+
<span className="dshAcPauseId">{sessionId}</span>
|
|
401
|
+
<span>{t('recovery.count')}: {recent.length} · {t('recovery.consecutive')}: {latest.consecutive}</span>
|
|
402
|
+
<span>{t('recovery.latest')}: {t(`recovery.reason.${latest.reason}`)}</span>
|
|
403
|
+
<time className="dshAcHint" dateTime={new Date(latest.at).toISOString()}>{new Date(latest.at).toLocaleString()}</time>
|
|
404
|
+
</div>
|
|
405
|
+
</li>
|
|
406
|
+
);
|
|
407
|
+
})}
|
|
408
|
+
</ul>
|
|
409
|
+
)}
|
|
410
|
+
</section>
|
|
379
411
|
<section className="dshAcPanel">
|
|
380
412
|
<div className="dshAcPanelHead">
|
|
381
413
|
<span className="dshAcPanelTitle">{t('pause.title')}</span>
|
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
* default — and whether the user layer carries it (presence, not value
|
|
11
11
|
* equality, marks an override).
|
|
12
12
|
*/
|
|
13
|
-
import type { SettingsScope, SnapshotStore } from './dsh-store-compat.ts';
|
|
13
|
+
import type { SettingsScope, SettingsScopeSnapshot, SnapshotStore } from './dsh-store-compat.ts';
|
|
14
|
+
|
|
15
|
+
/** Current forms omit mode; legacy memory scopes still cannot persist settings. */
|
|
16
|
+
export function canWriteSettings(snapshot: SettingsScopeSnapshot<unknown>): boolean {
|
|
17
|
+
return snapshot.status === 'ready' && snapshot.writable && (snapshot.mode === undefined || snapshot.mode === 'host');
|
|
18
|
+
}
|
|
14
19
|
|
|
15
20
|
/** The write one field's staged text performs when the card is saved. */
|
|
16
21
|
export type FieldWrite = { kind: 'set'; value: unknown } | { kind: 'clear' };
|
|
@@ -162,7 +167,7 @@ export class CardForm<T> {
|
|
|
162
167
|
const snapshot = this.scope.getSnapshot();
|
|
163
168
|
return {
|
|
164
169
|
available: snapshot.status === 'ready',
|
|
165
|
-
writable: snapshot
|
|
170
|
+
writable: canWriteSettings(snapshot),
|
|
166
171
|
dirty: this.plan().length > 0,
|
|
167
172
|
invalid: this.plan().some((item) => item.run === undefined),
|
|
168
173
|
saving: this.saving,
|
|
@@ -214,7 +219,7 @@ export class CardForm<T> {
|
|
|
214
219
|
const plan = this.plan();
|
|
215
220
|
const writes = plan.flatMap((item) => (item.run === undefined ? [] : [item.run]));
|
|
216
221
|
const snapshot = this.scope.getSnapshot();
|
|
217
|
-
if (plan.length === 0 || this.saving || writes.length !== plan.length ||
|
|
222
|
+
if (plan.length === 0 || this.saving || writes.length !== plan.length || !canWriteSettings(snapshot)) return false;
|
|
218
223
|
// Keep the staged edits this save writes. A field can be staged again
|
|
219
224
|
// while a write is pending, so clear it only if that exact edit remains.
|
|
220
225
|
const edits = plan.map(({ field, staged }) => ({ field, staged }));
|
package/src/client/styles.ts
CHANGED
|
@@ -104,6 +104,7 @@ const css = `
|
|
|
104
104
|
.dshAcPauseList { list-style: none; margin: 0; padding: 0; }
|
|
105
105
|
.dshAcPauseList li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
|
|
106
106
|
.dshAcPauseId { flex: 1; font: 12px ui-monospace, SFMono-Regular, monospace; }
|
|
107
|
+
.dshAcRecovery { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
|
|
107
108
|
@container auto-continue-settings (max-width: 760px) {
|
|
108
109
|
.dshAcHeaderFrame { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
|
|
109
110
|
.dshAcRepositoryCopy { display: none; }
|