UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

58 lines (57 loc) • 2.77 kB
import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs"; import { r as prepareAuthChoiceLoadedPluginProvider } from "./provider-auth-choice-Bs5LyXKi.mjs"; //#region src/commands/auth-choice.apply.ts /** Prepare a selected auth choice without writing its returned provider profiles. */ async function prepareAuthChoice(e) { let t = e.authChoice; if (t === "oauth") t = "setup-token"; else { const { resolveLegacyOnboardAuthChoice: n } = await import("./auth-choice-legacy-L1djL1_e.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-BL1WfjL-.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-CWdXW8t4.mjs"); const a = i(t, n) ?? (await import("./provider-install-catalog-Bx62GttL.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("\n")); 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 () => {} }; } /** Apply a selected auth choice, returning the mutated config or retry/model override signals. */ 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 } : {} }; } //#endregion export { prepareAuthChoice as n, applyAuthChoice as t };