@actiondock/core 2.6.0 → 2.8.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 +61 -68
- package/dist/catalog/action-catalog.d.ts +56 -0
- package/dist/catalog/action-catalog.js +202 -0
- package/dist/catalog/discovery.d.ts +60 -0
- package/dist/catalog/discovery.js +119 -0
- package/dist/catalog/graph.d.ts +190 -0
- package/dist/catalog/graph.js +589 -0
- package/dist/catalog/index.d.ts +5 -5
- package/dist/catalog/index.js +5 -5
- package/dist/catalog/resolve-action.d.ts +43 -0
- package/dist/catalog/resolve-action.js +119 -0
- package/dist/catalog/resolve-playbook.d.ts +26 -0
- package/dist/catalog/resolve-playbook.js +114 -0
- package/dist/doctor/checks/project.js +27 -8
- package/dist/doctor/checks/registry.js +2 -2
- package/dist/doctor/checks/runtime.js +34 -1
- package/dist/errors.d.ts +122 -10
- package/dist/errors.js +123 -10
- package/dist/execution/service.d.ts +18 -16
- package/dist/execution/service.js +183 -252
- package/dist/execution/types.d.ts +25 -69
- package/dist/execution/types.js +2 -1
- package/dist/filter/intent.d.ts +8 -9
- package/dist/filter/intent.js +49 -10
- package/dist/graph/index.d.ts +4 -0
- package/dist/graph/index.js +4 -0
- package/dist/host/host.d.ts +74 -32
- package/dist/host/host.js +585 -336
- package/dist/host/routing.d.ts +15 -48
- package/dist/host/routing.js +90 -153
- package/dist/host/types.d.ts +50 -17
- package/dist/index.d.ts +21 -22
- package/dist/index.js +19 -21
- package/dist/input/advice.d.ts +104 -0
- package/dist/input/advice.js +716 -0
- package/dist/input/describe.d.ts +106 -0
- package/dist/input/describe.js +176 -0
- package/dist/input/file-input.d.ts +54 -0
- package/dist/input/file-input.js +124 -0
- package/dist/input/flat-decode.d.ts +11 -0
- package/dist/input/flat-decode.js +13 -0
- package/dist/input/flat-errors.d.ts +71 -0
- package/dist/input/flat-errors.js +87 -0
- package/dist/input/flat-materializer.d.ts +29 -0
- package/dist/input/flat-materializer.js +177 -0
- package/dist/input/flat-parser.d.ts +50 -0
- package/dist/input/flat-parser.js +169 -0
- package/dist/input/flat-predicates.d.ts +34 -0
- package/dist/input/flat-predicates.js +50 -0
- package/dist/input/index.d.ts +14 -0
- package/dist/input/index.js +14 -0
- package/dist/input/input-resolver.d.ts +63 -0
- package/dist/input/input-resolver.js +254 -0
- package/dist/input/json-depth-scanner.d.ts +17 -0
- package/dist/input/json-depth-scanner.js +49 -0
- package/dist/input/metadata.d.ts +99 -0
- package/dist/input/metadata.js +99 -0
- package/dist/input/stdin-input.d.ts +26 -0
- package/dist/input/stdin-input.js +125 -0
- package/dist/input/utf8.d.ts +19 -0
- package/dist/input/utf8.js +36 -0
- package/dist/input/validation-mapper.d.ts +27 -0
- package/dist/input/validation-mapper.js +144 -0
- package/dist/invocation/index.d.ts +2 -0
- package/dist/invocation/index.js +2 -0
- package/dist/invocation/policy.d.ts +157 -0
- package/dist/invocation/policy.js +231 -0
- package/dist/invocation/types.d.ts +172 -0
- package/dist/invocation/types.js +97 -0
- package/dist/ipc/diagnostic.d.ts +0 -12
- package/dist/ipc/diagnostic.js +0 -21
- package/dist/ipc/host.d.ts +4 -4
- package/dist/ipc/host.js +44 -47
- package/dist/ipc/index.d.ts +1 -1
- package/dist/ipc/index.js +1 -1
- package/dist/ipc/service.d.ts +40 -0
- package/dist/ipc/service.js +349 -0
- package/dist/ipc/types.d.ts +21 -15
- package/dist/json/index.d.ts +1 -0
- package/dist/json/index.js +1 -0
- package/dist/json/value-validator.d.ts +88 -0
- package/dist/json/value-validator.js +330 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/module-loader.d.ts +63 -0
- package/dist/node/module-loader.js +112 -0
- package/dist/package/index.d.ts +23 -0
- package/dist/package/index.js +18 -0
- package/dist/{app/app.d.ts → package/runtime.d.ts} +41 -20
- package/dist/{app/app.js → package/runtime.js} +140 -95
- package/dist/{app → package}/static-index.js +58 -41
- package/dist/package/storage-view.d.ts +13 -0
- package/dist/package/storage-view.js +22 -0
- package/dist/{app → package}/types.d.ts +76 -57
- package/dist/package/types.js +22 -0
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/node.d.ts +48 -0
- package/dist/platform/node.js +96 -0
- package/dist/platform/types.d.ts +0 -9
- package/dist/process/control-arbiter.d.ts +2 -1
- package/dist/process/control-arbiter.js +1 -2
- package/dist/process/driver.d.ts +9 -8
- package/dist/process/driver.js +11 -22
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +2 -0
- package/dist/process/managed-record.d.ts +2 -2
- package/dist/process/process-driver.d.ts +109 -0
- package/dist/process/process-driver.js +650 -0
- package/dist/process/process-executor.d.ts +47 -0
- package/dist/process/process-executor.js +296 -0
- package/dist/process/process-manager.js +48 -26
- package/dist/process/run-executor.js +12 -12
- package/dist/profile/client-actions.js +2 -2
- package/dist/profile/client-health.js +3 -2
- package/dist/profile/client-query.js +5 -6
- package/dist/profile/client-transport.d.ts +19 -17
- package/dist/profile/client-transport.js +48 -80
- package/dist/profile/client.d.ts +2 -2
- package/dist/profile/client.js +1 -1
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile/index.js +1 -0
- package/dist/profile/manager.d.ts +5 -0
- package/dist/profile/manager.js +41 -6
- package/dist/project/closure.js +2 -2
- package/dist/project/index.d.ts +8 -1
- package/dist/project/index.js +10 -1
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +1 -1
- package/dist/project/loader.js +26 -29
- package/dist/project/transactions.js +5 -10
- package/dist/registry/index.d.ts +3 -1
- package/dist/registry/index.js +2 -1
- package/dist/registry/lock.d.ts +28 -7
- package/dist/registry/lock.js +136 -16
- package/dist/registry/registry.d.ts +1 -5
- package/dist/registry/registry.js +1 -53
- package/dist/registry/scan.d.ts +0 -15
- package/dist/registry/scan.js +0 -59
- package/dist/registry/store.d.ts +42 -0
- package/dist/registry/store.js +43 -0
- package/dist/registry/types.d.ts +0 -24
- package/dist/runtime/action-collection.d.ts +1 -1
- package/dist/runtime/action-registry.d.ts +0 -4
- package/dist/runtime/action-registry.js +0 -7
- package/dist/runtime/context.js +5 -11
- package/dist/runtime/events.js +3 -6
- package/dist/runtime/identity.d.ts +22 -0
- package/dist/runtime/identity.js +10 -0
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +1 -2
- package/dist/runtime/module-loader.d.ts +2 -34
- package/dist/runtime/module-loader.js +1 -16
- package/dist/runtime/process.d.ts +6 -24
- package/dist/runtime/process.js +1 -118
- package/dist/runtime/run-persistence.js +2 -5
- package/dist/runtime/runner.d.ts +33 -103
- package/dist/runtime/runner.js +142 -404
- package/dist/runtime/standalone.d.ts +37 -9
- package/dist/runtime/standalone.js +195 -136
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/validator.d.ts +10 -0
- package/dist/schema/validator.js +48 -54
- package/dist/server/body.d.ts +16 -8
- package/dist/server/body.js +33 -16
- package/dist/server/dispatcher.d.ts +6 -10
- package/dist/server/dispatcher.js +24 -32
- package/dist/server/http-server.d.ts +87 -0
- package/dist/server/http-server.js +304 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +10 -0
- package/dist/server/mcp-endpoint.d.ts +61 -0
- package/dist/server/mcp-endpoint.js +118 -0
- package/dist/server/routes/actions.js +34 -28
- package/dist/server/routes/common.d.ts +10 -14
- package/dist/server/routes/common.js +32 -56
- package/dist/server/routes/config.js +54 -64
- package/dist/server/routes/doctor.d.ts +1 -1
- package/dist/server/routes/doctor.js +10 -18
- package/dist/server/routes/health.d.ts +1 -1
- package/dist/server/routes/health.js +2 -3
- package/dist/server/routes/info.d.ts +2 -2
- package/dist/server/routes/info.js +12 -13
- package/dist/server/routes/playbooks.js +16 -29
- package/dist/server/routes/runs.js +95 -117
- package/dist/server/routes/state.js +63 -62
- package/dist/server/server.d.ts +2 -2
- package/dist/server/server.js +43 -227
- package/dist/server/types.d.ts +8 -19
- package/dist/service/factory.d.ts +12 -0
- package/dist/service/factory.js +85 -0
- package/dist/{target → service}/index.d.ts +1 -1
- package/dist/{target → service}/index.js +1 -1
- package/dist/service/local.d.ts +27 -0
- package/dist/service/local.js +138 -0
- package/dist/{target → service}/remote-errors.d.ts +3 -6
- package/dist/service/remote-errors.js +38 -0
- package/dist/{target → service}/remote-polling.d.ts +2 -2
- package/dist/{target → service}/remote-polling.js +8 -8
- package/dist/service/remote.d.ts +34 -0
- package/dist/service/remote.js +634 -0
- package/dist/service/sse-stream.d.ts +24 -0
- package/dist/service/sse-stream.js +139 -0
- package/dist/service/types.d.ts +272 -0
- package/dist/service/types.js +32 -0
- package/dist/storage/data-dir-lock.js +10 -5
- package/dist/storage/driver.d.ts +2 -1
- package/dist/storage/driver.js +3 -52
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/lock-core.d.ts +2 -6
- package/dist/storage/lock-core.js +4 -17
- package/dist/storage/params.d.ts +2 -8
- package/dist/storage/params.js +2 -8
- package/dist/storage/sqlite-driver.d.ts +40 -0
- package/dist/storage/sqlite-driver.js +116 -0
- package/dist/storage/sqlite.js +21 -6
- package/dist/storage/types.d.ts +4 -4
- package/dist/storage/types.js +2 -2
- package/dist/utils/index.d.ts +53 -0
- package/dist/utils/index.js +99 -4
- package/dist/utils/process.d.ts +10 -0
- package/dist/utils/process.js +21 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +41 -3
- package/dist/app/index.d.ts +0 -2
- package/dist/app/index.js +0 -2
- package/dist/app/types.js +0 -1
- package/dist/catalog/action-index.d.ts +0 -9
- package/dist/catalog/action-index.js +0 -95
- package/dist/catalog/action-resolver.d.ts +0 -20
- package/dist/catalog/action-resolver.js +0 -95
- package/dist/catalog/location-registry.d.ts +0 -15
- package/dist/catalog/location-registry.js +0 -138
- package/dist/catalog/package-catalog.d.ts +0 -7
- package/dist/catalog/package-catalog.js +0 -77
- package/dist/catalog/types.d.ts +0 -68
- package/dist/catalog/types.js +0 -1
- package/dist/export/index.d.ts +0 -1
- package/dist/export/index.js +0 -1
- package/dist/export/templates.d.ts +0 -71
- package/dist/export/templates.js +0 -623
- package/dist/ipc/target.d.ts +0 -74
- package/dist/ipc/target.js +0 -365
- package/dist/platform/default.d.ts +0 -38
- package/dist/platform/default.js +0 -78
- package/dist/project/resolver.d.ts +0 -116
- package/dist/project/resolver.js +0 -376
- package/dist/registry/resolve.d.ts +0 -62
- package/dist/registry/resolve.js +0 -195
- package/dist/runtime/execution-manager.d.ts +0 -48
- package/dist/runtime/execution-manager.js +0 -66
- package/dist/runtime/package-runner-factory.d.ts +0 -82
- package/dist/runtime/package-runner-factory.js +0 -186
- package/dist/target/local.d.ts +0 -53
- package/dist/target/local.js +0 -349
- package/dist/target/remote-errors.js +0 -51
- package/dist/target/remote.d.ts +0 -86
- package/dist/target/remote.js +0 -818
- package/dist/target/target.d.ts +0 -6
- package/dist/target/target.js +0 -37
- package/dist/target/types.d.ts +0 -261
- package/dist/target/types.js +0 -35
- /package/dist/{app → package}/static-index.d.ts +0 -0
- /package/dist/{target → service}/sse-parser.d.ts +0 -0
- /package/dist/{target → service}/sse-parser.js +0 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { isForbiddenActionInputPropertyName } from "../input/flat-predicates.js";
|
|
2
|
+
/** 默认 JSON 最大嵌套深度限制(防止恶意超深结构) */
|
|
3
|
+
export const DEFAULT_MAX_JSON_DEPTH = 256;
|
|
4
|
+
/**
|
|
5
|
+
* 按照 RFC 6901 转义单个 JSON Pointer 路径段。
|
|
6
|
+
*
|
|
7
|
+
* @param segment 路径段(属性名或数组索引)
|
|
8
|
+
* @returns 转义后的路径段
|
|
9
|
+
*/
|
|
10
|
+
export function escapeJsonPointerSegment(segment) {
|
|
11
|
+
return String(segment).replace(/~/g, "~0").replace(/\//g, "~1");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 将路径段追加到基础 RFC 6901 JSON Pointer 路径后。
|
|
15
|
+
*
|
|
16
|
+
* @param basePath 基础路径
|
|
17
|
+
* @param segment 待追加的路径段
|
|
18
|
+
* @returns 拼接后的 JSON Pointer
|
|
19
|
+
*/
|
|
20
|
+
export function appendJsonPointer(basePath, segment) {
|
|
21
|
+
return `${basePath}/${escapeJsonPointerSegment(segment)}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 内部统一 JSON 值与输入策略遍历校验引擎。
|
|
25
|
+
*
|
|
26
|
+
* 遍历规范:
|
|
27
|
+
* - 迭代式显式栈遍历:模拟调用栈,杜绝深层结构造成的堆栈溢出。
|
|
28
|
+
* - 严格数值有限性:全链路检查所有数值满足 Number.isFinite,拦截 NaN 与 Infinity。
|
|
29
|
+
* - 活跃祖先集合环路检测:仅在当前子树遍历期间在祖先集合中保留,完美放行有向无环(DAG)共享子结构。
|
|
30
|
+
* - 严格对象与原型校验:仅允许 Object.prototype 与 null 原型,拒绝 Date、Map、Set 等非纯数据对象与类实例。
|
|
31
|
+
* - 严格数组紧凑性:校验 0..length-1 全部存在,拒绝稀疏数组、额外属性与访问器元素。
|
|
32
|
+
* - Proxy 异常防御:对所有反射与属性检查执行防护拦截,杜绝未分类异常泄漏。
|
|
33
|
+
* - RFC 6901 路径追踪:全链路维护转义标准 JSON Pointer 路径。
|
|
34
|
+
*/
|
|
35
|
+
function walkJsonValue(value, options, checkForbiddenProperties = false) {
|
|
36
|
+
const maxDepth = options?.maxDepth ?? DEFAULT_MAX_JSON_DEPTH;
|
|
37
|
+
const ancestors = new Set();
|
|
38
|
+
const stack = [{ type: "ENTER", value, depth: 0, path: "" }];
|
|
39
|
+
while (stack.length > 0) {
|
|
40
|
+
const frame = stack.pop();
|
|
41
|
+
if (frame.type === "EXIT") {
|
|
42
|
+
ancestors.delete(frame.target);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const { value: val, depth, path } = frame;
|
|
46
|
+
if (val === null || typeof val === "boolean" || typeof val === "string") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (typeof val === "number") {
|
|
50
|
+
if (!Number.isFinite(val) || Number.isNaN(val)) {
|
|
51
|
+
return {
|
|
52
|
+
valid: false,
|
|
53
|
+
kind: "json-value",
|
|
54
|
+
code: "NON_FINITE_NUMBER",
|
|
55
|
+
reason: `Number is non-finite or NaN (${val})`,
|
|
56
|
+
path,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (typeof val === "undefined") {
|
|
62
|
+
return {
|
|
63
|
+
valid: false,
|
|
64
|
+
kind: "json-value",
|
|
65
|
+
code: "UNDEFINED_JSON_VALUE",
|
|
66
|
+
reason: "Undefined value is not allowed in JSON",
|
|
67
|
+
path,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (typeof val === "function" ||
|
|
71
|
+
typeof val === "symbol" ||
|
|
72
|
+
typeof val === "bigint") {
|
|
73
|
+
return {
|
|
74
|
+
valid: false,
|
|
75
|
+
kind: "json-value",
|
|
76
|
+
code: "UNSUPPORTED_JSON_TYPE",
|
|
77
|
+
reason: `Unsupported JSON type '${typeof val}'`,
|
|
78
|
+
path,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (typeof val === "object") {
|
|
82
|
+
try {
|
|
83
|
+
if (ancestors.has(val)) {
|
|
84
|
+
return {
|
|
85
|
+
valid: false,
|
|
86
|
+
kind: "json-value",
|
|
87
|
+
code: "CIRCULAR_REFERENCE",
|
|
88
|
+
reason: "Circular reference detected in object structure",
|
|
89
|
+
path,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (depth > maxDepth) {
|
|
93
|
+
return {
|
|
94
|
+
valid: false,
|
|
95
|
+
kind: "json-value",
|
|
96
|
+
code: "MAX_JSON_DEPTH",
|
|
97
|
+
reason: `Max JSON depth limit (${maxDepth}) exceeded`,
|
|
98
|
+
path,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const proto = Object.getPrototypeOf(val);
|
|
102
|
+
const isArr = Array.isArray(val);
|
|
103
|
+
if (isArr) {
|
|
104
|
+
if (proto !== Array.prototype) {
|
|
105
|
+
return {
|
|
106
|
+
valid: false,
|
|
107
|
+
kind: "json-value",
|
|
108
|
+
code: "INVALID_JSON_OBJECT",
|
|
109
|
+
reason: "Array prototype must be Array.prototype",
|
|
110
|
+
path,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const len = val.length;
|
|
114
|
+
if (typeof len !== "number" ||
|
|
115
|
+
!Number.isInteger(len) ||
|
|
116
|
+
len < 0 ||
|
|
117
|
+
len > Number.MAX_SAFE_INTEGER) {
|
|
118
|
+
return {
|
|
119
|
+
valid: false,
|
|
120
|
+
kind: "json-value",
|
|
121
|
+
code: "INVALID_JSON_OBJECT",
|
|
122
|
+
reason: "Array length is invalid",
|
|
123
|
+
path,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const ownKeys = Reflect.ownKeys(val);
|
|
127
|
+
if (ownKeys.length !== len + 1) {
|
|
128
|
+
return {
|
|
129
|
+
valid: false,
|
|
130
|
+
kind: "json-value",
|
|
131
|
+
code: "INVALID_JSON_OBJECT",
|
|
132
|
+
reason: "Array must be dense without extra properties or holes",
|
|
133
|
+
path,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
ancestors.add(val);
|
|
137
|
+
stack.push({ type: "EXIT", target: val });
|
|
138
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
139
|
+
const keyStr = String(i);
|
|
140
|
+
const desc = Object.getOwnPropertyDescriptor(val, keyStr);
|
|
141
|
+
const elemPath = appendJsonPointer(path, i);
|
|
142
|
+
if (!desc) {
|
|
143
|
+
return {
|
|
144
|
+
valid: false,
|
|
145
|
+
kind: "json-value",
|
|
146
|
+
code: "INVALID_JSON_OBJECT",
|
|
147
|
+
reason: `Sparse array (missing element at index ${i})`,
|
|
148
|
+
path: elemPath,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (desc.get !== undefined || desc.set !== undefined) {
|
|
152
|
+
return {
|
|
153
|
+
valid: false,
|
|
154
|
+
kind: "json-value",
|
|
155
|
+
code: "INVALID_JSON_OBJECT",
|
|
156
|
+
reason: `Accessor property not allowed at array index ${i}`,
|
|
157
|
+
path: elemPath,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (!desc.enumerable) {
|
|
161
|
+
return {
|
|
162
|
+
valid: false,
|
|
163
|
+
kind: "json-value",
|
|
164
|
+
code: "INVALID_JSON_OBJECT",
|
|
165
|
+
reason: `Non-enumerable property not allowed at array index ${i}`,
|
|
166
|
+
path: elemPath,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (desc.value === undefined) {
|
|
170
|
+
return {
|
|
171
|
+
valid: false,
|
|
172
|
+
kind: "json-value",
|
|
173
|
+
code: "UNDEFINED_JSON_VALUE",
|
|
174
|
+
reason: `Undefined value is not allowed at array index ${i}`,
|
|
175
|
+
path: elemPath,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
stack.push({
|
|
179
|
+
type: "ENTER",
|
|
180
|
+
value: desc.value,
|
|
181
|
+
depth: depth + 1,
|
|
182
|
+
path: elemPath,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
188
|
+
return {
|
|
189
|
+
valid: false,
|
|
190
|
+
kind: "json-value",
|
|
191
|
+
code: "INVALID_JSON_OBJECT",
|
|
192
|
+
reason: "Object prototype must be Object.prototype or null",
|
|
193
|
+
path,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const ownKeys = Reflect.ownKeys(val);
|
|
197
|
+
ancestors.add(val);
|
|
198
|
+
stack.push({ type: "EXIT", target: val });
|
|
199
|
+
for (let i = ownKeys.length - 1; i >= 0; i--) {
|
|
200
|
+
const key = ownKeys[i];
|
|
201
|
+
if (typeof key !== "string") {
|
|
202
|
+
return {
|
|
203
|
+
valid: false,
|
|
204
|
+
kind: "json-value",
|
|
205
|
+
code: "INVALID_JSON_OBJECT",
|
|
206
|
+
reason: "Symbol-keyed properties are not allowed in JSON object",
|
|
207
|
+
path: appendJsonPointer(path, String(key)),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const propPath = appendJsonPointer(path, key);
|
|
211
|
+
if (checkForbiddenProperties &&
|
|
212
|
+
isForbiddenActionInputPropertyName(key)) {
|
|
213
|
+
return {
|
|
214
|
+
valid: false,
|
|
215
|
+
kind: "input-policy",
|
|
216
|
+
code: "FORBIDDEN_PROPERTY",
|
|
217
|
+
property: key,
|
|
218
|
+
path: propPath,
|
|
219
|
+
reason: `Forbidden property "${key}" is not allowed in Action input`,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const desc = Object.getOwnPropertyDescriptor(val, key);
|
|
223
|
+
if (!desc) {
|
|
224
|
+
return {
|
|
225
|
+
valid: false,
|
|
226
|
+
kind: "json-value",
|
|
227
|
+
code: "INVALID_JSON_OBJECT",
|
|
228
|
+
reason: `Property descriptor missing for key "${key}"`,
|
|
229
|
+
path: propPath,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (desc.get !== undefined || desc.set !== undefined) {
|
|
233
|
+
return {
|
|
234
|
+
valid: false,
|
|
235
|
+
kind: "json-value",
|
|
236
|
+
code: "INVALID_JSON_OBJECT",
|
|
237
|
+
reason: `Accessor properties (getters/setters) are not allowed for key "${key}"`,
|
|
238
|
+
path: propPath,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (!desc.enumerable) {
|
|
242
|
+
return {
|
|
243
|
+
valid: false,
|
|
244
|
+
kind: "json-value",
|
|
245
|
+
code: "INVALID_JSON_OBJECT",
|
|
246
|
+
reason: `Non-enumerable properties are not allowed for key "${key}"`,
|
|
247
|
+
path: propPath,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (desc.value === undefined) {
|
|
251
|
+
return {
|
|
252
|
+
valid: false,
|
|
253
|
+
kind: "json-value",
|
|
254
|
+
code: "UNDEFINED_JSON_VALUE",
|
|
255
|
+
reason: `Undefined value is not allowed for key "${key}"`,
|
|
256
|
+
path: propPath,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
stack.push({
|
|
260
|
+
type: "ENTER",
|
|
261
|
+
value: desc.value,
|
|
262
|
+
depth: depth + 1,
|
|
263
|
+
path: propPath,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
return {
|
|
270
|
+
valid: false,
|
|
271
|
+
kind: "json-value",
|
|
272
|
+
code: "INVALID_JSON_OBJECT",
|
|
273
|
+
reason: `Failed to inspect object: ${err instanceof Error ? err.message : String(err)}`,
|
|
274
|
+
path,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return { valid: true };
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 校验值是否为合法的 Canonical JSON 兼容结构。
|
|
283
|
+
*
|
|
284
|
+
* @param value 待校验的目标值
|
|
285
|
+
* @param options 校验配置选项
|
|
286
|
+
* @returns 校验结果对象
|
|
287
|
+
*/
|
|
288
|
+
export function validateJsonValue(value, options) {
|
|
289
|
+
const res = walkJsonValue(value, options, false);
|
|
290
|
+
if (res.valid) {
|
|
291
|
+
return { valid: true };
|
|
292
|
+
}
|
|
293
|
+
if (res.kind === "input-policy") {
|
|
294
|
+
return {
|
|
295
|
+
valid: false,
|
|
296
|
+
code: "INVALID_JSON_OBJECT",
|
|
297
|
+
reason: res.reason,
|
|
298
|
+
path: res.path,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
valid: false,
|
|
303
|
+
code: res.code,
|
|
304
|
+
reason: res.reason,
|
|
305
|
+
path: res.path,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* 校验 Action 输入值是否满足 Canonical JsonValue 规范且符合 ActionDock 安全策略。
|
|
310
|
+
* 在遍历过程中递归检查是否存在禁止属性(__proto__、constructor、prototype)。
|
|
311
|
+
*
|
|
312
|
+
* @param value 待校验的 Action 输入值
|
|
313
|
+
* @param options 校验配置选项
|
|
314
|
+
* @returns 校验结果对象
|
|
315
|
+
*/
|
|
316
|
+
export function validateActionInputValue(value, options) {
|
|
317
|
+
return walkJsonValue(value, options, true);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 断言值必须为合法的 Canonical JSON 兼容结构,若非法则抛出 TypeError。
|
|
321
|
+
*
|
|
322
|
+
* @param value 待断言的目标值
|
|
323
|
+
* @param options 校验配置选项
|
|
324
|
+
*/
|
|
325
|
+
export function assertJsonValue(value, options) {
|
|
326
|
+
const result = validateJsonValue(value, options);
|
|
327
|
+
if (!result.valid) {
|
|
328
|
+
throw new TypeError(`Invalid JSON value: ${result.reason}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./module-loader.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./module-loader.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一源码模块加载器接口。
|
|
3
|
+
* 解耦 Action 与各类扩展模块的具体加载机制(如 ECMAScript 原生 import、tsx 动态转译加载等)。
|
|
4
|
+
*/
|
|
5
|
+
export interface ModuleLoader {
|
|
6
|
+
/**
|
|
7
|
+
* 解析模块标识符为绝对路径或完整 URL。
|
|
8
|
+
*
|
|
9
|
+
* @param specifier 模块规范说明符或物理路径
|
|
10
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
11
|
+
*/
|
|
12
|
+
resolve?(specifier: string, parentPath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 动态加载模块并返回命名空间全量导出对象。
|
|
15
|
+
*
|
|
16
|
+
* @param specifier 模块规范说明符或物理路径
|
|
17
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
18
|
+
*/
|
|
19
|
+
load<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* 加载模块并解包其默认导出(default 或 action 属性)。
|
|
22
|
+
*
|
|
23
|
+
* @param specifier 模块规范说明符或物理路径
|
|
24
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
25
|
+
*/
|
|
26
|
+
loadDefault?<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 解包模块的默认导出对象,优先获取 default 或 action,自动解开嵌套互操作对象。
|
|
30
|
+
*
|
|
31
|
+
* @param moduleExports 待解包的模块导出对象
|
|
32
|
+
*/
|
|
33
|
+
export declare function unwrapDefaultExport<T = any>(moduleExports: any): T;
|
|
34
|
+
/**
|
|
35
|
+
* 基于 Node.js 原生 ESM 动态 import 的源码模块加载器。
|
|
36
|
+
* 遵循 Node 原生模块规范:
|
|
37
|
+
* - 严格要求显式入口扩展名(.ts, .mts, .js, .mjs)
|
|
38
|
+
* - 彻底拒绝无扩展名自动推断与 CommonJS 目录索引解析
|
|
39
|
+
* - 完全移除第三方转译运行时依赖
|
|
40
|
+
*/
|
|
41
|
+
export declare class NodeModuleLoader implements ModuleLoader {
|
|
42
|
+
/**
|
|
43
|
+
* 解析模块标识符与路径,严格要求显式扩展名且拒绝目录补全。
|
|
44
|
+
*
|
|
45
|
+
* @param specifier 模块规范说明符或相对/绝对物理路径
|
|
46
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
47
|
+
*/
|
|
48
|
+
resolve(specifier: string, parentPath?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* 基于 Node 原生 ESM 动态 import 加载模块并返回其全量导出对象。
|
|
51
|
+
*
|
|
52
|
+
* @param specifier 模块规范说明符或物理路径
|
|
53
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
54
|
+
*/
|
|
55
|
+
load<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
56
|
+
/**
|
|
57
|
+
* 加载模块并解包其默认导出(default 或 action)。
|
|
58
|
+
*
|
|
59
|
+
* @param specifier 模块规范说明符或物理路径
|
|
60
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
61
|
+
*/
|
|
62
|
+
loadDefault<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, extname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { ActionDockError, ACTION_LOAD_FAILED } from "../errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* Node 原生 TypeScript 与 ESM 模块支持的扩展名集合。
|
|
7
|
+
*/
|
|
8
|
+
const ALLOWED_EXTENSIONS = new Set([".ts", ".mts", ".js", ".mjs"]);
|
|
9
|
+
/**
|
|
10
|
+
* 解包模块的默认导出对象,优先获取 default 或 action,自动解开嵌套互操作对象。
|
|
11
|
+
*
|
|
12
|
+
* @param moduleExports 待解包的模块导出对象
|
|
13
|
+
*/
|
|
14
|
+
export function unwrapDefaultExport(moduleExports) {
|
|
15
|
+
if (moduleExports === null || moduleExports === undefined) {
|
|
16
|
+
return moduleExports;
|
|
17
|
+
}
|
|
18
|
+
let target = moduleExports.default !== undefined
|
|
19
|
+
? moduleExports.default
|
|
20
|
+
: moduleExports.action !== undefined
|
|
21
|
+
? moduleExports.action
|
|
22
|
+
: moduleExports;
|
|
23
|
+
if (target &&
|
|
24
|
+
typeof target === "object" &&
|
|
25
|
+
"default" in target &&
|
|
26
|
+
Object.keys(target).length === 1) {
|
|
27
|
+
target = target.default;
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 基于 Node.js 原生 ESM 动态 import 的源码模块加载器。
|
|
33
|
+
* 遵循 Node 原生模块规范:
|
|
34
|
+
* - 严格要求显式入口扩展名(.ts, .mts, .js, .mjs)
|
|
35
|
+
* - 彻底拒绝无扩展名自动推断与 CommonJS 目录索引解析
|
|
36
|
+
* - 完全移除第三方转译运行时依赖
|
|
37
|
+
*/
|
|
38
|
+
export class NodeModuleLoader {
|
|
39
|
+
/**
|
|
40
|
+
* 解析模块标识符与路径,严格要求显式扩展名且拒绝目录补全。
|
|
41
|
+
*
|
|
42
|
+
* @param specifier 模块规范说明符或相对/绝对物理路径
|
|
43
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
44
|
+
*/
|
|
45
|
+
resolve(specifier, parentPath) {
|
|
46
|
+
let target = specifier;
|
|
47
|
+
if (target.startsWith("file://")) {
|
|
48
|
+
target = fileURLToPath(target);
|
|
49
|
+
}
|
|
50
|
+
let baseDir = process.cwd();
|
|
51
|
+
if (parentPath) {
|
|
52
|
+
try {
|
|
53
|
+
const p = parentPath.startsWith("file://")
|
|
54
|
+
? fileURLToPath(parentPath)
|
|
55
|
+
: parentPath;
|
|
56
|
+
if (existsSync(p)) {
|
|
57
|
+
const stat = statSync(p);
|
|
58
|
+
baseDir = stat.isDirectory() ? resolve(p) : dirname(resolve(p));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
baseDir = dirname(resolve(p));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
baseDir = process.cwd();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const candidateBasePath = isAbsolute(target) ? target : resolve(baseDir, target);
|
|
69
|
+
const ext = extname(candidateBasePath);
|
|
70
|
+
if (!ext) {
|
|
71
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': missing file extension. Explicit .ts, .mts, .js, or .mjs extension is required.`);
|
|
72
|
+
}
|
|
73
|
+
if (!ALLOWED_EXTENSIONS.has(ext)) {
|
|
74
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': unsupported extension '${ext}'. Only .ts, .mts, .js, and .mjs are supported.`);
|
|
75
|
+
}
|
|
76
|
+
if (!existsSync(candidateBasePath)) {
|
|
77
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': file not found`);
|
|
78
|
+
}
|
|
79
|
+
let stat;
|
|
80
|
+
try {
|
|
81
|
+
stat = statSync(candidateBasePath);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
throw new ActionDockError(ACTION_LOAD_FAILED, `Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
if (!stat.isFile()) {
|
|
87
|
+
throw new ActionDockError(ACTION_LOAD_FAILED, `Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': path is not a file`);
|
|
88
|
+
}
|
|
89
|
+
return candidateBasePath;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 基于 Node 原生 ESM 动态 import 加载模块并返回其全量导出对象。
|
|
93
|
+
*
|
|
94
|
+
* @param specifier 模块规范说明符或物理路径
|
|
95
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
96
|
+
*/
|
|
97
|
+
async load(specifier, parentPath) {
|
|
98
|
+
const resolvedPath = this.resolve(specifier, parentPath);
|
|
99
|
+
const fileUrl = pathToFileURL(resolvedPath).href;
|
|
100
|
+
return (await import(fileUrl));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 加载模块并解包其默认导出(default 或 action)。
|
|
104
|
+
*
|
|
105
|
+
* @param specifier 模块规范说明符或物理路径
|
|
106
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
107
|
+
*/
|
|
108
|
+
async loadDefault(specifier, parentPath) {
|
|
109
|
+
const mod = await this.load(specifier, parentPath);
|
|
110
|
+
return unwrapDefaultExport(mod);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionDock 包级运行时必要门面与契约。
|
|
3
|
+
*
|
|
4
|
+
* 遵循 Minimal 暴露准则:仅对外输出 PackageRuntime、PackageRuntimeOptions、
|
|
5
|
+
* createPackageRuntime 以及包与动作元数据契约(PackageInfo、ActionSpec、ActionSummary、
|
|
6
|
+
* PlaybookSpec、PlaybookSummary)。
|
|
7
|
+
* 底层存储驱动、独立分发器与平台大对象统一由核心根入口导出。
|
|
8
|
+
*/
|
|
9
|
+
export { createPackageRuntime, DefaultPackageRuntime, } from "./runtime.js";
|
|
10
|
+
export { createNonClosingStorageView } from "./storage-view.js";
|
|
11
|
+
export { findExecutable } from "../utils/index.js";
|
|
12
|
+
export type { PackageRuntime, PackageRuntimeOptions, PackageInfo, ActionSpec, ActionSummary, PlaybookSpec, PlaybookSummary, } from "./types.js";
|
|
13
|
+
export type { RuntimePlatform, FileSystem, StorageFactory, StorageFactoryOptions, GlobalStorageFactoryOptions, } from "../platform/types.js";
|
|
14
|
+
export { type Clock, SystemClock, } from "../runtime/clock.js";
|
|
15
|
+
export type { ModuleLoader } from "../node/module-loader.js";
|
|
16
|
+
export { InMemoryEventSink, type EventSink, } from "../runtime/events.js";
|
|
17
|
+
export { ProcessManager, type ProcessOwner, } from "../process/process-manager.js";
|
|
18
|
+
export type { ProcessExecutor } from "../runtime/process.js";
|
|
19
|
+
export { NodeProcessExecutor } from "../process/process-executor.js";
|
|
20
|
+
export type { ProcessDriver, ProcessDriverCallbacks, ProcessDriverHandle, ProcessHandle, ProcessObserver, } from "../process/driver.js";
|
|
21
|
+
export { createStorage, resolveDatabasePath, } from "../storage/index.js";
|
|
22
|
+
export { SqliteRuntimeStorage } from "../storage/sqlite.js";
|
|
23
|
+
export type { RuntimeStorage, SqliteDriver, StateEntry, } from "../storage/types.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionDock 包级运行时必要门面与契约。
|
|
3
|
+
*
|
|
4
|
+
* 遵循 Minimal 暴露准则:仅对外输出 PackageRuntime、PackageRuntimeOptions、
|
|
5
|
+
* createPackageRuntime 以及包与动作元数据契约(PackageInfo、ActionSpec、ActionSummary、
|
|
6
|
+
* PlaybookSpec、PlaybookSummary)。
|
|
7
|
+
* 底层存储驱动、独立分发器与平台大对象统一由核心根入口导出。
|
|
8
|
+
*/
|
|
9
|
+
export { createPackageRuntime, DefaultPackageRuntime, } from "./runtime.js";
|
|
10
|
+
export { createNonClosingStorageView } from "./storage-view.js";
|
|
11
|
+
export { findExecutable } from "../utils/index.js";
|
|
12
|
+
export { SystemClock, } from "../runtime/clock.js";
|
|
13
|
+
export { InMemoryEventSink, } from "../runtime/events.js";
|
|
14
|
+
export { ProcessManager, } from "../process/process-manager.js";
|
|
15
|
+
export { NodeProcessExecutor } from "../process/process-executor.js";
|
|
16
|
+
// 存储契约与驱动
|
|
17
|
+
export { createStorage, resolveDatabasePath, } from "../storage/index.js";
|
|
18
|
+
export { SqliteRuntimeStorage } from "../storage/sqlite.js";
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import { type RuntimePlatform } from "../platform/index.js";
|
|
1
|
+
import type { ExecutionEvent, ExecutionResult, JsonValue, RunRecord } from "@actiondock/sdk";
|
|
2
|
+
import type { ActionInvoker, CancelResult, ExecutionTicket } from "../execution/types.js";
|
|
4
3
|
import type { ProjectConfig } from "../project/types.js";
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
4
|
+
import { type PackageIdentity } from "../runtime/identity.js";
|
|
5
|
+
import { type InvocationContext, type RunOptions } from "../invocation/types.js";
|
|
6
|
+
import type { ActionSpec, ActionSummary, ConfigValueView, HostManagedPackageRuntime, ListActionsOptions, ListRunsOptions, PackageInfo, PackageRuntime, PackageRuntimeOptions, PackageRuntimeInternalOptions, PlaybookSpec, PlaybookSummary, StateScopeOptions } from "./types.js";
|
|
7
7
|
/**
|
|
8
|
-
* ActionDock
|
|
8
|
+
* ActionDock 统一包运行时默认实现。
|
|
9
9
|
* 封装并管理单个 Action Package 的执行引擎、静态元数据索引、配置与状态存储生命周期。
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class DefaultPackageRuntime implements HostManagedPackageRuntime {
|
|
12
|
+
readonly identity: PackageIdentity;
|
|
12
13
|
readonly packageId: string;
|
|
13
14
|
readonly packageInstanceId: string;
|
|
14
15
|
readonly generationId: string;
|
|
15
16
|
readonly packageRoot?: string;
|
|
16
17
|
readonly projectConfig: ProjectConfig;
|
|
17
|
-
readonly platform
|
|
18
|
-
readonly storage
|
|
19
|
-
readonly globalStorage
|
|
20
|
-
readonly executionService
|
|
21
|
-
readonly actionsMap
|
|
18
|
+
private readonly platform;
|
|
19
|
+
private readonly storage;
|
|
20
|
+
private readonly globalStorage?;
|
|
21
|
+
private readonly executionService;
|
|
22
|
+
private readonly actionsMap;
|
|
22
23
|
private readonly options;
|
|
23
24
|
private runtimeConfig;
|
|
24
25
|
private isClosed;
|
|
26
|
+
private injectedGlobalStorage;
|
|
25
27
|
/** 静态清单索引缓存:包静态事实(根目录、配置、内存注入集合)在实例生命周期内不变,解析结果同实例内复用 */
|
|
26
28
|
private staticActionIndex?;
|
|
27
29
|
private staticPlaybookIndex?;
|
|
28
|
-
constructor(options?:
|
|
30
|
+
constructor(options?: PackageRuntimeInternalOptions);
|
|
29
31
|
/**
|
|
30
32
|
* 静态读取并聚合当前包的 Action 规范索引。
|
|
31
33
|
* 聚合逻辑委托 static-index 单一事实源;同实例内复用首次解析结果,
|
|
@@ -44,8 +46,10 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
44
46
|
describeAction(id: string): Promise<ActionSpec>;
|
|
45
47
|
listPlaybooks(): Promise<PlaybookSummary[]>;
|
|
46
48
|
describePlaybook(id: string): Promise<PlaybookSpec>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
private buildRootInvocationContext;
|
|
50
|
+
runAction(id: string, input: JsonValue, options?: RunOptions): Promise<ExecutionResult>;
|
|
51
|
+
startAction(id: string, input: JsonValue, options?: RunOptions): Promise<ExecutionTicket>;
|
|
52
|
+
startInvocation(actionId: string, input: JsonValue, context: InvocationContext): Promise<ExecutionTicket>;
|
|
49
53
|
getRun(runId: string): Promise<RunRecord | undefined>;
|
|
50
54
|
cancelRun(runId: string, reason?: string): Promise<CancelResult>;
|
|
51
55
|
events(runId: string, options?: {
|
|
@@ -53,6 +57,8 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
53
57
|
signal?: AbortSignal;
|
|
54
58
|
maxQueueSize?: number;
|
|
55
59
|
}): AsyncIterable<ExecutionEvent>;
|
|
60
|
+
setActionInvoker(invoker?: ActionInvoker): void;
|
|
61
|
+
recoverDeadSessionRuns(sessionId?: string): void;
|
|
56
62
|
listConfig(): Promise<ConfigValueView[]>;
|
|
57
63
|
getConfig(key: string): Promise<ConfigValueView>;
|
|
58
64
|
setConfig(key: string, value: JsonValue): Promise<void>;
|
|
@@ -60,11 +66,20 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
60
66
|
/**
|
|
61
67
|
* 状态作用域统一解析辅助函数(单一事实源)。
|
|
62
68
|
*
|
|
63
|
-
*
|
|
64
|
-
* - actionId
|
|
65
|
-
* -
|
|
69
|
+
* 完成重载消歧后委托 mergeStateScope 计算最终生效的命名空间:
|
|
70
|
+
* - (actionId, key, options) 形态:位置 actionId 参与冲突校验;
|
|
71
|
+
* - (key, options) 扁平形态:首参是状态键,options.actionId 属合法显式指定。
|
|
66
72
|
*/
|
|
67
73
|
private resolveStateScope;
|
|
74
|
+
/**
|
|
75
|
+
* 合并位置 actionId 与 options.actionId 并计算最终命名空间(单一事实源)。
|
|
76
|
+
*
|
|
77
|
+
* - positionalActionId 非 undefined:调用形态携带位置 actionId,
|
|
78
|
+
* options.actionId 与其冲突时抛出异常(空串同样参与冲突校验);
|
|
79
|
+
* - positionalActionId 为 undefined:无位置 actionId 的扁平调用形态,
|
|
80
|
+
* options.actionId 属合法显式指定,直接采纳。
|
|
81
|
+
*/
|
|
82
|
+
private mergeStateScope;
|
|
68
83
|
getState<T extends JsonValue = JsonValue>(key: string, options?: StateScopeOptions): Promise<T | undefined>;
|
|
69
84
|
getState<T extends JsonValue = JsonValue>(actionId: string, key: string, options?: StateScopeOptions): Promise<T | undefined>;
|
|
70
85
|
setState<T extends JsonValue = JsonValue>(key: string, value: T, options?: StateScopeOptions): Promise<void>;
|
|
@@ -78,11 +93,17 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
78
93
|
listStateKeys(actionId: string, options?: StateScopeOptions): Promise<string[]>;
|
|
79
94
|
clearState(options?: StateScopeOptions): Promise<number>;
|
|
80
95
|
clearState(actionId: string, options?: StateScopeOptions): Promise<number>;
|
|
96
|
+
listRuns(options?: ListRunsOptions): Promise<RunRecord[]>;
|
|
97
|
+
clearRuns(options?: {
|
|
98
|
+
actionId?: string;
|
|
99
|
+
status?: string;
|
|
100
|
+
}): Promise<number>;
|
|
101
|
+
listStateEntries(options?: any): Promise<import("../storage/types.js").StateEntry[]>;
|
|
81
102
|
close(options?: {
|
|
82
103
|
graceMs?: number;
|
|
83
104
|
}): Promise<void>;
|
|
84
105
|
}
|
|
85
106
|
/**
|
|
86
|
-
* 工厂函数:创建并初始化
|
|
107
|
+
* 工厂函数:创建并初始化 PackageRuntime 实例。
|
|
87
108
|
*/
|
|
88
|
-
export declare function
|
|
109
|
+
export declare function createPackageRuntime(options?: PackageRuntimeOptions): Promise<PackageRuntime>;
|