@ai-ecoverse/slicc-kernel 1.99.0 → 1.99.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.
package/dist/node.js CHANGED
@@ -3272,7 +3272,7 @@ function serveClient(port, host) {
3272
3272
  case "umount":
3273
3273
  return { result: await l.umountAs(clientCred(self), req.target).then(() => true) };
3274
3274
  case "mounts":
3275
- return { result: l.mounts.list() };
3275
+ return { result: l.mounts.listed() };
3276
3276
  case "dial":
3277
3277
  return dialFor(l, req, watches);
3278
3278
  case "serve-cdp":
@@ -7479,6 +7479,18 @@ function withCommandDirs(fs, names, userDir = async () => void 0, owners = false
7479
7479
  };
7480
7480
  }
7481
7481
 
7482
+ // src/fs/dev-removal.ts
7483
+ var SHM = "/dev/shm";
7484
+ function inDevTree(path) {
7485
+ if (path.startsWith(`${SHM}/`)) return false;
7486
+ return path === "/dev" || path.startsWith("/dev/");
7487
+ }
7488
+ function devRemoval(path, cred) {
7489
+ if (!inDevTree(path)) return void 0;
7490
+ if (cred && cred.euid !== 0) return "EACCES";
7491
+ return path === "/dev" ? "EBUSY" : "EPERM";
7492
+ }
7493
+
7482
7494
  // src/fs/fresh-modules.ts
7483
7495
  var MAGIC = [0, 97, 115, 109];
7484
7496
  var MAX_FRESH = 65536;
