@@ -733,7 +733,7 @@ describe("registerPluginCommand", () => {
733733 expect ( observedOwnerStatus ) . toBeUndefined ( ) ;
734734 } ) ;
735735
736- it ( "exposes owner status to plugin commands that opt in " , async ( ) => {
736+ it ( "ignores owner status opt-in from direct plugin command registration " , async ( ) => {
737737 let observedOwnerStatus : boolean | undefined ;
738738 registerPluginCommand ( "demo-plugin" , {
739739 name : "voice" ,
@@ -755,6 +755,84 @@ describe("registerPluginCommand", () => {
755755 config : { } ,
756756 } ) ;
757757
758+ expect ( observedOwnerStatus ) . toBeUndefined ( ) ;
759+ } ) ;
760+
761+ it ( "ignores owner status opt-in from external plugin registry commands" , async ( ) => {
762+ const pluginRegistry = createPluginRegistry ( {
763+ logger : {
764+ info ( ) { } ,
765+ warn ( ) { } ,
766+ error ( ) { } ,
767+ debug ( ) { } ,
768+ } ,
769+ runtime : { } as PluginRuntime ,
770+ activateGlobalSideEffects : true ,
771+ } ) ;
772+ let observedOwnerStatus : boolean | undefined ;
773+ pluginRegistry . registerCommand (
774+ {
775+ ...createBundledPluginRecord ( "external-plugin" ) ,
776+ origin : "workspace" ,
777+ source : "/workspace/external-plugin/index.ts" ,
778+ rootDir : "/workspace/external-plugin" ,
779+ } ,
780+ {
781+ name : "external" ,
782+ description : "External command" ,
783+ exposeSenderIsOwner : true ,
784+ handler : async ( ctx ) => {
785+ observedOwnerStatus = ctx . senderIsOwner ;
786+ return { text : "ok" } ;
787+ } ,
788+ } ,
789+ ) ;
790+ const match = requirePluginCommandMatch ( "/external" ) ;
791+
792+ await executePluginCommand ( {
793+ command : match . command ,
794+ channel : "telegram" ,
795+ isAuthorizedSender : true ,
796+ senderIsOwner : true ,
797+ commandBody : "/external" ,
798+ config : { } ,
799+ } ) ;
800+
801+ expect ( observedOwnerStatus ) . toBeUndefined ( ) ;
802+ } ) ;
803+
804+ it ( "exposes owner status to trusted bundled plugin commands that opt in" , async ( ) => {
805+ const pluginRegistry = createPluginRegistry ( {
806+ logger : {
807+ info ( ) { } ,
808+ warn ( ) { } ,
809+ error ( ) { } ,
810+ debug ( ) { } ,
811+ } ,
812+ runtime : { } as PluginRuntime ,
813+ activateGlobalSideEffects : true ,
814+ } ) ;
815+ let observedOwnerStatus : boolean | undefined ;
816+ pluginRegistry . registerCommand ( createBundledPluginRecord ( "phone-control" ) , {
817+ name : "phone" ,
818+ description : "Phone command" ,
819+ exposeSenderIsOwner : true ,
820+ handler : async ( ctx ) => {
821+ observedOwnerStatus = ctx . senderIsOwner ;
822+ return { text : "ok" } ;
823+ } ,
824+ } ) ;
825+ const match = requirePluginCommandMatch ( "/phone" ) ;
826+
827+ await executePluginCommand ( {
828+ command : match . command ,
829+ channel : "telegram" ,
830+ isAuthorizedSender : true ,
831+ senderIsOwner : true ,
832+ commandBody : "/phone" ,
833+ config : { } ,
834+ } ) ;
835+
758836 expect ( observedOwnerStatus ) . toBe ( true ) ;
759837 } ) ;
760838
0 commit comments