/**
 * Self-healing and retry logic for the Agent dimension.
 *
 * Provides configurable retry policies with exponential backoff + jitter,
 * and recovery mechanisms for crashed agents. Error classification
 * determines whether a retry is appropriate.
 *
 * @module agents/retry
 */
/** Configuration for retry behavior. */
export interface RetryPolicy {
    /** Maximum number of retry attempts. Default: 3. */
    maxRetries: number;
    /** Base delay in milliseconds before first retry. Default: 1000. */
    baseDelayMs: number;
    /** Maximum delay in milliseconds between retries. Default: 30000. */
    maxDelayMs: number;
    /** Multiplier for exponential backoff. Default: 2. */
    backoffMultiplier: number;
    /** Whether to add random jitter to delays. Default: true. */
    jitter: boolean;
    /** Whether to retry on 'unknown' error classification. Default: true. */
    retryOnUnknown: boolean;
}
/** Default retry policy matching the BRAIN specification. */
export declare const DEFAULT_RETRY_POLICY: Readonly<RetryPolicy>;
/**
 * Create a retry policy by merging overrides with the default policy.
 */
export declare function createRetryPolicy(overrides?: Partial<RetryPolicy>): RetryPolicy;
/**
 * Calculate the delay for a given retry attempt using exponential backoff.
 *
 * Formula: min(baseDelay * multiplier^attempt, maxDelay) + jitter
 * Jitter adds 0-25% randomness to prevent thundering herd.
 */
export declare function calculateDelay(attempt: number, policy: RetryPolicy): number;
/**
 * Determine whether an error should be retried based on its classification
 * and the retry policy.
 */
export declare function shouldRetry(error: unknown, attempt: number, policy: RetryPolicy): boolean;
/** Result of a retried operation. */
export interface RetryResult<T> {
    success: boolean;
    value?: T;
    error?: Error;
    attempts: number;
    totalDelayMs: number;
}
/**
 * Wrap an async function with retry logic using configurable exponential backoff.
 *
 * The function will be retried according to the policy when retriable errors
 * occur. Permanent errors cause immediate failure. Unknown errors respect
 * the `retryOnUnknown` policy setting.
 *
 * @param fn - The async function to execute with retries
 * @param policy - Retry policy (uses DEFAULT_RETRY_POLICY if not provided)
 * @returns The result of the operation with retry metadata
 */
export declare function withRetry<T>(fn: () => Promise<T>, policy?: Partial<RetryPolicy>): Promise<RetryResult<T>>;
/** Result of a recovery attempt for a single agent. */
export interface AgentRecoveryResult {
    agentId: string;
    recovered: boolean;
    action: 'restarted' | 'abandoned' | 'skipped';
    reason: string;
}
/**
 * Attempt to recover crashed agents.
 *
 * Finds all agents with status 'crashed' and determines if they can be
 * restarted based on their error history. Agents whose last error was
 * classified as 'permanent' are abandoned. Agents with retriable errors
 * are reset to 'starting' for the orchestration layer to re-assign.
 *
 * @param thresholdMs - Heartbeat threshold for crash detection (default: 30000)
 * @param cwd - Working directory
 * @returns Recovery results for each crashed agent
 */
export declare function recoverCrashedAgents(thresholdMs?: number, cwd?: string): Promise<AgentRecoveryResult[]>;
//# sourceMappingURL=retry.d.ts.map