@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.
@@ -7128,7 +7128,7 @@ function satisfies(version, range2) {
7128
7128
  }
7129
7129
 
7130
7130
  // src/version.ts
7131
- var KERNEL_VERSION = true ? "1.140.3" : "0.0.0-dev";
7131
+ var KERNEL_VERSION = true ? "1.140.5" : "0.0.0-dev";
7132
7132
  var OS_RELEASE = "6.0.0-slicc";
7133
7133
  function procVersion() {
7134
7134
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -7442,7 +7442,7 @@ function winners(tier) {
7442
7442
  }
7443
7443
  return out;
7444
7444
  }
7445
- async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION) {
7445
+ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused3) {
7446
7446
  const found = /* @__PURE__ */ new Map();
7447
7447
  const physical = physicalResolver(fs);
7448
7448
  const tiers = (typeof modules === "string" ? [modules] : modules).map(
@@ -7450,6 +7450,7 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
7450
7450
  );
7451
7451
  for (const [index, roots] of tiers.entries()) {
7452
7452
  const tier = await tierPackages(fs, physical, roots, index >= binsFrom, kernel);
7453
+ if (refused3) refused3.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
7453
7454
  for (const [name2, { pkg, command }] of winners(tier)) {
7454
7455
  if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
7455
7456
  }
@@ -25207,13 +25208,20 @@ function dohForward(transport, url) {
25207
25208
  return collect(res.body, DOH_MAX);
25208
25209
  };
25209
25210
  }
25211
+ async function writeAll5(conn, bytes) {
25212
+ for (let at = 0; at < bytes.length; ) {
25213
+ const n = await conn.write(bytes.subarray(at));
25214
+ if (!(n > 0)) throw new Error("the uplink wrote nothing");
25215
+ at += n;
25216
+ }
25217
+ }
25210
25218
  function uplinkForward(uplink, server) {
25211
25219
  return async (query, signal) => {
25212
25220
  const conn = await uplink.dial({ network: "tcp", host: server, port: DNS_PORT, signal });
25213
25221
  const stop = () => conn.close();
25214
25222
  signal.addEventListener("abort", stop, { once: true });
25215
25223
  try {
25216
- await conn.write(new Uint8Array([query.length >> 8, query.length & 255, ...query]));
25224
+ await writeAll5(conn, new Uint8Array([query.length >> 8, query.length & 255, ...query]));
25217
25225
  let got = new Uint8Array();
25218
25226
  for (; ; ) {
25219
25227
  if (got.length >= 2 && got.length >= 2 + u16(got, 0)) return got.slice(2, 2 + u16(got, 0));
@@ -27440,7 +27448,13 @@ function refusing(command) {
27440
27448
  args: [`${command.name}: ${command.refused}`],
27441
27449
  refused: command.refused,
27442
27450
  shows: command.script ?? command.wasm,
27443
- origin: { abi: command.abi, glue: command.glue, wasm: command.wasm }
27451
+ origin: {
27452
+ abi: command.abi,
27453
+ glue: command.glue,
27454
+ wasm: command.wasm,
27455
+ ...command.variants ? { variants: command.variants.map((one) => one.wasm) } : {},
27456
+ ...command.script ? { script: true } : {}
27457
+ }
27444
27458
  };
27445
27459
  }
27446
27460
 
@@ -28409,7 +28423,16 @@ var Launcher = class {
28409
28423
  if (!found) {
28410
28424
  found = this.trustedAppended().then(async (appended2) => {
28411
28425
  const tiers = await this.tiers(scope, appended2);
28412
- return scanCommands(this.scanned, tiers, tiers.length - appended2.length);
28426
+ const refused3 = [];
28427
+ const commands = await scanCommands(
28428
+ this.scanned,
28429
+ tiers,
28430
+ tiers.length - appended2.length,
28431
+ void 0,
28432
+ refused3
28433
+ );
28434
+ this.refusedOf.set(commands, refused3.map(refusing));
28435
+ return commands;
28413
28436
  }).then(
28414
28437
  (commands) => this.refusals(commands).set(SUDO_COMMAND.name, SUDO_COMMAND).set(CRONTAB_COMMAND.name, CRONTAB_COMMAND)
28415
28438
  );
@@ -28417,6 +28440,7 @@ var Launcher = class {
28417
28440
  }
28418
28441
  return found;
28419
28442
  }
28443
+ refusedOf = /* @__PURE__ */ new WeakMap();
28420
28444
  refusals(commands) {
28421
28445
  for (const [name2, command] of commands) {
28422
28446
  if (!command.refused) continue;
@@ -28570,22 +28594,30 @@ var Launcher = class {
28570
28594
  return await this.commandAt(path, scope) ?? await this.refusedAt(path, name2, scope);
28571
28595
  }
28572
28596
  async refusedAt(path, name2, scope) {
28573
- const refused3 = [...(await this.commands(scope)).values()].filter((c) => c.origin);
28574
- if (refused3.length === 0 || !await this.base.exists(path)) return void 0;
28597
+ const refused3 = this.refusedOf.get(await this.commands(scope)) ?? [];
28598
+ if (refused3.length === 0) return void 0;
28599
+ const st = await this.base.stat(path).catch(() => void 0);
28600
+ if (!st?.isFile) return void 0;
28575
28601
  const real = await physicalPathAsync(this.base, path).catch(() => path);
28576
- const at = async (c, which) => {
28577
- const own = c.origin[which];
28578
- return own === path || await physicalPathAsync(this.base, own).catch(() => own) === real;
28579
- };
28602
+ const same3 = async (own) => own === path || await physicalPathAsync(this.base, own).catch(() => own) === real;
28580
28603
  const owners = [];
28581
28604
  for (const c of refused3) {
28582
- if (await at(c, "glue") || await at(c, "wasm")) owners.push(c);
28605
+ const origin = c.origin;
28606
+ for (const own of [origin.glue, origin.wasm, ...origin.variants ?? []]) {
28607
+ if (!await same3(own)) continue;
28608
+ owners.push(c);
28609
+ break;
28610
+ }
28583
28611
  }
28584
- if (owners.length > 0) return owners.find((c) => c.name === name2) ?? owners[0];
28612
+ const stem = name2.replace(/\.wasm$/, "");
28613
+ const named = owners.find((c) => c.name === name2) ?? owners.find((c) => c.name === stem);
28614
+ return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused3);
28615
+ }
28616
+ async refusedCopy(real, name2, refused3) {
28585
28617
  const dir = real.slice(0, real.lastIndexOf("/"));
28586
28618
  for (const c of refused3) {
28587
28619
  const origin = c.origin;
28588
- if (origin.abi !== "emscripten" || c.name !== name2) continue;
28620
+ if (origin.abi !== "emscripten" || origin.script || c.name !== name2) continue;
28589
28621
  const own = await physicalPathAsync(this.base, origin.glue).catch(() => origin.glue);
28590
28622
  if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real, own)) return c;
28591
28623
  }