@verentis/cli 0.2.17 → 0.2.19

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 CHANGED
@@ -133,6 +133,47 @@ verentis validate engine.yaml # manifest checks before
133
133
 
134
134
  `dev run` writes `.verentis/context.json` (mode 600 — contains a short-lived token; git-ignore `.verentis/`).
135
135
 
136
+ There are two different ways to run a Python engine script from your machine:
137
+
138
+ | Goal | Command | `engine.files` uses |
139
+ | --- | --- | --- |
140
+ | Test against a real Verentis workspace | `verentis dev run transform.py` | Workspace VFS through the API |
141
+ | Test without Verentis | `python run-local.py` | A directory on your local filesystem |
142
+
143
+ Do **not** add `configure_local()` to the production script that you deploy to Verentis. Keep the
144
+ production logic in `transform.py`, then add a separate, local-only runner:
145
+
146
+ ```python
147
+ # run-local.py — do not package or deploy this file
148
+ from verentis import engine
149
+
150
+ engine.configure_local(
151
+ files_root="./workspace",
152
+ runtime_dir="./.verentis-runtime",
153
+ setting_aliases={"my-engine.api-key": "MY_ENGINE_API_KEY"},
154
+ )
155
+
156
+ from transform import main
157
+
158
+ main()
159
+ ```
160
+
161
+ Run the offline version with ordinary Python:
162
+
163
+ ```bash
164
+ export MY_ENGINE_API_KEY="..."
165
+ python run-local.py
166
+ ```
167
+
168
+ The local runner configures the shared `engine` singleton before importing and calling the production
169
+ entry point. The production script itself remains unchanged and continues to work when deployed,
170
+ because Verentis initializes `engine` from `/verentis/context.json`. `verentis dev run` has not been
171
+ removed; use it when you specifically want real workspace files, platform APIs, and scoped-token
172
+ behavior.
173
+
174
+ Offline local mode is a feature of the Python `verentis-engine-sdk`, not the TypeScript
175
+ `@verentis/sdk`.
176
+
136
177
  ### Standalone application launch
137
178
 
138
179
  Applications that can open without a selected file opt in through their manifest:
@@ -172,16 +213,17 @@ repositories:
172
213
  ```bash
173
214
  verentis create application my-app
174
215
  verentis create engine my-python-engine
175
- verentis create bundle sample-data
176
- verentis create canvas-component starter-widgets
177
216
  ```
178
217
 
179
- The initial mappings are `@verentis/template-application`,
180
- `@verentis/template-engine`, `@verentis/template-bundle`, and
181
- `@verentis/template-canvas-component`. Use `--package` for a compatible
182
- third-party template, `--version` to pin it, and `--registry` for a private
183
- npm registry. Templates are installed with `npm pack --ignore-scripts` and
184
- support `{{name}}` and `{{type}}` substitutions.
218
+ The supported mappings are `@verentis/template-application` and
219
+ `@verentis/template-engine`. Use `--package` for a compatible third-party
220
+ template, `--version` to pin it, and `--registry` for a private npm registry.
221
+ Templates are installed with `npm pack --ignore-scripts` and support
222
+ `{{name}}` and `{{type}}` substitutions.
223
+
224
+ Package manifests must declare both `metadata.package-id` (the immutable
225
+ Marketplace coordinate) and `metadata.name` (the runtime/install identity).
226
+ Commands that accept `publisher/package` references use the package ID.
185
227
 
