mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 15:03:39 +00:00
refactor(doctor): remove stale legacy path listers
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
// Legacy web-fetch migration tests cover doctor repair of old web fetch config.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import {
|
||||
listLegacyWebFetchConfigPaths,
|
||||
migrateLegacyWebFetchConfig,
|
||||
} from "./legacy-web-fetch-migrate.js";
|
||||
import { migrateLegacyWebFetchConfig } from "./legacy-web-fetch-migrate.js";
|
||||
|
||||
describe("legacy web fetch config", () => {
|
||||
it("migrates legacy Firecrawl fetch config into plugin-owned config", () => {
|
||||
@@ -68,20 +65,4 @@ describe("legacy web fetch config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("lists legacy Firecrawl fetch config paths", () => {
|
||||
expect(
|
||||
listLegacyWebFetchConfigPaths({
|
||||
tools: {
|
||||
web: {
|
||||
fetch: {
|
||||
firecrawl: {
|
||||
apiKey: "firecrawl-key",
|
||||
maxAgeMs: 123,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual(["tools.web.fetch.firecrawl.apiKey", "tools.web.fetch.firecrawl.maxAgeMs"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,16 +76,6 @@ function migratePluginWebFetchConfig(params: {
|
||||
);
|
||||
}
|
||||
|
||||
/** List legacy tools.web.fetch.firecrawl config paths present in raw config. */
|
||||
export function listLegacyWebFetchConfigPaths(raw: unknown): string[] {
|
||||
const fetch = resolveLegacyFetchConfig(raw);
|
||||
const firecrawl = fetch ? copyLegacyFirecrawlFetchConfig(fetch) : undefined;
|
||||
if (!firecrawl) {
|
||||
return [];
|
||||
}
|
||||
return Object.keys(firecrawl).map((key) => `tools.web.fetch.firecrawl.${key}`);
|
||||
}
|
||||
|
||||
/** Move legacy Firecrawl web-fetch config into plugins.entries.firecrawl.config.webFetch. */
|
||||
export function migrateLegacyWebFetchConfig<T>(raw: T): { config: T; changes: string[] } {
|
||||
if (!isRecord(raw) || !hasMappedLegacyWebFetchConfig(raw)) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Legacy X search migration tests cover doctor repair of old X search config.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import {
|
||||
listLegacyXSearchConfigPaths,
|
||||
migrateLegacyXSearchConfig,
|
||||
} from "./legacy-x-search-migrate.js";
|
||||
import { migrateLegacyXSearchConfig } from "./legacy-x-search-migrate.js";
|
||||
|
||||
describe("legacy x_search config migration", () => {
|
||||
it("moves only legacy x_search auth into the xai plugin config", () => {
|
||||
@@ -136,18 +133,4 @@ describe("legacy x_search config migration", () => {
|
||||
expect(res.config.plugins?.entries?.xai).toBeUndefined();
|
||||
});
|
||||
|
||||
it("lists legacy x_search paths", () => {
|
||||
expect(
|
||||
listLegacyXSearchConfigPaths({
|
||||
tools: {
|
||||
web: {
|
||||
x_search: {
|
||||
apiKey: "xai-legacy-key",
|
||||
enabled: false,
|
||||
},
|
||||
} as Record<string, unknown>,
|
||||
},
|
||||
} as OpenClawConfig),
|
||||
).toEqual(["tools.web.x_search.apiKey"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,15 +37,6 @@ function resolveLegacyXSearchAuth(legacy: JsonRecord): unknown {
|
||||
return legacy.apiKey;
|
||||
}
|
||||
|
||||
/** List legacy tools.web.x_search auth config paths present in raw config. */
|
||||
export function listLegacyXSearchConfigPaths(raw: unknown): string[] {
|
||||
const legacy = resolveLegacyXSearchConfig(raw);
|
||||
if (!legacy || !Object.hasOwn(legacy, "apiKey")) {
|
||||
return [];
|
||||
}
|
||||
return [`${X_SEARCH_LEGACY_PATH}.apiKey`];
|
||||
}
|
||||
|
||||
/** Move legacy X search API key config into plugins.entries.xai.config.webSearch. */
|
||||
export function migrateLegacyXSearchConfig<T>(raw: T): { config: T; changes: string[] } {
|
||||
if (!isRecord(raw)) {
|
||||
|
||||
Reference in New Issue
Block a user