@ai-ecoverse/slicc-kernel 1.40.1 → 1.41.1

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/dist/node.js CHANGED
@@ -800,8 +800,8 @@ var KernelSocket = class _KernelSocket {
800
800
  async accept(signal, nonblock = false) {
801
801
  for (; ; ) {
802
802
  if (this.state !== "listening") throw new KernelError("EINVAL");
803
- const next = this.queue.shift();
804
- if (next) return next;
803
+ const next2 = this.queue.shift();
804
+ if (next2) return next2;
805
805
  if (nonblock) throw new KernelError("EAGAIN");
806
806
  await this.changes.wait(signal);
807
807
  }
@@ -982,8 +982,8 @@ var LoopbackNet = class {
982
982
  if (reserve) this.internal.add(port);
983
983
  return this.internal.has(port);
984
984
  }
985
- activate(addr, start) {
986
- this.activators.set(keyOf(addr), start);
985
+ activate(addr, start2) {
986
+ this.activators.set(keyOf(addr), start2);
987
987
  }
988
988
  socket(domain) {
989
989
  return new KernelSocket(this, domain);
@@ -1242,12 +1242,12 @@ var MessageQueue = class {
1242
1242
  }
1243
1243
  async *[Symbol.asyncIterator]() {
1244
1244
  for (; ; ) {
1245
- const next = this.items.shift();
1246
- if (next !== void 0) {
1247
- const n = payloadSize(next);
1245
+ const next2 = this.items.shift();
1246
+ if (next2 !== void 0) {
1247
+ const n = payloadSize(next2);
1248
1248
  this.size -= n;
1249
1249
  this.taken?.(n);
1250
- yield next;
1250
+ yield next2;
1251
1251
  continue;
1252
1252
  }
1253
1253
  if (this.ended) return;
@@ -1352,8 +1352,8 @@ async function* chunks(body, idleMs) {
1352
1352
  if (!body) return;
1353
1353
  const reader = body.getReader();
1354
1354
  try {
1355
- for (let next = await readWithin(reader, idleMs); !next.done; next = await readWithin(reader, idleMs)) {
1356
- if (next.value.byteLength > 0) yield next.value;
1355
+ for (let next2 = await readWithin(reader, idleMs); !next2.done; next2 = await readWithin(reader, idleMs)) {
1356
+ if (next2.value.byteLength > 0) yield next2.value;
1357
1357
  }
1358
1358
  } finally {
1359
1359
  await reader.cancel().catch(() => void 0);
@@ -1424,7 +1424,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1424
1424
  ...typeof code === "string" ? { code } : {}
1425
1425
  });
1426
1426
  };
1427
- const start = async (call) => {
1427
+ const start2 = async (call) => {
1428
1428
  const abort = new AbortController();
1429
1429
  const entry = { abort };
1430
1430
  open.set(call.nid, entry);
@@ -1503,9 +1503,9 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1503
1503
  try {
1504
1504
  const messages = socket.messages[Symbol.asyncIterator]();
1505
1505
  for (; ; ) {
1506
- const next = await Promise.race([messages.next(), unanswered]);
1507
- if (next === "late" || next.done) break;
1508
- const data = next.value;
1506
+ const next2 = await Promise.race([messages.next(), unanswered]);
1507
+ if (next2 === "late" || next2.done) break;
1508
+ const data = next2.value;
1509
1509
  if (flow.closing) continue;
1510
1510
  if (payloadSize(data) > MESSAGE_LIMIT) {
1511
1511
  oversize = true;
@@ -1546,12 +1546,12 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1546
1546
  const body = open.get(nid)?.body;
1547
1547
  if (!body) return;
1548
1548
  try {
1549
- const next = await body.next();
1550
- if (next.done) {
1549
+ const next2 = await body.next();
1550
+ if (next2.done) {
1551
1551
  open.delete(nid);
1552
1552
  peer.postMessage({ net: "end", nid });
1553
1553
  } else {
1554
- const bytes = next.value.slice();
1554
+ const bytes = next2.value.slice();
1555
1555
  peer.postMessage({ net: "chunk", nid, bytes }, [bytes.buffer]);
1556
1556
  }
1557
1557
  } catch (e) {
@@ -1568,7 +1568,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1568
1568
  };
1569
1569
  return {
1570
1570
  answer(call) {
1571
- if (call.net === "fetch") void start(call);
1571
+ if (call.net === "fetch") void start2(call);
1572
1572
  else if (call.net === "read") void read(call.nid);
1573
1573
  else if (call.net === "ws-open") void openSocket(call);
1574
1574
  else if (call.net === "ws-send") void sendOn(call);
@@ -1623,17 +1623,17 @@ async function realpath(fs, path) {
1623
1623
  let parts = fs.resolvePath("/", path).split("/").filter(Boolean);
1624
1624
  let resolved = "";
1625
1625
  for (let hops = 0; parts.length > 0; ) {
1626
- const [name2, ...rest] = parts;
1627
- const next = `${resolved}/${name2}`;
1628
- if (!(await fs.lstat(next)).isSymbolicLink) {
1629
- resolved = next;
1630
- parts = rest;
1626
+ const [name2, ...rest2] = parts;
1627
+ const next2 = `${resolved}/${name2}`;
1628
+ if (!(await fs.lstat(next2)).isSymbolicLink) {
1629
+ resolved = next2;
1630
+ parts = rest2;
1631
1631
  continue;
1632
1632
  }
1633
1633
  if (++hops > MAX_LINKS) throw fsError("ELOOP", path);
1634
- const target = await fs.readlink(next);
1634
+ const target = await fs.readlink(next2);
1635
1635
  const base = target.startsWith("/") ? "/" : resolved || "/";
1636
- parts = [...fs.resolvePath(base, target).split("/").filter(Boolean), ...rest];
1636
+ parts = [...fs.resolvePath(base, target).split("/").filter(Boolean), ...rest2];
1637
1637
  resolved = "";
1638
1638
  }
1639
1639
  return resolved || "/";
@@ -2079,8 +2079,8 @@ var OpfsFs = class {
2079
2079
  resolvePath(base, path) {
2080
2080
  return resolvePath(base, path);
2081
2081
  }
2082
- async walk(parts, from, start) {
2083
- let dir = start;
2082
+ async walk(parts, from, start2) {
2083
+ let dir = start2;
2084
2084
  for (let at = from; at < parts.length; at++) {
2085
2085
  dir = await dir.getDirectoryHandle(parts[at]);
2086
2086
  this.dirs.set(`/${parts.slice(0, at + 1).join("/")}`, dir);
@@ -2166,7 +2166,7 @@ var OpfsFs = class {
2166
2166
  }
2167
2167
  return void 0;
2168
2168
  }
2169
- async locate(path, follow) {
2169
+ async locate(path, follow2) {
2170
2170
  let current = path;
2171
2171
  for (let hops = 0; hops <= MAX_LINKS2; hops++) {
2172
2172
  try {
@@ -2175,9 +2175,9 @@ var OpfsFs = class {
2175
2175
  if (!missing(err)) throw err;
2176
2176
  const link2 = await this.linkAlong(current);
2177
2177
  if (!link2) throw err;
2178
- if (link2.path === current && !follow) return { path: current, link: link2 };
2179
- const rest = current.slice(link2.path.length);
2180
- current = resolvePath(parentOf2(link2.path), `${link2.link}${rest}`);
2178
+ if (link2.path === current && !follow2) return { path: current, link: link2 };
2179
+ const rest2 = current.slice(link2.path.length);
2180
+ current = resolvePath(parentOf2(link2.path), `${link2.link}${rest2}`);
2181
2181
  }
2182
2182
  }
2183
2183
  throw fsError("ELOOP", path);
@@ -2493,9 +2493,9 @@ var OpfsFs = class {
2493
2493
  return timed;
2494
2494
  }
2495
2495
  async restamp(path, timed) {
2496
- for (const rest of timed) {
2497
- const mtimeFor = await this.modified(path + rest);
2498
- await this.meta.update(path + rest, (entry) => entry && { ...entry, mtimeFor });
2496
+ for (const rest2 of timed) {
2497
+ const mtimeFor = await this.modified(path + rest2);
2498
+ await this.meta.update(path + rest2, (entry) => entry && { ...entry, mtimeFor });
2499
2499
  }
2500
2500
  }
2501
2501
  async place(handle, dir, name2) {
@@ -2543,8 +2543,8 @@ var OpfsFs = class {
2543
2543
  }));
2544
2544
  this.touch(parent.path);
2545
2545
  }
2546
- async realpath(path, follow) {
2547
- return (await this.locate(path, follow)).path;
2546
+ async realpath(path, follow2) {
2547
+ return (await this.locate(path, follow2)).path;
2548
2548
  }
2549
2549
  async readlink(path) {
2550
2550
  const found = await this.locate(path, false);
@@ -2674,9 +2674,9 @@ var UnlinkedKeeper = class {
2674
2674
  void locks?.request(lockName(this.instance), () => new Promise(() => void 0));
2675
2675
  }
2676
2676
  serial(op) {
2677
- const next = this.queue.then(op);
2678
- this.queue = next.catch(() => void 0);
2679
- return next;
2677
+ const next2 = this.queue.then(op);
2678
+ this.queue = next2.catch(() => void 0);
2679
+ return next2;
2680
2680
  }
2681
2681
  wrap(fs = this.fs) {
2682
2682
  const keeper = this;
@@ -2858,10 +2858,10 @@ var Incoming = class {
2858
2858
  this.eof = true;
2859
2859
  return false;
2860
2860
  }
2861
- const next = new Uint8Array(this.buf.length + chunk2.length);
2862
- next.set(this.buf);
2863
- next.set(chunk2, this.buf.length);
2864
- this.buf = next;
2861
+ const next2 = new Uint8Array(this.buf.length + chunk2.length);
2862
+ next2.set(this.buf);
2863
+ next2.set(chunk2, this.buf.length);
2864
+ this.buf = next2;
2865
2865
  return true;
2866
2866
  }
2867
2867
  take(n) {
@@ -3889,6 +3889,53 @@ function withCommandDirs(fs, names) {
3889
3889
  };
3890
3890
  }
3891
3891
 
3892
+ // src/fs/physical-path.ts
3893
+ var MAX_HOPS = 40;
3894
+ function start(path) {
3895
+ return { done: [], todo: path.split("/").filter((p) => p !== ""), hops: 0 };
3896
+ }
3897
+ function next(walk) {
3898
+ while (walk.todo.length > 0) {
3899
+ const part = walk.todo.shift();
3900
+ if (part === ".") continue;
3901
+ if (part === "..") {
3902
+ walk.done.pop();
3903
+ continue;
3904
+ }
3905
+ return part;
3906
+ }
3907
+ return void 0;
3908
+ }
3909
+ function lexical(path) {
3910
+ const walk = start(path);
3911
+ for (let part = next(walk); part !== void 0; part = next(walk)) walk.done.push(part);
3912
+ return `/${walk.done.join("/")}`;
3913
+ }
3914
+ function rest(walk, part) {
3915
+ return lexical(`/${[...walk.done, part, ...walk.todo].join("/")}`);
3916
+ }
3917
+ function follow(walk, target) {
3918
+ if (++walk.hops > MAX_HOPS) return false;
3919
+ if (target.startsWith("/")) walk.done.length = 0;
3920
+ walk.todo = [...target.split("/").filter((p) => p !== ""), ...walk.todo];
3921
+ return true;
3922
+ }
3923
+ async function physicalPathAsync(fs, path) {
3924
+ const walk = start(path);
3925
+ for (let part = next(walk); part !== void 0; part = next(walk)) {
3926
+ const at = `/${[...walk.done, part].join("/")}`;
3927
+ let target;
3928
+ try {
3929
+ target = (await fs.lstat(at)).isSymbolicLink ? await fs.readlink(at) : void 0;
3930
+ } catch {
3931
+ return rest(walk, part);
3932
+ }
3933
+ if (target === void 0) walk.done.push(part);
3934
+ else if (!follow(walk, target)) return lexical(path);
3935
+ }
3936
+ return `/${walk.done.join("/")}`;
3937
+ }
3938
+
3892
3939
  // src/fs/watch.ts
3893
3940
  var WATCH_BATCH_LIMIT = 1e3;
3894
3941
  var under2 = (path, dir) => dir === "/" || path.startsWith(`${dir}/`);
@@ -4052,10 +4099,10 @@ var ChildTable = class {
4052
4099
  }
4053
4100
  return this.track(req, fds, captured, this.spawner);
4054
4101
  }
4055
- async track(req, fds, captured, start) {
4102
+ async track(req, fds, captured, start2) {
4056
4103
  let handle;
4057
4104
  try {
4058
- handle = await start(req, fds);
4105
+ handle = await start2(req, fds);
4059
4106
  } catch (e) {
4060
4107
  await fds.closeAll();
4061
4108
  throw e;
@@ -5054,9 +5101,9 @@ var MountFs = class {
5054
5101
  this.table.forget(found.mount, normalizePath(path));
5055
5102
  await found.mount.conn.call({ op: "symlink", target, path: found.rel });
5056
5103
  }
5057
- async realpath(path, follow) {
5104
+ async realpath(path, follow2) {
5058
5105
  if (this.at(path) || !this.base.realpath) throw errnoError("ENOSYS", path);
5059
- const real = await this.base.realpath(path, follow);
5106
+ const real = await this.base.realpath(path, follow2);
5060
5107
  if (this.at(real)) throw errnoError("ENOSYS", path);
5061
5108
  return real;
5062
5109
  }
@@ -6204,15 +6251,15 @@ var octets = (bytes) => tlv(4, bytes);
6204
6251
  var bits = (bytes, unused = 0) => tlv(3, Uint8Array.of(unused), bytes);
6205
6252
  var TRUE = tlv(1, Uint8Array.of(255));
6206
6253
  function integer(magnitude) {
6207
- let start = 0;
6208
- while (start < magnitude.length - 1 && magnitude[start] === 0) start++;
6209
- const trimmed = magnitude.subarray(start);
6254
+ let start2 = 0;
6255
+ while (start2 < magnitude.length - 1 && magnitude[start2] === 0) start2++;
6256
+ const trimmed = magnitude.subarray(start2);
6210
6257
  return tlv(2, trimmed[0] & 128 ? concat4([Uint8Array.of(0), trimmed]) : trimmed);
6211
6258
  }
6212
6259
  function oid(dotted) {
6213
- const [a, b, ...rest] = dotted.split(".").map(Number);
6260
+ const [a, b, ...rest2] = dotted.split(".").map(Number);
6214
6261
  const out = [40 * a + b];
6215
- for (const arc of rest) {
6262
+ for (const arc of rest2) {
6216
6263
  const groups = [];
6217
6264
  for (let v = arc; ; v = Math.floor(v / 128)) {
6218
6265
  groups.unshift(v & 127);
@@ -6252,19 +6299,19 @@ function children(der) {
6252
6299
  function header(der, at) {
6253
6300
  const tag = der[at];
6254
6301
  let len = der[at + 1];
6255
- let start = at + 2;
6302
+ let start2 = at + 2;
6256
6303
  if (len & 128) {
6257
6304
  const count = len & 127;
6258
6305
  len = 0;
6259
- for (let i = 0; i < count; i++) len = len * 256 + der[start + i];
6260
- start += count;
6306
+ for (let i = 0; i < count; i++) len = len * 256 + der[start2 + i];
6307
+ start2 += count;
6261
6308
  }
6262
- if (start + len > der.length) throw new Error("truncated DER");
6263
- return [tag, start, start + len];
6309
+ if (start2 + len > der.length) throw new Error("truncated DER");
6310
+ return [tag, start2, start2 + len];
6264
6311
  }
6265
6312
  function contents(element) {
6266
- const [, start, end] = header(element, 0);
6267
- return element.subarray(start, end);
6313
+ const [, start2, end] = header(element, 0);
6314
+ return element.subarray(start2, end);
6268
6315
  }
6269
6316
  function publicKeyBits(spki) {
6270
6317
  const key = children(spki)[1];
@@ -6865,9 +6912,9 @@ var HttpHandles = class {
6865
6912
  return this.close(req.handle);
6866
6913
  }
6867
6914
  traits() {
6868
- const { unavailable, crossOrigin = "any", ...rest } = this.transport.traits;
6915
+ const { unavailable, crossOrigin = "any", ...rest2 } = this.transport.traits;
6869
6916
  if (unavailable) return { ok: false, errno: "ENETUNREACH", message: NO_TRANSPORT };
6870
- return { ok: true, kind: "json", json: { ...rest, crossOrigin } };
6917
+ return { ok: true, kind: "json", json: { ...rest2, crossOrigin } };
6871
6918
  }
6872
6919
  add(abort, body, cancel) {
6873
6920
  const handle = ++this.nextHandle;
@@ -6929,9 +6976,9 @@ var HttpHandles = class {
6929
6976
  async take(entry, max) {
6930
6977
  if (entry.left.length === 0 && !entry.done) {
6931
6978
  try {
6932
- const next = await entry.body.next();
6933
- if (next.done) entry.done = true;
6934
- else entry.left = next.value;
6979
+ const next2 = await entry.body.next();
6980
+ if (next2.done) entry.done = true;
6981
+ else entry.left = next2.value;
6935
6982
  } catch (e) {
6936
6983
  entry.done = true;
6937
6984
  const timedOut = e?.code === "ETIMEDOUT";
@@ -7393,12 +7440,12 @@ var KernelTty = class {
7393
7440
  const chunks2 = [];
7394
7441
  let n = 0;
7395
7442
  while (this.readable.length > 0 && n < max) {
7396
- const next = this.readable[0];
7397
- if (next === null || next === void 0) break;
7398
- const take = next.subarray(0, max - n);
7443
+ const next2 = this.readable[0];
7444
+ if (next2 === null || next2 === void 0) break;
7445
+ const take = next2.subarray(0, max - n);
7399
7446
  chunks2.push(take);
7400
7447
  n += take.length;
7401
- if (take.length < next.length) this.readable[0] = next.subarray(take.length);
7448
+ if (take.length < next2.length) this.readable[0] = next2.subarray(take.length);
7402
7449
  else this.readable.shift();
7403
7450
  if (this.canonical) break;
7404
7451
  }
@@ -7495,11 +7542,11 @@ var PtyPair = class {
7495
7542
  const chunks2 = [];
7496
7543
  let n = 0;
7497
7544
  while (this.queue.length > 0 && n < max - status) {
7498
- const next = this.queue[0];
7499
- const take = next.subarray(0, max - status - n);
7545
+ const next2 = this.queue[0];
7546
+ const take = next2.subarray(0, max - status - n);
7500
7547
  chunks2.push(take);
7501
7548
  n += take.length;
7502
- if (take.length < next.length) this.queue[0] = next.subarray(take.length);
7549
+ if (take.length < next2.length) this.queue[0] = next2.subarray(take.length);
7503
7550
  else this.queue.shift();
7504
7551
  }
7505
7552
  const out = new Uint8Array(status + n);
@@ -7805,7 +7852,7 @@ var Pages = class {
7805
7852
  }
7806
7853
  const last = runs[runs.length - 1];
7807
7854
  if (last) last[1] = Math.max(last[1], Math.min(READAHEAD, this.stored - last[0]));
7808
- return runs.map(([start, n]) => [start, Math.min(n, this.stored - start)]);
7855
+ return runs.map(([start2, n]) => [start2, Math.min(n, this.stored - start2)]);
7809
7856
  }
7810
7857
  partial(at, length2) {
7811
7858
  if (length2 === 0) return [];
@@ -7813,16 +7860,16 @@ var Pages = class {
7813
7860
  const edges = /* @__PURE__ */ new Set([Math.floor(at / PAGE), Math.floor((at + length2 - 1) / PAGE)]);
7814
7861
  const runs = [];
7815
7862
  for (const page of edges) {
7816
- const start = page * PAGE;
7817
- const covered = at <= start && at + length2 >= start + PAGE;
7818
- if (covered || this.pages.has(page) || start >= this.stored) continue;
7819
- runs.push([start, Math.min(PAGE, this.stored - start)]);
7863
+ const start2 = page * PAGE;
7864
+ const covered = at <= start2 && at + length2 >= start2 + PAGE;
7865
+ if (covered || this.pages.has(page) || start2 >= this.stored) continue;
7866
+ runs.push([start2, Math.min(PAGE, this.stored - start2)]);
7820
7867
  }
7821
7868
  return runs;
7822
7869
  }
7823
- fill(start, bytes) {
7870
+ fill(start2, bytes) {
7824
7871
  for (let at = 0; at < bytes.length; at += PAGE) {
7825
- const page = (start + at) / PAGE;
7872
+ const page = (start2 + at) / PAGE;
7826
7873
  if (this.pages.has(page)) continue;
7827
7874
  const part = bytes.subarray(at, Math.min(at + PAGE, bytes.length));
7828
7875
  const fresh = this.take(part.length);
@@ -7888,14 +7935,14 @@ var Pages = class {
7888
7935
  while (j < sorted.length && sorted[j] === first + (j - i) && sorted[j] * PAGE % RUN !== 0) {
7889
7936
  j++;
7890
7937
  }
7891
- const start = first * PAGE;
7938
+ const start2 = first * PAGE;
7892
7939
  const end = Math.min(this.length, (first + (j - i)) * PAGE);
7893
- const bytes = new Uint8Array(end - start);
7940
+ const bytes = new Uint8Array(end - start2);
7894
7941
  for (let k = i; k < j; k++) {
7895
7942
  const page = this.pages.get(sorted[k]);
7896
- bytes.set(page.subarray(0, Math.min(PAGE, end - (k - i) * PAGE - start)), (k - i) * PAGE);
7943
+ bytes.set(page.subarray(0, Math.min(PAGE, end - (k - i) * PAGE - start2)), (k - i) * PAGE);
7897
7944
  }
7898
- runs.push({ offset: start, bytes });
7945
+ runs.push({ offset: start2, bytes });
7899
7946
  i = j;
7900
7947
  }
7901
7948
  const written2 = Math.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
@@ -7962,8 +8009,8 @@ var AsyncRangedFile = class {
7962
8009
  return this.pages.length;
7963
8010
  }
7964
8011
  async fetch(runs) {
7965
- for (const [start, n] of runs) {
7966
- this.pages.fill(start, await this.io.pread(this.path, start, n, this.version));
8012
+ for (const [start2, n] of runs) {
8013
+ this.pages.fill(start2, await this.io.pread(this.path, start2, n, this.version));
7967
8014
  }
7968
8015
  }
7969
8016
  async read(at, length2) {
@@ -8038,9 +8085,9 @@ var VfsNode = class {
8038
8085
  if (dirty && contents2 !== void 0) this.markDirty();
8039
8086
  }
8040
8087
  serial(op) {
8041
- const next = this.queue.then(op);
8042
- this.queue = next.catch(() => void 0);
8043
- return next;
8088
+ const next2 = this.queue.then(op);
8089
+ this.queue = next2.catch(() => void 0);
8090
+ return next2;
8044
8091
  }
8045
8092
  revoke() {
8046
8093
  this.revoked = true;
@@ -8222,10 +8269,10 @@ var VfsNodes = class {
8222
8269
  targetKey(path) {
8223
8270
  return this.real(path, true, () => realTarget(this.fs, path));
8224
8271
  }
8225
- async real(path, follow, walk) {
8272
+ async real(path, follow2, walk) {
8226
8273
  if (this.fs.realpath) {
8227
8274
  try {
8228
- return await this.fs.realpath(path, follow);
8275
+ return await this.fs.realpath(path, follow2);
8229
8276
  } catch (err) {
8230
8277
  if (errCode(err) === "ELOOP") throw err;
8231
8278
  }
@@ -8353,8 +8400,8 @@ var VfsNodes = class {
8353
8400
  }
8354
8401
  }
8355
8402
  };
8356
- async function present(fs, path, follow = false) {
8357
- const look = (follow ? void 0 : fs.lstat) ?? fs.stat;
8403
+ async function present(fs, path, follow2 = false) {
8404
+ const look = (follow2 ? void 0 : fs.lstat) ?? fs.stat;
8358
8405
  try {
8359
8406
  await (look ? look.call(fs, path) : fs.readFileBuffer(path));
8360
8407
  return true;
@@ -8380,10 +8427,10 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
8380
8427
  at = parentOf6(at);
8381
8428
  continue;
8382
8429
  }
8383
- const next = at === "/" ? `/${part}` : `${at}/${part}`;
8384
- const link2 = await linkOf(fs, next);
8430
+ const next2 = at === "/" ? `/${part}` : `${at}/${part}`;
8431
+ const link2 = await linkOf(fs, next2);
8385
8432
  if (link2 === void 0) {
8386
- at = next;
8433
+ at = next2;
8387
8434
  continue;
8388
8435
  }
8389
8436
  if (budget.hops >= MAX_LINKS5) throw fsError("ELOOP", dir);
@@ -10644,9 +10691,9 @@ function tmpfs() {
10644
10691
  let node = root;
10645
10692
  for (const name2 of parts(path)) {
10646
10693
  if (node.kind !== "directory") throw fsError2("ENOTDIR", path);
10647
- const next = node.children.get(name2);
10648
- if (!next) throw fsError2("ENOENT", path);
10649
- node = next;
10694
+ const next2 = node.children.get(name2);
10695
+ if (!next2) throw fsError2("ENOENT", path);
10696
+ node = next2;
10650
10697
  }
10651
10698
  return node;
10652
10699
  }
@@ -11210,8 +11257,8 @@ var Launcher = class {
11210
11257
  const words = shebang(head) ?? (binfmt ? [binfmt] : void 0);
11211
11258
  if (!words) return void 0;
11212
11259
  if (baseName(words[0]) === "env") words.shift();
11213
- const [interp, ...rest] = words;
11214
- const arg = rest.join(" ");
11260
+ const [interp, ...rest2] = words;
11261
+ const arg = rest2.join(" ");
11215
11262
  const passed = [...arg ? [arg] : [], command ? script : file, ...argv.slice(1)];
11216
11263
  const found = interp ? await this.resolve(interp, interp, cwd) : void 0;
11217
11264
  if (!found) {
@@ -11292,7 +11339,8 @@ var Launcher = class {
11292
11339
  }
11293
11340
  async launch(planned, req) {
11294
11341
  const { target, args } = planned;
11295
- const seen = { ...req.env, HOSTNAME: this.hostname, cwd: req.cwd };
11342
+ const cwd = await physicalPathAsync(this.base, req.cwd);
11343
+ const seen = { ...req.env, HOSTNAME: this.hostname, cwd };
11296
11344
  const env = { ...expandDefaults(target.env, seen), ...req.env };
11297
11345
  for (const key of target.unset ?? []) delete env[key];
11298
11346
  env.HOSTNAME = this.hostname;
@@ -11303,7 +11351,7 @@ var Launcher = class {
11303
11351
  await req.fds.closeAll();
11304
11352
  throw err;
11305
11353
  }
11306
- return this.start({ ...req, program, argv0: target.argv0, args, env });
11354
+ return this.start({ ...req, cwd, program, argv0: target.argv0, args, env });
11307
11355
  }
11308
11356
  groupSession(pgid) {
11309
11357
  return this.jobs.sessionOf(pgid);
@@ -11710,7 +11758,8 @@ var Launcher = class {
11710
11758
  async starting(argv, dir) {
11711
11759
  this.catalog = void 0;
11712
11760
  this.binfmts = void 0;
11713
- const cwd = this.fs.resolvePath("/", dir ?? "/");
11761
+ const start2 = dir ?? "/";
11762
+ const cwd = await physicalPathAsync(this.base, start2.startsWith("/") ? start2 : `/${start2}`);
11714
11763
  const [file = ""] = argv;
11715
11764
  await this.base.mkdir(cwd, { recursive: true });
11716
11765
  return { cwd, file, planned: await this.plan(file, argv, cwd) };
@@ -11869,26 +11918,26 @@ var MemoryFile = class {
11869
11918
  return new File(this.data.blobs, this.name, { lastModified: this.lastModified });
11870
11919
  }
11871
11920
  async createWritable({ keepExistingData = false } = {}) {
11872
- const next = keepExistingData ? new Chunks([...this.data.blobs], this.data.size) : new Chunks();
11921
+ const next2 = keepExistingData ? new Chunks([...this.data.blobs], this.data.size) : new Chunks();
11873
11922
  let position = 0;
11874
11923
  const put = async (data) => {
11875
11924
  const bytes = await bytesOf(data);
11876
- await next.write(position, bytes);
11925
+ await next2.write(position, bytes);
11877
11926
  position += bytes.length;
11878
11927
  };
11879
11928
  return {
11880
11929
  write: async (data) => {
11881
11930
  if (!isParams(data)) return put(data);
11882
- if (data.type === "truncate") return next.truncate(data.size ?? 0);
11931
+ if (data.type === "truncate") return next2.truncate(data.size ?? 0);
11883
11932
  position = data.position ?? position;
11884
11933
  if (data.type === "write") await put(data.data);
11885
11934
  },
11886
11935
  seek: async (at) => {
11887
11936
  position = at;
11888
11937
  },
11889
- truncate: async (size) => next.truncate(size),
11938
+ truncate: async (size) => next2.truncate(size),
11890
11939
  close: async () => {
11891
- this.data = next;
11940
+ this.data = next2;
11892
11941
  this.lastModified = Date.now();
11893
11942
  },
11894
11943
  abort: async () => {
@@ -12339,11 +12388,11 @@ function stream(chunks2, socket, signal) {
12339
12388
  },
12340
12389
  async pull(controller) {
12341
12390
  try {
12342
- const next = await chunks2.next();
12343
- if (next.done) {
12391
+ const next2 = await chunks2.next();
12392
+ if (next2.done) {
12344
12393
  controller.close();
12345
12394
  socket.close();
12346
- } else controller.enqueue(next.value);
12395
+ } else controller.enqueue(next2.value);
12347
12396
  } catch (err) {
12348
12397
  controller.error(err);
12349
12398
  socket.close();
@@ -12571,12 +12620,12 @@ async function dialOn(channel, { port, host }) {
12571
12620
  return dialStream(await since(channel, 4, "dial", () => channel.call(req)));
12572
12621
  }
12573
12622
  async function spawnOn(channel, argv, opts) {
12574
- const { onStdout, onStderr, stdin, group: _, ...rest } = opts;
12623
+ const { onStdout, onStderr, stdin, group: _, ...rest2 } = opts;
12575
12624
  if (opts.pgid !== void 0)
12576
12625
  await since(channel, 3, "spawn into a process group", async () => {
12577
12626
  });
12578
12627
  const started = Promise.withResolvers();
12579
- const options = { ...rest, ...stdin !== void 0 ? { stdin: bytesOf2(stdin) } : {} };
12628
+ const options = { ...rest2, ...stdin !== void 0 ? { stdin: bytesOf2(stdin) } : {} };
12580
12629
  const { done: done4 } = channel.request(
12581
12630
  { op: "spawn", argv, options },
12582
12631
  {
@@ -12595,7 +12644,7 @@ async function spawnOn(channel, argv, opts) {
12595
12644
  };
12596
12645
  }
12597
12646
  async function runOn(channel, argv, opts) {
12598
- const { onStdout, onStderr, ...rest } = opts;
12647
+ const { onStdout, onStderr, ...rest2 } = opts;
12599
12648
  const chunks2 = { 1: [], 2: [] };
12600
12649
  const live = { 1: new TextDecoder(), 2: new TextDecoder() };
12601
12650
  const tee = (fd, on) => (bytes) => {
@@ -12603,7 +12652,7 @@ async function runOn(channel, argv, opts) {
12603
12652
  on?.(live[fd].decode(bytes, { stream: true }));
12604
12653
  };
12605
12654
  const child = await spawnOn(channel, argv, {
12606
- ...rest,
12655
+ ...rest2,
12607
12656
  onStdout: tee(1, onStdout),
12608
12657
  onStderr: tee(2, onStderr)
12609
12658
  });
@@ -12632,9 +12681,9 @@ async function terminalOn(channel, argv, opts) {
12632
12681
  get onData() {
12633
12682
  return listener;
12634
12683
  },
12635
- set onData(next) {
12636
- listener = next;
12637
- if (next) for (const bytes of backlog.splice(0)) next(bytes);
12684
+ set onData(next2) {
12685
+ listener = next2;
12686
+ if (next2) for (const bytes of backlog.splice(0)) next2(bytes);
12638
12687
  },
12639
12688
  write: (data) => send({ action: "write", bytes: bytesOf2(data) }),
12640
12689
  resize: (cols, rows) => send({ action: "resize", cols, rows }),
@@ -12745,8 +12794,8 @@ async function attachKernel(port, options = {}) {
12745
12794
  mounts: () => since(channel, 2, "mounts", () => channel.call({ op: "mounts" })),
12746
12795
  kill: async (pid, signal = "SIGTERM") => void await channel.call({ op: "kill", pid, signal }),
12747
12796
  fetch: (req) => {
12748
- const { signal, ...rest } = req;
12749
- return transport.fetch({ ...rest, signal: signal ?? new AbortController().signal });
12797
+ const { signal, ...rest2 } = req;
12798
+ return transport.fetch({ ...rest2, signal: signal ?? new AbortController().signal });
12750
12799
  },
12751
12800
  dial: (options2) => dialOn(channel, options2),
12752
12801
  loopbackFetch: (input, options2) => loopbackFetch((o) => dialOn(channel, o), input, options2),
@@ -12863,12 +12912,12 @@ async function createNodeKernel(options = {}) {
12863
12912
  return {
12864
12913
  root,
12865
12914
  async run(argv, opts = {}) {
12866
- const { stdin, onStdout, onStderr, ...rest } = opts;
12915
+ const { stdin, onStdout, onStderr, ...rest2 } = opts;
12867
12916
  const onOut = textOf(onStdout);
12868
12917
  const onErr = textOf(onStderr);
12869
12918
  const result = await guard(
12870
12919
  () => launcher.run(argv, {
12871
- ...rest,
12920
+ ...rest2,
12872
12921
  ...stdin !== void 0 ? { stdin: typeof stdin === "string" ? new TextEncoder().encode(stdin) : stdin } : {},
12873
12922
  ...onOut ? { onStdout: onOut } : {},
12874
12923
  ...onErr ? { onStderr: onErr } : {}
@@ -12881,12 +12930,12 @@ async function createNodeKernel(options = {}) {
12881
12930
  };
12882
12931
  },
12883
12932
  async openTerminal(argv, opts = {}) {
12884
- const { onData, ...rest } = opts;
12933
+ const { onData, ...rest2 } = opts;
12885
12934
  let listener = onData ?? null;
12886
12935
  const backlog = [];
12887
12936
  const session = await guard(
12888
12937
  () => launcher.openTerminal(argv, {
12889
- ...rest,
12938
+ ...rest2,
12890
12939
  onData: (bytes) => listener ? listener(bytes) : backlog.push(bytes)
12891
12940
  })
12892
12941
  );
@@ -12896,9 +12945,9 @@ async function createNodeKernel(options = {}) {
12896
12945
  get onData() {
12897
12946
  return listener;
12898
12947
  },
12899
- set onData(next) {
12900
- listener = next;
12901
- if (next) for (const bytes of backlog.splice(0)) next(bytes);
12948
+ set onData(next2) {
12949
+ listener = next2;
12950
+ if (next2) for (const bytes of backlog.splice(0)) next2(bytes);
12902
12951
  },
12903
12952
  write: (data) => session.write(typeof data === "string" ? new TextEncoder().encode(data) : data),
12904
12953
  resize: (cols, rows) => session.resize(cols, rows),