use crate::{Task, containers::ContainerError};
use aether_core::events::AgentMessage;
use futures::Stream;
use thiserror::Error;
pub type AgentRunResult = Result<AgentMessage, RunError>;
pub trait Agent: Send + Sync {
fn run(&self, task: Task) -> impl Stream<Item = AgentRunResult> + Send + '_;
}
#[derive(Debug, Error)]
pub enum RunError {
#[error("Agent execution failed: {0}")]
ExecutionFailed(String),
#[error("Agent configuration error: {0}")]
ConfigurationError(String),
#[error("Agent command exited without emitting a terminal AgentMessage: {stderr}")]
CommandExitWithoutTerminal { stderr: String },
#[error("Agent command emitted invalid AgentMessage JSON line: {line}")]
AgentMessageJsonLine {
line: String,
#[source]
source: serde_json::Error,
},
#[error(transparent)]
Container(#[from] ContainerError),
}