{"version":3,"file":"transformers_js-p3lAkHFH.mjs","names":["#options","#pipeline","#resolvePipeline","#pipelinePromise","#toPcm16k"],"sources":["../src/batteries/specialists/stt/transformers_js/exceptions.ts","../src/batteries/specialists/stt/transformers_js/validation.ts","../src/batteries/specialists/stt/transformers_js/adapter.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the transformers.js STT adapter.\n *\n * @remarks\n * Battery-scoped exception classes for the transformers.js (`@huggingface/transformers`)\n * speech-to-text adapter, minted via `createException` from `@nhtio/adk/factories`. Categories mirror\n * the transformers.js Embeddings battery one-to-one — only the engine-specific failure differs.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when the resolved adapter options fail validation against\n * `transformersJsSttAdapterOptionsSchema` — e.g. a missing/empty `model` or an unknown option key.\n * Fatal: config bugs fail loud, not at transcribe time.\n */\nexport const E_INVALID_TRANSFORMERS_JS_STT_OPTIONS = createException<[string]>(\n  'E_INVALID_TRANSFORMERS_JS_STT_OPTIONS',\n  'Invalid transformers.js STT adapter options: %s',\n  'E_INVALID_TRANSFORMERS_JS_STT_OPTIONS',\n  529,\n  true\n)\n\n/**\n * Thrown when the transformers.js pipeline fails to load (e.g. the `@huggingface/transformers` peer\n * is not installed) or the `automatic-speech-recognition` call throws/returns a malformed result.\n * Non-fatal. Printf arg: `[detail]`.\n */\nexport const E_TRANSFORMERS_JS_STT_ENGINE_ERROR = createException<[string]>(\n  'E_TRANSFORMERS_JS_STT_ENGINE_ERROR',\n  'transformers.js STT engine error: %s',\n  'E_TRANSFORMERS_JS_STT_ENGINE_ERROR',\n  502,\n  false\n)\n","/**\n * Runtime validation schema and wrapper for transformers.js STT adapter options.\n *\n * @remarks\n * Validates `TransformersJsSttAdapterOptions` at construction time. Throws\n * `E_INVALID_TRANSFORMERS_JS_STT_OPTIONS` on failure. `model` is required; unknown top-level keys are\n * rejected so typos fail loud.\n */\n\nimport { isError } from '@nhtio/adk/guards'\nimport { validator, ValidationError } from '@nhtio/validation'\nimport { E_INVALID_TRANSFORMERS_JS_STT_OPTIONS } from './exceptions'\nimport type { TransformersJsSttAdapterOptions } from './types'\n\n/** Validator schema for `TransformersJsSttAdapterOptions`. Rejects unknown top-level keys. */\nexport const transformersJsSttAdapterOptionsSchema = validator\n  .object<TransformersJsSttAdapterOptions>({\n    model: validator.string().min(1).required(),\n    // Pipeline knobs (the transformers.js pipeline is a callable object — accept function or object)\n    pipeline: validator\n      .alternatives(validator.function(), validator.object().unknown(true))\n      .optional(),\n    createPipeline: validator.function().optional(),\n    device: validator.string().optional(),\n    dtype: validator.string().optional(),\n    chunkLengthS: validator.number().positive().default(30),\n    decodeAudio: validator.function().optional(),\n    modelSource: validator.function().optional(),\n    onInitProgress: validator.function().optional(),\n    isAvailable: validator.function().optional(),\n    // ── Lifecycle hooks (opt-in, normalized phase machine; additive over onInitProgress) ──\n    onLifecycle: validator.function().optional(),\n    onLoading: validator.function().optional(),\n    onCompiling: validator.function().optional(),\n    onReady: validator.function().optional(),\n    onGenerating: validator.function().optional(),\n    onComplete: validator.function().optional(),\n    onError: validator.function().optional(),\n  })\n  .unknown(false)\n\nconst isValidationError = (value: unknown): value is ValidationError =>\n  isError(value) && Array.isArray((value as ValidationError).details)\n\nconst formatValidationDetails = (err: ValidationError): string =>\n  err.details.map((d) => d.message).join(' and ')\n\n/**\n * Validates an arbitrary input against `transformersJsSttAdapterOptionsSchema`.\n *\n * @param input - The raw options object to validate.\n * @returns The resolved options object with defaults filled in.\n * @throws {@link @nhtio/adk/batteries!E_INVALID_TRANSFORMERS_JS_STT_OPTIONS} when invalid.\n */\nexport const validateOptions = (input: unknown): TransformersJsSttAdapterOptions => {\n  const { value, error } = transformersJsSttAdapterOptionsSchema.validate(input, {\n    abortEarly: false,\n    convert: false,\n  })\n  if (error && isValidationError(error)) {\n    throw new E_INVALID_TRANSFORMERS_JS_STT_OPTIONS([formatValidationDetails(error)], {\n      cause: error,\n    })\n  }\n  return value as TransformersJsSttAdapterOptions\n}\n","/**\n * transformers.js (ONNX, dual-environment) STT (speech-to-text) adapter battery.\n *\n * @remarks\n * Specialist battery backed by transformers.js's `automatic-speech-recognition` (Whisper-family)\n * pipeline. **Environment-neutral** — runs in Node (via `onnxruntime-node`) and the browser (via\n * `onnxruntime-web` / WebGPU), auto-selected by the package; there is no WebGPU requirement, mirroring\n * the transformers.js Embeddings battery this adapter is modeled on.\n *\n * Accepts any {@link @nhtio/adk/batteries/specialists/_shared!SpecialistAudioInput} form: already-\n * decoded mono PCM (skips decoding), or an encoded container (bytes / bytes+mime / a duck-typed\n * `Media`) decoded via an injectable {@link DecodeAudioFn}. Either path is resampled to the 16 kHz mono\n * PCM Whisper expects before the pipeline call.\n *\n * `@huggingface/transformers` is an optional peer dependency, imported lazily.\n */\n\nimport { isError } from '@nhtio/adk/guards'\nimport { validateOptions } from './validation'\nimport { resampleTo } from '../../../../lib/utils/audio'\nimport { emitLifecycle } from '../../../llm/chat_common/lifecycle'\nimport { isPcmInput, toBytes, defaultDecodeAudio } from '../../_shared'\nimport { withModelSource } from '../../../llm/transformers_js/model_source'\nimport {\n  E_INVALID_TRANSFORMERS_JS_STT_OPTIONS,\n  E_TRANSFORMERS_JS_STT_ENGINE_ERROR,\n} from './exceptions'\nimport type { SpecialistAudioInput } from '../../_shared'\nimport type {\n  TransformersJsSttAdapterOptions,\n  TransformersJsSttPipeline,\n  CreateTransformersJsSttPipeline,\n  TranscribeOptions,\n  TranscribeResult,\n  SttSegment,\n} from './types'\n\n/** The shape the transformers.js ASR pipeline resolves to (a subset of its documented output). */\ninterface AsrChunk {\n  /** `[start, end]` in seconds; `end` may be `null` when the engine cannot bound the chunk. */\n  timestamp: [number, number | null]\n  /** The chunk's recognized text. */\n  text: string\n}\n\ninterface AsrPipelineOutput {\n  text: string\n  chunks?: AsrChunk[]\n}\n\nconst makeDefaultCreatePipeline = (\n  modelSource: TransformersJsSttAdapterOptions['modelSource']\n): CreateTransformersJsSttPipeline => {\n  return async ({ model, device, dtype, onInitProgress }) => {\n    const transformers = await import('@huggingface/transformers')\n    const { pipeline, env } = transformers\n    const load = async () =>\n      (await pipeline('automatic-speech-recognition', model, {\n        ...(device ? { device } : {}),\n        ...(dtype ? { dtype } : {}),\n        ...(onInitProgress ? { progress_callback: onInitProgress } : {}),\n      } as never)) as unknown as TransformersJsSttPipeline\n    // When a custom model source is configured, serve files through it behind the global-`env` mutex.\n    return modelSource ? withModelSource(env as never, modelSource, load) : load()\n  }\n}\n\n/**\n * STT adapter for transformers.js's automatic-speech-recognition (Whisper-family) pipeline.\n *\n * @remarks\n * Reusable: construct once, call {@link TransformersJsSttAdapter.transcribe} as many times as needed.\n * The pipeline is resolved lazily on first use (or via {@link preload}) and cached with single-flight\n * semantics so concurrent calls share one load.\n */\nexport class TransformersJsSttAdapter {\n  readonly #options: TransformersJsSttAdapterOptions\n  #pipeline: TransformersJsSttPipeline | undefined\n  #pipelinePromise: Promise<TransformersJsSttPipeline> | undefined\n\n  /**\n   * Whether this battery is available. transformers.js is environment-neutral (Node + browser), so\n   * this is `true` whenever the runtime can import the peer — there is no WebGPU requirement.\n   */\n  public static isAvailable(): boolean {\n    return true\n  }\n\n  /**\n   * @param options - Constructor options. Validated eagerly.\n   * @throws {@link @nhtio/adk/batteries!E_INVALID_TRANSFORMERS_JS_STT_OPTIONS} when invalid.\n   */\n  constructor(options: unknown) {\n    this.#options = validateOptions(options)\n    this.#pipeline = this.#options.pipeline\n  }\n\n  /** Instance availability probe (honours an injected `isAvailable`). */\n  isAvailable(): boolean {\n    return (this.#options.isAvailable ?? TransformersJsSttAdapter.isAvailable)()\n  }\n\n  /** Eagerly loads (and caches) the pipeline so the first `transcribe` call is fast. Idempotent. */\n  async preload(): Promise<void> {\n    await this.#resolvePipeline()\n  }\n\n  /** Drops the cached pipeline and in-flight load so the next call reloads. */\n  reset(): void {\n    this.#pipeline = undefined\n    this.#pipelinePromise = undefined\n  }\n\n  /**\n   * Release the loaded model's ONNX sessions + GPU/wasm buffers, then drop the cached pipeline.\n   *\n   * @remarks\n   * `reset()` only nulls the JS reference; the native ONNX Runtime sessions and WebGPU/wasm device\n   * memory stay alive until GC. `AutomaticSpeechRecognitionPipeline` extends `Pipeline`, which exposes\n   * `dispose()` — this awaits it so the memory is reclaimed between loads, swallows a disposal error\n   * (teardown must not throw), and finishes with `reset()`. Idempotent.\n   */\n  async dispose(): Promise<void> {\n    const pipeline = this.#pipeline ?? (await this.#pipelinePromise?.catch(() => undefined))\n    const pipeWithDispose = pipeline as { dispose?: () => Promise<unknown> } | undefined\n    if (typeof pipeWithDispose?.dispose === 'function') {\n      await Promise.resolve(pipeWithDispose.dispose()).catch(() => undefined)\n    }\n    this.reset()\n  }\n\n  async #resolvePipeline(): Promise<TransformersJsSttPipeline> {\n    if (this.#pipeline) return this.#pipeline\n    if (!this.isAvailable()) {\n      throw new E_INVALID_TRANSFORMERS_JS_STT_OPTIONS([\n        'the transformers.js STT battery is not available in this runtime',\n      ])\n    }\n    const opts = this.#options\n    this.#pipelinePromise ??= (async () => {\n      emitLifecycle(opts, 'transformers_js_stt', opts.model, 'loading', {\n        detail: 'loading automatic-speech-recognition pipeline',\n      })\n      // Forward each provider download event into a normalized `loading` lifecycle report.\n      const hasLifecycle =\n        opts.onLifecycle ?? opts.onLoading ?? opts.onReady ?? opts.onGenerating ?? opts.onError\n      const forwardedInitProgress = hasLifecycle\n        ? (info: unknown) => {\n            const p = (info as { progress?: number } | undefined)?.progress\n            emitLifecycle(opts, 'transformers_js_stt', opts.model, 'loading', {\n              ...(typeof p === 'number' ? { progress: p / 100 } : {}),\n              raw: info,\n            })\n            opts.onInitProgress?.(info as never)\n          }\n        : opts.onInitProgress\n      const createPipeline = opts.createPipeline ?? makeDefaultCreatePipeline(opts.modelSource)\n      try {\n        // `from_pretrained` covers both fetch (reported via progress_callback → `loading`) and the\n        // ONNX-graph / WebGPU-WASM warmup. Mark the latter as `compiling` — a COARSE upper-bound marker\n        // (fetch + compile overlap inside the call), consistent with the LLM/embeddings batteries.\n        emitLifecycle(opts, 'transformers_js_stt', opts.model, 'compiling', {\n          detail: 'compiling automatic-speech-recognition graph',\n        })\n        const pipe = await createPipeline({\n          model: opts.model,\n          device: opts.device,\n          dtype: opts.dtype,\n          onInitProgress: forwardedInitProgress,\n        })\n        this.#pipeline = pipe\n        emitLifecycle(opts, 'transformers_js_stt', opts.model, 'ready', {\n          detail: 'automatic-speech-recognition pipeline ready',\n        })\n        return pipe\n      } catch (err) {\n        this.#pipelinePromise = undefined\n        emitLifecycle(opts, 'transformers_js_stt', opts.model, 'error', { error: err })\n        throw new E_TRANSFORMERS_JS_STT_ENGINE_ERROR([\n          `could not load the transformers.js pipeline: ${isError(err) ? err.message : String(err)} — install the peer dependency (pnpm add @huggingface/transformers)`,\n        ])\n      }\n    })()\n    return this.#pipelinePromise\n  }\n\n  /**\n   * Normalizes any accepted audio input form to 16 kHz mono PCM, the shape the Whisper pipeline\n   * expects.\n   *\n   * @remarks\n   * Already-decoded {@link @nhtio/adk/batteries/specialists/_shared!SpecialistPcmInput} is resampled\n   * directly (a no-op when already 16 kHz — {@link resampleTo} returns the same reference in that\n   * case). Any encoded-container form is normalized to bytes via\n   * {@link @nhtio/adk/batteries/specialists/_shared!toBytes}, decoded via the injected/default\n   * {@link @nhtio/adk/batteries/specialists/_shared!DecodeAudioFn} (already mono per that seam's\n   * contract), then resampled.\n   *\n   * @param input - The audio input in any accepted form.\n   * @returns 16 kHz mono PCM samples.\n   */\n  async #toPcm16k(input: SpecialistAudioInput): Promise<Float32Array> {\n    if (isPcmInput(input)) {\n      return resampleTo(input.pcm, input.sampleRate, 16000)\n    }\n    const { bytes } = await toBytes(input)\n    const decode = this.#options.decodeAudio ?? defaultDecodeAudio\n    const decoded = await decode(bytes)\n    return resampleTo(decoded.pcm, decoded.sampleRate, 16000)\n  }\n\n  /**\n   * Transcribes an audio clip.\n   *\n   * @param input - The audio input, in any {@link @nhtio/adk/batteries/specialists/_shared!SpecialistAudioInput}\n   *   form (pre-decoded PCM or an encoded container).\n   * @param opts - Per-call transcription options (language / translate / timestamps).\n   * @returns The recognized text, plus per-segment timing when `opts.timestamps` was set.\n   * @throws {@link @nhtio/adk/batteries!E_TRANSFORMERS_JS_STT_ENGINE_ERROR} when the pipeline fails to\n   *   load or the transcription call fails.\n   */\n  async transcribe(\n    input: SpecialistAudioInput,\n    opts?: TranscribeOptions\n  ): Promise<TranscribeResult> {\n    const pcm = await this.#toPcm16k(input)\n    const pipe = await this.#resolvePipeline()\n    const chunkLengthS = this.#options.chunkLengthS ?? 30\n\n    emitLifecycle(this.#options, 'transformers_js_stt', this.#options.model, 'generating')\n\n    let output: AsrPipelineOutput\n    try {\n      const result = await (\n        pipe as unknown as (\n          audio: Float32Array,\n          options: Record<string, unknown>\n        ) => Promise<AsrPipelineOutput | AsrPipelineOutput[]>\n      )(pcm, {\n        chunk_length_s: chunkLengthS,\n        ...(opts?.language ? { language: opts.language } : {}),\n        ...(opts?.translate ? { task: 'translate' } : {}),\n        ...(opts?.timestamps ? { return_timestamps: true } : {}),\n      })\n      output = Array.isArray(result) ? result[0] : result\n    } catch (err) {\n      emitLifecycle(this.#options, 'transformers_js_stt', this.#options.model, 'error', {\n        error: err,\n      })\n      throw new E_TRANSFORMERS_JS_STT_ENGINE_ERROR([isError(err) ? err.message : String(err)])\n    }\n\n    if (!output || typeof output.text !== 'string') {\n      emitLifecycle(this.#options, 'transformers_js_stt', this.#options.model, 'error', {\n        error: new Error('automatic-speech-recognition returned a malformed result'),\n      })\n      throw new E_TRANSFORMERS_JS_STT_ENGINE_ERROR([\n        'automatic-speech-recognition returned a malformed result',\n      ])\n    }\n\n    let segments: SttSegment[] | undefined\n    if (opts?.timestamps && Array.isArray(output.chunks)) {\n      segments = output.chunks.map((chunk) => ({\n        start: chunk.timestamp[0],\n        end: chunk.timestamp[1] ?? null,\n        text: chunk.text,\n      }))\n    }\n\n    emitLifecycle(this.#options, 'transformers_js_stt', this.#options.model, 'complete')\n    return segments ? { text: output.text, segments } : { text: output.text }\n  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