UNPKG

route-claudecode

Version:

Advanced routing and transformation system for Claude Code outputs to multiple AI providers

162 lines 4.96 kB
/** * Intelligent Routing Engine * Routes requests to appropriate providers based on model, content, and configuration */ import { BaseRequest, RoutingCategory, CategoryRouting, ProviderHealth } from '@/types'; export declare class RoutingEngine { private routingConfig; private providerHealth; private simpleProviderManager; private temporarilyDisabledProviders; constructor(routingConfig: Record<RoutingCategory, CategoryRouting>); /** * Route a request to the appropriate provider */ route(request: BaseRequest, requestId: string): Promise<string>; /** * Select provider with multi-provider and backup support */ private selectProviderWithBackup; /** * Select from multi-provider configuration with weighted selection and intelligent blacklisting */ private selectFromMultiProvider; /** * Select from legacy single provider + backup configuration using weighted selection */ private selectFromLegacyBackup; /** * Get provider success rate for health-based selection */ private getProviderSuccessRate; /** * Check if provider is healthy using simple provider manager * Now supports model-specific blacklisting */ private isProviderHealthy; /** * Initialize provider health tracking */ private initializeProviderHealth; /** * Record provider request result for health tracking and statistics with intelligent failover */ recordProviderResult(providerId: string, success: boolean, error?: string, httpCode?: number, model?: string, responseTimeMs?: number, isStreaming?: boolean): void; /** * 🧠 Intelligent failure categorization */ private categorizeFailure; /** * 🚨 Apply intelligent failover logic based on failure type */ private applyIntelligentFailover; /** * Mark provider as healthy or unhealthy (legacy method) */ setProviderHealth(providerId: string, healthy: boolean): void; /** * Get provider health status */ getProviderHealth(providerId: string): ProviderHealth | undefined; /** * Get all provider health statuses */ getAllProviderHealth(): Record<string, ProviderHealth>; /** * Apply failover filtering based on error conditions */ private applyFailoverFiltering; /** * Check if failover should be triggered for a provider */ private shouldTriggerFailover; /** * Get recent errors within specified time window (seconds) */ private getRecentErrors; /** * Check if provider should be failed over based on error conditions */ shouldFailoverProvider(providerId: string, errorType: string, httpCode?: number): boolean; /** * Determine the routing category based on request characteristics */ private determineCategory; /** * Apply model mapping based on routing configuration */ private applyModelMapping; /** * Calculate approximate token count for routing decisions */ private calculateRequestTokens; /** * Update routing configuration */ updateConfig(routingConfig: Record<RoutingCategory, CategoryRouting>): void; /** * Get current routing configuration summary */ getConfigSummary(): { categories: string[]; routing: Record<string, any>; }; /** * Get routing engine statistics (for compatibility) */ getStats(): { categories: string[]; routing: Record<RoutingCategory, CategoryRouting>; providerHealth: Record<string, ProviderHealth>; roundRobinState: Record<string, number>; }; /** * Get current round robin state from simple provider manager */ private getRoundRobinState; /** * Reset provider health (for testing or recovery) */ resetProviderHealth(providerId?: string): void; /** * 获取响应统计数据 */ getResponseStats(): any; /** * 获取统计汇总 */ getStatsSummary(): any; /** * 强制输出统计日志 */ logCurrentStats(): void; /** * 重置统计数据 */ resetStats(): void; /** * 临时禁用provider(非持久化) */ temporarilyDisableProvider(providerId: string): boolean; /** * 临时启用provider(非持久化) */ temporarilyEnableProvider(providerId: string): boolean; /** * 检查provider是否被临时禁用 */ isProviderTemporarilyDisabled(providerId: string): boolean; /** * 获取所有临时禁用的providers */ getTemporarilyDisabledProviders(): string[]; /** * 清除所有临时禁用状态(重启时自动调用) */ clearTemporaryDisables(): void; /** * Get blacklist status from simple provider manager */ getBlacklistStatus(): any; } //# sourceMappingURL=engine.d.ts.map