openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
62 lines (61 loc) • 1.76 kB
JavaScript
import { l as normalizeOptionalString } from "../../string-coerce-CCIiB4H7.mjs";
import { a as asOptionalRecord } from "../../record-coerce-CVPuDqcc.mjs";
import "../../string-coerce-runtime-BwAZZDf5.mjs";
import { v as buildOpenAICompatibleLiveModels } from "../../provider-catalog-live-runtime-D-M7f_ww.mjs";
//#region 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"
]);
return {
adaptiveThinking: t,
xhighEffort: n,
maxEffort: r,
...i === void 0 ? {} : { disabledThinking: i }
};
}
const projectAnthropicLiveModels = (e, t) => {
const n = /* @__PURE__ */ new Map();
for (const t of e) {
const e = asOptionalRecord(t);
const r = normalizeOptionalString(e?.id);
const i = readClaudeListedCapabilities(e?.capabilities);
if (r && i) n.set(r, i);
}
const r = buildOpenAICompatibleLiveModels(e, t, ({ id: e }) => n.has(e));
for (const [e, t] of r.entries()) {
const i = n.get(t.id);
if (i) r[e] = {
...t,
thinkingLevelMap: {
...t.thinkingLevelMap,
xhigh: i.xhighEffort ? "xhigh" : null,
max: i.maxEffort ? "max" : null
},
params: {
...t.params,
claudeCapabilities: i
}
};
}
return r;
};
//#endregion
export { projectAnthropicLiveModels };