diff --git a/src/commands/onboard-non-interactive/local/auth-choice.ts b/src/commands/onboard-non-interactive/local/auth-choice.ts index 9ba6bfd64..23a5d370d 100644 --- a/src/commands/onboard-non-interactive/local/auth-choice.ts +++ b/src/commands/onboard-non-interactive/local/auth-choice.ts @@ -453,7 +453,9 @@ export async function applyNonInteractiveAuthChoice(params: { }); } - if (authChoice === "moonshot-api-key") { + const applyMoonshotApiKeyChoice = async ( + applyConfig: (cfg: OpenClawConfig) => OpenClawConfig, + ): Promise => { const resolved = await resolveNonInteractiveApiKey({ provider: "moonshot", cfg: baseConfig, @@ -473,30 +475,15 @@ export async function applyNonInteractiveAuthChoice(params: { provider: "moonshot", mode: "api_key", }); - return applyMoonshotConfig(nextConfig); + return applyConfig(nextConfig); + }; + + if (authChoice === "moonshot-api-key") { + return await applyMoonshotApiKeyChoice(applyMoonshotConfig); } if (authChoice === "moonshot-api-key-cn") { - const resolved = await resolveNonInteractiveApiKey({ - provider: "moonshot", - cfg: baseConfig, - flagValue: opts.moonshotApiKey, - flagName: "--moonshot-api-key", - envVar: "MOONSHOT_API_KEY", - runtime, - }); - if (!resolved) { - return null; - } - if (resolved.source !== "profile") { - await setMoonshotApiKey(resolved.key); - } - nextConfig = applyAuthProfileConfig(nextConfig, { - profileId: "moonshot:default", - provider: "moonshot", - mode: "api_key", - }); - return applyMoonshotConfigCn(nextConfig); + return await applyMoonshotApiKeyChoice(applyMoonshotConfigCn); } if (authChoice === "kimi-code-api-key") {