@actiondock/core 2.5.1 → 2.7.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/dist/app/app.d.ts +14 -1
- package/dist/app/app.js +88 -222
- package/dist/app/static-index.d.ts +39 -0
- package/dist/app/static-index.js +164 -0
- package/dist/app/types.d.ts +5 -0
- package/dist/catalog/action-index.js +6 -4
- package/dist/catalog/package-catalog.js +2 -1
- package/dist/doctor/checks/index.d.ts +5 -0
- package/dist/doctor/checks/index.js +5 -0
- package/dist/doctor/checks/project-locate.d.ts +6 -0
- package/dist/doctor/checks/project-locate.js +36 -0
- package/dist/doctor/checks/project.d.ts +6 -0
- package/dist/doctor/checks/project.js +383 -0
- package/dist/doctor/checks/registry.d.ts +13 -0
- package/dist/doctor/checks/registry.js +207 -0
- package/dist/doctor/checks/runtime.d.ts +13 -0
- package/dist/doctor/checks/runtime.js +90 -0
- package/dist/doctor/checks/storage.d.ts +5 -0
- package/dist/doctor/checks/storage.js +34 -0
- package/dist/doctor/context.d.ts +35 -0
- package/dist/doctor/context.js +11 -0
- package/dist/doctor/doctor.d.ts +5 -0
- package/dist/doctor/doctor.js +33 -602
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +22 -0
- package/dist/execution/service.js +14 -9
- package/dist/export/templates.js +42 -30
- package/dist/host/host.d.ts +33 -0
- package/dist/host/host.js +222 -362
- package/dist/host/routing.d.ts +92 -0
- package/dist/host/routing.js +238 -0
- package/dist/host/types.d.ts +8 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/input/advice.d.ts +100 -0
- package/dist/input/advice.js +767 -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 +72 -0
- package/dist/input/flat-errors.js +87 -0
- package/dist/input/flat-materializer.d.ts +29 -0
- package/dist/input/flat-materializer.js +179 -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/ipc/host.js +38 -0
- 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/platform/types.d.ts +7 -0
- package/dist/process/control-arbiter.d.ts +107 -0
- package/dist/process/control-arbiter.js +251 -0
- package/dist/process/diagnostics-sink.d.ts +26 -0
- package/dist/process/diagnostics-sink.js +35 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +7 -0
- package/dist/process/input-dispatcher.d.ts +88 -0
- package/dist/process/input-dispatcher.js +240 -0
- package/dist/process/managed-record.d.ts +78 -0
- package/dist/process/managed-record.js +1 -0
- package/dist/process/process-manager.d.ts +15 -56
- package/dist/process/process-manager.js +119 -707
- package/dist/process/reservation-table.d.ts +39 -0
- package/dist/process/reservation-table.js +80 -0
- package/dist/process/run-executor.d.ts +16 -0
- package/dist/process/run-executor.js +155 -0
- package/dist/process/terminal-output-cache.d.ts +66 -0
- package/dist/process/terminal-output-cache.js +132 -0
- package/dist/profile/client-actions.d.ts +56 -0
- package/dist/profile/client-actions.js +215 -0
- package/dist/profile/client-config.d.ts +20 -0
- package/dist/profile/client-config.js +51 -0
- package/dist/profile/client-health.d.ts +14 -0
- package/dist/profile/client-health.js +69 -0
- package/dist/profile/client-playbooks.d.ts +19 -0
- package/dist/profile/client-playbooks.js +36 -0
- package/dist/profile/client-query.d.ts +30 -0
- package/dist/profile/client-query.js +70 -0
- package/dist/profile/client-runs.d.ts +42 -0
- package/dist/profile/client-runs.js +58 -0
- package/dist/profile/client-state.d.ts +56 -0
- package/dist/profile/client-state.js +83 -0
- package/dist/profile/client-transport.d.ts +61 -0
- package/dist/profile/client-transport.js +156 -0
- package/dist/profile/client.d.ts +23 -142
- package/dist/profile/client.js +28 -588
- package/dist/profile/manager.js +1 -1
- package/dist/project/closure.d.ts +4 -4
- package/dist/project/closure.js +11 -5
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +0 -25
- package/dist/project/loader.js +1 -154
- package/dist/project/transactions.d.ts +12 -14
- package/dist/project/transactions.js +60 -836
- package/dist/registry/registry.js +6 -4
- package/dist/registry/resolve.js +1 -1
- package/dist/runtime/action-registry.d.ts +45 -0
- package/dist/runtime/action-registry.js +108 -0
- package/dist/runtime/clock.d.ts +5 -17
- package/dist/runtime/clock.js +5 -15
- package/dist/runtime/context.d.ts +3 -0
- package/dist/runtime/context.js +17 -56
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/package-runner-factory.d.ts +82 -0
- package/dist/runtime/package-runner-factory.js +186 -0
- package/dist/runtime/run-persistence.d.ts +85 -0
- package/dist/runtime/run-persistence.js +111 -0
- package/dist/runtime/runner.d.ts +25 -45
- package/dist/runtime/runner.js +130 -354
- package/dist/runtime/standalone.d.ts +25 -2
- package/dist/runtime/standalone.js +305 -87
- 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/dispatcher.d.ts +8 -3
- package/dist/server/dispatcher.js +16 -40
- package/dist/server/routes/runs.js +6 -4
- package/dist/server/security.d.ts +1 -7
- package/dist/server/security.js +2 -13
- package/dist/storage/clock.d.ts +25 -0
- package/dist/storage/clock.js +23 -0
- package/dist/storage/data-dir-lock.d.ts +3 -36
- package/dist/storage/data-dir-lock.js +48 -881
- package/dist/storage/index.d.ts +8 -1
- package/dist/storage/index.js +8 -2
- package/dist/storage/lazy.js +1 -0
- package/dist/storage/lock-core.d.ts +162 -0
- package/dist/storage/lock-core.js +885 -0
- package/dist/storage/sqlite.d.ts +19 -6
- package/dist/storage/sqlite.js +81 -89
- package/dist/storage/types.d.ts +27 -5
- package/dist/storage/types.js +21 -0
- package/dist/storage/utils.d.ts +22 -0
- package/dist/storage/utils.js +34 -0
- package/dist/target/local.d.ts +1 -0
- package/dist/target/local.js +23 -17
- package/dist/target/remote-errors.d.ts +21 -0
- package/dist/target/remote-errors.js +51 -0
- package/dist/target/remote-polling.d.ts +35 -0
- package/dist/target/remote-polling.js +104 -0
- package/dist/target/remote.d.ts +4 -0
- package/dist/target/remote.js +108 -301
- package/dist/target/sse-parser.d.ts +35 -0
- package/dist/target/sse-parser.js +163 -0
- package/dist/target/target.js +2 -0
- package/dist/target/types.d.ts +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/net.d.ts +10 -0
- package/dist/utils/net.js +16 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InputValidationSource } from "./flat-errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* 校验并严格解码字节序列为合法 UTF-8 字符串。
|
|
4
|
+
* 使用 TextDecoder("utf-8", { fatal: true }) 拦截非法编码字节并抛出结构化 INVALID_JSON 异常。
|
|
5
|
+
*
|
|
6
|
+
* @param bytes 待解码的原始字节数据
|
|
7
|
+
* @param source 输入校验来源(默认为 full-json-inline)
|
|
8
|
+
* @returns 解码后的 UTF-8 文本
|
|
9
|
+
* @throws InputError 当包含非法 UTF-8 字节序列时抛出 INVALID_JSON 异常
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeUtf8Strict(bytes: Uint8Array | Buffer, source?: InputValidationSource): string;
|
|
12
|
+
/**
|
|
13
|
+
* 仅剥离输入字符串起始处的恰好一个 U+FEFF BOM。
|
|
14
|
+
* 若存在双重 BOM(\uFEFF\uFEFF),仅剥离首个,第二个保留给后续 JSON 解析器以触发 SYNTAX_ERROR。
|
|
15
|
+
*
|
|
16
|
+
* @param text 原始输入文本
|
|
17
|
+
* @returns 剥离首个 BOM 后的文本
|
|
18
|
+
*/
|
|
19
|
+
export declare function stripBom(text: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mapInputValidationFailure } from "./validation-mapper.js";
|
|
2
|
+
/**
|
|
3
|
+
* 校验并严格解码字节序列为合法 UTF-8 字符串。
|
|
4
|
+
* 使用 TextDecoder("utf-8", { fatal: true }) 拦截非法编码字节并抛出结构化 INVALID_JSON 异常。
|
|
5
|
+
*
|
|
6
|
+
* @param bytes 待解码的原始字节数据
|
|
7
|
+
* @param source 输入校验来源(默认为 full-json-inline)
|
|
8
|
+
* @returns 解码后的 UTF-8 文本
|
|
9
|
+
* @throws InputError 当包含非法 UTF-8 字节序列时抛出 INVALID_JSON 异常
|
|
10
|
+
*/
|
|
11
|
+
export function decodeUtf8Strict(bytes, source = "full-json-inline") {
|
|
12
|
+
try {
|
|
13
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
14
|
+
return decoder.decode(bytes);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
throw mapInputValidationFailure(source, {
|
|
18
|
+
valid: false,
|
|
19
|
+
code: "INVALID_UTF8",
|
|
20
|
+
reason: `Invalid UTF-8 encoding: ${err instanceof Error ? err.message : String(err)}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 仅剥离输入字符串起始处的恰好一个 U+FEFF BOM。
|
|
26
|
+
* 若存在双重 BOM(\uFEFF\uFEFF),仅剥离首个,第二个保留给后续 JSON 解析器以触发 SYNTAX_ERROR。
|
|
27
|
+
*
|
|
28
|
+
* @param text 原始输入文本
|
|
29
|
+
* @returns 剥离首个 BOM 后的文本
|
|
30
|
+
*/
|
|
31
|
+
export function stripBom(text) {
|
|
32
|
+
if (text.charCodeAt(0) === 0xfeff) {
|
|
33
|
+
return text.slice(1);
|
|
34
|
+
}
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InputError, type InputValidationSource } from "./flat-errors.js";
|
|
2
|
+
import type { ActionInputValidationResult, JsonValueValidationResult } from "../json/value-validator.js";
|
|
3
|
+
/**
|
|
4
|
+
* 校验失败结构化输入描述。
|
|
5
|
+
*/
|
|
6
|
+
export type ValidationFailureInput = Exclude<ActionInputValidationResult, {
|
|
7
|
+
valid: true;
|
|
8
|
+
}> | Exclude<JsonValueValidationResult, {
|
|
9
|
+
valid: true;
|
|
10
|
+
}> | {
|
|
11
|
+
valid: false;
|
|
12
|
+
kind?: "json-value" | "input-policy";
|
|
13
|
+
code: string;
|
|
14
|
+
reason: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
property?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 将校验失败结果根据输入来源映射为统一结构化异常。
|
|
21
|
+
* 遵循技术设计文档第 19 节 Mapping Table 规范。
|
|
22
|
+
*
|
|
23
|
+
* @param source 输入校验来源
|
|
24
|
+
* @param result 校验失败结果对象
|
|
25
|
+
* @returns 映射后的结构化输入异常
|
|
26
|
+
*/
|
|
27
|
+
export declare function mapInputValidationFailure(source: InputValidationSource, result: ActionInputValidationResult | JsonValueValidationResult | ValidationFailureInput): InputError;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { INPUT_NOT_JSON, INPUT_VALIDATION_FAILED, } from "../errors.js";
|
|
2
|
+
import { InputError, invalidJson, invalidJsonLiteral, flatInputLimitExceeded, inputLimitExceeded, inputPolicyViolation, } from "./flat-errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* 将校验失败结果根据输入来源映射为统一结构化异常。
|
|
5
|
+
* 遵循技术设计文档第 19 节 Mapping Table 规范。
|
|
6
|
+
*
|
|
7
|
+
* @param source 输入校验来源
|
|
8
|
+
* @param result 校验失败结果对象
|
|
9
|
+
* @returns 映射后的结构化输入异常
|
|
10
|
+
*/
|
|
11
|
+
export function mapInputValidationFailure(source, result) {
|
|
12
|
+
const failure = result;
|
|
13
|
+
const code = failure.code;
|
|
14
|
+
const reason = failure.reason;
|
|
15
|
+
const path = failure.path;
|
|
16
|
+
const isPolicyViolation = failure.kind === "input-policy" || code === "FORBIDDEN_PROPERTY";
|
|
17
|
+
switch (source) {
|
|
18
|
+
case "flat-json-literal": {
|
|
19
|
+
if (code === "SYNTAX_ERROR") {
|
|
20
|
+
return invalidJsonLiteral(reason || "Invalid JSON literal syntax", {
|
|
21
|
+
reason: "SYNTAX_ERROR",
|
|
22
|
+
path,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (code === "NON_FINITE_NUMBER") {
|
|
26
|
+
return invalidJsonLiteral(reason || "Non-finite number in JSON literal", {
|
|
27
|
+
reason: "NON_FINITE_NUMBER",
|
|
28
|
+
path,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (code === "MAX_JSON_DEPTH") {
|
|
32
|
+
return invalidJsonLiteral(reason || "Max JSON depth limit exceeded in JSON literal", {
|
|
33
|
+
reason: "MAX_JSON_DEPTH",
|
|
34
|
+
path,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return invalidJsonLiteral(reason || "Invalid JSON literal value", {
|
|
38
|
+
reason: "INVALID_JSON_VALUE",
|
|
39
|
+
path,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
case "full-json-inline":
|
|
43
|
+
case "full-json-file":
|
|
44
|
+
case "full-json-stdin": {
|
|
45
|
+
const cliSource = source === "full-json-inline"
|
|
46
|
+
? "inline-json"
|
|
47
|
+
: source === "full-json-file"
|
|
48
|
+
? "file"
|
|
49
|
+
: "stdin";
|
|
50
|
+
if (code === "SYNTAX_ERROR") {
|
|
51
|
+
return invalidJson(reason || "Invalid JSON syntax", {
|
|
52
|
+
reason: "SYNTAX_ERROR",
|
|
53
|
+
source: cliSource,
|
|
54
|
+
path,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (code === "INVALID_UTF8") {
|
|
58
|
+
return invalidJson(reason || "Invalid UTF-8 encoding in JSON input", {
|
|
59
|
+
reason: "INVALID_UTF8",
|
|
60
|
+
source: cliSource,
|
|
61
|
+
path,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (code === "NON_FINITE_NUMBER") {
|
|
65
|
+
return invalidJson(reason || "Number is non-finite or NaN", {
|
|
66
|
+
reason: "NON_FINITE_NUMBER",
|
|
67
|
+
source: cliSource,
|
|
68
|
+
path,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (code === "MAX_JSON_DEPTH") {
|
|
72
|
+
return invalidJson(reason || "Max JSON depth limit exceeded", {
|
|
73
|
+
reason: "MAX_JSON_DEPTH",
|
|
74
|
+
source: cliSource,
|
|
75
|
+
path,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return invalidJson(reason || "Invalid JSON value", {
|
|
79
|
+
reason: "INVALID_JSON_VALUE",
|
|
80
|
+
source: cliSource,
|
|
81
|
+
path,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
case "flat-materialized": {
|
|
85
|
+
if (code === "MAX_JSON_DEPTH") {
|
|
86
|
+
return flatInputLimitExceeded(reason || "Materialized JSON depth limit exceeded", {
|
|
87
|
+
reason: "MAX_MATERIALIZED_JSON_DEPTH",
|
|
88
|
+
path,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (code === "MAX_MATERIALIZED_BYTES") {
|
|
92
|
+
return flatInputLimitExceeded(reason || "Materialized input size exceeds limit", {
|
|
93
|
+
reason: "MAX_MATERIALIZED_BYTES",
|
|
94
|
+
path,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return flatInputLimitExceeded(reason || "Materialized input validation failed", {
|
|
98
|
+
reason: "INVALID_JSON_VALUE",
|
|
99
|
+
path,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
case "cli-pre-target": {
|
|
103
|
+
if (isPolicyViolation) {
|
|
104
|
+
const property = failure.property;
|
|
105
|
+
return inputPolicyViolation(reason || `Forbidden property "${property}" is not allowed in Action input`, {
|
|
106
|
+
reason: "FORBIDDEN_PROPERTY",
|
|
107
|
+
property,
|
|
108
|
+
path,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (code === "MAX_JSON_DEPTH") {
|
|
112
|
+
return inputLimitExceeded(reason || "Max JSON depth limit exceeded", {
|
|
113
|
+
reason: "MAX_JSON_DEPTH",
|
|
114
|
+
path,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (code === "NON_FINITE_NUMBER") {
|
|
118
|
+
return invalidJson(reason || "Number is non-finite or NaN", {
|
|
119
|
+
reason: "NON_FINITE_NUMBER",
|
|
120
|
+
path,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return invalidJson(reason || "Invalid JSON value in Action input", {
|
|
124
|
+
reason: "INVALID_JSON_VALUE",
|
|
125
|
+
path,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
case "runtime": {
|
|
129
|
+
if (isPolicyViolation) {
|
|
130
|
+
return new InputError(INPUT_VALIDATION_FAILED, reason || "Action input contains forbidden property", [reason || "Forbidden property in input"]);
|
|
131
|
+
}
|
|
132
|
+
return new InputError(INPUT_NOT_JSON, reason || "Input is not a valid JSON value", {
|
|
133
|
+
reason: code,
|
|
134
|
+
path,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
default: {
|
|
138
|
+
return new InputError(INPUT_NOT_JSON, reason || "Input validation failed", {
|
|
139
|
+
reason: code,
|
|
140
|
+
path,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
package/dist/ipc/host.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
import { TARGET_CAPABILITY_UNAVAILABLE } from "../target/types.js";
|
|
1
2
|
import { hasIpcSignalMarker, IPC_SIGNAL_MARKER } from "./target.js";
|
|
3
|
+
/**
|
|
4
|
+
* IPC 通道允许反射调用的目标方法白名单。
|
|
5
|
+
*
|
|
6
|
+
* 严格对齐 ActionDockTarget 公共接口方法名集合:白名单之外的方法一律拒绝,
|
|
7
|
+
* 防止 IPC 消息通道触达任意内部属性或危险方法(如 close 之外的私有能力)。
|
|
8
|
+
*/
|
|
9
|
+
const IPC_ALLOWED_METHODS = new Set([
|
|
10
|
+
"info",
|
|
11
|
+
"listPackages",
|
|
12
|
+
"listActions",
|
|
13
|
+
"describeAction",
|
|
14
|
+
"listPlaybooks",
|
|
15
|
+
"describePlaybook",
|
|
16
|
+
"runAction",
|
|
17
|
+
"startAction",
|
|
18
|
+
"listRuns",
|
|
19
|
+
"getRun",
|
|
20
|
+
"cancelRun",
|
|
21
|
+
"clearRuns",
|
|
22
|
+
"events",
|
|
23
|
+
"getConfig",
|
|
24
|
+
"setConfig",
|
|
25
|
+
"deleteConfig",
|
|
26
|
+
"listConfig",
|
|
27
|
+
"getState",
|
|
28
|
+
"setState",
|
|
29
|
+
"deleteState",
|
|
30
|
+
"listStateKeys",
|
|
31
|
+
"clearState",
|
|
32
|
+
"listStateEntries",
|
|
33
|
+
]);
|
|
2
34
|
/**
|
|
3
35
|
* 在 Host 子进程中启动 Node IPC 服务,向父进程暴露 ActionDockTarget 门面能力。
|
|
4
36
|
*
|
|
@@ -65,6 +97,12 @@ export async function serveParentIpc(target) {
|
|
|
65
97
|
const callMsg = msg;
|
|
66
98
|
const { id, method, args } = callMsg;
|
|
67
99
|
try {
|
|
100
|
+
// 白名单校验:仅允许 ActionDockTarget 公共接口方法,阻止任意方法反射调用
|
|
101
|
+
if (typeof method !== "string" || !IPC_ALLOWED_METHODS.has(method)) {
|
|
102
|
+
const err = new Error(`Target method '${method}' is not allowed over IPC (not in ActionDockTarget public interface)`);
|
|
103
|
+
err.code = TARGET_CAPABILITY_UNAVAILABLE;
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
68
106
|
const fn = target[method];
|
|
69
107
|
if (typeof fn !== "function") {
|
|
70
108
|
throw new Error(`Target method '${method}' not found`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./value-validator.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./value-validator.js";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { JsonValue } from "@actiondock/sdk";
|
|
2
|
+
/** 默认 JSON 最大嵌套深度限制(防止恶意超深结构) */
|
|
3
|
+
export declare const DEFAULT_MAX_JSON_DEPTH = 256;
|
|
4
|
+
/**
|
|
5
|
+
* JSON 结构校验选项。
|
|
6
|
+
*/
|
|
7
|
+
export interface ValidateJsonOptions {
|
|
8
|
+
/** 最大允许嵌套深度(默认 256) */
|
|
9
|
+
maxDepth?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Action 输入校验选项。
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateActionInputOptions extends ValidateJsonOptions {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* JSON 值校验错误码类型。
|
|
18
|
+
*/
|
|
19
|
+
export type JsonValueValidationErrorCode = "NON_FINITE_NUMBER" | "MAX_JSON_DEPTH" | "CIRCULAR_REFERENCE" | "UNSUPPORTED_JSON_TYPE" | "INVALID_JSON_OBJECT" | "UNDEFINED_JSON_VALUE";
|
|
20
|
+
/**
|
|
21
|
+
* Canonical JsonValue 校验结果。
|
|
22
|
+
*/
|
|
23
|
+
export type JsonValueValidationResult = {
|
|
24
|
+
valid: true;
|
|
25
|
+
} | {
|
|
26
|
+
valid: false;
|
|
27
|
+
code: JsonValueValidationErrorCode;
|
|
28
|
+
reason: string;
|
|
29
|
+
path?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Action 输入值校验结果(包含策略违规分支)。
|
|
33
|
+
*/
|
|
34
|
+
export type ActionInputValidationResult = {
|
|
35
|
+
valid: true;
|
|
36
|
+
} | {
|
|
37
|
+
valid: false;
|
|
38
|
+
kind: "json-value";
|
|
39
|
+
code: JsonValueValidationErrorCode;
|
|
40
|
+
reason: string;
|
|
41
|
+
path?: string;
|
|
42
|
+
} | {
|
|
43
|
+
valid: false;
|
|
44
|
+
kind: "input-policy";
|
|
45
|
+
code: "FORBIDDEN_PROPERTY";
|
|
46
|
+
property: string;
|
|
47
|
+
path: string;
|
|
48
|
+
reason: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 按照 RFC 6901 转义单个 JSON Pointer 路径段。
|
|
52
|
+
*
|
|
53
|
+
* @param segment 路径段(属性名或数组索引)
|
|
54
|
+
* @returns 转义后的路径段
|
|
55
|
+
*/
|
|
56
|
+
export declare function escapeJsonPointerSegment(segment: string | number): string;
|
|
57
|
+
/**
|
|
58
|
+
* 将路径段追加到基础 RFC 6901 JSON Pointer 路径后。
|
|
59
|
+
*
|
|
60
|
+
* @param basePath 基础路径
|
|
61
|
+
* @param segment 待追加的路径段
|
|
62
|
+
* @returns 拼接后的 JSON Pointer
|
|
63
|
+
*/
|
|
64
|
+
export declare function appendJsonPointer(basePath: string, segment: string | number): string;
|
|
65
|
+
/**
|
|
66
|
+
* 校验值是否为合法的 Canonical JSON 兼容结构。
|
|
67
|
+
*
|
|
68
|
+
* @param value 待校验的目标值
|
|
69
|
+
* @param options 校验配置选项
|
|
70
|
+
* @returns 校验结果对象
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateJsonValue(value: unknown, options?: ValidateJsonOptions): JsonValueValidationResult;
|
|
73
|
+
/**
|
|
74
|
+
* 校验 Action 输入值是否满足 Canonical JsonValue 规范且符合 ActionDock 安全策略。
|
|
75
|
+
* 在遍历过程中递归检查是否存在禁止属性(__proto__、constructor、prototype)。
|
|
76
|
+
*
|
|
77
|
+
* @param value 待校验的 Action 输入值
|
|
78
|
+
* @param options 校验配置选项
|
|
79
|
+
* @returns 校验结果对象
|
|
80
|
+
*/
|
|
81
|
+
export declare function validateActionInputValue(value: unknown, options?: ValidateActionInputOptions): ActionInputValidationResult;
|
|
82
|
+
/**
|
|
83
|
+
* 断言值必须为合法的 Canonical JSON 兼容结构,若非法则抛出 TypeError。
|
|
84
|
+
*
|
|
85
|
+
* @param value 待断言的目标值
|
|
86
|
+
* @param options 校验配置选项
|
|
87
|
+
*/
|
|
88
|
+
export declare function assertJsonValue(value: unknown, options?: ValidateJsonOptions): asserts value is JsonValue;
|