@@ -6,6 +6,7 @@ import { parseReplyDirectives } from "../../auto-reply/reply/reply-directives.js
66import type { OpenClawConfig } from "../../config/config.js" ;
77import * as mediaStore from "../../media/store.js" ;
88import * as webMedia from "../../media/web-media.js" ;
9+ import * as pluginConfig from "../../plugins/config-state.js" ;
910import { getCurrentPluginMetadataSnapshot } from "../../plugins/current-plugin-metadata-snapshot.js" ;
1011import { setCurrentPluginMetadataSnapshot } from "../../plugins/current-plugin-metadata.test-support.js" ;
1112import { resolveInstalledPluginIndexPolicyHash } from "../../plugins/installed-plugin-index-policy.js" ;
@@ -159,12 +160,13 @@ function createVideoProviderSnapshot(params: {
159160 id : string ;
160161 origin : PluginManifestRecord [ "origin" ] ;
161162 referenceAudioInputs ?: boolean ;
163+ unrelatedPluginCount ?: number ;
162164 workspaceDir ?: string ;
163165} ) : PluginMetadataSnapshot {
164166 // Plugin-backed provider snapshots are synthesized here so tool behavior can
165167 // be tested without loading plugin manifests from disk.
166168 const policyHash = resolveInstalledPluginIndexPolicyHash ( params . config ) ;
167- const plugin : PluginManifestRecord = {
169+ const providerPlugin : PluginManifestRecord = {
168170 id : params . id ,
169171 origin : params . origin ,
170172 rootDir : `/plugins/${ params . id } ` ,
@@ -183,6 +185,17 @@ function createVideoProviderSnapshot(params: {
183185 [ params . id ] : { referenceAudioInputs : params . referenceAudioInputs } ,
184186 } ,
185187 } ;
188+ const plugins = [
189+ providerPlugin ,
190+ ...Array . from ( { length : params . unrelatedPluginCount ?? 0 } , ( _ , index ) => ( {
191+ ...providerPlugin ,
192+ id : `unrelated-${ index } ` ,
193+ rootDir : `/plugins/unrelated-${ index } ` ,
194+ source : `/plugins/unrelated-${ index } /index.js` ,
195+ manifestPath : `/plugins/unrelated-${ index } /openclaw.plugin.json` ,
196+ contracts : index % 2 === 0 ? undefined : { videoGenerationProviders : [ ] } ,
197+ } ) ) ,
198+ ] ;
186199 const index : PluginMetadataSnapshot [ "index" ] = {
187200 version : 1 ,
188201 hostContractVersion : "test" ,
@@ -191,23 +204,21 @@ function createVideoProviderSnapshot(params: {
191204 policyHash,
192205 generatedAtMs : 0 ,
193206 installRecords : { } ,
194- plugins : [
195- {
196- pluginId : params . id ,
197- manifestPath : plugin . manifestPath ,
198- manifestHash : "test" ,
199- source : plugin . source ,
200- rootDir : plugin . rootDir ,
201- origin : params . origin ,
202- enabled : true ,
203- startup : {
204- sidecar : false ,
205- memory : false ,
206- agentHarnesses : [ ] ,
207- } ,
208- compat : [ ] ,
207+ plugins : plugins . map ( ( plugin ) => ( {
208+ pluginId : plugin . id ,
209+ manifestPath : plugin . manifestPath ,
210+ manifestHash : "test" ,
211+ source : plugin . source ,
212+ rootDir : plugin . rootDir ,
213+ origin : params . origin ,
214+ enabled : true ,
215+ startup : {
216+ sidecar : false ,
217+ memory : false ,
218+ agentHarnesses : [ ] ,
209219 } ,
210- ] ,
220+ compat : [ ] ,
221+ } ) ) ,
211222 diagnostics : [ ] ,
212223 } ;
213224 return {
@@ -216,10 +227,10 @@ function createVideoProviderSnapshot(params: {
216227 index,
217228 registryIndex : index ,
218229 registryDiagnostics : [ ] ,
219- manifestRegistry : { plugins : [ plugin ] , diagnostics : [ ] } ,
220- plugins : [ plugin ] ,
230+ manifestRegistry : { plugins, diagnostics : [ ] } ,
231+ plugins,
221232 diagnostics : [ ] ,
222- byPluginId : new Map ( [ [ plugin . id , plugin ] ] ) ,
233+ byPluginId : new Map ( plugins . map ( ( plugin ) => [ plugin . id , plugin ] ) ) ,
223234 normalizePluginId : ( pluginId ) => pluginId ,
224235 owners : {
225236 channels : new Map ( ) ,
@@ -237,8 +248,8 @@ function createVideoProviderSnapshot(params: {
237248 manifestRegistryMs : 0 ,
238249 ownerMapsMs : 0 ,
239250 totalMs : 0 ,
240- indexPluginCount : 1 ,
241- manifestPluginCount : 1 ,
251+ indexPluginCount : plugins . length ,
252+ manifestPluginCount : plugins . length ,
242253 } ,
243254 } ;
244255}
@@ -469,22 +480,30 @@ describe("createVideoGenerateTool", () => {
469480 } ,
470481 } ) ;
471482 const workspaceDir = "/workspace/external-video" ;
472- setCurrentPluginMetadataSnapshot (
473- createVideoProviderSnapshot ( {
474- config,
475- id : "external-video" ,
476- origin : "workspace" ,
477- workspaceDir,
478- } ) ,
479- { config, workspaceDir } ,
480- ) ;
481- expect ( getCurrentPluginMetadataSnapshot ( { config, workspaceDir } ) ) . toBeDefined ( ) ;
482-
483- const properties = toolParameterProperties ( createVideoGenerateTool ( { config, workspaceDir } ) ) ;
484-
485- expect ( properties . audioRef ) . toBeUndefined ( ) ;
486- expect ( properties . audioRefs ) . toBeUndefined ( ) ;
487- expect ( properties . audioRoles ) . toBeUndefined ( ) ;
483+ const normalize = vi . spyOn ( pluginConfig , "normalizePluginsConfig" ) ;
484+ const normalizationCounts : number [ ] = [ ] ;
485+ for ( const unrelatedPluginCount of [ 0 , 32 ] ) {
486+ setCurrentPluginMetadataSnapshot (
487+ createVideoProviderSnapshot ( {
488+ config,
489+ id : "external-video" ,
490+ origin : "workspace" ,
491+ unrelatedPluginCount,
492+ workspaceDir,
493+ } ) ,
494+ { config, workspaceDir } ,
495+ ) ;
496+ expect ( getCurrentPluginMetadataSnapshot ( { config, workspaceDir } ) ) . toBeDefined ( ) ;
497+ createVideoGenerateTool ( { config, workspaceDir } ) ;
498+ normalize . mockClear ( ) ;
499+ const properties = toolParameterProperties ( createVideoGenerateTool ( { config, workspaceDir } ) ) ;
500+ normalizationCounts . push ( normalize . mock . calls . length ) ;
501+
502+ expect ( properties . audioRef ) . toBeUndefined ( ) ;
503+ expect ( properties . audioRefs ) . toBeUndefined ( ) ;
504+ expect ( properties . audioRoles ) . toBeUndefined ( ) ;
505+ }
506+ expect ( normalizationCounts [ 1 ] ) . toBeLessThanOrEqual ( normalizationCounts [ 0 ] ! ) ;
488507 } ) ;
489508
490509 it ( "exposes reference-audio params for configured audio-capable model overrides" , ( ) => {
0 commit comments