use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::BoxFuture;
use crate::agents::error::AgentError;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionMetadata {
pub id: String,
pub name: Option<String>,
pub tags: Vec<String>,
pub agent_name: String,
pub created_at: i64,
pub updated_at: i64,
pub turn_count: u32,
pub total_tokens: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Session {
pub metadata: SessionMetadata,
pub messages: Vec<Value>,
pub state: Value,
}
pub trait SessionManager: Send + Sync {
fn list(&self) -> BoxFuture<'_, Result<Vec<SessionMetadata>, AgentError>>;
fn resume(&self, session_id: &str) -> BoxFuture<'_, Result<Session, AgentError>>;
fn save(&self, session: &Session) -> BoxFuture<'_, Result<(), AgentError>>;
fn delete(&self, session_id: &str) -> BoxFuture<'_, Result<(), AgentError>>;
fn fork(
&self,
session_id: &str,
new_name: Option<String>,
) -> BoxFuture<'_, Result<SessionMetadata, AgentError>>;
fn rewind(
&self,
session_id: &str,
turn_index: u32,
) -> BoxFuture<'_, Result<Session, AgentError>>;
fn tag(&self, session_id: &str, tags: Vec<String>) -> BoxFuture<'_, Result<(), AgentError>>;
fn rename(&self, session_id: &str, new_name: String) -> BoxFuture<'_, Result<(), AgentError>>;
}