use async_trait::async_trait;
use uuid::Uuid;
use cognis_core::{CognisError, Message};
use super::AgentResponse;
#[async_trait]
pub trait AgentLifecycle: Send + Sync {
async fn on_start(&self, run_id: Uuid, input: &Message) {
let _ = (run_id, input);
}
async fn on_stop(&self, run_id: Uuid, response: &AgentResponse) {
let _ = (run_id, response);
}
async fn on_error(&self, run_id: Uuid, error: &CognisError) {
let _ = (run_id, error);
}
}
pub struct OnStart<F: Fn(Uuid, &Message) + Send + Sync>(pub F);
#[async_trait]
impl<F: Fn(Uuid, &Message) + Send + Sync> AgentLifecycle for OnStart<F> {
async fn on_start(&self, run_id: Uuid, input: &Message) {
(self.0)(run_id, input)
}
}