import type { MemoryEntry, MemoryScope } from '../types/memory.js'; import type { WstackPaths } from '../utils/wstack-paths.js'; export interface MemoryBackend { readonly kind: string; remember(scope: MemoryScope, entry: MemoryEntry, filePath: string): Promise; forget(scope: MemoryScope, query: string, filePath: string): Promise; readAll(scope: MemoryScope, filePath: string): Promise; list(scope: MemoryScope, filePath: string, limit?: number | undefined): Promise; search(scope: MemoryScope, query: string, filePath: string, limit?: number | undefined): Promise; /** Find memories related to the given text via graph traversal. Optional — falls back to search. */ findRelated?(scope: MemoryScope, filePath: string, text: string, limit: number): Promise; clear(scope: MemoryScope, filePath: string): Promise; consolidate(scope: MemoryScope, filePath: string): Promise; } interface IndexedEntry { entry: MemoryEntry; /** Lower-cased words extracted from text. */ words: string[]; /** Lower-cased tags. */ tags: string[]; } interface InvertedIndex { /** word -> entry indices */ wordMap: Map; /** tag -> entry indices */ tagMap: Map; entries: IndexedEntry[]; /** Last known file mtime for cache invalidation. */ mtimeMs: number; } export declare function buildInvertedIndex(entries: MemoryEntry[]): InvertedIndex; export declare function searchIndex(index: InvertedIndex, query: string, limit?: number): MemoryEntry[]; export interface FileMemoryBackendOptions { paths: WstackPaths; } export declare class FileMemoryBackend implements MemoryBackend { readonly kind = "file"; private readonly files; /** Cache of parsed entries per file path. */ private readonly entryCache; /** Inverted index per file path. */ private readonly indexCache; /** File mtime cache for invalidation. */ private readonly mtimeCache; constructor(opts: FileMemoryBackendOptions); private resolveFile; private getMtime; private invalidateCache; /** * Load (and cache) the parsed entries for a file. Callers that have already * stat'd the file this tick (e.g. `getIndex`) can pass the known `mtime` to * avoid a redundant `fs.stat` — otherwise it's fetched here. */ private loadEntries; private getIndex; remember(scope: MemoryScope, entry: MemoryEntry, filePath: string): Promise; forget(scope: MemoryScope, query: string, filePath: string): Promise; readAll(scope: MemoryScope, filePath: string): Promise; list(scope: MemoryScope, filePath: string, limit?: number): Promise; search(scope: MemoryScope, query: string, filePath: string, limit?: number): Promise; clear(scope: MemoryScope, filePath: string): Promise; consolidate(scope: MemoryScope, filePath: string): Promise; } export declare function parseEntries(raw: string, scope?: MemoryScope): MemoryEntry[]; export {}; //# sourceMappingURL=memory-backend.d.ts.map