agent-inspect 6.29.4 → 6.29.6
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/CLI.md +1 -1
- package/docs/LIMITATIONS.md +1 -1
- package/docs/TRACE-CONTRACTS.md +11 -8
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-FJRUJSST.mjs → chunk-DBRMI7TC.mjs} +74 -30
- package/packages/cli/dist/chunk-DBRMI7TC.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +229 -73
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +148 -45
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-GZQVDREP.mjs → src-6CET2GW2.mjs} +3 -3
- package/packages/cli/dist/{src-GZQVDREP.mjs.map → src-6CET2GW2.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +39 -10
- 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 +15 -14
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +78 -32
- 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-XPDNO3KH.mjs → chunk-OOX25GTH.mjs} +62 -35
- package/packages/core/dist/chunk-OOX25GTH.mjs.map +1 -0
- 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-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-CrnEOoRu.d.ts → index-7hG_qggp.d.ts} +9 -4
- package/packages/core/dist/{index-BaQ48jrq.d.cts → index-CQJUNPPe.d.cts} +9 -4
- package/packages/core/dist/{index-BT3KcO6-.d.cts → index-Cdww9h50.d.cts} +2 -2
- 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-FJRUJSST.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]),
|
|
@@ -5800,6 +5814,18 @@ function limitFindings(findings, maxFindings) {
|
|
|
5800
5814
|
function hasRedactionMarker(value, markers) {
|
|
5801
5815
|
return markers.some((marker) => value.includes(marker)) || /^\[HASH:[A-Za-z0-9_-]+\]$/.test(value);
|
|
5802
5816
|
}
|
|
5817
|
+
function isFullyRedactedValue(value, markers = ["[REDACTED]", "[REDACTED:"]) {
|
|
5818
|
+
if (typeof value !== "string") return false;
|
|
5819
|
+
const trimmed = value.trim();
|
|
5820
|
+
if (trimmed.length === 0) return false;
|
|
5821
|
+
if (/^\[HASH:[A-Za-z0-9_-]+\]$/.test(trimmed)) return true;
|
|
5822
|
+
if (/^\[REDACTED:[^\]]*\]$/.test(trimmed)) return true;
|
|
5823
|
+
for (const marker of markers) {
|
|
5824
|
+
if (marker.endsWith(":")) continue;
|
|
5825
|
+
if (trimmed === marker) return true;
|
|
5826
|
+
}
|
|
5827
|
+
return false;
|
|
5828
|
+
}
|
|
5803
5829
|
function isSensitiveKey(key, sensitiveKeys) {
|
|
5804
5830
|
return isCredentialSensitiveKey(key, sensitiveKeys);
|
|
5805
5831
|
}
|
|
@@ -6118,8 +6144,26 @@ function createToolUsageRule(options) {
|
|
|
6118
6144
|
const findings = [];
|
|
6119
6145
|
for (const required of options.required ?? []) {
|
|
6120
6146
|
if (!nameSet.has(required)) {
|
|
6147
|
+
const otherKinds = [
|
|
6148
|
+
...new Set(
|
|
6149
|
+
context.events.filter((event) => {
|
|
6150
|
+
const kind = typeof event.kind === "string" ? event.kind.toUpperCase() : "";
|
|
6151
|
+
if (kind === "TOOL") return false;
|
|
6152
|
+
return resolveCanonicalToolName(event) === required || event.name === required || event.name === `tool:${required}` || event.name.endsWith(`:${required}`);
|
|
6153
|
+
}).map(
|
|
6154
|
+
(event) => typeof event.kind === "string" ? event.kind.toUpperCase() : "UNKNOWN"
|
|
6155
|
+
)
|
|
6156
|
+
)
|
|
6157
|
+
].sort();
|
|
6158
|
+
const hint = otherKinds.length > 0 ? ` Required name appears under non-TOOL kind(s): ${otherKinds.join(", ")}. tools.required / requiredOrder match TOOL events only.` : "";
|
|
6121
6159
|
findings.push(
|
|
6122
|
-
failFinding(
|
|
6160
|
+
failFinding(
|
|
6161
|
+
"tool.usage",
|
|
6162
|
+
`Required tool ${required} did not appear.${hint}`,
|
|
6163
|
+
runEvidence(context.selectedRun),
|
|
6164
|
+
required,
|
|
6165
|
+
names
|
|
6166
|
+
)
|
|
6123
6167
|
);
|
|
6124
6168
|
}
|
|
6125
6169
|
}
|
|
@@ -6293,6 +6337,12 @@ function createStructureCycleRule() {
|
|
|
6293
6337
|
};
|
|
6294
6338
|
}
|
|
6295
6339
|
function createStructureRelationshipRule(options = {}) {
|
|
6340
|
+
if (options.minConfidence !== void 0 && !isAttributionConfidence(options.minConfidence)) {
|
|
6341
|
+
throw new TypeError(
|
|
6342
|
+
`createStructureRelationshipRule: minConfidence must be one of: ${ATTRIBUTION_CONFIDENCES.join(", ")}.`
|
|
6343
|
+
);
|
|
6344
|
+
}
|
|
6345
|
+
const minConfidence = options.minConfidence;
|
|
6296
6346
|
return {
|
|
6297
6347
|
id: "structure.relationship",
|
|
6298
6348
|
category: "structure",
|
|
@@ -6300,18 +6350,21 @@ function createStructureRelationshipRule(options = {}) {
|
|
|
6300
6350
|
evaluate(context) {
|
|
6301
6351
|
const byId = eventMap(semanticEvents(context));
|
|
6302
6352
|
const findings = [];
|
|
6303
|
-
const minConfidence = options.minConfidence;
|
|
6304
6353
|
for (const event of semanticEvents(context)) {
|
|
6305
|
-
if (minConfidence
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6354
|
+
if (minConfidence) {
|
|
6355
|
+
const eventRank = CONFIDENCE_RANK[event.confidence] ?? CONFIDENCE_RANK.unknown;
|
|
6356
|
+
const minRank = CONFIDENCE_RANK[minConfidence];
|
|
6357
|
+
if (eventRank < minRank) {
|
|
6358
|
+
findings.push(
|
|
6359
|
+
failFinding(
|
|
6360
|
+
"structure.relationship",
|
|
6361
|
+
`Event confidence ${event.confidence} is below ${minConfidence}.`,
|
|
6362
|
+
[eventEvidence(event, "confidence")],
|
|
6363
|
+
{ minConfidence },
|
|
6364
|
+
event.confidence
|
|
6365
|
+
)
|
|
6366
|
+
);
|
|
6367
|
+
}
|
|
6315
6368
|
}
|
|
6316
6369
|
if (!event.parentId) continue;
|
|
6317
6370
|
if (event.parentId === event.eventId) {
|
|
@@ -6475,6 +6528,7 @@ function createSafetyRedactionRule(options = {}) {
|
|
|
6475
6528
|
function createSafetyRawContentRule(options = {}) {
|
|
6476
6529
|
const forbiddenKeys = options.forbiddenKeys ?? DEFAULT_RAW_CONTENT_KEYS;
|
|
6477
6530
|
const safePathPrefixes = options.safePathPrefixes ?? DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES;
|
|
6531
|
+
const markers = options.redactedMarkers ?? ["[REDACTED]", "[REDACTED:"];
|
|
6478
6532
|
return {
|
|
6479
6533
|
id: "safety.rawPrompt",
|
|
6480
6534
|
category: "safety",
|
|
@@ -6485,6 +6539,7 @@ function createSafetyRawContentRule(options = {}) {
|
|
|
6485
6539
|
for (const entry of eventValueEntries(event, { includeSummaries: options.includeSummaries })) {
|
|
6486
6540
|
const key = entry.key ?? lastPathSegment(entry.path);
|
|
6487
6541
|
if (!isRawContentPath(entry.path, key, forbiddenKeys, safePathPrefixes)) continue;
|
|
6542
|
+
if (isFullyRedactedValue(entry.value, markers)) continue;
|
|
6488
6543
|
findings.push(
|
|
6489
6544
|
failFinding(
|
|
6490
6545
|
"safety.rawPrompt",
|
|
@@ -6882,6 +6937,7 @@ function runTraceChecks(input3, options = {}) {
|
|
|
6882
6937
|
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
6938
|
var init_checks2 = __esm({
|
|
6884
6939
|
"packages/core/src/checks/index.ts"() {
|
|
6940
|
+
init_inspect_event();
|
|
6885
6941
|
init_programmatic();
|
|
6886
6942
|
init_outcomes();
|
|
6887
6943
|
init_sensitive_key();
|
|
@@ -6901,12 +6957,7 @@ var init_checks2 = __esm({
|
|
|
6901
6957
|
warning: 1,
|
|
6902
6958
|
pass: 2
|
|
6903
6959
|
};
|
|
6904
|
-
CONFIDENCE_RANK =
|
|
6905
|
-
unknown: 0,
|
|
6906
|
-
heuristic: 1,
|
|
6907
|
-
correlated: 2,
|
|
6908
|
-
explicit: 3
|
|
6909
|
-
};
|
|
6960
|
+
CONFIDENCE_RANK = ATTRIBUTION_CONFIDENCE_RANK;
|
|
6910
6961
|
DEFAULT_SENSITIVE_KEYS = DEFAULT_CREDENTIAL_SENSITIVE_KEYS;
|
|
6911
6962
|
DEFAULT_RAW_CONTENT_KEYS = [
|
|
6912
6963
|
"body",
|
|
@@ -13273,6 +13324,7 @@ var init_advanced = __esm({
|
|
|
13273
13324
|
init_terminal();
|
|
13274
13325
|
init_utils();
|
|
13275
13326
|
init_types();
|
|
13327
|
+
init_inspect_event();
|
|
13276
13328
|
init_storage();
|
|
13277
13329
|
init_read_trace();
|
|
13278
13330
|
init_trace_directory();
|
|
@@ -13759,7 +13811,7 @@ var init_src = __esm({
|
|
|
13759
13811
|
});
|
|
13760
13812
|
|
|
13761
13813
|
// package.json
|
|
13762
|
-
var version = "6.29.
|
|
13814
|
+
var version = "6.29.6";
|
|
13763
13815
|
|
|
13764
13816
|
// packages/cli/src/list.ts
|
|
13765
13817
|
init_advanced();
|
|
@@ -18439,6 +18491,7 @@ async function loadRedactionPolicy(policyPath) {
|
|
|
18439
18491
|
|
|
18440
18492
|
// packages/core/src/entries/checks.ts
|
|
18441
18493
|
init_checks2();
|
|
18494
|
+
init_inspect_event();
|
|
18442
18495
|
|
|
18443
18496
|
// packages/cli/src/trace-input.ts
|
|
18444
18497
|
init_advanced();
|
|
@@ -19807,12 +19860,22 @@ function open2(ruleId, message, evidence, severity = "error") {
|
|
|
19807
19860
|
};
|
|
19808
19861
|
}
|
|
19809
19862
|
function isToolEvent(event) {
|
|
19863
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
19864
|
+
if (kind === "tool") return true;
|
|
19865
|
+
if (kind === "llm" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
19866
|
+
return false;
|
|
19867
|
+
}
|
|
19810
19868
|
const name = event.name.toLowerCase();
|
|
19811
|
-
return
|
|
19869
|
+
return name.startsWith("tool:") || name.startsWith("function:") || name.includes(".tool.") || name.startsWith("mcp:");
|
|
19812
19870
|
}
|
|
19813
19871
|
function isLlmEvent(event) {
|
|
19872
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
19873
|
+
if (kind === "llm") return true;
|
|
19874
|
+
if (kind === "tool" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
19875
|
+
return false;
|
|
19876
|
+
}
|
|
19814
19877
|
const name = event.name.toLowerCase();
|
|
19815
|
-
return
|
|
19878
|
+
return name.startsWith("llm:") || name.includes(".llm.") || name.includes("generation");
|
|
19816
19879
|
}
|
|
19817
19880
|
function toolLabel(event) {
|
|
19818
19881
|
const attrs = event.attributes ?? {};
|
|
@@ -20257,6 +20320,14 @@ var CIRCUIT_ALIASES = {
|
|
|
20257
20320
|
"runaway-llm-loop": "circuit.runaway-llm-loop",
|
|
20258
20321
|
"excessive-branch-width": "circuit.excessive-branch-width"
|
|
20259
20322
|
};
|
|
20323
|
+
var KNOWN_CIRCUIT_RULES = /* @__PURE__ */ new Set([
|
|
20324
|
+
...Object.values(CIRCUIT_ALIASES),
|
|
20325
|
+
...ALL_RULES
|
|
20326
|
+
]);
|
|
20327
|
+
var KNOWN_GUARDRAIL_RULES = /* @__PURE__ */ new Set([
|
|
20328
|
+
...Object.values(GUARDRAIL_ALIASES),
|
|
20329
|
+
...ALL_RULES2
|
|
20330
|
+
]);
|
|
20260
20331
|
function parseGuardrailRules(values) {
|
|
20261
20332
|
if (!values?.length) return void 0;
|
|
20262
20333
|
return values.map((value) => {
|
|
@@ -20319,16 +20390,21 @@ function eventToCircuit(event) {
|
|
|
20319
20390
|
status: event.status
|
|
20320
20391
|
};
|
|
20321
20392
|
}
|
|
20322
|
-
function
|
|
20393
|
+
function scopedEvents(read, runId) {
|
|
20394
|
+
if (runId === void 0) return [...read.events];
|
|
20395
|
+
return read.events.filter((event) => event.runId === runId);
|
|
20396
|
+
}
|
|
20397
|
+
function collectGuardrailInputs(events) {
|
|
20323
20398
|
const inputs = [];
|
|
20324
|
-
for (const event of
|
|
20399
|
+
for (const event of events) {
|
|
20325
20400
|
const attrs = event.attributes ?? {};
|
|
20326
20401
|
for (const key of ["output", "answer", "text", "content", "message"]) {
|
|
20327
20402
|
const value = attrs[key];
|
|
20328
20403
|
if (typeof value === "string") inputs.push({ text: value });
|
|
20329
20404
|
else if (value !== void 0) inputs.push({ value });
|
|
20330
20405
|
}
|
|
20331
|
-
|
|
20406
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
20407
|
+
if (kind === "tool" || event.name.startsWith("tool:")) {
|
|
20332
20408
|
inputs.push({
|
|
20333
20409
|
toolName: String(attrs.toolName ?? attrs.tool ?? event.name),
|
|
20334
20410
|
toolArgs: attrs.arguments ?? attrs.args ?? attrs.input
|
|
@@ -20337,6 +20413,21 @@ function collectGuardrailInputs(read) {
|
|
|
20337
20413
|
}
|
|
20338
20414
|
return inputs;
|
|
20339
20415
|
}
|
|
20416
|
+
function classifyExtensionExecution(findings, errored) {
|
|
20417
|
+
if (errored) return "error";
|
|
20418
|
+
if (findings.some((finding) => finding.status === "fail")) return "fail";
|
|
20419
|
+
if (findings.some((finding) => finding.status === "warning")) return "warning";
|
|
20420
|
+
return "pass";
|
|
20421
|
+
}
|
|
20422
|
+
function extensionExecution(ruleId, findings, options) {
|
|
20423
|
+
return {
|
|
20424
|
+
ruleId,
|
|
20425
|
+
category: "safety",
|
|
20426
|
+
status: classifyExtensionExecution(findings, options.errored === true),
|
|
20427
|
+
findingCount: findings.length,
|
|
20428
|
+
...options.runId !== void 0 ? { runId: options.runId } : {}
|
|
20429
|
+
};
|
|
20430
|
+
}
|
|
20340
20431
|
var DEFAULT_GUARDRAIL_OPTIONS = {
|
|
20341
20432
|
bannedPhrase: { phrases: ["delete all data", "ignore all instructions"] },
|
|
20342
20433
|
promptInjection: {},
|
|
@@ -20353,53 +20444,116 @@ var DEFAULT_CIRCUIT_OPTIONS = {
|
|
|
20353
20444
|
};
|
|
20354
20445
|
function mergeSafetyExtensions(result, read, options) {
|
|
20355
20446
|
const findings = [...result.findings];
|
|
20447
|
+
const ruleExecutions = [...result.ruleExecutions ?? []];
|
|
20356
20448
|
let failed = result.summary.failed;
|
|
20357
20449
|
let warnings = result.summary.warnings;
|
|
20358
20450
|
let passed = result.summary.passed;
|
|
20451
|
+
let errors = result.summary.errors;
|
|
20452
|
+
const events = scopedEvents(read, options.runId);
|
|
20453
|
+
const runId = options.runId;
|
|
20359
20454
|
const guardrailRules = parseGuardrailRules(options.guardrails);
|
|
20360
20455
|
if (guardrailRules) {
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
|
|
20456
|
+
const inputs = collectGuardrailInputs(events);
|
|
20457
|
+
for (const ruleId of guardrailRules) {
|
|
20458
|
+
if (!KNOWN_GUARDRAIL_RULES.has(ruleId)) {
|
|
20459
|
+
const finding = {
|
|
20460
|
+
ruleId,
|
|
20461
|
+
severity: "error",
|
|
20462
|
+
status: "fail",
|
|
20463
|
+
message: `Unknown guardrail rule: ${ruleId}.`,
|
|
20464
|
+
evidence: []
|
|
20465
|
+
};
|
|
20368
20466
|
findings.push(finding);
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20467
|
+
failed += 1;
|
|
20468
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20469
|
+
errors += 1;
|
|
20470
|
+
continue;
|
|
20471
|
+
}
|
|
20472
|
+
const ruleFindings = [];
|
|
20473
|
+
if (inputs.length === 0) {
|
|
20474
|
+
ruleExecutions.push(extensionExecution(ruleId, [], { runId }));
|
|
20475
|
+
continue;
|
|
20476
|
+
}
|
|
20477
|
+
for (const input3 of inputs) {
|
|
20478
|
+
const run = runGuardrails(input3, {
|
|
20479
|
+
...DEFAULT_GUARDRAIL_OPTIONS,
|
|
20480
|
+
rules: [ruleId]
|
|
20481
|
+
});
|
|
20482
|
+
for (const item of run.results) {
|
|
20483
|
+
const finding = guardrailFinding(item);
|
|
20484
|
+
ruleFindings.push(finding);
|
|
20485
|
+
findings.push(finding);
|
|
20486
|
+
if (finding.status === "fail") failed += 1;
|
|
20487
|
+
else if (finding.status === "warning") warnings += 1;
|
|
20488
|
+
else passed += 1;
|
|
20489
|
+
}
|
|
20372
20490
|
}
|
|
20491
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
20373
20492
|
}
|
|
20374
20493
|
}
|
|
20375
20494
|
const circuitRules = parseCircuitRules(options.circuits);
|
|
20376
20495
|
if (circuitRules) {
|
|
20377
|
-
const
|
|
20378
|
-
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
|
|
20385
|
-
|
|
20386
|
-
|
|
20496
|
+
const projected = projectLogicalEvents(events);
|
|
20497
|
+
const circuitEvents = projected.logicalEvents.map(eventToCircuit);
|
|
20498
|
+
for (const ruleId of circuitRules) {
|
|
20499
|
+
if (!KNOWN_CIRCUIT_RULES.has(ruleId)) {
|
|
20500
|
+
const finding = {
|
|
20501
|
+
ruleId,
|
|
20502
|
+
severity: "error",
|
|
20503
|
+
status: "fail",
|
|
20504
|
+
message: `Unknown circuit rule: ${ruleId}.`,
|
|
20505
|
+
evidence: []
|
|
20506
|
+
};
|
|
20507
|
+
findings.push(finding);
|
|
20508
|
+
failed += 1;
|
|
20509
|
+
errors += 1;
|
|
20510
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20511
|
+
continue;
|
|
20512
|
+
}
|
|
20513
|
+
const circuitRun = runCircuits(circuitEvents, {
|
|
20514
|
+
...DEFAULT_CIRCUIT_OPTIONS,
|
|
20515
|
+
rules: [ruleId]
|
|
20516
|
+
});
|
|
20517
|
+
if (circuitRun.results.length === 0) {
|
|
20518
|
+
const finding = {
|
|
20519
|
+
ruleId,
|
|
20520
|
+
severity: "error",
|
|
20521
|
+
status: "fail",
|
|
20522
|
+
message: `Circuit rule ${ruleId} produced no evaluation result.`,
|
|
20523
|
+
evidence: []
|
|
20524
|
+
};
|
|
20525
|
+
findings.push(finding);
|
|
20526
|
+
failed += 1;
|
|
20527
|
+
errors += 1;
|
|
20528
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
20529
|
+
continue;
|
|
20530
|
+
}
|
|
20531
|
+
const ruleFindings = [];
|
|
20532
|
+
for (const item of circuitRun.results) {
|
|
20533
|
+
const finding = circuitFinding(item);
|
|
20534
|
+
ruleFindings.push(finding);
|
|
20535
|
+
findings.push(finding);
|
|
20536
|
+
if (finding.status === "fail") failed += 1;
|
|
20537
|
+
else if (finding.status === "warning") warnings += 1;
|
|
20538
|
+
else passed += 1;
|
|
20539
|
+
}
|
|
20540
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
20387
20541
|
}
|
|
20388
20542
|
}
|
|
20389
|
-
const
|
|
20543
|
+
const status = result.status === "error" || errors > 0 ? "error" : failed > 0 ? "fail" : result.status;
|
|
20390
20544
|
return {
|
|
20391
20545
|
...result,
|
|
20392
|
-
ok,
|
|
20393
|
-
status
|
|
20546
|
+
ok: status === "pass",
|
|
20547
|
+
status,
|
|
20394
20548
|
summary: {
|
|
20395
20549
|
passed,
|
|
20396
20550
|
failed,
|
|
20397
20551
|
warnings,
|
|
20398
|
-
errors
|
|
20399
|
-
rulesEvaluated:
|
|
20552
|
+
errors,
|
|
20553
|
+
rulesEvaluated: ruleExecutions.length
|
|
20400
20554
|
},
|
|
20401
20555
|
findings,
|
|
20402
|
-
ruleExecutions
|
|
20556
|
+
ruleExecutions
|
|
20403
20557
|
};
|
|
20404
20558
|
}
|
|
20405
20559
|
|
|
@@ -20603,7 +20757,7 @@ var SAFETY_KEYS = /* @__PURE__ */ new Set([
|
|
|
20603
20757
|
"maxFindings"
|
|
20604
20758
|
]);
|
|
20605
20759
|
var RUN_EXPECTED = /* @__PURE__ */ new Set(["ok", "error", "running"]);
|
|
20606
|
-
var
|
|
20760
|
+
var CONFIDENCE_LIST = ATTRIBUTION_CONFIDENCES.join(", ");
|
|
20607
20761
|
var CheckConfigError = class extends Error {
|
|
20608
20762
|
code;
|
|
20609
20763
|
constructor(code, message) {
|
|
@@ -20745,10 +20899,10 @@ function parseStructureSection(value) {
|
|
|
20745
20899
|
rejectUnknownKeys(record, STRUCTURE_KEYS, "checks.structure");
|
|
20746
20900
|
const out = {};
|
|
20747
20901
|
if (record.minConfidence !== void 0) {
|
|
20748
|
-
if (
|
|
20902
|
+
if (!isAttributionConfidence(record.minConfidence)) {
|
|
20749
20903
|
throw new CheckConfigError(
|
|
20750
20904
|
"AI_CHECK_CONFIG_INVALID_VALUE",
|
|
20751
|
-
`checks.structure.minConfidence must be one of:
|
|
20905
|
+
`checks.structure.minConfidence must be one of: ${CONFIDENCE_LIST}.`
|
|
20752
20906
|
);
|
|
20753
20907
|
}
|
|
20754
20908
|
out.minConfidence = record.minConfidence;
|
|
@@ -21258,7 +21412,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
21258
21412
|
read,
|
|
21259
21413
|
{
|
|
21260
21414
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
21261
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
21415
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
21416
|
+
runId: meta2.runId
|
|
21262
21417
|
}
|
|
21263
21418
|
)
|
|
21264
21419
|
);
|
|
@@ -21311,7 +21466,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
21311
21466
|
read,
|
|
21312
21467
|
{
|
|
21313
21468
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
21314
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
21469
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
21470
|
+
...options.run !== void 0 ? { runId: options.run } : {}
|
|
21315
21471
|
}
|
|
21316
21472
|
);
|
|
21317
21473
|
}
|
|
@@ -23490,10 +23646,10 @@ function selectRun4(read, runId) {
|
|
|
23490
23646
|
}
|
|
23491
23647
|
function summarizeTrace(read, run) {
|
|
23492
23648
|
const runId = run?.runId;
|
|
23493
|
-
const
|
|
23649
|
+
const scopedEvents2 = runId === void 0 ? read.events : read.events.filter((event) => event.runId === runId);
|
|
23494
23650
|
const eventsByKind = {};
|
|
23495
23651
|
const eventsByStatus = {};
|
|
23496
|
-
for (const event of
|
|
23652
|
+
for (const event of scopedEvents2) {
|
|
23497
23653
|
increment(eventsByKind, event.kind);
|
|
23498
23654
|
increment(eventsByStatus, event.status);
|
|
23499
23655
|
}
|
|
@@ -23503,7 +23659,7 @@ function summarizeTrace(read, run) {
|
|
|
23503
23659
|
...run?.status !== void 0 ? { runStatus: run.status } : {},
|
|
23504
23660
|
...run?.durationMs !== void 0 ? { runDurationMs: run.durationMs } : {},
|
|
23505
23661
|
runCount: read.runs.length,
|
|
23506
|
-
eventCount:
|
|
23662
|
+
eventCount: scopedEvents2.length,
|
|
23507
23663
|
eventsByKind: Object.fromEntries(Object.entries(eventsByKind).sort()),
|
|
23508
23664
|
eventsByStatus: Object.fromEntries(Object.entries(eventsByStatus).sort()),
|
|
23509
23665
|
readerWarnings: read.warnings.length,
|
|
@@ -26901,7 +27057,7 @@ function createCliProgram() {
|
|
|
26901
27057
|
"add run.maxStepDuration (e.g. 30s, 5m)"
|
|
26902
27058
|
).option("--require-completed", "add run.requireCompleted").option("--detect-stalls", "add run.stall for running or incomplete events").option(
|
|
26903
27059
|
"--fail-on-observation <status>",
|
|
26904
|
-
"
|
|
27060
|
+
"outcome gate: require \u22651 OUTCOME and fail when status matches (passed,failed,unknown,skipped; comma-separated). Does not invent outcomes from tool/LLM/run success; use --preset trajectory for structural checks"
|
|
26905
27061
|
).option("--session <id>", "check all runs in a workflow session (requires --dir)").option("--group <id>", "check all runs sharing a groupId (requires --dir)").option(
|
|
26906
27062
|
"--correlate-group",
|
|
26907
27063
|
"when using --session, also match synthetic group: session keys"
|
|
@@ -26914,7 +27070,7 @@ function createCliProgram() {
|
|
|
26914
27070
|
"run optional circuit rules (repeatable): same-tool-repetition, max-retries, ...",
|
|
26915
27071
|
(value, previous = []) => [...previous, value]
|
|
26916
27072
|
).addOption(
|
|
26917
|
-
new commander.Option("--preset <name>", "additive check preset").choices(["trajectory", "safety", "comprehensive", "behavioral-session"])
|
|
27073
|
+
new commander.Option("--preset <name>", "additive check preset (trajectory=structure only; safety=share checks; not interchangeable)").choices(["trajectory", "safety", "comprehensive", "behavioral-session"])
|
|
26918
27074
|
).addOption(
|
|
26919
27075
|
new commander.Option(
|
|
26920
27076
|
"--evidence-on <mode>",
|