pub struct SessionManager { /* private fields */ }Implementations§
Source§impl SessionManager
impl SessionManager
pub fn create(cwd: &Path, session_dir: Option<PathBuf>) -> Result<Self>
pub fn in_memory(cwd: &Path) -> Self
Sourcepub fn in_memory_with_entries(cwd: &Path, entries: Vec<SessionEntry>) -> Self
pub fn in_memory_with_entries(cwd: &Path, entries: Vec<SessionEntry>) -> Self
Restore an in-memory session from entries managed by an SDK caller.
pub fn open(path: &Path) -> Result<Self>
pub fn continue_recent(cwd: &Path, session_dir: Option<PathBuf>) -> Result<Self>
pub fn create_sibling(&self) -> Result<Self>
Sourcepub fn create_child(&self) -> Result<Self>
pub fn create_child(&self) -> Result<Self>
Create a child session in the same working directory and session store.
Sourcepub fn fork_from(
source: &Path,
cwd: &Path,
session_dir: Option<PathBuf>,
) -> Result<Self>
pub fn fork_from( source: &Path, cwd: &Path, session_dir: Option<PathBuf>, ) -> Result<Self>
Fork: copy the source session’s entries into a new file for cwd.
Sourcepub fn fork_active_branch(
&self,
through: Option<&str>,
include_through: bool,
) -> Result<Self>
pub fn fork_active_branch( &self, through: Option<&str>, include_through: bool, ) -> Result<Self>
Copy one active branch into a new session file.
through selects the last entry to inspect. When include_through is
false, the new session ends at that entry’s parent. This lets an
interactive caller put a selected user message back in the editor.
pub fn list(cwd: &Path, session_dir: &Path) -> Result<Vec<SessionListing>>
pub fn list_all(session_dir: &Path) -> Result<Vec<SessionListing>>
Sourcepub fn find_by_id(session_dir: &Path, partial: &str) -> Result<Option<PathBuf>>
pub fn find_by_id(session_dir: &Path, partial: &str) -> Result<Option<PathBuf>>
Find a session file by partial UUID across all projects.
pub fn append_message(&mut self, message: AgentMessage) -> Result<String>
pub fn append_messages_with_session_info<I>(
&mut self,
messages: I,
name: &str,
) -> Result<()>where
I: IntoIterator<Item = AgentMessage>,
pub fn append_model_change( &mut self, provider: &str, model_id: &str, ) -> Result<String>
pub fn append_thinking_level_change( &mut self, level: ThinkingLevel, ) -> Result<String>
pub fn append_usage( &mut self, kind: &str, provider: &str, model: &str, usage: Usage, note: Option<String>, ) -> Result<String>
pub fn append_compaction( &mut self, summary: String, tokens_before: u64, retained_tail: Vec<AgentMessage>, usage: Option<Usage>, details: Option<Value>, ) -> Result<String>
pub fn append_session_info(&mut self, name: &str) -> Result<String>
pub fn append_label( &mut self, target_id: &str, label: Option<String>, ) -> Result<String>
pub fn append_custom( &mut self, custom_type: &str, data: Option<Value>, ) -> Result<String>
pub fn get_entry(&self, id: &str) -> Option<&SessionEntry>
pub fn entries(&self) -> &[SessionEntry]
pub fn leaf_id(&self) -> Option<&str>
Sourcepub fn context_revision(&self) -> u64
pub fn context_revision(&self) -> u64
Monotonic value for cache invalidation after context or tree changes.
Sourcepub fn branch(&mut self, entry_id: &str) -> Result<()>
pub fn branch(&mut self, entry_id: &str) -> Result<()>
Move the leaf to an earlier entry (in-place branching).
Sourcepub fn reset_leaf(&mut self)
pub fn reset_leaf(&mut self)
Reset the leaf to before any entries.
Sourcepub fn branch_with_summary(
&mut self,
entry_id: Option<&str>,
from_id: &str,
summary: String,
usage: Option<Usage>,
details: Option<Value>,
) -> Result<String>
pub fn branch_with_summary( &mut self, entry_id: Option<&str>, from_id: &str, summary: String, usage: Option<Usage>, details: Option<Value>, ) -> Result<String>
Branch to entry_id and record a summary of the abandoned path.
pub fn children(&self, parent_id: Option<&str>) -> Vec<&SessionEntry>
Sourcepub fn branch_entries(&self, from: Option<&str>) -> Vec<&SessionEntry>
pub fn branch_entries(&self, from: Option<&str>) -> Vec<&SessionEntry>
Walk leaf -> root. Returns entries in root-first order.
Sourcepub fn branch_messages_after(
&self,
from: &str,
ancestor: Option<&str>,
) -> Vec<AgentMessage>
pub fn branch_messages_after( &self, from: &str, ancestor: Option<&str>, ) -> Vec<AgentMessage>
LLM messages on one branch after an optional common ancestor.
Sourcepub fn session_name(&self) -> Option<String>
pub fn session_name(&self) -> Option<String>
Latest session name on the active path.
pub fn label_of(&self, target: &str) -> Option<String>
Sourcepub fn build_context_entries(&self) -> Vec<&SessionEntry>
pub fn build_context_entries(&self) -> Vec<&SessionEntry>
Active-branch entries with compaction applied: on a compaction with a retained tail, the checkpoint replaces everything before it.
Sourcepub fn build_session_context(&self) -> SessionContext
pub fn build_session_context(&self) -> SessionContext
Messages + model + thinking level for the next LLM call.
Sourcepub fn build_openai_compaction_context(
&self,
model: &Model,
) -> Option<OpenAICompactionContext>
pub fn build_openai_compaction_context( &self, model: &Model, ) -> Option<OpenAICompactionContext>
Restore provider-native OpenAI history from the latest compaction on the active branch. Completed turns from another model are excluded.
pub fn header(&self) -> &SessionHeader
pub fn session_id(&self) -> &str
pub fn session_file(&self) -> Option<&Path>
pub fn cwd(&self) -> &Path
pub fn session_dir(&self) -> &Path
pub fn is_persisted(&self) -> bool
Sourcepub fn usage_totals(&self) -> Usage
pub fn usage_totals(&self) -> Usage
Sum every provider operation recorded in this append-only session.
Auto Trait Implementations§
impl Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe for SessionManager
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> 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