@ai-ecoverse/slicc-kernel 1.125.0 → 1.125.2

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.
@@ -605,7 +605,7 @@ function parseSyncFsStat(json2) {
605
605
  ...typeof s.gid === "number" ? { gid: s.gid } : {}
606
606
  };
607
607
  }
608
- var SYNC_FS_OPS, HOLD_READ, HOLD_WRITE, HOLD_CREATED, SYNC_FS_REQUEST_TIMEOUT_MS;
608
+ var SYNC_FS_OPS, HOLD_READ, HOLD_WRITE, HOLD_CREATED, SYNC_FS_REQUEST_TIMEOUT_MS, SYNC_FS_READ_ONLY;
609
609
  var init_sync_fs_wire = __esm({
610
610
  "src/realm/sync-fs-wire.ts"() {
611
611
  "use strict";
@@ -645,6 +645,19 @@ var init_sync_fs_wire = __esm({
645
645
  HOLD_WRITE = 8;
646
646
  HOLD_CREATED = 16;
647
647
  SYNC_FS_REQUEST_TIMEOUT_MS = 25e3;
648
+ SYNC_FS_READ_ONLY = /* @__PURE__ */ new Set([
649
+ "read",
650
+ "pread",
651
+ "exists",
652
+ "stat",
653
+ "lstat",
654
+ "readdir",
655
+ "readdir-stat",
656
+ "readlink",
657
+ "statfs",
658
+ "kept",
659
+ "access"
660
+ ]);
648
661
  }
649
662
  });
650
663
 
@@ -734,6 +747,17 @@ function index(map, key, path) {
734
747
  paths.add(path);
735
748
  map.set(key, paths);
736
749
  }
750
+ function goneAbove(maps, live, path) {
751
+ for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
752
+ const up = path.slice(0, at);
753
+ for (const map of maps) {
754
+ const hit = map.get(up);
755
+ const code2 = hit && "until" in hit ? hit.error.code : void 0;
756
+ if (hit && "until" in hit && code2 === "ENOENT" && live(hit, up)) return hit;
757
+ }
758
+ }
759
+ return void 0;
760
+ }
737
761
  function cachingBridge(bridge, now = () => performance.now(), shared) {
738
762
  const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
739
763
  const cache = new StatCache(blind ? void 0 : shared);
@@ -741,17 +765,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
741
765
  const view = bridge.changes;
742
766
  const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
743
767
  const seen = new SeenAt(view, lstats);
744
- const gone = (path) => {
745
- for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
746
- const up = path.slice(0, at);
747
- for (const map of [lstats, stats]) {
748
- const hit = map.get(up);
749
- const code2 = hit && "until" in hit ? hit.error.code : void 0;
750
- if (hit && "until" in hit && code2 === "ENOENT" && live(hit, up)) return hit;
751
- }
752
- }
753
- return void 0;
754
- };
768
+ const kept = remember(cache, seen, blind);
769
+ const gone = (path) => goneAbove([lstats, stats], live, path);
755
770
  const cached = (map, path, get) => {
756
771
  if (blind || view?.foreign()) return get();
757
772
  cache.fresh();
@@ -877,7 +892,10 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
877
892
  ...bridge.keptStat ? { keptStat: bridge.keptStat.bind(bridge) } : {},
878
893
  ...bridge.pinned ? { pinned: (handle) => pinnedIo(bridge, handle, rewriting) } : {},
879
894
  ...bridge.create ? {
880
- create: (p, mode, opening2) => mutating(() => bridge.create?.(p, mode, opening2), ...entry(p))
895
+ create: (p, mode, opening2) => kept(
896
+ p,
897
+ mutating(() => bridge.create?.(p, mode, opening2), ...entry(p))
898
+ )
881
899
  } : {},
882
900
  ...bridge.mkfifo ? {
883
901
  mkfifo: (p, mode) => mutating(() => bridge.mkfifo?.(p, mode), ...entry(p))
@@ -914,7 +932,7 @@ function pinnedIo(bridge, handle, rewriting) {
914
932
  } : {}
915
933
  };
916
934
  }
917
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt;
935
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
918
936
  var init_wasi_files = __esm({
919
937
  "src/process/wasi/wasi-files.ts"() {
920
938
  "use strict";
@@ -1304,6 +1322,13 @@ var init_wasi_files = __esm({
1304
1322
  return since.changed;
1305
1323
  }
1306
1324
  };
1325
+ remember = (cache, seen, blind) => (path, made) => {
1326
+ if (!made || blind) return made;
1327
+ const { seen: at, ...st } = made;
1328
+ cache.put(cache.stats, path, st);
1329
+ if (at !== void 0) seen.saw(cache.stats, path, at);
1330
+ return made;
1331
+ };
1307
1332
  }
1308
1333
  });
1309
1334
 
@@ -1356,7 +1381,8 @@ function decodeSabResult(status2, payload) {
1356
1381
  try {
1357
1382
  const parsed = JSON.parse(decoder.decode(payload));
1358
1383
  const errno2 = typeof parsed.errno === "string" && /^E[A-Z]+$|^EAI_[A-Z]+$/.test(parsed.errno) ? parsed.errno : "EIO";
1359
- return { ok: false, errno: errno2, message: String(parsed.message ?? errno2) };
1384
+ const message2 = String(parsed.message ?? errno2);
1385
+ return parsed.direct === true ? { ok: false, errno: errno2, message: message2, direct: true } : { ok: false, errno: errno2, message: message2 };
1360
1386
  } catch {
1361
1387
  return { ok: false, errno: "EIO", message: "sync-sab: malformed errno payload" };
1362
1388
  }
@@ -3418,6 +3444,8 @@ var init_wasi_fds = __esm({
3418
3444
  return openDevice2.call(this.kernel.sys, flags);
3419
3445
  }
3420
3446
  open(path, oflags, rights, fdflags, mode) {
3447
+ this.made = void 0;
3448
+ this.created = false;
3421
3449
  const device2 = deviceOf(path);
3422
3450
  if (device2) return this.install({ type: "device", device: device2 });
3423
3451
  const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
@@ -3425,8 +3453,8 @@ var init_wasi_fds = __esm({
3425
3453
  const alias = stdioAlias(path);
3426
3454
  if (alias !== void 0) return this.reopen(alias);
3427
3455
  const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
3428
- if (exclusive && this.shared && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
3429
- return this.kernelFile(path, void 0, oflags, rights, fdflags, mode, true);
3456
+ if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
3457
+ return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
3430
3458
  }
3431
3459
  if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
3432
3460
  const s = this.statOrMissing(path);
@@ -3443,15 +3471,15 @@ var init_wasi_fds = __esm({
3443
3471
  refuseWrite(s, oflags, rights);
3444
3472
  return this.regular(path, s, oflags, rights, fdflags, mode);
3445
3473
  }
3446
- regular(path, s, oflags, rights, fdflags, mode) {
3474
+ regular(path, s, oflags, rights, fdflags, mode, created = false) {
3447
3475
  if (s?.isFifo) return this.kernelFifo(path, s, oflags, rights, fdflags);
3448
3476
  if (s?.isSocket) throw new WasiError("ENXIO");
3449
3477
  if (this.shared || this.kernelHolds(path, s)) {
3450
- return this.kernelFile(path, s, oflags, rights, fdflags, mode);
3478
+ return this.kernelFile(path, s, oflags, rights, fdflags, mode, created);
3451
3479
  }
3452
3480
  return this.install({
3453
3481
  type: "file",
3454
- file: this.file(path, s, oflags, rights, fdflags, mode)
3482
+ file: this.file(path, s, oflags, rights, fdflags, mode, created)
3455
3483
  });
3456
3484
  }
3457
3485
  kernelHolds(path, st) {
@@ -3474,9 +3502,9 @@ var init_wasi_fds = __esm({
3474
3502
  } catch {
3475
3503
  }
3476
3504
  }
3477
- file(path, existing, oflags, rights, fdflags, mode) {
3505
+ file(path, existing, oflags, rights, fdflags, mode, created = false) {
3478
3506
  const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
3479
- let buffer = this.buffers.get(path);
3507
+ let buffer = created ? void 0 : this.buffers.get(path);
3480
3508
  if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
3481
3509
  this.buffers.delete(path);
3482
3510
  buffer = void 0;
@@ -3487,19 +3515,21 @@ var init_wasi_fds = __esm({
3487
3515
  if (this.fs.owners) this.fs.access?.(path, want, "open");
3488
3516
  if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
3489
3517
  } else {
3490
- buffer = this.freshBuffer(path, existing, oflags, want, mode);
3518
+ buffer = this.freshBuffer(path, existing, oflags, want, mode, created);
3491
3519
  }
3492
3520
  buffer.opens++;
3493
3521
  const file = new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
3494
3522
  file.ino = existing?.ino;
3495
3523
  return file;
3496
3524
  }
3497
- freshBuffer(path, existing, oflags, want, mode) {
3498
- const made = !existing && this.createNew(path, oflags, mode);
3525
+ freshBuffer(path, existing, oflags, want, mode, created = false) {
3526
+ const made = created || !existing && this.createNew(path, oflags, mode);
3527
+ const reply = made ? this.made : void 0;
3528
+ this.made = void 0;
3499
3529
  const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
3500
3530
  if (existing?.ranged) this.fs.invalidate?.();
3501
- const seen = this.fs.changes?.now();
3502
- const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
3531
+ const seen = reply ? reply.seen : this.fs.changes?.now();
3532
+ const st = reply?.st ?? (existing?.ranged || !existing ? this.fs.stat(path) : existing);
3503
3533
  const ranged = st.ranged ? st.size : void 0;
3504
3534
  const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
3505
3535
  const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0, {
@@ -3566,10 +3596,17 @@ var init_wasi_fds = __esm({
3566
3596
  }
3567
3597
  }
3568
3598
  }
3599
+ created = false;
3600
+ made;
3601
+ creating(path, mode) {
3602
+ const st = this.fs.create?.(path, mode, true);
3603
+ this.made = st ? { st, seen: st.seen } : void 0;
3604
+ this.created = true;
3605
+ }
3569
3606
  madeAtOnce(path, mode) {
3570
3607
  if (!this.fs.create) return false;
3571
3608
  try {
3572
- this.fs.create(path, mode, true);
3609
+ this.creating(path, mode);
3573
3610
  return true;
3574
3611
  } catch (err) {
3575
3612
  if (err.code === "EEXIST") throw err;
@@ -3579,10 +3616,11 @@ var init_wasi_fds = __esm({
3579
3616
  createNew(path, oflags, mode) {
3580
3617
  if (!this.fs.create) {
3581
3618
  this.fs.writeFile(path, new Uint8Array(0));
3619
+ this.created = true;
3582
3620
  return true;
3583
3621
  }
3584
3622
  try {
3585
- this.fs.create(path, mode, true);
3623
+ this.creating(path, mode);
3586
3624
  return true;
3587
3625
  } catch (err) {
3588
3626
  if (oflags & OFLAGS.EXCL || err.code !== "EEXIST") throw err;
@@ -5194,9 +5232,8 @@ var init_wasi_host = __esm({
5194
5232
  if (alias && !alias.stdio) this.openFd(alias.fd);
5195
5233
  const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
5196
5234
  if (deviceOf(path)) this.interrupted?.();
5197
- const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
5198
5235
  mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
5199
- if (fresh) this.created(path, 438);
5236
+ if (fds.created) this.created(path, 438);
5200
5237
  } catch (err) {
5201
5238
  if (err.code !== "ENOENT") throw err;
5202
5239
  const raw = mem.string(p, l);
@@ -6258,7 +6295,7 @@ var KERNEL_VERSION, OS_RELEASE;
6258
6295
  var init_version = __esm({
6259
6296
  "src/version.ts"() {
6260
6297
  "use strict";
6261
- KERNEL_VERSION = true ? "1.125.0" : "0.0.0-dev";
6298
+ KERNEL_VERSION = true ? "1.125.2" : "0.0.0-dev";
6262
6299
  OS_RELEASE = "6.0.0-slicc";
6263
6300
  }
6264
6301
  });
@@ -7102,7 +7139,8 @@ function controlsOf(r) {
7102
7139
  clientCertificate: r.clientCertificate === true,
7103
7140
  sni: r.sni !== false,
7104
7141
  hostnameChecked: r.hostnameChecked === true,
7105
- ...r.hostnameMatches === void 0 ? {} : { hostnameMatches: r.hostnameMatches }
7142
+ ...r.hostnameMatches === void 0 ? {} : { hostnameMatches: r.hostnameMatches },
7143
+ ...r.chainError ? { chainError: r.chainError } : {}
7106
7144
  };
7107
7145
  }
7108
7146
  function sessionOf(r) {
@@ -7128,13 +7166,17 @@ function sessionOf(r) {
7128
7166
  ...controlsOf(r)
7129
7167
  });
7130
7168
  }
7169
+ function withAlert(err) {
7170
+ const alert = ALERT.exec(err.detail ?? "")?.[1];
7171
+ return alert === void 0 ? err : Object.assign(err, { alert: Number(alert) });
7172
+ }
7131
7173
  async function secureCall(call2, what = "connect") {
7132
7174
  try {
7133
7175
  return await call2();
7134
7176
  } catch (err) {
7135
7177
  const e = err;
7136
7178
  const code2 = e.code === "EPROTO" && e.detail ? TLS_CODE.exec(e.detail)?.[1] : void 0;
7137
- if (code2) throw new JsCallError(code2, what, e.detail);
7179
+ if (code2) throw withAlert(new JsCallError(code2, what, e.detail));
7138
7180
  throw err;
7139
7181
  }
7140
7182
  }
@@ -7302,7 +7344,7 @@ function netOps(kernel, io) {
7302
7344
  }
7303
7345
  };
7304
7346
  }
7305
- var PEM, TLS_CODE, SHUT_RD, SHUT_WR, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2;
7347
+ var PEM, TLS_CODE, ALERT, SHUT_RD, SHUT_WR, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2;
7306
7348
  var init_js_net = __esm({
7307
7349
  "src/process/js/js-net.ts"() {
7308
7350
  "use strict";
@@ -7310,6 +7352,7 @@ var init_js_net = __esm({
7310
7352
  init_js_kernel();
7311
7353
  PEM = /-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/g;
7312
7354
  TLS_CODE = /^([A-Z][A-Z0-9_]+): /;
7355
+ ALERT = / \(alert (\d+)\)$/;
7313
7356
  SHUT_RD = 0;
7314
7357
  SHUT_WR = 1;
7315
7358
  IPV4 = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
@@ -7528,19 +7571,21 @@ function createSyncSabTransport(sab, port3, deps = {}) {
7528
7571
  }
7529
7572
  };
7530
7573
  }
7531
- function errnoError(code2, path) {
7532
- return syncError(code2, `sync-sab bridge, '${path}'`);
7574
+ function errnoError(code2, path, direct) {
7575
+ const err = syncError(code2, `sync-sab bridge, '${path}'`);
7576
+ return direct ? Object.assign(err, { direct }) : err;
7533
7577
  }
7534
7578
  function createSyncFsSabBridge(transport, opts = {}) {
7579
+ const direct = opts.direct ? { direct: true } : {};
7535
7580
  const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
7536
7581
  let identity = {};
7537
7582
  let once = false;
7538
7583
  let last = null;
7539
7584
  function run(req, path, transfer) {
7540
7585
  last = null;
7541
- const silence = READ_ONLY.has(req.op) ? timeoutMs2 : Number.POSITIVE_INFINITY;
7586
+ const silence = SYNC_FS_READ_ONLY.has(req.op) ? timeoutMs2 : Number.POSITIVE_INFINITY;
7542
7587
  const result = transport.call(req, silence, `sync-sab bridge, '${path}'`, transfer);
7543
- if (!result.ok) throw errnoError(result.errno, path);
7588
+ if (!result.ok) throw errnoError(result.errno, path, result.direct);
7544
7589
  return result;
7545
7590
  }
7546
7591
  function bytes(req, path) {
@@ -7586,12 +7631,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
7586
7631
  return s;
7587
7632
  },
7588
7633
  stat: (path) => {
7589
- const s = parseSyncFsStat(json2({ op: "stat", path }, path));
7634
+ const s = parseSyncFsStat(json2({ op: "stat", path, ...direct }, path));
7590
7635
  if (!s) throw errnoError("EIO", path);
7591
7636
  return s;
7592
7637
  },
7593
7638
  lstat: (path) => {
7594
- const s = parseSyncFsStat(json2({ op: "lstat", path }, path));
7639
+ const s = parseSyncFsStat(json2({ op: "lstat", path, ...direct }, path));
7595
7640
  if (!s) throw errnoError("EIO", path);
7596
7641
  return s;
7597
7642
  },
@@ -7669,7 +7714,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
7669
7714
  },
7670
7715
  create: (path, mode, opening2) => {
7671
7716
  const flags = { ...mode !== void 0 ? { mode } : {}, ...opening2 ? { opening: opening2 } : {} };
7672
- run({ op: "create", path, ...flags }, path);
7717
+ const r = run({ op: "create", path, ...flags, identity: true }, path);
7718
+ if (!r.ok || r.kind !== "json") return void 0;
7719
+ const st = parseSyncFsStat(r.json);
7720
+ if (!st) return void 0;
7721
+ const { seen } = r.json;
7722
+ return typeof seen === "number" ? { ...st, seen } : st;
7673
7723
  },
7674
7724
  chown: (path, uid, gid, follow3, handle) => {
7675
7725
  const ids = { ...uid !== void 0 ? { uid } : {}, ...gid !== void 0 ? { gid } : {} };
@@ -7701,7 +7751,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
7701
7751
  statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
7702
7752
  };
7703
7753
  }
7704
- var PATH_OPS, READ_ONLY, calls, looks, SPIN_MS, SPIN_STRIDE, SPIN_STRIDES, SPIN_CORES, spinning, SPIN_CAP_MS;
7754
+ var PATH_OPS, calls, looks, SPIN_MS, SPIN_STRIDE, SPIN_STRIDES, SPIN_CORES, spinning, SPIN_CAP_MS;
7705
7755
  var init_sync_sab_bridge = __esm({
7706
7756
  "src/realm/sync-sab-bridge.ts"() {
7707
7757
  "use strict";
@@ -7710,19 +7760,6 @@ var init_sync_sab_bridge = __esm({
7710
7760
  init_sync_fs_wire();
7711
7761
  init_sync_sab_wire();
7712
7762
  PATH_OPS = new Set(SYNC_FS_OPS);
7713
- READ_ONLY = /* @__PURE__ */ new Set([
7714
- "read",
7715
- "pread",
7716
- "exists",
7717
- "stat",
7718
- "lstat",
7719
- "readdir",
7720
- "readdir-stat",
7721
- "readlink",
7722
- "statfs",
7723
- "kept",
7724
- "access"
7725
- ]);
7726
7763
  calls = 0;
7727
7764
  looks = 0;
7728
7765
  SPIN_MS = 0.06;
@@ -10299,15 +10336,15 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
10299
10336
  };
10300
10337
  const track = (stream, names) => {
10301
10338
  let current = names;
10302
- const remember = (list) => scans.set(stream, new Set(list.filter((n) => /^[1-9]\d*$/.test(n)).map(Number)));
10303
- remember(current ?? []);
10339
+ const remember2 = (list) => scans.set(stream, new Set(list.filter((n) => /^[1-9]\d*$/.test(n)).map(Number)));
10340
+ remember2(current ?? []);
10304
10341
  Object.defineProperty(stream, "getdents", {
10305
10342
  configurable: true,
10306
10343
  enumerable: true,
10307
10344
  get: () => current,
10308
10345
  set: (next2) => {
10309
10346
  current = next2;
10310
- if (next2) remember(next2);
10347
+ if (next2) remember2(next2);
10311
10348
  }
10312
10349
  });
10313
10350
  };
@@ -10492,6 +10529,10 @@ function physicalProc(fs) {
10492
10529
  return physical2;
10493
10530
  };
10494
10531
  }
10532
+ function directMiss(err, path) {
10533
+ if (err?.direct !== true) return false;
10534
+ return !path.split("/").some((part) => part === "." || part === "..");
10535
+ }
10495
10536
  function procfsBridge(fs, tree) {
10496
10537
  const toProc = (path, follow3) => procPath(fs, path, follow3);
10497
10538
  const shadowing = physicalProc(fs);
@@ -10504,6 +10545,7 @@ function procfsBridge(fs, tree) {
10504
10545
  try {
10505
10546
  return own();
10506
10547
  } catch (err) {
10548
+ if (directMiss(err, p)) throw err;
10507
10549
  const real = toProc(p, follow3);
10508
10550
  if (real === void 0) throw err;
10509
10551
  return proc(real);
@@ -10564,7 +10606,12 @@ function procfsBridge(fs, tree) {
10564
10606
  const real = shadowing() ? probe() : void 0;
10565
10607
  if (real === null) return false;
10566
10608
  if (real !== void 0) return tree.exists(real);
10567
- if (fs.exists(p)) return true;
10609
+ try {
10610
+ fs.stat(p);
10611
+ return true;
10612
+ } catch (err) {
10613
+ if (directMiss(err, p)) return false;
10614
+ }
10568
10615
  const late2 = probe();
10569
10616
  return typeof late2 === "string" && tree.exists(late2);
10570
10617
  },
@@ -11015,10 +11062,22 @@ var init_js_run = __esm({
11015
11062
  });
11016
11063
 
11017
11064
  // src/process/js/js-sync.ts
11018
- function laneOf(lane) {
11065
+ function laneOf(lane, silence = SYNC_FS_REQUEST_TIMEOUT_MS, open = createSyncSabTransport) {
11019
11066
  if (!lane) return noLane;
11020
- const transport = createSyncSabTransport(lane.sab, lane.port);
11021
- return (req) => transport.call(req, Number.POSITIVE_INFINITY, req.op);
11067
+ const transport = open(lane.sab, lane.port);
11068
+ return (req) => {
11069
+ if (!READ_ONLY.has(req.op)) return transport.call(req, Number.POSITIVE_INFINITY, req.op);
11070
+ try {
11071
+ return transport.call(req, silence, req.op);
11072
+ } catch (err) {
11073
+ const errno2 = err?.code;
11074
+ return {
11075
+ ok: false,
11076
+ errno: typeof errno2 === "string" ? errno2 : "EIO",
11077
+ message: err instanceof Error ? err.message : String(err)
11078
+ };
11079
+ }
11080
+ };
11022
11081
  }
11023
11082
  function syncOps(kernel, shared) {
11024
11083
  const { infos, handles, resolve } = shared;
@@ -11285,7 +11344,7 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev) {
11285
11344
  }
11286
11345
  };
11287
11346
  }
11288
- var encoder3, noLane, JsSyncKernel;
11347
+ var encoder3, noLane, READ_ONLY, JsSyncKernel;
11289
11348
  var init_js_sync = __esm({
11290
11349
  "src/process/js/js-sync.ts"() {
11291
11350
  "use strict";
@@ -11299,6 +11358,7 @@ var init_js_sync = __esm({
11299
11358
  init_js_proc();
11300
11359
  encoder3 = new TextEncoder();
11301
11360
  noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
11361
+ READ_ONLY = /* @__PURE__ */ new Set([...SYNC_FS_READ_ONLY, "fd-path-flush"]);
11302
11362
  JsSyncKernel = class {
11303
11363
  lane;
11304
11364
  kernel;
@@ -16910,7 +16970,7 @@ async function runWasiProcess(init, port3) {
16910
16970
  kernel: { sys: traced(stats, "kernel", sys), call: call2 },
16911
16971
  fs: procfsBridge(
16912
16972
  cachingBridge(
16913
- traced(stats, "fs", createSyncFsSabBridge(transport, ownersOf(init))),
16973
+ traced(stats, "fs", createSyncFsSabBridge(transport, { ...ownersOf(init), direct: true })),
16914
16974
  void 0,
16915
16975
  threads?.ids
16916
16976
  ),
@@ -17015,7 +17075,11 @@ async function runWasiThread(init, port3) {
17015
17075
  parent: () => identify(transport, init).ppid,
17016
17076
  kernel: { sys, call: call2 },
17017
17077
  fs: procfsBridge(
17018
- cachingBridge(createSyncFsSabBridge(transport, ownersOf(init)), void 0, threads.ids),
17078
+ cachingBridge(
17079
+ createSyncFsSabBridge(transport, { ...ownersOf(init), direct: true }),
17080
+ void 0,
17081
+ threads.ids
17082
+ ),
17019
17083
  procTree(call2, id.pid)
17020
17084
  ),
17021
17085
  shared: threads.ids