@@ -60,6 +60,56 @@ function writeArtifactPreferencePlugin(id: string): TempPlugin {
6060 return plugin ;
6161}
6262
63+ function writeDistShimCapabilityPlugin ( id : string ) : TempPlugin {
64+ return writePlugin ( {
65+ id,
66+ filename : "index.ts" ,
67+ body : `import { isVoiceCompatibleAudio } from "openclaw/plugin-sdk/media-runtime";
68+
69+ void isVoiceCompatibleAudio;
70+
71+ export default {
72+ id: ${ JSON . stringify ( id ) } ,
73+ register(api) {
74+ api.registerMediaUnderstandingProvider({ id: ${ JSON . stringify ( id ) } });
75+ api.registerWebSearchProvider({ id: ${ JSON . stringify ( id ) } });
76+ api.registerMigrationProvider({ id: ${ JSON . stringify ( id ) } });
77+ },
78+ };` ,
79+ } ) ;
80+ }
81+
82+ function writeChannelCapabilityPlugin ( id : string ) : TempPlugin {
83+ const plugin = writePlugin ( {
84+ id,
85+ body : `module.exports = {
86+ id: ${ JSON . stringify ( id ) } ,
87+ register(api) {
88+ if (api.registrationMode === "discovery") {
89+ api.registerTranscriptSourceProvider({
90+ id: ${ JSON . stringify ( `${ id } -voice` ) } ,
91+ name: "Voice transcripts",
92+ sourceKinds: ["meeting"],
93+ });
94+ }
95+ },
96+ };` ,
97+ } ) ;
98+ fs . writeFileSync (
99+ path . join ( plugin . dir , "openclaw.plugin.json" ) ,
100+ JSON . stringify (
101+ {
102+ id,
103+ channels : [ id ] ,
104+ configSchema : { type : "object" , additionalProperties : false , properties : { } } ,
105+ } ,
106+ null ,
107+ 2 ,
108+ ) ,
109+ ) ;
110+ return plugin ;
111+ }
112+
63113function loadCanonicalFixture ( plugin : TempPlugin , discovery : PluginDiscoveryResult ) {
64114 return loadOpenClawPlugins ( {
65115 config : {
@@ -147,39 +197,43 @@ describe("loadBundledCapabilityRuntimeRegistry", () => {
147197 ) ;
148198
149199 it ( "loads runtime-backed bundled capabilities through the dist SDK shims" , ( ) => {
200+ const target = writeDistShimCapabilityPlugin ( "capability-dist-shims" ) ;
150201 const registry = loadBundledCapabilityRuntimeRegistry ( {
151- pluginIds : [ "codex" ] ,
202+ pluginIds : [ target . id ] ,
152203 pluginSdkResolution : "dist" ,
204+ discovery : discoveryFor ( target ) ,
153205 } ) ;
154206
155- const plugin = registry . plugins . find ( ( entry ) => entry . id === "codex" ) ;
207+ const plugin = registry . plugins . find ( ( entry ) => entry . id === target . id ) ;
156208 expect (
157209 plugin ?. status ,
158210 JSON . stringify ( { plugin, diagnostics : registry . diagnostics } , null , 2 ) ,
159211 ) . toBe ( "loaded" ) ;
160212 expect ( registry . mediaUnderstandingProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [
161- "codex" ,
213+ target . id ,
162214 ] ) ;
163- expect ( registry . webSearchProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [ "codex" ] ) ;
164- expect ( registry . migrationProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [ "codex" ] ) ;
215+ expect ( registry . webSearchProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [ target . id ] ) ;
216+ expect ( registry . migrationProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [ target . id ] ) ;
165217 } ) ;
166218
167- it ( "registers Discord voice transcript capabilities without full channel activation" , ( ) => {
219+ it ( "registers channel capabilities during discovery without replacing the active registry" , ( ) => {
220+ const target = writeChannelCapabilityPlugin ( "capability-channel" ) ;
168221 const active = createEmptyPluginRegistry ( ) ;
169- setActivePluginRegistry ( active , "existing-discord -registry" ) ;
222+ setActivePluginRegistry ( active , "existing-channel -registry" ) ;
170223 const registry = loadBundledCapabilityRuntimeRegistry ( {
171- pluginIds : [ "discord" ] ,
224+ pluginIds : [ target . id ] ,
172225 pluginSdkResolution : "dist" ,
226+ discovery : discoveryFor ( target ) ,
173227 } ) ;
174228
175- const plugin = registry . plugins . find ( ( entry ) => entry . id === "discord" ) ;
229+ const plugin = registry . plugins . find ( ( entry ) => entry . id === target . id ) ;
176230 expect (
177231 plugin ?. status ,
178232 JSON . stringify ( { plugin, diagnostics : registry . diagnostics } , null , 2 ) ,
179233 ) . toBe ( "loaded" ) ;
180- expect ( plugin ?. transcriptSourceProviderIds ) . toEqual ( [ "discord -voice" ] ) ;
234+ expect ( plugin ?. transcriptSourceProviderIds ) . toEqual ( [ ` ${ target . id } -voice` ] ) ;
181235 expect ( registry . transcriptSourceProviders . map ( ( entry ) => entry . provider . id ) ) . toEqual ( [
182- "discord -voice" ,
236+ ` ${ target . id } -voice` ,
183237 ] ) ;
184238 expect ( registry . typedHooks ) . toEqual ( [ ] ) ;
185239 expect ( getActivePluginRegistry ( ) ) . toBe ( active ) ;
0 commit comments