mod contract;
mod memory;
use std::sync::Arc;
use async_trait::async_trait;
use starweaver_context::{
AgentCheckpoint, AgentExecutionDecision, AgentExecutor, AgentExecutorError,
};
use starweaver_core::SessionId;
pub use contract::{SessionFilter, SessionStore};
pub use memory::InMemorySessionStore;
#[derive(Clone)]
pub struct SessionStoreExecutor {
store: Arc<dyn SessionStore>,
session_id: SessionId,
}
impl SessionStoreExecutor {
#[must_use]
pub fn new(store: Arc<dyn SessionStore>, session_id: SessionId) -> Self {
Self { store, session_id }
}
#[must_use]
pub const fn session_id(&self) -> &SessionId {
&self.session_id
}
}
#[async_trait]
impl AgentExecutor for SessionStoreExecutor {
async fn checkpoint(
&self,
checkpoint: AgentCheckpoint,
) -> Result<AgentExecutionDecision, AgentExecutorError> {
self.store
.commit_checkpoint(&self.session_id, checkpoint)
.await?;
Ok(AgentExecutionDecision::Continue)
}
}