tirea_agentos/composition/
wiring.rs

1use std::collections::HashMap;
2use std::sync::Arc;
3
4use super::registry::RegistryBundle;
5use super::AgentDefinition;
6use super::AgentOsWiringError;
7use crate::contracts::runtime::tool_call::Tool;
8use crate::contracts::runtime::AgentBehavior;
9
10/// Generic wiring interface for extension subsystems.
11///
12/// Each `SystemWiring` implementation encapsulates the tools, behaviors,
13/// and registry bundles contributed by one extension subsystem. The
14/// orchestrator iterates over registered wirings during `wire_into()`
15/// instead of hardcoding calls per extension.
16pub trait SystemWiring: Send + Sync {
17    /// Unique identifier for this wiring (e.g. `"skills"`).
18    fn id(&self) -> &str;
19
20    /// Behavior IDs reserved by this subsystem. Users cannot reference these
21    /// in `AgentDefinition.behavior_ids`.
22    fn reserved_behavior_ids(&self) -> &[&'static str] {
23        &[]
24    }
25
26    /// Produce wiring bundles for a specific agent definition.
27    ///
28    /// Called during `wire_into()`. The implementation receives the resolved
29    /// user-defined behaviors and existing tool map for conflict detection.
30    fn wire(
31        &self,
32        ctx: &WiringContext<'_>,
33    ) -> Result<Vec<Arc<dyn RegistryBundle>>, AgentOsWiringError>;
34}
35
36/// Context passed to [`SystemWiring::wire`].
37pub struct WiringContext<'a> {
38    pub resolved_behaviors: &'a [Arc<dyn AgentBehavior>],
39    pub existing_tools: &'a HashMap<String, Arc<dyn Tool>>,
40    pub agent_definition: &'a AgentDefinition,
41}