@codai/memorai-core
Version:
Simplified advanced memory engine - no tiers, just powerful semantic search with persistence
111 lines • 3.27 kB
TypeScript
/**
* Advanced Memory Engine - Single Unified Memory System
* No tiers, no complexity - just the most powerful memory engine
* Combines semantic search, persistent storage, and advanced AI capabilities
*/
import type { ContextRequest, ContextResponse, MemoryConfig, MemoryResult, MemoryType } from '../types/index.js';
export interface RememberOptions {
type?: MemoryType;
importance?: number;
emotional_weight?: number;
tags?: string[];
context?: Record<string, unknown>;
ttl?: Date;
}
export interface RecallOptions {
type?: MemoryType;
limit?: number;
threshold?: number;
include_context?: boolean;
time_decay?: boolean;
}
/**
* Advanced Memory Engine Configuration
*/
export interface AdvancedMemoryConfig extends Partial<MemoryConfig> {
dataPath?: string;
azureOpenAI?: {
endpoint?: string;
apiKey?: string;
deploymentName?: string;
apiVersion?: string;
};
apiKey?: string;
model?: string;
localEmbedding?: {
model?: string;
pythonPath?: string;
cachePath?: string;
};
}
/**
* The most advanced memory engine - no tiers, no complexity
* Combines the best of all features into a single powerful system
*/
export declare class AdvancedMemoryEngine {
private config;
private embedding;
private storage;
private isInitialized;
private semanticIndex;
private keywordIndex;
private typeIndex;
private tagIndex;
constructor(config?: AdvancedMemoryConfig);
/**
* Initialize the memory engine and load existing memories
*/
initialize(): Promise<void>;
/**
* Remember new information with semantic indexing and persistence
*/
remember(content: string, tenantId: string, agentId?: string, options?: RememberOptions): Promise<string>;
/**
* Recall memories using semantic search + keyword matching
*/
recall(query: string, tenantId: string, agentId?: string, options?: RecallOptions): Promise<MemoryResult[]>;
/**
* Get contextual summary for an agent
*/
getContext(request: ContextRequest): Promise<ContextResponse>;
/**
* Forget a memory by ID
*/
forget(memoryId: string): Promise<boolean>;
/**
* Get comprehensive statistics
*/
getStats(): Promise<{
totalMemories: number;
memoryTypes: Record<MemoryType, number>;
indexStats: {
semantic: number;
keywords: number;
types: number;
tags: number;
};
performance: {
avgImportance: number;
recentActivity: number;
};
}>;
private indexMemory;
private removeFromIndices;
private semanticSearch;
private keywordSearch;
private mergeSearchResults;
private extractKeywords;
private isStopWord;
private calculateKeywordScore;
private getKeywordRelevanceReason;
private cosineSimilarity;
private classifyMemoryType;
private calculateImportance;
private generateContextSummary;
private getDefaultDataPath;
private detectEmbeddingProvider;
private getEmbeddingApiKey;
private getAzureConfig;
private handleError;
}
//# sourceMappingURL=AdvancedMemoryEngine.d.ts.map