@verentis/cli 1.0.4 → 1.0.6
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 +29 -3
- package/dist/index.js +794 -85
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/samples/avatar-pack/clay.vavatar +1 -0
- package/samples/avatar-pack/manifest.yaml +29 -0
- package/src/vpkg/vendor/avatar/LICENSE +21 -0
- package/src/vpkg/vendor/avatar/THIRD_PARTY_NOTICES.txt +88 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, Option } from 'commander';
|
|
3
|
-
import { mkdir, stat, readFile, writeFile, readdir, realpath, glob, mkdtemp, rm, access } from 'fs/promises';
|
|
3
|
+
import { mkdir, stat, readFile, writeFile, readdir, realpath, glob, mkdtemp, rm, lstat, access } from 'fs/promises';
|
|
4
4
|
import { tmpdir, homedir } from 'os';
|
|
5
5
|
import { resolve, basename, dirname, posix, join, isAbsolute, relative, sep, extname } from 'path';
|
|
6
6
|
import { execFile, spawn, spawnSync } from 'child_process';
|
|
@@ -8,9 +8,11 @@ import { promisify, TextDecoder as TextDecoder$1 } from 'util';
|
|
|
8
8
|
import * as tar from 'tar';
|
|
9
9
|
import { extract } from 'tar';
|
|
10
10
|
import { generateKeyPairSync, createHash, randomUUID, randomBytes, createCipheriv, createPublicKey, verify, diffieHellman, hkdfSync, sign, createPrivateKey } from 'crypto';
|
|
11
|
-
import { parse, parseDocument, isScalar, stringify, Document, YAMLMap, Scalar, parseAllDocuments } from 'yaml';
|
|
11
|
+
import { parse, parseDocument, isScalar, stringify, Document, visit, isAlias, isNode, YAMLMap, Scalar, parseAllDocuments } from 'yaml';
|
|
12
12
|
import semver from 'semver';
|
|
13
13
|
import { createWriteStream, readFileSync, createReadStream } from 'fs';
|
|
14
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
15
|
+
import { buffer } from 'stream/consumers';
|
|
14
16
|
import { Readable } from 'stream';
|
|
15
17
|
import { pipeline } from 'stream/promises';
|
|
16
18
|
import { createRequire } from 'module';
|
|
@@ -715,7 +717,7 @@ var marketplace = {
|
|
|
715
717
|
|
|
716
718
|
// src/api/client.ts
|
|
717
719
|
function fillPath(template, params = {}) {
|
|
718
|
-
return template.replace(/\{(\w+)\}/g, (
|
|
720
|
+
return template.replace(/\{(\w+)\}/g, (_2, name) => {
|
|
719
721
|
const value = params[name];
|
|
720
722
|
if (value === void 0) throw new Error(`Missing path parameter '${name}' for ${template}`);
|
|
721
723
|
return String(value).split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
@@ -812,7 +814,7 @@ function printTable(rows, columns) {
|
|
|
812
814
|
const widths = headers.map((header, i) => Math.max(header.length, ...cells.map((row) => row[i].length)));
|
|
813
815
|
const line = (parts) => parts.map((part, i) => part.padEnd(widths[i])).join(" ").trimEnd();
|
|
814
816
|
console.log(line(headers));
|
|
815
|
-
console.log(line(widths.map((
|
|
817
|
+
console.log(line(widths.map((w2) => "-".repeat(w2))));
|
|
816
818
|
for (const row of cells) console.log(line(row));
|
|
817
819
|
}
|
|
818
820
|
function formatCell(value) {
|
|
@@ -1100,7 +1102,7 @@ async function substituteTemplateValues(root, values) {
|
|
|
1100
1102
|
const content = await readFile(path);
|
|
1101
1103
|
if (content.includes(0)) continue;
|
|
1102
1104
|
const text = content.toString("utf8");
|
|
1103
|
-
const substituted = text.replace(/\{\{(name|type)\}\}/g, (
|
|
1105
|
+
const substituted = text.replace(/\{\{(name|type)\}\}/g, (_2, key) => values[key] ?? "");
|
|
1104
1106
|
if (substituted !== text) await writeFile(path, substituted);
|
|
1105
1107
|
}
|
|
1106
1108
|
}
|
|
@@ -1235,6 +1237,7 @@ var package_types_default = {
|
|
|
1235
1237
|
mediaSlug: "agent",
|
|
1236
1238
|
sealedMediaSlug: "agent",
|
|
1237
1239
|
resourceKind: "Agent",
|
|
1240
|
+
installRoot: "applications/agents/{name}",
|
|
1238
1241
|
order: 30
|
|
1239
1242
|
},
|
|
1240
1243
|
{
|
|
@@ -1248,6 +1251,7 @@ var package_types_default = {
|
|
|
1248
1251
|
mediaSlug: "skill",
|
|
1249
1252
|
sealedMediaSlug: "skill",
|
|
1250
1253
|
resourceKind: "Skill",
|
|
1254
|
+
installRoot: "applications/skills/{name}",
|
|
1251
1255
|
order: 40
|
|
1252
1256
|
},
|
|
1253
1257
|
{
|
|
@@ -1261,6 +1265,7 @@ var package_types_default = {
|
|
|
1261
1265
|
mediaSlug: "tool",
|
|
1262
1266
|
sealedMediaSlug: "tool",
|
|
1263
1267
|
resourceKind: "Tool",
|
|
1268
|
+
installRoot: "applications/tools/{name}",
|
|
1264
1269
|
order: 50
|
|
1265
1270
|
},
|
|
1266
1271
|
{
|
|
@@ -1274,6 +1279,7 @@ var package_types_default = {
|
|
|
1274
1279
|
mediaSlug: "bundle",
|
|
1275
1280
|
sealedMediaSlug: "bundle",
|
|
1276
1281
|
resourceKind: "Custom",
|
|
1282
|
+
installRoot: "applications/bundles/{name}",
|
|
1277
1283
|
order: 60
|
|
1278
1284
|
},
|
|
1279
1285
|
{
|
|
@@ -1286,7 +1292,7 @@ var package_types_default = {
|
|
|
1286
1292
|
accent: "theme",
|
|
1287
1293
|
mediaSlug: "theme",
|
|
1288
1294
|
sealedMediaSlug: "theme",
|
|
1289
|
-
installRoot: "themes/{name}",
|
|
1295
|
+
installRoot: "applications/themes/{name}",
|
|
1290
1296
|
exclusiveSlot: "workspace-theme",
|
|
1291
1297
|
forceBranch: "main",
|
|
1292
1298
|
forceMode: "Extracted",
|
|
@@ -1295,6 +1301,21 @@ var package_types_default = {
|
|
|
1295
1301
|
hooks: { onUninstall: "workspace.theme.restore-defaults" },
|
|
1296
1302
|
forbiddenSpecFields: ["entry", "entry-points", "scopes", "permissions", "settings", "dependencies", "scripts", "engine", "launch", "install-root"],
|
|
1297
1303
|
order: 70
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
type: "AvatarPack",
|
|
1307
|
+
profile: "content",
|
|
1308
|
+
label: "Avatar style",
|
|
1309
|
+
plural: "Avatar styles",
|
|
1310
|
+
description: "Passive portrait styles for Avatar Studio.",
|
|
1311
|
+
icon: "palette",
|
|
1312
|
+
accent: "theme",
|
|
1313
|
+
mediaSlug: "avatar-pack",
|
|
1314
|
+
sealedMediaSlug: "avatar-pack",
|
|
1315
|
+
installRoot: "applications/avatar-packs/{name}",
|
|
1316
|
+
forceMode: "Extracted",
|
|
1317
|
+
validator: "avatar-pack",
|
|
1318
|
+
order: 80
|
|
1298
1319
|
}
|
|
1299
1320
|
]
|
|
1300
1321
|
};
|
|
@@ -1310,7 +1331,7 @@ var PackageTypeRegistry = class {
|
|
|
1310
1331
|
byKey = /* @__PURE__ */ new Map();
|
|
1311
1332
|
constructor(document) {
|
|
1312
1333
|
this.version = document.version ?? 1;
|
|
1313
|
-
this.types = [...document.types].sort((a,
|
|
1334
|
+
this.types = [...document.types].sort((a, b2) => (a.order ?? 0) - (b2.order ?? 0) || (a.type < b2.type ? -1 : a.type > b2.type ? 1 : 0));
|
|
1314
1335
|
for (const descriptor of this.types) {
|
|
1315
1336
|
if (!PACKAGE_PROFILES.includes(descriptor.profile)) {
|
|
1316
1337
|
throw new Error(`Package type '${descriptor.type}' has unknown profile '${String(descriptor.profile)}'.`);
|
|
@@ -1628,7 +1649,7 @@ function inlineIconsIntoDocument(document, resolution) {
|
|
|
1628
1649
|
return;
|
|
1629
1650
|
}
|
|
1630
1651
|
const node = new YAMLMap();
|
|
1631
|
-
for (const [key, markup] of [...icons.entries()].sort(([a], [
|
|
1652
|
+
for (const [key, markup] of [...icons.entries()].sort(([a], [b2]) => a.localeCompare(b2))) {
|
|
1632
1653
|
node.set(key, Object.assign(new Scalar(markup), { type: Scalar.BLOCK_LITERAL }));
|
|
1633
1654
|
}
|
|
1634
1655
|
document.set("icons", node);
|
|
@@ -1748,9 +1769,9 @@ function expandThemeManifest(manifest) {
|
|
|
1748
1769
|
return { ...manifest, spec: { ...spec, install } };
|
|
1749
1770
|
}
|
|
1750
1771
|
var SIGNATURES = {
|
|
1751
|
-
"image/png": (
|
|
1752
|
-
"image/jpeg": (
|
|
1753
|
-
"image/webp": (
|
|
1772
|
+
"image/png": (b2) => b2.length >= 8 && b2.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])),
|
|
1773
|
+
"image/jpeg": (b2) => b2.length >= 3 && b2[0] === 255 && b2[1] === 216 && b2[2] === 255,
|
|
1774
|
+
"image/webp": (b2) => b2.length >= 12 && b2.subarray(0, 4).toString("latin1") === "RIFF" && b2.subarray(8, 12).toString("latin1") === "WEBP"
|
|
1754
1775
|
};
|
|
1755
1776
|
var CSS_URL = /url\(\s*(?:"([^"]*)"?|'([^']*)'?|([^)]*))\s*\)?/gi;
|
|
1756
1777
|
var CSS_STRING_URL_FUNCTION = /\b(?:-webkit-)?(?:image-set|src|image|cross-fade)\s*\(/i;
|
|
@@ -1840,16 +1861,469 @@ var themeValidator = {
|
|
|
1840
1861
|
expandForPack: expandThemeManifest
|
|
1841
1862
|
};
|
|
1842
1863
|
|
|
1864
|
+
// src/vpkg/validators/avatar-pack.v1.schema.json
|
|
1865
|
+
var avatar_pack_v1_schema_default = {
|
|
1866
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
1867
|
+
title: "Signed AvatarPack manifest, Clay recipe revision 1",
|
|
1868
|
+
type: "object",
|
|
1869
|
+
additionalProperties: false,
|
|
1870
|
+
required: ["api-version", "kind", "metadata", "spec", "packaging"],
|
|
1871
|
+
properties: {
|
|
1872
|
+
"api-version": { const: "verentis.io/v1" },
|
|
1873
|
+
kind: { const: "AvatarPack" },
|
|
1874
|
+
metadata: {
|
|
1875
|
+
type: "object",
|
|
1876
|
+
additionalProperties: false,
|
|
1877
|
+
required: ["id", "name", "version"],
|
|
1878
|
+
properties: {
|
|
1879
|
+
id: { $ref: "#/$defs/id" },
|
|
1880
|
+
name: { type: "string", minLength: 1, maxLength: 96 },
|
|
1881
|
+
version: { type: "string", minLength: 1, maxLength: 64 },
|
|
1882
|
+
description: { type: "string", maxLength: 512 }
|
|
1883
|
+
}
|
|
1884
|
+
},
|
|
1885
|
+
packaging: {
|
|
1886
|
+
type: "object",
|
|
1887
|
+
additionalProperties: false,
|
|
1888
|
+
required: ["publisher", "files"],
|
|
1889
|
+
properties: {
|
|
1890
|
+
publisher: { $ref: "#/$defs/id" },
|
|
1891
|
+
files: { const: ["clay.vavatar"] },
|
|
1892
|
+
encryption: { const: "none" }
|
|
1893
|
+
}
|
|
1894
|
+
},
|
|
1895
|
+
spec: {
|
|
1896
|
+
type: "object",
|
|
1897
|
+
additionalProperties: false,
|
|
1898
|
+
required: ["style-id", "renderer", "recipe-revision", "project", "project-sha256", "preview-state", "traits", "cue-defaults", "attribution"],
|
|
1899
|
+
properties: {
|
|
1900
|
+
"style-id": { const: "clay" },
|
|
1901
|
+
renderer: { const: "opaline" },
|
|
1902
|
+
"recipe-revision": { const: 1 },
|
|
1903
|
+
project: { const: "clay.vavatar" },
|
|
1904
|
+
"project-sha256": { const: "83602b34b50cc27bf3df5da37a19ead950d55c219ca9f8a47547c389882891af" },
|
|
1905
|
+
"preview-state": { $ref: "#/$defs/state" },
|
|
1906
|
+
traits: {
|
|
1907
|
+
type: "object",
|
|
1908
|
+
additionalProperties: false,
|
|
1909
|
+
required: ["palette", "finish", "expression"],
|
|
1910
|
+
properties: {
|
|
1911
|
+
palette: { type: "array", uniqueItems: true, minItems: 1, maxItems: 7, items: { enum: ["vivid", "pastel", "electric", "muted", "warm", "cool", "mono"] } },
|
|
1912
|
+
finish: { type: "array", uniqueItems: true, minItems: 1, maxItems: 3, items: { enum: ["flat", "soft", "gloss"] } },
|
|
1913
|
+
expression: { type: "array", uniqueItems: true, minItems: 1, maxItems: 12, items: { enum: ["beam", "content", "proud", "dreamy", "hmm", "shy", "sleepy", "curious", "oh", "cheeky", "wink", "giggle"] } }
|
|
1914
|
+
}
|
|
1915
|
+
},
|
|
1916
|
+
"cue-defaults": {
|
|
1917
|
+
type: "object",
|
|
1918
|
+
additionalProperties: false,
|
|
1919
|
+
required: ["neutral"],
|
|
1920
|
+
properties: {
|
|
1921
|
+
neutral: { $ref: "#/$defs/state" },
|
|
1922
|
+
pleased: { $ref: "#/$defs/state" },
|
|
1923
|
+
amused: { $ref: "#/$defs/state" },
|
|
1924
|
+
surprised: { $ref: "#/$defs/state" },
|
|
1925
|
+
concerned: { $ref: "#/$defs/state" },
|
|
1926
|
+
sad: { $ref: "#/$defs/state" }
|
|
1927
|
+
}
|
|
1928
|
+
},
|
|
1929
|
+
attribution: { const: "Opaline Clay: Copyright (c) 2026 Inlaylab (MIT)" }
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
},
|
|
1933
|
+
$defs: {
|
|
1934
|
+
id: { type: "string", maxLength: 64, pattern: "^[a-z0-9]+(-[a-z0-9]+)*$" },
|
|
1935
|
+
state: { enum: ["idle", "happy", "curious", "concerned", "surprised", "sleeping", "wink", "play", "greet"] }
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1939
|
+
// src/vpkg/vendor/avatar/face-parser.mjs
|
|
1940
|
+
var j = 256;
|
|
1941
|
+
var S = ["idle", "thinking", "wink", "wide", "alert", "notify", "exclaim", "sleep", "egg", "hexagon", "play", "orbit", "swirl", "burst", "comet"];
|
|
1942
|
+
var x = Object.freeze(["waiting", "thinking", "working", "speaking"]);
|
|
1943
|
+
var w = Object.freeze(["neutral", "pleased", "amused", "surprised", "concerned", "sad"]);
|
|
1944
|
+
var h = Object.freeze(["beam", "content", "proud", "dreamy", "hmm", "shy", "sleepy", "curious", "oh", "cheeky", "wink", "giggle"]);
|
|
1945
|
+
var C = Object.freeze(["vivid", "pastel", "electric", "muted", "warm", "cool", "mono"]);
|
|
1946
|
+
var O = Object.freeze(["flat", "soft", "gloss"]);
|
|
1947
|
+
var u = Object.freeze({ seedLength: 128, shapes: 32, expressions: 64, states: 64, animations: 64, transitions: 256, steps: 32, radiusMin: 0.05, radiusMax: 1.5, yaw: 89, pitch: 89, roll: 89, split: 45, eyeSizeMin: 0.02, eyeSizeMax: 1, tilt: 90, holdMin: 0.1, holdMax: 60, entrySeconds: 8, ambientSeconds: 6, ambientFps: 12 });
|
|
1948
|
+
function z(n) {
|
|
1949
|
+
return typeof n == "string" && n.length <= u.seedLength * 2 && [...n].length <= u.seedLength && n.trim().length > 0 && !/[\u0000-\u001f\u007f]/.test(n);
|
|
1950
|
+
}
|
|
1951
|
+
function D(n, t, e2) {
|
|
1952
|
+
z(t) || n.issue(e2, "appearance.seed", `Expected a non-blank seed of at most ${u.seedLength} characters without control characters.`);
|
|
1953
|
+
}
|
|
1954
|
+
function A(n, t, e2) {
|
|
1955
|
+
let r = n.object(t, e2, ["kind", "generatorVersion", "style", "seed", "options"]);
|
|
1956
|
+
if (!r) return;
|
|
1957
|
+
r.kind !== "opaline" && n.issue(`${e2}.kind`, "appearance.kind", "Unsupported appearance kind; expected opaline."), r.generatorVersion !== 1 && n.issue(`${e2}.generatorVersion`, "appearance.revision", "Unsupported Opaline generator revision; expected generatorVersion 1."), r.style !== "clay" && n.issue(`${e2}.style`, "appearance.style", "Unsupported Opaline style; expected clay."), D(n, r.seed, `${e2}.seed`);
|
|
1958
|
+
let a = n.object(r.options, `${e2}.options`, ["body", "ears", "palette", "finish", "expression"]);
|
|
1959
|
+
a && (n.choice(a.body, `${e2}.options.body`, ["hood"]), n.choice(a.ears, `${e2}.options.ears`, ["bunny"]), n.choice(a.palette, `${e2}.options.palette`, C), n.choice(a.finish, `${e2}.options.finish`, O), n.choice(a.expression, `${e2}.options.expression`, h));
|
|
1960
|
+
}
|
|
1961
|
+
function I(n) {
|
|
1962
|
+
return Number(n.reduce((t, e2) => t + e2.hold, 0).toPrecision(15));
|
|
1963
|
+
}
|
|
1964
|
+
function E(n, t, e2) {
|
|
1965
|
+
let r = n.object(t, e2, ["version"], ["live", "settled"]);
|
|
1966
|
+
if (r) {
|
|
1967
|
+
if (r.version !== 1 && n.issue(`${e2}.version`, "version.unsupported", "Unsupported cue bindings version."), r.live !== void 0) {
|
|
1968
|
+
let a = n.object(r.live, `${e2}.live`, [], x);
|
|
1969
|
+
if (a) for (let p of x) Object.hasOwn(a, p) && n.id(a[p], `${e2}.live.${p}`);
|
|
1970
|
+
}
|
|
1971
|
+
if (r.settled !== void 0) {
|
|
1972
|
+
let a = n.object(r.settled, `${e2}.settled`, [], w);
|
|
1973
|
+
if (a) for (let p of w) {
|
|
1974
|
+
if (!Object.hasOwn(a, p)) continue;
|
|
1975
|
+
let c = `${e2}.settled.${p}`, o = n.object(a[p], c, ["stateId"], ["entryAnimationId", "motion"]);
|
|
1976
|
+
o && (n.id(o.stateId, `${c}.stateId`), o.entryAnimationId !== void 0 && n.id(o.entryAnimationId, `${c}.entryAnimationId`), o.motion !== void 0 && n.choice(o.motion, `${c}.motion`, ["hold", "ambient"]));
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
var b = Object.freeze({ bundleBytes: 4 * 1024 * 1024, projectBytes: 8 * 1024 * 1024, parts: 128, geometries: 128, paints: 128, poses: 128, clips: 128, behaviours: 128, segments: 4096, keyframes: 2e4, tracks: 2048, nesting: 16, morphSegmentsPerContour: j, jsonDepth: 64, jsonNodes: 3e5, jsonArrayItems: 2e4, jsonObjectKeys: 2048, sampleSeconds: 1e9, history: 4096 });
|
|
1982
|
+
var G = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
1983
|
+
var V = /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/;
|
|
1984
|
+
var T = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
1985
|
+
var F = 1e6;
|
|
1986
|
+
var $ = class {
|
|
1987
|
+
constructor(t = "v1") {
|
|
1988
|
+
this.version = t;
|
|
1989
|
+
}
|
|
1990
|
+
version;
|
|
1991
|
+
diagnostics = [];
|
|
1992
|
+
errorCount = 0;
|
|
1993
|
+
issue(t, e2, r, a = "error") {
|
|
1994
|
+
a === "error" && this.errorCount++;
|
|
1995
|
+
let p = { path: t, code: e2, message: r, severity: a };
|
|
1996
|
+
this.diagnostics.length < 200 ? this.diagnostics.push(p) : a === "error" && !this.diagnostics.some((c) => c.severity === "error") && (this.diagnostics[199] = p);
|
|
1997
|
+
}
|
|
1998
|
+
object(t, e2, r, a = []) {
|
|
1999
|
+
if (t === null || typeof t != "object" || Array.isArray(t)) {
|
|
2000
|
+
this.issue(e2, "type.object", "Expected an object.");
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
let p = t;
|
|
2004
|
+
for (let o of r) Object.hasOwn(p, o) || this.issue(`${e2}.${o}`, "field.required", "Required field is missing.");
|
|
2005
|
+
let c = /* @__PURE__ */ new Set([...r, ...a]);
|
|
2006
|
+
for (let o of Object.keys(p)) c.has(o) || this.issue(`${e2}.${o}`, "field.unknown", `Unknown fields are not supported in ${this.version}.`);
|
|
2007
|
+
return p;
|
|
2008
|
+
}
|
|
2009
|
+
array(t, e2, r, a) {
|
|
2010
|
+
return Array.isArray(t) ? t.length < r || t.length > a ? (this.issue(e2, "limit.items", `Expected between ${r} and ${a} items.`), []) : t : (this.issue(e2, "type.array", "Expected an array."), []);
|
|
2011
|
+
}
|
|
2012
|
+
number(t, e2, r = -F, a = F, p = false) {
|
|
2013
|
+
(typeof t != "number" || !Number.isFinite(t) || t < r || t > a || p && !Number.isInteger(t)) && this.issue(e2, "number.range", `Expected a finite ${p ? "integer" : "number"} between ${r} and ${a}.`);
|
|
2014
|
+
}
|
|
2015
|
+
text(t, e2, r = 256) {
|
|
2016
|
+
(typeof t != "string" || t.length < 1 || t.length > r || /[\u0000-\u001f\u007f]/.test(t)) && this.issue(e2, "string.invalid", `Expected a non-empty string of at most ${r} characters without control characters.`);
|
|
2017
|
+
}
|
|
2018
|
+
publicText(t, e2, r) {
|
|
2019
|
+
this.text(t, e2, r), typeof t == "string" && (/(?:^|[\s"'(])(?:\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*|[A-Za-z]:[\\/][^\s"'<>]*)/.test(t) && this.issue(e2, "metadata.path", "Runtime metadata must not contain local absolute paths."), /\b(?:Bearer\s+[A-Za-z0-9._~+/-]+=*|(?:access[_-]?token|api[_-]?key|password|secret)\s*[:=]\s*\S+)/i.test(t) && this.issue(e2, "metadata.credentials", "Runtime metadata must not contain credentials."));
|
|
2020
|
+
}
|
|
2021
|
+
id(t, e2) {
|
|
2022
|
+
(typeof t != "string" || !G.test(t) || T.has(t.toLowerCase())) && this.issue(e2, "id.invalid", 'Expected a safe identifier beginning with a letter, using only letters, digits, "_" and "-".');
|
|
2023
|
+
}
|
|
2024
|
+
colour(t, e2) {
|
|
2025
|
+
(typeof t != "string" || !V.test(t)) && this.issue(e2, "colour.invalid", "Expected #RRGGBB or #RRGGBBAA.");
|
|
2026
|
+
}
|
|
2027
|
+
bool(t, e2) {
|
|
2028
|
+
typeof t != "boolean" && this.issue(e2, "type.boolean", "Expected a boolean.");
|
|
2029
|
+
}
|
|
2030
|
+
choice(t, e2, r) {
|
|
2031
|
+
(typeof t != "string" || !r.includes(t)) && this.issue(e2, "enum.invalid", `Expected one of: ${r.join(", ")}.`);
|
|
2032
|
+
}
|
|
2033
|
+
point(t, e2) {
|
|
2034
|
+
let r = this.array(t, e2, 2, 2);
|
|
2035
|
+
r.length === 2 && (this.number(r[0], `${e2}[0]`), this.number(r[1], `${e2}[1]`));
|
|
2036
|
+
}
|
|
2037
|
+
get valid() {
|
|
2038
|
+
return this.errorCount === 0;
|
|
2039
|
+
}
|
|
2040
|
+
result() {
|
|
2041
|
+
return { valid: this.valid, diagnostics: this.diagnostics };
|
|
2042
|
+
}
|
|
2043
|
+
};
|
|
2044
|
+
function M(n, t, e2) {
|
|
2045
|
+
try {
|
|
2046
|
+
let r = [{ value: n, path: "$", depth: 0 }], a = /* @__PURE__ */ new WeakSet(), p = 0;
|
|
2047
|
+
for (; r.length; ) {
|
|
2048
|
+
let { value: o, path: d, depth: s } = r.pop();
|
|
2049
|
+
if (++p > b.jsonNodes) return e2.issue(d, "limit.nodes", "JSON contains too many values."), false;
|
|
2050
|
+
if (s > b.jsonDepth) return e2.issue(d, "limit.depth", "JSON nesting exceeds the limit."), false;
|
|
2051
|
+
if (o === null || typeof o == "boolean") continue;
|
|
2052
|
+
if (typeof o == "number") {
|
|
2053
|
+
Number.isFinite(o) || e2.issue(d, "number.finite", "Numbers must be finite.");
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
if (typeof o == "string") {
|
|
2057
|
+
o.length > t && e2.issue(d, "limit.string", "String exceeds the document size limit."), /https?:\/\/[^\s/]*@/i.test(o) && e2.issue(d, "url.credentials", "Credential-bearing URLs are not permitted.");
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (typeof o != "object") {
|
|
2061
|
+
e2.issue(d, "json.value", "Only inert JSON data is accepted.");
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
if (a.has(o)) {
|
|
2065
|
+
e2.issue(d, "json.cycle", "JSON cannot contain cycles or shared object references.");
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
a.add(o);
|
|
2069
|
+
let i = Array.isArray(o), l = Object.getPrototypeOf(o);
|
|
2070
|
+
if (l !== (i ? Array.prototype : Object.prototype) && l !== null) {
|
|
2071
|
+
e2.issue(d, "json.prototype", "Only plain JSON objects and arrays are accepted.");
|
|
2072
|
+
continue;
|
|
2073
|
+
}
|
|
2074
|
+
if (Object.getOwnPropertySymbols(o).length && e2.issue(d, "json.symbol", "Symbol properties are not accepted."), i && o.length > b.jsonArrayItems) return e2.issue(d, "limit.items", `Arrays may not exceed ${b.jsonArrayItems} items.`), false;
|
|
2075
|
+
if (!i && Reflect.ownKeys(o).length > b.jsonObjectKeys) return e2.issue(d, "limit.keys", `Objects may not exceed ${b.jsonObjectKeys} keys.`), false;
|
|
2076
|
+
let m = Object.getOwnPropertyDescriptors(o);
|
|
2077
|
+
for (let [f, y] of Object.entries(m)) if (!(i && f === "length")) {
|
|
2078
|
+
if (T.has(f.toLowerCase())) {
|
|
2079
|
+
e2.issue(`${d}.${f}`, "id.unsafe", "Prototype-sensitive keys are not permitted.");
|
|
2080
|
+
continue;
|
|
2081
|
+
}
|
|
2082
|
+
if (!("value" in y) || !y.enumerable) {
|
|
2083
|
+
e2.issue(`${d}.${f}`, "json.property", "Accessors and non-enumerable properties are not accepted.");
|
|
2084
|
+
continue;
|
|
2085
|
+
}
|
|
2086
|
+
if (i && (!/^(0|[1-9]\d*)$/.test(f) || Number(f) >= o.length)) {
|
|
2087
|
+
e2.issue(`${d}.${f}`, "json.array-property", "Arrays cannot have extra properties.");
|
|
2088
|
+
continue;
|
|
2089
|
+
}
|
|
2090
|
+
r.push({ value: y.value, path: i ? `${d}[${f}]` : `${d}.${f}`, depth: s + 1 });
|
|
2091
|
+
}
|
|
2092
|
+
i && Object.keys(m).length - 1 !== o.length && e2.issue(d, "json.sparse", "Sparse arrays are not accepted.");
|
|
2093
|
+
}
|
|
2094
|
+
if (!e2.valid) return false;
|
|
2095
|
+
let c = JSON.stringify(n);
|
|
2096
|
+
return typeof c != "string" || new TextEncoder().encode(c).byteLength > t ? (e2.issue("$", "limit.bytes", `Document exceeds ${t} UTF-8 bytes.`), false) : true;
|
|
2097
|
+
} catch {
|
|
2098
|
+
return e2.issue("$", "json.invalid", "The document could not be inspected as inert JSON."), false;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
var g = class extends Error {
|
|
2102
|
+
diagnostics;
|
|
2103
|
+
constructor(t) {
|
|
2104
|
+
super(t.find((e2) => e2.severity === "error")?.message ?? "Invalid avatar data."), this.name = "AvatarValidationError", this.diagnostics = t;
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
function U(n) {
|
|
2108
|
+
let t = 0, e2 = () => {
|
|
2109
|
+
for (; t < n.length && /[ \t\r\n]/.test(n[t]); ) t++;
|
|
2110
|
+
}, r = () => {
|
|
2111
|
+
throw new Error("Invalid JSON");
|
|
2112
|
+
};
|
|
2113
|
+
function a() {
|
|
2114
|
+
if (n[t] !== '"') return r();
|
|
2115
|
+
let c = t++;
|
|
2116
|
+
for (; t < n.length; ) {
|
|
2117
|
+
let o = n[t++];
|
|
2118
|
+
if (o === '"') return JSON.parse(n.slice(c, t));
|
|
2119
|
+
if (o === "\\") {
|
|
2120
|
+
if (t >= n.length) return r();
|
|
2121
|
+
t++;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
return r();
|
|
2125
|
+
}
|
|
2126
|
+
function p(c) {
|
|
2127
|
+
if (c > b.jsonDepth) throw new g([{ path: "$", code: "limit.depth", message: "JSON nesting exceeds the limit.", severity: "error" }]);
|
|
2128
|
+
if (e2(), n[t] === "{") {
|
|
2129
|
+
if (t++, e2(), n[t] === "}") {
|
|
2130
|
+
t++;
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
let d = /* @__PURE__ */ new Set();
|
|
2134
|
+
for (; t < n.length; ) {
|
|
2135
|
+
e2();
|
|
2136
|
+
let s = a();
|
|
2137
|
+
if (d.has(s)) throw new g([{ path: "$", code: "json.duplicate", message: `Duplicate JSON object key "${s}".`, severity: "error" }]);
|
|
2138
|
+
if (d.add(s), e2(), n[t++] !== ":") return r();
|
|
2139
|
+
if (p(c + 1), e2(), n[t] === "}") {
|
|
2140
|
+
t++;
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
if (n[t++] !== ",") return r();
|
|
2144
|
+
}
|
|
2145
|
+
return r();
|
|
2146
|
+
}
|
|
2147
|
+
if (n[t] === "[") {
|
|
2148
|
+
if (t++, e2(), n[t] === "]") {
|
|
2149
|
+
t++;
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
for (; t < n.length; ) {
|
|
2153
|
+
if (p(c + 1), e2(), n[t] === "]") {
|
|
2154
|
+
t++;
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
if (n[t++] !== ",") return r();
|
|
2158
|
+
}
|
|
2159
|
+
return r();
|
|
2160
|
+
}
|
|
2161
|
+
if (n[t] === '"') {
|
|
2162
|
+
a();
|
|
2163
|
+
return;
|
|
2164
|
+
}
|
|
2165
|
+
let o = t;
|
|
2166
|
+
for (; t < n.length && !/[ \t\r\n,}\]]/.test(n[t]); ) t++;
|
|
2167
|
+
t === o && r();
|
|
2168
|
+
}
|
|
2169
|
+
p(0), e2(), t !== n.length && r();
|
|
2170
|
+
}
|
|
2171
|
+
function R(n, t) {
|
|
2172
|
+
if (typeof n != "string" || n.length > t || new TextEncoder().encode(n).byteLength > t) throw new g([{ path: "$", code: "limit.bytes", message: `Document exceeds ${t} UTF-8 bytes.`, severity: "error" }]);
|
|
2173
|
+
try {
|
|
2174
|
+
return U(n), JSON.parse(n);
|
|
2175
|
+
} catch (e2) {
|
|
2176
|
+
throw e2 instanceof g ? e2 : new g([{ path: "$", code: "json.parse", message: "Document is not valid JSON.", severity: "error" }]);
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
var Y = /^#[0-9a-fA-F]{6}$/;
|
|
2180
|
+
function v(n, t, e2) {
|
|
2181
|
+
n.publicText(t, e2, 128), typeof t == "string" && (/[<>]/.test(t) || /\b(?:https?|file|javascript|data):/i.test(t)) && n.issue(e2, "string.unsafe", "Names cannot contain markup or resource URLs.");
|
|
2182
|
+
}
|
|
2183
|
+
function P(n, t, e2) {
|
|
2184
|
+
(typeof t != "string" || !Y.test(t)) && n.issue(e2, "colour.invalid", "Expected an opaque #RRGGBB colour.");
|
|
2185
|
+
}
|
|
2186
|
+
function J(n, t, e2) {
|
|
2187
|
+
let r = n.object(t, e2, ["w", "h", "open", "tilt"]);
|
|
2188
|
+
r && (n.number(r.w, `${e2}.w`, u.eyeSizeMin, u.eyeSizeMax), n.number(r.h, `${e2}.h`, u.eyeSizeMin, u.eyeSizeMax), n.number(r.open, `${e2}.open`, 0, 1), n.number(r.tilt, `${e2}.tilt`, -u.tilt, u.tilt));
|
|
2189
|
+
}
|
|
2190
|
+
function _(n, t, e2, r) {
|
|
2191
|
+
n.array(t, e2, r, u.steps).forEach((a, p) => {
|
|
2192
|
+
let c = `${e2}[${p}]`, o = n.object(a, c, ["state", "hold"]);
|
|
2193
|
+
o && (n.id(o.state, `${c}.state`), n.number(o.hold, `${c}.hold`, u.holdMin, u.holdMax));
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2196
|
+
function q(n, t, e2) {
|
|
2197
|
+
let r = e2.object(n, "$", ["format", "version", "id", "metadata", "palette", "shapes", "expressions", "states", "initialState", "animations", "transitions", ...t === 4 ? ["appearance"] : t === 5 ? ["cueBindings"] : []], t === 5 ? ["appearance"] : []);
|
|
2198
|
+
if (!r) return;
|
|
2199
|
+
r.format !== "verentis-avatar" && e2.issue("$.format", "format.unsupported", "Expected verentis-avatar.");
|
|
2200
|
+
let a = t === 4 || t === 5 && Object.hasOwn(r, "appearance");
|
|
2201
|
+
a && A(e2, r.appearance, "$.appearance"), t === 5 && E(e2, r.cueBindings, "$.cueBindings"), e2.id(r.id, "$.id");
|
|
2202
|
+
let p = e2.object(r.metadata, "$.metadata", ["name"]);
|
|
2203
|
+
p && v(e2, p.name, "$.metadata.name");
|
|
2204
|
+
let c = e2.object(r.palette, "$.palette", ["body", "eye", "accent"]);
|
|
2205
|
+
c && (P(e2, c.body, "$.palette.body"), P(e2, c.eye, "$.palette.eye"), P(e2, c.accent, "$.palette.accent")), e2.array(r.shapes, "$.shapes", 1, u.shapes).forEach((o, d) => {
|
|
2206
|
+
let s = `$.shapes[${d}]`, i = e2.object(o, s, ["id", "name", "radii"]);
|
|
2207
|
+
i && (e2.id(i.id, `${s}.id`), v(e2, i.name, `${s}.name`), e2.array(i.radii, `${s}.radii`, 64, 64).forEach((l, m) => e2.number(l, `${s}.radii[${m}]`, u.radiusMin, u.radiusMax)));
|
|
2208
|
+
}), e2.array(r.expressions, "$.expressions", 1, u.expressions).forEach((o, d) => {
|
|
2209
|
+
let s = `$.expressions[${d}]`, i = e2.object(o, s, ["id", "name", "gaze", "split", "eyes"], a ? ["opaline"] : []);
|
|
2210
|
+
if (!i) return;
|
|
2211
|
+
e2.id(i.id, `${s}.id`), v(e2, i.name, `${s}.name`), i.opaline !== void 0 && a && e2.choice(i.opaline, `${s}.opaline`, h);
|
|
2212
|
+
let l = e2.object(i.gaze, `${s}.gaze`, ["yaw", "pitch", "roll"]);
|
|
2213
|
+
l && (e2.number(l.yaw, `${s}.gaze.yaw`, -u.yaw, u.yaw), e2.number(l.pitch, `${s}.gaze.pitch`, -u.pitch, u.pitch), e2.number(l.roll, `${s}.gaze.roll`, -u.roll, u.roll)), e2.number(i.split, `${s}.split`, 0, u.split), e2.array(i.eyes, `${s}.eyes`, 2, 2).forEach((m, f) => J(e2, m, `${s}.eyes[${f}]`));
|
|
2214
|
+
}), e2.array(r.states, "$.states", 1, u.states).forEach((o, d) => {
|
|
2215
|
+
let s = `$.states[${d}]`, i = e2.object(o, s, ["id", "name", "motion"], ["shape", "expression"]);
|
|
2216
|
+
i && (e2.id(i.id, `${s}.id`), v(e2, i.name, `${s}.name`), e2.choice(i.motion, `${s}.motion`, S), i.shape !== void 0 && e2.id(i.shape, `${s}.shape`), i.expression !== void 0 && e2.id(i.expression, `${s}.expression`));
|
|
2217
|
+
}), e2.id(r.initialState, "$.initialState"), e2.array(r.animations, "$.animations", 0, u.animations).forEach((o, d) => {
|
|
2218
|
+
let s = `$.animations[${d}]`, i = e2.object(o, s, ["id", "name", "event", "mode", "steps"]);
|
|
2219
|
+
i && (e2.id(i.id, `${s}.id`), v(e2, i.name, `${s}.name`), e2.id(i.event, `${s}.event`), e2.choice(i.mode, `${s}.mode`, ["loop", "once"]), _(e2, i.steps, `${s}.steps`, 1));
|
|
2220
|
+
}), e2.array(r.transitions, "$.transitions", 0, u.transitions).forEach((o, d) => {
|
|
2221
|
+
let s = `$.transitions[${d}]`, i = e2.object(o, s, ["from", "to", "steps"]);
|
|
2222
|
+
i && (e2.id(i.from, `${s}.from`), e2.id(i.to, `${s}.to`), _(e2, i.steps, `${s}.steps`, 1));
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
function K(n, t) {
|
|
2226
|
+
function e2(i, l) {
|
|
2227
|
+
let m = /* @__PURE__ */ new Set();
|
|
2228
|
+
return i.forEach((f, y) => {
|
|
2229
|
+
m.has(f.id) && t.issue(`${l}[${y}].id`, "id.duplicate", "Identifiers must be unique in this collection."), m.add(f.id);
|
|
2230
|
+
}), m;
|
|
2231
|
+
}
|
|
2232
|
+
let r = e2(n.shapes, "$.shapes"), a = e2(n.expressions, "$.expressions"), p = e2(n.states, "$.states"), c = e2(n.animations, "$.animations"), o = (i, l, m) => {
|
|
2233
|
+
i.has(l) || t.issue(m, "reference.missing", `No item has identifier "${l}".`);
|
|
2234
|
+
};
|
|
2235
|
+
if (n.states.forEach((i, l) => {
|
|
2236
|
+
i.shape !== void 0 && o(r, i.shape, `$.states[${l}].shape`), i.expression !== void 0 && o(a, i.expression, `$.states[${l}].expression`);
|
|
2237
|
+
}), o(p, n.initialState, "$.initialState"), n.version === 5) {
|
|
2238
|
+
for (let [i, l] of Object.entries(n.cueBindings.live ?? {})) o(p, l, `$.cueBindings.live.${i}`);
|
|
2239
|
+
for (let [i, l] of Object.entries(n.cueBindings.settled ?? {})) {
|
|
2240
|
+
let m = `$.cueBindings.settled.${i}`;
|
|
2241
|
+
if (o(p, l.stateId, `${m}.stateId`), l.entryAnimationId === void 0) continue;
|
|
2242
|
+
o(c, l.entryAnimationId, `${m}.entryAnimationId`);
|
|
2243
|
+
let f = n.animations.find((y) => y.id === l.entryAnimationId);
|
|
2244
|
+
f && (f.mode !== "once" || I(f.steps) > u.entrySeconds) && t.issue(`${m}.entryAnimationId`, "animation.entry", `Entry must play once for at most ${u.entrySeconds} seconds.`);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
let d = /* @__PURE__ */ new Set();
|
|
2248
|
+
n.animations.forEach((i, l) => {
|
|
2249
|
+
let m = `$.animations[${l}]`;
|
|
2250
|
+
i.steps.forEach((f, y) => o(p, f.state, `${m}.steps[${y}].state`)), (d.has(i.event) || p.has(i.event)) && t.issue(`${m}.event`, "animation.event", "An animation event must be unique and must not be a state identifier."), d.add(i.event);
|
|
2251
|
+
});
|
|
2252
|
+
let s = /* @__PURE__ */ new Set();
|
|
2253
|
+
n.transitions.forEach((i, l) => {
|
|
2254
|
+
let m = `$.transitions[${l}]`;
|
|
2255
|
+
o(p, i.from, `${m}.from`), o(p, i.to, `${m}.to`), i.steps.forEach((y, L) => o(p, y.state, `${m}.steps[${L}].state`));
|
|
2256
|
+
let f = `${i.from}>${i.to}`;
|
|
2257
|
+
s.has(f) && t.issue(m, "transition.duplicate", "Each pair of states may have only one transition."), s.add(f);
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
function B(n) {
|
|
2261
|
+
let t = new $();
|
|
2262
|
+
if (!M(n, b.bundleBytes, t)) return t.result();
|
|
2263
|
+
try {
|
|
2264
|
+
let e2 = n && typeof n == "object" && "version" in n ? n.version : void 0;
|
|
2265
|
+
if (e2 !== 3 && e2 !== 4 && e2 !== 5) {
|
|
2266
|
+
let r = e2 === 1 ? "This is a version 1 rig; load it with parseAvatar from @verentis/avatar." : e2 === 2 ? "This is a version 2 face; load it with @verentis/avatar/face-v2." : "Unsupported face format version; expected version 3, 4 or 5.";
|
|
2267
|
+
return t.issue("$.version", "version.unsupported", r), t.result();
|
|
2268
|
+
}
|
|
2269
|
+
t = new $(`v${e2}`), q(n, e2, t), t.valid && K(n, t);
|
|
2270
|
+
} catch {
|
|
2271
|
+
t.issue("$", "validation.failed", "The face avatar could not be validated.");
|
|
2272
|
+
}
|
|
2273
|
+
return t.result();
|
|
2274
|
+
}
|
|
2275
|
+
function H(n) {
|
|
2276
|
+
let t = R(n, b.bundleBytes), e2 = B(t);
|
|
2277
|
+
if (!e2.valid) throw new g(e2.diagnostics);
|
|
2278
|
+
return t;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
// src/vpkg/validators/avatar-pack.ts
|
|
2282
|
+
var validate = new Ajv2020().compile(avatar_pack_v1_schema_default);
|
|
2283
|
+
function checkAvatarPackYaml(kind, text) {
|
|
2284
|
+
if (kind !== "AvatarPack") return;
|
|
2285
|
+
if (Buffer.byteLength(text) > 16 * 1024) throw new Error("AvatarPack YAML exceeds 16 KiB.");
|
|
2286
|
+
visit(parseDocument(text), (_2, node) => {
|
|
2287
|
+
if (isAlias(node) || isNode(node) && (node.tag || "anchor" in node && node.anchor))
|
|
2288
|
+
throw new Error("AvatarPack YAML cannot use anchors, aliases or explicit tags.");
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
function manifestErrors(manifest) {
|
|
2292
|
+
return validate(manifest) ? [] : (validate.errors ?? []).map((e2) => `AvatarPack ${e2.instancePath || "/"}: ${e2.message}`);
|
|
2293
|
+
}
|
|
2294
|
+
var avatarPackValidator = {
|
|
2295
|
+
validateManifest: manifestErrors,
|
|
2296
|
+
async validatePayload(projectDir, manifest) {
|
|
2297
|
+
if (!validate(manifest)) return manifestErrors(manifest);
|
|
2298
|
+
const spec = manifest.spec;
|
|
2299
|
+
try {
|
|
2300
|
+
const path = join(projectDir, spec.project);
|
|
2301
|
+
const info = await lstat(path);
|
|
2302
|
+
if (!info.isFile() || info.size > 64 * 1024) return ["AvatarPack requires a local regular project file \u226464 KiB."];
|
|
2303
|
+
const bytes = await readFile(path);
|
|
2304
|
+
if (createHash("sha256").update(bytes).digest("hex") !== spec["project-sha256"])
|
|
2305
|
+
return ["AvatarPack project does not match the approved native starter for this recipe revision."];
|
|
2306
|
+
const native = H(bytes.toString("utf8"));
|
|
2307
|
+
const states = new Set(native.states.map((s) => s.id));
|
|
2308
|
+
return [spec["preview-state"], ...Object.values(spec["cue-defaults"])].every((id) => states.has(id)) ? [] : ["AvatarPack preview or cue refers to an unknown native state."];
|
|
2309
|
+
} catch {
|
|
2310
|
+
return ["AvatarPack project cannot be read."];
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
};
|
|
2314
|
+
|
|
1843
2315
|
// src/vpkg/validators/index.ts
|
|
1844
2316
|
var PACKAGE_TYPE_VALIDATORS = {
|
|
1845
|
-
theme: themeValidator
|
|
2317
|
+
theme: themeValidator,
|
|
2318
|
+
"avatar-pack": avatarPackValidator
|
|
1846
2319
|
};
|
|
1847
2320
|
function validatorForKind(kind) {
|
|
1848
2321
|
const name = findPackageType(kind)?.validator;
|
|
1849
2322
|
return name ? PACKAGE_TYPE_VALIDATORS[name] : void 0;
|
|
1850
2323
|
}
|
|
1851
2324
|
var DOTLOTTIE_V2_FORMAT = "dotlottie/v2";
|
|
1852
|
-
var
|
|
2325
|
+
var NATIVE_AVATAR_FORMAT = "vavatar";
|
|
2326
|
+
var AVATAR_DEFINITION_MAX_BYTES = 4 * 1024 * 1024;
|
|
1853
2327
|
var AVATAR_FALLBACK_MAX_BYTES = 1024 * 1024;
|
|
1854
2328
|
var isRecord3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1855
2329
|
function normalizeAvatarAssetPath(value) {
|
|
@@ -1871,12 +2345,13 @@ function validateAgentAvatarManifest(kind, spec) {
|
|
|
1871
2345
|
errors.push(`spec.avatar.${key} is not supported.`);
|
|
1872
2346
|
}
|
|
1873
2347
|
}
|
|
1874
|
-
if (avatar.format !== DOTLOTTIE_V2_FORMAT) {
|
|
1875
|
-
errors.push(`spec.avatar.format must be '${DOTLOTTIE_V2_FORMAT}'.`);
|
|
2348
|
+
if (avatar.format !== DOTLOTTIE_V2_FORMAT && avatar.format !== NATIVE_AVATAR_FORMAT) {
|
|
2349
|
+
errors.push(`spec.avatar.format must be '${DOTLOTTIE_V2_FORMAT}' or '${NATIVE_AVATAR_FORMAT}'.`);
|
|
1876
2350
|
}
|
|
1877
2351
|
const definition = normalizeAvatarAssetPath(avatar.definition);
|
|
1878
|
-
|
|
1879
|
-
|
|
2352
|
+
const extension = avatar.format === NATIVE_AVATAR_FORMAT ? ".vavatar" : ".lottie";
|
|
2353
|
+
if (!definition || !definition.endsWith(extension)) {
|
|
2354
|
+
errors.push(`spec.avatar.definition must be a safe relative ${extension} package path (no absolute paths, traversal, URLs or encoded separators).`);
|
|
1880
2355
|
}
|
|
1881
2356
|
if (avatar.fallback !== void 0) {
|
|
1882
2357
|
const fallback = normalizeAvatarAssetPath(avatar.fallback);
|
|
@@ -1891,6 +2366,11 @@ function agentAvatarPayloadPaths(manifest) {
|
|
|
1891
2366
|
const avatar = manifest.spec.avatar;
|
|
1892
2367
|
return [avatar.definition, avatar.fallback].map(normalizeAvatarAssetPath).filter((path) => path !== void 0);
|
|
1893
2368
|
}
|
|
2369
|
+
function nativeAvatarDefinitionPath(manifest) {
|
|
2370
|
+
if (manifest.kind !== "Agent" || !isRecord3(manifest.spec) || !isRecord3(manifest.spec.avatar)) return void 0;
|
|
2371
|
+
const avatar = manifest.spec.avatar;
|
|
2372
|
+
return avatar.format === NATIVE_AVATAR_FORMAT ? normalizeAvatarAssetPath(avatar.definition) : void 0;
|
|
2373
|
+
}
|
|
1894
2374
|
function validateAgentAvatarPayloadFiles(manifest, payloadFiles) {
|
|
1895
2375
|
const included = new Set(payloadFiles.map((path) => path.replaceAll("\\", "/").replace(/^\.\//, "")));
|
|
1896
2376
|
return agentAvatarPayloadPaths(manifest).filter((path) => !included.has(path)).map((path) => `Avatar asset '${path}' is not included in the package payload; add it to packaging.files.`);
|
|
@@ -1919,16 +2399,25 @@ async function validateAgentAvatarPayload(projectDir, manifest) {
|
|
|
1919
2399
|
errors.push(`${at} must be a file.`);
|
|
1920
2400
|
continue;
|
|
1921
2401
|
}
|
|
1922
|
-
const
|
|
2402
|
+
const limit = asset.kind === "definition" ? AVATAR_DEFINITION_MAX_BYTES : AVATAR_FALLBACK_MAX_BYTES;
|
|
2403
|
+
const bytes = await buffer(createReadStream(absolute, { end: limit }));
|
|
2404
|
+
if (bytes.length > limit) {
|
|
2405
|
+
errors.push(`${at} exceeds ${limit / (1024 * 1024)} MiB.`);
|
|
2406
|
+
continue;
|
|
2407
|
+
}
|
|
1923
2408
|
if (asset.kind === "definition") {
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
2409
|
+
if (avatar.format === NATIVE_AVATAR_FORMAT) {
|
|
2410
|
+
try {
|
|
2411
|
+
H(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes));
|
|
2412
|
+
} catch {
|
|
2413
|
+
errors.push(`${at} is not a valid UTF-8 native runtime face.`);
|
|
2414
|
+
}
|
|
1926
2415
|
} else if (bytes.length < 22 || bytes[0] !== 80 || bytes[1] !== 75) {
|
|
1927
2416
|
errors.push(`${at} is not a dotLottie ZIP bundle.`);
|
|
1928
2417
|
}
|
|
1929
2418
|
} else {
|
|
1930
|
-
if (bytes.length === 0
|
|
1931
|
-
errors.push(`${at} must be non-empty
|
|
2419
|
+
if (bytes.length === 0) {
|
|
2420
|
+
errors.push(`${at} must be non-empty.`);
|
|
1932
2421
|
} else if (path.endsWith(".svg")) {
|
|
1933
2422
|
const text = decodeUtf8(bytes);
|
|
1934
2423
|
const reason = text === null ? "SVG must be UTF-8 text" : validateThemeSvg(text);
|
|
@@ -1964,9 +2453,34 @@ function validateAgentSpec(kind, spec) {
|
|
|
1964
2453
|
...fileAccessErrors(spec["file-access"]),
|
|
1965
2454
|
...uiErrors(spec.ui),
|
|
1966
2455
|
...modelErrors(spec.model),
|
|
1967
|
-
...capabilityErrors(spec.capabilities)
|
|
2456
|
+
...capabilityErrors(spec.capabilities),
|
|
2457
|
+
...chatErrors(spec.chat),
|
|
2458
|
+
...subagentErrors(spec.subagents)
|
|
1968
2459
|
];
|
|
1969
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
|
+
}
|
|
1970
2484
|
function stringListErrors(value, label, expected, unique = false) {
|
|
1971
2485
|
if (value === void 0) return [];
|
|
1972
2486
|
if (!Array.isArray(value)) return [`${label} must be ${expected}.`];
|
|
@@ -2120,6 +2634,7 @@ async function loadManifest(path) {
|
|
|
2120
2634
|
const text = await readFile(path, "utf8");
|
|
2121
2635
|
const manifest = parse(text);
|
|
2122
2636
|
if (!manifest || typeof manifest !== "object") throw new Error(`Failed to parse manifest at ${path}.`);
|
|
2637
|
+
checkAvatarPackYaml(manifest.kind, text);
|
|
2123
2638
|
if (!manifest.kind) throw new Error(`Manifest at ${path} is missing 'kind'.`);
|
|
2124
2639
|
const metadataErrors = validateDocumentMetadata(manifest.metadata);
|
|
2125
2640
|
if (metadataErrors.length > 0) throw new Error(`Invalid manifest at ${path}: ${metadataErrors.join("; ")}.`);
|
|
@@ -2140,9 +2655,9 @@ async function loadManifest(path) {
|
|
|
2140
2655
|
if (messageErrors.length > 0) {
|
|
2141
2656
|
throw new Error(`Invalid manifest at ${path}: ${messageErrors.join(" ")}`);
|
|
2142
2657
|
}
|
|
2143
|
-
const
|
|
2144
|
-
if (
|
|
2145
|
-
throw new Error(`Invalid manifest at ${path}: ${
|
|
2658
|
+
const chatErrors2 = validateChatSection(kind, manifest.spec);
|
|
2659
|
+
if (chatErrors2.length > 0) {
|
|
2660
|
+
throw new Error(`Invalid manifest at ${path}: ${chatErrors2.join(" ")}`);
|
|
2146
2661
|
}
|
|
2147
2662
|
const actorErrors = validateActorSection(kind, manifest.spec);
|
|
2148
2663
|
if (actorErrors.length > 0) {
|
|
@@ -2641,6 +3156,7 @@ async function readManifestDocument(path) {
|
|
|
2641
3156
|
const text = await readFile(path, "utf8");
|
|
2642
3157
|
const doc = parse(text);
|
|
2643
3158
|
if (!doc || typeof doc !== "object") throw new Error(`${path} is not a YAML manifest.`);
|
|
3159
|
+
checkAvatarPackYaml(doc.kind, text);
|
|
2644
3160
|
return doc;
|
|
2645
3161
|
}
|
|
2646
3162
|
function manifestPermissions(manifest) {
|
|
@@ -3315,17 +3831,17 @@ async function streamLogs(api, workspaceId, executionId) {
|
|
|
3315
3831
|
});
|
|
3316
3832
|
if (!res.body) return;
|
|
3317
3833
|
const decoder = new TextDecoder();
|
|
3318
|
-
let
|
|
3834
|
+
let buffer2 = "";
|
|
3319
3835
|
let currentEvent = "message";
|
|
3320
3836
|
const reader = res.body.getReader();
|
|
3321
3837
|
for (; ; ) {
|
|
3322
3838
|
const { done, value } = await reader.read();
|
|
3323
3839
|
if (done) break;
|
|
3324
|
-
|
|
3840
|
+
buffer2 += decoder.decode(value, { stream: true });
|
|
3325
3841
|
let newlineIdx;
|
|
3326
|
-
while ((newlineIdx =
|
|
3327
|
-
const line =
|
|
3328
|
-
|
|
3842
|
+
while ((newlineIdx = buffer2.indexOf("\n")) >= 0) {
|
|
3843
|
+
const line = buffer2.slice(0, newlineIdx).replace(/\r$/, "");
|
|
3844
|
+
buffer2 = buffer2.slice(newlineIdx + 1);
|
|
3329
3845
|
if (line.startsWith("event: ")) {
|
|
3330
3846
|
currentEvent = line.slice(7).trim();
|
|
3331
3847
|
} else if (line.startsWith("data: ")) {
|
|
@@ -3372,10 +3888,10 @@ var archiveImportPolling = {
|
|
|
3372
3888
|
};
|
|
3373
3889
|
var isZipName = (name) => name.toLowerCase().endsWith(".zip");
|
|
3374
3890
|
async function uploadWithHeaders(api, workspaceId, remotePath, localPath, options) {
|
|
3375
|
-
const
|
|
3891
|
+
const buffer2 = await readFile(localPath);
|
|
3376
3892
|
const contentType = options.contentType ?? (isZipName(localPath) ? "application/zip" : "application/octet-stream");
|
|
3377
3893
|
const form = new FormData();
|
|
3378
|
-
form.append("file", new Blob([
|
|
3894
|
+
form.append("file", new Blob([buffer2], { type: contentType }), basename(localPath));
|
|
3379
3895
|
form.append("metadata", JSON.stringify({ branch: options.branch, contentType: options.contentType }));
|
|
3380
3896
|
const headers = {};
|
|
3381
3897
|
if (options.autoExtract !== void 0) headers["X-Auto-Extract"] = String(options.autoExtract);
|
|
@@ -3395,19 +3911,19 @@ async function uploadWithHeaders(api, workspaceId, remotePath, localPath, option
|
|
|
3395
3911
|
}
|
|
3396
3912
|
return { status: res.status, location: res.headers?.get("Location") ?? void 0, body };
|
|
3397
3913
|
}
|
|
3398
|
-
function zipHasRootManifest(
|
|
3914
|
+
function zipHasRootManifest(buffer2) {
|
|
3399
3915
|
const EOCD = 101010256;
|
|
3400
3916
|
const CDH = 33639248;
|
|
3401
|
-
const minStart = Math.max(0,
|
|
3402
|
-
for (let i =
|
|
3403
|
-
if (
|
|
3404
|
-
let offset =
|
|
3405
|
-
if (offset === 4294967295 || offset >=
|
|
3406
|
-
while (offset + 46 <=
|
|
3407
|
-
const nameLength =
|
|
3408
|
-
const extraLength =
|
|
3409
|
-
const commentLength =
|
|
3410
|
-
const name =
|
|
3917
|
+
const minStart = Math.max(0, buffer2.length - 22 - 65535);
|
|
3918
|
+
for (let i = buffer2.length - 22; i >= minStart; i--) {
|
|
3919
|
+
if (buffer2.readUInt32LE(i) !== EOCD) continue;
|
|
3920
|
+
let offset = buffer2.readUInt32LE(i + 16);
|
|
3921
|
+
if (offset === 4294967295 || offset >= buffer2.length) return void 0;
|
|
3922
|
+
while (offset + 46 <= buffer2.length && buffer2.readUInt32LE(offset) === CDH) {
|
|
3923
|
+
const nameLength = buffer2.readUInt16LE(offset + 28);
|
|
3924
|
+
const extraLength = buffer2.readUInt16LE(offset + 30);
|
|
3925
|
+
const commentLength = buffer2.readUInt16LE(offset + 32);
|
|
3926
|
+
const name = buffer2.subarray(offset + 46, offset + 46 + nameLength).toString("utf8");
|
|
3411
3927
|
if (name === ".verentis-manifest.json" || name === "./.verentis-manifest.json") return true;
|
|
3412
3928
|
offset += 46 + nameLength + extraLength + commentLength;
|
|
3413
3929
|
}
|
|
@@ -3754,7 +4270,7 @@ async function migrateManifestIcons(manifestPath, options = {}) {
|
|
|
3754
4270
|
result.written.push(file);
|
|
3755
4271
|
}
|
|
3756
4272
|
let updated = text;
|
|
3757
|
-
for (const splice of splices.sort((a,
|
|
4273
|
+
for (const splice of splices.sort((a, b2) => b2.start - a.start)) {
|
|
3758
4274
|
updated = updated.slice(0, splice.start) + splice.replacement + updated.slice(splice.end);
|
|
3759
4275
|
}
|
|
3760
4276
|
await writeFile(manifestPath, updated);
|
|
@@ -3988,6 +4504,16 @@ var THEME_CSS = `/*
|
|
|
3988
4504
|
--brand-border: oklch(0.951 0.017 84.6 / 24%);
|
|
3989
4505
|
}
|
|
3990
4506
|
`;
|
|
4507
|
+
var sample = new URL("../samples/avatar-pack/", import.meta.url);
|
|
4508
|
+
function avatarPackStarterManifest(id) {
|
|
4509
|
+
const manifest = parse(readFileSync(new URL("manifest.yaml", sample), "utf8"));
|
|
4510
|
+
manifest.metadata.id = id;
|
|
4511
|
+
manifest.packaging.publisher = "your-publisher";
|
|
4512
|
+
return stringify(manifest);
|
|
4513
|
+
}
|
|
4514
|
+
function avatarPackStarterFiles() {
|
|
4515
|
+
return { "clay.vavatar": readFileSync(new URL("clay.vavatar", sample), "utf8") };
|
|
4516
|
+
}
|
|
3991
4517
|
|
|
3992
4518
|
// src/commands/init.ts
|
|
3993
4519
|
var APP_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
@@ -4031,9 +4557,11 @@ var TEMPLATE_BY_TYPE = {
|
|
|
4031
4557
|
Application: "application",
|
|
4032
4558
|
ExecutionEngine: "engine",
|
|
4033
4559
|
Bundle: "bundle",
|
|
4034
|
-
Theme: "theme"
|
|
4560
|
+
Theme: "theme",
|
|
4561
|
+
AvatarPack: "avatar-pack"
|
|
4035
4562
|
};
|
|
4036
4563
|
var TEMPLATES = {
|
|
4564
|
+
"avatar-pack": avatarPackStarterManifest,
|
|
4037
4565
|
application: (name) => `api-version: verentis.io/v1
|
|
4038
4566
|
kind: Application
|
|
4039
4567
|
|
|
@@ -4204,7 +4732,7 @@ function resolveInitTemplate(type) {
|
|
|
4204
4732
|
return key;
|
|
4205
4733
|
}
|
|
4206
4734
|
function registerInit(program2) {
|
|
4207
|
-
program2.command("init [dir]").description("Scaffold a manifest.yaml for a new package").option("--type <type>", "package type: application | engine | bundle | theme").option("--kind <kind>", "alias for --type").option("--id <id>", "package ID (defaults to the directory name)").action(async (dir, options) => {
|
|
4735
|
+
program2.command("init [dir]").description("Scaffold a manifest.yaml for a new package").option("--type <type>", "package type: application | engine | bundle | theme | avatar-pack").option("--kind <kind>", "alias for --type").option("--id <id>", "package ID (defaults to the directory name)").action(async (dir, options) => {
|
|
4208
4736
|
const templateKey = resolveInitTemplate(options.type ?? options.kind ?? "application");
|
|
4209
4737
|
const template = TEMPLATES[templateKey];
|
|
4210
4738
|
const targetDir = resolve(dir ?? ".");
|
|
@@ -4214,14 +4742,15 @@ function registerInit(program2) {
|
|
|
4214
4742
|
if (await exists3(manifestPath)) throw new Error(`${manifestPath} already exists.`);
|
|
4215
4743
|
await writeFile(manifestPath, template(name));
|
|
4216
4744
|
console.log(`Created ${manifestPath} (type: ${templateKey}).`);
|
|
4217
|
-
|
|
4745
|
+
const files2 = templateKey === "avatar-pack" ? avatarPackStarterFiles() : TEMPLATE_FILES[templateKey] ?? {};
|
|
4746
|
+
for (const [relativePath, content] of Object.entries(files2)) {
|
|
4218
4747
|
const path = join(targetDir, relativePath);
|
|
4219
4748
|
if (await exists3(path)) continue;
|
|
4220
4749
|
await mkdir(dirname(path), { recursive: true });
|
|
4221
4750
|
await writeFile(path, content);
|
|
4222
4751
|
console.log(`Created ${path}.`);
|
|
4223
4752
|
}
|
|
4224
|
-
console.log(templateKey === "theme" ? "Fill in packaging.publisher, replace the placeholder artwork in theme/, then run `verentis pack`." : "Fill in packaging.publisher and packaging.files, then run `verentis pack`.");
|
|
4753
|
+
console.log(templateKey === "avatar-pack" ? "Set packaging.publisher to your registered publisher, then validate and sign with `verentis pack`." : templateKey === "theme" ? "Fill in packaging.publisher, replace the placeholder artwork in theme/, then run `verentis pack`." : "Fill in packaging.publisher and packaging.files, then run `verentis pack`.");
|
|
4225
4754
|
});
|
|
4226
4755
|
}
|
|
4227
4756
|
async function exists3(path) {
|
|
@@ -4233,7 +4762,7 @@ async function exists3(path) {
|
|
|
4233
4762
|
}
|
|
4234
4763
|
}
|
|
4235
4764
|
function titleCase(value) {
|
|
4236
|
-
return value.replace(/(^|[-_])(\w)/g, (
|
|
4765
|
+
return value.replace(/(^|[-_])(\w)/g, (_2, __, c) => ` ${c.toUpperCase()}`).trim();
|
|
4237
4766
|
}
|
|
4238
4767
|
function computeKid(publicKeyBase64) {
|
|
4239
4768
|
return createHash("sha256").update(Buffer.from(publicKeyBase64, "base64")).digest("hex").slice(0, 16);
|
|
@@ -4329,9 +4858,9 @@ async function findRegistryVersion(api, publisher, packageId, version) {
|
|
|
4329
4858
|
throw error;
|
|
4330
4859
|
}
|
|
4331
4860
|
}
|
|
4332
|
-
function sameTreeDigest(a,
|
|
4861
|
+
function sameTreeDigest(a, b2) {
|
|
4333
4862
|
const normalize = (value) => (value ?? "").trim().toLowerCase().replace(/^sha256:/, "");
|
|
4334
|
-
return normalize(a) !== "" && normalize(a) === normalize(
|
|
4863
|
+
return normalize(a) !== "" && normalize(a) === normalize(b2);
|
|
4335
4864
|
}
|
|
4336
4865
|
async function uploadRegistryVersion(api, publisher, packageId, vpkgPath, options = {}) {
|
|
4337
4866
|
const stream = Readable.toWeb(createReadStream(vpkgPath));
|
|
@@ -4751,7 +5280,7 @@ function parseOverlayParams(pairs = []) {
|
|
|
4751
5280
|
}
|
|
4752
5281
|
function interpolateOverlay(overlay, params, source) {
|
|
4753
5282
|
const missing = /* @__PURE__ */ new Set();
|
|
4754
|
-
const
|
|
5283
|
+
const visit2 = (value) => {
|
|
4755
5284
|
if (typeof value === "string") {
|
|
4756
5285
|
return value.replace(PARAM_PLACEHOLDER_PATTERN, (raw, escape, name) => {
|
|
4757
5286
|
if (escape) return raw.slice(1);
|
|
@@ -4760,11 +5289,11 @@ function interpolateOverlay(overlay, params, source) {
|
|
|
4760
5289
|
return raw;
|
|
4761
5290
|
});
|
|
4762
5291
|
}
|
|
4763
|
-
if (Array.isArray(value)) return value.map(
|
|
4764
|
-
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key,
|
|
5292
|
+
if (Array.isArray(value)) return value.map(visit2);
|
|
5293
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit2(item)]));
|
|
4765
5294
|
return value;
|
|
4766
5295
|
};
|
|
4767
|
-
const result =
|
|
5296
|
+
const result = visit2(overlay);
|
|
4768
5297
|
if (missing.size > 0) {
|
|
4769
5298
|
const names = [...missing].sort();
|
|
4770
5299
|
throw new Error(`Overlay ${source} needs ${names.map((name) => `--param ${name}=<value>`).join(", ")}.`);
|
|
@@ -5033,7 +5562,12 @@ async function inspectPackagingTemplates(projectDir, manifest, payloadFiles) {
|
|
|
5033
5562
|
const issues = [];
|
|
5034
5563
|
const variables = readTemplateVariables(manifest, issues);
|
|
5035
5564
|
const templateFiles = await resolveTemplateFiles(projectDir, manifest, payloadFiles, issues);
|
|
5565
|
+
const nativeDefinition = nativeAvatarDefinitionPath(manifest);
|
|
5036
5566
|
for (const file of payloadFiles) {
|
|
5567
|
+
if (nativeDefinition === toEntryPath2(file) && templateFiles.has(file)) {
|
|
5568
|
+
issues.push({ level: "error", message: `Validated native avatar '${nativeDefinition}' must not be a packaging template.` });
|
|
5569
|
+
continue;
|
|
5570
|
+
}
|
|
5037
5571
|
const sourcePath = join(projectDir, file);
|
|
5038
5572
|
const bytes = await readFile(sourcePath);
|
|
5039
5573
|
if (templateFiles.has(file)) {
|
|
@@ -5197,6 +5731,123 @@ function findPlaceholders(text) {
|
|
|
5197
5731
|
}
|
|
5198
5732
|
return placeholders;
|
|
5199
5733
|
}
|
|
5734
|
+
var AGENT_FILE = /\.agent\.ya?ml$/i;
|
|
5735
|
+
var isRecord5 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
5736
|
+
async function validateAgentSuite(projectDir, manifestPath, manifest, payloadFiles) {
|
|
5737
|
+
const errors = [];
|
|
5738
|
+
const warnings = [];
|
|
5739
|
+
const agents = [];
|
|
5740
|
+
const spec = isRecord5(manifest.spec) ? manifest.spec : {};
|
|
5741
|
+
const recordFile = toPosix(relative(projectDir, manifestPath));
|
|
5742
|
+
if (manifest.kind === "Agent") agents.push(agentOf(recordFile, "the package agent", manifest.metadata?.id, spec));
|
|
5743
|
+
for (const file of payloadFiles.map(toPosix).filter((file2) => AGENT_FILE.test(file2)).sort()) {
|
|
5744
|
+
let document;
|
|
5745
|
+
try {
|
|
5746
|
+
document = parse(await readFile(join(projectDir, file), "utf8"));
|
|
5747
|
+
} catch (error) {
|
|
5748
|
+
errors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
5749
|
+
continue;
|
|
5750
|
+
}
|
|
5751
|
+
if (!isRecord5(document) || document.kind !== "Agent") {
|
|
5752
|
+
errors.push(`${file}: an *.agent.yaml file must be an Agent manifest (kind: Agent).`);
|
|
5753
|
+
continue;
|
|
5754
|
+
}
|
|
5755
|
+
const metadata = isRecord5(document.metadata) ? document.metadata : {};
|
|
5756
|
+
const agentSpec = isRecord5(document.spec) ? document.spec : {};
|
|
5757
|
+
if (typeof metadata.id !== "string" || !metadata.id.trim()) errors.push(`${file}: metadata.id is required.`);
|
|
5758
|
+
errors.push(...validateAgentSpec("Agent", agentSpec).map((message) => `${file}: ${message}`));
|
|
5759
|
+
agents.push(agentOf(file, file, metadata.id, agentSpec));
|
|
5760
|
+
}
|
|
5761
|
+
if (agents.length === 0) return { errors, warnings };
|
|
5762
|
+
const ids = /* @__PURE__ */ new Map();
|
|
5763
|
+
for (const agent of agents) {
|
|
5764
|
+
if (!agent.id) continue;
|
|
5765
|
+
const other = ids.get(agent.id);
|
|
5766
|
+
if (other) errors.push(`${agent.label}: metadata.id '${agent.id}' is also used by ${other}; agents of one package need unique ids.`);
|
|
5767
|
+
else ids.set(agent.id, agent.label);
|
|
5768
|
+
}
|
|
5769
|
+
const files2 = new Set(agents.map((agent) => agent.file));
|
|
5770
|
+
const dependencies = dependencyPackages(spec);
|
|
5771
|
+
const own = typeof manifest.packaging?.publisher === "string" && typeof manifest.metadata?.id === "string" ? `${manifest.packaging.publisher}/${manifest.metadata.id}` : void 0;
|
|
5772
|
+
for (const agent of agents) {
|
|
5773
|
+
const subagents = isRecord5(agent.spec.subagents) ? agent.spec.subagents : void 0;
|
|
5774
|
+
const references = Array.isArray(subagents?.agents) ? subagents.agents.filter((r) => typeof r === "string") : [];
|
|
5775
|
+
for (const reference of references.map((r) => r.trim())) {
|
|
5776
|
+
const problem = referenceProblem(agent.file, reference, files2, dependencies, own);
|
|
5777
|
+
if (problem?.error) errors.push(`${agent.label}: spec.subagents.agents '${reference}' ${problem.error}`);
|
|
5778
|
+
else if (problem?.warning) warnings.push(`${agent.label}: spec.subagents.agents '${reference}' ${problem.warning}`);
|
|
5779
|
+
}
|
|
5780
|
+
}
|
|
5781
|
+
const contacts = agents.filter((agent) => agent.contact);
|
|
5782
|
+
if (agents.length > 1 && contacts.length > 1) {
|
|
5783
|
+
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.`);
|
|
5784
|
+
}
|
|
5785
|
+
const orchestrators = agents.filter((agent) => isRecord5(agent.spec.subagents));
|
|
5786
|
+
if (agents.length > 1 && contacts.length === 0 && orchestrators.length > 0) {
|
|
5787
|
+
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.`);
|
|
5788
|
+
}
|
|
5789
|
+
if (manifest.kind !== "Agent") warnings.push(...bundledConsentWarnings(agents, spec));
|
|
5790
|
+
return { errors, warnings };
|
|
5791
|
+
}
|
|
5792
|
+
function agentOf(file, label, id, spec) {
|
|
5793
|
+
const chat = isRecord5(spec.chat) ? spec.chat : void 0;
|
|
5794
|
+
return { file, label, id: typeof id === "string" && id.trim() ? id : void 0, contact: chat?.contact !== false, spec };
|
|
5795
|
+
}
|
|
5796
|
+
function referenceProblem(from, reference, files2, dependencies, own) {
|
|
5797
|
+
if (reference === "self") return void 0;
|
|
5798
|
+
if (reference.startsWith("@")) {
|
|
5799
|
+
const body = reference.slice(1).split("@")[0];
|
|
5800
|
+
const parts = body.split("/").filter(Boolean);
|
|
5801
|
+
if (parts.length < 2 || parts.some((p) => p === "." || p === "..")) return { error: "is not a package reference (@publisher/package[/path])." };
|
|
5802
|
+
const pkg = `${parts[0]}/${parts[1]}`;
|
|
5803
|
+
if (pkg === own) {
|
|
5804
|
+
const item = parts.slice(2).join("/");
|
|
5805
|
+
return item && !files2.has(item) ? { error: `names ${item}, which is not an agent manifest in this package.` } : void 0;
|
|
5806
|
+
}
|
|
5807
|
+
return dependencies.has(pkg) ? void 0 : { warning: `names ${pkg}, which spec.dependencies doesn't declare; it resolves only where that package is already installed.` };
|
|
5808
|
+
}
|
|
5809
|
+
if (reference === "." || reference === ".." || reference.startsWith("./") || reference.startsWith("../")) {
|
|
5810
|
+
const target = posix.normalize(posix.join(posix.dirname(from || "."), reference));
|
|
5811
|
+
if (target.startsWith("../") || target === "..") return { error: "points outside the package." };
|
|
5812
|
+
return files2.has(target) ? void 0 : { error: `resolves to ${target}, which is not an agent manifest in this package.` };
|
|
5813
|
+
}
|
|
5814
|
+
return { warning: "is an absolute workspace path; use ./relative or @publisher/package so it moves with the package." };
|
|
5815
|
+
}
|
|
5816
|
+
function dependencyPackages(spec) {
|
|
5817
|
+
const packages = /* @__PURE__ */ new Set();
|
|
5818
|
+
for (const dependency of Array.isArray(spec.dependencies) ? spec.dependencies : []) {
|
|
5819
|
+
const value = typeof dependency === "string" ? dependency : isRecord5(dependency) ? dependency.package : void 0;
|
|
5820
|
+
if (typeof value === "string") packages.add(value.split("@")[0]);
|
|
5821
|
+
}
|
|
5822
|
+
return packages;
|
|
5823
|
+
}
|
|
5824
|
+
function bundledConsentWarnings(agents, spec) {
|
|
5825
|
+
const warnings = [];
|
|
5826
|
+
const scopes = new Set(Array.isArray(spec.permissions) ? spec.permissions.filter((p) => typeof p === "string") : []);
|
|
5827
|
+
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 }));
|
|
5828
|
+
for (const agent of agents) {
|
|
5829
|
+
const permissions = Array.isArray(agent.spec.permissions) ? agent.spec.permissions.filter((p) => typeof p === "string") : [];
|
|
5830
|
+
const missing = permissions.filter((p) => !scopes.has(p));
|
|
5831
|
+
if (missing.length > 0) {
|
|
5832
|
+
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.`);
|
|
5833
|
+
}
|
|
5834
|
+
for (const entry of (Array.isArray(agent.spec["file-access"]) ? agent.spec["file-access"] : []).filter(isRecord5)) {
|
|
5835
|
+
if (typeof entry.path !== "string") continue;
|
|
5836
|
+
if (!entry.path.startsWith("/")) {
|
|
5837
|
+
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.`);
|
|
5838
|
+
continue;
|
|
5839
|
+
}
|
|
5840
|
+
const path = trimSlash(entry.path);
|
|
5841
|
+
const covered = grants.some((g2) => (path === g2.path || path.startsWith(`${g2.path}/`) || g2.path === "") && (g2.mode === "write" || entry.mode !== "write"));
|
|
5842
|
+
if (!covered) {
|
|
5843
|
+
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.`);
|
|
5844
|
+
}
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
return warnings;
|
|
5848
|
+
}
|
|
5849
|
+
var trimSlash = (path) => path.replace(/\/+$/, "");
|
|
5850
|
+
var toPosix = (path) => path.split("\\").join("/");
|
|
5200
5851
|
var ARGUMENTS_SCHEMA = "verentis.io/script-arguments/v1";
|
|
5201
5852
|
var ARGUMENTS_SUFFIX = ".arguments.json";
|
|
5202
5853
|
var KINDS = /* @__PURE__ */ new Set(["option", "positional"]);
|
|
@@ -5410,7 +6061,7 @@ function validateRunSize(resources) {
|
|
|
5410
6061
|
return RUN_SIZES.includes(size.trim().toLowerCase()) ? void 0 : `resources.size '${size.trim()}' is not one of ${RUN_SIZES.join(", ")}.`;
|
|
5411
6062
|
}
|
|
5412
6063
|
async function findScriptRun(directory) {
|
|
5413
|
-
const names = (await readdir(directory)).filter((name) => /\.ya?ml$/i.test(name)).sort((a,
|
|
6064
|
+
const names = (await readdir(directory)).filter((name) => /\.ya?ml$/i.test(name)).sort((a, b2) => rank(a) - rank(b2) || a.localeCompare(b2));
|
|
5414
6065
|
for (const name of names) {
|
|
5415
6066
|
try {
|
|
5416
6067
|
const document = parse(await readFile(join(directory, name), "utf8"));
|
|
@@ -5457,8 +6108,13 @@ async function pack(options) {
|
|
|
5457
6108
|
overrideApplied = true;
|
|
5458
6109
|
}
|
|
5459
6110
|
const kind = normalizeKind(manifest.kind);
|
|
5460
|
-
|
|
5461
|
-
|
|
6111
|
+
if (kind === "AvatarPack") {
|
|
6112
|
+
if (!options.signingKey || options.encryptFor?.length) throw new Error("AvatarPack requires signing and cannot be encrypted.");
|
|
6113
|
+
if (options.publisher.toLowerCase() !== manifest.packaging?.publisher)
|
|
6114
|
+
throw new Error("AvatarPack publisher must match the signed packaging.publisher.");
|
|
6115
|
+
}
|
|
6116
|
+
const manifestErrors2 = validatePackageManifestRules(kind, manifest);
|
|
6117
|
+
if (manifestErrors2.length > 0) throw new Error(`Invalid manifest: ${manifestErrors2.join(" ")}`);
|
|
5462
6118
|
const dependencyErrors = validateDependencies(manifest.spec);
|
|
5463
6119
|
if (dependencyErrors.length > 0) throw new Error(`Invalid dependencies: ${dependencyErrors.join(" ")}`);
|
|
5464
6120
|
const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
|
|
@@ -5493,6 +6149,9 @@ async function pack(options) {
|
|
|
5493
6149
|
const avatarInclusionErrors = validateAgentAvatarPayloadFiles(manifest, payloadFiles);
|
|
5494
6150
|
if (avatarInclusionErrors.length > 0) throw new Error(`Invalid ${kind} payload:
|
|
5495
6151
|
${avatarInclusionErrors.join("\n ")}`);
|
|
6152
|
+
const suite = await validateAgentSuite(projectDir, manifestPath, manifest, payloadFiles);
|
|
6153
|
+
if (suite.errors.length > 0) throw new Error(`Invalid agents in ${kind} package:
|
|
6154
|
+
${suite.errors.join("\n ")}`);
|
|
5496
6155
|
const missingSources = expandedInstall.filter((from) => !payloadFiles.some((file) => toEntryPath2(file) === from));
|
|
5497
6156
|
if (missingSources.length > 0) {
|
|
5498
6157
|
throw new Error(`packaging.files does not include ${missingSources.join(", ")} declared by spec.assets.`);
|
|
@@ -5520,6 +6179,7 @@ async function pack(options) {
|
|
|
5520
6179
|
inlineIconsIntoDocument(document, icons);
|
|
5521
6180
|
manifestText = document.toString();
|
|
5522
6181
|
}
|
|
6182
|
+
checkAvatarPackYaml(kind, manifestText);
|
|
5523
6183
|
await writeFile(join(staging, "manifest.yaml"), manifestText);
|
|
5524
6184
|
const encrypt = (options.encryptFor?.length ?? 0) > 0;
|
|
5525
6185
|
const contentKey = encrypt ? generateContentKey() : null;
|
|
@@ -5604,7 +6264,7 @@ async function pack(options) {
|
|
|
5604
6264
|
treeDigest: sha256Hex(Buffer.from(digestsJson, "utf8")),
|
|
5605
6265
|
signed,
|
|
5606
6266
|
encrypted: encrypt,
|
|
5607
|
-
warnings: icons.warnings
|
|
6267
|
+
warnings: [...icons.warnings, ...suite.warnings]
|
|
5608
6268
|
};
|
|
5609
6269
|
} finally {
|
|
5610
6270
|
await rm(staging, { recursive: true, force: true });
|
|
@@ -5838,7 +6498,7 @@ function registerPackage(program2) {
|
|
|
5838
6498
|
pkgCmd.command("versions <ref>").description("List every version of a package in the registry, including pending, rejected and yanked ones").option("--json", "output JSON").action(async (ref, options) => {
|
|
5839
6499
|
const api = await createApiClient();
|
|
5840
6500
|
const pkg = await getRegistryPackage(api, await resolveRegistryPackageRef(api, ref));
|
|
5841
|
-
output(pkg.versions.map((
|
|
6501
|
+
output(pkg.versions.map((v2) => ({ ...v2 })), { version: "Version", status: "Status", deprecated: "Deprecated", publishedAt: "Published", yankedAt: "Yanked", sizeBytes: "Size", id: "Id" }, options);
|
|
5842
6502
|
});
|
|
5843
6503
|
pkgCmd.command("update <ref>").description("(removed) Package metadata comes from the signed manifest \u2014 edit it, `verentis pack`, then `verentis publish`").allowUnknownOption().action(() => {
|
|
5844
6504
|
throw new Error(
|
|
@@ -6141,9 +6801,9 @@ async function uploadPublisherLogo(api, publisherId, path) {
|
|
|
6141
6801
|
function isNewerVersion(candidate, base) {
|
|
6142
6802
|
return compareVersions(candidate, base) > 0;
|
|
6143
6803
|
}
|
|
6144
|
-
function compareVersions(a,
|
|
6145
|
-
const pa =
|
|
6146
|
-
const pb =
|
|
6804
|
+
function compareVersions(a, b2) {
|
|
6805
|
+
const pa = parse9(a);
|
|
6806
|
+
const pb = parse9(b2);
|
|
6147
6807
|
for (let i = 0; i < 3; i++) {
|
|
6148
6808
|
if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
|
|
6149
6809
|
}
|
|
@@ -6154,23 +6814,23 @@ function compareVersions(a, b) {
|
|
|
6154
6814
|
for (let i = 0; i < len; i++) {
|
|
6155
6815
|
if (i >= pa.pre.length) return -1;
|
|
6156
6816
|
if (i >= pb.pre.length) return 1;
|
|
6157
|
-
const
|
|
6817
|
+
const x2 = pa.pre[i];
|
|
6158
6818
|
const y = pb.pre[i];
|
|
6159
|
-
const xNum = /^\d+$/.test(
|
|
6819
|
+
const xNum = /^\d+$/.test(x2);
|
|
6160
6820
|
const yNum = /^\d+$/.test(y);
|
|
6161
6821
|
if (xNum && yNum) {
|
|
6162
|
-
const nx = Number(
|
|
6822
|
+
const nx = Number(x2);
|
|
6163
6823
|
const ny = Number(y);
|
|
6164
6824
|
if (nx !== ny) return nx < ny ? -1 : 1;
|
|
6165
6825
|
} else if (xNum !== yNum) {
|
|
6166
6826
|
return xNum ? -1 : 1;
|
|
6167
|
-
} else if (
|
|
6168
|
-
return
|
|
6827
|
+
} else if (x2 !== y) {
|
|
6828
|
+
return x2 < y ? -1 : 1;
|
|
6169
6829
|
}
|
|
6170
6830
|
}
|
|
6171
6831
|
return 0;
|
|
6172
6832
|
}
|
|
6173
|
-
function
|
|
6833
|
+
function parse9(version) {
|
|
6174
6834
|
const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
|
|
6175
6835
|
const dash = cleaned.indexOf("-");
|
|
6176
6836
|
const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
|
|
@@ -6181,15 +6841,48 @@ function parse7(version) {
|
|
|
6181
6841
|
|
|
6182
6842
|
// src/commands/installation-graph.ts
|
|
6183
6843
|
async function installGraph(api, workspaceId, packageId, options) {
|
|
6844
|
+
const personal = options.target === "personal";
|
|
6845
|
+
const requirePersonal = async (plan) => {
|
|
6846
|
+
const owner = plan.ownerId;
|
|
6847
|
+
if (plan.targetScope !== "personal" || plan.workspaceId !== workspaceId || !owner || !/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(owner) || !Array.isArray(plan.packages) || plan.packages.at(-1)?.packageId !== packageId || options.operation && options.operation !== plan.operationId || !plan.packages.every((n) => {
|
|
6848
|
+
if (n.ownerId !== owner || n.personalWorkspaceId !== workspaceId || n.branch !== "main" || typeof n.installPath !== "string") return false;
|
|
6849
|
+
const prefix = `home/${owner}/applications/`;
|
|
6850
|
+
const privatePath = (value) => {
|
|
6851
|
+
if (typeof value !== "string") return false;
|
|
6852
|
+
const path = value.replace(/^\//, "");
|
|
6853
|
+
return path.startsWith(prefix) && path.slice(prefix.length).split("/").every(
|
|
6854
|
+
(segment) => /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(segment)
|
|
6855
|
+
);
|
|
6856
|
+
};
|
|
6857
|
+
return !n.replaces && privatePath(n.installPath) && Array.isArray(n.installPaths) && n.installPaths.length > 0 && n.installPaths.every(privatePath);
|
|
6858
|
+
})) {
|
|
6859
|
+
throw new Error("The server did not return a personal plan; refusing to approve a workspace installation.");
|
|
6860
|
+
}
|
|
6861
|
+
const token = await api.mintAccessToken({ scopes: [SCOPES.installRead], workspaceId });
|
|
6862
|
+
const claims = decodeJwtPayload(token);
|
|
6863
|
+
if (claims?.sub !== owner || claims["https://verentis.io/claims/workspace_id"] !== workspaceId) {
|
|
6864
|
+
throw new Error("The personal plan does not belong to the signed-in member of the selected workspace.");
|
|
6865
|
+
}
|
|
6866
|
+
};
|
|
6184
6867
|
if (options.operation || options.consent) {
|
|
6185
6868
|
if (!options.operation || !options.consent) throw new Error("--operation and --consent must be supplied together.");
|
|
6869
|
+
if (personal) {
|
|
6870
|
+
const plan = await api.request("GET", `/v1/installations/graphs/${encodeURIComponent(options.operation)}`, {
|
|
6871
|
+
scopes: [SCOPES.installRead],
|
|
6872
|
+
tokenWorkspaceId: workspaceId,
|
|
6873
|
+
query: { workspaceId }
|
|
6874
|
+
});
|
|
6875
|
+
await requirePersonal(plan);
|
|
6876
|
+
}
|
|
6186
6877
|
const result = await api.request("POST", "/v1/installations/graphs", {
|
|
6187
|
-
scopes: [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete, SCOPES.installationRead, SCOPES.resourceReadAll],
|
|
6878
|
+
scopes: personal ? [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete] : [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete, SCOPES.installationRead, SCOPES.resourceReadAll],
|
|
6188
6879
|
tokenWorkspaceId: workspaceId,
|
|
6189
6880
|
body: { workspaceId, operationId: options.operation, fingerprint: options.consent, consent: true }
|
|
6190
6881
|
});
|
|
6191
6882
|
console.log(JSON.stringify(result, null, 2));
|
|
6192
|
-
if (result.succeeded !== true
|
|
6883
|
+
if (result.succeeded !== true && !["Queued", "Running", "RollingBack"].includes(result.status ?? "")) {
|
|
6884
|
+
throw new Error(`Graph installation failed. Inspect operation ${options.operation}; do not resubmit it.`);
|
|
6885
|
+
}
|
|
6193
6886
|
return;
|
|
6194
6887
|
}
|
|
6195
6888
|
const preview = await api.request("POST", "/v1/installations/graphs/preview", {
|
|
@@ -6199,13 +6892,15 @@ async function installGraph(api, workspaceId, packageId, options) {
|
|
|
6199
6892
|
workspaceId,
|
|
6200
6893
|
packageId,
|
|
6201
6894
|
packageVersion: options.version,
|
|
6895
|
+
...personal ? { targetScope: "personal" } : {},
|
|
6202
6896
|
installPath: options.path,
|
|
6203
6897
|
branch: options.branch,
|
|
6204
6898
|
installMode: options.sealed ? "Sealed" : void 0
|
|
6205
6899
|
}
|
|
6206
6900
|
});
|
|
6901
|
+
if (personal) await requirePersonal(preview);
|
|
6207
6902
|
console.log(JSON.stringify(preview, null, 2));
|
|
6208
|
-
console.log(`No packages installed. Review every package and its permissions, then repeat with --operation ${preview.operationId} --consent ${preview.fingerprint}.`);
|
|
6903
|
+
console.log(`No packages installed. Review every package and its permissions, then repeat with ${personal ? "--target personal " : ""}--operation ${preview.operationId} --consent ${preview.fingerprint}.`);
|
|
6209
6904
|
}
|
|
6210
6905
|
|
|
6211
6906
|
// src/commands/registry.ts
|
|
@@ -6370,13 +7065,14 @@ function registerRegistry(program2) {
|
|
|
6370
7065
|
console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
|
|
6371
7066
|
}
|
|
6372
7067
|
});
|
|
6373
|
-
program2.command("install <ref> [version]").description("Preview a required dependency graph; install only with explicit consent to that exact preview").option("--workspace <workspaceId>", "target workspace (default: configured default workspace)").option("--path <path>", "install path override (bundles)").option("--branch <branch>", "workspace branch", "main").option("--sealed", "install as a sealed tarball instead of extracting").option("--operation <id>", "previously displayed graph operation ID").option("--consent <fingerprint>", "explicitly approve the exact displayed graph fingerprint (single-use)").option("--preview", "preview even a package without dependencies instead of using its legacy install/reinstall behavior").action(async (ref, version, options) => {
|
|
7068
|
+
program2.command("install <ref> [version]").description("Preview a required dependency graph; install only with explicit consent to that exact preview").option("--workspace <workspaceId>", "target workspace (default: configured default workspace)").option("--path <path>", "install path override (bundles)").option("--target <scope>", "installation owner: workspace (default) or personal; personal always previews before approval").option("--branch <branch>", "workspace branch", "main").option("--sealed", "install as a sealed tarball instead of extracting").option("--operation <id>", "previously displayed graph operation ID").option("--consent <fingerprint>", "explicitly approve the exact displayed graph fingerprint (single-use)").option("--preview", "preview even a package without dependencies instead of using its legacy install/reinstall behavior").action(async (ref, version, options) => {
|
|
7069
|
+
if (options.target !== void 0 && !["personal", "workspace"].includes(options.target)) throw new Error("--target must be personal or workspace.");
|
|
6374
7070
|
const config = await loadConfig();
|
|
6375
7071
|
const workspaceId = options.workspace ?? config.defaultWorkspaceId;
|
|
6376
7072
|
if (!workspaceId) throw new Error("No workspace: pass --workspace <id> or set defaultWorkspaceId in ~/.verentis/config.json.");
|
|
6377
7073
|
const api = await createApiClient();
|
|
6378
7074
|
const { package: pkg } = await resolvePackageRef(api, ref);
|
|
6379
|
-
if (options.operation || options.consent || options.preview) {
|
|
7075
|
+
if (options.target === "personal" || options.operation || options.consent || options.preview) {
|
|
6380
7076
|
await installGraph(api, workspaceId, pkg.id, { ...options, version });
|
|
6381
7077
|
return;
|
|
6382
7078
|
}
|
|
@@ -6458,6 +7154,11 @@ function registerRegistry(program2) {
|
|
|
6458
7154
|
});
|
|
6459
7155
|
console.log(JSON.stringify(result, null, 2));
|
|
6460
7156
|
});
|
|
7157
|
+
program2.command("install-targets").description("Show server-supported personal package types and workspace-only reasons (version policy is checked on preview)").action(async () => {
|
|
7158
|
+
const api = await createApiClient();
|
|
7159
|
+
const matrix = await api.request("GET", "/v1/package-types/installation-targets", { scopes: [] });
|
|
7160
|
+
console.log(JSON.stringify(matrix, null, 2));
|
|
7161
|
+
});
|
|
6461
7162
|
program2.command("uninstall <installationId>").description("Uninstall a package from a workspace").requiredOption("--workspace <workspaceId>", "the workspace the installation belongs to").action(async (installationId, options) => {
|
|
6462
7163
|
const api = await createApiClient();
|
|
6463
7164
|
await call(api, marketplace.uninstall, {
|
|
@@ -6529,11 +7230,11 @@ function getCliVersion() {
|
|
|
6529
7230
|
}
|
|
6530
7231
|
function readVersion() {
|
|
6531
7232
|
const candidates = ["../package.json", "../../package.json"];
|
|
6532
|
-
for (const
|
|
7233
|
+
for (const relative8 of candidates) {
|
|
6533
7234
|
try {
|
|
6534
|
-
const raw = readFileSync(fileURLToPath(new URL(
|
|
7235
|
+
const raw = readFileSync(fileURLToPath(new URL(relative8, import.meta.url)), "utf8");
|
|
6535
7236
|
const pkg = JSON.parse(raw);
|
|
6536
|
-
if (pkg.version && (
|
|
7237
|
+
if (pkg.version && (relative8 === "../package.json" || pkg.name === PACKAGE_NAME)) return pkg.version;
|
|
6537
7238
|
} catch {
|
|
6538
7239
|
}
|
|
6539
7240
|
}
|
|
@@ -6871,14 +7572,21 @@ function registerValidate(program2) {
|
|
|
6871
7572
|
try {
|
|
6872
7573
|
const payloadFiles = await resolvePayloadFiles(dirname(manifestPath), manifestPath, manifest);
|
|
6873
7574
|
issues.push(...validateAgentAvatarPayloadFiles(manifest, payloadFiles).map((message) => ({ level: "error", message })));
|
|
6874
|
-
const
|
|
6875
|
-
issues.push(
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
payloadFiles,
|
|
6879
|
-
(file) => readTemplatedPayloadBytes(dirname(manifestPath), file, templateInspection)
|
|
7575
|
+
const suite = await validateAgentSuite(dirname(manifestPath), manifestPath, manifest, payloadFiles);
|
|
7576
|
+
issues.push(
|
|
7577
|
+
...suite.errors.map((message) => ({ level: "error", message })),
|
|
7578
|
+
...suite.warnings.map((message) => ({ level: "warning", message }))
|
|
6880
7579
|
);
|
|
6881
|
-
|
|
7580
|
+
if (avatarPayloadErrors.length === 0) {
|
|
7581
|
+
const templateInspection = await inspectPackagingTemplates(dirname(manifestPath), manifest, payloadFiles);
|
|
7582
|
+
issues.push(...templateInspection.issues);
|
|
7583
|
+
const argumentErrors = await checkScriptArgumentDescriptors(
|
|
7584
|
+
dirname(manifestPath),
|
|
7585
|
+
payloadFiles,
|
|
7586
|
+
(file) => readTemplatedPayloadBytes(dirname(manifestPath), file, templateInspection)
|
|
7587
|
+
);
|
|
7588
|
+
issues.push(...argumentErrors.map((message) => ({ level: "error", message })));
|
|
7589
|
+
}
|
|
6882
7590
|
} catch (error) {
|
|
6883
7591
|
issues.push({ level: "error", message: error instanceof Error ? error.message : String(error) });
|
|
6884
7592
|
}
|
|
@@ -7079,5 +7787,6 @@ async function main() {
|
|
|
7079
7787
|
await notifyOnExit(process.argv);
|
|
7080
7788
|
}
|
|
7081
7789
|
void main();
|
|
7790
|
+
/*! @verentis/avatar 0.5.0 pre-release: bundled strict face validation only. MIT; distribute with LICENSE and THIRD_PARTY_NOTICES.txt. */
|
|
7082
7791
|
//# sourceMappingURL=index.js.map
|
|
7083
7792
|
//# sourceMappingURL=index.js.map
|