agent-shim 8.31.0 → 8.33.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/cli.cjs CHANGED
@@ -13,9 +13,9 @@ var __commonJS = (cb, mod) => function __require() {
13
13
  throw mod = 0, e;
14
14
  }
15
15
  };
16
- var __export = (target, all2) => {
17
- for (var name in all2)
18
- __defProp(target, name, { get: all2[name], enumerable: true });
16
+ var __export = (target, all3) => {
17
+ for (var name in all3)
18
+ __defProp(target, name, { get: all3[name], enumerable: true });
19
19
  };
20
20
  var __copyProps = (to, from, except, desc) => {
21
21
  if (from && typeof from === "object" || typeof from === "function") {
@@ -5369,17 +5369,17 @@ var require_parse = __commonJS({
5369
5369
  let output2 = ")";
5370
5370
  if (brace.dots === true) {
5371
5371
  const arr = tokens.slice();
5372
- const range = [];
5372
+ const range2 = [];
5373
5373
  for (let i2 = arr.length - 1; i2 >= 0; i2--) {
5374
5374
  tokens.pop();
5375
5375
  if (arr[i2].type === "brace") {
5376
5376
  break;
5377
5377
  }
5378
5378
  if (arr[i2].type !== "dots") {
5379
- range.unshift(arr[i2].value);
5379
+ range2.unshift(arr[i2].value);
5380
5380
  }
5381
5381
  }
5382
- output2 = expandRange(range, opts);
5382
+ output2 = expandRange(range2, opts);
5383
5383
  state.backtrack = true;
5384
5384
  }
5385
5385
  if (brace.comma !== true && brace.dots !== true) {
@@ -5747,9 +5747,9 @@ var require_picomatch = __commonJS({
5747
5747
  var utils = require_utils();
5748
5748
  var constants = require_constants();
5749
5749
  var isObject5 = (val) => val && typeof val === "object" && !Array.isArray(val);
5750
- var picomatch4 = (glob, options, returnState = false) => {
5750
+ var picomatch3 = (glob, options, returnState = false) => {
5751
5751
  if (Array.isArray(glob)) {
5752
- const fns = glob.map((input2) => picomatch4(input2, options, returnState));
5752
+ const fns = glob.map((input2) => picomatch3(input2, options, returnState));
5753
5753
  const arrayMatcher = (str) => {
5754
5754
  for (const isMatch of fns) {
5755
5755
  const state2 = isMatch(str);
@@ -5765,16 +5765,16 @@ var require_picomatch = __commonJS({
5765
5765
  }
5766
5766
  const opts = options || {};
5767
5767
  const posix = opts.windows;
5768
- const regex = isState ? picomatch4.compileRe(glob, options) : picomatch4.makeRe(glob, options, false, true);
5768
+ const regex = isState ? picomatch3.compileRe(glob, options) : picomatch3.makeRe(glob, options, false, true);
5769
5769
  const state = regex.state;
5770
5770
  delete regex.state;
5771
5771
  let isIgnored = () => false;
5772
5772
  if (opts.ignore) {
5773
5773
  const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
5774
- isIgnored = picomatch4(opts.ignore, ignoreOpts, returnState);
5774
+ isIgnored = picomatch3(opts.ignore, ignoreOpts, returnState);
5775
5775
  }
5776
5776
  const matcher = (input2, returnObject = false) => {
5777
- const { isMatch, match, output: output2 } = picomatch4.test(input2, regex, options, { glob, posix });
5777
+ const { isMatch, match, output: output2 } = picomatch3.test(input2, regex, options, { glob, posix });
5778
5778
  const result = { glob, state, regex, posix, input: input2, output: output2, match, isMatch };
5779
5779
  if (typeof opts.onResult === "function") {
5780
5780
  opts.onResult(result);
@@ -5800,7 +5800,7 @@ var require_picomatch = __commonJS({
5800
5800
  }
5801
5801
  return matcher;
5802
5802
  };
5803
- picomatch4.test = (input2, regex, options, { glob, posix } = {}) => {
5803
+ picomatch3.test = (input2, regex, options, { glob, posix } = {}) => {
5804
5804
  if (typeof input2 !== "string") {
5805
5805
  throw new TypeError("Expected input to be a string");
5806
5806
  }
@@ -5817,24 +5817,24 @@ var require_picomatch = __commonJS({
5817
5817
  }
5818
5818
  if (match === false || opts.capture === true) {
5819
5819
  if (opts.matchBase === true || opts.basename === true) {
5820
- match = picomatch4.matchBase(input2, regex, options, posix);
5820
+ match = picomatch3.matchBase(input2, regex, options, posix);
5821
5821
  } else {
5822
5822
  match = regex.exec(output2);
5823
5823
  }
5824
5824
  }
5825
5825
  return { isMatch: Boolean(match), match, output: output2 };
5826
5826
  };
5827
- picomatch4.matchBase = (input2, glob, options, posix = options && options.windows) => {
5828
- const regex = glob instanceof RegExp ? glob : picomatch4.makeRe(glob, options);
5827
+ picomatch3.matchBase = (input2, glob, options, posix = options && options.windows) => {
5828
+ const regex = glob instanceof RegExp ? glob : picomatch3.makeRe(glob, options);
5829
5829
  return regex.test(utils.basename(input2, { windows: posix }));
5830
5830
  };
5831
- picomatch4.isMatch = (str, patterns, options) => picomatch4(patterns, options)(str);
5832
- picomatch4.parse = (pattern, options) => {
5833
- if (Array.isArray(pattern)) return pattern.map((p) => picomatch4.parse(p, options));
5831
+ picomatch3.isMatch = (str, patterns, options) => picomatch3(patterns, options)(str);
5832
+ picomatch3.parse = (pattern, options) => {
5833
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch3.parse(p, options));
5834
5834
  return parse3(pattern, { ...options, fastpaths: false });
5835
5835
  };
5836
- picomatch4.scan = (input2, options) => scan(input2, options);
5837
- picomatch4.compileRe = (state, options, returnOutput = false, returnState = false) => {
5836
+ picomatch3.scan = (input2, options) => scan(input2, options);
5837
+ picomatch3.compileRe = (state, options, returnOutput = false, returnState = false) => {
5838
5838
  if (returnOutput === true) {
5839
5839
  return state.output;
5840
5840
  }
@@ -5845,13 +5845,13 @@ var require_picomatch = __commonJS({
5845
5845
  if (state && state.negated === true) {
5846
5846
  source = `^(?!${source}).*$`;
5847
5847
  }
5848
- const regex = picomatch4.toRegex(source, options);
5848
+ const regex = picomatch3.toRegex(source, options);
5849
5849
  if (returnState === true) {
5850
5850
  regex.state = state;
5851
5851
  }
5852
5852
  return regex;
5853
5853
  };
5854
- picomatch4.makeRe = (input2, options = {}, returnOutput = false, returnState = false) => {
5854
+ picomatch3.makeRe = (input2, options = {}, returnOutput = false, returnState = false) => {
5855
5855
  if (!input2 || typeof input2 !== "string") {
5856
5856
  throw new TypeError("Expected a non-empty string");
5857
5857
  }
@@ -5862,9 +5862,9 @@ var require_picomatch = __commonJS({
5862
5862
  if (!parsed.output) {
5863
5863
  parsed = parse3(input2, options);
5864
5864
  }
5865
- return picomatch4.compileRe(parsed, options, returnOutput, returnState);
5865
+ return picomatch3.compileRe(parsed, options, returnOutput, returnState);
5866
5866
  };
5867
- picomatch4.toRegex = (source, options) => {
5867
+ picomatch3.toRegex = (source, options) => {
5868
5868
  try {
5869
5869
  const opts = options || {};
5870
5870
  return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
@@ -5873,8 +5873,8 @@ var require_picomatch = __commonJS({
5873
5873
  return /$^/;
5874
5874
  }
5875
5875
  };
5876
- picomatch4.constants = constants;
5877
- module2.exports = picomatch4;
5876
+ picomatch3.constants = constants;
5877
+ module2.exports = picomatch3;
5878
5878
  }
5879
5879
  });
5880
5880
 
@@ -5884,14 +5884,14 @@ var require_picomatch2 = __commonJS({
5884
5884
  "use strict";
5885
5885
  var pico = require_picomatch();
5886
5886
  var utils = require_utils();
5887
- function picomatch4(glob, options, returnState = false) {
5887
+ function picomatch3(glob, options, returnState = false) {
5888
5888
  if (options && (options.windows === null || options.windows === void 0)) {
5889
5889
  options = { ...options, windows: utils.isWindows() };
5890
5890
  }
5891
5891
  return pico(glob, options, returnState);
5892
5892
  }
5893
- Object.assign(picomatch4, pico);
5894
- module2.exports = picomatch4;
5893
+ Object.assign(picomatch3, pico);
5894
+ module2.exports = picomatch3;
5895
5895
  }
5896
5896
  });
5897
5897
 
@@ -7542,9 +7542,9 @@ var require_util2 = __commonJS({
7542
7542
  return !headerCharRegex.test(characters);
7543
7543
  }
7544
7544
  var rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+)?$/;
7545
- function parseRangeHeader(range) {
7546
- if (range == null || range === "") return { start: 0, end: null, size: null };
7547
- const m2 = range ? range.match(rangeHeaderRegex) : null;
7545
+ function parseRangeHeader(range2) {
7546
+ if (range2 == null || range2 === "") return { start: 0, end: null, size: null };
7547
+ const m2 = range2 ? range2.match(rangeHeaderRegex) : null;
7548
7548
  return m2 ? {
7549
7549
  start: parseInt(m2[1]),
7550
7550
  end: m2[2] ? parseInt(m2[2]) : null,
@@ -12608,7 +12608,7 @@ var require_client_h1 = __commonJS({
12608
12608
  var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER;
12609
12609
  var TIMEOUT_BODY = 4 | USE_FAST_TIMER;
12610
12610
  var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER;
12611
- var Parser = class {
12611
+ var Parser2 = class {
12612
12612
  /**
12613
12613
  * @param {import('./client.js')} client
12614
12614
  * @param {import('net').Socket} socket
@@ -13088,7 +13088,7 @@ var require_client_h1 = __commonJS({
13088
13088
  socket[kIdleSocketValidation] = 0;
13089
13089
  socket[kIdleSocketValidationTimeout] = null;
13090
13090
  socket[kSocketUsed] = false;
13091
- socket[kParser] = new Parser(client, socket, llhttpInstance);
13091
+ socket[kParser] = new Parser2(client, socket, llhttpInstance);
13092
13092
  util.addListener(socket, "error", onHttpSocketError);
13093
13093
  util.addListener(socket, "readable", onHttpSocketReadable);
13094
13094
  util.addListener(socket, "end", onHttpSocketEnd);
@@ -16832,16 +16832,16 @@ var require_retry_handler = __commonJS({
16832
16832
  const retryTime = new Date(retryAfter).getTime();
16833
16833
  return isNaN(retryTime) ? 0 : retryTime - Date.now();
16834
16834
  }
16835
- function validatePartialResponseContentLength(headers, range, statusCode, retryCount) {
16835
+ function validatePartialResponseContentLength(headers, range2, statusCode, retryCount) {
16836
16836
  const contentLength = headers["content-length"];
16837
16837
  if (contentLength == null) {
16838
16838
  return;
16839
16839
  }
16840
- if (!Number.isFinite(range.start) || !Number.isFinite(range.end)) {
16840
+ if (!Number.isFinite(range2.start) || !Number.isFinite(range2.end)) {
16841
16841
  return;
16842
16842
  }
16843
16843
  const length = Number(contentLength);
16844
- const expectedLength = range.end - range.start + 1;
16844
+ const expectedLength = range2.end - range2.start + 1;
16845
16845
  if (!Number.isFinite(length) || length !== expectedLength) {
16846
16846
  throw new RequestRetryError("Content-Length mismatch", statusCode, {
16847
16847
  headers,
@@ -17051,8 +17051,8 @@ var require_retry_handler = __commonJS({
17051
17051
  }
17052
17052
  if (this.end == null) {
17053
17053
  if (statusCode === 206) {
17054
- const range = parseRangeHeader(headers["content-range"]);
17055
- if (range == null) {
17054
+ const range2 = parseRangeHeader(headers["content-range"]);
17055
+ if (range2 == null) {
17056
17056
  this.headersSent = true;
17057
17057
  this.handler.onResponseStart?.(
17058
17058
  controller,
@@ -17062,8 +17062,8 @@ var require_retry_handler = __commonJS({
17062
17062
  );
17063
17063
  return;
17064
17064
  }
17065
- validatePartialResponseContentLength(headers, range, statusCode, this.retryCount);
17066
- const { start, size, end = size ? size - 1 : null } = range;
17065
+ validatePartialResponseContentLength(headers, range2, statusCode, this.retryCount);
17066
+ const { start, size, end = size ? size - 1 : null } = range2;
17067
17067
  assert2(
17068
17068
  start != null && Number.isFinite(start),
17069
17069
  "content-range mismatch"
@@ -35899,8 +35899,8 @@ function cleanRegex(source) {
35899
35899
  const end = source.endsWith("$") ? source.length - 1 : source.length;
35900
35900
  return source.slice(start, end);
35901
35901
  }
35902
- function floatSafeRemainder(val, step) {
35903
- const ratio = val / step;
35902
+ function floatSafeRemainder(val, step2) {
35903
+ const ratio = val / step2;
35904
35904
  const roundedRatio = Math.round(ratio);
35905
35905
  const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
35906
35906
  if (Math.abs(ratio - roundedRatio) < tolerance)
@@ -55148,6 +55148,1839 @@ var import_node_path5 = __toESM(require("node:path"), 1);
55148
55148
 
55149
55149
  // src/config/schema.ts
55150
55150
  var import_node_path4 = __toESM(require("node:path"), 1);
55151
+
55152
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/complex.js
55153
+ var complexFromPolar = (magnitude, phase, unit) => ({
55154
+ kind: "complex",
55155
+ re: magnitude * Math.cos(phase),
55156
+ im: magnitude * Math.sin(phase),
55157
+ unit
55158
+ });
55159
+
55160
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/computed-value.js
55161
+ var UnitSchema = external_exports.record(external_exports.string(), external_exports.number());
55162
+ var DurationUnitSchema = external_exports.enum([
55163
+ "ms",
55164
+ "s",
55165
+ "min",
55166
+ "h",
55167
+ "d"
55168
+ ]);
55169
+ var ComputedValueSchema = external_exports.discriminatedUnion("kind", [
55170
+ external_exports.object({
55171
+ kind: external_exports.literal("number"),
55172
+ value: external_exports.number(),
55173
+ unit: UnitSchema.optional()
55174
+ }),
55175
+ external_exports.object({
55176
+ kind: external_exports.literal("text"),
55177
+ value: external_exports.string()
55178
+ }),
55179
+ external_exports.object({
55180
+ kind: external_exports.literal("boolean"),
55181
+ value: external_exports.boolean()
55182
+ }),
55183
+ external_exports.object({
55184
+ kind: external_exports.literal("instant"),
55185
+ value: external_exports.string()
55186
+ }),
55187
+ external_exports.object({
55188
+ kind: external_exports.literal("duration"),
55189
+ value: external_exports.number(),
55190
+ unit: DurationUnitSchema
55191
+ }),
55192
+ external_exports.object({
55193
+ kind: external_exports.literal("complex"),
55194
+ re: external_exports.number(),
55195
+ im: external_exports.number(),
55196
+ unit: UnitSchema.optional()
55197
+ })
55198
+ ]);
55199
+ function normalizeUnit(unit) {
55200
+ if (unit === void 0) return {};
55201
+ const normalized = {};
55202
+ for (const [dimension, exponent] of Object.entries(unit)) if (exponent !== 0) normalized[dimension] = exponent;
55203
+ return normalized;
55204
+ }
55205
+ function unitsEqual(a2, b) {
55206
+ const normalizedA = normalizeUnit(a2);
55207
+ const normalizedB = normalizeUnit(b);
55208
+ const dimensionsA = Object.keys(normalizedA);
55209
+ const dimensionsB = Object.keys(normalizedB);
55210
+ if (dimensionsA.length !== dimensionsB.length) return false;
55211
+ return dimensionsA.every((dimension) => normalizedA[dimension] === normalizedB[dimension]);
55212
+ }
55213
+ function combineUnitsForMultiply(a2, b) {
55214
+ const normalizedA = normalizeUnit(a2);
55215
+ const normalizedB = normalizeUnit(b);
55216
+ const combined = { ...normalizedA };
55217
+ for (const [dimension, exponent] of Object.entries(normalizedB)) combined[dimension] = (combined[dimension] ?? 0) + exponent;
55218
+ return normalizeUnit(combined);
55219
+ }
55220
+ function combineUnitsForDivide(a2, b) {
55221
+ const normalizedA = normalizeUnit(a2);
55222
+ const normalizedB = normalizeUnit(b);
55223
+ const combined = { ...normalizedA };
55224
+ for (const [dimension, exponent] of Object.entries(normalizedB)) combined[dimension] = (combined[dimension] ?? 0) - exponent;
55225
+ return normalizeUnit(combined);
55226
+ }
55227
+
55228
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluation.js
55229
+ var IndeterminateReasonSchema = external_exports.object({
55230
+ /** Which of the three reason categories applies. */
55231
+ code: external_exports.enum([
55232
+ "not-found",
55233
+ "wrong-type",
55234
+ "domain-error"
55235
+ ]),
55236
+ /** A human-readable explanation, for logging and debugging. */
55237
+ message: external_exports.string()
55238
+ });
55239
+ function definite(value2) {
55240
+ return {
55241
+ status: "definite",
55242
+ value: value2
55243
+ };
55244
+ }
55245
+ function indeterminate(code, message) {
55246
+ return {
55247
+ status: "indeterminate",
55248
+ reason: {
55249
+ code,
55250
+ message
55251
+ }
55252
+ };
55253
+ }
55254
+ function firstIndeterminate(...results) {
55255
+ for (const result of results) if (result?.status === "indeterminate") return result.reason;
55256
+ }
55257
+
55258
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/json-value.js
55259
+ var JsonValueSchema = external_exports.lazy(() => external_exports.union([
55260
+ external_exports.string(),
55261
+ external_exports.number(),
55262
+ external_exports.boolean(),
55263
+ external_exports.null(),
55264
+ external_exports.array(JsonValueSchema),
55265
+ external_exports.record(external_exports.string(), JsonValueSchema)
55266
+ ]));
55267
+
55268
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/tree.js
55269
+ var ComparisonOperatorSchema = external_exports.enum([
55270
+ "gt",
55271
+ "gte",
55272
+ "lt",
55273
+ "lte",
55274
+ "eq",
55275
+ "neq"
55276
+ ]);
55277
+ var TextComparisonOperatorSchema = external_exports.enum([
55278
+ "equals",
55279
+ "notEquals",
55280
+ "matches",
55281
+ "notMatches",
55282
+ "portableMatches",
55283
+ "portableNotMatches"
55284
+ ]);
55285
+ var MembershipOperatorSchema = external_exports.enum(["in", "notIn"]);
55286
+ var ArithmeticOperatorSchema = external_exports.enum([
55287
+ "add",
55288
+ "subtract",
55289
+ "multiply",
55290
+ "divide",
55291
+ "power",
55292
+ "modulo"
55293
+ ]);
55294
+ var HitPolicySchema = external_exports.enum(["first", "unique"]);
55295
+ var NotNodeSchema = external_exports.object({
55296
+ kind: external_exports.literal("not"),
55297
+ get operand() {
55298
+ return PredicateNodeSchema;
55299
+ }
55300
+ });
55301
+ var AndNodeSchema = external_exports.object({
55302
+ kind: external_exports.literal("and"),
55303
+ get left() {
55304
+ return PredicateNodeSchema;
55305
+ },
55306
+ get right() {
55307
+ return PredicateNodeSchema;
55308
+ }
55309
+ });
55310
+ var OrNodeSchema = external_exports.object({
55311
+ kind: external_exports.literal("or"),
55312
+ get left() {
55313
+ return PredicateNodeSchema;
55314
+ },
55315
+ get right() {
55316
+ return PredicateNodeSchema;
55317
+ }
55318
+ });
55319
+ var AllOfNodeSchema = external_exports.object({
55320
+ kind: external_exports.literal("allOf"),
55321
+ get operands() {
55322
+ return external_exports.array(PredicateNodeSchema);
55323
+ }
55324
+ });
55325
+ var AnyOfNodeSchema = external_exports.object({
55326
+ kind: external_exports.literal("anyOf"),
55327
+ get operands() {
55328
+ return external_exports.array(PredicateNodeSchema);
55329
+ }
55330
+ });
55331
+ var CompareNodeSchema = external_exports.object({
55332
+ kind: external_exports.literal("compare"),
55333
+ op: ComparisonOperatorSchema,
55334
+ get left() {
55335
+ return ExpressionNodeSchema;
55336
+ },
55337
+ get right() {
55338
+ return ExpressionNodeSchema;
55339
+ }
55340
+ });
55341
+ var TextCompareNodeSchema = external_exports.object({
55342
+ kind: external_exports.literal("textCompare"),
55343
+ op: TextComparisonOperatorSchema,
55344
+ get left() {
55345
+ return ExpressionNodeSchema;
55346
+ },
55347
+ get right() {
55348
+ return ExpressionNodeSchema;
55349
+ }
55350
+ });
55351
+ var MemberOfNodeSchema = external_exports.object({
55352
+ kind: external_exports.literal("memberOf"),
55353
+ op: MembershipOperatorSchema,
55354
+ get operand() {
55355
+ return ExpressionNodeSchema;
55356
+ },
55357
+ get candidates() {
55358
+ return external_exports.array(ExpressionNodeSchema);
55359
+ }
55360
+ });
55361
+ var ExistsNodeSchema = external_exports.object({
55362
+ kind: external_exports.literal("exists"),
55363
+ get operand() {
55364
+ return ExpressionNodeSchema;
55365
+ }
55366
+ });
55367
+ var SomeNodeSchema = external_exports.object({
55368
+ kind: external_exports.literal("some"),
55369
+ collection: JsonValueSchema,
55370
+ get item() {
55371
+ return PredicateNodeSchema;
55372
+ },
55373
+ get filter() {
55374
+ return PredicateNodeSchema.optional();
55375
+ }
55376
+ });
55377
+ var EveryNodeSchema = external_exports.object({
55378
+ kind: external_exports.literal("every"),
55379
+ collection: JsonValueSchema,
55380
+ get item() {
55381
+ return PredicateNodeSchema;
55382
+ },
55383
+ get filter() {
55384
+ return PredicateNodeSchema.optional();
55385
+ }
55386
+ });
55387
+ var TreeReferenceNodeSchema = external_exports.object({
55388
+ kind: external_exports.literal("treeReference"),
55389
+ key: JsonValueSchema
55390
+ });
55391
+ var PredicateNodeSchema = external_exports.discriminatedUnion("kind", [
55392
+ NotNodeSchema,
55393
+ AndNodeSchema,
55394
+ OrNodeSchema,
55395
+ AllOfNodeSchema,
55396
+ AnyOfNodeSchema,
55397
+ CompareNodeSchema,
55398
+ TextCompareNodeSchema,
55399
+ MemberOfNodeSchema,
55400
+ ExistsNodeSchema,
55401
+ SomeNodeSchema,
55402
+ EveryNodeSchema,
55403
+ TreeReferenceNodeSchema
55404
+ ]);
55405
+ var NumberLiteralNodeSchema = external_exports.object({
55406
+ kind: external_exports.literal("numberLiteral"),
55407
+ value: external_exports.number(),
55408
+ unit: UnitSchema.optional()
55409
+ });
55410
+ var TextLiteralNodeSchema = external_exports.object({
55411
+ kind: external_exports.literal("textLiteral"),
55412
+ value: external_exports.string()
55413
+ });
55414
+ var BooleanLiteralNodeSchema = external_exports.object({
55415
+ kind: external_exports.literal("booleanLiteral"),
55416
+ value: external_exports.boolean()
55417
+ });
55418
+ var InstantLiteralNodeSchema = external_exports.object({
55419
+ kind: external_exports.literal("instantLiteral"),
55420
+ /** ISO-8601 timestamp. */
55421
+ value: external_exports.string()
55422
+ });
55423
+ var DurationLiteralNodeSchema = external_exports.object({
55424
+ kind: external_exports.literal("durationLiteral"),
55425
+ value: external_exports.number(),
55426
+ unit: DurationUnitSchema
55427
+ });
55428
+ var ComplexRectangularLiteralNodeSchema = external_exports.strictObject({
55429
+ kind: external_exports.literal("complexLiteral"),
55430
+ re: external_exports.number(),
55431
+ im: external_exports.number(),
55432
+ unit: UnitSchema.optional()
55433
+ });
55434
+ var ComplexPolarLiteralNodeSchema = external_exports.strictObject({
55435
+ kind: external_exports.literal("complexLiteral"),
55436
+ magnitude: external_exports.number(),
55437
+ phase: external_exports.number(),
55438
+ unit: UnitSchema.optional()
55439
+ });
55440
+ var ComplexLiteralNodeSchema = external_exports.union([ComplexRectangularLiteralNodeSchema, ComplexPolarLiteralNodeSchema]);
55441
+ var ReferenceNodeSchema = external_exports.object({
55442
+ kind: external_exports.literal("reference"),
55443
+ key: JsonValueSchema,
55444
+ unit: UnitSchema.optional()
55445
+ });
55446
+ var ArithmeticNodeSchema = external_exports.object({
55447
+ kind: external_exports.literal("arithmetic"),
55448
+ op: ArithmeticOperatorSchema,
55449
+ get left() {
55450
+ return ExpressionNodeSchema;
55451
+ },
55452
+ get right() {
55453
+ return ExpressionNodeSchema;
55454
+ }
55455
+ });
55456
+ var NegateNodeSchema = external_exports.object({
55457
+ kind: external_exports.literal("negate"),
55458
+ get operand() {
55459
+ return ExpressionNodeSchema;
55460
+ }
55461
+ });
55462
+ var CallNodeSchema = external_exports.object({
55463
+ kind: external_exports.literal("call"),
55464
+ fn: external_exports.string(),
55465
+ get args() {
55466
+ return external_exports.array(ExpressionNodeSchema);
55467
+ }
55468
+ });
55469
+ var LookupNodeSchema = external_exports.object({
55470
+ kind: external_exports.literal("lookup"),
55471
+ table: JsonValueSchema,
55472
+ get keys() {
55473
+ return external_exports.array(ExpressionNodeSchema);
55474
+ }
55475
+ });
55476
+ var ConditionalCaseSchema = external_exports.object({
55477
+ get when() {
55478
+ return PredicateNodeSchema;
55479
+ },
55480
+ get then() {
55481
+ return ExpressionNodeSchema;
55482
+ }
55483
+ });
55484
+ var ConditionalNodeSchema = external_exports.object({
55485
+ kind: external_exports.literal("conditional"),
55486
+ /** Absent means `"first"` -- the exact, unchanged behaviour of every tree serialised before this field existed. A deliberate, meaningful default, not a masked-bug fallback; see the `conditional` section of README.md for `"unique"`'s own absorption rules. */
55487
+ hitPolicy: HitPolicySchema.optional(),
55488
+ get cases() {
55489
+ return external_exports.array(ConditionalCaseSchema);
55490
+ },
55491
+ get fallback() {
55492
+ return ExpressionNodeSchema;
55493
+ }
55494
+ });
55495
+ var FoldCombinerSchema = external_exports.discriminatedUnion("mode", [
55496
+ external_exports.object({
55497
+ mode: external_exports.literal("max"),
55498
+ get item() {
55499
+ return ExpressionNodeSchema;
55500
+ }
55501
+ }),
55502
+ external_exports.object({
55503
+ mode: external_exports.literal("min"),
55504
+ get item() {
55505
+ return ExpressionNodeSchema;
55506
+ }
55507
+ }),
55508
+ external_exports.object({
55509
+ mode: external_exports.literal("reduce"),
55510
+ get initial() {
55511
+ return ExpressionNodeSchema;
55512
+ },
55513
+ get combine() {
55514
+ return ExpressionNodeSchema;
55515
+ }
55516
+ })
55517
+ ]);
55518
+ var FoldNodeSchema = external_exports.object({
55519
+ kind: external_exports.literal("fold"),
55520
+ collection: JsonValueSchema,
55521
+ get filter() {
55522
+ return PredicateNodeSchema.optional();
55523
+ },
55524
+ combiner: FoldCombinerSchema
55525
+ });
55526
+ var AccumulatorNodeSchema = external_exports.object({ kind: external_exports.literal("accumulator") });
55527
+ var DelegateNodeSchema = external_exports.object({
55528
+ kind: external_exports.literal("delegate"),
55529
+ system: external_exports.string(),
55530
+ payload: JsonValueSchema
55531
+ });
55532
+ var CoreExpressionNodeSchema = external_exports.discriminatedUnion("kind", [
55533
+ NumberLiteralNodeSchema,
55534
+ TextLiteralNodeSchema,
55535
+ BooleanLiteralNodeSchema,
55536
+ InstantLiteralNodeSchema,
55537
+ DurationLiteralNodeSchema,
55538
+ ReferenceNodeSchema,
55539
+ ArithmeticNodeSchema,
55540
+ NegateNodeSchema,
55541
+ CallNodeSchema,
55542
+ LookupNodeSchema,
55543
+ ConditionalNodeSchema,
55544
+ FoldNodeSchema,
55545
+ AccumulatorNodeSchema,
55546
+ DelegateNodeSchema,
55547
+ TreeReferenceNodeSchema
55548
+ ]);
55549
+ var ExpressionNodeSchema = external_exports.union([CoreExpressionNodeSchema, ComplexLiteralNodeSchema]);
55550
+
55551
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/functions.js
55552
+ var emptyFunctionRegistry = {};
55553
+
55554
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator-budget.js
55555
+ var DEFAULT_MAX_EVALUATION_NODES = 1e4;
55556
+ function createEvaluationBudget(maxNodes, maxNestingDepth) {
55557
+ let nodesVisited = 0;
55558
+ return { checkNode(nestingDepth) {
55559
+ nodesVisited += 1;
55560
+ if (nodesVisited > maxNodes) return indeterminate("domain-error", `evaluation exceeded the maximum of ${maxNodes.toString()} nodes visited in a single call (resource exhausted)`);
55561
+ if (nestingDepth >= maxNestingDepth) return indeterminate("domain-error", `evaluation nesting depth exceeds the maximum of ${maxNestingDepth.toString()} (resource exhausted)`);
55562
+ } };
55563
+ }
55564
+
55565
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator-effect.js
55566
+ function* wait(value2) {
55567
+ return yield {
55568
+ kind: "wait",
55569
+ value: value2
55570
+ };
55571
+ }
55572
+ function* all(tasks) {
55573
+ return yield {
55574
+ kind: "all",
55575
+ tasks
55576
+ };
55577
+ }
55578
+ function isThenable(value2) {
55579
+ return typeof value2 === "object" && value2 !== null && "then" in value2 && typeof value2.then === "function";
55580
+ }
55581
+ async function runAsync(task) {
55582
+ let step2 = task.next();
55583
+ while (step2.done !== true) {
55584
+ const suspension = step2.value;
55585
+ const result = suspension.kind === "wait" ? await suspension.value : await Promise.all(suspension.tasks.map(runAsync));
55586
+ step2 = task.next(result);
55587
+ }
55588
+ return step2.value;
55589
+ }
55590
+ function runSync(task) {
55591
+ let step2 = task.next();
55592
+ while (step2.done !== true) {
55593
+ const suspension = step2.value;
55594
+ let result;
55595
+ if (suspension.kind === "wait") {
55596
+ if (isThenable(suspension.value)) throw new TypeError("a resolver supplied to a synchronous evaluator returned a promise; use the asynchronous evaluator for asynchronous resolvers");
55597
+ result = suspension.value;
55598
+ } else result = suspension.tasks.map(runSync);
55599
+ step2 = task.next(result);
55600
+ }
55601
+ return step2.value;
55602
+ }
55603
+
55604
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator-collection.js
55605
+ function* resolveParticipatingItems(evaluatePredicate2, collection, filter, context, resolvers, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth) {
55606
+ const candidates = yield* wait(resolvers.resolveCollection(collection, context));
55607
+ return yield* all(candidates.map(function* (item) {
55608
+ if (filter === void 0) return {
55609
+ item,
55610
+ filterOutcome: "include"
55611
+ };
55612
+ const filterResult = yield* evaluatePredicate2(filter, item, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
55613
+ if (filterResult.status === "indeterminate") return {
55614
+ item,
55615
+ filterOutcome: filterResult
55616
+ };
55617
+ return {
55618
+ item,
55619
+ filterOutcome: filterResult.value ? "include" : "exclude"
55620
+ };
55621
+ }));
55622
+ }
55623
+ function firstFilterIndeterminate(participating) {
55624
+ for (const { filterOutcome } of participating) {
55625
+ if (filterOutcome === "include" || filterOutcome === "exclude") continue;
55626
+ if (filterOutcome.status === "indeterminate") return filterOutcome.reason;
55627
+ }
55628
+ }
55629
+
55630
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/ast.js
55631
+ function rangeContains(range2, unit) {
55632
+ return unit >= range2.from && unit <= range2.to;
55633
+ }
55634
+ function charClassMatches(node2, unit) {
55635
+ const inRanges = node2.ranges.some((range2) => rangeContains(range2, unit));
55636
+ return node2.negated ? !inRanges : inRanges;
55637
+ }
55638
+
55639
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/errors.js
55640
+ var RegexParseError = class extends Error {
55641
+ pattern;
55642
+ index;
55643
+ constructor(pattern, index, reason) {
55644
+ super(`invalid pattern at index ${String(index)}: ${reason}
55645
+ ${pattern}
55646
+ ${" ".repeat(index)}^`);
55647
+ this.name = "RegexParseError";
55648
+ this.pattern = pattern;
55649
+ this.index = index;
55650
+ }
55651
+ };
55652
+
55653
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/shorthand-classes.js
55654
+ function codeOf(char) {
55655
+ return char.charCodeAt(0);
55656
+ }
55657
+ function range(fromChar, toChar) {
55658
+ return {
55659
+ from: codeOf(fromChar),
55660
+ to: codeOf(toChar)
55661
+ };
55662
+ }
55663
+ function single(char) {
55664
+ const codeUnit = codeOf(char);
55665
+ return {
55666
+ from: codeUnit,
55667
+ to: codeUnit
55668
+ };
55669
+ }
55670
+ var DIGIT_RANGES = [range("0", "9")];
55671
+ var WORD_RANGES = [
55672
+ range("A", "Z"),
55673
+ range("a", "z"),
55674
+ range("0", "9"),
55675
+ single("_")
55676
+ ];
55677
+ var SPACE_RANGES = [
55678
+ single(" "),
55679
+ single(" "),
55680
+ single("\n"),
55681
+ single("\r"),
55682
+ single("\f"),
55683
+ single("\v")
55684
+ ];
55685
+ function expandShorthandClass(letter) {
55686
+ switch (letter) {
55687
+ case "d":
55688
+ return {
55689
+ kind: "charClass",
55690
+ negated: false,
55691
+ ranges: DIGIT_RANGES
55692
+ };
55693
+ case "D":
55694
+ return {
55695
+ kind: "charClass",
55696
+ negated: true,
55697
+ ranges: DIGIT_RANGES
55698
+ };
55699
+ case "w":
55700
+ return {
55701
+ kind: "charClass",
55702
+ negated: false,
55703
+ ranges: WORD_RANGES
55704
+ };
55705
+ case "W":
55706
+ return {
55707
+ kind: "charClass",
55708
+ negated: true,
55709
+ ranges: WORD_RANGES
55710
+ };
55711
+ case "s":
55712
+ return {
55713
+ kind: "charClass",
55714
+ negated: false,
55715
+ ranges: SPACE_RANGES
55716
+ };
55717
+ case "S":
55718
+ return {
55719
+ kind: "charClass",
55720
+ negated: true,
55721
+ ranges: SPACE_RANGES
55722
+ };
55723
+ default:
55724
+ throw new Error("unreachable shorthand class letter");
55725
+ }
55726
+ }
55727
+
55728
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/parser.js
55729
+ var SEQUENCE_TERMINATORS = /* @__PURE__ */ new Set(["|", ")"]);
55730
+ var SIMPLE_ESCAPES = {
55731
+ ".": ".",
55732
+ "*": "*",
55733
+ "+": "+",
55734
+ "?": "?",
55735
+ "(": "(",
55736
+ ")": ")",
55737
+ "[": "[",
55738
+ "]": "]",
55739
+ "{": "{",
55740
+ "}": "}",
55741
+ "|": "|",
55742
+ "^": "^",
55743
+ $: "$",
55744
+ "\\": "\\",
55745
+ "/": "/",
55746
+ n: "\n",
55747
+ t: " ",
55748
+ r: "\r",
55749
+ f: "\f",
55750
+ v: "\v"
55751
+ };
55752
+ var Parser = class {
55753
+ pattern;
55754
+ pos = 0;
55755
+ constructor(pattern) {
55756
+ this.pattern = pattern;
55757
+ }
55758
+ get position() {
55759
+ return this.pos;
55760
+ }
55761
+ atEnd() {
55762
+ return this.pos >= this.pattern.length;
55763
+ }
55764
+ peek(offset = 0) {
55765
+ return this.pattern[this.pos + offset];
55766
+ }
55767
+ advance() {
55768
+ const char = this.pattern[this.pos];
55769
+ if (char === void 0) throw new RegexParseError(this.pattern, this.pos, "unexpected end of pattern");
55770
+ this.pos += 1;
55771
+ return char;
55772
+ }
55773
+ parseAlternation() {
55774
+ const firstBranch = this.parseSequence();
55775
+ const laterBranches = [];
55776
+ while (this.peek() === "|") {
55777
+ this.advance();
55778
+ laterBranches.push(this.parseSequence());
55779
+ }
55780
+ return laterBranches.length === 0 ? firstBranch : {
55781
+ kind: "alternation",
55782
+ branches: [firstBranch, ...laterBranches]
55783
+ };
55784
+ }
55785
+ parseSequence() {
55786
+ if (this.atEnd() || SEQUENCE_TERMINATORS.has(this.peek() ?? "")) return {
55787
+ kind: "concat",
55788
+ operands: []
55789
+ };
55790
+ const firstOperand = this.parseQuantified();
55791
+ const laterOperands = [];
55792
+ while (!this.atEnd() && !SEQUENCE_TERMINATORS.has(this.peek() ?? "")) laterOperands.push(this.parseQuantified());
55793
+ return laterOperands.length === 0 ? firstOperand : {
55794
+ kind: "concat",
55795
+ operands: [firstOperand, ...laterOperands]
55796
+ };
55797
+ }
55798
+ parseQuantified() {
55799
+ const atomStart = this.pos;
55800
+ const atom = this.parseAtom();
55801
+ if (atom.kind === "anchorStart" || atom.kind === "anchorEnd") {
55802
+ if (this.peekIsQuantifierStart()) throw new RegexParseError(this.pattern, atomStart, `an anchor ('${atom.kind === "anchorStart" ? "^" : "$"}') cannot be quantified`);
55803
+ return atom;
55804
+ }
55805
+ const quantifier = this.tryParseQuantifier();
55806
+ if (quantifier === void 0) return atom;
55807
+ if (this.peekIsQuantifierStart()) throw new RegexParseError(this.pattern, this.pos, "a quantifier cannot itself be quantified -- this grammar has no lazy or possessive modifiers, since a pattern that only ever answers a yes/no match question has no notion for either to change");
55808
+ switch (quantifier.kind) {
55809
+ case "star":
55810
+ return {
55811
+ kind: "star",
55812
+ operand: atom
55813
+ };
55814
+ case "plus":
55815
+ return {
55816
+ kind: "plus",
55817
+ operand: atom
55818
+ };
55819
+ case "optional":
55820
+ return {
55821
+ kind: "optional",
55822
+ operand: atom
55823
+ };
55824
+ case "repeat":
55825
+ return {
55826
+ kind: "repeat",
55827
+ operand: atom,
55828
+ min: quantifier.min,
55829
+ max: quantifier.max
55830
+ };
55831
+ default:
55832
+ throw new Error("unreachable quantifier kind");
55833
+ }
55834
+ }
55835
+ /** A pure lookahead: restores `pos` before returning in every case, including through `tryParseBound`'s own successful parse. Used only to decide whether a second quantifier immediately follows the one just applied, which is always a parse error (see `parseQuantified`). */
55836
+ peekIsQuantifierStart() {
55837
+ const c2 = this.peek();
55838
+ if (c2 === "*" || c2 === "+" || c2 === "?") return true;
55839
+ if (c2 === "{") {
55840
+ const savedPos = this.pos;
55841
+ const bound = this.tryParseBound();
55842
+ this.pos = savedPos;
55843
+ return bound !== void 0;
55844
+ }
55845
+ return false;
55846
+ }
55847
+ tryParseQuantifier() {
55848
+ const c2 = this.peek();
55849
+ if (c2 === "*") {
55850
+ this.advance();
55851
+ return { kind: "star" };
55852
+ }
55853
+ if (c2 === "+") {
55854
+ this.advance();
55855
+ return { kind: "plus" };
55856
+ }
55857
+ if (c2 === "?") {
55858
+ this.advance();
55859
+ return { kind: "optional" };
55860
+ }
55861
+ if (c2 === "{") {
55862
+ const bound = this.tryParseBound();
55863
+ if (bound === void 0) return void 0;
55864
+ return {
55865
+ kind: "repeat",
55866
+ min: bound.min,
55867
+ max: bound.max
55868
+ };
55869
+ }
55870
+ }
55871
+ /**
55872
+ * Attempts `{min}` / `{min,}` / `{min,max}` starting at the current `{`. Rewinds and returns `undefined` for anything that is not exactly one of those three shapes -- including `{}`, `{,5}`, and a `{` with no closing brace at all -- so that an unrecognised `{` falls back to being parsed as a literal character by the caller, matching how a bounded-repetition quantifier is conventionally the only special meaning `{` ever carries.
55873
+ *
55874
+ * A backwards bound (`{5,2}`) is a real error rather than a fallback-to-literal case: the syntax is unambiguously a quantifier attempt, so this throws instead of returning `undefined` for it.
55875
+ */
55876
+ tryParseBound() {
55877
+ const savedPos = this.pos;
55878
+ this.pos += 1;
55879
+ const minDigits = this.readDigits();
55880
+ if (minDigits === "") {
55881
+ this.pos = savedPos;
55882
+ return;
55883
+ }
55884
+ let maxDigits;
55885
+ let hasComma = false;
55886
+ if (this.peek() === ",") {
55887
+ hasComma = true;
55888
+ this.pos += 1;
55889
+ maxDigits = this.readDigits();
55890
+ }
55891
+ if (this.peek() !== "}") {
55892
+ this.pos = savedPos;
55893
+ return;
55894
+ }
55895
+ this.pos += 1;
55896
+ const min = Number.parseInt(minDigits, 10);
55897
+ const max = !hasComma ? min : maxDigits === "" ? void 0 : Number.parseInt(maxDigits ?? "", 10);
55898
+ if (max !== void 0 && max < min) throw new RegexParseError(this.pattern, savedPos, `quantifier range is backwards: {${minDigits}${hasComma ? "," + (maxDigits ?? "") : ""}} would require between ${String(min)} and ${String(max)} repetitions`);
55899
+ return {
55900
+ min,
55901
+ max
55902
+ };
55903
+ }
55904
+ readDigits() {
55905
+ let digits = "";
55906
+ for (; ; ) {
55907
+ const c2 = this.peek();
55908
+ if (c2 === void 0 || c2 < "0" || c2 > "9") break;
55909
+ digits += c2;
55910
+ this.pos += 1;
55911
+ }
55912
+ return digits;
55913
+ }
55914
+ parseAtom() {
55915
+ const c2 = this.peek();
55916
+ if (c2 === void 0) throw new RegexParseError(this.pattern, this.pos, "unexpected end of pattern");
55917
+ if (c2 === "^") {
55918
+ this.advance();
55919
+ return { kind: "anchorStart" };
55920
+ }
55921
+ if (c2 === "$") {
55922
+ this.advance();
55923
+ return { kind: "anchorEnd" };
55924
+ }
55925
+ if (c2 === ".") {
55926
+ this.advance();
55927
+ return { kind: "anyChar" };
55928
+ }
55929
+ if (c2 === "(") return this.parseGroup();
55930
+ if (c2 === "[") return this.parseCharClass();
55931
+ if (c2 === "\\") return this.parseEscapedAtom();
55932
+ if (c2 === "*" || c2 === "+" || c2 === "?") throw new RegexParseError(this.pattern, this.pos, `quantifier '${c2}' with nothing to repeat`);
55933
+ this.advance();
55934
+ return {
55935
+ kind: "literal",
55936
+ codeUnit: c2.charCodeAt(0)
55937
+ };
55938
+ }
55939
+ parseGroup() {
55940
+ const start = this.pos;
55941
+ this.advance();
55942
+ if (this.peek() === "?" && this.peek(1) === ":") {
55943
+ this.advance();
55944
+ this.advance();
55945
+ } else throw new RegexParseError(this.pattern, start, "capturing groups are not supported in this grammar -- there is nothing to capture, since a pattern only ever answers whether it matches. Use '(?:...)' for grouping.");
55946
+ const inner = this.parseAlternation();
55947
+ if (this.peek() !== ")") throw new RegexParseError(this.pattern, this.pos, "expected ')' to close '(?:'");
55948
+ this.advance();
55949
+ return inner;
55950
+ }
55951
+ parseEscapedAtom() {
55952
+ const backslashPos = this.pos;
55953
+ this.advance();
55954
+ if (this.atEnd()) throw new RegexParseError(this.pattern, backslashPos, "trailing backslash with nothing to escape");
55955
+ const c2 = this.advance();
55956
+ if (c2 === "d" || c2 === "D" || c2 === "w" || c2 === "W" || c2 === "s" || c2 === "S") return expandShorthandClass(c2);
55957
+ const literal2 = SIMPLE_ESCAPES[c2];
55958
+ if (literal2 !== void 0) return {
55959
+ kind: "literal",
55960
+ codeUnit: literal2.charCodeAt(0)
55961
+ };
55962
+ throw new RegexParseError(this.pattern, backslashPos, `unknown escape sequence '\\${c2}'`);
55963
+ }
55964
+ parseCharClass() {
55965
+ const start = this.pos;
55966
+ this.advance();
55967
+ let negated = false;
55968
+ if (this.peek() === "^") {
55969
+ this.advance();
55970
+ negated = true;
55971
+ }
55972
+ const ranges = [];
55973
+ for (; ; ) {
55974
+ if (this.atEnd()) throw new RegexParseError(this.pattern, start, "unterminated character class -- missing closing ']'");
55975
+ if (this.peek() === "]") {
55976
+ if (ranges.length === 0) throw new RegexParseError(this.pattern, this.pos, "a character class must contain at least one item -- ']' immediately, or immediately after '[^', is not the empty class here (escape it as '\\]' to match a literal ']')");
55977
+ this.advance();
55978
+ break;
55979
+ }
55980
+ ranges.push(...this.parseClassItem());
55981
+ }
55982
+ return {
55983
+ kind: "charClass",
55984
+ negated,
55985
+ ranges
55986
+ };
55987
+ }
55988
+ parseClassItem() {
55989
+ const c2 = this.peek();
55990
+ if (c2 === "\\") {
55991
+ const backslashPos = this.pos;
55992
+ this.advance();
55993
+ if (this.atEnd()) throw new RegexParseError(this.pattern, backslashPos, "trailing backslash with nothing to escape");
55994
+ const escaped = this.advance();
55995
+ if (escaped === "d" || escaped === "w" || escaped === "s") return expandShorthandClass(escaped).ranges;
55996
+ if (escaped === "D" || escaped === "W" || escaped === "S") throw new RegexParseError(this.pattern, backslashPos, `the negated shorthand class '\\${escaped}' cannot be embedded inside a character class, because its complement cannot be represented as a set of ranges to union with the class's other members -- use it as its own atom instead of embedding it here`);
55997
+ const literal2 = SIMPLE_ESCAPES[escaped];
55998
+ if (literal2 === void 0) throw new RegexParseError(this.pattern, backslashPos, `unknown escape sequence '\\${escaped}'`);
55999
+ return this.parseOptionalRangeFrom(literal2.charCodeAt(0));
56000
+ }
56001
+ if (c2 === void 0) throw new RegexParseError(this.pattern, this.pos, "unterminated character class -- missing closing ']'");
56002
+ this.advance();
56003
+ return this.parseOptionalRangeFrom(c2.charCodeAt(0));
56004
+ }
56005
+ parseOptionalRangeFrom(fromCode) {
56006
+ if (this.peek() === "-" && this.peek(1) !== void 0 && this.peek(1) !== "]") {
56007
+ const hyphenPos = this.pos;
56008
+ this.advance();
56009
+ const toCode = this.parseClassRangeEndpoint();
56010
+ if (toCode < fromCode) throw new RegexParseError(this.pattern, hyphenPos, `invalid range in character class: '${String.fromCharCode(fromCode)}-${String.fromCharCode(toCode)}' is reversed`);
56011
+ return [{
56012
+ from: fromCode,
56013
+ to: toCode
56014
+ }];
56015
+ }
56016
+ return [{
56017
+ from: fromCode,
56018
+ to: fromCode
56019
+ }];
56020
+ }
56021
+ parseClassRangeEndpoint() {
56022
+ const c2 = this.peek();
56023
+ if (c2 === "\\") {
56024
+ const backslashPos = this.pos;
56025
+ this.advance();
56026
+ if (this.atEnd()) throw new RegexParseError(this.pattern, backslashPos, "trailing backslash with nothing to escape");
56027
+ const escaped = this.advance();
56028
+ if (escaped === "d" || escaped === "D" || escaped === "w" || escaped === "W" || escaped === "s" || escaped === "S") throw new RegexParseError(this.pattern, backslashPos, `a shorthand class ('\\${escaped}') cannot be a range endpoint`);
56029
+ const literal2 = SIMPLE_ESCAPES[escaped];
56030
+ if (literal2 === void 0) throw new RegexParseError(this.pattern, backslashPos, `unknown escape sequence '\\${escaped}'`);
56031
+ return literal2.charCodeAt(0);
56032
+ }
56033
+ if (c2 === void 0) throw new RegexParseError(this.pattern, this.pos, "unterminated character class -- missing closing ']'");
56034
+ this.advance();
56035
+ return c2.charCodeAt(0);
56036
+ }
56037
+ };
56038
+ function parseRegex(pattern) {
56039
+ const parser = new Parser(pattern);
56040
+ const node2 = parser.parseAlternation();
56041
+ if (!parser.atEnd()) throw new RegexParseError(pattern, parser.position, "unexpected character -- if this was meant literally, escape it with a backslash");
56042
+ return node2;
56043
+ }
56044
+
56045
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/nfa.js
56046
+ var NfaBuilder = class {
56047
+ states = [];
56048
+ add(state) {
56049
+ this.states.push(state);
56050
+ return this.states.length - 1;
56051
+ }
56052
+ patch(targets, target) {
56053
+ for (const patchTarget of targets) {
56054
+ const state = this.states[patchTarget.state];
56055
+ if (state === void 0) continue;
56056
+ switch (patchTarget.field) {
56057
+ case "to":
56058
+ if (state.kind === "char" || state.kind === "anchorStart" || state.kind === "anchorEnd") state.to = target;
56059
+ break;
56060
+ case "to1":
56061
+ if (state.kind === "split") state.to1 = target;
56062
+ break;
56063
+ case "to2":
56064
+ if (state.kind === "split") state.to2 = target;
56065
+ }
56066
+ }
56067
+ }
56068
+ /** A fragment that matches the empty string unconditionally: both of a split's own branches dangle straight out, so whichever target they are later patched to is reached having consumed nothing. Used for `{0}`/`{0,0}` repetition, the one shape bounded repetition can produce that no other node kind already covers. */
56069
+ emptyFrag() {
56070
+ const idx = this.add({
56071
+ kind: "split",
56072
+ to1: -1,
56073
+ to2: -1
56074
+ });
56075
+ return {
56076
+ start: idx,
56077
+ out: [{
56078
+ state: idx,
56079
+ field: "to1"
56080
+ }, {
56081
+ state: idx,
56082
+ field: "to2"
56083
+ }]
56084
+ };
56085
+ }
56086
+ compileRepeat(node2) {
56087
+ const { operand, min, max } = node2;
56088
+ if (max === void 0) {
56089
+ if (min === 0) return this.compileNode({
56090
+ kind: "star",
56091
+ operand
56092
+ });
56093
+ const parts2 = [];
56094
+ for (let i2 = 0; i2 < min - 1; i2 += 1) parts2.push(operand);
56095
+ parts2.push({
56096
+ kind: "plus",
56097
+ operand
56098
+ });
56099
+ return this.compileNode({
56100
+ kind: "concat",
56101
+ operands: parts2
56102
+ });
56103
+ }
56104
+ const parts = [];
56105
+ for (let i2 = 0; i2 < min; i2 += 1) parts.push(operand);
56106
+ for (let i2 = 0; i2 < max - min; i2 += 1) parts.push({
56107
+ kind: "optional",
56108
+ operand
56109
+ });
56110
+ if (parts.length === 0) return this.emptyFrag();
56111
+ return this.compileNode({
56112
+ kind: "concat",
56113
+ operands: parts
56114
+ });
56115
+ }
56116
+ compileNode(node2) {
56117
+ switch (node2.kind) {
56118
+ case "literal": {
56119
+ const codeUnit = node2.codeUnit;
56120
+ const idx = this.add({
56121
+ kind: "char",
56122
+ test: (unit) => unit === codeUnit,
56123
+ to: -1
56124
+ });
56125
+ return {
56126
+ start: idx,
56127
+ out: [{
56128
+ state: idx,
56129
+ field: "to"
56130
+ }]
56131
+ };
56132
+ }
56133
+ case "anyChar": {
56134
+ const idx = this.add({
56135
+ kind: "char",
56136
+ test: () => true,
56137
+ to: -1
56138
+ });
56139
+ return {
56140
+ start: idx,
56141
+ out: [{
56142
+ state: idx,
56143
+ field: "to"
56144
+ }]
56145
+ };
56146
+ }
56147
+ case "charClass": {
56148
+ const idx = this.add({
56149
+ kind: "char",
56150
+ test: (unit) => charClassMatches(node2, unit),
56151
+ to: -1
56152
+ });
56153
+ return {
56154
+ start: idx,
56155
+ out: [{
56156
+ state: idx,
56157
+ field: "to"
56158
+ }]
56159
+ };
56160
+ }
56161
+ case "anchorStart": {
56162
+ const idx = this.add({
56163
+ kind: "anchorStart",
56164
+ to: -1
56165
+ });
56166
+ return {
56167
+ start: idx,
56168
+ out: [{
56169
+ state: idx,
56170
+ field: "to"
56171
+ }]
56172
+ };
56173
+ }
56174
+ case "anchorEnd": {
56175
+ const idx = this.add({
56176
+ kind: "anchorEnd",
56177
+ to: -1
56178
+ });
56179
+ return {
56180
+ start: idx,
56181
+ out: [{
56182
+ state: idx,
56183
+ field: "to"
56184
+ }]
56185
+ };
56186
+ }
56187
+ case "concat": {
56188
+ if (node2.operands.length === 0) return this.emptyFrag();
56189
+ const [first, ...rest] = node2.operands;
56190
+ if (first === void 0) throw new Error("unreachable: a non-empty operands array always has a first element");
56191
+ let frag = this.compileNode(first);
56192
+ for (const operand of rest) {
56193
+ const next = this.compileNode(operand);
56194
+ this.patch(frag.out, next.start);
56195
+ frag = {
56196
+ start: frag.start,
56197
+ out: next.out
56198
+ };
56199
+ }
56200
+ return frag;
56201
+ }
56202
+ case "alternation": {
56203
+ const [first, ...rest] = node2.branches;
56204
+ if (first === void 0) throw new Error("unreachable: AlternationNode always has at least two branches");
56205
+ let frag = this.compileNode(first);
56206
+ for (const branch of rest) {
56207
+ const next = this.compileNode(branch);
56208
+ frag = {
56209
+ start: this.add({
56210
+ kind: "split",
56211
+ to1: frag.start,
56212
+ to2: next.start
56213
+ }),
56214
+ out: [...frag.out, ...next.out]
56215
+ };
56216
+ }
56217
+ return frag;
56218
+ }
56219
+ case "star": {
56220
+ const inner = this.compileNode(node2.operand);
56221
+ const splitIdx = this.add({
56222
+ kind: "split",
56223
+ to1: inner.start,
56224
+ to2: -1
56225
+ });
56226
+ this.patch(inner.out, splitIdx);
56227
+ return {
56228
+ start: splitIdx,
56229
+ out: [{
56230
+ state: splitIdx,
56231
+ field: "to2"
56232
+ }]
56233
+ };
56234
+ }
56235
+ case "plus": {
56236
+ const inner = this.compileNode(node2.operand);
56237
+ const splitIdx = this.add({
56238
+ kind: "split",
56239
+ to1: inner.start,
56240
+ to2: -1
56241
+ });
56242
+ this.patch(inner.out, splitIdx);
56243
+ return {
56244
+ start: inner.start,
56245
+ out: [{
56246
+ state: splitIdx,
56247
+ field: "to2"
56248
+ }]
56249
+ };
56250
+ }
56251
+ case "optional": {
56252
+ const inner = this.compileNode(node2.operand);
56253
+ const splitIdx = this.add({
56254
+ kind: "split",
56255
+ to1: inner.start,
56256
+ to2: -1
56257
+ });
56258
+ return {
56259
+ start: splitIdx,
56260
+ out: [...inner.out, {
56261
+ state: splitIdx,
56262
+ field: "to2"
56263
+ }]
56264
+ };
56265
+ }
56266
+ case "repeat":
56267
+ return this.compileRepeat(node2);
56268
+ default:
56269
+ throw new Error("unreachable regex node kind");
56270
+ }
56271
+ }
56272
+ build(root) {
56273
+ const frag = this.compileNode(root);
56274
+ const matchState = this.add({ kind: "match" });
56275
+ this.patch(frag.out, matchState);
56276
+ return {
56277
+ states: this.states,
56278
+ start: frag.start,
56279
+ matchState
56280
+ };
56281
+ }
56282
+ };
56283
+ function compileToNfa(node2) {
56284
+ return new NfaBuilder().build(node2);
56285
+ }
56286
+
56287
+ // node_modules/.pnpm/trilean-regex@1.0.3/node_modules/trilean-regex/dist/matcher.js
56288
+ function closure(nfa, seeds, pos, length) {
56289
+ const result = /* @__PURE__ */ new Set();
56290
+ const visited = /* @__PURE__ */ new Set();
56291
+ const stack = [...seeds];
56292
+ while (stack.length > 0) {
56293
+ const idx = stack.pop();
56294
+ if (idx === void 0) continue;
56295
+ if (visited.has(idx)) continue;
56296
+ visited.add(idx);
56297
+ const state = nfa.states[idx];
56298
+ if (state === void 0) continue;
56299
+ switch (state.kind) {
56300
+ case "char":
56301
+ case "match":
56302
+ result.add(idx);
56303
+ break;
56304
+ case "split":
56305
+ stack.push(state.to1, state.to2);
56306
+ break;
56307
+ case "anchorStart":
56308
+ if (pos === 0) stack.push(state.to);
56309
+ break;
56310
+ case "anchorEnd":
56311
+ if (pos === length) stack.push(state.to);
56312
+ }
56313
+ }
56314
+ return result;
56315
+ }
56316
+ function step(nfa, current, codeUnit) {
56317
+ const next = /* @__PURE__ */ new Set();
56318
+ for (const idx of current) {
56319
+ const state = nfa.states[idx];
56320
+ if (state?.kind !== "char") continue;
56321
+ if (state.test(codeUnit)) next.add(state.to);
56322
+ }
56323
+ return next;
56324
+ }
56325
+ function matchesNfa(nfa, input2) {
56326
+ const length = input2.length;
56327
+ let current = closure(nfa, [nfa.start], 0, length);
56328
+ if (current.has(nfa.matchState)) return true;
56329
+ for (let pos = 0; pos < length; pos += 1) {
56330
+ const codeUnit = input2.charCodeAt(pos);
56331
+ const stepped = step(nfa, current, codeUnit);
56332
+ stepped.add(nfa.start);
56333
+ current = closure(nfa, [...stepped], pos + 1, length);
56334
+ if (current.has(nfa.matchState)) return true;
56335
+ }
56336
+ return false;
56337
+ }
56338
+ function compilePattern(pattern) {
56339
+ const nfa = compileToNfa(parseRegex(pattern));
56340
+ return { test: (input2) => matchesNfa(nfa, input2) };
56341
+ }
56342
+
56343
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator-operations.js
56344
+ function combineAnd(left, right) {
56345
+ if (left.status === "definite" && !left.value) return definite(false);
56346
+ if (right.status === "definite" && !right.value) return definite(false);
56347
+ const reason = firstIndeterminate(left, right);
56348
+ if (reason !== void 0) return {
56349
+ status: "indeterminate",
56350
+ reason
56351
+ };
56352
+ return definite(true);
56353
+ }
56354
+ function combineOr(left, right) {
56355
+ if (left.status === "definite" && left.value) return definite(true);
56356
+ if (right.status === "definite" && right.value) return definite(true);
56357
+ const reason = firstIndeterminate(left, right);
56358
+ if (reason !== void 0) return {
56359
+ status: "indeterminate",
56360
+ reason
56361
+ };
56362
+ return definite(false);
56363
+ }
56364
+ function applyComparisonOperator(op, left, right) {
56365
+ switch (op) {
56366
+ case "gt":
56367
+ return left > right;
56368
+ case "gte":
56369
+ return left >= right;
56370
+ case "lt":
56371
+ return left < right;
56372
+ case "lte":
56373
+ return left <= right;
56374
+ case "eq":
56375
+ return left === right;
56376
+ case "neq":
56377
+ return left !== right;
56378
+ default:
56379
+ throw new Error("unreachable comparison operator");
56380
+ }
56381
+ }
56382
+ var millisecondsPerDurationUnit = {
56383
+ ms: 1,
56384
+ s: 1e3,
56385
+ min: 6e4,
56386
+ h: 36e5,
56387
+ d: 864e5
56388
+ };
56389
+ function toMilliseconds(value2, unit) {
56390
+ return value2 * millisecondsPerDurationUnit[unit];
56391
+ }
56392
+ function toEpochMilliseconds(value2) {
56393
+ const epochMilliseconds = Date.parse(value2);
56394
+ return Number.isNaN(epochMilliseconds) ? void 0 : epochMilliseconds;
56395
+ }
56396
+ function unparseableInstant(value2) {
56397
+ return indeterminate("wrong-type", `'${value2}' is not a parseable ISO-8601 timestamp`);
56398
+ }
56399
+ function instantFromEpochMilliseconds(epochMilliseconds) {
56400
+ const shifted = new Date(epochMilliseconds);
56401
+ if (Number.isNaN(shifted.getTime())) return indeterminate("domain-error", "the resulting instant falls outside the representable timestamp range");
56402
+ return definite({
56403
+ kind: "instant",
56404
+ value: shifted.toISOString()
56405
+ });
56406
+ }
56407
+ function compareValues(op, left, right) {
56408
+ switch (left.kind) {
56409
+ case "number":
56410
+ if (right.kind !== "number") return indeterminate("wrong-type", `cannot compare a 'number' value with a '${right.kind}' value`);
56411
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot compare numbers with incompatible units");
56412
+ return definite(applyComparisonOperator(op, left.value, right.value));
56413
+ case "text":
56414
+ return indeterminate("wrong-type", "text values are not comparable via 'compare'; use 'textCompare'");
56415
+ case "boolean":
56416
+ if (right.kind !== "boolean") return indeterminate("wrong-type", `cannot compare a 'boolean' value with a '${right.kind}' value`);
56417
+ if (op !== "eq" && op !== "neq") return indeterminate("wrong-type", `booleans have no natural ordering; '${op}' is only defined for 'eq'/'neq'`);
56418
+ return definite(op === "eq" ? left.value === right.value : left.value !== right.value);
56419
+ case "instant": {
56420
+ if (right.kind !== "instant") return indeterminate("wrong-type", `cannot compare an 'instant' value with a '${right.kind}' value`);
56421
+ const leftEpoch = toEpochMilliseconds(left.value);
56422
+ if (leftEpoch === void 0) return unparseableInstant(left.value);
56423
+ const rightEpoch = toEpochMilliseconds(right.value);
56424
+ if (rightEpoch === void 0) return unparseableInstant(right.value);
56425
+ return definite(applyComparisonOperator(op, leftEpoch, rightEpoch));
56426
+ }
56427
+ case "duration":
56428
+ if (right.kind !== "duration") return indeterminate("wrong-type", `cannot compare a 'duration' value with a '${right.kind}' value`);
56429
+ return definite(applyComparisonOperator(op, toMilliseconds(left.value, left.unit), toMilliseconds(right.value, right.unit)));
56430
+ case "complex":
56431
+ if (op !== "eq" && op !== "neq") return indeterminate("wrong-type", `ordering operator '${op}' is not defined for complex values; the complex plane has no total order`);
56432
+ if (right.kind !== "complex") return indeterminate("wrong-type", `cannot compare a 'complex' value with a '${right.kind}' value`);
56433
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot compare complex values with incompatible units");
56434
+ return definite(op === "eq" ? left.re === right.re && left.im === right.im : left.re !== right.re || left.im !== right.im);
56435
+ default:
56436
+ throw new Error("unreachable computed-value kind");
56437
+ }
56438
+ }
56439
+ function compareText(op, left, right) {
56440
+ if (left.kind !== "text") return indeterminate("wrong-type", `'textCompare' requires 'text' operands; the left operand is '${left.kind}'`);
56441
+ if (right.kind !== "text") return indeterminate("wrong-type", `'textCompare' requires 'text' operands; the right operand is '${right.kind}'`);
56442
+ switch (op) {
56443
+ case "equals":
56444
+ return definite(left.value === right.value);
56445
+ case "notEquals":
56446
+ return definite(left.value !== right.value);
56447
+ case "matches":
56448
+ case "notMatches": {
56449
+ let pattern;
56450
+ try {
56451
+ pattern = new RegExp(right.value);
56452
+ } catch {
56453
+ return indeterminate("wrong-type", `'${right.value}' is not a valid regular expression pattern`);
56454
+ }
56455
+ const isMatch = pattern.test(left.value);
56456
+ return definite(op === "matches" ? isMatch : !isMatch);
56457
+ }
56458
+ case "portableMatches":
56459
+ case "portableNotMatches": {
56460
+ let compiled;
56461
+ try {
56462
+ compiled = compilePattern(right.value);
56463
+ } catch (error62) {
56464
+ const reason = error62 instanceof RegexParseError ? error62.message : String(error62);
56465
+ return indeterminate("wrong-type", `'${right.value}' is not a valid trilean-regex pattern: ${reason}`);
56466
+ }
56467
+ const isMatch = compiled.test(left.value);
56468
+ return definite(op === "portableMatches" ? isMatch : !isMatch);
56469
+ }
56470
+ default:
56471
+ throw new Error("unreachable text comparison operator");
56472
+ }
56473
+ }
56474
+ function computeMembershipMatch(operand, candidate) {
56475
+ switch (operand.kind) {
56476
+ case "number":
56477
+ if (candidate.kind !== "number") return indeterminate("wrong-type", `cannot compare a 'number' value with a '${candidate.kind}' value for membership`);
56478
+ if (!unitsEqual(operand.unit, candidate.unit)) return indeterminate("wrong-type", "cannot compare numbers with incompatible units for membership");
56479
+ return definite(operand.value === candidate.value);
56480
+ case "text":
56481
+ if (candidate.kind !== "text") return indeterminate("wrong-type", `cannot compare a 'text' value with a '${candidate.kind}' value for membership`);
56482
+ return definite(operand.value === candidate.value);
56483
+ case "boolean":
56484
+ if (candidate.kind !== "boolean") return indeterminate("wrong-type", `cannot compare a 'boolean' value with a '${candidate.kind}' value for membership`);
56485
+ return definite(operand.value === candidate.value);
56486
+ case "instant": {
56487
+ if (candidate.kind !== "instant") return indeterminate("wrong-type", `cannot compare an 'instant' value with a '${candidate.kind}' value for membership`);
56488
+ const operandEpoch = toEpochMilliseconds(operand.value);
56489
+ if (operandEpoch === void 0) return unparseableInstant(operand.value);
56490
+ const candidateEpoch = toEpochMilliseconds(candidate.value);
56491
+ if (candidateEpoch === void 0) return unparseableInstant(candidate.value);
56492
+ return definite(operandEpoch === candidateEpoch);
56493
+ }
56494
+ case "duration":
56495
+ if (candidate.kind !== "duration") return indeterminate("wrong-type", `cannot compare a 'duration' value with a '${candidate.kind}' value for membership`);
56496
+ return definite(toMilliseconds(operand.value, operand.unit) === toMilliseconds(candidate.value, candidate.unit));
56497
+ case "complex":
56498
+ if (candidate.kind !== "complex") return indeterminate("wrong-type", `cannot compare a 'complex' value with a '${candidate.kind}' value for membership`);
56499
+ if (!unitsEqual(operand.unit, candidate.unit)) return indeterminate("wrong-type", "cannot compare complex values with incompatible units for membership");
56500
+ return definite(operand.re === candidate.re && operand.im === candidate.im);
56501
+ default:
56502
+ throw new Error("unreachable computed-value kind");
56503
+ }
56504
+ }
56505
+ function isDimensionless(unit) {
56506
+ return unitsEqual(unit, void 0);
56507
+ }
56508
+ function applyNegate(operand) {
56509
+ switch (operand.kind) {
56510
+ case "number":
56511
+ return definite({
56512
+ kind: "number",
56513
+ value: -operand.value,
56514
+ unit: operand.unit
56515
+ });
56516
+ case "duration":
56517
+ return definite({
56518
+ kind: "duration",
56519
+ value: -operand.value,
56520
+ unit: operand.unit
56521
+ });
56522
+ case "complex":
56523
+ return definite({
56524
+ kind: "complex",
56525
+ re: -operand.re,
56526
+ im: -operand.im,
56527
+ unit: operand.unit
56528
+ });
56529
+ case "text":
56530
+ case "instant":
56531
+ case "boolean":
56532
+ return indeterminate("wrong-type", `cannot negate a '${operand.kind}' value`);
56533
+ default:
56534
+ throw new Error("unreachable computed-value kind");
56535
+ }
56536
+ }
56537
+ function applyArithmeticOnNumbers(op, left, right) {
56538
+ switch (op) {
56539
+ case "add":
56540
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot add numbers with incompatible units");
56541
+ return definite({
56542
+ kind: "number",
56543
+ value: left.value + right.value,
56544
+ unit: left.unit
56545
+ });
56546
+ case "subtract":
56547
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot subtract numbers with incompatible units");
56548
+ return definite({
56549
+ kind: "number",
56550
+ value: left.value - right.value,
56551
+ unit: left.unit
56552
+ });
56553
+ case "multiply":
56554
+ return definite({
56555
+ kind: "number",
56556
+ value: left.value * right.value,
56557
+ unit: combineUnitsForMultiply(left.unit, right.unit)
56558
+ });
56559
+ case "divide":
56560
+ if (right.value === 0) return indeterminate("domain-error", "division by zero");
56561
+ return definite({
56562
+ kind: "number",
56563
+ value: left.value / right.value,
56564
+ unit: combineUnitsForDivide(left.unit, right.unit)
56565
+ });
56566
+ case "power":
56567
+ if (!isDimensionless(left.unit) || !isDimensionless(right.unit)) return indeterminate("wrong-type", "'power' requires dimensionless operands");
56568
+ if (left.value < 0 && !Number.isInteger(right.value)) return indeterminate("domain-error", "a negative base raised to a non-integer power is not a real number");
56569
+ if (left.value === 0 && right.value < 0) return indeterminate("domain-error", "zero raised to a negative power is a division by zero");
56570
+ return definite({
56571
+ kind: "number",
56572
+ value: left.value ** right.value
56573
+ });
56574
+ case "modulo":
56575
+ if (!isDimensionless(left.unit) || !isDimensionless(right.unit)) return indeterminate("wrong-type", "'modulo' requires dimensionless operands");
56576
+ if (right.value === 0) return indeterminate("domain-error", "modulo by zero");
56577
+ return definite({
56578
+ kind: "number",
56579
+ value: left.value % right.value
56580
+ });
56581
+ default:
56582
+ throw new Error("unreachable arithmetic operator");
56583
+ }
56584
+ }
56585
+ function applyArithmeticOnDurations(op, left, right) {
56586
+ switch (op) {
56587
+ case "add":
56588
+ return definite({
56589
+ kind: "duration",
56590
+ value: toMilliseconds(left.value, left.unit) + toMilliseconds(right.value, right.unit),
56591
+ unit: "ms"
56592
+ });
56593
+ case "subtract":
56594
+ return definite({
56595
+ kind: "duration",
56596
+ value: toMilliseconds(left.value, left.unit) - toMilliseconds(right.value, right.unit),
56597
+ unit: "ms"
56598
+ });
56599
+ case "multiply":
56600
+ case "divide":
56601
+ case "power":
56602
+ case "modulo":
56603
+ return indeterminate("wrong-type", `arithmetic operator '${op}' is not defined between two 'duration' values`);
56604
+ default:
56605
+ throw new Error("unreachable arithmetic operator");
56606
+ }
56607
+ }
56608
+ function toComplexValue(value2) {
56609
+ if (value2.kind === "complex") return value2;
56610
+ return {
56611
+ kind: "complex",
56612
+ re: value2.value,
56613
+ im: 0,
56614
+ unit: value2.unit
56615
+ };
56616
+ }
56617
+ function multiplyComplexValues(left, right) {
56618
+ return {
56619
+ kind: "complex",
56620
+ re: left.re * right.re - left.im * right.im,
56621
+ im: left.re * right.im + left.im * right.re,
56622
+ unit: combineUnitsForMultiply(left.unit, right.unit)
56623
+ };
56624
+ }
56625
+ function applyArithmeticOnComplex(op, left, right) {
56626
+ switch (op) {
56627
+ case "add":
56628
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot add complex values with incompatible units");
56629
+ return definite({
56630
+ kind: "complex",
56631
+ re: left.re + right.re,
56632
+ im: left.im + right.im,
56633
+ unit: left.unit
56634
+ });
56635
+ case "subtract":
56636
+ if (!unitsEqual(left.unit, right.unit)) return indeterminate("wrong-type", "cannot subtract complex values with incompatible units");
56637
+ return definite({
56638
+ kind: "complex",
56639
+ re: left.re - right.re,
56640
+ im: left.im - right.im,
56641
+ unit: left.unit
56642
+ });
56643
+ case "multiply":
56644
+ return definite(multiplyComplexValues(left, right));
56645
+ case "divide": {
56646
+ const divisorSquaredMagnitude = right.re * right.re + right.im * right.im;
56647
+ if (divisorSquaredMagnitude === 0) return indeterminate("domain-error", "division by zero");
56648
+ return definite({
56649
+ kind: "complex",
56650
+ re: (left.re * right.re + left.im * right.im) / divisorSquaredMagnitude,
56651
+ im: (left.im * right.re - left.re * right.im) / divisorSquaredMagnitude,
56652
+ unit: combineUnitsForDivide(left.unit, right.unit)
56653
+ });
56654
+ }
56655
+ case "modulo":
56656
+ return indeterminate("domain-error", "'modulo' is undefined for complex values");
56657
+ default:
56658
+ throw new Error("unreachable arithmetic operator");
56659
+ }
56660
+ }
56661
+ function applyComplexPower(base, exponent) {
56662
+ if (exponent.kind !== "number" || !Number.isInteger(exponent.value)) return indeterminate("wrong-type", "'power' with a complex operand requires a real integer exponent");
56663
+ if (!isDimensionless(base.unit) || !isDimensionless(exponent.unit)) return indeterminate("wrong-type", "'power' requires dimensionless operands");
56664
+ const complexUnit = {
56665
+ kind: "complex",
56666
+ re: 1,
56667
+ im: 0,
56668
+ unit: {}
56669
+ };
56670
+ const complexBase = toComplexValue(base);
56671
+ let repeatedProduct = complexUnit;
56672
+ for (let applied = 0; applied < Math.abs(exponent.value); applied += 1) repeatedProduct = multiplyComplexValues(repeatedProduct, complexBase);
56673
+ if (exponent.value >= 0) return definite(repeatedProduct);
56674
+ return applyArithmeticOnComplex("divide", complexUnit, repeatedProduct);
56675
+ }
56676
+ function applyArithmetic(op, left, right) {
56677
+ if (left.kind === "instant" && right.kind === "instant" && op === "subtract") {
56678
+ const leftEpoch = toEpochMilliseconds(left.value);
56679
+ if (leftEpoch === void 0) return unparseableInstant(left.value);
56680
+ const rightEpoch = toEpochMilliseconds(right.value);
56681
+ if (rightEpoch === void 0) return unparseableInstant(right.value);
56682
+ return definite({
56683
+ kind: "duration",
56684
+ value: leftEpoch - rightEpoch,
56685
+ unit: "ms"
56686
+ });
56687
+ }
56688
+ if (left.kind === "instant" && right.kind === "duration" && op === "add") {
56689
+ const leftEpoch = toEpochMilliseconds(left.value);
56690
+ if (leftEpoch === void 0) return unparseableInstant(left.value);
56691
+ return instantFromEpochMilliseconds(leftEpoch + toMilliseconds(right.value, right.unit));
56692
+ }
56693
+ if (left.kind === "duration" && right.kind === "instant" && op === "add") {
56694
+ const rightEpoch = toEpochMilliseconds(right.value);
56695
+ if (rightEpoch === void 0) return unparseableInstant(right.value);
56696
+ return instantFromEpochMilliseconds(rightEpoch + toMilliseconds(left.value, left.unit));
56697
+ }
56698
+ if (left.kind === "instant" || right.kind === "instant") return indeterminate("wrong-type", `arithmetic operator '${op}' is not defined between a '${left.kind}' and a '${right.kind}' value`);
56699
+ if (left.kind === "duration" && right.kind === "duration") return applyArithmeticOnDurations(op, left, right);
56700
+ if (left.kind === "duration" || right.kind === "duration") return indeterminate("wrong-type", `arithmetic operator '${op}' is not defined between a '${left.kind}' and a '${right.kind}' value`);
56701
+ if (left.kind !== "number" && left.kind !== "complex") return indeterminate("wrong-type", `arithmetic requires numeric operands; got a '${left.kind}' value`);
56702
+ if (right.kind !== "number" && right.kind !== "complex") return indeterminate("wrong-type", `arithmetic requires numeric operands; got a '${right.kind}' value`);
56703
+ if (left.kind === "complex" || right.kind === "complex") {
56704
+ if (op === "power") return applyComplexPower(left, right);
56705
+ return applyArithmeticOnComplex(op, toComplexValue(left), toComplexValue(right));
56706
+ }
56707
+ return applyArithmeticOnNumbers(op, left, right);
56708
+ }
56709
+ function checkReferenceUnit(expectedUnit, resolvedValue) {
56710
+ if (expectedUnit === void 0) return void 0;
56711
+ if (resolvedValue.kind !== "number" && resolvedValue.kind !== "complex") return indeterminate("wrong-type", "a unit was expected on a reference that resolved to a non-numeric value");
56712
+ if (!unitsEqual(expectedUnit, resolvedValue.unit)) return indeterminate("wrong-type", "the resolved value's unit does not match the reference's expected unit");
56713
+ }
56714
+ function invokeRegisteredFunction(functions, fnName, args) {
56715
+ const fn = Object.hasOwn(functions, fnName) ? functions[fnName] : void 0;
56716
+ if (fn === void 0) return indeterminate("wrong-type", `no function registered under the name '${fnName}'`);
56717
+ const outcome = fn(args);
56718
+ if ("domainError" in outcome) return indeterminate("domain-error", outcome.domainError);
56719
+ return definite(outcome);
56720
+ }
56721
+
56722
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator.js
56723
+ function* evaluatePredicateInternal(node2, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth) {
56724
+ const budgetExceeded = budget.checkNode(nestingDepth);
56725
+ if (budgetExceeded !== void 0) return budgetExceeded;
56726
+ switch (node2.kind) {
56727
+ case "not": {
56728
+ const operand = yield* evaluatePredicateInternal(node2.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56729
+ if (operand.status === "indeterminate") return operand;
56730
+ return definite(!operand.value);
56731
+ }
56732
+ case "and": {
56733
+ const [left, right] = yield* all([evaluatePredicateInternal(node2.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluatePredicateInternal(node2.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
56734
+ return combineAnd(left, right);
56735
+ }
56736
+ case "or": {
56737
+ const [left, right] = yield* all([evaluatePredicateInternal(node2.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluatePredicateInternal(node2.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
56738
+ return combineOr(left, right);
56739
+ }
56740
+ case "allOf":
56741
+ return (yield* all(node2.operands.map((operand) => evaluatePredicateInternal(operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)))).reduce(combineAnd, definite(true));
56742
+ case "anyOf":
56743
+ return (yield* all(node2.operands.map((operand) => evaluatePredicateInternal(operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)))).reduce(combineOr, definite(false));
56744
+ case "compare": {
56745
+ const [left, right] = yield* all([evaluateValueInternal(node2.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node2.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
56746
+ if (left.status === "indeterminate") return left;
56747
+ if (right.status === "indeterminate") return right;
56748
+ return compareValues(node2.op, left.value, right.value);
56749
+ }
56750
+ case "textCompare": {
56751
+ const [left, right] = yield* all([evaluateValueInternal(node2.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node2.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
56752
+ if (left.status === "indeterminate") return left;
56753
+ if (right.status === "indeterminate") return right;
56754
+ return compareText(node2.op, left.value, right.value);
56755
+ }
56756
+ case "memberOf": {
56757
+ const operandResult = yield* evaluateValueInternal(node2.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56758
+ if (operandResult.status === "indeterminate") return operandResult;
56759
+ const candidateOutcomes = yield* all(node2.candidates.map(function* (candidate) {
56760
+ const candidateResult = yield* evaluateValueInternal(candidate, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56761
+ if (candidateResult.status === "indeterminate") return candidateResult;
56762
+ return computeMembershipMatch(operandResult.value, candidateResult.value);
56763
+ }));
56764
+ for (const outcome of candidateOutcomes) if (outcome.status === "definite" && outcome.value) return definite(node2.op === "in");
56765
+ const reason = firstIndeterminate(...candidateOutcomes);
56766
+ if (reason !== void 0) return {
56767
+ status: "indeterminate",
56768
+ reason
56769
+ };
56770
+ return definite(node2.op === "notIn");
56771
+ }
56772
+ case "exists": {
56773
+ const operandResult = yield* evaluateValueInternal(node2.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56774
+ if (operandResult.status === "indeterminate" && operandResult.reason.code === "not-found") return definite(false);
56775
+ return definite(true);
56776
+ }
56777
+ case "some":
56778
+ case "every": {
56779
+ const participating = yield* resolveParticipatingItems(evaluatePredicateInternal, node2.collection, node2.filter, context, resolvers, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56780
+ const votes = (yield* all(participating.map(function* ({ item, filterOutcome }) {
56781
+ if (filterOutcome === "exclude") return void 0;
56782
+ if (filterOutcome !== "include") return filterOutcome;
56783
+ return yield* evaluatePredicateInternal(node2.item, item, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56784
+ }))).filter((vote) => vote !== void 0);
56785
+ const combine = node2.kind === "some" ? combineOr : combineAnd;
56786
+ const identity = node2.kind === "some" ? definite(false) : definite(true);
56787
+ return votes.reduce(combine, identity);
56788
+ }
56789
+ case "treeReference": {
56790
+ if (resolvers.resolveTree === void 0) return indeterminate("wrong-type", "no tree resolver registered for treeReference nodes");
56791
+ const keyString = JSON.stringify(node2.key);
56792
+ if (visitedTreeKeys.has(keyString)) return indeterminate("domain-error", "circular treeReference detected");
56793
+ if (treeReferenceDepth >= 100) return indeterminate("domain-error", `treeReference chain exceeds the maximum depth of ${100 .toString()}`);
56794
+ const resolution = yield* wait(resolvers.resolveTree(node2.key, context));
56795
+ if (!resolution.found) return indeterminate("not-found", "treeReference key did not resolve to a tree");
56796
+ const parsed = PredicateNodeSchema.safeParse(resolution.node);
56797
+ if (!parsed.success) return indeterminate("wrong-type", "the referenced tree is not a valid PredicateNode");
56798
+ return yield* evaluatePredicateInternal(parsed.data, context, resolvers, accumulator, functions, /* @__PURE__ */ new Set([...visitedTreeKeys, keyString]), treeReferenceDepth + 1, budget, nestingDepth + 1);
56799
+ }
56800
+ default:
56801
+ throw new Error("unreachable predicate node kind");
56802
+ }
56803
+ }
56804
+ function* evaluateValueInternal(node2, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth) {
56805
+ const budgetExceeded = budget.checkNode(nestingDepth);
56806
+ if (budgetExceeded !== void 0) return budgetExceeded;
56807
+ switch (node2.kind) {
56808
+ case "reference": {
56809
+ const resolution = yield* wait(resolvers.resolveValue(node2.key, context));
56810
+ if (!resolution.found) return indeterminate("not-found", `no value found for reference key ${JSON.stringify(node2.key)}`);
56811
+ const unitError = checkReferenceUnit(node2.unit, resolution.value);
56812
+ if (unitError !== void 0) return unitError;
56813
+ return definite(resolution.value);
56814
+ }
56815
+ case "accumulator":
56816
+ if (accumulator === void 0) return indeterminate("wrong-type", "accumulator used outside a reduce fold's combine expression");
56817
+ return definite(accumulator);
56818
+ case "call": {
56819
+ const argResults = yield* all(node2.args.map((arg) => evaluateValueInternal(arg, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)));
56820
+ const args = [];
56821
+ for (const result of argResults) {
56822
+ if (result.status === "indeterminate") return result;
56823
+ args.push(result.value);
56824
+ }
56825
+ return invokeRegisteredFunction(functions, node2.fn, args);
56826
+ }
56827
+ case "numberLiteral":
56828
+ return definite({
56829
+ kind: "number",
56830
+ value: node2.value,
56831
+ unit: node2.unit
56832
+ });
56833
+ case "textLiteral":
56834
+ return definite({
56835
+ kind: "text",
56836
+ value: node2.value
56837
+ });
56838
+ case "booleanLiteral":
56839
+ return definite({
56840
+ kind: "boolean",
56841
+ value: node2.value
56842
+ });
56843
+ case "instantLiteral":
56844
+ return definite({
56845
+ kind: "instant",
56846
+ value: node2.value
56847
+ });
56848
+ case "durationLiteral":
56849
+ return definite({
56850
+ kind: "duration",
56851
+ value: node2.value,
56852
+ unit: node2.unit
56853
+ });
56854
+ case "complexLiteral":
56855
+ if ("re" in node2) return definite({
56856
+ kind: "complex",
56857
+ re: node2.re,
56858
+ im: node2.im,
56859
+ unit: node2.unit
56860
+ });
56861
+ return definite(complexFromPolar(node2.magnitude, node2.phase, node2.unit));
56862
+ case "arithmetic": {
56863
+ const [left, right] = yield* all([evaluateValueInternal(node2.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node2.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
56864
+ if (left.status === "indeterminate") return left;
56865
+ if (right.status === "indeterminate") return right;
56866
+ return applyArithmetic(node2.op, left.value, right.value);
56867
+ }
56868
+ case "negate": {
56869
+ const operand = yield* evaluateValueInternal(node2.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56870
+ if (operand.status === "indeterminate") return operand;
56871
+ return applyNegate(operand.value);
56872
+ }
56873
+ case "lookup": {
56874
+ const keyResults = yield* all(node2.keys.map((key) => evaluateValueInternal(key, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)));
56875
+ const keyValues = [];
56876
+ for (const result of keyResults) {
56877
+ if (result.status === "indeterminate") return result;
56878
+ keyValues.push(result.value);
56879
+ }
56880
+ const resolution = yield* wait(resolvers.resolveLookup(node2.table, keyValues, context));
56881
+ if (!resolution.found) return indeterminate("not-found", `no match found in lookup table ${JSON.stringify(node2.table)}`);
56882
+ return definite(resolution.value);
56883
+ }
56884
+ case "conditional": {
56885
+ if ((node2.hitPolicy ?? "first") === "first") {
56886
+ for (const { when, then } of node2.cases) {
56887
+ const whenResult = yield* evaluatePredicateInternal(when, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56888
+ if (whenResult.status === "indeterminate") return whenResult;
56889
+ if (whenResult.value) return yield* evaluateValueInternal(then, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56890
+ }
56891
+ return yield* evaluateValueInternal(node2.fallback, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56892
+ }
56893
+ const evaluatedCases = yield* all(node2.cases.map(function* ({ when, then }) {
56894
+ return {
56895
+ then,
56896
+ whenResult: yield* evaluatePredicateInternal(when, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)
56897
+ };
56898
+ }));
56899
+ const matches = evaluatedCases.filter(({ whenResult }) => whenResult.status === "definite" && whenResult.value);
56900
+ if (matches.length >= 2) return indeterminate("domain-error", "more than one case matched under the 'unique' hit policy");
56901
+ const reason = firstIndeterminate(...evaluatedCases.map(({ whenResult }) => whenResult));
56902
+ if (reason !== void 0) return {
56903
+ status: "indeterminate",
56904
+ reason
56905
+ };
56906
+ const [match] = matches;
56907
+ if (match === void 0) return yield* evaluateValueInternal(node2.fallback, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56908
+ return yield* evaluateValueInternal(match.then, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56909
+ }
56910
+ case "fold": {
56911
+ const participating = yield* resolveParticipatingItems(evaluatePredicateInternal, node2.collection, node2.filter, context, resolvers, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56912
+ const filterIndeterminateReason = firstFilterIndeterminate(participating);
56913
+ if (filterIndeterminateReason !== void 0) return {
56914
+ status: "indeterminate",
56915
+ reason: filterIndeterminateReason
56916
+ };
56917
+ const includedItems = participating.filter(({ filterOutcome }) => filterOutcome === "include").map(({ item }) => item);
56918
+ if (node2.combiner.mode === "reduce") {
56919
+ const initialResult = yield* evaluateValueInternal(node2.combiner.initial, context, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56920
+ if (initialResult.status === "indeterminate") return initialResult;
56921
+ let runningAccumulator = initialResult.value;
56922
+ for (const item of includedItems) {
56923
+ const stepResult = yield* evaluateValueInternal(node2.combiner.combine, item, resolvers, runningAccumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56924
+ if (stepResult.status === "indeterminate") return stepResult;
56925
+ runningAccumulator = stepResult.value;
56926
+ }
56927
+ return definite(runningAccumulator);
56928
+ }
56929
+ if (includedItems.length === 0) return indeterminate("domain-error", `'${node2.combiner.mode}' has no participating items to seed a running result from`);
56930
+ const dominatesOp = node2.combiner.mode === "max" ? "gt" : "lt";
56931
+ let runningExtremum;
56932
+ for (const item of includedItems) {
56933
+ const itemResult = yield* evaluateValueInternal(node2.combiner.item, item, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
56934
+ if (itemResult.status === "indeterminate") return itemResult;
56935
+ if (runningExtremum === void 0) {
56936
+ runningExtremum = itemResult.value;
56937
+ continue;
56938
+ }
56939
+ const comparison = compareValues(dominatesOp, itemResult.value, runningExtremum);
56940
+ if (comparison.status === "indeterminate") return comparison;
56941
+ if (comparison.value) runningExtremum = itemResult.value;
56942
+ }
56943
+ if (runningExtremum === void 0) throw new Error("unreachable: max/min over a non-empty participating list produced no running result");
56944
+ return definite(runningExtremum);
56945
+ }
56946
+ case "delegate": {
56947
+ if (resolvers.resolveDelegate === void 0) return indeterminate("wrong-type", `no delegate handler registered for external system '${node2.system}'`);
56948
+ const resolution = yield* wait(resolvers.resolveDelegate(node2.system, node2.payload, context));
56949
+ if (!resolution.found) return indeterminate("not-found", `delegate handler for external system '${node2.system}' reported no value`);
56950
+ return definite(resolution.value);
56951
+ }
56952
+ case "treeReference": {
56953
+ if (resolvers.resolveTree === void 0) return indeterminate("wrong-type", "no tree resolver registered for treeReference nodes");
56954
+ const keyString = JSON.stringify(node2.key);
56955
+ if (visitedTreeKeys.has(keyString)) return indeterminate("domain-error", "circular treeReference detected");
56956
+ if (treeReferenceDepth >= 100) return indeterminate("domain-error", `treeReference chain exceeds the maximum depth of ${100 .toString()}`);
56957
+ const resolution = yield* wait(resolvers.resolveTree(node2.key, context));
56958
+ if (!resolution.found) return indeterminate("not-found", "treeReference key did not resolve to a tree");
56959
+ const parsed = ExpressionNodeSchema.safeParse(resolution.node);
56960
+ if (!parsed.success) return indeterminate("wrong-type", "the referenced tree is not a valid ExpressionNode");
56961
+ return yield* evaluateValueInternal(parsed.data, context, resolvers, accumulator, functions, /* @__PURE__ */ new Set([...visitedTreeKeys, keyString]), treeReferenceDepth + 1, budget, nestingDepth + 1);
56962
+ }
56963
+ default:
56964
+ throw new Error("unreachable expression node kind");
56965
+ }
56966
+ }
56967
+
56968
+ // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/evaluator-factory.js
56969
+ function createEvaluator({ functions = emptyFunctionRegistry, maxNodes = DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
56970
+ return {
56971
+ evaluatePredicate: async (node2, context, resolvers) => runAsync(evaluatePredicateInternal(node2, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
56972
+ evaluateValue: async (node2, context, resolvers) => runAsync(evaluateValueInternal(node2, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0))
56973
+ };
56974
+ }
56975
+ function createSyncEvaluator({ functions = emptyFunctionRegistry, maxNodes = DEFAULT_MAX_EVALUATION_NODES, maxNestingDepth = 500 }) {
56976
+ return {
56977
+ evaluatePredicate: (node2, context, resolvers) => runSync(evaluatePredicateInternal(node2, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0)),
56978
+ evaluateValue: (node2, context, resolvers) => runSync(evaluateValueInternal(node2, context, resolvers, void 0, functions, /* @__PURE__ */ new Set(), 0, createEvaluationBudget(maxNodes, maxNestingDepth), 0))
56979
+ };
56980
+ }
56981
+ var { evaluatePredicate, evaluateValue } = createEvaluator({});
56982
+
56983
+ // src/config/schema.ts
55151
56984
  var CATEGORY_NAMES = ["secret", "runtime", "history", "knowledge", "settings"];
55152
56985
  var OVERRIDABLE_CATEGORIES = ["runtime", "history", "knowledge", "settings"];
55153
56986
  function isOverridableCategory(name) {
@@ -55157,11 +56990,11 @@ function isCategoryName(name) {
55157
56990
  return CATEGORY_NAMES.some((category) => category === name);
55158
56991
  }
55159
56992
  function expandAllCategoryKey(pairs) {
55160
- const { all: all2, ...rest } = pairs;
55161
- if (all2 === void 0) {
56993
+ const { all: all3, ...rest } = pairs;
56994
+ if (all3 === void 0) {
55162
56995
  return { ...rest };
55163
56996
  }
55164
- const expanded = Object.fromEntries(OVERRIDABLE_CATEGORIES.filter((category) => !all2 || category !== "runtime").map((category) => [category, all2]));
56997
+ const expanded = Object.fromEntries(OVERRIDABLE_CATEGORIES.filter((category) => !all3 || category !== "runtime").map((category) => [category, all3]));
55165
56998
  return { ...expanded, ...rest };
55166
56999
  }
55167
57000
  var CategoryMapSchema = external_exports.strictObject({
@@ -55173,13 +57006,14 @@ var CategoryMapSchema = external_exports.strictObject({
55173
57006
  }).transform((input2) => expandAllCategoryKey(input2));
55174
57007
  var DURATION_RE = /^(?:0|[1-9][0-9]*)(?:ms|s|m|h|d|w)$/;
55175
57008
  var DurationSchema = external_exports.string().regex(DURATION_RE);
55176
- var WhenSchema = external_exports.strictObject({
57009
+ var WhenConditionObjectSchema = external_exports.strictObject({
55177
57010
  newerThan: DurationSchema.optional(),
55178
57011
  olderThan: DurationSchema.optional(),
55179
57012
  maxSizeBytes: external_exports.int().positive().optional(),
55180
57013
  branch: external_exports.string().min(1).optional(),
55181
57014
  env: external_exports.record(external_exports.string().min(1), external_exports.string()).optional()
55182
57015
  });
57016
+ var WhenSchema = external_exports.union([WhenConditionObjectSchema, PredicateNodeSchema]);
55183
57017
  var EntryValueSchema = external_exports.union([
55184
57018
  external_exports.boolean(),
55185
57019
  external_exports.strictObject({ value: external_exports.boolean(), when: WhenSchema })
@@ -59055,7 +60889,6 @@ function planReconciliation(params) {
59055
60889
  }
59056
60890
 
59057
60891
  // src/resolve/conditions.ts
59058
- var import_picomatch2 = __toESM(require_picomatch2(), 1);
59059
60892
  var MILLISECONDS_PER_UNIT = Object.freeze({
59060
60893
  ms: 1,
59061
60894
  s: 1e3,
@@ -59080,62 +60913,85 @@ function parseDuration(value2) {
59080
60913
  }
59081
60914
  return Number(count) * multiplier;
59082
60915
  }
59083
- function matchBranch(pattern, branch, detached = false) {
59084
- if (branch === void 0 || branch === "" || detached) {
59085
- return false;
60916
+ var evaluator = createSyncEvaluator({});
60917
+ function resolversOf(context) {
60918
+ const values = {
60919
+ now: context.nowMs,
60920
+ ...context.fact?.latestMtimeMs === void 0 ? {} : { "entry.latestMtimeMs": context.fact.latestMtimeMs },
60921
+ ...context.fact?.totalSizeBytes === void 0 ? {} : { "entry.totalSizeBytes": context.fact.totalSizeBytes },
60922
+ ...context.branch === void 0 ? {} : { "repo.branch": context.branch },
60923
+ "repo.detached": context.branchDetached ?? false
60924
+ };
60925
+ return {
60926
+ resolveValue: (key) => {
60927
+ const wrap = (value3) => ({ found: true, value: typeof value3 === "number" ? { kind: "number", value: value3 } : typeof value3 === "string" ? { kind: "text", value: value3 } : { kind: "boolean", value: value3 } });
60928
+ if (typeof key !== "string") {
60929
+ return { found: false };
60930
+ }
60931
+ if (key.startsWith("env.")) {
60932
+ const value3 = context.env[key.slice("env.".length)];
60933
+ return value3 === void 0 ? { found: false } : wrap(value3);
60934
+ }
60935
+ const value2 = values[key];
60936
+ return value2 === void 0 ? { found: false } : wrap(value2);
60937
+ },
60938
+ // This embedding provides the reference namespace only: a tree that asks for a lookup or a collection finds neither, which the evaluator carries as indeterminate rather than letting the tree pretend an answer.
60939
+ resolveLookup: () => ({ found: false }),
60940
+ resolveCollection: () => []
60941
+ };
60942
+ }
60943
+ function fieldPredicate(field, when, context) {
60944
+ switch (field) {
60945
+ case "newerThan": {
60946
+ const window = parseDuration(when.newerThan ?? "");
60947
+ return { kind: "compare", op: "gte", left: { kind: "reference", key: "entry.latestMtimeMs" }, right: { kind: "numberLiteral", value: context.nowMs - window } };
60948
+ }
60949
+ case "olderThan": {
60950
+ const window = parseDuration(when.olderThan ?? "");
60951
+ return { kind: "compare", op: "lt", left: { kind: "reference", key: "entry.latestMtimeMs" }, right: { kind: "numberLiteral", value: context.nowMs - window } };
60952
+ }
60953
+ case "maxSizeBytes":
60954
+ return { kind: "compare", op: "lte", left: { kind: "reference", key: "entry.totalSizeBytes" }, right: { kind: "numberLiteral", value: when.maxSizeBytes ?? 0 } };
60955
+ case "branch":
60956
+ return { kind: "allOf", operands: [{ kind: "textCompare", op: "portableMatches", left: { kind: "reference", key: "repo.branch" }, right: { kind: "textLiteral", value: when.branch ?? "" } }, { kind: "compare", op: "eq", left: { kind: "reference", key: "repo.detached" }, right: { kind: "booleanLiteral", value: false } }] };
60957
+ case "env": {
60958
+ const entries = Object.entries(when.env ?? {});
60959
+ return { kind: "allOf", operands: entries.map(([name, expected]) => ({ kind: "textCompare", op: "equals", left: { kind: "reference", key: `env.${name}` }, right: { kind: "textLiteral", value: expected } })) };
60960
+ }
59086
60961
  }
59087
- return (0, import_picomatch2.default)(pattern, { dot: true, nocase: false })(branch);
60962
+ return { kind: "allOf", operands: [] };
59088
60963
  }
59089
60964
  function evaluateWhen(when, context) {
59090
60965
  if (when === void 0) {
59091
- return { passed: true, checked: [], failed: [] };
60966
+ return { status: "definite", passed: true, checked: [], failed: [] };
60967
+ }
60968
+ if ("kind" in when) {
60969
+ const result = evaluator.evaluatePredicate(when, void 0, resolversOf(context));
60970
+ return result.status === "indeterminate" ? { status: "indeterminate", reason: result.reason.message, checked: ["predicate"] } : { status: "definite", passed: result.value, checked: ["predicate"], failed: result.value ? [] : ["predicate"] };
59092
60971
  }
59093
60972
  const checked = [];
59094
60973
  const failed = [];
59095
- if (when.newerThan !== void 0) {
59096
- checked.push("newerThan");
59097
- const window = parseDuration(when.newerThan);
59098
- const latest = context.fact?.latestMtimeMs;
59099
- if (latest === void 0 || context.nowMs - latest > window) {
59100
- failed.push("newerThan");
59101
- }
59102
- }
59103
- if (when.olderThan !== void 0) {
59104
- checked.push("olderThan");
59105
- const window = parseDuration(when.olderThan);
59106
- const latest = context.fact?.latestMtimeMs;
59107
- if (latest === void 0 || context.nowMs - latest <= window) {
59108
- failed.push("olderThan");
59109
- }
59110
- }
59111
- if (when.maxSizeBytes !== void 0) {
59112
- checked.push("maxSizeBytes");
59113
- const total = context.fact?.totalSizeBytes;
59114
- if (total === void 0 || total > when.maxSizeBytes) {
59115
- failed.push("maxSizeBytes");
60974
+ for (const field of ["newerThan", "olderThan", "maxSizeBytes", "branch", "env"]) {
60975
+ if (when[field] === void 0) {
60976
+ continue;
59116
60977
  }
59117
- }
59118
- if (when.branch !== void 0) {
59119
- checked.push("branch");
59120
- if (!matchBranch(when.branch, context.branch, context.branchDetached ?? false)) {
59121
- failed.push("branch");
60978
+ checked.push(field);
60979
+ const result = evaluator.evaluatePredicate(fieldPredicate(field, when, context), void 0, resolversOf(context));
60980
+ if (result.status === "indeterminate") {
60981
+ return { status: "indeterminate", reason: result.reason.message, checked };
59122
60982
  }
59123
- }
59124
- if (when.env !== void 0) {
59125
- checked.push("env");
59126
- const mismatch = Object.entries(when.env).some(([name, expected]) => context.env[name] !== expected);
59127
- if (mismatch) {
59128
- failed.push("env");
60983
+ if (!result.value) {
60984
+ failed.push(field);
59129
60985
  }
59130
60986
  }
59131
- return { passed: failed.length === 0, checked, failed };
60987
+ return { status: "definite", passed: failed.length === 0, checked, failed };
59132
60988
  }
59133
60989
  function isVacuousWhen(when) {
59134
- return when !== void 0 && Object.keys(when).length === 0;
60990
+ return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
59135
60991
  }
59136
60992
 
59137
60993
  // src/resolve/match.ts
59138
- var import_picomatch3 = __toESM(require_picomatch2(), 1);
60994
+ var import_picomatch2 = __toESM(require_picomatch2(), 1);
59139
60995
 
59140
60996
  // src/resolve/projects.ts
59141
60997
  var NON_ALPHANUMERIC = /[^A-Za-z0-9]/g;
@@ -59311,8 +61167,8 @@ function canonicaliseEntryKey(key, options) {
59311
61167
  }
59312
61168
  function compileMatcher(canonicalPattern) {
59313
61169
  const options = { dot: true, nocase: false };
59314
- const self = (0, import_picomatch3.default)(canonicalPattern, options);
59315
- const subtree = (0, import_picomatch3.default)(`${canonicalPattern}/**`, options);
61170
+ const self = (0, import_picomatch2.default)(canonicalPattern, options);
61171
+ const subtree = (0, import_picomatch2.default)(`${canonicalPattern}/**`, options);
59316
61172
  return (relPath) => self(relPath) || subtree(relPath);
59317
61173
  }
59318
61174
  function patternCouldReachUnder(canonicalPattern, dir) {
@@ -59335,7 +61191,7 @@ function couldReach(patternSegments, dirSegments) {
59335
61191
  if (head === void 0 || dirHead === void 0) {
59336
61192
  return true;
59337
61193
  }
59338
- if (!(0, import_picomatch3.default)(head, { dot: true, nocase: false })(dirHead)) {
61194
+ if (!(0, import_picomatch2.default)(head, { dot: true, nocase: false })(dirHead)) {
59339
61195
  return false;
59340
61196
  }
59341
61197
  return couldReach(restPattern, restDir);
@@ -59502,10 +61358,10 @@ function selectRule(relPath, flattened, context) {
59502
61358
  ...context.branchDetached === void 0 ? {} : { branchDetached: context.branchDetached },
59503
61359
  env: context.env
59504
61360
  });
59505
- if (evaluation.passed) {
61361
+ if (evaluation.status === "definite" && evaluation.passed) {
59506
61362
  return { rule, eliminated };
59507
61363
  }
59508
- eliminated.push({ rule, failed: evaluation.failed });
61364
+ eliminated.push({ rule, failed: evaluation.status === "definite" ? evaluation.failed : [`${evaluation.checked.join(", ")} could not be decided: ${evaluation.reason}`] });
59509
61365
  }
59510
61366
  return { eliminated };
59511
61367
  }
@@ -59739,7 +61595,10 @@ function planFarm(params) {
59739
61595
  var ENTER_EVERYTHING = () => true;
59740
61596
  function readsSubtreeAggregates(rule) {
59741
61597
  const when = rule.when;
59742
- return when !== void 0 && (when.newerThan !== void 0 || when.olderThan !== void 0 || when.maxSizeBytes !== void 0);
61598
+ if (when === void 0) {
61599
+ return false;
61600
+ }
61601
+ return "kind" in when || when.newerThan !== void 0 || when.olderThan !== void 0 || when.maxSizeBytes !== void 0;
59743
61602
  }
59744
61603
  function hasUnboundedDepth(pattern) {
59745
61604
  return pattern.includes("**") || /[{(]/.test(pattern);
@@ -59759,11 +61618,11 @@ function couldMatchBeneath(rule, dirRel) {
59759
61618
  return prefix === "" || prefix.startsWith(`${dirRel}/`) || dirRel.startsWith(prefix);
59760
61619
  }
59761
61620
  function descendPolicy(rules) {
59762
- const all2 = [...rules];
59763
- if (all2.some(readsSubtreeAggregates)) {
61621
+ const all3 = [...rules];
61622
+ if (all3.some(readsSubtreeAggregates)) {
59764
61623
  return ENTER_EVERYTHING;
59765
61624
  }
59766
- return (dirRel) => all2.some((rule) => couldMatchBeneath(rule, dirRel));
61625
+ return (dirRel) => all3.some((rule) => couldMatchBeneath(rule, dirRel));
59767
61626
  }
59768
61627
  function enterRulesAnd(policy, target) {
59769
61628
  if (target === void 0 || target === "") {
@@ -61796,7 +63655,7 @@ function registerIdentityCommand(program2, deps) {
61796
63655
  // package.json
61797
63656
  var package_default = {
61798
63657
  name: "agent-shim",
61799
- version: "8.31.0",
63658
+ version: "8.33.0",
61800
63659
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
61801
63660
  license: "MIT",
61802
63661
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -61852,6 +63711,7 @@ var package_default = {
61852
63711
  commander: "^15.0.0",
61853
63712
  cosmiconfig: "^10.0.1",
61854
63713
  picomatch: "^4.0.7",
63714
+ trilean: "1.7.1",
61855
63715
  undici: "7.29.1",
61856
63716
  zod: "^4.6.1"
61857
63717
  },
@@ -62512,7 +64372,7 @@ function createJsonScanner() {
62512
64372
  capture = "";
62513
64373
  inValue = false;
62514
64374
  };
62515
- const step = (char) => {
64375
+ const step2 = (char) => {
62516
64376
  if (capturing !== void 0 && !(depth === 1 && !inString && (char === "," || char === "}"))) {
62517
64377
  capture += char;
62518
64378
  }
@@ -62579,7 +64439,7 @@ function createJsonScanner() {
62579
64439
  return {
62580
64440
  push: (text2) => {
62581
64441
  for (const char of text2) {
62582
- step(char);
64442
+ step2(char);
62583
64443
  }
62584
64444
  },
62585
64445
  result: () => {
@@ -62775,10 +64635,10 @@ function windowBlockedUntil(windows) {
62775
64635
  const resets = windows.flatMap((window) => window.status === "rejected" && window.resetsAtMs !== void 0 ? [window.resetsAtMs] : []);
62776
64636
  return resets.length === 0 ? void 0 : Math.max(...resets);
62777
64637
  }
62778
- function fiveHourBurn(records) {
64638
+ function windowBurn(records, which) {
62779
64639
  const points = [];
62780
64640
  for (const record2 of records) {
62781
- const window = record2.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record2.rateLimitHeaders)?.fiveHour;
64641
+ const window = record2.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record2.rateLimitHeaders)?.[which];
62782
64642
  if (window?.utilization !== void 0 && window.resetsAt !== void 0) {
62783
64643
  points.push({ resetsAt: window.resetsAt, point: { atMs: Date.parse(record2.at), utilization: window.utilization } });
62784
64644
  }
@@ -62872,11 +64732,16 @@ function assessIdentity(member, nowMs) {
62872
64732
  const score = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR);
62873
64733
  const fiveRemaining = five?.utilization === void 0 ? void 0 : Math.max(0, 1 - five.utilization);
62874
64734
  const fiveUntil = five?.resetsAtMs === void 0 ? FIVE_HOUR_WINDOW_MS : Math.max(five.resetsAtMs - nowMs, MS_PER_SECOND3);
62875
- const burn = fiveHourBurn(member.records);
64735
+ const burn = windowBurn(member.records, "fiveHour");
64736
+ const sevenRemaining = seven?.utilization === void 0 ? void 0 : Math.max(0, 1 - seven.utilization);
64737
+ const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND3);
64738
+ const sevenDayBurn = windowBurn(member.records, "sevenDay");
62876
64739
  return {
62877
64740
  candidate: { ...base, class: "scored", score, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
62878
64741
  ...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
62879
- ...burn === void 0 ? {} : { burn }
64742
+ ...burn === void 0 ? {} : { burn },
64743
+ ...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
64744
+ ...sevenDayBurn === void 0 ? {} : { sevenDayBurn }
62880
64745
  };
62881
64746
  }
62882
64747
  function rankPool(input2) {
@@ -62887,14 +64752,27 @@ function rankPool(input2) {
62887
64752
  const candidates = assessments.map((assessment) => {
62888
64753
  const { candidate, fiveHour, burn } = assessment;
62889
64754
  const pace = burn ?? (sharedDemand === void 0 ? void 0 : sharedDemand / capacityOf(candidate.plan));
62890
- if (candidate.class !== "scored" || fiveHour === void 0 || pace === void 0) {
64755
+ const { sevenDay, sevenDayBurn } = assessment;
64756
+ if (candidate.class !== "scored") {
62891
64757
  return { ...candidate, feasible: true };
62892
64758
  }
62893
- const runsDryInMs = fiveHour.remaining / pace;
62894
- if (runsDryInMs >= fiveHour.untilResetMs) {
64759
+ const drySpots = [];
64760
+ if (fiveHour !== void 0 && pace !== void 0) {
64761
+ const runsDryInMs = fiveHour.remaining / pace;
64762
+ if (runsDryInMs < fiveHour.untilResetMs) {
64763
+ drySpots.push(`5h window would run dry in ${formatAge(runsDryInMs)}, before it resets in ${formatAge(fiveHour.untilResetMs)}`);
64764
+ }
64765
+ }
64766
+ if (sevenDay !== void 0 && sevenDayBurn !== void 0) {
64767
+ const runsDryInMs = sevenDay.remaining / sevenDayBurn;
64768
+ if (runsDryInMs < sevenDay.untilResetMs) {
64769
+ drySpots.push(`7d window would run dry in ${formatAge(runsDryInMs)}, before it resets in ${formatAge(sevenDay.untilResetMs)}`);
64770
+ }
64771
+ }
64772
+ if (drySpots.length === 0) {
62895
64773
  return { ...candidate, feasible: true };
62896
64774
  }
62897
- return { ...candidate, feasible: false, reasons: [`5h window would run dry in ${formatAge(runsDryInMs)}, before it resets in ${formatAge(fiveHour.untilResetMs)}`, ...candidate.reasons] };
64775
+ return { ...candidate, feasible: false, reasons: [...drySpots, ...candidate.reasons] };
62898
64776
  });
62899
64777
  const ordered = input2.preference === "listed" ? [...candidates] : [...candidates].sort(
62900
64778
  (left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(right.feasible) - Number(left.feasible) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
@@ -62902,7 +64780,8 @@ function rankPool(input2) {
62902
64780
  const sticky = input2.sticky;
62903
64781
  const stickyIndex = sticky === void 0 ? -1 : ordered.findIndex((candidate) => candidate.identity === sticky.identity);
62904
64782
  const stickyCandidate = ordered[stickyIndex];
62905
- if (sticky !== void 0 && stickyCandidate?.class === "scored" && stickyCandidate.feasible) {
64783
+ const keepSticky = stickyCandidate?.class === "scored" && stickyCandidate.feasible;
64784
+ if (sticky !== void 0 && keepSticky) {
62906
64785
  const ageMs = nowMs - Date.parse(sticky.at);
62907
64786
  const warm = ageMs <= PROMPT_CACHE_TTL_MS;
62908
64787
  if (input2.resuming || warm) {
@@ -62911,12 +64790,14 @@ function rankPool(input2) {
62911
64790
  ordered.unshift({ ...stickyCandidate, reasons: [why, ...stickyCandidate.reasons] });
62912
64791
  }
62913
64792
  }
64793
+ const movedOff = sticky !== void 0 && input2.resuming && !keepSticky ? { identity: sticky.identity, reason: stickyCandidate?.reasons[0] ?? "no longer among the pool's members" } : void 0;
62914
64794
  const pick2 = ordered.find((candidate) => candidate.class !== "ineligible");
62915
64795
  const returns = ordered.flatMap((candidate) => candidate.blockedUntilMs === void 0 ? [] : [{ identity: candidate.identity, atMs: candidate.blockedUntilMs }]);
62916
64796
  const earliestReturn = returns.length === 0 ? void 0 : returns.reduce((soonest, entry) => entry.atMs < soonest.atMs ? entry : soonest);
62917
64797
  return {
62918
64798
  candidates: ordered,
62919
- ...pick2 === void 0 ? { ...earliestReturn === void 0 ? {} : { earliestReturn } } : { pick: pick2 }
64799
+ ...pick2 === void 0 ? { ...earliestReturn === void 0 ? {} : { earliestReturn } } : { pick: pick2 },
64800
+ ...movedOff === void 0 || pick2 === void 0 ? {} : { movedOff }
62920
64801
  };
62921
64802
  }
62922
64803
 
@@ -63332,6 +65213,7 @@ function collectPoolPick(params) {
63332
65213
  candidates: ranking.candidates.map(candidateView),
63333
65214
  missing: missing.map(({ identity }) => identity),
63334
65215
  ...ranking.earliestReturn === void 0 ? {} : { earliestReturn: { identity: ranking.earliestReturn.identity, at: new Date(ranking.earliestReturn.atMs).toISOString() } },
65216
+ ...ranking.movedOff === void 0 ? {} : { movedOff: ranking.movedOff },
63335
65217
  ...sticky.problem === void 0 ? {} : { stickyProblem: sticky.problem }
63336
65218
  };
63337
65219
  }
@@ -69611,6 +71493,8 @@ var PoolPickReportSchema = external_exports.strictObject({
69611
71493
  missing: external_exports.array(external_exports.string()),
69612
71494
  /** When nothing can be picked, the soonest any member returns. */
69613
71495
  earliestReturn: external_exports.strictObject({ identity: external_exports.string(), at: external_exports.iso.datetime() }).optional(),
71496
+ /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
71497
+ movedOff: external_exports.strictObject({ identity: external_exports.string(), reason: external_exports.string() }).optional(),
69614
71498
  /** Why the last-pick record could not be read, when that is the case. */
69615
71499
  stickyProblem: external_exports.string().optional()
69616
71500
  });
@@ -73084,7 +74968,7 @@ var StandardHandler = class {
73084
74968
  return runWithSpan(
73085
74969
  { name: `${request7.method} ${request7.url.pathname}` },
73086
74970
  async (span) => {
73087
- let step;
74971
+ let step2;
73088
74972
  try {
73089
74973
  return await intercept(
73090
74974
  this.interceptors,
@@ -73103,12 +74987,12 @@ var StandardHandler = class {
73103
74987
  span?.updateName(`${ORPC_NAME}.${match.path.join("/")}`);
73104
74988
  span?.setAttribute("rpc.system", ORPC_NAME);
73105
74989
  span?.setAttribute("rpc.method", match.path.join("."));
73106
- step = "decode_input";
74990
+ step2 = "decode_input";
73107
74991
  let input2 = await runWithSpan(
73108
74992
  { name: "decode_input" },
73109
74993
  () => this.codec.decode(request22, match.params, match.procedure)
73110
74994
  );
73111
- step = void 0;
74995
+ step2 = void 0;
73112
74996
  if (isAsyncIteratorObject(input2)) {
73113
74997
  input2 = asyncIteratorWithSpan(
73114
74998
  { name: "consume_event_iterator_input", signal: request22.signal },
@@ -73120,12 +75004,12 @@ var StandardHandler = class {
73120
75004
  path: match.path,
73121
75005
  interceptors: this.clientInterceptors
73122
75006
  });
73123
- step = "call_procedure";
75007
+ step2 = "call_procedure";
73124
75008
  const output2 = await client(input2, {
73125
75009
  signal: request22.signal,
73126
75010
  lastEventId: flattenHeader(request22.headers["last-event-id"])
73127
75011
  });
73128
- step = void 0;
75012
+ step2 = void 0;
73129
75013
  const response = this.codec.encode(output2, match.procedure);
73130
75014
  return {
73131
75015
  matched: true,
@@ -73134,10 +75018,10 @@ var StandardHandler = class {
73134
75018
  }
73135
75019
  );
73136
75020
  } catch (e) {
73137
- if (step !== "call_procedure") {
75021
+ if (step2 !== "call_procedure") {
73138
75022
  setSpanError(span, e);
73139
75023
  }
73140
- const error62 = step === "decode_input" && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
75024
+ const error62 = step2 === "decode_input" && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
73141
75025
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
73142
75026
  cause: e
73143
75027
  }) : toORPCError(e);
@@ -75221,17 +77105,17 @@ function createCodexRoute(ports) {
75221
77105
  const frames = async function* () {
75222
77106
  try {
75223
77107
  for await (const event of codexEvents(upstreamBody)) {
75224
- const step = relay.push(event);
75225
- for (const frame of step.frames) {
77108
+ const step2 = relay.push(event);
77109
+ for (const frame of step2.frames) {
75226
77110
  yield renderSseFrame(frame);
75227
77111
  }
75228
- if (step.completed !== void 0) {
75229
- logCompleted(step.completed.message, step.completed.usage);
77112
+ if (step2.completed !== void 0) {
77113
+ logCompleted(step2.completed.message, step2.completed.usage);
75230
77114
  return;
75231
77115
  }
75232
- if (step.failed !== void 0) {
75233
- ports.log(`${upstreamRequest.model} stream error: ${step.failed.message}`);
75234
- yield errorFrame(HTTP_STATUS.internalServerError, step.failed.message);
77116
+ if (step2.failed !== void 0) {
77117
+ ports.log(`${upstreamRequest.model} stream error: ${step2.failed.message}`);
77118
+ yield errorFrame(HTTP_STATUS.internalServerError, step2.failed.message);
75235
77119
  return;
75236
77120
  }
75237
77121
  }
@@ -75253,14 +77137,14 @@ function createCodexRoute(ports) {
75253
77137
  }
75254
77138
  try {
75255
77139
  for await (const event of codexEvents(upstreamBody)) {
75256
- const step = relay.push(event);
75257
- if (step.completed !== void 0) {
75258
- logCompleted(step.completed.message, step.completed.usage);
75259
- return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json", ...quota }, body: JSON.stringify(step.completed.message) };
77140
+ const step2 = relay.push(event);
77141
+ if (step2.completed !== void 0) {
77142
+ logCompleted(step2.completed.message, step2.completed.usage);
77143
+ return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json", ...quota }, body: JSON.stringify(step2.completed.message) };
75260
77144
  }
75261
- if (step.failed !== void 0) {
75262
- ports.log(`${upstreamRequest.model} stream error: ${step.failed.message}`);
75263
- return errorResponse(HTTP_STATUS.internalServerError, step.failed.message);
77145
+ if (step2.failed !== void 0) {
77146
+ ports.log(`${upstreamRequest.model} stream error: ${step2.failed.message}`);
77147
+ return errorResponse(HTTP_STATUS.internalServerError, step2.failed.message);
75264
77148
  }
75265
77149
  }
75266
77150
  } catch (error62) {
@@ -80682,11 +82566,11 @@ function formatRateLimit(state) {
80682
82566
  return `quota (as of ${state.observedAt}): ${[...parts, `status ${unified.status ?? "unknown"}`, ...unified.overageStatus === void 0 ? [] : [`extra usage ${unified.overageStatus}`]].join("; ")}`;
80683
82567
  }
80684
82568
  function formatLimit(limit) {
80685
- const wait = [
82569
+ const wait2 = [
80686
82570
  ...limit.resetAt === void 0 ? [] : [`resets ${limit.resetAt}`],
80687
82571
  ...limit.retryAfterSeconds === void 0 ? [] : [`retry after ${String(limit.retryAfterSeconds)}s`]
80688
82572
  ];
80689
- return `last limit: ${limit.kind} (${String(limit.status)}) at ${limit.observedAt}${limit.window === void 0 ? "" : ` on the ${limit.window} window`}${wait.length === 0 ? "" : `, ${wait.join(", ")}`}`;
82573
+ return `last limit: ${limit.kind} (${String(limit.status)}) at ${limit.observedAt}${limit.window === void 0 ? "" : ` on the ${limit.window} window`}${wait2.length === 0 ? "" : `, ${wait2.join(", ")}`}`;
80690
82574
  }
80691
82575
  var MONEY_DECIMALS = 2;
80692
82576
  var MS_PER_HOUR3 = 36e5;
@@ -81187,10 +83071,11 @@ function resolvePoolLaunch(params) {
81187
83071
  if (graph.ranking.candidates.length === 0) {
81188
83072
  return { ok: false, message: `agent-shim: no member of pool "${poolName}" is an existing identity.` };
81189
83073
  }
81190
- const { pick: pick2, earliestReturn } = graph.ranking;
83074
+ const { pick: pick2, earliestReturn, movedOff } = graph.ranking;
81191
83075
  if (pick2 !== void 0) {
81192
83076
  recordStickyPick(params.usageFs, params.paths.usagePicksFile, params.cwd, pick2.identity, nowMs);
81193
- return { ok: true, identity: pick2.identity, explanation: `pool ${poolName}: ${pick2.reasons.slice(0, REASONS_LOGGED).join("; ")}` };
83077
+ const move = movedOff === void 0 ? "" : `moved off ${movedOff.identity} (${movedOff.reason}); `;
83078
+ return { ok: true, identity: pick2.identity, explanation: `pool ${poolName}: ${move}${pick2.reasons.slice(0, REASONS_LOGGED).join("; ")}` };
81194
83079
  }
81195
83080
  if (earliestReturn === void 0) {
81196
83081
  return { ok: false, message: `agent-shim: no member of pool "${poolName}" can be picked.` };