use async_trait::async_trait;
use serde_json::Value;
use crate::{Identity, Permissions, ToolError};
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct CallContext {
pub session_id: String,
pub identity: Identity,
pub permissions: Permissions,
pub key_id: Option<String>,
}
impl CallContext {
pub fn new(session_id: String, identity: Identity, permissions: Permissions) -> Self {
Self {
session_id,
identity,
permissions,
key_id: None,
}
}
pub fn with_key_id(mut self, key_id: Option<String>) -> Self {
self.key_id = key_id;
self
}
}
#[async_trait]
pub trait ToolHandler: Send + Sync {
fn name(&self) -> &str;
fn description(&self) -> &str;
async fn call(&self, ctx: &CallContext, args: Value) -> Result<Value, ToolError>;
}