diff --git a/src/cli/channel-options.test.ts b/src/cli/channel-options.test.ts index 6e538402d31..bb7ca02835b 100644 --- a/src/cli/channel-options.test.ts +++ b/src/cli/channel-options.test.ts @@ -1,5 +1,6 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { __testing, resolveCliChannelOptions } from "./channel-options.js"; +import { __testing as startupMetadataTesting } from "./startup-metadata.js"; const readFileSyncMock = vi.hoisted(() => vi.fn()); @@ -23,6 +24,7 @@ vi.mock("../channels/ids.js", () => ({ describe("resolveCliChannelOptions", () => { afterEach(() => { __testing.resetPrecomputedChannelOptionsForTests(); + startupMetadataTesting.clearStartupMetadataCache(); vi.clearAllMocks(); }); diff --git a/src/commands/doctor/shared/legacy-config-runtime-migrate.ts b/src/commands/doctor/shared/legacy-config-runtime-migrate.ts deleted file mode 100644 index c4028ae8ec8..00000000000 --- a/src/commands/doctor/shared/legacy-config-runtime-migrate.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { OpenClawConfig } from "../../../config/types.openclaw.js"; -import { normalizeBaseCompatibilityConfigValues } from "./legacy-config-compatibility-base.js"; - -export function normalizeRuntimeCompatibilityConfigValues(cfg: OpenClawConfig): { - config: OpenClawConfig; - changes: string[]; -} { - const changes: string[] = []; - const next = normalizeBaseCompatibilityConfigValues(cfg, 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 deleted file mode 100644 index 3860125bf88..00000000000 --- a/src/commands/doctor/shared/runtime-compat-api.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { isDeepStrictEqual } from "node:util"; -import type { OpenClawConfig } from "../../../config/types.openclaw.js"; -import { applyLegacyDoctorMigrations } from "./legacy-config-compat.js"; -import { normalizeRuntimeCompatibilityConfigValues } from "./legacy-config-runtime-migrate.js"; - -export function applyRuntimeLegacyConfigMigrations(raw: unknown): { - next: Record | null; - changes: string[]; -} { - if (!raw || typeof raw !== "object") { - return { next: null, changes: [] }; - } - - const original = raw as Record; - const migrated = applyLegacyDoctorMigrations(original); - const base = (migrated.next ?? original) as OpenClawConfig; - const normalized = normalizeRuntimeCompatibilityConfigValues(base); - const next = normalized.config as OpenClawConfig & Record; - const changes = [...migrated.changes, ...normalized.changes]; - - if (changes.length === 0 || isDeepStrictEqual(next, original)) { - return { next: null, changes: [] }; - } - return { next, changes }; -} diff --git a/src/config/config-misc.test.ts b/src/config/config-misc.test.ts index 75d8ddc26a1..b8daa3bf362 100644 --- a/src/config/config-misc.test.ts +++ b/src/config/config-misc.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; -import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js"; import { getConfigValueAtPath, parseConfigPath, @@ -940,7 +939,7 @@ describe("config strict validation", () => { }); }); - it("accepts legacy messages.tts provider keys via auto-migration and reports legacyIssues", async () => { + it("reports legacy messages.tts provider keys without read-time auto-migration", async () => { const raw = { messages: { tts: { @@ -953,29 +952,13 @@ describe("config strict validation", () => { }, }; const issues = findLegacyConfigIssues(raw); - const migrated = applyRuntimeLegacyConfigMigrations(raw); expect(issues.some((issue) => issue.path === "messages.tts")).toBe(true); - expect(migrated.next).not.toBeNull(); - - const next = migrated.next as { - messages?: { - tts?: { - providers?: { - elevenlabs?: { - apiKey?: string; - voiceId?: string; - }; - }; - elevenlabs?: unknown; - }; - }; - } | null; - expect(next?.messages?.tts?.providers?.elevenlabs).toEqual({ + expect(raw.messages.tts.elevenlabs).toEqual({ apiKey: "test-key", voiceId: "voice-1", }); - expect(next?.messages?.tts?.elevenlabs).toBeUndefined(); + expect(raw.messages.tts).not.toHaveProperty("providers"); }); it("rejects legacy sandbox perSession without read-time auto-migration", async () => { diff --git a/src/config/io.compat.test.ts b/src/config/io.compat.test.ts index e75f9135f4c..a0f2891d902 100644 --- a/src/config/io.compat.test.ts +++ b/src/config/io.compat.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; -import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js"; +import { normalizeCompatibilityConfigValues } from "../commands/doctor-legacy-config.js"; import { createConfigIO } from "./io.js"; import { normalizeExecSafeBinProfilesInConfig } from "./normalize-exec-safe-bin.js"; import type { OpenClawConfig } from "./types.openclaw.js"; @@ -155,7 +155,7 @@ describe("config io paths", () => { }); it("moves WhatsApp shared access defaults into accounts.default during runtime compat", () => { - const migrated = applyRuntimeLegacyConfigMigrations({ + const migrated = normalizeCompatibilityConfigValues({ channels: { whatsapp: { enabled: true, @@ -171,9 +171,8 @@ describe("config io paths", () => { }, }, }, - }); - const next = migrated.next as OpenClawConfig | null; - expect(next?.channels?.whatsapp?.accounts?.default).toMatchObject({ + } as OpenClawConfig); + expect(migrated.config.channels?.whatsapp?.accounts?.default).toMatchObject({ dmPolicy: "allowlist", allowFrom: ["+15550001111"], groupPolicy: "open",