mod context;
mod logging;
use async_trait::async_trait;
pub use context::RunContext;
pub use logging::{LogLevel, LoggingHooks};
use serde_json::Value;
use crate::chat::ChatResponse;
use crate::error::Error;
use crate::message::Message;
pub type SharedHooks = std::sync::Arc<dyn Hooks>;
#[async_trait]
pub trait Hooks: Send + Sync {
async fn on_agent_start(&self, _ctx: &RunContext, _agent_name: &str) {}
async fn on_agent_end(&self, _ctx: &RunContext, _agent_name: &str, _output: &Value) {}
async fn on_llm_start(
&self,
_ctx: &RunContext,
_agent_name: &str,
_system_prompt: Option<&str>,
_messages: &[Message],
) {
}
async fn on_llm_end(&self, _ctx: &RunContext, _agent_name: &str, _response: &ChatResponse) {}
async fn on_tool_start(&self, _ctx: &RunContext, _agent_name: &str, _tool_name: &str) {}
async fn on_tool_end(
&self,
_ctx: &RunContext,
_agent_name: &str,
_tool_name: &str,
_result: &str,
) {
}
async fn on_error(&self, _ctx: &RunContext, _agent_name: &str, _error: &Error) {}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct NoopHooks;
#[async_trait]
impl Hooks for NoopHooks {}