UNPKG

@ever_cheng/memory-task-mcp

Version:

Memory and task management MCP Server

132 lines (131 loc) 3.54 kB
import { Memory, AddMemoryArgs, SearchMemoryArgs, ListMemoriesArgs, DeleteMemoryArgs } from './types'; import { CacheService } from './cache'; import { EmbeddingService } from './embedding'; import { VectorStore } from './vector_store'; import { Disposable } from './resource_manager'; import { SystemConfig } from './config'; /** * Memory Manager Class * * Combines the functionality of MemoryService and MemoryStorage into a single class, * simplifies the architecture, reduces layers and dependencies. */ export declare class MemoryManager implements Disposable { private storagePath; private cache; private config; private chunkingService?; private embeddingService?; private vectorStore?; private semanticSearchEnabled; private resourceManager; /** * Constructor * @param storagePath Storage path * @param cacheService Unified cache service instance * @param config System configuration for multi-tenant support */ constructor(storagePath: string, cacheService: CacheService<string, Memory>, config: SystemConfig); /** * 啟用語義搜尋功能 */ enableSemanticSearch(): Promise<void>; /** * Initialize */ initialize(): Promise<void>; /** * Add memory * @param args Add memory parameters */ addMemory(args: AddMemoryArgs): Promise<Memory>; /** * Search memory * @param args Search parameters */ searchMemory(args: SearchMemoryArgs): Promise<Array<{ memory: Memory; similarity: number; }>>; /** * List memories * @param args List parameters */ listMemories(args?: ListMemoriesArgs): Promise<Memory[]>; /** * Get memory * @param id Memory ID */ getMemory(id: string): Promise<Memory | null>; /** * Update memory * @param id Memory ID * @param updates Update content */ updateMemory(id: string, updates: Partial<{ content: string; summary: string; tags: string[]; }>): Promise<Memory | null>; /** * Delete memory * @param args Delete parameters */ deleteMemory(args: DeleteMemoryArgs): Promise<boolean>; /** * Batch get memories * @param ids Array of IDs */ batchGetMemories(ids: string[]): Promise<Memory[]>; /** * Add progress note to memory * @param memoryId Memory ID * @param note Progress note to add */ addMemoryProgressNote(memoryId: string, note: string): Promise<void>; /** * Get cache statistics */ getCacheStats(): import("./types").CacheStats; /** * Save memory * @param id Memory ID * @param memory Memory object */ private save; /** * Load memory * @param id Memory ID */ private load; /** * Delete memory * @param id Memory ID */ private delete; /** * List all memories */ private list; /** * 處理記憶體進行語義搜尋 */ private processMemoryForSemanticSearch; /** * 獲取語義搜尋服務實例 */ getSemanticSearchServices(): { embeddingService?: EmbeddingService; vectorStore?: VectorStore; enabled: boolean; }; /** * 清理資源 (實現 Disposable 介面) */ dispose(): Promise<void>; /** * Calculate simple similarity * Simplified version of similarity calculation, not using complex TF-IDF algorithm */ private calculateSimpleSimilarity; }