/**
 * Base Provider
 *
 * Abstract base class and interface for AI providers.
 * Defines the contract that all LLM providers (Grok, Claude, OpenAI, etc.) must fulfill.
 */
import { EventEmitter } from 'events';
import type { ProviderType, ProviderConfig, CompletionOptions, LLMResponse, StreamChunk, ProviderFeature, LLMMessage } from './types.js';
/**
 * Interface representing a generic AI Provider.
 * This interface abstracts away the differences between various LLM APIs
 * (e.g., Anthropic, OpenAI, XAI) providing a unified way to interact with them.
 */
export interface AIProvider {
    /** The unique identifier for the provider type (e.g., 'grok', 'claude'). */
    readonly type: ProviderType;
    /** The display name of the provider. */
    readonly name: string;
    /** The default model ID used by this provider if none is specified. */
    readonly defaultModel: string;
    /**
     * Initializes the provider with the necessary configuration.
     * This typically involves setting API keys and validating basic settings.
     *
     * @param config - The configuration object containing API keys, model preferences, etc.
     * @returns A promise that resolves when initialization is complete.
     */
    initialize(config: ProviderConfig): Promise<void>;
    /**
     * Checks if the provider is fully initialized and ready to accept requests.
     *
     * @returns `true` if the provider is ready, `false` otherwise.
     */
    isReady(): boolean;
    /**
     * Sends a chat completion request to the provider (non-streaming).
     *
     * @param options - The options for the completion request (messages, tools, etc.).
     * @returns A promise resolving to the standardized LLM response.
     */
    chat(options: CompletionOptions): Promise<LLMResponse>;
    /**
     * Legacy alias for `chat`.
     * @deprecated Use `chat` instead.
     */
    complete(options: CompletionOptions): Promise<LLMResponse>;
    /**
     * Sends a chat completion request and returns a stream of chunks.
     * Useful for real-time UIs where the response is displayed as it generates.
     *
     * @param options - The options for the completion request.
     * @returns An async iterable of `StreamChunk` objects.
     */
    stream(options: CompletionOptions): AsyncIterable<StreamChunk>;
    /**
     * Retrieves the list of available models for this provider.
     *
     * @returns A promise resolving to an array of model ID strings.
     */
    getModels(): Promise<string[]>;
    /**
     * Checks if the provider supports a specific feature.
     *
     * @param feature - The feature to check (e.g., 'streaming', 'tools', 'vision').
     * @returns `true` if the feature is supported, `false` otherwise.
     */
    supports(feature: ProviderFeature): boolean;
    /**
     * Estimates the number of tokens in a text string or list of messages.
     * Used for context window management.
     *
     * @param content - The text or messages to estimate.
     * @returns The estimated number of tokens.
     */
    estimateTokens(content: string | LLMMessage[]): number;
    /**
     * Gets the pricing configuration for the current model.
     *
     * @returns An object containing input and output costs per 1k tokens (or similar unit).
     */
    getPricing(): {
        input: number;
        output: number;
    };
    /**
     * Cleans up resources, clears listeners, and resets the provider state.
     */
    dispose(): void;
}
/**
 * Abstract base class that implements common functionality for AI providers.
 * Concrete provider implementations should extend this class.
 */
export declare abstract class BaseProvider extends EventEmitter implements AIProvider {
    abstract readonly type: ProviderType;
    abstract readonly name: string;
    abstract readonly defaultModel: string;
    protected config: ProviderConfig | null;
    protected ready: boolean;
    /**
     * Initializes the provider.
     * Validates configuration and emits a 'ready' event upon success.
     */
    initialize(config: ProviderConfig): Promise<void>;
    isReady(): boolean;
    /**
     * Validates the provided configuration.
     * Throws an error if required fields (like apiKey) are missing.
     * Can be overridden by subclasses for specific validation logic.
     */
    protected validateConfig(): Promise<void>;
    /**
     * Standard chat completion method.
     * Delegates to the abstract `complete` method which must be implemented by subclasses.
     * Wrapped with latency measurement for performance tracking.
     */
    chat(options: CompletionOptions): Promise<LLMResponse>;
    /**
     * Abstract method to perform the actual completion request.
     * Must be implemented by concrete providers.
     */
    abstract complete(options: CompletionOptions): Promise<LLMResponse>;
    /**
     * Abstract method to perform streaming completion.
     * Must be implemented by concrete providers.
     */
    abstract stream(options: CompletionOptions): AsyncIterable<StreamChunk>;
    /**
     * Wraps a stream with latency tracking for first-token and total time.
     * Use this in provider implementations to get streaming metrics.
     */
    protected trackStreamLatency(streamIterable: AsyncIterable<StreamChunk>): AsyncIterable<StreamChunk>;
    getModels(): Promise<string[]>;
    supports(feature: ProviderFeature): boolean;
    estimateTokens(content: string | LLMMessage[]): number;
    abstract getPricing(): {
        input: number;
        output: number;
    };
    dispose(): void;
}
