@ai-ecoverse/slicc-kernel 1.183.0 → 1.184.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.
Files changed (60) hide show
  1. package/README.md +96 -0
  2. package/dist/async-process.js +14060 -0
  3. package/dist/async-process.js.map +7 -0
  4. package/dist/cloudflare-sources.js +2 -0
  5. package/dist/cloudflare.js +42562 -0
  6. package/dist/cloudflare.js.map +7 -0
  7. package/dist/driver-worker.js.map +2 -2
  8. package/dist/index.js.map +2 -2
  9. package/dist/kernel-worker.js +134 -39
  10. package/dist/kernel-worker.js.map +4 -4
  11. package/dist/node-driver-worker.js.map +2 -2
  12. package/dist/node-process-worker.cjs +3985 -574
  13. package/dist/node-process-worker.cjs.map +4 -4
  14. package/dist/node-process-worker.js +3985 -574
  15. package/dist/node-process-worker.js.map +4 -4
  16. package/dist/node.js +1478 -193
  17. package/dist/node.js.map +4 -4
  18. package/dist/process-worker.js +3901 -490
  19. package/dist/process-worker.js.map +4 -4
  20. package/dist/types/async/header-hook.d.ts +3 -0
  21. package/dist/types/async/link.d.ts +14 -0
  22. package/dist/types/async/message-link.d.ts +15 -0
  23. package/dist/types/async/node-host.d.ts +16 -0
  24. package/dist/types/async/remote-worker.d.ts +12 -0
  25. package/dist/types/async/snapshots.d.ts +13 -0
  26. package/dist/types/async/transport.d.ts +28 -0
  27. package/dist/types/async/wire.d.ts +113 -0
  28. package/dist/types/cdp/port.d.ts +2 -1
  29. package/dist/types/cloudflare/clock-skew.d.ts +2 -0
  30. package/dist/types/cloudflare/computer-driver.d.ts +65 -0
  31. package/dist/types/cloudflare/computer.d.ts +105 -0
  32. package/dist/types/cloudflare/fork-tokens.d.ts +17 -0
  33. package/dist/types/cloudflare/images.d.ts +20 -0
  34. package/dist/types/cloudflare/isolates.d.ts +17 -0
  35. package/dist/types/cloudflare/kernel-end.d.ts +45 -0
  36. package/dist/types/cloudflare/loader.d.ts +54 -0
  37. package/dist/types/cloudflare/options.d.ts +81 -0
  38. package/dist/types/cloudflare/placement.d.ts +61 -0
  39. package/dist/types/cloudflare/rpc-link.d.ts +49 -0
  40. package/dist/types/cloudflare/rpc-pack.d.ts +7 -0
  41. package/dist/types/cloudflare/sqlite-meta.d.ts +4 -0
  42. package/dist/types/cloudflare/sqlite-root.d.ts +5 -0
  43. package/dist/types/cloudflare/sqlite-store.d.ts +73 -0
  44. package/dist/types/cloudflare.d.ts +16 -0
  45. package/dist/types/facade/port.d.ts +2 -1
  46. package/dist/types/kernel/host.d.ts +1 -0
  47. package/dist/types/kernel/process.d.ts +2 -0
  48. package/dist/types/kernel/protocol.d.ts +1 -0
  49. package/dist/types/launcher.d.ts +16 -0
  50. package/dist/types/mount/hostfs.d.ts +2 -1
  51. package/dist/types/mount/in-process.d.ts +15 -0
  52. package/dist/types/node.d.ts +14 -0
  53. package/dist/types/ports.d.ts +7 -0
  54. package/dist/types/process/wasi/wasi-files.d.ts +1 -0
  55. package/dist/types/process/wasi/wasi-host.d.ts +3 -2
  56. package/dist/types/process/wasi/wasi-module.d.ts +2 -0
  57. package/dist/types/process/wasi/wasi-sigmask.d.ts +2 -1
  58. package/dist/types/process/wasi/wasm-reentry.d.ts +1 -0
  59. package/dist/types/realm/sync-sab-bridge.d.ts +1 -0
  60. package/package.json +10 -4
