pub mod message;
mod mutations;
pub mod notifications;
mod queries;
pub use notifications::ContextNotificationRepository;
use sqlx::PgPool;
use std::sync::Arc;
use systemprompt_database::DbPool;
use crate::error::AgentError;
use crate::repository::task::TaskConstructor;
#[derive(Debug, Clone)]
pub struct ContextRepository {
pool: Arc<PgPool>,
write_pool: Arc<PgPool>,
tasks: TaskConstructor,
}
impl ContextRepository {
pub fn new(db: &DbPool) -> Result<Self, AgentError> {
let pool = db.pool_arc().map_err(|e| AgentError::Init(e.to_string()))?;
let write_pool = db
.write_pool_arc()
.map_err(|e| AgentError::Init(e.to_string()))?;
Ok(Self {
pool,
write_pool,
tasks: TaskConstructor::new(db)?,
})
}
}