import type { EmbeddingModel } from "../types.js"; export interface NeuralEmbeddingConfig { backend: "hash" | "neural"; modelPath?: string; } export type FeatureExtractionPipeline = (text: string, options: { pooling: "mean"; normalize: true; }) => Promise<{ data: ArrayLike; }>; export interface EmbeddingModelFactoryOptions { /** Test/DI seam: loads (or fakes) the transformers.js feature-extraction pipeline. */ loadPipeline?: (modelPath: string | undefined) => Promise; /** * Called with the error that triggered a fallback to LocalHashEmbeddingModel. * Never allowed to break the fallback: any synchronous error thrown from * this callback is swallowed. (An async onFallback that rejects after * returning would produce an unhandled rejection — the inner try/catch * here does not catch that case.) Use this for observability (network * failure vs. corrupted model vs. OOM are operationally very different) — * never for control flow. */ onFallback?: (error: unknown) => void; } /** * Routes @huggingface/transformers's model-weight downloads through the * standard proxy env vars. Returns whether a proxy was configured (by this * call or a previous one in this process). */ export declare function configureProxyFromEnvironment(env?: Record): boolean; export declare class BgeSmallEmbeddingModel implements EmbeddingModel { private readonly extractor; readonly id = "bge-small-en-v1.5"; readonly dimensions = 384; constructor(extractor: FeatureExtractionPipeline); embed(text: string, signal?: AbortSignal): Promise; } /** * Resolves the configured embedding backend. Any failure to load the neural * pipeline, download weights, or run inference falls back to * LocalHashEmbeddingModel — an embedding backend failure must never break * OpenCode prompt execution. */ export declare function createEmbeddingModel(config: NeuralEmbeddingConfig, options?: EmbeddingModelFactoryOptions): Promise;