dsh-client-auto-continue 0.17.4 → 0.19.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +230 -281
  3. package/README.ru.md +382 -0
  4. package/README.zh.md +229 -279
  5. package/docs/auto-continue-workflow.archify.json +3 -3
  6. package/docs/auto-continue-workflow.en.archify.json +3 -3
  7. package/docs/auto-continue-workflow.en.html +1 -1
  8. package/docs/auto-continue-workflow.html +1 -1
  9. package/docs/auto-continue-workflow.ru.svg +530 -0
  10. package/docs/banner-ru-dark.svg +38 -0
  11. package/docs/banner-ru.svg +38 -0
  12. package/docs/demo-ru-static.svg +115 -0
  13. package/docs/demo-ru.svg +147 -0
  14. package/docs/releases/v0.18.0.md +58 -0
  15. package/docs/releases/v0.19.0.md +62 -0
  16. package/docs/social-preview.png +0 -0
  17. package/docs/social-preview.svg +30 -1
  18. package/lib/client.js +347 -100
  19. package/lib/client.js.map +3 -3
  20. package/lib/index.js +790 -49
  21. package/lib/types/client/auto-continue-icon.d.ts +7 -0
  22. package/lib/types/client/bridge.d.ts +2 -0
  23. package/lib/types/client/composer-toggle.d.ts +2 -0
  24. package/lib/types/client/locales.d.ts +19 -0
  25. package/lib/types/client/settings-card.d.ts +8 -0
  26. package/lib/types/host/connectivity.d.ts +4 -0
  27. package/lib/types/host/engine.d.ts +97 -5
  28. package/lib/types/index.d.ts +64 -0
  29. package/lib/types/shared/core.d.ts +54 -1
  30. package/locale/ru.json +6 -0
  31. package/package.json +6 -4
  32. package/scripts/build-docs-assets.mjs +126 -0
  33. package/src/client/auto-continue-icon.tsx +6 -27
  34. package/src/client/bridge.ts +26 -6
  35. package/src/client/composer-toggle.tsx +22 -11
  36. package/src/client/index.ts +5 -1
  37. package/src/client/locales.ts +241 -38
  38. package/src/client/settings-card.tsx +31 -4
  39. package/src/client/settings-notifications.ts +3 -2
  40. package/src/client/styles.ts +17 -19
  41. package/src/host/connectivity.ts +54 -0
  42. package/src/host/engine.ts +852 -40
  43. package/src/host/settings-migration.ts +1 -1
  44. package/src/index.ts +26 -1
  45. package/src/shared/core.ts +94 -3
@@ -1 +1,8 @@
1
+ /**
2
+ * Auto-continue glyph: a single-stroke infinity loop.
3
+ *
4
+ * Deliberately not the host's refresh icon. Refresh reads as "start over",
5
+ * auto-continue means "keep going without stopping" (#86). Drawn on a 16px grid
6
+ * with a 2px margin so both loops stay distinct at 14px.
7
+ */
1
8
  export declare function AutoContinueIcon(): import("react").JSX.Element;
@@ -28,7 +28,9 @@ export declare function pausedSessions(): PausedSessionView[];
28
28
  /** 当前桥状态里的今日统计(卡片面板用)。 */
29
29
  export declare function readTodayStats(): DayStatsView;
30
30
  export declare function readRecoveryAttempts(): RecoveryAttempt[];
31
+ /** Last policy the host sent. It survives a bridge reconnect, so check {@link isBridgeConnected} before writing. */
31
32
  export declare function readSessionPolicy(): SessionPolicy | undefined;
33
+ export declare function isBridgeConnected(): boolean;
32
34
  export declare function setSessionMode(sessionId: string, mode: SessionMode): Promise<void>;
33
35
  /** 清零今日统计(经动作端点交给 host 引擎执行)。 */
34
36
  export declare function resetTodayStats(): void;
