@cortexkit/aft-opencode 0.51.3 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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@4.6.2/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";
@@ -7073,7 +7075,7 @@ var require_common = __commonJS((exports, module) => {
7073
7075
  });
7074
7076
 
7075
7077
  // ../../node_modules/.bun/comment-json@4.6.2/node_modules/comment-json/src/array.js
7076
- var require_array = __commonJS((exports, module) => {
7078
+ var require_array = __commonJS(function(exports, module) {
7077
7079
  var { sort } = require_src();
7078
7080
  var {
7079
7081
  PROP_SYMBOL_PREFIXES,
@@ -7231,7 +7233,7 @@ var require_array = __commonJS((exports, module) => {
7231
7233
  });
7232
7234
 
7233
7235
  // ../../node_modules/.bun/comment-json@4.6.2/node_modules/comment-json/src/parse.js
7234
- var require_parse = __commonJS((exports, module) => {
7236
+ var require_parse = __commonJS(function(exports, module) {
7235
7237
  var esprima = require_esprima();
7236
7238
  var {
7237
7239
  CommentArray
@@ -7556,7 +7558,7 @@ var require_parse = __commonJS((exports, module) => {
7556
7558
  });
7557
7559
 
7558
7560
  // ../../node_modules/.bun/comment-json@4.6.2/node_modules/comment-json/src/stringify.js
7559
- var require_stringify = __commonJS((exports, module) => {
7561
+ var require_stringify = __commonJS(function(exports, module) {
7560
7562
  var {
7561
7563
  PREFIX_BEFORE_ALL,
7562
7564
  PREFIX_BEFORE,
@@ -7768,7 +7770,7 @@ var require_stringify = __commonJS((exports, module) => {
7768
7770
  });
7769
7771
 
7770
7772
  // ../../node_modules/.bun/comment-json@4.6.2/node_modules/comment-json/src/index.js
7771
- var require_src2 = __commonJS((exports, module) => {
7773
+ var require_src2 = __commonJS(function(exports, module) {
7772
7774
  var { parse, tokenize } = require_parse();
7773
7775
  var stringify = require_stringify();
7774
7776
  var { CommentArray } = require_array();
@@ -9828,19 +9830,38 @@ async function downloadBinary(version) {
9828
9830
  releaseLock?.();
9829
9831
  }
9830
9832
  }
9833
+ var ensureBinaryInFlight = new Map;
9834
+ function ensureBinaryKey(version) {
9835
+ if (!version)
9836
+ return "latest";
9837
+ return version.startsWith("v") ? version : `v${version}`;
9838
+ }
9831
9839
  async function ensureBinary(version) {
9832
- if (version) {
9833
- const tag = version.startsWith("v") ? version : `v${version}`;
9834
- const versionCached = getCachedBinaryPath(tag);
9835
- if (versionCached && isExpectedCachedBinary(versionCached, tag)) {
9836
- log(`Found cached binary for ${tag}: ${versionCached}`);
9837
- return versionCached;
9838
- }
9839
- log(`No cached binary for ${tag}, downloading...`);
9840
- return downloadBinary(tag);
9840
+ const key = ensureBinaryKey(version);
9841
+ const existing = ensureBinaryInFlight.get(key);
9842
+ if (existing)
9843
+ return existing;
9844
+ const task = (async () => {
9845
+ if (version) {
9846
+ const tag = ensureBinaryKey(version);
9847
+ const versionCached = getCachedBinaryPath(tag);
9848
+ if (versionCached && isExpectedCachedBinary(versionCached, tag)) {
9849
+ log(`Found cached binary for ${tag}: ${versionCached}`);
9850
+ return versionCached;
9851
+ }
9852
+ log(`No cached binary for ${tag}, downloading...`);
9853
+ return downloadBinary(tag);
9854
+ }
9855
+ log("No cached binary found, downloading latest...");
9856
+ return downloadBinary();
9857
+ })();
9858
+ ensureBinaryInFlight.set(key, task);
9859
+ try {
9860
+ return await task;
9861
+ } finally {
9862
+ if (ensureBinaryInFlight.get(key) === task)
9863
+ ensureBinaryInFlight.delete(key);
9841
9864
  }
9842
- log("No cached binary found, downloading latest...");
9843
- return downloadBinary();
9844
9865
  }
9845
9866
  function createDownloadLockOwner() {
9846
9867
  return JSON.stringify({
@@ -10094,78 +10115,17 @@ async function renameIfPresent(from, to) {
10094
10115
  throw error2;
10095
10116
  }
10096
10117
  }
10097
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/client.js
10118
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/client.js
10098
10119
  import { promises as fs3 } from "node:fs";
10099
10120
  import { debuglog } from "node:util";
10100
10121
 
10101
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/auth.js
10122
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/auth.js
10102
10123
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
10103
- var NONCE_LEN = 32;
10104
- var MAX_AUTH_MESSAGE_LEN = 4096;
10105
- var SERVER_PROOF_DOMAIN = "subc-server-v1";
10106
- var CLIENT_AUTH_DOMAIN = "subc-client-v1";
10107
- var DEFAULT_CLIENT_ROLE = "client";
10108
-
10109
- class AuthError extends Error {
10110
- }
10111
- function computeProof(key, domain, clientNonce, serverNonce, daemonId) {
10112
- const mac = createHmac("sha256", Buffer.from(key));
10113
- mac.update(Buffer.from(domain, "utf8"));
10114
- mac.update(Buffer.from(clientNonce));
10115
- mac.update(Buffer.from(serverNonce));
10116
- mac.update(Buffer.from(daemonId));
10117
- return new Uint8Array(mac.digest());
10118
- }
10119
- function constantTimeEq(a, b) {
10120
- if (a.length !== b.length)
10121
- return false;
10122
- return timingSafeEqual(Buffer.from(a), Buffer.from(b));
10123
- }
10124
- async function writeMessage(sock, value, deadlineMs) {
10125
- const json = Buffer.from(JSON.stringify(value), "utf8");
10126
- if (json.length > MAX_AUTH_MESSAGE_LEN) {
10127
- throw new AuthError(`auth message too large: ${json.length} > ${MAX_AUTH_MESSAGE_LEN}`);
10128
- }
10129
- const lenPrefix = new Uint8Array(4);
10130
- new DataView(lenPrefix.buffer).setUint32(0, json.length, true);
10131
- await sock.write(lenPrefix, deadlineMs);
10132
- await sock.write(json, deadlineMs);
10133
- }
10134
- async function readMessage(sock, deadlineMs) {
10135
- const lenBytes = await sock.readExact(4, deadlineMs);
10136
- const len = new DataView(lenBytes.buffer, lenBytes.byteOffset, 4).getUint32(0, true);
10137
- if (len > MAX_AUTH_MESSAGE_LEN) {
10138
- throw new AuthError(`auth message too large: ${len} > ${MAX_AUTH_MESSAGE_LEN}`);
10139
- }
10140
- const body = len === 0 ? new Uint8Array(0) : await sock.readExact(len, deadlineMs);
10141
- try {
10142
- return JSON.parse(Buffer.from(body).toString("utf8"));
10143
- } catch (err) {
10144
- throw new AuthError(`auth message JSON decode failed: ${String(err)}`);
10145
- }
10146
- }
10147
- async function authenticateClient(sock, conn, deadlineMs) {
10148
- const clientNonce = new Uint8Array(randomBytes(NONCE_LEN));
10149
- await writeMessage(sock, { client_nonce: Array.from(clientNonce), role: DEFAULT_CLIENT_ROLE }, deadlineMs);
10150
- const proof = await readMessage(sock, deadlineMs);
10151
- const serverNonce = Uint8Array.from(proof.server_nonce);
10152
- const daemonId = Uint8Array.from(proof.daemon_id);
10153
- const serverProof = Uint8Array.from(proof.server_proof);
10154
- const expected = computeProof(conn.key, SERVER_PROOF_DOMAIN, clientNonce, serverNonce, daemonId);
10155
- if (!constantTimeEq(expected, serverProof)) {
10156
- throw new AuthError("server proof mismatch — wrong key or impostor daemon");
10157
- }
10158
- if (!constantTimeEq(daemonId, conn.daemonId)) {
10159
- throw new AuthError("daemon id mismatch — connection file points at a different daemon");
10160
- }
10161
- const clientAuth = computeProof(conn.key, CLIENT_AUTH_DOMAIN, clientNonce, serverNonce, daemonId);
10162
- await writeMessage(sock, { client_auth: Array.from(clientAuth) }, deadlineMs);
10163
- }
10164
10124
 
10165
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
10166
- import { promises as fs2 } from "node:fs";
10125
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/socket.js
10126
+ import net from "node:net";
10167
10127
 
10168
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/envelope.js
10128
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/envelope.js
10169
10129
  var PROTOCOL_VERSION = 2;
10170
10130
  var HEADER_LEN = 21;
10171
10131
  var FROZEN_PREFIX_LEN = 5;
@@ -10239,6 +10199,39 @@ class DecodeError extends Error {
10239
10199
  this.name = "DecodeError";
10240
10200
  }
10241
10201
  }
10202
+ function validateHeaderFields(header) {
10203
+ const len = header.len >>> 0;
10204
+ const ver = header.ver >>> 0 & 255;
10205
+ const typeByte = header.ty >>> 0 & 255;
10206
+ const flags = header.flags >>> 0 & 255;
10207
+ const channel = header.channel >>> 0 & 65535;
10208
+ const epoch = header.epoch >>> 0;
10209
+ BigInt.asUintN(64, header.corr);
10210
+ if (ver !== PROTOCOL_VERSION)
10211
+ throw new DecodeError(`unsupported envelope version ${ver}`, "unsupported_version");
10212
+ if (typeByte > FRAME_TYPE_MAX)
10213
+ throw new DecodeError(`unknown frame type byte ${typeByte}`, "unknown_frame_type");
10214
+ const ty = typeByte;
10215
+ if ((flags & FLAG_RESERVED_MASK) !== 0) {
10216
+ throw new DecodeError(`reserved flag bits set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_flag_bits");
10217
+ }
10218
+ if ((flags & FLAG_PRIORITY_MASK) >> FLAG_PRIORITY_SHIFT === 3) {
10219
+ throw new DecodeError(`reserved priority bits set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_priority_bits");
10220
+ }
10221
+ const admission = (flags & FLAG_ADMISSION_MASK) >> FLAG_ADMISSION_SHIFT;
10222
+ if (admission === 3) {
10223
+ throw new DecodeError(`reserved admission class set in flags 0b${flags.toString(2).padStart(8, "0")}`, "reserved_admission_class");
10224
+ }
10225
+ if (admission === AdmissionClass.Sheddable && ty !== FrameType.Push && ty !== FrameType.StreamData) {
10226
+ throw new DecodeError(`SHEDDABLE admission class is illegal on ${FrameType[ty]} in flags 0b${flags.toString(2).padStart(8, "0")}`, "sheddable_illegal_frame_type");
10227
+ }
10228
+ if (channel === 0 && epoch !== 0) {
10229
+ throw new DecodeError(`control channel carried nonzero epoch ${epoch}`, "nonzero_epoch_on_control_channel");
10230
+ }
10231
+ if (isPureHeader(ty) && len !== 0) {
10232
+ throw new DecodeError(`pure-header frame ${FrameType[ty]} declared non-zero body length ${len}`, "pure_header_frame_with_body");
10233
+ }
10234
+ }
10242
10235
  function decodeHeader(bytes) {
10243
10236
  if (bytes.length < FROZEN_PREFIX_LEN) {
10244
10237
  throw new DecodeError(`header shorter than frozen prefix: have ${bytes.length} bytes`, "too_short_for_prefix");
@@ -10287,7 +10280,7 @@ function buildFrameWithVersion(ver, ty, flags, channel, epoch, corr, body) {
10287
10280
  throw new DecodeError(`frame body ${body.length} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10288
10281
  }
10289
10282
  const header = { len: body.length, ver, ty, flags, channel, epoch, corr };
10290
- decodeHeader(encodeHeader(header));
10283
+ validateHeaderFields(header);
10291
10284
  return { header, body };
10292
10285
  }
10293
10286
  function encodeFrame(frame) {
@@ -10301,7 +10294,315 @@ function encodeFrame(frame) {
10301
10294
  return output;
10302
10295
  }
10303
10296
 
10304
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
10297
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/socket.js
10298
+ class SocketClosedError extends Error {
10299
+ }
10300
+
10301
+ class SocketTimeoutError extends Error {
10302
+ }
10303
+
10304
+ class SocketWriteNotQueuedError extends Error {
10305
+ cause;
10306
+ constructor(message, cause) {
10307
+ super(message);
10308
+ this.cause = cause;
10309
+ }
10310
+ }
10311
+
10312
+ class SocketWriteQueuedError extends Error {
10313
+ cause;
10314
+ constructor(message, cause) {
10315
+ super(message);
10316
+ this.cause = cause;
10317
+ }
10318
+ }
10319
+ function toWriteBuffer(bytes) {
10320
+ return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
10321
+ }
10322
+ var WRITE_BORROWED = Symbol("subc.socket.writeBorrowed");
10323
+ var WRITE_TRACKED_BORROWED = Symbol("subc.socket.writeTrackedBorrowed");
10324
+ function writeBorrowed(socket, bytes, deadlineMs) {
10325
+ const borrowed = socket[WRITE_BORROWED];
10326
+ return borrowed ? borrowed.call(socket, bytes, deadlineMs) : socket.write(bytes, deadlineMs);
10327
+ }
10328
+ function writeTrackedBorrowed(socket, bytes, deadlineMs) {
10329
+ const borrowed = socket[WRITE_TRACKED_BORROWED];
10330
+ return borrowed ? borrowed.call(socket, bytes, deadlineMs) : socket.writeTracked(bytes, deadlineMs);
10331
+ }
10332
+
10333
+ class SubcSocket {
10334
+ sock;
10335
+ chunks = [];
10336
+ buffered = 0;
10337
+ waiter = null;
10338
+ closedErr = null;
10339
+ bufferedBytes() {
10340
+ return this.buffered;
10341
+ }
10342
+ constructor(sock) {
10343
+ this.sock = sock;
10344
+ sock.on("data", (chunk) => {
10345
+ this.chunks.push(chunk);
10346
+ this.buffered += chunk.length;
10347
+ this.tryServe();
10348
+ });
10349
+ const fail = (err) => {
10350
+ if (!this.closedErr)
10351
+ this.closedErr = err;
10352
+ this.tryServe();
10353
+ };
10354
+ sock.on("error", (err) => fail(err instanceof Error ? err : new Error(String(err))));
10355
+ sock.on("end", () => fail(new SocketClosedError("subc closed the connection")));
10356
+ sock.on("close", () => fail(new SocketClosedError("subc connection closed")));
10357
+ }
10358
+ localPort() {
10359
+ return this.sock.localPort ?? null;
10360
+ }
10361
+ static connect(host, port, deadlineMs) {
10362
+ return new Promise((resolve3, reject) => {
10363
+ const sock = net.connect({ host, port });
10364
+ sock.setNoDelay(true);
10365
+ const timer = setTimeout(() => {
10366
+ sock.destroy();
10367
+ reject(new SocketTimeoutError(`timed out connecting to ${host}:${port}`));
10368
+ }, Math.max(0, deadlineMs - Date.now()));
10369
+ sock.once("connect", () => {
10370
+ clearTimeout(timer);
10371
+ resolve3(new SubcSocket(sock));
10372
+ });
10373
+ sock.once("error", (err) => {
10374
+ clearTimeout(timer);
10375
+ reject(err);
10376
+ });
10377
+ });
10378
+ }
10379
+ async readFrame(headerDeadlineMs, bodyDeadline, onHeader) {
10380
+ const prefix = await this.readExact(FROZEN_PREFIX_LEN, headerDeadlineMs);
10381
+ const version = prefix[4];
10382
+ if (version !== PROTOCOL_VERSION)
10383
+ throw new DecodeError(`unsupported envelope version ${version}`, "unsupported_version");
10384
+ const remainder = await this.readExact(HEADER_LEN - FROZEN_PREFIX_LEN, headerDeadlineMs);
10385
+ const headerBytes = new Uint8Array(HEADER_LEN);
10386
+ headerBytes.set(prefix);
10387
+ headerBytes.set(remainder, FROZEN_PREFIX_LEN);
10388
+ const header = decodeHeader(headerBytes);
10389
+ if (header.len > MAX_FRAME_BODY_LEN) {
10390
+ throw new DecodeError(`frame body ${header.len} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10391
+ }
10392
+ onHeader?.();
10393
+ const bodyDeadlineMs = typeof bodyDeadline === "number" ? bodyDeadline : Date.now() + bodyDeadline.afterHeaderMs;
10394
+ const body = header.len === 0 ? new Uint8Array(0) : await this.readExact(header.len, bodyDeadlineMs);
10395
+ return { header, body };
10396
+ }
10397
+ readExact(n, deadlineMs) {
10398
+ if (this.waiter) {
10399
+ return Promise.reject(new Error("concurrent readExact is not supported"));
10400
+ }
10401
+ if (n === 0)
10402
+ return Promise.resolve(new Uint8Array(0));
10403
+ return new Promise((resolve3, reject) => {
10404
+ let timer = null;
10405
+ if (Number.isFinite(deadlineMs)) {
10406
+ const remaining = deadlineMs - Date.now();
10407
+ if (remaining <= 0) {
10408
+ reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10409
+ return;
10410
+ }
10411
+ timer = setTimeout(() => {
10412
+ this.waiter = null;
10413
+ reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10414
+ }, remaining);
10415
+ }
10416
+ this.waiter = { need: n, resolve: resolve3, reject, timer };
10417
+ this.tryServe();
10418
+ });
10419
+ }
10420
+ async write(bytes, deadlineMs) {
10421
+ await this.writeBuffer(Buffer.from(bytes), deadlineMs);
10422
+ }
10423
+ writeTracked(bytes, deadlineMs) {
10424
+ return this.writeTrackedBuffer(Buffer.from(bytes), deadlineMs);
10425
+ }
10426
+ async[WRITE_BORROWED](bytes, deadlineMs) {
10427
+ await this.writeBuffer(toWriteBuffer(bytes), deadlineMs);
10428
+ }
10429
+ [WRITE_TRACKED_BORROWED](bytes, deadlineMs) {
10430
+ return this.writeTrackedBuffer(toWriteBuffer(bytes), deadlineMs);
10431
+ }
10432
+ async writeBuffer(buffer, deadlineMs) {
10433
+ try {
10434
+ await this.writeTrackedBuffer(buffer, deadlineMs).completed;
10435
+ } catch (err) {
10436
+ if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError) {
10437
+ throw err.cause ?? err;
10438
+ }
10439
+ throw err;
10440
+ }
10441
+ }
10442
+ writeTrackedBuffer(buffer, deadlineMs) {
10443
+ if (this.closedErr) {
10444
+ return {
10445
+ queued: false,
10446
+ completed: Promise.reject(new SocketWriteNotQueuedError("subc socket was closed before bytes could be queued", this.closedErr))
10447
+ };
10448
+ }
10449
+ let queued = false;
10450
+ let settled = false;
10451
+ let timer = null;
10452
+ const completed = new Promise((resolve3, reject) => {
10453
+ const settle = (run) => {
10454
+ if (settled)
10455
+ return;
10456
+ settled = true;
10457
+ if (timer)
10458
+ clearTimeout(timer);
10459
+ run();
10460
+ };
10461
+ const remaining = deadlineMs - Date.now();
10462
+ if (remaining <= 0) {
10463
+ settle(() => reject(new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", new SocketTimeoutError("timed out writing to subc"))));
10464
+ return;
10465
+ }
10466
+ timer = setTimeout(() => {
10467
+ const timeout = new SocketTimeoutError("timed out writing to subc");
10468
+ 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)));
10469
+ }, remaining);
10470
+ try {
10471
+ this.sock.write(buffer, (err) => {
10472
+ settle(() => {
10473
+ if (err) {
10474
+ reject(new SocketWriteQueuedError("subc socket reported a write error after bytes were handed to the socket", err instanceof Error ? err : new Error(String(err))));
10475
+ } else {
10476
+ resolve3();
10477
+ }
10478
+ });
10479
+ });
10480
+ queued = true;
10481
+ } catch (err) {
10482
+ settle(() => reject(new SocketWriteNotQueuedError("subc socket write threw before bytes could be queued", err instanceof Error ? err : new Error(String(err)))));
10483
+ }
10484
+ });
10485
+ return { queued, completed };
10486
+ }
10487
+ close() {
10488
+ this.sock.destroy();
10489
+ }
10490
+ tryServe() {
10491
+ const w = this.waiter;
10492
+ if (!w)
10493
+ return;
10494
+ if (this.buffered >= w.need) {
10495
+ const out = this.take(w.need);
10496
+ this.waiter = null;
10497
+ if (w.timer)
10498
+ clearTimeout(w.timer);
10499
+ w.resolve(out);
10500
+ return;
10501
+ }
10502
+ if (this.closedErr) {
10503
+ this.waiter = null;
10504
+ if (w.timer)
10505
+ clearTimeout(w.timer);
10506
+ w.reject(this.closedErr);
10507
+ }
10508
+ }
10509
+ take(n) {
10510
+ const out = Buffer.allocUnsafe(n);
10511
+ let off = 0;
10512
+ while (off < n) {
10513
+ const head = this.chunks[0];
10514
+ const want = n - off;
10515
+ if (head.length <= want) {
10516
+ head.copy(out, off);
10517
+ off += head.length;
10518
+ this.chunks.shift();
10519
+ } else {
10520
+ head.copy(out, off, 0, want);
10521
+ this.chunks[0] = head.subarray(want);
10522
+ off += want;
10523
+ }
10524
+ }
10525
+ this.buffered -= n;
10526
+ return out;
10527
+ }
10528
+ }
10529
+
10530
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/auth.js
10531
+ var NONCE_LEN = 32;
10532
+ var MAX_AUTH_MESSAGE_LEN = 4096;
10533
+ var SERVER_PROOF_DOMAIN = "subc-server-v1";
10534
+ var CLIENT_AUTH_DOMAIN = "subc-client-v1";
10535
+ var DEFAULT_CLIENT_ROLE = "client";
10536
+
10537
+ class AuthError extends Error {
10538
+ }
10539
+ function computeProof(key, domain, clientNonce, serverNonce, daemonId) {
10540
+ const mac = createHmac("sha256", Buffer.from(key));
10541
+ mac.update(Buffer.from(domain, "utf8"));
10542
+ mac.update(Buffer.from(clientNonce));
10543
+ mac.update(Buffer.from(serverNonce));
10544
+ mac.update(Buffer.from(daemonId));
10545
+ return new Uint8Array(mac.digest());
10546
+ }
10547
+ function constantTimeEq(a, b) {
10548
+ if (a.length !== b.length)
10549
+ return false;
10550
+ return timingSafeEqual(Buffer.from(a), Buffer.from(b));
10551
+ }
10552
+ async function writeMessage(sock, value, deadlineMs) {
10553
+ const json = Buffer.from(JSON.stringify(value), "utf8");
10554
+ if (json.length > MAX_AUTH_MESSAGE_LEN) {
10555
+ throw new AuthError(`auth message too large: ${json.length} > ${MAX_AUTH_MESSAGE_LEN}`);
10556
+ }
10557
+ const lenPrefix = new Uint8Array(4);
10558
+ new DataView(lenPrefix.buffer).setUint32(0, json.length, true);
10559
+ await writeBorrowed(sock, lenPrefix, deadlineMs);
10560
+ await writeBorrowed(sock, json, deadlineMs);
10561
+ }
10562
+ async function readMessage(sock, deadlineMs) {
10563
+ const lenBytes = await sock.readExact(4, deadlineMs);
10564
+ const len = new DataView(lenBytes.buffer, lenBytes.byteOffset, 4).getUint32(0, true);
10565
+ if (len > MAX_AUTH_MESSAGE_LEN) {
10566
+ throw new AuthError(`auth message too large: ${len} > ${MAX_AUTH_MESSAGE_LEN}`);
10567
+ }
10568
+ const body = len === 0 ? new Uint8Array(0) : await sock.readExact(len, deadlineMs);
10569
+ try {
10570
+ return JSON.parse(Buffer.from(body).toString("utf8"));
10571
+ } catch (err) {
10572
+ throw new AuthError(`auth message JSON decode failed: ${String(err)}`);
10573
+ }
10574
+ }
10575
+ function authBytes(value, field) {
10576
+ if (!Array.isArray(value)) {
10577
+ throw new AuthError(`auth field '${field}' must be a byte array`);
10578
+ }
10579
+ for (const byte of value) {
10580
+ if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) {
10581
+ throw new AuthError(`auth field '${field}' has invalid byte ${String(byte)}`);
10582
+ }
10583
+ }
10584
+ return Uint8Array.from(value);
10585
+ }
10586
+ async function authenticateClient(sock, conn, deadlineMs) {
10587
+ const clientNonce = new Uint8Array(randomBytes(NONCE_LEN));
10588
+ await writeMessage(sock, { client_nonce: Array.from(clientNonce), role: DEFAULT_CLIENT_ROLE }, deadlineMs);
10589
+ const proof = await readMessage(sock, deadlineMs);
10590
+ const serverNonce = authBytes(proof.server_nonce, "server_nonce");
10591
+ const daemonId = authBytes(proof.daemon_id, "daemon_id");
10592
+ const serverProof = authBytes(proof.server_proof, "server_proof");
10593
+ const expected = computeProof(conn.key, SERVER_PROOF_DOMAIN, clientNonce, serverNonce, daemonId);
10594
+ if (!constantTimeEq(expected, serverProof)) {
10595
+ throw new AuthError("server proof mismatch — wrong key or impostor daemon");
10596
+ }
10597
+ if (!constantTimeEq(daemonId, conn.daemonId)) {
10598
+ throw new AuthError("daemon id mismatch — connection file points at a different daemon");
10599
+ }
10600
+ const clientAuth = computeProof(conn.key, CLIENT_AUTH_DOMAIN, clientNonce, serverNonce, daemonId);
10601
+ await writeMessage(sock, { client_auth: Array.from(clientAuth) }, deadlineMs);
10602
+ }
10603
+
10604
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/connection-file.js
10605
+ import { promises as fs2 } from "node:fs";
10305
10606
  var SCHEMA_VERSION = 1;
10306
10607
  var MIN_KEY_LEN = 32;
10307
10608
  var DAEMON_ID_LEN = 16;
@@ -10309,9 +10610,14 @@ var DAEMON_ID_LEN = 16;
10309
10610
  class ConnectionFileError extends Error {
10310
10611
  }
10311
10612
  function toBytes(value, field) {
10312
- if (!Array.isArray(value) || value.some((n) => typeof n !== "number")) {
10613
+ if (!Array.isArray(value)) {
10313
10614
  throw new ConnectionFileError(`connection file field '${field}' must be a JSON array of bytes`);
10314
10615
  }
10616
+ for (const byte of value) {
10617
+ if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) {
10618
+ throw new ConnectionFileError(`connection file field '${field}' has invalid byte ${String(byte)}`);
10619
+ }
10620
+ }
10315
10621
  return Uint8Array.from(value);
10316
10622
  }
10317
10623
  function validate(info) {
@@ -10373,7 +10679,7 @@ async function readConnectionFile(path2) {
10373
10679
  return info;
10374
10680
  }
10375
10681
 
10376
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/route-handle.js
10682
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/route-handle.js
10377
10683
  var connectionToken = new WeakMap;
10378
10684
 
10379
10685
  class RouteHandle {
@@ -10419,220 +10725,12 @@ function sameRouteHandle(left, right) {
10419
10725
  return left === right;
10420
10726
  }
10421
10727
 
10422
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/socket.js
10423
- import net from "node:net";
10424
- class SocketClosedError extends Error {
10425
- }
10426
-
10427
- class SocketTimeoutError extends Error {
10428
- }
10429
-
10430
- class SocketWriteNotQueuedError extends Error {
10431
- cause;
10432
- constructor(message, cause) {
10433
- super(message);
10434
- this.cause = cause;
10435
- }
10436
- }
10437
-
10438
- class SocketWriteQueuedError extends Error {
10439
- cause;
10440
- constructor(message, cause) {
10441
- super(message);
10442
- this.cause = cause;
10443
- }
10444
- }
10445
-
10446
- class SubcSocket {
10447
- sock;
10448
- chunks = [];
10449
- buffered = 0;
10450
- waiter = null;
10451
- closedErr = null;
10452
- bufferedBytes() {
10453
- return this.buffered;
10454
- }
10455
- constructor(sock) {
10456
- this.sock = sock;
10457
- sock.on("data", (chunk) => {
10458
- this.chunks.push(chunk);
10459
- this.buffered += chunk.length;
10460
- this.tryServe();
10461
- });
10462
- const fail = (err) => {
10463
- if (!this.closedErr)
10464
- this.closedErr = err;
10465
- this.tryServe();
10466
- };
10467
- sock.on("error", (err) => fail(err instanceof Error ? err : new Error(String(err))));
10468
- sock.on("end", () => fail(new SocketClosedError("subc closed the connection")));
10469
- sock.on("close", () => fail(new SocketClosedError("subc connection closed")));
10470
- }
10471
- localPort() {
10472
- return this.sock.localPort ?? null;
10473
- }
10474
- static connect(host, port, deadlineMs) {
10475
- return new Promise((resolve3, reject) => {
10476
- const sock = net.connect({ host, port });
10477
- sock.setNoDelay(true);
10478
- const timer = setTimeout(() => {
10479
- sock.destroy();
10480
- reject(new SocketTimeoutError(`timed out connecting to ${host}:${port}`));
10481
- }, Math.max(0, deadlineMs - Date.now()));
10482
- sock.once("connect", () => {
10483
- clearTimeout(timer);
10484
- resolve3(new SubcSocket(sock));
10485
- });
10486
- sock.once("error", (err) => {
10487
- clearTimeout(timer);
10488
- reject(err);
10489
- });
10490
- });
10491
- }
10492
- async readFrame(headerDeadlineMs, bodyDeadline, onHeader) {
10493
- const prefix = await this.readExact(FROZEN_PREFIX_LEN, headerDeadlineMs);
10494
- const version = prefix[4];
10495
- if (version !== PROTOCOL_VERSION)
10496
- throw new DecodeError(`unsupported envelope version ${version}`, "unsupported_version");
10497
- const remainder = await this.readExact(HEADER_LEN - FROZEN_PREFIX_LEN, headerDeadlineMs);
10498
- const headerBytes = new Uint8Array(HEADER_LEN);
10499
- headerBytes.set(prefix);
10500
- headerBytes.set(remainder, FROZEN_PREFIX_LEN);
10501
- const header = decodeHeader(headerBytes);
10502
- if (header.len > MAX_FRAME_BODY_LEN) {
10503
- throw new DecodeError(`frame body ${header.len} exceeds max ${MAX_FRAME_BODY_LEN}`, "frame_body_too_large");
10504
- }
10505
- onHeader?.();
10506
- const bodyDeadlineMs = typeof bodyDeadline === "number" ? bodyDeadline : Date.now() + bodyDeadline.afterHeaderMs;
10507
- const body = header.len === 0 ? new Uint8Array(0) : await this.readExact(header.len, bodyDeadlineMs);
10508
- return { header, body };
10509
- }
10510
- readExact(n, deadlineMs) {
10511
- if (this.waiter) {
10512
- return Promise.reject(new Error("concurrent readExact is not supported"));
10513
- }
10514
- if (n === 0)
10515
- return Promise.resolve(new Uint8Array(0));
10516
- return new Promise((resolve3, reject) => {
10517
- let timer = null;
10518
- if (Number.isFinite(deadlineMs)) {
10519
- const remaining = deadlineMs - Date.now();
10520
- if (remaining <= 0) {
10521
- reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10522
- return;
10523
- }
10524
- timer = setTimeout(() => {
10525
- this.waiter = null;
10526
- reject(new SocketTimeoutError(`timed out waiting for ${n} bytes`));
10527
- }, remaining);
10528
- }
10529
- this.waiter = { need: n, resolve: resolve3, reject, timer };
10530
- this.tryServe();
10531
- });
10532
- }
10533
- async write(bytes, deadlineMs) {
10534
- try {
10535
- await this.writeTracked(bytes, deadlineMs).completed;
10536
- } catch (err) {
10537
- if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError) {
10538
- throw err.cause ?? err;
10539
- }
10540
- throw err;
10541
- }
10542
- }
10543
- writeTracked(bytes, deadlineMs) {
10544
- if (this.closedErr) {
10545
- return {
10546
- queued: false,
10547
- completed: Promise.reject(new SocketWriteNotQueuedError("subc socket was closed before bytes could be queued", this.closedErr))
10548
- };
10549
- }
10550
- let queued = false;
10551
- let settled = false;
10552
- let timer = null;
10553
- const completed = new Promise((resolve3, reject) => {
10554
- const settle = (run) => {
10555
- if (settled)
10556
- return;
10557
- settled = true;
10558
- if (timer)
10559
- clearTimeout(timer);
10560
- run();
10561
- };
10562
- const remaining = deadlineMs - Date.now();
10563
- if (remaining <= 0) {
10564
- settle(() => reject(new SocketWriteNotQueuedError("timed out before bytes could be queued to subc", new SocketTimeoutError("timed out writing to subc"))));
10565
- return;
10566
- }
10567
- timer = setTimeout(() => {
10568
- const timeout = new SocketTimeoutError("timed out writing to subc");
10569
- 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)));
10570
- }, remaining);
10571
- try {
10572
- this.sock.write(Buffer.from(bytes), (err) => {
10573
- settle(() => {
10574
- if (err) {
10575
- reject(new SocketWriteQueuedError("subc socket reported a write error after bytes were handed to the socket", err instanceof Error ? err : new Error(String(err))));
10576
- } else {
10577
- resolve3();
10578
- }
10579
- });
10580
- });
10581
- queued = true;
10582
- } catch (err) {
10583
- settle(() => reject(new SocketWriteNotQueuedError("subc socket write threw before bytes could be queued", err instanceof Error ? err : new Error(String(err)))));
10584
- }
10585
- });
10586
- return { queued, completed };
10587
- }
10588
- close() {
10589
- this.sock.destroy();
10590
- }
10591
- tryServe() {
10592
- const w = this.waiter;
10593
- if (!w)
10594
- return;
10595
- if (this.buffered >= w.need) {
10596
- const out = this.take(w.need);
10597
- this.waiter = null;
10598
- if (w.timer)
10599
- clearTimeout(w.timer);
10600
- w.resolve(out);
10601
- return;
10602
- }
10603
- if (this.closedErr) {
10604
- this.waiter = null;
10605
- if (w.timer)
10606
- clearTimeout(w.timer);
10607
- w.reject(this.closedErr);
10608
- }
10609
- }
10610
- take(n) {
10611
- const out = Buffer.allocUnsafe(n);
10612
- let off = 0;
10613
- while (off < n) {
10614
- const head = this.chunks[0];
10615
- const want = n - off;
10616
- if (head.length <= want) {
10617
- head.copy(out, off);
10618
- off += head.length;
10619
- this.chunks.shift();
10620
- } else {
10621
- head.copy(out, off, 0, want);
10622
- this.chunks[0] = head.subarray(want);
10623
- off += want;
10624
- }
10625
- }
10626
- this.buffered -= n;
10627
- return out;
10628
- }
10629
- }
10630
-
10631
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/client.js
10728
+ // ../../node_modules/.bun/@cortexkit+subc-client@0.8.1/node_modules/@cortexkit/subc-client/dist/client.js
10632
10729
  var debug = debuglog("subc-client");
10633
10730
  var DEFAULT_HANDSHAKE_TIMEOUT_MS = 1e4;
10634
10731
  var DEFAULT_REQUEST_TIMEOUT_MS = 30000;
10635
10732
  var TIMEOUT_ARBITRATION_GRACE_MS = 50;
10733
+ var LIVENESS_PROBE_WINDOW_MS = 2000;
10636
10734
  var REQUEST_DEADLINE_MARKER = "request_deadline";
10637
10735
  var DEADLINE_NO_DROP_CODE = "deadline_exceeded_no_drop_observed";
10638
10736
  var ROUTE_OPEN_RETRY_DEADLINE_MS = 30000;
@@ -10763,12 +10861,13 @@ class SubcClient {
10763
10861
  } catch (err) {
10764
10862
  if (!(err instanceof SubcCallError))
10765
10863
  throw this.terminalCallError("managed call failed", err);
10766
- if (err.code === "unknown_channel" && !retriedUnknownChannel && !this.closeStarted) {
10864
+ const deadBindCode = err.code === "unknown_channel" || err.code === "stale_route_epoch";
10865
+ if (deadBindCode && !retriedUnknownChannel && !this.closeStarted) {
10767
10866
  retriedUnknownChannel = true;
10768
10867
  this.evictRouteHandle(routeHandle);
10769
10868
  continue;
10770
10869
  }
10771
- if (err.code === "unknown_channel" && retriedUnknownChannel) {
10870
+ if (deadBindCode && retriedUnknownChannel) {
10772
10871
  this.evictRouteHandle(routeHandle);
10773
10872
  }
10774
10873
  if (err.kind === "not_sent") {
@@ -10781,6 +10880,8 @@ class SubcClient {
10781
10880
  }
10782
10881
  if (err.kind === "outcome_unknown" && err.code !== DEADLINE_NO_DROP_CODE) {
10783
10882
  this.scheduleReconnectAfterDrop(err);
10883
+ } else if (err.kind === "outcome_unknown" && err.code === DEADLINE_NO_DROP_CODE) {
10884
+ this.probeLivenessAfterDeadline();
10784
10885
  }
10785
10886
  throw err;
10786
10887
  }
@@ -10793,21 +10894,25 @@ class SubcClient {
10793
10894
  const admission = opts.admissionClass ?? AdmissionClass.Normal;
10794
10895
  const corr = this.allocateCorr();
10795
10896
  const key = pendingKey(handle, corr);
10897
+ let subscriptionPending = null;
10898
+ let resolveClosed = null;
10796
10899
  const closed = new Promise((resolve3, reject) => {
10797
10900
  if (this.closedErr) {
10798
10901
  reject(this.closedErr);
10799
10902
  return;
10800
10903
  }
10801
- this.pending.set(key, {
10904
+ resolveClosed = resolve3;
10905
+ subscriptionPending = {
10802
10906
  handle,
10803
10907
  resolve: () => resolve3(),
10804
10908
  reject,
10805
10909
  onProgress: onEvent,
10806
10910
  timer: null,
10807
10911
  subscription: true
10808
- });
10912
+ };
10913
+ this.pending.set(key, subscriptionPending);
10809
10914
  const frame = buildFrame(FrameType.Request, buildFlags(false, priority, false, admission), handle.channel, handle.epoch, corr, bytes);
10810
- this.sock.write(encodeFrame(frame), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch((err) => {
10915
+ writeBorrowed(this.sock, encodeFrame(frame), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch((err) => {
10811
10916
  const pending = this.pending.get(key);
10812
10917
  if (pending)
10813
10918
  this.rejectPending(key, pending, err instanceof Error ? err : new SubcError(String(err)));
@@ -10818,14 +10923,17 @@ class SubcClient {
10818
10923
  if (cancelled)
10819
10924
  return;
10820
10925
  cancelled = true;
10821
- this.cancel(handle, corr, priority);
10926
+ if (subscriptionPending && resolveClosed)
10927
+ this.settle(key, subscriptionPending, resolveClosed);
10928
+ if (this.isLiveHandle(handle))
10929
+ this.cancel(handle, corr, priority);
10822
10930
  };
10823
10931
  return { unsubscribe, closed };
10824
10932
  }
10825
10933
  cancel(handle, corr, priority = Priority.Interactive) {
10826
10934
  this.assertLiveHandle(handle);
10827
10935
  const cancel = buildFrame(FrameType.Cancel, buildFlags(false, priority, false), handle.channel, handle.epoch, corr, EMPTY_BODY);
10828
- this.sock.write(encodeFrame(cancel), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch(() => {
10936
+ writeBorrowed(this.sock, encodeFrame(cancel), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS).catch(() => {
10829
10937
  return;
10830
10938
  });
10831
10939
  }
@@ -10906,7 +11014,7 @@ class SubcClient {
10906
11014
  return;
10907
11015
  }
10908
11016
  const goodbye = buildFrame(FrameType.Goodbye, buildFlags(false, Priority.Interactive, false), handle.channel, handle.epoch, 0n, EMPTY_BODY);
10909
- const write = this.sock.writeTracked(encodeFrame(goodbye), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS);
11017
+ const write = writeTrackedBorrowed(this.sock, encodeFrame(goodbye), Date.now() + DEFAULT_REQUEST_TIMEOUT_MS);
10910
11018
  if (!write.queued && closeOnQueueFailure)
10911
11019
  this.closeConnectionAfterCleanupFailure();
10912
11020
  write.completed.catch(() => {
@@ -10958,7 +11066,7 @@ class SubcClient {
10958
11066
  };
10959
11067
  pending.timer = setTimeout(() => this.arbitrateTimeout(key, pending, channel, corr, ms), ms);
10960
11068
  this.pending.set(key, pending);
10961
- this.sock.write(encodeFrame(frame), Date.now() + ms).catch((error2) => {
11069
+ writeBorrowed(this.sock, encodeFrame(frame), Date.now() + ms).catch((error2) => {
10962
11070
  const current = this.pending.get(key);
10963
11071
  if (current)
10964
11072
  this.rejectPending(key, current, error2 instanceof Error ? error2 : new SubcError(String(error2)));
@@ -11035,7 +11143,7 @@ class SubcClient {
11035
11143
  };
11036
11144
  pending.timer = setTimeout(() => this.arbitrateTimeout(key, pending, handle.channel, corr, ms), ms);
11037
11145
  this.pending.set(key, pending);
11038
- const write = this.sock.writeTracked(encodeFrame(frame), Date.now() + ms);
11146
+ const write = writeTrackedBorrowed(this.sock, encodeFrame(frame), Date.now() + ms);
11039
11147
  handedToSocket = write.queued;
11040
11148
  write.completed.catch((error2) => {
11041
11149
  const current = this.pending.get(key);
@@ -11123,6 +11231,46 @@ class SubcClient {
11123
11231
  }
11124
11232
  }
11125
11233
  }
11234
+ lastInboundAtMs = 0;
11235
+ livenessProbe = null;
11236
+ hasControlPending() {
11237
+ for (const pending of this.pending.values()) {
11238
+ if (pending.handle === null)
11239
+ return true;
11240
+ }
11241
+ return false;
11242
+ }
11243
+ probeLivenessAfterDeadline() {
11244
+ if (this.livenessProbe || this.closeStarted || this.closedErr)
11245
+ return;
11246
+ if (this.hasControlPending())
11247
+ return;
11248
+ const sock = this.sock;
11249
+ const generation = this.generation;
11250
+ let corr;
11251
+ try {
11252
+ corr = this.allocateCorr();
11253
+ } catch {
11254
+ return;
11255
+ }
11256
+ const t0 = Date.now();
11257
+ const ping = buildFrame(FrameType.Ping, buildFlags(false, Priority.Interactive, false, AdmissionClass.Normal), 0, 0, corr, new Uint8Array);
11258
+ const probe = (async () => {
11259
+ await writeBorrowed(sock, encodeFrame(ping), t0 + this.opts.livenessProbeWindowMs).catch(() => {});
11260
+ await this.opts.sleep(this.opts.livenessProbeWindowMs);
11261
+ if (this.sock !== sock || this.generation !== generation || this.closeStarted)
11262
+ return;
11263
+ if (this.lastInboundAtMs >= t0)
11264
+ return;
11265
+ if (this.hasControlPending())
11266
+ return;
11267
+ 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`));
11268
+ sock.close();
11269
+ })().finally(() => {
11270
+ this.livenessProbe = null;
11271
+ });
11272
+ this.livenessProbe = probe;
11273
+ }
11126
11274
  async ensureConnectedForManaged() {
11127
11275
  if (this.closeStarted)
11128
11276
  throw new SubcError("client closed");
@@ -11234,6 +11382,24 @@ class SubcClient {
11234
11382
  }
11235
11383
  }
11236
11384
  dispatch(frame) {
11385
+ this.lastInboundAtMs = Date.now();
11386
+ if (frame.header.channel === 0 && frame.header.ty === FrameType.Push) {
11387
+ const observer = this.opts.onControlPush;
11388
+ if (observer) {
11389
+ let parsed = null;
11390
+ try {
11391
+ const body = this.parseJson(frame);
11392
+ if (body && typeof body.op === "string")
11393
+ parsed = { op: body.op, body };
11394
+ } catch {}
11395
+ if (parsed) {
11396
+ try {
11397
+ observer(parsed);
11398
+ } catch {}
11399
+ }
11400
+ }
11401
+ return;
11402
+ }
11237
11403
  let handle = null;
11238
11404
  if (frame.header.channel !== 0) {
11239
11405
  handle = this.liveRoutes.get(frame.header.channel) ?? null;
@@ -11250,7 +11416,9 @@ class SubcClient {
11250
11416
  switch (frame.header.ty) {
11251
11417
  case FrameType.Push:
11252
11418
  case FrameType.StreamData:
11253
- pending.onProgress?.(frame.body);
11419
+ try {
11420
+ pending.onProgress?.(frame.body);
11421
+ } catch {}
11254
11422
  return;
11255
11423
  case FrameType.Response:
11256
11424
  case FrameType.StreamEnd:
@@ -11270,7 +11438,7 @@ class SubcClient {
11270
11438
  return;
11271
11439
  }
11272
11440
  if (frame.header.ty === FrameType.Goodbye && handle) {
11273
- this.failHandle(handle, new SubcError("route closed by subc (GOODBYE)"));
11441
+ this.failHandle(handle, new SubcError("route closed by subc (GOODBYE)", "route_closed"));
11274
11442
  if (this.liveRoutes.get(handle.channel) === handle)
11275
11443
  this.liveRoutes.delete(handle.channel);
11276
11444
  this.evictRouteHandle(handle);
@@ -11377,10 +11545,11 @@ class SubcClient {
11377
11545
  this.scheduleReconnectAfterDrop(error2);
11378
11546
  }
11379
11547
  encode(value) {
11380
- return new Uint8Array(Buffer.from(JSON.stringify(value), "utf8"));
11548
+ return Buffer.from(JSON.stringify(value), "utf8");
11381
11549
  }
11382
11550
  parseJson(frame) {
11383
- return JSON.parse(Buffer.from(frame.body).toString("utf8"));
11551
+ const b = frame.body;
11552
+ return JSON.parse(Buffer.from(b.buffer, b.byteOffset, b.byteLength).toString("utf8"));
11384
11553
  }
11385
11554
  }
11386
11555
  function isConsumerReconnectTransient(err) {
@@ -11398,7 +11567,7 @@ function isConsumerReconnectTransient(err) {
11398
11567
  return code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPIPE" || code === "ETIMEDOUT" || code === "ENOENT";
11399
11568
  }
11400
11569
  function isRetryableRouteOpenCode(code) {
11401
- return code === "unknown_module" || code === "module_reloading" || code === "target_unavailable" || code === "module_timeout";
11570
+ return code === "unknown_module" || code === "module_reloading" || code === "module_warming" || code === "target_unavailable" || code === "module_timeout";
11402
11571
  }
11403
11572
  async function connectionFileExists(path2) {
11404
11573
  try {
@@ -11416,7 +11585,9 @@ function normalizeConnectOptions(opts) {
11416
11585
  targetKind: opts.targetKind ?? DEFAULT_MANAGED_TARGET_KIND,
11417
11586
  reconnectBackoff: opts.reconnectBackoff ?? DEFAULT_RECONNECT_BACKOFF,
11418
11587
  sleep: opts.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms))),
11419
- timeoutArbitrationGraceMs: opts.timeoutArbitrationGraceMs ?? TIMEOUT_ARBITRATION_GRACE_MS
11588
+ timeoutArbitrationGraceMs: opts.timeoutArbitrationGraceMs ?? TIMEOUT_ARBITRATION_GRACE_MS,
11589
+ livenessProbeWindowMs: opts.livenessProbeWindowMs ?? LIVENESS_PROBE_WINDOW_MS,
11590
+ onControlPush: opts.onControlPush
11420
11591
  };
11421
11592
  }
11422
11593
  function routeCacheKey(target, identity, consumerIdentity) {
@@ -11448,1071 +11619,221 @@ function causeMessage(cause) {
11448
11619
  function pendingKey(handle, corr) {
11449
11620
  return handle ? `${handle.channel}:${handle.epoch}:${corr}` : `0:0:${corr}`;
11450
11621
  }
11451
- // ../../node_modules/.bun/@cortexkit+subc-client@0.5.0/node_modules/@cortexkit/subc-client/dist/provider.js
11452
- import { Buffer as Buffer2 } from "node:buffer";
11453
- var DEFAULT_HANDSHAKE_TIMEOUT_MS2 = 1e4;
11454
- var BODY_READ_TIMEOUT_MS2 = 30000;
11455
- var WRITE_TIMEOUT_MS = 30000;
11456
- var DEFAULT_RESTORED_DEBOUNCE_MS = 250;
11457
- var DEFAULT_PROVIDER_HANDLER_CAPACITY = 64;
11458
- var HEALTH_CHECK_OP = "health.check";
11459
- var HELLO_CORR = 1n;
11622
+ // ../aft-bridge/dist/subc-transport.js
11623
+ import { existsSync as existsSync3, statSync as statSync3 } from "node:fs";
11460
11624
 
11461
- class AsyncPermitPool {
11462
- available;
11463
- waiters = [];
11464
- constructor(capacity) {
11465
- if (!Number.isInteger(capacity) || capacity <= 0) {
11466
- throw new SubcProviderError("provider handler capacity must be a positive integer", "invalid_handler_capacity");
11467
- }
11468
- this.available = capacity;
11469
- }
11470
- async acquire() {
11471
- if (this.available > 0) {
11472
- this.available -= 1;
11473
- return this.releaseOnce();
11474
- }
11475
- await new Promise((resolve3) => {
11476
- this.waiters.push(resolve3);
11477
- });
11478
- return this.releaseOnce();
11479
- }
11480
- releaseOnce() {
11481
- let released = false;
11482
- return () => {
11483
- if (released)
11484
- return;
11485
- released = true;
11486
- const next = this.waiters.shift();
11487
- if (next) {
11488
- next();
11489
- } else {
11490
- this.available += 1;
11491
- }
11492
- };
11625
+ // ../aft-bridge/dist/lifecycle-registry.js
11626
+ import { lstat } from "node:fs/promises";
11627
+ function asCanonicalRootPath(root) {
11628
+ return root;
11629
+ }
11630
+ function asRootGeneration(generation) {
11631
+ if (!Number.isSafeInteger(generation) || generation < 1) {
11632
+ throw new RangeError("root generations must be positive safe integers");
11493
11633
  }
11634
+ return generation;
11494
11635
  }
11495
-
11496
- class SubcProviderError extends Error {
11497
- code;
11498
- constructor(message, code) {
11499
- super(message);
11500
- this.code = code;
11636
+ function asConcretePoolId(id) {
11637
+ return id;
11638
+ }
11639
+ var DEFAULT_LIFECYCLE_INTERVAL_MS = 5 * 60 * 1000;
11640
+ var DEFAULT_REALM = "default";
11641
+ function rootKey(root) {
11642
+ return root;
11643
+ }
11644
+ function resultMeansPresent(result) {
11645
+ if (typeof result === "boolean")
11646
+ return result;
11647
+ if (typeof result === "object" && result !== null && "exists" in result) {
11648
+ return result.exists !== false;
11501
11649
  }
11650
+ return true;
11502
11651
  }
11503
- class SubcProvider {
11504
- sock;
11505
- currentConn;
11506
- opts;
11507
- closed;
11508
- resolveClosed = () => {
11509
- return;
11652
+ function isEnoent(error2) {
11653
+ return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
11654
+ }
11655
+ function closeCounts(result) {
11656
+ const teardown = typeof result === "object" && result !== null ? result : undefined;
11657
+ const sessions = teardown?.tornDownSessionCount;
11658
+ const facades = teardown?.tornDownFacadeCount;
11659
+ return {
11660
+ sessions: typeof sessions === "number" && Number.isFinite(sessions) ? Math.max(0, sessions) : 0,
11661
+ facades: typeof facades === "number" && Number.isFinite(facades) ? Math.max(0, facades) : 0
11510
11662
  };
11511
- closeStarted = false;
11512
- closedErr = null;
11513
- inflight = new Map;
11514
- pending = new Map;
11515
- liveRoutes = new Map;
11516
- connectionToken = newConnectionToken();
11517
- nextCorr = 1n;
11518
- ingressEpochDropCount = 0;
11519
- requestGate = new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY);
11520
- reconnecting = null;
11521
- generation = 1;
11522
- connectionEpoch = 1;
11523
- stateQueue = [];
11524
- drainingStateQueue = false;
11525
- restoredDebounceToken = 0;
11526
- storage;
11527
- constructor(sock, currentConn, opts, storage) {
11528
- this.sock = sock;
11529
- this.currentConn = currentConn;
11530
- this.opts = opts;
11531
- this.storage = storage;
11532
- this.closed = new Promise((resolve3) => {
11533
- this.resolveClosed = resolve3;
11663
+ }
11664
+ function defaultTimer() {
11665
+ return {
11666
+ setInterval(callback, delayMs) {
11667
+ const handle = setInterval(callback, delayMs);
11668
+ const maybeUnref = handle;
11669
+ maybeUnref.unref?.();
11670
+ return handle;
11671
+ },
11672
+ clearInterval(handle) {
11673
+ clearInterval(handle);
11674
+ }
11675
+ };
11676
+ }
11677
+
11678
+ class LifecycleRegistry {
11679
+ realm;
11680
+ intervalMs;
11681
+ registrations = new Map;
11682
+ registrationByPool = new WeakMap;
11683
+ nextGenerationByRoot = new Map;
11684
+ nextConcretePoolNumber = 1;
11685
+ nextRegistrationSequence = 1;
11686
+ timer;
11687
+ statRoot;
11688
+ demand;
11689
+ onEvent;
11690
+ intervalHandle = null;
11691
+ sweepInFlight = null;
11692
+ constructor(options = {}) {
11693
+ this.realm = options.realm ?? DEFAULT_REALM;
11694
+ this.intervalMs = options.intervalMs ?? DEFAULT_LIFECYCLE_INTERVAL_MS;
11695
+ if (!Number.isFinite(this.intervalMs) || this.intervalMs <= 0) {
11696
+ throw new RangeError("lifecycle interval must be a positive finite number");
11697
+ }
11698
+ const nativeTimer = defaultTimer();
11699
+ this.timer = options.timer ?? (options.setInterval || options.clearInterval ? {
11700
+ setInterval: options.setInterval ?? nativeTimer.setInterval,
11701
+ clearInterval: options.clearInterval ?? nativeTimer.clearInterval
11702
+ } : nativeTimer);
11703
+ this.statRoot = options.stat ?? ((root) => lstat(root));
11704
+ this.demand = options.demandCheck ?? (() => false);
11705
+ this.onEvent = options.onEvent;
11706
+ }
11707
+ registerLifecyclePool(pool, options) {
11708
+ if (!pool || typeof pool.closeProjectRoot !== "function") {
11709
+ throw new TypeError("a lifecycle pool must provide closeProjectRoot");
11710
+ }
11711
+ if (typeof options?.evictOuterFacade !== "function") {
11712
+ throw new TypeError("lifecycle registration requires evictOuterFacade");
11713
+ }
11714
+ if (typeof options.reapingEnabled !== "boolean") {
11715
+ throw new TypeError("reapingEnabled must be a boolean");
11716
+ }
11717
+ const previous = this.registrationByPool.get(pool);
11718
+ if (previous?.active)
11719
+ this.deregisterInternal(previous);
11720
+ const concretePoolId = asConcretePoolId(`pool-${this.nextConcretePoolNumber++}`);
11721
+ const registrationIdentity = Object.freeze({
11722
+ concretePoolId,
11723
+ registrationSequence: this.nextRegistrationSequence++
11534
11724
  });
11535
- this.readLoop(sock, this.generation);
11536
- this.enqueueConnectionState({ state: "connected", epoch: this.connectionEpoch });
11725
+ const internal = {
11726
+ pool,
11727
+ concretePoolId,
11728
+ registrationIdentity,
11729
+ reapingEnabled: options.reapingEnabled,
11730
+ evictOuterFacade: options.evictOuterFacade,
11731
+ roots: new Map,
11732
+ handle: undefined,
11733
+ active: true
11734
+ };
11735
+ const handle = {
11736
+ registrationIdentity,
11737
+ identity: registrationIdentity,
11738
+ get concretePoolId() {
11739
+ return concretePoolId;
11740
+ },
11741
+ get reapingEnabled() {
11742
+ return internal.reapingEnabled;
11743
+ },
11744
+ deregister: () => {
11745
+ this.deregisterInternal(internal);
11746
+ }
11747
+ };
11748
+ internal.handle = handle;
11749
+ this.registrations.set(concretePoolId, internal);
11750
+ this.registrationByPool.set(pool, internal);
11751
+ this.refreshTimer();
11752
+ return handle;
11537
11753
  }
11538
- get droppedIngressFrames() {
11539
- return this.ingressEpochDropCount;
11754
+ registerPool(pool, options) {
11755
+ return this.registerLifecyclePool(pool, options);
11540
11756
  }
11541
- get conn() {
11542
- return this.currentConn;
11757
+ registerRoot(poolId, root) {
11758
+ const registration = this.currentRegistration(poolId);
11759
+ if (!registration)
11760
+ throw new Error(`unknown lifecycle pool ${poolId}`);
11761
+ const key = rootKey(root);
11762
+ const existing = registration.roots.get(key);
11763
+ if (existing?.state === "live")
11764
+ return existing.generation;
11765
+ if (existing && !existing.synchronousPhaseComplete) {
11766
+ throw new Error("root registration raced its synchronous close phase");
11767
+ }
11768
+ const next = (this.nextGenerationByRoot.get(`${poolId}\x00${key}`) ?? 0) + 1;
11769
+ this.nextGenerationByRoot.set(`${poolId}\x00${key}`, next);
11770
+ const entry = {
11771
+ registration,
11772
+ canonicalRoot: root,
11773
+ generation: asRootGeneration(next),
11774
+ state: "live",
11775
+ consecutiveAbsences: 0,
11776
+ tombstoned: false,
11777
+ synchronousPhaseComplete: true,
11778
+ closePromise: null,
11779
+ eventEmitted: false,
11780
+ cause: null
11781
+ };
11782
+ registration.roots.set(key, entry);
11783
+ return entry.generation;
11543
11784
  }
11544
- currentEpoch() {
11545
- return this.connectionEpoch;
11785
+ currentGeneration(poolId, root) {
11786
+ return this.currentRoot(poolId, root)?.generation;
11546
11787
  }
11547
- async request(handle, body, opts = {}) {
11548
- this.assertLiveHandle(handle);
11549
- const corr = this.allocateCorr();
11550
- const key = routeKey(handle, corr);
11551
- const timeoutMs = opts.timeoutMs ?? WRITE_TIMEOUT_MS;
11552
- const frame = buildFrame(FrameType.Request, buildFlags(false, opts.priority ?? Priority.Interactive, false, opts.admissionClass ?? AdmissionClass.Normal), handle.channel, handle.epoch, corr, body);
11553
- return await new Promise((resolve3, reject) => {
11554
- const timer = setTimeout(() => {
11555
- if (this.pending.delete(key))
11556
- reject(new SubcProviderError("reverse request timed out", "request_timeout"));
11557
- }, timeoutMs);
11558
- this.pending.set(key, {
11559
- resolve: (response) => resolve3(response.body),
11560
- reject,
11561
- timer
11562
- });
11563
- this.sendOn(this.sock, this.generation, frame).catch((error2) => {
11564
- const pending = this.pending.get(key);
11565
- if (!pending)
11566
- return;
11567
- this.pending.delete(key);
11568
- clearTimeout(pending.timer);
11569
- reject(error2 instanceof Error ? error2 : new SubcProviderError(String(error2)));
11570
- });
11571
- });
11788
+ isTombstoned(poolId, root, generation) {
11789
+ const entry = this.currentRoot(poolId, root);
11790
+ return entry?.generation === generation && entry.tombstoned;
11572
11791
  }
11573
- async push(handle, body, opts = {}) {
11574
- this.assertLiveHandle(handle);
11575
- 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));
11792
+ isCurrentRegistration(identity) {
11793
+ const registration = this.registrations.get(identity.concretePoolId);
11794
+ return registration?.active === true && registration.registrationIdentity === identity;
11576
11795
  }
11577
- cancel(handle, corr) {
11578
- this.assertLiveHandle(handle);
11579
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Cancel, controlFlags(), handle.channel, handle.epoch, corr, new Uint8Array(0)));
11796
+ isCurrentLiveGeneration(poolId, root, generation) {
11797
+ const entry = this.currentRoot(poolId, root);
11798
+ return entry?.generation === generation && entry.state === "live";
11580
11799
  }
11581
- closeRoute(handle) {
11582
- this.assertLiveHandle(handle);
11583
- this.liveRoutes.delete(handle.channel);
11584
- this.abortHandle(handle);
11585
- this.sendOn(this.sock, this.generation, buildFrame(FrameType.Goodbye, controlFlags(), handle.channel, handle.epoch, 0n, new Uint8Array(0)));
11800
+ getRootSnapshot(poolId, root) {
11801
+ const entry = this.currentRoot(poolId, root);
11802
+ return entry ? this.snapshotRoot(entry) : undefined;
11586
11803
  }
11587
- static async connect(opts) {
11588
- if (opts.manifest.protocol_ver !== PROTOCOL_VERSION) {
11589
- throw new SubcProviderError(`manifest protocol_ver ${opts.manifest.protocol_ver} does not match client protocol ${PROTOCOL_VERSION}`, "invalid_manifest");
11590
- }
11591
- const normalized = normalizeProviderConnectOptions(opts);
11592
- const opened = await SubcProvider.openConnection(normalized);
11593
- return new SubcProvider(opened.sock, opened.conn, normalized, opened.ack.storage);
11594
- }
11595
- async close() {
11596
- if (!this.closeStarted) {
11597
- this.closeStarted = true;
11598
- this.cancelRestoredDebounce();
11599
- const sock = this.sock;
11600
- try {
11601
- await sendFrame(sock, buildFrame(FrameType.Goodbye, controlFlags(), 0, 0, 0n, new Uint8Array(0)));
11602
- } catch {} finally {
11603
- sock.close();
11604
- this.finishClosed();
11605
- }
11606
- }
11607
- await this.closed;
11804
+ rootSnapshots(poolId) {
11805
+ const entries = poolId ? [this.currentRegistration(poolId)].filter((registration) => registration != null) : [...this.registrations.values()];
11806
+ return entries.flatMap((registration) => [...registration.roots.values()].map((entry) => this.snapshotRoot(entry)));
11608
11807
  }
11609
- static async openConnection(opts, onSocket) {
11610
- const conn = await readConnectionFile(opts.connectionFile);
11611
- const deadline = Date.now() + (opts.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS2);
11612
- const endpoint = conn.endpoints[0];
11613
- const sock = await SubcSocket.connect(endpoint.host, endpoint.port, deadline);
11614
- try {
11615
- onSocket?.(sock);
11616
- await authenticateClient(sock, conn, deadline);
11617
- await sendFrame(sock, buildHelloFrame(opts));
11618
- const ack = await expectHelloAck(sock, deadline);
11619
- return { sock, conn, ack };
11620
- } catch (err) {
11621
- sock.close();
11622
- throw err;
11623
- }
11808
+ snapshot() {
11809
+ return {
11810
+ realm: this.realm,
11811
+ intervalMs: this.intervalMs,
11812
+ timerActive: this.intervalHandle !== null,
11813
+ registrations: [...this.registrations.values()].map((registration) => ({
11814
+ concretePoolId: registration.concretePoolId,
11815
+ reapingEnabled: registration.reapingEnabled,
11816
+ roots: [...registration.roots.values()].map((entry) => this.snapshotRoot(entry))
11817
+ }))
11818
+ };
11624
11819
  }
11625
- async readLoop(sock, generation) {
11820
+ status() {
11821
+ return this.snapshot();
11822
+ }
11823
+ async ensureRootForDemand(poolId, root) {
11824
+ const registration = this.currentRegistration(poolId);
11825
+ if (!registration)
11826
+ return;
11827
+ const existing = registration.roots.get(rootKey(root));
11828
+ if (existing?.state === "live")
11829
+ return existing.generation;
11830
+ if (existing && !existing.synchronousPhaseComplete)
11831
+ return;
11832
+ let result;
11626
11833
  try {
11627
- for (;; ) {
11628
- const frame = await sock.readFrame(Number.POSITIVE_INFINITY, { afterHeaderMs: BODY_READ_TIMEOUT_MS2 });
11629
- const keepGoing = await this.dispatch(frame, sock, generation);
11630
- if (!keepGoing) {
11631
- if (this.sock === sock && this.generation === generation)
11632
- this.closeStarted = true;
11633
- break;
11634
- }
11635
- }
11636
- } catch (error2) {
11637
- if (this.sock === sock && this.generation === generation && !this.closeStarted) {
11638
- this.handleUnexpectedDrop(sock, generation, error2 instanceof Error ? error2 : new SubcProviderError(String(error2)));
11639
- return;
11640
- }
11641
- } finally {
11642
- if (this.sock === sock && this.generation === generation) {
11643
- sock.close();
11644
- if (this.closeStarted)
11645
- this.finishClosed();
11646
- }
11647
- }
11648
- }
11649
- async dispatch(frame, sock, generation) {
11650
- let handle = null;
11651
- if (frame.header.channel !== 0) {
11652
- handle = this.liveRoutes.get(frame.header.channel) ?? null;
11653
- if (!handle || handle.epoch !== frame.header.epoch) {
11654
- this.ingressEpochDropCount += 1;
11655
- return true;
11656
- }
11657
- }
11658
- if (handle) {
11659
- const pendingKey2 = routeKey(handle, frame.header.corr);
11660
- const pending = this.pending.get(pendingKey2);
11661
- if (pending) {
11662
- if (frame.header.ty === FrameType.Push || frame.header.ty === FrameType.StreamData)
11663
- return true;
11664
- if (frame.header.ty === FrameType.Response || frame.header.ty === FrameType.StreamEnd) {
11665
- this.pending.delete(pendingKey2);
11666
- clearTimeout(pending.timer);
11667
- pending.resolve(frame);
11668
- return true;
11669
- }
11670
- if (frame.header.ty === FrameType.Error) {
11671
- this.pending.delete(pendingKey2);
11672
- clearTimeout(pending.timer);
11673
- pending.reject(providerErrorFromFrame(frame));
11674
- return true;
11675
- }
11676
- }
11677
- }
11678
- switch (frame.header.ty) {
11679
- case FrameType.Ping:
11680
- if (frame.header.channel === 0) {
11681
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Pong, frame.header.flags, 0, 0, frame.header.corr, new Uint8Array(0)));
11682
- }
11683
- return true;
11684
- case FrameType.Goodbye:
11685
- if (!handle)
11686
- return false;
11687
- this.liveRoutes.delete(handle.channel);
11688
- this.abortHandle(handle);
11689
- await this.opts.onRouteGone?.(handle);
11690
- return true;
11691
- case FrameType.Cancel:
11692
- if (handle)
11693
- this.inflight.get(routeKey(handle, frame.header.corr))?.abort();
11694
- return true;
11695
- case FrameType.Request:
11696
- if (frame.header.channel === 0) {
11697
- await this.handleControlRequest(frame, sock, generation);
11698
- } else if (handle) {
11699
- this.handleDataRequest(frame, handle, sock, generation).catch((error2) => {
11700
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
11701
- console.warn("SubcProvider handler failed after its request was dispatched", error2);
11702
- }
11703
- });
11704
- }
11705
- return true;
11706
- default:
11707
- return true;
11708
- }
11709
- }
11710
- abortHandle(handle) {
11711
- const prefix = `${handle.channel}:${handle.epoch}:`;
11712
- for (const [key, controller] of this.inflight) {
11713
- if (key.startsWith(prefix))
11714
- controller.abort();
11715
- }
11716
- for (const [key, pending] of this.pending) {
11717
- if (!key.startsWith(prefix))
11718
- continue;
11719
- this.pending.delete(key);
11720
- clearTimeout(pending.timer);
11721
- pending.reject(new StaleRouteHandleError(handle));
11722
- }
11723
- }
11724
- abortGeneration(_generation) {
11725
- this.abortAllInflight();
11726
- for (const [key, pending] of this.pending) {
11727
- this.pending.delete(key);
11728
- clearTimeout(pending.timer);
11729
- pending.reject(new SubcProviderError("provider connection dropped", "connection_dropped"));
11730
- }
11731
- this.liveRoutes.clear();
11732
- }
11733
- abortAllInflight() {
11734
- for (const controller of this.inflight.values())
11735
- controller.abort();
11736
- }
11737
- async handleControlRequest(frame, sock, generation) {
11738
- const request = parseJson(frame.body);
11739
- if (request.op === HEALTH_CHECK_OP) {
11740
- this.handleHealthRequest(frame, sock, generation).catch((error2) => {
11741
- if (!this.closeStarted && this.sock === sock && this.generation === generation) {
11742
- console.warn("SubcProvider health handler failed after its request was dispatched", error2);
11743
- }
11744
- });
11745
- return;
11746
- }
11747
- if (request.op !== "route.bind") {
11748
- throw new SubcProviderError(`unsupported module control request ${request.op ?? "<missing op>"}`);
11749
- }
11750
- const boundChannel = numberField(request.route_channel, "route_channel");
11751
- const boundEpoch = numberField(request.epoch, "epoch");
11752
- const stale = this.liveRoutes.get(boundChannel);
11753
- if (stale) {
11754
- if (boundEpoch <= stale.epoch) {
11755
- await this.sendError(frame, "route_rejected", `route.bind epoch ${boundEpoch} does not supersede installed epoch ${stale.epoch} on channel ${boundChannel}`, controlFlags(), sock, generation);
11756
- return;
11757
- }
11758
- this.liveRoutes.delete(stale.channel);
11759
- this.abortHandle(stale);
11760
- await this.opts.onRouteGone?.(stale);
11761
- }
11762
- const tentative = createRouteHandle(boundChannel, boundEpoch, this.connectionToken);
11763
- const bindRequest = {
11764
- handle: tentative,
11765
- target: request.target,
11766
- identity: request.identity,
11767
- principal: request.principal,
11768
- consumer_capabilities: request.consumer_capabilities
11769
- };
11770
- let decision;
11771
- try {
11772
- decision = await this.opts.onBind?.(bindRequest);
11773
- } catch (error2) {
11774
- try {
11775
- await this.sendError(frame, "route_rejected", error2 instanceof Error ? error2.message : String(error2), controlFlags(), sock, generation);
11776
- } finally {
11777
- await this.opts.onRouteGone?.(tentative);
11778
- }
11779
- return;
11780
- }
11781
- const rejection = bindRejection(decision);
11782
- if (rejection) {
11783
- try {
11784
- await this.sendError(frame, rejection.code, rejection.message, controlFlags(), sock, generation);
11785
- } finally {
11786
- await this.opts.onRouteGone?.(tentative);
11787
- }
11788
- return;
11789
- }
11790
- try {
11791
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Response, controlFlags(), 0, 0, frame.header.corr, encodeJson({ op: "route.bind" })));
11792
- } catch (error2) {
11793
- await this.opts.onRouteGone?.(tentative);
11794
- throw error2;
11795
- }
11796
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr) {
11797
- await this.opts.onRouteGone?.(tentative);
11798
- return;
11799
- }
11800
- this.liveRoutes.set(tentative.channel, tentative);
11801
- await this.opts.onBound?.(tentative);
11802
- }
11803
- async handleDataRequest(frame, handle, sock, generation) {
11804
- const { corr, ver } = frame.header;
11805
- const key = routeKey(handle, corr);
11806
- const controller = new AbortController;
11807
- this.inflight.set(key, controller);
11808
- const context = {
11809
- handle,
11810
- signal: controller.signal,
11811
- currentEpoch: () => this.connectionEpoch,
11812
- emit: async (eventBody, options = {}) => {
11813
- this.assertLiveHandle(handle);
11814
- if (controller.signal.aborted)
11815
- return;
11816
- 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));
11817
- }
11818
- };
11819
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
11820
- const dataFlags = buildFlags(false, Priority.Interactive, false);
11821
- try {
11822
- const body = await this.opts.handler(handle, frame.body, context);
11823
- if (controller.signal.aborted)
11824
- return;
11825
- this.assertLiveHandle(handle);
11826
- if (body === undefined) {
11827
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.StreamEnd, dataFlags, handle.channel, handle.epoch, corr, new Uint8Array(0)));
11828
- } else if (body instanceof Uint8Array) {
11829
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, dataFlags, handle.channel, handle.epoch, corr, body));
11830
- } else {
11831
- throw new SubcProviderError("provider handler must return a Uint8Array or void", "invalid_handler_response");
11832
- }
11833
- } catch (error2) {
11834
- if (error2 instanceof StaleRouteHandleError || controller.signal.aborted)
11835
- return;
11836
- await this.sendError(frame, error2 instanceof SubcProviderError && error2.code ? error2.code : "handler_error", error2 instanceof Error ? error2.message : String(error2), dataFlags, sock, generation);
11837
- } finally {
11838
- releasePermit();
11839
- if (this.inflight.get(key) === controller)
11840
- this.inflight.delete(key);
11841
- }
11842
- }
11843
- async handleHealthRequest(frame, sock, generation) {
11844
- const { corr, ver } = frame.header;
11845
- const key = `control:${generation}:${corr}`;
11846
- const controller = new AbortController;
11847
- this.inflight.set(key, controller);
11848
- const releasePermit = await (this.requestGate ?? new AsyncPermitPool(DEFAULT_PROVIDER_HANDLER_CAPACITY)).acquire();
11849
- try {
11850
- if (controller.signal.aborted)
11851
- return;
11852
- const report = await this.opts.health();
11853
- await this.sendOn(sock, generation, buildFrameWithVersion(ver, FrameType.Response, controlFlags(), 0, 0, corr, encodeJson({
11854
- op: HEALTH_CHECK_OP,
11855
- status: report.status,
11856
- ...report.detail === undefined ? {} : { detail: report.detail },
11857
- ...report.metrics === undefined ? {} : { metrics: report.metrics }
11858
- })));
11859
- } catch (error2) {
11860
- await this.sendError(frame, error2 instanceof SubcProviderError && error2.code ? error2.code : "health_error", error2 instanceof Error ? error2.message : String(error2), controlFlags(), sock, generation);
11861
- } finally {
11862
- releasePermit();
11863
- if (this.inflight.get(key) === controller)
11864
- this.inflight.delete(key);
11865
- }
11866
- }
11867
- async sendError(frame, code, message, flags, sock, generation) {
11868
- await this.sendOn(sock, generation, buildFrameWithVersion(frame.header.ver, FrameType.Error, flags, frame.header.channel, frame.header.epoch, frame.header.corr, encodeJson({ code, message })));
11869
- }
11870
- async sendOn(sock, generation, frame) {
11871
- if (this.sock !== sock || this.generation !== generation || this.closeStarted || this.closedErr)
11872
- return;
11873
- await sendFrame(sock, frame);
11874
- }
11875
- handleUnexpectedDrop(sock, generation, cause) {
11876
- if (this.closeStarted || this.sock !== sock || this.generation !== generation)
11877
- return;
11878
- this.cancelRestoredDebounce();
11879
- this.abortGeneration(generation);
11880
- this.generation += 1;
11881
- sock.close();
11882
- this.scheduleReconnectAfterDrop(cause, this.generation, sock);
11883
- }
11884
- scheduleReconnectAfterDrop(cause, generation, droppedSocket) {
11885
- if (this.closeStarted)
11886
- return;
11887
- const previous = this.reconnecting;
11888
- if (previous) {
11889
- if (!this.shouldSupersedeReconnect(previous, generation, droppedSocket))
11890
- return;
11891
- previous.superseded = true;
11892
- previous.socket?.close();
11893
- }
11894
- const cycle = {
11895
- generation,
11896
- socket: null,
11897
- socketDied: false,
11898
- superseded: false
11899
- };
11900
- this.reconnecting = cycle;
11901
- this.enqueueConnectionState({ state: "down", cause });
11902
- this.reconnectWithRetry(cycle).catch((err) => {
11903
- if (this.isCurrentReconnect(cycle) && !this.closeStarted) {
11904
- this.failFatal(err instanceof Error ? err : new SubcProviderError(String(err)));
11905
- }
11906
- }).finally(() => {
11907
- if (this.isCurrentReconnect(cycle))
11908
- this.reconnecting = null;
11909
- });
11910
- }
11911
- async reconnectWithRetry(cycle) {
11912
- let attempt = 0;
11913
- let delay = this.opts.reconnectBackoff.baseMs;
11914
- for (;; ) {
11915
- if (!this.isCurrentReconnect(cycle))
11916
- return;
11917
- if (this.closeStarted)
11918
- throw new SubcProviderError("provider closed");
11919
- cycle.socket = null;
11920
- cycle.socketDied = false;
11921
- attempt += 1;
11922
- this.enqueueReconnectState(cycle, attempt);
11923
- try {
11924
- const opened = await SubcProvider.openConnection(this.opts, (sock) => {
11925
- if (!this.isCurrentReconnect(cycle)) {
11926
- sock.close();
11927
- return;
11928
- }
11929
- cycle.socket = sock;
11930
- });
11931
- if (!this.isCurrentReconnect(cycle) || this.closeStarted) {
11932
- opened.sock.close();
11933
- if (this.closeStarted)
11934
- throw new SubcProviderError("provider closed");
11935
- return;
11936
- }
11937
- const epoch = this.replaceConnection(opened, cycle.generation);
11938
- this.reconnecting = null;
11939
- if (this.reconnecting !== null) {
11940
- throw new SubcProviderError("reconnect state must clear before restored", "reconnect_state");
11941
- }
11942
- this.scheduleRestored(cycle.generation, epoch);
11943
- return;
11944
- } catch (err) {
11945
- if (!this.isCurrentReconnect(cycle))
11946
- return;
11947
- if (cycle.socket)
11948
- cycle.socketDied = true;
11949
- if (this.closeStarted)
11950
- throw err;
11951
- if (!isProviderReconnectTransient(err))
11952
- throw err;
11953
- await this.opts.sleep(delay);
11954
- delay = Math.min(delay * 2, this.opts.reconnectBackoff.capMs);
11955
- }
11956
- }
11957
- }
11958
- isCurrentReconnect(cycle) {
11959
- return !cycle.superseded && this.reconnecting === cycle && this.generation === cycle.generation;
11960
- }
11961
- shouldSupersedeReconnect(cycle, generation, droppedSocket) {
11962
- return cycle.generation < generation || cycle.socketDied || cycle.socket === droppedSocket;
11963
- }
11964
- enqueueReconnectState(cycle, attempt) {
11965
- if (!this.isCurrentReconnect(cycle))
11966
- return;
11967
- this.enqueueConnectionState({ state: "reconnecting", attempt }, cycle.generation, cycle);
11968
- }
11969
- replaceConnection(opened, generation) {
11970
- this.sock.close();
11971
- this.sock = opened.sock;
11972
- this.currentConn = opened.conn;
11973
- this.storage = opened.ack.storage;
11974
- this.closedErr = null;
11975
- this.connectionEpoch += 1;
11976
- this.connectionToken = newConnectionToken();
11977
- this.liveRoutes.clear();
11978
- this.nextCorr = 1n;
11979
- this.readLoop(opened.sock, generation);
11980
- return this.connectionEpoch;
11981
- }
11982
- scheduleRestored(generation, epoch) {
11983
- if (!this.opts.onConnectionState)
11984
- return;
11985
- const token = ++this.restoredDebounceToken;
11986
- this.opts.sleep(this.opts.restoredDebounceMs).then(() => {
11987
- if (token === this.restoredDebounceToken && !this.closeStarted && this.sock && this.generation === generation && this.connectionEpoch === epoch) {
11988
- this.enqueueConnectionState({ state: "restored", epoch }, generation);
11989
- }
11990
- }).catch((err) => {
11991
- if (token === this.restoredDebounceToken && !this.closeStarted) {
11992
- console.warn("SubcProvider restored debounce timer failed", err);
11993
- }
11994
- });
11995
- }
11996
- cancelRestoredDebounce() {
11997
- this.restoredDebounceToken += 1;
11998
- }
11999
- enqueueConnectionState(event, generation, reconnect) {
12000
- if (!this.opts.onConnectionState)
12001
- return;
12002
- this.stateQueue.push({ event, generation, reconnect });
12003
- if (!this.drainingStateQueue)
12004
- this.drainConnectionStateQueue();
12005
- }
12006
- async drainConnectionStateQueue() {
12007
- if (this.drainingStateQueue)
12008
- return;
12009
- this.drainingStateQueue = true;
12010
- try {
12011
- while (this.stateQueue.length > 0) {
12012
- const queued = this.stateQueue[0];
12013
- if (this.closeStarted || queued.generation !== undefined && queued.generation !== this.generation || queued.reconnect?.superseded) {
12014
- this.stateQueue.shift();
12015
- continue;
12016
- }
12017
- const { event } = queued;
12018
- try {
12019
- await this.opts.onConnectionState?.(event);
12020
- this.stateQueue.shift();
12021
- } catch (err) {
12022
- if (event.state === "restored") {
12023
- console.warn("SubcProvider restored callback failed; retrying delivery", err);
12024
- await pauseBeforeStateRetry();
12025
- continue;
12026
- }
12027
- console.warn("SubcProvider connection-state callback failed", err);
12028
- this.stateQueue.shift();
12029
- }
12030
- }
12031
- } finally {
12032
- this.drainingStateQueue = false;
12033
- if (this.stateQueue.length > 0)
12034
- this.drainConnectionStateQueue();
12035
- }
12036
- }
12037
- isLiveHandle(handle) {
12038
- return belongsToConnection(handle, this.connectionToken) && this.liveRoutes.get(handle.channel) === handle;
12039
- }
12040
- assertLiveHandle(handle) {
12041
- if (!this.isLiveHandle(handle))
12042
- throw new StaleRouteHandleError(handle);
12043
- }
12044
- allocateCorr() {
12045
- const maximum = 0xffffffffffffffffn;
12046
- if (this.nextCorr > maximum) {
12047
- const error2 = new SubcProviderError("channel-0 correlation id allocator exhausted", "corr_exhausted");
12048
- this.handleUnexpectedDrop(this.sock, this.generation, error2);
12049
- throw error2;
12050
- }
12051
- const corr = this.nextCorr;
12052
- this.nextCorr += 1n;
12053
- return corr;
12054
- }
12055
- failFatal(err) {
12056
- if (!this.closedErr)
12057
- this.closedErr = err;
12058
- this.closeStarted = true;
12059
- this.cancelRestoredDebounce();
12060
- this.abortAllInflight();
12061
- this.sock.close();
12062
- this.finishClosed();
12063
- }
12064
- finishClosed() {
12065
- this.resolveClosed();
12066
- }
12067
- }
12068
- function routeKey(handle, corr) {
12069
- return `${handle.channel}:${handle.epoch}:${corr}`;
12070
- }
12071
- function providerErrorFromFrame(frame) {
12072
- try {
12073
- const body = parseJson(frame.body);
12074
- return new SubcProviderError(body.message ?? "subc error", body.code);
12075
- } catch {
12076
- return new SubcProviderError(Buffer2.from(frame.body).toString("utf8") || "subc error");
12077
- }
12078
- }
12079
- function launchNonce(opts) {
12080
- const nonce = opts.launchNonce ?? process.env[SUBC_LAUNCH_NONCE_ENV2];
12081
- return nonce && nonce.length > 0 ? nonce : undefined;
12082
- }
12083
- var SUBC_LAUNCH_NONCE_ENV2 = "SUBC_LAUNCH_NONCE";
12084
- function normalizeProviderConnectOptions(opts) {
12085
- return {
12086
- connectionFile: opts.connectionFile,
12087
- manifest: opts.manifest,
12088
- handler: opts.handler,
12089
- health: opts.health ?? (() => ({ status: "ok" })),
12090
- handshakeTimeoutMs: opts.handshakeTimeoutMs,
12091
- controlOps: opts.controlOps,
12092
- onBind: opts.onBind,
12093
- onBound: opts.onBound,
12094
- onRouteGone: opts.onRouteGone,
12095
- reconnectBackoff: opts.reconnectBackoff ?? DEFAULT_RECONNECT_BACKOFF,
12096
- sleep: opts.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms))),
12097
- restoredDebounceMs: opts.restoredDebounceMs ?? DEFAULT_RESTORED_DEBOUNCE_MS,
12098
- onConnectionState: opts.onConnectionState,
12099
- launchNonce: opts.launchNonce
12100
- };
12101
- }
12102
- function normalizedControlOps(controlOps) {
12103
- if (controlOps === null)
12104
- return null;
12105
- const merged = new Set(controlOps ?? []);
12106
- merged.add(HEALTH_CHECK_OP);
12107
- return [...merged];
12108
- }
12109
- function buildHelloFrame(opts) {
12110
- const nonce = launchNonce(opts);
12111
- return buildFrame(FrameType.Hello, controlFlags(), 0, 0, HELLO_CORR, encodeJson({
12112
- manifest: normalizeManifest(opts.manifest),
12113
- protocol_ver: PROTOCOL_VERSION,
12114
- control_ops: normalizedControlOps(opts.controlOps),
12115
- ...nonce ? { launch_nonce: nonce } : {}
12116
- }));
12117
- }
12118
- function isProviderReconnectTransient(err) {
12119
- if (err instanceof SubcProviderError)
12120
- return err.code === "duplicate_module_id";
12121
- if (err instanceof SocketClosedError || err instanceof SocketTimeoutError)
12122
- return true;
12123
- if (err instanceof SocketWriteNotQueuedError || err instanceof SocketWriteQueuedError)
12124
- return true;
12125
- if (err instanceof AuthError)
12126
- return true;
12127
- if (err instanceof ConnectionFileError)
12128
- return false;
12129
- const code = errorCode2(err);
12130
- return code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPIPE" || code === "ETIMEDOUT" || code === "ENOENT";
12131
- }
12132
- function errorCode2(err) {
12133
- if (typeof err === "object" && err !== null && "code" in err) {
12134
- const code = err.code;
12135
- if (typeof code === "string")
12136
- return code;
12137
- }
12138
- return;
12139
- }
12140
- async function pauseBeforeStateRetry() {
12141
- await new Promise((resolve3) => setTimeout(resolve3, 0));
12142
- }
12143
- function controlFlags() {
12144
- return buildFlags(false, Priority.Passive, false);
12145
- }
12146
- async function sendFrame(sock, frame) {
12147
- await sock.write(encodeFrame(frame), Date.now() + WRITE_TIMEOUT_MS);
12148
- }
12149
- async function expectHelloAck(sock, deadline) {
12150
- const frame = await sock.readFrame(deadline, deadline);
12151
- switch (frame.header.ty) {
12152
- case FrameType.HelloAck: {
12153
- const ack = parseJson(frame.body);
12154
- if (ack.negotiated_ver !== PROTOCOL_VERSION) {
12155
- throw new SubcProviderError(`subc negotiated protocol ${ack.negotiated_ver}; expected exactly ${PROTOCOL_VERSION}`, "unsupported_version");
12156
- }
12157
- return ack;
12158
- }
12159
- case FrameType.Error: {
12160
- const error2 = parseJson(frame.body);
12161
- throw new SubcProviderError(`subc rejected HELLO: ${error2.code ?? "unknown"} — ${error2.message ?? "subc error"}`, error2.code);
12162
- }
12163
- default:
12164
- throw new SubcProviderError(`unexpected frame ${FrameType[frame.header.ty]} awaiting HELLO_ACK`);
12165
- }
12166
- }
12167
- function encodeJson(value) {
12168
- return new Uint8Array(Buffer2.from(JSON.stringify(value), "utf8"));
12169
- }
12170
- function parseJson(bytes) {
12171
- return JSON.parse(Buffer2.from(bytes).toString("utf8"));
12172
- }
12173
- function numberField(value, field) {
12174
- if (typeof value !== "number" || !Number.isInteger(value)) {
12175
- throw new SubcProviderError(`route.bind ${field} must be an integer`);
12176
- }
12177
- return value;
12178
- }
12179
- function bindRejection(decision) {
12180
- if (decision === undefined || decision === true)
12181
- return null;
12182
- if (decision === false) {
12183
- return { code: "route_rejected", message: "route.bind rejected by provider" };
12184
- }
12185
- if (decision.accept)
12186
- return null;
12187
- return {
12188
- code: decision.code ?? "route_rejected",
12189
- message: decision.message ?? "route.bind rejected by provider"
12190
- };
12191
- }
12192
- function normalizeManifest(manifest) {
12193
- return {
12194
- module_id: manifest.module_id,
12195
- module_version: manifest.module_version,
12196
- protocol_ver: manifest.protocol_ver,
12197
- trust_tier: manifest.trust_tier,
12198
- provides: manifest.provides.map(normalizeProviderRole),
12199
- consumes: manifest.consumes.map(normalizeConsumerRole),
12200
- scheduled_tasks: manifest.scheduled_tasks.map(normalizeScheduledTask),
12201
- bindings: {
12202
- storage: {
12203
- kind: manifest.bindings.storage.kind,
12204
- scope: manifest.bindings.storage.scope,
12205
- owns_schema: manifest.bindings.storage.owns_schema
12206
- },
12207
- vault_grants: manifest.bindings.vault_grants.map((grant) => ({
12208
- secret: grant.secret,
12209
- reason: grant.reason
12210
- })),
12211
- identity: {
12212
- requires: [...manifest.bindings.identity.requires],
12213
- optional: [...manifest.bindings.identity.optional]
12214
- }
12215
- }
12216
- };
12217
- }
12218
- function normalizeProviderRole(role) {
12219
- switch (role.role) {
12220
- case "tool_provider":
12221
- return {
12222
- role: "tool_provider",
12223
- tools: role.tools.map((tool) => ({
12224
- name: tool.name,
12225
- ...tool.description === undefined ? {} : { description: tool.description },
12226
- execution_mode: tool.execution_mode,
12227
- schema: tool.schema
12228
- })),
12229
- identity_scope: [...role.identity_scope],
12230
- concurrency: role.concurrency,
12231
- emits_push: role.emits_push,
12232
- sub_supervises: role.sub_supervises
12233
- };
12234
- case "pipeline_stage":
12235
- return {
12236
- role: "pipeline_stage",
12237
- stage: role.stage,
12238
- applies_to: {
12239
- provider: role.applies_to.provider,
12240
- model: role.applies_to.model
12241
- },
12242
- interface: role.interface,
12243
- declares_frozen_floor: role.declares_frozen_floor,
12244
- needs_signals: [...role.needs_signals],
12245
- conformance_class: role.conformance_class
12246
- };
12247
- case "management_surface":
12248
- return {
12249
- role: "management_surface",
12250
- operations: role.operations.map((operation) => ({
12251
- name: operation.name,
12252
- kind: operation.kind
12253
- })),
12254
- config_schema: role.config_schema,
12255
- observability: role.observability.map((surface) => ({
12256
- name: surface.name,
12257
- kind: surface.kind
12258
- })),
12259
- identity_scope: [...role.identity_scope]
12260
- };
12261
- case "internal_service":
12262
- return {
12263
- role: "internal_service",
12264
- service_id: role.service_id,
12265
- transport: role.transport,
12266
- agent_facing: role.agent_facing,
12267
- operations: [...role.operations]
12268
- };
12269
- }
12270
- }
12271
- function normalizeConsumerRole(role) {
12272
- switch (role.role) {
12273
- case "tool_client":
12274
- return { role: "tool_client", of: [...role.of] };
12275
- case "llm_client":
12276
- return { role: "llm_client", via: role.via, auth: role.auth };
12277
- case "service_client":
12278
- return { role: "service_client", of: [...role.of] };
12279
- }
12280
- }
12281
- function normalizeScheduledTask(task) {
12282
- return {
12283
- task_id: task.task_id,
12284
- eligibility: {
12285
- cooldown: task.eligibility.cooldown,
12286
- window: task.eligibility.window
12287
- },
12288
- lease_scope: task.lease_scope,
12289
- renews_during_calls: task.renews_during_calls,
12290
- toolset: [...task.toolset],
12291
- model_policy: {
12292
- tier: task.model_policy.tier,
12293
- fallback_chain: [...task.model_policy.fallback_chain]
12294
- },
12295
- step_cap: task.step_cap,
12296
- circuit_breaker: {
12297
- identical_failures: task.circuit_breaker.identical_failures
12298
- }
12299
- };
12300
- }
12301
- // ../aft-bridge/dist/subc-transport.js
12302
- import { existsSync as existsSync3, statSync as statSync3 } from "node:fs";
12303
-
12304
- // ../aft-bridge/dist/lifecycle-registry.js
12305
- import { lstat } from "node:fs/promises";
12306
- function asCanonicalRootPath(root) {
12307
- return root;
12308
- }
12309
- function asRootGeneration(generation) {
12310
- if (!Number.isSafeInteger(generation) || generation < 1) {
12311
- throw new RangeError("root generations must be positive safe integers");
12312
- }
12313
- return generation;
12314
- }
12315
- function asConcretePoolId(id) {
12316
- return id;
12317
- }
12318
- var DEFAULT_LIFECYCLE_INTERVAL_MS = 5 * 60 * 1000;
12319
- var DEFAULT_REALM = "default";
12320
- function rootKey(root) {
12321
- return root;
12322
- }
12323
- function resultMeansPresent(result) {
12324
- if (typeof result === "boolean")
12325
- return result;
12326
- if (typeof result === "object" && result !== null && "exists" in result) {
12327
- return result.exists !== false;
12328
- }
12329
- return true;
12330
- }
12331
- function isEnoent(error2) {
12332
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
12333
- }
12334
- function closeCounts(result) {
12335
- const teardown = typeof result === "object" && result !== null ? result : undefined;
12336
- const sessions = teardown?.tornDownSessionCount;
12337
- const facades = teardown?.tornDownFacadeCount;
12338
- return {
12339
- sessions: typeof sessions === "number" && Number.isFinite(sessions) ? Math.max(0, sessions) : 0,
12340
- facades: typeof facades === "number" && Number.isFinite(facades) ? Math.max(0, facades) : 0
12341
- };
12342
- }
12343
- function defaultTimer() {
12344
- return {
12345
- setInterval(callback, delayMs) {
12346
- const handle = setInterval(callback, delayMs);
12347
- const maybeUnref = handle;
12348
- maybeUnref.unref?.();
12349
- return handle;
12350
- },
12351
- clearInterval(handle) {
12352
- clearInterval(handle);
12353
- }
12354
- };
12355
- }
12356
-
12357
- class LifecycleRegistry {
12358
- realm;
12359
- intervalMs;
12360
- registrations = new Map;
12361
- registrationByPool = new WeakMap;
12362
- nextGenerationByRoot = new Map;
12363
- nextConcretePoolNumber = 1;
12364
- nextRegistrationSequence = 1;
12365
- timer;
12366
- statRoot;
12367
- demand;
12368
- onEvent;
12369
- intervalHandle = null;
12370
- sweepInFlight = null;
12371
- constructor(options = {}) {
12372
- this.realm = options.realm ?? DEFAULT_REALM;
12373
- this.intervalMs = options.intervalMs ?? DEFAULT_LIFECYCLE_INTERVAL_MS;
12374
- if (!Number.isFinite(this.intervalMs) || this.intervalMs <= 0) {
12375
- throw new RangeError("lifecycle interval must be a positive finite number");
12376
- }
12377
- const nativeTimer = defaultTimer();
12378
- this.timer = options.timer ?? (options.setInterval || options.clearInterval ? {
12379
- setInterval: options.setInterval ?? nativeTimer.setInterval,
12380
- clearInterval: options.clearInterval ?? nativeTimer.clearInterval
12381
- } : nativeTimer);
12382
- this.statRoot = options.stat ?? ((root) => lstat(root));
12383
- this.demand = options.demandCheck ?? (() => false);
12384
- this.onEvent = options.onEvent;
12385
- }
12386
- registerLifecyclePool(pool, options) {
12387
- if (!pool || typeof pool.closeProjectRoot !== "function") {
12388
- throw new TypeError("a lifecycle pool must provide closeProjectRoot");
12389
- }
12390
- if (typeof options?.evictOuterFacade !== "function") {
12391
- throw new TypeError("lifecycle registration requires evictOuterFacade");
12392
- }
12393
- if (typeof options.reapingEnabled !== "boolean") {
12394
- throw new TypeError("reapingEnabled must be a boolean");
12395
- }
12396
- const previous = this.registrationByPool.get(pool);
12397
- if (previous?.active)
12398
- this.deregisterInternal(previous);
12399
- const concretePoolId = asConcretePoolId(`pool-${this.nextConcretePoolNumber++}`);
12400
- const registrationIdentity = Object.freeze({
12401
- concretePoolId,
12402
- registrationSequence: this.nextRegistrationSequence++
12403
- });
12404
- const internal = {
12405
- pool,
12406
- concretePoolId,
12407
- registrationIdentity,
12408
- reapingEnabled: options.reapingEnabled,
12409
- evictOuterFacade: options.evictOuterFacade,
12410
- roots: new Map,
12411
- handle: undefined,
12412
- active: true
12413
- };
12414
- const handle = {
12415
- registrationIdentity,
12416
- identity: registrationIdentity,
12417
- get concretePoolId() {
12418
- return concretePoolId;
12419
- },
12420
- get reapingEnabled() {
12421
- return internal.reapingEnabled;
12422
- },
12423
- deregister: () => {
12424
- this.deregisterInternal(internal);
12425
- }
12426
- };
12427
- internal.handle = handle;
12428
- this.registrations.set(concretePoolId, internal);
12429
- this.registrationByPool.set(pool, internal);
12430
- this.refreshTimer();
12431
- return handle;
12432
- }
12433
- registerPool(pool, options) {
12434
- return this.registerLifecyclePool(pool, options);
12435
- }
12436
- registerRoot(poolId, root) {
12437
- const registration = this.currentRegistration(poolId);
12438
- if (!registration)
12439
- throw new Error(`unknown lifecycle pool ${poolId}`);
12440
- const key = rootKey(root);
12441
- const existing = registration.roots.get(key);
12442
- if (existing?.state === "live")
12443
- return existing.generation;
12444
- if (existing && !existing.synchronousPhaseComplete) {
12445
- throw new Error("root registration raced its synchronous close phase");
12446
- }
12447
- const next = (this.nextGenerationByRoot.get(`${poolId}\x00${key}`) ?? 0) + 1;
12448
- this.nextGenerationByRoot.set(`${poolId}\x00${key}`, next);
12449
- const entry = {
12450
- registration,
12451
- canonicalRoot: root,
12452
- generation: asRootGeneration(next),
12453
- state: "live",
12454
- consecutiveAbsences: 0,
12455
- tombstoned: false,
12456
- synchronousPhaseComplete: true,
12457
- closePromise: null,
12458
- eventEmitted: false,
12459
- cause: null
12460
- };
12461
- registration.roots.set(key, entry);
12462
- return entry.generation;
12463
- }
12464
- currentGeneration(poolId, root) {
12465
- return this.currentRoot(poolId, root)?.generation;
12466
- }
12467
- isTombstoned(poolId, root, generation) {
12468
- const entry = this.currentRoot(poolId, root);
12469
- return entry?.generation === generation && entry.tombstoned;
12470
- }
12471
- isCurrentRegistration(identity) {
12472
- const registration = this.registrations.get(identity.concretePoolId);
12473
- return registration?.active === true && registration.registrationIdentity === identity;
12474
- }
12475
- isCurrentLiveGeneration(poolId, root, generation) {
12476
- const entry = this.currentRoot(poolId, root);
12477
- return entry?.generation === generation && entry.state === "live";
12478
- }
12479
- getRootSnapshot(poolId, root) {
12480
- const entry = this.currentRoot(poolId, root);
12481
- return entry ? this.snapshotRoot(entry) : undefined;
12482
- }
12483
- rootSnapshots(poolId) {
12484
- const entries = poolId ? [this.currentRegistration(poolId)].filter((registration) => registration != null) : [...this.registrations.values()];
12485
- return entries.flatMap((registration) => [...registration.roots.values()].map((entry) => this.snapshotRoot(entry)));
12486
- }
12487
- snapshot() {
12488
- return {
12489
- realm: this.realm,
12490
- intervalMs: this.intervalMs,
12491
- timerActive: this.intervalHandle !== null,
12492
- registrations: [...this.registrations.values()].map((registration) => ({
12493
- concretePoolId: registration.concretePoolId,
12494
- reapingEnabled: registration.reapingEnabled,
12495
- roots: [...registration.roots.values()].map((entry) => this.snapshotRoot(entry))
12496
- }))
12497
- };
12498
- }
12499
- status() {
12500
- return this.snapshot();
12501
- }
12502
- async ensureRootForDemand(poolId, root) {
12503
- const registration = this.currentRegistration(poolId);
12504
- if (!registration)
12505
- return;
12506
- const existing = registration.roots.get(rootKey(root));
12507
- if (existing?.state === "live")
12508
- return existing.generation;
12509
- if (existing && !existing.synchronousPhaseComplete)
12510
- return;
12511
- let result;
12512
- try {
12513
- result = await this.demand(root, poolId);
12514
- } catch {
12515
- return;
11834
+ result = await this.demand(root, poolId);
11835
+ } catch {
11836
+ return;
12516
11837
  }
12517
11838
  if (!resultMeansPresent(result))
12518
11839
  return;
@@ -12764,7 +12085,14 @@ class SubcTransportShuttingDownError extends SubcCallError {
12764
12085
  }
12765
12086
  var AFT_MODULE_ID = "aft";
12766
12087
  var MAX_CONSECUTIVE_TRANSPORT_FAILURES = 3;
12088
+ var RECONNECT_RETRY_FLOOR_MS = 100;
12089
+ var RECONNECT_RETRY_CAP_MS = 2000;
12090
+ var ROUTE_OPEN_RELOAD_WAIT_CAP_MS = 15000;
12091
+ var ROUTE_OPEN_RELOAD_WAIT_EXHAUSTED_SUFFIX = " The AFT daemon module did not return within the 15s reload window.";
12767
12092
  var BG_STABLE_MS = 5000;
12093
+ function reconnectBackoffMs(attempt) {
12094
+ return Math.min(RECONNECT_RETRY_FLOOR_MS * 2 ** Math.min(attempt, 6), RECONNECT_RETRY_CAP_MS);
12095
+ }
12768
12096
  var BG_LIFECYCLE_LOG_INTERVAL_MS = 60000;
12769
12097
  var BG_DISPATCH_PROBE_INTERVAL_MS = 60000;
12770
12098
  var DEFAULT_SESSION_ID = "__default__";
@@ -13028,6 +12356,8 @@ class BgSubscription {
13028
12356
  giveUp("stopped");
13029
12357
  return;
13030
12358
  }
12359
+ if (Date.now() - subscribedAt >= BG_STABLE_MS)
12360
+ backoffAttempt = 0;
13031
12361
  beginReconnect();
13032
12362
  } catch (err) {
13033
12363
  const routeId2 = this.routeId(route);
@@ -13052,8 +12382,7 @@ class BgSubscription {
13052
12382
  giveUp("stopped");
13053
12383
  }
13054
12384
  async backoff(attempt) {
13055
- const ms = Math.min(100 * 2 ** Math.min(attempt, 6), 2000);
13056
- await this.sleep(ms);
12385
+ await this.sleep(reconnectBackoffMs(attempt));
13057
12386
  }
13058
12387
  }
13059
12388
  function isRecord(value) {
@@ -13068,6 +12397,15 @@ function isAbsentRootRouteError(err) {
13068
12397
  function absentRootError(root) {
13069
12398
  return new SubcError(`invalid route project root: project root does not exist: ${root}`, "config_divergence");
13070
12399
  }
12400
+ function reloadWindowExhaustedError(error2) {
12401
+ if (error2 instanceof Error) {
12402
+ try {
12403
+ error2.message += ROUTE_OPEN_RELOAD_WAIT_EXHAUSTED_SUFFIX;
12404
+ return error2;
12405
+ } catch {}
12406
+ }
12407
+ return new Error(`${String(error2)}${ROUTE_OPEN_RELOAD_WAIT_EXHAUSTED_SUFFIX}`);
12408
+ }
13071
12409
  function safeCloseRoute(client, route) {
13072
12410
  try {
13073
12411
  client.closeRouteChannel(route).catch(() => {
@@ -13179,6 +12517,7 @@ class SubcTransportPool {
13179
12517
  onBgEventsNudge;
13180
12518
  onBgEventsNudgeRef;
13181
12519
  bgBackoffSleep;
12520
+ routeRetrySleep;
13182
12521
  bgDispatchProbeIntervalMs;
13183
12522
  lifecycleDemandCheck;
13184
12523
  onLifecycleEvent;
@@ -13189,6 +12528,9 @@ class SubcTransportPool {
13189
12528
  outerFacadeEvictor;
13190
12529
  client = null;
13191
12530
  connecting = null;
12531
+ routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
12532
+ routeReopenRetry = null;
12533
+ routeReopenRetryMs = null;
13192
12534
  sessions = new Map;
13193
12535
  rootIndex = new Map;
13194
12536
  dormantRoots = new Map;
@@ -13209,6 +12551,7 @@ class SubcTransportPool {
13209
12551
  this.onBgEventsNudge = options.onBgEventsNudge;
13210
12552
  this.onBgEventsNudgeRef = options.onBgEventsNudgeRef;
13211
12553
  this.bgBackoffSleep = options.bgBackoffSleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
12554
+ this.routeRetrySleep = options.routeRetrySleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
13212
12555
  this.bgDispatchProbeIntervalMs = options.bgDispatchProbeIntervalMs ?? BG_DISPATCH_PROBE_INTERVAL_MS;
13213
12556
  const lifecycle = options.lifecycle;
13214
12557
  const demandCheck = options.lifecycleDemandCheck ?? options.demandCheck ?? lifecycle?.demandCheck;
@@ -13661,6 +13004,23 @@ class SubcTransportPool {
13661
13004
  throw error2;
13662
13005
  }
13663
13006
  };
13007
+ const openRouteAfterReloadWindow = async () => {
13008
+ let reloadWaitedMs = 0;
13009
+ while (true) {
13010
+ try {
13011
+ return await openRoute();
13012
+ } catch (error2) {
13013
+ if (!isRouteOpenReloadWindowError(error2))
13014
+ throw error2;
13015
+ const { delayMs, wait } = this.waitForRouteReopenBackoff();
13016
+ if (reloadWaitedMs + delayMs > ROUTE_OPEN_RELOAD_WAIT_CAP_MS) {
13017
+ throw reloadWindowExhaustedError(error2);
13018
+ }
13019
+ reloadWaitedMs += delayMs;
13020
+ await wait;
13021
+ }
13022
+ }
13023
+ };
13664
13024
  const clearRouteEntry = (entry) => {
13665
13025
  if (record.routeEntry !== entry)
13666
13026
  return;
@@ -13697,7 +13057,7 @@ class SubcTransportPool {
13697
13057
  this.ensureBgSubscription(identity, record);
13698
13058
  return reply;
13699
13059
  };
13700
- let routeAndEntry = await openRoute();
13060
+ let routeAndEntry = await openRouteAfterReloadWindow();
13701
13061
  try {
13702
13062
  return await requestOnRoute(routeAndEntry.route);
13703
13063
  } catch (error2) {
@@ -13705,9 +13065,12 @@ class SubcTransportPool {
13705
13065
  throw this.annotateReapError(error2, record);
13706
13066
  if (isRouteProvenAbsentError(error2) && this.isCurrentSession(key, record) && this.client === client) {
13707
13067
  clearRouteEntry(routeAndEntry.entry);
13708
- routeAndEntry = await openRoute();
13068
+ await this.waitForRouteReopenBackoff().wait;
13069
+ routeAndEntry = await openRouteAfterReloadWindow();
13709
13070
  try {
13710
- return await requestOnRoute(routeAndEntry.route);
13071
+ const reply = await requestOnRoute(routeAndEntry.route);
13072
+ this.resetRouteReopenBackoff();
13073
+ return reply;
13711
13074
  } catch (retryError) {
13712
13075
  if (this.isReapInduced(record))
13713
13076
  throw this.annotateReapError(retryError, record);
@@ -13727,6 +13090,27 @@ class SubcTransportPool {
13727
13090
  this.deleteSessionIfEmpty(key, record);
13728
13091
  }
13729
13092
  }
13093
+ waitForRouteReopenBackoff() {
13094
+ const pending = this.routeReopenRetry;
13095
+ const pendingDelay = this.routeReopenRetryMs;
13096
+ if (pending && pendingDelay !== null)
13097
+ return { delayMs: pendingDelay, wait: pending };
13098
+ const delayMs = this.routeReopenRetryDelayMs;
13099
+ this.routeReopenRetryDelayMs = Math.min(delayMs * 2, RECONNECT_RETRY_CAP_MS);
13100
+ let retry;
13101
+ retry = Promise.resolve().then(() => this.routeRetrySleep(delayMs)).finally(() => {
13102
+ if (this.routeReopenRetry === retry) {
13103
+ this.routeReopenRetry = null;
13104
+ this.routeReopenRetryMs = null;
13105
+ }
13106
+ });
13107
+ this.routeReopenRetry = retry;
13108
+ this.routeReopenRetryMs = delayMs;
13109
+ return { delayMs, wait: retry };
13110
+ }
13111
+ resetRouteReopenBackoff() {
13112
+ this.routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
13113
+ }
13730
13114
  async ensureClient() {
13731
13115
  if (this.shuttingDown)
13732
13116
  throw new SubcTransportShuttingDownError;
@@ -14009,6 +13393,12 @@ function isRouteGoodbyeError(error2) {
14009
13393
  }
14010
13394
  return error2.code === "route_closed" && error2.message.includes("route closed by subc");
14011
13395
  }
13396
+ function isRouteOpenReloadWindowError(error2) {
13397
+ if (error2 === null || typeof error2 !== "object")
13398
+ return false;
13399
+ const code = error2.code;
13400
+ return code === "module_reloading" || code === "module_warming" || code === "target_unavailable";
13401
+ }
14012
13402
  function hasEngineResponse(error2) {
14013
13403
  const response = error2.response;
14014
13404
  if (response !== null && typeof response === "object")
@@ -14333,7 +13723,16 @@ function platformKey(platform = process.platform, arch = process.arch) {
14333
13723
  }
14334
13724
  return key;
14335
13725
  }
13726
+ function logBinaryResolution(resolution) {
13727
+ log(`Resolved binary from ${resolution.source}: ${resolution.path}`);
13728
+ }
14336
13729
  function findBinarySync(expectedVersion) {
13730
+ const resolution = findBinarySyncInner(expectedVersion);
13731
+ if (resolution)
13732
+ logBinaryResolution(resolution);
13733
+ return resolution?.path ?? null;
13734
+ }
13735
+ function findBinarySyncInner(expectedVersion) {
14337
13736
  const ext = process.platform === "win32" ? ".exe" : "";
14338
13737
  const env = { ...process.env };
14339
13738
  const pluginVersion = expectedVersion ?? (() => {
@@ -14347,8 +13746,9 @@ function findBinarySync(expectedVersion) {
14347
13746
  if (pluginVersion) {
14348
13747
  const tag = pluginVersion.startsWith("v") ? pluginVersion : `v${pluginVersion}`;
14349
13748
  const versionCached = cachedBinaryPathFromEnv(tag, env, ext);
14350
- if (versionCached && isExpectedCachedBinary2(versionCached, pluginVersion))
14351
- return versionCached;
13749
+ if (versionCached && isExpectedCachedBinary2(versionCached, pluginVersion)) {
13750
+ return { path: versionCached, source: "versioned cache" };
13751
+ }
14352
13752
  }
14353
13753
  try {
14354
13754
  const key = platformKey();
@@ -14363,7 +13763,7 @@ function findBinarySync(expectedVersion) {
14363
13763
  warn(`npm platform package binary v${npmVersion} does not match plugin v${pluginVersion}; skipping (continuing to PATH lookup)`);
14364
13764
  } else {
14365
13765
  const copied = copyToVersionedCache(resolved, npmVersion);
14366
- return copied ?? resolved;
13766
+ return { path: copied ?? resolved, source: "npm platform package" };
14367
13767
  }
14368
13768
  }
14369
13769
  } catch {}
@@ -14381,27 +13781,28 @@ function findBinarySync(expectedVersion) {
14381
13781
  }
14382
13782
  const usable = probeBinaryCandidate(candidate, "PATH", expectedVersion);
14383
13783
  if (usable)
14384
- return usable;
13784
+ return { path: usable, source: "PATH" };
14385
13785
  }
14386
13786
  } catch {}
14387
13787
  const cargoPath = join7(homeDirFromEnv(env), ".cargo", "bin", `aft${ext}`);
14388
13788
  if (existsSync5(cargoPath)) {
14389
13789
  const usable = probeBinaryCandidate(cargoPath, "cargo", expectedVersion);
14390
13790
  if (usable)
14391
- return usable;
13791
+ return { path: usable, source: "cargo" };
14392
13792
  }
14393
13793
  return null;
14394
13794
  }
14395
13795
  async function findBinary(expectedVersion) {
14396
13796
  const syncResult = findBinarySync(expectedVersion);
14397
13797
  if (syncResult) {
14398
- log(`Resolved binary: ${syncResult}`);
14399
13798
  return syncResult;
14400
13799
  }
14401
13800
  log("Binary not found locally, attempting auto-download...");
14402
13801
  const downloaded = await ensureBinaryForResolver(expectedVersion);
14403
- if (downloaded)
13802
+ if (downloaded) {
13803
+ logBinaryResolution({ path: downloaded, source: "auto-download" });
14404
13804
  return downloaded;
13805
+ }
14405
13806
  throw new Error([
14406
13807
  "Could not find the `aft` binary.",
14407
13808
  "",
@@ -16419,11 +15820,16 @@ function normalizeKey(projectRoot) {
16419
15820
  return canonicalizeProjectRoot(projectRoot);
16420
15821
  }
16421
15822
  // ../aft-bridge/dist/revivable-transport.js
15823
+ var REVIVAL_RETRY_FLOOR_MS = 100;
15824
+ var REVIVAL_RETRY_CAP_MS = 2000;
15825
+
16422
15826
  class RevivableTransportPool {
16423
15827
  createPool;
16424
15828
  onBinaryReplaced;
16425
15829
  activePool;
16426
15830
  revival = null;
15831
+ revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
15832
+ revivalRetryNotBefore = 0;
16427
15833
  transports = new Map;
16428
15834
  configureOverrides = new Map;
16429
15835
  editSlotSurvivesCaptured = false;
@@ -16517,12 +15923,30 @@ class RevivableTransportPool {
16517
15923
  return this.activePool;
16518
15924
  if (this.revival)
16519
15925
  return this.revival;
15926
+ const delay = Math.max(0, this.revivalRetryNotBefore - Date.now());
15927
+ if (delay > 0) {
15928
+ let scheduled;
15929
+ scheduled = new Promise((resolve7) => setTimeout(resolve7, delay)).then(() => {
15930
+ if (this.revival === scheduled)
15931
+ this.revival = null;
15932
+ return this.ensureActivePool();
15933
+ });
15934
+ this.revival = scheduled;
15935
+ scheduled.then(() => {
15936
+ return;
15937
+ }, () => {
15938
+ return;
15939
+ });
15940
+ return scheduled;
15941
+ }
16520
15942
  warn("transport was shut down but new demand arrived — reviving (host quit hook fired without process exit?)");
16521
- const revival = this.createPool().then((pool) => {
15943
+ const revival = Promise.resolve().then(() => this.createPool()).then((pool) => {
16522
15944
  for (const [key, value] of this.configureOverrides) {
16523
15945
  pool.setConfigureOverride(key, value);
16524
15946
  }
16525
15947
  this.activePool = pool;
15948
+ this.revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
15949
+ this.revivalRetryNotBefore = 0;
16526
15950
  for (const [root, transport] of this.transports) {
16527
15951
  transport.refreshStatusSubscription(pool.getActiveBridgeForRoot(root));
16528
15952
  }
@@ -16533,6 +15957,8 @@ class RevivableTransportPool {
16533
15957
  if (this.revival === revival)
16534
15958
  this.revival = null;
16535
15959
  }, () => {
15960
+ this.revivalRetryNotBefore = Date.now() + this.revivalRetryDelayMs;
15961
+ this.revivalRetryDelayMs = Math.min(this.revivalRetryDelayMs * 2, REVIVAL_RETRY_CAP_MS);
16536
15962
  if (this.revival === revival)
16537
15963
  this.revival = null;
16538
15964
  });
@@ -18019,523 +17445,523 @@ var import_comment_json = __toESM(require_src2(), 1);
18019
17445
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
18020
17446
  var exports_external = {};
18021
17447
  __export(exports_external, {
18022
- xor: () => xor,
18023
- xid: () => xid2,
18024
- void: () => _void2,
18025
- uuidv7: () => uuidv7,
18026
- uuidv6: () => uuidv6,
18027
- uuidv4: () => uuidv4,
18028
- uuid: () => uuid2,
18029
- util: () => exports_util,
18030
- url: () => url,
18031
- uppercase: () => _uppercase,
18032
- unknown: () => unknown,
18033
- union: () => union,
18034
- undefined: () => _undefined3,
18035
- ulid: () => ulid2,
18036
- uint64: () => uint64,
18037
- uint32: () => uint32,
18038
- tuple: () => tuple,
18039
- trim: () => _trim,
18040
- treeifyError: () => treeifyError,
18041
- transform: () => transform,
18042
- toUpperCase: () => _toUpperCase,
18043
- toLowerCase: () => _toLowerCase,
18044
- toJSONSchema: () => toJSONSchema,
18045
- templateLiteral: () => templateLiteral,
18046
- symbol: () => symbol,
18047
- superRefine: () => superRefine,
18048
- success: () => success,
18049
- stringbool: () => stringbool,
18050
- stringFormat: () => stringFormat,
18051
- string: () => string2,
18052
- strictObject: () => strictObject,
18053
- startsWith: () => _startsWith,
18054
- slugify: () => _slugify,
18055
- size: () => _size,
18056
- setErrorMap: () => setErrorMap,
18057
- set: () => set,
18058
- safeParseAsync: () => safeParseAsync2,
18059
- safeParse: () => safeParse2,
18060
- safeEncodeAsync: () => safeEncodeAsync2,
18061
- safeEncode: () => safeEncode2,
18062
- safeDecodeAsync: () => safeDecodeAsync2,
18063
- safeDecode: () => safeDecode2,
18064
- registry: () => registry,
18065
- regexes: () => exports_regexes,
18066
- regex: () => _regex,
18067
- refine: () => refine,
18068
- record: () => record,
18069
- readonly: () => readonly,
18070
- property: () => _property,
18071
- promise: () => promise,
18072
- prettifyError: () => prettifyError,
18073
- preprocess: () => preprocess,
18074
- prefault: () => prefault,
18075
- positive: () => _positive,
18076
- pipe: () => pipe,
18077
- partialRecord: () => partialRecord,
18078
- parseAsync: () => parseAsync2,
18079
- parse: () => parse3,
18080
- overwrite: () => _overwrite,
18081
- optional: () => optional,
18082
- object: () => object,
18083
- number: () => number2,
18084
- nullish: () => nullish2,
18085
- nullable: () => nullable,
18086
- null: () => _null3,
18087
- normalize: () => _normalize,
18088
- nonpositive: () => _nonpositive,
18089
- nonoptional: () => nonoptional,
18090
- nonnegative: () => _nonnegative,
18091
- never: () => never,
18092
- negative: () => _negative,
18093
- nativeEnum: () => nativeEnum,
18094
- nanoid: () => nanoid2,
18095
- nan: () => nan,
18096
- multipleOf: () => _multipleOf,
18097
- minSize: () => _minSize,
18098
- minLength: () => _minLength,
18099
- mime: () => _mime,
18100
- meta: () => meta2,
18101
- maxSize: () => _maxSize,
18102
- maxLength: () => _maxLength,
18103
- map: () => map,
18104
- mac: () => mac2,
18105
- lte: () => _lte,
18106
- lt: () => _lt,
18107
- lowercase: () => _lowercase,
18108
- looseRecord: () => looseRecord,
18109
- looseObject: () => looseObject,
18110
- locales: () => exports_locales,
18111
- literal: () => literal,
18112
- length: () => _length,
18113
- lazy: () => lazy,
18114
- ksuid: () => ksuid2,
18115
- keyof: () => keyof,
18116
- jwt: () => jwt,
18117
- json: () => json,
18118
- iso: () => exports_iso,
18119
- ipv6: () => ipv62,
18120
- ipv4: () => ipv42,
18121
- invertCodec: () => invertCodec,
18122
- intersection: () => intersection,
18123
- int64: () => int64,
18124
- int32: () => int32,
18125
- int: () => int,
18126
- instanceof: () => _instanceof,
18127
- includes: () => _includes,
18128
- httpUrl: () => httpUrl,
18129
- hostname: () => hostname3,
18130
- hex: () => hex2,
18131
- hash: () => hash,
18132
- guid: () => guid2,
18133
- gte: () => _gte,
18134
- gt: () => _gt,
18135
- globalRegistry: () => globalRegistry,
18136
- getErrorMap: () => getErrorMap,
18137
- function: () => _function,
18138
- fromJSONSchema: () => fromJSONSchema,
18139
- formatError: () => formatError,
18140
- float64: () => float64,
18141
- float32: () => float32,
18142
- flattenError: () => flattenError,
18143
- file: () => file,
18144
- exactOptional: () => exactOptional,
18145
- enum: () => _enum2,
18146
- endsWith: () => _endsWith,
18147
- encodeAsync: () => encodeAsync2,
18148
- encode: () => encode2,
18149
- emoji: () => emoji2,
18150
- email: () => email2,
18151
- e164: () => e1642,
18152
- discriminatedUnion: () => discriminatedUnion,
18153
- describe: () => describe2,
18154
- decodeAsync: () => decodeAsync2,
18155
- decode: () => decode2,
18156
- date: () => date3,
18157
- custom: () => custom,
18158
- cuid2: () => cuid22,
18159
- cuid: () => cuid3,
18160
- core: () => exports_core2,
18161
- config: () => config,
18162
- coerce: () => exports_coerce,
18163
- codec: () => codec,
18164
- clone: () => clone,
18165
- cidrv6: () => cidrv62,
18166
- cidrv4: () => cidrv42,
18167
- check: () => check,
18168
- catch: () => _catch2,
18169
- boolean: () => boolean2,
18170
- bigint: () => bigint2,
18171
- base64url: () => base64url2,
18172
- base64: () => base642,
18173
- array: () => array,
18174
- any: () => any,
18175
- _function: () => _function,
18176
- _default: () => _default2,
18177
- _ZodString: () => _ZodString,
18178
- ZodXor: () => ZodXor,
18179
- ZodXID: () => ZodXID,
18180
- ZodVoid: () => ZodVoid,
18181
- ZodUnknown: () => ZodUnknown,
18182
- ZodUnion: () => ZodUnion,
18183
- ZodUndefined: () => ZodUndefined,
18184
- ZodUUID: () => ZodUUID,
18185
- ZodURL: () => ZodURL,
18186
- ZodULID: () => ZodULID,
18187
- ZodType: () => ZodType,
18188
- ZodTuple: () => ZodTuple,
18189
- ZodTransform: () => ZodTransform,
18190
- ZodTemplateLiteral: () => ZodTemplateLiteral,
18191
- ZodSymbol: () => ZodSymbol,
18192
- ZodSuccess: () => ZodSuccess,
18193
- ZodStringFormat: () => ZodStringFormat,
18194
- ZodString: () => ZodString,
18195
- ZodSet: () => ZodSet,
18196
- ZodRecord: () => ZodRecord,
18197
- ZodRealError: () => ZodRealError,
18198
- ZodReadonly: () => ZodReadonly,
18199
- ZodPromise: () => ZodPromise,
18200
- ZodPreprocess: () => ZodPreprocess,
18201
- ZodPrefault: () => ZodPrefault,
18202
- ZodPipe: () => ZodPipe,
18203
- ZodOptional: () => ZodOptional,
18204
- ZodObject: () => ZodObject,
18205
- ZodNumberFormat: () => ZodNumberFormat,
18206
- ZodNumber: () => ZodNumber,
18207
- ZodNullable: () => ZodNullable,
18208
- ZodNull: () => ZodNull,
18209
- ZodNonOptional: () => ZodNonOptional,
18210
- ZodNever: () => ZodNever,
18211
- ZodNanoID: () => ZodNanoID,
18212
- ZodNaN: () => ZodNaN,
18213
- ZodMap: () => ZodMap,
18214
- ZodMAC: () => ZodMAC,
18215
- ZodLiteral: () => ZodLiteral,
18216
- ZodLazy: () => ZodLazy,
18217
- ZodKSUID: () => ZodKSUID,
18218
- ZodJWT: () => ZodJWT,
18219
- ZodIssueCode: () => ZodIssueCode,
18220
- ZodIntersection: () => ZodIntersection,
18221
- ZodISOTime: () => ZodISOTime,
18222
- ZodISODuration: () => ZodISODuration,
18223
- ZodISODateTime: () => ZodISODateTime,
18224
- ZodISODate: () => ZodISODate,
18225
- ZodIPv6: () => ZodIPv6,
18226
- ZodIPv4: () => ZodIPv4,
18227
- ZodGUID: () => ZodGUID,
18228
- ZodFunction: () => ZodFunction,
18229
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
18230
- ZodFile: () => ZodFile,
18231
- ZodExactOptional: () => ZodExactOptional,
18232
- ZodError: () => ZodError,
18233
- ZodEnum: () => ZodEnum,
18234
- ZodEmoji: () => ZodEmoji,
18235
- ZodEmail: () => ZodEmail,
18236
- ZodE164: () => ZodE164,
18237
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
18238
- ZodDefault: () => ZodDefault,
18239
- ZodDate: () => ZodDate,
18240
- ZodCustomStringFormat: () => ZodCustomStringFormat,
18241
- ZodCustom: () => ZodCustom,
18242
- ZodCodec: () => ZodCodec,
18243
- ZodCatch: () => ZodCatch,
18244
- ZodCUID2: () => ZodCUID2,
18245
- ZodCUID: () => ZodCUID,
18246
- ZodCIDRv6: () => ZodCIDRv6,
18247
- ZodCIDRv4: () => ZodCIDRv4,
18248
- ZodBoolean: () => ZodBoolean,
18249
- ZodBigIntFormat: () => ZodBigIntFormat,
18250
- ZodBigInt: () => ZodBigInt,
18251
- ZodBase64URL: () => ZodBase64URL,
18252
- ZodBase64: () => ZodBase64,
18253
- ZodArray: () => ZodArray,
18254
- ZodAny: () => ZodAny,
18255
- TimePrecision: () => TimePrecision,
18256
- NEVER: () => NEVER,
18257
- $output: () => $output,
17448
+ $brand: () => $brand,
18258
17449
  $input: () => $input,
18259
- $brand: () => $brand
17450
+ $output: () => $output,
17451
+ NEVER: () => NEVER,
17452
+ TimePrecision: () => TimePrecision,
17453
+ ZodAny: () => ZodAny,
17454
+ ZodArray: () => ZodArray,
17455
+ ZodBase64: () => ZodBase64,
17456
+ ZodBase64URL: () => ZodBase64URL,
17457
+ ZodBigInt: () => ZodBigInt,
17458
+ ZodBigIntFormat: () => ZodBigIntFormat,
17459
+ ZodBoolean: () => ZodBoolean,
17460
+ ZodCIDRv4: () => ZodCIDRv4,
17461
+ ZodCIDRv6: () => ZodCIDRv6,
17462
+ ZodCUID: () => ZodCUID,
17463
+ ZodCUID2: () => ZodCUID2,
17464
+ ZodCatch: () => ZodCatch,
17465
+ ZodCodec: () => ZodCodec,
17466
+ ZodCustom: () => ZodCustom,
17467
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
17468
+ ZodDate: () => ZodDate,
17469
+ ZodDefault: () => ZodDefault,
17470
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
17471
+ ZodE164: () => ZodE164,
17472
+ ZodEmail: () => ZodEmail,
17473
+ ZodEmoji: () => ZodEmoji,
17474
+ ZodEnum: () => ZodEnum,
17475
+ ZodError: () => ZodError,
17476
+ ZodExactOptional: () => ZodExactOptional,
17477
+ ZodFile: () => ZodFile,
17478
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
17479
+ ZodFunction: () => ZodFunction,
17480
+ ZodGUID: () => ZodGUID,
17481
+ ZodIPv4: () => ZodIPv4,
17482
+ ZodIPv6: () => ZodIPv6,
17483
+ ZodISODate: () => ZodISODate,
17484
+ ZodISODateTime: () => ZodISODateTime,
17485
+ ZodISODuration: () => ZodISODuration,
17486
+ ZodISOTime: () => ZodISOTime,
17487
+ ZodIntersection: () => ZodIntersection,
17488
+ ZodIssueCode: () => ZodIssueCode,
17489
+ ZodJWT: () => ZodJWT,
17490
+ ZodKSUID: () => ZodKSUID,
17491
+ ZodLazy: () => ZodLazy,
17492
+ ZodLiteral: () => ZodLiteral,
17493
+ ZodMAC: () => ZodMAC,
17494
+ ZodMap: () => ZodMap,
17495
+ ZodNaN: () => ZodNaN,
17496
+ ZodNanoID: () => ZodNanoID,
17497
+ ZodNever: () => ZodNever,
17498
+ ZodNonOptional: () => ZodNonOptional,
17499
+ ZodNull: () => ZodNull,
17500
+ ZodNullable: () => ZodNullable,
17501
+ ZodNumber: () => ZodNumber,
17502
+ ZodNumberFormat: () => ZodNumberFormat,
17503
+ ZodObject: () => ZodObject,
17504
+ ZodOptional: () => ZodOptional,
17505
+ ZodPipe: () => ZodPipe,
17506
+ ZodPrefault: () => ZodPrefault,
17507
+ ZodPreprocess: () => ZodPreprocess,
17508
+ ZodPromise: () => ZodPromise,
17509
+ ZodReadonly: () => ZodReadonly,
17510
+ ZodRealError: () => ZodRealError,
17511
+ ZodRecord: () => ZodRecord,
17512
+ ZodSet: () => ZodSet,
17513
+ ZodString: () => ZodString,
17514
+ ZodStringFormat: () => ZodStringFormat,
17515
+ ZodSuccess: () => ZodSuccess,
17516
+ ZodSymbol: () => ZodSymbol,
17517
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
17518
+ ZodTransform: () => ZodTransform,
17519
+ ZodTuple: () => ZodTuple,
17520
+ ZodType: () => ZodType,
17521
+ ZodULID: () => ZodULID,
17522
+ ZodURL: () => ZodURL,
17523
+ ZodUUID: () => ZodUUID,
17524
+ ZodUndefined: () => ZodUndefined,
17525
+ ZodUnion: () => ZodUnion,
17526
+ ZodUnknown: () => ZodUnknown,
17527
+ ZodVoid: () => ZodVoid,
17528
+ ZodXID: () => ZodXID,
17529
+ ZodXor: () => ZodXor,
17530
+ _ZodString: () => _ZodString,
17531
+ _default: () => _default2,
17532
+ _function: () => _function,
17533
+ any: () => any,
17534
+ array: () => array,
17535
+ base64: () => base642,
17536
+ base64url: () => base64url2,
17537
+ bigint: () => bigint2,
17538
+ boolean: () => boolean2,
17539
+ catch: () => _catch2,
17540
+ check: () => check,
17541
+ cidrv4: () => cidrv42,
17542
+ cidrv6: () => cidrv62,
17543
+ clone: () => clone,
17544
+ codec: () => codec,
17545
+ coerce: () => exports_coerce,
17546
+ config: () => config,
17547
+ core: () => exports_core2,
17548
+ cuid: () => cuid3,
17549
+ cuid2: () => cuid22,
17550
+ custom: () => custom,
17551
+ date: () => date3,
17552
+ decode: () => decode2,
17553
+ decodeAsync: () => decodeAsync2,
17554
+ describe: () => describe2,
17555
+ discriminatedUnion: () => discriminatedUnion,
17556
+ e164: () => e1642,
17557
+ email: () => email2,
17558
+ emoji: () => emoji2,
17559
+ encode: () => encode2,
17560
+ encodeAsync: () => encodeAsync2,
17561
+ endsWith: () => _endsWith,
17562
+ enum: () => _enum2,
17563
+ exactOptional: () => exactOptional,
17564
+ file: () => file,
17565
+ flattenError: () => flattenError,
17566
+ float32: () => float32,
17567
+ float64: () => float64,
17568
+ formatError: () => formatError,
17569
+ fromJSONSchema: () => fromJSONSchema,
17570
+ function: () => _function,
17571
+ getErrorMap: () => getErrorMap,
17572
+ globalRegistry: () => globalRegistry,
17573
+ gt: () => _gt,
17574
+ gte: () => _gte,
17575
+ guid: () => guid2,
17576
+ hash: () => hash,
17577
+ hex: () => hex2,
17578
+ hostname: () => hostname3,
17579
+ httpUrl: () => httpUrl,
17580
+ includes: () => _includes,
17581
+ instanceof: () => _instanceof,
17582
+ int: () => int,
17583
+ int32: () => int32,
17584
+ int64: () => int64,
17585
+ intersection: () => intersection,
17586
+ invertCodec: () => invertCodec,
17587
+ ipv4: () => ipv42,
17588
+ ipv6: () => ipv62,
17589
+ iso: () => exports_iso,
17590
+ json: () => json,
17591
+ jwt: () => jwt,
17592
+ keyof: () => keyof,
17593
+ ksuid: () => ksuid2,
17594
+ lazy: () => lazy,
17595
+ length: () => _length,
17596
+ literal: () => literal,
17597
+ locales: () => exports_locales,
17598
+ looseObject: () => looseObject,
17599
+ looseRecord: () => looseRecord,
17600
+ lowercase: () => _lowercase,
17601
+ lt: () => _lt,
17602
+ lte: () => _lte,
17603
+ mac: () => mac2,
17604
+ map: () => map,
17605
+ maxLength: () => _maxLength,
17606
+ maxSize: () => _maxSize,
17607
+ meta: () => meta2,
17608
+ mime: () => _mime,
17609
+ minLength: () => _minLength,
17610
+ minSize: () => _minSize,
17611
+ multipleOf: () => _multipleOf,
17612
+ nan: () => nan,
17613
+ nanoid: () => nanoid2,
17614
+ nativeEnum: () => nativeEnum,
17615
+ negative: () => _negative,
17616
+ never: () => never,
17617
+ nonnegative: () => _nonnegative,
17618
+ nonoptional: () => nonoptional,
17619
+ nonpositive: () => _nonpositive,
17620
+ normalize: () => _normalize,
17621
+ null: () => _null3,
17622
+ nullable: () => nullable,
17623
+ nullish: () => nullish2,
17624
+ number: () => number2,
17625
+ object: () => object,
17626
+ optional: () => optional,
17627
+ overwrite: () => _overwrite,
17628
+ parse: () => parse3,
17629
+ parseAsync: () => parseAsync2,
17630
+ partialRecord: () => partialRecord,
17631
+ pipe: () => pipe,
17632
+ positive: () => _positive,
17633
+ prefault: () => prefault,
17634
+ preprocess: () => preprocess,
17635
+ prettifyError: () => prettifyError,
17636
+ promise: () => promise,
17637
+ property: () => _property,
17638
+ readonly: () => readonly,
17639
+ record: () => record,
17640
+ refine: () => refine,
17641
+ regex: () => _regex,
17642
+ regexes: () => exports_regexes,
17643
+ registry: () => registry,
17644
+ safeDecode: () => safeDecode2,
17645
+ safeDecodeAsync: () => safeDecodeAsync2,
17646
+ safeEncode: () => safeEncode2,
17647
+ safeEncodeAsync: () => safeEncodeAsync2,
17648
+ safeParse: () => safeParse2,
17649
+ safeParseAsync: () => safeParseAsync2,
17650
+ set: () => set,
17651
+ setErrorMap: () => setErrorMap,
17652
+ size: () => _size,
17653
+ slugify: () => _slugify,
17654
+ startsWith: () => _startsWith,
17655
+ strictObject: () => strictObject,
17656
+ string: () => string2,
17657
+ stringFormat: () => stringFormat,
17658
+ stringbool: () => stringbool,
17659
+ success: () => success,
17660
+ superRefine: () => superRefine,
17661
+ symbol: () => symbol,
17662
+ templateLiteral: () => templateLiteral,
17663
+ toJSONSchema: () => toJSONSchema,
17664
+ toLowerCase: () => _toLowerCase,
17665
+ toUpperCase: () => _toUpperCase,
17666
+ transform: () => transform,
17667
+ treeifyError: () => treeifyError,
17668
+ trim: () => _trim,
17669
+ tuple: () => tuple,
17670
+ uint32: () => uint32,
17671
+ uint64: () => uint64,
17672
+ ulid: () => ulid2,
17673
+ undefined: () => _undefined3,
17674
+ union: () => union,
17675
+ unknown: () => unknown,
17676
+ uppercase: () => _uppercase,
17677
+ url: () => url,
17678
+ util: () => exports_util,
17679
+ uuid: () => uuid2,
17680
+ uuidv4: () => uuidv4,
17681
+ uuidv6: () => uuidv6,
17682
+ uuidv7: () => uuidv7,
17683
+ void: () => _void2,
17684
+ xid: () => xid2,
17685
+ xor: () => xor
18260
17686
  });
18261
17687
 
18262
17688
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/index.js
18263
17689
  var exports_core2 = {};
18264
17690
  __export(exports_core2, {
18265
- version: () => version,
18266
- util: () => exports_util,
18267
- treeifyError: () => treeifyError,
18268
- toJSONSchema: () => toJSONSchema,
18269
- toDotPath: () => toDotPath,
18270
- safeParseAsync: () => safeParseAsync,
18271
- safeParse: () => safeParse,
18272
- safeEncodeAsync: () => safeEncodeAsync,
18273
- safeEncode: () => safeEncode,
18274
- safeDecodeAsync: () => safeDecodeAsync,
18275
- safeDecode: () => safeDecode,
18276
- registry: () => registry,
18277
- regexes: () => exports_regexes,
18278
- process: () => process2,
18279
- prettifyError: () => prettifyError,
18280
- parseAsync: () => parseAsync,
18281
- parse: () => parse,
18282
- meta: () => meta,
18283
- locales: () => exports_locales,
18284
- isValidJWT: () => isValidJWT,
18285
- isValidBase64URL: () => isValidBase64URL,
18286
- isValidBase64: () => isValidBase64,
18287
- initializeContext: () => initializeContext,
18288
- globalRegistry: () => globalRegistry,
18289
- globalConfig: () => globalConfig,
18290
- formatError: () => formatError,
18291
- flattenError: () => flattenError,
18292
- finalize: () => finalize,
18293
- extractDefs: () => extractDefs,
18294
- encodeAsync: () => encodeAsync,
18295
- encode: () => encode,
18296
- describe: () => describe,
18297
- decodeAsync: () => decodeAsync,
18298
- decode: () => decode,
18299
- createToJSONSchemaMethod: () => createToJSONSchemaMethod,
18300
- createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
18301
- config: () => config,
18302
- clone: () => clone,
18303
- _xor: () => _xor,
18304
- _xid: () => _xid,
18305
- _void: () => _void,
18306
- _uuidv7: () => _uuidv7,
18307
- _uuidv6: () => _uuidv6,
18308
- _uuidv4: () => _uuidv4,
18309
- _uuid: () => _uuid,
18310
- _url: () => _url,
18311
- _uppercase: () => _uppercase,
18312
- _unknown: () => _unknown,
18313
- _union: () => _union,
18314
- _undefined: () => _undefined2,
18315
- _ulid: () => _ulid,
18316
- _uint64: () => _uint64,
18317
- _uint32: () => _uint32,
18318
- _tuple: () => _tuple,
18319
- _trim: () => _trim,
18320
- _transform: () => _transform,
18321
- _toUpperCase: () => _toUpperCase,
18322
- _toLowerCase: () => _toLowerCase,
18323
- _templateLiteral: () => _templateLiteral,
18324
- _symbol: () => _symbol,
18325
- _superRefine: () => _superRefine,
18326
- _success: () => _success,
18327
- _stringbool: () => _stringbool,
18328
- _stringFormat: () => _stringFormat,
18329
- _string: () => _string,
18330
- _startsWith: () => _startsWith,
18331
- _slugify: () => _slugify,
18332
- _size: () => _size,
18333
- _set: () => _set,
18334
- _safeParseAsync: () => _safeParseAsync,
18335
- _safeParse: () => _safeParse,
18336
- _safeEncodeAsync: () => _safeEncodeAsync,
18337
- _safeEncode: () => _safeEncode,
18338
- _safeDecodeAsync: () => _safeDecodeAsync,
18339
- _safeDecode: () => _safeDecode,
18340
- _regex: () => _regex,
18341
- _refine: () => _refine,
18342
- _record: () => _record,
18343
- _readonly: () => _readonly,
18344
- _property: () => _property,
18345
- _promise: () => _promise,
18346
- _positive: () => _positive,
18347
- _pipe: () => _pipe,
18348
- _parseAsync: () => _parseAsync,
18349
- _parse: () => _parse,
18350
- _overwrite: () => _overwrite,
18351
- _optional: () => _optional,
18352
- _number: () => _number,
18353
- _nullable: () => _nullable,
18354
- _null: () => _null2,
18355
- _normalize: () => _normalize,
18356
- _nonpositive: () => _nonpositive,
18357
- _nonoptional: () => _nonoptional,
18358
- _nonnegative: () => _nonnegative,
18359
- _never: () => _never,
18360
- _negative: () => _negative,
18361
- _nativeEnum: () => _nativeEnum,
18362
- _nanoid: () => _nanoid,
18363
- _nan: () => _nan,
18364
- _multipleOf: () => _multipleOf,
18365
- _minSize: () => _minSize,
18366
- _minLength: () => _minLength,
18367
- _min: () => _gte,
18368
- _mime: () => _mime,
18369
- _maxSize: () => _maxSize,
18370
- _maxLength: () => _maxLength,
18371
- _max: () => _lte,
18372
- _map: () => _map,
18373
- _mac: () => _mac,
18374
- _lte: () => _lte,
18375
- _lt: () => _lt,
18376
- _lowercase: () => _lowercase,
18377
- _literal: () => _literal,
18378
- _length: () => _length,
18379
- _lazy: () => _lazy,
18380
- _ksuid: () => _ksuid,
18381
- _jwt: () => _jwt,
18382
- _isoTime: () => _isoTime,
18383
- _isoDuration: () => _isoDuration,
18384
- _isoDateTime: () => _isoDateTime,
18385
- _isoDate: () => _isoDate,
18386
- _ipv6: () => _ipv6,
18387
- _ipv4: () => _ipv4,
18388
- _intersection: () => _intersection,
18389
- _int64: () => _int64,
18390
- _int32: () => _int32,
18391
- _int: () => _int,
18392
- _includes: () => _includes,
18393
- _guid: () => _guid,
18394
- _gte: () => _gte,
18395
- _gt: () => _gt,
18396
- _float64: () => _float64,
18397
- _float32: () => _float32,
18398
- _file: () => _file,
18399
- _enum: () => _enum,
18400
- _endsWith: () => _endsWith,
18401
- _encodeAsync: () => _encodeAsync,
18402
- _encode: () => _encode,
18403
- _emoji: () => _emoji2,
18404
- _email: () => _email,
18405
- _e164: () => _e164,
18406
- _discriminatedUnion: () => _discriminatedUnion,
18407
- _default: () => _default,
18408
- _decodeAsync: () => _decodeAsync,
18409
- _decode: () => _decode,
18410
- _date: () => _date,
18411
- _custom: () => _custom,
18412
- _cuid2: () => _cuid2,
18413
- _cuid: () => _cuid,
18414
- _coercedString: () => _coercedString,
18415
- _coercedNumber: () => _coercedNumber,
18416
- _coercedDate: () => _coercedDate,
18417
- _coercedBoolean: () => _coercedBoolean,
18418
- _coercedBigint: () => _coercedBigint,
18419
- _cidrv6: () => _cidrv6,
18420
- _cidrv4: () => _cidrv4,
18421
- _check: () => _check,
18422
- _catch: () => _catch,
18423
- _boolean: () => _boolean,
18424
- _bigint: () => _bigint,
18425
- _base64url: () => _base64url,
18426
- _base64: () => _base64,
18427
- _array: () => _array,
18428
- _any: () => _any,
18429
- TimePrecision: () => TimePrecision,
18430
- NEVER: () => NEVER,
18431
- JSONSchemaGenerator: () => JSONSchemaGenerator,
18432
- JSONSchema: () => exports_json_schema,
18433
- Doc: () => Doc,
18434
- $output: () => $output,
18435
- $input: () => $input,
18436
- $constructor: () => $constructor,
18437
- $brand: () => $brand,
18438
- $ZodXor: () => $ZodXor,
18439
- $ZodXID: () => $ZodXID,
18440
- $ZodVoid: () => $ZodVoid,
18441
- $ZodUnknown: () => $ZodUnknown,
18442
- $ZodUnion: () => $ZodUnion,
18443
- $ZodUndefined: () => $ZodUndefined,
18444
- $ZodUUID: () => $ZodUUID,
18445
- $ZodURL: () => $ZodURL,
18446
- $ZodULID: () => $ZodULID,
18447
- $ZodType: () => $ZodType,
18448
- $ZodTuple: () => $ZodTuple,
18449
- $ZodTransform: () => $ZodTransform,
18450
- $ZodTemplateLiteral: () => $ZodTemplateLiteral,
18451
- $ZodSymbol: () => $ZodSymbol,
18452
- $ZodSuccess: () => $ZodSuccess,
18453
- $ZodStringFormat: () => $ZodStringFormat,
18454
- $ZodString: () => $ZodString,
18455
- $ZodSet: () => $ZodSet,
18456
- $ZodRegistry: () => $ZodRegistry,
18457
- $ZodRecord: () => $ZodRecord,
18458
- $ZodRealError: () => $ZodRealError,
18459
- $ZodReadonly: () => $ZodReadonly,
18460
- $ZodPromise: () => $ZodPromise,
18461
- $ZodPreprocess: () => $ZodPreprocess,
18462
- $ZodPrefault: () => $ZodPrefault,
18463
- $ZodPipe: () => $ZodPipe,
18464
- $ZodOptional: () => $ZodOptional,
18465
- $ZodObjectJIT: () => $ZodObjectJIT,
18466
- $ZodObject: () => $ZodObject,
18467
- $ZodNumberFormat: () => $ZodNumberFormat,
18468
- $ZodNumber: () => $ZodNumber,
18469
- $ZodNullable: () => $ZodNullable,
18470
- $ZodNull: () => $ZodNull,
18471
- $ZodNonOptional: () => $ZodNonOptional,
18472
- $ZodNever: () => $ZodNever,
18473
- $ZodNanoID: () => $ZodNanoID,
18474
- $ZodNaN: () => $ZodNaN,
18475
- $ZodMap: () => $ZodMap,
18476
- $ZodMAC: () => $ZodMAC,
18477
- $ZodLiteral: () => $ZodLiteral,
18478
- $ZodLazy: () => $ZodLazy,
18479
- $ZodKSUID: () => $ZodKSUID,
18480
- $ZodJWT: () => $ZodJWT,
18481
- $ZodIntersection: () => $ZodIntersection,
18482
- $ZodISOTime: () => $ZodISOTime,
18483
- $ZodISODuration: () => $ZodISODuration,
18484
- $ZodISODateTime: () => $ZodISODateTime,
18485
- $ZodISODate: () => $ZodISODate,
18486
- $ZodIPv6: () => $ZodIPv6,
18487
- $ZodIPv4: () => $ZodIPv4,
18488
- $ZodGUID: () => $ZodGUID,
18489
- $ZodFunction: () => $ZodFunction,
18490
- $ZodFile: () => $ZodFile,
18491
- $ZodExactOptional: () => $ZodExactOptional,
18492
- $ZodError: () => $ZodError,
18493
- $ZodEnum: () => $ZodEnum,
18494
- $ZodEncodeError: () => $ZodEncodeError,
18495
- $ZodEmoji: () => $ZodEmoji,
18496
- $ZodEmail: () => $ZodEmail,
18497
- $ZodE164: () => $ZodE164,
18498
- $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
18499
- $ZodDefault: () => $ZodDefault,
18500
- $ZodDate: () => $ZodDate,
18501
- $ZodCustomStringFormat: () => $ZodCustomStringFormat,
18502
- $ZodCustom: () => $ZodCustom,
18503
- $ZodCodec: () => $ZodCodec,
18504
- $ZodCheckUpperCase: () => $ZodCheckUpperCase,
18505
- $ZodCheckStringFormat: () => $ZodCheckStringFormat,
18506
- $ZodCheckStartsWith: () => $ZodCheckStartsWith,
18507
- $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
18508
- $ZodCheckRegex: () => $ZodCheckRegex,
18509
- $ZodCheckProperty: () => $ZodCheckProperty,
18510
- $ZodCheckOverwrite: () => $ZodCheckOverwrite,
18511
- $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
18512
- $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
18513
- $ZodCheckMinSize: () => $ZodCheckMinSize,
18514
- $ZodCheckMinLength: () => $ZodCheckMinLength,
18515
- $ZodCheckMimeType: () => $ZodCheckMimeType,
18516
- $ZodCheckMaxSize: () => $ZodCheckMaxSize,
18517
- $ZodCheckMaxLength: () => $ZodCheckMaxLength,
18518
- $ZodCheckLowerCase: () => $ZodCheckLowerCase,
18519
- $ZodCheckLessThan: () => $ZodCheckLessThan,
18520
- $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
18521
- $ZodCheckIncludes: () => $ZodCheckIncludes,
18522
- $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
18523
- $ZodCheckEndsWith: () => $ZodCheckEndsWith,
18524
- $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
18525
- $ZodCheck: () => $ZodCheck,
18526
- $ZodCatch: () => $ZodCatch,
18527
- $ZodCUID2: () => $ZodCUID2,
18528
- $ZodCUID: () => $ZodCUID,
18529
- $ZodCIDRv6: () => $ZodCIDRv6,
18530
- $ZodCIDRv4: () => $ZodCIDRv4,
18531
- $ZodBoolean: () => $ZodBoolean,
18532
- $ZodBigIntFormat: () => $ZodBigIntFormat,
18533
- $ZodBigInt: () => $ZodBigInt,
18534
- $ZodBase64URL: () => $ZodBase64URL,
18535
- $ZodBase64: () => $ZodBase64,
18536
- $ZodAsyncError: () => $ZodAsyncError,
17691
+ $ZodAny: () => $ZodAny,
18537
17692
  $ZodArray: () => $ZodArray,
18538
- $ZodAny: () => $ZodAny
17693
+ $ZodAsyncError: () => $ZodAsyncError,
17694
+ $ZodBase64: () => $ZodBase64,
17695
+ $ZodBase64URL: () => $ZodBase64URL,
17696
+ $ZodBigInt: () => $ZodBigInt,
17697
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
17698
+ $ZodBoolean: () => $ZodBoolean,
17699
+ $ZodCIDRv4: () => $ZodCIDRv4,
17700
+ $ZodCIDRv6: () => $ZodCIDRv6,
17701
+ $ZodCUID: () => $ZodCUID,
17702
+ $ZodCUID2: () => $ZodCUID2,
17703
+ $ZodCatch: () => $ZodCatch,
17704
+ $ZodCheck: () => $ZodCheck,
17705
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
17706
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
17707
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
17708
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
17709
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
17710
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
17711
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
17712
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
17713
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
17714
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
17715
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
17716
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
17717
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
17718
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
17719
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
17720
+ $ZodCheckProperty: () => $ZodCheckProperty,
17721
+ $ZodCheckRegex: () => $ZodCheckRegex,
17722
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
17723
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
17724
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
17725
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
17726
+ $ZodCodec: () => $ZodCodec,
17727
+ $ZodCustom: () => $ZodCustom,
17728
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
17729
+ $ZodDate: () => $ZodDate,
17730
+ $ZodDefault: () => $ZodDefault,
17731
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
17732
+ $ZodE164: () => $ZodE164,
17733
+ $ZodEmail: () => $ZodEmail,
17734
+ $ZodEmoji: () => $ZodEmoji,
17735
+ $ZodEncodeError: () => $ZodEncodeError,
17736
+ $ZodEnum: () => $ZodEnum,
17737
+ $ZodError: () => $ZodError,
17738
+ $ZodExactOptional: () => $ZodExactOptional,
17739
+ $ZodFile: () => $ZodFile,
17740
+ $ZodFunction: () => $ZodFunction,
17741
+ $ZodGUID: () => $ZodGUID,
17742
+ $ZodIPv4: () => $ZodIPv4,
17743
+ $ZodIPv6: () => $ZodIPv6,
17744
+ $ZodISODate: () => $ZodISODate,
17745
+ $ZodISODateTime: () => $ZodISODateTime,
17746
+ $ZodISODuration: () => $ZodISODuration,
17747
+ $ZodISOTime: () => $ZodISOTime,
17748
+ $ZodIntersection: () => $ZodIntersection,
17749
+ $ZodJWT: () => $ZodJWT,
17750
+ $ZodKSUID: () => $ZodKSUID,
17751
+ $ZodLazy: () => $ZodLazy,
17752
+ $ZodLiteral: () => $ZodLiteral,
17753
+ $ZodMAC: () => $ZodMAC,
17754
+ $ZodMap: () => $ZodMap,
17755
+ $ZodNaN: () => $ZodNaN,
17756
+ $ZodNanoID: () => $ZodNanoID,
17757
+ $ZodNever: () => $ZodNever,
17758
+ $ZodNonOptional: () => $ZodNonOptional,
17759
+ $ZodNull: () => $ZodNull,
17760
+ $ZodNullable: () => $ZodNullable,
17761
+ $ZodNumber: () => $ZodNumber,
17762
+ $ZodNumberFormat: () => $ZodNumberFormat,
17763
+ $ZodObject: () => $ZodObject,
17764
+ $ZodObjectJIT: () => $ZodObjectJIT,
17765
+ $ZodOptional: () => $ZodOptional,
17766
+ $ZodPipe: () => $ZodPipe,
17767
+ $ZodPrefault: () => $ZodPrefault,
17768
+ $ZodPreprocess: () => $ZodPreprocess,
17769
+ $ZodPromise: () => $ZodPromise,
17770
+ $ZodReadonly: () => $ZodReadonly,
17771
+ $ZodRealError: () => $ZodRealError,
17772
+ $ZodRecord: () => $ZodRecord,
17773
+ $ZodRegistry: () => $ZodRegistry,
17774
+ $ZodSet: () => $ZodSet,
17775
+ $ZodString: () => $ZodString,
17776
+ $ZodStringFormat: () => $ZodStringFormat,
17777
+ $ZodSuccess: () => $ZodSuccess,
17778
+ $ZodSymbol: () => $ZodSymbol,
17779
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
17780
+ $ZodTransform: () => $ZodTransform,
17781
+ $ZodTuple: () => $ZodTuple,
17782
+ $ZodType: () => $ZodType,
17783
+ $ZodULID: () => $ZodULID,
17784
+ $ZodURL: () => $ZodURL,
17785
+ $ZodUUID: () => $ZodUUID,
17786
+ $ZodUndefined: () => $ZodUndefined,
17787
+ $ZodUnion: () => $ZodUnion,
17788
+ $ZodUnknown: () => $ZodUnknown,
17789
+ $ZodVoid: () => $ZodVoid,
17790
+ $ZodXID: () => $ZodXID,
17791
+ $ZodXor: () => $ZodXor,
17792
+ $brand: () => $brand,
17793
+ $constructor: () => $constructor,
17794
+ $input: () => $input,
17795
+ $output: () => $output,
17796
+ Doc: () => Doc,
17797
+ JSONSchema: () => exports_json_schema,
17798
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
17799
+ NEVER: () => NEVER,
17800
+ TimePrecision: () => TimePrecision,
17801
+ _any: () => _any,
17802
+ _array: () => _array,
17803
+ _base64: () => _base64,
17804
+ _base64url: () => _base64url,
17805
+ _bigint: () => _bigint,
17806
+ _boolean: () => _boolean,
17807
+ _catch: () => _catch,
17808
+ _check: () => _check,
17809
+ _cidrv4: () => _cidrv4,
17810
+ _cidrv6: () => _cidrv6,
17811
+ _coercedBigint: () => _coercedBigint,
17812
+ _coercedBoolean: () => _coercedBoolean,
17813
+ _coercedDate: () => _coercedDate,
17814
+ _coercedNumber: () => _coercedNumber,
17815
+ _coercedString: () => _coercedString,
17816
+ _cuid: () => _cuid,
17817
+ _cuid2: () => _cuid2,
17818
+ _custom: () => _custom,
17819
+ _date: () => _date,
17820
+ _decode: () => _decode,
17821
+ _decodeAsync: () => _decodeAsync,
17822
+ _default: () => _default,
17823
+ _discriminatedUnion: () => _discriminatedUnion,
17824
+ _e164: () => _e164,
17825
+ _email: () => _email,
17826
+ _emoji: () => _emoji2,
17827
+ _encode: () => _encode,
17828
+ _encodeAsync: () => _encodeAsync,
17829
+ _endsWith: () => _endsWith,
17830
+ _enum: () => _enum,
17831
+ _file: () => _file,
17832
+ _float32: () => _float32,
17833
+ _float64: () => _float64,
17834
+ _gt: () => _gt,
17835
+ _gte: () => _gte,
17836
+ _guid: () => _guid,
17837
+ _includes: () => _includes,
17838
+ _int: () => _int,
17839
+ _int32: () => _int32,
17840
+ _int64: () => _int64,
17841
+ _intersection: () => _intersection,
17842
+ _ipv4: () => _ipv4,
17843
+ _ipv6: () => _ipv6,
17844
+ _isoDate: () => _isoDate,
17845
+ _isoDateTime: () => _isoDateTime,
17846
+ _isoDuration: () => _isoDuration,
17847
+ _isoTime: () => _isoTime,
17848
+ _jwt: () => _jwt,
17849
+ _ksuid: () => _ksuid,
17850
+ _lazy: () => _lazy,
17851
+ _length: () => _length,
17852
+ _literal: () => _literal,
17853
+ _lowercase: () => _lowercase,
17854
+ _lt: () => _lt,
17855
+ _lte: () => _lte,
17856
+ _mac: () => _mac,
17857
+ _map: () => _map,
17858
+ _max: () => _lte,
17859
+ _maxLength: () => _maxLength,
17860
+ _maxSize: () => _maxSize,
17861
+ _mime: () => _mime,
17862
+ _min: () => _gte,
17863
+ _minLength: () => _minLength,
17864
+ _minSize: () => _minSize,
17865
+ _multipleOf: () => _multipleOf,
17866
+ _nan: () => _nan,
17867
+ _nanoid: () => _nanoid,
17868
+ _nativeEnum: () => _nativeEnum,
17869
+ _negative: () => _negative,
17870
+ _never: () => _never,
17871
+ _nonnegative: () => _nonnegative,
17872
+ _nonoptional: () => _nonoptional,
17873
+ _nonpositive: () => _nonpositive,
17874
+ _normalize: () => _normalize,
17875
+ _null: () => _null2,
17876
+ _nullable: () => _nullable,
17877
+ _number: () => _number,
17878
+ _optional: () => _optional,
17879
+ _overwrite: () => _overwrite,
17880
+ _parse: () => _parse,
17881
+ _parseAsync: () => _parseAsync,
17882
+ _pipe: () => _pipe,
17883
+ _positive: () => _positive,
17884
+ _promise: () => _promise,
17885
+ _property: () => _property,
17886
+ _readonly: () => _readonly,
17887
+ _record: () => _record,
17888
+ _refine: () => _refine,
17889
+ _regex: () => _regex,
17890
+ _safeDecode: () => _safeDecode,
17891
+ _safeDecodeAsync: () => _safeDecodeAsync,
17892
+ _safeEncode: () => _safeEncode,
17893
+ _safeEncodeAsync: () => _safeEncodeAsync,
17894
+ _safeParse: () => _safeParse,
17895
+ _safeParseAsync: () => _safeParseAsync,
17896
+ _set: () => _set,
17897
+ _size: () => _size,
17898
+ _slugify: () => _slugify,
17899
+ _startsWith: () => _startsWith,
17900
+ _string: () => _string,
17901
+ _stringFormat: () => _stringFormat,
17902
+ _stringbool: () => _stringbool,
17903
+ _success: () => _success,
17904
+ _superRefine: () => _superRefine,
17905
+ _symbol: () => _symbol,
17906
+ _templateLiteral: () => _templateLiteral,
17907
+ _toLowerCase: () => _toLowerCase,
17908
+ _toUpperCase: () => _toUpperCase,
17909
+ _transform: () => _transform,
17910
+ _trim: () => _trim,
17911
+ _tuple: () => _tuple,
17912
+ _uint32: () => _uint32,
17913
+ _uint64: () => _uint64,
17914
+ _ulid: () => _ulid,
17915
+ _undefined: () => _undefined2,
17916
+ _union: () => _union,
17917
+ _unknown: () => _unknown,
17918
+ _uppercase: () => _uppercase,
17919
+ _url: () => _url,
17920
+ _uuid: () => _uuid,
17921
+ _uuidv4: () => _uuidv4,
17922
+ _uuidv6: () => _uuidv6,
17923
+ _uuidv7: () => _uuidv7,
17924
+ _void: () => _void,
17925
+ _xid: () => _xid,
17926
+ _xor: () => _xor,
17927
+ clone: () => clone,
17928
+ config: () => config,
17929
+ createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
17930
+ createToJSONSchemaMethod: () => createToJSONSchemaMethod,
17931
+ decode: () => decode,
17932
+ decodeAsync: () => decodeAsync,
17933
+ describe: () => describe,
17934
+ encode: () => encode,
17935
+ encodeAsync: () => encodeAsync,
17936
+ extractDefs: () => extractDefs,
17937
+ finalize: () => finalize,
17938
+ flattenError: () => flattenError,
17939
+ formatError: () => formatError,
17940
+ globalConfig: () => globalConfig,
17941
+ globalRegistry: () => globalRegistry,
17942
+ initializeContext: () => initializeContext,
17943
+ isValidBase64: () => isValidBase64,
17944
+ isValidBase64URL: () => isValidBase64URL,
17945
+ isValidJWT: () => isValidJWT,
17946
+ locales: () => exports_locales,
17947
+ meta: () => meta,
17948
+ parse: () => parse,
17949
+ parseAsync: () => parseAsync,
17950
+ prettifyError: () => prettifyError,
17951
+ process: () => process2,
17952
+ regexes: () => exports_regexes,
17953
+ registry: () => registry,
17954
+ safeDecode: () => safeDecode,
17955
+ safeDecodeAsync: () => safeDecodeAsync,
17956
+ safeEncode: () => safeEncode,
17957
+ safeEncodeAsync: () => safeEncodeAsync,
17958
+ safeParse: () => safeParse,
17959
+ safeParseAsync: () => safeParseAsync,
17960
+ toDotPath: () => toDotPath,
17961
+ toJSONSchema: () => toJSONSchema,
17962
+ treeifyError: () => treeifyError,
17963
+ util: () => exports_util,
17964
+ version: () => version
18539
17965
  });
18540
17966
 
18541
17967
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
@@ -18619,69 +18045,69 @@ function config(newConfig) {
18619
18045
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
18620
18046
  var exports_util = {};
18621
18047
  __export(exports_util, {
18622
- unwrapMessage: () => unwrapMessage,
18623
- uint8ArrayToHex: () => uint8ArrayToHex,
18624
- uint8ArrayToBase64url: () => uint8ArrayToBase64url,
18625
- uint8ArrayToBase64: () => uint8ArrayToBase64,
18626
- stringifyPrimitive: () => stringifyPrimitive,
18627
- slugify: () => slugify,
18628
- shallowClone: () => shallowClone,
18629
- safeExtend: () => safeExtend,
18630
- required: () => required,
18631
- randomString: () => randomString,
18632
- propertyKeyTypes: () => propertyKeyTypes,
18633
- promiseAllObject: () => promiseAllObject,
18634
- primitiveTypes: () => primitiveTypes,
18635
- prefixIssues: () => prefixIssues,
18636
- pick: () => pick,
18637
- partial: () => partial,
18638
- parsedType: () => parsedType,
18639
- optionalKeys: () => optionalKeys,
18640
- omit: () => omit,
18641
- objectClone: () => objectClone,
18642
- numKeys: () => numKeys,
18643
- nullish: () => nullish,
18644
- normalizeParams: () => normalizeParams,
18645
- mergeDefs: () => mergeDefs,
18646
- merge: () => merge,
18647
- jsonStringifyReplacer: () => jsonStringifyReplacer,
18648
- joinValues: () => joinValues,
18649
- issue: () => issue,
18650
- isPlainObject: () => isPlainObject,
18651
- isObject: () => isObject,
18652
- hexToUint8Array: () => hexToUint8Array,
18653
- getSizableOrigin: () => getSizableOrigin,
18654
- getParsedType: () => getParsedType,
18655
- getLengthableOrigin: () => getLengthableOrigin,
18656
- getEnumValues: () => getEnumValues,
18657
- getElementAtPath: () => getElementAtPath,
18658
- floatSafeRemainder: () => floatSafeRemainder,
18659
- finalizeIssue: () => finalizeIssue,
18660
- extend: () => extend,
18661
- explicitlyAborted: () => explicitlyAborted,
18662
- escapeRegex: () => escapeRegex,
18663
- esc: () => esc,
18664
- defineLazy: () => defineLazy,
18665
- createTransparentProxy: () => createTransparentProxy,
18666
- cloneDef: () => cloneDef,
18667
- clone: () => clone,
18668
- cleanRegex: () => cleanRegex,
18669
- cleanEnum: () => cleanEnum,
18670
- captureStackTrace: () => captureStackTrace,
18671
- cached: () => cached,
18672
- base64urlToUint8Array: () => base64urlToUint8Array,
18673
- base64ToUint8Array: () => base64ToUint8Array,
18674
- assignProp: () => assignProp,
18675
- assertNotEqual: () => assertNotEqual,
18676
- assertNever: () => assertNever,
18677
- assertIs: () => assertIs,
18678
- assertEqual: () => assertEqual,
18679
- assert: () => assert,
18680
- allowsEval: () => allowsEval,
18681
- aborted: () => aborted,
18682
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
18048
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
18683
18049
  Class: () => Class,
18684
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
18050
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
18051
+ aborted: () => aborted,
18052
+ allowsEval: () => allowsEval,
18053
+ assert: () => assert,
18054
+ assertEqual: () => assertEqual,
18055
+ assertIs: () => assertIs,
18056
+ assertNever: () => assertNever,
18057
+ assertNotEqual: () => assertNotEqual,
18058
+ assignProp: () => assignProp,
18059
+ base64ToUint8Array: () => base64ToUint8Array,
18060
+ base64urlToUint8Array: () => base64urlToUint8Array,
18061
+ cached: () => cached,
18062
+ captureStackTrace: () => captureStackTrace,
18063
+ cleanEnum: () => cleanEnum,
18064
+ cleanRegex: () => cleanRegex,
18065
+ clone: () => clone,
18066
+ cloneDef: () => cloneDef,
18067
+ createTransparentProxy: () => createTransparentProxy,
18068
+ defineLazy: () => defineLazy,
18069
+ esc: () => esc,
18070
+ escapeRegex: () => escapeRegex,
18071
+ explicitlyAborted: () => explicitlyAborted,
18072
+ extend: () => extend,
18073
+ finalizeIssue: () => finalizeIssue,
18074
+ floatSafeRemainder: () => floatSafeRemainder,
18075
+ getElementAtPath: () => getElementAtPath,
18076
+ getEnumValues: () => getEnumValues,
18077
+ getLengthableOrigin: () => getLengthableOrigin,
18078
+ getParsedType: () => getParsedType,
18079
+ getSizableOrigin: () => getSizableOrigin,
18080
+ hexToUint8Array: () => hexToUint8Array,
18081
+ isObject: () => isObject,
18082
+ isPlainObject: () => isPlainObject,
18083
+ issue: () => issue,
18084
+ joinValues: () => joinValues,
18085
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
18086
+ merge: () => merge,
18087
+ mergeDefs: () => mergeDefs,
18088
+ normalizeParams: () => normalizeParams,
18089
+ nullish: () => nullish,
18090
+ numKeys: () => numKeys,
18091
+ objectClone: () => objectClone,
18092
+ omit: () => omit,
18093
+ optionalKeys: () => optionalKeys,
18094
+ parsedType: () => parsedType,
18095
+ partial: () => partial,
18096
+ pick: () => pick,
18097
+ prefixIssues: () => prefixIssues,
18098
+ primitiveTypes: () => primitiveTypes,
18099
+ promiseAllObject: () => promiseAllObject,
18100
+ propertyKeyTypes: () => propertyKeyTypes,
18101
+ randomString: () => randomString,
18102
+ required: () => required,
18103
+ safeExtend: () => safeExtend,
18104
+ shallowClone: () => shallowClone,
18105
+ slugify: () => slugify,
18106
+ stringifyPrimitive: () => stringifyPrimitive,
18107
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
18108
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
18109
+ uint8ArrayToHex: () => uint8ArrayToHex,
18110
+ unwrapMessage: () => unwrapMessage
18685
18111
  });
18686
18112
  function assertEqual(val) {
18687
18113
  return val;
@@ -19538,65 +18964,65 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
19538
18964
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/regexes.js
19539
18965
  var exports_regexes = {};
19540
18966
  __export(exports_regexes, {
19541
- xid: () => xid,
19542
- uuid7: () => uuid7,
19543
- uuid6: () => uuid6,
19544
- uuid4: () => uuid4,
19545
- uuid: () => uuid,
19546
- uppercase: () => uppercase,
19547
- unicodeEmail: () => unicodeEmail,
19548
- undefined: () => _undefined,
19549
- ulid: () => ulid,
19550
- time: () => time,
19551
- string: () => string,
19552
- sha512_hex: () => sha512_hex,
19553
- sha512_base64url: () => sha512_base64url,
19554
- sha512_base64: () => sha512_base64,
19555
- sha384_hex: () => sha384_hex,
19556
- sha384_base64url: () => sha384_base64url,
19557
- sha384_base64: () => sha384_base64,
19558
- sha256_hex: () => sha256_hex,
19559
- sha256_base64url: () => sha256_base64url,
19560
- sha256_base64: () => sha256_base64,
19561
- sha1_hex: () => sha1_hex,
19562
- sha1_base64url: () => sha1_base64url,
19563
- sha1_base64: () => sha1_base64,
19564
- rfc5322Email: () => rfc5322Email,
19565
- number: () => number,
19566
- null: () => _null,
19567
- nanoid: () => nanoid,
19568
- md5_hex: () => md5_hex,
19569
- md5_base64url: () => md5_base64url,
19570
- md5_base64: () => md5_base64,
19571
- mac: () => mac,
19572
- lowercase: () => lowercase,
19573
- ksuid: () => ksuid,
19574
- ipv6: () => ipv6,
19575
- ipv4: () => ipv4,
19576
- integer: () => integer,
19577
- idnEmail: () => idnEmail,
19578
- httpProtocol: () => httpProtocol,
19579
- html5Email: () => html5Email,
19580
- hostname: () => hostname2,
19581
- hex: () => hex,
19582
- guid: () => guid,
19583
- extendedDuration: () => extendedDuration,
19584
- emoji: () => emoji,
19585
- email: () => email,
19586
- e164: () => e164,
19587
- duration: () => duration,
19588
- domain: () => domain,
19589
- datetime: () => datetime,
19590
- date: () => date,
19591
- cuid2: () => cuid2,
19592
- cuid: () => cuid,
19593
- cidrv6: () => cidrv6,
19594
- cidrv4: () => cidrv4,
19595
- browserEmail: () => browserEmail,
19596
- boolean: () => boolean,
19597
- bigint: () => bigint,
18967
+ base64: () => base64,
19598
18968
  base64url: () => base64url,
19599
- base64: () => base64
18969
+ bigint: () => bigint,
18970
+ boolean: () => boolean,
18971
+ browserEmail: () => browserEmail,
18972
+ cidrv4: () => cidrv4,
18973
+ cidrv6: () => cidrv6,
18974
+ cuid: () => cuid,
18975
+ cuid2: () => cuid2,
18976
+ date: () => date,
18977
+ datetime: () => datetime,
18978
+ domain: () => domain,
18979
+ duration: () => duration,
18980
+ e164: () => e164,
18981
+ email: () => email,
18982
+ emoji: () => emoji,
18983
+ extendedDuration: () => extendedDuration,
18984
+ guid: () => guid,
18985
+ hex: () => hex,
18986
+ hostname: () => hostname2,
18987
+ html5Email: () => html5Email,
18988
+ httpProtocol: () => httpProtocol,
18989
+ idnEmail: () => idnEmail,
18990
+ integer: () => integer,
18991
+ ipv4: () => ipv4,
18992
+ ipv6: () => ipv6,
18993
+ ksuid: () => ksuid,
18994
+ lowercase: () => lowercase,
18995
+ mac: () => mac,
18996
+ md5_base64: () => md5_base64,
18997
+ md5_base64url: () => md5_base64url,
18998
+ md5_hex: () => md5_hex,
18999
+ nanoid: () => nanoid,
19000
+ null: () => _null,
19001
+ number: () => number,
19002
+ rfc5322Email: () => rfc5322Email,
19003
+ sha1_base64: () => sha1_base64,
19004
+ sha1_base64url: () => sha1_base64url,
19005
+ sha1_hex: () => sha1_hex,
19006
+ sha256_base64: () => sha256_base64,
19007
+ sha256_base64url: () => sha256_base64url,
19008
+ sha256_hex: () => sha256_hex,
19009
+ sha384_base64: () => sha384_base64,
19010
+ sha384_base64url: () => sha384_base64url,
19011
+ sha384_hex: () => sha384_hex,
19012
+ sha512_base64: () => sha512_base64,
19013
+ sha512_base64url: () => sha512_base64url,
19014
+ sha512_hex: () => sha512_hex,
19015
+ string: () => string,
19016
+ time: () => time,
19017
+ ulid: () => ulid,
19018
+ undefined: () => _undefined,
19019
+ unicodeEmail: () => unicodeEmail,
19020
+ uppercase: () => uppercase,
19021
+ uuid: () => uuid,
19022
+ uuid4: () => uuid4,
19023
+ uuid6: () => uuid6,
19024
+ uuid7: () => uuid7,
19025
+ xid: () => xid
19600
19026
  });
19601
19027
  var cuid = /^[cC][0-9a-z]{6,}$/;
19602
19028
  var cuid2 = /^[0-9a-z]+$/;
@@ -22373,58 +21799,58 @@ function handleRefineResult(result, payload, input, inst) {
22373
21799
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/index.js
22374
21800
  var exports_locales = {};
22375
21801
  __export(exports_locales, {
22376
- zhTW: () => zh_TW_default,
22377
- zhCN: () => zh_CN_default,
22378
- yo: () => yo_default,
22379
- vi: () => vi_default,
22380
- uz: () => uz_default,
22381
- ur: () => ur_default,
22382
- uk: () => uk_default,
22383
- ua: () => ua_default,
22384
- tr: () => tr_default,
22385
- th: () => th_default,
22386
- ta: () => ta_default,
22387
- sv: () => sv_default,
22388
- sl: () => sl_default,
22389
- ru: () => ru_default,
22390
- ro: () => ro_default,
22391
- pt: () => pt_default,
22392
- ps: () => ps_default,
22393
- pl: () => pl_default,
22394
- ota: () => ota_default,
22395
- no: () => no_default,
22396
- nl: () => nl_default,
22397
- ms: () => ms_default,
22398
- mk: () => mk_default,
22399
- lt: () => lt_default,
22400
- ko: () => ko_default,
22401
- km: () => km_default,
22402
- kh: () => kh_default,
22403
- ka: () => ka_default,
22404
- ja: () => ja_default,
22405
- it: () => it_default,
22406
- is: () => is_default,
22407
- id: () => id_default,
22408
- hy: () => hy_default,
22409
- hu: () => hu_default,
22410
- hr: () => hr_default,
22411
- he: () => he_default,
22412
- frCA: () => fr_CA_default,
22413
- fr: () => fr_default,
22414
- fi: () => fi_default,
22415
- fa: () => fa_default,
22416
- es: () => es_default,
22417
- eo: () => eo_default,
22418
- en: () => en_default,
22419
- el: () => el_default,
22420
- de: () => de_default,
22421
- da: () => da_default,
22422
- cs: () => cs_default,
22423
- ca: () => ca_default,
22424
- bg: () => bg_default,
22425
- be: () => be_default,
21802
+ ar: () => ar_default,
22426
21803
  az: () => az_default,
22427
- ar: () => ar_default
21804
+ be: () => be_default,
21805
+ bg: () => bg_default,
21806
+ ca: () => ca_default,
21807
+ cs: () => cs_default,
21808
+ da: () => da_default,
21809
+ de: () => de_default,
21810
+ el: () => el_default,
21811
+ en: () => en_default,
21812
+ eo: () => eo_default,
21813
+ es: () => es_default,
21814
+ fa: () => fa_default,
21815
+ fi: () => fi_default,
21816
+ fr: () => fr_default,
21817
+ frCA: () => fr_CA_default,
21818
+ he: () => he_default,
21819
+ hr: () => hr_default,
21820
+ hu: () => hu_default,
21821
+ hy: () => hy_default,
21822
+ id: () => id_default,
21823
+ is: () => is_default,
21824
+ it: () => it_default,
21825
+ ja: () => ja_default,
21826
+ ka: () => ka_default,
21827
+ kh: () => kh_default,
21828
+ km: () => km_default,
21829
+ ko: () => ko_default,
21830
+ lt: () => lt_default,
21831
+ mk: () => mk_default,
21832
+ ms: () => ms_default,
21833
+ nl: () => nl_default,
21834
+ no: () => no_default,
21835
+ ota: () => ota_default,
21836
+ pl: () => pl_default,
21837
+ ps: () => ps_default,
21838
+ pt: () => pt_default,
21839
+ ro: () => ro_default,
21840
+ ru: () => ru_default,
21841
+ sl: () => sl_default,
21842
+ sv: () => sv_default,
21843
+ ta: () => ta_default,
21844
+ th: () => th_default,
21845
+ tr: () => tr_default,
21846
+ ua: () => ua_default,
21847
+ uk: () => uk_default,
21848
+ ur: () => ur_default,
21849
+ uz: () => uz_default,
21850
+ vi: () => vi_default,
21851
+ yo: () => yo_default,
21852
+ zhCN: () => zh_CN_default,
21853
+ zhTW: () => zh_TW_default
22428
21854
  });
22429
21855
 
22430
21856
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/ar.js
@@ -30195,219 +29621,219 @@ var exports_json_schema = {};
30195
29621
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
30196
29622
  var exports_schemas2 = {};
30197
29623
  __export(exports_schemas2, {
30198
- xor: () => xor,
30199
- xid: () => xid2,
30200
- void: () => _void2,
30201
- uuidv7: () => uuidv7,
30202
- uuidv6: () => uuidv6,
30203
- uuidv4: () => uuidv4,
30204
- uuid: () => uuid2,
30205
- url: () => url,
30206
- unknown: () => unknown,
30207
- union: () => union,
30208
- undefined: () => _undefined3,
30209
- ulid: () => ulid2,
30210
- uint64: () => uint64,
30211
- uint32: () => uint32,
30212
- tuple: () => tuple,
30213
- transform: () => transform,
30214
- templateLiteral: () => templateLiteral,
30215
- symbol: () => symbol,
30216
- superRefine: () => superRefine,
30217
- success: () => success,
30218
- stringbool: () => stringbool,
30219
- stringFormat: () => stringFormat,
30220
- string: () => string2,
30221
- strictObject: () => strictObject,
30222
- set: () => set,
30223
- refine: () => refine,
30224
- record: () => record,
30225
- readonly: () => readonly,
30226
- promise: () => promise,
30227
- preprocess: () => preprocess,
30228
- prefault: () => prefault,
30229
- pipe: () => pipe,
30230
- partialRecord: () => partialRecord,
30231
- optional: () => optional,
30232
- object: () => object,
30233
- number: () => number2,
30234
- nullish: () => nullish2,
30235
- nullable: () => nullable,
30236
- null: () => _null3,
30237
- nonoptional: () => nonoptional,
30238
- never: () => never,
30239
- nativeEnum: () => nativeEnum,
30240
- nanoid: () => nanoid2,
30241
- nan: () => nan,
30242
- meta: () => meta2,
30243
- map: () => map,
30244
- mac: () => mac2,
30245
- looseRecord: () => looseRecord,
30246
- looseObject: () => looseObject,
30247
- literal: () => literal,
30248
- lazy: () => lazy,
30249
- ksuid: () => ksuid2,
30250
- keyof: () => keyof,
30251
- jwt: () => jwt,
30252
- json: () => json,
30253
- ipv6: () => ipv62,
30254
- ipv4: () => ipv42,
30255
- invertCodec: () => invertCodec,
30256
- intersection: () => intersection,
30257
- int64: () => int64,
30258
- int32: () => int32,
30259
- int: () => int,
30260
- instanceof: () => _instanceof,
30261
- httpUrl: () => httpUrl,
30262
- hostname: () => hostname3,
30263
- hex: () => hex2,
30264
- hash: () => hash,
30265
- guid: () => guid2,
30266
- function: () => _function,
30267
- float64: () => float64,
30268
- float32: () => float32,
30269
- file: () => file,
30270
- exactOptional: () => exactOptional,
30271
- enum: () => _enum2,
30272
- emoji: () => emoji2,
30273
- email: () => email2,
30274
- e164: () => e1642,
30275
- discriminatedUnion: () => discriminatedUnion,
30276
- describe: () => describe2,
30277
- date: () => date3,
30278
- custom: () => custom,
30279
- cuid2: () => cuid22,
30280
- cuid: () => cuid3,
30281
- codec: () => codec,
30282
- cidrv6: () => cidrv62,
30283
- cidrv4: () => cidrv42,
30284
- check: () => check,
30285
- catch: () => _catch2,
30286
- boolean: () => boolean2,
30287
- bigint: () => bigint2,
30288
- base64url: () => base64url2,
30289
- base64: () => base642,
30290
- array: () => array,
30291
- any: () => any,
30292
- _function: () => _function,
30293
- _default: () => _default2,
30294
- _ZodString: () => _ZodString,
30295
- ZodXor: () => ZodXor,
30296
- ZodXID: () => ZodXID,
30297
- ZodVoid: () => ZodVoid,
30298
- ZodUnknown: () => ZodUnknown,
30299
- ZodUnion: () => ZodUnion,
30300
- ZodUndefined: () => ZodUndefined,
30301
- ZodUUID: () => ZodUUID,
30302
- ZodURL: () => ZodURL,
30303
- ZodULID: () => ZodULID,
30304
- ZodType: () => ZodType,
30305
- ZodTuple: () => ZodTuple,
30306
- ZodTransform: () => ZodTransform,
30307
- ZodTemplateLiteral: () => ZodTemplateLiteral,
30308
- ZodSymbol: () => ZodSymbol,
30309
- ZodSuccess: () => ZodSuccess,
30310
- ZodStringFormat: () => ZodStringFormat,
30311
- ZodString: () => ZodString,
30312
- ZodSet: () => ZodSet,
30313
- ZodRecord: () => ZodRecord,
30314
- ZodReadonly: () => ZodReadonly,
30315
- ZodPromise: () => ZodPromise,
30316
- ZodPreprocess: () => ZodPreprocess,
30317
- ZodPrefault: () => ZodPrefault,
30318
- ZodPipe: () => ZodPipe,
30319
- ZodOptional: () => ZodOptional,
30320
- ZodObject: () => ZodObject,
30321
- ZodNumberFormat: () => ZodNumberFormat,
30322
- ZodNumber: () => ZodNumber,
30323
- ZodNullable: () => ZodNullable,
30324
- ZodNull: () => ZodNull,
30325
- ZodNonOptional: () => ZodNonOptional,
30326
- ZodNever: () => ZodNever,
30327
- ZodNanoID: () => ZodNanoID,
30328
- ZodNaN: () => ZodNaN,
30329
- ZodMap: () => ZodMap,
30330
- ZodMAC: () => ZodMAC,
30331
- ZodLiteral: () => ZodLiteral,
30332
- ZodLazy: () => ZodLazy,
30333
- ZodKSUID: () => ZodKSUID,
30334
- ZodJWT: () => ZodJWT,
30335
- ZodIntersection: () => ZodIntersection,
30336
- ZodIPv6: () => ZodIPv6,
30337
- ZodIPv4: () => ZodIPv4,
30338
- ZodGUID: () => ZodGUID,
30339
- ZodFunction: () => ZodFunction,
30340
- ZodFile: () => ZodFile,
30341
- ZodExactOptional: () => ZodExactOptional,
30342
- ZodEnum: () => ZodEnum,
30343
- ZodEmoji: () => ZodEmoji,
30344
- ZodEmail: () => ZodEmail,
30345
- ZodE164: () => ZodE164,
30346
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
30347
- ZodDefault: () => ZodDefault,
30348
- ZodDate: () => ZodDate,
30349
- ZodCustomStringFormat: () => ZodCustomStringFormat,
30350
- ZodCustom: () => ZodCustom,
30351
- ZodCodec: () => ZodCodec,
30352
- ZodCatch: () => ZodCatch,
30353
- ZodCUID2: () => ZodCUID2,
30354
- ZodCUID: () => ZodCUID,
30355
- ZodCIDRv6: () => ZodCIDRv6,
30356
- ZodCIDRv4: () => ZodCIDRv4,
30357
- ZodBoolean: () => ZodBoolean,
30358
- ZodBigIntFormat: () => ZodBigIntFormat,
30359
- ZodBigInt: () => ZodBigInt,
30360
- ZodBase64URL: () => ZodBase64URL,
30361
- ZodBase64: () => ZodBase64,
29624
+ ZodAny: () => ZodAny,
30362
29625
  ZodArray: () => ZodArray,
30363
- ZodAny: () => ZodAny
29626
+ ZodBase64: () => ZodBase64,
29627
+ ZodBase64URL: () => ZodBase64URL,
29628
+ ZodBigInt: () => ZodBigInt,
29629
+ ZodBigIntFormat: () => ZodBigIntFormat,
29630
+ ZodBoolean: () => ZodBoolean,
29631
+ ZodCIDRv4: () => ZodCIDRv4,
29632
+ ZodCIDRv6: () => ZodCIDRv6,
29633
+ ZodCUID: () => ZodCUID,
29634
+ ZodCUID2: () => ZodCUID2,
29635
+ ZodCatch: () => ZodCatch,
29636
+ ZodCodec: () => ZodCodec,
29637
+ ZodCustom: () => ZodCustom,
29638
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
29639
+ ZodDate: () => ZodDate,
29640
+ ZodDefault: () => ZodDefault,
29641
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
29642
+ ZodE164: () => ZodE164,
29643
+ ZodEmail: () => ZodEmail,
29644
+ ZodEmoji: () => ZodEmoji,
29645
+ ZodEnum: () => ZodEnum,
29646
+ ZodExactOptional: () => ZodExactOptional,
29647
+ ZodFile: () => ZodFile,
29648
+ ZodFunction: () => ZodFunction,
29649
+ ZodGUID: () => ZodGUID,
29650
+ ZodIPv4: () => ZodIPv4,
29651
+ ZodIPv6: () => ZodIPv6,
29652
+ ZodIntersection: () => ZodIntersection,
29653
+ ZodJWT: () => ZodJWT,
29654
+ ZodKSUID: () => ZodKSUID,
29655
+ ZodLazy: () => ZodLazy,
29656
+ ZodLiteral: () => ZodLiteral,
29657
+ ZodMAC: () => ZodMAC,
29658
+ ZodMap: () => ZodMap,
29659
+ ZodNaN: () => ZodNaN,
29660
+ ZodNanoID: () => ZodNanoID,
29661
+ ZodNever: () => ZodNever,
29662
+ ZodNonOptional: () => ZodNonOptional,
29663
+ ZodNull: () => ZodNull,
29664
+ ZodNullable: () => ZodNullable,
29665
+ ZodNumber: () => ZodNumber,
29666
+ ZodNumberFormat: () => ZodNumberFormat,
29667
+ ZodObject: () => ZodObject,
29668
+ ZodOptional: () => ZodOptional,
29669
+ ZodPipe: () => ZodPipe,
29670
+ ZodPrefault: () => ZodPrefault,
29671
+ ZodPreprocess: () => ZodPreprocess,
29672
+ ZodPromise: () => ZodPromise,
29673
+ ZodReadonly: () => ZodReadonly,
29674
+ ZodRecord: () => ZodRecord,
29675
+ ZodSet: () => ZodSet,
29676
+ ZodString: () => ZodString,
29677
+ ZodStringFormat: () => ZodStringFormat,
29678
+ ZodSuccess: () => ZodSuccess,
29679
+ ZodSymbol: () => ZodSymbol,
29680
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
29681
+ ZodTransform: () => ZodTransform,
29682
+ ZodTuple: () => ZodTuple,
29683
+ ZodType: () => ZodType,
29684
+ ZodULID: () => ZodULID,
29685
+ ZodURL: () => ZodURL,
29686
+ ZodUUID: () => ZodUUID,
29687
+ ZodUndefined: () => ZodUndefined,
29688
+ ZodUnion: () => ZodUnion,
29689
+ ZodUnknown: () => ZodUnknown,
29690
+ ZodVoid: () => ZodVoid,
29691
+ ZodXID: () => ZodXID,
29692
+ ZodXor: () => ZodXor,
29693
+ _ZodString: () => _ZodString,
29694
+ _default: () => _default2,
29695
+ _function: () => _function,
29696
+ any: () => any,
29697
+ array: () => array,
29698
+ base64: () => base642,
29699
+ base64url: () => base64url2,
29700
+ bigint: () => bigint2,
29701
+ boolean: () => boolean2,
29702
+ catch: () => _catch2,
29703
+ check: () => check,
29704
+ cidrv4: () => cidrv42,
29705
+ cidrv6: () => cidrv62,
29706
+ codec: () => codec,
29707
+ cuid: () => cuid3,
29708
+ cuid2: () => cuid22,
29709
+ custom: () => custom,
29710
+ date: () => date3,
29711
+ describe: () => describe2,
29712
+ discriminatedUnion: () => discriminatedUnion,
29713
+ e164: () => e1642,
29714
+ email: () => email2,
29715
+ emoji: () => emoji2,
29716
+ enum: () => _enum2,
29717
+ exactOptional: () => exactOptional,
29718
+ file: () => file,
29719
+ float32: () => float32,
29720
+ float64: () => float64,
29721
+ function: () => _function,
29722
+ guid: () => guid2,
29723
+ hash: () => hash,
29724
+ hex: () => hex2,
29725
+ hostname: () => hostname3,
29726
+ httpUrl: () => httpUrl,
29727
+ instanceof: () => _instanceof,
29728
+ int: () => int,
29729
+ int32: () => int32,
29730
+ int64: () => int64,
29731
+ intersection: () => intersection,
29732
+ invertCodec: () => invertCodec,
29733
+ ipv4: () => ipv42,
29734
+ ipv6: () => ipv62,
29735
+ json: () => json,
29736
+ jwt: () => jwt,
29737
+ keyof: () => keyof,
29738
+ ksuid: () => ksuid2,
29739
+ lazy: () => lazy,
29740
+ literal: () => literal,
29741
+ looseObject: () => looseObject,
29742
+ looseRecord: () => looseRecord,
29743
+ mac: () => mac2,
29744
+ map: () => map,
29745
+ meta: () => meta2,
29746
+ nan: () => nan,
29747
+ nanoid: () => nanoid2,
29748
+ nativeEnum: () => nativeEnum,
29749
+ never: () => never,
29750
+ nonoptional: () => nonoptional,
29751
+ null: () => _null3,
29752
+ nullable: () => nullable,
29753
+ nullish: () => nullish2,
29754
+ number: () => number2,
29755
+ object: () => object,
29756
+ optional: () => optional,
29757
+ partialRecord: () => partialRecord,
29758
+ pipe: () => pipe,
29759
+ prefault: () => prefault,
29760
+ preprocess: () => preprocess,
29761
+ promise: () => promise,
29762
+ readonly: () => readonly,
29763
+ record: () => record,
29764
+ refine: () => refine,
29765
+ set: () => set,
29766
+ strictObject: () => strictObject,
29767
+ string: () => string2,
29768
+ stringFormat: () => stringFormat,
29769
+ stringbool: () => stringbool,
29770
+ success: () => success,
29771
+ superRefine: () => superRefine,
29772
+ symbol: () => symbol,
29773
+ templateLiteral: () => templateLiteral,
29774
+ transform: () => transform,
29775
+ tuple: () => tuple,
29776
+ uint32: () => uint32,
29777
+ uint64: () => uint64,
29778
+ ulid: () => ulid2,
29779
+ undefined: () => _undefined3,
29780
+ union: () => union,
29781
+ unknown: () => unknown,
29782
+ url: () => url,
29783
+ uuid: () => uuid2,
29784
+ uuidv4: () => uuidv4,
29785
+ uuidv6: () => uuidv6,
29786
+ uuidv7: () => uuidv7,
29787
+ void: () => _void2,
29788
+ xid: () => xid2,
29789
+ xor: () => xor
30364
29790
  });
30365
29791
 
30366
29792
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/checks.js
30367
29793
  var exports_checks2 = {};
30368
29794
  __export(exports_checks2, {
30369
- uppercase: () => _uppercase,
30370
- trim: () => _trim,
30371
- toUpperCase: () => _toUpperCase,
30372
- toLowerCase: () => _toLowerCase,
30373
- startsWith: () => _startsWith,
30374
- slugify: () => _slugify,
30375
- size: () => _size,
30376
- regex: () => _regex,
30377
- property: () => _property,
30378
- positive: () => _positive,
30379
- overwrite: () => _overwrite,
30380
- normalize: () => _normalize,
30381
- nonpositive: () => _nonpositive,
30382
- nonnegative: () => _nonnegative,
30383
- negative: () => _negative,
30384
- multipleOf: () => _multipleOf,
30385
- minSize: () => _minSize,
30386
- minLength: () => _minLength,
30387
- mime: () => _mime,
30388
- maxSize: () => _maxSize,
30389
- maxLength: () => _maxLength,
30390
- lte: () => _lte,
30391
- lt: () => _lt,
30392
- lowercase: () => _lowercase,
30393
- length: () => _length,
30394
- includes: () => _includes,
30395
- gte: () => _gte,
29795
+ endsWith: () => _endsWith,
30396
29796
  gt: () => _gt,
30397
- endsWith: () => _endsWith
29797
+ gte: () => _gte,
29798
+ includes: () => _includes,
29799
+ length: () => _length,
29800
+ lowercase: () => _lowercase,
29801
+ lt: () => _lt,
29802
+ lte: () => _lte,
29803
+ maxLength: () => _maxLength,
29804
+ maxSize: () => _maxSize,
29805
+ mime: () => _mime,
29806
+ minLength: () => _minLength,
29807
+ minSize: () => _minSize,
29808
+ multipleOf: () => _multipleOf,
29809
+ negative: () => _negative,
29810
+ nonnegative: () => _nonnegative,
29811
+ nonpositive: () => _nonpositive,
29812
+ normalize: () => _normalize,
29813
+ overwrite: () => _overwrite,
29814
+ positive: () => _positive,
29815
+ property: () => _property,
29816
+ regex: () => _regex,
29817
+ size: () => _size,
29818
+ slugify: () => _slugify,
29819
+ startsWith: () => _startsWith,
29820
+ toLowerCase: () => _toLowerCase,
29821
+ toUpperCase: () => _toUpperCase,
29822
+ trim: () => _trim,
29823
+ uppercase: () => _uppercase
30398
29824
  });
30399
29825
 
30400
29826
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
30401
29827
  var exports_iso = {};
30402
29828
  __export(exports_iso, {
30403
- time: () => time2,
30404
- duration: () => duration2,
30405
- datetime: () => datetime2,
30406
- date: () => date2,
30407
- ZodISOTime: () => ZodISOTime,
30408
- ZodISODuration: () => ZodISODuration,
29829
+ ZodISODate: () => ZodISODate,
30409
29830
  ZodISODateTime: () => ZodISODateTime,
30410
- ZodISODate: () => ZodISODate
29831
+ ZodISODuration: () => ZodISODuration,
29832
+ ZodISOTime: () => ZodISOTime,
29833
+ date: () => date2,
29834
+ datetime: () => datetime2,
29835
+ duration: () => duration2,
29836
+ time: () => time2
30411
29837
  });
30412
29838
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
30413
29839
  $ZodISODateTime.init(inst, def);
@@ -32268,11 +31694,11 @@ function fromJSONSchema(schema, params) {
32268
31694
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/coerce.js
32269
31695
  var exports_coerce = {};
32270
31696
  __export(exports_coerce, {
32271
- string: () => string3,
32272
- number: () => number3,
32273
- date: () => date4,
31697
+ bigint: () => bigint3,
32274
31698
  boolean: () => boolean3,
32275
- bigint: () => bigint3
31699
+ date: () => date4,
31700
+ number: () => number3,
31701
+ string: () => string3
32276
31702
  });
32277
31703
  function string3(params) {
32278
31704
  return _coercedString(ZodString, params);
@@ -32383,6 +31809,9 @@ var SubcConfigSchema = exports_external.object({
32383
31809
  connection_file: exports_external.string().optional(),
32384
31810
  client_reaper: exports_external.boolean().optional()
32385
31811
  });
31812
+ var GhShimConfigSchema = exports_external.object({
31813
+ enabled: exports_external.boolean().optional()
31814
+ });
32386
31815
  var DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 120000;
32387
31816
  var MIN_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 1e4;
32388
31817
  var MAX_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 600000;
@@ -32437,7 +31866,8 @@ var AftConfigSchema = exports_external.preprocess((value) => stripHarnessSpecifi
32437
31866
  semantic: SemanticConfigSchema.optional(),
32438
31867
  auto_update: exports_external.boolean().optional(),
32439
31868
  bridge: BridgeConfigSchema.optional(),
32440
- subc: SubcConfigSchema.optional()
31869
+ subc: SubcConfigSchema.optional(),
31870
+ gh_shim: GhShimConfigSchema.optional()
32441
31871
  }).strict());
32442
31872
  function resolveInspectDiagnosticsTimeoutMs(config2) {
32443
31873
  return clampInspectDiagnosticsTimeoutMs(config2.inspect?.diagnostics_timeout_ms ?? DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS);
@@ -32890,6 +32320,8 @@ function getStrippedTopLevelKeys(override) {
32890
32320
  stripped.push("sandbox.write_allow");
32891
32321
  if (override.subc !== undefined)
32892
32322
  stripped.push("subc");
32323
+ if (override.gh_shim !== undefined)
32324
+ stripped.push("gh_shim");
32893
32325
  if (override.disabled_tools?.includes("aft_safety"))
32894
32326
  stripped.push("disabled_tools.aft_safety");
32895
32327
  return stripped;
@@ -37594,6 +37026,7 @@ function createBashTool(ctx, aftSearchRegisteredOverride) {
37594
37026
  compressed: z5.boolean().optional().describe("When true or omitted, return compressed output with noisy terminal control sequences reduced. Set to false for raw output."),
37595
37027
  ...ptyArgs
37596
37028
  };
37029
+ let hostFallbackActive = false;
37597
37030
  return {
37598
37031
  description: bashToolDescription(false, initialBashCfg.compress, initialBashCfg.background),
37599
37032
  args,
@@ -37690,12 +37123,15 @@ function createBashTool(ctx, aftSearchRegisteredOverride) {
37690
37123
  env: shellEnv?.env
37691
37124
  });
37692
37125
  usedHostFallback = true;
37126
+ hostFallbackActive = true;
37693
37127
  } finally {
37694
37128
  removeAbortListener();
37695
37129
  }
37696
37130
  if (data.success === false) {
37697
37131
  throw new Error(data.message || "bash failed");
37698
37132
  }
37133
+ if (!usedHostFallback && hostFallbackActive)
37134
+ hostFallbackActive = false;
37699
37135
  const uiTitle = description ?? shortenCommand(command);
37700
37136
  if (data.status === "running" && typeof data.task_id === "string") {
37701
37137
  const taskId = data.task_id;
@@ -38593,9 +38029,20 @@ ${backupBehavior}
38593
38029
  - Symbol replace includes decorators, attributes, and doc comments in range
38594
38030
  - Response is a compact server-rendered summary; before/after diff details are attached as UI metadata when available.`;
38595
38031
  }
38032
+ var HASHLINE_EDIT_DESCRIPTION = [
38033
+ "Apply a hashline patch. Arguments are exactly `{patch}` where `patch` is a non-empty string. Server-owned preview control is outside this schema.",
38034
+ "",
38035
+ "Quick reference:",
38036
+ "- 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.",
38037
+ "- Same canonical path: multiple sections compose in patch order against pre-request coordinates.",
38038
+ "- 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.",
38039
+ "- 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 `-`.",
38040
+ "- 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."
38041
+ ].join(`
38042
+ `);
38596
38043
  function createHashlineEditTool(ctx) {
38597
38044
  return {
38598
- 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.",
38045
+ description: HASHLINE_EDIT_DESCRIPTION,
38599
38046
  args: {
38600
38047
  patch: z8.string().min(1).describe("Hashline patch text with one or more [path#TAG] sections and PUT/CUT/REM/MV operations")
38601
38048
  },
@@ -40262,7 +39709,7 @@ var PLUGIN_VERSION = (() => {
40262
39709
  return "0.0.0";
40263
39710
  }
40264
39711
  })();
40265
- var ANNOUNCEMENT_VERSION = "0.51.3";
39712
+ var ANNOUNCEMENT_VERSION = "0.52.1";
40266
39713
  var ANNOUNCEMENT_FEATURES = [
40267
39714
  "Callgraph stays consistent under load: edits arriving mid-rebuild can no longer be silently lost from navigation results.",
40268
39715
  "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).",
@@ -40291,7 +39738,16 @@ async function initializePluginForDirectory(input) {
40291
39738
  log2(`AFT disabled by config for ${registrationRoot}`);
40292
39739
  return { tool: {} };
40293
39740
  }
40294
- const binaryPath = await findBinary(PLUGIN_VERSION);
39741
+ const cachedBinaryPath = findBinarySync(PLUGIN_VERSION);
39742
+ if (!cachedBinaryPath) {
39743
+ ensureBinary(PLUGIN_VERSION).then((path7) => {
39744
+ if (path7)
39745
+ log2(`Background binary warmup ready at ${path7}`);
39746
+ }, (err) => {
39747
+ warn2(`Background binary warmup failed: ${err instanceof Error ? err.message : String(err)}`);
39748
+ });
39749
+ }
39750
+ const binaryPath = cachedBinaryPath ?? await findBinary(PLUGIN_VERSION);
40295
39751
  await ensureStorageMigrated({ harness: "opencode", binaryPath, logger: bridgeLogger });
40296
39752
  const autoUpdateAbort = new AbortController;
40297
39753
  const projectEnabledCache = new Map([[registrationRoot, true]]);