//#region extensions/crypto/src/services/agent-memory.d.ts /** * Agent Memory Service — file-backed declarative memory with frozen snapshots. * * Inspired by Hermes Agent's memory system. Two stores: * MEMORY.md — agent's own notes (environment facts, tool quirks, lessons) * USER_{id}.md — per-user profile (preferences, communication style, habits) * * The "frozen snapshot" pattern: * 1. At session start, MEMORY.md + USER_{id}.md are read from disk * 2. The contents are injected into the system prompt via before_prompt_build * 3. Mid-session writes update disk immediately but do NOT change the active * prompt — this preserves the LLM prefix cache * 4. Next session sees the updated memory * * Entries are §-delimited strings inside the markdown files. * Character limits prevent unbounded growth. * * All writes are scanned for prompt injection and credential leaks. */ interface MemoryConfig { /** Max characters for agent memory. Default: 2200. */ agentCharLimit?: number; /** Max characters per user profile. Default: 1375. */ userCharLimit?: number; /** Base directory for memory files. Default: ~/.openclawnch/memory/ */ baseDir?: string; } interface MemoryEntry { content: string; addedAt: number; } declare class AgentMemoryService { private config; private agentStore; private userStores; private frozenSnapshots; private static readonly MAX_SNAPSHOTS; private static readonly SNAPSHOT_TTL_MS; constructor(config?: MemoryConfig); /** * Take a frozen snapshot for a session. * Call this at session start (before_prompt_build). The snapshot is * immutable for the duration of the session. */ freezeSnapshot(sessionKey: string, userId?: string): string; /** * Get the frozen snapshot for a session (returns empty string if none/expired). */ getSnapshot(sessionKey: string): string; /** * Clear the frozen snapshot when a session ends. */ clearSnapshot(sessionKey: string): void; /** * Evict stale/oversized snapshots to prevent unbounded memory growth. */ private evictStaleSnapshots; addAgentMemory(entry: string): { ok: boolean; error?: string; }; replaceAgentMemory(oldSubstring: string, newContent: string): { ok: boolean; error?: string; }; removeAgentMemory(substring: string): { ok: boolean; removed?: string; error?: string; }; getAgentMemory(): string[]; getAgentMemoryStats(): { entries: number; chars: number; limit: number; }; private getUserStore; addUserMemory(userId: string, entry: string): { ok: boolean; error?: string; }; replaceUserMemory(userId: string, oldSubstring: string, newContent: string): { ok: boolean; error?: string; }; removeUserMemory(userId: string, substring: string): { ok: boolean; removed?: string; error?: string; }; getUserMemory(userId: string): string[]; getUserMemoryStats(userId: string): { entries: number; chars: number; limit: number; }; getStatus(): { agentEntries: number; agentChars: number; agentCharLimit: number; userStoreCount: number; frozenSnapshotCount: number; }; } declare function getAgentMemory(config?: MemoryConfig): AgentMemoryService; declare function resetAgentMemory(): void; //#endregion export { MemoryConfig, MemoryEntry, getAgentMemory, resetAgentMemory }; //# sourceMappingURL=agent-memory.d.mts.map