@verentis/cli 1.0.5 → 1.0.7
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/index.js +173 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2443,19 +2443,44 @@ function hasRasterSignature(path, bytes) {
|
|
|
2443
2443
|
var AGENT_UI_FORMATS = ["openui"];
|
|
2444
2444
|
var AGENT_MODEL_CHOICES = ["fixed", "open"];
|
|
2445
2445
|
var AGENT_CAPABILITIES = ["network", "execution"];
|
|
2446
|
-
var AGENT_FILE_ACCESS_KEYS = ["path", "mode", "reason"];
|
|
2446
|
+
var AGENT_FILE_ACCESS_KEYS = ["path", "mode", "execute", "reason"];
|
|
2447
2447
|
var isRecord4 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
2448
2448
|
var isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
2449
2449
|
function validateAgentSpec(kind, spec) {
|
|
2450
2450
|
if (findPackageType(kind)?.resourceKind !== "Agent" || !isRecord4(spec)) return [];
|
|
2451
2451
|
return [
|
|
2452
2452
|
...stringListErrors(spec.permissions, "spec.permissions", "a list of permission names (scopes)"),
|
|
2453
|
-
...fileAccessErrors(spec["file-access"]),
|
|
2453
|
+
...fileAccessErrors(spec["file-access"], spec.permissions),
|
|
2454
2454
|
...uiErrors(spec.ui),
|
|
2455
2455
|
...modelErrors(spec.model),
|
|
2456
|
-
...capabilityErrors(spec.capabilities)
|
|
2456
|
+
...capabilityErrors(spec.capabilities),
|
|
2457
|
+
...chatErrors(spec.chat),
|
|
2458
|
+
...subagentErrors(spec.subagents)
|
|
2457
2459
|
];
|
|
2458
2460
|
}
|
|
2461
|
+
function chatErrors(value) {
|
|
2462
|
+
if (value === void 0) return [];
|
|
2463
|
+
if (!isRecord4(value)) return ["spec.chat must be a mapping (contact)."];
|
|
2464
|
+
const errors = Object.keys(value).filter((key) => key !== "contact").map((key) => `spec.chat.${key} is not supported.`);
|
|
2465
|
+
if (value.contact !== void 0 && typeof value.contact !== "boolean") errors.push("spec.chat.contact must be true or false.");
|
|
2466
|
+
return errors;
|
|
2467
|
+
}
|
|
2468
|
+
function subagentErrors(value) {
|
|
2469
|
+
if (value === void 0) return [];
|
|
2470
|
+
if (!isRecord4(value)) return ["spec.subagents must be a mapping (agents, max-children)."];
|
|
2471
|
+
const errors = Object.keys(value).filter((key) => key !== "agents" && key !== "max-children").map((key) => `spec.subagents.${key} is not supported.`);
|
|
2472
|
+
errors.push(...stringListErrors(
|
|
2473
|
+
value.agents,
|
|
2474
|
+
"spec.subagents.agents",
|
|
2475
|
+
"a list of agents: 'self', ./relative, @publisher/package[/path] or an absolute workspace path",
|
|
2476
|
+
true
|
|
2477
|
+
));
|
|
2478
|
+
const max = value["max-children"];
|
|
2479
|
+
if (max !== void 0 && (!Number.isInteger(max) || max < 0 || max > 64)) {
|
|
2480
|
+
errors.push("spec.subagents.max-children must be a whole number from 0 to 64.");
|
|
2481
|
+
}
|
|
2482
|
+
return errors;
|
|
2483
|
+
}
|
|
2459
2484
|
function stringListErrors(value, label, expected, unique = false) {
|
|
2460
2485
|
if (value === void 0) return [];
|
|
2461
2486
|
if (!Array.isArray(value)) return [`${label} must be ${expected}.`];
|
|
@@ -2468,14 +2493,20 @@ function stringListErrors(value, label, expected, unique = false) {
|
|
|
2468
2493
|
});
|
|
2469
2494
|
return errors;
|
|
2470
2495
|
}
|
|
2471
|
-
function fileAccessErrors(value) {
|
|
2496
|
+
function fileAccessErrors(value, permissions) {
|
|
2472
2497
|
if (!Array.isArray(value)) return [];
|
|
2498
|
+
const canRun = Array.isArray(permissions) && permissions.some((p) => typeof p === "string" && p.trim() === "execution.run");
|
|
2473
2499
|
const errors = [];
|
|
2474
2500
|
value.forEach((entry, index) => {
|
|
2475
2501
|
if (!isRecord4(entry)) return;
|
|
2476
2502
|
const at = `spec.file-access[${index}]`;
|
|
2477
2503
|
for (const key of Object.keys(entry).filter((key2) => !AGENT_FILE_ACCESS_KEYS.includes(key2))) {
|
|
2478
|
-
errors.push(`${at}.${key} is not supported for Agent manifests (declare path, mode and reason).`);
|
|
2504
|
+
errors.push(`${at}.${key} is not supported for Agent manifests (declare path, mode, execute and reason).`);
|
|
2505
|
+
}
|
|
2506
|
+
if (entry.execute !== void 0 && typeof entry.execute !== "boolean") {
|
|
2507
|
+
errors.push(`${at}.execute must be true or false.`);
|
|
2508
|
+
} else if (entry.execute === true && !canRun) {
|
|
2509
|
+
errors.push(`${at}.execute requires spec.permissions to declare execution.run (running programs stored in the folder).`);
|
|
2479
2510
|
}
|
|
2480
2511
|
if (entry.reason === void 0 || typeof entry.reason === "string" && !entry.reason.trim()) {
|
|
2481
2512
|
errors.push(`${at}.reason is required: say why the agent needs this folder (shown when the agent is installed).`);
|
|
@@ -2630,9 +2661,9 @@ async function loadManifest(path) {
|
|
|
2630
2661
|
if (messageErrors.length > 0) {
|
|
2631
2662
|
throw new Error(`Invalid manifest at ${path}: ${messageErrors.join(" ")}`);
|
|
2632
2663
|
}
|
|
2633
|
-
const
|
|
2634
|
-
if (
|
|
2635
|
-
throw new Error(`Invalid manifest at ${path}: ${
|
|
2664
|
+
const chatErrors2 = validateChatSection(kind, manifest.spec);
|
|
2665
|
+
if (chatErrors2.length > 0) {
|
|
2666
|
+
throw new Error(`Invalid manifest at ${path}: ${chatErrors2.join(" ")}`);
|
|
2636
2667
|
}
|
|
2637
2668
|
const actorErrors = validateActorSection(kind, manifest.spec);
|
|
2638
2669
|
if (actorErrors.length > 0) {
|
|
@@ -5706,6 +5737,125 @@ function findPlaceholders(text) {
|
|
|
5706
5737
|
}
|
|
5707
5738
|
return placeholders;
|
|
5708
5739
|
}
|
|
5740
|
+
var AGENT_FILE = /\.agent\.ya?ml$/i;
|
|
5741
|
+
var isRecord5 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
5742
|
+
async function validateAgentSuite(projectDir, manifestPath, manifest, payloadFiles) {
|
|
5743
|
+
const errors = [];
|
|
5744
|
+
const warnings = [];
|
|
5745
|
+
const agents = [];
|
|
5746
|
+
const spec = isRecord5(manifest.spec) ? manifest.spec : {};
|
|
5747
|
+
const recordFile = toPosix(relative(projectDir, manifestPath));
|
|
5748
|
+
if (manifest.kind === "Agent") agents.push(agentOf(recordFile, "the package agent", manifest.metadata?.id, spec));
|
|
5749
|
+
for (const file of payloadFiles.map(toPosix).filter((file2) => AGENT_FILE.test(file2)).sort()) {
|
|
5750
|
+
let document;
|
|
5751
|
+
try {
|
|
5752
|
+
document = parse(await readFile(join(projectDir, file), "utf8"));
|
|
5753
|
+
} catch (error) {
|
|
5754
|
+
errors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
5755
|
+
continue;
|
|
5756
|
+
}
|
|
5757
|
+
if (!isRecord5(document) || document.kind !== "Agent") {
|
|
5758
|
+
errors.push(`${file}: an *.agent.yaml file must be an Agent manifest (kind: Agent).`);
|
|
5759
|
+
continue;
|
|
5760
|
+
}
|
|
5761
|
+
const metadata = isRecord5(document.metadata) ? document.metadata : {};
|
|
5762
|
+
const agentSpec = isRecord5(document.spec) ? document.spec : {};
|
|
5763
|
+
if (typeof metadata.id !== "string" || !metadata.id.trim()) errors.push(`${file}: metadata.id is required.`);
|
|
5764
|
+
errors.push(...validateAgentSpec("Agent", agentSpec).map((message) => `${file}: ${message}`));
|
|
5765
|
+
agents.push(agentOf(file, file, metadata.id, agentSpec));
|
|
5766
|
+
}
|
|
5767
|
+
if (agents.length === 0) return { errors, warnings };
|
|
5768
|
+
const ids = /* @__PURE__ */ new Map();
|
|
5769
|
+
for (const agent of agents) {
|
|
5770
|
+
if (!agent.id) continue;
|
|
5771
|
+
const other = ids.get(agent.id);
|
|
5772
|
+
if (other) errors.push(`${agent.label}: metadata.id '${agent.id}' is also used by ${other}; agents of one package need unique ids.`);
|
|
5773
|
+
else ids.set(agent.id, agent.label);
|
|
5774
|
+
}
|
|
5775
|
+
const files2 = new Set(agents.map((agent) => agent.file));
|
|
5776
|
+
const dependencies = dependencyPackages(spec);
|
|
5777
|
+
const own = typeof manifest.packaging?.publisher === "string" && typeof manifest.metadata?.id === "string" ? `${manifest.packaging.publisher}/${manifest.metadata.id}` : void 0;
|
|
5778
|
+
for (const agent of agents) {
|
|
5779
|
+
const subagents = isRecord5(agent.spec.subagents) ? agent.spec.subagents : void 0;
|
|
5780
|
+
const references = Array.isArray(subagents?.agents) ? subagents.agents.filter((r) => typeof r === "string") : [];
|
|
5781
|
+
for (const reference of references.map((r) => r.trim())) {
|
|
5782
|
+
const problem = referenceProblem(agent.file, reference, files2, dependencies, own);
|
|
5783
|
+
if (problem?.error) errors.push(`${agent.label}: spec.subagents.agents '${reference}' ${problem.error}`);
|
|
5784
|
+
else if (problem?.warning) warnings.push(`${agent.label}: spec.subagents.agents '${reference}' ${problem.warning}`);
|
|
5785
|
+
}
|
|
5786
|
+
}
|
|
5787
|
+
const contacts = agents.filter((agent) => agent.contact);
|
|
5788
|
+
if (agents.length > 1 && contacts.length > 1) {
|
|
5789
|
+
warnings.push(`${contacts.length} agents are Chat contacts (${contacts.map((a) => a.label).join(", ")}). Set spec.chat.contact: false on the sub-agents so Chat lists only the agent people talk to.`);
|
|
5790
|
+
}
|
|
5791
|
+
const orchestrators = agents.filter((agent) => isRecord5(agent.spec.subagents));
|
|
5792
|
+
if (agents.length > 1 && contacts.length === 0 && orchestrators.length > 0) {
|
|
5793
|
+
warnings.push(`No agent in this package is a Chat contact; ${orchestrators.map((a) => a.label).join(", ")} can only be started from a schedule, a trigger or the runs page.`);
|
|
5794
|
+
}
|
|
5795
|
+
if (manifest.kind !== "Agent") warnings.push(...bundledConsentWarnings(agents, spec));
|
|
5796
|
+
return { errors, warnings };
|
|
5797
|
+
}
|
|
5798
|
+
function agentOf(file, label, id, spec) {
|
|
5799
|
+
const chat = isRecord5(spec.chat) ? spec.chat : void 0;
|
|
5800
|
+
return { file, label, id: typeof id === "string" && id.trim() ? id : void 0, contact: chat?.contact !== false, spec };
|
|
5801
|
+
}
|
|
5802
|
+
function referenceProblem(from, reference, files2, dependencies, own) {
|
|
5803
|
+
if (reference === "self") return void 0;
|
|
5804
|
+
if (reference.startsWith("@")) {
|
|
5805
|
+
const body = reference.slice(1).split("@")[0];
|
|
5806
|
+
const parts = body.split("/").filter(Boolean);
|
|
5807
|
+
if (parts.length < 2 || parts.some((p) => p === "." || p === "..")) return { error: "is not a package reference (@publisher/package[/path])." };
|
|
5808
|
+
const pkg = `${parts[0]}/${parts[1]}`;
|
|
5809
|
+
if (pkg === own) {
|
|
5810
|
+
const item = parts.slice(2).join("/");
|
|
5811
|
+
return item && !files2.has(item) ? { error: `names ${item}, which is not an agent manifest in this package.` } : void 0;
|
|
5812
|
+
}
|
|
5813
|
+
return dependencies.has(pkg) ? void 0 : { warning: `names ${pkg}, which spec.dependencies doesn't declare; it resolves only where that package is already installed.` };
|
|
5814
|
+
}
|
|
5815
|
+
if (reference === "." || reference === ".." || reference.startsWith("./") || reference.startsWith("../")) {
|
|
5816
|
+
const target = posix.normalize(posix.join(posix.dirname(from || "."), reference));
|
|
5817
|
+
if (target.startsWith("../") || target === "..") return { error: "points outside the package." };
|
|
5818
|
+
return files2.has(target) ? void 0 : { error: `resolves to ${target}, which is not an agent manifest in this package.` };
|
|
5819
|
+
}
|
|
5820
|
+
return { warning: "is an absolute workspace path; use ./relative or @publisher/package so it moves with the package." };
|
|
5821
|
+
}
|
|
5822
|
+
function dependencyPackages(spec) {
|
|
5823
|
+
const packages = /* @__PURE__ */ new Set();
|
|
5824
|
+
for (const dependency of Array.isArray(spec.dependencies) ? spec.dependencies : []) {
|
|
5825
|
+
const value = typeof dependency === "string" ? dependency : isRecord5(dependency) ? dependency.package : void 0;
|
|
5826
|
+
if (typeof value === "string") packages.add(value.split("@")[0]);
|
|
5827
|
+
}
|
|
5828
|
+
return packages;
|
|
5829
|
+
}
|
|
5830
|
+
function bundledConsentWarnings(agents, spec) {
|
|
5831
|
+
const warnings = [];
|
|
5832
|
+
const scopes = new Set(Array.isArray(spec.permissions) ? spec.permissions.filter((p) => typeof p === "string") : []);
|
|
5833
|
+
const grants = (Array.isArray(spec["file-access"]) ? spec["file-access"] : []).filter(isRecord5).filter((g2) => typeof g2.path === "string" && g2.path.startsWith("/") && (g2.mode === "read" || g2.mode === "write")).map((g2) => ({ path: trimSlash(g2.path), mode: g2.mode, execute: g2.execute === true }));
|
|
5834
|
+
for (const agent of agents) {
|
|
5835
|
+
const permissions = Array.isArray(agent.spec.permissions) ? agent.spec.permissions.filter((p) => typeof p === "string") : [];
|
|
5836
|
+
const missing = permissions.filter((p) => !scopes.has(p));
|
|
5837
|
+
if (missing.length > 0) {
|
|
5838
|
+
warnings.push(`${agent.label}: requests ${missing.join(", ")}, which the package's spec.permissions doesn't declare; a bundled agent only gets what the package is consented.`);
|
|
5839
|
+
}
|
|
5840
|
+
for (const entry of (Array.isArray(agent.spec["file-access"]) ? agent.spec["file-access"] : []).filter(isRecord5)) {
|
|
5841
|
+
if (typeof entry.path !== "string") continue;
|
|
5842
|
+
if (!entry.path.startsWith("/")) {
|
|
5843
|
+
warnings.push(`${agent.label}: spec.file-access '${entry.path}' is relative; a bundled agent's folder is covered only when an absolute package grant includes it. Request the absolute folder the package declares.`);
|
|
5844
|
+
continue;
|
|
5845
|
+
}
|
|
5846
|
+
const path = trimSlash(entry.path);
|
|
5847
|
+
const covered = grants.some((g2) => (path === g2.path || path.startsWith(`${g2.path}/`) || g2.path === "") && (g2.mode === "write" || entry.mode !== "write"));
|
|
5848
|
+
if (!covered) {
|
|
5849
|
+
warnings.push(`${agent.label}: spec.file-access '${entry.path}' (${String(entry.mode)}) isn't covered by the package's spec.file-access; a bundled agent only gets what the package is consented.`);
|
|
5850
|
+
} else if (entry.execute === true && !grants.some((g2) => g2.execute && (path === g2.path || path.startsWith(`${g2.path}/`) || g2.path === ""))) {
|
|
5851
|
+
warnings.push(`${agent.label}: spec.file-access '${entry.path}' asks to execute, which no package spec.file-access entry with execute: true covers; a bundled agent only gets what the package is consented.`);
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
return warnings;
|
|
5856
|
+
}
|
|
5857
|
+
var trimSlash = (path) => path.replace(/\/+$/, "");
|
|
5858
|
+
var toPosix = (path) => path.split("\\").join("/");
|
|
5709
5859
|
var ARGUMENTS_SCHEMA = "verentis.io/script-arguments/v1";
|
|
5710
5860
|
var ARGUMENTS_SUFFIX = ".arguments.json";
|
|
5711
5861
|
var KINDS = /* @__PURE__ */ new Set(["option", "positional"]);
|
|
@@ -6007,6 +6157,9 @@ async function pack(options) {
|
|
|
6007
6157
|
const avatarInclusionErrors = validateAgentAvatarPayloadFiles(manifest, payloadFiles);
|
|
6008
6158
|
if (avatarInclusionErrors.length > 0) throw new Error(`Invalid ${kind} payload:
|
|
6009
6159
|
${avatarInclusionErrors.join("\n ")}`);
|
|
6160
|
+
const suite = await validateAgentSuite(projectDir, manifestPath, manifest, payloadFiles);
|
|
6161
|
+
if (suite.errors.length > 0) throw new Error(`Invalid agents in ${kind} package:
|
|
6162
|
+
${suite.errors.join("\n ")}`);
|
|
6010
6163
|
const missingSources = expandedInstall.filter((from) => !payloadFiles.some((file) => toEntryPath2(file) === from));
|
|
6011
6164
|
if (missingSources.length > 0) {
|
|
6012
6165
|
throw new Error(`packaging.files does not include ${missingSources.join(", ")} declared by spec.assets.`);
|
|
@@ -6119,7 +6272,7 @@ async function pack(options) {
|
|
|
6119
6272
|
treeDigest: sha256Hex(Buffer.from(digestsJson, "utf8")),
|
|
6120
6273
|
signed,
|
|
6121
6274
|
encrypted: encrypt,
|
|
6122
|
-
warnings: icons.warnings
|
|
6275
|
+
warnings: [...icons.warnings, ...suite.warnings]
|
|
6123
6276
|
};
|
|
6124
6277
|
} finally {
|
|
6125
6278
|
await rm(staging, { recursive: true, force: true });
|
|
@@ -6657,8 +6810,8 @@ function isNewerVersion(candidate, base) {
|
|
|
6657
6810
|
return compareVersions(candidate, base) > 0;
|
|
6658
6811
|
}
|
|
6659
6812
|
function compareVersions(a, b2) {
|
|
6660
|
-
const pa =
|
|
6661
|
-
const pb =
|
|
6813
|
+
const pa = parse9(a);
|
|
6814
|
+
const pb = parse9(b2);
|
|
6662
6815
|
for (let i = 0; i < 3; i++) {
|
|
6663
6816
|
if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
|
|
6664
6817
|
}
|
|
@@ -6685,7 +6838,7 @@ function compareVersions(a, b2) {
|
|
|
6685
6838
|
}
|
|
6686
6839
|
return 0;
|
|
6687
6840
|
}
|
|
6688
|
-
function
|
|
6841
|
+
function parse9(version) {
|
|
6689
6842
|
const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
|
|
6690
6843
|
const dash = cleaned.indexOf("-");
|
|
6691
6844
|
const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
|
|
@@ -7085,11 +7238,11 @@ function getCliVersion() {
|
|
|
7085
7238
|
}
|
|
7086
7239
|
function readVersion() {
|
|
7087
7240
|
const candidates = ["../package.json", "../../package.json"];
|
|
7088
|
-
for (const
|
|
7241
|
+
for (const relative8 of candidates) {
|
|
7089
7242
|
try {
|
|
7090
|
-
const raw = readFileSync(fileURLToPath(new URL(
|
|
7243
|
+
const raw = readFileSync(fileURLToPath(new URL(relative8, import.meta.url)), "utf8");
|
|
7091
7244
|
const pkg = JSON.parse(raw);
|
|
7092
|
-
if (pkg.version && (
|
|
7245
|
+
if (pkg.version && (relative8 === "../package.json" || pkg.name === PACKAGE_NAME)) return pkg.version;
|
|
7093
7246
|
} catch {
|
|
7094
7247
|
}
|
|
7095
7248
|
}
|
|
@@ -7427,6 +7580,11 @@ function registerValidate(program2) {
|
|
|
7427
7580
|
try {
|
|
7428
7581
|
const payloadFiles = await resolvePayloadFiles(dirname(manifestPath), manifestPath, manifest);
|
|
7429
7582
|
issues.push(...validateAgentAvatarPayloadFiles(manifest, payloadFiles).map((message) => ({ level: "error", message })));
|
|
7583
|
+
const suite = await validateAgentSuite(dirname(manifestPath), manifestPath, manifest, payloadFiles);
|
|
7584
|
+
issues.push(
|
|
7585
|
+
...suite.errors.map((message) => ({ level: "error", message })),
|
|
7586
|
+
...suite.warnings.map((message) => ({ level: "warning", message }))
|
|
7587
|
+
);
|
|
7430
7588
|
if (avatarPayloadErrors.length === 0) {
|
|
7431
7589
|
const templateInspection = await inspectPackagingTemplates(dirname(manifestPath), manifest, payloadFiles);
|
|
7432
7590
|
issues.push(...templateInspection.issues);
|