@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
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { loadManifest } from "../project/manifest.js";
|
|
4
|
-
export class ActionIndex {
|
|
5
|
-
actions = new Map(); // actionId -> IndexedAction[]
|
|
6
|
-
constructor(snapshot) {
|
|
7
|
-
this.indexSnapshot(snapshot);
|
|
8
|
-
}
|
|
9
|
-
indexSnapshot(snapshot) {
|
|
10
|
-
for (const [packageId, pkg] of snapshot.packages) {
|
|
11
|
-
let manifest = null;
|
|
12
|
-
try {
|
|
13
|
-
manifest = loadManifest(pkg.projectRoot);
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
// 清单损坏时跳过索引但输出告警含路径,回退扫描 actions 目录
|
|
17
|
-
console.warn(`[Catalog] Failed to load manifest for package '${packageId}' at '${pkg.projectRoot}': ${err?.message || String(err)}`);
|
|
18
|
-
}
|
|
19
|
-
if (manifest && manifest.actions) {
|
|
20
|
-
for (const [actionId, item] of Object.entries(manifest.actions)) {
|
|
21
|
-
const indexed = {
|
|
22
|
-
packageId,
|
|
23
|
-
actionId,
|
|
24
|
-
contract: {
|
|
25
|
-
id: actionId,
|
|
26
|
-
description: item.description,
|
|
27
|
-
inputSchema: item.inputSchema,
|
|
28
|
-
outputSchema: item.outputSchema,
|
|
29
|
-
uses: item.uses,
|
|
30
|
-
tags: item.tags,
|
|
31
|
-
annotations: item.annotations,
|
|
32
|
-
},
|
|
33
|
-
entry: item.entry,
|
|
34
|
-
projectRoot: pkg.projectRoot,
|
|
35
|
-
};
|
|
36
|
-
this.add(indexed);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// 向后兼容回退:若未提供清单,扫描 actions 目录生成基础索引
|
|
41
|
-
const actionsDir = join(pkg.projectRoot, pkg.config.actionsDir || "actions");
|
|
42
|
-
if (existsSync(actionsDir)) {
|
|
43
|
-
try {
|
|
44
|
-
const files = readdirSync(actionsDir);
|
|
45
|
-
for (const file of files) {
|
|
46
|
-
if (file.endsWith(".ts") || file.endsWith(".js")) {
|
|
47
|
-
const actionId = file.replace(/\.(ts|js)$/, "");
|
|
48
|
-
const indexed = {
|
|
49
|
-
packageId,
|
|
50
|
-
actionId,
|
|
51
|
-
contract: {
|
|
52
|
-
id: actionId,
|
|
53
|
-
},
|
|
54
|
-
entry: join(pkg.config.actionsDir || "actions", file),
|
|
55
|
-
projectRoot: pkg.projectRoot,
|
|
56
|
-
};
|
|
57
|
-
this.add(indexed);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
// 目录扫描失败时输出告警含路径,不再无声吞没
|
|
63
|
-
console.warn(`[Catalog] Failed to scan actions directory for package '${packageId}' at '${actionsDir}': ${err?.message || String(err)}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
add(action) {
|
|
70
|
-
let list = this.actions.get(action.actionId);
|
|
71
|
-
if (!list) {
|
|
72
|
-
list = [];
|
|
73
|
-
this.actions.set(action.actionId, list);
|
|
74
|
-
}
|
|
75
|
-
list.push(action);
|
|
76
|
-
}
|
|
77
|
-
list(packageId) {
|
|
78
|
-
const all = [];
|
|
79
|
-
for (const [_, list] of this.actions) {
|
|
80
|
-
for (const action of list) {
|
|
81
|
-
if (!packageId || action.packageId === packageId) {
|
|
82
|
-
all.push(action);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return all;
|
|
87
|
-
}
|
|
88
|
-
find(actionId, packageId) {
|
|
89
|
-
const matches = this.actions.get(actionId) || [];
|
|
90
|
-
if (packageId) {
|
|
91
|
-
return matches.filter((a) => a.packageId === packageId);
|
|
92
|
-
}
|
|
93
|
-
return matches;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ActionRef, ResolvedActionRef } from "@actiondock/sdk";
|
|
2
|
-
import { ActionIndex } from "./action-index.js";
|
|
3
|
-
import type { CatalogSnapshot, IndexedAction } from "./types.js";
|
|
4
|
-
export interface ResolveOptions {
|
|
5
|
-
currentPackageId?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class ActionResolver {
|
|
8
|
-
private snapshot;
|
|
9
|
-
private index;
|
|
10
|
-
constructor(snapshot: CatalogSnapshot, index?: ActionIndex);
|
|
11
|
-
/**
|
|
12
|
-
* 解析字符串或 ActionRef 为规范化的 ActionRef。
|
|
13
|
-
* 支持 greet、my-tools/greet、@team/github/issues.list。
|
|
14
|
-
*/
|
|
15
|
-
static parseRef(refStringOrObj: string | ActionRef): ActionRef;
|
|
16
|
-
resolve(refStringOrObj: string | ActionRef, options?: ResolveOptions): {
|
|
17
|
-
resolved: ResolvedActionRef;
|
|
18
|
-
action: IndexedAction;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ActionIndex } from "./action-index.js";
|
|
2
|
-
export class ActionResolver {
|
|
3
|
-
snapshot;
|
|
4
|
-
index;
|
|
5
|
-
constructor(snapshot, index) {
|
|
6
|
-
this.snapshot = snapshot;
|
|
7
|
-
this.index = index || new ActionIndex(snapshot);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 解析字符串或 ActionRef 为规范化的 ActionRef。
|
|
11
|
-
* 支持 greet、my-tools/greet、@team/github/issues.list。
|
|
12
|
-
*/
|
|
13
|
-
static parseRef(refStringOrObj) {
|
|
14
|
-
if (typeof refStringOrObj === "object") {
|
|
15
|
-
return refStringOrObj;
|
|
16
|
-
}
|
|
17
|
-
const str = refStringOrObj.trim();
|
|
18
|
-
if (str.includes("/")) {
|
|
19
|
-
const lastSlashIndex = str.lastIndexOf("/");
|
|
20
|
-
const packageId = str.slice(0, lastSlashIndex);
|
|
21
|
-
const actionId = str.slice(lastSlashIndex + 1);
|
|
22
|
-
if (actionId.includes(":") || actionId.includes("/") || actionId.includes("..")) {
|
|
23
|
-
throw new Error(`Invalid action identifier: '${actionId}'`);
|
|
24
|
-
}
|
|
25
|
-
return { packageId, actionId };
|
|
26
|
-
}
|
|
27
|
-
// 处理旧语法 package:action 的兼容提醒
|
|
28
|
-
if (str.includes(":")) {
|
|
29
|
-
const parts = str.split(":");
|
|
30
|
-
throw new Error(`Legacy syntax '${str}' is deprecated. Please use '${parts.join("/")}' instead.`);
|
|
31
|
-
}
|
|
32
|
-
return { actionId: str };
|
|
33
|
-
}
|
|
34
|
-
resolve(refStringOrObj, options = {}) {
|
|
35
|
-
const ref = ActionResolver.parseRef(refStringOrObj);
|
|
36
|
-
// 1. 若指定了 packageId,直接精确匹配
|
|
37
|
-
if (ref.packageId) {
|
|
38
|
-
const matches = this.index.find(ref.actionId, ref.packageId);
|
|
39
|
-
if (matches.length === 0) {
|
|
40
|
-
throw new Error(`ACTION_NOT_FOUND: Action '${ref.actionId}' not found in package '${ref.packageId}'`);
|
|
41
|
-
}
|
|
42
|
-
const matched = matches[0];
|
|
43
|
-
const pkg = this.snapshot.packages.get(matched.packageId);
|
|
44
|
-
return {
|
|
45
|
-
resolved: {
|
|
46
|
-
packageId: matched.packageId,
|
|
47
|
-
packageInstanceId: pkg?.packageInstanceId || matched.packageId,
|
|
48
|
-
actionId: matched.actionId,
|
|
49
|
-
generationId: this.snapshot.generationId,
|
|
50
|
-
},
|
|
51
|
-
action: matched,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// 2. 未指定 packageId:优先查找当前调用者包
|
|
55
|
-
if (options.currentPackageId) {
|
|
56
|
-
const inCurrent = this.index.find(ref.actionId, options.currentPackageId);
|
|
57
|
-
if (inCurrent.length > 0) {
|
|
58
|
-
const matched = inCurrent[0];
|
|
59
|
-
const pkg = this.snapshot.packages.get(matched.packageId);
|
|
60
|
-
return {
|
|
61
|
-
resolved: {
|
|
62
|
-
packageId: matched.packageId,
|
|
63
|
-
packageInstanceId: pkg?.packageInstanceId || matched.packageId,
|
|
64
|
-
actionId: matched.actionId,
|
|
65
|
-
generationId: this.snapshot.generationId,
|
|
66
|
-
},
|
|
67
|
-
action: matched,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// 3. 全局唯一匹配检查
|
|
72
|
-
const allMatches = this.index.find(ref.actionId);
|
|
73
|
-
if (allMatches.length === 0) {
|
|
74
|
-
throw new Error(`ACTION_NOT_FOUND: Action '${ref.actionId}' not found in any linked package`);
|
|
75
|
-
}
|
|
76
|
-
if (allMatches.length > 1) {
|
|
77
|
-
const candidates = allMatches.map((m) => `${m.packageId}/${m.actionId}`).join(", ");
|
|
78
|
-
const err = new Error(`INVALID_ACTION_REF: Action '${ref.actionId}' is ambiguous and provided by multiple packages: ${candidates}. Please specify the package name. (AMBIGUOUS_ACTION_REF)`);
|
|
79
|
-
err.code = "INVALID_ACTION_REF";
|
|
80
|
-
err.details = { alias: "AMBIGUOUS_ACTION_REF" };
|
|
81
|
-
throw err;
|
|
82
|
-
}
|
|
83
|
-
const matched = allMatches[0];
|
|
84
|
-
const pkg = this.snapshot.packages.get(matched.packageId);
|
|
85
|
-
return {
|
|
86
|
-
resolved: {
|
|
87
|
-
packageId: matched.packageId,
|
|
88
|
-
packageInstanceId: pkg?.packageInstanceId || matched.packageId,
|
|
89
|
-
actionId: matched.actionId,
|
|
90
|
-
generationId: this.snapshot.generationId,
|
|
91
|
-
},
|
|
92
|
-
action: matched,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LocationLink, LocationRegistryData } from "./types.js";
|
|
2
|
-
export declare class LocationRegistry {
|
|
3
|
-
private customHome?;
|
|
4
|
-
private filePath;
|
|
5
|
-
constructor(customHome?: string);
|
|
6
|
-
getFilePath(): string;
|
|
7
|
-
load(): LocationRegistryData;
|
|
8
|
-
save(data: LocationRegistryData): Promise<void>;
|
|
9
|
-
addLink(path: string, options?: {
|
|
10
|
-
type?: "package" | "workspace";
|
|
11
|
-
depth?: number;
|
|
12
|
-
}): Promise<LocationLink>;
|
|
13
|
-
removeLink(targetPathOrId: string): Promise<LocationLink | null>;
|
|
14
|
-
prune(): Promise<LocationLink[]>;
|
|
15
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { getRegistryFilePath, linkPackage, loadRegistry, loadRegistryAsync, pruneRegistry, unlinkPackage, } from "../registry/registry.js";
|
|
4
|
-
import { withRegistryLock } from "../registry/lock.js";
|
|
5
|
-
import { writeRegistryLocked } from "../registry/registry.js";
|
|
6
|
-
import { loadProjectConfig } from "../project/loader.js";
|
|
7
|
-
import { ACTIONDOCK_VERSION } from "../version.js";
|
|
8
|
-
export class LocationRegistry {
|
|
9
|
-
customHome;
|
|
10
|
-
filePath;
|
|
11
|
-
constructor(customHome) {
|
|
12
|
-
this.customHome = customHome;
|
|
13
|
-
this.filePath = getRegistryFilePath(customHome);
|
|
14
|
-
}
|
|
15
|
-
getFilePath() {
|
|
16
|
-
return this.filePath;
|
|
17
|
-
}
|
|
18
|
-
load() {
|
|
19
|
-
const reg = loadRegistry(this.customHome);
|
|
20
|
-
const links = [];
|
|
21
|
-
if (reg.workspaces) {
|
|
22
|
-
for (const [wsPath, ws] of Object.entries(reg.workspaces)) {
|
|
23
|
-
links.push({
|
|
24
|
-
type: "workspace",
|
|
25
|
-
path: resolve(ws.path || wsPath),
|
|
26
|
-
linkedAt: ws.linkedAt || new Date().toISOString(),
|
|
27
|
-
depth: 3,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (reg.packages) {
|
|
32
|
-
for (const pkg of Object.values(reg.packages)) {
|
|
33
|
-
if (!pkg.workspaceRoot && pkg.path) {
|
|
34
|
-
links.push({
|
|
35
|
-
type: "package",
|
|
36
|
-
path: resolve(pkg.path),
|
|
37
|
-
linkedAt: pkg.linkedAt || new Date().toISOString(),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return { schemaVersion: 1, links };
|
|
43
|
-
}
|
|
44
|
-
async save(data) {
|
|
45
|
-
// 读改写整体收敛在注册表锁内完成,写入直接走锁内原子落盘,
|
|
46
|
-
// 避免嵌套调用 saveRegistry 造成的同路径锁重入死等
|
|
47
|
-
await withRegistryLock(this.filePath, async () => {
|
|
48
|
-
const current = await loadRegistryAsync(this.customHome);
|
|
49
|
-
const newPackages = {};
|
|
50
|
-
const newWorkspaces = {};
|
|
51
|
-
for (const link of data.links) {
|
|
52
|
-
const absPath = resolve(link.path);
|
|
53
|
-
if (link.type === "workspace") {
|
|
54
|
-
newWorkspaces[absPath] = {
|
|
55
|
-
path: absPath,
|
|
56
|
-
linkedAt: link.linkedAt || new Date().toISOString(),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const existing = Object.values(current.packages || {}).find((p) => resolve(p.path) === absPath);
|
|
61
|
-
if (existing) {
|
|
62
|
-
newPackages[existing.id] = existing;
|
|
63
|
-
}
|
|
64
|
-
else if (existsSync(absPath)) {
|
|
65
|
-
try {
|
|
66
|
-
const config = loadProjectConfig(absPath);
|
|
67
|
-
newPackages[config.id] = {
|
|
68
|
-
id: config.id,
|
|
69
|
-
name: config.name || config.id,
|
|
70
|
-
version: config.version || "0.0.0",
|
|
71
|
-
path: absPath,
|
|
72
|
-
linkedAt: link.linkedAt || new Date().toISOString(),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
// 项目损坏或配置非法:跳过该链接条目,避免保存整体失败
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
await writeRegistryLocked({
|
|
82
|
-
version: ACTIONDOCK_VERSION,
|
|
83
|
-
packages: newPackages,
|
|
84
|
-
workspaces: newWorkspaces,
|
|
85
|
-
}, this.customHome);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async addLink(path, options = {}) {
|
|
89
|
-
const type = options.type || "package";
|
|
90
|
-
if (type === "workspace") {
|
|
91
|
-
const res = await linkPackage(path, this.customHome, { recursive: true });
|
|
92
|
-
return {
|
|
93
|
-
type: "workspace",
|
|
94
|
-
path: resolve(path),
|
|
95
|
-
linkedAt: res.linkedAt,
|
|
96
|
-
depth: options.depth ?? 3,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const res = await linkPackage(path, this.customHome, { recursive: false });
|
|
101
|
-
return {
|
|
102
|
-
type: "package",
|
|
103
|
-
path: resolve(path),
|
|
104
|
-
linkedAt: res.linkedAt,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async removeLink(targetPathOrId) {
|
|
109
|
-
const unres = await unlinkPackage(targetPathOrId, this.customHome);
|
|
110
|
-
if (!unres || (!unres.removedPackage && !unres.packagesCount)) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
type: unres.type,
|
|
115
|
-
path: unres.path,
|
|
116
|
-
linkedAt: new Date().toISOString(),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
async prune() {
|
|
120
|
-
const pruneRes = await pruneRegistry(this.customHome);
|
|
121
|
-
const removed = [];
|
|
122
|
-
for (const pkg of pruneRes.prunedPackages) {
|
|
123
|
-
removed.push({
|
|
124
|
-
type: "package",
|
|
125
|
-
path: pkg.path,
|
|
126
|
-
linkedAt: pkg.linkedAt,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
for (const ws of pruneRes.prunedWorkspaces) {
|
|
130
|
-
removed.push({
|
|
131
|
-
type: "workspace",
|
|
132
|
-
path: ws.path,
|
|
133
|
-
linkedAt: ws.linkedAt,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return removed;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { findProjectRoot, loadProjectConfig } from "../project/loader.js";
|
|
5
|
-
import { discoverProjects } from "../registry/registry.js";
|
|
6
|
-
import { LocationRegistry } from "./location-registry.js";
|
|
7
|
-
export class PackageCatalog {
|
|
8
|
-
registry;
|
|
9
|
-
constructor(registry) {
|
|
10
|
-
this.registry = registry || new LocationRegistry();
|
|
11
|
-
}
|
|
12
|
-
buildSnapshot(cwd = process.cwd()) {
|
|
13
|
-
const packages = new Map();
|
|
14
|
-
const seenRealPaths = new Map(); // realPath -> packageId
|
|
15
|
-
const seenPackageIds = new Map(); // packageId -> realPath
|
|
16
|
-
const registerPackage = (root, isChild = false) => {
|
|
17
|
-
const abs = resolve(root);
|
|
18
|
-
if (!existsSync(abs))
|
|
19
|
-
return;
|
|
20
|
-
const real = realpathSync(abs);
|
|
21
|
-
if (seenRealPaths.has(real)) {
|
|
22
|
-
return; // 符号链接归一化去重
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
const config = loadProjectConfig(abs);
|
|
26
|
-
if (seenPackageIds.has(config.id)) {
|
|
27
|
-
const existingPath = seenPackageIds.get(config.id);
|
|
28
|
-
if (existingPath !== real) {
|
|
29
|
-
throw new Error(`PACKAGE_ID_CONFLICT: Package ID '${config.id}' is declared by multiple directories: '${existingPath}' and '${real}'`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const entry = {
|
|
33
|
-
id: config.id,
|
|
34
|
-
packageInstanceId: `${config.id}:${real}`,
|
|
35
|
-
projectRoot: abs,
|
|
36
|
-
config,
|
|
37
|
-
isWorkspaceChild: isChild,
|
|
38
|
-
};
|
|
39
|
-
packages.set(config.id, entry);
|
|
40
|
-
seenRealPaths.set(real, config.id);
|
|
41
|
-
seenPackageIds.set(config.id, real);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
if (e.message?.startsWith("PACKAGE_ID_CONFLICT")) {
|
|
45
|
-
throw e;
|
|
46
|
-
}
|
|
47
|
-
// 无效项目跳过注册但输出告警含路径,杜绝无声丢弃
|
|
48
|
-
console.warn(`[Catalog] Skipping invalid package at '${abs}': ${e?.message || String(e)}`);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
// 优先包含当前工作目录所在项目
|
|
52
|
-
const currentRoot = findProjectRoot(cwd);
|
|
53
|
-
if (currentRoot) {
|
|
54
|
-
registerPackage(currentRoot);
|
|
55
|
-
}
|
|
56
|
-
// 扫描注册表中的位置
|
|
57
|
-
const regData = this.registry.load();
|
|
58
|
-
for (const link of regData.links) {
|
|
59
|
-
if (!existsSync(link.path))
|
|
60
|
-
continue;
|
|
61
|
-
if (link.type === "package") {
|
|
62
|
-
registerPackage(link.path);
|
|
63
|
-
}
|
|
64
|
-
else if (link.type === "workspace") {
|
|
65
|
-
const subprojects = discoverProjects(link.path, link.depth ?? 3);
|
|
66
|
-
for (const sub of subprojects) {
|
|
67
|
-
registerPackage(sub, true);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
generationId: randomUUID(),
|
|
73
|
-
createdAt: new Date().toISOString(),
|
|
74
|
-
packages,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
package/dist/catalog/types.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ActionContract } from "@actiondock/sdk";
|
|
2
|
-
import type { ProjectConfig } from "../project/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* 注册的位置条目类型。
|
|
5
|
-
*/
|
|
6
|
-
export type LocationType = "package" | "workspace";
|
|
7
|
-
/**
|
|
8
|
-
* 位置注册表中的单条链接记录。
|
|
9
|
-
*/
|
|
10
|
-
export interface LocationLink {
|
|
11
|
-
/** 位置类型:单包或工作区 */
|
|
12
|
-
type: LocationType;
|
|
13
|
-
/** 目录绝对物理路径 */
|
|
14
|
-
path: string;
|
|
15
|
-
/** 注册时间(ISO 8601) */
|
|
16
|
-
linkedAt: string;
|
|
17
|
-
/** 扫描最大深度(工作区模式有效,默认 3) */
|
|
18
|
-
depth?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 物理位置注册表文件(~/.actiondock/registry.json)格式。
|
|
22
|
-
*/
|
|
23
|
-
export interface LocationRegistryData {
|
|
24
|
-
schemaVersion: 1;
|
|
25
|
-
links: LocationLink[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 解析后的包实例快照。
|
|
29
|
-
*/
|
|
30
|
-
export interface CatalogPackageEntry {
|
|
31
|
-
/** 逻辑包标识 */
|
|
32
|
-
id: string;
|
|
33
|
-
/** 包物理实例唯一标识 */
|
|
34
|
-
packageInstanceId: string;
|
|
35
|
-
/** 项目根目录绝对路径 */
|
|
36
|
-
projectRoot: string;
|
|
37
|
-
/** 项目配置 */
|
|
38
|
-
config: ProjectConfig;
|
|
39
|
-
/** 是否来自工作区自动发现 */
|
|
40
|
-
isWorkspaceChild?: boolean;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 运行时目录与包快照。
|
|
44
|
-
*/
|
|
45
|
-
export interface CatalogSnapshot {
|
|
46
|
-
/** 快照代次唯一标识 */
|
|
47
|
-
generationId: string;
|
|
48
|
-
/** 生成快照时间 */
|
|
49
|
-
createdAt: string;
|
|
50
|
-
/** 已发现的包集合(按 packageId 索引) */
|
|
51
|
-
packages: Map<string, CatalogPackageEntry>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 索引中的 Action 描述符。
|
|
55
|
-
*/
|
|
56
|
-
export interface IndexedAction {
|
|
57
|
-
/** 所属逻辑包 ID */
|
|
58
|
-
packageId: string;
|
|
59
|
-
/** 动作 ID */
|
|
60
|
-
actionId: string;
|
|
61
|
-
/** 契约元数据 */
|
|
62
|
-
contract: ActionContract;
|
|
63
|
-
/** 实现入口相对路径 */
|
|
64
|
-
entry: string;
|
|
65
|
-
/** 包根目录绝对路径 */
|
|
66
|
-
projectRoot: string;
|
|
67
|
-
}
|
|
68
|
-
export type { ModuleLoader } from "../runtime/module-loader.js";
|
package/dist/catalog/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/export/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./templates.js";
|
package/dist/export/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./templates.js";
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ActionSpec } from "../app/types.js";
|
|
2
|
-
import type { PlaybookDefinition, ProjectConfig } from "../project/types.js";
|
|
3
|
-
export type SkillActionItem = ActionSpec | {
|
|
4
|
-
id: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
inputSchema?: any;
|
|
7
|
-
outputSchema?: any;
|
|
8
|
-
annotations?: any;
|
|
9
|
-
};
|
|
10
|
-
export declare function generateSourceSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: PlaybookDefinition[]): string;
|
|
11
|
-
export declare function generateStandaloneSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: PlaybookDefinition[], binaryRelPath?: string): string;
|
|
12
|
-
export declare function generateSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: PlaybookDefinition[], optionsOrBinaryPath?: string | {
|
|
13
|
-
mode?: "source" | "standalone";
|
|
14
|
-
binaryRelPath?: string;
|
|
15
|
-
}): string;
|
|
16
|
-
export interface CompositeSkillPackageInfo {
|
|
17
|
-
config: ProjectConfig;
|
|
18
|
-
actions: Array<{
|
|
19
|
-
id: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
}>;
|
|
22
|
-
playbooks: Array<{
|
|
23
|
-
id: string;
|
|
24
|
-
name?: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
filePath: string;
|
|
27
|
-
}>;
|
|
28
|
-
packageDir: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 复合技能自定义说明书(SKILL.custom.md)的槽位,
|
|
32
|
-
* 决定自定义段落插入到官方模板生成结果中的位置。
|
|
33
|
-
*/
|
|
34
|
-
export type CompositeCustomSlot = "intro" | "after-init" | "after-describe" | "after-actions" | "after-playbooks" | "after-invoke" | "append";
|
|
35
|
-
export declare const COMPOSITE_CUSTOM_SLOTS: readonly CompositeCustomSlot[];
|
|
36
|
-
/** 工作区内约定俗成的复合技能自定义说明书文件名。 */
|
|
37
|
-
export declare const COMPOSITE_CUSTOM_DECLARATION_FILE = "SKILL.custom.md";
|
|
38
|
-
export interface CompositeCustomSection {
|
|
39
|
-
slot: CompositeCustomSlot;
|
|
40
|
-
content: string;
|
|
41
|
-
}
|
|
42
|
-
export interface CompositeCustomDeclaration {
|
|
43
|
-
/** 自定义说明书 frontmatter 中声明的 description 覆盖值 */
|
|
44
|
-
description?: string;
|
|
45
|
-
sections: CompositeCustomSection[];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* 解析自定义说明书正文:以 `<!-- actiondock:slot <name> -->` 标记行分段。
|
|
49
|
-
* 首个标记之前的内容归入 `append` 槽位;未知槽位名直接抛错,避免拼写错误被静默吞掉。
|
|
50
|
-
*/
|
|
51
|
-
export declare function parseCustomSections(source: string): CompositeCustomSection[];
|
|
52
|
-
/**
|
|
53
|
-
* 解析复合技能自定义说明书文件:支持 YAML frontmatter 中的 `description` 覆盖,
|
|
54
|
-
* 正文按槽位标记解析为自定义段落。
|
|
55
|
-
*/
|
|
56
|
-
export declare function parseCustomSkillDeclaration(source: string): CompositeCustomDeclaration;
|
|
57
|
-
/**
|
|
58
|
-
* 生成多包聚合的复合模式 SKILL.md 文档。
|
|
59
|
-
*/
|
|
60
|
-
export declare function generateCompositeSkillMd(bundleName: string, description: string, packages: CompositeSkillPackageInfo[], options?: {
|
|
61
|
-
customSections?: CompositeCustomSection[];
|
|
62
|
-
/** 规程链接的子包目录前缀:导出布局为 "packages"(默认);就地生成时传 "." 使用工作区实际目录 */
|
|
63
|
-
packagesBaseDir?: string;
|
|
64
|
-
}): string;
|
|
65
|
-
export interface GenerateSkillJsonOptions {
|
|
66
|
-
mode?: "source" | "standalone";
|
|
67
|
-
executable?: string;
|
|
68
|
-
target?: string;
|
|
69
|
-
playbooks?: PlaybookDefinition[];
|
|
70
|
-
}
|
|
71
|
-
export declare function generateSkillJson(config: ProjectConfig, actions: SkillActionItem[], binaryNameOrOptions?: string | GenerateSkillJsonOptions, target?: string, playbooksList?: PlaybookDefinition[]): string;
|