pub struct MemoryApi { /* private fields */ }Expand description
Memory subsystem facade.
Provides high-level memory operations without exposing the
internal MemoryManager directly. This is the 14th typed API
in KernelHandle (alongside A2aApi, AgentApi, etc.).
Implementations§
Source§impl MemoryApi
impl MemoryApi
Sourcepub fn new(memory_manager: Arc<MemoryManager>) -> Self
pub fn new(memory_manager: Arc<MemoryManager>) -> Self
Create a new MemoryApi.
Sourcepub fn set_hnsw_index(&mut self, index: Arc<HnswMemoryIndex>)
pub fn set_hnsw_index(&mut self, index: Arc<HnswMemoryIndex>)
Attach an HNSW index for fast semantic search.
Sourcepub async fn remember(&self, entry: MemoryEntry) -> Result<String>
pub async fn remember(&self, entry: MemoryEntry) -> Result<String>
Store a memory entry. Returns the entry’s ID.
Sourcepub async fn search(
&self,
query: &str,
memory_type: Option<MemoryType>,
limit: usize,
) -> Result<Vec<MemoryEntry>>
pub async fn search( &self, query: &str, memory_type: Option<MemoryType>, limit: usize, ) -> Result<Vec<MemoryEntry>>
Search memory by text query.
Sourcepub async fn recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
pub async fn recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
Recall memory by query (semantic if HNSW available, else keyword).
Sourcepub async fn get(
&self,
id: &str,
memory_type: MemoryType,
) -> Result<Option<MemoryEntry>>
pub async fn get( &self, id: &str, memory_type: MemoryType, ) -> Result<Option<MemoryEntry>>
Get a specific memory entry by ID and type.
Sourcepub async fn forget(&self, id: &str, memory_type: MemoryType) -> Result<bool>
pub async fn forget(&self, id: &str, memory_type: MemoryType) -> Result<bool>
Forget (delete) a memory entry.
Sourcepub async fn list(
&self,
memory_type: MemoryType,
limit: usize,
) -> Result<Vec<MemoryEntry>>
pub async fn list( &self, memory_type: MemoryType, limit: usize, ) -> Result<Vec<MemoryEntry>>
List memories of a given type.
Sourcepub async fn search_semantic(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SemanticHit>>
pub async fn search_semantic( &self, query: &str, limit: usize, ) -> Result<Vec<SemanticHit>>
Search memory using semantic similarity (returns SemanticHits). Falls back to keyword search if no HNSW index.
Sourcepub async fn stats(&self) -> (usize, usize)
pub async fn stats(&self) -> (usize, usize)
Get memory statistics: (total_entries, vector_index_size).
Sourcepub async fn rebuild_hnsw_index(&self) -> Result<usize>
pub async fn rebuild_hnsw_index(&self) -> Result<usize>
Rebuild the HNSW index from current memory state. Returns the number of vectors indexed.
Sourcepub fn manager(&self) -> &Arc<MemoryManager> ⓘ
pub fn manager(&self) -> &Arc<MemoryManager> ⓘ
Access the underlying memory manager. For advanced operations not yet exposed via this facade.