{"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../../src/batteries/llm/litert_lm/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for LiteRT-LM adapter failures.\n *\n * @module @nhtio/adk/batteries/llm/litert_lm/exceptions\n *\n * @remarks\n * Battery-scoped exception classes for the LiteRT-LM adapter. These exceptions are owned by the\n * battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.\n * Re-exported from the battery's 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.liteRtLm`) fail validation against `liteRtLmOptionsSchema`.\n */\nexport const E_INVALID_LITERT_LM_OPTIONS = createException<[string]>(\n  'E_INVALID_LITERT_LM_OPTIONS',\n  'Invalid LiteRT-LM adapter options: %s',\n  'E_INVALID_LITERT_LM_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. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in\n * the message so middleware can target shedding.\n */\nexport const E_LITERT_LM_CONTEXT_OVERFLOW = createException<[number, number, string, string]>(\n  'E_LITERT_LM_CONTEXT_OVERFLOW',\n  'LiteRT-LM request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s',\n  'E_LITERT_LM_CONTEXT_OVERFLOW',\n  529,\n  true\n)\n\n/**\n * Thrown when the LiteRT-LM engine call or response stream fails. Non-fatal — surfaced via\n * `ctx.nack(...)`.\n */\nexport const E_LITERT_LM_STREAM_ERROR = createException<[string]>(\n  'E_LITERT_LM_STREAM_ERROR',\n  'LiteRT-LM stream error: %s',\n  'E_LITERT_LM_STREAM_ERROR',\n  502,\n  false\n)\n\n/**\n * Raised when a tool-call emitted by the model carries malformed `arguments`.\n *\n * @remarks\n * Unlike OpenAI-wire batteries (where tool-call `arguments` arrive as a JSON **string** that may\n * fail to parse), LiteRT-LM delivers `ToolCall.function.arguments` already as a parsed object\n * (`Record<string, JsonValue>`). This exception therefore guards the rarer case where that field is\n * present but is not a plain object (e.g. an array or a primitive slipped through the wire shape).\n *\n * Non-fatal. The adapter does NOT throw this — it instantiates it inside `executeAndPersistToolCall`,\n * pulls `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with\n * `isError: true` so the model can self-correct on the next iteration.\n *\n * Printf args: `[reasonHeadline, rawArgs]`.\n */\nexport const E_LITERT_LM_INVALID_TOOL_CALL_ARGS = createException<[string, string]>(\n  'E_LITERT_LM_INVALID_TOOL_CALL_ARGS',\n  'Tool arguments %s. Raw value: %s',\n  'E_LITERT_LM_INVALID_TOOL_CALL_ARGS',\n  422,\n  false\n)\n\n/**\n * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be represented for the\n * LiteRT-LM model reaches the adapter under `unsupportedMediaPolicy: 'throw'`.\n *\n * @remarks\n * The `@litert-lm/core` types expose `audioModalityEnabled` / `visionModalityEnabled`, but the\n * preview `.litertlm` models are text-in/text-out today. Media this adapter cannot map (or that the\n * configured model does not accept) triggers this under the `'throw'` policy; switch to\n * `'fallback-stash'` or `'synthetic-description'` to degrade to a text representation instead.\n *\n * Printf args: `[kind, mimeType, filename]`.\n */\nexport const E_UNSUPPORTED_MEDIA_MODALITY = createException<[string, string, string]>(\n  'E_UNSUPPORTED_MEDIA_MODALITY',\n  'LiteRT-LM 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":";;;;;;;;;;;;;;;;;AAiBA,IAAa,8BAA8B,gBACzC,+BACA,yCACA,+BACA,KACA,IACF;;;;;;AAOA,IAAa,+BAA+B,gBAC1C,gCACA,+GACA,gCACA,KACA,IACF;;;;;AAMA,IAAa,2BAA2B,gBACtC,4BACA,8BACA,4BACA,KACA,KACF;;;;;;;;;;;;;;;;AAiBA,IAAa,qCAAqC,gBAChD,sCACA,oCACA,sCACA,KACA,KACF;;;;;;;;;;;;;AAcA,IAAa,+BAA+B,gBAC1C,gCACA,+MACA,gCACA,KACA,IACF"}