pub struct SessionManager { /* private fields */ }Expand description
Manages sessions on disk.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new() -> Result<Self, SessionError>
pub fn new() -> Result<Self, SessionError>
Create a new SessionManager with the default sessions directory (~/.talos/sessions/).
Sourcepub fn with_dir(sessions_dir: PathBuf) -> Self
pub fn with_dir(sessions_dir: PathBuf) -> Self
Create a new SessionManager with a custom sessions directory.
Sourcepub fn sessions_dir(&self) -> &Path
pub fn sessions_dir(&self) -> &Path
Return the root directory used for session JSONL files and the colocated index.
Sourcepub fn create_session(
&self,
project: &str,
workspace_root: &str,
) -> Result<Session, SessionError>
pub fn create_session( &self, project: &str, workspace_root: &str, ) -> Result<Session, SessionError>
Create a new session for the given project and workspace.
The session file is created at ~/.talos/sessions/<workspace_dir>/<uuid>.jsonl,
where workspace_dir is a hash of the workspace root path.
Sourcepub fn defer_create_session(
&self,
project: &str,
workspace_root: &str,
) -> Result<Session, SessionError>
pub fn defer_create_session( &self, project: &str, workspace_root: &str, ) -> Result<Session, SessionError>
Prepare a new session without creating the file on disk.
Returns a Session with persisted = false. The JSONL file is
not created until Session::ensure_persisted is called (triggered
automatically on the first message append).
Sourcepub fn get_session(&self, id: &Uuid) -> Result<Session, SessionError>
pub fn get_session(&self, id: &Uuid) -> Result<Session, SessionError>
Load an existing session by ID.
Scans all workspace directories (both old basename and new hashed layouts)
for a file matching <id>.jsonl.
Sourcepub fn list_sessions(&self) -> Result<Vec<SessionInfo>, SessionError>
pub fn list_sessions(&self) -> Result<Vec<SessionInfo>, SessionError>
List all sessions across all workspace directories.
Sourcepub fn list_workspace_sessions(
&self,
workspace_root: &str,
) -> Result<Vec<SessionInfo>, SessionError>
pub fn list_workspace_sessions( &self, workspace_root: &str, ) -> Result<Vec<SessionInfo>, SessionError>
List sessions for one workspace directory.
Sourcepub fn latest_workspace_session(
&self,
workspace_root: &str,
) -> Result<Option<SessionInfo>, SessionError>
pub fn latest_workspace_session( &self, workspace_root: &str, ) -> Result<Option<SessionInfo>, SessionError>
Return the most recently modified session for one workspace directory.
Sourcepub fn resume_session(&self, session_id: &str) -> Result<Session, SessionError>
pub fn resume_session(&self, session_id: &str) -> Result<Session, SessionError>
Resume a session by ID, loading all entries from the JSONL file.
This is equivalent to SessionManager::get_session but with a clearer
name for the “resume” use case.
Sourcepub fn search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SearchResult>, IndexError>
pub fn search( &self, query: &str, limit: usize, ) -> Result<Vec<SearchResult>, IndexError>
Perform a full-text search across all indexed session messages.
Returns results ranked by relevance. The index is created lazily if it does not exist.
Sourcepub fn list_recent(&self, limit: usize) -> Result<Vec<SessionInfo>, IndexError>
pub fn list_recent(&self, limit: usize) -> Result<Vec<SessionInfo>, IndexError>
List the most recently updated sessions from the index.
Returns sessions ordered by last update time, descending.
Sourcepub fn update_index(&self, session: &Session) -> Result<(), IndexError>
pub fn update_index(&self, session: &Session) -> Result<(), IndexError>
Update the search index for a session.
If the index has not been initialized, this is a no-op.
Sourcepub fn checkpoint_index(&self) -> Result<(), IndexError>
pub fn checkpoint_index(&self) -> Result<(), IndexError>
Checkpoint the session index WAL and truncate it where possible.
Sourcepub fn vacuum_index(&self) -> Result<(), IndexError>
pub fn vacuum_index(&self) -> Result<(), IndexError>
Vacuum the session index database.
Sourcepub fn get_forks(&self, session_id: &str) -> Result<Vec<ForkInfo>, IndexError>
pub fn get_forks(&self, session_id: &str) -> Result<Vec<ForkInfo>, IndexError>
Return forks originating from the given session ID.
pub fn reconcile_index(&self) -> Result<usize, IndexError>
pub fn delete_session(&self, id: &Uuid) -> Result<(), SessionError>
Sourcepub fn cleanup_candidates(
&self,
policy: &SessionCleanupPolicy,
) -> Result<Vec<SessionCleanupCandidate>, SessionError>
pub fn cleanup_candidates( &self, policy: &SessionCleanupPolicy, ) -> Result<Vec<SessionCleanupCandidate>, SessionError>
Return sessions that would be removed by policy without deleting files.
Sourcepub fn apply_cleanup(
&self,
policy: &SessionCleanupPolicy,
) -> Result<SessionCleanupReport, SessionError>
pub fn apply_cleanup( &self, policy: &SessionCleanupPolicy, ) -> Result<SessionCleanupReport, SessionError>
Apply a cleanup policy by deleting selected sessions and index rows.
This is an explicit maintenance operation. It never removes IDs listed in
protected_session_ids, even if callers accidentally include an active
session in an otherwise matching policy.
Trait Implementations§
Source§impl Clone for SessionManager
impl Clone for SessionManager
Source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more