use thiserror::Error;

#[derive(Error, Debug)]
pub enum SwarmError {
    #[error("Agent not found: {0}")]
    AgentNotFound(String),

    #[error("Agent already exists: {0}")]
    AgentAlreadyExists(String),

    #[error("LLM provider error: {0}")]
    LlmError(String),

    #[error("Tool execution error: {0}")]
    ToolError(String),

    #[error("Configuration error: {0}")]
    ConfigError(String),

    #[error("Channel closed")]
    ChannelClosed,

    #[error("Timeout after {0}s")]
    Timeout(u64),

    #[error("Database error: {0}")]
    DbError(#[from] rusqlite::Error),

    #[error("Serialization error: {0}")]
    SerdeError(#[from] serde_json::Error),

    #[error("IO error: {0}")]
    IoError(#[from] std::io::Error),

    #[error("{0}")]
    Other(#[from] anyhow::Error),
}

pub type SwarmResult<T> = Result<T, SwarmError>;
