openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.26 kB
JavaScript
import{r as normalizeProviderId}from"./provider-id-A-8WTtLA.mjs";import"./user-model-account-authority-B8H7rvCb.mjs";import{t as CLAUDE_CLI_PROFILE_ID}from"./profile-ids-CZ5PgZfr.mjs";import{i as resolveProviderIdForAuth}from"./provider-auth-aliases-BRA1A5Vm.mjs";import{m as resolveExplicitAuthOrderSelection}from"./order-B8e_5ABM.mjs";import{c as resolveCliRuntimeExecutionProvider}from"./model-runtime-aliases-BFQ__k4Y.mjs";
//!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}}export{resolveExternalCliAuthOverlayScopeFromSelection as t};