pub struct MemoryManager { /* private fields */ }Expand description
Unified memory manager composing all layers.
Implementations§
Source§impl MemoryManager
impl MemoryManager
Sourcepub fn with_graph(self, path: &Path) -> Result<Self>
pub fn with_graph(self, path: &Path) -> Result<Self>
Enable graph memory at a given path.
Requires the graph feature.
Sourcepub fn with_graph_in_memory(self) -> Result<Self>
pub fn with_graph_in_memory(self) -> Result<Self>
Enable in-memory graph (no persistence).
Requires the graph feature.
Sourcepub fn with_memory_dir(self, dir: PathBuf) -> Self
pub fn with_memory_dir(self, dir: PathBuf) -> Self
Set a custom memory directory.
Sourcepub fn with_sessions_dir(self, dir: PathBuf) -> Self
pub fn with_sessions_dir(self, dir: PathBuf) -> Self
Set a custom sessions directory.
Sourcepub fn build_context(&self) -> String
pub fn build_context(&self) -> String
Build the complete memory context for the system prompt. Includes MEMORY.md index + CLAUDE.md hierarchy.
Sourcepub fn scan(&self) -> Vec<MemoryFileMeta>
pub fn scan(&self) -> Vec<MemoryFileMeta>
Scan memory directory for all memory file metadata.
Sourcepub fn load_file(&self, path: &Path) -> Option<MemoryFile>
pub fn load_file(&self, path: &Path) -> Option<MemoryFile>
Load a specific memory file by path.
Sourcepub fn store_memory(
&self,
content: &str,
mem_type: MemoryType,
confidence: f32,
) -> Option<String>
pub fn store_memory( &self, content: &str, mem_type: MemoryType, confidence: f32, ) -> Option<String>
Store a memory (writes to graph if available, always returns success).
Sourcepub fn recall(&self, query: &str, limit: usize) -> Vec<String>
pub fn recall(&self, query: &str, limit: usize) -> Vec<String>
Recall memories matching a query. Uses graph if available, falls back to memdir scan + text matching.
Sourcepub fn by_type(&self, mem_type: MemoryType) -> Vec<String>
pub fn by_type(&self, mem_type: MemoryType) -> Vec<String>
Get memories by type (graph only, returns empty without graph).
Sourcepub fn session_path(&self, session_id: &str) -> PathBuf
pub fn session_path(&self, session_id: &str) -> PathBuf
Get the transcript path for a session.
Sourcepub fn write_user_message(
&self,
session_id: &str,
message: Message,
) -> Result<String>
pub fn write_user_message( &self, session_id: &str, message: Message, ) -> Result<String>
Write a user message to the session transcript.
Sourcepub fn write_assistant_message(
&self,
session_id: &str,
message: Message,
parent_uuid: Option<&str>,
) -> Result<String>
pub fn write_assistant_message( &self, session_id: &str, message: Message, parent_uuid: Option<&str>, ) -> Result<String>
Write an assistant message to the session transcript.
Sourcepub fn load_session_messages(&self, session_id: &str) -> Result<Vec<Message>>
pub fn load_session_messages(&self, session_id: &str) -> Result<Vec<Message>>
Load a session’s messages.
Sourcepub fn list_sessions(&self) -> Vec<SessionInfo>
pub fn list_sessions(&self) -> Vec<SessionInfo>
List all session files.
Sourcepub fn graph_stats(&self) -> GraphStats
pub fn graph_stats(&self) -> GraphStats
Get graph statistics (returns default if no graph).
Sourcepub fn tag_memory(&self, memory_id: &str, topic: &str)
pub fn tag_memory(&self, memory_id: &str, topic: &str)
Tag a memory in the graph (no-op without graph).
Sourcepub fn link_memories(&self, from_id: &str, to_id: &str, relationship: &str)
pub fn link_memories(&self, from_id: &str, to_id: &str, relationship: &str)
Link two memories in the graph (no-op without graph).
Sourcepub fn memory_dir(&self) -> &Path
pub fn memory_dir(&self) -> &Path
Access paths.