use thiserror::Error; pub type Result = std::result::Result; #[derive(Debug, Error)] pub enum Error { #[error("tool not found: {0}")] ToolNotFound(String), #[error("resource not found: {0}")] ResourceNotFound(String), /// An in-flight request was cancelled — by the client (`notifications/ /// cancelled`) or by the app (a human took the buffer back). The `String` /// is the cancelled request id. #[error("request cancelled: {0}")] Cancelled(String), #[error("invalid arguments for tool `{tool}`: {message}")] InvalidArgs { tool: String, message: String }, #[error("tool `{tool}` failed: {message}")] ToolFailed { tool: String, message: String }, /// Registered refusal — the tool exists in the surface but is not offered. /// The `reason` is stable text the model can act on. #[error("tool `{tool}` is not offered: {reason}")] Refused { tool: String, reason: String }, /// Write tool called without a grant for its capability. Includes a stable /// suffix so small models learn not to retry. #[error("tool `{tool}` requires capability `{capability}` which was not granted; do not retry")] CapabilityDenied { tool: String, capability: String }, #[error("protocol error: {0}")] Protocol(String), #[error("transport error: {0}")] Transport(String), #[error(transparent)] Json(#[from] serde_json::Error), #[error(transparent)] Io(#[from] std::io::Error), #[cfg(feature = "ollama")] #[error(transparent)] Http(#[from] reqwest::Error), }