refactor: centralize model override validation

This commit is contained in:
Peter Steinberger committed 2026-01-09 20:14:42 +01:00
1 parent f0a909f6dd
commit 7e81980747
7 files changed
+204 -59

No files matched your search

+49
View File
@@ -8,6 +8,13 @@ import {
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
} from "../agents/agent-scope.js";
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
import { loadModelCatalog } from "../agents/model-catalog.js";
import {
getModelRefStatus,
resolveConfiguredModelRef,
resolveHooksGmailModel,
} from "../agents/model-selection.js";
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
import type { ClawdbotConfig } from "../config/config.js";
import {
@@ -201,6 +208,48 @@ export async function doctorCommand(
await noteSecurityWarnings(cfg);
if (cfg.hooks?.gmail?.model?.trim()) {
const hooksModelRef = resolveHooksGmailModel({
cfg,
defaultProvider: DEFAULT_PROVIDER,
});
if (!hooksModelRef) {
note(
`- hooks.gmail.model "${cfg.hooks.gmail.model}" could not be resolved`,
"Hooks",
);
} else {
const { provider: defaultProvider, model: defaultModel } =
resolveConfiguredModelRef({
cfg,
defaultProvider: DEFAULT_PROVIDER,
defaultModel: DEFAULT_MODEL,
});
const catalog = await loadModelCatalog({ config: cfg });
const status = getModelRefStatus({
cfg,
catalog,
ref: hooksModelRef,
defaultProvider,
defaultModel,
});
const warnings: string[] = [];
if (!status.allowed) {
warnings.push(
`- hooks.gmail.model "${status.key}" not in agents.defaults.models allowlist (will use primary instead)`,
);
}
if (!status.inCatalog) {
warnings.push(
`- hooks.gmail.model "${status.key}" not in the model catalog (may fail at runtime)`,
);
}
if (warnings.length > 0) {
note(warnings.join("\n"), "Hooks");
}
}
}
if (
options.nonInteractive !== true &&
process.platform === "linux" &&