UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

45 lines • 1.94 kB
"use strict"; /** * thinkingModeFor — the thinking mode a provider DECLARES for one model. * * Pattern: capability declaration (the `thinkingHandlerFor` / * `cacheStrategyFor` twin). The adapter knows which thinking request * each model on its wire takes and declares it * (`LLMProvider.thinkingMode`); a wrapper forwards the field. Never * derived from `provider.name`. * Role: the ONE place the agent reads that declaration, so a malformed one * is refused at build, by provider name, instead of meaning "no claim". */ Object.defineProperty(exports, "__esModule", { value: true }); exports.thinkingModeFor = void 0; const MODES = new Set(['adaptive', 'budget', 'none']); /** * The mode `provider` declares for `model`, or `undefined` when it declares * none (it makes no per-model claim; requests carry `thinking: { budget }` * and the adapter decides). * * @throws TypeError when the declaration is not a function, or answers * something other than `'adaptive'`, `'budget'` or `'none'`. * * @example * ```ts * thinkingModeFor(withRetry(anthropic()), 'claude-opus-5-5'); // 'adaptive' * ``` */ function thinkingModeFor(provider, model) { const declared = provider.thinkingMode; if (declared === undefined) return undefined; if (typeof declared !== 'function') { throw new TypeError(`the '${provider.name}' provider declares a thinkingMode that is not a function of the ` + `model id. Declare (model) => 'adaptive' | 'budget' | 'none', or leave it out.`); } const mode = declared(model); if (!MODES.has(mode)) { throw new TypeError(`the '${provider.name}' provider's thinkingMode('${model}') answered ` + `${JSON.stringify(mode)}; a ThinkingMode is 'adaptive', 'budget' or 'none'.`); } return mode; } exports.thinkingModeFor = thinkingModeFor; //# sourceMappingURL=thinkingModeFor.js.map