Expand description
Session persistence and memory management for swink-agent.
This crate provides pluggable session storage, durable checkpoint storage, and context compaction strategies for the swink-agent framework. It extracts session persistence from the TUI into a reusable library and lays the groundwork for multi-layer memory research (summarization, RAG, tool-aware compaction).
§Quick Start
ⓘ
use swink_agent_memory::{
JsonlSessionStore, SessionMeta, SessionStore, format_session_id, now_utc,
};
let dir = JsonlSessionStore::default_dir().expect("config dir");
let store = JsonlSessionStore::new(dir)?;
let id = format_session_id(); // e.g. "20260320_143000_6f00bfe3f7c54b2f86d780df58ccf0a1"
let meta = SessionMeta::new(id.clone(), "My session", now_utc(), now_utc());
store.save(&id, &meta, &messages)?;For durable agent checkpoints, use FileCheckpointStore.
Structs§
- Blocking
Session Store - Adapter that wraps a synchronous
SessionStoreand exposes async methods by running each call viatokio::task::spawn_blocking. - Compaction
Result - Result of a compaction operation (diagnostic type for future use).
- File
Checkpoint Store - Durable checkpoint store that persists one checkpoint per JSON file.
- Interrupt
State - Snapshot of agent state at the point of interruption.
- Jsonl
Session Store - JSONL file-based session store.
- Load
Options - Options for loading a subset of session entries.
- Pending
Tool Call - A tool call awaiting approval at the time of interruption.
- Session
Hit - A single cross-session search result.
- Session
Meta - Metadata stored as the first line of a session JSONL file.
- Session
Search Options - Options for searching persisted sessions.
- Summarizing
Compactor - Summarization-aware context compactor.
- Tantivy
Index - Tantivy-backed full-text index.
Enums§
- Session
Entry - A single entry in a persisted session.
Traits§
- Session
Migrator - Migrates session entries from one schema version to the next.
- Session
Store - Pluggable session persistence.
Functions§
- format_
session_ id - Generate a session ID as
YYYYMMDD_HHMMSS_<uuid-v4-hex>. - now_utc
- Returns the current UTC time.
Type Aliases§
- Session
Store Future - A boxed future returned by
BlockingSessionStoremethods.