use std::sync::Arc;
use async_trait::async_trait;
use crate::core::{EventStream, InvocationContext};
use crate::error::Result;
#[async_trait]
pub trait BaseAgent: Send + Sync + std::fmt::Debug + 'static {
fn name(&self) -> &str;
fn description(&self) -> &str {
""
}
fn sub_agents(&self) -> &[Arc<dyn BaseAgent>] {
&[]
}
fn find_agent(&self, name: &str) -> Option<Arc<dyn BaseAgent>> {
for sub in self.sub_agents() {
if sub.name() == name {
return Some(sub.clone());
}
if let Some(found) = sub.find_agent(name) {
return Some(found);
}
}
None
}
async fn run(self: Arc<Self>, ctx: Arc<InvocationContext>) -> Result<EventStream<'static>>;
}