/**
 * Binary Downloader
 * Handles downloading files with retry logic, progress tracking, and redirect following.
 * Robust handling for transient network errors (socket hang up, ECONNRESET, etc.)
 * Respects http_proxy, https_proxy, and all_proxy environment variables.
 */
/// <reference types="node" />
/// <reference types="node" />
import * as https from 'https';
import * as http from 'http';
import { DownloadResult, ProgressCallback } from '../types';
import { getProxyUrl, shouldBypassProxy } from '../../utils/proxy-env';
/**
 * Extract hostname from URL.
 * @param url The URL to parse
 * @returns Hostname or empty string if invalid
 */
declare function getHostname(url: string): string;
/**
 * Create appropriate proxy agent based on URL protocol.
 * Respects NO_PROXY/no_proxy for bypassing specific hosts.
 * @param url Target URL to determine protocol
 * @returns Proxy agent or false (no agent/pooling disabled)
 */
declare function getProxyAgent(url: string): http.Agent | https.Agent | false;
/** Default configuration for downloader */
export interface DownloaderConfig {
    /** Maximum retry attempts */
    maxRetries: number;
    /** Enable verbose logging */
    verbose: boolean;
    /** Timeout in milliseconds (default: 120000 for large files) */
    timeout?: number;
}
/** Error types for categorized handling */
export type NetworkErrorType = 'socket' | 'timeout' | 'http' | 'redirect' | 'unknown';
/** Categorize error for appropriate retry/reporting */
export declare function categorizeError(error: Error): NetworkErrorType;
/** Get user-friendly error message */
export declare function getErrorMessage(error: Error, attempt: number, maxAttempts: number): string;
/** Check if error is retryable */
export declare function isRetryableError(error: Error): boolean;
/**
 * Download file from URL with progress tracking
 * @param timeout Timeout in ms (default 120000 for large files)
 * @param maxRedirects Maximum number of redirects to follow (default 10)
 */
export declare function downloadFile(url: string, destPath: string, onProgress?: ProgressCallback, verbose?: boolean, timeout?: number, maxRedirects?: number): Promise<void>;
/**
 * Download file with retry logic and exponential backoff
 * Uses smarter backoff for socket errors (longer delays)
 */
export declare function downloadWithRetry(url: string, destPath: string, config?: Partial<DownloaderConfig>): Promise<DownloadResult>;
/**
 * Fetch text content from URL with retry logic
 */
export declare function fetchText(url: string, verbose?: boolean, maxRetries?: number): Promise<string>;
/**
 * Fetch JSON from URL (for GitHub API) with retry logic
 */
export declare function fetchJson(url: string, verbose?: boolean, maxRetries?: number): Promise<Record<string, unknown>>;
export declare const __testExports: {
    getProxyUrl: typeof getProxyUrl;
    shouldBypassProxy: typeof shouldBypassProxy;
    getHostname: typeof getHostname;
    getProxyAgent: typeof getProxyAgent;
};
export {};
//# sourceMappingURL=downloader.d.ts.map