@@ -8272,12 +8284,18 @@ var DriverConnection = class _DriverConnection {
8272
8284
  timeoutMs;
8273
8285
  nextId = 0;
8274
8286
  onFail;
8275
- constructor(port, capabilities, waiting, timeoutMs, onFail) {
8287
+ idle;
8288
+ constructor(port, capabilities, waiting, timeoutMs, options) {
8276
8289
  this.port = port;
8277
8290
  this.capabilities = capabilities;
8278
8291
  this.waiting = waiting;
8279
8292
  this.timeoutMs = timeoutMs;
8280
- this.onFail = onFail;
8293
+ this.onFail = options.onFail;
8294
+ this.idle = options.idle === true;
8295
+ if (this.idle) port.unref?.();
8296
+ }
8297
+ settled() {
8298
+ if (this.idle && this.waiting.size === 0) this.port.unref?.();
8281
8299
  }
8282
8300
  static async open(port, mount, options = {}) {
8283
8301
  const timeoutMs = options.timeoutMs ?? DRIVER_TIMEOUT_MS;
@@ -8293,6 +8311,7 @@ var DriverConnection = class _DriverConnection {
8293
8311
  clearTimeout(call.timer);
8294
8312
  if (data.errno) call.reject(errnoError(data.errno, data.message ?? data.errno));
8295
8313
  else call.resolve(data.result);
8314
+ if (options.idle && waiting.size === 0) port.unref?.();
8296
8315
  });
8297
8316
  port.start?.();
8298
8317
  port.postMessage({ hello: { protocol: DRIVER_PROTOCOL, mount } });
@@ -8311,7 +8330,7 @@ var DriverConnection = class _DriverConnection {
8311
8330
  const refused2 = driverVersionError(hello.protocol);
8312
8331
  if (refused2) throw errnoError("EPROTO", refused2);
8313
8332
  if (hello.error) throw errnoError(hello.errno ?? "EIO", hello.error);
8314
- return new _DriverConnection(port, hello.capabilities ?? {}, waiting, timeoutMs, options.onFail);
8333
+ return new _DriverConnection(port, hello.capabilities ?? {}, waiting, timeoutMs, options);
8315
8334
  }
8316
8335
  call(call, transfer = []) {
8317
8336
  if (this.failure) return Promise.reject(this.failure);
@@ -8320,6 +8339,7 @@ var DriverConnection = class _DriverConnection {
8320
8339
  const timer = unref(
8321
8340
  setTimeout(() => {
8322
8341
  this.waiting.delete(id2);
8342
+ this.settled();
8323
8343
  const error = errnoError(
8324
8344
  "EIO",
8325
8345
  `the driver did not answer ${call.op} within ${this.timeoutMs} ms`
@@ -8329,6 +8349,7 @@ var DriverConnection = class _DriverConnection {
8329
8349
  this.onFail?.(error);
8330
8350
  }, this.timeoutMs)
8331
8351
  );
8352
+ if (this.idle && this.waiting.size === 0) this.port.ref?.();
8332
8353
  this.waiting.set(id2, { resolve: resolve2, reject, timer });
8333
8354
  this.port.postMessage({ ...call, id: id2 }, transfer);
8334
8355
  });
@@ -8341,6 +8362,7 @@ var DriverConnection = class _DriverConnection {
8341
8362
  call.reject(error);
8342
8363
  }
8343
8364
  this.waiting.clear();
8365
+ this.settled();
8344
8366
  }
8345
8367
  close() {
8346
8368
  this.fail(errnoError("EIO", "the file system is unmounted"));
@@ -8605,6 +8627,7 @@ var MountTable = class {
8605
8627
  devices = 0;
8606
8628
  pending = /* @__PURE__ */ new Set();
8607
8629
  notes = /* @__PURE__ */ new Map();
8630
+ system = /* @__PURE__ */ new Set();
8608
8631
  deps;
8609
8632
  constructor(deps) {
8610
8633
  this.deps = deps;
@@ -8626,6 +8649,13 @@ var MountTable = class {
8626
8649
  const noted = [...this.notes.values()].filter((note) => !this.mounts.has(note.target));
8627
8650
  return [...mounted, ...noted.map((note) => ({ ...note, options: { ...note.options } }))];
8628
8651
  }
8652
+ listed() {
8653
+ return this.list().filter((entry) => !this.system.has(entry.target));
8654
+ }
8655
+ async mountSystem(spec, fs) {
8656
+ await this.mount(spec, fs);
8657
+ this.system.add(normalizePath(spec.target));
8658
+ }
8629
8659
  note(spec, state, error) {
8630
8660
  const target = normalizePath(spec.target);
8631
8661
  this.notes.set(target, {
@@ -8687,6 +8717,7 @@ var MountTable = class {
8687
8717
  { source: spec.source, options },
8688
8718
  {
8689
8719
  ...this.deps.timeoutMs ? { timeoutMs: this.deps.timeoutMs } : {},
8720
+ ...opened2.idle ? { idle: true } : {},
8690
8721
  onInvalidate: (paths) => this.invalidated(target, paths),
8691
8722
  onFail: (error) => {
8692
8723
  if (mounted) this.crashed(mounted, error);
@@ -8732,6 +8763,7 @@ var MountTable = class {
8732
8763
  if (!mount && this.notes.delete(at)) return;
8733
8764
  if (!mount) throw errnoError("EINVAL", `${at} is not mounted`);
8734
8765
  if (!detach && this.deps.busy(at)) throw errnoError("EBUSY", `${at} has open files`);
8766
+ this.system.delete(at);
8735
8767
  this.notes.delete(at);
8736
8768
  this.mounts.delete(at);
8737
8769
  this.deps.reshaped?.();
@@ -9640,16 +9672,6 @@ var MountFs = class _MountFs {
9640
9672
  }
9641
9673
  };
9642
9674
 
9643
- // src/fs/dev-removal.ts
9644
- function inDevTree(path) {
9645
- return path === "/dev" || path.startsWith("/dev/");
9646
- }
9647
- function devRemoval(path, cred) {
9648
- if (!inDevTree(path)) return void 0;
9649
- if (cred && cred.euid !== 0) return "EACCES";
9650
- return path === "/dev" ? "EBUSY" : "EPERM";
9651
- }
9652
-
9653
9675
  // src/realm/sync-fs-token-registry.ts
9654
9676
  var registry = /* @__PURE__ */ new Map();
9655
9677
  function mintSyncFsToken(entry) {
@@ -11078,7 +11100,7 @@ var PATH_OPS = new Set(SYNC_FS_OPS);
11078
11100
  var EARLY_WHOLE_FILE = 64 * 1024;
11079
11101
 
11080
11102
  // src/version.ts
11081
- var KERNEL_VERSION = true ? "1.99.0" : "0.0.0-dev";
11103
+ var KERNEL_VERSION = true ? "1.99.2" : "0.0.0-dev";
11082
11104
  var OS_RELEASE = "6.0.0-slicc";
11083
11105
  function procVersion() {
11084
11106
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -21781,8 +21803,10 @@ var Launcher = class {
21781
21803
  },
21782
21804
  { owned: true }
21783
21805
  );
21806
+ if (spec.target === SHM) port2.unref?.();
21784
21807
  return {
21785
21808
  port: port1,
21809
+ ...spec.target === SHM ? { idle: true } : {},
21786
21810
  dispose: () => {
21787
21811
  port1.close();
21788
21812
  port2.close();
@@ -21883,6 +21907,11 @@ var Launcher = class {
21883
21907
  this.pnpmStale();
21884
21908
  return entry;
21885
21909
  }
21910
+ async mountShm() {
21911
+ await this.base.mkdir(SHM, { recursive: true });
21912
+ await this.mounts.mountSystem({ type: "tmpfs", source: "shm", target: SHM }, this.fs);
21913
+ await this.fs.chmod(SHM, 1023);
21914
+ }
21886
21915
  async ownTmp() {
21887
21916
  const real = await this.realLayoutPath("/tmp");
21888
21917
  const st = real === void 0 ? void 0 : await this.base.lstat(real).catch(() => void 0);
@@ -22039,6 +22068,7 @@ var Launcher = class {
22039
22068
  await this.resolvePrefixes();
22040
22069
  for (const dir of SHARED_DIRS) await this.base.mkdir(dir, { recursive: true });
22041
22070
  if (this.owners) await this.ownTmp();
22071
+ await this.mountShm();
22042
22072
  await this.pnpmReady();
22043
22073
  await this.users.ensure();
22044
22074
  if (this.owners) await this.stampLayout();
@@ -23779,7 +23809,7 @@ async function createNodeKernel(options = {}) {
23779
23809
  readFile: async (path) => launcher.fs.readFileBuffer(path),
23780
23810
  mount: (spec) => guard2(() => launcher.mount(spec)),
23781
23811
  umount: (target) => guard2(async () => launcher.umount(target)),
23782
- mounts: async () => launcher.mounts.list(),
23812
+ mounts: async () => launcher.mounts.listed(),
23783
23813
  setRoutes: (routes) => guard2(async () => launcher.setRoutes(routes)),
23784
23814
  updateTransportTraits: () => guard2(async () => launcher.updateTransportTraits()),
23785
23815
  users: {