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