Skip to main content

Module session

Module session 

Source
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§

ProjectedEntry
One context entry of a branch and the messages it contributes after edits.
Projection
The context of a branch, entry by entry.
SessionContext
The model context a branch produces.
SessionManager
A session: its entries, where it is stored, and the current leaf.
SessionSummary
Summary of a session file, for listings.
SessionTree
Every entry of a session as a tree, stored flat.
TreeNode
One entry of a SessionTree.

Enums§

SessionError
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 dir with exactly this id, from cwd when given.
find_most_recent
The most recently modified session file in dir, from cwd when given.
list
Sessions in dir, latest activity first, only those from cwd when 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.