use async_trait::async_trait;
use crate::subagent::SubAgentResult;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SubAgentSpawnOutcome {
pub agent_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SubAgentSpawnError {
NoClient,
SpawnFailed(String),
}
impl std::fmt::Display for SubAgentSpawnError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NoClient => write!(f, "API client not configured"),
Self::SpawnFailed(msg) => write!(f, "{msg}"),
}
}
}
impl std::error::Error for SubAgentSpawnError {}
#[deprecated(
since = "0.8.16",
note = "use `zagens_core::engine::hosts::SubAgentHost` instead; \
this alias will be removed in the next release"
)]
#[async_trait]
pub trait SubAgentSpawnPort: Send + Sync {
async fn spawn_general_subagent(
&self,
prompt: &str,
) -> Result<SubAgentSpawnOutcome, SubAgentSpawnError>;
async fn list_subagents(&self) -> Vec<SubAgentResult>;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn subagent_spawn_error_display_messages() {
assert_eq!(
SubAgentSpawnError::NoClient.to_string(),
"API client not configured"
);
assert_eq!(
SubAgentSpawnError::SpawnFailed("depth limit".into()).to_string(),
"depth limit"
);
}
}