pub struct SessionManager { /* private fields */ }Expand description
SessionManager: entries form a tree through id/parentId; the leaf is the current position.
Appends add a child of the leaf; branching moves the leaf. Persisted sessions are written only once
the first assistant message exists, then appended line by line.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn create(
env: Box<dyn Env>,
cwd: &str,
session_dir: Option<&str>,
options: Option<NewSessionOptions>,
) -> Result<Self, Error>
pub fn create( env: Box<dyn Env>, cwd: &str, session_dir: Option<&str>, options: Option<NewSessionOptions>, ) -> Result<Self, Error>
create: a new persisted session in session_dir (default: the cwd’s dir under the agent dir).
Sourcepub fn open(
env: Box<dyn Env>,
path: &str,
session_dir: Option<&str>,
cwd_override: Option<&str>,
) -> Result<Self, Error>
pub fn open( env: Box<dyn Env>, path: &str, session_dir: Option<&str>, cwd_override: Option<&str>, ) -> Result<Self, Error>
open: a specific session file. The cwd comes from cwd_override, else the header, else
the process cwd; session_dir defaults to the file’s directory.
Sourcepub fn in_memory(
env: Box<dyn Env>,
cwd: &str,
options: Option<NewSessionOptions>,
entries: Option<Vec<Value>>,
) -> Result<Self, Error>
pub fn in_memory( env: Box<dyn Env>, cwd: &str, options: Option<NewSessionOptions>, entries: Option<Vec<Value>>, ) -> Result<Self, Error>
inMemory: a session that is never written, optionally adopting stored entries.
Sourcepub fn fork_from(
env: Box<dyn Env>,
source_path: &str,
target_cwd: &str,
session_dir: Option<&str>,
options: Option<NewSessionOptions>,
) -> Result<Self, Error>
pub fn fork_from( env: Box<dyn Env>, source_path: &str, target_cwd: &str, session_dir: Option<&str>, options: Option<NewSessionOptions>, ) -> Result<Self, Error>
forkFrom: copies another session’s entries into a new session for target_cwd.
Sourcepub fn new_session(
&mut self,
options: Option<NewSessionOptions>,
) -> Result<Option<String>, Error>
pub fn new_session( &mut self, options: Option<NewSessionOptions>, ) -> Result<Option<String>, Error>
newSession: a fresh header and no entries. Returns the new session file path (persisted only).
Sourcepub fn append_message(&mut self, message: Value) -> Result<String, Error>
pub fn append_message(&mut self, message: Value) -> Result<String, Error>
appendMessage: a message entry as child of the leaf. Returns its id.
Sourcepub fn session_name(&self) -> Option<String>
pub fn session_name(&self) -> Option<String>
getSessionName: the latest session_info name; empty clears it.
Sourcepub fn branch(&mut self, branch_from_id: &str) -> Result<(), Error>
pub fn branch(&mut self, branch_from_id: &str) -> Result<(), Error>
branch: moves the leaf to an earlier entry; the next append starts a new branch there.
Sourcepub fn reset_leaf(&mut self)
pub fn reset_leaf(&mut self)
resetLeaf: the next append creates a new root.
pub fn cwd(&self) -> &str
pub fn session_dir(&self) -> &str
pub fn session_id(&self) -> &str
pub fn session_file(&self) -> Option<&str>
Sourcepub fn leaf_id(&self) -> Option<&Value>
pub fn leaf_id(&self) -> Option<&Value>
The leaf id; None before the first entry (or after reset_leaf).
pub fn entry(&self, id: &str) -> Option<&Value>
Sourcepub fn children(&self, parent_id: &str) -> Vec<&Value>
pub fn children(&self, parent_id: &str) -> Vec<&Value>
getChildren: direct children in index order.
pub fn label(&self, id: &str) -> Option<&Value>
Sourcepub fn branch_entries(&self, from_id: Option<&str>) -> Vec<&Value>
pub fn branch_entries(&self, from_id: Option<&str>) -> Vec<&Value>
getBranch: root-first path to from_id (default: the leaf).
Sourcepub fn build_context_entries(&self) -> Vec<&Value>
pub fn build_context_entries(&self) -> Vec<&Value>
buildContextEntries from the leaf.
Sourcepub fn build_session_projection(&self) -> SessionProjection<'_>
pub fn build_session_projection(&self) -> SessionProjection<'_>
buildSessionProjection from the leaf.
Sourcepub fn build_session_context(&self) -> SessionContext
pub fn build_session_context(&self) -> SessionContext
buildSessionContext from the leaf.