pub struct Session { /* private fields */ }Implementations§
Source§impl Session
impl Session
pub fn create(dir: &Path) -> Result<Session>
Sourcepub fn create_with_cwd(dir: &Path, cwd: &Path) -> Result<Session>
pub fn create_with_cwd(dir: &Path, cwd: &Path) -> Result<Session>
Like [create], but records cwd in the session header instead of the
process working directory. An agent whose tools run against a custom
working_dir (see AgentConfig.working_dir) should stamp that same
directory here so a resumed session’s header agrees with where the tools
actually ran — otherwise the header’s cwd describes a directory the
tools never touched.
Sourcepub fn create_named(dir: &Path, name: &str) -> Result<Session>
pub fn create_named(dir: &Path, name: &str) -> Result<Session>
Like [create], but the file is exactly <dir>/<name>.jsonl — the
deterministic tree session groups need (root.jsonl, members/<name>.jsonl),
where a {millis}_{uuid8} name would not map back to an address. Header
content identical to [create_with_cwd]; only the file name is caller-
supplied.
Sourcepub fn create_named_with_cwd(
dir: &Path,
name: &str,
cwd: &Path,
) -> Result<Session>
pub fn create_named_with_cwd( dir: &Path, name: &str, cwd: &Path, ) -> Result<Session>
[create_named] with an explicit cwd (see [create_with_cwd]).
pub fn open(path: &Path) -> Result<Session>
pub fn in_memory() -> Session
pub fn append(&mut self, e: SessionEntry) -> Result<()>
pub fn entries(&self) -> &[SessionEntry]
pub fn messages(&self) -> Vec<AgentMessage>
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Number of persisted Message entries — the ordinal space that
SessionEntry::Compaction::first_kept_message indexes into.
Sourcepub fn record_compaction(
&mut self,
summary: &str,
kept_messages: usize,
tokens_before: Option<u64>,
usage: Option<Usage>,
) -> Result<()>
pub fn record_compaction( &mut self, summary: &str, kept_messages: usize, tokens_before: Option<u64>, usage: Option<Usage>, ) -> Result<()>
Record a compaction: summary stands in for every Message before the
most recent kept_messages, which stay. The boundary ordinal is derived
from the current message count, so it stays correct as messages append.
pub fn path(&self) -> Option<&Path>
pub fn model(&self) -> Option<String>
pub fn effort(&self) -> Option<Option<String>>
Sourcepub fn todo(&self) -> Option<Vec<TodoItem>>
pub fn todo(&self) -> Option<Vec<TodoItem>>
The most recently persisted checklist, if any (None = never written).
Last write wins, like Self::model/Self::effort.