@@ -612,49 +612,54 @@ async fn test_full_conversation_flow() {
612612async fn test_notification_wire_format ( ) {
613613 use crate :: {
614614 AgentNotification , AgentSide , CancelNotification , ClientNotification , ClientSide ,
615- ContentBlock , SessionNotification , SessionUpdate , TextContent , rpc:: OutgoingMessage ,
615+ ContentBlock , SessionNotification , SessionUpdate , TextContent ,
616+ rpc:: { JsonRpcMessage , OutgoingMessage } ,
616617 } ;
617618 use serde_json:: { Value , json} ;
618619
619620 // Test client -> agent notification wire format
620- let outgoing_msg = OutgoingMessage :: < ClientSide , AgentSide > :: Notification {
621- method : "cancel" ,
622- params : Some ( ClientNotification :: CancelNotification ( CancelNotification {
623- session_id : SessionId ( "test-123" . into ( ) ) ,
624- } ) ) ,
625- } ;
621+ let outgoing_msg =
622+ JsonRpcMessage :: wrap ( OutgoingMessage :: < ClientSide , AgentSide > :: Notification {
623+ method : "cancel" ,
624+ params : Some ( ClientNotification :: CancelNotification ( CancelNotification {
625+ session_id : SessionId ( "test-123" . into ( ) ) ,
626+ } ) ) ,
627+ } ) ;
626628
627629 let serialized: Value = serde_json:: to_value ( & outgoing_msg) . unwrap ( ) ;
628630 assert_eq ! (
629631 serialized,
630632 json!( {
633+ "jsonrpc" : "2.0" ,
631634 "method" : "cancel" ,
632635 "params" : {
633636 "sessionId" : "test-123"
634- }
637+ } ,
635638 } )
636639 ) ;
637640
638641 // Test agent -> client notification wire format
639- let outgoing_msg = OutgoingMessage :: < AgentSide , ClientSide > :: Notification {
640- method : "sessionUpdate" ,
641- params : Some ( AgentNotification :: SessionNotification (
642- SessionNotification {
643- session_id : SessionId ( "test-456" . into ( ) ) ,
644- update : SessionUpdate :: AgentMessageChunk {
645- content : ContentBlock :: Text ( TextContent {
646- annotations : None ,
647- text : "Hello" . to_string ( ) ,
648- } ) ,
642+ let outgoing_msg =
643+ JsonRpcMessage :: wrap ( OutgoingMessage :: < AgentSide , ClientSide > :: Notification {
644+ method : "sessionUpdate" ,
645+ params : Some ( AgentNotification :: SessionNotification (
646+ SessionNotification {
647+ session_id : SessionId ( "test-456" . into ( ) ) ,
648+ update : SessionUpdate :: AgentMessageChunk {
649+ content : ContentBlock :: Text ( TextContent {
650+ annotations : None ,
651+ text : "Hello" . to_string ( ) ,
652+ } ) ,
653+ } ,
649654 } ,
650- } ,
651- ) ) ,
652- } ;
655+ ) ) ,
656+ } ) ;
653657
654658 let serialized: Value = serde_json:: to_value ( & outgoing_msg) . unwrap ( ) ;
655659 assert_eq ! (
656660 serialized,
657661 json!( {
662+ "jsonrpc" : "2.0" ,
658663 "method" : "sessionUpdate" ,
659664 "params" : {
660665 "sessionId" : "test-456" ,
0 commit comments