@verentis/cli 1.0.3 → 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 +46 -3
- package/dist/index.js +734 -87
- 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)}'.`);
|
|
@@ -1379,6 +1400,10 @@ var findPackageType = (type) => packageTypes().find(type);
|
|
|
1379
1400
|
var canonicalPackageType = (type) => packageTypes().canonical(type);
|
|
1380
1401
|
var packageTypeProfile = (type) => packageTypes().find(type)?.profile;
|
|
1381
1402
|
var isApplicationProfile = (type) => packageTypeProfile(type) === "application";
|
|
1403
|
+
var recordsInstallationConsent = (type) => {
|
|
1404
|
+
const descriptor = findPackageType(type);
|
|
1405
|
+
return descriptor?.profile === "application" || descriptor?.resourceKind === "Agent";
|
|
1406
|
+
};
|
|
1382
1407
|
async function refreshPackageTypes(apiUrl, options = {}) {
|
|
1383
1408
|
if (process.env.VERENTIS_PACKAGE_TYPES_CACHE === "0") return false;
|
|
1384
1409
|
try {
|
|
@@ -1624,7 +1649,7 @@ function inlineIconsIntoDocument(document, resolution) {
|
|
|
1624
1649
|
return;
|
|
1625
1650
|
}
|
|
1626
1651
|
const node = new YAMLMap();
|
|
1627
|
-
for (const [key, markup] of [...icons.entries()].sort(([a], [
|
|
1652
|
+
for (const [key, markup] of [...icons.entries()].sort(([a], [b2]) => a.localeCompare(b2))) {
|
|
1628
1653
|
node.set(key, Object.assign(new Scalar(markup), { type: Scalar.BLOCK_LITERAL }));
|
|
1629
1654
|
}
|
|
1630
1655
|
document.set("icons", node);
|
|
@@ -1744,9 +1769,9 @@ function expandThemeManifest(manifest) {
|
|
|
1744
1769
|
return { ...manifest, spec: { ...spec, install } };
|
|
1745
1770
|
}
|
|
1746
1771
|
var SIGNATURES = {
|
|
1747
|
-
"image/png": (
|
|
1748
|
-
"image/jpeg": (
|
|
1749
|
-
"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"
|
|
1750
1775
|
};
|
|
1751
1776
|
var CSS_URL = /url\(\s*(?:"([^"]*)"?|'([^']*)'?|([^)]*))\s*\)?/gi;
|
|
1752
1777
|
var CSS_STRING_URL_FUNCTION = /\b(?:-webkit-)?(?:image-set|src|image|cross-fade)\s*\(/i;
|
|
@@ -1836,16 +1861,469 @@ var themeValidator = {
|
|
|
1836
1861
|
expandForPack: expandThemeManifest
|
|
1837
1862
|
};
|
|
1838
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
|
+
|
|
1839
2315
|
// src/vpkg/validators/index.ts
|
|
1840
2316
|
var PACKAGE_TYPE_VALIDATORS = {
|
|
1841
|
-
theme: themeValidator
|
|
2317
|
+
theme: themeValidator,
|
|
2318
|
+
"avatar-pack": avatarPackValidator
|
|
1842
2319
|
};
|
|
1843
2320
|
function validatorForKind(kind) {
|
|
1844
2321
|
const name = findPackageType(kind)?.validator;
|
|
1845
2322
|
return name ? PACKAGE_TYPE_VALIDATORS[name] : void 0;
|
|
1846
2323
|
}
|
|
1847
2324
|
var DOTLOTTIE_V2_FORMAT = "dotlottie/v2";
|
|
1848
|
-
var
|
|
2325
|
+
var NATIVE_AVATAR_FORMAT = "vavatar";
|
|
2326
|
+
var AVATAR_DEFINITION_MAX_BYTES = 4 * 1024 * 1024;
|
|
1849
2327
|
var AVATAR_FALLBACK_MAX_BYTES = 1024 * 1024;
|
|
1850
2328
|
var isRecord3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1851
2329
|
function normalizeAvatarAssetPath(value) {
|
|
@@ -1867,12 +2345,13 @@ function validateAgentAvatarManifest(kind, spec) {
|
|
|
1867
2345
|
errors.push(`spec.avatar.${key} is not supported.`);
|
|
1868
2346
|
}
|
|
1869
2347
|
}
|
|
1870
|
-
if (avatar.format !== DOTLOTTIE_V2_FORMAT) {
|
|
1871
|
-
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}'.`);
|
|
1872
2350
|
}
|
|
1873
2351
|
const definition = normalizeAvatarAssetPath(avatar.definition);
|
|
1874
|
-
|
|
1875
|
-
|
|
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).`);
|
|
1876
2355
|
}
|
|
1877
2356
|
if (avatar.fallback !== void 0) {
|
|
1878
2357
|
const fallback = normalizeAvatarAssetPath(avatar.fallback);
|
|
@@ -1887,6 +2366,11 @@ function agentAvatarPayloadPaths(manifest) {
|
|
|
1887
2366
|
const avatar = manifest.spec.avatar;
|
|
1888
2367
|
return [avatar.definition, avatar.fallback].map(normalizeAvatarAssetPath).filter((path) => path !== void 0);
|
|
1889
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
|
+
}
|
|
1890
2374
|
function validateAgentAvatarPayloadFiles(manifest, payloadFiles) {
|
|
1891
2375
|
const included = new Set(payloadFiles.map((path) => path.replaceAll("\\", "/").replace(/^\.\//, "")));
|
|
1892
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.`);
|
|
@@ -1915,16 +2399,25 @@ async function validateAgentAvatarPayload(projectDir, manifest) {
|
|
|
1915
2399
|
errors.push(`${at} must be a file.`);
|
|
1916
2400
|
continue;
|
|
1917
2401
|
}
|
|
1918
|
-
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
|
+
}
|
|
1919
2408
|
if (asset.kind === "definition") {
|
|
1920
|
-
if (
|
|
1921
|
-
|
|
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
|
+
}
|
|
1922
2415
|
} else if (bytes.length < 22 || bytes[0] !== 80 || bytes[1] !== 75) {
|
|
1923
2416
|
errors.push(`${at} is not a dotLottie ZIP bundle.`);
|
|
1924
2417
|
}
|
|
1925
2418
|
} else {
|
|
1926
|
-
if (bytes.length === 0
|
|
1927
|
-
errors.push(`${at} must be non-empty
|
|
2419
|
+
if (bytes.length === 0) {
|
|
2420
|
+
errors.push(`${at} must be non-empty.`);
|
|
1928
2421
|
} else if (path.endsWith(".svg")) {
|
|
1929
2422
|
const text = decodeUtf8(bytes);
|
|
1930
2423
|
const reason = text === null ? "SVG must be UTF-8 text" : validateThemeSvg(text);
|
|
@@ -1946,6 +2439,88 @@ function hasRasterSignature(path, bytes) {
|
|
|
1946
2439
|
return false;
|
|
1947
2440
|
}
|
|
1948
2441
|
|
|
2442
|
+
// src/vpkg/agent.ts
|
|
2443
|
+
var AGENT_UI_FORMATS = ["openui"];
|
|
2444
|
+
var AGENT_MODEL_CHOICES = ["fixed", "open"];
|
|
2445
|
+
var AGENT_CAPABILITIES = ["network", "execution"];
|
|
2446
|
+
var AGENT_FILE_ACCESS_KEYS = ["path", "mode", "reason"];
|
|
2447
|
+
var isRecord4 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
2448
|
+
var isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
2449
|
+
function validateAgentSpec(kind, spec) {
|
|
2450
|
+
if (findPackageType(kind)?.resourceKind !== "Agent" || !isRecord4(spec)) return [];
|
|
2451
|
+
return [
|
|
2452
|
+
...stringListErrors(spec.permissions, "spec.permissions", "a list of permission names (scopes)"),
|
|
2453
|
+
...fileAccessErrors(spec["file-access"]),
|
|
2454
|
+
...uiErrors(spec.ui),
|
|
2455
|
+
...modelErrors(spec.model),
|
|
2456
|
+
...capabilityErrors(spec.capabilities)
|
|
2457
|
+
];
|
|
2458
|
+
}
|
|
2459
|
+
function stringListErrors(value, label, expected, unique = false) {
|
|
2460
|
+
if (value === void 0) return [];
|
|
2461
|
+
if (!Array.isArray(value)) return [`${label} must be ${expected}.`];
|
|
2462
|
+
const errors = [];
|
|
2463
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2464
|
+
value.forEach((item, index) => {
|
|
2465
|
+
if (!isNonEmptyString(item)) errors.push(`${label}[${index}] must be a non-empty string.`);
|
|
2466
|
+
else if (unique && seen.has(item)) errors.push(`${label} contains duplicate '${item}'.`);
|
|
2467
|
+
else seen.add(item);
|
|
2468
|
+
});
|
|
2469
|
+
return errors;
|
|
2470
|
+
}
|
|
2471
|
+
function fileAccessErrors(value) {
|
|
2472
|
+
if (!Array.isArray(value)) return [];
|
|
2473
|
+
const errors = [];
|
|
2474
|
+
value.forEach((entry, index) => {
|
|
2475
|
+
if (!isRecord4(entry)) return;
|
|
2476
|
+
const at = `spec.file-access[${index}]`;
|
|
2477
|
+
for (const key of Object.keys(entry).filter((key2) => !AGENT_FILE_ACCESS_KEYS.includes(key2))) {
|
|
2478
|
+
errors.push(`${at}.${key} is not supported for Agent manifests (declare path, mode and reason).`);
|
|
2479
|
+
}
|
|
2480
|
+
if (entry.reason === void 0 || typeof entry.reason === "string" && !entry.reason.trim()) {
|
|
2481
|
+
errors.push(`${at}.reason is required: say why the agent needs this folder (shown when the agent is installed).`);
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
return errors;
|
|
2485
|
+
}
|
|
2486
|
+
function uiErrors(value) {
|
|
2487
|
+
if (value === void 0) return [];
|
|
2488
|
+
const expected = AGENT_UI_FORMATS.join(", ");
|
|
2489
|
+
if (!Array.isArray(value)) return [`spec.ui must be a list of interface formats (${expected}).`];
|
|
2490
|
+
const errors = [];
|
|
2491
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2492
|
+
value.forEach((item, index) => {
|
|
2493
|
+
if (!AGENT_UI_FORMATS.includes(item)) {
|
|
2494
|
+
errors.push(`spec.ui[${index}] '${String(item)}' is not supported (expected ${expected}).`);
|
|
2495
|
+
} else if (seen.has(item)) {
|
|
2496
|
+
errors.push(`spec.ui contains duplicate '${String(item)}'.`);
|
|
2497
|
+
}
|
|
2498
|
+
seen.add(item);
|
|
2499
|
+
});
|
|
2500
|
+
return errors;
|
|
2501
|
+
}
|
|
2502
|
+
function modelErrors(value) {
|
|
2503
|
+
if (value === void 0 || isNonEmptyString(value)) return [];
|
|
2504
|
+
if (!isRecord4(value)) return ["spec.model must be a model profile name or a mapping with profile."];
|
|
2505
|
+
const errors = [];
|
|
2506
|
+
const choice = value.choice ?? "fixed";
|
|
2507
|
+
if (!AGENT_MODEL_CHOICES.includes(choice)) {
|
|
2508
|
+
errors.push(`spec.model.choice must be ${AGENT_MODEL_CHOICES.map((c) => `'${c}'`).join(" or ")}.`);
|
|
2509
|
+
}
|
|
2510
|
+
if (value.allowed !== void 0) {
|
|
2511
|
+
if (choice !== "open") errors.push("spec.model.allowed is only valid with spec.model.choice: open.");
|
|
2512
|
+
errors.push(...stringListErrors(value.allowed, "spec.model.allowed", "a list of model profile names", true));
|
|
2513
|
+
}
|
|
2514
|
+
return errors;
|
|
2515
|
+
}
|
|
2516
|
+
function capabilityErrors(value) {
|
|
2517
|
+
if (value === void 0) return [];
|
|
2518
|
+
if (!isRecord4(value)) {
|
|
2519
|
+
return ["spec.capabilities must be a mapping (network, execution) for Agent manifests; declare folders in spec.file-access."];
|
|
2520
|
+
}
|
|
2521
|
+
return Object.keys(value).filter((key) => !AGENT_CAPABILITIES.includes(key)).map((key) => key === "files" ? "spec.capabilities.files is no longer supported; declare the folders the agent works in under spec.file-access ([{ path, mode: read|write, reason }]), consented when the agent is installed." : `spec.capabilities.${key} is not supported (expected ${AGENT_CAPABILITIES.join(" or ")}).`);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
1949
2524
|
// src/vpkg/manifest.ts
|
|
1950
2525
|
var METADATA_ID_REQUIRED_MESSAGE = "metadata.id is required";
|
|
1951
2526
|
var LEGACY_PACKAGE_ID_MESSAGE = "metadata.package-id is no longer supported; use metadata.id";
|
|
@@ -2021,7 +2596,8 @@ function validatePackageManifestRules(kind, manifest) {
|
|
|
2021
2596
|
...validateMetadataTags(manifest.metadata?.tags),
|
|
2022
2597
|
...validateTypeSpecFields(kind, manifest.spec),
|
|
2023
2598
|
...validateTypeManifest(kind, manifest),
|
|
2024
|
-
...validateAgentAvatarManifest(kind, manifest.spec)
|
|
2599
|
+
...validateAgentAvatarManifest(kind, manifest.spec),
|
|
2600
|
+
...validateAgentSpec(kind, manifest.spec)
|
|
2025
2601
|
];
|
|
2026
2602
|
}
|
|
2027
2603
|
function validateLaunchManifestKind(kind, spec) {
|
|
@@ -2033,6 +2609,7 @@ async function loadManifest(path) {
|
|
|
2033
2609
|
const text = await readFile(path, "utf8");
|
|
2034
2610
|
const manifest = parse(text);
|
|
2035
2611
|
if (!manifest || typeof manifest !== "object") throw new Error(`Failed to parse manifest at ${path}.`);
|
|
2612
|
+
checkAvatarPackYaml(manifest.kind, text);
|
|
2036
2613
|
if (!manifest.kind) throw new Error(`Manifest at ${path} is missing 'kind'.`);
|
|
2037
2614
|
const metadataErrors = validateDocumentMetadata(manifest.metadata);
|
|
2038
2615
|
if (metadataErrors.length > 0) throw new Error(`Invalid manifest at ${path}: ${metadataErrors.join("; ")}.`);
|
|
@@ -2554,6 +3131,7 @@ async function readManifestDocument(path) {
|
|
|
2554
3131
|
const text = await readFile(path, "utf8");
|
|
2555
3132
|
const doc = parse(text);
|
|
2556
3133
|
if (!doc || typeof doc !== "object") throw new Error(`${path} is not a YAML manifest.`);
|
|
3134
|
+
checkAvatarPackYaml(doc.kind, text);
|
|
2557
3135
|
return doc;
|
|
2558
3136
|
}
|
|
2559
3137
|
function manifestPermissions(manifest) {
|
|
@@ -2639,6 +3217,7 @@ function validateManifest(manifest) {
|
|
|
2639
3217
|
if (descriptor?.resourceKind === "Tool") validateToolManifest(spec, issues);
|
|
2640
3218
|
if (isPolicy) validatePolicyManifest(spec, issues);
|
|
2641
3219
|
for (const message of validateAgentAvatarManifest(kind, spec)) error(message);
|
|
3220
|
+
for (const message of validateAgentSpec(kind, spec)) error(message);
|
|
2642
3221
|
validateInstallDirectives(spec.install, issues);
|
|
2643
3222
|
validateSettingDeclarations(descriptor?.profile === "engine", spec, issues);
|
|
2644
3223
|
for (const message of validateMarketplaceSection(manifest.marketplace)) error(message);
|
|
@@ -2765,7 +3344,7 @@ function validateBindingIcons(bindings, path, issues) {
|
|
|
2765
3344
|
});
|
|
2766
3345
|
}
|
|
2767
3346
|
function validateOptionalIcon(value, path, issues) {
|
|
2768
|
-
if (value !== void 0 && !
|
|
3347
|
+
if (value !== void 0 && !isNonEmptyString2(value)) {
|
|
2769
3348
|
issues.push({ level: "error", message: `${path} must be a non-empty string` });
|
|
2770
3349
|
}
|
|
2771
3350
|
}
|
|
@@ -2801,7 +3380,7 @@ function validateApplicationLaunch(spec, issues) {
|
|
|
2801
3380
|
error("spec.launch.enabled requires spec.entry or spec.launch.entry-point");
|
|
2802
3381
|
}
|
|
2803
3382
|
}
|
|
2804
|
-
function
|
|
3383
|
+
function isNonEmptyString2(value) {
|
|
2805
3384
|
return typeof value === "string" && value.trim().length > 0;
|
|
2806
3385
|
}
|
|
2807
3386
|
function resolvesIframeEntry(baseEntry, routeOrEntry) {
|
|
@@ -2809,7 +3388,7 @@ function resolvesIframeEntry(baseEntry, routeOrEntry) {
|
|
|
2809
3388
|
return isAbsoluteHttpUrl(baseEntry);
|
|
2810
3389
|
}
|
|
2811
3390
|
function isAbsoluteHttpUrl(value) {
|
|
2812
|
-
if (!
|
|
3391
|
+
if (!isNonEmptyString2(value)) return false;
|
|
2813
3392
|
try {
|
|
2814
3393
|
const url = new URL(value);
|
|
2815
3394
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
@@ -3227,17 +3806,17 @@ async function streamLogs(api, workspaceId, executionId) {
|
|
|
3227
3806
|
});
|
|
3228
3807
|
if (!res.body) return;
|
|
3229
3808
|
const decoder = new TextDecoder();
|
|
3230
|
-
let
|
|
3809
|
+
let buffer2 = "";
|
|
3231
3810
|
let currentEvent = "message";
|
|
3232
3811
|
const reader = res.body.getReader();
|
|
3233
3812
|
for (; ; ) {
|
|
3234
3813
|
const { done, value } = await reader.read();
|
|
3235
3814
|
if (done) break;
|
|
3236
|
-
|
|
3815
|
+
buffer2 += decoder.decode(value, { stream: true });
|
|
3237
3816
|
let newlineIdx;
|
|
3238
|
-
while ((newlineIdx =
|
|
3239
|
-
const line =
|
|
3240
|
-
|
|
3817
|
+
while ((newlineIdx = buffer2.indexOf("\n")) >= 0) {
|
|
3818
|
+
const line = buffer2.slice(0, newlineIdx).replace(/\r$/, "");
|
|
3819
|
+
buffer2 = buffer2.slice(newlineIdx + 1);
|
|
3241
3820
|
if (line.startsWith("event: ")) {
|
|
3242
3821
|
currentEvent = line.slice(7).trim();
|
|
3243
3822
|
} else if (line.startsWith("data: ")) {
|
|
@@ -3284,10 +3863,10 @@ var archiveImportPolling = {
|
|
|
3284
3863
|
};
|
|
3285
3864
|
var isZipName = (name) => name.toLowerCase().endsWith(".zip");
|
|
3286
3865
|
async function uploadWithHeaders(api, workspaceId, remotePath, localPath, options) {
|
|
3287
|
-
const
|
|
3866
|
+
const buffer2 = await readFile(localPath);
|
|
3288
3867
|
const contentType = options.contentType ?? (isZipName(localPath) ? "application/zip" : "application/octet-stream");
|
|
3289
3868
|
const form = new FormData();
|
|
3290
|
-
form.append("file", new Blob([
|
|
3869
|
+
form.append("file", new Blob([buffer2], { type: contentType }), basename(localPath));
|
|
3291
3870
|
form.append("metadata", JSON.stringify({ branch: options.branch, contentType: options.contentType }));
|
|
3292
3871
|
const headers = {};
|
|
3293
3872
|
if (options.autoExtract !== void 0) headers["X-Auto-Extract"] = String(options.autoExtract);
|
|
@@ -3307,19 +3886,19 @@ async function uploadWithHeaders(api, workspaceId, remotePath, localPath, option
|
|
|
3307
3886
|
}
|
|
3308
3887
|
return { status: res.status, location: res.headers?.get("Location") ?? void 0, body };
|
|
3309
3888
|
}
|
|
3310
|
-
function zipHasRootManifest(
|
|
3889
|
+
function zipHasRootManifest(buffer2) {
|
|
3311
3890
|
const EOCD = 101010256;
|
|
3312
3891
|
const CDH = 33639248;
|
|
3313
|
-
const minStart = Math.max(0,
|
|
3314
|
-
for (let i =
|
|
3315
|
-
if (
|
|
3316
|
-
let offset =
|
|
3317
|
-
if (offset === 4294967295 || offset >=
|
|
3318
|
-
while (offset + 46 <=
|
|
3319
|
-
const nameLength =
|
|
3320
|
-
const extraLength =
|
|
3321
|
-
const commentLength =
|
|
3322
|
-
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");
|
|
3323
3902
|
if (name === ".verentis-manifest.json" || name === "./.verentis-manifest.json") return true;
|
|
3324
3903
|
offset += 46 + nameLength + extraLength + commentLength;
|
|
3325
3904
|
}
|
|
@@ -3666,7 +4245,7 @@ async function migrateManifestIcons(manifestPath, options = {}) {
|
|
|
3666
4245
|
result.written.push(file);
|
|
3667
4246
|
}
|
|
3668
4247
|
let updated = text;
|
|
3669
|
-
for (const splice of splices.sort((a,
|
|
4248
|
+
for (const splice of splices.sort((a, b2) => b2.start - a.start)) {
|
|
3670
4249
|
updated = updated.slice(0, splice.start) + splice.replacement + updated.slice(splice.end);
|
|
3671
4250
|
}
|
|
3672
4251
|
await writeFile(manifestPath, updated);
|
|
@@ -3900,6 +4479,16 @@ var THEME_CSS = `/*
|
|
|
3900
4479
|
--brand-border: oklch(0.951 0.017 84.6 / 24%);
|
|
3901
4480
|
}
|
|
3902
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
|
+
}
|
|
3903
4492
|
|
|
3904
4493
|
// src/commands/init.ts
|
|
3905
4494
|
var APP_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
@@ -3943,9 +4532,11 @@ var TEMPLATE_BY_TYPE = {
|
|
|
3943
4532
|
Application: "application",
|
|
3944
4533
|
ExecutionEngine: "engine",
|
|
3945
4534
|
Bundle: "bundle",
|
|
3946
|
-
Theme: "theme"
|
|
4535
|
+
Theme: "theme",
|
|
4536
|
+
AvatarPack: "avatar-pack"
|
|
3947
4537
|
};
|
|
3948
4538
|
var TEMPLATES = {
|
|
4539
|
+
"avatar-pack": avatarPackStarterManifest,
|
|
3949
4540
|
application: (name) => `api-version: verentis.io/v1
|
|
3950
4541
|
kind: Application
|
|
3951
4542
|
|
|
@@ -4116,7 +4707,7 @@ function resolveInitTemplate(type) {
|
|
|
4116
4707
|
return key;
|
|
4117
4708
|
}
|
|
4118
4709
|
function registerInit(program2) {
|
|
4119
|
-
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) => {
|
|
4120
4711
|
const templateKey = resolveInitTemplate(options.type ?? options.kind ?? "application");
|
|
4121
4712
|
const template = TEMPLATES[templateKey];
|
|
4122
4713
|
const targetDir = resolve(dir ?? ".");
|
|
@@ -4126,14 +4717,15 @@ function registerInit(program2) {
|
|
|
4126
4717
|
if (await exists3(manifestPath)) throw new Error(`${manifestPath} already exists.`);
|
|
4127
4718
|
await writeFile(manifestPath, template(name));
|
|
4128
4719
|
console.log(`Created ${manifestPath} (type: ${templateKey}).`);
|
|
4129
|
-
|
|
4720
|
+
const files2 = templateKey === "avatar-pack" ? avatarPackStarterFiles() : TEMPLATE_FILES[templateKey] ?? {};
|
|
4721
|
+
for (const [relativePath, content] of Object.entries(files2)) {
|
|
4130
4722
|
const path = join(targetDir, relativePath);
|
|
4131
4723
|
if (await exists3(path)) continue;
|
|
4132
4724
|
await mkdir(dirname(path), { recursive: true });
|
|
4133
4725
|
await writeFile(path, content);
|
|
4134
4726
|
console.log(`Created ${path}.`);
|
|
4135
4727
|
}
|
|
4136
|
-
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`.");
|
|
4137
4729
|
});
|
|
4138
4730
|
}
|
|
4139
4731
|
async function exists3(path) {
|
|
@@ -4145,7 +4737,7 @@ async function exists3(path) {
|
|
|
4145
4737
|
}
|
|
4146
4738
|
}
|
|
4147
4739
|
function titleCase(value) {
|
|
4148
|
-
return value.replace(/(^|[-_])(\w)/g, (
|
|
4740
|
+
return value.replace(/(^|[-_])(\w)/g, (_2, __, c) => ` ${c.toUpperCase()}`).trim();
|
|
4149
4741
|
}
|
|
4150
4742
|
function computeKid(publicKeyBase64) {
|
|
4151
4743
|
return createHash("sha256").update(Buffer.from(publicKeyBase64, "base64")).digest("hex").slice(0, 16);
|
|
@@ -4241,9 +4833,9 @@ async function findRegistryVersion(api, publisher, packageId, version) {
|
|
|
4241
4833
|
throw error;
|
|
4242
4834
|
}
|
|
4243
4835
|
}
|
|
4244
|
-
function sameTreeDigest(a,
|
|
4836
|
+
function sameTreeDigest(a, b2) {
|
|
4245
4837
|
const normalize = (value) => (value ?? "").trim().toLowerCase().replace(/^sha256:/, "");
|
|
4246
|
-
return normalize(a) !== "" && normalize(a) === normalize(
|
|
4838
|
+
return normalize(a) !== "" && normalize(a) === normalize(b2);
|
|
4247
4839
|
}
|
|
4248
4840
|
async function uploadRegistryVersion(api, publisher, packageId, vpkgPath, options = {}) {
|
|
4249
4841
|
const stream = Readable.toWeb(createReadStream(vpkgPath));
|
|
@@ -4663,7 +5255,7 @@ function parseOverlayParams(pairs = []) {
|
|
|
4663
5255
|
}
|
|
4664
5256
|
function interpolateOverlay(overlay, params, source) {
|
|
4665
5257
|
const missing = /* @__PURE__ */ new Set();
|
|
4666
|
-
const
|
|
5258
|
+
const visit2 = (value) => {
|
|
4667
5259
|
if (typeof value === "string") {
|
|
4668
5260
|
return value.replace(PARAM_PLACEHOLDER_PATTERN, (raw, escape, name) => {
|
|
4669
5261
|
if (escape) return raw.slice(1);
|
|
@@ -4672,11 +5264,11 @@ function interpolateOverlay(overlay, params, source) {
|
|
|
4672
5264
|
return raw;
|
|
4673
5265
|
});
|
|
4674
5266
|
}
|
|
4675
|
-
if (Array.isArray(value)) return value.map(
|
|
4676
|
-
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)]));
|
|
4677
5269
|
return value;
|
|
4678
5270
|
};
|
|
4679
|
-
const result =
|
|
5271
|
+
const result = visit2(overlay);
|
|
4680
5272
|
if (missing.size > 0) {
|
|
4681
5273
|
const names = [...missing].sort();
|
|
4682
5274
|
throw new Error(`Overlay ${source} needs ${names.map((name) => `--param ${name}=<value>`).join(", ")}.`);
|
|
@@ -4945,7 +5537,12 @@ async function inspectPackagingTemplates(projectDir, manifest, payloadFiles) {
|
|
|
4945
5537
|
const issues = [];
|
|
4946
5538
|
const variables = readTemplateVariables(manifest, issues);
|
|
4947
5539
|
const templateFiles = await resolveTemplateFiles(projectDir, manifest, payloadFiles, issues);
|
|
5540
|
+
const nativeDefinition = nativeAvatarDefinitionPath(manifest);
|
|
4948
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
|
+
}
|
|
4949
5546
|
const sourcePath = join(projectDir, file);
|
|
4950
5547
|
const bytes = await readFile(sourcePath);
|
|
4951
5548
|
if (templateFiles.has(file)) {
|
|
@@ -5322,7 +5919,7 @@ function validateRunSize(resources) {
|
|
|
5322
5919
|
return RUN_SIZES.includes(size.trim().toLowerCase()) ? void 0 : `resources.size '${size.trim()}' is not one of ${RUN_SIZES.join(", ")}.`;
|
|
5323
5920
|
}
|
|
5324
5921
|
async function findScriptRun(directory) {
|
|
5325
|
-
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));
|
|
5326
5923
|
for (const name of names) {
|
|
5327
5924
|
try {
|
|
5328
5925
|
const document = parse(await readFile(join(directory, name), "utf8"));
|
|
@@ -5369,8 +5966,13 @@ async function pack(options) {
|
|
|
5369
5966
|
overrideApplied = true;
|
|
5370
5967
|
}
|
|
5371
5968
|
const kind = normalizeKind(manifest.kind);
|
|
5372
|
-
|
|
5373
|
-
|
|
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(" ")}`);
|
|
5374
5976
|
const dependencyErrors = validateDependencies(manifest.spec);
|
|
5375
5977
|
if (dependencyErrors.length > 0) throw new Error(`Invalid dependencies: ${dependencyErrors.join(" ")}`);
|
|
5376
5978
|
const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
|
|
@@ -5385,11 +5987,11 @@ async function pack(options) {
|
|
|
5385
5987
|
manifest = typeValidator?.expandForPack ? typeValidator.expandForPack(manifest) : manifest;
|
|
5386
5988
|
const normalizedSpec = normalizeDependencies(manifest.spec);
|
|
5387
5989
|
if (normalizedSpec !== manifest.spec) manifest = { ...manifest, spec: normalizedSpec };
|
|
5388
|
-
const
|
|
5990
|
+
const fileAccessErrors2 = validateFileAccess(manifest.spec?.["file-access"], "spec.file-access", MAX_PACKAGE_FILE_ACCESS);
|
|
5389
5991
|
const scriptAccess = await collectScriptFileAccess(projectDir, manifest.spec);
|
|
5390
|
-
|
|
5391
|
-
if (
|
|
5392
|
-
${
|
|
5992
|
+
fileAccessErrors2.push(...scriptAccess.errors);
|
|
5993
|
+
if (fileAccessErrors2.length > 0) throw new Error(`Invalid file-access:
|
|
5994
|
+
${fileAccessErrors2.join("\n ")}`);
|
|
5393
5995
|
const accessSpec = mergeFileAccess(manifest.spec, scriptAccess.entries);
|
|
5394
5996
|
if (accessSpec !== manifest.spec) manifest = { ...manifest, spec: accessSpec };
|
|
5395
5997
|
const packageAccessErrors = validateFileAccess(manifest.spec?.["file-access"], "spec.file-access", MAX_PACKAGE_FILE_ACCESS);
|
|
@@ -5432,6 +6034,7 @@ async function pack(options) {
|
|
|
5432
6034
|
inlineIconsIntoDocument(document, icons);
|
|
5433
6035
|
manifestText = document.toString();
|
|
5434
6036
|
}
|
|
6037
|
+
checkAvatarPackYaml(kind, manifestText);
|
|
5435
6038
|
await writeFile(join(staging, "manifest.yaml"), manifestText);
|
|
5436
6039
|
const encrypt = (options.encryptFor?.length ?? 0) > 0;
|
|
5437
6040
|
const contentKey = encrypt ? generateContentKey() : null;
|
|
@@ -5750,7 +6353,7 @@ function registerPackage(program2) {
|
|
|
5750
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) => {
|
|
5751
6354
|
const api = await createApiClient();
|
|
5752
6355
|
const pkg = await getRegistryPackage(api, await resolveRegistryPackageRef(api, ref));
|
|
5753
|
-
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);
|
|
5754
6357
|
});
|
|
5755
6358
|
pkgCmd.command("update <ref>").description("(removed) Package metadata comes from the signed manifest \u2014 edit it, `verentis pack`, then `verentis publish`").allowUnknownOption().action(() => {
|
|
5756
6359
|
throw new Error(
|
|
@@ -6053,9 +6656,9 @@ async function uploadPublisherLogo(api, publisherId, path) {
|
|
|
6053
6656
|
function isNewerVersion(candidate, base) {
|
|
6054
6657
|
return compareVersions(candidate, base) > 0;
|
|
6055
6658
|
}
|
|
6056
|
-
function compareVersions(a,
|
|
6057
|
-
const pa =
|
|
6058
|
-
const pb =
|
|
6659
|
+
function compareVersions(a, b2) {
|
|
6660
|
+
const pa = parse8(a);
|
|
6661
|
+
const pb = parse8(b2);
|
|
6059
6662
|
for (let i = 0; i < 3; i++) {
|
|
6060
6663
|
if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
|
|
6061
6664
|
}
|
|
@@ -6066,23 +6669,23 @@ function compareVersions(a, b) {
|
|
|
6066
6669
|
for (let i = 0; i < len; i++) {
|
|
6067
6670
|
if (i >= pa.pre.length) return -1;
|
|
6068
6671
|
if (i >= pb.pre.length) return 1;
|
|
6069
|
-
const
|
|
6672
|
+
const x2 = pa.pre[i];
|
|
6070
6673
|
const y = pb.pre[i];
|
|
6071
|
-
const xNum = /^\d+$/.test(
|
|
6674
|
+
const xNum = /^\d+$/.test(x2);
|
|
6072
6675
|
const yNum = /^\d+$/.test(y);
|
|
6073
6676
|
if (xNum && yNum) {
|
|
6074
|
-
const nx = Number(
|
|
6677
|
+
const nx = Number(x2);
|
|
6075
6678
|
const ny = Number(y);
|
|
6076
6679
|
if (nx !== ny) return nx < ny ? -1 : 1;
|
|
6077
6680
|
} else if (xNum !== yNum) {
|
|
6078
6681
|
return xNum ? -1 : 1;
|
|
6079
|
-
} else if (
|
|
6080
|
-
return
|
|
6682
|
+
} else if (x2 !== y) {
|
|
6683
|
+
return x2 < y ? -1 : 1;
|
|
6081
6684
|
}
|
|
6082
6685
|
}
|
|
6083
6686
|
return 0;
|
|
6084
6687
|
}
|
|
6085
|
-
function
|
|
6688
|
+
function parse8(version) {
|
|
6086
6689
|
const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
|
|
6087
6690
|
const dash = cleaned.indexOf("-");
|
|
6088
6691
|
const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
|
|
@@ -6093,15 +6696,48 @@ function parse7(version) {
|
|
|
6093
6696
|
|
|
6094
6697
|
// src/commands/installation-graph.ts
|
|
6095
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
|
+
};
|
|
6096
6722
|
if (options.operation || options.consent) {
|
|
6097
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
|
+
}
|
|
6098
6732
|
const result = await api.request("POST", "/v1/installations/graphs", {
|
|
6099
|
-
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],
|
|
6100
6734
|
tokenWorkspaceId: workspaceId,
|
|
6101
6735
|
body: { workspaceId, operationId: options.operation, fingerprint: options.consent, consent: true }
|
|
6102
6736
|
});
|
|
6103
6737
|
console.log(JSON.stringify(result, null, 2));
|
|
6104
|
-
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
|
+
}
|
|
6105
6741
|
return;
|
|
6106
6742
|
}
|
|
6107
6743
|
const preview = await api.request("POST", "/v1/installations/graphs/preview", {
|
|
@@ -6111,13 +6747,15 @@ async function installGraph(api, workspaceId, packageId, options) {
|
|
|
6111
6747
|
workspaceId,
|
|
6112
6748
|
packageId,
|
|
6113
6749
|
packageVersion: options.version,
|
|
6750
|
+
...personal ? { targetScope: "personal" } : {},
|
|
6114
6751
|
installPath: options.path,
|
|
6115
6752
|
branch: options.branch,
|
|
6116
6753
|
installMode: options.sealed ? "Sealed" : void 0
|
|
6117
6754
|
}
|
|
6118
6755
|
});
|
|
6756
|
+
if (personal) await requirePersonal(preview);
|
|
6119
6757
|
console.log(JSON.stringify(preview, null, 2));
|
|
6120
|
-
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}.`);
|
|
6121
6759
|
}
|
|
6122
6760
|
|
|
6123
6761
|
// src/commands/registry.ts
|
|
@@ -6282,13 +6920,14 @@ function registerRegistry(program2) {
|
|
|
6282
6920
|
console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
|
|
6283
6921
|
}
|
|
6284
6922
|
});
|
|
6285
|
-
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.");
|
|
6286
6925
|
const config = await loadConfig();
|
|
6287
6926
|
const workspaceId = options.workspace ?? config.defaultWorkspaceId;
|
|
6288
6927
|
if (!workspaceId) throw new Error("No workspace: pass --workspace <id> or set defaultWorkspaceId in ~/.verentis/config.json.");
|
|
6289
6928
|
const api = await createApiClient();
|
|
6290
6929
|
const { package: pkg } = await resolvePackageRef(api, ref);
|
|
6291
|
-
if (options.operation || options.consent || options.preview) {
|
|
6930
|
+
if (options.target === "personal" || options.operation || options.consent || options.preview) {
|
|
6292
6931
|
await installGraph(api, workspaceId, pkg.id, { ...options, version });
|
|
6293
6932
|
return;
|
|
6294
6933
|
}
|
|
@@ -6324,7 +6963,7 @@ function registerRegistry(program2) {
|
|
|
6324
6963
|
);
|
|
6325
6964
|
const existing = pageItems(page).find((installation) => installation.status !== "Uninstalled");
|
|
6326
6965
|
const nodeScopes = [NODE.nodeCreate, NODE.fileRead];
|
|
6327
|
-
const consentScopes =
|
|
6966
|
+
const consentScopes = recordsInstallationConsent(pkg.type ?? pkg.kind) ? [SCOPES.installationRead, SCOPES.resourceReadAll, SCOPES.resourceUpdate] : [];
|
|
6328
6967
|
if (existing) {
|
|
6329
6968
|
if (options.path && existing.installPath !== options.path.replace(/^\/+|\/+$/g, "")) {
|
|
6330
6969
|
throw new Error(`${ref} is already installed at '${existing.installPath}'. Uninstall it before moving it.`);
|
|
@@ -6370,6 +7009,11 @@ function registerRegistry(program2) {
|
|
|
6370
7009
|
});
|
|
6371
7010
|
console.log(JSON.stringify(result, null, 2));
|
|
6372
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
|
+
});
|
|
6373
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) => {
|
|
6374
7018
|
const api = await createApiClient();
|
|
6375
7019
|
await call(api, marketplace.uninstall, {
|
|
@@ -6783,14 +7427,16 @@ function registerValidate(program2) {
|
|
|
6783
7427
|
try {
|
|
6784
7428
|
const payloadFiles = await resolvePayloadFiles(dirname(manifestPath), manifestPath, manifest);
|
|
6785
7429
|
issues.push(...validateAgentAvatarPayloadFiles(manifest, payloadFiles).map((message) => ({ level: "error", message })));
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
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
|
+
}
|
|
6794
7440
|
} catch (error) {
|
|
6795
7441
|
issues.push({ level: "error", message: error instanceof Error ? error.message : String(error) });
|
|
6796
7442
|
}
|
|
@@ -6991,5 +7637,6 @@ async function main() {
|
|
|
6991
7637
|
await notifyOnExit(process.argv);
|
|
6992
7638
|
}
|
|
6993
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. */
|
|
6994
7641
|
//# sourceMappingURL=index.js.map
|
|
6995
7642
|
//# sourceMappingURL=index.js.map
|