use async_trait::async_trait;
use rpi_ai::types::Tool;
use tokio_util::sync::CancellationToken;
use crate::error::AgentError;
use crate::types::{AgentToolResult, ToolExecutionMode, ToolResultPartial};
use std::sync::Arc;
#[async_trait]
pub trait AgentTool: Send + Sync {
fn schema(&self) -> &Tool;
fn label(&self) -> &str;
fn execution_mode(&self) -> ToolExecutionMode {
ToolExecutionMode::Parallel
}
fn prepare_arguments(&self, args: serde_json::Value) -> Result<serde_json::Value, AgentError> {
Ok(args)
}
async fn execute(
&self,
tool_call_id: &str,
params: serde_json::Value,
signal: CancellationToken,
on_update: Arc<dyn Fn(ToolResultPartial) + Send + Sync>,
) -> Result<AgentToolResult, AgentError>;
}