Expand description
Session files: a JSONL tree of entries with a movable leaf.
Port of packages/coding-agent/src/core/session-manager.ts in pi v1.0.0.
Entries are kept as order-preserving documents so a migration rewrites files the
way pi does. Typed views are parsed alongside. A new session reaches disk only
once it has a user or assistant message.
Structs§
- Projected
Entry - One context entry of a branch and the messages it contributes after edits.
- Projection
- The context of a branch, entry by entry.
- Session
Context - The model context a branch produces.
- Session
Manager - A session: its entries, where it is stored, and the current leaf.
- Session
Summary - Summary of a session file, for listings.
- Session
Tree - Every entry of a session as a tree, stored flat.
- Tree
Node - One entry of a
SessionTree.
Enums§
- Session
Error - Session file errors.
Functions§
- build_
context - The model context of a branch path (see
build_projection). - build_
projection - Projects a branch path: the last compaction, the entries it keeps, then later entries, with context edits applied and model and thinking level as last set.
- find_
by_ id - The session file in
dirwith exactly this id, fromcwdwhen given. - find_
most_ recent - The most recently modified session file in
dir, fromcwdwhen given. - list
- Sessions in
dir, latest activity first, only those fromcwdwhen given. - list_
all - Sessions of every project: the session files in each directory under
root, latest activity first. - validate_
session_ id - Whether a session id is valid: alphanumeric at both ends, with
.,_and-inside.