@actiondock/core 2.7.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.
Files changed (236) hide show
  1. package/README.md +61 -68
  2. package/dist/catalog/action-catalog.d.ts +56 -0
  3. package/dist/catalog/action-catalog.js +202 -0
  4. package/dist/catalog/discovery.d.ts +60 -0
  5. package/dist/catalog/discovery.js +119 -0
  6. package/dist/catalog/graph.d.ts +190 -0
  7. package/dist/catalog/graph.js +589 -0
  8. package/dist/catalog/index.d.ts +5 -5
  9. package/dist/catalog/index.js +5 -5
  10. package/dist/catalog/resolve-action.d.ts +43 -0
  11. package/dist/catalog/resolve-action.js +119 -0
  12. package/dist/catalog/resolve-playbook.d.ts +26 -0
  13. package/dist/catalog/resolve-playbook.js +114 -0
  14. package/dist/doctor/checks/project.js +27 -8
  15. package/dist/doctor/checks/registry.js +2 -2
  16. package/dist/doctor/checks/runtime.js +34 -1
  17. package/dist/errors.d.ts +102 -10
  18. package/dist/errors.js +103 -10
  19. package/dist/execution/service.d.ts +18 -16
  20. package/dist/execution/service.js +183 -252
  21. package/dist/execution/types.d.ts +25 -69
  22. package/dist/execution/types.js +2 -1
  23. package/dist/filter/intent.d.ts +8 -9
  24. package/dist/filter/intent.js +49 -10
  25. package/dist/graph/index.d.ts +4 -0
  26. package/dist/graph/index.js +4 -0
  27. package/dist/host/host.d.ts +74 -32
  28. package/dist/host/host.js +585 -336
  29. package/dist/host/routing.d.ts +15 -48
  30. package/dist/host/routing.js +90 -153
  31. package/dist/host/types.d.ts +50 -17
  32. package/dist/index.d.ts +21 -24
  33. package/dist/index.js +19 -23
  34. package/dist/input/advice.d.ts +5 -1
  35. package/dist/input/advice.js +163 -214
  36. package/dist/input/describe.d.ts +1 -1
  37. package/dist/input/flat-errors.d.ts +5 -6
  38. package/dist/input/flat-errors.js +6 -6
  39. package/dist/input/flat-materializer.js +42 -44
  40. package/dist/invocation/index.d.ts +2 -0
  41. package/dist/invocation/index.js +2 -0
  42. package/dist/invocation/policy.d.ts +157 -0
  43. package/dist/invocation/policy.js +231 -0
  44. package/dist/invocation/types.d.ts +172 -0
  45. package/dist/invocation/types.js +97 -0
  46. package/dist/ipc/diagnostic.d.ts +0 -12
  47. package/dist/ipc/diagnostic.js +0 -21
  48. package/dist/ipc/host.d.ts +4 -4
  49. package/dist/ipc/host.js +44 -47
  50. package/dist/ipc/index.d.ts +1 -1
  51. package/dist/ipc/index.js +1 -1
  52. package/dist/ipc/service.d.ts +40 -0
  53. package/dist/ipc/service.js +349 -0
  54. package/dist/ipc/types.d.ts +21 -15
  55. package/dist/node/index.d.ts +1 -0
  56. package/dist/node/index.js +1 -0
  57. package/dist/node/module-loader.d.ts +63 -0
  58. package/dist/node/module-loader.js +112 -0
  59. package/dist/package/index.d.ts +23 -0
  60. package/dist/package/index.js +18 -0
  61. package/dist/{app/app.d.ts → package/runtime.d.ts} +41 -20
  62. package/dist/{app/app.js → package/runtime.js} +140 -95
  63. package/dist/{app → package}/static-index.js +58 -41
  64. package/dist/package/storage-view.d.ts +13 -0
  65. package/dist/package/storage-view.js +22 -0
  66. package/dist/{app → package}/types.d.ts +76 -57
  67. package/dist/package/types.js +22 -0
  68. package/dist/platform/index.d.ts +1 -1
  69. package/dist/platform/index.js +1 -1
  70. package/dist/platform/node.d.ts +48 -0
  71. package/dist/platform/node.js +96 -0
  72. package/dist/platform/types.d.ts +0 -9
  73. package/dist/process/control-arbiter.d.ts +2 -1
  74. package/dist/process/control-arbiter.js +1 -2
  75. package/dist/process/driver.d.ts +9 -8
  76. package/dist/process/driver.js +11 -22
  77. package/dist/process/index.d.ts +2 -0
  78. package/dist/process/index.js +2 -0
  79. package/dist/process/managed-record.d.ts +2 -2
  80. package/dist/process/process-driver.d.ts +109 -0
  81. package/dist/process/process-driver.js +650 -0
  82. package/dist/process/process-executor.d.ts +47 -0
  83. package/dist/process/process-executor.js +296 -0
  84. package/dist/process/process-manager.js +48 -26
  85. package/dist/process/run-executor.js +12 -12
  86. package/dist/profile/client-actions.js +2 -2
  87. package/dist/profile/client-health.js +2 -2
  88. package/dist/profile/client-query.js +5 -6
  89. package/dist/profile/client-transport.d.ts +19 -17
  90. package/dist/profile/client-transport.js +47 -80
  91. package/dist/profile/client.d.ts +2 -2
  92. package/dist/profile/client.js +1 -1
  93. package/dist/profile/index.d.ts +1 -0
  94. package/dist/profile/index.js +1 -0
  95. package/dist/profile/manager.d.ts +5 -0
  96. package/dist/profile/manager.js +41 -6
  97. package/dist/project/closure.js +2 -2
  98. package/dist/project/index.d.ts +8 -1
  99. package/dist/project/index.js +10 -1
  100. package/dist/project/init.js +2 -2
  101. package/dist/project/loader.d.ts +1 -1
  102. package/dist/project/loader.js +26 -29
  103. package/dist/project/transactions.js +5 -10
  104. package/dist/registry/index.d.ts +3 -1
  105. package/dist/registry/index.js +2 -1
  106. package/dist/registry/lock.d.ts +28 -7
  107. package/dist/registry/lock.js +136 -16
  108. package/dist/registry/registry.d.ts +1 -5
  109. package/dist/registry/registry.js +1 -53
  110. package/dist/registry/scan.d.ts +0 -15
  111. package/dist/registry/scan.js +0 -59
  112. package/dist/registry/store.d.ts +42 -0
  113. package/dist/registry/store.js +43 -0
  114. package/dist/registry/types.d.ts +0 -24
  115. package/dist/runtime/action-collection.d.ts +1 -1
  116. package/dist/runtime/action-registry.d.ts +0 -4
  117. package/dist/runtime/action-registry.js +0 -7
  118. package/dist/runtime/context.js +5 -11
  119. package/dist/runtime/events.js +3 -6
  120. package/dist/runtime/identity.d.ts +22 -0
  121. package/dist/runtime/identity.js +10 -0
  122. package/dist/runtime/index.d.ts +1 -2
  123. package/dist/runtime/index.js +1 -2
  124. package/dist/runtime/module-loader.d.ts +2 -34
  125. package/dist/runtime/module-loader.js +1 -16
  126. package/dist/runtime/process.d.ts +6 -24
  127. package/dist/runtime/process.js +1 -118
  128. package/dist/runtime/run-persistence.js +2 -5
  129. package/dist/runtime/runner.d.ts +33 -93
  130. package/dist/runtime/runner.js +132 -364
  131. package/dist/runtime/standalone.d.ts +23 -8
  132. package/dist/runtime/standalone.js +100 -147
  133. package/dist/server/body.d.ts +16 -8
  134. package/dist/server/body.js +33 -16
  135. package/dist/server/dispatcher.d.ts +6 -10
  136. package/dist/server/dispatcher.js +24 -32
  137. package/dist/server/http-server.d.ts +87 -0
  138. package/dist/server/http-server.js +304 -0
  139. package/dist/server/index.d.ts +11 -0
  140. package/dist/server/index.js +10 -0
  141. package/dist/server/mcp-endpoint.d.ts +61 -0
  142. package/dist/server/mcp-endpoint.js +118 -0
  143. package/dist/server/routes/actions.js +34 -28
  144. package/dist/server/routes/common.d.ts +10 -14
  145. package/dist/server/routes/common.js +32 -56
  146. package/dist/server/routes/config.js +54 -64
  147. package/dist/server/routes/doctor.d.ts +1 -1
  148. package/dist/server/routes/doctor.js +10 -18
  149. package/dist/server/routes/health.d.ts +1 -1
  150. package/dist/server/routes/health.js +2 -3
  151. package/dist/server/routes/info.d.ts +2 -2
  152. package/dist/server/routes/info.js +12 -13
  153. package/dist/server/routes/playbooks.js +16 -29
  154. package/dist/server/routes/runs.js +95 -117
  155. package/dist/server/routes/state.js +63 -62
  156. package/dist/server/server.d.ts +2 -2
  157. package/dist/server/server.js +43 -227
  158. package/dist/server/types.d.ts +8 -19
  159. package/dist/service/factory.d.ts +12 -0
  160. package/dist/service/factory.js +85 -0
  161. package/dist/{target → service}/index.d.ts +1 -1
  162. package/dist/{target → service}/index.js +1 -1
  163. package/dist/service/local.d.ts +27 -0
  164. package/dist/service/local.js +138 -0
  165. package/dist/{target → service}/remote-errors.d.ts +3 -6
  166. package/dist/service/remote-errors.js +38 -0
  167. package/dist/{target → service}/remote-polling.d.ts +2 -2
  168. package/dist/{target → service}/remote-polling.js +8 -8
  169. package/dist/service/remote.d.ts +34 -0
  170. package/dist/service/remote.js +634 -0
  171. package/dist/service/sse-stream.d.ts +24 -0
  172. package/dist/service/sse-stream.js +139 -0
  173. package/dist/service/types.d.ts +272 -0
  174. package/dist/service/types.js +32 -0
  175. package/dist/storage/data-dir-lock.js +10 -5
  176. package/dist/storage/driver.d.ts +2 -1
  177. package/dist/storage/driver.js +3 -52
  178. package/dist/storage/index.d.ts +1 -0
  179. package/dist/storage/index.js +1 -0
  180. package/dist/storage/lock-core.d.ts +2 -6
  181. package/dist/storage/lock-core.js +4 -17
  182. package/dist/storage/params.d.ts +2 -8
  183. package/dist/storage/params.js +2 -8
  184. package/dist/storage/sqlite-driver.d.ts +40 -0
  185. package/dist/storage/sqlite-driver.js +116 -0
  186. package/dist/storage/sqlite.js +21 -6
  187. package/dist/storage/types.d.ts +4 -4
  188. package/dist/storage/types.js +2 -2
  189. package/dist/utils/index.d.ts +53 -0
  190. package/dist/utils/index.js +99 -4
  191. package/dist/utils/process.d.ts +10 -0
  192. package/dist/utils/process.js +21 -0
  193. package/dist/version.d.ts +1 -1
  194. package/dist/version.js +1 -1
  195. package/package.json +41 -3
  196. package/dist/app/index.d.ts +0 -2
  197. package/dist/app/index.js +0 -2
  198. package/dist/app/types.js +0 -1
  199. package/dist/catalog/action-index.d.ts +0 -9
  200. package/dist/catalog/action-index.js +0 -95
  201. package/dist/catalog/action-resolver.d.ts +0 -20
  202. package/dist/catalog/action-resolver.js +0 -95
  203. package/dist/catalog/location-registry.d.ts +0 -15
  204. package/dist/catalog/location-registry.js +0 -138
  205. package/dist/catalog/package-catalog.d.ts +0 -7
  206. package/dist/catalog/package-catalog.js +0 -77
  207. package/dist/catalog/types.d.ts +0 -68
  208. package/dist/catalog/types.js +0 -1
  209. package/dist/export/index.d.ts +0 -1
  210. package/dist/export/index.js +0 -1
  211. package/dist/export/templates.d.ts +0 -71
  212. package/dist/export/templates.js +0 -635
  213. package/dist/ipc/target.d.ts +0 -74
  214. package/dist/ipc/target.js +0 -365
  215. package/dist/platform/default.d.ts +0 -38
  216. package/dist/platform/default.js +0 -78
  217. package/dist/project/resolver.d.ts +0 -116
  218. package/dist/project/resolver.js +0 -376
  219. package/dist/registry/resolve.d.ts +0 -62
  220. package/dist/registry/resolve.js +0 -195
  221. package/dist/runtime/execution-manager.d.ts +0 -48
  222. package/dist/runtime/execution-manager.js +0 -66
  223. package/dist/runtime/package-runner-factory.d.ts +0 -82
  224. package/dist/runtime/package-runner-factory.js +0 -186
  225. package/dist/target/local.d.ts +0 -53
  226. package/dist/target/local.js +0 -349
  227. package/dist/target/remote-errors.js +0 -51
  228. package/dist/target/remote.d.ts +0 -86
  229. package/dist/target/remote.js +0 -818
  230. package/dist/target/target.d.ts +0 -6
  231. package/dist/target/target.js +0 -37
  232. package/dist/target/types.d.ts +0 -261
  233. package/dist/target/types.js +0 -35
  234. /package/dist/{app → package}/static-index.d.ts +0 -0
  235. /package/dist/{target → service}/sse-parser.d.ts +0 -0
  236. /package/dist/{target → service}/sse-parser.js +0 -0
