use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GateId {
FtsRead,
EmbeddingRead,
ContextRead,
HealthRead,
SessionWrite,
CommitWrite,
}
#[derive(Debug)]
pub enum ToolError {
InvalidParams(String),
PolicyRejected(String),
SizeLimitExceeded(String),
Internal(String),
}
impl fmt::Display for ToolError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ToolError::InvalidParams(msg) => write!(f, "invalid params: {msg}"),
ToolError::PolicyRejected(msg) => write!(f, "policy rejected: {msg}"),
ToolError::SizeLimitExceeded(msg) => write!(f, "size limit exceeded: {msg}"),
ToolError::Internal(msg) => write!(f, "internal error: {msg}"),
}
}
}
pub trait ToolHandler: Send + Sync {
fn name(&self) -> &'static str;
fn gate_set(&self) -> &'static [GateId];
fn call(&self, params: serde_json::Value) -> Result<serde_json::Value, ToolError>;
}