From 30a9be4dc5084a763c712d3feaca683b546f9299 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 20 Sep 2026 16:00:29 +1000 Subject: [PATCH] fix(webui): make chat a FAB-opened panel and stop the topbar clipping Four P0 defects from the frontend audit, plus the one-line theme fix that was making every one of them look worse. Chat is a floating launcher and the panel it opens, not a route (archie-core-yuvg, archie-core-hesx). /chat rendered an empty page with a drawer over it, and that drawer hosted the full-page chat workspace: a page title, a conversations column, a four-control action row and a command-help column, all inside 440px. Measured at 1440x900, .chat-workspace was 174px wide holding 270px of content and the composer ran off the viewport. - The Chat nav entry, the /chat route and the topbar chat icon are gone; the launcher is the single way in. - The panel anchors to the launcher and opens leftward from it, sharing its bottom edge, so the button never moves. No scrim and no scroll lock: the page stays readable and clickable, which is the point of asking Archie about the page you are on. - Conversations became a switcher in a compact bar; personality, provider and model moved into a disclosure beside it; the empty state and composer dropped to panel type scale. - The launcher renders outside .shell because .shell's backdrop-filter is a containing block for fixed positioning, which otherwise pinned the button to the scrolling shell instead of the viewport. - Update-check, Dangerous actions and Reload Telegram left the panel; their api.* calls are untouched for the rehome to Configuration (archie-core-tf20). The topbar no longer clips its utility cluster (archie-core-mkb3). brand, nav and topbar-end were all flex:none with no wrap above 1220px, and .app sets overflow:hidden, so between 1221px and ~1582px the avatar, theme toggle and documentation button were cut off with no way to reach them. The nav is now the one region allowed to shrink, the search collapses to its icon below 1500px, and the nav wraps to its own row below 1270px where it stops fitting. Live activity clamps its detail column (archie-core-qo7f). An agent_finish payload rendered raw turned one row into six viewports and the dashboard into 7,481px. The cell shows the first meaningful line; the full text stays on the title. color-scheme is bound to the active theme (archie-core-nm0y), so scrollbars and native controls stop rendering light inside the dark UI. --- internal/gateway/dashboard_tools.go | 1 - ui/dist/assets/index.css | 2 +- ui/dist/assets/index.js | 15 +- ui/src/chat/chat.css | 150 ++++++++++-- ui/src/chat/chat.jsx | 353 ++++++---------------------- ui/src/css/base.css | 14 ++ ui/src/css/layout.css | 248 +++++++++++++------ ui/src/css/tokens.css | 4 + ui/src/dashboard/activity-detail.js | 30 +++ ui/src/dashboard/dashboard.css | 15 ++ ui/src/dashboard/dashboard.jsx | 6 +- ui/src/main.jsx | 160 +++++++------ ui/test/activity-detail.test.js | 43 ++++ ui/test/chat-app.test.js | 64 ++++- ui/test/chat-fab.test.js | 89 +++++++ 15 files changed, 729 insertions(+), 465 deletions(-) create mode 100644 ui/src/dashboard/activity-detail.js create mode 100644 ui/test/activity-detail.test.js create mode 100644 ui/test/chat-fab.test.js diff --git a/internal/gateway/dashboard_tools.go b/internal/gateway/dashboard_tools.go index 6bc4be768..2261272ad 100644 --- a/internal/gateway/dashboard_tools.go +++ b/internal/gateway/dashboard_tools.go @@ -28,7 +28,6 @@ type DashboardPage struct { // never points at a page it was not told about. var dashboardPages = []DashboardPage{ {Path: "/", Label: "Dashboard", Description: "The control room: what Archie is working on, what needs you, and token spend."}, - {Path: "/chat", Label: "Chat", Description: "Conversations with Archie and the web chat session tools."}, {Path: "/tasks", Label: "Tasks", Description: "Issues Archie has picked up and where they stand: the work queue."}, {Path: "/logs", Label: "Logs", Description: "The daemon log stream, filterable by level and component."}, {Path: "/captures", Label: "Event inspector", Description: "Captured inbound events for inspection."}, diff --git a/ui/dist/assets/index.css b/ui/dist/assets/index.css index 3b291d297..9349df1bc 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]{--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]{--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{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{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.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);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-drawer{inset:var(--sp-4);pointer-events:none;z-index:40;justify-content:flex-end;align-items:stretch;display:flex;position:fixed}.chat-drawer-panel{pointer-events:auto;z-index:1;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:min(430px,100%);height:100%;box-shadow:var(--shadow-md);opacity:0;transition:opacity var(--transition), transform var(--transition);grid-template-rows:auto minmax(0,1fr);display:grid;position:relative;overflow:hidden;transform:translate(1.2rem)}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none}.chat-drawer.is-open .chat-drawer-panel{opacity:1;transform:none}.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}.chat-scrim{background:color-mix(in srgb, var(--bg) 40%, transparent);opacity:0;pointer-events:none;transition:opacity var(--transition);position:fixed;inset:0}.chat-drawer.is-open .chat-scrim{opacity:1;pointer-events:auto}body.chat-open{overflow:hidden}@media (width<=1220px) 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}.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)}.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)}.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}}.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-page-content{flex-direction:column;flex:auto;min-height:0;display:flex;overflow:hidden}.chat-topbar{flex:none;justify-content:space-between;align-items:center;gap:1rem;margin-bottom:1rem;display:flex}.chat-kicker,.chat-workspace-label{color:var(--fg-muted);letter-spacing:.12em;font-size:.68rem;font-weight:700}.chat-topbar-actions{align-items:center;gap:.55rem;display:flex}.chat-topbar-actions .chat-select{min-width:0;max-width:14rem}.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-layout{flex:auto;grid-template-columns:242px minmax(0,1fr);gap:.75rem;min-height:0;display:grid;overflow:hidden}.chat-sidebar,.chat-workspace{background:var(--surface);border:1px solid var(--border);border-radius:1rem}.chat-sidebar{padding:.8rem;overflow-y:auto}.chat-sidebar-head,.chat-toolbar,.chat-compose-actions{justify-content:space-between;align-items:center;gap:.6rem;display:flex}.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-workspace{grid-template-rows:auto minmax(0,1fr) auto;min-width:0;display:grid;overflow:hidden}.chat-workspace-head{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;padding:.85rem 1.1rem;display:flex}.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{align-content:start;gap:1rem;padding:1.25rem;display:grid;overflow:auto}.chat-empty-state{text-align:center;place-self:center;width:min(100%,40rem);padding:3rem 1rem}.chat-empty-mark{border:1px solid var(--border-strong);width:2.6rem;height:2.6rem;color:var(--accent);border-radius:.8rem;place-items:center;margin:0 auto 1rem;font-weight:700;display:grid}.chat-empty-state h2{letter-spacing:-.04em;margin:0;font-size:clamp(1.5rem,3vw,2.25rem)}.chat-empty-state p{color:var(--fg-muted);margin:.6rem 0 1.4rem}.chat-prompt-grid{flex-wrap:wrap;justify-content:center;gap:.5rem;display:flex}.chat-prompt{border:1px solid var(--border);background:var(--surface-hover);color:var(--fg-muted);cursor:pointer;border-radius:999px;padding:.55rem .75rem}.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{border-top:1px solid var(--border);padding:.85rem 1rem 1rem}.chat-composer-shell{background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem .55rem;position:relative}.chat-composer{resize:vertical;box-sizing:border-box;width:100%;min-height:3.3rem;color:var(--fg);font:inherit;background:0 0;border:0;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{margin-top:.55rem}.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<=760px){.chat-topbar,.chat-topbar-actions{flex-direction:column;align-items:flex-start}.chat-layout{grid-template-columns:1fr}.chat-sidebar{max-height:14rem;overflow:auto}}@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:#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);border-radius:var(--radius-lg);width:100%;height:100%;box-shadow:var(--shadow-md);opacity:0;transform-origin:100% 100%;transform:scale(.92) translateX(var(--sp-3));transition:opacity var(--transition), transform var(--transition);grid-template-rows:auto minmax(0,1fr);display:grid;overflow:hidden}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none;visibility:hidden}.chat-drawer.is-open .chat-drawer-panel{opacity:1;visibility:visible;transform:none}.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:var(--fab-inset);width:auto;height:min(78vh, calc(100vh - var(--fab-inset) * 2));position:fixed}.chat-drawer-panel{transform-origin:bottom;transform:scale(.98) translateY(var(--sp-3))}.chat-dock.is-open .chat-fab{opacity:0;pointer-events:none}}@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}}.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 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{background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem .55rem;position:relative}.chat-composer{resize:vertical;box-sizing:border-box;width:100%;min-height:3.3rem;color:var(--fg);font:inherit;background:0 0;border:0;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{margin-top:var(--sp-2);row-gap:var(--sp-2);flex-wrap:wrap;justify-content:flex-end}.chat-compose-actions .chat-hint{font-size:var(--text-xs);color:var(--fg-muted);flex:1 0 100%}.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 415a64524..75a6ceb4f 100644 --- a/ui/dist/assets/index.js +++ b/ui/dist/assets/index.js @@ -1,9 +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 z(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 W(e){return oe=1,he(Ce,e)}function he(e,t,n){var r=me(re++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ce(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=H,!H.__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};H.__f=!0;var a=H.shouldComponentUpdate,o=H.componentWillUpdate;H.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)},H.shouldComponentUpdate=i}return r.__N||r.__}function G(e,t){var n=me(re++,3);!U.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,H.__H.__h.push(n))}function K(e){return oe=5,ge(function(){return{current:e}},[])}function ge(e,t){var n=me(re++,7);return Se(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _e(e,t){return oe=8,ge(function(){return e},t)}function ve(){for(var e;e=se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(q),t.__h.some(xe),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){H=null,ce&&ce(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),pe&&pe(e,t)},U.__r=function(e){le&&le(e),re=0;var t=(H=e.__c).__H;t&&(ie===H?(t.__h=[],H.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(q),t.__h.some(xe),t.__h=[],re=0)),ie=H},U.diffed=function(e){ue&&ue(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(se.push(t)!==1&&ae===U.requestAnimationFrame||((ae=U.requestAnimationFrame)||be)(ve)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ie=H=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(q),e.__h=e.__h.filter(function(e){return!e.__||xe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),de&&de(e,t)},U.unmount=function(e){fe&&fe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{q(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var ye=typeof requestAnimationFrame==`function`;function be(e){var t,n=function(){clearTimeout(r),ye&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ye&&(t=requestAnimationFrame(n))}function q(e){var t=H,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),H=t}function xe(e){var t=H;e.__c=e.__(),H=t}function Se(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ce(e,t){return typeof t==`function`?t(e):t}function we(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 Te=15e3;function Ee(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 De(e){try{let t=(await e.text()).trim();if(t)return t.split(` -`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Oe=class extends Error{constructor(e,t){super(e),this.status=t}};function ke(e){let t=e instanceof Oe?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 Ae(e,t){let n=await fetch(e,t);if(!n.ok)throw new Oe(await De(n),n.status);return n}async function J(e,{method:t=`GET`,body:n,timeoutMs:r=Te,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 Ae(e,o);return i?s.json():void 0}var Y={summary:()=>J(`/api/summary`),tasks:()=>J(`/api/tasks`),taskMeta:()=>J(`/api/task-meta`),task:e=>J(`/api/tasks/${e}`),taskAttempts:e=>J(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>J(`/api/tasks/${e}/changes`+Ee(t)),taskDebug:(e,t)=>J(`/api/tasks/${e}/debug`+Ee(t)),taskAction:(e,t)=>J(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>J(`/api/setup`),capabilities:()=>J(`/api/capabilities`),workflows:()=>J(`/api/workflows`),workRequest:e=>J(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>J(`/api/skills`),channels:()=>J(`/api/channels`),curators:()=>J(`/api/curators`),channelReload:e=>J(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>J(`/api/config`),version:()=>J(`/api/version`),configUpdate:e=>J(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>J(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>J(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>J(`/api/logs`+Ee(e)),taskLogs:(e,t)=>J(`/api/tasks/${e}/logs`+Ee(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>J(`/api/captures`+Ee({limit:e})),mappings:()=>J(`/api/mappings`),mappingCreate:e=>J(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>J(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>J(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>J(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>J(`/api/bindings`),bindingCreate:e=>J(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>J(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>J(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>J(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>J(`/api/chat/sessions`),chatMessages:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>J(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>J(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:we(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>J(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>J(`/api/chat/update`),chatUpdateDefer:e=>J(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>J(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>J(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Ae(`/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 je(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 Me(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 Ne(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Pe=[{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`}],Fe=[{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`}],Ie=[...Pe],Le=[...Fe],Re=new Map(Ie.map(e=>[e.id,e])),ze=new Map(Le.map(e=>[e.id,e]));function Be(){Re=new Map(Ie.map(e=>[e.id,e])),ze=new Map(Le.map(e=>[e.id,e]))}async function Ve(){try{let e=await Y.taskMeta();Array.isArray(e?.statuses)&&(Ie=e.statuses),Array.isArray(e?.actions)&&(Le=e.actions),Be()}catch{}}function He(e){return Re.get(e)?.label||e||`Unknown`}function Ue(e){return Re.get(e)?.kind||`idle`}function We(){return Ie.map(e=>e.id)}function Ge(){return new Set(Ie.filter(e=>e.needs_you).map(e=>e.id))}function Ke(e){return ze.get(e)||null}var qe=0;Array.isArray;function X(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:--qe,__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 Je={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,help:``};function Z({name:e,size:t=18,className:n=``}){return X(`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:Je[e]||Je.dashboard}})}function Ye(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 Xe(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function Ze({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 X(`div`,{className:`card stat`,children:[X(`div`,{className:`stat-head`,children:[X(`span`,{className:`stat-label`,children:e}),s?X(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[X(Z,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),X(`div`,{className:`stat-value`,children:[t,n?X(`span`,{className:`stat-unit`,children:n}):null]}),i?X(`div`,{className:`stat-compare`,children:i}):null,a.length>1?X(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 X(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:X(`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 X(`div`,{className:`gauge-wrap`,children:[X(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[X(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),X(`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`})]}),X(`div`,{className:`gauge-center`,children:[X(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),X(`div`,{className:`gauge-label`,children:t})]})]})}function et({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return X(`div`,{children:[X(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>X(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),X(`div`,{className:`segbar-legend`,children:e.map(e=>X(`span`,{className:`segbar-key`,children:[X(`span`,{className:`segbar-dot segbar-${e.kind||`idle`}`}),e.label]},e.label))})]})}function Q({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}var tt=`archie.setup-complete.dismissed.v1`;function nt(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?.(tt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function rt(e=globalThis.localStorage){e?.setItem?.(tt,`1`)}var it=new Set([`waiting_human`,`parked`]);function at(e=[]){let t=e.filter(e=>it.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 ot({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function st(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 ct(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function lt(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 ut(){let[e,t]=W([]),[n,r]=W(`connecting`),[i,a]=W(`idle`),[o,s]=W(new Map),[c,l]=W(null),[u,d]=W(null),[f,p]=W(null),[m,h]=W(null),[g,_]=W(null),[,v]=W(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([Y.summary(),Y.setup().catch(()=>null),Y.workflows().catch(()=>null),Y.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))}};G(()=>(y(),je(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{rt(),v(e=>!e)},x=u?.operator?`${ct()}, ${u.operator}`:ct(),C=null;if(g)C=X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(Z,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=at(m),t=e.attention.count,n=e.running.count;C=X(S,{children:[t>0&&X(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[X(Z,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&X(`a`,{className:`btn`,href:e.running.href,children:[X(Z,{name:`workflows`,size:15}),` `,n,` running`]}),X(`a`,{className:`btn`,href:`#/logs`,children:[X(Z,{name:`logs`,size:15}),` Logs`]}),X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(Z,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=X(`div`,{className:`card`,children:X(ot,{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=X(S,{children:[X(Ze,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),X(Ze,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(Ze,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),X(Ze,{label:`Tokens used`,value:Xe(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:lt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=nt(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=X(`div`,{className:`card setup`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Finish setting up`}),X(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),X(`span`,{className:`setup-pct`,children:[t,`%`]})]}),X(`div`,{className:`setup-bar`,children:X(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),X(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>X(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[X(`span`,{className:`setup-check`,children:e.done?X(Z,{name:`check`,size:12}):``}),X(`div`,{children:[X(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&X(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=X(`div`,{className:`card setup setup-done`,children:X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Setup complete`}),X(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),X(`div`,{className:`setup-complete-actions`,children:[X(`span`,{className:`setup-pct`,children:X(Z,{name:`check`,size:16})}),X(`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=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`h2`,{className:`card-title`,children:`Gate pulse`})}),X(ot,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;O=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Gate pulse`}),X(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),X($e,{value:i,label:`pass rate`}),X(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>X(`li`,{className:`pulse-item`,children:[X(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),X(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&&X(`li`,{className:`pulse-item`,children:[X(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),X(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=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`h2`,{className:`card-title`,children:`Token outlook`})}),X(ot,{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=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Token outlook`}),X(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),X(`div`,{className:`forecast-value`,children:Xe(r)}),X(`div`,{className:`forecast-note`,children:[`Based on `,Xe(Math.round(n)),` per day over `,e.length,` days`]}),X(et,{segments:[{label:`Last 7 days (${Xe(i)})`,value:i,kind:`info`},{label:`Earlier (${Xe(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return X(S,{children:[X(`div`,{className:`hero`,children:[X(`div`,{children:[X(`h1`,{className:`hero-title`,children:x}),X(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),X(`div`,{className:`hero-actions`,children:X(`div`,{className:`hero-actions-inner`,children:C})})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:X(`h2`,{className:`dash-section-title`,children:`Health`})}),X(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[X(`div`,{children:T}),X(`div`,{children:O})]})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:[X(`h2`,{className:`dash-section-title`,children:`Throughput`}),X(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),X(`div`,{className:`grid grid-4`,children:w})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:X(`h2`,{className:`dash-section-title`,children:`Right now`})}),X(`div`,{className:`dash-split`,children:[X(`div`,{children:k}),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Live activity`}),X(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),X(Q,{text:n,kind:i})]}),X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Event`}),X(`th`,{children:`Task`}),X(`th`,{children:`Detail`}),X(`th`,{children:`When`})]})}),X(`tbody`,{children:e.length?e.map((e,t)=>{let n=st(e,o),r=n>0,i=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return X(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?i:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())}:void 0,children:[X(`td`,{className:`strong`,children:X(`span`,{children:e.kind||e.type||`event`})}),X(`td`,{className:`mono`,children:r?`#${n}`:`—`}),X(`td`,{children:e.detail||e.message||``}),X(`td`,{children:Ye(e.at||Date.now())})]},t)}):X(`tr`,{children:X(`td`,{colSpan:`4`,children:X(ot,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function dt(){return X(ut,{})}function ft(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 pt(){return new Set([`needs_you`,...We()])}function mt(e){let t=e?.get?.(`status`)||``;return pt().has(t)?t:``}function ht(e,t){return t?t===`needs_you`?Ge().has(e.status):e.status===t:!0}function gt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function _t(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 vt(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function yt(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=_t(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=vt(t.iterations),i=vt(t.tokens),a=Number(t.cached_tokens)||0,o=vt((Number(t.prompt_tokens)||0)-a),s=vt(t.completion_tokens),c=vt(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:gt(e.kind||e.type),detail:e.detail||``}}var bt=[{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 xt(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function St({entry:e}){let t=e.fields||{};return X(`div`,{className:`log-row log-${xt(e.level)}`,children:[X(`span`,{className:`log-time mono`,children:wt(e.time)}),X(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),X(`span`,{className:`log-body`,children:[X(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>X(`span`,{className:`log-field`,children:[X(`span`,{className:`log-field-key`,children:e}),String(Ct(t))]},e))]})]})}function Ct(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function wt(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Tt(e,t){return`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`)}var Et={level:``,stage:``};function Dt(e,t,n=Et){let r=n||Et;return[e,Number(t)||0,r.level||``,r.stage||``].join(`|`)}function Ot({filters:e,onFilterChange:t,stages:n,attempt:r}){let i=n=>t?.({...e,...n}),a=Number(r)||0;return X(`div`,{className:`log-filters task-log-filters`,children:[X(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?X(S,{children:[X(`label`,{className:`task-log-filter`,children:[X(`span`,{className:`task-log-filter-label`,children:`Level`}),X(`select`,{className:`task-filter`,value:e.level,"aria-label":`Filter log entries by level`,onChange:e=>i({level:e.target.value}),children:bt.map(e=>X(`option`,{value:e.value,children:e.label},e.value))})]}),X(`label`,{className:`task-log-filter`,children:[X(`span`,{className:`task-log-filter-label`,children:`Stage`}),X(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[X(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>X(`option`,{value:e,children:e},e))]})]}),e.stage?X(`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?X(`p`,{className:`task-log-filter-note`,children:`This attempt recorded no stage names, so the stage filter has nothing to match.`}):null]}):null]})}function kt({text:e}){return X(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:e})}function At({state:e,onRetry:t,taskId:n,attempt:r,filters:i=Et,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=X(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=X(`div`,{className:`task-log-error`,children:[X(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),X(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),X(`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=X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),X(`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:Tt(n,s||null),i=r?X(`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=X(S,{children:[X(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>X(St,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`Nothing recorded`}),X(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return X(S,{children:[X(Ot,{filters:i,onFilterChange:a,stages:o,attempt:s}),X(kt,{text:c}),l]})}function jt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function Mt(){return jt()?`auto`:`smooth`}function Nt({kind:e,message:t}){return e===`session-expired`?X(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,X(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?X(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):X(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function Pt({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Ft({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=K(r);return a.current=r,G(()=>{n===void 0&&a.current()},[n]),X(At,{state:n,taskId:e,attempt:t,onRetry:i})}function It({query:e}){let[t,n]=W(null),[r,i]=W(null),[a,o]=W(()=>mt(e)),[s,c]=W(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=W(u),[p,m]=W(u!==null),[h,g]=W(new Map),[_,v]=W(new Map),y=K(new Set),[b,x]=W(new Set),[C,w]=W(new Map),[T,E]=W(new Set),D=async()=>{try{i(null);let e=await Y.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}};G(()=>{D()},[]);let O=async e=>{try{let t=await Y.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=Dt(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 Y.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 Y.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,ke(t)))}};G(()=>{p&&d&&t&&(m(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${d}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`center`,behavior:Mt()}))}))},[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 X(`div`,{className:`grid grid-4 task-summary`,children:[X(Ze,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),X(Ze,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),X(Ze,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(Ze,{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?Nt(t):null,r=T.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=Ke(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 X(`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?`—`:X(`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`?X(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):X(`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?X(`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:X(`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=Dt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return X(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:X(`td`,{colSpan:8,children:[X(`div`,{className:`task-detail-actions`,children:[X(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&X(`div`,{className:`task-decision`,children:[X(`div`,{className:`task-decision-title`,children:`Decision required`}),X(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&X(`div`,{className:`task-decision`,children:[X(`div`,{className:`task-decision-title`,children:`Park reason`}),X(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?X(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?X(`div`,{className:`task-timeline-error`,children:[X(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),X(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),X(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?X(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=yt(e);return X(`li`,{className:`task-timeline-entry`,children:[X(`span`,{className:`task-timeline-dot`}),X(`div`,{children:[X(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&X(`div`,{className:`task-timeline-detail`,children:n.detail}),X(`div`,{className:`task-timeline-when`,children:Ye(e.at)})]})]},t)})}):X(Pt,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),X(`div`,{className:`task-logs-section`,children:[X(`div`,{className:`task-decision-title`,children:[`Attempt log`,X(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&X(Ft,{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 X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Tasks`}),X(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?X(`div`,{className:`grid grid-4 task-summary`,children:X(`div`,{className:`card`,children:X(Pt,{title:`Cannot reach archied`,detail:r})})}):P(),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`All tasks`}),X(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),X(`div`,{className:`task-filters`,children:[X(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),X(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[X(`option`,{value:``,children:`All statuses`}),X(`option`,{value:`needs_you`,children:`Needs you`}),We().map(e=>X(`option`,{value:e,children:He(e)},e))]})]})]}),X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>X(`th`,{children:e},e))})}),X(`tbody`,{children:(()=>{if(r)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(Pt,{title:`Cannot reach archied`,detail:r})})});if(!t)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(Pt,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>ht(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 X(S,{children:[X(`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),...ft(e,t),children:[X(`td`,{className:`mono`,"data-label":`Repository`,children:[X(`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}`]}),X(`td`,{className:`mono`,"data-label":`Issue`,children:ee(e)??`#${e.issue_number}`}),X(`td`,{className:`strong`,"data-label":`Title`,children:X(`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)`})}),X(`td`,{"data-label":`Status`,children:X(Q,{text:He(e.status),kind:Ue(e.status)})}),X(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),X(`td`,{"data-label":`Stage`,children:e.stage||`—`}),X(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${Ye(e.created_at)}`:``,children:Ye(e.updated_at)}),X(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&R(e)]},e.id)}):X(`tr`,{children:X(`td`,{colSpan:8,children:X(Pt,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function Lt(e){return X(It,{query:e})}function Rt(e,t){return`${e}-tab-${t}`}function zt(e,t){return`${e}-panel-${t}`}function Bt({tabs:e,active:t,onSelect:n,prefix:r=`run`,label:i=`Run detail views`}){let a=K([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return X(`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 X(`button`,{ref:e=>{a.current[i]=e},id:Rt(r,e.id),className:`tab${o?` is-selected`:``}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":zt(r,e.id),tabIndex:o?0:-1,onClick:()=>n?.(e.id),children:e.label},e.id)})})}var Vt={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 Ht(e){return Vt[e]||{label:e||`unknown`,kind:`idle`}}function Ut(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>yt(e))}function Wt(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 Gt({stage:e,attemptNumber:t,events:n}){let r=Ht(e.status),i=_t(e.duration_ms),a=Ut(n,t,e.name);return X(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[X(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),X(`div`,{className:`run-stage-body`,children:[X(`div`,{className:`run-stage-head`,children:[X(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),X(Q,{text:r.label,kind:r.kind}),X(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?X(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>X(`div`,{className:`run-agent-report`,children:[X(`span`,{className:`run-agent-report-label`,children:`Agent's own report, not verified by archie: `}),[e.title,e.detail].filter(Boolean).join(` · `)]},t))]})]})}function Kt({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function qt({count:e}){let t=Number(e)||0;return t?X(`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 Jt({state:e,attemptNumber:t,events:n,onRetry:r}){if(e===void 0)return X(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return X(`div`,{className:`run-error`,children:[X(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),X(`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?X(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return X(S,{children:[X(Kt,{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.`}),X(qt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return X(S,{children:[X(Kt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),X(qt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Ht(a.status);return X(`div`,{className:`run-rail`,children:[X(`div`,{className:`run-rail-head`,children:[X(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),X(Q,{text:s.label,kind:s.kind}),X(`span`,{className:`run-rail-when`,children:Wt(a.started_at)})]}),o.length?X(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>X(Gt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):X(Kt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),X(`p`,{className:`run-rail-legend`,children:[X(`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.`]}),X(qt,{count:e?.unattributed_events})]})}var Yt={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,typechange:`Type changed`};function Xt(e){return Yt[e]||e||`unknown`}function Zt(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 Qt(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 $t({capture:e}){let t=e.files||[],n=Number(e.totals?.files)||t.length;return t.length?X(S,{children:[X(`table`,{className:`table run-changes-table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Path`}),X(`th`,{children:`Change`}),X(`th`,{className:`run-changes-count`,children:`Added`}),X(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),X(`tbody`,{children:t.map((e,t)=>X(`tr`,{children:[X(`td`,{className:`mono run-changes-path`,children:[e.old_path?X(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),X(`td`,{children:[Xt(e.status),e.binary?X(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),X(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),X(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?X(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):X(`div`,{className:`run-changes-empty`,children:[`This capture recorded no file entries`,n?`, though its totals cover ${n} file${n===1?``:`s`}`:``,`.`]})}function en({capture:e,task:t}){let n=Zt(e,t),r=e.pr_number;return X(`section`,{className:`run-capture`,children:[X(`div`,{className:`run-capture-head`,children:[X(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),X(`span`,{className:`run-capture-at`,children:e.captured_at?Ye(e.captured_at):``})]}),X(`div`,{className:`run-capture-meta`,children:[X(`span`,{className:`mono`,children:n.repo?X(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?X(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?X(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?X(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):X(`span`,{className:`mono`,children:[`PR #`,r]}):null,X(`span`,{className:`run-capture-totals`,children:Qt(e.totals)})]}),X($t,{capture:e})]})}function tn({state:e,task:t,onRetry:n}){if(e===void 0)return X(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return X(`div`,{className:`run-error`,children:[X(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),X(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?X(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),X(`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?X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),X(`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".`})]}):X(`div`,{className:`run-changes`,children:r.map((e,n)=>X(en,{capture:e,task:t},`${e.captured_at||``}:${n}`))})}function nn(e,t){return(e||[]).find(e=>e&&e.kind===`config_captured`&&Number(e.attempt)===Number(t))||null}function rn({events:e,attempt:t,onRetry:n}){if(e===void 0)return X(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return X(`div`,{className:`run-error`,children:[X(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),X(`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?X(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=nn(e,t);if(!r)return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`Not captured for this run`}),X(`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 X(`div`,{className:`run-config`,children:[X(`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.`]}),X(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?X(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):X(S,{children:[X(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),X(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function an({state:e,attempt:t,onRetry:n}){return e===void 0?X(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?X(`div`,{className:`run-error`,children:[X(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),X(`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?X(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):X(`div`,{className:`run-debug`,children:[X(`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.`]}),X(`pre`,{className:`run-json`,children:JSON.stringify(e,null,2)})]})}var on=[{id:`stages`,label:`Stages`},{id:`log`,label:`Log`},{id:`changes`,label:`Changed files`},{id:`config`,label:`Configuration`},{id:`debug`,label:`Debug`}],sn=`run`,cn=new Set(on.map(e=>e.id));function ln(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 un(e){let t=e?.get?.(`tab`)||``;return cn.has(t)?t:on[0].id}function dn(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 fn(e,t,n){let r=new URLSearchParams;return r.set(`tab`,t||on[0].id),n&&r.set(`attempt`,String(n)),`#/tasks/${e}?${r.toString()}`}function pn(e,t,n){try{window.history.replaceState(null,``,`${location.pathname}${location.search}${fn(e,t,n)}`)}catch{}}function mn(e,t){return`${e}|${Number(t)||0}`}function hn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function gn({id:e}){return X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Task not found`}),X(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),X(`div`,{className:`page-actions`,children:X(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),X(`div`,{className:`card`,children:X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),X(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function _n({raw:e}){return X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Not a task id`}),X(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),X(`div`,{className:`page-actions`,children:X(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),X(`div`,{className:`card`,children:X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),X(`div`,{children:`A task id is a positive whole number. Nothing was requested.`})]})})]})}function vn({attempts:e,selected:t,onSelect:n}){let r=e?.attempts||[];return r.length?X(`div`,{className:`run-attempts`,role:`group`,"aria-label":`Attempts of this task`,children:r.map(e=>{let r=Ht(e.status),i=Number(e.attempt)===Number(t);return X(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[X(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),X(Q,{text:r.label,kind:r.kind}),X(`span`,{className:`run-attempt-meta`,children:[(e.stages||[]).length,` stage`,(e.stages||[]).length===1?``:`s`]})]},e.attempt)})}):null}function yn({id:e,query:t}){let[n,r]=W(()=>un(t)),[i,a]=W(()=>dn(t)),[o,s]=W(void 0),[c,l]=W(void 0),[u,d]=W(!1),[f,p]=W(void 0),[m,h]=W(Et),[g,_]=W(new Map),[v,y]=W(new Map),[b,x]=W(new Map),[S,C]=W(!1),[w,T]=W(null),[E,D]=W(0),O=K(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),Y.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),Y.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),Y.task(e).then(e=>p(e||[])).catch(()=>p(null))},ee=(t,n)=>P(Dt(e,t,m),()=>Y.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),R=(t,n)=>P(mn(e,t),()=>Y.taskChanges(e,{attempt:t}),y,n),z=(t,n)=>P(mn(e,t),()=>Y.taskDebug(e,{attempt:t}),x,n),te=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};G(()=>{F(),I(),L()},[]),G(()=>{j!=null&&(n===`log`?ee(j):n===`changes`?R(j):n===`debug`&&z(j))},[n,j,m,E]),G(()=>{pn(e,n,j)},[e,n,j]);let B=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 Y.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(ke(e))}finally{C(!1)}}};if(u)return X(gn,{id:e});let V=j==null?null:Dt(e,j,m),ne=mn(e,j),re=mn(e,j),H=()=>{if(n===`stages`)return X(Jt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return X(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return X(`div`,{className:`run-error`,children:[X(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),X(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),X(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return X(hn,{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 X(At,{state:V&&g.has(V)?g.get(V):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>ee(j,{force:!0})});case`changes`:return X(tn,{state:v.has(ne)?v.get(ne):void 0,task:k,onRetry:()=>R(j,{force:!0})});case`config`:return X(rn,{events:f,attempt:j,onRetry:L});case`debug`:return X(an,{state:b.has(re)?b.get(re):void 0,attempt:j,onRetry:()=>z(j,{force:!0})});default:return X(Jt,{state:c,attemptNumber:j,events:f,onRetry:I})}},ie=Ke(`retry`),ae=!!(ie&&(k?.actions||[]).includes(`retry`));return X(`div`,{className:`run-page`,children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),X(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),X(`div`,{className:`page-actions`,children:[X(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),X(`button`,{className:`btn`,type:`button`,onClick:te,children:`Refresh`})]})]}),X(`div`,{className:`run-meta`,children:[X(`span`,{className:`run-meta-item`,children:[X(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?X(`span`,{className:`run-meta-muted`,children:`loading…`}):k?X(Q,{text:He(k.status),kind:Ue(k.status)}):X(`span`,{className:`run-meta-muted`,children:`not read`})]}),X(`span`,{className:`run-meta-item`,children:[X(`span`,{className:`run-meta-label`,children:`Attempt`}),X(`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?X(`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?X(`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?X(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?X(`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?X(`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,X(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[X(`button`,{className:`btn ${ie?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!ae||S,title:`Retry this task as a new run`,onClick:B,children:S?`Starting…`:`Start a new run`}),X(`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.`}),!ae&&o!==void 0?X(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${He(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?X(`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]}),X(vn,{attempts:c,selected:j,onSelect:e=>a(e)}),X(`div`,{className:`card run-card`,children:[X(Bt,{tabs:on,active:n,onSelect:r,prefix:sn}),X(`div`,{className:`run-panel`,role:`tabpanel`,id:zt(sn,n),"aria-labelledby":Rt(sn,n),tabIndex:0,children:H()})]})]})}function bn(e,t){let n=t?.id,r=ln(n);return r===null?X(_n,{raw:n??``}):X(yn,{id:r,query:e},r)}function xn({title:e,detail:t}){return X(`div`,{class:`empty`,children:[X(`div`,{class:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Sn(e){return X(Cn,{query:e})}function Cn(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W(null),o=async()=>{try{let e=await Y.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};G(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=ge(()=>e.filter(e=>s(e,n)),[e,n]);return X(`div`,{children:[X(`div`,{class:`page-head`,children:[X(`div`,{children:[X(`h1`,{class:`page-title`,children:`Skills`}),X(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),X(`div`,{class:`page-actions`,children:X(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:[X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Catalogue`}),X(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),X(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),X(`div`,{class:`grid grid-2`,children:i?X(xn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>X(`div`,{class:`card skill-card`,children:[X(`div`,{class:`card-head`,children:[X(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&X(Q,{text:e.workflow,kind:`info`})]}),X(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),X(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):X(xn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):X(xn,{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 wn={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function Tn(e){return wn[e]?wn[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function En(e,t){return t?Math.round(e/t*100):0}function Dn(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 On({title:e,detail:t}){return X(`div`,{class:`empty`,children:[X(`div`,{class:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function kn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return X(`div`,{class:`wf-bar`,children:X(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function An(e){return X(jn,{query:e})}function jn(){let[e,t]=W([]),[n,r]=W([]),[i,a]=W([]),[o,s]=W(null),c=async()=>{try{let e=await Y.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return G(()=>{c()},[]),X(`div`,{children:[X(`div`,{class:`page-head`,children:[X(`div`,{children:[X(`h1`,{class:`page-title`,children:`Workflows`}),X(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),X(`div`,{class:`page-actions`,children:X(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),X(Mn,{definitions:e}),o?X(`div`,{class:`card`,children:X(On,{title:`Cannot reach archied`,detail:o})}):X(S,{children:[X(Nn,{workflows:n,definitions:e}),X(Pn,{stages:i})]})]})}function Mn({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=W(``),[i,a]=W(``),[o,s]=W(t),[c,l]=W(``),[u,d]=W(``),[f,p]=W(!1),[m,h]=W(``);return G(()=>{!o&&t&&s(t)},[t,o]),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Start work`}),X(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),X(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await Y.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:[X(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),X(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),X(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>X(`option`,{value:e.id,children:Tn(e.name||e.id)},e.id))}),X(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),X(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),X(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&X(`p`,{class:`card-sub`,children:m})]})]})}function Nn({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?X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Per workflow`}),X(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Origin`}),X(`th`,{children:`Runs`}),X(`th`,{children:`Success rate`}),X(`th`,{children:`Avg tokens`}),X(`th`,{children:`Avg steps`})]})}),X(`tbody`,{children:r.map(e=>{let t=En(e.merged,e.runs);return X(`tr`,{children:[X(`td`,{class:`strong`,children:Tn(e.workflow)}),X(`td`,{class:`mono`,children:e.origin||`registry`}),X(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:[t,`%`,X(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),X(kn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),X(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),X(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:X(`h2`,{class:`card-title`,children:`Per workflow`})})}),X(On,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function Pn({stages:e}){if(!e.length)return X(`div`,{class:`card wf-stage-card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:X(`h2`,{class:`card-title`,children:`Per stage`})})}),X(On,{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 X(`div`,{class:`grid grid-2 wf-stage-card`,children:[X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Slowest stages`}),X(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Stage`}),X(`th`,{children:`Runs`}),X(`th`,{children:`Avg duration`})]})}),X(`tbody`,{children:n.map((e,n)=>X(`tr`,{children:[X(`td`,{children:Tn(e.workflow)}),X(`td`,{class:`strong`,children:e.stage}),X(`td`,{children:e.runs}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:Dn(e.avg_ms)}),X(kn,{fraction:En(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Most failures`}),X(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Stage`}),X(`th`,{children:`Failures`})]})}),X(`tbody`,{children:r.map((e,t)=>X(`tr`,{children:[X(`td`,{children:Tn(e.workflow)}),X(`td`,{class:`strong`,children:e.stage}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),X(kn,{fraction:En(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):X(On,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Fn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function In(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function Ln(){let[e,t]=W([]),[n,r]=W(null),i=async()=>{try{let e=await Y.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return G(()=>{i()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Channels`}),X(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),X(`div`,{className:`grid grid-2`,children:n?X(Fn,{title:`Cannot reach archied`,detail:n}):e.length===0?X(Fn,{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=>X(`div`,{className:`card channel-card`,children:[X(`div`,{className:`card-head`,children:[X(`h3`,{className:`card-title`,children:e.name}),X(Q,{text:e.state||(e.configured?`configured`:`stopped`),kind:In(e.state,e.configured)})]}),X(`p`,{className:`channel-desc`,children:e.description}),X(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?X(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await Y.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):X(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Rn(e){return X(Ln,{query:e})}function zn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Bn(e){return X(Vn,{query:e})}function Vn({query:e}){let[t,n]=W([]),[r,i]=W(null),a=async()=>{try{let e=await Y.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return G(()=>{a()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Curators`}),X(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),X(`div`,{className:`grid grid-2`,children:r?X(zn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>X(Un,{curator:e},e.name)):X(zn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function Hn(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function Un({curator:e}){let t=e.recent_actions||[];return X(`div`,{className:`card curator-card`,children:[X(`div`,{className:`card-head`,children:[X(`h3`,{className:`card-title`,children:e.name}),X(Q,{text:e.health?.status||`unknown`,kind:Hn(e.health?.status)})]}),e.health?.message&&X(`p`,{className:`curator-health-message`,children:e.health.message}),X(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${Ye(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?X(`ul`,{className:`curator-actions`,children:t.map((e,t)=>X(`li`,{className:`curator-action`,children:[X(`div`,{className:`curator-action-head`,children:[X(`span`,{className:`curator-action-type`,children:e.type||`action`}),X(`span`,{className:`curator-action-time`,children:Ye(e.at)})]}),e.detail&&X(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&X(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):X(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function Wn(e){return e==null||e===``?`—`:String(e)}function Gn({label:e,value:t,opts:n}){let r=Wn(t),[i,a]=W(!1),[o,s]=W(``),[c,l]=W(null),[u,d]=W(!1),[f,p]=W(!1),m=n?.key;if(!m)return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n?.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return X(`div`,{className:`kv is-locked`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),X(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`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 Y.configReset(m),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{p(!1)}},y=async()=>{let e=Kn(n.type,o);if(e.error){l(e.error);return}d(!0),l(null);try{await(n.save||(e=>Y.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=K(null);G(()=>{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`?X(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[X(`option`,{value:`true`,children:`true`}),X(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?X(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>X(`option`,{value:e,children:e},e))}):X(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),i,X(`div`,{className:`kv-actions`,children:[X(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),X(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&X(`span`,{className:`kv-note is-error`,children:c})]})}return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),X(`div`,{className:`kv-actions`,children:[g&&X(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),X(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&X(`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&&X(`span`,{className:`kv-note is-error`,children:c})]})}function Kn(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 X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Jn({sub:e,title:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:t||`Update status`}),X(`p`,{className:`card-sub`,children:e})]})}),n]})}var Yn={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},Xn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function Zn({components:e}){return!e||!e.length?X(Jn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:X(qn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):X(Jn,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Component`}),X(`th`,{children:`Install type`}),X(`th`,{children:`Running`}),X(`th`,{children:`Latest available`}),X(`th`,{children:`Status`})]})}),X(`tbody`,{children:e.map(e=>X(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` -`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Q,{text:Yn[e.status]||e.status,kind:Xn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Qn({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function $n({origins:e}){return e?.length?X(Qn,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(Gn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X(Qn,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X($,{title:`Source provenance is unavailable.`})})}function er(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function tr({data:e,error:t}){if(t)return X(Qn,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X(Qn,{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:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??He(e.id),n=e.kind??Ue(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Q,{text:t,kind:n})})]},e.id)})}):X($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=er(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function nr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?X(`td`,{children:[X(`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 Y.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function rr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?X(`td`,{children:[X(`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 Y.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&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function ir({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X(Qn,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X($,{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 X(Qn,{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:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(nr,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),X(rr,{r:e,field:`max_retries`,onSaved:t,editable:n}),X(nr,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function ar(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function or({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return X(Qn,{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:[X(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?X(`div`,{className:`kv-list`,children:n.map(([e,t])=>X(Gn,{label:ar(e),value:t},e))}):X($,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),X(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Provider`}),X(`th`,{children:`Class`}),X(`th`,{children:`Base URL`}),X(`th`,{children:`API key env var`}),X(`th`,{children:`Status`})]})}),X(`tbody`,{children:r.map(([e,t])=>X(`tr`,{children:[X(`td`,{className:`strong`,children:e}),X(`td`,{children:t.class}),X(`td`,{className:`mono`,children:t.base_url||`default`}),X(`td`,{className:`mono`,children:t.api_key_env||`—`}),X(`td`,{children:t.configured?X(Q,{text:`configured`,kind:`ok`}):X(Q,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):X($,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function sr(){let[e,t]=W(null),[n,r]=W(null),[i,a]=W(null),[o,s]=W(null),[c,l]=W(!1),[u,d]=W(null),[f,p]=W(null),m=()=>{h(),g(),_()},h=async()=>{try{let e=await Y.config();t(e),r(null)}catch(e){r(String(e.message||e))}},g=async()=>{try{let e=await Y.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},_=async()=>{try{let e=await Y.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return G(()=>{m()},[]),X(`div`,{className:`cfg-page`,children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Configuration`}),X(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:m,children:`Refresh`})})]}),X(`div`,{children:!c&&(o?X(`div`,{className:`card`,children:X($,{title:`Update status unavailable`,detail:o})}):i?X(Zn,{components:i}):null)}),X(`div`,{children:X(tr,{data:u,error:f})}),X(`div`,{children:n?X(`div`,{className:`card`,children:X($,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?X(`div`,{className:`card`,children:X($,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):X(S,{children:[e.reload?.overlay_unavailable&&X(`div`,{className:`card cfg-notice`,children:X(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&X(`div`,{className:`card cfg-notice`,children:X(`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?X(Qn,{title:t.label,sub:t.description,children:X(`div`,{className:`kv-list`,children:r.map(t=>X(Gn,{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:h}},t.key))})},n):null}),X(ir,{repos:e.repositories,onSaved:h,editable:e.editable!==!1}),X(or,{models:e.models,providers:e.providers}),X($n,{origins:e.provenance})]})})]})}function cr(e){return X(sr,{query:e})}function lr({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function ur(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function dr(){let[e,t]=W({level:``,component:``,q:``}),[n,r]=W(!1),[i,a]=W([]),[o,s]=W([]),c=K(new Map),[l,u]=W(0),[d,f]=W(!1),[p,m]=W(`connecting`),[h,g]=W(`Refreshing…`),_=K(null),v=K(null),y=async()=>{g(`Refreshing…`);try{let t=await Y.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`)}};G(()=>{y()},[e]),G(()=>{let e=Me(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(ur(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=K(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=K(x);S.current=x;let C=ge(()=>{let e=new Map;for(let t of o)e.set(ur(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return G(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Logs`}),X(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),X(`div`,{className:`page-actions`,children:[X(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),X(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{className:`log-filters`,children:[X(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:bt.map(e=>X(`option`,{value:e.value,children:e.label},e.value))}),X(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[X(`option`,{value:``,children:`All components`}),i.map(e=>X(`option`,{value:e,children:e},e))]}),X(`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)}})]}),X(`div`,{className:`log-status`,children:[X(`span`,{className:`log-meta`,children:h}),X(Q,{text:p,kind:p===`live`?`ok`:`warn`})]})]}),X(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?X(lr,{title:`Cannot read logs`}):C.length?C.map(e=>X(St,{entry:e},ur(e))):X(lr,{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 fr(e){return X(dr,{query:e})}function pr({capture:e,expanded:t,onToggle:n}){return X(S,{children:[X(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[X(`td`,{className:`mono`,children:e.source||`(unknown)`}),X(`td`,{title:e.received_at||``,children:Ye(e.received_at)}),X(`td`,{children:X(Q,{text:`Unbound`,kind:`idle`})}),X(`td`,{className:`mono`,children:e.content_type||`—`}),X(`td`,{children:X(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&X(mr,{capture:e})]})}function mr({capture:e}){return X(`tr`,{className:`capture-detail-row`,children:X(`td`,{colSpan:`5`,children:X(`div`,{className:`capture-detail`,children:[X(`div`,{className:`capture-detail-section`,children:[X(`div`,{className:`capture-detail-title`,children:`Payload`}),X(hr,{raw:e.body})]}),X(`div`,{className:`capture-detail-section`,children:[X(`div`,{className:`capture-detail-title`,children:`Headers`}),X(hr,{raw:e.headers})]})]})})})}function hr({raw:e}){return e?X(`pre`,{className:`capture-payload`,children:gr(e)}):X(`div`,{className:`capture-empty`,children:`(empty)`})}function gr(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function _r({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function vr(e){return X(yr,{query:e})}function yr({query:e}){let[t,n]=W([]),[r,i]=W(null),[a,o]=W(null),[s,c]=W(!0),[l,u]=W({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await Y.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return G(()=>{d();let e=je(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Event inspector`}),X(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),X(`div`,{className:`page-actions`,children:[X(Q,{text:l.text,kind:l.kind}),X(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),X(`div`,{className:`card`,children:a?X(_r,{title:`Cannot reach archied`,detail:a}):s?t.length?X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:t.map(e=>X(pr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):X(_r,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):X(_r,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var br=[`string`,`number`,`bool`,`object`,`array`,`any`];function xr(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 Sr(e,t){return e?`${e}.${t}`:t}function Cr(e,t){return`${e}[${t}]`}function wr({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?X(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Cr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,Sr(t,e)])).map(([e,t,n])=>X(`li`,{className:`mapping-tree-item`,children:[X(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:xr(t),name:e})},children:e}),X(wr,{value:t,path:n,name:e,onPick:r})]},n))}):X(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:xr(e),name:n})},children:JSON.stringify(e)})}function Tr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return X(`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 X(`table`,{className:`table mapping-fields-table`,children:[X(`thead`,{children:X(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:e.map((e,s)=>X(`tr`,{children:[X(`td`,{children:X(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),X(`td`,{className:`mono`,children:e.path}),X(`td`,{children:X(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:br.map(e=>X(`option`,{value:e,children:e},e))})}),X(`td`,{children:X(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),X(`td`,{children:X(Er,{field:e,preview:t,failureByField:o})}),X(`td`,{children:X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Er({field:e,preview:t,failureByField:n}){if(!t)return X(Q,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?X(Q,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?X(Q,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):X(Q,{text:`skipped (optional)`,kind:`idle`})}function Dr({mapping:e,onEdit:t,onDelete:n}){return X(`tr`,{children:[X(`td`,{children:e.name}),X(`td`,{className:`mono`,children:e.source_hint||`—`}),X(`td`,{children:String(e.fields?.length??0)}),X(`td`,{children:[X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Or({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function kr(e){return X(Ar,{query:e})}function Ar({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W(null),[s,c]=W(null),l=async()=>{try{let[e,t]=await Promise.all([Y.mappings(),Y.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};G(()=>{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 Y.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?X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:X(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),X(`div`,{className:`page-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),X(`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 Y.mappingUpdate(s.id,e):await Y.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&X(`div`,{className:`mapping-error`,children:s.actionError}),X(`div`,{className:`card mapping-form`,children:[X(`label`,{className:`mapping-form-row`,children:[`Name`,X(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),X(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,X(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),X(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,X(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[X(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>X(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),X(`div`,{className:`card mapping-fields`,children:[X(`div`,{className:`mapping-section-title`,children:`Bound fields`}),X(Tr,{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})}),X(`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 Y.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),X(`div`,{className:`card mapping-payload`,children:[X(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?X(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?X(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):X(wr,{value:s.payload,onPick:m})]})]}):X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Field mappings`}),X(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?X(Or,{title:`Cannot reach archied`,detail:a}):t.length?X(`div`,{className:`card`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:t.map(e=>X(Dr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):X(Or,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var jr={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Mr={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Nr({status:e}){return X(Q,{text:jr[e]||e,kind:Mr[e]||`idle`})}function Pr({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return X(`tr`,{children:[X(`td`,{children:e.name}),X(`td`,{className:`mono`,children:e.matcher?.source||`—`}),X(`td`,{children:e.workflow}),X(`td`,{className:`mono`,children:i}),X(`td`,{children:X(Nr,{status:e.status})}),X(`td`,{children:[X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&X(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function Fr({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Ir(e){return X(Rr,{query:e})}function Lr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Rr({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W([]),[s,c]=W(null),[l,u]=W(null),d=async()=>{try{let[e,t,r]=await Promise.all([Y.bindings(),Y.mappings(),Y.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};G(()=>{d()},[]);let f=()=>{u(Lr())},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 Y.bindingUpdate(l.id,e):await Y.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await Y.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await Y.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:X(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),X(`div`,{className:`page-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&X(`div`,{className:`binding-error`,children:l.actionError}),X(`div`,{className:`card binding-form`,children:[X(`label`,{className:`binding-form-row`,children:[`Name`,X(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),X(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,X(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),X(`label`,{className:`binding-form-row`,children:[`Field mapping`,X(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[X(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>X(`option`,{value:e.id,children:e.name},e.id))]})]}),X(`label`,{className:`binding-form-row`,children:[`Workflow`,X(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[X(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>X(`option`,{value:e.id,children:e.name},e.id))]})]}),X(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,X(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),X(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,X(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),X(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,X(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Playbook bindings`}),X(`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.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?X(Fr,{title:`Cannot reach archied`,detail:s}):t.length?X(`div`,{className:`card`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:t.map(e=>X(Pr,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):X(Fr,{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 Br(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(X(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(X(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(X(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(X(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(X(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(X(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(X(`p`,{children:Br(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>X(`li`,{children:Br(e)},t));n.push(a.tag===`ol`?X(`ol`,{children:e},s++):X(`ul`,{children:e},s++)),a=null};for(let e=0;eX(`th`,{children:Br(e)},t))})}),X(`tbody`,{children:t.map((e,t)=>X(`tr`,{children:e.map((e,t)=>X(`td`,{children:Br(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(X(e,{children:Br(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(X(`blockquote`,{children:Br(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(X(`pre`,{children:X(`code`,{children:o.join(` -`)})},s++)),X(`div`,{className:t,children:n})}function Hr(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 Ur(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Wr=`archie.web.chat.channel`;function Gr(){let e=localStorage.getItem(Wr);return e||(e=we(),localStorage.setItem(Wr,e)),e}function Kr(e){return{text:e,sourceID:we()}}function qr(e){return{...e}}function Jr(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?qr(e.turn):Kr(r),isRetry:n}}function Yr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Xr(e){return e?.status===501?null:`Could not check for updates.`}function Zr(){return location.hash.slice(1)||`/`}function Qr(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),[j,M]=W(null),[N,P]=W(null),[F,I]=W(``),[L,ee]=W(``),[R,z]=W(null),te=K(null),B=K(null),V=K(null),ne=K(null),re=K(null),H=K(u);H.current=u,G(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[i,R]),G(()=>{le().catch(e=>{l(e.message||`Chat unavailable`)}),ie();let e=()=>{V.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),V.current?.abort()}},[]);async function ie(){try{let e=await Y.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=Xr(e);A(t?{error:t}:null)}}async function ae(){if(j)try{await Y.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function oe(){if(j)try{l(`Installing…`);let e=await Y.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function se(){try{let e=await Y.chatDangerous();P(e)}catch(e){P({error:e.message||`Dangerous actions unavailable`})}}async function U(e,t){if(t)try{await Y.chatDangerousRequest(e,t),l(`Approval requested`),await se()}catch(e){l(e.message||`Could not request action`)}}async function ce(e,t){try{await Y.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await se()}catch(e){l(e.message||`Approval failed`)}}async function le(){let e=await Y.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await se(),!n&&r[0]&&await ue(r[0].session_id,e,r)}async function ue(e,t,n){let i=t||f;r(e),a([]),z(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await Y.chatMessage(Gr(),`/resume ${e}`);let[t,n]=await Promise.all([Y.chatMessages(e),Y.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});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function de(e){if(n)try{l(`Working…`);let t=await Y.chatMessage(Gr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await le(),(t.session_id||n)&&await ue(t.session_id||n),ne.current&&(ne.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function fe(e,t){let n=window.prompt(t);n?.trim()&&de(`${e} ${n.trim()}`)}function pe(e){let t=e.target.value;h(t),!(!n||!t)&&Y.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function me(e){let t=e.target.value;if(_(t),t)try{let e=await Y.chatMessage(Gr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await le()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function he(e){let t=e.target.value;if(y(t),t)try{let e=await Y.chatMessage(Gr(),`/model ${t}`);l(e.reply||`Model updated`),await le()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ge(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),q({textOverride:`/restart`}))}function _e(){s(`/new`),q({textOverride:`/new`})}function ve(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function ye(e){let t=C[e];if(!t||!B.current)return;let n=B.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]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function be(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===o.trim())){e.preventDefault(),O(!1),q();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),ye(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),q())}async function q(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:c}=Jr(e,t===void 0?o:t);if(!n||H.current)return;O(!1),d(!0),l(c?`Retrying…`:`Thinking…`),c||(a(e=>[...e,{from:`web`,text:n}]),s(``));let u=[];z({text:``,tools:[],isError:!1,turn:i,isRetry:c});let f=``,p=!1,m=!1,h=null;try{let e=new AbortController;V.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await Y.chatStream({channel_id:Gr(),source_id:i.sourceID,text:i.text,page:Zr()},{signal:e.signal})).body.getReader(),n=new TextDecoder,o=``;for(;;){let{value:e,done:i}=await t.read();o+=n.decode(e||new Uint8Array,{stream:!i});let a=o.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(z):e.constructor===void 0?v({},e):null}function ee(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 W(e){return oe=1,he(we,e)}function he(e,t,n){var r=me(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):we(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 G(e,t){var n=me(B++,3);!U.__s&&Ce(n.__H,t)&&(n.__=e,n.u=t,V.__H.__h.push(n))}function K(e){return oe=5,ge(function(){return{current:e}},[])}function ge(e,t){var n=me(B++,7);return Ce(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _e(e,t){return oe=8,ge(function(){return e},t)}function ve(){for(var e;e=se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(xe),t.__h.some(Se),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){V=null,ce&&ce(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),pe&&pe(e,t)},U.__r=function(e){le&&le(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(xe),t.__h.some(Se),t.__h=[],B=0)),ae=V},U.diffed=function(e){ue&&ue(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(se.push(t)!==1&&H===U.requestAnimationFrame||((H=U.requestAnimationFrame)||be)(ve)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ae=V=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(xe),e.__h=e.__h.filter(function(e){return!e.__||Se(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),de&&de(e,t)},U.unmount=function(e){fe&&fe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{xe(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var ye=typeof requestAnimationFrame==`function`;function be(e){var t,n=function(){clearTimeout(r),ye&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ye&&(t=requestAnimationFrame(n))}function xe(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function Se(e){var t=V;e.__c=e.__(),V=t}function Ce(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function we(e,t){return typeof t==`function`?t(e):t}function Te(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 Ee=15e3;function De(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 Oe(e){try{let t=(await e.text()).trim();if(t)return t.split(` +`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var ke=class extends Error{constructor(e,t){super(e),this.status=t}};function Ae(e){let t=e instanceof ke?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 je(e,t){let n=await fetch(e,t);if(!n.ok)throw new ke(await Oe(n),n.status);return n}async function q(e,{method:t=`GET`,body:n,timeoutMs:r=Ee,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 je(e,o);return i?s.json():void 0}var J={summary:()=>q(`/api/summary`),tasks:()=>q(`/api/tasks`),taskMeta:()=>q(`/api/task-meta`),task:e=>q(`/api/tasks/${e}`),taskAttempts:e=>q(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>q(`/api/tasks/${e}/changes`+De(t)),taskDebug:(e,t)=>q(`/api/tasks/${e}/debug`+De(t)),taskAction:(e,t)=>q(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>q(`/api/setup`),capabilities:()=>q(`/api/capabilities`),workflows:()=>q(`/api/workflows`),workRequest:e=>q(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>q(`/api/skills`),channels:()=>q(`/api/channels`),curators:()=>q(`/api/curators`),channelReload:e=>q(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>q(`/api/config`),version:()=>q(`/api/version`),configUpdate:e=>q(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>q(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>q(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>q(`/api/logs`+De(e)),taskLogs:(e,t)=>q(`/api/tasks/${e}/logs`+De(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>q(`/api/captures`+De({limit:e})),mappings:()=>q(`/api/mappings`),mappingCreate:e=>q(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>q(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>q(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>q(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>q(`/api/bindings`),bindingCreate:e=>q(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>q(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>q(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>q(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>q(`/api/chat/sessions`),chatMessages:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>q(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>q(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Te(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>q(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>q(`/api/chat/update`),chatUpdateDefer:e=>q(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>q(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>q(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>je(`/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 Me(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 Ne(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 Pe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Fe=[{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`}],Ie=[{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`}],Le=[...Fe],Re=[...Ie],ze=new Map(Le.map(e=>[e.id,e])),Be=new Map(Re.map(e=>[e.id,e]));function Ve(){ze=new Map(Le.map(e=>[e.id,e])),Be=new Map(Re.map(e=>[e.id,e]))}async function He(){try{let e=await J.taskMeta();Array.isArray(e?.statuses)&&(Le=e.statuses),Array.isArray(e?.actions)&&(Re=e.actions),Ve()}catch{}}function Ue(e){return ze.get(e)?.label||e||`Unknown`}function We(e){return ze.get(e)?.kind||`idle`}function Ge(){return Le.map(e=>e.id)}function Ke(){return new Set(Le.filter(e=>e.needs_you).map(e=>e.id))}function qe(e){return Be.get(e)||null}var Je=0;Array.isArray;function Y(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:--Je,__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 Ye={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,help:``};function X({name:e,size:t=18,className:n=``}){return Y(`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:Ye[e]||Ye.dashboard}})}function Z(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 Xe(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function Ze({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 Y(`div`,{className:`card stat`,children:[Y(`div`,{className:`stat-head`,children:[Y(`span`,{className:`stat-label`,children:e}),s?Y(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[Y(X,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),Y(`div`,{className:`stat-value`,children:[t,n?Y(`span`,{className:`stat-unit`,children:n}):null]}),i?Y(`div`,{className:`stat-compare`,children:i}):null,a.length>1?Y(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 Y(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:Y(`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 Y(`div`,{className:`gauge-wrap`,children:[Y(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[Y(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),Y(`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`})]}),Y(`div`,{className:`gauge-center`,children:[Y(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),Y(`div`,{className:`gauge-label`,children:t})]})]})}function et({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return Y(`div`,{children:[Y(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>Y(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),Y(`div`,{className:`segbar-legend`,children:e.map(e=>Y(`span`,{className:`segbar-key`,children:[Y(`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 Y(`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 Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`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]=W([]),[n,r]=W(`connecting`),[i,a]=W(`idle`),[o,s]=W(new Map),[c,l]=W(null),[u,d]=W(null),[f,p]=W(null),[m,h]=W(null),[g,_]=W(null),[,v]=W(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([J.summary(),J.setup().catch(()=>null),J.workflows().catch(()=>null),J.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))}};G(()=>(y(),Me(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=Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=Y(S,{children:[t>0&&Y(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Y(X,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Y(`a`,{className:`btn`,href:e.running.href,children:[Y(X,{name:`workflows`,size:15}),` `,n,` running`]}),Y(`a`,{className:`btn`,href:`#/logs`,children:[Y(X,{name:`logs`,size:15}),` Logs`]}),Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=Y(`div`,{className:`card`,children:Y(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=Y(S,{children:[Y(Ze,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Y(Ze,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Y(Ze,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Y(Ze,{label:`Tokens used`,value:Xe(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=Y(`div`,{className:`card setup`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Finish setting up`}),Y(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),Y(`span`,{className:`setup-pct`,children:[t,`%`]})]}),Y(`div`,{className:`setup-bar`,children:Y(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),Y(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>Y(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[Y(`span`,{className:`setup-check`,children:e.done?Y(X,{name:`check`,size:12}):``}),Y(`div`,{children:[Y(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&Y(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=Y(`div`,{className:`card setup setup-done`,children:Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Setup complete`}),Y(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),Y(`div`,{className:`setup-complete-actions`,children:[Y(`span`,{className:`setup-pct`,children:Y(X,{name:`check`,size:16})}),Y(`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=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`h2`,{className:`card-title`,children:`Gate pulse`})}),Y(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=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Gate pulse`}),Y(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),Y($e,{value:i,label:`pass rate`}),Y(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>Y(`li`,{className:`pulse-item`,children:[Y(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),Y(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&&Y(`li`,{className:`pulse-item`,children:[Y(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),Y(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=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`h2`,{className:`card-title`,children:`Token outlook`})}),Y(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=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Token outlook`}),Y(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),Y(`div`,{className:`forecast-value`,children:Xe(r)}),Y(`div`,{className:`forecast-note`,children:[`Based on `,Xe(Math.round(n)),` per day over `,e.length,` days`]}),Y(et,{segments:[{label:`Last 7 days (${Xe(i)})`,value:i,kind:`info`},{label:`Earlier (${Xe(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return Y(S,{children:[Y(`div`,{className:`hero`,children:[Y(`div`,{children:[Y(`h1`,{className:`hero-title`,children:x}),Y(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),Y(`div`,{className:`hero-actions`,children:Y(`div`,{className:`hero-actions-inner`,children:C})})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:Y(`h2`,{className:`dash-section-title`,children:`Health`})}),Y(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[Y(`div`,{children:T}),Y(`div`,{children:O})]})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:[Y(`h2`,{className:`dash-section-title`,children:`Throughput`}),Y(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),Y(`div`,{className:`grid grid-4`,children:w})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:Y(`h2`,{className:`dash-section-title`,children:`Right now`})}),Y(`div`,{className:`dash-split`,children:[Y(`div`,{children:k}),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Live activity`}),Y(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),Y(Q,{text:n,kind:i})]}),Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Event`}),Y(`th`,{children:`Task`}),Y(`th`,{children:`Detail`}),Y(`th`,{children:`When`})]})}),Y(`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 Y(`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:[Y(`td`,{className:`strong`,children:Y(`span`,{children:e.kind||e.type||`event`})}),Y(`td`,{className:`mono`,children:r?`#${n}`:`—`}),Y(`td`,{className:`activity-detail`,children:Y(`span`,{title:i.truncated?i.full:void 0,children:i.text})}),Y(`td`,{children:Z(e.at||Date.now())})]},t)}):Y(`tr`,{children:Y(`td`,{colSpan:`4`,children:Y(ct,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function pt(){return Y(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`,...Ge()])}function gt(e){let t=e?.get?.(`status`)||``;return ht().has(t)?t:``}function _t(e,t){return t?t===`needs_you`?Ke().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 Y(`div`,{className:`log-row log-${Ct(e.level)}`,children:[Y(`span`,{className:`log-time mono`,children:Et(e.time)}),Y(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),Y(`span`,{className:`log-body`,children:[Y(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>Y(`span`,{className:`log-field`,children:[Y(`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 Y(`div`,{className:`log-filters task-log-filters`,children:[Y(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?Y(S,{children:[Y(`label`,{className:`task-log-filter`,children:[Y(`span`,{className:`task-log-filter-label`,children:`Level`}),Y(`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=>Y(`option`,{value:e.value,children:e.label},e.value))})]}),Y(`label`,{className:`task-log-filter`,children:[Y(`span`,{className:`task-log-filter-label`,children:`Stage`}),Y(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[Y(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),e.stage?Y(`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?Y(`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 Y(`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=Y(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=Y(`div`,{className:`task-log-error`,children:[Y(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),Y(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),Y(`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=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),Y(`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?Y(`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=Y(S,{children:[Y(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>Y(wt,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`Nothing recorded`}),Y(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return Y(S,{children:[Y(At,{filters:i,onFilterChange:a,stages:o,attempt:s}),Y(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`?Y(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,Y(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?Y(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):Y(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function It({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Lt({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=K(r);return a.current=r,G(()=>{n===void 0&&a.current()},[n]),Y(Mt,{state:n,taskId:e,attempt:t,onRetry:i})}function Rt({query:e}){let[t,n]=W(null),[r,i]=W(null),[a,o]=W(()=>gt(e)),[s,c]=W(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=W(u),[p,m]=W(u!==null),[h,g]=W(new Map),[_,v]=W(new Map),y=K(new Set),[b,x]=W(new Set),[C,w]=W(new Map),[T,E]=W(new Set),D=async()=>{try{i(null);let e=await J.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}};G(()=>{D()},[]);let O=async e=>{try{let t=await J.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 J.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 J.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,Ae(t)))}};G(()=>{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 Y(`div`,{className:`grid grid-4 task-summary`,children:[Y(Ze,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),Y(Ze,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),Y(Ze,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Y(Ze,{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=qe(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 Y(`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?`—`:Y(`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`?Y(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):Y(`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?Y(`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},R=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:Y(`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]})},z=e=>{let t=kt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return Y(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:Y(`td`,{colSpan:8,children:[Y(`div`,{className:`task-detail-actions`,children:[Y(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&Y(`div`,{className:`task-decision`,children:[Y(`div`,{className:`task-decision-title`,children:`Decision required`}),Y(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&Y(`div`,{className:`task-decision`,children:[Y(`div`,{className:`task-decision-title`,children:`Park reason`}),Y(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?Y(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?Y(`div`,{className:`task-timeline-error`,children:[Y(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),Y(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),Y(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?Y(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=xt(e);return Y(`li`,{className:`task-timeline-entry`,children:[Y(`span`,{className:`task-timeline-dot`}),Y(`div`,{children:[Y(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&Y(`div`,{className:`task-timeline-detail`,children:n.detail}),Y(`div`,{className:`task-timeline-when`,children:Z(e.at)})]})]},t)})}):Y(It,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),Y(`div`,{className:`task-logs-section`,children:[Y(`div`,{className:`task-decision-title`,children:[`Attempt log`,Y(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&Y(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 Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Tasks`}),Y(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?Y(`div`,{className:`grid grid-4 task-summary`,children:Y(`div`,{className:`card`,children:Y(It,{title:`Cannot reach archied`,detail:r})})}):P(),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`All tasks`}),Y(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),Y(`div`,{className:`task-filters`,children:[Y(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),Y(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[Y(`option`,{value:``,children:`All statuses`}),Y(`option`,{value:`needs_you`,children:`Needs you`}),Ge().map(e=>Y(`option`,{value:e,children:Ue(e)},e))]})]})]}),Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>Y(`th`,{children:e},e))})}),Y(`tbody`,{children:(()=>{if(r)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(It,{title:`Cannot reach archied`,detail:r})})});if(!t)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(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 Y(S,{children:[Y(`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:[Y(`td`,{className:`mono`,"data-label":`Repository`,children:[Y(`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}`]}),Y(`td`,{className:`mono`,"data-label":`Issue`,children:R(e)??`#${e.issue_number}`}),Y(`td`,{className:`strong`,"data-label":`Title`,children:Y(`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)`})}),Y(`td`,{"data-label":`Status`,children:Y(Q,{text:Ue(e.status),kind:We(e.status)})}),Y(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),Y(`td`,{"data-label":`Stage`,children:e.stage||`—`}),Y(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${Z(e.created_at)}`:``,children:Z(e.updated_at)}),Y(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&z(e)]},e.id)}):Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(It,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function zt(e){return Y(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=K([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return Y(`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 Y(`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 Y(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[Y(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),Y(`div`,{className:`run-stage-body`,children:[Y(`div`,{className:`run-stage-head`,children:[Y(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),Y(Q,{text:r.label,kind:r.kind}),Y(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?Y(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>Y(`div`,{className:`run-agent-report`,children:[Y(`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 Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Yt({count:e}){let t=Number(e)||0;return t?Y(`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 Y(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),Y(`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?Y(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return Y(S,{children:[Y(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.`}),Y(Yt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return Y(S,{children:[Y(Jt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),Y(Yt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Wt(a.status);return Y(`div`,{className:`run-rail`,children:[Y(`div`,{className:`run-rail-head`,children:[Y(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),Y(Q,{text:s.label,kind:s.kind}),Y(`span`,{className:`run-rail-when`,children:Kt(a.started_at)})]}),o.length?Y(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>Y(qt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):Y(Jt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),Y(`p`,{className:`run-rail-legend`,children:[Y(`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.`]}),Y(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?Y(S,{children:[Y(`table`,{className:`table run-changes-table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Path`}),Y(`th`,{children:`Change`}),Y(`th`,{className:`run-changes-count`,children:`Added`}),Y(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),Y(`tbody`,{children:t.map((e,t)=>Y(`tr`,{children:[Y(`td`,{className:`mono run-changes-path`,children:[e.old_path?Y(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),Y(`td`,{children:[Qt(e.status),e.binary?Y(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),Y(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),Y(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?Y(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):Y(`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 Y(`section`,{className:`run-capture`,children:[Y(`div`,{className:`run-capture-head`,children:[Y(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),Y(`span`,{className:`run-capture-at`,children:e.captured_at?Z(e.captured_at):``})]}),Y(`div`,{className:`run-capture-meta`,children:[Y(`span`,{className:`mono`,children:n.repo?Y(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?Y(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?Y(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?Y(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):Y(`span`,{className:`mono`,children:[`PR #`,r]}):null,Y(`span`,{className:`run-capture-totals`,children:en(e.totals)})]}),Y(tn,{capture:e})]})}function rn({state:e,task:t,onRetry:n}){if(e===void 0)return Y(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),Y(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),Y(`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?Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),Y(`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".`})]}):Y(`div`,{className:`run-changes`,children:r.map((e,n)=>Y(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 Y(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),Y(`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?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=an(e,t);if(!r)return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`Not captured for this run`}),Y(`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 Y(`div`,{className:`run-config`,children:[Y(`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.`]}),Y(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?Y(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):Y(S,{children:[Y(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),Y(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function sn({state:e,attempt:t,onRetry:n}){return e===void 0?Y(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),Y(`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?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):Y(`div`,{className:`run-debug`,children:[Y(`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.`]}),Y(`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 Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function vn({id:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Task not found`}),Y(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),Y(`div`,{className:`page-actions`,children:Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),Y(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function yn({raw:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Not a task id`}),Y(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),Y(`div`,{className:`page-actions`,children:Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),Y(`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?Y(`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 Y(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[Y(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),Y(Q,{text:r.label,kind:r.kind}),Y(`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]=W(()=>fn(t)),[i,a]=W(()=>pn(t)),[o,s]=W(void 0),[c,l]=W(void 0),[u,d]=W(!1),[f,p]=W(void 0),[m,h]=W(Ot),[g,_]=W(new Map),[v,y]=W(new Map),[b,x]=W(new Map),[S,C]=W(!1),[w,T]=W(null),[E,D]=W(0),O=K(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),J.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),J.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),J.task(e).then(e=>p(e||[])).catch(()=>p(null))},R=(t,n)=>P(kt(e,t,m),()=>J.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),z=(t,n)=>P(gn(e,t),()=>J.taskChanges(e,{attempt:t}),y,n),ee=(t,n)=>P(gn(e,t),()=>J.taskDebug(e,{attempt:t}),x,n),te=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};G(()=>{F(),I(),L()},[]),G(()=>{j!=null&&(n===`log`?R(j):n===`changes`?z(j):n===`debug`&&ee(j))},[n,j,m,E]),G(()=>{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 J.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(Ae(e))}finally{C(!1)}}};if(u)return Y(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 Y(Xt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return Y(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),Y(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),Y(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return Y(_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 Y(Mt,{state:re&&g.has(re)?g.get(re):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>R(j,{force:!0})});case`changes`:return Y(rn,{state:v.has(ie)?v.get(ie):void 0,task:k,onRetry:()=>z(j,{force:!0})});case`config`:return Y(on,{events:f,attempt:j,onRetry:L});case`debug`:return Y(sn,{state:b.has(B)?b.get(B):void 0,attempt:j,onRetry:()=>ee(j,{force:!0})});default:return Y(Xt,{state:c,attemptNumber:j,events:f,onRetry:I})}},ae=qe(`retry`),H=!!(ae&&(k?.actions||[]).includes(`retry`));return Y(`div`,{className:`run-page`,children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),Y(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),Y(`div`,{className:`page-actions`,children:[Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),Y(`button`,{className:`btn`,type:`button`,onClick:te,children:`Refresh`})]})]}),Y(`div`,{className:`run-meta`,children:[Y(`span`,{className:`run-meta-item`,children:[Y(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?Y(`span`,{className:`run-meta-muted`,children:`loading…`}):k?Y(Q,{text:Ue(k.status),kind:We(k.status)}):Y(`span`,{className:`run-meta-muted`,children:`not read`})]}),Y(`span`,{className:`run-meta-item`,children:[Y(`span`,{className:`run-meta-label`,children:`Attempt`}),Y(`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?Y(`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?Y(`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?Y(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?Y(`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?Y(`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,Y(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[Y(`button`,{className:`btn ${ae?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!H||S,title:`Retry this task as a new run`,onClick:ne,children:S?`Starting…`:`Start a new run`}),Y(`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.`}),!H&&o!==void 0?Y(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${Ue(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?Y(`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]}),Y(bn,{attempts:c,selected:j,onSelect:e=>a(e)}),Y(`div`,{className:`card run-card`,children:[Y(Ht,{tabs:cn,active:n,onSelect:r,prefix:ln}),Y(`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?Y(yn,{raw:n??``}):Y(xn,{id:r,query:e},r)}function Cn({title:e,detail:t}){return Y(`div`,{class:`empty`,children:[Y(`div`,{class:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function wn(e){return Y(Tn,{query:e})}function Tn(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W(null),o=async()=>{try{let e=await J.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};G(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=ge(()=>e.filter(e=>s(e,n)),[e,n]);return Y(`div`,{children:[Y(`div`,{class:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{class:`page-title`,children:`Skills`}),Y(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),Y(`div`,{class:`page-actions`,children:Y(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Catalogue`}),Y(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),Y(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),Y(`div`,{class:`grid grid-2`,children:i?Y(Cn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>Y(`div`,{class:`card skill-card`,children:[Y(`div`,{class:`card-head`,children:[Y(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&Y(Q,{text:e.workflow,kind:`info`})]}),Y(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),Y(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):Y(Cn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):Y(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 Y(`div`,{class:`empty`,children:[Y(`div`,{class:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function jn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return Y(`div`,{class:`wf-bar`,children:Y(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Mn(e){return Y(Nn,{query:e})}function Nn(){let[e,t]=W([]),[n,r]=W([]),[i,a]=W([]),[o,s]=W(null),c=async()=>{try{let e=await J.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return G(()=>{c()},[]),Y(`div`,{children:[Y(`div`,{class:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{class:`page-title`,children:`Workflows`}),Y(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),Y(`div`,{class:`page-actions`,children:Y(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),Y(Pn,{definitions:e}),o?Y(`div`,{class:`card`,children:Y(An,{title:`Cannot reach archied`,detail:o})}):Y(S,{children:[Y(Fn,{workflows:n,definitions:e}),Y(In,{stages:i})]})]})}function Pn({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=W(``),[i,a]=W(``),[o,s]=W(t),[c,l]=W(``),[u,d]=W(``),[f,p]=W(!1),[m,h]=W(``);return G(()=>{!o&&t&&s(t)},[t,o]),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Start work`}),Y(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),Y(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await J.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:[Y(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),Y(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),Y(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>Y(`option`,{value:e.id,children:Dn(e.name||e.id)},e.id))}),Y(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),Y(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),Y(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&Y(`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?Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Per workflow`}),Y(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Origin`}),Y(`th`,{children:`Runs`}),Y(`th`,{children:`Success rate`}),Y(`th`,{children:`Avg tokens`}),Y(`th`,{children:`Avg steps`})]})}),Y(`tbody`,{children:r.map(e=>{let t=On(e.merged,e.runs);return Y(`tr`,{children:[Y(`td`,{class:`strong`,children:Dn(e.workflow)}),Y(`td`,{class:`mono`,children:e.origin||`registry`}),Y(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:[t,`%`,Y(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),Y(jn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),Y(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),Y(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:Y(`h2`,{class:`card-title`,children:`Per workflow`})})}),Y(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 Y(`div`,{class:`card wf-stage-card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:Y(`h2`,{class:`card-title`,children:`Per stage`})})}),Y(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 Y(`div`,{class:`grid grid-2 wf-stage-card`,children:[Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Slowest stages`}),Y(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Stage`}),Y(`th`,{children:`Runs`}),Y(`th`,{children:`Avg duration`})]})}),Y(`tbody`,{children:n.map((e,n)=>Y(`tr`,{children:[Y(`td`,{children:Dn(e.workflow)}),Y(`td`,{class:`strong`,children:e.stage}),Y(`td`,{children:e.runs}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:kn(e.avg_ms)}),Y(jn,{fraction:On(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Most failures`}),Y(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Stage`}),Y(`th`,{children:`Failures`})]})}),Y(`tbody`,{children:r.map((e,t)=>Y(`tr`,{children:[Y(`td`,{children:Dn(e.workflow)}),Y(`td`,{class:`strong`,children:e.stage}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),Y(jn,{fraction:On(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):Y(An,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Ln({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Rn(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function zn(){let[e,t]=W([]),[n,r]=W(null),i=async()=>{try{let e=await J.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return G(()=>{i()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Channels`}),Y(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),Y(`div`,{className:`grid grid-2`,children:n?Y(Ln,{title:`Cannot reach archied`,detail:n}):e.length===0?Y(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=>Y(`div`,{className:`card channel-card`,children:[Y(`div`,{className:`card-head`,children:[Y(`h3`,{className:`card-title`,children:e.name}),Y(Q,{text:e.state||(e.configured?`configured`:`stopped`),kind:Rn(e.state,e.configured)})]}),Y(`p`,{className:`channel-desc`,children:e.description}),Y(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?Y(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await J.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):Y(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Bn(e){return Y(zn,{query:e})}function Vn({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Hn(e){return Y(Un,{query:e})}function Un({query:e}){let[t,n]=W([]),[r,i]=W(null),a=async()=>{try{let e=await J.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return G(()=>{a()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Curators`}),Y(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),Y(`div`,{className:`grid grid-2`,children:r?Y(Vn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>Y(Gn,{curator:e},e.name)):Y(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 Y(`div`,{className:`card curator-card`,children:[Y(`div`,{className:`card-head`,children:[Y(`h3`,{className:`card-title`,children:e.name}),Y(Q,{text:e.health?.status||`unknown`,kind:Wn(e.health?.status)})]}),e.health?.message&&Y(`p`,{className:`curator-health-message`,children:e.health.message}),Y(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${Z(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?Y(`ul`,{className:`curator-actions`,children:t.map((e,t)=>Y(`li`,{className:`curator-action`,children:[Y(`div`,{className:`curator-action-head`,children:[Y(`span`,{className:`curator-action-type`,children:e.type||`action`}),Y(`span`,{className:`curator-action-time`,children:Z(e.at)})]}),e.detail&&Y(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&Y(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):Y(`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]=W(!1),[o,s]=W(``),[c,l]=W(null),[u,d]=W(!1),[f,p]=W(!1),m=n?.key;if(!m)return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n?.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return Y(`div`,{className:`kv is-locked`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Y(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`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 J.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=>J.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=K(null);G(()=>{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`?Y(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[Y(`option`,{value:`true`,children:`true`}),Y(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?Y(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>Y(`option`,{value:e,children:e},e))}):Y(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),i,Y(`div`,{className:`kv-actions`,children:[Y(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),Y(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&Y(`span`,{className:`kv-note is-error`,children:c})]})}return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Y(`div`,{className:`kv-actions`,children:[g&&Y(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),Y(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&Y(`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&&Y(`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 Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Xn({sub:e,title:t,children:n}){return Y(`div`,{className:`card cfg-section`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:t||`Update status`}),Y(`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?Y(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:Y(Yn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):Y(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:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Component`}),Y(`th`,{children:`Install type`}),Y(`th`,{children:`Running`}),Y(`th`,{children:`Latest available`}),Y(`th`,{children:`Status`})]})}),Y(`tbody`,{children:e.map(e=>Y(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` +`),children:[Y(`td`,{className:`strong`,children:e.label||e.id}),Y(`td`,{className:`mono`,children:e.install_type||`—`}),Y(`td`,{className:`mono`,children:e.running_version||`—`}),Y(`td`,{className:`mono`,children:e.latest_available||`—`}),Y(`td`,{children:Y(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function er({title:e,sub:t,children:n}){return Y(`div`,{className:`card cfg-section`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:e}),Y(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr({origins:e}){return e?.length?Y(er,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Y(`div`,{className:`kv-list`,children:e.map((e,t)=>Y(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Y(er,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Y($,{title:`Source provenance is unavailable.`})})}function nr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function rr({data:e,error:t}){if(t)return Y(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Y($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Y(er,{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:[Y(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Y(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??Ue(e.id),n=e.kind??We(e.id);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(Q,{text:t,kind:n})})]},e.id)})}):Y($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Y(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Y(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=nr(e.kind);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Y($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ir({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?Y(`td`,{children:[Y(`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 J.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{children:c?`yes`:`no`})}function ar({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?Y(`td`,{children:[Y(`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 J.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&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{className:`mono`,children:i})}function or({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return Y(er,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Y($,{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 Y(er,{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:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Repository`}),Y(`th`,{children:`Base branch`}),Y(`th`,{children:`Ecosystem`}),Y(`th`,{children:`Quality gate`}),Y(`th`,{children:`Protected paths`}),Y(`th`,{children:`Concurrent`}),Y(`th`,{children:`Max retries`}),Y(`th`,{children:`Self-review`})]})}),Y(`tbody`,{children:e.map((e,i)=>Y(`tr`,{children:[Y(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Y(`td`,{className:`mono`,children:e.base}),Y(`td`,{children:e.ecosystem||`go`}),Y(`td`,{className:`mono`,children:r(e.gate)}),Y(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Y(ir,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),Y(ar,{r:e,field:`max_retries`,onSaved:t,editable:n}),Y(ir,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function sr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function cr({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return Y(er,{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:[Y(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?Y(`div`,{className:`kv-list`,children:n.map(([e,t])=>Y(qn,{label:sr(e),value:t},e))}):Y($,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),Y(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Provider`}),Y(`th`,{children:`Class`}),Y(`th`,{children:`Base URL`}),Y(`th`,{children:`API key env var`}),Y(`th`,{children:`Status`})]})}),Y(`tbody`,{children:r.map(([e,t])=>Y(`tr`,{children:[Y(`td`,{className:`strong`,children:e}),Y(`td`,{children:t.class}),Y(`td`,{className:`mono`,children:t.base_url||`default`}),Y(`td`,{className:`mono`,children:t.api_key_env||`—`}),Y(`td`,{children:t.configured?Y(Q,{text:`configured`,kind:`ok`}):Y(Q,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):Y($,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function lr(){let[e,t]=W(null),[n,r]=W(null),[i,a]=W(null),[o,s]=W(null),[c,l]=W(!1),[u,d]=W(null),[f,p]=W(null),m=()=>{h(),g(),_()},h=async()=>{try{let e=await J.config();t(e),r(null)}catch(e){r(String(e.message||e))}},g=async()=>{try{let e=await J.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},_=async()=>{try{let e=await J.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return G(()=>{m()},[]),Y(`div`,{className:`cfg-page`,children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Configuration`}),Y(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:m,children:`Refresh`})})]}),Y(`div`,{children:!c&&(o?Y(`div`,{className:`card`,children:Y($,{title:`Update status unavailable`,detail:o})}):i?Y($n,{components:i}):null)}),Y(`div`,{children:Y(rr,{data:u,error:f})}),Y(`div`,{children:n?Y(`div`,{className:`card`,children:Y($,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?Y(`div`,{className:`card`,children:Y($,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):Y(S,{children:[e.reload?.overlay_unavailable&&Y(`div`,{className:`card cfg-notice`,children:Y(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&Y(`div`,{className:`card cfg-notice`,children:Y(`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?Y(er,{title:t.label,sub:t.description,children:Y(`div`,{className:`kv-list`,children:r.map(t=>Y(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:h}},t.key))})},n):null}),Y(or,{repos:e.repositories,onSaved:h,editable:e.editable!==!1}),Y(cr,{models:e.models,providers:e.providers}),Y(tr,{origins:e.provenance})]})})]})}function ur(e){return Y(lr,{query:e})}function dr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function fr(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function pr(){let[e,t]=W({level:``,component:``,q:``}),[n,r]=W(!1),[i,a]=W([]),[o,s]=W([]),c=K(new Map),[l,u]=W(0),[d,f]=W(!1),[p,m]=W(`connecting`),[h,g]=W(`Refreshing…`),_=K(null),v=K(null),y=async()=>{g(`Refreshing…`);try{let t=await J.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`)}};G(()=>{y()},[e]),G(()=>{let e=Ne(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(fr(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=K(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=K(x);S.current=x;let C=ge(()=>{let e=new Map;for(let t of o)e.set(fr(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return G(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Logs`}),Y(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),Y(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{className:`log-filters`,children:[Y(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:St.map(e=>Y(`option`,{value:e.value,children:e.label},e.value))}),Y(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[Y(`option`,{value:``,children:`All components`}),i.map(e=>Y(`option`,{value:e,children:e},e))]}),Y(`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)}})]}),Y(`div`,{className:`log-status`,children:[Y(`span`,{className:`log-meta`,children:h}),Y(Q,{text:p,kind:p===`live`?`ok`:`warn`})]})]}),Y(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?Y(dr,{title:`Cannot read logs`}):C.length?C.map(e=>Y(wt,{entry:e},fr(e))):Y(dr,{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 mr(e){return Y(pr,{query:e})}function hr({capture:e,expanded:t,onToggle:n}){return Y(S,{children:[Y(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[Y(`td`,{className:`mono`,children:e.source||`(unknown)`}),Y(`td`,{title:e.received_at||``,children:Z(e.received_at)}),Y(`td`,{children:Y(Q,{text:`Unbound`,kind:`idle`})}),Y(`td`,{className:`mono`,children:e.content_type||`—`}),Y(`td`,{children:Y(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&Y(gr,{capture:e})]})}function gr({capture:e}){return Y(`tr`,{className:`capture-detail-row`,children:Y(`td`,{colSpan:`5`,children:Y(`div`,{className:`capture-detail`,children:[Y(`div`,{className:`capture-detail-section`,children:[Y(`div`,{className:`capture-detail-title`,children:`Payload`}),Y(_r,{raw:e.body})]}),Y(`div`,{className:`capture-detail-section`,children:[Y(`div`,{className:`capture-detail-title`,children:`Headers`}),Y(_r,{raw:e.headers})]})]})})})}function _r({raw:e}){return e?Y(`pre`,{className:`capture-payload`,children:vr(e)}):Y(`div`,{className:`capture-empty`,children:`(empty)`})}function vr(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function yr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function br(e){return Y(xr,{query:e})}function xr({query:e}){let[t,n]=W([]),[r,i]=W(null),[a,o]=W(null),[s,c]=W(!0),[l,u]=W({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await J.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return G(()=>{d();let e=Me(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Event inspector`}),Y(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),Y(`div`,{className:`page-actions`,children:[Y(Q,{text:l.text,kind:l.kind}),Y(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),Y(`div`,{className:`card`,children:a?Y(yr,{title:`Cannot reach archied`,detail:a}):s?t.length?Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(hr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):Y(yr,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):Y(yr,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var Sr=[`string`,`number`,`bool`,`object`,`array`,`any`];function Cr(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 wr(e,t){return e?`${e}.${t}`:t}function Tr(e,t){return`${e}[${t}]`}function Er({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?Y(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Tr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,wr(t,e)])).map(([e,t,n])=>Y(`li`,{className:`mapping-tree-item`,children:[Y(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:Cr(t),name:e})},children:e}),Y(Er,{value:t,path:n,name:e,onPick:r})]},n))}):Y(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:Cr(e),name:n})},children:JSON.stringify(e)})}function Dr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return Y(`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 Y(`table`,{className:`table mapping-fields-table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:e.map((e,s)=>Y(`tr`,{children:[Y(`td`,{children:Y(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),Y(`td`,{className:`mono`,children:e.path}),Y(`td`,{children:Y(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Sr.map(e=>Y(`option`,{value:e,children:e},e))})}),Y(`td`,{children:Y(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),Y(`td`,{children:Y(Or,{field:e,preview:t,failureByField:o})}),Y(`td`,{children:Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Or({field:e,preview:t,failureByField:n}){if(!t)return Y(Q,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?Y(Q,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?Y(Q,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):Y(Q,{text:`skipped (optional)`,kind:`idle`})}function kr({mapping:e,onEdit:t,onDelete:n}){return Y(`tr`,{children:[Y(`td`,{children:e.name}),Y(`td`,{className:`mono`,children:e.source_hint||`—`}),Y(`td`,{children:String(e.fields?.length??0)}),Y(`td`,{children:[Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Ar({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function jr(e){return Y(Mr,{query:e})}function Mr({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W(null),[s,c]=W(null),l=async()=>{try{let[e,t]=await Promise.all([J.mappings(),J.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};G(()=>{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 J.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?Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:Y(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),Y(`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 J.mappingUpdate(s.id,e):await J.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&Y(`div`,{className:`mapping-error`,children:s.actionError}),Y(`div`,{className:`card mapping-form`,children:[Y(`label`,{className:`mapping-form-row`,children:[`Name`,Y(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),Y(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,Y(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),Y(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,Y(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[Y(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>Y(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),Y(`div`,{className:`card mapping-fields`,children:[Y(`div`,{className:`mapping-section-title`,children:`Bound fields`}),Y(Dr,{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})}),Y(`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 J.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),Y(`div`,{className:`card mapping-payload`,children:[Y(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?Y(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?Y(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):Y(Er,{value:s.payload,onPick:m})]})]}):Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Field mappings`}),Y(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?Y(Ar,{title:`Cannot reach archied`,detail:a}):t.length?Y(`div`,{className:`card`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(kr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):Y(Ar,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var Nr={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Pr={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Fr({status:e}){return Y(Q,{text:Nr[e]||e,kind:Pr[e]||`idle`})}function Ir({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return Y(`tr`,{children:[Y(`td`,{children:e.name}),Y(`td`,{className:`mono`,children:e.matcher?.source||`—`}),Y(`td`,{children:e.workflow}),Y(`td`,{className:`mono`,children:i}),Y(`td`,{children:Y(Fr,{status:e.status})}),Y(`td`,{children:[Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&Y(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function Lr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Rr(e){return Y(Br,{query:e})}function zr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Br({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W([]),[s,c]=W(null),[l,u]=W(null),d=async()=>{try{let[e,t,r]=await Promise.all([J.bindings(),J.mappings(),J.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};G(()=>{d()},[]);let f=()=>{u(zr())},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 J.bindingUpdate(l.id,e):await J.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await J.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await J.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:Y(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&Y(`div`,{className:`binding-error`,children:l.actionError}),Y(`div`,{className:`card binding-form`,children:[Y(`label`,{className:`binding-form-row`,children:[`Name`,Y(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,Y(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Field mapping`,Y(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[Y(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>Y(`option`,{value:e.id,children:e.name},e.id))]})]}),Y(`label`,{className:`binding-form-row`,children:[`Workflow`,Y(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[Y(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>Y(`option`,{value:e.id,children:e.name},e.id))]})]}),Y(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,Y(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,Y(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,Y(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Playbook bindings`}),Y(`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.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?Y(Lr,{title:`Cannot reach archied`,detail:s}):t.length?Y(`div`,{className:`card`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(Ir,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):Y(Lr,{title:`No bindings yet`,detail:`Create one from a saved field mapping to turn a captured webhook into a workflow.`})]})}var Vr=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;function Hr(e){let t=[],n=0,r=0;for(let i of String(e).matchAll(Vr)){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith(`![`)){let e=a.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.push(Y(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(Y(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(Y(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(Y(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(Y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(Y(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(Y(`p`,{children:Hr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>Y(`li`,{children:Hr(e)},t));n.push(a.tag===`ol`?Y(`ol`,{children:e},s++):Y(`ul`,{children:e},s++)),a=null};for(let e=0;eY(`th`,{children:Hr(e)},t))})}),Y(`tbody`,{children:t.map((e,t)=>Y(`tr`,{children:e.map((e,t)=>Y(`td`,{children:Hr(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(Y(e,{children:Hr(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(Y(`blockquote`,{children:Hr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(Y(`pre`,{children:Y(`code`,{children:o.join(` +`)})},s++)),Y(`div`,{className:t,children:n})}function Wr(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 Gr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Kr=`archie.web.chat.channel`;function qr(){let e=localStorage.getItem(Kr);return e||(e=Te(),localStorage.setItem(Kr,e)),e}function Jr(e){return{text:e,sourceID:Te()}}function Yr(e){return{...e}}function Xr(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?Yr(e.turn):Jr(r),isRetry:n}}function Zr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Qr(){return location.hash.slice(1)||`/`}function $r(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),j=K(null),M=K(null),N=K(null),P=K(null),F=K(null),I=K(u);I.current=u,G(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[i,k]),G(()=>{L().catch(e=>{l(e.message||`Chat unavailable`)});let e=()=>{N.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),N.current?.abort()}},[]);async function L(){let e=await J.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),!n&&r[0]&&await R(r[0].session_id,e,r)}async function R(e,t,n){let i=t||f;r(e),a([]),A(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await J.chatMessage(qr(),`/resume ${e}`);let[t,n]=await Promise.all([J.chatMessages(e),J.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});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function z(e){if(n)try{l(`Working…`);let t=await J.chatMessage(qr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await L(),(t.session_id||n)&&await R(t.session_id||n),P.current&&(P.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function ee(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function te(e){let t=e.target.value;h(t),!(!n||!t)&&J.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function ne(e){let t=e.target.value;if(_(t),t)try{let e=await J.chatMessage(qr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await L()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function re(e){let t=e.target.value;if(y(t),t)try{let e=await J.chatMessage(qr(),`/model ${t}`);l(e.reply||`Model updated`),await L()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ie(){s(`/new`),H({textOverride:`/new`})}function B(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function V(e){let t=C[e];if(!t||!M.current)return;let n=M.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]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function ae(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===o.trim())){e.preventDefault(),O(!1),H();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),V(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}async function H(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:c}=Xr(e,t===void 0?o:t);if(!n||I.current)return;O(!1),d(!0),l(c?`Retrying…`:`Thinking…`),c||(a(e=>[...e,{from:`web`,text:n}]),s(``));let u=[];A({text:``,tools:[],isError:!1,turn:i,isRetry:c});let f=``,p=!1,m=!1,h=null;try{let e=new AbortController;N.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await J.chatStream({channel_id:qr(),source_id:i.sourceID,text:i.text,page:Qr()},{signal:e.signal})).body.getReader(),n=new TextDecoder,o=``;for(;;){let{value:e,done:i}=await t.read();o+=n.decode(e||new Uint8Array,{stream:!i});let a=o.split(` `);o=a.pop()||``;for(let e of a){let t=e.split(` -`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,z(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),z(null),l(`Ready`),await le()}catch(e){if(e.name===`AbortError`&&!m)z({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;z({text:t,tools:u,isError:!0,turn:qr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),V.current=null,d(!1),B.current&&B.current.focus()}}function xe(){l(`Stopping…`),n&&Y.chatCancel(n).catch(()=>{}),V.current?.abort()}let Se=f.models_by_provider||{},Ce=g&&Se[g]?Se[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ge,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ie,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:pe,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:me,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:he,children:[X(`option`,{value:``,children:`Model`}),Ce.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:ae,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:oe,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&N&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:F,onChange:e=>I(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`rollback`,F),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:L,onInput:e=>ee(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`stop`,L),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:_e,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>ue(e.session_id),children:[X(`strong`,{children:Yr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will appear here.`})})]}),X(`section`,{className:`chat-workspace`,children:[X(`div`,{className:`chat-workspace-head`,children:[X(`span`,{className:`chat-workspace-label`,children:`PERSONAL ASSISTANT`}),X(`details`,{className:`chat-command-help`,children:[X(`summary`,{children:[`Available commands (`,b.length,`)`]}),X(`div`,{className:`chat-command-list`,children:b.length?b.map(e=>X(`div`,{className:`chat-command-item`,children:[X(`code`,{children:e.usage||e.command}),X(`span`,{children:e.description||``})]},e.command)):X(`span`,{children:`Send a message to begin.`})})]}),X(`details`,{className:`chat-session-tools`,ref:ne,hidden:!n,children:[X(`summary`,{children:`Session actions`}),X(`div`,{className:`chat-session-tool-list`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>de(`/retry`),children:`Retry`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>de(`/undo`),children:`Undo`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/title`,`Session title`),children:`Rename`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/branch`,`Branch name (optional)`),children:`Branch`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>de(`/compress --preview`),children:`Preview compression`})]})]})]}),X(`div`,{className:`chat-transcript`,ref:te,children:!i.length&&!R?X(`div`,{className:`chat-empty-state`,children:[X(`span`,{className:`chat-empty-mark`,children:`A`}),X(`h2`,{children:`What are we working on?`}),X(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),X(`div`,{className:`chat-prompt-grid`,children:[X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Summarise active tasks`),B.current?.focus()},children:`Summarise active tasks`}),X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Show running agents`),B.current?.focus()},children:`Show running agents`}),X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Check system status`),B.current?.focus()},children:`Check system status`})]})]}):X(S,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return X(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:X(`div`,{className:`chat-bubble`,children:[X(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?X(S,{children:[a.length>0&&X(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return X(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[X(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),X(`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 X(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[X(`span`,{className:`chat-tool-icon`,children:`🔧`}),X(`span`,{className:`chat-tool-name`,children:n}),r&&X(`code`,{className:`chat-tool-parameters`,children:r}),X(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),X(Vr,{text:r})]}):X(`div`,{className:`chat-bubble-text`,children:r})]})},t)}),R&&X(`div`,{className:`chat-bubble-row assistant`,children:X(`div`,{className:`chat-bubble`,children:[X(`div`,{className:`chat-bubble-meta`,children:`Archie`}),R.tools?.length>0&&X(`div`,{className:`chat-tools`,children:R.tools.map((e,t)=>{if(e.path)return X(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[X(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),X(`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 X(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[X(`span`,{className:`chat-tool-icon`,children:`🔧`}),X(`span`,{className:`chat-tool-name`,children:n}),r&&X(`code`,{className:`chat-tool-parameters`,children:r}),X(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),X(Vr,{text:R.text||`…`}),R.isError&&X(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>q({turn:R.turn}),children:`Retry`})]})})]})}),X(`div`,{className:`chat-compose`,children:X(`div`,{className:`chat-composer-shell`,children:[X(`textarea`,{ref:B,className:`chat-composer`,rows:3,placeholder:`Message Archie… (commands like /status and /new work here)`,"aria-label":`Message Archie`,disabled:u,value:o,onInput:ve,onKeyDown:be}),D&&C.length>0&&X(`div`,{className:`chat-command-menu`,ref:re,role:`listbox`,"aria-label":`Commands`,children:C.map((e,t)=>X(`button`,{type:`button`,role:`option`,"aria-selected":String(t===T),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>ye(t),children:[X(`code`,{children:e.command}),X(`span`,{children:e.description||e.usage||``})]},e.command))}),X(`div`,{className:`chat-compose-actions`,children:[X(`span`,{className:`chat-hint`,children:`Enter to send · Shift+Enter for a new line`}),X(`button`,{className:`btn`,type:`button`,disabled:!u,onClick:xe,children:`Stop`}),X(`button`,{className:`btn btn-primary`,type:`button`,disabled:u||!o.trim(),onClick:()=>q(),children:`Send`})]})]})})]})]})]})}function $r(){return X(Qr,{})}function ei(e,t){let n=ni(t);for(let t of e){let e=ri(t.path,n);if(e)return{route:t,params:e}}return null}function ti(e){return e?.navPath||e?.path||`/`}function ni(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function ri(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 li({activePath:e,hidden:t,onNavigate:n,chatOpen:r,onToggleChat:i,theme:a,onToggleTheme:o}){let[s,c]=W(!1),l=K(null),u=()=>c(!1);return X(`header`,{className:`topbar`,children:[X(`div`,{className:`brand`,children:[X(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),X(`nav`,{className:`nav`,children:ci(t).map(t=>X(`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:[X(Z,{name:t.icon}),X(`span`,{className:`nav-label`,children:t.label}),t.soon?X(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),X(`div`,{className:`topbar-end`,children:[X(`div`,{className:`topbar-search${s?` is-open`:``}`,children:[X(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:X(Z,{name:`search`,size:15})}),X(`button`,{className:`icon-btn mobile-search-toggle`,type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":s?`true`:`false`,onClick:()=>{c(!0),l.current?.focus()},children:X(Z,{name:`search`,size:15})}),X(`input`,{ref:l,type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),u(),e.target.blur();return}if(e.key!==`Enter`)return;let t=e.target.value.trim().toLowerCase(),r=ii.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),u())}})]}),X(`button`,{className:`icon-btn icon-btn-chat`,"aria-label":`Open chat`,title:`Chat with Archie`,"aria-expanded":r?`true`:`false`,onClick:()=>i(),children:X(Z,{name:`chat`})}),X(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:X(Z,{name:`help`})}),X(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:o,children:X(Z,{name:a===`dark`?`moon`:`sun`})}),X(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}function ui({open:e,onClose:t}){return X(`aside`,{className:`chat-drawer${e?` is-open`:``}`,"aria-label":`Chat with Archie`,children:[X(`div`,{className:`chat-drawer-panel`,children:[X(`div`,{className:`chat-drawer-head`,children:[X(`strong`,{children:`Archie`}),X(`button`,{className:`icon-btn chat-drawer-close`,"aria-label":`Close chat`,title:`Close chat`,onClick:t,children:X(Z,{name:`close`})})]}),X($r,{})]}),X(`div`,{className:`chat-scrim`,onClick:t})]})}function di({label:e}){return X(`div`,{children:[X(`div`,{className:`page-head`,children:X(`div`,{children:X(`h1`,{className:`page-title`,children:e})})}),X(`div`,{className:`card`,children:X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`${e} is not built yet`}),X(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function fi({view:e,search:t,params:n}){return e(t,n)}var pi=null,mi=null;function hi(e){if(!pi)return;let[t,n=``]=String(e).split(`?`,2),r=ei(ii,t),i=r?.route||ii[0],a=r?.params||{};if(i.path===`/chat`){ne(null,pi);return}ne(i.view?X(fi,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):X(di,{label:i.label}),pi)}function gi(e){let[t]=String(e).split(`?`,2),n=ei(ii,t)?.route||ii[0];pi?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),mi?.setActive(ti(n)),mi?.setChatOpen(n.path===`/chat`),hi(e)}function _i(e){location.hash===`#${e}`?gi(e):location.hash=e}window.addEventListener(`hashchange`,()=>gi(location.hash.slice(1)||`/`)),window.addEventListener(`keydown`,e=>{e.defaultPrevented||e.key===`Escape`&&mi?.setChatOpen(!1)});function vi(){let[e,t]=W(`/`),[n,r]=W(oi),[i,a]=W(!1),[o,s]=W([]),c=_e(e=>{pi=e,mi={setActive:t,setChatOpen:a}},[]);return G(()=>{si(n)},[n]),G(()=>{document.body.classList.toggle(`chat-open`,i)},[i]),G(()=>{Y.capabilities().then(e=>s(Ne(e?.sections,ii))).catch(()=>{})},[]),G(()=>{Ve().then(()=>hi(location.hash.slice(1)||`/`))},[]),X(`div`,{className:`shell`,children:[X(li,{activePath:e,hidden:o,onNavigate:_i,chatOpen:i,onToggleChat:()=>a(e=>!e),theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),X(`main`,{className:`main`,ref:c}),X(ui,{open:i,onClose:()=>a(!1)})]})}si(oi()),ne(X(vi,{}),document.getElementById(`app`)),gi(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&&r(n.session_id),n.type===`delta`&&(f+=n.text,A(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),A(null),l(`Ready`),await L()}catch(e){if(e.name===`AbortError`&&!m)A({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;A({text:t,tools:u,isError:!0,turn:Yr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),N.current=null,d(!1),M.current&&M.current.focus()}}function oe(){l(`Stopping…`),n&&J.chatCancel(n).catch(()=>{}),N.current?.abort()}let se=f.models_by_provider||{},U=g&&se[g]?se[g]:f.models||[];return Y(`div`,{className:`chat-panel-content`,children:[Y(`div`,{className:`chat-bar`,children:[Y(`label`,{className:`chat-session-switch`,children:[Y(`span`,{className:`sr-only`,children:`Conversation`}),Y(`select`,{value:n,onChange:e=>R(e.target.value),disabled:!e.length,children:e.length?e.map(e=>Y(`option`,{value:e.session_id,children:Zr(e)},e.session_id)):Y(`option`,{value:``,children:`No conversations yet`})})]}),Y(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:ie,children:`+`}),Y(`details`,{className:`chat-settings`,children:[Y(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:Y(`span`,{"aria-hidden":`true`,children:`⚙`})}),Y(`div`,{className:`chat-settings-body`,children:[Y(`span`,{className:`chat-status`,children:c}),Y(`label`,{children:[`Personality`,Y(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:te,children:[Y(`option`,{value:``,children:`Default`}),(f.personas||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),(f.providers||[]).length>0&&Y(`label`,{children:[`Provider`,Y(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:ne,children:[Y(`option`,{value:``,children:`Default`}),(f.providers||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),Y(`label`,{children:[`Model`,Y(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:re,children:[Y(`option`,{value:``,children:`Default`}),U.map(e=>Y(`option`,{value:e,children:e},e))]})]})]})]})]}),Y(`div`,{className:`chat-layout`,children:Y(`section`,{className:`chat-workspace`,children:[Y(`div`,{className:`chat-workspace-head`,children:[Y(`details`,{className:`chat-command-help`,children:[Y(`summary`,{children:[`Available commands (`,b.length,`)`]}),Y(`div`,{className:`chat-command-list`,children:b.length?b.map(e=>Y(`div`,{className:`chat-command-item`,children:[Y(`code`,{children:e.usage||e.command}),Y(`span`,{children:e.description||``})]},e.command)):Y(`span`,{children:`Send a message to begin.`})})]}),Y(`details`,{className:`chat-session-tools`,ref:P,hidden:!n,children:[Y(`summary`,{children:`Session actions`}),Y(`div`,{className:`chat-session-tool-list`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/title`,`Session title`),children:`Rename`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/branch`,`Branch name (optional)`),children:`Branch`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})]}),Y(`div`,{className:`chat-transcript`,ref:j,children:!i.length&&!k?Y(`div`,{className:`chat-empty-state`,children:[Y(`span`,{className:`chat-empty-mark`,children:`A`}),Y(`h2`,{children:`What are we working on?`}),Y(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),Y(`div`,{className:`chat-prompt-grid`,children:[Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Summarise active tasks`),M.current?.focus()},children:`Summarise active tasks`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Show running agents`),M.current?.focus()},children:`Show running agents`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Check system status`),M.current?.focus()},children:`Check system status`})]})]}):Y(S,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return Y(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:Y(`div`,{className:`chat-bubble`,children:[Y(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?Y(S,{children:[a.length>0&&Y(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return Y(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Y(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Y(`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 Y(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[Y(`span`,{className:`chat-tool-icon`,children:`🔧`}),Y(`span`,{className:`chat-tool-name`,children:n}),r&&Y(`code`,{className:`chat-tool-parameters`,children:r}),Y(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Y(Ur,{text:r})]}):Y(`div`,{className:`chat-bubble-text`,children:r})]})},t)}),k&&Y(`div`,{className:`chat-bubble-row assistant`,children:Y(`div`,{className:`chat-bubble`,children:[Y(`div`,{className:`chat-bubble-meta`,children:`Archie`}),k.tools?.length>0&&Y(`div`,{className:`chat-tools`,children:k.tools.map((e,t)=>{if(e.path)return Y(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Y(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Y(`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 Y(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[Y(`span`,{className:`chat-tool-icon`,children:`🔧`}),Y(`span`,{className:`chat-tool-name`,children:n}),r&&Y(`code`,{className:`chat-tool-parameters`,children:r}),Y(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Y(Ur,{text:k.text||`…`}),k.isError&&Y(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>H({turn:k.turn}),children:`Retry`})]})})]})}),Y(`div`,{className:`chat-compose`,children:Y(`div`,{className:`chat-composer-shell`,children:[Y(`textarea`,{ref:M,className:`chat-composer`,rows:3,placeholder:`Message Archie, or type / for commands`,"aria-label":`Message Archie`,disabled:u,value:o,onInput:B,onKeyDown:ae}),D&&C.length>0&&Y(`div`,{className:`chat-command-menu`,ref:F,role:`listbox`,"aria-label":`Commands`,children:C.map((e,t)=>Y(`button`,{type:`button`,role:`option`,"aria-selected":String(t===T),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>V(t),children:[Y(`code`,{children:e.command}),Y(`span`,{children:e.description||e.usage||``})]},e.command))}),Y(`div`,{className:`chat-compose-actions`,children:[Y(`span`,{className:`chat-hint`,children:`Enter to send · Shift+Enter for a new line`}),Y(`button`,{className:`btn`,type:`button`,disabled:!u,onClick:oe,children:`Stop`}),Y(`button`,{className:`btn btn-primary`,type:`button`,disabled:u||!o.trim(),onClick:()=>H(),children:`Send`})]})]})})]})})]})}function ei(e,t){let n=ni(t);for(let t of e){let e=ri(t.path,n);if(e)return{route:t,params:e}}return null}function ti(e){return e?.navPath||e?.path||`/`}function ni(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function ri(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 li({activePath:e,hidden:t,onNavigate:n,theme:r,onToggleTheme:i}){let[a,o]=W(!1),s=K(null),c=()=>o(!1);return Y(`header`,{className:`topbar`,children:[Y(`div`,{className:`brand`,children:[Y(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),Y(`nav`,{className:`nav`,children:ci(t).map(t=>Y(`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:[Y(X,{name:t.icon}),Y(`span`,{className:`nav-label`,children:t.label}),t.soon?Y(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),Y(`div`,{className:`topbar-end`,children:[Y(`div`,{className:`topbar-search${a?` is-open`:``}`,children:[Y(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:Y(X,{name:`search`,size:15})}),Y(`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:Y(X,{name:`search`,size:15})}),Y(`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=ii.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),c())}})]}),Y(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:Y(X,{name:`help`})}),Y(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:i,children:Y(X,{name:r===`dark`?`moon`:`sun`})}),Y(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}var ui=`chat-panel`;function di(){let[e,t]=W(!1),n=K(null),r=_e(()=>{t(!1),n.current?.focus()},[]);return G(()=>{if(!e)return;let t=e=>{e.defaultPrevented||e.key!==`Escape`||r()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),Y(`div`,{className:`chat-dock${e?` is-open`:``}`,children:[Y(`aside`,{className:`chat-drawer${e?` is-open`:``}`,id:ui,"aria-label":`Chat with Archie`,"aria-hidden":e?void 0:`true`,children:Y(`div`,{className:`chat-drawer-panel`,children:[Y(`div`,{className:`chat-drawer-head`,children:[Y(`strong`,{children:`Archie`}),Y(`button`,{className:`icon-btn chat-drawer-close`,"aria-label":`Close chat`,title:`Close chat`,onClick:r,children:Y(X,{name:`close`})})]}),Y($r,{})]})}),Y(`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":ui,onClick:()=>e?r():t(!0),children:[Y(`span`,{className:`chat-fab-icon chat-fab-icon-open`,"aria-hidden":`true`,children:Y(X,{name:`chat`,size:22})}),Y(`span`,{className:`chat-fab-icon chat-fab-icon-close`,"aria-hidden":`true`,children:Y(X,{name:`close`,size:22})})]})]})}function fi({label:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:Y(`div`,{children:Y(`h1`,{className:`page-title`,children:e})})}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`${e} is not built yet`}),Y(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function pi({view:e,search:t,params:n}){return e(t,n)}var mi=null,hi=null;function gi(e){if(!mi)return;let[t,n=``]=String(e).split(`?`,2),r=ei(ii,t),i=r?.route||ii[0],a=r?.params||{};ie(i.view?Y(pi,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):Y(fi,{label:i.label}),mi)}function _i(e){let[t]=String(e).split(`?`,2),n=ei(ii,t)?.route||ii[0];mi?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),hi?.setActive(ti(n)),gi(e)}function vi(e){location.hash===`#${e}`?_i(e):location.hash=e}window.addEventListener(`hashchange`,()=>_i(location.hash.slice(1)||`/`));function yi(){let[e,t]=W(`/`),[n,r]=W(oi),[i,a]=W([]),o=_e(e=>{mi=e,hi={setActive:t}},[]);return G(()=>{si(n)},[n]),G(()=>{J.capabilities().then(e=>a(Pe(e?.sections,ii))).catch(()=>{})},[]),G(()=>{He().then(()=>gi(location.hash.slice(1)||`/`))},[]),Y(S,{children:[Y(`div`,{className:`shell`,children:[Y(li,{activePath:e,hidden:i,onNavigate:vi,theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),Y(`main`,{className:`main`,ref:o})]}),Y(di,{})]})}si(oi()),ie(Y(yi,{}),document.getElementById(`app`)),_i(location.hash.slice(1)||`/`); \ No newline at end of file diff --git a/ui/src/chat/chat.css b/ui/src/chat/chat.css index fe93a1b07..f8de3807a 100644 --- a/ui/src/chat/chat.css +++ b/ui/src/chat/chat.css @@ -1,8 +1,120 @@ -.chat-page-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; } -.chat-topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; } -.chat-kicker, .chat-workspace-label { color: var(--fg-muted); font-size: .68rem; font-weight: 700; letter-spacing: .12em; } -.chat-topbar-actions { display: flex; align-items: center; gap: .55rem; } -.chat-topbar-actions .chat-select { max-width: 14rem; min-width: 0; } +/* The panel's own column. ChatApp is mounted in a ~440px launcher panel, never + on a page, so there is one column and every row earns its height + (archie-core-hesx). */ +.chat-panel-content { + display: grid; + grid-template-rows: auto minmax(0, 1fr); + flex: 1 1 auto; + min-height: 0; + overflow: hidden; +} + +/* One row for everything that is not the conversation: which conversation, + a new one, and the model controls folded away behind a disclosure. */ +.chat-bar { + display: flex; + align-items: center; + gap: var(--sp-2); + padding: var(--sp-2) var(--sp-3); + border-bottom: 1px solid var(--border); +} + +.chat-session-switch { + flex: 1 1 auto; + min-width: 0; +} + +.chat-session-switch select { + width: 100%; + background: var(--surface-hover); + 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 { + position: relative; + flex: none; +} + +.chat-settings > summary { + display: grid; + place-items: center; + width: 32px; + height: 32px; + border-radius: var(--radius-sm); + color: var(--fg-muted); + cursor: pointer; + list-style: none; +} + +.chat-settings > summary::-webkit-details-marker { + display: none; +} + +.chat-settings > summary:hover { + background: var(--surface-hover); + color: var(--fg); +} + +/* Opens over the transcript rather than pushing it down: the panel is short + and the conversation should not jump when the controls are consulted. */ +.chat-settings-body { + position: absolute; + top: calc(100% + var(--sp-2)); + right: 0; + z-index: 2; + display: grid; + 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); +} + +.chat-settings-body label { + display: grid; + gap: var(--sp-1); + font-size: var(--text-xs); + color: var(--fg-muted); +} + +.chat-settings-body .chat-select { + width: 100%; +} + +.chat-layout { + display: grid; + min-height: 0; + overflow: hidden; +} + +.chat-workspace { + display: grid; + grid-template-rows: auto minmax(0, 1fr) auto; + min-width: 0; + overflow: hidden; +} + +.chat-workspace-head { + display: flex; + 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); +} + .chat-update-panel { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 .75rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: .75rem; color: var(--fg-muted); font-size: .8rem; } .chat-update-panel > div:first-child { display: grid; gap: .2rem; } .chat-update-panel strong { color: var(--fg); } @@ -15,27 +127,21 @@ .chat-dangerous-input { min-width: 0; flex: 1; padding: .5rem .65rem; background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; font: inherit; } .chat-dangerous-pending-list { display: grid; gap: .45rem; margin-top: .75rem; } .chat-dangerous-pending { padding-top: .55rem; border-top: 1px solid var(--border); color: var(--fg-muted); font-size: .8rem; } -.chat-layout { display: grid; grid-template-columns: 242px minmax(0, 1fr); gap: .75rem; flex: 1 1 auto; min-height: 0; overflow: hidden; } -.chat-sidebar, .chat-workspace { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; } -.chat-sidebar { padding: .8rem; overflow-y: auto; } -.chat-sidebar-head, .chat-toolbar, .chat-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; } .chat-session-list { display: grid; gap: .35rem; margin-top: 1rem; } .chat-session { display: grid; gap: .25rem; text-align: left; background: transparent; color: var(--fg-muted); border: 1px solid transparent; border-radius: .65rem; padding: .7rem; cursor: pointer; } .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-workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; min-width: 0; } -.chat-workspace-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); } .chat-session-tools { position: relative; margin-left: .6rem; color: var(--fg-muted); font-size: .78rem; } .chat-session-tools summary { cursor: pointer; } .chat-session-tool-list { position: absolute; z-index: 2; right: 0; top: calc(100% + .45rem); display: flex; flex-wrap: wrap; gap: .35rem; width: min(22rem, 72vw); padding: .55rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .65rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); } .chat-select { background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; padding: .5rem .65rem; } -.chat-transcript { overflow: auto; padding: 1.25rem; display: grid; align-content: start; gap: 1rem; } -.chat-empty-state { align-self: center; justify-self: center; width: min(100%, 40rem); padding: 3rem 1rem; text-align: center; } -.chat-empty-mark { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; margin: 0 auto 1rem; border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; } -.chat-empty-state h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.04em; } -.chat-empty-state p { margin: .6rem 0 1.4rem; color: var(--fg-muted); } -.chat-prompt-grid { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; } -.chat-prompt { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; } +.chat-transcript { overflow: auto; padding: var(--sp-4); display: grid; align-content: start; gap: var(--sp-4); } +.chat-empty-state { align-self: center; justify-self: center; width: 100%; padding: var(--sp-5) 0; text-align: center; } +.chat-empty-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin: 0 auto var(--sp-3); border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; } +.chat-empty-state h2 { margin: 0; font-size: var(--text-lg); letter-spacing: -.02em; } +.chat-empty-state p { margin: var(--sp-2) 0 var(--sp-4); color: var(--fg-muted); font-size: var(--text-sm); } +.chat-prompt-grid { display: grid; gap: var(--sp-2); } +.chat-prompt { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); text-align: left; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; } .chat-prompt:hover { color: var(--fg); border-color: var(--border-strong); } .chat-bubble-row { display: flex; } .chat-bubble-row.user { justify-content: flex-end; } @@ -96,7 +202,7 @@ } .chat-nav-chip-icon { font-size: .8rem; line-height: 1; } -.chat-compose { padding: .85rem 1rem 1rem; border-top: 1px solid var(--border); } +.chat-compose { padding: var(--sp-3); border-top: 1px solid var(--border); } .chat-composer-shell { position: relative; padding: .7rem .8rem .55rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; } .chat-composer { width: 100%; min-height: 3.3rem; resize: vertical; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; } .chat-composer:focus { outline: 0; } @@ -105,12 +211,14 @@ .chat-command-option { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .65rem; align-items: center; padding: .5rem .6rem; text-align: left; color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: .45rem; cursor: pointer; } .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 { margin-top: .55rem; } +/* The hint takes the whole first row so Stop and Send always sit together on + the second, rather than the hint pushing Send onto a line of its own. */ +.chat-compose-actions { margin-top: var(--sp-2); flex-wrap: wrap; row-gap: var(--sp-2); justify-content: flex-end; } +.chat-compose-actions .chat-hint { flex: 1 0 100%; font-size: var(--text-xs); color: var(--fg-muted); } .chat-hint, .chat-empty { color: var(--fg-muted); font-size: .78rem; } .chat-command-help { color: var(--fg-muted); font-size: .78rem; margin-right: auto; } .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 { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: .7rem; padding: .3rem 0; } .chat-command-item code { color: var(--fg); } -@media (max-width: 760px) { .chat-topbar, .chat-topbar-actions { align-items: flex-start; flex-direction: column; } .chat-layout { grid-template-columns: 1fr; } .chat-sidebar { max-height: 14rem; overflow: auto; } } @media (max-width: 520px) { .chat-update-panel { align-items: flex-start; flex-direction: column; } } diff --git a/ui/src/chat/chat.jsx b/ui/src/chat/chat.jsx index 29555c963..4d9618510 100644 --- a/ui/src/chat/chat.jsx +++ b/ui/src/chat/chat.jsx @@ -5,7 +5,6 @@ import { ChatMarkdown } from "./markdown.jsx"; import { channelID } from "./chat-state.jsx"; import { newChatTurn, retryChatTurn, resolveTurn } from "./chat-retry.jsx"; import { sessionTitle } from "./chat-render.jsx"; -import { updateUnavailableMessage } from "./chat-update-status.jsx"; import "./chat.css"; @@ -31,13 +30,6 @@ export function ChatApp() { const [commandSelection, setCommandSelection] = useState(0); const [isCommandMenuOpen, setIsCommandMenuOpen] = useState(false); - const [updateData, setUpdateData] = useState(null); - const [updateSnapshot, setUpdateSnapshot] = useState(null); - - const [dangerousData, setDangerousData] = useState(null); - const [dangerousCheckpoint, setDangerousCheckpoint] = useState(""); - const [dangerousStopSpec, setDangerousStopSpec] = useState(""); - const [streamingTurn, setStreamingTurn] = useState(null); // streamingTurn: { text: string, tools: [], isError: bool, turn: object, isRetry: bool } @@ -60,7 +52,6 @@ export function ChatApp() { refreshSessions().catch((err) => { setStatusText(err.message || "Chat unavailable"); }); - refreshUpdate(); const onTeardown = () => { activeControllerRef.current?.abort(); @@ -72,75 +63,6 @@ export function ChatApp() { }; }, []); - async function refreshUpdate() { - try { - const data = await api.chatUpdate(); - setUpdateSnapshot(data?.snapshot || null); - setUpdateData(data); - } catch (err) { - const message = updateUnavailableMessage(err); - if (message) { - setUpdateData({ error: message }); - } else { - setUpdateData(null); - } - } - } - - async function deferUpdate() { - if (!updateSnapshot) return; - try { - await api.chatUpdateDefer(updateSnapshot); - setUpdateData({ snapshot: { deferred: true }, available: [] }); - setStatusText("Update deferred"); - } catch (err) { - setStatusText(err.message || "Could not defer update"); - } - } - - async function installUpdate() { - if (!updateSnapshot) return; - try { - setStatusText("Installing…"); - const result = await api.chatUpdateInstall(updateSnapshot); - setUpdateSnapshot(null); - setUpdateData({ snapshot: {}, available: [] }); - setStatusText(result?.result?.restart_requested ? "Update installed; restart queued" : "Update complete"); - } catch (err) { - setStatusText(err.message || "Update install failed"); - } - } - - async function refreshDangerous() { - try { - const data = await api.chatDangerous(); - setDangerousData(data); - } catch (err) { - setDangerousData({ error: err.message || "Dangerous actions unavailable" }); - } - } - - async function requestDangerousAction(kind, spec) { - if (!spec) return; - try { - await api.chatDangerousRequest(kind, spec); - setStatusText("Approval requested"); - await refreshDangerous(); - } catch (err) { - setStatusText(err.message || "Could not request action"); - } - } - - async function decideDangerousAction(id, decision) { - try { - await api.chatDangerousDecision(id, decision); - setStatusText(decision === "deny" ? "Action denied" : "Action approved"); - await refreshDangerous(); - } catch (err) { - setStatusText(err.message || "Approval failed"); - } - } - async function refreshSessions() { const data = await api.chatSessions(); const sessionList = data.sessions || []; @@ -158,10 +80,6 @@ export function ChatApp() { ); setCommandSpecs(specs); - if (data.dangerous_available) { - await refreshDangerous(); - } - if (!currentSession && sessionList[0]) { await selectSession(sessionList[0].session_id, data, sessionList); } @@ -258,12 +176,6 @@ export function ChatApp() { } } - function handleRestartTelegram() { - if (!window.confirm("Reload the Telegram chat adapter?")) return; - setComposerText("/restart"); - sendMessage({ textOverride: "/restart" }); - } - function handleNewChat() { setComposerText("/new"); sendMessage({ textOverride: "/new" }); @@ -487,213 +399,94 @@ export function ChatApp() { : selectorData.models || []; return ( -
-
-
- ARCHIE WORKSPACE -

Chat

-
-
- {statusText} - {selectorData.restart_available && ( - - )} - +
+
+
-
+ - {/* Update Panel */} - {updateData && ( -
- {updateData.error ? ( - {updateData.error} - ) : updateData.available?.length ? ( - -
- Update available - - {updateData.available - .map((c) => `${c.Label || c.label}: ${c.Available || c.available}`) - .join(" · ")} - -
-
- - {updateData.can_install && ( - - )} -
-
- ) : ( - {updateData.snapshot?.deferred ? "Update deferred." : "Archie is up to date."} - )} -
- )} + - {/* Dangerous Panel */} - {selectorData.dangerous_available && dangerousData && ( -
-
- Dangerous actions - Every action requires approval. -
-
-
+
+ + + +
+ {statusText} +
-
- setDangerousStopSpec(e.target.value)} - /> - -
-
-
- {(dangerousData.pending || []).length ? ( - dangerousData.pending.map((action) => ( -
- {action.description} -
- - - -
-
- )) - ) : ( - No pending dangerous actions. - )} -
-
- )} - - {/* Main Layout */} -
- + +
+
- PERSONAL ASSISTANT
Available commands ({commandSpecs.length})
@@ -937,7 +730,7 @@ export function ChatApp() { ref={composerRef} className="chat-composer" rows={3} - placeholder="Message Archie… (commands like /status and /new work here)" + placeholder="Message Archie, or type / for commands" aria-label="Message Archie" disabled={isSending} value={composerText} @@ -993,7 +786,3 @@ export function ChatApp() {
); } - -export function ChatPage() { - return ; -} diff --git a/ui/src/css/base.css b/ui/src/css/base.css index 6613c8227..14d20e354 100644 --- a/ui/src/css/base.css +++ b/ui/src/css/base.css @@ -54,3 +54,17 @@ a { clip-path: inset(50%); white-space: nowrap; } + +/* Visible to assistive technology only. For a control whose purpose is clear + from its position but which still needs a name in the accessibility tree. */ +.sr-only { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} diff --git a/ui/src/css/layout.css b/ui/src/css/layout.css index 97cf889bd..03e76c8cd 100644 --- a/ui/src/css/layout.css +++ b/ui/src/css/layout.css @@ -74,14 +74,28 @@ body { align-items: center; gap: 2px; margin: 0 auto; + /* The nav is the only region that can afford to lose width, so it is the + only one allowed to shrink. min-width:0 lets it actually do so inside a + flex row, and the scroll is the last resort before anything clips -- + .app sets overflow:hidden, so an unshrinkable row loses the utility + cluster off the right edge with no way to reach it. */ + flex: 0 1 auto; + min-width: 0; + overflow-x: auto; + scrollbar-width: none; padding: 3px; border-radius: var(--radius-pill); background: var(--surface-glass-strong); border: 1px solid var(--hairline); } +.nav::-webkit-scrollbar { + display: none; +} + .nav-item { display: inline-flex; + flex: none; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); @@ -192,28 +206,86 @@ body { overflow-x: hidden; } -/* ── Chat drawer ─────────────────────────────────────────────────────── */ -/* The chat is a persistent slide-over, not a route: it is mounted once and - opened from the topbar, so the operator can talk to Archie from any page - without leaving the work that prompted the question. It overlays the - layout rather than replacing it, and the navigation/outlet stay interactive - behind the scrim. */ -.chat-drawer { +/* ── Chat launcher and panel ─────────────────────────────────────────── */ +/* A floating launcher, bottom-right, and the panel it opens immediately to + its left. The two share a bottom edge and the panel grows out of the button, + so the launcher never moves and always reads as the thing that produced the + panel. + + Deliberately not a modal: no scrim, no body scroll lock, no focus trap. The + operator asks Archie about the page they are on, so that page has to stay + readable, scrollable and clickable while the panel is open. */ +.chat-dock { + --fab-size: 56px; + --fab-inset: var(--sp-5); + --fab-gap: var(--sp-3); position: fixed; - inset: var(--sp-4); - display: flex; - align-items: stretch; - justify-content: flex-end; - pointer-events: none; + right: var(--fab-inset); + bottom: var(--fab-inset); z-index: 40; } + +.chat-fab { + position: relative; + display: grid; + place-items: center; + width: var(--fab-size); + height: var(--fab-size); + border: 0; + 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); +} + +.chat-fab:hover { + transform: translateY(-1px); + box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent); +} + +.chat-fab:active { + transform: translateY(0); +} + +/* Both glyphs are stacked and cross-faded, so the button keeps one size and + the swap cannot reflow the dock. */ +.chat-fab-icon { + grid-area: 1 / 1; + display: grid; + place-items: center; + transition: opacity var(--transition), transform var(--transition); +} + +.chat-fab-icon-close, +.chat-dock.is-open .chat-fab-icon-open { + opacity: 0; + transform: scale(0.7) rotate(-45deg); +} + +.chat-fab-icon-open, +.chat-dock.is-open .chat-fab-icon-close { + opacity: 1; + transform: none; +} + +/* The panel is positioned off the dock, not the viewport: it sits one gap to + the left of the launcher and rises from the shared bottom edge. */ +.chat-drawer { + position: absolute; + right: calc(var(--fab-size) + var(--fab-gap)); + bottom: 0; + 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; +} + .chat-drawer-panel { pointer-events: auto; - position: relative; - z-index: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); - width: min(430px, 100%); + width: 100%; height: 100%; background: var(--surface); border: 1px solid var(--border); @@ -221,19 +293,25 @@ body { box-shadow: var(--shadow-md); overflow: hidden; opacity: 0; - transform: translateX(1.2rem); + /* Grows out of the launcher: the origin is the corner nearest the button. */ + transform-origin: bottom right; + transform: scale(0.92) translateX(var(--sp-3)); transition: opacity var(--transition), transform var(--transition); } -/* A closed (opacity-0, still mounted) panel must not block the page behind - it: opacity does not disable hit-testing, so without this the invisible - 430px panel would make the whole right column unclickable at z-index 40. */ + +/* A closed panel is still mounted so the session and its stream survive. It + must not take hits or reach the tab order while invisible. */ .chat-drawer:not(.is-open) .chat-drawer-panel { pointer-events: none; + visibility: hidden; } + .chat-drawer.is-open .chat-drawer-panel { opacity: 1; transform: none; + visibility: visible; } + .chat-drawer-head { display: flex; align-items: center; @@ -242,28 +320,89 @@ body { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); } -.chat-scrim { - position: fixed; - inset: 0; - background: color-mix(in srgb, var(--bg) 40%, transparent); - opacity: 0; - pointer-events: none; - transition: opacity var(--transition); + +/* Below this there is no room beside the launcher, so the panel stops being + anchored to it and becomes a sheet on the viewport. The launcher hides while + the sheet is up: its own close button is the way out. */ +@media (max-width: 720px) { + .chat-dock { + --fab-inset: var(--sp-4); + } + + .chat-drawer { + position: fixed; + right: var(--fab-inset); + left: var(--fab-inset); + bottom: var(--fab-inset); + width: auto; + height: min(78vh, calc(100vh - var(--fab-inset) * 2)); + } + + .chat-drawer-panel { + transform-origin: bottom center; + transform: scale(0.98) translateY(var(--sp-3)); + } + + .chat-dock.is-open .chat-fab { + opacity: 0; + pointer-events: none; + } } -/* The scrim shows and closes from outside clicks only when the drawer is - open; it is driven by the drawer's own state so it can never be on top of - a closed drawer. */ -.chat-drawer.is-open .chat-scrim { - opacity: 1; - pointer-events: auto; -} -body.chat-open { - overflow: hidden; + +/* ── Collapsed search ───────────────────────────────────────────────────── */ + +/* The always-open "Jump to" field is the widest thing in the utility cluster + and the least often used. Past this width it collapses to its icon and + expands on demand, which is what keeps the nav from having to scroll at + ordinary laptop sizes. Measured: the labelled nav needs 917px and the + collapsed cluster 160px, so an expanded field does not fit beside them until + about 1430px -- collapsing to 1500 keeps 1440 comfortable rather than + marginal. */ +@media (max-width: 1500px) { + .topbar-search { + padding: 0; + border: 0; + background: transparent; + overflow: hidden; + } + + .topbar-search-icon { + display: none; + } + + .mobile-search-toggle { + display: grid; + } + + .topbar-search input { + width: 0; + padding: 0; + opacity: 0; + pointer-events: none; + transition: width var(--transition), opacity var(--transition); + } + + .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 { + width: min(9rem, 34vw); + opacity: 1; + pointer-events: auto; + } } /* ── Constrained desktop ────────────────────────────────────────────────── */ -@media (max-width: 1220px) and (min-width: 901px) { +/* The nav needs 917px on one line. Below the width where it still fits beside + the brand and the collapsed cluster it takes a row of its own, which reads + better than the scroll that would otherwise kick in. */ +@media (max-width: 1270px) and (min-width: 901px) { .topbar { flex-wrap: wrap; } @@ -320,43 +459,6 @@ body.chat-open { } - .topbar-search { - padding: 0; - border: 0; - background: transparent; - overflow: hidden; - } - - .topbar-search-icon { - display: none; - } - - .mobile-search-toggle { - display: grid; - } - - .topbar-search input { - width: 0; - padding: 0; - opacity: 0; - pointer-events: none; - transition: width var(--transition), opacity var(--transition); - } - - .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 { - width: min(9rem, 34vw); - opacity: 1; - pointer-events: auto; - } - .main { padding: var(--sp-4); } diff --git a/ui/src/css/tokens.css b/ui/src/css/tokens.css index 0939dad8d..9b0372911 100644 --- a/ui/src/css/tokens.css +++ b/ui/src/css/tokens.css @@ -41,6 +41,8 @@ /* ── Dark (default) ─────────────────────────────────────────────────────── */ [data-theme="dark"] { + color-scheme: dark; + --bg: #0d1014; --bg-raised: #141920; --surface: #171d25; @@ -88,6 +90,8 @@ /* ── Light ──────────────────────────────────────────────────────────────── */ [data-theme="light"] { + color-scheme: light; + --bg: #f6f8fb; --bg-raised: #ffffff; --surface: #ffffff; diff --git a/ui/src/dashboard/activity-detail.js b/ui/src/dashboard/activity-detail.js new file mode 100644 index 000000000..7151bb396 --- /dev/null +++ b/ui/src/dashboard/activity-detail.js @@ -0,0 +1,30 @@ +// Live activity's detail column. +// +// The daemon puts whatever a stage produced into an event's detail, so the +// column holds anything from "session-memory" to a few thousand characters of +// agent transcript. Printed raw, one agent_finish row was taller than six +// viewports and the table stopped being scannable (archie-core-qo7f). +// +// The rule is one line in the cell, the whole payload still available. The cut +// happens here rather than in CSS because the row also needs to know whether +// there is more to show. + +// Long enough for a useful parked reason, short enough that every row is the +// same height at the widths the table is used at. +const CELL_LIMIT = 160; + +/** + * activityDetail returns `{ text, full, truncated }` for one event: + * `text` is the single line the cell renders, `full` the untouched payload, + * and `truncated` whether the two differ. + */ +export function activityDetail(event) { + const full = String(event?.detail || event?.message || ""); + if (!full) return { text: "", full: "", truncated: false }; + + // The first line that says something: agent output often opens with blanks. + const firstLine = full.split("\n").map((line) => line.trim()).find(Boolean) || ""; + const clipped = firstLine.length > CELL_LIMIT ? `${firstLine.slice(0, CELL_LIMIT).trimEnd()}…` : firstLine; + + return { text: clipped, full, truncated: clipped !== full }; +} diff --git a/ui/src/dashboard/dashboard.css b/ui/src/dashboard/dashboard.css index a81b3a23c..38a4d8026 100644 --- a/ui/src/dashboard/dashboard.css +++ b/ui/src/dashboard/dashboard.css @@ -411,3 +411,18 @@ background: var(--warn-soft); filter: brightness(1.1); } + +/* Live activity's detail column. activity-detail.js already cuts the payload + to one line; this stops a long unbroken token (a path, a URL, a hash) from + widening the column past the table and keeps every row the same height. */ +.activity-detail { + max-width: 0; + width: 55%; +} + +.activity-detail span { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/ui/src/dashboard/dashboard.jsx b/ui/src/dashboard/dashboard.jsx index a436d24e5..3c3012d2b 100644 --- a/ui/src/dashboard/dashboard.jsx +++ b/ui/src/dashboard/dashboard.jsx @@ -6,6 +6,7 @@ import { ago, compact } from "../base/format.jsx"; import { statusKind } from "../base/task-meta.jsx"; import { StatTile } from "../base/statTile.jsx"; import { Gauge, SegmentBar } from "../base/gauge.jsx"; +import { activityDetail } from "./activity-detail.js"; import { Icon } from "../base/icons.jsx"; import { Pill } from "../base/pill.jsx"; import { dismissSetupComplete, setupPanelState } from "./setup-preference.jsx"; @@ -401,6 +402,7 @@ function DashboardApp() { activity.map((event, i) => { const taskID = taskIDForEvent(event, taskIDsBySource); const hasTask = taskID > 0; + const detail = activityDetail(event); const openTask = () => { if (hasTask) location.hash = `#/tasks?task=${encodeURIComponent(taskID)}`; }; @@ -423,7 +425,9 @@ function DashboardApp() { {event.kind || event.type || "event"} {hasTask ? `#${taskID}` : "—"} - {event.detail || event.message || ""} + + {detail.text} + {ago(event.at || Date.now())} ); diff --git a/ui/src/main.jsx b/ui/src/main.jsx index e3d90d23f..f054caceb 100644 --- a/ui/src/main.jsx +++ b/ui/src/main.jsx @@ -1,5 +1,5 @@ import "./css/_main.css"; -import { h, render } from "preact"; +import { Fragment, h, render } from "preact"; import { useCallback, useEffect, useRef, useState } from "preact/hooks"; import { api } from "./base/api.jsx"; import { hiddenRoutes } from "./capabilities.jsx"; @@ -17,7 +17,7 @@ import { logsPage } from "./logs/logs.jsx"; import { capturesPage } from "./captures/captures.jsx"; import { mappingsPage } from "./mappings/mappings.jsx"; import { bindingsPage } from "./bindings/bindings.jsx"; -import { ChatPage } from "./chat/chat.jsx"; +import { ChatApp } from "./chat/chat.jsx"; import { matchRoute, navPath } from "./routing.jsx"; /** @@ -44,7 +44,6 @@ import { matchRoute, navPath } from "./routing.jsx"; // :name -- one captured path segment, e.g. /tasks/:id const routes = [ { path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage }, - { path: "/chat", label: "Chat", icon: "chat", view: ChatPage, section: "chat" }, { path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage }, { path: "/tasks/:id", label: "Task run", view: taskDetailPage, nav: false, navPath: "/tasks" }, { path: "/logs", label: "Logs", icon: "logs", view: logsPage, section: "logs" }, @@ -75,7 +74,7 @@ function navEntries(hidden) { return routes.filter((route) => route.nav !== false && !hidden.includes(route.path)); } -function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme, onToggleTheme }) { +function Topbar({ activePath, hidden, onNavigate, theme, onToggleTheme }) { const [searchOpen, setSearchOpen] = useState(false); const searchRef = useRef(null); @@ -159,15 +158,6 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme, onKeyDown={onSearchKeyDown} />
- @@ -187,26 +177,80 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme, ); } -// The chat drawer lives beside the outlet, mounted once. It is closed by -// default and opened from the topbar launcher; because it is a slide-over -// rather than a route, the operator can talk to Archie from any page without -// leaving the work that prompted the question. It hosts a single ChatPage -// instance, so session state and the stream survive navigation and are not -// duplicated per page. -function ChatDrawer({ open, onClose }) { +// Chat is a floating launcher and the panel it opens, mounted once beside the +// outlet. It is not a route: the operator asks Archie about the page they are +// already on, so navigating must not close it and opening must not replace the +// work that prompted the question. +// +// The panel anchors to the launcher and opens leftward from it, sharing its +// bottom edge, so the button stays put and reads as the thing the panel came +// out of. Nothing is dimmed and the page keeps scrolling: this is a companion +// to the work, not a modal over it. +// +// It hosts a single ChatApp instance, so session state and the stream survive +// navigation rather than being rebuilt per page. +const CHAT_PANEL_ID = "chat-panel"; + +function ChatLauncher() { + const [open, setOpen] = useState(false); + const fabRef = useRef(null); + + const close = useCallback(() => { + setOpen(false); + // Focus goes back to the control that opened the panel; otherwise a + // keyboard user who dismisses it lands at the top of the document. + fabRef.current?.focus(); + }, []); + + useEffect(() => { + if (!open) return undefined; + const onKeyDown = (event) => { + // A focused control (the composer dismissing its command menu, or the + // topbar search) already handled Escape via preventDefault; closing the + // panel too would make that menu impossible to dismiss on its own. + if (event.defaultPrevented || event.key !== "Escape") return; + close(); + }; + document.addEventListener("keydown", onKeyDown); + return () => document.removeEventListener("keydown", onKeyDown); + }, [open, close]); + return ( - + + +
); } @@ -264,13 +308,6 @@ function renderRoute(rawPath) { const route = match?.route || routes[0]; const params = match?.params || {}; - // The chat is a drawer, not a page: /chat opens it rather than mounting a - // second ChatPage (which would duplicate session state and the stream). - if (route.path === "/chat") { - render(null, outlet); - return; - } - // The key covers the path and its parameters, but NOT the query: the query // string is an entry state, so a navigation that only changes the query of // the page already mounted keeps the operator's own filter selection. @@ -302,9 +339,6 @@ function show(rawPath) { // Tasks stays current on #/tasks/42 instead of every item losing it. chrome?.setActive(navPath(route)); - // The chat is a drawer, not a page: /chat opens it rather than mounting a - // second ChatPage (which would duplicate session state and the stream). - chrome?.setChatOpen(route.path === "/chat"); renderRoute(rawPath); } @@ -314,35 +348,22 @@ function navigate(next) { } window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/")); -window.addEventListener("keydown", (event) => { - // A focused control (the composer dismissing its command menu, or the topbar - // search) already handled Escape via preventDefault; closing the drawer too - // would make the menu impossible to dismiss alone. - if (event.defaultPrevented) return; - if (event.key === "Escape") chrome?.setChatOpen(false); -}); - function App() { const [active, setActive] = useState("/"); const [theme, setTheme] = useState(currentTheme); - const [chatOpen, setChatOpen] = useState(false); const [hidden, setHidden] = useState([]); // Publishes the router's handles. A callback ref runs at commit time, so a // hashchange that lands right after the first paint already finds them. const publish = useCallback((element) => { outlet = element; - chrome = { setActive, setChatOpen }; + chrome = { setActive }; }, []); useEffect(() => { applyTheme(theme); }, [theme]); - useEffect(() => { - document.body.classList.toggle("chat-open", chatOpen); - }, [chatOpen]); - // Asked for once, after the shell is up: the nav renders immediately and // loses the entries this process cannot back a moment later, rather than // holding the whole page behind one request. @@ -368,19 +389,22 @@ function App() { }, []); return ( -
-
+ +
+
+ {/* Outside .shell on purpose: its backdrop-filter is a containing block + for fixed positioning, so a launcher nested inside would anchor to the + scrolling shell and ride off the bottom of a long page. */} + +
); } diff --git a/ui/test/activity-detail.test.js b/ui/test/activity-detail.test.js new file mode 100644 index 000000000..3d7519e74 --- /dev/null +++ b/ui/test/activity-detail.test.js @@ -0,0 +1,43 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { activityDetail } from "../src/dashboard/activity-detail.js"; + +// Live activity renders whatever the daemon put in an event's detail. An +// agent_finish payload is a few thousand characters of transcript, and printed +// raw it turned one table row into six viewports (archie-core-qo7f). The cell +// shows a single scannable line; the full text stays reachable, never silently +// dropped. + +test("a short detail is shown as-is and needs no expansion", () => { + assert.deepEqual(activityDetail({ detail: "session-memory" }), { + text: "session-memory", + full: "session-memory", + truncated: false, + }); +}); + +test("a long detail is cut to one line and keeps the full text", () => { + const long = "x".repeat(5000); + const result = activityDetail({ detail: long }); + assert.equal(result.truncated, true); + assert.ok(result.text.length < 200, `cell text is still ${result.text.length} chars`); + assert.equal(result.full, long, "full payload was dropped rather than kept"); +}); + +test("a multi-line detail collapses to its first meaningful line", () => { + const result = activityDetail({ + detail: "stage fix: agent parked (gate_parked):\n[golangci-lint] run ./...\nlevel=warning msg=deprecated", + }); + assert.equal(result.text, "stage fix: agent parked (gate_parked):"); + assert.equal(result.truncated, true); +}); + +test("leading blank lines do not produce an empty cell", () => { + assert.equal(activityDetail({ detail: "\n\n real content\nmore" }).text, "real content"); +}); + +test("message is used when detail is absent, and absence is not an error", () => { + assert.equal(activityDetail({ message: "fallback" }).text, "fallback"); + assert.deepEqual(activityDetail({}), { text: "", full: "", truncated: false }); + assert.deepEqual(activityDetail(undefined), { text: "", full: "", truncated: false }); +}); diff --git a/ui/test/chat-app.test.js b/ui/test/chat-app.test.js index d128901cb..18c91ad07 100644 --- a/ui/test/chat-app.test.js +++ b/ui/test/chat-app.test.js @@ -1,25 +1,67 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { render, cleanup } from "@testing-library/preact"; +import { render } from "@testing-library/preact"; import { ChatApp } from "../src/chat/chat.jsx"; -test("ChatApp renders structure with topbar, sidebar, transcript and composer", () => { +// ChatApp lives in a ~440px panel hung off the launcher, never on a page of its +// own. These tests hold that shape: one column, no page furniture, and the +// controls that are not conversation kept out of the reading area +// (archie-core-hesx). + +test("the panel is a single column: no page title, no persistent sidebar", () => { + const { container, unmount } = render(); + + assert.equal(container.querySelector(".chat-topbar"), null, "page topbar should be gone"); + assert.equal(container.querySelector(".chat-kicker"), null, "ARCHIE WORKSPACE kicker should be gone"); + assert.equal(container.querySelector(".page-title"), null, "the panel header already names Archie"); + assert.equal(container.querySelector(".chat-sidebar"), null, "conversations should not hold a column"); + unmount(); +}); + +test("the transcript and composer are the panel's own rows", () => { const { container, unmount } = render(); - assert.ok(container.querySelector(".chat-topbar"), "topbar should render"); - assert.ok(container.querySelector(".chat-sidebar"), "sidebar should render"); assert.ok(container.querySelector(".chat-transcript"), "transcript should render"); - assert.ok(container.querySelector(".chat-composer"), "composer textarea should render"); - assert.ok(container.querySelector(".chat-sidebar button"), "+ New chat button should exist"); + assert.ok(container.querySelector(".chat-composer"), "composer should render"); unmount(); }); -test("ChatApp renders empty state with prompt chips when messages are empty", () => { +test("conversations are a switcher in the bar, not a column", () => { const { container, unmount } = render(); - const emptyState = container.querySelector(".chat-empty-state"); - assert.ok(emptyState, "empty state should be present"); - const prompts = container.querySelectorAll(".chat-prompt"); - assert.ok(prompts.length >= 3, "should have prompt buttons"); + const bar = container.querySelector(".chat-bar"); + assert.ok(bar, "compact bar should render"); + assert.ok(bar.querySelector(".chat-session-switch"), "session switcher should live in the bar"); + assert.ok(bar.querySelector(".chat-new"), "new chat should live in the bar"); + unmount(); +}); + +test("model controls are behind one settings affordance, not laid out inline", () => { + const { container, unmount } = render(); + + const settings = container.querySelector(".chat-settings"); + assert.ok(settings, "settings popover should render"); + assert.ok(settings.querySelector('[aria-label="Personality"]'), "personality lives in the popover"); + assert.ok(settings.querySelector('[aria-label="Model"]'), "model lives in the popover"); + + // Closed by default: a 440px panel cannot spend its width on three selects. + assert.equal(settings.tagName, "DETAILS"); + assert.equal(settings.hasAttribute("open"), false); + unmount(); +}); + +test("operator panels are not rendered in the chat panel", () => { + const { container, unmount } = render(); + + assert.equal(container.querySelector(".chat-update-panel"), null, "update panel belongs to Configuration"); + assert.equal(container.querySelector(".chat-dangerous-panel"), null, "dangerous actions belong to Configuration"); + unmount(); +}); + +test("the empty state still offers its prompts", () => { + const { container, unmount } = render(); + + assert.ok(container.querySelector(".chat-empty-state"), "empty state should be present"); + assert.ok(container.querySelectorAll(".chat-prompt").length >= 3, "should have prompt buttons"); unmount(); }); diff --git a/ui/test/chat-fab.test.js b/ui/test/chat-fab.test.js new file mode 100644 index 000000000..291dcad7f --- /dev/null +++ b/ui/test/chat-fab.test.js @@ -0,0 +1,89 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { waitFor } from "@testing-library/preact"; + +// The chat is a FAB-opened panel, not a route. These tests hold that shape: +// there is exactly one way in (the floating button), the panel anchors beside +// it rather than filling the right edge, and `#/chat` is not a destination. +// +// main.jsx starts on import and cannot be imported twice, so this file drives +// the same live app the routing test does. +globalThis.fetch = async () => { + throw new Error("no daemon in this test"); +}; + +class InertEventSource { + close() {} +} +globalThis.EventSource = InertEventSource; + +const fab = () => document.querySelector(".chat-fab"); +const drawer = () => document.querySelector(".chat-drawer"); + +async function settle() { + await new Promise((resolve) => setTimeout(resolve, 0)); +} + +test("chat is reachable only from the floating button", async (t) => { + document.body.innerHTML = '
'; + location.hash = "#/"; + await import("../src/main.jsx"); + await waitFor(() => assert.ok(document.querySelector(".topbar"))); + + await t.test("the nav has no Chat entry", () => { + const labels = [...document.querySelectorAll("a.nav-item .nav-label")].map((el) => el.textContent); + assert.ok(!labels.includes("Chat"), `nav still offers Chat: ${labels.join(", ")}`); + assert.equal(document.querySelector('a.nav-item[href="#/chat"]'), null); + }); + + await t.test("the topbar has no chat icon button", () => { + assert.equal(document.querySelector(".topbar .icon-btn-chat"), null); + }); + + await t.test("the floating button is present and announces its state", () => { + assert.ok(fab(), "no .chat-fab rendered"); + assert.equal(fab().getAttribute("aria-expanded"), "false"); + assert.ok(fab().getAttribute("aria-controls"), "FAB does not point at the panel it opens"); + }); +}); + +test("the floating button opens and closes the panel", async () => { + assert.ok(fab(), "no .chat-fab rendered"); + assert.ok(!drawer().classList.contains("is-open")); + + fab().click(); + await waitFor(() => assert.ok(drawer().classList.contains("is-open"))); + assert.equal(fab().getAttribute("aria-expanded"), "true"); + + // The panel it controls is the one that actually opened. + assert.equal(document.getElementById(fab().getAttribute("aria-controls")), drawer()); + + fab().click(); + await waitFor(() => assert.ok(!drawer().classList.contains("is-open"))); + assert.equal(fab().getAttribute("aria-expanded"), "false"); +}); + +test("Escape closes the panel and returns focus to the button", async () => { + fab().click(); + await waitFor(() => assert.ok(drawer().classList.contains("is-open"))); + + // The class lands with the render, but the effect that binds Escape runs + // after paint. Pressing the key on each retry means the test waits for the + // binding rather than for a guessed number of milliseconds. + await waitFor(() => { + document.dispatchEvent(new window.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); + assert.ok(!drawer().classList.contains("is-open")); + }); + assert.equal(document.activeElement, fab(), "focus was not returned to the launcher"); +}); + +test("#/chat is not a route and does not blank the page", async () => { + location.hash = "#/chat"; + await settle(); + await waitFor(() => { + const main = document.querySelector(".main"); + assert.ok(main && main.textContent.trim().length > 0, "#/chat rendered an empty page"); + }); + // It resolves to the dashboard rather than to a chat page. + assert.equal(document.querySelector('a.nav-item[href="#/"]')?.getAttribute("aria-current"), "page"); +});