adk_memory/lib.rs
1//! # adk-memory
2//!
3//! Semantic memory and search for ADK agents.
4//!
5//! ## Overview
6//!
7//! This crate provides long-term memory capabilities:
8//!
9//! - [`InMemoryMemoryService`] - Simple in-memory memory storage
10//! - [`MemoryService`] - Trait for custom backends
11//! - [`MemoryEntry`] - Structured memory with metadata
12//! - [`MemoryServiceAdapter`] - Bridge to [`adk_core::Memory`] with optional project scope
13//! - [`validate_project_id`] - Project identifier validation
14//!
15//! ## Quick Start
16//!
17//! ```rust,no_run
18//! use adk_memory::InMemoryMemoryService;
19//!
20//! let service = InMemoryMemoryService::new();
21//!
22//! // Memory is automatically searched and injected
23//! // when configured via LlmAgentBuilder::include_memory()
24//! ```
25//!
26//! ## Project-Scoped Memory
27//!
28//! Memories can be isolated by project within a user. The isolation key is
29//! `(app_name, user_id, project_id?)`:
30//!
31//! - **Global entries** (`project_id = None`): visible in all contexts.
32//! - **Project entries** (`project_id = Some(id)`): visible only within that project.
33//! - **Project search**: returns global + matching project entries.
34//! - **Global search**: returns only global entries.
35//!
36//! ```rust,ignore
37//! use adk_memory::{InMemoryMemoryService, MemoryService, MemoryServiceAdapter};
38//! use std::sync::Arc;
39//!
40//! let service = Arc::new(InMemoryMemoryService::new());
41//!
42//! // Store entries in a project
43//! service.add_session_to_project("app", "user", "sess", "my-project", entries).await?;
44//!
45//! // Adapter scoped to a project
46//! let adapter = MemoryServiceAdapter::new(service, "app", "user")
47//! .with_project_id("my-project");
48//! ```
49//!
50//! ## Features
51//!
52//! - Per-user and per-project memory isolation
53//! - Semantic search queries
54//! - Six backends: InMemory, SQLite, PostgreSQL, Redis, MongoDB, Neo4j
55//! - Versioned schema migrations
56//! - GDPR `delete_user` across all projects
57
58pub mod adapter;
59pub mod inmemory;
60pub mod migration;
61pub mod service;
62pub mod text;
63
64#[cfg(any(feature = "database-memory", feature = "mongodb-memory", feature = "neo4j-memory"))]
65pub mod embedding;
66#[cfg(feature = "mongodb-memory")]
67pub mod mongodb;
68#[cfg(feature = "neo4j-memory")]
69pub mod neo4j;
70#[cfg(feature = "database-memory")]
71pub mod postgres;
72#[cfg(feature = "redis-memory")]
73pub mod redis;
74#[cfg(feature = "sqlite-memory")]
75pub mod sqlite;
76
77pub use adapter::MemoryServiceAdapter;
78pub use inmemory::InMemoryMemoryService;
79pub use service::{MemoryEntry, MemoryService, SearchRequest, SearchResponse, validate_project_id};
80
81#[cfg(any(feature = "database-memory", feature = "mongodb-memory", feature = "neo4j-memory"))]
82pub use embedding::EmbeddingProvider;
83#[cfg(feature = "mongodb-memory")]
84pub use mongodb::MongoMemoryService;
85#[cfg(feature = "neo4j-memory")]
86pub use neo4j::Neo4jMemoryService;
87#[cfg(feature = "database-memory")]
88pub use postgres::{PostgresMemoryService, PostgresMemoryServiceBuilder, VectorIndexType};
89#[cfg(feature = "redis-memory")]
90pub use redis::{RedisMemoryConfig, RedisMemoryService};
91#[cfg(feature = "sqlite-memory")]
92pub use sqlite::SqliteMemoryService;