{"version":3,"file":"openrouter-reasoning.d.ts","sourceRoot":"","sources":["../src/openrouter-reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIlE,MAAM,WAAW,+BAA+B;IAC/C,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,sFAAsF;IACtF,uBAAuB,EAAE,OAAO,CAAC;IACjC,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACnB;AAwBD,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,+BAA+B,GAAG,SAAS,CA+B9G","sourcesContent":["import type { ThinkingLevel, ThinkingLevelMap } from \"./types.js\";\n\nconst THINKING_LEVELS: readonly ThinkingLevel[] = [\"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport interface OpenRouterReasoningCapabilities {\n\t/** Exact local-to-provider effort map. null entries are unsupported. */\n\tthinkingLevelMap?: ThinkingLevelMap;\n\t/** Whether the model exposes effort selection, rather than only an enabled toggle. */\n\tsupportsReasoningEffort: boolean;\n\t/** Whether the model rejects attempts to disable reasoning. */\n\tmandatory: boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction enabledOnlyCapabilities(mandatory: boolean): OpenRouterReasoningCapabilities {\n\t// The model supports reasoning as an on/off capability, but does not expose\n\t// effort selection. Represent that as one generic active level in the UI.\n\treturn {\n\t\tthinkingLevelMap: {\n\t\t\t...(mandatory ? { off: null } : {}),\n\t\t\tminimal: null,\n\t\t\tlow: null,\n\t\t\tmedium: null,\n\t\t\thigh: \"high\",\n\t\t\txhigh: null,\n\t\t\tmax: null,\n\t\t},\n\t\tsupportsReasoningEffort: false,\n\t\tmandatory,\n\t};\n}\n\nexport function getOpenRouterReasoningCapabilities(model: unknown): OpenRouterReasoningCapabilities | undefined {\n\tif (!isRecord(model)) return undefined;\n\tconst supportedParameters = Array.isArray(model.supported_parameters) ? model.supported_parameters : [];\n\tif (!supportedParameters.includes(\"reasoning\") || !isRecord(model.reasoning)) return undefined;\n\n\tconst mandatory = model.reasoning.mandatory === true;\n\tconst rawEfforts = model.reasoning.supported_efforts;\n\tif (rawEfforts === null) {\n\t\tconst thinkingLevelMap: ThinkingLevelMap = {};\n\t\tif (mandatory) thinkingLevelMap.off = null;\n\t\tfor (const level of THINKING_LEVELS) thinkingLevelMap[level] = level;\n\t\treturn { thinkingLevelMap, supportsReasoningEffort: true, mandatory };\n\t}\n\n\tif (Array.isArray(rawEfforts) && rawEfforts.length > 0) {\n\t\tconst supportedEfforts = new Set(\n\t\t\trawEfforts.filter(\n\t\t\t\t(effort): effort is ThinkingLevel =>\n\t\t\t\t\ttypeof effort === \"string\" && THINKING_LEVELS.includes(effort as ThinkingLevel),\n\t\t\t),\n\t\t);\n\t\tif (supportedEfforts.size === 0) return enabledOnlyCapabilities(mandatory);\n\t\tconst thinkingLevelMap: ThinkingLevelMap = {};\n\t\tif (mandatory) thinkingLevelMap.off = null;\n\t\tfor (const level of THINKING_LEVELS) {\n\t\t\tthinkingLevelMap[level] = supportedEfforts.has(level) ? level : null;\n\t\t}\n\t\treturn { thinkingLevelMap, supportsReasoningEffort: true, mandatory };\n\t}\n\n\treturn enabledOnlyCapabilities(mandatory);\n}\n"]}