@cortexkit/aft-pi 0.51.2 → 0.52.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.
package/dist/index.js CHANGED
@@ -19,12 +19,14 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  }
20
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
21
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
22
+ if (mod && typeof mod === "object" || typeof mod === "function") {
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ }
28
30
  if (canCache)
29
31
  cache.set(mod, to);
30
32
  return to;
@@ -46,7 +48,7 @@ var __export = (target, all) => {
46
48
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
47
49
 
48
50
  // ../../node_modules/.bun/esprima@4.0.1/node_modules/esprima/dist/esprima.js
49
- var require_esprima = __commonJS((exports, module) => {
51
+ var require_esprima = __commonJS(function(exports, module) {
50
52
  (function webpackUniversalModuleDefinition(root, factory) {
51
53
  if (typeof exports === "object" && typeof module === "object")
52
54
  module.exports = factory();
@@ -6186,7 +6188,7 @@ var require_esprima = __commonJS((exports, module) => {
6186
6188
  });
6187
6189
 
6188
6190
  // ../../node_modules/.bun/array-timsort@1.0.3/node_modules/array-timsort/src/index.js
6189
- var require_src = __commonJS((exports, module) => {
6191
+ var require_src = __commonJS(function(exports, module) {
6190
6192
  var DEFAULT_MIN_MERGE = 32;
6191
6193
  var DEFAULT_MIN_GALLOPING = 7;
6192
6194
  var DEFAULT_TMP_STORAGE_LENGTH = 256;
@@ -6829,7 +6831,7 @@ var require_src = __commonJS((exports, module) => {
6829
6831
  });
6830
6832
 
6831
6833
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/common.js
6832
- var require_common = __commonJS((exports, module) => {
6834
+ var require_common = __commonJS(function(exports, module) {
6833
6835
  var PREFIX_BEFORE = "before";
6834
6836
  var PREFIX_AFTER_PROP = "after-prop";
6835
6837
  var PREFIX_AFTER_COLON = "after-colon";
@@ -7115,7 +7117,7 @@ var require_common = __commonJS((exports, module) => {
7115
7117
  });
7116
7118
 
7117
7119
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/array.js
7118
- var require_array = __commonJS((exports, module) => {
7120
+ var require_array = __commonJS(function(exports, module) {
7119
7121
  var { sort } = require_src();
7120
7122
  var {
7121
7123
  PROP_SYMBOL_PREFIXES,
@@ -7273,7 +7275,7 @@ var require_array = __commonJS((exports, module) => {
7273
7275
  });
7274
7276
 
7275
7277
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/parse.js
7276
- var require_parse = __commonJS((exports, module) => {
7278
+ var require_parse = __commonJS(function(exports, module) {
7277
7279
  var esprima = require_esprima();
7278
7280
  var {
7279
7281
  CommentArray
@@ -7639,7 +7641,7 @@ var require_parse = __commonJS((exports, module) => {
7639
7641
  });
7640
7642
 
7641
7643
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/stringify.js
7642
- var require_stringify = __commonJS((exports, module) => {
7644
+ var require_stringify = __commonJS(function(exports, module) {
7643
7645
  var {
7644
7646
  PREFIX_BEFORE_ALL,
7645
7647
  PREFIX_BEFORE,
@@ -7847,7 +7849,7 @@ var require_stringify = __commonJS((exports, module) => {
7847
7849
  });
7848
7850
 
7849
7851
  // ../../node_modules/.bun/comment-json@5.0.0/node_modules/comment-json/src/index.js
7850
- var require_src2 = __commonJS((exports, module) => {
7852
+ var require_src2 = __commonJS(function(exports, module) {
7851
7853
  var { parse, tokenize } = require_parse();
7852
7854
  var stringify = require_stringify();
7853
7855
  var { CommentArray } = require_array();
@@ -10181,19 +10183,38 @@ async function downloadBinary(version) {
10181
10183
  releaseLock?.();
10182
10184
  }
10183
10185
  }
10186
+ var ensureBinaryInFlight = new Map;
10187
+ function ensureBinaryKey(version) {
10188
+ if (!version)
10189
+ return "latest";
10190
+ return version.startsWith("v") ? version : `v${version}`;
10191
+ }
10184
10192
  async function ensureBinary(version) {
10185
- if (version) {
10186
- const tag = version.startsWith("v") ? version : `v${version}`;
10187
- const versionCached = getCachedBinaryPath(tag);
10188
- if (versionCached && isExpectedCachedBinary(versionCached, tag)) {
10189
- log(`Found cached binary for ${tag}: ${versionCached}`);
10190
- return versionCached;
10191
- }
10192
- log(`No cached binary for ${tag}, downloading...`);
10193
- return downloadBinary(tag);
10193
+ const key = ensureBinaryKey(version);
10194
+ const existing = ensureBinaryInFlight.get(key);
10195
+ if (existing)
10196
+ return existing;
10197
+ const task = (async () => {
10198
+ if (version) {
10199
+ const tag = ensureBinaryKey(version);
10200
+ const versionCached = getCachedBinaryPath(tag);
10201
+ if (versionCached && isExpectedCachedBinary(versionCached, tag)) {
10202
+ log(`Found cached binary for ${tag}: ${versionCached}`);
10203
+ return versionCached;
10204
+ }
10205
+ log(`No cached binary for ${tag}, downloading...`);
10206
+ return downloadBinary(tag);
10207
+ }
10208
+ log("No cached binary found, downloading latest...");
10209
+ return downloadBinary();
10210
+ })();
10211
+ ensureBinaryInFlight.set(key, task);
10212
+ try {
10213
+ return await task;
10214
+ } finally {
10215
+ if (ensureBinaryInFlight.get(key) === task)
10216
+ ensureBinaryInFlight.delete(key);
10194
10217
  }
10195
- log("No cached binary found, downloading latest...");
10196
- return downloadBinary();
10197
10218
  }
10198
10219
  function createDownloadLockOwner() {
10199
10220
  return JSON.stringify({
@@ -10493,78 +10514,17 @@ ${reflowText}`;
10493
10514
  }
10494
10515
  return " Auto-formatted.";
10495
10516
  }
10496
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/client.js
10517
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/client.js
10497
10518
  import { promises as fs3 } from "node:fs";
10498
10519
  import { debuglog } from "node:util";
10499
10520
 
10500
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/auth.js
10521
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/auth.js
10501
10522
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
10502
- var NONCE_LEN = 32;
10503
- var MAX_AUTH_MESSAGE_LEN = 4096;
10504
- var SERVER_PROOF_DOMAIN = "subc-server-v1";
10505
- var CLIENT_AUTH_DOMAIN = "subc-client-v1";
10506
- var DEFAULT_CLIENT_ROLE = "client";
10507
-
10508
- class AuthError extends Error {
10509
- }
10510
- function computeProof(key, domain, clientNonce, serverNonce, daemonId) {
10511
- const mac = createHmac("sha256", Buffer.from(key));
10512
- mac.update(Buffer.from(domain, "utf8"));
10513
- mac.update(Buffer.from(clientNonce));
10514
- mac.update(Buffer.from(serverNonce));
10515
- mac.update(Buffer.from(daemonId));
10516
- return new Uint8Array(mac.digest());
10517
- }
10518
- function constantTimeEq(a, b) {
10519
- if (a.length !== b.length)
10520
- return false;
10521
- return timingSafeEqual(Buffer.from(a), Buffer.from(b));
10522
- }
10523
- async function writeMessage(sock, value, deadlineMs) {
10524
- const json = Buffer.from(JSON.stringify(value), "utf8");
10525
- if (json.length > MAX_AUTH_MESSAGE_LEN) {
10526
- throw new AuthError(`auth message too large: ${json.length} > ${MAX_AUTH_MESSAGE_LEN}`);
10527
- }
10528
- const lenPrefix = new Uint8Array(4);
10529
- new DataView(lenPrefix.buffer).setUint32(0, json.length, true);
10530
- await sock.write(lenPrefix, deadlineMs);
10531
- await sock.write(json, deadlineMs);
10532
- }
10533
- async function readMessage(sock, deadlineMs) {
10534
- const lenBytes = await sock.readExact(4, deadlineMs);
10535
- const len = new DataView(lenBytes.buffer, lenBytes.byteOffset, 4).getUint32(0, true);
10536
- if (len > MAX_AUTH_MESSAGE_LEN) {
10537
- throw new AuthError(`auth message too large: ${len} > ${MAX_AUTH_MESSAGE_LEN}`);
10538
- }
10539
- const body = len === 0 ? new Uint8Array(0) : await sock.readExact(len, deadlineMs);
10540
- try {
10541
- return JSON.parse(Buffer.from(body).toString("utf8"));
10542
- } catch (err) {
10543
- throw new AuthError(`auth message JSON decode failed: ${String(err)}`);
10544
- }
10545
- }
10546
- async function authenticateClient(sock, conn, deadlineMs) {
10547
- const clientNonce = new Uint8Array(randomBytes(NONCE_LEN));
10548
- await writeMessage(sock, { client_nonce: Array.from(clientNonce), role: DEFAULT_CLIENT_ROLE }, deadlineMs);
10549
- const proof = await readMessage(sock, deadlineMs);
10550
- const serverNonce = Uint8Array.from(proof.server_nonce);
10551
- const daemonId = Uint8Array.from(proof.daemon_id);
10552
- const serverProof = Uint8Array.from(proof.server_proof);
10553
- const expected = computeProof(conn.key, SERVER_PROOF_DOMAIN, clientNonce, serverNonce, daemonId);
10554
- if (!constantTimeEq(expected, serverProof)) {
10555
- throw new AuthError("server proof mismatch — wrong key or impostor daemon");
10556
- }
10557
- if (!constantTimeEq(daemonId, conn.daemonId)) {
10558
- throw new AuthError("daemon id mismatch — connection file points at a different daemon");
10559
- }
10560
- const clientAuth = computeProof(conn.key, CLIENT_AUTH_DOMAIN, clientNonce, serverNonce, daemonId);
10561
- await writeMessage(sock, { client_auth: Array.from(clientAuth) }, deadlineMs);
10562
- }
10563
10523
 
10564
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
10565
- import { promises as fs2 } from "node:fs";
10524
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/socket.js
10525
+ import net from "node:net";
10566
10526
 
10567
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/envelope.js
10527
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/envelope.js
10568
10528
  var PROTOCOL_VERSION = 2;
10569
10529
  var HEADER_LEN = 21;
10570
10530
  var FROZEN_PREFIX_LEN = 5;
@@ -10638,6 +10598,39 @@ class DecodeError extends Error {
10638
10598
  this.name = "DecodeError";
10639
10599
  }
10640
10600
  }
10601
+ function validateHeaderFields(header) {
10602
+ const len = header.len >>> 0;
10603
+ const ver = header.ver >>> 0 & 255;
10604
+ const typeByte = header.ty >>> 0 & 255;
10605
+ const flags = header.flags >>> 0 & 255;
10606
+ const channel = header.channel >>> 0 & 65535;
10607
+ const epoch = header.epoch >>> 0;
10608
+ BigInt.asUintN(64, header.corr);
10609
+ if (ver !== PROTOCOL_VERSION)
10610
+ throw new DecodeError(`unsupported envelope version ${ver}`, "unsupported_version");
10611
+ if (typeByte > FRAME_TYPE_MAX)
10612
+ throw new DecodeError(`unknown frame type byte ${typeByte}`, "unknown_frame_type");
10613
+ const ty = typeByte;
10614
+ if ((flags & FLAG_RESERVED_MASK) !== 0) {
10615
+ throw new DecodeError(`reserved flag bits set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_flag_bits");
10616
+ }
10617
+ if ((flags & FLAG_PRIORITY_MASK) >> FLAG_PRIORITY_SHIFT === 3) {
10618
+ throw new DecodeError(`reserved priority bits set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_priority_bits");
10619
+ }
10620
+ const admission = (flags & FLAG_ADMISSION_MASK) >> FLAG_ADMISSION_SHIFT;
10621
+ if (admission === 3) {
10622
+ throw new DecodeError(`reserved admission class set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_admission_class");
10623
+ }
10624
+ if (admission === AdmissionClass.Sheddable && ty !== FrameType.Push && ty !== FrameType.StreamData) {
10625
+ throw new DecodeError(`SHEDDABLE admission class is illegal on ${FrameType[ty]} in flags 0b${flags.toString(2).padStart(8, "0")}`, "sheddable_illegal_frame_type");
10626
+ }
10627
+ if (channel === 0 && epoch !== 0) {
10628
+ throw new DecodeError(`control channel carried nonzero epoch ${epoch}`, "nonzero_epoch_on_control_channel");
10629
+ }
10630
+ if (isPureHeader(ty) && len !== 0) {
10631
+ throw new DecodeError(`pure-header frame ${FrameType[ty]} declared non-zero body length ${len}`, "pure_header_frame_with_body");
10632
+ }
10633
+ }
10641
10634
  function decodeHeader(bytes) {
10642
10635
  if (bytes.length < FROZEN_PREFIX_LEN) {
10643
10636
  throw new DecodeError(`header shorter than frozen prefix: have ${bytes.length} bytes`, "too_short_for_prefix");
@@ -10686,7 +10679,7 @@ function buildFrameWithVersion(ver, ty, flags, channel, epoch, corr, body) {
10686
10679
  throw new DecodeError(`frame body ${body.length} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10687
10680
  }
10688
10681
  const header = { len: body.length, ver, ty, flags, channel, epoch, corr };
10689
- decodeHeader(encodeHeader(header));
10682
+ validateHeaderFields(header);
10690
10683
  return { header, body };
10691
10684
  }
10692
10685
  function encodeFrame(frame) {
@@ -10700,7 +10693,315 @@ function encodeFrame(frame) {
10700
10693
  return output;
10701
10694
  }
10702
10695
 
10703
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
10696
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/socket.js
10697
+ class SocketClosedError extends Error {
10698
+ }
10699
+
10700
+ class SocketTimeoutError extends Error {
10701
+ }
10702
+
10703
+ class SocketWriteNotQueuedError extends Error {
10704
+ cause;
10705
+ constructor(message, cause) {
10706
+ super(message);
10707
+ this.cause = cause;
10708
+ }
10709
+ }
10710
+
10711
+ class SocketWriteQueuedError extends Error {
10712
+ cause;
10713
+ constructor(message, cause) {
10714
+ super(message);
10715
+ this.cause = cause;
10716
+ }
10717
+ }
10718
+ function toWriteBuffer(bytes) {
10719
+ return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
10720
+ }
10721
+ var WRITE_BORROWED = Symbol("subc.socket.writeBorrowed");
10722
+ var WRITE_TRACKED_BORROWED = Symbol("subc.socket.writeTrackedBorrowed");
10723
+ function writeBorrowed(socket, bytes, deadlineMs) {
10724
+ const borrowed = socket[WRITE_BORROWED];
10725
+ return borrowed ? borrowed.call(socket, bytes, deadlineMs) : socket.write(bytes, deadlineMs);
10726
+ }
10727
+ function writeTrackedBorrowed(socket, bytes, deadlineMs) {
10728
+ const borrowed = socket[WRITE_TRACKED_BORROWED];
10729
+ return borrowed ? borrowed.call(socket, bytes, deadlineMs) : socket.writeTracked(bytes, deadlineMs);
10730
+ }
10731
+
10732
+ class SubcSocket {
10733
+ sock;
10734
+ chunks = [];
10735
+ buffered = 0;
10736
+ waiter = null;
10737
+ closedErr = null;
10738
+ bufferedBytes() {
10739
+ return this.buffered;
10740
+ }
10741
+ constructor(sock) {
10742
+ this.sock = sock;
10743
+ sock.on("data", (chunk) => {
10744
+ this.chunks.push(chunk);
10745
+ this.buffered += chunk.length;
10746
+ this.tryServe();
10747
+ });
10748
+ const fail = (err) => {
10749
+ if (!this.closedErr)
10750
+ this.closedErr = err;
10751
+ this.tryServe();
10752
+ };
10753
+ sock.on("error", (err) => fail(err instanceof Error ? err : new Error(String(err))));
10754
+ sock.on("end", () => fail(new SocketClosedError("subc closed the connection")));
10755
+ sock.on("close", () => fail(new SocketClosedError("subc connection closed")));
10756
+ }
10757
+ localPort() {
10758
+ return this.sock.localPort ?? null;
10759
+ }
10760
+ static connect(host, port, deadlineMs) {
10761
+ return new Promise((resolve3, reject) => {
10762
+ const sock = net.connect({ host, port });
10763
+ sock.setNoDelay(true);
10764
+ const timer = setTimeout(() => {
10765
+ sock.destroy();
10766
+ reject(new SocketTimeoutError(`timed out connecting to ${host}:${port}`));
10767
+ }, Math.max(0, deadlineMs - Date.now()));
10768
+ sock.once("connect", () => {
10769
+ clearTimeout(timer);
10770
+ resolve3(new SubcSocket(sock));
10771
+ });
10772
+ sock.once("error", (err) => {
10773
+ clearTimeout(timer);
10774
+ reject(err);
10775
+ });
10776
+ });
10777
+ }
10778
+ async readFrame(headerDeadlineMs, bodyDeadline, onHeader) {
10779
+ const prefix = await this.readExact(FROZEN_PREFIX_LEN, headerDeadlineMs);
10780
+ const version = prefix[4];
10781
+ if (version !== PROTOCOL_VERSION)
10782
+ throw new DecodeError(`unsupported envelope version ${version}`, "unsupported_version");
10783
+ const remainder = await this.readExact(HEADER_LEN - FROZEN_PREFIX_LEN, headerDeadlineMs);
10784
+ const headerBytes = new Uint8Array(HEADER_LEN);
10785
+ headerBytes.set(prefix);
10786
+ headerBytes.set(remainder, FROZEN_PREFIX_LEN);
10787
+ const header = decodeHeader(headerBytes);
10788
+ if (header.len > MAX_FRAME_BODY_LEN) {
10789
+ throw new DecodeError(`frame body ${header.len} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10790
+ }
10791
+ onHeader?.();
10792
+ const bodyDeadlineMs = typeof bodyDeadline === "number" ? bodyDeadline : Date.now() + bodyDeadline.afterHeaderMs;
10793
+ const body = header.len === 0 ? new Uint8Array(0) : await this.readExact(header.len, bodyDeadlineMs);
10794
+ return { header, body };
10795
+ }
10796
+ readExact(n, deadlineMs) {
10797
+ if (this.waiter) {
10798
+ return Promise.reject(new Error("concurrent readExact is not supported"));
10799
+ }
10800
+ if (n === 0)
10801
+ return Promise.resolve(new Uint8Array(0));
10802
+ return new Promise((resolve3, reject) => {
10803
+ let timer = null;
10804
+ if (Number.isFinite(deadlineMs)) {
10805
+ const remaining = deadlineMs - Date.now();
10806
+ if (remaining <= 0) {
10807
+ reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10808
+ return;
10809
+ }
10810
+ timer = setTimeout(() => {
10811
+ this.waiter = null;
10812
+ reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10813
+ }, remaining);
10814
+ }
10815
+ this.waiter = { need: n, resolve: resolve3, reject, timer };
10816
+ this.tryServe();
10817
+ });
10818
+ }
10819
+ async write(bytes, deadlineMs) {
10820
+ await this.writeBuffer(Buffer.from(bytes), deadlineMs);
10821
+ }
10822
+ writeTracked(bytes, deadlineMs) {
10823
+ return this.writeTrackedBuffer(Buffer.from(bytes), deadlineMs);
10824
+ }
10825
+ async[WRITE_BORROWED](bytes, deadlineMs) {
10826
+ await this.writeBuffer(toWriteBuffer(bytes), deadlineMs);
10827
+ }
10828
+ [WRITE_TRACKED_BORROWED](bytes, deadlineMs) {
10829
+ return this.writeTrackedBuffer(toWriteBuffer(bytes), deadlineMs);
10830
+ }
10831
+ async writeBuffer(buffer, deadlineMs) {
10832
+ try {
10833
+ await this.writeTrackedBuffer(buffer, deadlineMs).completed;
10834
+ } catch (err) {
10835
+ if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError) {
10836
+ throw err.cause ?? err;
10837
+ }
10838
+ throw err;
10839
+ }
10840
+ }
10841
+ writeTrackedBuffer(buffer, deadlineMs) {
10842
+ if (this.closedErr) {
10843
+ return {
10844
+ queued: false,
10845
+ completed: Promise.reject(new SocketWriteNotQueuedError("subc socket was closed before bytes could be queued", this.closedErr))
10846
+ };
10847
+ }
10848
+ let queued = false;
10849
+ let settled = false;
10850
+ let timer = null;
10851
+ const completed = new Promise((resolve3, reject) => {
10852
+ const settle = (run) => {
10853
+ if (settled)
10854
+ return;
10855
+ settled = true;
10856
+ if (timer)
10857
+ clearTimeout(timer);
10858
+ run();
10859
+ };
10860
+ const remaining = deadlineMs - Date.now();
10861
+ if (remaining <= 0) {
10862
+ settle(() => reject(new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", new SocketTimeoutError("timed out writing to subc"))));
10863
+ return;
10864
+ }
10865
+ timer = setTimeout(() => {
10866
+ const timeout = new SocketTimeoutError("timed out writing to subc");
10867
+ settle(() => reject(queued ? new SocketWriteQueuedError("timed out after bytes were handed to the subc socket", timeout) : new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", timeout)));
10868
+ }, remaining);
10869
+ try {
10870
+ this.sock.write(buffer, (err) => {
10871
+ settle(() => {
10872
+ if (err) {
10873
+ reject(new SocketWriteQueuedError("subc socket reported a write error after bytes were handed to the socket", err instanceof Error ? err : new Error(String(err))));
10874
+ } else {
10875
+ resolve3();
10876
+ }
10877
+ });
10878
+ });
10879
+ queued = true;
10880
+ } catch (err) {
10881
+ settle(() => reject(new SocketWriteNotQueuedError("subc socket write threw before bytes could be queued", err instanceof Error ? err : new Error(String(err)))));
10882
+ }
10883
+ });
10884
+ return { queued, completed };
10885
+ }
10886
+ close() {
10887
+ this.sock.destroy();
10888
+ }
10889
+ tryServe() {
10890
+ const w = this.waiter;
10891
+ if (!w)
10892
+ return;
10893
+ if (this.buffered >= w.need) {
10894
+ const out = this.take(w.need);
10895
+ this.waiter = null;
10896
+ if (w.timer)
10897
+ clearTimeout(w.timer);
10898
+ w.resolve(out);
10899
+ return;
10900
+ }
10901
+ if (this.closedErr) {
10902
+ this.waiter = null;
10903
+ if (w.timer)
10904
+ clearTimeout(w.timer);
10905
+ w.reject(this.closedErr);
10906
+ }
10907
+ }
10908
+ take(n) {
10909
+ const out = Buffer.allocUnsafe(n);
10910
+ let off = 0;
10911
+ while (off < n) {
10912
+ const head = this.chunks[0];
10913
+ const want = n - off;
10914
+ if (head.length <= want) {
10915
+ head.copy(out, off);
10916
+ off += head.length;
10917
+ this.chunks.shift();
10918
+ } else {
10919
+ head.copy(out, off, 0, want);
10920
+ this.chunks[0] = head.subarray(want);
10921
+ off += want;
10922
+ }
10923
+ }
10924
+ this.buffered -= n;
10925
+ return out;
10926
+ }
10927
+ }
10928
+
10929
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/auth.js
10930
+ var NONCE_LEN = 32;
10931
+ var MAX_AUTH_MESSAGE_LEN = 4096;
10932
+ var SERVER_PROOF_DOMAIN = "subc-server-v1";
10933
+ var CLIENT_AUTH_DOMAIN = "subc-client-v1";
10934
+ var DEFAULT_CLIENT_ROLE = "client";
10935
+
10936
+ class AuthError extends Error {
10937
+ }
10938
+ function computeProof(key, domain, clientNonce, serverNonce, daemonId) {
10939
+ const mac = createHmac("sha256", Buffer.from(key));
10940
+ mac.update(Buffer.from(domain, "utf8"));
10941
+ mac.update(Buffer.from(clientNonce));
10942
+ mac.update(Buffer.from(serverNonce));
10943
+ mac.update(Buffer.from(daemonId));
10944
+ return new Uint8Array(mac.digest());
10945
+ }
10946
+ function constantTimeEq(a, b) {
10947
+ if (a.length !== b.length)
10948
+ return false;
10949
+ return timingSafeEqual(Buffer.from(a), Buffer.from(b));
10950
+ }
10951
+ async function writeMessage(sock, value, deadlineMs) {
10952
+ const json = Buffer.from(JSON.stringify(value), "utf8");
10953
+ if (json.length > MAX_AUTH_MESSAGE_LEN) {
10954
+ throw new AuthError(`auth message too large: ${json.length} > ${MAX_AUTH_MESSAGE_LEN}`);
10955
+ }
10956
+ const lenPrefix = new Uint8Array(4);
10957
+ new DataView(lenPrefix.buffer).setUint32(0, json.length, true);
10958
+ await writeBorrowed(sock, lenPrefix, deadlineMs);
10959
+ await writeBorrowed(sock, json, deadlineMs);
10960
+ }
10961
+ async function readMessage(sock, deadlineMs) {
10962
+ const lenBytes = await sock.readExact(4, deadlineMs);
10963
+ const len = new DataView(lenBytes.buffer, lenBytes.byteOffset, 4).getUint32(0, true);
10964
+ if (len > MAX_AUTH_MESSAGE_LEN) {
10965
+ throw new AuthError(`auth message too large: ${len} > ${MAX_AUTH_MESSAGE_LEN}`);
10966
+ }
10967
+ const body = len === 0 ? new Uint8Array(0) : await sock.readExact(len, deadlineMs);
10968
+ try {
10969
+ return JSON.parse(Buffer.from(body).toString("utf8"));
10970
+ } catch (err) {
10971
+ throw new AuthError(`auth message JSON decode failed: ${String(err)}`);
10972
+ }
10973
+ }
10974
+ function authBytes(value, field) {
10975
+ if (!Array.isArray(value)) {
10976
+ throw new AuthError(`auth field '${field}' must be a byte array`);
10977
+ }
10978
+ for (const byte of value) {
10979
+ if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) {
10980
+ throw new AuthError(`auth field '${field}' has invalid byte ${String(byte)}`);
10981
+ }
10982
+ }
10983
+ return Uint8Array.from(value);
10984
+ }
10985
+ async function authenticateClient(sock, conn, deadlineMs) {
10986
+ const clientNonce = new Uint8Array(randomBytes(NONCE_LEN));
10987
+ await writeMessage(sock, { client_nonce: Array.from(clientNonce), role: DEFAULT_CLIENT_ROLE }, deadlineMs);
10988
+ const proof = await readMessage(sock, deadlineMs);
10989
+ const serverNonce = authBytes(proof.server_nonce, "server_nonce");
10990
+ const daemonId = authBytes(proof.daemon_id, "daemon_id");
10991
+ const serverProof = authBytes(proof.server_proof, "server_proof");
10992
+ const expected = computeProof(conn.key, SERVER_PROOF_DOMAIN, clientNonce, serverNonce, daemonId);
10993
+ if (!constantTimeEq(expected, serverProof)) {
10994
+ throw new AuthError("server proof mismatch — wrong key or impostor daemon");
10995
+ }
10996
+ if (!constantTimeEq(daemonId, conn.daemonId)) {
10997
+ throw new AuthError("daemon id mismatch — connection file points at a different daemon");
10998
+ }
10999
+ const clientAuth = computeProof(conn.key, CLIENT_AUTH_DOMAIN, clientNonce, serverNonce, daemonId);
11000
+ await writeMessage(sock, { client_auth: Array.from(clientAuth) }, deadlineMs);
11001
+ }
11002
+
11003
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/connection-file.js
11004
+ import { promises as fs2 } from "node:fs";
10704
11005
  var SCHEMA_VERSION = 1;
10705
11006
  var MIN_KEY_LEN = 32;
10706
11007
  var DAEMON_ID_LEN = 16;
@@ -10708,9 +11009,14 @@ var DAEMON_ID_LEN = 16;
10708
11009
  class ConnectionFileError extends Error {
10709
11010
  }
10710
11011
  function toBytes(value, field) {
10711
- if (!Array.isArray(value) || value.some((n) => typeof n !== "number")) {
11012
+ if (!Array.isArray(value)) {
10712
11013
  throw new ConnectionFileError(`connection file field '${field}' must be a JSON array of bytes`);
10713
11014
  }
11015
+ for (const byte of value) {
11016
+ if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) {
11017
+ throw new ConnectionFileError(`connection file field '${field}' has invalid byte ${String(byte)}`);
11018
+ }
11019
+ }
10714
11020
  return Uint8Array.from(value);
10715
11021
  }
10716
11022
  function validate(info) {
@@ -10772,7 +11078,7 @@ async function readConnectionFile(path2) {
10772
11078
  return info;
10773
11079
  }
10774
11080
 
10775
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/route-handle.js
11081
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/route-handle.js
10776
11082
  var connectionToken = new WeakMap;
10777
11083
 
10778
11084
  class RouteHandle {
@@ -10818,220 +11124,12 @@ function sameRouteHandle(left, right) {
10818
11124
  return left === right;
10819
11125
  }
10820
11126
 
10821
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/socket.js
10822
- import net from "node:net";
10823
- class SocketClosedError extends Error {
10824
- }
10825
-
10826
- class SocketTimeoutError extends Error {
10827
- }
10828
-
10829
- class SocketWriteNotQueuedError extends Error {
10830
- cause;
10831
- constructor(message, cause) {
10832
- super(message);
10833
- this.cause = cause;
10834
- }
10835
- }
10836
-
10837
- class SocketWriteQueuedError extends Error {
10838
- cause;
10839
- constructor(message, cause) {
10840
- super(message);
10841
- this.cause = cause;
10842
- }
10843
- }
10844
-
10845
- class SubcSocket {
10846
- sock;
10847
- chunks = [];
10848
- buffered = 0;
10849
- waiter = null;
10850
- closedErr = null;
10851
- bufferedBytes() {
10852
- return this.buffered;
10853
- }
10854
- constructor(sock) {
10855
- this.sock = sock;
10856
- sock.on("data", (chunk) => {
10857
- this.chunks.push(chunk);
10858
- this.buffered += chunk.length;
10859
- this.tryServe();
10860
- });
10861
- const fail = (err) => {
10862
- if (!this.closedErr)
10863
- this.closedErr = err;
10864
- this.tryServe();
10865
- };
10866
- sock.on("error", (err) => fail(err instanceof Error ? err : new Error(String(err))));
10867
- sock.on("end", () => fail(new SocketClosedError("subc closed the connection")));
10868
- sock.on("close", () => fail(new SocketClosedError("subc connection closed")));
10869
- }
10870
- localPort() {
10871
- return this.sock.localPort ?? null;
10872
- }
10873
- static connect(host, port, deadlineMs) {
10874
- return new Promise((resolve3, reject) => {
10875
- const sock = net.connect({ host, port });
10876
- sock.setNoDelay(true);
10877
- const timer = setTimeout(() => {
10878
- sock.destroy();
10879
- reject(new SocketTimeoutError(`timed out connecting to ${host}:${port}`));
10880
- }, Math.max(0, deadlineMs - Date.now()));
10881
- sock.once("connect", () => {
10882
- clearTimeout(timer);
10883
- resolve3(new SubcSocket(sock));
10884
- });
10885
- sock.once("error", (err) => {
10886
- clearTimeout(timer);
10887
- reject(err);
10888
- });
10889
- });
10890
- }
10891
- async readFrame(headerDeadlineMs, bodyDeadline, onHeader) {
10892
- const prefix = await this.readExact(FROZEN_PREFIX_LEN, headerDeadlineMs);
10893
- const version = prefix[4];
10894
- if (version !== PROTOCOL_VERSION)
10895
- throw new DecodeError(`unsupported envelope version ${version}`, "unsupported_version");
10896
- const remainder = await this.readExact(HEADER_LEN - FROZEN_PREFIX_LEN, headerDeadlineMs);
10897
- const headerBytes = new Uint8Array(HEADER_LEN);
10898
- headerBytes.set(prefix);
10899
- headerBytes.set(remainder, FROZEN_PREFIX_LEN);
10900
- const header = decodeHeader(headerBytes);
10901
- if (header.len > MAX_FRAME_BODY_LEN) {
10902
- throw new DecodeError(`frame body ${header.len} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10903
- }
10904
- onHeader?.();
10905
- const bodyDeadlineMs = typeof bodyDeadline === "number" ? bodyDeadline : Date.now() + bodyDeadline.afterHeaderMs;
10906
- const body = header.len === 0 ? new Uint8Array(0) : await this.readExact(header.len, bodyDeadlineMs);
10907
- return { header, body };
10908
- }
10909
- readExact(n, deadlineMs) {
10910
- if (this.waiter) {
10911
- return Promise.reject(new Error("concurrent readExact is not supported"));
10912
- }
10913
- if (n === 0)
10914
- return Promise.resolve(new Uint8Array(0));
10915
- return new Promise((resolve3, reject) => {
10916
- let timer = null;
10917
- if (Number.isFinite(deadlineMs)) {
10918
- const remaining = deadlineMs - Date.now();
10919
- if (remaining <= 0) {
10920
- reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10921
- return;
10922
- }
10923
- timer = setTimeout(() => {
10924
- this.waiter = null;
10925
- reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10926
- }, remaining);
10927
- }
10928
- this.waiter = { need: n, resolve: resolve3, reject, timer };
10929
- this.tryServe();
10930
- });
10931
- }
10932
- async write(bytes, deadlineMs) {
10933
- try {
10934
- await this.writeTracked(bytes, deadlineMs).completed;
10935
- } catch (err) {
10936
- if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError) {
10937
- throw err.cause ?? err;
10938
- }
10939
- throw err;
10940
- }
10941
- }
10942
- writeTracked(bytes, deadlineMs) {
10943
- if (this.closedErr) {
10944
- return {
10945
- queued: false,
10946
- completed: Promise.reject(new SocketWriteNotQueuedError("subc socket was closed before bytes could be queued", this.closedErr))
10947
- };
10948
- }
10949
- let queued = false;
10950
- let settled = false;
10951
- let timer = null;
10952
- const completed = new Promise((resolve3, reject) => {
10953
- const settle = (run) => {
10954
- if (settled)
10955
- return;
10956
- settled = true;
10957
- if (timer)
10958
- clearTimeout(timer);
10959
- run();
10960
- };
10961
- const remaining = deadlineMs - Date.now();
10962
- if (remaining <= 0) {
10963
- settle(() => reject(new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", new SocketTimeoutError("timed out writing to subc"))));
10964
- return;
10965
- }
10966
- timer = setTimeout(() => {
10967
- const timeout = new SocketTimeoutError("timed out writing to subc");
10968
- settle(() => reject(queued ? new SocketWriteQueuedError("timed out after bytes were handed to the subc socket", timeout) : new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", timeout)));
10969
- }, remaining);
10970
- try {
10971
- this.sock.write(Buffer.from(bytes), (err) => {
10972
- settle(() => {
10973
- if (err) {
10974
- reject(new SocketWriteQueuedError("subc socket reported a write error after bytes were handed to the socket", err instanceof Error ? err : new Error(String(err))));
10975
- } else {
10976
- resolve3();
10977
- }
10978
- });
10979
- });
10980
- queued = true;
10981
- } catch (err) {
10982
- settle(() => reject(new SocketWriteNotQueuedError("subc socket write threw before bytes could be queued", err instanceof Error ? err : new Error(String(err)))));
10983
- }
10984
- });
10985
- return { queued, completed };
10986
- }
10987
- close() {
10988
- this.sock.destroy();
10989
- }
10990
- tryServe() {
10991
- const w = this.waiter;
10992
- if (!w)
10993
- return;
10994
- if (this.buffered >= w.need) {
10995
- const out = this.take(w.need);
10996
- this.waiter = null;
10997
- if (w.timer)
10998
- clearTimeout(w.timer);
10999
- w.resolve(out);
11000
- return;
11001
- }
11002
- if (this.closedErr) {
11003
- this.waiter = null;
11004
- if (w.timer)
11005
- clearTimeout(w.timer);
11006
- w.reject(this.closedErr);
11007
- }
11008
- }
11009
- take(n) {
11010
- const out = Buffer.allocUnsafe(n);
11011
- let off = 0;
11012
- while (off < n) {
11013
- const head = this.chunks[0];
11014
- const want = n - off;
11015
- if (head.length <= want) {
11016
- head.copy(out, off);
11017
- off += head.length;
11018
- this.chunks.shift();
11019
- } else {
11020
- head.copy(out, off, 0, want);
11021
- this.chunks[0] = head.subarray(want);
11022
- off += want;
11023
- }
11024
- }
11025
- this.buffered -= n;
11026
- return out;
11027
- }
11028
- }
11029
-
11030
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/client.js
11127
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/client.js
11031
11128
  var debug = debuglog("subc-client");
11032
11129
  var DEFAULT_HANDSHAKE_TIMEOUT_MS = 1e4;
11033
11130
  var DEFAULT_REQUEST_TIMEOUT_MS = 30000;
11034
11131
  var TIMEOUT_ARBITRATION_GRACE_MS = 50;
11132
+ var LIVENESS_PROBE_WINDOW_MS = 2000;
11035
11133
  var REQUEST_DEADLINE_MARKER = "request_deadline";
11036
11134
  var DEADLINE_NO_DROP_CODE = "deadline_exceeded_no_drop_observed";
11037
11135
  var ROUTE_OPEN_RETRY_DEADLINE_MS = 30000;
@@ -11162,12 +11260,13 @@ class SubcClient {
11162
11260
  } catch (err) {
11163
11261
  if (!(err instanceof SubcCallError))
11164
11262
  throw this.terminalCallError("managed call failed", err);
11165
- if (err.code === "unknown_channel" && !retriedUnknownChannel && !this.closeStarted) {
11263
+ const deadBindCode = err.code === "unknown_channel" || err.code === "stale_route_epoch";
11264
+ if (deadBindCode && !retriedUnknownChannel && !this.closeStarted) {
11166
11265
  retriedUnknownChannel = true;
11167
11266
  this.evictRouteHandle(routeHandle);
11168
11267
  continue;
11169
11268
  }
11170
- if (err.code === "unknown_channel" && retriedUnknownChannel) {
11269
+ if (deadBindCode && retriedUnknownChannel) {
11171
11270
  this.evictRouteHandle(routeHandle);
11172
11271
  }
11173
11272
  if (err.kind === "not_sent") {
@@ -11180,6 +11279,8 @@ class SubcClient {
11180
11279
  }
11181
11280
  if (err.kind === "outcome_unknown" && err.code !== DEADLINE_NO_DROP_CODE) {
11182
11281
  this.scheduleReconnectAfterDrop(err);
11282
+ } else if (err.kind === "outcome_unknown" && err.code === DEADLINE_NO_DROP_CODE) {
11283
+ this.probeLivenessAfterDeadline();
11183
11284
  }
11184
11285
  throw err;
11185
11286
  }
@@ -11192,21 +11293,25 @@ class SubcClient {
11192
11293
  const admission = opts.admissionClass ?? AdmissionClass.Normal;
11193
11294
  const corr = this.allocateCorr();
11194
11295
  const key = pendingKey(handle, corr);
11296
+ let subscriptionPending = null;
11297
+ let resolveClosed = null;
11195
11298
  const closed = new Promise((resolve3, reject) => {
11196
11299
  if (this.closedErr) {
11197
11300
  reject(this.closedErr);
11198
11301
  return;
11199
11302
  }
11200
- this.pending.set(key, {
11303
+ resolveClosed = resolve3;
11304
+ subscriptionPending = {
11201
11305
  handle,
11202
11306
  resolve: () => resolve3(),
11203
11307
  reject,
11204
11308
  onProgress: onEvent,
11205
11309
  timer: null,
11206
11310
  subscription: true
11207
- });
11311
+ };
11312
+ this.pending.set(key, subscriptionPending);
11208
11313
  const frame = buildFrame(FrameType.Request, buildFlags(false, priority, false, admission), handle.channel, handle.epoch, corr, bytes);
11209
- this.sock.write(encodeFrame(frame), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch((err) => {
11314
+ writeBorrowed(this.sock, encodeFrame(frame), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch((err) => {
11210
11315
  const pending = this.pending.get(key);
11211
11316
  if (pending)
11212
11317
  this.rejectPending(key, pending, err instanceof Error ? err : new SubcError(String(err)));
@@ -11217,14 +11322,17 @@ class SubcClient {
11217
11322
  if (cancelled)
11218
11323
  return;
11219
11324
  cancelled = true;
11220
- this.cancel(handle, corr, priority);
11325
+ if (subscriptionPending && resolveClosed)
11326
+ this.settle(key, subscriptionPending, resolveClosed);
11327
+ if (this.isLiveHandle(handle))
11328
+ this.cancel(handle, corr, priority);
11221
11329
  };
11222
11330
  return { unsubscribe, closed };
11223
11331
  }
11224
11332
  cancel(handle, corr, priority = Priority.Interactive) {
11225
11333
  this.assertLiveHandle(handle);
11226
11334
  const cancel = buildFrame(FrameType.Cancel, buildFlags(false, priority, false), handle.channel, handle.epoch, corr, EMPTY_BODY);
11227
- this.sock.write(encodeFrame(cancel), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch(() => {
11335
+ writeBorrowed(this.sock, encodeFrame(cancel), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch(() => {
11228
11336
  return;
11229
11337
  });
11230
11338
  }
@@ -11305,7 +11413,7 @@ class SubcClient {
11305
11413
  return;
11306
11414
  }
11307
11415
  const goodbye = buildFrame(FrameType.Goodbye, buildFlags(false, Priority.Interactive, false), handle.channel, handle.epoch, 0n, EMPTY_BODY);
11308
- const write = this.sock.writeTracked(encodeFrame(goodbye), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS);
11416
+ const write = writeTrackedBorrowed(this.sock, encodeFrame(goodbye), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS);
11309
11417
  if (!write.queued && closeOnQueueFailure)
11310
11418
  this.closeConnectionAfterCleanupFailure();
11311
11419
  write.completed.catch(() => {
@@ -11357,7 +11465,7 @@ class SubcClient {
11357
11465
  };
11358
11466
  pending.timer = setTimeout(() => this.arbitrateTimeout(key, pending, channel, corr, ms), ms);
11359
11467
  this.pending.set(key, pending);
11360
- this.sock.write(encodeFrame(frame), Date.now() + ms).catch((error2) => {
11468
+ writeBorrowed(this.sock, encodeFrame(frame), Date.now() + ms).catch((error2) => {
11361
11469
  const current = this.pending.get(key);
11362
11470
  if (current)
11363
11471
  this.rejectPending(key, current, error2 instanceof Error ? error2 : new SubcError(String(error2)));
@@ -11434,7 +11542,7 @@ class SubcClient {
11434
11542
  };
11435
11543
  pending.timer = setTimeout(() => this.arbitrateTimeout(key, pending, handle.channel, corr, ms), ms);
11436
11544
  this.pending.set(key, pending);
11437
- const write = this.sock.writeTracked(encodeFrame(frame), Date.now() + ms);
11545
+ const write = writeTrackedBorrowed(this.sock, encodeFrame(frame), Date.now() + ms);
11438
11546
  handedToSocket = write.queued;
11439
11547
  write.completed.catch((error2) => {
11440
11548
  const current = this.pending.get(key);
@@ -11522,6 +11630,46 @@ class SubcClient {
11522
11630
  }
11523
11631
  }
11524
11632
  }
11633
+ lastInboundAtMs = 0;
11634
+ livenessProbe = null;
11635
+ hasControlPending() {
11636
+ for (const pending of this.pending.values()) {
11637
+ if (pending.handle === null)
11638
+ return true;
11639
+ }
11640
+ return false;
11641
+ }
11642
+ probeLivenessAfterDeadline() {
11643
+ if (this.livenessProbe || this.closeStarted || this.closedErr)
11644
+ return;
11645
+ if (this.hasControlPending())
11646
+ return;
11647
+ const sock = this.sock;
11648
+ const generation = this.generation;
11649
+ let corr;
11650
+ try {
11651
+ corr = this.allocateCorr();
11652
+ } catch {
11653
+ return;
11654
+ }
11655
+ const t0 = Date.now();
11656
+ const ping = buildFrame(FrameType.Ping, buildFlags(false, Priority.Interactive, false, AdmissionClass.Normal), 0, 0, corr, new Uint8Array);
11657
+ const probe = (async () => {
11658
+ await writeBorrowed(sock, encodeFrame(ping), t0 + this.opts.livenessProbeWindowMs).catch(() => {});
11659
+ await this.opts.sleep(this.opts.livenessProbeWindowMs);
11660
+ if (this.sock !== sock || this.generation !== generation || this.closeStarted)
11661
+ return;
11662
+ if (this.lastInboundAtMs >= t0)
11663
+ return;
11664
+ if (this.hasControlPending())
11665
+ return;
11666
+ this.fail(new SocketClosedError(`liveness probe convicted a half-open socket: no inbound frame for ${this.opts.livenessProbeWindowMs}ms after a channel-0 Ping (deadline-no-drop settles preceded this); closing so the next call reconnects`));
11667
+ sock.close();
11668
+ })().finally(() => {
11669
+ this.livenessProbe = null;
11670
+ });
11671
+ this.livenessProbe = probe;
11672
+ }
11525
11673
  async ensureConnectedForManaged() {
11526
11674
  if (this.closeStarted)
11527
11675
  throw new SubcError("client closed");
@@ -11633,6 +11781,24 @@ class SubcClient {
11633
11781
  }
11634
11782
  }
11635
11783
  dispatch(frame) {
11784
+ this.lastInboundAtMs = Date.now();
11785
+ if (frame.header.channel === 0 && frame.header.ty === FrameType.Push) {
11786
+ const observer = this.opts.onControlPush;
11787
+ if (observer) {
11788
+ let parsed = null;
11789
+ try {
11790
+ const body = this.parseJson(frame);
11791
+ if (body && typeof body.op === "string")
11792
+ parsed = { op: body.op, body };
11793
+ } catch {}
11794
+ if (parsed) {
11795
+ try {
11796
+ observer(parsed);
11797
+ } catch {}
11798
+ }
11799
+ }
11800
+ return;
11801
+ }
11636
11802
  let handle = null;
11637
11803
  if (frame.header.channel !== 0) {
11638
11804
  handle = this.liveRoutes.get(frame.header.channel) ?? null;
@@ -11649,7 +11815,9 @@ class SubcClient {
11649
11815
  switch (frame.header.ty) {
11650
11816
  case FrameType.Push:
11651
11817
  case FrameType.StreamData:
11652
- pending.onProgress?.(frame.body);
11818
+ try {
11819
+ pending.onProgress?.(frame.body);
11820
+ } catch {}
11653
11821
  return;
11654
11822
  case FrameType.Response:
11655
11823
  case FrameType.StreamEnd:
@@ -11669,7 +11837,7 @@ class SubcClient {
11669
11837
  return;
11670
11838
  }
11671
11839
  if (frame.header.ty === FrameType.Goodbye && handle) {
11672
- this.failHandle(handle, new SubcError("route closed by subc (GOODBYE)"));
11840
+ this.failHandle(handle, new SubcError("route closed by subc (GOODBYE)", "route_closed"));
11673
11841
  if (this.liveRoutes.get(handle.channel) === handle)
11674
11842
  this.liveRoutes.delete(handle.channel);
11675
11843
  this.evictRouteHandle(handle);
@@ -11776,10 +11944,11 @@ class SubcClient {
11776
11944
  this.scheduleReconnectAfterDrop(error2);
11777
11945
  }
11778
11946
  encode(value) {
11779
- return new Uint8Array(Buffer.from(JSON.stringify(value), "utf8"));
11947
+ return Buffer.from(JSON.stringify(value), "utf8");
11780
11948
  }
11781
11949
  parseJson(frame) {
11782
- return JSON.parse(Buffer.from(frame.body).toString("utf8"));
11950
+ const b = frame.body;
11951
+ return JSON.parse(Buffer.from(b.buffer, b.byteOffset, b.byteLength).toString("utf8"));
11783
11952
  }
11784
11953
  }
11785
11954
  function isConsumerReconnectTransient(err) {
@@ -11797,7 +11966,7 @@ function isConsumerReconnectTransient(err) {
11797
11966
  return code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPIPE" || code === "ETIMEDOUT" || code === "ENOENT";
11798
11967
  }
11799
11968
  function isRetryableRouteOpenCode(code) {
11800
- return code === "unknown_module" || code === "module_reloading" || code === "target_unavailable" || code === "module_timeout";
11969
+ return code === "unknown_module" || code === "module_reloading" || code === "module_warming" || code === "target_unavailable" || code === "module_timeout";
11801
11970
  }
11802
11971
  async function connectionFileExists(path2) {
11803
11972
  try {
@@ -11815,7 +11984,9 @@ function normalizeConnectOptions(opts) {
11815
11984
  targetKind: opts.targetKind ?? DEFAULT_MANAGED_TARGET_KIND,
11816
11985
  reconnectBackoff: opts.reconnectBackoff ?? DEFAULT_RECONNECT_BACKOFF,
11817
11986
  sleep: opts.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms))),
11818
- timeoutArbitrationGraceMs: opts.timeoutArbitrationGraceMs ?? TIMEOUT_ARBITRATION_GRACE_MS
11987
+ timeoutArbitrationGraceMs: opts.timeoutArbitrationGraceMs ?? TIMEOUT_ARBITRATION_GRACE_MS,
11988
+ livenessProbeWindowMs: opts.livenessProbeWindowMs ?? LIVENESS_PROBE_WINDOW_MS,
11989
+ onControlPush: opts.onControlPush
11819
11990
  };
11820
11991
  }
11821
11992
  function routeCacheKey(target, identity, consumerIdentity) {
@@ -11847,1071 +12018,221 @@ function causeMessage(cause) {
11847
12018
  function pendingKey(handle, corr) {
11848
12019
  return handle ? `${handle.channel}:${handle.epoch}:${corr}` : `0:0:${corr}`;
11849
12020
  }
11850
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/provider.js
11851
- import { Buffer as Buffer2 } from "node:buffer";
11852
- var DEFAULT_HANDSHAKE_TIMEOUT_MS2 = 1e4;
11853
- var BODY_READ_TIMEOUT_MS2 = 30000;
11854
- var WRITE_TIMEOUT_MS = 30000;
11855
- var DEFAULT_RESTORED_DEBOUNCE_MS = 250;
11856
- var DEFAULT_PROVIDER_HANDLER_CAPACITY = 64;
11857
- var HEALTH_CHECK_OP = "health.check";
11858
- var HELLO_CORR = 1n;
12021
+ // ../aft-bridge/dist/subc-transport.js
12022
+ import { existsSync as existsSync3, statSync as statSync3 } from "node:fs";
11859
12023
 
11860
- class AsyncPermitPool {
11861
- available;
11862
- waiters = [];
11863
- constructor(capacity) {
11864
- if (!Number.isInteger(capacity) || capacity <= 0) {
11865
- throw new SubcProviderError("provider handler capacity must be a positive integer", "invalid_handler_capacity");
11866
- }
11867
- this.available = capacity;
11868
- }
11869
- async acquire() {
11870
- if (this.available > 0) {
11871
- this.available -= 1;
11872
- return this.releaseOnce();
11873
- }
11874
- await new Promise((resolve3) => {
11875
- this.waiters.push(resolve3);
11876
- });
11877
- return this.releaseOnce();
11878
- }
11879
- releaseOnce() {
11880
- let released = false;
11881
- return () => {
11882
- if (released)
11883
- return;
11884
- released = true;
11885
- const next = this.waiters.shift();
11886
- if (next) {
11887
- next();
11888
- } else {
11889
- this.available += 1;
11890
- }
11891
- };
12024
+ // ../aft-bridge/dist/lifecycle-registry.js
12025
+ import { lstat } from "node:fs/promises";
12026
+ function asCanonicalRootPath(root) {
12027
+ return root;
12028
+ }
12029
+ function asRootGeneration(generation) {
12030
+ if (!Number.isSafeInteger(generation) || generation < 1) {
12031
+ throw new RangeError("root generations must be positive safe integers");
11892
12032
  }
12033
+ return generation;
11893
12034
  }
11894
-
11895
- class SubcProviderError extends Error {
11896
- code;
11897
- constructor(message, code) {
11898
- super(message);
11899
- this.code = code;
12035
+ function asConcretePoolId(id) {
12036
+ return id;
12037
+ }
12038
+ var DEFAULT_LIFECYCLE_INTERVAL_MS = 5 * 60 * 1000;
12039
+ var DEFAULT_REALM = "default";
12040
+ function rootKey(root) {
12041
+ return root;
12042
+ }
12043
+ function resultMeansPresent(result) {
12044
+ if (typeof result === "boolean")
12045
+ return result;
12046
+ if (typeof result === "object" && result !== null && "exists" in result) {
12047
+ return result.exists !== false;
11900
12048
  }
12049
+ return true;
11901
12050
  }
11902
- class SubcProvider {
11903
- sock;
11904
- currentConn;
11905
- opts;
11906
- closed;
11907
- resolveClosed = () => {
11908
- return;
12051
+ function isEnoent(error2) {
12052
+ return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
12053
+ }
12054
+ function closeCounts(result) {
12055
+ const teardown = typeof result === "object" && result !== null ? result : undefined;
12056
+ const sessions = teardown?.tornDownSessionCount;
12057
+ const facades = teardown?.tornDownFacadeCount;
12058
+ return {
12059
+ sessions: typeof sessions === "number" && Number.isFinite(sessions) ? Math.max(0, sessions) : 0,
12060
+ facades: typeof facades === "number" && Number.isFinite(facades) ? Math.max(0, facades) : 0
11909
12061
  };
11910
- closeStarted = false;
11911
- closedErr = null;
11912
- inflight = new Map;
11913
- pending = new Map;
11914
- liveRoutes = new Map;
11915
- connectionToken = newConnectionToken();
11916
- nextCorr = 1n;
11917
- ingressEpochDropCount = 0;
11918
- requestGate = new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY);
11919
- reconnecting = null;
11920
- generation = 1;
11921
- connectionEpoch = 1;
11922
- stateQueue = [];
11923
- drainingStateQueue = false;
11924
- restoredDebounceToken = 0;
11925
- storage;
11926
- constructor(sock, currentConn, opts, storage) {
11927
- this.sock = sock;
11928
- this.currentConn = currentConn;
11929
- this.opts = opts;
11930
- this.storage = storage;
11931
- this.closed = new Promise((resolve3) => {
11932
- this.resolveClosed = resolve3;
12062
+ }
12063
+ function defaultTimer() {
12064
+ return {
12065
+ setInterval(callback, delayMs) {
12066
+ const handle = setInterval(callback, delayMs);
12067
+ const maybeUnref = handle;
12068
+ maybeUnref.unref?.();
12069
+ return handle;
12070
+ },
12071
+ clearInterval(handle) {
12072
+ clearInterval(handle);
12073
+ }
12074
+ };
12075
+ }
12076
+
12077
+ class LifecycleRegistry {
12078
+ realm;
12079
+ intervalMs;
12080
+ registrations = new Map;
12081
+ registrationByPool = new WeakMap;
12082
+ nextGenerationByRoot = new Map;
12083
+ nextConcretePoolNumber = 1;
12084
+ nextRegistrationSequence = 1;
12085
+ timer;
12086
+ statRoot;
12087
+ demand;
12088
+ onEvent;
12089
+ intervalHandle = null;
12090
+ sweepInFlight = null;
12091
+ constructor(options = {}) {
12092
+ this.realm = options.realm ?? DEFAULT_REALM;
12093
+ this.intervalMs = options.intervalMs ?? DEFAULT_LIFECYCLE_INTERVAL_MS;
12094
+ if (!Number.isFinite(this.intervalMs) || this.intervalMs <= 0) {
12095
+ throw new RangeError("lifecycle interval must be a positive finite number");
12096
+ }
12097
+ const nativeTimer = defaultTimer();
12098
+ this.timer = options.timer ?? (options.setInterval || options.clearInterval ? {
12099
+ setInterval: options.setInterval ?? nativeTimer.setInterval,
12100
+ clearInterval: options.clearInterval ?? nativeTimer.clearInterval
12101
+ } : nativeTimer);
12102
+ this.statRoot = options.stat ?? ((root) => lstat(root));
12103
+ this.demand = options.demandCheck ?? (() => false);
12104
+ this.onEvent = options.onEvent;
12105
+ }
12106
+ registerLifecyclePool(pool, options) {
12107
+ if (!pool || typeof pool.closeProjectRoot !== "function") {
12108
+ throw new TypeError("a lifecycle pool must provide closeProjectRoot");
12109
+ }
12110
+ if (typeof options?.evictOuterFacade !== "function") {
12111
+ throw new TypeError("lifecycle registration requires evictOuterFacade");
12112
+ }
12113
+ if (typeof options.reapingEnabled !== "boolean") {
12114
+ throw new TypeError("reapingEnabled must be a boolean");
12115
+ }
12116
+ const previous = this.registrationByPool.get(pool);
12117
+ if (previous?.active)
12118
+ this.deregisterInternal(previous);
12119
+ const concretePoolId = asConcretePoolId(`pool-${this.nextConcretePoolNumber++}`);
12120
+ const registrationIdentity = Object.freeze({
12121
+ concretePoolId,
12122
+ registrationSequence: this.nextRegistrationSequence++
11933
12123
  });
11934
- this.readLoop(sock, this.generation);
11935
- this.enqueueConnectionState({ state: "connected", epoch: this.connectionEpoch });
12124
+ const internal = {
12125
+ pool,
12126
+ concretePoolId,
12127
+ registrationIdentity,
12128
+ reapingEnabled: options.reapingEnabled,
12129
+ evictOuterFacade: options.evictOuterFacade,
12130
+ roots: new Map,
12131
+ handle: undefined,
12132
+ active: true
12133
+ };
12134
+ const handle = {
12135
+ registrationIdentity,
12136
+ identity: registrationIdentity,
12137
+ get concretePoolId() {
12138
+ return concretePoolId;
12139
+ },
12140
+ get reapingEnabled() {
12141
+ return internal.reapingEnabled;
12142
+ },
12143
+ deregister: () => {
12144
+ this.deregisterInternal(internal);
12145
+ }
12146
+ };
12147
+ internal.handle = handle;
12148
+ this.registrations.set(concretePoolId, internal);
12149
+ this.registrationByPool.set(pool, internal);
12150
+ this.refreshTimer();
12151
+ return handle;
11936
12152
  }
11937
- get droppedIngressFrames() {
11938
- return this.ingressEpochDropCount;
12153
+ registerPool(pool, options) {
12154
+ return this.registerLifecyclePool(pool, options);
11939
12155
  }
11940
- get conn() {
11941
- return this.currentConn;
12156
+ registerRoot(poolId, root) {
12157
+ const registration = this.currentRegistration(poolId);
12158
+ if (!registration)
12159
+ throw new Error(`unknown lifecycle pool ${poolId}`);
12160
+ const key = rootKey(root);
12161
+ const existing = registration.roots.get(key);
12162
+ if (existing?.state === "live")
12163
+ return existing.generation;
12164
+ if (existing && !existing.synchronousPhaseComplete) {
12165
+ throw new Error("root registration raced its synchronous close phase");
12166
+ }
12167
+ const next = (this.nextGenerationByRoot.get(`${poolId}\x00${key}`) ?? 0) + 1;
12168
+ this.nextGenerationByRoot.set(`${poolId}\x00${key}`, next);
12169
+ const entry = {
12170
+ registration,
12171
+ canonicalRoot: root,
12172
+ generation: asRootGeneration(next),
12173
+ state: "live",
12174
+ consecutiveAbsences: 0,
12175
+ tombstoned: false,
12176
+ synchronousPhaseComplete: true,
12177
+ closePromise: null,
12178
+ eventEmitted: false,
12179
+ cause: null
12180
+ };
12181
+ registration.roots.set(key, entry);
12182
+ return entry.generation;
11942
12183
  }
11943
- currentEpoch() {
11944
- return this.connectionEpoch;
12184
+ currentGeneration(poolId, root) {
12185
+ return this.currentRoot(poolId, root)?.generation;
11945
12186
  }
11946
- async request(handle, body, opts = {}) {
11947
- this.assertLiveHandle(handle);
11948
- const corr = this.allocateCorr();
11949
- const key = routeKey(handle, corr);
11950
- const timeoutMs = opts.timeoutMs ?? WRITE_TIMEOUT_MS;
11951
- const frame = buildFrame(FrameType.Request, buildFlags(false, opts.priority ?? Priority.Interactive, false, opts.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, corr, body);
11952
- return await new Promise((resolve3, reject) => {
11953
- const timer = setTimeout(() => {
11954
- if (this.pending.delete(key))
11955
- reject(new SubcProviderError("reverse request timed out", "request_timeout"));
11956
- }, timeoutMs);
11957
- this.pending.set(key, {
11958
- resolve: (response) => resolve3(response.body),
11959
- reject,
11960
- timer
11961
- });
11962
- this.sendOn(this.sock, this.generation, frame).catch((error2) => {
11963
- const pending = this.pending.get(key);
11964
- if (!pending)
11965
- return;
11966
- this.pending.delete(key);
11967
- clearTimeout(pending.timer);
11968
- reject(error2 instanceof Error ? error2 : new SubcProviderError(String(error2)));
11969
- });
11970
- });
12187
+ isTombstoned(poolId, root, generation) {
12188
+ const entry = this.currentRoot(poolId, root);
12189
+ return entry?.generation === generation && entry.tombstoned;
11971
12190
  }
11972
- async push(handle, body, opts = {}) {
11973
- this.assertLiveHandle(handle);
11974
- await this.sendOn(this.sock, this.generation, buildFrame(FrameType.Push, buildFlags(false, opts.priority ?? Priority.Interactive, false, opts.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, 0n, body));
12191
+ isCurrentRegistration(identity) {
12192
+ const registration = this.registrations.get(identity.concretePoolId);
12193
+ return registration?.active === true && registration.registrationIdentity === identity;
11975
12194
  }
11976
- cancel(handle, corr) {
11977
- this.assertLiveHandle(handle);
11978
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Cancel, controlFlags(), handle.channel, handle.epoch, corr, new Uint8Array(0)));
12195
+ isCurrentLiveGeneration(poolId, root, generation) {
12196
+ const entry = this.currentRoot(poolId, root);
12197
+ return entry?.generation === generation && entry.state === "live";
11979
12198
  }
11980
- closeRoute(handle) {
11981
- this.assertLiveHandle(handle);
11982
- this.liveRoutes.delete(handle.channel);
11983
- this.abortHandle(handle);
11984
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Goodbye, controlFlags(), handle.channel, handle.epoch, 0n, new Uint8Array(0)));
12199
+ getRootSnapshot(poolId, root) {
12200
+ const entry = this.currentRoot(poolId, root);
12201
+ return entry ? this.snapshotRoot(entry) : undefined;
11985
12202
  }
11986
- static async connect(opts) {
11987
- if (opts.manifest.protocol_ver !== PROTOCOL_VERSION) {
11988
- throw new SubcProviderError(`manifest protocol_ver ${opts.manifest.protocol_ver} does not match client protocol ${PROTOCOL_VERSION}`, "invalid_manifest");
11989
- }
11990
- const normalized = normalizeProviderConnectOptions(opts);
11991
- const opened = await SubcProvider.openConnection(normalized);
11992
- return new SubcProvider(opened.sock, opened.conn, normalized, opened.ack.storage);
11993
- }
11994
- async close() {
11995
- if (!this.closeStarted) {
11996
- this.closeStarted = true;
11997
- this.cancelRestoredDebounce();
11998
- const sock = this.sock;
11999
- try {
12000
- await sendFrame(sock, buildFrame(FrameType.Goodbye, controlFlags(), 0, 0, 0n, new Uint8Array(0)));
12001
- } catch {} finally {
12002
- sock.close();
12003
- this.finishClosed();
12004
- }
12005
- }
12006
- await this.closed;
12203
+ rootSnapshots(poolId) {
12204
+ const entries = poolId ? [this.currentRegistration(poolId)].filter((registration) => registration != null) : [...this.registrations.values()];
12205
+ return entries.flatMap((registration) => [...registration.roots.values()].map((entry) => this.snapshotRoot(entry)));
12007
12206
  }
12008
- static async openConnection(opts, onSocket) {
12009
- const conn = await readConnectionFile(opts.connectionFile);
12010
- const deadline = Date.now() + (opts.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS2);
12011
- const endpoint = conn.endpoints[0];
12012
- const sock = await SubcSocket.connect(endpoint.host, endpoint.port, deadline);
12013
- try {
12014
- onSocket?.(sock);
12015
- await authenticateClient(sock, conn, deadline);
12016
- await sendFrame(sock, buildHelloFrame(opts));
12017
- const ack = await expectHelloAck(sock, deadline);
12018
- return { sock, conn, ack };
12019
- } catch (err) {
12020
- sock.close();
12021
- throw err;
12022
- }
12207
+ snapshot() {
12208
+ return {
12209
+ realm: this.realm,
12210
+ intervalMs: this.intervalMs,
12211
+ timerActive: this.intervalHandle !== null,
12212
+ registrations: [...this.registrations.values()].map((registration) => ({
12213
+ concretePoolId: registration.concretePoolId,
12214
+ reapingEnabled: registration.reapingEnabled,
12215
+ roots: [...registration.roots.values()].map((entry) => this.snapshotRoot(entry))
12216
+ }))
12217
+ };
12023
12218
  }
12024
- async readLoop(sock, generation) {
12219
+ status() {
12220
+ return this.snapshot();
12221
+ }
12222
+ async ensureRootForDemand(poolId, root) {
12223
+ const registration = this.currentRegistration(poolId);
12224
+ if (!registration)
12225
+ return;
12226
+ const existing = registration.roots.get(rootKey(root));
12227
+ if (existing?.state === "live")
12228
+ return existing.generation;
12229
+ if (existing && !existing.synchronousPhaseComplete)
12230
+ return;
12231
+ let result;
12025
12232
  try {
12026
- for (;; ) {
12027
- const frame = await sock.readFrame(Number.POSITIVE_INFINITY, { afterHeaderMs: BODY_READ_TIMEOUT_MS2 });
12028
- const keepGoing = await this.dispatch(frame, sock, generation);
12029
- if (!keepGoing) {
12030
- if (this.sock === sock && this.generation === generation)
12031
- this.closeStarted = true;
12032
- break;
12033
- }
12034
- }
12035
- } catch (error2) {
12036
- if (this.sock === sock && this.generation === generation && !this.closeStarted) {
12037
- this.handleUnexpectedDrop(sock, generation, error2 instanceof Error ? error2 : new SubcProviderError(String(error2)));
12038
- return;
12039
- }
12040
- } finally {
12041
- if (this.sock === sock && this.generation === generation) {
12042
- sock.close();
12043
- if (this.closeStarted)
12044
- this.finishClosed();
12045
- }
12046
- }
12047
- }
12048
- async dispatch(frame, sock, generation) {
12049
- let handle = null;
12050
- if (frame.header.channel !== 0) {
12051
- handle = this.liveRoutes.get(frame.header.channel) ?? null;
12052
- if (!handle || handle.epoch !== frame.header.epoch) {
12053
- this.ingressEpochDropCount += 1;
12054
- return true;
12055
- }
12056
- }
12057
- if (handle) {
12058
- const pendingKey2 = routeKey(handle, frame.header.corr);
12059
- const pending = this.pending.get(pendingKey2);
12060
- if (pending) {
12061
- if (frame.header.ty === FrameType.Push || frame.header.ty === FrameType.StreamData)
12062
- return true;
12063
- if (frame.header.ty === FrameType.Response || frame.header.ty === FrameType.StreamEnd) {
12064
- this.pending.delete(pendingKey2);
12065
- clearTimeout(pending.timer);
12066
- pending.resolve(frame);
12067
- return true;
12068
- }
12069
- if (frame.header.ty === FrameType.Error) {
12070
- this.pending.delete(pendingKey2);
12071
- clearTimeout(pending.timer);
12072
- pending.reject(providerErrorFromFrame(frame));
12073
- return true;
12074
- }
12075
- }
12076
- }
12077
- switch (frame.header.ty) {
12078
- case FrameType.Ping:
12079
- if (frame.header.channel === 0) {
12080
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Pong, frame.header.flags, 0, 0, frame.header.corr, new Uint8Array(0)));
12081
- }
12082
- return true;
12083
- case FrameType.Goodbye:
12084
- if (!handle)
12085
- return false;
12086
- this.liveRoutes.delete(handle.channel);
12087
- this.abortHandle(handle);
12088
- await this.opts.onRouteGone?.(handle);
12089
- return true;
12090
- case FrameType.Cancel:
12091
- if (handle)
12092
- this.inflight.get(routeKey(handle, frame.header.corr))?.abort();
12093
- return true;
12094
- case FrameType.Request:
12095
- if (frame.header.channel === 0) {
12096
- await this.handleControlRequest(frame, sock, generation);
12097
- } else if (handle) {
12098
- this.handleDataRequest(frame, handle, sock, generation).catch((error2) => {
12099
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
12100
- console.warn("SubcProvider handler failed after its request was dispatched", error2);
12101
- }
12102
- });
12103
- }
12104
- return true;
12105
- default:
12106
- return true;
12107
- }
12108
- }
12109
- abortHandle(handle) {
12110
- const prefix = `${handle.channel}:${handle.epoch}:`;
12111
- for (const [key, controller] of this.inflight) {
12112
- if (key.startsWith(prefix))
12113
- controller.abort();
12114
- }
12115
- for (const [key, pending] of this.pending) {
12116
- if (!key.startsWith(prefix))
12117
- continue;
12118
- this.pending.delete(key);
12119
- clearTimeout(pending.timer);
12120
- pending.reject(new StaleRouteHandleError(handle));
12121
- }
12122
- }
12123
- abortGeneration(_generation) {
12124
- this.abortAllInflight();
12125
- for (const [key, pending] of this.pending) {
12126
- this.pending.delete(key);
12127
- clearTimeout(pending.timer);
12128
- pending.reject(new SubcProviderError("provider connection dropped", "connection_dropped"));
12129
- }
12130
- this.liveRoutes.clear();
12131
- }
12132
- abortAllInflight() {
12133
- for (const controller of this.inflight.values())
12134
- controller.abort();
12135
- }
12136
- async handleControlRequest(frame, sock, generation) {
12137
- const request = parseJson(frame.body);
12138
- if (request.op === HEALTH_CHECK_OP) {
12139
- this.handleHealthRequest(frame, sock, generation).catch((error2) => {
12140
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
12141
- console.warn("SubcProvider health handler failed after its request was dispatched", error2);
12142
- }
12143
- });
12144
- return;
12145
- }
12146
- if (request.op !== "route.bind") {
12147
- throw new SubcProviderError(`unsupported module control request ${request.op ?? "<missing op>"}`);
12148
- }
12149
- const boundChannel = numberField(request.route_channel, "route_channel");
12150
- const boundEpoch = numberField(request.epoch, "epoch");
12151
- const stale = this.liveRoutes.get(boundChannel);
12152
- if (stale) {
12153
- if (boundEpoch <= stale.epoch) {
12154
- await this.sendError(frame, "route_rejected", `route.bind epoch ${boundEpoch} does not supersede installed epoch ${stale.epoch} on channel ${boundChannel}`, controlFlags(), sock, generation);
12155
- return;
12156
- }
12157
- this.liveRoutes.delete(stale.channel);
12158
- this.abortHandle(stale);
12159
- await this.opts.onRouteGone?.(stale);
12160
- }
12161
- const tentative = createRouteHandle(boundChannel, boundEpoch, this.connectionToken);
12162
- const bindRequest = {
12163
- handle: tentative,
12164
- target: request.target,
12165
- identity: request.identity,
12166
- principal: request.principal,
12167
- consumer_capabilities: request.consumer_capabilities
12168
- };
12169
- let decision;
12170
- try {
12171
- decision = await this.opts.onBind?.(bindRequest);
12172
- } catch (error2) {
12173
- try {
12174
- await this.sendError(frame, "route_rejected", error2 instanceof Error ? error2.message : String(error2), controlFlags(), sock, generation);
12175
- } finally {
12176
- await this.opts.onRouteGone?.(tentative);
12177
- }
12178
- return;
12179
- }
12180
- const rejection = bindRejection(decision);
12181
- if (rejection) {
12182
- try {
12183
- await this.sendError(frame, rejection.code, rejection.message, controlFlags(), sock, generation);
12184
- } finally {
12185
- await this.opts.onRouteGone?.(tentative);
12186
- }
12187
- return;
12188
- }
12189
- try {
12190
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Response, controlFlags(), 0, 0, frame.header.corr, encodeJson({ op: "route.bind" })));
12191
- } catch (error2) {
12192
- await this.opts.onRouteGone?.(tentative);
12193
- throw error2;
12194
- }
12195
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr) {
12196
- await this.opts.onRouteGone?.(tentative);
12197
- return;
12198
- }
12199
- this.liveRoutes.set(tentative.channel, tentative);
12200
- await this.opts.onBound?.(tentative);
12201
- }
12202
- async handleDataRequest(frame, handle, sock, generation) {
12203
- const { corr, ver } = frame.header;
12204
- const key = routeKey(handle, corr);
12205
- const controller = new AbortController;
12206
- this.inflight.set(key, controller);
12207
- const context = {
12208
- handle,
12209
- signal: controller.signal,
12210
- currentEpoch: () => this.connectionEpoch,
12211
- emit: async (eventBody, options = {}) => {
12212
- this.assertLiveHandle(handle);
12213
- if (controller.signal.aborted)
12214
- return;
12215
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.StreamData, buildFlags(false, options.priority ?? Priority.Interactive, false, options.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, corr, eventBody));
12216
- }
12217
- };
12218
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
12219
- const dataFlags = buildFlags(false, Priority.Interactive, false);
12220
- try {
12221
- const body = await this.opts.handler(handle, frame.body, context);
12222
- if (controller.signal.aborted)
12223
- return;
12224
- this.assertLiveHandle(handle);
12225
- if (body === undefined) {
12226
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.StreamEnd, dataFlags, handle.channel, handle.epoch, corr, new Uint8Array(0)));
12227
- } else if (body instanceof Uint8Array) {
12228
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, dataFlags, handle.channel, handle.epoch, corr, body));
12229
- } else {
12230
- throw new SubcProviderError("provider handler must return a Uint8Array or void", "invalid_handler_response");
12231
- }
12232
- } catch (error2) {
12233
- if (error2 instanceof StaleRouteHandleError || controller.signal.aborted)
12234
- return;
12235
- await this.sendError(frame, error2 instanceof SubcProviderError && error2.code ? error2.code : "handler_error", error2 instanceof Error ? error2.message : String(error2), dataFlags, sock, generation);
12236
- } finally {
12237
- releasePermit();
12238
- if (this.inflight.get(key) === controller)
12239
- this.inflight.delete(key);
12240
- }
12241
- }
12242
- async handleHealthRequest(frame, sock, generation) {
12243
- const { corr, ver } = frame.header;
12244
- const key = `control:${generation}:${corr}`;
12245
- const controller = new AbortController;
12246
- this.inflight.set(key, controller);
12247
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
12248
- try {
12249
- if (controller.signal.aborted)
12250
- return;
12251
- const report = await this.opts.health();
12252
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, controlFlags(), 0, 0, corr, encodeJson({
12253
- op: HEALTH_CHECK_OP,
12254
- status: report.status,
12255
- ...report.detail === undefined ? {} : { detail: report.detail },
12256
- ...report.metrics === undefined ? {} : { metrics: report.metrics }
12257
- })));
12258
- } catch (error2) {
12259
- await this.sendError(frame, error2 instanceof SubcProviderError && error2.code ? error2.code : "health_error", error2 instanceof Error ? error2.message : String(error2), controlFlags(), sock, generation);
12260
- } finally {
12261
- releasePermit();
12262
- if (this.inflight.get(key) === controller)
12263
- this.inflight.delete(key);
12264
- }
12265
- }
12266
- async sendError(frame, code, message, flags, sock, generation) {
12267
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Error, flags, frame.header.channel, frame.header.epoch, frame.header.corr, encodeJson({ code, message })));
12268
- }
12269
- async sendOn(sock, generation, frame) {
12270
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr)
12271
- return;
12272
- await sendFrame(sock, frame);
12273
- }
12274
- handleUnexpectedDrop(sock, generation, cause) {
12275
- if (this.closeStarted || this.sock !== sock || this.generation !== generation)
12276
- return;
12277
- this.cancelRestoredDebounce();
12278
- this.abortGeneration(generation);
12279
- this.generation += 1;
12280
- sock.close();
12281
- this.scheduleReconnectAfterDrop(cause, this.generation, sock);
12282
- }
12283
- scheduleReconnectAfterDrop(cause, generation, droppedSocket) {
12284
- if (this.closeStarted)
12285
- return;
12286
- const previous = this.reconnecting;
12287
- if (previous) {
12288
- if (!this.shouldSupersedeReconnect(previous, generation, droppedSocket))
12289
- return;
12290
- previous.superseded = true;
12291
- previous.socket?.close();
12292
- }
12293
- const cycle = {
12294
- generation,
12295
- socket: null,
12296
- socketDied: false,
12297
- superseded: false
12298
- };
12299
- this.reconnecting = cycle;
12300
- this.enqueueConnectionState({ state: "down", cause });
12301
- this.reconnectWithRetry(cycle).catch((err) => {
12302
- if (this.isCurrentReconnect(cycle) && !this.closeStarted) {
12303
- this.failFatal(err instanceof Error ? err : new SubcProviderError(String(err)));
12304
- }
12305
- }).finally(() => {
12306
- if (this.isCurrentReconnect(cycle))
12307
- this.reconnecting = null;
12308
- });
12309
- }
12310
- async reconnectWithRetry(cycle) {
12311
- let attempt = 0;
12312
- let delay = this.opts.reconnectBackoff.baseMs;
12313
- for (;; ) {
12314
- if (!this.isCurrentReconnect(cycle))
12315
- return;
12316
- if (this.closeStarted)
12317
- throw new SubcProviderError("provider closed");
12318
- cycle.socket = null;
12319
- cycle.socketDied = false;
12320
- attempt += 1;
12321
- this.enqueueReconnectState(cycle, attempt);
12322
- try {
12323
- const opened = await SubcProvider.openConnection(this.opts, (sock) => {
12324
- if (!this.isCurrentReconnect(cycle)) {
12325
- sock.close();
12326
- return;
12327
- }
12328
- cycle.socket = sock;
12329
- });
12330
- if (!this.isCurrentReconnect(cycle) || this.closeStarted) {
12331
- opened.sock.close();
12332
- if (this.closeStarted)
12333
- throw new SubcProviderError("provider closed");
12334
- return;
12335
- }
12336
- const epoch = this.replaceConnection(opened, cycle.generation);
12337
- this.reconnecting = null;
12338
- if (this.reconnecting !== null) {
12339
- throw new SubcProviderError("reconnect state must clear before restored", "reconnect_state");
12340
- }
12341
- this.scheduleRestored(cycle.generation, epoch);
12342
- return;
12343
- } catch (err) {
12344
- if (!this.isCurrentReconnect(cycle))
12345
- return;
12346
- if (cycle.socket)
12347
- cycle.socketDied = true;
12348
- if (this.closeStarted)
12349
- throw err;
12350
- if (!isProviderReconnectTransient(err))
12351
- throw err;
12352
- await this.opts.sleep(delay);
12353
- delay = Math.min(delay * 2, this.opts.reconnectBackoff.capMs);
12354
- }
12355
- }
12356
- }
12357
- isCurrentReconnect(cycle) {
12358
- return !cycle.superseded && this.reconnecting === cycle && this.generation === cycle.generation;
12359
- }
12360
- shouldSupersedeReconnect(cycle, generation, droppedSocket) {
12361
- return cycle.generation < generation || cycle.socketDied || cycle.socket === droppedSocket;
12362
- }
12363
- enqueueReconnectState(cycle, attempt) {
12364
- if (!this.isCurrentReconnect(cycle))
12365
- return;
12366
- this.enqueueConnectionState({ state: "reconnecting", attempt }, cycle.generation, cycle);
12367
- }
12368
- replaceConnection(opened, generation) {
12369
- this.sock.close();
12370
- this.sock = opened.sock;
12371
- this.currentConn = opened.conn;
12372
- this.storage = opened.ack.storage;
12373
- this.closedErr = null;
12374
- this.connectionEpoch += 1;
12375
- this.connectionToken = newConnectionToken();
12376
- this.liveRoutes.clear();
12377
- this.nextCorr = 1n;
12378
- this.readLoop(opened.sock, generation);
12379
- return this.connectionEpoch;
12380
- }
12381
- scheduleRestored(generation, epoch) {
12382
- if (!this.opts.onConnectionState)
12383
- return;
12384
- const token = ++this.restoredDebounceToken;
12385
- this.opts.sleep(this.opts.restoredDebounceMs).then(() => {
12386
- if (token === this.restoredDebounceToken && !this.closeStarted && this.sock && this.generation === generation && this.connectionEpoch === epoch) {
12387
- this.enqueueConnectionState({ state: "restored", epoch }, generation);
12388
- }
12389
- }).catch((err) => {
12390
- if (token === this.restoredDebounceToken && !this.closeStarted) {
12391
- console.warn("SubcProvider restored debounce timer failed", err);
12392
- }
12393
- });
12394
- }
12395
- cancelRestoredDebounce() {
12396
- this.restoredDebounceToken += 1;
12397
- }
12398
- enqueueConnectionState(event, generation, reconnect) {
12399
- if (!this.opts.onConnectionState)
12400
- return;
12401
- this.stateQueue.push({ event, generation, reconnect });
12402
- if (!this.drainingStateQueue)
12403
- this.drainConnectionStateQueue();
12404
- }
12405
- async drainConnectionStateQueue() {
12406
- if (this.drainingStateQueue)
12407
- return;
12408
- this.drainingStateQueue = true;
12409
- try {
12410
- while (this.stateQueue.length > 0) {
12411
- const queued = this.stateQueue[0];
12412
- if (this.closeStarted || queued.generation !== undefined && queued.generation !== this.generation || queued.reconnect?.superseded) {
12413
- this.stateQueue.shift();
12414
- continue;
12415
- }
12416
- const { event } = queued;
12417
- try {
12418
- await this.opts.onConnectionState?.(event);
12419
- this.stateQueue.shift();
12420
- } catch (err) {
12421
- if (event.state === "restored") {
12422
- console.warn("SubcProvider restored callback failed; retrying delivery", err);
12423
- await pauseBeforeStateRetry();
12424
- continue;
12425
- }
12426
- console.warn("SubcProvider connection-state callback failed", err);
12427
- this.stateQueue.shift();
12428
- }
12429
- }
12430
- } finally {
12431
- this.drainingStateQueue = false;
12432
- if (this.stateQueue.length > 0)
12433
- this.drainConnectionStateQueue();
12434
- }
12435
- }
12436
- isLiveHandle(handle) {
12437
- return belongsToConnection(handle, this.connectionToken) && this.liveRoutes.get(handle.channel) === handle;
12438
- }
12439
- assertLiveHandle(handle) {
12440
- if (!this.isLiveHandle(handle))
12441
- throw new StaleRouteHandleError(handle);
12442
- }
12443
- allocateCorr() {
12444
- const maximum = 0xffffffffffffffffn;
12445
- if (this.nextCorr > maximum) {
12446
- const error2 = new SubcProviderError("channel-0 correlation id allocator exhausted", "corr_exhausted");
12447
- this.handleUnexpectedDrop(this.sock, this.generation, error2);
12448
- throw error2;
12449
- }
12450
- const corr = this.nextCorr;
12451
- this.nextCorr += 1n;
12452
- return corr;
12453
- }
12454
- failFatal(err) {
12455
- if (!this.closedErr)
12456
- this.closedErr = err;
12457
- this.closeStarted = true;
12458
- this.cancelRestoredDebounce();
12459
- this.abortAllInflight();
12460
- this.sock.close();
12461
- this.finishClosed();
12462
- }
12463
- finishClosed() {
12464
- this.resolveClosed();
12465
- }
12466
- }
12467
- function routeKey(handle, corr) {
12468
- return `${handle.channel}:${handle.epoch}:${corr}`;
12469
- }
12470
- function providerErrorFromFrame(frame) {
12471
- try {
12472
- const body = parseJson(frame.body);
12473
- return new SubcProviderError(body.message ?? "subc error", body.code);
12474
- } catch {
12475
- return new SubcProviderError(Buffer2.from(frame.body).toString("utf8") || "subc error");
12476
- }
12477
- }
12478
- function launchNonce(opts) {
12479
- const nonce = opts.launchNonce ?? process.env[SUBC_LAUNCH_NONCE_ENV2];
12480
- return nonce && nonce.length > 0 ? nonce : undefined;
12481
- }
12482
- var SUBC_LAUNCH_NONCE_ENV2 = "SUBC_LAUNCH_NONCE";
12483
- function normalizeProviderConnectOptions(opts) {
12484
- return {
12485
- connectionFile: opts.connectionFile,
12486
- manifest: opts.manifest,
12487
- handler: opts.handler,
12488
- health: opts.health ?? (() => ({ status: "ok" })),
12489
- handshakeTimeoutMs: opts.handshakeTimeoutMs,
12490
- controlOps: opts.controlOps,
12491
- onBind: opts.onBind,
12492
- onBound: opts.onBound,
12493
- onRouteGone: opts.onRouteGone,
12494
- reconnectBackoff: opts.reconnectBackoff ?? DEFAULT_RECONNECT_BACKOFF,
12495
- sleep: opts.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms))),
12496
- restoredDebounceMs: opts.restoredDebounceMs ?? DEFAULT_RESTORED_DEBOUNCE_MS,
12497
- onConnectionState: opts.onConnectionState,
12498
- launchNonce: opts.launchNonce
12499
- };
12500
- }
12501
- function normalizedControlOps(controlOps) {
12502
- if (controlOps === null)
12503
- return null;
12504
- const merged = new Set(controlOps ?? []);
12505
- merged.add(HEALTH_CHECK_OP);
12506
- return [...merged];
12507
- }
12508
- function buildHelloFrame(opts) {
12509
- const nonce = launchNonce(opts);
12510
- return buildFrame(FrameType.Hello, controlFlags(), 0, 0, HELLO_CORR, encodeJson({
12511
- manifest: normalizeManifest(opts.manifest),
12512
- protocol_ver: PROTOCOL_VERSION,
12513
- control_ops: normalizedControlOps(opts.controlOps),
12514
- ...nonce ? { launch_nonce: nonce } : {}
12515
- }));
12516
- }
12517
- function isProviderReconnectTransient(err) {
12518
- if (err instanceof SubcProviderError)
12519
- return err.code === "duplicate_module_id";
12520
- if (err instanceof SocketClosedError || err instanceof SocketTimeoutError)
12521
- return true;
12522
- if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError)
12523
- return true;
12524
- if (err instanceof AuthError)
12525
- return true;
12526
- if (err instanceof ConnectionFileError)
12527
- return false;
12528
- const code = errorCode2(err);
12529
- return code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPIPE" || code === "ETIMEDOUT" || code === "ENOENT";
12530
- }
12531
- function errorCode2(err) {
12532
- if (typeof err === "object" && err !== null && "code" in err) {
12533
- const code = err.code;
12534
- if (typeof code === "string")
12535
- return code;
12536
- }
12537
- return;
12538
- }
12539
- async function pauseBeforeStateRetry() {
12540
- await new Promise((resolve3) => setTimeout(resolve3, 0));
12541
- }
12542
- function controlFlags() {
12543
- return buildFlags(false, Priority.Passive, false);
12544
- }
12545
- async function sendFrame(sock, frame) {
12546
- await sock.write(encodeFrame(frame), Date.now() + WRITE_TIMEOUT_MS);
12547
- }
12548
- async function expectHelloAck(sock, deadline) {
12549
- const frame = await sock.readFrame(deadline, deadline);
12550
- switch (frame.header.ty) {
12551
- case FrameType.HelloAck: {
12552
- const ack = parseJson(frame.body);
12553
- if (ack.negotiated_ver !== PROTOCOL_VERSION) {
12554
- throw new SubcProviderError(`subc negotiated protocol ${ack.negotiated_ver}; expected exactly ${PROTOCOL_VERSION}`, "unsupported_version");
12555
- }
12556
- return ack;
12557
- }
12558
- case FrameType.Error: {
12559
- const error2 = parseJson(frame.body);
12560
- throw new SubcProviderError(`subc rejected HELLO: ${error2.code ?? "unknown"} — ${error2.message ?? "subc error"}`, error2.code);
12561
- }
12562
- default:
12563
- throw new SubcProviderError(`unexpected frame ${FrameType[frame.header.ty]} awaiting HELLO_ACK`);
12564
- }
12565
- }
12566
- function encodeJson(value) {
12567
- return new Uint8Array(Buffer2.from(JSON.stringify(value), "utf8"));
12568
- }
12569
- function parseJson(bytes) {
12570
- return JSON.parse(Buffer2.from(bytes).toString("utf8"));
12571
- }
12572
- function numberField(value, field) {
12573
- if (typeof value !== "number" || !Number.isInteger(value)) {
12574
- throw new SubcProviderError(`route.bind ${field} must be an integer`);
12575
- }
12576
- return value;
12577
- }
12578
- function bindRejection(decision) {
12579
- if (decision === undefined || decision === true)
12580
- return null;
12581
- if (decision === false) {
12582
- return { code: "route_rejected", message: "route.bind rejected by provider" };
12583
- }
12584
- if (decision.accept)
12585
- return null;
12586
- return {
12587
- code: decision.code ?? "route_rejected",
12588
- message: decision.message ?? "route.bind rejected by provider"
12589
- };
12590
- }
12591
- function normalizeManifest(manifest) {
12592
- return {
12593
- module_id: manifest.module_id,
12594
- module_version: manifest.module_version,
12595
- protocol_ver: manifest.protocol_ver,
12596
- trust_tier: manifest.trust_tier,
12597
- provides: manifest.provides.map(normalizeProviderRole),
12598
- consumes: manifest.consumes.map(normalizeConsumerRole),
12599
- scheduled_tasks: manifest.scheduled_tasks.map(normalizeScheduledTask),
12600
- bindings: {
12601
- storage: {
12602
- kind: manifest.bindings.storage.kind,
12603
- scope: manifest.bindings.storage.scope,
12604
- owns_schema: manifest.bindings.storage.owns_schema
12605
- },
12606
- vault_grants: manifest.bindings.vault_grants.map((grant) => ({
12607
- secret: grant.secret,
12608
- reason: grant.reason
12609
- })),
12610
- identity: {
12611
- requires: [...manifest.bindings.identity.requires],
12612
- optional: [...manifest.bindings.identity.optional]
12613
- }
12614
- }
12615
- };
12616
- }
12617
- function normalizeProviderRole(role) {
12618
- switch (role.role) {
12619
- case "tool_provider":
12620
- return {
12621
- role: "tool_provider",
12622
- tools: role.tools.map((tool) => ({
12623
- name: tool.name,
12624
- ...tool.description === undefined ? {} : { description: tool.description },
12625
- execution_mode: tool.execution_mode,
12626
- schema: tool.schema
12627
- })),
12628
- identity_scope: [...role.identity_scope],
12629
- concurrency: role.concurrency,
12630
- emits_push: role.emits_push,
12631
- sub_supervises: role.sub_supervises
12632
- };
12633
- case "pipeline_stage":
12634
- return {
12635
- role: "pipeline_stage",
12636
- stage: role.stage,
12637
- applies_to: {
12638
- provider: role.applies_to.provider,
12639
- model: role.applies_to.model
12640
- },
12641
- interface: role.interface,
12642
- declares_frozen_floor: role.declares_frozen_floor,
12643
- needs_signals: [...role.needs_signals],
12644
- conformance_class: role.conformance_class
12645
- };
12646
- case "management_surface":
12647
- return {
12648
- role: "management_surface",
12649
- operations: role.operations.map((operation) => ({
12650
- name: operation.name,
12651
- kind: operation.kind
12652
- })),
12653
- config_schema: role.config_schema,
12654
- observability: role.observability.map((surface) => ({
12655
- name: surface.name,
12656
- kind: surface.kind
12657
- })),
12658
- identity_scope: [...role.identity_scope]
12659
- };
12660
- case "internal_service":
12661
- return {
12662
- role: "internal_service",
12663
- service_id: role.service_id,
12664
- transport: role.transport,
12665
- agent_facing: role.agent_facing,
12666
- operations: [...role.operations]
12667
- };
12668
- }
12669
- }
12670
- function normalizeConsumerRole(role) {
12671
- switch (role.role) {
12672
- case "tool_client":
12673
- return { role: "tool_client", of: [...role.of] };
12674
- case "llm_client":
12675
- return { role: "llm_client", via: role.via, auth: role.auth };
12676
- case "service_client":
12677
- return { role: "service_client", of: [...role.of] };
12678
- }
12679
- }
12680
- function normalizeScheduledTask(task) {
12681
- return {
12682
- task_id: task.task_id,
12683
- eligibility: {
12684
- cooldown: task.eligibility.cooldown,
12685
- window: task.eligibility.window
12686
- },
12687
- lease_scope: task.lease_scope,
12688
- renews_during_calls: task.renews_during_calls,
12689
- toolset: [...task.toolset],
12690
- model_policy: {
12691
- tier: task.model_policy.tier,
12692
- fallback_chain: [...task.model_policy.fallback_chain]
12693
- },
12694
- step_cap: task.step_cap,
12695
- circuit_breaker: {
12696
- identical_failures: task.circuit_breaker.identical_failures
12697
- }
12698
- };
12699
- }
12700
- // ../aft-bridge/dist/subc-transport.js
12701
- import { existsSync as existsSync3, statSync as statSync3 } from "node:fs";
12702
-
12703
- // ../aft-bridge/dist/lifecycle-registry.js
12704
- import { lstat } from "node:fs/promises";
12705
- function asCanonicalRootPath(root) {
12706
- return root;
12707
- }
12708
- function asRootGeneration(generation) {
12709
- if (!Number.isSafeInteger(generation) || generation < 1) {
12710
- throw new RangeError("root generations must be positive safe integers");
12711
- }
12712
- return generation;
12713
- }
12714
- function asConcretePoolId(id) {
12715
- return id;
12716
- }
12717
- var DEFAULT_LIFECYCLE_INTERVAL_MS = 5 * 60 * 1000;
12718
- var DEFAULT_REALM = "default";
12719
- function rootKey(root) {
12720
- return root;
12721
- }
12722
- function resultMeansPresent(result) {
12723
- if (typeof result === "boolean")
12724
- return result;
12725
- if (typeof result === "object" && result !== null && "exists" in result) {
12726
- return result.exists !== false;
12727
- }
12728
- return true;
12729
- }
12730
- function isEnoent(error2) {
12731
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
12732
- }
12733
- function closeCounts(result) {
12734
- const teardown = typeof result === "object" && result !== null ? result : undefined;
12735
- const sessions = teardown?.tornDownSessionCount;
12736
- const facades = teardown?.tornDownFacadeCount;
12737
- return {
12738
- sessions: typeof sessions === "number" && Number.isFinite(sessions) ? Math.max(0, sessions) : 0,
12739
- facades: typeof facades === "number" && Number.isFinite(facades) ? Math.max(0, facades) : 0
12740
- };
12741
- }
12742
- function defaultTimer() {
12743
- return {
12744
- setInterval(callback, delayMs) {
12745
- const handle = setInterval(callback, delayMs);
12746
- const maybeUnref = handle;
12747
- maybeUnref.unref?.();
12748
- return handle;
12749
- },
12750
- clearInterval(handle) {
12751
- clearInterval(handle);
12752
- }
12753
- };
12754
- }
12755
-
12756
- class LifecycleRegistry {
12757
- realm;
12758
- intervalMs;
12759
- registrations = new Map;
12760
- registrationByPool = new WeakMap;
12761
- nextGenerationByRoot = new Map;
12762
- nextConcretePoolNumber = 1;
12763
- nextRegistrationSequence = 1;
12764
- timer;
12765
- statRoot;
12766
- demand;
12767
- onEvent;
12768
- intervalHandle = null;
12769
- sweepInFlight = null;
12770
- constructor(options = {}) {
12771
- this.realm = options.realm ?? DEFAULT_REALM;
12772
- this.intervalMs = options.intervalMs ?? DEFAULT_LIFECYCLE_INTERVAL_MS;
12773
- if (!Number.isFinite(this.intervalMs) || this.intervalMs <= 0) {
12774
- throw new RangeError("lifecycle interval must be a positive finite number");
12775
- }
12776
- const nativeTimer = defaultTimer();
12777
- this.timer = options.timer ?? (options.setInterval || options.clearInterval ? {
12778
- setInterval: options.setInterval ?? nativeTimer.setInterval,
12779
- clearInterval: options.clearInterval ?? nativeTimer.clearInterval
12780
- } : nativeTimer);
12781
- this.statRoot = options.stat ?? ((root) => lstat(root));
12782
- this.demand = options.demandCheck ?? (() => false);
12783
- this.onEvent = options.onEvent;
12784
- }
12785
- registerLifecyclePool(pool, options) {
12786
- if (!pool || typeof pool.closeProjectRoot !== "function") {
12787
- throw new TypeError("a lifecycle pool must provide closeProjectRoot");
12788
- }
12789
- if (typeof options?.evictOuterFacade !== "function") {
12790
- throw new TypeError("lifecycle registration requires evictOuterFacade");
12791
- }
12792
- if (typeof options.reapingEnabled !== "boolean") {
12793
- throw new TypeError("reapingEnabled must be a boolean");
12794
- }
12795
- const previous = this.registrationByPool.get(pool);
12796
- if (previous?.active)
12797
- this.deregisterInternal(previous);
12798
- const concretePoolId = asConcretePoolId(`pool-${this.nextConcretePoolNumber++}`);
12799
- const registrationIdentity = Object.freeze({
12800
- concretePoolId,
12801
- registrationSequence: this.nextRegistrationSequence++
12802
- });
12803
- const internal = {
12804
- pool,
12805
- concretePoolId,
12806
- registrationIdentity,
12807
- reapingEnabled: options.reapingEnabled,
12808
- evictOuterFacade: options.evictOuterFacade,
12809
- roots: new Map,
12810
- handle: undefined,
12811
- active: true
12812
- };
12813
- const handle = {
12814
- registrationIdentity,
12815
- identity: registrationIdentity,
12816
- get concretePoolId() {
12817
- return concretePoolId;
12818
- },
12819
- get reapingEnabled() {
12820
- return internal.reapingEnabled;
12821
- },
12822
- deregister: () => {
12823
- this.deregisterInternal(internal);
12824
- }
12825
- };
12826
- internal.handle = handle;
12827
- this.registrations.set(concretePoolId, internal);
12828
- this.registrationByPool.set(pool, internal);
12829
- this.refreshTimer();
12830
- return handle;
12831
- }
12832
- registerPool(pool, options) {
12833
- return this.registerLifecyclePool(pool, options);
12834
- }
12835
- registerRoot(poolId, root) {
12836
- const registration = this.currentRegistration(poolId);
12837
- if (!registration)
12838
- throw new Error(`unknown lifecycle pool ${poolId}`);
12839
- const key = rootKey(root);
12840
- const existing = registration.roots.get(key);
12841
- if (existing?.state === "live")
12842
- return existing.generation;
12843
- if (existing && !existing.synchronousPhaseComplete) {
12844
- throw new Error("root registration raced its synchronous close phase");
12845
- }
12846
- const next = (this.nextGenerationByRoot.get(`${poolId}\x00${key}`) ?? 0) + 1;
12847
- this.nextGenerationByRoot.set(`${poolId}\x00${key}`, next);
12848
- const entry = {
12849
- registration,
12850
- canonicalRoot: root,
12851
- generation: asRootGeneration(next),
12852
- state: "live",
12853
- consecutiveAbsences: 0,
12854
- tombstoned: false,
12855
- synchronousPhaseComplete: true,
12856
- closePromise: null,
12857
- eventEmitted: false,
12858
- cause: null
12859
- };
12860
- registration.roots.set(key, entry);
12861
- return entry.generation;
12862
- }
12863
- currentGeneration(poolId, root) {
12864
- return this.currentRoot(poolId, root)?.generation;
12865
- }
12866
- isTombstoned(poolId, root, generation) {
12867
- const entry = this.currentRoot(poolId, root);
12868
- return entry?.generation === generation && entry.tombstoned;
12869
- }
12870
- isCurrentRegistration(identity) {
12871
- const registration = this.registrations.get(identity.concretePoolId);
12872
- return registration?.active === true && registration.registrationIdentity === identity;
12873
- }
12874
- isCurrentLiveGeneration(poolId, root, generation) {
12875
- const entry = this.currentRoot(poolId, root);
12876
- return entry?.generation === generation && entry.state === "live";
12877
- }
12878
- getRootSnapshot(poolId, root) {
12879
- const entry = this.currentRoot(poolId, root);
12880
- return entry ? this.snapshotRoot(entry) : undefined;
12881
- }
12882
- rootSnapshots(poolId) {
12883
- const entries = poolId ? [this.currentRegistration(poolId)].filter((registration) => registration != null) : [...this.registrations.values()];
12884
- return entries.flatMap((registration) => [...registration.roots.values()].map((entry) => this.snapshotRoot(entry)));
12885
- }
12886
- snapshot() {
12887
- return {
12888
- realm: this.realm,
12889
- intervalMs: this.intervalMs,
12890
- timerActive: this.intervalHandle !== null,
12891
- registrations: [...this.registrations.values()].map((registration) => ({
12892
- concretePoolId: registration.concretePoolId,
12893
- reapingEnabled: registration.reapingEnabled,
12894
- roots: [...registration.roots.values()].map((entry) => this.snapshotRoot(entry))
12895
- }))
12896
- };
12897
- }
12898
- status() {
12899
- return this.snapshot();
12900
- }
12901
- async ensureRootForDemand(poolId, root) {
12902
- const registration = this.currentRegistration(poolId);
12903
- if (!registration)
12904
- return;
12905
- const existing = registration.roots.get(rootKey(root));
12906
- if (existing?.state === "live")
12907
- return existing.generation;
12908
- if (existing && !existing.synchronousPhaseComplete)
12909
- return;
12910
- let result;
12911
- try {
12912
- result = await this.demand(root, poolId);
12913
- } catch {
12914
- return;
12233
+ result = await this.demand(root, poolId);
12234
+ } catch {
12235
+ return;
12915
12236
  }
12916
12237
  if (!resultMeansPresent(result))
12917
12238
  return;
@@ -13159,7 +12480,12 @@ class SubcTransportShuttingDownError extends SubcCallError {
13159
12480
  }
13160
12481
  var AFT_MODULE_ID = "aft";
13161
12482
  var MAX_CONSECUTIVE_TRANSPORT_FAILURES = 3;
12483
+ var RECONNECT_RETRY_FLOOR_MS = 100;
12484
+ var RECONNECT_RETRY_CAP_MS = 2000;
13162
12485
  var BG_STABLE_MS = 5000;
12486
+ function reconnectBackoffMs(attempt) {
12487
+ return Math.min(RECONNECT_RETRY_FLOOR_MS * 2 ** Math.min(attempt, 6), RECONNECT_RETRY_CAP_MS);
12488
+ }
13163
12489
  var BG_LIFECYCLE_LOG_INTERVAL_MS = 60000;
13164
12490
  var BG_DISPATCH_PROBE_INTERVAL_MS = 60000;
13165
12491
  var DEFAULT_SESSION_ID = "__default__";
@@ -13423,6 +12749,8 @@ class BgSubscription {
13423
12749
  giveUp("stopped");
13424
12750
  return;
13425
12751
  }
12752
+ if (Date.now() - subscribedAt >= BG_STABLE_MS)
12753
+ backoffAttempt = 0;
13426
12754
  beginReconnect();
13427
12755
  } catch (err) {
13428
12756
  const routeId2 = this.routeId(route);
@@ -13447,8 +12775,7 @@ class BgSubscription {
13447
12775
  giveUp("stopped");
13448
12776
  }
13449
12777
  async backoff(attempt) {
13450
- const ms = Math.min(100 * 2 ** Math.min(attempt, 6), 2000);
13451
- await this.sleep(ms);
12778
+ await this.sleep(reconnectBackoffMs(attempt));
13452
12779
  }
13453
12780
  }
13454
12781
  function isRecord(value) {
@@ -13574,6 +12901,7 @@ class SubcTransportPool {
13574
12901
  onBgEventsNudge;
13575
12902
  onBgEventsNudgeRef;
13576
12903
  bgBackoffSleep;
12904
+ routeRetrySleep;
13577
12905
  bgDispatchProbeIntervalMs;
13578
12906
  lifecycleDemandCheck;
13579
12907
  onLifecycleEvent;
@@ -13584,6 +12912,8 @@ class SubcTransportPool {
13584
12912
  outerFacadeEvictor;
13585
12913
  client = null;
13586
12914
  connecting = null;
12915
+ routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
12916
+ routeReopenRetry = null;
13587
12917
  sessions = new Map;
13588
12918
  rootIndex = new Map;
13589
12919
  dormantRoots = new Map;
@@ -13604,6 +12934,7 @@ class SubcTransportPool {
13604
12934
  this.onBgEventsNudge = options.onBgEventsNudge;
13605
12935
  this.onBgEventsNudgeRef = options.onBgEventsNudgeRef;
13606
12936
  this.bgBackoffSleep = options.bgBackoffSleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
12937
+ this.routeRetrySleep = options.routeRetrySleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
13607
12938
  this.bgDispatchProbeIntervalMs = options.bgDispatchProbeIntervalMs ?? BG_DISPATCH_PROBE_INTERVAL_MS;
13608
12939
  const lifecycle = options.lifecycle;
13609
12940
  const demandCheck = options.lifecycleDemandCheck ?? options.demandCheck ?? lifecycle?.demandCheck;
@@ -14100,9 +13431,12 @@ class SubcTransportPool {
14100
13431
  throw this.annotateReapError(error2, record);
14101
13432
  if (isRouteProvenAbsentError(error2) && this.isCurrentSession(key, record) && this.client === client) {
14102
13433
  clearRouteEntry(routeAndEntry.entry);
13434
+ await this.waitForRouteReopenBackoff();
14103
13435
  routeAndEntry = await openRoute();
14104
13436
  try {
14105
- return await requestOnRoute(routeAndEntry.route);
13437
+ const reply = await requestOnRoute(routeAndEntry.route);
13438
+ this.resetRouteReopenBackoff();
13439
+ return reply;
14106
13440
  } catch (retryError) {
14107
13441
  if (this.isReapInduced(record))
14108
13442
  throw this.annotateReapError(retryError, record);
@@ -14122,6 +13456,23 @@ class SubcTransportPool {
14122
13456
  this.deleteSessionIfEmpty(key, record);
14123
13457
  }
14124
13458
  }
13459
+ waitForRouteReopenBackoff() {
13460
+ const pending = this.routeReopenRetry;
13461
+ if (pending)
13462
+ return pending;
13463
+ const delay = this.routeReopenRetryDelayMs;
13464
+ this.routeReopenRetryDelayMs = Math.min(delay * 2, RECONNECT_RETRY_CAP_MS);
13465
+ let retry;
13466
+ retry = Promise.resolve().then(() => this.routeRetrySleep(delay)).finally(() => {
13467
+ if (this.routeReopenRetry === retry)
13468
+ this.routeReopenRetry = null;
13469
+ });
13470
+ this.routeReopenRetry = retry;
13471
+ return retry;
13472
+ }
13473
+ resetRouteReopenBackoff() {
13474
+ this.routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
13475
+ }
14125
13476
  async ensureClient() {
14126
13477
  if (this.shuttingDown)
14127
13478
  throw new SubcTransportShuttingDownError;
@@ -16833,11 +16184,16 @@ function normalizeKey(projectRoot) {
16833
16184
  return canonicalizeProjectRoot(projectRoot);
16834
16185
  }
16835
16186
  // ../aft-bridge/dist/revivable-transport.js
16187
+ var REVIVAL_RETRY_FLOOR_MS = 100;
16188
+ var REVIVAL_RETRY_CAP_MS = 2000;
16189
+
16836
16190
  class RevivableTransportPool {
16837
16191
  createPool;
16838
16192
  onBinaryReplaced;
16839
16193
  activePool;
16840
16194
  revival = null;
16195
+ revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
16196
+ revivalRetryNotBefore = 0;
16841
16197
  transports = new Map;
16842
16198
  configureOverrides = new Map;
16843
16199
  editSlotSurvivesCaptured = false;
@@ -16931,12 +16287,30 @@ class RevivableTransportPool {
16931
16287
  return this.activePool;
16932
16288
  if (this.revival)
16933
16289
  return this.revival;
16290
+ const delay = Math.max(0, this.revivalRetryNotBefore - Date.now());
16291
+ if (delay > 0) {
16292
+ let scheduled;
16293
+ scheduled = new Promise((resolve7) => setTimeout(resolve7, delay)).then(() => {
16294
+ if (this.revival === scheduled)
16295
+ this.revival = null;
16296
+ return this.ensureActivePool();
16297
+ });
16298
+ this.revival = scheduled;
16299
+ scheduled.then(() => {
16300
+ return;
16301
+ }, () => {
16302
+ return;
16303
+ });
16304
+ return scheduled;
16305
+ }
16934
16306
  warn("transport was shut down but new demand arrived — reviving (host quit hook fired without process exit?)");
16935
- const revival = this.createPool().then((pool) => {
16307
+ const revival = Promise.resolve().then(() => this.createPool()).then((pool) => {
16936
16308
  for (const [key, value] of this.configureOverrides) {
16937
16309
  pool.setConfigureOverride(key, value);
16938
16310
  }
16939
16311
  this.activePool = pool;
16312
+ this.revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
16313
+ this.revivalRetryNotBefore = 0;
16940
16314
  for (const [root, transport] of this.transports) {
16941
16315
  transport.refreshStatusSubscription(pool.getActiveBridgeForRoot(root));
16942
16316
  }
@@ -16947,6 +16321,8 @@ class RevivableTransportPool {
16947
16321
  if (this.revival === revival)
16948
16322
  this.revival = null;
16949
16323
  }, () => {
16324
+ this.revivalRetryNotBefore = Date.now() + this.revivalRetryDelayMs;
16325
+ this.revivalRetryDelayMs = Math.min(this.revivalRetryDelayMs * 2, REVIVAL_RETRY_CAP_MS);
16950
16326
  if (this.revival === revival)
16951
16327
  this.revival = null;
16952
16328
  });
@@ -18017,7 +17393,7 @@ import {
18017
17393
  // package.json
18018
17394
  var package_default = {
18019
17395
  name: "@cortexkit/aft-pi",
18020
- version: "0.51.2",
17396
+ version: "0.52.0",
18021
17397
  type: "module",
18022
17398
  description: "Pi coding agent extension for Agent File Tools (AFT) — tree-sitter and LSP-powered code analysis",
18023
17399
  main: "dist/index.js",
@@ -18040,19 +17416,19 @@ var package_default = {
18040
17416
  "test:unit": "bun test src/__tests__ --path-ignore-patterns 'src/__tests__/e2e/**'"
18041
17417
  },
18042
17418
  dependencies: {
18043
- "@cortexkit/aft-bridge": "0.51.2",
17419
+ "@cortexkit/aft-bridge": "0.52.0",
18044
17420
  "comment-json": "^5.0.0",
18045
17421
  diff: "^8.0.4",
18046
17422
  typebox: "1.1.38",
18047
17423
  zod: "^4.4.3"
18048
17424
  },
18049
17425
  optionalDependencies: {
18050
- "@cortexkit/aft-darwin-arm64": "0.51.2",
18051
- "@cortexkit/aft-darwin-x64": "0.51.2",
18052
- "@cortexkit/aft-linux-arm64": "0.51.2",
18053
- "@cortexkit/aft-linux-x64": "0.51.2",
18054
- "@cortexkit/aft-win32-arm64": "0.51.2",
18055
- "@cortexkit/aft-win32-x64": "0.51.2"
17426
+ "@cortexkit/aft-darwin-arm64": "0.52.0",
17427
+ "@cortexkit/aft-darwin-x64": "0.52.0",
17428
+ "@cortexkit/aft-linux-arm64": "0.52.0",
17429
+ "@cortexkit/aft-linux-x64": "0.52.0",
17430
+ "@cortexkit/aft-win32-arm64": "0.52.0",
17431
+ "@cortexkit/aft-win32-x64": "0.52.0"
18056
17432
  },
18057
17433
  devDependencies: {
18058
17434
  "@earendil-works/pi-coding-agent": "^0.80.2",
@@ -18717,523 +18093,523 @@ var import_comment_json = __toESM(require_src2(), 1);
18717
18093
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
18718
18094
  var exports_external = {};
18719
18095
  __export(exports_external, {
18720
- xor: () => xor,
18721
- xid: () => xid2,
18722
- void: () => _void2,
18723
- uuidv7: () => uuidv7,
18724
- uuidv6: () => uuidv6,
18725
- uuidv4: () => uuidv4,
18726
- uuid: () => uuid2,
18727
- util: () => exports_util,
18728
- url: () => url,
18729
- uppercase: () => _uppercase,
18730
- unknown: () => unknown,
18731
- union: () => union,
18732
- undefined: () => _undefined3,
18733
- ulid: () => ulid2,
18734
- uint64: () => uint64,
18735
- uint32: () => uint32,
18736
- tuple: () => tuple,
18737
- trim: () => _trim,
18738
- treeifyError: () => treeifyError,
18739
- transform: () => transform,
18740
- toUpperCase: () => _toUpperCase,
18741
- toLowerCase: () => _toLowerCase,
18742
- toJSONSchema: () => toJSONSchema,
18743
- templateLiteral: () => templateLiteral,
18744
- symbol: () => symbol,
18745
- superRefine: () => superRefine,
18746
- success: () => success,
18747
- stringbool: () => stringbool,
18748
- stringFormat: () => stringFormat,
18749
- string: () => string2,
18750
- strictObject: () => strictObject,
18751
- startsWith: () => _startsWith,
18752
- slugify: () => _slugify,
18753
- size: () => _size,
18754
- setErrorMap: () => setErrorMap,
18755
- set: () => set,
18756
- safeParseAsync: () => safeParseAsync2,
18757
- safeParse: () => safeParse2,
18758
- safeEncodeAsync: () => safeEncodeAsync2,
18759
- safeEncode: () => safeEncode2,
18760
- safeDecodeAsync: () => safeDecodeAsync2,
18761
- safeDecode: () => safeDecode2,
18762
- registry: () => registry,
18763
- regexes: () => exports_regexes,
18764
- regex: () => _regex,
18765
- refine: () => refine,
18766
- record: () => record,
18767
- readonly: () => readonly,
18768
- property: () => _property,
18769
- promise: () => promise,
18770
- prettifyError: () => prettifyError,
18771
- preprocess: () => preprocess,
18772
- prefault: () => prefault,
18773
- positive: () => _positive,
18774
- pipe: () => pipe,
18775
- partialRecord: () => partialRecord,
18776
- parseAsync: () => parseAsync2,
18777
- parse: () => parse3,
18778
- overwrite: () => _overwrite,
18779
- optional: () => optional,
18780
- object: () => object,
18781
- number: () => number2,
18782
- nullish: () => nullish2,
18783
- nullable: () => nullable,
18784
- null: () => _null3,
18785
- normalize: () => _normalize,
18786
- nonpositive: () => _nonpositive,
18787
- nonoptional: () => nonoptional,
18788
- nonnegative: () => _nonnegative,
18789
- never: () => never,
18790
- negative: () => _negative,
18791
- nativeEnum: () => nativeEnum,
18792
- nanoid: () => nanoid2,
18793
- nan: () => nan,
18794
- multipleOf: () => _multipleOf,
18795
- minSize: () => _minSize,
18796
- minLength: () => _minLength,
18797
- mime: () => _mime,
18798
- meta: () => meta2,
18799
- maxSize: () => _maxSize,
18800
- maxLength: () => _maxLength,
18801
- map: () => map,
18802
- mac: () => mac2,
18803
- lte: () => _lte,
18804
- lt: () => _lt,
18805
- lowercase: () => _lowercase,
18806
- looseRecord: () => looseRecord,
18807
- looseObject: () => looseObject,
18808
- locales: () => exports_locales,
18809
- literal: () => literal,
18810
- length: () => _length,
18811
- lazy: () => lazy,
18812
- ksuid: () => ksuid2,
18813
- keyof: () => keyof,
18814
- jwt: () => jwt,
18815
- json: () => json,
18816
- iso: () => exports_iso,
18817
- ipv6: () => ipv62,
18818
- ipv4: () => ipv42,
18819
- invertCodec: () => invertCodec,
18820
- intersection: () => intersection,
18821
- int64: () => int64,
18822
- int32: () => int32,
18823
- int: () => int,
18824
- instanceof: () => _instanceof,
18825
- includes: () => _includes,
18826
- httpUrl: () => httpUrl,
18827
- hostname: () => hostname3,
18828
- hex: () => hex2,
18829
- hash: () => hash,
18830
- guid: () => guid2,
18831
- gte: () => _gte,
18832
- gt: () => _gt,
18833
- globalRegistry: () => globalRegistry,
18834
- getErrorMap: () => getErrorMap,
18835
- function: () => _function,
18836
- fromJSONSchema: () => fromJSONSchema,
18837
- formatError: () => formatError,
18838
- float64: () => float64,
18839
- float32: () => float32,
18840
- flattenError: () => flattenError,
18841
- file: () => file,
18842
- exactOptional: () => exactOptional,
18843
- enum: () => _enum2,
18844
- endsWith: () => _endsWith,
18845
- encodeAsync: () => encodeAsync2,
18846
- encode: () => encode2,
18847
- emoji: () => emoji2,
18848
- email: () => email2,
18849
- e164: () => e1642,
18850
- discriminatedUnion: () => discriminatedUnion,
18851
- describe: () => describe2,
18852
- decodeAsync: () => decodeAsync2,
18853
- decode: () => decode2,
18854
- date: () => date3,
18855
- custom: () => custom,
18856
- cuid2: () => cuid22,
18857
- cuid: () => cuid3,
18858
- core: () => exports_core2,
18859
- config: () => config,
18860
- coerce: () => exports_coerce,
18861
- codec: () => codec,
18862
- clone: () => clone,
18863
- cidrv6: () => cidrv62,
18864
- cidrv4: () => cidrv42,
18865
- check: () => check,
18866
- catch: () => _catch2,
18867
- boolean: () => boolean2,
18868
- bigint: () => bigint2,
18869
- base64url: () => base64url2,
18870
- base64: () => base642,
18871
- array: () => array,
18872
- any: () => any,
18873
- _function: () => _function,
18874
- _default: () => _default2,
18875
- _ZodString: () => _ZodString,
18876
- ZodXor: () => ZodXor,
18877
- ZodXID: () => ZodXID,
18878
- ZodVoid: () => ZodVoid,
18879
- ZodUnknown: () => ZodUnknown,
18880
- ZodUnion: () => ZodUnion,
18881
- ZodUndefined: () => ZodUndefined,
18882
- ZodUUID: () => ZodUUID,
18883
- ZodURL: () => ZodURL,
18884
- ZodULID: () => ZodULID,
18885
- ZodType: () => ZodType,
18886
- ZodTuple: () => ZodTuple,
18887
- ZodTransform: () => ZodTransform,
18888
- ZodTemplateLiteral: () => ZodTemplateLiteral,
18889
- ZodSymbol: () => ZodSymbol,
18890
- ZodSuccess: () => ZodSuccess,
18891
- ZodStringFormat: () => ZodStringFormat,
18892
- ZodString: () => ZodString,
18893
- ZodSet: () => ZodSet,
18894
- ZodRecord: () => ZodRecord,
18895
- ZodRealError: () => ZodRealError,
18896
- ZodReadonly: () => ZodReadonly,
18897
- ZodPromise: () => ZodPromise,
18898
- ZodPreprocess: () => ZodPreprocess,
18899
- ZodPrefault: () => ZodPrefault,
18900
- ZodPipe: () => ZodPipe,
18901
- ZodOptional: () => ZodOptional,
18902
- ZodObject: () => ZodObject,
18903
- ZodNumberFormat: () => ZodNumberFormat,
18904
- ZodNumber: () => ZodNumber,
18905
- ZodNullable: () => ZodNullable,
18906
- ZodNull: () => ZodNull,
18907
- ZodNonOptional: () => ZodNonOptional,
18908
- ZodNever: () => ZodNever,
18909
- ZodNanoID: () => ZodNanoID,
18910
- ZodNaN: () => ZodNaN,
18911
- ZodMap: () => ZodMap,
18912
- ZodMAC: () => ZodMAC,
18913
- ZodLiteral: () => ZodLiteral,
18914
- ZodLazy: () => ZodLazy,
18915
- ZodKSUID: () => ZodKSUID,
18916
- ZodJWT: () => ZodJWT,
18917
- ZodIssueCode: () => ZodIssueCode,
18918
- ZodIntersection: () => ZodIntersection,
18919
- ZodISOTime: () => ZodISOTime,
18920
- ZodISODuration: () => ZodISODuration,
18921
- ZodISODateTime: () => ZodISODateTime,
18922
- ZodISODate: () => ZodISODate,
18923
- ZodIPv6: () => ZodIPv6,
18924
- ZodIPv4: () => ZodIPv4,
18925
- ZodGUID: () => ZodGUID,
18926
- ZodFunction: () => ZodFunction,
18927
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
18928
- ZodFile: () => ZodFile,
18929
- ZodExactOptional: () => ZodExactOptional,
18930
- ZodError: () => ZodError,
18931
- ZodEnum: () => ZodEnum,
18932
- ZodEmoji: () => ZodEmoji,
18933
- ZodEmail: () => ZodEmail,
18934
- ZodE164: () => ZodE164,
18935
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
18936
- ZodDefault: () => ZodDefault,
18937
- ZodDate: () => ZodDate,
18938
- ZodCustomStringFormat: () => ZodCustomStringFormat,
18939
- ZodCustom: () => ZodCustom,
18940
- ZodCodec: () => ZodCodec,
18941
- ZodCatch: () => ZodCatch,
18942
- ZodCUID2: () => ZodCUID2,
18943
- ZodCUID: () => ZodCUID,
18944
- ZodCIDRv6: () => ZodCIDRv6,
18945
- ZodCIDRv4: () => ZodCIDRv4,
18946
- ZodBoolean: () => ZodBoolean,
18947
- ZodBigIntFormat: () => ZodBigIntFormat,
18948
- ZodBigInt: () => ZodBigInt,
18949
- ZodBase64URL: () => ZodBase64URL,
18950
- ZodBase64: () => ZodBase64,
18951
- ZodArray: () => ZodArray,
18952
- ZodAny: () => ZodAny,
18953
- TimePrecision: () => TimePrecision,
18954
- NEVER: () => NEVER,
18955
- $output: () => $output,
18096
+ $brand: () => $brand,
18956
18097
  $input: () => $input,
18957
- $brand: () => $brand
18098
+ $output: () => $output,
18099
+ NEVER: () => NEVER,
18100
+ TimePrecision: () => TimePrecision,
18101
+ ZodAny: () => ZodAny,
18102
+ ZodArray: () => ZodArray,
18103
+ ZodBase64: () => ZodBase64,
18104
+ ZodBase64URL: () => ZodBase64URL,
18105
+ ZodBigInt: () => ZodBigInt,
18106
+ ZodBigIntFormat: () => ZodBigIntFormat,
18107
+ ZodBoolean: () => ZodBoolean,
18108
+ ZodCIDRv4: () => ZodCIDRv4,
18109
+ ZodCIDRv6: () => ZodCIDRv6,
18110
+ ZodCUID: () => ZodCUID,
18111
+ ZodCUID2: () => ZodCUID2,
18112
+ ZodCatch: () => ZodCatch,
18113
+ ZodCodec: () => ZodCodec,
18114
+ ZodCustom: () => ZodCustom,
18115
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
18116
+ ZodDate: () => ZodDate,
18117
+ ZodDefault: () => ZodDefault,
18118
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
18119
+ ZodE164: () => ZodE164,
18120
+ ZodEmail: () => ZodEmail,
18121
+ ZodEmoji: () => ZodEmoji,
18122
+ ZodEnum: () => ZodEnum,
18123
+ ZodError: () => ZodError,
18124
+ ZodExactOptional: () => ZodExactOptional,
18125
+ ZodFile: () => ZodFile,
18126
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
18127
+ ZodFunction: () => ZodFunction,
18128
+ ZodGUID: () => ZodGUID,
18129
+ ZodIPv4: () => ZodIPv4,
18130
+ ZodIPv6: () => ZodIPv6,
18131
+ ZodISODate: () => ZodISODate,
18132
+ ZodISODateTime: () => ZodISODateTime,
18133
+ ZodISODuration: () => ZodISODuration,
18134
+ ZodISOTime: () => ZodISOTime,
18135
+ ZodIntersection: () => ZodIntersection,
18136
+ ZodIssueCode: () => ZodIssueCode,
18137
+ ZodJWT: () => ZodJWT,
18138
+ ZodKSUID: () => ZodKSUID,
18139
+ ZodLazy: () => ZodLazy,
18140
+ ZodLiteral: () => ZodLiteral,
18141
+ ZodMAC: () => ZodMAC,
18142
+ ZodMap: () => ZodMap,
18143
+ ZodNaN: () => ZodNaN,
18144
+ ZodNanoID: () => ZodNanoID,
18145
+ ZodNever: () => ZodNever,
18146
+ ZodNonOptional: () => ZodNonOptional,
18147
+ ZodNull: () => ZodNull,
18148
+ ZodNullable: () => ZodNullable,
18149
+ ZodNumber: () => ZodNumber,
18150
+ ZodNumberFormat: () => ZodNumberFormat,
18151
+ ZodObject: () => ZodObject,
18152
+ ZodOptional: () => ZodOptional,
18153
+ ZodPipe: () => ZodPipe,
18154
+ ZodPrefault: () => ZodPrefault,
18155
+ ZodPreprocess: () => ZodPreprocess,
18156
+ ZodPromise: () => ZodPromise,
18157
+ ZodReadonly: () => ZodReadonly,
18158
+ ZodRealError: () => ZodRealError,
18159
+ ZodRecord: () => ZodRecord,
18160
+ ZodSet: () => ZodSet,
18161
+ ZodString: () => ZodString,
18162
+ ZodStringFormat: () => ZodStringFormat,
18163
+ ZodSuccess: () => ZodSuccess,
18164
+ ZodSymbol: () => ZodSymbol,
18165
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
18166
+ ZodTransform: () => ZodTransform,
18167
+ ZodTuple: () => ZodTuple,
18168
+ ZodType: () => ZodType,
18169
+ ZodULID: () => ZodULID,
18170
+ ZodURL: () => ZodURL,
18171
+ ZodUUID: () => ZodUUID,
18172
+ ZodUndefined: () => ZodUndefined,
18173
+ ZodUnion: () => ZodUnion,
18174
+ ZodUnknown: () => ZodUnknown,
18175
+ ZodVoid: () => ZodVoid,
18176
+ ZodXID: () => ZodXID,
18177
+ ZodXor: () => ZodXor,
18178
+ _ZodString: () => _ZodString,
18179
+ _default: () => _default2,
18180
+ _function: () => _function,
18181
+ any: () => any,
18182
+ array: () => array,
18183
+ base64: () => base642,
18184
+ base64url: () => base64url2,
18185
+ bigint: () => bigint2,
18186
+ boolean: () => boolean2,
18187
+ catch: () => _catch2,
18188
+ check: () => check,
18189
+ cidrv4: () => cidrv42,
18190
+ cidrv6: () => cidrv62,
18191
+ clone: () => clone,
18192
+ codec: () => codec,
18193
+ coerce: () => exports_coerce,
18194
+ config: () => config,
18195
+ core: () => exports_core2,
18196
+ cuid: () => cuid3,
18197
+ cuid2: () => cuid22,
18198
+ custom: () => custom,
18199
+ date: () => date3,
18200
+ decode: () => decode2,
18201
+ decodeAsync: () => decodeAsync2,
18202
+ describe: () => describe2,
18203
+ discriminatedUnion: () => discriminatedUnion,
18204
+ e164: () => e1642,
18205
+ email: () => email2,
18206
+ emoji: () => emoji2,
18207
+ encode: () => encode2,
18208
+ encodeAsync: () => encodeAsync2,
18209
+ endsWith: () => _endsWith,
18210
+ enum: () => _enum2,
18211
+ exactOptional: () => exactOptional,
18212
+ file: () => file,
18213
+ flattenError: () => flattenError,
18214
+ float32: () => float32,
18215
+ float64: () => float64,
18216
+ formatError: () => formatError,
18217
+ fromJSONSchema: () => fromJSONSchema,
18218
+ function: () => _function,
18219
+ getErrorMap: () => getErrorMap,
18220
+ globalRegistry: () => globalRegistry,
18221
+ gt: () => _gt,
18222
+ gte: () => _gte,
18223
+ guid: () => guid2,
18224
+ hash: () => hash,
18225
+ hex: () => hex2,
18226
+ hostname: () => hostname3,
18227
+ httpUrl: () => httpUrl,
18228
+ includes: () => _includes,
18229
+ instanceof: () => _instanceof,
18230
+ int: () => int,
18231
+ int32: () => int32,
18232
+ int64: () => int64,
18233
+ intersection: () => intersection,
18234
+ invertCodec: () => invertCodec,
18235
+ ipv4: () => ipv42,
18236
+ ipv6: () => ipv62,
18237
+ iso: () => exports_iso,
18238
+ json: () => json,
18239
+ jwt: () => jwt,
18240
+ keyof: () => keyof,
18241
+ ksuid: () => ksuid2,
18242
+ lazy: () => lazy,
18243
+ length: () => _length,
18244
+ literal: () => literal,
18245
+ locales: () => exports_locales,
18246
+ looseObject: () => looseObject,
18247
+ looseRecord: () => looseRecord,
18248
+ lowercase: () => _lowercase,
18249
+ lt: () => _lt,
18250
+ lte: () => _lte,
18251
+ mac: () => mac2,
18252
+ map: () => map,
18253
+ maxLength: () => _maxLength,
18254
+ maxSize: () => _maxSize,
18255
+ meta: () => meta2,
18256
+ mime: () => _mime,
18257
+ minLength: () => _minLength,
18258
+ minSize: () => _minSize,
18259
+ multipleOf: () => _multipleOf,
18260
+ nan: () => nan,
18261
+ nanoid: () => nanoid2,
18262
+ nativeEnum: () => nativeEnum,
18263
+ negative: () => _negative,
18264
+ never: () => never,
18265
+ nonnegative: () => _nonnegative,
18266
+ nonoptional: () => nonoptional,
18267
+ nonpositive: () => _nonpositive,
18268
+ normalize: () => _normalize,
18269
+ null: () => _null3,
18270
+ nullable: () => nullable,
18271
+ nullish: () => nullish2,
18272
+ number: () => number2,
18273
+ object: () => object,
18274
+ optional: () => optional,
18275
+ overwrite: () => _overwrite,
18276
+ parse: () => parse3,
18277
+ parseAsync: () => parseAsync2,
18278
+ partialRecord: () => partialRecord,
18279
+ pipe: () => pipe,
18280
+ positive: () => _positive,
18281
+ prefault: () => prefault,
18282
+ preprocess: () => preprocess,
18283
+ prettifyError: () => prettifyError,
18284
+ promise: () => promise,
18285
+ property: () => _property,
18286
+ readonly: () => readonly,
18287
+ record: () => record,
18288
+ refine: () => refine,
18289
+ regex: () => _regex,
18290
+ regexes: () => exports_regexes,
18291
+ registry: () => registry,
18292
+ safeDecode: () => safeDecode2,
18293
+ safeDecodeAsync: () => safeDecodeAsync2,
18294
+ safeEncode: () => safeEncode2,
18295
+ safeEncodeAsync: () => safeEncodeAsync2,
18296
+ safeParse: () => safeParse2,
18297
+ safeParseAsync: () => safeParseAsync2,
18298
+ set: () => set,
18299
+ setErrorMap: () => setErrorMap,
18300
+ size: () => _size,
18301
+ slugify: () => _slugify,
18302
+ startsWith: () => _startsWith,
18303
+ strictObject: () => strictObject,
18304
+ string: () => string2,
18305
+ stringFormat: () => stringFormat,
18306
+ stringbool: () => stringbool,
18307
+ success: () => success,
18308
+ superRefine: () => superRefine,
18309
+ symbol: () => symbol,
18310
+ templateLiteral: () => templateLiteral,
18311
+ toJSONSchema: () => toJSONSchema,
18312
+ toLowerCase: () => _toLowerCase,
18313
+ toUpperCase: () => _toUpperCase,
18314
+ transform: () => transform,
18315
+ treeifyError: () => treeifyError,
18316
+ trim: () => _trim,
18317
+ tuple: () => tuple,
18318
+ uint32: () => uint32,
18319
+ uint64: () => uint64,
18320
+ ulid: () => ulid2,
18321
+ undefined: () => _undefined3,
18322
+ union: () => union,
18323
+ unknown: () => unknown,
18324
+ uppercase: () => _uppercase,
18325
+ url: () => url,
18326
+ util: () => exports_util,
18327
+ uuid: () => uuid2,
18328
+ uuidv4: () => uuidv4,
18329
+ uuidv6: () => uuidv6,
18330
+ uuidv7: () => uuidv7,
18331
+ void: () => _void2,
18332
+ xid: () => xid2,
18333
+ xor: () => xor
18958
18334
  });
18959
18335
 
18960
18336
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/index.js
18961
18337
  var exports_core2 = {};
18962
18338
  __export(exports_core2, {
18963
- version: () => version,
18964
- util: () => exports_util,
18965
- treeifyError: () => treeifyError,
18966
- toJSONSchema: () => toJSONSchema,
18967
- toDotPath: () => toDotPath,
18968
- safeParseAsync: () => safeParseAsync,
18969
- safeParse: () => safeParse,
18970
- safeEncodeAsync: () => safeEncodeAsync,
18971
- safeEncode: () => safeEncode,
18972
- safeDecodeAsync: () => safeDecodeAsync,
18973
- safeDecode: () => safeDecode,
18974
- registry: () => registry,
18975
- regexes: () => exports_regexes,
18976
- process: () => process2,
18977
- prettifyError: () => prettifyError,
18978
- parseAsync: () => parseAsync,
18979
- parse: () => parse,
18980
- meta: () => meta,
18981
- locales: () => exports_locales,
18982
- isValidJWT: () => isValidJWT,
18983
- isValidBase64URL: () => isValidBase64URL,
18984
- isValidBase64: () => isValidBase64,
18985
- initializeContext: () => initializeContext,
18986
- globalRegistry: () => globalRegistry,
18987
- globalConfig: () => globalConfig,
18988
- formatError: () => formatError,
18989
- flattenError: () => flattenError,
18990
- finalize: () => finalize,
18991
- extractDefs: () => extractDefs,
18992
- encodeAsync: () => encodeAsync,
18993
- encode: () => encode,
18994
- describe: () => describe,
18995
- decodeAsync: () => decodeAsync,
18996
- decode: () => decode,
18997
- createToJSONSchemaMethod: () => createToJSONSchemaMethod,
18998
- createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
18999
- config: () => config,
19000
- clone: () => clone,
19001
- _xor: () => _xor,
19002
- _xid: () => _xid,
19003
- _void: () => _void,
19004
- _uuidv7: () => _uuidv7,
19005
- _uuidv6: () => _uuidv6,
19006
- _uuidv4: () => _uuidv4,
19007
- _uuid: () => _uuid,
19008
- _url: () => _url,
19009
- _uppercase: () => _uppercase,
19010
- _unknown: () => _unknown,
19011
- _union: () => _union,
19012
- _undefined: () => _undefined2,
19013
- _ulid: () => _ulid,
19014
- _uint64: () => _uint64,
19015
- _uint32: () => _uint32,
19016
- _tuple: () => _tuple,
19017
- _trim: () => _trim,
19018
- _transform: () => _transform,
19019
- _toUpperCase: () => _toUpperCase,
19020
- _toLowerCase: () => _toLowerCase,
19021
- _templateLiteral: () => _templateLiteral,
19022
- _symbol: () => _symbol,
19023
- _superRefine: () => _superRefine,
19024
- _success: () => _success,
19025
- _stringbool: () => _stringbool,
19026
- _stringFormat: () => _stringFormat,
19027
- _string: () => _string,
19028
- _startsWith: () => _startsWith,
19029
- _slugify: () => _slugify,
19030
- _size: () => _size,
19031
- _set: () => _set,
19032
- _safeParseAsync: () => _safeParseAsync,
19033
- _safeParse: () => _safeParse,
19034
- _safeEncodeAsync: () => _safeEncodeAsync,
19035
- _safeEncode: () => _safeEncode,
19036
- _safeDecodeAsync: () => _safeDecodeAsync,
19037
- _safeDecode: () => _safeDecode,
19038
- _regex: () => _regex,
19039
- _refine: () => _refine,
19040
- _record: () => _record,
19041
- _readonly: () => _readonly,
19042
- _property: () => _property,
19043
- _promise: () => _promise,
19044
- _positive: () => _positive,
19045
- _pipe: () => _pipe,
19046
- _parseAsync: () => _parseAsync,
19047
- _parse: () => _parse,
19048
- _overwrite: () => _overwrite,
19049
- _optional: () => _optional,
19050
- _number: () => _number,
19051
- _nullable: () => _nullable,
19052
- _null: () => _null2,
19053
- _normalize: () => _normalize,
19054
- _nonpositive: () => _nonpositive,
19055
- _nonoptional: () => _nonoptional,
19056
- _nonnegative: () => _nonnegative,
19057
- _never: () => _never,
19058
- _negative: () => _negative,
19059
- _nativeEnum: () => _nativeEnum,
19060
- _nanoid: () => _nanoid,
19061
- _nan: () => _nan,
19062
- _multipleOf: () => _multipleOf,
19063
- _minSize: () => _minSize,
19064
- _minLength: () => _minLength,
19065
- _min: () => _gte,
19066
- _mime: () => _mime,
19067
- _maxSize: () => _maxSize,
19068
- _maxLength: () => _maxLength,
19069
- _max: () => _lte,
19070
- _map: () => _map,
19071
- _mac: () => _mac,
19072
- _lte: () => _lte,
19073
- _lt: () => _lt,
19074
- _lowercase: () => _lowercase,
19075
- _literal: () => _literal,
19076
- _length: () => _length,
19077
- _lazy: () => _lazy,
19078
- _ksuid: () => _ksuid,
19079
- _jwt: () => _jwt,
19080
- _isoTime: () => _isoTime,
19081
- _isoDuration: () => _isoDuration,
19082
- _isoDateTime: () => _isoDateTime,
19083
- _isoDate: () => _isoDate,
19084
- _ipv6: () => _ipv6,
19085
- _ipv4: () => _ipv4,
19086
- _intersection: () => _intersection,
19087
- _int64: () => _int64,
19088
- _int32: () => _int32,
19089
- _int: () => _int,
19090
- _includes: () => _includes,
19091
- _guid: () => _guid,
19092
- _gte: () => _gte,
19093
- _gt: () => _gt,
19094
- _float64: () => _float64,
19095
- _float32: () => _float32,
19096
- _file: () => _file,
19097
- _enum: () => _enum,
19098
- _endsWith: () => _endsWith,
19099
- _encodeAsync: () => _encodeAsync,
19100
- _encode: () => _encode,
19101
- _emoji: () => _emoji2,
19102
- _email: () => _email,
19103
- _e164: () => _e164,
19104
- _discriminatedUnion: () => _discriminatedUnion,
19105
- _default: () => _default,
19106
- _decodeAsync: () => _decodeAsync,
19107
- _decode: () => _decode,
19108
- _date: () => _date,
19109
- _custom: () => _custom,
19110
- _cuid2: () => _cuid2,
19111
- _cuid: () => _cuid,
19112
- _coercedString: () => _coercedString,
19113
- _coercedNumber: () => _coercedNumber,
19114
- _coercedDate: () => _coercedDate,
19115
- _coercedBoolean: () => _coercedBoolean,
19116
- _coercedBigint: () => _coercedBigint,
19117
- _cidrv6: () => _cidrv6,
19118
- _cidrv4: () => _cidrv4,
19119
- _check: () => _check,
19120
- _catch: () => _catch,
19121
- _boolean: () => _boolean,
19122
- _bigint: () => _bigint,
19123
- _base64url: () => _base64url,
19124
- _base64: () => _base64,
19125
- _array: () => _array,
19126
- _any: () => _any,
19127
- TimePrecision: () => TimePrecision,
19128
- NEVER: () => NEVER,
19129
- JSONSchemaGenerator: () => JSONSchemaGenerator,
19130
- JSONSchema: () => exports_json_schema,
19131
- Doc: () => Doc,
19132
- $output: () => $output,
19133
- $input: () => $input,
19134
- $constructor: () => $constructor,
19135
- $brand: () => $brand,
19136
- $ZodXor: () => $ZodXor,
19137
- $ZodXID: () => $ZodXID,
19138
- $ZodVoid: () => $ZodVoid,
19139
- $ZodUnknown: () => $ZodUnknown,
19140
- $ZodUnion: () => $ZodUnion,
19141
- $ZodUndefined: () => $ZodUndefined,
19142
- $ZodUUID: () => $ZodUUID,
19143
- $ZodURL: () => $ZodURL,
19144
- $ZodULID: () => $ZodULID,
19145
- $ZodType: () => $ZodType,
19146
- $ZodTuple: () => $ZodTuple,
19147
- $ZodTransform: () => $ZodTransform,
19148
- $ZodTemplateLiteral: () => $ZodTemplateLiteral,
19149
- $ZodSymbol: () => $ZodSymbol,
19150
- $ZodSuccess: () => $ZodSuccess,
19151
- $ZodStringFormat: () => $ZodStringFormat,
19152
- $ZodString: () => $ZodString,
19153
- $ZodSet: () => $ZodSet,
19154
- $ZodRegistry: () => $ZodRegistry,
19155
- $ZodRecord: () => $ZodRecord,
19156
- $ZodRealError: () => $ZodRealError,
19157
- $ZodReadonly: () => $ZodReadonly,
19158
- $ZodPromise: () => $ZodPromise,
19159
- $ZodPreprocess: () => $ZodPreprocess,
19160
- $ZodPrefault: () => $ZodPrefault,
19161
- $ZodPipe: () => $ZodPipe,
19162
- $ZodOptional: () => $ZodOptional,
19163
- $ZodObjectJIT: () => $ZodObjectJIT,
19164
- $ZodObject: () => $ZodObject,
19165
- $ZodNumberFormat: () => $ZodNumberFormat,
19166
- $ZodNumber: () => $ZodNumber,
19167
- $ZodNullable: () => $ZodNullable,
19168
- $ZodNull: () => $ZodNull,
19169
- $ZodNonOptional: () => $ZodNonOptional,
19170
- $ZodNever: () => $ZodNever,
19171
- $ZodNanoID: () => $ZodNanoID,
19172
- $ZodNaN: () => $ZodNaN,
19173
- $ZodMap: () => $ZodMap,
19174
- $ZodMAC: () => $ZodMAC,
19175
- $ZodLiteral: () => $ZodLiteral,
19176
- $ZodLazy: () => $ZodLazy,
19177
- $ZodKSUID: () => $ZodKSUID,
19178
- $ZodJWT: () => $ZodJWT,
19179
- $ZodIntersection: () => $ZodIntersection,
19180
- $ZodISOTime: () => $ZodISOTime,
19181
- $ZodISODuration: () => $ZodISODuration,
19182
- $ZodISODateTime: () => $ZodISODateTime,
19183
- $ZodISODate: () => $ZodISODate,
19184
- $ZodIPv6: () => $ZodIPv6,
19185
- $ZodIPv4: () => $ZodIPv4,
19186
- $ZodGUID: () => $ZodGUID,
19187
- $ZodFunction: () => $ZodFunction,
19188
- $ZodFile: () => $ZodFile,
19189
- $ZodExactOptional: () => $ZodExactOptional,
19190
- $ZodError: () => $ZodError,
19191
- $ZodEnum: () => $ZodEnum,
19192
- $ZodEncodeError: () => $ZodEncodeError,
19193
- $ZodEmoji: () => $ZodEmoji,
19194
- $ZodEmail: () => $ZodEmail,
19195
- $ZodE164: () => $ZodE164,
19196
- $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
19197
- $ZodDefault: () => $ZodDefault,
19198
- $ZodDate: () => $ZodDate,
19199
- $ZodCustomStringFormat: () => $ZodCustomStringFormat,
19200
- $ZodCustom: () => $ZodCustom,
19201
- $ZodCodec: () => $ZodCodec,
19202
- $ZodCheckUpperCase: () => $ZodCheckUpperCase,
19203
- $ZodCheckStringFormat: () => $ZodCheckStringFormat,
19204
- $ZodCheckStartsWith: () => $ZodCheckStartsWith,
19205
- $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
19206
- $ZodCheckRegex: () => $ZodCheckRegex,
19207
- $ZodCheckProperty: () => $ZodCheckProperty,
19208
- $ZodCheckOverwrite: () => $ZodCheckOverwrite,
19209
- $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
19210
- $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
19211
- $ZodCheckMinSize: () => $ZodCheckMinSize,
19212
- $ZodCheckMinLength: () => $ZodCheckMinLength,
19213
- $ZodCheckMimeType: () => $ZodCheckMimeType,
19214
- $ZodCheckMaxSize: () => $ZodCheckMaxSize,
19215
- $ZodCheckMaxLength: () => $ZodCheckMaxLength,
19216
- $ZodCheckLowerCase: () => $ZodCheckLowerCase,
19217
- $ZodCheckLessThan: () => $ZodCheckLessThan,
19218
- $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
19219
- $ZodCheckIncludes: () => $ZodCheckIncludes,
19220
- $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
19221
- $ZodCheckEndsWith: () => $ZodCheckEndsWith,
19222
- $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
19223
- $ZodCheck: () => $ZodCheck,
19224
- $ZodCatch: () => $ZodCatch,
19225
- $ZodCUID2: () => $ZodCUID2,
19226
- $ZodCUID: () => $ZodCUID,
19227
- $ZodCIDRv6: () => $ZodCIDRv6,
19228
- $ZodCIDRv4: () => $ZodCIDRv4,
19229
- $ZodBoolean: () => $ZodBoolean,
19230
- $ZodBigIntFormat: () => $ZodBigIntFormat,
19231
- $ZodBigInt: () => $ZodBigInt,
19232
- $ZodBase64URL: () => $ZodBase64URL,
19233
- $ZodBase64: () => $ZodBase64,
19234
- $ZodAsyncError: () => $ZodAsyncError,
18339
+ $ZodAny: () => $ZodAny,
19235
18340
  $ZodArray: () => $ZodArray,
19236
- $ZodAny: () => $ZodAny
18341
+ $ZodAsyncError: () => $ZodAsyncError,
18342
+ $ZodBase64: () => $ZodBase64,
18343
+ $ZodBase64URL: () => $ZodBase64URL,
18344
+ $ZodBigInt: () => $ZodBigInt,
18345
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
18346
+ $ZodBoolean: () => $ZodBoolean,
18347
+ $ZodCIDRv4: () => $ZodCIDRv4,
18348
+ $ZodCIDRv6: () => $ZodCIDRv6,
18349
+ $ZodCUID: () => $ZodCUID,
18350
+ $ZodCUID2: () => $ZodCUID2,
18351
+ $ZodCatch: () => $ZodCatch,
18352
+ $ZodCheck: () => $ZodCheck,
18353
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
18354
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
18355
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
18356
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
18357
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
18358
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
18359
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
18360
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
18361
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
18362
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
18363
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
18364
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
18365
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
18366
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
18367
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
18368
+ $ZodCheckProperty: () => $ZodCheckProperty,
18369
+ $ZodCheckRegex: () => $ZodCheckRegex,
18370
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
18371
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
18372
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
18373
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
18374
+ $ZodCodec: () => $ZodCodec,
18375
+ $ZodCustom: () => $ZodCustom,
18376
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
18377
+ $ZodDate: () => $ZodDate,
18378
+ $ZodDefault: () => $ZodDefault,
18379
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
18380
+ $ZodE164: () => $ZodE164,
18381
+ $ZodEmail: () => $ZodEmail,
18382
+ $ZodEmoji: () => $ZodEmoji,
18383
+ $ZodEncodeError: () => $ZodEncodeError,
18384
+ $ZodEnum: () => $ZodEnum,
18385
+ $ZodError: () => $ZodError,
18386
+ $ZodExactOptional: () => $ZodExactOptional,
18387
+ $ZodFile: () => $ZodFile,
18388
+ $ZodFunction: () => $ZodFunction,
18389
+ $ZodGUID: () => $ZodGUID,
18390
+ $ZodIPv4: () => $ZodIPv4,
18391
+ $ZodIPv6: () => $ZodIPv6,
18392
+ $ZodISODate: () => $ZodISODate,
18393
+ $ZodISODateTime: () => $ZodISODateTime,
18394
+ $ZodISODuration: () => $ZodISODuration,
18395
+ $ZodISOTime: () => $ZodISOTime,
18396
+ $ZodIntersection: () => $ZodIntersection,
18397
+ $ZodJWT: () => $ZodJWT,
18398
+ $ZodKSUID: () => $ZodKSUID,
18399
+ $ZodLazy: () => $ZodLazy,
18400
+ $ZodLiteral: () => $ZodLiteral,
18401
+ $ZodMAC: () => $ZodMAC,
18402
+ $ZodMap: () => $ZodMap,
18403
+ $ZodNaN: () => $ZodNaN,
18404
+ $ZodNanoID: () => $ZodNanoID,
18405
+ $ZodNever: () => $ZodNever,
18406
+ $ZodNonOptional: () => $ZodNonOptional,
18407
+ $ZodNull: () => $ZodNull,
18408
+ $ZodNullable: () => $ZodNullable,
18409
+ $ZodNumber: () => $ZodNumber,
18410
+ $ZodNumberFormat: () => $ZodNumberFormat,
18411
+ $ZodObject: () => $ZodObject,
18412
+ $ZodObjectJIT: () => $ZodObjectJIT,
18413
+ $ZodOptional: () => $ZodOptional,
18414
+ $ZodPipe: () => $ZodPipe,
18415
+ $ZodPrefault: () => $ZodPrefault,
18416
+ $ZodPreprocess: () => $ZodPreprocess,
18417
+ $ZodPromise: () => $ZodPromise,
18418
+ $ZodReadonly: () => $ZodReadonly,
18419
+ $ZodRealError: () => $ZodRealError,
18420
+ $ZodRecord: () => $ZodRecord,
18421
+ $ZodRegistry: () => $ZodRegistry,
18422
+ $ZodSet: () => $ZodSet,
18423
+ $ZodString: () => $ZodString,
18424
+ $ZodStringFormat: () => $ZodStringFormat,
18425
+ $ZodSuccess: () => $ZodSuccess,
18426
+ $ZodSymbol: () => $ZodSymbol,
18427
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
18428
+ $ZodTransform: () => $ZodTransform,
18429
+ $ZodTuple: () => $ZodTuple,
18430
+ $ZodType: () => $ZodType,
18431
+ $ZodULID: () => $ZodULID,
18432
+ $ZodURL: () => $ZodURL,
18433
+ $ZodUUID: () => $ZodUUID,
18434
+ $ZodUndefined: () => $ZodUndefined,
18435
+ $ZodUnion: () => $ZodUnion,
18436
+ $ZodUnknown: () => $ZodUnknown,
18437
+ $ZodVoid: () => $ZodVoid,
18438
+ $ZodXID: () => $ZodXID,
18439
+ $ZodXor: () => $ZodXor,
18440
+ $brand: () => $brand,
18441
+ $constructor: () => $constructor,
18442
+ $input: () => $input,
18443
+ $output: () => $output,
18444
+ Doc: () => Doc,
18445
+ JSONSchema: () => exports_json_schema,
18446
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
18447
+ NEVER: () => NEVER,
18448
+ TimePrecision: () => TimePrecision,
18449
+ _any: () => _any,
18450
+ _array: () => _array,
18451
+ _base64: () => _base64,
18452
+ _base64url: () => _base64url,
18453
+ _bigint: () => _bigint,
18454
+ _boolean: () => _boolean,
18455
+ _catch: () => _catch,
18456
+ _check: () => _check,
18457
+ _cidrv4: () => _cidrv4,
18458
+ _cidrv6: () => _cidrv6,
18459
+ _coercedBigint: () => _coercedBigint,
18460
+ _coercedBoolean: () => _coercedBoolean,
18461
+ _coercedDate: () => _coercedDate,
18462
+ _coercedNumber: () => _coercedNumber,
18463
+ _coercedString: () => _coercedString,
18464
+ _cuid: () => _cuid,
18465
+ _cuid2: () => _cuid2,
18466
+ _custom: () => _custom,
18467
+ _date: () => _date,
18468
+ _decode: () => _decode,
18469
+ _decodeAsync: () => _decodeAsync,
18470
+ _default: () => _default,
18471
+ _discriminatedUnion: () => _discriminatedUnion,
18472
+ _e164: () => _e164,
18473
+ _email: () => _email,
18474
+ _emoji: () => _emoji2,
18475
+ _encode: () => _encode,
18476
+ _encodeAsync: () => _encodeAsync,
18477
+ _endsWith: () => _endsWith,
18478
+ _enum: () => _enum,
18479
+ _file: () => _file,
18480
+ _float32: () => _float32,
18481
+ _float64: () => _float64,
18482
+ _gt: () => _gt,
18483
+ _gte: () => _gte,
18484
+ _guid: () => _guid,
18485
+ _includes: () => _includes,
18486
+ _int: () => _int,
18487
+ _int32: () => _int32,
18488
+ _int64: () => _int64,
18489
+ _intersection: () => _intersection,
18490
+ _ipv4: () => _ipv4,
18491
+ _ipv6: () => _ipv6,
18492
+ _isoDate: () => _isoDate,
18493
+ _isoDateTime: () => _isoDateTime,
18494
+ _isoDuration: () => _isoDuration,
18495
+ _isoTime: () => _isoTime,
18496
+ _jwt: () => _jwt,
18497
+ _ksuid: () => _ksuid,
18498
+ _lazy: () => _lazy,
18499
+ _length: () => _length,
18500
+ _literal: () => _literal,
18501
+ _lowercase: () => _lowercase,
18502
+ _lt: () => _lt,
18503
+ _lte: () => _lte,
18504
+ _mac: () => _mac,
18505
+ _map: () => _map,
18506
+ _max: () => _lte,
18507
+ _maxLength: () => _maxLength,
18508
+ _maxSize: () => _maxSize,
18509
+ _mime: () => _mime,
18510
+ _min: () => _gte,
18511
+ _minLength: () => _minLength,
18512
+ _minSize: () => _minSize,
18513
+ _multipleOf: () => _multipleOf,
18514
+ _nan: () => _nan,
18515
+ _nanoid: () => _nanoid,
18516
+ _nativeEnum: () => _nativeEnum,
18517
+ _negative: () => _negative,
18518
+ _never: () => _never,
18519
+ _nonnegative: () => _nonnegative,
18520
+ _nonoptional: () => _nonoptional,
18521
+ _nonpositive: () => _nonpositive,
18522
+ _normalize: () => _normalize,
18523
+ _null: () => _null2,
18524
+ _nullable: () => _nullable,
18525
+ _number: () => _number,
18526
+ _optional: () => _optional,
18527
+ _overwrite: () => _overwrite,
18528
+ _parse: () => _parse,
18529
+ _parseAsync: () => _parseAsync,
18530
+ _pipe: () => _pipe,
18531
+ _positive: () => _positive,
18532
+ _promise: () => _promise,
18533
+ _property: () => _property,
18534
+ _readonly: () => _readonly,
18535
+ _record: () => _record,
18536
+ _refine: () => _refine,
18537
+ _regex: () => _regex,
18538
+ _safeDecode: () => _safeDecode,
18539
+ _safeDecodeAsync: () => _safeDecodeAsync,
18540
+ _safeEncode: () => _safeEncode,
18541
+ _safeEncodeAsync: () => _safeEncodeAsync,
18542
+ _safeParse: () => _safeParse,
18543
+ _safeParseAsync: () => _safeParseAsync,
18544
+ _set: () => _set,
18545
+ _size: () => _size,
18546
+ _slugify: () => _slugify,
18547
+ _startsWith: () => _startsWith,
18548
+ _string: () => _string,
18549
+ _stringFormat: () => _stringFormat,
18550
+ _stringbool: () => _stringbool,
18551
+ _success: () => _success,
18552
+ _superRefine: () => _superRefine,
18553
+ _symbol: () => _symbol,
18554
+ _templateLiteral: () => _templateLiteral,
18555
+ _toLowerCase: () => _toLowerCase,
18556
+ _toUpperCase: () => _toUpperCase,
18557
+ _transform: () => _transform,
18558
+ _trim: () => _trim,
18559
+ _tuple: () => _tuple,
18560
+ _uint32: () => _uint32,
18561
+ _uint64: () => _uint64,
18562
+ _ulid: () => _ulid,
18563
+ _undefined: () => _undefined2,
18564
+ _union: () => _union,
18565
+ _unknown: () => _unknown,
18566
+ _uppercase: () => _uppercase,
18567
+ _url: () => _url,
18568
+ _uuid: () => _uuid,
18569
+ _uuidv4: () => _uuidv4,
18570
+ _uuidv6: () => _uuidv6,
18571
+ _uuidv7: () => _uuidv7,
18572
+ _void: () => _void,
18573
+ _xid: () => _xid,
18574
+ _xor: () => _xor,
18575
+ clone: () => clone,
18576
+ config: () => config,
18577
+ createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
18578
+ createToJSONSchemaMethod: () => createToJSONSchemaMethod,
18579
+ decode: () => decode,
18580
+ decodeAsync: () => decodeAsync,
18581
+ describe: () => describe,
18582
+ encode: () => encode,
18583
+ encodeAsync: () => encodeAsync,
18584
+ extractDefs: () => extractDefs,
18585
+ finalize: () => finalize,
18586
+ flattenError: () => flattenError,
18587
+ formatError: () => formatError,
18588
+ globalConfig: () => globalConfig,
18589
+ globalRegistry: () => globalRegistry,
18590
+ initializeContext: () => initializeContext,
18591
+ isValidBase64: () => isValidBase64,
18592
+ isValidBase64URL: () => isValidBase64URL,
18593
+ isValidJWT: () => isValidJWT,
18594
+ locales: () => exports_locales,
18595
+ meta: () => meta,
18596
+ parse: () => parse,
18597
+ parseAsync: () => parseAsync,
18598
+ prettifyError: () => prettifyError,
18599
+ process: () => process2,
18600
+ regexes: () => exports_regexes,
18601
+ registry: () => registry,
18602
+ safeDecode: () => safeDecode,
18603
+ safeDecodeAsync: () => safeDecodeAsync,
18604
+ safeEncode: () => safeEncode,
18605
+ safeEncodeAsync: () => safeEncodeAsync,
18606
+ safeParse: () => safeParse,
18607
+ safeParseAsync: () => safeParseAsync,
18608
+ toDotPath: () => toDotPath,
18609
+ toJSONSchema: () => toJSONSchema,
18610
+ treeifyError: () => treeifyError,
18611
+ util: () => exports_util,
18612
+ version: () => version
19237
18613
  });
19238
18614
 
19239
18615
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
@@ -19317,69 +18693,69 @@ function config(newConfig) {
19317
18693
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
19318
18694
  var exports_util = {};
19319
18695
  __export(exports_util, {
19320
- unwrapMessage: () => unwrapMessage,
19321
- uint8ArrayToHex: () => uint8ArrayToHex,
19322
- uint8ArrayToBase64url: () => uint8ArrayToBase64url,
19323
- uint8ArrayToBase64: () => uint8ArrayToBase64,
19324
- stringifyPrimitive: () => stringifyPrimitive,
19325
- slugify: () => slugify,
19326
- shallowClone: () => shallowClone,
19327
- safeExtend: () => safeExtend,
19328
- required: () => required,
19329
- randomString: () => randomString,
19330
- propertyKeyTypes: () => propertyKeyTypes,
19331
- promiseAllObject: () => promiseAllObject,
19332
- primitiveTypes: () => primitiveTypes,
19333
- prefixIssues: () => prefixIssues,
19334
- pick: () => pick,
19335
- partial: () => partial,
19336
- parsedType: () => parsedType,
19337
- optionalKeys: () => optionalKeys,
19338
- omit: () => omit,
19339
- objectClone: () => objectClone,
19340
- numKeys: () => numKeys,
19341
- nullish: () => nullish,
19342
- normalizeParams: () => normalizeParams,
19343
- mergeDefs: () => mergeDefs,
19344
- merge: () => merge,
19345
- jsonStringifyReplacer: () => jsonStringifyReplacer,
19346
- joinValues: () => joinValues,
19347
- issue: () => issue,
19348
- isPlainObject: () => isPlainObject,
19349
- isObject: () => isObject,
19350
- hexToUint8Array: () => hexToUint8Array,
19351
- getSizableOrigin: () => getSizableOrigin,
19352
- getParsedType: () => getParsedType,
19353
- getLengthableOrigin: () => getLengthableOrigin,
19354
- getEnumValues: () => getEnumValues,
19355
- getElementAtPath: () => getElementAtPath,
19356
- floatSafeRemainder: () => floatSafeRemainder,
19357
- finalizeIssue: () => finalizeIssue,
19358
- extend: () => extend,
19359
- explicitlyAborted: () => explicitlyAborted,
19360
- escapeRegex: () => escapeRegex,
19361
- esc: () => esc,
19362
- defineLazy: () => defineLazy,
19363
- createTransparentProxy: () => createTransparentProxy,
19364
- cloneDef: () => cloneDef,
19365
- clone: () => clone,
19366
- cleanRegex: () => cleanRegex,
19367
- cleanEnum: () => cleanEnum,
19368
- captureStackTrace: () => captureStackTrace,
19369
- cached: () => cached,
19370
- base64urlToUint8Array: () => base64urlToUint8Array,
19371
- base64ToUint8Array: () => base64ToUint8Array,
19372
- assignProp: () => assignProp,
19373
- assertNotEqual: () => assertNotEqual,
19374
- assertNever: () => assertNever,
19375
- assertIs: () => assertIs,
19376
- assertEqual: () => assertEqual,
19377
- assert: () => assert,
19378
- allowsEval: () => allowsEval,
19379
- aborted: () => aborted,
19380
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
18696
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
19381
18697
  Class: () => Class,
19382
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
18698
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
18699
+ aborted: () => aborted,
18700
+ allowsEval: () => allowsEval,
18701
+ assert: () => assert,
18702
+ assertEqual: () => assertEqual,
18703
+ assertIs: () => assertIs,
18704
+ assertNever: () => assertNever,
18705
+ assertNotEqual: () => assertNotEqual,
18706
+ assignProp: () => assignProp,
18707
+ base64ToUint8Array: () => base64ToUint8Array,
18708
+ base64urlToUint8Array: () => base64urlToUint8Array,
18709
+ cached: () => cached,
18710
+ captureStackTrace: () => captureStackTrace,
18711
+ cleanEnum: () => cleanEnum,
18712
+ cleanRegex: () => cleanRegex,
18713
+ clone: () => clone,
18714
+ cloneDef: () => cloneDef,
18715
+ createTransparentProxy: () => createTransparentProxy,
18716
+ defineLazy: () => defineLazy,
18717
+ esc: () => esc,
18718
+ escapeRegex: () => escapeRegex,
18719
+ explicitlyAborted: () => explicitlyAborted,
18720
+ extend: () => extend,
18721
+ finalizeIssue: () => finalizeIssue,
18722
+ floatSafeRemainder: () => floatSafeRemainder,
18723
+ getElementAtPath: () => getElementAtPath,
18724
+ getEnumValues: () => getEnumValues,
18725
+ getLengthableOrigin: () => getLengthableOrigin,
18726
+ getParsedType: () => getParsedType,
18727
+ getSizableOrigin: () => getSizableOrigin,
18728
+ hexToUint8Array: () => hexToUint8Array,
18729
+ isObject: () => isObject,
18730
+ isPlainObject: () => isPlainObject,
18731
+ issue: () => issue,
18732
+ joinValues: () => joinValues,
18733
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
18734
+ merge: () => merge,
18735
+ mergeDefs: () => mergeDefs,
18736
+ normalizeParams: () => normalizeParams,
18737
+ nullish: () => nullish,
18738
+ numKeys: () => numKeys,
18739
+ objectClone: () => objectClone,
18740
+ omit: () => omit,
18741
+ optionalKeys: () => optionalKeys,
18742
+ parsedType: () => parsedType,
18743
+ partial: () => partial,
18744
+ pick: () => pick,
18745
+ prefixIssues: () => prefixIssues,
18746
+ primitiveTypes: () => primitiveTypes,
18747
+ promiseAllObject: () => promiseAllObject,
18748
+ propertyKeyTypes: () => propertyKeyTypes,
18749
+ randomString: () => randomString,
18750
+ required: () => required,
18751
+ safeExtend: () => safeExtend,
18752
+ shallowClone: () => shallowClone,
18753
+ slugify: () => slugify,
18754
+ stringifyPrimitive: () => stringifyPrimitive,
18755
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
18756
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
18757
+ uint8ArrayToHex: () => uint8ArrayToHex,
18758
+ unwrapMessage: () => unwrapMessage
19383
18759
  });
19384
18760
  function assertEqual(val) {
19385
18761
  return val;
@@ -20236,65 +19612,65 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
20236
19612
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/regexes.js
20237
19613
  var exports_regexes = {};
20238
19614
  __export(exports_regexes, {
20239
- xid: () => xid,
20240
- uuid7: () => uuid7,
20241
- uuid6: () => uuid6,
20242
- uuid4: () => uuid4,
20243
- uuid: () => uuid,
20244
- uppercase: () => uppercase,
20245
- unicodeEmail: () => unicodeEmail,
20246
- undefined: () => _undefined,
20247
- ulid: () => ulid,
20248
- time: () => time,
20249
- string: () => string,
20250
- sha512_hex: () => sha512_hex,
20251
- sha512_base64url: () => sha512_base64url,
20252
- sha512_base64: () => sha512_base64,
20253
- sha384_hex: () => sha384_hex,
20254
- sha384_base64url: () => sha384_base64url,
20255
- sha384_base64: () => sha384_base64,
20256
- sha256_hex: () => sha256_hex,
20257
- sha256_base64url: () => sha256_base64url,
20258
- sha256_base64: () => sha256_base64,
20259
- sha1_hex: () => sha1_hex,
20260
- sha1_base64url: () => sha1_base64url,
20261
- sha1_base64: () => sha1_base64,
20262
- rfc5322Email: () => rfc5322Email,
20263
- number: () => number,
20264
- null: () => _null,
20265
- nanoid: () => nanoid,
20266
- md5_hex: () => md5_hex,
20267
- md5_base64url: () => md5_base64url,
20268
- md5_base64: () => md5_base64,
20269
- mac: () => mac,
20270
- lowercase: () => lowercase,
20271
- ksuid: () => ksuid,
20272
- ipv6: () => ipv6,
20273
- ipv4: () => ipv4,
20274
- integer: () => integer,
20275
- idnEmail: () => idnEmail,
20276
- httpProtocol: () => httpProtocol,
20277
- html5Email: () => html5Email,
20278
- hostname: () => hostname2,
20279
- hex: () => hex,
20280
- guid: () => guid,
20281
- extendedDuration: () => extendedDuration,
20282
- emoji: () => emoji,
20283
- email: () => email,
20284
- e164: () => e164,
20285
- duration: () => duration,
20286
- domain: () => domain,
20287
- datetime: () => datetime,
20288
- date: () => date,
20289
- cuid2: () => cuid2,
20290
- cuid: () => cuid,
20291
- cidrv6: () => cidrv6,
20292
- cidrv4: () => cidrv4,
20293
- browserEmail: () => browserEmail,
20294
- boolean: () => boolean,
20295
- bigint: () => bigint,
19615
+ base64: () => base64,
20296
19616
  base64url: () => base64url,
20297
- base64: () => base64
19617
+ bigint: () => bigint,
19618
+ boolean: () => boolean,
19619
+ browserEmail: () => browserEmail,
19620
+ cidrv4: () => cidrv4,
19621
+ cidrv6: () => cidrv6,
19622
+ cuid: () => cuid,
19623
+ cuid2: () => cuid2,
19624
+ date: () => date,
19625
+ datetime: () => datetime,
19626
+ domain: () => domain,
19627
+ duration: () => duration,
19628
+ e164: () => e164,
19629
+ email: () => email,
19630
+ emoji: () => emoji,
19631
+ extendedDuration: () => extendedDuration,
19632
+ guid: () => guid,
19633
+ hex: () => hex,
19634
+ hostname: () => hostname2,
19635
+ html5Email: () => html5Email,
19636
+ httpProtocol: () => httpProtocol,
19637
+ idnEmail: () => idnEmail,
19638
+ integer: () => integer,
19639
+ ipv4: () => ipv4,
19640
+ ipv6: () => ipv6,
19641
+ ksuid: () => ksuid,
19642
+ lowercase: () => lowercase,
19643
+ mac: () => mac,
19644
+ md5_base64: () => md5_base64,
19645
+ md5_base64url: () => md5_base64url,
19646
+ md5_hex: () => md5_hex,
19647
+ nanoid: () => nanoid,
19648
+ null: () => _null,
19649
+ number: () => number,
19650
+ rfc5322Email: () => rfc5322Email,
19651
+ sha1_base64: () => sha1_base64,
19652
+ sha1_base64url: () => sha1_base64url,
19653
+ sha1_hex: () => sha1_hex,
19654
+ sha256_base64: () => sha256_base64,
19655
+ sha256_base64url: () => sha256_base64url,
19656
+ sha256_hex: () => sha256_hex,
19657
+ sha384_base64: () => sha384_base64,
19658
+ sha384_base64url: () => sha384_base64url,
19659
+ sha384_hex: () => sha384_hex,
19660
+ sha512_base64: () => sha512_base64,
19661
+ sha512_base64url: () => sha512_base64url,
19662
+ sha512_hex: () => sha512_hex,
19663
+ string: () => string,
19664
+ time: () => time,
19665
+ ulid: () => ulid,
19666
+ undefined: () => _undefined,
19667
+ unicodeEmail: () => unicodeEmail,
19668
+ uppercase: () => uppercase,
19669
+ uuid: () => uuid,
19670
+ uuid4: () => uuid4,
19671
+ uuid6: () => uuid6,
19672
+ uuid7: () => uuid7,
19673
+ xid: () => xid
20298
19674
  });
20299
19675
  var cuid = /^[cC][0-9a-z]{6,}$/;
20300
19676
  var cuid2 = /^[0-9a-z]+$/;
@@ -23071,58 +22447,58 @@ function handleRefineResult(result, payload, input, inst) {
23071
22447
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/index.js
23072
22448
  var exports_locales = {};
23073
22449
  __export(exports_locales, {
23074
- zhTW: () => zh_TW_default,
23075
- zhCN: () => zh_CN_default,
23076
- yo: () => yo_default,
23077
- vi: () => vi_default,
23078
- uz: () => uz_default,
23079
- ur: () => ur_default,
23080
- uk: () => uk_default,
23081
- ua: () => ua_default,
23082
- tr: () => tr_default,
23083
- th: () => th_default,
23084
- ta: () => ta_default,
23085
- sv: () => sv_default,
23086
- sl: () => sl_default,
23087
- ru: () => ru_default,
23088
- ro: () => ro_default,
23089
- pt: () => pt_default,
23090
- ps: () => ps_default,
23091
- pl: () => pl_default,
23092
- ota: () => ota_default,
23093
- no: () => no_default,
23094
- nl: () => nl_default,
23095
- ms: () => ms_default,
23096
- mk: () => mk_default,
23097
- lt: () => lt_default,
23098
- ko: () => ko_default,
23099
- km: () => km_default,
23100
- kh: () => kh_default,
23101
- ka: () => ka_default,
23102
- ja: () => ja_default,
23103
- it: () => it_default,
23104
- is: () => is_default,
23105
- id: () => id_default,
23106
- hy: () => hy_default,
23107
- hu: () => hu_default,
23108
- hr: () => hr_default,
23109
- he: () => he_default,
23110
- frCA: () => fr_CA_default,
23111
- fr: () => fr_default,
23112
- fi: () => fi_default,
23113
- fa: () => fa_default,
23114
- es: () => es_default,
23115
- eo: () => eo_default,
23116
- en: () => en_default,
23117
- el: () => el_default,
23118
- de: () => de_default,
23119
- da: () => da_default,
23120
- cs: () => cs_default,
23121
- ca: () => ca_default,
23122
- bg: () => bg_default,
23123
- be: () => be_default,
22450
+ ar: () => ar_default,
23124
22451
  az: () => az_default,
23125
- ar: () => ar_default
22452
+ be: () => be_default,
22453
+ bg: () => bg_default,
22454
+ ca: () => ca_default,
22455
+ cs: () => cs_default,
22456
+ da: () => da_default,
22457
+ de: () => de_default,
22458
+ el: () => el_default,
22459
+ en: () => en_default,
22460
+ eo: () => eo_default,
22461
+ es: () => es_default,
22462
+ fa: () => fa_default,
22463
+ fi: () => fi_default,
22464
+ fr: () => fr_default,
22465
+ frCA: () => fr_CA_default,
22466
+ he: () => he_default,
22467
+ hr: () => hr_default,
22468
+ hu: () => hu_default,
22469
+ hy: () => hy_default,
22470
+ id: () => id_default,
22471
+ is: () => is_default,
22472
+ it: () => it_default,
22473
+ ja: () => ja_default,
22474
+ ka: () => ka_default,
22475
+ kh: () => kh_default,
22476
+ km: () => km_default,
22477
+ ko: () => ko_default,
22478
+ lt: () => lt_default,
22479
+ mk: () => mk_default,
22480
+ ms: () => ms_default,
22481
+ nl: () => nl_default,
22482
+ no: () => no_default,
22483
+ ota: () => ota_default,
22484
+ pl: () => pl_default,
22485
+ ps: () => ps_default,
22486
+ pt: () => pt_default,
22487
+ ro: () => ro_default,
22488
+ ru: () => ru_default,
22489
+ sl: () => sl_default,
22490
+ sv: () => sv_default,
22491
+ ta: () => ta_default,
22492
+ th: () => th_default,
22493
+ tr: () => tr_default,
22494
+ ua: () => ua_default,
22495
+ uk: () => uk_default,
22496
+ ur: () => ur_default,
22497
+ uz: () => uz_default,
22498
+ vi: () => vi_default,
22499
+ yo: () => yo_default,
22500
+ zhCN: () => zh_CN_default,
22501
+ zhTW: () => zh_TW_default
23126
22502
  });
23127
22503
 
23128
22504
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/ar.js
@@ -30893,219 +30269,219 @@ var exports_json_schema = {};
30893
30269
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
30894
30270
  var exports_schemas2 = {};
30895
30271
  __export(exports_schemas2, {
30896
- xor: () => xor,
30897
- xid: () => xid2,
30898
- void: () => _void2,
30899
- uuidv7: () => uuidv7,
30900
- uuidv6: () => uuidv6,
30901
- uuidv4: () => uuidv4,
30902
- uuid: () => uuid2,
30903
- url: () => url,
30904
- unknown: () => unknown,
30905
- union: () => union,
30906
- undefined: () => _undefined3,
30907
- ulid: () => ulid2,
30908
- uint64: () => uint64,
30909
- uint32: () => uint32,
30910
- tuple: () => tuple,
30911
- transform: () => transform,
30912
- templateLiteral: () => templateLiteral,
30913
- symbol: () => symbol,
30914
- superRefine: () => superRefine,
30915
- success: () => success,
30916
- stringbool: () => stringbool,
30917
- stringFormat: () => stringFormat,
30918
- string: () => string2,
30919
- strictObject: () => strictObject,
30920
- set: () => set,
30921
- refine: () => refine,
30922
- record: () => record,
30923
- readonly: () => readonly,
30924
- promise: () => promise,
30925
- preprocess: () => preprocess,
30926
- prefault: () => prefault,
30927
- pipe: () => pipe,
30928
- partialRecord: () => partialRecord,
30929
- optional: () => optional,
30930
- object: () => object,
30931
- number: () => number2,
30932
- nullish: () => nullish2,
30933
- nullable: () => nullable,
30934
- null: () => _null3,
30935
- nonoptional: () => nonoptional,
30936
- never: () => never,
30937
- nativeEnum: () => nativeEnum,
30938
- nanoid: () => nanoid2,
30939
- nan: () => nan,
30940
- meta: () => meta2,
30941
- map: () => map,
30942
- mac: () => mac2,
30943
- looseRecord: () => looseRecord,
30944
- looseObject: () => looseObject,
30945
- literal: () => literal,
30946
- lazy: () => lazy,
30947
- ksuid: () => ksuid2,
30948
- keyof: () => keyof,
30949
- jwt: () => jwt,
30950
- json: () => json,
30951
- ipv6: () => ipv62,
30952
- ipv4: () => ipv42,
30953
- invertCodec: () => invertCodec,
30954
- intersection: () => intersection,
30955
- int64: () => int64,
30956
- int32: () => int32,
30957
- int: () => int,
30958
- instanceof: () => _instanceof,
30959
- httpUrl: () => httpUrl,
30960
- hostname: () => hostname3,
30961
- hex: () => hex2,
30962
- hash: () => hash,
30963
- guid: () => guid2,
30964
- function: () => _function,
30965
- float64: () => float64,
30966
- float32: () => float32,
30967
- file: () => file,
30968
- exactOptional: () => exactOptional,
30969
- enum: () => _enum2,
30970
- emoji: () => emoji2,
30971
- email: () => email2,
30972
- e164: () => e1642,
30973
- discriminatedUnion: () => discriminatedUnion,
30974
- describe: () => describe2,
30975
- date: () => date3,
30976
- custom: () => custom,
30977
- cuid2: () => cuid22,
30978
- cuid: () => cuid3,
30979
- codec: () => codec,
30980
- cidrv6: () => cidrv62,
30981
- cidrv4: () => cidrv42,
30982
- check: () => check,
30983
- catch: () => _catch2,
30984
- boolean: () => boolean2,
30985
- bigint: () => bigint2,
30986
- base64url: () => base64url2,
30987
- base64: () => base642,
30988
- array: () => array,
30989
- any: () => any,
30990
- _function: () => _function,
30991
- _default: () => _default2,
30992
- _ZodString: () => _ZodString,
30993
- ZodXor: () => ZodXor,
30994
- ZodXID: () => ZodXID,
30995
- ZodVoid: () => ZodVoid,
30996
- ZodUnknown: () => ZodUnknown,
30997
- ZodUnion: () => ZodUnion,
30998
- ZodUndefined: () => ZodUndefined,
30999
- ZodUUID: () => ZodUUID,
31000
- ZodURL: () => ZodURL,
31001
- ZodULID: () => ZodULID,
31002
- ZodType: () => ZodType,
31003
- ZodTuple: () => ZodTuple,
31004
- ZodTransform: () => ZodTransform,
31005
- ZodTemplateLiteral: () => ZodTemplateLiteral,
31006
- ZodSymbol: () => ZodSymbol,
31007
- ZodSuccess: () => ZodSuccess,
31008
- ZodStringFormat: () => ZodStringFormat,
31009
- ZodString: () => ZodString,
31010
- ZodSet: () => ZodSet,
31011
- ZodRecord: () => ZodRecord,
31012
- ZodReadonly: () => ZodReadonly,
31013
- ZodPromise: () => ZodPromise,
31014
- ZodPreprocess: () => ZodPreprocess,
31015
- ZodPrefault: () => ZodPrefault,
31016
- ZodPipe: () => ZodPipe,
31017
- ZodOptional: () => ZodOptional,
31018
- ZodObject: () => ZodObject,
31019
- ZodNumberFormat: () => ZodNumberFormat,
31020
- ZodNumber: () => ZodNumber,
31021
- ZodNullable: () => ZodNullable,
31022
- ZodNull: () => ZodNull,
31023
- ZodNonOptional: () => ZodNonOptional,
31024
- ZodNever: () => ZodNever,
31025
- ZodNanoID: () => ZodNanoID,
31026
- ZodNaN: () => ZodNaN,
31027
- ZodMap: () => ZodMap,
31028
- ZodMAC: () => ZodMAC,
31029
- ZodLiteral: () => ZodLiteral,
31030
- ZodLazy: () => ZodLazy,
31031
- ZodKSUID: () => ZodKSUID,
31032
- ZodJWT: () => ZodJWT,
31033
- ZodIntersection: () => ZodIntersection,
31034
- ZodIPv6: () => ZodIPv6,
31035
- ZodIPv4: () => ZodIPv4,
31036
- ZodGUID: () => ZodGUID,
31037
- ZodFunction: () => ZodFunction,
31038
- ZodFile: () => ZodFile,
31039
- ZodExactOptional: () => ZodExactOptional,
31040
- ZodEnum: () => ZodEnum,
31041
- ZodEmoji: () => ZodEmoji,
31042
- ZodEmail: () => ZodEmail,
31043
- ZodE164: () => ZodE164,
31044
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
31045
- ZodDefault: () => ZodDefault,
31046
- ZodDate: () => ZodDate,
31047
- ZodCustomStringFormat: () => ZodCustomStringFormat,
31048
- ZodCustom: () => ZodCustom,
31049
- ZodCodec: () => ZodCodec,
31050
- ZodCatch: () => ZodCatch,
31051
- ZodCUID2: () => ZodCUID2,
31052
- ZodCUID: () => ZodCUID,
31053
- ZodCIDRv6: () => ZodCIDRv6,
31054
- ZodCIDRv4: () => ZodCIDRv4,
31055
- ZodBoolean: () => ZodBoolean,
31056
- ZodBigIntFormat: () => ZodBigIntFormat,
31057
- ZodBigInt: () => ZodBigInt,
31058
- ZodBase64URL: () => ZodBase64URL,
31059
- ZodBase64: () => ZodBase64,
30272
+ ZodAny: () => ZodAny,
31060
30273
  ZodArray: () => ZodArray,
31061
- ZodAny: () => ZodAny
30274
+ ZodBase64: () => ZodBase64,
30275
+ ZodBase64URL: () => ZodBase64URL,
30276
+ ZodBigInt: () => ZodBigInt,
30277
+ ZodBigIntFormat: () => ZodBigIntFormat,
30278
+ ZodBoolean: () => ZodBoolean,
30279
+ ZodCIDRv4: () => ZodCIDRv4,
30280
+ ZodCIDRv6: () => ZodCIDRv6,
30281
+ ZodCUID: () => ZodCUID,
30282
+ ZodCUID2: () => ZodCUID2,
30283
+ ZodCatch: () => ZodCatch,
30284
+ ZodCodec: () => ZodCodec,
30285
+ ZodCustom: () => ZodCustom,
30286
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
30287
+ ZodDate: () => ZodDate,
30288
+ ZodDefault: () => ZodDefault,
30289
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
30290
+ ZodE164: () => ZodE164,
30291
+ ZodEmail: () => ZodEmail,
30292
+ ZodEmoji: () => ZodEmoji,
30293
+ ZodEnum: () => ZodEnum,
30294
+ ZodExactOptional: () => ZodExactOptional,
30295
+ ZodFile: () => ZodFile,
30296
+ ZodFunction: () => ZodFunction,
30297
+ ZodGUID: () => ZodGUID,
30298
+ ZodIPv4: () => ZodIPv4,
30299
+ ZodIPv6: () => ZodIPv6,
30300
+ ZodIntersection: () => ZodIntersection,
30301
+ ZodJWT: () => ZodJWT,
30302
+ ZodKSUID: () => ZodKSUID,
30303
+ ZodLazy: () => ZodLazy,
30304
+ ZodLiteral: () => ZodLiteral,
30305
+ ZodMAC: () => ZodMAC,
30306
+ ZodMap: () => ZodMap,
30307
+ ZodNaN: () => ZodNaN,
30308
+ ZodNanoID: () => ZodNanoID,
30309
+ ZodNever: () => ZodNever,
30310
+ ZodNonOptional: () => ZodNonOptional,
30311
+ ZodNull: () => ZodNull,
30312
+ ZodNullable: () => ZodNullable,
30313
+ ZodNumber: () => ZodNumber,
30314
+ ZodNumberFormat: () => ZodNumberFormat,
30315
+ ZodObject: () => ZodObject,
30316
+ ZodOptional: () => ZodOptional,
30317
+ ZodPipe: () => ZodPipe,
30318
+ ZodPrefault: () => ZodPrefault,
30319
+ ZodPreprocess: () => ZodPreprocess,
30320
+ ZodPromise: () => ZodPromise,
30321
+ ZodReadonly: () => ZodReadonly,
30322
+ ZodRecord: () => ZodRecord,
30323
+ ZodSet: () => ZodSet,
30324
+ ZodString: () => ZodString,
30325
+ ZodStringFormat: () => ZodStringFormat,
30326
+ ZodSuccess: () => ZodSuccess,
30327
+ ZodSymbol: () => ZodSymbol,
30328
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
30329
+ ZodTransform: () => ZodTransform,
30330
+ ZodTuple: () => ZodTuple,
30331
+ ZodType: () => ZodType,
30332
+ ZodULID: () => ZodULID,
30333
+ ZodURL: () => ZodURL,
30334
+ ZodUUID: () => ZodUUID,
30335
+ ZodUndefined: () => ZodUndefined,
30336
+ ZodUnion: () => ZodUnion,
30337
+ ZodUnknown: () => ZodUnknown,
30338
+ ZodVoid: () => ZodVoid,
30339
+ ZodXID: () => ZodXID,
30340
+ ZodXor: () => ZodXor,
30341
+ _ZodString: () => _ZodString,
30342
+ _default: () => _default2,
30343
+ _function: () => _function,
30344
+ any: () => any,
30345
+ array: () => array,
30346
+ base64: () => base642,
30347
+ base64url: () => base64url2,
30348
+ bigint: () => bigint2,
30349
+ boolean: () => boolean2,
30350
+ catch: () => _catch2,
30351
+ check: () => check,
30352
+ cidrv4: () => cidrv42,
30353
+ cidrv6: () => cidrv62,
30354
+ codec: () => codec,
30355
+ cuid: () => cuid3,
30356
+ cuid2: () => cuid22,
30357
+ custom: () => custom,
30358
+ date: () => date3,
30359
+ describe: () => describe2,
30360
+ discriminatedUnion: () => discriminatedUnion,
30361
+ e164: () => e1642,
30362
+ email: () => email2,
30363
+ emoji: () => emoji2,
30364
+ enum: () => _enum2,
30365
+ exactOptional: () => exactOptional,
30366
+ file: () => file,
30367
+ float32: () => float32,
30368
+ float64: () => float64,
30369
+ function: () => _function,
30370
+ guid: () => guid2,
30371
+ hash: () => hash,
30372
+ hex: () => hex2,
30373
+ hostname: () => hostname3,
30374
+ httpUrl: () => httpUrl,
30375
+ instanceof: () => _instanceof,
30376
+ int: () => int,
30377
+ int32: () => int32,
30378
+ int64: () => int64,
30379
+ intersection: () => intersection,
30380
+ invertCodec: () => invertCodec,
30381
+ ipv4: () => ipv42,
30382
+ ipv6: () => ipv62,
30383
+ json: () => json,
30384
+ jwt: () => jwt,
30385
+ keyof: () => keyof,
30386
+ ksuid: () => ksuid2,
30387
+ lazy: () => lazy,
30388
+ literal: () => literal,
30389
+ looseObject: () => looseObject,
30390
+ looseRecord: () => looseRecord,
30391
+ mac: () => mac2,
30392
+ map: () => map,
30393
+ meta: () => meta2,
30394
+ nan: () => nan,
30395
+ nanoid: () => nanoid2,
30396
+ nativeEnum: () => nativeEnum,
30397
+ never: () => never,
30398
+ nonoptional: () => nonoptional,
30399
+ null: () => _null3,
30400
+ nullable: () => nullable,
30401
+ nullish: () => nullish2,
30402
+ number: () => number2,
30403
+ object: () => object,
30404
+ optional: () => optional,
30405
+ partialRecord: () => partialRecord,
30406
+ pipe: () => pipe,
30407
+ prefault: () => prefault,
30408
+ preprocess: () => preprocess,
30409
+ promise: () => promise,
30410
+ readonly: () => readonly,
30411
+ record: () => record,
30412
+ refine: () => refine,
30413
+ set: () => set,
30414
+ strictObject: () => strictObject,
30415
+ string: () => string2,
30416
+ stringFormat: () => stringFormat,
30417
+ stringbool: () => stringbool,
30418
+ success: () => success,
30419
+ superRefine: () => superRefine,
30420
+ symbol: () => symbol,
30421
+ templateLiteral: () => templateLiteral,
30422
+ transform: () => transform,
30423
+ tuple: () => tuple,
30424
+ uint32: () => uint32,
30425
+ uint64: () => uint64,
30426
+ ulid: () => ulid2,
30427
+ undefined: () => _undefined3,
30428
+ union: () => union,
30429
+ unknown: () => unknown,
30430
+ url: () => url,
30431
+ uuid: () => uuid2,
30432
+ uuidv4: () => uuidv4,
30433
+ uuidv6: () => uuidv6,
30434
+ uuidv7: () => uuidv7,
30435
+ void: () => _void2,
30436
+ xid: () => xid2,
30437
+ xor: () => xor
31062
30438
  });
31063
30439
 
31064
30440
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/checks.js
31065
30441
  var exports_checks2 = {};
31066
30442
  __export(exports_checks2, {
31067
- uppercase: () => _uppercase,
31068
- trim: () => _trim,
31069
- toUpperCase: () => _toUpperCase,
31070
- toLowerCase: () => _toLowerCase,
31071
- startsWith: () => _startsWith,
31072
- slugify: () => _slugify,
31073
- size: () => _size,
31074
- regex: () => _regex,
31075
- property: () => _property,
31076
- positive: () => _positive,
31077
- overwrite: () => _overwrite,
31078
- normalize: () => _normalize,
31079
- nonpositive: () => _nonpositive,
31080
- nonnegative: () => _nonnegative,
31081
- negative: () => _negative,
31082
- multipleOf: () => _multipleOf,
31083
- minSize: () => _minSize,
31084
- minLength: () => _minLength,
31085
- mime: () => _mime,
31086
- maxSize: () => _maxSize,
31087
- maxLength: () => _maxLength,
31088
- lte: () => _lte,
31089
- lt: () => _lt,
31090
- lowercase: () => _lowercase,
31091
- length: () => _length,
31092
- includes: () => _includes,
31093
- gte: () => _gte,
30443
+ endsWith: () => _endsWith,
31094
30444
  gt: () => _gt,
31095
- endsWith: () => _endsWith
30445
+ gte: () => _gte,
30446
+ includes: () => _includes,
30447
+ length: () => _length,
30448
+ lowercase: () => _lowercase,
30449
+ lt: () => _lt,
30450
+ lte: () => _lte,
30451
+ maxLength: () => _maxLength,
30452
+ maxSize: () => _maxSize,
30453
+ mime: () => _mime,
30454
+ minLength: () => _minLength,
30455
+ minSize: () => _minSize,
30456
+ multipleOf: () => _multipleOf,
30457
+ negative: () => _negative,
30458
+ nonnegative: () => _nonnegative,
30459
+ nonpositive: () => _nonpositive,
30460
+ normalize: () => _normalize,
30461
+ overwrite: () => _overwrite,
30462
+ positive: () => _positive,
30463
+ property: () => _property,
30464
+ regex: () => _regex,
30465
+ size: () => _size,
30466
+ slugify: () => _slugify,
30467
+ startsWith: () => _startsWith,
30468
+ toLowerCase: () => _toLowerCase,
30469
+ toUpperCase: () => _toUpperCase,
30470
+ trim: () => _trim,
30471
+ uppercase: () => _uppercase
31096
30472
  });
31097
30473
 
31098
30474
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
31099
30475
  var exports_iso = {};
31100
30476
  __export(exports_iso, {
31101
- time: () => time2,
31102
- duration: () => duration2,
31103
- datetime: () => datetime2,
31104
- date: () => date2,
31105
- ZodISOTime: () => ZodISOTime,
31106
- ZodISODuration: () => ZodISODuration,
30477
+ ZodISODate: () => ZodISODate,
31107
30478
  ZodISODateTime: () => ZodISODateTime,
31108
- ZodISODate: () => ZodISODate
30479
+ ZodISODuration: () => ZodISODuration,
30480
+ ZodISOTime: () => ZodISOTime,
30481
+ date: () => date2,
30482
+ datetime: () => datetime2,
30483
+ duration: () => duration2,
30484
+ time: () => time2
31109
30485
  });
31110
30486
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
31111
30487
  $ZodISODateTime.init(inst, def);
@@ -32966,11 +32342,11 @@ function fromJSONSchema(schema, params) {
32966
32342
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/coerce.js
32967
32343
  var exports_coerce = {};
32968
32344
  __export(exports_coerce, {
32969
- string: () => string3,
32970
- number: () => number3,
32971
- date: () => date4,
32345
+ bigint: () => bigint3,
32972
32346
  boolean: () => boolean3,
32973
- bigint: () => bigint3
32347
+ date: () => date4,
32348
+ number: () => number3,
32349
+ string: () => string3
32974
32350
  });
32975
32351
  function string3(params) {
32976
32352
  return _coercedString(ZodString, params);
@@ -32991,6 +32367,15 @@ function date4(params) {
32991
32367
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
32992
32368
  config(en_default());
32993
32369
  // src/config.ts
32370
+ var DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 120000;
32371
+ var MIN_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 1e4;
32372
+ var MAX_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 600000;
32373
+ function clampInspectDiagnosticsTimeoutMs(value) {
32374
+ return Math.min(MAX_INSPECT_DIAGNOSTICS_TIMEOUT_MS, Math.max(MIN_INSPECT_DIAGNOSTICS_TIMEOUT_MS, value));
32375
+ }
32376
+ function resolveInspectDiagnosticsTimeoutMs(config2) {
32377
+ return clampInspectDiagnosticsTimeoutMs(config2.inspect?.diagnostics_timeout_ms ?? DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS);
32378
+ }
32994
32379
  var FOREGROUND_WAIT_WINDOW_DEFAULT_MS = 15000;
32995
32380
  var FOREGROUND_WAIT_WINDOW_MIN_MS = 5000;
32996
32381
  function resolveBashConfig(config2) {
@@ -33130,8 +32515,12 @@ var SubcConfigSchema = exports_external.object({
33130
32515
  client_reaper: exports_external.boolean().optional(),
33131
32516
  connection_file: exports_external.string().optional()
33132
32517
  });
32518
+ var GhShimConfigSchema = exports_external.object({
32519
+ enabled: exports_external.boolean().optional()
32520
+ });
33133
32521
  var InspectConfigSchema = exports_external.object({
33134
32522
  enabled: exports_external.boolean().optional(),
32523
+ diagnostics_timeout_ms: exports_external.number().int().positive().optional().transform((value) => value === undefined ? undefined : clampInspectDiagnosticsTimeoutMs(value)),
33135
32524
  tier2_idle_minutes: exports_external.number().min(0).optional(),
33136
32525
  categories: exports_external.record(exports_external.string(), exports_external.boolean()).optional(),
33137
32526
  tier2_soft_deadline_ms: exports_external.number().int().positive().optional(),
@@ -33175,7 +32564,8 @@ var AftConfigSchema = exports_external.preprocess((value) => stripHarnessSpecifi
33175
32564
  url_fetch_allow_private: exports_external.boolean().optional(),
33176
32565
  semantic: SemanticConfigSchema.optional(),
33177
32566
  bridge: BridgeConfigSchema.optional(),
33178
- subc: SubcConfigSchema.optional()
32567
+ subc: SubcConfigSchema.optional(),
32568
+ gh_shim: GhShimConfigSchema.optional()
33179
32569
  }).strict());
33180
32570
  var CONFIG_MIGRATIONS = [
33181
32571
  { oldKey: "experimental_search_index", newPath: ["search_index"] },
@@ -33434,9 +32824,12 @@ function mergeWorktreeConfig(baseWorktree, overrideWorktree) {
33434
32824
  return { ...baseWorktree, ...overrideWorktree };
33435
32825
  }
33436
32826
  function mergeInspectConfig(baseInspect, overrideInspect) {
32827
+ const diagnosticsTimeoutConfigured = baseInspect?.diagnostics_timeout_ms !== undefined || overrideInspect?.diagnostics_timeout_ms !== undefined;
32828
+ const diagnosticsTimeoutMs = Math.max(clampInspectDiagnosticsTimeoutMs(baseInspect?.diagnostics_timeout_ms ?? DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS), clampInspectDiagnosticsTimeoutMs(overrideInspect?.diagnostics_timeout_ms ?? DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS));
33437
32829
  const inspect = {
33438
32830
  ...baseInspect,
33439
32831
  ...overrideInspect,
32832
+ ...diagnosticsTimeoutConfigured ? { diagnostics_timeout_ms: diagnosticsTimeoutMs } : {},
33440
32833
  duplicates: baseInspect?.duplicates || overrideInspect?.duplicates ? {
33441
32834
  ...baseInspect?.duplicates,
33442
32835
  ...overrideInspect?.duplicates
@@ -33547,6 +32940,8 @@ function getStrippedTopLevelKeys(override) {
33547
32940
  stripped.push("sandbox.write_allow");
33548
32941
  if (override.subc !== undefined)
33549
32942
  stripped.push("subc");
32943
+ if (override.gh_shim !== undefined)
32944
+ stripped.push("gh_shim");
33550
32945
  if (override.disabled_tools?.includes("aft_safety"))
33551
32946
  stripped.push("disabled_tools.aft_safety");
33552
32947
  return stripped;
@@ -35840,6 +35235,16 @@ var EditParams = Type2.Object({
35840
35235
  description: "Batch edits — non-empty array of { oldString, newString }, { oldString, newString, replaceAll: true }, or { startLine, endLine, content } objects applied atomically."
35841
35236
  }))
35842
35237
  });
35238
+ var HASHLINE_EDIT_DESCRIPTION = [
35239
+ "Apply a hashline patch. Arguments are exactly `{patch}` where `patch` is a non-empty string. Server-owned preview control is outside this schema.",
35240
+ "",
35241
+ "Quick reference:",
35242
+ "- Header: `[path#TAG]`; TAG is exactly four hexadecimal digits from a current tagged read. Read every addressed row and gap boundary; REM and MV require a whole-file tagged read. Re-read after an edit before chaining: an edit-response tag can retain only changed context.",
35243
+ "- Addresses: `0` (BOF), `N` (one line), `N.=M` (range; `N..=M`/`N..M` also work), `<N`/`>N` (gap before/after), `N*`/`<N*`/`>N*` (block), and `$`/`$-K` (EOF-relative). A plain `N` PUT replaces; use `<N` or `>N` to insert.",
35244
+ "- PUT text: `PUT <address>:` followed by one or more `+` body rows (`+` alone is blank). A final patch newline is allowed. PUT without `:` copies `@name` (or the anonymous register) and takes no body; names use `@` plus ASCII letters, digits, `_`, or `-`.",
35245
+ "- CUT: `CUT <address> [@name]`. REM: bare `REM` only, removing the whole file. MV: `MV <destination>` (one whitespace-free path, optional matching quotes), once and after any line operations. `*** Begin Patch`/`*** End Patch` is an optional envelope."
35246
+ ].join(`
35247
+ `);
35843
35248
  var HashlineEditParams = Type2.Object({
35844
35249
  patch: Type2.String({
35845
35250
  minLength: 1,
@@ -36017,7 +35422,7 @@ PDFs aren't supported on the Pi harness yet.`, response);
36017
35422
  pi.registerTool({
36018
35423
  name: "edit",
36019
35424
  label: "edit",
36020
- description: "Apply a hashline patch. Arguments are exactly `{patch}` where `patch` is a non-empty string of one or more `[path#TAG]` sections with PUT/CUT/REM/MV operations. Paths and tags come from section headers; obtain tags from tagged reads. Server-owned preview control is outside this schema.",
35425
+ description: HASHLINE_EDIT_DESCRIPTION,
36021
35426
  promptSnippet: "Apply a tagged hashline patch through the edit tool",
36022
35427
  promptGuidelines: [
36023
35428
  "Read a file to obtain its current hashline tag before editing it.",
@@ -36883,6 +36288,7 @@ function registerBashTool(pi, ctx, aftSearchRegistered = false) {
36883
36288
  const spawnHook = getBashSpawnHook(pi);
36884
36289
  const searchSteer = aftSearchRegistered ? "use `aft_search` (concepts, identifiers, regex, literals), `read`, `aft_outline`, or `aft_zoom` instead" : "use the `grep` tool, `read`, `aft_outline`, or `aft_zoom` instead";
36885
36290
  const bashCfg = resolveBashConfig(ctx.config);
36291
+ let hostFallbackActive = false;
36886
36292
  const compressionSentence = bashCfg.compress ? " Output is compressed by default; pass `compressed: false` for raw output. Piped commands run verbatim and show the pipeline's output; for AFT's test/build summary, run the runner without `| head`, `| tail`, or `| grep`." : "";
36887
36293
  const tasksSentence = bashCfg.background ? ' Commands run in the foreground and return inline; `wait: true` blocks until a long command finishes instead of auto-promoting, but detaches to background if you send a new message — use it when you need the result before doing anything else; keep it off otherwise so auto-promote can remind you while you work. Use `background: true` yourself ONLY when you have other useful work to do while it runs; then `bash_watch` waits on the task (sync blocks until exit/pattern, async notifies) and `bash_status` peeks at it — never background a command and immediately `bash_watch` it (that wastes a turn for what foreground returns in one), and never loop `bash_status` to wait. `pty: true` runs interactive programs (REPLs, TUIs), implies background, and is driven with `bash_status({ output_mode: "screen" })` plus `bash_write`.' : " Commands run in the foreground to completion; `timeout` is the hard kill cap (default 30 minutes).";
36888
36294
  pi.registerTool({
@@ -36988,10 +36394,13 @@ DO NOT use bash for code search or code exploration. If you are about to run gre
36988
36394
  env: spawnContext.env
36989
36395
  });
36990
36396
  usedHostFallback = true;
36397
+ hostFallbackActive = true;
36991
36398
  }
36992
36399
  if (response.success === false) {
36993
36400
  throw new Error(response.message ?? "bash failed");
36994
36401
  }
36402
+ if (!usedHostFallback && hostFallbackActive)
36403
+ hostFallbackActive = false;
36995
36404
  const taskId = response.task_id;
36996
36405
  if (response.status === "running" && taskId) {
36997
36406
  trackBgTask(resolveSessionId(extCtx), taskId);
@@ -37845,12 +37254,13 @@ function registerImportTools(pi, ctx) {
37845
37254
 
37846
37255
  // src/tools/inspect.ts
37847
37256
  import { Type as Type8 } from "typebox";
37257
+ var INSPECT_TRANSPORT_HEADROOM_MS = 30000;
37848
37258
  var InspectParams = Type8.Object({
37849
37259
  sections: Type8.Optional(Type8.Union([Type8.String(), Type8.Array(Type8.String())], {
37850
37260
  description: "Categories to include in detailed drill-down (e.g. 'todos' or ['todos', 'dead_code', 'cycles']). Use 'all' for every active category. Omit for summary-only mode. `sections` changes detail, not the categories verified."
37851
37261
  })),
37852
37262
  scope: Type8.Optional(Type8.Union([Type8.String(), Type8.Array(Type8.String())], {
37853
- description: "Restrict returned results to paths under this scope (file or directory, absolute or relative to project root). `scope=` narrows results; it does not reduce the blocking-fresh verification work."
37263
+ description: "Restrict returned results to paths under this scope (file or directory, absolute or relative to project root). `scope=` narrows results; it does not change the diagnostic collection work. Scoped files no producer has authoritatively analyzed are reported as named gaps (complete: false), never as a clean empty result."
37854
37264
  })),
37855
37265
  topK: Type8.Optional(Type8.Integer({
37856
37266
  minimum: 1,
@@ -38134,7 +37544,7 @@ function registerInspectTool(pi, ctx) {
38134
37544
  pi.registerTool({
38135
37545
  name: "aft_inspect",
38136
37546
  label: "inspect",
38137
- description: "Blocking-fresh codebase health inspection. Each call completes current analysis and produces exactly one terminal result: FRESH includes a wait-stamp and completed phases; INTERRUPTED and PHASE-FAILED retain completed phases, with PHASE-FAILED also reporting its phase attribution and failure reason. `sections` selects drill-down detail, not the categories verified.\n\n" + "Use `scope=` to narrow returned results. It does not reduce the fresh verification work. Passive health changes use the alert channel; do not infer inspect completion from that channel.\n\n" + `Use when: starting work on unfamiliar code, after multi-edit batches to check diagnostics, before a refactor, before review, or to verify cleanup completeness.
37547
+ description: "Blocking-fresh codebase health inspection. Each call completes current analysis and produces exactly one terminal result: FRESH includes a wait-stamp and completed phases; INTERRUPTED and PHASE-FAILED retain completed phases, with PHASE-FAILED also reporting its phase attribution and failure reason. `sections` selects drill-down detail, not the categories verified.\n\n" + "Use `scope=` to narrow returned results. Scope filters rendered diagnostics; it does not change collection work. Scoped files no producer has authoritatively analyzed are reported as named gaps (complete: false). Passive health changes use the alert channel; do not infer inspect completion from that channel.\n\n" + `Use when: starting work on unfamiliar code, after multi-edit batches to check diagnostics, before a refactor, before review, or to verify cleanup completeness.
38138
37548
 
38139
37549
  ` + "Treat `dead_code` as a hint, not proof: reachability is call-based, so symbols reached only via method dispatch or referenced only in type position may be false positives — verify before deleting.",
38140
37550
  parameters: InspectParams,
@@ -38150,7 +37560,9 @@ function registerInspectTool(pi, ctx) {
38150
37560
  rawArgs.scope = scope;
38151
37561
  if (topK !== undefined)
38152
37562
  rawArgs.topK = topK;
38153
- const response = await callToolCall(bridge, "inspect", rawArgs, extCtx);
37563
+ const response = await callToolCall(bridge, "inspect", rawArgs, extCtx, {
37564
+ transportTimeoutMs: resolveInspectDiagnosticsTimeoutMs(ctx.config) + INSPECT_TRANSPORT_HEADROOM_MS
37565
+ });
38154
37566
  const terminal = parseInspectTerminal(response);
38155
37567
  if (terminal)
38156
37568
  return textResult(renderInspectTerminal(terminal, response.text), response);
@@ -39315,7 +38727,7 @@ var PLUGIN_VERSION = (() => {
39315
38727
  return "0.0.0";
39316
38728
  }
39317
38729
  })();
39318
- var ANNOUNCEMENT_VERSION = "0.51.2";
38730
+ var ANNOUNCEMENT_VERSION = "0.52.0";
39319
38731
  var ANNOUNCEMENT_FEATURES = [
39320
38732
  "Callgraph stays consistent under load: edits arriving mid-rebuild can no longer be silently lost from navigation results.",
39321
38733
  "aft_zoom handles real-world .jsonc: files with comment banners above the opening brace now resolve, and not-found errors point at the segment that actually failed (thanks @iceteaSA).",
@@ -39435,9 +38847,18 @@ async function src_default(pi) {
39435
38847
  return;
39436
38848
  }
39437
38849
  log2(`AFT extension loading (plugin v${PLUGIN_VERSION})`);
38850
+ const cachedBinaryPath = findBinarySync(PLUGIN_VERSION);
38851
+ if (!cachedBinaryPath) {
38852
+ ensureBinary(PLUGIN_VERSION).then((path2) => {
38853
+ if (path2)
38854
+ log2(`Background binary warmup ready at ${path2}`);
38855
+ }, (err) => {
38856
+ warn2(`Background binary warmup failed: ${err instanceof Error ? err.message : String(err)}`);
38857
+ });
38858
+ }
39438
38859
  let binaryPath;
39439
38860
  try {
39440
- binaryPath = await findBinary(PLUGIN_VERSION);
38861
+ binaryPath = cachedBinaryPath ?? await findBinary(PLUGIN_VERSION);
39441
38862
  } catch (err) {
39442
38863
  warn2(`Failed to resolve AFT binary: ${err instanceof Error ? err.message : String(err)}. ` + "Tools will not be registered.");
39443
38864
  return;
@@ -39739,6 +39160,6 @@ var __test__2 = {
39739
39160
  createVersionMismatchHandler
39740
39161
  };
39741
39162
  export {
39742
- src_default as default,
39743
- __test__2 as __test__
39163
+ __test__2 as __test__,
39164
+ src_default as default
39744
39165
  };