@actiondock/core 2.15.0 → 2.17.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/dist/catalog/discovery.d.ts +3 -3
- package/dist/catalog/graph.d.ts +8 -6
- package/dist/catalog/graph.js +62 -197
- package/dist/catalog/resolve-playbook.d.ts +2 -2
- package/dist/catalog/resolve-playbook.js +53 -12
- package/dist/execution/service.js +6 -0
- package/dist/execution/types.d.ts +2 -2
- package/dist/host/host.js +16 -5
- package/dist/host/routing.d.ts +1 -1
- package/dist/host/routing.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -1
- package/dist/invocation/types.d.ts +5 -1
- package/dist/invocation/types.js +5 -0
- package/dist/package/runtime.d.ts +2 -2
- package/dist/package/runtime.js +9 -5
- package/dist/package/static-index.d.ts +6 -4
- package/dist/package/static-index.js +60 -12
- package/dist/package/types.d.ts +5 -5
- package/dist/project/index.d.ts +0 -1
- package/dist/project/index.js +0 -1
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +2 -4
- package/dist/project/loader.js +34 -38
- package/dist/project/manifest.d.ts +0 -2
- package/dist/project/manifest.js +1 -17
- package/dist/project/types.d.ts +0 -31
- package/dist/registry/registry.js +15 -27
- package/dist/runtime/context.d.ts +3 -3
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/run-origin.d.ts +9 -0
- package/dist/runtime/run-origin.js +33 -0
- package/dist/runtime/run-persistence.d.ts +3 -1
- package/dist/runtime/run-persistence.js +3 -0
- package/dist/runtime/standalone-commands.js +2 -8
- package/dist/runtime/standalone.d.ts +0 -2
- package/dist/server/policy.d.ts +8 -0
- package/dist/server/policy.js +14 -0
- package/dist/server/routes/actions.js +5 -0
- package/dist/service/types.d.ts +3 -1
- package/dist/storage/sqlite-runs.js +9 -3
- package/dist/storage/sqlite-schema.js +5 -1
- package/dist/storage/utils.d.ts +5 -2
- package/dist/storage/utils.js +7 -2
- package/dist/utils/semver.d.ts +1 -2
- package/dist/utils/semver.js +5 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/project/skill-dir.d.ts +0 -72
- package/dist/project/skill-dir.js +0 -244
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { ActionDockError, ACTION_NOT_FOUND, PACKAGE_NOT_FOUND, PACKAGE_ID_CONFLICT, } from "../errors.js";
|
|
4
|
-
import { loadProjectConfig } from "./loader.js";
|
|
5
|
-
import { PackageGraphBuilder } from "../catalog/graph.js";
|
|
6
|
-
import { parseActionRef } from "../catalog/resolve-action.js";
|
|
7
|
-
import { createPackageIdentity } from "../runtime/identity.js";
|
|
8
|
-
/**
|
|
9
|
-
* 判定路径字符串是否为显式文件/目录路径形态(而非包标识符)。
|
|
10
|
-
*
|
|
11
|
-
* 规则:
|
|
12
|
-
* - 以 .、/、~ 开头;
|
|
13
|
-
* - 包含 / 或 \\,且不是 scoped 包(@scope/name 仅含一个 /);
|
|
14
|
-
* - scoped 包若包含反斜杠或多于一个 /,亦视作路径。
|
|
15
|
-
*/
|
|
16
|
-
export function isExplicitPath(p) {
|
|
17
|
-
if (!p)
|
|
18
|
-
return false;
|
|
19
|
-
if (p.startsWith("@")) {
|
|
20
|
-
const slashCount = (p.match(/\//g) || []).length;
|
|
21
|
-
return slashCount > 1 || p.includes("\\");
|
|
22
|
-
}
|
|
23
|
-
return (p.startsWith(".") ||
|
|
24
|
-
p.startsWith("/") ||
|
|
25
|
-
p.startsWith("~") ||
|
|
26
|
-
p.includes("/") ||
|
|
27
|
-
p.includes("\\"));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 对明确的本地封闭包集合实施一致性校验。
|
|
31
|
-
*
|
|
32
|
-
* 校验规则:
|
|
33
|
-
* - 重复包标识防护:集合内不得存在相同 packageId;
|
|
34
|
-
* - 依赖存在性与版本兼容性:声明的直接依赖必须在集合内存在且满足语义版本约束(复用 PackageGraphBuilder);
|
|
35
|
-
* - 跨包 uses 目标完整性:uses 声明引用的目标包与目标 Action 必须在集合内存在。
|
|
36
|
-
*
|
|
37
|
-
* @param packages 封闭包条目集合
|
|
38
|
-
*/
|
|
39
|
-
export function validateLocalSkillPackages(packages) {
|
|
40
|
-
if (!packages || packages.length === 0)
|
|
41
|
-
return;
|
|
42
|
-
// 1. 重复 packageId 校验
|
|
43
|
-
const seenIds = new Set();
|
|
44
|
-
for (const pkg of packages) {
|
|
45
|
-
if (seenIds.has(pkg.packageId)) {
|
|
46
|
-
throw new ActionDockError(PACKAGE_ID_CONFLICT, `Package ID conflict: package '${pkg.packageId}' is declared more than once in skill packages`);
|
|
47
|
-
}
|
|
48
|
-
seenIds.add(pkg.packageId);
|
|
49
|
-
}
|
|
50
|
-
// 2. 构造包发现视图并交由 PackageGraphBuilder 校验依赖与版本
|
|
51
|
-
const discovered = packages.map((pkg) => ({
|
|
52
|
-
id: pkg.packageId,
|
|
53
|
-
root: pkg.packageRoot,
|
|
54
|
-
manifest: pkg.projectConfig,
|
|
55
|
-
identity: createPackageIdentity({
|
|
56
|
-
id: pkg.packageId,
|
|
57
|
-
instanceId: `${pkg.packageId}:${pkg.packageRoot}`,
|
|
58
|
-
generation: "skill-local",
|
|
59
|
-
}),
|
|
60
|
-
isCurrentProject: true,
|
|
61
|
-
}));
|
|
62
|
-
const builder = new PackageGraphBuilder({
|
|
63
|
-
packages: discovered,
|
|
64
|
-
validateDependencies: true,
|
|
65
|
-
});
|
|
66
|
-
builder.buildSync();
|
|
67
|
-
// 3. uses 声明目标存在性校验
|
|
68
|
-
const pkgMap = new Map();
|
|
69
|
-
for (const pkg of packages) {
|
|
70
|
-
pkgMap.set(pkg.packageId, pkg.projectConfig);
|
|
71
|
-
}
|
|
72
|
-
const validateUseRef = (rawRef, caller, currentPkg) => {
|
|
73
|
-
if (typeof rawRef !== "string" || !rawRef.trim())
|
|
74
|
-
return;
|
|
75
|
-
const trimmed = rawRef.trim();
|
|
76
|
-
// 先按完整包身份识别裸包引用,包括 scoped 包。
|
|
77
|
-
if (pkgMap.has(trimmed)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
// 裸 scoped 包只有一个斜杠,不能按限定动作拆分。
|
|
81
|
-
if (trimmed.startsWith("@") && (trimmed.match(/\//g) || []).length === 1) {
|
|
82
|
-
throw new ActionDockError(PACKAGE_NOT_FOUND, `Package '${trimmed}' referenced by uses in '${caller}' was not found in skill directory`);
|
|
83
|
-
}
|
|
84
|
-
// 限定动作与包级通配符复用统一引用解析器。
|
|
85
|
-
if (trimmed.includes("/")) {
|
|
86
|
-
const ref = parseActionRef(trimmed);
|
|
87
|
-
const targetPkgId = ref.packageId;
|
|
88
|
-
const targetActionId = ref.actionId;
|
|
89
|
-
const targetPkg = pkgMap.get(targetPkgId);
|
|
90
|
-
if (!targetPkg) {
|
|
91
|
-
throw new ActionDockError(PACKAGE_NOT_FOUND, `Package '${targetPkgId}' referenced by uses in '${caller}' was not found in skill directory`);
|
|
92
|
-
}
|
|
93
|
-
if (targetActionId !== "*") {
|
|
94
|
-
const hasAction = Boolean(targetPkg.actions && targetPkg.actions[targetActionId]);
|
|
95
|
-
if (!hasAction) {
|
|
96
|
-
throw new ActionDockError(ACTION_NOT_FOUND, `Action '${targetActionId}' referenced by uses in '${caller}' was not found in package '${targetPkgId}'`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
// 本包短动作引用。
|
|
102
|
-
if (currentPkg.actions && currentPkg.actions[trimmed]) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// 目标不存在。
|
|
106
|
-
throw new ActionDockError(PACKAGE_NOT_FOUND, `Package or action '${trimmed}' referenced by uses in '${caller}' was not found in skill directory`);
|
|
107
|
-
};
|
|
108
|
-
for (const pkg of packages) {
|
|
109
|
-
const pkgUses = pkg.projectConfig.uses;
|
|
110
|
-
if (Array.isArray(pkgUses)) {
|
|
111
|
-
for (const ref of pkgUses) {
|
|
112
|
-
validateUseRef(ref, `package '${pkg.packageId}'`, pkg.projectConfig);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (pkg.projectConfig.actions && typeof pkg.projectConfig.actions === "object") {
|
|
116
|
-
for (const [actionId, actionEntry] of Object.entries(pkg.projectConfig.actions)) {
|
|
117
|
-
if (actionEntry && Array.isArray(actionEntry.uses)) {
|
|
118
|
-
for (const ref of actionEntry.uses) {
|
|
119
|
-
validateUseRef(ref, `action '${pkg.packageId}/${actionId}'`, pkg.projectConfig);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* 发现本地 Skill / 包目录结构(支持单包根目录与 packages/* 复合套件布局)。
|
|
128
|
-
* 仅执行物理布局发现与清单加载,不执行跨包封闭依赖集合校验。
|
|
129
|
-
*
|
|
130
|
-
* @param directoryPath 待检查的目录路径(相对路径将基于 cwd 解析)
|
|
131
|
-
* @param cwd 解析基准工作目录(默认为 process.cwd())
|
|
132
|
-
*/
|
|
133
|
-
export function discoverLocalSkillDirectory(directoryPath, cwd) {
|
|
134
|
-
if (!directoryPath || typeof directoryPath !== "string") {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
const absDir = resolve(cwd || process.cwd(), directoryPath);
|
|
138
|
-
if (!existsSync(absDir)) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
const stat = statSync(absDir);
|
|
143
|
-
if (!stat.isDirectory()) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
// 单包布局:根目录包含 actiondock.json
|
|
151
|
-
const rootManifest = join(absDir, "actiondock.json");
|
|
152
|
-
if (existsSync(rootManifest)) {
|
|
153
|
-
const config = loadProjectConfig(absDir);
|
|
154
|
-
const packages = [
|
|
155
|
-
{
|
|
156
|
-
packageId: config.id,
|
|
157
|
-
packageRoot: absDir,
|
|
158
|
-
projectConfig: config,
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
return {
|
|
162
|
-
type: "single",
|
|
163
|
-
root: absDir,
|
|
164
|
-
packages,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
// 复合 Skill 布局:存在 packages/ 目录且包含至少一个有效子包
|
|
168
|
-
const packagesDir = join(absDir, "packages");
|
|
169
|
-
if (existsSync(packagesDir)) {
|
|
170
|
-
const pStat = statSync(packagesDir);
|
|
171
|
-
if (pStat.isDirectory()) {
|
|
172
|
-
const entries = readdirSync(packagesDir, { withFileTypes: true });
|
|
173
|
-
const packages = [];
|
|
174
|
-
const seenIds = new Set();
|
|
175
|
-
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
176
|
-
for (const entry of entries) {
|
|
177
|
-
const subDir = join(packagesDir, entry.name);
|
|
178
|
-
const sStat = statSync(subDir);
|
|
179
|
-
if (sStat.isDirectory()) {
|
|
180
|
-
const subManifest = join(subDir, "actiondock.json");
|
|
181
|
-
if (existsSync(subManifest)) {
|
|
182
|
-
const childConfig = loadProjectConfig(subDir);
|
|
183
|
-
if (seenIds.has(childConfig.id)) {
|
|
184
|
-
throw new ActionDockError(PACKAGE_ID_CONFLICT, `Package ID conflict: package '${childConfig.id}' is declared more than once in skill directory '${absDir}'`);
|
|
185
|
-
}
|
|
186
|
-
seenIds.add(childConfig.id);
|
|
187
|
-
packages.push({
|
|
188
|
-
packageId: childConfig.id,
|
|
189
|
-
packageRoot: subDir,
|
|
190
|
-
projectConfig: childConfig,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (packages.length > 0) {
|
|
196
|
-
return {
|
|
197
|
-
type: "composite",
|
|
198
|
-
root: absDir,
|
|
199
|
-
packages,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* 查询指定路径的本地包或技能目录(供 info / 查询命令使用)。
|
|
208
|
-
* 单包不要求 node_modules 依赖闭包;复合目录仍要求封闭集合完整。
|
|
209
|
-
*
|
|
210
|
-
* @param directoryPath 待检查的目录路径(相对路径将基于 cwd 解析)
|
|
211
|
-
* @param cwd 解析基准工作目录(默认为 process.cwd())
|
|
212
|
-
*/
|
|
213
|
-
export function queryLocalPackageDirectory(directoryPath, cwd) {
|
|
214
|
-
const discovered = discoverLocalSkillDirectory(directoryPath, cwd);
|
|
215
|
-
if (!discovered) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
if (discovered.type === "composite") {
|
|
219
|
-
validateLocalSkillPackages(discovered.packages);
|
|
220
|
-
}
|
|
221
|
-
return discovered;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* 探测指定路径是否为本地 Skill / 包目录(支持单包根目录与 packages/* 复合套件布局)。
|
|
225
|
-
*
|
|
226
|
-
* 封闭包装配与校验规则:
|
|
227
|
-
* - 符号链接按目录布局正常解析;Action 与规程入口的文件边界由相应加载器校验;
|
|
228
|
-
* - 单包布局:目录根部存在 actiondock.json,解析为包含单一包的 LocalSkillDirectory;
|
|
229
|
-
* - 复合布局:目录根部存在 packages/ 目录,遍历其直接子目录,收集包含 actiondock.json 的子包;
|
|
230
|
-
* - 集合一致性校验:通过 validateLocalSkillPackages 严格核查依赖闭包、版本兼容与 uses 目标;
|
|
231
|
-
* - 异常透传:坏清单或权限异常原样抛出,严禁静默回退 Registry;
|
|
232
|
-
* - 若非候选技能目录,返回 null。
|
|
233
|
-
*
|
|
234
|
-
* @param directoryPath 待检查的目录路径(相对路径将基于 cwd 解析)
|
|
235
|
-
* @param cwd 解析基准工作目录(默认为 process.cwd())
|
|
236
|
-
*/
|
|
237
|
-
export function inspectLocalPackageDirectory(directoryPath, cwd) {
|
|
238
|
-
const discovered = discoverLocalSkillDirectory(directoryPath, cwd);
|
|
239
|
-
if (!discovered) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
validateLocalSkillPackages(discovered.packages);
|
|
243
|
-
return discovered;
|
|
244
|
-
}
|