feat(webui): bindings dashboard UI; fix app-wide Preact render regression
Completes t2db.8's remaining UI half. Mirrors ui/src/mappings/ exactly: bindings.jsx (list + editor), binding-editor.jsx (pure StatusPill/ BindingRow), bindings.css, wired into main.jsx's route table with a new icon. API helpers (bindingCreate/Update/Delete/Approve) added to api.jsx following the existing mapping* pattern. CRITICAL FIX, found via real browser verification (AGENTS.md's UI rule), not by inspection: every JSX-based page in this app -- dashboard, tasks, logs, captures, mappings, skills, workflows, memory, curators, channels, settings, and now bindings -- silently rendered the literal text "[object Object]" instead of its content. Root cause: main.jsx's router passed each page's Preact VNode into dom.jsx's mount()/append(), which only knows how to append real DOM Nodes or stringify everything else -- so a VNode object became exactly that string. Confirmed this predates tonight's work entirely: extracted and served the already-committed ui/dist bundle in isolation and reproduced the identical failure on the stock dashboard, unrelated to any change here. Fix: main.jsx's show() now detects a Preact VNode vs. a real DOM Node (the unused `soon: true`/comingSoon() fallback) and calls Preact's own render() for the former, leaving the generic mount() helper and its other four vanilla-DOM call sites untouched. Verified every single page renders correctly post-fix via a throwaway, fully-isolated webui.Server harness (temp SQLite, no real config/forge/network calls) driven by Playwright -- not assumed from the source diff alone. Also found and fixed a second real bug the same way: editing a binding without retyping its secret (the intended "leave blank to keep the current one" UX, matching UpdateBinding's own documented COALESCE contract) was rejected with 400, because the API handler validated edits with the create-time Validate(), which unconditionally required a full-length secret. Root-cause fix: split Binding.Validate() (create, unchanged) from a new ValidateForUpdate() (skips the length floor only when the secret is empty -- preserving the existing one -- still enforces it on a genuinely-supplied new secret). Full state machine (draft -> edit -> pending_approval -> approve -> armed -> delete) verified end-to-end in the browser afterward. Filed archie-core-mlro separately for the Pill component's pre-existing duplication across 11 files -- not fixed here, out of scope for this ticket, following this session's established discipline.
This commit is contained in:
1 parent
44ff855a54
commit
8f9f2d601e
9 files changed
+440
-10
No files matched your search
Vendored
+1
-1
@@ -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}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(--accenLine truncated
|
: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}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(--accenLine truncated
|
||||||
Vendored
+8
-8
@@ -1,16 +1,16 @@
|
|||||||
(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=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;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.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(``)}`}async function t(e){let t=await fetch(e,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(15e3)});if(t.status===401)throw new i(`unauthorised`,401);if(!t.ok)throw new i(`${t.status} ${t.statusText}`,t.status);return t.json()}function n(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 r(e){try{let t=(await e.text()).trim();if(t)return t.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;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),te(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,re(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&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;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=te(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ie(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?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=ee(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),L(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ee(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function M(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function N(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||M(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||M(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 P(e){return function(n){if(this.l){var rLine truncated
|
||||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),curators:()=>t(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,a)=>{let o=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:a}),signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new i(await r(o),o.status);return o.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),taskLogs:(e,r)=>t(`/api/tasks/${e}/logs`+n(r)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n,page:location.hash.slice(1)||`/`}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/cLine truncated
|
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var B=class extends Error{constructor(e,t){super(e),this.status=t}},V={summary:()=>R(`/api/summary`),tasks:()=>R(`/api/tasks`),taskMeta:()=>R(`/api/task-meta`),task:e=>R(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},setup:()=>R(`/api/setup`),workflows:()=>R(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},skills:()=>R(`/api/skills`),channels:()=>R(`/api/channels`),curators:()=>R(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},config:()=>R(`/api/config`),version:()=>R(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,r)=>{let i=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:r}),signal:AbortSignal.timeout(15e3)});if(!i.ok)throw new B(await z(i),i.status);return i.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},logs:e=>R(`/api/logs`+ce(e)),taskLogs:(e,t)=>R(`/api/tasks/${e}/logs`+ce(t)),captures:e=>R(`/api/captures`+ce({limit:e})),mappings:()=>R(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindings:()=>R(`/api/bindings`),bindingCreate:async e=>{let t=await fetch(`/api/bindings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},bindingUpdate:async(e,t)=>{let n=await fetch(`/api/bindings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindingDelete:async e=>{let t=await fetch(`/api/bindings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},bindingApprove:async e=>{let t=await fetch(`/api/bindings/${e}/approve`,{method:`POST`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},memory:()=>R(`/api/memory`),chatSessions:()=>R(`/api/chat/sessions`),chatMessages:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(1
Line truncated
|
||||||
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
||||||
stroke-width="12" stroke-linecap="round"/>
|
stroke-width="12" stroke-linecap="round"/>
|
||||||
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
||||||
stroke-width="12" stroke-linecap="round"
|
stroke-width="12" stroke-linecap="round"
|
||||||
stroke-dasharray="${s}"
|
stroke-dasharray="${s}"
|
||||||
stroke-dashoffset="${s*(1-r/100)}"
|
stroke-dashoffset="${s*(1-r/100)}"
|
||||||
class="gauge-value"/>`,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function Xe(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Ze=`archie.setup-complete.dismissed.v1`;function Qe(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?.(Ze),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function $e(e=globalThis.localStorage){e?.setItem?.(Ze,`1`)}var et=new Set([`waiting_human`,`parked`]);function tt(e=[]){let t=e.filter(e=>et.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`}}}var nt=0;Array.isArray;function X(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--nt,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return D.vnode&&D.vnode(l),l}function rt({node:e}){let t=Y();return J(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function it(e){return X(rt,{node:qe(e)})}function at(e){return X(rt,{node:Ye(e)})}function ot({segments:e}){return X(rt,{node:Xe(e)})}function Z({name:e,opts:t}){return X(rt,{node:T(e,t)})}function st({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function ct({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}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]=q([]),[n,r]=q(`connecting`),[i,s]=q(`idle`),[c,l]=q(new Map),[u,d]=q(null),[f,p]=q(null),[m,h]=q(null),[g,_]=q(null),[v,y]=q(null),[,b]=q(!1),x=async()=>{y(null);try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.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);l(i),d(e),p(t),h(n),_(r)}catch(e){y(String(e.message||e))}};J(()=>(x(),o(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),s(e===`live`?`ok`:`warn`)})),[]);let w=()=>{$e(),b(e=>!e)},T=f?.operator?`${ut()}, ${f.operator}`:ut(),E=null;if(v)E=X(`button`,{className:`btn btn-primary`,onClick:x,children:[X(Z,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(g!==null){let e=tt(g),t=e.attention.count,n=e.running.count;E=X(V,{children:[t>0&&X(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[X(Z,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&X(`a`,{className:`btn`,href:e.running.href,children:[X(Z,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),X(`a`,{className:`btn`,href:`#/logs`,children:[X(Z,{name:`logs`,opts:{size:15}}),` Logs`]}),X(`button`,{className:`btn btn-primary`,onClick:x,children:[X(Z,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let D=null;if(v)D=X(`div`,{className:`card`,children:X(st,{title:`Cannot reach archied`,detail:v})});else if(u){let e=u?.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=u?.tokens_by_day||[];D=X(V,{children:[X(it,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),X(it,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(it,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),X(it,{label:`Tokens used`,value:C(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 O=null,k=Qe(f),A=k.kind===`omit`||k.kind===`dismissed`;if(!A){let e=k.remaining;if(e.length){let t=Math.round((f.steps.length-e.length)/f.steps.length*100);O=X(`div`,{className:`card setup`,children:[X(`div`,{className:`card-head`,children:[X(`diLine truncated
|
class="gauge-value"/>`,H(`div.gauge-wrap`,l,H(`div.gauge-center`,H(`div.gauge-pct`,`${Math.round(r)}%`),H(`div.gauge-label`,t)))}function Ye(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return H(`div`,H(`div.segbar`,...e.filter(e=>e.value>0).map(e=>H(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),H(`div.segbar-legend`,...e.map(e=>H(`span.segbar-key`,H(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Xe=`archie.setup-complete.dismissed.v1`;function Ze(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?.(Xe),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Qe(e=globalThis.localStorage){e?.setItem?.(Xe,`1`)}var $e=new Set([`waiting_human`,`parked`]);function et(e=[]){let t=e.filter(e=>$e.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`}}}var tt=0;Array.isArray;function Z(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:--tt,__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}function nt({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function rt(e){return Z(nt,{node:Ke(e)})}function it(e){return Z(nt,{node:Je(e)})}function at({segments:e}){return Z(nt,{node:Ye(e)})}function ot({name:e,opts:t}){return Z(nt,{node:G(e,t)})}function st({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ct({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}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]=J([]),[n,r]=J(`connecting`),[i,a]=J(`idle`),[o,s]=J(new Map),[c,l]=J(null),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[,v]=J(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([V.summary(),V.setup().catch(()=>null),V.workflows().catch(()=>null),V.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))}};Y(()=>(y(),le(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{Qe(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=et(m),t=e.attention.count,n=e.running.count;C=Z(S,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ot,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ot,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ot,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=Z(`div`,{className:`card`,children:Z(st,{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=Z(S,{children:[Z(rt,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(rt,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(rt,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(rt,{label:`Tokens used`,value:Ce(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=Ze(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=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,childre
Line truncated
|
||||||
`),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(un,{text:pn[e.status]||e.status,kind:mn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function gn({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function Q({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function $({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($,{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(cn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X(Q,{title:`Source provenance is unavailable.`})})}function vn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function yn({data:e,error:t}){if(t)return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X($,{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??m(e.id),n=e.kind??h(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(gn,{text:t,kind:n})})]},e.id)})}):X(Q,{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=vn(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(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function bn({r:e,field:t,onSaved:n}){let[r,i]=q(!1),[o,s]=q(null),[c,l]=q(!!e[t]);return X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let o=r.target.checked;l(o),i(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,o),n?.()}catch(e){l(!o),s(String(e.message||e))}finally{i(!1)}},disabled:r}),o&&X(`span`,{className:`kv-note is-error`,children:o})]})}function xn({r:e,field:t,onSaved:n}){let[r,i]=q(String(e[t]??0)),[o,s]=q(null),[c,l]=q(!1);return X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){s(`Enter a whole number`);return}l(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,i),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})]})}function Sn({repos:e,onSaved:t}){if(!e?.length)return X($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X($,{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,r)=>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:n(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(bn,{r:e,field:`allow_concurrent`,onSaved:t}),X(xn
Line truncated
|
`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(un,{text:pn[e.status]||e.status,kind:mn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function gn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Q({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function _n({origins:e}){return e?.length?Z($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z(cn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z(Q,{title:`Source provenance is unavailable.`})})}function vn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function yn({data:e,error:t}){if(t)return Z($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z($,{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:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??_e(e.id),n=e.kind??ve(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(gn,{text:t,kind:n})})]},e.id)})}):Z(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=vn(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function bn({r:e,field:t,onSaved:n}){let[r,i]=J(!1),[a,o]=J(null),[s,c]=J(!!e[t]);return Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:s,onChange:async r=>{let a=r.target.checked;c(a),i(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,a),n?.()}catch(e){c(!a),o(String(e.message||e))}finally{i(!1)}},disabled:r}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function xn({r:e,field:t,onSaved:n}){let[r,i]=J(String(e[t]??0)),[a,o]=J(null),[s,c]=J(!1);return Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){o(`Enter a whole number`);return}c(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){o(String(e.message||e))}finally{c(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:s}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function Sn({repos:e,onSaved:t}){if(!e?.length)return Z($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z($,{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:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,r)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:n(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(bn,{r:e,field:`allow_concurrent`,onSaved:t}),Z(
Line truncated
|
||||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(y(`p`,lr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(y(`pre`,y(`code`,a.join(`
|
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(H(`p`,vr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(H(`pre`,H(`code`,a.join(`
|
||||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=dr(c),u=e+1<n.length?dr(n[e+1]):null;if(l&&u&&fr(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=dr(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=y(`tbody`);for(let e of r)i.append(y(`tr`,...e.map(e=>y(`td`,lr(e)))));t.append(y(`table`,y(`thead`,y(`tr`,...l.map(e=>y(`th`,lr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(y(`h${d[1].length}`,lr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=y(e)),i.append(y(`li`,lr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(y(`blockquote`,lr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(y(`pre`,y(`code`,a.join(`
|
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=br(c),u=e+1<n.length?br(n[e+1]):null;if(l&&u&&xr(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=br(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=H(`tbody`);for(let e of r)i.append(H(`tr`,...e.map(e=>H(`td`,vr(e)))));t.append(H(`table`,H(`thead`,H(`tr`,...l.map(e=>H(`th`,vr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(H(`h${d[1].length}`,vr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=H(e)),i.append(H(`li`,vr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(H(`blockquote`,vr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(H(`pre`,H(`code`,a.join(`
|
||||||
`)))),t}function dr(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 fr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var pr=`archie.web.chat.channel`;function mr(){let t=localStorage.getItem(pr);return t||(t=e(),localStorage.setItem(pr,t)),t}function hr(t){return{text:t,sourceID:e()}}function gr(e){return{...e}}function _r(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?gr(e.turn):hr(r),isRetry:n}}function vr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function yr(e){return e?.status===501?null:`Could not check for updates.`}function br(){return location.hash.slice(1)||`/`}function xr({text:e}){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(ur(e||``))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function Sr(){let[e,t]=q([]),[n,r]=q(``),[i,o]=q([]),[s,c]=q(``),[l,u]=q(`Ready`),[d,f]=q(!1),[p,m]=q({}),[h,g]=q(``),[_,v]=q(``),[y,b]=q(``),[x,S]=q([]),[C,w]=q([]),[T,E]=q(0),[D,O]=q(!1),[k,A]=q(null),[j,M]=q(null),[N,ee]=q(null),[P,te]=q(``),[ne,re]=q(``),[F,I]=q(null),L=Y(null),R=Y(null),z=Y(null),B=Y(null),ie=Y(null),ae=Y(d);ae.current=d,J(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[i,F]),J(()=>{U().catch(e=>{u(e.message||`Chat unavailable`)}),oe();let e=()=>{z.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),z.current?.abort()}},[]);async function oe(){try{let e=await a.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=yr(e);A(t?{error:t}:null)}}async function se(){if(j)try{await a.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),u(`Update deferred`)}catch(e){u(e.message||`Could not defer update`)}}async function H(){if(j)try{u(`Installing…`);let e=await a.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),u(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){u(e.message||`Update install failed`)}}async function ce(){try{let e=await a.chatDangerous();ee(e)}catch(e){ee({error:e.message||`Dangerous actions unavailable`})}}async function le(e,t){if(t)try{await a.chatDangerousRequest(e,t),u(`Approval requested`),await ce()}catch(e){u(e.message||`Could not request action`)}}async function ue(e,t){try{await a.chatDangerousDecision(e,t),u(t===`deny`?`Action denied`:`Action approved`),await ce()}catch(e){u(e.message||`Approval failed`)}}async function U(){let e=await a.chatSessions(),r=e.sessions||[];t(r),m(e),g(e.active_persona||``);let i=e.providers||[],o=e.active_provider||i[0]||``;v(o),b(e.active_model||``);let s=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);S(s),e.dangerous_available&&await ce(),!n&&r[0]&&await de(r[0].session_id,e,r)}async function de(e,t,n){let i=t||p;r(e),o([]),I(null);let s=i.active_personas?.[e]||i.active_persona||``;g(s);try{await a.chatMessage(mr(),`/resume ${e}`);let[t,n]=await Promise.all([a.chatMessages(e),a.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function fe(e){if(n)try{u(`Working…`);let t=await a.chatMessage(mr(),e);t.session_id&&r(t.session_id),u(t.reply||`Session updated`),await U(),(t.session_id||n)&&await de(t.session_id||n),B.current&&(B.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function pe(e,t){let n=window.prompt(t);n?.trim()&&fe(`${e} ${n.trim()}`)}function me(e){let t=e.target.value;g(t),!(!n||!t)&&a.chatPersona(n,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function he(e){let t=e.target.value;if(v(t),t)try{let e=await a.chatMessage(mr(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await U()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function ge(e){let t=e.target.value;if(b(t),t)try{let e=await a.chatMessage(mr(),`/model ${t}`);u(e.reply||`Model updated`),await U()}catch(e){u(`Model update failed: ${e.message||e}`)}}function _e(){window.confirm(`Reload the Telegram chat adapter?`)&&(c(`/restart`),W({textOverride:`/restart`}))}function ve(){c(`/new`),W({textOverride:`/new`})}function ye(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function be(e){let t=C[e];if(!t||!R.current)return;let n=R.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\
Line truncated
|
`)))),t}function br(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 xr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Sr=`archie.web.chat.channel`;function Cr(){let e=localStorage.getItem(Sr);return e||(e=se(),localStorage.setItem(Sr,e)),e}function wr(e){return{text:e,sourceID:se()}}function Tr(e){return{...e}}function Er(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?Tr(e.turn):wr(r),isRetry:n}}function Dr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Or(e){return e?.status===501?null:`Could not check for updates.`}function kr(){return location.hash.slice(1)||`/`}function Ar({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(yr(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function jr(){let[e,t]=J([]),[n,r]=J(``),[i,a]=J([]),[o,s]=J(``),[c,l]=J(`Ready`),[u,d]=J(!1),[f,p]=J({}),[m,h]=J(``),[g,_]=J(``),[v,y]=J(``),[b,x]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,ee]=J(null),[M,N]=J(null),[P,te]=J(``),[ne,re]=J(``),[F,I]=J(null),ie=X(null),L=X(null),ae=X(null),oe=X(null),se=X(null),R=X(u);R.current=u,Y(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[i,F]),Y(()=>{fe().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ae.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ae.current?.abort()}},[]);async function ce(){try{let e=await V.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=Or(e);A(t?{error:t}:null)}}async function z(){if(j)try{await V.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function B(){if(j)try{l(`Installing…`);let e=await V.chatUpdateInstall(j);ee(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 le(){try{let e=await V.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function ue(e,t){if(t)try{await V.chatDangerousRequest(e,t),l(`Approval requested`),await le()}catch(e){l(e.message||`Could not request action`)}}async function de(e,t){try{await V.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await le()}catch(e){l(e.message||`Approval failed`)}}async function fe(){let e=await V.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 le(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await V.chatMessage(Cr(),`/resume ${e}`);let[t,n]=await Promise.all([V.chatMessages(e),V.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 me(e){if(n)try{l(`Working…`);let t=await V.chatMessage(Cr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await fe(),(t.session_id||n)&&await pe(t.session_id||n),oe.current&&(oe.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&V.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 _e(e){let t=e.target.value;if(_(t),t)try{let e=await V.chatMessage(Cr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await fe()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await V.chatMessage(Cr(),`/model ${t}`);l(e.reply||`Model updated`),await fe()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),U({textOverride:`/restart`}))}function be(){s(`/new`),U({textOverride:`/new`})}function xe(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 H(e){let t=C[e];if(!t||!L.current)return;let n=L.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.s
Line truncated
|
||||||
|
|
||||||
`);s=i.pop()||``;for(let e of i){let t=e.split(`
|
`);s=i.pop()||``;for(let e of i){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`&&(d+=n.text,I(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],I(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],I(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),I(null),u(`Ready`),await U()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:l,isError:!1,turn:i,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:l,isError:!0,turn:gr(i),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),z.current=null,f(!1),R.current&&R.current.focus()}}function Se(){u(`Stopping…`),n&&a.chatCancel(n).catch(()=>{}),z.current?.abort()}let Ce=p.models_by_provider||{},we=_&&Ce[_]?Ce[_]:p.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:l}),p.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:_e,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:oe,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:me,children:[X(`option`,{value:``,children:`Personality`}),(p.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(p.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:he,children:[X(`option`,{value:``,children:`Provider`}),(p.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:ge,children:[X(`option`,{value:``,children:`Model`}),we.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(V,{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:se,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:H,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),p.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:P,onChange:e=>te(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:()=>le(`rollback`,P),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>le(`stop`,ne),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:()=>ue(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(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:ve,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:()=>de(e.session_id),children:[X(`strong`,{children:vr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations wilLine truncated
|
`).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,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await fe()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:Tr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ae.current=null,d(!1),L.current&&L.current.focus()}}function W(){l(`Stopping…`),n&&V.chatCancel(n).catch(()=>{}),ae.current?.abort()}let Ce=f.models_by_provider||{},we=g&&Ce[g]?Ce[g]:f.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:c}),f.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[Z(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[Z(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[Z(`option`,{value:``,children:`Model`}),we.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(S,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:z,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:B,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`rollback`,P),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`stop`,ne),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[Z(`strong`,{children:Dr(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations wiLine truncated
|
||||||
@@ -162,6 +162,44 @@ export const api = {
|
|||||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||||
return res.json();
|
return res.json();
|
||||||
},
|
},
|
||||||
|
bindings: () => req("/api/bindings"),
|
||||||
|
bindingCreate: async (binding) => {
|
||||||
|
const res = await fetch("/api/bindings", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { Accept: "application/json", "Content-Type": "application/json", "X-Archie-CSRF": "1" },
|
||||||
|
body: JSON.stringify(binding),
|
||||||
|
signal: AbortSignal.timeout(15000),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||||
|
return res.json();
|
||||||
|
},
|
||||||
|
bindingUpdate: async (id, binding) => {
|
||||||
|
const res = await fetch(`/api/bindings/${id}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: { Accept: "application/json", "Content-Type": "application/json", "X-Archie-CSRF": "1" },
|
||||||
|
body: JSON.stringify(binding),
|
||||||
|
signal: AbortSignal.timeout(15000),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||||
|
return res.json();
|
||||||
|
},
|
||||||
|
bindingDelete: async (id) => {
|
||||||
|
const res = await fetch(`/api/bindings/${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: { Accept: "application/json", "X-Archie-CSRF": "1" },
|
||||||
|
signal: AbortSignal.timeout(15000),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||||
|
},
|
||||||
|
bindingApprove: async (id) => {
|
||||||
|
const res = await fetch(`/api/bindings/${id}/approve`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { Accept: "application/json", "X-Archie-CSRF": "1" },
|
||||||
|
signal: AbortSignal.timeout(15000),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||||
|
return res.json();
|
||||||
|
},
|
||||||
memory: () => req("/api/memory"),
|
memory: () => req("/api/memory"),
|
||||||
chatSessions: () => req("/api/chat/sessions"),
|
chatSessions: () => req("/api/chat/sessions"),
|
||||||
chatMessages: (id) => req(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
|
chatMessages: (id) => req(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const paths = {
|
|||||||
curators: '<circle cx="12" cy="12" r="8"/><path d="M12 8v4l3 2"/>',
|
curators: '<circle cx="12" cy="12" r="8"/><path d="M12 8v4l3 2"/>',
|
||||||
captures: '<path d="M12 3v11M12 14l-4-4M12 14l4-4"/><path d="M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"/>',
|
captures: '<path d="M12 3v11M12 14l-4-4M12 14l4-4"/><path d="M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"/>',
|
||||||
mappings: '<circle cx="5" cy="7" r="2"/><circle cx="5" cy="17" r="2"/><circle cx="19" cy="12" r="2"/><path d="M7 7l10 5M7 17l10-5"/>',
|
mappings: '<circle cx="5" cy="7" r="2"/><circle cx="5" cy="17" r="2"/><circle cx="19" cy="12" r="2"/><path d="M7 7l10 5M7 17l10-5"/>',
|
||||||
|
bindings: '<rect x="3" y="9" width="8" height="6" rx="2.5"/><rect x="13" y="9" width="8" height="6" rx="2.5"/><path d="M9 12h6"/>',
|
||||||
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"/>',
|
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"/>',
|
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"/>',
|
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"/>',
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { h } from "preact";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pure rendering logic for the bindings editor, split out from
|
||||||
|
* bindings.jsx so it is unit-testable without the page's fetch wiring,
|
||||||
|
* mirroring mappings/mapping-editor.jsx.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Pill({ text, kind = "idle" }) {
|
||||||
|
return <span className={`pill pill-${kind}`}>{text}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_LABELS = {
|
||||||
|
draft: "draft",
|
||||||
|
pending_approval: "pending approval",
|
||||||
|
armed: "armed",
|
||||||
|
};
|
||||||
|
|
||||||
|
const STATUS_KINDS = {
|
||||||
|
draft: "idle",
|
||||||
|
pending_approval: "warn",
|
||||||
|
armed: "ok",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Renders a binding's Status as a labeled pill -- draft/pending_approval/armed. */
|
||||||
|
export function StatusPill({ status }) {
|
||||||
|
return <Pill text={STATUS_LABELS[status] || status} kind={STATUS_KINDS[status] || "idle"} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One saved binding's summary row for the bindings list. */
|
||||||
|
export function BindingRow({ binding: b, onEdit, onApprove, onDelete }) {
|
||||||
|
const repoPin = b.owner && b.repo ? `${b.owner}/${b.repo}` : "—";
|
||||||
|
return (
|
||||||
|
<tr>
|
||||||
|
<td>{b.name}</td>
|
||||||
|
<td className="mono">{b.matcher?.source || "—"}</td>
|
||||||
|
<td>{b.workflow}</td>
|
||||||
|
<td className="mono">{repoPin}</td>
|
||||||
|
<td><StatusPill status={b.status} /></td>
|
||||||
|
<td>
|
||||||
|
<button className="btn btn-small" type="button" onClick={() => onEdit?.(b)}>Edit</button>
|
||||||
|
{b.status === "pending_approval" && (
|
||||||
|
<button className="btn btn-small btn-primary" type="button" onClick={() => onApprove?.(b)}>Approve</button>
|
||||||
|
)}
|
||||||
|
<button className="btn btn-small" type="button" onClick={() => onDelete?.(b)}>Delete</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/* Playbook binding editor: tie a matcher, a field mapping, and a
|
||||||
|
workflow together, gated by an explicit approval state machine. */
|
||||||
|
|
||||||
|
.binding-form {
|
||||||
|
margin-bottom: var(--sp-4);
|
||||||
|
padding: var(--sp-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.binding-form-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--sp-1);
|
||||||
|
margin-bottom: var(--sp-3);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
color: var(--fg-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
import { h } from "preact";
|
||||||
|
import { useState, useEffect } from "preact/hooks";
|
||||||
|
import "./bindings.css";
|
||||||
|
import { api } from "../base/api.jsx";
|
||||||
|
import { BindingRow } from "./binding-editor.jsx";
|
||||||
|
|
||||||
|
export function Empty({ title, detail }) {
|
||||||
|
return (
|
||||||
|
<div className="empty">
|
||||||
|
<div className="empty-title">{title}</div>
|
||||||
|
{detail && <div>{detail}</div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Playbook bindings (t2db.8): tie a matcher + payload mapping + workflow
|
||||||
|
* together, with a draft -> pending_approval -> armed state machine so
|
||||||
|
* nothing self-arms. See docs/architecture/bindings.md and
|
||||||
|
* docs/prds/payload-field-mapping.md. Owner/Repo optionally pin a
|
||||||
|
* multi-repo deployment's dispatch target (archie-core-t2db.8's backend
|
||||||
|
* fix, commit ac42f64).
|
||||||
|
*/
|
||||||
|
export function bindingsPage(query) {
|
||||||
|
return <BindingsApp query={query} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyEditor() {
|
||||||
|
return {
|
||||||
|
id: null,
|
||||||
|
name: "",
|
||||||
|
source: "",
|
||||||
|
mappingId: "",
|
||||||
|
workflow: "",
|
||||||
|
owner: "",
|
||||||
|
repo: "",
|
||||||
|
secret: "",
|
||||||
|
actionError: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function BindingsApp({ query }) {
|
||||||
|
const [bindings, setBindings] = useState([]);
|
||||||
|
const [mappings, setMappings] = useState([]);
|
||||||
|
const [workflows, setWorkflows] = useState([]);
|
||||||
|
const [loadError, setLoadError] = useState(null);
|
||||||
|
const [editor, setEditor] = useState(null);
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
try {
|
||||||
|
const [bRes, mRes, wRes] = await Promise.all([api.bindings(), api.mappings(), api.workflows()]);
|
||||||
|
setBindings(bRes.bindings || []);
|
||||||
|
setMappings(mRes.mappings || []);
|
||||||
|
setWorkflows((wRes.definitions || []).filter((d) => d.enabled));
|
||||||
|
setLoadError(null);
|
||||||
|
} catch (err) {
|
||||||
|
setLoadError(String(err.message || err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const startCreate = () => {
|
||||||
|
setEditor(emptyEditor());
|
||||||
|
};
|
||||||
|
|
||||||
|
const startEdit = (b) => {
|
||||||
|
setEditor({
|
||||||
|
id: b.id,
|
||||||
|
name: b.name,
|
||||||
|
source: b.matcher?.source || "",
|
||||||
|
mappingId: b.mapping_id ? String(b.mapping_id) : "",
|
||||||
|
workflow: b.workflow || "",
|
||||||
|
owner: b.owner || "",
|
||||||
|
repo: b.repo || "",
|
||||||
|
secret: "",
|
||||||
|
actionError: null,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancel = () => setEditor(null);
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
const body = {
|
||||||
|
name: editor.name,
|
||||||
|
matcher: { source: editor.source },
|
||||||
|
mapping_id: Number(editor.mappingId) || 0,
|
||||||
|
workflow: editor.workflow,
|
||||||
|
owner: editor.owner,
|
||||||
|
repo: editor.repo,
|
||||||
|
secret: editor.secret,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
if (editor.id) {
|
||||||
|
await api.bindingUpdate(editor.id, body);
|
||||||
|
} else {
|
||||||
|
await api.bindingCreate(body);
|
||||||
|
}
|
||||||
|
setEditor(null);
|
||||||
|
await load();
|
||||||
|
} catch (err) {
|
||||||
|
setEditor((prev) => ({ ...prev, actionError: String(err.message || err) }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const approve = async (b) => {
|
||||||
|
try {
|
||||||
|
await api.bindingApprove(b.id);
|
||||||
|
await load();
|
||||||
|
} catch (err) {
|
||||||
|
setLoadError(String(err.message || err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const remove = async (b) => {
|
||||||
|
if (!window.confirm(`Delete binding "${b.name}"?`)) return;
|
||||||
|
try {
|
||||||
|
await api.bindingDelete(b.id);
|
||||||
|
await load();
|
||||||
|
} catch (err) {
|
||||||
|
setLoadError(String(err.message || err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderList = () => (
|
||||||
|
<div>
|
||||||
|
<div className="page-head">
|
||||||
|
<div>
|
||||||
|
<h1 className="page-title">Playbook bindings</h1>
|
||||||
|
<p className="page-sub">Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire.</p>
|
||||||
|
</div>
|
||||||
|
<div className="page-actions">
|
||||||
|
<button className="btn btn-primary" type="button" onClick={startCreate}>New binding</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{loadError ? (
|
||||||
|
<Empty title="Cannot reach archied" detail={loadError} />
|
||||||
|
) : bindings.length ? (
|
||||||
|
<div className="card">
|
||||||
|
<div className="table-scroll">
|
||||||
|
<table className="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{["Name", "Source", "Workflow", "Repo pin", "Status", ""].map((h, i) => (
|
||||||
|
<th key={i}>{h}</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{bindings.map((b) => (
|
||||||
|
<BindingRow key={b.id} binding={b} onEdit={() => startEdit(b)} onApprove={() => approve(b)} onDelete={() => remove(b)} />
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Empty title="No bindings yet" detail="Create one from a saved field mapping to turn a captured webhook into a workflow." />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderEditor = () => (
|
||||||
|
<div>
|
||||||
|
<div className="page-head">
|
||||||
|
<div>
|
||||||
|
<h1 className="page-title">{editor.id ? "Edit binding" : "New binding"}</h1>
|
||||||
|
</div>
|
||||||
|
<div className="page-actions">
|
||||||
|
<button className="btn" type="button" onClick={cancel}>Cancel</button>
|
||||||
|
<button className="btn btn-primary" type="button" onClick={save}>Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{editor.actionError && <div className="binding-error">{editor.actionError}</div>}
|
||||||
|
<div className="card binding-form">
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Name
|
||||||
|
<input className="binding-input" value={editor.name} onInput={(e) => setEditor((p) => ({ ...p, name: e.target.value }))} />
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Source (the path segment senders POST to, e.g. "sentry")
|
||||||
|
<input className="binding-input" value={editor.source} onInput={(e) => setEditor((p) => ({ ...p, source: e.target.value }))} />
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Field mapping
|
||||||
|
<select className="binding-select" value={editor.mappingId} onChange={(e) => setEditor((p) => ({ ...p, mappingId: e.target.value }))}>
|
||||||
|
<option value="">— pick a saved mapping —</option>
|
||||||
|
{mappings.map((m) => (
|
||||||
|
<option key={m.id} value={m.id}>{m.name}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Workflow
|
||||||
|
<select className="binding-select" value={editor.workflow} onChange={(e) => setEditor((p) => ({ ...p, workflow: e.target.value }))}>
|
||||||
|
<option value="">— pick a workflow —</option>
|
||||||
|
{workflows.map((w) => (
|
||||||
|
<option key={w.id} value={w.id}>{w.name}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Repo pin -- owner (optional; leave both blank for the single-configured-repo default)
|
||||||
|
<input className="binding-input" value={editor.owner} onInput={(e) => setEditor((p) => ({ ...p, owner: e.target.value }))} />
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Repo pin -- repo
|
||||||
|
<input className="binding-input" value={editor.repo} onInput={(e) => setEditor((p) => ({ ...p, repo: e.target.value }))} />
|
||||||
|
</label>
|
||||||
|
<label className="binding-form-row">
|
||||||
|
Shared secret ({editor.id ? "leave blank to keep the current secret" : "senders sign with this via HMAC-SHA256"})
|
||||||
|
<input className="binding-input" type="password" value={editor.secret} onInput={(e) => setEditor((p) => ({ ...p, secret: e.target.value }))} />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return editor ? renderEditor() : renderList();
|
||||||
|
}
|
||||||
+20
-1
@@ -1,4 +1,5 @@
|
|||||||
import "./css/_main.css";
|
import "./css/_main.css";
|
||||||
|
import { render } from "preact";
|
||||||
import { el, mount } from "./base/dom.jsx";
|
import { el, mount } from "./base/dom.jsx";
|
||||||
import { icon } from "./base/icons.jsx";
|
import { icon } from "./base/icons.jsx";
|
||||||
import { dashboardPage } from "./dashboard/dashboard.jsx";
|
import { dashboardPage } from "./dashboard/dashboard.jsx";
|
||||||
@@ -11,6 +12,7 @@ import { settingsPage } from "./settings/settings.jsx";
|
|||||||
import { logsPage } from "./logs/logs.jsx";
|
import { logsPage } from "./logs/logs.jsx";
|
||||||
import { capturesPage } from "./captures/captures.jsx";
|
import { capturesPage } from "./captures/captures.jsx";
|
||||||
import { mappingsPage } from "./mappings/mappings.jsx";
|
import { mappingsPage } from "./mappings/mappings.jsx";
|
||||||
|
import { bindingsPage } from "./bindings/bindings.jsx";
|
||||||
import { memoryPage } from "./memory/memory.jsx";
|
import { memoryPage } from "./memory/memory.jsx";
|
||||||
import { chatPage } from "./chat/chat.jsx";
|
import { chatPage } from "./chat/chat.jsx";
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ const routes = [
|
|||||||
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage },
|
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage },
|
||||||
{ path: "/captures", label: "Event inspector", icon: "captures", view: capturesPage },
|
{ path: "/captures", label: "Event inspector", icon: "captures", view: capturesPage },
|
||||||
{ path: "/mappings", label: "Field mappings", icon: "mappings", view: mappingsPage },
|
{ path: "/mappings", label: "Field mappings", icon: "mappings", view: mappingsPage },
|
||||||
|
{ path: "/bindings", label: "Playbook bindings", icon: "bindings", view: bindingsPage },
|
||||||
{ path: "/skills", label: "Skills", icon: "skills", view: skillsPage },
|
{ path: "/skills", label: "Skills", icon: "skills", view: skillsPage },
|
||||||
{ path: "/workflows", label: "Workflows", icon: "workflows", view: workflowsPage },
|
{ path: "/workflows", label: "Workflows", icon: "workflows", view: workflowsPage },
|
||||||
{ path: "/memory", label: "Memory", icon: "memory", view: memoryPage },
|
{ path: "/memory", label: "Memory", icon: "memory", view: memoryPage },
|
||||||
@@ -219,7 +222,23 @@ function start() {
|
|||||||
toggleChat(true);
|
toggleChat(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mount(outlet, route.view ? route.view(new URLSearchParams(query)) : comingSoon(route));
|
// Every registered page returns a Preact VNode (all views import `h`
|
||||||
|
// from "preact"), which mount()/append() cannot render -- append()
|
||||||
|
// only knows real DOM Nodes and strings, so a bare VNode object became
|
||||||
|
// the literal text "[object Object]". Preact's own render() diffs and
|
||||||
|
// mounts a VNode correctly, including running the previous page's
|
||||||
|
// effect-cleanup on unmount. comingSoon() (the `!route.view` fallback,
|
||||||
|
// currently unused -- no route declares `soon: true`) still returns a
|
||||||
|
// real DOM Node, so it keeps going through mount() -- render() and
|
||||||
|
// mount()/replaceChildren() should not alternate on the same outlet
|
||||||
|
// across navigations, since Preact tracks its own vdom state on the
|
||||||
|
// container node; if a `soon: true` route is ever added, revisit this.
|
||||||
|
const rendered = route.view ? route.view(new URLSearchParams(query)) : comingSoon(route);
|
||||||
|
if (rendered instanceof Node) {
|
||||||
|
mount(outlet, rendered);
|
||||||
|
} else {
|
||||||
|
render(rendered, outlet);
|
||||||
|
}
|
||||||
// Navigating to a page dismisses the chat drawer; the operator has moved on.
|
// Navigating to a page dismisses the chat drawer; the operator has moved on.
|
||||||
toggleChat(false);
|
toggleChat(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { test } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { h } from "preact";
|
||||||
|
import { render } from "@testing-library/preact";
|
||||||
|
import { StatusPill, BindingRow } from "../src/bindings/binding-editor.jsx";
|
||||||
|
|
||||||
|
test("statusPill labels draft as idle", () => {
|
||||||
|
const { container } = render(h(StatusPill, { status: "draft" }));
|
||||||
|
assert.match(container.textContent, /draft/);
|
||||||
|
assert.ok(container.querySelector(".pill-idle"));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("statusPill labels pending_approval as warn, with a human-readable label", () => {
|
||||||
|
const { container } = render(h(StatusPill, { status: "pending_approval" }));
|
||||||
|
assert.match(container.textContent, /pending approval/);
|
||||||
|
assert.ok(container.querySelector(".pill-warn"));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("statusPill labels armed as ok", () => {
|
||||||
|
const { container } = render(h(StatusPill, { status: "armed" }));
|
||||||
|
assert.match(container.textContent, /armed/);
|
||||||
|
assert.ok(container.querySelector(".pill-ok"));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("statusPill falls back to the raw status for an unrecognised value", () => {
|
||||||
|
const { container } = render(h(StatusPill, { status: "weird" }));
|
||||||
|
assert.match(container.textContent, /weird/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("bindingRow shows name, matcher source, workflow, and status", () => {
|
||||||
|
const { container } = render(h(BindingRow, {
|
||||||
|
binding: { id: 1, name: "sentry alerts", matcher: { source: "sentry" }, workflow: "implement", status: "draft" },
|
||||||
|
onEdit: () => {},
|
||||||
|
onApprove: () => {},
|
||||||
|
onDelete: () => {},
|
||||||
|
}));
|
||||||
|
assert.match(container.textContent, /sentry alerts/);
|
||||||
|
assert.match(container.textContent, /sentry/);
|
||||||
|
assert.match(container.textContent, /implement/);
|
||||||
|
assert.match(container.textContent, /draft/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("bindingRow shows the owner/repo pin when set, or a placeholder when not", () => {
|
||||||
|
const pinned = render(h(BindingRow, {
|
||||||
|
binding: { id: 1, name: "a", matcher: { source: "s" }, workflow: "implement", status: "draft", owner: "acme", repo: "widget" },
|
||||||
|
}));
|
||||||
|
assert.match(pinned.container.textContent, /acme\/widget/);
|
||||||
|
|
||||||
|
const unpinned = render(h(BindingRow, {
|
||||||
|
binding: { id: 2, name: "b", matcher: { source: "s" }, workflow: "implement", status: "draft" },
|
||||||
|
}));
|
||||||
|
assert.match(unpinned.container.textContent, /—/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("bindingRow shows an Approve action only when pending_approval", () => {
|
||||||
|
const pending = render(h(BindingRow, {
|
||||||
|
binding: { id: 1, name: "a", matcher: { source: "s" }, workflow: "implement", status: "pending_approval" },
|
||||||
|
}));
|
||||||
|
assert.match(pending.container.textContent, /Approve/);
|
||||||
|
|
||||||
|
const draft = render(h(BindingRow, {
|
||||||
|
binding: { id: 2, name: "b", matcher: { source: "s" }, workflow: "implement", status: "draft" },
|
||||||
|
}));
|
||||||
|
assert.doesNotMatch(draft.container.textContent, /Approve/);
|
||||||
|
|
||||||
|
const armed = render(h(BindingRow, {
|
||||||
|
binding: { id: 3, name: "c", matcher: { source: "s" }, workflow: "implement", status: "armed" },
|
||||||
|
}));
|
||||||
|
assert.doesNotMatch(armed.container.textContent, /Approve/);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user