/** * Fast Context - Fast retrieval and summarization pipeline * Minimizes tokens and latency with deterministic caching */ export interface FastContextConfig { maxTokens?: number; cacheEnabled?: boolean; cacheTTL?: number; summarizer?: (text: string, maxTokens: number) => Promise; embeddingProvider?: { embed: (text: string) => Promise; }; } export interface ContextSource { id: string; type: 'memory' | 'knowledge' | 'file' | 'custom'; content: string; relevance?: number; metadata?: Record; } export interface FastContextResult { context: string; sources: ContextSource[]; tokenCount: number; cached: boolean; latencyMs: number; } /** * Represents a range of lines in a file. * * Python parity: praisonaiagents/context/fast/result.py:13-52 */ export interface LineRange { /** Starting line number (1-indexed) */ start: number; /** Ending line number (1-indexed, inclusive) */ end: number; /** Optional content of the lines */ content?: string; /** Score indicating relevance (0.0-1.0) */ relevanceScore: number; } /** * Create a LineRange with defaults. */ export declare function createLineRange(config: Partial & { start: number; end: number; }): LineRange; /** * Get the number of lines in a range. */ export declare function getLineCount(range: LineRange): number; /** * Check if two line ranges overlap. */ export declare function rangesOverlap(a: LineRange, b: LineRange): boolean; /** * Merge two overlapping line ranges. */ export declare function mergeRanges(a: LineRange, b: LineRange): LineRange; /** * Represents a file match from Fast Context search. * * Python parity: praisonaiagents/context/fast/result.py:55-92 */ export interface FileMatch { /** Absolute or relative path to the file */ path: string; /** List of relevant line ranges in the file */ lineRanges: LineRange[]; /** Overall relevance score (0.0-1.0) */ relevanceScore: number; /** Number of pattern matches found */ matchCount: number; } /** * Create a FileMatch with defaults. */ export declare function createFileMatch(config: Partial & { path: string; }): FileMatch; /** * Add a line range to a file match, merging with existing overlapping ranges. */ export declare function addLineRangeToFileMatch(fileMatch: FileMatch, lineRange: LineRange): void; /** * Get total number of lines across all ranges in a file match. */ export declare function getTotalLines(fileMatch: FileMatch): number; export interface CacheEntry { result: FastContextResult; timestamp: number; hits: number; } /** * Fast Context class for efficient context retrieval */ export declare class FastContext { private config; private cache; private sources; constructor(config?: FastContextConfig); /** * Register a context source */ registerSource(id: string, type: ContextSource['type'], contents: string[], metadata?: Record): void; /** * Register memory as a source */ registerMemory(memory: { getAll: () => Array<{ content: string; metadata?: any; }>; }): void; /** * Register knowledge base as a source */ registerKnowledge(knowledge: { search: (query: string, limit?: number) => Promise>; }): void; /** * Get context for a query */ getContext(query: string): Promise; /** * Gather relevant sources for a query */ private gatherRelevantSources; /** * Score relevance using embeddings */ private scoreRelevance; /** * Simple text-based relevance scoring */ private scoreRelevanceSimple; /** * Build context from sources within token limit */ private buildContext; /** * Get cache key for query */ private getCacheKey; /** * Get from cache */ private getFromCache; /** * Add to cache */ private addToCache; /** * Clear cache */ clearCache(): void; /** * Get cache stats */ getCacheStats(): { size: number; totalHits: number; }; /** * Estimate token count */ private estimateTokens; /** * Cosine similarity */ private cosineSimilarity; /** * Clear all sources */ clearSources(): void; } /** * Create a fast context instance */ export declare function createFastContext(config?: FastContextConfig): FastContext; /** * Quick context retrieval */ export declare function getQuickContext(query: string, sources: string[], maxTokens?: number): Promise;