use crate::{Task, containers::ContainerError};
use aether_core::events::AgentEvent;
use futures::Stream;
use thiserror::Error;
pub type AgentRunResult = Result<AgentEvent, 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 AgentEvent: {stderr}")]
CommandExitWithoutTerminal { stderr: String },
#[error("Agent command emitted invalid AgentEvent JSON line: {line}")]
AgentEventJsonLine {
line: String,
#[source]
source: serde_json::Error,
},
#[error(transparent)]
Container(#[from] ContainerError),
}