1use async_trait::async_trait;
4use serde_json::Value;
5
6use crate::{Identity, Permissions, ToolError};
7
8#[derive(Debug, Clone)]
14#[non_exhaustive]
15pub struct CallContext {
16 pub session_id: String,
17 pub identity: Identity,
18 pub permissions: Permissions,
19}
20
21impl CallContext {
22 pub fn new(session_id: String, identity: Identity, permissions: Permissions) -> Self {
23 Self {
24 session_id,
25 identity,
26 permissions,
27 }
28 }
29}
30
31#[async_trait]
32pub trait ToolHandler: Send + Sync {
33 fn name(&self) -> &str;
35
36 fn description(&self) -> &str;
38
39 async fn call(&self, ctx: &CallContext, args: Value) -> Result<Value, ToolError>;
41}