dsh-client-auto-continue 0.21.0 → 0.22.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
@@ -1127,6 +1127,7 @@ function resolveLocale(locale) {
1127
1127
  if (typeof locale !== "string") return "en";
1128
1128
  if (/^zh(?:-|$)/i.test(locale)) return "zh";
1129
1129
  if (/^ru(?:-|$)/i.test(locale)) return "ru";
1130
+ if (/^ja(?:-|$)/i.test(locale)) return "ja";
1130
1131
  return "en";
1131
1132
  }
1132
1133
  var isSessionMode = (value) => value === "default" || value === "off" || value === "recover" || value === "loop";
@@ -1166,6 +1167,17 @@ var LOCALIZED_TEXT_DEFAULTS = {
1166
1167
  guardPendingText: "(Предыдущий инструмент «{tool}», возможно, не завершился. Проверь его состояние перед продолжением и не запускай его повторно.)",
1167
1168
  guardDoneText: "(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)",
1168
1169
  loopText: "(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)"
1170
+ },
1171
+ ja: {
1172
+ continueText: "続けて",
1173
+ continueTextMaxTokens: "続けて",
1174
+ continueTextSilent: "続けて。前のターンは内部の推論だけで終わり、返信もツール呼び出しもなかったため、ユーザーには何も表示されていません。ターンは必ずツール呼び出しか目に見える返信で終えてください。",
1175
+ continueTextLoop: "続けて",
1176
+ continueTextInterrupted: "続けて。前のターンの実行中にホストが再起動しました。再起動時に未完了だったツール呼び出しは「結果不明」として記録されています。中断したところから再開し、副作用のある操作をやり直す前に外部の状態を確認してください。",
1177
+ continueTextQuestion: "これはホストの再起動後にプラグインが自動で送ったメッセージで、ユーザーの返答ではありません。あなたがユーザーにした質問は再起動で中断され、まだ答えがありません。同じ質問をもう一度して、答えを待ってください。ユーザーの代わりに決めないでください。",
1178
+ guardPendingText: "(前のツール「{tool}」は完了していない可能性があります。続ける前に状態を確認し、再実行しないでください)",
1179
+ guardDoneText: "(前のツール「{tool}」は正常に完了しました。結果: {result}。再実行せず、そこから続けてください)",
1180
+ loopText: "(ループに陥っている可能性があります。直前の動作を繰り返すのをやめ、別の方法で続けてください)"
1169
1181
  }
1170
1182
  };
