UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

46 lines (45 loc) 2.26 kB
/** * Shared Summarization Engine * * Extracted from ConversationMemoryManager and RedisConversationMemoryManager * to eliminate code duplication. Both managers delegate to this engine. */ import type { ChatMessage, ConversationMemoryConfig, SessionMemory } from "../types/index.js"; /** * Centralized summarization engine for conversation memory. * Handles token counting, threshold checking, and summary generation. */ export declare class SummarizationEngine { /** * Check if a session needs summarization and perform it if so. * @param session - Session memory to check and potentially summarize * @param threshold - Token threshold that triggers summarization * @param config - Conversation memory configuration (partial allowed) * @param logPrefix - Prefix for log messages * @returns True if summarization was performed */ checkAndSummarize(session: SessionMemory, threshold: number, config: Partial<ConversationMemoryConfig>, logPrefix?: string, requestId?: string): Promise<boolean>; /** * Perform token-based summarization on a session. * Uses pointer-based, non-destructive approach. * @param session - Session memory to summarize * @param threshold - Token threshold for calculating split point * @param config - Conversation memory configuration (partial allowed) * @param logPrefix - Prefix for log messages */ summarizeSession(session: SessionMemory, threshold: number, config: Partial<ConversationMemoryConfig>, logPrefix?: string, requestId?: string): Promise<void>; /** * Estimate total tokens for a message array. * @param messages - Array of chat messages * @returns Estimated token count */ estimateTokens(messages: ChatMessage[]): number; /** * Find split index to keep recent messages within target token count. * Works backwards from the most recent message to find the split point. * @param messages - Array of messages to analyze * @param targetRecentTokens - Target token count for recent messages * @returns Index at which to split (messages before this index will be summarized) */ findSplitIndexByTokens(messages: ChatMessage[], targetRecentTokens: number): number; }