@feng0531/dsh-execution-bus 0.5.1 → 0.6.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 +3 -3
- package/dist/bus.d.ts +14 -43
- package/dist/bus.js +135 -148
- package/dist/diagnostics.js +6 -4
- package/dist/error-codes.d.ts +54 -0
- package/dist/error-codes.js +60 -0
- package/dist/execution.d.ts +8 -0
- package/dist/execution.js +67 -48
- package/dist/handlers.js +14 -11
- package/dist/json.d.ts +1 -1
- package/dist/json.js +13 -11
- package/dist/limits.d.ts +20 -0
- package/dist/limits.js +23 -0
- package/dist/plugin.js +60 -36
- package/dist/preset.js +19 -17
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/protocol.d.ts +49 -0
- package/dist/protocol.js +54 -0
- package/docs/PRODUCT.md +1 -1
- package/docs/releases/0.6.0.md +20 -0
- package/package.json +18 -18
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type State = "queued" | "running" | "succeeded" | "failed" | "cancelled" | "unknown";
|
|
2
|
+
export type Owner = {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
callId: string;
|
|
5
|
+
};
|
|
6
|
+
export type Message = {
|
|
7
|
+
protocolVersion: 1;
|
|
8
|
+
messageId: string;
|
|
9
|
+
requestId: string;
|
|
10
|
+
type: "request" | "status" | "result" | "cancel";
|
|
11
|
+
payload: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type Event = {
|
|
14
|
+
protocolVersion: 1;
|
|
15
|
+
messageId: string;
|
|
16
|
+
requestId: string;
|
|
17
|
+
correlationId: string;
|
|
18
|
+
sequence: number;
|
|
19
|
+
type: string;
|
|
20
|
+
payload: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export type Capability = (input: Record<string, unknown>, signal: AbortSignal) => Promise<unknown>;
|
|
23
|
+
export interface Handler {
|
|
24
|
+
/** 是否可安全复用终态结果。省略默认 true(可复用,向后兼容);
|
|
25
|
+
* 显式 false = 有副作用,终态结果复用将被拒绝(运行中等待仍放行)。 */
|
|
26
|
+
readonly idempotent?: boolean;
|
|
27
|
+
validate(input: Record<string, unknown>): void;
|
|
28
|
+
run(input: Record<string, unknown>, ctx: {
|
|
29
|
+
signal: AbortSignal;
|
|
30
|
+
progress: (sequence: number, percent: number) => void;
|
|
31
|
+
requestId: string;
|
|
32
|
+
invoke?: Capability;
|
|
33
|
+
}): Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
export interface RecordView {
|
|
36
|
+
requestId: string;
|
|
37
|
+
state: State;
|
|
38
|
+
sequence: number;
|
|
39
|
+
cancelRequested: boolean;
|
|
40
|
+
delivery: "pending" | "returned";
|
|
41
|
+
result?: unknown;
|
|
42
|
+
error?: string;
|
|
43
|
+
progress?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare function object(v: unknown): Record<string, unknown>;
|
|
46
|
+
/** 规范排序后的稳定摘要,只用于同 requestId 的冲突比较,不用于跨请求去重。 */
|
|
47
|
+
export declare function canonical(v: unknown): string;
|
|
48
|
+
export declare function parse(raw: unknown): Message;
|
|
49
|
+
export declare function freezeJson<T>(value: T): T;
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { assertJson } from "./json.js";
|
|
2
|
+
import { ERRORS } from "./error-codes.js";
|
|
3
|
+
import { LIMITS } from "./limits.js";
|
|
4
|
+
export function object(v) {
|
|
5
|
+
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
6
|
+
throw Error(ERRORS.INVALID_OBJECT);
|
|
7
|
+
return v;
|
|
8
|
+
}
|
|
9
|
+
/** 规范排序后的稳定摘要,只用于同 requestId 的冲突比较,不用于跨请求去重。 */
|
|
10
|
+
export function canonical(v) {
|
|
11
|
+
if (v === null || typeof v !== "object")
|
|
12
|
+
return JSON.stringify(v);
|
|
13
|
+
if (Array.isArray(v))
|
|
14
|
+
return "[" + v.map(canonical).join(",") + "]";
|
|
15
|
+
return ("{" +
|
|
16
|
+
Object.keys(v)
|
|
17
|
+
.sort()
|
|
18
|
+
.map((k) => JSON.stringify(k) +
|
|
19
|
+
":" +
|
|
20
|
+
canonical(v[k]))
|
|
21
|
+
.join(",") +
|
|
22
|
+
"}");
|
|
23
|
+
}
|
|
24
|
+
export function parse(raw) {
|
|
25
|
+
assertJson(raw);
|
|
26
|
+
const m = object(raw);
|
|
27
|
+
if (Object.keys(m).some((k) => ![
|
|
28
|
+
"protocolVersion",
|
|
29
|
+
"messageId",
|
|
30
|
+
"requestId",
|
|
31
|
+
"type",
|
|
32
|
+
"payload",
|
|
33
|
+
].includes(k)))
|
|
34
|
+
throw Error(ERRORS.UNKNOWN_FIELD);
|
|
35
|
+
if (m.protocolVersion !== 1)
|
|
36
|
+
throw Error(ERRORS.UNSUPPORTED_VERSION);
|
|
37
|
+
for (const k of ["messageId", "requestId"])
|
|
38
|
+
if (typeof m[k] !== "string" || !LIMITS.idPattern.test(m[k]))
|
|
39
|
+
throw Error(ERRORS.INVALID_ID);
|
|
40
|
+
if (!["request", "status", "result", "cancel"].includes(m.type))
|
|
41
|
+
throw Error(ERRORS.UNSUPPORTED_TYPE);
|
|
42
|
+
object(m.payload);
|
|
43
|
+
if (Buffer.byteLength(JSON.stringify(m)) > LIMITS.messageMaxBytes)
|
|
44
|
+
throw Error(ERRORS.MESSAGE_TOO_LARGE);
|
|
45
|
+
return structuredClone(m);
|
|
46
|
+
}
|
|
47
|
+
export function freezeJson(value) {
|
|
48
|
+
if (value && typeof value === "object") {
|
|
49
|
+
for (const child of Object.values(value))
|
|
50
|
+
freezeJson(child);
|
|
51
|
+
Object.freeze(value);
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
package/docs/PRODUCT.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
萧何是 DSH 内的可选执行协调插件,提供独立可选择的 PTC 派生预设,不是 PTC 替代传输层,也不全局接管终端、编辑或其他工具。实际业务 Handler 为 host.read;test 是兼容保留的诊断 Handler,只有明确诊断需求时使用。测试能力存在不代表其他命令已接入总线。
|
|
6
6
|
|
|
7
|
-
0.
|
|
7
|
+
0.6.0 对齐 DSH 0.2.1-rc.2 并在 core 层为扩展 Handler 增加幂等声明,不以更名宣称完成生产环境认证。当前真实模型、桌面 UI 和实际沙箱尚未完整验收;同进程内存状态不支持跨重启恢复。
|
|
8
8
|
|
|
9
9
|
## 入口及配置层次
|
|
10
10
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 萧何 / Xiao He 0.6.0
|
|
2
|
+
|
|
3
|
+
## DSH 0.2.1-rc.2 兼容与 Handler 幂等约束
|
|
4
|
+
|
|
5
|
+
本版把兼容目标对齐到 DSH 0.2.1-rc.2,并在 core 层为扩展 Handler 增加可声明的幂等约束。
|
|
6
|
+
|
|
7
|
+
- 兼容目标升级为 DSH 0.2.1-rc.2:五个宿主 peer 依赖由 0.2.0-rc.2 升至 0.2.1-rc.2,锁文件重建。0.2.0-rc.2 宿主应继续使用 0.5.x。
|
|
8
|
+
- 新增 Handler.idempotent 声明。显式 idempotent:false 时,终态结果复用被拒绝并返回 MUTATING_REUSE_DENIED;运行中的重复 attach 仍只等待同一个执行,不会二次执行。省略该字段默认幂等,保持既有 handler 与调用方行为。
|
|
9
|
+
- 内置 test 与 host.read 显式声明 idempotent:true。
|
|
10
|
+
- 适配 0.2.1-rc.2 新增的 workingDirectory 服务:真实宿主组件测试为 read/run_code 路径注入最小 stub,不改变插件运行逻辑。
|
|
11
|
+
|
|
12
|
+
## 升级说明
|
|
13
|
+
|
|
14
|
+
需要 DSH 0.2.1-rc.2。升级前先停止新请求,等待已有任务完成或请求合作取消。本版不自动安装、重写日常配置或重启 DSH。
|
|
15
|
+
|
|
16
|
+
历史预设 execution-bus-test、配置行 preset-execution-bus-test、工具名、协议字段和既有错误码均不变;错误词汇仅新增 MUTATING_REUSE_DENIED。
|
|
17
|
+
|
|
18
|
+
## 验证与限制
|
|
19
|
+
|
|
20
|
+
本地全量 76 项测试通过(含新增幂等回归、真实宿主组件与 Node PTC 组件测试),包白名单校验通过。真实模型、桌面 UI 与实际沙箱仍未完整验收;状态仍为进程内存,不支持跨重启恢复。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feng0531/dsh-execution-bus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -52,25 +52,25 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@deepseek-ai/cordis": "~4.0.4",
|
|
54
54
|
"@deepseek-ai/cordis-plugin-include": "~1.0.9",
|
|
55
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.
|
|
56
|
-
"@deepseek-ai/dsh-jobs": "0.2.
|
|
57
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
58
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.
|
|
59
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
55
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-jobs": "0.2.1-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-scope": "0.2.1-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.
|
|
63
|
-
"@deepseek-ai/dsh-agent-preset": "0.2.
|
|
64
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.
|
|
65
|
-
"@deepseek-ai/dsh-agent-tool-presentation": "0.2.
|
|
66
|
-
"@deepseek-ai/dsh-fs-local": "0.2.
|
|
67
|
-
"@deepseek-ai/dsh-jobs": "0.2.
|
|
68
|
-
"@deepseek-ai/dsh-jobs-local": "0.2.
|
|
69
|
-
"@deepseek-ai/dsh-persona": "0.2.
|
|
70
|
-
"@deepseek-ai/dsh-ptc-runtime-node": "0.2.
|
|
71
|
-
"@deepseek-ai/dsh-subprocess-local": "0.2.
|
|
72
|
-
"@deepseek-ai/dsh-tool-fs": "0.2.
|
|
73
|
-
"@deepseek-ai/dsh-tool-jobs": "0.2.
|
|
62
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-agent-preset": "0.2.1-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-agent-tool-presentation": "0.2.1-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-fs-local": "0.2.1-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-jobs": "0.2.1-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-jobs-local": "0.2.1-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-persona": "0.2.1-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-ptc-runtime-node": "0.2.1-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.1-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-tool-fs": "0.2.1-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-tool-jobs": "0.2.1-rc.2",
|
|
74
74
|
"@types/js-yaml": "4.0.9",
|
|
75
75
|
"@types/node": "^22",
|
|
76
76
|
"prettier": "3.6.2",
|