

























@@ -1,11 +1,48 @@
11import { ensureAuthProfileStore, listProfilesForProvider } from "../agents/auth-profiles.js";
2+import { resolveAgentHarnessPolicy } from "../agents/harness/policy.js";
23import { hasUsableCustomProviderApiKey, resolveEnvApiKey } from "../agents/model-auth.js";
34import { loadModelCatalog } from "../agents/model-catalog.js";
45import { resolveDefaultModelForAgent } from "../agents/model-selection.js";
6+import { listOpenAIAuthProfileProvidersForAgentRuntime } from "../agents/openai-codex-routing.js";
57import type { OpenClawConfig } from "../config/types.openclaw.js";
68import type { WizardPrompter } from "../wizard/prompts.js";
79import { buildProviderAuthRecoveryHint } from "./provider-auth-guidance.js";
81011+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+25+function resolveAuthProviderCandidates(params: {
26+config: OpenClawConfig;
27+provider: string;
28+modelId: string;
29+agentId?: string;
30+}): string[] {
31+const harnessPolicy = resolveAgentHarnessPolicy({
32+provider: params.provider,
33+modelId: params.modelId,
34+config: params.config,
35+agentId: params.agentId,
36+});
37+return uniqueProviders([
38+params.provider,
39+ ...listOpenAIAuthProfileProvidersForAgentRuntime({
40+provider: params.provider,
41+harnessRuntime: harnessPolicy.runtime,
42+}),
43+]);
44+}
45+946export async function warnIfModelConfigLooksOff(
1047config: OpenClawConfig,
1148prompter: WizardPrompter,
@@ -34,9 +71,19 @@ export async function warnIfModelConfigLooksOff(
3471}
35723673const store = ensureAuthProfileStore(options?.agentDir);
37-const hasProfile = listProfilesForProvider(store, ref.provider).length > 0;
38-const envKey = resolveEnvApiKey(ref.provider);
39-const hasCustomKey = hasUsableCustomProviderApiKey(config, ref.provider);
74+const authProviders = resolveAuthProviderCandidates({
75+ config,
76+provider: ref.provider,
77+modelId: ref.model,
78+agentId: options?.agentId,
79+});
80+const hasProfile = authProviders.some(
81+(provider) => listProfilesForProvider(store, provider).length > 0,
82+);
83+const envKey = authProviders.some((provider) => resolveEnvApiKey(provider));
84+const hasCustomKey = authProviders.some((provider) =>
85+hasUsableCustomProviderApiKey(config, provider),
86+);
4087if (!hasProfile && !envKey && !hasCustomKey) {
4188warnings.push(
4289`No auth configured for provider "${ref.provider}". The agent may fail until credentials are added. ${buildProviderAuthRecoveryHint(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。