mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 20:24:46 +00:00
refactor(onboard): simplify model auth candidates
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user