use thiserror::Error;
#[derive(Debug, Error)]
pub enum MultiAgentError {
#[error("Agent with ID {0} not found")]
AgentNotFound(crate::AgentId),
#[error("Agent with ID {0} already exists")]
AgentAlreadyExists(crate::AgentId),
#[error("Agent {0} is not available")]
AgentNotAvailable(crate::AgentId),
#[error("Invalid role configuration: {0}")]
InvalidRoleConfig(String),
#[error("LLM error: {0}")]
LlmError(String),
#[error("Rig framework error: {0}")]
RigError(String),
#[error("Persistence error: {0}")]
PersistenceError(String),
#[error("Knowledge graph error: {0}")]
KnowledgeGraphError(String),
#[error("Agent evolution error: {0}")]
EvolutionError(String),
#[error("Context error: {0}")]
ContextError(String),
#[error("Task routing error: {0}")]
TaskRoutingError(String),
#[error("Agent communication error: {0}")]
CommunicationError(String),
#[error("Workflow execution error: {0}")]
WorkflowError(String),
#[error("Token limit exceeded: {current}/{limit}")]
TokenLimitExceeded { current: u64, limit: u64 },
#[error("Budget limit exceeded: ${current:.2}/${limit:.2}")]
BudgetLimitExceeded { current: f64, limit: f64 },
#[error("Rate limit exceeded: {requests} requests in {window_seconds}s")]
RateLimitExceeded { requests: u64, window_seconds: u64 },
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("System error: {0}")]
SystemError(String),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Serialization error: {0}")]
SerializationError(#[from] serde_json::Error),
#[error("Task was cancelled")]
TaskCancelled,
#[error("Operation timed out after {seconds}s")]
Timeout { seconds: u64 },
#[error("Session with ID {0} not found")]
SessionNotFound(uuid::Uuid),
#[error("Agent pool is exhausted - no available agents")]
PoolExhausted,
#[error("Agent {0} is currently busy")]
AgentBusy(crate::AgentId),
#[error("Agent creation timed out")]
AgentCreationTimeout,
#[error("Agent creation failed: {0}")]
AgentCreationFailed(String),
#[error("Pool error: {0}")]
PoolError(String),
#[error("External service error: {0}")]
External(String),
#[error("Hook validation: {0}")]
HookValidation(String),
}
impl From<anyhow::Error> for MultiAgentError {
fn from(err: anyhow::Error) -> Self {
MultiAgentError::SystemError(err.to_string())
}
}