use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolSpec {
pub name: String,
pub description: String,
pub parameters: Value, }
#[derive(Debug, Clone)]
pub struct ToolResult {
pub output: String,
pub is_error: bool,
}
impl ToolResult {
pub fn success(output: impl Into<String>) -> Self {
Self {
output: crate::redaction::redact_text(&output.into()),
is_error: false,
}
}
pub fn error(output: impl Into<String>) -> Self {
Self {
output: crate::redaction::redact_text(&output.into()),
is_error: true,
}
}
}
#[async_trait]
pub trait Tool: Send + Sync {
fn name(&self) -> &str;
fn spec(&self) -> ToolSpec;
async fn execute(&self, arguments: &str) -> anyhow::Result<ToolResult>;
}