@@ -48,7 +48,6 @@ vi.mock("./runtime/load-context.js", () => ({
4848} ) ) ;
4949
5050let resolvePluginWebProviders : typeof import ( "./web-provider-runtime-shared.js" ) . resolvePluginWebProviders ;
51- let resolveRuntimeWebProviders : typeof import ( "./web-provider-runtime-shared.js" ) . resolveRuntimeWebProviders ;
5251
5352const requireRecord = createRequireRecord ( "record" , "expected-non-array-record" ) ;
5453
@@ -58,8 +57,7 @@ function mockArg(mock: ReturnType<typeof vi.fn>, callIndex = 0): Record<string,
5857
5958describe ( "web-provider-runtime-shared" , ( ) => {
6059 beforeAll ( async ( ) => {
61- ( { resolvePluginWebProviders, resolveRuntimeWebProviders } =
62- await import ( "./web-provider-runtime-shared.js" ) ) ;
60+ ( { resolvePluginWebProviders } = await import ( "./web-provider-runtime-shared.js" ) ) ;
6361 } ) ;
6462
6563 beforeEach ( ( ) => {
@@ -87,34 +85,11 @@ describe("web-provider-runtime-shared", () => {
8785 } ) ;
8886
8987 it ( "preserves explicit empty scopes in runtime-compatible web provider loads" , ( ) => {
88+ const activeRegistry = { source : "active" } ;
9089 const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
91- mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( { } as never ) ;
92-
93- resolvePluginWebProviders (
94- {
95- config : { } ,
96- onlyPluginIds : [ ] ,
97- } ,
98- {
99- resolveBundledResolutionConfig : ( ) => ( {
100- config : { } ,
101- activationSourceConfig : { } ,
102- autoEnabledReasons : { } ,
103- } ) ,
104- resolveCandidatePluginIds : ( ) => [ ] ,
105- mapRegistryProviders,
106- } ,
107- ) ;
108-
109- expect ( mockArg ( mocks . getLoadedRuntimePluginRegistry ) . requiredPluginIds ) . toEqual ( [ ] ) ;
110- expect ( mockArg ( mapRegistryProviders ) . onlyPluginIds ) . toEqual ( [ ] ) ;
111- } ) ;
112-
113- it ( "preserves explicit empty scopes in direct runtime web provider resolution" , ( ) => {
114- const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
115- mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( { } as never ) ;
90+ mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( activeRegistry as never ) ;
11691
117- resolveRuntimeWebProviders (
92+ const result = resolvePluginWebProviders (
11893 {
11994 config : { } ,
12095 onlyPluginIds : [ ] ,
@@ -131,14 +106,19 @@ describe("web-provider-runtime-shared", () => {
131106 ) ;
132107
133108 expect ( mockArg ( mocks . getLoadedRuntimePluginRegistry ) . requiredPluginIds ) . toEqual ( [ ] ) ;
134- expect ( mockArg ( mapRegistryProviders ) . onlyPluginIds ) . toEqual ( [ ] ) ;
109+ expect ( mapRegistryProviders ) . toHaveBeenCalledWith ( {
110+ registry : activeRegistry ,
111+ onlyPluginIds : [ ] ,
112+ } ) ;
113+ expect ( result ) . toStrictEqual ( [ ] ) ;
114+ expect ( mocks . loadOpenClawPlugins ) . not . toHaveBeenCalled ( ) ;
135115 } ) ;
136116
137117 it ( "preserves explicit scopes when config is omitted in direct runtime resolution" , ( ) => {
138118 const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
139119 mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( { } as never ) ;
140120
141- resolveRuntimeWebProviders (
121+ resolvePluginWebProviders (
142122 {
143123 onlyPluginIds : [ "alpha" ] ,
144124 } ,
@@ -209,34 +189,6 @@ describe("web-provider-runtime-shared", () => {
209189 expect ( mocks . loadOpenClawPlugins ) . not . toHaveBeenCalled ( ) ;
210190 } ) ;
211191
212- it ( "preserves explicit empty candidate scopes when reusing the active registry" , ( ) => {
213- const activeRegistry = { source : "active" } ;
214- const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
215- mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( activeRegistry ) ;
216-
217- resolvePluginWebProviders (
218- {
219- config : { } ,
220- onlyPluginIds : [ ] ,
221- } ,
222- {
223- resolveBundledResolutionConfig : ( ) => ( {
224- config : { } ,
225- activationSourceConfig : { } ,
226- autoEnabledReasons : { } ,
227- } ) ,
228- resolveCandidatePluginIds : ( ) => [ ] ,
229- mapRegistryProviders,
230- } ,
231- ) ;
232-
233- expect ( mapRegistryProviders ) . toHaveBeenCalledWith ( {
234- registry : activeRegistry ,
235- onlyPluginIds : [ ] ,
236- } ) ;
237- expect ( mocks . loadOpenClawPlugins ) . not . toHaveBeenCalled ( ) ;
238- } ) ;
239-
240192 it ( "uses loaded runtime web providers without runtime plugin loads" , ( ) => {
241193 const loadedRegistry = { source : "loaded" } ;
242194 const mapRegistryProviders = vi . fn ( ( ) => [ "provider" ] ) ;
@@ -436,31 +388,6 @@ describe("web-provider-runtime-shared", () => {
436388 expect ( mapRegistryProviders ) . toHaveBeenCalledTimes ( 2 ) ;
437389 } ) ;
438390
439- it ( "does not fall back when the active runtime registry returns empty under an explicit empty scope" , ( ) => {
440- const activeRegistry = { source : "active" } ;
441- const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
442- mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( activeRegistry as never ) ;
443-
444- const result = resolvePluginWebProviders (
445- {
446- config : { } ,
447- onlyPluginIds : [ ] ,
448- } ,
449- {
450- resolveBundledResolutionConfig : ( ) => ( {
451- config : { } ,
452- activationSourceConfig : { } ,
453- autoEnabledReasons : { } ,
454- } ) ,
455- resolveCandidatePluginIds : ( ) => [ ] ,
456- mapRegistryProviders,
457- } ,
458- ) ;
459-
460- expect ( result ) . toStrictEqual ( [ ] ) ;
461- expect ( mocks . loadOpenClawPlugins ) . not . toHaveBeenCalled ( ) ;
462- } ) ;
463-
464391 it ( "does not treat an active registry missing declared candidates as authoritative" , ( ) => {
465392 // Regression: an active registry with SOME web providers used to win even when a
466393 // manifest-declared candidate (npm-installed Brave with BRAVE_API_KEY set) was
@@ -481,7 +408,7 @@ describe("web-provider-runtime-shared", () => {
481408 } ) ;
482409 mocks . loadOpenClawPlugins . mockReturnValue ( scopedRegistry as never ) ;
483410
484- const result = resolveRuntimeWebProviders (
411+ const result = resolvePluginWebProviders (
485412 {
486413 config : { } ,
487414 env : { BRAVE_API_KEY : "key" } as never ,
@@ -501,66 +428,6 @@ describe("web-provider-runtime-shared", () => {
501428 expect ( mocks . loadOpenClawPlugins ) . toHaveBeenCalledTimes ( 1 ) ;
502429 } ) ;
503430
504- it ( "falls back when the direct runtime registry has no web providers" , ( ) => {
505- const activeRegistry = { source : "active" } ;
506- const fallbackRegistry = { source : "fallback" } ;
507- const mapRegistryProviders = vi . fn ( ( { registry } ) =>
508- registry === fallbackRegistry ? [ "brave" ] : [ ] ,
509- ) ;
510- mocks . getLoadedRuntimePluginRegistry . mockImplementation ( ( args : unknown ) => {
511- const requiredPluginIds = ( args as { requiredPluginIds ?: readonly string [ ] } )
512- ?. requiredPluginIds ;
513- if ( requiredPluginIds === undefined ) {
514- return activeRegistry as never ;
515- }
516- return undefined ;
517- } ) ;
518- mocks . loadOpenClawPlugins . mockReturnValue ( fallbackRegistry as never ) ;
519-
520- const result = resolveRuntimeWebProviders (
521- {
522- config : { } ,
523- } ,
524- {
525- resolveBundledResolutionConfig : ( ) => ( {
526- config : { } ,
527- activationSourceConfig : { } ,
528- autoEnabledReasons : { } ,
529- } ) ,
530- resolveCandidatePluginIds : ( ) => undefined ,
531- mapRegistryProviders,
532- } ,
533- ) ;
534-
535- expect ( result ) . toEqual ( [ "brave" ] ) ;
536- expect ( mocks . loadOpenClawPlugins ) . toHaveBeenCalledTimes ( 1 ) ;
537- } ) ;
538-
539- it ( "does not fall back when direct runtime registry returns empty under an explicit empty scope" , ( ) => {
540- const activeRegistry = { source : "active" } ;
541- const mapRegistryProviders = vi . fn ( ( ) => [ ] ) ;
542- mocks . getLoadedRuntimePluginRegistry . mockReturnValue ( activeRegistry as never ) ;
543-
544- const result = resolveRuntimeWebProviders (
545- {
546- config : { } ,
547- onlyPluginIds : [ ] ,
548- } ,
549- {
550- resolveBundledResolutionConfig : ( ) => ( {
551- config : { } ,
552- activationSourceConfig : { } ,
553- autoEnabledReasons : { } ,
554- } ) ,
555- resolveCandidatePluginIds : ( ) => [ ] ,
556- mapRegistryProviders,
557- } ,
558- ) ;
559-
560- expect ( result ) . toStrictEqual ( [ ] ) ;
561- expect ( mocks . loadOpenClawPlugins ) . not . toHaveBeenCalled ( ) ;
562- } ) ;
563-
564431 it ( "keeps explicit setup web provider cache opt-outs" , ( ) => {
565432 const loadedRegistry = { source : "setup" } ;
566433 const mapRegistryProviders = vi . fn ( ( ) => [ "provider" ] ) ;
0 commit comments