dsh-client-auto-continue 0.4.4 → 0.5.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/README.md +12 -5
- package/README.zh.md +12 -5
- package/lib/client.js +455 -22
- package/lib/client.js.map +2 -2
- package/lib/index.js +5 -1
- package/lib/types/client/engine.d.ts +77 -3
- package/lib/types/client/index.d.ts +1 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/client/settings-card.d.ts +3 -1
- package/lib/types/index.d.ts +8 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5,6 +5,8 @@ var AUTO_CONTINUE_NS = "auto-continue";
|
|
|
5
5
|
var AutoContinueSchema = z.object({
|
|
6
6
|
/** Text automatically sent after an interruption. */
|
|
7
7
|
continueText: z.string().default("继续"),
|
|
8
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
9
|
+
continueTextMaxTokens: z.string().default("继续"),
|
|
8
10
|
/** Grace period after an interruption before auto-sending (ms). */
|
|
9
11
|
graceMs: z.natural().default(3e3),
|
|
10
12
|
/** Minimum interval between two auto-continues per session (ms). */
|
|
@@ -30,7 +32,9 @@ var AutoContinueSchema = z.object({
|
|
|
30
32
|
/** Cap on the effective backoff interval (ms). */
|
|
31
33
|
backoffMaxMs: z.natural().default(3e5),
|
|
32
34
|
/** Show browser notifications for auto-continue events. */
|
|
33
|
-
notify: z.boolean().default(false)
|
|
35
|
+
notify: z.boolean().default(false),
|
|
36
|
+
/** Globally pause auto-continue: no live or scan send. */
|
|
37
|
+
paused: z.boolean().default(false)
|
|
34
38
|
});
|
|
35
39
|
function apply(ctx) {
|
|
36
40
|
ctx.inject(["settings"], (settingsCtx) => {
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
* All behavior is driven by the `auto-continue` settings namespace (see the
|
|
11
11
|
* plugin's settings card); every knob below is user-configurable there.
|
|
12
12
|
*/
|
|
13
|
-
import type { IApiClient } from '@deepseek-ai/dsh-client-connection/client';
|
|
13
|
+
import type { IApiClient, SessionId } from '@deepseek-ai/dsh-client-connection/client';
|
|
14
14
|
/** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
|
|
15
15
|
export interface AutoContinueSettings {
|
|
16
16
|
/** Text automatically sent after an interruption. */
|
|
17
17
|
continueText?: string;
|
|
18
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
19
|
+
continueTextMaxTokens?: string;
|
|
18
20
|
/** Grace period after an interruption before auto-sending (ms). */
|
|
19
21
|
graceMs?: number;
|
|
20
22
|
/** Minimum interval between two auto-continues per session (ms). */
|
|
@@ -41,6 +43,8 @@ export interface AutoContinueSettings {
|
|
|
41
43
|
backoffMaxMs?: number;
|
|
42
44
|
/** Show browser notifications for auto-continue events. */
|
|
43
45
|
notify?: boolean;
|
|
46
|
+
/** Globally pause auto-continue: no live or scan send, queued pending sends cancelled. */
|
|
47
|
+
paused?: boolean;
|
|
44
48
|
}
|
|
45
49
|
/** Fully resolved configuration (built-in defaults + user overrides). */
|
|
46
50
|
export type AutoContinueConfig = Required<AutoContinueSettings>;
|
|
@@ -69,10 +73,69 @@ export declare function isTransientFailure(failure: FailureFacts): boolean;
|
|
|
69
73
|
* 序列化失败(如 Windows 下 abort 的 DOMException reason)绝不能自动续跑。
|
|
70
74
|
*/
|
|
71
75
|
export declare function isTransientAgentError(message: string): boolean;
|
|
72
|
-
/**
|
|
73
|
-
export
|
|
76
|
+
/** 通知上的一个操作按钮(action 标识 + 显示文案)。 */
|
|
77
|
+
export interface NotifyAction {
|
|
78
|
+
/** 稳定动作标识, 点击时经 onAction 回调传出。 */
|
|
79
|
+
action: string;
|
|
80
|
+
/** 按钮显示文案。 */
|
|
81
|
+
title: string;
|
|
82
|
+
}
|
|
83
|
+
/** 通知的可选行为: 操作按钮列表与点击回调。 */
|
|
84
|
+
export interface NotifyOptions {
|
|
85
|
+
actions?: NotifyAction[];
|
|
86
|
+
onAction?: (action: string) => void;
|
|
87
|
+
}
|
|
88
|
+
/** 模板填充所需的上下文(全部可选, 缺失的占位符填为空串)。 */
|
|
89
|
+
export interface TemplateContext {
|
|
90
|
+
/** 失败事实(错误码/消息/HTTP 状态), 对应 {code}/{message}/{status}。 */
|
|
91
|
+
facts?: FailureFacts;
|
|
92
|
+
/** 失败前最后一次工具调用的名称, 对应 {tool}。 */
|
|
93
|
+
tool?: string;
|
|
94
|
+
/** 失败回合的编号, 对应 {turn}。 */
|
|
95
|
+
turn?: number;
|
|
96
|
+
/** 连续失败次数(含本次), 对应 {errorCount}。 */
|
|
97
|
+
errorCount?: number;
|
|
98
|
+
/** 会话标题(来自 session.list 投影, 可用时), 对应 {sessionTitle}。 */
|
|
99
|
+
sessionTitle?: string;
|
|
100
|
+
/** 自失败发生以来的毫秒数, 对应 {elapsed}。 */
|
|
101
|
+
elapsedMs?: number;
|
|
102
|
+
}
|
|
103
|
+
/** 用失败事实与回合信息填充 continueText 模板占位符({code}/{message}/{status}/{tool}/{turn}/{errorCount}/{sessionTitle}/{elapsed})。 */
|
|
104
|
+
export declare function fillTemplate(template: string, ctx: TemplateContext): string;
|
|
74
105
|
/** 自适应退避: 同一会话连续失败时的有效冷却间隔。 */
|
|
75
106
|
export declare function effectiveCooldown(consecutive: number, base: number, factor: number, max: number): number;
|
|
107
|
+
/** 暂停某会话: 到 `until` 之前, 引擎不会为该会话自动继续(通知按钮等调用)。 */
|
|
108
|
+
export declare function pauseSession(sessionId: SessionId, ms: number): void;
|
|
109
|
+
/** 解除某会话的暂停。 */
|
|
110
|
+
export declare function unpauseSession(sessionId: SessionId): void;
|
|
111
|
+
/** 会话暂停的截止时间戳; 0 表示未暂停。 */
|
|
112
|
+
export declare function sessionPauseUntil(sessionId: SessionId): number;
|
|
113
|
+
/** 当前生效(未过期)的暂停会话列表; 顺带清理过期条目。 */
|
|
114
|
+
export declare function pausedSessions(): {
|
|
115
|
+
sessionId: SessionId;
|
|
116
|
+
until: number;
|
|
117
|
+
}[];
|
|
118
|
+
/** 一天的自动继续统计。 */
|
|
119
|
+
export interface DayStats {
|
|
120
|
+
/** 本地日期 YYYY-MM-DD。 */
|
|
121
|
+
date: string;
|
|
122
|
+
/** 自动发送次数。 */
|
|
123
|
+
sent: number;
|
|
124
|
+
/** 因永久性错误跳过的次数。 */
|
|
125
|
+
skipped: number;
|
|
126
|
+
/** 发送后回合成功完成(恢复成功)的次数。 */
|
|
127
|
+
recovered: number;
|
|
128
|
+
/** 发送后再次失败的次数。 */
|
|
129
|
+
failed: number;
|
|
130
|
+
/** 达到连续上限而停止的次数(按停止事件计)。 */
|
|
131
|
+
gaveUp: number;
|
|
132
|
+
/** 按错误码计数的失败分布。 */
|
|
133
|
+
byCode: Record<string, number>;
|
|
134
|
+
}
|
|
135
|
+
/** 今日统计(设置卡片展示用)。 */
|
|
136
|
+
export declare function readTodayStats(): DayStats;
|
|
137
|
+
/** 清零今日统计。 */
|
|
138
|
+
export declare function resetTodayStats(): void;
|
|
76
139
|
/** 插件主体: 一条 mux 流 + 一条 host 流 + 启动/重连扫描。 */
|
|
77
140
|
export declare class AutoContinueRunner {
|
|
78
141
|
private readonly api;
|
|
@@ -97,11 +160,22 @@ export declare class AutoContinueRunner {
|
|
|
97
160
|
private onHostFrame;
|
|
98
161
|
/** 回合失败入口: 先做错误分类, 永久性失败跳过并通知, 临时性失败走正常调度。 */
|
|
99
162
|
private onTurnFailure;
|
|
163
|
+
/** 通知操作按钮与回调(「立即续跑」/「暂停该会话 1 小时」)。 */
|
|
164
|
+
private notifyOptions;
|
|
165
|
+
private onNotifyAction;
|
|
166
|
+
/** 恢复结果记账: 自动发送后窗口内的回合结束, 判定恢复成功或失败。 */
|
|
167
|
+
private noteRecovery;
|
|
168
|
+
/** 立即为该会话发送一次自动继续(无视冷却与连续上限; 由通知按钮触发)。 */
|
|
169
|
+
resumeNow(sessionId: SessionId): Promise<void>;
|
|
100
170
|
/** 本会话当前生效的冷却间隔(自适应退避)。 */
|
|
101
171
|
private cooldownFor;
|
|
102
172
|
private schedule;
|
|
103
173
|
private cancelPending;
|
|
104
174
|
private fire;
|
|
175
|
+
/** 会话标题缓存(来自 session.list 投影, {sessionTitle} 占位符用)。 */
|
|
176
|
+
private readonly titles;
|
|
177
|
+
/** 查一次 session.list, 顺带缓存该会话的标题。 */
|
|
178
|
+
private fetchSessionInfo;
|
|
105
179
|
private runningViaList;
|
|
106
180
|
private scheduleReconnectScan;
|
|
107
181
|
private bootScanLoop;
|
|
@@ -23,6 +23,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
23
23
|
}
|
|
24
24
|
/** Services required by this plugin. */
|
|
25
25
|
export declare const inject: string[];
|
|
26
|
+
export { fillTemplate, pauseSession, pausedSessions, readTodayStats, resetTodayStats, sessionPauseUntil, unpauseSession, } from './engine.ts';
|
|
26
27
|
/**
|
|
27
28
|
* Plugin body: mount the engine and the settings card.
|
|
28
29
|
* @param ctx - client root context.
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
export declare const zh: {
|
|
8
8
|
'card.title': string;
|
|
9
9
|
'card.description': string;
|
|
10
|
+
'field.paused': string;
|
|
11
|
+
'field.pausedHint': string;
|
|
10
12
|
'field.continueText': string;
|
|
11
13
|
'field.continueTextHint': string;
|
|
14
|
+
'field.continueTextMaxTokens': string;
|
|
15
|
+
'field.continueTextMaxTokensHint': string;
|
|
12
16
|
'field.graceMs': string;
|
|
13
17
|
'field.graceMsHint': string;
|
|
14
18
|
'field.cooldownMs': string;
|
|
@@ -35,6 +39,20 @@ export declare const zh: {
|
|
|
35
39
|
'field.backoffMaxMsHint': string;
|
|
36
40
|
'field.notify': string;
|
|
37
41
|
'field.notifyHint': string;
|
|
42
|
+
'stats.title': string;
|
|
43
|
+
'stats.sent': string;
|
|
44
|
+
'stats.skipped': string;
|
|
45
|
+
'stats.recovered': string;
|
|
46
|
+
'stats.failed': string;
|
|
47
|
+
'stats.gaveUp': string;
|
|
48
|
+
'stats.byCode': string;
|
|
49
|
+
'stats.empty': string;
|
|
50
|
+
'stats.reset': string;
|
|
51
|
+
'pause.title': string;
|
|
52
|
+
'pause.none': string;
|
|
53
|
+
'pause.clearAll': string;
|
|
54
|
+
'pause.unpause': string;
|
|
55
|
+
'pause.minutes': string;
|
|
38
56
|
'chrome.collapse': string;
|
|
39
57
|
'chrome.expand': string;
|
|
40
58
|
'chrome.unsaved': string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type SettingsScope, type SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client';
|
|
2
2
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
-
import type
|
|
3
|
+
import { type AutoContinueSettings } from './engine.ts';
|
|
4
4
|
import { type CardActions, type CardFieldState, type CardShell } from './settings-form.ts';
|
|
5
5
|
/** What the auto-continue card renders. */
|
|
6
6
|
export interface AutoContinueSettingsCardState extends CardShell {
|
|
7
|
+
paused: CardFieldState;
|
|
7
8
|
continueText: CardFieldState;
|
|
9
|
+
continueTextMaxTokens: CardFieldState;
|
|
8
10
|
graceMs: CardFieldState;
|
|
9
11
|
cooldownMs: CardFieldState;
|
|
10
12
|
maxConsecutive: CardFieldState;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare const AUTO_CONTINUE_NS = "auto-continue";
|
|
|
11
11
|
export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
12
12
|
/** Text automatically sent after an interruption. */
|
|
13
13
|
continueText: z<string, string>;
|
|
14
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
15
|
+
continueTextMaxTokens: z<string, string>;
|
|
14
16
|
/** Grace period after an interruption before auto-sending (ms). */
|
|
15
17
|
graceMs: z<number, number>;
|
|
16
18
|
/** Minimum interval between two auto-continues per session (ms). */
|
|
@@ -37,9 +39,13 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
37
39
|
backoffMaxMs: z<number, number>;
|
|
38
40
|
/** Show browser notifications for auto-continue events. */
|
|
39
41
|
notify: z<boolean, boolean>;
|
|
42
|
+
/** Globally pause auto-continue: no live or scan send. */
|
|
43
|
+
paused: z<boolean, boolean>;
|
|
40
44
|
}>, Schemastery.ObjectT<{
|
|
41
45
|
/** Text automatically sent after an interruption. */
|
|
42
46
|
continueText: z<string, string>;
|
|
47
|
+
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
48
|
+
continueTextMaxTokens: z<string, string>;
|
|
43
49
|
/** Grace period after an interruption before auto-sending (ms). */
|
|
44
50
|
graceMs: z<number, number>;
|
|
45
51
|
/** Minimum interval between two auto-continues per session (ms). */
|
|
@@ -66,6 +72,8 @@ export declare const AutoContinueSchema: z<Schemastery.ObjectS<{
|
|
|
66
72
|
backoffMaxMs: z<number, number>;
|
|
67
73
|
/** Show browser notifications for auto-continue events. */
|
|
68
74
|
notify: z<boolean, boolean>;
|
|
75
|
+
/** Globally pause auto-continue: no live or scan send. */
|
|
76
|
+
paused: z<boolean, boolean>;
|
|
69
77
|
}>>;
|
|
70
78
|
/**
|
|
71
79
|
* Plugin body: register the settings namespace when a settings provider is
|
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 \"继续\" (continue) when a request is interrupted by network errors or other non-human causes",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|