buckyos 0.7.177 → 0.7.180

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
@@ -6114,7 +6114,7 @@ async function readSkillDirectory(root, limit) {
6114
6114
  await walk(realRoot, "");
6115
6115
  return { files, ignored };
6116
6116
  }
6117
- const PACKAGE_VERSION = "0.7.177";
6117
+ const PACKAGE_VERSION = "0.7.180";
6118
6118
  const TOOL_VERSION = PACKAGE_VERSION;
6119
6119
  const SDK_VERSION = PACKAGE_VERSION;
6120
6120
  const PROTOCOL_VERSION = "1";
@@ -6423,7 +6423,14 @@ async function doctorCommand(ctx, input) {
6423
6423
  }
6424
6424
  if (app.categories[0] === PATH_KINDS["ext-tools"].category) {
6425
6425
  const catalog2 = optionalInputString(input, "catalog");
6426
- checks.push(...await extToolsChecks(app, pikg, metaDir, catalog2 ? resolveFromCwd$1(ctx, catalog2) : void 0));
6426
+ checks.push(
6427
+ ...await extToolsChecks(
6428
+ app,
6429
+ pikg,
6430
+ metaDir,
6431
+ catalog2 ? resolveFromCwd$1(ctx, catalog2) : void 0
6432
+ )
6433
+ );
6427
6434
  }
