tirea_agentos/composition/registry/
mod.rs1mod agent;
2mod behavior;
3mod model;
4mod provider;
5mod stop_policy;
6mod tool;
7pub mod traits;
8
9use std::collections::HashMap;
10use std::sync::Arc;
11
12#[cfg(feature = "skills")]
13use crate::extensions::skills::SkillRegistry;
14
15pub use stop_policy::StopPolicyRegistry;
16pub use traits::{AgentRegistry, BehaviorRegistry, ModelRegistry, ProviderRegistry, ToolRegistry};
17
18pub use agent::{CompositeAgentRegistry, InMemoryAgentRegistry};
19pub use behavior::{CompositeBehaviorRegistry, InMemoryBehaviorRegistry};
20pub use model::{CompositeModelRegistry, InMemoryModelRegistry};
21pub use provider::{CompositeProviderRegistry, InMemoryProviderRegistry};
22pub use stop_policy::{
23 CompositeStopPolicyRegistry, InMemoryStopPolicyRegistry, StopPolicyRegistryError,
24};
25pub use tool::{CompositeToolRegistry, InMemoryToolRegistry};
26
27pub use traits::{
28 AgentRegistryError, BehaviorRegistryError, ModelDefinition, ModelRegistryError,
29 ProviderRegistryError, RegistryBundle, ToolRegistryError,
30};
31
32pub(crate) fn sorted_registry_ids<T>(entries: &HashMap<String, T>) -> Vec<String> {
33 let mut ids: Vec<String> = entries.keys().cloned().collect();
34 ids.sort();
35 ids
36}
37
38#[derive(Clone)]
40pub struct RegistrySet {
41 pub agents: Arc<dyn AgentRegistry>,
42 pub tools: Arc<dyn ToolRegistry>,
43 pub behaviors: Arc<dyn BehaviorRegistry>,
44 pub providers: Arc<dyn ProviderRegistry>,
45 pub models: Arc<dyn ModelRegistry>,
46 pub stop_policies: Arc<dyn StopPolicyRegistry>,
47 #[cfg(feature = "skills")]
48 pub skills: Option<Arc<dyn SkillRegistry>>,
49}
50
51impl RegistrySet {
52 pub fn new(
53 agents: Arc<dyn AgentRegistry>,
54 tools: Arc<dyn ToolRegistry>,
55 behaviors: Arc<dyn BehaviorRegistry>,
56 providers: Arc<dyn ProviderRegistry>,
57 models: Arc<dyn ModelRegistry>,
58 stop_policies: Arc<dyn StopPolicyRegistry>,
59 #[cfg(feature = "skills")] skills: Option<Arc<dyn SkillRegistry>>,
60 ) -> Self {
61 Self {
62 agents,
63 tools,
64 behaviors,
65 providers,
66 models,
67 stop_policies,
68 #[cfg(feature = "skills")]
69 skills,
70 }
71 }
72}