Skip to content

Commit 10a92e2

Browse files
committed
perf(config): keep runtime compat migrations lightweight
1 parent 68e0e45 commit 10a92e2

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
2+
import {
3+
normalizeLegacyBrowserConfig,
4+
normalizeLegacyCrossContextMessageConfig,
5+
normalizeLegacyMediaProviderOptions,
6+
normalizeLegacyMistralModelMaxTokens,
7+
normalizeLegacyNanoBananaSkill,
8+
normalizeLegacyTalkConfig,
9+
seedMissingDefaultAccountsFromSingleAccountBase,
10+
} from "./legacy-config-core-normalizers.js";
11+
import { migrateLegacyWebFetchConfig } from "./legacy-web-fetch-migrate.js";
12+
import { migrateLegacyWebSearchConfig } from "./legacy-web-search-migrate.js";
13+
import { migrateLegacyXSearchConfig } from "./legacy-x-search-migrate.js";
14+
15+
export function normalizeRuntimeCompatibilityConfigValues(cfg: OpenClawConfig): {
16+
config: OpenClawConfig;
17+
changes: string[];
18+
} {
19+
const changes: string[] = [];
20+
let next = seedMissingDefaultAccountsFromSingleAccountBase(cfg, changes);
21+
next = normalizeLegacyBrowserConfig(next, changes);
22+
23+
for (const migrate of [
24+
migrateLegacyWebSearchConfig,
25+
migrateLegacyWebFetchConfig,
26+
migrateLegacyXSearchConfig,
27+
]) {
28+
const migrated = migrate(next);
29+
if (migrated.changes.length === 0) {
30+
continue;
31+
}
32+
next = migrated.config;
33+
changes.push(...migrated.changes);
34+
}
35+
36+
next = normalizeLegacyNanoBananaSkill(next, changes);
37+
next = normalizeLegacyTalkConfig(next, changes);
38+
next = normalizeLegacyCrossContextMessageConfig(next, changes);
39+
next = normalizeLegacyMediaProviderOptions(next, changes);
40+
next = normalizeLegacyMistralModelMaxTokens(next, changes);
41+
42+
return { config: next, changes };
43+
}

src/commands/doctor/shared/runtime-compat-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { isDeepStrictEqual } from "node:util";
22
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
33
import { applyLegacyDoctorMigrations } from "./legacy-config-compat.js";
4-
import { normalizeCompatibilityConfigValues } from "./legacy-config-core-migrate.js";
4+
import { normalizeRuntimeCompatibilityConfigValues } from "./legacy-config-runtime-migrate.js";
55

66
export function applyRuntimeLegacyConfigMigrations(raw: unknown): {
77
next: Record<string, unknown> | null;
@@ -14,7 +14,7 @@ export function applyRuntimeLegacyConfigMigrations(raw: unknown): {
1414
const original = raw as Record<string, unknown>;
1515
const migrated = applyLegacyDoctorMigrations(original);
1616
const base = (migrated.next ?? original) as OpenClawConfig;
17-
const normalized = normalizeCompatibilityConfigValues(base);
17+
const normalized = normalizeRuntimeCompatibilityConfigValues(base);
1818
const next = normalized.config as OpenClawConfig & Record<string, unknown>;
1919
const changes = [...migrated.changes, ...normalized.changes];
2020

0 commit comments

Comments
 (0)