/** * Error taxonomy, classification, and redaction utilities for observability. * * Provides error severity mapping, span status handling, and payload redaction * to ensure safe and meaningful error logging in traces and logs. * * @module src/core/observability/errors */ import { Effect, LogLevel } from 'effect'; import type { Span } from '../tracing/tracer'; /** * Error classification categories for Fred errors. */ export declare enum ErrorClass { /** Transient errors that can be retried (network timeouts, rate limits) */ RETRYABLE = "retryable", /** User input errors (validation failures, invalid requests) */ USER = "user", /** Provider/model errors (API errors, quota exceeded) */ PROVIDER = "provider", /** Infrastructure errors (database connection, system failures) */ INFRASTRUCTURE = "infrastructure", /** Unknown/unclassified errors */ UNKNOWN = "unknown" } /** * Map error class to OpenTelemetry span status code. */ export declare function errorClassToSpanStatus(errorClass: ErrorClass): 'ok' | 'error'; /** * Map error class to Effect log level. */ export declare function errorClassToLogLevel(errorClass: ErrorClass): LogLevel.LogLevel; /** * Classify an error based on its properties. */ export declare function classifyError(error: Error): ErrorClass; /** * Redaction filter function type. * Returns redacted version of the payload or null to remove entirely. */ export type RedactionFilter = (payload: unknown, context: RedactionContext) => unknown | null; /** * Context for redaction decisions. */ export interface RedactionContext { /** Type of payload being redacted */ payloadType: 'request' | 'response' | 'error' | 'metadata'; /** Source of the payload (tool, provider, step) */ source: string; /** Current log level */ logLevel: LogLevel.LogLevel; /** Error class if applicable */ errorClass?: ErrorClass; } export interface SecretRedactionOptions { readonly headers?: readonly string[]; readonly paths?: readonly string[]; readonly replacement?: string; } /** * Returns a non-mutating copy with secret-shaped fields, configured dot paths, * arrays, Error values, and known token formats redacted. */ export declare function redactSecrets(payload: unknown, options?: SecretRedactionOptions): unknown; /** * Default redaction filter: removes request/response bodies unless debug level. */ export declare function defaultRedactionFilter(payload: unknown, context: RedactionContext): unknown | null; /** * Redact a payload using the provided filter. */ export declare function redact(payload: unknown, context: RedactionContext, filter?: RedactionFilter): unknown; /** * Attach error metadata to a span with classification. */ export declare function attachErrorToSpan(span: Span, error: Error, options?: { errorClass?: ErrorClass; includeStack?: boolean; metadata?: Record; }): void; /** * Log error with Effect logging and appropriate level. */ export declare function logError(error: Error, options?: { errorClass?: ErrorClass; includeStack?: boolean; metadata?: Record; }): Effect.Effect; /** * Combined error handling: attach to span and log. */ export declare function handleError(error: Error, span: Span, options?: { errorClass?: ErrorClass; includeStack?: boolean; metadata?: Record; }): Effect.Effect; //# sourceMappingURL=errors.d.ts.map