/** * OpenRouter Client * * Client for OpenRouter API supporting both embeddings and chat completions. * Used for intelligent initialization and context understanding. */ /** * Message for chat completion */ export interface ChatMessage { role: 'system' | 'user' | 'assistant'; content: string; } /** * Configuration for OpenRouter client */ export interface OpenRouterConfig { apiKey: string; embeddingModel?: string; chatModel?: string; siteUrl?: string; siteName?: string; minRequestInterval?: number; requestTimeout?: number; } /** * OpenRouter-specific error types */ export declare class OpenRouterError extends Error { code?: string | undefined; constructor(message: string, code?: string | undefined); } export declare class OpenRouterRateLimitError extends OpenRouterError { retryAfter?: number | undefined; constructor(message: string, retryAfter?: number | undefined); } export declare class OpenRouterAuthError extends OpenRouterError { constructor(message: string); } export declare class OpenRouterTimeoutError extends OpenRouterError { constructor(message: string); } /** * OpenRouter client for embeddings and chat */ export declare class OpenRouterClient { private apiKey; private embeddingModel; private chatModel; private siteUrl; private siteName; private embeddingCache; /** * Retry configuration */ private maxRetries; private baseRetryDelay; /** * Rate limiting configuration */ private minRequestInterval; private lastRequestTime; /** * Timeout configuration */ private requestTimeout; /** * Sleep for specified milliseconds */ private sleep; /** * Create a timeout promise that rejects after specified milliseconds */ private createTimeoutPromise; /** * Wrap a fetch promise with timeout */ private fetchWithTimeout; /** * Apply rate limiting before API requests */ private applyRateLimit; constructor(config: OpenRouterConfig); /** * Generate embedding for a single text */ embed(text: string): Promise; /** * Generate embeddings for multiple texts (batch) */ embedBatch(texts: string[]): Promise; /** * Chat completion - for intelligent context understanding */ chat(messages: ChatMessage[], options?: { temperature?: number; maxTokens?: number; model?: string; }): Promise; /** * Analyze codebase content intelligently */ analyzeContent(content: string, analysisType: 'summarize' | 'extract_workflows' | 'extract_architecture' | 'suggest_context'): Promise; /** * Calculate cosine similarity between two embeddings */ static cosineSimilarity(a: number[], b: number[]): number; /** * Get embedding dimension */ getDimension(): number; /** * Clear embedding cache */ clearCache(): void; /** * Get cache size */ getCacheSize(): number; /** * Hash text for caching */ private hashText; } /** * Create OpenRouter client from environment * * Uses centralized model configuration from ../config/models.ts * Environment variables can override for testing purposes */ export declare function createOpenRouterClient(): OpenRouterClient; /** * Check if OpenRouter API key is available */ export declare function hasOpenRouterKey(): boolean; /** * Re-export model configuration for convenience */ export { K0NTEXT_MODELS, MODEL_CONFIG, getModelFor, getPrimaryChatModel, getEmbeddingModel, isValidModel } from '../config/models.js'; export type { ModelType, ModelCategory } from '../config/models.js'; //# sourceMappingURL=openrouter.d.ts.map