import { z } from 'zod'; /** * Memory Consolidation */ export interface ConsolidationMetrics { semanticSimilarity: number; contextualOverlap: number; temporalProximity: number; sourceReliability: number; confidenceScore: number; accessCount: number; lastAccessed: Date; createdAt: Date; importance: number; relevance: number; } /** * Consolidation result */ export interface ConsolidationResult { success: boolean; metrics: ConsolidationMetrics; preservedRelations: string[]; mergedIds: string[]; } /** * Base interface for all memory units */ export interface IMemoryUnit { id: string; content: any; metadata: Map; timestamp: Date; memoryType: MemoryType; accessCount?: number; lastAccessed?: Date; priority?: number; consolidationMetrics?: ConsolidationMetrics; associations?: Set; createdAt: Date; expiredAt?: Date; validAt?: Date; invalidAt?: Date; } /** * Memory Types */ export declare enum MemoryType { WORKING = "working", LONG_TERM = "long_term", DECLARATIVE = "declarative", SEMANTIC = "semantic", EPISODIC = "episodic", PROCEDURAL = "procedural", CONTEXTUAL = "contextual", SYSTEM = "system", GENERIC = "generic", EPHEMERAL = "ephemeral" } /** * Interface for all memory types */ export interface IMemory { /** * Store content with metadata */ store(content: Omit): Promise; /** * Retrieve a memory unit by ID */ retrieve(id: string): Promise; /** * Query memory units based on filter */ query(filter: MemoryFilter): Promise; /** * Delete a memory unit */ delete(id: string): Promise; /** * Clear all memory units */ clear(): Promise; /** * Subscribe to memory events */ onEvent(callback: (unit: T) => void): void; /** * Type guard to ensure retrieved memory unit is of correct type */ isMemoryUnitOfType(unit: any): unit is T; /** * Create a new memory unit with the given content and metadata * @param content The content to store, can be either a string or an object of type C * @param schema Optional schema for validating object content * @param metadata Optional metadata for the memory unit */ createMemoryUnit(content: C | string, schema?: z.ZodType, metadata?: Map): T; } /** * Filter type for memory queries */ export interface MemoryFilter { id?: string; ids?: string[]; types?: MemoryType[]; query?: string; embedding?: number[]; dateRange?: { start?: Date; end?: Date; }; metadataFilters?: Map[]; contentFilters?: Map[]; orderBy?: 'lastAccessed' | 'accessCount' | 'timestamp'; limit?: number; temporal?: { createdAfter?: Date; createdBefore?: Date; expiredAfter?: Date; expiredBefore?: Date; validAfter?: Date; validBefore?: Date; invalidAfter?: Date; invalidBefore?: Date; }; } /** * Base metadata interface that all memory types must implement */ export interface BaseMetadata { type: MemoryType; } /** * Interface for memory metadata */ export interface IMemoryMetadata { type: MemoryType; importanceScore?: number; emotionalSignificance?: number; consolidationStatus?: 'pending' | 'completed' | 'failed'; } /** * Interface for memory association operations */ export interface IMemoryAssociation { associate(sourceId: string, targetId: string): Promise; dissociate(sourceId: string, targetId: string): Promise; getAssociations(id: string): Promise; findRelatedMemories(id: string, maxResults?: number): Promise; }