//! Unified error enum for gate4agent.

/// Unified error type for all operations in this crate.
#[derive(Debug, thiserror::Error)]
pub enum AgentError {
    #[error("PTY creation failed: {0}")]
    PtyCreate(String),

    #[error("PTY spawn failed: {0}")]
    PtySpawn(String),

    #[error("PTY I/O error: {source}")]
    PtyIo {
        #[from]
        source: std::io::Error,
    },

    #[error("PTY operation failed: {0}")]
    Pty(String),

    #[error("Process spawn failed: {source}")]
    Spawn {
        #[source]
        source: std::io::Error,
    },

    #[error("Broadcast send error (no receivers)")]
    BroadcastSend,

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

    #[error("Spawn failed: {0}")]
    SpawnFailed(String),
}
