feat(worker-logs): add worker run-log viewer page

Nieuwe /worker-logs pagina: een tabel van de laatste N (10/25/50/100)
worker-runs met een inline detailpaneel dat de stream-json output van
Claude Code als leesbare timeline toont (system-init, assistant-tekst,
tool-calls/results, result-kaart).

- lib/parse-worker-log.ts: pure parser — summarizeRunLog (tabel) +
  parseRunLog (timeline), discriminated-union events, server-side
  truncatie van grote tool-results.
- lib/worker-logs.ts: server-only fs-toegang, leest uit WORKER_LOGS_DIR
  (read-only bind mount), naam-regex + pad-confinement, .gz support.
- app/api/worker-logs[/[name]]: GET-routes, auth-guarded, force-dynamic.
- app/worker-logs: server page + client view (tabel, N-selector,
  auto-refresh) + detail (timeline, auto-refresh tijdens in-progress run).

Vereist een read-only bind mount van /srv/scrum4me/worker-logs in de
ops-dashboard-container (docker-compose.yml + WORKER_LOGS_DIR in .env).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-05-15 01:58:03 +02:00
parent 84b3afbefa
commit 7e049ebdef
10 changed files with 1159 additions and 0 deletions

View file

@ -14,3 +14,15 @@ export function relativeTime(date: Date): string {
if (hours < 24) return `${hours}u geleden`
return `${Math.floor(hours / 24)}d geleden`
}
/** Human-readable duration from a millisecond count. */
export function formatDuration(ms: number): string {
if (ms < 1000) return `${ms}ms`
const totalSec = Math.round(ms / 1000)
if (totalSec < 60) return `${totalSec}s`
const minutes = Math.floor(totalSec / 60)
const seconds = totalSec % 60
if (minutes < 60) return `${minutes}m ${seconds}s`
const hours = Math.floor(minutes / 60)
return `${hours}u ${minutes % 60}m`
}