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.
- package/CHANGELOG.md +38 -0
- package/README.md +230 -310
- package/README.ru.md +382 -0
- package/README.zh.md +229 -308
- package/docs/auto-continue-workflow.archify.json +3 -3
- package/docs/auto-continue-workflow.en.archify.json +3 -3
- package/docs/auto-continue-workflow.en.html +1 -1
- package/docs/auto-continue-workflow.html +1 -1
- package/docs/auto-continue-workflow.ru.svg +530 -0
- package/docs/banner-ru-dark.svg +38 -0
- package/docs/banner-ru.svg +38 -0
- package/docs/demo-ru-static.svg +115 -0
- package/docs/demo-ru.svg +147 -0
- package/docs/releases/v0.19.0.md +62 -0
- package/docs/releases/v0.20.0.md +46 -0
- package/docs/social-preview.png +0 -0
- package/docs/social-preview.svg +30 -1
- package/lib/client.js +297 -99
- package/lib/client.js.map +3 -3
- package/lib/index.js +496 -43
- package/lib/types/client/auto-continue-icon.d.ts +7 -0
- package/lib/types/client/bridge.d.ts +2 -0
- package/lib/types/client/composer-toggle.d.ts +2 -0
- package/lib/types/client/locales.d.ts +5 -0
- package/lib/types/client/settings-card.d.ts +1 -0
- package/lib/types/host/engine.d.ts +88 -4
- package/lib/types/index.d.ts +8 -0
- package/lib/types/shared/core.d.ts +21 -1
- package/locale/ru.json +6 -0
- package/package.json +5 -3
- package/scripts/build-docs-assets.mjs +126 -0
- package/src/client/auto-continue-icon.tsx +6 -27
- package/src/client/bridge.ts +26 -6
- package/src/client/composer-toggle.tsx +22 -11
- package/src/client/index.ts +5 -1
- package/src/client/locales.ts +215 -40
- package/src/client/settings-card.tsx +8 -2
- package/src/client/settings-notifications.ts +3 -2
- package/src/client/styles.ts +17 -19
- package/src/host/engine.ts +571 -41
- package/src/host/settings-migration.ts +1 -1
- package/src/index.ts +23 -1
- package/src/shared/core.ts +32 -2
|
@@ -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>;
|
|
@@ -38,6 +38,7 @@ export declare const zh: {
|
|
|
38
38
|
'composer.loop': string;
|
|
39
39
|
'composer.paused': string;
|
|
40
40
|
'composer.unavailable': string;
|
|
41
|
+
'composer.reconnecting': string;
|
|
41
42
|
'composer.saving': string;
|
|
42
43
|
'composer.saveFailed': string;
|
|
43
44
|
'field.pausedHint': string;
|
|
@@ -49,6 +50,8 @@ export declare const zh: {
|
|
|
49
50
|
'default.continueTextMaxTokens': "继续";
|
|
50
51
|
'field.resumeSilentTurns': string;
|
|
51
52
|
'field.resumeSilentTurnsHint': string;
|
|
53
|
+
'field.resumeSubagentSessions': string;
|
|
54
|
+
'field.resumeSubagentSessionsHint': string;
|
|
52
55
|
'field.resumeCompletedTurns': string;
|
|
53
56
|
'field.resumeCompletedTurnsHint': string;
|
|
54
57
|
'field.resumeInterruptedChildren': string;
|
|
@@ -167,3 +170,5 @@ export declare const zh: {
|
|
|
167
170
|
export type SettingsCardKey = keyof typeof zh;
|
|
168
171
|
/** English dictionary, checked complete against the zh key set. */
|
|
169
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>;
|
|
@@ -16,6 +16,7 @@ export interface AutoContinueSettingsCardState extends CardShell {
|
|
|
16
16
|
continueText: CardFieldState;
|
|
17
17
|
continueTextMaxTokens: CardFieldState;
|
|
18
18
|
resumeSilentTurns: CardFieldState;
|
|
19
|
+
resumeSubagentSessions: CardFieldState;
|
|
19
20
|
resumeCompletedTurns: CardFieldState;
|
|
20
21
|
resumeInterruptedChildren: CardFieldState;
|
|
21
22
|
resumeGoals: CardFieldState;
|
|
@@ -14,7 +14,7 @@
|
|
|
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
18
|
import { type ConnectivityProbe } from './connectivity.ts';
|
|
19
19
|
/** 通知桥事件: host 引擎产生, browser 侧订阅展示(Notification / 动作按钮)。 */
|
|
20
20
|
export interface HostNotice {
|
|
@@ -28,12 +28,15 @@ export interface HostNotice {
|
|
|
28
28
|
/** 产生时间。 */
|
|
29
29
|
at: number;
|
|
30
30
|
}
|
|
31
|
-
/** 插件主体: 一条 mux 流 + 一条 host 流 + 启动/重连扫描。 */
|
|
32
31
|
export declare class AutoContinueRunner {
|
|
33
32
|
private readonly ctx;
|
|
34
33
|
private readonly getConfig;
|
|
35
34
|
private readonly probe;
|
|
36
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;
|
|
37
40
|
private readonly pauseUntil;
|
|
38
41
|
private dayStats;
|
|
39
42
|
private readonly recoveryAttempts;
|
|
@@ -41,6 +44,10 @@ export declare class AutoContinueRunner {
|
|
|
41
44
|
private readonly noticeListeners;
|
|
42
45
|
private readonly stateListeners;
|
|
43
46
|
private readonly prioritizedFollowups;
|
|
47
|
+
/** In-flight cold-resume calls, aborted when the plugin unloads. */
|
|
48
|
+
private readonly reviveControllers;
|
|
49
|
+
/** Hand-offs waiting for a live main conversation: parent -> child -> text. */
|
|
50
|
+
private readonly deferredHandoffs;
|
|
44
51
|
private readonly disposeSessionEvents;
|
|
45
52
|
private readonly disposeInboxEvents;
|
|
46
53
|
private disposed;
|
|
@@ -88,6 +95,12 @@ export declare class AutoContinueRunner {
|
|
|
88
95
|
subscribeState(listener: () => void): () => void;
|
|
89
96
|
private emitState;
|
|
90
97
|
private sessionConfig;
|
|
98
|
+
/**
|
|
99
|
+
* The session's own mode, ignoring subagent inheritance. The stored-session
|
|
100
|
+
* sweep and the restart hand-off (`resumeInterruptedChildren`) use this, so
|
|
101
|
+
* turning live subagent recovery off never silently disables them.
|
|
102
|
+
*/
|
|
103
|
+
private ownSessionConfig;
|
|
91
104
|
configurationChanged(): void;
|
|
92
105
|
/** 对外(状态桥): 消费待展示的通知。 */
|
|
93
106
|
drainNotices(): HostNotice[];
|
|
@@ -95,10 +108,44 @@ export declare class AutoContinueRunner {
|
|
|
95
108
|
handleNoticeAction(sessionId: SessionId | undefined, action: string): void;
|
|
96
109
|
dispose(): void;
|
|
97
110
|
private state;
|
|
98
|
-
/**
|
|
99
|
-
private
|
|
111
|
+
/** Record a subagent session's lineage and its parent id when the header carries one. */
|
|
112
|
+
private noteSubagent;
|
|
100
113
|
/** Read durable origin from the live agent for direct action paths as well. */
|
|
101
114
|
private isSubagent;
|
|
115
|
+
/** Header origin, cached set or state flag; for paths that only have the session id. */
|
|
116
|
+
private isSubagentSession;
|
|
117
|
+
/**
|
|
118
|
+
* Direct subagent parent id. DSH stores fork lineage in the same
|
|
119
|
+
* `header.parentSession` field, so only a session whose header origin is
|
|
120
|
+
* `subagent` may be followed upward: an ordinary ancestor (the visible main
|
|
121
|
+
* conversation, even a forked one) is the top of the recovery lineage.
|
|
122
|
+
*/
|
|
123
|
+
private parentOf;
|
|
124
|
+
/** Explicit session mode stored for this exact id, if the user gave one. */
|
|
125
|
+
private explicitMode;
|
|
126
|
+
/**
|
|
127
|
+
* A subagent's effective mode, or `undefined` when the lineage cannot be
|
|
128
|
+
* verified. An intermediate parent that is no longer live (and was never seen
|
|
129
|
+
* here) used to stop the walk early, fall back to the profile default and
|
|
130
|
+
* resume a child whose main conversation is Off; refusing the send is safe.
|
|
131
|
+
*/
|
|
132
|
+
private resolveSubagentMode;
|
|
133
|
+
/** Whether the setting and the inherited main-chat mode allow live recovery for this child. */
|
|
134
|
+
private subagentRecoveryEnabled;
|
|
135
|
+
/** Modes children inherit from their main conversation, for the composer's display. */
|
|
136
|
+
inheritedSubagentModes(): Record<string, SessionMode>;
|
|
137
|
+
/**
|
|
138
|
+
* Keep the lineage caches bounded on long-lived hosts. Once the cache grows,
|
|
139
|
+
* entries for sessions that are no longer loaded are dropped; they are re-read
|
|
140
|
+
* from the live header if the session comes back.
|
|
141
|
+
*/
|
|
142
|
+
private pruneLineage;
|
|
143
|
+
/** Mark a child session; drop only queued sends that its effective policy no longer allows. */
|
|
144
|
+
private markSubagent;
|
|
145
|
+
/** Pause deadline, including the parents' "pause this session 1h" for subagents. */
|
|
146
|
+
private effectivePauseUntil;
|
|
147
|
+
/** Whether this session sits below `ancestorId` in the subagent lineage (never fork lineage). */
|
|
148
|
+
private isDescendantOf;
|
|
102
149
|
/**
|
|
103
150
|
* 事件入口(host 单实例): 预处理工具调用/结果/模型消息(护栏与循环信号),
|
|
104
151
|
* 然后交给回合状态机。
|
|
@@ -148,6 +195,43 @@ export declare class AutoContinueRunner {
|
|
|
148
195
|
/** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens、自主循环, 其余用通用继续文本。 */
|
|
149
196
|
private templateFor;
|
|
150
197
|
private cancelPending;
|
|
198
|
+
/** Host-service facade used to cold-resume a disposed direct child. */
|
|
199
|
+
private subagentPromptProvider;
|
|
200
|
+
/** Attach the loader-provided subagent service; it may load after this plugin. */
|
|
201
|
+
setSubagentPromptProvider(provider: (() => unknown) | undefined): void;
|
|
202
|
+
private subagentPrompts;
|
|
203
|
+
/** Copy for one child hand-off, built once so a deferred delivery matches. */
|
|
204
|
+
private handoffText;
|
|
205
|
+
/**
|
|
206
|
+
* Revive a disposed child through the host's cold resume and deliver the
|
|
207
|
+
* continuation to it. Falls back to the main-conversation hand-off when the
|
|
208
|
+
* host cannot resume (no persistence, no live parent, not a direct child).
|
|
209
|
+
* The child's own recovery mode decides; the parent only has to be alive to
|
|
210
|
+
* authorize the call.
|
|
211
|
+
*/
|
|
212
|
+
private reviveChild;
|
|
213
|
+
/** Existing state of a session, without materializing one just to read it. */
|
|
214
|
+
private parentState;
|
|
215
|
+
/** Whether this session already has a continuation on the way. */
|
|
216
|
+
private hasPendingSend;
|
|
217
|
+
/**
|
|
218
|
+
* Ask the child's main conversation to take over a failure the plugin cannot
|
|
219
|
+
* repair itself: the child handle is gone, so only the root can continue it.
|
|
220
|
+
* The main conversation's Off is respected because this writes a user message
|
|
221
|
+
* into it; a child's own mode is never overridden by that Off for cold resume.
|
|
222
|
+
*/
|
|
223
|
+
private handOffToParent;
|
|
224
|
+
/**
|
|
225
|
+
* Post a hand-off into the main conversation the same way a continuation is
|
|
226
|
+
* sent: with the configured message source, and registered as our own echo so
|
|
227
|
+
* the parent does not read it as the user stepping in (which would reset its
|
|
228
|
+
* retry and loop counters and cancel whatever it had queued).
|
|
229
|
+
*/
|
|
230
|
+
private sendHandoff;
|
|
231
|
+
/** Keep one hand-off until its main conversation has a live agent again. */
|
|
232
|
+
private deferHandoff;
|
|
233
|
+
/** Deliver queued hand-offs once their main conversation is live again. */
|
|
234
|
+
private flushDeferredHandoffs;
|
|
151
235
|
private fire;
|
|
152
236
|
private resetLoopIterations;
|
|
153
237
|
/** 自主循环轮数上限: 触顶后静默停下, 每次触顶只提示一次。 */
|
package/lib/types/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
27
27
|
continueTextMaxTokens: z<string, string>;
|
|
28
28
|
/** Resume observed model activity that completes without visible output. */
|
|
29
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>;
|
|
30
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. */
|
|
31
33
|
resumeCompletedTurns: z<boolean, boolean>;
|
|
32
34
|
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
@@ -108,6 +110,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
108
110
|
continueTextMaxTokens: z<string, string>;
|
|
109
111
|
/** Resume observed model activity that completes without visible output. */
|
|
110
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>;
|
|
111
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. */
|
|
112
116
|
resumeCompletedTurns: z<boolean, boolean>;
|
|
113
117
|
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
@@ -192,6 +196,8 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
192
196
|
continueTextMaxTokens: z<string, string>;
|
|
193
197
|
/** Resume observed model activity that completes without visible output. */
|
|
194
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>;
|
|
195
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. */
|
|
196
202
|
resumeCompletedTurns: z<boolean, boolean>;
|
|
197
203
|
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
@@ -273,6 +279,8 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
273
279
|
continueTextMaxTokens: z<string, string>;
|
|
274
280
|
/** Resume observed model activity that completes without visible output. */
|
|
275
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>;
|
|
276
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. */
|
|
277
285
|
resumeCompletedTurns: z<boolean, boolean>;
|
|
278
286
|
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
@@ -14,11 +14,13 @@ 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';
|
|
17
|
+
export type AutoContinueLocale = 'en' | 'zh' | 'ru';
|
|
18
18
|
export declare function resolveLocale(locale: unknown): AutoContinueLocale;
|
|
19
19
|
export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
|
|
20
20
|
export interface SessionPolicy {
|
|
21
21
|
modes: Record<string, SessionMode>;
|
|
22
|
+
/** Modes a child inherits from its main conversation, keyed by child id. */
|
|
23
|
+
inheritedModes?: Record<string, SessionMode>;
|
|
22
24
|
defaultMode: 'recover' | 'loop';
|
|
23
25
|
paused: boolean;
|
|
24
26
|
writable: boolean;
|
|
@@ -47,6 +49,16 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
47
49
|
readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
|
|
48
50
|
readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
|
|
49
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
|
+
};
|
|
50
62
|
};
|
|
51
63
|
/** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
|
|
52
64
|
export interface AutoContinueSettings {
|
|
@@ -60,6 +72,8 @@ export interface AutoContinueSettings {
|
|
|
60
72
|
continueTextMaxTokens?: string;
|
|
61
73
|
/** Resume observed model activity that completes without visible output. */
|
|
62
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;
|
|
63
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. */
|
|
64
78
|
resumeCompletedTurns?: boolean;
|
|
65
79
|
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
@@ -348,6 +362,12 @@ export interface SessionState {
|
|
|
348
362
|
lastFailure: FailureFacts | undefined;
|
|
349
363
|
/** 最近一次失败的发生时间(模板 {elapsed} 与恢复统计用)。 */
|
|
350
364
|
lastFailureAt: number;
|
|
365
|
+
/** 最近一次把子代理失败移交主会话的时间戳(去重)。 */
|
|
366
|
+
handedOffAt?: number;
|
|
367
|
+
/** 冷恢复请求正在途中(去重, 防止重复 prompt)。 */
|
|
368
|
+
reviveInFlight?: boolean;
|
|
369
|
+
/** 主会话正在自行恢复: 由插件自己的调度/发送显式维护, 不用时间戳猜测。 */
|
|
370
|
+
recovering?: boolean;
|
|
351
371
|
/** callId 精确配对的工具调用、幂等护栏与 loop 重复态。 */
|
|
352
372
|
tools: ToolInvocationTracker;
|
|
353
373
|
/** 失败回合的编号(模板 {turn})。 */
|
package/locale/ru.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-auto-continue",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "Automatically resume interrupted DSH conversations, with an optional autonomous loop.",
|
|
4
|
+
"version": "0.20.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,7 +50,8 @@
|
|
|
49
50
|
"build": "node build.mjs && tsc -p tsconfig.build.json",
|
|
50
51
|
"watch": "node build.mjs --watch",
|
|
51
52
|
"typecheck": "tsc --noEmit",
|
|
52
|
-
"
|
|
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",
|
|
53
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
|
},
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Generate the README images in docs/: banners and the social preview. The
|
|
2
|
+
// workflow map is an Archify export (docs/auto-continue-workflow.*), not built here. Every SVG is standalone (system font stack, no external
|
|
3
|
+
// references). Run `npm run docs:assets`, then render the social preview PNG:
|
|
4
|
+
// rsvg-convert -w 1280 -h 640 docs/social-preview.svg -o docs/social-preview.png
|
|
5
|
+
import { writeFileSync } from 'node:fs';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const docs = join(dirname(fileURLToPath(import.meta.url)), '..', 'docs');
|
|
10
|
+
const FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif";
|
|
11
|
+
const MONO = "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace";
|
|
12
|
+
|
|
13
|
+
const esc = (text) => String(text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
14
|
+
const write = (name, svg) => {
|
|
15
|
+
writeFileSync(join(docs, name), `${svg.trim()}\n`);
|
|
16
|
+
console.log(`wrote docs/${name}`);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// The mark: a circular arrow wrapped around a play triangle.
|
|
20
|
+
const mark = (color) => `
|
|
21
|
+
<path d="M49 17A24 24 0 1 0 56 38" fill="none" stroke="${color}" stroke-width="5" stroke-linecap="round"/>
|
|
22
|
+
<path d="M49 6v12H37" fill="none" stroke="${color}" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
23
|
+
<path d="M27 22l16 10-16 10Z" fill="${color}" stroke="${color}" stroke-width="2" stroke-linejoin="round"/>`;
|
|
24
|
+
|
|
25
|
+
const THEMES = {
|
|
26
|
+
light: { bg: '#f4f4f5', tile: '#e4e4e7', ink: '#24262b', muted: '#545961', rule: '#d4d4d8' },
|
|
27
|
+
dark: { bg: '#141414', tile: '#23262c', ink: '#f4f4f5', muted: '#b9bec8', rule: '#37393e' },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// ---------------------------------------------------------------- banners
|
|
31
|
+
|
|
32
|
+
const BANNER_COPY = {
|
|
33
|
+
en: {
|
|
34
|
+
desc: 'A DeepSeek Harness plugin by HsiangNianian. Recover interrupted sessions, at your own pace.',
|
|
35
|
+
tagline: 'Recover interrupted sessions, at your own pace.',
|
|
36
|
+
compact: 'Interrupted? Keep going.',
|
|
37
|
+
},
|
|
38
|
+
zh: {
|
|
39
|
+
desc: 'HsiangNianian 的 DeepSeek Harness 插件。恢复意外中断的会话,按你的节奏继续。',
|
|
40
|
+
tagline: '恢复意外中断的会话,按你的节奏继续。',
|
|
41
|
+
compact: '会话意外中断?接着来。',
|
|
42
|
+
},
|
|
43
|
+
ru: {
|
|
44
|
+
desc: 'Плагин DeepSeek Harness от HsiangNianian. Возвращает прерванные сессии к работе в вашем темпе.',
|
|
45
|
+
tagline: 'Возвращает прерванные сессии к работе.',
|
|
46
|
+
compact: 'Прервалось? Продолжаем.',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function banner(lang, themeName) {
|
|
51
|
+
const t = THEMES[themeName];
|
|
52
|
+
const c = BANNER_COPY[lang];
|
|
53
|
+
return `
|
|
54
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="260" viewBox="0 0 960 260" role="img" lang="${lang}" aria-labelledby="title description">
|
|
55
|
+
<title id="title">dsh-auto-continue</title>
|
|
56
|
+
<desc id="description">${esc(c.desc)}</desc>
|
|
57
|
+
<style>
|
|
58
|
+
text { font-family: ${FONT}; }
|
|
59
|
+
.wordmark { font-size: 46px; font-weight: 650; letter-spacing: -1.5px; }
|
|
60
|
+
.tagline { font-size: 24px; }
|
|
61
|
+
.compact { display: none; }
|
|
62
|
+
@media (max-width: 520px) {
|
|
63
|
+
.eyebrow { font-size: 23px; letter-spacing: 0; }
|
|
64
|
+
.wordmark { font-size: 49px; }
|
|
65
|
+
.tagline { font-size: 32px; }
|
|
66
|
+
.credit { font-size: 25px; }
|
|
67
|
+
.full { display: none; }
|
|
68
|
+
.compact { display: inline; }
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
71
|
+
<rect width="960" height="260" rx="18" fill="${t.bg}"/>
|
|
72
|
+
<rect x="40" y="48" width="112" height="112" rx="28" fill="${t.tile}"/>
|
|
73
|
+
<g transform="translate(57 64) scale(1.25)">${mark(t.ink)}
|
|
74
|
+
</g>
|
|
75
|
+
<g fill="${t.ink}">
|
|
76
|
+
<text class="eyebrow" x="188" y="61" fill="${t.muted}" font-size="15" letter-spacing="1.6">DEEPSEEK HARNESS PLUGIN</text>
|
|
77
|
+
<text class="wordmark" x="185" y="118">dsh-auto-continue</text>
|
|
78
|
+
<text class="tagline full" x="188" y="163" fill="${t.muted}">${esc(c.tagline)}</text>
|
|
79
|
+
<text class="tagline compact" x="188" y="163" fill="${t.muted}">${esc(c.compact)}</text>
|
|
80
|
+
</g>
|
|
81
|
+
<path d="M40 200H920" stroke="${t.rule}"/>
|
|
82
|
+
<text class="credit" x="40" y="236" fill="${t.muted}" font-size="16">by HsiangNianian</text>
|
|
83
|
+
<!-- A broken thread joining back into one line. -->
|
|
84
|
+
<g fill="none" stroke="${t.muted}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
85
|
+
<path d="M700 230h44m12 0h3m12 0h3m12 0h126"/>
|
|
86
|
+
<path d="m902 224 10 6-10 6"/>
|
|
87
|
+
</g>
|
|
88
|
+
</svg>`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const lang of ['en', 'zh', 'ru']) {
|
|
92
|
+
const suffix = lang === 'en' ? '' : `-${lang}`;
|
|
93
|
+
write(`banner${suffix}.svg`, banner(lang, 'light'));
|
|
94
|
+
write(`banner${suffix}-dark.svg`, banner(lang, 'dark'));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ---------------------------------------------------------- social preview
|
|
98
|
+
|
|
99
|
+
write('social-preview.svg', `
|
|
100
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="640" viewBox="0 0 1280 640" role="img" lang="en" aria-labelledby="title">
|
|
101
|
+
<title id="title">dsh-auto-continue: recover interrupted DeepSeek Harness sessions</title>
|
|
102
|
+
<style>
|
|
103
|
+
text { font-family: ${FONT}; }
|
|
104
|
+
</style>
|
|
105
|
+
<rect width="1280" height="640" fill="${THEMES.dark.bg}"/>
|
|
106
|
+
<rect x="96" y="128" width="168" height="168" rx="42" fill="${THEMES.dark.tile}"/>
|
|
107
|
+
<g transform="translate(120 150) scale(1.9)">${mark(THEMES.dark.ink)}
|
|
108
|
+
</g>
|
|
109
|
+
<text x="320" y="160" fill="${THEMES.dark.muted}" font-size="22" letter-spacing="2.4">DEEPSEEK HARNESS PLUGIN</text>
|
|
110
|
+
<text x="316" y="240" fill="${THEMES.dark.ink}" font-size="74" font-weight="650" letter-spacing="-2">dsh-auto-continue</text>
|
|
111
|
+
<text x="320" y="300" fill="${THEMES.dark.muted}" font-size="32">Recover interrupted sessions, at your own pace.</text>
|
|
112
|
+
<g font-size="22" fill="${THEMES.dark.ink}">
|
|
113
|
+
<rect x="320" y="356" width="214" height="50" rx="25" fill="none" stroke="${THEMES.dark.rule}" stroke-width="2"/>
|
|
114
|
+
<text x="427" y="389" text-anchor="middle">Error recovery</text>
|
|
115
|
+
<rect x="550" y="356" width="214" height="50" rx="25" fill="none" stroke="${THEMES.dark.rule}" stroke-width="2"/>
|
|
116
|
+
<text x="657" y="389" text-anchor="middle">Startup scan</text>
|
|
117
|
+
<rect x="780" y="356" width="250" height="50" rx="25" fill="none" stroke="${THEMES.dark.rule}" stroke-width="2"/>
|
|
118
|
+
<text x="905" y="389" text-anchor="middle">Autonomous loop</text>
|
|
119
|
+
</g>
|
|
120
|
+
<path d="M96 520H1184" stroke="${THEMES.dark.rule}" stroke-width="2"/>
|
|
121
|
+
<text x="96" y="572" fill="${THEMES.dark.muted}" font-size="24">github.com/HsiangNianian/dsh-auto-continue</text>
|
|
122
|
+
<g fill="none" stroke="${THEMES.dark.muted}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
|
123
|
+
<path d="M884 564h60m16 0h4m16 0h4m16 0h168"/>
|
|
124
|
+
<path d="m1172 556 12 8-12 8"/>
|
|
125
|
+
</g>
|
|
126
|
+
</svg>`);
|
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auto-continue glyph.
|
|
2
|
+
* Auto-continue glyph: a single-stroke infinity loop.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* narrow widths.
|
|
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.
|
|
8
7
|
*/
|
|
9
|
-
import type { ComponentType } from 'react';
|
|
10
|
-
|
|
11
|
-
interface IconProps {
|
|
12
|
-
className?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const primitives = (() => {
|
|
16
|
-
try {
|
|
17
|
-
return require('@deepseek-ai/dsh-client-ui-primitives') as {
|
|
18
|
-
IconRefreshOutlineRegular?: ComponentType<IconProps>;
|
|
19
|
-
};
|
|
20
|
-
} catch {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
})();
|
|
24
|
-
|
|
25
|
-
const HostRefresh = primitives.IconRefreshOutlineRegular;
|
|
26
|
-
|
|
27
8
|
export function AutoContinueIcon() {
|
|
28
|
-
if (HostRefresh) return <HostRefresh />;
|
|
29
9
|
return (
|
|
30
|
-
<svg className="
|
|
31
|
-
<path d="
|
|
32
|
-
<path d="M13.25 3.1v3.3h-3.3" />
|
|
10
|
+
<svg className="dshAcGlyph" viewBox="0 0 16 16" aria-hidden="true">
|
|
11
|
+
<path d="M8 8C7 5.6 6.1 4.6 4.8 4.6C3.1 4.6 2 6.1 2 8C2 9.9 3.1 11.4 4.8 11.4C6.1 11.4 7 10.4 8 8C9 5.6 9.9 4.6 11.2 4.6C12.9 4.6 14 6.1 14 8C14 9.9 12.9 11.4 11.2 11.4C9.9 11.4 9 10.4 8 8Z" />
|
|
33
12
|
</svg>
|
|
34
13
|
);
|
|
35
14
|
}
|
package/src/client/bridge.ts
CHANGED
|
@@ -32,6 +32,8 @@ interface BridgeState {
|
|
|
32
32
|
paused: PausedSessionView[];
|
|
33
33
|
recoveryAttempts: RecoveryAttempt[];
|
|
34
34
|
sessionPolicy?: SessionPolicy;
|
|
35
|
+
/** False while the SSE stream is down; the last known policy stays readable but not writable. */
|
|
36
|
+
connected: boolean;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
interface BridgeNotice {
|
|
@@ -54,7 +56,7 @@ const EMPTY_STATS: DayStatsView = {
|
|
|
54
56
|
byCode: {},
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
let state: BridgeState = { stats: EMPTY_STATS, paused: [], recoveryAttempts: [] };
|
|
59
|
+
let state: BridgeState = { stats: EMPTY_STATS, paused: [], recoveryAttempts: [], connected: false };
|
|
58
60
|
const listeners = new Set<() => void>();
|
|
59
61
|
|
|
60
62
|
/** 当前桥状态里的已暂停会话(卡片面板用)。 */
|
|
@@ -71,12 +73,17 @@ export function readRecoveryAttempts(): RecoveryAttempt[] {
|
|
|
71
73
|
return state.recoveryAttempts;
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
/** Last policy the host sent. It survives a bridge reconnect, so check {@link isBridgeConnected} before writing. */
|
|
74
77
|
export function readSessionPolicy(): SessionPolicy | undefined {
|
|
75
78
|
return state.sessionPolicy;
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
export function isBridgeConnected(): boolean {
|
|
82
|
+
return state.connected;
|
|
83
|
+
}
|
|
84
|
+
|
|
78
85
|
export async function setSessionMode(sessionId: string, mode: SessionMode): Promise<void> {
|
|
79
|
-
if (!state.sessionPolicy?.writable) throw new Error('Session settings are unavailable');
|
|
86
|
+
if (!state.connected || !state.sessionPolicy?.writable) throw new Error('Session settings are unavailable');
|
|
80
87
|
const response = await fetch('/api/auto-continue-action', {
|
|
81
88
|
method: 'POST',
|
|
82
89
|
headers: { 'content-type': 'application/json' },
|
|
@@ -129,6 +136,7 @@ function handleEvent(event: { type: string; notice?: BridgeNotice; stats?: DaySt
|
|
|
129
136
|
sessionPolicy: policy && typeof policy.modes === 'object' && policy.modes !== null && !Array.isArray(policy.modes) &&
|
|
130
137
|
(policy.defaultMode === 'recover' || policy.defaultMode === 'loop') && typeof policy.paused === 'boolean' && typeof policy.writable === 'boolean'
|
|
131
138
|
? policy : undefined,
|
|
139
|
+
connected: true,
|
|
132
140
|
};
|
|
133
141
|
for (const listener of listeners) listener();
|
|
134
142
|
} else if (event.type === 'notice' && event.notice !== undefined) {
|
|
@@ -187,11 +195,19 @@ function showNotification(notice: BridgeNotice): void {
|
|
|
187
195
|
export function startBridge(): () => void {
|
|
188
196
|
let stopped = false;
|
|
189
197
|
let controller: AbortController | undefined;
|
|
198
|
+
// A dropped stream (engine rebuild, sleep, a proxy closing an idle socket) keeps the
|
|
199
|
+
// last policy on screen so the composer does not flash to "off" while reconnecting (#86).
|
|
190
200
|
const disconnected = () => {
|
|
191
|
-
|
|
201
|
+
if (!state.connected) return;
|
|
202
|
+
state = { ...state, connected: false };
|
|
203
|
+
for (const listener of listeners) listener();
|
|
204
|
+
};
|
|
205
|
+
const reset = () => {
|
|
206
|
+
state = { ...state, sessionPolicy: undefined, connected: false };
|
|
192
207
|
for (const listener of listeners) listener();
|
|
193
208
|
};
|
|
194
|
-
|
|
209
|
+
reset();
|
|
210
|
+
let failures = 0;
|
|
195
211
|
|
|
196
212
|
const loop = async (): Promise<void> => {
|
|
197
213
|
while (!stopped) {
|
|
@@ -199,6 +215,7 @@ export function startBridge(): () => void {
|
|
|
199
215
|
try {
|
|
200
216
|
const response = await fetch('/api/auto-continue-bridge', { signal: controller.signal });
|
|
201
217
|
if (!response.ok || response.body === null) throw new Error(`bridge HTTP ${response.status}`);
|
|
218
|
+
failures = 0;
|
|
202
219
|
const reader = response.body.getReader();
|
|
203
220
|
const decoder = new TextDecoder();
|
|
204
221
|
let buffer = '';
|
|
@@ -227,7 +244,10 @@ export function startBridge(): () => void {
|
|
|
227
244
|
}
|
|
228
245
|
if (!stopped) {
|
|
229
246
|
disconnected();
|
|
230
|
-
|
|
247
|
+
// The first retry is quick: most drops are the host rebuilding its engine.
|
|
248
|
+
const delay = failures === 0 ? 500 : 3000;
|
|
249
|
+
failures += 1;
|
|
250
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
231
251
|
}
|
|
232
252
|
}
|
|
233
253
|
};
|
|
@@ -236,6 +256,6 @@ export function startBridge(): () => void {
|
|
|
236
256
|
return () => {
|
|
237
257
|
stopped = true;
|
|
238
258
|
controller?.abort();
|
|
239
|
-
|
|
259
|
+
reset();
|
|
240
260
|
};
|
|
241
261
|
}
|