openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.75 kB
JavaScript
import{l as normalizeOptionalString}from"../../string-coerce-CpTFcSwY.mjs";import{a as asOptionalRecord}from"../../record-coerce-BTbqdJ3-.mjs";import"../../string-coerce-runtime-BYDH9Quw.mjs";import{v as buildOpenAICompatibleLiveModels}from"../../provider-catalog-live-runtime-BcG4uFWd.mjs";import{t as modelCatalog}from"../../openclaw.plugin-CjLtjBLN.mjs";
//!extensions/anthropic/live-model-projection.ts
function readSupported(e,t){let n=e;for(const e of t)n=asOptionalRecord(n)?.[e];if(n===null)return false;const r=asOptionalRecord(n)?.supported;return typeof r===`boolean`?r:void 0}function readClaudeListedCapabilities(e){const t=readSupported(e,[`thinking`,`types`,`adaptive`]);const n=readSupported(e,[`effort`,`xhigh`]);const r=readSupported(e,[`effort`,`max`]);if(t===void 0||n===void 0||r===void 0)return;const i=readSupported(e,[`thinking`,`types`,`disabled`]);const a=readSupported(e,[`context_management`,`compact_20260112`]);return{adaptiveThinking:t,xhighEffort:n,maxEffort:r,...i===void 0?{}:{disabledThinking:i},...a===void 0?{}:{serverCompaction:a}}}const projectAnthropicLiveModels=(e,t)=>{const n=/* @__PURE__ */ new Map;const r=e.map(e=>{const t=asOptionalRecord(e);const r=normalizeOptionalString(t?.id);const i=readClaudeListedCapabilities(t?.capabilities);if(r&&i){n.set(r,i);return{...t,capabilities:{chat:true,...asOptionalRecord(t?.capabilities)}}}return e});const i=buildOpenAICompatibleLiveModels(r,t,({id:e})=>n.has(e));for(const[e,t]of i.entries()){const r=n.get(t.id);if(r)i[e]={...t,family:modelCatalog.providers.anthropic.family,thinkingLevelMap:{...t.thinkingLevelMap,xhigh:r.xhighEffort?`xhigh`:null,max:r.maxEffort?`max`:null},params:{...t.params,claudeCapabilities:r}}}return i};export{projectAnthropicLiveModels};