import Database from 'better-sqlite3'; import { V as VectorStore } from '../types-CRqwkJoZ.js'; import { EmbeddingProvider } from '../embeddings/types.js'; import { Logger } from '../observability/logger.js'; import { Metrics } from '../observability/metrics.js'; import { NeuromcpConfig } from '../config.js'; import { MemoryWithScore, TrustLevel } from '../types.js'; import { RerankProvider } from '../rerank/types.js'; /** * Explanation payload attached to each search result. * Answers: why was this returned? How confident should you be? What contradicts it? */ interface MemoryExplanation { /** Why this trust level was assigned */ readonly source_trust: { readonly level: TrustLevel; readonly reason: string; }; /** Is this memory currently temporally valid? */ readonly temporal_validity: { readonly currently_valid: boolean; readonly valid_from: string | null; readonly valid_to: string | null; readonly superseded_by: string | null; }; /** Contradicting memories (via knowledge graph 'contradicts' edges) */ readonly contradictions: readonly { readonly memory_id: string; readonly content_preview: string; readonly resolution: string; }[]; /** Atomic claims extracted from this memory */ readonly claims: readonly { readonly subject: string; readonly predicate: string; readonly object: string; readonly confidence: number; }[]; /** Breakdown of the retrieval score */ readonly confidence: { readonly retrieval_score: number; readonly source_trust_score: number; readonly temporal_valid: boolean; readonly has_contradictions: boolean; readonly claim_count: number; /** Overall confidence: combined signal */ readonly overall: number; }; } interface MemoryWithExplanation extends MemoryWithScore { readonly explain: MemoryExplanation; } interface SearchInput { readonly query: string; readonly namespace?: string; readonly limit?: number; readonly category?: string; readonly tags?: readonly string[]; readonly min_importance?: number; readonly min_trust?: TrustLevel; readonly after?: string; readonly before?: string; readonly hybrid?: boolean; readonly valid_at?: string; readonly graph_boost?: boolean; readonly episode_id?: string; readonly explain?: boolean; readonly compact?: boolean; /** * v0.29: include superseded / window-closed rows. Default false — only * current facts. A `valid_at` point-in-time query overrides this (history * is exactly what valid_at asks for). */ readonly include_superseded?: boolean; } /** The 7 fields a consuming agent typically needs. Reduces payload ~10×. */ interface CompactMemory { readonly id: string; readonly content: string; readonly similarity_score: number; readonly category: string | null; readonly tags: string; readonly importance: number; readonly created_at: string; } /** * Strip a MemoryWithScore / MemoryWithExplanation down to the compact * projection. Keeps `explain` intact when present (it was explicitly * requested by the caller). */ declare function toCompact(m: MemoryWithScore | MemoryWithExplanation): CompactMemory | (CompactMemory & { explain: unknown; }); interface SearchDeps { readonly db: Database.Database; readonly vecStore: VectorStore; readonly embedder: EmbeddingProvider; readonly logger: Logger; readonly metrics: Metrics; readonly config: NeuromcpConfig; /** * Optional relevance reranker. When present, search fetches a wider * candidate pool (config.rerankPool), scores each candidate against the * query, and orders by that score before MMR. Absent/null → plain RRF * order (default). Constructed once at startup from config.reranker. */ readonly reranker?: RerankProvider | null; } /** * FTS5 candidate lookup with namespace pushdown. Without the pushdown the * limit*3 candidate budget is consumed by other namespaces' rows (which the * post-filter then discards), starving the FTS leg in multi-tenant DBs — * the keyword-side twin of the vec-side recall collapse fixed in * sqlite-vec.ts. `namespace === undefined` (or '*' resolved by the caller) * searches all namespaces. */ declare function ftsCandidates(db: Database.Database, ftsQuery: string, k: number, namespace?: string, currentOnlyNow?: string): Array<{ id: string; }>; declare function searchMemory(input: SearchInput, deps: SearchDeps): Promise; export { type CompactMemory, type SearchDeps, type SearchInput, ftsCandidates, searchMemory, toCompact };