diff --git a/src/commands/doctor/shared/legacy-config-runtime-migrate.ts b/src/commands/doctor/shared/legacy-config-runtime-migrate.ts new file mode 100644 index 00000000000..f1b2ecdafb0 --- /dev/null +++ b/src/commands/doctor/shared/legacy-config-runtime-migrate.ts @@ -0,0 +1,43 @@ +import type { OpenClawConfig } from "../../../config/types.openclaw.js"; +import { + normalizeLegacyBrowserConfig, + normalizeLegacyCrossContextMessageConfig, + normalizeLegacyMediaProviderOptions, + normalizeLegacyMistralModelMaxTokens, + normalizeLegacyNanoBananaSkill, + normalizeLegacyTalkConfig, + seedMissingDefaultAccountsFromSingleAccountBase, +} from "./legacy-config-core-normalizers.js"; +import { migrateLegacyWebFetchConfig } from "./legacy-web-fetch-migrate.js"; +import { migrateLegacyWebSearchConfig } from "./legacy-web-search-migrate.js"; +import { migrateLegacyXSearchConfig } from "./legacy-x-search-migrate.js"; + +export function normalizeRuntimeCompatibilityConfigValues(cfg: OpenClawConfig): { + config: OpenClawConfig; + changes: string[]; +} { + const changes: string[] = []; + let next = seedMissingDefaultAccountsFromSingleAccountBase(cfg, changes); + next = normalizeLegacyBrowserConfig(next, changes); + + for (const migrate of [ + migrateLegacyWebSearchConfig, + migrateLegacyWebFetchConfig, + migrateLegacyXSearchConfig, + ]) { + const migrated = migrate(next); + if (migrated.changes.length === 0) { + continue; + } + next = migrated.config; + changes.push(...migrated.changes); + } + + next = normalizeLegacyNanoBananaSkill(next, changes); + next = normalizeLegacyTalkConfig(next, changes); + next = normalizeLegacyCrossContextMessageConfig(next, changes); + next = normalizeLegacyMediaProviderOptions(next, changes); + next = normalizeLegacyMistralModelMaxTokens(next, changes); + + return { config: next, changes }; +} diff --git a/src/commands/doctor/shared/runtime-compat-api.ts b/src/commands/doctor/shared/runtime-compat-api.ts index bccdd2a9eca..3860125bf88 100644 --- a/src/commands/doctor/shared/runtime-compat-api.ts +++ b/src/commands/doctor/shared/runtime-compat-api.ts @@ -1,7 +1,7 @@ import { isDeepStrictEqual } from "node:util"; import type { OpenClawConfig } from "../../../config/types.openclaw.js"; import { applyLegacyDoctorMigrations } from "./legacy-config-compat.js"; -import { normalizeCompatibilityConfigValues } from "./legacy-config-core-migrate.js"; +import { normalizeRuntimeCompatibilityConfigValues } from "./legacy-config-runtime-migrate.js"; export function applyRuntimeLegacyConfigMigrations(raw: unknown): { next: Record | null; @@ -14,7 +14,7 @@ export function applyRuntimeLegacyConfigMigrations(raw: unknown): { const original = raw as Record; const migrated = applyLegacyDoctorMigrations(original); const base = (migrated.next ?? original) as OpenClawConfig; - const normalized = normalizeCompatibilityConfigValues(base); + const normalized = normalizeRuntimeCompatibilityConfigValues(base); const next = normalized.config as OpenClawConfig & Record; const changes = [...migrated.changes, ...normalized.changes];