@@ -5032,10 +5032,13 @@ function fresh(bytes, start2 = 0, end = bytes.length) {
5032
5032
  return new Uint8Array(bytes.subarray(start2, end));
5033
5033
  }
5034
5034
 
5035
+ // src/ports.ts
5036
+ var messageChannel = () => new MessageChannel();
5037
+
5035
5038
  // src/cdp/port.ts
5036
- function portCdpHook(ask, gone) {
5039
+ function portCdpHook(ask, gone, ports = messageChannel) {
5037
5040
  return (request3) => new Promise((resolve2, reject) => {
5038
- const { port1, port2 } = new MessageChannel();
5041
+ const { port1, port2 } = ports();
5039
5042
  let closed = false;
5040
5043
  const conn = {
5041
5044
  send: (m) => {
@@ -5293,9 +5296,9 @@ function embedderReplyOf(data) {
5293
5296
 
5294
5297
  // src/facade/port.ts
5295
5298
  var FACADE_GONE = "the facade host is gone";
5296
- function portFacadeHook(ask, gone) {
5299
+ function portFacadeHook(ask, gone, ports = messageChannel) {
5297
5300
  return (stamp, { name: name2 }) => new Promise((resolve2, reject) => {
5298
- const { port1, port2 } = new MessageChannel();
5301
+ const { port1, port2 } = ports();
5299
5302
  let closed = false;
5300
5303
  const shut = () => {
5301
5304
  closed = true;
@@ -8468,7 +8471,7 @@ function signalOf(host) {
8468
8471
  }
8469
8472
  function dialFor(l, req, open2) {
8470
8473
  const socket = dialSocket(l.net, req.port, req.host);
8471
- const { port1, port2 } = new MessageChannel();
8474
+ const { port1, port2 } = l.ports();
8472
8475
  open2.set(
8473
8476
  req.id,
8474
8477
  serveSocket(socket, port1, () => open2.delete(req.id))
@@ -8561,7 +8564,8 @@ function cdpRegistry(send2, gone) {
8561
8564
  (request3, cdp) => send2({ cdpOpen: { ...request3, registration: req.id }, port: cdp }, [
8562
8565
  cdp
8563
8566
  ]),
8564
- gone
8567
+ gone,
8568
+ l.ports
8565
8569
  );
8566
8570
  registered.set(req.id, l.cdp.register(hook, req.runtime));
8567
8571
  return req.id;
@@ -8584,7 +8588,8 @@ function facadeRegistry(send2, gone) {
8584
8588
  (request3, facade) => send2({ facadeOpen: { ...request3, registration: req.id }, port: facade }, [
8585
8589
  facade
8586
8590
  ]),
8587
- gone
8591
+ gone,
8592
+ l.ports
8588
8593
  );
8589
8594
  registered.set(req.id, l.facades.register(req.name, hook));
8590
8595
  return req.id;
@@ -9066,7 +9071,7 @@ function satisfies(version, range2) {
9066
9071
  }
9067
9072
 
9068
9073
  // src/version.ts
9069
- var KERNEL_VERSION = true ? "1.183.0" : "0.0.0-dev";
9074
+ var KERNEL_VERSION = true ? "1.184.0" : "0.0.0-dev";
9070
9075
  var OS_RELEASE = "6.0.0-slicc";
9071
9076
  function procVersion() {
9072
9077
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13121,12 +13126,12 @@ var ChildTable = class {
13121
13126
  async nextChange(candidates, flags2, interrupt) {
13122
13127
  let wake;
13123
13128
  const stateChange = new Promise((resolve2) => wake = resolve2);
13124
- const watching = flags2.untraced || flags2.continued;
13125
- if (watching && wake) this.stateChanged.push(wake);
13129
+ const watching2 = flags2.untraced || flags2.continued;
13130
+ if (watching2 && wake) this.stateChanged.push(wake);
13126
13131
  try {
13127
13132
  await Promise.race([
13128
13133
  ...candidates.map(([, child]) => child.exited),
13129
- ...watching ? [stateChange] : [],
13134
+ ...watching2 ? [stateChange] : [],
13130
13135
  interrupt
13131
13136
  ]);
13132
13137
  } finally {
@@ -15038,6 +15043,14 @@ function inheritedCwd(chdir, parent) {
15038
15043
  return chdir ? void 0 : parent;
15039
15044
  }
15040
15045
 
15046
+ // src/async/header-hook.ts
15047
+ var watchers = /* @__PURE__ */ new WeakMap();
15048
+ var watching = 0;
15049
+ function headerNotified(header4, index, bits2 = 0) {
15050
+ if (watching === 0) return;
15051
+ watchers.get(header4.buffer)?.(index, bits2);
15052
+ }
15053
+
15041
15054
  // src/fs/copy.ts
15042
15055
  async function present2(fs, path) {
15043
15056
  return fs.lstat(path).then(
@@ -17623,6 +17636,7 @@ function attachSyncSabResponder(port, sab, token, opts) {
17623
17636
  Atomics.store(header4, SAB_I_STATE, SAB_STATE_READY);
17624
17637
  Atomics.add(header4, SAB_I_PUB, 1);
17625
17638
  Atomics.notify(header4, SAB_I_PUB);
17639
+ headerNotified(header4, SAB_I_PUB);
17626
17640
  if (offset + chunk2 >= entry.payload.byteLength) drop(id2);
17627
17641
  else if (entry.timer) {
17628
17642
  clearTimeout(entry.timer);
@@ -29844,6 +29858,7 @@ var WasmProcess = class {
29844
29858
  case "fd-flush": {
29845
29859
  const file = this.fds.get(req.fd).file;
29846
29860
  if (file.flush) await file.flush();
29861
+ await this.options.durable?.();
29847
29862
  return { ok: true, kind: "void" };
29848
29863
  }
29849
29864
  }
@@ -29853,6 +29868,7 @@ var WasmProcess = class {
29853
29868
  const nodes = this.nodes;
29854
29869
  if (req.op === "fd-path-flush") {
29855
29870
  await nodes.flush(await nodes.targetKey(req.path).catch(() => req.path));
29871
+ if (req.durable) await this.options.durable?.();
29856
29872
  } else if (req.op === "fd-path-unlinking")
29857
29873
  await nodes.unlinking(await nodes.entryKey(req.path));
29858
29874
  else if (req.op === "fd-path-unlinked") nodes.unlinked(await nodes.entryKey(req.path));
@@ -30736,6 +30752,7 @@ var Dying = class {
30736
30752
  this.hard = setTimeout(finish, KILL_HARD_MS);
30737
30753
  this.arm();
30738
30754
  Atomics.store(header4, SAB_I_KILLED, code);
30755
+ headerNotified(header4, SAB_I_KILLED);
30739
30756
  process.die();
30740
30757
  }
30741
30758
  serve(req, work) {
@@ -30800,11 +30817,13 @@ function notifiers(header4) {
30800
30817
  onPending(sig) {
30801
30818
  Atomics.or(header4, SAB_I_SIGNALS, sigbit(sig));
30802
30819
  Atomics.notify(header4, SAB_I_SIGNALS);
30820
+ headerNotified(header4, SAB_I_SIGNALS, sigbit(sig));
30803
30821
  },
30804
30822
  onAsync() {
30805
30823
  for (const at of [header4, ...asyncFanout.get(header4) ?? []]) {
30806
30824
  Atomics.add(at, SAB_I_ASYNC, 1);
30807
30825
  Atomics.notify(at, SAB_I_ASYNC);
30826
+ headerNotified(at, SAB_I_ASYNC);
30808
30827
  }
30809
30828
  }
30810
30829
  };
@@ -30813,6 +30832,7 @@ function publishStops(process, header4) {
30813
30832
  process.onState((state) => {
30814
30833
  Atomics.store(header4, SAB_I_STOP, state === "stopped" ? 1 : 0);
30815
30834
  Atomics.notify(header4, SAB_I_STOP);
30835
+ headerNotified(header4, SAB_I_STOP);
30816
30836
  });
30817
30837
  }
30818
30838
  function transferOf(opts, lane) {
@@ -30936,6 +30956,7 @@ function processOptions(opts, header4, hooks, created4) {
30936
30956
  ...opts.dac ? { guard: { dac: opts.dac, fs: opts.fs, created: created4, ...linksOf(opts) } } : {},
30937
30957
  ...opts.identity ? { identity: opts.identity } : {},
30938
30958
  ...opts.onSyscall ? { onSyscall: opts.onSyscall } : {},
30959
+ ...opts.durable ? { durable: opts.durable } : {},
30939
30960
  ...opts.settling ? { settling: opts.settling } : {},
30940
30961
  ...heldHooks(opts),
30941
30962
  spawner: opts.spawner,
@@ -30964,7 +30985,10 @@ function processOptions(opts, header4, hooks, created4) {
30964
30985
  onReap: opts.onReap,
30965
30986
  resolver: opts.resolver,
30966
30987
  ...notifiers(header4),
30967
- onTimer: (which) => void Atomics.or(header4, SAB_I_TIMERS, 1 << which),
30988
+ onTimer: (which) => {
30989
+ Atomics.or(header4, SAB_I_TIMERS, 1 << which);
30990
+ headerNotified(header4, SAB_I_TIMERS, 1 << which);
30991
+ },
30968
30992
  hasPending: () => unblocked(header4) !== 0 || Atomics.load(header4, SAB_I_TIMERS) !== 0,
30969
30993
  raise: hooks.raise,
30970
30994
  threadKill: hooks.threadKill,
@@ -34065,12 +34089,12 @@ function grantConnect(hook, fetch2, liveness = {}) {
34065
34089
  return new HostfsClient(first, grant, fetch2);
34066
34090
  };
34067
34091
  }
34068
- async function openHostfs(spec, connect2, timing = {}) {
34092
+ async function openHostfs(spec, connect2, timing = {}, ports = messageChannel) {
34069
34093
  const readonly2 = spec.options?.ro !== void 0;
34070
- const { port1, port2 } = new MessageChannel();
34094
+ const { port1, port2 } = ports();
34071
34095
  const slot2 = mediumSlot(
34072
34096
  async (err) => unreachable(err),
34073
- () => watching.kick()
34097
+ () => watching2.kick()
34074
34098
  );
34075
34099
  const stop = new AbortController();
34076
34100
  let active;
@@ -34090,7 +34114,7 @@ async function openHostfs(spec, connect2, timing = {}) {
34090
34114
  ...readonly2 ? { readonly: true } : {}
34091
34115
  }
34092
34116
  );
34093
- const watching = keepWatching(
34117
+ const watching2 = keepWatching(
34094
34118
  {
34095
34119
  connect: () => connect2(spec.source, { readonly: readonly2 }),
34096
34120
  up(client) {
@@ -34107,7 +34131,7 @@ async function openHostfs(spec, connect2, timing = {}) {
34107
34131
  },
34108
34132
  stop.signal
34109
34133
  );
34110
- await watching.ready;
34134
+ await watching2.ready;
34111
34135
  return {
34112
34136
  port: port1,
34113
34137
  present: slot2.present,
@@ -34119,6 +34143,26 @@ async function openHostfs(spec, connect2, timing = {}) {
34119
34143
  };
34120
34144
  }
34121
34145
 
34146
+ // src/mount/in-process.ts
34147
+ var IN_PROCESS_DRIVER = /* @__PURE__ */ Symbol.for(
34148
+ "slicc-kernel.mount.in-process"
34149
+ );
34150
+ function openInProcess(spec, ports = messageChannel) {
34151
+ const driver = spec[IN_PROCESS_DRIVER];
34152
+ if (!driver) return void 0;
34153
+ const { port1, port2 } = ports();
34154
+ driver.served?.(
34155
+ serveFilesystem(port2, driver.handlers, driver.capabilities ?? {}, { owned: true })
34156
+ );
34157
+ return {
34158
+ port: port1,
34159
+ dispose: () => {
34160
+ port1.close();
34161
+ port2.close();
34162
+ }
34163
+ };
34164
+ }
34165
+
34122
34166
  // src/mount/media.ts
34123
34167
  var MEDIA_STORE = "handles";
34124
34168
  function memoryMedia() {
@@ -34578,13 +34622,29 @@ function foreignImports(bytes) {
34578
34622
  return {};
34579
34623
  }
34580
34624
  var LIBC_MARK = /^wasix-sysroot \d{4}\.\d+\.\d+-(\d+)/;
34581
- function libcVersion(module) {
34582
- for (const section of WebAssembly.Module.customSections(module, "slicc.libc")) {
34625
+ function libcOf(sections) {
34626
+ for (const section of sections) {
34583
34627
  const found = LIBC_MARK.exec(new TextDecoder().decode(section));
34584
34628
  if (found) return Number(found[1]);
34585
34629
  }
34586
34630
  return void 0;
34587
34631
  }
34632
+ function customSectionsOf(bytes, wanted) {
34633
+ const found = [];
34634
+ const r = new Reader(bytes);
34635
+ r.at = 8;
34636
+ while (r.at < bytes.length) {
34637
+ const id2 = r.byte();
34638
+ const size = r.u32();
34639
+ const end = r.at + size;
34640
+ if (id2 === 0 && r.name() === wanted) found.push(bytes.subarray(r.at, end));
34641
+ r.at = end;
34642
+ }
34643
+ return found;
34644
+ }
34645
+ function libcVersionOf(bytes) {
34646
+ return libcOf(customSectionsOf(bytes, "slicc.libc"));
34647
+ }
34588
34648
 
34589
34649
  // src/refused-command.ts
34590
34650
  var REFUSED_PATH = "/usr/lib/slicc/refused";
@@ -35015,8 +35075,8 @@ function cronPath(path) {
35015
35075
  );
35016
35076
  }
35017
35077
  var ETC_HOSTNAME_LIBC = 42;
35018
- function readsEtcHostname(program) {
35019
- return program.abi === "wasi" && (libcVersion(program.module) ?? 0) >= ETC_HOSTNAME_LIBC;
35078
+ function readsEtcHostname(program, libc) {
35079
+ return program.abi === "wasi" && (libc ?? 0) >= ETC_HOSTNAME_LIBC;
35020
35080
  }
35021
35081
  function setOrDrop(env, key, value2) {
35022
35082
  if (value2 === void 0) delete env[key];
@@ -35174,6 +35234,8 @@ function addTimes(into, pid, t) {
35174
35234
  into.set(pid, { utime: at.utime + t.utime, stime: at.stime + t.stime });
35175
35235
  }
35176
35236
  var Launcher = class {
35237
+ emscripten;
35238
+ admit;
35177
35239
  fs;
35178
35240
  processFs;
35179
35241
  noLinksFs;
@@ -35184,8 +35246,10 @@ var Launcher = class {
35184
35246
  unguardedRoot;
35185
35247
  writers;
35186
35248
  unlinkOwnerOption;
35249
+ durable;
35187
35250
  base;
35188
35251
  createWorker;
35252
+ compile;
35189
35253
  moduleUrl;
35190
35254
  moduleUrls = /* @__PURE__ */ new Map();
35191
35255
  urlsInUse = /* @__PURE__ */ new Map();
@@ -35200,6 +35264,7 @@ var Launcher = class {
35200
35264
  unwatchScopes = () => void 0;
35201
35265
  warned = /* @__PURE__ */ new Set();
35202
35266
  compiled = /* @__PURE__ */ new Map();
35267
+ libcs = /* @__PURE__ */ new WeakMap();
35203
35268
  texts = /* @__PURE__ */ new Map();
35204
35269
  revocations = 0;
35205
35270
  integrity;
@@ -35268,6 +35333,9 @@ var Launcher = class {
35268
35333
  onMountPending;
35269
35334
  removable = /* @__PURE__ */ new Map();
35270
35335
  hostfs;
35336
+ get ports() {
35337
+ return this.hostfs.ports ?? messageChannel;
35338
+ }
35271
35339
  fstabRetries;
35272
35340
  inserted = /* @__PURE__ */ new Map();
35273
35341
  openFiles = /* @__PURE__ */ new Set();
@@ -35351,8 +35419,8 @@ var Launcher = class {
35351
35419
  this.mounted = this.mounts.wrap(options.fs);
35352
35420
  this.base = this.rooted(this.mounted);
35353
35421
  this.createWorker = options.createWorker;
35354
- this.moduleUrl = options.moduleUrl;
35355
- this.createDriverWorker = options.createDriverWorker;
35422
+ ({ compile: this.compile, emscripten: this.emscripten, admit: this.admit } = options);
35423
+ ({ moduleUrl: this.moduleUrl, createDriverWorker: this.createDriverWorker } = options);
35356
35424
  this.media = options.media ?? memoryMedia();
35357
35425
  this.onMountPending = options.onMountPending;
35358
35426
  this.hostfs = options;
@@ -35425,7 +35493,7 @@ var Launcher = class {
35425
35493
  );
35426
35494
  this.fs = this.processChain(fs, this.nodes, this.unlinked);
35427
35495
  this.writerTags = writerTags(options.protect);
35428
- this.unlinkOwnerOption = options.unlinkOwner;
35496
+ ({ unlinkOwner: this.unlinkOwnerOption, durable: this.durable } = options);
35429
35497
  if (this.writerTags.size > 0 && options.fs.protect && !options.fs.unguarded) {
35430
35498
  throw new TypeError("protect.writers needs a root file system with an unguarded view");
35431
35499
  }
@@ -36211,9 +36279,12 @@ var Launcher = class {
36211
36279
  const bytes = sum === void 0 ? read : await this.pinnedBytes(pin, read);
36212
36280
  const memory = importedMemory(bytes);
36213
36281
  const foreign = foreignImports(bytes);
36214
- const compiled = await WebAssembly.compile(bytes);
36282
+ const libc = libcVersionOf(bytes);
36283
+ const named = customSectionsOf(bytes, "name").length > 0;
36284
+ const compiled = this.compile ? await this.compile(bytes, key) : await WebAssembly.compile(bytes);
36285
+ if (libc !== void 0) this.libcs.set(compiled, libc);
36215
36286
  return {
36216
- value: { module: compiled, ...memory ? { memory } : {}, foreign },
36287
+ value: { module: compiled, ...memory ? { memory } : {}, foreign, named },
36217
36288
  key: sum === void 0 ? readKey : key
36218
36289
  };
36219
36290
  });
@@ -36289,8 +36360,7 @@ var Launcher = class {
36289
36360
  if (this.urlsInUse.get(held.made.url) === held) this.urlsInUse.delete(held.made.url);
36290
36361
  held.made.revoke();
36291
36362
  }
36292
- async names(path, module) {
36293
- if (WebAssembly.Module.customSections(module, "name").length > 0) return void 0;
36363
+ async names(path) {
36294
36364
  const beside = `${path}.names`;
36295
36365
  if (await this.base.exists(beside)) return beside;
36296
36366
  const root = PACKAGE_ROOT.exec(path)?.[1];
@@ -36363,6 +36433,10 @@ var Launcher = class {
36363
36433
  const { url, source } = this.urlFor(await this.text(target.wasm, caller, asked));
36364
36434
  return { abi: "js", glue: "", url, path: target.wasm, ...source ? { source } : {} };
36365
36435
  }
36436
+ if (target.abi !== "wasi" && this.emscripten === "kernel") {
36437
+ const { module: module2 } = await this.module(target.wasm, caller, asked && modulePath(asked));
36438
+ return { abi: "emscripten", emscripten: "kernel", glue: "", module: module2, path: target.glue };
36439
+ }
36366
36440
  if (target.abi !== "wasi") {
36367
36441
  const [glue, { module: module2 }] = await Promise.all([
36368
36442
  this.text(target.glue, caller, asked),
@@ -36370,8 +36444,8 @@ var Launcher = class {
36370
36444
  ]);
36371
36445
  return { glue, module: module2, path: target.glue };
36372
36446
  }
36373
- const { module, memory, foreign } = await this.module(target.wasm, caller, asked);
36374
- const names2 = env.SLICC_WASM_BACKTRACE === "1" ? await this.names(target.wasm, module) : void 0;
36447
+ const { module, memory, foreign, named } = await this.module(target.wasm, caller, asked);
36448
+ const names2 = env.SLICC_WASM_BACKTRACE === "1" && !named ? await this.names(target.wasm) : void 0;
36375
36449
  const imports = target.imports ? await this.text(target.imports, caller) : void 0;
36376
36450
  return {
36377
36451
  abi: "wasi",
@@ -36406,7 +36480,7 @@ var Launcher = class {
36406
36480
  try {
36407
36481
  const cwdSlot = await this.cwds.hold(cwd, req.cwdFrom);
36408
36482
  const handle = await this.admitted(
36409
- program.abi !== "js",
36483
+ program,
36410
36484
  req.fds,
36411
36485
  (fds, quietOom) => this.start({
36412
36486
  ...req,
@@ -36421,7 +36495,8 @@ var Launcher = class {
36421
36495
  args,
36422
36496
  env,
36423
36497
  cwdSlot
36424
- })
36498
+ }),
36499
+ req.ppid
36425
36500
  ).finally(() => this.cwds.release(cwdSlot));
36426
36501
  void handle.exited.finally(done5);
36427
36502
  return handle;
@@ -36445,7 +36520,8 @@ var Launcher = class {
36445
36520
  };
36446
36521
  if (this.integrity) await this.checkedSources(planned, caller);
36447
36522
  const [program, exeId] = await this.loaded(planned.target, env, caller);
36448
- if (readsEtcHostname(program)) setOrDrop(env, "HOSTNAME", own);
36523
+ const libc = program.abi === "js" ? void 0 : this.libcs.get(program.module);
36524
+ if (readsEtcHostname(program, libc)) setOrDrop(env, "HOSTNAME", own);
36449
36525
  return { planned, env, program, exeId };
36450
36526
  }
36451
36527
  packageRootIs(path) {
@@ -36542,12 +36618,25 @@ var Launcher = class {
36542
36618
  if (req.command !== void 0) this.programs.set(pid, req.command);
36543
36619
  this.cwdPaths.set(pid, req.cwd);
36544
36620
  }
36545
- async admitted(wasm, fds, start2) {
36621
+ async reserved(program, fds, ppid) {
36622
+ if (!this.admit) return () => {
36623
+ };
36624
+ try {
36625
+ return await this.admit(program, ppid === void 0 ? {} : { ppid });
36626
+ } catch (err) {
36627
+ this.memories.ended();
36628
+ await fds.closeAll();
36629
+ throw err;
36630
+ }
36631
+ }
36632
+ async admitted(program, fds, start2, ppid) {
36633
+ const wasm = program.abi !== "js";
36546
36634
  for (; ; ) {
36547
36635
  await this.memories.admit().catch(async (err) => {
36548
36636
  await fds.closeAll();
36549
36637
  throw err;
36550
36638
  });
36639
+ const release = await this.reserved(program, fds, ppid);
36551
36640
  const counted2 = (handle2) => {
36552
36641
  void handle2.exited.finally(() => this.memories.ended());
36553
36642
  void Promise.resolve(handle2.ready).then(() => this.memories.started());
@@ -36559,6 +36648,8 @@ var Launcher = class {
36559
36648
  } catch (err) {
36560
36649
  this.memories.ended();
36561
36650
  throw err;
36651
+ } finally {
36652
+ release();
36562
36653
  }
36563
36654
  }
36564
36655
  const forked = fds.fork();
@@ -36566,7 +36657,7 @@ var Launcher = class {
36566
36657
  this.memories.ended();
36567
36658
  await forked.closeAll();
36568
36659
  throw err;
36569
- });
36660
+ }).finally(release);
36570
36661
  const fit = await (handle.ready ?? true);
36571
36662
  if (fit) {
36572
36663
  this.traceAdmitted(handle.pid, true);
@@ -36609,6 +36700,7 @@ var Launcher = class {
36609
36700
  this.settling.syscall(pid, call.op);
36610
36701
  },
36611
36702
  settling: () => this.settling.isSettling(pid),
36703
+ durable: this.durable,
36612
36704
  ...req.ignored ? { ignored: req.ignored } : {},
36613
36705
  ...anyBlocked(req.blocked) ? { blocked: req.blocked } : {},
36614
36706
  ...req.umask !== void 0 ? { umask: req.umask } : {},
@@ -37169,7 +37261,7 @@ var Launcher = class {
37169
37261
  tagBase: this.tagBases.get(ppid),
37170
37262
  links: this.links.get(ppid)
37171
37263
  });
37172
- return childHandle(await this.admitted(parent.program.abi !== "js", given, fresh4));
37264
+ return childHandle(await this.admitted(parent.program, given, fresh4, ppid));
37173
37265
  };
37174
37266
  }
37175
37267
  keySignal(tty, fallback, sig, send2) {
@@ -37299,6 +37391,8 @@ var Launcher = class {
37299
37391
  return targets.length > 0;
37300
37392
  }
37301
37393
  async driver(type, spec) {
37394
+ const inProcess = openInProcess(spec, this.ports);
37395
+ if (inProcess) return inProcess;
37302
37396
  if (type === "fsa") return this.fsaDriver(spec);
37303
37397
  if (type === "hostfs") {
37304
37398
  const { hostfs, hostfsFetch, hostfsTiming } = this.hostfs;
@@ -37307,11 +37401,12 @@ var Launcher = class {
37307
37401
  return openHostfs(
37308
37402
  spec,
37309
37403
  grantConnect(hostfs, hostfsFetch ?? ((url, init) => fetch(url, init)), hostfsTiming),
37310
- hostfsTiming
37404
+ hostfsTiming,
37405
+ this.ports
37311
37406
  );
37312
37407
  }
37313
37408
  if (type === "tmpfs") {
37314
- const { port1, port2 } = new MessageChannel();
37409
+ const { port1, port2 } = this.ports();
37315
37410
  serveFilesystem(
37316
37411
  port2,
37317
37412
  tmpfs(),
@@ -37372,7 +37467,7 @@ var Launcher = class {
37372
37467
  async fsaDriver(spec) {
37373
37468
  const { target, source } = spec;
37374
37469
  const ask = (handle) => this.onMountPending?.({ target, source, ...handle ? { handle } : {} });
37375
- const { port1, port2 } = new MessageChannel();
37470
+ const { port1, port2 } = this.ports();
37376
37471
  const medium = removableMedium((handle) => {
37377
37472
  served2.invalidate(true);
37378
37473
  ask(handle);