@verentis/cli 1.0.4 → 1.0.5
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 +637 -78
- 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);
|
|
@@ -2120,6 +2609,7 @@ async function loadManifest(path) {
|
|
|
2120
2609
|
const text = await readFile(path, "utf8");
|
|
2121
2610
|
const manifest = parse(text);
|
|
2122
2611
|
if (!manifest || typeof manifest !== "object") throw new Error(`Failed to parse manifest at ${path}.`);
|
|
2612
|
+
checkAvatarPackYaml(manifest.kind, text);
|
|
2123
2613
|
if (!manifest.kind) throw new Error(`Manifest at ${path} is missing 'kind'.`);
|
|
2124
2614
|
const metadataErrors = validateDocumentMetadata(manifest.metadata);
|
|
2125
2615
|
if (metadataErrors.length > 0) throw new Error(`Invalid manifest at ${path}: ${metadataErrors.join("; ")}.`);
|
|
@@ -2641,6 +3131,7 @@ async function readManifestDocument(path) {
|
|
|
2641
3131
|
const text = await readFile(path, "utf8");
|
|
2642
3132
|
const doc = parse(text);
|
|
2643
3133
|
if (!doc || typeof doc !== "object") throw new Error(`${path} is not a YAML manifest.`);
|
|
3134
|
+
checkAvatarPackYaml(doc.kind, text);
|
|
2644
3135
|
return doc;
|
|
2645
3136
|
}
|
|
2646
3137
|
function manifestPermissions(manifest) {
|
|
@@ -3315,17 +3806,17 @@ async function streamLogs(api, workspaceId, executionId) {
|
|
|
3315
3806
|
});
|
|
3316
3807
|
if (!res.body) return;
|
|
3317
3808
|
const decoder = new TextDecoder();
|
|
3318
|
-
let
|
|
3809
|
+
let buffer2 = "";
|
|
3319
3810
|
let currentEvent = "message";
|
|
3320
3811
|
const reader = res.body.getReader();
|
|
3321
3812
|
for (; ; ) {
|
|
3322
3813
|
const { done, value } = await reader.read();
|
|
3323
3814
|
if (done) break;
|
|
3324
|
-
|
|
3815
|
+
buffer2 += decoder.decode(value, { stream: true });
|
|
3325
3816
|
let newlineIdx;
|
|
3326
|
-
while ((newlineIdx =
|
|
3327
|
-
const line =
|
|
3328
|
-
|
|
3817
|
+
while ((newlineIdx = buffer2.indexOf("\n")) >= 0) {
|
|
3818
|
+
const line = buffer2.slice(0, newlineIdx).replace(/\r$/, "");
|
|
3819
|
+
buffer2 = buffer2.slice(newlineIdx + 1);
|
|
3329
3820
|
if (line.startsWith("event: ")) {
|
|
3330
3821
|
currentEvent = line.slice(7).trim();
|
|
3331
3822
|
} else if (line.startsWith("data: ")) {
|
|
@@ -3372,10 +3863,10 @@ var archiveImportPolling = {
|
|
|
3372
3863
|
};
|
|
3373
3864
|
var isZipName = (name) => name.toLowerCase().endsWith(".zip");
|
|
3374
3865
|
async function uploadWithHeaders(api, workspaceId, remotePath, localPath, options) {
|
|
3375
|
-
const
|
|
3866
|
+
const buffer2 = await readFile(localPath);
|
|
3376
3867
|
const contentType = options.contentType ?? (isZipName(localPath) ? "application/zip" : "application/octet-stream");
|
|
3377
3868
|
const form = new FormData();
|
|
3378
|
-
form.append("file", new Blob([
|
|
3869
|
+
form.append("file", new Blob([buffer2], { type: contentType }), basename(localPath));
|
|
3379
3870
|
form.append("metadata", JSON.stringify({ branch: options.branch, contentType: options.contentType }));
|
|
3380
3871
|
const headers = {};
|
|
3381
3872
|
if (options.autoExtract !== void 0) headers["X-Auto-Extract"] = String(options.autoExtract);
|
|
@@ -3395,19 +3886,19 @@ async function uploadWithHeaders(api, workspaceId, remotePath, localPath, option
|
|
|
3395
3886
|
}
|
|
3396
3887
|
return { status: res.status, location: res.headers?.get("Location") ?? void 0, body };
|
|
3397
3888
|
}
|
|
3398
|
-
function zipHasRootManifest(
|
|
3889
|
+
function zipHasRootManifest(buffer2) {
|
|
3399
3890
|
const EOCD = 101010256;
|
|
3400
3891
|
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 =
|
|
3892
|
+
const minStart = Math.max(0, buffer2.length - 22 - 65535);
|
|
3893
|
+
for (let i = buffer2.length - 22; i >= minStart; i--) {
|
|
3894
|
+
if (buffer2.readUInt32LE(i) !== EOCD) continue;
|
|
3895
|
+
let offset = buffer2.readUInt32LE(i + 16);
|
|
3896
|
+
if (offset === 4294967295 || offset >= buffer2.length) return void 0;
|
|
3897
|
+
while (offset + 46 <= buffer2.length && buffer2.readUInt32LE(offset) === CDH) {
|
|
3898
|
+
const nameLength = buffer2.readUInt16LE(offset + 28);
|
|
3899
|
+
const extraLength = buffer2.readUInt16LE(offset + 30);
|
|
3900
|
+
const commentLength = buffer2.readUInt16LE(offset + 32);
|
|
3901
|
+
const name = buffer2.subarray(offset + 46, offset + 46 + nameLength).toString("utf8");
|
|
3411
3902
|
if (name === ".verentis-manifest.json" || name === "./.verentis-manifest.json") return true;
|
|
3412
3903
|
offset += 46 + nameLength + extraLength + commentLength;
|
|
3413
3904
|
}
|
|
@@ -3754,7 +4245,7 @@ async function migrateManifestIcons(manifestPath, options = {}) {
|
|
|
3754
4245
|
result.written.push(file);
|
|
3755
4246
|
}
|
|
3756
4247
|
let updated = text;
|
|
3757
|
-
for (const splice of splices.sort((a,
|
|
4248
|
+
for (const splice of splices.sort((a, b2) => b2.start - a.start)) {
|
|
3758
4249
|
updated = updated.slice(0, splice.start) + splice.replacement + updated.slice(splice.end);
|
|
3759
4250
|
}
|
|
3760
4251
|
await writeFile(manifestPath, updated);
|
|
@@ -3988,6 +4479,16 @@ var THEME_CSS = `/*
|
|
|
3988
4479
|
--brand-border: oklch(0.951 0.017 84.6 / 24%);
|
|
3989
4480
|
}
|
|
3990
4481
|
`;
|
|
4482
|
+
var sample = new URL("../samples/avatar-pack/", import.meta.url);
|
|
4483
|
+
function avatarPackStarterManifest(id) {
|
|
4484
|
+
const manifest = parse(readFileSync(new URL("manifest.yaml", sample), "utf8"));
|
|
4485
|
+
manifest.metadata.id = id;
|
|
4486
|
+
manifest.packaging.publisher = "your-publisher";
|
|
4487
|
+
return stringify(manifest);
|
|
4488
|
+
}
|
|
4489
|
+
function avatarPackStarterFiles() {
|
|
4490
|
+
return { "clay.vavatar": readFileSync(new URL("clay.vavatar", sample), "utf8") };
|
|
4491
|
+
}
|
|
3991
4492
|
|
|
3992
4493
|
// src/commands/init.ts
|
|
3993
4494
|
var APP_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
@@ -4031,9 +4532,11 @@ var TEMPLATE_BY_TYPE = {
|
|
|
4031
4532
|
Application: "application",
|
|
4032
4533
|
ExecutionEngine: "engine",
|
|
4033
4534
|
Bundle: "bundle",
|
|
4034
|
-
Theme: "theme"
|
|
4535
|
+
Theme: "theme",
|
|
4536
|
+
AvatarPack: "avatar-pack"
|
|
4035
4537
|
};
|
|
4036
4538
|
var TEMPLATES = {
|
|
4539
|
+
"avatar-pack": avatarPackStarterManifest,
|
|
4037
4540
|
application: (name) => `api-version: verentis.io/v1
|
|
4038
4541
|
kind: Application
|
|
4039
4542
|
|
|
@@ -4204,7 +4707,7 @@ function resolveInitTemplate(type) {
|
|
|
4204
4707
|
return key;
|
|
4205
4708
|
}
|
|
4206
4709
|
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) => {
|
|
4710
|
+
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
4711
|
const templateKey = resolveInitTemplate(options.type ?? options.kind ?? "application");
|
|
4209
4712
|
const template = TEMPLATES[templateKey];
|
|
4210
4713
|
const targetDir = resolve(dir ?? ".");
|
|
@@ -4214,14 +4717,15 @@ function registerInit(program2) {
|
|
|
4214
4717
|
if (await exists3(manifestPath)) throw new Error(`${manifestPath} already exists.`);
|
|
4215
4718
|
await writeFile(manifestPath, template(name));
|
|
4216
4719
|
console.log(`Created ${manifestPath} (type: ${templateKey}).`);
|
|
4217
|
-
|
|
4720
|
+
const files2 = templateKey === "avatar-pack" ? avatarPackStarterFiles() : TEMPLATE_FILES[templateKey] ?? {};
|
|
4721
|
+
for (const [relativePath, content] of Object.entries(files2)) {
|
|
4218
4722
|
const path = join(targetDir, relativePath);
|
|
4219
4723
|
if (await exists3(path)) continue;
|
|
4220
4724
|
await mkdir(dirname(path), { recursive: true });
|
|
4221
4725
|
await writeFile(path, content);
|
|
4222
4726
|
console.log(`Created ${path}.`);
|
|
4223
4727
|
}
|
|
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`.");
|
|
4728
|
+
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
4729
|
});
|
|
4226
4730
|
}
|
|
4227
4731
|
async function exists3(path) {
|
|
@@ -4233,7 +4737,7 @@ async function exists3(path) {
|
|
|
4233
4737
|
}
|
|
4234
4738
|
}
|
|
4235
4739
|
function titleCase(value) {
|
|
4236
|
-
return value.replace(/(^|[-_])(\w)/g, (
|
|
4740
|
+
return value.replace(/(^|[-_])(\w)/g, (_2, __, c) => ` ${c.toUpperCase()}`).trim();
|
|
4237
4741
|
}
|
|
4238
4742
|
function computeKid(publicKeyBase64) {
|
|
4239
4743
|
return createHash("sha256").update(Buffer.from(publicKeyBase64, "base64")).digest("hex").slice(0, 16);
|
|
@@ -4329,9 +4833,9 @@ async function findRegistryVersion(api, publisher, packageId, version) {
|
|
|
4329
4833
|
throw error;
|
|
4330
4834
|
}
|
|
4331
4835
|
}
|
|
4332
|
-
function sameTreeDigest(a,
|
|
4836
|
+
function sameTreeDigest(a, b2) {
|
|
4333
4837
|
const normalize = (value) => (value ?? "").trim().toLowerCase().replace(/^sha256:/, "");
|
|
4334
|
-
return normalize(a) !== "" && normalize(a) === normalize(
|
|
4838
|
+
return normalize(a) !== "" && normalize(a) === normalize(b2);
|
|
4335
4839
|
}
|
|
4336
4840
|
async function uploadRegistryVersion(api, publisher, packageId, vpkgPath, options = {}) {
|
|
4337
4841
|
const stream = Readable.toWeb(createReadStream(vpkgPath));
|
|
@@ -4751,7 +5255,7 @@ function parseOverlayParams(pairs = []) {
|
|
|
4751
5255
|
}
|
|
4752
5256
|
function interpolateOverlay(overlay, params, source) {
|
|
4753
5257
|
const missing = /* @__PURE__ */ new Set();
|
|
4754
|
-
const
|
|
5258
|
+
const visit2 = (value) => {
|
|
4755
5259
|
if (typeof value === "string") {
|
|
4756
5260
|
return value.replace(PARAM_PLACEHOLDER_PATTERN, (raw, escape, name) => {
|
|
4757
5261
|
if (escape) return raw.slice(1);
|
|
@@ -4760,11 +5264,11 @@ function interpolateOverlay(overlay, params, source) {
|
|
|
4760
5264
|
return raw;
|
|
4761
5265
|
});
|
|
4762
5266
|
}
|
|
4763
|
-
if (Array.isArray(value)) return value.map(
|
|
4764
|
-
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key,
|
|
5267
|
+
if (Array.isArray(value)) return value.map(visit2);
|
|
5268
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit2(item)]));
|
|
4765
5269
|
return value;
|
|
4766
5270
|
};
|
|
4767
|
-
const result =
|
|
5271
|
+
const result = visit2(overlay);
|
|
4768
5272
|
if (missing.size > 0) {
|
|
4769
5273
|
const names = [...missing].sort();
|
|
4770
5274
|
throw new Error(`Overlay ${source} needs ${names.map((name) => `--param ${name}=<value>`).join(", ")}.`);
|
|
@@ -5033,7 +5537,12 @@ async function inspectPackagingTemplates(projectDir, manifest, payloadFiles) {
|
|
|
5033
5537
|
const issues = [];
|
|
5034
5538
|
const variables = readTemplateVariables(manifest, issues);
|
|
5035
5539
|
const templateFiles = await resolveTemplateFiles(projectDir, manifest, payloadFiles, issues);
|
|
5540
|
+
const nativeDefinition = nativeAvatarDefinitionPath(manifest);
|
|
5036
5541
|
for (const file of payloadFiles) {
|
|
5542
|
+
if (nativeDefinition === toEntryPath2(file) && templateFiles.has(file)) {
|
|
5543
|
+
issues.push({ level: "error", message: `Validated native avatar '${nativeDefinition}' must not be a packaging template.` });
|
|
5544
|
+
continue;
|
|
5545
|
+
}
|
|
5037
5546
|
const sourcePath = join(projectDir, file);
|
|
5038
5547
|
const bytes = await readFile(sourcePath);
|
|
5039
5548
|
if (templateFiles.has(file)) {
|
|
@@ -5410,7 +5919,7 @@ function validateRunSize(resources) {
|
|
|
5410
5919
|
return RUN_SIZES.includes(size.trim().toLowerCase()) ? void 0 : `resources.size '${size.trim()}' is not one of ${RUN_SIZES.join(", ")}.`;
|
|
5411
5920
|
}
|
|
5412
5921
|
async function findScriptRun(directory) {
|
|
5413
|
-
const names = (await readdir(directory)).filter((name) => /\.ya?ml$/i.test(name)).sort((a,
|
|
5922
|
+
const names = (await readdir(directory)).filter((name) => /\.ya?ml$/i.test(name)).sort((a, b2) => rank(a) - rank(b2) || a.localeCompare(b2));
|
|
5414
5923
|
for (const name of names) {
|
|
5415
5924
|
try {
|
|
5416
5925
|
const document = parse(await readFile(join(directory, name), "utf8"));
|
|
@@ -5457,8 +5966,13 @@ async function pack(options) {
|
|
|
5457
5966
|
overrideApplied = true;
|
|
5458
5967
|
}
|
|
5459
5968
|
const kind = normalizeKind(manifest.kind);
|
|
5460
|
-
|
|
5461
|
-
|
|
5969
|
+
if (kind === "AvatarPack") {
|
|
5970
|
+
if (!options.signingKey || options.encryptFor?.length) throw new Error("AvatarPack requires signing and cannot be encrypted.");
|
|
5971
|
+
if (options.publisher.toLowerCase() !== manifest.packaging?.publisher)
|
|
5972
|
+
throw new Error("AvatarPack publisher must match the signed packaging.publisher.");
|
|
5973
|
+
}
|
|
5974
|
+
const manifestErrors2 = validatePackageManifestRules(kind, manifest);
|
|
5975
|
+
if (manifestErrors2.length > 0) throw new Error(`Invalid manifest: ${manifestErrors2.join(" ")}`);
|
|
5462
5976
|
const dependencyErrors = validateDependencies(manifest.spec);
|
|
5463
5977
|
if (dependencyErrors.length > 0) throw new Error(`Invalid dependencies: ${dependencyErrors.join(" ")}`);
|
|
5464
5978
|
const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
|
|
@@ -5520,6 +6034,7 @@ async function pack(options) {
|
|
|
5520
6034
|
inlineIconsIntoDocument(document, icons);
|
|
5521
6035
|
manifestText = document.toString();
|
|
5522
6036
|
}
|
|
6037
|
+
checkAvatarPackYaml(kind, manifestText);
|
|
5523
6038
|
await writeFile(join(staging, "manifest.yaml"), manifestText);
|
|
5524
6039
|
const encrypt = (options.encryptFor?.length ?? 0) > 0;
|
|
5525
6040
|
const contentKey = encrypt ? generateContentKey() : null;
|
|
@@ -5838,7 +6353,7 @@ function registerPackage(program2) {
|
|
|
5838
6353
|
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
6354
|
const api = await createApiClient();
|
|
5840
6355
|
const pkg = await getRegistryPackage(api, await resolveRegistryPackageRef(api, ref));
|
|
5841
|
-
output(pkg.versions.map((
|
|
6356
|
+
output(pkg.versions.map((v2) => ({ ...v2 })), { version: "Version", status: "Status", deprecated: "Deprecated", publishedAt: "Published", yankedAt: "Yanked", sizeBytes: "Size", id: "Id" }, options);
|
|
5842
6357
|
});
|
|
5843
6358
|
pkgCmd.command("update <ref>").description("(removed) Package metadata comes from the signed manifest \u2014 edit it, `verentis pack`, then `verentis publish`").allowUnknownOption().action(() => {
|
|
5844
6359
|
throw new Error(
|
|
@@ -6141,9 +6656,9 @@ async function uploadPublisherLogo(api, publisherId, path) {
|
|
|
6141
6656
|
function isNewerVersion(candidate, base) {
|
|
6142
6657
|
return compareVersions(candidate, base) > 0;
|
|
6143
6658
|
}
|
|
6144
|
-
function compareVersions(a,
|
|
6145
|
-
const pa =
|
|
6146
|
-
const pb =
|
|
6659
|
+
function compareVersions(a, b2) {
|
|
6660
|
+
const pa = parse8(a);
|
|
6661
|
+
const pb = parse8(b2);
|
|
6147
6662
|
for (let i = 0; i < 3; i++) {
|
|
6148
6663
|
if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
|
|
6149
6664
|
}
|
|
@@ -6154,23 +6669,23 @@ function compareVersions(a, b) {
|
|
|
6154
6669
|
for (let i = 0; i < len; i++) {
|
|
6155
6670
|
if (i >= pa.pre.length) return -1;
|
|
6156
6671
|
if (i >= pb.pre.length) return 1;
|
|
6157
|
-
const
|
|
6672
|
+
const x2 = pa.pre[i];
|
|
6158
6673
|
const y = pb.pre[i];
|
|
6159
|
-
const xNum = /^\d+$/.test(
|
|
6674
|
+
const xNum = /^\d+$/.test(x2);
|
|
6160
6675
|
const yNum = /^\d+$/.test(y);
|
|
6161
6676
|
if (xNum && yNum) {
|
|
6162
|
-
const nx = Number(
|
|
6677
|
+
const nx = Number(x2);
|
|
6163
6678
|
const ny = Number(y);
|
|
6164
6679
|
if (nx !== ny) return nx < ny ? -1 : 1;
|
|
6165
6680
|
} else if (xNum !== yNum) {
|
|
6166
6681
|
return xNum ? -1 : 1;
|
|
6167
|
-
} else if (
|
|
6168
|
-
return
|
|
6682
|
+
} else if (x2 !== y) {
|
|
6683
|
+
return x2 < y ? -1 : 1;
|
|
6169
6684
|
}
|
|
6170
6685
|
}
|
|
6171
6686
|
return 0;
|
|
6172
6687
|
}
|
|
6173
|
-
function
|
|
6688
|
+
function parse8(version) {
|
|
6174
6689
|
const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
|
|
6175
6690
|
const dash = cleaned.indexOf("-");
|
|
6176
6691
|
const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
|
|
@@ -6181,15 +6696,48 @@ function parse7(version) {
|
|
|
6181
6696
|
|
|
6182
6697
|
// src/commands/installation-graph.ts
|
|
6183
6698
|
async function installGraph(api, workspaceId, packageId, options) {
|
|
6699
|
+
const personal = options.target === "personal";
|
|
6700
|
+
const requirePersonal = async (plan) => {
|
|
6701
|
+
const owner = plan.ownerId;
|
|
6702
|
+
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) => {
|
|
6703
|
+
if (n.ownerId !== owner || n.personalWorkspaceId !== workspaceId || n.branch !== "main" || typeof n.installPath !== "string") return false;
|
|
6704
|
+
const prefix = `home/${owner}/applications/`;
|
|
6705
|
+
const privatePath = (value) => {
|
|
6706
|
+
if (typeof value !== "string") return false;
|
|
6707
|
+
const path = value.replace(/^\//, "");
|
|
6708
|
+
return path.startsWith(prefix) && path.slice(prefix.length).split("/").every(
|
|
6709
|
+
(segment) => /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(segment)
|
|
6710
|
+
);
|
|
6711
|
+
};
|
|
6712
|
+
return !n.replaces && privatePath(n.installPath) && Array.isArray(n.installPaths) && n.installPaths.length > 0 && n.installPaths.every(privatePath);
|
|
6713
|
+
})) {
|
|
6714
|
+
throw new Error("The server did not return a personal plan; refusing to approve a workspace installation.");
|
|
6715
|
+
}
|
|
6716
|
+
const token = await api.mintAccessToken({ scopes: [SCOPES.installRead], workspaceId });
|
|
6717
|
+
const claims = decodeJwtPayload(token);
|
|
6718
|
+
if (claims?.sub !== owner || claims["https://verentis.io/claims/workspace_id"] !== workspaceId) {
|
|
6719
|
+
throw new Error("The personal plan does not belong to the signed-in member of the selected workspace.");
|
|
6720
|
+
}
|
|
6721
|
+
};
|
|
6184
6722
|
if (options.operation || options.consent) {
|
|
6185
6723
|
if (!options.operation || !options.consent) throw new Error("--operation and --consent must be supplied together.");
|
|
6724
|
+
if (personal) {
|
|
6725
|
+
const plan = await api.request("GET", `/v1/installations/graphs/${encodeURIComponent(options.operation)}`, {
|
|
6726
|
+
scopes: [SCOPES.installRead],
|
|
6727
|
+
tokenWorkspaceId: workspaceId,
|
|
6728
|
+
query: { workspaceId }
|
|
6729
|
+
});
|
|
6730
|
+
await requirePersonal(plan);
|
|
6731
|
+
}
|
|
6186
6732
|
const result = await api.request("POST", "/v1/installations/graphs", {
|
|
6187
|
-
scopes: [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete, SCOPES.installationRead, SCOPES.resourceReadAll],
|
|
6733
|
+
scopes: personal ? [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete] : [SCOPES.installCreate, NODE.nodeCreate, NODE.fileRead, NODE.fileDelete, SCOPES.installationRead, SCOPES.resourceReadAll],
|
|
6188
6734
|
tokenWorkspaceId: workspaceId,
|
|
6189
6735
|
body: { workspaceId, operationId: options.operation, fingerprint: options.consent, consent: true }
|
|
6190
6736
|
});
|
|
6191
6737
|
console.log(JSON.stringify(result, null, 2));
|
|
6192
|
-
if (result.succeeded !== true
|
|
6738
|
+
if (result.succeeded !== true && !["Queued", "Running", "RollingBack"].includes(result.status ?? "")) {
|
|
6739
|
+
throw new Error(`Graph installation failed. Inspect operation ${options.operation}; do not resubmit it.`);
|
|
6740
|
+
}
|
|
6193
6741
|
return;
|
|
6194
6742
|
}
|
|
6195
6743
|
const preview = await api.request("POST", "/v1/installations/graphs/preview", {
|
|
@@ -6199,13 +6747,15 @@ async function installGraph(api, workspaceId, packageId, options) {
|
|
|
6199
6747
|
workspaceId,
|
|
6200
6748
|
packageId,
|
|
6201
6749
|
packageVersion: options.version,
|
|
6750
|
+
...personal ? { targetScope: "personal" } : {},
|
|
6202
6751
|
installPath: options.path,
|
|
6203
6752
|
branch: options.branch,
|
|
6204
6753
|
installMode: options.sealed ? "Sealed" : void 0
|
|
6205
6754
|
}
|
|
6206
6755
|
});
|
|
6756
|
+
if (personal) await requirePersonal(preview);
|
|
6207
6757
|
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}.`);
|
|
6758
|
+
console.log(`No packages installed. Review every package and its permissions, then repeat with ${personal ? "--target personal " : ""}--operation ${preview.operationId} --consent ${preview.fingerprint}.`);
|
|
6209
6759
|
}
|
|
6210
6760
|
|
|
6211
6761
|
// src/commands/registry.ts
|
|
@@ -6370,13 +6920,14 @@ function registerRegistry(program2) {
|
|
|
6370
6920
|
console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
|
|
6371
6921
|
}
|
|
6372
6922
|
});
|
|
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) => {
|
|
6923
|
+
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) => {
|
|
6924
|
+
if (options.target !== void 0 && !["personal", "workspace"].includes(options.target)) throw new Error("--target must be personal or workspace.");
|
|
6374
6925
|
const config = await loadConfig();
|
|
6375
6926
|
const workspaceId = options.workspace ?? config.defaultWorkspaceId;
|
|
6376
6927
|
if (!workspaceId) throw new Error("No workspace: pass --workspace <id> or set defaultWorkspaceId in ~/.verentis/config.json.");
|
|
6377
6928
|
const api = await createApiClient();
|
|
6378
6929
|
const { package: pkg } = await resolvePackageRef(api, ref);
|
|
6379
|
-
if (options.operation || options.consent || options.preview) {
|
|
6930
|
+
if (options.target === "personal" || options.operation || options.consent || options.preview) {
|
|
6380
6931
|
await installGraph(api, workspaceId, pkg.id, { ...options, version });
|
|
6381
6932
|
return;
|
|
6382
6933
|
}
|
|
@@ -6458,6 +7009,11 @@ function registerRegistry(program2) {
|
|
|
6458
7009
|
});
|
|
6459
7010
|
console.log(JSON.stringify(result, null, 2));
|
|
6460
7011
|
});
|
|
7012
|
+
program2.command("install-targets").description("Show server-supported personal package types and workspace-only reasons (version policy is checked on preview)").action(async () => {
|
|
7013
|
+
const api = await createApiClient();
|
|
7014
|
+
const matrix = await api.request("GET", "/v1/package-types/installation-targets", { scopes: [] });
|
|
7015
|
+
console.log(JSON.stringify(matrix, null, 2));
|
|
7016
|
+
});
|
|
6461
7017
|
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
7018
|
const api = await createApiClient();
|
|
6463
7019
|
await call(api, marketplace.uninstall, {
|
|
@@ -6871,14 +7427,16 @@ function registerValidate(program2) {
|
|
|
6871
7427
|
try {
|
|
6872
7428
|
const payloadFiles = await resolvePayloadFiles(dirname(manifestPath), manifestPath, manifest);
|
|
6873
7429
|
issues.push(...validateAgentAvatarPayloadFiles(manifest, payloadFiles).map((message) => ({ level: "error", message })));
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
7430
|
+
if (avatarPayloadErrors.length === 0) {
|
|
7431
|
+
const templateInspection = await inspectPackagingTemplates(dirname(manifestPath), manifest, payloadFiles);
|
|
7432
|
+
issues.push(...templateInspection.issues);
|
|
7433
|
+
const argumentErrors = await checkScriptArgumentDescriptors(
|
|
7434
|
+
dirname(manifestPath),
|
|
7435
|
+
payloadFiles,
|
|
7436
|
+
(file) => readTemplatedPayloadBytes(dirname(manifestPath), file, templateInspection)
|
|
7437
|
+
);
|
|
7438
|
+
issues.push(...argumentErrors.map((message) => ({ level: "error", message })));
|
|
7439
|
+
}
|
|
6882
7440
|
} catch (error) {
|
|
6883
7441
|
issues.push({ level: "error", message: error instanceof Error ? error.message : String(error) });
|
|
6884
7442
|
}
|
|
@@ -7079,5 +7637,6 @@ async function main() {
|
|
|
7079
7637
|
await notifyOnExit(process.argv);
|
|
7080
7638
|
}
|
|
7081
7639
|
void main();
|
|
7640
|
+
/*! @verentis/avatar 0.5.0 pre-release: bundled strict face validation only. MIT; distribute with LICENSE and THIRD_PARTY_NOTICES.txt. */
|
|
7082
7641
|
//# sourceMappingURL=index.js.map
|
|
7083
7642
|
//# sourceMappingURL=index.js.map
|