UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

53 lines (52 loc) • 2.36 kB
import { o as normalizeLowercaseStringOrEmpty } from "../../string-coerce-CCIiB4H7.mjs"; import { l as isRecord } from "../../record-coerce-CVPuDqcc.mjs"; import "../../string-coerce-runtime-BwAZZDf5.mjs"; import { c as CLAUDE_CLI_PROFILE_ID, t as CLAUDE_CLI_BACKEND_ID } from "../../cli-constants-CDevEMvo.mjs"; import { n as normalizeAnthropicProviderId, r as parseAnthropicModelRef } from "../../claude-model-refs-CU8jKXtL.mjs"; //#region extensions/anthropic/doctor-contract-api.ts const CLAUDE_CLI_WILDCARD_REF = "anthropic/*"; function hasAnthropicCredential(e) { if (Object.values(e.auth?.profiles ?? {}).some((e) => normalizeAnthropicProviderId(e.provider) === "anthropic")) return true; return ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"].some((t) => { const n = process.env[t] || e.env?.vars?.[t] || e.env?.[t]; return typeof n === "string" && n.trim() !== ""; }); } function normalizeCompatibilityConfig({ cfg: e }) { const t = e.agents?.defaults?.models ?? {}; if (Object.keys(t).some((e) => { const t = parseAnthropicModelRef(e); return t?.explicitProvider && t.provider === "anthropic" && t.model === "*"; })) return { config: e, changes: [] }; const n = e.agents?.defaults?.model; const r = typeof n === "string" ? n : n?.primary; const i = r ? parseAnthropicModelRef(r) : null; const a = r ? t[r] : void 0; const o = isRecord(a?.agentRuntime) ? a.agentRuntime.id : void 0; const s = Object.entries(e.models?.providers ?? {}).filter(([e]) => normalizeAnthropicProviderId(e) === "anthropic"); if (!i?.explicitProvider || i.provider !== "anthropic" || normalizeLowercaseStringOrEmpty(o) !== "claude-cli" || s.some(([, e]) => e.agentRuntime !== void 0 || e.apiKey !== void 0 && e.apiKey !== "anthropic:claude-cli") || hasAnthropicCredential(e)) return { config: e, changes: [] }; return { config: { ...e, agents: { ...e.agents, defaults: { ...e.agents?.defaults, models: { ...t, [CLAUDE_CLI_WILDCARD_REF]: { agentRuntime: { id: CLAUDE_CLI_BACKEND_ID } } } } } }, changes: [`agents.defaults.models["${CLAUDE_CLI_WILDCARD_REF}"]: added the ${CLAUDE_CLI_BACKEND_ID} runtime so Claude models not seeded at Claude CLI sign-in run through Claude Code instead of failing without an Anthropic API key.`] }; } //#endregion export { normalizeCompatibilityConfig };