@@ -1,10 +1,9 @@
1
+ export * from "./identity.js";
1
2
  export * from "./context.js";
2
3
  export * from "./action-collection.js";
3
4
  export * from "./action-registry.js";
4
5
  export * from "./run-persistence.js";
5
- export * from "./package-runner-factory.js";
6
6
  export * from "./runner.js";
7
- export * from "./execution-manager.js";
8
7
  export * from "./standalone.js";
9
8
  export * from "./env.js";
10
9
  export * from "./clock.js";
@@ -1,34 +1,2 @@
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
- * 基于标准 ECMAScript 动态 import 的默认模块加载器。
30
- */
31
- export declare class DefaultModuleLoader implements ModuleLoader {
32
- load<T = any>(specifier: string, _parentPath?: string): Promise<T>;
33
- loadDefault<T = any>(specifier: string, parentPath?: string): Promise<T>;
34
- }
1
+ export type { ModuleLoader } from "../node/module-loader.js";
2
+ export { NodeModuleLoader, unwrapDefaultExport, } from "../node/module-loader.js";
@@ -1,16 +1 @@
1
- import { pathToFileURL } from "node:url";
2
- /**
3
- * 基于标准 ECMAScript 动态 import 的默认模块加载器。
4
- */
5
- export class DefaultModuleLoader {
6
- async load(specifier, _parentPath) {
7
- const importSpecifier = specifier.startsWith("file://")
8
- ? specifier
9
- : pathToFileURL(specifier).href;
10
- return (await import(importSpecifier));
11
- }
12
- async loadDefault(specifier, parentPath) {
13
- const mod = await this.load(specifier, parentPath);
14
- return (mod?.default !== undefined ? mod.default : mod?.action !== undefined ? mod.action : mod);
15
- }
16
- }
1
+ export { NodeModuleLoader, unwrapDefaultExport, } from "../node/module-loader.js";
@@ -1,26 +1,8 @@
1
- import { type CallOptions, type ControlGrant, type OperationReceipt, type ProcessAcquireInput, type ProcessAPI, type ProcessControlInput, type ProcessExecOptions, type ProcessInfo, type ProcessListInput, type ProcessListResult, type ProcessReadInput, type ProcessResult, type ProcessRunInput, type ProcessRunResult, type ProcessStartInput, type ProcessStartResult, type ProcessStopInput, type ProcessWriteInput, type ReadResult } from "@actiondock/sdk";
2
- import { ProcessManager, type ProcessOwner } from "../process/index.js";
3
- export type ProcessExecutor = ProcessAPI;
1
+ import type { ProcessAPI } from "@actiondock/sdk";
4
2
  /**
5
- * 基于受管进程驱动的默认基础执行器实现。
6
- * 保持内核彻底解耦与平台无关,不依赖操作系统原生进程句柄与 Node 模块。
3
+ * 进程执行器统一契约别名。
4
+ *
5
+ * 面向宿主与上层服务的进程能力均以 ProcessAPI 接口为准,
6
+ * 具体实现由各平台适配层(如 NodeProcessExecutor)提供。
7
7
  */
