Files
archie/ui/dist/assets/index.js
T
sam 4d44ef76f5 feat(webui): rebuild the dashboard
The old UI was a single 200-line Go file serving one hand-written HTML
page of task rows. It showed that archied was running and almost nothing
about what it was doing -- skills, workflows, memory, channels, logs and
configuration were all invisible unless you read the source or the
config file.

The dashboard now covers each of those as its own section, built as a
Vite app under ui/ at the repo root: it is a separate artefact from the
Go daemon, not an internal package of it. dist/ is committed so building
archied never needs a Node toolchain, and the !no_ui build tag keeps an
embed-free build available.

Both sides are split by concern rather than by layer -- one Go file per
API area, one folder per UI section with its own CSS -- so a change to
logs cannot disturb tasks.

Pages report consequences, not just state: an empty memory page says
Archie starts every conversation with no recollection of earlier ones,
and the setup checklist names what is missing in plain language instead
of showing a grid of zeroes. Nothing greets by a hardcoded name; the
operator comes from [chat], which is deployment data.

Auth is exposure control, not capability control -- the agent already
holds this user's authority through its own tools. So a loopback bind
needs no token, and only a reachable bind mints one and logs a URL,
which means an instance cannot be exposed merely by omitting config.

Container startup now degrades instead of aborting, for the reason
resolveForge already does: a missing agent image should not deny the
operator chat and the dashboard, and under Restart=on-failure it turns a
recoverable problem into a crash loop with the real error scrolling past.

`task dev` runs the daemon under air and the Vite server together in one
terminal.
2026-08-04 01:45:36 +10:00

8 lines
34 KiB
JavaScript

