aimem_core/lib.rs
1//! # aimem-core
2//!
3//! **Give your AI a memory — reusable core library.**
4//!
5//! `aimem-core` is a pure-Rust library that stores, retrieves, and searches
6//! text memories using [Turso](https://github.com/tursodatabase/turso) (an in-process
7//! SQLite engine with native vector support) as the sole storage backend.
8//!
9//! ## Feature overview
10//!
11//! | Feature | Implementation |
12//! |---------|---------------|
13//! | Vector storage | Turso `vector32()` BLOB column |
14//! | Semantic search | `vector_distance_cos()` — SimSIMD-accelerated cosine |
15//! | Full-text search | Turso FTS / Tantivy (`fts_match`, `fts_score`) |
16//! | Embedding generation | Gemini 2.0 (Remote) or `fastembed` (Local) |
17//! | Knowledge graph | Temporal entity-relationship triples in SQLite |
18//! | Graph traversal | BFS over wing/room adjacency — no graph DB needed |
19//!
20//! ## Architecture: 4-Layer Memory Stack
21//!
22//! ```text
23//! ┌─────────────────────────────────────────────────────────┐
24//! │ L0 Identity text ~100 tokens always loaded │
25//! │ L1 Essential story ~500-800 tok always loaded │
26//! │ L2 On-demand recall ~200-500 tok loaded on ask │
27//! │ L3 Deep hybrid search unlimited full memory │
28//! └─────────────────────────────────────────────────────────┘
29//! ```
30
31pub mod config;
32pub mod convo;
33pub mod db;
34pub mod embedder;
35pub mod extractor;
36pub mod graph;
37pub mod knowledge;
38pub mod layers;
39pub mod miner;
40pub mod search;
41pub mod types;
42
43pub use config::Config;
44pub use convo::{ConvoMineStats, ConvoMiner};
45pub use db::{AimemDb, EmbeddingStoreProfile};
46pub use embedder::{Embedder, Gemini2Embedder, LocalEmbedder};
47pub use graph::{AimemGraph, TraversalNode};
48pub use knowledge::KnowledgeGraph;
49pub use layers::MemoryStack;
50pub use miner::Miner;
51pub use search::Searcher;
52pub use types::{
53 ContentPart, Drawer, DrawerFilingRequest, DrawerMeta, Entity, HybridSearchResult,
54 KeywordSearchResult, RoomNode, SearchResult, Triple, Tunnel,
55};
56
57/// Curated high-level imports for typical AiMem integrations.
58pub mod prelude {
59 pub use crate::{
60 AimemDb, AimemGraph, Config, ContentPart, ConvoMineStats, ConvoMiner, Drawer,
61 DrawerFilingRequest, DrawerMeta, Embedder, EmbeddingStoreProfile, Entity, Gemini2Embedder,
62 HybridSearchResult, KeywordSearchResult, KnowledgeGraph, LocalEmbedder, MemoryStack, Miner,
63 RoomNode, SearchResult, Searcher, Triple, Tunnel,
64 };
65}