@@ -4,6 +4,8 @@ import { type SessionMode, type SessionPolicy } from '../shared/core.ts';
4
4
  export interface ComposerToggleState {
5
5
  visible: boolean;
6
6
  policy: SessionPolicy | undefined;
7
+ /** The bridge dropped; `policy` is the last known one and stays on screen, read-only. */
8
+ reconnecting: boolean;
7
9
  writable: boolean;
8
10
  saving: ReadonlySet<string>;
9
11
  failed: ReadonlySet<string>;
@@ -27,6 +27,8 @@ export declare const zh: {
27
27
  'field.paused': string;
28
28
  'field.showComposerToggle': string;
29
29
  'field.showComposerToggleHint': string;
30
+ 'field.usePluginSource': string;
31
+ 'field.usePluginSourceHint': string;
30
32
  'composer.label': string;
31
33
  'composer.mode': string;
32
34
  'composer.scope': string;
@@ -36,6 +38,7 @@ export declare const zh: {
36
38
  'composer.loop': string;
37
39
  'composer.paused': string;
38
40
  'composer.unavailable': string;
41
+ 'composer.reconnecting': string;
39
42
  'composer.saving': string;
40
43
  'composer.saveFailed': string;
41
44
  'field.pausedHint': string;
@@ -47,8 +50,22 @@ export declare const zh: {
47
50
  'default.continueTextMaxTokens': "继续";
48
51
  'field.resumeSilentTurns': string;
49
52
  'field.resumeSilentTurnsHint': string;
53
+ 'field.resumeSubagentSessions': string;
54
+ 'field.resumeSubagentSessionsHint': string;
50
55
  'field.resumeCompletedTurns': string;
51
56
  'field.resumeCompletedTurnsHint': string;
57
+ 'field.resumeInterruptedChildren': string;
58
+ 'field.resumeInterruptedChildrenHint': string;
59
+ 'field.resumeGoals': string;
60
+ 'field.resumeGoalsHint': string;
61
+ 'field.resumePausedGoals': string;
62
+ 'field.resumePausedGoalsHint': string;
63
+ 'field.pauseWhenOffline': string;
64
+ 'field.pauseWhenOfflineHint': string;
65
+ 'field.offlineCheckMs': string;
66
+ 'field.offlineCheckMsHint': string;
67
+ 'field.loopMaxIterations': string;
68
+ 'field.loopMaxIterationsHint': string;
52
69
  'field.continueTextLoop': string;
53
70
  'field.continueTextLoopHint': string;
54
71
  'default.continueTextLoop': "继续";
@@ -153,3 +170,5 @@ export declare const zh: {
153
170
  export type SettingsCardKey = keyof typeof zh;
154
171
  /** English dictionary, checked complete against the zh key set. */
155
172
  export declare const en: Record<SettingsCardKey, string>;
173
+ /** Russian dictionary, checked complete against the zh key set. */
174
+ export declare const ru: Record<SettingsCardKey, string>;
@@ -12,10 +12,18 @@ export interface AutoContinueSettingsCardState extends CardShell {
12
12
  notificationFeedback: SettingsCardKey | undefined;
13
13
  paused: CardFieldState;
14
14
  showComposerToggle: CardFieldState;
15
+ usePluginSource: CardFieldState;
15
16
  continueText: CardFieldState;
16
17
  continueTextMaxTokens: CardFieldState;
17
18
  resumeSilentTurns: CardFieldState;
19
+ resumeSubagentSessions: CardFieldState;
18
20
  resumeCompletedTurns: CardFieldState;
21
+ resumeInterruptedChildren: CardFieldState;
22
+ resumeGoals: CardFieldState;
23
+ resumePausedGoals: CardFieldState;
24
+ pauseWhenOffline: CardFieldState;
25
+ offlineCheckMs: CardFieldState;
26
+ loopMaxIterations: CardFieldState;
19
27
  continueTextLoop: CardFieldState;
20
28
  continueTextSilent: CardFieldState;
21
29
  continueTextInterrupted: CardFieldState;
@@ -0,0 +1,4 @@
1
+ /** Resolves `true` when the host looks online. Must never reject. */
2
+ export type ConnectivityProbe = () => Promise<boolean>;
3
+ /** Host-side connectivity check: a non-loopback interface plus one resolvable public name. */
4
+ export declare const probeConnectivity: ConnectivityProbe;
@@ -14,7 +14,8 @@
14
14
  */
15
15
  import type { Context } from '@deepseek-ai/cordis';
16
16
  import type { SessionId } from '@deepseek-ai/dsh-session/types';
17
- import { type AutoContinueConfig, type DayStats, type RecoveryAttempt, type NotifyAction } from '../shared/core.ts';
17
+ import { type AutoContinueConfig, type DayStats, type RecoveryAttempt, type SessionMode, type NotifyAction } from '../shared/core.ts';
18
+ import { type ConnectivityProbe } from './connectivity.ts';
18
19
  /** 通知桥事件: host 引擎产生, browser 侧订阅展示(Notification / 动作按钮)。 */
19
20
  export interface HostNotice {
20
21
  /** 稳定标识(供 browser 去重)。 */
@@ -27,11 +28,15 @@ export interface HostNotice {
27
28
  /** 产生时间。 */
28
29
  at: number;
29
30
  }
30
- /** 插件主体: 一条 mux 流 + 一条 host 流 + 启动/重连扫描。 */
31
31
  export declare class AutoContinueRunner {
32
32
  private readonly ctx;
33
33
  private readonly getConfig;
34
+ private readonly probe;
34
35
  private readonly states;
36
+ /** Cached subagent lineage: session id -> direct parent id (undefined when the header has none). */
37
+ private readonly parents;
38
+ /** Sessions already identified as subagents, including event views without header metadata. */
39
+ private readonly subagentSessions;
35
40
  private readonly pauseUntil;
36
41
  private dayStats;
37
42
  private readonly recoveryAttempts;
@@ -47,6 +52,16 @@ export declare class AutoContinueRunner {
47
52
  private readonly bootScanErrors;
48
53
  /** 存储扫描已裁决的会话 id, 避免每轮重复冷读大日志。 */
49
54
  private readonly storedSwept;
55
+ /** 子会话裁决独立记账: storedSwept 在 origin 判断之前就已标记, 不能复用。 */
56
+ private readonly childSwept;
57
+ /** 本轮已花掉的子会话观察配额(每轮重置, 子会话日志与主会话同等昂贵)。 */
58
+ private childScanned;
59
+ /** 本轮收集到的子会话中断, 按 root 主会话 id 归组。 */
60
+ private readonly childInterrupts;
61
+ /** 已唤醒过的 root 会话 → 上次唤醒覆盖的子会话签名, 防止每轮重复催同一批。 */
62
+ private readonly childWoken;
63
+ /** 已打印过「父链不可解析」的子会话, 避免 15 分钟扫描窗口内每轮重扫把日志刷爆。 */
64
+ private readonly childDirtyLogged;
50
65
  /** 存储会话的连续观察/物化失败次数, 触达 SWEEP_MAX_FAILURES 后不再重试。 */
51
66
  private readonly storedSweepFailures;
52
67
  private storedSweepAnnounced;
@@ -54,11 +69,13 @@ export declare class AutoContinueRunner {
54
69
  private wakeBootScan;
55
70
  private storedSweep;
56
71
  private readonly stopStoredSweep;
72
+ /** 并发的断网挂起共用同一次连通性检测。 */
73
+ private connectivityCheck;
57
74
  /**
58
75
  * @param ctx - host plugin context (agents registry, session events).
59
76
  * @param getConfig - read the current resolved configuration (entry config).
60
77
  */
61
- constructor(ctx: Context, getConfig: () => AutoContinueConfig);
78
+ constructor(ctx: Context, getConfig: () => AutoContinueConfig, probe?: ConnectivityProbe);
62
79
  private log;
63
80
  /** 对外(状态桥): 今日统计快照。 */
64
81
  todayStats(): DayStats;
@@ -74,6 +91,12 @@ export declare class AutoContinueRunner {
74
91
  subscribeState(listener: () => void): () => void;
75
92
  private emitState;
76
93
  private sessionConfig;
94
+ /**
95
+ * The session's own mode, ignoring subagent inheritance. The stored-session
96
+ * sweep and the restart hand-off (`resumeInterruptedChildren`) use this, so
97
+ * turning live subagent recovery off never silently disables them.
98
+ */
99
+ private ownSessionConfig;
77
100
  configurationChanged(): void;
78
101
  /** 对外(状态桥): 消费待展示的通知。 */
79
102
  drainNotices(): HostNotice[];
@@ -81,10 +104,44 @@ export declare class AutoContinueRunner {
81
104
  handleNoticeAction(sessionId: SessionId | undefined, action: string): void;
82
105
  dispose(): void;
83
106
  private state;
84
- /** Mark a child session and clear queued grace/cooldown sends. */
85
- private markSubagent;
107
+ /** Record a subagent session's lineage and its parent id when the header carries one. */
108
+ private noteSubagent;
86
109
  /** Read durable origin from the live agent for direct action paths as well. */
87
110
  private isSubagent;
111
+ /** Header origin, cached set or state flag; for paths that only have the session id. */
112
+ private isSubagentSession;
113
+ /**
114
+ * Direct subagent parent id. DSH stores fork lineage in the same
115
+ * `header.parentSession` field, so only a session whose header origin is
116
+ * `subagent` may be followed upward: an ordinary ancestor (the visible main
117
+ * conversation, even a forked one) is the top of the recovery lineage.
118
+ */
119
+ private parentOf;
120
+ /** Explicit session mode stored for this exact id, if the user gave one. */
121
+ private explicitMode;
122
+ /**
123
+ * A subagent's effective mode, or `undefined` when the lineage cannot be
124
+ * verified. An intermediate parent that is no longer live (and was never seen
125
+ * here) used to stop the walk early, fall back to the profile default and
126
+ * resume a child whose main conversation is Off; refusing the send is safe.
127
+ */
128
+ private resolveSubagentMode;
129
+ /** Whether the setting and the inherited main-chat mode allow live recovery for this child. */
130
+ private subagentRecoveryEnabled;
131
+ /** Modes children inherit from their main conversation, for the composer's display. */
132
+ inheritedSubagentModes(): Record<string, SessionMode>;
133
+ /**
134
+ * Keep the lineage caches bounded on long-lived hosts. Once the cache grows,
135
+ * entries for sessions that are no longer loaded are dropped; they are re-read
136
+ * from the live header if the session comes back.
137
+ */
138
+ private pruneLineage;
139
+ /** Mark a child session; drop only queued sends that its effective policy no longer allows. */
140
+ private markSubagent;
141
+ /** Pause deadline, including the parents' "pause this session 1h" for subagents. */
142
+ private effectivePauseUntil;
143
+ /** Whether this session sits below `ancestorId` in the subagent lineage (never fork lineage). */
144
+ private isDescendantOf;
88
145
  /**
89
146
  * 事件入口(host 单实例): 预处理工具调用/结果/模型消息(护栏与循环信号),
90
147
  * 然后交给回合状态机。
@@ -135,6 +192,16 @@ export declare class AutoContinueRunner {
135
192
  private templateFor;
136
193
  private cancelPending;
137
194
  private fire;
195
+ private resetLoopIterations;
196
+ /** 自主循环轮数上限: 触顶后静默停下, 每次触顶只提示一次。 */
197
+ private loopCapReached;
198
+ private checkConnectivity;
199
+ /**
200
+ * 网络类失败的续跑先过连通性检测: 断网时发出去必然再失败一次, 白白吃掉连续上限,
201
+ * 等网络恢复时预算已耗尽。挂起期间不计次数, 每 offlineCheckMs 复检一次, 恢复后
202
+ * 重新走 schedule(宽限、冷却照常)。手动续跑和非网络原因不受影响。
203
+ */
204
+ private fireWhenOnline;
138
205
  /**
139
206
  * 组装本次续跑消息: 模板填充 + 幂等护栏。
140
207
  * 护栏依据上一步工具调用的执行状态附加指引, 防止重跑副作用操作:
@@ -156,6 +223,31 @@ export declare class AutoContinueRunner {
156
223
  * 则启动扫描永远看不到它们; 谓词与上方扫描一致, 仅失败类原因。
157
224
  */
158
225
  private sweepStoredSessions;
226
+ /**
227
+ * 子会话裁决。子会话本身永不直接续跑(父代理权威, 见 README), 但启动扫描要
228
+ * 知道它是否在重启时被打断, 才能在自己的 root 会话上补一次带清单的唤醒。
229
+ * 独立 `childSwept` 记账与独立配额: 主扫描的 `storedSwept` 在 origin 判断
230
+ * 之前就已标记, 复用它会让子会话永远扫不到, 也会吃掉主扫描的观察预算。
231
+ */
232
+ private sweepChild;
233
+ /** 把本轮收集到的子会话中断转成 root 会话上的一次唤醒(同一批只催一次)。 */
234
+ private wakeInterruptedChildren;
235
+ /**
236
+ * 在 root 会话上唤醒一次。只有在 root 自己是"干净终态"时才动手: 它若被打断,
237
+ * 主扫描本来就会续跑它; 它若被用户手动停止, 唤醒就是幽灵回合。
238
+ */
239
+ private wakeRoot;
240
+ /** 父会话只在"干净结束"或"被宿主关闭"时接受唤醒; 用户手动停止的绝不复活。 */
241
+ private rootAcceptsWake;
242
+ /** 发送需要 live agent; 存储会话沿既有物化路径拉起, 复用 preset 与模型回装。 */
243
+ private ensureLiveAgent;
244
+ /** 唤醒文本必须带会话级证据: 否则父会话看不到任何状态, 只会白跑一轮再回一句"都结束了"。 */
245
+ private buildChildResumeText;
246
+ /**
247
+ * 重启会把 active goal 置为 disarmed(宿主卸载驱动的正常动作), 只有人类授权的
248
+ * resume 能重新 arm; paused 则是人类的显式决定。两者都默认关闭。
249
+ */
250
+ private rearmGoal;
159
251
  /**
160
252
  * 按会话记录的 preset 组合把存储会话恢复为 live agent(镜像会话控制
161
253
  * 器的 adopt 路径: preset 挂载 + 会话已记录的模型选择回装)。模型选择
@@ -19,12 +19,16 @@ export declare const AUTO_CONTINUE_NS = "auto-continue";
19
19
  export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
20
20
  /** Active browser/UI locale mirrored by the client. */
21
21
  locale: z<string, string>;
22
+ /** Send continue messages with the plugin source instead of the legacy user source. */
23
+ usePluginSource: z<boolean, boolean>;
22
24
  /** Text automatically sent after an interruption. */
23
25
  continueText: z<string, string>;
24
26
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
25
27
  continueTextMaxTokens: z<string, string>;
26
28
  /** Resume observed model activity that completes without visible output. */
27
29
  resumeSilentTurns: z<boolean, boolean>;
30
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
31
+ resumeSubagentSessions: z<boolean, boolean>;
28
32
  /** 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
33
  resumeCompletedTurns: z<boolean, boolean>;
30
34
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -83,15 +87,31 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
83
87
  loopToolRepeat: z<number, number>;
84
88
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
85
89
  loopText: z<string, string>;
90
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
91
+ resumeInterruptedChildren: z<boolean, boolean>;
92
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
93
+ resumeGoals: z<boolean, boolean>;
94
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
95
+ resumePausedGoals: z<boolean, boolean>;
96
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
97
+ pauseWhenOffline: z<boolean, boolean>;
98
+ /** How often (ms) a held recovery re-checks connectivity. */
99
+ offlineCheckMs: z<number, number>;
100
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
101
+ loopMaxIterations: z<number, number>;
86
102
  }>, Schemastery.ObjectT<{
87
103
  /** Active browser/UI locale mirrored by the client. */
88
104
  locale: z<string, string>;
105
+ /** Send continue messages with the plugin source instead of the legacy user source. */
106
+ usePluginSource: z<boolean, boolean>;
89
107
  /** Text automatically sent after an interruption. */
90
108
  continueText: z<string, string>;
91
109
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
92
110
  continueTextMaxTokens: z<string, string>;
93
111
  /** Resume observed model activity that completes without visible output. */
94
112
  resumeSilentTurns: z<boolean, boolean>;
113
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
114
+ resumeSubagentSessions: z<boolean, boolean>;
95
115
  /** 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. */
96
116
  resumeCompletedTurns: z<boolean, boolean>;
97
117
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -150,18 +170,34 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
150
170
  loopToolRepeat: z<number, number>;
151
171
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
152
172
  loopText: z<string, string>;
173
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
174
+ resumeInterruptedChildren: z<boolean, boolean>;
175
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
176
+ resumeGoals: z<boolean, boolean>;
177
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
178
+ resumePausedGoals: z<boolean, boolean>;
179
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
180
+ pauseWhenOffline: z<boolean, boolean>;
181
+ /** How often (ms) a held recovery re-checks connectivity. */
182
+ offlineCheckMs: z<number, number>;
183
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
184
+ loopMaxIterations: z<number, number>;
153
185
  }>>;
154
186
  /** Loader config is a live reference on DSH 0.1.7, and a plain object on older hosts. */
155
187
  export type AutoContinueEntryConfig = EntrySettings | LiveEntrySettings;
156
188
  export declare const Config: z<Schemastery.ObjectS<{
157
189
  /** Active browser/UI locale mirrored by the client. */
158
190
  locale: z<string, string>;
191
+ /** Send continue messages with the plugin source instead of the legacy user source. */
192
+ usePluginSource: z<boolean, boolean>;
159
193
  /** Text automatically sent after an interruption. */
160
194
  continueText: z<string, string>;
161
195
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
162
196
  continueTextMaxTokens: z<string, string>;
163
197
  /** Resume observed model activity that completes without visible output. */
164
198
  resumeSilentTurns: z<boolean, boolean>;
199
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
200
+ resumeSubagentSessions: z<boolean, boolean>;
165
201
  /** 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. */
166
202
  resumeCompletedTurns: z<boolean, boolean>;
167
203
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -220,15 +256,31 @@ export declare const Config: z<Schemastery.ObjectS<{
220
256
  loopToolRepeat: z<number, number>;
221
257
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
222
258
  loopText: z<string, string>;
259
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
260
+ resumeInterruptedChildren: z<boolean, boolean>;
261
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
262
+ resumeGoals: z<boolean, boolean>;
263
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
264
+ resumePausedGoals: z<boolean, boolean>;
265
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
266
+ pauseWhenOffline: z<boolean, boolean>;
267
+ /** How often (ms) a held recovery re-checks connectivity. */
268
+ offlineCheckMs: z<number, number>;
269
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
270
+ loopMaxIterations: z<number, number>;
223
271
  }>, Schemastery.ObjectT<{
224
272
  /** Active browser/UI locale mirrored by the client. */
225
273
  locale: z<string, string>;
274
+ /** Send continue messages with the plugin source instead of the legacy user source. */
275
+ usePluginSource: z<boolean, boolean>;
226
276
  /** Text automatically sent after an interruption. */
227
277
  continueText: z<string, string>;
228
278
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
229
279
  continueTextMaxTokens: z<string, string>;
230
280
  /** Resume observed model activity that completes without visible output. */
231
281
  resumeSilentTurns: z<boolean, boolean>;
282
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
283
+ resumeSubagentSessions: z<boolean, boolean>;
232
284
  /** 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. */
233
285
  resumeCompletedTurns: z<boolean, boolean>;
234
286
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -287,6 +339,18 @@ export declare const Config: z<Schemastery.ObjectS<{
287
339
  loopToolRepeat: z<number, number>;
288
340
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
289
341
  loopText: z<string, string>;
342
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
343
+ resumeInterruptedChildren: z<boolean, boolean>;
344
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
345
+ resumeGoals: z<boolean, boolean>;
346
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
347
+ resumePausedGoals: z<boolean, boolean>;
348
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
349
+ pauseWhenOffline: z<boolean, boolean>;
350
+ /** How often (ms) a held recovery re-checks connectivity. */
351
+ offlineCheckMs: z<number, number>;
352
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
353
+ loopMaxIterations: z<number, number>;
290
354
  }>> | z<AutoContinueSettings, AutoContinueEntryConfig>;
291
355
  /**
292
356
  * Plugin body: start the single-instance engine and serve the status bridge.
@@ -5,12 +5,22 @@
5
5
  * 以及回显识别。引擎迁入 host 后(0.8.0), 浏览器半侧只 re-export 本模块。
6
6
  */
7
7
  import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
8
+ export declare const AUTO_CONTINUE_SOURCE_KIND = "plugin:dsh-client-auto-continue";
9
+ declare module '@deepseek-ai/dsh-llm' {
10
+ interface MessageSourceMap {
11
+ 'plugin:dsh-client-auto-continue': {
12
+ kind: typeof AUTO_CONTINUE_SOURCE_KIND;
13
+ };
14
+ }
15
+ }
8
16
  /** Supported UI/config locales; missing and unsupported values use English. */
9
- export type AutoContinueLocale = 'en' | 'zh';
17
+ export type AutoContinueLocale = 'en' | 'zh' | 'ru';
10
18
  export declare function resolveLocale(locale: unknown): AutoContinueLocale;
11
19
  export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
12
20
  export interface SessionPolicy {
13
21
  modes: Record<string, SessionMode>;
22
+ /** Modes a child inherits from its main conversation, keyed by child id. */
23
+ inheritedModes?: Record<string, SessionMode>;
14
24
  defaultMode: 'recover' | 'loop';
15
25
  paused: boolean;
16
26
  writable: boolean;
@@ -39,17 +49,31 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
39
49
  readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
40
50
  readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
41
51
  };
52
+ readonly ru: {
53
+ readonly continueText: "Продолжай";
54
+ readonly continueTextMaxTokens: "Продолжай";
55
+ readonly continueTextSilent: "Продолжай. Предыдущий ход закончился только внутренним рассуждением: ни ответа, ни вызова инструмента, поэтому пользователь ничего не увидел. Каждый ход должен заканчиваться вызовом инструмента или видимым ответом.";
56
+ readonly continueTextLoop: "Продолжай";
57
+ readonly continueTextInterrupted: "Продолжай. Хост перезапустился, пока предыдущий ход ещё выполнялся; вызовы инструментов, незавершённые на момент перезапуска, записаны с неизвестным результатом. Продолжай с места остановки, проверяя внешнее состояние перед повтором действий с возможными побочными эффектами.";
58
+ readonly guardPendingText: "(Предыдущий инструмент «{tool}», возможно, не завершился. Проверь его состояние перед продолжением и не запускай его повторно.)";
59
+ readonly guardDoneText: "(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)";
60
+ readonly loopText: "(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)";
61
+ };
42
62
  };
43
63
  /** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
44
64
  export interface AutoContinueSettings {
45
65
  /** Active browser/UI locale mirrored by the client. */
46
66
  locale?: AutoContinueLocale;
67
+ /** Send continue messages with the plugin source instead of the legacy user source. */
68
+ usePluginSource?: boolean;
47
69
  /** Text automatically sent after an interruption. */
48
70
  continueText?: string;
49
71
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
50
72
  continueTextMaxTokens?: string;
51
73
  /** Resume observed model activity that completes without visible output. */
52
74
  resumeSilentTurns?: boolean;
75
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
76
+ resumeSubagentSessions?: boolean;
53
77
  /** 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. */
54
78
  resumeCompletedTurns?: boolean;
55
79
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -108,6 +132,18 @@ export interface AutoContinueSettings {
108
132
  loopRepeatText?: number;
109
133
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
110
134
  loopText?: string;
135
+ /** Recover child (subagent / Agent Teams) sessions that a restart interrupted by waking their root session once. */
136
+ resumeInterruptedChildren?: boolean;
137
+ /** Re-arm a goal that a restart left `active` but `disarmed`, when its own session is resumed. */
138
+ resumeGoals?: boolean;
139
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
140
+ resumePausedGoals?: boolean;
141
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
142
+ pauseWhenOffline?: boolean;
143
+ /** How often (ms) a held recovery re-checks connectivity. */
144
+ offlineCheckMs?: number;
145
+ /** Autonomous-loop round cap per session; 0 means unlimited. Resets when the user sends a message or turns the loop back on. */
146
+ loopMaxIterations?: number;
111
147
  }
112
148
  /** Fully resolved configuration (built-in defaults + user overrides). */
113
149
  export type AutoContinueConfig = Required<AutoContinueSettings>;
@@ -145,6 +181,11 @@ export declare function isTransientFailure(failure: FailureFacts, retryableError
145
181
  * 序列化失败(如 Windows 下 abort 的 DOMException reason)绝不能自动续跑。
146
182
  */
147
183
  export declare function isTransientAgentError(message: string): boolean;
184
+ /**
185
+ * 失败是否属于连接层(断网/DNS/连接被拒/传输超时)。只有这类失败值得先做连通性
186
+ * 检测: 断网时续跑必然再失败一次, 白白消耗连续上限。5xx/429 等服务端错误不在此列。
187
+ */
188
+ export declare function isNetworkFailure(failure: FailureFacts): boolean;
148
189
  /** 通知上的一个操作按钮(action 标识 + 显示文案)。 */
149
190
  export interface NotifyAction {
150
191
  /** 稳定动作标识, 点击时经 onAction 回调传出。 */
@@ -353,6 +394,18 @@ export interface SessionState {
353
394
  loopRetryTimer: ReturnType<typeof setTimeout> | undefined;
354
395
  /** 冷却期恢复的延迟定时器(等到冷却结束再 schedule, 而不是丢弃这次恢复)。 */
355
396
  cooldownRetryTimer: ReturnType<typeof setTimeout> | undefined;
397
+ /** 断网挂起: 进行中的连通性检测令牌(取消时置空, 迟到的检测结果据此作废)。 */
398
+ offlineWait: object | undefined;
399
+ /** 断网挂起: 下一次连通性复检的定时器。 */
400
+ offlineTimer: ReturnType<typeof setTimeout> | undefined;
401
+ /** 本次断网挂起开始的时间; 0 = 未挂起(只在挂起开始/结束时各记一次日志)。 */
402
+ offlineSince: number;
403
+ /** 自主循环已续跑的轮数(用户发消息或重新开启循环时清零)。 */
404
+ loopIterations: number;
405
+ /** 本轮循环上限提示已发出(每次触顶只提示一次)。 */
406
+ loopCapNotified: boolean;
407
+ /** 上次观察到的循环开关; 由关到开时清零轮数。 */
408
+ loopEnabled: boolean | undefined;
356
409
  }
357
410
  export declare const freshState: () => SessionState;
358
411
  export declare const RECOVERY_WINDOW_MS: number;
package/locale/ru.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
- "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.17.4",
3
+ "description": "Automatically resume interrupted DSH conversations, with an optional autonomous loop.",
4
+ "version": "0.19.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  "tsconfig.build.json",
29
29
  "README.md",
30
30
  "README.zh.md",
31
+ "README.ru.md",
31
32
  "CHANGELOG.md",
32
33
  "LICENSE"
33
34
  ],
@@ -49,8 +50,9 @@
49
50
  "build": "node build.mjs && tsc -p tsconfig.build.json",
50
51
  "watch": "node build.mjs --watch",
51
52
  "typecheck": "tsc --noEmit",
52
- "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 && node tests/settings-host-live.mjs 0.2.1-rc.2 mixed && node tests/settings-migration.mjs",
53
- "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/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",
53
+ "docs:assets": "node scripts/build-docs-assets.mjs",
54
+ "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/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",
54
56
  "prepack": "npm run build"
55
57
  },
56
58
  "keywords": [