coderifts 1.8.4 → 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/dist/cli.js +3274 -8
- package/package.json +2 -1
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",
|
|
@@ -61749,7 +61750,7 @@ var require_axios = __commonJS({
|
|
|
61749
61750
|
advertiseZstdAcceptEncoding: false,
|
|
61750
61751
|
validateStatusUndefinedResolves: true
|
|
61751
61752
|
};
|
|
61752
|
-
var
|
|
61753
|
+
var URLSearchParams2 = url.URLSearchParams;
|
|
61753
61754
|
var ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
|
61754
61755
|
var DIGIT = "0123456789";
|
|
61755
61756
|
var ALPHABET = {
|
|
@@ -61772,7 +61773,7 @@ var require_axios = __commonJS({
|
|
|
61772
61773
|
var platform$1 = {
|
|
61773
61774
|
isNode: true,
|
|
61774
61775
|
classes: {
|
|
61775
|
-
URLSearchParams,
|
|
61776
|
+
URLSearchParams: URLSearchParams2,
|
|
61776
61777
|
FormData: FormData$1,
|
|
61777
61778
|
Blob: typeof Blob !== "undefined" && Blob || null
|
|
61778
61779
|
},
|
|
@@ -65405,6 +65406,3267 @@ var require_diff = __commonJS({
|
|
|
65405
65406
|
}
|
|
65406
65407
|
});
|
|
65407
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
|
+
|
|
65408
68670
|
// src/commands/init.js
|
|
65409
68671
|
var require_init = __commonJS({
|
|
65410
68672
|
"src/commands/init.js"(exports2, module2) {
|
|
@@ -76068,7 +79330,7 @@ var require_zipWith = __commonJS({
|
|
|
76068
79330
|
});
|
|
76069
79331
|
|
|
76070
79332
|
// node_modules/rxjs/dist/cjs/index.js
|
|
76071
|
-
var
|
|
79333
|
+
var require_cjs5 = __commonJS({
|
|
76072
79334
|
"node_modules/rxjs/dist/cjs/index.js"(exports2) {
|
|
76073
79335
|
"use strict";
|
|
76074
79336
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -77385,7 +80647,7 @@ var require_run_async = __commonJS({
|
|
|
77385
80647
|
var require_utils3 = __commonJS({
|
|
77386
80648
|
"node_modules/inquirer/lib/utils/utils.js"(exports2) {
|
|
77387
80649
|
"use strict";
|
|
77388
|
-
var { from, of } =
|
|
80650
|
+
var { from, of } = require_cjs5();
|
|
77389
80651
|
var runAsync = require_run_async();
|
|
77390
80652
|
exports2.fetchAsyncQuestionProperty = function(question, prop, answers) {
|
|
77391
80653
|
if (typeof question[prop] !== "function") {
|
|
@@ -77410,7 +80672,7 @@ var require_prompt = __commonJS({
|
|
|
77410
80672
|
get: require_get2(),
|
|
77411
80673
|
set: require_set3()
|
|
77412
80674
|
};
|
|
77413
|
-
var { defer, empty, from, of } =
|
|
80675
|
+
var { defer, empty, from, of } = require_cjs5();
|
|
77414
80676
|
var { concatMap, filter, publish, reduce } = require_operators();
|
|
77415
80677
|
var runAsync = require_run_async();
|
|
77416
80678
|
var utils = require_utils3();
|
|
@@ -80124,7 +83386,7 @@ var require_base = __commonJS({
|
|
|
80124
83386
|
var require_events = __commonJS({
|
|
80125
83387
|
"node_modules/inquirer/lib/utils/events.js"(exports2, module2) {
|
|
80126
83388
|
"use strict";
|
|
80127
|
-
var { fromEvent } =
|
|
83389
|
+
var { fromEvent } = require_cjs5();
|
|
80128
83390
|
var { filter, map, share, takeUntil } = require_operators();
|
|
80129
83391
|
function normalizeKeypressEvents(value, key) {
|
|
80130
83392
|
return { value, key: key || {} };
|
|
@@ -90922,7 +94184,7 @@ var require_editor = __commonJS({
|
|
|
90922
94184
|
var { editAsync } = require_commonjs();
|
|
90923
94185
|
var Base = require_base();
|
|
90924
94186
|
var observe = require_events();
|
|
90925
|
-
var { Subject } =
|
|
94187
|
+
var { Subject } = require_cjs5();
|
|
90926
94188
|
var EditorPrompt = class extends Base {
|
|
90927
94189
|
/**
|
|
90928
94190
|
* Start the Inquiry session
|
|
@@ -93140,6 +96402,10 @@ program.command("diff <old-spec> <new-spec>").description("Compare two OpenAPI s
|
|
|
93140
96402
|
const { diff } = require_diff();
|
|
93141
96403
|
await diff(oldSpec, newSpec, options);
|
|
93142
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
|
+
});
|
|
93143
96409
|
program.command("init [template]").description("Generate a .coderifts.yml from a policy template (startup, growth, fintech, public-api, microservices)").action(async (template) => {
|
|
93144
96410
|
const { init } = require_init();
|
|
93145
96411
|
await init(template);
|