dsh-client-auto-continue 0.18.0 → 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.
- package/CHANGELOG.md +25 -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/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 +258 -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 +47 -4
- package/lib/types/index.d.ts +8 -0
- package/lib/types/shared/core.d.ts +15 -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 +283 -41
- package/src/host/settings-migration.ts +1 -1
- package/src/index.ts +12 -1
- package/src/shared/core.ts +26 -2
|
@@ -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;
|
|
@@ -88,6 +91,12 @@ export declare class AutoContinueRunner {
|
|
|
88
91
|
subscribeState(listener: () => void): () => void;
|
|
89
92
|
private emitState;
|
|
90
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;
|
|
91
100
|
configurationChanged(): void;
|
|
92
101
|
/** 对外(状态桥): 消费待展示的通知。 */
|
|
93
102
|
drainNotices(): HostNotice[];
|
|
@@ -95,10 +104,44 @@ export declare class AutoContinueRunner {
|
|
|
95
104
|
handleNoticeAction(sessionId: SessionId | undefined, action: string): void;
|
|
96
105
|
dispose(): void;
|
|
97
106
|
private state;
|
|
98
|
-
/**
|
|
99
|
-
private
|
|
107
|
+
/** Record a subagent session's lineage and its parent id when the header carries one. */
|
|
108
|
+
private noteSubagent;
|
|
100
109
|
/** Read durable origin from the live agent for direct action paths as well. */
|
|
101
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;
|
|
102
145
|
/**
|
|
103
146
|
* 事件入口(host 单实例): 预处理工具调用/结果/模型消息(护栏与循环信号),
|
|
104
147
|
* 然后交给回合状态机。
|
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`). */
|
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.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,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
|
}
|
|
@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
3
|
import type { SnapshotStore } from './dsh-store-compat.ts';
|
|
4
4
|
import { sessionMode, type SessionMode, type SessionPolicy } from '../shared/core.ts';
|
|
5
|
-
import { NativeSwitch } from './native-switch.tsx';
|
|
6
5
|
import { ModeMenu, type ModeMenuOption } from './mode-menu.tsx';
|
|
7
6
|
import { AutoContinueIcon } from './auto-continue-icon.tsx';
|
|
8
7
|
import { NativeToast, WarningIcon, hasNativeToast } from './native-toast.tsx';
|
|
@@ -10,6 +9,8 @@ import { NativeToast, WarningIcon, hasNativeToast } from './native-toast.tsx';
|
|
|
10
9
|
export interface ComposerToggleState {
|
|
11
10
|
visible: boolean;
|
|
12
11
|
policy: SessionPolicy | undefined;
|
|
12
|
+
/** The bridge dropped; `policy` is the last known one and stays on screen, read-only. */
|
|
13
|
+
reconnecting: boolean;
|
|
13
14
|
writable: boolean;
|
|
14
15
|
saving: ReadonlySet<string>;
|
|
15
16
|
failed: ReadonlySet<string>;
|
|
@@ -47,9 +48,16 @@ export function AutoContinueComposerToggle(props: PropsLocale<'auto-continue'> &
|
|
|
47
48
|
const failed = state.failed.has(props.sessionId);
|
|
48
49
|
const saving = state.saving.has(props.sessionId);
|
|
49
50
|
const policy = state.policy;
|
|
50
|
-
|
|
51
|
+
// A child with no mode of its own shows what it actually inherits; the host
|
|
52
|
+
// resolves that alongside the explicit modes so the control never reports the
|
|
53
|
+
// profile default while recovery is disabled by the main conversation.
|
|
54
|
+
const ownMode = sessionMode(policy?.modes ?? {}, props.sessionId);
|
|
55
|
+
const mode: SessionMode = ownMode === 'default'
|
|
56
|
+
? policy?.inheritedModes?.[props.sessionId] ?? 'default'
|
|
57
|
+
: ownMode;
|
|
51
58
|
const disabled = !policy || !state.writable || saving;
|
|
52
|
-
const title = props.t(!policy ? 'composer.unavailable' :
|
|
59
|
+
const title = props.t(!policy ? 'composer.unavailable' : state.reconnecting ? 'composer.reconnecting'
|
|
60
|
+
: !state.writable ? 'chrome.readOnly' : saving ? 'composer.saving' : 'composer.scope');
|
|
53
61
|
const modeName = props.t(`composer.${mode}`);
|
|
54
62
|
const defaultName = policy
|
|
55
63
|
? `${props.t('composer.default')} (${props.t(`composer.${policy.defaultMode}`)})`
|
|
@@ -62,17 +70,20 @@ export function AutoContinueComposerToggle(props: PropsLocale<'auto-continue'> &
|
|
|
62
70
|
{ id: 'recover', label: props.t('composer.recover') },
|
|
63
71
|
{ id: 'loop', label: props.t('composer.loop') },
|
|
64
72
|
];
|
|
73
|
+
const enabled = !!policy && mode !== 'off';
|
|
74
|
+
// Turning on writes `default`, unless that would just inherit Off again (a child of an Off main chat).
|
|
75
|
+
const onMode: SessionMode = policy?.inheritedModes?.[props.sessionId] === 'off' ? 'recover' : 'default';
|
|
76
|
+
// One 28px icon switch plus a chevron-only mode menu: the mode name lives in the
|
|
77
|
+
// menu, the tooltip and the accessible name instead of taking composer width (#86).
|
|
65
78
|
return (
|
|
66
79
|
<div className="dshAcComposer" title={title} aria-busy={saving || undefined}>
|
|
67
80
|
<span className="dshAcComposerCore">
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
disabled={disabled} label={props.t('composer.label')} title={title} />
|
|
75
|
-
</span>
|
|
81
|
+
<button type="button" role="switch" className="dshAcIconBtn" data-state={enabled ? 'on' : 'off'}
|
|
82
|
+
data-stale={state.reconnecting || undefined} aria-checked={enabled}
|
|
83
|
+
aria-label={`${props.t('composer.label')}: ${fullModeLabel}`} title={`${modeTitle}\n${title}`}
|
|
84
|
+
disabled={disabled} onClick={() => props.setMode(enabled ? 'off' : onMode)}>
|
|
85
|
+
<AutoContinueIcon />
|
|
86
|
+
</button>
|
|
76
87
|
<ModeMenu mode={mode} options={options} label={modeName}
|
|
77
88
|
ariaLabel={modeTitle} selectLabel={props.t('composer.mode')} title={modeTitle}
|
|
78
89
|
disabled={disabled} onChange={props.setMode} />
|
package/src/client/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
|
20
20
|
// Type-only: pulls the `settings.plugin.item` SlotMap merge.
|
|
21
21
|
import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client';
|
|
22
22
|
import { resolveLocale, type AutoContinueSettings } from '../shared/core.ts';
|
|
23
|
-
import { en, zh, type SettingsCardKey } from './locales.ts';
|
|
23
|
+
import { en, ru, zh, type SettingsCardKey } from './locales.ts';
|
|
24
24
|
import {
|
|
25
25
|
AutoContinueSettingsCard,
|
|
26
26
|
AutoContinueSettingsCardController,
|
|
@@ -80,7 +80,11 @@ export {
|
|
|
80
80
|
* @param ctx - client root context.
|
|
81
81
|
*/
|
|
82
82
|
export function apply(ctx: ClientContext): void {
|
|
83
|
+
// The base package types `register()` dictionaries as the built-in `zh`/`en`
|
|
84
|
+
// pair only; further languages (here `ru`, added by a locale plugin at
|
|
85
|
+
// runtime) register one locale at a time, exactly as `addLanguage` allows.
|
|
83
86
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'auto-continue: dictionaries');
|
|
87
|
+
ctx.effect(() => ctx.locale.register(NS, 'ru', ru), 'auto-continue: russian dictionary');
|
|
84
88
|
ctx.effect(() => startBridge(), 'auto-continue: host bridge');
|
|
85
89
|
|
|
86
90
|
// Cordis waits for ALL top-level dependencies. Requiring settingsScope here
|