refactor(onboard): reuse applyAgentDefaultModelPrimary

This commit is contained in:
Peter Steinberger
2026-02-15 18:34:55 +00:00
parent 8678b10aef
commit a5b87338e5
2 changed files with 16 additions and 218 deletions

View File

@@ -3,7 +3,10 @@ import {
buildCloudflareAiGatewayModelDefinition,
resolveCloudflareAiGatewayBaseUrl,
} from "../agents/cloudflare-ai-gateway.js";
import { applyProviderConfigWithDefaultModel } from "./onboard-auth.config-shared.js";
import {
applyAgentDefaultModelPrimary,
applyProviderConfigWithDefaultModel,
} from "./onboard-auth.config-shared.js";
import {
CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
@@ -76,24 +79,7 @@ export function applyCloudflareAiGatewayProviderConfig(
export function applyVercelAiGatewayConfig(cfg: OpenClawConfig): OpenClawConfig {
const next = applyVercelAiGatewayProviderConfig(cfg);
const existingModel = next.agents?.defaults?.model;
return {
...next,
agents: {
...next.agents,
defaults: {
...next.agents?.defaults,
model: {
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
? {
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
}
: undefined),
primary: VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
},
},
},
};
return applyAgentDefaultModelPrimary(next, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF);
}
export function applyCloudflareAiGatewayConfig(
@@ -101,22 +87,5 @@ export function applyCloudflareAiGatewayConfig(
params?: { accountId?: string; gatewayId?: string },
): OpenClawConfig {
const next = applyCloudflareAiGatewayProviderConfig(cfg, params);
const existingModel = next.agents?.defaults?.model;
return {
...next,
agents: {
...next.agents,
defaults: {
...next.agents?.defaults,
model: {
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
? {
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
}
: undefined),
primary: CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
},
},
},
};
return applyAgentDefaultModelPrimary(next, CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF);
}