{"version":3,"file":"exceptions.cjs","names":[],"sources":["../../../src/batteries/context/exceptions.ts"],"sourcesContent":["/**\n * Shared exception for the context-management batteries — the one failure class `thrift` and\n * `compact` have in common.\n *\n * @module @nhtio/adk/batteries/context/exceptions\n *\n * @remarks\n * Both `thrift` (`subtractToFit`) and `compact` (`summariseTurns`, `assembleCompactedTurns`) require\n * a caller-injected resolver (`estimateTokens`, and for `compact` also `summarize`) because neither\n * battery bundles a tokenizer or a model transport of its own — see each battery's `contracts.ts` for\n * the \"surface, don't impose\" rationale. A missing resolver is the SAME failure shape in both\n * batteries (a required injected function wasn't supplied), so it is minted ONCE here rather than\n * duplicated per-battery. This module lives at the `context` domain level (a sibling of `thrift/` and\n * `compact/`, not inside either) specifically so both can import it without either depending on the\n * other, and re-exports from `../index.ts` so a consumer of either battery's public barrel sees it\n * without a deep import. Minted via `createException` from `@nhtio/adk/factories`, matching every\n * other battery's exception convention.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when a context-management battery function is called without a REQUIRED injected resolver\n * (`estimateTokens`, or — for Compact's `summarize` seam — the model-call function).\n *\n * @remarks\n * Both `@nhtio/adk/batteries/context/thrift` and `@nhtio/adk/batteries/context/compact` ship with no\n * bundled tokenizer and (for Compact) no bundled model transport — every capability they cannot\n * perform themselves is an INJECTED function the caller must supply. Omitting one is a caller\n * programming error (a wiring mistake, not a runtime condition to recover from): rather than let the\n * omission surface later as a confusing `undefined is not a function` deep inside the algorithm, every\n * entry point checks eagerly and throws this, naming both the missing option and the function that\n * needed it, so the fix is obvious at the call site. Fatal — construct the missing resolver and retry;\n * there is no degrade-and-continue path, because a battery with no way to measure tokens (or, for\n * Compact, no way to call a model) cannot make progress at all.\n *\n * Printf args: `[functionName, missingOption]` — e.g. `['subtractToFit', 'estimateTokens']` or\n * `['summariseTurns', 'summarize']`.\n *\n * @example\n * ```ts\n * import { isInstanceOf } from '@nhtio/adk'\n *\n * try {\n *   subtractToFit(ws, contextWindow, relevantToolNames, {} as never)\n * } catch (err) {\n *   if (isInstanceOf(err, 'E_CONTEXT_RESOLVER_MISSING')) {\n *     // err.message: \"subtractToFit: options.estimateTokens is required — this context-management\n *     // battery ships with no bundled tokenizer/model transport of its own.\"\n *   }\n * }\n * ```\n */\nexport const E_CONTEXT_RESOLVER_MISSING = createException<[string, string]>(\n  'E_CONTEXT_RESOLVER_MISSING',\n  '%s: options.%s is required — this context-management battery ships with no bundled tokenizer/model transport of its own.',\n  'E_CONTEXT_RESOLVER_MISSING',\n  422,\n  true\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,IAAa,6BAA6B,mBAAA,gBACxC,8BACA,4HACA,8BACA,KACA,IACF"}