import { M as Message } from '../streaming.d-Cj-pZLSI.js'; import '../common.d-iR60eBef.js'; /** * Type definitions for conversation summarization */ /** * Compression level for summaries */ declare enum CompressionLevel { /** Very brief summary - key points only */ BRIEF = "brief", /** Moderate summary - balanced detail */ MODERATE = "moderate", /** Detailed summary - comprehensive */ DETAILED = "detailed" } /** * Summarization strategy */ type SummaryStrategy = 'single-pass' | 'rolling' | 'hierarchical' | 'extractive' | 'hybrid'; /** * LLM provider for summarization */ type SummaryProvider = 'openai' | 'anthropic'; /** * Configuration for conversation summarization */ interface SummaryConfig { /** * Summarization strategy to use */ strategy: SummaryStrategy; /** * Compression level */ compressionLevel: CompressionLevel; /** * LLM provider for summarization */ provider: SummaryProvider; /** * Provider-specific configuration */ providerConfig: { apiKey: string; model: string; temperature?: number; maxTokens?: number; }; /** * Custom prompt template for summarization */ customPrompt?: string; /** * Chunk size for rolling and hierarchical strategies (number of messages) */ chunkSize?: number; /** * Maximum number of key points to extract */ maxKeyPoints?: number; /** * Whether to cache summaries */ enableCache?: boolean; /** * Cache TTL in seconds (0 = no expiration) */ cacheTTL?: number; /** * Whether to include metadata in summaries */ includeMetadata?: boolean; /** * Custom metadata to include in summary */ metadata?: Record; } /** * Summary of a conversation or conversation chunk */ interface Summary { /** * Unique identifier for this summary */ id: string; /** * Conversation ID this summary belongs to */ conversationId: string; /** * The summarized content */ content: string; /** * Key points extracted from the conversation */ keyPoints?: string[]; /** * Strategy used to generate this summary */ strategy: SummaryStrategy; /** * Compression level used */ compressionLevel: CompressionLevel; /** * Number of messages summarized */ messageCount: number; /** * Range of messages summarized (indices) */ messageRange?: { start: number; end: number; }; /** * Timestamp when summary was created */ createdAt: number; /** * Timestamp when summary was last updated */ updatedAt?: number; /** * Token usage for generating this summary */ usage?: { promptTokens: number; completionTokens: number; totalTokens: number; }; /** * Parent summary ID (for hierarchical summaries) */ parentSummaryId?: string; /** * Child summary IDs (for hierarchical summaries) */ childSummaryIds?: string[]; /** * Custom metadata */ metadata?: Record; } /** * Result of a summarization operation */ interface SummarizationResult { /** * The primary summary */ summary: Summary; /** * Additional summaries (for hierarchical strategy) */ additionalSummaries?: Summary[]; /** * Whether the summary was retrieved from cache */ cached: boolean; /** * Total time taken to generate summary (ms) */ durationMs: number; } /** * Options for summarization */ interface SummarizeOptions { /** * Start index for messages to summarize */ startIndex?: number; /** * End index for messages to summarize */ endIndex?: number; /** * Whether to force regeneration (skip cache) */ forceRegenerate?: boolean; /** * Additional context to include in summarization */ context?: string; /** * Custom metadata for this summary */ metadata?: Record; } /** * Cache entry for summaries */ interface SummaryCacheEntry { /** * Cache key */ key: string; /** * Cached summary */ summary: Summary; /** * Timestamp when cached */ cachedAt: number; /** * TTL in seconds */ ttl: number; } /** * Statistics for summarization operations */ interface SummarizationStats { /** * Total number of summaries generated */ totalSummaries: number; /** * Number of cached summaries used */ cacheHits: number; /** * Number of summaries regenerated */ cacheMisses: number; /** * Total tokens used for summarization */ totalTokens: number; /** * Average time per summary (ms) */ averageDurationMs: number; /** * Total time spent on summarization (ms) */ totalDurationMs: number; } /** * Extractive summary sentence */ interface ExtractedSentence { /** * The extracted sentence */ text: string; /** * Score/importance of this sentence */ score: number; /** * Source message index */ messageIndex: number; /** * Role of the message author */ role: string; } /** * Options for incremental summarization */ interface IncrementalSummaryOptions { /** * Existing summary to build upon */ existingSummary: Summary; /** * New messages to incorporate */ newMessages: Message[]; /** * Whether to merge or append new content */ mode: 'merge' | 'append'; } /** * Conversation Summarizer * * Automatic summarization of long conversations using various strategies */ /** * Conversation Summarizer */ declare class ConversationSummarizer { private config; private provider; private cache; private stats; constructor(config: SummaryConfig); /** * Create LLM provider based on configuration */ private createProvider; /** * Summarize a conversation */ summarize(conversationId: string, messages: Message[], options?: SummarizeOptions): Promise; /** * Single-pass summarization - summarize entire conversation in one LLM call */ private singlePassSummarize; /** * Rolling summarization - summarize in chunks, then summarize summaries */ private rollingSummarize; /** * Hierarchical summarization - create multi-level summaries */ private hierarchicalSummarize; /** * Extractive summarization - extract key sentences without LLM */ private extractiveSummarize; /** * Hybrid summarization - combine extractive and abstractive approaches */ private hybridSummarize; /** * Incremental summarization - append new messages to existing summary */ summarizeIncremental(options: IncrementalSummaryOptions): Promise; /** * Build prompt from messages */ private buildPrompt; /** * Extract key points from summary text */ private extractKeyPointsFromSummary; /** * Get cached summary if available and not expired */ private getCachedSummary; /** * Cache a summary */ private cacheSummary; /** * Generate cache key */ private getCacheKey; /** * Clear cache */ clearCache(): void; /** * Get summarization statistics */ getStats(): SummarizationStats; /** * Reset statistics */ resetStats(): void; } /** * Extractive summarization utilities * * Extract key sentences from conversations without using LLMs */ /** * Extract key sentences from messages using TF-IDF */ declare function extractKeySentences(messages: Message[], maxSentences?: number): ExtractedSentence[]; /** * Extract key points from messages (distinct from sentences) */ declare function extractKeyPoints(messages: Message[], maxPoints?: number): string[]; /** * Create an extractive summary from messages */ declare function createExtractiveSummary(messages: Message[], maxSentences?: number): string; /** * Calculate conversation diversity (vocabulary richness) */ declare function calculateDiversity(messages: Message[]): number; /** * Identify important keywords in conversation */ declare function extractKeywords(messages: Message[], topN?: number): string[]; export { CompressionLevel, ConversationSummarizer, type ExtractedSentence, type IncrementalSummaryOptions, type SummarizationResult, type SummarizationStats, type SummarizeOptions, type Summary, type SummaryCacheEntry, type SummaryConfig, type SummaryProvider, type SummaryStrategy, calculateDiversity, createExtractiveSummary, extractKeyPoints, extractKeySentences, extractKeywords };