dsh-client-auto-continue 0.7.2 → 0.7.3

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 CHANGED
@@ -43,7 +43,7 @@ For [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh we
43
43
  - **Idempotency guard** — before resuming, the plugin inspects the last tool call: if its result is unconfirmed (the turn died mid-tool, e.g. a `git push` that may have gone through), the resume message tells the model to check state first and not to rerun; if the tool is confirmed done, it says so and asks not to repeat it; a failed tool gets no guard (retrying it is the point). Both guard texts are configurable (`{tool}` / `{result}` placeholders)
44
44
  - **Pause** — a global **Pause auto-continue** toggle in the settings card stops everything (live + scan) instantly; per-session pauses (e.g. via a notification button) suspend only one session until they expire. The **Resume now** notification button is the one explicit exception: pressing it is the user asking for exactly one send, pause or not
45
45
  - **Notification buttons** — notifications carry **Resume now** (send immediately, ignoring cooldown, the consecutive cap and any pause) and **Pause this session 1h** actions
46
- - **Loop guard** — watches **running** turns too: many short model messages inside a short time window with no tool call in between (the "Let me read…" spin), or the same tool called repeatedly with the **same arguments and the same results** (a changed argument or result counts as progress), trips the guard, which cancels the turn and restarts it with a configurable loop text ("stop repeating, try another way"). The cancel carries an internal marker so it is never confused with a user stop — the restart only happens for guard-initiated cancels. Thresholds, the time window and the loop text are configurable
46
+ - **Loop guard** — watches **running** turns too. Three signals trip the guard, which cancels the turn and restarts it with a configurable loop text ("stop repeating, try another way"): the model repeating the **exact same message** several times (any length — e.g. "Let me test variants of the regex…" ×7), many short messages inside a short time window with no tool call in between (the "Let me read…" spin), or the same tool called repeatedly with the **same arguments and the same results** (a changed argument or result counts as progress). The cancel carries an internal marker so it is never confused with a user stop — the restart only happens for guard-initiated cancels. Thresholds, the time window and the loop text are configurable
47
47
  - **Stats panel** — the settings card shows today's auto-continue count, recoveries, failures, permanent skips, give-ups and loop breaks, broken down by error code, with a one-click reset
48
48
  - **Browser notifications** — optional alerts when auto-continue fires, gives up, or hits a permanent error; the browser asks for permission on first use, and nothing is shown again after a denial
49
49
 
@@ -177,6 +177,7 @@ auto-continue:
177
177
  loopShortChars: 40
178
178
  loopWindowMs: 30000
179
179
  loopShortCount: 12
180
+ loopRepeatText: 4
180
181
  loopToolRepeat: 5
181
182
  loopText: '(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)'
182
183
  ```
@@ -202,6 +203,7 @@ auto-continue:
202
203
  | Short-sentence max (chars) | `40` | A model message shorter than this counts as a short sentence (spinning signal) |
203
204
  | Short-sentence window (ms) | `30000` | Consecutive short sentences must land inside this window; normal thinking spread over time is not misjudged |
204
205
  | Short-sentence threshold | `12` | Consecutive short sentences inside the window, with no tool call in between, trip the loop guard |
206
+ | Identical message count | `4` | Consecutive identical messages (any length) trip the loop guard — the strongest spinning signal |
205
207
  | Same-tool repeat count | `5` | Consecutive calls of the same tool with identical arguments and results trip the loop guard |
206
208
  | Loop text | `(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)` | Text sent after the loop guard restarts a turn; `{tool}` placeholder |
207
209
  | Guard text (unconfirmed result) | `(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)` | Appended when the last tool may have partially executed; `{tool}` placeholder |
@@ -241,7 +243,7 @@ The plugin is browser-only and touches **no files, credentials, or network beyon
241
243
  npm run typecheck # tsc --noEmit
242
244
  npm run build # lib/client.js + lib/index.js + lib/types
243
245
  npm run watch # rebuild on change; host HMR hot-reloads without a page refresh
244
- npm run test # node tests/simulate.mjs — 36 behavioral scenarios
246
+ npm run test # node tests/simulate.mjs — 38 behavioral scenarios
245
247
  ```
246
248
 
247
249
  While `npm run watch` runs, the profile's client-hmr row polls `lib/client.js` every 500 ms and hot-reloads the plugin in the browser — no server restart needed for code changes.
package/README.zh.md CHANGED
@@ -43,7 +43,7 @@
43
43
  - **幂等护栏** — 续跑前检查上一步工具调用: 结果未确认(回合在工具执行中途夭折, 如 `git push` 可能已经推上去了)时, 续跑消息会提示模型先确认状态、不要重复执行; 工具已确认成功时说明已完成、请勿重复; 工具失败则不加护栏(重试本来就是目的)。两段护栏文本都可配置(支持 `{tool}` / `{result}` 占位符)
44
44
  - **暂停** — 设置卡片里的全局 **暂停自动继续** 开关可立即停掉一切(实时 + 扫描); 会话级暂停(如通过通知按钮)只挂起单个会话, 到期自动恢复。唯一的显式例外是通知里的 **立即续跑** 按钮——按下它等于用户明确要求发送这一次, 不受暂停限制
45
45
  - **通知按钮** — 通知带 **立即续跑**(无视冷却、连续上限与暂停, 马上发送)和 **暂停该会话 1 小时** 按钮
46
- - **循环守卫** — 连**运行中的回合**也盯着: 短时间内连续多条短句且期间无工具调用(典型的「Let me read…」空转), 或同一工具被连续反复调用且**参数与结果都相同**(参数或结果有变化视为有进展), 都会触发守卫: 取消当前回合并用可配置的循环提示文本重启(「停止重复, 换一种方式」)。取消带有内部来源标记, 绝不会与用户手动停止混淆——只有守卫发起的取消才会重启。阈值、时间窗与提示文本都可配置
46
+ - **循环守卫** — 连**运行中的回合**也盯着, 三个信号都会触发守卫(取消当前回合并用可配置的循环提示文本重启, 「停止重复, 换一种方式」): 模型**连续输出完全相同的消息**(不限长度, 如 "Let me test variants of the regex…" 连续 7 遍)、短时间内连续多条短句且期间无工具调用(典型的「Let me read…」空转)、或同一工具被连续反复调用且**参数与结果都相同**(参数或结果有变化视为有进展)。取消带有内部来源标记, 绝不会与用户手动停止混淆——只有守卫发起的取消才会重启。阈值、时间窗与提示文本都可配置
47
47
  - **统计面板** — 设置卡片展示今日自动继续次数、恢复成功、继续后失败、永久性跳过、达上限停止、循环打断, 按错误码统计, 可一键清零
48
48
  - **浏览器通知** — 可选: 自动继续成功 / 放弃 / 遇到永久性错误时弹出提醒; 首次使用时请求权限, 被拒绝后不再打扰
49
49
 
@@ -177,6 +177,7 @@ auto-continue:
177
177
  loopShortChars: 40
178
178
  loopWindowMs: 30000
179
179
  loopShortCount: 12
180
+ loopRepeatText: 4
180
181
  loopToolRepeat: 5
181
182
  loopText: '(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)'
182
183
  ```
@@ -202,6 +203,7 @@ auto-continue:
202
203
  | 短句长度上限 (字符) | `40` | 模型消息文本短于该值计为一条短句(空转信号) |
203
204
  | 短句时间窗 (ms) | `30000` | 连续短句必须落在这个时间窗内; 正常思考的短文本散布在长时间里不会被误判 |
204
205
  | 连续短句阈值 | `12` | 时间窗内连续多少条短句且期间无工具调用时判定空转循环 |
206
+ | 相同消息重复次数 | `4` | 连续输出多少条完全相同的消息时判定空转(不限长度, 最强信号) |
205
207
  | 同工具重复次数 | `5` | 同工具+同参数+同结果的连续调用多少次时判定死循环 |
206
208
  | 循环提示文本 | `(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)` | 打断后重启回合时发送的文本; 支持 {tool} 占位符 |
207
209
  | 结果未确认时的护栏文本 | `(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)` | 上一步工具可能已部分执行时附加; 支持 {tool} 占位符 |
@@ -241,7 +243,7 @@ auto-continue:
241
243
  npm run typecheck # tsc --noEmit
242
244
  npm run build # lib/client.js + lib/index.js + lib/types
243
245
  npm run watch # 监听变更自动重建; 宿主 HMR 免刷新热重载
244
- npm run test # node tests/simulate.mjs — 36 个行为场景
246
+ npm run test # node tests/simulate.mjs — 38 个行为场景
245
247
  ```
246
248
 
247
249
  `npm run watch` 运行时, profile 的 client-hmr 行每 500ms 轮询 `lib/client.js` 并在浏览器中热重载插件——改代码无需重启服务。
package/lib/client.js CHANGED
@@ -63,6 +63,7 @@ var DEFAULT_CONFIG = {
63
63
  loopShortChars: 40,
64
64
  loopWindowMs: 3e4,
65
65
  loopShortCount: 12,
66
+ loopRepeatText: 4,
66
67
  loopToolRepeat: 5,
67
68
  loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)"
68
69
  };
