@ai-ecoverse/slicc-kernel 1.162.1 → 1.163.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.
package/dist/node.js CHANGED
@@ -3677,7 +3677,7 @@ function satisfies(version, range2) {
3677
3677
  }
3678
3678
 
3679
3679
  // src/version.ts
3680
- var KERNEL_VERSION = true ? "1.162.1" : "0.0.0-dev";
3680
+ var KERNEL_VERSION = true ? "1.163.1" : "0.0.0-dev";
3681
3681
  var OS_RELEASE = "6.0.0-slicc";
3682
3682
  function procVersion() {
3683
3683
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9070,6 +9070,11 @@ var HeldSet = class extends Set {
9070
9070
  async bindIds(id2) {
9071
9071
  for (const holds2 of [...this]) await holds2.bindIds(id2);
9072
9072
  }
9073
+ heldIds() {
9074
+ const out = /* @__PURE__ */ new Map();
9075
+ for (const holds2 of this) for (const [path, fid] of holds2.heldIds()) out.set(path, fid);
9076
+ return [...out];
9077
+ }
9073
9078
  delete(holds2) {
9074
9079
  const removed = super.delete(holds2);
9075
9080
  for (const path of /* @__PURE__ */ new Set([...holds2.keys(), ...holds2.opens.keys()])) this.idle(path);
@@ -9136,6 +9141,14 @@ var HeldPaths = class extends Map {
9136
9141
  this.bound.set(handle, { ...bound3, fid });
9137
9142
  }
9138
9143
  }
9144
+ heldIds() {
9145
+ const out = [];
9146
+ for (const [handle, key] of this.handles) {
9147
+ if (this.keptHandles.has(handle)) continue;
9148
+ out.push([key, this.bound.get(handle)?.fid]);
9149
+ }
9150
+ return out;
9151
+ }
9139
9152
  trust(handle, doubt) {
9140
9153
  if (this.doubted.get(handle) === doubt) this.doubted.delete(handle);
9141
9154
  }
@@ -32611,6 +32624,10 @@ var Launcher = class {
32611
32624
  for (const [holds2, ids] of keeping) holds2.keepBound(ids, path, file);
32612
32625
  void this.rootFs.announceHolds?.([], [path, hidden], false);
32613
32626
  }
32627
+ announceHeld() {
32628
+ const held = this.held.heldIds().filter(([path]) => this.mounts.locate(path) === void 0);
32629
+ return held.length === 0 ? void 0 : this.rootFs.announceHolds?.(held, [], false);
32630
+ }
32614
32631
  rootFileId(path) {
32615
32632
  return this.mounts.locate(path) === void 0 ? this.rootFs.bindId?.(path) : void 0;
32616
32633
  }
@@ -32621,7 +32638,7 @@ var Launcher = class {
32621
32638
  this.changes.flush();
32622
32639
  this.changes.foreign(crowded);
32623
32640
  if (crowded) {
32624
- void this.held?.bindIds((path) => this.rootFileId(path));
32641
+ void this.held?.bindIds((path) => this.rootFileId(path)).then(() => this.announceHeld());
32625
32642
  for (const nodes of this.openFiles) nodes.shared();
32626
32643
  }
32627
32644
  });
@@ -35249,8 +35266,35 @@ function sparesOf(options) {
35249
35266
  }
35250
35267
  return n;
35251
35268
  }
35252
- function processWorker(file, workerData) {
35253
- return new Worker(file, { env: workerEnv(), ...workerData ? { workerData } : {} });
35269
+ var INTERNALS = "--expose-internals";
35270
+ var internalArgv;
35271
+ function narrowArgv(argv, message3) {
35272
+ const at = message3.indexOf(": ");
35273
+ if (at < 0) return null;
35274
+ const bad = new Set(message3.slice(at + 2).split(", "));
35275
+ const kept = argv.filter((arg) => !bad.has(arg));
35276
+ return kept.length < argv.length ? kept : null;
35277
+ }
35278
+ function internalsWorker(make, argv = process.execArgv) {
35279
+ internalArgv ??= [...argv, INTERNALS];
35280
+ for (let tries = 0; internalArgv !== null && tries < 2; tries++) {
35281
+ try {
35282
+ return make(internalArgv);
35283
+ } catch (err) {
35284
+ const { code, message: message3 } = err;
35285
+ if (code !== "ERR_WORKER_INVALID_EXEC_ARGV" || typeof message3 !== "string") throw err;
35286
+ internalArgv = narrowArgv(internalArgv, message3);
35287
+ }
35288
+ }
35289
+ internalArgv = null;
35290
+ return make();
35291
+ }
35292
+ function resetInternalArgv() {
35293
+ internalArgv = void 0;
35294
+ }
35295
+ function processWorker(file, workerData, internals = false) {
35296
+ const make = (execArgv) => new Worker(file, { env: workerEnv(), ...workerData ? { workerData } : {}, execArgv });
35297
+ return internals ? internalsWorker(make) : make();
35254
35298
  }
35255
35299
  function sourceModule(source) {
35256
35300
  const url = `slicc-module:${createHash("sha256").update(source).digest("hex")}`;
@@ -35260,9 +35304,9 @@ function sourceModule(source) {
35260
35304
  function warmPoolOf(options, file, workerData, live) {
35261
35305
  const size = sparesOf(options);
35262
35306
  if (size === 0) return void 0;
35263
- return warmPool(() => processWorker(file, workerData), live, WARM_IDLE_MS, size);
35307
+ return warmPool(() => processWorker(file, workerData, true), live, WARM_IDLE_MS, size);
35264
35308
  }
35265
- function nodeWorker(file, live, closed, workerData, take) {
35309
+ function nodeWorker(file, live, closed, workerData, take, internals = false) {
35266
35310
  const errors = /* @__PURE__ */ new Set();
35267
35311
  const messages = /* @__PURE__ */ new Map();
35268
35312
  const fail3 = (message3) => {
@@ -35271,7 +35315,7 @@ function nodeWorker(file, live, closed, workerData, take) {
35271
35315
  } });
35272
35316
  }
35273
35317
  };
35274
- const worker = closed ? void 0 : take?.() ?? processWorker(file, workerData);
35318
+ const worker = closed ? void 0 : take?.() ?? processWorker(file, workerData, internals);
35275
35319
  let ending = false;
35276
35320
  if (worker) {
35277
35321
  const kill = () => {
@@ -35449,7 +35493,7 @@ async function createNodeKernel(options = {}) {
35449
35493
  fs,
35450
35494
  moduleUrl: sourceModule,
35451
35495
  unlinkOwner: pidOwner(process),
35452
- createWorker: () => nodeWorker(file, live, terminated, workerData, warm ? () => warm.take() : void 0),
35496
+ createWorker: () => nodeWorker(file, live, terminated, workerData, warm ? () => warm.take() : void 0, true),
35453
35497
  createDriverWorker: () => nodeWorker(
35454
35498
  options.driverWorker ?? new URL("./node-driver-worker.js", import.meta.url),
35455
35499
  live,
@@ -35592,10 +35636,13 @@ export {
35592
35636
  attachKernel,
35593
35637
  createNodeKernel,
35594
35638
  fetchTransport,
35639
+ internalsWorker,
35595
35640
  memoryRoot,
35641
+ narrowArgv,
35596
35642
  nodeTransport,
35597
35643
  ownCacheDir,
35598
35644
  privateCacheDir,
35645
+ resetInternalArgv,
35599
35646
  serveHostfsPort,
35600
35647
  sourceModule,
35601
35648
  sparesOf,