use crate::agent::AgentState;
use crate::error::OpenAIAgentError;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use uuid::Uuid;
pub type EntityId = String;
pub fn generate_id() -> EntityId {
Uuid::new_v4().to_string()
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConversationMetadata {
pub id: EntityId,
pub name: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub message_count: usize,
pub token_count: usize,
}
#[async_trait]
pub trait PersistenceStore: Send + Sync {
async fn store_conversation(&self, id: &str, state: &AgentState) -> Result<(), OpenAIAgentError>;
async fn get_conversation(&self, id: &str) -> Result<Option<AgentState>, OpenAIAgentError>;
async fn delete_conversation(&self, id: &str) -> Result<(), OpenAIAgentError>;
async fn list_conversations(&self, limit: usize, offset: usize) -> Result<Vec<ConversationMetadata>, OpenAIAgentError>;
}
pub mod memory;
pub mod postgres;
pub use memory::MemoryStore;
pub use postgres::PostgresStore;