@actiondock/core 2.6.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 +122 -10
- package/dist/errors.js +123 -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 -22
- package/dist/index.js +19 -21
- package/dist/input/advice.d.ts +104 -0
- package/dist/input/advice.js +716 -0
- package/dist/input/describe.d.ts +106 -0
- package/dist/input/describe.js +176 -0
- package/dist/input/file-input.d.ts +54 -0
- package/dist/input/file-input.js +124 -0
- package/dist/input/flat-decode.d.ts +11 -0
- package/dist/input/flat-decode.js +13 -0
- package/dist/input/flat-errors.d.ts +71 -0
- package/dist/input/flat-errors.js +87 -0
- package/dist/input/flat-materializer.d.ts +29 -0
- package/dist/input/flat-materializer.js +177 -0
- package/dist/input/flat-parser.d.ts +50 -0
- package/dist/input/flat-parser.js +169 -0
- package/dist/input/flat-predicates.d.ts +34 -0
- package/dist/input/flat-predicates.js +50 -0
- package/dist/input/index.d.ts +14 -0
- package/dist/input/index.js +14 -0
- package/dist/input/input-resolver.d.ts +63 -0
- package/dist/input/input-resolver.js +254 -0
- package/dist/input/json-depth-scanner.d.ts +17 -0
- package/dist/input/json-depth-scanner.js +49 -0
- package/dist/input/metadata.d.ts +99 -0
- package/dist/input/metadata.js +99 -0
- package/dist/input/stdin-input.d.ts +26 -0
- package/dist/input/stdin-input.js +125 -0
- package/dist/input/utf8.d.ts +19 -0
- package/dist/input/utf8.js +36 -0
- package/dist/input/validation-mapper.d.ts +27 -0
- package/dist/input/validation-mapper.js +144 -0
- package/dist/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/json/index.d.ts +1 -0
- package/dist/json/index.js +1 -0
- package/dist/json/value-validator.d.ts +88 -0
- package/dist/json/value-validator.js +330 -0
- package/dist/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 +3 -2
- package/dist/profile/client-query.js +5 -6
- package/dist/profile/client-transport.d.ts +19 -17
- package/dist/profile/client-transport.js +48 -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 -103
- package/dist/runtime/runner.js +142 -404
- package/dist/runtime/standalone.d.ts +37 -9
- package/dist/runtime/standalone.js +195 -136
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/validator.d.ts +10 -0
- package/dist/schema/validator.js +48 -54
- package/dist/server/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 -623
- 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
package/dist/runtime/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
*
|
|
3
|
+
* 进程执行器统一契约别名。
|
|
4
|
+
*
|
|
5
|
+
* 面向宿主与上层服务的进程能力均以 ProcessAPI 接口为准,
|
|
6
|
+
* 具体实现由各平台适配层(如 NodeProcessExecutor)提供。
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
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;
|
package/dist/runtime/process.js
CHANGED
|
@@ -1,118 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
/**
|
package/dist/runtime/runner.d.ts
CHANGED
|
@@ -2,48 +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
|
-
|
|
6
|
+
import type { PackageIdentity } from "./identity.js";
|
|
7
|
+
import type { ActionInvoker } from "../execution/types.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* 环路检测采用「当前递归路径栈」语义:对象仅在自身子树遍历期间保持标记,
|
|
12
|
-
* 子树遍历完成后立即移除,从而正确放行共享子对象的有向无环结构(如 {a: shared, b: shared})。
|
|
13
|
-
*/
|
|
14
|
-
export declare function validateJsonValue(val: unknown, stack?: WeakSet<object>): {
|
|
15
|
-
valid: true;
|
|
16
|
-
} | {
|
|
17
|
-
valid: false;
|
|
18
|
-
reason: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* 跨包运行上下文解析结果契约。
|
|
22
|
-
*/
|
|
23
|
-
export interface PackageContextResolution {
|
|
24
|
-
projectRoot?: string;
|
|
25
|
-
projectConfig?: ProjectConfig;
|
|
26
|
-
storage: RuntimeStorage;
|
|
27
|
-
actions?: Map<string, ActionDefinition>;
|
|
28
|
-
packageInstanceId?: string;
|
|
29
|
-
generationId?: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 跨包运行上下文解析委托函数契约。
|
|
9
|
+
* 局部动作解析器委托函数契约(仅限当前包内部动作)。
|
|
33
10
|
*/
|
|
34
|
-
export type
|
|
11
|
+
export type LocalActionResolver = (actionId: string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
|
|
35
12
|
/**
|
|
36
13
|
* ActionRunner 初始化配置选项。
|
|
37
14
|
*/
|
|
38
|
-
export interface
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
/** 包物理实例标识 */
|
|
42
|
-
packageInstanceId?: string;
|
|
43
|
-
/** 快照代次标识 */
|
|
44
|
-
generationId?: string;
|
|
15
|
+
export interface ActionRunnerOptions {
|
|
16
|
+
/** 显式注入的包物理与快照身份标识值对象(必填单一事实源) */
|
|
17
|
+
identity: PackageIdentity;
|
|
45
18
|
/** 持久化运行时存储实例(SQLite) */
|
|
46
|
-
storage
|
|
19
|
+
storage: RuntimeStorage;
|
|
47
20
|
/** 全局共享持久化存储实例(SQLite,用于单例池化避免泄漏) */
|
|
48
21
|
globalStorage?: RuntimeStorage;
|
|
49
22
|
/** 项目根目录绝对路径 */
|
|
@@ -58,25 +31,15 @@ export interface RunnerOptions {
|
|
|
58
31
|
process?: ProcessAPI;
|
|
59
32
|
/** 可选的时间与时钟源(默认使用存储内嵌时钟或系统时间) */
|
|
60
33
|
clock?: Clock;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/** 动态解析跨包或未注册 Action 的委托函数 */
|
|
64
|
-
actionResolver?: (ref: ActionRef | string, currentPackageId?: string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
|
|
65
|
-
/** 最大调用嵌套深度限制(防死循环/过深调用链,默认 16) */
|
|
66
|
-
maxCallDepth?: number;
|
|
67
|
-
/** 最大并发子任务数限制(默认 64) */
|
|
68
|
-
maxSubRuns?: number;
|
|
69
|
-
/** 跨包存储工厂 */
|
|
70
|
-
getStorageForPackage?: (packageId: string, projectRoot?: string) => RuntimeStorage;
|
|
71
|
-
/** 跨包运行上下文解析委托函数 */
|
|
72
|
-
packageContextResolver?: PackageContextResolver;
|
|
34
|
+
/** 仅支持当前包局部 Action 的动态解析委托函数 */
|
|
35
|
+
actionResolver?: LocalActionResolver;
|
|
73
36
|
/** 自定义 ActionDock 用户家目录(用于测试隔离与多租户环境) */
|
|
74
37
|
customHome?: string;
|
|
75
38
|
/** 执行宿主会话标识 */
|
|
76
39
|
hostSessionId?: string;
|
|
40
|
+
/** 子任务调用委托函数 */
|
|
41
|
+
actionInvoker?: ActionInvoker;
|
|
77
42
|
}
|
|
78
|
-
/** ActionRunnerOptions 别名兼容 */
|
|
79
|
-
export type ActionRunnerOptions = RunnerOptions;
|
|
80
43
|
/**
|
|
81
44
|
* 启动 Action 执行时的可选控制参数。
|
|
82
45
|
*/
|
|
@@ -111,14 +74,16 @@ export interface ExecutionStartOptions {
|
|
|
111
74
|
maxCallDepth?: number;
|
|
112
75
|
/** 外部注入的进程执行器 */
|
|
113
76
|
process?: ProcessAPI;
|
|
114
|
-
/**
|
|
115
|
-
|
|
77
|
+
/** 可选的时间与时钟源 */
|
|
78
|
+
clock?: Clock;
|
|
116
79
|
/** 外部注入的进度报告器 */
|
|
117
80
|
progress?: ProgressReporter;
|
|
118
81
|
/** 外部注入的日志记录器 */
|
|
119
82
|
logger?: Logger;
|
|
120
83
|
/** 执行级临时配置覆盖项 */
|
|
121
84
|
configOverrides?: Record<string, unknown>;
|
|
85
|
+
/** 子任务调用委托函数 */
|
|
86
|
+
actionInvoker?: ActionInvoker;
|
|
122
87
|
}
|
|
123
88
|
/**
|
|
124
89
|
* 异步执行句柄,支持获取执行结果 Promise 与主动取消操作。
|
|
@@ -144,26 +109,22 @@ export type ActionResolution = {
|
|
|
144
109
|
} | {
|
|
145
110
|
status: "not_found";
|
|
146
111
|
reason?: string;
|
|
147
|
-
} | {
|
|
148
|
-
status: "load_failed";
|
|
149
|
-
error: Error;
|
|
150
|
-
packageId: string;
|
|
151
|
-
projectRoot: string;
|
|
152
112
|
};
|
|
153
113
|
/**
|
|
154
114
|
* ActionDock 核心执行引擎(ActionRunner)。
|
|
155
115
|
*
|
|
156
116
|
* 本类为执行编排壳:负责 Action 执行的全生命周期编排(校验、深度与环路检测、
|
|
157
117
|
* 超时与取消竞态、子调用 uses 授权与错误分类),并将单一职责域委托至独立模块:
|
|
158
|
-
* - Action 注册与检索委托
|
|
118
|
+
* - Action 注册与检索委托 ActionRegistry(action-registry.ts)
|
|
159
119
|
* - RunRecord 构造与落库委托 run-persistence.ts
|
|
160
|
-
* -
|
|
120
|
+
* - 跨包动作调用委托注入的 ActionInvoker 并重返目标包执行服务
|
|
161
121
|
*
|
|
162
122
|
* 入参 (inputSchema) 与出参 (outputSchema) 的 JSON Schema 严格校验、嵌套 Action
|
|
163
123
|
* 相互调用的环路检测(Cycle Detection)、超时 (Timeout) 与中断信号 (AbortSignal)
|
|
164
124
|
* 竞态控制与运行记录持久化编排仍由本类承担。
|
|
165
125
|
*/
|
|
166
126
|
export declare class ActionRunner {
|
|
127
|
+
readonly identity: PackageIdentity;
|
|
167
128
|
readonly packageId: string;
|
|
168
129
|
readonly packageInstanceId: string;
|
|
169
130
|
readonly generationId: string;
|
|
@@ -175,20 +136,14 @@ export declare class ActionRunner {
|
|
|
175
136
|
private registry;
|
|
176
137
|
private clock?;
|
|
177
138
|
private process?;
|
|
178
|
-
private platform?;
|
|
179
|
-
private maxCallDepth;
|
|
180
|
-
private maxSubRuns;
|
|
181
|
-
private activeSubRuns;
|
|
182
|
-
private packageFactory;
|
|
183
|
-
private actionResolver?;
|
|
184
|
-
private getStorageForPackage?;
|
|
185
139
|
private customHome?;
|
|
140
|
+
private actionResolver?;
|
|
186
141
|
private hostSessionId?;
|
|
187
|
-
|
|
188
|
-
|
|
142
|
+
private actionInvoker?;
|
|
143
|
+
constructor(options: ActionRunnerOptions);
|
|
144
|
+
/** 本地 Action 注册表底层映射 */
|
|
189
145
|
private get actions();
|
|
190
146
|
getStorage(): RuntimeStorage;
|
|
191
|
-
getPackageRunners(): Map<string, ActionRunner>;
|
|
192
147
|
/**
|
|
193
148
|
* 注册单个 Action 到当前 Runner。
|
|
194
149
|
*/
|
|
@@ -201,29 +156,21 @@ export declare class ActionRunner {
|
|
|
201
156
|
* 根据 ID 检索注册的 Action。
|
|
202
157
|
*/
|
|
203
158
|
getAction(id: string): ActionDefinition | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* 设置子任务动作调用委托器。
|
|
161
|
+
*/
|
|
162
|
+
setActionInvoker(invoker?: ActionInvoker): void;
|
|
204
163
|
/**
|
|
205
164
|
* 动态解析 Action(支持本地注册表、自定义解析器委托与已链接包目录索引检索)。
|
|
206
165
|
*
|
|
207
166
|
* @param actionOrRef Action 定义对象、引用或标识符
|
|
208
|
-
* @returns 解析判别联合结果(found | not_found
|
|
167
|
+
* @returns 解析判别联合结果(found | not_found)
|
|
209
168
|
*/
|
|
210
169
|
resolveAction(actionOrRef: ActionDefinition | ActionRef | string): Promise<ActionResolution>;
|
|
211
170
|
/**
|
|
212
171
|
* 获取当前 Runner 已注册的所有 Action 列表。
|
|
213
172
|
*/
|
|
214
173
|
listActions(): ActionDefinition[];
|
|
215
|
-
/**
|
|
216
|
-
* 注入或更新跨包运行上下文解析委托。
|
|
217
|
-
*/
|
|
218
|
-
setPackageContextResolver(resolver: PackageContextResolver): void;
|
|
219
|
-
/**
|
|
220
|
-
* 跨包运行时解析与获取(确保跨包执行具备独立的配置、存储、状态与 Action 注册表)。
|
|
221
|
-
*
|
|
222
|
-
* 缓存 miss 后存在长异步窗口(加载配置、扫描 Action、打开存储),并发调用会重复构建
|
|
223
|
-
* Runner、重复打开 SQLite 连接且子任务限流计数分裂;故以 in-flight Promise 去重,
|
|
224
|
-
* 并发方 await 同一构建任务,构建失败时移除该 Promise 以便后续重试。
|
|
225
|
-
*/
|
|
226
|
-
resolveTargetPackageRunner(targetPackageId: string): Promise<ActionRunner | undefined>;
|
|
227
174
|
/**
|
|
228
175
|
* 异步启动 Action 的执行并立即返回 ExecutionHandle 句柄。
|
|
229
176
|
*
|
|
@@ -245,14 +192,6 @@ export declare class ActionRunner {
|
|
|
245
192
|
* 依据运行期上下文装配落库模块入参(RunRecord 构造领域契约)。
|
|
246
193
|
*/
|
|
247
194
|
private buildRunPersistenceInput;
|
|
248
|
-
/**
|
|
249
|
-
* 调用嵌套深度限制检测(超限时返回 ACTION_CALL_CYCLE 错误)。
|
|
250
|
-
*/
|
|
251
|
-
private checkCallDepth;
|
|
252
|
-
/**
|
|
253
|
-
* 计算调用键并执行环路死锁检测(命中时返回携带错误的调用键结果)。
|
|
254
|
-
*/
|
|
255
|
-
private computeCallKey;
|
|
256
195
|
/**
|
|
257
196
|
* 输入参数 JSON Schema 校验(若 action 已就绪,返回校验错误或 undefined)。
|
|
258
197
|
*/
|
|
@@ -262,17 +201,11 @@ export declare class ActionRunner {
|
|
|
262
201
|
*/
|
|
263
202
|
private buildActionContext;
|
|
264
203
|
/**
|
|
265
|
-
* 子 Action
|
|
204
|
+
* 子 Action 调用委托:
|
|
205
|
+
* 必须委托 Host 动作调用器(走 Host 执行主链与 InvocationPolicy 鉴权);
|
|
206
|
+
* 缺少 actionInvoker 时直接抛出 INVOCATION_UNSUPPORTED,严禁跨包或同包无约束执行逃逸。
|
|
266
207
|
*/
|
|
267
208
|
private invokeChildAction;
|
|
268
|
-
/**
|
|
269
|
-
* 校验跨包子调用是否已在 uses 声明中授权(未声明时抛出 UNDECLARED_ACTION_DEPENDENCY)。
|
|
270
|
-
*/
|
|
271
|
-
private assertDeclaredUses;
|
|
272
|
-
/**
|
|
273
|
-
* 解析子调用应使用的 Runner(本包或已解析的目标包 Runner)。
|
|
274
|
-
*/
|
|
275
|
-
private resolveChildRunner;
|
|
276
209
|
/**
|
|
277
210
|
* 执行 Action 业务逻辑并与取消/超时信号进行竞态,返回执行结果信封 Promise。
|
|
278
211
|
*/
|
|
@@ -286,11 +219,8 @@ export declare class ActionRunner {
|
|
|
286
219
|
*/
|
|
287
220
|
private classifyExecutionError;
|
|
288
221
|
/**
|
|
289
|
-
* 释放 Runner
|
|
290
|
-
*
|
|
291
|
-
* 幂等且并发安全:重复调用直接复用首次 Promise;子包存储异常不阻断其余释放;
|
|
292
|
-
* 仅关闭由本 Runner 构建子包 Runner 时独立创建的存储,外部注入的存储(如经
|
|
293
|
-
* packageContextResolver 传入的目标包自身存储)生命周期归所有者管理,不在此误关。
|
|
222
|
+
* 释放 Runner 持有的资源。
|
|
223
|
+
* 铁律 4:Runner 仅执行自己所属 Package 的 Action,不管理外部包生命周期。
|
|
294
224
|
*/
|
|
295
225
|
dispose(): Promise<void>;
|
|
296
226
|
/**
|