dsh-client-auto-continue 0.11.9 → 0.12.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/lib/index.js CHANGED
@@ -102,6 +102,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
102
102
  continueText: "继续",
103
103
  continueTextMaxTokens: "继续",
104
104
  continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。",
105
+ continueTextLoop: "继续",
105
106
  guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)",
106
107
  guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)",
107
108
  loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)"
@@ -110,6 +111,7 @@ var LOCALIZED_TEXT_DEFAULTS = {
110
111
  continueText: "Continue",
111
112
  continueTextMaxTokens: "Continue",
112
113
  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.",
114
+ continueTextLoop: "Continue",
113
115
  guardPendingText: '(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)',
114
116
  guardDoneText: '(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)',
115
117
  loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)"
@@ -119,6 +121,8 @@ var DEFAULT_CONFIG = {
119
121
  locale: "zh",
120
122
  ...LOCALIZED_TEXT_DEFAULTS.zh,
121
123
  resumeSilentTurns: true,
124
+ resumeCompletedTurns: false,
125
+ continueTextLoop: "",
122
126
  guardTools: true,
123
127
  graceMs: 3e3,
124
128
  cooldownMs: 2e4,
@@ -153,6 +157,7 @@ function resolveConfig(section) {
153
157
  const text = typeof value.continueText === "string" && value.continueText.trim() !== "" ? value.continueText : localized.continueText;
154
158
  const maxTokensText = typeof value.continueTextMaxTokens === "string" && value.continueTextMaxTokens.trim() !== "" ? value.continueTextMaxTokens : localized.continueTextMaxTokens;
155
159
  const silentText = typeof value.continueTextSilent === "string" && value.continueTextSilent.trim() !== "" ? value.continueTextSilent : localized.continueTextSilent;
160
+ const loopText = typeof value.continueTextLoop === "string" && value.continueTextLoop.trim() !== "" ? value.continueTextLoop : localized.continueTextLoop;
156
161
  const guardPendingText = typeof value.guardPendingText === "string" && value.guardPendingText.trim() !== "" ? value.guardPendingText : localized.guardPendingText;
157
162
  const guardDoneText = typeof value.guardDoneText === "string" && value.guardDoneText.trim() !== "" ? value.guardDoneText : localized.guardDoneText;
158
163
  return {
@@ -160,7 +165,9 @@ function resolveConfig(section) {
160
165
  continueText: text,
161
166
  continueTextMaxTokens: maxTokensText,
162
167
  resumeSilentTurns: booleanOr(value.resumeSilentTurns, DEFAULT_CONFIG.resumeSilentTurns),
168
+ resumeCompletedTurns: booleanOr(value.resumeCompletedTurns, DEFAULT_CONFIG.resumeCompletedTurns),
163
169
  continueTextSilent: silentText,
170
+ continueTextLoop: loopText,
164
171
  guardTools: booleanOr(value.guardTools, DEFAULT_CONFIG.guardTools),
165
172
  guardPendingText,
166
173
  guardDoneText,
@@ -561,7 +568,8 @@ var freshState = () => ({
561
568
  streamLastSegment: "",
562
569
  streamRepeatRun: 0,
563
570
  loopFired: false,
564
- loopRetryTimer: void 0
571
+ loopRetryTimer: void 0,
572
+ cooldownRetryTimer: void 0
565
573
  });
566
574
  var RECOVERY_WINDOW_MS = 10 * 60 * 1e3;
567
575
  var ECHO_WINDOW_MS = 10 * 60 * 1e3;
@@ -621,6 +629,9 @@ var LOOP_GUARD_CANCEL_CAUSE = {
621
629
  kind: "hook",
622
630
  reason: "dsh-auto-continue:loop-guard"
623
631
  };
632
+ var LOOP_COMPLETED_REASON = "turn/end:completed";
633
+ var LOOP_SILENT_REASON = "turn/end:loop-silent";
634
+ var isLoopReason = (reason) => reason === LOOP_COMPLETED_REASON || reason === LOOP_SILENT_REASON;
624
635
  var STREAM_NEAR_DUPLICATE_MAX_CHARS = 2048;
625
636
  var STREAM_TAIL_MAX_CHARS = 4096;
626
637
  function snapshotSessionEvents(session) {
@@ -775,6 +786,7 @@ var AutoContinueRunner = class {
775
786
  for (const state of this.states.values()) {
776
787
  if (state.pendingTimer !== void 0) clearTimeout(state.pendingTimer);
777
788
  if (state.loopRetryTimer !== void 0) clearTimeout(state.loopRetryTimer);
789
+ if (state.cooldownRetryTimer !== void 0) clearTimeout(state.cooldownRetryTimer);
778
790
  }
779
791
  this.states.clear();
780
792
  }
@@ -1055,11 +1067,22 @@ var AutoContinueRunner = class {
1055
1067
  state.lastTurn = event.data.turn;
1056
1068
  state.lastFailureAt = Date.now();
1057
1069
  this.noteRecovery(sessionId, "error");
1058
- if (this.getConfig().resumeSilentTurns) this.schedule(sessionId, `turn/end:${reasonKind}:silent`);
1070
+ if (this.getConfig().resumeCompletedTurns) {
1071
+ this.schedule(sessionId, LOOP_SILENT_REASON);
1072
+ } else if (this.getConfig().resumeSilentTurns) {
1073
+ this.schedule(sessionId, `turn/end:${reasonKind}:silent`);
1074
+ }
1059
1075
  break;
1060
1076
  }
1061
1077
  if (reasonKind === "completed") {
1062
- if (turnOutput === "visible") {
1078
+ if (this.getConfig().resumeCompletedTurns) {
1079
+ if (turnOutput === "visible") {
1080
+ state.consecutive = 0;
1081
+ state.lastFailure = void 0;
1082
+ this.noteRecovery(sessionId, "completed");
1083
+ }
1084
+ this.schedule(sessionId, LOOP_COMPLETED_REASON, true);
1085
+ } else if (turnOutput === "visible") {
1063
1086
  state.consecutive = 0;
1064
1087
  state.lastFailure = void 0;
1065
1088
  this.noteRecovery(sessionId, "completed");
@@ -1183,6 +1206,7 @@ var AutoContinueRunner = class {
1183
1206
  if (delta.code !== void 0) {
1184
1207
  this.dayStats.byCode[delta.code] = (this.dayStats.byCode[delta.code] ?? 0) + 1;
1185
1208
  }
1209
+ this.emitState();
1186
1210
  }
1187
1211
  /** 通知桥: 产生一条通知事件, SSE 端点推给 browser 侧展示。 */
1188
1212
  notify(sessionId, title, body, options) {
@@ -1235,7 +1259,7 @@ var AutoContinueRunner = class {
1235
1259
  config.backoffMaxMs
1236
1260
  );
1237
1261
  }
1238
- schedule(sessionId, reason) {
1262
+ schedule(sessionId, reason, force = false) {
1239
1263
  const state = this.state(sessionId);
1240
1264
  const config = this.getConfig();
1241
1265
  if (state.subagent) return;
@@ -1248,18 +1272,24 @@ var AutoContinueRunner = class {
1248
1272
  return;
1249
1273
  }
1250
1274
  if (state.pendingTimer !== void 0) return;
1251
- if (Date.now() - state.lastAttemptAt < this.cooldownFor(state)) return;
1252
- if (state.consecutive >= config.maxConsecutive) {
1275
+ if (!force && state.consecutive >= config.maxConsecutive) {
1253
1276
  this.log(
1254
1277
  `跳过 ${sessionId}(${reason}): 已连续自动继续 ${state.consecutive} 次, 等待用户介入或成功回合`
1255
1278
  );
1256
1279
  return;
1257
1280
  }
1281
+ if (!force) {
1282
+ const remaining = this.cooldownFor(state) - (Date.now() - state.lastAttemptAt);
1283
+ if (remaining > 0) {
1284
+ this.deferCooldownRetry(sessionId, reason, remaining);
1285
+ return;
1286
+ }
1287
+ }
1258
1288
  const timer = setTimeout(() => {
1259
1289
  if (state.pendingTimer !== timer) return;
1260
1290
  state.pendingTimer = void 0;
1261
1291
  try {
1262
- void this.fire(sessionId, reason);
1292
+ void this.fire(sessionId, reason, force);
1263
1293
  } catch (error) {
1264
1294
  console.error(`[auto-continue] 定时发送异常 ${sessionId}: ${error instanceof Error ? error.message : String(error)}`);
1265
1295
  }
@@ -1270,25 +1300,52 @@ var AutoContinueRunner = class {
1270
1300
  `检测到非人为中断 ${sessionId}(${reason}), ${config.graceMs}ms 后自动发送「${template}」`
1271
1301
  );
1272
1302
  }
1273
- /** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens, 其余用通用继续文本。 */
1303
+ /**
1304
+ * 冷却期内的恢复: 等到冷却结束再重新调度。
1305
+ * 直接丢弃会让一次瞬时失败把会话搁置, 直到用户手动发消息才恢复。
1306
+ */
1307
+ deferCooldownRetry(sessionId, reason, remaining) {
1308
+ const state = this.state(sessionId);
1309
+ if (state.cooldownRetryTimer !== void 0) clearTimeout(state.cooldownRetryTimer);
1310
+ state.cooldownRetryTimer = setTimeout(() => {
1311
+ state.cooldownRetryTimer = void 0;
1312
+ try {
1313
+ this.schedule(sessionId, reason);
1314
+ } catch (error) {
1315
+ console.error(`[auto-continue] 冷却后重试异常 ${sessionId}: ${error instanceof Error ? error.message : String(error)}`);
1316
+ }
1317
+ }, remaining + 10);
1318
+ this.log(`冷却中 ${sessionId}(${reason}), ${remaining}ms 后重试`);
1319
+ }
1320
+ /** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens、自主循环, 其余用通用继续文本。 */
1274
1321
  templateFor(config, reason) {
1275
1322
  if (reason.startsWith("loop:")) return config.loopText;
1323
+ if (isLoopReason(reason)) return config.continueTextLoop;
1276
1324
  if (reason.endsWith(":silent")) return config.continueTextSilent;
1277
1325
  if (reason.includes("max-tokens")) return config.continueTextMaxTokens;
1278
1326
  return config.continueText;
1279
1327
  }
1280
1328
  cancelPending(sessionId, why) {
1281
1329
  const state = this.state(sessionId);
1282
- if (state.pendingTimer === void 0) return;
1283
- clearTimeout(state.pendingTimer);
1284
- state.pendingTimer = void 0;
1285
- this.log(`取消 ${sessionId} 的自动继续(${why})`);
1330
+ let cancelled = false;
1331
+ if (state.pendingTimer !== void 0) {
1332
+ clearTimeout(state.pendingTimer);
1333
+ state.pendingTimer = void 0;
1334
+ cancelled = true;
1335
+ }
1336
+ if (state.cooldownRetryTimer !== void 0) {
1337
+ clearTimeout(state.cooldownRetryTimer);
1338
+ state.cooldownRetryTimer = void 0;
1339
+ cancelled = true;
1340
+ }
1341
+ if (cancelled) this.log(`取消 ${sessionId} 的自动继续(${why})`);
1286
1342
  }
1287
1343
  fire(sessionId, reason, force = false) {
1288
1344
  if (this.disposed) return;
1289
1345
  const state = this.state(sessionId);
1290
1346
  const config = this.getConfig();
1291
1347
  if (reason.endsWith(":silent") && !config.resumeSilentTurns) return;
1348
+ if (isLoopReason(reason) && !config.resumeCompletedTurns) return;
1292
1349
  if (state.subagent) return;
1293
1350
  if (config.paused) {
1294
1351
  this.log(`跳过 ${sessionId}(${reason}): 全局暂停中`);
@@ -1330,7 +1387,7 @@ var AutoContinueRunner = class {
1330
1387
  this.prioritizedFollowups.delete(message.id);
1331
1388
  }
1332
1389
  const now = Date.now();
1333
- state.consecutive += 1;
1390
+ if (reason !== LOOP_COMPLETED_REASON) state.consecutive += 1;
1334
1391
  state.pendingRecoveryAt = now;
1335
1392
  this.bumpStat({ sent: 1, ...state.lastFailure !== void 0 ? { code: state.lastFailure.code } : {} });
1336
1393
  this.log(`已自动发送「${text}」到 ${sessionId}(${reason}), 第 ${state.consecutive} 次连续`);
@@ -1512,8 +1569,12 @@ var AutoContinueSchema = z2.object({
1512
1569
  continueTextMaxTokens: z2.string().default(""),
1513
1570
  /** Resume observed model activity that completes without visible output. */
1514
1571
  resumeSilentTurns: z2.boolean().default(true),
1572
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
1573
+ resumeCompletedTurns: z2.boolean().default(false),
1515
1574
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
1516
1575
  continueTextSilent: z2.string().default(""),
1576
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
1577
+ continueTextLoop: z2.string().default(""),
1517
1578
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
1518
1579
  guardTools: z2.boolean().default(true),
1519
1580
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -9,6 +9,8 @@ export declare const zh: {
9
9
  'repo.aria': string;
10
10
  'section.handoff.title': string;
11
11
  'section.handoff.description': string;
12
+ 'section.autoloop.title': string;
13
+ 'section.autoloop.description': string;
12
14
  'section.safety.title': string;
13
15
  'section.safety.description': string;
14
16
  'section.recovery.title': string;
@@ -27,6 +29,11 @@ export declare const zh: {
27
29
  'default.continueTextMaxTokens': "继续";
28
30
  'field.resumeSilentTurns': string;
29
31
  'field.resumeSilentTurnsHint': string;
32
+ 'field.resumeCompletedTurns': string;
33
+ 'field.resumeCompletedTurnsHint': string;
34
+ 'field.continueTextLoop': string;
35
+ 'field.continueTextLoopHint': string;
36
+ 'default.continueTextLoop': "继续";
30
37
  'field.continueTextSilent': string;
31
38
  'field.continueTextSilentHint': string;
32
39
  'default.continueTextSilent': "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。";
@@ -8,6 +8,8 @@ export interface AutoContinueSettingsCardState extends CardShell {
8
8
  continueText: CardFieldState;
9
9
  continueTextMaxTokens: CardFieldState;
10
10
  resumeSilentTurns: CardFieldState;
11
+ resumeCompletedTurns: CardFieldState;
12
+ continueTextLoop: CardFieldState;
11
13
  continueTextSilent: CardFieldState;
12
14
  guardTools: CardFieldState;
13
15
  guardPendingText: CardFieldState;
@@ -109,7 +109,12 @@ export declare class AutoContinueRunner {
109
109
  /** 本会话当前生效的冷却间隔(自适应退避)。 */
110
110
  private cooldownFor;
111
111
  private schedule;
112
- /** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens, 其余用通用继续文本。 */
112
+ /**
113
+ * 冷却期内的恢复: 等到冷却结束再重新调度。
114
+ * 直接丢弃会让一次瞬时失败把会话搁置, 直到用户手动发消息才恢复。
115
+ */
116
+ private deferCooldownRetry;
117
+ /** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens、自主循环, 其余用通用继续文本。 */
113
118
  private templateFor;
114
119
  private cancelPending;
115
120
  private fire;
@@ -25,8 +25,12 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
25
25
  continueTextMaxTokens: z<string, string>;
26
26
  /** Resume observed model activity that completes without visible output. */
27
27
  resumeSilentTurns: z<boolean, boolean>;
28
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
29
+ resumeCompletedTurns: z<boolean, boolean>;
28
30
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
29
31
  continueTextSilent: z<string, string>;
32
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
33
+ continueTextLoop: z<string, string>;
30
34
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
31
35
  guardTools: z<boolean, boolean>;
32
36
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -82,8 +86,12 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
82
86
  continueTextMaxTokens: z<string, string>;
83
87
  /** Resume observed model activity that completes without visible output. */
84
88
  resumeSilentTurns: z<boolean, boolean>;
89
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
90
+ resumeCompletedTurns: z<boolean, boolean>;
85
91
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
86
92
  continueTextSilent: z<string, string>;
93
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
94
+ continueTextLoop: z<string, string>;
87
95
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
88
96
  guardTools: z<boolean, boolean>;
89
97
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -144,8 +152,12 @@ export declare const Config: z<Schemastery.ObjectS<{
144
152
  continueTextMaxTokens: z<string, string>;
145
153
  /** Resume observed model activity that completes without visible output. */
146
154
  resumeSilentTurns: z<boolean, boolean>;
155
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
156
+ resumeCompletedTurns: z<boolean, boolean>;
147
157
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
148
158
  continueTextSilent: z<string, string>;
159
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
160
+ continueTextLoop: z<string, string>;
149
161
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
150
162
  guardTools: z<boolean, boolean>;
151
163
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -201,8 +213,12 @@ export declare const Config: z<Schemastery.ObjectS<{
201
213
  continueTextMaxTokens: z<string, string>;
202
214
  /** Resume observed model activity that completes without visible output. */
203
215
  resumeSilentTurns: z<boolean, boolean>;
216
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
217
+ resumeCompletedTurns: z<boolean, boolean>;
204
218
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
205
219
  continueTextSilent: z<string, string>;
220
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
221
+ continueTextLoop: z<string, string>;
206
222
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
207
223
  guardTools: z<boolean, boolean>;
208
224
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -13,6 +13,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
13
13
  readonly continueText: "继续";
14
14
  readonly continueTextMaxTokens: "继续";
15
15
  readonly continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。";
16
+ readonly continueTextLoop: "继续";
16
17
  readonly guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)";
17
18
  readonly guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)";
18
19
  readonly loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)";
@@ -21,6 +22,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
21
22
  readonly continueText: "Continue";
22
23
  readonly continueTextMaxTokens: "Continue";
23
24
  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
+ readonly continueTextLoop: "Continue";
24
26
  readonly guardPendingText: "(The previous tool \"{tool}\" may not have completed. Check its state before continuing and do not run it again.)";
25
27
  readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
26
28
  readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
@@ -36,8 +38,12 @@ export interface AutoContinueSettings {
36
38
  continueTextMaxTokens?: string;
37
39
  /** Resume observed model activity that completes without visible output. */
38
40
  resumeSilentTurns?: boolean;
41
+ /** Autonomous mode: hand the thread back to the agent after every completed turn, looping until the user stops it. The consecutive-failure cap only throttles failures, never successful completions. */
42
+ resumeCompletedTurns?: boolean;
39
43
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
40
44
  continueTextSilent?: string;
45
+ /** Text sent for each autonomous-loop continuation (same placeholders as `continueText`). */
46
+ continueTextLoop?: string;
41
47
  /** Idempotency guard: inspect the last tool call before resuming and steer the model. */
42
48
  guardTools?: boolean;
43
49
  /** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
@@ -317,6 +323,8 @@ export interface SessionState {
317
323
  loopFired: boolean;
318
324
  /** loop 重启的延迟定时器(冷却结束后再 schedule)。 */
319
325
  loopRetryTimer: ReturnType<typeof setTimeout> | undefined;
326
+ /** 冷却期恢复的延迟定时器(等到冷却结束再 schedule, 而不是丢弃这次恢复)。 */
327
+ cooldownRetryTimer: ReturnType<typeof setTimeout> | undefined;
320
328
  }
321
329
  export declare const freshState: () => SessionState;
322
330
  export declare const RECOVERY_WINDOW_MS: number;
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.11.9",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "watch": "node build.mjs --watch",
48
48
  "typecheck": "tsc --noEmit",
49
49
  "test:runtime": "node tests/settings-host-live.mjs",
50
- "test": "node tests/scan-on-boot.mjs && node tests/silent-turn-boundaries.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/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/prepare-github-package.mjs",
50
+ "test": "node tests/scan-on-boot.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.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/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/prepare-github-package.mjs",
51
51
  "prepack": "npm run build"
52
52
  },
53
53
  "keywords": [
@@ -16,6 +16,8 @@ export const zh = {
16
16
  'repo.aria': '打开 dsh-auto-continue 的 GitHub 开源地址并点 Star',
17
17
  'section.handoff.title': '接力方式',
18
18
  'section.handoff.description': '决定中断后说什么,以及什么时候暂时停手。',
19
+ 'section.autoloop.title': '自主循环',
20
+ 'section.autoloop.description': '每个回合结束后自动把对话交还给 Agent,直到手动停止。',
19
21
  'section.safety.title': '安全节奏',
20
22
  'section.safety.description': '先确认上一步,再控制等待与连续续跑的边界。',
21
23
  'section.recovery.title': '恢复雷达',
@@ -34,6 +36,11 @@ export const zh = {
34
36
  'default.continueTextMaxTokens': LOCALIZED_TEXT_DEFAULTS.zh.continueTextMaxTokens,
35
37
  'field.resumeSilentTurns': '续跑无输出回合',
36
38
  'field.resumeSilentTurnsHint': '已观察到模型活动但没有可见输出时续跑;不把空回合、图片或扩展内容误判为静默,冷却与连续上限照常生效。',
39
+ 'field.resumeCompletedTurns': '自主循环(每个回合后都续跑)',
40
+ 'field.resumeCompletedTurnsHint': '每个正常完成的回合结束后立即把对话交还给 Agent,无限循环直到你手动停止或发送消息。连续失败上限只对失败生效,成功的回合不计入。',
41
+ 'field.continueTextLoop': '自主循环的继续文本',
42
+ 'field.continueTextLoopHint': '自主循环每次续跑时发送的文本。',
43
+ 'default.continueTextLoop': LOCALIZED_TEXT_DEFAULTS.zh.continueTextLoop,
37
44
  'field.continueTextSilent': '无输出回合的继续文本',
38
45
  'field.continueTextSilentHint': '回合只输出推理就结束时自动发送的文本, 支持与继续文本相同的占位符。',
39
46
  'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.zh.continueTextSilent,
@@ -130,6 +137,8 @@ export const en: Record<SettingsCardKey, string> = {
130
137
  'repo.aria': 'Open the dsh-auto-continue repository on GitHub and star it',
131
138
  'section.handoff.title': 'The handoff',
132
139
  'section.handoff.description': 'Choose what gets sent after an interruption and when the relay should stand down.',
140
+ 'section.autoloop.title': 'Autonomous loop',
141
+ 'section.autoloop.description': 'Hand the thread back after every completed turn until manually stopped.',
133
142
  'section.safety.title': 'Safety rhythm',
134
143
  'section.safety.description': 'Confirm the previous step, then set the boundaries for waiting and repeated resumes.',
135
144
  'section.recovery.title': 'Recovery radar',
@@ -148,6 +157,11 @@ export const en: Record<SettingsCardKey, string> = {
148
157
  'default.continueTextMaxTokens': LOCALIZED_TEXT_DEFAULTS.en.continueTextMaxTokens,
149
158
  'field.resumeSilentTurns': 'Resume silent turns',
150
159
  '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.',
160
+ 'field.resumeCompletedTurns': 'Autonomous loop (continue after every turn)',
161
+ 'field.resumeCompletedTurnsHint': 'Hand the thread back to the agent after every completed turn, looping until you press stop or send a message. The consecutive-failure cap only throttles failures; successful turns never count.',
162
+ 'field.continueTextLoop': 'Continue text (autonomous loop)',
163
+ 'field.continueTextLoopHint': 'Text sent on each autonomous-loop continuation.',
164
+ 'default.continueTextLoop': LOCALIZED_TEXT_DEFAULTS.en.continueTextLoop,
151
165
  'field.continueTextSilent': 'Continue text (silent turn)',
152
166
  'field.continueTextSilentHint': 'Text sent when a turn ends with reasoning only; same placeholders as the continue text.',
153
167
  'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.en.continueTextSilent,
@@ -40,6 +40,8 @@ export interface AutoContinueSettingsCardState extends CardShell {
40
40
  continueText: CardFieldState;
41
41
  continueTextMaxTokens: CardFieldState;
42
42
  resumeSilentTurns: CardFieldState;
43
+ resumeCompletedTurns: CardFieldState;
44
+ continueTextLoop: CardFieldState;
43
45
  continueTextSilent: CardFieldState;
44
46
  guardTools: CardFieldState;
45
47
  guardPendingText: CardFieldState;
@@ -87,6 +89,8 @@ export class AutoContinueSettingsCardController {
87
89
  textField('continueText'),
88
90
  textField('continueTextMaxTokens'),
89
91
  booleanField('resumeSilentTurns'),
92
+ booleanField('resumeCompletedTurns'),
93
+ textField('continueTextLoop'),
90
94
  textField('continueTextSilent'),
91
95
  booleanField('guardTools'),
92
96
  textField('guardPendingText'),
@@ -121,6 +125,8 @@ export class AutoContinueSettingsCardController {
121
125
  continueText: this.form.field('continueText'),
122
126
  continueTextMaxTokens: this.form.field('continueTextMaxTokens'),
123
127
  resumeSilentTurns: this.form.field('resumeSilentTurns'),
128
+ resumeCompletedTurns: this.form.field('resumeCompletedTurns'),
129
+ continueTextLoop: this.form.field('continueTextLoop'),
124
130
  continueTextSilent: this.form.field('continueTextSilent'),
125
131
  guardTools: this.form.field('guardTools'),
126
132
  guardPendingText: this.form.field('guardPendingText'),
@@ -412,7 +418,7 @@ function BooleanField(props: FieldProps) {
412
418
  );
413
419
  }
414
420
 
415
- type SettingsSectionTone = 'handoff' | 'safety' | 'recovery' | 'loop' | 'live';
421
+ type SettingsSectionTone = 'handoff' | 'autoloop' | 'safety' | 'recovery' | 'loop' | 'live';
416
422
 
417
423
  /** A real behavior group, not a decorative divider: each section maps to one phase of the relay. */
418
424
  function SettingsSection(props: {
@@ -622,6 +628,35 @@ export function AutoContinueSettingsCard(props: AutoContinueSettingsCardProps) {
622
628
  />
623
629
  </SettingsSection>
624
630
 
631
+ <SettingsSection
632
+ t={t}
633
+ titleKey="section.autoloop.title"
634
+ descriptionKey="section.autoloop.description"
635
+ tone="autoloop"
636
+ >
637
+ <BooleanField
638
+ wide
639
+ id="auto-continue-resume-completed-turns"
640
+ label={t('field.resumeCompletedTurns')}
641
+ hint={t('field.resumeCompletedTurnsHint')}
642
+ {...shared}
643
+ {...state.resumeCompletedTurns}
644
+ onEdit={(text) => props.edit('resumeCompletedTurns', text)}
645
+ onReset={() => props.resetField('resumeCompletedTurns')}
646
+ />
647
+ <ValueField
648
+ wide
649
+ id="auto-continue-continue-text-loop"
650
+ label={t('field.continueTextLoop')}
651
+ hint={t('field.continueTextLoopHint')}
652
+ {...shared}
653
+ {...state.continueTextLoop}
654
+ onEdit={(text) => props.edit('continueTextLoop', text)}
655
+ placeholder={t('default.continueTextLoop')}
656
+ onReset={() => props.resetField('continueTextLoop')}
657
+ />
658
+ </SettingsSection>
659
+
625
660
  <SettingsSection
626
661
  t={t}
627
662
  titleKey="section.safety.title"
@@ -10,6 +10,7 @@ const css = `
10
10
  --dsh-ac-violet: #8b7cff;
11
11
  --dsh-ac-cyan: #45cce5;
12
12
  --dsh-ac-mint: #46d69d;
13
+ --dsh-ac-red: #e5484d;
13
14
  --dsh-ac-amber: #f1b95c;
14
15
  isolation: isolate;
15
16
  position: relative;
@@ -232,6 +233,7 @@ const css = `
232
233
  background: color-mix(in srgb, var(--dsw-alias-bg-layer-3) 95%, var(--dsh-ac-section) 5%);
233
234
  }
234
235
  .dshAcFormSection-handoff { --dsh-ac-section: var(--dsh-ac-mint); }
236
+ .dshAcFormSection-autoloop { --dsh-ac-section: var(--dsh-ac-red); }
235
237
  .dshAcFormSection-safety { --dsh-ac-section: var(--dsh-ac-amber); }
236
238
  .dshAcFormSection-recovery { --dsh-ac-section: var(--dsh-ac-cyan); }
237
239
  .dshAcFormSection-loop { --dsh-ac-section: var(--dsh-ac-violet); }