/** * AgentMemory — Multi-layer memory system for agents. * * Three memory layers: * - **Episodic**: per-run short-term memory with time-based decay * - **Procedural**: persistent skill/chain patterns (e.g. SkillComposer recipes) * - **Shared long-term**: cross-agent knowledge base with relevance scoring * * @module AgentMemory */ /** A single memory entry */ export interface MemoryEntry { id: string; content: string; tags: string[]; createdAt: number; lastAccessed: number; accessCount: number; score: number; metadata: Record; } /** Episodic memory entry — decays over time */ export interface EpisodicEntry extends MemoryEntry { /** Decay half-life in milliseconds */ halfLifeMs: number; } /** Procedural memory entry — persistent skill/pattern */ export interface ProceduralEntry extends MemoryEntry { /** The pattern type (chain, batch, loop, etc.) */ patternType: string; /** Number of times this pattern succeeded */ successCount: number; /** Number of times this pattern failed */ failureCount: number; } /** Shared long-term entry — cross-agent knowledge */ export interface SharedEntry extends MemoryEntry { /** Agent that contributed this knowledge */ sourceAgent: string; /** Agents that have accessed this entry */ accessedBy: Set; } /** Query options for memory recall */ export interface RecallOptions { tags?: string[]; maxResults?: number; minScore?: number; /** Only entries newer than this timestamp */ since?: number; } /** * Short-term, per-run memory with exponential time decay. * Entries lose relevance over time; stale entries are pruned. */ export declare class EpisodicMemory { private entries; private maxEntries; private defaultHalfLifeMs; constructor(options?: { maxEntries?: number; defaultHalfLifeMs?: number; }); /** Store a new episodic memory */ store(content: string, tags?: string[], metadata?: Record, halfLifeMs?: number): string; /** Recall entries matching criteria, scored by recency and decay */ recall(options?: RecallOptions): EpisodicEntry[]; /** Remove a specific entry */ remove(id: string): boolean; /** Clear all entries */ clear(): void; /** Number of stored entries */ size(): number; /** Prune entries below a score threshold */ prune(minScore?: number): number; private evict; } /** * Persistent memory for successful skill/chain patterns. * Agents learn which patterns work and prefer them in future. */ export declare class ProceduralMemory { private entries; private maxEntries; constructor(options?: { maxEntries?: number; }); /** Register a pattern (chain/batch/loop/verify) */ register(id: string, content: string, patternType: string, tags?: string[], metadata?: Record): ProceduralEntry; /** Record success for a pattern — increases its score */ recordSuccess(id: string): void; /** Record failure for a pattern — decreases its score */ recordFailure(id: string): void; /** Recall top-scoring patterns matching criteria */ recall(options?: RecallOptions & { patternType?: string; }): ProceduralEntry[]; /** Get a specific pattern by ID */ get(id: string): ProceduralEntry | undefined; /** Number of stored patterns */ size(): number; /** Clear all patterns */ clear(): void; private evict; } /** * Cross-agent shared knowledge base. * Any agent can contribute; all agents can query. * Relevance scored by tag overlap and access frequency. */ export declare class SharedLongTermMemory { private entries; private maxEntries; constructor(options?: { maxEntries?: number; }); /** Contribute knowledge to the shared store */ contribute(sourceAgent: string, content: string, tags?: string[], metadata?: Record): string; /** Query shared memory, scored by tag overlap and recency */ query(agentId: string, options?: RecallOptions): SharedEntry[]; /** Get all entries contributed by a specific agent */ getByAgent(sourceAgent: string): SharedEntry[]; /** Number of stored entries */ size(): number; /** Clear all entries */ clear(): void; private evict; } /** * Unified memory system combining all three layers. * Instantiate per-agent for episodic, share ProceduralMemory and * SharedLongTermMemory across agents. * * @example * ```ts * const procedural = new ProceduralMemory(); * const shared = new SharedLongTermMemory(); * * const agentMemory = new AgentMemory('agent-1', { procedural, shared }); * agentMemory.episodic.store('Completed code review', ['review', 'code']); * agentMemory.procedural.recordSuccess('chain-review-fix'); * agentMemory.shared.contribute('agent-1', 'Auth service uses JWT', ['auth']); * ``` */ export declare class AgentMemory { readonly agentId: string; readonly episodic: EpisodicMemory; readonly procedural: ProceduralMemory; readonly shared: SharedLongTermMemory; constructor(agentId: string, options?: { episodic?: EpisodicMemory; procedural?: ProceduralMemory; shared?: SharedLongTermMemory; }); /** Recall across all layers, merged and ranked by score */ recallAll(options?: RecallOptions): MemoryEntry[]; } //# sourceMappingURL=agent-memory.d.ts.map