Skip to main content

systemprompt_extension/
context.rs

1//! Runtime context handed to extensions during router resolution.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use std::sync::Arc;
7use systemprompt_traits::{ConfigProvider, DatabaseHandle};
8
9pub trait ExtensionContext: Send + Sync {
10    fn system_owner_id(&self) -> systemprompt_identifiers::UserId;
11
12    fn config(&self) -> Arc<dyn ConfigProvider>;
13
14    fn database(&self) -> Arc<dyn DatabaseHandle>;
15
16    fn get_extension(&self, id: &str) -> Option<Arc<dyn crate::Extension>>;
17
18    fn has_extension(&self, id: &str) -> bool {
19        self.get_extension(id).is_some()
20    }
21}
22
23pub type DynExtensionContext = Arc<dyn ExtensionContext>;