dsh-input-traffic 0.2.10-beta.3 → 0.3.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 +8 -10
- package/INSTALL.md +11 -0
- package/INSTALL.zh.md +11 -0
- package/README.md +7 -7
- package/lib/client.js +1433 -1433
- package/lib/client.js.map +1 -1
- package/lib/types/client/index.d.ts +47 -47
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- package/package.json +16 -7
- package/lib/types/client/auto-continue-core.d.ts +0 -103
- package/lib/types/client/auto-continue-core.d.ts.map +0 -1
- package/lib/types/client/auto-continue-core.js +0 -131
- package/lib/types/client/auto-continue-core.js.map +0 -1
- package/lib/types/client/auto-continue-store.d.ts +0 -41
- package/lib/types/client/auto-continue-store.d.ts.map +0 -1
- package/lib/types/client/auto-continue-store.js +0 -93
- package/lib/types/client/auto-continue-store.js.map +0 -1
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-input-traffic —browser half.
|
|
3
|
-
*
|
|
4
|
-
* The whole takeover lives here:
|
|
5
|
-
* 1. registers the `steer` dictionaries;
|
|
6
|
-
* 2. pins `ui-conversation.busyEnter` to `queue` (plain Enter = green later)
|
|
7
|
-
* so the hidden official row cannot leak a stale queue/steer preference;
|
|
8
|
-
* 3. shadows the official queue dock (`conversation.input.dock` cell id
|
|
9
|
-
* `queue`, priority -1) with the three-tier planning strip;
|
|
10
|
-
* 4. shadows the official busy-Enter settings row (`settings.general.item`
|
|
11
|
-
* cell id `composer-enter`, priority -1) with a null render.
|
|
12
|
-
*
|
|
13
|
-
* ORDERING (why the dock registers at QUEUE_DOCK_ORDER instead of the
|
|
14
|
-
* official dock's 20): a list slot's DISPLAY position is decided by `order`
|
|
15
|
-
* alone — `ui-renderer/src/client/scoped-slots.tsx` maps the shadowing
|
|
16
|
-
* winners to rows and then sorts them by `order` (both 0.1.1 and 0.1.2) —
|
|
17
|
-
* while `priority` only decides which entry wins a shared cell id. Keeping
|
|
18
|
-
* the official 20 therefore left the strip above any later contributor
|
|
19
|
-
* (dsh-perm-gate's notice registers order 30), which pushed that notice
|
|
20
|
-
* between the queue strip and the composer card. A deliberately high order
|
|
21
|
-
* keeps the strip adjacent to the card; priority stays -1 so the cell
|
|
22
|
-
* takeover still holds.
|
|
23
|
-
*
|
|
24
|
-
* All @deepseek-ai/* imports are type-only: collaboration happens through
|
|
25
|
-
* cordis services and slot registration only (client bundle purity).
|
|
26
|
-
*/
|
|
27
|
-
import type { ClientContext } from '@deepseek-ai/
|
|
28
|
-
/**
|
|
29
|
-
* Display order of the queue strip inside `conversation.input.dock`.
|
|
30
|
-
*
|
|
31
|
-
* List rows render sorted by `order` ascending, so a value above every other
|
|
32
|
-
* contributor keeps the strip as the bottom-most entry of the band — directly
|
|
33
|
-
* on top of the composer card. Known contributors in both 0.1.1-rc.2 and
|
|
34
|
-
* 0.1.2-rc.1: `todo` 0, `goal` 10, official `queue` 20, `dsh-perm-gate.notice`
|
|
35
|
-
* 30. DSH has no "last" slot semantics, so this is a convention, not a
|
|
36
|
-
* structural guarantee: a third party registering a larger value could still
|
|
37
|
-
* land below us.
|
|
38
|
-
*/
|
|
39
|
-
export declare const QUEUE_DOCK_ORDER = 1000;
|
|
40
|
-
/** Services required by the browser half. */
|
|
41
|
-
export declare const inject: string[];
|
|
42
|
-
/**
|
|
43
|
-
* Client plugin body: dictionaries, busy-Enter pinning, and the two slot
|
|
44
|
-
* shadowings.
|
|
45
|
-
* @param ctx - client root context.
|
|
46
|
-
*/
|
|
47
|
-
export declare function apply(ctx: ClientContext): void;
|
|
1
|
+
/**
|
|
2
|
+
* dsh-input-traffic —browser half.
|
|
3
|
+
*
|
|
4
|
+
* The whole takeover lives here:
|
|
5
|
+
* 1. registers the `steer` dictionaries;
|
|
6
|
+
* 2. pins `ui-conversation.busyEnter` to `queue` (plain Enter = green later)
|
|
7
|
+
* so the hidden official row cannot leak a stale queue/steer preference;
|
|
8
|
+
* 3. shadows the official queue dock (`conversation.input.dock` cell id
|
|
9
|
+
* `queue`, priority -1) with the three-tier planning strip;
|
|
10
|
+
* 4. shadows the official busy-Enter settings row (`settings.general.item`
|
|
11
|
+
* cell id `composer-enter`, priority -1) with a null render.
|
|
12
|
+
*
|
|
13
|
+
* ORDERING (why the dock registers at QUEUE_DOCK_ORDER instead of the
|
|
14
|
+
* official dock's 20): a list slot's DISPLAY position is decided by `order`
|
|
15
|
+
* alone — `ui-renderer/src/client/scoped-slots.tsx` maps the shadowing
|
|
16
|
+
* winners to rows and then sorts them by `order` (both 0.1.1 and 0.1.2) —
|
|
17
|
+
* while `priority` only decides which entry wins a shared cell id. Keeping
|
|
18
|
+
* the official 20 therefore left the strip above any later contributor
|
|
19
|
+
* (dsh-perm-gate's notice registers order 30), which pushed that notice
|
|
20
|
+
* between the queue strip and the composer card. A deliberately high order
|
|
21
|
+
* keeps the strip adjacent to the card; priority stays -1 so the cell
|
|
22
|
+
* takeover still holds.
|
|
23
|
+
*
|
|
24
|
+
* All @deepseek-ai/* imports are type-only: collaboration happens through
|
|
25
|
+
* cordis services and slot registration only (client bundle purity).
|
|
26
|
+
*/
|
|
27
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
28
|
+
/**
|
|
29
|
+
* Display order of the queue strip inside `conversation.input.dock`.
|
|
30
|
+
*
|
|
31
|
+
* List rows render sorted by `order` ascending, so a value above every other
|
|
32
|
+
* contributor keeps the strip as the bottom-most entry of the band — directly
|
|
33
|
+
* on top of the composer card. Known contributors in both 0.1.1-rc.2 and
|
|
34
|
+
* 0.1.2-rc.1: `todo` 0, `goal` 10, official `queue` 20, `dsh-perm-gate.notice`
|
|
35
|
+
* 30. DSH has no "last" slot semantics, so this is a convention, not a
|
|
36
|
+
* structural guarantee: a third party registering a larger value could still
|
|
37
|
+
* land below us.
|
|
38
|
+
*/
|
|
39
|
+
export declare const QUEUE_DOCK_ORDER = 1000;
|
|
40
|
+
/** Services required by the browser half. */
|
|
41
|
+
export declare const inject: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Client plugin body: dictionaries, busy-Enter pinning, and the two slot
|
|
44
|
+
* shadowings.
|
|
45
|
+
* @param ctx - client root context.
|
|
46
|
+
*/
|
|
47
|
+
export declare function apply(ctx: ClientContext): void;
|
|
48
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAiBnE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAkBpC,6CAA6C;AAC7C,eAAO,MAAM,MAAM,UAAmE,CAAA;AAEtF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAyE9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAwB,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAsB,CAAA;AAEnD,wEAAwE;AACxE,MAAM,+BAA+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CAAC,CAAA,CAAC,CAAC;gBAC7E,2DAA2D;gBAC3D,gDAAgD;gBAChD,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE;oBAC3B,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;gBACnF,CAAC;aACF,CAAA;QACH,CAAC;KACF,EAAE,YAAY,CAAC,CAAC,CAAA;IAEjB,yEAAyE;IACzE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjE,IAAI,EAAE,uBAAuB;QAC7B,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,CAAC,CAAC;QACZ,MAAM,EAAE,EAAE;KACX,EAAE,YAAY,CAAC,CAAC,CAAA;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-input-traffic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"registry": "https://registry.npmjs.org",
|
|
6
|
+
"access": "public",
|
|
7
|
+
"tag": "dsh-0.1.2"
|
|
8
|
+
},
|
|
4
9
|
"type": "module",
|
|
5
10
|
"description": "Busy-time input queue for the DeepSeek Harness web GUI: three-tier (now/next/later) planning, queue editing with drag-to-reorder and concurrency protection, interject (steer) and interrupt, batch clear with confirm, session freeze - a cordis client plugin, no dsh source changes, no PR required",
|
|
6
11
|
"repository": {
|
|
@@ -59,16 +64,17 @@
|
|
|
59
64
|
},
|
|
60
65
|
"engines": {
|
|
61
66
|
"node": ">=20",
|
|
62
|
-
"dsh": ">=0.1.
|
|
67
|
+
"dsh": ">=0.1.2-alpha.1 <0.2.0-0"
|
|
63
68
|
},
|
|
64
69
|
"license": "MIT",
|
|
65
70
|
"peerDependencies": {
|
|
66
71
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
67
|
-
"@deepseek-ai/dsh-client-locale": "
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-conversation": "
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-primitives": "
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-settings": "
|
|
71
|
-
"@deepseek-ai/dsh-client-ui-slots": "
|
|
72
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.2-alpha.1 <0.2.0-0",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-conversation": ">=0.1.2-alpha.1 <0.2.0-0",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives": ">=0.1.2-alpha.1 <0.2.0-0",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.2-alpha.1 <0.2.0-0",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.2-alpha.1 <0.2.0-0",
|
|
77
|
+
"@deepseek-ai/dsh-session": ">=0.1.2-alpha.1 <0.2.0-0"
|
|
72
78
|
},
|
|
73
79
|
"peerDependenciesMeta": {
|
|
74
80
|
"@deepseek-ai/cordis": {
|
|
@@ -88,6 +94,9 @@
|
|
|
88
94
|
},
|
|
89
95
|
"@deepseek-ai/dsh-client-ui-slots": {
|
|
90
96
|
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"@deepseek-ai/dsh-session": {
|
|
99
|
+
"optional": true
|
|
91
100
|
}
|
|
92
101
|
},
|
|
93
102
|
"devDependencies": {
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-continue core — 平台无关的纯逻辑, 吸收自 dsh-auto-continue
|
|
3
|
-
* (https://github.com/HsiangNianian/dsh-auto-continue, MIT, v0.8.1 的
|
|
4
|
-
* src/shared/core.ts), 按 input-traffic 的纯 client 定位裁剪:
|
|
5
|
-
*
|
|
6
|
-
* - 只吸收「错误分类 / 自适应退避 / 幂等护栏 / 模板填充」这些无宿主依赖的纯函数;
|
|
7
|
-
* - 不吸收宿主引擎(host firehose / agent.followup / SSE 桥)——那会破坏本插件
|
|
8
|
-
* 「纯浏览器侧、不改官方源码」的定位, 且与「冻结会话省钱」方向相反(见 README 兼容性);
|
|
9
|
-
* - 全部函数无任何 @deepseek-ai/* 值导入, 通过 client bundle purity gate。
|
|
10
|
-
*
|
|
11
|
-
* 应用场景: dock 的「续跑」——检测到会话停下但排队消息未处理完(疑似中断)时,
|
|
12
|
-
* 分类失败、按退避节奏重发, 永久性错误则停止并提示人工介入。
|
|
13
|
-
*/
|
|
14
|
-
/** 一次发送失败的可分类事实(从 send 的 reject error 里提取)。 */
|
|
15
|
-
export interface FailureFacts {
|
|
16
|
-
/** 稳定机器路由码(如 UPSTREAM、RATE_LIMIT_EXCEEDED)。 */
|
|
17
|
-
code?: string;
|
|
18
|
-
/** 人类可读的失败描述。 */
|
|
19
|
-
message: string;
|
|
20
|
-
/** 供应商 HTTP 状态码(可用时)。 */
|
|
21
|
-
status?: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 错误分类: 该失败是否值得重试续跑。
|
|
25
|
-
* 永久性失败(认证/余额/模型不存在/上下文超限等)重试也不会成功, 应停止并提示用户;
|
|
26
|
-
* 其余(网络、超时、5xx、429 等)视为临时性失败, 允许自动重发。
|
|
27
|
-
*/
|
|
28
|
-
export declare function isTransientFailure(failure: FailureFacts): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 消息文本分类: 仅明确属于网络/传输类的临时错误才值得重试。
|
|
31
|
-
* 其余(序列化失败、配置/宿主内部错误等)视为永久性——重试无益。
|
|
32
|
-
*/
|
|
33
|
-
export declare function isTransientAgentError(message: string): boolean;
|
|
34
|
-
/** 自适应退避: 同一会话连续失败时的有效重试间隔。 */
|
|
35
|
-
export declare function effectiveCooldown(consecutive: number, base: number, factor: number, max: number): number;
|
|
36
|
-
/** 模板填充所需上下文(全部可选, 缺失的占位符填为空串)。 */
|
|
37
|
-
export interface TemplateContext {
|
|
38
|
-
/** 失败事实(错误码/消息/HTTP 状态), 对应 {code}/{message}/{status}。 */
|
|
39
|
-
facts?: FailureFacts;
|
|
40
|
-
/** 失败前最后一次工具调用的名称, 对应 {tool}。 */
|
|
41
|
-
tool?: string;
|
|
42
|
-
/** 连续失败次数(含本次), 对应 {errorCount}。 */
|
|
43
|
-
errorCount?: number;
|
|
44
|
-
/** 自失败发生以来的毫秒数, 对应 {elapsed}。 */
|
|
45
|
-
elapsedMs?: number;
|
|
46
|
-
/** 上一步工具结果摘要(截断), 对应 {result}(护栏模板用)。 */
|
|
47
|
-
result?: string;
|
|
48
|
-
}
|
|
49
|
-
/** 把毫秒格式化为人类可读的经过时长(如 65s → 1m5s)。 */
|
|
50
|
-
export declare function formatElapsed(ms: number | undefined): string;
|
|
51
|
-
/** 用失败事实填充续跑模板占位符({code}/{message}/{status}/{tool}/{errorCount}/{elapsed}/{result})。 */
|
|
52
|
-
export declare function fillTemplate(template: string, ctx: TemplateContext): string;
|
|
53
|
-
/** 上一步工具调用的判定结果: 是否已确认完成, 以及文本摘要。 */
|
|
54
|
-
export interface ToolResultFacts {
|
|
55
|
-
/** 工具是否成功完成(内部失败或 isError 视为未成功)。 */
|
|
56
|
-
ok: boolean;
|
|
57
|
-
/** 工具输出的文本摘要(截断)。 */
|
|
58
|
-
excerpt: string;
|
|
59
|
-
}
|
|
60
|
-
/** 从 tool/result 事件载荷提取成功与否与文本摘要(幂等护栏: 续跑时提示别重复执行)。 */
|
|
61
|
-
export declare function toolResultFacts(data: {
|
|
62
|
-
error?: {
|
|
63
|
-
name?: string;
|
|
64
|
-
code?: string;
|
|
65
|
-
};
|
|
66
|
-
message?: {
|
|
67
|
-
content?: Array<{
|
|
68
|
-
type?: string;
|
|
69
|
-
content?: unknown;
|
|
70
|
-
isError?: boolean;
|
|
71
|
-
}>;
|
|
72
|
-
};
|
|
73
|
-
}): ToolResultFacts;
|
|
74
|
-
/** 续跑配置(全部可选, 解析时回落默认值)。 */
|
|
75
|
-
export interface AutoContinueSettings {
|
|
76
|
-
/** 续跑时自动发送的消息文本(可含模板占位符)。 */
|
|
77
|
-
continueText?: string;
|
|
78
|
-
/** 宽限期: 停下多久后视为中断再自动重发(ms)。 */
|
|
79
|
-
graceMs?: number;
|
|
80
|
-
/** 同一会话两次自动续跑的最小间隔(ms)。 */
|
|
81
|
-
cooldownMs?: number;
|
|
82
|
-
/** 连续自动续跑上限; 超过后停止, 直到用户介入或成功回合。 */
|
|
83
|
-
maxConsecutive?: number;
|
|
84
|
-
/** 连续失败时的退避系数。 */
|
|
85
|
-
backoffFactor?: number;
|
|
86
|
-
/** 自适应退避的上限(ms)。 */
|
|
87
|
-
backoffMaxMs?: number;
|
|
88
|
-
/**
|
|
89
|
-
* 自动续跑: 检测到疑似中断时自动重发排队消息。
|
|
90
|
-
* 默认关闭——纯 client 拿不到 turn/end reason, 无法区分「用户主动停止」与
|
|
91
|
-
* 「非人为中断」, 故默认只提示不擅自续跑(与 auto-continue 的 paused 不同)。
|
|
92
|
-
*/
|
|
93
|
-
autoResume?: boolean;
|
|
94
|
-
/** 全局暂停续跑(如冻结期间)。 */
|
|
95
|
-
paused?: boolean;
|
|
96
|
-
}
|
|
97
|
-
/** 完全解析后的续跑配置(内置默认值 + 用户覆盖)。 */
|
|
98
|
-
export type AutoContinueConfig = Required<AutoContinueSettings>;
|
|
99
|
-
/** 内置默认值(与 dock 的 localStorage 持久化键一致)。 */
|
|
100
|
-
export declare const DEFAULT_CONFIG: AutoContinueConfig;
|
|
101
|
-
/** 把(可能不完整的)配置解析为完整配置(合法数字/布尔校验 + 兜底默认)。 */
|
|
102
|
-
export declare function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig;
|
|
103
|
-
//# sourceMappingURL=auto-continue-core.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-continue-core.d.ts","sourceR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C,IAAI,EAAE;IACpC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;CACvF,GAAG,eAAe,CAGlB;AAED,4BAA4B;AAC5B,MAAM,WAAW,oBAAoB;IACnC,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kBAAkB;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,qBAAqB;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,gCAAgC;AAChC,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAA;AAE/D,2CAA2C;AAC3C,eAAO,MAAM,cAAc,EAAE,kBAS5B,CAAA;AAUD,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,GAAG,kBAAkB,CAgB3F"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-continue core — 平台无关的纯逻辑, 吸收自 dsh-auto-continue
|
|
3
|
-
* (https://github.com/HsiangNianian/dsh-auto-continue, MIT, v0.8.1 的
|
|
4
|
-
* src/shared/core.ts), 按 input-traffic 的纯 client 定位裁剪:
|
|
5
|
-
*
|
|
6
|
-
* - 只吸收「错误分类 / 自适应退避 / 幂等护栏 / 模板填充」这些无宿主依赖的纯函数;
|
|
7
|
-
* - 不吸收宿主引擎(host firehose / agent.followup / SSE 桥)——那会破坏本插件
|
|
8
|
-
* 「纯浏览器侧、不改官方源码」的定位, 且与「冻结会话省钱」方向相反(见 README 兼容性);
|
|
9
|
-
* - 全部函数无任何 @deepseek-ai/* 值导入, 通过 client bundle purity gate。
|
|
10
|
-
*
|
|
11
|
-
* 应用场景: dock 的「续跑」——检测到会话停下但排队消息未处理完(疑似中断)时,
|
|
12
|
-
* 分类失败、按退避节奏重发, 永久性错误则停止并提示人工介入。
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* 错误分类: 该失败是否值得重试续跑。
|
|
16
|
-
* 永久性失败(认证/余额/模型不存在/上下文超限等)重试也不会成功, 应停止并提示用户;
|
|
17
|
-
* 其余(网络、超时、5xx、429 等)视为临时性失败, 允许自动重发。
|
|
18
|
-
*/
|
|
19
|
-
export function isTransientFailure(failure) {
|
|
20
|
-
const haystack = `${failure.code ?? ''} ${failure.message}`.toLowerCase();
|
|
21
|
-
const status = failure.status;
|
|
22
|
-
if (status !== undefined && (status === 401 || status === 403))
|
|
23
|
-
return false;
|
|
24
|
-
const permanent = /auth|unauthor|forbidden|credential|api[_-]?key|permission/i.test(haystack) ||
|
|
25
|
-
/insufficient.*(balance|quota)|billing|payment|quota.*exceeded.*(?!retry)/i.test(haystack) ||
|
|
26
|
-
/model[^a-z]*not[^a-z]*found|unknown[_-]?model|not.*support.*model/i.test(haystack) ||
|
|
27
|
-
/context.*(length|limit|overflow|exceed)|token.*limit|max.*context/i.test(haystack) ||
|
|
28
|
-
/invalid[_-]?request|bad[_-]?request/i.test(haystack);
|
|
29
|
-
return !permanent;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 消息文本分类: 仅明确属于网络/传输类的临时错误才值得重试。
|
|
33
|
-
* 其余(序列化失败、配置/宿主内部错误等)视为永久性——重试无益。
|
|
34
|
-
*/
|
|
35
|
-
export function isTransientAgentError(message) {
|
|
36
|
-
return /network|timeout|timed ?out|econn|etimedout|socket|5\d\d|\b429\b|upstream|temporar/i.test(message);
|
|
37
|
-
}
|
|
38
|
-
/** 自适应退避: 同一会话连续失败时的有效重试间隔。 */
|
|
39
|
-
export function effectiveCooldown(consecutive, base, factor, max) {
|
|
40
|
-
// consecutive = 已连续自动重发的次数; 第 1 次后开始按 factor 递增
|
|
41
|
-
const multiplier = Math.pow(factor, consecutive);
|
|
42
|
-
return Math.min(Math.max(base, base * multiplier), Math.max(base, max));
|
|
43
|
-
}
|
|
44
|
-
/** 把毫秒格式化为人类可读的经过时长(如 65s → 1m5s)。 */
|
|
45
|
-
export function formatElapsed(ms) {
|
|
46
|
-
if (ms === undefined || !Number.isFinite(ms) || ms < 0)
|
|
47
|
-
return '';
|
|
48
|
-
if (ms < 1000)
|
|
49
|
-
return `${Math.round(ms)}ms`;
|
|
50
|
-
const s = Math.round(ms / 1000);
|
|
51
|
-
if (s < 60)
|
|
52
|
-
return `${s}s`;
|
|
53
|
-
return `${Math.floor(s / 60)}m${s % 60 > 0 ? `${s % 60}s` : ''}`;
|
|
54
|
-
}
|
|
55
|
-
/** 用失败事实填充续跑模板占位符({code}/{message}/{status}/{tool}/{errorCount}/{elapsed}/{result})。 */
|
|
56
|
-
export function fillTemplate(template, ctx) {
|
|
57
|
-
return template
|
|
58
|
-
.replace(/\{code\}/g, ctx.facts?.code ?? '')
|
|
59
|
-
.replace(/\{message\}/g, ctx.facts?.message ?? '')
|
|
60
|
-
.replace(/\{status\}/g, ctx.facts?.status !== undefined ? String(ctx.facts.status) : '')
|
|
61
|
-
.replace(/\{tool\}/g, ctx.tool ?? '')
|
|
62
|
-
.replace(/\{errorCount\}/g, ctx.errorCount !== undefined ? String(ctx.errorCount) : '')
|
|
63
|
-
.replace(/\{elapsed\}/g, formatElapsed(ctx.elapsedMs))
|
|
64
|
-
.replace(/\{result\}/g, ctx.result ?? '');
|
|
65
|
-
}
|
|
66
|
-
/** 工具结果摘要的最大长度(护栏模板 {result} 用)。 */
|
|
67
|
-
const TOOL_RESULT_CAP = 160;
|
|
68
|
-
/** 从任意内容块里递归收集文本(结果为模型可见的工具输出)。 */
|
|
69
|
-
function extractText(blocks, cap) {
|
|
70
|
-
let out = '';
|
|
71
|
-
const walk = (value) => {
|
|
72
|
-
if (out.length >= cap)
|
|
73
|
-
return;
|
|
74
|
-
if (Array.isArray(value)) {
|
|
75
|
-
for (const item of value)
|
|
76
|
-
walk(item);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (typeof value !== 'object' || value === null)
|
|
80
|
-
return;
|
|
81
|
-
const record = value;
|
|
82
|
-
if (record['type'] === 'text' && typeof record['text'] === 'string') {
|
|
83
|
-
out += record['text'];
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
for (const child of Object.values(record))
|
|
87
|
-
walk(child);
|
|
88
|
-
};
|
|
89
|
-
walk(blocks);
|
|
90
|
-
return out.slice(0, cap);
|
|
91
|
-
}
|
|
92
|
-
/** 从 tool/result 事件载荷提取成功与否与文本摘要(幂等护栏: 续跑时提示别重复执行)。 */
|
|
93
|
-
export function toolResultFacts(data) {
|
|
94
|
-
const failed = data.error !== undefined || data.message?.content?.[0]?.isError === true;
|
|
95
|
-
return { ok: !failed, excerpt: extractText(data.message?.content?.[0]?.content, TOOL_RESULT_CAP) };
|
|
96
|
-
}
|
|
97
|
-
/** 内置默认值(与 dock 的 localStorage 持久化键一致)。 */
|
|
98
|
-
export const DEFAULT_CONFIG = {
|
|
99
|
-
continueText: '继续',
|
|
100
|
-
graceMs: 3000,
|
|
101
|
-
cooldownMs: 20000,
|
|
102
|
-
maxConsecutive: 3,
|
|
103
|
-
backoffFactor: 2,
|
|
104
|
-
backoffMaxMs: 300000,
|
|
105
|
-
autoResume: false,
|
|
106
|
-
paused: false,
|
|
107
|
-
};
|
|
108
|
-
function numberOr(value, fallback) {
|
|
109
|
-
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
110
|
-
}
|
|
111
|
-
function booleanOr(value, fallback) {
|
|
112
|
-
return typeof value === 'boolean' ? value : fallback;
|
|
113
|
-
}
|
|
114
|
-
/** 把(可能不完整的)配置解析为完整配置(合法数字/布尔校验 + 兜底默认)。 */
|
|
115
|
-
export function resolveConfig(section) {
|
|
116
|
-
const value = section ?? {};
|
|
117
|
-
const text = typeof value.continueText === 'string' && value.continueText.trim() !== ''
|
|
118
|
-
? value.continueText
|
|
119
|
-
: DEFAULT_CONFIG.continueText;
|
|
120
|
-
return {
|
|
121
|
-
continueText: text,
|
|
122
|
-
graceMs: numberOr(value.graceMs, DEFAULT_CONFIG.graceMs),
|
|
123
|
-
cooldownMs: numberOr(value.cooldownMs, DEFAULT_CONFIG.cooldownMs),
|
|
124
|
-
maxConsecutive: Math.max(1, numberOr(value.maxConsecutive, DEFAULT_CONFIG.maxConsecutive)),
|
|
125
|
-
backoffFactor: Math.max(1, numberOr(value.backoffFactor, DEFAULT_CONFIG.backoffFactor)),
|
|
126
|
-
backoffMaxMs: numberOr(value.backoffMaxMs, DEFAULT_CONFIG.backoffMaxMs),
|
|
127
|
-
autoResume: booleanOr(value.autoResume, DEFAULT_CONFIG.autoResume),
|
|
128
|
-
paused: booleanOr(value.paused, DEFAULT_CONFIG.paused),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=auto-continue-core.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-continue-core.js","sourceRoot":"","sources":["../../../src/client/auto-continue-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB;IACtD,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,OAAO,CAAC,OAAO,EA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AAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;QACvF,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,CAAC,YAAY,CAAC;QACvE,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC;QAClE,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC;KACvD,CAAA;AACH,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-continue store — 中断检测与续跑配置的共享状态。
|
|
3
|
-
*
|
|
4
|
-
* 与 freeze-store 同构(无运行时依赖、稳定 identity per mount、可测试):
|
|
5
|
-
* - interrupted: 检测到「会话停下但排队消息未处理完」(疑似非人为中断)时置位,
|
|
6
|
-
* dock 据此显示续跑提示条;
|
|
7
|
-
* - 续跑配置持久化到 localStorage(键 `dsh-input-traffic:auto-continue`),
|
|
8
|
-
* 自动续跑默认关闭(纯 client 拿不到 turn/end reason, 无法与用户主动停止
|
|
9
|
-
* 区分, 故默认只提示、不擅自续跑)。
|
|
10
|
-
*/
|
|
11
|
-
import { type AutoContinueConfig, type AutoContinueSettings } from './auto-continue-core.ts';
|
|
12
|
-
/** localStorage 持久化键(续跑配置)。 */
|
|
13
|
-
export declare const CONFIG_KEY = "dsh-input-traffic:auto-continue";
|
|
14
|
-
export interface AutoContinueState {
|
|
15
|
-
/** 是否检测到疑似中断(提示条可见性)。 */
|
|
16
|
-
interrupted: boolean;
|
|
17
|
-
/** 连续自动续跑次数(按配置上限封顶)。 */
|
|
18
|
-
consecutive: number;
|
|
19
|
-
/** 上次续跑尝试时间戳(退避节流用)。 */
|
|
20
|
-
lastAttemptAt: number;
|
|
21
|
-
}
|
|
22
|
-
/** 最小快照 store(与 freeze-store 同构)。 */
|
|
23
|
-
export declare const autoContinueStore: {
|
|
24
|
-
getSnapshot(): AutoContinueState;
|
|
25
|
-
subscribe(listener: () => void): () => void;
|
|
26
|
-
};
|
|
27
|
-
/** 当前解析后的续跑配置。 */
|
|
28
|
-
export declare function readAutoContinueConfig(): AutoContinueConfig;
|
|
29
|
-
/** 持久化续跑配置(部分覆盖, 缺失回落默认)。 */
|
|
30
|
-
export declare function setAutoContinueConfig(patch: AutoContinueSettings): void;
|
|
31
|
-
/** 标记检测到疑似中断(dock 显示提示条)。 */
|
|
32
|
-
export declare function markInterrupted(): void;
|
|
33
|
-
/** 清除中断标志(用户手动续跑 / 队列清空 / 会话重新运行)。 */
|
|
34
|
-
export declare function clearInterrupted(): void;
|
|
35
|
-
/** 记录一次续跑尝试(推进连续计数与退避节流)。 */
|
|
36
|
-
export declare function noteRetry(consecutive: number): void;
|
|
37
|
-
/** 重置续跑状态(成功回合 / 用户介入后)。 */
|
|
38
|
-
export declare function resetAutoContinue(): void;
|
|
39
|
-
/** 测试重置。 */
|
|
40
|
-
export declare function resetAutoContinueStore(): void;
|
|
41
|
-
//# sourceMappingURL=auto-continue-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-continue-store.d.ts","sourceRoot":"","sources":["../../../src/client/auto-continue-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAiB,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE3G,+BAA+B;AAC/B,eAAO,MAAM,UAAU,oCAAoC,CAAA;AAE3D,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,wBAAwB;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAsBD,qCAAqC;AACrC,eAAO,MAAM,iBAAiB;mBACb,iBAAiB;wBAGZ,MAAM,IAAI,GAAG,MAAM,IAAI;CAI5C,CAAA;AAED,kBAAkB;AAClB,wBAAgB,sBAAsB,IAAI,kBAAkB,CAE3D;AAED,6BAA6B;AAC7B,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAUvE;AAED,6BAA6B;AAC7B,wBAAgB,eAAe,IAAI,IAAI,CAGtC;AAED,sCAAsC;AACtC,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED,6BAA6B;AAC7B,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAGnD;AAED,4BAA4B;AAC5B,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED,YAAY;AACZ,wBAAgB,sBAAsB,IAAI,IAAI,CAS7C"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-continue store — 中断检测与续跑配置的共享状态。
|
|
3
|
-
*
|
|
4
|
-
* 与 freeze-store 同构(无运行时依赖、稳定 identity per mount、可测试):
|
|
5
|
-
* - interrupted: 检测到「会话停下但排队消息未处理完」(疑似非人为中断)时置位,
|
|
6
|
-
* dock 据此显示续跑提示条;
|
|
7
|
-
* - 续跑配置持久化到 localStorage(键 `dsh-input-traffic:auto-continue`),
|
|
8
|
-
* 自动续跑默认关闭(纯 client 拿不到 turn/end reason, 无法与用户主动停止
|
|
9
|
-
* 区分, 故默认只提示、不擅自续跑)。
|
|
10
|
-
*/
|
|
11
|
-
import { resolveConfig } from "./auto-continue-core.js";
|
|
12
|
-
/** localStorage 持久化键(续跑配置)。 */
|
|
13
|
-
export const CONFIG_KEY = 'dsh-input-traffic:auto-continue';
|
|
14
|
-
const listeners = new Set();
|
|
15
|
-
let state = { interrupted: false, consecutive: 0, lastAttemptAt: 0 };
|
|
16
|
-
let config = readConfig();
|
|
17
|
-
/** 读取(可能不完整的)localStorage 配置并解析为完整配置。 */
|
|
18
|
-
function readConfig() {
|
|
19
|
-
let raw;
|
|
20
|
-
try {
|
|
21
|
-
const stored = localStorage.getItem(CONFIG_KEY);
|
|
22
|
-
if (stored !== null)
|
|
23
|
-
raw = JSON.parse(stored);
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
/* storage 不可用或损坏: 回落默认 */
|
|
27
|
-
}
|
|
28
|
-
return resolveConfig(raw);
|
|
29
|
-
}
|
|
30
|
-
function emit() {
|
|
31
|
-
for (const listener of listeners)
|
|
32
|
-
listener();
|
|
33
|
-
}
|
|
34
|
-
/** 最小快照 store(与 freeze-store 同构)。 */
|
|
35
|
-
export const autoContinueStore = {
|
|
36
|
-
getSnapshot() {
|
|
37
|
-
return state;
|
|
38
|
-
},
|
|
39
|
-
subscribe(listener) {
|
|
40
|
-
listeners.add(listener);
|
|
41
|
-
return () => { listeners.delete(listener); };
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
/** 当前解析后的续跑配置。 */
|
|
45
|
-
export function readAutoContinueConfig() {
|
|
46
|
-
return config;
|
|
47
|
-
}
|
|
48
|
-
/** 持久化续跑配置(部分覆盖, 缺失回落默认)。 */
|
|
49
|
-
export function setAutoContinueConfig(patch) {
|
|
50
|
-
config = resolveConfig({ ...config, ...patch });
|
|
51
|
-
try {
|
|
52
|
-
localStorage.setItem(CONFIG_KEY, JSON.stringify(config));
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
/* storage 不可用: 仅内存生效 */
|
|
56
|
-
}
|
|
57
|
-
// 强制快照引用变化: useSyncExternalStore 依赖引用对比决定是否重渲染。
|
|
58
|
-
state = { ...state };
|
|
59
|
-
emit();
|
|
60
|
-
}
|
|
61
|
-
/** 标记检测到疑似中断(dock 显示提示条)。 */
|
|
62
|
-
export function markInterrupted() {
|
|
63
|
-
state = { ...state, interrupted: true };
|
|
64
|
-
emit();
|
|
65
|
-
}
|
|
66
|
-
/** 清除中断标志(用户手动续跑 / 队列清空 / 会话重新运行)。 */
|
|
67
|
-
export function clearInterrupted() {
|
|
68
|
-
state = { ...state, interrupted: false };
|
|
69
|
-
emit();
|
|
70
|
-
}
|
|
71
|
-
/** 记录一次续跑尝试(推进连续计数与退避节流)。 */
|
|
72
|
-
export function noteRetry(consecutive) {
|
|
73
|
-
state = { ...state, consecutive, lastAttemptAt: Date.now() };
|
|
74
|
-
emit();
|
|
75
|
-
}
|
|
76
|
-
/** 重置续跑状态(成功回合 / 用户介入后)。 */
|
|
77
|
-
export function resetAutoContinue() {
|
|
78
|
-
state = { interrupted: false, consecutive: 0, lastAttemptAt: 0 };
|
|
79
|
-
emit();
|
|
80
|
-
}
|
|
81
|
-
/** 测试重置。 */
|
|
82
|
-
export function resetAutoContinueStore() {
|
|
83
|
-
state = { interrupted: false, consecutive: 0, lastAttemptAt: 0 };
|
|
84
|
-
try {
|
|
85
|
-
localStorage.removeItem(CONFIG_KEY);
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
/* storage 不可用 */
|
|
89
|
-
}
|
|
90
|
-
config = readConfig();
|
|
91
|
-
emit();
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=auto-continue-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-continue-store.js","sourceRoot":"","sources":["../../../src/client/auto-continue-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAsD,MAAM,yBAAyB,CAAA;AAE3G,+BAA+B;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,iCAAiC,CAAA;AAW3D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,IAAI,KAAK,GAAsB,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAA;AACvF,IAAI,MAAM,GAAuB,UAAU,EAAE,CAAA;AAE7C,yCAAyC;AACzC,SAAS,UAAU;IACjB,IAAI,GAAqC,CAAA;IACzC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CA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