coderifts 1.8.3 → 1.9.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/bin/coderifts.js +17 -0
- package/corpus/vectors-mcp-fpfn.json +35 -13
- package/corpus/vectors-openapi-fpfn.json +18 -7
- package/dist/cli.js +3730 -145
- package/package.json +4 -2
package/dist/cli.js
CHANGED
|
@@ -3007,7 +3007,7 @@ var require_package = __commonJS({
|
|
|
3007
3007
|
"package.json"(exports2, module2) {
|
|
3008
3008
|
module2.exports = {
|
|
3009
3009
|
name: "coderifts",
|
|
3010
|
-
version: "1.
|
|
3010
|
+
version: "1.9.0",
|
|
3011
3011
|
description: "Detect breaking API changes from the command line. Works locally or with the CodeRifts cloud API.",
|
|
3012
3012
|
author: "CodeRifts <hello@coderifts.com>",
|
|
3013
3013
|
license: "MIT",
|
|
@@ -3050,6 +3050,7 @@ var require_package = __commonJS({
|
|
|
3050
3050
|
test: "node --test test/*.test.js"
|
|
3051
3051
|
},
|
|
3052
3052
|
dependencies: {
|
|
3053
|
+
"@coderifts/agent-guard": "^1.6.0",
|
|
3053
3054
|
chalk: "^4.1.2",
|
|
3054
3055
|
"cli-table3": "^0.6.4",
|
|
3055
3056
|
commander: "^12.0.0",
|
|
@@ -3061,7 +3062,8 @@ var require_package = __commonJS({
|
|
|
3061
3062
|
overrides: {
|
|
3062
3063
|
"z-schema": "^7.2.0",
|
|
3063
3064
|
"json-schema-ref-parser": "npm:@apidevtools/json-schema-ref-parser@^11.7.3",
|
|
3064
|
-
"form-data": "^4.0.6"
|
|
3065
|
+
"form-data": "^4.0.6",
|
|
3066
|
+
axios: ">=1.18.0"
|
|
3065
3067
|
},
|
|
3066
3068
|
devDependencies: {
|
|
3067
3069
|
esbuild: "^0.28.1"
|
|
@@ -30018,6 +30020,7 @@ var require_fast_uri = __commonJS({
|
|
|
30018
30020
|
return uriTokens.join("");
|
|
30019
30021
|
}
|
|
30020
30022
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
30023
|
+
var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
|
|
30021
30024
|
function getParseError(parsed, matches) {
|
|
30022
30025
|
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
30023
30026
|
return 'URI path must start with "/" when authority is present.';
|
|
@@ -30047,6 +30050,11 @@ var require_fast_uri = __commonJS({
|
|
|
30047
30050
|
uri = "//" + uri;
|
|
30048
30051
|
}
|
|
30049
30052
|
}
|
|
30053
|
+
const authorityMatch = uri.match(AUTHORITY_PREFIX);
|
|
30054
|
+
if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
|
|
30055
|
+
parsed.error = "URI authority must not contain a literal backslash.";
|
|
30056
|
+
malformedAuthorityOrPort = true;
|
|
30057
|
+
}
|
|
30050
30058
|
const matches = uri.match(URI_PARSE);
|
|
30051
30059
|
if (matches) {
|
|
30052
30060
|
parsed.scheme = matches[1];
|
|
@@ -30090,7 +30098,7 @@ var require_fast_uri = __commonJS({
|
|
|
30090
30098
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
30091
30099
|
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
30092
30100
|
try {
|
|
30093
|
-
parsed.host = URL
|
|
30101
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
30094
30102
|
} catch (e) {
|
|
30095
30103
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
30096
30104
|
}
|
|
@@ -60563,6 +60571,25 @@ var require_axios = __commonJS({
|
|
|
60563
60571
|
iterator,
|
|
60564
60572
|
toStringTag
|
|
60565
60573
|
} = Symbol;
|
|
60574
|
+
var hasOwnProperty = (({
|
|
60575
|
+
hasOwnProperty: hasOwnProperty2
|
|
60576
|
+
}) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
60577
|
+
var hasOwnInPrototypeChain = (thing, prop) => {
|
|
60578
|
+
let obj = thing;
|
|
60579
|
+
const seen = [];
|
|
60580
|
+
while (obj != null && obj !== Object.prototype) {
|
|
60581
|
+
if (seen.indexOf(obj) !== -1) {
|
|
60582
|
+
return false;
|
|
60583
|
+
}
|
|
60584
|
+
seen.push(obj);
|
|
60585
|
+
if (hasOwnProperty(obj, prop)) {
|
|
60586
|
+
return true;
|
|
60587
|
+
}
|
|
60588
|
+
obj = getPrototypeOf(obj);
|
|
60589
|
+
}
|
|
60590
|
+
return false;
|
|
60591
|
+
};
|
|
60592
|
+
var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
|
|
60566
60593
|
var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
|
|
60567
60594
|
const str = toString.call(thing);
|
|
60568
60595
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -60595,11 +60622,14 @@ var require_axios = __commonJS({
|
|
|
60595
60622
|
var isObject = (thing) => thing !== null && typeof thing === "object";
|
|
60596
60623
|
var isBoolean = (thing) => thing === true || thing === false;
|
|
60597
60624
|
var isPlainObject = (val) => {
|
|
60598
|
-
if (
|
|
60625
|
+
if (!isObject(val)) {
|
|
60599
60626
|
return false;
|
|
60600
60627
|
}
|
|
60601
60628
|
const prototype2 = getPrototypeOf(val);
|
|
60602
|
-
return (prototype2 === null || prototype2 === Object.prototype ||
|
|
60629
|
+
return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
|
|
60630
|
+
// Symbol.iterator as evidence the value is a tagged/iterable type rather
|
|
60631
|
+
// than a plain object, while ignoring keys injected onto Object.prototype.
|
|
60632
|
+
!hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
|
|
60603
60633
|
};
|
|
60604
60634
|
var isEmptyObject = (val) => {
|
|
60605
60635
|
if (!isObject(val) || isBuffer(val)) {
|
|
@@ -60852,9 +60882,6 @@ var require_axios = __commonJS({
|
|
|
60852
60882
|
return p1.toUpperCase() + p2;
|
|
60853
60883
|
});
|
|
60854
60884
|
};
|
|
60855
|
-
var hasOwnProperty = (({
|
|
60856
|
-
hasOwnProperty: hasOwnProperty2
|
|
60857
|
-
}) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
60858
60885
|
var {
|
|
60859
60886
|
propertyIsEnumerable
|
|
60860
60887
|
} = Object.prototype;
|
|
@@ -60955,6 +60982,7 @@ var require_axios = __commonJS({
|
|
|
60955
60982
|
})(typeof setImmediate === "function", isFunction$1(_global.postMessage));
|
|
60956
60983
|
var asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
|
|
60957
60984
|
var isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
60985
|
+
var isSafeIterable = (thing) => thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
|
|
60958
60986
|
var utils$1 = {
|
|
60959
60987
|
isArray,
|
|
60960
60988
|
isArrayBuffer,
|
|
@@ -61000,6 +61028,8 @@ var require_axios = __commonJS({
|
|
|
61000
61028
|
hasOwnProperty,
|
|
61001
61029
|
hasOwnProp: hasOwnProperty,
|
|
61002
61030
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
61031
|
+
hasOwnInPrototypeChain,
|
|
61032
|
+
getSafeProp,
|
|
61003
61033
|
reduceDescriptors,
|
|
61004
61034
|
freezeMethods,
|
|
61005
61035
|
toObjectSet,
|
|
@@ -61015,7 +61045,8 @@ var require_axios = __commonJS({
|
|
|
61015
61045
|
isThenable,
|
|
61016
61046
|
setImmediate: _setImmediate,
|
|
61017
61047
|
asap,
|
|
61018
|
-
isIterable
|
|
61048
|
+
isIterable,
|
|
61049
|
+
isSafeIterable
|
|
61019
61050
|
};
|
|
61020
61051
|
var ignoreDuplicateOf = utils$1.toObjectSet(["age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent"]);
|
|
61021
61052
|
var parseHeaders = (rawHeaders) => {
|
|
@@ -61153,13 +61184,19 @@ var require_axios = __commonJS({
|
|
|
61153
61184
|
setHeaders(header, valueOrRewrite);
|
|
61154
61185
|
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
61155
61186
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
61156
|
-
} else if (utils$1.isObject(header) && utils$1.
|
|
61157
|
-
let obj =
|
|
61187
|
+
} else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
|
|
61188
|
+
let obj = /* @__PURE__ */ Object.create(null), dest, key;
|
|
61158
61189
|
for (const entry of header) {
|
|
61159
61190
|
if (!utils$1.isArray(entry)) {
|
|
61160
61191
|
throw new TypeError("Object iterator must return a key-value pair");
|
|
61161
61192
|
}
|
|
61162
|
-
|
|
61193
|
+
key = entry[0];
|
|
61194
|
+
if (utils$1.hasOwnProp(obj, key)) {
|
|
61195
|
+
dest = obj[key];
|
|
61196
|
+
obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
|
|
61197
|
+
} else {
|
|
61198
|
+
obj[key] = entry[1];
|
|
61199
|
+
}
|
|
61163
61200
|
}
|
|
61164
61201
|
setHeaders(obj, valueOrRewrite);
|
|
61165
61202
|
} else {
|
|
@@ -61364,7 +61401,13 @@ var require_axios = __commonJS({
|
|
|
61364
61401
|
var AxiosError = class _AxiosError extends Error {
|
|
61365
61402
|
static from(error, code, config, request, response, customProps) {
|
|
61366
61403
|
const axiosError = new _AxiosError(error.message, code || error.code, config, request, response);
|
|
61367
|
-
axiosError
|
|
61404
|
+
Object.defineProperty(axiosError, "cause", {
|
|
61405
|
+
__proto__: null,
|
|
61406
|
+
value: error,
|
|
61407
|
+
writable: true,
|
|
61408
|
+
enumerable: false,
|
|
61409
|
+
configurable: true
|
|
61410
|
+
});
|
|
61368
61411
|
axiosError.name = error.name;
|
|
61369
61412
|
if (error.status != null && axiosError.status == null) {
|
|
61370
61413
|
axiosError.status = error.status;
|
|
@@ -61441,6 +61484,7 @@ var require_axios = __commonJS({
|
|
|
61441
61484
|
AxiosError.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
|
61442
61485
|
AxiosError.ERR_INVALID_URL = "ERR_INVALID_URL";
|
|
61443
61486
|
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = "ERR_FORM_DATA_DEPTH_EXCEEDED";
|
|
61487
|
+
var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
61444
61488
|
function isVisitable(thing) {
|
|
61445
61489
|
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
61446
61490
|
}
|
|
@@ -61477,8 +61521,9 @@ var require_axios = __commonJS({
|
|
|
61477
61521
|
const dots = options.dots;
|
|
61478
61522
|
const indexes = options.indexes;
|
|
61479
61523
|
const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
|
|
61480
|
-
const maxDepth = options.maxDepth === void 0 ?
|
|
61524
|
+
const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
61481
61525
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
61526
|
+
const stack = [];
|
|
61482
61527
|
if (!utils$1.isFunction(visitor)) {
|
|
61483
61528
|
throw new TypeError("visitor must be a function");
|
|
61484
61529
|
}
|
|
@@ -61494,10 +61539,38 @@ var require_axios = __commonJS({
|
|
|
61494
61539
|
throw new AxiosError("Blob is not supported. Use a Buffer instead.");
|
|
61495
61540
|
}
|
|
61496
61541
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
61497
|
-
|
|
61542
|
+
if (useBlob && typeof _Blob === "function") {
|
|
61543
|
+
return new _Blob([value]);
|
|
61544
|
+
}
|
|
61545
|
+
if (typeof Buffer !== "undefined") {
|
|
61546
|
+
return Buffer.from(value);
|
|
61547
|
+
}
|
|
61548
|
+
throw new AxiosError("Blob is not supported. Use a Buffer instead.", AxiosError.ERR_NOT_SUPPORT);
|
|
61498
61549
|
}
|
|
61499
61550
|
return value;
|
|
61500
61551
|
}
|
|
61552
|
+
function throwIfMaxDepthExceeded(depth) {
|
|
61553
|
+
if (depth > maxDepth) {
|
|
61554
|
+
throw new AxiosError("Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|
61555
|
+
}
|
|
61556
|
+
}
|
|
61557
|
+
function stringifyWithDepthLimit(value, depth) {
|
|
61558
|
+
if (maxDepth === Infinity) {
|
|
61559
|
+
return JSON.stringify(value);
|
|
61560
|
+
}
|
|
61561
|
+
const ancestors = [];
|
|
61562
|
+
return JSON.stringify(value, function limitDepth(_key, currentValue) {
|
|
61563
|
+
if (!utils$1.isObject(currentValue)) {
|
|
61564
|
+
return currentValue;
|
|
61565
|
+
}
|
|
61566
|
+
while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
|
|
61567
|
+
ancestors.pop();
|
|
61568
|
+
}
|
|
61569
|
+
ancestors.push(currentValue);
|
|
61570
|
+
throwIfMaxDepthExceeded(depth + ancestors.length - 1);
|
|
61571
|
+
return currentValue;
|
|
61572
|
+
});
|
|
61573
|
+
}
|
|
61501
61574
|
function defaultVisitor(value, key, path2) {
|
|
61502
61575
|
let arr = value;
|
|
61503
61576
|
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
@@ -61507,7 +61580,7 @@ var require_axios = __commonJS({
|
|
|
61507
61580
|
if (value && !path2 && typeof value === "object") {
|
|
61508
61581
|
if (utils$1.endsWith(key, "{}")) {
|
|
61509
61582
|
key = metaTokens ? key : key.slice(0, -2);
|
|
61510
|
-
value =
|
|
61583
|
+
value = stringifyWithDepthLimit(value, 1);
|
|
61511
61584
|
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
|
|
61512
61585
|
key = removeBrackets(key);
|
|
61513
61586
|
arr.forEach(function each(el, index) {
|
|
@@ -61526,7 +61599,6 @@ var require_axios = __commonJS({
|
|
|
61526
61599
|
formData.append(renderKey(path2, key, dots), convertValue(value));
|
|
61527
61600
|
return false;
|
|
61528
61601
|
}
|
|
61529
|
-
const stack = [];
|
|
61530
61602
|
const exposedHelpers = Object.assign(predicates, {
|
|
61531
61603
|
defaultVisitor,
|
|
61532
61604
|
convertValue,
|
|
@@ -61534,9 +61606,7 @@ var require_axios = __commonJS({
|
|
|
61534
61606
|
});
|
|
61535
61607
|
function build(value, path2, depth = 0) {
|
|
61536
61608
|
if (utils$1.isUndefined(value)) return;
|
|
61537
|
-
|
|
61538
|
-
throw new AxiosError("Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|
61539
|
-
}
|
|
61609
|
+
throwIfMaxDepthExceeded(depth);
|
|
61540
61610
|
if (stack.indexOf(value) !== -1) {
|
|
61541
61611
|
throw new Error("Circular reference detected in " + path2.join("."));
|
|
61542
61612
|
}
|
|
@@ -61577,9 +61647,7 @@ var require_axios = __commonJS({
|
|
|
61577
61647
|
this._pairs.push([name, value]);
|
|
61578
61648
|
};
|
|
61579
61649
|
prototype.toString = function toString2(encoder) {
|
|
61580
|
-
const _encode = encoder ?
|
|
61581
|
-
return encoder.call(this, value, encode$1);
|
|
61582
|
-
} : encode$1;
|
|
61650
|
+
const _encode = encoder ? (value) => encoder.call(this, value, encode$1) : encode$1;
|
|
61583
61651
|
return this._pairs.map(function each(pair) {
|
|
61584
61652
|
return _encode(pair[0]) + "=" + _encode(pair[1]);
|
|
61585
61653
|
}, "").join("&");
|
|
@@ -61591,11 +61659,12 @@ var require_axios = __commonJS({
|
|
|
61591
61659
|
if (!params) {
|
|
61592
61660
|
return url2;
|
|
61593
61661
|
}
|
|
61594
|
-
|
|
61662
|
+
url2 = url2 || "";
|
|
61595
61663
|
const _options = utils$1.isFunction(options) ? {
|
|
61596
61664
|
serialize: options
|
|
61597
61665
|
} : options;
|
|
61598
|
-
const
|
|
61666
|
+
const _encode = utils$1.getSafeProp(_options, "encode") || encode;
|
|
61667
|
+
const serializeFn = utils$1.getSafeProp(_options, "serialize");
|
|
61599
61668
|
let serializedParams;
|
|
61600
61669
|
if (serializeFn) {
|
|
61601
61670
|
serializedParams = serializeFn(params, _options);
|
|
@@ -61678,9 +61747,10 @@ var require_axios = __commonJS({
|
|
|
61678
61747
|
forcedJSONParsing: true,
|
|
61679
61748
|
clarifyTimeoutError: false,
|
|
61680
61749
|
legacyInterceptorReqResOrdering: true,
|
|
61681
|
-
advertiseZstdAcceptEncoding: false
|
|
61750
|
+
advertiseZstdAcceptEncoding: false,
|
|
61751
|
+
validateStatusUndefinedResolves: true
|
|
61682
61752
|
};
|
|
61683
|
-
var
|
|
61753
|
+
var URLSearchParams2 = url.URLSearchParams;
|
|
61684
61754
|
var ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
|
61685
61755
|
var DIGIT = "0123456789";
|
|
61686
61756
|
var ALPHABET = {
|
|
@@ -61703,7 +61773,7 @@ var require_axios = __commonJS({
|
|
|
61703
61773
|
var platform$1 = {
|
|
61704
61774
|
isNode: true,
|
|
61705
61775
|
classes: {
|
|
61706
|
-
URLSearchParams,
|
|
61776
|
+
URLSearchParams: URLSearchParams2,
|
|
61707
61777
|
FormData: FormData$1,
|
|
61708
61778
|
Blob: typeof Blob !== "undefined" && Blob || null
|
|
61709
61779
|
},
|
|
@@ -61743,10 +61813,21 @@ var require_axios = __commonJS({
|
|
|
61743
61813
|
...options
|
|
61744
61814
|
});
|
|
61745
61815
|
}
|
|
61816
|
+
var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
61817
|
+
function throwIfDepthExceeded(index) {
|
|
61818
|
+
if (index > MAX_DEPTH) {
|
|
61819
|
+
throw new AxiosError("FormData field is too deeply nested (" + index + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|
61820
|
+
}
|
|
61821
|
+
}
|
|
61746
61822
|
function parsePropPath(name) {
|
|
61747
|
-
|
|
61748
|
-
|
|
61749
|
-
|
|
61823
|
+
const path2 = [];
|
|
61824
|
+
const pattern = /\w+|\[(\w*)]/g;
|
|
61825
|
+
let match;
|
|
61826
|
+
while ((match = pattern.exec(name)) !== null) {
|
|
61827
|
+
throwIfDepthExceeded(path2.length);
|
|
61828
|
+
path2.push(match[0] === "[]" ? "" : match[1] || match[0]);
|
|
61829
|
+
}
|
|
61830
|
+
return path2;
|
|
61750
61831
|
}
|
|
61751
61832
|
function arrayToObject(arr) {
|
|
61752
61833
|
const obj = {};
|
|
@@ -61762,6 +61843,7 @@ var require_axios = __commonJS({
|
|
|
61762
61843
|
}
|
|
61763
61844
|
function formDataToJSON(formData) {
|
|
61764
61845
|
function buildPath(path2, value, target, index) {
|
|
61846
|
+
throwIfDepthExceeded(index);
|
|
61765
61847
|
let name = path2[index++];
|
|
61766
61848
|
if (name === "__proto__") return true;
|
|
61767
61849
|
const isNumericKey = Number.isFinite(+name);
|
|
@@ -61948,9 +62030,28 @@ var require_axios = __commonJS({
|
|
|
61948
62030
|
function combineURLs(baseURL, relativeURL) {
|
|
61949
62031
|
return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
61950
62032
|
}
|
|
61951
|
-
|
|
62033
|
+
var malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
62034
|
+
var httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
62035
|
+
function stripLeadingC0ControlOrSpace(url2) {
|
|
62036
|
+
let i = 0;
|
|
62037
|
+
while (i < url2.length && url2.charCodeAt(i) <= 32) {
|
|
62038
|
+
i++;
|
|
62039
|
+
}
|
|
62040
|
+
return url2.slice(i);
|
|
62041
|
+
}
|
|
62042
|
+
function normalizeURLForProtocolCheck(url2) {
|
|
62043
|
+
return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
|
|
62044
|
+
}
|
|
62045
|
+
function assertValidHttpProtocolURL(url2, config) {
|
|
62046
|
+
if (typeof url2 === "string" && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url2))) {
|
|
62047
|
+
throw new AxiosError('Invalid URL: missing "//" after protocol', AxiosError.ERR_INVALID_URL, config);
|
|
62048
|
+
}
|
|
62049
|
+
}
|
|
62050
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
62051
|
+
assertValidHttpProtocolURL(requestedURL, config);
|
|
61952
62052
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
61953
62053
|
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
62054
|
+
assertValidHttpProtocolURL(baseURL, config);
|
|
61954
62055
|
return combineURLs(baseURL, requestedURL);
|
|
61955
62056
|
}
|
|
61956
62057
|
return requestedURL;
|
|
@@ -62020,7 +62121,7 @@ var require_axios = __commonJS({
|
|
|
62020
62121
|
function getEnv(key) {
|
|
62021
62122
|
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
|
|
62022
62123
|
}
|
|
62023
|
-
var VERSION = "1.
|
|
62124
|
+
var VERSION = "1.18.1";
|
|
62024
62125
|
function parseProtocol(url2) {
|
|
62025
62126
|
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url2);
|
|
62026
62127
|
return match && match[1] || "";
|
|
@@ -62042,13 +62143,13 @@ var require_axios = __commonJS({
|
|
|
62042
62143
|
const params = match[2];
|
|
62043
62144
|
const encoding = match[3] ? "base64" : "utf8";
|
|
62044
62145
|
const body = match[4];
|
|
62045
|
-
let mime;
|
|
62146
|
+
let mime = "";
|
|
62046
62147
|
if (type) {
|
|
62047
62148
|
mime = params ? type + params : type;
|
|
62048
62149
|
} else if (params) {
|
|
62049
62150
|
mime = "text/plain" + params;
|
|
62050
62151
|
}
|
|
62051
|
-
const buffer = Buffer.from(decodeURIComponent(body), encoding);
|
|
62152
|
+
const buffer = encoding === "base64" ? Buffer.from(body, "base64") : Buffer.from(decodeURIComponent(body), encoding);
|
|
62052
62153
|
if (asBlob) {
|
|
62053
62154
|
if (!_Blob) {
|
|
62054
62155
|
throw new AxiosError("Blob is not supported", AxiosError.ERR_NOT_SUPPORT);
|
|
@@ -62372,13 +62473,29 @@ var require_axios = __commonJS({
|
|
|
62372
62473
|
}, cb);
|
|
62373
62474
|
} : fn;
|
|
62374
62475
|
};
|
|
62375
|
-
var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost"]);
|
|
62476
|
+
var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
|
|
62376
62477
|
var isIPv4Loopback = (host) => {
|
|
62377
62478
|
const parts = host.split(".");
|
|
62378
62479
|
if (parts.length !== 4) return false;
|
|
62379
62480
|
if (parts[0] !== "127") return false;
|
|
62380
62481
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
62381
62482
|
};
|
|
62483
|
+
var isIPv6ZeroGroup = (group) => /^0{1,4}$/.test(group);
|
|
62484
|
+
var isIPv6Unspecified = (host) => {
|
|
62485
|
+
if (host === "::") return true;
|
|
62486
|
+
const compressionIndex = host.indexOf("::");
|
|
62487
|
+
if (compressionIndex !== -1) {
|
|
62488
|
+
if (compressionIndex !== host.lastIndexOf("::")) return false;
|
|
62489
|
+
const left = host.slice(0, compressionIndex);
|
|
62490
|
+
const right = host.slice(compressionIndex + 2);
|
|
62491
|
+
const leftGroups = left ? left.split(":") : [];
|
|
62492
|
+
const rightGroups = right ? right.split(":") : [];
|
|
62493
|
+
const explicitGroups = leftGroups.length + rightGroups.length;
|
|
62494
|
+
return explicitGroups < 8 && leftGroups.every(isIPv6ZeroGroup) && rightGroups.every(isIPv6ZeroGroup);
|
|
62495
|
+
}
|
|
62496
|
+
const groups = host.split(":");
|
|
62497
|
+
return groups.length === 8 && groups.every(isIPv6ZeroGroup);
|
|
62498
|
+
};
|
|
62382
62499
|
var isIPv6Loopback = (host) => {
|
|
62383
62500
|
if (host === "::1") return true;
|
|
62384
62501
|
const v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
@@ -62401,6 +62518,7 @@ var require_axios = __commonJS({
|
|
|
62401
62518
|
if (!host) return false;
|
|
62402
62519
|
if (LOOPBACK_HOSTNAMES.has(host)) return true;
|
|
62403
62520
|
if (isIPv4Loopback(host)) return true;
|
|
62521
|
+
if (isIPv6Unspecified(host)) return true;
|
|
62404
62522
|
return isIPv6Loopback(host);
|
|
62405
62523
|
};
|
|
62406
62524
|
var DEFAULT_PORTS = {
|
|
@@ -62593,6 +62711,8 @@ var require_axios = __commonJS({
|
|
|
62593
62711
|
}), throttled[1]];
|
|
62594
62712
|
};
|
|
62595
62713
|
var asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
62714
|
+
var isHexDigit = (charCode) => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
|
|
62715
|
+
var isPercentEncodedByte = (str, i, len) => i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
62596
62716
|
function estimateDataURLDecodedBytes(url2) {
|
|
62597
62717
|
if (!url2 || typeof url2 !== "string") return 0;
|
|
62598
62718
|
if (!url2.startsWith("data:")) return 0;
|
|
@@ -62608,7 +62728,7 @@ var require_axios = __commonJS({
|
|
|
62608
62728
|
if (body.charCodeAt(i) === 37 && i + 2 < len) {
|
|
62609
62729
|
const a = body.charCodeAt(i + 1);
|
|
62610
62730
|
const b = body.charCodeAt(i + 2);
|
|
62611
|
-
const isHex = (a
|
|
62731
|
+
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
62612
62732
|
if (isHex) {
|
|
62613
62733
|
effectiveLen -= 2;
|
|
62614
62734
|
i += 2;
|
|
@@ -62640,13 +62760,13 @@ var require_axios = __commonJS({
|
|
|
62640
62760
|
const bytes2 = groups * 3 - (pad || 0);
|
|
62641
62761
|
return bytes2 > 0 ? bytes2 : 0;
|
|
62642
62762
|
}
|
|
62643
|
-
if (typeof Buffer !== "undefined" && typeof Buffer.byteLength === "function") {
|
|
62644
|
-
return Buffer.byteLength(body, "utf8");
|
|
62645
|
-
}
|
|
62646
62763
|
let bytes = 0;
|
|
62647
62764
|
for (let i = 0, len = body.length; i < len; i++) {
|
|
62648
62765
|
const c = body.charCodeAt(i);
|
|
62649
|
-
if (c
|
|
62766
|
+
if (c === 37 && isPercentEncodedByte(body, i, len)) {
|
|
62767
|
+
bytes += 1;
|
|
62768
|
+
i += 2;
|
|
62769
|
+
} else if (c < 128) {
|
|
62650
62770
|
bytes += 1;
|
|
62651
62771
|
} else if (c < 2048) {
|
|
62652
62772
|
bytes += 2;
|
|
@@ -62702,6 +62822,33 @@ var require_axios = __commonJS({
|
|
|
62702
62822
|
var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
|
|
62703
62823
|
var tunnelingAgentCache = /* @__PURE__ */ new Map();
|
|
62704
62824
|
var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
|
|
62825
|
+
var NODE_NATIVE_ENV_PROXY_SUPPORT = {
|
|
62826
|
+
22: 21,
|
|
62827
|
+
24: 5
|
|
62828
|
+
};
|
|
62829
|
+
function isNodeNativeEnvProxySupported(nodeVersion = process.versions && process.versions.node) {
|
|
62830
|
+
if (!nodeVersion) {
|
|
62831
|
+
return false;
|
|
62832
|
+
}
|
|
62833
|
+
const [major, minor] = nodeVersion.split(".").map((part) => Number(part));
|
|
62834
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor)) {
|
|
62835
|
+
return false;
|
|
62836
|
+
}
|
|
62837
|
+
if (major > 24) {
|
|
62838
|
+
return true;
|
|
62839
|
+
}
|
|
62840
|
+
return NODE_NATIVE_ENV_PROXY_SUPPORT[major] != null && minor >= NODE_NATIVE_ENV_PROXY_SUPPORT[major];
|
|
62841
|
+
}
|
|
62842
|
+
function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.versions.node) {
|
|
62843
|
+
if (!isNodeNativeEnvProxySupported(nodeVersion)) {
|
|
62844
|
+
return false;
|
|
62845
|
+
}
|
|
62846
|
+
const agentOptions = agent && agent.options;
|
|
62847
|
+
return Boolean(agentOptions && utils$1.hasOwnProp(agentOptions, "proxyEnv") && agentOptions.proxyEnv != null);
|
|
62848
|
+
}
|
|
62849
|
+
function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
|
|
62850
|
+
return isHttps.test(options.protocol) ? configHttpsAgent || https.globalAgent : configHttpAgent || http.globalAgent;
|
|
62851
|
+
}
|
|
62705
62852
|
function getTunnelingAgent(agentOptions, userHttpsAgent) {
|
|
62706
62853
|
const key = agentOptions.protocol + "//" + agentOptions.hostname + ":" + (agentOptions.port || "") + "#" + (agentOptions.auth || "");
|
|
62707
62854
|
const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, /* @__PURE__ */ new Map()).get(userHttpsAgent) : tunnelingAgentCache;
|
|
@@ -62753,13 +62900,37 @@ var require_axios = __commonJS({
|
|
|
62753
62900
|
if (options.beforeRedirects.auth) {
|
|
62754
62901
|
options.beforeRedirects.auth(options);
|
|
62755
62902
|
}
|
|
62903
|
+
if (options.beforeRedirects.sensitiveHeaders) {
|
|
62904
|
+
options.beforeRedirects.sensitiveHeaders(options, requestDetails);
|
|
62905
|
+
}
|
|
62756
62906
|
if (options.beforeRedirects.config) {
|
|
62757
62907
|
options.beforeRedirects.config(options, responseDetails, requestDetails);
|
|
62758
62908
|
}
|
|
62759
62909
|
}
|
|
62760
|
-
function
|
|
62910
|
+
function stripMatchingHeaders(headers, sensitiveSet) {
|
|
62911
|
+
if (!headers) {
|
|
62912
|
+
return;
|
|
62913
|
+
}
|
|
62914
|
+
Object.keys(headers).forEach((header) => {
|
|
62915
|
+
if (sensitiveSet.has(header.toLowerCase())) {
|
|
62916
|
+
delete headers[header];
|
|
62917
|
+
}
|
|
62918
|
+
});
|
|
62919
|
+
}
|
|
62920
|
+
function isSameOriginRedirect(redirectOptions, requestDetails) {
|
|
62921
|
+
if (!requestDetails) {
|
|
62922
|
+
return false;
|
|
62923
|
+
}
|
|
62924
|
+
try {
|
|
62925
|
+
return new URL(requestDetails.url).origin === new URL(redirectOptions.href).origin;
|
|
62926
|
+
} catch (e) {
|
|
62927
|
+
return false;
|
|
62928
|
+
}
|
|
62929
|
+
}
|
|
62930
|
+
function setProxy(options, configProxy, location2, isRedirect, configHttpsAgent, configHttpAgent) {
|
|
62761
62931
|
let proxy = configProxy;
|
|
62762
|
-
|
|
62932
|
+
const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
|
|
62933
|
+
if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
62763
62934
|
const proxyUrl = getProxyForUrl(location2);
|
|
62764
62935
|
if (proxyUrl) {
|
|
62765
62936
|
if (!shouldBypassProxy(location2)) {
|
|
@@ -62850,7 +63021,7 @@ var require_axios = __commonJS({
|
|
|
62850
63021
|
}
|
|
62851
63022
|
}
|
|
62852
63023
|
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
|
62853
|
-
setProxy(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent);
|
|
63024
|
+
setProxy(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent);
|
|
62854
63025
|
};
|
|
62855
63026
|
}
|
|
62856
63027
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
|
|
@@ -62927,7 +63098,7 @@ var require_axios = __commonJS({
|
|
|
62927
63098
|
};
|
|
62928
63099
|
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
|
|
62929
63100
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
62930
|
-
const own2 = (key) => utils$1.
|
|
63101
|
+
const own2 = (key) => utils$1.getSafeProp(config, key);
|
|
62931
63102
|
const transitional = own2("transitional") || transitionalDefaults;
|
|
62932
63103
|
let data = own2("data");
|
|
62933
63104
|
let lookup = own2("lookup");
|
|
@@ -62935,9 +63106,17 @@ var require_axios = __commonJS({
|
|
|
62935
63106
|
let httpVersion = own2("httpVersion");
|
|
62936
63107
|
if (httpVersion === void 0) httpVersion = 1;
|
|
62937
63108
|
let http2Options = own2("http2Options");
|
|
63109
|
+
const httpAgent = own2("httpAgent");
|
|
63110
|
+
const httpsAgent = own2("httpsAgent");
|
|
63111
|
+
const configProxy = own2("proxy");
|
|
62938
63112
|
const responseType = own2("responseType");
|
|
62939
63113
|
const responseEncoding = own2("responseEncoding");
|
|
62940
|
-
const
|
|
63114
|
+
const socketPath = own2("socketPath");
|
|
63115
|
+
const method = own2("method").toUpperCase();
|
|
63116
|
+
const maxRedirects = own2("maxRedirects");
|
|
63117
|
+
const maxBodyLength = own2("maxBodyLength");
|
|
63118
|
+
const maxContentLength = own2("maxContentLength");
|
|
63119
|
+
const decompress = own2("decompress");
|
|
62941
63120
|
let isDone;
|
|
62942
63121
|
let rejected = false;
|
|
62943
63122
|
let req;
|
|
@@ -62976,9 +63155,11 @@ var require_axios = __commonJS({
|
|
|
62976
63155
|
}
|
|
62977
63156
|
}
|
|
62978
63157
|
function createTimeoutError() {
|
|
62979
|
-
|
|
62980
|
-
|
|
62981
|
-
|
|
63158
|
+
const configTimeout = own2("timeout");
|
|
63159
|
+
let timeoutErrorMessage = configTimeout ? "timeout of " + configTimeout + "ms exceeded" : "timeout exceeded";
|
|
63160
|
+
const configTimeoutErrorMessage = own2("timeoutErrorMessage");
|
|
63161
|
+
if (configTimeoutErrorMessage) {
|
|
63162
|
+
timeoutErrorMessage = configTimeoutErrorMessage;
|
|
62982
63163
|
}
|
|
62983
63164
|
return new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req);
|
|
62984
63165
|
}
|
|
@@ -63019,15 +63200,16 @@ var require_axios = __commonJS({
|
|
|
63019
63200
|
onFinished();
|
|
63020
63201
|
}
|
|
63021
63202
|
});
|
|
63022
|
-
const fullPath = buildFullPath(
|
|
63023
|
-
const
|
|
63203
|
+
const fullPath = buildFullPath(own2("baseURL"), own2("url"), own2("allowAbsoluteUrls"), config);
|
|
63204
|
+
const urlBase = socketPath ? "http://localhost" : platform.hasBrowserEnv ? platform.origin : void 0;
|
|
63205
|
+
const parsed = new URL(fullPath, urlBase);
|
|
63024
63206
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
63025
63207
|
if (protocol === "data:") {
|
|
63026
|
-
if (
|
|
63027
|
-
const dataUrl = String(
|
|
63208
|
+
if (maxContentLength > -1) {
|
|
63209
|
+
const dataUrl = String(own2("url") || fullPath || "");
|
|
63028
63210
|
const estimated = estimateDataURLDecodedBytes(dataUrl);
|
|
63029
|
-
if (estimated >
|
|
63030
|
-
return reject(new AxiosError("maxContentLength size of " +
|
|
63211
|
+
if (estimated > maxContentLength) {
|
|
63212
|
+
return reject(new AxiosError("maxContentLength size of " + maxContentLength + " exceeded", AxiosError.ERR_BAD_RESPONSE, config));
|
|
63031
63213
|
}
|
|
63032
63214
|
}
|
|
63033
63215
|
let convertedData;
|
|
@@ -63040,7 +63222,7 @@ var require_axios = __commonJS({
|
|
|
63040
63222
|
});
|
|
63041
63223
|
}
|
|
63042
63224
|
try {
|
|
63043
|
-
convertedData = fromDataURI(
|
|
63225
|
+
convertedData = fromDataURI(own2("url"), responseType === "blob", {
|
|
63044
63226
|
Blob: config.env && config.env.Blob
|
|
63045
63227
|
});
|
|
63046
63228
|
} catch (err) {
|
|
@@ -63105,7 +63287,7 @@ var require_axios = __commonJS({
|
|
|
63105
63287
|
return reject(new AxiosError("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream", AxiosError.ERR_BAD_REQUEST, config));
|
|
63106
63288
|
}
|
|
63107
63289
|
headers.setContentLength(data.length, false);
|
|
63108
|
-
if (
|
|
63290
|
+
if (maxBodyLength > -1 && data.length > maxBodyLength) {
|
|
63109
63291
|
return reject(new AxiosError("Request body larger than maxBodyLength limit", AxiosError.ERR_BAD_REQUEST, config));
|
|
63110
63292
|
}
|
|
63111
63293
|
}
|
|
@@ -63130,8 +63312,8 @@ var require_axios = __commonJS({
|
|
|
63130
63312
|
let auth = void 0;
|
|
63131
63313
|
const configAuth = own2("auth");
|
|
63132
63314
|
if (configAuth) {
|
|
63133
|
-
const username = configAuth
|
|
63134
|
-
const password = configAuth
|
|
63315
|
+
const username = utils$1.getSafeProp(configAuth, "username") || "";
|
|
63316
|
+
const password = utils$1.getSafeProp(configAuth, "password") || "";
|
|
63135
63317
|
auth = username + ":" + password;
|
|
63136
63318
|
}
|
|
63137
63319
|
if (!auth && (parsed.username || parsed.password)) {
|
|
@@ -63142,13 +63324,12 @@ var require_axios = __commonJS({
|
|
|
63142
63324
|
auth && headers.delete("authorization");
|
|
63143
63325
|
let path$1;
|
|
63144
63326
|
try {
|
|
63145
|
-
path$1 = buildURL(parsed.pathname + parsed.search,
|
|
63327
|
+
path$1 = buildURL(parsed.pathname + parsed.search, own2("params"), own2("paramsSerializer")).replace(/^\?/, "");
|
|
63146
63328
|
} catch (err) {
|
|
63147
|
-
|
|
63148
|
-
|
|
63149
|
-
|
|
63150
|
-
|
|
63151
|
-
return reject(customErr);
|
|
63329
|
+
return reject(AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config, null, null, {
|
|
63330
|
+
url: own2("url"),
|
|
63331
|
+
exists: true
|
|
63332
|
+
}));
|
|
63152
63333
|
}
|
|
63153
63334
|
headers.set("Accept-Encoding", utils$1.hasOwnProp(transitional, "advertiseZstdAcceptEncoding") && transitional.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING, false);
|
|
63154
63335
|
const options = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
@@ -63156,8 +63337,8 @@ var require_axios = __commonJS({
|
|
|
63156
63337
|
method,
|
|
63157
63338
|
headers: toByteStringHeaderObject(headers),
|
|
63158
63339
|
agents: {
|
|
63159
|
-
http:
|
|
63160
|
-
https:
|
|
63340
|
+
http: httpAgent,
|
|
63341
|
+
https: httpsAgent
|
|
63161
63342
|
},
|
|
63162
63343
|
auth,
|
|
63163
63344
|
protocol,
|
|
@@ -63167,7 +63348,6 @@ var require_axios = __commonJS({
|
|
|
63167
63348
|
http2Options
|
|
63168
63349
|
});
|
|
63169
63350
|
!utils$1.isUndefined(lookup) && (options.lookup = lookup);
|
|
63170
|
-
const socketPath = own2("socketPath");
|
|
63171
63351
|
if (socketPath) {
|
|
63172
63352
|
if (typeof socketPath !== "string") {
|
|
63173
63353
|
return reject(new AxiosError("socketPath must be a string", AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
@@ -63185,13 +63365,14 @@ var require_axios = __commonJS({
|
|
|
63185
63365
|
} else {
|
|
63186
63366
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
63187
63367
|
options.port = parsed.port;
|
|
63188
|
-
setProxy(options,
|
|
63368
|
+
setProxy(options, configProxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path, false, httpsAgent, httpAgent);
|
|
63189
63369
|
}
|
|
63190
63370
|
let transport;
|
|
63191
63371
|
let isNativeTransport = false;
|
|
63372
|
+
let transportEnforcesMaxBodyLength = false;
|
|
63192
63373
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
63193
63374
|
if (options.agent == null) {
|
|
63194
|
-
options.agent = isHttpsRequest ?
|
|
63375
|
+
options.agent = isHttpsRequest ? httpsAgent : httpAgent;
|
|
63195
63376
|
}
|
|
63196
63377
|
if (isHttp2) {
|
|
63197
63378
|
transport = http2Transport;
|
|
@@ -63199,12 +63380,14 @@ var require_axios = __commonJS({
|
|
|
63199
63380
|
const configTransport = own2("transport");
|
|
63200
63381
|
if (configTransport) {
|
|
63201
63382
|
transport = configTransport;
|
|
63202
|
-
} else if (
|
|
63383
|
+
} else if (maxRedirects === 0) {
|
|
63203
63384
|
transport = isHttpsRequest ? https : http;
|
|
63204
63385
|
isNativeTransport = true;
|
|
63205
63386
|
} else {
|
|
63206
|
-
|
|
63207
|
-
|
|
63387
|
+
transportEnforcesMaxBodyLength = true;
|
|
63388
|
+
options.sensitiveHeaders = [];
|
|
63389
|
+
if (maxRedirects) {
|
|
63390
|
+
options.maxRedirects = maxRedirects;
|
|
63208
63391
|
}
|
|
63209
63392
|
const configBeforeRedirect = own2("beforeRedirect");
|
|
63210
63393
|
if (configBeforeRedirect) {
|
|
@@ -63222,11 +63405,32 @@ var require_axios = __commonJS({
|
|
|
63222
63405
|
}
|
|
63223
63406
|
};
|
|
63224
63407
|
}
|
|
63408
|
+
const sensitiveHeaders = own2("sensitiveHeaders");
|
|
63409
|
+
if (sensitiveHeaders != null) {
|
|
63410
|
+
if (!utils$1.isArray(sensitiveHeaders)) {
|
|
63411
|
+
return reject(new AxiosError("sensitiveHeaders must be an array of strings", AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
63412
|
+
}
|
|
63413
|
+
const sensitiveSet = /* @__PURE__ */ new Set();
|
|
63414
|
+
for (const header of sensitiveHeaders) {
|
|
63415
|
+
if (!utils$1.isString(header)) {
|
|
63416
|
+
return reject(new AxiosError("sensitiveHeaders must be an array of strings", AxiosError.ERR_BAD_OPTION_VALUE, config));
|
|
63417
|
+
}
|
|
63418
|
+
sensitiveSet.add(header.toLowerCase());
|
|
63419
|
+
}
|
|
63420
|
+
if (sensitiveSet.size) {
|
|
63421
|
+
options.sensitiveHeaders = Array.from(sensitiveSet);
|
|
63422
|
+
options.beforeRedirects.sensitiveHeaders = function beforeRedirectSensitiveHeaders(redirectOptions, requestDetails) {
|
|
63423
|
+
if (!isSameOriginRedirect(redirectOptions, requestDetails)) {
|
|
63424
|
+
stripMatchingHeaders(redirectOptions.headers, sensitiveSet);
|
|
63425
|
+
}
|
|
63426
|
+
};
|
|
63427
|
+
}
|
|
63428
|
+
}
|
|
63225
63429
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
63226
63430
|
}
|
|
63227
63431
|
}
|
|
63228
|
-
if (
|
|
63229
|
-
options.maxBodyLength =
|
|
63432
|
+
if (maxBodyLength > -1) {
|
|
63433
|
+
options.maxBodyLength = maxBodyLength;
|
|
63230
63434
|
} else {
|
|
63231
63435
|
options.maxBodyLength = Infinity;
|
|
63232
63436
|
}
|
|
@@ -63245,7 +63449,7 @@ var require_axios = __commonJS({
|
|
|
63245
63449
|
}
|
|
63246
63450
|
let responseStream = res;
|
|
63247
63451
|
const lastRequest = res.req || req;
|
|
63248
|
-
if (
|
|
63452
|
+
if (decompress !== false && res.headers["content-encoding"]) {
|
|
63249
63453
|
if (method === "HEAD" || res.statusCode === 204) {
|
|
63250
63454
|
delete res.headers["content-encoding"];
|
|
63251
63455
|
}
|
|
@@ -63286,8 +63490,8 @@ var require_axios = __commonJS({
|
|
|
63286
63490
|
request: lastRequest
|
|
63287
63491
|
};
|
|
63288
63492
|
if (responseType === "stream") {
|
|
63289
|
-
if (
|
|
63290
|
-
const limit =
|
|
63493
|
+
if (maxContentLength > -1) {
|
|
63494
|
+
const limit = maxContentLength;
|
|
63291
63495
|
const source = responseStream;
|
|
63292
63496
|
async function* enforceMaxContentLength() {
|
|
63293
63497
|
let totalResponseBytes = 0;
|
|
@@ -63311,10 +63515,10 @@ var require_axios = __commonJS({
|
|
|
63311
63515
|
responseStream.on("data", function handleStreamData(chunk) {
|
|
63312
63516
|
responseBuffer.push(chunk);
|
|
63313
63517
|
totalResponseBytes += chunk.length;
|
|
63314
|
-
if (
|
|
63518
|
+
if (maxContentLength > -1 && totalResponseBytes > maxContentLength) {
|
|
63315
63519
|
rejected = true;
|
|
63316
63520
|
responseStream.destroy();
|
|
63317
|
-
abort(new AxiosError("maxContentLength size of " +
|
|
63521
|
+
abort(new AxiosError("maxContentLength size of " + maxContentLength + " exceeded", AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
|
|
63318
63522
|
}
|
|
63319
63523
|
});
|
|
63320
63524
|
responseStream.on("aborted", function handlerStreamAborted() {
|
|
@@ -63364,7 +63568,9 @@ var require_axios = __commonJS({
|
|
|
63364
63568
|
});
|
|
63365
63569
|
const boundSockets = /* @__PURE__ */ new Set();
|
|
63366
63570
|
req.on("socket", function handleRequestSocket(socket) {
|
|
63367
|
-
socket.setKeepAlive
|
|
63571
|
+
if (typeof socket.setKeepAlive === "function") {
|
|
63572
|
+
socket.setKeepAlive(true, 1e3 * 60);
|
|
63573
|
+
}
|
|
63368
63574
|
if (!socket[kAxiosSocketListener]) {
|
|
63369
63575
|
socket.on("error", function handleSocketError(err) {
|
|
63370
63576
|
const current = socket[kAxiosCurrentReq];
|
|
@@ -63386,8 +63592,8 @@ var require_axios = __commonJS({
|
|
|
63386
63592
|
}
|
|
63387
63593
|
boundSockets.clear();
|
|
63388
63594
|
});
|
|
63389
|
-
if (
|
|
63390
|
-
const timeout = parseInt(
|
|
63595
|
+
if (own2("timeout")) {
|
|
63596
|
+
const timeout = parseInt(own2("timeout"), 10);
|
|
63391
63597
|
if (Number.isNaN(timeout)) {
|
|
63392
63598
|
abort(new AxiosError("error trying to parse `config.timeout` to int", AxiosError.ERR_BAD_OPTION_VALUE, config, req));
|
|
63393
63599
|
return;
|
|
@@ -63419,8 +63625,8 @@ var require_axios = __commonJS({
|
|
|
63419
63625
|
}
|
|
63420
63626
|
});
|
|
63421
63627
|
let uploadStream = data;
|
|
63422
|
-
if (
|
|
63423
|
-
const limit =
|
|
63628
|
+
if (maxBodyLength > -1 && !transportEnforcesMaxBodyLength) {
|
|
63629
|
+
const limit = maxBodyLength;
|
|
63424
63630
|
let bytesSent = 0;
|
|
63425
63631
|
uploadStream = stream.pipeline([data, new stream.Transform({
|
|
63426
63632
|
transform(chunk, _enc, cb) {
|
|
@@ -63476,7 +63682,11 @@ var require_axios = __commonJS({
|
|
|
63476
63682
|
const cookie = cookies2[i].replace(/^\s+/, "");
|
|
63477
63683
|
const eq = cookie.indexOf("=");
|
|
63478
63684
|
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
63479
|
-
|
|
63685
|
+
try {
|
|
63686
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
63687
|
+
} catch (e) {
|
|
63688
|
+
return cookie.slice(eq + 1);
|
|
63689
|
+
}
|
|
63480
63690
|
}
|
|
63481
63691
|
}
|
|
63482
63692
|
return null;
|
|
@@ -63501,6 +63711,7 @@ var require_axios = __commonJS({
|
|
|
63501
63711
|
...thing
|
|
63502
63712
|
} : thing;
|
|
63503
63713
|
function mergeConfig(config1, config2) {
|
|
63714
|
+
config1 = config1 || {};
|
|
63504
63715
|
config2 = config2 || {};
|
|
63505
63716
|
const config = /* @__PURE__ */ Object.create(null);
|
|
63506
63717
|
Object.defineProperty(config, "hasOwnProperty", {
|
|
@@ -63543,6 +63754,23 @@ var require_axios = __commonJS({
|
|
|
63543
63754
|
return getMergedValue(void 0, a);
|
|
63544
63755
|
}
|
|
63545
63756
|
}
|
|
63757
|
+
function getMergedTransitionalOption(prop) {
|
|
63758
|
+
const transitional2 = utils$1.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
|
|
63759
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
63760
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
63761
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
63762
|
+
return transitional2[prop];
|
|
63763
|
+
}
|
|
63764
|
+
} else {
|
|
63765
|
+
return void 0;
|
|
63766
|
+
}
|
|
63767
|
+
}
|
|
63768
|
+
const transitional1 = utils$1.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
|
|
63769
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
63770
|
+
return transitional1[prop];
|
|
63771
|
+
}
|
|
63772
|
+
return void 0;
|
|
63773
|
+
}
|
|
63546
63774
|
function mergeDirectKeys(a, b, prop) {
|
|
63547
63775
|
if (utils$1.hasOwnProp(config2, prop)) {
|
|
63548
63776
|
return getMergedValue(a, b);
|
|
@@ -63593,6 +63821,13 @@ var require_axios = __commonJS({
|
|
|
63593
63821
|
const configValue = merge2(a, b, prop);
|
|
63594
63822
|
utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
63595
63823
|
});
|
|
63824
|
+
if (utils$1.hasOwnProp(config2, "validateStatus") && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption("validateStatusUndefinedResolves") === false) {
|
|
63825
|
+
if (utils$1.hasOwnProp(config1, "validateStatus")) {
|
|
63826
|
+
config.validateStatus = getMergedValue(void 0, config1.validateStatus);
|
|
63827
|
+
} else {
|
|
63828
|
+
delete config.validateStatus;
|
|
63829
|
+
}
|
|
63830
|
+
}
|
|
63596
63831
|
return config;
|
|
63597
63832
|
}
|
|
63598
63833
|
var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
|
|
@@ -63601,7 +63836,7 @@ var require_axios = __commonJS({
|
|
|
63601
63836
|
headers.set(formHeaders);
|
|
63602
63837
|
return;
|
|
63603
63838
|
}
|
|
63604
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
63839
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
63605
63840
|
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
63606
63841
|
headers.set(key, val);
|
|
63607
63842
|
}
|
|
@@ -63621,9 +63856,15 @@ var require_axios = __commonJS({
|
|
|
63621
63856
|
const allowAbsoluteUrls = own2("allowAbsoluteUrls");
|
|
63622
63857
|
const url2 = own2("url");
|
|
63623
63858
|
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
63624
|
-
newConfig.url = buildURL(buildFullPath(baseURL, url2, allowAbsoluteUrls), own2("params"), own2("paramsSerializer"));
|
|
63859
|
+
newConfig.url = buildURL(buildFullPath(baseURL, url2, allowAbsoluteUrls, newConfig), own2("params"), own2("paramsSerializer"));
|
|
63625
63860
|
if (auth) {
|
|
63626
|
-
|
|
63861
|
+
const username = utils$1.getSafeProp(auth, "username") || "";
|
|
63862
|
+
const password = utils$1.getSafeProp(auth, "password") || "";
|
|
63863
|
+
try {
|
|
63864
|
+
headers.set("Authorization", "Basic " + btoa(username + ":" + (password ? encodeUTF8$1(password) : "")));
|
|
63865
|
+
} catch (e) {
|
|
63866
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
63867
|
+
}
|
|
63627
63868
|
}
|
|
63628
63869
|
if (utils$1.isFormData(data)) {
|
|
63629
63870
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
|
|
@@ -63770,6 +64011,7 @@ var require_axios = __commonJS({
|
|
|
63770
64011
|
const protocol = parseProtocol(_config.url);
|
|
63771
64012
|
if (protocol && !platform.protocols.includes(protocol)) {
|
|
63772
64013
|
reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
|
|
64014
|
+
done();
|
|
63773
64015
|
return;
|
|
63774
64016
|
}
|
|
63775
64017
|
request.send(requestData || null);
|
|
@@ -63805,7 +64047,9 @@ var require_axios = __commonJS({
|
|
|
63805
64047
|
});
|
|
63806
64048
|
signals = null;
|
|
63807
64049
|
};
|
|
63808
|
-
signals.forEach((signal2) => signal2.addEventListener("abort", onabort
|
|
64050
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort, {
|
|
64051
|
+
once: true
|
|
64052
|
+
}));
|
|
63809
64053
|
const {
|
|
63810
64054
|
signal
|
|
63811
64055
|
} = controller;
|
|
@@ -64035,12 +64279,14 @@ var require_axios = __commonJS({
|
|
|
64035
64279
|
composedSignal.unsubscribe();
|
|
64036
64280
|
});
|
|
64037
64281
|
let requestContentLength;
|
|
64282
|
+
let pendingBodyError = null;
|
|
64283
|
+
const maxBodyLengthError = () => new AxiosError("Request body larger than maxBodyLength limit", AxiosError.ERR_BAD_REQUEST, config, request);
|
|
64038
64284
|
try {
|
|
64039
64285
|
let auth = void 0;
|
|
64040
64286
|
const configAuth = own2("auth");
|
|
64041
64287
|
if (configAuth) {
|
|
64042
|
-
const username = configAuth
|
|
64043
|
-
const password = configAuth
|
|
64288
|
+
const username = utils$1.getSafeProp(configAuth, "username") || "";
|
|
64289
|
+
const password = utils$1.getSafeProp(configAuth, "password") || "";
|
|
64044
64290
|
auth = {
|
|
64045
64291
|
username,
|
|
64046
64292
|
password
|
|
@@ -64073,25 +64319,42 @@ var require_axios = __commonJS({
|
|
|
64073
64319
|
}
|
|
64074
64320
|
}
|
|
64075
64321
|
if (hasMaxBodyLength && method !== "get" && method !== "head") {
|
|
64076
|
-
const outboundLength = await
|
|
64077
|
-
if (typeof outboundLength === "number" && isFinite(outboundLength)
|
|
64078
|
-
|
|
64322
|
+
const outboundLength = await getBodyLength(data);
|
|
64323
|
+
if (typeof outboundLength === "number" && isFinite(outboundLength)) {
|
|
64324
|
+
requestContentLength = outboundLength;
|
|
64325
|
+
if (outboundLength > maxBodyLength) {
|
|
64326
|
+
throw maxBodyLengthError();
|
|
64327
|
+
}
|
|
64079
64328
|
}
|
|
64080
64329
|
}
|
|
64081
|
-
|
|
64082
|
-
|
|
64083
|
-
|
|
64084
|
-
|
|
64085
|
-
|
|
64086
|
-
|
|
64087
|
-
|
|
64088
|
-
|
|
64089
|
-
|
|
64090
|
-
|
|
64091
|
-
|
|
64092
|
-
|
|
64093
|
-
|
|
64330
|
+
const mustEnforceStreamBody = hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
|
|
64331
|
+
const trackRequestStream = (stream2, onProgress, flush) => trackStream(stream2, DEFAULT_CHUNK_SIZE, (loadedBytes) => {
|
|
64332
|
+
if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
|
|
64333
|
+
throw pendingBodyError = maxBodyLengthError();
|
|
64334
|
+
}
|
|
64335
|
+
onProgress && onProgress(loadedBytes);
|
|
64336
|
+
}, flush);
|
|
64337
|
+
if (supportsRequestStream && method !== "get" && method !== "head" && (onUploadProgress || mustEnforceStreamBody)) {
|
|
64338
|
+
requestContentLength = requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
|
|
64339
|
+
if (requestContentLength !== 0 || mustEnforceStreamBody) {
|
|
64340
|
+
let _request = new Request(url2, {
|
|
64341
|
+
method: "POST",
|
|
64342
|
+
body: data,
|
|
64343
|
+
duplex: "half"
|
|
64344
|
+
});
|
|
64345
|
+
let contentTypeHeader;
|
|
64346
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
|
|
64347
|
+
headers.setContentType(contentTypeHeader);
|
|
64348
|
+
}
|
|
64349
|
+
if (_request.body) {
|
|
64350
|
+
const [onProgress, flush] = onUploadProgress && progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))) || [];
|
|
64351
|
+
data = trackRequestStream(_request.body, onProgress, flush);
|
|
64352
|
+
}
|
|
64094
64353
|
}
|
|
64354
|
+
} else if (mustEnforceStreamBody && !isRequestSupported && isReadableStreamSupported && method !== "get" && method !== "head") {
|
|
64355
|
+
data = trackRequestStream(data);
|
|
64356
|
+
} else if (mustEnforceStreamBody && isRequestSupported && !supportsRequestStream && method !== "get" && method !== "head") {
|
|
64357
|
+
throw new AxiosError("Stream request bodies are not supported by the current fetch implementation", AxiosError.ERR_NOT_SUPPORT, config, request);
|
|
64095
64358
|
}
|
|
64096
64359
|
if (!utils$1.isString(withCredentials)) {
|
|
64097
64360
|
withCredentials = withCredentials ? "include" : "omit";
|
|
@@ -64115,8 +64378,9 @@ var require_axios = __commonJS({
|
|
|
64115
64378
|
};
|
|
64116
64379
|
request = isRequestSupported && new Request(url2, resolvedOptions);
|
|
64117
64380
|
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
|
|
64381
|
+
const responseHeaders = AxiosHeaders.from(response.headers);
|
|
64118
64382
|
if (hasMaxContentLength) {
|
|
64119
|
-
const declaredLength = utils$1.toFiniteNumber(
|
|
64383
|
+
const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
64120
64384
|
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
64121
64385
|
throw new AxiosError("maxContentLength size of " + maxContentLength + " exceeded", AxiosError.ERR_BAD_RESPONSE, config, request);
|
|
64122
64386
|
}
|
|
@@ -64127,7 +64391,7 @@ var require_axios = __commonJS({
|
|
|
64127
64391
|
["status", "statusText", "headers"].forEach((prop) => {
|
|
64128
64392
|
options[prop] = response[prop];
|
|
64129
64393
|
});
|
|
64130
|
-
const responseContentLength = utils$1.toFiniteNumber(
|
|
64394
|
+
const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
64131
64395
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [];
|
|
64132
64396
|
let bytesRead = 0;
|
|
64133
64397
|
const onChunkProgress = (loadedBytes) => {
|
|
@@ -64178,13 +64442,35 @@ var require_axios = __commonJS({
|
|
|
64178
64442
|
const canceledError = composedSignal.reason;
|
|
64179
64443
|
canceledError.config = config;
|
|
64180
64444
|
request && (canceledError.request = request);
|
|
64181
|
-
err !== canceledError
|
|
64445
|
+
if (err !== canceledError) {
|
|
64446
|
+
Object.defineProperty(canceledError, "cause", {
|
|
64447
|
+
__proto__: null,
|
|
64448
|
+
value: err,
|
|
64449
|
+
writable: true,
|
|
64450
|
+
enumerable: false,
|
|
64451
|
+
configurable: true
|
|
64452
|
+
});
|
|
64453
|
+
}
|
|
64182
64454
|
throw canceledError;
|
|
64183
64455
|
}
|
|
64456
|
+
if (pendingBodyError) {
|
|
64457
|
+
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
64458
|
+
throw pendingBodyError;
|
|
64459
|
+
}
|
|
64460
|
+
if (err instanceof AxiosError) {
|
|
64461
|
+
request && !err.request && (err.request = request);
|
|
64462
|
+
throw err;
|
|
64463
|
+
}
|
|
64184
64464
|
if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
|
|
64185
|
-
|
|
64186
|
-
|
|
64465
|
+
const networkError = new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request, err && err.response);
|
|
64466
|
+
Object.defineProperty(networkError, "cause", {
|
|
64467
|
+
__proto__: null,
|
|
64468
|
+
value: err.cause || err,
|
|
64469
|
+
writable: true,
|
|
64470
|
+
enumerable: false,
|
|
64471
|
+
configurable: true
|
|
64187
64472
|
});
|
|
64473
|
+
throw networkError;
|
|
64188
64474
|
}
|
|
64189
64475
|
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
64190
64476
|
}
|
|
@@ -64259,7 +64545,7 @@ var require_axios = __commonJS({
|
|
|
64259
64545
|
if (!adapter) {
|
|
64260
64546
|
const reasons = Object.entries(rejectedReasons).map(([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build"));
|
|
64261
64547
|
let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
|
|
64262
|
-
throw new AxiosError(`There is no suitable adapter to dispatch the request ` + s,
|
|
64548
|
+
throw new AxiosError(`There is no suitable adapter to dispatch the request ` + s, AxiosError.ERR_NOT_SUPPORT);
|
|
64263
64549
|
}
|
|
64264
64550
|
return adapter;
|
|
64265
64551
|
}
|
|
@@ -64346,7 +64632,7 @@ var require_axios = __commonJS({
|
|
|
64346
64632
|
};
|
|
64347
64633
|
};
|
|
64348
64634
|
function assertOptions(options, schema, allowUnknown) {
|
|
64349
|
-
if (typeof options !== "object") {
|
|
64635
|
+
if (typeof options !== "object" || options === null) {
|
|
64350
64636
|
throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
|
|
64351
64637
|
}
|
|
64352
64638
|
const keys = Object.keys(options);
|
|
@@ -64438,7 +64724,8 @@ var require_axios = __commonJS({
|
|
|
64438
64724
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
64439
64725
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
64440
64726
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
64441
|
-
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean)
|
|
64727
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
64728
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean)
|
|
64442
64729
|
}, false);
|
|
64443
64730
|
}
|
|
64444
64731
|
if (paramsSerializer != null) {
|
|
@@ -64528,7 +64815,7 @@ var require_axios = __commonJS({
|
|
|
64528
64815
|
}
|
|
64529
64816
|
getUri(config) {
|
|
64530
64817
|
config = mergeConfig(this.defaults, config);
|
|
64531
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
64818
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
|
|
64532
64819
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
64533
64820
|
}
|
|
64534
64821
|
};
|
|
@@ -64537,7 +64824,7 @@ var require_axios = __commonJS({
|
|
|
64537
64824
|
return this.request(mergeConfig(config || {}, {
|
|
64538
64825
|
method,
|
|
64539
64826
|
url: url2,
|
|
64540
|
-
data: (config
|
|
64827
|
+
data: config && utils$1.hasOwnProp(config, "data") ? config.data : void 0
|
|
64541
64828
|
}));
|
|
64542
64829
|
};
|
|
64543
64830
|
});
|
|
@@ -65119,6 +65406,3267 @@ var require_diff = __commonJS({
|
|
|
65119
65406
|
}
|
|
65120
65407
|
});
|
|
65121
65408
|
|
|
65409
|
+
// ../../node_modules/@coderifts/sdk/dist/cjs/errors.js
|
|
65410
|
+
var require_errors5 = __commonJS({
|
|
65411
|
+
"../../node_modules/@coderifts/sdk/dist/cjs/errors.js"(exports2) {
|
|
65412
|
+
"use strict";
|
|
65413
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65414
|
+
exports2.AuthError = exports2.RateLimitError = exports2.TimeoutError = exports2.ApiError = exports2.CodeRiftsError = void 0;
|
|
65415
|
+
var CodeRiftsError = class extends Error {
|
|
65416
|
+
code;
|
|
65417
|
+
constructor(message, code = "unknown") {
|
|
65418
|
+
super(message);
|
|
65419
|
+
this.name = "CodeRiftsError";
|
|
65420
|
+
this.code = code;
|
|
65421
|
+
}
|
|
65422
|
+
};
|
|
65423
|
+
exports2.CodeRiftsError = CodeRiftsError;
|
|
65424
|
+
var ApiError = class extends CodeRiftsError {
|
|
65425
|
+
status;
|
|
65426
|
+
code;
|
|
65427
|
+
body;
|
|
65428
|
+
constructor(status, body) {
|
|
65429
|
+
super(`[${status}] ${body.error}: ${body.message}`);
|
|
65430
|
+
this.name = "ApiError";
|
|
65431
|
+
this.status = status;
|
|
65432
|
+
this.code = body.error;
|
|
65433
|
+
this.body = body;
|
|
65434
|
+
}
|
|
65435
|
+
};
|
|
65436
|
+
exports2.ApiError = ApiError;
|
|
65437
|
+
var TimeoutError = class extends CodeRiftsError {
|
|
65438
|
+
constructor(timeoutMs) {
|
|
65439
|
+
super(`Request timed out after ${timeoutMs}ms`);
|
|
65440
|
+
this.name = "TimeoutError";
|
|
65441
|
+
}
|
|
65442
|
+
};
|
|
65443
|
+
exports2.TimeoutError = TimeoutError;
|
|
65444
|
+
var RateLimitError = class extends ApiError {
|
|
65445
|
+
constructor(body) {
|
|
65446
|
+
super(429, body);
|
|
65447
|
+
this.name = "RateLimitError";
|
|
65448
|
+
}
|
|
65449
|
+
};
|
|
65450
|
+
exports2.RateLimitError = RateLimitError;
|
|
65451
|
+
var AuthError = class extends ApiError {
|
|
65452
|
+
constructor(body) {
|
|
65453
|
+
super(401, body);
|
|
65454
|
+
this.name = "AuthError";
|
|
65455
|
+
}
|
|
65456
|
+
};
|
|
65457
|
+
exports2.AuthError = AuthError;
|
|
65458
|
+
}
|
|
65459
|
+
});
|
|
65460
|
+
|
|
65461
|
+
// ../../node_modules/@coderifts/sdk/dist/cjs/client.js
|
|
65462
|
+
var require_client = __commonJS({
|
|
65463
|
+
"../../node_modules/@coderifts/sdk/dist/cjs/client.js"(exports2) {
|
|
65464
|
+
"use strict";
|
|
65465
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65466
|
+
exports2.CodeRifts = void 0;
|
|
65467
|
+
var errors_js_1 = require_errors5();
|
|
65468
|
+
var DEFAULT_BASE_URL = "https://app.coderifts.com";
|
|
65469
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
65470
|
+
var CodeRifts = class {
|
|
65471
|
+
apiKey;
|
|
65472
|
+
baseUrl;
|
|
65473
|
+
timeout;
|
|
65474
|
+
constructor(options) {
|
|
65475
|
+
if (!options.apiKey) {
|
|
65476
|
+
throw new Error("apiKey is required");
|
|
65477
|
+
}
|
|
65478
|
+
this.apiKey = options.apiKey;
|
|
65479
|
+
this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
65480
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT;
|
|
65481
|
+
}
|
|
65482
|
+
// ─── Internal HTTP helper ──────────────────────────────────────────────
|
|
65483
|
+
async request(method, path, body) {
|
|
65484
|
+
const url = `${this.baseUrl}${path}`;
|
|
65485
|
+
const controller = new AbortController();
|
|
65486
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
65487
|
+
try {
|
|
65488
|
+
const res = await fetch(url, {
|
|
65489
|
+
method,
|
|
65490
|
+
headers: {
|
|
65491
|
+
"Content-Type": "application/json",
|
|
65492
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
65493
|
+
},
|
|
65494
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
65495
|
+
signal: controller.signal
|
|
65496
|
+
});
|
|
65497
|
+
const json = await res.json();
|
|
65498
|
+
if (!res.ok) {
|
|
65499
|
+
const errorBody = {
|
|
65500
|
+
error: json.error || "unknown",
|
|
65501
|
+
message: json.message || res.statusText
|
|
65502
|
+
};
|
|
65503
|
+
if (res.status === 401)
|
|
65504
|
+
throw new errors_js_1.AuthError(errorBody);
|
|
65505
|
+
if (res.status === 429)
|
|
65506
|
+
throw new errors_js_1.RateLimitError(errorBody);
|
|
65507
|
+
throw new errors_js_1.ApiError(res.status, errorBody);
|
|
65508
|
+
}
|
|
65509
|
+
return json;
|
|
65510
|
+
} catch (err) {
|
|
65511
|
+
if (err instanceof errors_js_1.ApiError)
|
|
65512
|
+
throw err;
|
|
65513
|
+
if (err.name === "AbortError") {
|
|
65514
|
+
throw new errors_js_1.TimeoutError(this.timeout);
|
|
65515
|
+
}
|
|
65516
|
+
throw err;
|
|
65517
|
+
} finally {
|
|
65518
|
+
clearTimeout(timer);
|
|
65519
|
+
}
|
|
65520
|
+
}
|
|
65521
|
+
// ─── 1. preflightCheck ─────────────────────────────────────────────────
|
|
65522
|
+
/**
|
|
65523
|
+
* Check whether it is safe to proceed with a tool invocation.
|
|
65524
|
+
*
|
|
65525
|
+
* Accepts `old_spec` / `new_spec` (OpenAPI YAML strings) and a `tool_name`.
|
|
65526
|
+
* The SDK converts the specs to MCP tool arrays and calls POST /api/v1/agent/preflight.
|
|
65527
|
+
*/
|
|
65528
|
+
async preflightCheck(req) {
|
|
65529
|
+
const raw = await this.request("POST", "/api/v1/agent/preflight", {
|
|
65530
|
+
tool_name: req.tool_name,
|
|
65531
|
+
old_spec: req.old_spec,
|
|
65532
|
+
new_spec: req.new_spec
|
|
65533
|
+
});
|
|
65534
|
+
const decision = raw.decision || "ALLOW";
|
|
65535
|
+
return {
|
|
65536
|
+
decision,
|
|
65537
|
+
omega_api: raw.omega_api ?? 0,
|
|
65538
|
+
safe: decision === "ALLOW" || decision === "WARN",
|
|
65539
|
+
reflex_triggers: raw.reflex_triggers || [],
|
|
65540
|
+
affected_tools: raw.affected_tools || [],
|
|
65541
|
+
confidence_score: raw.confidence_score,
|
|
65542
|
+
reflex_override: raw.reflex_override,
|
|
65543
|
+
omega_components: raw.omega_components,
|
|
65544
|
+
breaking_changes: raw.breaking_changes,
|
|
65545
|
+
stats: raw.stats,
|
|
65546
|
+
mitigation_available: raw.mitigation_available
|
|
65547
|
+
};
|
|
65548
|
+
}
|
|
65549
|
+
// ─── 2. diff ───────────────────────────────────────────────────────────
|
|
65550
|
+
/**
|
|
65551
|
+
* Full analysis of two OpenAPI specs.
|
|
65552
|
+
*/
|
|
65553
|
+
async diff(req) {
|
|
65554
|
+
return this.request("POST", "/api/v1/diff", req);
|
|
65555
|
+
}
|
|
65556
|
+
// ─── 3. explainDecision ────────────────────────────────────────────────
|
|
65557
|
+
/**
|
|
65558
|
+
* Returns a human-readable explanation of why a decision was made.
|
|
65559
|
+
*
|
|
65560
|
+
* Computed client-side from the omega components and reflex triggers.
|
|
65561
|
+
*/
|
|
65562
|
+
async explainDecision(req) {
|
|
65563
|
+
const components = [];
|
|
65564
|
+
if (req.omega_components) {
|
|
65565
|
+
for (const [name, value] of Object.entries(req.omega_components)) {
|
|
65566
|
+
if (typeof value === "number") {
|
|
65567
|
+
components.push({
|
|
65568
|
+
name,
|
|
65569
|
+
value,
|
|
65570
|
+
description: describeComponent(name, value)
|
|
65571
|
+
});
|
|
65572
|
+
}
|
|
65573
|
+
}
|
|
65574
|
+
}
|
|
65575
|
+
const triggers = req.reflex_triggers || [];
|
|
65576
|
+
let summary = `Decision: ${req.decision} (\u03A9_API = ${req.omega_api}).`;
|
|
65577
|
+
if (triggers.length > 0) {
|
|
65578
|
+
summary += ` ${triggers.length} reflex rule(s) triggered.`;
|
|
65579
|
+
}
|
|
65580
|
+
if (req.decision === "BLOCK") {
|
|
65581
|
+
summary += " This change is blocked due to high risk.";
|
|
65582
|
+
} else if (req.decision === "REQUIRE_APPROVAL") {
|
|
65583
|
+
summary += " This change requires manual approval before merging.";
|
|
65584
|
+
} else if (req.decision === "WARN") {
|
|
65585
|
+
summary += " This change has warnings but can proceed.";
|
|
65586
|
+
} else {
|
|
65587
|
+
summary += " This change is safe to proceed.";
|
|
65588
|
+
}
|
|
65589
|
+
return { summary, components };
|
|
65590
|
+
}
|
|
65591
|
+
// ─── 4. howToUnblock ───────────────────────────────────────────────────
|
|
65592
|
+
/**
|
|
65593
|
+
* Returns actionable steps to resolve a BLOCK decision.
|
|
65594
|
+
*
|
|
65595
|
+
* Computed client-side from breaking changes and detected patterns.
|
|
65596
|
+
*/
|
|
65597
|
+
async howToUnblock(req) {
|
|
65598
|
+
const actions = [];
|
|
65599
|
+
let step = 1;
|
|
65600
|
+
if (req.decision !== "BLOCK") {
|
|
65601
|
+
actions.push({
|
|
65602
|
+
step: step++,
|
|
65603
|
+
description: `Current decision is "${req.decision}" \u2014 no unblock needed.`
|
|
65604
|
+
});
|
|
65605
|
+
return { actions };
|
|
65606
|
+
}
|
|
65607
|
+
const bcs = req.breaking_changes || [];
|
|
65608
|
+
if (bcs.length > 0) {
|
|
65609
|
+
actions.push({
|
|
65610
|
+
step: step++,
|
|
65611
|
+
description: `Fix ${bcs.length} breaking change(s) in your spec.`,
|
|
65612
|
+
code_example: bcs.slice(0, 3).map((bc) => `# ${bc.type} at ${bc.path}: ${bc.description}`).join("\n")
|
|
65613
|
+
});
|
|
65614
|
+
}
|
|
65615
|
+
const triggers = req.reflex_triggers || [];
|
|
65616
|
+
for (const trigger of triggers) {
|
|
65617
|
+
actions.push({
|
|
65618
|
+
step: step++,
|
|
65619
|
+
description: `Resolve reflex rule: ${trigger.rule}`
|
|
65620
|
+
});
|
|
65621
|
+
}
|
|
65622
|
+
actions.push({
|
|
65623
|
+
step: step++,
|
|
65624
|
+
description: "Request a manual override via POST /api/v1/ledger/:id/override if this is an emergency."
|
|
65625
|
+
});
|
|
65626
|
+
return { actions };
|
|
65627
|
+
}
|
|
65628
|
+
// ─── 5. scoreMcp ──────────────────────────────────────────────────────
|
|
65629
|
+
/**
|
|
65630
|
+
* Score an MCP manifest for agent safety.
|
|
65631
|
+
*/
|
|
65632
|
+
async scoreMcp(req) {
|
|
65633
|
+
return this.request("POST", "/api/v1/agent-readiness-score", {
|
|
65634
|
+
spec: req.manifest,
|
|
65635
|
+
spec_type: "mcp"
|
|
65636
|
+
});
|
|
65637
|
+
}
|
|
65638
|
+
// ─── 6. getLedger ─────────────────────────────────────────────────────
|
|
65639
|
+
/**
|
|
65640
|
+
* Query compliance ledger entries.
|
|
65641
|
+
*/
|
|
65642
|
+
async getLedger(req = {}) {
|
|
65643
|
+
const params = new URLSearchParams();
|
|
65644
|
+
if (req.repo)
|
|
65645
|
+
params.set("repo", req.repo);
|
|
65646
|
+
if (req.decision)
|
|
65647
|
+
params.set("decision", req.decision);
|
|
65648
|
+
if (req.from)
|
|
65649
|
+
params.set("from", req.from);
|
|
65650
|
+
if (req.to)
|
|
65651
|
+
params.set("to", req.to);
|
|
65652
|
+
if (req.limit)
|
|
65653
|
+
params.set("limit", String(req.limit));
|
|
65654
|
+
const qs = params.toString();
|
|
65655
|
+
const path = `/api/v1/ledger${qs ? `?${qs}` : ""}`;
|
|
65656
|
+
return this.request("GET", path);
|
|
65657
|
+
}
|
|
65658
|
+
// ─── 7. simulatePolicy ───────────────────────────────────────────────
|
|
65659
|
+
/**
|
|
65660
|
+
* Test a YAML policy against two OpenAPI specs.
|
|
65661
|
+
*/
|
|
65662
|
+
async simulatePolicy(req) {
|
|
65663
|
+
return this.request("POST", "/api/v1/policy-simulator", req);
|
|
65664
|
+
}
|
|
65665
|
+
// ─── 8. preflightChangeSet ─────────────────────────────────────────────
|
|
65666
|
+
/**
|
|
65667
|
+
* Preflight a multi-artifact change set (OpenAPI / GraphQL / gRPC / AsyncAPI / MCP manifest)
|
|
65668
|
+
* in one call. Returns one aggregated ALLOW/WARN/REQUIRE_APPROVAL/BLOCK decision (strictest-wins)
|
|
65669
|
+
* with per-artifact findings, a bundle fingerprint, and a decision-result.v1.1 envelope +
|
|
65670
|
+
* chain receipt. POST /api/v1/preflight.
|
|
65671
|
+
*/
|
|
65672
|
+
async preflightChangeSet(req) {
|
|
65673
|
+
return this.request("POST", "/api/v1/preflight", req);
|
|
65674
|
+
}
|
|
65675
|
+
// ─── 9. verifyReceipt ──────────────────────────────────────────────────
|
|
65676
|
+
/**
|
|
65677
|
+
* Verify a CodeRifts chain receipt's signature and integrity. No API key is required — this is a
|
|
65678
|
+
* public endpoint (the Authorization header is sent for consistency but ignored server-side).
|
|
65679
|
+
* POST /api/v1/verify-receipt.
|
|
65680
|
+
*/
|
|
65681
|
+
async verifyReceipt(token) {
|
|
65682
|
+
return this.request("POST", "/api/v1/verify-receipt", { token });
|
|
65683
|
+
}
|
|
65684
|
+
// ─── 10. getDecisionDetails ────────────────────────────────────────────
|
|
65685
|
+
/**
|
|
65686
|
+
* Look up a stored decision by decision_id or fingerprint; returns the stored
|
|
65687
|
+
* decision-result.v1.1 envelope + meta. POST /api/v1/decisions/lookup.
|
|
65688
|
+
*/
|
|
65689
|
+
async getDecisionDetails(req) {
|
|
65690
|
+
return this.request("POST", "/api/v1/decisions/lookup", req);
|
|
65691
|
+
}
|
|
65692
|
+
};
|
|
65693
|
+
exports2.CodeRifts = CodeRifts;
|
|
65694
|
+
function describeComponent(name, value) {
|
|
65695
|
+
const descriptions = {
|
|
65696
|
+
S_contract: "Contract severity score \u2014 measures how severe the breaking changes are",
|
|
65697
|
+
P_break: "Break probability \u2014 likelihood that downstream consumers will break",
|
|
65698
|
+
S_blast_eff: "Blast radius \u2014 how many consumers are affected",
|
|
65699
|
+
S_agent: "Agent safety score \u2014 risk to AI agent tool invocations",
|
|
65700
|
+
S_runtime: "Runtime impact \u2014 risk of runtime failures",
|
|
65701
|
+
ECI: "Ecosystem coupling index \u2014 how tightly coupled the API is",
|
|
65702
|
+
M_eff: "Migration effort \u2014 estimated effort to migrate consumers",
|
|
65703
|
+
D_contract: "Contract distance \u2014 semantic distance between old and new contracts",
|
|
65704
|
+
confidence_score: "Confidence in the analysis result"
|
|
65705
|
+
};
|
|
65706
|
+
return descriptions[name] || `${name} = ${value}`;
|
|
65707
|
+
}
|
|
65708
|
+
}
|
|
65709
|
+
});
|
|
65710
|
+
|
|
65711
|
+
// ../../node_modules/@coderifts/sdk/dist/cjs/decision.js
|
|
65712
|
+
var require_decision = __commonJS({
|
|
65713
|
+
"../../node_modules/@coderifts/sdk/dist/cjs/decision.js"(exports2) {
|
|
65714
|
+
"use strict";
|
|
65715
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65716
|
+
exports2.readDecision = readDecision;
|
|
65717
|
+
var EXECUTION_ACTION = {
|
|
65718
|
+
ALLOW: "CONTINUE",
|
|
65719
|
+
WARN: "CONTINUE_WITH_MONITORING",
|
|
65720
|
+
REQUIRE_APPROVAL: "REQUEST_APPROVAL",
|
|
65721
|
+
BLOCK: "STOP"
|
|
65722
|
+
};
|
|
65723
|
+
function isExecutionAction(v) {
|
|
65724
|
+
return v === "CONTINUE" || v === "CONTINUE_WITH_MONITORING" || v === "REQUEST_APPROVAL" || v === "STOP";
|
|
65725
|
+
}
|
|
65726
|
+
function readDecision(response) {
|
|
65727
|
+
if (!response || typeof response !== "object") {
|
|
65728
|
+
return { executionAction: "STOP", decision: null, reason: "UNREADABLE_DECISION" };
|
|
65729
|
+
}
|
|
65730
|
+
const r = response;
|
|
65731
|
+
const env = r.decision_result;
|
|
65732
|
+
if (env && typeof env === "object" && isExecutionAction(env.execution_action)) {
|
|
65733
|
+
const receipt = env.receipt;
|
|
65734
|
+
return {
|
|
65735
|
+
executionAction: env.execution_action,
|
|
65736
|
+
decision: typeof env.decision === "string" ? env.decision : null,
|
|
65737
|
+
envelope: env,
|
|
65738
|
+
receipt: receipt && typeof receipt === "object" ? receipt : void 0
|
|
65739
|
+
};
|
|
65740
|
+
}
|
|
65741
|
+
if (isExecutionAction(r.execution_action)) {
|
|
65742
|
+
return {
|
|
65743
|
+
executionAction: r.execution_action,
|
|
65744
|
+
decision: typeof r.decision === "string" ? r.decision : null
|
|
65745
|
+
};
|
|
65746
|
+
}
|
|
65747
|
+
if (typeof r.decision === "string" && Object.prototype.hasOwnProperty.call(EXECUTION_ACTION, r.decision)) {
|
|
65748
|
+
return { executionAction: EXECUTION_ACTION[r.decision], decision: r.decision };
|
|
65749
|
+
}
|
|
65750
|
+
return {
|
|
65751
|
+
executionAction: "STOP",
|
|
65752
|
+
decision: typeof r.decision === "string" ? r.decision : null,
|
|
65753
|
+
reason: "UNREADABLE_DECISION"
|
|
65754
|
+
};
|
|
65755
|
+
}
|
|
65756
|
+
}
|
|
65757
|
+
});
|
|
65758
|
+
|
|
65759
|
+
// ../../node_modules/@coderifts/sdk/dist/cjs/index.js
|
|
65760
|
+
var require_cjs3 = __commonJS({
|
|
65761
|
+
"../../node_modules/@coderifts/sdk/dist/cjs/index.js"(exports2) {
|
|
65762
|
+
"use strict";
|
|
65763
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65764
|
+
exports2.readDecision = exports2.AuthError = exports2.RateLimitError = exports2.TimeoutError = exports2.ApiError = exports2.CodeRiftsError = exports2.CodeRifts = void 0;
|
|
65765
|
+
var client_js_1 = require_client();
|
|
65766
|
+
Object.defineProperty(exports2, "CodeRifts", { enumerable: true, get: function() {
|
|
65767
|
+
return client_js_1.CodeRifts;
|
|
65768
|
+
} });
|
|
65769
|
+
var errors_js_1 = require_errors5();
|
|
65770
|
+
Object.defineProperty(exports2, "CodeRiftsError", { enumerable: true, get: function() {
|
|
65771
|
+
return errors_js_1.CodeRiftsError;
|
|
65772
|
+
} });
|
|
65773
|
+
Object.defineProperty(exports2, "ApiError", { enumerable: true, get: function() {
|
|
65774
|
+
return errors_js_1.ApiError;
|
|
65775
|
+
} });
|
|
65776
|
+
Object.defineProperty(exports2, "TimeoutError", { enumerable: true, get: function() {
|
|
65777
|
+
return errors_js_1.TimeoutError;
|
|
65778
|
+
} });
|
|
65779
|
+
Object.defineProperty(exports2, "RateLimitError", { enumerable: true, get: function() {
|
|
65780
|
+
return errors_js_1.RateLimitError;
|
|
65781
|
+
} });
|
|
65782
|
+
Object.defineProperty(exports2, "AuthError", { enumerable: true, get: function() {
|
|
65783
|
+
return errors_js_1.AuthError;
|
|
65784
|
+
} });
|
|
65785
|
+
var decision_js_1 = require_decision();
|
|
65786
|
+
Object.defineProperty(exports2, "readDecision", { enumerable: true, get: function() {
|
|
65787
|
+
return decision_js_1.readDecision;
|
|
65788
|
+
} });
|
|
65789
|
+
}
|
|
65790
|
+
});
|
|
65791
|
+
|
|
65792
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/detector.js
|
|
65793
|
+
var require_detector = __commonJS({
|
|
65794
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/detector.js"(exports2) {
|
|
65795
|
+
"use strict";
|
|
65796
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65797
|
+
exports2.builtinDetector = exports2.DETECTOR_VERSION = void 0;
|
|
65798
|
+
var node_zlib_1 = require("node:zlib");
|
|
65799
|
+
exports2.DETECTOR_VERSION = "builtin/1.1.0";
|
|
65800
|
+
var CONTRACT_PATH_RE = [
|
|
65801
|
+
/openapi/i,
|
|
65802
|
+
/swagger/i,
|
|
65803
|
+
/asyncapi/i,
|
|
65804
|
+
/\.graphql$/i,
|
|
65805
|
+
/\.gql$/i,
|
|
65806
|
+
/\.proto$/i,
|
|
65807
|
+
/\.pb($|\.)/i,
|
|
65808
|
+
/(^|\/)[\w.-]*mcp[\w.-]*\.json$/i,
|
|
65809
|
+
/tools-catalog\.json$/i,
|
|
65810
|
+
/schema\.prisma$/i,
|
|
65811
|
+
/(^|\/)migrations?\//i,
|
|
65812
|
+
/(^|\/)alembic\//i,
|
|
65813
|
+
/(^|\/)buf\.ya?ml$/i,
|
|
65814
|
+
/\.spectral\.ya?ml$/i,
|
|
65815
|
+
/(^|\/)\.github\/workflows\//i,
|
|
65816
|
+
/(^|\/)\.husky\//i,
|
|
65817
|
+
/api[-_]?contract/i,
|
|
65818
|
+
/service-definition/i,
|
|
65819
|
+
/(^|\/)contracts?\//i,
|
|
65820
|
+
/schemas?\/components?\//i,
|
|
65821
|
+
/\bcontract\.json$/i,
|
|
65822
|
+
/(^|\/)spec\.(ya?ml|json)$/i,
|
|
65823
|
+
/api[-_/]spec\.(ya?ml|json)$/i,
|
|
65824
|
+
/-api\.(ya?ml|yml)$/i,
|
|
65825
|
+
/current-api/i,
|
|
65826
|
+
/(^|\/)(src\/)?generated\//i,
|
|
65827
|
+
/(^|\/)gen\//i,
|
|
65828
|
+
/\.pb\.go$/i,
|
|
65829
|
+
/openapi\.d\.ts$/i
|
|
65830
|
+
];
|
|
65831
|
+
var NON_SSOT_PATH_RE = [
|
|
65832
|
+
/(^|\/)tests?\//i,
|
|
65833
|
+
/(^|\/)__tests__\//i,
|
|
65834
|
+
/(^|\/)__mocks__\//i,
|
|
65835
|
+
/\/fixtures?\//i,
|
|
65836
|
+
/(^|\/)mocks?\//i,
|
|
65837
|
+
/\.test\.[jt]sx?$/i,
|
|
65838
|
+
/\.spec\.[jt]sx?$/i,
|
|
65839
|
+
/(^|\/)src\/internal\//i,
|
|
65840
|
+
/(^|\/)node_modules\//i
|
|
65841
|
+
];
|
|
65842
|
+
var PROSE_PATH_RE = [/(^|\/)README(\.\w+)?$/i, /(^|\/)CHANGELOG(\.\w+)?$/i, /(^|\/)LICENSE(\.\w+)?$/i, /\.md$/i];
|
|
65843
|
+
var CODE_CONTRACT_PATH_RE = [/(^|\/)src\/routes?\//i, /(^|\/)routes?\//i, /(^|\/)app\/api\//i, /(^|\/)src\/dto\//i, /dto/i, /routers?\//i, /\.prisma$/i, /\.tf$/i, /server\/routers?\//i];
|
|
65844
|
+
var GATE_PATH_RE = [/(^|\/)\.github\/workflows\//i, /(^|\/)\.husky\//i, /\.spectral\.ya?ml$/i, /(^|\/)buf\.ya?ml$/i];
|
|
65845
|
+
var LOCKFILE_RE = /(package-lock\.json|pnpm-lock\.ya?ml|yarn\.lock|composer\.lock|Cargo\.lock)$/i;
|
|
65846
|
+
var CONTRACT_CONTENT_RE = [
|
|
65847
|
+
/\bopenapi\s*[:=]\s*["']?3/i,
|
|
65848
|
+
/["']openapi["']\s*:/i,
|
|
65849
|
+
/\bswagger\s*[:=]/i,
|
|
65850
|
+
/["']swagger["']\s*:/i,
|
|
65851
|
+
/\basyncapi\s*[:=]/i,
|
|
65852
|
+
/["']asyncapi["']\s*:/i,
|
|
65853
|
+
/(^|\n)\s*paths\s*:/i,
|
|
65854
|
+
/["']paths["']\s*:/i,
|
|
65855
|
+
/syntax\s*=\s*["']proto3/i,
|
|
65856
|
+
/(^|\n)\s*message\s+\w+\s*\{/i,
|
|
65857
|
+
/\btype\s+(Query|Mutation|Subscription)\b/i,
|
|
65858
|
+
/["']tools["']\s*:\s*\[/i,
|
|
65859
|
+
/["']inputSchema["']\s*:/i,
|
|
65860
|
+
/\/v\d+\/[\w{}.-]*\s*:/,
|
|
65861
|
+
// versioned route-path key
|
|
65862
|
+
/\bchannels\s*:/i
|
|
65863
|
+
];
|
|
65864
|
+
var CONTRACT_STRUCTURE_RE = [
|
|
65865
|
+
/(get|post|put|delete|patch)\s*:\s*\{?/i,
|
|
65866
|
+
/message\s+\w+\s*\{[^}]*=\s*\d+/i,
|
|
65867
|
+
/\/v\d+\/[\w{}.-]*\s*:/,
|
|
65868
|
+
/"name"\s*:\s*"[^"]+"[\s,}]*"?inputSchema/i
|
|
65869
|
+
];
|
|
65870
|
+
var REAL_CHANGE_RE = [
|
|
65871
|
+
/required\s*:\s*\[/i,
|
|
65872
|
+
/["']required["']\s*:\s*\[/i,
|
|
65873
|
+
/\btype\s*:\s*\w+/i,
|
|
65874
|
+
/nullable\s*:/i,
|
|
65875
|
+
/:\s*\w+!/,
|
|
65876
|
+
/additionalProperties\s*:\s*(true|false)/i,
|
|
65877
|
+
/["']additionalProperties["']/i,
|
|
65878
|
+
/\bDROP\s+COLUMN\b/i,
|
|
65879
|
+
/\bALTER\s+COLUMN\b/i,
|
|
65880
|
+
/alter_column\s*\(/i,
|
|
65881
|
+
/new_column_name/i,
|
|
65882
|
+
/\bRENAME\b/i,
|
|
65883
|
+
/DROP\s+TABLE/i,
|
|
65884
|
+
/@IsString|@IsOptional|response_model|z\.string|@unique/i,
|
|
65885
|
+
/app\.(get|post|put|delete|patch)\s*\(/i,
|
|
65886
|
+
/@router\.(get|post|put|delete|patch)/i,
|
|
65887
|
+
/\/v\d+\//,
|
|
65888
|
+
/continue-on-error|if:\s*false|:\s*off\b|'off'|"off"/i,
|
|
65889
|
+
/\bignore\s*:/i,
|
|
65890
|
+
/(^|\n)\s*breaking\s*:/i
|
|
65891
|
+
];
|
|
65892
|
+
var INERT_KEY_RE = [
|
|
65893
|
+
/^description\s*:/i,
|
|
65894
|
+
/^["']description["']\s*:/i,
|
|
65895
|
+
/^summary\s*:/i,
|
|
65896
|
+
/^title\s*:/i,
|
|
65897
|
+
/^contact\s*:/i,
|
|
65898
|
+
/^name\s*:/i,
|
|
65899
|
+
/^examples?\s*:/i,
|
|
65900
|
+
/^["']examples?["']\s*:/i,
|
|
65901
|
+
/^x-[\w-]+\s*:/i,
|
|
65902
|
+
/^["']x-[\w-]+["']\s*:/i
|
|
65903
|
+
];
|
|
65904
|
+
var READ_ONLY_TOOLS = /* @__PURE__ */ new Set(["read", "grep", "glob", "ls", "cat", "view", "search", "list", "get"]);
|
|
65905
|
+
var FORMATTER_RE = /\b(prettier|eslint\s+--fix|gofmt|rustfmt|black|clang-format|dprint)\b/i;
|
|
65906
|
+
var GATE_KEYWORD_RE = /coderifts|agent-guard|contract-check|contract\b|preflight|spectral|\bbuf\b/i;
|
|
65907
|
+
function anyMatch(res, s) {
|
|
65908
|
+
return res.some((r) => r.test(s));
|
|
65909
|
+
}
|
|
65910
|
+
function argString(args) {
|
|
65911
|
+
if (args == null)
|
|
65912
|
+
return "";
|
|
65913
|
+
if (typeof args === "string")
|
|
65914
|
+
return args;
|
|
65915
|
+
try {
|
|
65916
|
+
return JSON.stringify(args);
|
|
65917
|
+
} catch {
|
|
65918
|
+
return "";
|
|
65919
|
+
}
|
|
65920
|
+
}
|
|
65921
|
+
function changeText(call) {
|
|
65922
|
+
const parts = [];
|
|
65923
|
+
if (call.diff)
|
|
65924
|
+
parts.push(call.diff);
|
|
65925
|
+
const a = call.arguments;
|
|
65926
|
+
if (a && typeof a === "object") {
|
|
65927
|
+
for (const k of ["new_string", "old_string", "contents", "content", "patch", "command"]) {
|
|
65928
|
+
const v = a[k];
|
|
65929
|
+
if (typeof v === "string")
|
|
65930
|
+
parts.push(v);
|
|
65931
|
+
}
|
|
65932
|
+
const edits = a.edits;
|
|
65933
|
+
if (Array.isArray(edits))
|
|
65934
|
+
for (const e of edits)
|
|
65935
|
+
parts.push(argString(e));
|
|
65936
|
+
}
|
|
65937
|
+
return parts.join("\n");
|
|
65938
|
+
}
|
|
65939
|
+
function commandText(call) {
|
|
65940
|
+
const a = call.arguments;
|
|
65941
|
+
const c = a && typeof a === "object" ? a.command : void 0;
|
|
65942
|
+
return typeof c === "string" ? c : "";
|
|
65943
|
+
}
|
|
65944
|
+
function allPaths(call) {
|
|
65945
|
+
const out = [...call.filesTouched || []];
|
|
65946
|
+
const a = call.arguments;
|
|
65947
|
+
if (a && typeof a === "object" && typeof a.path === "string")
|
|
65948
|
+
out.push(a.path);
|
|
65949
|
+
return out;
|
|
65950
|
+
}
|
|
65951
|
+
function isContractPath(p) {
|
|
65952
|
+
if (anyMatch(NON_SSOT_PATH_RE, p))
|
|
65953
|
+
return false;
|
|
65954
|
+
if (anyMatch(PROSE_PATH_RE, p))
|
|
65955
|
+
return false;
|
|
65956
|
+
return anyMatch(CONTRACT_PATH_RE, p);
|
|
65957
|
+
}
|
|
65958
|
+
function changedLines(call) {
|
|
65959
|
+
if (call.diff) {
|
|
65960
|
+
return call.diff.split("\n").filter((l) => l.startsWith("+") || l.startsWith("-")).map((l) => l.slice(1));
|
|
65961
|
+
}
|
|
65962
|
+
const out = [];
|
|
65963
|
+
const a = call.arguments;
|
|
65964
|
+
const pushSetDiff = (oldS, newS) => {
|
|
65965
|
+
const oldL = typeof oldS === "string" ? oldS.split("\n") : [];
|
|
65966
|
+
const newL = typeof newS === "string" ? newS.split("\n") : [];
|
|
65967
|
+
const oldSet = new Set(oldL.map((l) => l.trim()));
|
|
65968
|
+
const newSet = new Set(newL.map((l) => l.trim()));
|
|
65969
|
+
for (const l of newL)
|
|
65970
|
+
if (!oldSet.has(l.trim()))
|
|
65971
|
+
out.push(l);
|
|
65972
|
+
for (const l of oldL)
|
|
65973
|
+
if (!newSet.has(l.trim()))
|
|
65974
|
+
out.push(l);
|
|
65975
|
+
};
|
|
65976
|
+
if (a && typeof a === "object") {
|
|
65977
|
+
pushSetDiff(a.old_string, a.new_string);
|
|
65978
|
+
const contents = a.contents ?? a.content;
|
|
65979
|
+
if (typeof contents === "string")
|
|
65980
|
+
for (const l of contents.split("\n"))
|
|
65981
|
+
out.push(l);
|
|
65982
|
+
const patch = a.patch;
|
|
65983
|
+
if (typeof patch === "string") {
|
|
65984
|
+
for (const l of patch.split("\n"))
|
|
65985
|
+
if (l.startsWith("+") || l.startsWith("-"))
|
|
65986
|
+
out.push(l.slice(1));
|
|
65987
|
+
}
|
|
65988
|
+
const edits = a.edits;
|
|
65989
|
+
if (Array.isArray(edits)) {
|
|
65990
|
+
for (const e of edits)
|
|
65991
|
+
if (e && typeof e === "object")
|
|
65992
|
+
pushSetDiff(e.old_string, e.new_string);
|
|
65993
|
+
}
|
|
65994
|
+
}
|
|
65995
|
+
return out;
|
|
65996
|
+
}
|
|
65997
|
+
function migrationDestructive(text) {
|
|
65998
|
+
return /\bDROP\s+COLUMN\b|\bALTER\s+COLUMN\b|new_column_name|alter_column|\bRENAME\b|DROP\s+TABLE|DROP\s+CONSTRAINT/i.test(text);
|
|
65999
|
+
}
|
|
66000
|
+
function migrationIndexOnly(text) {
|
|
66001
|
+
return /CREATE\s+INDEX/i.test(text) && !migrationDestructive(text) && !/ADD\s+COLUMN|DROP\b/i.test(text);
|
|
66002
|
+
}
|
|
66003
|
+
function gateDisabled(call) {
|
|
66004
|
+
const paths = allPaths(call);
|
|
66005
|
+
if (!paths.some((p) => anyMatch(GATE_PATH_RE, p)))
|
|
66006
|
+
return false;
|
|
66007
|
+
const text = changeText(call);
|
|
66008
|
+
if (!GATE_KEYWORD_RE.test(text))
|
|
66009
|
+
return false;
|
|
66010
|
+
const lines = changedLines(call);
|
|
66011
|
+
const commentedOut = lines.some((l) => /^\s*(#|\/\/)/.test(l) && GATE_KEYWORD_RE.test(l));
|
|
66012
|
+
const weakened = anyMatch(REAL_CHANGE_RE, text) || /continue-on-error|if:\s*false|:\s*off\b|ignore\s*:/i.test(text);
|
|
66013
|
+
return commentedOut || weakened;
|
|
66014
|
+
}
|
|
66015
|
+
function lockfileContractChange(call) {
|
|
66016
|
+
const paths = allPaths(call);
|
|
66017
|
+
if (!paths.some((p) => LOCKFILE_RE.test(p)))
|
|
66018
|
+
return false;
|
|
66019
|
+
const text = changeText(call);
|
|
66020
|
+
const contractPkg = /@[\w.-]+\/(openapi|graphql|proto|asyncapi|schema)\b|(openapi|graphql|proto|asyncapi|schema)@\d/i.test(text);
|
|
66021
|
+
if (!contractPkg)
|
|
66022
|
+
return false;
|
|
66023
|
+
return /"resolved"\s*:/i.test(text) || /@\d+\.\d+\.\d+/.test(text) || /@\d+['":]/.test(text);
|
|
66024
|
+
}
|
|
66025
|
+
function isInertOnly(call) {
|
|
66026
|
+
const text = changeText(call);
|
|
66027
|
+
const paths = allPaths(call);
|
|
66028
|
+
if (paths.some((p) => LOCKFILE_RE.test(p)) && !lockfileContractChange(call)) {
|
|
66029
|
+
if (/"integrity"\s*:/i.test(text) && !/"resolved"\s*:/i.test(text))
|
|
66030
|
+
return true;
|
|
66031
|
+
}
|
|
66032
|
+
if (paths.some((p) => /migrations?\/|alembic\//i.test(p)) && migrationIndexOnly(text))
|
|
66033
|
+
return true;
|
|
66034
|
+
if (paths.some((p) => anyMatch(GATE_PATH_RE, p))) {
|
|
66035
|
+
if (!GATE_KEYWORD_RE.test(text) && !anyMatch(REAL_CHANGE_RE, text))
|
|
66036
|
+
return true;
|
|
66037
|
+
return false;
|
|
66038
|
+
}
|
|
66039
|
+
const cmd = commandText(call);
|
|
66040
|
+
if (cmd && FORMATTER_RE.test(cmd))
|
|
66041
|
+
return true;
|
|
66042
|
+
if (/\b(examples?|value)\s*:/i.test(text) && !anyMatch(REAL_CHANGE_RE, text))
|
|
66043
|
+
return true;
|
|
66044
|
+
const lines = changedLines(call);
|
|
66045
|
+
if (lines.length === 0)
|
|
66046
|
+
return false;
|
|
66047
|
+
let sawReal = false;
|
|
66048
|
+
let sawInert = false;
|
|
66049
|
+
for (const raw of lines) {
|
|
66050
|
+
const t = raw.trim();
|
|
66051
|
+
if (t === "") {
|
|
66052
|
+
sawInert = true;
|
|
66053
|
+
continue;
|
|
66054
|
+
}
|
|
66055
|
+
if (/^#|^\/\/|^\/\*|\*\/|^\*/.test(t)) {
|
|
66056
|
+
sawInert = true;
|
|
66057
|
+
continue;
|
|
66058
|
+
}
|
|
66059
|
+
if (/^```/.test(t)) {
|
|
66060
|
+
sawInert = true;
|
|
66061
|
+
continue;
|
|
66062
|
+
}
|
|
66063
|
+
if (/^["'].*["']$/.test(t) && !t.includes(":")) {
|
|
66064
|
+
sawInert = true;
|
|
66065
|
+
continue;
|
|
66066
|
+
}
|
|
66067
|
+
if (/generated|timestamp/i.test(t)) {
|
|
66068
|
+
sawInert = true;
|
|
66069
|
+
continue;
|
|
66070
|
+
}
|
|
66071
|
+
if (anyMatch(INERT_KEY_RE, t)) {
|
|
66072
|
+
sawInert = true;
|
|
66073
|
+
continue;
|
|
66074
|
+
}
|
|
66075
|
+
if (anyMatch(REAL_CHANGE_RE, t) || anyMatch(CONTRACT_STRUCTURE_RE, t) || anyMatch(CONTRACT_CONTENT_RE, t)) {
|
|
66076
|
+
sawReal = true;
|
|
66077
|
+
continue;
|
|
66078
|
+
}
|
|
66079
|
+
if (/^[\w"']+\??\s*:\s*\S/.test(t)) {
|
|
66080
|
+
sawReal = true;
|
|
66081
|
+
continue;
|
|
66082
|
+
}
|
|
66083
|
+
}
|
|
66084
|
+
return sawInert && !sawReal;
|
|
66085
|
+
}
|
|
66086
|
+
function realChangePresent(call) {
|
|
66087
|
+
const text = changeText(call);
|
|
66088
|
+
if (migrationDestructive(text))
|
|
66089
|
+
return true;
|
|
66090
|
+
if (gateDisabled(call))
|
|
66091
|
+
return true;
|
|
66092
|
+
if (lockfileContractChange(call))
|
|
66093
|
+
return true;
|
|
66094
|
+
for (const raw of changedLines(call)) {
|
|
66095
|
+
const t = raw.trim();
|
|
66096
|
+
if (anyMatch(INERT_KEY_RE, t))
|
|
66097
|
+
continue;
|
|
66098
|
+
if (anyMatch(REAL_CHANGE_RE, t))
|
|
66099
|
+
return true;
|
|
66100
|
+
if (/^[\w"']+\??\s*:\s*\S/.test(t) && !/^(paths|components|info|servers|channels|tools|get|post|put|delete|patch)\s*:/i.test(t))
|
|
66101
|
+
return true;
|
|
66102
|
+
}
|
|
66103
|
+
return false;
|
|
66104
|
+
}
|
|
66105
|
+
function intentMentionsContract(intent) {
|
|
66106
|
+
if (!intent)
|
|
66107
|
+
return false;
|
|
66108
|
+
return /openapi|swagger|graphql|protobuf|\bproto\b|asyncapi|mcp\s*manifest|mcp\.json|json\s*schema|\bschema\b|required\s+field|\bendpoint\b|wire\s*format|api\s*spec|contract\s*(file|change|surface)/i.test(intent);
|
|
66109
|
+
}
|
|
66110
|
+
function commandMutatesContract(call) {
|
|
66111
|
+
const cmd = commandText(call);
|
|
66112
|
+
if (!cmd)
|
|
66113
|
+
return false;
|
|
66114
|
+
if (FORMATTER_RE.test(cmd))
|
|
66115
|
+
return false;
|
|
66116
|
+
const touchesContract = allPaths(call).some(isContractPath) || /(>|>>|-o\s|mv\s|ln\s+-sf?\s|git\s+mv\s|cp\s)[^\n|]*(openapi|swagger|asyncapi|\.graphql|\.gql|\.proto|\.pb\b|mcp[.-]?\w*\.json|schema\.prisma|spec\.(ya?ml|json))/i.test(cmd) || anyMatch(CONTRACT_CONTENT_RE, cmd);
|
|
66117
|
+
const mutates = /(>|>>|\bmv\b|\bcp\b|\bln\s|git\s+mv|curl|wget|-o\b|base64\s+-d|xxd|\bjq\b|\bsed\b|\btee\b|echo|printf|\bcat\b)/i.test(cmd);
|
|
66118
|
+
return touchesContract && mutates;
|
|
66119
|
+
}
|
|
66120
|
+
var DEEP_MAX_DEPTH = 8;
|
|
66121
|
+
var DEEP_MAX_BYTES = 262144;
|
|
66122
|
+
var DEEP_DECODE_MAX_BYTES = 65536;
|
|
66123
|
+
var DEEP_DECODE_LEVELS = 3;
|
|
66124
|
+
var OPAQUE_MIN_LEN = 40;
|
|
66125
|
+
function looksLikePath(v) {
|
|
66126
|
+
return v.length > 0 && v.length <= 256 && !/[\n\r{}<>]/.test(v) && /(^|\/)[\w.@-]+\.[A-Za-z0-9]+$/.test(v.trim());
|
|
66127
|
+
}
|
|
66128
|
+
function decodeCandidates(v) {
|
|
66129
|
+
const out = [];
|
|
66130
|
+
const push = (s) => {
|
|
66131
|
+
if (s && s.length > 0 && s.length <= DEEP_DECODE_MAX_BYTES)
|
|
66132
|
+
out.push(s);
|
|
66133
|
+
};
|
|
66134
|
+
const compact = v.replace(/\s+/g, "");
|
|
66135
|
+
if (compact.length >= 16 && compact.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(compact)) {
|
|
66136
|
+
try {
|
|
66137
|
+
push(Buffer.from(compact, "base64").toString("utf8"));
|
|
66138
|
+
} catch {
|
|
66139
|
+
}
|
|
66140
|
+
try {
|
|
66141
|
+
const b = Buffer.from(compact, "base64");
|
|
66142
|
+
push((0, node_zlib_1.gunzipSync)(b).toString("utf8"));
|
|
66143
|
+
} catch {
|
|
66144
|
+
}
|
|
66145
|
+
}
|
|
66146
|
+
if (compact.length >= 16 && compact.length % 2 === 0 && /^[0-9a-fA-F]+$/.test(compact)) {
|
|
66147
|
+
try {
|
|
66148
|
+
push(Buffer.from(compact, "hex").toString("utf8"));
|
|
66149
|
+
} catch {
|
|
66150
|
+
}
|
|
66151
|
+
}
|
|
66152
|
+
if (/%[0-9a-fA-F]{2}/.test(v)) {
|
|
66153
|
+
try {
|
|
66154
|
+
push(decodeURIComponent(v));
|
|
66155
|
+
} catch {
|
|
66156
|
+
}
|
|
66157
|
+
}
|
|
66158
|
+
if (/\\["\\/]|^\s*"/.test(v)) {
|
|
66159
|
+
try {
|
|
66160
|
+
const p = JSON.parse(v);
|
|
66161
|
+
if (typeof p === "string")
|
|
66162
|
+
push(p);
|
|
66163
|
+
} catch {
|
|
66164
|
+
}
|
|
66165
|
+
}
|
|
66166
|
+
return out;
|
|
66167
|
+
}
|
|
66168
|
+
function looksEncoded(v) {
|
|
66169
|
+
const c = v.replace(/\s+/g, "");
|
|
66170
|
+
if (c.length < OPAQUE_MIN_LEN)
|
|
66171
|
+
return false;
|
|
66172
|
+
return /^[A-Za-z0-9+/]+={0,2}$/.test(c) && c.length % 4 === 0 || /^[0-9a-fA-F]+$/.test(c) && c.length % 2 === 0;
|
|
66173
|
+
}
|
|
66174
|
+
function deepArgScan(call) {
|
|
66175
|
+
const acc = { contractContent: false, pathContractSsot: false, pathNonSsot: false, pathLikeCount: 0, proseCount: 0, opaque: false, capHit: false };
|
|
66176
|
+
let budget = DEEP_MAX_BYTES;
|
|
66177
|
+
const scanString = (s) => {
|
|
66178
|
+
if (looksLikePath(s)) {
|
|
66179
|
+
acc.pathLikeCount++;
|
|
66180
|
+
if (anyMatch(NON_SSOT_PATH_RE, s))
|
|
66181
|
+
acc.pathNonSsot = true;
|
|
66182
|
+
else if (anyMatch(PROSE_PATH_RE, s))
|
|
66183
|
+
acc.proseCount++;
|
|
66184
|
+
else if (isContractPath(s))
|
|
66185
|
+
acc.pathContractSsot = true;
|
|
66186
|
+
return;
|
|
66187
|
+
}
|
|
66188
|
+
if (anyMatch(CONTRACT_CONTENT_RE, s) || anyMatch(CONTRACT_STRUCTURE_RE, s)) {
|
|
66189
|
+
acc.contractContent = true;
|
|
66190
|
+
return;
|
|
66191
|
+
}
|
|
66192
|
+
let level = [s];
|
|
66193
|
+
for (let d = 0; d < DEEP_DECODE_LEVELS && !acc.contractContent; d++) {
|
|
66194
|
+
const next = [];
|
|
66195
|
+
for (const val of level) {
|
|
66196
|
+
for (const dec of decodeCandidates(val)) {
|
|
66197
|
+
if (anyMatch(CONTRACT_CONTENT_RE, dec) || anyMatch(CONTRACT_STRUCTURE_RE, dec)) {
|
|
66198
|
+
acc.contractContent = true;
|
|
66199
|
+
break;
|
|
66200
|
+
}
|
|
66201
|
+
next.push(dec);
|
|
66202
|
+
}
|
|
66203
|
+
if (acc.contractContent)
|
|
66204
|
+
break;
|
|
66205
|
+
}
|
|
66206
|
+
level = next;
|
|
66207
|
+
}
|
|
66208
|
+
if (!acc.contractContent && looksEncoded(s) && level.every((x) => !isReadableText(x)))
|
|
66209
|
+
acc.opaque = true;
|
|
66210
|
+
};
|
|
66211
|
+
const walk = (node, depth) => {
|
|
66212
|
+
if (acc.capHit || budget <= 0)
|
|
66213
|
+
return;
|
|
66214
|
+
if (depth > DEEP_MAX_DEPTH) {
|
|
66215
|
+
acc.capHit = true;
|
|
66216
|
+
return;
|
|
66217
|
+
}
|
|
66218
|
+
if (typeof node === "string") {
|
|
66219
|
+
budget -= node.length;
|
|
66220
|
+
if (budget <= 0) {
|
|
66221
|
+
acc.capHit = true;
|
|
66222
|
+
return;
|
|
66223
|
+
}
|
|
66224
|
+
scanString(node);
|
|
66225
|
+
} else if (Array.isArray(node)) {
|
|
66226
|
+
for (const el of node) {
|
|
66227
|
+
if (acc.capHit)
|
|
66228
|
+
break;
|
|
66229
|
+
walk(el, depth + 1);
|
|
66230
|
+
}
|
|
66231
|
+
} else if (node && typeof node === "object") {
|
|
66232
|
+
for (const val of Object.values(node)) {
|
|
66233
|
+
if (acc.capHit)
|
|
66234
|
+
break;
|
|
66235
|
+
walk(val, depth + 1);
|
|
66236
|
+
}
|
|
66237
|
+
}
|
|
66238
|
+
};
|
|
66239
|
+
try {
|
|
66240
|
+
walk(call.arguments, 0);
|
|
66241
|
+
} catch {
|
|
66242
|
+
acc.capHit = true;
|
|
66243
|
+
}
|
|
66244
|
+
return acc;
|
|
66245
|
+
}
|
|
66246
|
+
function isReadableText(s) {
|
|
66247
|
+
if (!s)
|
|
66248
|
+
return false;
|
|
66249
|
+
let printable = 0;
|
|
66250
|
+
const n = Math.min(s.length, 512);
|
|
66251
|
+
for (let i = 0; i < n; i++) {
|
|
66252
|
+
const c = s.charCodeAt(i);
|
|
66253
|
+
if (c === 9 || c === 10 || c === 13 || c >= 32 && c < 127)
|
|
66254
|
+
printable++;
|
|
66255
|
+
}
|
|
66256
|
+
return printable / n > 0.85;
|
|
66257
|
+
}
|
|
66258
|
+
exports2.builtinDetector = {
|
|
66259
|
+
version: exports2.DETECTOR_VERSION,
|
|
66260
|
+
detect(call) {
|
|
66261
|
+
const signals = [];
|
|
66262
|
+
const artifacts = Array.isArray(call.artifacts) ? call.artifacts : [];
|
|
66263
|
+
if (artifacts.length > 0)
|
|
66264
|
+
return { trigger: true, artifacts, signals: ["explicit_artifacts"], confident: true };
|
|
66265
|
+
if (READ_ONLY_TOOLS.has(String(call.toolName).toLowerCase()) && !commandMutatesContract(call)) {
|
|
66266
|
+
return { trigger: false, artifacts: [], signals: ["non_mutating_tool"], confident: true };
|
|
66267
|
+
}
|
|
66268
|
+
const paths = allPaths(call);
|
|
66269
|
+
const contractPath = paths.some(isContractPath);
|
|
66270
|
+
const codeContractPath = paths.some((p) => anyMatch(CODE_CONTRACT_PATH_RE, p) && !anyMatch(NON_SSOT_PATH_RE, p));
|
|
66271
|
+
const change = changeText(call);
|
|
66272
|
+
const inProse = paths.length > 0 && paths.every((p) => anyMatch(PROSE_PATH_RE, p));
|
|
66273
|
+
const contentMarker = anyMatch(CONTRACT_CONTENT_RE, change) && !paths.some((p) => anyMatch(NON_SSOT_PATH_RE, p)) && !inProse;
|
|
66274
|
+
const shellMutation = commandMutatesContract(call);
|
|
66275
|
+
const gate = gateDisabled(call);
|
|
66276
|
+
const lockContract = lockfileContractChange(call);
|
|
66277
|
+
const contractSurface = contractPath || contentMarker || shellMutation || codeContractPath || gate || lockContract;
|
|
66278
|
+
if (contractSurface) {
|
|
66279
|
+
if (shellMutation) {
|
|
66280
|
+
signals.push("shell_mutates_contract");
|
|
66281
|
+
return { trigger: true, artifacts, signals, confident: true };
|
|
66282
|
+
}
|
|
66283
|
+
if (gate) {
|
|
66284
|
+
signals.push("contract_gate_disabled");
|
|
66285
|
+
return { trigger: true, artifacts, signals, confident: true };
|
|
66286
|
+
}
|
|
66287
|
+
if (lockContract) {
|
|
66288
|
+
signals.push("lockfile_contract_redirect");
|
|
66289
|
+
return { trigger: true, artifacts, signals, confident: true };
|
|
66290
|
+
}
|
|
66291
|
+
if (isInertOnly(call)) {
|
|
66292
|
+
signals.push("inert_change_only");
|
|
66293
|
+
return { trigger: false, artifacts: [], signals, confident: true };
|
|
66294
|
+
}
|
|
66295
|
+
if (realChangePresent(call) || contentMarker || anyMatch(CONTRACT_STRUCTURE_RE, change)) {
|
|
66296
|
+
signals.push("contract_change");
|
|
66297
|
+
return { trigger: true, artifacts, signals, confident: true };
|
|
66298
|
+
}
|
|
66299
|
+
signals.push("ambiguous_contract_surface");
|
|
66300
|
+
return { trigger: true, artifacts, signals, confident: false };
|
|
66301
|
+
}
|
|
66302
|
+
const deep = deepArgScan(call);
|
|
66303
|
+
if (deep.contractContent || deep.pathContractSsot) {
|
|
66304
|
+
const deepInProse = deep.pathLikeCount > 0 && deep.proseCount === deep.pathLikeCount && !deep.pathContractSsot;
|
|
66305
|
+
if (!deep.pathNonSsot && !deepInProse && !isInertOnly(call)) {
|
|
66306
|
+
signals.push(deep.contractContent ? "arguments_deep_contract" : "arguments_deep_path");
|
|
66307
|
+
return { trigger: true, artifacts, signals, confident: false };
|
|
66308
|
+
}
|
|
66309
|
+
}
|
|
66310
|
+
if (deep.opaque || deep.capHit) {
|
|
66311
|
+
signals.push(deep.capHit ? "arguments_scan_capped" : "arguments_opaque");
|
|
66312
|
+
return { trigger: true, artifacts, signals, confident: false };
|
|
66313
|
+
}
|
|
66314
|
+
if (intentMentionsContract(call.intent)) {
|
|
66315
|
+
signals.push("intent_contract_reference");
|
|
66316
|
+
return { trigger: true, artifacts, signals, confident: false };
|
|
66317
|
+
}
|
|
66318
|
+
signals.push("no_contract_signal");
|
|
66319
|
+
return { trigger: false, artifacts: [], signals, confident: true };
|
|
66320
|
+
}
|
|
66321
|
+
};
|
|
66322
|
+
}
|
|
66323
|
+
});
|
|
66324
|
+
|
|
66325
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/receipt-binding.js
|
|
66326
|
+
var require_receipt_binding = __commonJS({
|
|
66327
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/receipt-binding.js"(exports2) {
|
|
66328
|
+
"use strict";
|
|
66329
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66330
|
+
exports2.canonicalJson = canonicalJson;
|
|
66331
|
+
exports2.computeBodyHash = computeBodyHash;
|
|
66332
|
+
exports2.bindReceiptToEnvelope = bindReceiptToEnvelope;
|
|
66333
|
+
var node_crypto_1 = require("node:crypto");
|
|
66334
|
+
function canonicalJson(value) {
|
|
66335
|
+
return encode(value);
|
|
66336
|
+
}
|
|
66337
|
+
function encode(value) {
|
|
66338
|
+
if (value === null)
|
|
66339
|
+
return "null";
|
|
66340
|
+
const t = typeof value;
|
|
66341
|
+
if (t === "boolean" || t === "string")
|
|
66342
|
+
return JSON.stringify(value);
|
|
66343
|
+
if (t === "number") {
|
|
66344
|
+
if (!Number.isFinite(value))
|
|
66345
|
+
throw new TypeError("canonicalJson: non-finite number is not representable");
|
|
66346
|
+
return JSON.stringify(value);
|
|
66347
|
+
}
|
|
66348
|
+
if (t === "undefined")
|
|
66349
|
+
throw new TypeError("canonicalJson: undefined is not representable (omit the key instead)");
|
|
66350
|
+
if (Array.isArray(value))
|
|
66351
|
+
return `[${value.map(encode).join(",")}]`;
|
|
66352
|
+
if (t === "object") {
|
|
66353
|
+
const obj = value;
|
|
66354
|
+
const keys = Object.keys(obj).sort();
|
|
66355
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${encode(obj[k])}`).join(",")}}`;
|
|
66356
|
+
}
|
|
66357
|
+
throw new TypeError(`canonicalJson: unsupported type ${t}`);
|
|
66358
|
+
}
|
|
66359
|
+
function sha256hex(s) {
|
|
66360
|
+
return (0, node_crypto_1.createHash)("sha256").update(s).digest("hex");
|
|
66361
|
+
}
|
|
66362
|
+
function computeBodyHash(envelope) {
|
|
66363
|
+
const rest = { ...envelope };
|
|
66364
|
+
delete rest.receipt;
|
|
66365
|
+
delete rest.decision_body_hash;
|
|
66366
|
+
return `sha256:${sha256hex(canonicalJson(rest))}`;
|
|
66367
|
+
}
|
|
66368
|
+
function bindReceiptToEnvelope(envelope, vr, ctx = {}) {
|
|
66369
|
+
if (!envelope)
|
|
66370
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: "no envelope" };
|
|
66371
|
+
if (!vr || vr.valid !== true)
|
|
66372
|
+
return { ok: false, cause: "RECEIPT_UNVERIFIED", detail: `valid=${vr ? vr.valid : "none"}` };
|
|
66373
|
+
if (vr.status !== "VERIFIED_CURRENT") {
|
|
66374
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: `status ${vr.status ?? "unknown"} != VERIFIED_CURRENT` };
|
|
66375
|
+
}
|
|
66376
|
+
const payload = vr.payload || {};
|
|
66377
|
+
const localBh = computeBodyHash(envelope);
|
|
66378
|
+
if (typeof payload.bh !== "string" || payload.bh !== localBh) {
|
|
66379
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: "decision_body_hash mismatch (receipt was signed over a different envelope)" };
|
|
66380
|
+
}
|
|
66381
|
+
if (typeof payload.fp !== "string" || payload.fp !== envelope.fingerprint) {
|
|
66382
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: "verdict_fingerprint mismatch" };
|
|
66383
|
+
}
|
|
66384
|
+
const requestedOp = ctx.operation ?? "tool_call";
|
|
66385
|
+
if (envelope.operation != null && requestedOp != null && envelope.operation !== requestedOp) {
|
|
66386
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: `operation ${String(envelope.operation)} != ${String(requestedOp)}` };
|
|
66387
|
+
}
|
|
66388
|
+
if (ctx.environment != null && envelope.environment != null && envelope.environment !== ctx.environment) {
|
|
66389
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: `environment ${String(envelope.environment)} != ${String(ctx.environment)}` };
|
|
66390
|
+
}
|
|
66391
|
+
if (ctx.audience != null && envelope.audience != null && envelope.audience !== ctx.audience) {
|
|
66392
|
+
return { ok: false, cause: "RECEIPT_ENVELOPE_MISMATCH", detail: `audience ${String(envelope.audience)} != ${String(ctx.audience)}` };
|
|
66393
|
+
}
|
|
66394
|
+
return { ok: true };
|
|
66395
|
+
}
|
|
66396
|
+
}
|
|
66397
|
+
});
|
|
66398
|
+
|
|
66399
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/enforcement-gate.js
|
|
66400
|
+
var require_enforcement_gate = __commonJS({
|
|
66401
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/enforcement-gate.js"(exports2) {
|
|
66402
|
+
"use strict";
|
|
66403
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66404
|
+
exports2.computeArtifactDigest = computeArtifactDigest;
|
|
66405
|
+
exports2.computeBundleFingerprint = computeBundleFingerprint;
|
|
66406
|
+
exports2.evaluateEnvelope = evaluateEnvelope;
|
|
66407
|
+
var node_crypto_1 = require("node:crypto");
|
|
66408
|
+
var DECISION_RANK = { ALLOW: 0, WARN: 1, REQUIRE_APPROVAL: 2, BLOCK: 3 };
|
|
66409
|
+
var ACTION_TO_DECISION = {
|
|
66410
|
+
CONTINUE: "ALLOW",
|
|
66411
|
+
CONTINUE_WITH_MONITORING: "WARN",
|
|
66412
|
+
REQUEST_APPROVAL: "REQUIRE_APPROVAL",
|
|
66413
|
+
STOP: "BLOCK"
|
|
66414
|
+
};
|
|
66415
|
+
var DECISION_TO_ACTION = {
|
|
66416
|
+
ALLOW: "CONTINUE",
|
|
66417
|
+
WARN: "CONTINUE_WITH_MONITORING",
|
|
66418
|
+
REQUIRE_APPROVAL: "REQUEST_APPROVAL",
|
|
66419
|
+
BLOCK: "STOP"
|
|
66420
|
+
};
|
|
66421
|
+
function isDecision(v) {
|
|
66422
|
+
return v === "ALLOW" || v === "WARN" || v === "REQUIRE_APPROVAL" || v === "BLOCK";
|
|
66423
|
+
}
|
|
66424
|
+
function isAction(v) {
|
|
66425
|
+
return v === "CONTINUE" || v === "CONTINUE_WITH_MONITORING" || v === "REQUEST_APPROVAL" || v === "STOP";
|
|
66426
|
+
}
|
|
66427
|
+
var NUL = "";
|
|
66428
|
+
function sha256hex(s) {
|
|
66429
|
+
return (0, node_crypto_1.createHash)("sha256").update(s).digest("hex");
|
|
66430
|
+
}
|
|
66431
|
+
function specStr(v) {
|
|
66432
|
+
return v == null ? "" : typeof v === "string" ? v : JSON.stringify(v);
|
|
66433
|
+
}
|
|
66434
|
+
function computeArtifactDigest(artifacts) {
|
|
66435
|
+
const preimage = artifacts.slice().sort((a, b) => `${a.type}${NUL}${a.id}` < `${b.type}${NUL}${b.id}` ? -1 : 1).map((a) => `${sha256hex(specStr(a.before))}${sha256hex(specStr(a.after))}`).join(NUL);
|
|
66436
|
+
return `sha256:${sha256hex(preimage)}`;
|
|
66437
|
+
}
|
|
66438
|
+
function computeBundleFingerprint(artifacts) {
|
|
66439
|
+
const parts = artifacts.slice().sort((a, b) => `${a.type}${NUL}${a.id}` < `${b.type}${NUL}${b.id}` ? -1 : 1).map((a) => [a.type, a.id, sha256hex(specStr(a.before)), sha256hex(specStr(a.after))].join(NUL));
|
|
66440
|
+
return `sha256:${sha256hex(parts.join(NUL))}`;
|
|
66441
|
+
}
|
|
66442
|
+
function evaluateEnvelope(response, envelope, executionAction, sentArtifacts) {
|
|
66443
|
+
const dec = envelope.decision;
|
|
66444
|
+
if (!isDecision(dec)) {
|
|
66445
|
+
return { verdict: "fail-closed", cause: "DECISION_INCONSISTENT", detail: `decision=${JSON.stringify(dec)} is missing/invalid` };
|
|
66446
|
+
}
|
|
66447
|
+
const signals = [dec, ACTION_TO_DECISION[executionAction]];
|
|
66448
|
+
const top = response && typeof response === "object" ? response : {};
|
|
66449
|
+
if (isDecision(top.decision))
|
|
66450
|
+
signals.push(top.decision);
|
|
66451
|
+
if (isAction(top.execution_action))
|
|
66452
|
+
signals.push(ACTION_TO_DECISION[top.execution_action]);
|
|
66453
|
+
const effective = signals.reduce((a, b) => DECISION_RANK[b] > DECISION_RANK[a] ? b : a);
|
|
66454
|
+
if (DECISION_RANK[effective] >= DECISION_RANK.REQUIRE_APPROVAL) {
|
|
66455
|
+
return { verdict: "block-strict", decision: effective };
|
|
66456
|
+
}
|
|
66457
|
+
if (DECISION_TO_ACTION[dec] !== executionAction) {
|
|
66458
|
+
return { verdict: "fail-closed", cause: "DECISION_INCONSISTENT", detail: `decision=${dec} \u2260 execution_action=${executionAction}` };
|
|
66459
|
+
}
|
|
66460
|
+
if (envelope.safe_for_agent === false) {
|
|
66461
|
+
return { verdict: "fail-closed", cause: "DECISION_INCONSISTENT", detail: "safe_for_agent=false on an allow-class decision" };
|
|
66462
|
+
}
|
|
66463
|
+
const degradedReasons = envelope.degraded_reasons;
|
|
66464
|
+
if (envelope.analysis_complete === false || Array.isArray(degradedReasons) && degradedReasons.length > 0 || envelope.degraded === true || envelope.coverage_gap === true) {
|
|
66465
|
+
return { verdict: "fail-closed", cause: "ANALYSIS_DEGRADED", detail: "analysis degraded / incomplete" };
|
|
66466
|
+
}
|
|
66467
|
+
if (Array.isArray(sentArtifacts) && sentArtifacts.length > 0 && typeof envelope.artifact_digest === "string" && envelope.artifact_digest !== computeArtifactDigest(sentArtifacts)) {
|
|
66468
|
+
return { verdict: "fail-closed", cause: "ARTIFACT_MISMATCH", detail: "artifact_digest \u2260 locally-recomputed digest of sent artifacts" };
|
|
66469
|
+
}
|
|
66470
|
+
return { verdict: "allow", kind: effective === "ALLOW" ? "ALLOW" : "MONITOR" };
|
|
66471
|
+
}
|
|
66472
|
+
}
|
|
66473
|
+
});
|
|
66474
|
+
|
|
66475
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/guard.js
|
|
66476
|
+
var require_guard = __commonJS({
|
|
66477
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/guard.js"(exports2) {
|
|
66478
|
+
"use strict";
|
|
66479
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66480
|
+
exports2.guardToolCall = guardToolCall;
|
|
66481
|
+
var node_crypto_1 = require("node:crypto");
|
|
66482
|
+
var sdk_1 = require_cjs3();
|
|
66483
|
+
var detector_js_1 = require_detector();
|
|
66484
|
+
var receipt_binding_js_1 = require_receipt_binding();
|
|
66485
|
+
var enforcement_gate_js_1 = require_enforcement_gate();
|
|
66486
|
+
var breakers = /* @__PURE__ */ new WeakMap();
|
|
66487
|
+
var nowMs = () => Date.now();
|
|
66488
|
+
var iso = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
66489
|
+
function emit(config, e) {
|
|
66490
|
+
if (config.onEvent) {
|
|
66491
|
+
try {
|
|
66492
|
+
config.onEvent(e);
|
|
66493
|
+
} catch {
|
|
66494
|
+
}
|
|
66495
|
+
}
|
|
66496
|
+
}
|
|
66497
|
+
function fingerprint(call) {
|
|
66498
|
+
const canon = JSON.stringify({ toolName: call.toolName, arguments: call.arguments, artifacts: call.artifacts, filesTouched: call.filesTouched, diff: call.diff });
|
|
66499
|
+
return "sha256:" + (0, node_crypto_1.createHash)("sha256").update(canon).digest("hex");
|
|
66500
|
+
}
|
|
66501
|
+
function breakerRecord(config) {
|
|
66502
|
+
let s = breakers.get(config);
|
|
66503
|
+
if (!s) {
|
|
66504
|
+
s = { fails: [] };
|
|
66505
|
+
breakers.set(config, s);
|
|
66506
|
+
}
|
|
66507
|
+
s.fails.push(nowMs());
|
|
66508
|
+
}
|
|
66509
|
+
function breakerTripped(config) {
|
|
66510
|
+
const s = breakers.get(config);
|
|
66511
|
+
if (!s)
|
|
66512
|
+
return false;
|
|
66513
|
+
const win = config.breakerWindowMs ?? 6e4;
|
|
66514
|
+
const t = nowMs();
|
|
66515
|
+
s.fails = s.fails.filter((x) => t - x < win);
|
|
66516
|
+
return s.fails.length >= (config.maxUnavailablePerWindow ?? 3);
|
|
66517
|
+
}
|
|
66518
|
+
function classifyError(err, config) {
|
|
66519
|
+
const e = err;
|
|
66520
|
+
const name = e?.name;
|
|
66521
|
+
const status = e?.status ?? e?.body?.status;
|
|
66522
|
+
if (name === "TimeoutError" || name === "AbortError" || e?.code === "ABORT_ERR")
|
|
66523
|
+
return { cause: "TIMEOUT", integrity: false };
|
|
66524
|
+
if (status === 429 || name === "RateLimitError")
|
|
66525
|
+
return { cause: "RATE_LIMITED", integrity: false };
|
|
66526
|
+
if (status === 413)
|
|
66527
|
+
return { cause: "PAYLOAD_TOO_LARGE", integrity: true };
|
|
66528
|
+
if (status === 422)
|
|
66529
|
+
return { cause: "REQUEST_REJECTED", integrity: true };
|
|
66530
|
+
if (status === 400 || status === 401 || status === 409)
|
|
66531
|
+
return { cause: "REQUEST_REJECTED", integrity: true };
|
|
66532
|
+
if (typeof status === "number" && status >= 500)
|
|
66533
|
+
return { cause: "SERVER_ERROR", integrity: false };
|
|
66534
|
+
if (name === "TypeError" || /fetch failed|network|ENOTFOUND|ECONNREFUSED|EAI_AGAIN/i.test(String(e?.message)))
|
|
66535
|
+
return { cause: "NETWORK", integrity: false };
|
|
66536
|
+
if (name === "ApiError")
|
|
66537
|
+
return { cause: "SERVER_ERROR", integrity: false };
|
|
66538
|
+
return { cause: "INVALID_RESPONSE", integrity: true };
|
|
66539
|
+
}
|
|
66540
|
+
function withTimeout(p, ms) {
|
|
66541
|
+
return new Promise((resolve, reject) => {
|
|
66542
|
+
const timer = setTimeout(() => reject(Object.assign(new Error(`preflight timed out after ${ms}ms`), { name: "TimeoutError" })), Math.max(1, ms));
|
|
66543
|
+
p.then((v) => {
|
|
66544
|
+
clearTimeout(timer);
|
|
66545
|
+
resolve(v);
|
|
66546
|
+
}, (e) => {
|
|
66547
|
+
clearTimeout(timer);
|
|
66548
|
+
reject(e);
|
|
66549
|
+
});
|
|
66550
|
+
});
|
|
66551
|
+
}
|
|
66552
|
+
async function preflightWithRetry(config, request) {
|
|
66553
|
+
const retries = config.retries ?? 1;
|
|
66554
|
+
const timeoutMs = config.timeoutMs ?? 2e3;
|
|
66555
|
+
const budget = config.totalBudgetMs ?? 4500;
|
|
66556
|
+
const start = nowMs();
|
|
66557
|
+
let last = { cause: "TIMEOUT", integrity: false };
|
|
66558
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
66559
|
+
const remaining = budget - (nowMs() - start);
|
|
66560
|
+
if (remaining <= 0)
|
|
66561
|
+
return { ok: false, cause: "TIMEOUT", integrity: false };
|
|
66562
|
+
try {
|
|
66563
|
+
const response = await withTimeout(config.client.preflightChangeSet(request), Math.min(timeoutMs, remaining));
|
|
66564
|
+
return { ok: true, response };
|
|
66565
|
+
} catch (err) {
|
|
66566
|
+
last = classifyError(err, config);
|
|
66567
|
+
if (last.integrity)
|
|
66568
|
+
return { ok: false, ...last };
|
|
66569
|
+
}
|
|
66570
|
+
}
|
|
66571
|
+
return { ok: false, ...last };
|
|
66572
|
+
}
|
|
66573
|
+
async function verifyEnvelope(config, envelope) {
|
|
66574
|
+
if (!envelope)
|
|
66575
|
+
return { verified: null };
|
|
66576
|
+
if (config.verifyReceipts === false)
|
|
66577
|
+
return { verified: null };
|
|
66578
|
+
const token = envelope.receipt?.token;
|
|
66579
|
+
if (!token)
|
|
66580
|
+
return { verified: null };
|
|
66581
|
+
try {
|
|
66582
|
+
const r = await config.client.verifyReceipt(token);
|
|
66583
|
+
const bind = (0, receipt_binding_js_1.bindReceiptToEnvelope)(envelope, r, { operation: config.operation, environment: config.environment, audience: config.audience });
|
|
66584
|
+
if (bind.ok)
|
|
66585
|
+
return { verified: envelope };
|
|
66586
|
+
emit(config, { type: "receipt_unverified", at: iso(), decisionId: envelope.decision_id, cause: bind.detail });
|
|
66587
|
+
return { verified: null, cause: bind.cause };
|
|
66588
|
+
} catch {
|
|
66589
|
+
return { verified: null, cause: "RECEIPT_UNVERIFIED" };
|
|
66590
|
+
}
|
|
66591
|
+
}
|
|
66592
|
+
async function runEnforced(config, factory, approved, redacted) {
|
|
66593
|
+
emit(config, { type: "execution_started", at: iso(), action: approved.action, decisionId: approved.envelope.decision_id });
|
|
66594
|
+
try {
|
|
66595
|
+
const result = await factory(approved.envelope, redacted);
|
|
66596
|
+
return { executionAttempted: true, executed: true, enforced: true, result, verdict: approved, preflighted: true };
|
|
66597
|
+
} catch (error) {
|
|
66598
|
+
emit(config, { type: "factory_error", at: iso(), action: approved.action });
|
|
66599
|
+
return { executionAttempted: true, executed: false, enforced: true, error, verdict: approved, preflighted: true };
|
|
66600
|
+
}
|
|
66601
|
+
}
|
|
66602
|
+
async function runUnenforced(config, factory, envelope, verdict, preflighted, redacted) {
|
|
66603
|
+
emit(config, { type: "execution_started", at: iso() });
|
|
66604
|
+
try {
|
|
66605
|
+
const result = await factory(envelope, redacted);
|
|
66606
|
+
return { executionAttempted: true, executed: true, enforced: false, result, verdict, preflighted };
|
|
66607
|
+
} catch (error) {
|
|
66608
|
+
emit(config, { type: "factory_error", at: iso() });
|
|
66609
|
+
return { executionAttempted: true, executed: false, enforced: false, error, verdict, preflighted };
|
|
66610
|
+
}
|
|
66611
|
+
}
|
|
66612
|
+
function blocked(verdict, preflighted) {
|
|
66613
|
+
return { executionAttempted: false, executed: false, enforced: false, verdict, preflighted };
|
|
66614
|
+
}
|
|
66615
|
+
function hasAnalyzableContent(artifacts) {
|
|
66616
|
+
if (!Array.isArray(artifacts) || artifacts.length === 0)
|
|
66617
|
+
return false;
|
|
66618
|
+
return artifacts.some((a) => {
|
|
66619
|
+
if (!a || typeof a !== "object")
|
|
66620
|
+
return false;
|
|
66621
|
+
const before = a.before;
|
|
66622
|
+
const after = a.after;
|
|
66623
|
+
return typeof before === "string" && before.length > 0 || typeof after === "string" && after.length > 0;
|
|
66624
|
+
});
|
|
66625
|
+
}
|
|
66626
|
+
function unavailableVerdict(parts, count) {
|
|
66627
|
+
return { kind: "UNAVAILABLE", decisionMissing: true, unavailableCount: count, ...parts };
|
|
66628
|
+
}
|
|
66629
|
+
async function guardToolCall(call, executeFactory, config) {
|
|
66630
|
+
const failPolicy = config.failPolicy ?? "closed";
|
|
66631
|
+
let redacted;
|
|
66632
|
+
try {
|
|
66633
|
+
redacted = config.redactor ? config.redactor(call) : call;
|
|
66634
|
+
} catch {
|
|
66635
|
+
breakerRecord(config);
|
|
66636
|
+
return closedIntegrity(config, "CONFIG_ERROR", failPolicy);
|
|
66637
|
+
}
|
|
66638
|
+
const inputFp = fingerprint(redacted);
|
|
66639
|
+
const detector = config.detector ?? detector_js_1.builtinDetector;
|
|
66640
|
+
let detection;
|
|
66641
|
+
try {
|
|
66642
|
+
detection = detector.detect(redacted);
|
|
66643
|
+
} catch {
|
|
66644
|
+
breakerRecord(config);
|
|
66645
|
+
return closedIntegrity(config, "DETECTOR_ERROR", failPolicy);
|
|
66646
|
+
}
|
|
66647
|
+
const suppressedByStrict = config.requireExplicitArtifacts === true && redacted.nonContract === true && (!detection.artifacts || detection.artifacts.length === 0) && detection.confident && !detection.trigger;
|
|
66648
|
+
if (!detection.trigger || suppressedByStrict) {
|
|
66649
|
+
emit(config, { type: "detection_skip", at: iso(), signals: detection.signals, detectorVersion: detector.version });
|
|
66650
|
+
const verdict = { kind: "SKIPPED", reason: "NOT_A_CONTRACT_CALL", signals: detection.signals, detectorVersion: detector.version };
|
|
66651
|
+
return runUnenforced(config, executeFactory, null, verdict, false, redacted);
|
|
66652
|
+
}
|
|
66653
|
+
if (!hasAnalyzableContent(detection.artifacts)) {
|
|
66654
|
+
emit(config, { type: "artifact_content_missing", at: iso(), cause: "MISSING_ARTIFACT_CONTENT", signals: detection.signals });
|
|
66655
|
+
const count = breakers.get(config)?.fails.length ?? 0;
|
|
66656
|
+
const v = unavailableVerdict({ cause: "MISSING_ARTIFACT_CONTENT", failPolicy, resolution: "CLOSED", action: "STOP" }, count);
|
|
66657
|
+
return blocked(v, false);
|
|
66658
|
+
}
|
|
66659
|
+
if (failPolicy === "lkg" && !config.lkg) {
|
|
66660
|
+
breakerRecord(config);
|
|
66661
|
+
return closedIntegrity(config, "CONFIG_ERROR", failPolicy);
|
|
66662
|
+
}
|
|
66663
|
+
const request = {
|
|
66664
|
+
artifacts: detection.artifacts,
|
|
66665
|
+
context: { operation: config.operation ?? "tool_call", environment: config.environment, audience: config.audience },
|
|
66666
|
+
previous_receipt: void 0,
|
|
66667
|
+
idempotency_key: void 0
|
|
66668
|
+
};
|
|
66669
|
+
const cap = config.maxPayloadBytes ?? 1e6;
|
|
66670
|
+
if (Buffer.byteLength(JSON.stringify(request), "utf8") > cap) {
|
|
66671
|
+
breakerRecord(config);
|
|
66672
|
+
return closedIntegrity(config, "PAYLOAD_TOO_LARGE", failPolicy);
|
|
66673
|
+
}
|
|
66674
|
+
emit(config, { type: "preflight_start", at: iso() });
|
|
66675
|
+
const pf = await preflightWithRetry(config, request);
|
|
66676
|
+
if (!pf.ok) {
|
|
66677
|
+
breakerRecord(config);
|
|
66678
|
+
const count = breakers.get(config)?.fails.length ?? 1;
|
|
66679
|
+
if (pf.integrity) {
|
|
66680
|
+
emit(config, { type: "breaker_tripped", at: iso(), cause: pf.cause });
|
|
66681
|
+
const v2 = unavailableVerdict({ cause: pf.cause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
|
|
66682
|
+
return blocked(v2, false);
|
|
66683
|
+
}
|
|
66684
|
+
const availCause = pf.cause;
|
|
66685
|
+
if (failPolicy === "open" && !breakerTripped(config)) {
|
|
66686
|
+
emit(config, { type: "preflight_unavailable", at: iso(), cause: availCause, action: "CONTINUE" });
|
|
66687
|
+
const v2 = unavailableVerdict({ cause: availCause, failPolicy: "open", resolution: "OPEN_PASSTHROUGH", action: "CONTINUE" }, count);
|
|
66688
|
+
return runUnenforced(config, executeFactory, null, v2, false, redacted);
|
|
66689
|
+
}
|
|
66690
|
+
if (failPolicy === "lkg") {
|
|
66691
|
+
const lkg = await tryLkg(config, inputFp);
|
|
66692
|
+
if (lkg) {
|
|
66693
|
+
emit(config, { type: "preflight_unavailable", at: iso(), cause: availCause, action: lkg.action });
|
|
66694
|
+
const v2 = unavailableVerdict({ cause: availCause, failPolicy: "lkg", resolution: "LKG_SUBSTITUTION", action: lkg.action, lkgEnvelope: lkg.envelope }, count);
|
|
66695
|
+
return runUnenforced(config, executeFactory, lkg.envelope, v2, false, redacted);
|
|
66696
|
+
}
|
|
66697
|
+
}
|
|
66698
|
+
if (breakerTripped(config))
|
|
66699
|
+
emit(config, { type: "breaker_tripped", at: iso(), cause: availCause });
|
|
66700
|
+
const v = unavailableVerdict({ cause: availCause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
|
|
66701
|
+
return blocked(v, false);
|
|
66702
|
+
}
|
|
66703
|
+
const rd = (0, sdk_1.readDecision)(pf.response);
|
|
66704
|
+
if (rd.reason === "UNREADABLE_DECISION" || !rd.envelope) {
|
|
66705
|
+
breakerRecord(config);
|
|
66706
|
+
return closedIntegrity(config, "SCHEMA_INVALID", failPolicy);
|
|
66707
|
+
}
|
|
66708
|
+
const envelope = rd.envelope;
|
|
66709
|
+
const expired = isExpired(envelope);
|
|
66710
|
+
const bindResult = await verifyEnvelope(config, envelope);
|
|
66711
|
+
const verified = bindResult.verified;
|
|
66712
|
+
const receiptVerified = !!verified;
|
|
66713
|
+
if (!receiptVerified)
|
|
66714
|
+
emit(config, { type: "receipt_unverified", at: iso(), decisionId: envelope.decision_id });
|
|
66715
|
+
emit(config, { type: "preflight_result", at: iso(), action: rd.executionAction, decisionId: envelope.decision_id });
|
|
66716
|
+
if (config.verifyReceipts !== false && !receiptVerified && envelope.receipt?.token) {
|
|
66717
|
+
breakerRecord(config);
|
|
66718
|
+
return closedIntegrity(config, bindResult.cause ?? "RECEIPT_UNVERIFIED", failPolicy);
|
|
66719
|
+
}
|
|
66720
|
+
const gate = (0, enforcement_gate_js_1.evaluateEnvelope)(pf.response, envelope, rd.executionAction, detection.artifacts);
|
|
66721
|
+
if (gate.verdict === "fail-closed") {
|
|
66722
|
+
breakerRecord(config);
|
|
66723
|
+
return closedIntegrity(config, gate.cause, failPolicy);
|
|
66724
|
+
}
|
|
66725
|
+
if (gate.verdict === "block-strict") {
|
|
66726
|
+
return gate.decision === "BLOCK" ? blocked({ kind: "BLOCK", action: "STOP", envelope, receiptVerified }, true) : blocked({ kind: "APPROVAL", action: "REQUEST_APPROVAL", envelope, receiptVerified }, true);
|
|
66727
|
+
}
|
|
66728
|
+
const kind = gate.kind;
|
|
66729
|
+
if (expired) {
|
|
66730
|
+
breakerRecord(config);
|
|
66731
|
+
return closedIntegrity(config, "SCHEMA_INVALID", failPolicy);
|
|
66732
|
+
}
|
|
66733
|
+
const sinkWired = !!config.onEvent;
|
|
66734
|
+
if (kind === "MONITOR") {
|
|
66735
|
+
if (sinkWired)
|
|
66736
|
+
emit(config, { type: "monitoring_required", at: iso(), decisionId: envelope.decision_id });
|
|
66737
|
+
else
|
|
66738
|
+
emit(config, { type: "monitoring_unwired", at: iso(), decisionId: envelope.decision_id });
|
|
66739
|
+
}
|
|
66740
|
+
if (config.observeOnly) {
|
|
66741
|
+
emit(config, { type: "observe_only_passthrough", at: iso(), action: rd.executionAction });
|
|
66742
|
+
const verdict = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified };
|
|
66743
|
+
return runUnenforced(config, executeFactory, envelope, verdict, true, redacted);
|
|
66744
|
+
}
|
|
66745
|
+
const enforceable = receiptVerified && (kind === "ALLOW" || sinkWired);
|
|
66746
|
+
if (enforceable) {
|
|
66747
|
+
const approved = kind === "ALLOW" ? { kind: "ALLOW", action: "CONTINUE", envelope, receiptVerified: true } : { kind: "MONITOR", action: "CONTINUE_WITH_MONITORING", envelope, receiptVerified: true };
|
|
66748
|
+
return runEnforced(config, executeFactory, approved, redacted);
|
|
66749
|
+
}
|
|
66750
|
+
breakerRecord(config);
|
|
66751
|
+
return closedIntegrity(config, receiptVerified ? "MONITORING_UNWIRED" : "RECEIPT_MISSING", failPolicy);
|
|
66752
|
+
}
|
|
66753
|
+
function closedIntegrity(config, cause, failPolicy) {
|
|
66754
|
+
const count = breakers.get(config)?.fails.length ?? 1;
|
|
66755
|
+
emit(config, { type: "breaker_tripped", at: iso(), cause });
|
|
66756
|
+
const v = unavailableVerdict({ cause, failPolicy, resolution: "CLOSED", action: "STOP" }, count);
|
|
66757
|
+
return blocked(v, false);
|
|
66758
|
+
}
|
|
66759
|
+
function isExpired(envelope) {
|
|
66760
|
+
const exp = envelope.expires_at;
|
|
66761
|
+
if (typeof exp !== "string")
|
|
66762
|
+
return false;
|
|
66763
|
+
const t = Date.parse(exp);
|
|
66764
|
+
return Number.isFinite(t) && t < Date.now();
|
|
66765
|
+
}
|
|
66766
|
+
async function tryLkg(config, inputFp) {
|
|
66767
|
+
if (!config.lkg)
|
|
66768
|
+
return null;
|
|
66769
|
+
let cached;
|
|
66770
|
+
try {
|
|
66771
|
+
cached = await config.lkg.get(inputFp);
|
|
66772
|
+
} catch {
|
|
66773
|
+
return null;
|
|
66774
|
+
}
|
|
66775
|
+
if (!cached)
|
|
66776
|
+
return null;
|
|
66777
|
+
const { verified } = await verifyEnvelope(config, cached);
|
|
66778
|
+
if (!verified)
|
|
66779
|
+
return null;
|
|
66780
|
+
const dec = cached.decision ?? "";
|
|
66781
|
+
if (dec !== "ALLOW" && dec !== "WARN")
|
|
66782
|
+
return null;
|
|
66783
|
+
if (isExpired(cached))
|
|
66784
|
+
return null;
|
|
66785
|
+
const maxAge = config.lkgMaxAgeMs ?? 9e5;
|
|
66786
|
+
const evalAt = Date.parse(cached.evaluated_at);
|
|
66787
|
+
if (Number.isFinite(evalAt) && Date.now() - evalAt > maxAge)
|
|
66788
|
+
return null;
|
|
66789
|
+
const bindings = [
|
|
66790
|
+
cached.ruleset_hash,
|
|
66791
|
+
cached.environment,
|
|
66792
|
+
cached.operation,
|
|
66793
|
+
cached.audience
|
|
66794
|
+
];
|
|
66795
|
+
if (bindings.some((b) => b === void 0))
|
|
66796
|
+
return null;
|
|
66797
|
+
const action = dec === "ALLOW" ? "CONTINUE" : "CONTINUE_WITH_MONITORING";
|
|
66798
|
+
return { envelope: verified, action };
|
|
66799
|
+
}
|
|
66800
|
+
}
|
|
66801
|
+
});
|
|
66802
|
+
|
|
66803
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/session-taint.js
|
|
66804
|
+
var require_session_taint = __commonJS({
|
|
66805
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/session-taint.js"(exports2) {
|
|
66806
|
+
"use strict";
|
|
66807
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66808
|
+
exports2.SessionTaintTracker = exports2.SESSION_TAINT_VERSION = void 0;
|
|
66809
|
+
exports2.pathClass = pathClass;
|
|
66810
|
+
exports2.emptySessionState = emptySessionState;
|
|
66811
|
+
exports2.projectState = projectState;
|
|
66812
|
+
exports2.classifyCommand = classifyCommand;
|
|
66813
|
+
exports2.updateSession = updateSession;
|
|
66814
|
+
exports2.computeTainted = computeTainted;
|
|
66815
|
+
exports2.deriveKeySignal = deriveKeySignal;
|
|
66816
|
+
exports2.evaluate = evaluate;
|
|
66817
|
+
exports2.SESSION_TAINT_VERSION = "session-taint/1.0.0";
|
|
66818
|
+
var NON_SSOT_RE = /(^|\/)(tests?|__tests__|fixtures?|__mocks__|src\/internal)\//i;
|
|
66819
|
+
var PIPELINE_SCRATCH_RE = /(^|\/)(build|\.cache|codegen|idl)(\/|$)/i;
|
|
66820
|
+
var PROSE_RE = /(^|\/)(README|CHANGELOG|LICENSE)(\.\w+)?$|\.md$/i;
|
|
66821
|
+
var SSOT_PATH_RE = /(^|\/)(openapi|swagger|asyncapi)[^/]*\.(ya?ml|json)$|(^|\/)mcp\.json$|\.graphql$|\.gql$|(^|\/)idl\/.*\.proto$|(^|\/)specs?\/.*\.(ya?ml|json)$|openapi\.yaml|schema\.graphql|asyncapi\.yaml/i;
|
|
66822
|
+
var MIGRATION_RE = /(^|\/)migrations?\//i;
|
|
66823
|
+
var CODE_OR_CONFIG_RE = /\.(ts|tsx|js|jsx)$/i;
|
|
66824
|
+
var CONTRACT_CONTENT_RE = /\bopenapi\s*[:=]|\bswagger\s*[:=]|\basyncapi\s*[:=]|syntax\s*=\s*["']proto3|["']inputSchema["']|\btype\s+Query\b|(^|\n)\s*paths\s*:/i;
|
|
66825
|
+
var STAGING_NAME_RE = /\.b64$|enc\/|field-map|flags\.json|optional_fields|required_fields|service\.idl|frags\/|BREAKING_DROP/i;
|
|
66826
|
+
var NON_SINK_RE = /validate-frags|gen-docs|reload-flags|snapshot-spec|prettier|npm test|npm install|npx prettier/i;
|
|
66827
|
+
var SSOT_INVALIDATE_RE = /archive-old-spec/i;
|
|
66828
|
+
var SSOT_SINK_RE = /dsl-to-openapi|merge-spec|publish-fixture|promote-spec|sync-graphql|b64join-write|decode-promote|apply-field-map|render-openapi|idl\/compile|generate-and-test|compile_spec_bundle|install-proto|install-mcp|promote-asyncapi|repack-extract|codegen\/build\.js|codegen\/apply|codegen\/render/i;
|
|
66829
|
+
function pathClass(p) {
|
|
66830
|
+
if (PROSE_RE.test(p))
|
|
66831
|
+
return "prose";
|
|
66832
|
+
if (NON_SSOT_RE.test(p) || PIPELINE_SCRATCH_RE.test(p))
|
|
66833
|
+
return "scratch";
|
|
66834
|
+
if (MIGRATION_RE.test(p))
|
|
66835
|
+
return "migration";
|
|
66836
|
+
if (SSOT_PATH_RE.test(p))
|
|
66837
|
+
return "ssot";
|
|
66838
|
+
if (CODE_OR_CONFIG_RE.test(p) || p.startsWith("src/") || p.startsWith("config/") || p === "package.json")
|
|
66839
|
+
return "code_or_config";
|
|
66840
|
+
return "other";
|
|
66841
|
+
}
|
|
66842
|
+
function emptySessionState() {
|
|
66843
|
+
return {
|
|
66844
|
+
scratch_writes: [],
|
|
66845
|
+
contract_looking_scratch: [],
|
|
66846
|
+
encoded_fragments: [],
|
|
66847
|
+
intermediate_artifacts: [],
|
|
66848
|
+
pending_renames: [],
|
|
66849
|
+
optional_fields_added: [],
|
|
66850
|
+
required_fields_declared: [],
|
|
66851
|
+
ssot_paths_touched: [],
|
|
66852
|
+
ssot_sink_events: [],
|
|
66853
|
+
ssot_invalidated: false,
|
|
66854
|
+
reverse_snapshot: false,
|
|
66855
|
+
formatter_only_ssot: false,
|
|
66856
|
+
store_keys: [],
|
|
66857
|
+
tainted: false
|
|
66858
|
+
};
|
|
66859
|
+
}
|
|
66860
|
+
function projectState(s) {
|
|
66861
|
+
return {
|
|
66862
|
+
scratch_writes: s.scratch_writes.slice(),
|
|
66863
|
+
encoded_fragments: s.encoded_fragments.slice(),
|
|
66864
|
+
pending_renames: s.pending_renames.map((r) => "drop" in r ? `drop:${r.drop}` : `${r.from}->${r.to}`),
|
|
66865
|
+
optional_fields_added: s.optional_fields_added.slice(),
|
|
66866
|
+
required_fields_declared: s.required_fields_declared.slice(),
|
|
66867
|
+
ssot_paths_touched: s.ssot_paths_touched.slice(),
|
|
66868
|
+
contract_looking_scratch: s.contract_looking_scratch.slice(),
|
|
66869
|
+
intermediate_artifacts: s.intermediate_artifacts.slice(),
|
|
66870
|
+
ssot_sink_events: s.ssot_sink_events.slice(),
|
|
66871
|
+
ssot_invalidated: s.ssot_invalidated,
|
|
66872
|
+
reverse_snapshot: s.reverse_snapshot,
|
|
66873
|
+
formatter_only_ssot: s.formatter_only_ssot,
|
|
66874
|
+
store_keys: s.store_keys.slice(),
|
|
66875
|
+
tainted: s.tainted
|
|
66876
|
+
};
|
|
66877
|
+
}
|
|
66878
|
+
function asRecord(args) {
|
|
66879
|
+
return args && typeof args === "object" ? args : {};
|
|
66880
|
+
}
|
|
66881
|
+
function extractPaths(args) {
|
|
66882
|
+
const a = asRecord(args);
|
|
66883
|
+
const out = [];
|
|
66884
|
+
for (const k of ["path", "target", "file", "dest", "filename", "destination"])
|
|
66885
|
+
if (typeof a[k] === "string")
|
|
66886
|
+
out.push(a[k]);
|
|
66887
|
+
return out;
|
|
66888
|
+
}
|
|
66889
|
+
function extractContent(args) {
|
|
66890
|
+
const a = asRecord(args);
|
|
66891
|
+
const parts = [];
|
|
66892
|
+
for (const k of ["contents", "content", "new_string", "old_string", "patch", "value", "command"])
|
|
66893
|
+
if (typeof a[k] === "string")
|
|
66894
|
+
parts.push(a[k]);
|
|
66895
|
+
return parts.join("\n");
|
|
66896
|
+
}
|
|
66897
|
+
function isEncodedFragment(path, content) {
|
|
66898
|
+
if (path && /part\.|enc\/|\.b64$|pkg\.part/i.test(path))
|
|
66899
|
+
return true;
|
|
66900
|
+
const c = content.replace(/\s+/g, "");
|
|
66901
|
+
if (c.length >= 8 && c.length < 80 && /^[A-Za-z0-9+/=]+$/.test(c))
|
|
66902
|
+
return true;
|
|
66903
|
+
return false;
|
|
66904
|
+
}
|
|
66905
|
+
function classifyCommand(command, action, cfg = {}) {
|
|
66906
|
+
const s = `${command || ""} ${action || ""}`;
|
|
66907
|
+
const extraNon = cfg.extraNonSinkPatterns || [];
|
|
66908
|
+
const extraSink = cfg.extraSinkPatterns || [];
|
|
66909
|
+
if (NON_SINK_RE.test(s) || extraNon.some((r) => r.test(s)))
|
|
66910
|
+
return "non_sink";
|
|
66911
|
+
if (SSOT_INVALIDATE_RE.test(s))
|
|
66912
|
+
return "ssot_invalidate";
|
|
66913
|
+
if (SSOT_SINK_RE.test(s) || action === "compile_spec_bundle" || extraSink.some((r) => r.test(s)))
|
|
66914
|
+
return "ssot_sink";
|
|
66915
|
+
if (/snapshot/i.test(s))
|
|
66916
|
+
return "reverse_snapshot";
|
|
66917
|
+
if (/prettier|format/i.test(s))
|
|
66918
|
+
return "formatter";
|
|
66919
|
+
return "unknown_script";
|
|
66920
|
+
}
|
|
66921
|
+
function pushUniq(arr, v) {
|
|
66922
|
+
if (v != null && !arr.includes(v))
|
|
66923
|
+
arr.push(v);
|
|
66924
|
+
}
|
|
66925
|
+
function updateSession(state, call, cfg = {}) {
|
|
66926
|
+
const s = JSON.parse(JSON.stringify(state));
|
|
66927
|
+
const args = asRecord(call && call.arguments);
|
|
66928
|
+
const paths = extractPaths(args);
|
|
66929
|
+
const content = extractContent(args);
|
|
66930
|
+
const tool = call && call.toolName;
|
|
66931
|
+
if (tool === "store" && typeof args.key === "string") {
|
|
66932
|
+
pushUniq(s.store_keys, args.key);
|
|
66933
|
+
if (/spec_|api_|openapi|schema/i.test(args.key) || /BREAKING|ROUTE|FIELD|REMOVE|MANDATORY|required|optional/i.test(String(args.value))) {
|
|
66934
|
+
pushUniq(s.intermediate_artifacts, `store:${args.key}`);
|
|
66935
|
+
}
|
|
66936
|
+
}
|
|
66937
|
+
if (tool === "apply" && typeof args.action === "string") {
|
|
66938
|
+
if (classifyCommand("", args.action, cfg) === "ssot_sink")
|
|
66939
|
+
s.ssot_sink_events.push(args.action);
|
|
66940
|
+
}
|
|
66941
|
+
if (tool === "Bash" || typeof args.command === "string") {
|
|
66942
|
+
const cmd = typeof args.command === "string" ? args.command : "";
|
|
66943
|
+
const kind = classifyCommand(cmd, "", cfg);
|
|
66944
|
+
if (kind === "ssot_sink")
|
|
66945
|
+
s.ssot_sink_events.push(cmd);
|
|
66946
|
+
if (kind === "ssot_invalidate")
|
|
66947
|
+
s.ssot_invalidated = true;
|
|
66948
|
+
if (kind === "reverse_snapshot")
|
|
66949
|
+
s.reverse_snapshot = true;
|
|
66950
|
+
if (kind === "formatter" && (SSOT_PATH_RE.test(cmd) || /openapi|swagger|asyncapi|\.graphql|\.gql|mcp\.json|schema/i.test(cmd)))
|
|
66951
|
+
s.formatter_only_ssot = true;
|
|
66952
|
+
}
|
|
66953
|
+
for (const p of paths) {
|
|
66954
|
+
const pc = pathClass(p);
|
|
66955
|
+
const isScratch = pc === "scratch" || NON_SSOT_RE.test(p) || PIPELINE_SCRATCH_RE.test(p);
|
|
66956
|
+
if (isScratch) {
|
|
66957
|
+
pushUniq(s.scratch_writes, p);
|
|
66958
|
+
if (CONTRACT_CONTENT_RE.test(content) || STAGING_NAME_RE.test(p + content))
|
|
66959
|
+
pushUniq(s.contract_looking_scratch, p);
|
|
66960
|
+
if (PIPELINE_SCRATCH_RE.test(p))
|
|
66961
|
+
pushUniq(s.intermediate_artifacts, p);
|
|
66962
|
+
if (isEncodedFragment(p, content) || /\.b64$/i.test(p) || /enc\//i.test(p) || /pkg\.part/i.test(p))
|
|
66963
|
+
pushUniq(s.encoded_fragments, p);
|
|
66964
|
+
if (/field-map|flags\.json|optional_fields|required_fields|\.idl$/i.test(p))
|
|
66965
|
+
pushUniq(s.intermediate_artifacts, p);
|
|
66966
|
+
}
|
|
66967
|
+
if (pc === "ssot" && !(tool === "Bash" && /prettier/i.test(typeof args.command === "string" ? args.command : "")))
|
|
66968
|
+
pushUniq(s.ssot_paths_touched, p);
|
|
66969
|
+
if (/field-map/i.test(p)) {
|
|
66970
|
+
let obj;
|
|
66971
|
+
try {
|
|
66972
|
+
obj = JSON.parse(content);
|
|
66973
|
+
} catch {
|
|
66974
|
+
obj = null;
|
|
66975
|
+
}
|
|
66976
|
+
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
66977
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
66978
|
+
if (k === "__drop" && Array.isArray(v)) {
|
|
66979
|
+
for (const d of v)
|
|
66980
|
+
s.pending_renames.push({ drop: String(d) });
|
|
66981
|
+
} else if (typeof v === "string")
|
|
66982
|
+
s.pending_renames.push({ from: k, to: v });
|
|
66983
|
+
}
|
|
66984
|
+
}
|
|
66985
|
+
}
|
|
66986
|
+
if (/flags\.json/i.test(p)) {
|
|
66987
|
+
for (const m of content.matchAll(/"(\w+)":\s*"optional"/g))
|
|
66988
|
+
pushUniq(s.optional_fields_added, m[1]);
|
|
66989
|
+
for (const m of content.matchAll(/"(\w+)":\s*"required"/g))
|
|
66990
|
+
pushUniq(s.required_fields_declared, m[1]);
|
|
66991
|
+
}
|
|
66992
|
+
if (/optional_fields/i.test(p)) {
|
|
66993
|
+
for (const line of content.split("\n"))
|
|
66994
|
+
if (line.trim())
|
|
66995
|
+
pushUniq(s.optional_fields_added, line.trim());
|
|
66996
|
+
}
|
|
66997
|
+
if (/required_fields/i.test(p)) {
|
|
66998
|
+
for (const line of content.split("\n"))
|
|
66999
|
+
if (line.trim())
|
|
67000
|
+
pushUniq(s.required_fields_declared, line.trim());
|
|
67001
|
+
}
|
|
67002
|
+
if (NON_SSOT_RE.test(p) && /required:\s*\[[^\]]*owner_id/.test(content))
|
|
67003
|
+
pushUniq(s.required_fields_declared, "owner_id");
|
|
67004
|
+
if (NON_SSOT_RE.test(p) && /owner_id:\s*\{type: string\}/.test(content))
|
|
67005
|
+
pushUniq(s.optional_fields_added, "owner_id");
|
|
67006
|
+
if (/\.idl$/i.test(p) || p.startsWith("idl/"))
|
|
67007
|
+
pushUniq(s.intermediate_artifacts, p);
|
|
67008
|
+
}
|
|
67009
|
+
if (/BREAKING_DROP|FIELD .* REMOVE|MANDATORY/i.test(content))
|
|
67010
|
+
pushUniq(s.intermediate_artifacts, paths[0] || "inline_flag");
|
|
67011
|
+
s.tainted = computeTainted(s);
|
|
67012
|
+
return s;
|
|
67013
|
+
}
|
|
67014
|
+
function computeTainted(s) {
|
|
67015
|
+
return s.contract_looking_scratch.length > 0 || s.encoded_fragments.length > 0 || s.intermediate_artifacts.length > 0 || s.store_keys.some((k) => /spec_|api_|schema|openapi/i.test(k)) || s.pending_renames.length > 0 || s.optional_fields_added.some((f) => s.required_fields_declared.includes(f)) || s.required_fields_declared.length > 0 && s.optional_fields_added.length > 0 || s.ssot_invalidated === true;
|
|
67016
|
+
}
|
|
67017
|
+
function deriveKeySignal(s) {
|
|
67018
|
+
if (s.ssot_invalidated)
|
|
67019
|
+
return "delete_recreate_ssot_via_session";
|
|
67020
|
+
if (s.encoded_fragments.length)
|
|
67021
|
+
return "encoded_scratch_then_ssot_promotion";
|
|
67022
|
+
if (s.optional_fields_added.some((f) => s.required_fields_declared.includes(f)) || s.required_fields_declared.length && s.optional_fields_added.length)
|
|
67023
|
+
return "cumulative_required_flip";
|
|
67024
|
+
if (s.pending_renames.length)
|
|
67025
|
+
return "cumulative_rename_via_codegen";
|
|
67026
|
+
if (s.contract_looking_scratch.length)
|
|
67027
|
+
return "scratch_to_ssot_promotion";
|
|
67028
|
+
if (s.intermediate_artifacts.length)
|
|
67029
|
+
return "cross_call_reassembly_to_ssot";
|
|
67030
|
+
return "session_ssot_sink_with_taint";
|
|
67031
|
+
}
|
|
67032
|
+
function evaluate(state, prevFlagged = false, opts = {}) {
|
|
67033
|
+
const sink = state.ssot_sink_events.length > 0 || opts.sinkSeen === true;
|
|
67034
|
+
const taint = state.tainted || opts.overflow === true;
|
|
67035
|
+
const flag = sink && taint;
|
|
67036
|
+
return { flag, trip: flag && !prevFlagged, key_signal: flag ? deriveKeySignal(state) : null };
|
|
67037
|
+
}
|
|
67038
|
+
var DEF = { maxCalls: 256, maxPathsTracked: 512, maxSinkEvents: 64, maxStateBytes: 256e3, ttlMs: 36e5 };
|
|
67039
|
+
var SessionTaintTracker = class {
|
|
67040
|
+
version = exports2.SESSION_TAINT_VERSION;
|
|
67041
|
+
state = emptySessionState();
|
|
67042
|
+
prevFlag = false;
|
|
67043
|
+
callCount = 0;
|
|
67044
|
+
overflow = false;
|
|
67045
|
+
sinkSeen = false;
|
|
67046
|
+
lastObserveAt = 0;
|
|
67047
|
+
cfg;
|
|
67048
|
+
constructor(config = {}) {
|
|
67049
|
+
this.cfg = config;
|
|
67050
|
+
}
|
|
67051
|
+
pathTotal() {
|
|
67052
|
+
const s = this.state;
|
|
67053
|
+
return s.scratch_writes.length + s.contract_looking_scratch.length + s.encoded_fragments.length + s.intermediate_artifacts.length + s.ssot_paths_touched.length;
|
|
67054
|
+
}
|
|
67055
|
+
observe(call) {
|
|
67056
|
+
const now = this.now();
|
|
67057
|
+
if (this.lastObserveAt && now - this.lastObserveAt > (this.cfg.ttlMs ?? DEF.ttlMs))
|
|
67058
|
+
this.reset();
|
|
67059
|
+
this.lastObserveAt = now;
|
|
67060
|
+
const next = updateSession(this.state, call, this.cfg);
|
|
67061
|
+
this.callCount++;
|
|
67062
|
+
if (this.callCount > (this.cfg.maxCalls ?? DEF.maxCalls))
|
|
67063
|
+
this.overflow = true;
|
|
67064
|
+
if (this.pathTotal() > (this.cfg.maxPathsTracked ?? DEF.maxPathsTracked))
|
|
67065
|
+
this.overflow = true;
|
|
67066
|
+
if (JSON.stringify(next).length > (this.cfg.maxStateBytes ?? DEF.maxStateBytes))
|
|
67067
|
+
this.overflow = true;
|
|
67068
|
+
if (next.ssot_sink_events.length > (this.cfg.maxSinkEvents ?? DEF.maxSinkEvents)) {
|
|
67069
|
+
next.ssot_sink_events = next.ssot_sink_events.slice(0, this.cfg.maxSinkEvents ?? DEF.maxSinkEvents);
|
|
67070
|
+
}
|
|
67071
|
+
this.state = next;
|
|
67072
|
+
if (this.state.ssot_sink_events.length > 0)
|
|
67073
|
+
this.sinkSeen = true;
|
|
67074
|
+
return this.snapshot();
|
|
67075
|
+
}
|
|
67076
|
+
status() {
|
|
67077
|
+
return this.snapshot();
|
|
67078
|
+
}
|
|
67079
|
+
reset() {
|
|
67080
|
+
this.state = emptySessionState();
|
|
67081
|
+
this.prevFlag = false;
|
|
67082
|
+
this.callCount = 0;
|
|
67083
|
+
this.overflow = false;
|
|
67084
|
+
this.sinkSeen = false;
|
|
67085
|
+
this.lastObserveAt = 0;
|
|
67086
|
+
}
|
|
67087
|
+
snapshot() {
|
|
67088
|
+
const eva = evaluate(this.state, this.prevFlag, { overflow: this.overflow, sinkSeen: this.sinkSeen });
|
|
67089
|
+
if (eva.flag)
|
|
67090
|
+
this.prevFlag = true;
|
|
67091
|
+
return {
|
|
67092
|
+
flag: eva.flag,
|
|
67093
|
+
trip: eva.trip,
|
|
67094
|
+
key_signal: eva.key_signal,
|
|
67095
|
+
state: projectState(this.state),
|
|
67096
|
+
version: exports2.SESSION_TAINT_VERSION,
|
|
67097
|
+
overflow: this.overflow,
|
|
67098
|
+
severity: this.cfg.sessionTaintSeverity || "caution"
|
|
67099
|
+
};
|
|
67100
|
+
}
|
|
67101
|
+
// Date.now is fine at runtime; isolated for testability.
|
|
67102
|
+
now() {
|
|
67103
|
+
return Date.now();
|
|
67104
|
+
}
|
|
67105
|
+
};
|
|
67106
|
+
exports2.SessionTaintTracker = SessionTaintTracker;
|
|
67107
|
+
}
|
|
67108
|
+
});
|
|
67109
|
+
|
|
67110
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/resolver-yaml.js
|
|
67111
|
+
var require_resolver_yaml = __commonJS({
|
|
67112
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/resolver-yaml.js"(exports2) {
|
|
67113
|
+
"use strict";
|
|
67114
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
67115
|
+
exports2.YamlLiteError = void 0;
|
|
67116
|
+
exports2.parseDoc = parseDoc;
|
|
67117
|
+
exports2.stableStringify = stableStringify;
|
|
67118
|
+
var YamlLiteError = class extends Error {
|
|
67119
|
+
constructor(message) {
|
|
67120
|
+
super(message);
|
|
67121
|
+
this.name = "YamlLiteError";
|
|
67122
|
+
}
|
|
67123
|
+
};
|
|
67124
|
+
exports2.YamlLiteError = YamlLiteError;
|
|
67125
|
+
function parseDoc(text) {
|
|
67126
|
+
const trimmed = text.trimStart();
|
|
67127
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
67128
|
+
try {
|
|
67129
|
+
return JSON.parse(text);
|
|
67130
|
+
} catch (e) {
|
|
67131
|
+
throw new YamlLiteError(`invalid JSON: ${e.message}`);
|
|
67132
|
+
}
|
|
67133
|
+
}
|
|
67134
|
+
const lines = [];
|
|
67135
|
+
for (const raw of text.split("\n")) {
|
|
67136
|
+
const trimmedLine = raw.trim();
|
|
67137
|
+
if (trimmedLine === "" || trimmedLine.startsWith("#"))
|
|
67138
|
+
continue;
|
|
67139
|
+
lines.push({ indent: raw.length - raw.trimStart().length, text: trimmedLine });
|
|
67140
|
+
}
|
|
67141
|
+
if (lines.length === 0)
|
|
67142
|
+
return null;
|
|
67143
|
+
const [value] = parseBlock(lines, 0, lines[0].indent);
|
|
67144
|
+
return value;
|
|
67145
|
+
}
|
|
67146
|
+
function parseBlock(lines, start, indent) {
|
|
67147
|
+
if (start >= lines.length)
|
|
67148
|
+
return [null, start];
|
|
67149
|
+
const first = lines[start];
|
|
67150
|
+
if (first.text === "-" || first.text.startsWith("- "))
|
|
67151
|
+
return parseSequence(lines, start, indent);
|
|
67152
|
+
return parseMapping(lines, start, indent);
|
|
67153
|
+
}
|
|
67154
|
+
function parseMapping(lines, start, indent) {
|
|
67155
|
+
const obj = {};
|
|
67156
|
+
let i = start;
|
|
67157
|
+
while (i < lines.length && lines[i].indent === indent) {
|
|
67158
|
+
const { key, rest } = splitKeyValue(lines[i].text);
|
|
67159
|
+
i += 1;
|
|
67160
|
+
if (rest === "") {
|
|
67161
|
+
if (i < lines.length && lines[i].indent > indent) {
|
|
67162
|
+
const [child, next] = parseBlock(lines, i, lines[i].indent);
|
|
67163
|
+
obj[key] = child;
|
|
67164
|
+
i = next;
|
|
67165
|
+
} else {
|
|
67166
|
+
obj[key] = null;
|
|
67167
|
+
}
|
|
67168
|
+
} else {
|
|
67169
|
+
obj[key] = parseScalarOrFlow(rest);
|
|
67170
|
+
}
|
|
67171
|
+
}
|
|
67172
|
+
return [obj, i];
|
|
67173
|
+
}
|
|
67174
|
+
function parseSequence(lines, start, indent) {
|
|
67175
|
+
const arr = [];
|
|
67176
|
+
let i = start;
|
|
67177
|
+
while (i < lines.length && lines[i].indent === indent && (lines[i].text === "-" || lines[i].text.startsWith("- "))) {
|
|
67178
|
+
const itemText = lines[i].text.slice(1).trim();
|
|
67179
|
+
i += 1;
|
|
67180
|
+
if (itemText === "") {
|
|
67181
|
+
if (i < lines.length && lines[i].indent > indent) {
|
|
67182
|
+
const [child, next] = parseBlock(lines, i, lines[i].indent);
|
|
67183
|
+
arr.push(child);
|
|
67184
|
+
i = next;
|
|
67185
|
+
} else {
|
|
67186
|
+
arr.push(null);
|
|
67187
|
+
}
|
|
67188
|
+
} else {
|
|
67189
|
+
arr.push(parseScalarOrFlow(itemText));
|
|
67190
|
+
}
|
|
67191
|
+
}
|
|
67192
|
+
return [arr, i];
|
|
67193
|
+
}
|
|
67194
|
+
function splitKeyValue(text) {
|
|
67195
|
+
let key;
|
|
67196
|
+
let idx;
|
|
67197
|
+
if (text[0] === "'" || text[0] === '"') {
|
|
67198
|
+
const q = text[0];
|
|
67199
|
+
let j = 1;
|
|
67200
|
+
while (j < text.length && text[j] !== q)
|
|
67201
|
+
j += 1;
|
|
67202
|
+
key = text.slice(1, j);
|
|
67203
|
+
idx = text.indexOf(":", j);
|
|
67204
|
+
} else {
|
|
67205
|
+
idx = text.indexOf(":");
|
|
67206
|
+
key = idx === -1 ? text : text.slice(0, idx);
|
|
67207
|
+
}
|
|
67208
|
+
if (idx === -1)
|
|
67209
|
+
return { key: key.trim(), rest: "" };
|
|
67210
|
+
return { key: key.trim(), rest: text.slice(idx + 1).trim() };
|
|
67211
|
+
}
|
|
67212
|
+
function parseScalarOrFlow(s) {
|
|
67213
|
+
const t = s.trim();
|
|
67214
|
+
if (t === "" || t === "~" || t === "null")
|
|
67215
|
+
return null;
|
|
67216
|
+
if (t[0] === "{" || t[0] === "[")
|
|
67217
|
+
return parseFlow(t).value;
|
|
67218
|
+
if (t[0] === "'" || t[0] === '"')
|
|
67219
|
+
return unquote(t);
|
|
67220
|
+
return t;
|
|
67221
|
+
}
|
|
67222
|
+
function unquote(t) {
|
|
67223
|
+
const q = t[0];
|
|
67224
|
+
let j = 1;
|
|
67225
|
+
let out = "";
|
|
67226
|
+
while (j < t.length && t[j] !== q) {
|
|
67227
|
+
out += t[j];
|
|
67228
|
+
j += 1;
|
|
67229
|
+
}
|
|
67230
|
+
return out;
|
|
67231
|
+
}
|
|
67232
|
+
function parseFlow(s) {
|
|
67233
|
+
if (s[0] === "{")
|
|
67234
|
+
return parseFlowMap(s);
|
|
67235
|
+
if (s[0] === "[")
|
|
67236
|
+
return parseFlowSeq(s);
|
|
67237
|
+
throw new YamlLiteError(`not a flow collection: ${s.slice(0, 20)}`);
|
|
67238
|
+
}
|
|
67239
|
+
function parseFlowMap(s) {
|
|
67240
|
+
const obj = {};
|
|
67241
|
+
let i = 1;
|
|
67242
|
+
while (i < s.length) {
|
|
67243
|
+
while (i < s.length && (s[i] === " " || s[i] === ","))
|
|
67244
|
+
i += 1;
|
|
67245
|
+
if (s[i] === "}")
|
|
67246
|
+
return { value: obj, end: i + 1 };
|
|
67247
|
+
let key;
|
|
67248
|
+
if (s[i] === "'" || s[i] === '"') {
|
|
67249
|
+
const q = s[i];
|
|
67250
|
+
let j = i + 1;
|
|
67251
|
+
let k = "";
|
|
67252
|
+
while (j < s.length && s[j] !== q) {
|
|
67253
|
+
k += s[j];
|
|
67254
|
+
j += 1;
|
|
67255
|
+
}
|
|
67256
|
+
key = k;
|
|
67257
|
+
i = j + 1;
|
|
67258
|
+
} else {
|
|
67259
|
+
let k = "";
|
|
67260
|
+
while (i < s.length && s[i] !== ":" && s[i] !== "}" && s[i] !== ",") {
|
|
67261
|
+
k += s[i];
|
|
67262
|
+
i += 1;
|
|
67263
|
+
}
|
|
67264
|
+
key = k.trim();
|
|
67265
|
+
}
|
|
67266
|
+
while (i < s.length && (s[i] === " " || s[i] === ":"))
|
|
67267
|
+
i += 1;
|
|
67268
|
+
const [val, next] = readFlowValue(s, i);
|
|
67269
|
+
obj[key] = val;
|
|
67270
|
+
i = next;
|
|
67271
|
+
}
|
|
67272
|
+
throw new YamlLiteError(`unterminated flow map: ${s.slice(0, 40)}`);
|
|
67273
|
+
}
|
|
67274
|
+
function parseFlowSeq(s) {
|
|
67275
|
+
const arr = [];
|
|
67276
|
+
let i = 1;
|
|
67277
|
+
while (i < s.length) {
|
|
67278
|
+
while (i < s.length && (s[i] === " " || s[i] === ","))
|
|
67279
|
+
i += 1;
|
|
67280
|
+
if (s[i] === "]")
|
|
67281
|
+
return { value: arr, end: i + 1 };
|
|
67282
|
+
const [val, next] = readFlowValue(s, i);
|
|
67283
|
+
arr.push(val);
|
|
67284
|
+
i = next;
|
|
67285
|
+
}
|
|
67286
|
+
throw new YamlLiteError(`unterminated flow seq: ${s.slice(0, 40)}`);
|
|
67287
|
+
}
|
|
67288
|
+
function readFlowValue(s, start) {
|
|
67289
|
+
let i = start;
|
|
67290
|
+
while (i < s.length && s[i] === " ")
|
|
67291
|
+
i += 1;
|
|
67292
|
+
if (s[i] === "{" || s[i] === "[") {
|
|
67293
|
+
const { value, end } = parseFlow(s.slice(i));
|
|
67294
|
+
return [value, i + end];
|
|
67295
|
+
}
|
|
67296
|
+
if (s[i] === "'" || s[i] === '"') {
|
|
67297
|
+
const q = s[i];
|
|
67298
|
+
let j = i + 1;
|
|
67299
|
+
let out2 = "";
|
|
67300
|
+
while (j < s.length && s[j] !== q) {
|
|
67301
|
+
out2 += s[j];
|
|
67302
|
+
j += 1;
|
|
67303
|
+
}
|
|
67304
|
+
return [out2, j + 1];
|
|
67305
|
+
}
|
|
67306
|
+
let out = "";
|
|
67307
|
+
while (i < s.length && s[i] !== "," && s[i] !== "}" && s[i] !== "]") {
|
|
67308
|
+
out += s[i];
|
|
67309
|
+
i += 1;
|
|
67310
|
+
}
|
|
67311
|
+
return [out.trim(), i];
|
|
67312
|
+
}
|
|
67313
|
+
function stableStringify(value) {
|
|
67314
|
+
return JSON.stringify(sortKeys(value));
|
|
67315
|
+
}
|
|
67316
|
+
function sortKeys(value) {
|
|
67317
|
+
if (Array.isArray(value))
|
|
67318
|
+
return value.map(sortKeys);
|
|
67319
|
+
if (value && typeof value === "object") {
|
|
67320
|
+
const out = {};
|
|
67321
|
+
for (const k of Object.keys(value).sort()) {
|
|
67322
|
+
out[k] = sortKeys(value[k]);
|
|
67323
|
+
}
|
|
67324
|
+
return out;
|
|
67325
|
+
}
|
|
67326
|
+
return value;
|
|
67327
|
+
}
|
|
67328
|
+
}
|
|
67329
|
+
});
|
|
67330
|
+
|
|
67331
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/resolver-glob.js
|
|
67332
|
+
var require_resolver_glob = __commonJS({
|
|
67333
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/resolver-glob.js"(exports2) {
|
|
67334
|
+
"use strict";
|
|
67335
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
67336
|
+
exports2.globToRegExp = globToRegExp;
|
|
67337
|
+
exports2.matchGlob = matchGlob;
|
|
67338
|
+
exports2.matchAny = matchAny;
|
|
67339
|
+
exports2.firstMatchIndex = firstMatchIndex;
|
|
67340
|
+
function globToRegExp(glob) {
|
|
67341
|
+
let re = "";
|
|
67342
|
+
for (let i = 0; i < glob.length; i += 1) {
|
|
67343
|
+
const c = glob[i];
|
|
67344
|
+
if (c === "*") {
|
|
67345
|
+
if (glob[i + 1] === "*") {
|
|
67346
|
+
i += 1;
|
|
67347
|
+
if (glob[i + 1] === "/") {
|
|
67348
|
+
re += "(?:.*/)?";
|
|
67349
|
+
i += 1;
|
|
67350
|
+
} else {
|
|
67351
|
+
re += ".*";
|
|
67352
|
+
}
|
|
67353
|
+
} else {
|
|
67354
|
+
re += "[^/]*";
|
|
67355
|
+
}
|
|
67356
|
+
} else if (c === "?") {
|
|
67357
|
+
re += "[^/]";
|
|
67358
|
+
} else if (".+^${}()|[]\\".includes(c)) {
|
|
67359
|
+
re += `\\${c}`;
|
|
67360
|
+
} else {
|
|
67361
|
+
re += c;
|
|
67362
|
+
}
|
|
67363
|
+
}
|
|
67364
|
+
return new RegExp(`^${re}$`);
|
|
67365
|
+
}
|
|
67366
|
+
function matchGlob(glob, path) {
|
|
67367
|
+
return globToRegExp(glob).test(path);
|
|
67368
|
+
}
|
|
67369
|
+
function matchAny(globs, path) {
|
|
67370
|
+
if (!Array.isArray(globs))
|
|
67371
|
+
return false;
|
|
67372
|
+
return globs.some((g) => g === path || matchGlob(g, path));
|
|
67373
|
+
}
|
|
67374
|
+
function firstMatchIndex(globs, path) {
|
|
67375
|
+
if (!Array.isArray(globs))
|
|
67376
|
+
return -1;
|
|
67377
|
+
for (let i = 0; i < globs.length; i += 1) {
|
|
67378
|
+
if (globs[i] === path || matchGlob(globs[i], path))
|
|
67379
|
+
return i;
|
|
67380
|
+
}
|
|
67381
|
+
return -1;
|
|
67382
|
+
}
|
|
67383
|
+
}
|
|
67384
|
+
});
|
|
67385
|
+
|
|
67386
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/artifact-resolver.js
|
|
67387
|
+
var require_artifact_resolver = __commonJS({
|
|
67388
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/artifact-resolver.js"(exports2) {
|
|
67389
|
+
"use strict";
|
|
67390
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
67391
|
+
exports2.resolve = resolve;
|
|
67392
|
+
var resolver_yaml_js_1 = require_resolver_yaml();
|
|
67393
|
+
var resolver_glob_js_1 = require_resolver_glob();
|
|
67394
|
+
var DEFAULT_GENERATED = ["**/generated/**", "**/gen/**"];
|
|
67395
|
+
var VENDOR_GLOBS = ["**/node_modules/**", "**/vendor/**"];
|
|
67396
|
+
function normalizePath(p) {
|
|
67397
|
+
let s = p.replace(/\\/g, "/").trim();
|
|
67398
|
+
while (s.startsWith("./"))
|
|
67399
|
+
s = s.slice(2);
|
|
67400
|
+
return s;
|
|
67401
|
+
}
|
|
67402
|
+
function dirname(p) {
|
|
67403
|
+
const i = p.lastIndexOf("/");
|
|
67404
|
+
return i === -1 ? "" : p.slice(0, i);
|
|
67405
|
+
}
|
|
67406
|
+
function basename(p) {
|
|
67407
|
+
const i = p.lastIndexOf("/");
|
|
67408
|
+
return i === -1 ? p : p.slice(i + 1);
|
|
67409
|
+
}
|
|
67410
|
+
function extname(p) {
|
|
67411
|
+
const b = basename(p);
|
|
67412
|
+
const i = b.lastIndexOf(".");
|
|
67413
|
+
return i === -1 ? "" : b.slice(i + 1).toLowerCase();
|
|
67414
|
+
}
|
|
67415
|
+
function resolveRelative(dir, rel) {
|
|
67416
|
+
const parts = (dir ? dir.split("/") : []).concat(normalizePath(rel).split("/"));
|
|
67417
|
+
const out = [];
|
|
67418
|
+
for (const seg of parts) {
|
|
67419
|
+
if (seg === "" || seg === ".")
|
|
67420
|
+
continue;
|
|
67421
|
+
if (seg === "..")
|
|
67422
|
+
out.pop();
|
|
67423
|
+
else
|
|
67424
|
+
out.push(seg);
|
|
67425
|
+
}
|
|
67426
|
+
return out.join("/");
|
|
67427
|
+
}
|
|
67428
|
+
function classifyByName(path) {
|
|
67429
|
+
const b = basename(path).toLowerCase();
|
|
67430
|
+
const ext = extname(path);
|
|
67431
|
+
const yamlJson = ext === "yaml" || ext === "yml" || ext === "json";
|
|
67432
|
+
if (yamlJson && (b.includes("openapi") || b.includes("swagger")))
|
|
67433
|
+
return "openapi";
|
|
67434
|
+
if (yamlJson && b.includes("asyncapi"))
|
|
67435
|
+
return "asyncapi";
|
|
67436
|
+
if (ext === "graphql" || ext === "gql")
|
|
67437
|
+
return "graphql";
|
|
67438
|
+
if (ext === "proto")
|
|
67439
|
+
return "grpc";
|
|
67440
|
+
if (b === "mcp.json" || b === "tools-catalog.json")
|
|
67441
|
+
return "mcp_manifest";
|
|
67442
|
+
return null;
|
|
67443
|
+
}
|
|
67444
|
+
function classifyByContent(text) {
|
|
67445
|
+
if (!text)
|
|
67446
|
+
return null;
|
|
67447
|
+
if (/(^|\n)\s*["']?openapi["']?\s*:\s*["']?[23]/.test(text) || /swagger\s*:/.test(text) && /paths\s*:/.test(text))
|
|
67448
|
+
return "openapi";
|
|
67449
|
+
if (/(^|\n)\s*["']?asyncapi["']?\s*:/.test(text))
|
|
67450
|
+
return "asyncapi";
|
|
67451
|
+
if (/\btype\s+Query\b|\btype\s+Mutation\b|\bschema\s*\{/.test(text))
|
|
67452
|
+
return "graphql";
|
|
67453
|
+
if (/syntax\s*=\s*["']proto[23]["']/.test(text))
|
|
67454
|
+
return "grpc";
|
|
67455
|
+
try {
|
|
67456
|
+
const j = JSON.parse(text);
|
|
67457
|
+
if (j && Array.isArray(j.tools) && j.tools.some((t) => t && typeof t === "object" && "inputSchema" in t))
|
|
67458
|
+
return "mcp_manifest";
|
|
67459
|
+
} catch {
|
|
67460
|
+
}
|
|
67461
|
+
return null;
|
|
67462
|
+
}
|
|
67463
|
+
function isMcpByNameNeedingContent(path) {
|
|
67464
|
+
const b = basename(path).toLowerCase();
|
|
67465
|
+
return extname(path) === "json" && b.includes("mcp") && b !== "mcp.json";
|
|
67466
|
+
}
|
|
67467
|
+
var REF_RE = /\$ref["']?\s*:\s*["']?([^"'\s,}]+)["']?/g;
|
|
67468
|
+
function scanRefs(text) {
|
|
67469
|
+
const out = [];
|
|
67470
|
+
let m;
|
|
67471
|
+
REF_RE.lastIndex = 0;
|
|
67472
|
+
while ((m = REF_RE.exec(text)) !== null)
|
|
67473
|
+
out.push(m[1]);
|
|
67474
|
+
return out;
|
|
67475
|
+
}
|
|
67476
|
+
function isExternalRef(ref) {
|
|
67477
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(ref) || ref.startsWith("//");
|
|
67478
|
+
}
|
|
67479
|
+
function isInternalRef(ref) {
|
|
67480
|
+
return ref.startsWith("#");
|
|
67481
|
+
}
|
|
67482
|
+
function splitRef(ref) {
|
|
67483
|
+
const i = ref.indexOf("#");
|
|
67484
|
+
return i === -1 ? { file: ref, pointer: "" } : { file: ref.slice(0, i), pointer: ref.slice(i + 1) };
|
|
67485
|
+
}
|
|
67486
|
+
function jsonPointer(doc, pointer) {
|
|
67487
|
+
if (pointer === "" || pointer === "/")
|
|
67488
|
+
return doc;
|
|
67489
|
+
const parts = pointer.replace(/^\//, "").split("/").map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
67490
|
+
let cur = doc;
|
|
67491
|
+
for (const part of parts) {
|
|
67492
|
+
if (cur && typeof cur === "object" && part in cur)
|
|
67493
|
+
cur = cur[part];
|
|
67494
|
+
else
|
|
67495
|
+
return void 0;
|
|
67496
|
+
}
|
|
67497
|
+
return cur;
|
|
67498
|
+
}
|
|
67499
|
+
function slugify(s) {
|
|
67500
|
+
return s.replace(/[^A-Za-z0-9]+/g, "_");
|
|
67501
|
+
}
|
|
67502
|
+
var RefError = class extends Error {
|
|
67503
|
+
reason;
|
|
67504
|
+
related;
|
|
67505
|
+
constructor(reason, related) {
|
|
67506
|
+
super(reason);
|
|
67507
|
+
this.reason = reason;
|
|
67508
|
+
this.related = related;
|
|
67509
|
+
}
|
|
67510
|
+
};
|
|
67511
|
+
function assembleSide(rootPath, rootText, refSide, input, config, deps) {
|
|
67512
|
+
const maxDepth = config.maxRefDepth ?? 8;
|
|
67513
|
+
let root;
|
|
67514
|
+
try {
|
|
67515
|
+
root = (0, resolver_yaml_js_1.parseDoc)(rootText);
|
|
67516
|
+
} catch (e) {
|
|
67517
|
+
if (e instanceof resolver_yaml_js_1.YamlLiteError)
|
|
67518
|
+
throw new RefError("parse_error");
|
|
67519
|
+
throw e;
|
|
67520
|
+
}
|
|
67521
|
+
const components = {};
|
|
67522
|
+
const inline = (node, curDir, depth, stack) => {
|
|
67523
|
+
if (Array.isArray(node))
|
|
67524
|
+
return node.map((n) => inline(n, curDir, depth, stack));
|
|
67525
|
+
if (node && typeof node === "object") {
|
|
67526
|
+
const rec = node;
|
|
67527
|
+
if (typeof rec.$ref === "string") {
|
|
67528
|
+
const ref = rec.$ref;
|
|
67529
|
+
if (isExternalRef(ref))
|
|
67530
|
+
throw new RefError("external_ref_forbidden");
|
|
67531
|
+
if (isInternalRef(ref))
|
|
67532
|
+
return { ...rec };
|
|
67533
|
+
const { file, pointer } = splitRef(ref);
|
|
67534
|
+
const targetPath = resolveRelative(curDir, file);
|
|
67535
|
+
const key = `${targetPath}#${pointer}`;
|
|
67536
|
+
if (depth + 1 > maxDepth)
|
|
67537
|
+
throw new RefError("ref_depth_exceeded", targetPath);
|
|
67538
|
+
if (stack.has(key))
|
|
67539
|
+
throw new RefError("ref_cycle", targetPath);
|
|
67540
|
+
const blob = getBlob(input, refSide, targetPath);
|
|
67541
|
+
if (blob === null || blob === void 0)
|
|
67542
|
+
throw new RefError("missing_ref_target", targetPath);
|
|
67543
|
+
if (typeof blob === "object")
|
|
67544
|
+
throw new RefError(blob.error, targetPath);
|
|
67545
|
+
deps.add(targetPath);
|
|
67546
|
+
let targetDoc;
|
|
67547
|
+
try {
|
|
67548
|
+
targetDoc = (0, resolver_yaml_js_1.parseDoc)(blob);
|
|
67549
|
+
} catch {
|
|
67550
|
+
throw new RefError("parse_error", targetPath);
|
|
67551
|
+
}
|
|
67552
|
+
const resolved = jsonPointer(targetDoc, pointer);
|
|
67553
|
+
if (resolved === void 0)
|
|
67554
|
+
throw new RefError("missing_ref_target", targetPath);
|
|
67555
|
+
const inlined = inline(resolved, dirname(targetPath), depth + 1, /* @__PURE__ */ new Set([...stack, key]));
|
|
67556
|
+
const slug = slugify(`${targetPath}__${pointer}`);
|
|
67557
|
+
components[slug] = inlined;
|
|
67558
|
+
return { $ref: `#/components/${slug}` };
|
|
67559
|
+
}
|
|
67560
|
+
const out = {};
|
|
67561
|
+
for (const k of Object.keys(rec))
|
|
67562
|
+
out[k] = inline(rec[k], curDir, depth, stack);
|
|
67563
|
+
return out;
|
|
67564
|
+
}
|
|
67565
|
+
return node;
|
|
67566
|
+
};
|
|
67567
|
+
const inlinedRoot = inline(root, dirname(rootPath), 0, /* @__PURE__ */ new Set());
|
|
67568
|
+
if (Object.keys(components).length > 0) {
|
|
67569
|
+
const existing = inlinedRoot.components && typeof inlinedRoot.components === "object" ? inlinedRoot.components : {};
|
|
67570
|
+
inlinedRoot.components = { ...existing, ...components };
|
|
67571
|
+
}
|
|
67572
|
+
return (0, resolver_yaml_js_1.stableStringify)(inlinedRoot);
|
|
67573
|
+
}
|
|
67574
|
+
function getBlob(input, ref, path) {
|
|
67575
|
+
return input.blobs[`${ref}:${path}`];
|
|
67576
|
+
}
|
|
67577
|
+
function loadRoot(path, type, input, config) {
|
|
67578
|
+
const baseBlob = getBlob(input, input.baseRef, path);
|
|
67579
|
+
const headBlob = getBlob(input, input.headRef, path);
|
|
67580
|
+
if (baseBlob && typeof baseBlob === "object")
|
|
67581
|
+
return { unresolved: { path, reason: baseBlob.error } };
|
|
67582
|
+
if (headBlob && typeof headBlob === "object")
|
|
67583
|
+
return { unresolved: { path, reason: headBlob.error } };
|
|
67584
|
+
const baseNull = baseBlob === null || baseBlob === void 0;
|
|
67585
|
+
const headNull = headBlob === null || headBlob === void 0;
|
|
67586
|
+
if (baseNull && headNull)
|
|
67587
|
+
return { unresolved: { path, reason: "empty_changed_contract" } };
|
|
67588
|
+
let before = baseNull ? "" : baseBlob;
|
|
67589
|
+
let after = headNull ? "" : headBlob;
|
|
67590
|
+
const deps = /* @__PURE__ */ new Set();
|
|
67591
|
+
const assemble = (type === "openapi" || type === "asyncapi") && (config.openApiAssembly ?? "bundle_inline") === "bundle_inline";
|
|
67592
|
+
if (assemble) {
|
|
67593
|
+
try {
|
|
67594
|
+
if (before !== "" && scanRefs(before).some((r) => !isInternalRef(r)))
|
|
67595
|
+
before = assembleSide(path, before, input.baseRef, input, config, deps);
|
|
67596
|
+
if (after !== "" && scanRefs(after).some((r) => !isInternalRef(r)))
|
|
67597
|
+
after = assembleSide(path, after, input.headRef, input, config, deps);
|
|
67598
|
+
} catch (e) {
|
|
67599
|
+
if (e instanceof RefError)
|
|
67600
|
+
return { unresolved: { path, reason: e.reason, ...e.related ? { related_paths: [e.related] } : {} } };
|
|
67601
|
+
throw e;
|
|
67602
|
+
}
|
|
67603
|
+
}
|
|
67604
|
+
const id = input.repository ? `${input.repository}:${type}:${path}` : `${type}:${path}`;
|
|
67605
|
+
return { artifact: { id, type, before, after }, deps: [...deps] };
|
|
67606
|
+
}
|
|
67607
|
+
function selectGroups(candidates, config, generatedGlobs) {
|
|
67608
|
+
const n = candidates.length;
|
|
67609
|
+
const parent = Array.from({ length: n }, (_, i) => i);
|
|
67610
|
+
const find = (x) => {
|
|
67611
|
+
while (parent[x] !== x) {
|
|
67612
|
+
parent[x] = parent[parent[x]];
|
|
67613
|
+
x = parent[x];
|
|
67614
|
+
}
|
|
67615
|
+
return x;
|
|
67616
|
+
};
|
|
67617
|
+
const union = (a, b) => {
|
|
67618
|
+
const ra = find(a);
|
|
67619
|
+
const rb = find(b);
|
|
67620
|
+
if (ra !== rb)
|
|
67621
|
+
parent[Math.max(ra, rb)] = Math.min(ra, rb);
|
|
67622
|
+
};
|
|
67623
|
+
if (Array.isArray(config.forceSameSurfaceGroup)) {
|
|
67624
|
+
const idxs = candidates.map((c, i) => config.forceSameSurfaceGroup.includes(c.path) ? i : -1).filter((i) => i >= 0);
|
|
67625
|
+
for (let k = 1; k < idxs.length; k += 1)
|
|
67626
|
+
union(idxs[0], idxs[k]);
|
|
67627
|
+
}
|
|
67628
|
+
const byType = /* @__PURE__ */ new Map();
|
|
67629
|
+
candidates.forEach((c, i) => {
|
|
67630
|
+
const a = byType.get(c.type) ?? [];
|
|
67631
|
+
a.push(i);
|
|
67632
|
+
byType.set(c.type, a);
|
|
67633
|
+
});
|
|
67634
|
+
for (const idxs of byType.values()) {
|
|
67635
|
+
const gen = idxs.filter((i) => (0, resolver_glob_js_1.matchAny)(generatedGlobs, candidates[i].path));
|
|
67636
|
+
if (gen.length > 0 && gen.length < idxs.length)
|
|
67637
|
+
for (let k = 1; k < idxs.length; k += 1)
|
|
67638
|
+
union(idxs[0], idxs[k]);
|
|
67639
|
+
}
|
|
67640
|
+
const groups = /* @__PURE__ */ new Map();
|
|
67641
|
+
for (let i = 0; i < n; i += 1) {
|
|
67642
|
+
const r = find(i);
|
|
67643
|
+
const g = groups.get(r) ?? [];
|
|
67644
|
+
g.push(i);
|
|
67645
|
+
groups.set(r, g);
|
|
67646
|
+
}
|
|
67647
|
+
const selections = [];
|
|
67648
|
+
const chosen = [];
|
|
67649
|
+
const ambiguous = [];
|
|
67650
|
+
for (const g of groups.values()) {
|
|
67651
|
+
const members = g.map((i) => candidates[i].path).sort();
|
|
67652
|
+
if (members.length === 1) {
|
|
67653
|
+
chosen.push(candidates[g[0]]);
|
|
67654
|
+
selections.push({ chosen: members[0], deferred: [], reason: "single" });
|
|
67655
|
+
continue;
|
|
67656
|
+
}
|
|
67657
|
+
const prefRanked = members.map((p) => ({ p, rank: (0, resolver_glob_js_1.firstMatchIndex)(config.ssotPrefer, p) })).filter((x) => x.rank >= 0);
|
|
67658
|
+
if (prefRanked.length > 0) {
|
|
67659
|
+
prefRanked.sort((a, b) => a.rank - b.rank || (a.p < b.p ? -1 : 1));
|
|
67660
|
+
const chosenPath = prefRanked[0].p;
|
|
67661
|
+
chosen.push(candidates[g.find((i) => candidates[i].path === chosenPath)]);
|
|
67662
|
+
selections.push({ chosen: chosenPath, deferred: members.filter((m) => m !== chosenPath), reason: "ssotPrefer" });
|
|
67663
|
+
continue;
|
|
67664
|
+
}
|
|
67665
|
+
const nongen = members.filter((p) => !(0, resolver_glob_js_1.matchAny)(generatedGlobs, p));
|
|
67666
|
+
if (nongen.length === 1) {
|
|
67667
|
+
const chosenPath = nongen[0];
|
|
67668
|
+
chosen.push(candidates[g.find((i) => candidates[i].path === chosenPath)]);
|
|
67669
|
+
selections.push({ chosen: chosenPath, deferred: members.filter((m) => m !== chosenPath), reason: "generated_deprioritized" });
|
|
67670
|
+
continue;
|
|
67671
|
+
}
|
|
67672
|
+
ambiguous.push(...members);
|
|
67673
|
+
}
|
|
67674
|
+
return { selections, chosen, ambiguous };
|
|
67675
|
+
}
|
|
67676
|
+
function resolve(input, config = {}) {
|
|
67677
|
+
const generatedGlobs = config.generatedGlobs ?? DEFAULT_GENERATED;
|
|
67678
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67679
|
+
const paths = [];
|
|
67680
|
+
for (const raw of Array.isArray(input.changedFiles) ? input.changedFiles : []) {
|
|
67681
|
+
const p = normalizePath(raw);
|
|
67682
|
+
if (p && !seen.has(p)) {
|
|
67683
|
+
seen.add(p);
|
|
67684
|
+
paths.push(p);
|
|
67685
|
+
}
|
|
67686
|
+
}
|
|
67687
|
+
const candidates = [];
|
|
67688
|
+
const ignored = [];
|
|
67689
|
+
for (const p of paths) {
|
|
67690
|
+
if ((0, resolver_glob_js_1.matchAny)(VENDOR_GLOBS, p)) {
|
|
67691
|
+
ignored.push(p);
|
|
67692
|
+
continue;
|
|
67693
|
+
}
|
|
67694
|
+
let type = config.pathTypeHints?.[p] ?? classifyByName(p);
|
|
67695
|
+
if (type === null || isMcpByNameNeedingContent(p)) {
|
|
67696
|
+
const peek = firstDefinedText(getBlob(input, input.headRef, p), getBlob(input, input.baseRef, p));
|
|
67697
|
+
const sniff = classifyByContent(peek);
|
|
67698
|
+
if (isMcpByNameNeedingContent(p))
|
|
67699
|
+
type = sniff === "mcp_manifest" ? "mcp_manifest" : type ?? sniff;
|
|
67700
|
+
else
|
|
67701
|
+
type = sniff;
|
|
67702
|
+
}
|
|
67703
|
+
if (type)
|
|
67704
|
+
candidates.push({ path: p, type });
|
|
67705
|
+
else
|
|
67706
|
+
ignored.push(p);
|
|
67707
|
+
}
|
|
67708
|
+
const unresolved = [];
|
|
67709
|
+
let effectiveCandidates = candidates;
|
|
67710
|
+
if (config.requireSsotIfConfigured && Array.isArray(config.ssotPrefer)) {
|
|
67711
|
+
const missing = config.ssotPrefer.filter((pref) => !hasGlobChar(pref) && !existsInTree(input, pref));
|
|
67712
|
+
const hasGenerated = candidates.some((c) => (0, resolver_glob_js_1.matchAny)(generatedGlobs, c.path));
|
|
67713
|
+
if (missing.length > 0 && hasGenerated) {
|
|
67714
|
+
for (const pref of missing)
|
|
67715
|
+
unresolved.push({ path: pref, reason: "config_ssot_missing" });
|
|
67716
|
+
effectiveCandidates = candidates.filter((c) => !(0, resolver_glob_js_1.matchAny)(generatedGlobs, c.path));
|
|
67717
|
+
}
|
|
67718
|
+
}
|
|
67719
|
+
const { selections, chosen, ambiguous } = selectGroups(effectiveCandidates, config, generatedGlobs);
|
|
67720
|
+
for (const p of [...new Set(ambiguous)].sort())
|
|
67721
|
+
unresolved.push({ path: p, reason: "ambiguous_ssot" });
|
|
67722
|
+
const artifacts = [];
|
|
67723
|
+
const selBySel = new Map(selections.map((s) => [s.chosen, s]));
|
|
67724
|
+
for (const c of chosen.slice().sort((a, b) => a.path < b.path ? -1 : 1)) {
|
|
67725
|
+
const res = loadRoot(c.path, c.type, input, config);
|
|
67726
|
+
if ("artifact" in res) {
|
|
67727
|
+
artifacts.push(res.artifact);
|
|
67728
|
+
const sel = selBySel.get(c.path);
|
|
67729
|
+
for (const dep of res.deps) {
|
|
67730
|
+
const idx = ignored.indexOf(dep);
|
|
67731
|
+
if (idx >= 0)
|
|
67732
|
+
ignored.splice(idx, 1);
|
|
67733
|
+
if (sel && !sel.deferred.includes(dep) && dep !== c.path)
|
|
67734
|
+
sel.deferred.push(dep);
|
|
67735
|
+
}
|
|
67736
|
+
if (sel)
|
|
67737
|
+
sel.deferred.sort();
|
|
67738
|
+
} else {
|
|
67739
|
+
unresolved.push(res.unresolved);
|
|
67740
|
+
}
|
|
67741
|
+
}
|
|
67742
|
+
const A = artifacts.length;
|
|
67743
|
+
const U = unresolved.length;
|
|
67744
|
+
const chosenCount = chosen.length;
|
|
67745
|
+
let coverage;
|
|
67746
|
+
if (chosenCount === 0 && U === 0)
|
|
67747
|
+
coverage = "EMPTY";
|
|
67748
|
+
else if (U === 0 && A >= 1 && A === chosenCount)
|
|
67749
|
+
coverage = "COMPLETE";
|
|
67750
|
+
else if (A >= 1 && U >= 1)
|
|
67751
|
+
coverage = "PARTIAL";
|
|
67752
|
+
else
|
|
67753
|
+
coverage = "UNRESOLVED";
|
|
67754
|
+
artifacts.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
67755
|
+
unresolved.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.reason < b.reason ? -1 : a.reason > b.reason ? 1 : 0);
|
|
67756
|
+
ignored.sort();
|
|
67757
|
+
const contractDiscovered = effectiveCandidates.map((c) => c.path).slice().sort();
|
|
67758
|
+
return {
|
|
67759
|
+
artifacts,
|
|
67760
|
+
unresolved,
|
|
67761
|
+
coverage,
|
|
67762
|
+
report: {
|
|
67763
|
+
version: "artifact-resolver-report/1.0",
|
|
67764
|
+
baseRef: input.baseRef,
|
|
67765
|
+
headRef: input.headRef,
|
|
67766
|
+
contract_paths_discovered: contractDiscovered,
|
|
67767
|
+
ignored_non_contract: ignored,
|
|
67768
|
+
ssot_selections: selections,
|
|
67769
|
+
claim: {
|
|
67770
|
+
artifacts_ready_for_preflight: coverage === "COMPLETE" || coverage === "EMPTY",
|
|
67771
|
+
produces_verdict: false
|
|
67772
|
+
}
|
|
67773
|
+
}
|
|
67774
|
+
};
|
|
67775
|
+
}
|
|
67776
|
+
function firstDefinedText(...vals) {
|
|
67777
|
+
for (const v of vals)
|
|
67778
|
+
if (typeof v === "string")
|
|
67779
|
+
return v;
|
|
67780
|
+
return void 0;
|
|
67781
|
+
}
|
|
67782
|
+
function hasGlobChar(p) {
|
|
67783
|
+
return /[*?]/.test(p);
|
|
67784
|
+
}
|
|
67785
|
+
function existsInTree(input, path) {
|
|
67786
|
+
return typeof getBlob(input, input.baseRef, path) === "string" || typeof getBlob(input, input.headRef, path) === "string";
|
|
67787
|
+
}
|
|
67788
|
+
}
|
|
67789
|
+
});
|
|
67790
|
+
|
|
67791
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/tool-registry.js
|
|
67792
|
+
var require_tool_registry = __commonJS({
|
|
67793
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/tool-registry.js"(exports2) {
|
|
67794
|
+
"use strict";
|
|
67795
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
67796
|
+
exports2.RegistryConstructionError = void 0;
|
|
67797
|
+
exports2.guardToolRegistry = guardToolRegistry;
|
|
67798
|
+
var guard_js_1 = require_guard();
|
|
67799
|
+
var RegistryConstructionError = class extends Error {
|
|
67800
|
+
code;
|
|
67801
|
+
toolName;
|
|
67802
|
+
constructor(code, message, toolName) {
|
|
67803
|
+
super(message);
|
|
67804
|
+
this.name = "RegistryConstructionError";
|
|
67805
|
+
this.code = code;
|
|
67806
|
+
this.toolName = toolName;
|
|
67807
|
+
}
|
|
67808
|
+
};
|
|
67809
|
+
exports2.RegistryConstructionError = RegistryConstructionError;
|
|
67810
|
+
var MUTATING_GENERIC = ["write", "edit", "create", "update", "delete", "remove", "apply_patch", "applypatch", "str_replace", "notebook_edit", "multi_edit", "insert"];
|
|
67811
|
+
var MUTATING_SHELL = ["bash", "shell", "terminal", "run_command", "exec", "powershell"];
|
|
67812
|
+
var MUTATING_VCS = ["git_commit", "git_push", "git_merge", "commit", "push"];
|
|
67813
|
+
var MUTATING_DEPLOY = ["deploy", "kubectl_apply", "helm_upgrade", "release"];
|
|
67814
|
+
var MUTATING_PUBLISH = ["npm_publish", "publish_package", "twine_upload", "cargo_publish"];
|
|
67815
|
+
var MUTATING_SCHEMA = ["register_tools", "update_manifest", "mcp_register"];
|
|
67816
|
+
var READONLY = ["read", "grep", "glob", "search", "list", "ls", "cat", "get", "fetch", "web_search", "browser_navigate"];
|
|
67817
|
+
function isMutatingClass(cls) {
|
|
67818
|
+
return cls !== "readonly";
|
|
67819
|
+
}
|
|
67820
|
+
function matchesAny(hay, patterns) {
|
|
67821
|
+
return patterns.some((p) => hay.includes(p));
|
|
67822
|
+
}
|
|
67823
|
+
function heuristicClass(name) {
|
|
67824
|
+
const n = String(name || "").toLowerCase();
|
|
67825
|
+
if (matchesAny(n, MUTATING_SHELL))
|
|
67826
|
+
return "mutating_shell";
|
|
67827
|
+
if (matchesAny(n, MUTATING_VCS) || n.startsWith("git_"))
|
|
67828
|
+
return "mutating_vcs";
|
|
67829
|
+
if (matchesAny(n, MUTATING_DEPLOY))
|
|
67830
|
+
return "mutating_deploy";
|
|
67831
|
+
if (matchesAny(n, MUTATING_PUBLISH))
|
|
67832
|
+
return "mutating_publish";
|
|
67833
|
+
if (matchesAny(n, MUTATING_SCHEMA))
|
|
67834
|
+
return "mutating_schema";
|
|
67835
|
+
if (matchesAny(n, MUTATING_GENERIC))
|
|
67836
|
+
return "mutating";
|
|
67837
|
+
if (matchesAny(n, READONLY))
|
|
67838
|
+
return "readonly";
|
|
67839
|
+
return null;
|
|
67840
|
+
}
|
|
67841
|
+
function resolveClass(tool, config, unknownPolicy) {
|
|
67842
|
+
const classify = config.classify || {};
|
|
67843
|
+
if (Object.prototype.hasOwnProperty.call(classify, tool.name))
|
|
67844
|
+
return { cls: classify[tool.name], source: "classify" };
|
|
67845
|
+
if (tool.mutationClass)
|
|
67846
|
+
return { cls: tool.mutationClass, source: "mutationClass" };
|
|
67847
|
+
if (Array.isArray(config.forceReadonly) && config.forceReadonly.includes(tool.name))
|
|
67848
|
+
return { cls: "readonly", source: "forceReadonly" };
|
|
67849
|
+
const h = heuristicClass(tool.name);
|
|
67850
|
+
if (h)
|
|
67851
|
+
return { cls: h, source: "heuristic" };
|
|
67852
|
+
if (unknownPolicy === "reject") {
|
|
67853
|
+
throw new RegistryConstructionError("UNKNOWN_TOOL", `tool '${tool.name}' is unclassified and unknownToolPolicy='reject'`, tool.name);
|
|
67854
|
+
}
|
|
67855
|
+
return { cls: unknownPolicy === "readonly" ? "readonly" : "mutating", source: "unknown" };
|
|
67856
|
+
}
|
|
67857
|
+
function operationForClass(cls, name, guardOperation) {
|
|
67858
|
+
switch (cls) {
|
|
67859
|
+
case "mutating_shell":
|
|
67860
|
+
return "tool_call";
|
|
67861
|
+
case "mutating_vcs":
|
|
67862
|
+
return /merge/i.test(name) ? "merge" : "tool_call";
|
|
67863
|
+
case "mutating_deploy":
|
|
67864
|
+
return "deploy";
|
|
67865
|
+
case "mutating_publish":
|
|
67866
|
+
return "publish";
|
|
67867
|
+
case "mutating_schema":
|
|
67868
|
+
return "tool_call";
|
|
67869
|
+
case "mutating":
|
|
67870
|
+
default:
|
|
67871
|
+
return guardOperation ?? "tool_call";
|
|
67872
|
+
}
|
|
67873
|
+
}
|
|
67874
|
+
function defaultBinder(tool, args) {
|
|
67875
|
+
return { toolName: tool.name, arguments: args };
|
|
67876
|
+
}
|
|
67877
|
+
var RAW_EXECUTORS = /* @__PURE__ */ new WeakMap();
|
|
67878
|
+
function freezeTool(t) {
|
|
67879
|
+
Object.freeze(t._coderifts);
|
|
67880
|
+
return Object.freeze(t);
|
|
67881
|
+
}
|
|
67882
|
+
function passthroughProtected(tool, cls) {
|
|
67883
|
+
const rawExecute = tool.execute;
|
|
67884
|
+
const protectedTool = {
|
|
67885
|
+
name: tool.name,
|
|
67886
|
+
description: tool.description,
|
|
67887
|
+
inputSchema: tool.inputSchema,
|
|
67888
|
+
meta: tool.meta,
|
|
67889
|
+
execute: async (args) => rawExecute(args),
|
|
67890
|
+
// new function, not === rawExecute
|
|
67891
|
+
_coderifts: { guarded: false, mutationClass: cls }
|
|
67892
|
+
};
|
|
67893
|
+
RAW_EXECUTORS.set(protectedTool, rawExecute);
|
|
67894
|
+
return freezeTool(protectedTool);
|
|
67895
|
+
}
|
|
67896
|
+
function wrapWithGuard(tool, cls, config) {
|
|
67897
|
+
const rawExecute = tool.execute;
|
|
67898
|
+
const guardBase = config.guard;
|
|
67899
|
+
const operation = operationForClass(cls, tool.name, guardBase.operation);
|
|
67900
|
+
const guardCfg = { ...guardBase, operation };
|
|
67901
|
+
const binder = config.binders && config.binders[tool.name] || ((t, a) => defaultBinder(t, a));
|
|
67902
|
+
const protectedTool = {
|
|
67903
|
+
name: tool.name,
|
|
67904
|
+
description: tool.description,
|
|
67905
|
+
inputSchema: tool.inputSchema,
|
|
67906
|
+
meta: tool.meta,
|
|
67907
|
+
execute: async (args) => {
|
|
67908
|
+
const call = binder(tool, args, cls);
|
|
67909
|
+
return (0, guard_js_1.guardToolCall)(call, async (_envelope, redacted) => rawExecute(redacted ? redacted.arguments : args), guardCfg);
|
|
67910
|
+
},
|
|
67911
|
+
_coderifts: { guarded: true, mutationClass: cls, operation }
|
|
67912
|
+
};
|
|
67913
|
+
RAW_EXECUTORS.set(protectedTool, rawExecute);
|
|
67914
|
+
return freezeTool(protectedTool);
|
|
67915
|
+
}
|
|
67916
|
+
function guardToolRegistry(rawTools, config = {}) {
|
|
67917
|
+
const failHard = config.failOnUnguardedMutator !== false;
|
|
67918
|
+
const unknownPolicy = config.unknownToolPolicy ?? "mutating";
|
|
67919
|
+
const input = Array.isArray(rawTools) ? rawTools : [];
|
|
67920
|
+
for (const tool of input) {
|
|
67921
|
+
if (!tool || typeof tool.name !== "string" || tool.name.trim() === "") {
|
|
67922
|
+
throw new RegistryConstructionError("INVALID_TOOL", "a tool has a missing or empty name");
|
|
67923
|
+
}
|
|
67924
|
+
if (typeof tool.execute !== "function") {
|
|
67925
|
+
throw new RegistryConstructionError("INVALID_TOOL", `tool '${tool.name}' has no execute function`, tool.name);
|
|
67926
|
+
}
|
|
67927
|
+
}
|
|
67928
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67929
|
+
for (const tool of input) {
|
|
67930
|
+
if (seen.has(tool.name)) {
|
|
67931
|
+
throw new RegistryConstructionError("DUPLICATE_TOOL_NAME", `duplicate tool name '${tool.name}'`, tool.name);
|
|
67932
|
+
}
|
|
67933
|
+
seen.add(tool.name);
|
|
67934
|
+
}
|
|
67935
|
+
const sorted = input.slice().sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
67936
|
+
const guardedMutators = [];
|
|
67937
|
+
const readonlyPassthrough = [];
|
|
67938
|
+
const warnings = [];
|
|
67939
|
+
const staged = [];
|
|
67940
|
+
let anyForced = false;
|
|
67941
|
+
let anyUnknownReadonly = false;
|
|
67942
|
+
for (const tool of sorted) {
|
|
67943
|
+
const { cls, source } = resolveClass(tool, config, unknownPolicy);
|
|
67944
|
+
const forced = cls === "readonly" && (source === "classify" || source === "forceReadonly") && isMutating(heuristicClass(tool.name));
|
|
67945
|
+
if (forced) {
|
|
67946
|
+
anyForced = true;
|
|
67947
|
+
warnings.push(`force_readonly_on_mutator_heuristic:${tool.name}`);
|
|
67948
|
+
}
|
|
67949
|
+
if (source === "unknown" && cls === "readonly")
|
|
67950
|
+
anyUnknownReadonly = true;
|
|
67951
|
+
staged.push({ tool, cls, forced });
|
|
67952
|
+
}
|
|
67953
|
+
if (anyForced && failHard) {
|
|
67954
|
+
throw new RegistryConstructionError("FORCE_READONLY_MUTATOR", `forceReadonly/classify downgraded a heuristic mutator to readonly while failOnUnguardedMutator is true`);
|
|
67955
|
+
}
|
|
67956
|
+
const willWrap = staged.some((s) => isMutating(s.cls) && !s.forced);
|
|
67957
|
+
const validGuard = !!(config.guard && config.guard.client);
|
|
67958
|
+
if (willWrap && !validGuard) {
|
|
67959
|
+
throw new RegistryConstructionError("GUARD_CONFIG_INVALID", "a mutating tool is present but config.guard.client is missing/invalid");
|
|
67960
|
+
}
|
|
67961
|
+
const protectedTools = [];
|
|
67962
|
+
for (const { tool, cls, forced } of staged) {
|
|
67963
|
+
if (cls === "readonly") {
|
|
67964
|
+
readonlyPassthrough.push(tool.name);
|
|
67965
|
+
protectedTools.push(passthroughProtected(tool, "readonly"));
|
|
67966
|
+
} else {
|
|
67967
|
+
guardedMutators.push(tool.name);
|
|
67968
|
+
protectedTools.push(wrapWithGuard(tool, cls, config));
|
|
67969
|
+
}
|
|
67970
|
+
void forced;
|
|
67971
|
+
}
|
|
67972
|
+
for (const p of protectedTools) {
|
|
67973
|
+
if (isMutatingClass(p._coderifts.mutationClass) && p._coderifts.guarded !== true) {
|
|
67974
|
+
throw new RegistryConstructionError("GUARD_CONFIG_INVALID", `invariant violated: '${p.name}' is a mutator exposed without a guard`, p.name);
|
|
67975
|
+
}
|
|
67976
|
+
}
|
|
67977
|
+
const M = guardedMutators.length;
|
|
67978
|
+
const G = guardedMutators.length;
|
|
67979
|
+
let coverage;
|
|
67980
|
+
if (anyForced) {
|
|
67981
|
+
coverage = "BYPASSED";
|
|
67982
|
+
} else if (unknownPolicy === "readonly" && anyUnknownReadonly) {
|
|
67983
|
+
coverage = "PARTIAL";
|
|
67984
|
+
} else if (M === G) {
|
|
67985
|
+
coverage = "COMPLETE";
|
|
67986
|
+
} else {
|
|
67987
|
+
coverage = "PARTIAL";
|
|
67988
|
+
}
|
|
67989
|
+
if (unknownPolicy === "readonly" && anyUnknownReadonly && !warnings.includes("unknown_treated_as_readonly")) {
|
|
67990
|
+
warnings.push("unknown_treated_as_readonly");
|
|
67991
|
+
}
|
|
67992
|
+
const inescapableRuntime = coverage === "COMPLETE" && failHard;
|
|
67993
|
+
const report = {
|
|
67994
|
+
version: "guard-tool-registry-report/1.0",
|
|
67995
|
+
coverage,
|
|
67996
|
+
protected_tools: protectedTools.map((p) => p.name),
|
|
67997
|
+
guarded_mutators: guardedMutators.slice(),
|
|
67998
|
+
readonly_passthrough: readonlyPassthrough.slice(),
|
|
67999
|
+
unguarded_mutators: [],
|
|
68000
|
+
// strict impl: always [] (COMPLETE ⇒ [] by G4; forced tools are readonly)
|
|
68001
|
+
unknown_treated_as: unknownPolicy,
|
|
68002
|
+
claim: {
|
|
68003
|
+
inescapable_runtime: inescapableRuntime,
|
|
68004
|
+
inescapable_merge: false,
|
|
68005
|
+
inescapable_deploy: false
|
|
68006
|
+
},
|
|
68007
|
+
siblings: {
|
|
68008
|
+
merge_gate: "required_separate_#7",
|
|
68009
|
+
artifact_resolver: "sibling_#4"
|
|
68010
|
+
},
|
|
68011
|
+
warnings
|
|
68012
|
+
};
|
|
68013
|
+
Object.freeze(report.claim);
|
|
68014
|
+
Object.freeze(report.siblings);
|
|
68015
|
+
Object.freeze(report);
|
|
68016
|
+
return {
|
|
68017
|
+
tools: Object.freeze(protectedTools),
|
|
68018
|
+
coverage,
|
|
68019
|
+
report
|
|
68020
|
+
};
|
|
68021
|
+
}
|
|
68022
|
+
function isMutating(cls) {
|
|
68023
|
+
return cls != null && cls !== "readonly";
|
|
68024
|
+
}
|
|
68025
|
+
}
|
|
68026
|
+
});
|
|
68027
|
+
|
|
68028
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/merge-gate.js
|
|
68029
|
+
var require_merge_gate = __commonJS({
|
|
68030
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/merge-gate.js"(exports2) {
|
|
68031
|
+
"use strict";
|
|
68032
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
68033
|
+
exports2.gateDecision = gateDecision;
|
|
68034
|
+
function normSha(s) {
|
|
68035
|
+
return String(s == null ? "" : s).trim().toLowerCase();
|
|
68036
|
+
}
|
|
68037
|
+
function normOp(o) {
|
|
68038
|
+
return String(o == null ? "" : o).trim().toLowerCase();
|
|
68039
|
+
}
|
|
68040
|
+
function sameHead(a, b, allowPrefix) {
|
|
68041
|
+
const na = normSha(a);
|
|
68042
|
+
const nb = normSha(b);
|
|
68043
|
+
if (!na || !nb)
|
|
68044
|
+
return false;
|
|
68045
|
+
if (na === nb)
|
|
68046
|
+
return true;
|
|
68047
|
+
if (allowPrefix && na.length >= 7 && nb.length >= 7 && (na.startsWith(nb) || nb.startsWith(na)))
|
|
68048
|
+
return true;
|
|
68049
|
+
return false;
|
|
68050
|
+
}
|
|
68051
|
+
function isAllowClass(receipt, allowWarnMerge) {
|
|
68052
|
+
const dec = receipt.decision;
|
|
68053
|
+
const decisionOk = dec === "ALLOW" || dec === "WARN" && allowWarnMerge === true;
|
|
68054
|
+
if (!decisionOk)
|
|
68055
|
+
return false;
|
|
68056
|
+
const ea = receipt.execution_action;
|
|
68057
|
+
if (ea === void 0 || ea === null || ea === "")
|
|
68058
|
+
return true;
|
|
68059
|
+
return ea === "CONTINUE" || ea === "CONTINUE_WITH_MONITORING";
|
|
68060
|
+
}
|
|
68061
|
+
function targetMatches(targetId, repository) {
|
|
68062
|
+
const t = String(targetId).toLowerCase();
|
|
68063
|
+
const r = String(repository).toLowerCase();
|
|
68064
|
+
return t === r || t === `repo:${r}` || t.endsWith(`:${r}`) || t.endsWith(`/${r}`);
|
|
68065
|
+
}
|
|
68066
|
+
function gateDecision(input) {
|
|
68067
|
+
const rc = input.requiredContext || {};
|
|
68068
|
+
const protection = rc.protection || { enforcement: "UNKNOWN", admin_bypass_possible: true };
|
|
68069
|
+
const enforcement_state = protection.enforcement;
|
|
68070
|
+
const allowPending = input.allowPending ?? rc.allowPending ?? false;
|
|
68071
|
+
const allowWarnMerge = input.allowWarnMerge ?? rc.allowWarnMerge ?? false;
|
|
68072
|
+
const allowPrefix = input.allowPrefixCompare ?? rc.allowPrefixCompare ?? false;
|
|
68073
|
+
const receipt = input.receipt;
|
|
68074
|
+
const detail = {
|
|
68075
|
+
prHeadSha: normSha(input.prHeadSha),
|
|
68076
|
+
bound_head_sha: receipt ? normSha(receipt.bound_head_sha) : null,
|
|
68077
|
+
decision: receipt ? String(receipt.decision) : null
|
|
68078
|
+
};
|
|
68079
|
+
const fail = (state, reason) => ({
|
|
68080
|
+
merge_allowed: false,
|
|
68081
|
+
state,
|
|
68082
|
+
reason,
|
|
68083
|
+
enforcement_state,
|
|
68084
|
+
inescapable_merge: false,
|
|
68085
|
+
detail
|
|
68086
|
+
});
|
|
68087
|
+
if (!input.prHeadSha || String(input.prHeadSha).trim() === "") {
|
|
68088
|
+
return fail(allowPending ? "pending" : "failure", "inputs_incomplete");
|
|
68089
|
+
}
|
|
68090
|
+
if (receipt === null || receipt === void 0) {
|
|
68091
|
+
return fail(allowPending ? "pending" : "failure", "no_receipt");
|
|
68092
|
+
}
|
|
68093
|
+
if (receipt.currently_authorized !== true) {
|
|
68094
|
+
return fail("failure", "receipt_not_authorized");
|
|
68095
|
+
}
|
|
68096
|
+
const op = rc.operation ?? "merge";
|
|
68097
|
+
if (receipt.operation == null || normOp(receipt.operation) !== normOp(op)) {
|
|
68098
|
+
return fail("failure", "operation_mismatch");
|
|
68099
|
+
}
|
|
68100
|
+
if (!sameHead(receipt.bound_head_sha, input.prHeadSha, allowPrefix)) {
|
|
68101
|
+
return fail("failure", "stale_head");
|
|
68102
|
+
}
|
|
68103
|
+
if (rc.expected_fingerprint != null && receipt.verdict_fingerprint !== rc.expected_fingerprint) {
|
|
68104
|
+
return fail("failure", "fingerprint_mismatch");
|
|
68105
|
+
}
|
|
68106
|
+
if (rc.expected_body_hash != null && receipt.body_hash !== rc.expected_body_hash) {
|
|
68107
|
+
return fail("failure", "body_hash_mismatch");
|
|
68108
|
+
}
|
|
68109
|
+
if (rc.repository && receipt.target_id && !targetMatches(receipt.target_id, rc.repository)) {
|
|
68110
|
+
return fail("failure", "target_mismatch");
|
|
68111
|
+
}
|
|
68112
|
+
if (!isAllowClass(receipt, allowWarnMerge)) {
|
|
68113
|
+
return fail("failure", "decision_not_allow");
|
|
68114
|
+
}
|
|
68115
|
+
const inescapable_merge = enforcement_state === "ENFORCING" && protection.admin_bypass_possible === false;
|
|
68116
|
+
let residual;
|
|
68117
|
+
if (!inescapable_merge) {
|
|
68118
|
+
if (enforcement_state === "ENFORCING")
|
|
68119
|
+
residual = "admin_bypass_open";
|
|
68120
|
+
else if (enforcement_state === "ADVISORY")
|
|
68121
|
+
residual = "protection_advisory_only";
|
|
68122
|
+
else
|
|
68123
|
+
residual = "protection_not_configured";
|
|
68124
|
+
}
|
|
68125
|
+
return {
|
|
68126
|
+
merge_allowed: true,
|
|
68127
|
+
state: "success",
|
|
68128
|
+
reason: "allow_current_head",
|
|
68129
|
+
enforcement_state,
|
|
68130
|
+
inescapable_merge,
|
|
68131
|
+
...residual ? { residual } : {},
|
|
68132
|
+
detail
|
|
68133
|
+
};
|
|
68134
|
+
}
|
|
68135
|
+
}
|
|
68136
|
+
});
|
|
68137
|
+
|
|
68138
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/deploy-gate.js
|
|
68139
|
+
var require_deploy_gate = __commonJS({
|
|
68140
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/deploy-gate.js"(exports2) {
|
|
68141
|
+
"use strict";
|
|
68142
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
68143
|
+
exports2.deployGate = deployGate;
|
|
68144
|
+
function norm(s) {
|
|
68145
|
+
return String(s == null ? "" : s).trim().toLowerCase();
|
|
68146
|
+
}
|
|
68147
|
+
function sameNorm(a, b, allowPrefix) {
|
|
68148
|
+
const na = norm(a);
|
|
68149
|
+
const nb = norm(b);
|
|
68150
|
+
if (!na || !nb)
|
|
68151
|
+
return false;
|
|
68152
|
+
if (na === nb)
|
|
68153
|
+
return true;
|
|
68154
|
+
if (allowPrefix && na.length >= 7 && nb.length >= 7 && (na.startsWith(nb) || nb.startsWith(na)))
|
|
68155
|
+
return true;
|
|
68156
|
+
return false;
|
|
68157
|
+
}
|
|
68158
|
+
function isAllowClass(receipt, allowWarnDeploy) {
|
|
68159
|
+
const dec = receipt.decision;
|
|
68160
|
+
const decisionOk = dec === "ALLOW" || dec === "WARN" && allowWarnDeploy === true;
|
|
68161
|
+
if (!decisionOk)
|
|
68162
|
+
return false;
|
|
68163
|
+
const ea = receipt.execution_action;
|
|
68164
|
+
if (ea === void 0 || ea === null || ea === "")
|
|
68165
|
+
return true;
|
|
68166
|
+
return ea === "CONTINUE" || ea === "CONTINUE_WITH_MONITORING";
|
|
68167
|
+
}
|
|
68168
|
+
function idMatchesName(targetId, name) {
|
|
68169
|
+
const t = norm(targetId);
|
|
68170
|
+
const r = norm(name);
|
|
68171
|
+
return t === r || t === `svc:${r}` || t === `repo:${r}` || t.endsWith(`:${r}`) || t.endsWith(`/${r}`);
|
|
68172
|
+
}
|
|
68173
|
+
function deployGate(input) {
|
|
68174
|
+
const target = input.deployTarget || {};
|
|
68175
|
+
const rc = input.requiredContext || {};
|
|
68176
|
+
const enf = rc.enforcement || { enforcement: "UNKNOWN", bypass_possible: true };
|
|
68177
|
+
const enforcement_state = enf.enforcement;
|
|
68178
|
+
const opRequired = rc.operation ?? "deploy";
|
|
68179
|
+
const requireEnv = rc.require_bound_environment !== false;
|
|
68180
|
+
const requireArt = rc.require_bound_artifact !== false;
|
|
68181
|
+
const allowPending = input.allowPending ?? rc.allowPending ?? false;
|
|
68182
|
+
const allowWarnDeploy = input.allowWarnDeploy ?? rc.allowWarnDeploy ?? false;
|
|
68183
|
+
const allowPrefix = input.allowPrefixCompare ?? rc.allowPrefixCompare ?? false;
|
|
68184
|
+
const receipt = input.receipt;
|
|
68185
|
+
const detail = {
|
|
68186
|
+
environment: norm(target.environment),
|
|
68187
|
+
artifact_id: norm(target.artifact_id),
|
|
68188
|
+
bound_environment: receipt && receipt.bound_environment != null ? norm(receipt.bound_environment) : null,
|
|
68189
|
+
bound_artifact_id: receipt && receipt.bound_artifact_id != null ? norm(receipt.bound_artifact_id) : null,
|
|
68190
|
+
operation: receipt && receipt.operation != null ? String(receipt.operation) : null
|
|
68191
|
+
};
|
|
68192
|
+
const deny = (state, reason) => ({
|
|
68193
|
+
deploy_allowed: false,
|
|
68194
|
+
state,
|
|
68195
|
+
reason,
|
|
68196
|
+
enforcement_state,
|
|
68197
|
+
inescapable_deploy: false,
|
|
68198
|
+
detail
|
|
68199
|
+
});
|
|
68200
|
+
if (!target.environment || String(target.environment).trim() === "" || !target.artifact_id || String(target.artifact_id).trim() === "") {
|
|
68201
|
+
return deny(allowPending ? "pending" : "failure", "inputs_incomplete");
|
|
68202
|
+
}
|
|
68203
|
+
if (receipt === null || receipt === void 0) {
|
|
68204
|
+
return deny(allowPending ? "pending" : "failure", "no_receipt");
|
|
68205
|
+
}
|
|
68206
|
+
if (receipt.currently_authorized !== true) {
|
|
68207
|
+
return deny("failure", "receipt_not_authorized");
|
|
68208
|
+
}
|
|
68209
|
+
if (receipt.operation == null || norm(receipt.operation) !== norm(opRequired)) {
|
|
68210
|
+
return deny("failure", "operation_mismatch");
|
|
68211
|
+
}
|
|
68212
|
+
if (requireEnv) {
|
|
68213
|
+
if (!receipt.bound_environment || !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
68214
|
+
return deny("failure", "env_mismatch");
|
|
68215
|
+
}
|
|
68216
|
+
} else if (receipt.bound_environment && !sameNorm(receipt.bound_environment, target.environment, allowPrefix)) {
|
|
68217
|
+
return deny("failure", "env_mismatch");
|
|
68218
|
+
}
|
|
68219
|
+
if (requireArt) {
|
|
68220
|
+
if (!receipt.bound_artifact_id || !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
68221
|
+
return deny("failure", "stale_artifact");
|
|
68222
|
+
}
|
|
68223
|
+
} else if (receipt.bound_artifact_id && !sameNorm(receipt.bound_artifact_id, target.artifact_id, allowPrefix)) {
|
|
68224
|
+
return deny("failure", "stale_artifact");
|
|
68225
|
+
}
|
|
68226
|
+
if (rc.expected_fingerprint != null && receipt.verdict_fingerprint !== rc.expected_fingerprint) {
|
|
68227
|
+
return deny("failure", "fingerprint_mismatch");
|
|
68228
|
+
}
|
|
68229
|
+
if (rc.expected_body_hash != null && receipt.body_hash !== rc.expected_body_hash) {
|
|
68230
|
+
return deny("failure", "body_hash_mismatch");
|
|
68231
|
+
}
|
|
68232
|
+
if (rc.service && receipt.target_id) {
|
|
68233
|
+
if (!idMatchesName(receipt.target_id, rc.service))
|
|
68234
|
+
return deny("failure", "target_mismatch");
|
|
68235
|
+
} else if (rc.repository && receipt.target_id) {
|
|
68236
|
+
if (!idMatchesName(receipt.target_id, rc.repository))
|
|
68237
|
+
return deny("failure", "target_mismatch");
|
|
68238
|
+
}
|
|
68239
|
+
if (!isAllowClass(receipt, allowWarnDeploy)) {
|
|
68240
|
+
return deny("failure", "decision_not_allow");
|
|
68241
|
+
}
|
|
68242
|
+
const inescapable_deploy = enforcement_state === "ENFORCING" && enf.bypass_possible === false;
|
|
68243
|
+
let residual;
|
|
68244
|
+
if (!inescapable_deploy) {
|
|
68245
|
+
if (enforcement_state === "ENFORCING")
|
|
68246
|
+
residual = "bypass_open";
|
|
68247
|
+
else
|
|
68248
|
+
residual = "enforcement_not_configured";
|
|
68249
|
+
}
|
|
68250
|
+
return {
|
|
68251
|
+
deploy_allowed: true,
|
|
68252
|
+
state: "success",
|
|
68253
|
+
reason: "allow_current_deploy",
|
|
68254
|
+
enforcement_state,
|
|
68255
|
+
inescapable_deploy,
|
|
68256
|
+
...residual ? { residual } : {},
|
|
68257
|
+
detail
|
|
68258
|
+
};
|
|
68259
|
+
}
|
|
68260
|
+
}
|
|
68261
|
+
});
|
|
68262
|
+
|
|
68263
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/coverage-report.js
|
|
68264
|
+
var require_coverage_report = __commonJS({
|
|
68265
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/coverage-report.js"(exports2) {
|
|
68266
|
+
"use strict";
|
|
68267
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
68268
|
+
exports2.coverageReport = coverageReport;
|
|
68269
|
+
var TEMPLATES = {
|
|
68270
|
+
claim_fully_enforced: "All applicable CodeRifts placements are enforcing and non-bypassable for this target. Residuals outside tetrad (e.g. infra break-glass) may still exist.",
|
|
68271
|
+
claim_partially_enforced: "Partial enforcement: some applicable placements enforce; open gaps: {residuals}.",
|
|
68272
|
+
claim_advisory_only: "CodeRifts is present but no applicable placement is fully enforcing. Gaps: {residuals}.",
|
|
68273
|
+
claim_content_blocked: "Contract artifact content is not fully resolved; enforcement of preflight content is incomplete. Gaps: {residuals}.",
|
|
68274
|
+
claim_unknown: "One or more applicable placements cannot be observed. Cannot attest full enforcement. Gaps: {residuals}.",
|
|
68275
|
+
claim_not_applicable: "No CodeRifts placements are in scope for this target."
|
|
68276
|
+
};
|
|
68277
|
+
var OVERALL_TO_KEY = {
|
|
68278
|
+
FULLY_ENFORCED: "claim_fully_enforced",
|
|
68279
|
+
PARTIALLY_ENFORCED: "claim_partially_enforced",
|
|
68280
|
+
ADVISORY_ONLY: "claim_advisory_only",
|
|
68281
|
+
CONTENT_BLOCKED: "claim_content_blocked",
|
|
68282
|
+
UNKNOWN: "claim_unknown",
|
|
68283
|
+
NOT_APPLICABLE: "claim_not_applicable"
|
|
68284
|
+
};
|
|
68285
|
+
function computeRuntime(applicable, input) {
|
|
68286
|
+
if (!applicable)
|
|
68287
|
+
return { strength: "EXCLUDED", residuals: [], summary: { enforcement_or_coverage: input?.coverage ?? "N/A", inescapable_flag: input?.inescapable_runtime ?? null } };
|
|
68288
|
+
if (input == null)
|
|
68289
|
+
return { strength: "UNKNOWN", residuals: ["runtime_state_missing"], summary: { enforcement_or_coverage: "MISSING", inescapable_flag: null } };
|
|
68290
|
+
const residuals = [...input.residuals ?? []];
|
|
68291
|
+
let strength;
|
|
68292
|
+
if (input.coverage === "COMPLETE" && input.inescapable_runtime === true)
|
|
68293
|
+
strength = "ENFORCING";
|
|
68294
|
+
else if (input.coverage === "UNKNOWN")
|
|
68295
|
+
strength = "UNKNOWN";
|
|
68296
|
+
else
|
|
68297
|
+
strength = "WEAK";
|
|
68298
|
+
if (input.coverage === "BYPASSED")
|
|
68299
|
+
residuals.push("runtime_bypassed");
|
|
68300
|
+
return { strength, residuals, summary: { enforcement_or_coverage: input.coverage, inescapable_flag: input.inescapable_runtime } };
|
|
68301
|
+
}
|
|
68302
|
+
function computeMerge(applicable, input) {
|
|
68303
|
+
if (!applicable)
|
|
68304
|
+
return { strength: "EXCLUDED", residuals: [], summary: { enforcement_or_coverage: input?.enforcement_state ?? "N/A", inescapable_flag: input?.inescapable_merge ?? null } };
|
|
68305
|
+
if (input == null)
|
|
68306
|
+
return { strength: "UNKNOWN", residuals: ["merge_state_missing"], summary: { enforcement_or_coverage: "MISSING", inescapable_flag: null } };
|
|
68307
|
+
const residuals = [...input.residuals ?? []];
|
|
68308
|
+
let strength;
|
|
68309
|
+
if (input.inescapable_merge === true && input.enforcement_state === "ENFORCING")
|
|
68310
|
+
strength = "ENFORCING";
|
|
68311
|
+
else if (input.inescapable_merge === true) {
|
|
68312
|
+
strength = "WEAK";
|
|
68313
|
+
residuals.push("inescapable_flag_inconsistent");
|
|
68314
|
+
} else if (input.enforcement_state === "UNKNOWN")
|
|
68315
|
+
strength = "UNKNOWN";
|
|
68316
|
+
else
|
|
68317
|
+
strength = "WEAK";
|
|
68318
|
+
if (strength === "WEAK") {
|
|
68319
|
+
if (input.enforcement_state === "ENFORCING" && input.inescapable_merge === false)
|
|
68320
|
+
residuals.push("admin_bypass_open");
|
|
68321
|
+
else if (input.enforcement_state === "ABSENT")
|
|
68322
|
+
residuals.push("merge_gate_not_configured");
|
|
68323
|
+
else if (input.enforcement_state === "ADVISORY")
|
|
68324
|
+
residuals.push("merge_gate_advisory");
|
|
68325
|
+
}
|
|
68326
|
+
return { strength, residuals, summary: { enforcement_or_coverage: input.enforcement_state, inescapable_flag: input.inescapable_merge } };
|
|
68327
|
+
}
|
|
68328
|
+
function computeDeploy(applicable, input) {
|
|
68329
|
+
if (!applicable)
|
|
68330
|
+
return { strength: "EXCLUDED", residuals: [], summary: { enforcement_or_coverage: input?.enforcement_state ?? "N/A", inescapable_flag: input?.inescapable_deploy ?? null } };
|
|
68331
|
+
if (input == null)
|
|
68332
|
+
return { strength: "UNKNOWN", residuals: ["deploy_state_missing"], summary: { enforcement_or_coverage: "MISSING", inescapable_flag: null } };
|
|
68333
|
+
const residuals = [...input.residuals ?? []];
|
|
68334
|
+
let strength;
|
|
68335
|
+
if (input.inescapable_deploy === true && input.enforcement_state === "ENFORCING")
|
|
68336
|
+
strength = "ENFORCING";
|
|
68337
|
+
else if (input.inescapable_deploy === true) {
|
|
68338
|
+
strength = "WEAK";
|
|
68339
|
+
residuals.push("inescapable_flag_inconsistent");
|
|
68340
|
+
} else if (input.enforcement_state === "UNKNOWN")
|
|
68341
|
+
strength = "UNKNOWN";
|
|
68342
|
+
else
|
|
68343
|
+
strength = "WEAK";
|
|
68344
|
+
if (strength === "WEAK") {
|
|
68345
|
+
if (input.enforcement_state === "ENFORCING" && input.inescapable_deploy === false)
|
|
68346
|
+
residuals.push("bypass_open");
|
|
68347
|
+
else if (input.enforcement_state === "ABSENT")
|
|
68348
|
+
residuals.push("deploy_path_ungated");
|
|
68349
|
+
else if (input.enforcement_state === "ADVISORY")
|
|
68350
|
+
residuals.push("deploy_gate_advisory");
|
|
68351
|
+
}
|
|
68352
|
+
return { strength, residuals, summary: { enforcement_or_coverage: input.enforcement_state, inescapable_flag: input.inescapable_deploy } };
|
|
68353
|
+
}
|
|
68354
|
+
function computeContent(applicable, input) {
|
|
68355
|
+
if (!applicable)
|
|
68356
|
+
return { strength: "EXCLUDED", residuals: [], summary: { enforcement_or_coverage: input?.coverage ?? "N/A", inescapable_flag: input?.artifacts_ready ?? null } };
|
|
68357
|
+
if (input == null)
|
|
68358
|
+
return { strength: "UNKNOWN", residuals: ["content_state_missing"], summary: { enforcement_or_coverage: "MISSING", inescapable_flag: null } };
|
|
68359
|
+
const residuals = [...input.residuals ?? []];
|
|
68360
|
+
let strength;
|
|
68361
|
+
if (input.coverage === "COMPLETE" || input.coverage === "EMPTY")
|
|
68362
|
+
strength = "ENFORCING";
|
|
68363
|
+
else if (input.coverage === "UNRESOLVED") {
|
|
68364
|
+
strength = "WEAK";
|
|
68365
|
+
residuals.push("content_unresolved");
|
|
68366
|
+
} else if (input.coverage === "PARTIAL") {
|
|
68367
|
+
strength = "WEAK";
|
|
68368
|
+
residuals.push("content_partial");
|
|
68369
|
+
} else
|
|
68370
|
+
strength = "UNKNOWN";
|
|
68371
|
+
return { strength, residuals, summary: { enforcement_or_coverage: input.coverage, inescapable_flag: input.artifacts_ready ?? null } };
|
|
68372
|
+
}
|
|
68373
|
+
function coverageReport(input) {
|
|
68374
|
+
const applicability = input.applicability || { runtime: false, merge: false, deploy: false, content: false };
|
|
68375
|
+
const computed = {
|
|
68376
|
+
runtime: computeRuntime(applicability.runtime === true, input.runtime),
|
|
68377
|
+
merge: computeMerge(applicability.merge === true, input.merge),
|
|
68378
|
+
deploy: computeDeploy(applicability.deploy === true, input.deploy),
|
|
68379
|
+
content: computeContent(applicability.content === true, input.content)
|
|
68380
|
+
};
|
|
68381
|
+
const order = ["runtime", "merge", "deploy", "content"];
|
|
68382
|
+
const isApplicable = (p) => applicability[p] === true;
|
|
68383
|
+
const applicableStrengths = order.filter(isApplicable).map((p) => computed[p].strength);
|
|
68384
|
+
const contentApplicable = isApplicable("content");
|
|
68385
|
+
const contentUnresolved = contentApplicable && input.content != null && input.content.coverage === "UNRESOLVED";
|
|
68386
|
+
const weakPlacements = order.filter((p) => isApplicable(p) && computed[p].strength === "WEAK");
|
|
68387
|
+
let overall;
|
|
68388
|
+
if (applicableStrengths.length === 0) {
|
|
68389
|
+
overall = "NOT_APPLICABLE";
|
|
68390
|
+
} else if (applicableStrengths.every((s) => s === "ENFORCING")) {
|
|
68391
|
+
overall = "FULLY_ENFORCED";
|
|
68392
|
+
} else if (applicableStrengths.some((s) => s === "WEAK") && applicableStrengths.some((s) => s === "ENFORCING")) {
|
|
68393
|
+
overall = contentUnresolved ? "CONTENT_BLOCKED" : "PARTIALLY_ENFORCED";
|
|
68394
|
+
} else if (applicableStrengths.some((s) => s === "WEAK")) {
|
|
68395
|
+
overall = contentUnresolved && weakPlacements.every((p) => p === "content") ? "CONTENT_BLOCKED" : "ADVISORY_ONLY";
|
|
68396
|
+
} else {
|
|
68397
|
+
overall = "UNKNOWN";
|
|
68398
|
+
}
|
|
68399
|
+
const residualSet = /* @__PURE__ */ new Set();
|
|
68400
|
+
for (const p of order)
|
|
68401
|
+
if (isApplicable(p))
|
|
68402
|
+
for (const r of computed[p].residuals)
|
|
68403
|
+
residualSet.add(r);
|
|
68404
|
+
const residuals = [...residualSet].sort();
|
|
68405
|
+
const honest_claim_key = OVERALL_TO_KEY[overall];
|
|
68406
|
+
const honest_claim_language = TEMPLATES[honest_claim_key].replace("{residuals}", residuals.length ? residuals.join(", ") : "none");
|
|
68407
|
+
const flags = {
|
|
68408
|
+
may_claim_inescapable_runtime: isApplicable("runtime") && computed.runtime.strength === "ENFORCING",
|
|
68409
|
+
may_claim_inescapable_merge: isApplicable("merge") && computed.merge.strength === "ENFORCING",
|
|
68410
|
+
may_claim_inescapable_deploy: isApplicable("deploy") && computed.deploy.strength === "ENFORCING",
|
|
68411
|
+
may_claim_full_tetrad: overall === "FULLY_ENFORCED"
|
|
68412
|
+
};
|
|
68413
|
+
const per_placement = order.map((p) => ({
|
|
68414
|
+
placement: p,
|
|
68415
|
+
applicable: isApplicable(p),
|
|
68416
|
+
strength: computed[p].strength,
|
|
68417
|
+
summary: computed[p].summary,
|
|
68418
|
+
residuals: isApplicable(p) ? [...new Set(computed[p].residuals)].sort() : []
|
|
68419
|
+
}));
|
|
68420
|
+
return { overall_coverage: overall, per_placement, residuals, honest_claim_key, honest_claim_language, flags };
|
|
68421
|
+
}
|
|
68422
|
+
}
|
|
68423
|
+
});
|
|
68424
|
+
|
|
68425
|
+
// ../../node_modules/@coderifts/agent-guard/dist/cjs/index.js
|
|
68426
|
+
var require_cjs4 = __commonJS({
|
|
68427
|
+
"../../node_modules/@coderifts/agent-guard/dist/cjs/index.js"(exports2) {
|
|
68428
|
+
"use strict";
|
|
68429
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
68430
|
+
exports2.coverageReport = exports2.deployGate = exports2.gateDecision = exports2.RegistryConstructionError = exports2.guardToolRegistry = exports2.globToRegExp = exports2.matchGlob = exports2.resolveArtifacts = exports2.deriveKeySignal = exports2.pathClass = exports2.classifyCommand = exports2.projectState = exports2.emptySessionState = exports2.computeTainted = exports2.evaluate = exports2.updateSession = exports2.SESSION_TAINT_VERSION = exports2.SessionTaintTracker = exports2.readDecision = exports2.computeBundleFingerprint = exports2.computeArtifactDigest = exports2.evaluateEnvelope = exports2.canonicalJson = exports2.computeBodyHash = exports2.bindReceiptToEnvelope = exports2.DETECTOR_VERSION = exports2.builtinDetector = exports2.guardToolCall = void 0;
|
|
68431
|
+
var guard_js_1 = require_guard();
|
|
68432
|
+
Object.defineProperty(exports2, "guardToolCall", { enumerable: true, get: function() {
|
|
68433
|
+
return guard_js_1.guardToolCall;
|
|
68434
|
+
} });
|
|
68435
|
+
var detector_js_1 = require_detector();
|
|
68436
|
+
Object.defineProperty(exports2, "builtinDetector", { enumerable: true, get: function() {
|
|
68437
|
+
return detector_js_1.builtinDetector;
|
|
68438
|
+
} });
|
|
68439
|
+
Object.defineProperty(exports2, "DETECTOR_VERSION", { enumerable: true, get: function() {
|
|
68440
|
+
return detector_js_1.DETECTOR_VERSION;
|
|
68441
|
+
} });
|
|
68442
|
+
var receipt_binding_js_1 = require_receipt_binding();
|
|
68443
|
+
Object.defineProperty(exports2, "bindReceiptToEnvelope", { enumerable: true, get: function() {
|
|
68444
|
+
return receipt_binding_js_1.bindReceiptToEnvelope;
|
|
68445
|
+
} });
|
|
68446
|
+
Object.defineProperty(exports2, "computeBodyHash", { enumerable: true, get: function() {
|
|
68447
|
+
return receipt_binding_js_1.computeBodyHash;
|
|
68448
|
+
} });
|
|
68449
|
+
Object.defineProperty(exports2, "canonicalJson", { enumerable: true, get: function() {
|
|
68450
|
+
return receipt_binding_js_1.canonicalJson;
|
|
68451
|
+
} });
|
|
68452
|
+
var enforcement_gate_js_1 = require_enforcement_gate();
|
|
68453
|
+
Object.defineProperty(exports2, "evaluateEnvelope", { enumerable: true, get: function() {
|
|
68454
|
+
return enforcement_gate_js_1.evaluateEnvelope;
|
|
68455
|
+
} });
|
|
68456
|
+
Object.defineProperty(exports2, "computeArtifactDigest", { enumerable: true, get: function() {
|
|
68457
|
+
return enforcement_gate_js_1.computeArtifactDigest;
|
|
68458
|
+
} });
|
|
68459
|
+
Object.defineProperty(exports2, "computeBundleFingerprint", { enumerable: true, get: function() {
|
|
68460
|
+
return enforcement_gate_js_1.computeBundleFingerprint;
|
|
68461
|
+
} });
|
|
68462
|
+
var sdk_1 = require_cjs3();
|
|
68463
|
+
Object.defineProperty(exports2, "readDecision", { enumerable: true, get: function() {
|
|
68464
|
+
return sdk_1.readDecision;
|
|
68465
|
+
} });
|
|
68466
|
+
var session_taint_js_1 = require_session_taint();
|
|
68467
|
+
Object.defineProperty(exports2, "SessionTaintTracker", { enumerable: true, get: function() {
|
|
68468
|
+
return session_taint_js_1.SessionTaintTracker;
|
|
68469
|
+
} });
|
|
68470
|
+
Object.defineProperty(exports2, "SESSION_TAINT_VERSION", { enumerable: true, get: function() {
|
|
68471
|
+
return session_taint_js_1.SESSION_TAINT_VERSION;
|
|
68472
|
+
} });
|
|
68473
|
+
Object.defineProperty(exports2, "updateSession", { enumerable: true, get: function() {
|
|
68474
|
+
return session_taint_js_1.updateSession;
|
|
68475
|
+
} });
|
|
68476
|
+
Object.defineProperty(exports2, "evaluate", { enumerable: true, get: function() {
|
|
68477
|
+
return session_taint_js_1.evaluate;
|
|
68478
|
+
} });
|
|
68479
|
+
Object.defineProperty(exports2, "computeTainted", { enumerable: true, get: function() {
|
|
68480
|
+
return session_taint_js_1.computeTainted;
|
|
68481
|
+
} });
|
|
68482
|
+
Object.defineProperty(exports2, "emptySessionState", { enumerable: true, get: function() {
|
|
68483
|
+
return session_taint_js_1.emptySessionState;
|
|
68484
|
+
} });
|
|
68485
|
+
Object.defineProperty(exports2, "projectState", { enumerable: true, get: function() {
|
|
68486
|
+
return session_taint_js_1.projectState;
|
|
68487
|
+
} });
|
|
68488
|
+
Object.defineProperty(exports2, "classifyCommand", { enumerable: true, get: function() {
|
|
68489
|
+
return session_taint_js_1.classifyCommand;
|
|
68490
|
+
} });
|
|
68491
|
+
Object.defineProperty(exports2, "pathClass", { enumerable: true, get: function() {
|
|
68492
|
+
return session_taint_js_1.pathClass;
|
|
68493
|
+
} });
|
|
68494
|
+
Object.defineProperty(exports2, "deriveKeySignal", { enumerable: true, get: function() {
|
|
68495
|
+
return session_taint_js_1.deriveKeySignal;
|
|
68496
|
+
} });
|
|
68497
|
+
var artifact_resolver_js_1 = require_artifact_resolver();
|
|
68498
|
+
Object.defineProperty(exports2, "resolveArtifacts", { enumerable: true, get: function() {
|
|
68499
|
+
return artifact_resolver_js_1.resolve;
|
|
68500
|
+
} });
|
|
68501
|
+
var resolver_glob_js_1 = require_resolver_glob();
|
|
68502
|
+
Object.defineProperty(exports2, "matchGlob", { enumerable: true, get: function() {
|
|
68503
|
+
return resolver_glob_js_1.matchGlob;
|
|
68504
|
+
} });
|
|
68505
|
+
Object.defineProperty(exports2, "globToRegExp", { enumerable: true, get: function() {
|
|
68506
|
+
return resolver_glob_js_1.globToRegExp;
|
|
68507
|
+
} });
|
|
68508
|
+
var tool_registry_js_1 = require_tool_registry();
|
|
68509
|
+
Object.defineProperty(exports2, "guardToolRegistry", { enumerable: true, get: function() {
|
|
68510
|
+
return tool_registry_js_1.guardToolRegistry;
|
|
68511
|
+
} });
|
|
68512
|
+
Object.defineProperty(exports2, "RegistryConstructionError", { enumerable: true, get: function() {
|
|
68513
|
+
return tool_registry_js_1.RegistryConstructionError;
|
|
68514
|
+
} });
|
|
68515
|
+
var merge_gate_js_1 = require_merge_gate();
|
|
68516
|
+
Object.defineProperty(exports2, "gateDecision", { enumerable: true, get: function() {
|
|
68517
|
+
return merge_gate_js_1.gateDecision;
|
|
68518
|
+
} });
|
|
68519
|
+
var deploy_gate_js_1 = require_deploy_gate();
|
|
68520
|
+
Object.defineProperty(exports2, "deployGate", { enumerable: true, get: function() {
|
|
68521
|
+
return deploy_gate_js_1.deployGate;
|
|
68522
|
+
} });
|
|
68523
|
+
var coverage_report_js_1 = require_coverage_report();
|
|
68524
|
+
Object.defineProperty(exports2, "coverageReport", { enumerable: true, get: function() {
|
|
68525
|
+
return coverage_report_js_1.coverageReport;
|
|
68526
|
+
} });
|
|
68527
|
+
}
|
|
68528
|
+
});
|
|
68529
|
+
|
|
68530
|
+
// src/commands/deploy-gate.js
|
|
68531
|
+
var require_deploy_gate2 = __commonJS({
|
|
68532
|
+
"src/commands/deploy-gate.js"(exports2, module2) {
|
|
68533
|
+
"use strict";
|
|
68534
|
+
var fs = require("fs");
|
|
68535
|
+
var path = require("path");
|
|
68536
|
+
var chalk = require_source();
|
|
68537
|
+
var { deployGate } = require_cjs4();
|
|
68538
|
+
var { renderJson } = require_json2();
|
|
68539
|
+
if (process.env.NO_COLOR) chalk.level = 0;
|
|
68540
|
+
var REPAIRABLE = /* @__PURE__ */ new Set(["env_mismatch", "stale_artifact", "operation_mismatch", "receipt_not_authorized", "fingerprint_mismatch", "body_hash_mismatch"]);
|
|
68541
|
+
function enforceSignal(options) {
|
|
68542
|
+
return options && options.enforce === true || String(process.env.CODERIFTS_DEPLOY_ENFORCE || "").toLowerCase() === "true";
|
|
68543
|
+
}
|
|
68544
|
+
function observeCDEnforcement(options = {}) {
|
|
68545
|
+
const envVal = String(process.env.CODERIFTS_DEPLOY_ENFORCE || "").toLowerCase();
|
|
68546
|
+
let enforcement;
|
|
68547
|
+
if (enforceSignal(options)) enforcement = "ENFORCING";
|
|
68548
|
+
else if (envVal === "unknown") enforcement = "UNKNOWN";
|
|
68549
|
+
else enforcement = "ADVISORY";
|
|
68550
|
+
const bypass_possible = String(process.env.CODERIFTS_DEPLOY_NO_BYPASS || "").toLowerCase() !== "true";
|
|
68551
|
+
return {
|
|
68552
|
+
enforcement,
|
|
68553
|
+
bypass_possible,
|
|
68554
|
+
step_is_required: enforcement === "ENFORCING",
|
|
68555
|
+
required_step_name: "CodeRifts / deploy-gate",
|
|
68556
|
+
attestation_source: "cli_flag"
|
|
68557
|
+
};
|
|
68558
|
+
}
|
|
68559
|
+
function deployReportResiduals(state, inescapable, enforcement) {
|
|
68560
|
+
const out = [];
|
|
68561
|
+
if (state === "success" && inescapable !== true) {
|
|
68562
|
+
if (enforcement === "ENFORCING") out.push("bypass_open");
|
|
68563
|
+
else if (enforcement === "ADVISORY") out.push("deploy_gate_advisory");
|
|
68564
|
+
else if (enforcement === "ABSENT") out.push("deploy_path_ungated");
|
|
68565
|
+
}
|
|
68566
|
+
return out;
|
|
68567
|
+
}
|
|
68568
|
+
function deployCoverageInput(enforcement_state, inescapable_deploy) {
|
|
68569
|
+
return { enforcement_state, inescapable_deploy: inescapable_deploy === true, applicability_attested: true };
|
|
68570
|
+
}
|
|
68571
|
+
function deployBind({ environment, artifact_id, receipt, observed_cd_enforcement, expected_fingerprint, expected_body_hash }) {
|
|
68572
|
+
const attested_enforcement = observed_cd_enforcement && observed_cd_enforcement.enforcement || "UNKNOWN";
|
|
68573
|
+
if (!receipt) {
|
|
68574
|
+
return {
|
|
68575
|
+
deploy_check_status: "pending",
|
|
68576
|
+
reason: "no_receipt",
|
|
68577
|
+
must_re_preflight: true,
|
|
68578
|
+
attested_enforcement,
|
|
68579
|
+
gate: null,
|
|
68580
|
+
report_residuals: [],
|
|
68581
|
+
coverage_deploy_input: deployCoverageInput(attested_enforcement, false)
|
|
68582
|
+
};
|
|
68583
|
+
}
|
|
68584
|
+
const requiredContext = {
|
|
68585
|
+
operation: "deploy",
|
|
68586
|
+
enforcement: {
|
|
68587
|
+
enforcement: attested_enforcement,
|
|
68588
|
+
// fail-closed: bypass is possible unless observation proved it disabled.
|
|
68589
|
+
bypass_possible: !(observed_cd_enforcement && observed_cd_enforcement.bypass_possible === false)
|
|
68590
|
+
}
|
|
68591
|
+
};
|
|
68592
|
+
if (attested_enforcement === "ENFORCING") {
|
|
68593
|
+
if (expected_fingerprint != null) requiredContext.expected_fingerprint = expected_fingerprint;
|
|
68594
|
+
if (expected_body_hash != null) requiredContext.expected_body_hash = expected_body_hash;
|
|
68595
|
+
}
|
|
68596
|
+
const gate = deployGate({ deployTarget: { environment, artifact_id }, receipt, requiredContext });
|
|
68597
|
+
const inescapable_deploy = gate.inescapable_deploy === true;
|
|
68598
|
+
return {
|
|
68599
|
+
deploy_check_status: gate.state,
|
|
68600
|
+
reason: gate.reason,
|
|
68601
|
+
must_re_preflight: REPAIRABLE.has(gate.reason),
|
|
68602
|
+
attested_enforcement,
|
|
68603
|
+
gate: { deploy_allowed: gate.deploy_allowed, reason: gate.reason, inescapable_deploy },
|
|
68604
|
+
report_residuals: deployReportResiduals(gate.state, inescapable_deploy, attested_enforcement),
|
|
68605
|
+
coverage_deploy_input: deployCoverageInput(attested_enforcement, inescapable_deploy)
|
|
68606
|
+
};
|
|
68607
|
+
}
|
|
68608
|
+
function clampExit(deployCheckStatus, enforce) {
|
|
68609
|
+
if (deployCheckStatus === "success") return 0;
|
|
68610
|
+
if (deployCheckStatus === "failure" && enforce === true) return 1;
|
|
68611
|
+
return 0;
|
|
68612
|
+
}
|
|
68613
|
+
function readReceiptFile(filePath) {
|
|
68614
|
+
if (!filePath) return null;
|
|
68615
|
+
const resolved = path.resolve(filePath);
|
|
68616
|
+
if (!fs.existsSync(resolved)) return null;
|
|
68617
|
+
try {
|
|
68618
|
+
return JSON.parse(fs.readFileSync(resolved, "utf-8"));
|
|
68619
|
+
} catch (_) {
|
|
68620
|
+
return null;
|
|
68621
|
+
}
|
|
68622
|
+
}
|
|
68623
|
+
function renderDeployGateTerminal(bind, enforce) {
|
|
68624
|
+
const g = bind.gate;
|
|
68625
|
+
const color = bind.deploy_check_status === "success" ? chalk.green : bind.deploy_check_status === "failure" ? chalk.red : chalk.yellow;
|
|
68626
|
+
const lines = [];
|
|
68627
|
+
lines.push("");
|
|
68628
|
+
lines.push(chalk.bold(` CodeRifts deploy-gate \u2014 ${color(bind.deploy_check_status.toUpperCase())}`));
|
|
68629
|
+
lines.push(` Reason: ${bind.reason}`);
|
|
68630
|
+
lines.push(` Enforcement: ${bind.attested_enforcement}`);
|
|
68631
|
+
lines.push(` inescapable_deploy: ${g ? g.inescapable_deploy : false}`);
|
|
68632
|
+
if (bind.report_residuals.length) lines.push(` Residuals: ${bind.report_residuals.join(", ")}`);
|
|
68633
|
+
if (bind.must_re_preflight) lines.push(chalk.yellow(" Action: re-preflight this { environment, artifact } \u2014 the receipt does not authorize it."));
|
|
68634
|
+
lines.push("");
|
|
68635
|
+
lines.push(enforce ? chalk.dim(" Enforcing \u2014 a failing gate exits non-zero (blocks the deploy step).") : chalk.dim(" Advisory (phase 1) \u2014 does not block the deploy (exit 0)."));
|
|
68636
|
+
lines.push("");
|
|
68637
|
+
return lines.join("\n");
|
|
68638
|
+
}
|
|
68639
|
+
async function runDeployGate(options = {}) {
|
|
68640
|
+
const environment = options.env;
|
|
68641
|
+
const artifactId = options.artifact;
|
|
68642
|
+
if (!environment || !artifactId) {
|
|
68643
|
+
console.error(chalk.red("Error: --env and --artifact are required."));
|
|
68644
|
+
process.exit(1);
|
|
68645
|
+
return;
|
|
68646
|
+
}
|
|
68647
|
+
const enforce = enforceSignal(options);
|
|
68648
|
+
const receipt = readReceiptFile(options.receipt);
|
|
68649
|
+
const observed = observeCDEnforcement({ enforce });
|
|
68650
|
+
const bind = deployBind({ environment, artifact_id: artifactId, receipt, observed_cd_enforcement: observed });
|
|
68651
|
+
const code = clampExit(bind.deploy_check_status, enforce);
|
|
68652
|
+
if (options.json) {
|
|
68653
|
+
console.log(renderJson({ command: "deploy-gate", environment, artifact_id: artifactId, phase: enforce ? "enforcing" : "advisory", exit_code: code, ...bind }));
|
|
68654
|
+
} else {
|
|
68655
|
+
console.log(renderDeployGateTerminal(bind, enforce));
|
|
68656
|
+
}
|
|
68657
|
+
process.exit(code);
|
|
68658
|
+
}
|
|
68659
|
+
module2.exports = {
|
|
68660
|
+
runDeployGate,
|
|
68661
|
+
deployBind,
|
|
68662
|
+
observeCDEnforcement,
|
|
68663
|
+
clampExit,
|
|
68664
|
+
readReceiptFile,
|
|
68665
|
+
renderDeployGateTerminal
|
|
68666
|
+
};
|
|
68667
|
+
}
|
|
68668
|
+
});
|
|
68669
|
+
|
|
65122
68670
|
// src/commands/init.js
|
|
65123
68671
|
var require_init = __commonJS({
|
|
65124
68672
|
"src/commands/init.js"(exports2, module2) {
|
|
@@ -75782,7 +79330,7 @@ var require_zipWith = __commonJS({
|
|
|
75782
79330
|
});
|
|
75783
79331
|
|
|
75784
79332
|
// node_modules/rxjs/dist/cjs/index.js
|
|
75785
|
-
var
|
|
79333
|
+
var require_cjs5 = __commonJS({
|
|
75786
79334
|
"node_modules/rxjs/dist/cjs/index.js"(exports2) {
|
|
75787
79335
|
"use strict";
|
|
75788
79336
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -77099,7 +80647,7 @@ var require_run_async = __commonJS({
|
|
|
77099
80647
|
var require_utils3 = __commonJS({
|
|
77100
80648
|
"node_modules/inquirer/lib/utils/utils.js"(exports2) {
|
|
77101
80649
|
"use strict";
|
|
77102
|
-
var { from, of } =
|
|
80650
|
+
var { from, of } = require_cjs5();
|
|
77103
80651
|
var runAsync = require_run_async();
|
|
77104
80652
|
exports2.fetchAsyncQuestionProperty = function(question, prop, answers) {
|
|
77105
80653
|
if (typeof question[prop] !== "function") {
|
|
@@ -77124,7 +80672,7 @@ var require_prompt = __commonJS({
|
|
|
77124
80672
|
get: require_get2(),
|
|
77125
80673
|
set: require_set3()
|
|
77126
80674
|
};
|
|
77127
|
-
var { defer, empty, from, of } =
|
|
80675
|
+
var { defer, empty, from, of } = require_cjs5();
|
|
77128
80676
|
var { concatMap, filter, publish, reduce } = require_operators();
|
|
77129
80677
|
var runAsync = require_run_async();
|
|
77130
80678
|
var utils = require_utils3();
|
|
@@ -79838,7 +83386,7 @@ var require_base = __commonJS({
|
|
|
79838
83386
|
var require_events = __commonJS({
|
|
79839
83387
|
"node_modules/inquirer/lib/utils/events.js"(exports2, module2) {
|
|
79840
83388
|
"use strict";
|
|
79841
|
-
var { fromEvent } =
|
|
83389
|
+
var { fromEvent } = require_cjs5();
|
|
79842
83390
|
var { filter, map, share, takeUntil } = require_operators();
|
|
79843
83391
|
function normalizeKeypressEvents(value, key) {
|
|
79844
83392
|
return { value, key: key || {} };
|
|
@@ -90636,7 +94184,7 @@ var require_editor = __commonJS({
|
|
|
90636
94184
|
var { editAsync } = require_commonjs();
|
|
90637
94185
|
var Base = require_base();
|
|
90638
94186
|
var observe = require_events();
|
|
90639
|
-
var { Subject } =
|
|
94187
|
+
var { Subject } = require_cjs5();
|
|
90640
94188
|
var EditorPrompt = class extends Base {
|
|
90641
94189
|
/**
|
|
90642
94190
|
* Start the Inquiry session
|
|
@@ -91018,7 +94566,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91018
94566
|
expected: {
|
|
91019
94567
|
has_breaking: false,
|
|
91020
94568
|
should_flag_poison: false,
|
|
91021
|
-
risk_max:
|
|
94569
|
+
risk_max: 0,
|
|
94570
|
+
bounds_changelog: "risk_max 20 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94571
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91022
94572
|
deep_signals: [],
|
|
91023
94573
|
notes: "Purely additive optional property. Agents that do not send 'limit' continue to work. Must NOT trigger breaking or high risk."
|
|
91024
94574
|
}
|
|
@@ -91052,7 +94602,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91052
94602
|
expected: {
|
|
91053
94603
|
has_breaking: false,
|
|
91054
94604
|
should_flag_poison: false,
|
|
91055
|
-
risk_max:
|
|
94605
|
+
risk_max: 0,
|
|
94606
|
+
bounds_changelog: "risk_max 15 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94607
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91056
94608
|
deep_signals: [],
|
|
91057
94609
|
notes: "Input enum expansion is non-breaking for callers. Existing 'read'/'write' payloads still validate. Do not cry wolf."
|
|
91058
94610
|
}
|
|
@@ -91085,7 +94637,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91085
94637
|
expected: {
|
|
91086
94638
|
has_breaking: false,
|
|
91087
94639
|
should_flag_poison: false,
|
|
91088
|
-
risk_max:
|
|
94640
|
+
risk_max: 0,
|
|
94641
|
+
bounds_changelog: "risk_max 25 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94642
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91089
94643
|
deep_signals: ["composition_branch_count_changed"],
|
|
91090
94644
|
notes: "New branch is additive. Old 'text' payloads continue to match first branch exactly. Non-breaking per rules."
|
|
91091
94645
|
}
|
|
@@ -91109,7 +94663,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91109
94663
|
expected: {
|
|
91110
94664
|
has_breaking: false,
|
|
91111
94665
|
should_flag_poison: false,
|
|
91112
|
-
risk_max:
|
|
94666
|
+
risk_max: 0,
|
|
94667
|
+
bounds_changelog: "risk_max 5 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94668
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91113
94669
|
deep_signals: ["description_changed"],
|
|
91114
94670
|
notes: "Description change only. No structural impact and no suspicious content. Must stay low risk / non-breaking."
|
|
91115
94671
|
}
|
|
@@ -91141,7 +94697,8 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91141
94697
|
expected: {
|
|
91142
94698
|
has_breaking: false,
|
|
91143
94699
|
should_flag_poison: false,
|
|
91144
|
-
risk_max:
|
|
94700
|
+
risk_max: 24,
|
|
94701
|
+
bounds_changelog: "risk_max 10 -> 24 (recalibrated 2026-07 to measured 20 on the oasdiff-1.11.11 pinned path)",
|
|
91145
94702
|
deep_signals: [],
|
|
91146
94703
|
notes: "Adding fields to output is generally non-breaking for agents (they can ignore unknown keys unless strict validation)."
|
|
91147
94704
|
}
|
|
@@ -91168,7 +94725,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91168
94725
|
expected: {
|
|
91169
94726
|
has_breaking: false,
|
|
91170
94727
|
should_flag_poison: false,
|
|
91171
|
-
risk_max:
|
|
94728
|
+
risk_max: 0,
|
|
94729
|
+
bounds_changelog: "risk_max 5 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94730
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91172
94731
|
deep_signals: [],
|
|
91173
94732
|
notes: "Vendor extensions and unknown keywords do not affect validation contract for existing payloads."
|
|
91174
94733
|
}
|
|
@@ -91202,7 +94761,8 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91202
94761
|
expected: {
|
|
91203
94762
|
has_breaking: true,
|
|
91204
94763
|
should_flag_poison: false,
|
|
91205
|
-
risk_min:
|
|
94764
|
+
risk_min: 24,
|
|
94765
|
+
bounds_changelog: "risk_min 60 -> 24 (recalibrated 2026-07 to measured 30 on the oasdiff-1.11.11 pinned path)",
|
|
91206
94766
|
deep_signals: ["required_added", "property_removed"],
|
|
91207
94767
|
notes: "Old agents send 'title'. New contract requires 'name'. Direct break. Must be detected as breaking despite surface 'add+remove' appearance."
|
|
91208
94768
|
}
|
|
@@ -91233,7 +94793,8 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91233
94793
|
},
|
|
91234
94794
|
expected: {
|
|
91235
94795
|
has_breaking: true,
|
|
91236
|
-
risk_min:
|
|
94796
|
+
risk_min: 16,
|
|
94797
|
+
bounds_changelog: "risk_min 45 -> 16 (recalibrated 2026-07 to measured 20 on the oasdiff-1.11.11 pinned path)",
|
|
91237
94798
|
deep_signals: ["enum_value_removed"],
|
|
91238
94799
|
notes: "Server will no longer emit 'error' state. Any agent logic or monitoring keyed on it breaks. Must flag."
|
|
91239
94800
|
}
|
|
@@ -91271,7 +94832,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91271
94832
|
},
|
|
91272
94833
|
expected: {
|
|
91273
94834
|
has_breaking: true,
|
|
91274
|
-
risk_min:
|
|
94835
|
+
risk_min: 0,
|
|
94836
|
+
bounds_changelog: "risk_min 70 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94837
|
+
risk_note: "risk scorer produces no signal for this vector class - detection-only guard",
|
|
91275
94838
|
deep_signals: ["conditional_required_added", "required_added"],
|
|
91276
94839
|
notes: "When mode=full, 'reason' becomes mandatory. Agents using the old manifest for full updates will fail validation. Must catch deep conditional."
|
|
91277
94840
|
}
|
|
@@ -91314,7 +94877,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91314
94877
|
expected: {
|
|
91315
94878
|
has_breaking: true,
|
|
91316
94879
|
should_flag_poison: true,
|
|
91317
|
-
risk_min:
|
|
94880
|
+
risk_min: 0,
|
|
94881
|
+
bounds_changelog: "risk_min 80 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94882
|
+
risk_note: "risk scorer produces no signal for this vector class - detection-only guard",
|
|
91318
94883
|
deep_signals: ["$defs_changed", "required_added"],
|
|
91319
94884
|
poison_signals: ["Ignore previous", "always include"],
|
|
91320
94885
|
notes: "Ref target now requires extra field + contains FSP instruction. Classic deep + poison vector. Must surface both structural break and poisoning."
|
|
@@ -91350,7 +94915,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91350
94915
|
expected: {
|
|
91351
94916
|
has_breaking: false,
|
|
91352
94917
|
should_flag_poison: true,
|
|
91353
|
-
risk_min:
|
|
94918
|
+
risk_min: 0,
|
|
94919
|
+
bounds_changelog: "risk_min 55 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94920
|
+
risk_note: "risk scorer produces no signal for this vector class - detection-only guard",
|
|
91354
94921
|
poison_signals: ["send a copy", "attacker.example"],
|
|
91355
94922
|
notes: "Structural contract same, but FSP in a property description. Shallow tools miss it. Full-schema detector + risk must catch."
|
|
91356
94923
|
}
|
|
@@ -91383,7 +94950,9 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91383
94950
|
},
|
|
91384
94951
|
expected: {
|
|
91385
94952
|
has_breaking: true,
|
|
91386
|
-
risk_min:
|
|
94953
|
+
risk_min: 0,
|
|
94954
|
+
bounds_changelog: "risk_min 65 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
94955
|
+
risk_note: "risk scorer produces no signal for this vector class - detection-only guard",
|
|
91387
94956
|
deep_signals: ["required_added"],
|
|
91388
94957
|
notes: "The second allOf fragment now requires 'data'. After merge the whole schema requires it. Must detect via normalization + allOf handling."
|
|
91389
94958
|
}
|
|
@@ -91414,7 +94983,8 @@ var require_vectors_mcp_fpfn = __commonJS({
|
|
|
91414
94983
|
},
|
|
91415
94984
|
expected: {
|
|
91416
94985
|
has_breaking: true,
|
|
91417
|
-
risk_min:
|
|
94986
|
+
risk_min: 16,
|
|
94987
|
+
bounds_changelog: "risk_min 70 -> 16 (recalibrated 2026-07 to measured 20 on the oasdiff-1.11.11 pinned path)",
|
|
91418
94988
|
deep_signals: ["conditional_required_added"],
|
|
91419
94989
|
notes: "Error path now mandates 'result'. Agents and any gateway transformation that relied on optional result on error will break or behave differently."
|
|
91420
94990
|
}
|
|
@@ -91467,7 +95037,9 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91467
95037
|
},
|
|
91468
95038
|
expected: {
|
|
91469
95039
|
has_breaking: false,
|
|
91470
|
-
risk_max:
|
|
95040
|
+
risk_max: 0,
|
|
95041
|
+
bounds_changelog: "risk_max 10 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
95042
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91471
95043
|
notes: "Optional query param addition never breaks existing calls that omit it. Must not flag."
|
|
91472
95044
|
}
|
|
91473
95045
|
},
|
|
@@ -91520,7 +95092,9 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91520
95092
|
},
|
|
91521
95093
|
expected: {
|
|
91522
95094
|
has_breaking: false,
|
|
91523
|
-
risk_max:
|
|
95095
|
+
risk_max: 0,
|
|
95096
|
+
bounds_changelog: "risk_max 8 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
95097
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91524
95098
|
notes: "Extra response fields are ignored by most clients unless they use strict additionalProperties:false. Non-breaking."
|
|
91525
95099
|
}
|
|
91526
95100
|
},
|
|
@@ -91577,7 +95151,9 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91577
95151
|
},
|
|
91578
95152
|
expected: {
|
|
91579
95153
|
has_breaking: false,
|
|
91580
|
-
risk_max:
|
|
95154
|
+
risk_max: 0,
|
|
95155
|
+
bounds_changelog: "risk_max 12 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
95156
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91581
95157
|
notes: "Response enum expansion gives clients more cases to handle optionally. Existing handling of open/closed remains valid."
|
|
91582
95158
|
}
|
|
91583
95159
|
},
|
|
@@ -91613,7 +95189,8 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91613
95189
|
},
|
|
91614
95190
|
expected: {
|
|
91615
95191
|
has_breaking: true,
|
|
91616
|
-
risk_min:
|
|
95192
|
+
risk_min: 2,
|
|
95193
|
+
bounds_changelog: "risk_min 70 -> 2 (recalibrated 2026-07 to measured 3 on the production-faithful path - no pattern boost)",
|
|
91617
95194
|
notes: "All prior requests without 'org' now invalid. Direct breaking change for agents and SDK clients. Must be caught."
|
|
91618
95195
|
}
|
|
91619
95196
|
},
|
|
@@ -91718,7 +95295,8 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91718
95295
|
},
|
|
91719
95296
|
expected: {
|
|
91720
95297
|
has_breaking: true,
|
|
91721
|
-
risk_min:
|
|
95298
|
+
risk_min: 4,
|
|
95299
|
+
bounds_changelog: "risk_min 75 -> 4 (recalibrated 2026-07 to measured 6 on the production-faithful path - no pattern boost)",
|
|
91722
95300
|
notes: "Request payload shape changed for a required identifier. Old 'userId' submissions rejected. Must detect rename as breaking."
|
|
91723
95301
|
}
|
|
91724
95302
|
},
|
|
@@ -91842,7 +95420,8 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91842
95420
|
},
|
|
91843
95421
|
expected: {
|
|
91844
95422
|
has_breaking: true,
|
|
91845
|
-
risk_min:
|
|
95423
|
+
risk_min: 6,
|
|
95424
|
+
bounds_changelog: "risk_min 50 -> 6 (recalibrated 2026-07 to measured 8 on the production-faithful path - no pattern boost)",
|
|
91846
95425
|
notes: "Request-side tightening rejects previously-valid payloads. Must be caught."
|
|
91847
95426
|
}
|
|
91848
95427
|
},
|
|
@@ -91896,7 +95475,9 @@ var require_vectors_openapi_fpfn = __commonJS({
|
|
|
91896
95475
|
},
|
|
91897
95476
|
expected: {
|
|
91898
95477
|
has_breaking: false,
|
|
91899
|
-
risk_max:
|
|
95478
|
+
risk_max: 0,
|
|
95479
|
+
bounds_changelog: "risk_max 10 -> 0 (recalibrated 2026-07 to measured 0 on the oasdiff-1.11.11 pinned path)",
|
|
95480
|
+
risk_note: "safe vector scores 0 on the pinned path - max 0 catches any inflation (detection-only)",
|
|
91900
95481
|
notes: "Request-side loosening (nullable false->true, format unchanged): all previously-valid payloads stay valid. Must NOT be flagged breaking."
|
|
91901
95482
|
}
|
|
91902
95483
|
}
|
|
@@ -91997,7 +95578,7 @@ var require_mcp_schema_normalizer = __commonJS({
|
|
|
91997
95578
|
return parts.join("|");
|
|
91998
95579
|
}
|
|
91999
95580
|
function normalizeConditionals(schema, warnings = []) {
|
|
92000
|
-
|
|
95581
|
+
const result = { ...schema };
|
|
92001
95582
|
if (result.if) result.if = normalizeMcpSchema(result.if, { warnings }).canonical;
|
|
92002
95583
|
if (result.then) result.then = normalizeMcpSchema(result.then, { warnings }).canonical;
|
|
92003
95584
|
if (result.else) result.else = normalizeMcpSchema(result.else, { warnings }).canonical;
|
|
@@ -92821,6 +96402,10 @@ program.command("diff <old-spec> <new-spec>").description("Compare two OpenAPI s
|
|
|
92821
96402
|
const { diff } = require_diff();
|
|
92822
96403
|
await diff(oldSpec, newSpec, options);
|
|
92823
96404
|
});
|
|
96405
|
+
program.command("deploy-gate").description("Gate a deploy on the current { environment, artifact } using a preflight receipt (phase-1 advisory)").option("--env <environment>", "Target environment (e.g. production, staging)").option("--artifact <artifact_id>", "Immutable artifact identity being deployed (content digest or commit SHA)").option("--receipt <file>", "Path to the deploy-scoped receipt JSON produced by preflight").option("--json", "Output the binding result as JSON").option("--enforce", "Treat the step as enforcing: attest ENFORCING and exit non-zero on a gate failure").action(async (options) => {
|
|
96406
|
+
const { runDeployGate } = require_deploy_gate2();
|
|
96407
|
+
await runDeployGate(options);
|
|
96408
|
+
});
|
|
92824
96409
|
program.command("init [template]").description("Generate a .coderifts.yml from a policy template (startup, growth, fintech, public-api, microservices)").action(async (template) => {
|
|
92825
96410
|
const { init } = require_init();
|
|
92826
96411
|
await init(template);
|
|
@@ -92880,5 +96465,5 @@ mime-types/index.js:
|
|
|
92880
96465
|
*)
|
|
92881
96466
|
|
|
92882
96467
|
axios/dist/node/axios.cjs:
|
|
92883
|
-
(*! Axios v1.
|
|
96468
|
+
(*! Axios v1.18.1 Copyright (c) 2026 Matt Zabriskie and contributors *)
|
|
92884
96469
|
*/
|