@ai-ecoverse/slicc-kernel 1.41.0 → 1.41.3

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;
@@ -4068,6 +4115,7 @@ var ChildTable = class {
4068
4115
  });
4069
4116
  handle.onState?.((state, sig) => {
4070
4117
  child.stopReport = state === "stopped" ? sig : void 0;
4118
+ child.stoppedBy = child.stopReport;
4071
4119
  child.continueReport = state === "continued";
4072
4120
  this.watchers.get(handle.pid)?.(state, sig);
4073
4121
  const waiters = this.stateChanged;
@@ -4079,7 +4127,10 @@ var ChildTable = class {
4079
4127
  return handle.pid;
4080
4128
  }
4081
4129
  watch(pid, listener) {
4082
- if (this.children.has(pid)) this.watchers.set(pid, listener);
4130
+ const child = this.children.get(pid);
4131
+ if (!child) return;
4132
+ this.watchers.set(pid, listener);
4133
+ if (child.stoppedBy !== void 0) listener("stopped", child.stoppedBy);
4083
4134
  }
4084
4135
  openSlot(slot, n, captured) {
4085
4136
  if ("fd" in slot) return this.parentFds.get(slot.fd).retain();
@@ -4292,8 +4343,7 @@ var HeldSet = class extends Set {
4292
4343
  delete(holds) {
4293
4344
  const removed = super.delete(holds);
4294
4345
  for (const path of /* @__PURE__ */ new Set([...holds.keys(), ...holds.opens.keys()])) this.idle(path);
4295
- for (const kept of holds.unlinked.values()) kept.release();
4296
- holds.unlinked.clear();
4346
+ holds.releaseAll();
4297
4347
  return removed;
4298
4348
  }
4299
4349
  };
@@ -4306,6 +4356,10 @@ var HeldPaths = class extends Map {
4306
4356
  opens = /* @__PURE__ */ new Map();
4307
4357
  unlinked = /* @__PURE__ */ new Map();
4308
4358
  aliases = /* @__PURE__ */ new Map();
4359
+ handles = /* @__PURE__ */ new Map();
4360
+ keptHandles = /* @__PURE__ */ new Map();
4361
+ uses = /* @__PURE__ */ new Map();
4362
+ lastHandle = 0;
4309
4363
  owning;
4310
4364
  onIdle;
4311
4365
  keyOf(path) {
@@ -4321,29 +4375,70 @@ var HeldPaths = class extends Map {
4321
4375
  return this.opens.keys();
4322
4376
  }
4323
4377
  isKept(path) {
4324
- return this.unlinked.has(path);
4378
+ const ids = this.handlesAt(path);
4379
+ return ids.length === 0 ? this.unlinked.has(path) : ids.every((id) => this.keptHandles.has(id));
4380
+ }
4381
+ handlesAt(path) {
4382
+ return [...this.handles].filter(([, key]) => key === path).map(([id]) => id);
4383
+ }
4384
+ keptFor(handle) {
4385
+ return this.keptHandles.get(handle);
4325
4386
  }
4326
4387
  keep(path, file) {
4388
+ const fresh = this.handlesAt(path).filter((id) => !this.keptHandles.has(id));
4389
+ for (const id of fresh) this.keptHandles.set(id, file);
4390
+ this.uses.set(file, Math.max(fresh.length, 1));
4327
4391
  this.unlinked.set(path, file);
4328
4392
  }
4329
- unkeep(path) {
4330
- this.unlinked.delete(path);
4331
- }
4332
- hold(path, on, open = false, real) {
4333
- if (open) {
4334
- const key = real ?? this.keyOf(path);
4335
- if (key !== path) this.aliases.set(path, key);
4336
- const count2 = (this.opens.get(key) ?? 0) + (on ? 1 : -1);
4337
- if (count2 > 0) this.opens.set(key, count2);
4338
- else {
4339
- this.opens.delete(key);
4340
- this.unlinked.get(key)?.release();
4341
- this.unlinked.delete(key);
4342
- for (const [alias, target] of this.aliases) if (target === key) this.aliases.delete(alias);
4343
- this.onIdle?.(key);
4344
- }
4393
+ unkeep(path, file) {
4394
+ for (const [id, kept] of this.keptHandles) if (kept === file) this.keptHandles.delete(id);
4395
+ this.uses.delete(file);
4396
+ if (this.unlinked.get(path) === file) this.unlinked.delete(path);
4397
+ }
4398
+ letGo(file, all = false) {
4399
+ const left = all ? 0 : (this.uses.get(file) ?? 0) - 1;
4400
+ if (left > 0) {
4401
+ this.uses.set(file, left);
4345
4402
  return;
4346
4403
  }
4404
+ if (!this.uses.delete(file)) return;
4405
+ file.release();
4406
+ for (const [path, kept] of this.unlinked) if (kept === file) this.unlinked.delete(path);
4407
+ }
4408
+ releaseAll() {
4409
+ for (const file of [...this.uses.keys()]) this.letGo(file, true);
4410
+ this.keptHandles.clear();
4411
+ }
4412
+ hold(path, on, open = false, real, handle) {
4413
+ if (open) return this.holdOpen(path, on, real, handle);
4414
+ this.holdWrite(path, on);
4415
+ return void 0;
4416
+ }
4417
+ holdOpen(path, on, real, handle) {
4418
+ const known = handle === void 0 ? void 0 : this.handles.get(handle);
4419
+ const key = known ?? real ?? this.keyOf(path);
4420
+ if (key !== path) this.aliases.set(path, key);
4421
+ if (handle !== void 0) {
4422
+ const kept = this.keptHandles.get(handle);
4423
+ this.handles.delete(handle);
4424
+ this.keptHandles.delete(handle);
4425
+ if (kept) this.letGo(kept);
4426
+ }
4427
+ const count = (this.opens.get(key) ?? 0) + (on ? 1 : -1);
4428
+ if (count > 0) this.opens.set(key, count);
4429
+ else {
4430
+ this.opens.delete(key);
4431
+ for (const id of this.handlesAt(key)) this.handles.delete(id);
4432
+ const kept = this.unlinked.get(key);
4433
+ if (kept) this.letGo(kept, true);
4434
+ for (const [alias, target] of this.aliases) if (target === key) this.aliases.delete(alias);
4435
+ this.onIdle?.(key);
4436
+ }
4437
+ if (!on) return void 0;
4438
+ this.handles.set(++this.lastHandle, key);
4439
+ return this.lastHandle;
4440
+ }
4441
+ holdWrite(path, on) {
4347
4442
  const count = (this.get(path) ?? 0) + (on ? 1 : -1);
4348
4443
  if (count > 0) this.set(path, count);
4349
4444
  else {
@@ -4380,6 +4475,9 @@ var HeldPaths = class extends Map {
4380
4475
  this.opens.delete(path);
4381
4476
  this.opens.set(moved2, (this.opens.get(moved2) ?? 0) + count);
4382
4477
  }
4478
+ for (const [id, key] of this.handles) {
4479
+ if (within3(key, from)) this.handles.set(id, to + key.slice(from.length));
4480
+ }
4383
4481
  }
4384
4482
  isRevoked(path) {
4385
4483
  return this.revoked.has(path);
@@ -5054,9 +5152,9 @@ var MountFs = class {
5054
5152
  this.table.forget(found.mount, normalizePath(path));
5055
5153
  await found.mount.conn.call({ op: "symlink", target, path: found.rel });
5056
5154
  }
5057
- async realpath(path, follow) {
5155
+ async realpath(path, follow2) {
5058
5156
  if (this.at(path) || !this.base.realpath) throw errnoError("ENOSYS", path);
5059
- const real = await this.base.realpath(path, follow);
5157
+ const real = await this.base.realpath(path, follow2);
5060
5158
  if (this.at(real)) throw errnoError("ENOSYS", path);
5061
5159
  return real;
5062
5160
  }
@@ -5243,25 +5341,31 @@ async function ranged(fs, path, req) {
5243
5341
  }
5244
5342
  var UNLINKED_OPS = /* @__PURE__ */ new Set(["read", "pread", "pwrite", "truncate"]);
5245
5343
  var OWN_OPS = /* @__PURE__ */ new Set(["rm", "unlink", "rmdir", "rename"]);
5344
+ async function keptOr(entry, path, handle) {
5345
+ if (handle !== void 0) return entry.keptFor?.(handle)?.hidden ?? path;
5346
+ const kept = entry.unlinked?.(path);
5347
+ return kept && !await entry.fs.exists(path) ? kept.hidden : path;
5348
+ }
5246
5349
  async function dispatchSyncFs(req) {
5247
5350
  const entry = resolveSyncFsToken(req.token);
5248
5351
  if (!entry) return { ok: false, errno: "EACCES", message: "sync-fs: unknown or revoked token" };
5249
5352
  const { fs, cwd } = entry;
5250
5353
  try {
5251
5354
  const path = fs.resolvePath(cwd, req.path);
5355
+ if (req.op === "kept") return json2(entry.keptFor?.(req.handle ?? -1) !== void 0);
5252
5356
  if (req.op === "statfs") return json2(await entry.statfs?.(path) ?? await storageUsage());
5253
5357
  if (req.op === "hold") {
5254
5358
  const [on, open] = [((req.mode ?? 0) & 1) === 1, ((req.mode ?? 0) & 2) === 2];
5255
- const real = on && open ? await fs.realpath?.(path, true).catch(() => path) : void 0;
5256
- entry.hold?.(path, on, open, real);
5359
+ if (on && open) {
5360
+ const real = await fs.realpath?.(path, true).catch(() => path);
5361
+ return json2(entry.hold?.(path, on, open, real) ?? null);
5362
+ }
5363
+ entry.hold?.(path, on, open, void 0, req.handle);
5257
5364
  return done;
5258
5365
  }
5259
5366
  if (entry.revoked?.(path)) return { ok: false, errno: "EIO", message: `${path} was unmounted` };
5260
5367
  if (req.op === "write" && req.mode === 1 || UNLINKED_OPS.has(req.op)) {
5261
- const serve = async () => {
5262
- const kept = entry.unlinked?.(path);
5263
- return run(entry, kept && !await fs.exists(path) ? kept.hidden : path, req);
5264
- };
5368
+ const serve = async () => run(entry, await keptOr(entry, path, req.handle), req);
5265
5369
  return await (entry.gate ? entry.gate(path, serve) : serve());
5266
5370
  }
5267
5371
  if (!entry.own || !OWN_OPS.has(req.op)) return await run(entry, path, req);
@@ -6204,15 +6308,15 @@ var octets = (bytes) => tlv(4, bytes);
6204
6308
  var bits = (bytes, unused = 0) => tlv(3, Uint8Array.of(unused), bytes);
6205
6309
  var TRUE = tlv(1, Uint8Array.of(255));
6206
6310
  function integer(magnitude) {
6207
- let start = 0;
6208
- while (start < magnitude.length - 1 && magnitude[start] === 0) start++;
6209
- const trimmed = magnitude.subarray(start);
6311
+ let start2 = 0;
6312
+ while (start2 < magnitude.length - 1 && magnitude[start2] === 0) start2++;
6313
+ const trimmed = magnitude.subarray(start2);
6210
6314
  return tlv(2, trimmed[0] & 128 ? concat4([Uint8Array.of(0), trimmed]) : trimmed);
6211
6315
  }
6212
6316
  function oid(dotted) {
6213
- const [a, b, ...rest] = dotted.split(".").map(Number);
6317
+ const [a, b, ...rest2] = dotted.split(".").map(Number);
6214
6318
  const out = [40 * a + b];
6215
- for (const arc of rest) {
6319
+ for (const arc of rest2) {
6216
6320
  const groups = [];
6217
6321
  for (let v = arc; ; v = Math.floor(v / 128)) {
6218
6322
  groups.unshift(v & 127);
@@ -6252,19 +6356,19 @@ function children(der) {
6252
6356
  function header(der, at) {
6253
6357
  const tag = der[at];
6254
6358
  let len = der[at + 1];
6255
- let start = at + 2;
6359
+ let start2 = at + 2;
6256
6360
  if (len & 128) {
6257
6361
  const count = len & 127;
6258
6362
  len = 0;
6259
- for (let i = 0; i < count; i++) len = len * 256 + der[start + i];
6260
- start += count;
6363
+ for (let i = 0; i < count; i++) len = len * 256 + der[start2 + i];
6364
+ start2 += count;
6261
6365
  }
6262
- if (start + len > der.length) throw new Error("truncated DER");
6263
- return [tag, start, start + len];
6366
+ if (start2 + len > der.length) throw new Error("truncated DER");
6367
+ return [tag, start2, start2 + len];
6264
6368
  }
6265
6369
  function contents(element) {
6266
- const [, start, end] = header(element, 0);
6267
- return element.subarray(start, end);
6370
+ const [, start2, end] = header(element, 0);
6371
+ return element.subarray(start2, end);
6268
6372
  }
6269
6373
  function publicKeyBits(spki) {
6270
6374
  const key = children(spki)[1];
@@ -6865,9 +6969,9 @@ var HttpHandles = class {
6865
6969
  return this.close(req.handle);
6866
6970
  }
6867
6971
  traits() {
6868
- const { unavailable, crossOrigin = "any", ...rest } = this.transport.traits;
6972
+ const { unavailable, crossOrigin = "any", ...rest2 } = this.transport.traits;
6869
6973
  if (unavailable) return { ok: false, errno: "ENETUNREACH", message: NO_TRANSPORT };
6870
- return { ok: true, kind: "json", json: { ...rest, crossOrigin } };
6974
+ return { ok: true, kind: "json", json: { ...rest2, crossOrigin } };
6871
6975
  }
6872
6976
  add(abort, body, cancel) {
6873
6977
  const handle = ++this.nextHandle;
@@ -6929,9 +7033,9 @@ var HttpHandles = class {
6929
7033
  async take(entry, max) {
6930
7034
  if (entry.left.length === 0 && !entry.done) {
6931
7035
  try {
6932
- const next = await entry.body.next();
6933
- if (next.done) entry.done = true;
6934
- else entry.left = next.value;
7036
+ const next2 = await entry.body.next();
7037
+ if (next2.done) entry.done = true;
7038
+ else entry.left = next2.value;
6935
7039
  } catch (e) {
6936
7040
  entry.done = true;
6937
7041
  const timedOut = e?.code === "ETIMEDOUT";
@@ -7393,12 +7497,12 @@ var KernelTty = class {
7393
7497
  const chunks2 = [];
7394
7498
  let n = 0;
7395
7499
  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);
7500
+ const next2 = this.readable[0];
7501
+ if (next2 === null || next2 === void 0) break;
7502
+ const take = next2.subarray(0, max - n);
7399
7503
  chunks2.push(take);
7400
7504
  n += take.length;
7401
- if (take.length < next.length) this.readable[0] = next.subarray(take.length);
7505
+ if (take.length < next2.length) this.readable[0] = next2.subarray(take.length);
7402
7506
  else this.readable.shift();
7403
7507
  if (this.canonical) break;
7404
7508
  }
@@ -7495,11 +7599,11 @@ var PtyPair = class {
7495
7599
  const chunks2 = [];
7496
7600
  let n = 0;
7497
7601
  while (this.queue.length > 0 && n < max - status) {
7498
- const next = this.queue[0];
7499
- const take = next.subarray(0, max - status - n);
7602
+ const next2 = this.queue[0];
7603
+ const take = next2.subarray(0, max - status - n);
7500
7604
  chunks2.push(take);
7501
7605
  n += take.length;
7502
- if (take.length < next.length) this.queue[0] = next.subarray(take.length);
7606
+ if (take.length < next2.length) this.queue[0] = next2.subarray(take.length);
7503
7607
  else this.queue.shift();
7504
7608
  }
7505
7609
  const out = new Uint8Array(status + n);
@@ -7805,7 +7909,7 @@ var Pages = class {
7805
7909
  }
7806
7910
  const last = runs[runs.length - 1];
7807
7911
  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)]);
7912
+ return runs.map(([start2, n]) => [start2, Math.min(n, this.stored - start2)]);
7809
7913
  }
7810
7914
  partial(at, length2) {
7811
7915
  if (length2 === 0) return [];
@@ -7813,16 +7917,16 @@ var Pages = class {
7813
7917
  const edges = /* @__PURE__ */ new Set([Math.floor(at / PAGE), Math.floor((at + length2 - 1) / PAGE)]);
7814
7918
  const runs = [];
7815
7919
  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)]);
7920
+ const start2 = page * PAGE;
7921
+ const covered = at <= start2 && at + length2 >= start2 + PAGE;
7922
+ if (covered || this.pages.has(page) || start2 >= this.stored) continue;
7923
+ runs.push([start2, Math.min(PAGE, this.stored - start2)]);
7820
7924
  }
7821
7925
  return runs;
7822
7926
  }
7823
- fill(start, bytes) {
7927
+ fill(start2, bytes) {
7824
7928
  for (let at = 0; at < bytes.length; at += PAGE) {
7825
- const page = (start + at) / PAGE;
7929
+ const page = (start2 + at) / PAGE;
7826
7930
  if (this.pages.has(page)) continue;
7827
7931
  const part = bytes.subarray(at, Math.min(at + PAGE, bytes.length));
7828
7932
  const fresh = this.take(part.length);
@@ -7888,14 +7992,14 @@ var Pages = class {
7888
7992
  while (j < sorted.length && sorted[j] === first + (j - i) && sorted[j] * PAGE % RUN !== 0) {
7889
7993
  j++;
7890
7994
  }
7891
- const start = first * PAGE;
7995
+ const start2 = first * PAGE;
7892
7996
  const end = Math.min(this.length, (first + (j - i)) * PAGE);
7893
- const bytes = new Uint8Array(end - start);
7997
+ const bytes = new Uint8Array(end - start2);
7894
7998
  for (let k = i; k < j; k++) {
7895
7999
  const page = this.pages.get(sorted[k]);
7896
- bytes.set(page.subarray(0, Math.min(PAGE, end - (k - i) * PAGE - start)), (k - i) * PAGE);
8000
+ bytes.set(page.subarray(0, Math.min(PAGE, end - (k - i) * PAGE - start2)), (k - i) * PAGE);
7897
8001
  }
7898
- runs.push({ offset: start, bytes });
8002
+ runs.push({ offset: start2, bytes });
7899
8003
  i = j;
7900
8004
  }
7901
8005
  const written2 = Math.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
@@ -7962,8 +8066,8 @@ var AsyncRangedFile = class {
7962
8066
  return this.pages.length;
7963
8067
  }
7964
8068
  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));
8069
+ for (const [start2, n] of runs) {
8070
+ this.pages.fill(start2, await this.io.pread(this.path, start2, n, this.version));
7967
8071
  }
7968
8072
  }
7969
8073
  async read(at, length2) {
@@ -8038,9 +8142,9 @@ var VfsNode = class {
8038
8142
  if (dirty && contents2 !== void 0) this.markDirty();
8039
8143
  }
8040
8144
  serial(op) {
8041
- const next = this.queue.then(op);
8042
- this.queue = next.catch(() => void 0);
8043
- return next;
8145
+ const next2 = this.queue.then(op);
8146
+ this.queue = next2.catch(() => void 0);
8147
+ return next2;
8044
8148
  }
8045
8149
  revoke() {
8046
8150
  this.revoked = true;
@@ -8222,10 +8326,10 @@ var VfsNodes = class {
8222
8326
  targetKey(path) {
8223
8327
  return this.real(path, true, () => realTarget(this.fs, path));
8224
8328
  }
8225
- async real(path, follow, walk) {
8329
+ async real(path, follow2, walk) {
8226
8330
  if (this.fs.realpath) {
8227
8331
  try {
8228
- return await this.fs.realpath(path, follow);
8332
+ return await this.fs.realpath(path, follow2);
8229
8333
  } catch (err) {
8230
8334
  if (errCode(err) === "ELOOP") throw err;
8231
8335
  }
@@ -8353,8 +8457,8 @@ var VfsNodes = class {
8353
8457
  }
8354
8458
  }
8355
8459
  };
8356
- async function present(fs, path, follow = false) {
8357
- const look = (follow ? void 0 : fs.lstat) ?? fs.stat;
8460
+ async function present(fs, path, follow2 = false) {
8461
+ const look = (follow2 ? void 0 : fs.lstat) ?? fs.stat;
8358
8462
  try {
8359
8463
  await (look ? look.call(fs, path) : fs.readFileBuffer(path));
8360
8464
  return true;
@@ -8380,10 +8484,10 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
8380
8484
  at = parentOf6(at);
8381
8485
  continue;
8382
8486
  }
8383
- const next = at === "/" ? `/${part}` : `${at}/${part}`;
8384
- const link2 = await linkOf(fs, next);
8487
+ const next2 = at === "/" ? `/${part}` : `${at}/${part}`;
8488
+ const link2 = await linkOf(fs, next2);
8385
8489
  if (link2 === void 0) {
8386
- at = next;
8490
+ at = next2;
8387
8491
  continue;
8388
8492
  }
8389
8493
  if (budget.hops >= MAX_LINKS5) throw fsError("ELOOP", dir);
@@ -8640,6 +8744,7 @@ var WasmProcess = class {
8640
8744
  dying = false;
8641
8745
  umask = DEFAULT_UMASK;
8642
8746
  execChild;
8747
+ killed = false;
8643
8748
  execTermsig;
8644
8749
  stopped = 0;
8645
8750
  stops = 0;
@@ -8677,7 +8782,10 @@ var WasmProcess = class {
8677
8782
  this.wake?.();
8678
8783
  return "forward";
8679
8784
  }
8680
- if (sig === SIG.KILL) return "terminate";
8785
+ if (sig === SIG.KILL) {
8786
+ this.killed = true;
8787
+ return "terminate";
8788
+ }
8681
8789
  if (sig === SIG.CONT) this.cont();
8682
8790
  if (sig === SIG.STOP) return this.stop(sig);
8683
8791
  const bit = sigbit(sig);
@@ -8695,6 +8803,19 @@ var WasmProcess = class {
8695
8803
  blocked.abort();
8696
8804
  return "deliver";
8697
8805
  }
8806
+ async spawn(req) {
8807
+ const { file, argv, env, cwd, stdio, inherit, exec } = req;
8808
+ const spawned = { file, argv, env, cwd, ...exec ? { exec } : {} };
8809
+ const pid = await this.children.spawn(spawned, stdio, inherit);
8810
+ if (!exec) return pid;
8811
+ if (this.killed) void Promise.allSettled([this.options.kill?.(pid, SIG.KILL)]);
8812
+ else this.adoptExec(pid);
8813
+ return pid;
8814
+ }
8815
+ adoptExec(pid) {
8816
+ this.execChild = pid;
8817
+ this.children.watch(pid, (state, sig) => state === "stopped" ? this.stop(sig) : this.cont());
8818
+ }
8698
8819
  onState(listener) {
8699
8820
  this.stateListeners.push(listener);
8700
8821
  }
@@ -9100,12 +9221,8 @@ var WasmProcess = class {
9100
9221
  switch (req.op) {
9101
9222
  case "proc-fork":
9102
9223
  return { ok: true, kind: "json", json: await this.children.fork(req.state) };
9103
- case "proc-spawn": {
9104
- const { file, argv, env, cwd, stdio, inherit, exec } = req;
9105
- const spawned = { file, argv, env, cwd, ...exec ? { exec } : {} };
9106
- const pid = await this.children.spawn(spawned, stdio, inherit);
9107
- return { ok: true, kind: "json", json: pid };
9108
- }
9224
+ case "proc-spawn":
9225
+ return { ok: true, kind: "json", json: await this.spawn(req) };
9109
9226
  case "proc-wait": {
9110
9227
  const signal = req.nohang ? this.interrupt.signal : this.blockingSignal();
9111
9228
  const flags = {
@@ -9119,12 +9236,8 @@ var WasmProcess = class {
9119
9236
  case "proc-identity":
9120
9237
  return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
9121
9238
  case "proc-exec": {
9122
- this.execChild = req.pid;
9239
+ this.adoptExec(req.pid);
9123
9240
  this.options.jobs?.exec(this.pid, req.pid);
9124
- this.children.watch(
9125
- req.pid,
9126
- (state, sig) => state === "stopped" ? this.stop(sig) : this.cont()
9127
- );
9128
9241
  await this.fds.closeAll();
9129
9242
  try {
9130
9243
  const waited = await this.children.wait(req.pid, false);
@@ -9378,7 +9491,8 @@ function holdingToken(opts, holds) {
9378
9491
  fs: opts.fs,
9379
9492
  cwd: opts.cwd,
9380
9493
  ...opts.statfs ? { statfs: opts.statfs } : {},
9381
- hold: (path, on, open, real) => holds.hold(path, on, open, real),
9494
+ hold: (path, on, open, real, handle) => holds.hold(path, on, open, real, handle),
9495
+ keptFor: (handle) => holds.keptFor(handle),
9382
9496
  unlinked: (path) => holds.keptAt(path),
9383
9497
  gate: (path, op) => opts.unlinkGate && holds.holding(path) ? opts.unlinkGate.run(holds.keyOf(path), op) : op(),
9384
9498
  own: (path, op) => holds.own(path, op),
@@ -10644,9 +10758,9 @@ function tmpfs() {
10644
10758
  let node = root;
10645
10759
  for (const name2 of parts(path)) {
10646
10760
  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;
10761
+ const next2 = node.children.get(name2);
10762
+ if (!next2) throw fsError2("ENOENT", path);
10763
+ node = next2;
10650
10764
  }
10651
10765
  return node;
10652
10766
  }
@@ -11210,8 +11324,8 @@ var Launcher = class {
11210
11324
  const words = shebang(head) ?? (binfmt ? [binfmt] : void 0);
11211
11325
  if (!words) return void 0;
11212
11326
  if (baseName(words[0]) === "env") words.shift();
11213
- const [interp, ...rest] = words;
11214
- const arg = rest.join(" ");
11327
+ const [interp, ...rest2] = words;
11328
+ const arg = rest2.join(" ");
11215
11329
  const passed = [...arg ? [arg] : [], command ? script : file, ...argv.slice(1)];
11216
11330
  const found = interp ? await this.resolve(interp, interp, cwd) : void 0;
11217
11331
  if (!found) {
@@ -11292,7 +11406,8 @@ var Launcher = class {
11292
11406
  }
11293
11407
  async launch(planned, req) {
11294
11408
  const { target, args } = planned;
11295
- const seen = { ...req.env, HOSTNAME: this.hostname, cwd: req.cwd };
11409
+ const cwd = await physicalPathAsync(this.base, req.cwd);
11410
+ const seen = { ...req.env, HOSTNAME: this.hostname, cwd };
11296
11411
  const env = { ...expandDefaults(target.env, seen), ...req.env };
11297
11412
  for (const key of target.unset ?? []) delete env[key];
11298
11413
  env.HOSTNAME = this.hostname;
@@ -11303,7 +11418,7 @@ var Launcher = class {
11303
11418
  await req.fds.closeAll();
11304
11419
  throw err;
11305
11420
  }
11306
- return this.start({ ...req, program, argv0: target.argv0, args, env });
11421
+ return this.start({ ...req, cwd, program, argv0: target.argv0, args, env });
11307
11422
  }
11308
11423
  groupSession(pgid) {
11309
11424
  return this.jobs.sessionOf(pgid);
@@ -11710,7 +11825,8 @@ var Launcher = class {
11710
11825
  async starting(argv, dir) {
11711
11826
  this.catalog = void 0;
11712
11827
  this.binfmts = void 0;
11713
- const cwd = this.fs.resolvePath("/", dir ?? "/");
11828
+ const start2 = dir ?? "/";
11829
+ const cwd = await physicalPathAsync(this.base, start2.startsWith("/") ? start2 : `/${start2}`);
11714
11830
  const [file = ""] = argv;
11715
11831
  await this.base.mkdir(cwd, { recursive: true });
11716
11832
  return { cwd, file, planned: await this.plan(file, argv, cwd) };
@@ -11869,26 +11985,26 @@ var MemoryFile = class {
11869
11985
  return new File(this.data.blobs, this.name, { lastModified: this.lastModified });
11870
11986
  }
11871
11987
  async createWritable({ keepExistingData = false } = {}) {
11872
- const next = keepExistingData ? new Chunks([...this.data.blobs], this.data.size) : new Chunks();
11988
+ const next2 = keepExistingData ? new Chunks([...this.data.blobs], this.data.size) : new Chunks();
11873
11989
  let position = 0;
11874
11990
  const put = async (data) => {
11875
11991
  const bytes = await bytesOf(data);
11876
- await next.write(position, bytes);
11992
+ await next2.write(position, bytes);
11877
11993
  position += bytes.length;
11878
11994
  };
11879
11995
  return {
11880
11996
  write: async (data) => {
11881
11997
  if (!isParams(data)) return put(data);
11882
- if (data.type === "truncate") return next.truncate(data.size ?? 0);
11998
+ if (data.type === "truncate") return next2.truncate(data.size ?? 0);
11883
11999
  position = data.position ?? position;
11884
12000
  if (data.type === "write") await put(data.data);
11885
12001
  },
11886
12002
  seek: async (at) => {
11887
12003
  position = at;
11888
12004
  },
11889
- truncate: async (size) => next.truncate(size),
12005
+ truncate: async (size) => next2.truncate(size),
11890
12006
  close: async () => {
11891
- this.data = next;
12007
+ this.data = next2;
11892
12008
  this.lastModified = Date.now();
11893
12009
  },
11894
12010
  abort: async () => {
@@ -12339,11 +12455,11 @@ function stream(chunks2, socket, signal) {
12339
12455
  },
12340
12456
  async pull(controller) {
12341
12457
  try {
12342
- const next = await chunks2.next();
12343
- if (next.done) {
12458
+ const next2 = await chunks2.next();
12459
+ if (next2.done) {
12344
12460
  controller.close();
12345
12461
  socket.close();
12346
- } else controller.enqueue(next.value);
12462
+ } else controller.enqueue(next2.value);
12347
12463
  } catch (err) {
12348
12464
  controller.error(err);
12349
12465
  socket.close();
@@ -12571,12 +12687,12 @@ async function dialOn(channel, { port, host }) {
12571
12687
  return dialStream(await since(channel, 4, "dial", () => channel.call(req)));
12572
12688
  }
12573
12689
  async function spawnOn(channel, argv, opts) {
12574
- const { onStdout, onStderr, stdin, group: _, ...rest } = opts;
12690
+ const { onStdout, onStderr, stdin, group: _, ...rest2 } = opts;
12575
12691
  if (opts.pgid !== void 0)
12576
12692
  await since(channel, 3, "spawn into a process group", async () => {
12577
12693
  });
12578
12694
  const started = Promise.withResolvers();
12579
- const options = { ...rest, ...stdin !== void 0 ? { stdin: bytesOf2(stdin) } : {} };
12695
+ const options = { ...rest2, ...stdin !== void 0 ? { stdin: bytesOf2(stdin) } : {} };
12580
12696
  const { done: done4 } = channel.request(
12581
12697
  { op: "spawn", argv, options },
12582
12698
  {
@@ -12595,7 +12711,7 @@ async function spawnOn(channel, argv, opts) {
12595
12711
  };
12596
12712
  }
12597
12713
  async function runOn(channel, argv, opts) {
12598
- const { onStdout, onStderr, ...rest } = opts;
12714
+ const { onStdout, onStderr, ...rest2 } = opts;
12599
12715
  const chunks2 = { 1: [], 2: [] };
12600
12716
  const live = { 1: new TextDecoder(), 2: new TextDecoder() };
12601
12717
  const tee = (fd, on) => (bytes) => {
@@ -12603,7 +12719,7 @@ async function runOn(channel, argv, opts) {
12603
12719
  on?.(live[fd].decode(bytes, { stream: true }));
12604
12720
  };
12605
12721
  const child = await spawnOn(channel, argv, {
12606
- ...rest,
12722
+ ...rest2,
12607
12723
  onStdout: tee(1, onStdout),
12608
12724
  onStderr: tee(2, onStderr)
12609
12725
  });
@@ -12632,9 +12748,9 @@ async function terminalOn(channel, argv, opts) {
12632
12748
  get onData() {
12633
12749
  return listener;
12634
12750
  },
12635
- set onData(next) {
12636
- listener = next;
12637
- if (next) for (const bytes of backlog.splice(0)) next(bytes);
12751
+ set onData(next2) {
12752
+ listener = next2;
12753
+ if (next2) for (const bytes of backlog.splice(0)) next2(bytes);
12638
12754
  },
12639
12755
  write: (data) => send({ action: "write", bytes: bytesOf2(data) }),
12640
12756
  resize: (cols, rows) => send({ action: "resize", cols, rows }),
@@ -12745,8 +12861,8 @@ async function attachKernel(port, options = {}) {
12745
12861
  mounts: () => since(channel, 2, "mounts", () => channel.call({ op: "mounts" })),
12746
12862
  kill: async (pid, signal = "SIGTERM") => void await channel.call({ op: "kill", pid, signal }),
12747
12863
  fetch: (req) => {
12748
- const { signal, ...rest } = req;
12749
- return transport.fetch({ ...rest, signal: signal ?? new AbortController().signal });
12864
+ const { signal, ...rest2 } = req;
12865
+ return transport.fetch({ ...rest2, signal: signal ?? new AbortController().signal });
12750
12866
  },
12751
12867
  dial: (options2) => dialOn(channel, options2),
12752
12868
  loopbackFetch: (input, options2) => loopbackFetch((o) => dialOn(channel, o), input, options2),
@@ -12863,12 +12979,12 @@ async function createNodeKernel(options = {}) {
12863
12979
  return {
12864
12980
  root,
12865
12981
  async run(argv, opts = {}) {
12866
- const { stdin, onStdout, onStderr, ...rest } = opts;
12982
+ const { stdin, onStdout, onStderr, ...rest2 } = opts;
12867
12983
  const onOut = textOf(onStdout);
12868
12984
  const onErr = textOf(onStderr);
12869
12985
  const result = await guard(
12870
12986
  () => launcher.run(argv, {
12871
- ...rest,
12987
+ ...rest2,
12872
12988
  ...stdin !== void 0 ? { stdin: typeof stdin === "string" ? new TextEncoder().encode(stdin) : stdin } : {},
12873
12989
  ...onOut ? { onStdout: onOut } : {},
12874
12990
  ...onErr ? { onStderr: onErr } : {}
@@ -12881,12 +12997,12 @@ async function createNodeKernel(options = {}) {
12881
12997
  };
12882
12998
  },
12883
12999
  async openTerminal(argv, opts = {}) {
12884
- const { onData, ...rest } = opts;
13000
+ const { onData, ...rest2 } = opts;
12885
13001
  let listener = onData ?? null;
12886
13002
  const backlog = [];
12887
13003
  const session = await guard(
12888
13004
  () => launcher.openTerminal(argv, {
12889
- ...rest,
13005
+ ...rest2,
12890
13006
  onData: (bytes) => listener ? listener(bytes) : backlog.push(bytes)
12891
13007
  })
12892
13008
  );
@@ -12896,9 +13012,9 @@ async function createNodeKernel(options = {}) {
12896
13012
  get onData() {
12897
13013
  return listener;
12898
13014
  },
12899
- set onData(next) {
12900
- listener = next;
12901
- if (next) for (const bytes of backlog.splice(0)) next(bytes);
13015
+ set onData(next2) {
13016
+ listener = next2;
13017
+ if (next2) for (const bytes of backlog.splice(0)) next2(bytes);
12902
13018
  },
12903
13019
  write: (data) => session.write(typeof data === "string" ? new TextEncoder().encode(data) : data),
12904
13020
  resize: (cols, rows) => session.resize(cols, rows),