8
- export declare class DefaultProcessExecutor implements ProcessExecutor {
9
- private readonly manager;
10
- private readonly owner;
11
- constructor(manager?: ProcessManager, owner?: ProcessOwner);
12
- exec(command: string, args?: string[], options?: ProcessExecOptions): Promise<ProcessResult>;
13
- spawn(command: string, args?: string[], options?: ProcessExecOptions): Promise<ProcessResult>;
14
- run(input: ProcessRunInput, call?: CallOptions): Promise<ProcessRunResult>;
15
- start(input: ProcessStartInput, call?: CallOptions): Promise<ProcessStartResult>;
16
- inspect(id: string, call?: CallOptions): Promise<ProcessInfo>;
17
- list(input: ProcessListInput, call?: CallOptions): Promise<ProcessListResult>;
18
- acquire(id: string, input: ProcessAcquireInput, call?: CallOptions): Promise<ControlGrant>;
19
- renew(id: string, token: string, ttlMs: number, call?: CallOptions): Promise<ControlGrant>;
20
- release(id: string, token: string, call?: CallOptions): Promise<void>;
21
- write(id: string, input: ProcessWriteInput, call?: CallOptions): Promise<OperationReceipt>;
22
- operation(id: string, requestId: string, call?: CallOptions): Promise<OperationReceipt>;
23
- read(id: string, input: ProcessReadInput, call?: CallOptions): Promise<ReadResult>;
24
- control(id: string, input: ProcessControlInput, call?: CallOptions): Promise<OperationReceipt>;
25
- stop(id: string, input: ProcessStopInput, call?: CallOptions): Promise<ProcessInfo>;
26
- }
8
+ export type ProcessExecutor = ProcessAPI;
@@ -1,118 +1 @@
1
- import { MemoryProcessDriver, ProcessManager } from "../process/index.js";
2
- /**
3
- * 基于受管进程驱动的默认基础执行器实现。
4
- * 保持内核彻底解耦与平台无关,不依赖操作系统原生进程句柄与 Node 模块。
5
- */
6
- export class DefaultProcessExecutor {
7
- manager;
8
- owner;
9
- constructor(manager, owner) {
10
- this.manager = manager ?? new ProcessManager({ driver: new MemoryProcessDriver() });
11
- this.owner = owner ?? {
12
- tenantId: "default",
13
- principalId: "default",
14
- packageInstanceId: "default",
15
- generationId: "default",
16
- };
17
- }
18
- async exec(command, args = [], options = {}) {
19
- const startTime = Date.now();
20
- try {
21
- const runResult = await this.manager.run(this.owner, {
22
- spec: {
23
- executable: command,
24
- args,
25
- cwd: options.cwd,
26
- env: options.env ? { inherit: "none", set: options.env } : undefined,
27
- io: { mode: "pipe" },
28
- },
29
- timeoutMs: options.timeoutMs ?? 0,
30
- maxOutputBytes: options.maxOutputBytes ?? 10 * 1024 * 1024,
31
- }, options.signal ? { signal: options.signal } : undefined);
32
- let stdout = "";
33
- let stderr = "";
34
- for (const chunk of runResult.chunks) {
35
- if (chunk.stream === "stdout") {
36
- stdout += chunk.data.data;
37
- }
38
- else if (chunk.stream === "stderr") {
39
- stderr += chunk.data.data;
40
- }
41
- }
42
- const durationMs = Date.now() - startTime;
43
- const ok = runResult.exit.code === 0;
44
- if (!ok && options.throwOnError) {
45
- throw new Error(stderr || `Process exited with code ${runResult.exit.code}`);
46
- }
47
- return {
48
- ok,
49
- exitCode: runResult.exit.code,
50
- signal: runResult.exit.signal ?? undefined,
51
- stdout,
52
- stderr,
53
- raw: new Uint8Array(),
54
- timedOut: false,
55
- cancelled: false,
56
- durationMs,
57
- };
58
- }
59
- catch (err) {
60
- if (options.throwOnError) {
61
- throw err;
62
- }
63
- return {
64
- ok: false,
65
- exitCode: -1,
66
- stdout: "",
67
- stderr: err?.message || String(err),
68
- raw: new Uint8Array(),
69
- timedOut: false,
70
- cancelled: false,
71
- durationMs: Date.now() - startTime,
72
- error: {
73
- code: err?.code || "PROCESS_FAILED",
74
- message: err?.message || String(err),
75
- },
76
- };
77
- }
78
- }
79
- async spawn(command, args = [], options = {}) {
80
- return this.exec(command, args, options);
81
- }
82
- async run(input, call) {
83
- return this.manager.run(this.owner, input, call);
84
- }
85
- async start(input, call) {
86
- return this.manager.start(this.owner, input, call);
87
- }
88
- async inspect(id, call) {
89
- return this.manager.inspect(this.owner, id, call);
90
- }
91
- async list(input, call) {
92
- return this.manager.list(this.owner, input, call);
93
- }
94
- async acquire(id, input, call) {
95
- return this.manager.acquire(this.owner, id, input, call);
96
- }
97
- async renew(id, token, ttlMs, call) {
98
- return this.manager.renew(this.owner, id, token, ttlMs, call);
99
- }
100
- async release(id, token, call) {
101
- return this.manager.release(this.owner, id, token, call);
102
- }
103
- async write(id, input, call) {
104
- return this.manager.write(this.owner, id, input, call);
105
- }
106
- async operation(id, requestId, call) {
107
- return this.manager.operation(this.owner, id, requestId, call);
108
- }
109
- async read(id, input, call) {
110
- return this.manager.read(this.owner, id, input, call);
111
- }
112
- async control(id, input, call) {
113
- return this.manager.control(this.owner, id, input, call);
114
- }
115
- async stop(id, input, call) {
116
- return this.manager.stop(this.owner, id, input, call);
117
- }
118
- }
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { RUN_PERSISTENCE_FAILED, RUN_REPOSITORY_UNAVAILABLE } from "../errors.js";
1
+ import { ActionDockError, RUN_PERSISTENCE_FAILED, RUN_REPOSITORY_UNAVAILABLE } from "../errors.js";
2
2
  /**
3
3
  * 构建运行初始记录(RunRecord 组装单一事实源)。
4
4
  */
