import { AgentMessageType, GraphStorageInterface, ThreadStateType } from '../../../Types/AgentGraph/AgentGraphTypes'; /** * In-memory implementation of GraphStorageInterface * Stores all data in RAM using Maps * Note: Data is lost when the process restarts */ export default class InMemoryStorageService implements GraphStorageInterface { /** * Agent private memory storage * Key: "threadId:agentId:key", Value: stored data */ private agentMemory; /** * Shared thread memory storage * Key: "threadId:key", Value: stored data */ private sharedMemory; /** * Global memory (accessible by all threads) * Key: memory key, Value: stored data */ private globalMemory; /** * Thread message history storage * Key: threadId, Value: array of messages */ private threads; /** * Thread state storage * Key: threadId, Value: thread state */ private states; /** * Get agent private memory by key * @param threadId - Thread identifier * @param agentId - Agent identifier * @param key - Memory key * @returns Promise resolving to stored value or null */ getAgentMemory(threadId: string, agentId: string, key: string): Promise; /** * Set agent private memory by key (replaces existing value) * @param threadId - Thread identifier * @param agentId - Agent identifier * @param key - Memory key * @param data - Data to store */ setAgentMemory(threadId: string, agentId: string, key: string, data: any): Promise; /** * Get shared thread memory by key * @param threadId - Thread identifier * @param key - Memory key * @returns Promise resolving to stored value or null */ getSharedMemory(threadId: string, key: string): Promise; /** * Set shared thread memory by key (replaces existing value) * @param threadId - Thread identifier * @param key - Memory key * @param data - Data to store */ setSharedMemory(threadId: string, key: string, data: any): Promise; /** * Get global memory by key (accessible by all threads) * @param key - Memory key * @returns Promise resolving to stored value or null */ getGlobalMemory(key: string): Promise; /** * Set global memory by key (replaces existing value) * @param key - Memory key * @param data - Data to store */ setGlobalMemory(key: string, data: any): Promise; /** * Get message history for a thread * @param threadId - Thread identifier * @returns Promise resolving to array of messages */ getHistory(threadId: string): Promise; /** * Add a message to thread history * @param threadId - Thread identifier * @param message - Message to add */ addMessage(threadId: string, message: AgentMessageType): Promise; /** * Get thread state * @param threadId - Thread identifier * @returns Promise resolving to thread state or null if not found */ getThreadState(threadId: string): Promise; /** * Set thread state * @param threadId - Thread identifier * @param state - State to set */ setThreadState(threadId: string, state: ThreadStateType): Promise; /** * Clear all data for a thread * @param threadId - Thread identifier */ clear(threadId: string): Promise; }