import { type Graph } from './build.js'; import { type EmbeddingInput, type ScoredCandidate } from './embed.js'; import type { Inventory, IR } from '../core/types.js'; /** What the apply loop needs from a driver. Durable Objects, D1 and * node:sqlite all satisfy this in a few lines. */ export interface SqlSink { exec(sql: string): void; run(sql: string, params: (string | number | null)[]): void; /** E28 t6 — OPTIONAL read-back, used for one thing only: finding typed tables * the current format no longer declares, so they can be dropped instead of * lingering as stale-but-queryable data. A sink that cannot read simply keeps * them; every sink that can (node:sqlite, Durable Object SQLite, D1) sweeps. */ all?(sql: string): { name: string; }[]; } /** Rebuild the projection in place: reset, insert, index. Idempotent by * construction — the graph is derived, so re-applying is always correct and * no migration is ever needed. */ export declare function applyGraph(sink: SqlSink, graph: Graph): void; /** The whole projection as a portable `.sql` script — what you pipe into * `sqlite3`, or POST to a host that has no driver binding of its own. */ export declare function toSqlScript(graph: Graph): string; /** Write a real database file. `node:sqlite` is built in from Node 22.5 — * no dependency is added — but the engine supports Node 20, so a runtime * without it gets the script instead of a crash. */ export declare function writeDatabase(file: string, graph: Graph, embeddings?: EmbeddingInput[] | null): Promise; /** A live database over a graph, for a host that answers queries: `docujoint * serve` keeps one in memory and rebuilds it whenever the vault changes. * Only NAMED queries from the shipped library can be run — a caller picks * from the catalogue exactly as a definition picks a widget, and arbitrary * SQL is never accepted from outside the engine. */ export interface GraphQueryRunner { run(name: string, params: (string | number)[]): unknown[]; /** Store vectors a HOST produced. The engine validates and files them; it * never calls a model. */ putEmbeddings(batch: EmbeddingInput[]): { stored: number; skipped: { id: string; reason: string; }[]; }; /** Semantic search: SQLite narrows by the same prefilters a keyword search * uses, the host scores what survives. */ similar(vector: number[], filters: Record, k: number): ScoredCandidate[]; close(): void; } /** * @param file where the projection lives. Omitted, it is in memory and dies * with the process. Given a path, it is a real database on disk — which is * what makes EMBEDDINGS survive a restart: the projection is re-derived * around them on every rebuild, and they are the only part nobody can * recompute for free. */ export declare function openQueryRunner(graph: Graph, file?: string | null): Promise; /** One call for the common case. */ export declare function graphOf(ir: IR, inventory?: Inventory | null): Graph;