@@ -43,10 +43,7 @@ export function createRunOrThrow(storage, record) {
43
43
  storage.createRun(record);
44
44
  }
45
45
  catch (err) {
46
- const error = new Error(`RUN_REPOSITORY_UNAVAILABLE: Failed to initialize run record in repository: ${err?.message || String(err)}`);
47
- error.code = RUN_REPOSITORY_UNAVAILABLE;
48
- error.details = { originalError: err?.message };
49
- throw error;
46
+ throw new ActionDockError(RUN_REPOSITORY_UNAVAILABLE, `RUN_REPOSITORY_UNAVAILABLE: Failed to initialize run record in repository: ${err?.message || String(err)}`, { originalError: err?.message });
50
47
  }
51
48
  }
52
49
  /**
@@ -2,38 +2,21 @@ import type { ActionDefinition, ActionRef, ExecutionResult, Logger, ProcessAPI,
2
2
  import type { ProjectConfig } from "../project/types.js";
3
3
  import type { RuntimeStorage } from "../storage/types.js";
4
4
  import type { Clock } from "./clock.js";
5
- import type { RuntimePlatform } from "../platform/types.js";
6
5
  import type { ProcessOwner } from "../process/index.js";
7
- export { RUN_REPOSITORY_UNAVAILABLE, RUN_PERSISTENCE_FAILED, INPUT_NOT_JSON, OUTPUT_NOT_JSON, ACTION_SUBRUN_LIMIT, MAX_SUBRUNS_REACHED, ACTION_CALL_CYCLE, ACTION_CYCLE_DETECTED, ACTION_MAX_DEPTH_EXCEEDED, } from "../errors.js";
8
- import { validateJsonValue, validateActionInputValue, assertJsonValue, type ValidateJsonOptions, type ValidateActionInputOptions } from "../json/value-validator.js";
9
- export { validateJsonValue, validateActionInputValue, assertJsonValue, type ValidateJsonOptions, type ValidateActionInputOptions, };
6
+ import type { PackageIdentity } from "./identity.js";
7
+ import type { ActionInvoker } from "../execution/types.js";
10
8
  /**
11
- * 跨包运行上下文解析结果契约。
9
+ * 局部动作解析器委托函数契约(仅限当前包内部动作)。
12
10
  */
