ai-agent 0.13.4

Idiomatic agent sdk inspired by the claude code source leak
Documentation
//! Memory age utilities

const MS_PER_DAY: u64 = 86_400_000;

/// Days elapsed since mtime. Floor-rounded — 0 for today, 1 for
/// yesterday, 2+ for older. Negative inputs (future mtime, clock skew)
/// clamp to 0.
pub fn memory_age_days(mtime_ms: u64) -> i64 {
    let now = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .map(|d| d.as_millis() as u64)
        .unwrap_or(0);
    let diff = now.saturating_sub(mtime_ms);
    (diff / MS_PER_DAY).max(0) as i64
}

/// Human-readable age string
pub fn memory_age(mtime_ms: u64) -> String {
    let d = memory_age_days(mtime_ms);
    if d == 0 {
        "today".to_string()
    } else if d == 1 {
        "yesterday".to_string()
    } else {
        format!("{} days ago", d)
    }
}

/// Plain-text staleness caveat for memories >1 day old
pub fn memory_freshness_text(mtime_ms: u64) -> String {
    let d = memory_age_days(mtime_ms);
    if d <= 1 {
        String::new()
    } else {
        format!(
            "This memory is {} days old. Memories are point-in-time observations, not live state — claims about code behavior or file:line citations may be outdated. Verify against current code before asserting as fact.",
            d
        )
    }
}

/// Per-memory staleness note wrapped in <system-reminder> tags
pub fn memory_freshness_note(mtime_ms: u64) -> String {
    let text = memory_freshness_text(mtime_ms);
    if text.is_empty() {
        String::new()
    } else {
        format!("<system-reminder>{}</system-reminder>\n", text)
    }
}