refactor(onboard): simplify model auth candidates

This commit is contained in:
Ayaan Zaidi
2026-05-12 16:46:28 +05:30
parent 9600646449
commit a6faeecf52
2 changed files with 13 additions and 27 deletions

View File

@@ -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",

View File

@@ -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<string>();
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(