agent-inspect 6.31.17 → 6.31.18

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.
@@ -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-USZJEEME.mjs';
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-AHARYDFO.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";
17
+ var version = "6.31.18";
18
18
 
19
19
  // packages/cli/src/trace-dir-scale.ts
20
20
  var TRACE_COUNT_WARN = 1e3;
@@ -2609,6 +2609,51 @@ function genAiOperationName(kind) {
2609
2609
  return void 0;
2610
2610
  }
2611
2611
  }
2612
+ var STRUCTURAL_IDENTITY_KEYS = [
2613
+ "operationId",
2614
+ "attemptId",
2615
+ "retryOf",
2616
+ "attemptNumber",
2617
+ "attempt"
2618
+ ];
2619
+ function pickBoundedIdentityString(bag, key, maxLen) {
2620
+ if (!bag || typeof bag !== "object") return void 0;
2621
+ const direct = bag[key];
2622
+ if (typeof direct === "string" && direct.trim() !== "") {
2623
+ return direct.trim().slice(0, maxLen);
2624
+ }
2625
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
2626
+ if (typeof nested === "string" && nested.trim() !== "") {
2627
+ return nested.trim().slice(0, maxLen);
2628
+ }
2629
+ return void 0;
2630
+ }
2631
+ function pickBoundedIdentityNumber(bag, key) {
2632
+ if (!bag || typeof bag !== "object") return void 0;
2633
+ const direct = bag[key];
2634
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
2635
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
2636
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
2637
+ return void 0;
2638
+ }
2639
+ function appendStructuralIdentityAttrs(attrs, meta, maxLen) {
2640
+ const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
2641
+ if (operationId !== void 0) {
2642
+ attrs.push(stringAttr("agent_inspect.operation_id", operationId));
2643
+ }
2644
+ const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
2645
+ if (attemptId !== void 0) {
2646
+ attrs.push(stringAttr("agent_inspect.attempt_id", attemptId));
2647
+ }
2648
+ const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
2649
+ if (retryOf !== void 0) {
2650
+ attrs.push(stringAttr("agent_inspect.retry_of", retryOf));
2651
+ }
2652
+ const attemptNumber2 = pickBoundedIdentityNumber(meta, "attemptNumber") ?? pickBoundedIdentityNumber(meta, "attempt");
2653
+ if (attemptNumber2 !== void 0) {
2654
+ attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber2));
2655
+ }
2656
+ }
2612
2657
  function resolveSpanTimes(ev) {
2613
2658
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
2614
2659
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -2629,7 +2674,8 @@ function exportOtlpJson(tree, options) {
2629
2674
  const warnings = [
2630
2675
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
2631
2676
  "Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
2632
- "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
2677
+ "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)."
2633
2679
  ];
2634
2680
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
2635
2681
  const includeAttributes = options?.includeAttributes ?? false;
@@ -2677,6 +2723,11 @@ function exportOtlpJson(tree, options) {
2677
2723
  if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
2678
2724
  if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
2679
2725
  }
2726
+ appendStructuralIdentityAttrs(
2727
+ attrs,
2728
+ meta && typeof meta === "object" ? meta : void 0,
2729
+ maxLen
2730
+ );
2680
2731
  if (includeAttributes && meta && typeof meta === "object") {
2681
2732
  const skipKeys = /* @__PURE__ */ new Set([
2682
2733
  "tokens",
@@ -2685,7 +2736,8 @@ function exportOtlpJson(tree, options) {
2685
2736
  "responseModel",
2686
2737
  "responseModelId",
2687
2738
  "provider",
2688
- "originalSourceType"
2739
+ "originalSourceType",
2740
+ ...STRUCTURAL_IDENTITY_KEYS
2689
2741
  ]);
2690
2742
  for (const [k, v] of Object.entries(meta)) {
2691
2743
  if (skipKeys.has(k)) continue;
@@ -3988,7 +4040,7 @@ async function newestTraceMtimeMs(traceDir) {
3988
4040
  }
3989
4041
  async function loadSessionRuns(traceDir) {
3990
4042
  try {
3991
- const mod = await import('./src-EY4EY456.mjs');
4043
+ const mod = await import('./src-YNZZ2KYR.mjs');
3992
4044
  const dbPath = mod.resolveIndexDbPath(traceDir);
3993
4045
  const status = mod.indexStatus(dbPath);
3994
4046
  if (!status.healthy) {
@@ -13970,7 +14022,7 @@ function isModuleNotFound4(e) {
13970
14022
  }
13971
14023
  async function loadIndexSqlite() {
13972
14024
  try {
13973
- return await import('./src-EY4EY456.mjs');
14025
+ return await import('./src-YNZZ2KYR.mjs');
13974
14026
  } catch (e) {
13975
14027
  if (isModuleNotFound4(e)) {
13976
14028
  console.error(