@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.
- package/README.md +61 -68
- package/dist/catalog/action-catalog.d.ts +56 -0
- package/dist/catalog/action-catalog.js +202 -0
- package/dist/catalog/discovery.d.ts +60 -0
- package/dist/catalog/discovery.js +119 -0
- package/dist/catalog/graph.d.ts +190 -0
- package/dist/catalog/graph.js +589 -0
- package/dist/catalog/index.d.ts +5 -5
- package/dist/catalog/index.js +5 -5
- package/dist/catalog/resolve-action.d.ts +43 -0
- package/dist/catalog/resolve-action.js +119 -0
- package/dist/catalog/resolve-playbook.d.ts +26 -0
- package/dist/catalog/resolve-playbook.js +114 -0
- package/dist/doctor/checks/project.js +27 -8
- package/dist/doctor/checks/registry.js +2 -2
- package/dist/doctor/checks/runtime.js +34 -1
- package/dist/errors.d.ts +102 -10
- package/dist/errors.js +103 -10
- package/dist/execution/service.d.ts +18 -16
- package/dist/execution/service.js +183 -252
- package/dist/execution/types.d.ts +25 -69
- package/dist/execution/types.js +2 -1
- package/dist/filter/intent.d.ts +8 -9
- package/dist/filter/intent.js +49 -10
- package/dist/graph/index.d.ts +4 -0
- package/dist/graph/index.js +4 -0
- package/dist/host/host.d.ts +74 -32
- package/dist/host/host.js +585 -336
- package/dist/host/routing.d.ts +15 -48
- package/dist/host/routing.js +90 -153
- package/dist/host/types.d.ts +50 -17
- package/dist/index.d.ts +21 -24
- package/dist/index.js +19 -23
- package/dist/input/advice.d.ts +5 -1
- package/dist/input/advice.js +163 -214
- package/dist/input/describe.d.ts +1 -1
- package/dist/input/flat-errors.d.ts +5 -6
- package/dist/input/flat-errors.js +6 -6
- package/dist/input/flat-materializer.js +42 -44
- package/dist/invocation/index.d.ts +2 -0
- package/dist/invocation/index.js +2 -0
- package/dist/invocation/policy.d.ts +157 -0
- package/dist/invocation/policy.js +231 -0
- package/dist/invocation/types.d.ts +172 -0
- package/dist/invocation/types.js +97 -0
- package/dist/ipc/diagnostic.d.ts +0 -12
- package/dist/ipc/diagnostic.js +0 -21
- package/dist/ipc/host.d.ts +4 -4
- package/dist/ipc/host.js +44 -47
- package/dist/ipc/index.d.ts +1 -1
- package/dist/ipc/index.js +1 -1
- package/dist/ipc/service.d.ts +40 -0
- package/dist/ipc/service.js +349 -0
- package/dist/ipc/types.d.ts +21 -15
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/module-loader.d.ts +63 -0
- package/dist/node/module-loader.js +112 -0
- package/dist/package/index.d.ts +23 -0
- package/dist/package/index.js +18 -0
- package/dist/{app/app.d.ts → package/runtime.d.ts} +41 -20
- package/dist/{app/app.js → package/runtime.js} +140 -95
- package/dist/{app → package}/static-index.js +58 -41
- package/dist/package/storage-view.d.ts +13 -0
- package/dist/package/storage-view.js +22 -0
- package/dist/{app → package}/types.d.ts +76 -57
- package/dist/package/types.js +22 -0
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/node.d.ts +48 -0
- package/dist/platform/node.js +96 -0
- package/dist/platform/types.d.ts +0 -9
- package/dist/process/control-arbiter.d.ts +2 -1
- package/dist/process/control-arbiter.js +1 -2
- package/dist/process/driver.d.ts +9 -8
- package/dist/process/driver.js +11 -22
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +2 -0
- package/dist/process/managed-record.d.ts +2 -2
- package/dist/process/process-driver.d.ts +109 -0
- package/dist/process/process-driver.js +650 -0
- package/dist/process/process-executor.d.ts +47 -0
- package/dist/process/process-executor.js +296 -0
- package/dist/process/process-manager.js +48 -26
- package/dist/process/run-executor.js +12 -12
- package/dist/profile/client-actions.js +2 -2
- package/dist/profile/client-health.js +2 -2
- package/dist/profile/client-query.js +5 -6
- package/dist/profile/client-transport.d.ts +19 -17
- package/dist/profile/client-transport.js +47 -80
- package/dist/profile/client.d.ts +2 -2
- package/dist/profile/client.js +1 -1
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile/index.js +1 -0
- package/dist/profile/manager.d.ts +5 -0
- package/dist/profile/manager.js +41 -6
- package/dist/project/closure.js +2 -2
- package/dist/project/index.d.ts +8 -1
- package/dist/project/index.js +10 -1
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +1 -1
- package/dist/project/loader.js +26 -29
- package/dist/project/transactions.js +5 -10
- package/dist/registry/index.d.ts +3 -1
- package/dist/registry/index.js +2 -1
- package/dist/registry/lock.d.ts +28 -7
- package/dist/registry/lock.js +136 -16
- package/dist/registry/registry.d.ts +1 -5
- package/dist/registry/registry.js +1 -53
- package/dist/registry/scan.d.ts +0 -15
- package/dist/registry/scan.js +0 -59
- package/dist/registry/store.d.ts +42 -0
- package/dist/registry/store.js +43 -0
- package/dist/registry/types.d.ts +0 -24
- package/dist/runtime/action-collection.d.ts +1 -1
- package/dist/runtime/action-registry.d.ts +0 -4
- package/dist/runtime/action-registry.js +0 -7
- package/dist/runtime/context.js +5 -11
- package/dist/runtime/events.js +3 -6
- package/dist/runtime/identity.d.ts +22 -0
- package/dist/runtime/identity.js +10 -0
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +1 -2
- package/dist/runtime/module-loader.d.ts +2 -34
- package/dist/runtime/module-loader.js +1 -16
- package/dist/runtime/process.d.ts +6 -24
- package/dist/runtime/process.js +1 -118
- package/dist/runtime/run-persistence.js +2 -5
- package/dist/runtime/runner.d.ts +33 -93
- package/dist/runtime/runner.js +132 -364
- package/dist/runtime/standalone.d.ts +23 -8
- package/dist/runtime/standalone.js +100 -147
- package/dist/server/body.d.ts +16 -8
- package/dist/server/body.js +33 -16
- package/dist/server/dispatcher.d.ts +6 -10
- package/dist/server/dispatcher.js +24 -32
- package/dist/server/http-server.d.ts +87 -0
- package/dist/server/http-server.js +304 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +10 -0
- package/dist/server/mcp-endpoint.d.ts +61 -0
- package/dist/server/mcp-endpoint.js +118 -0
- package/dist/server/routes/actions.js +34 -28
- package/dist/server/routes/common.d.ts +10 -14
- package/dist/server/routes/common.js +32 -56
- package/dist/server/routes/config.js +54 -64
- package/dist/server/routes/doctor.d.ts +1 -1
- package/dist/server/routes/doctor.js +10 -18
- package/dist/server/routes/health.d.ts +1 -1
- package/dist/server/routes/health.js +2 -3
- package/dist/server/routes/info.d.ts +2 -2
- package/dist/server/routes/info.js +12 -13
- package/dist/server/routes/playbooks.js +16 -29
- package/dist/server/routes/runs.js +95 -117
- package/dist/server/routes/state.js +63 -62
- package/dist/server/server.d.ts +2 -2
- package/dist/server/server.js +43 -227
- package/dist/server/types.d.ts +8 -19
- package/dist/service/factory.d.ts +12 -0
- package/dist/service/factory.js +85 -0
- package/dist/{target → service}/index.d.ts +1 -1
- package/dist/{target → service}/index.js +1 -1
- package/dist/service/local.d.ts +27 -0
- package/dist/service/local.js +138 -0
- package/dist/{target → service}/remote-errors.d.ts +3 -6
- package/dist/service/remote-errors.js +38 -0
- package/dist/{target → service}/remote-polling.d.ts +2 -2
- package/dist/{target → service}/remote-polling.js +8 -8
- package/dist/service/remote.d.ts +34 -0
- package/dist/service/remote.js +634 -0
- package/dist/service/sse-stream.d.ts +24 -0
- package/dist/service/sse-stream.js +139 -0
- package/dist/service/types.d.ts +272 -0
- package/dist/service/types.js +32 -0
- package/dist/storage/data-dir-lock.js +10 -5
- package/dist/storage/driver.d.ts +2 -1
- package/dist/storage/driver.js +3 -52
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/lock-core.d.ts +2 -6
- package/dist/storage/lock-core.js +4 -17
- package/dist/storage/params.d.ts +2 -8
- package/dist/storage/params.js +2 -8
- package/dist/storage/sqlite-driver.d.ts +40 -0
- package/dist/storage/sqlite-driver.js +116 -0
- package/dist/storage/sqlite.js +21 -6
- package/dist/storage/types.d.ts +4 -4
- package/dist/storage/types.js +2 -2
- package/dist/utils/index.d.ts +53 -0
- package/dist/utils/index.js +99 -4
- package/dist/utils/process.d.ts +10 -0
- package/dist/utils/process.js +21 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +41 -3
- package/dist/app/index.d.ts +0 -2
- package/dist/app/index.js +0 -2
- package/dist/app/types.js +0 -1
- package/dist/catalog/action-index.d.ts +0 -9
- package/dist/catalog/action-index.js +0 -95
- package/dist/catalog/action-resolver.d.ts +0 -20
- package/dist/catalog/action-resolver.js +0 -95
- package/dist/catalog/location-registry.d.ts +0 -15
- package/dist/catalog/location-registry.js +0 -138
- package/dist/catalog/package-catalog.d.ts +0 -7
- package/dist/catalog/package-catalog.js +0 -77
- package/dist/catalog/types.d.ts +0 -68
- package/dist/catalog/types.js +0 -1
- package/dist/export/index.d.ts +0 -1
- package/dist/export/index.js +0 -1
- package/dist/export/templates.d.ts +0 -71
- package/dist/export/templates.js +0 -635
- package/dist/ipc/target.d.ts +0 -74
- package/dist/ipc/target.js +0 -365
- package/dist/platform/default.d.ts +0 -38
- package/dist/platform/default.js +0 -78
- package/dist/project/resolver.d.ts +0 -116
- package/dist/project/resolver.js +0 -376
- package/dist/registry/resolve.d.ts +0 -62
- package/dist/registry/resolve.js +0 -195
- package/dist/runtime/execution-manager.d.ts +0 -48
- package/dist/runtime/execution-manager.js +0 -66
- package/dist/runtime/package-runner-factory.d.ts +0 -82
- package/dist/runtime/package-runner-factory.js +0 -186
- package/dist/target/local.d.ts +0 -53
- package/dist/target/local.js +0 -349
- package/dist/target/remote-errors.js +0 -51
- package/dist/target/remote.d.ts +0 -86
- package/dist/target/remote.js +0 -818
- package/dist/target/target.d.ts +0 -6
- package/dist/target/target.js +0 -37
- package/dist/target/types.d.ts +0 -261
- package/dist/target/types.js +0 -35
- /package/dist/{app → package}/static-index.d.ts +0 -0
- /package/dist/{target → service}/sse-parser.d.ts +0 -0
- /package/dist/{target → service}/sse-parser.js +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一源码模块加载器接口。
|
|
3
|
+
* 解耦 Action 与各类扩展模块的具体加载机制(如 ECMAScript 原生 import、tsx 动态转译加载等)。
|
|
4
|
+
*/
|
|
5
|
+
export interface ModuleLoader {
|
|
6
|
+
/**
|
|
7
|
+
* 解析模块标识符为绝对路径或完整 URL。
|
|
8
|
+
*
|
|
9
|
+
* @param specifier 模块规范说明符或物理路径
|
|
10
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
11
|
+
*/
|
|
12
|
+
resolve?(specifier: string, parentPath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 动态加载模块并返回命名空间全量导出对象。
|
|
15
|
+
*
|
|
16
|
+
* @param specifier 模块规范说明符或物理路径
|
|
17
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
18
|
+
*/
|
|
19
|
+
load<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* 加载模块并解包其默认导出(default 或 action 属性)。
|
|
22
|
+
*
|
|
23
|
+
* @param specifier 模块规范说明符或物理路径
|
|
24
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
25
|
+
*/
|
|
26
|
+
loadDefault?<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 解包模块的默认导出对象,优先获取 default 或 action,自动解开嵌套互操作对象。
|
|
30
|
+
*
|
|
31
|
+
* @param moduleExports 待解包的模块导出对象
|
|
32
|
+
*/
|
|
33
|
+
export declare function unwrapDefaultExport<T = any>(moduleExports: any): T;
|
|
34
|
+
/**
|
|
35
|
+
* 基于 Node.js 原生 ESM 动态 import 的源码模块加载器。
|
|
36
|
+
* 遵循 Node 原生模块规范:
|
|
37
|
+
* - 严格要求显式入口扩展名(.ts, .mts, .js, .mjs)
|
|
38
|
+
* - 彻底拒绝无扩展名自动推断与 CommonJS 目录索引解析
|
|
39
|
+
* - 完全移除第三方转译运行时依赖
|
|
40
|
+
*/
|
|
41
|
+
export declare class NodeModuleLoader implements ModuleLoader {
|
|
42
|
+
/**
|
|
43
|
+
* 解析模块标识符与路径,严格要求显式扩展名且拒绝目录补全。
|
|
44
|
+
*
|
|
45
|
+
* @param specifier 模块规范说明符或相对/绝对物理路径
|
|
46
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
47
|
+
*/
|
|
48
|
+
resolve(specifier: string, parentPath?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* 基于 Node 原生 ESM 动态 import 加载模块并返回其全量导出对象。
|
|
51
|
+
*
|
|
52
|
+
* @param specifier 模块规范说明符或物理路径
|
|
53
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
54
|
+
*/
|
|
55
|
+
load<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
56
|
+
/**
|
|
57
|
+
* 加载模块并解包其默认导出(default 或 action)。
|
|
58
|
+
*
|
|
59
|
+
* @param specifier 模块规范说明符或物理路径
|
|
60
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
61
|
+
*/
|
|
62
|
+
loadDefault<T = any>(specifier: string, parentPath?: string): Promise<T>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, extname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { ActionDockError, ACTION_LOAD_FAILED } from "../errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* Node 原生 TypeScript 与 ESM 模块支持的扩展名集合。
|
|
7
|
+
*/
|
|
8
|
+
const ALLOWED_EXTENSIONS = new Set([".ts", ".mts", ".js", ".mjs"]);
|
|
9
|
+
/**
|
|
10
|
+
* 解包模块的默认导出对象,优先获取 default 或 action,自动解开嵌套互操作对象。
|
|
11
|
+
*
|
|
12
|
+
* @param moduleExports 待解包的模块导出对象
|
|
13
|
+
*/
|
|
14
|
+
export function unwrapDefaultExport(moduleExports) {
|
|
15
|
+
if (moduleExports === null || moduleExports === undefined) {
|
|
16
|
+
return moduleExports;
|
|
17
|
+
}
|
|
18
|
+
let target = moduleExports.default !== undefined
|
|
19
|
+
? moduleExports.default
|
|
20
|
+
: moduleExports.action !== undefined
|
|
21
|
+
? moduleExports.action
|
|
22
|
+
: moduleExports;
|
|
23
|
+
if (target &&
|
|
24
|
+
typeof target === "object" &&
|
|
25
|
+
"default" in target &&
|
|
26
|
+
Object.keys(target).length === 1) {
|
|
27
|
+
target = target.default;
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 基于 Node.js 原生 ESM 动态 import 的源码模块加载器。
|
|
33
|
+
* 遵循 Node 原生模块规范:
|
|
34
|
+
* - 严格要求显式入口扩展名(.ts, .mts, .js, .mjs)
|
|
35
|
+
* - 彻底拒绝无扩展名自动推断与 CommonJS 目录索引解析
|
|
36
|
+
* - 完全移除第三方转译运行时依赖
|
|
37
|
+
*/
|
|
38
|
+
export class NodeModuleLoader {
|
|
39
|
+
/**
|
|
40
|
+
* 解析模块标识符与路径,严格要求显式扩展名且拒绝目录补全。
|
|
41
|
+
*
|
|
42
|
+
* @param specifier 模块规范说明符或相对/绝对物理路径
|
|
43
|
+
* @param parentPath 发起解析的父级文件或目录路径
|
|
44
|
+
*/
|
|
45
|
+
resolve(specifier, parentPath) {
|
|
46
|
+
let target = specifier;
|
|
47
|
+
if (target.startsWith("file://")) {
|
|
48
|
+
target = fileURLToPath(target);
|
|
49
|
+
}
|
|
50
|
+
let baseDir = process.cwd();
|
|
51
|
+
if (parentPath) {
|
|
52
|
+
try {
|
|
53
|
+
const p = parentPath.startsWith("file://")
|
|
54
|
+
? fileURLToPath(parentPath)
|
|
55
|
+
: parentPath;
|
|
56
|
+
if (existsSync(p)) {
|
|
57
|
+
const stat = statSync(p);
|
|
58
|
+
baseDir = stat.isDirectory() ? resolve(p) : dirname(resolve(p));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
baseDir = dirname(resolve(p));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
baseDir = process.cwd();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const candidateBasePath = isAbsolute(target) ? target : resolve(baseDir, target);
|
|
69
|
+
const ext = extname(candidateBasePath);
|
|
70
|
+
if (!ext) {
|
|
71
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': missing file extension. Explicit .ts, .mts, .js, or .mjs extension is required.`);
|
|
72
|
+
}
|
|
73
|
+
if (!ALLOWED_EXTENSIONS.has(ext)) {
|
|
74
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': unsupported extension '${ext}'. Only .ts, .mts, .js, and .mjs are supported.`);
|
|
75
|
+
}
|
|
76
|
+
if (!existsSync(candidateBasePath)) {
|
|
77
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': file not found`);
|
|
78
|
+
}
|
|
79
|
+
let stat;
|
|
80
|
+
try {
|
|
81
|
+
stat = statSync(candidateBasePath);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
throw new ActionDockError(ACTION_LOAD_FAILED, `Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
if (!stat.isFile()) {
|
|
87
|
+
throw new ActionDockError(ACTION_LOAD_FAILED, `Cannot resolve module '${specifier}' from '${parentPath || process.cwd()}': path is not a file`);
|
|
88
|
+
}
|
|
89
|
+
return candidateBasePath;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 基于 Node 原生 ESM 动态 import 加载模块并返回其全量导出对象。
|
|
93
|
+
*
|
|
94
|
+
* @param specifier 模块规范说明符或物理路径
|
|
95
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
96
|
+
*/
|
|
97
|
+
async load(specifier, parentPath) {
|
|
98
|
+
const resolvedPath = this.resolve(specifier, parentPath);
|
|
99
|
+
const fileUrl = pathToFileURL(resolvedPath).href;
|
|
100
|
+
return (await import(fileUrl));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 加载模块并解包其默认导出(default 或 action)。
|
|
104
|
+
*
|
|
105
|
+
* @param specifier 模块规范说明符或物理路径
|
|
106
|
+
* @param parentPath 发起加载的父级文件或目录路径
|
|
107
|
+
*/
|
|
108
|
+
async loadDefault(specifier, parentPath) {
|
|
109
|
+
const mod = await this.load(specifier, parentPath);
|
|
110
|
+
return unwrapDefaultExport(mod);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionDock 包级运行时必要门面与契约。
|
|
3
|
+
*
|
|
4
|
+
* 遵循 Minimal 暴露准则:仅对外输出 PackageRuntime、PackageRuntimeOptions、
|
|
5
|
+
* createPackageRuntime 以及包与动作元数据契约(PackageInfo、ActionSpec、ActionSummary、
|
|
6
|
+
* PlaybookSpec、PlaybookSummary)。
|
|
7
|
+
* 底层存储驱动、独立分发器与平台大对象统一由核心根入口导出。
|
|
8
|
+
*/
|
|
9
|
+
export { createPackageRuntime, DefaultPackageRuntime, } from "./runtime.js";
|
|
10
|
+
export { createNonClosingStorageView } from "./storage-view.js";
|
|
11
|
+
export { findExecutable } from "../utils/index.js";
|
|
12
|
+
export type { PackageRuntime, PackageRuntimeOptions, PackageInfo, ActionSpec, ActionSummary, PlaybookSpec, PlaybookSummary, } from "./types.js";
|
|
13
|
+
export type { RuntimePlatform, FileSystem, StorageFactory, StorageFactoryOptions, GlobalStorageFactoryOptions, } from "../platform/types.js";
|
|
14
|
+
export { type Clock, SystemClock, } from "../runtime/clock.js";
|
|
15
|
+
export type { ModuleLoader } from "../node/module-loader.js";
|
|
16
|
+
export { InMemoryEventSink, type EventSink, } from "../runtime/events.js";
|
|
17
|
+
export { ProcessManager, type ProcessOwner, } from "../process/process-manager.js";
|
|
18
|
+
export type { ProcessExecutor } from "../runtime/process.js";
|
|
19
|
+
export { NodeProcessExecutor } from "../process/process-executor.js";
|
|
20
|
+
export type { ProcessDriver, ProcessDriverCallbacks, ProcessDriverHandle, ProcessHandle, ProcessObserver, } from "../process/driver.js";
|
|
21
|
+
export { createStorage, resolveDatabasePath, } from "../storage/index.js";
|
|
22
|
+
export { SqliteRuntimeStorage } from "../storage/sqlite.js";
|
|
23
|
+
export type { RuntimeStorage, SqliteDriver, StateEntry, } from "../storage/types.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionDock 包级运行时必要门面与契约。
|
|
3
|
+
*
|
|
4
|
+
* 遵循 Minimal 暴露准则:仅对外输出 PackageRuntime、PackageRuntimeOptions、
|
|
5
|
+
* createPackageRuntime 以及包与动作元数据契约(PackageInfo、ActionSpec、ActionSummary、
|
|
6
|
+
* PlaybookSpec、PlaybookSummary)。
|
|
7
|
+
* 底层存储驱动、独立分发器与平台大对象统一由核心根入口导出。
|
|
8
|
+
*/
|
|
9
|
+
export { createPackageRuntime, DefaultPackageRuntime, } from "./runtime.js";
|
|
10
|
+
export { createNonClosingStorageView } from "./storage-view.js";
|
|
11
|
+
export { findExecutable } from "../utils/index.js";
|
|
12
|
+
export { SystemClock, } from "../runtime/clock.js";
|
|
13
|
+
export { InMemoryEventSink, } from "../runtime/events.js";
|
|
14
|
+
export { ProcessManager, } from "../process/process-manager.js";
|
|
15
|
+
export { NodeProcessExecutor } from "../process/process-executor.js";
|
|
16
|
+
// 存储契约与驱动
|
|
17
|
+
export { createStorage, resolveDatabasePath, } from "../storage/index.js";
|
|
18
|
+
export { SqliteRuntimeStorage } from "../storage/sqlite.js";
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import { type RuntimePlatform } from "../platform/index.js";
|
|
1
|
+
import type { ExecutionEvent, ExecutionResult, JsonValue, RunRecord } from "@actiondock/sdk";
|
|
2
|
+
import type { ActionInvoker, CancelResult, ExecutionTicket } from "../execution/types.js";
|
|
4
3
|
import type { ProjectConfig } from "../project/types.js";
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
4
|
+
import { type PackageIdentity } from "../runtime/identity.js";
|
|
5
|
+
import { type InvocationContext, type RunOptions } from "../invocation/types.js";
|
|
6
|
+
import type { ActionSpec, ActionSummary, ConfigValueView, HostManagedPackageRuntime, ListActionsOptions, ListRunsOptions, PackageInfo, PackageRuntime, PackageRuntimeOptions, PackageRuntimeInternalOptions, PlaybookSpec, PlaybookSummary, StateScopeOptions } from "./types.js";
|
|
7
7
|
/**
|
|
8
|
-
* ActionDock
|
|
8
|
+
* ActionDock 统一包运行时默认实现。
|
|
9
9
|
* 封装并管理单个 Action Package 的执行引擎、静态元数据索引、配置与状态存储生命周期。
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class DefaultPackageRuntime implements HostManagedPackageRuntime {
|
|
12
|
+
readonly identity: PackageIdentity;
|
|
12
13
|
readonly packageId: string;
|
|
13
14
|
readonly packageInstanceId: string;
|
|
14
15
|
readonly generationId: string;
|
|
15
16
|
readonly packageRoot?: string;
|
|
16
17
|
readonly projectConfig: ProjectConfig;
|
|
17
|
-
readonly platform
|
|
18
|
-
readonly storage
|
|
19
|
-
readonly globalStorage
|
|
20
|
-
readonly executionService
|
|
21
|
-
readonly actionsMap
|
|
18
|
+
private readonly platform;
|
|
19
|
+
private readonly storage;
|
|
20
|
+
private readonly globalStorage?;
|
|
21
|
+
private readonly executionService;
|
|
22
|
+
private readonly actionsMap;
|
|
22
23
|
private readonly options;
|
|
23
24
|
private runtimeConfig;
|
|
24
25
|
private isClosed;
|
|
26
|
+
private injectedGlobalStorage;
|
|
25
27
|
/** 静态清单索引缓存:包静态事实(根目录、配置、内存注入集合)在实例生命周期内不变,解析结果同实例内复用 */
|
|
26
28
|
private staticActionIndex?;
|
|
27
29
|
private staticPlaybookIndex?;
|
|
28
|
-
constructor(options?:
|
|
30
|
+
constructor(options?: PackageRuntimeInternalOptions);
|
|
29
31
|
/**
|
|
30
32
|
* 静态读取并聚合当前包的 Action 规范索引。
|
|
31
33
|
* 聚合逻辑委托 static-index 单一事实源;同实例内复用首次解析结果,
|
|
@@ -44,8 +46,10 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
44
46
|
describeAction(id: string): Promise<ActionSpec>;
|
|
45
47
|
listPlaybooks(): Promise<PlaybookSummary[]>;
|
|
46
48
|
describePlaybook(id: string): Promise<PlaybookSpec>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
private buildRootInvocationContext;
|
|
50
|
+
runAction(id: string, input: JsonValue, options?: RunOptions): Promise<ExecutionResult>;
|
|
51
|
+
startAction(id: string, input: JsonValue, options?: RunOptions): Promise<ExecutionTicket>;
|
|
52
|
+
startInvocation(actionId: string, input: JsonValue, context: InvocationContext): Promise<ExecutionTicket>;
|
|
49
53
|
getRun(runId: string): Promise<RunRecord | undefined>;
|
|
50
54
|
cancelRun(runId: string, reason?: string): Promise<CancelResult>;
|
|
51
55
|
events(runId: string, options?: {
|
|
@@ -53,6 +57,8 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
53
57
|
signal?: AbortSignal;
|
|
54
58
|
maxQueueSize?: number;
|
|
55
59
|
}): AsyncIterable<ExecutionEvent>;
|
|
60
|
+
setActionInvoker(invoker?: ActionInvoker): void;
|
|
61
|
+
recoverDeadSessionRuns(sessionId?: string): void;
|
|
56
62
|
listConfig(): Promise<ConfigValueView[]>;
|
|
57
63
|
getConfig(key: string): Promise<ConfigValueView>;
|
|
58
64
|
setConfig(key: string, value: JsonValue): Promise<void>;
|
|
@@ -60,11 +66,20 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
60
66
|
/**
|
|
61
67
|
* 状态作用域统一解析辅助函数(单一事实源)。
|
|
62
68
|
*
|
|
63
|
-
*
|
|
64
|
-
* - actionId
|
|
65
|
-
* -
|
|
69
|
+
* 完成重载消歧后委托 mergeStateScope 计算最终生效的命名空间:
|
|
70
|
+
* - (actionId, key, options) 形态:位置 actionId 参与冲突校验;
|
|
71
|
+
* - (key, options) 扁平形态:首参是状态键,options.actionId 属合法显式指定。
|
|
66
72
|
*/
|
|
67
73
|
private resolveStateScope;
|
|
74
|
+
/**
|
|
75
|
+
* 合并位置 actionId 与 options.actionId 并计算最终命名空间(单一事实源)。
|
|
76
|
+
*
|
|
77
|
+
* - positionalActionId 非 undefined:调用形态携带位置 actionId,
|
|
78
|
+
* options.actionId 与其冲突时抛出异常(空串同样参与冲突校验);
|
|
79
|
+
* - positionalActionId 为 undefined:无位置 actionId 的扁平调用形态,
|
|
80
|
+
* options.actionId 属合法显式指定,直接采纳。
|
|
81
|
+
*/
|
|
82
|
+
private mergeStateScope;
|
|
68
83
|
getState<T extends JsonValue = JsonValue>(key: string, options?: StateScopeOptions): Promise<T | undefined>;
|
|
69
84
|
getState<T extends JsonValue = JsonValue>(actionId: string, key: string, options?: StateScopeOptions): Promise<T | undefined>;
|
|
70
85
|
setState<T extends JsonValue = JsonValue>(key: string, value: T, options?: StateScopeOptions): Promise<void>;
|
|
@@ -78,11 +93,17 @@ export declare class DefaultActionDockApp implements ActionDockApp {
|
|
|
78
93
|
listStateKeys(actionId: string, options?: StateScopeOptions): Promise<string[]>;
|
|
79
94
|
clearState(options?: StateScopeOptions): Promise<number>;
|
|
80
95
|
clearState(actionId: string, options?: StateScopeOptions): Promise<number>;
|
|
96
|
+
listRuns(options?: ListRunsOptions): Promise<RunRecord[]>;
|
|
97
|
+
clearRuns(options?: {
|
|
98
|
+
actionId?: string;
|
|
99
|
+
status?: string;
|
|
100
|
+
}): Promise<number>;
|
|
101
|
+
listStateEntries(options?: any): Promise<import("../storage/types.js").StateEntry[]>;
|
|
81
102
|
close(options?: {
|
|
82
103
|
graceMs?: number;
|
|
83
104
|
}): Promise<void>;
|
|
84
105
|
}
|
|
85
106
|
/**
|
|
86
|
-
* 工厂函数:创建并初始化
|
|
107
|
+
* 工厂函数:创建并初始化 PackageRuntime 实例。
|
|
87
108
|
*/
|
|
88
|
-
export declare function
|
|
109
|
+
export declare function createPackageRuntime(options?: PackageRuntimeOptions): Promise<PackageRuntime>;
|