refactor(doctor): remove stale legacy path listers · openclaw/openclaw@01b919a
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
File tree
src/commands/doctor/shared
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Legacy web-fetch migration tests cover doctor repair of old web fetch config. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | 3 | import type { OpenClawConfig } from "../../../config/config.js"; |
4 | | -import { |
5 | | -listLegacyWebFetchConfigPaths, |
6 | | -migrateLegacyWebFetchConfig, |
7 | | -} from "./legacy-web-fetch-migrate.js"; |
| 4 | +import { migrateLegacyWebFetchConfig } from "./legacy-web-fetch-migrate.js"; |
8 | 5 | |
9 | 6 | describe("legacy web fetch config", () => { |
10 | 7 | it("migrates legacy Firecrawl fetch config into plugin-owned config", () => { |
@@ -68,20 +65,4 @@ describe("legacy web fetch config", () => {
|
68 | 65 | }); |
69 | 66 | }); |
70 | 67 | |
71 | | -it("lists legacy Firecrawl fetch config paths", () => { |
72 | | -expect( |
73 | | -listLegacyWebFetchConfigPaths({ |
74 | | -tools: { |
75 | | -web: { |
76 | | -fetch: { |
77 | | -firecrawl: { |
78 | | -apiKey: "firecrawl-key", |
79 | | -maxAgeMs: 123, |
80 | | -}, |
81 | | -}, |
82 | | -}, |
83 | | -}, |
84 | | -}), |
85 | | -).toEqual(["tools.web.fetch.firecrawl.apiKey", "tools.web.fetch.firecrawl.maxAgeMs"]); |
86 | | -}); |
87 | 68 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -76,16 +76,6 @@ function migratePluginWebFetchConfig(params: {
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | | -/** List legacy tools.web.fetch.firecrawl config paths present in raw config. */ |
80 | | -export function listLegacyWebFetchConfigPaths(raw: unknown): string[] { |
81 | | -const fetch = resolveLegacyFetchConfig(raw); |
82 | | -const firecrawl = fetch ? copyLegacyFirecrawlFetchConfig(fetch) : undefined; |
83 | | -if (!firecrawl) { |
84 | | -return []; |
85 | | -} |
86 | | -return Object.keys(firecrawl).map((key) => `tools.web.fetch.firecrawl.${key}`); |
87 | | -} |
88 | | - |
89 | 79 | /** Move legacy Firecrawl web-fetch config into plugins.entries.firecrawl.config.webFetch. */ |
90 | 80 | export function migrateLegacyWebFetchConfig<T>(raw: T): { config: T; changes: string[] } { |
91 | 81 | if (!isRecord(raw) || !hasMappedLegacyWebFetchConfig(raw)) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Legacy X search migration tests cover doctor repair of old X search config. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | 3 | import type { OpenClawConfig } from "../../../config/config.js"; |
4 | | -import { |
5 | | -listLegacyXSearchConfigPaths, |
6 | | -migrateLegacyXSearchConfig, |
7 | | -} from "./legacy-x-search-migrate.js"; |
| 4 | +import { migrateLegacyXSearchConfig } from "./legacy-x-search-migrate.js"; |
8 | 5 | |
9 | 6 | describe("legacy x_search config migration", () => { |
10 | 7 | it("moves only legacy x_search auth into the xai plugin config", () => { |
@@ -136,18 +133,4 @@ describe("legacy x_search config migration", () => {
|
136 | 133 | expect(res.config.plugins?.entries?.xai).toBeUndefined(); |
137 | 134 | }); |
138 | 135 | |
139 | | -it("lists legacy x_search paths", () => { |
140 | | -expect( |
141 | | -listLegacyXSearchConfigPaths({ |
142 | | -tools: { |
143 | | -web: { |
144 | | -x_search: { |
145 | | -apiKey: "xai-legacy-key", |
146 | | -enabled: false, |
147 | | -}, |
148 | | -} as Record<string, unknown>, |
149 | | -}, |
150 | | -} as OpenClawConfig), |
151 | | -).toEqual(["tools.web.x_search.apiKey"]); |
152 | | -}); |
153 | 136 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -37,15 +37,6 @@ function resolveLegacyXSearchAuth(legacy: JsonRecord): unknown {
|
37 | 37 | return legacy.apiKey; |
38 | 38 | } |
39 | 39 | |
40 | | -/** List legacy tools.web.x_search auth config paths present in raw config. */ |
41 | | -export function listLegacyXSearchConfigPaths(raw: unknown): string[] { |
42 | | -const legacy = resolveLegacyXSearchConfig(raw); |
43 | | -if (!legacy || !Object.hasOwn(legacy, "apiKey")) { |
44 | | -return []; |
45 | | -} |
46 | | -return [`${X_SEARCH_LEGACY_PATH}.apiKey`]; |
47 | | -} |
48 | | - |
49 | 40 | /** Move legacy X search API key config into plugins.entries.xai.config.webSearch. */ |
50 | 41 | export function migrateLegacyXSearchConfig<T>(raw: T): { config: T; changes: string[] } { |
51 | 42 | if (!isRecord(raw)) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。