diff --git a/Cargo.lock b/Cargo.lock index cbed9f5988b1ec96308f89c3c37309bab0b13bb1..b86444b42da723fea897d33084807b01e5406a75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,9 +279,9 @@ dependencies = [ [[package]] name = "agentic-coding-protocol" -version = "0.0.9" +version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e276b798eddd02562a339340a96919d90bbfcf78de118fdddc932524646fac7" +checksum = "48322590276f36cf49197898cde1c54645991c96c0c83722ef321da7f2b0ae42" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index aa9af9a423eb0d283df821a46424a4702154bce5..cbb8eb0bf922b3440a9ec3408d2f838809c613ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -410,7 +410,7 @@ zlog_settings = { path = "crates/zlog_settings" } # External crates # -agentic-coding-protocol = "0.0.9" +agentic-coding-protocol = "0.0.11" aho-corasick = "1.1" alacritty_terminal = { git = "https://github.com/zed-industries/alacritty.git", branch = "add-hush-login-flag" } any_vec = "0.14" diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index ae22725d5eac36a326718a66d5944c9fcfb44a4b..676834e90d2b300fe595821d9283559471542a5e 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -869,9 +869,34 @@ impl AcpThread { false } - pub fn initialize(&self) -> impl use<> + Future> { + pub fn initialize( + &self, + cx: &mut Context, + ) -> impl use<> + Future> { + let context_server_store = self.project.read(cx).context_server_store().read(cx); + let mut context_servers = HashMap::new(); + for id in context_server_store.all_server_ids() { + let Some(configuration) = context_server_store.configuration_for_server(&id) else { + continue; + }; + let command = configuration.command(); + context_servers.insert( + id.0.to_string(), + acp::ContextServer::Stdio { + command: command.path.clone(), + args: command.args.clone(), + env: command + .env + .iter() + .flatten() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(), + }, + ); + } self.request(acp::InitializeParams { protocol_version: ProtocolVersion::latest(), + context_servers, }) } @@ -1187,6 +1212,13 @@ impl acp::Client for AcpClientDelegate { Ok(()) } + async fn update_plan( + &self, + _request: agentic_coding_protocol::UpdatePlanParams, + ) -> Result<(), acp::Error> { + Ok(()) + } + async fn request_tool_call_confirmation( &self, request: acp::RequestToolCallConfirmationParams, diff --git a/crates/agent_servers/src/claude.rs b/crates/agent_servers/src/claude.rs index 52c601226705e8253147feb4c45c62f86265058a..891cedafcaf13b920d4a832044d45b53137a611c 100644 --- a/crates/agent_servers/src/claude.rs +++ b/crates/agent_servers/src/claude.rs @@ -65,6 +65,22 @@ impl AgentServer for ClaudeCode { let project = project.clone(); let root_dir = root_dir.to_path_buf(); let title = self.name().into(); + let context_server_store = project.read(cx).context_server_store().read(cx); + let mut mcp_servers = HashMap::default(); + for id in context_server_store.all_server_ids() { + let Some(configuration) = context_server_store.configuration_for_server(&id) else { + continue; + }; + let command = configuration.command(); + mcp_servers.insert( + id.0.to_string(), + McpServerConfig { + command: command.path.clone(), + args: command.args.clone(), + env: command.env.clone(), + }, + ); + } cx.spawn(async move |cx| { let (mut delegate_tx, delegate_rx) = watch::channel(None); let tool_id_map = Rc::new(RefCell::new(HashMap::default())); @@ -72,11 +88,11 @@ impl AgentServer for ClaudeCode { let permission_mcp_server = ClaudeMcpServer::new(delegate_rx, tool_id_map.clone(), cx).await?; - let mut mcp_servers = HashMap::default(); mcp_servers.insert( mcp_server::SERVER_NAME.to_string(), permission_mcp_server.server_config()?, ); + dbg!(&mcp_servers); let mcp_config = McpConfig { mcp_servers }; let mcp_config_file = tempfile::NamedTempFile::new()?; @@ -567,7 +583,7 @@ struct McpConfig { mcp_servers: HashMap, } -#[derive(Serialize)] +#[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] struct McpServerConfig { command: String, diff --git a/crates/agent_servers/src/e2e_tests.rs b/crates/agent_servers/src/e2e_tests.rs index 12f74cb13e41fea5c313729edf857173af94f74e..071f2eb256013e2b1efb801ade3821333c4f1bb8 100644 --- a/crates/agent_servers/src/e2e_tests.rs +++ b/crates/agent_servers/src/e2e_tests.rs @@ -375,7 +375,7 @@ pub async fn new_test_thread( .unwrap(); thread - .update(cx, |thread, _| thread.initialize()) + .update(cx, |thread, cx| thread.initialize(cx)) .await .unwrap(); thread diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 765f4fe6c0f270ee88b17d140169095a34dc3a3c..d46fb86bc7e4696a2a7d94f15b3962931d85f1d5 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -216,7 +216,7 @@ impl AcpThreadView { let init_response = async { let resp = thread - .read_with(cx, |thread, _cx| thread.initialize())? + .update(cx, |thread, cx| thread.initialize(cx))? .await?; anyhow::Ok(resp) };