/**
 * Provider-Agnostic Base Interface for MCP
 *
 * Abstract base classes and interfaces for LLM providers
 */
import { EventEmitter } from 'events';
import { MCPProvider, LLMRequest, LLMResponse, LLMResponseChunk, LLMCapabilities, ModelInfo, RateLimitInfo, ProviderConfig, ProviderStatus, MCPError, LLMRequestType, FunctionDefinition, FunctionCall, UsageInfo } from '../types';
/**
 * Provider request context
 */
export interface ProviderRequestContext {
    requestId: string;
    agentDID: string;
    sessionId: string;
    timestamp: Date;
    retryCount: number;
    timeout: number;
    metadata?: Record<string, any>;
}
/**
 * Provider response context
 */
export interface ProviderResponseContext {
    requestId: string;
    providerId: string;
    model: string;
    latency: number;
    cached: boolean;
    retryCount: number;
    metadata?: Record<string, any>;
}
/**
 * Abstract base provider class
 */
export declare abstract class BaseLLMProvider extends EventEmitter implements MCPProvider {
    readonly id: string;
    readonly name: string;
    readonly version: string;
    readonly description: string;
    capabilities: LLMCapabilities;
    models: ModelInfo[];
    rateLimits: RateLimitInfo;
    config: ProviderConfig;
    status: ProviderStatus;
    protected requestCount: number;
    protected errorCount: number;
    protected lastRequestTime: Date | null;
    protected lastErrorTime: Date | null;
    constructor(config: ProviderConfig);
    /**
     * Initialize the provider
     */
    abstract initialize(): Promise<void>;
    /**
     * Check provider health
     */
    abstract health(): Promise<{
        status: 'healthy' | 'unhealthy';
        latency?: number;
        details?: any;
    }>;
    /**
     * Send completion request
     */
    abstract completion(request: LLMRequest, context: ProviderRequestContext): Promise<LLMResponse>;
    /**
     * Send streaming completion request
     */
    abstract stream(request: LLMRequest, context: ProviderRequestContext): AsyncIterable<LLMResponseChunk>;
    /**
     * Generate embeddings
     */
    abstract embed(request: LLMRequest, context: ProviderRequestContext): Promise<LLMResponse>;
    /**
     * Moderate content
     */
    abstract moderate(request: LLMRequest, context: ProviderRequestContext): Promise<LLMResponse>;
    /**
     * Process request based on type
     */
    processRequest(request: LLMRequest, context: ProviderRequestContext): Promise<LLMResponse>;
    /**
     * Process streaming request
     */
    processStreamingRequest(request: LLMRequest, context: ProviderRequestContext): AsyncIterable<LLMResponseChunk>;
    /**
     * Validate request before processing
     */
    protected validateRequest(request: LLMRequest): void;
    /**
     * Create base response structure
     */
    protected createBaseResponse(request: LLMRequest, context: ProviderRequestContext): Partial<LLMResponse>;
    /**
     * Create error response
     */
    protected createErrorResponse(request: LLMRequest, context: ProviderRequestContext, error: Error | MCPError): LLMResponse;
    /**
     * Calculate usage information
     */
    protected calculateUsage(request: LLMRequest, response: string, model: string): UsageInfo;
    /**
     * Calculate cost based on token usage
     */
    protected calculateCost(promptTokens: number, completionTokens: number, model: string): number;
    /**
     * Handle errors
     */
    protected handleError(error: Error, request: LLMRequest, context: ProviderRequestContext): void;
    /**
     * Update request metrics
     */
    protected updateMetrics(): void;
    /**
     * Convert function definitions to provider-specific format
     */
    protected convertFunctions(functions: FunctionDefinition[]): any[];
    /**
     * Extract function calls from provider response
     */
    protected extractFunctionCalls(response: any): FunctionCall[];
    /**
     * Get provider statistics
     */
    getStats(): {
        requestCount: number;
        errorCount: number;
        errorRate: number;
        lastRequestTime: Date | null;
        lastErrorTime: Date | null;
        status: ProviderStatus;
    };
    /**
     * Reset statistics
     */
    resetStats(): void;
    /**
     * Get supported models
     */
    getSupportedModels(): ModelInfo[];
    /**
     * Check if model is supported
     */
    isModelSupported(modelId: string): boolean;
    /**
     * Get default model for request type
     */
    getDefaultModel(requestType: LLMRequestType): string;
    /**
     * Validate model availability
     */
    protected validateModel(modelId: string): void;
    /**
     * Shutdown provider
     */
    shutdown(): Promise<void>;
}
/**
 * Provider factory interface
 */
export interface ProviderFactory {
    createProvider(config: ProviderConfig): BaseLLMProvider;
    validateConfig(config: ProviderConfig): boolean;
    getProviderType(): string;
}
/**
 * Abstract provider factory
 */
export declare abstract class BaseProviderFactory implements ProviderFactory {
    abstract createProvider(config: ProviderConfig): BaseLLMProvider;
    abstract validateConfig(config: ProviderConfig): boolean;
    abstract getProviderType(): string;
    /**
     * Validate base configuration requirements
     */
    protected validateBaseConfig(config: ProviderConfig): boolean;
}
//# sourceMappingURL=base-provider.d.ts.map