@@ -75,7 +75,16 @@ pub trait Agent {
7575 fn load_session (
7676 & self ,
7777 arguments : LoadSessionRequest ,
78- ) -> impl Future < Output = Result < ( ) , Error > > ;
78+ ) -> impl Future < Output = Result < LoadSessionResponse , Error > > ;
79+
80+ /// **UNSTABLE**
81+ ///
82+ /// This method is not part of the spec, and may be removed or changed at any point.
83+ #[ cfg( feature = "unstable" ) ]
84+ fn set_session_mode (
85+ & self ,
86+ arguments : SetSessionModeRequest ,
87+ ) -> impl Future < Output = Result < SetSessionModeResponse , Error > > ;
7988
8089 /// Processes a user prompt within a session.
8190 ///
@@ -204,6 +213,11 @@ pub struct NewSessionResponse {
204213 ///
205214 /// Used in all subsequent requests for this conversation.
206215 pub session_id : SessionId ,
216+ /// **UNSTABLE**
217+ ///
218+ /// This field is not part of the spec, and may be removed or changed at any point.
219+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
220+ pub modes : Option < SessionModeState > ,
207221}
208222
209223// Load session
@@ -225,6 +239,72 @@ pub struct LoadSessionRequest {
225239 pub session_id : SessionId ,
226240}
227241
242+ /// Response from loading an existing session.
243+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
244+ #[ serde( rename_all = "camelCase" ) ]
245+ pub struct LoadSessionResponse {
246+ /// **UNSTABLE**
247+ ///
248+ /// This field is not part of the spec, and may be removed or changed at any point.
249+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
250+ pub modes : Option < SessionModeState > ,
251+ }
252+
253+ // Session modes
254+
255+ /// **UNSTABLE**
256+ ///
257+ /// This type is not part of the spec, and may be removed or changed at any point.
258+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
259+ #[ serde( rename_all = "camelCase" ) ]
260+ pub struct SessionModeState {
261+ pub current_mode_id : SessionModeId ,
262+ pub available_modes : Vec < SessionMode > ,
263+ }
264+
265+ /// **UNSTABLE**
266+ ///
267+ /// This type is not part of the spec, and may be removed or changed at any point.
268+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
269+ #[ serde( rename_all = "camelCase" ) ]
270+ pub struct SessionMode {
271+ pub id : SessionModeId ,
272+ pub name : String ,
273+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
274+ pub description : Option < String > ,
275+ }
276+
277+ /// **UNSTABLE**
278+ ///
279+ /// This type is not part of the spec, and may be removed or changed at any point.
280+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq , Eq , Hash ) ]
281+ #[ serde( rename_all = "camelCase" ) ]
282+ pub struct SessionModeId ( pub Arc < str > ) ;
283+
284+ impl std:: fmt:: Display for SessionModeId {
285+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
286+ write ! ( f, "{}" , self . 0 )
287+ }
288+ }
289+
290+ /// **UNSTABLE**
291+ ///
292+ /// This type is not part of the spec, and may be removed or changed at any point.
293+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
294+ #[ schemars( extend( "x-docs-ignore" = true ) ) ]
295+ #[ serde( rename_all = "camelCase" ) ]
296+ pub struct SetSessionModeRequest {
297+ pub session_id : SessionId ,
298+ pub mode_id : SessionModeId ,
299+ }
300+
301+ /// **UNSTABLE**
302+ ///
303+ /// This type is not part of the spec, and may be removed or changed at any point.
304+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
305+ #[ serde( rename_all = "camelCase" ) ]
306+ pub struct SetSessionModeResponse { }
307+
228308// MCP
229309
230310/// Configuration for connecting to an MCP (Model Context Protocol) server.
@@ -440,6 +520,9 @@ pub struct AgentMethodNames {
440520 pub session_new : & ' static str ,
441521 /// Method for loading an existing session.
442522 pub session_load : & ' static str ,
523+ /// Method for setting the mode for a session.
524+ #[ cfg( feature = "unstable" ) ]
525+ pub session_set_mode : & ' static str ,
443526 /// Method for sending a prompt to the agent.
444527 pub session_prompt : & ' static str ,
445528 /// Notification for cancelling operations.
@@ -452,6 +535,8 @@ pub const AGENT_METHOD_NAMES: AgentMethodNames = AgentMethodNames {
452535 authenticate : AUTHENTICATE_METHOD_NAME ,
453536 session_new : SESSION_NEW_METHOD_NAME ,
454537 session_load : SESSION_LOAD_METHOD_NAME ,
538+ #[ cfg( feature = "unstable" ) ]
539+ session_set_mode : SESSION_SET_MODE_METHOD_NAME ,
455540 session_prompt : SESSION_PROMPT_METHOD_NAME ,
456541 session_cancel : SESSION_CANCEL_METHOD_NAME ,
457542} ;
@@ -464,6 +549,9 @@ pub(crate) const AUTHENTICATE_METHOD_NAME: &str = "authenticate";
464549pub ( crate ) const SESSION_NEW_METHOD_NAME : & str = "session/new" ;
465550/// Method name for loading an existing session.
466551pub ( crate ) const SESSION_LOAD_METHOD_NAME : & str = "session/load" ;
552+ /// Method name for setting the mode for a session.
553+ #[ cfg( feature = "unstable" ) ]
554+ pub ( crate ) const SESSION_SET_MODE_METHOD_NAME : & str = "session/set_mode" ;
467555/// Method name for sending a prompt.
468556pub ( crate ) const SESSION_PROMPT_METHOD_NAME : & str = "session/prompt" ;
469557/// Method name for the cancel notification.
@@ -483,6 +571,8 @@ pub enum ClientRequest {
483571 AuthenticateRequest ( AuthenticateRequest ) ,
484572 NewSessionRequest ( NewSessionRequest ) ,
485573 LoadSessionRequest ( LoadSessionRequest ) ,
574+ #[ cfg( feature = "unstable" ) ]
575+ SetSessionModeRequest ( SetSessionModeRequest ) ,
486576 PromptRequest ( PromptRequest ) ,
487577}
488578
@@ -499,7 +589,9 @@ pub enum AgentResponse {
499589 InitializeResponse ( InitializeResponse ) ,
500590 AuthenticateResponse ,
501591 NewSessionResponse ( NewSessionResponse ) ,
502- LoadSessionResponse ,
592+ LoadSessionResponse ( LoadSessionResponse ) ,
593+ #[ cfg( feature = "unstable" ) ]
594+ SetSessionModeResponse ( SetSessionModeResponse ) ,
503595 PromptResponse ( PromptResponse ) ,
504596}
505597
0 commit comments