From 2991a6331adff12e887df5614b9b667894442060 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Tue, 16 Dec 2025 14:08:13 +0100 Subject: [PATCH 1/2] Update schema version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3819e07..e38e0f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,9 +26,9 @@ dependencies = [ [[package]] name = "agent-client-protocol-schema" -version = "0.10.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af81cc2d5c3f9c04f73db452efd058333735ba9d51c2cf7ef33c9fee038e7e6" +checksum = "158b8b314ca8072d2600b734df23b62389eda58a951618754d51a60ca6d0b1cd" dependencies = [ "anyhow", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 4e501b8..07b1a16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ tokio = { version = "1.48", features = ["full"] } tokio-util = { version = "0.7", features = ["compat"] } # Protocol -agent-client-protocol-schema = { version = "0.10.0" } +agent-client-protocol-schema = { version = "=0.10.4" } # Serialization serde = { version = "1.0", features = ["derive", "rc"] } From e00e6324e786e18b3499f26a505b1a19f1c504bc Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Tue, 16 Dec 2025 14:26:41 +0100 Subject: [PATCH 2/2] feat(unstable): Add initial support for listing sessions --- examples/agent.rs | 15 ++++++++--- src/agent-client-protocol/Cargo.toml | 17 +++++++++++- src/agent-client-protocol/src/agent.rs | 30 +++++++++++++++++++--- src/agent-client-protocol/src/lib.rs | 25 +++++++++++++++--- src/agent-client-protocol/src/rpc_tests.rs | 12 ++++++++- 5 files changed, 87 insertions(+), 12 deletions(-) diff --git a/examples/agent.rs b/examples/agent.rs index b5d395a..da6e1e9 100644 --- a/examples/agent.rs +++ b/examples/agent.rs @@ -73,7 +73,7 @@ impl acp::Agent for ExampleAgent { Ok(acp::NewSessionResponse { session_id: acp::SessionId(session_id.to_string().into()), modes: None, - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] models: None, meta: None, }) @@ -86,7 +86,7 @@ impl acp::Agent for ExampleAgent { log::info!("Received load session request {arguments:?}"); Ok(acp::LoadSessionResponse { modes: None, - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] models: None, meta: None, }) @@ -133,7 +133,7 @@ impl acp::Agent for ExampleAgent { Ok(acp::SetSessionModeResponse::default()) } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, args: acp::SetSessionModelRequest, @@ -142,6 +142,15 @@ impl acp::Agent for ExampleAgent { Ok(acp::SetSessionModelResponse::default()) } + #[cfg(feature = "unstable_session_list")] + async fn list_sessions( + &self, + args: acp::ListSessionsRequest, + ) -> Result { + log::info!("Received list sessions request {args:?}"); + Ok(acp::ListSessionsResponse::new(vec![])) + } + async fn ext_method(&self, args: acp::ExtRequest) -> Result { log::info!( "Received extension method call: method={}, params={:?}", diff --git a/src/agent-client-protocol/Cargo.toml b/src/agent-client-protocol/Cargo.toml index a431ce7..9ce47fd 100644 --- a/src/agent-client-protocol/Cargo.toml +++ b/src/agent-client-protocol/Cargo.toml @@ -13,7 +13,22 @@ keywords = ["agent", "client", "protocol", "ai", "editor"] categories = ["development-tools", "api-bindings"] [features] -unstable = ["agent-client-protocol-schema/unstable"] +unstable = [ + "unstable_cancel_request", + "unstable_session_config_options", + "unstable_session_fork", + "unstable_session_info_update", + "unstable_session_list", + "unstable_session_model", + "unstable_session_resume", +] +unstable_cancel_request = ["agent-client-protocol-schema/unstable_cancel_request"] +unstable_session_config_options = ["agent-client-protocol-schema/unstable_session_config_options"] +unstable_session_fork = ["agent-client-protocol-schema/unstable_session_fork"] +unstable_session_info_update = ["agent-client-protocol-schema/unstable_session_info_update"] +unstable_session_list = ["agent-client-protocol-schema/unstable_session_list"] +unstable_session_model = ["agent-client-protocol-schema/unstable_session_model"] +unstable_session_resume = ["agent-client-protocol-schema/unstable_session_resume"] [dependencies] agent-client-protocol-schema.workspace = true diff --git a/src/agent-client-protocol/src/agent.rs b/src/agent-client-protocol/src/agent.rs index a870038..f1e4ba4 100644 --- a/src/agent-client-protocol/src/agent.rs +++ b/src/agent-client-protocol/src/agent.rs @@ -6,7 +6,9 @@ use agent_client_protocol_schema::{ LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, Result, SetSessionModeRequest, SetSessionModeResponse, }; -#[cfg(feature = "unstable")] +#[cfg(feature = "unstable_session_list")] +use agent_client_protocol_schema::{ListSessionsRequest, ListSessionsResponse}; +#[cfg(feature = "unstable_session_model")] use agent_client_protocol_schema::{SetSessionModelRequest, SetSessionModelResponse}; use serde_json::value::RawValue; @@ -118,7 +120,7 @@ pub trait Agent { /// This capability is not part of the spec yet, and may be removed or changed at any point. /// /// Select a model for a given session. - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, _args: SetSessionModelRequest, @@ -126,6 +128,18 @@ pub trait Agent { Err(Error::method_not_found()) } + /// **UNSTABLE** + /// + /// This capability is not part of the spec yet, and may be removed or changed at any point. + /// + /// Lists existing sessions known to the agent. + /// + /// Only available if the Agent supports the `sessionCapabilities.list` capability. + #[cfg(feature = "unstable_session_list")] + async fn list_sessions(&self, _args: ListSessionsRequest) -> Result { + Err(Error::method_not_found()) + } + /// Handles extension method requests from the client. /// /// Extension methods provide a way to add custom functionality while maintaining @@ -173,13 +187,17 @@ impl Agent for Rc { async fn cancel(&self, args: CancelNotification) -> Result<()> { self.as_ref().cancel(args).await } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, args: SetSessionModelRequest, ) -> Result { self.as_ref().set_session_model(args).await } + #[cfg(feature = "unstable_session_list")] + async fn list_sessions(&self, args: ListSessionsRequest) -> Result { + self.as_ref().list_sessions(args).await + } async fn ext_method(&self, args: ExtRequest) -> Result { self.as_ref().ext_method(args).await } @@ -214,13 +232,17 @@ impl Agent for Arc { async fn cancel(&self, args: CancelNotification) -> Result<()> { self.as_ref().cancel(args).await } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, args: SetSessionModelRequest, ) -> Result { self.as_ref().set_session_model(args).await } + #[cfg(feature = "unstable_session_list")] + async fn list_sessions(&self, args: ListSessionsRequest) -> Result { + self.as_ref().list_sessions(args).await + } async fn ext_method(&self, args: ExtRequest) -> Result { self.as_ref().ext_method(args).await } diff --git a/src/agent-client-protocol/src/lib.rs b/src/agent-client-protocol/src/lib.rs index 42825b7..a2b88b3 100644 --- a/src/agent-client-protocol/src/lib.rs +++ b/src/agent-client-protocol/src/lib.rs @@ -142,7 +142,7 @@ impl Agent for ClientSideConnection { ) } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, args: SetSessionModelRequest, @@ -155,6 +155,16 @@ impl Agent for ClientSideConnection { .await } + #[cfg(feature = "unstable_session_list")] + async fn list_sessions(&self, args: ListSessionsRequest) -> Result { + self.conn + .request( + AGENT_METHOD_NAMES.session_list, + Some(ClientRequest::ListSessionsRequest(args)), + ) + .await + } + async fn ext_method(&self, args: ExtRequest) -> Result { self.conn .request( @@ -514,10 +524,14 @@ impl Side for AgentSide { m if m == AGENT_METHOD_NAMES.session_set_mode => serde_json::from_str(params.get()) .map(ClientRequest::SetSessionModeRequest) .map_err(Into::into), - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] m if m == AGENT_METHOD_NAMES.session_set_model => serde_json::from_str(params.get()) .map(ClientRequest::SetSessionModelRequest) .map_err(Into::into), + #[cfg(feature = "unstable_session_list")] + m if m == AGENT_METHOD_NAMES.session_list => serde_json::from_str(params.get()) + .map(ClientRequest::ListSessionsRequest) + .map_err(Into::into), m if m == AGENT_METHOD_NAMES.session_prompt => serde_json::from_str(params.get()) .map(ClientRequest::PromptRequest) .map_err(Into::into), @@ -582,11 +596,16 @@ impl MessageHandler for T { let response = self.set_session_mode(args).await?; Ok(AgentResponse::SetSessionModeResponse(response)) } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] ClientRequest::SetSessionModelRequest(args) => { let response = self.set_session_model(args).await?; Ok(AgentResponse::SetSessionModelResponse(response)) } + #[cfg(feature = "unstable_session_list")] + ClientRequest::ListSessionsRequest(args) => { + let response = self.list_sessions(args).await?; + Ok(AgentResponse::ListSessionsResponse(response)) + } ClientRequest::ExtMethodRequest(args) => { let response = self.ext_method(args).await?; Ok(AgentResponse::ExtMethodResponse(response)) diff --git a/src/agent-client-protocol/src/rpc_tests.rs b/src/agent-client-protocol/src/rpc_tests.rs index d7b93b9..8467564 100644 --- a/src/agent-client-protocol/src/rpc_tests.rs +++ b/src/agent-client-protocol/src/rpc_tests.rs @@ -196,7 +196,7 @@ impl Agent for TestAgent { Ok(()) } - #[cfg(feature = "unstable")] + #[cfg(feature = "unstable_session_model")] async fn set_session_model( &self, args: agent_client_protocol_schema::SetSessionModelRequest, @@ -205,6 +205,16 @@ impl Agent for TestAgent { Ok(agent_client_protocol_schema::SetSessionModelResponse::default()) } + #[cfg(feature = "unstable_session_list")] + async fn list_sessions( + &self, + _args: agent_client_protocol_schema::ListSessionsRequest, + ) -> Result { + Ok(agent_client_protocol_schema::ListSessionsResponse::new( + vec![], + )) + } + async fn ext_method(&self, args: ExtRequest) -> Result { dbg!(); match dbg!(args.method.as_ref()) {