Skip to main content

oino_session/
lib.rs

1//! `oino-session`: session format v3 for Oino.
2//!
3//! Session files are JSONL: a `"type":"session"` header followed by tree entries linked by
4//! `id`/`parentId`. This crate owns the line types, LLM conversion of coding-agent messages,
5//! the pure context-building rules, migration (v1/v2 and pre-v1 Oino files) and — behind
6//! the default `manager` feature — the synchronous [`SessionManager`] (D20). Without
7//! `manager` the crate is pure and builds for `wasm32-wasip2`.
8//!
9//! # API map
10//!
11//! | Module | Contents |
12//! |---|---|
13//! | [`entry`] | [`SessionHeader`], [`SessionEntry`], [`EntryKind`], [`EntryId`], [`IsoTimestamp`], [`FileLine`] |
14//! | [`messages`] | [`convert_to_llm`], summary prefixes, `bashExecutionToText` |
15//! | [`context`] | [`EntryIndex`], [`SessionProjection`], [`SessionContext`] |
16//! | [`migrate`] | [`migrate::detect`], [`migrate::parse_session_text`], legacy Oino mapping |
17//! | [`manager`] (feature) | [`SessionManager`], listing, [`ReadonlySession`] |
18//! | [`time`] | ISO formatting/parsing |
19//!
20//! Files live at `<sessions root>/--<cwd>--/<ts>_<sessionId>.jsonl` and are append-only; a
21//! file is created only once the first user or assistant message exists.
22
23#![forbid(unsafe_code)]
24#![cfg_attr(
25    test,
26    allow(
27        clippy::unwrap_used,
28        clippy::expect_used,
29        clippy::panic,
30        reason = "tests assert by unwrapping"
31    )
32)]
33
34pub mod context;
35pub mod entry;
36mod error;
37#[cfg(feature = "manager")]
38pub mod manager;
39pub mod messages;
40pub mod migrate;
41pub mod time;
42
43pub use context::{
44    BranchSelection, EntryIndex, ModelRef, ProjectedEntry, SessionContext, SessionProjection,
45    branch_selection, build_context_entries, build_session_context, build_session_projection,
46    entry_to_context_messages, latest_compaction, path_to,
47};
48pub use entry::{
49    BranchSummaryEntry, CURRENT_SESSION_VERSION, CompactionEntry, ContextReplacement,
50    EditableContent, EntryId, EntryKind, FileLine, IsoTimestamp, SessionEntry, SessionHeader,
51};
52pub use error::SessionError;
53#[cfg(feature = "manager")]
54pub use error::SessionLockError;
55#[cfg(feature = "manager")]
56pub use manager::{
57    BranchSummaryDraft, CompactionDraft, CreateOptions, INTERRUPTED_TOOL_TEXT, LeaseInfo,
58    MigratedSession, ProgressSink, RESUME_REPAIR_TYPE, ReadonlySession, RepairReport, SessionInfo,
59    SessionLease, SessionManager, SessionTreeNode, TOOL_DISPATCH_TYPE, TakeoverRequest,
60    clear_takeover_request, lock_file_path, lock_metadata_path, read_takeover_request,
61    takeover_path, write_takeover_request,
62};
63pub use messages::{
64    BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, COMPACTION_SUMMARY_PREFIX,
65    COMPACTION_SUMMARY_SUFFIX, convert_to_llm,
66};
67pub use migrate::{FileFormat, MigrationWarning};