@@ -11,6 +11,9 @@ use serde::{Deserialize, Serialize};
1111
1212#[ cfg( feature = "unstable" ) ]
1313use crate :: SessionModeId ;
14+ use crate :: ext:: {
15+ EXT_METHOD_NAME , EXT_NOTIFICATION_NAME , ExtMethodRequest , ExtMethodResponse , ExtNotification ,
16+ } ;
1417use crate :: { ContentBlock , Error , Plan , SessionId , ToolCall , ToolCallUpdate } ;
1518
1619/// Defines the interface that ACP-compliant clients must implement.
@@ -120,6 +123,24 @@ pub trait Client {
120123 #[ doc( hidden) ]
121124 #[ cfg( feature = "unstable" ) ]
122125 fn kill_terminal ( & self , args : KillTerminalRequest ) -> impl Future < Output = Result < ( ) , Error > > ;
126+
127+ /// Extension method
128+ ///
129+ /// Allows the Agent to send an arbitrary request that is not part of the ACP spec.
130+ fn ext_method (
131+ & self ,
132+ method : Arc < str > ,
133+ params : serde_json:: Value ,
134+ ) -> impl Future < Output = Result < serde_json:: Value , Error > > ;
135+
136+ /// Extension notification
137+ ///
138+ /// Allows the Agent to send an arbitrary notifiation that is not part of the ACP spec.
139+ fn ext_notification (
140+ & self ,
141+ method : Arc < str > ,
142+ params : serde_json:: Value ,
143+ ) -> impl Future < Output = Result < ( ) , Error > > ;
123144}
124145
125146// Session updates
@@ -560,6 +581,10 @@ pub struct ClientMethodNames {
560581 /// Method for killing a terminal.
561582 #[ cfg( feature = "unstable" ) ]
562583 pub terminal_kill : & ' static str ,
584+ /// Extension method for custom functionality.
585+ pub ext_method : & ' static str ,
586+ /// Extension notification for custom functionality.
587+ pub ext_notification : & ' static str ,
563588}
564589
565590/// Constant containing all client method names.
@@ -578,6 +603,8 @@ pub const CLIENT_METHOD_NAMES: ClientMethodNames = ClientMethodNames {
578603 terminal_wait_for_exit : TERMINAL_WAIT_FOR_EXIT_METHOD_NAME ,
579604 #[ cfg( feature = "unstable" ) ]
580605 terminal_kill : TERMINAL_KILL_METHOD_NAME ,
606+ ext_method : EXT_METHOD_NAME ,
607+ ext_notification : EXT_NOTIFICATION_NAME ,
581608} ;
582609
583610/// Notification name for session updates.
@@ -627,6 +654,7 @@ pub enum AgentRequest {
627654 WaitForTerminalExitRequest ( WaitForTerminalExitRequest ) ,
628655 #[ cfg( feature = "unstable" ) ]
629656 KillTerminalRequest ( KillTerminalRequest ) ,
657+ ExtMethodRequest ( ExtMethodRequest ) ,
630658}
631659
632660/// All possible responses that a client can send to an agent.
@@ -652,6 +680,7 @@ pub enum ClientResponse {
652680 WaitForTerminalExitResponse ( WaitForTerminalExitResponse ) ,
653681 #[ cfg( feature = "unstable" ) ]
654682 KillTerminalResponse ,
683+ ExtMethodResponse ( ExtMethodResponse ) ,
655684}
656685
657686/// All possible notifications that an agent can send to a client.
@@ -663,6 +692,8 @@ pub enum ClientResponse {
663692#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
664693#[ serde( untagged) ]
665694#[ schemars( extend( "x-docs-ignore" = true ) ) ]
695+ #[ allow( clippy:: large_enum_variant) ]
666696pub enum AgentNotification {
667697 SessionNotification ( SessionNotification ) ,
698+ ExtNotification ( ExtNotification ) ,
668699}
0 commit comments