agent-inspect 6.14.1 → 6.15.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/CHANGELOG.md +14 -2
- package/README.md +1 -1
- package/docs/API.md +19 -3
- package/docs/KNOWN-ISSUES.md +2 -1
- package/package.json +2 -2
- package/packages/cli/dist/{chunk-MEO2Z3KE.mjs → chunk-LFSBMUCD.mjs} +316 -41
- package/packages/cli/dist/chunk-LFSBMUCD.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +388 -42
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +59 -6
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-6VZNGIF6.mjs → src-5J2HPOJ3.mjs} +3 -3
- package/packages/cli/dist/{src-6VZNGIF6.mjs.map → src-5J2HPOJ3.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +268 -24
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +18 -10
- package/packages/core/dist/advanced.d.ts +18 -10
- package/packages/core/dist/advanced.mjs +7 -6
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +221 -22
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.d.cts +18 -8
- package/packages/core/dist/checks.d.ts +18 -8
- package/packages/core/dist/checks.mjs +2 -1
- package/packages/core/dist/chunk-AK5EN4U2.mjs +174 -0
- package/packages/core/dist/chunk-AK5EN4U2.mjs.map +1 -0
- package/packages/core/dist/chunk-FWK3Q3OJ.mjs +56 -0
- package/packages/core/dist/chunk-FWK3Q3OJ.mjs.map +1 -0
- package/packages/core/dist/{chunk-CTA6XNDP.mjs → chunk-HT54OLPE.mjs} +54 -7
- package/packages/core/dist/chunk-HT54OLPE.mjs.map +1 -0
- package/packages/core/dist/{chunk-BS2QCAJX.mjs → chunk-NF4ZHNTC.mjs} +169 -25
- package/packages/core/dist/chunk-NF4ZHNTC.mjs.map +1 -0
- package/packages/core/dist/{chunk-UOPVGCOB.mjs → chunk-NXQF73EC.mjs} +3 -3
- package/packages/core/dist/{chunk-UOPVGCOB.mjs.map → chunk-NXQF73EC.mjs.map} +1 -1
- package/packages/core/dist/{chunk-LFWZEO2L.mjs → chunk-SGL4JGCD.mjs} +3 -3
- package/packages/core/dist/{chunk-LFWZEO2L.mjs.map → chunk-SGL4JGCD.mjs.map} +1 -1
- package/packages/core/dist/{context-BHAgRjOe.d.cts → context-Ca5yK8Cs.d.cts} +3 -3
- package/packages/core/dist/{context-Blyjb5my.d.ts → context-D6cS4XIL.d.ts} +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 +1 -1
- package/packages/core/dist/index-B259NKkH.d.cts +102 -0
- package/packages/core/dist/index-B9ZGvUVL.d.ts +102 -0
- package/packages/core/dist/{index-Bu_vOjql.d.ts → index-BsCcOKxy.d.ts} +4 -4
- package/packages/core/dist/{index-CmXMS-MF.d.cts → index-Xk9X-yjY.d.cts} +4 -4
- package/packages/core/dist/index.d.cts +6 -6
- package/packages/core/dist/index.d.ts +6 -6
- package/packages/core/dist/{inspect-event-DVg84S4v.d.cts → inspect-event-DRthdZlf.d.cts} +9 -0
- package/packages/core/dist/{inspect-event-DVg84S4v.d.ts → inspect-event-DRthdZlf.d.ts} +9 -0
- package/packages/core/dist/{log-config-BG1WmWf2.d.cts → log-config-CFlIJHTf.d.cts} +1 -1
- package/packages/core/dist/{log-config-Ck0aT_Ou.d.ts → log-config-OZRfpHED.d.ts} +1 -1
- package/packages/core/dist/logs.cjs +95 -15
- package/packages/core/dist/logs.cjs.map +1 -1
- package/packages/core/dist/logs.d.cts +3 -3
- package/packages/core/dist/logs.d.ts +3 -3
- package/packages/core/dist/logs.mjs +2 -2
- package/packages/core/dist/{persisted-inspect-event-ChE7pGb7.d.ts → persisted-inspect-event-BVucFVrP.d.ts} +1 -1
- package/packages/core/dist/{persisted-inspect-event-d-mSP8kd.d.cts → persisted-inspect-event-CVZWZldL.d.cts} +1 -1
- package/packages/core/dist/persisted.cjs +95 -15
- 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 +203 -18
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.d.cts +27 -78
- package/packages/core/dist/readers.d.ts +27 -78
- package/packages/core/dist/readers.mjs +4 -3
- package/packages/core/dist/{types-MuwXSJ4b.d.ts → types--ainI31J.d.ts} +1 -1
- package/packages/core/dist/{types-BLX3tiOW.d.cts → types-UnrNaTo2.d.cts} +1 -1
- package/packages/core/dist/writers.d.cts +2 -2
- package/packages/core/dist/writers.d.ts +2 -2
- package/packages/cli/dist/chunk-MEO2Z3KE.mjs.map +0 -1
- package/packages/core/dist/chunk-BS2QCAJX.mjs.map +0 -1
- package/packages/core/dist/chunk-CTA6XNDP.mjs.map +0 -1
- package/packages/core/dist/chunk-T5MASTIW.mjs +0 -94
- package/packages/core/dist/chunk-T5MASTIW.mjs.map +0 -1
|
@@ -10,6 +10,59 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
10
10
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
11
11
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
12
12
|
|
|
13
|
+
// packages/core/src/diagnostics/programmatic.ts
|
|
14
|
+
var PROGRAMMATIC_DIAGNOSTIC_SPECS = Object.freeze({
|
|
15
|
+
AI_TRACE_INPUT_INVALID: {
|
|
16
|
+
code: "AI_TRACE_INPUT_INVALID",
|
|
17
|
+
summary: 'Expected { type: "file", path }, { type: "directory", path }, { type: "string", content }, { type: "buffer", content }, or { type: "stdin" }.',
|
|
18
|
+
remediation: "For a file path, use openTraceFile(path).",
|
|
19
|
+
relatedCodes: ["invalid_input"]
|
|
20
|
+
},
|
|
21
|
+
AI_TRACE_FORMAT_UNSUPPORTED: {
|
|
22
|
+
code: "AI_TRACE_FORMAT_UNSUPPORTED",
|
|
23
|
+
summary: "No trace reader could detect the input format.",
|
|
24
|
+
remediation: "Pass an AgentInspect JSONL file via openTraceFile, or set options.format to a registered reader.",
|
|
25
|
+
relatedCodes: ["unsupported_format"]
|
|
26
|
+
},
|
|
27
|
+
AI_TRACE_FORMAT_AMBIGUOUS: {
|
|
28
|
+
code: "AI_TRACE_FORMAT_AMBIGUOUS",
|
|
29
|
+
summary: "Multiple trace readers matched the input with equal confidence.",
|
|
30
|
+
remediation: "Set options.format explicitly to disambiguate the reader.",
|
|
31
|
+
relatedCodes: ["ambiguous_format"]
|
|
32
|
+
},
|
|
33
|
+
AI_TRACE_FACTS_INPUT_NOT_NORMALIZED: {
|
|
34
|
+
code: "AI_TRACE_FACTS_INPUT_NOT_NORMALIZED",
|
|
35
|
+
summary: "TraceFacts requires TraceReadResult or PersistedInspectEvent[].",
|
|
36
|
+
remediation: "Use openTraceFile() to normalize a JSONL trace first."
|
|
37
|
+
},
|
|
38
|
+
AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED: {
|
|
39
|
+
code: "AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED",
|
|
40
|
+
summary: "Multiple runs are available; select a run before executing checks.",
|
|
41
|
+
remediation: "Pass options.runId or TraceCheckInput.selectedRun.",
|
|
42
|
+
relatedCodes: ["AI_CHECK_RUN_SELECTION_REQUIRED"]
|
|
43
|
+
},
|
|
44
|
+
AI_TRACE_RELATIONSHIP_SELF_PARENT: {
|
|
45
|
+
code: "AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
46
|
+
summary: "A parentId equals its own event/step id.",
|
|
47
|
+
remediation: "Reject at capture (AI_LANGGRAPH_SELF_PARENT_REJECTED) or drop via logical projection; do not invent replacement parents.",
|
|
48
|
+
relatedCodes: [
|
|
49
|
+
"AI_LANGGRAPH_SELF_PARENT_REJECTED",
|
|
50
|
+
"AI_LOGICAL_SELF_PARENT_REMOVED"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
AI_TRACE_RELATIONSHIP_CYCLE: {
|
|
54
|
+
code: "AI_TRACE_RELATIONSHIP_CYCLE",
|
|
55
|
+
summary: "Trace contains a parentId cycle.",
|
|
56
|
+
remediation: "Use visibility-first tree linking for legacy fixtures; prefer acyclic capture for new adapter output.",
|
|
57
|
+
relatedCodes: ["structure.cycle"]
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
function formatProgrammaticDiagnostic(code, detail) {
|
|
61
|
+
const spec = PROGRAMMATIC_DIAGNOSTIC_SPECS[code];
|
|
62
|
+
const summary = detail?.trim() ? detail.trim() : spec.summary;
|
|
63
|
+
return `${code}: ${summary} Remediation: ${spec.remediation}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
13
66
|
// packages/core/src/outcomes/types.ts
|
|
14
67
|
var OUTCOME_ATTRIBUTE_STATUS_KEY = "outcomeStatus";
|
|
15
68
|
var OUTCOME_ATTRIBUTE_EXPECTATION_KEY = "expectation";
|
|
@@ -64,6 +117,73 @@ function outcomesMatchingStatus(outcomes, statuses) {
|
|
|
64
117
|
return outcomes.filter((outcome) => set.has(outcome.status));
|
|
65
118
|
}
|
|
66
119
|
|
|
120
|
+
// packages/core/src/safety/sensitive-key.ts
|
|
121
|
+
function normalizeSensitiveKey(value) {
|
|
122
|
+
return value.toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
123
|
+
}
|
|
124
|
+
var NON_CREDENTIAL_TOKEN_CONFIG_KEYS = new Set(
|
|
125
|
+
[
|
|
126
|
+
"tokens",
|
|
127
|
+
"max_tokens",
|
|
128
|
+
"min_tokens",
|
|
129
|
+
"ls_max_tokens",
|
|
130
|
+
"token_count",
|
|
131
|
+
"token_limit",
|
|
132
|
+
"token_budget",
|
|
133
|
+
"input_tokens",
|
|
134
|
+
"output_tokens",
|
|
135
|
+
"total_tokens",
|
|
136
|
+
"cached_tokens",
|
|
137
|
+
"prompt_tokens",
|
|
138
|
+
"completion_tokens"
|
|
139
|
+
].map(normalizeSensitiveKey)
|
|
140
|
+
);
|
|
141
|
+
var DEFAULT_CREDENTIAL_SENSITIVE_KEYS = [
|
|
142
|
+
"authorization",
|
|
143
|
+
"cookie",
|
|
144
|
+
"token",
|
|
145
|
+
"access_token",
|
|
146
|
+
"accesstoken",
|
|
147
|
+
"auth_token",
|
|
148
|
+
"authtoken",
|
|
149
|
+
"refresh_token",
|
|
150
|
+
"refreshtoken",
|
|
151
|
+
"id_token",
|
|
152
|
+
"idtoken",
|
|
153
|
+
"bearer_token",
|
|
154
|
+
"bearertoken",
|
|
155
|
+
"api_token",
|
|
156
|
+
"apitoken",
|
|
157
|
+
"apikey",
|
|
158
|
+
"api_key",
|
|
159
|
+
"password",
|
|
160
|
+
"secret",
|
|
161
|
+
"email"
|
|
162
|
+
];
|
|
163
|
+
function isTokenCredentialKey(normalized) {
|
|
164
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
165
|
+
if (normalized === "token") return true;
|
|
166
|
+
if (normalized.endsWith("tokens")) return false;
|
|
167
|
+
return normalized.endsWith("token");
|
|
168
|
+
}
|
|
169
|
+
function isCredentialSensitiveKey(key, sensitiveKeys = DEFAULT_CREDENTIAL_SENSITIVE_KEYS) {
|
|
170
|
+
if (!key) return false;
|
|
171
|
+
const normalized = normalizeSensitiveKey(key);
|
|
172
|
+
if (!normalized) return false;
|
|
173
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
174
|
+
for (const sensitive of sensitiveKeys) {
|
|
175
|
+
const s = normalizeSensitiveKey(sensitive);
|
|
176
|
+
if (!s) continue;
|
|
177
|
+
if (s === "token") {
|
|
178
|
+
if (isTokenCredentialKey(normalized)) return true;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (normalized === s) return true;
|
|
182
|
+
if (normalized.endsWith(`_${s}`) || normalized.startsWith(`${s}_`)) return true;
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
67
187
|
// packages/core/src/checks/logical-events.ts
|
|
68
188
|
function isRecord(value) {
|
|
69
189
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -259,6 +379,26 @@ function projectLogicalEvents(events) {
|
|
|
259
379
|
}
|
|
260
380
|
}
|
|
261
381
|
if (!remapped) {
|
|
382
|
+
if (originalParentId === event.eventId) {
|
|
383
|
+
diagnostics.push({
|
|
384
|
+
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
385
|
+
message: formatProgrammaticDiagnostic(
|
|
386
|
+
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
387
|
+
`Removed self-parent edge on ${event.eventId}.`
|
|
388
|
+
),
|
|
389
|
+
eventIds: [event.eventId]
|
|
390
|
+
});
|
|
391
|
+
const { parentId: _drop, ...rest } = event;
|
|
392
|
+
normalized.push({
|
|
393
|
+
...rest,
|
|
394
|
+
projection: {
|
|
395
|
+
...event.projection,
|
|
396
|
+
parentNormalized: true,
|
|
397
|
+
originalParentId
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
262
402
|
if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
|
|
263
403
|
const mapping = event.attributes?.parentMapping;
|
|
264
404
|
const unresolved = mapping === "unresolved" || event.attributes?.parentUnresolved === true || event.attributes?.unresolvedParent === true || // LangGraph/framework scaffolding sentinel labels are not event ids.
|
|
@@ -274,6 +414,26 @@ function projectLogicalEvents(events) {
|
|
|
274
414
|
normalized.push(event);
|
|
275
415
|
continue;
|
|
276
416
|
}
|
|
417
|
+
if (nextParent === event.eventId) {
|
|
418
|
+
diagnostics.push({
|
|
419
|
+
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
420
|
+
message: formatProgrammaticDiagnostic(
|
|
421
|
+
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
422
|
+
`Removed self-parent edge on ${event.eventId} (was ${originalParentId}).`
|
|
423
|
+
),
|
|
424
|
+
eventIds: [event.eventId]
|
|
425
|
+
});
|
|
426
|
+
const { parentId: _drop, ...rest } = event;
|
|
427
|
+
normalized.push({
|
|
428
|
+
...rest,
|
|
429
|
+
projection: {
|
|
430
|
+
...event.projection,
|
|
431
|
+
parentNormalized: true,
|
|
432
|
+
originalParentId
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
277
437
|
diagnostics.push({
|
|
278
438
|
code: "AI_LOGICAL_PARENT_REMAPPED",
|
|
279
439
|
message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
|
|
@@ -346,7 +506,45 @@ function summarizeSemanticParity(events) {
|
|
|
346
506
|
diagnostics: projection.diagnostics
|
|
347
507
|
};
|
|
348
508
|
}
|
|
349
|
-
|
|
509
|
+
var TRACE_FACTS_INPUT_NOT_NORMALIZED = formatProgrammaticDiagnostic(
|
|
510
|
+
"AI_TRACE_FACTS_INPUT_NOT_NORMALIZED"
|
|
511
|
+
);
|
|
512
|
+
function isTraceReadResult(input) {
|
|
513
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
const record = input;
|
|
517
|
+
return Array.isArray(record.events) && Array.isArray(record.runs) && typeof record.format === "string" && Array.isArray(record.warnings);
|
|
518
|
+
}
|
|
519
|
+
function looksLikeRawV01TraceEvents(input) {
|
|
520
|
+
if (!Array.isArray(input) || input.length === 0) return false;
|
|
521
|
+
const first = input[0];
|
|
522
|
+
if (typeof first !== "object" || first === null) return false;
|
|
523
|
+
const row = first;
|
|
524
|
+
return typeof row.event === "string" && (row.schemaVersion === "0.1" || row.eventId === void 0);
|
|
525
|
+
}
|
|
526
|
+
function isPersistedInspectEventArray(input) {
|
|
527
|
+
if (!Array.isArray(input)) return false;
|
|
528
|
+
if (input.length === 0) return true;
|
|
529
|
+
const first = input[0];
|
|
530
|
+
if (typeof first !== "object" || first === null) return false;
|
|
531
|
+
const row = first;
|
|
532
|
+
return typeof row.eventId === "string" && (row.schemaVersion === "0.2" || row.schemaVersion === "1.0" || row.schemaVersion === "0.1") && typeof row.event !== "string";
|
|
533
|
+
}
|
|
534
|
+
function resolveTraceFactsEvents(input) {
|
|
535
|
+
if (isTraceReadResult(input)) {
|
|
536
|
+
return input.events;
|
|
537
|
+
}
|
|
538
|
+
if (looksLikeRawV01TraceEvents(input)) {
|
|
539
|
+
throw new TypeError(TRACE_FACTS_INPUT_NOT_NORMALIZED);
|
|
540
|
+
}
|
|
541
|
+
if (isPersistedInspectEventArray(input)) {
|
|
542
|
+
return input;
|
|
543
|
+
}
|
|
544
|
+
throw new TypeError(TRACE_FACTS_INPUT_NOT_NORMALIZED);
|
|
545
|
+
}
|
|
546
|
+
function buildTraceFacts(input) {
|
|
547
|
+
const events = resolveTraceFactsEvents(input);
|
|
350
548
|
const projection = projectLogicalEvents(events);
|
|
351
549
|
const toolsByName = /* @__PURE__ */ new Map();
|
|
352
550
|
const llmEvents = [];
|
|
@@ -551,6 +749,9 @@ function evaluateTraceContract(input, contract, options = {}) {
|
|
|
551
749
|
...options.runId !== void 0 ? { runId: options.runId } : {}
|
|
552
750
|
});
|
|
553
751
|
}
|
|
752
|
+
function evaluateTraceContractRead(read, contract, options = {}) {
|
|
753
|
+
return evaluateTraceContract({ read }, contract, options);
|
|
754
|
+
}
|
|
554
755
|
|
|
555
756
|
// packages/core/src/checks/index.ts
|
|
556
757
|
var SEVERITY_RANK = {
|
|
@@ -569,16 +770,7 @@ var CONFIDENCE_RANK = {
|
|
|
569
770
|
correlated: 2,
|
|
570
771
|
explicit: 3
|
|
571
772
|
};
|
|
572
|
-
var DEFAULT_SENSITIVE_KEYS =
|
|
573
|
-
"authorization",
|
|
574
|
-
"cookie",
|
|
575
|
-
"token",
|
|
576
|
-
"apikey",
|
|
577
|
-
"api_key",
|
|
578
|
-
"password",
|
|
579
|
-
"secret",
|
|
580
|
-
"email"
|
|
581
|
-
];
|
|
773
|
+
var DEFAULT_SENSITIVE_KEYS = DEFAULT_CREDENTIAL_SENSITIVE_KEYS;
|
|
582
774
|
var DEFAULT_RAW_CONTENT_KEYS = [
|
|
583
775
|
"body",
|
|
584
776
|
"headers",
|
|
@@ -736,7 +928,13 @@ function resolveSelectedRun(input, runId) {
|
|
|
736
928
|
if (input.read.runs.length === 0) {
|
|
737
929
|
return {
|
|
738
930
|
diagnostics: [
|
|
739
|
-
diagnostic(
|
|
931
|
+
diagnostic(
|
|
932
|
+
"AI_CHECK_RUN_SELECTION_REQUIRED",
|
|
933
|
+
formatProgrammaticDiagnostic(
|
|
934
|
+
"AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED",
|
|
935
|
+
"No runs are available for checks."
|
|
936
|
+
)
|
|
937
|
+
)
|
|
740
938
|
]
|
|
741
939
|
};
|
|
742
940
|
}
|
|
@@ -744,7 +942,7 @@ function resolveSelectedRun(input, runId) {
|
|
|
744
942
|
diagnostics: [
|
|
745
943
|
diagnostic(
|
|
746
944
|
"AI_CHECK_RUN_SELECTION_REQUIRED",
|
|
747
|
-
"
|
|
945
|
+
formatProgrammaticDiagnostic("AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED")
|
|
748
946
|
)
|
|
749
947
|
]
|
|
750
948
|
};
|
|
@@ -1011,9 +1209,7 @@ function hasRedactionMarker(value, markers) {
|
|
|
1011
1209
|
return markers.some((marker) => value.includes(marker)) || /^\[HASH:[A-Za-z0-9_-]+\]$/.test(value);
|
|
1012
1210
|
}
|
|
1013
1211
|
function isSensitiveKey(key, sensitiveKeys) {
|
|
1014
|
-
|
|
1015
|
-
const normalized = normalizedKey(key);
|
|
1016
|
-
return sensitiveKeys.some((sensitive) => normalized.includes(normalizedKey(sensitive)));
|
|
1212
|
+
return isCredentialSensitiveKey(key, sensitiveKeys);
|
|
1017
1213
|
}
|
|
1018
1214
|
function isRawContentKey(key, forbiddenKeys) {
|
|
1019
1215
|
if (!key) return false;
|
|
@@ -1372,7 +1568,7 @@ function createToolUsageRule(options) {
|
|
|
1372
1568
|
}
|
|
1373
1569
|
}
|
|
1374
1570
|
const forbidden = new Set(options.forbidden ?? []);
|
|
1375
|
-
const allowed = options.allowed ? new Set(options.allowed) : void 0;
|
|
1571
|
+
const allowed = options.allowed?.length ? new Set(options.allowed) : void 0;
|
|
1376
1572
|
for (const event of tools) {
|
|
1377
1573
|
const name = toolName(event);
|
|
1378
1574
|
if (forbidden.has(name)) {
|
|
@@ -1472,9 +1668,9 @@ function createLlmUsageRule(options) {
|
|
|
1472
1668
|
evaluate(context) {
|
|
1473
1669
|
const llms = finishedEvents(context, "LLM");
|
|
1474
1670
|
const findings = [];
|
|
1475
|
-
const allowedModels = options.allowedModels ? new Set(options.allowedModels) : void 0;
|
|
1476
|
-
const allowedProviders = options.allowedProviders ? new Set(options.allowedProviders) : void 0;
|
|
1477
|
-
const finishReasons = options.finishReasons ? new Set(options.finishReasons) : void 0;
|
|
1671
|
+
const allowedModels = options.allowedModels?.length ? new Set(options.allowedModels) : void 0;
|
|
1672
|
+
const allowedProviders = options.allowedProviders?.length ? new Set(options.allowedProviders) : void 0;
|
|
1673
|
+
const finishReasons = options.finishReasons?.length ? new Set(options.finishReasons) : void 0;
|
|
1478
1674
|
if (options.maxCalls !== void 0 && llms.length > options.maxCalls) {
|
|
1479
1675
|
findings.push(
|
|
1480
1676
|
failFinding(
|
|
@@ -1627,7 +1823,7 @@ function createStructureCycleRule() {
|
|
|
1627
1823
|
findings.push(
|
|
1628
1824
|
failFinding(
|
|
1629
1825
|
"structure.cycle",
|
|
1630
|
-
"
|
|
1826
|
+
formatProgrammaticDiagnostic("AI_TRACE_RELATIONSHIP_CYCLE"),
|
|
1631
1827
|
cycle.map((item) => eventEvidence(item, "parentId")),
|
|
1632
1828
|
"acyclic parentId graph",
|
|
1633
1829
|
cycle.map((item) => item.eventId).sort()
|
|
@@ -1815,7 +2011,7 @@ function createSignalRule(ruleId, label, options, selectEvents, nameForEvent) {
|
|
|
1815
2011
|
}
|
|
1816
2012
|
}
|
|
1817
2013
|
const forbidden = new Set(options.forbidden ?? []);
|
|
1818
|
-
const allowed = options.allowed ? new Set(options.allowed) : void 0;
|
|
2014
|
+
const allowed = options.allowed?.length ? new Set(options.allowed) : void 0;
|
|
1819
2015
|
for (const event of events) {
|
|
1820
2016
|
const name = nameForEvent(event);
|
|
1821
2017
|
if (forbidden.has(name)) {
|
|
@@ -2295,6 +2491,7 @@ function runTraceChecks(input, options = {}) {
|
|
|
2295
2491
|
};
|
|
2296
2492
|
}
|
|
2297
2493
|
|
|
2494
|
+
exports.PROGRAMMATIC_DIAGNOSTIC_SPECS = PROGRAMMATIC_DIAGNOSTIC_SPECS;
|
|
2298
2495
|
exports.buildTraceFacts = buildTraceFacts;
|
|
2299
2496
|
exports.createBaselineRegressionRule = createBaselineRegressionRule;
|
|
2300
2497
|
exports.createDecisionRule = createDecisionRule;
|
|
@@ -2323,6 +2520,8 @@ exports.createToolOrderingRule = createToolOrderingRule;
|
|
|
2323
2520
|
exports.createToolUsageRule = createToolUsageRule;
|
|
2324
2521
|
exports.defineTraceContract = defineTraceContract;
|
|
2325
2522
|
exports.evaluateTraceContract = evaluateTraceContract;
|
|
2523
|
+
exports.evaluateTraceContractRead = evaluateTraceContractRead;
|
|
2524
|
+
exports.formatProgrammaticDiagnostic = formatProgrammaticDiagnostic;
|
|
2326
2525
|
exports.projectLogicalEvents = projectLogicalEvents;
|
|
2327
2526
|
exports.resolveCanonicalToolName = resolveCanonicalToolName;
|
|
2328
2527
|
exports.runTraceChecks = runTraceChecks;
|