/**
 * GlmtProxy - Legacy embedded HTTP proxy retained for compatibility work.
 *
 * Architecture:
 * - Intercepts Claude CLI → Z.AI calls
 * - Transforms Anthropic format → OpenAI format
 * - Converts reasoning_content → thinking blocks
 * - Supports both streaming and buffered modes
 *
 * Current status:
 * - No longer started by the normal `ccs glmt` runtime path
 * - Kept for legacy/internal compatibility and transformer-adjacent tests
 * - Binds to 127.0.0.1:random_port (security + avoid conflicts)
 * - Terminates when parent process exits
 *
 * Debugging:
 * - Verbose: Pass --verbose to see request/response logs
 * - Debug: Set CCS_DEBUG=1 to write logs to ~/.ccs/logs/
 */
/// <reference types="node" />
import * as http from 'http';
interface GlmtProxyConfig {
    verbose?: boolean;
    debugLog?: boolean;
    timeout?: number;
}
export declare class GlmtProxy {
    private transformer;
    private upstreamUrl;
    private server;
    private port;
    private verbose;
    private timeout;
    private retryConfig;
    private httpsAgent;
    constructor(config?: GlmtProxyConfig);
    /**
     * Start HTTP server on random port
     */
    start(): Promise<number>;
    /**
     * Handle incoming HTTP request
     */
    handleRequest(req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
    /**
     * Handle buffered (non-streaming) request
     */
    private handleBufferedRequest;
    /**
     * Handle streaming request
     */
    private handleStreamingRequest;
    /**
     * Read request body
     */
    private readBody;
    /**
     * Sleep for specified milliseconds
     */
    private sleep;
    /**
     * Calculate retry delay with exponential backoff and jitter
     * Honors Retry-After header if provided
     */
    private calculateRetryDelay;
    /**
     * Check if error is retryable (429 rate limit)
     * Returns retryable status and optional Retry-After value
     */
    private isRetryableError;
    /**
     * Forward request with retry logic for rate limit errors
     */
    private forwardWithRetry;
    /**
     * Forward streaming request with retry logic for rate limit errors
     * Only retries if headers haven't been sent yet
     */
    private forwardAndStreamWithRetry;
    /**
     * Forward request to Z.AI upstream
     */
    private forwardToUpstream;
    /**
     * Forward request to Z.AI and stream response
     */
    private forwardAndStreamUpstream;
    /**
     * Stop proxy server
     */
    stop(): void;
    /**
     * Log message if verbose
     */
    private log;
    /**
     * Format Authorization header based on endpoint type
     * OpenAI-compatible endpoints (chat/completions) require "Bearer " prefix
     * Anthropic-compatible endpoints use token directly
     */
    private formatAuthHeader;
    /**
     * Parse upstream error and return user-friendly error info
     */
    private parseUpstreamError;
}
export default GlmtProxy;
//# sourceMappingURL=glmt-proxy.d.ts.map