use crate::ConversationHandle;
use std::time::Instant;
use wcore::{model::HistoryEntry, storage::ConversationMeta};
#[derive(Debug, Clone)]
pub struct Conversation {
pub id: u64,
pub history: Vec<HistoryEntry>,
pub title: String,
pub uptime_secs: u64,
pub created_at: Instant,
pub handle: Option<ConversationHandle>,
pub topic: Option<String>,
}
impl Conversation {
pub fn new(id: u64) -> Self {
Self {
id,
history: Vec::new(),
title: String::new(),
uptime_secs: 0,
created_at: Instant::now(),
handle: None,
topic: None,
}
}
pub fn meta(&self, agent: &str, created_by: &str) -> ConversationMeta {
ConversationMeta {
agent: agent.to_owned(),
created_by: created_by.to_owned(),
created_at: chrono::Utc::now().to_rfc3339(),
title: self.title.clone(),
uptime_secs: self.uptime_secs,
topic: self.topic.clone(),
}
}
}