agent-inspect 6.31.32 → 6.31.33
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 +6 -0
- package/README.md +1 -1
- package/docs/TRACE-CONTRACTS.md +2 -0
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-PEGM6T2X.mjs → chunk-AILSHDEF.mjs} +111 -24
- package/packages/cli/dist/chunk-AILSHDEF.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +110 -23
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +4 -4
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-CWUJTMRD.mjs → src-SP36M4VB.mjs} +3 -3
- package/packages/cli/dist/{src-CWUJTMRD.mjs.map → src-SP36M4VB.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +76 -18
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +2 -2
- package/packages/core/dist/checks.cjs +109 -22
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +1 -1
- package/packages/core/dist/{chunk-6G67ZN72.mjs → chunk-EMDJLFRK.mjs} +111 -24
- package/packages/core/dist/chunk-EMDJLFRK.mjs.map +1 -0
- package/packages/cli/dist/chunk-PEGM6T2X.mjs.map +0 -1
- package/packages/core/dist/chunk-6G67ZN72.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractToolArgumentPayload, lintTraceContract, resolveJsonPointer, resolveTraceContractScope, runTraceChecks, summarizeSemanticParity, workflowMetadataForRun } from './chunk-
|
|
1
|
+
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractToolArgumentPayload, lintTraceContract, resolveJsonPointer, resolveTraceContractScope, runTraceChecks, summarizeSemanticParity, workflowMetadataForRun } from './chunk-EMDJLFRK.mjs';
|
|
2
2
|
import './chunk-FBPDF7HO.mjs';
|
|
3
3
|
import './chunk-RB6WANSW.mjs';
|
|
4
4
|
import './chunk-VLVCLAPB.mjs';
|
|
@@ -2345,10 +2345,17 @@ function contractToRules(contract) {
|
|
|
2345
2345
|
(event) => event.status === "running"
|
|
2346
2346
|
);
|
|
2347
2347
|
if (running.length > 0) {
|
|
2348
|
+
const labels = running.map((event) => {
|
|
2349
|
+
if (event.kind === "TOOL") {
|
|
2350
|
+
return `tool ${resolveCanonicalToolName(event)}`;
|
|
2351
|
+
}
|
|
2352
|
+
return `${event.kind} ${event.name}`;
|
|
2353
|
+
});
|
|
2354
|
+
const message = labels.length === 1 ? `Run contains incomplete running events: ${labels[0]} never completed.` : `Run contains incomplete running events: ${labels.join("; ")}.`;
|
|
2348
2355
|
findings.push(
|
|
2349
2356
|
contractFailFinding(
|
|
2350
2357
|
"contract.run.allowedStatuses",
|
|
2351
|
-
|
|
2358
|
+
message,
|
|
2352
2359
|
running.map((event) => ({
|
|
2353
2360
|
runId: event.runId,
|
|
2354
2361
|
eventId: event.eventId,
|
|
@@ -2357,7 +2364,10 @@ function contractToRules(contract) {
|
|
|
2357
2364
|
status: event.status
|
|
2358
2365
|
})),
|
|
2359
2366
|
"no running events",
|
|
2360
|
-
|
|
2367
|
+
{
|
|
2368
|
+
count: running.length,
|
|
2369
|
+
unfinished: labels
|
|
2370
|
+
}
|
|
2361
2371
|
)
|
|
2362
2372
|
);
|
|
2363
2373
|
}
|
|
@@ -3494,6 +3504,11 @@ function compareFindings(eventById) {
|
|
|
3494
3504
|
if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
|
|
3495
3505
|
return STATUS_RANK[a.status] - STATUS_RANK[b.status];
|
|
3496
3506
|
}
|
|
3507
|
+
if (a.ruleId === "tool.usage") {
|
|
3508
|
+
const aHasEvent = a.evidence[0]?.eventId !== void 0;
|
|
3509
|
+
const bHasEvent = b.evidence[0]?.eventId !== void 0;
|
|
3510
|
+
if (aHasEvent !== bHasEvent) return aHasEvent ? -1 : 1;
|
|
3511
|
+
}
|
|
3497
3512
|
const byRun = compareStrings(a.evidence[0]?.runId, b.evidence[0]?.runId);
|
|
3498
3513
|
if (byRun !== 0) return byRun;
|
|
3499
3514
|
const byTime = eventTimestamp(a, eventById).localeCompare(eventTimestamp(b, eventById));
|
|
@@ -3619,6 +3634,37 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
|
|
|
3619
3634
|
function toolName(event) {
|
|
3620
3635
|
return resolveCanonicalToolName(event);
|
|
3621
3636
|
}
|
|
3637
|
+
function formatToolNameForMessage(name) {
|
|
3638
|
+
const details = [];
|
|
3639
|
+
for (let index = 0; index < name.length; ) {
|
|
3640
|
+
const codePoint = name.codePointAt(index);
|
|
3641
|
+
const width = codePoint > 65535 ? 2 : 1;
|
|
3642
|
+
if (codePoint > 127) {
|
|
3643
|
+
details.push(
|
|
3644
|
+
`U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`
|
|
3645
|
+
);
|
|
3646
|
+
}
|
|
3647
|
+
index += width;
|
|
3648
|
+
}
|
|
3649
|
+
if (details.length === 0) return name;
|
|
3650
|
+
return `"${name}" (contains ${details.join("; ")})`;
|
|
3651
|
+
}
|
|
3652
|
+
function describeRunningEvent(event) {
|
|
3653
|
+
if (event.kind === "TOOL") {
|
|
3654
|
+
return `tool ${formatToolNameForMessage(resolveCanonicalToolName(event))}`;
|
|
3655
|
+
}
|
|
3656
|
+
if (event.kind === "LLM") {
|
|
3657
|
+
return `llm ${stepEndpointName(event, "LLM")}`;
|
|
3658
|
+
}
|
|
3659
|
+
return `${event.kind} ${event.name}`;
|
|
3660
|
+
}
|
|
3661
|
+
function incompleteRunningMessage(prefix, running) {
|
|
3662
|
+
const labels = running.map(describeRunningEvent);
|
|
3663
|
+
if (labels.length === 1) {
|
|
3664
|
+
return `${prefix}: ${labels[0]} never completed.`;
|
|
3665
|
+
}
|
|
3666
|
+
return `${prefix}: ${labels.join("; ")}.`;
|
|
3667
|
+
}
|
|
3622
3668
|
function stepEndpointName(event, kind) {
|
|
3623
3669
|
if (kind === "TOOL") return resolveCanonicalToolName(event);
|
|
3624
3670
|
for (const prefix of ["llm:", "generation:", "transcription:", "speech:"]) {
|
|
@@ -3963,10 +4009,13 @@ function createRunStatusRule(options = {}) {
|
|
|
3963
4009
|
findings.push(
|
|
3964
4010
|
failFinding(
|
|
3965
4011
|
"run.status",
|
|
3966
|
-
"Run contains incomplete running events
|
|
4012
|
+
incompleteRunningMessage("Run contains incomplete running events", running),
|
|
3967
4013
|
running.map((event) => eventEvidence3(event)),
|
|
3968
4014
|
"no running events",
|
|
3969
|
-
|
|
4015
|
+
{
|
|
4016
|
+
count: running.length,
|
|
4017
|
+
unfinished: running.map(describeRunningEvent)
|
|
4018
|
+
}
|
|
3970
4019
|
)
|
|
3971
4020
|
);
|
|
3972
4021
|
}
|
|
@@ -4172,6 +4221,34 @@ function createToolUsageRule(options) {
|
|
|
4172
4221
|
const names = tools.map(toolName);
|
|
4173
4222
|
const nameSet = new Set(names);
|
|
4174
4223
|
const findings = [];
|
|
4224
|
+
const forbidden = new Set(options.forbidden ?? []);
|
|
4225
|
+
const allowed = options.allowed?.length ? new Set(options.allowed) : void 0;
|
|
4226
|
+
for (const event of tools) {
|
|
4227
|
+
const name = toolName(event);
|
|
4228
|
+
const display = formatToolNameForMessage(name);
|
|
4229
|
+
if (forbidden.has(name)) {
|
|
4230
|
+
findings.push(
|
|
4231
|
+
failFinding(
|
|
4232
|
+
"tool.usage",
|
|
4233
|
+
`Forbidden tool ${display} appeared.`,
|
|
4234
|
+
[eventEvidence3(event)],
|
|
4235
|
+
"tool absent",
|
|
4236
|
+
name
|
|
4237
|
+
)
|
|
4238
|
+
);
|
|
4239
|
+
}
|
|
4240
|
+
if (allowed && !allowed.has(name)) {
|
|
4241
|
+
findings.push(
|
|
4242
|
+
failFinding(
|
|
4243
|
+
"tool.usage",
|
|
4244
|
+
`Tool ${display} is not in the allowed tool set.`,
|
|
4245
|
+
[eventEvidence3(event)],
|
|
4246
|
+
[...allowed].sort(),
|
|
4247
|
+
name
|
|
4248
|
+
)
|
|
4249
|
+
);
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4175
4252
|
for (const required of options.required ?? []) {
|
|
4176
4253
|
if (!nameSet.has(required)) {
|
|
4177
4254
|
const otherKinds = [
|
|
@@ -4189,7 +4266,7 @@ function createToolUsageRule(options) {
|
|
|
4189
4266
|
findings.push(
|
|
4190
4267
|
failFinding(
|
|
4191
4268
|
"tool.usage",
|
|
4192
|
-
`Required tool ${required} did not appear.${hint}`,
|
|
4269
|
+
`Required tool ${formatToolNameForMessage(required)} did not appear.${hint}`,
|
|
4193
4270
|
runEvidence(context.selectedRun),
|
|
4194
4271
|
required,
|
|
4195
4272
|
names
|
|
@@ -4197,21 +4274,6 @@ function createToolUsageRule(options) {
|
|
|
4197
4274
|
);
|
|
4198
4275
|
}
|
|
4199
4276
|
}
|
|
4200
|
-
const forbidden = new Set(options.forbidden ?? []);
|
|
4201
|
-
const allowed = options.allowed?.length ? new Set(options.allowed) : void 0;
|
|
4202
|
-
for (const event of tools) {
|
|
4203
|
-
const name = toolName(event);
|
|
4204
|
-
if (forbidden.has(name)) {
|
|
4205
|
-
findings.push(
|
|
4206
|
-
failFinding("tool.usage", `Forbidden tool ${name} appeared.`, [eventEvidence3(event)], "tool absent", name)
|
|
4207
|
-
);
|
|
4208
|
-
}
|
|
4209
|
-
if (allowed && !allowed.has(name)) {
|
|
4210
|
-
findings.push(
|
|
4211
|
-
failFinding("tool.usage", `Tool ${name} is not in the allowed tool set.`, [eventEvidence3(event)], [...allowed].sort(), name)
|
|
4212
|
-
);
|
|
4213
|
-
}
|
|
4214
|
-
}
|
|
4215
4277
|
if (options.minCount !== void 0 && tools.length < options.minCount) {
|
|
4216
4278
|
findings.push(
|
|
4217
4279
|
failFinding("tool.usage", `Tool count ${tools.length} was below minimum ${options.minCount}.`, runEvidence(context.selectedRun), { minCount: options.minCount }, tools.length)
|
|
@@ -4245,6 +4307,28 @@ function createStepOrderingRule(options) {
|
|
|
4245
4307
|
const afterEvents = finishedEvents(context, options.after.kind).filter(
|
|
4246
4308
|
(event) => stepEndpointName(event, options.after.kind) === options.after.name
|
|
4247
4309
|
);
|
|
4310
|
+
const beforeRunning = semanticEvents(context).filter(
|
|
4311
|
+
(event) => event.kind === options.before.kind && event.status === "running" && stepEndpointName(event, options.before.kind) === options.before.name
|
|
4312
|
+
);
|
|
4313
|
+
if (beforeEvents.length === 0 && afterEvents.length > 0 && beforeRunning.length > 0) {
|
|
4314
|
+
const endpointExpected2 = bothTools ? { before: options.before.name, after: options.after.name } : { before: options.before, after: options.after };
|
|
4315
|
+
return [
|
|
4316
|
+
failFinding(
|
|
4317
|
+
ruleId,
|
|
4318
|
+
`${subject} ${beforeLabel} started but never finished before ${afterLabel} ran.`,
|
|
4319
|
+
[
|
|
4320
|
+
...beforeRunning.map((event) => eventEvidence3(event)),
|
|
4321
|
+
eventEvidence3(afterEvents[0])
|
|
4322
|
+
],
|
|
4323
|
+
{ ...endpointExpected2, mode },
|
|
4324
|
+
{
|
|
4325
|
+
code: bothTools ? "tool.order.interval-unresolved" : "step.order.interval-unresolved",
|
|
4326
|
+
unfinishedBefore: true,
|
|
4327
|
+
beforeStatus: "running"
|
|
4328
|
+
}
|
|
4329
|
+
)
|
|
4330
|
+
];
|
|
4331
|
+
}
|
|
4248
4332
|
if (beforeEvents.length === 0 || afterEvents.length === 0) {
|
|
4249
4333
|
if (!requireEndpoints) return [];
|
|
4250
4334
|
const findings = [];
|
|
@@ -4621,10 +4705,13 @@ function createStructureIncompleteRule(options = {}) {
|
|
|
4621
4705
|
findings.push(
|
|
4622
4706
|
failFinding(
|
|
4623
4707
|
"structure.incomplete",
|
|
4624
|
-
"Trace contains incomplete running events
|
|
4708
|
+
incompleteRunningMessage("Trace contains incomplete running events", running),
|
|
4625
4709
|
running.map((event) => eventEvidence3(event, "status")),
|
|
4626
4710
|
"no running events",
|
|
4627
|
-
|
|
4711
|
+
{
|
|
4712
|
+
count: running.length,
|
|
4713
|
+
unfinished: running.map(describeRunningEvent)
|
|
4714
|
+
}
|
|
4628
4715
|
)
|
|
4629
4716
|
);
|
|
4630
4717
|
}
|
|
@@ -5418,5 +5505,5 @@ function runTraceChecks(input, options = {}) {
|
|
|
5418
5505
|
}
|
|
5419
5506
|
|
|
5420
5507
|
export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStepOrderingRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, deriveRelationshipFacts, evaluateToolArgumentValue, evaluateTraceContract, evaluateTraceContractRead, explainTraceContract, extractSessionWorkflowMetadata, extractToolArgumentPayload, lintTraceContract, resolveJsonPointer, resolveTraceContractScope, runTraceChecks, sessionKeyForRun, summarizeSemanticParity, workflowMetadataForRun };
|
|
5421
|
-
//# sourceMappingURL=chunk-
|
|
5422
|
-
//# sourceMappingURL=chunk-
|
|
5508
|
+
//# sourceMappingURL=chunk-EMDJLFRK.mjs.map
|
|
5509
|
+
//# sourceMappingURL=chunk-EMDJLFRK.mjs.map
|