mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:00:42 +00:00
perf(config): keep runtime compat migrations lightweight
This commit is contained in:
43
src/commands/doctor/shared/legacy-config-runtime-migrate.ts
Normal file
43
src/commands/doctor/shared/legacy-config-runtime-migrate.ts
Normal 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 };
|
||||
}
|
||||
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user