UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

70 lines (69 loc) • 2.65 kB
import { r as normalizeProviderId } from "./provider-id-b5XGSf9C.mjs"; import "./user-model-account-authority-CRj924IP.mjs"; import { t as CLAUDE_CLI_PROFILE_ID } from "./profile-ids-B9fFWPvP.mjs"; import { i as resolveProviderIdForAuth } from "./provider-auth-aliases-CgGlzANu.mjs"; import { m as resolveExplicitAuthOrderSelection } from "./order-jOvee2J6.mjs"; import { c as resolveCliRuntimeExecutionProvider } from "./model-runtime-aliases-DZy9Ea2c.mjs"; //#region src/agents/auth-profiles/external-cli-auth-selection.ts const CLAUDE_CLI_PROVIDER_ID = "claude-cli"; function resolveExternalCliAuthOverlayScopeFromSelection(e) { const t = e.provider; const n = e.cfg; const r = e.workspaceDir; const i = e.store; const a = e.userPinnedAuthProfileId; const o = []; const s = resolveProviderIdForAuth(t, { config: n, workspaceDir: r }); const c = resolveExplicitAuthOrderSelection({ storeOrder: i?.order, configuredOrder: n?.auth?.order, providerKey: t, providerAuthKey: s }).order ?? []; const l = [...new Set(c.map((e) => e?.trim()).filter((e) => Boolean(e)))]; const u = [.../* @__PURE__ */ new Set([...Object.keys(n?.auth?.profiles ?? {}), ...Object.keys(i?.profiles ?? {})])]; const d = l.length > 0 ? l : u; const f = a ? [a, ...d.filter((e) => e !== a)] : d; let p; let m = 0; for (const e of f) { const a = n?.auth?.profiles?.[e]; const s = i?.profiles?.[e]; const c = a?.provider ?? s?.provider ?? (e === "anthropic:claude-cli" ? CLAUDE_CLI_PROVIDER_ID : void 0); if (!c) continue; const l = { config: n, workspaceDir: r }; const u = resolveProviderIdForAuth(t, l); const d = resolveProviderIdForAuth(c, { ...l, storedCredential: true }); if (!u || d !== u) continue; const f = normalizeProviderId(c) === CLAUDE_CLI_PROVIDER_ID ? CLAUDE_CLI_PROVIDER_ID : void 0; m += 1; if (m === 1) p = f; if (f) o.push(f); } const h = [...new Set(o)]; if (!a && l.length === 0) p = m === 1 ? h[0] : void 0; const g = resolveCliRuntimeExecutionProvider({ provider: e.provider, cfg: e.cfg, agentId: e.agentId, modelId: e.modelId, authProfileId: e.userPinnedAuthProfileId }) || (e.provider === CLAUDE_CLI_PROVIDER_ID ? CLAUDE_CLI_PROVIDER_ID : void 0); const _ = p ?? (g === CLAUDE_CLI_PROVIDER_ID ? CLAUDE_CLI_PROVIDER_ID : void 0); const v = [.../* @__PURE__ */ new Set([...h, ...g === CLAUDE_CLI_PROVIDER_ID ? [CLAUDE_CLI_PROVIDER_ID] : []])]; return { ...v.length > 0 ? { providerIds: v } : {}, ignoreAutoPreferredProfile: !e.userPinnedAuthProfileId && _ === CLAUDE_CLI_PROVIDER_ID }; } //#endregion export { resolveExternalCliAuthOverlayScopeFromSelection as t };