dsh-client-auto-continue 0.11.7 → 0.11.9
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/README.md +23 -9
- package/README.zh.md +23 -9
- package/lib/client.js +91 -14
- package/lib/client.js.map +2 -2
- package/lib/index.js +197 -89
- package/lib/types/client/dsh-store-compat.d.ts +3 -3
- package/lib/types/client/index.d.ts +12 -2
- package/lib/types/client/locales.d.ts +5 -0
- package/lib/types/client/settings-card.d.ts +8 -2
- package/lib/types/client/settings-form.d.ts +3 -0
- package/lib/types/host/engine.d.ts +15 -11
- package/lib/types/index.d.ts +145 -11
- package/lib/types/shared/core.d.ts +14 -4
- package/package.json +9 -3
- package/src/client/dsh-store-compat.ts +3 -3
- package/src/client/index.ts +48 -12
- package/src/client/locales.ts +20 -10
- package/src/client/settings-card.tsx +44 -3
- package/src/client/settings-form.ts +8 -1
- package/src/host/engine.ts +159 -87
- package/src/index.ts +74 -27
- package/src/shared/core.ts +26 -4
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* bugs (issue #13) cannot exist by construction. Listens to the session event
|
|
7
7
|
* firehose (`session/event`), sends through the agent registry
|
|
8
8
|
* (`agent.followup`), cancels through `agent.cancel`, and reads configuration
|
|
9
|
-
*
|
|
9
|
+
* injected by the entry (`apply`'s config argument, merged with schema
|
|
10
|
+
* defaults by `resolveConfig`).
|
|
10
11
|
*
|
|
11
|
-
* All behavior is driven by the `auto-continue`
|
|
12
|
-
*
|
|
12
|
+
* All behavior is driven by the `auto-continue` entry config; every knob below
|
|
13
|
+
* is user-configurable there.
|
|
13
14
|
*/
|
|
14
15
|
import type { Context } from '@deepseek-ai/cordis';
|
|
15
16
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
@@ -40,9 +41,12 @@ export declare class AutoContinueRunner {
|
|
|
40
41
|
private readonly disposeSessionEvents;
|
|
41
42
|
private readonly disposeInboxEvents;
|
|
42
43
|
private disposed;
|
|
44
|
+
private readonly bootScannedSessions;
|
|
45
|
+
private bootScanTimer;
|
|
46
|
+
private wakeBootScan;
|
|
43
47
|
/**
|
|
44
|
-
* @param ctx - host plugin context (agents registry, session events
|
|
45
|
-
* @param getConfig - read the current resolved configuration (
|
|
48
|
+
* @param ctx - host plugin context (agents registry, session events).
|
|
49
|
+
* @param getConfig - read the current resolved configuration (entry config).
|
|
46
50
|
*/
|
|
47
51
|
constructor(ctx: Context, getConfig: () => AutoContinueConfig);
|
|
48
52
|
private log;
|
|
@@ -69,6 +73,9 @@ export declare class AutoContinueRunner {
|
|
|
69
73
|
* 然后交给回合状态机。
|
|
70
74
|
*/
|
|
71
75
|
private onHostEvent;
|
|
76
|
+
private tracksOutput;
|
|
77
|
+
/** Treat unknown block kinds conservatively: only reasoning and blank text are silent. */
|
|
78
|
+
private hasVisibleContent;
|
|
72
79
|
/** 从 assistant/message 事件提取纯文本。 */
|
|
73
80
|
private assistantText;
|
|
74
81
|
private assistantChunkText;
|
|
@@ -102,6 +109,8 @@ export declare class AutoContinueRunner {
|
|
|
102
109
|
/** 本会话当前生效的冷却间隔(自适应退避)。 */
|
|
103
110
|
private cooldownFor;
|
|
104
111
|
private schedule;
|
|
112
|
+
/** 按调度原因选择续跑模板: loop 重启、无输出回合、max-tokens, 其余用通用继续文本。 */
|
|
113
|
+
private templateFor;
|
|
105
114
|
private cancelPending;
|
|
106
115
|
private fire;
|
|
107
116
|
/**
|
|
@@ -115,12 +124,7 @@ export declare class AutoContinueRunner {
|
|
|
115
124
|
/** 上一步工具调用的护栏状态(实时路径, 由 mux 帧维护)。 */
|
|
116
125
|
private currentGuard;
|
|
117
126
|
private bootScanLoop;
|
|
118
|
-
/**
|
|
119
|
-
private scanLoop;
|
|
120
|
-
/**
|
|
121
|
-
* 扫描最近中断过的会话: 最后回合以非人为原因结束, 且其后没有新回合或用户消息。
|
|
122
|
-
* @returns 是否成功完成一次扫描(宿主就绪)。
|
|
123
|
-
*/
|
|
127
|
+
/** Inspect newly available sessions; process each settled startup history once. */
|
|
124
128
|
private scanInterrupted;
|
|
125
129
|
/** 从历史事件恢复上一步工具调用状态(扫描路径的幂等护栏)。 */
|
|
126
130
|
private applyGuardFromEvents;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host half of the auto-continue plugin.
|
|
3
3
|
*
|
|
4
|
-
* -
|
|
5
|
-
*
|
|
4
|
+
* - Configuration is this entry's own Loader config: `apply(ctx, config)`
|
|
5
|
+
* injects it into the engine, where `resolveConfig` merges it with the
|
|
6
|
+
* schema defaults (the browser half's settings card writes the same values).
|
|
6
7
|
* - Runs the single-instance auto-continue engine: listens to the session
|
|
7
8
|
* event firehose, sends via `agent.followup`, cancels via `agent.cancel`.
|
|
8
9
|
* - Serves a status bridge the browser half subscribes to: notifications and
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
*/
|
|
12
13
|
import type { Context } from '@deepseek-ai/cordis';
|
|
13
14
|
import z from '@deepseek-ai/schemastery';
|
|
15
|
+
import { type AutoContinueSettings } from './shared/core.ts';
|
|
14
16
|
/** Settings namespace of the auto-continue plugin (lowercase kebab-case). */
|
|
15
17
|
export declare const AUTO_CONTINUE_NS = "auto-continue";
|
|
16
18
|
/** Wire schema; blank localized text fields tell resolveConfig() to select the active locale's defaults. */
|
|
@@ -21,6 +23,10 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
21
23
|
continueText: z<string, string>;
|
|
22
24
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
23
25
|
continueTextMaxTokens: z<string, string>;
|
|
26
|
+
/** Resume observed model activity that completes without visible output. */
|
|
27
|
+
resumeSilentTurns: z<boolean, boolean>;
|
|
28
|
+
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
29
|
+
continueTextSilent: z<string, string>;
|
|
24
30
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
25
31
|
guardTools: z<boolean, boolean>;
|
|
26
32
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -33,11 +39,11 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
33
39
|
cooldownMs: z<number, number>;
|
|
34
40
|
/** Max consecutive auto-continues per session before stopping. */
|
|
35
41
|
maxConsecutive: z<number, number>;
|
|
36
|
-
/**
|
|
42
|
+
/** Recover delayed interrupted sessions during the host startup window. */
|
|
37
43
|
scanOnBoot: z<boolean, boolean>;
|
|
38
|
-
/** Max
|
|
44
|
+
/** Max eligible recoveries per scan pass (most recently active first). */
|
|
39
45
|
scanLimit: z<number, number>;
|
|
40
|
-
/**
|
|
46
|
+
/** Interruption freshness and duration of startup polling (ms). */
|
|
41
47
|
freshMs: z<number, number>;
|
|
42
48
|
/** Log `[auto-continue]` lines to the browser console. */
|
|
43
49
|
verbose: z<boolean, boolean>;
|
|
@@ -74,6 +80,10 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
74
80
|
continueText: z<string, string>;
|
|
75
81
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
76
82
|
continueTextMaxTokens: z<string, string>;
|
|
83
|
+
/** Resume observed model activity that completes without visible output. */
|
|
84
|
+
resumeSilentTurns: z<boolean, boolean>;
|
|
85
|
+
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
86
|
+
continueTextSilent: z<string, string>;
|
|
77
87
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
78
88
|
guardTools: z<boolean, boolean>;
|
|
79
89
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -86,11 +96,11 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
86
96
|
cooldownMs: z<number, number>;
|
|
87
97
|
/** Max consecutive auto-continues per session before stopping. */
|
|
88
98
|
maxConsecutive: z<number, number>;
|
|
89
|
-
/**
|
|
99
|
+
/** Recover delayed interrupted sessions during the host startup window. */
|
|
90
100
|
scanOnBoot: z<boolean, boolean>;
|
|
91
|
-
/** Max
|
|
101
|
+
/** Max eligible recoveries per scan pass (most recently active first). */
|
|
92
102
|
scanLimit: z<number, number>;
|
|
93
|
-
/**
|
|
103
|
+
/** Interruption freshness and duration of startup polling (ms). */
|
|
94
104
|
freshMs: z<number, number>;
|
|
95
105
|
/** Log `[auto-continue]` lines to the browser console. */
|
|
96
106
|
verbose: z<boolean, boolean>;
|
|
@@ -121,9 +131,133 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
121
131
|
/** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
|
|
122
132
|
loopText: z<string, string>;
|
|
123
133
|
}>>;
|
|
134
|
+
/** Loader config is a live reference on DSH 0.1.7, and a plain object on older hosts. */
|
|
135
|
+
export type AutoContinueEntryConfig = AutoContinueSettings | {
|
|
136
|
+
get(): AutoContinueSettings | undefined;
|
|
137
|
+
};
|
|
138
|
+
export declare const Config: z<Schemastery.ObjectS<{
|
|
139
|
+
/** Active browser/UI locale mirrored by the client. */
|
|
140
|
+
locale: z<string, string>;
|
|
141
|
+
/** Text automatically sent after an interruption. */
|
|
142
|
+
continueText: z<string, string>;
|
|
143
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
144
|
+
continueTextMaxTokens: z<string, string>;
|
|
145
|
+
/** Resume observed model activity that completes without visible output. */
|
|
146
|
+
resumeSilentTurns: z<boolean, boolean>;
|
|
147
|
+
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
148
|
+
continueTextSilent: z<string, string>;
|
|
149
|
+
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
150
|
+
guardTools: z<boolean, boolean>;
|
|
151
|
+
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
152
|
+
guardPendingText: z<string, string>;
|
|
153
|
+
/** Guard text appended when the last tool call completed successfully (don't rerun it). */
|
|
154
|
+
guardDoneText: z<string, string>;
|
|
155
|
+
/** Grace period after an interruption before auto-sending (ms). */
|
|
156
|
+
graceMs: z<number, number>;
|
|
157
|
+
/** Minimum interval between two auto-continues per session (ms). */
|
|
158
|
+
cooldownMs: z<number, number>;
|
|
159
|
+
/** Max consecutive auto-continues per session before stopping. */
|
|
160
|
+
maxConsecutive: z<number, number>;
|
|
161
|
+
/** Recover delayed interrupted sessions during the host startup window. */
|
|
162
|
+
scanOnBoot: z<boolean, boolean>;
|
|
163
|
+
/** Max eligible recoveries per scan pass (most recently active first). */
|
|
164
|
+
scanLimit: z<number, number>;
|
|
165
|
+
/** Interruption freshness and duration of startup polling (ms). */
|
|
166
|
+
freshMs: z<number, number>;
|
|
167
|
+
/** Log `[auto-continue]` lines to the browser console. */
|
|
168
|
+
verbose: z<boolean, boolean>;
|
|
169
|
+
/** Classify failures: auto-continue transient errors only; permanent ones are skipped and notified. */
|
|
170
|
+
classify: z<boolean, boolean>;
|
|
171
|
+
/** Provider-specific message/code/status fragments that explicitly count as retryable, one literal per line. */
|
|
172
|
+
retryableErrorPatterns: z<string, string>;
|
|
173
|
+
/** Cooldown multiplier per consecutive failure (adaptive backoff). */
|
|
174
|
+
backoffFactor: z<number, number>;
|
|
175
|
+
/** Cap on the effective backoff interval (ms). */
|
|
176
|
+
backoffMaxMs: z<number, number>;
|
|
177
|
+
/** Show browser notifications for auto-continue events. */
|
|
178
|
+
notify: z<boolean, boolean>;
|
|
179
|
+
/** Globally pause auto-continue: no live or scan send. */
|
|
180
|
+
paused: z<boolean, boolean>;
|
|
181
|
+
/** Loop guard: detect a running turn spinning in place and restart it. */
|
|
182
|
+
loopGuard: z<boolean, boolean>;
|
|
183
|
+
/** A model message shorter than this many chars counts as a short sentence (loop signal). */
|
|
184
|
+
loopShortChars: z<number, number>;
|
|
185
|
+
/** Consecutive short sentences within this window (ms) with no tool call in between trip the loop guard. */
|
|
186
|
+
loopWindowMs: z<number, number>;
|
|
187
|
+
/** Consecutive short sentences trip the loop guard. */
|
|
188
|
+
loopShortCount: z<number, number>;
|
|
189
|
+
/** Consecutive identical assistant messages trip the loop guard (strongest signal; also used for streamed intra-message repetition). */
|
|
190
|
+
loopRepeatText: z<number, number>;
|
|
191
|
+
/** Consecutive identical tool calls with identical arguments AND results trip the loop guard. */
|
|
192
|
+
loopToolRepeat: z<number, number>;
|
|
193
|
+
/** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
|
|
194
|
+
loopText: z<string, string>;
|
|
195
|
+
}>, Schemastery.ObjectT<{
|
|
196
|
+
/** Active browser/UI locale mirrored by the client. */
|
|
197
|
+
locale: z<string, string>;
|
|
198
|
+
/** Text automatically sent after an interruption. */
|
|
199
|
+
continueText: z<string, string>;
|
|
200
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
201
|
+
continueTextMaxTokens: z<string, string>;
|
|
202
|
+
/** Resume observed model activity that completes without visible output. */
|
|
203
|
+
resumeSilentTurns: z<boolean, boolean>;
|
|
204
|
+
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
205
|
+
continueTextSilent: z<string, string>;
|
|
206
|
+
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
207
|
+
guardTools: z<boolean, boolean>;
|
|
208
|
+
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
209
|
+
guardPendingText: z<string, string>;
|
|
210
|
+
/** Guard text appended when the last tool call completed successfully (don't rerun it). */
|
|
211
|
+
guardDoneText: z<string, string>;
|
|
212
|
+
/** Grace period after an interruption before auto-sending (ms). */
|
|
213
|
+
graceMs: z<number, number>;
|
|
214
|
+
/** Minimum interval between two auto-continues per session (ms). */
|
|
215
|
+
cooldownMs: z<number, number>;
|
|
216
|
+
/** Max consecutive auto-continues per session before stopping. */
|
|
217
|
+
maxConsecutive: z<number, number>;
|
|
218
|
+
/** Recover delayed interrupted sessions during the host startup window. */
|
|
219
|
+
scanOnBoot: z<boolean, boolean>;
|
|
220
|
+
/** Max eligible recoveries per scan pass (most recently active first). */
|
|
221
|
+
scanLimit: z<number, number>;
|
|
222
|
+
/** Interruption freshness and duration of startup polling (ms). */
|
|
223
|
+
freshMs: z<number, number>;
|
|
224
|
+
/** Log `[auto-continue]` lines to the browser console. */
|
|
225
|
+
verbose: z<boolean, boolean>;
|
|
226
|
+
/** Classify failures: auto-continue transient errors only; permanent ones are skipped and notified. */
|
|
227
|
+
classify: z<boolean, boolean>;
|
|
228
|
+
/** Provider-specific message/code/status fragments that explicitly count as retryable, one literal per line. */
|
|
229
|
+
retryableErrorPatterns: z<string, string>;
|
|
230
|
+
/** Cooldown multiplier per consecutive failure (adaptive backoff). */
|
|
231
|
+
backoffFactor: z<number, number>;
|
|
232
|
+
/** Cap on the effective backoff interval (ms). */
|
|
233
|
+
backoffMaxMs: z<number, number>;
|
|
234
|
+
/** Show browser notifications for auto-continue events. */
|
|
235
|
+
notify: z<boolean, boolean>;
|
|
236
|
+
/** Globally pause auto-continue: no live or scan send. */
|
|
237
|
+
paused: z<boolean, boolean>;
|
|
238
|
+
/** Loop guard: detect a running turn spinning in place and restart it. */
|
|
239
|
+
loopGuard: z<boolean, boolean>;
|
|
240
|
+
/** A model message shorter than this many chars counts as a short sentence (loop signal). */
|
|
241
|
+
loopShortChars: z<number, number>;
|
|
242
|
+
/** Consecutive short sentences within this window (ms) with no tool call in between trip the loop guard. */
|
|
243
|
+
loopWindowMs: z<number, number>;
|
|
244
|
+
/** Consecutive short sentences trip the loop guard. */
|
|
245
|
+
loopShortCount: z<number, number>;
|
|
246
|
+
/** Consecutive identical assistant messages trip the loop guard (strongest signal; also used for streamed intra-message repetition). */
|
|
247
|
+
loopRepeatText: z<number, number>;
|
|
248
|
+
/** Consecutive identical tool calls with identical arguments AND results trip the loop guard. */
|
|
249
|
+
loopToolRepeat: z<number, number>;
|
|
250
|
+
/** Text sent after the loop guard cancels and restarts a turn (supports {tool}). */
|
|
251
|
+
loopText: z<string, string>;
|
|
252
|
+
}>> | z<AutoContinueSettings, AutoContinueEntryConfig>;
|
|
124
253
|
/**
|
|
125
|
-
* Plugin body:
|
|
126
|
-
*
|
|
254
|
+
* Plugin body: start the single-instance engine and serve the status bridge.
|
|
255
|
+
*
|
|
256
|
+
* Configuration comes from this entry's own Loader config (merged with the
|
|
257
|
+
* schema defaults by `resolveConfig`); the current harness exposes entry
|
|
258
|
+
* config through the settings service instead of the legacy `register`/`get`
|
|
259
|
+
* namespace API this plugin was originally written against.
|
|
127
260
|
* @param ctx - host plugin context.
|
|
261
|
+
* @param config - this entry's config (may be partial / absent → defaults).
|
|
128
262
|
*/
|
|
129
|
-
export declare function apply(ctx: Context): void;
|
|
263
|
+
export declare function apply(ctx: Context, config?: AutoContinueEntryConfig): void;
|
|
@@ -12,6 +12,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
12
12
|
readonly zh: {
|
|
13
13
|
readonly continueText: "继续";
|
|
14
14
|
readonly continueTextMaxTokens: "继续";
|
|
15
|
+
readonly continueTextSilent: "继续。你上一轮只输出了内部推理, 既没有回复也没有调用工具, 用户什么都没看到。每一轮都要以工具调用或可见回复结束。";
|
|
15
16
|
readonly guardPendingText: "(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)";
|
|
16
17
|
readonly guardDoneText: "(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)";
|
|
17
18
|
readonly loopText: "(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)";
|
|
@@ -19,6 +20,7 @@ export declare const LOCALIZED_TEXT_DEFAULTS: {
|
|
|
19
20
|
readonly en: {
|
|
20
21
|
readonly continueText: "Continue";
|
|
21
22
|
readonly continueTextMaxTokens: "Continue";
|
|
23
|
+
readonly continueTextSilent: "Continue. Your previous turn ended with internal reasoning only, with no message and no tool call, so nothing reached the user. Always finish a turn with a tool call or a visible answer.";
|
|
22
24
|
readonly guardPendingText: "(The previous tool \"{tool}\" may not have completed. Check its state before continuing and do not run it again.)";
|
|
23
25
|
readonly guardDoneText: "(The previous tool \"{tool}\" completed successfully. Result: {result}; do not run it again. Continue from there.)";
|
|
24
26
|
readonly loopText: "(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)";
|
|
@@ -32,6 +34,10 @@ export interface AutoContinueSettings {
|
|
|
32
34
|
continueText?: string;
|
|
33
35
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
34
36
|
continueTextMaxTokens?: string;
|
|
37
|
+
/** Resume observed model activity that completes without visible output. */
|
|
38
|
+
resumeSilentTurns?: boolean;
|
|
39
|
+
/** Text sent to resume a silent turn (same placeholders as `continueText`). */
|
|
40
|
+
continueTextSilent?: string;
|
|
35
41
|
/** Idempotency guard: inspect the last tool call before resuming and steer the model. */
|
|
36
42
|
guardTools?: boolean;
|
|
37
43
|
/** Guard text appended when the last tool call has no confirmed result (it may have partially executed). */
|
|
@@ -44,11 +50,11 @@ export interface AutoContinueSettings {
|
|
|
44
50
|
cooldownMs?: number;
|
|
45
51
|
/** Max consecutive auto-continues per session before stopping. */
|
|
46
52
|
maxConsecutive?: number;
|
|
47
|
-
/**
|
|
53
|
+
/** Recover delayed interrupted sessions during the host startup window. */
|
|
48
54
|
scanOnBoot?: boolean;
|
|
49
|
-
/** Max
|
|
55
|
+
/** Max eligible recoveries per scan pass (most recently active first). */
|
|
50
56
|
scanLimit?: number;
|
|
51
|
-
/**
|
|
57
|
+
/** Interruption freshness and duration of startup polling (ms). */
|
|
52
58
|
freshMs?: number;
|
|
53
59
|
/** Log `[auto-continue]` lines to the browser console. */
|
|
54
60
|
verbose?: boolean;
|
|
@@ -88,7 +94,7 @@ export declare function resolveConfig(section: AutoContinueSettings | undefined)
|
|
|
88
94
|
/**
|
|
89
95
|
* 视为「非人为中断」的回合结束原因, 用于启动/重连扫描。
|
|
90
96
|
* - `interrupted` 只由崩溃修复在宿主重载时写入(loop 永不实时发出), 因此仅在扫描路径处理;
|
|
91
|
-
* - 实时事件路径只对 `error` / `max-tokens` 自动续跑;
|
|
97
|
+
* - 实时事件路径只对 `error` / `max-tokens` 自动续跑; 另外续跑没有可见输出的 `completed` / `no-visible-output` 回合(不属于本类型);
|
|
92
98
|
* - `aborted`(用户停止)与 `blocked`(策略拒绝)永不自动继续。
|
|
93
99
|
*/
|
|
94
100
|
type NonHumanReason = 'error' | 'interrupted' | 'max-tokens';
|
|
@@ -289,6 +295,10 @@ export interface SessionState {
|
|
|
289
295
|
lastTurn: number | undefined;
|
|
290
296
|
/** 我们最近一次自动发送的时间戳; 0 = 没有待确认的恢复。 */
|
|
291
297
|
pendingRecoveryAt: number;
|
|
298
|
+
/** unknown: no observed start; empty: no model activity; silent: activity without visible output. */
|
|
299
|
+
turnOutput: 'unknown' | 'empty' | 'silent' | 'visible';
|
|
300
|
+
outputTurn: number | undefined;
|
|
301
|
+
outputStartSeq: number;
|
|
292
302
|
/** 当前连续短句数(loop guard 信号 1: 空转)。 */
|
|
293
303
|
shortRun: number;
|
|
294
304
|
/** 最后一条短句的时间(时间窗判定用)。 */
|
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.11.
|
|
4
|
+
"version": "0.11.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"build": "node build.mjs && tsc -p tsconfig.build.json",
|
|
47
47
|
"watch": "node build.mjs --watch",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"test": "node tests/
|
|
49
|
+
"test:runtime": "node tests/settings-host-live.mjs",
|
|
50
|
+
"test": "node tests/scan-on-boot.mjs && node tests/silent-turn-boundaries.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/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/prepare-github-package.mjs",
|
|
50
51
|
"prepack": "npm run build"
|
|
51
52
|
},
|
|
52
53
|
"keywords": [
|
|
@@ -80,8 +81,13 @@
|
|
|
80
81
|
"license": "MIT",
|
|
81
82
|
"peerDependencies": {
|
|
82
83
|
"react": "^18.2.0",
|
|
83
|
-
"@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
|
|
84
|
+
"@deepseek-ai/dsh-settings": "^0.1.0-rc.7 || ^0.1.7-0",
|
|
84
85
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
85
86
|
"@deepseek-ai/cordis": "^4.0.1"
|
|
87
|
+
},
|
|
88
|
+
"peerDependenciesMeta": {
|
|
89
|
+
"@deepseek-ai/dsh-settings": {
|
|
90
|
+
"optional": true
|
|
91
|
+
}
|
|
86
92
|
}
|
|
87
93
|
}
|
|
@@ -27,12 +27,12 @@ export interface SettingsScopeSnapshot<T> {
|
|
|
27
27
|
mode: 'host' | 'memory';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/** Stable subset shared by
|
|
30
|
+
/** Stable subset shared by settings scopes and DSH 0.1.7 configuration forms. */
|
|
31
31
|
export interface SettingsScope<T> {
|
|
32
32
|
getSnapshot(): SettingsScopeSnapshot<T>;
|
|
33
33
|
subscribe(listener: () => void): () => void;
|
|
34
|
-
set(field: string, value: unknown): Promise<void>;
|
|
35
|
-
unset(field: string): Promise<void>;
|
|
34
|
+
set(field: string, value: unknown): Promise<void | boolean>;
|
|
35
|
+
unset(field: string): Promise<void | boolean>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
interface SnapshotStoreModule {
|
package/src/client/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Since 0.8.0 the auto-continue ENGINE runs inside the host process (single
|
|
5
5
|
* instance — see src/host/engine.ts), so this half only:
|
|
6
|
-
* - registers the `auto-continue` settings card
|
|
6
|
+
* - registers the `auto-continue` settings card in the available plugin UI,
|
|
7
7
|
* - subscribes to the host status bridge (SSE) and shows browser
|
|
8
8
|
* notifications with action buttons (Resume now / Pause 1h) via the bridge
|
|
9
9
|
* action endpoint,
|
|
@@ -21,8 +21,10 @@ import { en, zh, type SettingsCardKey } from './locales.ts';
|
|
|
21
21
|
import {
|
|
22
22
|
AutoContinueSettingsCard,
|
|
23
23
|
AutoContinueSettingsCardController,
|
|
24
|
+
AutoContinueSettingsPage,
|
|
24
25
|
} from './settings-card.tsx';
|
|
25
26
|
import { startBridge } from './bridge.ts';
|
|
27
|
+
import type { SettingsScope } from './dsh-store-compat.ts';
|
|
26
28
|
|
|
27
29
|
/** Dictionary namespace owned by this plugin. */
|
|
28
30
|
const NS = 'auto-continue';
|
|
@@ -31,14 +33,27 @@ const NS = 'auto-continue';
|
|
|
31
33
|
const SETTINGS_NS = 'auto-continue';
|
|
32
34
|
|
|
33
35
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
36
|
+
interface SlotMap {
|
|
37
|
+
/** DSH 0.1.7's bundle configuration seat; only the owner props we consume. */
|
|
38
|
+
'plugins.bundle.config': {
|
|
39
|
+
kind: 'keyed';
|
|
40
|
+
scope: 'root';
|
|
41
|
+
owner: { readonly view: 'summary' | 'page' };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
34
44
|
interface LocaleNamespaceMap {
|
|
35
45
|
/** auto-continue settings-card copy. */
|
|
36
46
|
'auto-continue': SettingsCardKey;
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
/**
|
|
41
|
-
|
|
50
|
+
/** Shared subset of DSH 0.1.7's provider, without a new runtime dependency. */
|
|
51
|
+
type ConfigFormsContext = ClientContext & {
|
|
52
|
+
configForms: { get<T>(entryId: string): SettingsScope<T> };
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Settings services are injected separately: neither exists in every DSH cohort. */
|
|
56
|
+
export const inject = ['slots', 'locale'];
|
|
42
57
|
|
|
43
58
|
// 浏览器侧辅助(设置卡片用): 桥状态读取与暂停解除。
|
|
44
59
|
export {
|
|
@@ -55,8 +70,22 @@ export {
|
|
|
55
70
|
*/
|
|
56
71
|
export function apply(ctx: ClientContext): void {
|
|
57
72
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'auto-continue: dictionaries');
|
|
73
|
+
ctx.effect(() => startBridge(), 'auto-continue: host bridge');
|
|
74
|
+
|
|
75
|
+
// Cordis waits for ALL top-level dependencies. Requiring settingsScope here
|
|
76
|
+
// would leave DSH 0.1.7 pending forever; requiring configForms breaks older
|
|
77
|
+
// hosts. Separate child fibers also follow late providers and their teardown.
|
|
78
|
+
ctx.inject(['settingsScope'], (settingsCtx) => {
|
|
79
|
+
mountSettings(settingsCtx, settingsCtx.settingsScope.bind<AutoContinueSettings>({ namespace: SETTINGS_NS }));
|
|
80
|
+
});
|
|
81
|
+
ctx.inject(['configForms'], (settingsCtx) => {
|
|
82
|
+
const forms = (settingsCtx as ConfigFormsContext).configForms;
|
|
83
|
+
mountSettings(settingsCtx, forms.get<AutoContinueSettings>(SETTINGS_NS));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
58
86
|
|
|
59
|
-
|
|
87
|
+
/** Attach this consumer's subscriptions and card to the provider's lifecycle. */
|
|
88
|
+
function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSettings>): void {
|
|
60
89
|
/**
|
|
61
90
|
* Mirror the browser locale into the host config, with a hard per-page budget.
|
|
62
91
|
*
|
|
@@ -105,15 +134,11 @@ export function apply(ctx: ClientContext): void {
|
|
|
105
134
|
ctx.on('locale/change', syncLocale);
|
|
106
135
|
syncLocale();
|
|
107
136
|
|
|
108
|
-
// 状态桥: 订阅 host 的通知与运行时状态, 弹浏览器通知并驱动卡片面板。
|
|
109
|
-
ctx.effect(() => startBridge(), 'auto-continue: host bridge');
|
|
110
|
-
|
|
111
|
-
// Plugin configuration card: one staged form over the `auto-continue`
|
|
112
|
-
// settings namespace, contributed to the plugin-configuration section
|
|
113
|
-
// (Settings → Plugins). Since DSH 0.1.0-rc.7 `settings.plugin.item` is a
|
|
114
|
-
// keyed slot dispatched by the settings namespace it edits, so the entry
|
|
115
|
-
// registers with `key` (the namespace), like the official cards.
|
|
116
137
|
const controller = new AutoContinueSettingsCardController(scope);
|
|
138
|
+
ctx.effect(() => () => controller.dispose(), 'auto-continue: settings form');
|
|
139
|
+
|
|
140
|
+
// Slot injection waits for the matching UI declaration. Keep the old
|
|
141
|
+
// settings card and the new bundle page independent of service migration.
|
|
117
142
|
ctx.slots.inject('settings.plugin.item', () =>
|
|
118
143
|
ctx.slots.register(
|
|
119
144
|
{
|
|
@@ -125,4 +150,15 @@ export function apply(ctx: ClientContext): void {
|
|
|
125
150
|
AutoContinueSettingsCard,
|
|
126
151
|
),
|
|
127
152
|
);
|
|
153
|
+
ctx.slots.inject('plugins.bundle.config', () =>
|
|
154
|
+
ctx.slots.register(
|
|
155
|
+
{
|
|
156
|
+
name: 'plugins.bundle.config',
|
|
157
|
+
key: 'dsh-client-auto-continue',
|
|
158
|
+
locale: NS,
|
|
159
|
+
inject: () => controller.inject(),
|
|
160
|
+
},
|
|
161
|
+
AutoContinueSettingsPage,
|
|
162
|
+
),
|
|
163
|
+
);
|
|
128
164
|
}
|
package/src/client/locales.ts
CHANGED
|
@@ -32,6 +32,11 @@ export const zh = {
|
|
|
32
32
|
'field.continueTextMaxTokens': '超限时的继续文本',
|
|
33
33
|
'field.continueTextMaxTokensHint': '达到输出 token 上限时自动发送的文本, 支持与继续文本相同的占位符。',
|
|
34
34
|
'default.continueTextMaxTokens': LOCALIZED_TEXT_DEFAULTS.zh.continueTextMaxTokens,
|
|
35
|
+
'field.resumeSilentTurns': '续跑无输出回合',
|
|
36
|
+
'field.resumeSilentTurnsHint': '已观察到模型活动但没有可见输出时续跑;不把空回合、图片或扩展内容误判为静默,冷却与连续上限照常生效。',
|
|
37
|
+
'field.continueTextSilent': '无输出回合的继续文本',
|
|
38
|
+
'field.continueTextSilentHint': '回合只输出推理就结束时自动发送的文本, 支持与继续文本相同的占位符。',
|
|
39
|
+
'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.zh.continueTextSilent,
|
|
35
40
|
'field.guardTools': '幂等护栏',
|
|
36
41
|
'field.guardToolsHint': '续跑前检查上一步工具调用: 结果未确认时提示先确认状态, 已成功时提示不要重复执行, 避免重复 commit/调 API。',
|
|
37
42
|
'field.guardPendingText': '结果未确认时的护栏文本',
|
|
@@ -45,13 +50,13 @@ export const zh = {
|
|
|
45
50
|
'field.cooldownMs': '冷却时间 (ms)',
|
|
46
51
|
'field.cooldownMsHint': '同一会话两次自动「继续」的最小间隔, 失败尝试也计入。',
|
|
47
52
|
'field.maxConsecutive': '最大连续次数',
|
|
48
|
-
'field.maxConsecutiveHint': '
|
|
49
|
-
'field.scanOnBoot': '
|
|
50
|
-
'field.scanOnBootHint': '
|
|
53
|
+
'field.maxConsecutiveHint': '同一会话连续自动「继续」的上限;直到用户介入或成功回合产生已确认的可见输出才清零。',
|
|
54
|
+
'field.scanOnBoot': '启动恢复扫描',
|
|
55
|
+
'field.scanOnBootHint': '宿主启动后在扫描时间窗内等待延迟加载的中断会话,每个已就绪会话只检查一次。',
|
|
51
56
|
'field.scanLimit': '扫描会话数',
|
|
52
|
-
'field.scanLimitHint': '
|
|
57
|
+
'field.scanLimitHint': '每次扫描最多恢复多少个符合条件的会话,优先最近活动的会话。',
|
|
53
58
|
'field.freshMs': '扫描时间窗 (ms)',
|
|
54
|
-
'field.freshMsHint': '
|
|
59
|
+
'field.freshMsHint': '只处理该时间窗内的中断;启动轮询也会在这段时间后结束。',
|
|
55
60
|
'field.verbose': '详细日志',
|
|
56
61
|
'field.verboseHint': '在浏览器控制台输出 [auto-continue] 日志。',
|
|
57
62
|
'field.classify': '错误分类',
|
|
@@ -141,6 +146,11 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
141
146
|
'field.continueTextMaxTokens': 'Continue text (max tokens)',
|
|
142
147
|
'field.continueTextMaxTokensHint': 'Text sent when the output token ceiling is reached; same placeholders as the continue text.',
|
|
143
148
|
'default.continueTextMaxTokens': LOCALIZED_TEXT_DEFAULTS.en.continueTextMaxTokens,
|
|
149
|
+
'field.resumeSilentTurns': 'Resume silent turns',
|
|
150
|
+
'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.',
|
|
151
|
+
'field.continueTextSilent': 'Continue text (silent turn)',
|
|
152
|
+
'field.continueTextSilentHint': 'Text sent when a turn ends with reasoning only; same placeholders as the continue text.',
|
|
153
|
+
'default.continueTextSilent': LOCALIZED_TEXT_DEFAULTS.en.continueTextSilent,
|
|
144
154
|
'field.guardTools': 'Idempotency guard',
|
|
145
155
|
'field.guardToolsHint': 'Before resuming, inspect the last tool call: if its result is unconfirmed, tell the model to check state first; if it succeeded, tell it not to rerun — avoids duplicate commits / API calls.',
|
|
146
156
|
'field.guardPendingText': 'Guard text (unconfirmed result)',
|
|
@@ -154,13 +164,13 @@ export const en: Record<SettingsCardKey, string> = {
|
|
|
154
164
|
'field.cooldownMs': 'Cooldown (ms)',
|
|
155
165
|
'field.cooldownMsHint': 'Minimum interval between auto-continues per session; failed attempts count too.',
|
|
156
166
|
'field.maxConsecutive': 'Max consecutive',
|
|
157
|
-
'field.maxConsecutiveHint': 'Max consecutive auto-continues per session;
|
|
158
|
-
'field.scanOnBoot': 'Scan on
|
|
159
|
-
'field.scanOnBootHint': '
|
|
167
|
+
'field.maxConsecutiveHint': 'Max consecutive auto-continues per session; resets only after user intervention or a completed turn with confirmed visible output.',
|
|
168
|
+
'field.scanOnBoot': 'Scan on host startup',
|
|
169
|
+
'field.scanOnBootHint': 'Wait for delayed interrupted sessions during the startup scan window; inspect each settled session once.',
|
|
160
170
|
'field.scanLimit': 'Scan limit',
|
|
161
|
-
'field.scanLimitHint': '
|
|
171
|
+
'field.scanLimitHint': 'Maximum eligible sessions to recover per pass, most recently active first.',
|
|
162
172
|
'field.freshMs': 'Scan window (ms)',
|
|
163
|
-
'field.freshMsHint': 'Only interruptions inside this window are considered.',
|
|
173
|
+
'field.freshMsHint': 'Only interruptions inside this window are considered; startup polling also ends after this duration.',
|
|
164
174
|
'field.verbose': 'Verbose logs',
|
|
165
175
|
'field.verboseHint': 'Log [auto-continue] lines to the browser console.',
|
|
166
176
|
'field.classify': 'Classify errors',
|