pub struct SessionStore { /* private fields */ }Expand description
Persists SessionSnapshot JSON files to disk under <data_dir>/sessions/.
By default, secret redaction is enabled so API keys and tokens are scrubbed from saved event text.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn with_redaction(data_dir: PathBuf, redact_secrets: bool) -> Self
pub fn with_redaction(data_dir: PathBuf, redact_secrets: bool) -> Self
Creates a new store with the given redaction setting.
Sourcepub fn create_id() -> SessionId
pub fn create_id() -> SessionId
Generates a session id that is unique across concurrent NAVI instances.
The timestamp keeps ids naturally ordered, while the process id, in-process sequence, and random nonce prevent two agents started in the same millisecond from sharing a provider cache-affinity identity.
Sourcepub fn save(&self, snapshot: &SessionSnapshot) -> Result<PathBuf>
pub fn save(&self, snapshot: &SessionSnapshot) -> Result<PathBuf>
Serializes and saves a snapshot to disk, creating the sessions directory if needed. Applies secret redaction unless disabled.
This is the blocking implementation used internally and in tests. Use
Self::save_async from async contexts to avoid blocking the Tokio
runtime.
Sourcepub async fn save_async(&self, snapshot: SessionSnapshot) -> Result<PathBuf>
pub async fn save_async(&self, snapshot: SessionSnapshot) -> Result<PathBuf>
Async wrapper around Self::save that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn list(&self) -> Vec<SessionSnapshot>
pub fn list(&self) -> Vec<SessionSnapshot>
Loads all saved sessions from disk, sorted by most recently updated first.
Sourcepub fn list_info(&self) -> Vec<SessionSnapshotInfo>
pub fn list_info(&self) -> Vec<SessionSnapshotInfo>
Loads only session metadata from disk, sorted by most recently updated first.
Sourcepub async fn list_async(&self) -> Vec<SessionSnapshot>
pub async fn list_async(&self) -> Vec<SessionSnapshot>
Async wrapper around Self::list that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub async fn list_info_async(&self) -> Vec<SessionSnapshotInfo>
pub async fn list_info_async(&self) -> Vec<SessionSnapshotInfo>
Async wrapper around Self::list_info that avoids blocking the async runtime.
Sourcepub fn load(&self, session_id: &str) -> Result<SessionSnapshot>
pub fn load(&self, session_id: &str) -> Result<SessionSnapshot>
Loads a single session by id. Returns an error if the file is missing or the snapshot version is newer than supported.
Sourcepub async fn load_async(&self, session_id: String) -> Result<SessionSnapshot>
pub async fn load_async(&self, session_id: String) -> Result<SessionSnapshot>
Async wrapper around Self::load that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn delete(&self, session_id: &str) -> Result<bool>
pub fn delete(&self, session_id: &str) -> Result<bool>
Deletes the session file. Returns true if the file existed and was removed.
Sourcepub fn rename(&self, session_id: &str, title: &str) -> Result<bool>
pub fn rename(&self, session_id: &str, title: &str) -> Result<bool>
Renames a saved session by updating its title field in the snapshot.
Returns true if the session existed and was updated.
Sourcepub async fn rename_async(
&self,
session_id: String,
title: String,
) -> Result<bool>
pub async fn rename_async( &self, session_id: String, title: String, ) -> Result<bool>
Async wrapper around Self::rename.
Sourcepub async fn delete_async(&self, session_id: String) -> Result<bool>
pub async fn delete_async(&self, session_id: String) -> Result<bool>
Async wrapper around Self::delete that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn save_memory(
&self,
project_dir: &Path,
memory: &ProjectMemory,
) -> Result<PathBuf>
pub fn save_memory( &self, project_dir: &Path, memory: &ProjectMemory, ) -> Result<PathBuf>
Persists project memory to <data_dir>/memory/<hash>.json.
Sourcepub async fn save_memory_async(
&self,
project_dir: PathBuf,
memory: ProjectMemory,
) -> Result<PathBuf>
pub async fn save_memory_async( &self, project_dir: PathBuf, memory: ProjectMemory, ) -> Result<PathBuf>
Async wrapper around Self::save_memory that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Sourcepub fn load_memory(&self, project_dir: &Path) -> Option<ProjectMemory>
pub fn load_memory(&self, project_dir: &Path) -> Option<ProjectMemory>
Loads project memory from disk, returning None if no memory file exists.
Sourcepub async fn load_memory_async(
&self,
project_dir: PathBuf,
) -> Option<ProjectMemory>
pub async fn load_memory_async( &self, project_dir: PathBuf, ) -> Option<ProjectMemory>
Async wrapper around Self::load_memory that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Sourcepub fn add_memory_entry(
&self,
project_dir: &Path,
session_id: &SessionId,
summary: String,
) -> Result<PathBuf>
pub fn add_memory_entry( &self, project_dir: &Path, session_id: &SessionId, summary: String, ) -> Result<PathBuf>
Appends a new memory entry for the project and persists it to disk.
Sourcepub async fn add_memory_entry_async(
&self,
project_dir: PathBuf,
session_id: String,
summary: String,
) -> Result<PathBuf>
pub async fn add_memory_entry_async( &self, project_dir: PathBuf, session_id: String, summary: String, ) -> Result<PathBuf>
Async wrapper around Self::add_memory_entry that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Auto Trait Implementations§
impl Freeze for SessionStore
impl RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl UnwindSafe for SessionStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more