/** * Runs the transformers.js feature-extraction pipeline in a worker thread. * * Why: onnxruntime-node 1.21.0 (pinned exactly by @huggingface/transformers * 3.8.x) aborts the whole process on macOS when the process calls * process.exit() while an ONNX session lives on the main thread: * "libc++abi: terminating due to uncaught exception of type * std::__1::system_error: mutex lock failed: Invalid argument" (exit 134). * phi quits through process.exit(), so every macOS session that used memory * ended with that abort. Fixed upstream in onnxruntime-node >= 1.24, which * transformers 3.x cannot use. A worker's environment is torn down (ONNX * objects released) before the process exits, which avoids the abort with * the current dependency (verified on macos-latest, install smoke workflow). */ /** Same call shape as the in-process pipeline: (text, options) => { data }. */ export type EmbeddingPipeline = ((text: string, options: Record) => Promise<{ data: Float32Array; }>) & { dispose: () => Promise; }; export interface WorkerPipelineOptions { /** Absolute path of the @huggingface/transformers entry to load in the worker. */ transformersEntry: string; modelCacheDir?: string; task: string; model: string; options: Record; } /** Starts the worker, loads the model there, resolves once it is ready. */ export declare function createWorkerPipeline(config: WorkerPipelineOptions): Promise; /** * Whether embeddings run in a worker by default: macOS under Node only (the * abort is specific to onnxruntime-node's static teardown on macOS; the Bun * binary keeps the in-process pipeline). PHI_EMBEDDING_WORKER=1|0 overrides. */ export declare function defaultUseEmbeddingWorker(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, isBun?: boolean): boolean; //# sourceMappingURL=embedding-worker.d.ts.map