/**
 * Memory Manager - Persistent user memory across sessions.
 *
 * Stores memories in ~/.avis/self/memory/memory.jsonl as an append-only log.
 * Supports create, update, delete, and list operations.
 * Memories are injected into the system prompt so the agent has context
 * about user preferences, past decisions, and behavioral patterns.
 */
import { ConversationBuffer } from "./conversation-buffer.js";
import { MemoryGraph, type RetrievalResult } from "./memory-graph.js";
export interface Memory {
    id: string;
    content: string;
    tags: string[];
    createdAt: string;
    updatedAt: string;
}
export declare class MemoryManager {
    private _filePath;
    private _memories;
    private _loaded;
    private _graph;
    private _graphDirty;
    /** Track file mtime to detect external changes */
    private _lastMtime;
    /** File watcher for real-time sync across instances */
    private _watcher;
    /** Debounce timer for file change events */
    private _reloadTimer;
    /** Tier 1: Rolling verbatim conversation buffer */
    private _conversationBuffer;
    /** Cached container context block (refreshed periodically) */
    private _containerContext;
    private _containerContextAge;
    private _containerAlive;
    constructor(filePath?: string, options?: {
        bufferSize?: number;
    });
    /** Watch memory.jsonl for external changes (other avis instances, daemon, etc.) */
    private _startWatching;
    /** Check if file changed externally and reload if needed */
    private _checkAndReload;
    /** Stop watching for changes (cleanup) */
    stopWatching(): void;
    /** Get the conversation buffer (Tier 1 memory) */
    get conversationBuffer(): ConversationBuffer;
    /** Get or create the memory graph */
    get graph(): MemoryGraph;
    get filePath(): string;
    /** Lazy-load memories from disk */
    private _ensureLoaded;
    private _append;
    /** Get all active memories */
    list(): Memory[];
    /** Search memories by content substring or tag */
    search(query: string): Memory[];
    /** Get a single memory by ID */
    get(id: string): Memory | undefined;
    /** Create a new memory. Returns the created memory. */
    create(content: string, tags?: string[]): Memory;
    /** Update an existing memory. Returns the updated memory or undefined if not found. */
    update(id: string, content?: string, tags?: string[]): Memory | undefined;
    /** Delete a memory. Returns true if found and deleted. */
    delete(id: string): boolean;
    /** Delete all memories */
    clear(): number;
    /** Get the count of active memories */
    get count(): number;
    /**
     * Format memories for injection into the system prompt.
     * If graph is available and built, uses graph-based formatting with god nodes
     * and community context. Otherwise falls back to flat list.
     * Returns empty string if no memories exist.
     */
    formatForSystemPrompt(): string;
    /** Non-blocking refresh of container context. Caches for 60s. */
    private _refreshContainerContext;
    private _fetchContainerContext;
    /** Whether the container daemon is reachable. */
    get isContainerAlive(): boolean;
    /** Store a memory in both the local file and the container. */
    storeToContainer(content: string, category?: string, tags?: string[]): Promise<void>;
    /**
     * Retrieve memories relevant to a specific query using graph traversal.
     * Falls back to text search if graph is not available.
     * @param query The user's message or search query
     * @param maxResults Maximum number of memories to return
     */
    retrieveRelevant(query: string, maxResults?: number): RetrievalResult;
    /**
     * Format context-aware memories for the system prompt.
     * Uses graph traversal to find only memories relevant to the current query.
     * Falls back to formatForSystemPrompt() if graph is not available.
     */
    formatRelevantForPrompt(query: string, maxResults?: number): string;
    /**
     * Rebuild the memory graph if needed.
     * Call this after batch memory operations or periodically.
     * Returns stats if rebuild happened, null if not needed.
     */
    rebuildGraphIfNeeded(): Promise<{
        nodeCount: number;
        edgeCount: number;
        communityCount: number;
    } | null>;
    /** Force reload from disk */
    reload(): void;
}
//# sourceMappingURL=memory-manager.d.ts.map