dsh-client-auto-continue 0.17.3 → 0.18.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.
@@ -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;
@@ -49,6 +51,18 @@ export declare const zh: {
49
51
  'field.resumeSilentTurnsHint': string;
50
52
  'field.resumeCompletedTurns': string;
51
53
  'field.resumeCompletedTurnsHint': string;
54
+ 'field.resumeInterruptedChildren': string;
55
+ 'field.resumeInterruptedChildrenHint': string;
56
+ 'field.resumeGoals': string;
57
+ 'field.resumeGoalsHint': string;
58
+ 'field.resumePausedGoals': string;
59
+ 'field.resumePausedGoalsHint': string;
60
+ 'field.pauseWhenOffline': string;
61
+ 'field.pauseWhenOfflineHint': string;
62
+ 'field.offlineCheckMs': string;
63
+ 'field.offlineCheckMsHint': string;
64
+ 'field.loopMaxIterations': string;
65
+ 'field.loopMaxIterationsHint': string;
52
66
  'field.continueTextLoop': string;
53
67
  'field.continueTextLoopHint': string;
54
68
  'default.continueTextLoop': "继续";
@@ -12,10 +12,17 @@ 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;
18
19
  resumeCompletedTurns: CardFieldState;
20
+ resumeInterruptedChildren: CardFieldState;
21
+ resumeGoals: CardFieldState;
22
+ resumePausedGoals: CardFieldState;
23
+ pauseWhenOffline: CardFieldState;
24
+ offlineCheckMs: CardFieldState;
25
+ loopMaxIterations: CardFieldState;
19
26
  continueTextLoop: CardFieldState;
20
27
  continueTextSilent: CardFieldState;
21
28
  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;
@@ -15,6 +15,7 @@
15
15
  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 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 去重)。 */
