Skip to main content

systemprompt_extension/
context.rs

1//! Runtime context handed to extensions during router resolution.
2
3use std::sync::Arc;
4use systemprompt_traits::{ConfigProvider, DatabaseHandle};
5
6pub trait ExtensionContext: Send + Sync {
7    fn config(&self) -> Arc<dyn ConfigProvider>;
8
9    fn database(&self) -> Arc<dyn DatabaseHandle>;
10
11    fn get_extension(&self, id: &str) -> Option<Arc<dyn crate::Extension>>;
12
13    fn has_extension(&self, id: &str) -> bool {
14        self.get_extension(id).is_some()
15    }
16}
17
18pub type DynExtensionContext = Arc<dyn ExtensionContext>;