























@@ -0,0 +1,75 @@
1+import {
2+defineLegacyConfigMigration,
3+getRecord,
4+type LegacyConfigMigrationSpec,
5+type LegacyConfigRule,
6+} from "../../../config/legacy.shared.js";
7+import { isModelThinkingFormat } from "../../../config/types.models.js";
8+9+function hasInvalidThinkingFormat(providers: unknown): boolean {
10+const providersRecord = getRecord(providers);
11+if (!providersRecord) {
12+return false;
13+}
14+15+for (const provider of Object.values(providersRecord)) {
16+const models = getRecord(provider)?.models;
17+if (!Array.isArray(models)) {
18+continue;
19+}
20+21+for (const model of models) {
22+const compat = getRecord(getRecord(model)?.compat);
23+const thinkingFormat = compat?.thinkingFormat;
24+if (typeof thinkingFormat === "string" && !isModelThinkingFormat(thinkingFormat)) {
25+return true;
26+}
27+}
28+}
29+30+return false;
31+}
32+33+const INVALID_THINKING_FORMAT_RULE: LegacyConfigRule = {
34+path: ["models", "providers"],
35+message:
36+'models.providers.<id>.models[*].compat.thinkingFormat has an unrecognized value; run "openclaw doctor --fix" to remove it and restore the runtime default.',
37+match: (value) => hasInvalidThinkingFormat(value),
38+};
39+40+export const LEGACY_CONFIG_MIGRATIONS_RUNTIME_MODELS: LegacyConfigMigrationSpec[] = [
41+defineLegacyConfigMigration({
42+id: "models.providers.*.models.*.compat.thinkingFormat-invalid",
43+describe: "Remove unrecognized compat.thinkingFormat values from provider model entries",
44+legacyRules: [INVALID_THINKING_FORMAT_RULE],
45+apply: (raw, changes) => {
46+const providers = getRecord(getRecord(raw.models)?.providers);
47+if (!providers) {
48+return;
49+}
50+51+for (const [providerId, provider] of Object.entries(providers)) {
52+const models = getRecord(provider)?.models;
53+if (!Array.isArray(models)) {
54+continue;
55+}
56+57+for (const [index, model] of models.entries()) {
58+const compat = getRecord(getRecord(model)?.compat);
59+if (!compat) {
60+continue;
61+}
62+const thinkingFormat = compat.thinkingFormat;
63+if (typeof thinkingFormat !== "string" || isModelThinkingFormat(thinkingFormat)) {
64+continue;
65+}
66+67+delete compat.thinkingFormat;
68+changes.push(
69+`Removed models.providers.${providerId}.models.${index}.compat.thinkingFormat (unrecognized value ${JSON.stringify(thinkingFormat)}; runtime default applies).`,
70+);
71+}
72+}
73+},
74+}),
75+];
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。