mod accounting;
mod state;
pub mod store;
pub use accounting::GoalAccounting;
pub use state::GoalStatus;
pub use store::{GoalError, GoalStore};
use chrono::{DateTime, Utc};
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Goal {
pub id: String,
pub text: String,
pub status: GoalStatus,
pub token_budget: Option<i64>,
pub turns_used: i64,
pub tokens_used: i64,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub completed_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct GoalSnapshot {
pub id: String,
pub text: String,
pub status: GoalStatus,
pub turns_used: u64,
pub tokens_used: u64,
pub token_budget: Option<u64>,
}
impl From<Goal> for GoalSnapshot {
fn from(g: Goal) -> Self {
Self {
id: g.id,
text: g.text,
status: g.status,
turns_used: g.turns_used.max(0).cast_unsigned(),
tokens_used: g.tokens_used.max(0).cast_unsigned(),
token_budget: g.token_budget.map(|b| b.max(0).cast_unsigned()),
}
}
}