@ai-ecoverse/slicc-kernel 1.191.4 → 1.192.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.
@@ -278,7 +278,7 @@ var KernelSide = class {
278
278
  const {
279
279
  sab: _sab,
280
280
  changes: _changes,
281
- held,
281
+ held: held2,
282
282
  program,
283
283
  signals: _signals,
284
284
  thread,
@@ -287,17 +287,17 @@ var KernelSide = class {
287
287
  const { memory: _memory, ids: _ids, modules: _modules, blocked: blocked2, tid, arg } = thread;
288
288
  return {
289
289
  ...rest2,
290
- ...this.shared(program, held, image),
290
+ ...this.shared(program, held2, image),
291
291
  thread: { tid, arg, ...blocked2 ? { blocked: blocked2 } : {} }
292
292
  };
293
293
  }
294
- shared(program, held, image) {
294
+ shared(program, held2, image) {
295
295
  const { module: _module, ...shown2 } = program;
296
296
  const changes = initial(this.changes);
297
297
  const cwds = initial(this.cwds);
298
298
  return {
299
299
  program: { ...shown2, image },
300
- ...held ? { held: { slot: held.slot, seen: held.seen, dead: held.dead } } : {},
300
+ ...held2 ? { held: { slot: held2.slot, seen: held2.seen, dead: held2.dead } } : {},
301
301
  ...Number.isFinite(this.max) ? { maxMessageBytes: this.max } : {},
302
302
  mirror: {
303
303
  seq: 0,
@@ -312,7 +312,7 @@ var KernelSide = class {
312
312
  };
313
313
  }
314
314
  wire(init, image) {
315
- const { sab: _sab, changes: _changes, held, program, fork, ...rest2 } = init;
315
+ const { sab: _sab, changes: _changes, held: held2, program, fork, ...rest2 } = init;
316
316
  const memory = fork?.memory;
317
317
  let forkWire;
318
318
  if (fork && memory && memory.byteLength > this.max) {
@@ -320,7 +320,7 @@ var KernelSide = class {
320
320
  } else if (fork) forkWire = fork;
321
321
  return {
322
322
  ...rest2,
323
- ...this.shared(program, held, image),
323
+ ...this.shared(program, held2, image),
324
324
  ...forkWire ? { fork: forkWire } : {}
325
325
  };
326
326
  }
@@ -750,6 +750,7 @@ var LocalPort = class extends EventTarget {
750
750
  peer;
751
751
  started = false;
752
752
  closed = false;
753
+ ending = false;
753
754
  inbox = [];
754
755
  flushing = false;
755
756
  handler = null;
@@ -790,8 +791,15 @@ var LocalPort = class extends EventTarget {
790
791
  while (this.inbox.length > 0 && !this.closed) {
791
792
  this.dispatchEvent(new MessageEvent("message", { data: this.inbox.shift() }));
792
793
  }
794
+ if (this.ending) this.close();
793
795
  });
794
796
  }
797
+ peerClosed() {
798
+ this.peer = void 0;
799
+ this.ending = true;
800
+ if (this.inbox.length === 0) this.close();
801
+ else this.schedule();
802
+ }
795
803
  close() {
796
804
  if (this.closed) return;
797
805
  this.closed = true;
@@ -799,7 +807,7 @@ var LocalPort = class extends EventTarget {
799
807
  const peer = this.peer;
800
808
  this.peer = void 0;
801
809
  queueMicrotask(() => this.dispatchEvent(new Event("close")));
802
- peer?.close();
810
+ peer?.peerClosed();
803
811
  }
804
812
  };
805
813
  var localPorts = () => {
@@ -810,6 +818,56 @@ var localPorts = () => {
810
818
  return { port1, port2 };
811
819
  };
812
820
 
821
+ // src/cdp/held.ts
822
+ function heldConnection(send3, close) {
823
+ const queued = [];
824
+ let ended;
825
+ let onmessage = null;
826
+ let onclose = null;
827
+ let draining = false;
828
+ const drain2 = () => {
829
+ if (draining) return;
830
+ draining = true;
831
+ queueMicrotask(() => {
832
+ draining = false;
833
+ while (onmessage && queued.length > 0) onmessage(queued.shift());
834
+ if (!onclose || !ended) return;
835
+ const { reason } = ended;
836
+ ended = void 0;
837
+ onclose(reason);
838
+ });
839
+ };
840
+ const conn = {
841
+ send: send3,
842
+ close,
843
+ get onmessage() {
844
+ return onmessage;
845
+ },
846
+ set onmessage(next3) {
847
+ onmessage = next3;
848
+ if (next3) drain2();
849
+ },
850
+ get onclose() {
851
+ return onclose;
852
+ },
853
+ set onclose(next3) {
854
+ onclose = next3;
855
+ if (next3) drain2();
856
+ }
857
+ };
858
+ return {
859
+ conn,
860
+ message(message3) {
861
+ if (onmessage && queued.length === 0) onmessage(message3);
862
+ else queued.push(message3);
863
+ },
864
+ end(reason) {
865
+ ended = { reason };
866
+ drain2();
867
+ }
868
+ };
869
+ }
870
+
813
871
  // src/cdp/port.ts
814
872
  function serveCdpPort(port, hook, request, onDone) {
815
873
  let conn;
@@ -836,11 +894,11 @@ function serveCdpPort(port, hook, request, onDone) {
836
894
  (opened2) => {
837
895
  conn = opened2;
838
896
  if (done4) return opened2.close();
897
+ port.postMessage({ open: true });
839
898
  opened2.onmessage = (m) => {
840
899
  if (!done4) port.postMessage({ m });
841
900
  };
842
901
  opened2.onclose = (reason) => finish(reason ?? null);
843
- port.postMessage({ open: true });
844
902
  },
845
903
  (e) => {
846
904
  if (done4) return;
@@ -858,22 +916,20 @@ function portCdpHook(ask, gone, ports = messageChannel) {
858
916
  return (request) => new Promise((resolve2, reject) => {
859
917
  const { port1, port2 } = ports();
860
918
  let closed = false;
861
- const conn = {
862
- send: (m) => {
919
+ const held2 = heldConnection(
920
+ (m) => {
863
921
  if (!closed) port1.postMessage({ m });
864
922
  },
865
- onmessage: null,
866
- onclose: null,
867
- close: () => {
923
+ () => {
868
924
  if (closed) return;
869
925
  closed = true;
870
926
  port1.postMessage({ close: true });
871
927
  port1.close();
872
928
  }
873
- };
929
+ );
874
930
  port1.addEventListener("message", ({ data }) => {
875
- if ("m" in data) conn.onmessage?.(data.m);
876
- else if ("open" in data) resolve2(conn);
931
+ if ("m" in data) held2.message(data.m);
932
+ else if ("open" in data) resolve2(held2.conn);
877
933
  else if ("error" in data) {
878
934
  closed = true;
879
935
  port1.close();
@@ -881,17 +937,20 @@ function portCdpHook(ask, gone, ports = messageChannel) {
881
937
  } else if (!closed) {
882
938
  closed = true;
883
939
  port1.close();
884
- conn.onclose?.(data.close ?? void 0);
940
+ reject(new Error(data.close ?? "the CDP host closed"));
941
+ held2.end(data.close ?? void 0);
885
942
  }
886
943
  });
887
- port1.start();
888
- void gone?.then(() => {
944
+ const lost = (reason) => {
889
945
  if (closed) return;
890
946
  closed = true;
891
947
  port1.close();
892
- reject(new Error("the CDP host is gone"));
893
- conn.onclose?.("the CDP host is gone");
894
- });
948
+ reject(new Error(reason));
949
+ held2.end(reason);
950
+ };
951
+ port1.addEventListener("close", () => lost("the CDP host closed its port"));
952
+ port1.start();
953
+ void gone?.then(() => lost("the CDP host is gone"));
895
954
  ask(request, port2);
896
955
  });
897
956
  }
@@ -4637,7 +4696,7 @@ var CdpHosts = class {
4637
4696
  if (!entry) throw new HttpError(503, NO_CDP_HOST);
4638
4697
  let conn;
4639
4698
  try {
4640
- conn = await entry.hook(hookRequest(request));
4699
+ conn = held(await entry.hook(hookRequest(request)));
4641
4700
  } catch (e) {
4642
4701
  throw new HttpError(502, `CDP host: ${e instanceof Error ? e.message : String(e)}`);
4643
4702
  }
@@ -4657,6 +4716,15 @@ var CdpHosts = class {
4657
4716
  for (const entry of [this.embedder, ...this.clients]) if (entry) closeAll(entry);
4658
4717
  }
4659
4718
  };
4719
+ function held(host) {
4720
+ const { conn, message: message3, end } = heldConnection(
4721
+ (m) => host.send(m),
4722
+ () => host.close()
4723
+ );
4724
+ host.onmessage = message3;
4725
+ host.onclose = end;
4726
+ return conn;
4727
+ }
4660
4728
  function hookRequest({ runtime, stamp }) {
4661
4729
  return {
4662
4730
  ...runtime ? { runtime } : {},
@@ -4821,7 +4889,7 @@ function satisfies(version, range2) {
4821
4889
  }
4822
4890
 
4823
4891
  // src/version.ts
4824
- var KERNEL_VERSION = true ? "1.191.4" : "0.0.0-dev";
4892
+ var KERNEL_VERSION = true ? "1.192.0" : "0.0.0-dev";
4825
4893
  var OS_RELEASE = "6.0.0-slicc";
4826
4894
  function procVersion() {
4827
4895
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -6164,15 +6232,15 @@ var UnlinkedKeeper = class {
6164
6232
  pinned2.commit();
6165
6233
  }
6166
6234
  heldWithin(target) {
6167
- const held = /* @__PURE__ */ new Map();
6235
+ const held2 = /* @__PURE__ */ new Map();
6168
6236
  for (const holder of this.holders) {
6169
6237
  if (holder.owns(target)) continue;
6170
6238
  for (const path of holder.held()) {
6171
6239
  if (!within2(path, target) || holder.isKept(path)) continue;
6172
- held.set(path, [...held.get(path) ?? [], holder]);
6240
+ held2.set(path, [...held2.get(path) ?? [], holder]);
6173
6241
  }
6174
6242
  }
6175
- return held;
6243
+ return held2;
6176
6244
  }
6177
6245
  async pin(target, gated = () => void 0, sealed = () => void 0) {
6178
6246
  const paths = [];
@@ -6195,18 +6263,18 @@ var UnlinkedKeeper = class {
6195
6263
  };
6196
6264
  await take();
6197
6265
  gated();
6198
- const held = /* @__PURE__ */ new Map();
6266
+ const held2 = /* @__PURE__ */ new Map();
6199
6267
  const hidden = /* @__PURE__ */ new Map();
6200
6268
  const moved3 = [];
6201
6269
  try {
6202
6270
  for (; ; ) {
6203
6271
  await take();
6204
6272
  const now = this.heldWithin(target);
6205
- const next3 = paths.filter((path) => now.has(path) && !held.has(path));
6273
+ const next3 = paths.filter((path) => now.has(path) && !held2.has(path));
6206
6274
  if (next3.length === 0) break;
6207
6275
  for (const path of next3) {
6208
6276
  const holders2 = now.get(path);
6209
- held.set(path, holders2);
6277
+ held2.set(path, holders2);
6210
6278
  for (const holder of holders2) moved3.push(holder.moving?.(path) ?? (() => void 0));
6211
6279
  const at = await this.keepAside(path);
6212
6280
  if (at === void 0) continue;
@@ -6230,7 +6298,7 @@ var UnlinkedKeeper = class {
6230
6298
  };
6231
6299
  const files = /* @__PURE__ */ new Map();
6232
6300
  for (const [path, at] of hidden) {
6233
- const holders2 = held.get(path);
6301
+ const holders2 = held2.get(path);
6234
6302
  const file = this.keptFile(at, { refs: holders2.length + 1 });
6235
6303
  files.set(path, file);
6236
6304
  for (const holder of holders2) holder.keep(path, file);
@@ -6244,7 +6312,7 @@ var UnlinkedKeeper = class {
6244
6312
  },
6245
6313
  rollback: async () => {
6246
6314
  for (const [path, file] of files) {
6247
- for (const holder of held.get(path)) holder.unkeep(path, file);
6315
+ for (const holder of held2.get(path)) holder.unkeep(path, file);
6248
6316
  await this.serial(async () => {
6249
6317
  await Promise.allSettled([this.fs.rename(file.hidden, path)]);
6250
6318
  this.unlinkedName(file.hidden);
@@ -6277,10 +6345,10 @@ var UnlinkedKeeper = class {
6277
6345
  const none = { whole: false, undoing: (op) => op() };
6278
6346
  const peers = this.peers;
6279
6347
  if (!peers?.shared() || this.rootOf(target) !== "/") return none;
6280
- const held = peers.heldWithin(target).filter((holder) => holder.instance !== void 0);
6281
- if (held.length === 0 || !await valid3()) return none;
6348
+ const held2 = peers.heldWithin(target).filter((holder) => holder.instance !== void 0);
6349
+ if (held2.length === 0 || !await valid3()) return none;
6282
6350
  const tabs = /* @__PURE__ */ new Map();
6283
- for (const holder of held) tabs.set(holder.tab, [...tabs.get(holder.tab) ?? [], holder]);
6351
+ for (const holder of held2) tabs.set(holder.tab, [...tabs.get(holder.tab) ?? [], holder]);
6284
6352
  const asked = [...tabs].map(([tab, holders2]) => {
6285
6353
  const paths = holders2.map((holder) => holder.path);
6286
6354
  return { tab, holders: holders2, paths };
@@ -6517,7 +6585,7 @@ var UnlinkedKeeper = class {
6517
6585
  const dir = dirOf(root);
6518
6586
  const names2 = await this.fs.readdir(dir).catch(() => void 0);
6519
6587
  if (!names2) return;
6520
- const held = query && new Set(((await query()).held ?? []).map((lock) => lock.name));
6588
+ const held2 = query && new Set(((await query()).held ?? []).map((lock) => lock.name));
6521
6589
  for (const name2 of names2) {
6522
6590
  const id2 = name2.slice(0, name2.lastIndexOf("."));
6523
6591
  const at = id2.indexOf("~");
@@ -6530,7 +6598,7 @@ var UnlinkedKeeper = class {
6530
6598
  );
6531
6599
  continue;
6532
6600
  }
6533
- const dead = id2 !== this.instance && (at < 0 ? held !== void 0 && !held.has(lockName(id2)) : owner?.alive(id2.slice(0, at)) === false);
6601
+ const dead = id2 !== this.instance && (at < 0 ? held2 !== void 0 && !held2.has(lockName(id2)) : owner?.alive(id2.slice(0, at)) === false);
6534
6602
  if (dead) await this.fs.rm(`${dir}/${name2}`, { recursive: true }).catch(() => void 0);
6535
6603
  }
6536
6604
  await this.tidy(dir);
@@ -8648,11 +8716,11 @@ var ProtectedFs = class {
8648
8716
  async exclusive(path, run2, follow2) {
8649
8717
  return fs.exclusive(
8650
8718
  path,
8651
- (held) => run2({
8652
- ...held,
8719
+ (held2) => run2({
8720
+ ...held2,
8653
8721
  writeFile: async (...args) => {
8654
8722
  await check(args[0], true);
8655
- return held.writeFile(...args);
8723
+ return held2.writeFile(...args);
8656
8724
  }
8657
8725
  }),
8658
8726
  follow2
@@ -9166,11 +9234,11 @@ var TextBusy = class {
9166
9234
  return exclusive.call(
9167
9235
  fs,
9168
9236
  path,
9169
- (held) => run2({
9170
- ...held,
9237
+ (held2) => run2({
9238
+ ...held2,
9171
9239
  writeFile: async (at, content, owner) => {
9172
9240
  await check(at);
9173
- return held.writeFile(at, content, owner);
9241
+ return held2.writeFile(at, content, owner);
9174
9242
  }
9175
9243
  }),
9176
9244
  follow2
@@ -10214,9 +10282,9 @@ var EmbedderChannel = class {
10214
10282
  }
10215
10283
  set caller(caller) {
10216
10284
  this.current = caller;
10217
- const held = this.held;
10285
+ const held2 = this.held;
10218
10286
  this.held = [];
10219
- for (const line of held) this.tell(line);
10287
+ for (const line of held2) this.tell(line);
10220
10288
  }
10221
10289
  tell(line) {
10222
10290
  if (!this.current.progress(line) && this.held.length < HELD_MAX) this.held.push(line);
@@ -11705,27 +11773,27 @@ var CwdTable = class {
11705
11773
  return slot2;
11706
11774
  }
11707
11775
  share(slot2) {
11708
- const held = slot2 === void 0 ? void 0 : this.held.get(slot2);
11709
- if (!held) return UNTRACKED;
11710
- held.refs++;
11776
+ const held2 = slot2 === void 0 ? void 0 : this.held.get(slot2);
11777
+ if (!held2) return UNTRACKED;
11778
+ held2.refs++;
11711
11779
  return slot2;
11712
11780
  }
11713
11781
  release(slot2) {
11714
- const held = slot2 === void 0 ? void 0 : this.held.get(slot2);
11715
- if (!held || --held.refs > 0) return;
11782
+ const held2 = slot2 === void 0 ? void 0 : this.held.get(slot2);
11783
+ if (!held2 || --held2.refs > 0) return;
11716
11784
  this.held.delete(slot2);
11717
11785
  Atomics.add(this.view, slot2, 1);
11718
11786
  this.free.push(slot2);
11719
11787
  }
11720
11788
  stateOf(slot2) {
11721
- const held = this.held.get(slot2);
11722
- return { seen: held?.verified ?? Atomics.load(this.view, slot2), dead: held?.dead === true };
11789
+ const held2 = this.held.get(slot2);
11790
+ return { seen: held2?.verified ?? Atomics.load(this.view, slot2), dead: held2?.dead === true };
11723
11791
  }
11724
11792
  touched(paths, trees = []) {
11725
11793
  if (this.held.size === 0) return;
11726
- for (const [slot2, held] of this.held) {
11727
- if (held.dead) continue;
11728
- if (paths.some((p) => under4(held.path, p)) || trees.some((t) => under4(held.path, t))) {
11794
+ for (const [slot2, held2] of this.held) {
11795
+ if (held2.dead) continue;
11796
+ if (paths.some((p) => under4(held2.path, p)) || trees.some((t) => under4(held2.path, t))) {
11729
11797
  Atomics.add(this.view, slot2, 1);
11730
11798
  }
11731
11799
  }
@@ -11733,14 +11801,14 @@ var CwdTable = class {
11733
11801
  async check(slot2) {
11734
11802
  this.checks++;
11735
11803
  const gen = Atomics.load(this.view, slot2);
11736
- const held = this.held.get(slot2);
11737
- if (!held) return { gen, alive: true };
11738
- if (!held.dead) {
11739
- const ino = await this.inodeOf(held.path).catch(() => null);
11740
- held.dead = ino === null || held.ino !== void 0 && ino !== held.ino;
11741
- held.verified = gen;
11804
+ const held2 = this.held.get(slot2);
11805
+ if (!held2) return { gen, alive: true };
11806
+ if (!held2.dead) {
11807
+ const ino = await this.inodeOf(held2.path).catch(() => null);
11808
+ held2.dead = ino === null || held2.ino !== void 0 && ino !== held2.ino;
11809
+ held2.verified = gen;
11742
11810
  }
11743
- return { gen, alive: !held.dead };
11811
+ return { gen, alive: !held2.dead };
11744
11812
  }
11745
11813
  };
11746
11814
  function heldInit(o) {
@@ -12006,8 +12074,8 @@ var HeldSet = class extends Set {
12006
12074
  return removed;
12007
12075
  }
12008
12076
  };
12009
- function heldUnder(held, target) {
12010
- for (const paths of held) for (const path of paths.keys()) if (within6(path, target)) return true;
12077
+ function heldUnder(held2, target) {
12078
+ for (const paths of held2) for (const path of paths.keys()) if (within6(path, target)) return true;
12011
12079
  return false;
12012
12080
  }
12013
12081
  var HeldPaths = class extends Map {
@@ -13552,8 +13620,8 @@ function nothing() {
13552
13620
  return false;
13553
13621
  }
13554
13622
  function heldPaths(arg) {
13555
- const held = JSON.parse(arg ?? "[]");
13556
- return Array.isArray(held) ? held.filter((path) => typeof path === "string") : [];
13623
+ const held2 = JSON.parse(arg ?? "[]");
13624
+ return Array.isArray(held2) ? held2.filter((path) => typeof path === "string") : [];
13557
13625
  }
13558
13626
  async function usageAt(entry, path) {
13559
13627
  if (!entry.statfs) return void 0;
@@ -14116,11 +14184,11 @@ async function dispatchSyncFs(req) {
14116
14184
  return devsOf(entry, req, await dispatchOne(entry, req));
14117
14185
  const { fs, cwd } = entry;
14118
14186
  const path = fs.resolvePath(cwd, req.path);
14119
- const identified = async (held) => {
14120
- const own = held ? { ...entry, fs: { ...fs, writeFile: held.writeFile } } : entry;
14187
+ const identified = async (held2) => {
14188
+ const own = held2 ? { ...entry, fs: { ...fs, writeFile: held2.writeFile } } : entry;
14121
14189
  const result = await dispatchOne(own, req);
14122
14190
  if (!result.ok) return result;
14123
- if (held && !held.direct) return json2(null);
14191
+ if (held2 && !held2.direct) return json2(null);
14124
14192
  const look = req.op === "lchown" ? fs.lstat : fs.stat;
14125
14193
  const st = await look.call(fs, path).catch(() => void 0);
14126
14194
  return json2(st ? statJson(st) : null);
@@ -14267,8 +14335,8 @@ async function dispatchPath(entry, req) {
14267
14335
  if (device) return { ok: false, errno: device, message: `${path}: a device entry stays` };
14268
14336
  const made2 = await newDevName(entry, path, req);
14269
14337
  if (made2) return made2;
14270
- const held = await byHandle(entry, path, req);
14271
- if (held) return held;
14338
+ const held2 = await byHandle(entry, path, req);
14339
+ if (held2) return held2;
14272
14340
  if (req.op === "access") return await accessOp(entry, path, req);
14273
14341
  if (req.op === "hold") return await holdOp(entry, path, req);
14274
14342
  const resolved2 = await guardAndResolve(entry, path, req);
@@ -20055,10 +20123,10 @@ async function recordLock2(req, ctx) {
20055
20123
  const range2 = lockRange(req.start, req.len);
20056
20124
  const key = await fileKey(target, req.kind, req.op === "lk-set" && req.fd !== void 0);
20057
20125
  if (req.op === "lk-get") {
20058
- const held = await locks.holder(key, owner, { key, kind: req.kind, ...range2 });
20059
- if (!held) return json3(null);
20060
- const len = held.end === Number.POSITIVE_INFINITY ? 0 : held.end - held.start;
20061
- return json3({ kind: held.kind, pid: held.owner, start: held.start, len });
20126
+ const held2 = await locks.holder(key, owner, { key, kind: req.kind, ...range2 });
20127
+ if (!held2) return json3(null);
20128
+ const len = held2.end === Number.POSITIVE_INFINITY ? 0 : held2.end - held2.start;
20129
+ return json3({ kind: held2.kind, pid: held2.owner, start: held2.start, len });
20062
20130
  }
20063
20131
  const granted2 = req.kind !== "unlock";
20064
20132
  const shared2 = locks.shared?.() === true;
@@ -24396,8 +24464,8 @@ var TlsContext = class {
24396
24464
  var TLS_CONTEXTS_MAX = 64;
24397
24465
  async function contextSecure(proc, cert) {
24398
24466
  if (!cert) throw new KernelError("EINVAL", "ERR_INVALID_ARG_VALUE: a context needs cert and key");
24399
- const held = proc.fds.numbers().filter((fd) => proc.fds.get(fd).file instanceof TlsContext);
24400
- if (held.length >= TLS_CONTEXTS_MAX) {
24467
+ const held2 = proc.fds.numbers().filter((fd) => proc.fds.get(fd).file instanceof TlsContext);
24468
+ if (held2.length >= TLS_CONTEXTS_MAX) {
24401
24469
  wipe(certBytes(cert));
24402
24470
  throw new KernelError("EMFILE", `at most ${TLS_CONTEXTS_MAX} tls contexts per process`);
24403
24471
  }
@@ -24416,14 +24484,14 @@ function contextAt(fds, fd) {
24416
24484
  const open = fds.get(fd);
24417
24485
  const file = open.file;
24418
24486
  if (!(file instanceof TlsContext)) throw new KernelError("EBADF", "not a tls context");
24419
- const held = open.retain();
24487
+ const held2 = open.retain();
24420
24488
  let released2 = false;
24421
24489
  return {
24422
24490
  leaf: file.leaf,
24423
24491
  done: () => {
24424
24492
  if (released2) return;
24425
24493
  released2 = true;
24426
- void held.release();
24494
+ void held2.release();
24427
24495
  }
24428
24496
  };
24429
24497
  }
@@ -25661,8 +25729,8 @@ var VfsNodes = class {
25661
25729
  createExclusive(path, owner) {
25662
25730
  return this.onEntry(path, async () => {
25663
25731
  const node = this.byPath.get(path);
25664
- const held = node ? await node.serial(async () => node.holds()) : false;
25665
- if (held) throw fsError("EEXIST", path);
25732
+ const held2 = node ? await node.serial(async () => node.holds()) : false;
25733
+ if (held2) throw fsError("EEXIST", path);
25666
25734
  const exclusive = this.fs.createExclusive;
25667
25735
  if (exclusive) return exclusive.call(this.fs, path, owner);
25668
25736
  if (await present3(this.fs, path)) throw fsError("EEXIST", path);
@@ -25894,8 +25962,8 @@ var VfsNodes = class {
25894
25962
  for (const [p, node] of this.byPath) if (within8(p, path)) await node.serial(() => node.flush());
25895
25963
  }
25896
25964
  async unlinking(path) {
25897
- for (const [held, node] of [...this.byPath]) {
25898
- if (!within8(held, path)) continue;
25965
+ for (const [held2, node] of [...this.byPath]) {
25966
+ if (!within8(held2, path)) continue;
25899
25967
  await node.serial(async () => {
25900
25968
  await Promise.all([this.keepsOnDisk || node.keep(), node.limit()]);
25901
25969
  });
@@ -25909,9 +25977,9 @@ var VfsNodes = class {
25909
25977
  }
25910
25978
  }
25911
25979
  unlinked(path) {
25912
- for (const [held, node] of [...this.byPath]) {
25913
- if (!within8(held, path) || this.byPath.get(held) !== node) continue;
25914
- if (!this.dropName(held, node)) this.orphan(node);
25980
+ for (const [held2, node] of [...this.byPath]) {
25981
+ if (!within8(held2, path) || this.byPath.get(held2) !== node) continue;
25982
+ if (!this.dropName(held2, node)) this.orphan(node);
25915
25983
  }
25916
25984
  }
25917
25985
  renamed(from, to) {
@@ -25977,8 +26045,8 @@ async function aliasOf(fs, nodes, at) {
25977
26045
  return nodes.holdingId(`${st.dev ?? 0}:${st.ino}`);
25978
26046
  }
25979
26047
  async function heldAt(fs, nodes, at) {
25980
- const held = nodes.holding(at);
25981
- if (held || !nodes.holdsAny() || nodes.plainAt(at)) return held;
26048
+ const held2 = nodes.holding(at);
26049
+ if (held2 || !nodes.holdsAny() || nodes.plainAt(at)) return held2;
25982
26050
  const shape = nodes.shape;
25983
26051
  const found = await aliasOf(fs, nodes, at);
25984
26052
  if (!found) nodes.notePlain(at, shape);
@@ -25988,21 +26056,21 @@ function heldIo(fs, nodes, changed) {
25988
26056
  const ranged2 = rangedOps(fs);
25989
26057
  const node = (path) => heldAt(fs, nodes, fs.resolvePath("/", path));
25990
26058
  const write = async (path, op, fallback) => {
25991
- const held = await node(path);
25992
- if (!held) return fallback();
25993
- const out = await held.byName(async () => {
25994
- const done4 = await op(held);
25995
- await held.flush();
26059
+ const held2 = await node(path);
26060
+ if (!held2) return fallback();
26061
+ const out = await held2.byName(async () => {
26062
+ const done4 = await op(held2);
26063
+ await held2.flush();
25996
26064
  return done4;
25997
26065
  });
25998
26066
  changed(fs.resolvePath("/", path));
25999
- if (held.path !== fs.resolvePath("/", path)) changed(held.path);
26067
+ if (held2.path !== fs.resolvePath("/", path)) changed(held2.path);
26000
26068
  return out;
26001
26069
  };
26002
26070
  return {
26003
26071
  append: (path, bytes) => write(
26004
26072
  path,
26005
- (held) => held.append(bytes),
26073
+ (held2) => held2.append(bytes),
26006
26074
  async () => {
26007
26075
  const end = await fs.append?.(path, bytes, { alone: true }).catch((err) => {
26008
26076
  if (!positional(err)) throw err;
@@ -26022,32 +26090,32 @@ function heldIo(fs, nodes, changed) {
26022
26090
  ),
26023
26091
  async stat(path) {
26024
26092
  const st = await fs.stat(path);
26025
- const held = st.isFile ? await node(path) : void 0;
26026
- return held ? { ...st, size: await held.byName(() => held.size()) } : st;
26093
+ const held2 = st.isFile ? await node(path) : void 0;
26094
+ return held2 ? { ...st, size: await held2.byName(() => held2.size()) } : st;
26027
26095
  },
26028
26096
  async lstat(path) {
26029
26097
  const st = await fs.lstat(path);
26030
- const held = st.isFile && !st.isSymbolicLink ? await node(path) : void 0;
26031
- return held ? { ...st, size: await held.byName(() => held.size()) } : st;
26098
+ const held2 = st.isFile && !st.isSymbolicLink ? await node(path) : void 0;
26099
+ return held2 ? { ...st, size: await held2.byName(() => held2.size()) } : st;
26032
26100
  },
26033
26101
  async readFileBuffer(path) {
26034
- const held = await node(path);
26035
- if (!held) return fs.readFileBuffer(path);
26036
- return held.byName(async () => held.pread(await held.size(), 0));
26102
+ const held2 = await node(path);
26103
+ if (!held2) return fs.readFileBuffer(path);
26104
+ return held2.byName(async () => held2.pread(await held2.size(), 0));
26037
26105
  },
26038
26106
  ...ranged2 ? {
26039
26107
  pread: async (path, at, n, version) => {
26040
- const held = await node(path);
26041
- return held ? held.byName(() => held.pread(n, at)) : ranged2.pread(path, at, n, version);
26108
+ const held2 = await node(path);
26109
+ return held2 ? held2.byName(() => held2.pread(n, at)) : ranged2.pread(path, at, n, version);
26042
26110
  },
26043
26111
  pwrite: (path, at, bytes, transfer, options) => write(
26044
26112
  path,
26045
- async (held) => void await held.pwrite(bytes, at),
26113
+ async (held2) => void await held2.pwrite(bytes, at),
26046
26114
  () => ranged2.pwrite(path, at, bytes, transfer, options)
26047
26115
  ),
26048
26116
  truncate: (path, size) => write(
26049
26117
  path,
26050
- (held) => held.truncate(size),
26118
+ (held2) => held2.truncate(size),
26051
26119
  () => ranged2.truncate(path, size)
26052
26120
  )
26053
26121
  } : {}
@@ -26088,15 +26156,15 @@ function keepingOpen(fs, nodes, changed = () => {
26088
26156
  },
26089
26157
  writeFile: async (path, content, owner) => {
26090
26158
  const at = fs.resolvePath("/", path);
26091
- const held = await heldAt(fs, nodes, at);
26092
- if (!held) return nodes.onEntry(at, () => fs.writeFile(path, content, owner));
26159
+ const held2 = await heldAt(fs, nodes, at);
26160
+ if (!held2) return nodes.onEntry(at, () => fs.writeFile(path, content, owner));
26093
26161
  const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
26094
- return held.byName(async () => {
26095
- await held.truncate(0);
26096
- await held.pwrite(bytes, 0);
26097
- await held.flush();
26162
+ return held2.byName(async () => {
26163
+ await held2.truncate(0);
26164
+ await held2.pwrite(bytes, 0);
26165
+ await held2.flush();
26098
26166
  changed(at);
26099
- if (held.path !== at) changed(held.path);
26167
+ if (held2.path !== at) changed(held2.path);
26100
26168
  });
26101
26169
  },
26102
26170
  createExclusive: async (path, owner) => nodes.createExclusive(await nodes.entryKey(fs.resolvePath("/", path)), owner),
@@ -28381,12 +28449,12 @@ var Dying = class {
28381
28449
  };
28382
28450
  function killThread(thread, caught, sig) {
28383
28451
  if (!thread) return false;
28384
- const held = (Atomics.load(thread.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
28385
- if (!held && (caught & sigbit(sig)) === 0) return false;
28452
+ const held2 = (Atomics.load(thread.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
28453
+ if (!held2 && (caught & sigbit(sig)) === 0) return false;
28386
28454
  Atomics.or(thread.header, SAB_I_SIGNALS, sigbit(sig));
28387
28455
  Atomics.notify(thread.header, SAB_I_SIGNALS);
28388
28456
  headerNotified(thread.header, SAB_I_SIGNALS, sigbit(sig));
28389
- if (held) return true;
28457
+ if (held2) return true;
28390
28458
  const blocked2 = thread.interrupt;
28391
28459
  thread.interrupt = new AbortController();
28392
28460
  blocked2.abort();
@@ -29132,8 +29200,8 @@ var RemoteWatch = class {
29132
29200
  if (!this.locks) return;
29133
29201
  const prefix = `${this.name}:`;
29134
29202
  const mine = this.lockOf(this.tab);
29135
- const held = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
29136
- if (!held.some((name2) => name2.startsWith(prefix) && name2 !== mine) || this.peers.size > 0)
29203
+ const held2 = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
29204
+ if (!held2.some((name2) => name2.startsWith(prefix) && name2 !== mine) || this.peers.size > 0)
29137
29205
  return;
29138
29206
  await new Promise((resolve2) => {
29139
29207
  const timer = setTimeout(resolve2, ANNOUNCE_WAIT_MS);
@@ -29167,8 +29235,8 @@ var RemoteWatch = class {
29167
29235
  const prefix = `${this.name}:`;
29168
29236
  const began = performance.now();
29169
29237
  for (; ; ) {
29170
- const held = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
29171
- const silent = held.some(
29238
+ const held2 = ((await this.locks.query()).held ?? []).map((lock) => lock.name ?? "");
29239
+ const silent = held2.some(
29172
29240
  (name2) => name2.startsWith(prefix) && name2 !== this.lockOf(this.tab) && !this.peers.has(name2.slice(prefix.length))
29173
29241
  );
29174
29242
  if (!silent) return true;
@@ -29218,8 +29286,8 @@ var RemoteWatch = class {
29218
29286
  if (!this.locks || this.mourned.has(peer)) return;
29219
29287
  this.mourned.add(peer);
29220
29288
  const name2 = this.lockOf(peer);
29221
- const { held = [], pending = [] } = await this.locks.query();
29222
- if (![...held, ...pending].some((lock) => lock.name === name2)) {
29289
+ const { held: held2 = [], pending = [] } = await this.locks.query();
29290
+ if (![...held2, ...pending].some((lock) => lock.name === name2)) {
29223
29291
  this.mourned.delete(peer);
29224
29292
  const live2 = this.peers.has(peer) || this.flushes.has(peer);
29225
29293
  if (tries > 1 && live2) {
@@ -29300,10 +29368,10 @@ var RemoteWatch = class {
29300
29368
  const from = tab;
29301
29369
  const { add, drop } = holds3;
29302
29370
  if (holds3?.instance !== void 0) this.instances.set(from, holds3.instance);
29303
- const held = this.peerHolds.get(from) ?? /* @__PURE__ */ new Map();
29304
- for (const path of drop) held.delete(path);
29305
- for (const [path, fid] of add) held.set(path, fid);
29306
- if (held.size > 0) this.peerHolds.set(from, held);
29371
+ const held2 = this.peerHolds.get(from) ?? /* @__PURE__ */ new Map();
29372
+ for (const path of drop) held2.delete(path);
29373
+ for (const [path, fid] of add) held2.set(path, fid);
29374
+ if (held2.size > 0) this.peerHolds.set(from, held2);
29307
29375
  else this.peerHolds.delete(from);
29308
29376
  this.holdsChanged?.();
29309
29377
  this.channel.postMessage({ ack: seq2, from: this.tab, to: from });
@@ -29352,8 +29420,8 @@ var RemoteWatch = class {
29352
29420
  }
29353
29421
  heldWithin(target) {
29354
29422
  const out = [];
29355
- for (const [tab, held] of this.peerHolds) {
29356
- for (const [path, fid] of held) {
29423
+ for (const [tab, held2] of this.peerHolds) {
29424
+ for (const [path, fid] of held2) {
29357
29425
  if (path !== target && !path.startsWith(`${target}/`)) continue;
29358
29426
  out.push({ tab, path, fid, instance: this.instances.get(tab) });
29359
29427
  }
@@ -29377,18 +29445,18 @@ var RemoteWatch = class {
29377
29445
  }
29378
29446
  peerHeld(path) {
29379
29447
  const out = [];
29380
- for (const [tab, held] of this.peerHolds)
29381
- if (held.has(path)) out.push({ tab, fid: held.get(path) });
29448
+ for (const [tab, held2] of this.peerHolds)
29449
+ if (held2.has(path)) out.push({ tab, fid: held2.get(path) });
29382
29450
  return out;
29383
29451
  }
29384
29452
  peerHeldPaths() {
29385
29453
  const out = /* @__PURE__ */ new Set();
29386
- for (const held of this.peerHolds.values()) for (const path of held.keys()) out.add(path);
29454
+ for (const held2 of this.peerHolds.values()) for (const path of held2.keys()) out.add(path);
29387
29455
  return [...out].sort();
29388
29456
  }
29389
29457
  holdCounts() {
29390
29458
  let peers = 0;
29391
- for (const held of this.peerHolds.values()) peers += held.size;
29459
+ for (const held2 of this.peerHolds.values()) peers += held2.size;
29392
29460
  return { mine: this.myHolds.size, peers, sent: this.holdsSent };
29393
29461
  }
29394
29462
  acked(seq2, from) {
@@ -29403,10 +29471,10 @@ var RemoteWatch = class {
29403
29471
  }
29404
29472
  async prune() {
29405
29473
  if (!this.locks) return;
29406
- const held = new Set(((await this.locks.query()).held ?? []).map((lock) => lock.name));
29474
+ const held2 = new Set(((await this.locks.query()).held ?? []).map((lock) => lock.name));
29407
29475
  let left = false;
29408
29476
  for (const tab of /* @__PURE__ */ new Set([...this.others.keys(), ...this.peers, ...this.peerHolds.keys()])) {
29409
- if (!held.has(this.lockOf(tab))) {
29477
+ if (!held2.has(this.lockOf(tab))) {
29410
29478
  if (this.peers.delete(tab)) left = true;
29411
29479
  this.others.delete(tab);
29412
29480
  if (this.peerHolds.delete(tab)) this.holdsChanged?.();
@@ -29636,9 +29704,9 @@ var LockService = class {
29636
29704
  case "set":
29637
29705
  return t.set(ask.key, this.ownerFor(from, ask.owner), ask.kind, ask.start, ask.end);
29638
29706
  case "holder": {
29639
- const held = t.holder(ask.key, this.ownerFor(from, ask.owner), ask);
29640
- if (!held) return void 0;
29641
- return { ...held, owner: this.ownerOf.get(held.owner)?.owner ?? held.owner };
29707
+ const held2 = t.holder(ask.key, this.ownerFor(from, ask.owner), ask);
29708
+ if (!held2) return void 0;
29709
+ return { ...held2, owner: this.ownerOf.get(held2.owner)?.owner ?? held2.owner };
29642
29710
  }
29643
29711
  case "wait":
29644
29712
  return this.blockFor(
@@ -29682,15 +29750,15 @@ var LockService = class {
29682
29750
  this.pruner.unref?.();
29683
29751
  }
29684
29752
  async prune() {
29685
- const held = new Set(((await this.locks.query()).held ?? []).map((l) => l.name));
29753
+ const held2 = new Set(((await this.locks.query()).held ?? []).map((l) => l.name));
29686
29754
  for (const [id2, { kernel, owner }] of [...this.ownerOf]) {
29687
- if (held.has(this.aliveOf(kernel))) continue;
29755
+ if (held2.has(this.aliveOf(kernel))) continue;
29688
29756
  this.table.release(id2);
29689
29757
  this.ownerOf.delete(id2);
29690
29758
  this.owners.delete(`${kernel}:${owner}`);
29691
29759
  }
29692
29760
  for (const [name2, token] of [...this.tokens]) {
29693
- if (held.has(this.aliveOf(name2.slice(0, name2.lastIndexOf(":"))))) continue;
29761
+ if (held2.has(this.aliveOf(name2.slice(0, name2.lastIndexOf(":"))))) continue;
29694
29762
  this.table.flocks.drop(token);
29695
29763
  this.tokens.delete(name2);
29696
29764
  }
@@ -29706,11 +29774,11 @@ var LockService = class {
29706
29774
  for (const [id2, p] of this.pending)
29707
29775
  this.channel.postMessage({ id: id2, from: this.kernel, ask: p.ask });
29708
29776
  }
29709
- adopt(from, held) {
29710
- for (const [key, locks] of held.records)
29777
+ adopt(from, held2) {
29778
+ for (const [key, locks] of held2.records)
29711
29779
  for (const l of locks)
29712
29780
  this.table.set(key, this.ownerFor(from, l.owner), l.kind, l.start, l.end);
29713
- for (const [key, owner, kind] of held.flocks)
29781
+ for (const [key, owner, kind] of held2.flocks)
29714
29782
  this.table.flocks.set(key, this.tokenFor(from, owner), kind);
29715
29783
  }
29716
29784
  flockIdOf(owner) {
@@ -30109,23 +30177,23 @@ function bodiless(hop) {
30109
30177
  }
30110
30178
  function replayingHops(inner, heldMs = HELD_MS) {
30111
30179
  if (!inner.traits.redirectHops || inner.traits.manualRedirects) return inner;
30112
- const held = /* @__PURE__ */ new Map();
30180
+ const held2 = /* @__PURE__ */ new Map();
30113
30181
  const drop = (key) => {
30114
- const entry = held.get(key);
30182
+ const entry = held2.get(key);
30115
30183
  if (!entry) return;
30116
- held.delete(key);
30184
+ held2.delete(key);
30117
30185
  clearTimeout(entry.timer);
30118
30186
  void entry.final.cancel().catch(() => void 0);
30119
30187
  };
30120
30188
  const keyOf4 = (owner, method, url) => `${owner} ${method} ${url}`;
30121
30189
  const hold = (key, chain2) => {
30122
30190
  drop(key);
30123
- const mine = [...held.keys()].filter((k) => held.get(k)?.owner === chain2.owner);
30191
+ const mine = [...held2.keys()].filter((k) => held2.get(k)?.owner === chain2.owner);
30124
30192
  if (mine.length >= HELD_PER_OWNER) drop(mine[0]);
30125
- if (held.size >= HELD_MAX2) drop(held.keys().next().value);
30193
+ if (held2.size >= HELD_MAX2) drop(held2.keys().next().value);
30126
30194
  const timer = setTimeout(() => drop(key), heldMs);
30127
30195
  timer.unref?.();
30128
- held.set(key, { ...chain2, timer });
30196
+ held2.set(key, { ...chain2, timer });
30129
30197
  };
30130
30198
  const replay = (chain2) => {
30131
30199
  const [hop, ...rest2] = chain2.hops;
@@ -30154,9 +30222,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
30154
30222
  const [caller] = rest2;
30155
30223
  const owner = caller ?? KERNEL;
30156
30224
  const key = keyOf4(owner, request.method, request.url);
30157
- const waiting2 = held.get(key);
30225
+ const waiting2 = held2.get(key);
30158
30226
  if (waiting2 && waiting2.fingerprint === fingerprint(request.headers)) {
30159
- held.delete(key);
30227
+ held2.delete(key);
30160
30228
  clearTimeout(waiting2.timer);
30161
30229
  return replay(waiting2);
30162
30230
  }
@@ -30463,10 +30531,10 @@ var RenameLog = class {
30463
30531
  }
30464
30532
  return void 0;
30465
30533
  }
30466
- since(seen, held) {
30534
+ since(seen, held2) {
30467
30535
  const now = this.entries.at(-1)?.seq ?? seen;
30468
30536
  const renames = [];
30469
- let paths = [...held];
30537
+ let paths = [...held2];
30470
30538
  for (const { seq: seq2, from, to } of this.entries) {
30471
30539
  if (seq2 <= seen || !paths.some((path) => within9(path, from))) continue;
30472
30540
  renames.push([from, to]);
@@ -30511,11 +30579,11 @@ var PackageLocks = class {
30511
30579
  const { locks } = this;
30512
30580
  if (!locks) return Promise.resolve(() => {
30513
30581
  });
30514
- const { promise: held, resolve: release } = Promise.withResolvers();
30582
+ const { promise: held2, resolve: release } = Promise.withResolvers();
30515
30583
  return new Promise((granted2, failed4) => {
30516
30584
  locks.request(replacingLock(this.metadata, root), { mode: "exclusive" }, () => {
30517
30585
  granted2(() => release());
30518
- return held;
30586
+ return held2;
30519
30587
  }).catch(failed4);
30520
30588
  });
30521
30589
  }
@@ -31185,14 +31253,14 @@ var OpfsFs = class {
31185
31253
  return void 0;
31186
31254
  }
31187
31255
  heldUnder = () => [];
31188
- heldBy(held) {
31189
- this.heldUnder = held;
31256
+ heldBy(held2) {
31257
+ this.heldUnder = held2;
31190
31258
  }
31191
31259
  async pinHeld(dir) {
31192
- const held = this.heldUnder(dir);
31193
- if (held.length === 0) return;
31194
- const known = await this.meta.get(held);
31195
- const bare = held.filter((_, i) => known[i]?.ino === void 0);
31260
+ const held2 = this.heldUnder(dir);
31261
+ if (held2.length === 0) return;
31262
+ const known = await this.meta.get(held2);
31263
+ const bare = held2.filter((_, i) => known[i]?.ino === void 0);
31196
31264
  for (const p of bare) {
31197
31265
  await this.meta.update(p, (entry) => ({ ...occupied(entry), path: p, ino: inodeOf(p) }));
31198
31266
  }
@@ -32632,8 +32700,8 @@ var OpfsFs = class {
32632
32700
  }
32633
32701
  }
32634
32702
  async renamingElsewhere() {
32635
- const { held = [] } = await this.locks.query();
32636
- return held.some(({ name: name2 }) => this.renameHere(name2) && !this.ownLocks.has(name2));
32703
+ const { held: held2 = [] } = await this.locks.query();
32704
+ return held2.some(({ name: name2 }) => this.renameHere(name2) && !this.ownLocks.has(name2));
32637
32705
  }
32638
32706
  lookForRenames() {
32639
32707
  const locks = this.locks;
@@ -32643,8 +32711,8 @@ var OpfsFs = class {
32643
32711
  for (; ; ) {
32644
32712
  const asked = performance.now();
32645
32713
  this.queries++;
32646
- const { held = [] } = await locks.query();
32647
- const unknown = () => held.some(
32714
+ const { held: held2 = [] } = await locks.query();
32715
+ const unknown = () => held2.some(
32648
32716
  ({ name: name2 }) => this.renameHere(name2) && !this.ownLocks.has(name2) && !this.peerMoves.has(name2)
32649
32717
  );
32650
32718
  if (unknown()) await this.learnRenames();
@@ -32825,13 +32893,13 @@ var OpfsFs = class {
32825
32893
  }
32826
32894
  async finishRenames(orphaned = false) {
32827
32895
  const locks = this.locks;
32828
- const held = /* @__PURE__ */ new Set();
32896
+ const held2 = /* @__PURE__ */ new Set();
32829
32897
  if (orphaned && locks) {
32830
32898
  const { held: h = [], pending = [] } = await locks.query();
32831
- for (const lock of [...h, ...pending]) held.add(lock.name);
32899
+ for (const lock of [...h, ...pending]) held2.add(lock.name);
32832
32900
  }
32833
32901
  const intents = (await this.meta.under(RENAMES2)).filter(
32834
- (entry) => entry.rename !== void 0 && (!orphaned || locks !== void 0 && entry.rename.lock !== void 0 && !held.has(entry.rename.lock))
32902
+ (entry) => entry.rename !== void 0 && (!orphaned || locks !== void 0 && entry.rename.lock !== void 0 && !held2.has(entry.rename.lock))
32835
32903
  ).sort(
32836
32904
  (a, b) => a.rename.at - b.rename.at
32837
32905
  );
@@ -36462,34 +36530,34 @@ var Launcher = class {
36462
36530
  known.users++;
36463
36531
  return known.made;
36464
36532
  }
36465
- const held = {
36533
+ const held2 = {
36466
36534
  made: (this.moduleUrl ?? dataModuleUrl)(source),
36467
36535
  users: 1,
36468
36536
  evicted: false
36469
36537
  };
36470
- this.moduleUrls.set(source, held);
36471
- this.urlsInUse.set(held.made.url, held);
36538
+ this.moduleUrls.set(source, held2);
36539
+ this.urlsInUse.set(held2.made.url, held2);
36472
36540
  for (const [old, entry] of this.moduleUrls) {
36473
36541
  if (this.moduleUrls.size <= MODULE_URLS) break;
36474
36542
  this.moduleUrls.delete(old);
36475
36543
  entry.evicted = true;
36476
36544
  this.releaseUrl(entry);
36477
36545
  }
36478
- return held.made;
36546
+ return held2.made;
36479
36547
  }
36480
36548
  heldUrl(program) {
36481
- const held = program.abi === "js" && program.url ? this.urlsInUse.get(program.url) : void 0;
36482
- if (!held) return () => {
36549
+ const held2 = program.abi === "js" && program.url ? this.urlsInUse.get(program.url) : void 0;
36550
+ if (!held2) return () => {
36483
36551
  };
36484
36552
  return () => {
36485
- held.users--;
36486
- this.releaseUrl(held);
36553
+ held2.users--;
36554
+ this.releaseUrl(held2);
36487
36555
  };
36488
36556
  }
36489
- releaseUrl(held) {
36490
- if (!held.evicted || held.users > 0) return;
36491
- if (this.urlsInUse.get(held.made.url) === held) this.urlsInUse.delete(held.made.url);
36492
- held.made.revoke();
36557
+ releaseUrl(held2) {
36558
+ if (!held2.evicted || held2.users > 0) return;
36559
+ if (this.urlsInUse.get(held2.made.url) === held2) this.urlsInUse.delete(held2.made.url);
36560
+ held2.made.revoke();
36493
36561
  }
36494
36562
  async names(path) {
36495
36563
  const beside = `${path}.names`;
@@ -36576,10 +36644,10 @@ var Launcher = class {
36576
36644
  }
36577
36645
  const mine = hold;
36578
36646
  mine.users++;
36579
- let held = true;
36647
+ let held2 = true;
36580
36648
  return () => {
36581
- if (!held) return;
36582
- held = false;
36649
+ if (!held2) return;
36650
+ held2 = false;
36583
36651
  if (--mine.users > 0) return;
36584
36652
  holds3.delete(mine);
36585
36653
  if (holds3.size === 0 && this.imageHolds.get(path) === holds3) this.imageHolds.delete(path);
@@ -36742,16 +36810,16 @@ var Launcher = class {
36742
36810
  let roots = this.packageRoots(planned);
36743
36811
  let stale = false;
36744
36812
  for (; ; ) {
36745
- const held = roots;
36746
- const done4 = await this.packageLocks.loading(held, async (waited) => {
36813
+ const held2 = roots;
36814
+ const done4 = await this.packageLocks.loading(held2, async (waited) => {
36747
36815
  if (!waited && !stale) return { value: await load(planned) };
36748
- this.rootFs.refresh?.(held);
36816
+ this.rootFs.refresh?.(held2);
36749
36817
  this.resetCatalogs();
36750
36818
  if (replan) planned = await replan() ?? planned;
36751
36819
  await recheck?.(planned);
36752
36820
  const now = this.packageRoots(planned);
36753
- if (now.every((root) => held.includes(root))) return { value: await load(planned) };
36754
- roots = [.../* @__PURE__ */ new Set([...held, ...now])].sort();
36821
+ if (now.every((root) => held2.includes(root))) return { value: await load(planned) };
36822
+ roots = [.../* @__PURE__ */ new Set([...held2, ...now])].sort();
36755
36823
  stale = true;
36756
36824
  return void 0;
36757
36825
  });
@@ -36959,7 +37027,7 @@ var Launcher = class {
36959
37027
  unlinkGate: stack.unlinked.gate,
36960
37028
  replacements: stack.unlinked,
36961
37029
  statfs: (path) => this.mounts.statfs(path),
36962
- renames: (since2, held) => this.renameLog.since(since2, held),
37030
+ renames: (since2, held2) => this.renameLog.since(since2, held2),
36963
37031
  fileId: (path) => this.locks.shared?.() === true ? this.rootFileId(path) : void 0,
36964
37032
  announceHold: (path, fid, created4) => this.locks.shared?.() === true && this.mounts.locate(path) === void 0 ? this.rootFs.announceHolds?.([[path, fid]], [], !created4) : void 0,
36965
37033
  renameSeq: (from, to) => this.renameLog.seqOf(from, to),
@@ -37152,17 +37220,17 @@ var Launcher = class {
37152
37220
  const tags = this.tagsOf(pid);
37153
37221
  const cred = this.credOf(pid);
37154
37222
  if (!this.traces.wants(tags, cred)) return;
37155
- const held = this.traceHeld.get(pid);
37156
- if (held) held.events.push({ tags, cred: copyCred(cred), draft: build() });
37223
+ const held2 = this.traceHeld.get(pid);
37224
+ if (held2) held2.events.push({ tags, cred: copyCred(cred), draft: build() });
37157
37225
  else this.traces.publish(tags, cred, build());
37158
37226
  }
37159
37227
  traceAdmitted(pid, fit) {
37160
- const held = this.traceHeld.get(pid);
37161
- if (!held) return;
37228
+ const held2 = this.traceHeld.get(pid);
37229
+ if (!held2) return;
37162
37230
  this.traceHeld.delete(pid);
37163
37231
  if (!fit) return;
37164
- if (held.replaces !== void 0) this.replacedImages.add(held.replaces);
37165
- for (const { tags, cred, draft } of held.events) this.traces.publish(tags, cred, draft);
37232
+ if (held2.replaces !== void 0) this.replacedImages.add(held2.replaces);
37233
+ for (const { tags, cred, draft } of held2.events) this.traces.publish(tags, cred, draft);
37166
37234
  }
37167
37235
  chainTimes(pid) {
37168
37236
  let utime = 0;
@@ -38127,10 +38195,10 @@ var Launcher = class {
38127
38195
  }
38128
38196
  announceHeld() {
38129
38197
  const nodes = [...this.openFiles].flatMap((open) => open.heldIds());
38130
- const held = [...this.held.heldIds(), ...nodes].filter(
38198
+ const held2 = [...this.held.heldIds(), ...nodes].filter(
38131
38199
  ([path]) => this.mounts.locate(path) === void 0 && !path.startsWith(`/${UNLINKED_DIR}/`)
38132
38200
  );
38133
- return held.length === 0 ? void 0 : this.rootFs.announceHolds?.(held, [], false);
38201
+ return held2.length === 0 ? void 0 : this.rootFs.announceHolds?.(held2, [], false);
38134
38202
  }
38135
38203
  rootFileId(path) {
38136
38204
  return this.mounts.locate(path) === void 0 ? this.rootFs.bindId?.(path) : void 0;
@@ -39986,16 +40054,16 @@ var Held = class {
39986
40054
  answer(result) {
39987
40055
  const { value: value2, pieces: pieces2 } = pack(result);
39988
40056
  if (pieces2.length === 0) return { value: value2 };
39989
- const held = this.next++;
39990
- this.answers.set(held, pieces2);
39991
- return { value: value2, held, count: pieces2.length };
40057
+ const held2 = this.next++;
40058
+ this.answers.set(held2, pieces2);
40059
+ return { value: value2, held: held2, count: pieces2.length };
39992
40060
  }
39993
- take(held, index) {
39994
- const pieces2 = this.answers.get(held);
40061
+ take(held2, index) {
40062
+ const pieces2 = this.answers.get(held2);
39995
40063
  const piece = pieces2?.[index];
39996
- if (!pieces2 || !piece) throw new Error(`no piece ${index} of answer ${held}`);
40064
+ if (!pieces2 || !piece) throw new Error(`no piece ${index} of answer ${held2}`);
39997
40065
  pieces2[index] = new Uint8Array(0);
39998
- if (index === pieces2.length - 1) this.answers.delete(held);
40066
+ if (index === pieces2.length - 1) this.answers.delete(held2);
39999
40067
  return piece;
40000
40068
  }
40001
40069
  clear() {
@@ -40186,8 +40254,8 @@ var KernelEnd = class extends RpcTarget {
40186
40254
  throw err;
40187
40255
  }
40188
40256
  }
40189
- take(held, index) {
40190
- return this.#state.held.take(held, index);
40257
+ take(held2, index) {
40258
+ return this.#state.held.take(held2, index);
40191
40259
  }
40192
40260
  };
40193
40261
  function describe2(err) {
@@ -41236,8 +41304,8 @@ var Files = class {
41236
41304
  return id2;
41237
41305
  }
41238
41306
  stagedChunk(writer, idx) {
41239
- const held = writer.staged.get(idx);
41240
- if (held) return held;
41307
+ const held2 = writer.staged.get(idx);
41308
+ if (held2) return held2;
41241
41309
  if (!writer.spilled.has(idx)) return void 0;
41242
41310
  const row = this.store.row(
41243
41311
  "SELECT data FROM slicc_staged WHERE writer = ? AND idx = ?",
@@ -41317,8 +41385,8 @@ var Files = class {
41317
41385
  const tail2 = size % CHUNK_BYTES;
41318
41386
  const last = Math.floor(size / CHUNK_BYTES);
41319
41387
  if (tail2 !== 0) {
41320
- const held = this.stagedChunk(writer, last);
41321
- if (held && held.length > tail2) this.stage(writer, last, held.slice(0, tail2));
41388
+ const held2 = this.stagedChunk(writer, last);
41389
+ if (held2 && held2.length > tail2) this.stage(writer, last, held2.slice(0, tail2));
41322
41390
  }
41323
41391
  }
41324
41392
  writer.size = size;
@@ -42185,13 +42253,13 @@ async function holdLock(locks) {
42185
42253
  } };
42186
42254
  const name2 = `slicc-kernel-client:${crypto.randomUUID()}`;
42187
42255
  const granted2 = Promise.withResolvers();
42188
- const held = Promise.withResolvers();
42256
+ const held2 = Promise.withResolvers();
42189
42257
  void locks.request(name2, () => {
42190
42258
  granted2.resolve();
42191
- return held.promise;
42259
+ return held2.promise;
42192
42260
  });
42193
42261
  await granted2.promise;
42194
- return { name: name2, release: () => held.resolve() };
42262
+ return { name: name2, release: () => held2.resolve() };
42195
42263
  }
42196
42264
  function concat8(chunks2) {
42197
42265
  const out = new Uint8Array(chunks2.reduce((n, c) => n + c.length, 0));
@@ -43546,12 +43614,12 @@ function shellFor(client2, driver, options, mountPoint) {
43546
43614
  }
43547
43615
  var holders = /* @__PURE__ */ new WeakMap();
43548
43616
  function holdersOf(kernel) {
43549
- let held = holders.get(kernel);
43550
- if (!held) {
43551
- held = /* @__PURE__ */ new Map();
43552
- holders.set(kernel, held);
43617
+ let held2 = holders.get(kernel);
43618
+ if (!held2) {
43619
+ held2 = /* @__PURE__ */ new Map();
43620
+ holders.set(kernel, held2);
43553
43621
  }
43554
- return held;
43622
+ return held2;
43555
43623
  }
43556
43624
  function sliccBackend(options) {
43557
43625
  const mountPoint = (options.mountPoint ?? "/workspace").replace(/\/+$/, "") || "/";
@@ -43563,8 +43631,8 @@ function sliccBackend(options) {
43563
43631
  description: options.description ?? `Runs the source with GNU bash in the SLICC kernel, with the packages installed in it, on the Workspace files at ${mountPoint}.`,
43564
43632
  async connect(host) {
43565
43633
  const kernel = await options.kernel();
43566
- const held = holdersOf(kernel);
43567
- await held.get(mountPoint)?.();
43634
+ const held2 = holdersOf(kernel);
43635
+ await held2.get(mountPoint)?.();
43568
43636
  const driver = workspaceDriver(host.fs, {
43569
43637
  root,
43570
43638
  writeBehind: options.writeBehind ?? true,
@@ -43594,11 +43662,11 @@ function sliccBackend(options) {
43594
43662
  await landed(driver);
43595
43663
  await kernel.umount(mountPoint).catch(() => void 0);
43596
43664
  await client2.close();
43597
- if (held.get(mountPoint) === close) held.delete(mountPoint);
43665
+ if (held2.get(mountPoint) === close) held2.delete(mountPoint);
43598
43666
  })();
43599
43667
  return closing2;
43600
43668
  };
43601
- held.set(mountPoint, close);
43669
+ held2.set(mountPoint, close);
43602
43670
  return {
43603
43671
  rpc: { sync: refusingSync(), shell },
43604
43672
  runtimeId: crypto.randomUUID(),
@@ -43668,6 +43736,13 @@ function checkedRequests(hook) {
43668
43736
  const kinds = kindsOf(hook);
43669
43737
  return { kinds, handle: (request) => hook.handle(request) };
43670
43738
  }
43739
+ function embedderHooks({ requests, approve, cdp }) {
43740
+ return {
43741
+ ...requests ? { embedder: checkedRequests(requests) } : {},
43742
+ ...approve ? { approve } : {},
43743
+ ...cdp ? { cdp } : {}
43744
+ };
43745
+ }
43671
43746
  function sourceModule(source) {
43672
43747
  return { url: "slicc-module:cloudflare", source, revoke: () => {
43673
43748
  } };
@@ -43799,8 +43874,7 @@ async function createCloudflareKernel(options) {
43799
43874
  ...options.protect ? { protect: options.protect } : {},
43800
43875
  ...hooks.request ? { sealed: hooks.request } : {},
43801
43876
  ...hooks.fetch ? { sealedFetch: hooks.fetch } : {},
43802
- ...options.requests ? { embedder: checkedRequests(options.requests) } : {},
43803
- ...options.approve ? { approve: options.approve } : {},
43877
+ ...embedderHooks(options),
43804
43878
  ...options.wasmMemories ? { wasmMemories: options.wasmMemories } : {},
43805
43879
  cron: { poll: false, ...options.cron }
43806
43880
  });