/** * Client for the `embsearch` stdio daemon (vendored from * github.com/kolisachint/embeddingsearchtools ts/client.ts). * * Spawns `embsearch serve` once and talks newline-delimited JSON over its * stdin/stdout. The process stays alive so the model and index load a single * time; every query after startup is hot. */ export interface EmbSearchResult { id: string; score: number; } export interface EmbSearchDaemonInfo { modelId: string; dim: number; count: number; /** * Whether the open store carries a BM25 index alongside its vectors. * * Fixed when the store is created — passing `--hybrid` at a non-hybrid * store only warns — so this is the only reliable way to find out, and the * signal that an existing store has to be rebuilt rather than reused. */ hybrid?: boolean; /** * Whether this daemon can actually serve `rerank`, or `undefined` from a * daemon too old to say. * * Reported separately from the version because the two came apart: * released binaries carry the `rerank` op but no longer bundle the ~23 MB * cross-encoder weights, so a version check alone would advertise a * reranker that fails on first call. */ rerank?: boolean; } /** One candidate sent for cross-encoder scoring. */ export interface EmbSearchRerankPassage { id: string; text: string; } /** A cross-encoder relevance logit. Higher is more relevant, but the scale is * unnormalized and comparable only within one call. */ export interface EmbSearchRerankResult { id: string; score: number; } export interface EmbSearchBulkResult { inserted: number; updated: number; } /** Which daemon-side retriever answers a query (embsearch >= 0.2.0). */ export type DaemonRetriever = "dense" | "lexical" | "hybrid"; export interface EmbSearchClientOptions { /** Open/create the store with a BM25 lexical index alongside the vectors. */ hybrid?: boolean; /** Path to the `embsearch` binary. */ binaryPath: string; /** Store directory passed as `--path`. */ storePath: string; /** * Model directory passed as `--model` (onnx builds only): a dir holding * `model.onnx`, `tokenizer.json` and `model.json`. * * Omitted, the daemon uses the model bundled into the binary. Set, the * binary no longer determines which model produced a vector — which is why * the eval harness records `info.model_id` rather than the binary version. */ modelDir?: string; /** Metric for a freshly created store. Default: "cosine". */ metric?: "cosine" | "dot" | "euclidean"; } export declare class EmbSearchClient { private proc; private queue; private buffer; private closed; private readyPromise; constructor(opts: EmbSearchClientOptions); /** Resolves once the daemon has loaded the model + index. */ ready(): Promise; get isClosed(): boolean; private onStdout; private send; /** * Search for the top-`k` matches for `text`. * * `retriever` selects which leg answers: * - `dense` (default) — vector search, the historical behaviour; * - `lexical` — BM25 only, raw scores, no embedding computed; * - `hybrid` — both, pre-fused by the daemon's own RRF constant. * * `lexical` and `hybrid` need a store created with `--hybrid`. Prefer * `lexical` over `hybrid` when fusing here: `hybrid` collapses both legs * into one RRF score, discarding the per-retriever ranks the trace records * and preventing n-way fusion with the grep leg. */ query(text: string, k?: number, retriever?: DaemonRetriever): Promise; /** * Score `passages` against `query` with the daemon's cross-encoder and * return the best `k`, best first. * * Passages are sent inline rather than referenced by id: the caller has the * exact spans it intends to show the model, and a cross-encoder scores the * text it is given, so sending anything else would score the wrong thing. * Requires an onnx build with reranker weights (embsearch >= 0.3.0). */ rerank(query: string, passages: EmbSearchRerankPassage[], k: number): Promise; /** * Batched insert-or-replace. One embedding inference for the whole batch — * the fast path for bulk indexing. Keep batches modest (e.g. 32–64) so a * concurrent query is not stuck behind a huge inference. */ bulk(items: Array<{ id: string; text: string; }>): Promise; /** Model id, dimensionality, and live vector count of the daemon. */ info(): Promise; /** Remove a record. Resolves to `true` if it existed. */ remove(id: string): Promise; /** Reclaim tombstoned rows left behind by `remove`. */ compact(): Promise; /** Persist the index to the store directory. */ save(): Promise; /** Shut the daemon down, closing stdin so it exits cleanly. */ close(): Promise; } //# sourceMappingURL=client.d.ts.map