chimera-core 0.1.0

Shared traits, types, and transport for the chimera AI agent SDK
Documentation
use std::path::PathBuf;

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum AgentError {
    #[error("binary not found: {binary} (searched: {searched:?})")]
    BinaryNotFound {
        binary: String,
        searched: Vec<PathBuf>,
    },

    #[error("failed to spawn process: {source}")]
    SpawnFailed {
        #[source]
        source: std::io::Error,
    },

    #[error("process exited with code {code}: {stderr}")]
    ProcessFailed { code: i32, stderr: String },

    #[error("process killed by signal: {stderr}")]
    ProcessKilled { stderr: String },

    #[error("failed to write to subprocess stdin: {source}")]
    StdinWrite {
        #[source]
        source: std::io::Error,
    },

    #[error("failed to parse JSON: {line}")]
    JsonParse {
        line: String,
        #[source]
        source: serde_json::Error,
    },

    #[error("JSON buffer exceeded {limit} bytes")]
    BufferOverflow { limit: usize },

    #[error("turn failed: {message}")]
    TurnFailed { message: String },

    #[error("control protocol error: {message}")]
    ControlError { message: String },

    #[error("operation timed out after {duration:?}")]
    Timeout { duration: std::time::Duration },

    #[error("session interrupted")]
    Interrupted,

    #[error("backend config does not match backend variant")]
    ConfigMismatch,

    #[error("{message}")]
    Other {
        message: String,
        #[source]
        source: Option<Box<dyn std::error::Error + Send + Sync>>,
    },
}