@actiondock/core 2.0.12 → 2.2.1
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 -30
- package/dist/app/app.d.ts +73 -0
- package/dist/app/app.js +700 -0
- package/dist/app/index.d.ts +2 -0
- package/dist/app/index.js +2 -0
- package/dist/app/types.d.ts +283 -0
- package/dist/app/types.js +1 -0
- package/dist/catalog/action-index.d.ts +1 -1
- package/dist/catalog/action-index.js +93 -0
- package/dist/catalog/action-resolver.d.ts +2 -2
- package/dist/catalog/action-resolver.js +95 -0
- package/dist/catalog/index.d.ts +5 -5
- package/dist/catalog/index.js +5 -0
- package/dist/catalog/location-registry.d.ts +5 -5
- package/dist/catalog/location-registry.js +138 -0
- package/dist/catalog/package-catalog.d.ts +2 -2
- package/dist/catalog/package-catalog.js +76 -0
- package/dist/catalog/types.d.ts +2 -2
- package/dist/catalog/types.js +1 -0
- package/dist/doctor/doctor.d.ts +2 -1
- package/dist/doctor/doctor.js +613 -0
- package/dist/doctor/index.d.ts +2 -2
- package/dist/doctor/index.js +2 -0
- package/dist/doctor/types.js +1 -0
- package/dist/errors.d.ts +122 -0
- package/dist/errors.js +123 -0
- package/dist/execution/index.d.ts +2 -2
- package/dist/execution/index.js +2 -0
- package/dist/execution/service.d.ts +46 -41
- package/dist/execution/service.js +633 -0
- package/dist/execution/types.d.ts +59 -2
- package/dist/execution/types.js +1 -0
- package/dist/export/index.d.ts +1 -1
- package/dist/export/index.js +1 -0
- package/dist/export/templates.d.ts +45 -7
- package/dist/export/templates.js +631 -0
- package/dist/filter/index.d.ts +1 -1
- package/dist/filter/index.js +1 -0
- package/dist/filter/intent.js +123 -0
- package/dist/host/host.d.ts +55 -0
- package/dist/host/host.js +740 -0
- package/dist/host/index.d.ts +2 -0
- package/dist/host/index.js +2 -0
- package/dist/host/types.d.ts +81 -0
- package/dist/host/types.js +1 -0
- package/dist/index.d.ts +21 -16
- package/dist/index.js +20 -8458
- package/dist/ipc/diagnostic.d.ts +65 -0
- package/dist/ipc/diagnostic.js +129 -0
- package/dist/ipc/host.d.ts +7 -0
- package/dist/ipc/host.js +93 -0
- package/dist/ipc/index.d.ts +4 -0
- package/dist/ipc/index.js +4 -0
- package/dist/ipc/target.d.ts +56 -0
- package/dist/ipc/target.js +297 -0
- package/dist/ipc/types.d.ts +42 -0
- package/dist/ipc/types.js +1 -0
- package/dist/platform/default.d.ts +32 -0
- package/dist/platform/default.js +40 -0
- package/dist/platform/index.d.ts +3 -0
- package/dist/platform/index.js +3 -0
- package/dist/platform/node-fs.d.ts +37 -0
- package/dist/platform/node-fs.js +81 -0
- package/dist/platform/types.d.ts +104 -0
- package/dist/platform/types.js +1 -0
- package/dist/profile/client.d.ts +58 -12
- package/dist/profile/client.js +467 -0
- package/dist/profile/index.d.ts +3 -3
- package/dist/profile/index.js +3 -0
- package/dist/profile/manager.d.ts +2 -2
- package/dist/profile/manager.js +294 -0
- package/dist/profile/types.d.ts +1 -1
- package/dist/profile/types.js +1 -0
- package/dist/project/closure.js +68 -0
- package/dist/project/digest.d.ts +29 -0
- package/dist/project/digest.js +324 -0
- package/dist/project/index.d.ts +10 -5
- package/dist/project/index.js +10 -0
- package/dist/project/init.d.ts +3 -4
- package/dist/project/init.js +175 -0
- package/dist/project/loader.d.ts +21 -27
- package/dist/project/loader.js +484 -0
- package/dist/project/lockfile.d.ts +55 -0
- package/dist/project/lockfile.js +175 -0
- package/dist/project/manifest.d.ts +6 -28
- package/dist/project/manifest.js +220 -0
- package/dist/project/resolver.d.ts +116 -0
- package/dist/project/resolver.js +376 -0
- package/dist/project/transactions.d.ts +103 -0
- package/dist/project/transactions.js +1203 -0
- package/dist/project/types-generator.d.ts +33 -0
- package/dist/project/types-generator.js +168 -0
- package/dist/project/types.d.ts +58 -82
- package/dist/project/types.js +1 -0
- package/dist/registry/index.d.ts +5 -2
- package/dist/registry/index.js +5 -0
- package/dist/registry/lock.d.ts +27 -0
- package/dist/registry/lock.js +93 -0
- package/dist/registry/registry.d.ts +32 -11
- package/dist/registry/registry.js +611 -0
- package/dist/registry/resolve.d.ts +62 -0
- package/dist/registry/resolve.js +195 -0
- package/dist/registry/scan.d.ts +38 -0
- package/dist/registry/scan.js +135 -0
- package/dist/registry/types.d.ts +1 -1
- package/dist/registry/types.js +1 -0
- package/dist/runtime/action-collection.d.ts +27 -0
- package/dist/runtime/action-collection.js +57 -0
- package/dist/runtime/clock.d.ts +0 -2
- package/dist/runtime/clock.js +17 -0
- package/dist/runtime/context.d.ts +16 -5
- package/dist/runtime/context.js +242 -0
- package/dist/runtime/env.d.ts +3 -1
- package/dist/runtime/env.js +159 -0
- package/dist/runtime/events.d.ts +46 -14
- package/dist/runtime/events.js +604 -0
- package/dist/runtime/execution-manager.d.ts +1 -1
- package/dist/runtime/execution-manager.js +66 -0
- package/dist/runtime/index.d.ts +10 -9
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/module-loader.d.ts +0 -8
- package/dist/runtime/module-loader.js +16 -0
- package/dist/runtime/process.d.ts +2 -4
- package/dist/runtime/process.js +146 -0
- package/dist/runtime/runner.d.ts +117 -10
- package/dist/runtime/runner.js +984 -0
- package/dist/runtime/standalone.d.ts +68 -19
- package/dist/runtime/standalone.js +536 -0
- package/dist/schema/validator.js +122 -0
- package/dist/server/body.js +93 -0
- package/dist/server/index.d.ts +5 -6
- package/dist/server/index.js +5 -0
- package/dist/server/routes/actions.d.ts +2 -2
- package/dist/server/routes/actions.js +298 -0
- package/dist/server/routes/common.d.ts +28 -17
- package/dist/server/routes/common.js +104 -0
- package/dist/server/routes/config.d.ts +2 -1
- package/dist/server/routes/config.js +173 -0
- package/dist/server/routes/doctor.d.ts +2 -2
- package/dist/server/routes/doctor.js +63 -0
- package/dist/server/routes/health.d.ts +2 -2
- package/dist/server/routes/health.js +35 -0
- package/dist/server/routes/index.d.ts +9 -9
- package/dist/server/routes/index.js +9 -0
- package/dist/server/routes/info.d.ts +4 -2
- package/dist/server/routes/info.js +158 -0
- package/dist/server/routes/playbooks.d.ts +2 -2
- package/dist/server/routes/playbooks.js +134 -0
- package/dist/server/routes/runs.d.ts +2 -2
- package/dist/server/routes/runs.js +343 -0
- package/dist/server/routes/state.d.ts +2 -1
- package/dist/server/routes/state.js +169 -0
- package/dist/server/security.d.ts +11 -4
- package/dist/server/security.js +101 -0
- package/dist/server/server.d.ts +6 -6
- package/dist/server/server.js +355 -0
- package/dist/server/types.d.ts +27 -8
- package/dist/server/types.js +1 -0
- package/dist/storage/data-dir-lock.d.ts +119 -0
- package/dist/storage/data-dir-lock.js +1016 -0
- package/dist/storage/driver.d.ts +4 -10
- package/dist/storage/driver.js +59 -0
- package/dist/storage/index.d.ts +30 -10
- package/dist/storage/index.js +98 -0
- package/dist/storage/lazy.d.ts +8 -0
- package/dist/storage/lazy.js +44 -0
- package/dist/storage/mask.d.ts +12 -5
- package/dist/storage/mask.js +48 -0
- package/dist/storage/params.d.ts +13 -0
- package/dist/storage/params.js +32 -0
- package/dist/storage/sqlite.d.ts +19 -6
- package/dist/storage/sqlite.js +689 -0
- package/dist/storage/types.d.ts +57 -6
- package/dist/storage/types.js +14 -0
- package/dist/target/index.d.ts +4 -0
- package/dist/target/index.js +4 -0
- package/dist/target/local.d.ts +52 -0
- package/dist/target/local.js +343 -0
- package/dist/target/remote.d.ts +76 -0
- package/dist/target/remote.js +839 -0
- package/dist/target/target.d.ts +6 -0
- package/dist/target/target.js +35 -0
- package/dist/target/types.d.ts +246 -0
- package/dist/target/types.js +34 -0
- package/dist/utils/index.d.ts +22 -2
- package/dist/utils/index.js +180 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -0
- package/package.json +6 -7
- package/dist/build/index.d.ts +0 -1
- package/dist/build/templates.d.ts +0 -19
- package/dist/server/runtime-registry.d.ts +0 -78
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全仓统一错误码单一事实源。
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* - 集中定义所有跨模块、跨包协议中传输的结构化错误码字符串常量。
|
|
6
|
+
* - 任何新错误码必须先在此登记再使用,严禁在业务代码中散落硬编码字面量。
|
|
7
|
+
* - 附带 Action 加载失败根因的统一判定与结构化描述构造能力。
|
|
8
|
+
*/
|
|
9
|
+
/** 目标包未安装或不可解析 */
|
|
10
|
+
export declare const PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND";
|
|
11
|
+
export declare const ACTION_PACKAGE_VERSION_CONFLICT = "ACTION_PACKAGE_VERSION_CONFLICT";
|
|
12
|
+
/** Action 在注册表、链接包与解析器中均未命中 */
|
|
13
|
+
export declare const ACTION_NOT_FOUND = "ACTION_NOT_FOUND";
|
|
14
|
+
/** Action 源码模块加载失败 */
|
|
15
|
+
export declare const ACTION_LOAD_FAILED = "ACTION_LOAD_FAILED";
|
|
16
|
+
/** Action 业务逻辑抛出的未分类失败 */
|
|
17
|
+
export declare const ACTION_FAILED = "ACTION_FAILED";
|
|
18
|
+
/** Action 执行超过时限 */
|
|
19
|
+
export declare const ACTION_TIMEOUT = "ACTION_TIMEOUT";
|
|
20
|
+
/** Action 执行被取消信号中断 */
|
|
21
|
+
export declare const ACTION_CANCELLED = "ACTION_CANCELLED";
|
|
22
|
+
/** 入参不符合 Action 声明的 inputSchema */
|
|
23
|
+
export declare const INPUT_VALIDATION_FAILED = "INPUT_VALIDATION_FAILED";
|
|
24
|
+
/** 出参不符合 Action 声明的 outputSchema */
|
|
25
|
+
export declare const OUTPUT_VALIDATION_FAILED = "OUTPUT_VALIDATION_FAILED";
|
|
26
|
+
/** 入参不是合法的 JSON 兼容结构 */
|
|
27
|
+
export declare const INPUT_NOT_JSON = "INPUT_NOT_JSON";
|
|
28
|
+
/** 出参不是合法的 JSON 兼容结构 */
|
|
29
|
+
export declare const OUTPUT_NOT_JSON = "OUTPUT_NOT_JSON";
|
|
30
|
+
/** 根运行并发子任务数达到上限 */
|
|
31
|
+
export declare const ACTION_SUBRUN_LIMIT = "ACTION_SUBRUN_LIMIT";
|
|
32
|
+
/** 子任务数达限错误的别名标记(details.alias 专用,非独立错误码) */
|
|
33
|
+
export declare const MAX_SUBRUNS_REACHED = "MAX_SUBRUNS_REACHED";
|
|
34
|
+
/** Action 调用链出现环路 */
|
|
35
|
+
export declare const ACTION_CALL_CYCLE = "ACTION_CALL_CYCLE";
|
|
36
|
+
/** 调用链环路检测的别名标记(details.alias 专用,非独立错误码) */
|
|
37
|
+
export declare const ACTION_CYCLE_DETECTED = "ACTION_CYCLE_DETECTED";
|
|
38
|
+
/** 调用链深度超限的别名标记(details.alias 专用,非独立错误码) */
|
|
39
|
+
export declare const ACTION_MAX_DEPTH_EXCEEDED = "ACTION_MAX_DEPTH_EXCEEDED";
|
|
40
|
+
/** 跨包调用未在 uses 中声明依赖 */
|
|
41
|
+
export declare const UNDECLARED_ACTION_DEPENDENCY = "UNDECLARED_ACTION_DEPENDENCY";
|
|
42
|
+
/** Action 引用存在多包歧义 */
|
|
43
|
+
export declare const INVALID_ACTION_REF = "INVALID_ACTION_REF";
|
|
44
|
+
/** 幂等请求参数摘要冲突 */
|
|
45
|
+
export declare const IDEMPOTENCY_CONFLICT = "IDEMPOTENCY_CONFLICT";
|
|
46
|
+
/** 运行以失败态终结且缺少结构化错误 */
|
|
47
|
+
export declare const EXECUTION_FAILED = "EXECUTION_FAILED";
|
|
48
|
+
/** 执行服务外层捕获到未处理异常 */
|
|
49
|
+
export declare const UNHANDLED_EXECUTION_ERROR = "UNHANDLED_EXECUTION_ERROR";
|
|
50
|
+
/** 运行仓储不可用(存储层异常) */
|
|
51
|
+
export declare const RUN_REPOSITORY_UNAVAILABLE = "RUN_REPOSITORY_UNAVAILABLE";
|
|
52
|
+
/** 运行记录持久化失败 */
|
|
53
|
+
export declare const RUN_PERSISTENCE_FAILED = "RUN_PERSISTENCE_FAILED";
|
|
54
|
+
/** 独立单执行二进制拒绝异步启动语义 */
|
|
55
|
+
export declare const STANDALONE_ASYNC_UNSUPPORTED = "STANDALONE_ASYNC_UNSUPPORTED";
|
|
56
|
+
/** 宿主子进程已退出,调用无法送达 */
|
|
57
|
+
export declare const HOST_PROCESS_EXITED = "HOST_PROCESS_EXITED";
|
|
58
|
+
/** 调用在启动前已被取消 */
|
|
59
|
+
export declare const EXECUTION_ABORTED = "EXECUTION_ABORTED";
|
|
60
|
+
/** 远程运行等待超时 */
|
|
61
|
+
export declare const TIMEOUT = "TIMEOUT";
|
|
62
|
+
/** 远程服务器网络连接失败 */
|
|
63
|
+
export declare const NETWORK_ERROR = "NETWORK_ERROR";
|
|
64
|
+
/** 远程目标未启用管理接口能力 */
|
|
65
|
+
export declare const CAPABILITY_UNAVAILABLE = "CAPABILITY_UNAVAILABLE";
|
|
66
|
+
/** 远程状态键不存在 */
|
|
67
|
+
export declare const STATE_KEY_NOT_FOUND = "STATE_KEY_NOT_FOUND";
|
|
68
|
+
/** SQLite 数据库忙或锁定 */
|
|
69
|
+
export declare const STORAGE_BUSY = "STORAGE_BUSY";
|
|
70
|
+
/** 工程事务锁被其他活跃进程持有 */
|
|
71
|
+
export declare const PROJECT_BUSY = "PROJECT_BUSY";
|
|
72
|
+
/** 工程存在未恢复的崩溃事务,需要执行恢复流程 */
|
|
73
|
+
export declare const PROJECT_RECOVERY_REQUIRED = "PROJECT_RECOVERY_REQUIRED";
|
|
74
|
+
/** SQLite 工作线程已退出 */
|
|
75
|
+
export declare const STORAGE_WORKER_EXITED = "STORAGE_WORKER_EXITED";
|
|
76
|
+
/** 事件订阅队列积压超过背压上限 */
|
|
77
|
+
export declare const EVENT_BACKPRESSURE_LIMIT = "EVENT_BACKPRESSURE_LIMIT";
|
|
78
|
+
export declare const EVENT_CURSOR_EXPIRED = "EVENT_CURSOR_EXPIRED";
|
|
79
|
+
/** 子进程输出超过字节上限 */
|
|
80
|
+
export declare const PROCESS_OUTPUT_LIMIT = "PROCESS_OUTPUT_LIMIT";
|
|
81
|
+
/** 子进程启动失败 */
|
|
82
|
+
export declare const PROCESS_SPAWN_ERROR = "PROCESS_SPAWN_ERROR";
|
|
83
|
+
/** 子进程被取消 */
|
|
84
|
+
export declare const PROCESS_CANCELLED = "PROCESS_CANCELLED";
|
|
85
|
+
/** 子进程执行超时 */
|
|
86
|
+
export declare const PROCESS_TIMEOUT = "PROCESS_TIMEOUT";
|
|
87
|
+
/** HTTP 服务鉴权失败 */
|
|
88
|
+
export declare const UNAUTHORIZED = "UNAUTHORIZED";
|
|
89
|
+
/** HTTP 服务资源不存在 */
|
|
90
|
+
export declare const NOT_FOUND = "NOT_FOUND";
|
|
91
|
+
/** HTTP 服务内部错误 */
|
|
92
|
+
export declare const SERVER_ERROR = "SERVER_ERROR";
|
|
93
|
+
/**
|
|
94
|
+
* 判定错误消息根因是否为依赖模块缺失。
|
|
95
|
+
* 兼容 Node.js 与打包器(Bun 等)两类加载器的报错文案。
|
|
96
|
+
*/
|
|
97
|
+
export declare function isMissingModuleError(message: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Action 加载失败的上下文信息。
|
|
100
|
+
*/
|
|
101
|
+
export interface ActionLoadFailureContext {
|
|
102
|
+
/** 加载失败的 Action 标识 */
|
|
103
|
+
actionId: string;
|
|
104
|
+
/** 所属包标识 */
|
|
105
|
+
packageId: string;
|
|
106
|
+
/** 包项目根目录绝对路径 */
|
|
107
|
+
projectRoot: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 统一构造 ACTION_LOAD_FAILED 结构化错误描述。
|
|
111
|
+
* 作为 Runner 与执行服务两处加载失败错误构造的单一事实源。
|
|
112
|
+
*/
|
|
113
|
+
export declare function describeActionLoadFailure(err: unknown, context: ActionLoadFailureContext): {
|
|
114
|
+
code: typeof ACTION_LOAD_FAILED;
|
|
115
|
+
message: string;
|
|
116
|
+
details: {
|
|
117
|
+
packageId: string;
|
|
118
|
+
projectRoot: string;
|
|
119
|
+
rootCause: string;
|
|
120
|
+
hint: string | undefined;
|
|
121
|
+
};
|
|
122
|
+
};
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全仓统一错误码单一事实源。
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* - 集中定义所有跨模块、跨包协议中传输的结构化错误码字符串常量。
|
|
6
|
+
* - 任何新错误码必须先在此登记再使用,严禁在业务代码中散落硬编码字面量。
|
|
7
|
+
* - 附带 Action 加载失败根因的统一判定与结构化描述构造能力。
|
|
8
|
+
*/
|
|
9
|
+
/** 目标包未安装或不可解析 */
|
|
10
|
+
export const PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND";
|
|
11
|
+
export const ACTION_PACKAGE_VERSION_CONFLICT = "ACTION_PACKAGE_VERSION_CONFLICT";
|
|
12
|
+
/** Action 在注册表、链接包与解析器中均未命中 */
|
|
13
|
+
export const ACTION_NOT_FOUND = "ACTION_NOT_FOUND";
|
|
14
|
+
/** Action 源码模块加载失败 */
|
|
15
|
+
export const ACTION_LOAD_FAILED = "ACTION_LOAD_FAILED";
|
|
16
|
+
/** Action 业务逻辑抛出的未分类失败 */
|
|
17
|
+
export const ACTION_FAILED = "ACTION_FAILED";
|
|
18
|
+
/** Action 执行超过时限 */
|
|
19
|
+
export const ACTION_TIMEOUT = "ACTION_TIMEOUT";
|
|
20
|
+
/** Action 执行被取消信号中断 */
|
|
21
|
+
export const ACTION_CANCELLED = "ACTION_CANCELLED";
|
|
22
|
+
/** 入参不符合 Action 声明的 inputSchema */
|
|
23
|
+
export const INPUT_VALIDATION_FAILED = "INPUT_VALIDATION_FAILED";
|
|
24
|
+
/** 出参不符合 Action 声明的 outputSchema */
|
|
25
|
+
export const OUTPUT_VALIDATION_FAILED = "OUTPUT_VALIDATION_FAILED";
|
|
26
|
+
/** 入参不是合法的 JSON 兼容结构 */
|
|
27
|
+
export const INPUT_NOT_JSON = "INPUT_NOT_JSON";
|
|
28
|
+
/** 出参不是合法的 JSON 兼容结构 */
|
|
29
|
+
export const OUTPUT_NOT_JSON = "OUTPUT_NOT_JSON";
|
|
30
|
+
/** 根运行并发子任务数达到上限 */
|
|
31
|
+
export const ACTION_SUBRUN_LIMIT = "ACTION_SUBRUN_LIMIT";
|
|
32
|
+
/** 子任务数达限错误的别名标记(details.alias 专用,非独立错误码) */
|
|
33
|
+
export const MAX_SUBRUNS_REACHED = "MAX_SUBRUNS_REACHED";
|
|
34
|
+
/** Action 调用链出现环路 */
|
|
35
|
+
export const ACTION_CALL_CYCLE = "ACTION_CALL_CYCLE";
|
|
36
|
+
/** 调用链环路检测的别名标记(details.alias 专用,非独立错误码) */
|
|
37
|
+
export const ACTION_CYCLE_DETECTED = "ACTION_CYCLE_DETECTED";
|
|
38
|
+
/** 调用链深度超限的别名标记(details.alias 专用,非独立错误码) */
|
|
39
|
+
export const ACTION_MAX_DEPTH_EXCEEDED = "ACTION_MAX_DEPTH_EXCEEDED";
|
|
40
|
+
/** 跨包调用未在 uses 中声明依赖 */
|
|
41
|
+
export const UNDECLARED_ACTION_DEPENDENCY = "UNDECLARED_ACTION_DEPENDENCY";
|
|
42
|
+
/** Action 引用存在多包歧义 */
|
|
43
|
+
export const INVALID_ACTION_REF = "INVALID_ACTION_REF";
|
|
44
|
+
/** 幂等请求参数摘要冲突 */
|
|
45
|
+
export const IDEMPOTENCY_CONFLICT = "IDEMPOTENCY_CONFLICT";
|
|
46
|
+
/** 运行以失败态终结且缺少结构化错误 */
|
|
47
|
+
export const EXECUTION_FAILED = "EXECUTION_FAILED";
|
|
48
|
+
/** 执行服务外层捕获到未处理异常 */
|
|
49
|
+
export const UNHANDLED_EXECUTION_ERROR = "UNHANDLED_EXECUTION_ERROR";
|
|
50
|
+
/** 运行仓储不可用(存储层异常) */
|
|
51
|
+
export const RUN_REPOSITORY_UNAVAILABLE = "RUN_REPOSITORY_UNAVAILABLE";
|
|
52
|
+
/** 运行记录持久化失败 */
|
|
53
|
+
export const RUN_PERSISTENCE_FAILED = "RUN_PERSISTENCE_FAILED";
|
|
54
|
+
/** 独立单执行二进制拒绝异步启动语义 */
|
|
55
|
+
export const STANDALONE_ASYNC_UNSUPPORTED = "STANDALONE_ASYNC_UNSUPPORTED";
|
|
56
|
+
/** 宿主子进程已退出,调用无法送达 */
|
|
57
|
+
export const HOST_PROCESS_EXITED = "HOST_PROCESS_EXITED";
|
|
58
|
+
/** 调用在启动前已被取消 */
|
|
59
|
+
export const EXECUTION_ABORTED = "EXECUTION_ABORTED";
|
|
60
|
+
/** 远程运行等待超时 */
|
|
61
|
+
export const TIMEOUT = "TIMEOUT";
|
|
62
|
+
/** 远程服务器网络连接失败 */
|
|
63
|
+
export const NETWORK_ERROR = "NETWORK_ERROR";
|
|
64
|
+
/** 远程目标未启用管理接口能力 */
|
|
65
|
+
export const CAPABILITY_UNAVAILABLE = "CAPABILITY_UNAVAILABLE";
|
|
66
|
+
/** 远程状态键不存在 */
|
|
67
|
+
export const STATE_KEY_NOT_FOUND = "STATE_KEY_NOT_FOUND";
|
|
68
|
+
/** SQLite 数据库忙或锁定 */
|
|
69
|
+
export const STORAGE_BUSY = "STORAGE_BUSY";
|
|
70
|
+
/** 工程事务锁被其他活跃进程持有 */
|
|
71
|
+
export const PROJECT_BUSY = "PROJECT_BUSY";
|
|
72
|
+
/** 工程存在未恢复的崩溃事务,需要执行恢复流程 */
|
|
73
|
+
export const PROJECT_RECOVERY_REQUIRED = "PROJECT_RECOVERY_REQUIRED";
|
|
74
|
+
/** SQLite 工作线程已退出 */
|
|
75
|
+
export const STORAGE_WORKER_EXITED = "STORAGE_WORKER_EXITED";
|
|
76
|
+
/** 事件订阅队列积压超过背压上限 */
|
|
77
|
+
export const EVENT_BACKPRESSURE_LIMIT = "EVENT_BACKPRESSURE_LIMIT";
|
|
78
|
+
export const EVENT_CURSOR_EXPIRED = "EVENT_CURSOR_EXPIRED";
|
|
79
|
+
/** 子进程输出超过字节上限 */
|
|
80
|
+
export const PROCESS_OUTPUT_LIMIT = "PROCESS_OUTPUT_LIMIT";
|
|
81
|
+
/** 子进程启动失败 */
|
|
82
|
+
export const PROCESS_SPAWN_ERROR = "PROCESS_SPAWN_ERROR";
|
|
83
|
+
/** 子进程被取消 */
|
|
84
|
+
export const PROCESS_CANCELLED = "PROCESS_CANCELLED";
|
|
85
|
+
/** 子进程执行超时 */
|
|
86
|
+
export const PROCESS_TIMEOUT = "PROCESS_TIMEOUT";
|
|
87
|
+
/** HTTP 服务鉴权失败 */
|
|
88
|
+
export const UNAUTHORIZED = "UNAUTHORIZED";
|
|
89
|
+
/** HTTP 服务资源不存在 */
|
|
90
|
+
export const NOT_FOUND = "NOT_FOUND";
|
|
91
|
+
/** HTTP 服务内部错误 */
|
|
92
|
+
export const SERVER_ERROR = "SERVER_ERROR";
|
|
93
|
+
/**
|
|
94
|
+
* 判定错误消息根因是否为依赖模块缺失。
|
|
95
|
+
* 兼容 Node.js 与打包器(Bun 等)两类加载器的报错文案。
|
|
96
|
+
*/
|
|
97
|
+
export function isMissingModuleError(message) {
|
|
98
|
+
return (message.includes("Cannot find package") ||
|
|
99
|
+
message.includes("Cannot find module") ||
|
|
100
|
+
message.includes("ERR_MODULE_NOT_FOUND") ||
|
|
101
|
+
message.includes("Could not resolve"));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 统一构造 ACTION_LOAD_FAILED 结构化错误描述。
|
|
105
|
+
* 作为 Runner 与执行服务两处加载失败错误构造的单一事实源。
|
|
106
|
+
*/
|
|
107
|
+
export function describeActionLoadFailure(err, context) {
|
|
108
|
+
const rootCause = err instanceof Error ? err.message : String(err ?? "");
|
|
109
|
+
const isMissingModule = isMissingModuleError(rootCause);
|
|
110
|
+
const hint = isMissingModule
|
|
111
|
+
? `依赖未安装,在 '${context.projectRoot}' 执行 npm install 或先执行 'ad run ${context.packageId}/${context.actionId}'`
|
|
112
|
+
: undefined;
|
|
113
|
+
return {
|
|
114
|
+
code: ACTION_LOAD_FAILED,
|
|
115
|
+
message: `Failed to load action '${context.actionId}' from package '${context.packageId}' (${context.projectRoot}): ${rootCause}`,
|
|
116
|
+
details: {
|
|
117
|
+
packageId: context.packageId,
|
|
118
|
+
projectRoot: context.projectRoot,
|
|
119
|
+
rootCause,
|
|
120
|
+
hint,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export { DefaultExecutionService, DefaultExecutionService as ExecutionService, type ExecutionServiceOptions, } from "./service";
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { DefaultExecutionService, DefaultExecutionService as ExecutionService, type ExecutionServiceOptions, } from "./service.js";
|
|
@@ -1,41 +1,8 @@
|
|
|
1
|
-
import type { ActionDefinition, ActionRef, ExecutionEvent, ExecutionResult, JsonValue,
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import type { RuntimeStorage } from "../storage/types";
|
|
7
|
-
import type { CancelResult, ExecuteOptions, ExecutionService, ExecutionTicket } from "./types";
|
|
8
|
-
export interface ExecutionServiceOptions {
|
|
9
|
-
packageId: string;
|
|
10
|
-
storage: RuntimeStorage;
|
|
11
|
-
globalStorage?: RuntimeStorage;
|
|
12
|
-
projectRoot?: string;
|
|
13
|
-
projectConfig?: ProjectConfig;
|
|
14
|
-
configOverrides?: Record<string, unknown>;
|
|
15
|
-
actions?: Map<string, ActionDefinition>;
|
|
16
|
-
process?: ProcessAPI;
|
|
17
|
-
clock?: Clock;
|
|
18
|
-
logger?: Logger;
|
|
19
|
-
eventSink?: EventSink;
|
|
20
|
-
maxActiveRuns?: number;
|
|
21
|
-
maxCallDepth?: number;
|
|
22
|
-
maxSubRuns?: number;
|
|
23
|
-
ownerId?: string;
|
|
24
|
-
actionResolver?: (ref: ActionRef | string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
|
|
25
|
-
getStorageForPackage?: (packageId: string, projectRoot?: string) => RuntimeStorage;
|
|
26
|
-
packageContextResolver?: (packageId: string) => Promise<{
|
|
27
|
-
projectRoot?: string;
|
|
28
|
-
projectConfig?: ProjectConfig;
|
|
29
|
-
storage: RuntimeStorage;
|
|
30
|
-
actions?: Map<string, ActionDefinition>;
|
|
31
|
-
} | undefined> | {
|
|
32
|
-
projectRoot?: string;
|
|
33
|
-
projectConfig?: ProjectConfig;
|
|
34
|
-
storage: RuntimeStorage;
|
|
35
|
-
actions?: Map<string, ActionDefinition>;
|
|
36
|
-
} | undefined;
|
|
37
|
-
customHome?: string;
|
|
38
|
-
}
|
|
1
|
+
import type { ActionDefinition, ActionRef, ExecutionEvent, ExecutionResult, JsonValue, RunRecord } from "@actiondock/sdk";
|
|
2
|
+
import { type EventSink } from "../runtime/events.js";
|
|
3
|
+
import { ActionRunner, type ExecutionHandle } from "../runtime/runner.js";
|
|
4
|
+
import type { CancelResult, ExecuteOptions, ExecutionService, ExecutionServiceOptions, ExecutionTicket } from "./types.js";
|
|
5
|
+
export type { ExecutionServiceOptions };
|
|
39
6
|
/**
|
|
40
7
|
* 统一执行协调服务实现。
|
|
41
8
|
*/
|
|
@@ -43,29 +10,67 @@ export declare class DefaultExecutionService implements ExecutionService {
|
|
|
43
10
|
private packageId;
|
|
44
11
|
private storage;
|
|
45
12
|
private projectConfig?;
|
|
46
|
-
|
|
13
|
+
readonly eventSink: EventSink;
|
|
47
14
|
private maxActiveRuns;
|
|
48
15
|
private ownerId;
|
|
16
|
+
hostSessionId?: string;
|
|
49
17
|
private _runner;
|
|
50
18
|
private logger?;
|
|
51
19
|
private clock?;
|
|
20
|
+
private process?;
|
|
21
|
+
private platform?;
|
|
52
22
|
private actionResolver?;
|
|
53
23
|
private activeRuns;
|
|
24
|
+
private reservedSlots;
|
|
54
25
|
private isClosing;
|
|
26
|
+
private ownsStorage;
|
|
27
|
+
private ownsGlobalStorage;
|
|
28
|
+
private globalStorage?;
|
|
55
29
|
constructor(options: ExecutionServiceOptions);
|
|
56
30
|
get runner(): ActionRunner;
|
|
57
|
-
registerAction(action: ActionDefinition): void;
|
|
31
|
+
registerAction(id: string, action: ActionDefinition): void;
|
|
32
|
+
registerAction(action: ({
|
|
33
|
+
id: string;
|
|
34
|
+
action?: ActionDefinition;
|
|
35
|
+
} & Partial<ActionDefinition>) | ActionDefinition): void;
|
|
58
36
|
getAction(id: string): ActionDefinition | undefined;
|
|
59
37
|
listActions(): ActionDefinition[];
|
|
60
38
|
getActiveHandle(runId: string): ExecutionHandle | undefined;
|
|
39
|
+
setPackageContextResolver(resolver: any): void;
|
|
61
40
|
private resolveTargetAction;
|
|
62
41
|
execute(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
42
|
+
get activeRunsCount(): number;
|
|
63
43
|
start(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionTicket>;
|
|
44
|
+
/**
|
|
45
|
+
* 幂等门检查:digest 计算与冲突/重复分流(重复命中时直接返回已有票据)。
|
|
46
|
+
*/
|
|
47
|
+
private checkIdempotencyGate;
|
|
48
|
+
/**
|
|
49
|
+
* 解析执行目标:确定目标 Runner 并解析目标 Action 定义。
|
|
50
|
+
*/
|
|
51
|
+
private resolveExecutionTarget;
|
|
52
|
+
/**
|
|
53
|
+
* 注册解析成功的目标 Action 至目标 Runner(收敛为单一注册入口)。
|
|
54
|
+
*/
|
|
55
|
+
private registerResolvedAction;
|
|
56
|
+
/**
|
|
57
|
+
* 目标 Action 缺失时的失败票据:落库 failed 记录并补发 status 与 finish 事件。
|
|
58
|
+
*/
|
|
59
|
+
private failTicketForMissingAction;
|
|
60
|
+
/**
|
|
61
|
+
* 创建执行事件桥:事件序列号分配、进度报告器与双写日志适配器。
|
|
62
|
+
*/
|
|
63
|
+
private createEventBridge;
|
|
64
|
+
/**
|
|
65
|
+
* 监听执行句柄终态:映射终态状态、补发 status 与 finish 事件并注销活跃运行。
|
|
66
|
+
*/
|
|
67
|
+
private watchHandleCompletion;
|
|
64
68
|
get(runId: string): Promise<RunRecord | undefined>;
|
|
65
69
|
cancel(runId: string, reason?: string): Promise<CancelResult>;
|
|
66
70
|
events(runId: string, options?: {
|
|
67
|
-
after?: number;
|
|
71
|
+
after?: number | string;
|
|
68
72
|
signal?: AbortSignal;
|
|
73
|
+
maxQueueSize?: number;
|
|
69
74
|
}): AsyncIterable<ExecutionEvent>;
|
|
70
75
|
close(options?: {
|
|
71
76
|
graceMs?: number;
|