@@ -523,6 +523,13 @@ impl RustyredExecutor for InMemoryRustyredExecutor {
523523
524524 fn execute_request ( & mut self , request : RustyredRequest ) -> RustyredResponse {
525525 let command_name = request. command . clone ( ) ;
526+ if let Some ( operation) = crate :: plugin:: builtin_plugin_registry ( ) . operation ( & command_name) {
527+ let context = crate :: plugin:: PluginOperationContext {
528+ command : operation. command ,
529+ state_hash : self . state_hash ( ) ,
530+ } ;
531+ return ( operation. handler ) ( context, request. args ) ;
532+ }
526533 match RustyredCommand :: from_name ( & request. command ) {
527534 Ok ( command) => self . execute ( command, request. args ) . unwrap_or_else ( |error| {
528535 RustyredResponse :: err ( command_name, error, self . state_hash ( ) )
@@ -551,6 +558,17 @@ impl<S: RustyredStore> RustyredExecutor for StoreBackedRustyredExecutor<S> {
551558
552559 fn execute_request ( & mut self , request : RustyredRequest ) -> RustyredResponse {
553560 let command_name = request. command . clone ( ) ;
561+ if let Some ( operation) = crate :: plugin:: builtin_plugin_registry ( ) . operation ( & command_name) {
562+ let context = crate :: plugin:: PluginOperationContext {
563+ command : operation. command ,
564+ state_hash : self . state_hash ( ) ,
565+ } ;
566+ let response = ( operation. handler ) ( context, request. args ) ;
567+ if response. ok {
568+ self . persist ( ) ;
569+ }
570+ return response;
571+ }
554572 match RustyredCommand :: from_name ( & request. command ) {
555573 Ok ( command) => self . execute ( command, request. args ) . unwrap_or_else ( |error| {
556574 RustyredResponse :: err ( command_name, error, self . state_hash ( ) )
@@ -907,4 +925,17 @@ mod tests {
907925 Some ( "missing_graph_endpoint" )
908926 ) ;
909927 }
928+
929+ #[ test]
930+ fn plugin_operation_round_trips_through_json_executor ( ) {
931+ let mut executor = InMemoryRustyredExecutor :: new ( ) ;
932+ let raw = executor. execute_json (
933+ r#"{"command":"RUSTYRED.PLUGIN.ECHO","args":{"message":"hello plugin"}}"# ,
934+ ) ;
935+ let parsed: serde_json:: Value = serde_json:: from_str ( & raw ) . unwrap ( ) ;
936+
937+ assert_eq ! ( parsed[ "ok" ] , true ) ;
938+ assert_eq ! ( parsed[ "command" ] , "RUSTYRED.PLUGIN.ECHO" ) ;
939+ assert_eq ! ( parsed[ "payload" ] [ "args" ] [ "message" ] , "hello plugin" ) ;
940+ }
910941}
0 commit comments