13
- export interface PackageContextResolution {
14
- projectRoot?: string;
15
- projectConfig?: ProjectConfig;
16
- storage: RuntimeStorage;
17
- actions?: Map<string, ActionDefinition>;
18
- packageInstanceId?: string;
19
- generationId?: string;
20
- }
21
- /**
22
- * 跨包运行上下文解析委托函数契约。
23
- */
24
- export type PackageContextResolver = (packageId: string) => Promise<PackageContextResolution | undefined> | PackageContextResolution | undefined;
11
+ export type LocalActionResolver = (actionId: string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
25
12
  /**
26
13
  * ActionRunner 初始化配置选项。
27
14
  */
28
- export interface RunnerOptions {
29
- /** 运行所属的 Package ID */
30
- packageId: string;
31
- /** 包物理实例标识 */
32
- packageInstanceId?: string;
33
- /** 快照代次标识 */
34
- generationId?: string;
15
+ export interface ActionRunnerOptions {
16
+ /** 显式注入的包物理与快照身份标识值对象(必填单一事实源) */
17
+ identity: PackageIdentity;
35
18
  /** 持久化运行时存储实例(SQLite) */
36
- storage?: RuntimeStorage;
19
+ storage: RuntimeStorage;
37
20
  /** 全局共享持久化存储实例(SQLite,用于单例池化避免泄漏) */
38
21
  globalStorage?: RuntimeStorage;
39
22
  /** 项目根目录绝对路径 */
@@ -48,25 +31,15 @@ export interface RunnerOptions {
48
31
  process?: ProcessAPI;
49
32
  /** 可选的时间与时钟源(默认使用存储内嵌时钟或系统时间) */
50
33
  clock?: Clock;
51
- /** 可选的底层运行时平台契约 */
52
- platform?: RuntimePlatform;
53
- /** 动态解析跨包或未注册 Action 的委托函数 */
54
- actionResolver?: (ref: ActionRef | string, currentPackageId?: string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
55
- /** 最大调用嵌套深度限制(防死循环/过深调用链,默认 16) */
56
- maxCallDepth?: number;
57
- /** 最大并发子任务数限制(默认 64) */
58
- maxSubRuns?: number;
59
- /** 跨包存储工厂 */
60
- getStorageForPackage?: (packageId: string, projectRoot?: string) => RuntimeStorage;
61
- /** 跨包运行上下文解析委托函数 */
62
- packageContextResolver?: PackageContextResolver;
34
+ /** 仅支持当前包局部 Action 的动态解析委托函数 */
35
+ actionResolver?: LocalActionResolver;
63
36
  /** 自定义 ActionDock 用户家目录(用于测试隔离与多租户环境) */
64
37
  customHome?: string;
65
38
  /** 执行宿主会话标识 */
66
39
  hostSessionId?: string;
40
+ /** 子任务调用委托函数 */
41
+ actionInvoker?: ActionInvoker;
67
42
  }
68
- /** ActionRunnerOptions 别名兼容 */
69
- export type ActionRunnerOptions = RunnerOptions;
70
43
  /**
71
44
  * 启动 Action 执行时的可选控制参数。
72
45
  */
@@ -101,14 +74,16 @@ export interface ExecutionStartOptions {
101
74
  maxCallDepth?: number;
102
75
  /** 外部注入的进程执行器 */
103
76
  process?: ProcessAPI;
104
- /** 可选的底层运行时平台契约 */
105
- platform?: RuntimePlatform;
77
+ /** 可选的时间与时钟源 */
78
+ clock?: Clock;
106
79
  /** 外部注入的进度报告器 */
107
80
  progress?: ProgressReporter;
108
81
  /** 外部注入的日志记录器 */
109
82
  logger?: Logger;
110
83
  /** 执行级临时配置覆盖项 */
111
84
  configOverrides?: Record<string, unknown>;
85
+ /** 子任务调用委托函数 */
86
+ actionInvoker?: ActionInvoker;
112
87
  }
113
88
  /**
114
89
  * 异步执行句柄,支持获取执行结果 Promise 与主动取消操作。
@@ -134,26 +109,22 @@ export type ActionResolution = {
134
109
  } | {
135
110
  status: "not_found";
136
111
  reason?: string;
137
- } | {
138
- status: "load_failed";
139
- error: Error;
140
- packageId: string;
141
- projectRoot: string;
142
112
  };
143
113
  /**
144
114
  * ActionDock 核心执行引擎(ActionRunner)。
145
115
  *
146
116
  * 本类为执行编排壳:负责 Action 执行的全生命周期编排(校验、深度与环路检测、
147
117
  * 超时与取消竞态、子调用 uses 授权与错误分类),并将单一职责域委托至独立模块:
148
- * - Action 注册与检索委托 `ActionRegistry`(action-registry.ts)
118
+ * - Action 注册与检索委托 ActionRegistry(action-registry.ts)
149
119
  * - RunRecord 构造与落库委托 run-persistence.ts
150
- * - 跨包 Runner 构建与缓存委托 `PackageRunnerFactory`(package-runner-factory.ts)
120
+ * - 跨包动作调用委托注入的 ActionInvoker 并重返目标包执行服务
151
121
  *
152
122
  * 入参 (inputSchema) 与出参 (outputSchema) 的 JSON Schema 严格校验、嵌套 Action
153
123
  * 相互调用的环路检测(Cycle Detection)、超时 (Timeout) 与中断信号 (AbortSignal)
154
124
  * 竞态控制与运行记录持久化编排仍由本类承担。
155
125
  */
156
126
  export declare class ActionRunner {
127
+ readonly identity: PackageIdentity;
157
128
  readonly packageId: string;
158
129
  readonly packageInstanceId: string;
159
130
  readonly generationId: string;
@@ -165,20 +136,14 @@ export declare class ActionRunner {
165
136
  private registry;
166
137
  private clock?;
167
138
  private process?;
168
- private platform?;
169
- private maxCallDepth;
170
- private maxSubRuns;
171
- private activeSubRuns;
172
- private packageFactory;
173
- private actionResolver?;
174
- private getStorageForPackage?;
175
139
  private customHome?;
140
+ private actionResolver?;
176
141
  private hostSessionId?;
177
- constructor(options: RunnerOptions);
178
- /** 本地 Action 注册表底层映射(仅内部与跨包工厂委托使用) */
142
+ private actionInvoker?;
143
+ constructor(options: ActionRunnerOptions);
144
+ /** 本地 Action 注册表底层映射 */
179
145
  private get actions();
180
146
  getStorage(): RuntimeStorage;
181
- getPackageRunners(): Map<string, ActionRunner>;
182
147
  /**
183
148
  * 注册单个 Action 到当前 Runner。
184
149
  */
@@ -191,29 +156,21 @@ export declare class ActionRunner {
191
156
  * 根据 ID 检索注册的 Action。
192
157
  */
193
158
  getAction(id: string): ActionDefinition | undefined;
159
+ /**
160
+ * 设置子任务动作调用委托器。
161
+ */
162
+ setActionInvoker(invoker?: ActionInvoker): void;
194
163
  /**
195
164
  * 动态解析 Action(支持本地注册表、自定义解析器委托与已链接包目录索引检索)。
196
165
  *
197
166
  * @param actionOrRef Action 定义对象、引用或标识符
198
- * @returns 解析判别联合结果(found | not_found | load_failed)
167
+ * @returns 解析判别联合结果(found | not_found)
199
168
  */
200
169
  resolveAction(actionOrRef: ActionDefinition | ActionRef | string): Promise<ActionResolution>;
201
170
  /**
202
171
  * 获取当前 Runner 已注册的所有 Action 列表。
203
172
  */
204
173
  listActions(): ActionDefinition[];
205
- /**
206
- * 注入或更新跨包运行上下文解析委托。
207
- */
208
- setPackageContextResolver(resolver: PackageContextResolver): void;
209
- /**
210
- * 跨包运行时解析与获取(确保跨包执行具备独立的配置、存储、状态与 Action 注册表)。
211
- *
212
- * 缓存 miss 后存在长异步窗口(加载配置、扫描 Action、打开存储),并发调用会重复构建
213
- * Runner、重复打开 SQLite 连接且子任务限流计数分裂;故以 in-flight Promise 去重,
214
- * 并发方 await 同一构建任务,构建失败时移除该 Promise 以便后续重试。
215
- */
216
- resolveTargetPackageRunner(targetPackageId: string): Promise<ActionRunner | undefined>;
217
174
  /**
218
175
  * 异步启动 Action 的执行并立即返回 ExecutionHandle 句柄。
219
176
  *
@@ -235,14 +192,6 @@ export declare class ActionRunner {
235
192
  * 依据运行期上下文装配落库模块入参(RunRecord 构造领域契约)。
236
193
  */
237
194
  private buildRunPersistenceInput;
238
- /**
239
- * 调用嵌套深度限制检测(超限时返回 ACTION_CALL_CYCLE 错误)。
240
- */
241
- private checkCallDepth;
242
- /**
243
- * 计算调用键并执行环路死锁检测(命中时返回携带错误的调用键结果)。
244
- */
245
- private computeCallKey;
246
195
  /**
247
196
  * 输入参数 JSON Schema 校验(若 action 已就绪,返回校验错误或 undefined)。
248
197
  */
@@ -252,17 +201,11 @@ export declare class ActionRunner {
252
201
  */
253
202
  private buildActionContext;
254
203
  /**
255
- * 子 Action 调用委托:并发上限守卫、uses 跨包声明校验与子执行派发。
204
+ * 子 Action 调用委托:
205
+ * 必须委托 Host 动作调用器(走 Host 执行主链与 InvocationPolicy 鉴权);
206
+ * 缺少 actionInvoker 时直接抛出 INVOCATION_UNSUPPORTED,严禁跨包或同包无约束执行逃逸。
256
207
  */
257
208
  private invokeChildAction;
258
- /**
259
- * 校验跨包子调用是否已在 uses 声明中授权(未声明时抛出 UNDECLARED_ACTION_DEPENDENCY)。
260
- */
261
- private assertDeclaredUses;
262
- /**
263
- * 解析子调用应使用的 Runner(本包或已解析的目标包 Runner)。
264
- */
265
- private resolveChildRunner;
266
209
  /**
267
210
  * 执行 Action 业务逻辑并与取消/超时信号进行竞态,返回执行结果信封 Promise。
268
211
  */
@@ -276,11 +219,8 @@ export declare class ActionRunner {
276
219
  */
277
220
  private classifyExecutionError;
278
221
  /**
279
- * 释放 Runner 持有的跨包资源:遍历关闭全部子包 Runner 及其独立创建的存储连接。
280
- *
281
- * 幂等且并发安全:重复调用直接复用首次 Promise;子包存储异常不阻断其余释放;
282
- * 仅关闭由本 Runner 构建子包 Runner 时独立创建的存储,外部注入的存储(如经
283
- * packageContextResolver 传入的目标包自身存储)生命周期归所有者管理,不在此误关。
222
+ * 释放 Runner 持有的资源。
223
+ * 铁律 4:Runner 仅执行自己所属 Package 的 Action,不管理外部包生命周期。
284
224
  */
285
225
  dispose(): Promise<void>;
286
226
  /**