/**
 * SmartPerfetto Multi-Model Router
 *
 * 多模型路由组件，负责：
 * 1. 按任务类型选择最适合的模型
 * 2. 故障转移和自动切换
 * 3. 多模型投票 (ensemble)
 * 4. 成本和延迟跟踪
 */
import { EventEmitter } from 'events';
import { ModelStrength, TaskType, ModelProfile, ModelRouterConfig, ModelCallResult, EnsembleResult } from '../types';
/**
 * 模型路由器实现
 */
export declare class ModelRouter extends EventEmitter {
    private config;
    private models;
    private callStats;
    private llmClients;
    private static readonly CONTEXT_OVERFLOW_PATTERNS;
    private static readonly PROMPT_COMPACTION_RATIOS;
    private static readonly MIN_PROMPT_FOR_COMPACTION;
    private static readonly MIN_COMPACTED_PROMPT;
    /** Buffer for downstream transformations (ensureJsonOnlyInstruction + redaction overhead) */
    private static readonly TRANSFORMATION_OVERHEAD_CHARS;
    constructor(config?: Partial<ModelRouterConfig>);
    /**
     * 按任务类型选择模型
     */
    routeByTask(taskType: TaskType): ModelProfile;
    /**
     * 根据强项查找最佳模型
     */
    findByStrengths(requiredStrengths: ModelStrength[]): ModelProfile | undefined;
    /**
     * 获取指定模型
     */
    getModel(modelId: string): ModelProfile | undefined;
    /**
     * 获取所有已启用的模型
     */
    getEnabledModels(): ModelProfile[];
    /**
     * 带故障转移的模型调用
     */
    callWithFallback(prompt: string, taskType: TaskType, options?: CallOptions): Promise<ModelCallResult>;
    private isContextOverflowError;
    private buildPromptCompactionCandidates;
    private compactPromptMiddle;
    /**
     * 调用单个模型
     */
    callModel(model: ModelProfile, prompt: string, options?: CallOptions): Promise<ModelCallResult>;
    /**
     * 多模型投票
     */
    ensemble(prompt: string, modelIds?: string[], options?: CallOptions): Promise<EnsembleResult>;
    /**
     * 聚合多个响应
     */
    private aggregateResponses;
    /**
     * 计算响应一致性分数
     */
    private calculateAgreement;
    /**
     * 获取故障转移链
     */
    getFallbackChain(excludeModelId?: string): string[];
    /**
     * 设置故障转移链
     */
    setFallbackChain(chain: string[]): void;
    /**
     * 获取或创建 LLM 客户端
     */
    private getOrCreateClient;
    /**
     * 创建 LLM 客户端
     */
    private createClient;
    /**
     * 注册自定义 LLM 客户端
     */
    registerClient(modelId: string, client: LLMClientInterface): void;
    /**
     * 更新调用统计
     */
    private updateStats;
    /**
     * 记录失败
     */
    private recordFailure;
    /**
     * 获取模型使用统计
     */
    getStats(): Record<string, {
        calls: number;
        tokens: number;
        cost: number;
        failures: number;
    }>;
    /**
     * 获取总成本
     */
    getTotalCost(): number;
    /**
     * 重置统计
     */
    resetStats(): void;
    /**
     * 启用模型
     */
    enableModel(modelId: string): void;
    /**
     * 禁用模型
     */
    disableModel(modelId: string): void;
    /**
     * 添加自定义模型
     */
    addModel(model: ModelProfile): void;
    /**
     * 移除模型
     */
    removeModel(modelId: string): void;
    /**
     * 更新模型配置
     */
    updateModel(modelId: string, updates: Partial<ModelProfile>): void;
    /**
     * 列出所有模型
     */
    listModels(): ModelProfile[];
}
interface CallOptions {
    maxTokens?: number;
    temperature?: number;
    jsonMode?: boolean;
    onToken?: (token: string) => void;
    tools?: Array<Record<string, unknown>>;
    toolChoice?: string | Record<string, unknown>;
    tool_choice?: string | Record<string, unknown>;
    reasoning?: Record<string, unknown>;
    sessionId?: string;
    traceId?: string;
    taskType?: TaskType;
    promptId?: string;
    promptVersion?: string;
    contractVersion?: string;
}
interface LLMClientInterface {
    complete(prompt: string, options?: CallOptions): Promise<string>;
}
/**
 * 所有模型失败错误
 */
declare class AllModelsFailedError extends Error {
    triedModels: string[];
    constructor(message: string, triedModels: string[]);
}
export { AllModelsFailedError };
export default ModelRouter;
//# sourceMappingURL=modelRouter.d.ts.map