agent-inspect 6.31.11 → 6.31.13
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 +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-MQYHJL3W.mjs → chunk-ZAYVAHIH.mjs} +206 -34
- package/packages/cli/dist/chunk-ZAYVAHIH.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +413 -67
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +209 -36
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-76R6E2LQ.mjs → src-KP4UIFK5.mjs} +3 -3
- package/packages/cli/dist/{src-76R6E2LQ.mjs.map → src-KP4UIFK5.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +204 -32
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +151 -28
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/{chunk-OAUNS5CS.mjs → chunk-JE3TUFAQ.mjs} +3 -3
- package/packages/core/dist/{chunk-OAUNS5CS.mjs.map → chunk-JE3TUFAQ.mjs.map} +1 -1
- package/packages/core/dist/{chunk-QOC3PJO3.mjs → chunk-NJUSSJX3.mjs} +3 -3
- package/packages/core/dist/{chunk-QOC3PJO3.mjs.map → chunk-NJUSSJX3.mjs.map} +1 -1
- package/packages/core/dist/{chunk-AK5EN4U2.mjs → chunk-YU6XT5A2.mjs} +58 -9
- package/packages/core/dist/chunk-YU6XT5A2.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +205 -32
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +205 -32
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/logs.cjs +56 -7
- package/packages/core/dist/logs.cjs.map +1 -1
- package/packages/core/dist/logs.mjs +2 -2
- package/packages/core/dist/persisted.cjs +56 -7
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.mjs +3 -3
- package/packages/core/dist/readers.cjs +56 -7
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.mjs +3 -3
- package/packages/cli/dist/chunk-MQYHJL3W.mjs.map +0 -1
- package/packages/core/dist/chunk-AK5EN4U2.mjs.map +0 -1
|
@@ -11,12 +11,12 @@ import { escapeHtml, flattenTree } from './chunk-CAWPF22J.mjs';
|
|
|
11
11
|
import { resolveRedactionProfile, readTraceEventsFromFile, stringContainsHighConfidenceCredential } from './chunk-DK3OW6UI.mjs';
|
|
12
12
|
export { DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, getRunIdFromTraceFileName, initializeTraceFile, listTraceFiles, prepareMetadataForDisk, prepareTraceEventForDisk, readTraceEvents, readTraceFile, resolveRedactionProfile, resolveTraceSafetyOptions, serializeEvent, validateEvent, writeTraceEvent } from './chunk-DK3OW6UI.mjs';
|
|
13
13
|
import { Redactor } from './chunk-VLVCLAPB.mjs';
|
|
14
|
-
import { openTrace } from './chunk-
|
|
15
|
-
import './chunk-
|
|
14
|
+
import { openTrace } from './chunk-NJUSSJX3.mjs';
|
|
15
|
+
import './chunk-JE3TUFAQ.mjs';
|
|
16
16
|
import { projectLogicalEvents } from './chunk-AHUZNHFI.mjs';
|
|
17
17
|
import './chunk-S4YWKV4G.mjs';
|
|
18
18
|
import './chunk-S6LQBLX5.mjs';
|
|
19
|
-
import './chunk-
|
|
19
|
+
import './chunk-YU6XT5A2.mjs';
|
|
20
20
|
import { parseDuration, isTraceEvent, getTraceFilePath } from './chunk-7DHSWDKB.mjs';
|
|
21
21
|
export { DEFAULT_TRACE_DIR_NAME, FALLBACK_TRACE_DIR, MAX_NAME_LENGTH, RUNS_DIR_NAME, createRunId, createStepId, ensureTraceDir, formatDuration, formatError, formatTimestamp, getDefaultTraceDir, getTraceFilePath, isStepStatus, isStepType, isTraceEvent, parseDuration, parseTraceJsonl, truncateName, unknownTraceFormatMessage, warn } from './chunk-7DHSWDKB.mjs';
|
|
22
22
|
import { persistedInspectEventsToTraceEvents } from './chunk-EE5Z2GQ3.mjs';
|
|
@@ -381,12 +381,14 @@ function topKinds(run) {
|
|
|
381
381
|
function countErrorNodes(nodes) {
|
|
382
382
|
return nodes.filter((entry) => entry.node.event.status === "error").length;
|
|
383
383
|
}
|
|
384
|
+
function isExecutionStepKind(kind) {
|
|
385
|
+
return kind !== "RUN" && kind !== "OUTCOME";
|
|
386
|
+
}
|
|
384
387
|
function slowestNode(nodes) {
|
|
385
388
|
return nodes.filter(
|
|
386
389
|
(entry) => entry.node.event.durationMs !== void 0 && // The RUN boundary spans the whole run, so its duration always dominates
|
|
387
|
-
// and shadows every real step.
|
|
388
|
-
|
|
389
|
-
entry.node.event.kind !== "RUN"
|
|
390
|
+
// and shadows every real step. OUTCOME is a linked result, not execution.
|
|
391
|
+
isExecutionStepKind(entry.node.event.kind)
|
|
390
392
|
).sort((a, b) => {
|
|
391
393
|
const delta = (b.node.event.durationMs ?? 0) - (a.node.event.durationMs ?? 0);
|
|
392
394
|
return delta !== 0 ? delta : a.index - b.index;
|
|
@@ -439,6 +441,12 @@ function buildFacts(run, redactor, events) {
|
|
|
439
441
|
const scoped = events.filter((event) => event.runId === run.runId);
|
|
440
442
|
const { logicalEvents: logical } = projectLogicalEvents(scoped);
|
|
441
443
|
const logicalSteps = logical.filter((event) => event.kind !== "RUN");
|
|
444
|
+
const executionSteps = logical.filter((event) => isExecutionStepKind(event.kind));
|
|
445
|
+
const executionByKind = {
|
|
446
|
+
LLM: executionSteps.filter((event) => event.kind === "LLM").length,
|
|
447
|
+
TOOL: executionSteps.filter((event) => event.kind === "TOOL").length,
|
|
448
|
+
LOGIC: executionSteps.filter((event) => event.kind === "LOGIC").length
|
|
449
|
+
};
|
|
442
450
|
facts.push(
|
|
443
451
|
fact("run.rawEventCount", "Raw persisted event count", scoped.length, redactor),
|
|
444
452
|
fact(
|
|
@@ -452,9 +460,21 @@ function buildFacts(run, redactor, events) {
|
|
|
452
460
|
"Logical lifecycle event count (including RUN)",
|
|
453
461
|
logical.length,
|
|
454
462
|
redactor
|
|
463
|
+
),
|
|
464
|
+
fact(
|
|
465
|
+
"run.executionStepCount",
|
|
466
|
+
"Execution step count (excludes RUN and OUTCOME)",
|
|
467
|
+
executionSteps.length,
|
|
468
|
+
redactor
|
|
469
|
+
),
|
|
470
|
+
fact(
|
|
471
|
+
"run.executionStepKinds",
|
|
472
|
+
"Execution step kind counts",
|
|
473
|
+
executionByKind,
|
|
474
|
+
redactor
|
|
455
475
|
)
|
|
456
476
|
);
|
|
457
|
-
const slowestLogical = [...
|
|
477
|
+
const slowestLogical = [...executionSteps].filter((event) => typeof event.durationMs === "number").sort((a, b) => {
|
|
458
478
|
const delta = (b.durationMs ?? 0) - (a.durationMs ?? 0);
|
|
459
479
|
return delta !== 0 ? delta : a.eventId.localeCompare(b.eventId);
|
|
460
480
|
})[0];
|
|
@@ -3394,25 +3414,86 @@ function asStringArray(value, label) {
|
|
|
3394
3414
|
function asPositiveNumber(value, label) {
|
|
3395
3415
|
if (value === void 0) return void 0;
|
|
3396
3416
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
3397
|
-
throw new Error(`${label} must be a non-negative number.`);
|
|
3417
|
+
throw new Error(`${label} must be a non-negative finite number.`);
|
|
3398
3418
|
}
|
|
3399
3419
|
return value;
|
|
3400
3420
|
}
|
|
3401
|
-
function
|
|
3421
|
+
function asBoolean(value, label) {
|
|
3402
3422
|
if (value === void 0) return void 0;
|
|
3423
|
+
if (typeof value !== "boolean") {
|
|
3424
|
+
throw new Error(`${label} must be a boolean (not a string or other type).`);
|
|
3425
|
+
}
|
|
3426
|
+
return value;
|
|
3427
|
+
}
|
|
3428
|
+
function assertObject(value, label) {
|
|
3403
3429
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
3404
3430
|
throw new Error(`${label} must be an object.`);
|
|
3405
3431
|
}
|
|
3406
|
-
|
|
3432
|
+
return value;
|
|
3433
|
+
}
|
|
3434
|
+
function assertKnownKeys(raw, allowed, label) {
|
|
3435
|
+
const allowedSet = new Set(allowed);
|
|
3436
|
+
for (const key of Object.keys(raw)) {
|
|
3437
|
+
if (!allowedSet.has(key)) {
|
|
3438
|
+
throw new Error(`${label} has unknown key "${key}".`);
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
var CASE_KEYS = [
|
|
3443
|
+
"id",
|
|
3444
|
+
"trace",
|
|
3445
|
+
"runId",
|
|
3446
|
+
"input",
|
|
3447
|
+
"requireTools",
|
|
3448
|
+
"forbidTools",
|
|
3449
|
+
"maxDurationMs",
|
|
3450
|
+
"expectedObservations",
|
|
3451
|
+
"expect"
|
|
3452
|
+
];
|
|
3453
|
+
var EXPECT_KEYS = [
|
|
3454
|
+
"checkStatus",
|
|
3455
|
+
"findingRuleIds",
|
|
3456
|
+
"rejectUnexpectedFindings",
|
|
3457
|
+
"minAssertions"
|
|
3458
|
+
];
|
|
3459
|
+
var CHECKS_KEYS = ["select", "run", "tool", "llm"];
|
|
3460
|
+
var CHECKS_RUN_KEYS = ["maxDurationMs", "maxDepth"];
|
|
3461
|
+
var CHECKS_TOOL_KEYS = ["required", "forbidden"];
|
|
3462
|
+
var CHECKS_LLM_KEYS = ["allowedModels", "maxTotalTokens"];
|
|
3463
|
+
var EVAL_KEYS = [
|
|
3464
|
+
"requireSuccess",
|
|
3465
|
+
"requiredTools",
|
|
3466
|
+
"forbiddenTools",
|
|
3467
|
+
"maxDurationMs",
|
|
3468
|
+
"maxDepth",
|
|
3469
|
+
"maxRetries",
|
|
3470
|
+
"maxTotalTokens"
|
|
3471
|
+
];
|
|
3472
|
+
var ROOT_KEYS = [
|
|
3473
|
+
"name",
|
|
3474
|
+
"traces",
|
|
3475
|
+
"cases",
|
|
3476
|
+
"checks",
|
|
3477
|
+
"eval",
|
|
3478
|
+
"redactionProfile",
|
|
3479
|
+
"artifacts",
|
|
3480
|
+
"baseline",
|
|
3481
|
+
"candidate"
|
|
3482
|
+
];
|
|
3483
|
+
function asExpectConfig(value, label) {
|
|
3484
|
+
if (value === void 0) return void 0;
|
|
3485
|
+
const raw = assertObject(value, label);
|
|
3486
|
+
assertKnownKeys(raw, EXPECT_KEYS, label);
|
|
3407
3487
|
const checkStatus = raw.checkStatus;
|
|
3408
3488
|
if (checkStatus !== "pass" && checkStatus !== "fail" && checkStatus !== "error") {
|
|
3409
3489
|
throw new Error(`${label}.checkStatus must be "pass", "fail", or "error".`);
|
|
3410
3490
|
}
|
|
3411
3491
|
const findingRuleIds = asStringArray(raw.findingRuleIds, `${label}.findingRuleIds`);
|
|
3412
3492
|
const minAssertions = asPositiveNumber(raw.minAssertions, `${label}.minAssertions`);
|
|
3413
|
-
const rejectUnexpectedFindings =
|
|
3414
|
-
|
|
3415
|
-
|
|
3493
|
+
const rejectUnexpectedFindings = asBoolean(
|
|
3494
|
+
raw.rejectUnexpectedFindings,
|
|
3495
|
+
`${label}.rejectUnexpectedFindings`
|
|
3496
|
+
);
|
|
3416
3497
|
return {
|
|
3417
3498
|
checkStatus,
|
|
3418
3499
|
...findingRuleIds !== void 0 ? { findingRuleIds } : {},
|
|
@@ -3420,6 +3501,56 @@ function asExpectConfig(value, label) {
|
|
|
3420
3501
|
...minAssertions !== void 0 ? { minAssertions } : {}
|
|
3421
3502
|
};
|
|
3422
3503
|
}
|
|
3504
|
+
function asChecksConfig(value, label) {
|
|
3505
|
+
const raw = assertObject(value, label);
|
|
3506
|
+
assertKnownKeys(raw, CHECKS_KEYS, label);
|
|
3507
|
+
const checks = {};
|
|
3508
|
+
const select = asStringArray(raw.select, `${label}.select`);
|
|
3509
|
+
if (select !== void 0) checks.select = select;
|
|
3510
|
+
if (raw.run !== void 0) {
|
|
3511
|
+
const run = assertObject(raw.run, `${label}.run`);
|
|
3512
|
+
assertKnownKeys(run, CHECKS_RUN_KEYS, `${label}.run`);
|
|
3513
|
+
checks.run = {
|
|
3514
|
+
...asPositiveNumber(run.maxDurationMs, `${label}.run.maxDurationMs`) !== void 0 ? { maxDurationMs: asPositiveNumber(run.maxDurationMs, `${label}.run.maxDurationMs`) } : {},
|
|
3515
|
+
...asPositiveNumber(run.maxDepth, `${label}.run.maxDepth`) !== void 0 ? { maxDepth: asPositiveNumber(run.maxDepth, `${label}.run.maxDepth`) } : {}
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
if (raw.tool !== void 0) {
|
|
3519
|
+
const tool = assertObject(raw.tool, `${label}.tool`);
|
|
3520
|
+
assertKnownKeys(tool, CHECKS_TOOL_KEYS, `${label}.tool`);
|
|
3521
|
+
checks.tool = {
|
|
3522
|
+
...asStringArray(tool.required, `${label}.tool.required`) !== void 0 ? { required: asStringArray(tool.required, `${label}.tool.required`) } : {},
|
|
3523
|
+
...asStringArray(tool.forbidden, `${label}.tool.forbidden`) !== void 0 ? { forbidden: asStringArray(tool.forbidden, `${label}.tool.forbidden`) } : {}
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
if (raw.llm !== void 0) {
|
|
3527
|
+
const llm = assertObject(raw.llm, `${label}.llm`);
|
|
3528
|
+
assertKnownKeys(llm, CHECKS_LLM_KEYS, `${label}.llm`);
|
|
3529
|
+
checks.llm = {
|
|
3530
|
+
...asStringArray(llm.allowedModels, `${label}.llm.allowedModels`) !== void 0 ? { allowedModels: asStringArray(llm.allowedModels, `${label}.llm.allowedModels`) } : {},
|
|
3531
|
+
...asPositiveNumber(llm.maxTotalTokens, `${label}.llm.maxTotalTokens`) !== void 0 ? {
|
|
3532
|
+
maxTotalTokens: asPositiveNumber(
|
|
3533
|
+
llm.maxTotalTokens,
|
|
3534
|
+
`${label}.llm.maxTotalTokens`
|
|
3535
|
+
)
|
|
3536
|
+
} : {}
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
return checks;
|
|
3540
|
+
}
|
|
3541
|
+
function asEvalConfig(value, label) {
|
|
3542
|
+
const raw = assertObject(value, label);
|
|
3543
|
+
assertKnownKeys(raw, EVAL_KEYS, label);
|
|
3544
|
+
return {
|
|
3545
|
+
...asBoolean(raw.requireSuccess, `${label}.requireSuccess`) !== void 0 ? { requireSuccess: asBoolean(raw.requireSuccess, `${label}.requireSuccess`) } : {},
|
|
3546
|
+
...asStringArray(raw.requiredTools, `${label}.requiredTools`) !== void 0 ? { requiredTools: asStringArray(raw.requiredTools, `${label}.requiredTools`) } : {},
|
|
3547
|
+
...asStringArray(raw.forbiddenTools, `${label}.forbiddenTools`) !== void 0 ? { forbiddenTools: asStringArray(raw.forbiddenTools, `${label}.forbiddenTools`) } : {},
|
|
3548
|
+
...asPositiveNumber(raw.maxDurationMs, `${label}.maxDurationMs`) !== void 0 ? { maxDurationMs: asPositiveNumber(raw.maxDurationMs, `${label}.maxDurationMs`) } : {},
|
|
3549
|
+
...asPositiveNumber(raw.maxDepth, `${label}.maxDepth`) !== void 0 ? { maxDepth: asPositiveNumber(raw.maxDepth, `${label}.maxDepth`) } : {},
|
|
3550
|
+
...asPositiveNumber(raw.maxRetries, `${label}.maxRetries`) !== void 0 ? { maxRetries: asPositiveNumber(raw.maxRetries, `${label}.maxRetries`) } : {},
|
|
3551
|
+
...asPositiveNumber(raw.maxTotalTokens, `${label}.maxTotalTokens`) !== void 0 ? { maxTotalTokens: asPositiveNumber(raw.maxTotalTokens, `${label}.maxTotalTokens`) } : {}
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3423
3554
|
function validateCaseConfig(value, index) {
|
|
3424
3555
|
const diagnostics = [];
|
|
3425
3556
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -3430,6 +3561,7 @@ function validateCaseConfig(value, index) {
|
|
|
3430
3561
|
}
|
|
3431
3562
|
const raw = value;
|
|
3432
3563
|
try {
|
|
3564
|
+
assertKnownKeys(raw, CASE_KEYS, `cases[${index}]`);
|
|
3433
3565
|
const id = asString(raw.id, `cases[${index}].id`);
|
|
3434
3566
|
if (id === void 0) {
|
|
3435
3567
|
diagnostics.push(
|
|
@@ -3478,6 +3610,7 @@ function normalizeSuiteConfig(value) {
|
|
|
3478
3610
|
throw new Error("Suite config must export an object.");
|
|
3479
3611
|
}
|
|
3480
3612
|
const raw = value;
|
|
3613
|
+
assertKnownKeys(raw, ROOT_KEYS, "suite config");
|
|
3481
3614
|
const name = asString(raw.name, "name");
|
|
3482
3615
|
const traces = asString(raw.traces, "traces");
|
|
3483
3616
|
if (name === void 0) throw new Error("name is required.");
|
|
@@ -3506,25 +3639,15 @@ function normalizeSuiteConfig(value) {
|
|
|
3506
3639
|
}
|
|
3507
3640
|
const config = { name, traces, cases };
|
|
3508
3641
|
if (raw.checks !== void 0) {
|
|
3509
|
-
|
|
3510
|
-
throw new Error("checks must be an object.");
|
|
3511
|
-
}
|
|
3512
|
-
config.checks = raw.checks;
|
|
3642
|
+
config.checks = asChecksConfig(raw.checks, "checks");
|
|
3513
3643
|
}
|
|
3514
3644
|
if (raw.eval !== void 0) {
|
|
3515
|
-
|
|
3516
|
-
throw new Error("eval must be an object.");
|
|
3517
|
-
}
|
|
3518
|
-
config.eval = raw.eval;
|
|
3645
|
+
config.eval = asEvalConfig(raw.eval, "eval");
|
|
3519
3646
|
}
|
|
3520
3647
|
if (raw.artifacts !== void 0) {
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
const outputDir = asString(
|
|
3525
|
-
raw.artifacts.outputDir,
|
|
3526
|
-
"artifacts.outputDir"
|
|
3527
|
-
);
|
|
3648
|
+
const artifacts = assertObject(raw.artifacts, "artifacts");
|
|
3649
|
+
assertKnownKeys(artifacts, ["outputDir"], "artifacts");
|
|
3650
|
+
const outputDir = asString(artifacts.outputDir, "artifacts.outputDir");
|
|
3528
3651
|
config.artifacts = outputDir !== void 0 ? { outputDir } : {};
|
|
3529
3652
|
}
|
|
3530
3653
|
if (raw.baseline !== void 0) {
|