pub struct Session<M>where
M: AgentMessage,{ /* private fields */ }Expand description
Session manager: JSONL persistence, history access, context trimming.
Uses Claude Code compatible JSONL format with UUID v7 (time-sortable).
Implementations§
Source§impl<M> Session<M>where
M: AgentMessage,
impl<M> Session<M>where
M: AgentMessage,
Sourcepub fn new(session_dir: &str, max_history: usize) -> Result<Session<M>, Error>
pub fn new(session_dir: &str, max_history: usize) -> Result<Session<M>, Error>
Create a new session with a fresh JSONL file.
Creates the session directory if it doesn’t exist. Returns an error if the directory cannot be created.
Sourcepub fn resume(path: &Path, _session_dir: &str, max_history: usize) -> Session<M>
pub fn resume(path: &Path, _session_dir: &str, max_history: usize) -> Session<M>
Resume from a specific session file.
Sourcepub fn resume_last(session_dir: &str, max_history: usize) -> Option<Session<M>>
pub fn resume_last(session_dir: &str, max_history: usize) -> Option<Session<M>>
Resume the most recent session in the session directory.
Sourcepub fn push(&mut self, role: <M as AgentMessage>::Role, content: String) -> &M
pub fn push(&mut self, role: <M as AgentMessage>::Role, content: String) -> &M
Push a message, persist to JSONL, return ref.
Sourcepub fn messages_mut(&mut self) -> &mut Vec<M>
pub fn messages_mut(&mut self) -> &mut Vec<M>
Mutable access to messages (for external trimming).
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn session_file(&self) -> &Path
pub fn session_id(&self) -> &str
Auto Trait Implementations§
impl<M> Freeze for Session<M>
impl<M> RefUnwindSafe for Session<M>where
M: RefUnwindSafe,
impl<M> Send for Session<M>where
M: Send,
impl<M> Sync for Session<M>where
M: Sync,
impl<M> Unpin for Session<M>where
M: Unpin,
impl<M> UnsafeUnpin for Session<M>
impl<M> UnwindSafe for Session<M>where
M: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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