export type DebugFn = (message: string, data?: Record) => void; /** * Result of submitting a batch or polling its status. * Providers map their native status types into this shape. */ export type BatchResult = { /** Provider-specific batch identifier (OpenAI/Voyage: id, Gemini: name). */ id: string; /** Whether the batch has completed successfully. */ completed: boolean; /** Whether the batch has terminally failed. */ failed: boolean; /** Human-readable failure message (only when failed). */ failureMessage?: string; /** Output file identifier, available when completed. */ outputFileId?: string; }; /** * Provider-specific adapter for the batch embedding pipeline. * * TRequest is the provider's request line type (e.g. OpenAiBatchRequest). */ export interface BatchEmbeddingProvider { /** Provider name for log/error messages (e.g. "openai", "gemini", "voyage"). */ name: string; /** Maximum requests per single batch job. */ maxRequestsPerBatch: number; /** Upload requests and create a batch job. Return its initial status. */ submitBatch(requests: TRequest[], koiId: string): Promise; /** Poll for current batch status. */ pollBatchStatus(batchId: string): Promise; /** * Fetch the output file and parse it into a map of custom_id → embedding. * Should throw on per-line errors or missing embeddings. * @param outputFileId The file id from the completed batch * @param requests Original requests (to verify all are accounted for) * @param batchId For error messages */ fetchOutputEmbeddings(outputFileId: string, requests: TRequest[], batchId: string): Promise>; } export type RunBatchParams = { provider: BatchEmbeddingProvider; koiId: string; requests: TRequest[]; wait: boolean; pollIntervalMs: number; timeoutMs: number; concurrency: number; debug?: DebugFn; }; /** * Generic batch embedding pipeline. * Splits requests into groups, submits them with concurrency control, * polls for completion, fetches output, and merges results. */ export declare function runBatchEmbeddingPipeline(params: RunBatchParams): Promise>;