agent-inspect 6.17.7 → 6.18.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.
@@ -1,4 +1,5 @@
1
1
  export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-Ca5yK8Cs.cjs';
2
+ import { R as RedactionRule } from './log-config-CFlIJHTf.cjs';
2
3
  import { R as RedactionProfile, h as TraceEvent, E as ErrorInfo, b as RunStatus, e as StepStatus, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-UnrNaTo2.cjs';
3
4
  export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-UnrNaTo2.cjs';
4
5
  import { a as InspectRunTree } from './inspect-event-DRthdZlf.cjs';
@@ -9,7 +10,6 @@ import { b as ObservedOutcome } from './types-B562HgN_.cjs';
9
10
  export { O as ObservedOutcomeStatus } from './types-B562HgN_.cjs';
10
11
  import { b as TraceCheckResult, N as TraceCheckStatus } from './index-DWu54Y28.cjs';
11
12
  import './writers.cjs';
12
- import './log-config-CFlIJHTf.cjs';
13
13
  import './index-B259NKkH.cjs';
14
14
 
15
15
  interface ResolvedRedactionProfile {
@@ -24,6 +24,85 @@ declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRe
24
24
  declare function extractOutcomesFromTraceEvents(events: readonly TraceEvent[]): ObservedOutcome[];
25
25
  declare function extractOutcomesFromPersistedEvents(events: readonly PersistedInspectEvent[]): ObservedOutcome[];
26
26
 
27
+ /** Default bound for adapter preview fields (characters). */
28
+ declare const DEFAULT_ADAPTER_MAX_PREVIEW_CHARS = 200;
29
+ /**
30
+ * Capture policy shared by the official adapters.
31
+ *
32
+ * `metadata-only` is the default everywhere and never persists framework
33
+ * payload content. `preview` opts into bounded, redacted previews.
34
+ */
35
+ type AdapterCaptureMode = "metadata-only" | "preview";
36
+ /** Stable diagnostic codes emitted by shared preview capture. */
37
+ declare const ADAPTER_CAPTURE_DIAGNOSTIC_CODES: readonly ["AI_CAPTURE_FIELD_UNAVAILABLE", "AI_CAPTURE_PREVIEW_TRUNCATED", "AI_CAPTURE_PREVIEW_REDACTED"];
38
+ type AdapterCaptureDiagnosticCode = (typeof ADAPTER_CAPTURE_DIAGNOSTIC_CODES)[number];
39
+ /** One bounded diagnostic. Never contains preview content or filesystem paths. */
40
+ interface AdapterCaptureDiagnostic {
41
+ readonly code: AdapterCaptureDiagnosticCode;
42
+ readonly message: string;
43
+ /** Persisted attribute name the diagnostic refers to (e.g. `inputPreview`). */
44
+ readonly field: string;
45
+ readonly capture: AdapterCaptureMode;
46
+ }
47
+ /** Optional consumer hook for adapter capture diagnostics. */
48
+ type AdapterDiagnosticListener = (diagnostic: AdapterCaptureDiagnostic) => void;
49
+ /** Preview capture options accepted by every official adapter. */
50
+ interface AdapterPreviewCaptureOptions {
51
+ /** Defaults to `metadata-only`. */
52
+ capture?: AdapterCaptureMode;
53
+ /** Redaction profile applied to preview values before they reach an event. */
54
+ redactionProfile?: RedactionProfile;
55
+ /** Upper bound for each serialized preview field. */
56
+ maxPreviewChars?: number;
57
+ /** Extra adapter-supplied redaction rules. */
58
+ redact?: RedactionRule[];
59
+ /** Receives bounded capture diagnostics. Listener failures are swallowed. */
60
+ onDiagnostic?: AdapterDiagnosticListener;
61
+ }
62
+ /** Bounded capture counters for adapter `getDiagnostics()` surfaces. */
63
+ interface AdapterCaptureDiagnostics {
64
+ readonly capture: AdapterCaptureMode;
65
+ readonly redactionProfile: RedactionProfile;
66
+ readonly maxPreviewChars: number;
67
+ readonly previewFieldsCaptured: number;
68
+ readonly previewFieldsUnavailable: number;
69
+ readonly previewFieldsTruncated: number;
70
+ readonly previewFieldsRedacted: number;
71
+ readonly lastDiagnosticCode?: AdapterCaptureDiagnosticCode;
72
+ readonly lastDiagnosticMessage?: string;
73
+ }
74
+ /** Shared preview capture handle owned by one adapter instance. */
75
+ interface AdapterPreviewCapture {
76
+ /** Effective capture mode (adapters no longer downgrade `preview`). */
77
+ readonly capture: AdapterCaptureMode;
78
+ readonly previewEnabled: boolean;
79
+ readonly maxPreviewChars: number;
80
+ readonly redactionProfile: RedactionProfile;
81
+ /** Normalizes a logical field to a persisted `*Preview` attribute name. */
82
+ previewFieldName(field: string): string;
83
+ /**
84
+ * Returns a bounded, redacted preview string, or `undefined` when capture is
85
+ * metadata-only or the field could not be sourced.
86
+ */
87
+ capturePreviewField(field: string, value: unknown): string | undefined;
88
+ /** Writes every available preview onto `target` and returns it. */
89
+ applyPreviewFields(target: Record<string, unknown>, fields: Record<string, unknown>): Record<string, unknown>;
90
+ getDiagnostics(): AdapterCaptureDiagnostics;
91
+ }
92
+ /**
93
+ * JSON-ish serialization that tolerates cycles, bigints, and throwing getters,
94
+ * bounded to `maxChars`. Returns `undefined` for a non-positive bound or a
95
+ * value JSON cannot represent.
96
+ */
97
+ declare function serializeAdapterPreview(value: unknown, maxChars: number): string | undefined;
98
+ /**
99
+ * Resolves the effective preview bound. Profile caps apply so a `share` or
100
+ * `strict` profile cannot be widened by a larger adapter option.
101
+ */
102
+ declare function resolveAdapterMaxPreviewChars(value: unknown, profile?: RedactionProfile): number;
103
+ /** Creates the shared preview capture handle for one adapter instance. */
104
+ declare function createAdapterPreviewCapture(options?: AdapterPreviewCaptureOptions): AdapterPreviewCapture;
105
+
27
106
  /** Two spaces per nesting level in terminal output. */
28
107
  declare const TERMINAL_INDENT = " ";
29
108
  /** Max display length for names in terminal output. */
@@ -1443,4 +1522,4 @@ declare function renderGateGithubStepSummary(result: GateResult): string;
1443
1522
  declare function renderGateJUnit(result: GateResult): string;
1444
1523
  declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
1445
1524
 
1446
- export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CausalContractFindingInput, type CausalFailureKind, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, type EnrichSessionSummaryOptions, ErrorInfo, type EvidenceCheckFindingSummary, type EvidenceCiPackageFiles, type EvidenceCiPackageInput, type EvidenceContractsViewInput, type EvidenceFileEntry, type EvidenceFileRole, type EvidenceFormatVersion, type EvidenceHtmlShellInput, type EvidenceManifest, type EvidencePackagedFile, type EvidenceProvenanceViewInput, type EvidenceRedactionProfile, type EvidenceSafeStatus, type EvidenceSafetyViewInput, type EvidenceSourceHash, type EvidenceVerificationPolicy, type EvidenceVerifyIssue, type EvidenceVerifyOptions, type EvidenceVerifyResult, type EvidenceVerifyStatus, type EvidenceViewId, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type FindFirstCausalFailureOptions, type FirstCausalFailure, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, ObservedOutcome, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, type SuiteTemplateId, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, type ZipEntry, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, findFirstCausalFailure, formatDuration, formatError, formatStepLabel, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getSuiteTemplate, getTraceFilePath, groupSessionCohorts, inferEvidenceFileRole, initializeTraceFile, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeEvent, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory, warn, writeTraceEvent };
1525
+ export { ADAPTER_CAPTURE_DIAGNOSTIC_CODES, type ActivityEntry, type ActivitySummary, type AdapterCaptureDiagnostic, type AdapterCaptureDiagnosticCode, type AdapterCaptureDiagnostics, type AdapterCaptureMode, type AdapterDiagnosticListener, type AdapterPreviewCapture, type AdapterPreviewCaptureOptions, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CausalContractFindingInput, type CausalFailureKind, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_ADAPTER_MAX_PREVIEW_CHARS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, type EnrichSessionSummaryOptions, ErrorInfo, type EvidenceCheckFindingSummary, type EvidenceCiPackageFiles, type EvidenceCiPackageInput, type EvidenceContractsViewInput, type EvidenceFileEntry, type EvidenceFileRole, type EvidenceFormatVersion, type EvidenceHtmlShellInput, type EvidenceManifest, type EvidencePackagedFile, type EvidenceProvenanceViewInput, type EvidenceRedactionProfile, type EvidenceSafeStatus, type EvidenceSafetyViewInput, type EvidenceSourceHash, type EvidenceVerificationPolicy, type EvidenceVerifyIssue, type EvidenceVerifyOptions, type EvidenceVerifyResult, type EvidenceVerifyStatus, type EvidenceViewId, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type FindFirstCausalFailureOptions, type FirstCausalFailure, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, ObservedOutcome, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, type SuiteTemplateId, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, type ZipEntry, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, createAdapterPreviewCapture, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, findFirstCausalFailure, formatDuration, formatError, formatStepLabel, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getSuiteTemplate, getTraceFilePath, groupSessionCohorts, inferEvidenceFileRole, initializeTraceFile, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveAdapterMaxPreviewChars, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeAdapterPreview, serializeEvent, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory, warn, writeTraceEvent };
@@ -1,4 +1,5 @@
1
1
  export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-D6cS4XIL.js';
2
+ import { R as RedactionRule } from './log-config-OZRfpHED.js';
2
3
  import { R as RedactionProfile, h as TraceEvent, E as ErrorInfo, b as RunStatus, e as StepStatus, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types--ainI31J.js';
3
4
  export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types--ainI31J.js';
4
5
  import { a as InspectRunTree } from './inspect-event-DRthdZlf.js';
@@ -9,7 +10,6 @@ import { b as ObservedOutcome } from './types-B562HgN_.js';
9
10
  export { O as ObservedOutcomeStatus } from './types-B562HgN_.js';
10
11
  import { b as TraceCheckResult, N as TraceCheckStatus } from './index-DlwbVqEs.js';
11
12
  import './writers.js';
12
- import './log-config-OZRfpHED.js';
13
13
  import './index-B9ZGvUVL.js';
14
14
 
15
15
  interface ResolvedRedactionProfile {
@@ -24,6 +24,85 @@ declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRe
24
24
  declare function extractOutcomesFromTraceEvents(events: readonly TraceEvent[]): ObservedOutcome[];
25
25
  declare function extractOutcomesFromPersistedEvents(events: readonly PersistedInspectEvent[]): ObservedOutcome[];
26
26
 
27
+ /** Default bound for adapter preview fields (characters). */
28
+ declare const DEFAULT_ADAPTER_MAX_PREVIEW_CHARS = 200;
29
+ /**
30
+ * Capture policy shared by the official adapters.
31
+ *
32
+ * `metadata-only` is the default everywhere and never persists framework
33
+ * payload content. `preview` opts into bounded, redacted previews.
34
+ */
35
+ type AdapterCaptureMode = "metadata-only" | "preview";
36
+ /** Stable diagnostic codes emitted by shared preview capture. */
37
+ declare const ADAPTER_CAPTURE_DIAGNOSTIC_CODES: readonly ["AI_CAPTURE_FIELD_UNAVAILABLE", "AI_CAPTURE_PREVIEW_TRUNCATED", "AI_CAPTURE_PREVIEW_REDACTED"];
38
+ type AdapterCaptureDiagnosticCode = (typeof ADAPTER_CAPTURE_DIAGNOSTIC_CODES)[number];
39
+ /** One bounded diagnostic. Never contains preview content or filesystem paths. */
40
+ interface AdapterCaptureDiagnostic {
41
+ readonly code: AdapterCaptureDiagnosticCode;
42
+ readonly message: string;
43
+ /** Persisted attribute name the diagnostic refers to (e.g. `inputPreview`). */
44
+ readonly field: string;
45
+ readonly capture: AdapterCaptureMode;
46
+ }
47
+ /** Optional consumer hook for adapter capture diagnostics. */
48
+ type AdapterDiagnosticListener = (diagnostic: AdapterCaptureDiagnostic) => void;
49
+ /** Preview capture options accepted by every official adapter. */
50
+ interface AdapterPreviewCaptureOptions {
51
+ /** Defaults to `metadata-only`. */
52
+ capture?: AdapterCaptureMode;
53
+ /** Redaction profile applied to preview values before they reach an event. */
54
+ redactionProfile?: RedactionProfile;
55
+ /** Upper bound for each serialized preview field. */
56
+ maxPreviewChars?: number;
57
+ /** Extra adapter-supplied redaction rules. */
58
+ redact?: RedactionRule[];
59
+ /** Receives bounded capture diagnostics. Listener failures are swallowed. */
60
+ onDiagnostic?: AdapterDiagnosticListener;
61
+ }
62
+ /** Bounded capture counters for adapter `getDiagnostics()` surfaces. */
63
+ interface AdapterCaptureDiagnostics {
64
+ readonly capture: AdapterCaptureMode;
65
+ readonly redactionProfile: RedactionProfile;
66
+ readonly maxPreviewChars: number;
67
+ readonly previewFieldsCaptured: number;
68
+ readonly previewFieldsUnavailable: number;
69
+ readonly previewFieldsTruncated: number;
70
+ readonly previewFieldsRedacted: number;
71
+ readonly lastDiagnosticCode?: AdapterCaptureDiagnosticCode;
72
+ readonly lastDiagnosticMessage?: string;
73
+ }
74
+ /** Shared preview capture handle owned by one adapter instance. */
75
+ interface AdapterPreviewCapture {
76
+ /** Effective capture mode (adapters no longer downgrade `preview`). */
77
+ readonly capture: AdapterCaptureMode;
78
+ readonly previewEnabled: boolean;
79
+ readonly maxPreviewChars: number;
80
+ readonly redactionProfile: RedactionProfile;
81
+ /** Normalizes a logical field to a persisted `*Preview` attribute name. */
82
+ previewFieldName(field: string): string;
83
+ /**
84
+ * Returns a bounded, redacted preview string, or `undefined` when capture is
85
+ * metadata-only or the field could not be sourced.
86
+ */
87
+ capturePreviewField(field: string, value: unknown): string | undefined;
88
+ /** Writes every available preview onto `target` and returns it. */
89
+ applyPreviewFields(target: Record<string, unknown>, fields: Record<string, unknown>): Record<string, unknown>;
90
+ getDiagnostics(): AdapterCaptureDiagnostics;
91
+ }
92
+ /**
93
+ * JSON-ish serialization that tolerates cycles, bigints, and throwing getters,
94
+ * bounded to `maxChars`. Returns `undefined` for a non-positive bound or a
95
+ * value JSON cannot represent.
96
+ */
97
+ declare function serializeAdapterPreview(value: unknown, maxChars: number): string | undefined;
98
+ /**
99
+ * Resolves the effective preview bound. Profile caps apply so a `share` or
100
+ * `strict` profile cannot be widened by a larger adapter option.
101
+ */
102
+ declare function resolveAdapterMaxPreviewChars(value: unknown, profile?: RedactionProfile): number;
103
+ /** Creates the shared preview capture handle for one adapter instance. */
104
+ declare function createAdapterPreviewCapture(options?: AdapterPreviewCaptureOptions): AdapterPreviewCapture;
105
+
27
106
  /** Two spaces per nesting level in terminal output. */
28
107
  declare const TERMINAL_INDENT = " ";
29
108
  /** Max display length for names in terminal output. */
@@ -1443,4 +1522,4 @@ declare function renderGateGithubStepSummary(result: GateResult): string;
1443
1522
  declare function renderGateJUnit(result: GateResult): string;
1444
1523
  declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
1445
1524
 
1446
- export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CausalContractFindingInput, type CausalFailureKind, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, type EnrichSessionSummaryOptions, ErrorInfo, type EvidenceCheckFindingSummary, type EvidenceCiPackageFiles, type EvidenceCiPackageInput, type EvidenceContractsViewInput, type EvidenceFileEntry, type EvidenceFileRole, type EvidenceFormatVersion, type EvidenceHtmlShellInput, type EvidenceManifest, type EvidencePackagedFile, type EvidenceProvenanceViewInput, type EvidenceRedactionProfile, type EvidenceSafeStatus, type EvidenceSafetyViewInput, type EvidenceSourceHash, type EvidenceVerificationPolicy, type EvidenceVerifyIssue, type EvidenceVerifyOptions, type EvidenceVerifyResult, type EvidenceVerifyStatus, type EvidenceViewId, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type FindFirstCausalFailureOptions, type FirstCausalFailure, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, ObservedOutcome, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, type SuiteTemplateId, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, type ZipEntry, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, findFirstCausalFailure, formatDuration, formatError, formatStepLabel, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getSuiteTemplate, getTraceFilePath, groupSessionCohorts, inferEvidenceFileRole, initializeTraceFile, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeEvent, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory, warn, writeTraceEvent };
1525
+ export { ADAPTER_CAPTURE_DIAGNOSTIC_CODES, type ActivityEntry, type ActivitySummary, type AdapterCaptureDiagnostic, type AdapterCaptureDiagnosticCode, type AdapterCaptureDiagnostics, type AdapterCaptureMode, type AdapterDiagnosticListener, type AdapterPreviewCapture, type AdapterPreviewCaptureOptions, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CausalContractFindingInput, type CausalFailureKind, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_ADAPTER_MAX_PREVIEW_CHARS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, type EnrichSessionSummaryOptions, ErrorInfo, type EvidenceCheckFindingSummary, type EvidenceCiPackageFiles, type EvidenceCiPackageInput, type EvidenceContractsViewInput, type EvidenceFileEntry, type EvidenceFileRole, type EvidenceFormatVersion, type EvidenceHtmlShellInput, type EvidenceManifest, type EvidencePackagedFile, type EvidenceProvenanceViewInput, type EvidenceRedactionProfile, type EvidenceSafeStatus, type EvidenceSafetyViewInput, type EvidenceSourceHash, type EvidenceVerificationPolicy, type EvidenceVerifyIssue, type EvidenceVerifyOptions, type EvidenceVerifyResult, type EvidenceVerifyStatus, type EvidenceViewId, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type FindFirstCausalFailureOptions, type FirstCausalFailure, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, ObservedOutcome, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, type SuiteTemplateId, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, type ZipEntry, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, createAdapterPreviewCapture, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, findFirstCausalFailure, formatDuration, formatError, formatStepLabel, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getSuiteTemplate, getTraceFilePath, groupSessionCohorts, inferEvidenceFileRole, initializeTraceFile, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveAdapterMaxPreviewChars, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeAdapterPreview, serializeEvent, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory, warn, writeTraceEvent };
@@ -26,6 +26,181 @@ import { createHash } from 'crypto';
26
26
  import { stat, readFile, access, readdir } from 'fs/promises';
27
27
  import { pathToFileURL } from 'url';
28
28
 
29
+ // packages/core/src/adapters/preview-capture.ts
30
+ var DEFAULT_ADAPTER_MAX_PREVIEW_CHARS = 200;
31
+ var ADAPTER_CAPTURE_DIAGNOSTIC_CODES = [
32
+ "AI_CAPTURE_FIELD_UNAVAILABLE",
33
+ "AI_CAPTURE_PREVIEW_TRUNCATED",
34
+ "AI_CAPTURE_PREVIEW_REDACTED"
35
+ ];
36
+ function serializeAdapterPreview(value, maxChars) {
37
+ if (!Number.isFinite(maxChars) || maxChars <= 0) return void 0;
38
+ const serialized = serializePreviewValue(value);
39
+ if (serialized === void 0) return void 0;
40
+ return boundPreviewString(serialized, Math.floor(maxChars)).text;
41
+ }
42
+ function resolveAdapterMaxPreviewChars(value, profile = "local") {
43
+ const requested = typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : DEFAULT_ADAPTER_MAX_PREVIEW_CHARS;
44
+ const cap = resolveRedactionProfile(profile).maxPreviewLengthCap;
45
+ return cap === void 0 ? requested : Math.min(requested, cap);
46
+ }
47
+ function createAdapterPreviewCapture(options = {}) {
48
+ const capture = options.capture === "preview" ? "preview" : "metadata-only";
49
+ const redactionProfile = options.redactionProfile ?? "local";
50
+ const maxPreviewChars = resolveAdapterMaxPreviewChars(
51
+ options.maxPreviewChars,
52
+ redactionProfile
53
+ );
54
+ const redactor = new Redactor({
55
+ rules: options.redact,
56
+ extraKeys: resolveRedactionProfile(redactionProfile).extraKeys
57
+ });
58
+ const counters = {
59
+ previewFieldsCaptured: 0,
60
+ previewFieldsUnavailable: 0,
61
+ previewFieldsTruncated: 0,
62
+ previewFieldsRedacted: 0
63
+ };
64
+ let lastDiagnosticCode;
65
+ let lastDiagnosticMessage;
66
+ const emit = (code, field, message) => {
67
+ lastDiagnosticCode = code;
68
+ lastDiagnosticMessage = `${code}: ${message}`;
69
+ try {
70
+ options.onDiagnostic?.({ code, message, field, capture });
71
+ } catch {
72
+ }
73
+ };
74
+ const previewFieldName = (field) => /preview$/i.test(field) ? field : `${field}Preview`;
75
+ const capturePreviewField = (field, value) => {
76
+ if (capture !== "preview" || maxPreviewChars <= 0) return void 0;
77
+ const name = previewFieldName(field);
78
+ try {
79
+ if (value === void 0) {
80
+ counters.previewFieldsUnavailable += 1;
81
+ emit(
82
+ "AI_CAPTURE_FIELD_UNAVAILABLE",
83
+ name,
84
+ `${name} was requested but this framework callback did not expose the field`
85
+ );
86
+ return void 0;
87
+ }
88
+ const plain = toPlainPreviewValue(value);
89
+ if (plain === UNSERIALIZABLE) {
90
+ counters.previewFieldsUnavailable += 1;
91
+ emit(
92
+ "AI_CAPTURE_FIELD_UNAVAILABLE",
93
+ name,
94
+ `${name} could not be serialized into a bounded preview`
95
+ );
96
+ return void 0;
97
+ }
98
+ const serialized = serializePreviewValue(redactor.redactValue(name, plain));
99
+ if (serialized === void 0) {
100
+ counters.previewFieldsUnavailable += 1;
101
+ emit(
102
+ "AI_CAPTURE_FIELD_UNAVAILABLE",
103
+ name,
104
+ `${name} could not be serialized into a bounded preview`
105
+ );
106
+ return void 0;
107
+ }
108
+ if (containsRedactionMarker(serialized)) {
109
+ counters.previewFieldsRedacted += 1;
110
+ emit(
111
+ "AI_CAPTURE_PREVIEW_REDACTED",
112
+ name,
113
+ `${name} matched the ${redactionProfile} redaction profile before persistence`
114
+ );
115
+ }
116
+ const bounded = boundPreviewString(serialized, maxPreviewChars);
117
+ if (bounded.truncated) {
118
+ counters.previewFieldsTruncated += 1;
119
+ emit(
120
+ "AI_CAPTURE_PREVIEW_TRUNCATED",
121
+ name,
122
+ `${name} was truncated to maxPreviewChars=${maxPreviewChars}`
123
+ );
124
+ }
125
+ counters.previewFieldsCaptured += 1;
126
+ return bounded.text;
127
+ } catch {
128
+ counters.previewFieldsUnavailable += 1;
129
+ emit(
130
+ "AI_CAPTURE_FIELD_UNAVAILABLE",
131
+ name,
132
+ `${name} could not be read from this framework callback`
133
+ );
134
+ return void 0;
135
+ }
136
+ };
137
+ return {
138
+ capture,
139
+ previewEnabled: capture === "preview",
140
+ maxPreviewChars,
141
+ redactionProfile,
142
+ previewFieldName,
143
+ capturePreviewField,
144
+ applyPreviewFields(target, fields) {
145
+ if (capture !== "preview") return target;
146
+ for (const [field, value] of Object.entries(fields)) {
147
+ const preview = capturePreviewField(field, value);
148
+ if (preview !== void 0) target[previewFieldName(field)] = preview;
149
+ }
150
+ return target;
151
+ },
152
+ getDiagnostics() {
153
+ return {
154
+ capture,
155
+ redactionProfile,
156
+ maxPreviewChars,
157
+ ...counters,
158
+ ...lastDiagnosticCode === void 0 ? {} : { lastDiagnosticCode },
159
+ ...lastDiagnosticMessage === void 0 ? {} : { lastDiagnosticMessage }
160
+ };
161
+ }
162
+ };
163
+ }
164
+ var UNSERIALIZABLE = /* @__PURE__ */ Symbol("agent-inspect.preview.unserializable");
165
+ function toPlainPreviewValue(value) {
166
+ const json = serializePreviewValue(value);
167
+ if (json === void 0) return UNSERIALIZABLE;
168
+ try {
169
+ return JSON.parse(json);
170
+ } catch {
171
+ return json;
172
+ }
173
+ }
174
+ function containsRedactionMarker(serialized) {
175
+ return serialized.includes("[REDACTED]") || serialized.includes("[HASH:");
176
+ }
177
+ function serializePreviewValue(value) {
178
+ try {
179
+ const seen = /* @__PURE__ */ new WeakSet();
180
+ return JSON.stringify(value, (_key, entry) => {
181
+ if (typeof entry === "bigint") return entry.toString();
182
+ if (typeof entry === "function" || typeof entry === "symbol") {
183
+ return void 0;
184
+ }
185
+ if (typeof entry === "object" && entry !== null) {
186
+ if (seen.has(entry)) return "[Circular]";
187
+ seen.add(entry);
188
+ }
189
+ return entry;
190
+ });
191
+ } catch {
192
+ try {
193
+ return String(value);
194
+ } catch {
195
+ return void 0;
196
+ }
197
+ }
198
+ }
199
+ function boundPreviewString(value, maxChars) {
200
+ if (value.length <= maxChars) return { text: value, truncated: false };
201
+ return { text: `${value.slice(0, maxChars)}\u2026`, truncated: true };
202
+ }
203
+
29
204
  // packages/core/src/causal-failure.ts
30
205
  function runIdFromEvents(events) {
31
206
  for (const event of events) {
@@ -4413,6 +4588,6 @@ function renderGateReport(result, options = {}) {
4413
4588
  return renderGateSummaryMarkdown(result);
4414
4589
  }
4415
4590
 
4416
- export { COHORT_METRIC_IDS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildSessionIndex, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, findFirstCausalFailure, gateHasThresholds, getSuiteTemplate, groupSessionCohorts, inferEvidenceFileRole, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderSuiteReport, renderSuiteReportMarkdown, resolveBundleRunIds, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory };
4591
+ export { ADAPTER_CAPTURE_DIAGNOSTIC_CODES, COHORT_METRIC_IDS, DEFAULT_ADAPTER_MAX_PREVIEW_CHARS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, EVIDENCE_ASSESSMENT_NOTE, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, EVIDENCE_VIEW_CSS, EVIDENCE_VIEW_IDS, SESSION_WORKFLOW_KEYS, SUITE_TEMPLATE_IDS, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceFileEntries, buildEvidenceHtmlShell, buildEvidenceHtmlShellFromManifest, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildSessionIndex, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compareCohortAggregates, createAdapterPreviewCapture, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, encodeEmbeddedEvidenceJson, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, findFirstCausalFailure, gateHasThresholds, getSuiteTemplate, groupSessionCohorts, inferEvidenceFileRole, isAgentInspectTrace, isSha256Hex, listSuiteTemplates, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDurationFilter, parseEvidenceManifestJson, parseGateList, parseGateNumber, parseGroupBySpec, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderSuiteReport, renderSuiteReportMarkdown, resolveAdapterMaxPreviewChars, resolveBundleRunIds, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveSuiteTemplate, runGate, runSuite, sanitizeBundleRunId, searchTraces, serializeAdapterPreview, serializeEvidenceManifest, sessionKeyForRun, sha256Equals, sha256Hex, toMetadataSafeStatus, traceMetasToSessionRunRecords, validateEvidenceManifest, validateSuiteConfig, verifyEvidenceDirectory };
4417
4592
  //# sourceMappingURL=advanced.mjs.map
4418
4593
  //# sourceMappingURL=advanced.mjs.map