From da0116f0babf19ecbf280b778db2925ed8a32856 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 20 Sep 2026 16:50:28 +1000 Subject: [PATCH] fix(webui): stop the UI contradicting itself, and clear the AA failures Four P1 findings from the audit. Workflows claimed "No workflow runs yet" directly above stage tables listing those runs (archie-core-rcbf). The rows were built from the definition list alone, so a workflow with statistics but no definition produced no row at all. workflow-rows.js now merges both sides: a run is evidence the workflow exists. The producer is also at fault -- /api/workflows returns definitions: [] from the archie-ui composition while the daemon logs a registry of seven -- which also means "Start work" never renders there. Filed as archie-core-3tij. The logs page said "Durable history unavailable" twice and promised live logs from a stream that had stopped (archie-core-c5bz). EventSource fires onerror both for a retry and for a give-up; readyState tells them apart, so a dead stream now reports "unavailable" in red instead of "reconnecting" in amber forever. The toolbar says "Live only" and the empty state carries the explanation, each once. An unconfigured update check (501) now says so on Configuration rather than rendering nothing at all. Contrast (archie-core-umdn). --fg-subtle was 3.37:1 dark and 2.72:1 light, used for every KPI caption and column header; both move to values clearing 4.5:1 on every surface they actually land on, down to surface-hover at 4.51. White on the dark accent was 3.2:1 on the active nav item and every primary button: --accent-fg becomes near-black at 5.96:1 and the accent itself is untouched, since it is also the link colour and reads correctly on the canvas. Swept four routes in both themes: no remaining failures outside elements painted on a gradient, which a compositing check cannot judge and which are white on blue-purple anyway. The HEALTH cards take their own height again (archie-core-1786637500926-421-7c63bcd3). Equalising them was right when both held a checklist; once setup completes, that card is a title and one line while Gate pulse carries a gauge and four rows, so matching heights left a ~400px empty box in the first screen. --- ui/dist/assets/index.css | 2 +- ui/dist/assets/index.js | 16 +++++------ ui/src/base/api.jsx | 5 +++- ui/src/base/stream-state.js | 24 +++++++++++++++++ ui/src/css/tokens.css | 9 ++++--- ui/src/dashboard/dashboard.css | 21 ++++++--------- ui/src/logs/logs-empty.js | 29 ++++++++++++++++++++ ui/src/logs/logs.jsx | 14 ++++++---- ui/src/settings/settings.jsx | 24 ++++++++++++----- ui/src/workflows/workflow-rows.js | 36 +++++++++++++++++++++++++ ui/src/workflows/workflows.jsx | 7 ++--- ui/test/logs-empty.test.js | 30 +++++++++++++++++++++ ui/test/stream-state.test.js | 22 ++++++++++++++++ ui/test/workflow-rows.test.js | 44 +++++++++++++++++++++++++++++++ 14 files changed, 240 insertions(+), 43 deletions(-) create mode 100644 ui/src/base/stream-state.js create mode 100644 ui/src/logs/logs-empty.js create mode 100644 ui/src/workflows/workflow-rows.js create mode 100644 ui/test/logs-empty.test.js create mode 100644 ui/test/stream-state.test.js create mode 100644 ui/test/workflow-rows.test.js diff --git a/ui/dist/assets/index.css b/ui/dist/assets/index.css index 1f3531c85..67658a3b7 100644 --- a/ui/dist/assets/index.css +++ b/ui/dist/assets/index.css @@ -1 +1 @@ -:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden,.sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{scrollbar-width:none;border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);flex:0 auto;align-items:center;gap:2px;min-width:0;margin:0 auto;padding:3px;display:flex;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);flex:none;display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accent), var(--accent-2));cursor:pointer;flex:none;place-items:center;font-weight:600;display:grid}.ico{flex:none;display:block}.main{padding:var(--sp-6);flex:1;width:100%;overflow-x:hidden}.chat-dock{--fab-size:56px;--fab-inset:var(--sp-5);--fab-gap:var(--sp-3);right:var(--fab-inset);bottom:var(--fab-inset);z-index:40;position:fixed}.chat-fab{width:var(--fab-size);height:var(--fab-size);border-radius:var(--radius-pill);background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;cursor:pointer;box-shadow:var(--shadow-md);transition:transform var(--transition), box-shadow var(--transition);border:0;place-items:center;display:grid;position:relative}.chat-fab:hover{box-shadow:0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);transform:translateY(-1px)}.chat-fab:active{transform:translateY(0)}.chat-fab-icon{transition:opacity var(--transition), transform var(--transition);grid-area:1/1;place-items:center;display:grid}.chat-fab-icon-close,.chat-dock.is-open .chat-fab-icon-open{opacity:0;transform:scale(.7)rotate(-45deg)}.chat-fab-icon-open,.chat-dock.is-open .chat-fab-icon-close{opacity:1;transform:none}.chat-drawer{right:calc(var(--fab-size) + var(--fab-gap));width:min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));height:min(640px, calc(100vh - var(--fab-inset) * 2));pointer-events:none;position:absolute;bottom:0}.chat-drawer-panel{pointer-events:auto;background:var(--surface);border:1px solid var(--border);width:100%;height:100%;box-shadow:var(--shadow-md);opacity:0;border-radius:var(--radius-pill);transform-origin:100% 100%;transform:translateX(calc(var(--fab-size) + var(--fab-gap))) scale(.16);grid-template-rows:minmax(0,1fr);transition:opacity .16s cubic-bezier(.4,0,.2,1),transform .26s cubic-bezier(.22,1,.36,1),border-radius .26s cubic-bezier(.22,1,.36,1);display:grid;overflow:hidden}.chat-drawer.is-open .chat-drawer-panel{opacity:1;border-radius:var(--radius-lg);transform:none}.chat-drawer-panel>*{opacity:0;transition:opacity .12s linear}.chat-drawer.is-open .chat-drawer-panel>*{opacity:1;transition:opacity .16s linear .12s}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none;visibility:hidden;transition:opacity .14s cubic-bezier(.4,0,.2,1),transform .2s cubic-bezier(.4,0,1,1),border-radius .2s cubic-bezier(.4,0,1,1),visibility 0s linear .2s}.chat-drawer-head{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border);display:flex}@media (width<=720px){.chat-dock{--fab-inset:var(--sp-4)}.chat-drawer{right:var(--fab-inset);left:var(--fab-inset);bottom:calc(var(--fab-inset) + var(--fab-size) + var(--fab-gap));width:auto;height:min(72vh, calc(100vh - var(--fab-inset) * 2 - var(--fab-size) - var(--fab-gap)));position:fixed}.chat-drawer-panel{transform-origin:100% 100%;transform:translateY(calc(var(--fab-size) + var(--fab-gap))) scale(.16)}.chat-fab{z-index:1;position:relative}}@media (width<=1500px){.topbar-search{background:0 0;border:0;padding:0;overflow:hidden}.topbar-search-icon{display:none}.mobile-search-toggle{display:grid}.topbar-search input{opacity:0;pointer-events:none;width:0;transition:width var(--transition), opacity var(--transition);padding:0}.topbar-search.is-open,.topbar-search:focus-within{padding-right:var(--sp-2);border:1px solid var(--hairline);background:var(--surface-glass-strong)}.topbar-search.is-open input,.topbar-search:focus-within input{opacity:1;pointer-events:auto;width:min(9rem,34vw)}}@media (width<=1270px) and (width>=901px){.topbar{flex-wrap:wrap}.nav{border-radius:var(--radius-lg);flex-wrap:wrap;order:3;justify-content:center;width:100%;margin:0}}@media (width<=900px){body{padding:0}.shell{min-height:100vh;box-shadow:none;border:0;border-radius:0}.topbar{padding:var(--sp-3);gap:var(--sp-2);flex-wrap:wrap}.nav{border-radius:var(--radius-lg);scrollbar-width:none;flex-wrap:nowrap;order:3;justify-content:flex-start;width:100%;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item .nav-label{display:inline}.main{padding:var(--sp-4)}}.page-head{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-6);flex-wrap:wrap;display:flex}.page-title{font-size:var(--text-2xl);letter-spacing:-.02em;margin:0;font-weight:600}.page-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.page-actions{gap:var(--sp-2);align-items:center;display:flex}.btn{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-4);border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:background var(--transition), border-color var(--transition);display:inline-flex}.btn:hover{background:var(--surface-hover)}.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg);font-weight:500}.btn-primary:hover{filter:brightness(1.08);background:var(--accent)}.btn-icon{padding:var(--sp-2);border-radius:var(--radius-sm)}.card{background:var(--surface-glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--hairline);border-radius:var(--radius-lg);padding:var(--sp-5);box-shadow:var(--shadow-sm);overflow-x:auto}.card-head{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.card-title{font-size:var(--text-base);margin:0;font-weight:600}.card-sub{font-size:var(--text-xs);color:var(--fg-muted);margin:var(--sp-1) 0 0}.grid{gap:var(--sp-4);display:grid}.grid>*{min-width:0}.grid-4{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}.pill{align-items:center;gap:var(--sp-1);padding:2px var(--sp-2);border-radius:var(--radius-pill);font-size:var(--text-xs);white-space:nowrap;font-weight:500;display:inline-flex}.pill:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.pill-ok{color:var(--ok);background:var(--ok-soft)}.pill-warn{color:var(--warn);background:var(--warn-soft)}.pill-danger{color:var(--danger);background:var(--danger-soft)}.pill-info{color:var(--info);background:var(--info-soft)}.pill-idle{color:var(--idle);background:var(--idle-soft)}.table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}.table-scroll{-webkit-overflow-scrolling:touch;min-width:0;max-width:100%;overflow-x:auto}.table-scroll>.table{min-width:42rem}.table th{text-align:left;font-weight:500;font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);padding:0 var(--sp-3) var(--sp-3);border-bottom:1px solid var(--border)}.table td{padding:var(--sp-3);border-bottom:1px solid var(--border);color:var(--fg-muted)}.table tbody tr:last-child td{border-bottom:0}.table tbody tr:hover td{background:var(--surface-hover)}.table td.strong{color:var(--fg);font-weight:500}.mono{font-family:var(--font-mono);font-size:.95em}.empty{text-align:center;padding:var(--sp-7) var(--sp-4);color:var(--fg-muted)}.empty-title{color:var(--fg);margin-bottom:var(--sp-1);font-weight:500}.skeleton{background:linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);border-radius:var(--radius-sm);background-size:200% 100%;animation:1.4s infinite shimmer}@keyframes shimmer{to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}.nav-soon{font-size:var(--text-xs);color:var(--fg-subtle);background:var(--surface-hover);padding:1px var(--sp-2);border-radius:var(--radius-pill);margin-left:auto}.nav-item[aria-disabled]{opacity:.55;cursor:default}.nav-item[aria-disabled]:hover{color:var(--fg-muted);background:0 0}.stat-head{justify-content:space-between;align-items:center;gap:var(--sp-2);display:flex}.stat-label{font-size:var(--text-sm);color:var(--fg-muted)}.stat-trend{font-size:var(--text-xs);align-items:center;gap:3px;font-weight:500;display:inline-flex}.stat-trend.up{color:var(--ok)}.stat-trend.down{color:var(--danger)}.stat-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin:var(--sp-2) 0 0;font-weight:600}.stat-unit{font-size:var(--text-lg);color:var(--fg-muted);margin-left:var(--sp-1)}.stat-compare{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:var(--sp-1)}.spark{width:100%;height:34px;margin-top:var(--sp-3);display:block}.setup{margin-bottom:var(--sp-4)}.setup-pct{font-size:var(--text-lg);color:var(--accent);font-weight:600}.setup-complete-actions{align-items:center;gap:var(--sp-2);display:flex}.setup-dismiss{width:28px;height:28px;font-size:var(--text-lg);line-height:1}.setup-done .setup-pct{color:var(--ok)}.setup-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-bottom:var(--sp-4);overflow:hidden}.setup-bar-fill{background:var(--accent);border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.setup-list{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.setup-step{gap:var(--sp-3);align-items:flex-start;display:flex}.setup-check{border:1.5px solid var(--border-strong);width:18px;height:18px;font-size:var(--text-xs);color:var(--fg-subtle);border-radius:50%;flex:none;place-items:center;margin-top:1px;display:grid}.setup-step.done .setup-check{background:var(--ok-soft);color:var(--ok);border-color:#0000}.setup-step-title{font-size:var(--text-sm)}.setup-step.done .setup-step-title{color:var(--fg-muted);text-decoration:line-through}.setup-step-detail{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.hero{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-5);flex-wrap:wrap;display:flex}.hero-title{font-size:var(--text-3xl);letter-spacing:-.03em;margin:0;font-weight:600}.hero-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-2) 0 0}.hero-actions{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.dash-top{gap:var(--sp-4);margin-bottom:var(--sp-4);grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);display:grid}.dash-top>*,.dash-split>*{min-width:0}.dash-top>div{display:flex}.dash-top>div>.card{flex:1}.dash-top-standalone{grid-template-columns:minmax(0,1fr)}@media (width<=1080px){.dash-top{grid-template-columns:minmax(0,1fr)}}.gauge-wrap{place-items:center;display:grid;position:relative}.gauge{width:100%;max-width:200px;display:block}.gauge-value{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1)}.gauge-center{text-align:center;position:absolute;top:52%;transform:translateY(-50%)}.gauge-pct{font-size:var(--text-2xl);letter-spacing:-.03em;font-weight:600}.gauge-label{font-size:var(--text-xs);color:var(--fg-muted)}.pulse-list{margin:var(--sp-4) 0 0;gap:var(--sp-2);flex-direction:column;padding:0;list-style:none;display:flex}.pulse-item{justify-content:space-between;align-items:center;gap:var(--sp-3);font-size:var(--text-sm);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);display:flex}.pulse-name{color:var(--fg-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.segbar{border-radius:var(--radius-pill);background:var(--border);gap:2px;height:10px;display:flex;overflow:hidden}.segbar-part{height:100%;display:block}.segbar-ok{background:var(--ok)}.segbar-warn{background:var(--warn)}.segbar-danger{background:var(--danger)}.segbar-info{background:var(--info)}.segbar-idle{background:var(--idle)}.segbar-legend{gap:var(--sp-4);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.segbar-key{align-items:center;gap:var(--sp-2);font-size:var(--text-xs);color:var(--fg-muted);display:inline-flex}.segbar-dot{border-radius:50%;width:8px;height:8px}.forecast-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin-bottom:var(--sp-1);font-weight:600}.forecast-note{font-size:var(--text-xs);color:var(--fg-subtle);margin-bottom:var(--sp-4)}.dash-split{gap:var(--sp-4);margin-top:var(--sp-4);grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);display:grid}@media (width<=1080px){.dash-split{grid-template-columns:minmax(0,1fr)}}.stat-card{position:relative;overflow:hidden}.dash-section{margin-bottom:var(--sp-5)}.dash-section-head{align-items:baseline;gap:var(--sp-3);margin-bottom:var(--sp-3);padding-left:var(--sp-1);display:flex}.dash-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--fg-subtle);margin:0;font-weight:600}.dash-section-note{font-size:var(--text-xs);color:var(--fg-subtle)}.hero-actions-inner{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.btn-attention{border-color:var(--warn);color:var(--warn);background:var(--warn-soft);font-weight:500}.btn-attention:hover{background:var(--warn-soft);filter:brightness(1.1)}.activity-detail{width:55%;max-width:0}.activity-detail span{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.task-summary{margin-bottom:var(--sp-5)}.task-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.task-search,.task-filter{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3)}.task-search{width:220px}.task-search:focus,.task-filter:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.task-row{cursor:pointer}.task-expand{width:1.5rem;height:1.5rem;margin-right:var(--sp-2);color:var(--fg-muted);border:1px solid var(--border);font:inherit;cursor:pointer;background:0 0;border-radius:50%;padding:0;line-height:1}.task-expand:hover,.task-expand:focus-visible{color:var(--fg);border-color:var(--accent)}.activity-row{cursor:pointer}.activity-row:hover td,.activity-row:focus td{background:var(--surface-hover)}.activity-row:focus{outline:2px solid var(--accent);outline-offset:-2px}.task-source-link{color:var(--accent);text-decoration:none}.task-source-link:hover{text-decoration:underline}.task-detail-link{color:inherit}.task-detail-link:hover,.task-detail-link:focus-visible{text-decoration:underline;-webkit-text-decoration-color:var(--accent);text-decoration-color:var(--accent)}.task-actions{gap:var(--sp-1);white-space:nowrap;flex-wrap:wrap;display:flex}.btn-small{padding:var(--sp-1) var(--sp-2);font-size:var(--text-xs)}.btn-quiet{color:var(--fg-muted)}.task-action-error{max-width:220px;font-size:var(--text-xs);white-space:normal}.task-action-error-refused{color:var(--warn)}.task-action-error-broken{color:var(--danger)}.task-action-error-session{color:var(--warn);align-items:center;gap:var(--sp-1);flex-wrap:wrap;display:inline-flex}.task-decision{margin-bottom:var(--sp-4);padding:var(--sp-3);border-left:3px solid var(--accent);background:var(--surface)}.task-detail-actions{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);padding-bottom:var(--sp-3);border-bottom:1px solid var(--hairline);display:flex}.task-decision-title{color:var(--fg);font-weight:600}.task-decision-plan{margin-top:var(--sp-2);color:var(--fg-muted);white-space:pre-wrap}.task-logs-section{margin-top:var(--sp-4)}.task-logs-section .task-decision-title{justify-content:space-between;align-items:center;display:flex}.task-log-list{max-height:40vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);margin-top:var(--sp-2);overflow-y:auto}.task-log-loading,.task-log-error{padding:var(--sp-3) 0;color:var(--fg-muted)}@media (width<=700px){.task-filters,.task-search{width:100%}.task-filter{flex:100%}.table-scroll:has(.task-row){overflow:visible}.table:has(.task-row){display:block}.table:has(.task-row) tbody{display:block}.table-scroll>.table:has(.task-row){width:100%;min-width:0}.table:has(.task-row) thead{display:none}.task-row{gap:var(--sp-2) var(--sp-4);margin-bottom:var(--sp-3);padding:var(--sp-3);border:1px solid var(--hairline);border-radius:var(--radius-lg);background:var(--surface-glass);grid-template-columns:1fr 1fr;display:grid}.task-row td{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-1) 0;text-align:right;border:0;display:flex}.task-row td:before{content:attr(data-label);color:var(--fg-subtle);font-size:var(--text-xs);text-align:left;font-weight:500}.task-row td:nth-child(3),.task-row td:last-child{grid-column:1/-1}.task-row td:last-child{align-items:flex-start}.task-timeline-row,.task-timeline-row td{width:100%;display:block}.task-timeline-row td{margin:calc(var(--sp-2) * -1) 0 var(--sp-4);border-radius:0 0 var(--radius-lg) var(--radius-lg)}.task-detail-actions{flex-direction:column;align-items:flex-start}}@media (width<=480px){.task-row{grid-template-columns:1fr}.task-row td:nth-child(3),.task-row td:last-child{grid-column:auto}}.task-timeline-row td{background:var(--bg-raised);padding:var(--sp-4)}.task-timeline-loading{color:var(--fg-muted);font-size:var(--text-sm)}.task-timeline-error{align-items:flex-start;gap:var(--sp-2);flex-direction:column;display:flex}.task-timeline-error .task-timeline-title{color:var(--fg);font-weight:500}.task-timeline{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.task-timeline-entry{gap:var(--sp-3);align-items:flex-start;display:flex}.task-timeline-dot{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px;margin-top:5px}.task-timeline-kind{font-size:var(--text-sm);color:var(--fg);font-weight:500}.task-timeline-detail{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}.task-timeline-when{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.run-meta{align-items:center;gap:var(--sp-4);margin:calc(var(--sp-2) * -1) 0 var(--sp-4);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.run-meta-item{align-items:center;gap:var(--sp-2);display:inline-flex}.run-meta-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.run-meta-value{color:var(--fg)}.run-meta-muted{color:var(--fg-muted)}.run-meta-link{color:var(--accent)}.run-meta-link:hover{text-decoration:underline}.run-note{margin:0 0 var(--sp-4);padding:var(--sp-3) var(--sp-4);border-left:3px solid var(--warn);background:var(--warn-soft);border-radius:var(--radius-sm);color:var(--fg);font-size:var(--text-sm)}.run-restart{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-restart-copy,.run-restart-unavailable{color:var(--fg-muted);font-size:var(--text-sm);flex:22rem;margin:0}.run-restart-error{font-size:var(--text-sm);flex:100%;margin:0}.run-restart-error-refused{color:var(--warn)}.run-restart-error-broken{color:var(--danger)}.run-restart-error-session-expired{color:var(--warn)}.run-attempts{gap:var(--sp-2);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-attempt{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border:1px solid var(--border);border-radius:var(--radius-pill);background:var(--surface);color:var(--fg-muted);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:border-color var(--transition), color var(--transition);display:inline-flex}.run-attempt:hover{border-color:var(--border-strong);color:var(--fg)}.run-attempt.is-selected{border-color:var(--accent);background:var(--accent-soft);color:var(--fg)}.run-attempt-id{font-weight:500}.run-attempt-meta{color:var(--fg-muted);font-size:var(--text-xs)}.run-card{padding-top:var(--sp-4)}.tab-bar{gap:var(--sp-1);border-bottom:1px solid var(--border);margin-bottom:var(--sp-4);scrollbar-width:thin;display:flex;overflow-x:auto}.tab{padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--fg-muted);font:inherit;font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:color var(--transition), background var(--transition);background:0 0;border:0;border-bottom:2px solid #0000;position:relative}.tab:hover{color:var(--fg);background:var(--surface-hover)}.tab.is-selected{color:var(--fg);border-bottom-color:var(--accent);font-weight:500}.run-panel{min-width:0;min-height:6rem}.run-panel:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.run-loading{padding:var(--sp-5) 0;color:var(--fg-muted);font-size:var(--text-sm)}.run-error{align-items:flex-start;gap:var(--sp-2);padding:var(--sp-3) 0;flex-direction:column;display:flex}.run-error-title{color:var(--fg);font-weight:500}.run-error-detail{color:var(--fg-muted);font-size:var(--text-sm);max-width:60ch}.run-json{padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-sm);max-height:60vh;font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;line-height:1.5;overflow:auto}.run-rail-head{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-rail-attempt{font-weight:600}.run-rail-when{color:var(--fg-muted);font-size:var(--text-xs)}.run-stages{margin:0;padding:0;list-style:none}.run-stage{gap:var(--sp-2);padding-bottom:var(--sp-4);grid-template-columns:1.75rem 1fr;display:grid;position:relative}.run-stage:before{content:"";background:var(--border-strong);width:1px;position:absolute;top:1rem;bottom:0;left:.6875rem}.run-stage:last-child:before{display:none}.run-stage-node{z-index:1;border:2px solid var(--border-strong);background:var(--bg-raised);border-radius:50%;width:.875rem;height:.875rem;margin:.25rem 0 0 .25rem;position:relative}.run-stage[data-status=ok] .run-stage-node{border-color:var(--ok)}.run-stage[data-status=failed] .run-stage-node{border-color:var(--danger)}.run-stage[data-status=interrupted] .run-stage-node{border-color:var(--warn)}.run-stage[data-status=running] .run-stage-node{border-color:var(--info)}.run-stage-body{min-width:0}.run-stage-head{align-items:center;gap:var(--sp-2);flex-wrap:wrap;display:flex}.run-stage-name{color:var(--fg);overflow-wrap:anywhere;min-width:0;font-weight:500}.run-stage-duration{color:var(--fg-muted);font-size:var(--text-xs)}.run-stage-error{margin-top:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-left:3px solid var(--danger);background:var(--danger-soft);border-radius:var(--radius-sm);color:var(--fg-muted);font-size:var(--text-sm);white-space:pre-wrap;overflow-wrap:anywhere}.run-agent-report{margin-top:var(--sp-2);color:var(--fg-muted);font-size:var(--text-xs)}.run-agent-report-label{color:var(--fg-muted)}.run-rail-legend,.run-rail-note{margin:var(--sp-3) 0 0;color:var(--fg-muted);font-size:var(--text-xs);max-width:70ch}.run-rail-legend strong{color:var(--fg-muted)}.run-capture+.run-capture{margin-top:var(--sp-5);padding-top:var(--sp-4);border-top:1px solid var(--border)}.run-capture-head{justify-content:space-between;align-items:baseline;gap:var(--sp-3);flex-wrap:wrap;display:flex}.run-capture-when{color:var(--fg);font-size:var(--text-sm);font-weight:500}.run-capture-at{color:var(--fg-muted);font-size:var(--text-xs)}.run-capture-meta{align-items:center;gap:var(--sp-3);margin:var(--sp-2) 0 var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs);flex-wrap:wrap;display:flex}.run-capture-link{color:var(--accent)}.run-capture-link:hover{text-decoration:underline}.run-capture-branch,.run-capture-sha,.run-capture-totals{color:var(--fg-muted)}.run-changes-table td{padding:var(--sp-2) var(--sp-3);vertical-align:top}.run-changes-path{color:var(--fg);word-break:break-all}.run-changes-old{color:var(--fg-muted)}.run-changes-count{text-align:right;white-space:nowrap}.run-changes-hint,.run-changes-note,.run-changes-empty{color:var(--fg-muted);font-size:var(--text-xs)}.run-changes-hint{display:block}.run-changes-empty{padding:var(--sp-3) 0}.run-config-scope{margin:0 0 var(--sp-2);color:var(--fg-muted);font-size:var(--text-sm);max-width:75ch}.run-config-when{margin-bottom:var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs)}.run-config-unknown{margin-bottom:var(--sp-2);color:var(--warn);font-size:var(--text-sm)}.task-log-filters{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border)}.task-log-attempt{color:var(--fg);font-size:var(--text-sm);font-weight:500}.task-log-filter{align-items:center;gap:var(--sp-2);display:inline-flex}.task-log-filter-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.task-log-filter-note{color:var(--fg-muted);font-size:var(--text-xs);flex:100%;max-width:80ch;margin:0}.run-panel .task-log-list{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-raised);max-height:62vh;padding:0 var(--sp-2)}.run-page .pill{color:var(--fg)}.run-page .pill-ok:before{background:var(--ok)}.run-page .pill-warn:before{background:var(--warn)}.run-page .pill-danger:before{background:var(--danger)}.run-page .pill-info:before{background:var(--info)}.run-page .pill-idle:before{background:var(--idle)}@media (width<=700px){.run-meta{margin-bottom:var(--sp-3)}.run-restart{align-items:flex-start}.run-attempts{padding-bottom:var(--sp-1);flex-wrap:nowrap;overflow-x:auto}.run-stage{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border);grid-template-columns:1fr}.run-stage:before,.run-stage-node{display:none}.run-capture-head{align-items:flex-start;gap:var(--sp-1);flex-direction:column}}@media (width<=480px){.tab{padding:var(--sp-2)}.run-json{max-height:45vh}}@media (prefers-reduced-motion:reduce){.run-attempt,.tab{transition:none}}.skill-search{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);width:220px}.skill-search:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.skill-card{flex-direction:column;display:flex}.skill-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0 0 var(--sp-3);flex:1}.skill-source{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-stage-card{margin-top:var(--sp-4)}.wf-rate{font-size:var(--text-sm);color:var(--fg);align-items:baseline;gap:var(--sp-2);display:flex}.wf-rate-sub{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-top:var(--sp-2);width:140px;overflow:hidden}.wf-bar-fill{border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.wf-bar-ok{background:var(--ok)}.wf-bar-warn{background:var(--warn)}.wf-bar-danger{background:var(--danger)}.wf-bar-info{background:var(--info)}.wf-form{gap:var(--sp-2);flex-direction:column;display:flex}.wf-form input,.wf-form select,.wf-form textarea{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2);width:100%}.wf-form textarea{resize:vertical}.wf-form input:focus,.wf-form select:focus,.wf-form textarea:focus{outline:2px solid var(--accent);outline-offset:-1px}.wf-form input::placeholder,.wf-form textarea::placeholder{color:var(--fg-subtle)}.channel-card{gap:var(--sp-1);flex-direction:column;display:flex}.channel-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.channel-detail{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-card{gap:var(--sp-2);flex-direction:column;display:flex}.curator-health-message{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.curator-meta{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-actions{gap:var(--sp-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.curator-action{border-top:1px solid var(--border);padding-top:var(--sp-2)}.curator-action-head{justify-content:space-between;gap:var(--sp-2);font-size:var(--text-sm);display:flex}.curator-action-type{color:var(--fg);font-weight:600}.curator-action-time{color:var(--fg-subtle);font-size:var(--text-xs)}.curator-action-detail{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.curator-action-reason{color:var(--fg-subtle);font-size:var(--text-xs);margin:var(--sp-1) 0 0}.cfg-page{max-width:70rem;margin:0 auto}.cfg-section{margin-bottom:var(--sp-4)}.cfg-subhead{font-size:var(--text-sm);color:var(--fg-muted);margin:var(--sp-5) 0 var(--sp-2);font-weight:600}.cfg-subhead:first-child{margin-top:0}.kv-list{column-gap:var(--sp-4);grid-template-columns:max-content minmax(0,1fr) auto;row-gap:0;display:grid}.kv{grid-template-columns:subgrid;align-items:center;row-gap:var(--sp-1);padding:var(--sp-2) 0;border-radius:var(--radius-sm);grid-column:1/-1;display:grid}@supports not (grid-template-columns:subgrid){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(8rem,16rem) minmax(0,1fr) auto}}.kv+.kv{border-top:1px solid var(--border)}.kv:hover{background:var(--surface-hover)}.kv-label{font-size:var(--text-sm);color:var(--fg-muted)}.kv-value{min-width:0;font-size:var(--text-sm);color:var(--fg);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-value.is-empty{color:var(--fg-subtle)}.kv-actions{align-items:center;gap:var(--sp-2);justify-self:end;display:flex}.kv-note{font-size:var(--text-xs);color:var(--fg-subtle);grid-column:2/-1}.kv-note.is-error{color:var(--danger)}.kv.is-locked .kv-value{color:var(--fg-muted)}.kv-btn{font:inherit;font-size:var(--text-xs);color:var(--fg-subtle);border:1px solid var(--border);border-radius:var(--radius-sm);padding:2px var(--sp-2);cursor:pointer;background:0 0;flex:none;transition:color .12s,border-color .12s,background .12s}.kv:hover .kv-btn,.kv:focus-within .kv-btn{color:var(--fg-muted);border-color:var(--border-strong)}.kv-btn:hover{color:var(--fg);border-color:var(--accent);background:var(--accent-soft)}.kv-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.kv-flag{font-size:var(--text-xs);color:var(--warn);background:var(--warn-soft);border-radius:var(--radius-pill);padding:1px var(--sp-2);flex:none}.kv-input{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--bg,var(--surface));border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);width:100%;min-width:0}.kv-input:focus{outline:2px solid var(--accent);outline-offset:-1px}.kv-save,.kv-cancel{font:inherit;font-size:var(--text-xs);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);cursor:pointer;flex:none}.kv-save{background:var(--accent);border:1px solid var(--accent);color:var(--accent-fg);font-weight:500}.kv-save:disabled{opacity:.6;cursor:default}.kv-cancel{border:1px solid var(--border-strong);color:var(--fg-muted);background:0 0}.kv-cancel:hover{color:var(--fg)}.cfg-notice{border-left:3px solid var(--warn)}.cfg-notice p{font-size:var(--text-sm);color:var(--warn);margin:0}@media (width<=700px){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(0,1fr) auto}.kv-label{grid-column:1}.kv-actions{grid-area:1/2}.kv-value,.kv-note{white-space:normal;overflow-wrap:anywhere;grid-column:1/-1}}.cfg-note{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.cfg-actions{gap:var(--sp-2);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.cfg-request-row{align-items:center;gap:var(--sp-2);margin-bottom:var(--sp-3);flex-wrap:wrap;display:flex}.cfg-request-row select,.cfg-request-row input{min-width:0;padding:var(--sp-2) var(--sp-3);background:var(--surface-hover);color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);font:inherit;font-size:var(--text-sm);flex:0 22rem}.cfg-pending{justify-content:space-between;align-items:center;gap:var(--sp-3);padding:var(--sp-3) 0;border-top:1px solid var(--hairline);flex-wrap:wrap;display:flex}.cfg-pending .cfg-actions{margin-top:0}.log-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.log-status{gap:var(--sp-3);align-items:center;display:flex}.log-meta{font-size:var(--text-xs);color:var(--fg-subtle);font-family:var(--font-mono)}.log-select,.log-search{background:var(--bg-raised);border:1px solid var(--border-strong);color:var(--fg);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);font:inherit;font-size:var(--text-sm)}.log-search{min-width:220px}.log-select:focus,.log-search:focus{outline:2px solid var(--accent);outline-offset:-1px}.log-list{max-height:62vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);overflow-y:auto}.log-loading{padding:var(--sp-5);color:var(--fg-muted);text-align:center}.log-row{gap:var(--sp-3);padding:var(--sp-2) var(--sp-1);border-bottom:1px solid var(--border);grid-template-columns:62px 52px 1fr;align-items:baseline;display:grid}.log-row:hover{background:var(--surface-hover)}.log-time{color:var(--fg-subtle)}.log-level{letter-spacing:.04em;font-size:10px;font-weight:600}.log-danger .log-level{color:var(--danger)}.log-warn .log-level{color:var(--warn)}.log-info .log-level{color:var(--info)}.log-idle .log-level{color:var(--idle)}.log-danger .log-msg{color:var(--fg)}.log-body{gap:var(--sp-2);flex-wrap:wrap;align-items:baseline;min-width:0;display:flex}.log-msg{color:var(--fg);word-break:break-word}.log-field{color:var(--fg-muted);background:var(--bg-raised);border-radius:var(--radius-sm);padding:0 var(--sp-2);white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden}.log-field-key{color:var(--fg-subtle)}.log-field-key:after{content:"=";opacity:.6}@media (width<=860px){.log-row{grid-template-columns:56px 1fr}.log-level{display:none}.log-search{flex:1;min-width:0}}.capture-row{cursor:pointer}.capture-row:hover{background:var(--bg-raised)}.capture-row:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.capture-detail-row td{padding:var(--sp-3) var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border)}.capture-detail{gap:var(--sp-4);grid-template-columns:1fr 1fr;display:grid}.capture-detail-section{min-width:0}.capture-detail-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.capture-payload{background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-3);font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;word-break:break-word;max-height:24rem;overflow:auto}.capture-empty{color:var(--fg-muted);font-size:var(--text-sm)}@media (width<=640px){.capture-detail{grid-template-columns:1fr}}.mapping-form,.mapping-fields,.mapping-payload{margin-bottom:var(--sp-4);padding:var(--sp-4)}.mapping-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.mapping-input,.mapping-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.mapping-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.mapping-fields-table .mapping-input{width:100%}.mapping-empty-fields{color:var(--fg-muted);font-size:var(--text-sm);padding:var(--sp-3) 0}.mapping-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.mapping-tree-list{padding-left:var(--sp-4);font-family:var(--font-mono);font-size:var(--text-xs);margin:0;list-style:none}.mapping-tree-item{padding:2px 0}.mapping-tree-key,.mapping-tree-value{cursor:pointer;border-radius:var(--radius-sm);padding:0 4px}.mapping-tree-key:hover,.mapping-tree-value:hover{background:var(--bg-raised);outline:1px solid var(--accent)}.mapping-tree-value{color:var(--fg-subtle);margin-left:var(--sp-1)}.binding-form{margin-bottom:var(--sp-4);padding:var(--sp-4)}.binding-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.binding-input,.binding-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.binding-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.chat-panel-content{flex:auto;grid-template-rows:auto auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.chat-bar{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);display:flex}.chat-session-switch{flex:auto;min-width:0}.chat-session-switch select{background:var(--surface-hover);width:100%;color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);padding:var(--sp-2);font:inherit;font-size:var(--text-sm)}.chat-new,.chat-settings>summary{flex:none}.chat-settings{flex:none;position:relative}.chat-settings>summary{border-radius:var(--radius-sm);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;place-items:center;list-style:none;display:grid}.chat-settings>summary::-webkit-details-marker{display:none}.chat-settings>summary:hover{background:var(--surface-hover);color:var(--fg)}.chat-settings-body{top:calc(100% + var(--sp-2));z-index:2;gap:var(--sp-3);width:15rem;padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);display:grid;position:absolute;right:0}.chat-settings-body label{gap:var(--sp-1);font-size:var(--text-xs);color:var(--fg-muted);display:grid}.chat-settings-body .chat-select{width:100%}.chat-layout{min-height:0;display:grid;overflow:hidden}.chat-workspace{grid-template-rows:auto minmax(0,1fr) auto;min-width:0;display:grid;overflow:hidden}.chat-workspace-head{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);font-size:var(--text-xs);display:flex}.chat-update-panel{border:1px solid var(--border);color:var(--fg-muted);border-radius:.75rem;flex:none;justify-content:space-between;align-items:center;gap:1rem;margin:0 0 .75rem;padding:.7rem .9rem;font-size:.8rem;display:flex}.chat-update-panel>div:first-child{gap:.2rem;display:grid}.chat-update-panel strong{color:var(--fg)}.chat-update-actions{flex-shrink:0;gap:.45rem;display:flex}.chat-dangerous-panel{border:1px solid color-mix(in srgb, var(--danger) 45%, var(--border));border-radius:.75rem;flex:none;margin:0 0 .75rem;padding:.8rem .9rem}.chat-dangerous-head,.chat-dangerous-controls,.chat-dangerous-pending{justify-content:space-between;align-items:center;gap:.6rem;display:flex}.chat-dangerous-head{margin-bottom:.7rem}.chat-dangerous-controls{flex-wrap:wrap;align-items:stretch}.chat-dangerous-controls>div{flex:18rem;gap:.45rem;display:flex}.chat-dangerous-input{background:var(--surface-hover);min-width:0;color:var(--fg);border:1px solid var(--border-strong);font:inherit;border-radius:.5rem;flex:1;padding:.5rem .65rem}.chat-dangerous-pending-list{gap:.45rem;margin-top:.75rem;display:grid}.chat-dangerous-pending{border-top:1px solid var(--border);color:var(--fg-muted);padding-top:.55rem;font-size:.8rem}.chat-session-list{gap:.35rem;margin-top:1rem;display:grid}.chat-session{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.65rem;gap:.25rem;padding:.7rem;display:grid}.chat-session:hover,.chat-session.active{background:var(--surface-hover);color:var(--fg);border-color:var(--border-strong)}.chat-session span{font-size:.72rem}.chat-session-tools{color:var(--fg-muted);margin-left:.6rem;font-size:.78rem;position:relative}.chat-session-tools summary{cursor:pointer}.chat-session-tool-list{z-index:2;background:var(--surface);border:1px solid var(--border-strong);border-radius:.65rem;flex-wrap:wrap;gap:.35rem;width:min(22rem,72vw);padding:.55rem;display:flex;position:absolute;top:calc(100% + .45rem);right:0;box-shadow:0 .7rem 2rem #0000004d}.chat-select{background:var(--surface-hover);color:var(--fg);border:1px solid var(--border-strong);border-radius:.5rem;padding:.5rem .65rem}.chat-transcript{padding:var(--sp-4);align-content:start;gap:var(--sp-4);display:grid;overflow:auto}.chat-empty-state{width:100%;padding:var(--sp-5) 0;text-align:center;place-self:center}.chat-empty-mark{width:2.2rem;height:2.2rem;margin:0 auto var(--sp-3);border:1px solid var(--border-strong);color:var(--accent);border-radius:.8rem;place-items:center;font-weight:700;display:grid}.chat-empty-state h2{font-size:var(--text-lg);letter-spacing:-.02em;margin:0}.chat-empty-state p{margin:var(--sp-2) 0 var(--sp-4);color:var(--fg-muted);font-size:var(--text-sm)}.chat-prompt-grid{gap:var(--sp-2);display:grid}.chat-prompt{padding:var(--sp-2) var(--sp-3);font-size:var(--text-sm);text-align:left;border:1px solid var(--border);background:var(--surface-hover);color:var(--fg-muted);cursor:pointer;border-radius:999px}.chat-prompt:hover{color:var(--fg);border-color:var(--border-strong)}.chat-bubble-row{display:flex}.chat-bubble-row.user{justify-content:flex-end}.chat-bubble{background:var(--surface-hover);border-radius:.85rem;max-width:min(78ch,86%);padding:.8rem 1rem;line-height:1.5}.chat-bubble-row.user .chat-bubble{background:color-mix(in srgb, var(--accent) 18%, var(--surface))}.chat-bubble-meta{color:var(--fg-muted);margin-bottom:.3rem;font-size:.7rem}.chat-bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}.chat-bubble-text p{margin:0 0 .7rem}.chat-bubble-text p:last-child{margin-bottom:0}.chat-bubble-text h1,.chat-bubble-text h2,.chat-bubble-text h3{letter-spacing:-.02em;margin:.2rem 0 .6rem;line-height:1.2}.chat-bubble-text h1{font-size:1.25rem}.chat-bubble-text h2{font-size:1.1rem}.chat-bubble-text h3{font-size:1rem}.chat-bubble-text ul,.chat-bubble-text ol{margin:.25rem 0 .75rem;padding-left:1.35rem}.chat-bubble-text blockquote{border-left:3px solid var(--accent);color:var(--fg-muted);margin:.5rem 0;padding:.35rem .75rem}.chat-bubble-text code{background:color-mix(in srgb, var(--fg) 10%, transparent);border-radius:.3rem;padding:.1rem .3rem;font-size:.9em}.chat-bubble-text pre{border:1px solid var(--border);background:color-mix(in srgb, var(--surface) 75%, #000);border-radius:.5rem;margin:.6rem 0;padding:.75rem;overflow:auto}.chat-bubble-text pre code{background:0 0;padding:0}.chat-bubble-text a{color:var(--accent)}.chat-media-img{border:1px solid var(--border);object-fit:contain;background:var(--surface);cursor:pointer;border-radius:.5rem;max-width:100%;max-height:24rem;margin:.4rem 0;display:block}.chat-bubble-text table{border-collapse:collapse;width:100%;margin:.7rem 0;font-size:.92em}.chat-bubble-text th,.chat-bubble-text td{text-align:left;border:1px solid var(--border);padding:.45rem .6rem}.chat-bubble-text th{color:var(--fg);background:color-mix(in srgb, var(--surface) 70%, transparent);font-weight:700}.chat-tools{gap:.2rem;margin-bottom:.5rem;font-size:.78rem;display:grid}.chat-tools:empty{display:none}.chat-tool{color:var(--fg-muted);overflow-wrap:anywhere;align-items:baseline;gap:.4rem;display:flex}.chat-tool-name{color:var(--fg);font-weight:600}.chat-tool.failed .chat-tool-summary{color:var(--danger)}.chat-nav-chip{border:1px solid color-mix(in srgb, var(--accent) 45%, var(--border));background:var(--accent-soft);color:var(--accent);cursor:pointer;transition:background var(--transition), border-color var(--transition), color var(--transition);border-radius:999px;align-items:center;gap:.4rem;padding:.4rem .7rem;font-size:.82rem;font-weight:600;display:inline-flex}.chat-nav-chip:hover{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.chat-nav-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.chat-nav-chip-icon{font-size:.8rem;line-height:1}.chat-compose{padding:var(--sp-3);border-top:1px solid var(--border)}.chat-composer-shell{align-items:flex-end;gap:var(--sp-2);background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem;display:flex;position:relative}.chat-composer{resize:none;box-sizing:border-box;min-width:0;min-height:2.6rem;color:var(--fg);font:inherit;background:0 0;border:0;flex:auto;padding:.25rem 0}.chat-composer:focus{outline:0}.chat-command-menu{z-index:3;background:var(--surface);border:1px solid var(--border-strong);border-radius:.7rem;gap:.15rem;max-height:18rem;padding:.35rem;display:grid;position:absolute;bottom:calc(100% - .25rem);left:.8rem;right:.8rem;overflow:auto;box-shadow:0 .7rem 2rem #0000004d}.chat-command-menu[hidden]{display:none}.chat-command-option{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.45rem;grid-template-columns:minmax(8rem,14rem) 1fr;align-items:center;gap:.65rem;padding:.5rem .6rem;display:grid}.chat-command-option:hover,.chat-command-option[aria-selected=true]{color:var(--fg);background:var(--surface-hover);border-color:var(--border)}.chat-command-option code{color:var(--fg)}.chat-compose-actions{align-items:center;gap:var(--sp-2);flex:none;display:flex}.chat-hint,.chat-empty{color:var(--fg-muted);font-size:.78rem}.chat-command-help{color:var(--fg-muted);margin-right:auto;font-size:.78rem}.chat-command-help summary{cursor:pointer}.chat-command-list{min-width:min(34rem,70vw);max-width:40rem;padding-top:.4rem;line-height:1.45}.chat-command-item{grid-template-columns:minmax(10rem,16rem) 1fr;gap:.7rem;padding:.3rem 0;display:grid}.chat-command-item code{color:var(--fg)}@media (width<=520px){.chat-update-panel{flex-direction:column;align-items:flex-start}} +:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#7d8b9e;--accent:#4c8dff;--accent-fg:#0d1014;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#636f82;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden,.sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{scrollbar-width:none;border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);flex:0 auto;align-items:center;gap:2px;min-width:0;margin:0 auto;padding:3px;display:flex;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);flex:none;display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accent), var(--accent-2));cursor:pointer;flex:none;place-items:center;font-weight:600;display:grid}.ico{flex:none;display:block}.main{padding:var(--sp-6);flex:1;width:100%;overflow-x:hidden}.chat-dock{--fab-size:56px;--fab-inset:var(--sp-5);--fab-gap:var(--sp-3);right:var(--fab-inset);bottom:var(--fab-inset);z-index:40;position:fixed}.chat-fab{width:var(--fab-size);height:var(--fab-size);border-radius:var(--radius-pill);background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;cursor:pointer;box-shadow:var(--shadow-md);transition:transform var(--transition), box-shadow var(--transition);border:0;place-items:center;display:grid;position:relative}.chat-fab:hover{box-shadow:0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);transform:translateY(-1px)}.chat-fab:active{transform:translateY(0)}.chat-fab-icon{transition:opacity var(--transition), transform var(--transition);grid-area:1/1;place-items:center;display:grid}.chat-fab-icon-close,.chat-dock.is-open .chat-fab-icon-open{opacity:0;transform:scale(.7)rotate(-45deg)}.chat-fab-icon-open,.chat-dock.is-open .chat-fab-icon-close{opacity:1;transform:none}.chat-drawer{right:calc(var(--fab-size) + var(--fab-gap));width:min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));height:min(640px, calc(100vh - var(--fab-inset) * 2));pointer-events:none;position:absolute;bottom:0}.chat-drawer-panel{pointer-events:auto;background:var(--surface);border:1px solid var(--border);width:100%;height:100%;box-shadow:var(--shadow-md);opacity:0;border-radius:var(--radius-pill);transform-origin:100% 100%;transform:translateX(calc(var(--fab-size) + var(--fab-gap))) scale(.16);grid-template-rows:minmax(0,1fr);transition:opacity .16s cubic-bezier(.4,0,.2,1),transform .26s cubic-bezier(.22,1,.36,1),border-radius .26s cubic-bezier(.22,1,.36,1);display:grid;overflow:hidden}.chat-drawer.is-open .chat-drawer-panel{opacity:1;border-radius:var(--radius-lg);transform:none}.chat-drawer-panel>*{opacity:0;transition:opacity .12s linear}.chat-drawer.is-open .chat-drawer-panel>*{opacity:1;transition:opacity .16s linear .12s}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none;visibility:hidden;transition:opacity .14s cubic-bezier(.4,0,.2,1),transform .2s cubic-bezier(.4,0,1,1),border-radius .2s cubic-bezier(.4,0,1,1),visibility 0s linear .2s}.chat-drawer-head{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border);display:flex}@media (width<=720px){.chat-dock{--fab-inset:var(--sp-4)}.chat-drawer{right:var(--fab-inset);left:var(--fab-inset);bottom:calc(var(--fab-inset) + var(--fab-size) + var(--fab-gap));width:auto;height:min(72vh, calc(100vh - var(--fab-inset) * 2 - var(--fab-size) - var(--fab-gap)));position:fixed}.chat-drawer-panel{transform-origin:100% 100%;transform:translateY(calc(var(--fab-size) + var(--fab-gap))) scale(.16)}.chat-fab{z-index:1;position:relative}}@media (width<=1500px){.topbar-search{background:0 0;border:0;padding:0;overflow:hidden}.topbar-search-icon{display:none}.mobile-search-toggle{display:grid}.topbar-search input{opacity:0;pointer-events:none;width:0;transition:width var(--transition), opacity var(--transition);padding:0}.topbar-search.is-open,.topbar-search:focus-within{padding-right:var(--sp-2);border:1px solid var(--hairline);background:var(--surface-glass-strong)}.topbar-search.is-open input,.topbar-search:focus-within input{opacity:1;pointer-events:auto;width:min(9rem,34vw)}}@media (width<=1270px) and (width>=901px){.topbar{flex-wrap:wrap}.nav{border-radius:var(--radius-lg);flex-wrap:wrap;order:3;justify-content:center;width:100%;margin:0}}@media (width<=900px){body{padding:0}.shell{min-height:100vh;box-shadow:none;border:0;border-radius:0}.topbar{padding:var(--sp-3);gap:var(--sp-2);flex-wrap:wrap}.nav{border-radius:var(--radius-lg);scrollbar-width:none;flex-wrap:nowrap;order:3;justify-content:flex-start;width:100%;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item .nav-label{display:inline}.main{padding:var(--sp-4)}}.page-head{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-6);flex-wrap:wrap;display:flex}.page-title{font-size:var(--text-2xl);letter-spacing:-.02em;margin:0;font-weight:600}.page-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.page-actions{gap:var(--sp-2);align-items:center;display:flex}.btn{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-4);border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:background var(--transition), border-color var(--transition);display:inline-flex}.btn:hover{background:var(--surface-hover)}.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg);font-weight:500}.btn-primary:hover{filter:brightness(1.08);background:var(--accent)}.btn-icon{padding:var(--sp-2);border-radius:var(--radius-sm)}.card{background:var(--surface-glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--hairline);border-radius:var(--radius-lg);padding:var(--sp-5);box-shadow:var(--shadow-sm);overflow-x:auto}.card-head{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.card-title{font-size:var(--text-base);margin:0;font-weight:600}.card-sub{font-size:var(--text-xs);color:var(--fg-muted);margin:var(--sp-1) 0 0}.grid{gap:var(--sp-4);display:grid}.grid>*{min-width:0}.grid-4{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}.pill{align-items:center;gap:var(--sp-1);padding:2px var(--sp-2);border-radius:var(--radius-pill);font-size:var(--text-xs);white-space:nowrap;font-weight:500;display:inline-flex}.pill:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.pill-ok{color:var(--ok);background:var(--ok-soft)}.pill-warn{color:var(--warn);background:var(--warn-soft)}.pill-danger{color:var(--danger);background:var(--danger-soft)}.pill-info{color:var(--info);background:var(--info-soft)}.pill-idle{color:var(--idle);background:var(--idle-soft)}.table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}.table-scroll{-webkit-overflow-scrolling:touch;min-width:0;max-width:100%;overflow-x:auto}.table-scroll>.table{min-width:42rem}.table th{text-align:left;font-weight:500;font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);padding:0 var(--sp-3) var(--sp-3);border-bottom:1px solid var(--border)}.table td{padding:var(--sp-3);border-bottom:1px solid var(--border);color:var(--fg-muted)}.table tbody tr:last-child td{border-bottom:0}.table tbody tr:hover td{background:var(--surface-hover)}.table td.strong{color:var(--fg);font-weight:500}.mono{font-family:var(--font-mono);font-size:.95em}.empty{text-align:center;padding:var(--sp-7) var(--sp-4);color:var(--fg-muted)}.empty-title{color:var(--fg);margin-bottom:var(--sp-1);font-weight:500}.skeleton{background:linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);border-radius:var(--radius-sm);background-size:200% 100%;animation:1.4s infinite shimmer}@keyframes shimmer{to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}.nav-soon{font-size:var(--text-xs);color:var(--fg-subtle);background:var(--surface-hover);padding:1px var(--sp-2);border-radius:var(--radius-pill);margin-left:auto}.nav-item[aria-disabled]{opacity:.55;cursor:default}.nav-item[aria-disabled]:hover{color:var(--fg-muted);background:0 0}.stat-head{justify-content:space-between;align-items:center;gap:var(--sp-2);display:flex}.stat-label{font-size:var(--text-sm);color:var(--fg-muted)}.stat-trend{font-size:var(--text-xs);align-items:center;gap:3px;font-weight:500;display:inline-flex}.stat-trend.up{color:var(--ok)}.stat-trend.down{color:var(--danger)}.stat-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin:var(--sp-2) 0 0;font-weight:600}.stat-unit{font-size:var(--text-lg);color:var(--fg-muted);margin-left:var(--sp-1)}.stat-compare{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:var(--sp-1)}.spark{width:100%;height:34px;margin-top:var(--sp-3);display:block}.setup{margin-bottom:var(--sp-4)}.setup-pct{font-size:var(--text-lg);color:var(--accent);font-weight:600}.setup-complete-actions{align-items:center;gap:var(--sp-2);display:flex}.setup-dismiss{width:28px;height:28px;font-size:var(--text-lg);line-height:1}.setup-done .setup-pct{color:var(--ok)}.setup-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-bottom:var(--sp-4);overflow:hidden}.setup-bar-fill{background:var(--accent);border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.setup-list{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.setup-step{gap:var(--sp-3);align-items:flex-start;display:flex}.setup-check{border:1.5px solid var(--border-strong);width:18px;height:18px;font-size:var(--text-xs);color:var(--fg-subtle);border-radius:50%;flex:none;place-items:center;margin-top:1px;display:grid}.setup-step.done .setup-check{background:var(--ok-soft);color:var(--ok);border-color:#0000}.setup-step-title{font-size:var(--text-sm)}.setup-step.done .setup-step-title{color:var(--fg-muted);text-decoration:line-through}.setup-step-detail{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.hero{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-5);flex-wrap:wrap;display:flex}.hero-title{font-size:var(--text-3xl);letter-spacing:-.03em;margin:0;font-weight:600}.hero-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-2) 0 0}.hero-actions{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.dash-top{gap:var(--sp-4);margin-bottom:var(--sp-4);grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);display:grid}.dash-top>*,.dash-split>*{min-width:0}.dash-top{align-items:start}.dash-top-standalone{grid-template-columns:minmax(0,1fr)}@media (width<=1080px){.dash-top{grid-template-columns:minmax(0,1fr)}}.gauge-wrap{place-items:center;display:grid;position:relative}.gauge{width:100%;max-width:200px;display:block}.gauge-value{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1)}.gauge-center{text-align:center;position:absolute;top:52%;transform:translateY(-50%)}.gauge-pct{font-size:var(--text-2xl);letter-spacing:-.03em;font-weight:600}.gauge-label{font-size:var(--text-xs);color:var(--fg-muted)}.pulse-list{margin:var(--sp-4) 0 0;gap:var(--sp-2);flex-direction:column;padding:0;list-style:none;display:flex}.pulse-item{justify-content:space-between;align-items:center;gap:var(--sp-3);font-size:var(--text-sm);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);display:flex}.pulse-name{color:var(--fg-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.segbar{border-radius:var(--radius-pill);background:var(--border);gap:2px;height:10px;display:flex;overflow:hidden}.segbar-part{height:100%;display:block}.segbar-ok{background:var(--ok)}.segbar-warn{background:var(--warn)}.segbar-danger{background:var(--danger)}.segbar-info{background:var(--info)}.segbar-idle{background:var(--idle)}.segbar-legend{gap:var(--sp-4);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.segbar-key{align-items:center;gap:var(--sp-2);font-size:var(--text-xs);color:var(--fg-muted);display:inline-flex}.segbar-dot{border-radius:50%;width:8px;height:8px}.forecast-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin-bottom:var(--sp-1);font-weight:600}.forecast-note{font-size:var(--text-xs);color:var(--fg-subtle);margin-bottom:var(--sp-4)}.dash-split{gap:var(--sp-4);margin-top:var(--sp-4);grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);display:grid}@media (width<=1080px){.dash-split{grid-template-columns:minmax(0,1fr)}}.stat-card{position:relative;overflow:hidden}.dash-section{margin-bottom:var(--sp-5)}.dash-section-head{align-items:baseline;gap:var(--sp-3);margin-bottom:var(--sp-3);padding-left:var(--sp-1);display:flex}.dash-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--fg-subtle);margin:0;font-weight:600}.dash-section-note{font-size:var(--text-xs);color:var(--fg-subtle)}.hero-actions-inner{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.btn-attention{border-color:var(--warn);color:var(--warn);background:var(--warn-soft);font-weight:500}.btn-attention:hover{background:var(--warn-soft);filter:brightness(1.1)}.activity-detail{width:55%;max-width:0}.activity-detail span{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.task-summary{margin-bottom:var(--sp-5)}.task-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.task-search,.task-filter{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3)}.task-search{width:220px}.task-search:focus,.task-filter:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.task-row{cursor:pointer}.task-expand{width:1.5rem;height:1.5rem;margin-right:var(--sp-2);color:var(--fg-muted);border:1px solid var(--border);font:inherit;cursor:pointer;background:0 0;border-radius:50%;padding:0;line-height:1}.task-expand:hover,.task-expand:focus-visible{color:var(--fg);border-color:var(--accent)}.activity-row{cursor:pointer}.activity-row:hover td,.activity-row:focus td{background:var(--surface-hover)}.activity-row:focus{outline:2px solid var(--accent);outline-offset:-2px}.task-source-link{color:var(--accent);text-decoration:none}.task-source-link:hover{text-decoration:underline}.task-detail-link{color:inherit}.task-detail-link:hover,.task-detail-link:focus-visible{text-decoration:underline;-webkit-text-decoration-color:var(--accent);text-decoration-color:var(--accent)}.task-actions{gap:var(--sp-1);white-space:nowrap;flex-wrap:wrap;display:flex}.btn-small{padding:var(--sp-1) var(--sp-2);font-size:var(--text-xs)}.btn-quiet{color:var(--fg-muted)}.task-action-error{max-width:220px;font-size:var(--text-xs);white-space:normal}.task-action-error-refused{color:var(--warn)}.task-action-error-broken{color:var(--danger)}.task-action-error-session{color:var(--warn);align-items:center;gap:var(--sp-1);flex-wrap:wrap;display:inline-flex}.task-decision{margin-bottom:var(--sp-4);padding:var(--sp-3);border-left:3px solid var(--accent);background:var(--surface)}.task-detail-actions{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);padding-bottom:var(--sp-3);border-bottom:1px solid var(--hairline);display:flex}.task-decision-title{color:var(--fg);font-weight:600}.task-decision-plan{margin-top:var(--sp-2);color:var(--fg-muted);white-space:pre-wrap}.task-logs-section{margin-top:var(--sp-4)}.task-logs-section .task-decision-title{justify-content:space-between;align-items:center;display:flex}.task-log-list{max-height:40vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);margin-top:var(--sp-2);overflow-y:auto}.task-log-loading,.task-log-error{padding:var(--sp-3) 0;color:var(--fg-muted)}@media (width<=700px){.task-filters,.task-search{width:100%}.task-filter{flex:100%}.table-scroll:has(.task-row){overflow:visible}.table:has(.task-row){display:block}.table:has(.task-row) tbody{display:block}.table-scroll>.table:has(.task-row){width:100%;min-width:0}.table:has(.task-row) thead{display:none}.task-row{gap:var(--sp-2) var(--sp-4);margin-bottom:var(--sp-3);padding:var(--sp-3);border:1px solid var(--hairline);border-radius:var(--radius-lg);background:var(--surface-glass);grid-template-columns:1fr 1fr;display:grid}.task-row td{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-1) 0;text-align:right;border:0;display:flex}.task-row td:before{content:attr(data-label);color:var(--fg-subtle);font-size:var(--text-xs);text-align:left;font-weight:500}.task-row td:nth-child(3),.task-row td:last-child{grid-column:1/-1}.task-row td:last-child{align-items:flex-start}.task-timeline-row,.task-timeline-row td{width:100%;display:block}.task-timeline-row td{margin:calc(var(--sp-2) * -1) 0 var(--sp-4);border-radius:0 0 var(--radius-lg) var(--radius-lg)}.task-detail-actions{flex-direction:column;align-items:flex-start}}@media (width<=480px){.task-row{grid-template-columns:1fr}.task-row td:nth-child(3),.task-row td:last-child{grid-column:auto}}.task-timeline-row td{background:var(--bg-raised);padding:var(--sp-4)}.task-timeline-loading{color:var(--fg-muted);font-size:var(--text-sm)}.task-timeline-error{align-items:flex-start;gap:var(--sp-2);flex-direction:column;display:flex}.task-timeline-error .task-timeline-title{color:var(--fg);font-weight:500}.task-timeline{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.task-timeline-entry{gap:var(--sp-3);align-items:flex-start;display:flex}.task-timeline-dot{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px;margin-top:5px}.task-timeline-kind{font-size:var(--text-sm);color:var(--fg);font-weight:500}.task-timeline-detail{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}.task-timeline-when{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.run-meta{align-items:center;gap:var(--sp-4);margin:calc(var(--sp-2) * -1) 0 var(--sp-4);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.run-meta-item{align-items:center;gap:var(--sp-2);display:inline-flex}.run-meta-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.run-meta-value{color:var(--fg)}.run-meta-muted{color:var(--fg-muted)}.run-meta-link{color:var(--accent)}.run-meta-link:hover{text-decoration:underline}.run-note{margin:0 0 var(--sp-4);padding:var(--sp-3) var(--sp-4);border-left:3px solid var(--warn);background:var(--warn-soft);border-radius:var(--radius-sm);color:var(--fg);font-size:var(--text-sm)}.run-restart{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-restart-copy,.run-restart-unavailable{color:var(--fg-muted);font-size:var(--text-sm);flex:22rem;margin:0}.run-restart-error{font-size:var(--text-sm);flex:100%;margin:0}.run-restart-error-refused{color:var(--warn)}.run-restart-error-broken{color:var(--danger)}.run-restart-error-session-expired{color:var(--warn)}.run-attempts{gap:var(--sp-2);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-attempt{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border:1px solid var(--border);border-radius:var(--radius-pill);background:var(--surface);color:var(--fg-muted);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:border-color var(--transition), color var(--transition);display:inline-flex}.run-attempt:hover{border-color:var(--border-strong);color:var(--fg)}.run-attempt.is-selected{border-color:var(--accent);background:var(--accent-soft);color:var(--fg)}.run-attempt-id{font-weight:500}.run-attempt-meta{color:var(--fg-muted);font-size:var(--text-xs)}.run-card{padding-top:var(--sp-4)}.tab-bar{gap:var(--sp-1);border-bottom:1px solid var(--border);margin-bottom:var(--sp-4);scrollbar-width:thin;display:flex;overflow-x:auto}.tab{padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--fg-muted);font:inherit;font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:color var(--transition), background var(--transition);background:0 0;border:0;border-bottom:2px solid #0000;position:relative}.tab:hover{color:var(--fg);background:var(--surface-hover)}.tab.is-selected{color:var(--fg);border-bottom-color:var(--accent);font-weight:500}.run-panel{min-width:0;min-height:6rem}.run-panel:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.run-loading{padding:var(--sp-5) 0;color:var(--fg-muted);font-size:var(--text-sm)}.run-error{align-items:flex-start;gap:var(--sp-2);padding:var(--sp-3) 0;flex-direction:column;display:flex}.run-error-title{color:var(--fg);font-weight:500}.run-error-detail{color:var(--fg-muted);font-size:var(--text-sm);max-width:60ch}.run-json{padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-sm);max-height:60vh;font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;line-height:1.5;overflow:auto}.run-rail-head{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-rail-attempt{font-weight:600}.run-rail-when{color:var(--fg-muted);font-size:var(--text-xs)}.run-stages{margin:0;padding:0;list-style:none}.run-stage{gap:var(--sp-2);padding-bottom:var(--sp-4);grid-template-columns:1.75rem 1fr;display:grid;position:relative}.run-stage:before{content:"";background:var(--border-strong);width:1px;position:absolute;top:1rem;bottom:0;left:.6875rem}.run-stage:last-child:before{display:none}.run-stage-node{z-index:1;border:2px solid var(--border-strong);background:var(--bg-raised);border-radius:50%;width:.875rem;height:.875rem;margin:.25rem 0 0 .25rem;position:relative}.run-stage[data-status=ok] .run-stage-node{border-color:var(--ok)}.run-stage[data-status=failed] .run-stage-node{border-color:var(--danger)}.run-stage[data-status=interrupted] .run-stage-node{border-color:var(--warn)}.run-stage[data-status=running] .run-stage-node{border-color:var(--info)}.run-stage-body{min-width:0}.run-stage-head{align-items:center;gap:var(--sp-2);flex-wrap:wrap;display:flex}.run-stage-name{color:var(--fg);overflow-wrap:anywhere;min-width:0;font-weight:500}.run-stage-duration{color:var(--fg-muted);font-size:var(--text-xs)}.run-stage-error{margin-top:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-left:3px solid var(--danger);background:var(--danger-soft);border-radius:var(--radius-sm);color:var(--fg-muted);font-size:var(--text-sm);white-space:pre-wrap;overflow-wrap:anywhere}.run-agent-report{margin-top:var(--sp-2);color:var(--fg-muted);font-size:var(--text-xs)}.run-agent-report-label{color:var(--fg-muted)}.run-rail-legend,.run-rail-note{margin:var(--sp-3) 0 0;color:var(--fg-muted);font-size:var(--text-xs);max-width:70ch}.run-rail-legend strong{color:var(--fg-muted)}.run-capture+.run-capture{margin-top:var(--sp-5);padding-top:var(--sp-4);border-top:1px solid var(--border)}.run-capture-head{justify-content:space-between;align-items:baseline;gap:var(--sp-3);flex-wrap:wrap;display:flex}.run-capture-when{color:var(--fg);font-size:var(--text-sm);font-weight:500}.run-capture-at{color:var(--fg-muted);font-size:var(--text-xs)}.run-capture-meta{align-items:center;gap:var(--sp-3);margin:var(--sp-2) 0 var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs);flex-wrap:wrap;display:flex}.run-capture-link{color:var(--accent)}.run-capture-link:hover{text-decoration:underline}.run-capture-branch,.run-capture-sha,.run-capture-totals{color:var(--fg-muted)}.run-changes-table td{padding:var(--sp-2) var(--sp-3);vertical-align:top}.run-changes-path{color:var(--fg);word-break:break-all}.run-changes-old{color:var(--fg-muted)}.run-changes-count{text-align:right;white-space:nowrap}.run-changes-hint,.run-changes-note,.run-changes-empty{color:var(--fg-muted);font-size:var(--text-xs)}.run-changes-hint{display:block}.run-changes-empty{padding:var(--sp-3) 0}.run-config-scope{margin:0 0 var(--sp-2);color:var(--fg-muted);font-size:var(--text-sm);max-width:75ch}.run-config-when{margin-bottom:var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs)}.run-config-unknown{margin-bottom:var(--sp-2);color:var(--warn);font-size:var(--text-sm)}.task-log-filters{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border)}.task-log-attempt{color:var(--fg);font-size:var(--text-sm);font-weight:500}.task-log-filter{align-items:center;gap:var(--sp-2);display:inline-flex}.task-log-filter-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.task-log-filter-note{color:var(--fg-muted);font-size:var(--text-xs);flex:100%;max-width:80ch;margin:0}.run-panel .task-log-list{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-raised);max-height:62vh;padding:0 var(--sp-2)}.run-page .pill{color:var(--fg)}.run-page .pill-ok:before{background:var(--ok)}.run-page .pill-warn:before{background:var(--warn)}.run-page .pill-danger:before{background:var(--danger)}.run-page .pill-info:before{background:var(--info)}.run-page .pill-idle:before{background:var(--idle)}@media (width<=700px){.run-meta{margin-bottom:var(--sp-3)}.run-restart{align-items:flex-start}.run-attempts{padding-bottom:var(--sp-1);flex-wrap:nowrap;overflow-x:auto}.run-stage{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border);grid-template-columns:1fr}.run-stage:before,.run-stage-node{display:none}.run-capture-head{align-items:flex-start;gap:var(--sp-1);flex-direction:column}}@media (width<=480px){.tab{padding:var(--sp-2)}.run-json{max-height:45vh}}@media (prefers-reduced-motion:reduce){.run-attempt,.tab{transition:none}}.skill-search{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);width:220px}.skill-search:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.skill-card{flex-direction:column;display:flex}.skill-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0 0 var(--sp-3);flex:1}.skill-source{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-stage-card{margin-top:var(--sp-4)}.wf-rate{font-size:var(--text-sm);color:var(--fg);align-items:baseline;gap:var(--sp-2);display:flex}.wf-rate-sub{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-top:var(--sp-2);width:140px;overflow:hidden}.wf-bar-fill{border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.wf-bar-ok{background:var(--ok)}.wf-bar-warn{background:var(--warn)}.wf-bar-danger{background:var(--danger)}.wf-bar-info{background:var(--info)}.wf-form{gap:var(--sp-2);flex-direction:column;display:flex}.wf-form input,.wf-form select,.wf-form textarea{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2);width:100%}.wf-form textarea{resize:vertical}.wf-form input:focus,.wf-form select:focus,.wf-form textarea:focus{outline:2px solid var(--accent);outline-offset:-1px}.wf-form input::placeholder,.wf-form textarea::placeholder{color:var(--fg-subtle)}.channel-card{gap:var(--sp-1);flex-direction:column;display:flex}.channel-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.channel-detail{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-card{gap:var(--sp-2);flex-direction:column;display:flex}.curator-health-message{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.curator-meta{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-actions{gap:var(--sp-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.curator-action{border-top:1px solid var(--border);padding-top:var(--sp-2)}.curator-action-head{justify-content:space-between;gap:var(--sp-2);font-size:var(--text-sm);display:flex}.curator-action-type{color:var(--fg);font-weight:600}.curator-action-time{color:var(--fg-subtle);font-size:var(--text-xs)}.curator-action-detail{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.curator-action-reason{color:var(--fg-subtle);font-size:var(--text-xs);margin:var(--sp-1) 0 0}.cfg-page{max-width:70rem;margin:0 auto}.cfg-section{margin-bottom:var(--sp-4)}.cfg-subhead{font-size:var(--text-sm);color:var(--fg-muted);margin:var(--sp-5) 0 var(--sp-2);font-weight:600}.cfg-subhead:first-child{margin-top:0}.kv-list{column-gap:var(--sp-4);grid-template-columns:max-content minmax(0,1fr) auto;row-gap:0;display:grid}.kv{grid-template-columns:subgrid;align-items:center;row-gap:var(--sp-1);padding:var(--sp-2) 0;border-radius:var(--radius-sm);grid-column:1/-1;display:grid}@supports not (grid-template-columns:subgrid){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(8rem,16rem) minmax(0,1fr) auto}}.kv+.kv{border-top:1px solid var(--border)}.kv:hover{background:var(--surface-hover)}.kv-label{font-size:var(--text-sm);color:var(--fg-muted)}.kv-value{min-width:0;font-size:var(--text-sm);color:var(--fg);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-value.is-empty{color:var(--fg-subtle)}.kv-actions{align-items:center;gap:var(--sp-2);justify-self:end;display:flex}.kv-note{font-size:var(--text-xs);color:var(--fg-subtle);grid-column:2/-1}.kv-note.is-error{color:var(--danger)}.kv.is-locked .kv-value{color:var(--fg-muted)}.kv-btn{font:inherit;font-size:var(--text-xs);color:var(--fg-subtle);border:1px solid var(--border);border-radius:var(--radius-sm);padding:2px var(--sp-2);cursor:pointer;background:0 0;flex:none;transition:color .12s,border-color .12s,background .12s}.kv:hover .kv-btn,.kv:focus-within .kv-btn{color:var(--fg-muted);border-color:var(--border-strong)}.kv-btn:hover{color:var(--fg);border-color:var(--accent);background:var(--accent-soft)}.kv-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.kv-flag{font-size:var(--text-xs);color:var(--warn);background:var(--warn-soft);border-radius:var(--radius-pill);padding:1px var(--sp-2);flex:none}.kv-input{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--bg,var(--surface));border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);width:100%;min-width:0}.kv-input:focus{outline:2px solid var(--accent);outline-offset:-1px}.kv-save,.kv-cancel{font:inherit;font-size:var(--text-xs);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);cursor:pointer;flex:none}.kv-save{background:var(--accent);border:1px solid var(--accent);color:var(--accent-fg);font-weight:500}.kv-save:disabled{opacity:.6;cursor:default}.kv-cancel{border:1px solid var(--border-strong);color:var(--fg-muted);background:0 0}.kv-cancel:hover{color:var(--fg)}.cfg-notice{border-left:3px solid var(--warn)}.cfg-notice p{font-size:var(--text-sm);color:var(--warn);margin:0}@media (width<=700px){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(0,1fr) auto}.kv-label{grid-column:1}.kv-actions{grid-area:1/2}.kv-value,.kv-note{white-space:normal;overflow-wrap:anywhere;grid-column:1/-1}}.cfg-note{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.cfg-actions{gap:var(--sp-2);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.cfg-request-row{align-items:center;gap:var(--sp-2);margin-bottom:var(--sp-3);flex-wrap:wrap;display:flex}.cfg-request-row select,.cfg-request-row input{min-width:0;padding:var(--sp-2) var(--sp-3);background:var(--surface-hover);color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);font:inherit;font-size:var(--text-sm);flex:0 22rem}.cfg-pending{justify-content:space-between;align-items:center;gap:var(--sp-3);padding:var(--sp-3) 0;border-top:1px solid var(--hairline);flex-wrap:wrap;display:flex}.cfg-pending .cfg-actions{margin-top:0}.log-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.log-status{gap:var(--sp-3);align-items:center;display:flex}.log-meta{font-size:var(--text-xs);color:var(--fg-subtle);font-family:var(--font-mono)}.log-select,.log-search{background:var(--bg-raised);border:1px solid var(--border-strong);color:var(--fg);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);font:inherit;font-size:var(--text-sm)}.log-search{min-width:220px}.log-select:focus,.log-search:focus{outline:2px solid var(--accent);outline-offset:-1px}.log-list{max-height:62vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);overflow-y:auto}.log-loading{padding:var(--sp-5);color:var(--fg-muted);text-align:center}.log-row{gap:var(--sp-3);padding:var(--sp-2) var(--sp-1);border-bottom:1px solid var(--border);grid-template-columns:62px 52px 1fr;align-items:baseline;display:grid}.log-row:hover{background:var(--surface-hover)}.log-time{color:var(--fg-subtle)}.log-level{letter-spacing:.04em;font-size:10px;font-weight:600}.log-danger .log-level{color:var(--danger)}.log-warn .log-level{color:var(--warn)}.log-info .log-level{color:var(--info)}.log-idle .log-level{color:var(--idle)}.log-danger .log-msg{color:var(--fg)}.log-body{gap:var(--sp-2);flex-wrap:wrap;align-items:baseline;min-width:0;display:flex}.log-msg{color:var(--fg);word-break:break-word}.log-field{color:var(--fg-muted);background:var(--bg-raised);border-radius:var(--radius-sm);padding:0 var(--sp-2);white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden}.log-field-key{color:var(--fg-subtle)}.log-field-key:after{content:"=";opacity:.6}@media (width<=860px){.log-row{grid-template-columns:56px 1fr}.log-level{display:none}.log-search{flex:1;min-width:0}}.capture-row{cursor:pointer}.capture-row:hover{background:var(--bg-raised)}.capture-row:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.capture-detail-row td{padding:var(--sp-3) var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border)}.capture-detail{gap:var(--sp-4);grid-template-columns:1fr 1fr;display:grid}.capture-detail-section{min-width:0}.capture-detail-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.capture-payload{background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-3);font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;word-break:break-word;max-height:24rem;overflow:auto}.capture-empty{color:var(--fg-muted);font-size:var(--text-sm)}@media (width<=640px){.capture-detail{grid-template-columns:1fr}}.mapping-form,.mapping-fields,.mapping-payload{margin-bottom:var(--sp-4);padding:var(--sp-4)}.mapping-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.mapping-input,.mapping-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.mapping-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.mapping-fields-table .mapping-input{width:100%}.mapping-empty-fields{color:var(--fg-muted);font-size:var(--text-sm);padding:var(--sp-3) 0}.mapping-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.mapping-tree-list{padding-left:var(--sp-4);font-family:var(--font-mono);font-size:var(--text-xs);margin:0;list-style:none}.mapping-tree-item{padding:2px 0}.mapping-tree-key,.mapping-tree-value{cursor:pointer;border-radius:var(--radius-sm);padding:0 4px}.mapping-tree-key:hover,.mapping-tree-value:hover{background:var(--bg-raised);outline:1px solid var(--accent)}.mapping-tree-value{color:var(--fg-subtle);margin-left:var(--sp-1)}.binding-form{margin-bottom:var(--sp-4);padding:var(--sp-4)}.binding-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.binding-input,.binding-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.binding-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.chat-panel-content{flex:auto;grid-template-rows:auto auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.chat-bar{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);display:flex}.chat-session-switch{flex:auto;min-width:0}.chat-session-switch select{background:var(--surface-hover);width:100%;color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);padding:var(--sp-2);font:inherit;font-size:var(--text-sm)}.chat-new,.chat-settings>summary{flex:none}.chat-settings{flex:none;position:relative}.chat-settings>summary{border-radius:var(--radius-sm);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;place-items:center;list-style:none;display:grid}.chat-settings>summary::-webkit-details-marker{display:none}.chat-settings>summary:hover{background:var(--surface-hover);color:var(--fg)}.chat-settings-body{top:calc(100% + var(--sp-2));z-index:2;gap:var(--sp-3);width:15rem;padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);display:grid;position:absolute;right:0}.chat-settings-body label{gap:var(--sp-1);font-size:var(--text-xs);color:var(--fg-muted);display:grid}.chat-settings-body .chat-select{width:100%}.chat-layout{min-height:0;display:grid;overflow:hidden}.chat-workspace{grid-template-rows:auto minmax(0,1fr) auto;min-width:0;display:grid;overflow:hidden}.chat-workspace-head{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);font-size:var(--text-xs);display:flex}.chat-update-panel{border:1px solid var(--border);color:var(--fg-muted);border-radius:.75rem;flex:none;justify-content:space-between;align-items:center;gap:1rem;margin:0 0 .75rem;padding:.7rem .9rem;font-size:.8rem;display:flex}.chat-update-panel>div:first-child{gap:.2rem;display:grid}.chat-update-panel strong{color:var(--fg)}.chat-update-actions{flex-shrink:0;gap:.45rem;display:flex}.chat-dangerous-panel{border:1px solid color-mix(in srgb, var(--danger) 45%, var(--border));border-radius:.75rem;flex:none;margin:0 0 .75rem;padding:.8rem .9rem}.chat-dangerous-head,.chat-dangerous-controls,.chat-dangerous-pending{justify-content:space-between;align-items:center;gap:.6rem;display:flex}.chat-dangerous-head{margin-bottom:.7rem}.chat-dangerous-controls{flex-wrap:wrap;align-items:stretch}.chat-dangerous-controls>div{flex:18rem;gap:.45rem;display:flex}.chat-dangerous-input{background:var(--surface-hover);min-width:0;color:var(--fg);border:1px solid var(--border-strong);font:inherit;border-radius:.5rem;flex:1;padding:.5rem .65rem}.chat-dangerous-pending-list{gap:.45rem;margin-top:.75rem;display:grid}.chat-dangerous-pending{border-top:1px solid var(--border);color:var(--fg-muted);padding-top:.55rem;font-size:.8rem}.chat-session-list{gap:.35rem;margin-top:1rem;display:grid}.chat-session{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.65rem;gap:.25rem;padding:.7rem;display:grid}.chat-session:hover,.chat-session.active{background:var(--surface-hover);color:var(--fg);border-color:var(--border-strong)}.chat-session span{font-size:.72rem}.chat-session-tools{color:var(--fg-muted);margin-left:.6rem;font-size:.78rem;position:relative}.chat-session-tools summary{cursor:pointer}.chat-session-tool-list{z-index:2;background:var(--surface);border:1px solid var(--border-strong);border-radius:.65rem;flex-wrap:wrap;gap:.35rem;width:min(22rem,72vw);padding:.55rem;display:flex;position:absolute;top:calc(100% + .45rem);right:0;box-shadow:0 .7rem 2rem #0000004d}.chat-select{background:var(--surface-hover);color:var(--fg);border:1px solid var(--border-strong);border-radius:.5rem;padding:.5rem .65rem}.chat-transcript{padding:var(--sp-4);align-content:start;gap:var(--sp-4);display:grid;overflow:auto}.chat-empty-state{width:100%;padding:var(--sp-5) 0;text-align:center;place-self:center}.chat-empty-mark{width:2.2rem;height:2.2rem;margin:0 auto var(--sp-3);border:1px solid var(--border-strong);color:var(--accent);border-radius:.8rem;place-items:center;font-weight:700;display:grid}.chat-empty-state h2{font-size:var(--text-lg);letter-spacing:-.02em;margin:0}.chat-empty-state p{margin:var(--sp-2) 0 var(--sp-4);color:var(--fg-muted);font-size:var(--text-sm)}.chat-prompt-grid{gap:var(--sp-2);display:grid}.chat-prompt{padding:var(--sp-2) var(--sp-3);font-size:var(--text-sm);text-align:left;border:1px solid var(--border);background:var(--surface-hover);color:var(--fg-muted);cursor:pointer;border-radius:999px}.chat-prompt:hover{color:var(--fg);border-color:var(--border-strong)}.chat-bubble-row{display:flex}.chat-bubble-row.user{justify-content:flex-end}.chat-bubble{background:var(--surface-hover);border-radius:.85rem;max-width:min(78ch,86%);padding:.8rem 1rem;line-height:1.5}.chat-bubble-row.user .chat-bubble{background:color-mix(in srgb, var(--accent) 18%, var(--surface))}.chat-bubble-meta{color:var(--fg-muted);margin-bottom:.3rem;font-size:.7rem}.chat-bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}.chat-bubble-text p{margin:0 0 .7rem}.chat-bubble-text p:last-child{margin-bottom:0}.chat-bubble-text h1,.chat-bubble-text h2,.chat-bubble-text h3{letter-spacing:-.02em;margin:.2rem 0 .6rem;line-height:1.2}.chat-bubble-text h1{font-size:1.25rem}.chat-bubble-text h2{font-size:1.1rem}.chat-bubble-text h3{font-size:1rem}.chat-bubble-text ul,.chat-bubble-text ol{margin:.25rem 0 .75rem;padding-left:1.35rem}.chat-bubble-text blockquote{border-left:3px solid var(--accent);color:var(--fg-muted);margin:.5rem 0;padding:.35rem .75rem}.chat-bubble-text code{background:color-mix(in srgb, var(--fg) 10%, transparent);border-radius:.3rem;padding:.1rem .3rem;font-size:.9em}.chat-bubble-text pre{border:1px solid var(--border);background:color-mix(in srgb, var(--surface) 75%, #000);border-radius:.5rem;margin:.6rem 0;padding:.75rem;overflow:auto}.chat-bubble-text pre code{background:0 0;padding:0}.chat-bubble-text a{color:var(--accent)}.chat-media-img{border:1px solid var(--border);object-fit:contain;background:var(--surface);cursor:pointer;border-radius:.5rem;max-width:100%;max-height:24rem;margin:.4rem 0;display:block}.chat-bubble-text table{border-collapse:collapse;width:100%;margin:.7rem 0;font-size:.92em}.chat-bubble-text th,.chat-bubble-text td{text-align:left;border:1px solid var(--border);padding:.45rem .6rem}.chat-bubble-text th{color:var(--fg);background:color-mix(in srgb, var(--surface) 70%, transparent);font-weight:700}.chat-tools{gap:.2rem;margin-bottom:.5rem;font-size:.78rem;display:grid}.chat-tools:empty{display:none}.chat-tool{color:var(--fg-muted);overflow-wrap:anywhere;align-items:baseline;gap:.4rem;display:flex}.chat-tool-name{color:var(--fg);font-weight:600}.chat-tool.failed .chat-tool-summary{color:var(--danger)}.chat-nav-chip{border:1px solid color-mix(in srgb, var(--accent) 45%, var(--border));background:var(--accent-soft);color:var(--accent);cursor:pointer;transition:background var(--transition), border-color var(--transition), color var(--transition);border-radius:999px;align-items:center;gap:.4rem;padding:.4rem .7rem;font-size:.82rem;font-weight:600;display:inline-flex}.chat-nav-chip:hover{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.chat-nav-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.chat-nav-chip-icon{font-size:.8rem;line-height:1}.chat-compose{padding:var(--sp-3);border-top:1px solid var(--border)}.chat-composer-shell{align-items:flex-end;gap:var(--sp-2);background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem;display:flex;position:relative}.chat-composer{resize:none;box-sizing:border-box;min-width:0;min-height:2.6rem;color:var(--fg);font:inherit;background:0 0;border:0;flex:auto;padding:.25rem 0}.chat-composer:focus{outline:0}.chat-command-menu{z-index:3;background:var(--surface);border:1px solid var(--border-strong);border-radius:.7rem;gap:.15rem;max-height:18rem;padding:.35rem;display:grid;position:absolute;bottom:calc(100% - .25rem);left:.8rem;right:.8rem;overflow:auto;box-shadow:0 .7rem 2rem #0000004d}.chat-command-menu[hidden]{display:none}.chat-command-option{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.45rem;grid-template-columns:minmax(8rem,14rem) 1fr;align-items:center;gap:.65rem;padding:.5rem .6rem;display:grid}.chat-command-option:hover,.chat-command-option[aria-selected=true]{color:var(--fg);background:var(--surface-hover);border-color:var(--border)}.chat-command-option code{color:var(--fg)}.chat-compose-actions{align-items:center;gap:var(--sp-2);flex:none;display:flex}.chat-hint,.chat-empty{color:var(--fg-muted);font-size:.78rem}.chat-command-help{color:var(--fg-muted);margin-right:auto;font-size:.78rem}.chat-command-help summary{cursor:pointer}.chat-command-list{min-width:min(34rem,70vw);max-width:40rem;padding-top:.4rem;line-height:1.45}.chat-command-item{grid-template-columns:minmax(10rem,16rem) 1fr;gap:.7rem;padding:.3rem 0;display:grid}.chat-command-item code{color:var(--fg)}@media (width<=520px){.chat-update-panel{flex-direction:column;align-items:flex-start}} diff --git a/ui/dist/assets/index.js b/ui/dist/assets/index.js index 7927d61b2..2044ca1cc 100644 --- a/ui/dist/assets/index.js +++ b/ui/dist/assets/index.js @@ -1,10 +1,10 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;tt&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]0?e:_(e)?e.map(R):e.constructor===void 0?v({},e):null}function te(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d=n.__.length&&n.__.push({}),n.__[e]}function U(e){return se=1,ge(Te,e)}function ge(e,t,n){var r=he(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=V,!V.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},V.shouldComponentUpdate=i}return r.__N||r.__}function W(e,t){var n=he(B++,3);!H.__s&&we(n.__H,t)&&(n.__=e,n.u=t,V.__H.__h.push(n))}function G(e){return se=5,_e(function(){return{current:e}},[])}function _e(e,t){var n=he(B++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return se=8,_e(function(){return e},t)}function ye(){for(var e;e=ce.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],H.__e(n,e.__v)}}}H.__b=function(e){V=null,le&&le(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},H.__r=function(e){ue&&ue(e),B=0;var t=(V=e.__c).__H;t&&(ae===V?(t.__h=[],V.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],B=0)),ae=V},H.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ce.push(t)!==1&&oe===H.requestAnimationFrame||((oe=H.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ae=V=null},H.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],H.__e(n,e.__v)}}),fe&&fe(e,t)},H.unmount=function(e){pe&&pe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&H.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function Ce(e){var t=V;e.__c=e.__(),V=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}function Ee(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;ee.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}var De=15e3;function Oe(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function ke(e){try{let t=(await e.text()).trim();if(t)return t.split(` -`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Ae=class extends Error{constructor(e,t){super(e),this.status=t}};function je(e){let t=e instanceof Ae?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Me(e,t){let n=await fetch(e,t);if(!n.ok)throw new Ae(await ke(n),n.status);return n}async function K(e,{method:t=`GET`,body:n,timeoutMs:r=De,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Me(e,o);return i?s.json():void 0}var q={summary:()=>K(`/api/summary`),tasks:()=>K(`/api/tasks`),taskMeta:()=>K(`/api/task-meta`),task:e=>K(`/api/tasks/${e}`),taskAttempts:e=>K(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>K(`/api/tasks/${e}/changes`+Oe(t)),taskDebug:(e,t)=>K(`/api/tasks/${e}/debug`+Oe(t)),taskAction:(e,t)=>K(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>K(`/api/setup`),capabilities:()=>K(`/api/capabilities`),workflows:()=>K(`/api/workflows`),workRequest:e=>K(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>K(`/api/skills`),channels:()=>K(`/api/channels`),curators:()=>K(`/api/curators`),channelReload:e=>K(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>K(`/api/config`),version:()=>K(`/api/version`),configUpdate:e=>K(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>K(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>K(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>K(`/api/logs`+Oe(e)),taskLogs:(e,t)=>K(`/api/tasks/${e}/logs`+Oe(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>K(`/api/captures`+Oe({limit:e})),mappings:()=>K(`/api/mappings`),mappingCreate:e=>K(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>K(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>K(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>K(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>K(`/api/bindings`),bindingCreate:e=>K(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>K(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>K(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>K(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>K(`/api/chat/sessions`),chatMessages:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>K(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>K(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Ee(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>K(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>K(`/api/chat/update`),chatUpdateDefer:e=>K(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>K(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>K(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Me(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Ne(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Pe(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Fe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Ie=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Le=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],Re=[...Ie],ze=[...Le],Be=new Map(Re.map(e=>[e.id,e])),Ve=new Map(ze.map(e=>[e.id,e]));function He(){Be=new Map(Re.map(e=>[e.id,e])),Ve=new Map(ze.map(e=>[e.id,e]))}async function Ue(){try{let e=await q.taskMeta();Array.isArray(e?.statuses)&&(Re=e.statuses),Array.isArray(e?.actions)&&(ze=e.actions),He()}catch{}}function We(e){return Be.get(e)?.label||e||`Unknown`}function Ge(e){return Be.get(e)?.kind||`idle`}function Ke(){return Re.map(e=>e.id)}function qe(){return new Set(Re.filter(e=>e.needs_you).map(e=>e.id))}function Je(e){return Ve.get(e)||null}var Ye=0;Array.isArray;function J(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ye,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var Xe={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,"message-circle-plus":``,help:``};function Y({name:e,size:t=18,className:n=``}){return J(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,className:`ico ${n}`.trim(),dangerouslySetInnerHTML:{__html:Xe[e]||Xe.dashboard}})}function X(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function Ze(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function Z({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return J(`div`,{className:`card stat`,children:[J(`div`,{className:`stat-head`,children:[J(`span`,{className:`stat-label`,children:e}),s?J(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[J(Y,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),J(`div`,{className:`stat-value`,children:[t,n?J(`span`,{className:`stat-unit`,children:n}):null]}),i?J(`div`,{className:`stat-compare`,children:i}):null,a.length>1?J(Qe,{series:a,stroke:c===!1?`var(--danger)`:`var(--ok)`}):null]})}function Qe({series:e,stroke:t=`var(--ok)`,width:n=220,height:r=34}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `);return J(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:J(`polyline`,{points:c,fill:`none`,stroke:t,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`})})}function $e({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)};return J(`div`,{className:`gauge-wrap`,children:[J(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[J(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),J(`path`,{d:c(150,240),fill:`none`,stroke:i,"stroke-width":`12`,"stroke-linecap":`round`,"stroke-dasharray":s,"stroke-dashoffset":s*(1-r/100),className:`gauge-value`})]}),J(`div`,{className:`gauge-center`,children:[J(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),J(`div`,{className:`gauge-label`,children:t})]})]})}function et({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return J(`div`,{children:[J(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>J(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),J(`div`,{className:`segbar-legend`,children:e.map(e=>J(`span`,{className:`segbar-key`,children:[J(`span`,{className:`segbar-dot segbar-${e.kind||`idle`}`}),e.label]},e.label))})]})}var tt=160;function nt(e){let t=String(e?.detail||e?.message||``);if(!t)return{text:``,full:``,truncated:!1};let n=t.split(` -`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tt?`${n.slice(0,tt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Q({text:e,kind:t=`idle`}){return J(`span`,{className:`pill pill-${t}`,children:e})}var rt=`archie.setup-complete.dismissed.v1`;function it(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(rt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function at(e=globalThis.localStorage){e?.setItem?.(rt,`1`)}var ot=new Set([`waiting_human`,`parked`]);function st(e=[]){let t=e.filter(e=>ot.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ct({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=U([]),[n,r]=U(`connecting`),[i,a]=U(`idle`),[o,s]=U(new Map),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),[m,h]=U(null),[g,_]=U(null),[,v]=U(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([q.summary(),q.setup().catch(()=>null),q.workflows().catch(()=>null),q.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};W(()=>(y(),Ne(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{at(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=J(S,{children:[t>0&&J(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[J(Y,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&J(`a`,{className:`btn`,href:e.running.href,children:[J(Y,{name:`workflows`,size:15}),` `,n,` running`]}),J(`a`,{className:`btn`,href:`#/logs`,children:[J(Y,{name:`logs`,size:15}),` Logs`]}),J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=J(`div`,{className:`card`,children:J(ct,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=J(S,{children:[J(Z,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),J(Z,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),J(Z,{label:`Tokens used`,value:Ze(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=it(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=J(`div`,{className:`card setup`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Finish setting up`}),J(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),J(`span`,{className:`setup-pct`,children:[t,`%`]})]}),J(`div`,{className:`setup-bar`,children:J(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),J(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>J(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[J(`span`,{className:`setup-check`,children:e.done?J(Y,{name:`check`,size:12}):``}),J(`div`,{children:[J(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&J(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=J(`div`,{className:`card setup setup-done`,children:J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Setup complete`}),J(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),J(`div`,{className:`setup-complete-actions`,children:[J(`span`,{className:`setup-pct`,children:J(Y,{name:`check`,size:16})}),J(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:b,children:`×`})]})]})})}let O=null;if(c){let e=f?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)O=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`h2`,{className:`card-title`,children:`Gate pulse`})}),J(ct,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;O=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Gate pulse`}),J(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),J($e,{value:i,label:`pass rate`}),J(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>J(`li`,{className:`pulse-item`,children:[J(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),J(Q,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&J(`li`,{className:`pulse-item`,children:[J(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),J(Q,{text:String(r),kind:`warn`})]})]})]})}}let k=null;if(c){let e=c?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)k=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`h2`,{className:`card-title`,children:`Token outlook`})}),J(ct,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);k=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Token outlook`}),J(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),J(`div`,{className:`forecast-value`,children:Ze(r)}),J(`div`,{className:`forecast-note`,children:[`Based on `,Ze(Math.round(n)),` per day over `,e.length,` days`]}),J(et,{segments:[{label:`Last 7 days (${Ze(i)})`,value:i,kind:`info`},{label:`Earlier (${Ze(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return J(S,{children:[J(`div`,{className:`hero`,children:[J(`div`,{children:[J(`h1`,{className:`hero-title`,children:x}),J(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),J(`div`,{className:`hero-actions`,children:J(`div`,{className:`hero-actions-inner`,children:C})})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:J(`h2`,{className:`dash-section-title`,children:`Health`})}),J(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[J(`div`,{children:T}),J(`div`,{children:O})]})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:[J(`h2`,{className:`dash-section-title`,children:`Throughput`}),J(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),J(`div`,{className:`grid grid-4`,children:w})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:J(`h2`,{className:`dash-section-title`,children:`Right now`})}),J(`div`,{className:`dash-split`,children:[J(`div`,{children:k}),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Live activity`}),J(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),J(Q,{text:n,kind:i})]}),J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Event`}),J(`th`,{children:`Task`}),J(`th`,{children:`Detail`}),J(`th`,{children:`When`})]})}),J(`tbody`,{children:e.length?e.map((e,t)=>{let n=lt(e,o),r=n>0,i=nt(e),a=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return J(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?a:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}:void 0,children:[J(`td`,{className:`strong`,children:J(`span`,{children:e.kind||e.type||`event`})}),J(`td`,{className:`mono`,children:r?`#${n}`:`—`}),J(`td`,{className:`activity-detail`,children:J(`span`,{title:i.truncated?i.full:void 0,children:i.text})}),J(`td`,{children:X(e.at||Date.now())})]},t)}):J(`tr`,{children:J(`td`,{colSpan:`4`,children:J(ct,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function pt(){return J(ft,{})}function mt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}function ht(){return new Set([`needs_you`,...Ke()])}function gt(e){let t=e?.get?.(`status`)||``;return ht().has(t)?t:``}function _t(e,t){return t?t===`needs_you`?qe().has(e.status):e.status===t:!0}function vt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yt(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function bt(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function xt(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=yt(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=bt(t.iterations),i=bt(t.tokens),a=Number(t.cached_tokens)||0,o=bt((Number(t.prompt_tokens)||0)-a),s=bt(t.completion_tokens),c=bt(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`changes_captured`){let e=Number(t.totals?.files);return{title:`Change capture recorded`,detail:[Number.isFinite(e)&&e>0?`${e} file${e===1?``:`s`} changed`:``,t.captured_after?`captured after ${t.captured_after}`:``].filter(Boolean).join(` · `)}}return{title:vt(e.kind||e.type),detail:e.detail||``}}var St=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function Ct(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function wt({entry:e}){let t=e.fields||{};return J(`div`,{className:`log-row log-${Ct(e.level)}`,children:[J(`span`,{className:`log-time mono`,children:Et(e.time)}),J(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),J(`span`,{className:`log-body`,children:[J(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>J(`span`,{className:`log-field`,children:[J(`span`,{className:`log-field-key`,children:e}),String(Tt(t))]},e))]})]})}function Tt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Et(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Dt(e,t){return`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`)}var Ot={level:``,stage:``};function kt(e,t,n=Ot){let r=n||Ot;return[e,Number(t)||0,r.level||``,r.stage||``].join(`|`)}function At({filters:e,onFilterChange:t,stages:n,attempt:r}){let i=n=>t?.({...e,...n}),a=Number(r)||0;return J(`div`,{className:`log-filters task-log-filters`,children:[J(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?J(S,{children:[J(`label`,{className:`task-log-filter`,children:[J(`span`,{className:`task-log-filter-label`,children:`Level`}),J(`select`,{className:`task-filter`,value:e.level,"aria-label":`Filter log entries by level`,onChange:e=>i({level:e.target.value}),children:St.map(e=>J(`option`,{value:e.value,children:e.label},e.value))})]}),J(`label`,{className:`task-log-filter`,children:[J(`span`,{className:`task-log-filter-label`,children:`Stage`}),J(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[J(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),e.stage?J(`p`,{className:`task-log-filter-note`,children:`A stage filter matches only log lines that record a stage. Agent and tool output carries none, so it is not shown while this filter is set.`}):null,!e.stage&&!(n||[]).length?J(`p`,{className:`task-log-filter-note`,children:`This attempt recorded no stage names, so the stage filter has nothing to match.`}):null]}):null]})}function jt({text:e}){return J(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:e})}function Mt({state:e,onRetry:t,taskId:n,attempt:r,filters:i=Ot,onFilterChange:a,stages:o=[]}){let s=Number(r)||Number(e?.attempt)||0,c,l;if(e===void 0)c=`Loading this attempt's log`,l=J(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=J(`div`,{className:`task-log-error`,children:[J(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),J(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),J(`div`,{children:`This attempt produced no output, or it has not started writing yet.`})]});else if(e.disabled)c=`This dashboard cannot read task logs`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),J(`div`,{children:`This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.`})]});else{let t=e.entries||[],r=n==null?null:Dt(n,s||null),i=r?J(`a`,{className:`btn btn-small task-log-download`,href:r,download:!0,children:`Download log`}):null;t.length?(c=`${t.length} log entr${t.length===1?`y`:`ies`} shown`,l=J(S,{children:[J(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>J(wt,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`Nothing recorded`}),J(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return J(S,{children:[J(At,{filters:i,onFilterChange:a,stages:o,attempt:s}),J(jt,{text:c}),l]})}function Nt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function Pt(){return Nt()?`auto`:`smooth`}function Ft({kind:e,message:t}){return e===`session-expired`?J(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,J(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?J(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):J(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function It({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Lt({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=G(r);return a.current=r,W(()=>{n===void 0&&a.current()},[n]),J(Mt,{state:n,taskId:e,attempt:t,onRetry:i})}function Rt({query:e}){let[t,n]=U(null),[r,i]=U(null),[a,o]=U(()=>gt(e)),[s,c]=U(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=U(u),[p,m]=U(u!==null),[h,g]=U(new Map),[_,v]=U(new Map),y=G(new Set),[b,x]=U(new Set),[C,w]=U(new Map),[T,E]=U(new Set),D=async()=>{try{i(null);let e=await q.tasks();return n(e),d&&e.some(e=>String(e.id)===String(d))&&(h.has(d)||O(d)),e}catch(e){return i(String(e.message||e)),n(null),null}};W(()=>{D()},[]);let O=async e=>{try{let t=await q.task(e);g(n=>new Map(n).set(e,t||[]))}catch{g(t=>new Map(t).set(e,null))}},k=async(e,t,{force:n=!1}={})=>{let r=kt(e,t);if(!(y.current.has(r)&&!n)){y.current.add(r),n&&v(e=>{let t=new Map(e);return t.delete(r),t});try{let n=await q.taskLogs(e,{attempt:t||void 0,limit:500});v(e=>new Map(e).set(r,n))}catch{v(e=>new Map(e).set(r,null))}}},A=e=>{g(t=>{let n=new Map(t);return n.delete(e),n})},j=async(e,t)=>{w(t=>{let n=new Map(t);return n.delete(e),n}),E(t=>new Set(t).add(e));try{await q.taskAction(e,t),E(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&f(null),A(e);let n=await D();Array.isArray(n)&&n.find(t=>String(t.id)===String(e))&&d===e&&O(e)}catch(t){E(t=>{let n=new Set(t);return n.delete(e),n}),w(n=>new Map(n).set(e,je(t)))}};W(()=>{p&&d&&t&&(m(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${d}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`center`,behavior:Pt()}))}))},[p,d,t]);let M=(e,t)=>{t&&t.stopPropagation();let n=d!==e;f(n?e:null),n&&O(e)},N=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return J(`div`,{className:`grid grid-4 task-summary`,children:[J(Z,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),J(Z,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),J(Z,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},F=e=>{let t=C.get(e.id),n=t?Ft(t):null,r=T.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=Je(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return I(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return I(e,`issue`,e.issue_number,n.label)}return J(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&j(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:J(`div`,{className:`task-actions`,children:[n,a]})},I=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?J(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):J(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},L=e=>{let t=e.repo_url;return t?J(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},ee=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:J(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},R=e=>{let t=kt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return J(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:J(`td`,{colSpan:8,children:[J(`div`,{className:`task-detail-actions`,children:[J(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&J(`div`,{className:`task-decision`,children:[J(`div`,{className:`task-decision-title`,children:`Decision required`}),J(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&J(`div`,{className:`task-decision`,children:[J(`div`,{className:`task-decision-title`,children:`Park reason`}),J(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?J(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?J(`div`,{className:`task-timeline-error`,children:[J(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),J(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),J(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?J(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=xt(e);return J(`li`,{className:`task-timeline-entry`,children:[J(`span`,{className:`task-timeline-dot`}),J(`div`,{children:[J(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&J(`div`,{className:`task-timeline-detail`,children:n.detail}),J(`div`,{className:`task-timeline-when`,children:X(e.at)})]})]},t)})}):J(It,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),J(`div`,{className:`task-logs-section`,children:[J(`div`,{className:`task-decision-title`,children:[`Attempt log`,J(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&J(Lt,{taskId:e.id,attempt:e.attempt,state:_.has(t)?_.get(t):void 0,onLoad:()=>k(e.id,e.attempt),onRetry:()=>k(e.id,e.attempt,{force:!0})})]})]})})};return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Tasks`}),J(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?J(`div`,{className:`grid grid-4 task-summary`,children:J(`div`,{className:`card`,children:J(It,{title:`Cannot reach archied`,detail:r})})}):P(),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`All tasks`}),J(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),J(`div`,{className:`task-filters`,children:[J(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),J(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[J(`option`,{value:``,children:`All statuses`}),J(`option`,{value:`needs_you`,children:`Needs you`}),Ke().map(e=>J(`option`,{value:e,children:We(e)},e))]})]})]}),J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>J(`th`,{children:e},e))})}),J(`tbody`,{children:(()=>{if(r)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`Cannot reach archied`,detail:r})})});if(!t)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>_t(e,a)?!s||`${e.title} ${e.repo}`.toLowerCase().includes(s):!1);return e.length?e.map(e=>{let t=d===e.id,n=`task-timeline-${e.id}`;return J(S,{children:[J(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),M(e.id,t))},onClick:t=>M(e.id,t),...mt(e,t),children:[J(`td`,{className:`mono`,"data-label":`Repository`,children:[J(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>M(e.id,t),children:t?`−`:`+`}),L(e)??`${e.owner}/${e.repo}`]}),J(`td`,{className:`mono`,"data-label":`Issue`,children:ee(e)??`#${e.issue_number}`}),J(`td`,{className:`strong`,"data-label":`Title`,children:J(`a`,{className:`task-detail-link`,href:`#/tasks/${e.id}`,title:`Open the run detail for this task`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.title||`(untitled)`})}),J(`td`,{"data-label":`Status`,children:J(Q,{text:We(e.status),kind:Ge(e.status)})}),J(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),J(`td`,{"data-label":`Stage`,children:e.stage||`—`}),J(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${X(e.created_at)}`:``,children:X(e.updated_at)}),J(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&R(e)]},e.id)}):J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function zt(e){return J(Rt,{query:e})}function Bt(e,t){return`${e}-tab-${t}`}function Vt(e,t){return`${e}-panel-${t}`}function Ht({tabs:e,active:t,onSelect:n,prefix:r=`run`,label:i=`Run detail views`}){let a=G([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return J(`div`,{className:`tab-bar`,role:`tablist`,"aria-label":i,onKeyDown:n=>{let r=e.findIndex(e=>e.id===t);if(r<0)return;let i;if(n.key===`ArrowRight`)i=(r+1)%e.length;else if(n.key===`ArrowLeft`)i=(r-1+e.length)%e.length;else if(n.key===`Home`)i=0;else if(n.key===`End`)i=e.length-1;else return;n.preventDefault(),o(i)},children:e.map((e,i)=>{let o=e.id===t;return J(`button`,{ref:e=>{a.current[i]=e},id:Bt(r,e.id),className:`tab${o?` is-selected`:``}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":Vt(r,e.id),tabIndex:o?0:-1,onClick:()=>n?.(e.id),children:e.label},e.id)})})}var Ut={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},unknown:{label:`unknown`,kind:`idle`}};function Wt(e){return Ut[e]||{label:e||`unknown`,kind:`idle`}}function Gt(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>xt(e))}function Kt(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`start time not recorded`:`started ${t.toISOString().replace(`T`,` `).slice(0,16)} UTC`}function qt({stage:e,attemptNumber:t,events:n}){let r=Wt(e.status),i=yt(e.duration_ms),a=Gt(n,t,e.name);return J(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[J(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),J(`div`,{className:`run-stage-body`,children:[J(`div`,{className:`run-stage-head`,children:[J(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),J(Q,{text:r.label,kind:r.kind}),J(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?J(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>J(`div`,{className:`run-agent-report`,children:[J(`span`,{className:`run-agent-report-label`,children:`Agent's own report, not verified by archie: `}),[e.title,e.detail].filter(Boolean).join(` · `)]},t))]})]})}function Jt({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Yt({count:e}){let t=Number(e)||0;return t?J(`p`,{className:`run-rail-note`,children:[t,` event`,t===1?``:`s`,` on this task predate attempt attribution and cannot be assigned to a run.`]}):null}function Xt({state:e,attemptNumber:t,events:n,onRetry:r}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's run history. It may be restarting — retry, or check the daemon.`}),r?J(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return J(S,{children:[J(Jt,{title:`No attempts recorded`,detail:`This task has no recorded run. An attempt is written when a stage event is emitted, and none exist here.`}),J(Yt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return J(S,{children:[J(Jt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),J(Yt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Wt(a.status);return J(`div`,{className:`run-rail`,children:[J(`div`,{className:`run-rail-head`,children:[J(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),J(Q,{text:s.label,kind:s.kind}),J(`span`,{className:`run-rail-when`,children:Kt(a.started_at)})]}),o.length?J(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>J(qt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):J(Jt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),J(`p`,{className:`run-rail-legend`,children:[J(`strong`,{children:`ok`}),` means the stage returned without error. Archie records no exit code and does not verify that the work was correct, so this is a progress status, not a check result.`]}),J(Yt,{count:e?.unattributed_events})]})}var Zt={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,typechange:`Type changed`};function Qt(e){return Zt[e]||e||`unknown`}function $t(e,t){let n=e?.repo_url||t?.repo_url||``,r=t&&String(t.pr_number??``)!==``&&String(t.pr_number)===String(e?.pr_number??``);return{repo:n,pr:e?.pr_url||r&&t.pr_url||``}}function en(e={}){let t=Number(e.files)||0,n=[`${t} file${t===1?``:`s`}`];return e.additions&&n.push(`+${e.additions}`),e.deletions&&n.push(`−${e.deletions}`),n.join(` · `)}function tn({capture:e}){let t=e.files||[],n=Number(e.totals?.files)||t.length;return t.length?J(S,{children:[J(`table`,{className:`table run-changes-table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Path`}),J(`th`,{children:`Change`}),J(`th`,{className:`run-changes-count`,children:`Added`}),J(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:[J(`td`,{className:`mono run-changes-path`,children:[e.old_path?J(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),J(`td`,{children:[Qt(e.status),e.binary?J(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),J(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),J(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?J(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):J(`div`,{className:`run-changes-empty`,children:[`This capture recorded no file entries`,n?`, though its totals cover ${n} file${n===1?``:`s`}`:``,`.`]})}function nn({capture:e,task:t}){let n=$t(e,t),r=e.pr_number;return J(`section`,{className:`run-capture`,children:[J(`div`,{className:`run-capture-head`,children:[J(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),J(`span`,{className:`run-capture-at`,children:e.captured_at?X(e.captured_at):``})]}),J(`div`,{className:`run-capture-meta`,children:[J(`span`,{className:`mono`,children:n.repo?J(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?J(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?J(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?J(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):J(`span`,{className:`mono`,children:[`PR #`,r]}):null,J(`span`,{className:`run-capture-totals`,children:en(e.totals)})]}),J(tn,{capture:e})]})}function rn({state:e,task:t,onRetry:n}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),J(`div`,{children:`This attempt has a change capture event, but this dashboard could not decode its payload. That is a read failure, not a statement about what the attempt changed.`})]}):!e.found||!r.length?J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),J(`div`,{children:`Archie records what an attempt changed when it commits or pushes that work. Nothing was recorded here — the attempt may predate capture, or it produced no commit. This is not the same as "no files changed".`})]}):J(`div`,{className:`run-changes`,children:r.map((e,n)=>J(nn,{capture:e,task:t},`${e.captured_at||``}:${n}`))})}function an(e,t){return(e||[]).find(e=>e&&e.kind===`config_captured`&&Number(e.attempt)===Number(t))||null}function on({events:e,attempt:t,onRetry:n}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),J(`div`,{className:`run-error-detail`,children:`The configuration is recorded as an event on the task, so it cannot be shown while the event stream is unreadable. archied did not answer — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=an(e,t);if(!r)return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`Not captured for this run`}),J(`div`,{children:[`Archie records the effective configuration when it dispatches an attempt. Attempt `,t,` `,`has no such record — it predates the record, or the capture did not run. Nothing here says the run used the defaults.`]})]});let i=r.data||{},a=i.schema||``,o=i.document;return J(`div`,{className:`run-config`,children:[J(`p`,{className:`run-config-scope`,children:[`This is attempt `,r.attempt,`'s effective task-runtime configuration: a non-secret subset covering bot identity, models, limits, budgets, dispatch, diff cap, notifications, forge host and tool policy. It is not the dashboard configuration view — providers, repositories, identities, credentials and lock state are not part of it.`]}),J(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?J(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):J(S,{children:[J(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),J(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function sn({state:e,attempt:t,onRetry:n}){return e===void 0?J(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's debug view. It may be restarting — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):J(`div`,{className:`run-debug`,children:[J(`p`,{className:`run-debug-note`,children:[`The stored task record and its events, verbatim. Events are unfiltered on purpose: this is every event the task has, and each one carries the attempt it belongs to. Attempt `,t,` `,`is the one selected above.`]}),J(`pre`,{className:`run-json`,children:JSON.stringify(e,null,2)})]})}var cn=[{id:`stages`,label:`Stages`},{id:`log`,label:`Log`},{id:`changes`,label:`Changed files`},{id:`config`,label:`Configuration`},{id:`debug`,label:`Debug`}],ln=`run`,un=new Set(cn.map(e=>e.id));function dn(e){let t=String(e??``).trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:null}function fn(e){let t=e?.get?.(`tab`)||``;return un.has(t)?t:cn[0].id}function pn(e){let t=e?.get?.(`attempt`);if(t==null||t===``)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null}function mn(e,t,n){let r=new URLSearchParams;return r.set(`tab`,t||cn[0].id),n&&r.set(`attempt`,String(n)),`#/tasks/${e}?${r.toString()}`}function hn(e,t,n){try{window.history.replaceState(null,``,`${location.pathname}${location.search}${mn(e,t,n)}`)}catch{}}function gn(e,t){return`${e}|${Number(t)||0}`}function _n({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function vn({id:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Task not found`}),J(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),J(`div`,{className:`page-actions`,children:J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),J(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function yn({raw:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Not a task id`}),J(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),J(`div`,{className:`page-actions`,children:J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),J(`div`,{children:`A task id is a positive whole number. Nothing was requested.`})]})})]})}function bn({attempts:e,selected:t,onSelect:n}){let r=e?.attempts||[];return r.length?J(`div`,{className:`run-attempts`,role:`group`,"aria-label":`Attempts of this task`,children:r.map(e=>{let r=Wt(e.status),i=Number(e.attempt)===Number(t);return J(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[J(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),J(Q,{text:r.label,kind:r.kind}),J(`span`,{className:`run-attempt-meta`,children:[(e.stages||[]).length,` stage`,(e.stages||[]).length===1?``:`s`]})]},e.attempt)})}):null}function xn({id:e,query:t}){let[n,r]=U(()=>fn(t)),[i,a]=U(()=>pn(t)),[o,s]=U(void 0),[c,l]=U(void 0),[u,d]=U(!1),[f,p]=U(void 0),[m,h]=U(Ot),[g,_]=U(new Map),[v,y]=U(new Map),[b,x]=U(new Map),[S,C]=U(!1),[w,T]=U(null),[E,D]=U(0),O=G(new Set),k=Array.isArray(o)&&o.find(t=>String(t.id)===String(e))||null,A=Number(c?.current_attempt)>0?Number(c.current_attempt):null,j=i??A,M=(c?.attempts||[]).find(e=>Number(e.attempt)===Number(j)),N=[...new Set((M?.stages||[]).map(e=>e.name).filter(Boolean))],P=(e,t,n,{force:r=!1}={})=>{O.current.has(e)&&!r||(O.current.add(e),n(t=>new Map(t).set(e,void 0)),t().then(t=>n(n=>new Map(n).set(e,t))).catch(()=>n(t=>new Map(t).set(e,null))))},F=()=>{s(void 0),q.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),q.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),q.task(e).then(e=>p(e||[])).catch(()=>p(null))},ee=(t,n)=>P(kt(e,t,m),()=>q.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),R=(t,n)=>P(gn(e,t),()=>q.taskChanges(e,{attempt:t}),y,n),te=(t,n)=>P(gn(e,t),()=>q.taskDebug(e,{attempt:t}),x,n),z=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};W(()=>{F(),I(),L()},[]),W(()=>{j!=null&&(n===`log`?ee(j):n===`changes`?R(j):n===`debug`&&te(j))},[n,j,m,E]),W(()=>{hn(e,n,j)},[e,n,j]);let ne=async()=>{let t=k?.title||`task ${e}`;if(window.confirm(`Start a new run for "${t}"? This is a new attempt, and the previous attempt's commits are discarded.`)){T(null),C(!0);try{await q.taskAction(e,`retry`),O.current=new Set,_(new Map),y(new Map),x(new Map),a(null),F(),I(),L(),D(e=>e+1)}catch(e){T(je(e))}finally{C(!1)}}};if(u)return J(vn,{id:e});let re=j==null?null:kt(e,j,m),ie=gn(e,j),B=gn(e,j),V=()=>{if(n===`stages`)return J(Xt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),J(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),J(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return J(_n,{title:`No attempt recorded`,detail:`This task has no recorded run, so there is nothing to read for an attempt.`});switch(n){case`log`:return J(Mt,{state:re&&g.has(re)?g.get(re):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>ee(j,{force:!0})});case`changes`:return J(rn,{state:v.has(ie)?v.get(ie):void 0,task:k,onRetry:()=>R(j,{force:!0})});case`config`:return J(on,{events:f,attempt:j,onRetry:L});case`debug`:return J(sn,{state:b.has(B)?b.get(B):void 0,attempt:j,onRetry:()=>te(j,{force:!0})});default:return J(Xt,{state:c,attemptNumber:j,events:f,onRetry:I})}},ae=Je(`retry`),oe=!!(ae&&(k?.actions||[]).includes(`retry`));return J(`div`,{className:`run-page`,children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),J(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),J(`div`,{className:`page-actions`,children:[J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),J(`button`,{className:`btn`,type:`button`,onClick:z,children:`Refresh`})]})]}),J(`div`,{className:`run-meta`,children:[J(`span`,{className:`run-meta-item`,children:[J(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?J(`span`,{className:`run-meta-muted`,children:`loading…`}):k?J(Q,{text:We(k.status),kind:Ge(k.status)}):J(`span`,{className:`run-meta-muted`,children:`not read`})]}),J(`span`,{className:`run-meta-item`,children:[J(`span`,{className:`run-meta-label`,children:`Attempt`}),J(`span`,{className:`run-meta-value`,children:c===null?`run history unreadable`:c===void 0?`loading…`:j==null?`none recorded`:`attempt ${j} of ${A??j}`})]}),k?.repo_url?J(`a`,{className:`run-meta-link`,href:k.repo_url,target:`_blank`,rel:`noreferrer`,children:[k.owner,`/`,k.repo]}):null,k?.issue_url&&k.issue_number?J(`a`,{className:`run-meta-link`,href:k.issue_url,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,k.issue_number]}):null,k?.pr_url&&k.pr_number?J(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?J(`p`,{className:`run-note`,children:`The task list could not be read, so this page cannot show the task's current status or its operator controls. The run history below comes from the task's own endpoints.`}):null,Array.isArray(o)&&!k?J(`p`,{className:`run-note`,children:[`Task `,e,` is not among the tasks this dashboard lists (the list covers the 100 most recently updated). Its recorded attempts are shown below; the Debug tab holds the stored record verbatim.`]}):null,J(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[J(`button`,{className:`btn ${ae?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!oe||S,title:`Retry this task as a new run`,onClick:ne,children:S?`Starting…`:`Start a new run`}),J(`p`,{className:`run-restart-copy`,children:`Starts a new attempt for this task: a fresh worktree reset onto the base branch. The previous attempt's commits are discarded — they are not carried into the new run.`}),!oe&&o!==void 0?J(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${We(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?J(`p`,{className:`run-restart-error run-restart-error-${w.kind}`,children:w.kind===`session-expired`?`Your session has expired. Reload to sign in.`:w.kind===`refused`?`${w.message} — this run cannot be restarted from here.`:`${w.message} — try again, or check the daemon.`}):null]}),J(bn,{attempts:c,selected:j,onSelect:e=>a(e)}),J(`div`,{className:`card run-card`,children:[J(Ht,{tabs:cn,active:n,onSelect:r,prefix:ln}),J(`div`,{className:`run-panel`,role:`tabpanel`,id:Vt(ln,n),"aria-labelledby":Bt(ln,n),tabIndex:0,children:V()})]})]})}function Sn(e,t){let n=t?.id,r=dn(n);return r===null?J(yn,{raw:n??``}):J(xn,{id:r,query:e},r)}function Cn({title:e,detail:t}){return J(`div`,{class:`empty`,children:[J(`div`,{class:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function wn(e){return J(Tn,{query:e})}function Tn(){let[e,t]=U([]),[n,r]=U(``),[i,a]=U(null),o=async()=>{try{let e=await q.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};W(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=_e(()=>e.filter(e=>s(e,n)),[e,n]);return J(`div`,{children:[J(`div`,{class:`page-head`,children:[J(`div`,{children:[J(`h1`,{class:`page-title`,children:`Skills`}),J(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),J(`div`,{class:`page-actions`,children:J(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:[J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Catalogue`}),J(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),J(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),J(`div`,{class:`grid grid-2`,children:i?J(Cn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>J(`div`,{class:`card skill-card`,children:[J(`div`,{class:`card-head`,children:[J(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&J(Q,{text:e.workflow,kind:`info`})]}),J(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),J(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):J(Cn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):J(Cn,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}var En={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function Dn(e){return En[e]?En[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function On(e,t){return t?Math.round(e/t*100):0}function kn(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function An({title:e,detail:t}){return J(`div`,{class:`empty`,children:[J(`div`,{class:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function jn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return J(`div`,{class:`wf-bar`,children:J(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Mn(e){return J(Nn,{query:e})}function Nn(){let[e,t]=U([]),[n,r]=U([]),[i,a]=U([]),[o,s]=U(null),c=async()=>{try{let e=await q.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return W(()=>{c()},[]),J(`div`,{children:[J(`div`,{class:`page-head`,children:[J(`div`,{children:[J(`h1`,{class:`page-title`,children:`Workflows`}),J(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),J(`div`,{class:`page-actions`,children:J(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),J(Pn,{definitions:e}),o?J(`div`,{class:`card`,children:J(An,{title:`Cannot reach archied`,detail:o})}):J(S,{children:[J(Fn,{workflows:n,definitions:e}),J(In,{stages:i})]})]})}function Pn({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=U(``),[i,a]=U(``),[o,s]=U(t),[c,l]=U(``),[u,d]=U(``),[f,p]=U(!1),[m,h]=U(``);return W(()=>{!o&&t&&s(t)},[t,o]),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Start work`}),J(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),J(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await q.workRequest({identity:n,repository:i,workflow:o,title:c,instructions:u});h(`Queued task #${e.task_id}.`),r(``),a(``),s(t),l(``),d(``)}catch(e){h(String(e.message||e))}finally{p(!1)}},children:[J(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),J(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),J(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>J(`option`,{value:e.id,children:Dn(e.name||e.id)},e.id))}),J(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),J(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),J(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&J(`p`,{class:`card-sub`,children:m})]})]})}function Fn({workflows:e,definitions:t}){let n=new Map(e.map(e=>[e.workflow,e])),r=t.map(e=>({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}}));return r.length?J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Per workflow`}),J(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Origin`}),J(`th`,{children:`Runs`}),J(`th`,{children:`Success rate`}),J(`th`,{children:`Avg tokens`}),J(`th`,{children:`Avg steps`})]})}),J(`tbody`,{children:r.map(e=>{let t=On(e.merged,e.runs);return J(`tr`,{children:[J(`td`,{class:`strong`,children:Dn(e.workflow)}),J(`td`,{class:`mono`,children:e.origin||`registry`}),J(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:[t,`%`,J(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),J(jn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),J(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),J(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:J(`h2`,{class:`card-title`,children:`Per workflow`})})}),J(An,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function In({stages:e}){if(!e.length)return J(`div`,{class:`card wf-stage-card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:J(`h2`,{class:`card-title`,children:`Per stage`})})}),J(An,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return J(`div`,{class:`grid grid-2 wf-stage-card`,children:[J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Slowest stages`}),J(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Stage`}),J(`th`,{children:`Runs`}),J(`th`,{children:`Avg duration`})]})}),J(`tbody`,{children:n.map((e,n)=>J(`tr`,{children:[J(`td`,{children:Dn(e.workflow)}),J(`td`,{class:`strong`,children:e.stage}),J(`td`,{children:e.runs}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:kn(e.avg_ms)}),J(jn,{fraction:On(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Most failures`}),J(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Stage`}),J(`th`,{children:`Failures`})]})}),J(`tbody`,{children:r.map((e,t)=>J(`tr`,{children:[J(`td`,{children:Dn(e.workflow)}),J(`td`,{class:`strong`,children:e.stage}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),J(jn,{fraction:On(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):J(An,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Ln({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Rn(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function zn(){let[e,t]=U([]),[n,r]=U(null),i=async()=>{try{let e=await q.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return W(()=>{i()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Channels`}),J(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),J(`div`,{className:`grid grid-2`,children:n?J(Ln,{title:`Cannot reach archied`,detail:n}):e.length===0?J(Ln,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>J(`div`,{className:`card channel-card`,children:[J(`div`,{className:`card-head`,children:[J(`h3`,{className:`card-title`,children:e.name}),J(Q,{text:e.state||(e.configured?`configured`:`stopped`),kind:Rn(e.state,e.configured)})]}),J(`p`,{className:`channel-desc`,children:e.description}),J(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?J(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await q.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):J(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Bn(e){return J(zn,{query:e})}function Vn({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Hn(e){return J(Un,{query:e})}function Un({query:e}){let[t,n]=U([]),[r,i]=U(null),a=async()=>{try{let e=await q.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return W(()=>{a()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Curators`}),J(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),J(`div`,{className:`grid grid-2`,children:r?J(Vn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>J(Gn,{curator:e},e.name)):J(Vn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function Wn(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function Gn({curator:e}){let t=e.recent_actions||[];return J(`div`,{className:`card curator-card`,children:[J(`div`,{className:`card-head`,children:[J(`h3`,{className:`card-title`,children:e.name}),J(Q,{text:e.health?.status||`unknown`,kind:Wn(e.health?.status)})]}),e.health?.message&&J(`p`,{className:`curator-health-message`,children:e.health.message}),J(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${X(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?J(`ul`,{className:`curator-actions`,children:t.map((e,t)=>J(`li`,{className:`curator-action`,children:[J(`div`,{className:`curator-action-head`,children:[J(`span`,{className:`curator-action-type`,children:e.type||`action`}),J(`span`,{className:`curator-action-time`,children:X(e.at)})]}),e.detail&&J(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&J(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):J(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function Kn(e){return e==null||e===``?`—`:String(e)}function qn({label:e,value:t,opts:n}){let r=Kn(t),[i,a]=U(!1),[o,s]=U(``),[c,l]=U(null),[u,d]=U(!1),[f,p]=U(!1),m=n?.key;if(!m)return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n?.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return J(`div`,{className:`kv is-locked`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),J(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.overridden?.includes(m),_=()=>{s(String(n.raw??``)),l(null),a(!0)},v=async()=>{p(!0),l(null);try{await q.configReset(m),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{p(!1)}},y=async()=>{let e=Jn(n.type,o);if(e.error){l(e.error);return}d(!0),l(null);try{await(n.save||(e=>q.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=G(null);W(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),y()),e.key===`Escape`&&a(!1)},i;return i=n.type===`bool`?J(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[J(`option`,{value:`true`,children:`true`}),J(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?J(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>J(`option`,{value:e,children:e},e))}):J(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),i,J(`div`,{className:`kv-actions`,children:[J(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),J(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&J(`span`,{className:`kv-note is-error`,children:c})]})}return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),J(`div`,{className:`kv-actions`,children:[g&&J(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),J(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&J(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:v,disabled:f,children:`Reset`})]}),c&&J(`span`,{className:`kv-note is-error`,children:c})]})}function Jn(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function Yn({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Xn({sub:e,title:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:t||`Update status`}),J(`p`,{className:`card-sub`,children:e})]})}),n]})}var Zn={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},Qn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function $n({components:e}){return!e||!e.length?J(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:J(Yn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):J(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Component`}),J(`th`,{children:`Install type`}),J(`th`,{children:`Running`}),J(`th`,{children:`Latest available`}),J(`th`,{children:`Status`})]})}),J(`tbody`,{children:e.map(e=>J(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` -`),children:[J(`td`,{className:`strong`,children:e.label||e.id}),J(`td`,{className:`mono`,children:e.install_type||`—`}),J(`td`,{className:`mono`,children:e.running_version||`—`}),J(`td`,{className:`mono`,children:e.latest_available||`—`}),J(`td`,{children:J(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function er({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr(e){return e?.error?e.error:e?.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`}function nr({data:e,onDefer:t,onInstall:n}){let r=e?.available||[];return r.length?J(er,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:[J(`p`,{className:`cfg-note`,children:r.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)}),J(`div`,{className:`cfg-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>t?.(e.snapshot),children:`Defer`}),e.can_install&&J(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>n?.(e.snapshot),children:`Install update`})]})]}):J(er,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:J(`p`,{className:`cfg-note`,children:tr(e)})})}var rr=e=>e.Number??e.number,ir=e=>e.Label??e.label??`checkpoint`;function ar({data:e,onRequest:t,onDecide:n}){let[r,i]=U(``),[a,o]=U(``);if(e?.error)return J(er,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run.`,children:J(`p`,{className:`cfg-note`,children:e.error})});let s=e?.pending||[];return J(er,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run. Requesting one only queues it.`,children:[J(`div`,{className:`cfg-request-row`,children:[J(`select`,{"aria-label":`Checkpoint`,value:r,onChange:e=>i(e.target.value),children:[J(`option`,{value:``,children:`Select checkpoint`}),(e?.checkpoints||[]).map(e=>J(`option`,{value:String(rr(e)),children:[rr(e),` — `,ir(e)]},rr(e)))]}),J(`button`,{className:`btn`,type:`button`,disabled:!r,onClick:()=>t?.(`rollback`,r),children:`Request rollback`})]}),J(`div`,{className:`cfg-request-row`,children:[J(`input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`,value:a,onInput:e=>o(e.target.value)}),J(`button`,{className:`btn`,type:`button`,disabled:!a.trim(),onClick:()=>t?.(`stop`,a),children:`Request stop`})]}),s.length?J(S,{children:s.map(e=>J(`div`,{className:`cfg-pending`,children:[J(`span`,{children:e.description}),J(`div`,{className:`cfg-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`approve`),children:`Approve`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`permanent`),children:`Approve for 24h`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`deny`),children:`Deny`})]})]},e.id))}):J(`p`,{className:`cfg-note`,children:`No pending dangerous actions.`})]})}function $({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function or({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function sr({origins:e}){return e?.length?J(or,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:J(`div`,{className:`kv-list`,children:e.map((e,t)=>J(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):J(or,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:J($,{title:`Source provenance is unavailable.`})})}function cr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function lr({data:e,error:t}){if(t)return J(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:J($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return J(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[J(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?J(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??We(e.id),n=e.kind??Ge(e.id);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(Q,{text:t,kind:n})})]},e.id)})}):J($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),J(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?J(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=cr(e.kind);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):J($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ur({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=U(!1),[o,s]=U(null),[c,l]=U(!!e[t]);return r?J(`td`,{children:[J(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await q.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{children:c?`yes`:`no`})}function dr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=U(String(e[t]??0)),[o,s]=U(null),[c,l]=U(!1);return r?J(`td`,{children:[J(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await q.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{className:`mono`,children:i})}function fr({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return J(or,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:J($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return J(or,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Repository`}),J(`th`,{children:`Base branch`}),J(`th`,{children:`Ecosystem`}),J(`th`,{children:`Quality gate`}),J(`th`,{children:`Protected paths`}),J(`th`,{children:`Concurrent`}),J(`th`,{children:`Max retries`}),J(`th`,{children:`Self-review`})]})}),J(`tbody`,{children:e.map((e,i)=>J(`tr`,{children:[J(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),J(`td`,{className:`mono`,children:e.base}),J(`td`,{children:e.ecosystem||`go`}),J(`td`,{className:`mono`,children:r(e.gate)}),J(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),J(ur,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),J(dr,{r:e,field:`max_retries`,onSaved:t,editable:n}),J(ur,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function pr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function mr({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return J(or,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[J(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?J(`div`,{className:`kv-list`,children:n.map(([e,t])=>J(qn,{label:pr(e),value:t},e))}):J($,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),J(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Provider`}),J(`th`,{children:`Class`}),J(`th`,{children:`Base URL`}),J(`th`,{children:`API key env var`}),J(`th`,{children:`Status`})]})}),J(`tbody`,{children:r.map(([e,t])=>J(`tr`,{children:[J(`td`,{className:`strong`,children:e}),J(`td`,{children:t.class}),J(`td`,{className:`mono`,children:t.base_url||`default`}),J(`td`,{className:`mono`,children:t.api_key_env||`—`}),J(`td`,{children:t.configured?J(Q,{text:`configured`,kind:`ok`}):J(Q,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):J($,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function hr(){let[e,t]=U(null),[n,r]=U(null),[i,a]=U(null),[o,s]=U(null),[c,l]=U(!1),[u,d]=U(null),[f,p]=U(null),[m,h]=U(null),[g,_]=U(null),v=()=>{E(),D(),O(),y(),b()},y=async()=>{try{h(await q.chatUpdate())}catch(e){h(e?.status===501?null:{error:String(e.message||e)})}},b=async()=>{try{_(await q.chatDangerous())}catch(e){_(e?.status===501?null:{error:String(e.message||e)})}},x=async e=>{await q.chatUpdateDefer(e),await y()},C=async e=>{await q.chatUpdateInstall(e),await y()},w=async(e,t)=>{await q.chatDangerousRequest(e,t),await b()},T=async(e,t)=>{await q.chatDangerousDecision(e,t),await b()},E=async()=>{try{let e=await q.config();t(e),r(null)}catch(e){r(String(e.message||e))}},D=async()=>{try{let e=await q.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},O=async()=>{try{let e=await q.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return W(()=>{v()},[]),J(`div`,{className:`cfg-page`,children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Configuration`}),J(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:v,children:`Refresh`})})]}),J(`div`,{children:!c&&(o?J(`div`,{className:`card`,children:J($,{title:`Update status unavailable`,detail:o})}):i?J($n,{components:i}):null)}),m&&J(`div`,{children:J(nr,{data:m,onDefer:x,onInstall:C})}),g&&J(`div`,{children:J(ar,{data:g,onRequest:w,onDecide:T})}),J(`div`,{children:J(lr,{data:u,error:f})}),J(`div`,{children:n?J(`div`,{className:`card`,children:J($,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?J(`div`,{className:`card`,children:J($,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):J(S,{children:[e.reload?.overlay_unavailable&&J(`div`,{className:`card cfg-notice`,children:J(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&J(`div`,{className:`card cfg-notice`,children:J(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?J(or,{title:t.label,sub:t.description,children:J(`div`,{className:`kv-list`,children:r.map(t=>J(qn,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable&&e.editable!==!1,locked:e.locked||{},overridden:e.overridden||[],onSaved:E}},t.key))})},n):null}),J(fr,{repos:e.repositories,onSaved:E,editable:e.editable!==!1}),J(mr,{models:e.models,providers:e.providers}),J(sr,{origins:e.provenance})]})})]})}function gr(e){return J(hr,{query:e})}function _r({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function vr(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function yr(){let[e,t]=U({level:``,component:``,q:``}),[n,r]=U(!1),[i,a]=U([]),[o,s]=U([]),c=G(new Map),[l,u]=U(0),[d,f]=U(!1),[p,m]=U(`connecting`),[h,g]=U(`Refreshing…`),_=G(null),v=G(null),y=async()=>{g(`Refreshing…`);try{let t=await q.logs({level:e.level,component:e.component,q:e.q,limit:500});a(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),f(!!t.disabled);let n=t.disabled?`Durable history unavailable; live daemon logs continue.`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;g(n),s(t.entries||[])}catch{g(`Cannot read logs`)}};W(()=>{y()},[e]),W(()=>{let e=Pe(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(vr(t),t),t.fields?.component&&a(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),u(e=>e+1))},e=>{m(e)});return()=>e()},[]);let b=G(n);b.current=n;let x=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},S=G(x);S.current=x;let C=_e(()=>{let e=new Map;for(let t of o)e.set(vr(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return W(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Logs`}),J(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),J(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{className:`log-filters`,children:[J(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:St.map(e=>J(`option`,{value:e.value,children:e.label},e.value))}),J(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[J(`option`,{value:``,children:`All components`}),i.map(e=>J(`option`,{value:e,children:e},e))]}),J(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),J(`div`,{className:`log-status`,children:[J(`span`,{className:`log-meta`,children:h}),J(Q,{text:p,kind:p===`live`?`ok`:`warn`})]})]}),J(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?J(_r,{title:`Cannot read logs`}):C.length?C.map(e=>J(wt,{entry:e},vr(e))):J(_r,{title:d?`Durable history unavailable`:`Nothing matches`,detail:d?`Live daemon logs will appear here while this page is open.`:`Try a wider level or clear the search.`})})]})]})}function br(e){return J(yr,{query:e})}function xr({capture:e,expanded:t,onToggle:n}){return J(S,{children:[J(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[J(`td`,{className:`mono`,children:e.source||`(unknown)`}),J(`td`,{title:e.received_at||``,children:X(e.received_at)}),J(`td`,{children:J(Q,{text:`Unbound`,kind:`idle`})}),J(`td`,{className:`mono`,children:e.content_type||`—`}),J(`td`,{children:J(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&J(Sr,{capture:e})]})}function Sr({capture:e}){return J(`tr`,{className:`capture-detail-row`,children:J(`td`,{colSpan:`5`,children:J(`div`,{className:`capture-detail`,children:[J(`div`,{className:`capture-detail-section`,children:[J(`div`,{className:`capture-detail-title`,children:`Payload`}),J(Cr,{raw:e.body})]}),J(`div`,{className:`capture-detail-section`,children:[J(`div`,{className:`capture-detail-title`,children:`Headers`}),J(Cr,{raw:e.headers})]})]})})})}function Cr({raw:e}){return e?J(`pre`,{className:`capture-payload`,children:wr(e)}):J(`div`,{className:`capture-empty`,children:`(empty)`})}function wr(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Tr({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Er(e){return J(Dr,{query:e})}function Dr({query:e}){let[t,n]=U([]),[r,i]=U(null),[a,o]=U(null),[s,c]=U(!0),[l,u]=U({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await q.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return W(()=>{d();let e=Ne(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Event inspector`}),J(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),J(`div`,{className:`page-actions`,children:[J(Q,{text:l.text,kind:l.kind}),J(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),J(`div`,{className:`card`,children:a?J(Tr,{title:`Cannot reach archied`,detail:a}):s?t.length?J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(xr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):J(Tr,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):J(Tr,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var Or=[`string`,`number`,`bool`,`object`,`array`,`any`];function kr(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function Ar(e,t){return e?`${e}.${t}`:t}function jr(e,t){return`${e}[${t}]`}function Mr({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?J(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,jr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,Ar(t,e)])).map(([e,t,n])=>J(`li`,{className:`mapping-tree-item`,children:[J(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:kr(t),name:e})},children:e}),J(Mr,{value:t,path:n,name:e,onPick:r})]},n))}):J(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:kr(e),name:n})},children:JSON.stringify(e)})}function Nr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return J(`div`,{className:`mapping-empty-fields`,children:`Click a value in the payload to bind a field.`});let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return J(`table`,{className:`table mapping-fields-table`,children:[J(`thead`,{children:J(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:e.map((e,s)=>J(`tr`,{children:[J(`td`,{children:J(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),J(`td`,{className:`mono`,children:e.path}),J(`td`,{children:J(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Or.map(e=>J(`option`,{value:e,children:e},e))})}),J(`td`,{children:J(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),J(`td`,{children:J(Pr,{field:e,preview:t,failureByField:o})}),J(`td`,{children:J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Pr({field:e,preview:t,failureByField:n}){if(!t)return J(Q,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?J(Q,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?J(Q,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):J(Q,{text:`skipped (optional)`,kind:`idle`})}function Fr({mapping:e,onEdit:t,onDelete:n}){return J(`tr`,{children:[J(`td`,{children:e.name}),J(`td`,{className:`mono`,children:e.source_hint||`—`}),J(`td`,{children:String(e.fields?.length??0)}),J(`td`,{children:[J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Ir({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Lr(e){return J(Rr,{query:e})}function Rr({query:e}){let[t,n]=U([]),[r,i]=U([]),[a,o]=U(null),[s,c]=U(null),l=async()=>{try{let[e,t]=await Promise.all([q.mappings(),q.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};W(()=>{l()},[]);let u=()=>{c({id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},d=e=>{c({id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},f=async e=>{if(window.confirm(`Delete mapping "${e.name}"?`))try{await q.mappingDelete(e.id),await l()}catch(e){o(String(e.message||e))}},p=e=>{let t=r.find(t=>String(t.id)===String(e));c(e=>{let n={...e,captureId:t?t.id:null,preview:null};if(!t)n.payload=null,n.payloadError=null;else try{n.payload=JSON.parse(t.body),n.payloadError=null}catch{n.payload=null,n.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}return n})},m=({path:e,type:t,name:n})=>{c(r=>{let i=new Set(r.fields.map(e=>e.name)),a=n||`field`,o=1;for(;i.has(a);)a=`${n||`field`}_${++o}`;let s=[...r.fields,{name:a,path:e,type:t,required:!0}];return{...r,fields:s,preview:null}})},h=e=>{c(t=>{let n=t.fields.slice();return n.splice(e,1),{...t,fields:n,preview:null}})},g=(e,t)=>{c(n=>{let r=n.fields.slice();return r[e]={...r[e],...t},{...n,fields:r,preview:null}})};return s?J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:J(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),J(`button`,{className:`btn btn-primary`,type:`button`,onClick:async()=>{let e={name:s.name,source_hint:s.sourceHint,fields:s.fields};try{s.id?await q.mappingUpdate(s.id,e):await q.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&J(`div`,{className:`mapping-error`,children:s.actionError}),J(`div`,{className:`card mapping-form`,children:[J(`label`,{className:`mapping-form-row`,children:[`Name`,J(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),J(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,J(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),J(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,J(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[J(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>J(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),J(`div`,{className:`card mapping-fields`,children:[J(`div`,{className:`mapping-section-title`,children:`Bound fields`}),J(Nr,{fields:s.fields,preview:s.preview,onRemove:h,onNameChange:(e,t)=>g(e,{name:t}),onTypeChange:(e,t)=>g(e,{type:t}),onRequiredChange:(e,t)=>g(e,{required:t})}),J(`button`,{className:`btn`,type:`button`,onClick:async()=>{if(!s.captureId){c(e=>({...e,actionError:`Pick a captured event to preview against.`}));return}try{let e=await q.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),J(`div`,{className:`card mapping-payload`,children:[J(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?J(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?J(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):J(Mr,{value:s.payload,onPick:m})]})]}):J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Field mappings`}),J(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?J(Ir,{title:`Cannot reach archied`,detail:a}):t.length?J(`div`,{className:`card`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(Fr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):J(Ir,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var zr={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Br={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Vr({status:e}){return J(Q,{text:zr[e]||e,kind:Br[e]||`idle`})}function Hr({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return J(`tr`,{children:[J(`td`,{children:e.name}),J(`td`,{className:`mono`,children:e.matcher?.source||`—`}),J(`td`,{children:e.workflow}),J(`td`,{className:`mono`,children:i}),J(`td`,{children:J(Vr,{status:e.status})}),J(`td`,{children:[J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&J(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function Ur({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Wr(e){return J(Kr,{query:e})}function Gr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Kr({query:e}){let[t,n]=U([]),[r,i]=U([]),[a,o]=U([]),[s,c]=U(null),[l,u]=U(null),d=async()=>{try{let[e,t,r]=await Promise.all([q.bindings(),q.mappings(),q.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};W(()=>{d()},[]);let f=()=>{u(Gr())},p=e=>{u({id:e.id,name:e.name,source:e.matcher?.source||``,mappingId:e.mapping_id?String(e.mapping_id):``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,secret:``,actionError:null})},m=()=>u(null),h=async()=>{let e={name:l.name,matcher:{source:l.source},mapping_id:Number(l.mappingId)||0,workflow:l.workflow,owner:l.owner,repo:l.repo,secret:l.secret};try{l.id?await q.bindingUpdate(l.id,e):await q.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await q.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await q.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:J(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),J(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&J(`div`,{className:`binding-error`,children:l.actionError}),J(`div`,{className:`card binding-form`,children:[J(`label`,{className:`binding-form-row`,children:[`Name`,J(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,J(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Field mapping`,J(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[J(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>J(`option`,{value:e.id,children:e.name},e.id))]})]}),J(`label`,{className:`binding-form-row`,children:[`Workflow`,J(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[J(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>J(`option`,{value:e.id,children:e.name},e.id))]})]}),J(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,J(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,J(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,J(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Playbook bindings`}),J(`p`,{className:`page-sub`,children:`Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?J(Ur,{title:`Cannot reach archied`,detail:s}):t.length?J(`div`,{className:`card`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(Hr,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):J(Ur,{title:`No bindings yet`,detail:`Create one from a saved field mapping to turn a captured webhook into a workflow.`})]})}var qr=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;function Jr(e){let t=[],n=0,r=0;for(let i of String(e).matchAll(qr)){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith(`![`)){let e=a.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.push(J(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(J(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(J(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(J(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(J(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(J(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(J(`p`,{children:Jr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>J(`li`,{children:Jr(e)},t));n.push(a.tag===`ol`?J(`ol`,{children:e},s++):J(`ul`,{children:e},s++)),a=null};for(let e=0;eJ(`th`,{children:Jr(e)},t))})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:e.map((e,t)=>J(`td`,{children:Jr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(J(e,{children:Jr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(J(`blockquote`,{children:Jr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(J(`pre`,{children:J(`code`,{children:o.join(` -`)})},s++)),J(`div`,{className:t,children:n})}function Xr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Zr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Qr=`archie.web.chat.channel`;function $r(){let e=localStorage.getItem(Qr);return e||(e=Ee(),localStorage.setItem(Qr,e)),e}function ei(e){return{text:e,sourceID:Ee()}}function ti(e){return{...e}}function ni(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?ti(e.turn):ei(r),isRetry:n}}function ri({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||ne+t?i-t:e}function ii(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ai(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?ii(n):`Archie`}function oi(){return location.hash.slice(1)||`/`}function si({open:e=!0}){let[t,n]=U([]),[r,i]=U(``),[a,o]=U([]),[s,c]=U(``),[l,u]=U(`Ready`),[d,f]=U(!1),[p,m]=U({}),[h,g]=U(``),[_,v]=U(``),[y,b]=U(``),[x,C]=U([]),[w,T]=U([]),[E,D]=U(0),[O,k]=U(!1),[A,j]=U(null),M=G(null),N=G(null),P=G(null),F=G(null),I=G(null),L=G(null),ee=G(d);ee.current=d,W(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),W(()=>{e&&N.current?.focus()},[e]),W(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=ri({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),W(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),W(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await q.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await q.chatMessage($r(),`/resume ${e}`);let[t,n]=await Promise.all([q.chatMessages(e),q.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function z(e){if(r)try{u(`Working…`);let t=await q.chatMessage($r(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function ne(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function re(e){let t=e.target.value;g(t),!(!r||!t)&&q.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ie(e){let t=e.target.value;if(v(t),t)try{let e=await q.chatMessage($r(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function B(e){let t=e.target.value;if(b(t),t)try{let e=await q.chatMessage($r(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function V(){c(`/new`),ce({textOverride:`/new`})}function ae(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function oe(e){let t=w[e];if(!t||!N.current)return;let n=N.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function se(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),ce();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),oe(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ce())}async function ce(e=null){let t=e?.textOverride,{text:n,turn:r,isRetry:a}=ni(e,t===void 0?s:t);if(!n||ee.current)return;k(!1),f(!0),u(a?`Retrying…`:`Thinking…`),a||(o(e=>[...e,{from:`web`,text:n}]),c(``));let l=[];j({text:``,tools:[],isError:!1,turn:r,isRetry:a});let d=``,p=!1,m=!1,h=null;try{let e=new AbortController;P.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await q.chatStream({channel_id:$r(),source_id:r.sourceID,text:r.text,page:oi()},{signal:e.signal})).body.getReader(),n=new TextDecoder,a=``;for(;;){let{value:e,done:r}=await t.read();a+=n.decode(e||new Uint8Array,{stream:!r});let o=a.split(` +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;tt&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]0?e:_(e)?e.map(R):e.constructor===void 0?v({},e):null}function te(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d=n.__.length&&n.__.push({}),n.__[e]}function H(e){return ce=1,_e(Ee,e)}function _e(e,t,n){var r=ge(z++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ee(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=B,!B.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},B.shouldComponentUpdate=i}return r.__N||r.__}function U(e,t){var n=ge(z++,3);!V.__s&&Te(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function W(e){return ce=5,ve(function(){return{current:e}},[])}function ve(e,t){var n=ge(z++,7);return Te(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ye(e,t){return ce=8,ve(function(){return e},t)}function be(){for(var e;e=le.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ce),t.__h.some(we),t.__h=[]}catch(n){t.__h=[],V.__e(n,e.__v)}}}V.__b=function(e){B=null,ue&&ue(e)},V.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),he&&he(e,t)},V.__r=function(e){de&&de(e),z=0;var t=(B=e.__c).__H;t&&(oe===B?(t.__h=[],B.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ce),t.__h.some(we),t.__h=[],z=0)),oe=B},V.diffed=function(e){fe&&fe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(le.push(t)!==1&&se===V.requestAnimationFrame||((se=V.requestAnimationFrame)||Se)(be)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),oe=B=null},V.__c=function(e,t){t.some(function(e){try{e.__h.some(Ce),e.__h=e.__h.filter(function(e){return!e.__||we(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],V.__e(n,e.__v)}}),pe&&pe(e,t)},V.unmount=function(e){me&&me(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ce(e)}catch(e){t=e}}),n.__H=void 0,t&&V.__e(t,n.__v))};var xe=typeof requestAnimationFrame==`function`;function Se(e){var t,n=function(){clearTimeout(r),xe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);xe&&(t=requestAnimationFrame(n))}function Ce(e){var t=B,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),B=t}function we(e){var t=B;e.__c=e.__(),B=t}function Te(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ee(e,t){return typeof t==`function`?t(e):t}function De(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;ee.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}function Oe(e){return e===0?`reconnecting`:e===1?`live`:`unavailable`}var ke=15e3;function Ae(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function je(e){try{let t=(await e.text()).trim();if(t)return t.split(` +`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Me=class extends Error{constructor(e,t){super(e),this.status=t}};function Ne(e){let t=e instanceof Me?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Pe(e,t){let n=await fetch(e,t);if(!n.ok)throw new Me(await je(n),n.status);return n}async function G(e,{method:t=`GET`,body:n,timeoutMs:r=ke,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Pe(e,o);return i?s.json():void 0}var K={summary:()=>G(`/api/summary`),tasks:()=>G(`/api/tasks`),taskMeta:()=>G(`/api/task-meta`),task:e=>G(`/api/tasks/${e}`),taskAttempts:e=>G(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>G(`/api/tasks/${e}/changes`+Ae(t)),taskDebug:(e,t)=>G(`/api/tasks/${e}/debug`+Ae(t)),taskAction:(e,t)=>G(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>G(`/api/setup`),capabilities:()=>G(`/api/capabilities`),workflows:()=>G(`/api/workflows`),workRequest:e=>G(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>G(`/api/skills`),channels:()=>G(`/api/channels`),curators:()=>G(`/api/curators`),channelReload:e=>G(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>G(`/api/config`),version:()=>G(`/api/version`),configUpdate:e=>G(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>G(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>G(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>G(`/api/logs`+Ae(e)),taskLogs:(e,t)=>G(`/api/tasks/${e}/logs`+Ae(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>G(`/api/captures`+Ae({limit:e})),mappings:()=>G(`/api/mappings`),mappingCreate:e=>G(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>G(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>G(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>G(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>G(`/api/bindings`),bindingCreate:e=>G(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>G(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>G(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>G(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>G(`/api/chat/sessions`),chatMessages:e=>G(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>G(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>G(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>G(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:De(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>G(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>G(`/api/chat/update`),chatUpdateDefer:e=>G(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>G(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>G(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>G(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>G(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Pe(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Fe(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Ie(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Oe(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Le(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Re=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],ze=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],Be=[...Re],Ve=[...ze],He=new Map(Be.map(e=>[e.id,e])),Ue=new Map(Ve.map(e=>[e.id,e]));function We(){He=new Map(Be.map(e=>[e.id,e])),Ue=new Map(Ve.map(e=>[e.id,e]))}async function Ge(){try{let e=await K.taskMeta();Array.isArray(e?.statuses)&&(Be=e.statuses),Array.isArray(e?.actions)&&(Ve=e.actions),We()}catch{}}function Ke(e){return He.get(e)?.label||e||`Unknown`}function qe(e){return He.get(e)?.kind||`idle`}function Je(){return Be.map(e=>e.id)}function Ye(){return new Set(Be.filter(e=>e.needs_you).map(e=>e.id))}function Xe(e){return Ue.get(e)||null}var Ze=0;Array.isArray;function q(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var Qe={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,"message-circle-plus":``,help:``};function J({name:e,size:t=18,className:n=``}){return q(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,className:`ico ${n}`.trim(),dangerouslySetInnerHTML:{__html:Qe[e]||Qe.dashboard}})}function Y(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function $e(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function X({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return q(`div`,{className:`card stat`,children:[q(`div`,{className:`stat-head`,children:[q(`span`,{className:`stat-label`,children:e}),s?q(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[q(J,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),q(`div`,{className:`stat-value`,children:[t,n?q(`span`,{className:`stat-unit`,children:n}):null]}),i?q(`div`,{className:`stat-compare`,children:i}):null,a.length>1?q(et,{series:a,stroke:c===!1?`var(--danger)`:`var(--ok)`}):null]})}function et({series:e,stroke:t=`var(--ok)`,width:n=220,height:r=34}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `);return q(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:q(`polyline`,{points:c,fill:`none`,stroke:t,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`})})}function tt({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)};return q(`div`,{className:`gauge-wrap`,children:[q(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[q(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),q(`path`,{d:c(150,240),fill:`none`,stroke:i,"stroke-width":`12`,"stroke-linecap":`round`,"stroke-dasharray":s,"stroke-dashoffset":s*(1-r/100),className:`gauge-value`})]}),q(`div`,{className:`gauge-center`,children:[q(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),q(`div`,{className:`gauge-label`,children:t})]})]})}function nt({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return q(`div`,{children:[q(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>q(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),q(`div`,{className:`segbar-legend`,children:e.map(e=>q(`span`,{className:`segbar-key`,children:[q(`span`,{className:`segbar-dot segbar-${e.kind||`idle`}`}),e.label]},e.label))})]})}var rt=160;function it(e){let t=String(e?.detail||e?.message||``);if(!t)return{text:``,full:``,truncated:!1};let n=t.split(` +`).map(e=>e.trim()).find(Boolean)||``,r=n.length>rt?`${n.slice(0,rt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Z({text:e,kind:t=`idle`}){return q(`span`,{className:`pill pill-${t}`,children:e})}var at=`archie.setup-complete.dismissed.v1`;function ot(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(at),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function st(e=globalThis.localStorage){e?.setItem?.(at,`1`)}var ct=new Set([`waiting_human`,`parked`]);function lt(e=[]){let t=e.filter(e=>ct.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ut({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function dt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ft(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function pt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function mt(){let[e,t]=H([]),[n,r]=H(`connecting`),[i,a]=H(`idle`),[o,s]=H(new Map),[c,l]=H(null),[u,d]=H(null),[f,p]=H(null),[m,h]=H(null),[g,_]=H(null),[,v]=H(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([K.summary(),K.setup().catch(()=>null),K.workflows().catch(()=>null),K.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};U(()=>(y(),Fe(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{st(),v(e=>!e)},x=u?.operator?`${ft()}, ${u.operator}`:ft(),C=null;if(g)C=q(`button`,{className:`btn btn-primary`,onClick:y,children:[q(J,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=lt(m),t=e.attention.count,n=e.running.count;C=q(S,{children:[t>0&&q(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[q(J,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&q(`a`,{className:`btn`,href:e.running.href,children:[q(J,{name:`workflows`,size:15}),` `,n,` running`]}),q(`a`,{className:`btn`,href:`#/logs`,children:[q(J,{name:`logs`,size:15}),` Logs`]}),q(`button`,{className:`btn btn-primary`,onClick:y,children:[q(J,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=q(`div`,{className:`card`,children:q(ut,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=q(S,{children:[q(X,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),q(X,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),q(X,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),q(X,{label:`Tokens used`,value:$e(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:pt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=ot(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=q(`div`,{className:`card setup`,children:[q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Finish setting up`}),q(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),q(`span`,{className:`setup-pct`,children:[t,`%`]})]}),q(`div`,{className:`setup-bar`,children:q(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),q(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>q(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[q(`span`,{className:`setup-check`,children:e.done?q(J,{name:`check`,size:12}):``}),q(`div`,{children:[q(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&q(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=q(`div`,{className:`card setup setup-done`,children:q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Setup complete`}),q(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),q(`div`,{className:`setup-complete-actions`,children:[q(`span`,{className:`setup-pct`,children:q(J,{name:`check`,size:16})}),q(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:b,children:`×`})]})]})})}let O=null;if(c){let e=f?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)O=q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:q(`h2`,{className:`card-title`,children:`Gate pulse`})}),q(ut,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;O=q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Gate pulse`}),q(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),q(tt,{value:i,label:`pass rate`}),q(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>q(`li`,{className:`pulse-item`,children:[q(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),q(Z,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&q(`li`,{className:`pulse-item`,children:[q(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),q(Z,{text:String(r),kind:`warn`})]})]})]})}}let k=null;if(c){let e=c?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)k=q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:q(`h2`,{className:`card-title`,children:`Token outlook`})}),q(ut,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);k=q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Token outlook`}),q(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),q(`div`,{className:`forecast-value`,children:$e(r)}),q(`div`,{className:`forecast-note`,children:[`Based on `,$e(Math.round(n)),` per day over `,e.length,` days`]}),q(nt,{segments:[{label:`Last 7 days (${$e(i)})`,value:i,kind:`info`},{label:`Earlier (${$e(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return q(S,{children:[q(`div`,{className:`hero`,children:[q(`div`,{children:[q(`h1`,{className:`hero-title`,children:x}),q(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),q(`div`,{className:`hero-actions`,children:q(`div`,{className:`hero-actions-inner`,children:C})})]}),q(`div`,{className:`dash-section`,children:[q(`div`,{className:`dash-section-head`,children:q(`h2`,{className:`dash-section-title`,children:`Health`})}),q(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[q(`div`,{children:T}),q(`div`,{children:O})]})]}),q(`div`,{className:`dash-section`,children:[q(`div`,{className:`dash-section-head`,children:[q(`h2`,{className:`dash-section-title`,children:`Throughput`}),q(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),q(`div`,{className:`grid grid-4`,children:w})]}),q(`div`,{className:`dash-section`,children:[q(`div`,{className:`dash-section-head`,children:q(`h2`,{className:`dash-section-title`,children:`Right now`})}),q(`div`,{className:`dash-split`,children:[q(`div`,{children:k}),q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Live activity`}),q(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),q(Z,{text:n,kind:i})]}),q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Event`}),q(`th`,{children:`Task`}),q(`th`,{children:`Detail`}),q(`th`,{children:`When`})]})}),q(`tbody`,{children:e.length?e.map((e,t)=>{let n=dt(e,o),r=n>0,i=it(e),a=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return q(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?a:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}:void 0,children:[q(`td`,{className:`strong`,children:q(`span`,{children:e.kind||e.type||`event`})}),q(`td`,{className:`mono`,children:r?`#${n}`:`—`}),q(`td`,{className:`activity-detail`,children:q(`span`,{title:i.truncated?i.full:void 0,children:i.text})}),q(`td`,{children:Y(e.at||Date.now())})]},t)}):q(`tr`,{children:q(`td`,{colSpan:`4`,children:q(ut,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function ht(){return q(mt,{})}function gt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}function _t(){return new Set([`needs_you`,...Je()])}function vt(e){let t=e?.get?.(`status`)||``;return _t().has(t)?t:``}function yt(e,t){return t?t===`needs_you`?Ye().has(e.status):e.status===t:!0}function bt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function xt(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function St(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function Ct(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=xt(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=St(t.iterations),i=St(t.tokens),a=Number(t.cached_tokens)||0,o=St((Number(t.prompt_tokens)||0)-a),s=St(t.completion_tokens),c=St(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`changes_captured`){let e=Number(t.totals?.files);return{title:`Change capture recorded`,detail:[Number.isFinite(e)&&e>0?`${e} file${e===1?``:`s`} changed`:``,t.captured_after?`captured after ${t.captured_after}`:``].filter(Boolean).join(` · `)}}return{title:bt(e.kind||e.type),detail:e.detail||``}}var wt=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function Tt(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function Et({entry:e}){let t=e.fields||{};return q(`div`,{className:`log-row log-${Tt(e.level)}`,children:[q(`span`,{className:`log-time mono`,children:Ot(e.time)}),q(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),q(`span`,{className:`log-body`,children:[q(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>q(`span`,{className:`log-field`,children:[q(`span`,{className:`log-field-key`,children:e}),String(Dt(t))]},e))]})]})}function Dt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Ot(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function kt(e,t){return`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`)}var At={level:``,stage:``};function jt(e,t,n=At){let r=n||At;return[e,Number(t)||0,r.level||``,r.stage||``].join(`|`)}function Mt({filters:e,onFilterChange:t,stages:n,attempt:r}){let i=n=>t?.({...e,...n}),a=Number(r)||0;return q(`div`,{className:`log-filters task-log-filters`,children:[q(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?q(S,{children:[q(`label`,{className:`task-log-filter`,children:[q(`span`,{className:`task-log-filter-label`,children:`Level`}),q(`select`,{className:`task-filter`,value:e.level,"aria-label":`Filter log entries by level`,onChange:e=>i({level:e.target.value}),children:wt.map(e=>q(`option`,{value:e.value,children:e.label},e.value))})]}),q(`label`,{className:`task-log-filter`,children:[q(`span`,{className:`task-log-filter-label`,children:`Stage`}),q(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[q(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>q(`option`,{value:e,children:e},e))]})]}),e.stage?q(`p`,{className:`task-log-filter-note`,children:`A stage filter matches only log lines that record a stage. Agent and tool output carries none, so it is not shown while this filter is set.`}):null,!e.stage&&!(n||[]).length?q(`p`,{className:`task-log-filter-note`,children:`This attempt recorded no stage names, so the stage filter has nothing to match.`}):null]}):null]})}function Nt({text:e}){return q(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:e})}function Pt({state:e,onRetry:t,taskId:n,attempt:r,filters:i=At,onFilterChange:a,stages:o=[]}){let s=Number(r)||Number(e?.attempt)||0,c,l;if(e===void 0)c=`Loading this attempt's log`,l=q(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=q(`div`,{className:`task-log-error`,children:[q(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),q(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),q(`div`,{children:`This attempt produced no output, or it has not started writing yet.`})]});else if(e.disabled)c=`This dashboard cannot read task logs`,l=q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),q(`div`,{children:`This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.`})]});else{let t=e.entries||[],r=n==null?null:kt(n,s||null),i=r?q(`a`,{className:`btn btn-small task-log-download`,href:r,download:!0,children:`Download log`}):null;t.length?(c=`${t.length} log entr${t.length===1?`y`:`ies`} shown`,l=q(S,{children:[q(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>q(Et,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`Nothing recorded`}),q(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return q(S,{children:[q(Mt,{filters:i,onFilterChange:a,stages:o,attempt:s}),q(Nt,{text:c}),l]})}function Ft(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function It(){return Ft()?`auto`:`smooth`}function Lt({kind:e,message:t}){return e===`session-expired`?q(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,q(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?q(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):q(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function Rt({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function zt({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=W(r);return a.current=r,U(()=>{n===void 0&&a.current()},[n]),q(Pt,{state:n,taskId:e,attempt:t,onRetry:i})}function Bt({query:e}){let[t,n]=H(null),[r,i]=H(null),[a,o]=H(()=>vt(e)),[s,c]=H(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=H(u),[p,m]=H(u!==null),[h,g]=H(new Map),[_,v]=H(new Map),y=W(new Set),[b,x]=H(new Set),[C,w]=H(new Map),[T,E]=H(new Set),D=async()=>{try{i(null);let e=await K.tasks();return n(e),d&&e.some(e=>String(e.id)===String(d))&&(h.has(d)||O(d)),e}catch(e){return i(String(e.message||e)),n(null),null}};U(()=>{D()},[]);let O=async e=>{try{let t=await K.task(e);g(n=>new Map(n).set(e,t||[]))}catch{g(t=>new Map(t).set(e,null))}},k=async(e,t,{force:n=!1}={})=>{let r=jt(e,t);if(!(y.current.has(r)&&!n)){y.current.add(r),n&&v(e=>{let t=new Map(e);return t.delete(r),t});try{let n=await K.taskLogs(e,{attempt:t||void 0,limit:500});v(e=>new Map(e).set(r,n))}catch{v(e=>new Map(e).set(r,null))}}},A=e=>{g(t=>{let n=new Map(t);return n.delete(e),n})},j=async(e,t)=>{w(t=>{let n=new Map(t);return n.delete(e),n}),E(t=>new Set(t).add(e));try{await K.taskAction(e,t),E(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&f(null),A(e);let n=await D();Array.isArray(n)&&n.find(t=>String(t.id)===String(e))&&d===e&&O(e)}catch(t){E(t=>{let n=new Set(t);return n.delete(e),n}),w(n=>new Map(n).set(e,Ne(t)))}};U(()=>{p&&d&&t&&(m(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${d}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`center`,behavior:It()}))}))},[p,d,t]);let M=(e,t)=>{t&&t.stopPropagation();let n=d!==e;f(n?e:null),n&&O(e)},N=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return q(`div`,{className:`grid grid-4 task-summary`,children:[q(X,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),q(X,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),q(X,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),q(X,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},F=e=>{let t=C.get(e.id),n=t?Lt(t):null,r=T.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=Xe(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return I(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return I(e,`issue`,e.issue_number,n.label)}return q(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&j(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:q(`div`,{className:`task-actions`,children:[n,a]})},I=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?q(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):q(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},L=e=>{let t=e.repo_url;return t?q(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},ee=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:q(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},R=e=>{let t=jt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return q(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:q(`td`,{colSpan:8,children:[q(`div`,{className:`task-detail-actions`,children:[q(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&q(`div`,{className:`task-decision`,children:[q(`div`,{className:`task-decision-title`,children:`Decision required`}),q(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&q(`div`,{className:`task-decision`,children:[q(`div`,{className:`task-decision-title`,children:`Park reason`}),q(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?q(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?q(`div`,{className:`task-timeline-error`,children:[q(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),q(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),q(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?q(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=Ct(e);return q(`li`,{className:`task-timeline-entry`,children:[q(`span`,{className:`task-timeline-dot`}),q(`div`,{children:[q(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&q(`div`,{className:`task-timeline-detail`,children:n.detail}),q(`div`,{className:`task-timeline-when`,children:Y(e.at)})]})]},t)})}):q(Rt,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),q(`div`,{className:`task-logs-section`,children:[q(`div`,{className:`task-decision-title`,children:[`Attempt log`,q(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&q(zt,{taskId:e.id,attempt:e.attempt,state:_.has(t)?_.get(t):void 0,onLoad:()=>k(e.id,e.attempt),onRetry:()=>k(e.id,e.attempt,{force:!0})})]})]})})};return q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Tasks`}),q(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?q(`div`,{className:`grid grid-4 task-summary`,children:q(`div`,{className:`card`,children:q(Rt,{title:`Cannot reach archied`,detail:r})})}):P(),q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`All tasks`}),q(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),q(`div`,{className:`task-filters`,children:[q(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),q(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[q(`option`,{value:``,children:`All statuses`}),q(`option`,{value:`needs_you`,children:`Needs you`}),Je().map(e=>q(`option`,{value:e,children:Ke(e)},e))]})]})]}),q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>q(`th`,{children:e},e))})}),q(`tbody`,{children:(()=>{if(r)return q(`tr`,{children:q(`td`,{colSpan:8,children:q(Rt,{title:`Cannot reach archied`,detail:r})})});if(!t)return q(`tr`,{children:q(`td`,{colSpan:8,children:q(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return q(`tr`,{children:q(`td`,{colSpan:8,children:q(Rt,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>yt(e,a)?!s||`${e.title} ${e.repo}`.toLowerCase().includes(s):!1);return e.length?e.map(e=>{let t=d===e.id,n=`task-timeline-${e.id}`;return q(S,{children:[q(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),M(e.id,t))},onClick:t=>M(e.id,t),...gt(e,t),children:[q(`td`,{className:`mono`,"data-label":`Repository`,children:[q(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>M(e.id,t),children:t?`−`:`+`}),L(e)??`${e.owner}/${e.repo}`]}),q(`td`,{className:`mono`,"data-label":`Issue`,children:ee(e)??`#${e.issue_number}`}),q(`td`,{className:`strong`,"data-label":`Title`,children:q(`a`,{className:`task-detail-link`,href:`#/tasks/${e.id}`,title:`Open the run detail for this task`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.title||`(untitled)`})}),q(`td`,{"data-label":`Status`,children:q(Z,{text:Ke(e.status),kind:qe(e.status)})}),q(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),q(`td`,{"data-label":`Stage`,children:e.stage||`—`}),q(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${Y(e.created_at)}`:``,children:Y(e.updated_at)}),q(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&R(e)]},e.id)}):q(`tr`,{children:q(`td`,{colSpan:8,children:q(Rt,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function Vt(e){return q(Bt,{query:e})}function Ht(e,t){return`${e}-tab-${t}`}function Ut(e,t){return`${e}-panel-${t}`}function Wt({tabs:e,active:t,onSelect:n,prefix:r=`run`,label:i=`Run detail views`}){let a=W([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return q(`div`,{className:`tab-bar`,role:`tablist`,"aria-label":i,onKeyDown:n=>{let r=e.findIndex(e=>e.id===t);if(r<0)return;let i;if(n.key===`ArrowRight`)i=(r+1)%e.length;else if(n.key===`ArrowLeft`)i=(r-1+e.length)%e.length;else if(n.key===`Home`)i=0;else if(n.key===`End`)i=e.length-1;else return;n.preventDefault(),o(i)},children:e.map((e,i)=>{let o=e.id===t;return q(`button`,{ref:e=>{a.current[i]=e},id:Ht(r,e.id),className:`tab${o?` is-selected`:``}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":Ut(r,e.id),tabIndex:o?0:-1,onClick:()=>n?.(e.id),children:e.label},e.id)})})}var Gt={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},unknown:{label:`unknown`,kind:`idle`}};function Kt(e){return Gt[e]||{label:e||`unknown`,kind:`idle`}}function qt(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>Ct(e))}function Jt(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`start time not recorded`:`started ${t.toISOString().replace(`T`,` `).slice(0,16)} UTC`}function Yt({stage:e,attemptNumber:t,events:n}){let r=Kt(e.status),i=xt(e.duration_ms),a=qt(n,t,e.name);return q(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[q(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),q(`div`,{className:`run-stage-body`,children:[q(`div`,{className:`run-stage-head`,children:[q(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),q(Z,{text:r.label,kind:r.kind}),q(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?q(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>q(`div`,{className:`run-agent-report`,children:[q(`span`,{className:`run-agent-report-label`,children:`Agent's own report, not verified by archie: `}),[e.title,e.detail].filter(Boolean).join(` · `)]},t))]})]})}function Xt({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Zt({count:e}){let t=Number(e)||0;return t?q(`p`,{className:`run-rail-note`,children:[t,` event`,t===1?``:`s`,` on this task predate attempt attribution and cannot be assigned to a run.`]}):null}function Qt({state:e,attemptNumber:t,events:n,onRetry:r}){if(e===void 0)return q(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return q(`div`,{className:`run-error`,children:[q(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),q(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's run history. It may be restarting — retry, or check the daemon.`}),r?q(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return q(S,{children:[q(Xt,{title:`No attempts recorded`,detail:`This task has no recorded run. An attempt is written when a stage event is emitted, and none exist here.`}),q(Zt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return q(S,{children:[q(Xt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),q(Zt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Kt(a.status);return q(`div`,{className:`run-rail`,children:[q(`div`,{className:`run-rail-head`,children:[q(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),q(Z,{text:s.label,kind:s.kind}),q(`span`,{className:`run-rail-when`,children:Jt(a.started_at)})]}),o.length?q(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>q(Yt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):q(Xt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),q(`p`,{className:`run-rail-legend`,children:[q(`strong`,{children:`ok`}),` means the stage returned without error. Archie records no exit code and does not verify that the work was correct, so this is a progress status, not a check result.`]}),q(Zt,{count:e?.unattributed_events})]})}var $t={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,typechange:`Type changed`};function en(e){return $t[e]||e||`unknown`}function tn(e,t){let n=e?.repo_url||t?.repo_url||``,r=t&&String(t.pr_number??``)!==``&&String(t.pr_number)===String(e?.pr_number??``);return{repo:n,pr:e?.pr_url||r&&t.pr_url||``}}function nn(e={}){let t=Number(e.files)||0,n=[`${t} file${t===1?``:`s`}`];return e.additions&&n.push(`+${e.additions}`),e.deletions&&n.push(`−${e.deletions}`),n.join(` · `)}function rn({capture:e}){let t=e.files||[],n=Number(e.totals?.files)||t.length;return t.length?q(S,{children:[q(`table`,{className:`table run-changes-table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Path`}),q(`th`,{children:`Change`}),q(`th`,{className:`run-changes-count`,children:`Added`}),q(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),q(`tbody`,{children:t.map((e,t)=>q(`tr`,{children:[q(`td`,{className:`mono run-changes-path`,children:[e.old_path?q(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),q(`td`,{children:[en(e.status),e.binary?q(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),q(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),q(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?q(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):q(`div`,{className:`run-changes-empty`,children:[`This capture recorded no file entries`,n?`, though its totals cover ${n} file${n===1?``:`s`}`:``,`.`]})}function an({capture:e,task:t}){let n=tn(e,t),r=e.pr_number;return q(`section`,{className:`run-capture`,children:[q(`div`,{className:`run-capture-head`,children:[q(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),q(`span`,{className:`run-capture-at`,children:e.captured_at?Y(e.captured_at):``})]}),q(`div`,{className:`run-capture-meta`,children:[q(`span`,{className:`mono`,children:n.repo?q(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?q(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?q(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?q(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):q(`span`,{className:`mono`,children:[`PR #`,r]}):null,q(`span`,{className:`run-capture-totals`,children:nn(e.totals)})]}),q(rn,{capture:e})]})}function on({state:e,task:t,onRetry:n}){if(e===void 0)return q(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return q(`div`,{className:`run-error`,children:[q(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),q(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?q(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),q(`div`,{children:`This attempt has a change capture event, but this dashboard could not decode its payload. That is a read failure, not a statement about what the attempt changed.`})]}):!e.found||!r.length?q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),q(`div`,{children:`Archie records what an attempt changed when it commits or pushes that work. Nothing was recorded here — the attempt may predate capture, or it produced no commit. This is not the same as "no files changed".`})]}):q(`div`,{className:`run-changes`,children:r.map((e,n)=>q(an,{capture:e,task:t},`${e.captured_at||``}:${n}`))})}function sn(e,t){return(e||[]).find(e=>e&&e.kind===`config_captured`&&Number(e.attempt)===Number(t))||null}function cn({events:e,attempt:t,onRetry:n}){if(e===void 0)return q(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return q(`div`,{className:`run-error`,children:[q(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),q(`div`,{className:`run-error-detail`,children:`The configuration is recorded as an event on the task, so it cannot be shown while the event stream is unreadable. archied did not answer — retry, or check the daemon.`}),n?q(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=sn(e,t);if(!r)return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`Not captured for this run`}),q(`div`,{children:[`Archie records the effective configuration when it dispatches an attempt. Attempt `,t,` `,`has no such record — it predates the record, or the capture did not run. Nothing here says the run used the defaults.`]})]});let i=r.data||{},a=i.schema||``,o=i.document;return q(`div`,{className:`run-config`,children:[q(`p`,{className:`run-config-scope`,children:[`This is attempt `,r.attempt,`'s effective task-runtime configuration: a non-secret subset covering bot identity, models, limits, budgets, dispatch, diff cap, notifications, forge host and tool policy. It is not the dashboard configuration view — providers, repositories, identities, credentials and lock state are not part of it.`]}),q(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?q(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):q(S,{children:[q(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),q(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function ln({state:e,attempt:t,onRetry:n}){return e===void 0?q(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?q(`div`,{className:`run-error`,children:[q(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),q(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's debug view. It may be restarting — retry, or check the daemon.`}),n?q(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):q(`div`,{className:`run-debug`,children:[q(`p`,{className:`run-debug-note`,children:[`The stored task record and its events, verbatim. Events are unfiltered on purpose: this is every event the task has, and each one carries the attempt it belongs to. Attempt `,t,` `,`is the one selected above.`]}),q(`pre`,{className:`run-json`,children:JSON.stringify(e,null,2)})]})}var un=[{id:`stages`,label:`Stages`},{id:`log`,label:`Log`},{id:`changes`,label:`Changed files`},{id:`config`,label:`Configuration`},{id:`debug`,label:`Debug`}],dn=`run`,fn=new Set(un.map(e=>e.id));function pn(e){let t=String(e??``).trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:null}function mn(e){let t=e?.get?.(`tab`)||``;return fn.has(t)?t:un[0].id}function hn(e){let t=e?.get?.(`attempt`);if(t==null||t===``)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null}function gn(e,t,n){let r=new URLSearchParams;return r.set(`tab`,t||un[0].id),n&&r.set(`attempt`,String(n)),`#/tasks/${e}?${r.toString()}`}function _n(e,t,n){try{window.history.replaceState(null,``,`${location.pathname}${location.search}${gn(e,t,n)}`)}catch{}}function vn(e,t){return`${e}|${Number(t)||0}`}function yn({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function bn({id:e}){return q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Task not found`}),q(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),q(`div`,{className:`page-actions`,children:q(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),q(`div`,{className:`card`,children:q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),q(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function xn({raw:e}){return q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Not a task id`}),q(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),q(`div`,{className:`page-actions`,children:q(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),q(`div`,{className:`card`,children:q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),q(`div`,{children:`A task id is a positive whole number. Nothing was requested.`})]})})]})}function Sn({attempts:e,selected:t,onSelect:n}){let r=e?.attempts||[];return r.length?q(`div`,{className:`run-attempts`,role:`group`,"aria-label":`Attempts of this task`,children:r.map(e=>{let r=Kt(e.status),i=Number(e.attempt)===Number(t);return q(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[q(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),q(Z,{text:r.label,kind:r.kind}),q(`span`,{className:`run-attempt-meta`,children:[(e.stages||[]).length,` stage`,(e.stages||[]).length===1?``:`s`]})]},e.attempt)})}):null}function Cn({id:e,query:t}){let[n,r]=H(()=>mn(t)),[i,a]=H(()=>hn(t)),[o,s]=H(void 0),[c,l]=H(void 0),[u,d]=H(!1),[f,p]=H(void 0),[m,h]=H(At),[g,_]=H(new Map),[v,y]=H(new Map),[b,x]=H(new Map),[S,C]=H(!1),[w,T]=H(null),[E,D]=H(0),O=W(new Set),k=Array.isArray(o)&&o.find(t=>String(t.id)===String(e))||null,A=Number(c?.current_attempt)>0?Number(c.current_attempt):null,j=i??A,M=(c?.attempts||[]).find(e=>Number(e.attempt)===Number(j)),N=[...new Set((M?.stages||[]).map(e=>e.name).filter(Boolean))],P=(e,t,n,{force:r=!1}={})=>{O.current.has(e)&&!r||(O.current.add(e),n(t=>new Map(t).set(e,void 0)),t().then(t=>n(n=>new Map(n).set(e,t))).catch(()=>n(t=>new Map(t).set(e,null))))},F=()=>{s(void 0),K.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),K.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),K.task(e).then(e=>p(e||[])).catch(()=>p(null))},ee=(t,n)=>P(jt(e,t,m),()=>K.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),R=(t,n)=>P(vn(e,t),()=>K.taskChanges(e,{attempt:t}),y,n),te=(t,n)=>P(vn(e,t),()=>K.taskDebug(e,{attempt:t}),x,n),ne=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};U(()=>{F(),I(),L()},[]),U(()=>{j!=null&&(n===`log`?ee(j):n===`changes`?R(j):n===`debug`&&te(j))},[n,j,m,E]),U(()=>{_n(e,n,j)},[e,n,j]);let re=async()=>{let t=k?.title||`task ${e}`;if(window.confirm(`Start a new run for "${t}"? This is a new attempt, and the previous attempt's commits are discarded.`)){T(null),C(!0);try{await K.taskAction(e,`retry`),O.current=new Set,_(new Map),y(new Map),x(new Map),a(null),F(),I(),L(),D(e=>e+1)}catch(e){T(Ne(e))}finally{C(!1)}}};if(u)return q(bn,{id:e});let ie=j==null?null:jt(e,j,m),ae=vn(e,j),z=vn(e,j),B=()=>{if(n===`stages`)return q(Qt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return q(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return q(`div`,{className:`run-error`,children:[q(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),q(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),q(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return q(yn,{title:`No attempt recorded`,detail:`This task has no recorded run, so there is nothing to read for an attempt.`});switch(n){case`log`:return q(Pt,{state:ie&&g.has(ie)?g.get(ie):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>ee(j,{force:!0})});case`changes`:return q(on,{state:v.has(ae)?v.get(ae):void 0,task:k,onRetry:()=>R(j,{force:!0})});case`config`:return q(cn,{events:f,attempt:j,onRetry:L});case`debug`:return q(ln,{state:b.has(z)?b.get(z):void 0,attempt:j,onRetry:()=>te(j,{force:!0})});default:return q(Qt,{state:c,attemptNumber:j,events:f,onRetry:I})}},oe=Xe(`retry`),se=!!(oe&&(k?.actions||[]).includes(`retry`));return q(`div`,{className:`run-page`,children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),q(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),q(`div`,{className:`page-actions`,children:[q(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),q(`button`,{className:`btn`,type:`button`,onClick:ne,children:`Refresh`})]})]}),q(`div`,{className:`run-meta`,children:[q(`span`,{className:`run-meta-item`,children:[q(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?q(`span`,{className:`run-meta-muted`,children:`loading…`}):k?q(Z,{text:Ke(k.status),kind:qe(k.status)}):q(`span`,{className:`run-meta-muted`,children:`not read`})]}),q(`span`,{className:`run-meta-item`,children:[q(`span`,{className:`run-meta-label`,children:`Attempt`}),q(`span`,{className:`run-meta-value`,children:c===null?`run history unreadable`:c===void 0?`loading…`:j==null?`none recorded`:`attempt ${j} of ${A??j}`})]}),k?.repo_url?q(`a`,{className:`run-meta-link`,href:k.repo_url,target:`_blank`,rel:`noreferrer`,children:[k.owner,`/`,k.repo]}):null,k?.issue_url&&k.issue_number?q(`a`,{className:`run-meta-link`,href:k.issue_url,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,k.issue_number]}):null,k?.pr_url&&k.pr_number?q(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?q(`p`,{className:`run-note`,children:`The task list could not be read, so this page cannot show the task's current status or its operator controls. The run history below comes from the task's own endpoints.`}):null,Array.isArray(o)&&!k?q(`p`,{className:`run-note`,children:[`Task `,e,` is not among the tasks this dashboard lists (the list covers the 100 most recently updated). Its recorded attempts are shown below; the Debug tab holds the stored record verbatim.`]}):null,q(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[q(`button`,{className:`btn ${oe?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!se||S,title:`Retry this task as a new run`,onClick:re,children:S?`Starting…`:`Start a new run`}),q(`p`,{className:`run-restart-copy`,children:`Starts a new attempt for this task: a fresh worktree reset onto the base branch. The previous attempt's commits are discarded — they are not carried into the new run.`}),!se&&o!==void 0?q(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${Ke(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?q(`p`,{className:`run-restart-error run-restart-error-${w.kind}`,children:w.kind===`session-expired`?`Your session has expired. Reload to sign in.`:w.kind===`refused`?`${w.message} — this run cannot be restarted from here.`:`${w.message} — try again, or check the daemon.`}):null]}),q(Sn,{attempts:c,selected:j,onSelect:e=>a(e)}),q(`div`,{className:`card run-card`,children:[q(Wt,{tabs:un,active:n,onSelect:r,prefix:dn}),q(`div`,{className:`run-panel`,role:`tabpanel`,id:Ut(dn,n),"aria-labelledby":Ht(dn,n),tabIndex:0,children:B()})]})]})}function wn(e,t){let n=t?.id,r=pn(n);return r===null?q(xn,{raw:n??``}):q(Cn,{id:r,query:e},r)}function Tn({title:e,detail:t}){return q(`div`,{class:`empty`,children:[q(`div`,{class:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function En(e){return q(Dn,{query:e})}function Dn(){let[e,t]=H([]),[n,r]=H(``),[i,a]=H(null),o=async()=>{try{let e=await K.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};U(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=ve(()=>e.filter(e=>s(e,n)),[e,n]);return q(`div`,{children:[q(`div`,{class:`page-head`,children:[q(`div`,{children:[q(`h1`,{class:`page-title`,children:`Skills`}),q(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),q(`div`,{class:`page-actions`,children:q(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:[q(`div`,{children:[q(`h2`,{class:`card-title`,children:`Catalogue`}),q(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),q(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),q(`div`,{class:`grid grid-2`,children:i?q(Tn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>q(`div`,{class:`card skill-card`,children:[q(`div`,{class:`card-head`,children:[q(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&q(Z,{text:e.workflow,kind:`info`})]}),q(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),q(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):q(Tn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):q(Tn,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}function On(e,t){let n=new Map((e||[]).map(e=>[e.workflow,e])),r=[],i=new Set;for(let e of t||[])i.add(e.id),r.push({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}});for(let t of e||[])i.has(t.workflow)||r.push({id:t.workflow,name:t.workflow,...t});return r}var kn={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function An(e){return kn[e]?kn[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function jn(e,t){return t?Math.round(e/t*100):0}function Mn(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function Nn({title:e,detail:t}){return q(`div`,{class:`empty`,children:[q(`div`,{class:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Pn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return q(`div`,{class:`wf-bar`,children:q(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Fn(e){return q(In,{query:e})}function In(){let[e,t]=H([]),[n,r]=H([]),[i,a]=H([]),[o,s]=H(null),c=async()=>{try{let e=await K.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return U(()=>{c()},[]),q(`div`,{children:[q(`div`,{class:`page-head`,children:[q(`div`,{children:[q(`h1`,{class:`page-title`,children:`Workflows`}),q(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),q(`div`,{class:`page-actions`,children:q(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),q(Ln,{definitions:e}),o?q(`div`,{class:`card`,children:q(Nn,{title:`Cannot reach archied`,detail:o})}):q(S,{children:[q(Rn,{workflows:n,definitions:e}),q(zn,{stages:i})]})]})}function Ln({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=H(``),[i,a]=H(``),[o,s]=H(t),[c,l]=H(``),[u,d]=H(``),[f,p]=H(!1),[m,h]=H(``);return U(()=>{!o&&t&&s(t)},[t,o]),q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:[q(`h2`,{class:`card-title`,children:`Start work`}),q(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),q(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await K.workRequest({identity:n,repository:i,workflow:o,title:c,instructions:u});h(`Queued task #${e.task_id}.`),r(``),a(``),s(t),l(``),d(``)}catch(e){h(String(e.message||e))}finally{p(!1)}},children:[q(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),q(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),q(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>q(`option`,{value:e.id,children:An(e.name||e.id)},e.id))}),q(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),q(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),q(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&q(`p`,{class:`card-sub`,children:m})]})]})}function Rn({workflows:e,definitions:t}){let n=On(e,t);return n.length?q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:[q(`h2`,{class:`card-title`,children:`Per workflow`}),q(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),q(`div`,{class:`table-scroll`,children:q(`table`,{class:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Workflow`}),q(`th`,{children:`Origin`}),q(`th`,{children:`Runs`}),q(`th`,{children:`Success rate`}),q(`th`,{children:`Avg tokens`}),q(`th`,{children:`Avg steps`})]})}),q(`tbody`,{children:n.map(e=>{let t=jn(e.merged,e.runs);return q(`tr`,{children:[q(`td`,{class:`strong`,children:An(e.workflow)}),q(`td`,{class:`mono`,children:e.origin||`registry`}),q(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),q(`td`,{children:[q(`div`,{class:`wf-rate`,children:[t,`%`,q(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),q(Pn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),q(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),q(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:q(`h2`,{class:`card-title`,children:`Per workflow`})})}),q(Nn,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function zn({stages:e}){if(!e.length)return q(`div`,{class:`card wf-stage-card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:q(`h2`,{class:`card-title`,children:`Per stage`})})}),q(Nn,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return q(`div`,{class:`grid grid-2 wf-stage-card`,children:[q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:[q(`h2`,{class:`card-title`,children:`Slowest stages`}),q(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),q(`div`,{class:`table-scroll`,children:q(`table`,{class:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Workflow`}),q(`th`,{children:`Stage`}),q(`th`,{children:`Runs`}),q(`th`,{children:`Avg duration`})]})}),q(`tbody`,{children:n.map((e,n)=>q(`tr`,{children:[q(`td`,{children:An(e.workflow)}),q(`td`,{class:`strong`,children:e.stage}),q(`td`,{children:e.runs}),q(`td`,{children:[q(`div`,{class:`wf-rate`,children:Mn(e.avg_ms)}),q(Pn,{fraction:jn(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),q(`div`,{class:`card`,children:[q(`div`,{class:`card-head`,children:q(`div`,{children:[q(`h2`,{class:`card-title`,children:`Most failures`}),q(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?q(`div`,{class:`table-scroll`,children:q(`table`,{class:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Workflow`}),q(`th`,{children:`Stage`}),q(`th`,{children:`Failures`})]})}),q(`tbody`,{children:r.map((e,t)=>q(`tr`,{children:[q(`td`,{children:An(e.workflow)}),q(`td`,{class:`strong`,children:e.stage}),q(`td`,{children:[q(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),q(Pn,{fraction:jn(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):q(Nn,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Bn({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Vn(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function Hn(){let[e,t]=H([]),[n,r]=H(null),i=async()=>{try{let e=await K.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return U(()=>{i()},[]),q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Channels`}),q(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),q(`div`,{className:`grid grid-2`,children:n?q(Bn,{title:`Cannot reach archied`,detail:n}):e.length===0?q(Bn,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>q(`div`,{className:`card channel-card`,children:[q(`div`,{className:`card-head`,children:[q(`h3`,{className:`card-title`,children:e.name}),q(Z,{text:e.state||(e.configured?`configured`:`stopped`),kind:Vn(e.state,e.configured)})]}),q(`p`,{className:`channel-desc`,children:e.description}),q(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?q(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await K.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):q(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Un(e){return q(Hn,{query:e})}function Wn({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Gn(e){return q(Kn,{query:e})}function Kn({query:e}){let[t,n]=H([]),[r,i]=H(null),a=async()=>{try{let e=await K.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return U(()=>{a()},[]),q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Curators`}),q(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),q(`div`,{className:`grid grid-2`,children:r?q(Wn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>q(Jn,{curator:e},e.name)):q(Wn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function qn(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function Jn({curator:e}){let t=e.recent_actions||[];return q(`div`,{className:`card curator-card`,children:[q(`div`,{className:`card-head`,children:[q(`h3`,{className:`card-title`,children:e.name}),q(Z,{text:e.health?.status||`unknown`,kind:qn(e.health?.status)})]}),e.health?.message&&q(`p`,{className:`curator-health-message`,children:e.health.message}),q(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${Y(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?q(`ul`,{className:`curator-actions`,children:t.map((e,t)=>q(`li`,{className:`curator-action`,children:[q(`div`,{className:`curator-action-head`,children:[q(`span`,{className:`curator-action-type`,children:e.type||`action`}),q(`span`,{className:`curator-action-time`,children:Y(e.at)})]}),e.detail&&q(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&q(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):q(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function Yn(e){return e==null||e===``?`—`:String(e)}function Xn({label:e,value:t,opts:n}){let r=Yn(t),[i,a]=H(!1),[o,s]=H(``),[c,l]=H(null),[u,d]=H(!1),[f,p]=H(!1),m=n?.key;if(!m)return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,title:n?.hint,children:e}),q(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return q(`div`,{className:`kv is-locked`,children:[q(`span`,{className:`kv-label`,title:n.hint,children:e}),q(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),q(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,title:n.hint,children:e}),q(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.overridden?.includes(m),_=()=>{s(String(n.raw??``)),l(null),a(!0)},v=async()=>{p(!0),l(null);try{await K.configReset(m),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{p(!1)}},y=async()=>{let e=Zn(n.type,o);if(e.error){l(e.error);return}d(!0),l(null);try{await(n.save||(e=>K.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=W(null);U(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),y()),e.key===`Escape`&&a(!1)},i;return i=n.type===`bool`?q(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[q(`option`,{value:`true`,children:`true`}),q(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?q(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>q(`option`,{value:e,children:e},e))}):q(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,title:n.hint,children:e}),i,q(`div`,{className:`kv-actions`,children:[q(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),q(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&q(`span`,{className:`kv-note is-error`,children:c})]})}return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,title:n.hint,children:e}),q(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),q(`div`,{className:`kv-actions`,children:[g&&q(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),q(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&q(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:v,disabled:f,children:`Reset`})]}),c&&q(`span`,{className:`kv-note is-error`,children:c})]})}function Zn(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function Qn({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function $n({sub:e,title:t,children:n}){return q(`div`,{className:`card cfg-section`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:t||`Update status`}),q(`p`,{className:`card-sub`,children:e})]})}),n]})}var er={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},tr={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function nr({components:e}){return!e||!e.length?q($n,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:q(Qn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):q($n,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Component`}),q(`th`,{children:`Install type`}),q(`th`,{children:`Running`}),q(`th`,{children:`Latest available`}),q(`th`,{children:`Status`})]})}),q(`tbody`,{children:e.map(e=>q(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` +`),children:[q(`td`,{className:`strong`,children:e.label||e.id}),q(`td`,{className:`mono`,children:e.install_type||`—`}),q(`td`,{className:`mono`,children:e.running_version||`—`}),q(`td`,{className:`mono`,children:e.latest_available||`—`}),q(`td`,{children:q(Z,{text:er[e.status]||e.status,kind:tr[e.status]||`idle`})})]},e.id||e.label))})]})})})}function rr({title:e,sub:t,children:n}){return q(`div`,{className:`card cfg-section`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:e}),q(`p`,{className:`card-sub`,children:t})]})}),n]})}function ir(e){return e?.error?e.error:e?.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`}function ar({data:e,onDefer:t,onInstall:n}){let r=e?.available||[];return r.length?q(rr,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:[q(`p`,{className:`cfg-note`,children:r.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)}),q(`div`,{className:`cfg-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>t?.(e.snapshot),children:`Defer`}),e.can_install&&q(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>n?.(e.snapshot),children:`Install update`})]})]}):q(rr,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:q(`p`,{className:`cfg-note`,children:ir(e)})})}var or=e=>e.Number??e.number,sr=e=>e.Label??e.label??`checkpoint`;function cr({data:e,onRequest:t,onDecide:n}){let[r,i]=H(``),[a,o]=H(``);if(e?.error)return q(rr,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run.`,children:q(`p`,{className:`cfg-note`,children:e.error})});let s=e?.pending||[];return q(rr,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run. Requesting one only queues it.`,children:[q(`div`,{className:`cfg-request-row`,children:[q(`select`,{"aria-label":`Checkpoint`,value:r,onChange:e=>i(e.target.value),children:[q(`option`,{value:``,children:`Select checkpoint`}),(e?.checkpoints||[]).map(e=>q(`option`,{value:String(or(e)),children:[or(e),` — `,sr(e)]},or(e)))]}),q(`button`,{className:`btn`,type:`button`,disabled:!r,onClick:()=>t?.(`rollback`,r),children:`Request rollback`})]}),q(`div`,{className:`cfg-request-row`,children:[q(`input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`,value:a,onInput:e=>o(e.target.value)}),q(`button`,{className:`btn`,type:`button`,disabled:!a.trim(),onClick:()=>t?.(`stop`,a),children:`Request stop`})]}),s.length?q(S,{children:s.map(e=>q(`div`,{className:`cfg-pending`,children:[q(`span`,{children:e.description}),q(`div`,{className:`cfg-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`approve`),children:`Approve`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`permanent`),children:`Approve for 24h`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`deny`),children:`Deny`})]})]},e.id))}):q(`p`,{className:`cfg-note`,children:`No pending dangerous actions.`})]})}function Q({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return q(`div`,{className:`card cfg-section`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:e}),q(`p`,{className:`card-sub`,children:t})]})}),n]})}function lr({origins:e}){return e?.length?q($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:q(`div`,{className:`kv-list`,children:e.map((e,t)=>q(Xn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):q($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:q(Q,{title:`Source provenance is unavailable.`})})}function ur(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function dr({data:e,error:t}){if(t)return q($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:q(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return q($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[q(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?q(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??Ke(e.id),n=e.kind??qe(e.id);return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,children:e.id}),q(`span`,{className:`kv-value`,children:q(Z,{text:t,kind:n})})]},e.id)})}):q(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),q(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?q(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=ur(e.kind);return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,children:e.id}),q(`span`,{className:`kv-value`,children:q(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):q(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function fr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=H(!1),[o,s]=H(null),[c,l]=H(!!e[t]);return r?q(`td`,{children:[q(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await K.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&q(`span`,{className:`kv-note is-error`,children:o})]}):q(`td`,{children:c?`yes`:`no`})}function pr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=H(String(e[t]??0)),[o,s]=H(null),[c,l]=H(!1);return r?q(`td`,{children:[q(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await K.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&q(`span`,{className:`kv-note is-error`,children:o})]}):q(`td`,{className:`mono`,children:i})}function mr({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return q($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:q(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return q($,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Repository`}),q(`th`,{children:`Base branch`}),q(`th`,{children:`Ecosystem`}),q(`th`,{children:`Quality gate`}),q(`th`,{children:`Protected paths`}),q(`th`,{children:`Concurrent`}),q(`th`,{children:`Max retries`}),q(`th`,{children:`Self-review`})]})}),q(`tbody`,{children:e.map((e,i)=>q(`tr`,{children:[q(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),q(`td`,{className:`mono`,children:e.base}),q(`td`,{children:e.ecosystem||`go`}),q(`td`,{className:`mono`,children:r(e.gate)}),q(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),q(fr,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),q(pr,{r:e,field:`max_retries`,onSaved:t,editable:n}),q(fr,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function hr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function gr({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return q($,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[q(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?q(`div`,{className:`kv-list`,children:n.map(([e,t])=>q(Xn,{label:hr(e),value:t},e))}):q(Q,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),q(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{children:`Provider`}),q(`th`,{children:`Class`}),q(`th`,{children:`Base URL`}),q(`th`,{children:`API key env var`}),q(`th`,{children:`Status`})]})}),q(`tbody`,{children:r.map(([e,t])=>q(`tr`,{children:[q(`td`,{className:`strong`,children:e}),q(`td`,{children:t.class}),q(`td`,{className:`mono`,children:t.base_url||`default`}),q(`td`,{className:`mono`,children:t.api_key_env||`—`}),q(`td`,{children:t.configured?q(Z,{text:`configured`,kind:`ok`}):q(Z,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):q(Q,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function _r(){let[e,t]=H(null),[n,r]=H(null),[i,a]=H(null),[o,s]=H(null),[c,l]=H(!1),[u,d]=H(null),[f,p]=H(null),[m,h]=H(null),[g,_]=H(null),v=()=>{E(),D(),O(),y(),b()},y=async()=>{try{h(await K.chatUpdate())}catch(e){h(e?.status===501?null:{error:String(e.message||e)})}},b=async()=>{try{_(await K.chatDangerous())}catch(e){_(e?.status===501?null:{error:String(e.message||e)})}},x=async e=>{await K.chatUpdateDefer(e),await y()},C=async e=>{await K.chatUpdateInstall(e),await y()},w=async(e,t)=>{await K.chatDangerousRequest(e,t),await b()},T=async(e,t)=>{await K.chatDangerousDecision(e,t),await b()},E=async()=>{try{let e=await K.config();t(e),r(null)}catch(e){r(String(e.message||e))}},D=async()=>{try{let e=await K.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},O=async()=>{try{let e=await K.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return U(()=>{v()},[]),q(`div`,{className:`cfg-page`,children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Configuration`}),q(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn`,onClick:v,children:`Refresh`})})]}),q(`div`,{children:c?q(`div`,{className:`card cfg-section`,children:q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Update status`}),q(`p`,{className:`card-sub`,children:`Not configured on this deployment, so there is nothing to check against.`})]})})}):o?q(`div`,{className:`card`,children:q(Q,{title:`Update status unavailable`,detail:o})}):i?q(nr,{components:i}):null}),m&&q(`div`,{children:q(ar,{data:m,onDefer:x,onInstall:C})}),g&&q(`div`,{children:q(cr,{data:g,onRequest:w,onDecide:T})}),q(`div`,{children:q(dr,{data:u,error:f})}),q(`div`,{children:n?q(`div`,{className:`card`,children:q(Q,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?q(`div`,{className:`card`,children:q(Q,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):q(S,{children:[e.reload?.overlay_unavailable&&q(`div`,{className:`card cfg-notice`,children:q(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&q(`div`,{className:`card cfg-notice`,children:q(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?q($,{title:t.label,sub:t.description,children:q(`div`,{className:`kv-list`,children:r.map(t=>q(Xn,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable&&e.editable!==!1,locked:e.locked||{},overridden:e.overridden||[],onSaved:E}},t.key))})},n):null}),q(mr,{repos:e.repositories,onSaved:E,editable:e.editable!==!1}),q(gr,{models:e.models,providers:e.providers}),q(lr,{origins:e.provenance})]})})]})}function vr(e){return q(_r,{query:e})}function yr(e,t){return t===`unavailable`?`Log stream unavailable`:e?`No logs yet`:`Nothing matches`}function br(e,t){return t===`unavailable`?`The daemon is not serving /api/logs/stream. Reload once it is reachable.`:e?`This deployment keeps no durable history. Live daemon logs appear here while the page is open.`:`Try a wider level or clear the search.`}function xr({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Sr(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function Cr(){let[e,t]=H({level:``,component:``,q:``}),[n,r]=H(!1),[i,a]=H([]),[o,s]=H([]),c=W(new Map),[l,u]=H(0),[d,f]=H(!1),[p,m]=H(`connecting`),[h,g]=H(`Refreshing…`),_=W(null),v=W(null),y=async()=>{g(`Refreshing…`);try{let t=await K.logs({level:e.level,component:e.component,q:e.q,limit:500});a(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),f(!!t.disabled);let n=t.disabled?`Live only`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;g(n),s(t.entries||[])}catch{g(`Cannot read logs`)}};U(()=>{y()},[e]),U(()=>{let e=Ie(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(Sr(t),t),t.fields?.component&&a(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),u(e=>e+1))},e=>{m(e)});return()=>e()},[]);let b=W(n);b.current=n;let x=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},S=W(x);S.current=x;let C=ve(()=>{let e=new Map;for(let t of o)e.set(Sr(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return U(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Logs`}),q(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),q(`div`,{className:`page-actions`,children:[q(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),q(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),q(`div`,{className:`card`,children:[q(`div`,{className:`card-head`,children:[q(`div`,{className:`log-filters`,children:[q(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:wt.map(e=>q(`option`,{value:e.value,children:e.label},e.value))}),q(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[q(`option`,{value:``,children:`All components`}),i.map(e=>q(`option`,{value:e,children:e},e))]}),q(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),q(`div`,{className:`log-status`,children:[q(`span`,{className:`log-meta`,children:h}),q(Z,{text:p,kind:p===`live`?`ok`:p===`unavailable`?`danger`:`warn`})]})]}),q(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?q(xr,{title:`Cannot read logs`}):C.length?C.map(e=>q(Et,{entry:e},Sr(e))):q(xr,{title:yr(d,p),detail:br(d,p)})})]})]})}function wr(e){return q(Cr,{query:e})}function Tr({capture:e,expanded:t,onToggle:n}){return q(S,{children:[q(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[q(`td`,{className:`mono`,children:e.source||`(unknown)`}),q(`td`,{title:e.received_at||``,children:Y(e.received_at)}),q(`td`,{children:q(Z,{text:`Unbound`,kind:`idle`})}),q(`td`,{className:`mono`,children:e.content_type||`—`}),q(`td`,{children:q(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&q(Er,{capture:e})]})}function Er({capture:e}){return q(`tr`,{className:`capture-detail-row`,children:q(`td`,{colSpan:`5`,children:q(`div`,{className:`capture-detail`,children:[q(`div`,{className:`capture-detail-section`,children:[q(`div`,{className:`capture-detail-title`,children:`Payload`}),q(Dr,{raw:e.body})]}),q(`div`,{className:`capture-detail-section`,children:[q(`div`,{className:`capture-detail-title`,children:`Headers`}),q(Dr,{raw:e.headers})]})]})})})}function Dr({raw:e}){return e?q(`pre`,{className:`capture-payload`,children:Or(e)}):q(`div`,{className:`capture-empty`,children:`(empty)`})}function Or(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function kr({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Ar(e){return q(jr,{query:e})}function jr({query:e}){let[t,n]=H([]),[r,i]=H(null),[a,o]=H(null),[s,c]=H(!0),[l,u]=H({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await K.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return U(()=>{d();let e=Fe(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Event inspector`}),q(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),q(`div`,{className:`page-actions`,children:[q(Z,{text:l.text,kind:l.kind}),q(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),q(`div`,{className:`card`,children:a?q(kr,{title:`Cannot reach archied`,detail:a}):s?t.length?q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>q(`th`,{children:e},t))})}),q(`tbody`,{children:t.map(e=>q(Tr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):q(kr,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):q(kr,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var Mr=[`string`,`number`,`bool`,`object`,`array`,`any`];function Nr(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function Pr(e,t){return e?`${e}.${t}`:t}function Fr(e,t){return`${e}[${t}]`}function Ir({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?q(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Fr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,Pr(t,e)])).map(([e,t,n])=>q(`li`,{className:`mapping-tree-item`,children:[q(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:Nr(t),name:e})},children:e}),q(Ir,{value:t,path:n,name:e,onPick:r})]},n))}):q(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:Nr(e),name:n})},children:JSON.stringify(e)})}function Lr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return q(`div`,{className:`mapping-empty-fields`,children:`Click a value in the payload to bind a field.`});let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return q(`table`,{className:`table mapping-fields-table`,children:[q(`thead`,{children:q(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>q(`th`,{children:e},t))})}),q(`tbody`,{children:e.map((e,s)=>q(`tr`,{children:[q(`td`,{children:q(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),q(`td`,{className:`mono`,children:e.path}),q(`td`,{children:q(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Mr.map(e=>q(`option`,{value:e,children:e},e))})}),q(`td`,{children:q(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),q(`td`,{children:q(Rr,{field:e,preview:t,failureByField:o})}),q(`td`,{children:q(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Rr({field:e,preview:t,failureByField:n}){if(!t)return q(Z,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?q(Z,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?q(Z,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):q(Z,{text:`skipped (optional)`,kind:`idle`})}function zr({mapping:e,onEdit:t,onDelete:n}){return q(`tr`,{children:[q(`td`,{children:e.name}),q(`td`,{className:`mono`,children:e.source_hint||`—`}),q(`td`,{children:String(e.fields?.length??0)}),q(`td`,{children:[q(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),q(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Br({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Vr(e){return q(Hr,{query:e})}function Hr({query:e}){let[t,n]=H([]),[r,i]=H([]),[a,o]=H(null),[s,c]=H(null),l=async()=>{try{let[e,t]=await Promise.all([K.mappings(),K.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};U(()=>{l()},[]);let u=()=>{c({id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},d=e=>{c({id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},f=async e=>{if(window.confirm(`Delete mapping "${e.name}"?`))try{await K.mappingDelete(e.id),await l()}catch(e){o(String(e.message||e))}},p=e=>{let t=r.find(t=>String(t.id)===String(e));c(e=>{let n={...e,captureId:t?t.id:null,preview:null};if(!t)n.payload=null,n.payloadError=null;else try{n.payload=JSON.parse(t.body),n.payloadError=null}catch{n.payload=null,n.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}return n})},m=({path:e,type:t,name:n})=>{c(r=>{let i=new Set(r.fields.map(e=>e.name)),a=n||`field`,o=1;for(;i.has(a);)a=`${n||`field`}_${++o}`;let s=[...r.fields,{name:a,path:e,type:t,required:!0}];return{...r,fields:s,preview:null}})},h=e=>{c(t=>{let n=t.fields.slice();return n.splice(e,1),{...t,fields:n,preview:null}})},g=(e,t)=>{c(n=>{let r=n.fields.slice();return r[e]={...r[e],...t},{...n,fields:r,preview:null}})};return s?q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:q(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),q(`div`,{className:`page-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),q(`button`,{className:`btn btn-primary`,type:`button`,onClick:async()=>{let e={name:s.name,source_hint:s.sourceHint,fields:s.fields};try{s.id?await K.mappingUpdate(s.id,e):await K.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&q(`div`,{className:`mapping-error`,children:s.actionError}),q(`div`,{className:`card mapping-form`,children:[q(`label`,{className:`mapping-form-row`,children:[`Name`,q(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),q(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,q(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),q(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,q(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[q(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>q(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),q(`div`,{className:`card mapping-fields`,children:[q(`div`,{className:`mapping-section-title`,children:`Bound fields`}),q(Lr,{fields:s.fields,preview:s.preview,onRemove:h,onNameChange:(e,t)=>g(e,{name:t}),onTypeChange:(e,t)=>g(e,{type:t}),onRequiredChange:(e,t)=>g(e,{required:t})}),q(`button`,{className:`btn`,type:`button`,onClick:async()=>{if(!s.captureId){c(e=>({...e,actionError:`Pick a captured event to preview against.`}));return}try{let e=await K.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),q(`div`,{className:`card mapping-payload`,children:[q(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?q(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?q(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):q(Ir,{value:s.payload,onPick:m})]})]}):q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Field mappings`}),q(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?q(Br,{title:`Cannot reach archied`,detail:a}):t.length?q(`div`,{className:`card`,children:q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>q(`th`,{children:e},t))})}),q(`tbody`,{children:t.map(e=>q(zr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):q(Br,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var Ur={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Wr={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Gr({status:e}){return q(Z,{text:Ur[e]||e,kind:Wr[e]||`idle`})}function Kr({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return q(`tr`,{children:[q(`td`,{children:e.name}),q(`td`,{className:`mono`,children:e.matcher?.source||`—`}),q(`td`,{children:e.workflow}),q(`td`,{className:`mono`,children:i}),q(`td`,{children:q(Gr,{status:e.status})}),q(`td`,{children:[q(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&q(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),q(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function qr({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function Jr(e){return q(Xr,{query:e})}function Yr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Xr({query:e}){let[t,n]=H([]),[r,i]=H([]),[a,o]=H([]),[s,c]=H(null),[l,u]=H(null),d=async()=>{try{let[e,t,r]=await Promise.all([K.bindings(),K.mappings(),K.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};U(()=>{d()},[]);let f=()=>{u(Yr())},p=e=>{u({id:e.id,name:e.name,source:e.matcher?.source||``,mappingId:e.mapping_id?String(e.mapping_id):``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,secret:``,actionError:null})},m=()=>u(null),h=async()=>{let e={name:l.name,matcher:{source:l.source},mapping_id:Number(l.mappingId)||0,workflow:l.workflow,owner:l.owner,repo:l.repo,secret:l.secret};try{l.id?await K.bindingUpdate(l.id,e):await K.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await K.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await K.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:q(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),q(`div`,{className:`page-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),q(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&q(`div`,{className:`binding-error`,children:l.actionError}),q(`div`,{className:`card binding-form`,children:[q(`label`,{className:`binding-form-row`,children:[`Name`,q(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),q(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,q(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),q(`label`,{className:`binding-form-row`,children:[`Field mapping`,q(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[q(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>q(`option`,{value:e.id,children:e.name},e.id))]})]}),q(`label`,{className:`binding-form-row`,children:[`Workflow`,q(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[q(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>q(`option`,{value:e.id,children:e.name},e.id))]})]}),q(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,q(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),q(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,q(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),q(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,q(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):q(`div`,{children:[q(`div`,{className:`page-head`,children:[q(`div`,{children:[q(`h1`,{className:`page-title`,children:`Playbook bindings`}),q(`p`,{className:`page-sub`,children:`Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire.`})]}),q(`div`,{className:`page-actions`,children:q(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?q(qr,{title:`Cannot reach archied`,detail:s}):t.length?q(`div`,{className:`card`,children:q(`div`,{className:`table-scroll`,children:q(`table`,{className:`table`,children:[q(`thead`,{children:q(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>q(`th`,{children:e},t))})}),q(`tbody`,{children:t.map(e=>q(Kr,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):q(qr,{title:`No bindings yet`,detail:`Create one from a saved field mapping to turn a captured webhook into a workflow.`})]})}var Zr=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;function Qr(e){let t=[],n=0,r=0;for(let i of String(e).matchAll(Zr)){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith(`![`)){let e=a.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.push(q(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(q(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(q(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(q(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(q(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(q(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(q(`p`,{children:Qr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>q(`li`,{children:Qr(e)},t));n.push(a.tag===`ol`?q(`ol`,{children:e},s++):q(`ul`,{children:e},s++)),a=null};for(let e=0;eq(`th`,{children:Qr(e)},t))})}),q(`tbody`,{children:t.map((e,t)=>q(`tr`,{children:e.map((e,t)=>q(`td`,{children:Qr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(q(e,{children:Qr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(q(`blockquote`,{children:Qr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(q(`pre`,{children:q(`code`,{children:o.join(` +`)})},s++)),q(`div`,{className:t,children:n})}function ei(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function ti(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ni=`archie.web.chat.channel`;function ri(){let e=localStorage.getItem(ni);return e||(e=De(),localStorage.setItem(ni,e)),e}function ii(e){return{text:e,sourceID:De()}}function ai(e){return{...e}}function oi(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?ai(e.turn):ii(r),isRetry:n}}function si({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||ne+t?i-t:e}function ci(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function li(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?ci(n):`Archie`}function ui(){return location.hash.slice(1)||`/`}function di({open:e=!0}){let[t,n]=H([]),[r,i]=H(``),[a,o]=H([]),[s,c]=H(``),[l,u]=H(`Ready`),[d,f]=H(!1),[p,m]=H({}),[h,g]=H(``),[_,v]=H(``),[y,b]=H(``),[x,C]=H([]),[w,T]=H([]),[E,D]=H(0),[O,k]=H(!1),[A,j]=H(null),M=W(null),N=W(null),P=W(null),F=W(null),I=W(null),L=W(null),ee=W(d);ee.current=d,U(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),U(()=>{e&&N.current?.focus()},[e]),U(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=si({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),U(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),U(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await K.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await K.chatMessage(ri(),`/resume ${e}`);let[t,n]=await Promise.all([K.chatMessages(e),K.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function ne(e){if(r)try{u(`Working…`);let t=await K.chatMessage(ri(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function re(e,t){let n=window.prompt(t);n?.trim()&&ne(`${e} ${n.trim()}`)}function ie(e){let t=e.target.value;g(t),!(!r||!t)&&K.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ae(e){let t=e.target.value;if(v(t),t)try{let e=await K.chatMessage(ri(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function z(e){let t=e.target.value;if(b(t),t)try{let e=await K.chatMessage(ri(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function B(){c(`/new`),le({textOverride:`/new`})}function oe(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function se(e){let t=w[e];if(!t||!N.current)return;let n=N.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function ce(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),le();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),se(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),le())}async function le(e=null){let t=e?.textOverride,{text:n,turn:r,isRetry:a}=oi(e,t===void 0?s:t);if(!n||ee.current)return;k(!1),f(!0),u(a?`Retrying…`:`Thinking…`),a||(o(e=>[...e,{from:`web`,text:n}]),c(``));let l=[];j({text:``,tools:[],isError:!1,turn:r,isRetry:a});let d=``,p=!1,m=!1,h=null;try{let e=new AbortController;P.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await K.chatStream({channel_id:ri(),source_id:r.sourceID,text:r.text,page:ui()},{signal:e.signal})).body.getReader(),n=new TextDecoder,a=``;for(;;){let{value:e,done:r}=await t.read();a+=n.decode(e||new Uint8Array,{stream:!r});let o=a.split(` `);a=o.pop()||``;for(let e of o){let t=e.split(` -`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:ti(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function H(){u(`Stopping…`),r&&q.chatCancel(r).catch(()=>{}),P.current?.abort()}let le=p.models_by_provider||{},ue=_&&le[_]?le[_]:p.models||[];return J(`div`,{className:`chat-panel-content`,children:[J(`div`,{className:`chat-drawer-head`,children:[J(`strong`,{className:`chat-panel-title`,children:ai(t,r)}),J(`div`,{className:`chat-head-actions`,children:J(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:V,children:J(Y,{name:`message-circle-plus`})})})]}),J(`div`,{className:`chat-bar`,children:[J(`label`,{className:`chat-session-switch`,children:[J(`span`,{className:`sr-only`,children:`Conversation`}),J(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>J(`option`,{value:e.session_id,children:ii(e)},e.session_id)):J(`option`,{value:``,children:`No conversations yet`})})]}),J(`details`,{className:`chat-settings`,ref:L,children:[J(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:J(`span`,{"aria-hidden":`true`,children:`⚙`})}),J(`div`,{className:`chat-settings-body`,children:[J(`span`,{className:`chat-status`,children:l}),J(`label`,{children:[`Personality`,J(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:re,children:[J(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&J(`label`,{children:[`Provider`,J(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ie,children:[J(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),J(`label`,{children:[`Model`,J(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:B,children:[J(`option`,{value:``,children:`Default`}),ue.map(e=>J(`option`,{value:e,children:e},e))]})]})]})]})]}),J(`div`,{className:`chat-layout`,children:J(`section`,{className:`chat-workspace`,children:[J(`div`,{className:`chat-workspace-head`,children:J(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[J(`summary`,{children:`Session actions`}),J(`div`,{className:`chat-session-tool-list`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/title`,`Session title`),children:`Rename`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/branch`,`Branch name (optional)`),children:`Branch`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})}),J(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?J(`div`,{className:`chat-empty-state`,children:[J(`span`,{className:`chat-empty-mark`,children:`A`}),J(`h2`,{children:`What are we working on?`}),J(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),J(`div`,{className:`chat-prompt-grid`,children:[J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):J(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return J(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:J(`div`,{className:`chat-bubble`,children:i?J(S,{children:[a.length>0&&J(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return J(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[J(`span`,{className:`chat-tool-icon`,children:`🔧`}),J(`span`,{className:`chat-tool-name`,children:n}),r&&J(`code`,{className:`chat-tool-parameters`,children:r}),J(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),J(Yr,{text:r})]}):J(`div`,{className:`chat-bubble-text`,children:r})})},t)}),A&&J(`div`,{className:`chat-bubble-row assistant`,children:J(`div`,{className:`chat-bubble`,children:[A.tools?.length>0&&J(`div`,{className:`chat-tools`,children:A.tools.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return J(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[J(`span`,{className:`chat-tool-icon`,children:`🔧`}),J(`span`,{className:`chat-tool-name`,children:n}),r&&J(`code`,{className:`chat-tool-parameters`,children:r}),J(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),J(Yr,{text:A.text||`…`}),A.isError&&J(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>ce({turn:A.turn}),children:`Retry`})]})})]})}),J(`div`,{className:`chat-compose`,children:J(`div`,{className:`chat-composer-shell`,children:[J(`textarea`,{ref:N,className:`chat-composer`,rows:3,placeholder:`Message Archie, or type / for commands`,"aria-label":`Message Archie`,value:s,onInput:ae,onKeyDown:se}),O&&w.length>0&&J(`div`,{className:`chat-command-menu`,ref:I,role:`listbox`,"aria-label":`Commands`,children:w.map((e,t)=>J(`button`,{type:`button`,role:`option`,"aria-selected":String(t===E),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>oe(t),children:[J(`code`,{children:e.command}),J(`span`,{children:e.description||e.usage||``})]},e.command))}),J(`div`,{className:`chat-compose-actions`,children:[d&&J(`button`,{className:`btn`,type:`button`,onClick:H,children:`Stop`}),J(`button`,{className:`btn btn-primary`,type:`button`,disabled:d||!s.trim(),onClick:()=>ce(),children:`Send`})]})]})})]})})]})}function ci(e,t){let n=ui(t);for(let t of e){let e=di(t.path,n);if(e)return{route:t,params:e}}return null}function li(e){return e?.navPath||e?.path||`/`}function ui(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function di(e,t){let n=String(e).split(`/`),r=String(t).split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;et.nav!==!1&&!e.includes(t.path))}function _i({activePath:e,hidden:t,onNavigate:n,theme:r,onToggleTheme:i}){let[a,o]=U(!1),s=G(null),c=()=>o(!1);return J(`header`,{className:`topbar`,children:[J(`div`,{className:`brand`,children:[J(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),J(`nav`,{className:`nav`,children:gi(t).map(t=>J(`a`,{className:`nav-item`,href:`#${t.path}`,"aria-current":t.path===e?`page`:void 0,"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0,onClick:e=>{t.soon?e.preventDefault():n(t.path)},children:[J(Y,{name:t.icon}),J(`span`,{className:`nav-label`,children:t.label}),t.soon?J(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),J(`div`,{className:`topbar-end`,children:[J(`div`,{className:`topbar-search${a?` is-open`:``}`,children:[J(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:J(Y,{name:`search`,size:15})}),J(`button`,{className:`icon-btn mobile-search-toggle`,type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":a?`true`:`false`,onClick:()=>{o(!0),s.current?.focus()},children:J(Y,{name:`search`,size:15})}),J(`input`,{ref:s,type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),c(),e.target.blur();return}if(e.key!==`Enter`)return;let t=e.target.value.trim().toLowerCase(),r=fi.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),c())}})]}),J(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:J(Y,{name:`help`})}),J(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:i,children:J(Y,{name:r===`dark`?`moon`:`sun`})}),J(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}var vi=`chat-panel`;function yi(){let[e,t]=U(!1),n=G(null),r=ve(()=>{t(!1),n.current?.focus()},[]);return W(()=>{if(!e)return;let t=e=>{e.defaultPrevented||e.key!==`Escape`||r()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),J(`div`,{className:`chat-dock${e?` is-open`:``}`,children:[J(`aside`,{className:`chat-drawer${e?` is-open`:``}`,id:vi,"aria-label":`Chat with Archie`,"aria-hidden":e?void 0:`true`,children:J(`div`,{className:`chat-drawer-panel`,children:J(si,{open:e})})}),J(`button`,{ref:n,type:`button`,className:`chat-fab`,"aria-label":e?`Close chat`:`Chat with Archie`,title:e?`Close chat`:`Chat with Archie`,"aria-expanded":e?`true`:`false`,"aria-controls":vi,onClick:()=>e?r():t(!0),children:[J(`span`,{className:`chat-fab-icon chat-fab-icon-open`,"aria-hidden":`true`,children:J(Y,{name:`chat`,size:22})}),J(`span`,{className:`chat-fab-icon chat-fab-icon-close`,"aria-hidden":`true`,children:J(Y,{name:`close`,size:22})})]})]})}function bi({label:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:J(`div`,{children:J(`h1`,{className:`page-title`,children:e})})}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`${e} is not built yet`}),J(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function xi({view:e,search:t,params:n}){return e(t,n)}var Si=null,Ci=null;function wi(e){if(!Si)return;let[t,n=``]=String(e).split(`?`,2),r=ci(fi,t),i=r?.route||fi[0],a=r?.params||{};ie(i.view?J(xi,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):J(bi,{label:i.label}),Si)}function Ti(e){let[t]=String(e).split(`?`,2),n=ci(fi,t)?.route||fi[0];Si?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),Ci?.setActive(li(n)),wi(e)}function Ei(e){location.hash===`#${e}`?Ti(e):location.hash=e}window.addEventListener(`hashchange`,()=>Ti(location.hash.slice(1)||`/`));function Di(){let[e,t]=U(`/`),[n,r]=U(mi),[i,a]=U([]),o=ve(e=>{Si=e,Ci={setActive:t}},[]);return W(()=>{hi(n)},[n]),W(()=>{q.capabilities().then(e=>a(Fe(e?.sections,fi))).catch(()=>{})},[]),W(()=>{Ue().then(()=>wi(location.hash.slice(1)||`/`))},[]),J(S,{children:[J(`div`,{className:`shell`,children:[J(_i,{activePath:e,hidden:i,onNavigate:Ei,theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),J(`main`,{className:`main`,ref:o})]}),J(yi,{})]})}hi(mi()),ie(J(Di,{}),document.getElementById(`app`)),Ti(location.hash.slice(1)||`/`); \ No newline at end of file +`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:ai(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function V(){u(`Stopping…`),r&&K.chatCancel(r).catch(()=>{}),P.current?.abort()}let ue=p.models_by_provider||{},de=_&&ue[_]?ue[_]:p.models||[];return q(`div`,{className:`chat-panel-content`,children:[q(`div`,{className:`chat-drawer-head`,children:[q(`strong`,{className:`chat-panel-title`,children:li(t,r)}),q(`div`,{className:`chat-head-actions`,children:q(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:B,children:q(J,{name:`message-circle-plus`})})})]}),q(`div`,{className:`chat-bar`,children:[q(`label`,{className:`chat-session-switch`,children:[q(`span`,{className:`sr-only`,children:`Conversation`}),q(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>q(`option`,{value:e.session_id,children:ci(e)},e.session_id)):q(`option`,{value:``,children:`No conversations yet`})})]}),q(`details`,{className:`chat-settings`,ref:L,children:[q(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:q(`span`,{"aria-hidden":`true`,children:`⚙`})}),q(`div`,{className:`chat-settings-body`,children:[q(`span`,{className:`chat-status`,children:l}),q(`label`,{children:[`Personality`,q(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:ie,children:[q(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>q(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&q(`label`,{children:[`Provider`,q(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ae,children:[q(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>q(`option`,{value:e,children:e},e))]})]}),q(`label`,{children:[`Model`,q(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:z,children:[q(`option`,{value:``,children:`Default`}),de.map(e=>q(`option`,{value:e,children:e},e))]})]})]})]})]}),q(`div`,{className:`chat-layout`,children:q(`section`,{className:`chat-workspace`,children:[q(`div`,{className:`chat-workspace-head`,children:q(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[q(`summary`,{children:`Session actions`}),q(`div`,{className:`chat-session-tool-list`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/retry`),children:`Retry`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/undo`),children:`Undo`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>re(`/title`,`Session title`),children:`Rename`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>re(`/branch`,`Branch name (optional)`),children:`Branch`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/compress --preview`),children:`Preview compression`})]})]})}),q(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?q(`div`,{className:`chat-empty-state`,children:[q(`span`,{className:`chat-empty-mark`,children:`A`}),q(`h2`,{children:`What are we working on?`}),q(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),q(`div`,{className:`chat-prompt-grid`,children:[q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):q(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return q(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:q(`div`,{className:`chat-bubble`,children:i?q(S,{children:[a.length>0&&q(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return q(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[q(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),q(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return q(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[q(`span`,{className:`chat-tool-icon`,children:`🔧`}),q(`span`,{className:`chat-tool-name`,children:n}),r&&q(`code`,{className:`chat-tool-parameters`,children:r}),q(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),q($r,{text:r})]}):q(`div`,{className:`chat-bubble-text`,children:r})})},t)}),A&&q(`div`,{className:`chat-bubble-row assistant`,children:q(`div`,{className:`chat-bubble`,children:[A.tools?.length>0&&q(`div`,{className:`chat-tools`,children:A.tools.map((e,t)=>{if(e.path)return q(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[q(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),q(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return q(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[q(`span`,{className:`chat-tool-icon`,children:`🔧`}),q(`span`,{className:`chat-tool-name`,children:n}),r&&q(`code`,{className:`chat-tool-parameters`,children:r}),q(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),q($r,{text:A.text||`…`}),A.isError&&q(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>le({turn:A.turn}),children:`Retry`})]})})]})}),q(`div`,{className:`chat-compose`,children:q(`div`,{className:`chat-composer-shell`,children:[q(`textarea`,{ref:N,className:`chat-composer`,rows:3,placeholder:`Message Archie, or type / for commands`,"aria-label":`Message Archie`,value:s,onInput:oe,onKeyDown:ce}),O&&w.length>0&&q(`div`,{className:`chat-command-menu`,ref:I,role:`listbox`,"aria-label":`Commands`,children:w.map((e,t)=>q(`button`,{type:`button`,role:`option`,"aria-selected":String(t===E),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>se(t),children:[q(`code`,{children:e.command}),q(`span`,{children:e.description||e.usage||``})]},e.command))}),q(`div`,{className:`chat-compose-actions`,children:[d&&q(`button`,{className:`btn`,type:`button`,onClick:V,children:`Stop`}),q(`button`,{className:`btn btn-primary`,type:`button`,disabled:d||!s.trim(),onClick:()=>le(),children:`Send`})]})]})})]})})]})}function fi(e,t){let n=mi(t);for(let t of e){let e=hi(t.path,n);if(e)return{route:t,params:e}}return null}function pi(e){return e?.navPath||e?.path||`/`}function mi(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function hi(e,t){let n=String(e).split(`/`),r=String(t).split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;et.nav!==!1&&!e.includes(t.path))}function xi({activePath:e,hidden:t,onNavigate:n,theme:r,onToggleTheme:i}){let[a,o]=H(!1),s=W(null),c=()=>o(!1);return q(`header`,{className:`topbar`,children:[q(`div`,{className:`brand`,children:[q(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),q(`nav`,{className:`nav`,children:bi(t).map(t=>q(`a`,{className:`nav-item`,href:`#${t.path}`,"aria-current":t.path===e?`page`:void 0,"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0,onClick:e=>{t.soon?e.preventDefault():n(t.path)},children:[q(J,{name:t.icon}),q(`span`,{className:`nav-label`,children:t.label}),t.soon?q(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),q(`div`,{className:`topbar-end`,children:[q(`div`,{className:`topbar-search${a?` is-open`:``}`,children:[q(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:q(J,{name:`search`,size:15})}),q(`button`,{className:`icon-btn mobile-search-toggle`,type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":a?`true`:`false`,onClick:()=>{o(!0),s.current?.focus()},children:q(J,{name:`search`,size:15})}),q(`input`,{ref:s,type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),c(),e.target.blur();return}if(e.key!==`Enter`)return;let t=e.target.value.trim().toLowerCase(),r=gi.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),c())}})]}),q(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:q(J,{name:`help`})}),q(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:i,children:q(J,{name:r===`dark`?`moon`:`sun`})}),q(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}var Si=`chat-panel`;function Ci(){let[e,t]=H(!1),n=W(null),r=ye(()=>{t(!1),n.current?.focus()},[]);return U(()=>{if(!e)return;let t=e=>{e.defaultPrevented||e.key!==`Escape`||r()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),q(`div`,{className:`chat-dock${e?` is-open`:``}`,children:[q(`aside`,{className:`chat-drawer${e?` is-open`:``}`,id:Si,"aria-label":`Chat with Archie`,"aria-hidden":e?void 0:`true`,children:q(`div`,{className:`chat-drawer-panel`,children:q(di,{open:e})})}),q(`button`,{ref:n,type:`button`,className:`chat-fab`,"aria-label":e?`Close chat`:`Chat with Archie`,title:e?`Close chat`:`Chat with Archie`,"aria-expanded":e?`true`:`false`,"aria-controls":Si,onClick:()=>e?r():t(!0),children:[q(`span`,{className:`chat-fab-icon chat-fab-icon-open`,"aria-hidden":`true`,children:q(J,{name:`chat`,size:22})}),q(`span`,{className:`chat-fab-icon chat-fab-icon-close`,"aria-hidden":`true`,children:q(J,{name:`close`,size:22})})]})]})}function wi({label:e}){return q(`div`,{children:[q(`div`,{className:`page-head`,children:q(`div`,{children:q(`h1`,{className:`page-title`,children:e})})}),q(`div`,{className:`card`,children:q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:`${e} is not built yet`}),q(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function Ti({view:e,search:t,params:n}){return e(t,n)}var Ei=null,Di=null;function Oi(e){if(!Ei)return;let[t,n=``]=String(e).split(`?`,2),r=fi(gi,t),i=r?.route||gi[0],a=r?.params||{};ae(i.view?q(Ti,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):q(wi,{label:i.label}),Ei)}function ki(e){let[t]=String(e).split(`?`,2),n=fi(gi,t)?.route||gi[0];Ei?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),Di?.setActive(pi(n)),Oi(e)}function Ai(e){location.hash===`#${e}`?ki(e):location.hash=e}window.addEventListener(`hashchange`,()=>ki(location.hash.slice(1)||`/`));function ji(){let[e,t]=H(`/`),[n,r]=H(vi),[i,a]=H([]),o=ye(e=>{Ei=e,Di={setActive:t}},[]);return U(()=>{yi(n)},[n]),U(()=>{K.capabilities().then(e=>a(Le(e?.sections,gi))).catch(()=>{})},[]),U(()=>{Ge().then(()=>Oi(location.hash.slice(1)||`/`))},[]),q(S,{children:[q(`div`,{className:`shell`,children:[q(xi,{activePath:e,hidden:i,onNavigate:Ai,theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),q(`main`,{className:`main`,ref:o})]}),q(Ci,{})]})}yi(vi()),ae(q(ji,{}),document.getElementById(`app`)),ki(location.hash.slice(1)||`/`); \ No newline at end of file diff --git a/ui/src/base/api.jsx b/ui/src/base/api.jsx index 73f9c9299..b019c02df 100644 --- a/ui/src/base/api.jsx +++ b/ui/src/base/api.jsx @@ -5,6 +5,7 @@ // fetch() call appears here, and it fails if any method omits a header the // server requires. import { randomUUID } from "./uuid.jsx"; +import { streamStateFor } from "./stream-state.js"; // DEFAULT_TIMEOUT_MS bounds a request so a daemon that accepts the connection // but never answers cannot leave the UI in a loading state with no way back. @@ -186,7 +187,9 @@ export function subscribeEvents(onEvent, onStateChange) { export function subscribeLogs(onEntry, onStateChange) { const src = new EventSource("/api/logs/stream"); src.onopen = () => onStateChange?.("live"); - src.onerror = () => onStateChange?.("reconnecting"); + // onerror fires both for a drop the browser will retry and for one it has + // given up on; readyState is what tells them apart. + src.onerror = () => onStateChange?.(streamStateFor(src.readyState)); src.onmessage = (event) => { try { onEntry(JSON.parse(event.data)); } catch { /* malformed log frame */ } }; diff --git a/ui/src/base/stream-state.js b/ui/src/base/stream-state.js new file mode 100644 index 000000000..3c12ad9bb --- /dev/null +++ b/ui/src/base/stream-state.js @@ -0,0 +1,24 @@ +// What an EventSource error actually means. +// +// In base/ rather than logs/ because this is EventSource semantics, not a +// logs concept, and base must not import a feature folder. +// +// EventSource fires onerror both for a dropped connection it will retry and +// for one it has given up on. Reporting "reconnecting" for both left the logs +// page showing a permanent amber "reconnecting" pill against a stream that had +// stopped for good, next to text claiming live logs were still arriving +// (archie-core-c5bz). +// +// readyState is the difference: CONNECTING means a retry is scheduled, CLOSED +// means the browser will not try again. + +/** + * streamStateFor maps an EventSource readyState to the state the UI reports: + * "live", "reconnecting", or "unavailable". + */ +export function streamStateFor(readyState) { + // Numeric literals rather than EventSource.* so this is testable without one. + if (readyState === 0) return "reconnecting"; + if (readyState === 1) return "live"; + return "unavailable"; +} diff --git a/ui/src/css/tokens.css b/ui/src/css/tokens.css index 9b0372911..62969c8b6 100644 --- a/ui/src/css/tokens.css +++ b/ui/src/css/tokens.css @@ -52,10 +52,13 @@ --fg: #e8edf4; --fg-muted: #8b97a8; - --fg-subtle: #5d6878; + --fg-subtle: #7d8b9e; --accent: #4c8dff; - --accent-fg: #ffffff; + /* Near-black, not white: white on this blue is 3.2:1 and fails AA on the + active nav item and every primary button. The accent stays as-is because + it is also the link colour, where it reads correctly on the dark canvas. */ + --accent-fg: #0d1014; --accent-soft: rgba(76, 141, 255, 0.14); /* Status. Used for task state, gate results and trend direction alike, so @@ -101,7 +104,7 @@ --fg: #16202e; --fg-muted: #5a6779; - --fg-subtle: #8c99ab; + --fg-subtle: #636f82; --accent: #2563eb; --accent-fg: #ffffff; diff --git a/ui/src/dashboard/dashboard.css b/ui/src/dashboard/dashboard.css index 38a4d8026..3c2f82366 100644 --- a/ui/src/dashboard/dashboard.css +++ b/ui/src/dashboard/dashboard.css @@ -197,19 +197,14 @@ min-width: 0; } -/* The grid row stretches each column wrapper to the taller card's height by - default, but a block-level .card child doesn't fill that stretched height - on its own -- it shrinks to its own content, leaving the shorter card - (typically Gate pulse's empty state) sitting flush at the top with dead - space below it instead of matching its sibling. Flexing the wrapper and - growing the card to fill it makes both HEALTH cards the same height while - each card's own content still flows from the top. */ -.dash-top > div { - display: flex; -} - -.dash-top > div > .card { - flex: 1; +/* Each HEALTH card takes its own content height. Equalising them (the earlier + fix for this row) was right when both held a checklist, but once setup is + complete that card is a title and one line while Gate pulse carries a gauge + and four rows, so matching heights left a ~400px empty box taking a quarter + of the first screen. A ragged bottom edge is the lesser cost. + (archie-core-1786637500926-421-7c63bcd3) */ +.dash-top { + align-items: start; } /* No setup panel to show: the gate pulse spans the whole row instead of diff --git a/ui/src/logs/logs-empty.js b/ui/src/logs/logs-empty.js new file mode 100644 index 000000000..c8674e5b3 --- /dev/null +++ b/ui/src/logs/logs-empty.js @@ -0,0 +1,29 @@ +// What the logs list says when it has nothing to show. +// +// Three different situations produced one message, which is how the page ended +// up promising that "live daemon logs will appear here" while the stream that +// would deliver them had already given up (archie-core-c5bz). + +/** + * logsEmptyTitle names the situation: a dead stream, a deployment with no + * durable history, or filters that match nothing. + */ +export function logsEmptyTitle(durableUnavailable, streamState) { + if (streamState === "unavailable") return "Log stream unavailable"; + if (durableUnavailable) return "No logs yet"; + return "Nothing matches"; +} + +/** + * logsEmptyDetail says what to expect next, and never promises live logs from + * a stream that has stopped. + */ +export function logsEmptyDetail(durableUnavailable, streamState) { + if (streamState === "unavailable") { + return "The daemon is not serving /api/logs/stream. Reload once it is reachable."; + } + if (durableUnavailable) { + return "This deployment keeps no durable history. Live daemon logs appear here while the page is open."; + } + return "Try a wider level or clear the search."; +} diff --git a/ui/src/logs/logs.jsx b/ui/src/logs/logs.jsx index 9adc8cf10..6644b450e 100644 --- a/ui/src/logs/logs.jsx +++ b/ui/src/logs/logs.jsx @@ -4,6 +4,7 @@ import "./logs.css"; import { api, subscribeLogs } from "../base/api.jsx"; import { LOG_LEVELS, LogRow } from "../base/log-row.jsx"; import { Pill } from "../base/pill.jsx"; +import { logsEmptyTitle, logsEmptyDetail } from "./logs-empty.js"; function Empty({ title, detail }) { return ( @@ -48,7 +49,7 @@ function LogsApp() { }); setDurableUnavailable(!!res.disabled); - const newMeta = res.disabled ? "Durable history unavailable; live daemon logs continue." : res.truncated + const newMeta = res.disabled ? "Live only" : res.truncated ? `showing the most recent matches from ${res.file}` : res.file || ""; setMeta(newMeta); @@ -170,7 +171,10 @@ function LogsApp() {
{meta} - +
@@ -178,9 +182,9 @@ function LogsApp() { {meta === "Cannot read logs" ? ( ) : !entriesToRender.length ? ( - ) : ( entriesToRender.map(entry => ) diff --git a/ui/src/settings/settings.jsx b/ui/src/settings/settings.jsx index 6f92813df..b4aec1644 100644 --- a/ui/src/settings/settings.jsx +++ b/ui/src/settings/settings.jsx @@ -399,13 +399,23 @@ function SettingsApp() {
- {!versionMissing && ( - versionError ? ( -
- ) : versionData ? ( - - ) : null - )} + {/* A 501 is a deployment that did not wire update checking, which is a + legitimate state and a different thing from a broken one. Saying so + once here covers the absent UpdateActionsCard below too. */} + {versionMissing ? ( +
+
+
+

Update status

+

Not configured on this deployment, so there is nothing to check against.

+
+
+
+ ) : versionError ? ( +
+ ) : versionData ? ( + + ) : null}
{updateData && ( diff --git a/ui/src/workflows/workflow-rows.js b/ui/src/workflows/workflow-rows.js new file mode 100644 index 000000000..b9fc37de3 --- /dev/null +++ b/ui/src/workflows/workflow-rows.js @@ -0,0 +1,36 @@ +// Merging workflow definitions with their run statistics. +// +// The rows used to come from the definition list alone, so a workflow that had +// run but was no longer in that list (or a definitions fetch that came back +// empty while the stats fetch succeeded) produced no rows at all. The page then +// showed "No workflow runs yet" directly above the stage tables listing those +// very runs (archie-core-rcbf). +// +// A run is evidence the workflow exists. Anything with either a definition or +// statistics gets a row. + +/** + * workflowRows returns one row per known workflow, definitions first and in + * their declared order, then any workflow seen only in the statistics. + */ +export function workflowRows(workflows, definitions) { + const stats = new Map((workflows || []).map((w) => [w.workflow, w])); + const rows = []; + const claimed = new Set(); + + for (const definition of definitions || []) { + claimed.add(definition.id); + rows.push({ + ...definition, + ...(stats.get(definition.id) || { workflow: definition.id, runs: 0, merged: 0 }), + }); + } + + for (const workflow of workflows || []) { + if (claimed.has(workflow.workflow)) continue; + // No definition to describe it, so the id is the only name it has. + rows.push({ id: workflow.workflow, name: workflow.workflow, ...workflow }); + } + + return rows; +} diff --git a/ui/src/workflows/workflows.jsx b/ui/src/workflows/workflows.jsx index de907ad88..71c897cd9 100644 --- a/ui/src/workflows/workflows.jsx +++ b/ui/src/workflows/workflows.jsx @@ -2,6 +2,7 @@ import { h, Fragment } from "preact"; import { useState, useEffect } from "preact/hooks"; import "./workflows.css"; import { api } from "../base/api.jsx"; +import { workflowRows } from "./workflow-rows.js"; const WORKFLOW_LABELS = { bootstrap: "Bootstrap", @@ -162,11 +163,7 @@ function StartWork({ definitions }) { } function Workflows({ workflows, definitions }) { - const byID = new Map(workflows.map((workflow) => [workflow.workflow, workflow])); - const rows = definitions.map((definition) => ({ - ...definition, - ...(byID.get(definition.id) || { workflow: definition.id, runs: 0, merged: 0 }), - })); + const rows = workflowRows(workflows, definitions); if (!rows.length) { return ( diff --git a/ui/test/logs-empty.test.js b/ui/test/logs-empty.test.js new file mode 100644 index 000000000..9ab3af3ac --- /dev/null +++ b/ui/test/logs-empty.test.js @@ -0,0 +1,30 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { logsEmptyTitle, logsEmptyDetail } from "../src/logs/logs-empty.js"; + +test("filters that match nothing say so", () => { + assert.equal(logsEmptyTitle(false, "live"), "Nothing matches"); + assert.match(logsEmptyDetail(false, "live"), /wider level/); +}); + +test("a deployment without durable history explains live-only", () => { + assert.equal(logsEmptyTitle(true, "live"), "No logs yet"); + assert.match(logsEmptyDetail(true, "live"), /no durable history/i); +}); + +// The bug: a dead stream still promised that live logs were on their way. +test("a dead stream does not promise live logs", () => { + assert.equal(logsEmptyTitle(true, "unavailable"), "Log stream unavailable"); + const detail = logsEmptyDetail(true, "unavailable"); + assert.ok(!/appear here while the page is open/.test(detail), `still promising live logs: ${detail}`); + assert.match(detail, /not serving/); +}); + +test("a dead stream outranks the durable-history message either way", () => { + assert.equal(logsEmptyTitle(false, "unavailable"), "Log stream unavailable"); + assert.equal(logsEmptyTitle(true, "unavailable"), "Log stream unavailable"); +}); + +test("a reconnecting stream still reads as a filter miss, not a failure", () => { + assert.equal(logsEmptyTitle(false, "reconnecting"), "Nothing matches"); +}); diff --git a/ui/test/stream-state.test.js b/ui/test/stream-state.test.js new file mode 100644 index 000000000..e155a232a --- /dev/null +++ b/ui/test/stream-state.test.js @@ -0,0 +1,22 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { streamStateFor } from "../src/base/stream-state.js"; + +test("a retrying connection reports reconnecting", () => { + assert.equal(streamStateFor(0), "reconnecting"); +}); + +test("an open connection reports live", () => { + assert.equal(streamStateFor(1), "live"); +}); + +// The bug: a 503 closes the stream for good, and the page claimed it was +// reconnecting forever. +test("a closed connection reports unavailable, not reconnecting", () => { + assert.equal(streamStateFor(2), "unavailable"); +}); + +test("an unexpected readyState is treated as unavailable rather than live", () => { + assert.equal(streamStateFor(undefined), "unavailable"); + assert.equal(streamStateFor(99), "unavailable"); +}); diff --git a/ui/test/workflow-rows.test.js b/ui/test/workflow-rows.test.js new file mode 100644 index 000000000..93114397c --- /dev/null +++ b/ui/test/workflow-rows.test.js @@ -0,0 +1,44 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { workflowRows } from "../src/workflows/workflow-rows.js"; + +test("a defined workflow with no runs still gets a row at zero", () => { + const rows = workflowRows([], [{ id: "tdd", name: "TDD", enabled: true }]); + assert.equal(rows.length, 1); + assert.equal(rows[0].id, "tdd"); + assert.equal(rows[0].runs, 0); +}); + +test("statistics are merged onto their definition", () => { + const rows = workflowRows( + [{ workflow: "tdd", runs: 3, merged: 1 }], + [{ id: "tdd", name: "TDD", enabled: true }], + ); + assert.equal(rows.length, 1); + assert.equal(rows[0].name, "TDD"); + assert.equal(rows[0].runs, 3); + assert.equal(rows[0].merged, 1); +}); + +// The regression: stats arrived, definitions did not, and the page claimed +// there were no runs while the stage tables below listed them. +test("a workflow with runs but no definition still gets a row", () => { + const rows = workflowRows([{ workflow: "implement", runs: 6, merged: 3 }], []); + assert.equal(rows.length, 1); + assert.equal(rows[0].id, "implement"); + assert.equal(rows[0].runs, 6); +}); + +test("definitions keep their order and stats-only workflows follow", () => { + const rows = workflowRows( + [{ workflow: "ghost", runs: 2 }, { workflow: "tdd", runs: 1 }], + [{ id: "tdd" }, { id: "implement" }], + ); + assert.deepEqual(rows.map((r) => r.id), ["tdd", "implement", "ghost"]); +}); + +test("only genuinely empty input produces no rows", () => { + assert.deepEqual(workflowRows([], []), []); + assert.deepEqual(workflowRows(undefined, undefined), []); + assert.deepEqual(workflowRows(null, null), []); +});