Skip to content

Commit b388869

Browse files
committed
refactor(onboard): simplify model auth candidates
1 parent f8bb6eb commit b388869

2 files changed

Lines changed: 13 additions & 27 deletions

File tree

src/commands/auth-choice.model-check.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ describe("warnIfModelConfigLooksOff", () => {
4747
expect(loadModelCatalog).not.toHaveBeenCalled();
4848
expect(ensureAuthProfileStore).toHaveBeenCalledOnce();
4949
expect(listProfilesForProvider).toHaveBeenCalledOnce();
50-
const [profileStore, providerId] = listProfilesForProvider.mock.calls.at(0) as unknown as [
51-
AuthProfileStore,
52-
string,
53-
];
54-
expect(profileStore?.profiles).toEqual({});
55-
expect(providerId).toBe("openai-codex");
50+
expect(listProfilesForProvider).toHaveBeenCalledWith(
51+
{ version: 1, profiles: {} },
52+
"openai-codex",
53+
);
5654
expect(note).toHaveBeenCalledWith(
5755
'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.',
5856
"Model check",

src/commands/auth-choice.model-check.ts

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
88
import type { WizardPrompter } from "../wizard/prompts.js";
99
import { buildProviderAuthRecoveryHint } from "./provider-auth-guidance.js";
1010

11-
function uniqueProviders(providers: readonly string[]): string[] {
12-
const seen = new Set<string>();
13-
const result: string[] = [];
14-
for (const provider of providers) {
15-
const trimmed = provider.trim();
16-
if (!trimmed || seen.has(trimmed)) {
17-
continue;
18-
}
19-
seen.add(trimmed);
20-
result.push(trimmed);
21-
}
22-
return result;
23-
}
24-
2511
function resolveAuthProviderCandidates(params: {
2612
config: OpenClawConfig;
2713
provider: string;
@@ -34,13 +20,15 @@ function resolveAuthProviderCandidates(params: {
3420
config: params.config,
3521
agentId: params.agentId,
3622
});
37-
return uniqueProviders([
38-
params.provider,
39-
...listOpenAIAuthProfileProvidersForAgentRuntime({
40-
provider: params.provider,
41-
harnessRuntime: harnessPolicy.runtime,
42-
}),
43-
]);
23+
return [
24+
...new Set([
25+
params.provider,
26+
...listOpenAIAuthProfileProvidersForAgentRuntime({
27+
provider: params.provider,
28+
harnessRuntime: harnessPolicy.runtime,
29+
}),
30+
]),
31+
];
4432
}
4533

4634
export async function warnIfModelConfigLooksOff(

0 commit comments

Comments
 (0)