@actiondock/core 2.9.1 → 2.11.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.
Files changed (256) hide show
  1. package/README.md +1 -2
  2. package/dist/catalog/action-catalog.js +3 -33
  3. package/dist/catalog/discovery.d.ts +0 -3
  4. package/dist/catalog/discovery.js +4 -4
  5. package/dist/catalog/graph.d.ts +0 -4
  6. package/dist/catalog/graph.js +12 -15
  7. package/dist/{profile/client-actions.d.ts → client/actions.d.ts} +1 -1
  8. package/dist/{profile/client-actions.js → client/actions.js} +2 -8
  9. package/dist/{profile/client-config.d.ts → client/config.d.ts} +1 -1
  10. package/dist/{profile/client-config.js → client/config.js} +1 -1
  11. package/dist/client/dispatcher.d.ts +4 -0
  12. package/dist/client/dispatcher.js +21 -0
  13. package/dist/client/health.d.ts +38 -0
  14. package/dist/{profile/client-health.js → client/health.js} +9 -6
  15. package/dist/client/index.d.ts +16 -0
  16. package/dist/client/index.js +20 -0
  17. package/dist/{profile/client-playbooks.d.ts → client/playbooks.d.ts} +1 -1
  18. package/dist/{profile/client-playbooks.js → client/playbooks.js} +1 -1
  19. package/dist/{profile/client-runs.d.ts → client/runs.d.ts} +4 -2
  20. package/dist/{profile/client-runs.js → client/runs.js} +7 -1
  21. package/dist/{profile/client-state.d.ts → client/state.d.ts} +1 -1
  22. package/dist/{profile/client-state.js → client/state.js} +1 -1
  23. package/dist/{profile/client-transport.d.ts → client/transport.d.ts} +29 -10
  24. package/dist/{profile/client-transport.js → client/transport.js} +125 -35
  25. package/dist/doctor/checks/index.d.ts +1 -1
  26. package/dist/doctor/checks/index.js +1 -1
  27. package/dist/doctor/checks/project.js +24 -92
  28. package/dist/doctor/checks/registry.js +1 -1
  29. package/dist/doctor/checks/runtime.d.ts +0 -4
  30. package/dist/doctor/checks/runtime.js +0 -28
  31. package/dist/doctor/doctor.js +1 -2
  32. package/dist/errors.d.ts +85 -4
  33. package/dist/errors.js +114 -4
  34. package/dist/execution/service.d.ts +55 -37
  35. package/dist/execution/service.js +601 -212
  36. package/dist/execution/types.d.ts +24 -5
  37. package/dist/host/host.d.ts +42 -22
  38. package/dist/host/host.js +565 -150
  39. package/dist/host/routing.js +6 -6
  40. package/dist/host/types.d.ts +25 -13
  41. package/dist/index.d.ts +9 -4
  42. package/dist/index.js +5 -2
  43. package/dist/input/advice.d.ts +0 -44
  44. package/dist/input/advice.js +7 -141
  45. package/dist/input/describe.d.ts +6 -0
  46. package/dist/input/describe.js +26 -1
  47. package/dist/input/flat-materializer.js +1 -1
  48. package/dist/input/flat-parser.js +1 -1
  49. package/dist/input/index.d.ts +0 -1
  50. package/dist/input/index.js +0 -1
  51. package/dist/input/input-resolver.js +2 -2
  52. package/dist/input/validation-mapper.d.ts +1 -1
  53. package/dist/invocation/policy.js +2 -0
  54. package/dist/ipc/diagnostic.d.ts +8 -21
  55. package/dist/ipc/diagnostic.js +24 -57
  56. package/dist/ipc/host.js +21 -7
  57. package/dist/ipc/service.d.ts +14 -0
  58. package/dist/ipc/service.js +132 -26
  59. package/dist/ipc/types.d.ts +0 -4
  60. package/dist/package/index.d.ts +4 -5
  61. package/dist/package/index.js +1 -2
  62. package/dist/package/runtime.d.ts +94 -23
  63. package/dist/package/runtime.js +628 -274
  64. package/dist/package/static-index.d.ts +3 -6
  65. package/dist/package/static-index.js +11 -40
  66. package/dist/package/types.d.ts +19 -4
  67. package/dist/platform/index.d.ts +2 -1
  68. package/dist/platform/index.js +2 -1
  69. package/dist/platform/loader-hook.d.ts +32 -0
  70. package/dist/platform/loader-hook.js +90 -0
  71. package/dist/{node → platform}/module-loader.d.ts +13 -0
  72. package/dist/{node → platform}/module-loader.js +51 -4
  73. package/dist/platform/node.d.ts +19 -8
  74. package/dist/platform/node.js +50 -20
  75. package/dist/platform/types.d.ts +7 -47
  76. package/dist/process/context-process.d.ts +3 -18
  77. package/dist/process/context-process.js +3 -44
  78. package/dist/process/control.d.ts +21 -0
  79. package/dist/process/control.js +34 -0
  80. package/dist/process/converters.d.ts +23 -0
  81. package/dist/process/converters.js +92 -0
  82. package/dist/process/cursor.js +2 -22
  83. package/dist/process/{diagnostics-sink.d.ts → diagnostics.d.ts} +0 -7
  84. package/dist/process/{diagnostics-sink.js → diagnostics.js} +6 -8
  85. package/dist/process/index.d.ts +1 -3
  86. package/dist/process/index.js +1 -3
  87. package/dist/process/input-dispatcher.d.ts +4 -13
  88. package/dist/process/input-dispatcher.js +48 -69
  89. package/dist/process/managed-record.d.ts +3 -31
  90. package/dist/process/metadata-store.d.ts +0 -41
  91. package/dist/process/metadata-store.js +2 -341
  92. package/dist/process/process-driver.js +2 -2
  93. package/dist/process/process-manager.d.ts +8 -50
  94. package/dist/process/process-manager.js +28 -417
  95. package/dist/process/quotas.d.ts +14 -0
  96. package/dist/process/quotas.js +29 -0
  97. package/dist/process/run-executor.js +0 -1
  98. package/dist/process/terminal-output-cache.d.ts +20 -34
  99. package/dist/process/terminal-output-cache.js +43 -64
  100. package/dist/profile/index.d.ts +1 -2
  101. package/dist/profile/index.js +1 -2
  102. package/dist/profile/manager.d.ts +2 -4
  103. package/dist/profile/manager.js +10 -40
  104. package/dist/profile/types.d.ts +1 -17
  105. package/dist/project/digest.d.ts +5 -1
  106. package/dist/project/digest.js +81 -219
  107. package/dist/project/index.d.ts +4 -5
  108. package/dist/project/index.js +4 -5
  109. package/dist/project/init.js +2 -2
  110. package/dist/project/loader.d.ts +3 -3
  111. package/dist/project/loader.js +72 -50
  112. package/dist/project/lockfile.js +6 -5
  113. package/dist/project/manifest.js +5 -4
  114. package/dist/project/transactions.d.ts +4 -42
  115. package/dist/project/transactions.js +83 -138
  116. package/dist/project/types-generator.js +2 -1
  117. package/dist/project/types.d.ts +2 -0
  118. package/dist/registry/index.d.ts +0 -1
  119. package/dist/registry/index.js +0 -1
  120. package/dist/registry/lock.d.ts +2 -11
  121. package/dist/registry/lock.js +14 -183
  122. package/dist/registry/registry.d.ts +1 -6
  123. package/dist/registry/registry.js +5 -17
  124. package/dist/runtime/action-registry.d.ts +1 -5
  125. package/dist/runtime/action-registry.js +0 -12
  126. package/dist/runtime/context.js +2 -2
  127. package/dist/runtime/events.d.ts +11 -50
  128. package/dist/runtime/events.js +88 -368
  129. package/dist/runtime/index.d.ts +0 -4
  130. package/dist/runtime/index.js +0 -4
  131. package/dist/runtime/run-persistence.d.ts +2 -0
  132. package/dist/runtime/run-persistence.js +2 -1
  133. package/dist/runtime/standalone-commands.d.ts +18 -0
  134. package/dist/runtime/standalone-commands.js +466 -0
  135. package/dist/runtime/standalone-help.d.ts +20 -0
  136. package/dist/runtime/standalone-help.js +72 -0
  137. package/dist/runtime/standalone.d.ts +1 -44
  138. package/dist/runtime/standalone.js +31 -526
  139. package/dist/schema/validator.d.ts +2 -2
  140. package/dist/schema/validator.js +2 -9
  141. package/dist/server/index.d.ts +0 -2
  142. package/dist/server/index.js +0 -2
  143. package/dist/server/routes/actions.js +1 -1
  144. package/dist/server/routes/info.js +1 -1
  145. package/dist/server/routes/playbooks.js +1 -1
  146. package/dist/server/routes/runs.js +123 -16
  147. package/dist/server/routes/state.js +43 -18
  148. package/dist/server/security.d.ts +1 -1
  149. package/dist/server/security.js +2 -2
  150. package/dist/server/server.js +3 -7
  151. package/dist/service/factory.js +4 -3
  152. package/dist/service/index.d.ts +1 -1
  153. package/dist/service/index.js +1 -1
  154. package/dist/service/remote-errors.d.ts +1 -1
  155. package/dist/service/remote-errors.js +6 -6
  156. package/dist/service/remote-polling.d.ts +3 -0
  157. package/dist/service/remote-polling.js +10 -5
  158. package/dist/service/remote.d.ts +5 -1
  159. package/dist/service/remote.js +108 -17
  160. package/dist/service/sse-stream.js +2 -2
  161. package/dist/service/types.d.ts +22 -19
  162. package/dist/service/types.js +1 -24
  163. package/dist/storage/clock.d.ts +1 -1
  164. package/dist/storage/clock.js +1 -1
  165. package/dist/storage/data-dir-lock.d.ts +10 -22
  166. package/dist/storage/data-dir-lock.js +28 -56
  167. package/dist/storage/file-lock.d.ts +64 -0
  168. package/dist/storage/file-lock.js +447 -0
  169. package/dist/storage/index.d.ts +2 -2
  170. package/dist/storage/index.js +5 -4
  171. package/dist/storage/run-liveness.d.ts +48 -0
  172. package/dist/storage/run-liveness.js +44 -0
  173. package/dist/storage/sqlite-config.d.ts +16 -0
  174. package/dist/storage/sqlite-config.js +59 -0
  175. package/dist/storage/sqlite-driver.d.ts +3 -1
  176. package/dist/storage/sqlite-driver.js +14 -4
  177. package/dist/storage/sqlite-events.d.ts +13 -0
  178. package/dist/storage/sqlite-events.js +48 -0
  179. package/dist/storage/sqlite-runs.d.ts +107 -0
  180. package/dist/storage/sqlite-runs.js +622 -0
  181. package/dist/storage/sqlite-schema.d.ts +5 -0
  182. package/dist/storage/sqlite-schema.js +143 -0
  183. package/dist/storage/sqlite-state.d.ts +33 -0
  184. package/dist/storage/sqlite-state.js +270 -0
  185. package/dist/storage/sqlite.d.ts +30 -57
  186. package/dist/storage/sqlite.js +84 -741
  187. package/dist/storage/types.d.ts +35 -2
  188. package/dist/utils/index.d.ts +18 -14
  189. package/dist/utils/index.js +37 -29
  190. package/dist/utils/semver.d.ts +18 -0
  191. package/dist/utils/semver.js +19 -0
  192. package/dist/utils/warning.d.ts +1 -0
  193. package/dist/utils/warning.js +52 -0
  194. package/dist/{json/value-validator.d.ts → value-validator.d.ts} +9 -0
  195. package/dist/value-validator.js +330 -0
  196. package/dist/version.d.ts +1 -1
  197. package/dist/version.js +1 -1
  198. package/package.json +10 -12
  199. package/dist/execution/index.d.ts +0 -2
  200. package/dist/execution/index.js +0 -2
  201. package/dist/filter/index.d.ts +0 -1
  202. package/dist/filter/index.js +0 -1
  203. package/dist/graph/index.d.ts +0 -4
  204. package/dist/graph/index.js +0 -4
  205. package/dist/input/metadata.d.ts +0 -99
  206. package/dist/input/metadata.js +0 -99
  207. package/dist/invocation/index.d.ts +0 -2
  208. package/dist/invocation/index.js +0 -2
  209. package/dist/ipc/index.d.ts +0 -4
  210. package/dist/ipc/index.js +0 -4
  211. package/dist/json/index.d.ts +0 -1
  212. package/dist/json/index.js +0 -1
  213. package/dist/json/value-validator.js +0 -330
  214. package/dist/node/index.d.ts +0 -1
  215. package/dist/node/index.js +0 -1
  216. package/dist/platform/node-fs.d.ts +0 -37
  217. package/dist/platform/node-fs.js +0 -81
  218. package/dist/process/control-arbiter.d.ts +0 -108
  219. package/dist/process/control-arbiter.js +0 -250
  220. package/dist/process/process-executor.d.ts +0 -47
  221. package/dist/process/process-executor.js +0 -296
  222. package/dist/profile/client-health.d.ts +0 -14
  223. package/dist/profile/client-query.d.ts +0 -30
  224. package/dist/profile/client-query.js +0 -69
  225. package/dist/profile/client.d.ts +0 -26
  226. package/dist/profile/client.js +0 -31
  227. package/dist/project/closure.d.ts +0 -25
  228. package/dist/project/closure.js +0 -74
  229. package/dist/registry/store.d.ts +0 -42
  230. package/dist/registry/store.js +0 -43
  231. package/dist/runtime/clock.d.ts +0 -7
  232. package/dist/runtime/clock.js +0 -7
  233. package/dist/runtime/module-loader.d.ts +0 -2
  234. package/dist/runtime/module-loader.js +0 -1
  235. package/dist/runtime/process.d.ts +0 -8
  236. package/dist/runtime/process.js +0 -1
  237. package/dist/runtime/runner.d.ts +0 -234
  238. package/dist/runtime/runner.js +0 -609
  239. package/dist/schema/index.d.ts +0 -1
  240. package/dist/schema/index.js +0 -1
  241. package/dist/server/dispatcher.d.ts +0 -25
  242. package/dist/server/dispatcher.js +0 -54
  243. package/dist/service/local.d.ts +0 -27
  244. package/dist/service/local.js +0 -141
  245. package/dist/storage/driver.d.ts +0 -10
  246. package/dist/storage/driver.js +0 -10
  247. package/dist/storage/lazy.d.ts +0 -8
  248. package/dist/storage/lazy.js +0 -45
  249. package/dist/storage/lock-core.d.ts +0 -158
  250. package/dist/storage/lock-core.js +0 -872
  251. package/dist/utils/net.d.ts +0 -10
  252. package/dist/utils/net.js +0 -16
  253. package/dist/utils/process.d.ts +0 -10
  254. package/dist/utils/process.js +0 -21
  255. /package/dist/{filter → utils}/intent.d.ts +0 -0
  256. /package/dist/{filter → utils}/intent.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/core",
