@cortexkit/aft-opencode 0.51.3 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,12 +19,14 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  }
20
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
21
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
22
+ if (mod && typeof mod === "object" || typeof mod === "function") {
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ }
28
30
  if (canCache)
29
31
  cache.set(mod, to);
30
32
  return to;
@@ -46,7 +48,7 @@ var __export = (target, all) => {
46
48
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
47
49
 
48
50
  // ../../node_modules/.bun/esprima@4.0.1/node_modules/esprima/dist/esprima.js
49
- var require_esprima = __commonJS((exports, module) => {
51
+ var require_esprima = __commonJS(function(exports, module) {
50
52
  (function webpackUniversalModuleDefinition(root, factory) {
51
53
  if (typeof exports === "object" && typeof module === "object")
52
54
  module.exports = factory();
@@ -6186,7 +6188,7 @@ var require_esprima = __commonJS((exports, module) => {
6186
6188
  });
6187
6189
 
6188
6190
  // ../../node_modules/.bun/array-timsort@1.0.3/node_modules/array-timsort/src/index.js
6189
- var require_src = __commonJS((exports, module) => {
6191
+ var require_src = __commonJS(function(exports, module) {
6190
6192
  var DEFAULT_MIN_MERGE = 32;
6191
6193
  var DEFAULT_MIN_GALLOPING = 7;
6192
6194
  var DEFAULT_TMP_STORAGE_LENGTH = 256;
@@ -6829,7 +6831,7 @@ var require_src = __commonJS((exports, module) => {
6829
6831
  });
6830
6832
 
6831
6833
  // ../../node_modules/.bun/comment-json@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,12 @@ 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;
12767
12090
  var BG_STABLE_MS = 5000;
12091
+ function reconnectBackoffMs(attempt) {
12092
+ return Math.min(RECONNECT_RETRY_FLOOR_MS * 2 ** Math.min(attempt, 6), RECONNECT_RETRY_CAP_MS);
12093
+ }
12768
12094
  var BG_LIFECYCLE_LOG_INTERVAL_MS = 60000;
12769
12095
  var BG_DISPATCH_PROBE_INTERVAL_MS = 60000;
12770
12096
  var DEFAULT_SESSION_ID = "__default__";
@@ -13028,6 +12354,8 @@ class BgSubscription {
13028
12354
  giveUp("stopped");
13029
12355
  return;
13030
12356
  }
12357
+ if (Date.now() - subscribedAt >= BG_STABLE_MS)
12358
+ backoffAttempt = 0;
13031
12359
  beginReconnect();
13032
12360
  } catch (err) {
13033
12361
  const routeId2 = this.routeId(route);
@@ -13052,8 +12380,7 @@ class BgSubscription {
13052
12380
  giveUp("stopped");
13053
12381
  }
13054
12382
  async backoff(attempt) {
13055
- const ms = Math.min(100 * 2 ** Math.min(attempt, 6), 2000);
13056
- await this.sleep(ms);
12383
+ await this.sleep(reconnectBackoffMs(attempt));
13057
12384
  }
13058
12385
  }
13059
12386
  function isRecord(value) {
@@ -13179,6 +12506,7 @@ class SubcTransportPool {
13179
12506
  onBgEventsNudge;
13180
12507
  onBgEventsNudgeRef;
13181
12508
  bgBackoffSleep;
12509
+ routeRetrySleep;
13182
12510
  bgDispatchProbeIntervalMs;
13183
12511
  lifecycleDemandCheck;
13184
12512
  onLifecycleEvent;
@@ -13189,6 +12517,8 @@ class SubcTransportPool {
13189
12517
  outerFacadeEvictor;
13190
12518
  client = null;
13191
12519
  connecting = null;
12520
+ routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
12521
+ routeReopenRetry = null;
13192
12522
  sessions = new Map;
13193
12523
  rootIndex = new Map;
13194
12524
  dormantRoots = new Map;
@@ -13209,6 +12539,7 @@ class SubcTransportPool {
13209
12539
  this.onBgEventsNudge = options.onBgEventsNudge;
13210
12540
  this.onBgEventsNudgeRef = options.onBgEventsNudgeRef;
13211
12541
  this.bgBackoffSleep = options.bgBackoffSleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
12542
+ this.routeRetrySleep = options.routeRetrySleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
13212
12543
  this.bgDispatchProbeIntervalMs = options.bgDispatchProbeIntervalMs ?? BG_DISPATCH_PROBE_INTERVAL_MS;
13213
12544
  const lifecycle = options.lifecycle;
13214
12545
  const demandCheck = options.lifecycleDemandCheck ?? options.demandCheck ?? lifecycle?.demandCheck;
@@ -13705,9 +13036,12 @@ class SubcTransportPool {
13705
13036
  throw this.annotateReapError(error2, record);
13706
13037
  if (isRouteProvenAbsentError(error2) && this.isCurrentSession(key, record) && this.client === client) {
13707
13038
  clearRouteEntry(routeAndEntry.entry);
13039
+ await this.waitForRouteReopenBackoff();
13708
13040
  routeAndEntry = await openRoute();
13709
13041
  try {
13710
- return await requestOnRoute(routeAndEntry.route);
13042
+ const reply = await requestOnRoute(routeAndEntry.route);
13043
+ this.resetRouteReopenBackoff();
13044
+ return reply;
13711
13045
  } catch (retryError) {
13712
13046
  if (this.isReapInduced(record))
13713
13047
  throw this.annotateReapError(retryError, record);
@@ -13727,6 +13061,23 @@ class SubcTransportPool {
13727
13061
  this.deleteSessionIfEmpty(key, record);
13728
13062
  }
13729
13063
  }
13064
+ waitForRouteReopenBackoff() {
13065
+ const pending = this.routeReopenRetry;
13066
+ if (pending)
13067
+ return pending;
13068
+ const delay = this.routeReopenRetryDelayMs;
13069
+ this.routeReopenRetryDelayMs = Math.min(delay * 2, RECONNECT_RETRY_CAP_MS);
13070
+ let retry;
13071
+ retry = Promise.resolve().then(() => this.routeRetrySleep(delay)).finally(() => {
13072
+ if (this.routeReopenRetry === retry)
13073
+ this.routeReopenRetry = null;
13074
+ });
13075
+ this.routeReopenRetry = retry;
13076
+ return retry;
13077
+ }
13078
+ resetRouteReopenBackoff() {
13079
+ this.routeReopenRetryDelayMs = RECONNECT_RETRY_FLOOR_MS;
13080
+ }
13730
13081
  async ensureClient() {
13731
13082
  if (this.shuttingDown)
13732
13083
  throw new SubcTransportShuttingDownError;
@@ -16419,11 +15770,16 @@ function normalizeKey(projectRoot) {
16419
15770
  return canonicalizeProjectRoot(projectRoot);
16420
15771
  }
16421
15772
  // ../aft-bridge/dist/revivable-transport.js
15773
+ var REVIVAL_RETRY_FLOOR_MS = 100;
15774
+ var REVIVAL_RETRY_CAP_MS = 2000;
15775
+
16422
15776
  class RevivableTransportPool {
16423
15777
  createPool;
16424
15778
  onBinaryReplaced;
16425
15779
  activePool;
16426
15780
  revival = null;
15781
+ revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
15782
+ revivalRetryNotBefore = 0;
16427
15783
  transports = new Map;
16428
15784
  configureOverrides = new Map;
16429
15785
  editSlotSurvivesCaptured = false;
@@ -16517,12 +15873,30 @@ class RevivableTransportPool {
16517
15873
  return this.activePool;
16518
15874
  if (this.revival)
16519
15875
  return this.revival;
15876
+ const delay = Math.max(0, this.revivalRetryNotBefore - Date.now());
15877
+ if (delay > 0) {
15878
+ let scheduled;
15879
+ scheduled = new Promise((resolve7) => setTimeout(resolve7, delay)).then(() => {
15880
+ if (this.revival === scheduled)
15881
+ this.revival = null;
15882
+ return this.ensureActivePool();
15883
+ });
15884
+ this.revival = scheduled;
15885
+ scheduled.then(() => {
15886
+ return;
15887
+ }, () => {
15888
+ return;
15889
+ });
15890
+ return scheduled;
15891
+ }
16520
15892
  warn("transport was shut down but new demand arrived — reviving (host quit hook fired without process exit?)");
16521
- const revival = this.createPool().then((pool) => {
15893
+ const revival = Promise.resolve().then(() => this.createPool()).then((pool) => {
16522
15894
  for (const [key, value] of this.configureOverrides) {
16523
15895
  pool.setConfigureOverride(key, value);
16524
15896
  }
16525
15897
  this.activePool = pool;
15898
+ this.revivalRetryDelayMs = REVIVAL_RETRY_FLOOR_MS;
15899
+ this.revivalRetryNotBefore = 0;
16526
15900
  for (const [root, transport] of this.transports) {
16527
15901
  transport.refreshStatusSubscription(pool.getActiveBridgeForRoot(root));
16528
15902
  }
@@ -16533,6 +15907,8 @@ class RevivableTransportPool {
16533
15907
  if (this.revival === revival)
16534
15908
  this.revival = null;
16535
15909
  }, () => {
15910
+ this.revivalRetryNotBefore = Date.now() + this.revivalRetryDelayMs;
15911
+ this.revivalRetryDelayMs = Math.min(this.revivalRetryDelayMs * 2, REVIVAL_RETRY_CAP_MS);
16536
15912
  if (this.revival === revival)
16537
15913
  this.revival = null;
16538
15914
  });
@@ -18019,523 +17395,523 @@ var import_comment_json = __toESM(require_src2(), 1);
18019
17395
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
18020
17396
  var exports_external = {};
18021
17397
  __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,
17398
+ $brand: () => $brand,
18258
17399
  $input: () => $input,
18259
- $brand: () => $brand
17400
+ $output: () => $output,
17401
+ NEVER: () => NEVER,
17402
+ TimePrecision: () => TimePrecision,
17403
+ ZodAny: () => ZodAny,
17404
+ ZodArray: () => ZodArray,
17405
+ ZodBase64: () => ZodBase64,
17406
+ ZodBase64URL: () => ZodBase64URL,
17407
+ ZodBigInt: () => ZodBigInt,
17408
+ ZodBigIntFormat: () => ZodBigIntFormat,
17409
+ ZodBoolean: () => ZodBoolean,
17410
+ ZodCIDRv4: () => ZodCIDRv4,
17411
+ ZodCIDRv6: () => ZodCIDRv6,
17412
+ ZodCUID: () => ZodCUID,
17413
+ ZodCUID2: () => ZodCUID2,
17414
+ ZodCatch: () => ZodCatch,
17415
+ ZodCodec: () => ZodCodec,
17416
+ ZodCustom: () => ZodCustom,
17417
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
17418
+ ZodDate: () => ZodDate,
17419
+ ZodDefault: () => ZodDefault,
17420
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
17421
+ ZodE164: () => ZodE164,
17422
+ ZodEmail: () => ZodEmail,
17423
+ ZodEmoji: () => ZodEmoji,
17424
+ ZodEnum: () => ZodEnum,
17425
+ ZodError: () => ZodError,
17426
+ ZodExactOptional: () => ZodExactOptional,
17427
+ ZodFile: () => ZodFile,
17428
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
17429
+ ZodFunction: () => ZodFunction,
17430
+ ZodGUID: () => ZodGUID,
17431
+ ZodIPv4: () => ZodIPv4,
17432
+ ZodIPv6: () => ZodIPv6,
17433
+ ZodISODate: () => ZodISODate,
17434
+ ZodISODateTime: () => ZodISODateTime,
17435
+ ZodISODuration: () => ZodISODuration,
17436
+ ZodISOTime: () => ZodISOTime,
17437
+ ZodIntersection: () => ZodIntersection,
17438
+ ZodIssueCode: () => ZodIssueCode,
17439
+ ZodJWT: () => ZodJWT,
17440
+ ZodKSUID: () => ZodKSUID,
17441
+ ZodLazy: () => ZodLazy,
17442
+ ZodLiteral: () => ZodLiteral,
17443
+ ZodMAC: () => ZodMAC,
17444
+ ZodMap: () => ZodMap,
17445
+ ZodNaN: () => ZodNaN,
17446
+ ZodNanoID: () => ZodNanoID,
17447
+ ZodNever: () => ZodNever,
17448
+ ZodNonOptional: () => ZodNonOptional,
17449
+ ZodNull: () => ZodNull,
17450
+ ZodNullable: () => ZodNullable,
17451
+ ZodNumber: () => ZodNumber,
17452
+ ZodNumberFormat: () => ZodNumberFormat,
17453
+ ZodObject: () => ZodObject,
17454
+ ZodOptional: () => ZodOptional,
17455
+ ZodPipe: () => ZodPipe,
17456
+ ZodPrefault: () => ZodPrefault,
17457
+ ZodPreprocess: () => ZodPreprocess,
17458
+ ZodPromise: () => ZodPromise,
17459
+ ZodReadonly: () => ZodReadonly,
17460
+ ZodRealError: () => ZodRealError,
17461
+ ZodRecord: () => ZodRecord,
17462
+ ZodSet: () => ZodSet,
17463
+ ZodString: () => ZodString,
17464
+ ZodStringFormat: () => ZodStringFormat,
17465
+ ZodSuccess: () => ZodSuccess,
17466
+ ZodSymbol: () => ZodSymbol,
17467
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
17468
+ ZodTransform: () => ZodTransform,
17469
+ ZodTuple: () => ZodTuple,
17470
+ ZodType: () => ZodType,
17471
+ ZodULID: () => ZodULID,
17472
+ ZodURL: () => ZodURL,
17473
+ ZodUUID: () => ZodUUID,
17474
+ ZodUndefined: () => ZodUndefined,
17475
+ ZodUnion: () => ZodUnion,
17476
+ ZodUnknown: () => ZodUnknown,
17477
+ ZodVoid: () => ZodVoid,
17478
+ ZodXID: () => ZodXID,
17479
+ ZodXor: () => ZodXor,
17480
+ _ZodString: () => _ZodString,
17481
+ _default: () => _default2,
17482
+ _function: () => _function,
17483
+ any: () => any,
17484
+ array: () => array,
17485
+ base64: () => base642,
17486
+ base64url: () => base64url2,
17487
+ bigint: () => bigint2,
17488
+ boolean: () => boolean2,
17489
+ catch: () => _catch2,
17490
+ check: () => check,
17491
+ cidrv4: () => cidrv42,
17492
+ cidrv6: () => cidrv62,
17493
+ clone: () => clone,
17494
+ codec: () => codec,
17495
+ coerce: () => exports_coerce,
17496
+ config: () => config,
17497
+ core: () => exports_core2,
17498
+ cuid: () => cuid3,
17499
+ cuid2: () => cuid22,
17500
+ custom: () => custom,
17501
+ date: () => date3,
17502
+ decode: () => decode2,
17503
+ decodeAsync: () => decodeAsync2,
17504
+ describe: () => describe2,
17505
+ discriminatedUnion: () => discriminatedUnion,
17506
+ e164: () => e1642,
17507
+ email: () => email2,
17508
+ emoji: () => emoji2,
17509
+ encode: () => encode2,
17510
+ encodeAsync: () => encodeAsync2,
17511
+ endsWith: () => _endsWith,
17512
+ enum: () => _enum2,
17513
+ exactOptional: () => exactOptional,
17514
+ file: () => file,
17515
+ flattenError: () => flattenError,
17516
+ float32: () => float32,
17517
+ float64: () => float64,
17518
+ formatError: () => formatError,
17519
+ fromJSONSchema: () => fromJSONSchema,
17520
+ function: () => _function,
17521
+ getErrorMap: () => getErrorMap,
17522
+ globalRegistry: () => globalRegistry,
17523
+ gt: () => _gt,
17524
+ gte: () => _gte,
17525
+ guid: () => guid2,
17526
+ hash: () => hash,
17527
+ hex: () => hex2,
17528
+ hostname: () => hostname3,
17529
+ httpUrl: () => httpUrl,
17530
+ includes: () => _includes,
17531
+ instanceof: () => _instanceof,
17532
+ int: () => int,
17533
+ int32: () => int32,
17534
+ int64: () => int64,
17535
+ intersection: () => intersection,
17536
+ invertCodec: () => invertCodec,
17537
+ ipv4: () => ipv42,
17538
+ ipv6: () => ipv62,
17539
+ iso: () => exports_iso,
17540
+ json: () => json,
17541
+ jwt: () => jwt,
17542
+ keyof: () => keyof,
17543
+ ksuid: () => ksuid2,
17544
+ lazy: () => lazy,
17545
+ length: () => _length,
17546
+ literal: () => literal,
17547
+ locales: () => exports_locales,
17548
+ looseObject: () => looseObject,
17549
+ looseRecord: () => looseRecord,
17550
+ lowercase: () => _lowercase,
17551
+ lt: () => _lt,
17552
+ lte: () => _lte,
17553
+ mac: () => mac2,
17554
+ map: () => map,
17555
+ maxLength: () => _maxLength,
17556
+ maxSize: () => _maxSize,
17557
+ meta: () => meta2,
17558
+ mime: () => _mime,
17559
+ minLength: () => _minLength,
17560
+ minSize: () => _minSize,
17561
+ multipleOf: () => _multipleOf,
17562
+ nan: () => nan,
17563
+ nanoid: () => nanoid2,
17564
+ nativeEnum: () => nativeEnum,
17565
+ negative: () => _negative,
17566
+ never: () => never,
17567
+ nonnegative: () => _nonnegative,
17568
+ nonoptional: () => nonoptional,
17569
+ nonpositive: () => _nonpositive,
17570
+ normalize: () => _normalize,
17571
+ null: () => _null3,
17572
+ nullable: () => nullable,
17573
+ nullish: () => nullish2,
17574
+ number: () => number2,
17575
+ object: () => object,
17576
+ optional: () => optional,
17577
+ overwrite: () => _overwrite,
17578
+ parse: () => parse3,
17579
+ parseAsync: () => parseAsync2,
17580
+ partialRecord: () => partialRecord,
17581
+ pipe: () => pipe,
17582
+ positive: () => _positive,
17583
+ prefault: () => prefault,
17584
+ preprocess: () => preprocess,
17585
+ prettifyError: () => prettifyError,
17586
+ promise: () => promise,
17587
+ property: () => _property,
17588
+ readonly: () => readonly,
17589
+ record: () => record,
17590
+ refine: () => refine,
17591
+ regex: () => _regex,
17592
+ regexes: () => exports_regexes,
17593
+ registry: () => registry,
17594
+ safeDecode: () => safeDecode2,
17595
+ safeDecodeAsync: () => safeDecodeAsync2,
17596
+ safeEncode: () => safeEncode2,
17597
+ safeEncodeAsync: () => safeEncodeAsync2,
17598
+ safeParse: () => safeParse2,
17599
+ safeParseAsync: () => safeParseAsync2,
17600
+ set: () => set,
17601
+ setErrorMap: () => setErrorMap,
17602
+ size: () => _size,
17603
+ slugify: () => _slugify,
17604
+ startsWith: () => _startsWith,
17605
+ strictObject: () => strictObject,
17606
+ string: () => string2,
17607
+ stringFormat: () => stringFormat,
17608
+ stringbool: () => stringbool,
17609
+ success: () => success,
17610
+ superRefine: () => superRefine,
17611
+ symbol: () => symbol,
17612
+ templateLiteral: () => templateLiteral,
17613
+ toJSONSchema: () => toJSONSchema,
17614
+ toLowerCase: () => _toLowerCase,
17615
+ toUpperCase: () => _toUpperCase,
17616
+ transform: () => transform,
17617
+ treeifyError: () => treeifyError,
17618
+ trim: () => _trim,
17619
+ tuple: () => tuple,
17620
+ uint32: () => uint32,
17621
+ uint64: () => uint64,
17622
+ ulid: () => ulid2,
17623
+ undefined: () => _undefined3,
17624
+ union: () => union,
17625
+ unknown: () => unknown,
17626
+ uppercase: () => _uppercase,
17627
+ url: () => url,
17628
+ util: () => exports_util,
17629
+ uuid: () => uuid2,
17630
+ uuidv4: () => uuidv4,
17631
+ uuidv6: () => uuidv6,
17632
+ uuidv7: () => uuidv7,
17633
+ void: () => _void2,
17634
+ xid: () => xid2,
17635
+ xor: () => xor
18260
17636
  });
18261
17637
 
18262
17638
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/index.js
18263
17639
  var exports_core2 = {};
18264
17640
  __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,
17641
+ $ZodAny: () => $ZodAny,
18537
17642
  $ZodArray: () => $ZodArray,
18538
- $ZodAny: () => $ZodAny
17643
+ $ZodAsyncError: () => $ZodAsyncError,
17644
+ $ZodBase64: () => $ZodBase64,
17645
+ $ZodBase64URL: () => $ZodBase64URL,
17646
+ $ZodBigInt: () => $ZodBigInt,
17647
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
17648
+ $ZodBoolean: () => $ZodBoolean,
17649
+ $ZodCIDRv4: () => $ZodCIDRv4,
17650
+ $ZodCIDRv6: () => $ZodCIDRv6,
17651
+ $ZodCUID: () => $ZodCUID,
17652
+ $ZodCUID2: () => $ZodCUID2,
17653
+ $ZodCatch: () => $ZodCatch,
17654
+ $ZodCheck: () => $ZodCheck,
17655
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
17656
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
17657
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
17658
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
17659
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
17660
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
17661
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
17662
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
17663
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
17664
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
17665
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
17666
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
17667
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
17668
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
17669
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
17670
+ $ZodCheckProperty: () => $ZodCheckProperty,
17671
+ $ZodCheckRegex: () => $ZodCheckRegex,
17672
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
17673
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
17674
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
17675
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
17676
+ $ZodCodec: () => $ZodCodec,
17677
+ $ZodCustom: () => $ZodCustom,
17678
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
17679
+ $ZodDate: () => $ZodDate,
17680
+ $ZodDefault: () => $ZodDefault,
17681
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
17682
+ $ZodE164: () => $ZodE164,
17683
+ $ZodEmail: () => $ZodEmail,
17684
+ $ZodEmoji: () => $ZodEmoji,
17685
+ $ZodEncodeError: () => $ZodEncodeError,
17686
+ $ZodEnum: () => $ZodEnum,
17687
+ $ZodError: () => $ZodError,
17688
+ $ZodExactOptional: () => $ZodExactOptional,
17689
+ $ZodFile: () => $ZodFile,
17690
+ $ZodFunction: () => $ZodFunction,
17691
+ $ZodGUID: () => $ZodGUID,
17692
+ $ZodIPv4: () => $ZodIPv4,
17693
+ $ZodIPv6: () => $ZodIPv6,
17694
+ $ZodISODate: () => $ZodISODate,
17695
+ $ZodISODateTime: () => $ZodISODateTime,
17696
+ $ZodISODuration: () => $ZodISODuration,
17697
+ $ZodISOTime: () => $ZodISOTime,
17698
+ $ZodIntersection: () => $ZodIntersection,
17699
+ $ZodJWT: () => $ZodJWT,
17700
+ $ZodKSUID: () => $ZodKSUID,
17701
+ $ZodLazy: () => $ZodLazy,
17702
+ $ZodLiteral: () => $ZodLiteral,
17703
+ $ZodMAC: () => $ZodMAC,
17704
+ $ZodMap: () => $ZodMap,
17705
+ $ZodNaN: () => $ZodNaN,
17706
+ $ZodNanoID: () => $ZodNanoID,
17707
+ $ZodNever: () => $ZodNever,
17708
+ $ZodNonOptional: () => $ZodNonOptional,
17709
+ $ZodNull: () => $ZodNull,
17710
+ $ZodNullable: () => $ZodNullable,
17711
+ $ZodNumber: () => $ZodNumber,
17712
+ $ZodNumberFormat: () => $ZodNumberFormat,
17713
+ $ZodObject: () => $ZodObject,
17714
+ $ZodObjectJIT: () => $ZodObjectJIT,
17715
+ $ZodOptional: () => $ZodOptional,
17716
+ $ZodPipe: () => $ZodPipe,
17717
+ $ZodPrefault: () => $ZodPrefault,
17718
+ $ZodPreprocess: () => $ZodPreprocess,
17719
+ $ZodPromise: () => $ZodPromise,
17720
+ $ZodReadonly: () => $ZodReadonly,
17721
+ $ZodRealError: () => $ZodRealError,
17722
+ $ZodRecord: () => $ZodRecord,
17723
+ $ZodRegistry: () => $ZodRegistry,
17724
+ $ZodSet: () => $ZodSet,
17725
+ $ZodString: () => $ZodString,
17726
+ $ZodStringFormat: () => $ZodStringFormat,
17727
+ $ZodSuccess: () => $ZodSuccess,
17728
+ $ZodSymbol: () => $ZodSymbol,
17729
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
17730
+ $ZodTransform: () => $ZodTransform,
17731
+ $ZodTuple: () => $ZodTuple,
17732
+ $ZodType: () => $ZodType,
17733
+ $ZodULID: () => $ZodULID,
17734
+ $ZodURL: () => $ZodURL,
17735
+ $ZodUUID: () => $ZodUUID,
17736
+ $ZodUndefined: () => $ZodUndefined,
17737
+ $ZodUnion: () => $ZodUnion,
17738
+ $ZodUnknown: () => $ZodUnknown,
17739
+ $ZodVoid: () => $ZodVoid,
17740
+ $ZodXID: () => $ZodXID,
17741
+ $ZodXor: () => $ZodXor,
17742
+ $brand: () => $brand,
17743
+ $constructor: () => $constructor,
17744
+ $input: () => $input,
17745
+ $output: () => $output,
17746
+ Doc: () => Doc,
17747
+ JSONSchema: () => exports_json_schema,
17748
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
17749
+ NEVER: () => NEVER,
17750
+ TimePrecision: () => TimePrecision,
17751
+ _any: () => _any,
17752
+ _array: () => _array,
17753
+ _base64: () => _base64,
17754
+ _base64url: () => _base64url,
17755
+ _bigint: () => _bigint,
17756
+ _boolean: () => _boolean,
17757
+ _catch: () => _catch,
17758
+ _check: () => _check,
17759
+ _cidrv4: () => _cidrv4,
17760
+ _cidrv6: () => _cidrv6,
17761
+ _coercedBigint: () => _coercedBigint,
17762
+ _coercedBoolean: () => _coercedBoolean,
17763
+ _coercedDate: () => _coercedDate,
17764
+ _coercedNumber: () => _coercedNumber,
17765
+ _coercedString: () => _coercedString,
17766
+ _cuid: () => _cuid,
17767
+ _cuid2: () => _cuid2,
17768
+ _custom: () => _custom,
17769
+ _date: () => _date,
17770
+ _decode: () => _decode,
17771
+ _decodeAsync: () => _decodeAsync,
17772
+ _default: () => _default,
17773
+ _discriminatedUnion: () => _discriminatedUnion,
17774
+ _e164: () => _e164,
17775
+ _email: () => _email,
17776
+ _emoji: () => _emoji2,
17777
+ _encode: () => _encode,
17778
+ _encodeAsync: () => _encodeAsync,
17779
+ _endsWith: () => _endsWith,
17780
+ _enum: () => _enum,
17781
+ _file: () => _file,
17782
+ _float32: () => _float32,
17783
+ _float64: () => _float64,
17784
+ _gt: () => _gt,
17785
+ _gte: () => _gte,
17786
+ _guid: () => _guid,
17787
+ _includes: () => _includes,
17788
+ _int: () => _int,
17789
+ _int32: () => _int32,
17790
+ _int64: () => _int64,
17791
+ _intersection: () => _intersection,
17792
+ _ipv4: () => _ipv4,
17793
+ _ipv6: () => _ipv6,
17794
+ _isoDate: () => _isoDate,
17795
+ _isoDateTime: () => _isoDateTime,
17796
+ _isoDuration: () => _isoDuration,
17797
+ _isoTime: () => _isoTime,
17798
+ _jwt: () => _jwt,
17799
+ _ksuid: () => _ksuid,
17800
+ _lazy: () => _lazy,
17801
+ _length: () => _length,
17802
+ _literal: () => _literal,
17803
+ _lowercase: () => _lowercase,
17804
+ _lt: () => _lt,
17805
+ _lte: () => _lte,
17806
+ _mac: () => _mac,
17807
+ _map: () => _map,
17808
+ _max: () => _lte,
17809
+ _maxLength: () => _maxLength,
17810
+ _maxSize: () => _maxSize,
17811
+ _mime: () => _mime,
17812
+ _min: () => _gte,
17813
+ _minLength: () => _minLength,
17814
+ _minSize: () => _minSize,
17815
+ _multipleOf: () => _multipleOf,
17816
+ _nan: () => _nan,
17817
+ _nanoid: () => _nanoid,
17818
+ _nativeEnum: () => _nativeEnum,
17819
+ _negative: () => _negative,
17820
+ _never: () => _never,
17821
+ _nonnegative: () => _nonnegative,
17822
+ _nonoptional: () => _nonoptional,
17823
+ _nonpositive: () => _nonpositive,
17824
+ _normalize: () => _normalize,
17825
+ _null: () => _null2,
17826
+ _nullable: () => _nullable,
17827
+ _number: () => _number,
17828
+ _optional: () => _optional,
17829
+ _overwrite: () => _overwrite,
17830
+ _parse: () => _parse,
17831
+ _parseAsync: () => _parseAsync,
17832
+ _pipe: () => _pipe,
17833
+ _positive: () => _positive,
17834
+ _promise: () => _promise,
17835
+ _property: () => _property,
17836
+ _readonly: () => _readonly,
17837
+ _record: () => _record,
17838
+ _refine: () => _refine,
17839
+ _regex: () => _regex,
17840
+ _safeDecode: () => _safeDecode,
17841
+ _safeDecodeAsync: () => _safeDecodeAsync,
17842
+ _safeEncode: () => _safeEncode,
17843
+ _safeEncodeAsync: () => _safeEncodeAsync,
17844
+ _safeParse: () => _safeParse,
17845
+ _safeParseAsync: () => _safeParseAsync,
17846
+ _set: () => _set,
17847
+ _size: () => _size,
17848
+ _slugify: () => _slugify,
17849
+ _startsWith: () => _startsWith,
17850
+ _string: () => _string,
17851
+ _stringFormat: () => _stringFormat,
17852
+ _stringbool: () => _stringbool,
17853
+ _success: () => _success,
17854
+ _superRefine: () => _superRefine,
17855
+ _symbol: () => _symbol,
17856
+ _templateLiteral: () => _templateLiteral,
17857
+ _toLowerCase: () => _toLowerCase,
17858
+ _toUpperCase: () => _toUpperCase,
17859
+ _transform: () => _transform,
17860
+ _trim: () => _trim,
17861
+ _tuple: () => _tuple,
17862
+ _uint32: () => _uint32,
17863
+ _uint64: () => _uint64,
17864
+ _ulid: () => _ulid,
17865
+ _undefined: () => _undefined2,
17866
+ _union: () => _union,
17867
+ _unknown: () => _unknown,
17868
+ _uppercase: () => _uppercase,
17869
+ _url: () => _url,
17870
+ _uuid: () => _uuid,
17871
+ _uuidv4: () => _uuidv4,
17872
+ _uuidv6: () => _uuidv6,
17873
+ _uuidv7: () => _uuidv7,
17874
+ _void: () => _void,
17875
+ _xid: () => _xid,
17876
+ _xor: () => _xor,
17877
+ clone: () => clone,
17878
+ config: () => config,
17879
+ createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
17880
+ createToJSONSchemaMethod: () => createToJSONSchemaMethod,
17881
+ decode: () => decode,
17882
+ decodeAsync: () => decodeAsync,
17883
+ describe: () => describe,
17884
+ encode: () => encode,
17885
+ encodeAsync: () => encodeAsync,
17886
+ extractDefs: () => extractDefs,
17887
+ finalize: () => finalize,
17888
+ flattenError: () => flattenError,
17889
+ formatError: () => formatError,
17890
+ globalConfig: () => globalConfig,
17891
+ globalRegistry: () => globalRegistry,
17892
+ initializeContext: () => initializeContext,
17893
+ isValidBase64: () => isValidBase64,
17894
+ isValidBase64URL: () => isValidBase64URL,
17895
+ isValidJWT: () => isValidJWT,
17896
+ locales: () => exports_locales,
17897
+ meta: () => meta,
17898
+ parse: () => parse,
17899
+ parseAsync: () => parseAsync,
17900
+ prettifyError: () => prettifyError,
17901
+ process: () => process2,
17902
+ regexes: () => exports_regexes,
17903
+ registry: () => registry,
17904
+ safeDecode: () => safeDecode,
17905
+ safeDecodeAsync: () => safeDecodeAsync,
17906
+ safeEncode: () => safeEncode,
17907
+ safeEncodeAsync: () => safeEncodeAsync,
17908
+ safeParse: () => safeParse,
17909
+ safeParseAsync: () => safeParseAsync,
17910
+ toDotPath: () => toDotPath,
17911
+ toJSONSchema: () => toJSONSchema,
17912
+ treeifyError: () => treeifyError,
17913
+ util: () => exports_util,
17914
+ version: () => version
18539
17915
  });
18540
17916
 
18541
17917
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
@@ -18619,69 +17995,69 @@ function config(newConfig) {
18619
17995
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
18620
17996
  var exports_util = {};
18621
17997
  __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,
17998
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
18683
17999
  Class: () => Class,
18684
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
18000
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
18001
+ aborted: () => aborted,
18002
+ allowsEval: () => allowsEval,
18003
+ assert: () => assert,
18004
+ assertEqual: () => assertEqual,
18005
+ assertIs: () => assertIs,
18006
+ assertNever: () => assertNever,
18007
+ assertNotEqual: () => assertNotEqual,
18008
+ assignProp: () => assignProp,
18009
+ base64ToUint8Array: () => base64ToUint8Array,
18010
+ base64urlToUint8Array: () => base64urlToUint8Array,
18011
+ cached: () => cached,
18012
+ captureStackTrace: () => captureStackTrace,
18013
+ cleanEnum: () => cleanEnum,
18014
+ cleanRegex: () => cleanRegex,
18015
+ clone: () => clone,
18016
+ cloneDef: () => cloneDef,
18017
+ createTransparentProxy: () => createTransparentProxy,
18018
+ defineLazy: () => defineLazy,
18019
+ esc: () => esc,
18020
+ escapeRegex: () => escapeRegex,
18021
+ explicitlyAborted: () => explicitlyAborted,
18022
+ extend: () => extend,
18023
+ finalizeIssue: () => finalizeIssue,
18024
+ floatSafeRemainder: () => floatSafeRemainder,
18025
+ getElementAtPath: () => getElementAtPath,
18026
+ getEnumValues: () => getEnumValues,
18027
+ getLengthableOrigin: () => getLengthableOrigin,
18028
+ getParsedType: () => getParsedType,
18029
+ getSizableOrigin: () => getSizableOrigin,
18030
+ hexToUint8Array: () => hexToUint8Array,
18031
+ isObject: () => isObject,
18032
+ isPlainObject: () => isPlainObject,
18033
+ issue: () => issue,
18034
+ joinValues: () => joinValues,
18035
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
18036
+ merge: () => merge,
18037
+ mergeDefs: () => mergeDefs,
18038
+ normalizeParams: () => normalizeParams,
18039
+ nullish: () => nullish,
18040
+ numKeys: () => numKeys,
18041
+ objectClone: () => objectClone,
18042
+ omit: () => omit,
18043
+ optionalKeys: () => optionalKeys,
18044
+ parsedType: () => parsedType,
18045
+ partial: () => partial,
18046
+ pick: () => pick,
18047
+ prefixIssues: () => prefixIssues,
18048
+ primitiveTypes: () => primitiveTypes,
18049
+ promiseAllObject: () => promiseAllObject,
18050
+ propertyKeyTypes: () => propertyKeyTypes,
18051
+ randomString: () => randomString,
18052
+ required: () => required,
18053
+ safeExtend: () => safeExtend,
18054
+ shallowClone: () => shallowClone,
18055
+ slugify: () => slugify,
18056
+ stringifyPrimitive: () => stringifyPrimitive,
18057
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
18058
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
18059
+ uint8ArrayToHex: () => uint8ArrayToHex,
18060
+ unwrapMessage: () => unwrapMessage
18685
18061
  });
18686
18062
  function assertEqual(val) {
18687
18063
  return val;
@@ -19538,65 +18914,65 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
19538
18914
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/regexes.js
19539
18915
  var exports_regexes = {};
19540
18916
  __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,
18917
+ base64: () => base64,
19598
18918
  base64url: () => base64url,
19599
- base64: () => base64
18919
+ bigint: () => bigint,
18920
+ boolean: () => boolean,
18921
+ browserEmail: () => browserEmail,
18922
+ cidrv4: () => cidrv4,
18923
+ cidrv6: () => cidrv6,
18924
+ cuid: () => cuid,
18925
+ cuid2: () => cuid2,
18926
+ date: () => date,
18927
+ datetime: () => datetime,
18928
+ domain: () => domain,
18929
+ duration: () => duration,
18930
+ e164: () => e164,
18931
+ email: () => email,
18932
+ emoji: () => emoji,
18933
+ extendedDuration: () => extendedDuration,
18934
+ guid: () => guid,
18935
+ hex: () => hex,
18936
+ hostname: () => hostname2,
18937
+ html5Email: () => html5Email,
18938
+ httpProtocol: () => httpProtocol,
18939
+ idnEmail: () => idnEmail,
18940
+ integer: () => integer,
18941
+ ipv4: () => ipv4,
18942
+ ipv6: () => ipv6,
18943
+ ksuid: () => ksuid,
18944
+ lowercase: () => lowercase,
18945
+ mac: () => mac,
18946
+ md5_base64: () => md5_base64,
18947
+ md5_base64url: () => md5_base64url,
18948
+ md5_hex: () => md5_hex,
18949
+ nanoid: () => nanoid,
18950
+ null: () => _null,
18951
+ number: () => number,
18952
+ rfc5322Email: () => rfc5322Email,
18953
+ sha1_base64: () => sha1_base64,
18954
+ sha1_base64url: () => sha1_base64url,
18955
+ sha1_hex: () => sha1_hex,
18956
+ sha256_base64: () => sha256_base64,
18957
+ sha256_base64url: () => sha256_base64url,
18958
+ sha256_hex: () => sha256_hex,
18959
+ sha384_base64: () => sha384_base64,
18960
+ sha384_base64url: () => sha384_base64url,
18961
+ sha384_hex: () => sha384_hex,
18962
+ sha512_base64: () => sha512_base64,
18963
+ sha512_base64url: () => sha512_base64url,
18964
+ sha512_hex: () => sha512_hex,
18965
+ string: () => string,
18966
+ time: () => time,
18967
+ ulid: () => ulid,
18968
+ undefined: () => _undefined,
18969
+ unicodeEmail: () => unicodeEmail,
18970
+ uppercase: () => uppercase,
18971
+ uuid: () => uuid,
18972
+ uuid4: () => uuid4,
18973
+ uuid6: () => uuid6,
18974
+ uuid7: () => uuid7,
18975
+ xid: () => xid
19600
18976
  });
19601
18977
  var cuid = /^[cC][0-9a-z]{6,}$/;
19602
18978
  var cuid2 = /^[0-9a-z]+$/;
@@ -22373,58 +21749,58 @@ function handleRefineResult(result, payload, input, inst) {
22373
21749
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/index.js
22374
21750
  var exports_locales = {};
22375
21751
  __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,
21752
+ ar: () => ar_default,
22426
21753
  az: () => az_default,
22427
- ar: () => ar_default
21754
+ be: () => be_default,
21755
+ bg: () => bg_default,
21756
+ ca: () => ca_default,
21757
+ cs: () => cs_default,
21758
+ da: () => da_default,
21759
+ de: () => de_default,
21760
+ el: () => el_default,
21761
+ en: () => en_default,
21762
+ eo: () => eo_default,
21763
+ es: () => es_default,
21764
+ fa: () => fa_default,
21765
+ fi: () => fi_default,
21766
+ fr: () => fr_default,
21767
+ frCA: () => fr_CA_default,
21768
+ he: () => he_default,
21769
+ hr: () => hr_default,
21770
+ hu: () => hu_default,
21771
+ hy: () => hy_default,
21772
+ id: () => id_default,
21773
+ is: () => is_default,
21774
+ it: () => it_default,
21775
+ ja: () => ja_default,
21776
+ ka: () => ka_default,
21777
+ kh: () => kh_default,
21778
+ km: () => km_default,
21779
+ ko: () => ko_default,
21780
+ lt: () => lt_default,
21781
+ mk: () => mk_default,
21782
+ ms: () => ms_default,
21783
+ nl: () => nl_default,
21784
+ no: () => no_default,
21785
+ ota: () => ota_default,
21786
+ pl: () => pl_default,
21787
+ ps: () => ps_default,
21788
+ pt: () => pt_default,
21789
+ ro: () => ro_default,
21790
+ ru: () => ru_default,
21791
+ sl: () => sl_default,
21792
+ sv: () => sv_default,
21793
+ ta: () => ta_default,
21794
+ th: () => th_default,
21795
+ tr: () => tr_default,
21796
+ ua: () => ua_default,
21797
+ uk: () => uk_default,
21798
+ ur: () => ur_default,
21799
+ uz: () => uz_default,
21800
+ vi: () => vi_default,
21801
+ yo: () => yo_default,
21802
+ zhCN: () => zh_CN_default,
21803
+ zhTW: () => zh_TW_default
22428
21804
  });
22429
21805
 
22430
21806
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/ar.js
@@ -30195,219 +29571,219 @@ var exports_json_schema = {};
30195
29571
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
30196
29572
  var exports_schemas2 = {};
30197
29573
  __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,
29574
+ ZodAny: () => ZodAny,
30362
29575
  ZodArray: () => ZodArray,
30363
- ZodAny: () => ZodAny
29576
+ ZodBase64: () => ZodBase64,
29577
+ ZodBase64URL: () => ZodBase64URL,
29578
+ ZodBigInt: () => ZodBigInt,
29579
+ ZodBigIntFormat: () => ZodBigIntFormat,
29580
+ ZodBoolean: () => ZodBoolean,
29581
+ ZodCIDRv4: () => ZodCIDRv4,
29582
+ ZodCIDRv6: () => ZodCIDRv6,
29583
+ ZodCUID: () => ZodCUID,
29584
+ ZodCUID2: () => ZodCUID2,
29585
+ ZodCatch: () => ZodCatch,
29586
+ ZodCodec: () => ZodCodec,
29587
+ ZodCustom: () => ZodCustom,
29588
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
29589
+ ZodDate: () => ZodDate,
29590
+ ZodDefault: () => ZodDefault,
29591
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
29592
+ ZodE164: () => ZodE164,
29593
+ ZodEmail: () => ZodEmail,
29594
+ ZodEmoji: () => ZodEmoji,
29595
+ ZodEnum: () => ZodEnum,
29596
+ ZodExactOptional: () => ZodExactOptional,
29597
+ ZodFile: () => ZodFile,
29598
+ ZodFunction: () => ZodFunction,
29599
+ ZodGUID: () => ZodGUID,
29600
+ ZodIPv4: () => ZodIPv4,
29601
+ ZodIPv6: () => ZodIPv6,
29602
+ ZodIntersection: () => ZodIntersection,
29603
+ ZodJWT: () => ZodJWT,
29604
+ ZodKSUID: () => ZodKSUID,
29605
+ ZodLazy: () => ZodLazy,
29606
+ ZodLiteral: () => ZodLiteral,
29607
+ ZodMAC: () => ZodMAC,
29608
+ ZodMap: () => ZodMap,
29609
+ ZodNaN: () => ZodNaN,
29610
+ ZodNanoID: () => ZodNanoID,
29611
+ ZodNever: () => ZodNever,
29612
+ ZodNonOptional: () => ZodNonOptional,
29613
+ ZodNull: () => ZodNull,
29614
+ ZodNullable: () => ZodNullable,
29615
+ ZodNumber: () => ZodNumber,
29616
+ ZodNumberFormat: () => ZodNumberFormat,
29617
+ ZodObject: () => ZodObject,
29618
+ ZodOptional: () => ZodOptional,
29619
+ ZodPipe: () => ZodPipe,
29620
+ ZodPrefault: () => ZodPrefault,
29621
+ ZodPreprocess: () => ZodPreprocess,
29622
+ ZodPromise: () => ZodPromise,
29623
+ ZodReadonly: () => ZodReadonly,
29624
+ ZodRecord: () => ZodRecord,
29625
+ ZodSet: () => ZodSet,
29626
+ ZodString: () => ZodString,
29627
+ ZodStringFormat: () => ZodStringFormat,
29628
+ ZodSuccess: () => ZodSuccess,
29629
+ ZodSymbol: () => ZodSymbol,
29630
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
29631
+ ZodTransform: () => ZodTransform,
29632
+ ZodTuple: () => ZodTuple,
29633
+ ZodType: () => ZodType,
29634
+ ZodULID: () => ZodULID,
29635
+ ZodURL: () => ZodURL,
29636
+ ZodUUID: () => ZodUUID,
29637
+ ZodUndefined: () => ZodUndefined,
29638
+ ZodUnion: () => ZodUnion,
29639
+ ZodUnknown: () => ZodUnknown,
29640
+ ZodVoid: () => ZodVoid,
29641
+ ZodXID: () => ZodXID,
29642
+ ZodXor: () => ZodXor,
29643
+ _ZodString: () => _ZodString,
29644
+ _default: () => _default2,
29645
+ _function: () => _function,
29646
+ any: () => any,
29647
+ array: () => array,
29648
+ base64: () => base642,
29649
+ base64url: () => base64url2,
29650
+ bigint: () => bigint2,
29651
+ boolean: () => boolean2,
29652
+ catch: () => _catch2,
29653
+ check: () => check,
29654
+ cidrv4: () => cidrv42,
29655
+ cidrv6: () => cidrv62,
29656
+ codec: () => codec,
29657
+ cuid: () => cuid3,
29658
+ cuid2: () => cuid22,
29659
+ custom: () => custom,
29660
+ date: () => date3,
29661
+ describe: () => describe2,
29662
+ discriminatedUnion: () => discriminatedUnion,
29663
+ e164: () => e1642,
29664
+ email: () => email2,
29665
+ emoji: () => emoji2,
29666
+ enum: () => _enum2,
29667
+ exactOptional: () => exactOptional,
29668
+ file: () => file,
29669
+ float32: () => float32,
29670
+ float64: () => float64,
29671
+ function: () => _function,
29672
+ guid: () => guid2,
29673
+ hash: () => hash,
29674
+ hex: () => hex2,
29675
+ hostname: () => hostname3,
29676
+ httpUrl: () => httpUrl,
29677
+ instanceof: () => _instanceof,
29678
+ int: () => int,
29679
+ int32: () => int32,
29680
+ int64: () => int64,
29681
+ intersection: () => intersection,
29682
+ invertCodec: () => invertCodec,
29683
+ ipv4: () => ipv42,
29684
+ ipv6: () => ipv62,
29685
+ json: () => json,
29686
+ jwt: () => jwt,
29687
+ keyof: () => keyof,
29688
+ ksuid: () => ksuid2,
29689
+ lazy: () => lazy,
29690
+ literal: () => literal,
29691
+ looseObject: () => looseObject,
29692
+ looseRecord: () => looseRecord,
29693
+ mac: () => mac2,
29694
+ map: () => map,
29695
+ meta: () => meta2,
29696
+ nan: () => nan,
29697
+ nanoid: () => nanoid2,
29698
+ nativeEnum: () => nativeEnum,
29699
+ never: () => never,
29700
+ nonoptional: () => nonoptional,
29701
+ null: () => _null3,
29702
+ nullable: () => nullable,
29703
+ nullish: () => nullish2,
29704
+ number: () => number2,
29705
+ object: () => object,
29706
+ optional: () => optional,
29707
+ partialRecord: () => partialRecord,
29708
+ pipe: () => pipe,
29709
+ prefault: () => prefault,
29710
+ preprocess: () => preprocess,
29711
+ promise: () => promise,
29712
+ readonly: () => readonly,
29713
+ record: () => record,
29714
+ refine: () => refine,
29715
+ set: () => set,
29716
+ strictObject: () => strictObject,
29717
+ string: () => string2,
29718
+ stringFormat: () => stringFormat,
29719
+ stringbool: () => stringbool,
29720
+ success: () => success,
29721
+ superRefine: () => superRefine,
29722
+ symbol: () => symbol,
29723
+ templateLiteral: () => templateLiteral,
29724
+ transform: () => transform,
29725
+ tuple: () => tuple,
29726
+ uint32: () => uint32,
29727
+ uint64: () => uint64,
29728
+ ulid: () => ulid2,
29729
+ undefined: () => _undefined3,
29730
+ union: () => union,
29731
+ unknown: () => unknown,
29732
+ url: () => url,
29733
+ uuid: () => uuid2,
29734
+ uuidv4: () => uuidv4,
29735
+ uuidv6: () => uuidv6,
29736
+ uuidv7: () => uuidv7,
29737
+ void: () => _void2,
29738
+ xid: () => xid2,
29739
+ xor: () => xor
30364
29740
  });
30365
29741
 
30366
29742
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/checks.js
30367
29743
  var exports_checks2 = {};
30368
29744
  __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,
29745
+ endsWith: () => _endsWith,
30396
29746
  gt: () => _gt,
30397
- endsWith: () => _endsWith
29747
+ gte: () => _gte,
29748
+ includes: () => _includes,
29749
+ length: () => _length,
29750
+ lowercase: () => _lowercase,
29751
+ lt: () => _lt,
29752
+ lte: () => _lte,
29753
+ maxLength: () => _maxLength,
29754
+ maxSize: () => _maxSize,
29755
+ mime: () => _mime,
29756
+ minLength: () => _minLength,
29757
+ minSize: () => _minSize,
29758
+ multipleOf: () => _multipleOf,
29759
+ negative: () => _negative,
29760
+ nonnegative: () => _nonnegative,
29761
+ nonpositive: () => _nonpositive,
29762
+ normalize: () => _normalize,
29763
+ overwrite: () => _overwrite,
29764
+ positive: () => _positive,
29765
+ property: () => _property,
29766
+ regex: () => _regex,
29767
+ size: () => _size,
29768
+ slugify: () => _slugify,
29769
+ startsWith: () => _startsWith,
29770
+ toLowerCase: () => _toLowerCase,
29771
+ toUpperCase: () => _toUpperCase,
29772
+ trim: () => _trim,
29773
+ uppercase: () => _uppercase
30398
29774
  });
30399
29775
 
30400
29776
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
30401
29777
  var exports_iso = {};
30402
29778
  __export(exports_iso, {
30403
- time: () => time2,
30404
- duration: () => duration2,
30405
- datetime: () => datetime2,
30406
- date: () => date2,
30407
- ZodISOTime: () => ZodISOTime,
30408
- ZodISODuration: () => ZodISODuration,
29779
+ ZodISODate: () => ZodISODate,
30409
29780
  ZodISODateTime: () => ZodISODateTime,
30410
- ZodISODate: () => ZodISODate
29781
+ ZodISODuration: () => ZodISODuration,
29782
+ ZodISOTime: () => ZodISOTime,
29783
+ date: () => date2,
29784
+ datetime: () => datetime2,
29785
+ duration: () => duration2,
29786
+ time: () => time2
30411
29787
  });
30412
29788
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
30413
29789
  $ZodISODateTime.init(inst, def);
@@ -32268,11 +31644,11 @@ function fromJSONSchema(schema, params) {
32268
31644
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/coerce.js
32269
31645
  var exports_coerce = {};
32270
31646
  __export(exports_coerce, {
32271
- string: () => string3,
32272
- number: () => number3,
32273
- date: () => date4,
31647
+ bigint: () => bigint3,
32274
31648
  boolean: () => boolean3,
32275
- bigint: () => bigint3
31649
+ date: () => date4,
31650
+ number: () => number3,
31651
+ string: () => string3
32276
31652
  });
32277
31653
  function string3(params) {
32278
31654
  return _coercedString(ZodString, params);
@@ -32383,6 +31759,9 @@ var SubcConfigSchema = exports_external.object({
32383
31759
  connection_file: exports_external.string().optional(),
32384
31760
  client_reaper: exports_external.boolean().optional()
32385
31761
  });
31762
+ var GhShimConfigSchema = exports_external.object({
31763
+ enabled: exports_external.boolean().optional()
31764
+ });
32386
31765
  var DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 120000;
32387
31766
  var MIN_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 1e4;
32388
31767
  var MAX_INSPECT_DIAGNOSTICS_TIMEOUT_MS = 600000;
@@ -32437,7 +31816,8 @@ var AftConfigSchema = exports_external.preprocess((value) => stripHarnessSpecifi
32437
31816
  semantic: SemanticConfigSchema.optional(),
32438
31817
  auto_update: exports_external.boolean().optional(),
32439
31818
  bridge: BridgeConfigSchema.optional(),
32440
- subc: SubcConfigSchema.optional()
31819
+ subc: SubcConfigSchema.optional(),
31820
+ gh_shim: GhShimConfigSchema.optional()
32441
31821
  }).strict());
32442
31822
  function resolveInspectDiagnosticsTimeoutMs(config2) {
32443
31823
  return clampInspectDiagnosticsTimeoutMs(config2.inspect?.diagnostics_timeout_ms ?? DEFAULT_INSPECT_DIAGNOSTICS_TIMEOUT_MS);
@@ -32890,6 +32270,8 @@ function getStrippedTopLevelKeys(override) {
32890
32270
  stripped.push("sandbox.write_allow");
32891
32271
  if (override.subc !== undefined)
32892
32272
  stripped.push("subc");
32273
+ if (override.gh_shim !== undefined)
32274
+ stripped.push("gh_shim");
32893
32275
  if (override.disabled_tools?.includes("aft_safety"))
32894
32276
  stripped.push("disabled_tools.aft_safety");
32895
32277
  return stripped;
@@ -37594,6 +36976,7 @@ function createBashTool(ctx, aftSearchRegisteredOverride) {
37594
36976
  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
36977
  ...ptyArgs
37596
36978
  };
36979
+ let hostFallbackActive = false;
37597
36980
  return {
37598
36981
  description: bashToolDescription(false, initialBashCfg.compress, initialBashCfg.background),
37599
36982
  args,
@@ -37690,12 +37073,15 @@ function createBashTool(ctx, aftSearchRegisteredOverride) {
37690
37073
  env: shellEnv?.env
37691
37074
  });
37692
37075
  usedHostFallback = true;
37076
+ hostFallbackActive = true;
37693
37077
  } finally {
37694
37078
  removeAbortListener();
37695
37079
  }
37696
37080
  if (data.success === false) {
37697
37081
  throw new Error(data.message || "bash failed");
37698
37082
  }
37083
+ if (!usedHostFallback && hostFallbackActive)
37084
+ hostFallbackActive = false;
37699
37085
  const uiTitle = description ?? shortenCommand(command);
37700
37086
  if (data.status === "running" && typeof data.task_id === "string") {
37701
37087
  const taskId = data.task_id;
@@ -38593,9 +37979,19 @@ ${backupBehavior}
38593
37979
  - Symbol replace includes decorators, attributes, and doc comments in range
38594
37980
  - Response is a compact server-rendered summary; before/after diff details are attached as UI metadata when available.`;
38595
37981
  }
37982
+ var HASHLINE_EDIT_DESCRIPTION = [
37983
+ "Apply a hashline patch. Arguments are exactly `{patch}` where `patch` is a non-empty string. Server-owned preview control is outside this schema.",
37984
+ "",
37985
+ "Quick reference:",
37986
+ "- 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.",
37987
+ "- 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.",
37988
+ "- 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 `-`.",
37989
+ "- 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."
37990
+ ].join(`
37991
+ `);
38596
37992
  function createHashlineEditTool(ctx) {
38597
37993
  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.",
37994
+ description: HASHLINE_EDIT_DESCRIPTION,
38599
37995
  args: {
38600
37996
  patch: z8.string().min(1).describe("Hashline patch text with one or more [path#TAG] sections and PUT/CUT/REM/MV operations")
38601
37997
  },
@@ -40262,7 +39658,7 @@ var PLUGIN_VERSION = (() => {
40262
39658
  return "0.0.0";
40263
39659
  }
40264
39660
  })();
40265
- var ANNOUNCEMENT_VERSION = "0.51.3";
39661
+ var ANNOUNCEMENT_VERSION = "0.52.0";
40266
39662
  var ANNOUNCEMENT_FEATURES = [
40267
39663
  "Callgraph stays consistent under load: edits arriving mid-rebuild can no longer be silently lost from navigation results.",
40268
39664
  "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 +39687,16 @@ async function initializePluginForDirectory(input) {
40291
39687
  log2(`AFT disabled by config for ${registrationRoot}`);
40292
39688
  return { tool: {} };
40293
39689
  }
40294
- const binaryPath = await findBinary(PLUGIN_VERSION);
39690
+ const cachedBinaryPath = findBinarySync(PLUGIN_VERSION);
39691
+ if (!cachedBinaryPath) {
39692
+ ensureBinary(PLUGIN_VERSION).then((path7) => {
39693
+ if (path7)
39694
+ log2(`Background binary warmup ready at ${path7}`);
39695
+ }, (err) => {
39696
+ warn2(`Background binary warmup failed: ${err instanceof Error ? err.message : String(err)}`);
39697
+ });
39698
+ }
39699
+ const binaryPath = cachedBinaryPath ?? await findBinary(PLUGIN_VERSION);
40295
39700
  await ensureStorageMigrated({ harness: "opencode", binaryPath, logger: bridgeLogger });
40296
39701
  const autoUpdateAbort = new AbortController;
40297
39702
  const projectEnabledCache = new Map([[registrationRoot, true]]);