@@ -102,6 +103,7 @@ function resolveConfig(section) {
102
103
  loopShortChars: Math.max(1, numberOr(value.loopShortChars, DEFAULT_CONFIG.loopShortChars)),
103
104
  loopWindowMs: Math.max(1e3, numberOr(value.loopWindowMs, DEFAULT_CONFIG.loopWindowMs)),
104
105
  loopShortCount: Math.max(2, numberOr(value.loopShortCount, DEFAULT_CONFIG.loopShortCount)),
106
+ loopRepeatText: Math.max(2, numberOr(value.loopRepeatText, DEFAULT_CONFIG.loopRepeatText)),
105
107
  loopToolRepeat: Math.max(2, numberOr(value.loopToolRepeat, DEFAULT_CONFIG.loopToolRepeat)),
106
108
  loopText: typeof value.loopText === "string" && value.loopText.trim() !== "" ? value.loopText : DEFAULT_CONFIG.loopText
107
109
  };
@@ -334,6 +336,8 @@ var freshState = () => ({
334
336
  pendingRecoveryAt: 0,
335
337
  shortRun: 0,
336
338
  lastShortAt: 0,
339
+ lastAssistantText: "",
340
+ sameTextRun: 0,
337
341
  toolRun: void 0,
338
342
  loopFired: false,
339
343
  loopCancelled: false
@@ -506,7 +510,14 @@ ${frame.event.data.arguments}`;
506
510
  onAssistantMessage(sessionId, state, event) {
507
511
  if (!this.getConfig().loopGuard) return;
508
512
  const text = this.assistantText(event);
509
- if (text.trim().length < this.getConfig().loopShortChars) {
513
+ const trimmed = text.trim();
514
+ if (trimmed !== "" && trimmed === state.lastAssistantText) {
515
+ state.sameTextRun += 1;
516
+ } else {
517
+ state.lastAssistantText = trimmed;
518
+ state.sameTextRun = 1;
519
+ }
520
+ if (trimmed.length < this.getConfig().loopShortChars) {
510
521
  const now = Date.now();
511
522
  if (now - state.lastShortAt > this.getConfig().loopWindowMs) {
512
523
  state.shortRun = 0;
@@ -525,7 +536,10 @@ ${frame.event.data.arguments}`;
525
536
  if (state.loopFired) return;
526
537
  if (!state.running) return;
527
538
  const config = this.getConfig();
528
- if (state.shortRun >= config.loopShortCount) {
539
+ if (state.sameTextRun >= config.loopRepeatText) {
540
+ this.log(`检测到空转循环 ${sessionId}: 连续 ${state.sameTextRun} 条相同消息`);
541
+ void this.interruptLoop(sessionId, state);
542
+ } else if (state.shortRun >= config.loopShortCount) {
529
543
  this.log(`检测到空转循环 ${sessionId}: 连续 ${state.shortRun} 条短句且无工具调用`);
530
544
  void this.interruptLoop(sessionId, state);
531
545
  } else if (state.toolRun !== void 0 && state.toolRun.count >= config.loopToolRepeat) {
@@ -568,6 +582,8 @@ ${frame.event.data.arguments}`;
568
582
  state.lastToolResult = void 0;
569
583
  state.shortRun = 0;
570
584
  state.lastShortAt = 0;
585
+ state.lastAssistantText = "";
586
+ state.sameTextRun = 0;
571
587
  state.toolRun = void 0;
572
588
  state.loopFired = false;
573
589
  state.loopCancelled = false;
@@ -589,6 +605,8 @@ ${frame.event.data.arguments}`;
589
605
  state.pendingRecoveryAt = 0;
590
606
  state.shortRun = 0;
591
607
  state.lastShortAt = 0;
608
+ state.lastAssistantText = "";
609
+ state.sameTextRun = 0;
592
610
  state.toolRun = void 0;
593
611
  state.lastAttemptAt = 0;
594
612
  this.schedule(sessionId, "loop:aborted");
@@ -1082,6 +1100,8 @@ var zh = {
1082
1100
  "field.loopWindowMsHint": "连续短句必须落在这个时间窗内; 正常思考的短文本散布在长时间里不会被误判。",
1083
1101
  "field.loopShortCount": "连续短句阈值",
1084
1102
  "field.loopShortCountHint": "时间窗内连续多少条短句且期间无工具调用时判定空转循环。",
1103
+ "field.loopRepeatText": "相同消息重复次数",
1104
+ "field.loopRepeatTextHint": "连续输出多少条完全相同的消息时判定空转(最强信号, 不限长度, 如模型反复说同一句话)。",
1085
1105
  "field.loopToolRepeat": "同工具重复次数",
1086
1106
  "field.loopToolRepeatHint": "同工具+同参数+同结果的连续调用多少次时判定死循环; 参数或结果有变化视为有进展。",
1087
1107
  "field.loopText": "循环提示文本",
@@ -1165,6 +1185,8 @@ var en = {
1165
1185
  "field.loopWindowMsHint": "Consecutive short sentences must land inside this window; normal thinking spread over time is not misjudged.",
1166
1186
  "field.loopShortCount": "Short-sentence threshold",
1167
1187
  "field.loopShortCountHint": "How many consecutive short sentences inside the window, with no tool call, trip the loop guard.",
1188
+ "field.loopRepeatText": "Identical message count",
1189
+ "field.loopRepeatTextHint": "How many consecutive identical messages trip the guard (strongest signal, any length, e.g. the model repeating the same line).",
1168
1190
  "field.loopToolRepeat": "Same-tool repeat count",
1169
1191
  "field.loopToolRepeatHint": "How many consecutive calls of the same tool with identical arguments and results trip the loop guard; a changed argument or result counts as progress.",
1170
1192
  "field.loopText": "Loop text",
@@ -1578,6 +1600,7 @@ var AutoContinueSettingsCardController = class {
1578
1600
  numberField("loopShortChars", 1),
1579
1601
  numberField("loopWindowMs", 1e3),
1580
1602
  numberField("loopShortCount", 2),
1603
+ numberField("loopRepeatText", 2),
1581
1604
  numberField("loopToolRepeat", 2),
1582
1605
  textField("loopText")
1583
1606
  ]);
@@ -1609,6 +1632,7 @@ var AutoContinueSettingsCardController = class {
1609
1632
  loopShortChars: this.form.field("loopShortChars"),
1610
1633
  loopWindowMs: this.form.field("loopWindowMs"),
1611
1634
  loopShortCount: this.form.field("loopShortCount"),
1635
+ loopRepeatText: this.form.field("loopRepeatText"),
1612
1636
  loopToolRepeat: this.form.field("loopToolRepeat"),
1613
1637
  loopText: this.form.field("loopText")
1614
1638
  };
@@ -2150,6 +2174,19 @@ function AutoContinueSettingsCard(props) {
2150
2174
  onReset: () => props.resetField("loopToolRepeat")
2151
2175
  }
2152
2176
  ),
2177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2178
+ ValueField,
2179
+ {
2180
+ id: "auto-continue-loop-repeat-text",
2181
+ label: t("field.loopRepeatText"),
2182
+ hint: t("field.loopRepeatTextHint"),
2183
+ numeric: true,
2184
+ ...shared,
2185
+ ...state.loopRepeatText,
2186
+ onEdit: (text) => props.edit("loopRepeatText", text),
2187
+ onReset: () => props.resetField("loopRepeatText")
2188
+ }
2189
+ ),
2153
2190
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2154
2191
  ValueField,
2155
2192
  {