11import type { OpenClawConfig } from "../../../config/config.js" ;
22import { mergeMissing } from "../../../config/legacy.shared.js" ;
3- import { BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS } from "../../../plugins/bundled-capability-metadata.js" ;
3+ import {
4+ loadPluginManifestRegistry ,
5+ resolveManifestContractOwnerPluginId ,
6+ } from "../../../plugins/manifest-registry.js" ;
47
58type JsonRecord = Record < string , unknown > ;
69
@@ -9,12 +12,11 @@ const MODERN_SCOPED_WEB_SEARCH_KEYS = new Set(["openaiCodex"]);
912// Tavily only ever used the plugin-owned config path, so there is no legacy
1013// `tools.web.search.tavily.*` shape to migrate.
1114const NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS = new Set ( [ "tavily" ] ) ;
12- const LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS = Object . fromEntries (
13- Object . entries ( BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS ) . filter (
14- ( [ providerId ] ) => ! NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS . has ( providerId ) ,
15- ) ,
16- ) ;
17- const LEGACY_WEB_SEARCH_PROVIDER_IDS = Object . keys ( LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS ) ;
15+ const LEGACY_WEB_SEARCH_PROVIDER_IDS = loadPluginManifestRegistry ( { cache : true } )
16+ . plugins . filter ( ( plugin ) => plugin . origin === "bundled" )
17+ . flatMap ( ( plugin ) => plugin . contracts ?. webSearchProviders ?? [ ] )
18+ . filter ( ( providerId ) => ! NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS . has ( providerId ) )
19+ . toSorted ( ( left , right ) => left . localeCompare ( right ) ) ;
1820const LEGACY_WEB_SEARCH_PROVIDER_ID_SET = new Set ( LEGACY_WEB_SEARCH_PROVIDER_IDS ) ;
1921const LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID = "brave" ;
2022
@@ -84,8 +86,11 @@ function resolveLegacyGlobalWebSearchMigration(search: JsonRecord): {
8486 return null ;
8587 }
8688 const pluginId =
87- LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS [ LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID ] ??
88- LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID ;
89+ resolveManifestContractOwnerPluginId ( {
90+ contract : "webSearchProviders" ,
91+ value : LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID ,
92+ origin : "bundled" ,
93+ } ) ?? LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID ;
8994 return {
9095 pluginId,
9196 payload,
@@ -233,7 +238,11 @@ function normalizeLegacyWebSearchConfigRecord<T extends JsonRecord>(
233238 if ( ! scoped || Object . keys ( scoped ) . length === 0 ) {
234239 continue ;
235240 }
236- const pluginId = LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS [ providerId ] ;
241+ const pluginId = resolveManifestContractOwnerPluginId ( {
242+ contract : "webSearchProviders" ,
243+ value : providerId ,
244+ origin : "bundled" ,
245+ } ) ;
237246 if ( ! pluginId ) {
238247 continue ;
239248 }
0 commit comments