import { TelemetryIntegration } from 'ai'; import { TraceWriterStats, TraceWriter } from 'agent-inspect/writers'; /** Named redaction presets for trace writing and share-safe exports (v1.3.0+). */ type RedactionProfile = "local" | "share" | "strict"; /** * Capture policy shared by the official adapters. * * `metadata-only` is the default everywhere and never persists framework * payload content. `preview` opts into bounded, redacted previews. */ type AdapterCaptureMode = "metadata-only" | "preview"; /** Stable diagnostic codes emitted by shared preview capture. */ declare const ADAPTER_CAPTURE_DIAGNOSTIC_CODES: readonly ["AI_CAPTURE_FIELD_UNAVAILABLE", "AI_CAPTURE_PREVIEW_TRUNCATED", "AI_CAPTURE_PREVIEW_REDACTED"]; type AdapterCaptureDiagnosticCode = (typeof ADAPTER_CAPTURE_DIAGNOSTIC_CODES)[number]; /** One bounded diagnostic. Never contains preview content or filesystem paths. */ interface AdapterCaptureDiagnostic { readonly code: AdapterCaptureDiagnosticCode; readonly message: string; /** Persisted attribute name the diagnostic refers to (e.g. `inputPreview`). */ readonly field: string; readonly capture: AdapterCaptureMode; } /** Optional consumer hook for adapter capture diagnostics. */ type AdapterDiagnosticListener = (diagnostic: AdapterCaptureDiagnostic) => void; /** Bounded capture counters for adapter `getDiagnostics()` surfaces. */ interface AdapterCaptureDiagnostics { readonly capture: AdapterCaptureMode; readonly redactionProfile: RedactionProfile; readonly maxPreviewChars: number; readonly previewFieldsCaptured: number; readonly previewFieldsUnavailable: number; readonly previewFieldsTruncated: number; readonly previewFieldsRedacted: number; readonly lastDiagnosticCode?: AdapterCaptureDiagnosticCode; readonly lastDiagnosticMessage?: string; } /** * Experimental capture mode for the AI SDK adapter. * * `metadata-only` is the default. `preview` persists bounded, redacted preview * attributes through the shared adapter capture helper. * * @experimental This package is part of the framework adapter train. */ type AgentInspectAiSdkCaptureMode = "metadata-only" | "preview"; /** * Options for the experimental AI SDK telemetry integration. * * @experimental Callers must keep AI SDK telemetry configured with * `recordInputs: false` and `recordOutputs: false`. */ interface AgentInspectAiSdkOptions { /** * Explicit local writer for runtime integration. */ writer?: TraceWriter; /** * Convenience local trace directory for writer-owned persistence. */ traceDir?: string; /** * Optional run name used by lifecycle mapping. */ runName?: string; /** * Capture policy. Defaults to metadata-only. * * @experimental `preview` persists bounded, redacted prompt/message/output * previews. It never persists full content. */ capture?: AgentInspectAiSdkCaptureMode; /** * Redaction profile applied to preview attributes before persistence. * `share` and `strict` also cap `maxPreviewChars`. * * @experimental Effective only when `capture: "preview"`. */ redactionProfile?: RedactionProfile; /** * Upper bound for each serialized preview attribute. Defaults to 200. * * @experimental Effective only when `capture: "preview"`. */ maxPreviewChars?: number; /** * Receives bounded capture diagnostics such as * `AI_CAPTURE_FIELD_UNAVAILABLE`. Listener failures are isolated. * * @experimental */ onDiagnostic?: AdapterDiagnosticListener; } interface AgentInspectAiSdkDiagnostics { writeFailures: number; lifecycleWarnings: number; flushFailures: number; closeFailures: number; lastError?: string; lastWarning?: string; /** Shared preview-capture counters (`@experimental`). */ capture: AdapterCaptureDiagnostics; } interface AgentInspectAiSdkIntegration extends TelemetryIntegration { getDiagnostics(): AgentInspectAiSdkDiagnostics; getWriterStats(): TraceWriterStats | undefined; flush(): Promise; close(): Promise; } /** * Create an AgentInspect telemetry integration for the Vercel AI SDK. * * @experimental The adapter maps generation, LLM step, and tool lifecycle * events. Capture is metadata-only by default; `capture: "preview"` adds * bounded, redacted preview attributes. Keep AI SDK telemetry configured with * `recordInputs: false` and `recordOutputs: false`. */ declare function agentInspect(options?: AgentInspectAiSdkOptions): AgentInspectAiSdkIntegration; export { type AgentInspectAiSdkCaptureMode, type AgentInspectAiSdkDiagnostics, type AgentInspectAiSdkIntegration, type AgentInspectAiSdkOptions, agentInspect };