|
1 | 1 | import { formatCliCommand } from "../cli/command-format.js"; |
2 | 2 | import type { |
| 3 | + AuthChoice, |
3 | 4 | GatewayAuthChoice, |
4 | 5 | OnboardMode, |
5 | 6 | OnboardOptions, |
@@ -484,25 +485,23 @@ export async function runSetupWizard( |
484 | 485 | let nextConfig: OpenClawConfig = applyLocalSetupWorkspaceConfig(baseConfig, workspaceDir); |
485 | 486 |
|
486 | 487 | const authChoiceFromPrompt = opts.authChoice === undefined; |
487 | | - const promptedAuthChoice = authChoiceFromPrompt |
488 | | - ? await (async () => { |
489 | | - const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js"); |
490 | | - const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js"); |
491 | | - const authStore = ensureAuthProfileStore(undefined, { |
492 | | - allowKeychainPrompt: false, |
493 | | - }); |
494 | | - return await promptAuthChoiceGrouped({ |
495 | | - prompter, |
496 | | - store: authStore, |
497 | | - includeSkip: true, |
498 | | - config: nextConfig, |
499 | | - workspaceDir, |
500 | | - }); |
501 | | - })() |
502 | | - : undefined; |
503 | | - const authChoice = opts.authChoice ?? promptedAuthChoice; |
504 | | - if (!authChoice) { |
505 | | - throw new Error("Failed to resolve auth choice."); |
| 488 | + let authChoice: AuthChoice | undefined = opts.authChoice; |
| 489 | + if (authChoiceFromPrompt) { |
| 490 | + const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js"); |
| 491 | + const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js"); |
| 492 | + const authStore = ensureAuthProfileStore(undefined, { |
| 493 | + allowKeychainPrompt: false, |
| 494 | + }); |
| 495 | + authChoice = await promptAuthChoiceGrouped({ |
| 496 | + prompter, |
| 497 | + store: authStore, |
| 498 | + includeSkip: true, |
| 499 | + config: nextConfig, |
| 500 | + workspaceDir, |
| 501 | + }); |
| 502 | + } |
| 503 | + if (authChoice === undefined) { |
| 504 | + throw new WizardCancelledError("auth choice is required"); |
506 | 505 | } |
507 | 506 |
|
508 | 507 | if (authChoice === "custom-api-key") { |
|
0 commit comments