alexhancock/mcp-crate-cleanup (#4885)

This commit is contained in:
Alex Hancock
2025-09-29 17:00:17 -04:00
committed by GitHub
parent 2bd18a757b
commit cb0eca9966
78 changed files with 1039 additions and 1090 deletions
+18 -12
View File
@@ -285,24 +285,30 @@ impl GooseAcpAgent {
// Extract tool name and parameters from the ToolCall if successful
let (tool_name, locations) = match &tool_request.tool_call {
Ok(tool_call) => {
let name = tool_call.name.clone();
// Extract file locations from certain tools for client tracking
let mut locs = Vec::new();
if name == "developer__text_editor" {
if tool_call.name == "developer__text_editor" {
// Try to extract the path from the arguments
let args = &tool_call.arguments;
if let Some(path_str) = args.get("path").and_then(|p| p.as_str()) {
locs.push(acp::ToolCallLocation {
path: path_str.into(),
line: Some(1),
meta: None,
});
if let Some(path_str) = tool_call
.arguments
.as_ref()
.and_then(|args_map| args_map.get("path"))
.and_then(|p| p.as_str())
{
let path = std::path::PathBuf::from(path_str);
if path.exists() && path.is_file() {
locs.push(acp::ToolCallLocation {
path: path_str.into(),
line: Some(1),
meta: None,
});
}
}
}
(name, locs)
(tool_call.name.to_string(), locs)
}
Err(_) => ("unknown".to_string(), Vec::new()),
Err(_) => ("error".to_string(), vec![]),
};
// Send tool call notification
+12 -4
View File
@@ -17,6 +17,7 @@ use goose::agents::{Agent, AgentEvent};
use goose::conversation::message::Message as GooseMessage;
use goose::session::SessionManager;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{net::SocketAddr, sync::Arc};
use tokio::sync::{Mutex, RwLock};
use tower_http::cors::{Any, CorsLayer};
@@ -518,8 +519,10 @@ async fn process_message_streaming(
serde_json::to_string(
&WebSocketMessage::ToolRequest {
id: req.id.clone(),
tool_name: tool_call.name.clone(),
arguments: tool_call.arguments.clone(),
tool_name: tool_call.name.to_string(),
arguments: Value::from(
tool_call.arguments.clone(),
),
},
)
.unwrap()
@@ -536,8 +539,13 @@ async fn process_message_streaming(
serde_json::to_string(
&WebSocketMessage::ToolConfirmation {
id: confirmation.id.clone(),
tool_name: confirmation.tool_name.clone(),
arguments: confirmation.arguments.clone(),
tool_name: confirmation
.tool_name
.to_string()
.clone(),
arguments: Value::from(
confirmation.arguments.clone(),
),
needs_confirmation: true,
},
)