@ai-ecoverse/slicc-kernel 1.159.6 → 1.160.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -206,7 +206,13 @@ function decodeSabResult(status2, payload) {
206
206
  const parsed = capturedJSON.parse(decoder.decode(payload));
207
207
  const errno2 = typeof parsed.errno === "string" && /^E[A-Z]+$|^EAI_[A-Z]+$/.test(parsed.errno) ? parsed.errno : "EIO";
208
208
  const message2 = capturedString(parsed.message ?? errno2);
209
- return parsed.direct === true ? { ok: false, errno: errno2, message: message2, direct: true } : { ok: false, errno: errno2, message: message2 };
209
+ return {
210
+ ok: false,
211
+ errno: errno2,
212
+ message: message2,
213
+ ...parsed.direct === true ? { direct: true } : {},
214
+ ...typeof parsed.dev === "string" ? { dev: parsed.dev } : {}
215
+ };
210
216
  } catch {
211
217
  return { ok: false, errno: "EIO", message: "sync-sab: malformed errno payload" };
212
218
  }
@@ -3052,7 +3058,7 @@ var init_version = __esm({
3052
3058
  "src/version.ts"() {
3053
3059
  "use strict";
3054
3060
  init_captured_globals();
3055
- KERNEL_VERSION = true ? "1.159.6" : "0.0.0-dev";
3061
+ KERNEL_VERSION = true ? "1.160.1" : "0.0.0-dev";
3056
3062
  OS_RELEASE = "6.0.0-slicc";
3057
3063
  }
3058
3064
  });
@@ -7991,6 +7997,10 @@ var init_async_sab = __esm({
7991
7997
  });
7992
7998
 
7993
7999
  // src/process/js/js-kernel.ts
