/**
 * Custom error classes for Code Buddy
 */
/**
 * Base error class for all Code Buddy errors
 */
export declare class CodeBuddyError extends Error {
    code?: string | undefined;
    details?: unknown | undefined;
    constructor(message: string, code?: string | undefined, details?: unknown | undefined);
    toJSON(): {
        name: string;
        message: string;
        code: string | undefined;
        details: unknown;
    };
}
/**
 * Error thrown when API key is missing or invalid
 */
export declare class APIKeyError extends CodeBuddyError {
    constructor(message?: string);
}
/**
 * Error thrown when API request fails
 */
export declare class APIError extends CodeBuddyError {
    statusCode?: number | undefined;
    response?: unknown | undefined;
    constructor(message: string, statusCode?: number | undefined, response?: unknown | undefined);
}
/**
 * Error thrown when network request fails
 */
export declare class NetworkError extends CodeBuddyError {
    originalError?: Error | undefined;
    constructor(message: string, originalError?: Error | undefined);
}
/**
 * Error thrown when operation times out
 */
export declare class TimeoutError extends CodeBuddyError {
    timeoutMs: number;
    constructor(message: string, timeoutMs: number);
}
/**
 * Error thrown when file operation fails
 */
export declare class FileError extends CodeBuddyError {
    filePath: string;
    operation: 'read' | 'write' | 'delete' | 'create';
    constructor(message: string, filePath: string, operation: 'read' | 'write' | 'delete' | 'create');
}
/**
 * Error thrown when file is not found
 */
export declare class FileNotFoundError extends FileError {
    constructor(filePath: string);
}
/**
 * Error thrown when tool execution fails
 */
export declare class ToolExecutionError extends CodeBuddyError {
    toolName: string;
    toolArgs?: unknown | undefined;
    constructor(message: string, toolName: string, toolArgs?: unknown | undefined);
}
/**
 * Error thrown when bash command is invalid or dangerous
 */
export declare class InvalidCommandError extends CodeBuddyError {
    command: string;
    constructor(message: string, command: string);
}
/**
 * Error thrown when bash command execution fails
 */
export declare class CommandExecutionError extends CodeBuddyError {
    command: string;
    exitCode?: number | undefined;
    stderr?: string | undefined;
    constructor(message: string, command: string, exitCode?: number | undefined, stderr?: string | undefined);
}
/**
 * Error thrown when validation fails
 */
export declare class ValidationError extends CodeBuddyError {
    field?: string | undefined;
    value?: unknown | undefined;
    constructor(message: string, field?: string | undefined, value?: unknown | undefined);
}
/**
 * Error thrown when configuration is invalid
 */
export declare class ConfigurationError extends CodeBuddyError {
    configKey?: string | undefined;
    constructor(message: string, configKey?: string | undefined);
}
/**
 * Error thrown when MCP server communication fails
 */
export declare class MCPError extends CodeBuddyError {
    serverName?: string | undefined;
    operation?: string | undefined;
    constructor(message: string, serverName?: string | undefined, operation?: string | undefined);
}
/**
 * Error thrown when search operation fails
 */
export declare class SearchError extends CodeBuddyError {
    query?: string | undefined;
    searchType?: "ripgrep" | "web" | "symbol" | undefined;
    constructor(message: string, query?: string | undefined, searchType?: "ripgrep" | "web" | "symbol" | undefined);
}
/**
 * Error thrown when code parsing fails
 */
export declare class ParserError extends CodeBuddyError {
    filePath?: string | undefined;
    language?: string | undefined;
    constructor(message: string, filePath?: string | undefined, language?: string | undefined);
}
/**
 * Error thrown when path traversal is attempted
 */
export declare class PathTraversalError extends CodeBuddyError {
    attemptedPath: string;
    basePath?: string | undefined;
    constructor(message: string, attemptedPath: string, basePath?: string | undefined);
}
/**
 * Error thrown when JSON parsing fails
 */
export declare class JSONParseError extends CodeBuddyError {
    input?: string | undefined;
    constructor(message: string, input?: string | undefined);
}
/**
 * Options for user-friendly errors
 */
