buckyos 0.7.185 → 0.7.187

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/cli/dist/cli.mjs CHANGED
@@ -4678,12 +4678,96 @@ const EXT_TOOLS_PLATFORMS = [
4678
4678
  function extToolsPlatformOfKey(key) {
4679
4679
  return EXT_TOOLS_PLATFORMS.find((platform) => platform.key === key);
4680
4680
  }
4681
+ const EXT_TOOLS_VERSION = /^[A-Za-z0-9._+-]+$/;
4682
+ const EXT_TOOLS_ONLINE_FORMATS = ["zip", "tar.gz"];
4683
+ function unknownKeys(value, allowed) {
4684
+ return Object.keys(value).filter((key) => !allowed.includes(key));
4685
+ }
4686
+ function isHttpsUrl(value) {
4687
+ if (typeof value !== "string")
4688
+ return false;
4689
+ try {
4690
+ const url = new URL(value);
4691
+ return url.protocol === "https:" && url.hostname !== "";
4692
+ } catch {
4693
+ return false;
4694
+ }
4695
+ }
4696
+ function extToolsOnlineSourceErrors(item, raw) {
4697
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
4698
+ return ["must be an object"];
4699
+ const source = raw;
4700
+ const errors = unknownKeys(source, ["url", "sha256", "size_bytes", "format", "into", "rename", "overlay"]).map((key) => `${key} is not a field`);
4701
+ if (!isHttpsUrl(source.url))
4702
+ errors.push(`url ${JSON.stringify(source.url)} must be an https address`);
4703
+ if (typeof source.sha256 !== "string" || !/^[0-9a-fA-F]{64}$/.test(source.sha256))
4704
+ errors.push("sha256 must be 64 hex digits");
4705
+ if (!Number.isSafeInteger(source.size_bytes) || source.size_bytes <= 0)
4706
+ errors.push("size_bytes must be the size of the archive");
4707
+ if (typeof source.format !== "string" || !EXT_TOOLS_ONLINE_FORMATS.includes(source.format))
4708
+ errors.push(`format ${JSON.stringify(source.format)} must be zip or tar.gz`);
4709
+ if (source.into !== void 0 && (typeof source.into !== "string" || !isSafeRelativePath(source.into)))
4710
+ errors.push("into must be a relative path inside the item");
4711
+ const pairs = source.rename === void 0 ? [] : source.rename;
4712
+ const renamed = Array.isArray(pairs) && pairs.every(
4713
+ (pair) => Array.isArray(pair) && pair.length === 2 && pair.every((path) => typeof path === "string" && isSafeRelativePath(path)) && pair[0] !== pair[1]
4714
+ );
4715
+ if (!renamed)
4716
+ errors.push("rename must be [from, to] pairs of relative paths inside the item");
4717
+ const root = `online/${item}`;
4718
+ const overlay = source.overlay;
4719
+ if (overlay !== void 0 && !(typeof overlay === "string" && isSafeRelativePath(overlay) && (overlay === root || overlay.startsWith(`${root}/`)))) {
4720
+ errors.push(`overlay must be ${root} or a directory below it`);
4721
+ }
4722
+ return errors;
4723
+ }
4724
+ function extToolsOnlineErrors(manifest) {
4725
+ const errors = [];
4726
+ const items = /* @__PURE__ */ new Set();
4727
+ if (manifest.online === void 0)
4728
+ return { errors, items };
4729
+ if (!Array.isArray(manifest.online))
4730
+ return { errors: ["online must be a list of items"], items };
4731
+ const platforms = Array.isArray(manifest.platforms) ? manifest.platforms : [];
4732
+ for (const raw of manifest.online) {
4733
+ const item = raw ?? {};
4734
+ const id = item.id;
4735
+ if (typeof id !== "string" || !EXT_TOOLS_ID.test(id)) {
4736
+ errors.push(`online: id ${JSON.stringify(id)} must be lowercase letters, digits and -`);
4737
+ continue;
4738
+ }
4739
+ if (items.has(id))
4740
+ errors.push(`online: ${id} is listed twice`);
4741
+ items.add(id);
4742
+ for (const key of unknownKeys(item, ["id", "version", "desc", "license", "auto", "platforms"]))
4743
+ errors.push(`online ${id}: ${key} is not a field`);
4744
+ if (typeof item.version !== "string" || !EXT_TOOLS_VERSION.test(item.version))
4745
+ errors.push(`online ${id}: version must be letters, digits and ._+-`);
4746
+ for (const text2 of ["desc", "license"])
4747
+ if (item[text2] !== void 0 && typeof item[text2] !== "string")
4748
+ errors.push(`online ${id}: ${text2} must be a string`);
4749
+ if (item.auto !== void 0 && typeof item.auto !== "boolean")
4750
+ errors.push(`online ${id}: auto must be true or false`);
4751
+ const sources = item.platforms;
4752
+ if (!sources || typeof sources !== "object" || Array.isArray(sources) || Object.keys(sources).length === 0) {
4753
+ errors.push(`online ${id}: platforms must not be empty`);
4754
+ continue;
4755
+ }
4756
+ for (const [platform, source] of Object.entries(sources)) {
4757
+ if (!platforms.includes(platform))
4758
+ errors.push(`online ${id}: ${platform} is not a platform of the package`);
4759
+ for (const problem of extToolsOnlineSourceErrors(id, source))
4760
+ errors.push(`online ${id} on ${platform}: ${problem}`);
4761
+ }
4762
+ }
4763
+ return { errors, items };
4764
+ }
4681
4765
  function extToolsManifestErrors(value) {
4682
4766
  if (!value || typeof value !== "object" || Array.isArray(value))
4683
4767
  return ["must be a JSON object"];
4684
4768
  const manifest = value;
4685
4769
  const errors = [];
4686
- const allowed = ["schema", "id", "version", "requires", "conflicts", "provides", "platforms", "size_bytes", "license", "desc"];
4770
+ const allowed = ["schema", "id", "version", "requires", "conflicts", "provides", "platforms", "size_bytes", "license", "desc", "online"];
4687
4771
  for (const key of Object.keys(manifest))
4688
4772
  if (!allowed.includes(key))
4689
4773
  errors.push(`${key} is not a field of the manifest`);
@@ -4691,10 +4775,12 @@ function extToolsManifestErrors(value) {
4691
4775
  errors.push(`schema must be ${EXT_TOOLS_MANIFEST_SCHEMA}`);
4692
4776
  if (typeof manifest.id !== "string" || !EXT_TOOLS_ID.test(manifest.id))
4693
4777
  errors.push("id must be lowercase letters, digits and -");
4694
- if (typeof manifest.version !== "string" || !/^[A-Za-z0-9._+-]+$/.test(manifest.version))
4778
+ if (typeof manifest.version !== "string" || !EXT_TOOLS_VERSION.test(manifest.version))
4695
4779
  errors.push("version must be letters, digits and ._+-");
4696
4780
  if (!Array.isArray(manifest.provides) || manifest.provides.length === 0)
4697
4781
  errors.push("provides must not be empty");
4782
+ const online = extToolsOnlineErrors(manifest);
4783
+ errors.push(...online.errors);
4698
4784
  const commands = /* @__PURE__ */ new Set();
4699
4785
  for (const raw of Array.isArray(manifest.provides) ? manifest.provides : []) {
4700
4786
  const entry = raw ?? {};
@@ -4708,12 +4794,24 @@ function extToolsManifestErrors(value) {
4708
4794
  if (EXT_TOOLS_RESERVED_COMMANDS.includes(command2))
4709
4795
  errors.push(`provides: ${command2} is a standard command and cannot be provided by a package`);
4710
4796
  commands.add(command2);
4797
+ for (const key of unknownKeys(entry, ["command", "version_probe", "smoke", "needs"]))
4798
+ errors.push(`provides: ${key} is not a field of ${command2}`);
4711
4799
  if (typeof entry.version_probe !== "string" || !entry.version_probe.trim())
4712
4800
  errors.push(`provides: ${command2} has no version_probe`);
4713
4801
  const smoke = entry.smoke;
4714
4802
  if (smoke !== void 0 && (typeof smoke !== "string" || !isSafeRelativePath(smoke))) {
4715
4803
  errors.push(`provides: the smoke of ${command2} must be a relative path inside the payload`);
4716
4804
  }
4805
+ const needs = entry.needs === void 0 ? [] : entry.needs;
4806
+ if (!Array.isArray(needs) || !needs.every((need) => typeof need === "string")) {
4807
+ errors.push(`provides: the needs of ${command2} must list online items by id`);
4808
+ continue;
4809
+ }
4810
+ for (const need of needs)
4811
+ if (!online.items.has(need))
4812
+ errors.push(`provides: ${command2} needs ${need}, which is not an online item of the package`);
4813
+ if (new Set(needs).size !== needs.length)
4814
+ errors.push(`provides: ${command2} needs an online item twice`);
4717
4815
  }
4718
4816
  if (!Array.isArray(manifest.platforms) || manifest.platforms.length === 0)
4719
4817
  errors.push("platforms must not be empty");
@@ -4754,14 +4852,23 @@ function extToolsPayloadErrors(manifest, platform, tree, buildPaths = []) {
4754
4852
  const errors = [];
4755
4853
  const windows = platform.startsWith("windows-");
4756
4854
  const suffixes = windows ? EXT_TOOLS_WINDOWS_SUFFIXES : [""];
4855
+ const online = manifest.online ?? [];
4757
4856
  for (const path of [...tree.files.keys(), ...tree.directories]) {
4758
4857
  const [top, second] = path.split("/");
4759
4858
  const isTop = !path.includes("/");
4760
- const known = top === EXT_TOOLS_MANIFEST_FILE && isTop || top === "bin" || top === "smoke" || top === "store";
4859
+ const known = top === EXT_TOOLS_MANIFEST_FILE && isTop || top === "bin" || top === "smoke" || top === "store" || top === "online";
4761
4860
  if (!known)
4762
- errors.push(`${path}: a package only holds ${EXT_TOOLS_MANIFEST_FILE}, bin/, smoke/ and store/${manifest.id}/`);
4861
+ errors.push(`${path}: a package only holds ${EXT_TOOLS_MANIFEST_FILE}, bin/, smoke/, store/${manifest.id}/ and online/<item>/`);
4763
4862
  if (top === "store" && second !== void 0 && second !== manifest.id)
4764
4863
  errors.push(`${path}: a package only writes store/${manifest.id}/`);
4864
+ if (top === "online" && second !== void 0 && !online.some((item) => item.id === second))
4865
+ errors.push(`${path}: not an online item of the package`);
4866
+ }
4867
+ for (const item of online) {
4868
+ const overlay = item.platforms[platform]?.overlay;
4869
+ const present = overlay !== void 0 && (tree.directories.has(overlay) || [...tree.files.keys()].some((path) => path.startsWith(`${overlay}/`)));
4870
+ if (overlay !== void 0 && !present)
4871
+ errors.push(`${overlay}: the overlay of online item ${item.id} is missing`);
4765
4872
  }
4766
4873
  const declared = new Set(manifest.provides.map((provided) => provided.command));
4767
4874
  for (const provided of manifest.provides) {
@@ -6116,7 +6223,7 @@ async function readSkillDirectory(root, limit) {
6116
6223
  await walk(realRoot, "");
6117
6224
  return { files, ignored };
6118
6225
  }
6119
- const PACKAGE_VERSION = "0.7.185";
6226
+ const PACKAGE_VERSION = "0.7.187";
6120
6227
  const TOOL_VERSION = PACKAGE_VERSION;
6121
6228
  const SDK_VERSION = PACKAGE_VERSION;
6122
6229
  const PROTOCOL_VERSION = "1";
@@ -13374,15 +13481,45 @@ function desired(verb, summary2, enabled) {
13374
13481
  handler: (ctx, input) => call$1(ctx, input.dry_run === true ? "ext_tools.plan" : "ext_tools.set_desired", requestOf(input, enabled))
13375
13482
  };
13376
13483
  }
13484
+ function download() {
13485
+ return {
13486
+ verb: "download",
13487
+ summary: "Ask the nodes to download an online item of a package again: after a failure, or to replace what is there",
13488
+ positionals: [
13489
+ { name: "id", description: "Package id, e.g. ext-core" },
13490
+ { name: "item", description: "Online item id, e.g. chromium (see `online` in ext-tools status)" }
13491
+ ],
13492
+ options: [{ name: "node", description: "Only this node; without it every node that has the item", type: "string" }],
13493
+ inputSchema: {
13494
+ type: "object",
13495
+ properties: { id: ID$1, item: ID$1, node: { type: "string", minLength: 1 } },
13496
+ required: ["id", "item"],
13497
+ additionalProperties: false
13498
+ },
13499
+ outputSchema: OBJECT_OUTPUT$3,
13500
+ resultSchemaVersion: 1,
13501
+ access: { mode: "fixed", level: "write" },
13502
+ asyncMode: "sync",
13503
+ requiresSession: true,
13504
+ handler: (ctx, input) => {
13505
+ for (const name of ["id", "item"]) {
13506
+ if (typeof input[name] !== "string" || !input[name])
13507
+ throw new UsageError("MISSING_ARGUMENT", `a package id and an online item id are required`);
13508
+ }
13509
+ return call$1(ctx, "ext_tools.download", { id: input.id, item: input.item, ...typeof input.node === "string" ? { node: input.node } : {} });
13510
+ }
13511
+ };
13512
+ }
13377
13513
  function createExtToolsModule() {
13378
13514
  return {
13379
13515
  name: "ext-tools",
13380
13516
  summary: "Manage the extension tool packages every Agent of the Zone shares",
13381
13517
  commands: [
13382
13518
  read("list", "The packages published in the Repo, and what each provides", "ext_tools.catalog"),
13383
- read("status", "Package by node: what is asked for and where each node got to", "ext_tools.status"),
13519
+ read("status", "Package by node: what is asked for, where each node got to, and the online items it downloaded or still waits for", "ext_tools.status"),
13384
13520
  desired("enable", "Enable or upgrade a package, with the packages it requires", true),
13385
13521
  desired("disable", "Disable a package; refused while an enabled package requires it", false),
13522
+ download(),
13386
13523
  {
13387
13524
  verb: "import",
13388
13525
  summary: "Put an already built .pikg (an official release asset) into the Repo unchanged",
@@ -14612,7 +14749,7 @@ const setPropCommand = {
14612
14749
  };
14613
14750
  const infoCommand = {
14614
14751
  verb: "info",
14615
- summary: "Workspace info: versions, capabilities of the caller, usage, hosted execution configuration",
14752
+ summary: "Workspace info: versions, capabilities of the caller, usage, where wish runs execute by default",
14616
14753
  options: [WORKSPACE_OPTION],
14617
14754
  inputSchema: workspaceInput({}),
14618
14755
  outputSchema: OBJECT_OUTPUT,