Skip to main content

aether_core/core/
agent_deps.rs

1use crate::events::{AgentObserver, ObserverFactory};
2use aether_auth::OAuthCredentialStorage;
3use std::sync::Arc;
4
5/// Cross-cutting dependencies threaded to every agent a run spawns — the root
6/// agent and any sub-agents created by in-memory MCP servers. Bundling them
7/// keeps the plumbing through builders and servers a single value.
8#[derive(Clone, Default)]
9pub struct AgentDeps {
10    pub oauth_credential_store: Option<Arc<dyn OAuthCredentialStorage>>,
11    pub observer_factory: Option<ObserverFactory>,
12}
13
14impl AgentDeps {
15    pub fn new(
16        oauth_credential_store: Arc<dyn OAuthCredentialStorage>,
17        observer_factory: Option<ObserverFactory>,
18    ) -> Self {
19        Self { oauth_credential_store: Some(oauth_credential_store), observer_factory }
20    }
21
22    /// A fresh observer for one agent, if a factory is configured.
23    pub fn observer(&self) -> Option<Box<dyn AgentObserver>> {
24        self.observer_factory.as_ref().map(|factory| factory())
25    }
26}