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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! Agent Coordinator Module
//!
//! This module provides agent coordination functionality for managing multiple
//! concurrent agent lifecycles with support for cancellation, timeout control,
//! and state management.
//!
//! # Overview
//!
//! The Agent Coordinator is inspired by Crush's Coordinator design and provides:
//!
//! - Unique agent identification via `AgentId`
//! - State tracking with `AgentState` (Idle, Running, Completed, Failed, Cancelled)
//! - Concurrent execution management
//! - Cancellation support (single or all agents)
//! - Timeout control
//! - Statistics and cleanup
//!
//! # Usage
//!
//! ```rust,no_run
//! # use litellm_rs::core::agent::{DefaultCoordinator, AgentCoordinator, AgentState};
//! # use std::time::Duration;
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a coordinator
//! let coordinator = DefaultCoordinator::new();
//!
//! // Spawn an agent
//! let agent_id = coordinator.spawn(async {
//! // Agent work here
//! 42
//! }).await?;
//!
//! // Check state
//! let state = coordinator.state(agent_id).await?;
//! println!("Agent state: {}", state);
//!
//! // Wait for completion with timeout
//! let final_state = coordinator.wait(agent_id, Some(Duration::from_secs(30))).await?;
//!
//! // Get statistics
//! let stats = coordinator.stats().await;
//! println!("Completed: {}, Failed: {}", stats.completed, stats.failed);
//! # Ok(())
//! # }
//! ```
//!
//! # Cancellation
//!
//! ```rust,no_run
//! # use litellm_rs::core::agent::{DefaultCoordinator, AgentCoordinator};
//! # use std::time::Duration;
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let coordinator = DefaultCoordinator::new();
//!
//! // Spawn a long-running agent
//! let agent_id = coordinator.spawn(async {
//! tokio::time::sleep(Duration::from_secs(60)).await;
//! }).await?;
//!
//! // Cancel it
//! coordinator.cancel(agent_id).await?;
//!
//! // Or cancel all agents
//! let cancelled_count = coordinator.cancel_all().await;
//! # Ok(())
//! # }
//! ```
// Re-export commonly used types
pub use ;
pub use ;
pub use ;