agent-contracts 0.19.3 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1757,7 +1757,7 @@ declare function buildAuditContext(auditType: AuditType, dsl: Dsl, config: Resol
1757
1757
 
1758
1758
  declare function formatAuditResult(r: AuditRunResult, format: OutputFormat): string;
1759
1759
  declare function formatAuditResults(results: AuditRunResult[], format: OutputFormat): string;
1760
- declare function computeExitCode(results: AuditRunResult[]): number;
1760
+ declare function computeExitCode(results: AuditRunResult[], failOn?: string): number;
1761
1761
 
1762
1762
  interface ResolvedCheck {
1763
1763
  guardrail_id: string;
package/dist/index.js CHANGED
@@ -55080,16 +55080,22 @@ function formatAuditResults(results, format2) {
55080
55080
  }
55081
55081
  return results.map((r3) => formatAuditResult(r3, format2)).join("\n\n");
55082
55082
  }
55083
- function computeExitCode(results) {
55083
+ function computeExitCode(results, failOn) {
55084
55084
  for (const r3 of results) {
55085
55085
  if (r3.status === "error") {
55086
- if (r3.errorMessage?.includes("not installed") || r3.errorMessage?.includes("adapter")) return 3;
55087
- return 2;
55086
+ if (r3.errorMessage?.includes("not installed")) return 11;
55087
+ if (r3.errorMessage?.includes("adapter") || r3.errorMessage?.includes("API")) return 12;
55088
+ return 1;
55088
55089
  }
55089
55090
  }
55091
+ const severityRank = { info: 0, warning: 1, error: 2, critical: 3 };
55092
+ const threshold = severityRank[failOn ?? "critical"] ?? 3;
55090
55093
  for (const r3 of results) {
55091
- if (r3.data?.critical_gaps && r3.data.critical_gaps.some((g2) => g2.severity === "critical")) {
55092
- return 1;
55094
+ if (r3.data?.critical_gaps) {
55095
+ for (const gap of r3.data.critical_gaps) {
55096
+ const rank = severityRank[gap.severity ?? ""] ?? 0;
55097
+ if (rank >= threshold) return 10;
55098
+ }
55093
55099
  }
55094
55100
  }
55095
55101
  return 0;