#[cfg(target_arch = "wasm32")]
pub mod tokio {
pub use tokio_with_wasm::alias::*;
}
pub mod adapter;
pub mod blob;
mod error;
#[cfg(not(target_arch = "wasm32"))]
pub mod index;
#[cfg(not(target_arch = "wasm32"))]
pub mod realm;
#[cfg(all(feature = "jsonl", not(target_arch = "wasm32")))]
pub mod jsonl;
#[cfg(feature = "memory")]
pub mod memory;
#[cfg(not(target_arch = "wasm32"))]
pub mod redb_store;
#[cfg(all(feature = "sqlite", not(target_arch = "wasm32")))]
pub mod sqlite_store;
pub use adapter::StoreAdapter;
pub use blob::MemoryBlobStore;
pub use error::StoreError;
#[cfg(not(target_arch = "wasm32"))]
pub use blob::FsBlobStore;
#[cfg(not(target_arch = "wasm32"))]
pub use index::SessionIndex;
#[cfg(not(target_arch = "wasm32"))]
pub use realm::{
REALM_LEASE_HEARTBEAT_SECS, REALM_LEASE_STALE_TTL_SECS, RealmBackend, RealmLeaseGuard,
RealmLeaseRecord, RealmLeaseStatus, RealmManifest, RealmManifestEntry, RealmOrigin, RealmPaths,
derive_workspace_realm_id, ensure_realm_manifest, ensure_realm_manifest_in, fnv1a64_hex,
generate_realm_id, inspect_realm_leases, inspect_realm_leases_in, list_realm_manifests_in,
open_realm_session_store, open_realm_session_store_in, realm_lease_dir, realm_paths,
realm_paths_in, sanitize_realm_id, start_realm_lease, start_realm_lease_in,
};
#[cfg(not(target_arch = "wasm32"))]
pub use redb_store::RedbSessionStore;
#[cfg(all(feature = "sqlite", not(target_arch = "wasm32")))]
pub use sqlite_store::SqliteSessionStore;
use async_trait::async_trait;
use meerkat_core::time_compat::SystemTime;
use meerkat_core::{Session, SessionId, SessionMeta};
#[derive(Debug, Clone, Default)]
pub struct SessionFilter {
pub created_after: Option<SystemTime>,
pub updated_after: Option<SystemTime>,
pub limit: Option<usize>,
pub offset: Option<usize>,
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait SessionStore: Send + Sync {
async fn save(&self, session: &Session) -> Result<(), StoreError>;
async fn load(&self, id: &SessionId) -> Result<Option<Session>, StoreError>;
async fn list(&self, filter: SessionFilter) -> Result<Vec<SessionMeta>, StoreError>;
async fn delete(&self, id: &SessionId) -> Result<(), StoreError>;
async fn exists(&self, id: &SessionId) -> Result<bool, StoreError> {
Ok(self.load(id).await?.is_some())
}
}
#[cfg(all(feature = "jsonl", not(target_arch = "wasm32")))]
pub use jsonl::JsonlStore;
#[cfg(feature = "memory")]
pub use memory::MemoryStore;