Skip to main content

Crate swink_agent_memory

Crate swink_agent_memory 

Source
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§

BlockingSessionStore
Adapter that wraps a synchronous SessionStore and exposes async methods by running each call via tokio::task::spawn_blocking.
CompactionResult
Result of a compaction operation (diagnostic type for future use).
FileCheckpointStore
Durable checkpoint store that persists one checkpoint per JSON file.
InterruptState
Snapshot of agent state at the point of interruption.
JsonlSessionStore
JSONL file-based session store.
LoadOptions
Options for loading a subset of session entries.
PendingToolCall
A tool call awaiting approval at the time of interruption.
SessionHit
A single cross-session search result.
SessionMeta
Metadata stored as the first line of a session JSONL file.
SessionSearchOptions
Options for searching persisted sessions.
SummarizingCompactor
Summarization-aware context compactor.
TantivyIndex
Tantivy-backed full-text index.

Enums§

SessionEntry
A single entry in a persisted session.

Traits§

SessionMigrator
Migrates session entries from one schema version to the next.
SessionStore
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§

SessionStoreFuture
A boxed future returned by BlockingSessionStore methods.