use thiserror::Error;
#[derive(Debug, Error)]
pub enum A2AError {
#[error("agent discovery failed: {0}")]
DiscoveryFailed(String),
#[error("invalid agent card: {0}")]
InvalidAgentCard(String),
#[error("transport error: {0}")]
Transport(#[from] reqwest::Error),
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("JSON-RPC error {code}: {message}")]
JsonRpc {
code: i64,
message: String,
data: Option<serde_json::Value>,
},
#[error("task not found: {0}")]
TaskNotFound(String),
#[error("task rejected: {0}")]
TaskRejected(String),
#[error("task failed: {0}")]
TaskFailed(String),
#[error("authentication required: {0}")]
AuthRequired(String),
#[error("streaming error: {0}")]
StreamingError(String),
#[error("push notification error: {0}")]
PushNotificationError(String),
#[error("invalid URL: {0}")]
InvalidUrl(#[from] url::ParseError),
#[error("timeout after {0:?}")]
Timeout(std::time::Duration),
#[error("unsupported operation: {0}")]
Unsupported(String),
}
pub type A2AResult<T> = Result<T, A2AError>;