use std::sync::Arc;
use async_trait::async_trait;
use serde_json::Value;
use tokio::sync::{RwLock, mpsc};
use zagens_tools::{ToolError, ToolResult};
use crate::events::Event;
use super::host::TurnLoopToolRegistry;
#[derive(Clone)]
pub struct TurnLoopToolExec {
pub lock: Arc<RwLock<()>>,
pub tx_event: mpsc::Sender<Event>,
}
#[async_trait]
pub trait TurnLoopToolExecutor: Send + Sync {
type ToolRegistry: TurnLoopToolRegistry;
#[allow(clippy::too_many_arguments)]
async fn execute_with_lock(
&self,
exec: TurnLoopToolExec,
supports_parallel: bool,
interactive: bool,
tool_name: String,
tool_input: Value,
registry: Option<&Self::ToolRegistry>,
mcp_pool: Option<Arc<tokio::sync::Mutex<dyn McpPoolPort + Send + Sync>>>,
tool_progress_id: Option<String>,
) -> Result<ToolResult, ToolError>;
}
#[async_trait]
pub trait McpPoolPort: Send + Sync {
async fn execute_tool(&self, tool_name: &str, input: Value) -> Result<ToolResult, ToolError>;
}