export interface UserFriendlyErrorOptions {
    /** Main error message */
    message: string;
    /** Suggested action to fix the error */
    suggestion?: string;
    /** Link to documentation */
    docs?: string;
    /** Additional context information */
    context?: Record<string, unknown>;
    /** Error code for categorization */
    code?: string;
    /** Original error that caused this */
    cause?: Error;
}
/**
 * User-friendly error with actionable suggestions
 *
 * Provides clear, actionable error messages with:
 * - Human-readable message explaining what went wrong
 * - Suggested command or action to fix the issue
 * - Link to relevant documentation
 * - Additional context for debugging
 *
 * @example
 * ```typescript
 * throw new UserFriendlyError({
 *   message: 'Model "llama3" not found',
 *   suggestion: 'Run: ollama pull llama3',
 *   docs: 'https://docs.codebuddy.dev/models',
 *   context: { availableModels: ['llama2', 'mistral'] }
 * });
 * ```
 */
export declare class UserFriendlyError extends CodeBuddyError {
    /** Suggested action to fix the error */
    readonly suggestion?: string;
    /** Link to documentation */
    readonly docs?: string;
    /** Original error that caused this */
    readonly cause?: Error;
    constructor(options: UserFriendlyErrorOptions);
    /**
     * Format the error for display to the user
     */
    format(): string;
    toJSON(): {
        suggestion: string | undefined;
        docs: string | undefined;
        cause: {
            message: string;
            name: string;
        } | undefined;
        name: string;
        message: string;
        code: string | undefined;
        details: unknown;
    };
}
/**
 * Error thrown when a model is not found
 */
export declare class ModelNotFoundError extends UserFriendlyError {
    constructor(options: {
        model: string;
        provider: 'ollama' | 'local-llama' | 'webllm' | string;
        availableModels?: string[];
        downloadCommand?: string;
    });
}
/**
 * Error thrown when tool argument parsing fails
 */
export declare class ToolArgumentParseError extends UserFriendlyError {
    constructor(options: {
        toolName: string;
        rawArguments: string;
        parseError: string;
        expectedSchema?: Record<string, unknown>;
    });
}
/**
 * Error thrown when a provider is not available
 */
export declare class ProviderNotAvailableError extends UserFriendlyError {
    constructor(options: {
        provider: string;
        reason?: string;
        installCommand?: string;
        startCommand?: string;
    });
}
/**
 * Error thrown when a loop exceeds maximum iterations
 */
export declare class LoopTimeoutError extends CodeBuddyError {
    maxIterations: number;
    context?: string | undefined;
    constructor(message: string, maxIterations: number, context?: string | undefined);
}
/**
 * Checks if an error is a CodeBuddyError or subclass
 */
export declare function isCodeBuddyError(error: unknown): error is CodeBuddyError;
/**
 * Safely extracts error message from any error type
 */
export declare function getErrorMessage(error: unknown): string;
/**
 * Wraps a promise with timeout
 */
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
/**
 * Retries a function with exponential backoff
 */
export declare function withRetry<T>(fn: () => Promise<T>, options?: {
    maxRetries?: number;
    initialDelay?: number;
    maxDelay?: number;
    shouldRetry?: (error: unknown) => boolean;
}): Promise<T>;
/**
 * Options for loop guard
 */
export interface LoopGuardOptions {
    /** Maximum number of iterations allowed (default: 10000) */
    maxIterations?: number;
    /** Context description for error messages */
    context?: string;
    /** Warning threshold - logs warning when reached (default: 80% of max) */
    warnAt?: number;
    /** Optional logger function for warnings */
    onWarn?: (message: string) => void;
}
/**
 * Loop guard to prevent infinite loops
 * Returns a function that should be called at each iteration.
 * Throws LoopTimeoutError when max iterations exceeded.
 *
 * @example
 * ```typescript
 * const guard = createLoopGuard({ maxIterations: 1000, context: 'parsing postfix' });
 * while (true) {
 *   guard(); // Throws if iterations exceed limit
 *   // ... loop body
 * }
 * ```
 */
export declare function createLoopGuard(options?: LoopGuardOptions): () => void;
