adk_plugin/lib.rs
1//! # adk-plugin
2//!
3//! Plugin system for ADK-Rust agents.
4//!
5//! This crate provides a plugin architecture similar to adk-go's plugin package,
6//! allowing you to extend agent behavior through callbacks at various lifecycle points.
7//!
8//! ## Overview
9//!
10//! Plugins can hook into:
11//! - **Run lifecycle**: Before/after the entire agent run
12//! - **User messages**: Modify or inspect user input
13//! - **Events**: Modify or inspect agent events
14//! - **Agent callbacks**: Before/after agent execution
15//! - **Model callbacks**: Before/after LLM calls
16//! - **Tool callbacks**: Before/after tool execution
17//!
18//! ## Quick Start
19//!
20//! ```rust,ignore
21//! use adk_plugin::{Plugin, PluginConfig, PluginManager};
22//!
23//! // Create a logging plugin
24//! let logging_plugin = Plugin::new(PluginConfig {
25//! name: "logging".to_string(),
26//! on_user_message: Some(Box::new(|ctx, content| {
27//! Box::pin(async move {
28//! println!("User said: {:?}", content);
29//! Ok(None) // Don't modify
30//! })
31//! })),
32//! on_event: Some(Box::new(|ctx, event| {
33//! Box::pin(async move {
34//! println!("Event: {:?}", event);
35//! Ok(None) // Don't modify
36//! })
37//! })),
38//! ..Default::default()
39//! });
40//!
41//! // Create plugin manager
42//! let manager = PluginManager::new(vec![logging_plugin]);
43//!
44//! // Use with Runner
45//! let runner = Runner::new(RunnerConfig {
46//! plugin_manager: Some(manager),
47//! ..config
48//! });
49//! ```
50
51mod callbacks;
52mod manager;
53mod plugin;
54
55pub use callbacks::*;
56pub use manager::{PluginManager, PluginManagerConfig};
57pub use plugin::{Plugin, PluginBuilder, PluginConfig};