merge: t2db.40 sources and signing into pg/foundation

Resolves against t2db.36: captures carry both event_type and unsigned (proto field 10), the State Store serves sources and event types from the Postgres EDA store, the capture row shows event type and signature together, and the staterpc sentinels map both ways from one table.
This commit is contained in:
sam committed 2026-09-24 14:38:40 +10:00
commit 8a2b5b95f9
63 files changed
+3839 -1753

No files matched your search

+11 -11
View File
@@ -1,20 +1,20 @@
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(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 n=window.location.hash;if(n.startsWith(`#/`)){let e=n.slice(1);window.history.replaceState(null,``,e+window.location.search)}function r(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var i={},a=[],o=()=>{},s=()=>!1,c=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),l=e=>e.startsWith(`onUpdate:`),u=Object.assign,d=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},f=Object.prototype.hasOwnProperty,p=(e,t)=>f.call(e,t),m=Array.isArray,h=e=>ee(e)===`[object Map]`,g=e=>ee(e)===`[object Set]`,_=e=>ee(e)===`[object Date]`,v=e=>ee(e)===`[object RegExp]`,y=e=>typeof e==`function`,b=e=>typeof e==`string`,x=e=>typeof e==`symbol`,S=e=>typeof e==`object`&&!!e,C=e=>(S(e)||y(e))&&y(e.then)&&y(e.catch),w=Object.prototype.toString,ee=e=>w.call(e),te=e=>ee(e).slice(8,-1),ne=e=>ee(e)===`[object Object]`,re=e=>b(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,ie=r(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ae=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},oe=/-\w/g,se=ae(e=>e.replace(oe,e=>e.slice(1).toUpperCase())),ce=/\B([A-Z])/g,le=ae(e=>e.replace(ce,`-$1`).toLowerCase()),ue=ae(e=>e.charAt(0).toUpperCase()+e.slice(1)),T=ae(e=>e?`on${ue(e)}`:``),de=(e,t)=>!Object.is(e,t),fe=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},pe=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},me=e=>{let t=parseFloat(e);return isNaN(t)?e:t},he=e=>{let t=b(e)?Number(e):NaN;return isNaN(t)?e:t},ge,_e=()=>ge||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},ve=r(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function ye(e){if(m(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=b(r)?Ce(r):ye(r);if(i)for(let e in i)t[e]=i[e]}return t}if(b(e)||S(e))return e}var be=/;(?![^(]*\))/g,xe=/:([^]+)/,Se=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function Ce(e){let t={};return e.replace(Se,e=>e.startsWith(`/*`)?``:e).split(be).forEach(e=>{if(e){let n=e.split(xe);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function E(e){let t=``;if(b(e))t=e;else if(m(e))for(let n=0;n<e.length;n++){let r=E(e[n]);r&&(t+=r+` `)}else if(S(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function we(e){if(!e)return null;let{class:t,style:n}=e;return t&&!b(t)&&(e.class=E(t)),n&&(e.style=ye(n)),e}var Te=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Ee=r(Te);Te+``;function De(e){return!!e||e===``}function Oe(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=Me(e[i],t[i],n);return r}function ke(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&Me(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Ae(e,t,n){let r=h(e),i=h(t);if(r||i||(r=g(e),i=g(t),r||i))return r&&i?ke(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!Me(e[r],t[r],n))return!1}return String(e)===String(t)}function je(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function Me(e,t,n){if(e===t)return!0;let r=_(e),i=_(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=x(e),i=x(t),r||i?e===t:(r=m(e),i=m(t),r||i?r&&i?je(e,t,n,Oe):!1:(r=S(e),i=S(t),r||i?!r||!i?!1:je(e,t,n,Ae):String(e)===String(t))))}function Ne(e,t){return e.findIndex(e=>Me(e,t))}var Pe=e=>!!(e&&e.__v_isRef===!0),D=e=>b(e)?e:e==null?``:m(e)||S(e)&&(e.toString===w||!y(e.toString))?Pe(e)?D(e.value):JSON.stringify(e,Fe,2):String(e),Fe=(e,t)=>Pe(t)?Fe(e,t.value):h(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Ie(t,r)+` =>`]=n,e),{})}:g(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Ie(e))}Line truncated
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
`)&&(Ai(e,0)||bi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||c(a)&&!ie(a)||a[0]===`.`||t&&!ie(a)||u&&u.includes(a)){if(Di(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&ln(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Ps(x,n,t),h&&Tr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&us(()=>{x&&Ps(x,n,t),l&&g.enter(e),h&&Tr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=js(d[t]),g=h.type===ps;e?(g&&!u&&t+1<p&&js(d[t+1]).type===ps&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,Ai(r,1)||bi()),n(null,h,r,null,o,s,Ci(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&wi(f)&&f.data===`]`?a(t.anchor=f):(bi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,c,l)=>{if(Mi(e,t)||bi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)s(n);else break}}let u=a(e),d=o(e);return s(e),n(null,t,d,u,r,i,Ci(d),c),r&&(r.vnode.el=t.el,Co(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&wi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ei=new Set([`src`,`srcset`,`href`,`poster`]);function Di(e,t,n){return Ei.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Oi=`data-allow-mismatch`,ki={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function Ai(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Oi);)e=e.parentElement;return ji(e&&e.getAttribute(Oi),t)}function ji(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(ki[t])}}function Mi(e,t){return Ai(e.parentElement,1)||Ni(e)||Pi(t)}function Ni(e){return e.nodeType===1&&ji(e.getAttribute(Oi),1)}function Pi({props:e}){let t=e&&e[Oi];return typeof t==`string`&&ji(t,1)}var Fi=_e().requestIdleCallback||(e=>setTimeout(e,1)),Ii=_e().cancelIdleCallback||(e=>clearTimeout(e)),Li=(e=1e4)=>t=>{let n=Fi(t,{timeout:e});return()=>Ii(n)};function Ri(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var zi=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Ri(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Bi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Vi=(e=[])=>(t,n)=>{b(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Hi(e,t){if(wi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(wi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ui=e=>!!e.type.__asyncLoader;function Wi(e){y(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return M({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Hi(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Rs;if(pi(e),u)return()=>Gi(u,e);let t=t=>{l=null,Zn(t,e,13,!r)};if(s&&e.suspense||Gs)return p().then(t=>()=>Gi(t,e)).catch(e=>(t(e),()=>r?B(r,{error:e}):null));let a=O(!1),c=O(),d=O(!!i),f,m;return ca(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Gi(u,e);if(c.value&&r)return B(r,{error:c.value});if(n&& Line truncated
`))),e[Kl]=Ul(i);let a=r||i.props&&i.props.type===`number`;ul(e,t?`change`:`input`,t=>{t.target.composing||e[Kl](Jl(e.value,n,a))}),(n||a)&&ul(e,`change`,()=>{e.value=Jl(e.value,n,a)}),t||(ul(e,`compositionstart`,Wl),ul(e,`compositionend`,Gl),ul(e,`change`,Gl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ql];delete e[ql],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Kl](Jl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Kl]=Ul(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?me(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Xl={deep:!0,created(e,t,n){e[Kl]=Ul(n),ul(e,`change`,()=>{let t=e._modelValue,n=nu(e),r=e.checked,i=e[Kl];if(m(t)){let e=Ne(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(g(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(ru(e,r))})},mounted:Zl,beforeUpdate(e,t,n){e[Kl]=Ul(n),Zl(e,t,n)}};function Zl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(m(t))i=Ne(t,r.props.value)>-1;else if(g(t))i=t.has(r.props.value);else{if(t===n)return;i=Me(t,ru(e,!0))}e.checked!==i&&(e.checked=i)}var Ql={created(e,{value:t},n){e.checked=Me(t,n.props.value),e[Kl]=Ul(n),ul(e,`change`,()=>{e[Kl](nu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Kl]=Ul(r),t!==n&&(e.checked=Me(t,r.props.value))}},$l={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ul(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?me(nu(e)):nu(e)),r=e.multiple,i=r?g(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?m(i)?t.slice():t:i];try{e[Kl](i)}finally{or(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Kl]=Ul(r)},mounted(e,{value:t}){tu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Kl]=Ul(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!eu(t,n[1],n[0]))&&tu(e,t)}};function eu(e,t,n){if(!n||m(e))return Me(e,t);if(g(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function tu(e,t){let n=e.multiple,r=m(t);if(!n||r||g(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=nu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Ne(t,o)>-1}else a.selected=t.has(o)}else if(Me(nu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function nu(e){return`_value`in e?e._value:e.value}function ru(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var iu={created(e,t,n){ou(e,t,n,null,`created`)},mounted(e,t,n){ou(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){ou(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){ou(e,t,n,r,`updated`)}};function au(e,t){switch(e){case`SELECT`:return $l;case`TEXTAREA`:return Yl;default:switch(t){case`checkbox`:return Xl;case`radio`:return Ql;default:return Yl}}}function ou(e,t,n,r,i){let a=au(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function su(){Yl.getSSRProps=({value:e})=>({value:e}),Ql.getSSRProps=({value:e},t)=>{if(t.props&&Me(t.props.value,e))return{checked:!0}},Xl.getSSRProps=({value:e},t)=>{if(m(e)){if(t.props&&Ne(e,t.props.value)>-1)return{checked:!0}}else if(g(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},iu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=au(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var cu=[`ctrl`,`shift`,`alt`,`meta`],lu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>cu.some(n=>e[`${n}Key`]&&!t.includes(n))},uu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=lu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},du={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},fu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=le(n.key);if(t.some(e=>e===r||du[e]===r))return e(n)}))},pu=u({patchProp:Sl},Sc),mu,hu=!1;function gu(){return mu||=Uo(pu)}function _u(){return mu=hu?mu:Wo(pu),hu=!0,mu}var vu=((...e)=>{gu().render(...e)}),yu=((...e)=>{_u().hydrate(...e)}),bu=((...e)=>{let t=gu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Cu(e);if(!r)return;let i=t._component;!y(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Su(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),xu=(( Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Mp;function Np(e){Mp=e}var Pp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Fp(e){let t=e instanceof Pp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Ip(e,t){let n=await fetch(e,t);if(Mp?.(n.status===401),!n.ok)throw new Pp(await jp(n),n.status);return n}async function Lp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=kp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Ip(e,s);return a?await c.json():void 0}var J={health:()=>Lp(`/health/detailed`),summary:()=>Lp(`/api/summary`),tasks:()=>Lp(`/api/tasks`),taskMeta:()=>Lp(`/api/task-meta`),task:e=>Lp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Lp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/changes`+Ap(t)),taskDebug:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/debug`+Ap(t)),taskAction:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Lp(`/api/setup`),capabilities:()=>Lp(`/api/capabilities`),workflows:()=>Lp(`/api/workflows`),workRequest:e=>Lp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Lp(`/api/skills`),channels:()=>Lp(`/api/channels`),curators:()=>Lp(`/api/curators`),channelReload:e=>Lp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Lp(`/api/config`),logs:e=>Lp(`/api/logs`+Ap(e)),taskLogs:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/logs`+Ap(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Lp(`/api/version`),updateSnapshot:()=>Lp(`/api/chat/update`),updateInstall:e=>Lp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Lp(`/api/captures`+Ap({limit:e})),eventTypes:()=>Lp(`/api/event-types`),eventTypeCreate:e=>Lp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Lp(`/api/mappings`),mappingCreate:e=>Lp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Lp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Lp(`/api/bindings`),bindingCreate:e=>Lp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),chatSessions:()=>Lp(`/api/chat/sessions`),chatMessages:e=>Lp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Lp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Lp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Lp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Op(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Lp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Lp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Lp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Lp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Ip(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Rp(e,t){let n=new EventSource(`/api/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function zp(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Dp(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var Bp=`archie.web.chat.channel`;function Vp(){let e=localStorage.getItem(Bp);return e||(e=Op(),localStorage.setItem(Bp,e)),e}var Hp=/(?:^|\s)\/([^\s]*)$/,Up=/(?:^|\s)\/[^\s]*$/,Wp=8;function Gp(e,t,n){let r=t.slice(0,n).match(Hp);if(!r)return[];let i=r[1].toLowerCase();return e.filter(e=>`${e.command} ${e.description??``}`.toLowerCase().includes(i)).slice(0,Wp)}function Kp(e,t,n){let r=e.slice(0,t),i=e.slice(t),a=r.search(Up),o=a<0?r.length:a+ +(r[a]===` `);return{text:`$Line truncated
`))),e[Kl]=Ul(i);let a=r||i.props&&i.props.type===`number`;ul(e,t?`change`:`input`,t=>{t.target.composing||e[Kl](Jl(e.value,n,a))}),(n||a)&&ul(e,`change`,()=>{e.value=Jl(e.value,n,a)}),t||(ul(e,`compositionstart`,Wl),ul(e,`compositionend`,Gl),ul(e,`change`,Gl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ql];delete e[ql],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Kl](Jl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Kl]=Ul(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?me(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Xl={deep:!0,created(e,t,n){e[Kl]=Ul(n),ul(e,`change`,()=>{let t=e._modelValue,n=nu(e),r=e.checked,i=e[Kl];if(m(t)){let e=Ne(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(g(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(ru(e,r))})},mounted:Zl,beforeUpdate(e,t,n){e[Kl]=Ul(n),Zl(e,t,n)}};function Zl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(m(t))i=Ne(t,r.props.value)>-1;else if(g(t))i=t.has(r.props.value);else{if(t===n)return;i=Me(t,ru(e,!0))}e.checked!==i&&(e.checked=i)}var Ql={created(e,{value:t},n){e.checked=Me(t,n.props.value),e[Kl]=Ul(n),ul(e,`change`,()=>{e[Kl](nu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Kl]=Ul(r),t!==n&&(e.checked=Me(t,r.props.value))}},$l={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ul(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?me(nu(e)):nu(e)),r=e.multiple,i=r?g(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?m(i)?t.slice():t:i];try{e[Kl](i)}finally{or(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Kl]=Ul(r)},mounted(e,{value:t}){tu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Kl]=Ul(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!eu(t,n[1],n[0]))&&tu(e,t)}};function eu(e,t,n){if(!n||m(e))return Me(e,t);if(g(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function tu(e,t){let n=e.multiple,r=m(t);if(!n||r||g(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=nu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Ne(t,o)>-1}else a.selected=t.has(o)}else if(Me(nu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function nu(e){return`_value`in e?e._value:e.value}function ru(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var iu={created(e,t,n){ou(e,t,n,null,`created`)},mounted(e,t,n){ou(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){ou(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){ou(e,t,n,r,`updated`)}};function au(e,t){switch(e){case`SELECT`:return $l;case`TEXTAREA`:return Yl;default:switch(t){case`checkbox`:return Xl;case`radio`:return Ql;default:return Yl}}}function ou(e,t,n,r,i){let a=au(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function su(){Yl.getSSRProps=({value:e})=>({value:e}),Ql.getSSRProps=({value:e},t)=>{if(t.props&&Me(t.props.value,e))return{checked:!0}},Xl.getSSRProps=({value:e},t)=>{if(m(e)){if(t.props&&Ne(e,t.props.value)>-1)return{checked:!0}}else if(g(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},iu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=au(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var cu=[`ctrl`,`shift`,`alt`,`meta`],lu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>cu.some(n=>e[`${n}Key`]&&!t.includes(n))},uu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=lu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},du={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},fu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=le(n.key);if(t.some(e=>e===r||du[e]===r))return e(n)}))},pu=u({patchProp:Sl},Sc),mu,hu=!1;function gu(){return mu||=Uo(pu)}function _u(){return mu=hu?mu:Wo(pu),hu=!0,mu}var vu=((...e)=>{gu().render(...e)}),yu=((...e)=>{_u().hydrate(...e)}),bu=((...e)=>{let t=gu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Cu(e);if(!r)return;let i=t._component;!y(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Su(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),xu=(( Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Fp;function Ip(e){Fp=e}var Lp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Rp(e){let t=e instanceof Lp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function zp(e,t){let n=await fetch(e,t);if(Fp?.(n.status===401),!n.ok)throw new Lp(await Pp(n),n.status);return n}async function Bp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Mp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await zp(e,s);return a?await c.json():void 0}var J={health:()=>Bp(`/health/detailed`),summary:()=>Bp(`/api/summary`),tasks:()=>Bp(`/api/tasks`),taskMeta:()=>Bp(`/api/task-meta`),task:e=>Bp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Bp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Bp(`/api/tasks/${encodeURIComponent(e)}/changes`+Np(t)),taskDebug:(e,t)=>Bp(`/api/tasks/${encodeURIComponent(e)}/debug`+Np(t)),taskAction:(e,t)=>Bp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Bp(`/api/setup`),capabilities:()=>Bp(`/api/capabilities`),workflows:()=>Bp(`/api/workflows`),workRequest:e=>Bp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Bp(`/api/skills`),channels:()=>Bp(`/api/channels`),curators:()=>Bp(`/api/curators`),channelReload:e=>Bp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Bp(`/api/config`),logs:e=>Bp(`/api/logs`+Np(e)),taskLogs:(e,t)=>Bp(`/api/tasks/${encodeURIComponent(e)}/logs`+Np(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Bp(`/api/version`),updateSnapshot:()=>Bp(`/api/chat/update`),updateInstall:e=>Bp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Bp(`/api/captures`+Np({limit:e})),eventTypes:()=>Bp(`/api/event-types`),eventTypeCreate:e=>Bp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Bp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Bp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Bp(`/api/mappings`),mappingCreate:e=>Bp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Bp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Bp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Bp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Bp(`/api/bindings`),bindingCreate:e=>Bp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Bp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Bp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Bp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),sources:()=>Bp(`/api/sources`),sourceCreate:e=>Bp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Bp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Bp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Bp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Bp(`/api/chat/sessions`),chatMessages:e=>Bp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Bp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Bp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Bp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:jp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Bp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Bp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Bp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Bp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>zp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Vp(e,t){let n=new EventSource(`/api/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Hp(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Ap(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var Up=`archie.web.chat.channel`;function Wp(){let e=localStorage.getItem(Up);return e||(e= Line truncated
`);u=r.pop()||``;for(let e of r){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(em.value=n.session_id),n.type===`delta`&&(o+=n.text,am.value=am.value?{...am.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],am.value=am.value?{...am.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);tm.value=[...tm.value,{from:`assistant`,text:o,tool_calls:a}],am.value=null,rm.value=`Ready`,await bm()}catch(e){let t=e;t.name===`AbortError`&&!c?(am.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},rm.value=`Stopped`):(am.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Yp(r):void 0,isRetry:i},rm.value=`Error — retry available`)}finally{clearTimeout(l),vm=null,im.value=!1}}function Nm(){rm.value=`Stopping…`,em.value&&J.chatCancel(em.value).catch(()=>{}),ym()}function Pm(){ia(()=>{bm().catch(e=>{rm.value=e.message||`Chat unavailable`})}),ca(()=>{ym()})}var Fm=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Im=M({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return q(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(I(),L(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full bg-linear-to-br from-primary to-[var(--brand-alt)] text-primary-foreground shadow-[var(--shadow-md)] transition-[transform,box-shadow] duration-[140ms] hover:-translate-y-px hover:shadow-[0_12px_34px_var(--primary-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":k(Zp),onClick:i[0]||=e=>n(`toggle`)},[z(`span`,{"aria-hidden":`true`,class:E(r(!e.open))},[B(k(Pd),{size:22})],2),z(`span`,{"aria-hidden":`true`,class:E(r(e.open))},[B(k(Zd),{size:22})],2)],8,Fm))}});function Lm(e){return typeof e==`string`?`'${e}'`:new Vm().serialize(e)}var Rm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,zm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Rm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Bm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&zm[n]?zm[n]:n+128,s=a<128&&zm[a]?zm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Vm=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Bm(e,t):n===`number`&&r===`number`?e-t:Bm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Bm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`InLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(rm.value=n.session_id),n.type===`delta`&&(o+=n.text,cm.value=cm.value?{...cm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],cm.value=cm.value?{...cm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);im.value=[...im.value,{from:`assistant`,text:o,tool_calls:a}],cm.value=null,om.value=`Ready`,await Cm()}catch(e){let t=e;t.name===`AbortError`&&!c?(cm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},om.value=`Stopped`):(cm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Qp(r):void 0,isRetry:i},om.value=`Error — retry available`)}finally{clearTimeout(l),xm=null,sm.value=!1}}function Im(){om.value=`Stopping…`,rm.value&&J.chatCancel(rm.value).catch(()=>{}),Sm()}function Lm(){ia(()=>{Cm().catch(e=>{om.value=e.message||`Chat unavailable`})}),ca(()=>{Sm()})}var Rm=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],zm=M({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return q(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(I(),L(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full bg-linear-to-br from-primary to-[var(--brand-alt)] text-primary-foreground shadow-[var(--shadow-md)] transition-[transform,box-shadow] duration-[140ms] hover:-translate-y-px hover:shadow-[0_12px_34px_var(--primary-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":k(em),onClick:i[0]||=e=>n(`toggle`)},[z(`span`,{"aria-hidden":`true`,class:E(r(!e.open))},[B(k(Ld),{size:22})],2),z(`span`,{"aria-hidden":`true`,class:E(r(e.open))},[B(k(ef),{size:22})],2)],8,Rm))}});function Bm(e){return typeof e==`string`?`'${e}'`:new Wm().serialize(e)}var Vm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Hm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Vm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Um(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Hm[n]?Hm[n]:n+128,s=a<128&&Hm[a]?Hm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Wm=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Um(e,t):n===`number`&&r===`number`?e-t:Um(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Um),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`InLine truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?ac(t.default({present:o.value})[0],{ref:e=>{let t=hh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),xg=M({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=wh(n.default()),r=e.findIndex(e=>e.type!==ms);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?U(t,i.props):t,o=ks({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Sg=[`area`,`img`,`input`],X=M({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Sg.includes(r)?()=>ac(r,t):r===`template`?()=>ac(xg,t,{default:n.default}):()=>ac(e.as,t,{default:n.default})}});function Cg(){let e=O();return{primitiveElement:e,currentElement:W(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:hh(e))}}function wg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Tg({type:e,defaultValue:t,modelValue:n}){return e||wg({type:e,defaultValue:t,modelValue:n})}function Eg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Dg(e,t){let n=W(()=>Tg(e)),r=Ch(e,`modelValue`,t,{defaultValue:Eg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Hm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Jm(t,e)){let n=t.findIndex(t=>Hm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:W(()=>n.value===`single`)}}var[Og,kg]=Wm(`DialogRoot`),Ag=M({inheritAttrs:!1,__name:`DialogRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1,default:!1},modal:{type:Boolean,required:!1,default:!0},unmountOnHide:{type:Boolean,required:!1,default:!0}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Ch(n,`open`,t,{defaultValue:n.defaultOpen,passive:n.open===void 0}),i=O(),a=O(),{modal:o,unmountOnHide:s}=Dn(n);return kg({open:r,modal:o,unmountOnHide:s,openModal:()=>{r.value=!0},onOpenChange:e=>{r.value=e},onOpenToggle:()=>{r.value=!r.value},contentId:``,titleId:``,descriptionId:``,triggerElement:i,contentElement:a}),(e,t)=>P(e.$slots,`default`,{open:k(r),close:()=>r.value=!1})}}),jg=M({__name:`DialogClose`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Y();let n=Og();return(e,r)=>(I(),R(k(X),U(t,{type:e.as===`button`?`button`:void 0,onClick:r[0]||=e=>k(n).onOpenChange(!1)}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`type`]))}}),Mg=`dismissableLayer.pointerDownOutside`,Ng=`dismissableLayer.focusOutside`;function Pg(e,t){if(!(t instanceof Element))return!1;let n=t.closest(`[data-dismissable-layer]`),r=e.dataset.dismissableLayer===``?e:e.querySelector(`[data-dismissable-layer]`),i=Array.from(e.ownerDocument.querySelectorAll(`[data-dismissable-layer]`));return!!(n&&(r===n||i.indexOf(r)<i.indexOf(n)))}function Fg(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1),a=O(()=>{});return jr(o=>{if(!Qm||!Sn(n))return;let s=async n=>{let o=n.target;if(t?.value&&o){if(Pg(t.value,o)){i.value=!1;return}if(n.target&&!i.value){let t={originalEvent:n};function i(){Km(Mg,e,t)}n.pointerType===`touch`?(r.removeEventListener(`click`,a.value),a.value=i,r.addEventListener(`click`,a.value,{once:!0})):i()}else r.removeEventListener(`click`,a.value);i.value=!1}},c=window.setTimeout(()=>{r.addEventListener(`pointerdown`,s)},0);o(()=>{window.clearTimeout(c),r.removeEventListener(`pointerdown`,s),r.removeEventListener(`click`,a.value)})}),{onPointerDownCapture:()=>{Sn(n)&&(i.value=!0)}}}function Ig(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1);return jr(a=>{if(!Qm||!Sn(n))return;let o=async n=>{if(!t?.value)return;await or(),await or();let r=n.target;t.value&&r&&!Pg(t.value,r)&&n.target&&!i.value&&Km(Ng,e,{originalEvent:n})};r.addEventListener(`focusin`,o),a(()=>r.removeEventListener(`focusin`,o))}),{onFocusCapture:()=>{Sn(n)&&(i.value=!0)},onBlurCapture:()=>{Sn(n)&&(i.value=!1)}}}var Lg=M({__name:`DismissableLayer`,props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},present:{type:Boolean,required:!1,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`dismiss`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Y(),o=W(()=>a.value?.ownerDocument??globalThis.document),s=W(()=>Ah.layersRoot),c=W(()=>a.value?Array.from(s.value).indexOf(a.value):-1),l=W(()=>Ah.layersWithOutsidePointerEventsDisabled.size>0),u=W(()=>{let e=Array.from(s.value),[t]=[...Ah.layersWithOutsidePointerEventsDisabled].slice(-1),n=e.indexOf(t);return c.value>=n}),d=Fg Line truncated
`))}return()=>i.value||r.value||o.value?ac(t.default({present:o.value})[0],{ref:e=>{let t=vh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),wg=M({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Dh(n.default()),r=e.findIndex(e=>e.type!==ms);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?U(t,i.props):t,o=ks({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Tg=[`area`,`img`,`input`],X=M({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Tg.includes(r)?()=>ac(r,t):r===`template`?()=>ac(wg,t,{default:n.default}):()=>ac(e.as,t,{default:n.default})}});function Eg(){let e=O();return{primitiveElement:e,currentElement:W(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:vh(e))}}function Dg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Og({type:e,defaultValue:t,modelValue:n}){return e||Dg({type:e,defaultValue:t,modelValue:n})}function kg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Ag(e,t){let n=W(()=>Og(e)),r=Eh(e,`modelValue`,t,{defaultValue:kg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Gm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Zm(t,e)){let n=t.findIndex(t=>Gm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:W(()=>n.value===`single`)}}var[jg,Mg]=qm(`DialogRoot`),Ng=M({inheritAttrs:!1,__name:`DialogRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1,default:!1},modal:{type:Boolean,required:!1,default:!0},unmountOnHide:{type:Boolean,required:!1,default:!0}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Eh(n,`open`,t,{defaultValue:n.defaultOpen,passive:n.open===void 0}),i=O(),a=O(),{modal:o,unmountOnHide:s}=Dn(n);return Mg({open:r,modal:o,unmountOnHide:s,openModal:()=>{r.value=!0},onOpenChange:e=>{r.value=e},onOpenToggle:()=>{r.value=!r.value},contentId:``,titleId:``,descriptionId:``,triggerElement:i,contentElement:a}),(e,t)=>P(e.$slots,`default`,{open:k(r),close:()=>r.value=!1})}}),Pg=M({__name:`DialogClose`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Y();let n=jg();return(e,r)=>(I(),R(k(X),U(t,{type:e.as===`button`?`button`:void 0,onClick:r[0]||=e=>k(n).onOpenChange(!1)}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`type`]))}}),Fg=`dismissableLayer.pointerDownOutside`,Ig=`dismissableLayer.focusOutside`;function Lg(e,t){if(!(t instanceof Element))return!1;let n=t.closest(`[data-dismissable-layer]`),r=e.dataset.dismissableLayer===``?e:e.querySelector(`[data-dismissable-layer]`),i=Array.from(e.ownerDocument.querySelectorAll(`[data-dismissable-layer]`));return!!(n&&(r===n||i.indexOf(r)<i.indexOf(n)))}function Rg(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1),a=O(()=>{});return jr(o=>{if(!th||!Sn(n))return;let s=async n=>{let o=n.target;if(t?.value&&o){if(Lg(t.value,o)){i.value=!1;return}if(n.target&&!i.value){let t={originalEvent:n};function i(){Ym(Fg,e,t)}n.pointerType===`touch`?(r.removeEventListener(`click`,a.value),a.value=i,r.addEventListener(`click`,a.value,{once:!0})):i()}else r.removeEventListener(`click`,a.value);i.value=!1}},c=window.setTimeout(()=>{r.addEventListener(`pointerdown`,s)},0);o(()=>{window.clearTimeout(c),r.removeEventListener(`pointerdown`,s),r.removeEventListener(`click`,a.value)})}),{onPointerDownCapture:()=>{Sn(n)&&(i.value=!0)}}}function zg(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1);return jr(a=>{if(!th||!Sn(n))return;let o=async n=>{if(!t?.value)return;await or(),await or();let r=n.target;t.value&&r&&!Lg(t.value,r)&&n.target&&!i.value&&Ym(Ig,e,{originalEvent:n})};r.addEventListener(`focusin`,o),a(()=>r.removeEventListener(`focusin`,o))}),{onFocusCapture:()=>{Sn(n)&&(i.value=!0)},onBlurCapture:()=>{Sn(n)&&(i.value=!1)}}}var Bg=M({__name:`DismissableLayer`,props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},present:{type:Boolean,required:!1,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`dismiss`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Y(),o=W(()=>a.value?.ownerDocument??globalThis.document),s=W(()=>Nh.layersRoot),c=W(()=>a.value?Array.from(s.value).indexOf(a.value):-1),l=W(()=>Nh.layersWithOutsidePointerEventsDisabled.size>0),u=W(()=>{let e=Array.from(s.value),[t]=[...Nh.layersWithOutsidePointerEventsDisabled].slice(-1),n=e.indexOf(t);return c.value>=n}),d=Rg Line truncated
- a positive number
- less than the value passed to \`max\` (or ${wx} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${Dx} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function kx(e){return Dx(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${wx}\`.`),wx)}var Ax=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:wx},getValueLabel:{type:Function,required:!1,default:(e,t)=>Dx(e)?`${Math.round(e/t*wx)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Y();let i=Ch(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Ch(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=Ox(e,n.max);t!==e&&(await or(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=kx(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=W(()=>qm(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Ex({modelValue:i,max:a,progressState:o}),(e,t)=>(I(),R(k(X),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":Dx(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[P(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),jx=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Tx();return Y(),(e,r)=>(I(),R(k(X),U(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),Mx=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Nx=[` `,`Enter`];function Px(e,t,n){return e===void 0?!1:Array.isArray(e)?e.some(e=>Fx(e,t,n)):Fx(e,t,n)}function Fx(e,t,n){return e===void 0||t===void 0?!1:typeof e==`string`?e===t:typeof n==`function`?n(e,t):typeof n==`string`?e?.[n]===t?.[n]:Hm(e,t)}function Ix(e){return e==null||e===``||Array.isArray(e)&&e.length===0}var Lx=[`value`],[Rx,zx]=Wm(`SelectRoot`),Bx=M({inheritAttrs:!1,__name:`SelectRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},nullableValue:{type:String,required:!1,default:``},by:{type:[String,Function],required:!1},dir:{type:String,required:!1},multiple:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`update:open`],setup(e,{emit:t}){let n=e,r=t,{required:i,disabled:a,multiple:o,dir:s}=Dn(n),c=Ch(n,`modelValue`,r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),l=Ch(n,`open`,r,{defaultValue:n.defaultOpen,passive:n.open===void 0}),u=O(),d=O(),f=O({x:0,y:0}),p=W(()=>o.value&&Array.isArray(c.value)?c.value?.length===0:qm(c.value));j_({isProvider:!0});let m=zh(s),h=Wh(u),g=O(new Set),_=W(()=>Array.from(g.value).map(e=>e.value).join(`;`));function v(e){if(o.value){let t=Array.isArray(c.value)?[...c.value]:[],r=t.findIndex(t=>Fx(t,e,n.by));r===-1?t.push(e):t.splice(r,1),c.value=[...t]}else c.value=e}function y(e){return Array.from(g.value).find(t=>Px(e,t.value,n.by))}return zx({triggerElement:u,onTriggerChange:e=>{u.value=e},valueElement:d,onValueElementChange:e=>{d.value=e},contentId:``,modelValue:c,onValueChange:v,by:n.by,open:l,multiple:o,required:i,onOpenChange:e=>{l.value=e},dir:m,triggerPointerDownPosRef:f,disabled:a,isEmptyModelValue:p,optionsSet:g,onOptionAdd:e=>{let t=y(e.value);t&&g.value.delete(t),g.value.add(e)},onOptionRemove:e=>{let t=y(e.value);t&&g.value.delete(t)}}),(e,t)=>(I(),R(k(W_),null,{default:A(()=>[P(e.$slots,`default`,{modelValue:k(c),open:k(l)}),k(h)&&e.name?(I(),R(Vx,{key:_.value,"aria-hidden":`true`,tabindex:`-1`,multiple:k(o),required:k(i),name:e.name,autocomplete:e.autocomplete,disabled:k(a),value:k(c)},{default:A(()=>[k(qm)(k(c))?(I(),L(`option`,{key:0,value:e.nullableValue},null,8,Lx)):H(`v-if`,!0),(I(!0),L(F,null,N(Array.from(g.value),e=>(I(),L(`option`,U({key:e.value??``},{ref_for:!0},e),null,16))),128))]),_:1},8,[`multiple`,`required`,`name`,`autocomplete`,`disabled`,`value`])):H(`v-if`,!0)]),_:3}))}}),Vx=M({__name:`BubbleSelect`,props:{autocomplete:{type:String,required:!1},autofocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},form:{type:String,required:!1},multiple:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},size:{type:Number,required:!1},value:{type:null,required:!1}},setup(e){let t=e,n=O(),r=Rx();j(()=>t.value,(e,t)=>{let r=window.HTMLSelectElement.prototype,i=Object.getOwnPropertyDescrLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:oT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>oT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=cT(c),u=e+1<n.length?cT(n[e+1]):null;if(l&&u&&lT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=cT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>oT(e)),rows:r.map(e=>e.map(e=>oT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:oT(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.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:oT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function cT(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 lT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var uT={class:`[overflow-wrap:anywhere]`},dT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},fT={class:`font-mono text-[0.85em]`},pT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},mT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},hT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},gT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},_T={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},vT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},yT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},bT={key:8,class:`mb-2.5 last:mb-0`},xT=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>sT(t.text));return(e,t)=>(I(),L(`div`,uT,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,dT,[z(`code`,fT,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,pT,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(iT,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(iT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,mT,[B(iT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,hT,[B(iT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,gT,[B(iT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,_T,[B(iT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,vT,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(iT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,yT,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(iT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,bT,[B(iT,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),ST={class:`truncate`},CT=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return I(),R(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:A(()=>[B(k(bd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,ST,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),wT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},TT={class:`font-semibold text-foreground`},ET={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},DT=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(I(),R(CT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,wT,[B(k(Xd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,TT,D(n.value),1),r.value?(I(),L(`code`,ET,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),OT={key:0,class:`mb-2 grid gap-0.5 text-xs`},kT={key:2,class:`whitespace-pre-wrap`},AT=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(I(),L(`div`,OT,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(DT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.assistant?(I(),R(xT,{key:1,text:e.text},null,8,[`text`])):(I(),L(`div`,kT,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),jT={class:`w-full self-center justify-self-center py-6 text-center`},MT={class:`grid gap-2`},NT=[`onClick`],PT=M({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(I(),L(`div`,jT,[t[0]||=z(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>rA?`${n.slice(0,rA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var aA=[`title`],oA=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>jk(n.event)),a=W(()=>iA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?SO(n.event.at):`—`);return(e,t)=>(I(),R(k(tA),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,aA)]),_:1}),B(k(Q),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function sA(e,t){return`${e}:${t??0}`}function cA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=sA(iA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var lA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},uA={class:`max-h-[28rem] overflow-y-auto`},dA=[`aria-expanded`,`aria-label`,`onClick`],fA=[`title`],pA=M({__name:`LiveActivityCard`,setup(e){let t=rE(),{activity:n,streamKind:r,streamState:i}=od(ik()),a=rn(new Set),o=W(()=>cA(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return iA(e.representative)}function u(e){return e.representative.at?SO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(mO),null,{default:A(()=>[B(k(yO),null,{default:A(()=>[B(k(bO),null,{default:A(()=>[...t[0]||=[V(`Live activity`,-1)]]),_:1}),B(k(hO),null,{default:A(()=>[B(k(eO),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(gO),null,{default:A(()=>[z(`div`,lA,[z(`div`,uA,[B(k($k),null,{default:A(()=>[B(k(nA),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(tA),null,{default:A(()=>[B(k($),null,{default:A(()=>[...t[1]||=[V(`Event`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[2]||=[V(`Task`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[3]||=[V(`Detail`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[4]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(eA),null,{default:A(()=>[k(n).length?H(``,!0):(I(),R(k(tA),{key:0},{default:A(()=>[B(k(Q),{colspan:`4`},{default:A(()=>[B(k(KD),null,{default:A(()=>[B(k(YD),null,{default:A(()=>[B(k(QD),null,{default:A(()=>[...t[5]||=[V(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),k(n).length?(I(!0),L(F,{key:1},N(o.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(oA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(I(),L(F,{key:1},[B(k(tA),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[z(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:uu(t=>s(e.key),[`stop`])},[c(e)?(I(),R(k(Sd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(eO),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,dA)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},D(l(e).text),9,fA)]),_:2},1024),B(k(Q),null,{default:A(()=>[V(D(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(oA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):H(``,!0)],64))],64))),128)):H(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),mA=M({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=nC(t,`class`);return(e,r)=>(I(),R(k(Ax),U({"data-slot":`progress`},k(n),{class:k(q)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:A(()=>[B(k(jx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ye(`transLine truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function SM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function CM(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function wM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var TM=O([]),EM=O([]),DM=O(!0),OM=O(null),kM=O(null),AM=O(!1),jM=O(null);async function MM(){try{let e=await J.eventTypes();DM.value=e.enabled!==!1,TM.value=e.event_types||[],EM.value=e.proposals||[],OM.value=null}catch(e){OM.value=e.message||String(e)}}function NM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function PM(e){jM.value=null,kM.value=e}function FM(e){let t=UM.value.find(t=>String(t.id)===e.sample_id);PM({mode:`proposal`,id:null,source:e.source,name:``,rule:NM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function IM(e=``){PM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function LM(e){PM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:NM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function RM(){kM.value=null}async function zM(){let e=kM.value;if(e){AM.value=!0;try{if(e.mode===`edit`&&e.id)await J.eventTypeUpdate(e.id,{name:e.name,rule:wM(e.rule)});else{let t=e.mode===`paste`?xM(e.headersText):e.exampleHeaders;await J.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:wM(e.rule),example:{headers:t,body:e.body}})}kM.value=null,await MM()}catch(e){jM.value=e.message||String(e)}finally{AM.value=!1}}}var BM=O(null);async function VM(){let e=BM.value;if(BM.value=null,e)try{await J.eventTypeDelete(e.id),await MM()}catch(e){OM.value=e.message||String(e)}}var HM=100,UM=O([]),WM=O(!0),GM=O(null),KM=O(!0),qM=O(null);async function JM(){try{let e=await J.captures(HM);WM.value=e.enabled!==!1,UM.value=e.captures||[],GM.value=null}catch(e){GM.value=e.message||String(e)}finally{KM.value=!1}}function YM(e){let t=UM.value.find(t=>t.id===e);return t&&(qM.value=t),!!t}function XM(){UM.value.length&&(qM.value=UM.value[0])}function ZM(){ak(`captures`,()=>{JM(),MM()})}var QM={class:`flex flex-col gap-5`},$M=M({__name:`CaptureDetail`,props:{maxHeight:{}},setup(e){let t=e,n=O(null),r=dC(`(max-width: 1099px)`),i=W(()=>r.value||!t.maxHeight?void 0:`${t.maxHeight}px`),a=W(()=>{let e=qM.value;return e?[SO(e.received_at),e.content_type||`no content type`,e.remote_addr].filter(Boolean).join(` · `):``});return j(qM,()=>{r.value&&n.value?.scrollIntoView({block:`start`,behavior:`smooth`})}),(e,t)=>k(qM)?(I(),L(`div`,{key:0,ref_key:`pane`,ref:n,class:`min-w-0`},[B(k(mO),{class:`flex flex-col`,style:ye(i.value?{maxHeight:i.value}:void 0)},{default:A(()=>[B(k(yO),null,{default:A(()=>[B(k(bO),{class:`font-mono`},{default:A(()=>[V(D(k(qM).source||`Unknown source`),1)]),_:1}),B(k(_O),null,{default:A(()=>[V(D(a.value),1)]),_:1})]),_:1}),B(k(gO),{class:`min-h-0 max-h-[62vh] overflow-y-auto min-[1100px]:max-h-none`},{default:A(()=>[z(`div`,QM,[B(bM,{label:`Payload`,raw:k(qM).body},null,8,[`raw`]),B(bM,{label:`Headers`,raw:k(qM).headers},null,8,[`raw`])])]),_:1})]),_:1},8,[`style`])],512)):H(``,!0)}}),eN=M({__name:`CaptureStatus`,setup(e){let{streamKind:t,streamState:n}=od(ik());return(e,r)=>(I(),R(k(eO),{variant:k(t)},{default:A(()=>[V(D(k(n)),1)]),_:1},8,[`variant`]))}}),tN={class:`truncate`},nN=M({__name:`CaptureRow`,props:{capture:{}},setup(e){let t=e,n=W(()=>SM(t.capture,TM.value)),r=W(()=>qM.value?.id===t.capture.id),i=W(()=>`Show the payload received from ${t.capture.source||`an unknown source`}`);function a(){qM.value=t.capture}return(e,o)=>(I(),R(k(tA),{"data-state":r.value?`selected`:void 0,role:`button`,tabindex:`0`,"aria-current":r.value?`true`:void 0,"aria-label":i.value,class:`cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`,onClick:a,onKeydown:[fu(uu(a,[`prevent`]),[`enter`]),fu(uu(a,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(t.capture.source||`(unknown)`),1)]),_:1}),B(k(Q),{title:t.capture.received_at||``},{default:A(()=>[V(D(k(SO)(t.capture.received_at)),1)]),_:1},8,[`title`]),B(k(Q),null,{default:A(()=>[B(k(eO),{variant:n.value.identified?`ok`:`warn`,class:`max-w-40`},{default:A(()=>[z(`span`,tN,D(n.value.label),1)]),_:1},8,[`variant`])]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(t.capture.content_type||`—`),1)]),_:1}),B(k(Q),{class:`text-right`},{default:A(()=>[B(k(wd),{class:`size-4 text-fg-sLine truncated
Defaulting to \`null\`.`),null)}function Mx(e){return Ax(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Dx}\`.`),Dx)}var Nx=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:Dx},getValueLabel:{type:Function,required:!1,default:(e,t)=>Ax(e)?`${Math.round(e/t*Dx)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Y();let i=Eh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Eh(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=jx(e,n.max);t!==e&&(await or(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=Mx(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=W(()=>Xm(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return kx({modelValue:i,max:a,progressState:o}),(e,t)=>(I(),R(k(X),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":Ax(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[P(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),Px=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Ox();return Y(),(e,r)=>(I(),R(k(X),U(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),Fx=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ix=[` `,`Enter`];function Lx(e,t,n){return e===void 0?!1:Array.isArray(e)?e.some(e=>Rx(e,t,n)):Rx(e,t,n)}function Rx(e,t,n){return e===void 0||t===void 0?!1:typeof e==`string`?e===t:typeof n==`function`?n(e,t):typeof n==`string`?e?.[n]===t?.[n]:Gm(e,t)}function zx(e){return e==null||e===``||Array.isArray(e)&&e.length===0}var Bx=[`value`],[Vx,Hx]=qm(`SelectRoot`),Ux=M({inheritAttrs:!1,__name:`SelectRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},nullableValue:{type:String,required:!1,default:``},by:{type:[String,Function],required:!1},dir:{type:String,required:!1},multiple:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`update:open`],setup(e,{emit:t}){let n=e,r=t,{required:i,disabled:a,multiple:o,dir:s}=Dn(n),c=Eh(n,`modelValue`,r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),l=Eh(n,`open`,r,{defaultValue:n.defaultOpen,passive:n.open===void 0}),u=O(),d=O(),f=O({x:0,y:0}),p=W(()=>o.value&&Array.isArray(c.value)?c.value?.length===0:Xm(c.value));P_({isProvider:!0});let m=Hh(s),h=qh(u),g=O(new Set),_=W(()=>Array.from(g.value).map(e=>e.value).join(`;`));function v(e){if(o.value){let t=Array.isArray(c.value)?[...c.value]:[],r=t.findIndex(t=>Rx(t,e,n.by));r===-1?t.push(e):t.splice(r,1),c.value=[...t]}else c.value=e}function y(e){return Array.from(g.value).find(t=>Lx(e,t.value,n.by))}return Hx({triggerElement:u,onTriggerChange:e=>{u.value=e},valueElement:d,onValueElementChange:e=>{d.value=e},contentId:``,modelValue:c,onValueChange:v,by:n.by,open:l,multiple:o,required:i,onOpenChange:e=>{l.value=e},dir:m,triggerPointerDownPosRef:f,disabled:a,isEmptyModelValue:p,optionsSet:g,onOptionAdd:e=>{let t=y(e.value);t&&g.value.delete(t),g.value.add(e)},onOptionRemove:e=>{let t=y(e.value);t&&g.value.delete(t)}}),(e,t)=>(I(),R(k(q_),null,{default:A(()=>[P(e.$slots,`default`,{modelValue:k(c),open:k(l)}),k(h)&&e.name?(I(),R(Wx,{key:_.value,"aria-hidden":`true`,tabindex:`-1`,multiple:k(o),required:k(i),name:e.name,autocomplete:e.autocomplete,disabled:k(a),value:k(c)},{default:A(()=>[k(Xm)(k(c))?(I(),L(`option`,{key:0,value:e.nullableValue},null,8,Bx)):H(`v-if`,!0),(I(!0),L(F,null,N(Array.from(g.value),e=>(I(),L(`option`,U({key:e.value??``},{ref_for:!0},e),null,16))),128))]),_:1},8,[`multiple`,`required`,`name`,`autocomplete`,`disabled`,`value`])):H(`v-if`,!0)]),_:3}))}}),Wx=M({__name:`BubbleSelect`,props:{autocomplete:{type:String,required:!1},autofocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},form:{type:String,required:!1},multiple:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},size:{type:Number,required:!1},value:{type:null,required:!1}},setup(e){let t=e,n=O(),r=Vx();j(()=>t.value,(e,t)=>{let r=window.HTMLSelectElement.prototype,i=Object.getOwnPropertyDescrLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:lT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>lT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=dT(c),u=e+1<n.length?dT(n[e+1]):null;if(l&&u&&fT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=dT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>lT(e)),rows:r.map(e=>e.map(e=>lT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:lT(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.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:lT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function dT(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 fT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var pT={class:`[overflow-wrap:anywhere]`},mT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},hT={class:`font-mono text-[0.85em]`},gT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},_T={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},vT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},yT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},bT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},xT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},ST={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},CT={key:8,class:`mb-2.5 last:mb-0`},wT=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>uT(t.text));return(e,t)=>(I(),L(`div`,pT,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,mT,[z(`code`,hT,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,gT,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(sT,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(sT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,_T,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,vT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,yT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,bT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,xT,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(sT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,ST,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(sT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,CT,[B(sT,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),TT={class:`truncate`},ET=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return I(),R(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:A(()=>[B(k(bd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,TT,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),DT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},OT={class:`font-semibold text-foreground`},kT={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},AT=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(I(),R(ET,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,DT,[B(k($d),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,OT,D(n.value),1),r.value?(I(),L(`code`,kT,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),jT={key:0,class:`mb-2 grid gap-0.5 text-xs`},MT={key:2,class:`whitespace-pre-wrap`},NT=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(I(),L(`div`,jT,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(AT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.assistant?(I(),R(wT,{key:1,text:e.text},null,8,[`text`])):(I(),L(`div`,MT,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),PT={class:`w-full self-center justify-self-center py-6 text-center`},FT={class:`grid gap-2`},IT=[`onClick`],LT=M({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(I(),L(`div`,PT,[t[0]||=z(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>oA?`${n.slice(0,oA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var cA=[`title`],lA=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>Pk(n.event)),a=W(()=>sA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?TO(n.event.at):`—`);return(e,t)=>(I(),R(k(iA),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,cA)]),_:1}),B(k(Q),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function uA(e,t){return`${e}:${t??0}`}function dA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=uA(sA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var fA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},pA={class:`max-h-[28rem] overflow-y-auto`},mA=[`aria-expanded`,`aria-label`,`onClick`],hA=[`title`],gA=M({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=od(sk()),a=rn(new Set),o=W(()=>dA(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return sA(e.representative)}function u(e){return e.representative.at?TO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(_O),null,{default:A(()=>[B(k(SO),null,{default:A(()=>[B(k(CO),null,{default:A(()=>[...t[0]||=[V(`Live activity`,-1)]]),_:1}),B(k(vO),null,{default:A(()=>[B(k(rO),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(yO),null,{default:A(()=>[z(`div`,fA,[z(`div`,pA,[B(k(nA),null,{default:A(()=>[B(k(aA),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(iA),null,{default:A(()=>[B(k($),null,{default:A(()=>[...t[1]||=[V(`Event`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[2]||=[V(`Task`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[3]||=[V(`Detail`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[4]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(rA),null,{default:A(()=>[k(n).length?H(``,!0):(I(),R(k(iA),{key:0},{default:A(()=>[B(k(Q),{colspan:`4`},{default:A(()=>[B(k(YD),null,{default:A(()=>[B(k(QD),null,{default:A(()=>[B(k(tO),null,{default:A(()=>[...t[5]||=[V(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),k(n).length?(I(!0),L(F,{key:1},N(o.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(lA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(I(),L(F,{key:1},[B(k(iA),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[z(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:uu(t=>s(e.key),[`stop`])},[c(e)?(I(),R(k(Sd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(rO),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,mA)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},D(l(e).text),9,hA)]),_:2},1024),B(k(Q),null,{default:A(()=>[V(D(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(lA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):H(``,!0)],64))],64))),128)):H(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),_A=M({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=aC(t,`class`);return(e,r)=>(I(),R(k(Nx),U({"data-slot":`progress`},k(n),{class:k(q)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:A(()=>[B(k(Px),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ye(`transLine truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function kM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function AM(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function jM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var MM=O([]),NM=O([]),PM=O(!0),FM=O(null),IM=O(null),LM=O(!1),RM=O(null);async function zM(){try{let e=await J.eventTypes();PM.value=e.enabled!==!1,MM.value=e.event_types||[],NM.value=e.proposals||[],FM.value=null}catch(e){FM.value=e.message||String(e)}}function BM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function VM(e){RM.value=null,IM.value=e}function HM(e){let t=XM.value.find(t=>String(t.id)===e.sample_id);VM({mode:`proposal`,id:null,source:e.source,name:``,rule:BM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function UM(e=``){VM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function WM(e){VM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:BM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function GM(){IM.value=null}async function KM(){let e=IM.value;if(e){LM.value=!0;try{if(e.mode===`edit`&&e.id)await J.eventTypeUpdate(e.id,{name:e.name,rule:jM(e.rule)});else{let t=e.mode===`paste`?OM(e.headersText):e.exampleHeaders;await J.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:jM(e.rule),example:{headers:t,body:e.body}})}IM.value=null,await zM()}catch(e){RM.value=e.message||String(e)}finally{LM.value=!1}}}var qM=O(null);async function JM(){let e=qM.value;if(qM.value=null,e)try{await J.eventTypeDelete(e.id),await zM()}catch(e){FM.value=e.message||String(e)}}var YM=100,XM=O([]),ZM=O(!0),QM=O(null),$M=O(!0),eN=O(null);async function tN(){try{let e=await J.captures(YM);ZM.value=e.enabled!==!1,XM.value=e.captures||[],QM.value=null}catch(e){QM.value=e.message||String(e)}finally{$M.value=!1}}function nN(e){let t=XM.value.find(t=>t.id===e);return t&&(eN.value=t),!!t}function rN(){XM.value.length&&(eN.value=XM.value[0])}function iN(){ck(`captures`,()=>{tN(),zM()})}var aN={class:`flex flex-col gap-5`},oN=M({__name:`CaptureDetail`,props:{maxHeight:{}},setup(e){let t=e,n=O(null),r=mC(`(max-width: 1099px)`),i=W(()=>r.value||!t.maxHeight?void 0:`${t.maxHeight}px`),a=W(()=>eN.value?_M(eN.value):null),o=W(()=>{let e=eN.value;return e?[TO(e.received_at),e.content_type||`no content type`,e.remote_addr].filter(Boolean).join(` · `):``});return j(eN,()=>{r.value&&n.value?.scrollIntoView({block:`start`,behavior:`smooth`})}),(e,t)=>k(eN)?(I(),L(`div`,{key:0,ref_key:`pane`,ref:n,class:`min-w-0`},[B(k(_O),{class:`flex flex-col`,style:ye(i.value?{maxHeight:i.value}:void 0)},{default:A(()=>[B(k(SO),null,{default:A(()=>[B(k(CO),{class:`flex items-center gap-2 font-mono`},{default:A(()=>[V(D(k(eN).source||`Unknown source`)+` `,1),a.value?(I(),R(k(rO),{key:0,variant:a.value.kind},{default:A(()=>[V(D(a.value.label),1)]),_:1},8,[`variant`])):H(``,!0)]),_:1}),B(k(bO),null,{default:A(()=>[V(D(o.value),1)]),_:1})]),_:1}),B(k(yO),{class:`min-h-0 max-h-[62vh] overflow-y-auto min-[1100px]:max-h-none`},{default:A(()=>[z(`div`,aN,[B(DM,{label:`Payload`,raw:k(eN).body},null,8,[`raw`]),B(DM,{label:`Headers`,raw:k(eN).headers},null,8,[`raw`])])]),_:1})]),_:1},8,[`style`])],512)):H(``,!0)}}),sN=M({__name:`CaptureStatus`,setup(e){let{streamKind:t,streamState:n}=od(sk());return(e,r)=>(I(),R(k(rO),{variant:k(t)},{default:A(()=>[V(D(k(n)),1)]),_:1},8,[`variant`]))}}),cN={class:`flex items-center gap-1`},lN={class:`truncate`},uN=M({__name:`CaptureRow`,props:{capture:{}},setup(e){let t=e,n=W(()=>kM(t.capture,MM.value)),r=W(()=>_M(t.capture)),i=W(()=>eN.value?.id===t.capture.id),a=W(()=>`Show the payload received from ${t.capture.source||`an unknown source`}`);function o(){eN.value=t.capture}return(e,s)=>(I(),R(k(iA),{"data-state":i.value?`selected`:void 0,role:`button`,tabindex:`0`,"aria-current":i.value?`true`:void 0,"aria-label":a.value,class:`cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(t.capture.source||`(unknown)`),1)]),_:1}),B(k(Q),{title:t.capture.received_at||``},{default:A(()=>[V(D(k(TO)(t.capture.received_at)),1)]),_:1},8,[`title`]),B(k(Q),null,{default:A(()=>[z(`div`,cN,[B(k(rO),{variant:n.value.identified?`ok`:`warn`,class Line truncated
+3 -46
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { Check, Copy, RefreshCw } from "@lucide/vue";
import { computed, ref, watch } from "vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
@@ -7,14 +6,11 @@ import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@/components/ui/input-group";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Spinner } from "@/components/ui/spinner";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import {
draftFromBinding,
emptyDraft,
generateSecret,
type Binding,
type BindingDraft,
type MappingOption,
@@ -23,8 +19,7 @@ import {
/**
* The binding editor: name, the matcher source senders POST to, the field
* mapping, the workflow, an optional repo pin, and the shared secret their
* signature is checked against.
* mapping, the workflow and an optional repo pin. Signing is the source's.
*/
const props = defineProps<{
@@ -51,17 +46,11 @@ watch(
);
const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
const copied = ref(false);
async function copySecret(): Promise<void> {
await navigator.clipboard.writeText(draft.value.secret);
copied.value = true;
setTimeout(() => (copied.value = false), 1500);
}
</script>
<template>
<Dialog v-model:open="open">
<!-- Seven fields make this taller than a short window; the dialog itself
<!-- Six fields make this taller than a short window; the dialog itself
scrolls rather than clipping its own Save button. -->
<DialogContent class="max-h-[85vh] overflow-y-auto sm:max-w-lg">
<DialogHeader>
@@ -81,7 +70,7 @@ async function copySecret(): Promise<void> {
<Field>
<FieldLabel for="binding-source">Source</FieldLabel>
<Input id="binding-source" v-model="draft.source" />
<FieldDescription>The path segment senders POST to, for example "sentry".</FieldDescription>
<FieldDescription>The path of a source, from the sources list above.</FieldDescription>
</Field>
<Field>
@@ -132,38 +121,6 @@ async function copySecret(): Promise<void> {
</FieldDescription>
</Field>
<Field>
<FieldLabel for="binding-secret">Signing secret</FieldLabel>
<InputGroup v-if="draft.secret">
<InputGroupInput id="binding-secret" :model-value="draft.secret" class="font-mono text-xs" readonly />
<InputGroupAddon align="inline-end">
<Tooltip>
<TooltipTrigger as-child>
<InputGroupButton size="icon-xs" aria-label="Copy secret" @click="copySecret">
<Check v-if="copied" />
<Copy v-else />
</InputGroupButton>
</TooltipTrigger>
<TooltipContent>Copy secret</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger as-child>
<InputGroupButton size="icon-xs" aria-label="Regenerate secret" @click="draft.secret = generateSecret()">
<RefreshCw />
</InputGroupButton>
</TooltipTrigger>
<TooltipContent>Regenerate</TooltipContent>
</Tooltip>
</InputGroupAddon>
</InputGroup>
<div v-else class="flex h-9 items-center justify-between rounded-md border px-3 text-sm">
<span class="text-fg-muted">Stored · HMAC-SHA256</span>
<Button type="button" variant="ghost" size="sm" @click="draft.secret = generateSecret()">
<RefreshCw data-icon="inline-start" />
Replace
</Button>
</div>
</Field>
</FieldGroup>
<!-- Beside the buttons, not at the top: the dialog scrolls, and Save is
+7 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { Check, Pencil, Trash2 } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { TableCell, TableRow } from "@/components/ui/table";
import BindingStatusBadge from "./BindingStatusBadge.vue";
@@ -18,7 +19,12 @@ const emit = defineEmits<{
<template>
<TableRow>
<TableCell class="font-medium">{{ props.binding.name }}</TableCell>
<TableCell class="font-mono text-fg-muted">{{ matcherSource(props.binding) }}</TableCell>
<TableCell class="font-mono text-fg-muted">
<div class="flex items-center gap-2">
{{ matcherSource(props.binding) }}
<Badge v-if="props.binding.unsigned" variant="warn">Unsigned</Badge>
</div>
</TableCell>
<TableCell>{{ props.binding.workflow || "—" }}</TableCell>
<TableCell class="font-mono text-fg-muted">{{ repoPin(props.binding) }}</TableCell>
<TableCell><BindingStatusBadge :status="props.binding.status" /></TableCell>
+3
View File
@@ -4,6 +4,7 @@ import { onMounted, ref } from "vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import SourcesPanel from "@/sources/SourcesPanel.vue";
import { useLiveResource } from "@/stores/live-updates";
import BindingEditor from "./BindingEditor.vue";
import BindingsTable from "./BindingsTable.vue";
@@ -69,6 +70,8 @@ async function handleDelete(binding: Binding): Promise<void> {
<template>
<div>
<SourcesPanel />
<!-- The tab owns the actions that belong to it. The page's header names the
page, not this panel, so nothing here repeats "Events". -->
<div class="mb-4 flex flex-wrap items-center justify-end gap-2">
+3 -15
View File
@@ -6,9 +6,8 @@
*/
/**
* A binding as GET /api/bindings returns it. Secret is never returned: the
* daemon strips it from every read, and a blank secret on update is its
* server-side "keep the current one".
* A binding as GET /api/bindings returns it. Signing belongs to the source the
* matcher names; unsigned is set when that source takes unsigned events.
*/
export interface Binding {
id: string;
@@ -21,6 +20,7 @@ export interface Binding {
repo?: string;
status?: string;
version?: number;
unsigned?: boolean;
}
/** The fields of GET /api/mappings this page needs. */
@@ -71,7 +71,6 @@ export interface BindingDraft {
workflow: string;
owner: string;
repo: string;
secret: string;
}
export function emptyDraft(): BindingDraft {
@@ -83,7 +82,6 @@ export function emptyDraft(): BindingDraft {
workflow: "",
owner: "",
repo: "",
secret: generateSecret(),
};
}
@@ -96,9 +94,6 @@ export function draftFromBinding(binding: Binding): BindingDraft {
workflow: binding.workflow || "",
owner: binding.owner || "",
repo: binding.repo || "",
// Deliberately blank: the secret is never sent to the browser, and an
// empty one on update keeps whatever the sender already signs with.
secret: "",
};
}
@@ -111,16 +106,9 @@ export function bindingPayload(draft: BindingDraft): Record<string, unknown> {
workflow: draft.workflow,
owner: draft.owner,
repo: draft.repo,
secret: draft.secret,
};
}
/** A 32-byte hex signing secret for a new binding. */
export function generateSecret(): string {
const bytes = crypto.getRandomValues(new Uint8Array(32));
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
}
/** The repo pin a row shows, or an em dash when the binding takes the
* single-configured-repo default. */
export function repoPin(binding: Binding): string {
+8 -1
View File
@@ -3,7 +3,9 @@ import { useMediaQuery } from "@vueuse/core";
import { computed, ref, watch } from "vue";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { ago } from "@/lib/format";
import { captureSignature } from "./capture-signature";
import CapturePayload from "./CapturePayload.vue";
import { selected } from "./state";
@@ -36,6 +38,8 @@ const stacked = useMediaQuery("(max-width: 1099px)");
const cap = computed(() => (stacked.value || !props.maxHeight ? undefined : `${props.maxHeight}px`));
const signature = computed(() => (selected.value ? captureSignature(selected.value) : null));
const meta = computed(() => {
const capture = selected.value;
if (!capture) return "";
@@ -54,7 +58,10 @@ watch(selected, () => {
<div v-if="selected" ref="pane" class="min-w-0">
<Card class="flex flex-col" :style="cap ? { maxHeight: cap } : undefined">
<CardHeader>
<CardTitle class="font-mono">{{ selected.source || "Unknown source" }}</CardTitle>
<CardTitle class="flex items-center gap-2 font-mono">
{{ selected.source || "Unknown source" }}
<Badge v-if="signature" :variant="signature.kind">{{ signature.label }}</Badge>
</CardTitle>
<CardDescription>{{ meta }}</CardDescription>
</CardHeader>
<!-- Stacked there is no sibling to be bound by, so the panel caps itself
+8 -3
View File
@@ -7,6 +7,7 @@ import { TableCell, TableRow } from "@/components/ui/table";
import { ago } from "@/lib/format";
import { eventTypes } from "./event-type-state";
import { captureIdentity } from "./event-types";
import { captureSignature } from "./capture-signature";
import { selected, type Capture } from "./state";
/**
@@ -19,6 +20,7 @@ const props = defineProps<{ capture: Capture }>();
const identity = computed(() => captureIdentity(props.capture, eventTypes.value));
const signature = computed(() => captureSignature(props.capture));
const isSelected = computed(() => selected.value?.id === props.capture.id);
// The name is set here because role="button" makes the cells presentational:
@@ -46,9 +48,12 @@ function open(): void {
<TableCell :title="props.capture.received_at || ''">{{ ago(props.capture.received_at) }}</TableCell>
<!-- An unidentified capture is never dispatched. -->
<TableCell>
<Badge :variant="identity.identified ? 'ok' : 'warn'" class="max-w-40">
<span class="truncate">{{ identity.label }}</span>
</Badge>
<div class="flex items-center gap-1">
<Badge :variant="identity.identified ? 'ok' : 'warn'" class="max-w-40">
<span class="truncate">{{ identity.label }}</span>
</Badge>
<Badge :variant="signature.kind">{{ signature.label }}</Badge>
</div>
</TableCell>
<TableCell class="font-mono">{{ props.capture.content_type || "—" }}</TableCell>
<TableCell class="text-right">
+15
View File
@@ -0,0 +1,15 @@
/**
* How a capture may dispatch: signed by its source's secret, taken on a
* source approved for unsigned events, or neither -- in which case nothing
* starts from it.
*/
export interface CaptureSignature {
label: "Signed" | "Unsigned" | "Unverified";
kind: "ok" | "warn" | "idle";
}
export function captureSignature(capture: { authenticated?: boolean; unsigned?: boolean }): CaptureSignature {
if (capture.unsigned) return { label: "Unsigned", kind: "warn" };
if (capture.authenticated) return { label: "Signed", kind: "ok" };
return { label: "Unverified", kind: "idle" };
}
+1
View File
@@ -28,6 +28,7 @@ export interface Capture {
authenticated?: boolean;
/** The event type it was identified as on arrival; empty is unidentified. */
event_type?: string;
unsigned?: boolean;
}
interface CapturesResponse {
+8
View File
@@ -178,6 +178,14 @@ export const api = {
request<T>(`/api/bindings/${encodeURIComponent(id)}`, { method: "PATCH", body: binding }),
bindingDelete: (id: string) => request<void>(`/api/bindings/${encodeURIComponent(id)}`, { method: "DELETE", parse: false }),
bindingApprove: <T = unknown>(id: string) => request<T>(`/api/bindings/${encodeURIComponent(id)}/approve`, { method: "POST" }),
sources: <T = unknown>() => request<T>("/api/sources"),
sourceCreate: <T = unknown>(path: string) => request<T>("/api/sources", { method: "POST", body: { path } }),
sourceSigning: <T = unknown>(path: string, signed: boolean) =>
request<T>(`/api/sources/${encodeURIComponent(path)}/signing`, { method: "POST", body: { signed } }),
sourceApproveUnsigned: <T = unknown>(path: string) =>
request<T>(`/api/sources/${encodeURIComponent(path)}/approve-unsigned`, { method: "POST" }),
sourceSecret: <T = unknown>(path: string) =>
request<T>(`/api/sources/${encodeURIComponent(path)}/secret`, { method: "POST" }),
chatSessions: <T = unknown>() => request<T>("/api/chat/sessions"),
chatMessages: <T = unknown>(id: string) => request<T>(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
chatTurns: <T = unknown>(id: string) => request<T>(`/api/chat/sessions/${encodeURIComponent(id)}/turns`),
+148
View File
@@ -0,0 +1,148 @@
<script setup lang="ts">
import { Check, Copy, KeyRound, Lock, LockOpen, Plus, X } from "@lucide/vue";
import { onMounted, ref } from "vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { useLiveResource } from "@/stores/live-updates";
import { signingKind, signingLabel, sourceURL, type Source } from "./source-signing";
import { useSources } from "./use-sources";
/**
* Capture sources: the endpoint each sender posts to and its signing setting
* (docs/prds/event-automation.md "Sources"). Turning signing off is a request
* that takes effect only once approved.
*/
const { sources, failure, revealed, busy, load, create, newSecret, requestUnsigned, requireSigning, approveUnsigned } =
useSources();
const customPath = ref("");
const copied = ref<string | null>(null);
useLiveResource(null, () => void load());
onMounted(load);
async function copy(value: string): Promise<void> {
await navigator.clipboard.writeText(value);
copied.value = value;
setTimeout(() => (copied.value = null), 1500);
}
async function submit(): Promise<void> {
await create(customPath.value);
if (!failure.value) customPath.value = "";
}
function url(source: Source): string {
return sourceURL(window.location.origin, source.path);
}
</script>
<template>
<section class="mb-6 flex flex-col gap-3">
<form class="flex flex-wrap items-center justify-end gap-2" @submit.prevent="submit">
<Input v-model="customPath" class="w-64 font-mono" placeholder="Custom path (optional)" aria-label="Custom path" />
<Button type="submit" variant="outline" :disabled="busy">
<Plus data-icon="inline-start" />
New source
</Button>
</form>
<Alert v-if="failure" variant="destructive">
<AlertTitle>That did not take effect</AlertTitle>
<AlertDescription>{{ failure }}</AlertDescription>
</Alert>
<Alert v-if="revealed">
<KeyRound />
<AlertTitle class="flex items-center justify-between gap-2">
<span class="font-mono">{{ revealed.path }} · signing secret, shown once</span>
<Button variant="ghost" size="icon-sm" aria-label="Dismiss" @click="revealed = null"><X /></Button>
</AlertTitle>
<AlertDescription class="flex items-center gap-2">
<code class="min-w-0 break-all font-mono text-xs">{{ revealed.secret }}</code>
<Button variant="ghost" size="icon-sm" aria-label="Copy secret" @click="copy(revealed.secret || '')">
<Check v-if="copied === revealed.secret" />
<Copy v-else />
</Button>
</AlertDescription>
</Alert>
<Card v-if="sources && sources.length">
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Source</TableHead>
<TableHead>Signing</TableHead>
<TableHead />
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-for="source in sources" :key="source.path">
<TableCell class="max-w-0 truncate font-mono text-fg-muted" :title="url(source)">{{ source.path }}</TableCell>
<TableCell>
<Badge :variant="signingKind(source.signing)">{{ signingLabel(source.signing) }}</Badge>
</TableCell>
<TableCell>
<div class="flex items-center justify-end gap-1">
<Tooltip>
<TooltipTrigger as-child>
<Button variant="ghost" size="icon-sm" aria-label="Copy URL" @click="copy(url(source))">
<Check v-if="copied === url(source)" />
<Copy v-else />
</Button>
</TooltipTrigger>
<TooltipContent>Copy URL</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger as-child>
<Button variant="ghost" size="icon-sm" aria-label="New secret" :disabled="busy" @click="newSecret(source)">
<KeyRound />
</Button>
</TooltipTrigger>
<TooltipContent>New secret</TooltipContent>
</Tooltip>
<Button
v-if="source.signing === 'signed'"
variant="outline"
size="sm"
:disabled="busy"
@click="requestUnsigned(source)"
>
<LockOpen data-icon="inline-start" />
Turn off signing
</Button>
<Button
v-if="source.signing === 'unsigned_pending_approval'"
size="sm"
:disabled="busy"
@click="approveUnsigned(source)"
>
<Check data-icon="inline-start" />
Approve unsigned
</Button>
<Button
v-if="source.signing !== 'signed'"
variant="outline"
size="sm"
:disabled="busy"
@click="requireSigning(source)"
>
<Lock data-icon="inline-start" />
Require signing
</Button>
</div>
</TableCell>
</TableRow>
</TableBody>
</Table>
</CardContent>
</Card>
</section>
</template>
+41
View File
@@ -0,0 +1,41 @@
/**
* The sources vocabulary: the wire shape GET /api/sources returns and the
* signing states it carries. A source's secret is only ever in the response
* to the write that generated it.
*/
export interface Source {
path: string;
signing?: string;
/** Present only on create and on a new secret. */
secret?: string;
created_at?: string;
}
export type SigningKind = "ok" | "info" | "warn" | "idle";
const LABELS: Record<string, string> = {
signed: "signed",
unsigned_pending_approval: "unsigned pending approval",
unsigned: "unsigned",
};
const KINDS: Record<string, SigningKind> = {
signed: "ok",
unsigned_pending_approval: "info",
unsigned: "warn",
};
export function signingLabel(signing?: string): string {
if (!signing) return "unknown";
return LABELS[signing] ?? signing;
}
export function signingKind(signing?: string): SigningKind {
return KINDS[signing ?? ""] ?? "idle";
}
/** The URL a sender posts to. */
export function sourceURL(origin: string, path: string): string {
return `${origin}/webhooks/capture/${encodeURIComponent(path)}`;
}
+58
View File
@@ -0,0 +1,58 @@
import { ref } from "vue";
import { api } from "@/lib/api";
import type { Source } from "./source-signing";
/**
* The sources list and its writes. A write that generates a secret keeps the
* returned source in `revealed` until dismissed: it is the only time the
* browser ever holds that secret.
*/
export function useSources() {
// null means loading, [] means loaded and empty.
const sources = ref<Source[] | null>(null);
const failure = ref<string | null>(null);
const revealed = ref<Source | null>(null);
const busy = ref(false);
function message(err: unknown): string {
return err instanceof Error && err.message ? err.message : String(err);
}
async function load(): Promise<void> {
try {
const res = await api.sources<{ sources?: Source[] }>();
sources.value = res.sources || [];
failure.value = null;
} catch (err) {
failure.value = message(err);
}
}
async function run(write: () => Promise<Source | void>): Promise<void> {
busy.value = true;
failure.value = null;
try {
const result = await write();
if (result?.secret) revealed.value = result;
await load();
} catch (err) {
failure.value = message(err);
} finally {
busy.value = false;
}
}
return {
sources,
failure,
revealed,
busy,
load,
create: (path: string) => run(() => api.sourceCreate<Source>(path.trim())),
newSecret: (source: Source) => run(() => api.sourceSecret<Source>(source.path)),
requestUnsigned: (source: Source) => run(() => api.sourceSigning<Source>(source.path, false)),
requireSigning: (source: Source) => run(() => api.sourceSigning<Source>(source.path, true)),
approveUnsigned: (source: Source) => run(() => api.sourceApproveUnsigned<Source>(source.path)),
};
}
+5 -1
View File
@@ -21,7 +21,11 @@ const line = computed(() => describeTimelineEvent(props.event));
<template>
<li class="flex items-start gap-3">
<span class="mt-[5px] size-2 shrink-0 rounded-full bg-primary" aria-hidden="true" />
<span
class="mt-[5px] size-2 shrink-0 rounded-full"
:class="line.tone === 'warn' ? 'bg-warn' : 'bg-primary'"
aria-hidden="true"
/>
<div>
<div class="text-sm font-medium">{{ line.title }}</div>
<div v-if="line.detail" class="mt-0.5 text-xs text-fg-muted">{{ line.detail }}</div>
+6
View File
@@ -48,6 +48,8 @@ function text(value: unknown): string {
export interface TimelineLine {
title: string;
detail: string;
/** Set for an event a reader must not skim past. */
tone?: "warn";
}
export function describeTimelineEvent(ev: TaskEvent = {}): TimelineLine {
@@ -112,6 +114,10 @@ export function describeTimelineEvent(ev: TaskEvent = {}): TimelineLine {
detail: "The effective task-runtime configuration for this run.",
};
}
if (ev.kind === "unsigned_event") {
const source = text(data.source);
return { title: "Started by an unsigned event", detail: source ? `source ${source}` : "", tone: "warn" };
}
if (ev.kind === "changes_captured") {
const totals = (data.totals ?? {}) as { files?: unknown };
const fileCount = Number(totals.files);
+52
View File
@@ -0,0 +1,52 @@
import assert from "node:assert/strict";
import test from "node:test";
import { bindingPayload, emptyDraft } from "../src/bindings/binding-draft.ts";
import { captureSignature } from "../src/captures/capture-signature.ts";
import { signingKind, signingLabel, sourceURL } from "../src/sources/source-signing.ts";
import { describeTimelineEvent } from "../src/tasks/timeline-event.ts";
test("a capture shows how it may dispatch", () => {
const cases: Array<[{ authenticated?: boolean; unsigned?: boolean }, string, string]> = [
[{ authenticated: true }, "Signed", "ok"],
[{ unsigned: true }, "Unsigned", "warn"],
[{}, "Unverified", "idle"],
[{ authenticated: false, unsigned: false }, "Unverified", "idle"],
];
for (const [capture, label, kind] of cases) {
assert.deepEqual(captureSignature(capture), { label, kind }, JSON.stringify(capture));
}
});
test("a source's signing state names itself and its tone", () => {
const cases: Array<[string | undefined, string, string]> = [
["signed", "signed", "ok"],
["unsigned_pending_approval", "unsigned pending approval", "info"],
["unsigned", "unsigned", "warn"],
["something_new", "something_new", "idle"],
[undefined, "unknown", "idle"],
];
for (const [signing, label, kind] of cases) {
assert.equal(signingLabel(signing), label, String(signing));
assert.equal(signingKind(signing), kind, String(signing));
}
});
test("a source's URL escapes nothing a valid path can hold", () => {
assert.equal(
sourceURL("https://archie.example", "0199a0b2-0000-7000-8000-000000000000"),
"https://archie.example/webhooks/capture/0199a0b2-0000-7000-8000-000000000000",
);
assert.equal(sourceURL("http://h", "a b"), "http://h/webhooks/capture/a%20b");
});
test("a task started by an unsigned event says so on its timeline", () => {
const line = describeTimelineEvent({ kind: "unsigned_event", data: { source: "firewall" } });
assert.deepEqual(line, { title: "Started by an unsigned event", detail: "source firewall", tone: "warn" });
assert.equal(describeTimelineEvent({ kind: "stage_start", stage: "plan" }).tone, undefined);
});
test("a binding no longer carries a signing secret", () => {
const payload = bindingPayload(emptyDraft());
assert.equal("secret" in payload, false);
});