@ai-ecoverse/slicc-kernel 1.178.2 → 1.178.4

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.
@@ -7518,7 +7518,7 @@ var init_version = __esm({
7518
7518
  "src/version.ts"() {
7519
7519
  "use strict";
7520
7520
  init_captured_globals();
7521
- KERNEL_VERSION = true ? "1.178.2" : "0.0.0-dev";
7521
+ KERNEL_VERSION = true ? "1.178.4" : "0.0.0-dev";
7522
7522
  OS_RELEASE = "6.0.0-slicc";
7523
7523
  }
7524
7524
  });
@@ -7517,7 +7517,7 @@ var init_version = __esm({
7517
7517
  "src/version.ts"() {
7518
7518
  "use strict";
7519
7519
  init_captured_globals();
7520
- KERNEL_VERSION = true ? "1.178.2" : "0.0.0-dev";
7520
+ KERNEL_VERSION = true ? "1.178.4" : "0.0.0-dev";
7521
7521
  OS_RELEASE = "6.0.0-slicc";
7522
7522
  }
7523
7523
  });
package/dist/node.js CHANGED
@@ -868,13 +868,6 @@ async function linkable(g, from, to, follow2) {
868
868
  }
869
869
  await inParent(g, "link", to);
870
870
  }
871
- async function ownerOnly(g, op, path, follow2) {
872
- const walked = await need(g, op, path, 0, { follow: follow2 });
873
- const perm = walked.perm;
874
- if (!perm || g.cred.euid === 0 || perm.uid === g.cred.euid) return walked;
875
- if (await present(g.fs, walked.path, false)) deny(g, op, path, "EPERM");
876
- return walked;
877
- }
878
871
  async function chmodMode(g, path, mode) {
879
872
  const walked = await need(g, "chmod", path, 0, { follow: true });
880
873
  const perm = walked.perm;
@@ -896,17 +889,26 @@ function heldChmodMode(g, path, st, mode) {
896
889
  function heldRetimable(g, path, st, now) {
897
890
  const perm = permOf(st);
898
891
  if (g.cred.euid === 0 || perm.uid === g.cred.euid) return;
899
- if (!now) deny(g, "futimens", path, "EPERM");
900
- else if (!permits(g.cred, perm, W_OK, false)) deny(g, "futimens", path);
892
+ if (now || st.fat) {
893
+ if (!permits(g.cred, perm, W_OK, false)) deny(g, "futimens", path);
894
+ return;
895
+ }
896
+ deny(g, "futimens", path, "EPERM");
901
897
  }
902
898
  async function retimable(g, op, path, now = false) {
903
899
  const follow2 = op !== "lutimes";
904
- if (!now) return void await ownerOnly(g, op, path, follow2);
905
900
  const walked = await need(g, op, path, 0, { follow: follow2 });
906
901
  const perm = walked.perm;
907
902
  if (!perm || g.cred.euid === 0 || perm.uid === g.cred.euid) return;
908
- if (permits(g.cred, perm, W_OK, false)) return;
909
- if (await present(g.fs, walked.path, false)) deny(g, op, path);
903
+ const look = follow2 ? g.fs.stat : g.fs.lstat;
904
+ const st = await look.call(g.fs, walked.path).catch(() => void 0);
905
+ if (now || st?.fat) {
906
+ if (!permits(g.cred, perm, W_OK, false) && await present(g.fs, walked.path, false)) {
907
+ deny(g, op, path);
908
+ }
909
+ return;
910
+ }
911
+ if (await present(g.fs, walked.path, false)) deny(g, op, path, "EPERM");
910
912
  }
911
913
  async function fileWritable(g, op, path) {
912
914
  await need(g, op, path, W_OK, { directory: false });
@@ -3709,7 +3711,7 @@ function satisfies(version, range2) {
3709
3711
  }
3710
3712
 
3711
3713
  // src/version.ts
3712
- var KERNEL_VERSION = true ? "1.178.2" : "0.0.0-dev";
3714
+ var KERNEL_VERSION = true ? "1.178.4" : "0.0.0-dev";
3713
3715
  var OS_RELEASE = "6.0.0-slicc";
3714
3716
  function procVersion() {
3715
3717
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -12773,11 +12775,11 @@ function systemFile(name2, listing, now, memory) {
12773
12775
  listing.processes.reduce((sum2, p) => sum2 + p.memory, 0)
12774
12776
  );
12775
12777
  }
12776
- const live = listing.processes.filter((p) => p.state !== "Z");
12778
+ const live2 = listing.processes.filter((p) => p.state !== "Z");
12777
12779
  if (name2 === "loadavg") {
12778
12780
  const last = Math.max(0, ...listing.processes.map((p) => p.pid));
12779
12781
  const [one, five, fifteen] = (listing.load ?? [0, 0, 0]).map((n) => n.toFixed(2));
12780
- return `${one} ${five} ${fifteen} 1/${live.length} ${last}
12782
+ return `${one} ${five} ${fifteen} 1/${live2.length} ${last}
12781
12783
  `;
12782
12784
  }
12783
12785
  const sum = (key) => listing.cpu?.[key] ?? listing.processes.reduce((n, p) => n + (p[key] ?? 0), 0);
@@ -15266,30 +15268,49 @@ function timestampKey(owner, type) {
15266
15268
  }
15267
15269
  return parent ? JSON.stringify(["ppid", parent.pid, parent.started]) : void 0;
15268
15270
  }
15271
+ function boundKey(bound3) {
15272
+ return JSON.stringify(
15273
+ Object.keys(bound3).sort().map((path) => [path, bound3[path]])
15274
+ );
15275
+ }
15276
+ function writable2(bound3) {
15277
+ return bound3 !== void 0 && Object.keys(bound3).length > 0;
15278
+ }
15279
+ function live(stamp, policy, now) {
15280
+ return stamp.at <= now && (policy.minutes < 0 || now - stamp.at < policy.minutes * MINUTE_MS2);
15281
+ }
15269
15282
  var Timestamps = class {
15270
15283
  users = /* @__PURE__ */ new Map();
15271
15284
  now;
15272
15285
  constructor(now) {
15273
15286
  this.now = now;
15274
15287
  }
15275
- current(owner, policy) {
15288
+ current(owner, policy, bound3) {
15276
15289
  if (policy.minutes === 0) return false;
15277
15290
  const key = timestampKey(owner, policy.type);
15278
- const at = key === void 0 ? void 0 : this.users.get(owner.uid)?.get(key);
15279
- if (at === void 0) return false;
15291
+ const stamp = key === void 0 ? void 0 : this.users.get(owner.uid)?.get(key);
15292
+ if (stamp === void 0) return false;
15280
15293
  const now = this.now();
15281
- return at <= now && (policy.minutes < 0 || now - at < policy.minutes * MINUTE_MS2);
15294
+ if (!live(stamp, policy, now)) {
15295
+ this.drop(owner.uid, key);
15296
+ return false;
15297
+ }
15298
+ if (!writable2(bound3)) return true;
15299
+ return stamp.covered.has(boundKey(bound3));
15282
15300
  }
15283
- stamp(owner, policy) {
15301
+ stamp(owner, policy, bound3) {
15284
15302
  const key = policy.minutes === 0 ? void 0 : timestampKey(owner, policy.type);
15285
15303
  if (key === void 0) return false;
15286
15304
  const now = this.now();
15287
15305
  const records = this.users.get(owner.uid) ?? /* @__PURE__ */ new Map();
15288
15306
  this.users.set(owner.uid, records);
15307
+ const prior = records.get(key);
15308
+ const covered = prior !== void 0 && live(prior, policy, now) ? prior.covered : /* @__PURE__ */ new Set();
15309
+ if (writable2(bound3)) covered.add(boundKey(bound3));
15289
15310
  records.delete(key);
15290
- records.set(key, now);
15291
- for (const [old, at] of records) {
15292
- const stale = policy.minutes > 0 && (at > now || now - at >= policy.minutes * MINUTE_MS2);
15311
+ records.set(key, { at: now, covered });
15312
+ for (const [old, stamp] of records) {
15313
+ const stale = policy.minutes > 0 && !live(stamp, policy, now);
15293
15314
  if (stale || records.size > TIMESTAMPS_MAX) records.delete(old);
15294
15315
  }
15295
15316
  return true;
@@ -15303,6 +15324,11 @@ var Timestamps = class {
15303
15324
  remove(uid) {
15304
15325
  this.users.delete(uid);
15305
15326
  }
15327
+ drop(uid, key) {
15328
+ const records = this.users.get(uid);
15329
+ records?.delete(key);
15330
+ if (records?.size === 0) this.users.delete(uid);
15331
+ }
15306
15332
  };
15307
15333
 
15308
15334
  // src/sudoers.ts
@@ -16309,12 +16335,12 @@ function usable(parsed2) {
16309
16335
  function policyOf(settings) {
16310
16336
  return { type: settings.timestampType, minutes: settings.timestampTimeout };
16311
16337
  }
16312
- function described(rule, writable2) {
16338
+ function described(rule, writable3) {
16313
16339
  const cmnd = rule.cmnd === "*" ? "ALL" : commandText(rule.cmnd);
16314
16340
  const cwd = rule.cwd === void 0 ? "" : `CWD=${quoteWord(rule.cwd)} `;
16315
16341
  const stdin = rule.stdin === void 0 ? "" : "STDIN=none ";
16316
16342
  const sums = Object.entries(rule.sha256 ?? {}).map(([path, hex4]) => `SHA256=${quoteWord(path)}:${hex4} `).join("");
16317
- const flag = writable2 ? " # user-writable command" : "";
16343
+ const flag = writable3 ? " # user-writable command" : "";
16318
16344
  return ` (${rule.target}) ${cwd}${stdin}${sums}${rule.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
16319
16345
  }
16320
16346
  var Sudo = class {
@@ -16607,8 +16633,8 @@ var Sudo = class {
16607
16633
  `sudo: ${self.name} is not allowed to run ${quoted} as ${target.name}`
16608
16634
  );
16609
16635
  }
16610
- if (!parsed2.reset && this.timestamps.current(s.owner, s.policy)) {
16611
- this.timestamps.stamp(s.owner, s.policy);
16636
+ if (!parsed2.reset && this.timestamps.current(s.owner, s.policy, bound3)) {
16637
+ this.timestamps.stamp(s.owner, s.policy, bound3);
16612
16638
  this.logged(s, cwd, argv);
16613
16639
  return grant();
16614
16640
  }
@@ -16623,7 +16649,7 @@ var Sudo = class {
16623
16649
  if (!now) return failed2("ENOENT", `sudo: ${word}: command not found`);
16624
16650
  const shown2 = recordable(cwd, [...parsed2.command, ...Object.keys(bound3)]);
16625
16651
  const result = answer2.answer === "once" ? grant() : await this.always(self, target, { cwd, argv, bound: bound3 }, now, shown2, grant);
16626
- if (!("error" in result)) this.stamped(s, answer2);
16652
+ if (!("error" in result)) this.stamped(s, answer2, bound3);
16627
16653
  return result;
16628
16654
  });
16629
16655
  }
@@ -16657,8 +16683,8 @@ var Sudo = class {
16657
16683
  this.pending.delete(uid);
16658
16684
  }
16659
16685
  }
16660
- stamped(s, answer2) {
16661
- if (answer2.person && !s.parsed.reset) this.timestamps.stamp(s.owner, s.policy);
16686
+ stamped(s, answer2, bound3 = {}) {
16687
+ if (answer2.person && !s.parsed.reset) this.timestamps.stamp(s.owner, s.policy, bound3);
16662
16688
  }
16663
16689
  logged(s, cwd, argv) {
16664
16690
  const { caller, self, target, owner, policy } = s;
@@ -22858,18 +22884,18 @@ var VfsNodes = class {
22858
22884
  if (id2 !== void 0) this.know(node, id2);
22859
22885
  return node;
22860
22886
  }
22861
- open(path, pin, writable2 = false, id2, ino) {
22887
+ open(path, pin, writable3 = false, id2, ino) {
22862
22888
  const found = this.named(path, id2);
22863
22889
  const same2 = !found || ino === void 0 || found.ino === void 0 || found.ino === ino;
22864
22890
  if (found && !same2) this.orphan(found);
22865
22891
  const node = (same2 ? found : void 0) ?? this.create(path, id2, new VfsNode(this.fs, path, void 0, false, false, pin));
22866
22892
  node.ino ??= ino;
22867
22893
  node.opens++;
22868
- if (writable2) node.writers++;
22894
+ if (writable3) node.writers++;
22869
22895
  if (node.opens === 1) this.opened?.(node);
22870
22896
  return node;
22871
22897
  }
22872
- adopt(path, contents2, dirty, writable2 = false, id2) {
22898
+ adopt(path, contents2, dirty, writable3 = false, id2) {
22873
22899
  let node = this.named(path, id2);
22874
22900
  if (!node) {
22875
22901
  node = this.create(path, id2, new VfsNode(this.fs, path, contents2, false, dirty));
@@ -22877,7 +22903,7 @@ var VfsNodes = class {
22877
22903
  node.replace(contents2);
22878
22904
  }
22879
22905
  node.opens++;
22880
- if (writable2) node.writers++;
22906
+ if (writable3) node.writers++;
22881
22907
  if (node.opens === 1) this.opened?.(node);
22882
22908
  return node;
22883
22909
  }
@@ -22890,11 +22916,11 @@ var VfsNodes = class {
22890
22916
  if (node.writers > 0 && within7(path, prefix)) return true;
22891
22917
  return false;
22892
22918
  }
22893
- closed(node, writable2 = false) {
22919
+ closed(node, writable3 = false) {
22894
22920
  node.opens--;
22895
- if (writable2) node.writers--;
22921
+ if (writable3) node.writers--;
22896
22922
  if (node.opens > 0) {
22897
- if (writable2 && node.writers === 0) this.onClosed?.(node.path);
22923
+ if (writable3 && node.writers === 0) this.onClosed?.(node.path);
22898
22924
  return;
22899
22925
  }
22900
22926
  this.forget(node);
@@ -23213,8 +23239,8 @@ function keepingOpen(fs, nodes, changed = () => {
23213
23239
  function vfsFile(fs, opts, nodes) {
23214
23240
  const access2 = opts.flags & O_ACCMODE;
23215
23241
  const readable2 = access2 !== O_WRONLY;
23216
- const writable2 = access2 === O_WRONLY || access2 === O_RDWR;
23217
- const node = !nodes || opts.orphan ? new VfsNode(fs, opts.path, opts.contents, opts.orphan === true, opts.dirty === true) : opts.contents !== void 0 ? nodes.adopt(opts.path, opts.contents, opts.dirty === true, writable2, opts.id) : nodes.open(opts.path, opts.pin, writable2, opts.id, opts.ino);
23242
+ const writable3 = access2 === O_WRONLY || access2 === O_RDWR;
23243
+ const node = !nodes || opts.orphan ? new VfsNode(fs, opts.path, opts.contents, opts.orphan === true, opts.dirty === true) : opts.contents !== void 0 ? nodes.adopt(opts.path, opts.contents, opts.dirty === true, writable3, opts.id) : nodes.open(opts.path, opts.pin, writable3, opts.id, opts.ino);
23218
23244
  let openError;
23219
23245
  const atOpen = (op) => {
23220
23246
  void node.serial(op).catch((err) => {
@@ -23241,7 +23267,7 @@ function vfsFile(fs, opts, nodes) {
23241
23267
  offset += out.length;
23242
23268
  return out;
23243
23269
  }) : void 0,
23244
- write: writable2 ? (bytes) => serial(async () => {
23270
+ write: writable3 ? (bytes) => serial(async () => {
23245
23271
  if (opts.flags & O_APPEND) offset = await node.append(bytes);
23246
23272
  else offset += await node.pwrite(bytes, offset);
23247
23273
  return bytes.length;
@@ -23260,11 +23286,11 @@ function vfsFile(fs, opts, nodes) {
23260
23286
  return node.pread(max, at);
23261
23287
  }),
23262
23288
  pwrite: (bytes, at) => serial(() => {
23263
- if (!writable2) throw new KernelError("EBADF");
23289
+ if (!writable3) throw new KernelError("EBADF");
23264
23290
  return node.pwrite(bytes, at);
23265
23291
  }),
23266
23292
  resize: (size) => serial(() => {
23267
- if (!writable2) throw new KernelError("EBADF");
23293
+ if (!writable3) throw new KernelError("EBADF");
23268
23294
  return node.truncate(size);
23269
23295
  }),
23270
23296
  stat: () => serial(async () => ({
@@ -23280,7 +23306,7 @@ function vfsFile(fs, opts, nodes) {
23280
23306
  takeOpenError();
23281
23307
  await node.flush();
23282
23308
  } finally {
23283
- nodes?.closed(node, writable2);
23309
+ nodes?.closed(node, writable3);
23284
23310
  }
23285
23311
  })
23286
23312
  });
@@ -25009,8 +25035,8 @@ var WasmProcess = class {
25009
25035
  };
25010
25036
  withDl(state) {
25011
25037
  if (this.dlLog.length === 0) return state;
25012
- const { next: next3, handle, free, live } = this.closures;
25013
- const dl = { log: [...this.dlLog], next: next3, handle, free: [...free], live: [...live] };
25038
+ const { next: next3, handle, free, live: live2 } = this.closures;
25039
+ const dl = { log: [...this.dlLog], next: next3, handle, free: [...free], live: [...live2] };
25014
25040
  return { ...state, dl };
25015
25041
  }
25016
25042
  seedDl(dl) {
@@ -26228,8 +26254,8 @@ var RemoteWatch = class {
26228
26254
  const { held = [], pending = [] } = await this.locks.query();
26229
26255
  if (![...held, ...pending].some((lock) => lock.name === name2)) {
26230
26256
  this.mourned.delete(peer);
26231
- const live = this.peers.has(peer) || this.flushes.has(peer);
26232
- if (tries > 1 && live) {
26257
+ const live2 = this.peers.has(peer) || this.flushes.has(peer);
26258
+ if (tries > 1 && live2) {
26233
26259
  setTimeout(() => void this.mourn(peer, tries - 1), MOURN_RETRY_MS);
26234
26260
  } else this.flushedAt(peer);
26235
26261
  return;
@@ -28437,11 +28463,11 @@ async function positioned(handle, op) {
28437
28463
  }
28438
28464
  return;
28439
28465
  }
28440
- const writable2 = await handle.createWritable({ keepExistingData: true });
28466
+ const writable3 = await handle.createWritable({ keepExistingData: true });
28441
28467
  try {
28442
28468
  await op({
28443
28469
  write: async (at, bytes) => {
28444
- await writable2.write({
28470
+ await writable3.write({
28445
28471
  type: "write",
28446
28472
  position: at,
28447
28473
  data: bytes
@@ -28449,15 +28475,15 @@ async function positioned(handle, op) {
28449
28475
  extent.wrote(at + bytes.length);
28450
28476
  },
28451
28477
  truncate: async (n) => {
28452
- await writable2.truncate(n);
28478
+ await writable3.truncate(n);
28453
28479
  extent.cut(n);
28454
28480
  }
28455
28481
  });
28456
28482
  } catch (err) {
28457
- await writable2.abort();
28483
+ await writable3.abort();
28458
28484
  throw err;
28459
28485
  }
28460
- await writable2.close();
28486
+ await writable3.close();
28461
28487
  if (extent.big()) extent.check((await handle.getFile()).size);
28462
28488
  }
28463
28489
  function isHandle(child) {
@@ -29539,21 +29565,21 @@ var OpfsFs = class {
29539
29565
  }
29540
29566
  async writeSession(path, truncate) {
29541
29567
  const [handle, , target] = await this.fileFor(path);
29542
- const writable2 = await this.retrying(
29568
+ const writable3 = await this.retrying(
29543
29569
  path,
29544
29570
  () => this.io(handle.createWritable({ keepExistingData: !truncate })),
29545
29571
  true
29546
29572
  );
29547
29573
  return {
29548
- write: (at, bytes) => writable2.write({ type: "write", position: at, data: bytes }).catch((err) => {
29574
+ write: (at, bytes) => writable3.write({ type: "write", position: at, data: bytes }).catch((err) => {
29549
29575
  throw translate(err, path, "write", false);
29550
29576
  }),
29551
- truncate: (size) => writable2.truncate(size).catch((err) => {
29577
+ truncate: (size) => writable3.truncate(size).catch((err) => {
29552
29578
  throw translate(err, path, "write", false);
29553
29579
  }),
29554
29580
  close: async () => {
29555
29581
  this.wrote(handle);
29556
- await writable2.close().catch((err) => {
29582
+ await writable3.close().catch((err) => {
29557
29583
  this.wrote(handle);
29558
29584
  throw translate(err, path, "commit", false);
29559
29585
  });
@@ -29605,19 +29631,19 @@ var OpfsFs = class {
29605
29631
  const [file, existed, target] = await this.fileFor(path, owner?.existing !== true);
29606
29632
  if (!existed) await this.stampNew(target, owner, false);
29607
29633
  if (!existed && content.length === 0) return;
29608
- let writable2;
29634
+ let writable3;
29609
29635
  this.wrote(file);
29610
29636
  try {
29611
- writable2 = await this.io(file.createWritable());
29612
- await writable2.write(content);
29613
- await writable2.close();
29637
+ writable3 = await this.io(file.createWritable());
29638
+ await writable3.write(content);
29639
+ await writable3.close();
29614
29640
  if (typeof content !== "string" && content.length >= CHECKED_BYTES) {
29615
29641
  const extent = new Extent();
29616
29642
  extent.cut(content.length);
29617
29643
  extent.check((await file.getFile()).size);
29618
29644
  }
29619
29645
  } catch (err) {
29620
- await writable2?.abort().catch(() => void 0);
29646
+ await writable3?.abort().catch(() => void 0);
29621
29647
  throw translate(err, path, "commit", false);
29622
29648
  } finally {
29623
29649
  this.wrote(file);
@@ -30342,7 +30368,7 @@ var OpfsFs = class {
30342
30368
  created4 = true;
30343
30369
  }
30344
30370
  let target = destination;
30345
- let writable2;
30371
+ let writable3;
30346
30372
  let handle;
30347
30373
  try {
30348
30374
  const kept = created4 ? this.files.get(destination) : void 0;
@@ -30361,11 +30387,11 @@ var OpfsFs = class {
30361
30387
  if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
30362
30388
  }
30363
30389
  this.wrote(handle);
30364
- writable2 = await handle.createWritable();
30365
- await writable2.write(file);
30366
- await writable2.close();
30390
+ writable3 = await handle.createWritable();
30391
+ await writable3.write(file);
30392
+ await writable3.close();
30367
30393
  } catch (err) {
30368
- await writable2?.abort().catch(() => void 0);
30394
+ await writable3?.abort().catch(() => void 0);
30369
30395
  if (created4) await this.rm(target, { file: true }).catch(() => void 0);
30370
30396
  throw translate(err, to, "commit", false);
30371
30397
  } finally {
@@ -30454,10 +30480,10 @@ var OpfsFs = class {
30454
30480
  }
30455
30481
  if (handle.kind === "file") {
30456
30482
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
30457
- const writable2 = await this.io(made2.createWritable());
30483
+ const writable3 = await this.io(made2.createWritable());
30458
30484
  const file = await this.io(handle.getFile());
30459
- await writable2.write(file);
30460
- await writable2.close();
30485
+ await writable3.write(file);
30486
+ await writable3.close();
30461
30487
  copies?.set(rest2, { before: copies.get(rest2)?.before ?? file.lastModified, made: made2 });
30462
30488
  return;
30463
30489
  }
@@ -31169,7 +31195,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
31169
31195
  if (remote.client.token === remote.token && !remote.client.gone) return remote;
31170
31196
  throw fsError2("ESTALE", "the folder was granted again, so this open file is gone");
31171
31197
  };
31172
- const live = (fh) => {
31198
+ const live2 = (fh) => {
31173
31199
  const remote = handles.get(fh);
31174
31200
  if (!remote) throw fsError2("EBADF", `handle ${fh}`);
31175
31201
  return fresh3(remote);
@@ -31188,7 +31214,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
31188
31214
  }, againMs);
31189
31215
  timer.unref?.();
31190
31216
  });
31191
- async function writable2(client, path, flags2) {
31217
+ async function writable3(client, path, flags2) {
31192
31218
  const { ifMatch: _, ...asked } = flags2;
31193
31219
  const opening2 = () => client.call("open", { path: rel(path), ...asked });
31194
31220
  try {
@@ -31219,7 +31245,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
31219
31245
  async open(path, flags2) {
31220
31246
  const client = current();
31221
31247
  const token = client.token;
31222
- const { opened: opened2, restore } = await writable2(client, path, flags2);
31248
+ const { opened: opened2, restore } = await writable3(client, path, flags2);
31223
31249
  if (flags2.ifMatch !== void 0 && opened2.attr?.etag !== flags2.ifMatch) {
31224
31250
  await client.call("release", { fh: opened2.fh }, true);
31225
31251
  throw fsError2("ESTALE", `${path} changed on the host while it was being read`);
@@ -31234,7 +31260,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
31234
31260
  return nextFh;
31235
31261
  },
31236
31262
  async read(fh, offset, size) {
31237
- const remote = live(fh);
31263
+ const remote = live2(fh);
31238
31264
  return remote.client.read(
31239
31265
  remote.fh,
31240
31266
  offset,
@@ -31243,7 +31269,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
31243
31269
  );
31244
31270
  },
31245
31271
  async write(fh, offset, bytes) {
31246
- const remote = live(fh);
31272
+ const remote = live2(fh);
31247
31273
  const most = remote.client.maxIo;
31248
31274
  for (let at = 0; at < bytes.length; at += most) {
31249
31275
  await remote.client.write(remote.fh, offset + at, bytes.subarray(at, at + most));
@@ -37250,7 +37276,7 @@ function dialStream(port, onClose) {
37250
37276
  else finish(errorWithCode(data.error));
37251
37277
  });
37252
37278
  port.start?.();
37253
- const writable2 = new WritableStream({
37279
+ const writable3 = new WritableStream({
37254
37280
  write(chunk2) {
37255
37281
  if (closed) throw errorWithCode("EPIPE: the connection is closed");
37256
37282
  const copy = fresh(chunk2);
@@ -37269,7 +37295,7 @@ function dialStream(port, onClose) {
37269
37295
  shut();
37270
37296
  finish(error);
37271
37297
  };
37272
- return { readable: readable2, writable: writable2, close, fail: fail3 };
37298
+ return { readable: readable2, writable: writable3, close, fail: fail3 };
37273
37299
  }
37274
37300
 
37275
37301
  // src/client/loopback-fetch.ts
@@ -37695,10 +37721,10 @@ function endedOf(done4, signal) {
37695
37721
  async function runOn(channel, argv, opts) {
37696
37722
  const { onStdout, onStderr, ...rest2 } = opts;
37697
37723
  const chunks2 = { 1: [], 2: [] };
37698
- const live = { 1: new TextDecoder(), 2: new TextDecoder() };
37724
+ const live2 = { 1: new TextDecoder(), 2: new TextDecoder() };
37699
37725
  const tee = (fd, on) => (bytes) => {
37700
37726
  chunks2[fd].push(bytes);
37701
- on?.(live[fd].decode(bytes, { stream: true }));
37727
+ on?.(live2[fd].decode(bytes, { stream: true }));
37702
37728
  };
37703
37729
  const child = await spawnOn(channel, argv, {
37704
37730
  ...rest2,
@@ -37913,7 +37939,7 @@ var TERMINATED = "the kernel is terminated";
37913
37939
  var EXIT_GRACE_MS = 50;
37914
37940
  var WARM_IDLE_MS = 3e4;
37915
37941
  var MAX_WARM_WORKERS = 64;
37916
- function warmPool(make, live, idleMs = WARM_IDLE_MS, size = 1) {
37942
+ function warmPool(make, live2, idleMs = WARM_IDLE_MS, size = 1) {
37917
37943
  const spares = [];
37918
37944
  let idle2;
37919
37945
  let closed = false;
@@ -37923,7 +37949,7 @@ function warmPool(make, live, idleMs = WARM_IDLE_MS, size = 1) {
37923
37949
  spares.splice(at, 1);
37924
37950
  if (spares.length > 0) return;
37925
37951
  clearTimeout(idle2);
37926
- live.delete(kill);
37952
+ live2.delete(kill);
37927
37953
  };
37928
37954
  const kill = () => {
37929
37955
  for (const worker of [...spares]) {
@@ -37944,7 +37970,7 @@ function warmPool(make, live, idleMs = WARM_IDLE_MS, size = 1) {
37944
37970
  worker.once("error", () => drop(worker));
37945
37971
  worker.once("exit", () => drop(worker));
37946
37972
  spares.push(worker);
37947
- live.add(kill);
37973
+ live2.add(kill);
37948
37974
  }
37949
37975
  clearTimeout(idle2);
37950
37976
  idle2 = setTimeout(kill, idleMs);
@@ -38017,12 +38043,12 @@ function sourceModule(source) {
38017
38043
  return { url, source, revoke: () => {
38018
38044
  } };
38019
38045
  }
38020
- function warmPoolOf(options, file, workerData, live) {
38046
+ function warmPoolOf(options, file, workerData, live2) {
38021
38047
  const size = sparesOf(options);
38022
38048
  if (size === 0) return void 0;
38023
- return warmPool(() => processWorker(file, workerData, true), live, WARM_IDLE_MS, size);
38049
+ return warmPool(() => processWorker(file, workerData, true), live2, WARM_IDLE_MS, size);
38024
38050
  }
38025
- function nodeWorker(file, live, closed, workerData, take, internals = false) {
38051
+ function nodeWorker(file, live2, closed, workerData, take, internals = false) {
38026
38052
  const errors = /* @__PURE__ */ new Set();
38027
38053
  const messages = /* @__PURE__ */ new Map();
38028
38054
  const fail3 = (message3) => {
@@ -38039,9 +38065,9 @@ function nodeWorker(file, live, closed, workerData, take, internals = false) {
38039
38065
  void worker.terminate();
38040
38066
  fail3(TERMINATED);
38041
38067
  };
38042
- live.add(kill);
38068
+ live2.add(kill);
38043
38069
  worker.once("exit", (code) => {
38044
- live.delete(kill);
38070
+ live2.delete(kill);
38045
38071
  setTimeout(() => {
38046
38072
  if (!ending) fail3(`the process worker exited with ${code}`);
38047
38073
  }, EXIT_GRACE_MS);
@@ -38198,23 +38224,23 @@ async function createNodeKernel(options = {}) {
38198
38224
  const root = options.root ?? memoryRoot();
38199
38225
  const fs = new OpfsFs(root, void 0, void 0, { ranged: isMemoryRoot(root) });
38200
38226
  await fs.reconcile();
38201
- const live = /* @__PURE__ */ new Set();
38227
+ const live2 = /* @__PURE__ */ new Set();
38202
38228
  const pending = /* @__PURE__ */ new Set();
38203
38229
  const clients = /* @__PURE__ */ new Set();
38204
38230
  let terminated = false;
38205
38231
  const file = options.worker ?? new URL("./node-process-worker.cjs", import.meta.url);
38206
38232
  const cache = cacheDirOf(options.compileCache);
38207
38233
  const workerData = cacheData(cache);
38208
- const warm = warmPoolOf(options, file, workerData, live);
38234
+ const warm = warmPoolOf(options, file, workerData, live2);
38209
38235
  const transport = options.network?.transport;
38210
38236
  const launcher = new Launcher({
38211
38237
  fs,
38212
38238
  moduleUrl: sourceModule,
38213
38239
  unlinkOwner: pidOwner(process),
38214
- createWorker: () => nodeWorker(file, live, terminated, workerData, warm ? () => warm.take() : void 0, true),
38240
+ createWorker: () => nodeWorker(file, live2, terminated, workerData, warm ? () => warm.take() : void 0, true),
38215
38241
  createDriverWorker: () => nodeWorker(
38216
38242
  options.driverWorker ?? new URL("./node-driver-worker.js", import.meta.url),
38217
- live,
38243
+ live2,
38218
38244
  terminated
38219
38245
  ),
38220
38246
  ...options.modules ? { modules: options.modules } : {},
@@ -38345,7 +38371,7 @@ async function createNodeKernel(options = {}) {
38345
38371
  warm?.close();
38346
38372
  for (const client of [...clients]) client.detach();
38347
38373
  for (const reject of [...pending]) reject(new Error(TERMINATED));
38348
- for (const kill of [...live]) kill();
38374
+ for (const kill of [...live2]) kill();
38349
38375
  launcher.cdp.close();
38350
38376
  launcher.endFills();
38351
38377
  launcher.unmountAll();