/**
 * Memory Graph - Knowledge graph layer over the flat memory store.
 *
 * Uses graphify to build a graph from memories, enabling:
 * - Contextual retrieval via BFS/DFS traversal
 * - Community detection to cluster related memories
 * - God node detection to find key themes
 * - Surprising connections between distant memories
 *
 * The graph is stored at ~/.avis/self/memory/graph/ and rebuilt
 * incrementally when memories change.
 */
import type { Memory, MemoryManager } from "./memory-manager.js";
export interface MemoryGraphNode {
    id: string;
    label: string;
    /** The memory ID(s) this node was extracted from */
    memoryIds: string[];
    community?: number;
    source_file?: string;
}
export interface MemoryGraphEdge {
    source: string;
    target: string;
    relation: string;
    confidence: string;
    confidence_score: number;
}
export interface MemoryGraphData {
    nodes: MemoryGraphNode[];
    edges: MemoryGraphEdge[];
    communities: Record<string, string[]>;
    communityLabels: Record<string, string>;
    godNodes: string[];
    lastMemoryCount: number;
    lastBuildTime: string;
}
export interface RetrievalResult {
    /** Memories ranked by relevance to the query */
    memories: Memory[];
    /** Community labels that matched */
    matchedCommunities: string[];
    /** God nodes (key themes) for context */
    godNodes: string[];
}
export declare class MemoryGraph {
    private _graphDir;
    private _graphPath;
    private _graphData;
    private _pythonPath;
    private _memoryManager;
    constructor(memoryManager: MemoryManager, graphDir?: string);
    get graphDir(): string;
    private _detectPython;
    private _runPython;
    /** Check if graphify is available */
    isAvailable(): boolean;
    /** Load graph data from disk */
    private _loadGraph;
    /** Check if graph needs rebuilding (memories changed since last build) */
    needsRebuild(): boolean;
    /**
     * Build or rebuild the knowledge graph from all memories.
     *
     * Converts memories into a document that graphify can process,
     * then extracts entities/relationships and clusters them.
     */
    build(): Promise<{
        nodeCount: number;
        edgeCount: number;
        communityCount: number;
    }>;
    /**
     * Convert memories into a structured extraction JSON that graphify can build from.
     * Each memory becomes one or more nodes with edges between related concepts.
     */
    private _extractFromMemories;
    /**
     * Extract key terms from memory content.
     * Simple heuristic: words > 3 chars, not stopwords, capitalized phrases.
     */
    private _extractKeyTerms;
    /**
     * Convert memories to a markdown document for graphify to process.
     */
    private _memoriesToDocument;
    /**
     * Query the memory graph to find memories relevant to a user message.
     *
     * Uses BFS from matching nodes to find connected memories,
     * ranked by graph distance and confidence scores.
     */
    retrieve(query: string, maxResults?: number): RetrievalResult;
    /**
     * Format a graph-based retrieval result for the system prompt.
     * Only includes memories relevant to the query, plus context from the graph.
     */
    formatRetrievalForPrompt(result: RetrievalResult): string;
    /**
     * Get graph statistics for display.
     */
    getStats(): {
        nodeCount: number;
        edgeCount: number;
        communityCount: number;
        godNodes: string[];
        lastBuildTime: string | null;
    };
}
//# sourceMappingURL=memory-graph.d.ts.map