@@ -31,6 +32,7 @@ export interface HostNotice {
31
32
  export declare class AutoContinueRunner {
32
33
  private readonly ctx;
33
34
  private readonly getConfig;
35
+ private readonly probe;
34
36
  private readonly states;
35
37
  private readonly pauseUntil;
36
38
  private dayStats;
@@ -47,6 +49,16 @@ export declare class AutoContinueRunner {
47
49
  private readonly bootScanErrors;
48
50
  /** 存储扫描已裁决的会话 id, 避免每轮重复冷读大日志。 */
49
51
  private readonly storedSwept;
52
+ /** 子会话裁决独立记账: storedSwept 在 origin 判断之前就已标记, 不能复用。 */
53
+ private readonly childSwept;
54
+ /** 本轮已花掉的子会话观察配额(每轮重置, 子会话日志与主会话同等昂贵)。 */
55
+ private childScanned;
56
+ /** 本轮收集到的子会话中断, 按 root 主会话 id 归组。 */
57
+ private readonly childInterrupts;
58
+ /** 已唤醒过的 root 会话 → 上次唤醒覆盖的子会话签名, 防止每轮重复催同一批。 */
59
+ private readonly childWoken;
60
+ /** 已打印过「父链不可解析」的子会话, 避免 15 分钟扫描窗口内每轮重扫把日志刷爆。 */
61
+ private readonly childDirtyLogged;
50
62
  /** 存储会话的连续观察/物化失败次数, 触达 SWEEP_MAX_FAILURES 后不再重试。 */
51
63
  private readonly storedSweepFailures;
52
64
  private storedSweepAnnounced;
@@ -54,11 +66,13 @@ export declare class AutoContinueRunner {
54
66
  private wakeBootScan;
55
67
  private storedSweep;
56
68
  private readonly stopStoredSweep;
69
+ /** 并发的断网挂起共用同一次连通性检测。 */
70
+ private connectivityCheck;
57
71
  /**
58
72
  * @param ctx - host plugin context (agents registry, session events).
59
73
  * @param getConfig - read the current resolved configuration (entry config).
60
74
  */
61
- constructor(ctx: Context, getConfig: () => AutoContinueConfig);
75
+ constructor(ctx: Context, getConfig: () => AutoContinueConfig, probe?: ConnectivityProbe);
62
76
  private log;
63
77
  /** 对外(状态桥): 今日统计快照。 */
64
78
  todayStats(): DayStats;
@@ -135,6 +149,16 @@ export declare class AutoContinueRunner {
135
149
  private templateFor;
136
150
  private cancelPending;
137
151
  private fire;
152
+ private resetLoopIterations;
153
+ /** 自主循环轮数上限: 触顶后静默停下, 每次触顶只提示一次。 */
154
+ private loopCapReached;
155
+ private checkConnectivity;
156
+ /**
157
+ * 网络类失败的续跑先过连通性检测: 断网时发出去必然再失败一次, 白白吃掉连续上限,
158
+ * 等网络恢复时预算已耗尽。挂起期间不计次数, 每 offlineCheckMs 复检一次, 恢复后
159
+ * 重新走 schedule(宽限、冷却照常)。手动续跑和非网络原因不受影响。
160
+ */
161
+ private fireWhenOnline;
138
162
  /**
139
163
  * 组装本次续跑消息: 模板填充 + 幂等护栏。
140
164
  * 护栏依据上一步工具调用的执行状态附加指引, 防止重跑副作用操作:
@@ -156,6 +180,31 @@ export declare class AutoContinueRunner {
156
180
  * 则启动扫描永远看不到它们; 谓词与上方扫描一致, 仅失败类原因。
157
181
  */
158
182
  private sweepStoredSessions;
183
+ /**
184
+ * 子会话裁决。子会话本身永不直接续跑(父代理权威, 见 README), 但启动扫描要
185
+ * 知道它是否在重启时被打断, 才能在自己的 root 会话上补一次带清单的唤醒。
186
+ * 独立 `childSwept` 记账与独立配额: 主扫描的 `storedSwept` 在 origin 判断
187
+ * 之前就已标记, 复用它会让子会话永远扫不到, 也会吃掉主扫描的观察预算。
188
+ */
189
+ private sweepChild;
190
+ /** 把本轮收集到的子会话中断转成 root 会话上的一次唤醒(同一批只催一次)。 */
191
+ private wakeInterruptedChildren;
192
+ /**
193
+ * 在 root 会话上唤醒一次。只有在 root 自己是"干净终态"时才动手: 它若被打断,
194
+ * 主扫描本来就会续跑它; 它若被用户手动停止, 唤醒就是幽灵回合。
195
+ */
196
+ private wakeRoot;
197
+ /** 父会话只在"干净结束"或"被宿主关闭"时接受唤醒; 用户手动停止的绝不复活。 */
198
+ private rootAcceptsWake;
199
+ /** 发送需要 live agent; 存储会话沿既有物化路径拉起, 复用 preset 与模型回装。 */
200
+ private ensureLiveAgent;
201
+ /** 唤醒文本必须带会话级证据: 否则父会话看不到任何状态, 只会白跑一轮再回一句"都结束了"。 */
202
+ private buildChildResumeText;
203
+ /**
204
+ * 重启会把 active goal 置为 disarmed(宿主卸载驱动的正常动作), 只有人类授权的
205
+ * resume 能重新 arm; paused 则是人类的显式决定。两者都默认关闭。
206
+ */
207
+ private rearmGoal;
159
208
  /**
160
209
  * 按会话记录的 preset 组合把存储会话恢复为 live agent(镜像会话控制
161
210
  * 器的 adopt 路径: preset 挂载 + 会话已记录的模型选择回装)。模型选择
@@ -19,6 +19,8 @@ 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`). */
@@ -83,9 +85,23 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
83
85
  loopToolRepeat: z<number, number>;
84
86
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
85
87
  loopText: z<string, string>;
88
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
89
+ resumeInterruptedChildren: z<boolean, boolean>;
90
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
91
+ resumeGoals: z<boolean, boolean>;
92
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
93
+ resumePausedGoals: z<boolean, boolean>;
94
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
95
+ pauseWhenOffline: z<boolean, boolean>;
96
+ /** How often (ms) a held recovery re-checks connectivity. */
97
+ offlineCheckMs: z<number, number>;
98
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
99
+ loopMaxIterations: z<number, number>;
86
100
  }>, Schemastery.ObjectT<{
87
101
  /** Active browser/UI locale mirrored by the client. */
88
102
  locale: z<string, string>;
103
+ /** Send continue messages with the plugin source instead of the legacy user source. */
104
+ usePluginSource: z<boolean, boolean>;
89
105
  /** Text automatically sent after an interruption. */
90
106
  continueText: z<string, string>;
91
107
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -150,12 +166,26 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
150
166
  loopToolRepeat: z<number, number>;
151
167
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
152
168
  loopText: z<string, string>;
169
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
170
+ resumeInterruptedChildren: z<boolean, boolean>;
171
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
172
+ resumeGoals: z<boolean, boolean>;
173
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
174
+ resumePausedGoals: z<boolean, boolean>;
175
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
176
+ pauseWhenOffline: z<boolean, boolean>;
177
+ /** How often (ms) a held recovery re-checks connectivity. */
178
+ offlineCheckMs: z<number, number>;
179
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
180
+ loopMaxIterations: z<number, number>;
153
181
  }>>;
154
182
  /** Loader config is a live reference on DSH 0.1.7, and a plain object on older hosts. */
155
183
  export type AutoContinueEntryConfig = EntrySettings | LiveEntrySettings;
156
184
  export declare const Config: z<Schemastery.ObjectS<{
157
185
  /** Active browser/UI locale mirrored by the client. */
158
186
  locale: z<string, string>;
187
+ /** Send continue messages with the plugin source instead of the legacy user source. */
188
+ usePluginSource: z<boolean, boolean>;
159
189
  /** Text automatically sent after an interruption. */
160
190
  continueText: z<string, string>;
161
191
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -220,9 +250,23 @@ export declare const Config: z<Schemastery.ObjectS<{
220
250
  loopToolRepeat: z<number, number>;
221
251
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
222
252
  loopText: z<string, string>;
253
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
254
+ resumeInterruptedChildren: z<boolean, boolean>;
255
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
256
+ resumeGoals: z<boolean, boolean>;
257
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
258
+ resumePausedGoals: z<boolean, boolean>;
259
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
260
+ pauseWhenOffline: z<boolean, boolean>;
261
+ /** How often (ms) a held recovery re-checks connectivity. */
262
+ offlineCheckMs: z<number, number>;
263
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
264
+ loopMaxIterations: z<number, number>;
223
265
  }>, Schemastery.ObjectT<{
224
266
  /** Active browser/UI locale mirrored by the client. */
225
267
  locale: z<string, string>;
268
+ /** Send continue messages with the plugin source instead of the legacy user source. */
269
+ usePluginSource: z<boolean, boolean>;
226
270
  /** Text automatically sent after an interruption. */
227
271
  continueText: z<string, string>;
228
272
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -287,6 +331,18 @@ export declare const Config: z<Schemastery.ObjectS<{
287
331
  loopToolRepeat: z<number, number>;
288
332
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
289
333
  loopText: z<string, string>;
334
+ /** Recover child (subagent / Agent Teams) sessions a restart interrupted by waking their root session once. */
335
+ resumeInterruptedChildren: z<boolean, boolean>;
336
+ /** Re-arm a goal a restart left `active` but `disarmed`, when its own session is resumed. */
337
+ resumeGoals: z<boolean, boolean>;
338
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
339
+ resumePausedGoals: z<boolean, boolean>;
340
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
341
+ pauseWhenOffline: z<boolean, boolean>;
342
+ /** How often (ms) a held recovery re-checks connectivity. */
343
+ offlineCheckMs: z<number, number>;
344
+ /** Autonomous-loop round cap per session; 0 means unlimited. */
345
+ loopMaxIterations: z<number, number>;
290
346
  }>> | z<AutoContinueSettings, AutoContinueEntryConfig>;
291
347
  /**
292
348
  * Plugin body: start the single-instance engine and serve the status bridge.
@@ -5,6 +5,14 @@
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
17
  export type AutoContinueLocale = 'en' | 'zh';
10
18
  export declare function resolveLocale(locale: unknown): AutoContinueLocale;
@@ -44,6 +52,8 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
44
52
  export interface AutoContinueSettings {
45
53
  /** Active browser/UI locale mirrored by the client. */
46
54
  locale?: AutoContinueLocale;
55
+ /** Send continue messages with the plugin source instead of the legacy user source. */
56
+ usePluginSource?: boolean;
47
57
  /** Text automatically sent after an interruption. */
48
58
  continueText?: string;
49
59
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -108,6 +118,18 @@ export interface AutoContinueSettings {
108
118
  loopRepeatText?: number;
109
119
  /** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
110
120
  loopText?: string;
121
+ /** Recover child (subagent / Agent Teams) sessions that a restart interrupted by waking their root session once. */
122
+ resumeInterruptedChildren?: boolean;
123
+ /** Re-arm a goal that a restart left `active` but `disarmed`, when its own session is resumed. */
124
+ resumeGoals?: boolean;
125
+ /** Also resume goals the user explicitly paused. Off by default: pausing is a human decision. */
126
+ resumePausedGoals?: boolean;
127
+ /** Hold network-error recoveries while the host is offline; waiting does not consume the retry budget. */
128
+ pauseWhenOffline?: boolean;
129
+ /** How often (ms) a held recovery re-checks connectivity. */
130
+ offlineCheckMs?: number;
131
+ /** Autonomous-loop round cap per session; 0 means unlimited. Resets when the user sends a message or turns the loop back on. */
132
+ loopMaxIterations?: number;
111
133
  }
112
134
  /** Fully resolved configuration (built-in defaults + user overrides). */
113
135
  export type AutoContinueConfig = Required<AutoContinueSettings>;
@@ -145,6 +167,11 @@ export declare function isTransientFailure(failure: FailureFacts, retryableError
145
167
  * 序列化失败(如 Windows 下 abort 的 DOMException reason)绝不能自动续跑。
146
168
  */
147
169
  export declare function isTransientAgentError(message: string): boolean;
170
+ /**
171
+ * 失败是否属于连接层(断网/DNS/连接被拒/传输超时)。只有这类失败值得先做连通性
172
+ * 检测: 断网时续跑必然再失败一次, 白白消耗连续上限。5xx/429 等服务端错误不在此列。
173
+ */
174
+ export declare function isNetworkFailure(failure: FailureFacts): boolean;
148
175
  /** 通知上的一个操作按钮(action 标识 + 显示文案)。 */
149
176
  export interface NotifyAction {
150
177
  /** 稳定动作标识, 点击时经 onAction 回调传出。 */
@@ -353,6 +380,18 @@ export interface SessionState {
353
380
  loopRetryTimer: ReturnType<typeof setTimeout> | undefined;
354
381
  /** 冷却期恢复的延迟定时器(等到冷却结束再 schedule, 而不是丢弃这次恢复)。 */
355
382
  cooldownRetryTimer: ReturnType<typeof setTimeout> | undefined;
383
+ /** 断网挂起: 进行中的连通性检测令牌(取消时置空, 迟到的检测结果据此作废)。 */
384
+ offlineWait: object | undefined;
385
+ /** 断网挂起: 下一次连通性复检的定时器。 */
386
+ offlineTimer: ReturnType<typeof setTimeout> | undefined;
387
+ /** 本次断网挂起开始的时间; 0 = 未挂起(只在挂起开始/结束时各记一次日志)。 */
388
+ offlineSince: number;
389
+ /** 自主循环已续跑的轮数(用户发消息或重新开启循环时清零)。 */
390
+ loopIterations: number;
391
+ /** 本轮循环上限提示已发出(每次触顶只提示一次)。 */
392
+ loopCapNotified: boolean;
393
+ /** 上次观察到的循环开关; 由关到开时清零轮数。 */
394
+ loopEnabled: boolean | undefined;
356
395
  }
357
396
  export declare const freshState: () => SessionState;
358
397
  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.17.3",
4
+ "version": "0.18.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "watch": "node build.mjs --watch",
51
51
  "typecheck": "tsc --noEmit",
52
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/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
+ "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
54
  "prepack": "npm run build"
55
55
  },
56
56
  "keywords": [
@@ -34,6 +34,8 @@ export const zh = {
34
34
  'field.paused': '全局启用自动继续',
35
35
  'field.showComposerToggle': '在会话区显示自动继续开关',
36
36
  'field.showComposerToggleHint': '默认显示。隐藏控件不会改变会话模式;点击保存后生效。',
37
+ 'field.usePluginSource': '以插件来源发送继续消息',
38
+ 'field.usePluginSourceHint': '默认关闭,沿用旧版用户消息来源;开启后标记为本插件来源。点击保存后生效。',
37
39
  'composer.label': '自动继续',
38
40
  'composer.mode': '自动继续模式',
39
41
  'composer.scope': '只控制当前会话,立即保存并同步到其他标签页。关闭后也不再自动打断循环。',
@@ -56,6 +58,18 @@ export const zh = {
56
58
  'field.resumeSilentTurnsHint': '已观察到模型活动但没有可见输出时续跑;不把空回合、图片或扩展内容误判为静默,冷却与连续上限照常生效。',
57
59
  'field.resumeCompletedTurns': '默认会话模式',
58
60
  'field.resumeCompletedTurnsHint': '用于没有单独设置模式的会话。仅故障恢复不会接力正常完成的回合;自主循环会在正常完成后继续。无输出和失败回合仍受重试预算约束。',
61
+ 'field.resumeInterruptedChildren': '重启后唤醒子代理会话',
62
+ 'field.resumeInterruptedChildrenHint': '启动扫描发现子代理 / 团队成员会话在重启时被打断时,给它的父会话发送一条带会话清单的提示,由父会话决定继续或收尾。父会话本身已正常结束(或被你手动停止)时不会唤醒。默认关闭。',
63
+ 'field.resumeGoals': '重新武装被重启失活的 goal',
64
+ 'field.resumeGoalsHint': '会话被自动续跑时,把被宿主 disarm 的 active goal 重新 arm,让 goal 的自动继续轮能转起来。注意:这等于代替你做了授权,所以默认关闭。',
65
+ 'field.resumePausedGoals': '恢复被暂停的 goal',
66
+ 'field.resumePausedGoalsHint': '连你手动 pause 的 goal 也一并恢复(需同时开启「重新武装被重启失活的 goal」)。暂停通常是人的明确决定,非必要别开。',
67
+ 'field.pauseWhenOffline': '断网时暂停续跑',
68
+ 'field.pauseWhenOfflineHint': '网络类错误(连不上、DNS 失败、传输超时)续跑前先检测宿主是否联网;断网时挂起,不消耗连续次数,联网后自动继续。设了 HTTP(S)_PROXY 时只检查网卡。',
69
+ 'field.offlineCheckMs': '断网复检间隔 (ms)',
70
+ 'field.offlineCheckMsHint': '挂起期间多久重新检测一次网络,最小 1000。',
71
+ 'field.loopMaxIterations': '自主循环轮数上限',
72
+ 'field.loopMaxIterationsHint': '每个会话自主续跑的最多轮数,0 为不限制。到达上限后停下并提示一次;你发消息或重新开启循环后重新计数。',
59
73
  'field.continueTextLoop': '自主循环的继续文本',
60
74
  'field.continueTextLoopHint': '自主循环每次续跑时发送的文本。',
61
75
  'default.continueTextLoop': LOCALIZED_TEXT_DEFAULTS.zh.continueTextLoop,
@@ -189,6 +203,8 @@ export const en: Record<SettingsCardKey, string> = {
189
203
  'field.paused': 'Enable auto-continue globally',
190
204
  'field.showComposerToggle': 'Show auto-continue switch in the composer',
191
205
  'field.showComposerToggleHint': 'Shown by default. Hiding the control does not change session modes. Click Save to apply.',
206
+ 'field.usePluginSource': 'Send continue messages with plugin source',
207
+ 'field.usePluginSourceHint': 'Off by default to keep the legacy user-message source. Turn on to identify messages as coming from this plugin. Click Save to apply.',
192
208
  'composer.label': 'Auto-continue',
193
209
  'composer.mode': 'Auto-continue mode',
194
210
  'composer.scope': 'Only affects this session. Saved immediately and synced across tabs. Off also disables loop-guard interruptions here.',
@@ -211,6 +227,18 @@ export const en: Record<SettingsCardKey, string> = {
211
227
  '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.',
212
228
  'field.resumeCompletedTurns': 'Default session mode',
213
229
  'field.resumeCompletedTurnsHint': 'Applies to sessions without their own mode. Recovery only leaves normal completions alone; autonomous loop continues after them. Silent and failed turns still consume the retry budget.',
230
+ 'field.resumeInterruptedChildren': 'Wake child sessions after restart',
231
+ 'field.resumeInterruptedChildrenHint': 'When the startup scan finds a subagent / team-member session interrupted by a restart, send its parent session one prompt listing those children so the parent can continue or wrap up. Skipped when the parent already finished cleanly or you stopped it yourself. Off by default.',
232
+ 'field.resumeGoals': 'Re-arm goals disarmed by a restart',
233
+ 'field.resumeGoalsHint': 'When a session is auto-continued, re-arm an active goal that the host disarmed so its continuation rounds can run again. This authorizes on your behalf, so it is off by default.',
234
+ 'field.resumePausedGoals': 'Resume paused goals',
235
+ 'field.resumePausedGoalsHint': 'Also resume goals you paused by hand (requires “Re-arm goals disarmed by a restart” to be on as well). Pausing is normally a deliberate human decision; leave this off unless you want it.',
236
+ 'field.pauseWhenOffline': 'Pause while offline',
237
+ 'field.pauseWhenOfflineHint': 'Before retrying a network error (unreachable host, DNS failure, transport timeout), check that the host is online. While offline the retry waits without using up consecutive attempts, then continues once the network is back. With HTTP(S)_PROXY set, only network interfaces are checked.',
238
+ 'field.offlineCheckMs': 'Offline re-check interval (ms)',
239
+ 'field.offlineCheckMsHint': 'How often a held retry checks the network again. Minimum 1000.',
240
+ 'field.loopMaxIterations': 'Autonomous loop round limit',
241
+ 'field.loopMaxIterationsHint': 'Maximum autonomous rounds per session; 0 means no limit. When reached, the loop stops and tells you once; sending a message or turning the loop back on starts the count over.',
214
242
  'field.continueTextLoop': 'Continue text (autonomous loop)',
215
243
  'field.continueTextLoopHint': 'Text sent on each autonomous-loop continuation.',
216
244
  'default.continueTextLoop': LOCALIZED_TEXT_DEFAULTS.en.continueTextLoop,
@@ -84,10 +84,17 @@ export interface AutoContinueSettingsCardState extends CardShell {
84
84
  notificationFeedback: SettingsCardKey | undefined;
85
85
  paused: CardFieldState;
86
86
  showComposerToggle: CardFieldState;
87
+ usePluginSource: CardFieldState;
87
88
  continueText: CardFieldState;
88
89
  continueTextMaxTokens: CardFieldState;
89
90
  resumeSilentTurns: CardFieldState;
90
91
  resumeCompletedTurns: CardFieldState;
92
+ resumeInterruptedChildren: CardFieldState;
93
+ resumeGoals: CardFieldState;
94
+ resumePausedGoals: CardFieldState;
95
+ pauseWhenOffline: CardFieldState;
96
+ offlineCheckMs: CardFieldState;
97
+ loopMaxIterations: CardFieldState;
91
98
  continueTextLoop: CardFieldState;
92
99
  continueTextSilent: CardFieldState;
93
100
  continueTextInterrupted: CardFieldState;
@@ -145,10 +152,17 @@ export class AutoContinueSettingsCardController {
145
152
  this.form = new CardForm(scope, [
146
153
  booleanField('paused'),
147
154
  booleanField('showComposerToggle'),
155
+ booleanField('usePluginSource'),
148
156
  textField('continueText'),
149
157
  textField('continueTextMaxTokens'),
150
158
  booleanField('resumeSilentTurns'),
151
159
  booleanField('resumeCompletedTurns'),
160
+ booleanField('resumeInterruptedChildren'),
161
+ booleanField('resumeGoals'),
162
+ booleanField('resumePausedGoals'),
163
+ booleanField('pauseWhenOffline'),
164
+ numberField('offlineCheckMs', 1000),
165
+ numberField('loopMaxIterations', 0),
152
166
  textField('continueTextLoop'),
153
167
  textField('continueTextSilent'),
154
168
  textField('continueTextInterrupted'),
@@ -187,10 +201,17 @@ export class AutoContinueSettingsCardController {
187
201
  notificationFeedback: this.notificationFeedback,
188
202
  paused: this.form.field('paused'),
189
203
  showComposerToggle: this.form.field('showComposerToggle'),
204
+ usePluginSource: this.form.field('usePluginSource'),
190
205
  continueText: this.form.field('continueText'),
191
206
  continueTextMaxTokens: this.form.field('continueTextMaxTokens'),
192
207
  resumeSilentTurns: this.form.field('resumeSilentTurns'),
193
208
  resumeCompletedTurns: this.form.field('resumeCompletedTurns'),
209
+ resumeInterruptedChildren: this.form.field('resumeInterruptedChildren'),
210
+ resumeGoals: this.form.field('resumeGoals'),
211
+ resumePausedGoals: this.form.field('resumePausedGoals'),
212
+ pauseWhenOffline: this.form.field('pauseWhenOffline'),
213
+ offlineCheckMs: this.form.field('offlineCheckMs'),
214
+ loopMaxIterations: this.form.field('loopMaxIterations'),
194
215
  continueTextLoop: this.form.field('continueTextLoop'),
195
216
  continueTextSilent: this.form.field('continueTextSilent'),
196
217
  continueTextInterrupted: this.form.field('continueTextInterrupted'),
@@ -301,9 +322,9 @@ export function AutoContinueSettingsPage(props: AutoContinueSettingsCardProps) {
301
322
 
302
323
  type FieldName = Exclude<keyof AutoContinueSettingsCardState, keyof CardShell | 'enabled' | 'notificationFeedback'>;
303
324
  const groups = [
304
- { id: 'general', fields: ['paused', 'showComposerToggle', 'resumeSilentTurns', 'resumeCompletedTurns', 'notify'] },
305
- { id: 'recovery', fields: ['graceMs', 'cooldownMs', 'maxConsecutive', 'classify', 'retryableErrorPatterns', 'backoffFactor', 'backoffMaxMs'] },
306
- { id: 'startup', fields: ['scanOnBoot', 'scanLimit', 'freshMs'] },
325
+ { id: 'general', fields: ['paused', 'showComposerToggle', 'usePluginSource', 'resumeSilentTurns', 'resumeCompletedTurns', 'loopMaxIterations', 'notify'] },
326
+ { id: 'recovery', fields: ['graceMs', 'cooldownMs', 'maxConsecutive', 'classify', 'retryableErrorPatterns', 'backoffFactor', 'backoffMaxMs', 'pauseWhenOffline', 'offlineCheckMs', 'resumeGoals', 'resumePausedGoals'] },
327
+ { id: 'startup', fields: ['scanOnBoot', 'resumeInterruptedChildren', 'scanLimit', 'freshMs'] },
307
328
  { id: 'prompts', fields: ['continueText', 'continueTextMaxTokens', 'continueTextSilent', 'continueTextInterrupted', 'continueTextLoop', 'guardPendingText', 'guardDoneText', 'loopText'] },
308
329
  { id: 'safety', fields: ['guardTools', 'loopGuard', 'loopShortChars', 'loopWindowMs', 'loopShortCount', 'loopRepeatText', 'loopToolRepeat'] },
309
330
  { id: 'status', fields: ['verbose'] },
@@ -0,0 +1,54 @@
1
+ import dns from 'node:dns';
2
+ import os from 'node:os';
3
+
4
+ /** Resolves `true` when the host looks online. Must never reject. */
5
+ export type ConnectivityProbe = () => Promise<boolean>;
6
+
7
+ /**
8
+ * 任一可解析即视为在线。覆盖国内外网络; 只做 DNS 解析, 不建立连接、不发请求。
9
+ * 走 fake-ip / TUN 代理时解析总会成功, 结果是"放行", 与关闭本功能等价, 不会误挂起。
10
+ */
11
+ const PROBE_HOSTS = ['api.deepseek.com', 'www.baidu.com', 'one.one.one.one'] as const;
12
+ const PROBE_TIMEOUT_MS = 3000;
13
+
14
+ function hasExternalInterface(): boolean {
15
+ try {
16
+ return Object.values(os.networkInterfaces()).some(list =>
17
+ list?.some(entry => !entry.internal) ?? false);
18
+ } catch {
19
+ return true; // 读不到网卡信息时不猜, 放行
20
+ }
21
+ }
22
+
23
+ /** 显式 HTTP(S) 代理下本地 DNS 可能本就不可用, 只看网卡, 避免永久误判断网。 */
24
+ function usesExplicitProxy(): boolean {
25
+ const env = process.env;
26
+ return [env.HTTPS_PROXY, env.https_proxy, env.HTTP_PROXY, env.http_proxy, env.ALL_PROXY, env.all_proxy]
27
+ .some(value => typeof value === 'string' && value.trim() !== '');
28
+ }
29
+
30
+ function lookupWithin(host: string, ms: number): Promise<unknown> {
31
+ return new Promise((resolve, reject) => {
32
+ const timer = setTimeout(() => reject(new Error(`dns lookup timed out: ${host}`)), ms);
33
+ (timer as { unref?: () => void }).unref?.();
34
+ dns.promises.lookup(host).then(
35
+ value => { clearTimeout(timer); resolve(value); },
36
+ error => { clearTimeout(timer); reject(error); },
37
+ );
38
+ });
39
+ }
40
+
41
+ /** Host-side connectivity check: a non-loopback interface plus one resolvable public name. */
42
+ export const probeConnectivity: ConnectivityProbe = async () => {
43
+ if (!hasExternalInterface()) return false;
44
+ if (usesExplicitProxy()) return true;
45
+ return new Promise<boolean>((resolve) => {
46
+ let pending: number = PROBE_HOSTS.length;
47
+ for (const host of PROBE_HOSTS) {
48
+ lookupWithin(host, PROBE_TIMEOUT_MS).then(
49
+ () => resolve(true),
50
+ () => { pending -= 1; if (pending === 0) resolve(false); },
51
+ );
52
+ }
53
+ });
54
+ };