stats: per-agent /stats page with chart.js trends + breakdowns

new hive-ag3nt::stats module reads turn_stats.sqlite read-only and
aggregates over 24h/7d/30d windows (hourly/daily buckets) — turn
rate, p50/p95/avg duration, ctx tokens (avg/max), cost token
components, top tools, wake mix, result mix. served by the agent
itself so per-MCP extensions can register more providers without
the host knowing their schemas.

/stats route + /api/stats?window=... on the per-agent web ui.
chart.js v4.4.4 pulled from jsdelivr (SRI hash deferred). nav
links: 📊 chip on the dashboard container row + 📊 stats → on
the per-agent header.

todo housekeeping: softened damocles-area note at the top,
new reverse-proxy + deferred reminder-rollup items, removed
the two telemetry-ui items absorbed by this page.
This commit is contained in:
müde 2026-05-19 00:27:01 +02:00
parent f9f1346eae
commit d3f90f4cc0
8 changed files with 930 additions and 3 deletions

View file

@ -487,6 +487,13 @@
el('a', { class: 'name', href: url, target: '_blank', rel: 'noopener' }, c.name),
el('span', { class: c.is_manager ? 'role role-m1nd' : 'role role-ag3nt' },
c.is_manager ? 'm1nd' : 'ag3nt'),
el('a', {
class: 'meta',
href: url + 'stats',
target: '_blank',
rel: 'noopener',
title: 'per-agent stats page (turn rate, durations, tokens, tool mix)',
}, '📊'),
);
if (pending) {
head.append(el('span', { class: 'pending-state' },