1171
1183
  var DEFAULT_CONFIG = {
@@ -1203,7 +1215,8 @@ var DEFAULT_CONFIG = {
1203
1215
  resumePausedGoals: false,
1204
1216
  pauseWhenOffline: true,
1205
1217
  offlineCheckMs: 15e3,
1206
- loopMaxIterations: 0
1218
+ loopMaxIterations: 0,
1219
+ loopStopMarker: ""
1207
1220
  };
1208
1221
  function numberOr(value, fallback) {
1209
1222
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
@@ -1268,7 +1281,8 @@ function resolveConfig(section) {
1268
1281
  resumePausedGoals: booleanOr(value.resumePausedGoals, DEFAULT_CONFIG.resumePausedGoals),
1269
1282
  pauseWhenOffline: booleanOr(value.pauseWhenOffline, DEFAULT_CONFIG.pauseWhenOffline),
1270
1283
  offlineCheckMs: Math.max(1e3, numberOr(value.offlineCheckMs, DEFAULT_CONFIG.offlineCheckMs)),
1271
- loopMaxIterations: Math.floor(numberOr(value.loopMaxIterations, DEFAULT_CONFIG.loopMaxIterations))
1284
+ loopMaxIterations: Math.floor(numberOr(value.loopMaxIterations, DEFAULT_CONFIG.loopMaxIterations)),
1285
+ loopStopMarker: typeof value.loopStopMarker === "string" ? value.loopStopMarker.trim() : DEFAULT_CONFIG.loopStopMarker
1272
1286
  };
1273
1287
  }
1274
1288
  function isNonHumanReason(kind) {
@@ -1659,7 +1673,12 @@ var freshState = () => ({
1659
1673
  offlineSince: 0,
1660
1674
  loopIterations: 0,
1661
1675
  loopCapNotified: false,
1662
- loopEnabled: void 0
1676
+ loopEnabled: void 0,
1677
+ turnVisibleText: "",
1678
+ turnStopMarker: "",
1679
+ loopStopped: false,
1680
+ loopEpoch: 0,
1681
+ turnLoopEpoch: 0
1663
1682
  });
1664
1683
  var RECOVERY_WINDOW_MS = 10 * 60 * 1e3;
1665
1684
  var ECHO_WINDOW_MS = 10 * 60 * 1e3;
@@ -1753,7 +1772,9 @@ var NOTICE_COPY = {
1753
1772
  stoppedTitle: "dsh-auto-continue: 已达到重试上限",
1754
1773
  stoppedBody: (sessionId, count) => `${sessionId}: 已连续尝试恢复 ${count} 次。请检查会话后再继续。`,
1755
1774
  loopCapTitle: "dsh-auto-continue: 自主循环已到上限",
1756
- loopCapBody: (sessionId, count) => `${sessionId}: 已自主续跑 ${count} 轮, 循环暂停; 发一条消息或重新开启循环即可继续`
1775
+ loopCapBody: (sessionId, count) => `${sessionId}: 已自主续跑 ${count} 轮, 循环暂停; 发一条消息或重新开启循环即可继续`,
1776
+ loopDoneTitle: "dsh-auto-continue: 自主循环已完成",
1777
+ loopDoneBody: (sessionId) => `${sessionId}: 模型写出了完成标记, 循环已停止; 发一条消息或重新开启循环即可继续`
1757
1778
  },
1758
1779
  en: {
1759
1780
  notContinuedTitle: "dsh-auto-continue: Review session error",
@@ -1765,7 +1786,9 @@ var NOTICE_COPY = {
1765
1786
  stoppedTitle: "dsh-auto-continue: Retry limit reached",
1766
1787
  stoppedBody: (sessionId, count) => `${sessionId}: Consecutive recovery attempts: ${count}. Review the conversation before continuing.`,
1767
1788
  loopCapTitle: "dsh-auto-continue: Autonomous loop limit reached",
1768
- loopCapBody: (sessionId, count) => `${sessionId}: Stopped after ${count} autonomous rounds; send a message or turn the loop back on to keep going`
1789
+ loopCapBody: (sessionId, count) => `${sessionId}: Stopped after ${count} autonomous rounds; send a message or turn the loop back on to keep going`,
1790
+ loopDoneTitle: "dsh-auto-continue: Autonomous loop finished",
1791
+ loopDoneBody: (sessionId) => `${sessionId}: The model wrote the stop marker, so the loop stopped; send a message or turn the loop back on to keep going`
1769
1792
  },
1770
1793
  ru: {
1771
1794
  notContinuedTitle: "dsh-auto-continue: продолжение не выполнено",
@@ -1777,7 +1800,23 @@ var NOTICE_COPY = {
1777
1800
  stoppedTitle: "dsh-auto-continue: авто-продолжение остановлено",
1778
1801
  stoppedBody: (sessionId, count) => `${sessionId}: сбоев подряд: ${count}; нужно вмешательство вручную`,
1779
1802
  loopCapTitle: "dsh-auto-continue: достигнут лимит автономного цикла",
1780
- loopCapBody: (sessionId, count) => `${sessionId}: остановлено после ${count} автономных раундов; отправьте сообщение или включите цикл снова, чтобы продолжить`
1803
+ loopCapBody: (sessionId, count) => `${sessionId}: остановлено после ${count} автономных раундов; отправьте сообщение или включите цикл снова, чтобы продолжить`,
1804
+ loopDoneTitle: "dsh-auto-continue: автономный цикл завершён",
1805
+ loopDoneBody: (sessionId) => `${sessionId}: модель написала маркер завершения, цикл остановлен; отправьте сообщение или включите цикл снова, чтобы продолжить`
1806
+ },
1807
+ ja: {
1808
+ notContinuedTitle: "dsh-auto-continue: セッションのエラーを確認してください",
1809
+ permanentErrorBody: (sessionId, summary) => `${sessionId}: ${summary}。このエラーを解決してから続けてください。`,
1810
+ resumeAction: "今すぐ再開",
1811
+ pauseAction: "このセッションを 1 時間一時停止",
1812
+ continuedTitle: "dsh-auto-continue: 続行メッセージを送信しました",
1813
+ continuedBody: (sessionId, text, count) => `${sessionId}: 「${text}」を送信しました(連続試行 ${count} 回)`,
1814
+ stoppedTitle: "dsh-auto-continue: 再試行の上限に達しました",
1815
+ stoppedBody: (sessionId, count) => `${sessionId}: 復旧を ${count} 回連続で試みました。会話を確認してから続けてください。`,
1816
+ loopCapTitle: "dsh-auto-continue: 自律ループの上限に達しました",
1817
+ loopCapBody: (sessionId, count) => `${sessionId}: 自律ループを ${count} ラウンド実行して停止しました。続けるにはメッセージを送るか、ループをもう一度オンにしてください`,
1818
+ loopDoneTitle: "dsh-auto-continue: 自律ループが完了しました",
1819
+ loopDoneBody: (sessionId) => `${sessionId}: モデルが完了マーカーを書いたため、ループを停止しました。続けるにはメッセージを送るか、ループをもう一度オンにしてください`
1781
1820
  }
1782
1821
  };
1783
1822
  var LOOP_GUARD_CANCEL_CAUSE = {
@@ -1788,6 +1827,20 @@ var LOOP_COMPLETED_REASON = "turn/end:completed";
1788
1827
  var LOOP_SILENT_REASON = "turn/end:loop-silent";
1789
1828
  var MANUAL_NOTIFICATION_REASON = "manual:notification";
1790
1829
  var ASK_USER_QUESTION_TOOL = "ask_user_question";
1830
+ function stopMarkerReported(text, marker) {
1831
+ const wanted = marker.trim();
1832
+ if (wanted === "") return false;
1833
+ let fenced = false;
1834
+ for (const raw of text.split(/\r?\n/)) {
1835
+ const line = raw.trim();
1836
+ if (line.startsWith("```") || line.startsWith("~~~")) {
1837
+ fenced = !fenced;
1838
+ continue;
1839
+ }
1840
+ if (!fenced && line === wanted) return true;
1841
+ }
1842
+ return false;
1843
+ }
1791
1844
  var SWEEP_OBSERVE_BATCH = 16;
1792
1845
  var STORED_READ_TIMEOUT_MS = 5e3;
1793
1846
  var SWEEP_MAX_FAILURES = 3;
@@ -1801,7 +1854,8 @@ var REVIVE_TIMEOUT_MS = 15e3;
1801
1854
  var HANDOFF_COPY = {
1802
1855
  zh: (child, code) => `子代理会话 ${child} 因 ${code} 中断, 已无法直接续跑。请检查它的状态, 然后继续或收尾。`,
1803
1856
  en: (child, code) => `Child session ${child} was interrupted by ${code} and can no longer be resumed directly. Check its state, then continue it or wrap it up.`,
1804
- ru: (child, code) => `Дочерняя сессия ${child} прервалась из-за ${code} и больше не может быть продолжена напрямую. Проверь её состояние и продолжи или заверши.`
1857
+ ru: (child, code) => `Дочерняя сессия ${child} прервалась из-за ${code} и больше не может быть продолжена напрямую. Проверь её состояние и продолжи или заверши.`,
1858
+ ja: (child, code) => `サブエージェントのセッション ${child} は ${code} で中断され、直接は再開できなくなりました。状態を確認してから、続けるか締めくくってください。`
1805
1859
  };
1806
1860
  var GOALS_SERVICE_KEY = "goals";
1807
1861
  var PROJECTION_CACHE_SERVICE_KEY = "sessionProjectionCache";
@@ -1826,6 +1880,31 @@ var CHILD_CAUSE_COPY = {
1826
1880
  interrupted: "закрыт восстановлением после сбоя",
1827
1881
  "max-tokens": "достигнут лимит вывода",
1828
1882
  error: "повторяемая ошибка"
1883
+ },
1884
+ ja: {
1885
+ "open-turn": "ターン開始後に中断",
1886
+ disposed: "ホストがエージェントを破棄",
1887
+ interrupted: "クラッシュ復旧で終了",
1888
+ "max-tokens": "出力上限に到達",
1889
+ error: "再試行可能なエラー"
1890
+ }
1891
+ };
1892
+ var CHILD_RESUME_COPY = {
1893
+ zh: {
1894
+ header: "重启时你开的以下子代理 / 团队成员会话被打断, 没有跑完。请逐个检查, 按需要继续或收尾:",
1895
+ tail: "要继续的用 send_message / subagent 重新拉起对应会话(重启后它们并未加载); 已完成或不再需要的, 说明结论即可。"
1896
+ },
1897
+ en: {
1898
+ header: "These child sessions you started (subagent / team member) were interrupted by a restart and did not finish. Check each one and either continue it or wrap it up:",
1899
+ tail: "Use send_message (or subagent) to bring back the ones that should continue — they are not loaded after the restart; for finished or abandoned ones, just state the conclusion."
1900
+ },
1901
+ ru: {
1902
+ header: "Эти дочерние сессии, которые ты запустил (субагент / участник команды), были прерваны перезапуском и не завершились. Проверь каждую и продолжи её или заверши:",
1903
+ tail: "Те, что нужно продолжить, верни через send_message (или subagent) — после перезапуска они не загружены; для завершённых или ненужных просто подведи итог."
1904
+ },
1905
+ ja: {
1906
+ header: "あなたが起動した次の子セッション(サブエージェント / チームメンバー)は再起動で中断され、終わっていません。1 つずつ確認し、続けるか締めくくってください:",
1907
+ tail: "続けるものは send_message(または subagent)で呼び戻してください。再起動後は読み込まれていません。完了したものや不要になったものは、結論を述べるだけで構いません。"
1829
1908
  }
1830
1909
  };
1831
1910
  var isLoopReason = (reason) => reason === LOOP_COMPLETED_REASON || reason === LOOP_SILENT_REASON;
@@ -1888,6 +1967,17 @@ function isHostCancel(value) {
1888
1967
  const cause = readCancelCause(value);
1889
1968
  return cause !== void 0 && RESTART_CANCEL_CAUSES.has(cause);
1890
1969
  }
1970
+ function goalStoppedByUser(events) {
1971
+ for (let index = events.length - 1; index >= 0; index -= 1) {
1972
+ const event = events[index];
1973
+ if (event.type === "goal/change") {
1974
+ if (event.data?.operation === "resume" || event.data?.operation === "create") return false;
1975
+ } else if (event.type === "turn/end" && readCancelCause(event.data?.reason) === "user") {
1976
+ return true;
1977
+ }
1978
+ }
1979
+ return false;
1980
+ }
1891
1981
  function classifyChildInterruption(events, config) {
1892
1982
  let lastEnd;
1893
1983
  for (let i = events.length - 1; i >= 0; i -= 1) {
@@ -2405,6 +2495,7 @@ var AutoContinueRunner = class {
2405
2495
  if (this.tracksOutput(state, event)) {
2406
2496
  if (this.hasVisibleContent(event.data.message.content)) state.turnOutput = "visible";
2407
2497
  else if (state.turnOutput === "empty") state.turnOutput = "silent";
2498
+ if (state.turnStopMarker !== "") state.turnVisibleText += this.assistantText(event);
2408
2499
  }
2409
2500
  this.onAssistantMessage(sessionId, state, event);
2410
2501
  }
@@ -2645,6 +2736,9 @@ var AutoContinueRunner = class {
2645
2736
  state.streamRepeatRun = 0;
2646
2737
  state.streamWindow = [];
2647
2738
  state.loopFired = false;
2739
+ state.turnStopMarker = this.sessionConfig(sessionId).loopStopMarker;
2740
+ state.turnLoopEpoch = state.loopEpoch;
2741
+ state.turnVisibleText = "";
2648
2742
  state.turnOutput = "empty";
2649
2743
  state.outputTurn = event.data.turn;
2650
2744
  state.outputStartSeq = event.seq;
@@ -2658,6 +2752,11 @@ var AutoContinueRunner = class {
2658
2752
  state.running = false;
2659
2753
  const loopCancelPending = state.loopFired;
2660
2754
  state.loopFired = false;
2755
+ const turnVisibleText = state.turnVisibleText;
2756
+ state.turnVisibleText = "";
2757
+ const turnStopMarker = state.turnStopMarker;
2758
+ state.turnStopMarker = "";
2759
+ const markerStillApplies = state.turnLoopEpoch === state.loopEpoch;
2661
2760
  this.cancelPending(sessionId, "收到新的 turn/end");
2662
2761
  const turnOutput = state.outputTurn === event.data.turn ? state.turnOutput : "unknown";
2663
2762
  state.turnOutput = "unknown";
@@ -2680,6 +2779,7 @@ var AutoContinueRunner = class {
2680
2779
  state.lastFailureAt = Date.now();
2681
2780
  this.noteRecovery(sessionId, "error");
2682
2781
  if (this.sessionConfig(sessionId).resumeCompletedTurns) {
2782
+ if (state.loopStopped) break;
2683
2783
  this.schedule(sessionId, LOOP_SILENT_REASON);
2684
2784
  } else if (this.sessionConfig(sessionId).resumeSilentTurns) {
2685
2785
  this.schedule(sessionId, `turn/end:${reasonKind}:silent`);
@@ -2694,6 +2794,16 @@ var AutoContinueRunner = class {
2694
2794
  state.lastFailure = void 0;
2695
2795
  this.noteRecovery(sessionId, "completed");
2696
2796
  }
2797
+ if (!state.loopStopped && turnStopMarker !== "" && markerStillApplies && stopMarkerReported(turnVisibleText, turnStopMarker)) {
2798
+ state.loopStopped = true;
2799
+ this.log(`自主循环: 回合文本命中完成标记, 停止继续 ${sessionId}`);
2800
+ const config = this.sessionConfig(sessionId);
2801
+ if (config.notify) {
2802
+ const copy = NOTICE_COPY[config.locale];
2803
+ this.notify(sessionId, copy.loopDoneTitle, copy.loopDoneBody(sessionId), this.notifyOptions(sessionId, config.locale));
2804
+ }
2805
+ }
2806
+ if (state.loopStopped) break;
2697
2807
  this.schedule(sessionId, LOOP_COMPLETED_REASON, true);
2698
2808
  } else if (turnOutput === "visible") {
2699
2809
  state.consecutive = 0;
@@ -3304,6 +3414,8 @@ var AutoContinueRunner = class {
3304
3414
  resetLoopIterations(state) {
3305
3415
  state.loopIterations = 0;
3306
3416
  state.loopCapNotified = false;
3417
+ state.loopStopped = false;
3418
+ state.loopEpoch += 1;
3307
3419
  }
3308
3420
  /** 自主循环轮数上限: 触顶后静默停下, 每次触顶只提示一次。 */
3309
3421
  loopCapReached(sessionId, state, config) {
@@ -3957,8 +4069,7 @@ var AutoContinueRunner = class {
3957
4069
  const cause = CHILD_CAUSE_COPY[config.locale][child.cause];
3958
4070
  return `- ${child.id} ${label}${preset} — ${cause}`;
3959
4071
  });
3960
- const header = config.locale === "zh" ? "重启时你开的以下子代理 / 团队成员会话被打断, 没有跑完。请逐个检查, 按需要继续或收尾:" : "These child sessions you started (subagent / team member) were interrupted by a restart and did not finish. Check each one and either continue it or wrap it up:";
3961
- const tail = config.locale === "zh" ? "要继续的用 send_message / subagent 重新拉起对应会话(重启后它们并未加载); 已完成或不再需要的, 说明结论即可。" : "Use send_message (or subagent) to bring back the ones that should continue — they are not loaded after the restart; for finished or abandoned ones, just state the conclusion.";
4072
+ const { header, tail } = CHILD_RESUME_COPY[config.locale];
3962
4073
  return [header, ...lines, tail].join("\n");
3963
4074
  }
3964
4075
  /**
@@ -3981,6 +4092,10 @@ var AutoContinueRunner = class {
3981
4092
  }
3982
4093
  const ref = view.ref ?? { id: view.id, revision };
3983
4094
  if (view.phase === "active" && view.activation === "disarmed") {
4095
+ if (goalStoppedByUser(snapshotSessionEvents(agent.session))) {
4096
+ this.log(`会话 ${sessionId}: goal 是用户停下的, 不重新武装(等用户自己恢复)`);
4097
+ return;
4098
+ }
3984
4099
  goals.resume(agent, ref);
3985
4100
  this.log(`会话 ${sessionId}: goal 被重启失活, 已重新武装`);
3986
4101
  return;
@@ -10568,7 +10683,9 @@ var settingsFields = {
10568
10683
  /** How often (ms) a held recovery re-checks connectivity. */
10569
10684
  offlineCheckMs: z2.natural().min(1e3).default(15e3),
10570
10685
  /** Autonomous-loop round cap per session; 0 means unlimited. */
10571
- loopMaxIterations: z2.natural().default(0)
10686
+ loopMaxIterations: z2.natural().default(0),
10687
+ /** Stop the autonomous loop when a completed turn's visible text contains this marker (empty = never). */
10688
+ loopStopMarker: z2.string().default("")
10572
10689
  };
10573
10690
  var AutoContinueSchema = z2.object(settingsFields);
10574
10691
  var entrySchema = z2.object({
@@ -66,6 +66,8 @@ export declare const zh: {
66
66
  'field.offlineCheckMsHint': string;
67
67
  'field.loopMaxIterations': string;
68
68
  'field.loopMaxIterationsHint': string;
69
+ 'field.loopStopMarker': string;
70
+ 'field.loopStopMarkerHint': string;
69
71
  'field.continueTextLoop': string;
70
72
  'field.continueTextLoopHint': string;
71
73
  'default.continueTextLoop': "继续";
@@ -175,3 +177,5 @@ export type SettingsCardKey = keyof typeof zh;
175
177
  export declare const en: Record<SettingsCardKey, string>;
176
178
  /** Russian dictionary, checked complete against the zh key set. */
177
179
  export declare const ru: Record<SettingsCardKey, string>;
180
+ /** Japanese dictionary, checked complete against the zh key set. */
181
+ export declare const ja: Record<SettingsCardKey, string>;
@@ -24,6 +24,7 @@ export interface AutoContinueSettingsCardState extends CardShell {
24
24
  pauseWhenOffline: CardFieldState;
25
25
  offlineCheckMs: CardFieldState;
26
26
  loopMaxIterations: CardFieldState;
27
+ loopStopMarker: CardFieldState;
27
28
  continueTextLoop: CardFieldState;
28
29
  continueTextSilent: CardFieldState;
29
30
  continueTextInterrupted: CardFieldState;
@@ -16,6 +16,13 @@ import type { Context } from '@deepseek-ai/cordis';
16
16
  import type { SessionId } from '@deepseek-ai/dsh-session/types';
17
17
  import { type AutoContinueConfig, type DayStats, type RecoveryAttempt, type SessionMode, type NotifyAction } from '../shared/core.ts';
18
18
  import { type ConnectivityProbe } from './connectivity.ts';
19
+ /**
20
+ * The completion marker counts only when the model writes it as a line of its
21
+ * own, outside a fenced code block. Content the agent reads could otherwise be
22
+ * echoed back verbatim — a quoted marker in prose or in a fenced snippet must
23
+ * not be able to end the loop before the work is done.
24
+ */
25
+ export declare function stopMarkerReported(text: string, marker: string): boolean;
19
26
  /** 通知桥事件: host 引擎产生, browser 侧订阅展示(Notification / 动作按钮)。 */
20
27
  export interface HostNotice {
21
28
  /** 稳定标识(供 browser 去重)。 */
@@ -101,6 +101,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
101
101
  offlineCheckMs: z<number, number>;
102
102
  /** Autonomous-loop round cap per session; 0 means unlimited. */
103
103
  loopMaxIterations: z<number, number>;
104
+ /** Stop the autonomous loop when a completed turn's visible text contains this marker (empty = never). */
105
+ loopStopMarker: z<string, string>;
104
106
  }>, Schemastery.ObjectT<{
105
107
  /** Active browser/UI locale mirrored by the client. */
106
108
  locale: z<string, string>;
@@ -186,6 +188,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
186
188
  offlineCheckMs: z<number, number>;
187
189
  /** Autonomous-loop round cap per session; 0 means unlimited. */
188
190
  loopMaxIterations: z<number, number>;
191
+ /** Stop the autonomous loop when a completed turn's visible text contains this marker (empty = never). */
192
+ loopStopMarker: z<string, string>;
189
193
  }>>;
190
194
  /** Loader config is a live reference on DSH 0.1.7, and a plain object on older hosts. */
191
195
  export type AutoContinueEntryConfig = EntrySettings | LiveEntrySettings;
@@ -274,6 +278,8 @@ export declare const Config: z<Schemastery.ObjectS<{
274
278
  offlineCheckMs: z<number, number>;
275
279
  /** Autonomous-loop round cap per session; 0 means unlimited. */
276
280
  loopMaxIterations: z<number, number>;
281
+ /** Stop the autonomous loop when a completed turn's visible text contains this marker (empty = never). */
282
+ loopStopMarker: z<string, string>;
277
283
  }>, Schemastery.ObjectT<{
278
284
  /** Active browser/UI locale mirrored by the client. */
279
285
  locale: z<string, string>;
@@ -359,6 +365,8 @@ export declare const Config: z<Schemastery.ObjectS<{
359
365
  offlineCheckMs: z<number, number>;
360
366
  /** Autonomous-loop round cap per session; 0 means unlimited. */
361
367
  loopMaxIterations: z<number, number>;
368
+ /** Stop the autonomous loop when a completed turn's visible text contains this marker (empty = never). */
369
+ loopStopMarker: z<string, string>;
362
370
  }>> | z<AutoContinueSettings, AutoContinueEntryConfig>;
363
371
  /**
364
372
  * Plugin body: start the single-instance engine and serve the status bridge.
@@ -14,7 +14,7 @@ declare module '@deepseek-ai/dsh-llm' {
14
14
  }
15
15
  }
16
16
  /** Supported UI/config locales; missing and unsupported values use English. */
17
- export type AutoContinueLocale = 'en' | 'zh' | 'ru';
17
+ export type AutoContinueLocale = 'en' | 'zh' | 'ru' | 'ja';
18
18
  export declare function resolveLocale(locale: unknown): AutoContinueLocale;
19
19
  export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
20
20
  export interface SessionPolicy {
@@ -62,6 +62,17 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
62
62
  readonly guardDoneText: "(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)";
63
63
  readonly loopText: "(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)";
64
64
  };
65
+ readonly ja: {
66
+ readonly continueText: "続けて";
67
+ readonly continueTextMaxTokens: "続けて";
68
+ readonly continueTextSilent: "続けて。前のターンは内部の推論だけで終わり、返信もツール呼び出しもなかったため、ユーザーには何も表示されていません。ターンは必ずツール呼び出しか目に見える返信で終えてください。";
69
+ readonly continueTextLoop: "続けて";
70
+ readonly continueTextInterrupted: "続けて。前のターンの実行中にホストが再起動しました。再起動時に未完了だったツール呼び出しは「結果不明」として記録されています。中断したところから再開し、副作用のある操作をやり直す前に外部の状態を確認してください。";
71
+ readonly continueTextQuestion: "これはホストの再起動後にプラグインが自動で送ったメッセージで、ユーザーの返答ではありません。あなたがユーザーにした質問は再起動で中断され、まだ答えがありません。同じ質問をもう一度して、答えを待ってください。ユーザーの代わりに決めないでください。";
72
+ readonly guardPendingText: "(前のツール「{tool}」は完了していない可能性があります。続ける前に状態を確認し、再実行しないでください)";
73
+ readonly guardDoneText: "(前のツール「{tool}」は正常に完了しました。結果: {result}。再実行せず、そこから続けてください)";
74
+ readonly loopText: "(ループに陥っている可能性があります。直前の動作を繰り返すのをやめ、別の方法で続けてください)";
75
+ };
65
76
  };
66
77
  /** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
67
78
  export interface AutoContinueSettings {
@@ -149,6 +160,8 @@ export interface AutoContinueSettings {
149
160
  offlineCheckMs?: number;
150
161
  /** Autonomous-loop round cap per session; 0 means unlimited. Resets when the user sends a message or turns the loop back on. */
151
162
  loopMaxIterations?: number;
163
+ /** Autonomous-loop stop marker: a completed turn whose visible text contains this literal stops the loop instead of continuing. Empty disables the check. */
164
+ loopStopMarker?: string;
152
165
  }
153
166
  /** Fully resolved configuration (built-in defaults + user overrides). */
154
167
  export type AutoContinueConfig = Required<AutoContinueSettings>;
@@ -419,6 +432,22 @@ export interface SessionState {
419
432
  loopCapNotified: boolean;
420
433
  /** 上次观察到的循环开关; 由关到开时清零轮数。 */
421
434
  loopEnabled: boolean | undefined;
435
+ /**
436
+ * 本回合可见的模型文本, 用于自主循环的完成标记检测。只有本回合开始时尚有
437
+ * 标记可匹配时才累积; 回合结束检查后立刻清空, 空闲会话不会囤积文本。
438
+ */
439
+ turnVisibleText: string;
440
+ /** 本回合开始时生效的完成标记(空串 = 未配置, 不累积文本)。 */
441
+ turnStopMarker: string;
442
+ /** 本会话的自主循环已被完成标记停下(用户发消息或重新开启循环后解除)。 */
443
+ loopStopped: boolean;
444
+ /**
445
+ * 用户介入的代数。用户在回合进行中排队新消息会加一, 使该回合结束时的完成
446
+ * 标记失效——否则排队回合跑完后循环会莫名其妙地停下。
447
+ */
448
+ loopEpoch: number;
449
+ /** 本回合开始时的 loopEpoch, 用来判定标记是否仍属于当前上下文。 */
450
+ turnLoopEpoch: number;
422
451
  }
423
452
  export declare const freshState: () => SessionState;
424
453
  export declare const RECOVERY_WINDOW_MS: number;
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "自動続行",
4
+ "description": "中断された会話を、あなたのペースで自動的に再開します。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-client-auto-continue",
3
3
  "description": "Automatically resume interrupted DSH conversations, with an optional autonomous loop.",
4
- "version": "0.21.0",
4
+ "version": "0.22.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "README.md",
30
30
  "README.zh.md",
31
31
  "README.ru.md",
32
+ "README.ja.md",
32
33
  "CHANGELOG.md",
33
34
  "LICENSE"
34
35
  ],
@@ -52,7 +53,7 @@
52
53
  "typecheck": "tsc --noEmit",
53
54
  "docs:assets": "node scripts/build-docs-assets.mjs",
54
55
  "test:runtime": "node tests/settings-host-live.mjs 0.1.7 && node tests/settings-host-live.mjs 0.2.0 && node tests/settings-host-live.mjs 0.2.1 && node tests/profile-compatibility.mjs 0.2.0 && node tests/profile-compatibility.mjs 0.2.1 && node tests/client-settings-services.mjs 0.2.0 && node tests/client-settings-services.mjs 0.2.1 && node tests/boot-scan-host-live.mjs 0.2.0-rc.2 && node tests/boot-scan-host-live.mjs 0.2.1 && node tests/settings-host-live.mjs 0.2.1-rc.2 && node tests/profile-compatibility.mjs 0.2.1-rc.2 && node tests/boot-scan-restart-live.mjs 0.2.1-rc.2 && node tests/boot-scan-restart-live.mjs 0.2.2-rc.1 && node tests/boot-scan-restart-live.mjs 0.2.2-rc.1 dispose && node tests/settings-host-live.mjs 0.2.1-rc.2 mixed && node tests/settings-migration.mjs",
55
- "test": "node tests/echo-matching.mjs && node tests/boot-scan-stored-sweep.mjs && node tests/restart-resume-guards.mjs && node tests/child-resume-scan.mjs && node tests/offline-and-loop-cap.mjs && node tests/loop-guard-progress.mjs && node tests/scan-on-boot.mjs && node tests/boot-scan-isolation.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/session-modes.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/failure-classification.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/settings-card-native.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs && node tests/maintenance-turns.mjs && node tests/publish-prerelease.mjs",
56
+ "test": "node tests/echo-matching.mjs && node tests/boot-scan-stored-sweep.mjs && node tests/restart-resume-guards.mjs && node tests/child-resume-scan.mjs && node tests/offline-and-loop-cap.mjs && node tests/loop-guard-progress.mjs && node tests/scan-on-boot.mjs && node tests/boot-scan-isolation.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/loop-stop-marker.mjs && node tests/session-modes.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/failure-classification.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/settings-card-native.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs && node tests/maintenance-turns.mjs && node tests/publish-prerelease.mjs",
56
57
  "prepack": "npm run build"
57
58
  },
58
59
  "keywords": [
@@ -45,6 +45,11 @@ const BANNER_COPY = {
45
45
  tagline: 'Возвращает прерванные сессии к работе.',
46
46
  compact: 'Прервалось? Продолжаем.',
47
47
  },
48
+ ja: {
49
+ desc: 'HsiangNianian による DeepSeek Harness プラグイン。中断されたセッションを、あなたのペースで再開します。',
50
+ tagline: '中断されたセッションを、あなたのペースで再開。',
51
+ compact: '中断しても、そのまま続けよう。',
52
+ },
48
53
  };
49
54
 
50
55
  function banner(lang, themeName) {
@@ -88,7 +93,7 @@ function banner(lang, themeName) {
88
93
  </svg>`;
89
94
  }
90
95
 
91
- for (const lang of ['en', 'zh', 'ru']) {
96
+ for (const lang of ['en', 'zh', 'ru', 'ja']) {
92
97
  const suffix = lang === 'en' ? '' : `-${lang}`;
93
98
  write(`banner${suffix}.svg`, banner(lang, 'light'));
94
99
  write(`banner${suffix}-dark.svg`, banner(lang, 'dark'));
@@ -20,7 +20,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
20
20
  // Type-only: pulls the `settings.plugin.item` SlotMap merge.
21
21
  import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client';
22
22
  import { resolveLocale, type AutoContinueSettings } from '../shared/core.ts';
23
- import { en, ru, zh, type SettingsCardKey } from './locales.ts';
23
+ import { en, ja, ru, zh, type SettingsCardKey } from './locales.ts';
24
24
  import {
25
25
  AutoContinueSettingsCard,
26
26
  AutoContinueSettingsCardController,
@@ -81,10 +81,11 @@ export {
81
81
  */
82
82
  export function apply(ctx: ClientContext): void {
83
83
  // The base package types `register()` dictionaries as the built-in `zh`/`en`
84
- // pair only; further languages (here `ru`, added by a locale plugin at
84
+ // pair only; further languages (here `ru` and `ja`, added by a locale plugin at
85
85
  // runtime) register one locale at a time, exactly as `addLanguage` allows.
86
86
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'auto-continue: dictionaries');
87
87
  ctx.effect(() => ctx.locale.register(NS, 'ru', ru), 'auto-continue: russian dictionary');
88
+ ctx.effect(() => ctx.locale.register(NS, 'ja', ja), 'auto-continue: japanese dictionary');
88
89
  ctx.effect(() => startBridge(), 'auto-continue: host bridge');
89
90
 
90
91
  // Cordis waits for ALL top-level dependencies. Requiring settingsScope here