agent-shim 8.32.0 → 8.34.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 +2054 -148
- package/dist/index.cjs +143 -61
- package/dist/index.mjs +143 -61
- package/dist/types/index.d.ts +939 -41
- package/package.json +2 -1
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,
|
|
17
|
-
for (var name in
|
|
18
|
-
__defProp(target, name, { get:
|
|
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
|
|
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
|
-
|
|
5379
|
+
range2.unshift(arr[i2].value);
|
|
5380
5380
|
}
|
|
5381
5381
|
}
|
|
5382
|
-
output2 = expandRange(
|
|
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
|
|
5750
|
+
var picomatch3 = (glob, options, returnState = false) => {
|
|
5751
5751
|
if (Array.isArray(glob)) {
|
|
5752
|
-
const fns = glob.map((input2) =>
|
|
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 ?
|
|
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 =
|
|
5774
|
+
isIgnored = picomatch3(opts.ignore, ignoreOpts, returnState);
|
|
5775
5775
|
}
|
|
5776
5776
|
const matcher = (input2, returnObject = false) => {
|
|
5777
|
-
const { isMatch, match, output: output2 } =
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
5828
|
-
const regex = glob instanceof RegExp ? glob :
|
|
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
|
-
|
|
5832
|
-
|
|
5833
|
-
if (Array.isArray(pattern)) return pattern.map((p) =>
|
|
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
|
-
|
|
5837
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
5865
|
+
return picomatch3.compileRe(parsed, options, returnOutput, returnState);
|
|
5866
5866
|
};
|
|
5867
|
-
|
|
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
|
-
|
|
5877
|
-
module2.exports =
|
|
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
|
|
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(
|
|
5894
|
-
module2.exports =
|
|
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(
|
|
7546
|
-
if (
|
|
7547
|
-
const m2 =
|
|
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
|
|
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
|
|
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,
|
|
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(
|
|
16840
|
+
if (!Number.isFinite(range2.start) || !Number.isFinite(range2.end)) {
|
|
16841
16841
|
return;
|
|
16842
16842
|
}
|
|
16843
16843
|
const length = Number(contentLength);
|
|
16844
|
-
const expectedLength =
|
|
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
|
|
17055
|
-
if (
|
|
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,
|
|
17066
|
-
const { start, size, end = size ? size - 1 : null } =
|
|
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,
|
|
35903
|
-
const ratio = val /
|
|
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:
|
|
55161
|
-
if (
|
|
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) => !
|
|
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
|
|
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 })
|
|
@@ -55301,11 +57135,14 @@ var IDENTITY_NAME_PATTERN = "[A-Za-z0-9][A-Za-z0-9._@-]*";
|
|
|
55301
57135
|
var PoolNameSchema = external_exports.string().min(1).regex(new RegExp(`^${POOL_NAME_PATTERN}$`));
|
|
55302
57136
|
var SELECTOR_RE = new RegExp(`^(${POOL_SELECTOR_PREFIX}${POOL_NAME_PATTERN}|${IDENTITY_NAME_PATTERN})$`);
|
|
55303
57137
|
var IdentitySelectorSchema = external_exports.string().min(1).regex(SELECTOR_RE);
|
|
55304
|
-
var PoolMemberSchema = external_exports.string().min(1).regex(SELECTOR_RE);
|
|
57138
|
+
var PoolMemberSchema = external_exports.union([external_exports.string().min(1).regex(SELECTOR_RE), external_exports.strictObject({ identity: external_exports.string().min(1).regex(SELECTOR_RE), when: WhenSchema })]);
|
|
57139
|
+
function poolMemberIdentity(member) {
|
|
57140
|
+
return typeof member === "string" ? member : member.identity;
|
|
57141
|
+
}
|
|
55305
57142
|
var POOL_PREFERENCES = ["score", "listed"];
|
|
55306
57143
|
var PoolPreferenceSchema = external_exports.enum(POOL_PREFERENCES);
|
|
55307
57144
|
var PoolSchema = external_exports.strictObject({
|
|
55308
|
-
identities: external_exports.array(PoolMemberSchema).min(1).refine((members2) => new Set(members2).size === members2.length, { message: "pool members must be unique" }),
|
|
57145
|
+
identities: external_exports.array(PoolMemberSchema).min(1).refine((members2) => new Set(members2.map(poolMemberIdentity)).size === members2.length, { message: "pool members must be unique" }),
|
|
55309
57146
|
preference: PoolPreferenceSchema.optional()
|
|
55310
57147
|
});
|
|
55311
57148
|
var DirectoryRuleSchema = ConfigProfileSchema.omit({ description: true }).extend({
|
|
@@ -58319,7 +60156,7 @@ function writePools(paths, pools) {
|
|
|
58319
60156
|
function poolCycleOf(pools, name) {
|
|
58320
60157
|
const walk = (current, path46) => {
|
|
58321
60158
|
for (const entry of pools[current]?.identities ?? []) {
|
|
58322
|
-
const nested = poolNameOf(entry);
|
|
60159
|
+
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
58323
60160
|
if (nested === void 0) {
|
|
58324
60161
|
continue;
|
|
58325
60162
|
}
|
|
@@ -58340,9 +60177,10 @@ function poolCycleOf(pools, name) {
|
|
|
58340
60177
|
}
|
|
58341
60178
|
function validateMembers(pools, name, members2) {
|
|
58342
60179
|
for (const entry of members2) {
|
|
58343
|
-
const
|
|
60180
|
+
const identity = poolMemberIdentity(entry);
|
|
60181
|
+
const nested = poolNameOf(identity);
|
|
58344
60182
|
if (nested !== void 0 && nested !== name && pools[nested] === void 0) {
|
|
58345
|
-
throw new UsageError(`Member "${
|
|
60183
|
+
throw new UsageError(`Member "${identity}" of pool "${name}" names a pool that is not defined. Run \`agent-shim pool add ${nested} --identity <name>...\` first.`);
|
|
58346
60184
|
}
|
|
58347
60185
|
}
|
|
58348
60186
|
const cycle = poolCycleOf({ ...pools, [name]: { identities: [...members2] } }, name);
|
|
@@ -59055,7 +60893,6 @@ function planReconciliation(params) {
|
|
|
59055
60893
|
}
|
|
59056
60894
|
|
|
59057
60895
|
// src/resolve/conditions.ts
|
|
59058
|
-
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
59059
60896
|
var MILLISECONDS_PER_UNIT = Object.freeze({
|
|
59060
60897
|
ms: 1,
|
|
59061
60898
|
s: 1e3,
|
|
@@ -59080,62 +60917,91 @@ function parseDuration(value2) {
|
|
|
59080
60917
|
}
|
|
59081
60918
|
return Number(count) * multiplier;
|
|
59082
60919
|
}
|
|
59083
|
-
|
|
59084
|
-
|
|
59085
|
-
|
|
60920
|
+
var evaluator = createSyncEvaluator({});
|
|
60921
|
+
function resolversOf(context) {
|
|
60922
|
+
const pool = context.pool;
|
|
60923
|
+
const values = {
|
|
60924
|
+
now: context.nowMs,
|
|
60925
|
+
...context.fact?.latestMtimeMs === void 0 ? {} : { "entry.latestMtimeMs": context.fact.latestMtimeMs },
|
|
60926
|
+
...context.fact?.totalSizeBytes === void 0 ? {} : { "entry.totalSizeBytes": context.fact.totalSizeBytes },
|
|
60927
|
+
...context.branch === void 0 ? {} : { "repo.branch": context.branch },
|
|
60928
|
+
"repo.detached": context.branchDetached ?? false,
|
|
60929
|
+
...pool?.fiveHour === void 0 ? {} : { "quota.fiveHour.remaining": pool.fiveHour.remaining, "quota.fiveHour.utilization": pool.fiveHour.utilization, "quota.fiveHour.hoursUntilReset": pool.fiveHour.hoursUntilReset },
|
|
60930
|
+
...pool?.sevenDay === void 0 ? {} : { "quota.sevenDay.remaining": pool.sevenDay.remaining, "quota.sevenDay.utilization": pool.sevenDay.utilization, "quota.sevenDay.hoursUntilReset": pool.sevenDay.hoursUntilReset },
|
|
60931
|
+
...pool?.burnPerHour === void 0 ? {} : { "quota.burnPerHour": pool.burnPerHour },
|
|
60932
|
+
...pool?.resuming === void 0 ? {} : { "session.resuming": pool.resuming },
|
|
60933
|
+
...pool?.lastPickHoursAgo === void 0 ? {} : { "session.lastPickHoursAgo": pool.lastPickHoursAgo }
|
|
60934
|
+
};
|
|
60935
|
+
return {
|
|
60936
|
+
resolveValue: (key) => {
|
|
60937
|
+
const wrap = (value3) => ({ found: true, value: typeof value3 === "number" ? { kind: "number", value: value3 } : typeof value3 === "string" ? { kind: "text", value: value3 } : { kind: "boolean", value: value3 } });
|
|
60938
|
+
if (typeof key !== "string") {
|
|
60939
|
+
return { found: false };
|
|
60940
|
+
}
|
|
60941
|
+
if (key.startsWith("env.")) {
|
|
60942
|
+
const value3 = context.env[key.slice("env.".length)];
|
|
60943
|
+
return value3 === void 0 ? { found: false } : wrap(value3);
|
|
60944
|
+
}
|
|
60945
|
+
const value2 = values[key];
|
|
60946
|
+
return value2 === void 0 ? { found: false } : wrap(value2);
|
|
60947
|
+
},
|
|
60948
|
+
// 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.
|
|
60949
|
+
resolveLookup: () => ({ found: false }),
|
|
60950
|
+
resolveCollection: () => []
|
|
60951
|
+
};
|
|
60952
|
+
}
|
|
60953
|
+
function fieldPredicate(field, when, context) {
|
|
60954
|
+
switch (field) {
|
|
60955
|
+
case "newerThan": {
|
|
60956
|
+
const window = parseDuration(when.newerThan ?? "");
|
|
60957
|
+
return { kind: "compare", op: "gte", left: { kind: "reference", key: "entry.latestMtimeMs" }, right: { kind: "numberLiteral", value: context.nowMs - window } };
|
|
60958
|
+
}
|
|
60959
|
+
case "olderThan": {
|
|
60960
|
+
const window = parseDuration(when.olderThan ?? "");
|
|
60961
|
+
return { kind: "compare", op: "lt", left: { kind: "reference", key: "entry.latestMtimeMs" }, right: { kind: "numberLiteral", value: context.nowMs - window } };
|
|
60962
|
+
}
|
|
60963
|
+
case "maxSizeBytes":
|
|
60964
|
+
return { kind: "compare", op: "lte", left: { kind: "reference", key: "entry.totalSizeBytes" }, right: { kind: "numberLiteral", value: when.maxSizeBytes ?? 0 } };
|
|
60965
|
+
case "branch":
|
|
60966
|
+
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 } }] };
|
|
60967
|
+
case "env": {
|
|
60968
|
+
const entries = Object.entries(when.env ?? {});
|
|
60969
|
+
return { kind: "allOf", operands: entries.map(([name, expected]) => ({ kind: "textCompare", op: "equals", left: { kind: "reference", key: `env.${name}` }, right: { kind: "textLiteral", value: expected } })) };
|
|
60970
|
+
}
|
|
59086
60971
|
}
|
|
59087
|
-
return
|
|
60972
|
+
return { kind: "allOf", operands: [] };
|
|
59088
60973
|
}
|
|
59089
60974
|
function evaluateWhen(when, context) {
|
|
59090
60975
|
if (when === void 0) {
|
|
59091
|
-
return { passed: true, checked: [], failed: [] };
|
|
60976
|
+
return { status: "definite", passed: true, checked: [], failed: [] };
|
|
60977
|
+
}
|
|
60978
|
+
if ("kind" in when) {
|
|
60979
|
+
const result = evaluator.evaluatePredicate(when, void 0, resolversOf(context));
|
|
60980
|
+
return result.status === "indeterminate" ? { status: "indeterminate", reason: result.reason.message, checked: ["predicate"] } : { status: "definite", passed: result.value, checked: ["predicate"], failed: result.value ? [] : ["predicate"] };
|
|
59092
60981
|
}
|
|
59093
60982
|
const checked = [];
|
|
59094
60983
|
const failed = [];
|
|
59095
|
-
|
|
59096
|
-
|
|
59097
|
-
|
|
59098
|
-
const latest = context.fact?.latestMtimeMs;
|
|
59099
|
-
if (latest === void 0 || context.nowMs - latest > window) {
|
|
59100
|
-
failed.push("newerThan");
|
|
60984
|
+
for (const field of ["newerThan", "olderThan", "maxSizeBytes", "branch", "env"]) {
|
|
60985
|
+
if (when[field] === void 0) {
|
|
60986
|
+
continue;
|
|
59101
60987
|
}
|
|
59102
|
-
|
|
59103
|
-
|
|
59104
|
-
|
|
59105
|
-
|
|
59106
|
-
const latest = context.fact?.latestMtimeMs;
|
|
59107
|
-
if (latest === void 0 || context.nowMs - latest <= window) {
|
|
59108
|
-
failed.push("olderThan");
|
|
60988
|
+
checked.push(field);
|
|
60989
|
+
const result = evaluator.evaluatePredicate(fieldPredicate(field, when, context), void 0, resolversOf(context));
|
|
60990
|
+
if (result.status === "indeterminate") {
|
|
60991
|
+
return { status: "indeterminate", reason: result.reason.message, checked };
|
|
59109
60992
|
}
|
|
59110
|
-
|
|
59111
|
-
|
|
59112
|
-
checked.push("maxSizeBytes");
|
|
59113
|
-
const total = context.fact?.totalSizeBytes;
|
|
59114
|
-
if (total === void 0 || total > when.maxSizeBytes) {
|
|
59115
|
-
failed.push("maxSizeBytes");
|
|
60993
|
+
if (!result.value) {
|
|
60994
|
+
failed.push(field);
|
|
59116
60995
|
}
|
|
59117
60996
|
}
|
|
59118
|
-
|
|
59119
|
-
checked.push("branch");
|
|
59120
|
-
if (!matchBranch(when.branch, context.branch, context.branchDetached ?? false)) {
|
|
59121
|
-
failed.push("branch");
|
|
59122
|
-
}
|
|
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");
|
|
59129
|
-
}
|
|
59130
|
-
}
|
|
59131
|
-
return { passed: failed.length === 0, checked, failed };
|
|
60997
|
+
return { status: "definite", passed: failed.length === 0, checked, failed };
|
|
59132
60998
|
}
|
|
59133
60999
|
function isVacuousWhen(when) {
|
|
59134
|
-
return when !== void 0 && Object.keys(when).length === 0;
|
|
61000
|
+
return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
|
|
59135
61001
|
}
|
|
59136
61002
|
|
|
59137
61003
|
// src/resolve/match.ts
|
|
59138
|
-
var
|
|
61004
|
+
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
59139
61005
|
|
|
59140
61006
|
// src/resolve/projects.ts
|
|
59141
61007
|
var NON_ALPHANUMERIC = /[^A-Za-z0-9]/g;
|
|
@@ -59311,8 +61177,8 @@ function canonicaliseEntryKey(key, options) {
|
|
|
59311
61177
|
}
|
|
59312
61178
|
function compileMatcher(canonicalPattern) {
|
|
59313
61179
|
const options = { dot: true, nocase: false };
|
|
59314
|
-
const self = (0,
|
|
59315
|
-
const subtree = (0,
|
|
61180
|
+
const self = (0, import_picomatch2.default)(canonicalPattern, options);
|
|
61181
|
+
const subtree = (0, import_picomatch2.default)(`${canonicalPattern}/**`, options);
|
|
59316
61182
|
return (relPath) => self(relPath) || subtree(relPath);
|
|
59317
61183
|
}
|
|
59318
61184
|
function patternCouldReachUnder(canonicalPattern, dir) {
|
|
@@ -59335,7 +61201,7 @@ function couldReach(patternSegments, dirSegments) {
|
|
|
59335
61201
|
if (head === void 0 || dirHead === void 0) {
|
|
59336
61202
|
return true;
|
|
59337
61203
|
}
|
|
59338
|
-
if (!(0,
|
|
61204
|
+
if (!(0, import_picomatch2.default)(head, { dot: true, nocase: false })(dirHead)) {
|
|
59339
61205
|
return false;
|
|
59340
61206
|
}
|
|
59341
61207
|
return couldReach(restPattern, restDir);
|
|
@@ -59502,10 +61368,10 @@ function selectRule(relPath, flattened, context) {
|
|
|
59502
61368
|
...context.branchDetached === void 0 ? {} : { branchDetached: context.branchDetached },
|
|
59503
61369
|
env: context.env
|
|
59504
61370
|
});
|
|
59505
|
-
if (evaluation.passed) {
|
|
61371
|
+
if (evaluation.status === "definite" && evaluation.passed) {
|
|
59506
61372
|
return { rule, eliminated };
|
|
59507
61373
|
}
|
|
59508
|
-
eliminated.push({ rule, failed: evaluation.failed });
|
|
61374
|
+
eliminated.push({ rule, failed: evaluation.status === "definite" ? evaluation.failed : [`${evaluation.checked.join(", ")} could not be decided: ${evaluation.reason}`] });
|
|
59509
61375
|
}
|
|
59510
61376
|
return { eliminated };
|
|
59511
61377
|
}
|
|
@@ -59739,7 +61605,10 @@ function planFarm(params) {
|
|
|
59739
61605
|
var ENTER_EVERYTHING = () => true;
|
|
59740
61606
|
function readsSubtreeAggregates(rule) {
|
|
59741
61607
|
const when = rule.when;
|
|
59742
|
-
|
|
61608
|
+
if (when === void 0) {
|
|
61609
|
+
return false;
|
|
61610
|
+
}
|
|
61611
|
+
return "kind" in when || when.newerThan !== void 0 || when.olderThan !== void 0 || when.maxSizeBytes !== void 0;
|
|
59743
61612
|
}
|
|
59744
61613
|
function hasUnboundedDepth(pattern) {
|
|
59745
61614
|
return pattern.includes("**") || /[{(]/.test(pattern);
|
|
@@ -59759,11 +61628,11 @@ function couldMatchBeneath(rule, dirRel) {
|
|
|
59759
61628
|
return prefix === "" || prefix.startsWith(`${dirRel}/`) || dirRel.startsWith(prefix);
|
|
59760
61629
|
}
|
|
59761
61630
|
function descendPolicy(rules) {
|
|
59762
|
-
const
|
|
59763
|
-
if (
|
|
61631
|
+
const all3 = [...rules];
|
|
61632
|
+
if (all3.some(readsSubtreeAggregates)) {
|
|
59764
61633
|
return ENTER_EVERYTHING;
|
|
59765
61634
|
}
|
|
59766
|
-
return (dirRel) =>
|
|
61635
|
+
return (dirRel) => all3.some((rule) => couldMatchBeneath(rule, dirRel));
|
|
59767
61636
|
}
|
|
59768
61637
|
function enterRulesAnd(policy, target) {
|
|
59769
61638
|
if (target === void 0 || target === "") {
|
|
@@ -61796,7 +63665,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
61796
63665
|
// package.json
|
|
61797
63666
|
var package_default = {
|
|
61798
63667
|
name: "agent-shim",
|
|
61799
|
-
version: "8.
|
|
63668
|
+
version: "8.34.0",
|
|
61800
63669
|
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
63670
|
license: "MIT",
|
|
61802
63671
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -61852,6 +63721,7 @@ var package_default = {
|
|
|
61852
63721
|
commander: "^15.0.0",
|
|
61853
63722
|
cosmiconfig: "^10.0.1",
|
|
61854
63723
|
picomatch: "^4.0.7",
|
|
63724
|
+
trilean: "1.7.1",
|
|
61855
63725
|
undici: "7.29.1",
|
|
61856
63726
|
zod: "^4.6.1"
|
|
61857
63727
|
},
|
|
@@ -62512,7 +64382,7 @@ function createJsonScanner() {
|
|
|
62512
64382
|
capture = "";
|
|
62513
64383
|
inValue = false;
|
|
62514
64384
|
};
|
|
62515
|
-
const
|
|
64385
|
+
const step2 = (char) => {
|
|
62516
64386
|
if (capturing !== void 0 && !(depth === 1 && !inString && (char === "," || char === "}"))) {
|
|
62517
64387
|
capture += char;
|
|
62518
64388
|
}
|
|
@@ -62579,7 +64449,7 @@ function createJsonScanner() {
|
|
|
62579
64449
|
return {
|
|
62580
64450
|
push: (text2) => {
|
|
62581
64451
|
for (const char of text2) {
|
|
62582
|
-
|
|
64452
|
+
step2(char);
|
|
62583
64453
|
}
|
|
62584
64454
|
},
|
|
62585
64455
|
result: () => {
|
|
@@ -62884,12 +64754,48 @@ function assessIdentity(member, nowMs) {
|
|
|
62884
64754
|
...sevenDayBurn === void 0 ? {} : { sevenDayBurn }
|
|
62885
64755
|
};
|
|
62886
64756
|
}
|
|
64757
|
+
function poolFactsOf(member, nowMs, resuming, sticky) {
|
|
64758
|
+
const unified = member.snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
64759
|
+
const window = (which) => {
|
|
64760
|
+
const raw = unified?.[which];
|
|
64761
|
+
if (raw?.utilization === void 0) {
|
|
64762
|
+
return void 0;
|
|
64763
|
+
}
|
|
64764
|
+
if (raw.resetsAt === void 0) {
|
|
64765
|
+
return void 0;
|
|
64766
|
+
}
|
|
64767
|
+
return { remaining: Math.max(0, 1 - raw.utilization), utilization: raw.utilization, hoursUntilReset: Math.max(0, (Date.parse(raw.resetsAt) - nowMs) / MS_PER_HOUR) };
|
|
64768
|
+
};
|
|
64769
|
+
const burn = windowBurn(member.records, "fiveHour");
|
|
64770
|
+
return {
|
|
64771
|
+
...window("fiveHour") === void 0 ? {} : { fiveHour: window("fiveHour") },
|
|
64772
|
+
...window("sevenDay") === void 0 ? {} : { sevenDay: window("sevenDay") },
|
|
64773
|
+
...burn === void 0 ? {} : { burnPerHour: burn * MS_PER_HOUR },
|
|
64774
|
+
resuming,
|
|
64775
|
+
...sticky?.identity === member.identity ? { lastPickHoursAgo: Math.max(0, (nowMs - Date.parse(sticky.at)) / MS_PER_HOUR) } : {}
|
|
64776
|
+
};
|
|
64777
|
+
}
|
|
62887
64778
|
function rankPool(input2) {
|
|
62888
64779
|
const { members: members2, nowMs } = input2;
|
|
62889
|
-
const assessments = members2.map((member) => assess(member, nowMs));
|
|
64780
|
+
const assessments = members2.map((member) => ({ member, ...assess(member, nowMs) }));
|
|
62890
64781
|
const demands = assessments.flatMap(({ candidate, burn }) => burn === void 0 ? [] : [burn * capacityOf(candidate.plan)]);
|
|
62891
64782
|
const sharedDemand = demands.length === 0 ? void 0 : Math.max(...demands);
|
|
62892
|
-
const
|
|
64783
|
+
const guarded = assessments.map((assessment) => {
|
|
64784
|
+
const { candidate } = assessment;
|
|
64785
|
+
if (candidate.class === "ineligible" || assessment.member.policy === void 0) {
|
|
64786
|
+
return assessment;
|
|
64787
|
+
}
|
|
64788
|
+
const context = { nowMs, env: {}, pool: poolFactsOf(assessment.member, nowMs, input2.resuming, input2.sticky) };
|
|
64789
|
+
const verdict = evaluateWhen(assessment.member.policy, context);
|
|
64790
|
+
if (verdict.status === "indeterminate") {
|
|
64791
|
+
return { ...assessment, candidate: { ...candidate, policyDemoted: true, reasons: [`policy undecided (${verdict.checked.join(", ") === "predicate" ? "predicate" : verdict.checked.join(", ")}): ${verdict.reason}`, ...candidate.reasons] } };
|
|
64792
|
+
}
|
|
64793
|
+
if (verdict.passed) {
|
|
64794
|
+
return assessment;
|
|
64795
|
+
}
|
|
64796
|
+
return { ...assessment, candidate: { ...candidate, class: "ineligible", reasons: [`skipped by policy (${verdict.checked.join(", ")}: did not hold)`, ...candidate.reasons] } };
|
|
64797
|
+
});
|
|
64798
|
+
const candidates = guarded.map((assessment) => {
|
|
62893
64799
|
const { candidate, fiveHour, burn } = assessment;
|
|
62894
64800
|
const pace = burn ?? (sharedDemand === void 0 ? void 0 : sharedDemand / capacityOf(candidate.plan));
|
|
62895
64801
|
const { sevenDay, sevenDayBurn } = assessment;
|
|
@@ -62915,7 +64821,7 @@ function rankPool(input2) {
|
|
|
62915
64821
|
return { ...candidate, feasible: false, reasons: [...drySpots, ...candidate.reasons] };
|
|
62916
64822
|
});
|
|
62917
64823
|
const ordered = input2.preference === "listed" ? [...candidates] : [...candidates].sort(
|
|
62918
|
-
(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)
|
|
64824
|
+
(left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(left.policyDemoted ?? false) - Number(right.policyDemoted ?? false) || Number(right.feasible) - Number(left.feasible) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
|
|
62919
64825
|
);
|
|
62920
64826
|
const sticky = input2.sticky;
|
|
62921
64827
|
const stickyIndex = sticky === void 0 ? -1 : ordered.findIndex((candidate) => candidate.identity === sticky.identity);
|
|
@@ -63244,27 +65150,27 @@ function rankNamedPool(input2, poolName, stack, sticky) {
|
|
|
63244
65150
|
throw new PoolGraphError(`No pool named "${poolName}". Run \`agent-shim pool add ${poolName} --identity <name>...\` first.`);
|
|
63245
65151
|
}
|
|
63246
65152
|
const childStack = [...stack, poolName];
|
|
63247
|
-
const direct = pool.identities.filter((entry) => poolNameOf(entry) === void 0);
|
|
63248
|
-
const missing = direct.filter((entry) => !input2.identityExists(entry)).map((
|
|
63249
|
-
const loaded = new Map(loadPoolMembers(input2.fs, input2.paths, direct.filter(input2.identityExists), input2.nowMs).map((member) => [member.identity, member]));
|
|
65153
|
+
const direct = pool.identities.filter((entry) => poolNameOf(poolMemberIdentity(entry)) === void 0);
|
|
65154
|
+
const missing = direct.filter((entry) => !input2.identityExists(poolMemberIdentity(entry))).map((entry) => ({ pool: poolName, identity: poolMemberIdentity(entry) }));
|
|
65155
|
+
const loaded = new Map(loadPoolMembers(input2.fs, input2.paths, direct.filter((entry) => input2.identityExists(poolMemberIdentity(entry))).map(poolMemberIdentity), input2.nowMs).map((member) => [member.identity, member]));
|
|
63250
65156
|
const members2 = [];
|
|
63251
65157
|
for (const entry of pool.identities) {
|
|
63252
|
-
const nestedName = poolNameOf(entry);
|
|
65158
|
+
const nestedName = poolNameOf(poolMemberIdentity(entry));
|
|
63253
65159
|
if (nestedName === void 0) {
|
|
63254
|
-
const member = loaded.get(entry);
|
|
65160
|
+
const member = loaded.get(poolMemberIdentity(entry));
|
|
63255
65161
|
if (member !== void 0) {
|
|
63256
|
-
members2.push(member);
|
|
65162
|
+
members2.push(typeof entry === "string" ? member : { ...member, policy: entry.when });
|
|
63257
65163
|
}
|
|
63258
65164
|
continue;
|
|
63259
65165
|
}
|
|
63260
65166
|
if (input2.pools[nestedName] === void 0) {
|
|
63261
|
-
throw new PoolGraphError(`Pool "${poolName}" member "${entry}" names a pool that is not defined.`);
|
|
65167
|
+
throw new PoolGraphError(`Pool "${poolName}" member "${poolMemberIdentity(entry)}" names a pool that is not defined.`);
|
|
63262
65168
|
}
|
|
63263
65169
|
if (childStack.includes(nestedName)) {
|
|
63264
|
-
throw new PoolGraphError(`Pool "${poolName}" member "${entry}" closes a cycle: ${[...childStack.slice(childStack.indexOf(nestedName)), nestedName].join(" -> ")}. A pool cannot nest itself, directly or through another pool.`);
|
|
65170
|
+
throw new PoolGraphError(`Pool "${poolName}" member "${poolMemberIdentity(entry)}" closes a cycle: ${[...childStack.slice(childStack.indexOf(nestedName)), nestedName].join(" -> ")}. A pool cannot nest itself, directly or through another pool.`);
|
|
63265
65171
|
}
|
|
63266
65172
|
const nested = nestedMember(input2, nestedName, childStack, sticky);
|
|
63267
|
-
members2.push(nested.member);
|
|
65173
|
+
members2.push(typeof entry === "string" ? nested.member : { ...nested.member, policy: entry.when });
|
|
63268
65174
|
missing.push(...nested.missing);
|
|
63269
65175
|
}
|
|
63270
65176
|
const ranking = rankPool({
|
|
@@ -68279,16 +70185,16 @@ function runDoctor(params) {
|
|
|
68279
70185
|
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
68280
70186
|
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
68281
70187
|
for (const [poolName, pool] of Object.entries(pools)) {
|
|
68282
|
-
const missing = pool.identities.filter((member) => poolNameOf(member) === void 0 && !validIdentityNames.has(member));
|
|
70188
|
+
const missing = pool.identities.filter((member) => poolNameOf(poolMemberIdentity(member)) === void 0 && !validIdentityNames.has(poolMemberIdentity(member)));
|
|
68283
70189
|
const undefinedPools = pool.identities.flatMap((member) => {
|
|
68284
|
-
const nested = poolNameOf(member);
|
|
70190
|
+
const nested = poolNameOf(poolMemberIdentity(member));
|
|
68285
70191
|
return nested === void 0 || nested in pools ? [] : [nested];
|
|
68286
70192
|
});
|
|
68287
70193
|
if (missing.length === 0 && undefinedPools.length === 0) {
|
|
68288
|
-
push("pool", "pass", `${poolName} is valid (${pool.identities.join(", ")}).`, poolName);
|
|
70194
|
+
push("pool", "pass", `${poolName} is valid (${pool.identities.map(poolMemberIdentity).join(", ")}).`, poolName);
|
|
68289
70195
|
} else {
|
|
68290
70196
|
const problems = [
|
|
68291
|
-
...missing.map((member) => `identity "${member}", which does not exist`),
|
|
70197
|
+
...missing.map((member) => `identity "${poolMemberIdentity(member)}", which does not exist`),
|
|
68292
70198
|
...undefinedPools.map((nested) => `pool "${nested}", which is not defined`)
|
|
68293
70199
|
];
|
|
68294
70200
|
push("pool", "fail", `Pool "${poolName}" names ${problems.join(" and ")}.`, poolName);
|
|
@@ -73108,7 +75014,7 @@ var StandardHandler = class {
|
|
|
73108
75014
|
return runWithSpan(
|
|
73109
75015
|
{ name: `${request7.method} ${request7.url.pathname}` },
|
|
73110
75016
|
async (span) => {
|
|
73111
|
-
let
|
|
75017
|
+
let step2;
|
|
73112
75018
|
try {
|
|
73113
75019
|
return await intercept(
|
|
73114
75020
|
this.interceptors,
|
|
@@ -73127,12 +75033,12 @@ var StandardHandler = class {
|
|
|
73127
75033
|
span?.updateName(`${ORPC_NAME}.${match.path.join("/")}`);
|
|
73128
75034
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
73129
75035
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
73130
|
-
|
|
75036
|
+
step2 = "decode_input";
|
|
73131
75037
|
let input2 = await runWithSpan(
|
|
73132
75038
|
{ name: "decode_input" },
|
|
73133
75039
|
() => this.codec.decode(request22, match.params, match.procedure)
|
|
73134
75040
|
);
|
|
73135
|
-
|
|
75041
|
+
step2 = void 0;
|
|
73136
75042
|
if (isAsyncIteratorObject(input2)) {
|
|
73137
75043
|
input2 = asyncIteratorWithSpan(
|
|
73138
75044
|
{ name: "consume_event_iterator_input", signal: request22.signal },
|
|
@@ -73144,12 +75050,12 @@ var StandardHandler = class {
|
|
|
73144
75050
|
path: match.path,
|
|
73145
75051
|
interceptors: this.clientInterceptors
|
|
73146
75052
|
});
|
|
73147
|
-
|
|
75053
|
+
step2 = "call_procedure";
|
|
73148
75054
|
const output2 = await client(input2, {
|
|
73149
75055
|
signal: request22.signal,
|
|
73150
75056
|
lastEventId: flattenHeader(request22.headers["last-event-id"])
|
|
73151
75057
|
});
|
|
73152
|
-
|
|
75058
|
+
step2 = void 0;
|
|
73153
75059
|
const response = this.codec.encode(output2, match.procedure);
|
|
73154
75060
|
return {
|
|
73155
75061
|
matched: true,
|
|
@@ -73158,10 +75064,10 @@ var StandardHandler = class {
|
|
|
73158
75064
|
}
|
|
73159
75065
|
);
|
|
73160
75066
|
} catch (e) {
|
|
73161
|
-
if (
|
|
75067
|
+
if (step2 !== "call_procedure") {
|
|
73162
75068
|
setSpanError(span, e);
|
|
73163
75069
|
}
|
|
73164
|
-
const error62 =
|
|
75070
|
+
const error62 = step2 === "decode_input" && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
|
|
73165
75071
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
73166
75072
|
cause: e
|
|
73167
75073
|
}) : toORPCError(e);
|
|
@@ -75245,17 +77151,17 @@ function createCodexRoute(ports) {
|
|
|
75245
77151
|
const frames = async function* () {
|
|
75246
77152
|
try {
|
|
75247
77153
|
for await (const event of codexEvents(upstreamBody)) {
|
|
75248
|
-
const
|
|
75249
|
-
for (const frame of
|
|
77154
|
+
const step2 = relay.push(event);
|
|
77155
|
+
for (const frame of step2.frames) {
|
|
75250
77156
|
yield renderSseFrame(frame);
|
|
75251
77157
|
}
|
|
75252
|
-
if (
|
|
75253
|
-
logCompleted(
|
|
77158
|
+
if (step2.completed !== void 0) {
|
|
77159
|
+
logCompleted(step2.completed.message, step2.completed.usage);
|
|
75254
77160
|
return;
|
|
75255
77161
|
}
|
|
75256
|
-
if (
|
|
75257
|
-
ports.log(`${upstreamRequest.model} stream error: ${
|
|
75258
|
-
yield errorFrame(HTTP_STATUS.internalServerError,
|
|
77162
|
+
if (step2.failed !== void 0) {
|
|
77163
|
+
ports.log(`${upstreamRequest.model} stream error: ${step2.failed.message}`);
|
|
77164
|
+
yield errorFrame(HTTP_STATUS.internalServerError, step2.failed.message);
|
|
75259
77165
|
return;
|
|
75260
77166
|
}
|
|
75261
77167
|
}
|
|
@@ -75277,14 +77183,14 @@ function createCodexRoute(ports) {
|
|
|
75277
77183
|
}
|
|
75278
77184
|
try {
|
|
75279
77185
|
for await (const event of codexEvents(upstreamBody)) {
|
|
75280
|
-
const
|
|
75281
|
-
if (
|
|
75282
|
-
logCompleted(
|
|
75283
|
-
return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json", ...quota }, body: JSON.stringify(
|
|
77186
|
+
const step2 = relay.push(event);
|
|
77187
|
+
if (step2.completed !== void 0) {
|
|
77188
|
+
logCompleted(step2.completed.message, step2.completed.usage);
|
|
77189
|
+
return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json", ...quota }, body: JSON.stringify(step2.completed.message) };
|
|
75284
77190
|
}
|
|
75285
|
-
if (
|
|
75286
|
-
ports.log(`${upstreamRequest.model} stream error: ${
|
|
75287
|
-
return errorResponse(HTTP_STATUS.internalServerError,
|
|
77191
|
+
if (step2.failed !== void 0) {
|
|
77192
|
+
ports.log(`${upstreamRequest.model} stream error: ${step2.failed.message}`);
|
|
77193
|
+
return errorResponse(HTTP_STATUS.internalServerError, step2.failed.message);
|
|
75288
77194
|
}
|
|
75289
77195
|
}
|
|
75290
77196
|
} catch (error62) {
|
|
@@ -79920,12 +81826,12 @@ function registerPoolCommand(program2, deps) {
|
|
|
79920
81826
|
}
|
|
79921
81827
|
const members2 = options.identity === void 0 ? existing.identities : membersOf(options);
|
|
79922
81828
|
if (options.identity !== void 0) {
|
|
79923
|
-
requireIdentities(paths,
|
|
81829
|
+
requireIdentities(paths, membersOf(options));
|
|
79924
81830
|
}
|
|
79925
81831
|
const preference = options.preference === void 0 ? existing.preference : options.preference === false ? void 0 : options.preference;
|
|
79926
81832
|
const updated = setPool(paths, name, members2, preference);
|
|
79927
81833
|
reportMutation(options.json, { action: "updated", kind: "pool", name, value: updated }, () => {
|
|
79928
|
-
console.log(`Pool "${name}" now has ${members2.join(", ")}.`);
|
|
81834
|
+
console.log(`Pool "${name}" now has ${members2.map(poolMemberIdentity).join(", ")}.`);
|
|
79929
81835
|
});
|
|
79930
81836
|
}),
|
|
79931
81837
|
["agent-shim pool set subs --identity work --identity personal --identity spare", "agent-shim pool set subs --preference listed"]
|
|
@@ -79945,7 +81851,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
79945
81851
|
}
|
|
79946
81852
|
for (const name of names) {
|
|
79947
81853
|
const entry = pools[name];
|
|
79948
|
-
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(entry?.identities ?? []).join(", ")}${entry?.preference === void 0 ? "" : " (preference: listed)"}`);
|
|
81854
|
+
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(entry?.identities ?? []).map(poolMemberIdentity).join(", ")}${entry?.preference === void 0 ? "" : " (preference: listed)"}`);
|
|
79949
81855
|
}
|
|
79950
81856
|
}),
|
|
79951
81857
|
["agent-shim pool list", "agent-shim pool list --json"]
|
|
@@ -79958,7 +81864,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
79958
81864
|
return;
|
|
79959
81865
|
}
|
|
79960
81866
|
console.log(`Pool: ${name}`);
|
|
79961
|
-
console.log(`Members: ${entry.identities.join(", ")}`);
|
|
81867
|
+
console.log(`Members: ${entry.identities.map(poolMemberIdentity).join(", ")}`);
|
|
79962
81868
|
if (entry.preference !== void 0) {
|
|
79963
81869
|
console.log(`Preference: ${entry.preference}`);
|
|
79964
81870
|
}
|
|
@@ -80706,11 +82612,11 @@ function formatRateLimit(state) {
|
|
|
80706
82612
|
return `quota (as of ${state.observedAt}): ${[...parts, `status ${unified.status ?? "unknown"}`, ...unified.overageStatus === void 0 ? [] : [`extra usage ${unified.overageStatus}`]].join("; ")}`;
|
|
80707
82613
|
}
|
|
80708
82614
|
function formatLimit(limit) {
|
|
80709
|
-
const
|
|
82615
|
+
const wait2 = [
|
|
80710
82616
|
...limit.resetAt === void 0 ? [] : [`resets ${limit.resetAt}`],
|
|
80711
82617
|
...limit.retryAfterSeconds === void 0 ? [] : [`retry after ${String(limit.retryAfterSeconds)}s`]
|
|
80712
82618
|
];
|
|
80713
|
-
return `last limit: ${limit.kind} (${String(limit.status)}) at ${limit.observedAt}${limit.window === void 0 ? "" : ` on the ${limit.window} window`}${
|
|
82619
|
+
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(", ")}`}`;
|
|
80714
82620
|
}
|
|
80715
82621
|
var MONEY_DECIMALS = 2;
|
|
80716
82622
|
var MS_PER_HOUR3 = 36e5;
|