@ai-ecoverse/slicc-kernel 1.16.1 → 1.17.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.
@@ -1020,15 +1020,18 @@ var init_wasi_errno = __esm({
1020
1020
  EPROTONOSUPPORT: 66,
1021
1021
  EOPNOTSUPP: 138,
1022
1022
  EBADF: 8,
1023
+ EBUSY: 10,
1023
1024
  ECHILD: 12,
1024
1025
  EFAULT: 21,
1025
1026
  EINTR: 27,
1026
1027
  EINVAL: 28,
1027
1028
  EIO: 29,
1028
1029
  EMFILE: 33,
1030
+ ENODEV: 43,
1029
1031
  ENOENT: 44,
1030
1032
  ENOEXEC: 45,
1031
1033
  ENOSYS: 52,
1034
+ ENOTDIR: 54,
1032
1035
  ENOTTY: 59,
1033
1036
  ENXIO: 60,
1034
1037
  EPERM: 63,
@@ -1447,6 +1450,7 @@ function createProcessKernel(deps) {
1447
1450
  const { transport, Fs } = deps;
1448
1451
  const reaped = /* @__PURE__ */ new Map();
1449
1452
  const call2 = (req, label) => transport.call(req, Infinity, label);
1453
+ const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
1450
1454
  const slot = (fd, n, promote) => {
1451
1455
  const stream = fd >= 0 ? Fs.getStream(fd) : null;
1452
1456
  if (!stream) return { none: true };
@@ -1554,6 +1558,13 @@ function createProcessKernel(deps) {
1554
1558
  pause() {
1555
1559
  return status(call2({ op: "sig-pause" }, "pause"));
1556
1560
  },
1561
+ mount(source, target, type, flags, data) {
1562
+ const req = { op: "mount", source, target: at(target), type, flags, data };
1563
+ return status(call2(req, `mount ${target}`));
1564
+ },
1565
+ umount2(target, flags) {
1566
+ return status(call2({ op: "umount", target: at(target), flags }, `umount ${target}`));
1567
+ },
1557
1568
  kill(pid, sig) {
1558
1569
  if (pid === deps.pid) {
1559
1570
  if (sig !== 0) deps.raise?.(sig);
@@ -1973,6 +1984,7 @@ function mountTable(mounts = []) {
1973
1984
  const lines = [`${root} / ${root} rw 0 0`, "devfs /dev devfs rw 0 0", "proc /proc proc rw 0 0"];
1974
1985
  for (const m of mounts) {
1975
1986
  const options = Object.entries(m.options).map(([k, v]) => v === "" ? k : `${k}=${v}`);
1987
+ if (m.state !== "ok") options.push(m.state);
1976
1988
  const access = options.includes("ro") ? [] : ["rw"];
1977
1989
  lines.push(
1978
1990
  `${field(m.source)} ${field(m.target)} ${m.type} ${[...access, ...options].join(",")} 0 0`
@@ -4414,6 +4426,24 @@ var init_wasi_host = __esm({
4414
4426
  get cwd() {
4415
4427
  return this.fds.cwd() ?? this.startCwd;
4416
4428
  }
4429
+ sliccImports() {
4430
+ const { mem } = this;
4431
+ const path = (p, l) => {
4432
+ const text = mem.string(p, l);
4433
+ return text === "" || text.startsWith("/") ? text : normalize(`${this.cwd}/${text}`);
4434
+ };
4435
+ return wrap({
4436
+ mount: (sp, sl, tp, tl, fp, fl, flags, dp, dl) => void this.o.kernel.call({
4437
+ op: "mount",
4438
+ source: mem.string(sp, sl),
4439
+ target: path(tp, tl),
4440
+ type: mem.string(fp, fl),
4441
+ flags,
4442
+ data: mem.string(dp, dl)
4443
+ }),
4444
+ umount2: (tp, tl, flags) => void this.o.kernel.call({ op: "umount", target: path(tp, tl), flags })
4445
+ });
4446
+ }
4417
4447
  imports() {
4418
4448
  this.cache ??= wrap({
4419
4449
  ...this.processImports(),
@@ -6549,12 +6579,14 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
6549
6579
  }
6550
6580
  return void 0;
6551
6581
  }
6552
- function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign) {
6582
+ function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}) {
6553
6583
  for (const ns of Object.keys(program)) {
6554
- if (RESERVED.has(ns)) throw new Error(`the imports module may not define ${ns}`);
6584
+ if (RESERVED.has(ns) || ns === SLICC)
6585
+ throw new Error(`the imports module may not define ${ns}`);
6555
6586
  }
6556
6587
  const imports = {
6557
6588
  ...program,
6589
+ [SLICC]: { ...slicc },
6558
6590
  [PREVIEW1]: preview1,
6559
6591
  ...wasix ? { [WASIX]: { ...wasix } } : {},
6560
6592
  ...threads ? { wasi: { "thread-spawn": (arg) => threads.spawn(arg) } } : {}
@@ -6680,7 +6712,8 @@ async function instantiate(host, module, memory, threads, {
6680
6712
  () => memory ?? instance?.exports.memory,
6681
6713
  () => instance
6682
6714
  );
6683
- const hostImports = linkImports(module, preview1, wasix, memory, threads, extra, foreign);
6715
+ const slicc = traced(stats, "slicc", host.sliccImports());
6716
+ const hostImports = linkImports(module, preview1, wasix, memory, threads, extra, foreign, slicc);
6684
6717
  const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
6685
6718
  instance = await WebAssembly.instantiate(module, imports);
6686
6719
  stats?.phase("instantiate");
@@ -6856,7 +6889,7 @@ async function runWasiThread(init, port) {
6856
6889
  throw e;
6857
6890
  }
6858
6891
  }
6859
- var TRAPPED, PREVIEW1, WASIX, RESERVED, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
6892
+ var TRAPPED, PREVIEW1, WASIX, SLICC, RESERVED, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
6860
6893
  var init_wasi_runtime = __esm({
6861
6894
  "src/process/wasi/wasi-runtime.ts"() {
6862
6895
  "use strict";
@@ -6881,6 +6914,7 @@ var init_wasi_runtime = __esm({
6881
6914
  TRAPPED = 134;
6882
6915
  PREVIEW1 = "wasi_snapshot_preview1";
6883
6916
  WASIX = "wasix_32v1";
6917
+ SLICC = "slicc";
6884
6918
  RESERVED = RESERVED_NAMESPACES;
6885
6919
  noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
6886
6920
  FALLBACK_MAXIMUM_PAGES = 32768;