agent-inspect 6.29.3 → 6.29.5
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/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/docs/LIMITATIONS.md +2 -1
- package/docs/RUN-COMPARABILITY.md +54 -0
- package/docs/TRACE-CONTRACTS.md +1 -1
- package/package.json +9 -5
- package/packages/cli/dist/{chunk-TBTRH7KY.mjs → chunk-XWQEHKGB.mjs} +44 -31
- package/packages/cli/dist/chunk-XWQEHKGB.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +197 -72
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +146 -43
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-PGESGQ7G.mjs → src-XNC4EUN3.mjs} +3 -3
- package/packages/cli/dist/{src-PGESGQ7G.mjs.map → src-XNC4EUN3.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +23 -11
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +10 -10
- package/packages/core/dist/advanced.d.ts +10 -10
- package/packages/core/dist/advanced.mjs +18 -16
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +45 -31
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.d.cts +7 -7
- package/packages/core/dist/checks.d.ts +7 -7
- package/packages/core/dist/checks.mjs +5 -5
- package/packages/core/dist/{chunk-7LSVGXCN.mjs → chunk-26YJSETN.mjs} +3 -3
- package/packages/core/dist/{chunk-7LSVGXCN.mjs.map → chunk-26YJSETN.mjs.map} +1 -1
- package/packages/core/dist/{chunk-5M4QUYFH.mjs → chunk-BGF5JDJN.mjs} +3 -3
- package/packages/core/dist/{chunk-5M4QUYFH.mjs.map → chunk-BGF5JDJN.mjs.map} +1 -1
- package/packages/core/dist/{chunk-3I6KX32E.mjs → chunk-EE5Z2GQ3.mjs} +20 -12
- package/packages/core/dist/chunk-EE5Z2GQ3.mjs.map +1 -0
- package/packages/core/dist/{chunk-FKVCTIP6.mjs → chunk-KWBO36PH.mjs} +4 -4
- package/packages/core/dist/{chunk-FKVCTIP6.mjs.map → chunk-KWBO36PH.mjs.map} +1 -1
- package/packages/core/dist/{chunk-BMRK6XHO.mjs → chunk-PBNBQRXV.mjs} +4 -4
- package/packages/core/dist/{chunk-BMRK6XHO.mjs.map → chunk-PBNBQRXV.mjs.map} +1 -1
- package/packages/core/dist/{chunk-KNRY24RS.mjs → chunk-Q5SLKV2Y.mjs} +3 -3
- package/packages/core/dist/{chunk-KNRY24RS.mjs.map → chunk-Q5SLKV2Y.mjs.map} +1 -1
- package/packages/core/dist/{chunk-XPDNO3KH.mjs → chunk-TU47EKKS.mjs} +29 -34
- package/packages/core/dist/chunk-TU47EKKS.mjs.map +1 -0
- package/packages/core/dist/{chunk-AT7TICCQ.mjs → chunk-WN5PT4GV.mjs} +4 -4
- package/packages/core/dist/{chunk-AT7TICCQ.mjs.map → chunk-WN5PT4GV.mjs.map} +1 -1
- package/packages/core/dist/{chunk-DZBNXCLA.mjs → chunk-ZFJ2ICTC.mjs} +5 -5
- package/packages/core/dist/{chunk-DZBNXCLA.mjs.map → chunk-ZFJ2ICTC.mjs.map} +1 -1
- package/packages/core/dist/{context-B8zzsmjX.d.ts → context-B7DqUmsJ.d.ts} +3 -3
- package/packages/core/dist/{context-BhaVHtOT.d.cts → context-rR_jW9TH.d.cts} +3 -3
- package/packages/core/dist/diff.d.cts +3 -3
- package/packages/core/dist/diff.d.ts +3 -3
- package/packages/core/dist/exporters.d.cts +3 -3
- package/packages/core/dist/exporters.d.ts +3 -3
- package/packages/core/dist/exporters.mjs +5 -5
- package/packages/core/dist/{index-BT3KcO6-.d.cts → index-Cdww9h50.d.cts} +2 -2
- package/packages/core/dist/{index-BaQ48jrq.d.cts → index-DKv7esIo.d.cts} +4 -4
- package/packages/core/dist/{index-CrnEOoRu.d.ts → index-DvSbXNot.d.ts} +4 -4
- package/packages/core/dist/{index-reskZCVW.d.ts → index-xUbdpcrP.d.ts} +2 -2
- package/packages/core/dist/index.cjs +11 -9
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +6 -6
- package/packages/core/dist/index.d.ts +6 -6
- package/packages/core/dist/index.mjs +6 -6
- package/packages/core/dist/{inspect-event-CDqjcrG_.d.cts → inspect-event-ClM5Z8om.d.cts} +6 -1
- package/packages/core/dist/{inspect-event-CDqjcrG_.d.ts → inspect-event-ClM5Z8om.d.ts} +6 -1
- package/packages/core/dist/{log-config-DcjV8ZjF.d.cts → log-config-CyRGaaWd.d.cts} +1 -1
- package/packages/core/dist/{log-config-N_c5AE09.d.ts → log-config-DAV_sR9A.d.ts} +1 -1
- package/packages/core/dist/logs.d.cts +3 -3
- package/packages/core/dist/logs.d.ts +3 -3
- package/packages/core/dist/{persisted-inspect-event-BMwvGIB8.d.ts → persisted-inspect-event-DG02LhEP.d.ts} +1 -1
- package/packages/core/dist/{persisted-inspect-event-DPaCiars.d.cts → persisted-inspect-event-q2ViiBW6.d.cts} +1 -1
- package/packages/core/dist/persisted.cjs +11 -9
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.d.cts +5 -5
- package/packages/core/dist/persisted.d.ts +5 -5
- package/packages/core/dist/persisted.mjs +3 -3
- package/packages/core/dist/readers.cjs +11 -9
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.d.cts +3 -3
- package/packages/core/dist/readers.d.ts +3 -3
- package/packages/core/dist/readers.mjs +4 -4
- package/packages/core/dist/{types-C5Y8Idle.d.ts → types-BX1EPji1.d.ts} +1 -1
- package/packages/core/dist/{types-BSzhK7Z1.d.cts → types-bwL8cBv5.d.cts} +1 -1
- package/packages/core/dist/writers.cjs +11 -9
- package/packages/core/dist/writers.cjs.map +1 -1
- package/packages/core/dist/writers.d.cts +2 -2
- package/packages/core/dist/writers.d.ts +2 -2
- package/packages/core/dist/writers.mjs +3 -3
- package/packages/cli/dist/chunk-TBTRH7KY.mjs.map +0 -1
- package/packages/core/dist/chunk-3I6KX32E.mjs.map +0 -1
- package/packages/core/dist/chunk-XPDNO3KH.mjs.map +0 -1
|
@@ -330,6 +330,28 @@ var init_types = __esm({
|
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
332
|
|
|
333
|
+
// packages/core/src/types/inspect-event.ts
|
|
334
|
+
function isAttributionConfidence(value) {
|
|
335
|
+
return typeof value === "string" && ATTRIBUTION_CONFIDENCES.includes(value);
|
|
336
|
+
}
|
|
337
|
+
var ATTRIBUTION_CONFIDENCES, ATTRIBUTION_CONFIDENCE_RANK;
|
|
338
|
+
var init_inspect_event = __esm({
|
|
339
|
+
"packages/core/src/types/inspect-event.ts"() {
|
|
340
|
+
ATTRIBUTION_CONFIDENCES = [
|
|
341
|
+
"unknown",
|
|
342
|
+
"heuristic",
|
|
343
|
+
"correlated",
|
|
344
|
+
"explicit"
|
|
345
|
+
];
|
|
346
|
+
ATTRIBUTION_CONFIDENCE_RANK = {
|
|
347
|
+
unknown: 0,
|
|
348
|
+
heuristic: 1,
|
|
349
|
+
correlated: 2,
|
|
350
|
+
explicit: 3
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
333
355
|
// packages/core/src/types/persisted-inspect-event.ts
|
|
334
356
|
function isRecord3(value) {
|
|
335
357
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -352,9 +374,6 @@ function isOptionalNonNegativeNumber(value) {
|
|
|
352
374
|
function isInspectKind(value) {
|
|
353
375
|
return typeof value === "string" && INSPECT_KINDS.includes(value);
|
|
354
376
|
}
|
|
355
|
-
function isAttributionConfidence(value) {
|
|
356
|
-
return typeof value === "string" && ATTRIBUTION_CONFIDENCES.includes(value);
|
|
357
|
-
}
|
|
358
377
|
function isPersistedEventSourceType(value) {
|
|
359
378
|
return typeof value === "string" && PERSISTED_EVENT_SOURCE_TYPES.includes(value);
|
|
360
379
|
}
|
|
@@ -429,9 +448,10 @@ function isPersistedInspectEvent(value) {
|
|
|
429
448
|
}
|
|
430
449
|
return true;
|
|
431
450
|
}
|
|
432
|
-
var INSPECT_KINDS,
|
|
451
|
+
var INSPECT_KINDS, PERSISTED_EVENT_SOURCE_TYPES, PERSISTED_EVENT_STATUSES;
|
|
433
452
|
var init_persisted_inspect_event = __esm({
|
|
434
453
|
"packages/core/src/types/persisted-inspect-event.ts"() {
|
|
454
|
+
init_inspect_event();
|
|
435
455
|
INSPECT_KINDS = [
|
|
436
456
|
"RUN",
|
|
437
457
|
"AGENT",
|
|
@@ -446,12 +466,6 @@ var init_persisted_inspect_event = __esm({
|
|
|
446
466
|
"LOG",
|
|
447
467
|
"OUTCOME"
|
|
448
468
|
];
|
|
449
|
-
ATTRIBUTION_CONFIDENCES = [
|
|
450
|
-
"explicit",
|
|
451
|
-
"correlated",
|
|
452
|
-
"heuristic",
|
|
453
|
-
"unknown"
|
|
454
|
-
];
|
|
455
469
|
PERSISTED_EVENT_SOURCE_TYPES = [
|
|
456
470
|
"manual",
|
|
457
471
|
"json-log",
|
|
@@ -5442,7 +5456,7 @@ function flattenNodes(nodes) {
|
|
|
5442
5456
|
function buildFacts2(input3, selectedRun) {
|
|
5443
5457
|
const scopedRuns = selectedRun ? [selectedRun] : input3.read.runs;
|
|
5444
5458
|
const scopedRunIds = new Set(scopedRuns.map((run) => run.runId));
|
|
5445
|
-
const
|
|
5459
|
+
const scopedEvents2 = selectedRun === void 0 ? input3.read.events : input3.read.events.filter((event) => scopedRunIds.has(event.runId));
|
|
5446
5460
|
const nodes = flattenNodes(scopedRuns.flatMap((run) => run.children));
|
|
5447
5461
|
const nodesByEventId = /* @__PURE__ */ new Map();
|
|
5448
5462
|
const childrenByParentId = /* @__PURE__ */ new Map();
|
|
@@ -5455,11 +5469,11 @@ function buildFacts2(input3, selectedRun) {
|
|
|
5455
5469
|
childrenByParentId.set(parentId, children);
|
|
5456
5470
|
}
|
|
5457
5471
|
}
|
|
5458
|
-
const projection = projectLogicalEvents(
|
|
5472
|
+
const projection = projectLogicalEvents(scopedEvents2);
|
|
5459
5473
|
return {
|
|
5460
5474
|
format: input3.read.format,
|
|
5461
5475
|
runs: Object.freeze([...input3.read.runs]),
|
|
5462
|
-
events: Object.freeze([...
|
|
5476
|
+
events: Object.freeze([...scopedEvents2]),
|
|
5463
5477
|
logicalEvents: projection.logicalEvents,
|
|
5464
5478
|
logicalProjectionDiagnostics: projection.diagnostics,
|
|
5465
5479
|
readerWarnings: Object.freeze([...input3.read.warnings]),
|
|
@@ -6293,6 +6307,12 @@ function createStructureCycleRule() {
|
|
|
6293
6307
|
};
|
|
6294
6308
|
}
|
|
6295
6309
|
function createStructureRelationshipRule(options = {}) {
|
|
6310
|
+
if (options.minConfidence !== void 0 && !isAttributionConfidence(options.minConfidence)) {
|
|
6311
|
+
throw new TypeError(
|
|
6312
|
+
`createStructureRelationshipRule: minConfidence must be one of: ${ATTRIBUTION_CONFIDENCES.join(", ")}.`
|
|
6313
|
+
);
|
|
6314
|
+
}
|
|
6315
|
+
const minConfidence = options.minConfidence;
|
|
6296
6316
|
return {
|
|
6297
6317
|
id: "structure.relationship",
|
|
6298
6318
|
category: "structure",
|
|
@@ -6300,18 +6320,21 @@ function createStructureRelationshipRule(options = {}) {
|
|
|
6300
6320
|
evaluate(context) {
|
|
6301
6321
|
const byId = eventMap(semanticEvents(context));
|
|
6302
6322
|
const findings = [];
|
|
6303
|
-
const minConfidence = options.minConfidence;
|
|
6304
6323
|
for (const event of semanticEvents(context)) {
|
|
6305
|
-
if (minConfidence
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6324
|
+
if (minConfidence) {
|
|
6325
|
+
const eventRank = CONFIDENCE_RANK[event.confidence] ?? CONFIDENCE_RANK.unknown;
|
|
6326
|
+
const minRank = CONFIDENCE_RANK[minConfidence];
|
|
6327
|
+
if (eventRank < minRank) {
|
|
6328
|
+
findings.push(
|
|
6329
|
+
failFinding(
|
|
6330
|
+
"structure.relationship",
|
|
6331
|
+
`Event confidence ${event.confidence} is below ${minConfidence}.`,
|
|
6332
|
+
[eventEvidence(event, "confidence")],
|
|
6333
|
+
{ minConfidence },
|
|
6334
|
+
event.confidence
|
|
6335
|
+
)
|
|
6336
|
+
);
|
|
6337
|
+
}
|
|
6315
6338
|
}
|
|
6316
6339
|
if (!event.parentId) continue;
|
|
6317
6340
|
if (event.parentId === event.eventId) {
|
|
@@ -6882,6 +6905,7 @@ function runTraceChecks(input3, options = {}) {
|
|
|
6882
6905
|
var SEVERITY_RANK, STATUS_RANK, CONFIDENCE_RANK, DEFAULT_SENSITIVE_KEYS, DEFAULT_RAW_CONTENT_KEYS, DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES, SAFE_USAGE_LEAF_KEYS, DEFAULT_SECRET_PATTERNS;
|
|
6883
6906
|
var init_checks2 = __esm({
|
|
6884
6907
|
"packages/core/src/checks/index.ts"() {
|
|
6908
|
+
init_inspect_event();
|
|
6885
6909
|
init_programmatic();
|
|
6886
6910
|
init_outcomes();
|
|
6887
6911
|
init_sensitive_key();
|
|
@@ -6901,12 +6925,7 @@ var init_checks2 = __esm({
|
|
|
6901
6925
|
warning: 1,
|
|
6902
6926
|
pass: 2
|
|
6903
6927
|
};
|
|
6904
|
-
CONFIDENCE_RANK =
|
|
6905
|
-
unknown: 0,
|
|
6906
|
-
heuristic: 1,
|
|
6907
|
-
correlated: 2,
|
|
6908
|
-
explicit: 3
|
|
6909
|
-
};
|
|
6928
|
+
CONFIDENCE_RANK = ATTRIBUTION_CONFIDENCE_RANK;
|
|
6910
6929
|
DEFAULT_SENSITIVE_KEYS = DEFAULT_CREDENTIAL_SENSITIVE_KEYS;
|
|
6911
6930
|
DEFAULT_RAW_CONTENT_KEYS = [
|
|
6912
6931
|
"body",
|
|
@@ -8025,8 +8044,9 @@ ${nav}
|
|
|
8025
8044
|
<p>Artifact status: <span class="badge ${statusClass(input3.assessmentStatus)}">${escapeHtml(input3.assessmentStatus)}</span>
|
|
8026
8045
|
${input3.sourceStatus !== void 0 ? ` \xB7 Source status: <span class="badge ${statusClass(input3.sourceStatus)}">${escapeHtml(input3.sourceStatus)}</span>` : ""}</p>
|
|
8027
8046
|
<p>Profile: <code>${escapeHtml(input3.redactionProfile)}</code> \xB7 Verification: <code>${escapeHtml(input3.verificationPolicy)}</code></p>
|
|
8028
|
-
|
|
8029
|
-
<p
|
|
8047
|
+
${input3.contractBinding !== void 0 ? ` <p>Contract binding: <code>${escapeHtml(input3.contractBinding.status)}</code>${input3.contractBinding.ruleCount !== void 0 ? ` \xB7 Rules: <code>${escapeHtml(String(input3.contractBinding.ruleCount))}</code>` : ""}${input3.contractBinding.sha256 !== void 0 ? ` \xB7 Digest: <code>${escapeHtml(input3.contractBinding.sha256.slice(0, 16))}\u2026</code>` : ""}</p>${input3.contractBinding.note !== void 0 && input3.contractBinding.note.trim() !== "" ? `
|
|
8048
|
+
<p class="muted">${escapeHtml(input3.contractBinding.note)}</p>` : ""}
|
|
8049
|
+
` : ""} <p>Generator: <code>${escapeHtml(input3.generatorName)}@${escapeHtml(input3.generatorVersion)}</code>
|
|
8030
8050
|
${input3.createdAt ? ` \xB7 Created: <code>${escapeHtml(input3.createdAt)}</code>` : ""}</p>
|
|
8031
8051
|
<h3>Runs</h3>
|
|
8032
8052
|
<ul class="runs">${runList}</ul>
|
|
@@ -13272,6 +13292,7 @@ var init_advanced = __esm({
|
|
|
13272
13292
|
init_terminal();
|
|
13273
13293
|
init_utils();
|
|
13274
13294
|
init_types();
|
|
13295
|
+
init_inspect_event();
|
|
13275
13296
|
init_storage();
|
|
13276
13297
|
init_read_trace();
|
|
13277
13298
|
init_trace_directory();
|
|
@@ -13758,7 +13779,7 @@ var init_src = __esm({
|
|
|
13758
13779
|
});
|
|
13759
13780
|
|
|
13760
13781
|
// package.json
|
|
13761
|
-
var version = "6.29.
|
|
13782
|
+
var version = "6.29.5";
|
|
13762
13783
|
|
|
13763
13784
|
// packages/cli/src/list.ts
|
|
13764
13785
|
init_advanced();
|
|
@@ -18438,6 +18459,7 @@ async function loadRedactionPolicy(policyPath) {
|
|
|
18438
18459
|
|
|
18439
18460
|
// packages/core/src/entries/checks.ts
|
|
18440
18461
|
init_checks2();
|
|
18462
|
+
init_inspect_event();
|
|
18441
18463
|
|
|
18442
18464
|
// packages/cli/src/trace-input.ts
|
|
18443
18465
|
init_advanced();
|
|
@@ -19806,12 +19828,22 @@ function open2(ruleId, message, evidence, severity = "error") {
|
|
|
19806
19828
|
};
|
|
19807
19829
|
}
|
|
19808
19830
|
function isToolEvent(event) {
|
|
19831
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
19832
|
+
if (kind === "tool") return true;
|
|
19833
|
+
if (kind === "llm" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
19834
|
+
return false;
|
|
19835
|
+
}
|
|
19809
19836
|
const name = event.name.toLowerCase();
|
|
19810
|
-
return
|
|
19837
|
+
return name.startsWith("tool:") || name.startsWith("function:") || name.includes(".tool.") || name.startsWith("mcp:");
|
|
19811
19838
|
}
|
|
19812
19839
|
function isLlmEvent(event) {
|
|
19840
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
19841
|
+
if (kind === "llm") return true;
|
|
19842
|
+
if (kind === "tool" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
19843
|
+
return false;
|
|
19844
|
+
}
|
|
19813
19845
|
const name = event.name.toLowerCase();
|
|
19814
|
-
return
|
|
19846
|
+
return name.startsWith("llm:") || name.includes(".llm.") || name.includes("generation");
|
|
19815
19847
|
}
|
|
19816
19848
|
function toolLabel(event) {
|
|
19817
19849
|
const attrs = event.attributes ?? {};
|
|
@@ -20256,6 +20288,14 @@ var CIRCUIT_ALIASES = {
|
|
|
20256
20288
|
"runaway-llm-loop": "circuit.runaway-llm-loop",
|
|
20257
20289
|
"excessive-branch-width": "circuit.excessive-branch-width"
|
|
20258
20290
|
};
|
|
20291
|
+
var KNOWN_CIRCUIT_RULES = /* @__PURE__ */ new Set([
|
|
20292
|
+
...Object.values(CIRCUIT_ALIASES),
|
|
20293
|
+
...ALL_RULES
|
|
20294
|
+
]);
|
|
20295
|
+
var KNOWN_GUARDRAIL_RULES = /* @__PURE__ */ new Set([
|
|
20296
|
+
...Object.values(GUARDRAIL_ALIASES),
|
|
20297
|
+
...ALL_RULES2
|
|
20298
|
+
]);
|
|
20259
20299
|
function parseGuardrailRules(values) {
|
|
20260
20300
|
if (!values?.length) return void 0;
|
|
20261
20301
|
return values.map((value) => {
|
|
@@ -20318,16 +20358,21 @@ function eventToCircuit(event) {
|
|
|
20318
20358
|
status: event.status
|
|
20319
20359
|
};
|
|
20320
20360
|
}
|
|
20321
|
-
function
|
|
20361
|
+
function scopedEvents(read, runId) {
|
|
20362
|
+
if (runId === void 0) return [...read.events];
|
|
20363
|
+
return read.events.filter((event) => event.runId === runId);
|
|
20364
|
+
}
|
|
20365
|
+
function collectGuardrailInputs(events) {
|
|
20322
20366
|
const inputs = [];
|
|
20323
|
-
for (const event of
|
|
20367
|
+
for (const event of events) {
|
|
20324
20368
|
const attrs = event.attributes ?? {};
|
|
20325
20369
|
for (const key of ["output", "answer", "text", "content", "message"]) {
|
|
20326
20370
|
const value = attrs[key];
|
|
20327
20371
|
if (typeof value === "string") inputs.push({ text: value });
|
|
20328
20372
|
else if (value !== void 0) inputs.push({ value });
|
|
20329
20373
|
}
|
|
20330
|
-
|
|
20374
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
20375
|
+
if (kind === "tool" || event.name.startsWith("tool:")) {
|
|
20331
20376
|
inputs.push({
|
|
20332
20377
|
toolName: String(attrs.toolName ?? attrs.tool ?? event.name),
|
|
20333
20378
|
toolArgs: attrs.arguments ?? attrs.args ?? attrs.input
|
|
@@ -20336,6 +20381,21 @@ function collectGuardrailInputs(read) {
|
|
|
20336
20381
|
}
|
|
20337
20382
|
return inputs;
|
|
20338
20383
|
}
|
|
20384
|
+
function classifyExtensionExecution(findings, errored) {
|
|
20385
|
+
if (errored) return "error";
|
|
20386
|
+
if (findings.some((finding) => finding.status === "fail")) return "fail";
|
|
20387
|
+
if (findings.some((finding) => finding.status === "warning")) return "warning";
|
|
20388
|
+
return "pass";
|
|
20389
|
+
}
|
|
20390
|
+
function extensionExecution(ruleId, findings, options) {
|
|
20391
|
+
return {
|
|
20392
|
+
ruleId,
|
|
20393
|
+
category: "safety",
|
|
20394
|
+
status: classifyExtensionExecution(findings, options.errored === true),
|
|
20395
|
+
findingCount: findings.length,
|
|
20396
|
+
...options.runId !== void 0 ? { runId: options.runId } : {}
|
|
20397
|
+
};
|
|
20398
|
+
}
|
|
20339
20399
|
var DEFAULT_GUARDRAIL_OPTIONS = {
|
|
20340
20400
|
bannedPhrase: { phrases: ["delete all data", "ignore all instructions"] },
|
|
20341
20401
|
promptInjection: {},
|
|
@@ -20352,53 +20412,116 @@ var DEFAULT_CIRCUIT_OPTIONS = {
|
|
|
20352
20412
|
};
|
|
20353
20413
|
function mergeSafetyExtensions(result, read, options) {
|
|
20354
20414
|
const findings = [...result.findings];
|
|
20415
|
+
const ruleExecutions = [...result.ruleExecutions ?? []];
|
|
20355
20416
|
let failed = result.summary.failed;
|
|
20356
20417
|
let warnings = result.summary.warnings;
|
|
20357
20418
|
let passed = result.summary.passed;
|
|
20419
|
+
let errors = result.summary.errors;
|
|
20420
|
+
const events = scopedEvents(read, options.runId);
|
|
20421
|
+
const runId = options.runId;
|
|
20358
20422
|
const guardrailRules = parseGuardrailRules(options.guardrails);
|
|
20359
20423
|
if (guardrailRules) {
|
|
20360
|
-
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20424
|
+
const inputs = collectGuardrailInputs(events);
|
|
20425
|
+
for (const ruleId of guardrailRules) {
|
|
20426
|
+
if (!KNOWN_GUARDRAIL_RULES.has(ruleId)) {
|
|
20427
|
+
const finding = {
|
|
20428
|
+
ruleId,
|
|
20429
|
+
severity: "error",
|
|
20430
|
+
status: "fail",
|
|
20431
|
+
message: `Unknown guardrail rule: ${ruleId}.`,
|
|
20432
|
+
evidence: []
|
|
20433
|
+
};
|
|
20367
20434
|
findings.push(finding);
|
|
20368
|
-
|
|
20369
|
-
|
|
20370
|
-
|
|
20435
|
+
failed += 1;
|
|
20436
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20437
|
+
errors += 1;
|
|
20438
|
+
continue;
|
|
20439
|
+
}
|
|
20440
|
+
const ruleFindings = [];
|
|
20441
|
+
if (inputs.length === 0) {
|
|
20442
|
+
ruleExecutions.push(extensionExecution(ruleId, [], { runId }));
|
|
20443
|
+
continue;
|
|
20444
|
+
}
|
|
20445
|
+
for (const input3 of inputs) {
|
|
20446
|
+
const run = runGuardrails(input3, {
|
|
20447
|
+
...DEFAULT_GUARDRAIL_OPTIONS,
|
|
20448
|
+
rules: [ruleId]
|
|
20449
|
+
});
|
|
20450
|
+
for (const item of run.results) {
|
|
20451
|
+
const finding = guardrailFinding(item);
|
|
20452
|
+
ruleFindings.push(finding);
|
|
20453
|
+
findings.push(finding);
|
|
20454
|
+
if (finding.status === "fail") failed += 1;
|
|
20455
|
+
else if (finding.status === "warning") warnings += 1;
|
|
20456
|
+
else passed += 1;
|
|
20457
|
+
}
|
|
20371
20458
|
}
|
|
20459
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
20372
20460
|
}
|
|
20373
20461
|
}
|
|
20374
20462
|
const circuitRules = parseCircuitRules(options.circuits);
|
|
20375
20463
|
if (circuitRules) {
|
|
20376
|
-
const
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
|
|
20385
|
-
|
|
20464
|
+
const projected = projectLogicalEvents(events);
|
|
20465
|
+
const circuitEvents = projected.logicalEvents.map(eventToCircuit);
|
|
20466
|
+
for (const ruleId of circuitRules) {
|
|
20467
|
+
if (!KNOWN_CIRCUIT_RULES.has(ruleId)) {
|
|
20468
|
+
const finding = {
|
|
20469
|
+
ruleId,
|
|
20470
|
+
severity: "error",
|
|
20471
|
+
status: "fail",
|
|
20472
|
+
message: `Unknown circuit rule: ${ruleId}.`,
|
|
20473
|
+
evidence: []
|
|
20474
|
+
};
|
|
20475
|
+
findings.push(finding);
|
|
20476
|
+
failed += 1;
|
|
20477
|
+
errors += 1;
|
|
20478
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20479
|
+
continue;
|
|
20480
|
+
}
|
|
20481
|
+
const circuitRun = runCircuits(circuitEvents, {
|
|
20482
|
+
...DEFAULT_CIRCUIT_OPTIONS,
|
|
20483
|
+
rules: [ruleId]
|
|
20484
|
+
});
|
|
20485
|
+
if (circuitRun.results.length === 0) {
|
|
20486
|
+
const finding = {
|
|
20487
|
+
ruleId,
|
|
20488
|
+
severity: "error",
|
|
20489
|
+
status: "fail",
|
|
20490
|
+
message: `Circuit rule ${ruleId} produced no evaluation result.`,
|
|
20491
|
+
evidence: []
|
|
20492
|
+
};
|
|
20493
|
+
findings.push(finding);
|
|
20494
|
+
failed += 1;
|
|
20495
|
+
errors += 1;
|
|
20496
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20497
|
+
continue;
|
|
20498
|
+
}
|
|
20499
|
+
const ruleFindings = [];
|
|
20500
|
+
for (const item of circuitRun.results) {
|
|
20501
|
+
const finding = circuitFinding(item);
|
|
20502
|
+
ruleFindings.push(finding);
|
|
20503
|
+
findings.push(finding);
|
|
20504
|
+
if (finding.status === "fail") failed += 1;
|
|
20505
|
+
else if (finding.status === "warning") warnings += 1;
|
|
20506
|
+
else passed += 1;
|
|
20507
|
+
}
|
|
20508
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
20386
20509
|
}
|
|
20387
20510
|
}
|
|
20388
|
-
const
|
|
20511
|
+
const status = result.status === "error" || errors > 0 ? "error" : failed > 0 ? "fail" : result.status;
|
|
20389
20512
|
return {
|
|
20390
20513
|
...result,
|
|
20391
|
-
ok,
|
|
20392
|
-
status
|
|
20514
|
+
ok: status === "pass",
|
|
20515
|
+
status,
|
|
20393
20516
|
summary: {
|
|
20394
20517
|
passed,
|
|
20395
20518
|
failed,
|
|
20396
20519
|
warnings,
|
|
20397
|
-
errors
|
|
20398
|
-
rulesEvaluated:
|
|
20520
|
+
errors,
|
|
20521
|
+
rulesEvaluated: ruleExecutions.length
|
|
20399
20522
|
},
|
|
20400
20523
|
findings,
|
|
20401
|
-
ruleExecutions
|
|
20524
|
+
ruleExecutions
|
|
20402
20525
|
};
|
|
20403
20526
|
}
|
|
20404
20527
|
|
|
@@ -20602,7 +20725,7 @@ var SAFETY_KEYS = /* @__PURE__ */ new Set([
|
|
|
20602
20725
|
"maxFindings"
|
|
20603
20726
|
]);
|
|
20604
20727
|
var RUN_EXPECTED = /* @__PURE__ */ new Set(["ok", "error", "running"]);
|
|
20605
|
-
var
|
|
20728
|
+
var CONFIDENCE_LIST = ATTRIBUTION_CONFIDENCES.join(", ");
|
|
20606
20729
|
var CheckConfigError = class extends Error {
|
|
20607
20730
|
code;
|
|
20608
20731
|
constructor(code, message) {
|
|
@@ -20744,10 +20867,10 @@ function parseStructureSection(value) {
|
|
|
20744
20867
|
rejectUnknownKeys(record, STRUCTURE_KEYS, "checks.structure");
|
|
20745
20868
|
const out = {};
|
|
20746
20869
|
if (record.minConfidence !== void 0) {
|
|
20747
|
-
if (
|
|
20870
|
+
if (!isAttributionConfidence(record.minConfidence)) {
|
|
20748
20871
|
throw new CheckConfigError(
|
|
20749
20872
|
"AI_CHECK_CONFIG_INVALID_VALUE",
|
|
20750
|
-
`checks.structure.minConfidence must be one of:
|
|
20873
|
+
`checks.structure.minConfidence must be one of: ${CONFIDENCE_LIST}.`
|
|
20751
20874
|
);
|
|
20752
20875
|
}
|
|
20753
20876
|
out.minConfidence = record.minConfidence;
|
|
@@ -21257,7 +21380,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
21257
21380
|
read,
|
|
21258
21381
|
{
|
|
21259
21382
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
21260
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
21383
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
21384
|
+
runId: meta2.runId
|
|
21261
21385
|
}
|
|
21262
21386
|
)
|
|
21263
21387
|
);
|
|
@@ -21310,7 +21434,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
21310
21434
|
read,
|
|
21311
21435
|
{
|
|
21312
21436
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
21313
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
21437
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
21438
|
+
...options.run !== void 0 ? { runId: options.run } : {}
|
|
21314
21439
|
}
|
|
21315
21440
|
);
|
|
21316
21441
|
}
|
|
@@ -23489,10 +23614,10 @@ function selectRun4(read, runId) {
|
|
|
23489
23614
|
}
|
|
23490
23615
|
function summarizeTrace(read, run) {
|
|
23491
23616
|
const runId = run?.runId;
|
|
23492
|
-
const
|
|
23617
|
+
const scopedEvents2 = runId === void 0 ? read.events : read.events.filter((event) => event.runId === runId);
|
|
23493
23618
|
const eventsByKind = {};
|
|
23494
23619
|
const eventsByStatus = {};
|
|
23495
|
-
for (const event of
|
|
23620
|
+
for (const event of scopedEvents2) {
|
|
23496
23621
|
increment(eventsByKind, event.kind);
|
|
23497
23622
|
increment(eventsByStatus, event.status);
|
|
23498
23623
|
}
|
|
@@ -23502,7 +23627,7 @@ function summarizeTrace(read, run) {
|
|
|
23502
23627
|
...run?.status !== void 0 ? { runStatus: run.status } : {},
|
|
23503
23628
|
...run?.durationMs !== void 0 ? { runDurationMs: run.durationMs } : {},
|
|
23504
23629
|
runCount: read.runs.length,
|
|
23505
|
-
eventCount:
|
|
23630
|
+
eventCount: scopedEvents2.length,
|
|
23506
23631
|
eventsByKind: Object.fromEntries(Object.entries(eventsByKind).sort()),
|
|
23507
23632
|
eventsByStatus: Object.fromEntries(Object.entries(eventsByStatus).sort()),
|
|
23508
23633
|
readerWarnings: read.warnings.length,
|