* chore: apply local workspace updates * fix: resolve prep findings after rebase (#9898) (thanks @gumadeiras) * refactor: centralize model allowlist normalization (#9898) (thanks @gumadeiras) * fix: guard model allowlist initialization (#9911) * docs: update changelog scope for #9911 * docs: remove model names from changelog entry (#9911) * fix: satisfy type-aware lint in model allowlist (#9911)
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import type { OpenClawConfig } from "../config/config.js";
|
|
import type { WizardPrompter } from "../wizard/prompts.js";
|
|
import { ensureModelAllowlistEntry } from "./model-allowlist.js";
|
|
|
|
export async function applyDefaultModelChoice(params: {
|
|
config: OpenClawConfig;
|
|
setDefaultModel: boolean;
|
|
defaultModel: string;
|
|
applyDefaultConfig: (config: OpenClawConfig) => OpenClawConfig;
|
|
applyProviderConfig: (config: OpenClawConfig) => OpenClawConfig;
|
|
noteDefault?: string;
|
|
noteAgentModel: (model: string) => Promise<void>;
|
|
prompter: WizardPrompter;
|
|
}): Promise<{ config: OpenClawConfig; agentModelOverride?: string }> {
|
|
if (params.setDefaultModel) {
|
|
const next = params.applyDefaultConfig(params.config);
|
|
if (params.noteDefault) {
|
|
await params.prompter.note(`Default model set to ${params.noteDefault}`, "Model configured");
|
|
}
|
|
return { config: next };
|
|
}
|
|
|
|
const next = params.applyProviderConfig(params.config);
|
|
const nextWithModel = ensureModelAllowlistEntry({
|
|
cfg: next,
|
|
modelRef: params.defaultModel,
|
|
});
|
|
await params.noteAgentModel(params.defaultModel);
|
|
return { config: nextWithModel, agentModelOverride: params.defaultModel };
|
|
}
|