agent-inspect 6.31.21 → 6.31.22
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/package.json +1 -1
- package/packages/cli/dist/{chunk-N5JN26MW.mjs → chunk-EMWA5EKU.mjs} +300 -31
- package/packages/cli/dist/chunk-EMWA5EKU.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +379 -56
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +75 -31
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-VMGRSTG7.mjs → src-VZHGOLTO.mjs} +3 -3
- package/packages/cli/dist/{src-VMGRSTG7.mjs.map → src-VZHGOLTO.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +247 -5
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +6 -5
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +160 -27
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +2 -1
- package/packages/core/dist/chunk-GCZUWY47.mjs +182 -0
- package/packages/core/dist/chunk-GCZUWY47.mjs.map +1 -0
- package/packages/core/dist/{chunk-JE3TUFAQ.mjs → chunk-RBXD7BNX.mjs} +3 -3
- package/packages/core/dist/{chunk-JE3TUFAQ.mjs.map → chunk-RBXD7BNX.mjs.map} +1 -1
- package/packages/core/dist/{chunk-YU6XT5A2.mjs → chunk-S4NU55LU.mjs} +45 -3
- package/packages/core/dist/chunk-S4NU55LU.mjs.map +1 -0
- package/packages/core/dist/{chunk-EIP5CNEL.mjs → chunk-UPGBMRL4.mjs} +49 -3
- package/packages/core/dist/chunk-UPGBMRL4.mjs.map +1 -0
- package/packages/core/dist/{chunk-4CDX5GDS.mjs → chunk-ZOF6ON65.mjs} +104 -99
- package/packages/core/dist/chunk-ZOF6ON65.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +82 -27
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +72 -27
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/logs.cjs +197 -1
- package/packages/core/dist/logs.cjs.map +1 -1
- package/packages/core/dist/logs.mjs +3 -2
- package/packages/core/dist/logs.mjs.map +1 -1
- package/packages/core/dist/persisted.cjs +197 -1
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.mjs +4 -3
- package/packages/core/dist/persisted.mjs.map +1 -1
- package/packages/core/dist/readers.cjs +243 -1
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.mjs +4 -3
- package/packages/cli/dist/chunk-N5JN26MW.mjs.map +0 -1
- package/packages/core/dist/chunk-4CDX5GDS.mjs.map +0 -1
- package/packages/core/dist/chunk-EIP5CNEL.mjs.map +0 -1
- package/packages/core/dist/chunk-YU6XT5A2.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ATTRIBUTION_CONFIDENCES, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, DEFAULT_REDACT_KEYS, truncateStringForProfile, stringContainsHighConfidenceCredential, isCredentialSensitiveKey, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, renderErrorLine, isAgentInspectTrace, persistedInspectEventsToRunTrees, defineTraceContract, filterMetasBySessionScope, evaluateTraceContract, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, getIndent, TreeBuilder, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, projectLogicalEvents, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, isAttributionConfidence, zeroKinds, diffRuns, manualTraceEventsToComparableRun } from './chunk-
|
|
2
|
+
import { ATTRIBUTION_CONFIDENCES, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, IDENTITY_CONFLICT_ATTR, DELIVERY_CONFLICT_ATTR, DEFAULT_REDACT_KEYS, truncateStringForProfile, stringContainsHighConfidenceCredential, isCredentialSensitiveKey, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, renderErrorLine, isAgentInspectTrace, persistedInspectEventsToRunTrees, defineTraceContract, filterMetasBySessionScope, evaluateTraceContract, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, getIndent, TreeBuilder, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, projectLogicalEvents, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, isAttributionConfidence, zeroKinds, diffRuns, manualTraceEventsToComparableRun } from './chunk-EMWA5EKU.mjs';
|
|
3
3
|
import { realpathSync, constants as constants$1, existsSync, readFileSync } from 'fs';
|
|
4
4
|
import path19 from 'path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
@@ -14,7 +14,7 @@ import { createServer } from 'http';
|
|
|
14
14
|
import { createRequire } from 'module';
|
|
15
15
|
|
|
16
16
|
// package.json
|
|
17
|
-
var version = "6.31.
|
|
17
|
+
var version = "6.31.22";
|
|
18
18
|
|
|
19
19
|
// packages/cli/src/trace-dir-scale.ts
|
|
20
20
|
var TRACE_COUNT_WARN = 1e3;
|
|
@@ -2616,43 +2616,81 @@ var STRUCTURAL_IDENTITY_KEYS = [
|
|
|
2616
2616
|
"attemptNumber",
|
|
2617
2617
|
"attempt"
|
|
2618
2618
|
];
|
|
2619
|
-
function
|
|
2619
|
+
function nestedBag(bag) {
|
|
2620
2620
|
if (!bag || typeof bag !== "object") return void 0;
|
|
2621
|
-
const
|
|
2622
|
-
if (typeof
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
if (
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2621
|
+
const nested = bag.metadata;
|
|
2622
|
+
if (!nested || typeof nested !== "object" || Array.isArray(nested)) return void 0;
|
|
2623
|
+
return nested;
|
|
2624
|
+
}
|
|
2625
|
+
function pickBoundedIdentityString(bag, key, maxLen) {
|
|
2626
|
+
if (!bag || typeof bag !== "object") return {};
|
|
2627
|
+
const directRaw = bag[key];
|
|
2628
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
2629
|
+
const direct = typeof directRaw === "string" && directRaw.trim() !== "" ? directRaw.trim().slice(0, maxLen) : void 0;
|
|
2630
|
+
const nested = typeof nestedRaw === "string" && nestedRaw.trim() !== "" ? nestedRaw.trim().slice(0, maxLen) : void 0;
|
|
2631
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
2632
|
+
return { value: direct, conflictAlternate: nested };
|
|
2633
|
+
}
|
|
2634
|
+
if (direct !== void 0) return { value: direct };
|
|
2635
|
+
if (nested !== void 0) return { value: nested };
|
|
2636
|
+
return {};
|
|
2630
2637
|
}
|
|
2631
2638
|
function pickBoundedIdentityNumber(bag, key) {
|
|
2632
|
-
if (!bag || typeof bag !== "object") return
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2639
|
+
if (!bag || typeof bag !== "object") return {};
|
|
2640
|
+
const directRaw = bag[key];
|
|
2641
|
+
const nestedRaw = nestedBag(bag)?.[key];
|
|
2642
|
+
const direct = typeof directRaw === "number" && Number.isFinite(directRaw) ? directRaw : void 0;
|
|
2643
|
+
const nested = typeof nestedRaw === "number" && Number.isFinite(nestedRaw) ? nestedRaw : void 0;
|
|
2644
|
+
if (direct !== void 0 && nested !== void 0 && direct !== nested) {
|
|
2645
|
+
return { value: direct, conflictAlternate: nested };
|
|
2646
|
+
}
|
|
2647
|
+
if (direct !== void 0) return { value: direct };
|
|
2648
|
+
if (nested !== void 0) return { value: nested };
|
|
2649
|
+
return {};
|
|
2638
2650
|
}
|
|
2639
2651
|
function appendStructuralIdentityAttrs(attrs, meta, maxLen) {
|
|
2652
|
+
const conflicts = [];
|
|
2640
2653
|
const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
|
|
2641
|
-
if (operationId !== void 0) {
|
|
2642
|
-
attrs.push(stringAttr("agent_inspect.operation_id", operationId));
|
|
2654
|
+
if (operationId.value !== void 0) {
|
|
2655
|
+
attrs.push(stringAttr("agent_inspect.operation_id", operationId.value));
|
|
2656
|
+
}
|
|
2657
|
+
if (operationId.conflictAlternate !== void 0) {
|
|
2658
|
+
attrs.push(
|
|
2659
|
+
stringAttr(IDENTITY_CONFLICT_ATTR.operationId, operationId.conflictAlternate)
|
|
2660
|
+
);
|
|
2661
|
+
conflicts.push("operationId");
|
|
2643
2662
|
}
|
|
2644
2663
|
const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
|
|
2645
|
-
if (attemptId !== void 0) {
|
|
2646
|
-
attrs.push(stringAttr("agent_inspect.attempt_id", attemptId));
|
|
2664
|
+
if (attemptId.value !== void 0) {
|
|
2665
|
+
attrs.push(stringAttr("agent_inspect.attempt_id", attemptId.value));
|
|
2666
|
+
}
|
|
2667
|
+
if (attemptId.conflictAlternate !== void 0) {
|
|
2668
|
+
attrs.push(stringAttr(IDENTITY_CONFLICT_ATTR.attemptId, attemptId.conflictAlternate));
|
|
2669
|
+
conflicts.push("attemptId");
|
|
2647
2670
|
}
|
|
2648
2671
|
const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
|
|
2649
|
-
if (retryOf !== void 0) {
|
|
2650
|
-
attrs.push(stringAttr("agent_inspect.retry_of", retryOf));
|
|
2672
|
+
if (retryOf.value !== void 0) {
|
|
2673
|
+
attrs.push(stringAttr("agent_inspect.retry_of", retryOf.value));
|
|
2674
|
+
}
|
|
2675
|
+
if (retryOf.conflictAlternate !== void 0) {
|
|
2676
|
+
attrs.push(stringAttr(IDENTITY_CONFLICT_ATTR.retryOf, retryOf.conflictAlternate));
|
|
2677
|
+
conflicts.push("retryOf");
|
|
2651
2678
|
}
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2654
|
-
|
|
2679
|
+
const attemptNumberPrimary = pickBoundedIdentityNumber(meta, "attemptNumber");
|
|
2680
|
+
const attemptNumber2 = attemptNumberPrimary.value !== void 0 || attemptNumberPrimary.conflictAlternate !== void 0 ? attemptNumberPrimary : pickBoundedIdentityNumber(meta, "attempt");
|
|
2681
|
+
if (attemptNumber2.value !== void 0) {
|
|
2682
|
+
attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber2.value));
|
|
2683
|
+
}
|
|
2684
|
+
if (attemptNumber2.conflictAlternate !== void 0) {
|
|
2685
|
+
attrs.push(
|
|
2686
|
+
intAttr(IDENTITY_CONFLICT_ATTR.attemptNumber, attemptNumber2.conflictAlternate)
|
|
2687
|
+
);
|
|
2688
|
+
conflicts.push("attemptNumber");
|
|
2655
2689
|
}
|
|
2690
|
+
if (meta?.[DELIVERY_CONFLICT_ATTR] === true) {
|
|
2691
|
+
attrs.push(boolAttr(DELIVERY_CONFLICT_ATTR, true));
|
|
2692
|
+
}
|
|
2693
|
+
return conflicts;
|
|
2656
2694
|
}
|
|
2657
2695
|
function resolveSpanTimes(ev) {
|
|
2658
2696
|
const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
|
|
@@ -2675,7 +2713,8 @@ function exportOtlpJson(tree, options) {
|
|
|
2675
2713
|
"OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
|
|
2676
2714
|
"Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
|
|
2677
2715
|
"Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
|
|
2678
|
-
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
|
|
2716
|
+
"When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump).",
|
|
2717
|
+
"When direct and nested identity disagree, export prefers direct for non-strict consumers and emits agent_inspect.identity_conflict.* for the nested alternate; this does not certify conflicting identity."
|
|
2679
2718
|
];
|
|
2680
2719
|
const traceId = hexFrom2(`trace:${tree.runId}`, 16);
|
|
2681
2720
|
const includeAttributes = options?.includeAttributes ?? false;
|
|
@@ -2723,11 +2762,16 @@ function exportOtlpJson(tree, options) {
|
|
|
2723
2762
|
if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
|
|
2724
2763
|
if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
|
|
2725
2764
|
}
|
|
2726
|
-
appendStructuralIdentityAttrs(
|
|
2765
|
+
const identityConflicts = appendStructuralIdentityAttrs(
|
|
2727
2766
|
attrs,
|
|
2728
2767
|
meta && typeof meta === "object" ? meta : void 0,
|
|
2729
2768
|
maxLen
|
|
2730
2769
|
);
|
|
2770
|
+
if (identityConflicts.length > 0) {
|
|
2771
|
+
warnings.push(
|
|
2772
|
+
`Identity representation conflict on event ${ev.eventId}: ${identityConflicts.join(", ")} (direct preferred; nested retained on agent_inspect.identity_conflict.*).`
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2731
2775
|
if (includeAttributes && meta && typeof meta === "object") {
|
|
2732
2776
|
const skipKeys = /* @__PURE__ */ new Set([
|
|
2733
2777
|
"tokens",
|
|
@@ -4040,7 +4084,7 @@ async function newestTraceMtimeMs(traceDir) {
|
|
|
4040
4084
|
}
|
|
4041
4085
|
async function loadSessionRuns(traceDir) {
|
|
4042
4086
|
try {
|
|
4043
|
-
const mod = await import('./src-
|
|
4087
|
+
const mod = await import('./src-VZHGOLTO.mjs');
|
|
4044
4088
|
const dbPath = mod.resolveIndexDbPath(traceDir);
|
|
4045
4089
|
const status = mod.indexStatus(dbPath);
|
|
4046
4090
|
if (!status.healthy) {
|
|
@@ -14022,7 +14066,7 @@ function isModuleNotFound4(e) {
|
|
|
14022
14066
|
}
|
|
14023
14067
|
async function loadIndexSqlite() {
|
|
14024
14068
|
try {
|
|
14025
|
-
return await import('./src-
|
|
14069
|
+
return await import('./src-VZHGOLTO.mjs');
|
|
14026
14070
|
} catch (e) {
|
|
14027
14071
|
if (isModuleNotFound4(e)) {
|
|
14028
14072
|
console.error(
|