use crate::{
AgentNamespace, Memory, NamespaceStats, SearchQuery, SearchResult, StoreMemoryRequest,
};
use async_trait::async_trait;
#[async_trait]
pub trait MemoryStorage: Send + Sync {
async fn store(&self, request: StoreMemoryRequest) -> crate::Result<Memory>;
async fn search(&self, query: SearchQuery) -> crate::Result<SearchResult>;
async fn get_by_id(&self, id: i64) -> crate::Result<Option<Memory>>;
async fn delete(&self, id: i64) -> crate::Result<bool>;
async fn update(&self, memory: Memory) -> crate::Result<Memory>;
}
#[async_trait]
pub trait NamespaceManager: Send + Sync {
async fn get_or_create(&self, name: &str, agent_type: &str) -> crate::Result<AgentNamespace>;
async fn get_by_name(&self, name: &str) -> crate::Result<Option<AgentNamespace>>;
async fn list_all(&self) -> crate::Result<Vec<AgentNamespace>>;
async fn stats(&self, name: &str) -> crate::Result<NamespaceStats>;
}
#[async_trait]
pub trait EmbeddingService: Send + Sync {
async fn embed(&self, text: &str) -> crate::Result<Vec<f32>>;
async fn embed_batch(&self, texts: &[String]) -> crate::Result<Vec<Vec<f32>>>;
fn dimension(&self) -> usize;
fn model_name(&self) -> &str;
}
#[async_trait]
pub trait VectorSearch: Send + Sync {
async fn find_similar(
&self,
embedding: &[f32],
namespace_id: i64,
limit: usize,
threshold: f32,
) -> crate::Result<Vec<(i64, f32)>>;
async fn store_vector(&self, memory_id: i64, embedding: &[f32]) -> crate::Result<()>;
async fn delete_vector(&self, memory_id: i64) -> crate::Result<()>;
}