@ai-ecoverse/slicc-kernel 1.141.2 → 1.142.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.
@@ -899,19 +899,19 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
899
899
  const live = (miss, path) => miss.until > now() && young2(miss) && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
900
900
  const seen = new SeenAt(view, lstats);
901
901
  const kept = remember(cache, seen, blind, (entry2) => filled2.set(entry2));
902
- const gone = (path) => goneAbove([lstats, stats], live, path);
902
+ const gone2 = (path) => goneAbove([lstats, stats], live, path);
903
903
  const usable = (map, path) => {
904
904
  const hit = map.get(path);
905
905
  if (hit === void 0) return void 0;
906
906
  if ("until" in hit) return live(hit, path) ? hit : void 0;
907
907
  return young2(hit) && !seen.changed(map, path) ? hit : void 0;
908
908
  };
909
- const cached = (map, path, get) => {
909
+ const cached2 = (map, path, get) => {
910
910
  if (blind) return get();
911
911
  cache.fresh();
912
912
  let hit = usable(map, path);
913
913
  if (hit === void 0) {
914
- const missing2 = gone(path);
914
+ const missing2 = gone2(path);
915
915
  if (missing2) throw missing2.error;
916
916
  hit = fetched({ view, now, seen, filled: filled2, cache }, map, path, get);
917
917
  }
@@ -984,11 +984,11 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
984
984
  }
985
985
  return bridge.readlink(p);
986
986
  },
