systemprompt_agent/
state.rs1use std::sync::Arc;
7use systemprompt_database::DbPool;
8use systemprompt_models::Config;
9use systemprompt_traits::DynJwtValidationProvider;
10
11use crate::repository::A2ARepositories;
12use crate::services::a2a_server::streaming::webhook_client::DynWebhookBroadcaster;
13
14#[derive(Clone)]
15pub struct AgentState {
16 db_pool: DbPool,
17 config: Arc<Config>,
18 jwt_provider: DynJwtValidationProvider,
19 repositories: Arc<A2ARepositories>,
20 webhooks: DynWebhookBroadcaster,
21}
22
23impl AgentState {
24 #[must_use]
25 pub fn new(
26 db_pool: DbPool,
27 config: Arc<Config>,
28 jwt_provider: DynJwtValidationProvider,
29 repositories: Arc<A2ARepositories>,
30 webhooks: DynWebhookBroadcaster,
31 ) -> Self {
32 Self {
33 db_pool,
34 config,
35 jwt_provider,
36 repositories,
37 webhooks,
38 }
39 }
40
41 #[must_use]
42 pub const fn db_pool(&self) -> &DbPool {
43 &self.db_pool
44 }
45
46 #[must_use]
47 pub fn config(&self) -> &Config {
48 &self.config
49 }
50
51 #[must_use]
52 pub fn jwt_provider(&self) -> &DynJwtValidationProvider {
53 &self.jwt_provider
54 }
55
56 #[must_use]
57 pub const fn repositories(&self) -> &Arc<A2ARepositories> {
58 &self.repositories
59 }
60
61 #[must_use]
62 pub fn webhooks(&self) -> DynWebhookBroadcaster {
63 Arc::clone(&self.webhooks)
64 }
65}
66
67impl std::fmt::Debug for AgentState {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 f.debug_struct("AgentState")
70 .field("db_pool", &"<DbPool>")
71 .field("config", &"<Arc<Config>>")
72 .field("jwt_provider", &"<DynJwtValidationProvider>")
73 .field("repositories", &"<A2ARepositories>")
74 .field("webhooks", &self.webhooks)
75 .finish()
76 }
77}