//#region packages/embeddings/src/embedder.interface.d.ts
/**
 * Embedding abstraction — allows swapping embedding models.
 */
interface IEmbedder {
  /** Generate an embedding vector for a single text string (used for documents/passages) */
  embed(text: string): Promise<Float32Array>;
  /**
   * Generate an embedding vector for a search query.
   * Some models (e.g., BGE) use a query prefix for asymmetric retrieval.
   * Falls back to embed() if the model doesn't need query prefixing.
   */
  embedQuery(query: string): Promise<Float32Array>;
  /** Generate embeddings for multiple text strings (batched, for documents/passages) */
  embedBatch(texts: string[], batchSize?: number): Promise<Float32Array[]>;
  /** The dimensionality of the embedding vectors */
  readonly dimensions: number;
  /** The model identifier */
  readonly modelId: string;
  /** Initialize the model (download if needed, load into memory) */
  initialize(): Promise<void>;
  /** Release model resources */
  shutdown?(): Promise<void>;
}
//#endregion
//#region packages/embeddings/src/embedder-proxy.d.ts
type EmbedderProxyLogger = {
  warn?: (message: string, data?: Record<string, unknown>) => void;
};
interface EmbedderProxyOptions {
  model?: string;
  dimensions?: number;
  nativeDim?: number;
  queryPrefix?: string;
  interOpNumThreads?: number;
  intraOpNumThreads?: number;
  initTimeoutMs?: number;
  requestTimeoutMs?: number;
  idleTimeoutMs?: number;
  logger?: EmbedderProxyLogger;
  maxRetries?: number;
  retryBaseDelayMs?: number;
}
declare class EmbedderProxy implements IEmbedder {
  private readonly options;
  private readonly logger?;
  private readonly healthBus;
  private readonly cb;
  private readonly initTimeoutMs;
  private readonly requestTimeoutMs;
  private readonly maxRetries;
  private readonly retryBaseDelayMs;
  private workerAvailable;
  private readonly workerPath;
  private readonly pendingRequests;
  private readonly childState;
  private readonly childErrors;
  private child;
  private readyChild;
  private pendingInit;
  private pendingShutdown;
  private initializePromise;
  private shutdownPromise;
  private cooldownRespawnTimer;
  private currentDimensions;
  private currentModelId;
  private coldStart;
  constructor(options?: EmbedderProxyOptions);
  get dimensions(): number;
  get modelId(): string;
  /** Whether the circuit breaker is currently open (embedder in cooldown) */
  get isCircuitOpen(): boolean;
  initialize(): Promise<void>;
  embed(text: string): Promise<Float32Array>;
  embedQuery(text: string): Promise<Float32Array>;
  embedBatch(texts: string[], batchSize?: number): Promise<Float32Array[]>;
  private sendBatchRequest;
  shutdown(): Promise<void>;
  private startWorker;
  private spawnChild;
  private handleChildMessage;
  private handleChildExit;
  private handleChildFailure;
  private sendVectorRequestWithRetry;
  private sendVectorRequest;
  private withWorkerExitRetry;
  private isWorkerExitError;
  private wait;
  private requireReadyChild;
  private buildInitConfig;
  private buildChildEnv;
  private requireChildState;
  private clearChildReference;
  private clearCooldownRespawnTimer;
  private startCooldownRespawn;
  private markWorkerUnresponsive;
  private assertCircuitClosed;
  private rejectPendingForChild;
  private resolveLifecycleIfOwned;
  private rejectLifecycleIfOwned;
  private toError;
}
//#endregion
//#region packages/embeddings/src/onnx-embedder.d.ts
declare class OnnxEmbedder implements IEmbedder {
  private pipe;
  private shutdownPromise;
  readonly dimensions: number;
  readonly modelId: string;
  private readonly nativeDim;
  private readonly queryPrefix;
  private readonly threadConfig;
  constructor(options?: {
    model?: string;
    dimensions?: number;
    nativeDim?: number;
    queryPrefix?: string;
    interOpNumThreads?: number;
    intraOpNumThreads?: number;
  });
  private detectQueryPrefix;
  private getPipelineOptions;
  private computeNorm;
  /**
   * Matryoshka truncation: slice to targetDim and re-normalize.
   * Only applied when targetDim < nativeDim.
   * Modular — swap this function to change truncation strategy.
   */
  private truncateAndRenorm;
  initialize(): Promise<void>;
  private isCorruptionError;
  shutdown(): Promise<void>;
  private _doShutdown;
  embed(text: string): Promise<Float32Array>;
  embedQuery(query: string): Promise<Float32Array>;
  embedBatch(texts: string[], batchSize?: number): Promise<Float32Array[]>;
}
//#endregion
export { EmbedderProxy, type EmbedderProxyOptions, type IEmbedder, OnnxEmbedder };