(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)}})();function e(e,n,...r){let[i,...a]=e.split(`.`),o=document.createElement(i||`div`);a.length&&(o.className=a.join(` `)),n&&(typeof n!=`object`||n instanceof Node)&&(r.unshift(n),n=null);for(let[e,t]of Object.entries(n||{}))t!=null&&t!==!1&&(e.startsWith(`on`)&&typeof t==`function`?o.addEventListener(e.slice(2).toLowerCase(),t):e===`class`?o.className=[o.className,t].filter(Boolean).join(` `):e===`html`?o.innerHTML=t:o.setAttribute(e,t===!0?``:String(t)));return t(o,r),o}function t(e,t){for(let n of t.flat(1/0))n!=null&&n!==!1&&e.append(n instanceof Node?n:document.createTextNode(String(n)))}function n(e,...n){return e.replaceChildren(),t(e,n),e}function r(t,n=`idle`){return e(`span.pill.pill-${n}`,t)}function i(e){switch(e){case`running`:return`info`;case`merged`:case`pr_open`:return`ok`;case`parked`:case`waiting_human`:return`warn`;case`dead`:case`rejected`:return`danger`;default:return`idle`}}function a(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 o(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function s(t,n){return e(`div.empty`,e(`div.empty-title`,t),n&&e(`div`,n))}var c={dashboard:`<rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/>`,tasks:`<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>`,logs:`<path d="M4 5h16M4 10h16M4 15h10M4 20h7"/>`,skills:`<path d="M12 3l2.6 5.6 6.1.8-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6L3.3 9.4l6.1-.8z"/>`,workflows:`<path d="M4 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h4"/><path d="M17 4l3 3-3 3"/><path d="M7 21l-3-3 3-3"/>`,memory:`<circle cx="12" cy="12" r="3.2"/><path d="M12 3v3.4M12 17.6V21M3 12h3.4M17.6 12H21M5.6 5.6l2.4 2.4M16 16l2.4 2.4M18.4 5.6L16 8M8 16l-2.4 2.4"/>`,channels:`<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3.5 7l8.5 6 8.5-6"/>`,settings:`<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2V21a2 2 0 1 1-4 0v-.1A1.7 1.7 0 0 0 7 19.4a1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 3 15H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.6 7a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 3.6V3a2 2 0 1 1 4 0v.1A1.7 1.7 0 0 0 15 4.6h.1a1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>`,search:`<circle cx="11" cy="11" r="7"/><path d="M20 20l-3.6-3.6"/>`,moon:`<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z"/>`,sun:`<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4"/>`,refresh:`<path d="M20 11a8 8 0 1 0-1.2 5.2"/><path d="M20 4v7h-7"/>`,bell:`<path d="M18 9a6 6 0 1 0-12 0c0 6-2 7-2 7h16s-2-1-2-7"/><path d="M13.7 20a2 2 0 0 1-3.4 0"/>`,trendUp:`<path d="M4 17L10 11l4 4 6-6"/><path d="M14 7h6v6"/>`,trendDown:`<path d="M4 7l6 6 4-4 6 6"/><path d="M14 17h6v-6"/>`,check:`<path d="M4.5 12.5l5 5 10-11"/>`,help:`<circle cx="12" cy="12" r="9"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.2-.9.8-.9 1.4v.4"/><path d="M12 17.2h.01"/>`};function l(e,{size:t=18,className:n=``}={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(t)),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.6`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`class`,`ico ${n}`.trim()),r.innerHTML=c[e]||c.dashboard,r}async function u(e){let t=await fetch(e,{headers:{Accept:`application/json`}});if(t.status===401)throw new f(`unauthorised`,401);if(!t.ok)throw new f(`${t.status} ${t.statusText}`,t.status);return t.json()}function d(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}`:``}var f=class extends Error{constructor(e,t){super(e),this.status=t}},p={summary:()=>u(`/api/summary`),tasks:()=>u(`/api/tasks`),task:e=>u(`/api/tasks/${e}`),setup:()=>u(`/api/setup`),workflows:()=>u(`/api/workflows`),skills:()=>u(`/api/skills`),channels:()=>u(`/api/channels`),config:()=>u(`/api/config`),logs:e=>u(`/api/logs`+d(e)),memory:()=>u(`/api/memory`)};function m(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 h({label:t,value:n,unit:r,trend:i,compare:a,series:o=[],goodDirection:s=`up`}){let c=i==null?null:i>=0?`up`:`down`,u=c==null?null:c===s;return e(`div.card.stat`,e(`div.stat-head`,e(`span.stat-label`,t),c&&e(`span.stat-trend.${u?`up`:`down`}`,l(c===`up`?`trendUp`:`trendDown`,{size:13}),`${Math.abs(i).toFixed(1)}%`)),e(`div.stat-value`,n,r&&e(`span.stat-unit`,r)),a&&e(`div.stat-compare`,a),o.length>1&&g(o,u===!1?`var(--danger)`:`var(--ok)`))}function g(t,n=`var(--ok)`,{width:r=220,height:i=34}={}){let a=Math.max(...t,1),o=Math.min(...t,0),s=a-o||1,c=t.length>1?r/(t.length-1):r,l=t.map((e,t)=>`${(t*c).toFixed(1)},${(i-(e-o)/s*i).toFixed(1)}`).join(` `),u=e(`svg.spark`,{viewBox:`0 0 ${r} ${i}`,preserveAspectRatio:`none`,"aria-hidden":`true`});return u.innerHTML=`<polyline points="${l}" fill="none" stroke="${n}" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" vector-effect="non-scaling-stroke"/>`,u}function _({value:t,label:n,size:r=168}){let i=Math.max(0,Math.min(100,Number(t)||0)),a=i>=90?`var(--ok)`:i>=70?`var(--warn)`:`var(--danger)`,o=r/2,s=r/2,c=2*Math.PI*62*(240/360),l=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${o+62*Math.cos(n)} ${s+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${o+62*Math.cos(r)} ${s+62*Math.sin(r)}`].join(` `)},u=e(`svg.gauge`,{viewBox:`0 0 ${r} ${r*.78}`,role:`img`,"aria-label":`${n}: ${i}%`});return u.innerHTML=`
<path d="${l(150,240)}" fill="none" stroke="var(--border)"
stroke-width="12" stroke-linecap="round"/>
<path d="${l(150,240)}" fill="none" stroke="${a}"
stroke-width="12" stroke-linecap="round"
stroke-dasharray="${c}"
stroke-dashoffset="${c*(1-i/100)}"
class="gauge-value"/>`,e(`div.gauge-wrap`,u,e(`div.gauge-center`,e(`div.gauge-pct`,`${Math.round(i)}%`),e(`div.gauge-label`,n)))}function v(t){let n=t.reduce((e,t)=>e+(t.value||0),0)||1;return e(`div`,e(`div.segbar`,...t.filter(e=>e.value>0).map(t=>e(`span`,{class:`segbar-part segbar-${t.kind||`idle`}`,style:`width:${(t.value/n*100).toFixed(1)}%`,title:`${t.label}: ${t.value}`}))),e(`div.segbar-legend`,...t.map(t=>e(`span.segbar-key`,e(`span`,{class:`segbar-dot segbar-${t.kind||`idle`}`}),t.label))))}function y(){let t=e(`div`),i=e(`tbody`),a=e(`div.grid.grid-4`),c=e(`div`),u=e(`div`),d=e(`div`),f=e(`div.hero-actions-inner`),g=e(`h1.hero-title`,x()),_=r(`connecting`,`idle`);y(),T();let v=m(e=>b(i,e),e=>{_.className=`pill pill-${e===`live`?`ok`:`warn`}`,_.textContent=e});t.addEventListener(`archie:teardown`,v);function y(){n(t,e(`div.hero`,e(`div`,g,e(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),e(`div.hero-actions`,f)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Health`)),e(`div.dash-top`,c,u)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Throughput`),e(`span.dash-section-note`,`Across all repositories`)),a),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Right now`)),e(`div.dash-split`,d,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Live activity`),e(`p.card-sub`,`Last 50, newest first`)),_),e(`table.table`,e(`thead`,e(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(t=>e(`th`,t)))),i))))),n(i,e(`tr`,e(`td`,{colspan:4},s(`Waiting for activity`,`Events appear here as Archie works.`))))}async function T(){try{let[e,t,n]=await Promise.all([p.summary(),p.setup().catch(()=>null),p.workflows().catch(()=>null)]);E(e),g.textContent=t?.operator?`${x()}, ${t.operator}`:x(),D(e),O(t),k(e,n),A(e)}catch(t){n(a,e(`div.card`,s(`Cannot reach archied`,String(t.message||t))))}}function E(t){let r=t?.statuses||{},i=(r.parked||0)+(r.waiting_human||0),a=r.running||0;n(f,i>0&&e(`a.btn.btn-attention`,{href:`#/tasks`},l(`tasks`,{size:15}),`${i} need${i===1?`s`:``} you`),a>0&&e(`a.btn`,{href:`#/tasks`},l(`workflows`,{size:15}),`${a} running`),e(`a.btn`,{href:`#/logs`},l(`logs`,{size:15}),`Logs`),e(`button.btn.btn-primary`,{onclick:T},l(`refresh`,{size:15}),`Refresh`))}function D(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),s=Object.values(t).reduce((e,t)=>e+t,0),c=e?.tokens_by_day||[];n(a,h({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:c.map(e=>e.tokens||0)}),h({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),h({label:`Delivered`,value:r,compare:s?`${Math.round(r/s*100)}% of all tasks`:`No tasks yet`}),h({label:`Tokens used`,value:o(c.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${c.length||0} days`,trend:w(c.map(e=>e.tokens||0)),goodDirection:`down`,series:c.map(e=>e.tokens||0)}))}function O(t){if(!t?.steps?.length)return n(c);let r=t.steps.filter(e=>!e.done);if(!r.length)return n(c);let i=Math.round((t.steps.length-r.length)/t.steps.length*100);n(c,e(`div.card.setup`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Finish setting up`),e(`p.card-sub`,`Archie needs these before it can work on its own.`)),e(`span.setup-pct`,`${i}%`)),e(`div.setup-bar`,e(`div.setup-bar-fill`,{style:`width:${i}%`})),e(`ul.setup-list`,...t.steps.map(j))))}function k(e,t){S(u,e,t)}function A(e){C(d,e)}function j(t){return e(`li.setup-step${t.done?`.done`:``}`,e(`span.setup-check`,t.done?l(`check`,{size:12}):``),e(`div`,e(`div.setup-step-title`,t.title),t.detail&&e(`div.setup-step-detail`,t.detail)))}return t}function b(t,n){t.firstElementChild?.querySelector(`.empty`)&&t.replaceChildren();let r=e(`tr`,e(`td.strong`,e(`span`,n.kind||n.type||`event`)),e(`td.mono`,n.task_id?`#${n.task_id}`:`—`),e(`td`,n.detail||n.message||``),e(`td`,a(n.at||Date.now())));for(t.prepend(r);t.children.length>50;)t.lastElementChild.remove()}function x(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function S(t,i,a){let o=a?.workflows||[],c=o.reduce((e,t)=>e+(t.runs||0),0),l=o.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),u=o.reduce((e,t)=>e+(t.parked||0),0);if(!c){n(t,e(`div.card`,e(`div.card-head`,e(`h2.card-title`,`Gate pulse`)),s(`No completed runs yet`,`Once Archie finishes a task, its gate pass rate appears here.`)));return}let d=l/c*100;n(t,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Gate pulse`),e(`p.card-sub`,`Work that passed its quality gates`))),_({value:d,label:`pass rate`}),e(`ul.pulse-list`,...o.slice(0,3).map(t=>e(`li.pulse-item`,e(`span.pulse-name`,t.workflow||`workflow`),r(`${t.merged||0}/${t.runs||0}`,(t.merged||0)===(t.runs||0)?`ok`:(t.parked||0)>0?`warn`:`info`))),u>0&&e(`li.pulse-item`,e(`span.pulse-name`,`Parked, awaiting you`),r(String(u),`warn`)))))}function C(t,r){let i=r?.tokens_by_day||[],a=i.reduce((e,t)=>e+(t.tokens||0),0);if(!i.length){n(t,e(`div.card`,e(`div.card-head`,e(`h2.card-title`,`Token outlook`)),s(`Nothing spent yet`,`Usage appears here once Archie runs its first task.`)));return}let c=a/i.length,l=Math.round(c*30),u=i.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);n(t,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Token outlook`),e(`p.card-sub`,`Next 30 days at the current rate`))),e(`div.forecast-value`,o(l)),e(`div.forecast-note`,`Based on ${o(Math.round(c))} per day over ${i.length} days`),v([{label:`Last 7 days (${o(u)})`,value:u,kind:`info`},{label:`Earlier (${o(a-u)})`,value:Math.max(a-u,0),kind:`idle`}])))}function w(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}var T={queued:`Queued`,running:`Working`,waiting_human:`Waiting for you`,pr_open:`In review`,merged:`Merged`,parked:`Parked`,dead:`Stopped (too many retries)`,rejected:`Rejected`,closed_wont_do:`Won't do`};function E(e){return T[e]||e||`Unknown`}function D(){let t=e(`div`),o=e(`div.grid.grid-4`),c=e(`tbody`),l=e(`input.task-search`,{type:`search`,placeholder:`Search by title or repo…`,oninput:e=>{m=e.target.value.trim().toLowerCase(),S()}}),u=e(`select.task-filter`,{onchange:e=>{f=e.target.value,S()}},e(`option`,{value:``},`All statuses`),...Object.entries(T).map(([t,n])=>e(`option`,{value:t},n))),d=[],f=``,m=``,g=null,_=new Map;v(),y();function v(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Tasks`),e(`p.page-sub`,`Every issue archied has picked up, and where it stands.`)),e(`div.page-actions`,e(`button.btn`,{onclick:y},`Refresh`))),o,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`All tasks`),e(`p.card-sub`,`Click a row for its timeline`)),e(`div.task-filters`,l,u)),e(`table.table`,e(`thead`,e(`tr`,...[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`].map(t=>e(`th`,t)))),c)))}async function y(){try{d=await p.tasks(),b(),S()}catch(t){n(o,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(c,e(`tr`,e(`td`,{colspan:7},s(`Cannot reach archied`,String(t.message||t)))))}}function b(){let e=d.length,t={};for(let e of d)t[e.status]=(t[e.status]||0)+1;let r=t.running||0,i=(t.waiting_human||0)+(t.parked||0),a=(t.merged||0)+(t.pr_open||0);n(o,h({label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),h({label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),h({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),h({label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`}))}function x(){return d.filter(e=>f&&e.status!==f?!1:!m||`${e.title} ${e.repo}`.toLowerCase().includes(m))}function S(){let t=x();if(!d.length){n(c,e(`tr`,e(`td`,{colspan:7},s(`No tasks yet`,`Tasks appear here once archied picks up an issue to work.`))));return}if(!t.length){n(c,e(`tr`,e(`td`,{colspan:7},s(`No matching tasks`,`Try a different search or status filter.`))));return}c.replaceChildren();for(let e of t)c.append(C(e)),g===e.id&&c.append(w(e))}function C(t){return e(`tr.task-row`,{onclick:()=>{g=g===t.id?null:t.id,S(),g===t.id&&O(t.id)}},e(`td.mono`,`${t.owner}/${t.repo}`),e(`td.mono`,`#${t.issue_number}`),e(`td.strong`,t.title||`(untitled)`),e(`td`,r(E(t.status),i(t.status))),e(`td`,t.workflow||`—`),e(`td`,t.stage||`—`),e(`td`,{title:t.created_at?`Created ${a(t.created_at)}`:``},a(t.updated_at)))}function w(t){let n=_.get(t.id);return e(`tr.task-timeline-row`,e(`td`,{colspan:7},n===void 0?e(`div.task-timeline-loading`,`Loading timeline…`):n===null?s(`Could not load timeline`,`archied could not be reached for this task's events.`):n.length?e(`ul.task-timeline`,...n.map(D)):s(`No events yet`,`This task has not recorded any transitions.`)))}function D(t){return e(`li.task-timeline-entry`,e(`span.task-timeline-dot`),e(`div`,e(`div.task-timeline-kind`,t.kind||t.type||`event`),t.detail&&e(`div.task-timeline-detail`,t.detail),e(`div.task-timeline-when`,a(t.at))))}async function O(e){try{let t=await p.task(e);_.set(e,t||[])}catch{_.set(e,null)}S()}return t}function O(){let t=e(`div`),r=e(`div.grid.grid-2`),i=e(`input.skill-search`,{type:`search`,placeholder:`Search skills…`,oninput:e=>{o=e.target.value.trim().toLowerCase(),d()}}),a=[],o=``,c=null;l(),u();function l(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Skills`),e(`p.page-sub`,`What Archie can do, in plain language.`)),e(`div.page-actions`,e(`button.btn`,{onclick:u},`Refresh`))),e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Catalogue`),e(`p.card-sub`,`Discovered from .agents/skills/`)),i),r)),d()}async function u(){try{a=(await p.skills())?.skills||[],c=null}catch(e){a=[],c=String(e.message||e)}d()}function d(){if(c)return n(r,s(`Cannot reach archied`,c));if(!a.length)return n(r,s(`No skills discovered yet`,`Skills live as SKILL.md files under .agents/skills/<name>/. Add one, or point skills_dir in config.toml at a shared skills directory, and it will appear here.`));let e=a.filter(e=>f(e,o));if(!e.length)return n(r,s(`No skills match`,`Nothing found for "${o}".`));n(r,...e.map(m))}function f(e,t){return!t||`${e.name} ${e.description}`.toLowerCase().includes(t)}function m(t){return e(`div.card.skill-card`,e(`div.card-head`,e(`h3.card-title`,t.name||`Untitled skill`),t.workflow&&e(`span.pill.pill-info`,t.workflow)),e(`p.skill-desc`,t.description||`No description provided.`),e(`div.skill-source`,t.source||`Unknown source`))}return t}var k={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function A(e){return k[e]?k[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function j(e,t){return t?Math.round(e/t*100):0}function M(t,n=`ok`){return e(`div.wf-bar`,e(`div.wf-bar-fill.wf-bar-${n}`,{style:`width:${Math.min(100,Math.max(0,t))}%`}))}function ee(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 te(){let t=e(`div`),r=e(`div`),i=e(`div`);a(),o();function a(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Workflows`),e(`p.page-sub`,`Run outcomes and spend per workflow, and where stages get stuck.`)),e(`div.page-actions`,e(`button.btn`,{onclick:o},`Refresh`))),r,i)}async function o(){try{let e=await p.workflows();c(e?.workflows||[]),l(e?.stages||[])}catch(t){n(r,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(i)}}function c(t){if(!t.length){n(r,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per workflow`))),s(`No workflow runs yet`,`Stats appear here once a task has run through a workflow.`)));return}n(r,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per workflow`),e(`p.card-sub`,`Success rate is merged tasks over all runs`))),e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Runs`,`Success rate`,`Avg tokens`,`Avg steps`].map(t=>e(`th`,t)))),e(`tbody`,...t.map(t=>{let n=j(t.merged,t.runs);return e(`tr`,e(`td.strong`,A(t.workflow)),e(`td`,`${t.runs} run${t.runs===1?``:`s`}`),e(`td`,e(`div.wf-rate`,`${n}%`,e(`span.wf-rate-sub`,`${t.merged} of ${t.runs} merged`)),M(n,n>=50?`ok`:`warn`)),e(`td.mono`,t.avg_tokens?t.avg_tokens.toLocaleString():`—`),e(`td.mono`,t.avg_steps?t.avg_steps.toFixed(1):`—`))})))))}function l(t){if(!t.length){n(i,e(`div.card.wf-stage-card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per stage`))),s(`No stage data yet`,`Stage timing and failures appear here once workflows have run.`)));return}let r=Math.max(...t.map(e=>e.avg_ms||0),1),a=[...t].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),o=[...t].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);n(i,e(`div.grid.grid-2.wf-stage-card`,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Slowest stages`),e(`p.card-sub`,`Average duration, this workflow's stages`))),e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Stage`,`Runs`,`Avg duration`].map(t=>e(`th`,t)))),e(`tbody`,...a.map(t=>e(`tr`,e(`td`,A(t.workflow)),e(`td.strong`,t.stage),e(`td`,`${t.runs}`),e(`td`,e(`div.wf-rate`,ee(t.avg_ms)),M(j(t.avg_ms,r),`info`))))))),e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Most failures`),e(`p.card-sub`,`Stages that error out, over their runs`))),o.length?e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Stage`,`Failures`].map(t=>e(`th`,t)))),e(`tbody`,...o.map(t=>e(`tr`,e(`td`,A(t.workflow)),e(`td.strong`,t.stage),e(`td`,e(`div.wf-rate`,`${t.errors} of ${t.runs}`),M(j(t.errors,t.runs),`danger`)))))):s(`No failures recorded`,`Every stage has completed cleanly so far.`))))}return t}function N(){let t=e(`div`),i=e(`div.grid.grid-2`);a(),o();function a(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Channels`),e(`p.page-sub`,`The conversational front-ends Archie can be reached through.`)),e(`div.page-actions`,e(`button.btn`,{onclick:o},`Refresh`))),i)}async function o(){try{c((await p.channels())?.channels||[])}catch(e){n(i,s(`Cannot reach archied`,String(e.message||e)))}}function c(e){if(!e.length){n(i,s(`No channels configured`,`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`));return}n(i,...e.map(l))}function l(t){return e(`div.card.channel-card`,e(`div.card-head`,e(`h3.card-title`,t.name),t.configured?r(`connected`,`ok`):r(`not configured`,`idle`)),e(`p.channel-desc`,t.description),e(`p.channel-detail`,t.detail))}return t}function ne(){let t=e(`div`),r=e(`div`);i(),a();function i(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Configuration`),e(`p.page-sub`,`What archied is actually running with right now.`)),e(`div.page-actions`,e(`button.btn`,{onclick:a},`Refresh`))),r)}async function a(){try{o(await p.config())}catch(t){n(r,e(`div.card`,s(`Cannot reach archied`,String(t.message||t))))}}function o(t){if(!t||Object.keys(t).length===0){n(r,e(`div.card`,s(`No configuration loaded`,`archied is running without a config file wired into the dashboard, so there is nothing to show.`)));return}n(r,re(t.identity),ie(t.repositories),L(t.models,t.providers),z(t.budgets),B(t.agent),H(t.storage,t.containers),W(t.web))}return t}function P(t,n,...r){return e(`div.card.cfg-section`,e(`div.card-head`,e(`div`,e(`h2.card-title`,t),e(`p.card-sub`,n))),...r)}function F(t,n){return e(`div.cfg-row`,e(`span.cfg-label`,t),e(`span.cfg-value.mono`,n??`—`))}function re(t){return t?P(`Identity`,`Who Archie is on the forge, and how it addresses commits and comments.`,e(`div.cfg-rows`,F(`Bot account`,t.bot_user),F(`Commit author email`,t.bot_email),F(`Pickup label`,t.label),F(`Forge type`,t.forge_type),F(`Forge host`,t.forge_host),F(`Max diff size (lines)`,t.diff_cap_lines))):P(`Identity`,`Who Archie is on the forge.`,s(`Not available`))}function ie(t){return t?.length?P(`Repositories`,`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.`,e(`table.table`,e(`thead`,e(`tr`,...[`Repository`,`Base branch`,`Ecosystem`,`Quality gate`,`Protected paths`].map(t=>e(`th`,t)))),e(`tbody`,...t.map(t=>e(`tr`,e(`td.strong`,`${t.owner}/${t.name}`),e(`td.mono`,t.base),e(`td`,t.ecosystem||`go`),e(`td.mono`,I(t.gate)),e(`td.mono`,t.protect?.length?t.protect.join(`, `):`—`)))))):P(`Repositories`,`The repositories Archie polls for work.`,s(`No repositories configured`,`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`))}function I(e){return e?.length?e.map(e=>e.join(` `)).join(` → `):`—`}function L(t,n){let i=Object.entries(t||{}),a=Object.entries(n||{}),o=i.length?e(`div.cfg-rows`,...i.map(([e,t])=>F(R(e),t))):s(`No model roles configured`,`Assign a model to at least one role (e.g. "builder") in [models].`),c=a.length?e(`table.table`,e(`thead`,e(`tr`,...[`Provider`,`Class`,`Base URL`,`API key env var`,`Status`].map(t=>e(`th`,t)))),e(`tbody`,...a.map(([t,n])=>e(`tr`,e(`td.strong`,t),e(`td`,n.class),e(`td.mono`,n.base_url||`default`),e(`td.mono`,n.api_key_env||`—`),e(`td`,n.configured?r(`configured`,`ok`):r(`missing credentials`,`warn`)))))):s(`No providers configured`,`Add a [providers.<name>] entry so a model role above has something to run on.`);return P(`Models & providers`,`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,e(`h3.cfg-subhead`,`Model roles`),o,e(`h3.cfg-subhead`,`Providers`),c)}function R(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function z(t){return t?P(`Budgets`,`The limits every autonomous stage runs under, so a stuck task cannot run forever.`,e(`div.cfg-rows`,F(`Max steps`,t.max_steps||`Unlimited`),F(`Max tokens`,t.max_tokens||`Unlimited`),F(`Wall clock`,t.wall_clock),F(`Max gate failures before parking`,t.gate_max_failures||`Unlimited`))):P(`Budgets`,`Limits on every agent stage.`,s(`Not available`))}function B(t){return t?P(`Agent execution`,`How archied actually runs a stage of work.`,e(`div.cfg-rows`,F(`Execution mode`,V(t.mode)),F(`Worker command`,t.command),F(`Extra environment variables passed through`,t.env?.length?t.env.join(`, `):`None`))):P(`Agent execution`,`How Archie runs autonomous stages.`,s(`Not available`))}function V(e){switch(e){case`inprocess`:return`In-process (same binary as the daemon)`;case`subprocess`:return`Subprocess (separate archie-agent process)`;case`nats`:return`NATS (dispatched to a worker over the message bus)`;default:return e||`Not set`}}function H(t,n){let r=[];return t&&r.push(e(`h3.cfg-subhead`,`Paths`),e(`div.cfg-rows`,F(`Work directory`,t.work_dir),F(`Task database`,t.db_path),F(`Shared skills directory`,t.skills_dir||`None (uses the work directory)`),F(`Daemon plugin directory`,t.plugin_dir||`None`),F(`Secret engine plugin directory`,t.secret_engine_dir||`None (built-in engines only)`))),n&&r.push(e(`h3.cfg-subhead`,`Sandboxed containers`),e(`div.cfg-rows`,F(`Sandboxing enabled`,n.enabled?`Yes`:`No`),F(`Agent image`,n.image||`Not set`),F(`Max concurrent tasks`,n.max_concurrency||`Unlimited`),F(`Container max lifetime`,n.max_uptime),F(`Persistent volume retention`,n.volume_ttl),F(`How images are refreshed`,U(n.pull_policy)),F(`Docker network`,n.network||`Auto-detected`))),r.length||r.push(s(`Not available`)),P(`Storage & sandboxing`,`Where archied keeps its state, and how it isolates task execution.`,...r)}function U(e){return e===`always`?`Always pull the latest image before running`:`Only pull when the image is missing locally`}function W(t){return t?P(`Dashboard`,`This dashboard's own listen address.`,e(`div.cfg-rows`,F(`Listen address`,t.listen===`off`?`Disabled`:t.listen))):P(`Dashboard`,`This dashboard's own listen address.`,s(`Not available`))}var G=[{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 K(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function q(){let t=e(`div`),i=e(`div.log-list`),a=r(`connecting`,`idle`),o=e(`span.log-meta`),c={level:``,component:``,q:``},l=!1,u=[],d=e(`select.log-select`,{onchange:e=>v({level:e.target.value})},...G.map(t=>e(`option`,{value:t.value},t.label))),f=e(`select.log-select`,{onchange:e=>v({component:e.target.value})}),h=e(`input.log-search`,{type:`search`,placeholder:`Search messages and fields…`,oninput:ce(e=>v({q:e.target.value}),250)}),g=e(`button.btn`,{onclick:y},`Pause`);b(),x();let _=m(e=>C(e),e=>{a.className=`pill pill-${e===`live`?`ok`:`warn`}`,a.textContent=e});t.addEventListener(`archie:teardown`,_);function v(e){c={...c,...e},x()}function y(){l=!l,g.textContent=l?`Resume`:`Pause`,g.classList.toggle(`btn-primary`,l)}function b(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Logs`),e(`p.page-sub`,`What Archie has been doing, newest last.`)),e(`div.page-actions`,g,e(`button.btn`,{onclick:x},`Refresh`))),e(`div.card`,e(`div.card-head`,e(`div.log-filters`,d,f,h),e(`div.log-status`,o,a)),i))}async function x(){n(i,e(`div.log-loading`,`Loading…`));try{let e=await p.logs({level:c.level,component:c.component,q:c.q,limit:500});if(e.disabled){n(i,s(`File logging is off`,`Set [log] file in your config to keep a durable record. Live lines below still stream while this page is open.`)),o.textContent=``;return}S(e.components||[]),o.textContent=e.truncated?`showing the most recent matches from ${e.file}`:e.file||``;let t=e.entries||[];if(!t.length){n(i,s(`Nothing matches`,`Try a wider level or clear the search.`));return}n(i,...t.map(J)),i.scrollTop=i.scrollHeight}catch(e){n(i,s(`Cannot read logs`,String(e.message||e)))}}function S(t){if(se(t,u))return;u=t;let r=c.component;n(f,e(`option`,{value:``},`All components`),...t.map(t=>e(`option`,{value:t},t))),f.value=r}function C(e){if(l)return;let t={time:e.at||new Date().toISOString(),level:e.level||`INFO`,msg:e.detail||e.message||e.kind||`event`,fields:e.task_id?{task:e.task_id}:null};if(!w(t))return;let n=i.scrollHeight-i.scrollTop-i.clientHeight<40;for(i.querySelector(`.empty, .log-loading`)&&i.replaceChildren(),i.append(J({...t,message:t.msg}));i.children.length>1e3;)i.firstElementChild.remove();n&&(i.scrollTop=i.scrollHeight)}function w(e){if(c.level&&!c.level.split(`,`).includes((e.level||``).toUpperCase())||c.component&&e.fields?.component!==c.component)return!1;if(c.q){let t=c.q.toLowerCase();if(!`${e.msg} ${JSON.stringify(e.fields||{})}`.toLowerCase().includes(t))return!1}return!0}return t}function J(t){let n=t.fields||{};return e(`div.log-row.log-${K(t.level)}`,e(`span.log-time.mono`,oe(t.time)),e(`span.log-level`,(t.level||`info`).toUpperCase()),e(`span.log-body`,e(`span.log-msg`,t.message||t.msg||``),...Object.entries(n).map(([t,n])=>e(`span.log-field`,e(`span.log-field-key`,t),String(ae(n))))))}function ae(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function oe(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function se(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function ce(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function le(){let t=e(`div`),r=e(`div`);i(),a();function i(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Memory`),e(`p.page-sub`,`What Archie can recall between conversations, and the tools it uses to do it.`)),e(`div.page-actions`,e(`button.btn`,{onclick:a},l(`refresh`,{size:15}),`Refresh`))),r)}async function a(){n(r,e(`div.card`,e(`div.mem-loading`,`Loading…`)));try{let t=await p.memory();if(!t.enabled||!t.providers?.length){n(r,e(`div.card`,s(`Memory is not configured`,`Without a provider, Archie starts every conversation with no recollection of earlier ones.`)));return}n(r,e(`div.grid.grid-2`,...t.providers.map(ue)))}catch(t){n(r,e(`div.card`,s(`Cannot read memory providers`,String(t.message||t))))}}return t}function ue(t){let n=t.tools||[];return e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,t.name||`provider`),e(`p.card-sub`,Y(t.role))),t.available?r(`ready`,`ok`):r(`unavailable`,`danger`)),!t.available&&e(`p.mem-warning`,`Configured but not usable right now — a required binary or connection may be missing.`),n.length?e(`ul.mem-tools`,...n.map(t=>e(`li.mem-tool`,e(`div.mem-tool-name.mono`,t.name),t.description&&e(`div.mem-tool-desc`,t.description)))):e(`p.mem-warning`,`This provider exposes no tools, so the agent cannot use it.`))}function Y(e){return e===`external`?`Added by you — an external store Archie was given`:`Built in — always available to Archie`}var X=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:y},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:D},{path:`/logs`,label:`Logs`,icon:`logs`,view:q},{path:`/skills`,label:`Skills`,icon:`skills`,view:O},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:te},{path:`/memory`,label:`Memory`,icon:`memory`,view:le},{path:`/channels`,label:`Channels`,icon:`channels`,view:N},{path:`/settings`,label:`Configuration`,icon:`settings`,view:ne}],Z=`archie.theme`;function Q(e){document.documentElement.dataset.theme=e,localStorage.setItem(Z,e)}function $(){return localStorage.getItem(Z)||`dark`}function de(t){let r=new Map,i=e(`nav.nav`,...[null].flatMap(()=>[...X.map(n=>{let i=e(`a.nav-item`,{href:`#${n.path}`,onclick:e=>{n.soon?e.preventDefault():t(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},l(n.icon),e(`span.nav-label`,n.label),n.soon&&e(`span.nav-soon`,`soon`));return r.set(n.path,i),i})])),a=e(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{Q($()===`dark`?`light`:`dark`),n(a,l($()===`dark`?`moon`:`sun`))}});n(a,l($()===`dark`?`moon`:`sun`));let o=e(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:e=>{if(e.key!==`Enter`)return;let n=e.target.value.trim().toLowerCase(),r=X.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(t(r.path),e.target.value=``,e.target.blur())}});return{node:e(`header.topbar`,e(`div.brand`,e(`span.brand-mark`,`A`),`Archie`),i,e(`div.topbar-end`,e(`div.topbar-search`,l(`search`,{size:15}),o),e(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},l(`help`)),a,e(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,n]of r)t===e?n.setAttribute(`aria-current`,`page`):n.removeAttribute(`aria-current`)}}}function fe(){Q($());let t=e(`main.main`),r=de(i);n(document.getElementById(`app`),e(`div.shell`,r.node,t));function i(e){location.hash===`#${e}`?a(e):location.hash=e}function a(e){t.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let i=X.find(t=>t.path===e)||X[0];r.highlight(i.path),n(t,i.view?i.view():pe(i))}window.addEventListener(`hashchange`,()=>a(location.hash.slice(1)||`/`)),a(location.hash.slice(1)||`/`)}function pe(t){return e(`div`,e(`div.page-head`,e(`div`,e(`h1.page-title`,t.label))),e(`div.card`,e(`div.empty`,e(`div.empty-title`,`${t.label} is not built yet`),e(`div`,`This section is next up. Nothing is broken.`))))}fe();