use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum HandshakeStep {
Initialize,
NewSession,
}
impl std::fmt::Display for HandshakeStep {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Initialize => f.write_str("initialize"),
Self::NewSession => f.write_str("session/new"),
}
}
}
#[derive(Debug, Error)]
pub enum AcpClientError {
#[error("invalid command config: {0}")]
InvalidConfig(String),
#[error("failed to spawn subprocess: {0}")]
Spawn(#[source] std::io::Error),
#[error("handshake failed at {step}: {source}")]
Handshake {
step: HandshakeStep,
#[source]
source: agent_client_protocol::Error,
},
#[error("failed to send to sub-agent: {0}")]
SendFailed(#[source] agent_client_protocol::Error),
#[error("driver is busy servicing another read operation")]
DriverBusy,
#[error("driver task exited unexpectedly")]
DriverDied,
#[error("operation timed out")]
Timeout,
#[error("session is closed")]
Closed,
#[error("operation cancelled")]
Cancelled,
#[error("ACP SDK error: {0}")]
Sdk(#[source] agent_client_protocol::Error),
}