/**
 * Error Handling Module (Module F)
 *
 * SPARC Architecture Reference: §2.7
 *
 * PURPOSE: Surface errors with context (no recovery)
 *
 * FORBIDDEN:
 * - Error Recovery (NO retry logic)
 * - Error Suppression (NO swallowing errors)
 * - Error Transformation (NO changing error semantics)
 * - Fallback Logic (NO alternative paths on error)
 */
import type { ErrorInfo, ErrorCategory, ContractViolation, ViolationType, ExitCode } from '../types/index.js';
export declare class CLIError extends Error {
    readonly code: string;
    readonly category: ErrorCategory;
    readonly details?: Record<string, unknown>;
    readonly timestamp: string;
    readonly module: string;
    readonly correlationId?: string;
    readonly recoverable: boolean;
    readonly exitCode: ExitCode;
    constructor(options: {
        code: string;
        category: ErrorCategory;
        message: string;
        details?: Record<string, unknown>;
        module: string;
        correlationId?: string;
        recoverable?: boolean;
        exitCode?: ExitCode;
        cause?: Error;
    });
    toErrorInfo(): ErrorInfo;
}
export declare class ValidationError extends CLIError {
    constructor(options: {
        message: string;
        field?: string;
        expected?: string;
        actual?: string;
        correlationId?: string;
    });
}
export declare class ReferenceValidationError extends CLIError {
    constructor(options: {
        refId: string;
        refType: string;
        repository: string;
        reason: string;
        correlationId?: string;
    });
}
export declare class ServiceError extends CLIError {
    constructor(options: {
        service: string;
        operation: string;
        type: 'unavailable' | 'timeout' | 'internal_error';
        statusCode?: number;
        upstreamMessage?: string;
        correlationId?: string;
    });
}
export declare class ContractViolationError extends CLIError {
    readonly violation: ContractViolation;
    constructor(options: {
        service: string;
        expectedContract: string;
        actualResponse: unknown;
        violationType: ViolationType;
        correlationId?: string;
    });
}
export declare class ConfigError extends CLIError {
    constructor(options: {
        message: string;
        configPath?: string;
        missingKey?: string;
        correlationId?: string;
    });
}
export declare class AuthError extends CLIError {
    constructor(options: {
        type: 'missing' | 'invalid' | 'expired' | 'insufficient' | 'denied' | 'network';
        message: string;
        correlationId?: string;
    });
}
export interface IErrorHandler {
    handle(error: Error, context: ErrorContext): ErrorInfo;
    format(info: ErrorInfo, options: FormatOptions): string;
}
export interface ErrorContext {
    command?: string;
    phase?: string;
    inputs?: unknown;
    correlationId?: string;
}
export interface FormatOptions {
    format: 'json' | 'text';
    pretty?: boolean;
    includeStack?: boolean;
}
export declare class ErrorHandler implements IErrorHandler {
    handle(error: Error, context: ErrorContext): ErrorInfo;
    format(info: ErrorInfo, options: FormatOptions): string;
}
/**
 * Convert any thrown value to a proper Error with a meaningful message.
 * Ensures we never produce [object Object] in error messages.
 */
export declare function toError(value: unknown): Error;
export declare function failFast(options: {
    command: string;
    phase: string;
    upstreamError: Error;
    inputs: unknown;
    partialRefs?: {
        id: string;
    }[];
    correlationId?: string;
}): never;
export declare const errorHandler: ErrorHandler;
//# sourceMappingURL=index.d.ts.map