refactor(commands): dedupe moonshot non-interactive auth
This commit is contained in:
@@ -453,7 +453,9 @@ export async function applyNonInteractiveAuthChoice(params: {
|
||||
});
|
||||
}
|
||||
|
||||
if (authChoice === "moonshot-api-key") {
|
||||
const applyMoonshotApiKeyChoice = async (
|
||||
applyConfig: (cfg: OpenClawConfig) => OpenClawConfig,
|
||||
): Promise<OpenClawConfig | null> => {
|
||||
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") {
|
||||
|
||||
Reference in New Issue
Block a user