Skip to main content

orcs_runtime/session/
mod.rs

1//! Session persistence and storage.
2//!
3//! This module provides session management with the following design principles:
4//!
5//! - **Abstraction**: [`SessionStore`] trait for pluggable storage backends
6//! - **Local First**: Works fully offline with [`LocalFileStore`]
7//! - **Cloud Ready**: Sync can be added via trait implementation
8//!
9//! # Architecture
10//!
11//! ```text
12//! ┌─────────────────────────────────────────────────────────────┐
13//! │                    Application Layer                        │
14//! │  SessionAsset, ConversationHistory, ProjectContext          │
15//! └─────────────────────────────────────────────────────────────┘
16//!                            │
17//!                            ▼
18//! ┌─────────────────────────────────────────────────────────────┐
19//! │                    Storage Abstraction                      │
20//! │  SessionStore trait                                         │
21//! └─────────────────────────────────────────────────────────────┘
22//!                            │
23//!           ┌────────────────┴────────────────┐
24//!           ▼                                 ▼
25//!     ┌──────────┐                     ┌──────────┐
26//!     │  Local   │                     │  Remote  │
27//!     │  Store   │                     │  Store   │
28//!     └──────────┘                     └──────────┘
29//! ```
30//!
31//! # Example
32//!
33//! ```no_run
34//! use orcs_runtime::session::{SessionStore, LocalFileStore, SessionAsset};
35//! use std::path::PathBuf;
36//!
37//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
38//! // Create a local store
39//! let store = LocalFileStore::new(PathBuf::from("~/.orcs/sessions"))?;
40//!
41//! // Create and save a session
42//! let mut asset = SessionAsset::new();
43//! store.save(&asset).await?;
44//!
45//! // List all sessions
46//! let sessions = store.list().await?;
47//!
48//! // Load a specific session
49//! let loaded = store.load(&asset.id).await?;
50//! # Ok(())
51//! # }
52//! ```
53
54mod asset;
55mod error;
56mod local;
57mod store;
58
59pub use asset::{
60    AutoTriggerConfig, CodingStylePrefs, CommunicationPrefs, CompactedTurn, ConversationHistory,
61    ConversationTurn, LearnedFact, ProjectContext, SessionAsset, SkillConfig, ToolCallRecord,
62    TriggerCondition, UserPreferences,
63};
64pub use error::StorageError;
65pub use local::{default_session_path, LocalFileStore};
66pub use store::{SessionMeta, SessionStore, SyncMode, SyncState, SyncStatus};