diff --git a/src/plugins/contracts/registry.ts b/src/plugins/contracts/registry.ts index fce86382798..24366afe7f6 100644 --- a/src/plugins/contracts/registry.ts +++ b/src/plugins/contracts/registry.ts @@ -52,6 +52,13 @@ type WebSearchProviderContractEntry = { credentialValue: unknown; }; +type PluginRegistrationContractEntry = { + pluginId: string; + providerIds: string[]; + webSearchProviderIds: string[]; + toolNames: string[]; +}; + const bundledProviderPlugins: RegistrablePlugin[] = [ anthropicPlugin, byteplusPlugin, @@ -97,11 +104,7 @@ const bundledWebSearchPlugins: Array; - plugin.register(api as OpenClawPluginApi); + plugin.register(captured.api); return captured; } @@ -124,3 +127,20 @@ export const webSearchProviderContractRegistry: WebSearchProviderContractEntry[] credentialValue: plugin.credentialValue, })); }); + +const bundledPluginRegistrationList = [ + ...new Map( + [...bundledProviderPlugins, ...bundledWebSearchPlugins].map((plugin) => [plugin.id, plugin]), + ).values(), +]; + +export const pluginRegistrationContractRegistry: PluginRegistrationContractEntry[] = + bundledPluginRegistrationList.map((plugin) => { + const captured = captureRegistrations(plugin); + return { + pluginId: plugin.id, + providerIds: captured.providers.map((provider) => provider.id), + webSearchProviderIds: captured.webSearchProviders.map((provider) => provider.id), + toolNames: captured.tools.map((tool) => tool.name), + }; + }); diff --git a/src/test-utils/plugin-registration.ts b/src/test-utils/plugin-registration.ts index fe89acc5d92..e17e4a2520d 100644 --- a/src/test-utils/plugin-registration.ts +++ b/src/test-utils/plugin-registration.ts @@ -1,4 +1,5 @@ import type { + AnyAgentTool, OpenClawPluginApi, ProviderPlugin, WebSearchProviderPlugin, @@ -8,15 +9,18 @@ export type CapturedPluginRegistration = { api: OpenClawPluginApi; providers: ProviderPlugin[]; webSearchProviders: WebSearchProviderPlugin[]; + tools: AnyAgentTool[]; }; export function createCapturedPluginRegistration(): CapturedPluginRegistration { const providers: ProviderPlugin[] = []; const webSearchProviders: WebSearchProviderPlugin[] = []; + const tools: AnyAgentTool[] = []; return { providers, webSearchProviders, + tools, api: { registerProvider(provider: ProviderPlugin) { providers.push(provider); @@ -24,6 +28,9 @@ export function createCapturedPluginRegistration(): CapturedPluginRegistration { registerWebSearchProvider(provider: WebSearchProviderPlugin) { webSearchProviders.push(provider); }, + registerTool(tool: AnyAgentTool) { + tools.push(tool); + }, } as OpenClawPluginApi, }; }