nucel-agent-core 0.2.0

Core traits and types for Nucel agent-sdk — provider-agnostic AI coding agent abstraction
Documentation
use thiserror::Error;

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

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum AgentError {
    #[error("provider error ({provider}): {message}")]
    Provider { provider: String, message: String },

    #[error("budget exceeded: spent ${spent:.2} of ${limit:.2}")]
    BudgetExceeded { limit: f64, spent: f64 },

    #[error("session not found: {session_id}")]
    SessionNotFound { session_id: String },

    #[error("agent CLI not found: {cli_name}")]
    CliNotFound { cli_name: String },

    #[error("configuration error: {0}")]
    Config(String),

    #[error("timeout after {seconds}s")]
    Timeout { seconds: u64 },

    #[error("agent requested escalation")]
    EscalationRequested,

    /// Streaming was interrupted before a terminal event was received.
    #[error("stream interrupted: {0}")]
    StreamInterrupted(String),

    /// Rate limit hit; the upstream provider is throttling.
    #[error("rate limited: {message}")]
    RateLimited { message: String },

    /// Hook execution failed.
    #[error("hook '{hook}' failed: {message}")]
    HookFailed { hook: String, message: String },

    #[error(transparent)]
    Io(#[from] std::io::Error),

    #[error(transparent)]
    Json(#[from] serde_json::Error),
}