Skip to main content

swink_agent_memory/
lib.rs

1#![forbid(unsafe_code)]
2//! Session persistence and memory management for swink-agent.
3//!
4//! This crate provides pluggable session storage, durable checkpoint storage,
5//! and context compaction strategies for the swink-agent framework. It
6//! extracts session persistence from the TUI into a reusable library and lays
7//! the groundwork for multi-layer memory research (summarization, RAG,
8//! tool-aware compaction).
9//!
10//! # Quick Start
11//!
12//! ```rust,ignore
13//! use swink_agent_memory::{
14//!     JsonlSessionStore, SessionMeta, SessionStore, format_session_id, now_utc,
15//! };
16//!
17//! let dir = JsonlSessionStore::default_dir().expect("config dir");
18//! let store = JsonlSessionStore::new(dir)?;
19//! let id = format_session_id(); // e.g. "20260320_143000_6f00bfe3f7c54b2f86d780df58ccf0a1"
20//! let meta = SessionMeta::new(id.clone(), "My session", now_utc(), now_utc());
21//! store.save(&id, &meta, &messages)?;
22//! ```
23//!
24//! For durable agent checkpoints, use [`FileCheckpointStore`].
25
26mod checkpoint_store;
27mod codec;
28mod compaction;
29mod entry;
30mod interrupt;
31mod jsonl;
32mod load_options;
33mod meta;
34mod migrate;
35mod search;
36mod store;
37mod store_async;
38mod time;
39
40pub use checkpoint_store::FileCheckpointStore;
41pub use compaction::{CompactionResult, SummarizingCompactor};
42pub use entry::SessionEntry;
43pub use interrupt::{InterruptState, PendingToolCall};
44pub use jsonl::JsonlSessionStore;
45pub use load_options::LoadOptions;
46pub use meta::SessionMeta;
47pub use migrate::SessionMigrator;
48#[cfg(feature = "search")]
49pub use search::index::TantivyIndex;
50pub use search::{SessionHit, SessionSearchOptions};
51pub use store::SessionStore;
52pub use store_async::{BlockingSessionStore, SessionStoreFuture};
53pub use time::{format_session_id, now_utc};