{"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../../src/batteries/llm/transformers_js/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the transformers.js LLM adapter.\n *\n * @module @nhtio/adk/batteries/llm/transformers_js/exceptions\n *\n * @remarks\n * Battery-scoped exception classes for the transformers.js (`@huggingface/transformers`) LLM adapter,\n * minted via `createException` from `@nhtio/adk/factories` and re-exported from the battery barrel.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch\n * `stash.transformersJs`) fail validation against `transformersJsOptionsSchema`.\n */\nexport const E_INVALID_TRANSFORMERS_JS_OPTIONS = createException<[string]>(\n  'E_INVALID_TRANSFORMERS_JS_OPTIONS',\n  'Invalid transformers.js adapter options: %s',\n  'E_INVALID_TRANSFORMERS_JS_OPTIONS',\n  529,\n  true\n)\n\n/**\n * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised\n * when `tokenEncoding` is non-null.\n */\nexport const E_TRANSFORMERS_JS_CONTEXT_OVERFLOW = createException<[number, number, string, string]>(\n  'E_TRANSFORMERS_JS_CONTEXT_OVERFLOW',\n  'transformers.js request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s',\n  'E_TRANSFORMERS_JS_CONTEXT_OVERFLOW',\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 generation call errors. Non-fatal — surfaced via `ctx.nack(...)`.\n */\nexport const E_TRANSFORMERS_JS_STREAM_ERROR = createException<[string]>(\n  'E_TRANSFORMERS_JS_STREAM_ERROR',\n  'transformers.js generation error: %s',\n  'E_TRANSFORMERS_JS_STREAM_ERROR',\n  502,\n  false\n)\n\n/**\n * Raised when a tool call parsed out of model output carries malformed arguments (not a JSON object).\n *\n * @remarks\n * Non-fatal. The adapter does NOT throw it — it instantiates it inside `executeAndPersistToolCall`,\n * pulls `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` with\n * `isError: true` so the model can self-correct. Printf args: `[reasonHeadline, rawArgs]`.\n */\nexport const E_TRANSFORMERS_JS_INVALID_TOOL_CALL_ARGS = createException<[string, string]>(\n  'E_TRANSFORMERS_JS_INVALID_TOOL_CALL_ARGS',\n  'Tool arguments %s. Raw value: %s',\n  'E_TRANSFORMERS_JS_INVALID_TOOL_CALL_ARGS',\n  422,\n  false\n)\n\n/**\n * Raised when the model emitted text that looked like a tool call but no configured parser could\n * extract a well-formed call from it.\n *\n * @remarks\n * Non-fatal. The adapter persists a `ToolCall` with `isError: true` carrying this message so the\n * model self-corrects on the next iteration (e.g. switch the `toolCallParser` option to match the\n * model family, or supply a custom parser). Printf args: `[parserName, rawTextExcerpt]`.\n */\nexport const E_TRANSFORMERS_JS_TOOL_PARSE_FAILED = createException<[string, string]>(\n  'E_TRANSFORMERS_JS_TOOL_PARSE_FAILED',\n  'transformers.js: model output looked like a tool call but parser \"%s\" could not extract one. Output excerpt: %s. Configure the `toolCallParser` option to match the model family, or supply a custom parser function.',\n  'E_TRANSFORMERS_JS_TOOL_PARSE_FAILED',\n  422,\n  false\n)\n\n/**\n * Raised when a {@link @nhtio/adk!Media} instance whose modality the configured model cannot consume\n * reaches the adapter under `unsupportedMediaPolicy: 'throw'`.\n *\n * @remarks\n * Printf args: `[kind, mimeType, filename]`.\n */\nexport const E_UNSUPPORTED_MEDIA_MODALITY = createException<[string, string, string]>(\n  'E_UNSUPPORTED_MEDIA_MODALITY',\n  'transformers.js does not support media of kind %s (mime=%s, filename=%s) for the configured model. Configure adapter `unsupportedMediaPolicy` to `fallback-stash` or `synthetic-description` to handle this case.',\n  'E_UNSUPPORTED_MEDIA_MODALITY',\n  422,\n  true\n)\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,oCAAoC,gBAC/C,qCACA,+CACA,qCACA,KACA,IACF;;;;;AAMA,IAAa,qCAAqC,gBAChD,sCACA,qHACA,sCACA,KACA,IACF;;;;;AAMA,IAAa,iCAAiC,gBAC5C,kCACA,wCACA,kCACA,KACA,KACF;;;;;;;;;AAUA,IAAa,2CAA2C,gBACtD,4CACA,oCACA,4CACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,sCAAsC,gBACjD,uCACA,2NACA,uCACA,KACA,KACF;;;;;;;;AASA,IAAa,+BAA+B,gBAC1C,gCACA,qNACA,gCACA,KACA,IACF"}