3
- "version": "2.9.1",
3
+ "version": "2.11.0",
4
4
  "description": "ActionDock Core Engine - Project loader, runtime execution, SQLite storage, standalone builder, and skill exporter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,45 +9,43 @@
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
- "bun": "./src/index.ts",
13
12
  "import": "./dist/index.js",
14
13
  "default": "./dist/index.js"
15
14
  },
16
15
  "./server": {
17
16
  "types": "./dist/server/index.d.ts",
18
- "bun": "./src/server/index.ts",
19
17
  "import": "./dist/server/index.js",
20
18
  "default": "./dist/server/index.js"
21
19
  },
22
20
  "./project": {
23
21
  "types": "./dist/project/index.d.ts",
24
- "bun": "./src/project/index.ts",
25
22
  "import": "./dist/project/index.js",
26
23
  "default": "./dist/project/index.js"
27
24
  },
28
25
  "./registry": {
29
26
  "types": "./dist/registry/index.d.ts",
30
- "bun": "./src/registry/index.ts",
31
27
  "import": "./dist/registry/index.js",
32
28
  "default": "./dist/registry/index.js"
33
29
  },
34
30
  "./profile": {
35
31
  "types": "./dist/profile/index.d.ts",
36
- "bun": "./src/profile/index.ts",
37
32
  "import": "./dist/profile/index.js",
38
33
  "default": "./dist/profile/index.js"
39
34
  },
