velocia 0.3.1

velocia – production-ready AI agent framework using ADK-Rust, A2A protocol, and AWS DynamoDB
use thiserror::Error;

#[derive(Debug, Error)]
pub enum AgentKitError {
    // ── Configuration ─────────────────────────────────────────────────────────
    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Failed to read config file '{path}': {source}")]
    ConfigIo {
        path: String,
        #[source]
        source: std::io::Error,
    },

    #[error("Failed to parse YAML config: {0}")]
    ConfigParse(#[from] serde_yaml::Error),

    // ── Agent ─────────────────────────────────────────────────────────────────
    #[error("Unknown agent type: '{0}'")]
    UnknownAgentType(String),

    #[error("Agent build error: {0}")]
    AgentBuild(String),

    // ── Tools ─────────────────────────────────────────────────────────────────
    #[error("Unknown tool type: '{0}'")]
    UnknownToolType(String),

    #[error("Tool load error for '{name}': {reason}")]
    ToolLoad { name: String, reason: String },

    #[error("Invalid tool configuration: {0}")]
    ToolConfig(String),

    // ── A2A Protocol ──────────────────────────────────────────────────────────
    #[error("Remote agent '{name}' not found")]
    RemoteAgentNotFound { name: String },

    #[error("A2A client error: {0}")]
    A2aClient(String),

    #[error("A2A server error: {0}")]
    A2aServer(String),

    // ── Authentication ────────────────────────────────────────────────────────
    #[error("Authentication error: {0}")]
    Auth(String),

    #[error("JWT validation error: {0}")]
    JwtValidation(String),

    #[error("Missing or malformed Authorization header")]
    InvalidAuthHeader,

    #[error("JWKS fetch error: {0}")]
    JwksFetch(String),

    #[error("Forbidden: missing required claims: {0:?}")]
    Forbidden(Vec<String>),

    // ── Session ───────────────────────────────────────────────────────────────
    #[error("Session error: {0}")]
    Session(String),

    // ── DynamoDB ──────────────────────────────────────────────────────────────
    #[error("DynamoDB error: {0}")]
    DynamoDB(String),

    // ── Observability ─────────────────────────────────────────────────────────
    #[error("Observability setup error: {0}")]
    Observability(String),

    // ── HTTP / Network ────────────────────────────────────────────────────────
    #[error("HTTP error: {0}")]
    Http(#[from] reqwest::Error),

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

    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),
}

pub type Result<T> = std::result::Result<T, AgentKitError>;