session_file/lib.rs
1//! Ultron's session persistence format: the Pi session JSONL written by the TypeScript
2//! `SessionManager` (`packages/coding-agent/src/core/session-manager.ts`).
3//!
4//! A session file is one JSON value per line: a `session` header (`version` 3), then entries that
5//! form a tree through `id`/`parentId`. Files from versions 1 and 2 are migrated and rewritten on
6//! load. Lines are written exactly as `JSON.stringify` writes them, so files stay byte-compatible
7//! with the TypeScript implementation in both directions.
8//!
9//! Entries are kept as JSON values rather than typed structs: unknown fields and entry types from
10//! newer or older writers survive a load/rewrite unchanged.
11
12mod context;
13mod env;
14mod file;
15pub mod js;
16mod manager;
17mod paths;
18
19pub use context::{
20 Leaf, ProjectedEntry, SessionContext, SessionProjection, build_context_entries, build_session_context,
21 build_session_projection, current_system_message, current_tools, entry_messages,
22};
23pub use env::{Env, SystemEnv};
24pub use file::{
25 CURRENT_SESSION_VERSION, HeaderScanError, SessionInfo, default_session_dir, default_session_dir_path,
26 find_most_recent_session, find_session_by_id, list_all_sessions, list_sessions, load_entries_from_file,
27 migrate_session_entries, migrate_sessions_from_agent_root, parse_session_entries, read_session_header,
28};
29pub use manager::{Error, NewSessionOptions, SessionManager, SessionTree, TreeNode};