6428
6435
  } catch (error) {
6429
6436
  checks.push({
@@ -6496,9 +6503,15 @@ async function initCommand(ctx, input, docker) {
6496
6503
  selector = platform.selector;
6497
6504
  sourceValue = {
6498
6505
  type: "path",
6499
- path: toPortablePath(relative(join(projectDir, "dapp_meta"), join(absoluteSource, "payload", platform.name)))
6506
+ path: toPortablePath(
6507
+ relative(join(projectDir, "dapp_meta"), join(absoluteSource, "payload", platform.name))
6508
+ )
6509
+ };
6510
+ sourceSummary2 = {
6511
+ type: "path",
6512
+ path: displaySource(projectDir, absoluteSource),
6513
+ platform: platform.name
6500
6514
  };
6501
- sourceSummary2 = { type: "path", path: displaySource(projectDir, absoluteSource), platform: platform.name };
6502
6515
  try {
6503
6516
  await getHost().lstat(join(absoluteSource, EXT_TOOLS_MANIFEST_FILE));
6504
6517
  } catch (error) {
@@ -6608,14 +6621,18 @@ async function skillLintCheck(packageName, source) {
6608
6621
  } else {
6609
6622
  files = /* @__PURE__ */ new Map();
6610
6623
  for (const entry of await readTarGz(await getHost().readFile(source), MAX_SKILL_SOURCE_BYTES)) {
6611
- if (SKILL_DIRS.includes(entry.path.split("/")[0]))
6624
+ if (SKILL_DIRS.includes(entry.path.split("/")[0])) {
6612
6625
  files.set(entry.path, { bytes: entry.bytes });
6613
- else
6626
+ } else
6614
6627
  ignored.push(entry.path);
6615
6628
  }
6616
6629
  }
6617
6630
  } catch (error) {
6618
- return { ...check, status: "error", detail: error instanceof Error ? error.message : String(error) };
6631
+ return {
6632
+ ...check,
6633
+ status: "error",
6634
+ detail: error instanceof Error ? error.message : String(error)
6635
+ };
6619
6636
  }
6620
6637
  const { skills, findings } = lintSkillPackage(packageName, files);
6621
6638
  const errors = findings.filter((finding) => finding.level === "error");
@@ -6624,7 +6641,13 @@ async function skillLintCheck(packageName, source) {
6624
6641
  status: errors.length ? "error" : "ok",
6625
6642
  ...errors.length ? { detail: errors.map((finding) => finding.note).join("; "), errors } : {},
6626
6643
  ...errors.length ? {} : { digest: skillContentDigest(files) },
6627
- skills: skills.map(({ kind, name, scope, size, commands }) => ({ kind, name, scope, size, commands })),
6644
+ skills: skills.map(({ kind, name, scope, size, commands }) => ({
6645
+ kind,
6646
+ name,
6647
+ scope,
6648
+ size,
6649
+ commands
6650
+ })),
6628
6651
  warnings: findings.filter((finding) => finding.level !== "error"),
6629
6652
  ...ignored.length ? { ignored_files: ignored } : {}
6630
6653
  };
@@ -6660,14 +6683,27 @@ async function writeAiwsSkeleton(dir, ownerDid, name, composite) {
6660
6683
  const encoder = new TextEncoder();
6661
6684
  const host2 = getHost();
6662
6685
  await host2.mkdir(join(dir, "controls", name), { recursive: true });
6663
- for (const [file, text2] of Object.entries(files))
6686
+ for (const [file, text2] of Object.entries(files)) {
6664
6687
  await host2.writeTextFile(join(dir, "controls", name, file), text2);
6665
- const digest = await aiwsContentDigest(Object.entries(files).map(([file, text2]) => [file, encoder.encode(text2)]));
6688
+ }
6689
+ const digest = await aiwsContentDigest(
6690
+ Object.entries(files).map(
6691
+ ([file, text2]) => [file, encoder.encode(text2)]
6692
+ )
6693
+ );
6666
6694
  const manifest = {
6667
6695
  manifest_version: AIWS_MANIFEST_VERSION,
6668
6696
  purpose: "aiws",
6669
6697
  host_api: composite ? {} : { declarative: 1 },
6670
- controls: [{ ident: `${ownerDid}#${name}`, name, kind, version: 1, digest, dir: `controls/${name}/`, title: name }],
6698
+ controls: [{
6699
+ ident: `${ownerDid}#${name}`,
6700
+ name,
6701
+ kind,
6702
+ version: 1,
6703
+ digest,
6704
+ dir: `controls/${name}/`,
6705
+ title: name
6706
+ }],
6671
6707
  workspace_templates: []
6672
6708
  };
6673
6709
  await host2.writeTextFile(join(dir, AIWS_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
@@ -6677,9 +6713,14 @@ function hostExtToolsPlatform() {
6677
6713
  const host2 = getHost();
6678
6714
  const os = host2.platform === "darwin" ? "macos" : host2.platform === "win32" ? "windows" : host2.platform;
6679
6715
  const arch = normalizeArch$1(host2.arch);
6680
- const platform = EXT_TOOLS_PLATFORMS.find((known) => known.selector.os === os && known.selector.arch === arch);
6716
+ const platform = EXT_TOOLS_PLATFORMS.find(
6717
+ (known) => known.selector.os === os && known.selector.arch === arch
6718
+ );
6681
6719
  if (!platform) {
6682
- throw new UsageError("UNSUPPORTED_PLATFORM", `extension packages have no payload for ${os}/${arch}`);
6720
+ throw new UsageError(
6721
+ "UNSUPPORTED_PLATFORM",
6722
+ `extension packages have no payload for ${os}/${arch}`
6723
+ );
6683
6724
  }
6684
6725
  return platform;
6685
6726
  }
@@ -6699,8 +6740,9 @@ async function writeExtToolsSkeleton(dir, id, version, platform) {
6699
6740
  const text2 = `${JSON.stringify(manifest, null, 2)}
6700
6741
  `;
6701
6742
  const payload = join(dir, "payload", platform);
6702
- for (const sub of ["bin", "smoke", join("store", id)])
6743
+ for (const sub of ["bin", "smoke", join("store", id)]) {
6703
6744
  await host2.mkdir(join(payload, sub), { recursive: true });
6745
+ }
6704
6746
  await host2.writeTextFile(join(dir, EXT_TOOLS_MANIFEST_FILE), text2);
6705
6747
  await host2.writeTextFile(join(payload, EXT_TOOLS_MANIFEST_FILE), text2);
6706
6748
  const windows = platform.startsWith("windows-");
@@ -6750,7 +6792,11 @@ async function readExtToolsManifestFile(path) {
6750
6792
  }
6751
6793
  async function readExtToolsPayloadTree(root) {
6752
6794
  const host2 = getHost();
6753
- const tree = { files: /* @__PURE__ */ new Map(), directories: /* @__PURE__ */ new Set(), launchers: /* @__PURE__ */ new Map() };
6795
+ const tree = {
6796
+ files: /* @__PURE__ */ new Map(),
6797
+ directories: /* @__PURE__ */ new Set(),
6798
+ launchers: /* @__PURE__ */ new Map()
6799
+ };
6754
6800
  const errors = [];
6755
6801
  const realRoot = await host2.realPath(root);
6756
6802
  const walk = async (directory, prefix) => {
@@ -6764,7 +6810,9 @@ async function readExtToolsPayloadTree(root) {
6764
6810
  try {
6765
6811
  physical = await host2.realPath(path);
6766
6812
  } catch (error) {
6767
- errors.push(`${archivePath}: ${isHostError(error, "NotFound") ? "a dangling symlink" : "a symlink out of the payload"}`);
6813
+ errors.push(
6814
+ `${archivePath}: ${isHostError(error, "NotFound") ? "a dangling symlink" : "a symlink out of the payload"}`
6815
+ );
6768
6816
  continue;
6769
6817
  }
6770
6818
  const inside = relative(realRoot, physical);
@@ -6806,20 +6854,27 @@ async function extToolsChecks(app, pikg, metaDir, catalogDir) {
6806
6854
  const source = sources.length > 0 ? dirname(dirname(sources[0])) : dirname(metaDir);
6807
6855
  const master = await readExtToolsManifestFile(join(source, EXT_TOOLS_MANIFEST_FILE));
6808
6856
  const manifestErrors = [...master.errors];
6809
- if (stray.length > 0)
6810
- manifestErrors.push(`sub packages must be ext_tools_<os>_<arch> from a directory: ${stray.join(", ")}`);
6857
+ if (stray.length > 0) {
6858
+ manifestErrors.push(
6859
+ `sub packages must be ext_tools_<os>_<arch> from a directory: ${stray.join(", ")}`
6860
+ );
6861
+ }
6811
6862
  const manifest = master.manifest;
6812
6863
  if (manifest) {
6813
- if (manifest.id !== app.name)
6864
+ if (manifest.id !== app.name) {
6814
6865
  manifestErrors.push(`id ${manifest.id} is not the App name ${app.name}`);
6815
- if (manifest.version !== app.version)
6866
+ }
6867
+ if (manifest.version !== app.version) {
6816
6868
  manifestErrors.push(`version ${manifest.version} is not the App version ${app.version}`);
6869
+ }
6817
6870
  const without = manifest.platforms.filter((name) => !platforms.has(name));
6818
- if (without.length > 0)
6871
+ if (without.length > 0) {
6819
6872
  manifestErrors.push(`platforms without a sub package: ${without.join(", ")}`);
6873
+ }
6820
6874
  const unlisted = [...platforms.keys()].filter((name) => !manifest.platforms.includes(name));
6821
- if (unlisted.length > 0)
6875
+ if (unlisted.length > 0) {
6822
6876
  manifestErrors.push(`sub packages of platforms it does not list: ${unlisted.join(", ")}`);
6877
+ }
6823
6878
  }
6824
6879
  checks.push({
6825
6880
  name: "ext_tools_manifest",
@@ -6835,10 +6890,11 @@ async function extToolsChecks(app, pikg, metaDir, catalogDir) {
6835
6890
  const { tree, errors: walkErrors } = await readExtToolsPayloadTree(dir);
6836
6891
  errors.push(...walkErrors);
6837
6892
  const copy = await readExtToolsManifestFile(join(dir, EXT_TOOLS_MANIFEST_FILE));
6838
- if (copy.errors.length > 0)
6893
+ if (copy.errors.length > 0) {
6839
6894
  errors.push(`${EXT_TOOLS_MANIFEST_FILE}: ${copy.errors.join("; ")}`);
6840
- else if (copy.text !== master.text)
6895
+ } else if (copy.text !== master.text) {
6841
6896
  errors.push(`${EXT_TOOLS_MANIFEST_FILE}: differs from the package's manifest`);
6897
+ }
6842
6898
  errors.push(...extToolsPayloadErrors(manifest, platform, tree, [source, metaDir]));
6843
6899
  } catch (error) {
6844
6900
  if (!isHostError(error, "NotFound"))
@@ -6866,13 +6922,16 @@ async function extToolsChecks(app, pikg, metaDir, catalogDir) {
6866
6922
  for (const entry of await getHost().readDir(catalogDir)) {
6867
6923
  if (entry.isFile)
6868
6924
  continue;
6869
- const candidate = await readExtToolsManifestFile(join(catalogDir, entry.name, EXT_TOOLS_MANIFEST_FILE));
6925
+ const candidate = await readExtToolsManifestFile(
6926
+ join(catalogDir, entry.name, EXT_TOOLS_MANIFEST_FILE)
6927
+ );
6870
6928
  if (candidate.errors.includes("not found"))
6871
6929
  continue;
6872
6930
  if (!candidate.manifest)
6873
6931
  catalogErrors.push(`${entry.name}: ${candidate.errors.join("; ")}`);
6874
- else if (candidate.manifest.id !== manifest.id)
6932
+ else if (candidate.manifest.id !== manifest.id) {
6875
6933
  others.set(candidate.manifest.id, candidate.manifest);
6934
+ }
6876
6935
  }
6877
6936
  for (const required of manifest.requires) {
6878
6937
  if (!others.has(required.id))
@@ -6882,9 +6941,14 @@ async function extToolsChecks(app, pikg, metaDir, catalogDir) {
6882
6941
  for (const other of others.values()) {
6883
6942
  if (manifest.conflicts.includes(other.id) || other.conflicts.includes(manifest.id))
6884
6943
  continue;
6885
- const shared = other.provides.map((provided) => provided.command).filter((command2) => commands.has(command2));
6886
- if (shared.length > 0)
6887
- catalogErrors.push(`${other.id} also provides ${shared.join(", ")}: one of the two must list the other in conflicts`);
6944
+ const shared = other.provides.map((provided) => provided.command).filter(
6945
+ (command2) => commands.has(command2)
6946
+ );
6947
+ if (shared.length > 0) {
6948
+ catalogErrors.push(
6949
+ `${other.id} also provides ${shared.join(", ")}: one of the two must list the other in conflicts`
6950
+ );
6951
+ }
6888
6952
  }
6889
6953
  checks.push({
6890
6954
  name: "ext_tools_catalog",
@@ -7257,7 +7321,11 @@ function parseAppMeta(value) {
7257
7321
  },
7258
7322
  categories,
7259
7323
  permissions,
7260
- ...value.content_handlers === void 0 ? {} : { content_handlers: developmentValidation(() => validateContentHandlers(value.content_handlers, permissions)) },
7324
+ ...value.content_handlers === void 0 ? {} : {
7325
+ content_handlers: developmentValidation(
7326
+ () => validateContentHandlers(value.content_handlers, permissions)
7327
+ )
7328
+ },
7261
7329
  selector_type: developmentString(value.selector_type, "app.json.selector_type"),
7262
7330
  service_config_tips: serviceConfig
7263
7331
  };
@@ -7483,18 +7551,26 @@ function assertSafeCleanTarget(ctx, metaDir, distDir, sourcePaths) {
7483
7551
  throw new ToolError("UNSAFE_CLEAN_TARGET", "refusing to clean an unsafe output directory");
7484
7552
  }
7485
7553
  }
7486
- async function replaceDirectory(temporary, destination) {
7487
- let exists = false;
7554
+ async function pathExists(path) {
7488
7555
  try {
7489
- await getHost().lstat(destination);
7490
- exists = true;
7556
+ await getHost().lstat(path);
7557
+ return true;
7491
7558
  } catch (error) {
7492
- if (!isHostError(error, "NotFound"))
7493
- throw error;
7559
+ if (isHostError(error, "NotFound"))
7560
+ return false;
7561
+ throw error;
7494
7562
  }
7495
- if (!exists) {
7496
- await getHost().rename(temporary, destination);
7497
- return;
7563
+ }
7564
+ async function replaceDirectory(temporary, destination) {
7565
+ if (!await pathExists(destination)) {
7566
+ try {
7567
+ await getHost().rename(temporary, destination);
7568
+ return;
7569
+ } catch (error) {
7570
+ if (getHost().platform !== "windows" || !isHostError(error, "PermissionDenied") || !await pathExists(destination)) {
7571
+ throw error;
7572
+ }
7573
+ }
7498
7574
  }
7499
7575
  const backup = `${destination}.previous-${crypto.randomUUID()}`;
7500
7576
  await getHost().rename(destination, backup);
@@ -14819,6 +14895,24 @@ async function runCli(host2, argv) {
14819
14895
  installHost(host2);
14820
14896
  return await new BuckyOSToolApplication().run(argv);
14821
14897
  }
14898
+ async function retryWindowsLock(windows, operation2, retryable, wait = defaultWait) {
14899
+ let attempt = 0;
14900
+ while (true) {
14901
+ try {
14902
+ return await operation2();
14903
+ } catch (error) {
14904
+ const delay = windows && retryable(error) ? wait(attempt) : 0;
14905
+ if (delay <= 0)
14906
+ throw error;
14907
+ attempt++;
14908
+ await new Promise((resolve2) => setTimeout(resolve2, delay));
14909
+ }
14910
+ }
14911
+ }
14912
+ function defaultWait(attempt) {
14913
+ const waits = [50, 100, 150, 250, 400, 600, 800];
14914
+ return waits[attempt] ?? 0;
14915
+ }
14822
14916
  async function assertPathAccess(policy2, path, realPath, candidate, operation2, resolveLinks = true) {
14823
14917
  const roots = operation2 === "read" ? policy2.readPaths : policy2.writePaths;
14824
14918
  const absolute = path.resolve(candidate);
@@ -14985,7 +15079,11 @@ class NodeHost {
14985
15079
  await this.assertPath(from, "write");
14986
15080
  await this.assertPath(to, "write");
14987
15081
  try {
14988
- await rename(from, to);
15082
+ await retryWindowsLock(
15083
+ this.platform === "windows",
15084
+ () => rename(from, to),
15085
+ nodeSharingViolation
15086
+ );
14989
15087
  } catch (error) {
14990
15088
  throw translateNodeError(error, `${from} -> ${to}`);
14991
15089
  }
@@ -14993,7 +15091,11 @@ class NodeHost {
14993
15091
  async remove(path, options = {}) {
14994
15092
  await this.assertPath(path, "write", false);
14995
15093
  try {
14996
- await rm(path, { recursive: options.recursive ?? false });
15094
+ await retryWindowsLock(
15095
+ this.platform === "windows",
15096
+ () => rm(path, { recursive: options.recursive ?? false }),
15097
+ nodeSharingViolation
15098
+ );
14997
15099
  } catch (error) {
14998
15100
  throw translateNodeError(error, path);
14999
15101
  }
@@ -15311,6 +15413,10 @@ async function readInputChunk() {
15311
15413
  process.stdin.once("error", onError);
15312
15414
  });
15313
15415
  }
15416
+ function nodeSharingViolation(error) {
15417
+ const code = error.code;
15418
+ return code === "EPERM" || code === "EACCES" || code === "EBUSY";
15419
+ }
15314
15420
  function translateNodeError(error, path) {
15315
15421
  if (error instanceof HostError)
15316
15422
  return error;