@ai-ecoverse/slicc-kernel 1.140.3 → 1.140.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.
@@ -6721,7 +6721,7 @@ var KERNEL_VERSION, OS_RELEASE;
6721
6721
  var init_version = __esm({
6722
6722
  "src/version.ts"() {
6723
6723
  "use strict";
6724
- KERNEL_VERSION = true ? "1.140.3" : "0.0.0-dev";
6724
+ KERNEL_VERSION = true ? "1.140.5" : "0.0.0-dev";
6725
6725
  OS_RELEASE = "6.0.0-slicc";
6726
6726
  }
6727
6727
  });
package/dist/node.js CHANGED
@@ -7514,7 +7514,7 @@ function satisfies(version, range2) {
7514
7514
  }
7515
7515
 
7516
7516
  // src/version.ts
7517
- var KERNEL_VERSION = true ? "1.140.3" : "0.0.0-dev";
7517
+ var KERNEL_VERSION = true ? "1.140.5" : "0.0.0-dev";
7518
7518
  var OS_RELEASE = "6.0.0-slicc";
7519
7519
  function procVersion() {
7520
7520
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -7828,7 +7828,7 @@ function winners(tier) {
7828
7828
  }
7829
7829
  return out;
7830
7830
  }
7831
- async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION) {
7831
+ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused3) {
7832
7832
  const found = /* @__PURE__ */ new Map();
7833
7833
  const physical = physicalResolver(fs);
7834
7834
  const tiers = (typeof modules === "string" ? [modules] : modules).map(
@@ -7836,6 +7836,7 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
7836
7836
  );
7837
7837
  for (const [index, roots] of tiers.entries()) {
7838
7838
  const tier = await tierPackages(fs, physical, roots, index >= binsFrom, kernel);
7839
+ if (refused3) refused3.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
7839
7840
  for (const [name2, { pkg, command }] of winners(tier)) {
7840
7841
  if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
7841
7842
  }
@@ -25055,13 +25056,20 @@ function dohForward(transport, url) {
25055
25056
  return collect(res.body, DOH_MAX);
25056
25057
  };
25057
25058
  }
25059
+ async function writeAll5(conn, bytes) {
25060
+ for (let at = 0; at < bytes.length; ) {
25061
+ const n = await conn.write(bytes.subarray(at));
25062
+ if (!(n > 0)) throw new Error("the uplink wrote nothing");
25063
+ at += n;
25064
+ }
25065
+ }
25058
25066
  function uplinkForward(uplink, server) {
25059
25067
  return async (query, signal) => {
25060
25068
  const conn = await uplink.dial({ network: "tcp", host: server, port: DNS_PORT, signal });
25061
25069
  const stop = () => conn.close();
25062
25070
  signal.addEventListener("abort", stop, { once: true });
25063
25071
  try {
25064
- await conn.write(new Uint8Array([query.length >> 8, query.length & 255, ...query]));
25072
+ await writeAll5(conn, new Uint8Array([query.length >> 8, query.length & 255, ...query]));
25065
25073
  let got = new Uint8Array();
25066
25074
  for (; ; ) {
25067
25075
  if (got.length >= 2 && got.length >= 2 + u16(got, 0)) return got.slice(2, 2 + u16(got, 0));
@@ -27360,7 +27368,13 @@ function refusing(command) {
27360
27368
  args: [`${command.name}: ${command.refused}`],
27361
27369
  refused: command.refused,
27362
27370
  shows: command.script ?? command.wasm,
27363
- origin: { abi: command.abi, glue: command.glue, wasm: command.wasm }
27371
+ origin: {
27372
+ abi: command.abi,
27373
+ glue: command.glue,
27374
+ wasm: command.wasm,
27375
+ ...command.variants ? { variants: command.variants.map((one) => one.wasm) } : {},
27376
+ ...command.script ? { script: true } : {}
27377
+ }
27364
27378
  };
27365
27379
  }
27366
27380
 
@@ -28325,7 +28339,16 @@ var Launcher = class {
28325
28339
  if (!found) {
28326
28340
  found = this.trustedAppended().then(async (appended2) => {
28327
28341
  const tiers = await this.tiers(scope, appended2);
28328
- return scanCommands(this.scanned, tiers, tiers.length - appended2.length);
28342
+ const refused3 = [];
28343
+ const commands = await scanCommands(
28344
+ this.scanned,
28345
+ tiers,
28346
+ tiers.length - appended2.length,
28347
+ void 0,
28348
+ refused3
28349
+ );
28350
+ this.refusedOf.set(commands, refused3.map(refusing));
28351
+ return commands;
28329
28352
  }).then(
28330
28353
  (commands) => this.refusals(commands).set(SUDO_COMMAND.name, SUDO_COMMAND).set(CRONTAB_COMMAND.name, CRONTAB_COMMAND)
28331
28354
  );
@@ -28333,6 +28356,7 @@ var Launcher = class {
28333
28356
  }
28334
28357
  return found;
28335
28358
  }
28359
+ refusedOf = /* @__PURE__ */ new WeakMap();
28336
28360
  refusals(commands) {
28337
28361
  for (const [name2, command] of commands) {
28338
28362
  if (!command.refused) continue;
@@ -28486,22 +28510,30 @@ var Launcher = class {
28486
28510
  return await this.commandAt(path, scope) ?? await this.refusedAt(path, name2, scope);
28487
28511
  }
28488
28512
  async refusedAt(path, name2, scope) {
28489
- const refused3 = [...(await this.commands(scope)).values()].filter((c) => c.origin);
28490
- if (refused3.length === 0 || !await this.base.exists(path)) return void 0;
28513
+ const refused3 = this.refusedOf.get(await this.commands(scope)) ?? [];
28514
+ if (refused3.length === 0) return void 0;
28515
+ const st = await this.base.stat(path).catch(() => void 0);
28516
+ if (!st?.isFile) return void 0;
28491
28517
  const real = await physicalPathAsync(this.base, path).catch(() => path);
28492
- const at = async (c, which) => {
28493
- const own = c.origin[which];
28494
- return own === path || await physicalPathAsync(this.base, own).catch(() => own) === real;
28495
- };
28518
+ const same2 = async (own) => own === path || await physicalPathAsync(this.base, own).catch(() => own) === real;
28496
28519
  const owners = [];
28497
28520
  for (const c of refused3) {
28498
- if (await at(c, "glue") || await at(c, "wasm")) owners.push(c);
28521
+ const origin = c.origin;
28522
+ for (const own of [origin.glue, origin.wasm, ...origin.variants ?? []]) {
28523
+ if (!await same2(own)) continue;
28524
+ owners.push(c);
28525
+ break;
28526
+ }
28499
28527
  }
28500
- if (owners.length > 0) return owners.find((c) => c.name === name2) ?? owners[0];
28528
+ const stem = name2.replace(/\.wasm$/, "");
28529
+ const named = owners.find((c) => c.name === name2) ?? owners.find((c) => c.name === stem);
28530
+ return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused3);
28531
+ }
28532
+ async refusedCopy(real, name2, refused3) {
28501
28533
  const dir = real.slice(0, real.lastIndexOf("/"));
28502
28534
  for (const c of refused3) {
28503
28535
  const origin = c.origin;
28504
- if (origin.abi !== "emscripten" || c.name !== name2) continue;
28536
+ if (origin.abi !== "emscripten" || origin.script || c.name !== name2) continue;
28505
28537
  const own = await physicalPathAsync(this.base, origin.glue).catch(() => origin.glue);
28506
28538
  if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real, own)) return c;
28507
28539
  }