dsh-client-auto-continue 0.18.0 → 0.20.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 (43) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +230 -310
  3. package/README.ru.md +382 -0
  4. package/README.zh.md +229 -308
  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.19.0.md +62 -0
  15. package/docs/releases/v0.20.0.md +46 -0
  16. package/docs/social-preview.png +0 -0
  17. package/docs/social-preview.svg +30 -1
  18. package/lib/client.js +297 -99
  19. package/lib/client.js.map +3 -3
  20. package/lib/index.js +496 -43
  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 +5 -0
  25. package/lib/types/client/settings-card.d.ts +1 -0
  26. package/lib/types/host/engine.d.ts +88 -4
  27. package/lib/types/index.d.ts +8 -0
  28. package/lib/types/shared/core.d.ts +21 -1
  29. package/locale/ru.json +6 -0
  30. package/package.json +5 -3
  31. package/scripts/build-docs-assets.mjs +126 -0
  32. package/src/client/auto-continue-icon.tsx +6 -27
  33. package/src/client/bridge.ts +26 -6
  34. package/src/client/composer-toggle.tsx +22 -11
  35. package/src/client/index.ts +5 -1
  36. package/src/client/locales.ts +215 -40
  37. package/src/client/settings-card.tsx +8 -2
  38. package/src/client/settings-notifications.ts +3 -2
  39. package/src/client/styles.ts +17 -19
  40. package/src/host/engine.ts +571 -41
  41. package/src/host/settings-migration.ts +1 -1
  42. package/src/index.ts +23 -1
  43. package/src/shared/core.ts +32 -2
@@ -49,7 +49,7 @@ export function migrateLegacySettings(
49
49
  if (disposed) return;
50
50
  // YAML errors may quote other plugins' secrets, so do not log the source
51
51
  // or parser exception. Leave the original document available for repair.
52
- migration.logger.error('[auto-continue] Could not import settings-legacy.yaml; automatic recovery and loop guard are held until the file/profile can be read and saved, then restart the host');
52
+ migration.logger.error('[auto-continue] Could not import settings-legacy.yaml. Automatic recovery and loop guard are paused. Check the legacy settings file and profile permissions, then restart DSH.');
53
53
  };
54
54
  // Do not return this task to Cordis: profile edits require the owning entry
55
55
  // to be active, and Loader.await() must not wait for this migration itself.
package/src/index.ts CHANGED
@@ -23,6 +23,8 @@ import type {} from '@deepseek-ai/dsh-settings';
23
23
 
24
24
  /** Settings namespace of the auto-continue plugin (lowercase kebab-case). */
25
25
  export const AUTO_CONTINUE_NS = 'auto-continue';
26
+ /** Interval for SSE comment frames on the status bridge, so idle connections are not dropped. */
27
+ const BRIDGE_HEARTBEAT_MS = 20_000;
26
28
 
27
29
  /** Wire schema; blank localized text fields tell resolveConfig() to select the active locale's defaults. */