186
228
  ```bash
187
229
  verentis publisher create --name acme --display-name "Acme Inc."
package/dist/index.js CHANGED
@@ -815,22 +815,16 @@ function registerApiKey(program2) {
815
815
  var execFileAsync = promisify(execFile);
816
816
  var TEMPLATE_PACKAGES = {
817
817
  application: "@verentis/template-application",
818
- engine: "@verentis/template-engine",
819
- bundle: "@verentis/template-bundle",
820
- "canvas-component": "@verentis/template-canvas-component"
818
+ engine: "@verentis/template-engine"
821
819
  };
822
820
  function normalizeTemplateType(value) {
823
821
  const normalized = value.trim().toLowerCase().replace(/[_\s]+/g, "-");
824
- if (normalized === "canvas" || normalized === "component" || normalized === "canvas-pack") {
825
- return "canvas-component";
826
- }
827
822
  if (normalized === "app") return "application";
828
823
  if (normalized === "execution-engine") return "engine";
829
- if (normalized === "bundle") return "bundle";
830
- if (normalized === "application" || normalized === "engine" || normalized === "canvas-component") {
824
+ if (normalized === "application" || normalized === "engine") {
831
825
  return normalized;
832
826
  }
833
- throw new Error(`Unknown template type '${value}' \u2014 use application, engine, bundle or canvas-component.`);
827
+ throw new Error(`Unknown template type '${value}' \u2014 use application or engine.`);
834
828
  }
835
829
  async function createFromTemplate(typeValue, name, destination, options = {}) {
836
830
  const type = normalizeTemplateType(typeValue);
@@ -982,7 +976,9 @@ async function loadManifest(path) {
982
976
  if (!manifest || typeof manifest !== "object") throw new Error(`Failed to parse manifest at ${path}.`);
983
977
  if (!manifest.kind) throw new Error(`Manifest at ${path} is missing 'kind'.`);
984
978
  if (!manifest.metadata?.name) throw new Error(`Manifest at ${path} is missing 'metadata.name'.`);
979
+ if (!manifest.metadata?.["package-id"]) throw new Error(`Manifest at ${path} is missing 'metadata.package-id'.`);
985
980
  if (!manifest.metadata?.version) throw new Error(`Manifest at ${path} is missing 'metadata.version'.`);
981
+ validatePackageName(manifest.metadata["package-id"], "package ID");
986
982
  const kind = normalizeKind(manifest.kind);
987
983
  const launchKindError = validateLaunchManifestKind(kind, manifest.spec);
988
984
  if (launchKindError) throw new Error(`Invalid manifest at ${path}: ${launchKindError}.`);
@@ -1147,6 +1143,11 @@ function validateManifest(manifest) {
1147
1143
  for (const field of ["name", "display-name", "version"]) {
1148
1144
  if (!meta[field]) error(`metadata.${field} is required`);
1149
1145
  }
1146
+ if (!meta["package-id"]) {
1147
+ error("metadata.package-id is required");
1148
+ } else if (!NAME_PATTERN.test(meta["package-id"])) {
1149
+ error("metadata.package-id must use lowercase letters, digits and internal hyphens");
1150
+ }
1150
1151
  const spec = manifest.spec ?? {};
1151
1152
  validateManifestIcons(meta, spec, issues);
1152
1153
  const launchKindError = validateLaunchManifestKind(kind, spec);
@@ -1854,6 +1855,7 @@ kind: Application
1854
1855
 
1855
1856
  metadata:
1856
1857
  name: ${name}
1858
+ package-id: ${name}
1857
1859
  display-name: ${titleCase(name)}
1858
1860
  description: ""
1859
1861
  icon: layout-dashboard
@@ -1905,6 +1907,7 @@ kind: ExecutionEngine
1905
1907
 
1906
1908
  metadata:
1907
1909
  name: ${name}
1910
+ package-id: ${name}
1908
1911
  display-name: ${titleCase(name)}
1909
1912
  description: ""
1910
1913
  icon: lucide:terminal
@@ -1941,6 +1944,7 @@ kind: Bundle
1941
1944
 
1942
1945
  metadata:
1943
1946
  name: ${name}
1947
+ package-id: ${name}
1944
1948
  display-name: ${titleCase(name)}
1945
1949
  description: ""
1946
1950
  version: 0.1.0
@@ -2058,18 +2062,19 @@ async function requireMyPublisher(api) {
2058
2062
  }
2059
2063
  return publisher;
2060
2064
  }
2061
- async function findPackageByName(api, publisherId, name) {
2065
+ async function findPackageByPackageId(api, publisherId, packageId) {
2062
2066
  const page = await api.request("GET", `/v1/publishers/${publisherId}/packages`, {
2063
2067
  scopes: [SCOPES.packageRead],
2064
2068
  query: { PageNo: 1, PageSize: 100 }
2065
2069
  });
2066
- return pageItems2(page).find((pkg) => pkg.name === name) ?? null;
2070
+ return pageItems2(page).find((pkg) => pkg.packageId === packageId) ?? null;
2067
2071
  }
2068
2072
  async function createPackage(api, input) {
2069
2073
  return api.request("POST", "/v1/packages", {
2070
2074
  scopes: [SCOPES.packageCreate],
2071
2075
  body: {
2072
2076
  publisherId: input.publisherId,
2077
+ packageId: input.packageId,
2073
2078
  name: input.name,
2074
2079
  displayName: input.displayName,
2075
2080
  kind: input.kind,
@@ -2102,19 +2107,19 @@ async function downloadTarball(api, packageId, version, workspaceId) {
2102
2107
  });
2103
2108
  }
2104
2109
  async function resolvePackageRef(api, ref) {
2105
- const [publisherName, packageName] = ref.includes("/") ? ref.split("/", 2) : [void 0, ref];
2110
+ const [publisherName, packageId] = ref.includes("/") ? ref.split("/", 2) : [void 0, ref];
2106
2111
  if (!publisherName) {
2107
2112
  const me = await requireMyPublisher(api);
2108
- const pkg2 = await findPackageByName(api, me.id, packageName);
2109
- if (!pkg2) throw new Error(`Package '${packageName}' not found under your publisher '${me.name}'.`);
2113
+ const pkg2 = await findPackageByPackageId(api, me.id, packageId);
2114
+ if (!pkg2) throw new Error(`Package '${packageId}' not found under your publisher '${me.name}'.`);
2110
2115
  return { package: pkg2, publisherName: me.name };
2111
2116
  }
2112
2117
  const page = await api.request("GET", "/v1/packages", {
2113
2118
  scopes: [SCOPES.packageReadAll],
2114
- query: { SearchText: packageName, PageNo: 1, PageSize: 100 }
2119
+ query: { SearchText: packageId, PageNo: 1, PageSize: 100 }
2115
2120
  });
2116
- const pkg = pageItems2(page).find((p) => p.name === packageName && p.publisherName === publisherName);
2117
- if (!pkg) throw new Error(`Package '${publisherName}/${packageName}' not found (or not visible to you).`);
2121
+ const pkg = pageItems2(page).find((p) => p.packageId === packageId && p.publisherName === publisherName);
2122
+ if (!pkg) throw new Error(`Package '${publisherName}/${packageId}' not found (or not visible to you).`);
2118
2123
  return { package: pkg, publisherName };
2119
2124
  }
2120
2125
 
@@ -2581,6 +2586,10 @@ async function pack(options) {
2581
2586
  }
2582
2587
  let manifest = overlay ? applyOverlay(base, overlay) : base;
2583
2588
  let overrideApplied = overlayPath !== void 0 || options.bumpVersion === true;
2589
+ if (options.name !== void 0) {
2590
+ manifest = { ...manifest, metadata: { ...manifest.metadata, "package-id": options.name } };
2591
+ overrideApplied = true;
2592
+ }
2584
2593
  if (options.version !== void 0) {
2585
2594
  manifest = { ...manifest, metadata: { ...manifest.metadata, version: options.version } };
2586
2595
  overrideApplied = true;
@@ -2590,9 +2599,11 @@ async function pack(options) {
2590
2599
  if (launchKindError) throw new Error(`Invalid manifest: ${launchKindError}.`);
2591
2600
  const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
2592
2601
  if (marketplaceErrors.length > 0) throw new Error(`Invalid marketplace section: ${marketplaceErrors.join(" ")}`);
2593
- const name = (options.name ?? manifest.packaging?.name ?? manifest.metadata.name).toLowerCase();
2602
+ const packageId = manifest.metadata["package-id"].toLowerCase();
2603
+ const name = manifest.metadata.name.toLowerCase();
2594
2604
  const publisher = options.publisher.toLowerCase();
2595
- validatePackageName(name, "package name");
2605
+ validatePackageName(packageId, "package ID");
2606
+ validatePackageName(name, "runtime name");
2596
2607
  validatePackageName(publisher, "publisher name");
2597
2608
  const version = manifest.metadata.version;
2598
2609
  const payloadFiles = await resolvePayloadFiles(projectDir, manifestPath, manifest);
@@ -2638,6 +2649,7 @@ async function pack(options) {
2638
2649
  const digestsJson = JSON.stringify({ algorithm: "sha256", entries: digests }, null, 2);
2639
2650
  await writeFile(join(staging, ".verentis", "digests.json"), digestsJson);
2640
2651
  const packageYaml = [
2652
+ `package-id: ${packageId}`,
2641
2653
  `name: ${name}`,
2642
2654
  `publisher: ${publisher}`,
2643
2655
  `version: ${version}`,
@@ -2655,7 +2667,7 @@ async function pack(options) {
2655
2667
  const outDir = resolve(options.outDir ?? projectDir);
2656
2668
  await mkdir(outDir, { recursive: true });
2657
2669
  const environmentSuffix = options.env ? `-${options.env}` : "";
2658
- const outFile = join(outDir, `${name}${environmentSuffix}-${version}.vpkg`);
2670
+ const outFile = join(outDir, `${packageId}${environmentSuffix}-${version}.vpkg`);
2659
2671
  const entries = [
2660
2672
  "manifest.yaml",
2661
2673
  ".verentis/package.yaml",
@@ -2668,6 +2680,7 @@ async function pack(options) {
2668
2680
  await tar.create({ gzip: true, file: outFile, cwd: staging, portable: true, mtime: /* @__PURE__ */ new Date(0) }, entries);
2669
2681
  return {
2670
2682
  outFile,
2683
+ packageId,
2671
2684
  name,
2672
2685
  publisher,
2673
2686
  version,
@@ -2752,6 +2765,9 @@ async function readVpkg(vpkgPath) {
2752
2765
  throw new Error("Invalid package: missing .verentis/digests.json.");
2753
2766
  });
2754
2767
  const metadata = parse(packageYaml);
2768
+ if (!metadata?.["package-id"]) {
2769
+ throw new Error("Invalid package: .verentis/package.yaml is missing package-id.");
2770
+ }
2755
2771
  const declared = JSON.parse(digestsJson);
2756
2772
  const files2 = await listFiles(staging, "files/**/*");
2757
2773
  const catalogFiles = await listFiles(staging, "catalog/**/*");
@@ -2828,7 +2844,7 @@ async function readJsonIfExists(path) {
2828
2844
 
2829
2845
  // src/commands/pack.ts
2830
2846
  function registerPack(program2) {
2831
- program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override the package name").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--bump-version", "increment metadata.version.patch and update the manifest").option("--bump", "alias for --bump-version").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2847
+ program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override metadata.package-id").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--bump-version", "increment metadata.version.patch and update the manifest").option("--bump", "alias for --bump-version").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2832
2848
  const projectDir = resolve(dir ?? ".");
2833
2849
  const manifestPath = options.manifest ? resolve(options.manifest) : await findManifest(projectDir);
2834
2850
  const manifest = await loadManifest(manifestPath);
@@ -2871,7 +2887,7 @@ function registerPack(program2) {
2871
2887
  signingKey,
2872
2888
  encryptFor
2873
2889
  });
2874
- console.log(`Packed ${result.publisher}/${result.name}@${result.version} (${result.kind})`);
2890
+ console.log(`Packed ${result.publisher}/${result.packageId}@${result.version} (${result.kind})`);
2875
2891
  console.log(` ${result.outFile}`);
2876
2892
  console.log(` ${result.files.length} payload file(s), tree digest ${result.treeDigest.slice(0, 16)}\u2026, ${result.signed ? "signed" : "UNSIGNED"}${result.encrypted ? ", ENCRYPTED" : ""}`);
2877
2893
  if (result.catalog) console.log(` ${result.catalogFiles.length} plaintext catalog file(s)`);
@@ -2884,7 +2900,7 @@ function registerPack(program2) {
2884
2900
  });
2885
2901
  program2.command("verify <vpkg>").description("Verify the digests (and, when possible, the developer signature) of a .vpkg").option("--key <name>", "verify the developer signature against a local key").action(async (vpkgPath, options) => {
2886
2902
  const contents = await readVpkg(resolve(vpkgPath));
2887
- console.log(`${contents.metadata.publisher}/${contents.metadata.name}@${contents.metadata.version} (${contents.metadata.kind})`);
2903
+ console.log(`${contents.metadata.publisher}/${contents.metadata["package-id"]}@${contents.metadata.version} (${contents.metadata.kind})`);
2888
2904
  console.log(` payload files: ${contents.files.length}, catalog files: ${contents.catalogFiles.length}, tree digest ${contents.treeDigest.slice(0, 16)}\u2026`);
2889
2905
  if (contents.catalog) {
2890
2906
  const docs = Number(!!contents.catalog.readme) + Number(!!contents.catalog.changelog);
@@ -2934,9 +2950,9 @@ function registerPackage(program2) {
2934
2950
  params: { publisherId: publisher.id },
2935
2951
  query: { PageNo: 1, PageSize: 100 }
2936
2952
  });
2937
- output(pageItems(page), { name: "Name", kind: "Kind", visibility: "Visibility", latestPublishedVersion: "Latest", id: "Id" }, options, page);
2953
+ output(pageItems(page), { packageId: "Package", name: "Runtime", kind: "Kind", visibility: "Visibility", latestPublishedVersion: "Latest", id: "Id" }, options, page);
2938
2954
  });
2939
- pkgCmd.command("info <ref>").description("Show package details (ref: 'name' or 'publisher/name')").option("--json", "output JSON").action(async (ref, options) => {
2955
+ pkgCmd.command("info <ref>").description("Show package details (ref: 'package-id' or 'publisher/package-id')").option("--json", "output JSON").action(async (ref, options) => {
2940
2956
  const api = await createApiClient();
2941
2957
  const { package: pkg } = await resolvePackageRef(api, ref);
2942
2958
  const detail = await call(api, marketplace.getPackage, { params: { id: pkg.id } });
@@ -3215,21 +3231,22 @@ function registerRegistry(program2) {
3215
3231
  if (publisher.name !== contents.metadata.publisher) {
3216
3232
  throw new Error(`Package declares publisher '${contents.metadata.publisher}' but you are '${publisher.name}'.`);
3217
3233
  }
3218
- let pkg = await findPackageByName(api, publisher.id, contents.metadata.name);
3234
+ let pkg = await findPackageByPackageId(api, publisher.id, contents.metadata["package-id"]);
3219
3235
  if (!pkg) {
3220
3236
  const visibility = options.visibility === "Public" ? "Public" : "Private";
3221
3237
  const id = await createPackage(api, {
3222
3238
  publisherId: publisher.id,
3239
+ packageId: contents.metadata["package-id"],
3223
3240
  name: contents.metadata.name,
3224
3241
  displayName: contents.metadata["display-name"] ?? contents.metadata.name,
3225
3242
  kind: contents.metadata.kind,
3226
3243
  visibility
3227
3244
  });
3228
- console.log(`Created package ${publisher.name}/${contents.metadata.name} (${visibility.toLowerCase()}).`);
3245
+ console.log(`Created package ${publisher.name}/${contents.metadata["package-id"]} (${visibility.toLowerCase()}).`);
3229
3246
  pkg = { id };
3230
3247
  }
3231
3248
  const version = await uploadVersion(api, pkg.id, selectedPath);
3232
- console.log(`Published ${publisher.name}/${contents.metadata.name}@${version.version} \u2192 ${version.status}`);
3249
+ console.log(`Published ${publisher.name}/${contents.metadata["package-id"]}@${version.version} \u2192 ${version.status}`);
3233
3250
  if (version.status === "Submitted") {
3234
3251
  console.log("The version is queued for moderation; it becomes installable once approved and published.");
3235
3252
  }
@@ -3246,7 +3263,7 @@ function registerRegistry(program2) {
3246
3263
  const effectiveVersion = version ?? pkg.latestPublishedVersion ?? void 0;
3247
3264
  if (!effectiveVersion) throw new Error(`Package '${ref}' has no published version.`);
3248
3265
  const res = await downloadTarball(api, pkg.id, effectiveVersion, options.workspace);
3249
- const outPath = resolve(options.out ?? `${pkg.name}-${effectiveVersion}.vpkg`);
3266
+ const outPath = resolve(options.out ?? `${pkg.packageId}-${effectiveVersion}.vpkg`);
3250
3267
  if (!res.body) throw new Error("Empty download response.");
3251
3268
  await pipeline(Readable.fromWeb(res.body), createWriteStream(outPath));
3252
3269
  console.log(`Downloaded ${ref}@${effectiveVersion} \u2192 ${outPath}`);
@@ -3264,7 +3281,7 @@ function registerRegistry(program2) {
3264
3281
  }
3265
3282
  for (const pkg of items) {
3266
3283
  const version = pkg.latestPublishedVersion ? `@${pkg.latestPublishedVersion}` : " (no published version)";
3267
- console.log(`${pkg.publisherName}/${pkg.name}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
3284
+ console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
3268
3285
  }
3269
3286
  });
3270
3287
  program2.command("install <ref> [version]").description("Install a package into a workspace").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").action(async (ref, version, options) => {