UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

4 lines • 2.29 kB
import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{r as prepareAuthChoiceLoadedPluginProvider}from"./provider-auth-choice-CTnmwi8x.mjs"; //!src/commands/auth-choice.apply.ts async function prepareAuthChoice(e){let t=e.authChoice;if(t===`oauth`)t=`setup-token`;else{const{resolveLegacyOnboardAuthChoice:n}=await import(`./auth-choice-legacy-BYdD4VKO.mjs`);t=n(t,e).authChoice??t}if(e.opts?.tokenProvider&&(t===`apiKey`||t===`token`||t===`setup-token`)){const{normalizeApiKeyTokenProviderAuthChoice:n}=await import(`./auth-choice.apply.api-providers-DCo9Nkg7.mjs`);t=n({authChoice:t,tokenProvider:e.opts.tokenProvider,config:e.config,workspaceDir:e.workspaceDir,env:e.env})}const n=t===e.authChoice?e:{...e,authChoice:t};const r=await prepareAuthChoiceLoadedPluginProvider(n,e=>e);if(r)return r;const{resolveManifestDeprecatedProviderAuthChoice:i}=await import(`./provider-auth-choices-Bb9BO-yA.mjs`);const a=i(t,n)??(await import(`./provider-install-catalog-BaHixsL2.mjs`)).resolveDeprecatedProviderInstallCatalogEntry(t,{...n,includeUntrustedWorkspacePlugins:false});if(a)throw new Error(`Auth choice ${JSON.stringify(t)} is no longer supported. Use ${JSON.stringify(a.choiceId)} instead, or run ${formatCliCommand(`openclaw onboard`)} to choose interactively.`);if(n.authChoice===`token`||n.authChoice===`setup-token`)throw new Error([`Auth choice "${n.authChoice}" was not matched to a provider setup flow.`,`Run ${formatCliCommand(`openclaw models auth login --provider <provider>`)} for provider auth, or rerun ${formatCliCommand(`openclaw onboard`)} to choose interactively.`].join(` `));if(n.authChoice===`oauth`)throw new Error(`Auth choice "oauth" is no longer supported directly. Use a provider-specific auth entry, or run ${formatCliCommand(`openclaw models auth login --provider <provider>`)}.`);return{config:n.config,authProfiles:[],persistAuthProfiles:async()=>{}}}async function applyAuthChoice(e){const t=await prepareAuthChoice(e);await t.persistAuthProfiles();return{config:t.config,...t.utilityModelOverride?{utilityModelOverride:t.utilityModelOverride,modelTarget:t.modelTarget}:{},...t.agentModelOverride?{agentModelOverride:t.agentModelOverride}:{},...t.retrySelection?{retrySelection:true}:{}}}export{prepareAuthChoice as n,applyAuthChoice as t};