mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:30:47 +00:00
refactor: share legacy config migration pipeline
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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 normalizeBaseCompatibilityConfigValues(
|
||||
cfg: OpenClawConfig,
|
||||
changes: string[],
|
||||
afterBrowser?: (config: OpenClawConfig) => OpenClawConfig,
|
||||
): OpenClawConfig {
|
||||
let next = seedMissingDefaultAccountsFromSingleAccountBase(cfg, changes);
|
||||
next = normalizeLegacyBrowserConfig(next, changes);
|
||||
next = afterBrowser ? afterBrowser(next) : next;
|
||||
|
||||
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);
|
||||
return normalizeLegacyMistralModelMaxTokens(next, changes);
|
||||
}
|
||||
@@ -1,53 +1,23 @@
|
||||
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
|
||||
import { runPluginSetupConfigMigrations } from "../../../plugins/setup-registry.js";
|
||||
import { applyChannelDoctorCompatibilityMigrations } from "./channel-legacy-config-migrate.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";
|
||||
import { normalizeBaseCompatibilityConfigValues } from "./legacy-config-compatibility-base.js";
|
||||
|
||||
export function normalizeCompatibilityConfigValues(cfg: OpenClawConfig): {
|
||||
config: OpenClawConfig;
|
||||
changes: string[];
|
||||
} {
|
||||
const changes: string[] = [];
|
||||
let next = seedMissingDefaultAccountsFromSingleAccountBase(cfg, changes);
|
||||
next = normalizeLegacyBrowserConfig(next, changes);
|
||||
|
||||
const setupMigration = runPluginSetupConfigMigrations({
|
||||
config: next,
|
||||
});
|
||||
if (setupMigration.changes.length > 0) {
|
||||
next = setupMigration.config;
|
||||
changes.push(...setupMigration.changes);
|
||||
}
|
||||
|
||||
for (const migrate of [
|
||||
migrateLegacyWebSearchConfig,
|
||||
migrateLegacyWebFetchConfig,
|
||||
migrateLegacyXSearchConfig,
|
||||
]) {
|
||||
const migrated = migrate(next);
|
||||
if (migrated.changes.length === 0) {
|
||||
continue;
|
||||
let next = normalizeBaseCompatibilityConfigValues(cfg, changes, (config) => {
|
||||
const setupMigration = runPluginSetupConfigMigrations({
|
||||
config,
|
||||
});
|
||||
if (setupMigration.changes.length === 0) {
|
||||
return config;
|
||||
}
|
||||
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);
|
||||
changes.push(...setupMigration.changes);
|
||||
return setupMigration.config;
|
||||
});
|
||||
const channelMigrations = applyChannelDoctorCompatibilityMigrations(next);
|
||||
if (channelMigrations.changes.length > 0) {
|
||||
next = channelMigrations.next;
|
||||
|
||||
@@ -1,43 +1,11 @@
|
||||
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";
|
||||
import { normalizeBaseCompatibilityConfigValues } from "./legacy-config-compatibility-base.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);
|
||||
|
||||
const next = normalizeBaseCompatibilityConfigValues(cfg, changes);
|
||||
return { config: next, changes };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user