@ai-ecoverse/slicc-kernel 1.44.0 → 1.45.0

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
@@ -1061,8 +1061,8 @@ function serveSocket(socket, port, onClose) {
1061
1061
  let writes = Promise.resolve();
1062
1062
  let credit = 0;
1063
1063
  let granted2;
1064
- const send = (message2, transfer) => {
1065
- if (!closed) port.postMessage(message2, transfer);
1064
+ const send = (message3, transfer) => {
1065
+ if (!closed) port.postMessage(message3, transfer);
1066
1066
  };
1067
1067
  const close = (reset = false) => {
1068
1068
  if (closed) return;
@@ -1194,8 +1194,8 @@ async function readWithin(reader, ms) {
1194
1194
  var INBOUND_LIMIT = 16 * 1024 * 1024;
1195
1195
  var MESSAGE_LIMIT = 64 * 1024 * 1024;
1196
1196
  var TOO_BIG = 1009;
1197
- function payloadSize(message2) {
1198
- return typeof message2 === "string" ? new TextEncoder().encode(message2).length : message2.length;
1197
+ function payloadSize(message3) {
1198
+ return typeof message3 === "string" ? new TextEncoder().encode(message3).length : message3.length;
1199
1199
  }
1200
1200
  var MessageQueue = class {
1201
1201
  items = [];
@@ -1215,9 +1215,9 @@ var MessageQueue = class {
1215
1215
  this.settle = resolve;
1216
1216
  });
1217
1217
  }
1218
- push(message2) {
1218
+ push(message3) {
1219
1219
  if (this.ended) return;
1220
- const size = payloadSize(message2);
1220
+ const size = payloadSize(message3);
1221
1221
  const huge = size > MESSAGE_LIMIT;
1222
1222
  if (huge || this.items.length > 0 && this.size + size > this.limit) {
1223
1223
  const reason = huge ? `a message is over ${MESSAGE_LIMIT} bytes` : `over ${this.limit} bytes of messages are waiting`;
@@ -1226,7 +1226,7 @@ var MessageQueue = class {
1226
1226
  return;
1227
1227
  }
1228
1228
  this.size += size;
1229
- this.items.push(message2);
1229
+ this.items.push(message3);
1230
1230
  this.wake();
1231
1231
  }
1232
1232
  end(close) {
@@ -1413,7 +1413,7 @@ function fetchTransport(options = {}) {
1413
1413
  }
1414
1414
  function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1415
1415
  const open = /* @__PURE__ */ new Map();
1416
- const fail2 = (nid, e) => {
1416
+ const fail3 = (nid, e) => {
1417
1417
  open.delete(nid);
1418
1418
  const { status, code } = e;
1419
1419
  peer.postMessage({
@@ -1449,7 +1449,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1449
1449
  headers: response.headers
1450
1450
  });
1451
1451
  } catch (e) {
1452
- fail2(call.nid, e);
1452
+ fail3(call.nid, e);
1453
1453
  }
1454
1454
  };
1455
1455
  const sockets = /* @__PURE__ */ new Map();
@@ -1483,7 +1483,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1483
1483
  peer.postMessage({ net: "ws-opened", nid: call.nid, protocol: socket.protocol });
1484
1484
  void relay(call.nid, socket);
1485
1485
  } catch (e) {
1486
- fail2(call.nid, e);
1486
+ fail3(call.nid, e);
1487
1487
  }
1488
1488
  };
1489
1489
  const relay = async (nid, socket) => {
@@ -1555,7 +1555,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
1555
1555
  peer.postMessage({ net: "chunk", nid, bytes }, [bytes.buffer]);
1556
1556
  }
1557
1557
  } catch (e) {
1558
- fail2(nid, e);
1558
+ fail3(nid, e);
1559
1559
  }
1560
1560
  };
1561
1561
  const drop = (nid) => {
@@ -2059,8 +2059,8 @@ function serveClient(port, host) {
2059
2059
  const watches = /* @__PURE__ */ new Map();
2060
2060
  let net;
2061
2061
  const ended = Promise.withResolvers();
2062
- const send = (message2, transfer = []) => {
2063
- if (state !== "closed") port.postMessage(message2, transfer);
2062
+ const send = (message3, transfer = []) => {
2063
+ if (state !== "closed") port.postMessage(message3, transfer);
2064
2064
  };
2065
2065
  const reply = (id2, body, transfer) => send({ id: id2, ...body }, transfer);
2066
2066
  const cdps = cdpRegistry(send, ended.promise);
@@ -2079,8 +2079,8 @@ function serveClient(port, host) {
2079
2079
  port.close?.();
2080
2080
  ended.resolve();
2081
2081
  }
2082
- async function hello(message2) {
2083
- const refused = versionError(message2.protocol);
2082
+ async function hello(message3) {
2083
+ const refused = versionError(message3.protocol);
2084
2084
  if (refused) {
2085
2085
  send({ hello: { protocol: PROTOCOL, error: refused } });
2086
2086
  detach();
@@ -2091,7 +2091,7 @@ function serveClient(port, host) {
2091
2091
  const transport = host.transport?.() ?? launcher.transport;
2092
2092
  net = serveTransport({ postMessage: (m, t) => send(m, t) }, transport);
2093
2093
  state = "open";
2094
- if (message2.lock && host.locks) void host.locks.request(message2.lock, () => detach());
2094
+ if (message3.lock && host.locks) void host.locks.request(message3.lock, () => detach());
2095
2095
  send({
2096
2096
  hello: {
2097
2097
  protocol: PROTOCOL,
@@ -3124,8 +3124,8 @@ var UnlinkedKeeper = class {
3124
3124
  // src/kernel/net/http1.ts
3125
3125
  var HttpError = class extends Error {
3126
3126
  status;
3127
- constructor(status, message2) {
3128
- super(message2);
3127
+ constructor(status, message3) {
3128
+ super(message3);
3129
3129
  this.status = status;
3130
3130
  }
3131
3131
  };
@@ -3392,8 +3392,8 @@ var OP = {
3392
3392
  };
3393
3393
  var WsError = class extends Error {
3394
3394
  code;
3395
- constructor(code, message2) {
3396
- super(message2);
3395
+ constructor(code, message3) {
3396
+ super(message3);
3397
3397
  this.code = code;
3398
3398
  }
3399
3399
  };
@@ -3690,8 +3690,8 @@ var CdpFacade = class {
3690
3690
  clearTimeout(timer);
3691
3691
  reject(new HttpError(502, `the CDP host closed: ${reason ?? "no reason"}`));
3692
3692
  };
3693
- conn.onmessage = (message2) => {
3694
- const parsed2 = JSON.parse(message2);
3693
+ conn.onmessage = (message3) => {
3694
+ const parsed2 = JSON.parse(message3);
3695
3695
  if (parsed2.id !== 1) return;
3696
3696
  clearTimeout(timer);
3697
3697
  resolve(parsed2);
@@ -3759,9 +3759,9 @@ var Relay = class {
3759
3759
  void this.end(reason ? CLOSE.error : CLOSE.normal, reason ?? "").then(() => resolve());
3760
3760
  };
3761
3761
  });
3762
- this.host.onmessage = (message2) => {
3762
+ this.host.onmessage = (message3) => {
3763
3763
  if (this.ended) return;
3764
- const bytes = new TextEncoder().encode(message2);
3764
+ const bytes = new TextEncoder().encode(message3);
3765
3765
  if (bytes.length > this.max)
3766
3766
  void this.end(CLOSE.tooBig, `a message is over ${this.max} bytes`);
3767
3767
  else void this.send(frame(OP_TEXT, bytes));
@@ -4349,10 +4349,10 @@ var SpawnError = class extends Error {
4349
4349
  };
4350
4350
  function interrupted(signal) {
4351
4351
  const { promise, reject } = Promise.withResolvers();
4352
- const fail2 = () => reject(new KernelError("EINTR"));
4353
- if (signal?.aborted) fail2();
4354
- else signal?.addEventListener("abort", fail2, { once: true });
4355
- return { promise, done: () => signal?.removeEventListener("abort", fail2) };
4352
+ const fail3 = () => reject(new KernelError("EINTR"));
4353
+ if (signal?.aborted) fail3();
4354
+ else signal?.addEventListener("abort", fail3, { once: true });
4355
+ return { promise, done: () => signal?.removeEventListener("abort", fail3) };
4356
4356
  }
4357
4357
  function stoppedStatus(sig) {
4358
4358
  return (sig & 255) << 8 | 127;
@@ -4543,8 +4543,8 @@ function unref(timer) {
4543
4543
  timer.unref?.();
4544
4544
  return timer;
4545
4545
  }
4546
- function errnoError(code, message2) {
4547
- return Object.assign(new Error(`${code}: ${message2}`), { code });
4546
+ function errnoError(code, message3) {
4547
+ return Object.assign(new Error(`${code}: ${message3}`), { code });
4548
4548
  }
4549
4549
  var DriverConnection = class _DriverConnection {
4550
4550
  capabilities;
@@ -5526,12 +5526,12 @@ function syncError(code, label) {
5526
5526
 
5527
5527
  // src/realm/sync-fs-dispatch.ts
5528
5528
  function toErrno(err) {
5529
- const message2 = err instanceof Error ? err.message : String(err);
5529
+ const message3 = err instanceof Error ? err.message : String(err);
5530
5530
  const code = err?.code;
5531
5531
  if (typeof code === "string" && /^E[A-Z]+$/.test(code)) {
5532
- return { ok: false, errno: code, message: message2 };
5532
+ return { ok: false, errno: code, message: message3 };
5533
5533
  }
5534
- return { ok: false, errno: "EIO", message: message2 };
5534
+ return { ok: false, errno: "EIO", message: message3 };
5535
5535
  }
5536
5536
  function statJson(s) {
5537
5537
  return {
@@ -6228,8 +6228,8 @@ function untilAborted(response, signal) {
6228
6228
  response.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
6229
6229
  });
6230
6230
  }
6231
- function plainResponse(status, message2) {
6232
- const body = latin1Bytes(`slicc realm proxy: ${message2}
6231
+ function plainResponse(status, message3) {
6232
+ const body = latin1Bytes(`slicc realm proxy: ${message3}
6233
6233
  `);
6234
6234
  return {
6235
6235
  status,
@@ -6411,10 +6411,10 @@ var RealmProxy = class {
6411
6411
  return await untilAborted(fetching, signal);
6412
6412
  } catch (e) {
6413
6413
  if (signal.aborted) throw e;
6414
- const message2 = e instanceof Error ? e.message : String(e);
6414
+ const message3 = e instanceof Error ? e.message : String(e);
6415
6415
  const status = e?.status;
6416
6416
  const own = typeof status === "number" && status >= 400 && status <= 599 ? status : 502;
6417
- return plainResponse(own, message2 || "upstream request failed");
6417
+ return plainResponse(own, message3 || "upstream request failed");
6418
6418
  }
6419
6419
  }
6420
6420
  async relay(conn, method, minor, response, keepAlive) {
@@ -6875,8 +6875,8 @@ var SCRATCH = 64 * 1024;
6875
6875
  var EOF = -1;
6876
6876
  var TlsError = class extends Error {
6877
6877
  code;
6878
- constructor(code, message2) {
6879
- super(message2);
6878
+ constructor(code, message3) {
6879
+ super(message3);
6880
6880
  this.code = code;
6881
6881
  }
6882
6882
  };
@@ -7257,10 +7257,133 @@ function enableNetwork(net, options) {
7257
7257
  return () => proxy;
7258
7258
  }
7259
7259
 
7260
+ // src/kernel/net/ws-syscalls.ts
7261
+ var WS_OPS = [
7262
+ "net-ws-open",
7263
+ "net-ws-ready",
7264
+ "net-ws-recv",
7265
+ "net-ws-wait",
7266
+ "net-ws-send",
7267
+ "net-ws-close"
7268
+ ];
7269
+ var TOKEN3 = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
7270
+ function message(e) {
7271
+ return e instanceof Error ? e.message : String(e);
7272
+ }
7273
+ function fail(errno, text) {
7274
+ return { ok: false, errno, message: text };
7275
+ }
7276
+ var WsHandles = class {
7277
+ transport;
7278
+ open = /* @__PURE__ */ new Map();
7279
+ next;
7280
+ constructor(transport, next2) {
7281
+ this.transport = transport;
7282
+ this.next = next2;
7283
+ }
7284
+ owns(handle) {
7285
+ return this.open.has(handle);
7286
+ }
7287
+ syscall(req) {
7288
+ if (req.op === "net-ws-open") return Promise.resolve(this.start(req));
7289
+ const entry = this.open.get(req.handle);
7290
+ if (!entry) return Promise.resolve(fail("EBADF", `no websocket ${req.handle}`));
7291
+ if (req.op === "net-ws-ready") return entry.ready;
7292
+ if (!entry.socket) return Promise.resolve(fail("ENOTCONN", "websocket not open"));
7293
+ if (req.op === "net-ws-recv") return this.recv(entry.socket, entry);
7294
+ if (req.op === "net-ws-wait") return this.closed(entry.socket);
7295
+ if (req.op === "net-ws-send") return Promise.resolve(this.send(entry.socket, req, entry));
7296
+ entry.ended = true;
7297
+ entry.socket.close(req.code ?? 1e3, req.reason ?? "");
7298
+ return Promise.resolve({ ok: true, kind: "void" });
7299
+ }
7300
+ start(req) {
7301
+ const handle = this.next();
7302
+ const entry = {
7303
+ abort: new AbortController(),
7304
+ ready: Promise.resolve({ ok: true, kind: "void" })
7305
+ };
7306
+ this.open.set(handle, entry);
7307
+ entry.ready = this.connect(handle, req, entry);
7308
+ return { ok: true, kind: "json", json: handle };
7309
+ }
7310
+ async connect(handle, req, entry) {
7311
+ const { transport } = this;
7312
+ if (!transport.traits.websocket || !transport.websocket) return fail("ENOTSUP", NO_WEBSOCKET2);
7313
+ let socket;
7314
+ try {
7315
+ socket = await transport.websocket({
7316
+ url: req.url,
7317
+ protocols: req.protocols,
7318
+ headers: req.headers,
7319
+ signal: entry.abort.signal
7320
+ });
7321
+ } catch (e) {
7322
+ return fail("ECONNREFUSED", message(e));
7323
+ }
7324
+ if (!this.open.has(handle)) {
7325
+ socket.close(1001, "the program went away");
7326
+ return fail("EBADF", `no websocket ${handle}`);
7327
+ }
7328
+ if (socket.protocol && !(req.protocols.includes(socket.protocol) && TOKEN3.test(socket.protocol))) {
7329
+ socket.close(1002, "subprotocol not offered");
7330
+ return fail("EPROTO", "the far end chose a subprotocol the program did not offer");
7331
+ }
7332
+ entry.socket = socket;
7333
+ void socket.closed.then(() => {
7334
+ entry.ended = true;
7335
+ });
7336
+ entry.messages = socket.messages[Symbol.asyncIterator]();
7337
+ return { ok: true, kind: "json", json: { protocol: socket.protocol } };
7338
+ }
7339
+ async recv(socket, entry) {
7340
+ try {
7341
+ const next2 = await entry.messages.next();
7342
+ if (!next2.done) {
7343
+ return typeof next2.value === "string" ? { ok: true, kind: "json", json: { text: next2.value } } : { ok: true, kind: "bytes", bytes: next2.value };
7344
+ }
7345
+ const closed = await socket.closed;
7346
+ return { ok: true, kind: "json", json: { code: closed.code, reason: closed.reason } };
7347
+ } catch (e) {
7348
+ return fail("ECONNRESET", message(e));
7349
+ }
7350
+ }
7351
+ async closed(socket) {
7352
+ const { code, reason } = await socket.closed;
7353
+ return { ok: true, kind: "json", json: { code, reason } };
7354
+ }
7355
+ send(socket, req, entry) {
7356
+ const data = req.text ?? req.body;
7357
+ if (entry.ended) return fail("EPIPE", "the websocket is closed");
7358
+ try {
7359
+ if (data !== void 0) socket.send(data);
7360
+ } catch (e) {
7361
+ return fail("EPIPE", message(e));
7362
+ }
7363
+ return { ok: true, kind: "json", json: socket.buffered };
7364
+ }
7365
+ close(handle) {
7366
+ const entry = this.open.get(handle);
7367
+ if (!entry) return;
7368
+ this.open.delete(handle);
7369
+ entry.abort.abort();
7370
+ entry.socket?.close(1001, "the program went away");
7371
+ }
7372
+ closeAll() {
7373
+ for (const handle of [...this.open.keys()]) this.close(handle);
7374
+ }
7375
+ };
7376
+
7260
7377
  // src/kernel/net/http-syscalls.ts
7261
- var HTTP_OPS = ["net-request", "net-read", "net-close", "net-traits"];
7378
+ var HTTP_OPS = [
7379
+ "net-request",
7380
+ "net-read",
7381
+ "net-close",
7382
+ "net-traits",
7383
+ ...WS_OPS
7384
+ ];
7262
7385
  var EMPTY = new Uint8Array(0);
7263
- function message(e) {
7386
+ function message2(e) {
7264
7387
  return e instanceof Error ? e.message : String(e);
7265
7388
  }
7266
7389
  async function* once(bytes) {
@@ -7270,10 +7393,13 @@ var HttpHandles = class {
7270
7393
  transport;
7271
7394
  open = /* @__PURE__ */ new Map();
7272
7395
  nextHandle = 0;
7396
+ ws;
7273
7397
  constructor(transport) {
7274
7398
  this.transport = transport;
7399
+ this.ws = new WsHandles(transport, () => ++this.nextHandle);
7275
7400
  }
7276
7401
  syscall(req) {
7402
+ if (req.op.startsWith("net-ws-")) return this.ws.syscall(req);
7277
7403
  if (req.op === "net-request") return this.request(req);
7278
7404
  if (req.op === "net-read") return this.read(req.handle, req.max);
7279
7405
  if (req.op === "net-traits") return Promise.resolve(this.traits());
@@ -7316,7 +7442,7 @@ var HttpHandles = class {
7316
7442
  };
7317
7443
  return { ok: true, kind: "json", json: head };
7318
7444
  } catch (e) {
7319
- const text = message(e);
7445
+ const text = message2(e);
7320
7446
  if (text === NO_TRANSPORT) return { ok: false, errno: "ENETUNREACH", message: text };
7321
7447
  const status = e.status;
7322
7448
  if (typeof status !== "number" || status === 502) {
@@ -7350,7 +7476,7 @@ var HttpHandles = class {
7350
7476
  } catch (e) {
7351
7477
  entry.done = true;
7352
7478
  const timedOut = e?.code === "ETIMEDOUT";
7353
- return { ok: false, errno: timedOut ? "ETIMEDOUT" : "EIO", message: message(e) };
7479
+ return { ok: false, errno: timedOut ? "ETIMEDOUT" : "EIO", message: message2(e) };
7354
7480
  }
7355
7481
  }
7356
7482
  const bytes = entry.left.subarray(0, Math.max(0, max));
@@ -7358,6 +7484,10 @@ var HttpHandles = class {
7358
7484
  return { ok: true, kind: "bytes", bytes };
7359
7485
  }
7360
7486
  async close(handle) {
7487
+ if (this.ws.owns(handle)) {
7488
+ this.ws.close(handle);
7489
+ return { ok: true, kind: "void" };
7490
+ }
7361
7491
  const entry = this.open.get(handle);
7362
7492
  if (!entry) return { ok: false, errno: "EBADF", message: `no request ${handle}` };
7363
7493
  this.open.delete(handle);
@@ -7366,6 +7496,7 @@ var HttpHandles = class {
7366
7496
  return { ok: true, kind: "void" };
7367
7497
  }
7368
7498
  async closeAll() {
7499
+ this.ws.closeAll();
7369
7500
  await Promise.all([...this.open.keys()].map((handle) => this.close(handle)));
7370
7501
  }
7371
7502
  };
@@ -7498,7 +7629,7 @@ var Resolver = class {
7498
7629
  this.routes = options.routes;
7499
7630
  this.now = options.now ?? Date.now;
7500
7631
  this.timeoutMs = options.timeoutMs ?? RESOLVE_TIMEOUT_MS;
7501
- this.log = options.log ?? ((message2) => console.warn(message2));
7632
+ this.log = options.log ?? ((message3) => console.warn(message3));
7502
7633
  this.own = ownNames(options.hostname ?? DEFAULT_HOSTNAME);
7503
7634
  }
7504
7635
  async resolve(name2, family, blocking) {
@@ -8058,10 +8189,10 @@ function ready(fds, read, write) {
8058
8189
  }
8059
8190
  function interruption(signal) {
8060
8191
  const { promise, reject } = Promise.withResolvers();
8061
- const fail2 = () => reject(new KernelError("EINTR"));
8062
- if (signal.aborted) fail2();
8063
- else signal.addEventListener("abort", fail2, { once: true });
8064
- return { promise, done: () => signal.removeEventListener("abort", fail2) };
8192
+ const fail3 = () => reject(new KernelError("EINTR"));
8193
+ if (signal.aborted) fail3();
8194
+ else signal.addEventListener("abort", fail3, { once: true });
8195
+ return { promise, done: () => signal.removeEventListener("abort", fail3) };
8065
8196
  }
8066
8197
  async function selectFds(fds, read, write, timeoutMs, interrupt) {
8067
8198
  const deadline = timeoutMs < 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs;
@@ -10210,8 +10341,8 @@ var SettlingChildren = class {
10210
10341
  };
10211
10342
 
10212
10343
  // src/mount/driver.ts
10213
- function fsError2(code, message2 = code) {
10214
- return Object.assign(new Error(message2), { code });
10344
+ function fsError2(code, message3 = code) {
10345
+ return Object.assign(new Error(message3), { code });
10215
10346
  }
10216
10347
  async function dispatch(h, req) {
10217
10348
  switch (req.op) {
@@ -10261,15 +10392,15 @@ async function dispatch(h, req) {
10261
10392
  }
10262
10393
  function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
10263
10394
  let open = false;
10264
- const reply = (message2, transfer = []) => port.postMessage(message2, transfer);
10265
- async function hello(message2) {
10266
- const refused = driverVersionError(message2.protocol);
10395
+ const reply = (message3, transfer = []) => port.postMessage(message3, transfer);
10396
+ async function hello(message3) {
10397
+ const refused = driverVersionError(message3.protocol);
10267
10398
  if (refused) {
10268
10399
  reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused, errno: "EPROTO" } });
10269
10400
  return;
10270
10401
  }
10271
10402
  try {
10272
- const refined = await handlers.mount?.(message2.mount);
10403
+ const refined = await handlers.mount?.(message3.mount);
10273
10404
  open = true;
10274
10405
  reply({
10275
10406
  hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } }
@@ -11601,10 +11732,10 @@ var Launcher = class {
11601
11732
  }
11602
11733
  interpreters() {
11603
11734
  this.binfmts ??= this.roots().then(
11604
- (roots) => scanBinfmts(this.base, roots, (message2) => {
11605
- if (this.warned.has(message2)) return;
11606
- this.warned.add(message2);
11607
- console.warn(message2);
11735
+ (roots) => scanBinfmts(this.base, roots, (message3) => {
11736
+ if (this.warned.has(message3)) return;
11737
+ this.warned.add(message3);
11738
+ console.warn(message3);
11608
11739
  })
11609
11740
  );
11610
11741
  return this.binfmts;
@@ -12231,7 +12362,7 @@ var Launcher = class {
12231
12362
  },
12232
12363
  account
12233
12364
  );
12234
- const report = (message2) => options.onData(encoder3.encode(`${message2}\r
12365
+ const report = (message3) => options.onData(encoder3.encode(`${message3}\r
12235
12366
  `));
12236
12367
  const handle = await this.launch(planned, { env, cwd, fds, report, ...this.identity(account) });
12237
12368
  leader = handle.pid;
@@ -12261,7 +12392,7 @@ var Launcher = class {
12261
12392
  };
12262
12393
  const stdout = collect(out, options.onStdout);
12263
12394
  const stderr = collect(err, options.onStderr);
12264
- const report = (message2) => stderr(encoder3.encode(`${message2}
12395
+ const report = (message3) => stderr(encoder3.encode(`${message3}
12265
12396
  `));
12266
12397
  if (!planned) {
12267
12398
  report(`${file}: command not found`);
@@ -12287,7 +12418,7 @@ var Launcher = class {
12287
12418
  };
12288
12419
 
12289
12420
  // src/node/memory-root.ts
12290
- var fail = (name2) => {
12421
+ var fail2 = (name2) => {
12291
12422
  throw new DOMException(name2, name2);
12292
12423
  };
12293
12424
  function valid(name2) {
@@ -12400,7 +12531,7 @@ var MemoryFile = class {
12400
12531
  }
12401
12532
  async move(parent, name2) {
12402
12533
  valid(name2);
12403
- if (parent.children.get(name2)?.kind === "directory") fail("InvalidModificationError");
12534
+ if (parent.children.get(name2)?.kind === "directory") fail2("InvalidModificationError");
12404
12535
  this.parent.children.delete(this.name);
12405
12536
  this.name = name2;
12406
12537
  this.parent = parent;
@@ -12418,15 +12549,15 @@ var MemoryDirectory = class _MemoryDirectory {
12418
12549
  this.parent = parent;
12419
12550
  }
12420
12551
  present() {
12421
- if (this.removed) fail("NotFoundError");
12552
+ if (this.removed) fail2("NotFoundError");
12422
12553
  }
12423
12554
  async getDirectoryHandle(name2, { create = false } = {}) {
12424
12555
  this.present();
12425
12556
  valid(name2);
12426
12557
  const found = this.children.get(name2);
12427
- if (found?.kind === "file") fail("TypeMismatchError");
12558
+ if (found?.kind === "file") fail2("TypeMismatchError");
12428
12559
  if (found) return found;
12429
- if (!create) fail("NotFoundError");
12560
+ if (!create) fail2("NotFoundError");
12430
12561
  const dir = new _MemoryDirectory(name2, this);
12431
12562
  this.children.set(name2, dir);
12432
12563
  return dir;
@@ -12435,9 +12566,9 @@ var MemoryDirectory = class _MemoryDirectory {
12435
12566
  this.present();
12436
12567
  valid(name2);
12437
12568
  const found = this.children.get(name2);
12438
- if (found?.kind === "directory") fail("TypeMismatchError");
12569
+ if (found?.kind === "directory") fail2("TypeMismatchError");
12439
12570
  if (found) return found;
12440
- if (!create) fail("NotFoundError");
12571
+ if (!create) fail2("NotFoundError");
12441
12572
  const file = new MemoryFile(name2, this);
12442
12573
  this.children.set(name2, file);
12443
12574
  return file;
@@ -12446,9 +12577,9 @@ var MemoryDirectory = class _MemoryDirectory {
12446
12577
  this.present();
12447
12578
  valid(name2);
12448
12579
  const found = this.children.get(name2);
12449
- if (!found) return fail("NotFoundError");
12580
+ if (!found) return fail2("NotFoundError");
12450
12581
  if (found.kind === "directory" && found.children.size > 0 && !recursive) {
12451
- fail("InvalidModificationError");
12582
+ fail2("InvalidModificationError");
12452
12583
  }
12453
12584
  this.children.delete(name2);
12454
12585
  if (found.kind === "directory") found.remove();
@@ -12477,7 +12608,7 @@ var MemoryDirectory = class _MemoryDirectory {
12477
12608
  }
12478
12609
  async move(parent, name2) {
12479
12610
  valid(name2);
12480
- if (parent.children.has(name2)) fail("InvalidModificationError");
12611
+ if (parent.children.has(name2)) fail2("InvalidModificationError");
12481
12612
  this.parent?.children.delete(this.name);
12482
12613
  this.name = name2;
12483
12614
  this.parent = parent;
@@ -12495,8 +12626,8 @@ function isMemoryRoot(handle) {
12495
12626
  var TransportError = class extends Error {
12496
12627
  status;
12497
12628
  code;
12498
- constructor(message2, status, code) {
12499
- super(message2);
12629
+ constructor(message3, status, code) {
12630
+ super(message3);
12500
12631
  this.status = status;
12501
12632
  this.code = code;
12502
12633
  }
@@ -12667,9 +12798,9 @@ function signalNumber(name2) {
12667
12798
  }
12668
12799
 
12669
12800
  // src/client/dial-stream.ts
12670
- function errorWithCode(message2) {
12671
- const code = /^E[A-Z]+/.exec(message2)?.[0];
12672
- return Object.assign(new Error(message2), code ? { code } : {});
12801
+ function errorWithCode(message3) {
12802
+ const code = /^E[A-Z]+/.exec(message3)?.[0];
12803
+ return Object.assign(new Error(message3), code ? { code } : {});
12673
12804
  }
12674
12805
  function dialStream(port, onClose) {
12675
12806
  let closed = false;
@@ -12687,15 +12818,15 @@ function dialStream(port, onClose) {
12687
12818
  close();
12688
12819
  }
12689
12820
  });
12690
- const finish = (fail3) => {
12821
+ const finish = (fail4) => {
12691
12822
  const controller = reader;
12692
12823
  reader = void 0;
12693
12824
  for (const ack of acks.splice(0)) {
12694
- if (fail3) ack.reject(fail3);
12825
+ if (fail4) ack.reject(fail4);
12695
12826
  else ack.resolve();
12696
12827
  }
12697
12828
  if (!controller) return;
12698
- if (fail3) controller.error(fail3);
12829
+ if (fail4) controller.error(fail4);
12699
12830
  else controller.close();
12700
12831
  };
12701
12832
  function shut() {
@@ -12731,11 +12862,11 @@ function dialStream(port, onClose) {
12731
12862
  close();
12732
12863
  }
12733
12864
  });
12734
- const fail2 = (error) => {
12865
+ const fail3 = (error) => {
12735
12866
  shut();
12736
12867
  finish(error);
12737
12868
  };
12738
- return { readable, writable, close, fail: fail2 };
12869
+ return { readable, writable, close, fail: fail3 };
12739
12870
  }
12740
12871
 
12741
12872
  // src/client/loopback-fetch.ts
@@ -12907,15 +13038,15 @@ async function loopbackFetch(dial, input, options) {
12907
13038
 
12908
13039
  // src/client/attach.ts
12909
13040
  var KernelGoneError = class extends Error {
12910
- constructor(message2 = "the slicc-kernel this client was attached to is gone") {
12911
- super(message2);
13041
+ constructor(message3 = "the slicc-kernel this client was attached to is gone") {
13042
+ super(message3);
12912
13043
  this.name = "KernelGoneError";
12913
13044
  }
12914
13045
  };
12915
13046
  var KernelCallError = class extends Error {
12916
13047
  code;
12917
- constructor(message2, code) {
12918
- super(message2);
13048
+ constructor(message3, code) {
13049
+ super(message3);
12919
13050
  this.name = "KernelCallError";
12920
13051
  this.code = code;
12921
13052
  }
@@ -12971,8 +13102,8 @@ var Channel = class {
12971
13102
  port.addEventListener("close", () => this.end(new KernelGoneError()));
12972
13103
  port.start?.();
12973
13104
  }
12974
- post(message2) {
12975
- if (!this.failure) this.port.postMessage(message2);
13105
+ post(message3) {
13106
+ if (!this.failure) this.port.postMessage(message3);
12976
13107
  }
12977
13108
  end(error) {
12978
13109
  if (this.failure) return;
@@ -13288,9 +13419,9 @@ var TERMINATED = "the kernel is terminated";
13288
13419
  function nodeWorker(file, live, closed) {
13289
13420
  const errors = /* @__PURE__ */ new Set();
13290
13421
  const messages = /* @__PURE__ */ new Map();
13291
- const fail2 = (message2) => {
13422
+ const fail3 = (message3) => {
13292
13423
  for (const handler of [...errors]) {
13293
- handler({ message: message2, preventDefault() {
13424
+ handler({ message: message3, preventDefault() {
13294
13425
  } });
13295
13426
  }
13296
13427
  };
@@ -13298,16 +13429,16 @@ function nodeWorker(file, live, closed) {
13298
13429
  if (worker) {
13299
13430
  const kill = () => {
13300
13431
  void worker.terminate();
13301
- fail2(TERMINATED);
13432
+ fail3(TERMINATED);
13302
13433
  };
13303
13434
  live.add(kill);
13304
13435
  worker.once("exit", () => live.delete(kill));
13305
- worker.on("error", (err) => fail2(String(err)));
13436
+ worker.on("error", (err) => fail3(String(err)));
13306
13437
  } else {
13307
- setTimeout(() => fail2(TERMINATED), 0);
13438
+ setTimeout(() => fail3(TERMINATED), 0);
13308
13439
  }
13309
13440
  return {
13310
- postMessage: (message2, transfer) => worker?.postMessage(message2, transfer),
13441
+ postMessage: (message3, transfer) => worker?.postMessage(message3, transfer),
13311
13442
  addEventListener(type, handler) {
13312
13443
  if (type === "error") {
13313
13444
  errors.add(handler);