1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Session-based memory for AI agents.
//!
//! The [`Session`] trait abstracts over storage backends, treating the
//! **message list as the single source of truth** for conversation history.
//! Agents stay stateless — all context lives in the session.
//!
//! # Available Backends
//!
//! | Type | Persistence | Feature |
//! |------|-------------|---------|
//! | [`InMemorySession`] | None (ephemeral) | always |
//! | [`SqliteSession`] | File or `:memory:` | `memory-sqlite` |
//!
//! # Quick Start
//!
//! ```rust
//! # tokio_test::block_on(async {
//! use machi::memory::{Session, InMemorySession};
//! use machi::message::Message;
//!
//! let session = InMemorySession::new("conv-1");
//!
//! session.add_messages(&[
//! Message::system("You are a helpful assistant."),
//! Message::user("What is Rust?"),
//! ]).await?;
//!
//! let history = session.get_messages(None).await?;
//! assert_eq!(history.len(), 2);
//!
//! let removed = session.pop_message().await?;
//! assert!(removed.is_some());
//! # Ok::<(), machi::Error>(())
//! # }).unwrap();
//! ```
pub use MemoryError;
pub use InMemorySession;
pub use ;
pub use SqliteSession;