pikiloom 0.4.44 → 0.4.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bot/render-shared.js +22 -1
- package/package.json +1 -1
|
@@ -105,11 +105,26 @@ export function formatUsageWindowsSummary(usage) {
|
|
|
105
105
|
return parts.join(' · ');
|
|
106
106
|
return usage.status ? `status=${usage.status}` : 'no data';
|
|
107
107
|
}
|
|
108
|
+
// Freshest capturedAt (ISO string) across the given agents' usage and their accounts' usage, or
|
|
109
|
+
// null when none carry a timestamp. Mirrors the dashboard usage popover: every usage here is
|
|
110
|
+
// probed in a single getUsageOverview pass, so one freshest stamp stands for the whole block
|
|
111
|
+
// rather than repeating a near-identical timestamp per row. ISO-8601 UTC sorts lexically → max = latest.
|
|
112
|
+
export function freshestUsageCapturedAt(agents) {
|
|
113
|
+
let best = null;
|
|
114
|
+
const consider = (iso) => { if (iso && (!best || iso > best))
|
|
115
|
+
best = iso; };
|
|
116
|
+
for (const agent of agents) {
|
|
117
|
+
consider(agent.usage?.capturedAt);
|
|
118
|
+
for (const account of agent.accounts)
|
|
119
|
+
consider(account.usage?.capturedAt);
|
|
120
|
+
}
|
|
121
|
+
return best;
|
|
122
|
+
}
|
|
108
123
|
// Multi-agent / multi-account usage block for `/status`, mirroring the dashboard's top-right
|
|
109
124
|
// view: each installed agent that has usage, and for account-capable agents every account's own
|
|
110
125
|
// quota with the active one marked (●). Returns [] when nothing has usage so callers can skip the
|
|
111
126
|
// section entirely. Leading blank + bold header follow the same shape callers already render.
|
|
112
|
-
export function buildUsageOverviewLines(overview) {
|
|
127
|
+
export function buildUsageOverviewLines(overview, now = Date.now()) {
|
|
113
128
|
const shown = overview.agents.filter(a => (a.usage?.ok && a.usage.windows.length) || a.accounts.length);
|
|
114
129
|
if (!shown.length)
|
|
115
130
|
return [];
|
|
@@ -117,6 +132,12 @@ export function buildUsageOverviewLines(overview) {
|
|
|
117
132
|
{ text: '', bold: false },
|
|
118
133
|
{ text: 'Provider Usage', bold: true },
|
|
119
134
|
];
|
|
135
|
+
// Data-freshness stamp (restored to match the old /status line and the dashboard usage popover):
|
|
136
|
+
// one "Updated: X ago" for the whole block, from the freshest capturedAt across everything shown.
|
|
137
|
+
const capturedMs = Date.parse(freshestUsageCapturedAt(shown) ?? '');
|
|
138
|
+
if (Number.isFinite(capturedMs)) {
|
|
139
|
+
lines.push({ text: ` Updated: ${fmtUptime(Math.max(0, now - capturedMs))} ago` });
|
|
140
|
+
}
|
|
120
141
|
for (const agent of shown) {
|
|
121
142
|
lines.push({ text: `${agent.label}${agent.isCurrent ? ' (current)' : ''}`, bold: true });
|
|
122
143
|
if (agent.accounts.length) {
|
package/package.json
CHANGED