use std::io;
#[derive(Debug, thiserror::Error)]
pub enum SdkError {
#[error("failed to spawn codex process: {0}")]
ProcessSpawn(#[source] io::Error),
#[error("codex process died (exit code: {exit_code:?}, stderr: {stderr})")]
ProcessDied {
exit_code: Option<i32>,
stderr: String,
},
#[error("invalid JSON from codex stdout: {message}")]
InvalidJson {
message: String,
line: String,
#[source]
source: serde_json::Error,
},
#[error("protocol error: {0}")]
ProtocolError(String),
#[error("operation timed out after {0:?}")]
Timeout(std::time::Duration),
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("execution is not running")]
NotRunning,
}
pub type Result<T> = std::result::Result<T, SdkError>;