${esc(s.title)}
${levelChip(s.level)}${esc(s.headline)}
${esc(s.detail)}
${s.id === 'intake' ? hoursChart(report) : ''}/** * Server-rendered Factory health pages: the factory looking at itself. * Pure (no kody:runtime). Every action is a plain form POST, so the pages * work without JavaScript. */ import { esc, icon, renderShell } from './ui.ts' import { ACTIVITY_ORIGIN, type HealthConfig } from '../health/config.ts' import { MAX_WAKES_PER_HOUR, activityUrlFor } from '../health/fingerprint.ts' import { ago, type HealthReport, type Level } from '../health/signals.ts' import type { FingerprintRecord, TimelineEvent } from '../health/store.ts' const TZ = 'America/Denver' const BAD_FLASH = /^(error|invalid|unknown|could not|no wake|wakes are off|not sent)/i function wakeAlertsHtml(facts: { now: number; wakeAlerts?: Array<{ at: string; bot: string; role: string; source: string; status: string; reason: string; cardId?: string }> }): string { const alerts = (facts.wakeAlerts ?? []).slice(0, 5) if (!alerts.length) return '
No undelivered wakes on record.
' return `Everything starts off. Intake and reconcile never send a wake; only the last switch does.
${esc(s.headline)}
${esc(s.detail)}
${s.id === 'intake' ? hoursChart(report) : ''}${esc(r.summary)}
` : ''}${esc(empty)}
One row per failing run family in the ${esc(opts.org)} org: surface, owner, and error family.
${fingerprints.length} shown
${list}${report.level === 'off' ? 'The feed is switched off, so there is nothing to judge yet.' : 'No signal needs attention.'}
` const main = `The factory looking at itself: its jobs, its intake, what is stuck, and the run errors in this org.
Run reconcile now is unavailable while the Reconcile switch is off: a reconcile writes Activity triage across this org.
'}Platform signals read ${snapshot ? when(facts.now, snapshot.collectedAt) : 'never'}. Times shown in Mountain Time.
Every wake goes through @kody/wake-relay, which holds each bot's wake URL and key. The check sends one dry-run wake request that the relay logs without posting.
${facts.lease?.fingerprint ? `Lease held ${esc(ago(facts.now, facts.lease.acquired_at))} by ${esc(facts.lease.fingerprint)}.` : 'No wake lease is held.'}
No runs linked.
' const timeline = opts.timeline.length ? `Nothing recorded yet.
' const capLeft = Math.max(0, MAX_WAKES_PER_HOUR - opts.wakesThisHour) const wakeNote = !opts.config.wakesEnabled ? 'Patch wakes are switched off, so nothing is sent. Turn the switch on from Factory health first.' : capLeft === 0 ? `The hourly cap of ${MAX_WAKES_PER_HOUR} wakes is used up. Try again next hour.` : `Sends this fingerprint to Patch now. ${capLeft} of ${MAX_WAKES_PER_HOUR} wakes left this hour.` const outcomeChoice = (value: string, label: string, sub: string) => `` const main = `${id}
${statusChip(r.outcome === 'failed' ? 'failed' : r.outcome)} recorded ${when(now, r.completed_at)}${r.classification ? ` · ${esc(r.classification)}` : ''}
` : 'No outcome recorded yet.
'} ${r.summary ? `The ${r.run_ids.length === 1 ? 'latest run' : `latest ${r.run_ids.length} runs`} in ${esc(r.org)} Activity, newest first.
${runs}${esc(wakeNote)}
It may have been recorded under a different id.