UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

18 lines (17 loc) • 639 B
const ONE_DAY_MS = 24 * 60 * 60 * 1_000; const ONE_WEEK_MS = 7 * ONE_DAY_MS; const ONE_MONTH_MS = 30.44 * ONE_DAY_MS; export function formatMemoryAge(ageMs) { if (ageMs < ONE_DAY_MS) return "today"; if (ageMs < 2 * ONE_DAY_MS) return "yesterday"; if (ageMs < ONE_WEEK_MS) return `${Math.floor(ageMs / ONE_DAY_MS)} days ago`; if (ageMs < ONE_MONTH_MS) { const weeks = Math.floor(ageMs / ONE_WEEK_MS); return `${weeks} ${weeks === 1 ? "week" : "weeks"} ago`; } const months = Math.floor(ageMs / ONE_MONTH_MS); return `${months} ${months === 1 ? "month" : "months"} ago`; }