@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
76 lines (75 loc) • 3.29 kB
TypeScript
/**
* Conversation Memory Manager for NeuroLink
* Handles in-memory conversation storage, session management, and context injection
*/
import type { ChatMessage, ConversationMemoryConfig, ConversationMemoryStats, SessionMemory, StoreConversationTurnOptions, IConversationMemoryManager } from "../types/index.js";
export declare class ConversationMemoryManager implements IConversationMemoryManager {
private sessions;
config: ConversationMemoryConfig;
private isInitialized;
private summarizationEngine;
/**
* Track sessions currently being summarized to prevent race conditions
*/
private summarizationInProgress;
constructor(config: ConversationMemoryConfig);
/**
* Initialize the memory manager
*/
initialize(): Promise<void>;
/** Whether this memory manager can persist data (always true for in-memory within process) */
get canPersist(): boolean;
/** Whether Redis client is configured (always false for in-memory) */
get isRedisConfigured(): boolean;
/** Get health status for monitoring */
getHealthStatus(): {
initialized: boolean;
connected: boolean;
};
/**
* Store a conversation turn for a session
* TOKEN-BASED: Validates message size and triggers summarization based on tokens
*/
storeConversationTurn(options: StoreConversationTurnOptions): Promise<void>;
/**
* Validate and prepare a message before adding to session
* Truncates if message exceeds token limit
*/
private validateAndPrepareMessage;
/**
* Check if summarization is needed based on token count
*/
private checkAndSummarize;
/**
* Estimate total tokens for a list of messages
*/
private estimateTokens;
/**
* Build context messages for AI prompt injection (TOKEN-BASED)
* Returns messages from pointer onwards (or all if no pointer)
* Now consistently async to match Redis implementation
*/
buildContextMessages(sessionId: string, _userId?: string, _enableSummarization?: boolean, requestId?: string): Promise<ChatMessage[]>;
getSession(sessionId: string, _userId?: string): SessionMemory | undefined;
createSummarySystemMessage(content: string, summarizesFrom?: string, summarizesTo?: string): ChatMessage;
private ensureInitialized;
private createNewSession;
private enforceSessionLimit;
getStats(): Promise<ConversationMemoryStats>;
clearSession(sessionId: string): Promise<boolean>;
clearAllSessions(): Promise<void>;
/**
* Get the raw messages array for a session.
* Returns the full messages list without context filtering or summarization.
* Returns a deep copy to prevent external mutation of internal state.
*/
getSessionMessages(sessionId: string, _userId?: string): Promise<ChatMessage[]>;
/**
* Replace the entire messages array for a session.
* Creates the session if it does not exist.
* Resets summary pointers since old pointers may reference messages that no longer exist.
*/
setSessionMessages(sessionId: string, messages: ChatMessage[], userId?: string): Promise<void>;
/** Close/shutdown — no-op for in-memory manager (no external connections to release) */
close(): Promise<void>;
}