987
- stat: (p) => cached(stats, p, () => bridge.stat(p)),
988
- lstat: (p) => cached(lstats, p, () => bridge.lstat(p)),
987
+ stat: (p) => cached2(stats, p, () => bridge.stat(p)),
988
+ lstat: (p) => cached2(lstats, p, () => bridge.lstat(p)),
989
989
  exists: (p) => {
990
990
  try {
991
- cached(stats, p, () => bridge.stat(p));
991
+ cached2(stats, p, () => bridge.stat(p));
992
992
  return true;
993
993
  } catch {
994
994
  return false;
@@ -2019,10 +2019,10 @@ function callError(result, op) {
2019
2019
  }
2020
2020
  function untilAborted(work, signal) {
2021
2021
  if (!signal) return work;
2022
- return new Promise((resolve) => {
2022
+ return new Promise((resolve2) => {
2023
2023
  const done = () => {
2024
2024
  signal.removeEventListener("abort", done);
2025
- resolve();
2025
+ resolve2();
2026
2026
  };
2027
2027
  signal.addEventListener("abort", done, { once: true });
2028
2028
  work.then(done, done);
@@ -5928,7 +5928,7 @@ var init_wasi_host = __esm({
5928
5928
  size: BigInt(size)
5929
5929
  };
5930
5930
  }
5931
- statOrphanable(path, size, orphan = false, gone = false) {
5931
+ statOrphanable(path, size, orphan = false, gone2 = false) {
5932
5932
  let s;
5933
5933
  if (!orphan) {
5934
5934
  try {
@@ -5937,7 +5937,7 @@ var init_wasi_host = __esm({
5937
5937
  }
5938
5938
  }
5939
5939
  const out = this.sized(path, s, size);
5940
- return gone ? { ...out, nlink: 0n } : out;
5940
+ return gone2 ? { ...out, nlink: 0n } : out;
5941
5941
  }
5942
5942
  synthetic(path) {
5943
5943
  return deviceOf(path) !== void 0 || path === SEALED_PATH && !!this.o.kernel.sys.openSealed || path === CLIPBOARD_PATH && !!this.o.kernel.sys.openClipboard;
@@ -6725,7 +6725,7 @@ var KERNEL_VERSION, OS_RELEASE;
6725
6725
  var init_version = __esm({
6726
6726
  "src/version.ts"() {
6727
6727
  "use strict";
6728
- KERNEL_VERSION = true ? "1.141.2" : "0.0.0-dev";
6728
+ KERNEL_VERSION = true ? "1.142.0" : "0.0.0-dev";
6729
6729
  OS_RELEASE = "6.0.0-slicc";
6730
6730
  }
6731
6731
  });
@@ -7673,7 +7673,7 @@ function netOps(kernel, io) {
7673
7673
  });
7674
7674
  return { fd, local: local3, remote, readable: readable3, writable: writable2, close };
7675
7675
  };
7676
- const resolve = async (host, signal) => {
7676
+ const resolve2 = async (host, signal) => {
7677
7677
  if (IPV4.test(host)) return host;
7678
7678
  const r = await kernel.blocking({ op: "sock-resolve", name: host, family: 4 }, signal);
7679
7679
  return (r.ok && r.kind === "json" ? r.json : [])[0];
@@ -7773,7 +7773,7 @@ function netOps(kernel, io) {
7773
7773
  if (host.includes(":")) throw new JsCallError("EADDRNOTAVAIL", host);
7774
7774
  const addr = {
7775
7775
  family: "inet",
7776
- host: await resolve(host, signal),
7776
+ host: await resolve2(host, signal),
7777
7777
  port: port(options.port)
7778
7778
  };
7779
7779
  return opened2(async (fd) => {
@@ -8256,6 +8256,9 @@ function refusal(err) {
8256
8256
  const code2 = err?.code;
8257
8257
  return code2 === "EACCES" || code2 === "EPERM";
8258
8258
  }
8259
+ function gone(err) {
8260
+ return err?.code === "ENOENT";
8261
+ }
8259
8262
  function young(s) {
8260
8263
  return performance.now() - (s.filledAt ?? Number.NEGATIVE_INFINITY) < SHARED_TTL_MS;
8261
8264
  }
@@ -8565,9 +8568,9 @@ function createNodeOps(h) {
8565
8568
  const owned = bridgeOf(node).owners === true;
8566
8569
  if (owned && Fs.isLink(node.mode) && statOf(node).uid === void 0)
8567
8570
  node.live.stat = void 0;
8568
- const cached = owned && cachedStat(node, Fs.isDir(node.mode), bridgeOf(node).changes);
8571
+ const cached2 = owned && cachedStat(node, Fs.isDir(node.mode), bridgeOf(node).changes);
8569
8572
  const st = statOf(node);
8570
- if (cached) searchParents(Fs, node, bridgeOf(node), call2);
8573
+ if (cached2) searchParents(Fs, node, bridgeOf(node), call2);
8571
8574
  const s = node.live;
8572
8575
  const size = Fs.isDir(node.mode) ? 4096 : s.ranged?.size() ?? (s.loaded ? s.len : st.size);
8573
8576
  const mtime = new Date(st.mtimeMs ?? 0);
@@ -8773,7 +8776,9 @@ function createStreamOps(h) {
8773
8776
  if (s.handle === void 0) h.handled.delete(node);
8774
8777
  else h.handled.add(node);
8775
8778
  } catch (err) {
8776
- if (refusal(err)) throw new Fs.ErrnoError(wasiErrno(err.code));
8779
+ if (refusal(err) || gone(err)) {
8780
+ throw new Fs.ErrnoError(wasiErrno(err.code));
8781
+ }
8777
8782
  }
8778
8783
  };
8779
8784
  const permitted = (stream, created) => {
@@ -9176,7 +9181,7 @@ function guardVanished(Fs) {
9176
9181
  const drop = forget;
9177
9182
  const lookupPath = Fs.lookupPath.bind(Fs);
9178
9183
  const ops = Fs;
9179
- const cached = (path, follow3) => {
9184
+ const cached2 = (path, follow3) => {
9180
9185
  try {
9181
9186
  const node = lookupPath(path, { follow: follow3 }).node;
9182
9187
  return node.live && node.live.openCount === 0 && !node.live.dirty ? node : void 0;
@@ -9199,7 +9204,7 @@ function guardVanished(Fs) {
9199
9204
  const code2 = err.errno;
9200
9205
  const taken = code2 === wasiErrno("EEXIST") && op === open;
9201
9206
  if (code2 !== wasiErrno("ENOENT") && !taken || typeof path !== "string") throw err;
9202
- const node = cached(path, follows(args));
9207
+ const node = cached2(path, follows(args));
9203
9208
  if (!node) throw err;
9204
9209
  drop(node);
9205
9210
  return op(...args);
@@ -11439,7 +11444,7 @@ function promised(file) {
11439
11444
  const out = { ...file };
11440
11445
  for (const [name2, value2] of Object.entries(file)) {
11441
11446
  if (typeof value2 === "function") {
11442
- out[name2] = (...args) => new Promise((resolve) => resolve(value2(...args)));
11447
+ out[name2] = (...args) => new Promise((resolve2) => resolve2(value2(...args)));
11443
11448
  }
11444
11449
  }
11445
11450
  return out;
@@ -11620,7 +11625,7 @@ function laneOf(lane, silence = SYNC_FS_REQUEST_TIMEOUT_MS, open = createSyncSab
11620
11625
  };
11621
11626
  }
11622
11627
  function syncOps(kernel, shared) {
11623
- const { infos, handles, resolve } = shared;
11628
+ const { infos, handles, resolve: resolve2 } = shared;
11624
11629
  const tryDevSync = (abs) => {
11625
11630
  try {
11626
11631
  const resolved2 = physicalPath(
@@ -11673,7 +11678,7 @@ function syncOps(kernel, shared) {
11673
11678
  return at;
11674
11679
  };
11675
11680
  const statOf = (op, path) => {
11676
- const abs = resolve(path);
11681
+ const abs = resolve2(path);
11677
11682
  if (inDev(abs)) return devSync(kernel, devStat(abs, op === "stat"));
11678
11683
  try {
11679
11684
  kernel.call({ op: "fd-path-flush", path: abs });
@@ -11703,7 +11708,7 @@ function syncOps(kernel, shared) {
11703
11708
  return handle.file;
11704
11709
  };
11705
11710
  const open = (path, options = {}) => {
11706
- const abs = resolve(path);
11711
+ const abs = resolve2(path);
11707
11712
  if (inDev(abs)) return openDev2(abs, options);
11708
11713
  try {
11709
11714
  let existing;
@@ -11746,9 +11751,9 @@ function syncOps(kernel, shared) {
11746
11751
  },
11747
11752
  socketpair: () => kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
11748
11753
  pipe: () => kernel.json({ op: "fd-pipe" }),
11749
- open: procOpenSync(open, kernel, { resolve, pid: shared.pid }),
11750
- fs: procFsSync(syncPathOps(kernel, resolve, statOf, open, tryDevSync), kernel, {
11751
- resolve,
11754
+ open: procOpenSync(open, kernel, { resolve: resolve2, pid: shared.pid }),
11755
+ fs: procFsSync(syncPathOps(kernel, resolve2, statOf, open, tryDevSync), kernel, {
11756
+ resolve: resolve2,
11752
11757
  pid: shared.pid
11753
11758
  })
11754
11759
  };
@@ -11817,41 +11822,41 @@ function syncFile(kernel, fd, path, append, forget) {
11817
11822
  }
11818
11823
  };
11819
11824
  }
11820
- function syncPathOps(kernel, resolve, statOf, open, tryDev) {
11825
+ function syncPathOps(kernel, resolve2, statOf, open, tryDev) {
11821
11826
  return {
11822
11827
  stat: (path) => statOf("stat", path),
11823
11828
  lstat: (path) => statOf("lstat", path),
11824
11829
  exists(path) {
11825
- const abs = resolve(path);
11830
+ const abs = resolve2(path);
11826
11831
  if (inDev(abs)) return devSync(kernel, devExists(abs));
11827
11832
  if (kernel.json({ op: "exists", path: abs }) === true) return true;
11828
11833
  const devPath = tryDev(abs);
11829
11834
  return devPath ? devSync(kernel, devExists(devPath)) : false;
11830
11835
  },
11831
11836
  readdir(path) {
11832
- const abs = resolve(path);
11837
+ const abs = resolve2(path);
11833
11838
  if (inDev(abs)) return devSync(kernel, devReaddir(abs));
11834
11839
  return kernel.json({ op: "readdir", path: abs });
11835
11840
  },
11836
11841
  mkdir: (path, options) => void kernel.call({
11837
11842
  op: "mkdir",
11838
- path: resolve(path),
11843
+ path: resolve2(path),
11839
11844
  ...options?.recursive === false ? { exclusive: true } : {},
11840
11845
  mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
11841
11846
  }),
11842
- rm: (path) => void kernel.call({ op: "rm", path: resolve(path) }),
11843
- unlink: (path) => void kernel.call({ op: "unlink", path: resolve(path) }),
11844
- rename: (from, to) => void kernel.call({ op: "rename", path: resolve(from), arg2: resolve(to) }),
11845
- chmod: (path, mode) => void kernel.call({ op: "chmod", path: resolve(path), mode: modeOf(mode) }),
11846
- link: (from, to) => void kernel.call({ op: "link", path: resolve(from), arg2: resolve(to) }),
11847
- symlink: (target, path) => void kernel.call({ op: "symlink", path: resolve(path), arg2: target }),
11847
+ rm: (path) => void kernel.call({ op: "rm", path: resolve2(path) }),
11848
+ unlink: (path) => void kernel.call({ op: "unlink", path: resolve2(path) }),
11849
+ rename: (from, to) => void kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
11850
+ chmod: (path, mode) => void kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
11851
+ link: (from, to) => void kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
11852
+ symlink: (target, path) => void kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
11848
11853
  readlink(path) {
11849
- const abs = resolve(path);
11854
+ const abs = resolve2(path);
11850
11855
  if (inDev(abs)) return devSync(kernel, devReadlink(abs));
11851
11856
  return String(kernel.json({ op: "readlink", path: abs }));
11852
11857
  },
11853
11858
  statfs(path) {
11854
- let abs = resolve(path);
11859
+ let abs = resolve2(path);
11855
11860
  if (inDev(abs)) {
11856
11861
  try {
11857
11862
  const target = devSync(kernel, devResolveTarget(abs));
@@ -11863,7 +11868,7 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev) {
11863
11868
  return statFsOf(kernel.json({ op: "statfs", path: abs }));
11864
11869
  },
11865
11870
  readFile(path) {
11866
- const abs = resolve(path);
11871
+ const abs = resolve2(path);
11867
11872
  if (inDev(abs)) return readWholeSync(open(abs));
11868
11873
  try {
11869
11874
  kernel.call({ op: "fd-path-flush", path: abs });
@@ -14121,8 +14126,8 @@ async function runWasmProcess(init, port3, deps = {}) {
14121
14126
  let exports;
14122
14127
  let atExit = () => () => {
14123
14128
  };
14124
- const initialized = new Promise((resolve, reject) => {
14125
- ready = resolve;
14129
+ const initialized = new Promise((resolve2, reject) => {
14130
+ ready = resolve2;
14126
14131
  failed5 = reject;
14127
14132
  });
14128
14133
  const id = identify(transport, init);
@@ -14508,12 +14513,12 @@ function within2(root, dir, path) {
14508
14513
  }
14509
14514
  return true;
14510
14515
  }
14511
- function preopensOf(given, resolve) {
14516
+ function preopensOf(given, resolve2) {
14512
14517
  if (given === void 0) return [];
14513
14518
  if (typeof given !== "object" || given === null) throw new JsCallError("EINVAL", "wasi preopens");
14514
14519
  return Object.entries(given).map(([name2, path]) => {
14515
14520
  if (typeof path !== "string" || path === "") throw new JsCallError("EINVAL", "wasi preopens");
14516
- return [name2, normalize(resolve(path))];
14521
+ return [name2, normalize(resolve2(path))];
14517
14522
  });
14518
14523
  }
14519
14524
  function createJsWasi(deps, o = {}) {
@@ -14842,8 +14847,8 @@ function websocketOp(kernel) {
14842
14847
  }
14843
14848
  let settle;
14844
14849
  let lose;
14845
- const closed = new Promise((resolve, reject) => {
14846
- settle = resolve;
14850
+ const closed = new Promise((resolve2, reject) => {
14851
+ settle = resolve2;
14847
14852
  lose = reject;
14848
14853
  });
14849
14854
  closed.catch(() => void 0);
@@ -14942,7 +14947,7 @@ var init_js_websocket = __esm({
14942
14947
  SEND_BUFFER = 1024 * 1024;
14943
14948
  MAX_REASON = 123;
14944
14949
  NEVER2 = new AbortController().signal;
14945
- wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14950
+ wait = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
14946
14951
  }
14947
14952
  });
14948
14953
 
@@ -15220,7 +15225,7 @@ function tracked2(pending, writeAll, writeSome, failed5) {
15220
15225
  if (status2 !== void 0) return Promise.reject(new JsExit(status2));
15221
15226
  const bytes = typeof data === "string" ? encoder4.encode(data) : data;
15222
15227
  let settle;
15223
- const settled2 = new Promise((resolve) => settle = resolve);
15228
+ const settled2 = new Promise((resolve2) => settle = resolve2);
15224
15229
  pending.add(settled2);
15225
15230
  return (async () => {
15226
15231
  try {
@@ -15255,7 +15260,7 @@ function createContext(o) {
15255
15260
  const pending = /* @__PURE__ */ new Set();
15256
15261
  const random = o.random ?? cryptoRandom;
15257
15262
  let held2;
15258
- const resolve = (path) => resolvePath(cwdFor(o.cwd, held2, path), path);
15263
+ const resolve2 = (path) => resolvePath(cwdFor(o.cwd, held2, path), path);
15259
15264
  const tryDev = (abs) => resolveDevAsync(kernel, abs);
15260
15265
  let exiting;
15261
15266
  const exit = (code2 = 0) => {
@@ -15283,13 +15288,13 @@ function createContext(o) {
15283
15288
  }
15284
15289
  });
15285
15290
  const statOf = async (op, path) => {
15286
- const abs = resolve(path);
15291
+ const abs = resolve2(path);
15287
15292
  if (inDev(abs)) return devAsync(kernel, devStat(abs, op === "stat"));
15288
15293
  return vfsStat(kernel, abs, op, tryDev);
15289
15294
  };
15290
15295
  const devIo = { infos, handles, read: read2, write: writeAll };
15291
15296
  const open = async (path, options = {}, whole = false) => {
15292
- const abs = resolve(path);
15297
+ const abs = resolve2(path);
15293
15298
  if (inDev(abs)) return openDev(kernel, abs, options, devIo);
15294
15299
  try {
15295
15300
  return await vfsOpen(kernel, abs, options, statOf, devIo, whole);
@@ -15300,8 +15305,8 @@ function createContext(o) {
15300
15305
  return openDev(kernel, devPath, options, devIo);
15301
15306
  }
15302
15307
  };
15303
- const fs = procFsAsync(pathOps(kernel, resolve, statOf, open, tryDev), kernel, {
15304
- resolve,
15308
+ const fs = procFsAsync(pathOps(kernel, resolve2, statOf, open, tryDev), kernel, {
15309
+ resolve: resolve2,
15305
15310
  pid: o.pid
15306
15311
  });
15307
15312
  const lane = o.lane ?? laneOf(void 0);
@@ -15309,13 +15314,13 @@ function createContext(o) {
15309
15314
  const syncKernel = new JsSyncKernel(lane, kernel, unwind);
15310
15315
  held2 = heldOn(o.held, lane, syncKernel);
15311
15316
  const terminal = ttyOps(kernel, syncKernel);
15312
- const shared = { pid: o.pid, resolve, random, infos, handles, closing };
15313
- const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve, fs: o.fs, owned: o.owned });
15317
+ const shared = { pid: o.pid, resolve: resolve2, random, infos, handles, closing };
15318
+ const wasi = wasiFor({ lane, pid: o.pid, cwd: o.cwd, resolve: resolve2, fs: o.fs, owned: o.owned });
15314
15319
  const sync = {
15315
15320
  kernel: KERNEL_INFO,
15316
15321
  tty: terminal.syncTty,
15317
15322
  ...watchingSyncOps(kernel, syncKernel, shared),
15318
- run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
15323
+ run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve: resolve2, signal: signalNumber }, options),
15319
15324
  spawn: (options) => spawnSync(options),
15320
15325
  wasi: { create: wasi.create },
15321
15326
  exit: (status2 = 0) => {
@@ -15364,8 +15369,8 @@ function createContext(o) {
15364
15369
  return { type, tty: type === "tty", seekable: type === "file" };
15365
15370
  },
15366
15371
  isatty: async (fd) => typeOf(await info(fd)) === "tty",
15367
- open: procOpenAsync(open, kernel, { resolve, pid: o.pid }),
15368
- resolve,
15372
+ open: procOpenAsync(open, kernel, { resolve: resolve2, pid: o.pid }),
15373
+ resolve: resolve2,
15369
15374
  fs,
15370
15375
  signals: {
15371
15376
  on: async (signal, handler) => kernel.setHandler(signalNumber(signal), handler),
@@ -15396,7 +15401,7 @@ function createContext(o) {
15396
15401
  wasi.closeAll();
15397
15402
  for (; ; ) {
15398
15403
  await Promise.all([...pending]);
15399
- await new Promise((resolve2) => setTimeout(resolve2, 0));
15404
+ await new Promise((resolve3) => setTimeout(resolve3, 0));
15400
15405
  if (pending.size === 0) break;
15401
15406
  }
15402
15407
  await terminal.restore();
@@ -15511,41 +15516,41 @@ async function sendSome(kernel, fd, body, signal) {
15511
15516
  await kernel.blocking({ op: "fd-select", read: [], write: [fd], timeoutMs: -1 }, signal);
15512
15517
  }
15513
15518
  }
15514
- function pathOps(kernel, resolve, statOf, open, tryDev) {
15519
+ function pathOps(kernel, resolve2, statOf, open, tryDev) {
15515
15520
  return {
15516
15521
  stat: (path) => statOf("stat", path),
15517
15522
  lstat: (path) => statOf("lstat", path),
15518
15523
  async exists(path) {
15519
- const abs = resolve(path);
15524
+ const abs = resolve2(path);
15520
15525
  if (inDev(abs)) return devAsync(kernel, devExists(abs));
15521
15526
  if (await kernel.json({ op: "exists", path: abs }) === true) return true;
15522
15527
  const devPath = await tryDev(abs);
15523
15528
  return devPath ? devAsync(kernel, devExists(devPath)) : false;
15524
15529
  },
15525
15530
  async readdir(path) {
15526
- const abs = resolve(path);
15531
+ const abs = resolve2(path);
15527
15532
  if (inDev(abs)) return devAsync(kernel, devReaddir(abs));
15528
15533
  return await kernel.json({ op: "readdir", path: abs });
15529
15534
  },
15530
15535
  mkdir: async (path, options) => void await kernel.call({
15531
15536
  op: "mkdir",
15532
- path: resolve(path),
15537
+ path: resolve2(path),
15533
15538
  ...options?.recursive === false ? { exclusive: true } : {},
15534
15539
  mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
15535
15540
  }),
15536
- rm: async (path) => void await kernel.call({ op: "rm", path: resolve(path) }),
15537
- unlink: async (path) => void await kernel.call({ op: "unlink", path: resolve(path) }),
15538
- rename: async (from, to) => void await kernel.call({ op: "rename", path: resolve(from), arg2: resolve(to) }),
15539
- chmod: async (path, mode) => void await kernel.call({ op: "chmod", path: resolve(path), mode: modeOf(mode) }),
15540
- link: async (from, to) => void await kernel.call({ op: "link", path: resolve(from), arg2: resolve(to) }),
15541
- symlink: async (target, path) => void await kernel.call({ op: "symlink", path: resolve(path), arg2: target }),
15541
+ rm: async (path) => void await kernel.call({ op: "rm", path: resolve2(path) }),
15542
+ unlink: async (path) => void await kernel.call({ op: "unlink", path: resolve2(path) }),
15543
+ rename: async (from, to) => void await kernel.call({ op: "rename", path: resolve2(from), arg2: resolve2(to) }),
15544
+ chmod: async (path, mode) => void await kernel.call({ op: "chmod", path: resolve2(path), mode: modeOf(mode) }),
15545
+ link: async (from, to) => void await kernel.call({ op: "link", path: resolve2(from), arg2: resolve2(to) }),
15546
+ symlink: async (target, path) => void await kernel.call({ op: "symlink", path: resolve2(path), arg2: target }),
15542
15547
  async readlink(path) {
15543
- const abs = resolve(path);
15548
+ const abs = resolve2(path);
15544
15549
  if (inDev(abs)) return devAsync(kernel, devReadlink(abs));
15545
15550
  return String(await kernel.json({ op: "readlink", path: abs }));
15546
15551
  },
15547
15552
  async statfs(path) {
15548
- let abs = resolve(path);
15553
+ let abs = resolve2(path);
15549
15554
  if (inDev(abs)) {
15550
15555
  const target = await devAsync(kernel, devResolveTarget(abs)).catch(() => void 0);
15551
15556
  if (target?.startsWith("/")) abs = target;
@@ -15555,11 +15560,11 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
15555
15560
  },
15556
15561
  async watch(path, options, listener) {
15557
15562
  const [given, onNote] = watchArgs(options, listener);
15558
- const id = await kernel.json(watchRequest(resolve(path), given));
15563
+ const id = await kernel.json(watchRequest(resolve2(path), given));
15559
15564
  return follow2(kernel, id, onNote);
15560
15565
  },
15561
15566
  async readFile(path) {
15562
- const abs = resolve(path);
15567
+ const abs = resolve2(path);
15563
15568
  if (inDev(abs)) return readWhole(await open(abs));
15564
15569
  try {
15565
15570
  await kernel.call({ op: "fd-path-flush", path: abs });
@@ -15642,7 +15647,7 @@ function optionsOf(options) {
15642
15647
  }
15643
15648
  function started(port3, control) {
15644
15649
  const exited = Promise.withResolvers();
15645
- return new Promise((resolve, reject) => {
15650
+ return new Promise((resolve2, reject) => {
15646
15651
  const thread = (tid) => Object.freeze({
15647
15652
  tid,
15648
15653
  port: port3,
@@ -15654,7 +15659,7 @@ function started(port3, control) {
15654
15659
  });
15655
15660
  control.onmessage = (event) => {
15656
15661
  const said = event.data;
15657
- if ("tid" in said) resolve(thread(said.tid));
15662
+ if ("tid" in said) resolve2(thread(said.tid));
15658
15663
  else if ("errno" in said) {
15659
15664
  control.close();
15660
15665
  port3.close();
@@ -15737,7 +15742,7 @@ function trapStrays(scope2, stray) {
15737
15742
  });
15738
15743
  }
15739
15744
  async function settledStrays() {
15740
- for (let turn = 0; turn < 2; turn++) await new Promise((resolve) => setTimeout(resolve, 0));
15745
+ for (let turn = 0; turn < 2; turn++) await new Promise((resolve2) => setTimeout(resolve2, 0));
15741
15746
  }
15742
15747
  function message(err) {
15743
15748
  return err instanceof Error ? err.message : String(err);
@@ -15760,7 +15765,7 @@ async function runJs(init, port3, deps, thread) {
15760
15765
  const failed5 = (err) => thread && outOfMemory(err) ? JS_THREAD_NO_MEMORY : 1;
15761
15766
  const transport = createAsyncSabTransport(init.sab, port3, deps.waitAsync);
15762
15767
  let resolveExit;
15763
- const exit = new Promise((resolve) => resolveExit = resolve);
15768
+ const exit = new Promise((resolve2) => resolveExit = resolve2);
15764
15769
  let exitedWith;
15765
15770
  const exited = (status3) => {
15766
15771
  exitedWith ??= status3;
@@ -15818,6 +15823,7 @@ async function runJs(init, port3, deps, thread) {
15818
15823
  (deps.lockdown ?? lockdown)();
15819
15824
  const { url, glue } = init.program;
15820
15825
  main = mainOf(await (url ? import(url) : (deps.load ?? importSource)(glue)));
15826
+ deps.imported?.();
15821
15827
  } catch (err) {
15822
15828
  await say(message(err));
15823
15829
  return NOT_RUNNABLE;
@@ -16949,7 +16955,7 @@ var init_wasix_linker = __esm({
16949
16955
  return { env, "GOT.mem": gotMem, "GOT.func": gotFunc };
16950
16956
  }
16951
16957
  bindMainGot() {
16952
- for (const resolve of this.mainGot) resolve();
16958
+ for (const resolve2 of this.mainGot) resolve2();
16953
16959
  }
16954
16960
  bindMain(instance, relocate) {
16955
16961
  this.main = instance;
@@ -17081,8 +17087,8 @@ var init_wasix_linker = __esm({
17081
17087
  this.slots.set(value2, record.index);
17082
17088
  }
17083
17089
  moduleAt(path) {
17084
- const cached = this.cache?.[path];
17085
- if (cached) return cached;
17090
+ const cached2 = this.cache?.[path];
17091
+ if (cached2) return cached2;
17086
17092
  const bytes = this.host.read(path);
17087
17093
  if (!bytes) throw new DlError(`${path}: gone`);
17088
17094
  return new WebAssembly.Module(bytes);
@@ -17187,7 +17193,7 @@ var init_wasix_linker = __esm({
17187
17193
  this.modules.set(at.handle, linked);
17188
17194
  const first = this.byPath.get(path);
17189
17195
  if (!first || at.handle < first.handle) this.byPath.set(path, linked);
17190
- for (const resolve of pending) resolve();
17196
+ for (const resolve2 of pending) resolve2();
17191
17197
  if (init) {
17192
17198
  call(linked.instance, "__wasm_apply_data_relocs");
17193
17199
  call(linked.instance, "__wasm_call_ctors");
@@ -17962,8 +17968,8 @@ function createImportedMemory(spec, copy2) {
17962
17968
  if (copy2) fillMemory(memory, copy2);
17963
17969
  return memory;
17964
17970
  }
17965
- function restoreExportedMemory(instance, imported, init) {
17966
- if (imported || !init.fork?.wasi) return;
17971
+ function restoreExportedMemory(instance, imported2, init) {
17972
+ if (imported2 || !init.fork?.wasi) return;
17967
17973
  fillMemory(instance.exports.memory, init.fork.memory);
17968
17974
  }
17969
17975
  function fillMemory(memory, copy2) {
@@ -17974,8 +17980,8 @@ function fillMemory(memory, copy2) {
17974
17980
  function sizeOf2(main) {
17975
17981
  return () => main.memory?.buffer.byteLength ?? 0;
17976
17982
  }
17977
- function memoryOf(instance, imported) {
17978
- return imported ?? instance.exports.memory;
17983
+ function memoryOf(instance, imported2) {
17984
+ return imported2 ?? instance.exports.memory;
17979
17985
  }
17980
17986
  function kernelOf(init, port3, hooks = { masks: () => null, raise: () => {
17981
17987
  } }, memory) {
@@ -18316,9 +18322,9 @@ function programNames(host, program, warned) {
18316
18322
  const path = program.names;
18317
18323
  if (path === void 0) return void 0;
18318
18324
  const read2 = (p) => host.o.fs.readFile(p);
18319
- const imported = WebAssembly.Module.imports(program.module).filter((i) => i.kind === "function");
18325
+ const imported2 = WebAssembly.Module.imports(program.module).filter((i) => i.kind === "function");
18320
18326
  return sidecarNames(read2, path, {
18321
- functions: () => imported.length + definedFunctions(read2(program.path)),
18327
+ functions: () => imported2.length + definedFunctions(read2(program.path)),
18322
18328
  warn: (line) => warned.push(line)
18323
18329
  });
18324
18330
  }
@@ -18562,12 +18568,13 @@ var init_wasi_runtime = __esm({
18562
18568
  });
18563
18569
 
18564
18570
  // src/node-process-worker.ts
18565
- import { createRequire } from "node:module";
18566
- import { parentPort } from "node:worker_threads";
18571
+ import { createRequire, enableCompileCache, flushCompileCache } from "node:module";
18572
+ import { parentPort, workerData } from "node:worker_threads";
18567
18573
 
18568
18574
  // src/node-lockdown.ts
18569
18575
  init_lockdown();
18570
18576
  import { isBuiltin, registerHooks } from "node:module";
18577
+ import { resolve, sep } from "node:path";
18571
18578
  import { getHeapStatistics } from "node:v8";
18572
18579
  var NODE_GLOBALS = ["localStorage", "sessionStorage"];
18573
18580
  var NODE_SLOTS = [
@@ -18660,6 +18667,16 @@ function workerShaped(scope2, href) {
18660
18667
  location: slot2(Object.freeze({ href }))
18661
18668
  });
18662
18669
  }
18670
+ function ownCache(dir, result) {
18671
+ const active = result.directory;
18672
+ if (active === void 0) return false;
18673
+ if (!`${resolve(active)}${sep}`.startsWith(`${resolve(dir)}${sep}`)) {
18674
+ throw new Error(
18675
+ `slicc-kernel: compileCache ${dir} was asked for, but this worker already caches in ${active} (a host preload enabled it): refusing to run programs`
18676
+ );
18677
+ }
18678
+ return true;
18679
+ }
18663
18680
 
18664
18681
  // src/node-process-worker.ts
18665
18682
  init_js_runtime();
@@ -18736,6 +18753,9 @@ var scope = globalThis;
18736
18753
  scope.require ??= createRequire(import.meta.url);
18737
18754
  scope.__filename ??= new URL(import.meta.url).pathname;
18738
18755
  scope.__dirname ??= new URL(".", import.meta.url).pathname;
18756
+ var cacheDir = workerData?.compileCache;
18757
+ var cached = typeof cacheDir === "string" && ownCache(cacheDir, enableCompileCache(cacheDir));
18758
+ var imported = cached ? () => flushCompileCache() : void 0;
18739
18759
  var port2 = parentPort;
18740
18760
  var post = {
18741
18761
  postMessage: (message2, transfer) => port2.postMessage(message2, transfer)
@@ -18752,12 +18772,14 @@ var onMessage = processEntry(
18752
18772
  runJsProcess: (init, at) => runJsProcess(init, at, {
18753
18773
  lockdown: () => nodeLockdown(),
18754
18774
  scope: strayScope,
18755
- memory: nodeMemory
18775
+ memory: nodeMemory,
18776
+ imported
18756
18777
  }),
18757
18778
  runJsThread: (init, at) => runJsThread(init, at, {
18758
18779
  lockdown: () => nodeLockdown(),
18759
18780
  scope: strayScope,
18760
- memory: nodeMemory
18781
+ memory: nodeMemory,
18782
+ imported
18761
18783
  })
18762
18784
  }),
18763
18785
  () => nodeLockdown()