perf(config): keep runtime compat migrations lightweight

This commit is contained in:
Vincent Koc
2026-04-13 21:14:15 +01:00
parent 68e0e456f3
commit 10a92e2ff4
2 changed files with 45 additions and 2 deletions

View File

@@ -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 };
}

View File

@@ -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<string, unknown> | null;
@@ -14,7 +14,7 @@ export function applyRuntimeLegacyConfigMigrations(raw: unknown): {
const original = raw as Record<string, unknown>;
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<string, unknown>;
const changes = [...migrated.changes, ...normalized.changes];