From a6faeecf52d8664fd55a8c0a4ae5c8f7d0de9e4c Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Tue, 12 May 2026 16:46:28 +0530 Subject: [PATCH] refactor(onboard): simplify model auth candidates --- src/commands/auth-choice.model-check.test.ts | 10 +++---- src/commands/auth-choice.model-check.ts | 30 ++++++-------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/commands/auth-choice.model-check.test.ts b/src/commands/auth-choice.model-check.test.ts index 58d20fcb55e..95ecfa9e971 100644 --- a/src/commands/auth-choice.model-check.test.ts +++ b/src/commands/auth-choice.model-check.test.ts @@ -47,12 +47,10 @@ describe("warnIfModelConfigLooksOff", () => { expect(loadModelCatalog).not.toHaveBeenCalled(); expect(ensureAuthProfileStore).toHaveBeenCalledOnce(); expect(listProfilesForProvider).toHaveBeenCalledOnce(); - const [profileStore, providerId] = listProfilesForProvider.mock.calls.at(0) as unknown as [ - AuthProfileStore, - string, - ]; - expect(profileStore?.profiles).toEqual({}); - expect(providerId).toBe("openai-codex"); + expect(listProfilesForProvider).toHaveBeenCalledWith( + { version: 1, profiles: {} }, + "openai-codex", + ); expect(note).toHaveBeenCalledWith( 'No auth configured for provider "openai-codex". The agent may fail until credentials are added. Run `openclaw models auth login --provider openai-codex`, `openclaw configure`, or set an API key env var.', "Model check", diff --git a/src/commands/auth-choice.model-check.ts b/src/commands/auth-choice.model-check.ts index 5b4178e8dd2..4a7cba26d41 100644 --- a/src/commands/auth-choice.model-check.ts +++ b/src/commands/auth-choice.model-check.ts @@ -8,20 +8,6 @@ import type { OpenClawConfig } from "../config/types.openclaw.js"; import type { WizardPrompter } from "../wizard/prompts.js"; import { buildProviderAuthRecoveryHint } from "./provider-auth-guidance.js"; -function uniqueProviders(providers: readonly string[]): string[] { - const seen = new Set(); - const result: string[] = []; - for (const provider of providers) { - const trimmed = provider.trim(); - if (!trimmed || seen.has(trimmed)) { - continue; - } - seen.add(trimmed); - result.push(trimmed); - } - return result; -} - function resolveAuthProviderCandidates(params: { config: OpenClawConfig; provider: string; @@ -34,13 +20,15 @@ function resolveAuthProviderCandidates(params: { config: params.config, agentId: params.agentId, }); - return uniqueProviders([ - params.provider, - ...listOpenAIAuthProfileProvidersForAgentRuntime({ - provider: params.provider, - harnessRuntime: harnessPolicy.runtime, - }), - ]); + return [ + ...new Set([ + params.provider, + ...listOpenAIAuthProfileProvidersForAgentRuntime({ + provider: params.provider, + harnessRuntime: harnessPolicy.runtime, + }), + ]), + ]; } export async function warnIfModelConfigLooksOff(