/** * LocalEmbeddingService * * A zero-config, on-device embedder. It runs a small, pinned, CPU-only model * via the optional `@huggingface/transformers` package (Transformers.js + * onnxruntime) — no endpoint, no API key, no network beyond a one-time model * download that is cached on disk. * * It implements the same {@link Embedder} contract as the remote * `EmbeddingService`, so `VectorIndex` is agnostic to which one it was handed. * * The heavy dependency is loaded lazily, the first time `embed()` runs, and is * declared as an *optional* dependency: if it is not installed (or failed to * build on the platform), `embed()` throws a clear, actionable error instead of * breaking the build/install. The first-class keyword (BM25) index never depends * on it. */ import type { Embedder } from './embedding-service.js'; import type { EmbeddingConfig } from '../../types/index.js'; /** * Pinned default model: all-MiniLM-L6-v2 (~22M params, 384-dim), the standard * small, CPU-runnable sentence embedder. Pre-quantized ONNX weights (~23 MB) are * fetched once and cached. Pinned so results are reproducible across machines. */ export declare const DEFAULT_LOCAL_MODEL = "Xenova/all-MiniLM-L6-v2"; /** Where downloaded model weights are cached — shared across repositories. */ export declare const LOCAL_MODEL_CACHE_DIR: string; /** Operator signal for any other model id: set outside the repository. */ export declare const LOCAL_MODEL_ENV = "OPENLORE_LOCAL_EMBED_MODEL"; /** * Resolve the model id for the local provider, refusing an arbitrary one that came out * of the repository's `.openlore/config.json`. * * `embedding.model` is committed IN the analyzed repo, so on a clone it is * attacker-authored — the same premise `repo-config-trust` acts on for * `embedding.baseUrl`. The local path is the sharper end of it: this string is a * HuggingFace repo id handed to Transformers.js, which downloads it and loads the * weights into onnxruntime IN-PROCESS, on the READ path (orient / search_code), not only * during `analyze`. `allowLocalModels = false` stops a local filesystem path; it does * nothing about a remote repo the clone chose. So a value that is neither allowlisted nor * named by the operator's environment is ignored, with the default used instead — the * warn-and-ignore shape the rest of the trust boundary uses. * * `openlore embed --local --model X` writes the field into that same file, so it cannot * itself be the consent signal; set `OPENLORE_LOCAL_EMBED_MODEL` for an id outside the * allowlist. */ export declare function resolveTrustedLocalModel(configValue: string | undefined): string; export declare class LocalEmbeddingService implements Embedder { private readonly model; private readonly batchSize; /** Lazily-initialised, memoised extractor (model loads once per process). */ private extractorPromise; /** Mirrors EmbeddingService: keep texts under the model's token window. */ private static readonly MAX_CHARS_PER_TEXT; constructor(model?: string, batchSize?: number); /** * Build from repository config. `cfg` comes from `.openlore/config.json`, so the model * id passes through {@link resolveTrustedLocalModel} — the constructor stays open for * operator-driven callers that pass a model they chose themselves. */ static fromConfig(cfg: EmbeddingConfig): LocalEmbeddingService; /** `local:` prefix lets the served retrieval mode be derived from the sidecar. */ get modelName(): string; private getExtractor; embed(texts: string[]): Promise; } //# sourceMappingURL=local-embedding-service.d.ts.map