8000
+ function devOf(found) {
8001
+ const dev = found?.dev;
8002
+ return typeof dev === "string" ? dev : void 0;
8003
+ }
7994
8004
  function umaskRequest(mask) {
7995
8005
  if (mask === void 0) return { op: "proc-umask" };
7996
8006
  if (!capturedNumber.isInteger(mask) || mask < 0 || mask > 511) {
@@ -8007,11 +8017,13 @@ function modeOf(mode) {
8007
8017
  function callError(result, op) {
8008
8018
  const { errno: errno2, message: message2 } = result;
8009
8019
  const detailed = typeof message2 === "string" && message2 !== errno2 && DETAILED.has(op);
8010
- return new JsCallError(
8020
+ const err = new JsCallError(
8011
8021
  errno2,
8012
8022
  detailed ? `${op}: ${message2}` : op,
8013
8023
  detailed ? message2 : void 0
8014
8024
  );
8025
+ err.dev = result.dev;
8026
+ return err;
8015
8027
  }
8016
8028
  function untilAborted(work, signal) {
8017
8029
  if (!signal) return work;
@@ -8040,6 +8052,7 @@ var init_js_kernel = __esm({
8040
8052
  JsCallError = class extends capturedError {
8041
8053
  code;
8042
8054
  detail;
8055
+ dev;
8043
8056
  constructor(code2, what, detail) {
8044
8057
  super(`${what}: ${code2}`);
8045
8058
  this.name = "JsCallError";
@@ -17695,12 +17708,12 @@ function syncOps(kernel, shared) {
17695
17708
  if (inDev(abs)) return devSync(kernel, devStat(abs, op === "stat"));
17696
17709
  try {
17697
17710
  if (!clean()) kernel.call({ op: "fd-path-flush", path: abs });
17698
- const s = parseSyncFsStat(kernel.json({ op, path: abs }));
17711
+ const s = parseSyncFsStat(kernel.json({ op, path: abs, devs: true }));
17699
17712
  if (!s) throw new JsCallError("EIO", op);
17700
17713
  return s;
17701
17714
  } catch (err) {
17702
17715
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
17703
- const devPath = tryDevSync(abs);
17716
+ const devPath = err.dev;
17704
17717
  if (!devPath) throw err;
17705
17718
  return devSync(kernel, devStat(devPath, op === "stat"));
17706
17719
  }
@@ -17771,7 +17784,7 @@ function syncOps(kernel, shared) {
17771
17784
  },
17772
17785
  pipe: () => kernel.json({ op: "fd-pipe" }),
17773
17786
  open: procOpenSync(open, kernel, { resolve, pid: shared.pid }),
17774
- fs: procFsSync(syncPathOps(kernel, resolve, statOf, open, tryDevSync, clean), kernel, {
17787
+ fs: procFsSync(syncPathOps(kernel, resolve, statOf, open, clean), kernel, {
17775
17788
  resolve,
17776
17789
  pid: shared.pid
17777
17790
  })
@@ -17848,15 +17861,16 @@ function syncFile(kernel, fd, path, append, forget) {
17848
17861
  }
17849
17862
  };
17850
17863
  }
17851
- function syncPathOps(kernel, resolve, statOf, open, tryDev, clean) {
17864
+ function syncPathOps(kernel, resolve, statOf, open, clean) {
17852
17865
  return {
17853
17866
  stat: (path) => statOf("stat", path),
17854
17867
  lstat: (path) => statOf("lstat", path),
17855
17868
  exists(path) {
17856
17869
  const abs = resolve(path);
17857
17870
  if (inDev(abs)) return devSync(kernel, devExists(abs));
17858
- if (kernel.json({ op: "exists", path: abs }) === true) return true;
17859
- const devPath = tryDev(abs);
17871
+ const found = kernel.json({ op: "exists", path: abs, devs: true });
17872
+ if (found === true) return true;
17873
+ const devPath = devOf(found);
17860
17874
  return devPath ? devSync(kernel, devExists(devPath)) : false;
17861
17875
  },
17862
17876
  readdir(path) {
@@ -17898,10 +17912,10 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev, clean) {
17898
17912
  if (inDev(abs)) return readWholeSync(open(abs));
17899
17913
  try {
17900
17914
  if (!clean()) kernel.call({ op: "fd-path-flush", path: abs });
17901
- return kernel.bytes({ op: "read", path: abs });
17915
+ return kernel.bytes({ op: "read", path: abs, devs: true });
17902
17916
  } catch (err) {
17903
17917
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
17904
- const devPath = tryDev(abs);
17918
+ const devPath = err.dev;
17905
17919
  if (!devPath) throw err;
17906
17920
  return readWholeSync(open(devPath));
17907
17921
  }
@@ -18729,15 +18743,15 @@ async function resolveDevAsync(kernel, abs) {
18729
18743
  return void 0;
18730
18744
  }
18731
18745
  }
18732
- async function vfsStat(kernel, abs, op, tryDev, clean) {
18746
+ async function vfsStat(kernel, abs, op, clean) {
18733
18747
  try {
18734
18748
  if (!clean()) await kernel.call({ op: "fd-path-flush", path: abs });
18735
- const s = parseSyncFsStat(await kernel.json({ op, path: abs }));
18749
+ const s = parseSyncFsStat(await kernel.json({ op, path: abs, devs: true }));
18736
18750
  if (!s) throw new JsCallError("EIO", op);
18737
18751
  return s;
18738
18752
  } catch (err) {
18739
18753
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
18740
- const devPath = await tryDev(abs);
18754
+ const devPath = err.dev;
18741
18755
  if (!devPath) throw err;
18742
18756
  return devAsync(kernel, devStat(devPath, op === "stat"));
18743
18757
  }
@@ -18916,9 +18930,12 @@ function scriptRunner(run) {
18916
18930
  };
18917
18931
  }
18918
18932
  function hostExtras(o) {
18933
+ const path = o.modulePath;
18934
+ const module = path === void 0 ? {} : { module: capturedObject.freeze({ path }) };
18919
18935
  return {
18920
18936
  memory: () => measured(o.memory),
18921
- ...o.asyncContext ? { asyncContext: o.asyncContext() } : {}
18937
+ ...o.asyncContext ? { asyncContext: o.asyncContext() } : {},
18938
+ ...module
18922
18939
  };
18923
18940
  }
18924
18941
  function cleanOf(sab) {
@@ -18963,7 +18980,7 @@ function createContext(o) {
18963
18980
  const statOf = async (op, path) => {
18964
18981
  const abs = resolve(path);
18965
18982
  if (inDev(abs)) return devAsync(kernel, devStat(abs, op === "stat"));
18966
- return vfsStat(kernel, abs, op, tryDev, clean);
18983
+ return vfsStat(kernel, abs, op, clean);
18967
18984
  };
18968
18985
  const devIo = { infos, handles, read: read2, write: writeAll };
18969
18986
  const open = async (path, options = {}, whole = false) => {
@@ -18978,7 +18995,7 @@ function createContext(o) {
18978
18995
  return openDev(kernel, devPath, options, devIo);
18979
18996
  }
18980
18997
  };
18981
- const fs = procFsAsync(pathOps(kernel, resolve, statOf, open, tryDev, clean), kernel, {
18998
+ const fs = procFsAsync(pathOps(kernel, resolve, statOf, open, clean), kernel, {
18982
18999
  resolve,
18983
19000
  pid: o.pid
18984
19001
  });
@@ -19194,15 +19211,16 @@ async function sendSome(kernel, fd, body, signal) {
19194
19211
  await kernel.blocking({ op: "fd-select", read: [], write: [fd], timeoutMs: -1 }, signal);
19195
19212
  }
19196
19213
  }
19197
- function pathOps(kernel, resolve, statOf, open, tryDev, clean) {
19214
+ function pathOps(kernel, resolve, statOf, open, clean) {
19198
19215
  return {
19199
19216
  stat: (path) => statOf("stat", path),
19200
19217
  lstat: (path) => statOf("lstat", path),
19201
19218
  async exists(path) {
19202
19219
  const abs = resolve(path);
19203
19220
  if (inDev(abs)) return devAsync(kernel, devExists(abs));
19204
- if (await kernel.json({ op: "exists", path: abs }) === true) return true;
19205
- const devPath = await tryDev(abs);
19221
+ const found = await kernel.json({ op: "exists", path: abs, devs: true });
19222
+ if (found === true) return true;
19223
+ const devPath = devOf(found);
19206
19224
  return devPath ? devAsync(kernel, devExists(devPath)) : false;
19207
19225
  },
19208
19226
  async readdir(path) {
@@ -19246,10 +19264,10 @@ function pathOps(kernel, resolve, statOf, open, tryDev, clean) {
19246
19264
  if (inDev(abs)) return readWhole(await open(abs));
19247
19265
  try {
19248
19266
  if (!clean()) await kernel.call({ op: "fd-path-flush", path: abs });
19249
- return await kernel.bytes({ op: "read", path: abs });
19267
+ return await kernel.bytes({ op: "read", path: abs, devs: true });
19250
19268
  } catch (err) {
19251
19269
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
19252
- const devPath = await tryDev(abs);
19270
+ const devPath = err.dev;
19253
19271
  if (!devPath) throw err;
19254
19272
  return readWhole(await open(devPath));
19255
19273
  }
@@ -19493,6 +19511,7 @@ async function runJs(init, port2, deps, thread) {
19493
19511
  memory: deps.memory,
19494
19512
  asyncContext: deps.asyncContext,
19495
19513
  runScript: deps.runScript,
19514
+ modulePath: modulePathOf(init.program),
19496
19515
  promiseState: deps.promiseState,
19497
19516
  ...thread?.owned ? { owned: thread.owned } : {},
19498
19517
  held: init.held,
@@ -19538,6 +19557,10 @@ async function runJs(init, port2, deps, thread) {
19538
19557
  if (exitedWith !== void 0) return exitedWith;
19539
19558
  return status2;
19540
19559
  }
19560
+ function modulePathOf(program) {
19561
+ if (program.glue !== "") return void 0;
19562
+ return program.path;
19563
+ }
19541
19564
  var NOT_RUNNABLE;
19542
19565
  var init_js_runtime = __esm({
19543
19566
  "src/process/js/js-runtime.ts"() {