28
30
  const settingsFields = {
@@ -36,6 +38,8 @@ const settingsFields = {
36
38
  continueTextMaxTokens: z.string().default(''),
37
39
  /** Resume observed model activity that completes without visible output. */
38
40
  resumeSilentTurns: z.boolean().default(true),
41
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
42
+ resumeSubagentSessions: z.boolean().default(false),
39
43
  /** 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. */
40
44
  resumeCompletedTurns: z.boolean().default(false),
41
45
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -176,6 +180,17 @@ export function apply(ctx: Context, config?: AutoContinueEntryConfig): void {
176
180
  disposeEngine?.();
177
181
  const readConfig = () => resolveConfig(legacyConfig?.() ?? readEntry());
178
182
  const runner = new AutoContinueRunner(engineCtx, readConfig);
183
+ // The subagent service may load after this plugin, and the engine context does
184
+ // not see it through `get`; inject the facade lazily so a later load is picked
185
+ // up and a disposed child can be cold-resumed instead of only handed off.
186
+ // Scoped to this engine, so a rebuilt engine does not stack another inject,
187
+ // and the provider is cleared again when the service unloads.
188
+ engineCtx.inject(['subagents'], (subagentCtx) => {
189
+ runner.setSubagentPromptProvider(
190
+ () => (subagentCtx as unknown as { subagents?: unknown }).subagents,
191
+ );
192
+ subagentCtx.effect(() => () => runner.setSubagentPromptProvider(undefined));
193
+ });
179
194
  const writableSettings = () => {
180
195
  const settings = engineCtx.get('settings');
181
196
  return settings?.writable && typeof settings.mutate === 'function' ? settings : undefined;
@@ -202,6 +217,7 @@ export function apply(ctx: Context, config?: AutoContinueEntryConfig): void {
202
217
  recoveryAttempts: runner.recentRecoveryAttempts(),
203
218
  sessionPolicy: {
204
219
  modes: config.sessionModes,
220
+ inheritedModes: runner.inheritedSubagentModes(),
205
221
  defaultMode: config.resumeCompletedTurns ? 'loop' : 'recover',
206
222
  paused: config.paused,
207
223
  writable: writableSettings() !== undefined,
@@ -236,9 +252,15 @@ export function apply(ctx: Context, config?: AutoContinueEntryConfig): void {
236
252
  res.write(data);
237
253
  };
238
254
  sseClients.add(send);
239
- const close = () => { res.end(); };
255
+ // Comment frames keep idle connections alive through proxies, sleep and security software (#86).
256
+ const heartbeat = setInterval(() => {
257
+ try { res.write(': ping\n\n'); } catch { /* the close handler cleans up */ }
258
+ }, BRIDGE_HEARTBEAT_MS);
259
+ heartbeat.unref?.();
260
+ const close = () => { clearInterval(heartbeat); res.end(); };
240
261
  closeClients.add(close);
241
262
  req.on('close', () => {
263
+ clearInterval(heartbeat);
242
264
  sseClients.delete(send);
243
265
  closeClients.delete(close);
244
266
  });
@@ -15,16 +15,21 @@ declare module '@deepseek-ai/dsh-llm' {
15
15
  }
16
16
 
17
17
  /** Supported UI/config locales; missing and unsupported values use English. */
18
- export type AutoContinueLocale = 'en' | 'zh';
18
+ export type AutoContinueLocale = 'en' | 'zh' | 'ru';
19
19
 
20
20
  export function resolveLocale(locale: unknown): AutoContinueLocale {
21
- return typeof locale === 'string' && /^zh(?:-|$)/i.test(locale) ? 'zh' : 'en';
21
+ if (typeof locale !== 'string') return 'en';
22
+ if (/^zh(?:-|$)/i.test(locale)) return 'zh';
23
+ if (/^ru(?:-|$)/i.test(locale)) return 'ru';
24
+ return 'en';
22
25
  }
23
26
 
24
27
  export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
25
28
 
26
29
  export interface SessionPolicy {
27
30
  modes: Record<string, SessionMode>;
31
+ /** Modes a child inherits from its main conversation, keyed by child id. */
32
+ inheritedModes?: Record<string, SessionMode>;
28
33
  defaultMode: 'recover' | 'loop';
29
34
  paused: boolean;
30
35
  writable: boolean;
@@ -66,6 +71,21 @@ export const LOCALIZED_TEXT_DEFAULTS = {
66
71
  loopText:
67
72
  '(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)',
68
73
  },
74
+ ru: {
75
+ continueText: 'Продолжай',
76
+ continueTextMaxTokens: 'Продолжай',
77
+ continueTextSilent:
78
+ 'Продолжай. Предыдущий ход закончился только внутренним рассуждением: ни ответа, ни вызова инструмента, поэтому пользователь ничего не увидел. Каждый ход должен заканчиваться вызовом инструмента или видимым ответом.',
79
+ continueTextLoop: 'Продолжай',
80
+ continueTextInterrupted:
81
+ 'Продолжай. Хост перезапустился, пока предыдущий ход ещё выполнялся; вызовы инструментов, незавершённые на момент перезапуска, записаны с неизвестным результатом. Продолжай с места остановки, проверяя внешнее состояние перед повтором действий с возможными побочными эффектами.',
82
+ guardPendingText:
83
+ '(Предыдущий инструмент «{tool}», возможно, не завершился. Проверь его состояние перед продолжением и не запускай его повторно.)',
84
+ guardDoneText:
85
+ '(Предыдущий инструмент «{tool}» завершился успешно. Результат: {result}; не запускай его повторно, продолжай с этого места.)',
86
+ loopText:
87
+ '(Похоже, ты застрял в цикле. Перестань повторять последнее действие и продолжай другим способом.)',
88
+ },
69
89
  } as const satisfies Record<AutoContinueLocale, Record<string, string>>;
70
90
 
71
91
  /** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
@@ -80,6 +100,8 @@ export interface AutoContinueSettings {
80
100
  continueTextMaxTokens?: string;
81
101
  /** Resume observed model activity that completes without visible output. */
82
102
  resumeSilentTurns?: boolean;
103
+ /** Resume interrupted subagent sessions when their main conversation has auto-continue enabled. Subagents never enter the autonomous loop. */
104
+ resumeSubagentSessions?: boolean;
83
105
  /** 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. */
84
106
  resumeCompletedTurns?: boolean;
85
107
  /** Text sent to resume a silent turn (same placeholders as `continueText`). */
@@ -161,6 +183,7 @@ export const DEFAULT_CONFIG: AutoContinueConfig = {
161
183
  ...LOCALIZED_TEXT_DEFAULTS.en,
162
184
  usePluginSource: false,
163
185
  resumeSilentTurns: true,
186
+ resumeSubagentSessions: false,
164
187
  resumeCompletedTurns: false,
165
188
  continueTextLoop: '',
166
189
  guardTools: true,
@@ -240,6 +263,7 @@ export function resolveConfig(section: AutoContinueSettings | undefined): AutoCo
240
263
  continueText: text,
241
264
  continueTextMaxTokens: maxTokensText,
242
265
  resumeSilentTurns: booleanOr(value.resumeSilentTurns, DEFAULT_CONFIG.resumeSilentTurns),
266
+ resumeSubagentSessions: booleanOr(value.resumeSubagentSessions, DEFAULT_CONFIG.resumeSubagentSessions),
243
267
  resumeCompletedTurns: booleanOr(value.resumeCompletedTurns, DEFAULT_CONFIG.resumeCompletedTurns),
244
268
  continueTextSilent: silentText,
245
269
  continueTextLoop: loopText,
@@ -937,6 +961,12 @@ export interface SessionState {
937
961
  lastFailure: FailureFacts | undefined;
938
962
  /** 最近一次失败的发生时间(模板 {elapsed} 与恢复统计用)。 */
939
963
  lastFailureAt: number;
964
+ /** 最近一次把子代理失败移交主会话的时间戳(去重)。 */
965
+ handedOffAt?: number;
966
+ /** 冷恢复请求正在途中(去重, 防止重复 prompt)。 */
967
+ reviveInFlight?: boolean;
968
+ /** 主会话正在自行恢复: 由插件自己的调度/发送显式维护, 不用时间戳猜测。 */
969
+ recovering?: boolean;
940
970
  /** callId 精确配对的工具调用、幂等护栏与 loop 重复态。 */
941
971
  tools: ToolInvocationTracker;
942
972
  /** 失败回合的编号(模板 {turn})。 */