mod file_store;
mod memory_store;
mod session_data;
#[cfg(test)]
mod tests;
pub use file_store::FileSessionStore;
pub use memory_store::MemorySessionStore;
pub use session_data::{
ContextUsage, LlmConfigData, SessionConfig, SessionData, SessionState,
DEFAULT_AUTO_COMPACT_THRESHOLD,
};
use crate::loop_checkpoint::LoopCheckpoint;
use crate::run::RunRecord;
use crate::subagent_task_tracker::SubagentTaskSnapshot;
use crate::tools::ArtifactStore;
use crate::trace::TraceEvent;
use crate::verification::VerificationReport;
use anyhow::Result;
#[async_trait::async_trait]
pub trait SessionStore: Send + Sync {
async fn save(&self, session: &SessionData) -> Result<()>;
async fn load(&self, id: &str) -> Result<Option<SessionData>>;
async fn delete(&self, id: &str) -> Result<()>;
async fn list(&self) -> Result<Vec<String>>;
async fn exists(&self, id: &str) -> Result<bool>;
async fn save_artifacts(&self, _id: &str, _artifacts: &ArtifactStore) -> Result<()> {
Ok(())
}
async fn load_artifacts(&self, _id: &str) -> Result<Option<ArtifactStore>> {
Ok(None)
}
async fn save_trace_events(&self, _id: &str, _events: &[TraceEvent]) -> Result<()> {
Ok(())
}
async fn load_trace_events(&self, _id: &str) -> Result<Option<Vec<TraceEvent>>> {
Ok(None)
}
async fn save_run_records(&self, _id: &str, _records: &[RunRecord]) -> Result<()> {
Ok(())
}
async fn load_run_records(&self, _id: &str) -> Result<Option<Vec<RunRecord>>> {
Ok(None)
}
async fn save_verification_reports(
&self,
_id: &str,
_reports: &[VerificationReport],
) -> Result<()> {
Ok(())
}
async fn load_verification_reports(
&self,
_id: &str,
) -> Result<Option<Vec<VerificationReport>>> {
Ok(None)
}
async fn save_subagent_tasks(&self, _id: &str, _tasks: &[SubagentTaskSnapshot]) -> Result<()> {
Ok(())
}
async fn load_subagent_tasks(&self, _id: &str) -> Result<Option<Vec<SubagentTaskSnapshot>>> {
Ok(None)
}
async fn save_loop_checkpoint(
&self,
_run_id: &str,
_checkpoint: &LoopCheckpoint,
) -> Result<()> {
Ok(())
}
async fn load_loop_checkpoint(&self, _run_id: &str) -> Result<Option<LoopCheckpoint>> {
Ok(None)
}
async fn delete_loop_checkpoint(&self, _run_id: &str) -> Result<()> {
Ok(())
}
async fn save_workflow_checkpoint(
&self,
_workflow_id: &str,
_checkpoint: &crate::orchestration::WorkflowCheckpoint,
) -> Result<()> {
Ok(())
}
async fn load_workflow_checkpoint(
&self,
_workflow_id: &str,
) -> Result<Option<crate::orchestration::WorkflowCheckpoint>> {
Ok(None)
}
async fn delete_workflow_checkpoint(&self, _workflow_id: &str) -> Result<()> {
Ok(())
}
async fn health_check(&self) -> Result<()> {
Ok(())
}
fn backend_name(&self) -> &str {
"unknown"
}
}