40
35
  "./graph": {
41
- "types": "./dist/graph/index.d.ts",
42
- "bun": "./src/graph/index.ts",
43
- "import": "./dist/graph/index.js",
44
- "default": "./dist/graph/index.js"
36
+ "types": "./dist/catalog/index.d.ts",
37
+ "import": "./dist/catalog/index.js",
38
+ "default": "./dist/catalog/index.js"
45
39
  },
46
40
  "./package": {
47
41
  "types": "./dist/package/index.d.ts",
48
- "bun": "./src/package/index.ts",
49
42
  "import": "./dist/package/index.js",
50
43
  "default": "./dist/package/index.js"
44
+ },
45
+ "./warning": {
46
+ "types": "./dist/utils/warning.d.ts",
47
+ "import": "./dist/utils/warning.js",
48
+ "default": "./dist/utils/warning.js"
51
49
  }
52
50
  },
53
51
  "files": [
@@ -66,7 +64,7 @@
66
64
  "test": "node ../../scripts/run-tests.ts"
67
65
  },
68
66
  "dependencies": {
69
- "@actiondock/sdk": "^2.9.1",
67
+ "@actiondock/sdk": "^2.11.0",
70
68
  "ajv": "^8.17.1",
71
69
  "ajv-formats": "^3.0.1",
72
70
  "undici": "^7.29.1"
@@ -1,2 +0,0 @@
1
- export * from "./types.js";
2
- export { DefaultExecutionService, DefaultExecutionService as ExecutionService, type ExecutionServiceOptions, } from "./service.js";
@@ -1,2 +0,0 @@
1
- export * from "./types.js";
2
- export { DefaultExecutionService, DefaultExecutionService as ExecutionService, } from "./service.js";
@@ -1 +0,0 @@
1
- export * from "./intent.js";
@@ -1 +0,0 @@
1
- export * from "./intent.js";
@@ -1,4 +0,0 @@
1
- export * from "../catalog/graph.js";
2
- export { parseActionRef, resolveAction } from "../catalog/resolve-action.js";
3
- export { resolvePlaybook } from "../catalog/resolve-playbook.js";
4
- export { DefaultActionCatalog, type ActionCatalog } from "../catalog/action-catalog.js";
@@ -1,4 +0,0 @@
1
- export * from "../catalog/graph.js";
2
- export { parseActionRef, resolveAction } from "../catalog/resolve-action.js";
3
- export { resolvePlaybook } from "../catalog/resolve-playbook.js";
4
- export { DefaultActionCatalog } from "../catalog/action-catalog.js";
@@ -1,99 +0,0 @@
1
- import { type CliInputAdviceV1 } from "./advice.js";
2
- /**
3
- * CLI 输入传输机制元数据契约(v1)。
4
- */
5
- export interface InputTransportV1 {
6
- version: 1;
7
- defaultInputMode: "empty-object";
8
- fullJson: {
9
- inlineOption: "--input";
10
- fileOption: "--input-file";
11
- stdinValue: "-";
12
- preferredLargeInputMode: "stdin";
13
- encoding: "utf-8";
14
- maxInputBytes: number;
15
- maxJsonDepth: number;
16
- };
17
- }
18
- /**
19
- * CLI 扁平编码规格元数据契约(v1)。
20
- */
21
- export interface CliInputEncodingV1 {
22
- name: "flat-json-value";
23
- version: 1;
24
- scope: "cli-argv";
25
- root: "object";
26
- operators: {
27
- string: "=";
28
- json: ":=";
29
- };
30
- limits: {
31
- maxAssignments: number;
32
- maxPathDepth: number;
33
- maxPathBytes: number;
34
- maxPropertyKeyBytes: number;
35
- maxRawValueBytes: number;
36
- maxJsonLiteralBytes: number;
37
- maxTotalRawBytes: number;
38
- maxArrayIndex: number;
39
- maxMaterializedBytes: number;
40
- maxJsonDepth: number;
41
- };
42
- }
43
- /**
44
- * CLI 输入安全策略元数据契约(v1)。
45
- */
46
- export interface InputPolicyV1 {
47
- version: 1;
48
- scope: "cli-pre-target";
49
- propertyScope: "recursive";
50
- forbiddenPropertyNames: readonly string[];
51
- }
52
- /**
53
- * CLI describe --json 输入元数据聚合契约(v1)。
54
- */
55
- export interface CliDescribeInputMetadataV1 {
56
- inputTransport: InputTransportV1;
57
- inputEncoding: CliInputEncodingV1;
58
- inputPolicy: InputPolicyV1;
59
- inputAdvice: CliInputAdviceV1;
60
- }
61
- /**
62
- * CLI 输入错误信封结构契约。
63
- */
64
- export interface CliInputErrorEnvelope {
65
- ok: false;
66
- error: {
67
- code: string;
68
- message: string;
69
- details?: unknown;
70
- };
71
- }
72
- /**
73
- * 构造输入传输层元数据(v1)。
74
- */
75
- export declare function buildInputTransportV1(): InputTransportV1;
76
- /**
77
- * 构造 CLI 扁平输入编码元数据(v1)。
78
- */
79
- export declare function buildCliInputEncodingV1(): CliInputEncodingV1;
80
- /**
81
- * 构造输入策略元数据(v1)。
82
- * 明确标注 scope 为 "cli-pre-target",防止远端目标未隔离策略造成歧义。
83
- */
84
- export declare function buildInputPolicyV1(): InputPolicyV1;
85
- /**
86
- * 聚合构造 CLI describe --json 所需的完整输入元数据。
87
- *
88
- * @param schema Action 的 inputSchema 定义
89
- * @returns 包含 transport、encoding、policy 与 advice 的聚合元数据对象
90
- */
91
- export declare function buildCliDescribeInputMetadataV1(schema: unknown): CliDescribeInputMetadataV1;
92
- /**
93
- * 格式化输入异常为 CLI 人类可读文本。
94
- */
95
- export declare function formatInputErrorForCli(err: unknown): string;
96
- /**
97
- * 将输入异常转换为统一的 CLI 错误信封结构。
98
- */
99
- export declare function toCliInputErrorEnvelope(err: unknown): CliInputErrorEnvelope;
@@ -1,99 +0,0 @@
1
- import { DEFAULT_MAX_INPUT_BYTES } from "./file-input.js";
2
- import { DEFAULT_MAX_JSON_DEPTH } from "../json/value-validator.js";
3
- import { DEFAULT_MAX_ASSIGNMENTS, DEFAULT_MAX_PATH_DEPTH, DEFAULT_MAX_PATH_LENGTH, DEFAULT_MAX_PROPERTY_KEY_LENGTH, DEFAULT_MAX_RAW_VALUE_LENGTH, DEFAULT_MAX_JSON_LITERAL_LENGTH, DEFAULT_MAX_TOTAL_RAW_BYTES, DEFAULT_MAX_ARRAY_INDEX, DEFAULT_MAX_MATERIALIZED_SIZE_BYTES, } from "./flat-parser.js";
4
- import { FORBIDDEN_ACTION_INPUT_PROPERTIES } from "./flat-predicates.js";
5
- import { buildCliInputAdviceV1 } from "./advice.js";
6
- /**
7
- * 构造输入传输层元数据(v1)。
8
- */
9
- export function buildInputTransportV1() {
10
- return {
11
- version: 1,
12
- defaultInputMode: "empty-object",
13
- fullJson: {
14
- inlineOption: "--input",
15
- fileOption: "--input-file",
16
- stdinValue: "-",
17
- preferredLargeInputMode: "stdin",
18
- encoding: "utf-8",
19
- maxInputBytes: DEFAULT_MAX_INPUT_BYTES,
20
- maxJsonDepth: DEFAULT_MAX_JSON_DEPTH,
21
- },
22
- };
23
- }
24
- /**
25
- * 构造 CLI 扁平输入编码元数据(v1)。
26
- */
27
- export function buildCliInputEncodingV1() {
28
- return {
29
- name: "flat-json-value",
30
- version: 1,
31
- scope: "cli-argv",
32
- root: "object",
33
- operators: {
34
- string: "=",
35
- json: ":=",
36
- },
37
- limits: {
38
- maxAssignments: DEFAULT_MAX_ASSIGNMENTS,
39
- maxPathDepth: DEFAULT_MAX_PATH_DEPTH,
40
- maxPathBytes: DEFAULT_MAX_PATH_LENGTH,
41
- maxPropertyKeyBytes: DEFAULT_MAX_PROPERTY_KEY_LENGTH,
42
- maxRawValueBytes: DEFAULT_MAX_RAW_VALUE_LENGTH,
43
- maxJsonLiteralBytes: DEFAULT_MAX_JSON_LITERAL_LENGTH,
44
- maxTotalRawBytes: DEFAULT_MAX_TOTAL_RAW_BYTES,
45
- maxArrayIndex: DEFAULT_MAX_ARRAY_INDEX,
46
- maxMaterializedBytes: DEFAULT_MAX_MATERIALIZED_SIZE_BYTES,
47
- maxJsonDepth: DEFAULT_MAX_JSON_DEPTH,
48
- },
49
- };
50
- }
51
- /**
52
- * 构造输入策略元数据(v1)。
53
- * 明确标注 scope 为 "cli-pre-target",防止远端目标未隔离策略造成歧义。
54
- */
55
- export function buildInputPolicyV1() {
56
- return {
57
- version: 1,
58
- scope: "cli-pre-target",
59
- propertyScope: "recursive",
60
- forbiddenPropertyNames: FORBIDDEN_ACTION_INPUT_PROPERTIES,
61
- };
62
- }
63
- /**
64
- * 聚合构造 CLI describe --json 所需的完整输入元数据。
65
- *
66
- * @param schema Action 的 inputSchema 定义
67
- * @returns 包含 transport、encoding、policy 与 advice 的聚合元数据对象
68
- */
69
- export function buildCliDescribeInputMetadataV1(schema) {
70
- return {
71
- inputTransport: buildInputTransportV1(),
72
- inputEncoding: buildCliInputEncodingV1(),
73
- inputPolicy: buildInputPolicyV1(),
74
- inputAdvice: buildCliInputAdviceV1(schema),
75
- };
76
- }
77
- /**
78
- * 格式化输入异常为 CLI 人类可读文本。
79
- */
80
- export function formatInputErrorForCli(err) {
81
- const message = err?.message || String(err);
82
- return `Error: ${message}`;
83
- }
84
- /**
85
- * 将输入异常转换为统一的 CLI 错误信封结构。
86
- */
87
- export function toCliInputErrorEnvelope(err) {
88
- const code = err?.code || "INVALID_ARGUMENT";
89
- const message = err?.message || String(err);
90
- const details = err?.details;
91
- return {
92
- ok: false,
93
- error: {
94
- code,
95
- message,
96
- ...(details !== undefined ? { details } : {}),
97
- },
98
- };
99
- }
@@ -1,2 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./policy.js";
@@ -1,2 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./policy.js";
@@ -1,4 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./diagnostic.js";
3
- export * from "./host.js";
4
- export * from "./service.js";
package/dist/ipc/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./diagnostic.js";
3
- export * from "./host.js";
4
- export * from "./service.js";
@@ -1 +0,0 @@
1
- export * from "./value-validator.js";
@@ -1 +0,0 @@
1
- export * from "./value-validator.js";
@@ -1,330 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export * from "./module-loader.js";
@@ -1 +0,0 @@
1
- export * from "./module-loader.js";