teapot-coding-agent 0.25.1 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",
@@ -1,7 +1,7 @@
1
1
  (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return t(this.context.count)},getNextContextId(){return t(this.context.count++)}};function t(t){let n=String(t),r=n.length-1;return e.context.id+(r?String.fromCharCode(96+r):``)+n}function n(t){e.context=t}var r=(e,t)=>e===t,i=Symbol(`solid-track`),a={equals:r},o=null,s=se,c=1,l=2,u={owned:null,cleanups:null,context:null,owner:null},d=null,f=null,p=null,m=null,h=null,g=0;function _(e,t){let n=p,r=d,i=e.length===0,a=t===void 0?r:t,o=i?u:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>S(()=>ue(o)));d=o,p=null;try{return ae(s,!0)}finally{p=n,d=r}}function v(e,t){t=t?Object.assign({},a,t):a;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[E.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),D(n,e))]}function y(e,t,n){O(k(e,t,!1,c))}function b(e,t,n){s=ce;let r=k(e,t,!1,c),i=ne&&T(ne);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):O(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=k(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,O(r),E.bind(r)}function S(e){if(p===null)return e();let t=p;p=null;try{return e()}finally{p=t}}function C(e){b(()=>S(e))}function w(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}var[ee,te]=v(!1);function T(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var ne;function E(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)O(this);else{let e=m;m=null,ae(()=>A(this),!1),m=e}}if(p){let e=this.observers;if(!e||e[e.length-1]!==p){let t=e?e.length:0;p.sources?(p.sources.push(this),p.sourceSlots.push(t)):(p.sources=[this],p.sourceSlots=[t]),e?(e.push(p),this.observerSlots.push(p.sources.length-1)):(this.observers=[p],this.observerSlots=[p.sources.length-1])}}return e&&f.sources.has(this)?this.tValue:this.value}function D(e,t,n){let r=f&&f.running&&f.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(f){let r=f.running;(r||!n&&f.sources.has(e))&&(f.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&ae(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=f&&f.running;r&&f.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?m.push(n):h.push(n),n.observers&&le(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function O(e){if(!e.fn)return;ue(e);let t=g;re(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{ae(()=>{f&&(f.running=!0),p=d=e,re(e,e.tValue,t),p=d=null},!1)})}function re(e,t,n){let r,i=d,a=p;p=d=e;try{r=e.fn(t)}catch(t){return e.pure&&(f&&f.running?(e.tState=c,e.tOwned&&e.tOwned.forEach(ue),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(ue),e.owned=null)),e.updatedAt=n+1,me(t)}finally{p=a,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?D(e,r,!0):f&&f.running&&e.pure?(f.sources.has(e)||(e.value=r),f.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function k(e,t,n,r=c,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};return f&&f.running&&(a.state=0,a.tState=r),d===null||d!==u&&(f&&f.running&&d.pure?d.tOwned?d.tOwned.push(a):d.tOwned=[a]:d.owned?d.owned.push(a):d.owned=[a]),a}function ie(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return A(e);if(e.suspense&&S(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);){if(t&&f.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(f.disposed.has(t))return}if((t?e.tState:e.state)===c)O(e);else if((t?e.tState:e.state)===l){let t=m;m=null,ae(()=>A(e,n[0]),!1),m=t}}}function ae(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return oe(n),t}catch(e){n||(h=null),m=null,me(e)}}function oe(e){if(m&&=(se(m),null),e)return;let t;if(f){if(!f.promises.size&&!f.queue.size){let e=f.sources,n=f.disposed;h.push.apply(h,f.effects),t=f.resolve;for(let e of h)`tState`in e&&(e.state=e.tState),delete e.tState;f=null,ae(()=>{for(let e of n)ue(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)ue(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}te(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,te(!0);return}}let n=h;h=null,n.length&&ae(()=>s(n),!1),t&&t()}function se(e){for(let t=0;t<e.length;t++)ie(e[t])}function ce(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:ie(e)}if(e.context){if(e.count){e.effects||=[],e.effects.push(...t.slice(0,i));return}n()}for(e.effects&&(e.done||!e.count)&&(t=[...e.effects,...t],i+=e.effects.length,delete e.effects),r=0;r<i;r++)ie(t[r])}function A(e,t){let n=f&&f.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===c?i!==t&&(!i.updatedAt||i.updatedAt<g)&&ie(i):e===l&&A(i,t)}}}function le(e){let t=f&&f.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=l:r.state=l,r.pure?m.push(r):h.push(r),r.observers&&le(r))}}function ue(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)ue(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)de(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)ue(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}f&&f.running?e.tState=0:e.state=0}function de(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)de(e.owned[t])}function fe(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function pe(e,t,n){try{for(let n of t)n(e)}catch(e){me(e,n&&n.owner||null)}}function me(e,t=d){let n=o&&t&&t.context&&t.context[o],r=fe(e);if(!n)throw r;h?h.push({fn(){pe(r,n,t)},state:c}):pe(r,n,t)}var he=Symbol(`fallback`);function ge(e){for(let t=0;t<e.length;t++)e[t]()}function _e(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>ge(o)),()=>{let l=e()||[],u=l.length,d,f;return l[i],S(()=>{let e,t,i,m,h,g,v,y,b;if(u===0)s!==0&&(ge(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[he],a[0]=_(e=>(o[0]=e,n.fallback())),s=1);else if(s===0){for(a=Array(u),f=0;f<u;f++)r[f]=l[f],a[f]=_(p);s=u}else{for(i=Array(u),m=Array(u),c&&(h=Array(u)),g=0,v=Math.min(s,u);g<v&&r[g]===l[g];g++);for(v=s-1,y=u-1;v>=g&&y>=g&&r[v]===l[y];v--,y--)i[y]=a[v],m[y]=o[v],c&&(h[y]=c[v]);for(e=new Map,t=Array(y+1),f=y;f>=g;f--)b=l[f],d=e.get(b),t[f]=d===void 0?-1:d,e.set(b,f);for(d=g;d<=v;d++)b=r[d],f=e.get(b),f!==void 0&&f!==-1?(i[f]=a[d],m[f]=o[d],c&&(h[f]=c[d]),f=t[f],e.set(b,f)):o[d]();for(f=g;f<u;f++)f in i?(a[f]=i[f],o[f]=m[f],c&&(c[f]=h[f],c[f](f))):a[f]=_(p);a=a.slice(0,s=u),r=l.slice(0)}return a});function p(e){if(o[f]=e,c){let[e,n]=v(f);return c[f]=n,t(l[f],e)}return t(l[f])}}}function ve(e,t,n={}){let r=[],a=[],o=[],s=[],c=0,l;return w(()=>ge(o)),()=>{let u=e()||[],d=u.length;return u[i],S(()=>{if(d===0)return c!==0&&(ge(o),o=[],r=[],a=[],c=0,s=[]),n.fallback&&(r=[he],a[0]=_(e=>(o[0]=e,n.fallback())),c=1),a;for(r[0]===he&&(o[0](),o=[],r=[],a=[],c=0),l=0;l<d;l++)l<r.length&&r[l]!==u[l]?s[l](()=>u[l]):l>=r.length&&(a[l]=_(f));for(;l<r.length;l++)o[l]();return c=s.length=o.length=d,r=u.slice(0),a=a.slice(0,c)});function f(e){o[l]=e;let[n,r]=v(u[l]);return s[l]=r,t(n,l)}}}function j(e,t){return S(()=>e(t||{}))}var ye=e=>`Stale read from <${e}>.`;function M(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(_e(()=>e.each,e.children,t||void 0))}function be(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(ve(()=>e.each,e.children,t||void 0))}function N(e){let t=e.keyed,n=x(()=>e.when,void 0,void 0),r=t?n:x(n,void 0,{equals:(e,t)=>!e==!t});return x(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?S(()=>a(t?i:()=>{if(!S(r))throw ye(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var P=e=>x(()=>e());function xe(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null){if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&(d=l.get(t[c]))!=null&&d===r+u;)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++}else t[o++].remove()}}}var Se=`_$DX_DELEGATE`;function Ce(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():R(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function F(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>S(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function we(e,t=window.document){let n=t[Se]||(t[Se]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,Ae))}}function I(e,t,n){ke(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function L(e,t){ke(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function Te(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function Ee(e,t,n){if(!t)return n?I(e,`style`):t;let r=e.style;if(typeof t==`string`)return r.cssText=t;typeof n==`string`&&(r.cssText=n=void 0),n||={},t||={};let i,a;for(a in n)t[a]??r.removeProperty(a),delete n[a];for(a in t)i=t[a],i!==n[a]&&(r.setProperty(a,i),n[a]=i);return n}function De(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function Oe(e,t,n){return S(()=>e(t,n))}function R(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return je(e,t,r,n);y(r=>je(e,t(),r,n),r)}function ke(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function Ae(t){if(e.registry&&e.events&&e.events.find(([e,n])=>n===t))return;let n=t.target,r=`$$${t.type}`,i=t.target,a=t.currentTarget,o=e=>Object.defineProperty(t,"target",{configurable:!0,value:e}),s=()=>{let e=n[r];if(e&&!n.disabled){let i=n[`${r}Data`];if(i===void 0?e.call(n,t):e.call(n,i,t),t.cancelBubble)return}return n.host&&typeof n.host!=`string`&&!n.host._$host&&n.contains(t.target)&&o(n.host),!0},c=()=>{for(;s()&&(n=n._$host||n.parentNode||n.host););};if(Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),e.registry&&!e.done&&(e.done=_$HY.done=!0),t.composedPath){let e=t.composedPath();o(e[0]);for(let t=0;t<e.length-2&&(n=e[t],s());t++){if(n._$host){n=n._$host,c();break}if(n.parentNode===a)break}}else c();o(i)}function je(e,t,n,r,i){let a=ke(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Pe(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Pe(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=je(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(Me(o,t,n,i))return y(()=>n=je(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Pe(e,n,r),s)return n}else c?n.length===0?Ne(e,o,r):xe(e,n,o):(n&&Pe(e),Ne(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Pe(e,n,r,t);Pe(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function Me(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(o!=null&&o!==!0&&o!==!1){if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=Me(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=Me(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0}else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}}return i}function Ne(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Pe(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}var Fe=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/;function Ie(e){return Le(Be(e.replace(/\r\n/g,`
2
2
  `)).split(`
3
3
  `))}function Le(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(/^```[^\n]*$/.test(o)&&!/^```.+\`\`\`/.test(o)){let r=[];for(n++;n<e.length&&!/^```\s*$/.test(e[n]);)r.push(e[n++]);n++,t.push(`<pre><code>${r.join(`
4
- `)}</code></pre>`);continue}if(/^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/.test(o)){t.push(`<hr>`),n++;continue}let s=o.match(/^(#{1,6})\s+(.*)$/);if(s){t.push(`<h${s[1].length}>${a(s[2])}</h${s[1].length}>`),n++;continue}if(/^\s*&gt;/.test(o)){let r=[];for(;n<e.length&&/^\s*&gt;/.test(e[n]);)r.push(e[n++].replace(/^\s*&gt;\s?/,``));t.push(`<blockquote>${Le(r)}</blockquote>`);continue}if(o.includes(`|`)&&n+1<e.length&&ze(e[n+1])){let r=Re(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`),i=Re(o);n+=2;let s=[];for(;n<e.length&&/\S/.test(e[n])&&e[n].includes(`|`);)s.push(Re(e[n])),n++;let c=(e,t,n)=>{let i=r[t];return`<${n}${i&&i!==`left`?` style="text-align:${i}"`:``}>${a(e)}</${n}>`},l=i.some(e=>e!==``);t.push(`<div class="tbl"><table>`+(l?`<thead><tr>${i.map((e,t)=>c(e,t,`th`)).join(``)}</tr></thead>`:``)+`<tbody>${s.map(e=>`<tr>${e.map((e,t)=>c(e,t,`td`)).join(``)}</tr>`).join(``)}</tbody></table></div>`);continue}if(Fe.test(o)){t.push(i(r(o.match(Fe)[1])));continue}if(/^\s*$/.test(o)){n++;continue}let c=[];for(;n<e.length&&!/^\s*$/.test(e[n])&&!/^#{1,6}\s/.test(e[n])&&!e[n].startsWith("```")&&!/^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/.test(e[n])&&!/^\s*&gt;/.test(e[n])&&!Fe.test(e[n])&&!(e[n].includes(`|`)&&n+1<e.length&&ze(e[n+1]));)c.push(e[n++]);t.push(`<p>${c.map(a).join(`<br>`)}</p>`)}return t.join(`
4
+ `)}</code></pre>`);continue}if(/^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/.test(o)){t.push(`<hr>`),n++;continue}let s=o.match(/^(#{1,6})\s+(.*)$/);if(s){t.push(`<h${s[1].length}>${a(s[2])}</h${s[1].length}>`),n++;continue}if(/^\s*&gt;/.test(o)){let r=[];for(;n<e.length&&/^\s*&gt;/.test(e[n]);)r.push(e[n++].replace(/^\s*&gt;\s?/,``));t.push(`<blockquote>${Le(r)}</blockquote>`);continue}if(o.includes(`|`)&&n+1<e.length&&ze(e[n+1])){let r=Re(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`),i=Re(o);n+=2;let s=[];for(;n<e.length&&/\S/.test(e[n])&&e[n].includes(`|`);)s.push(Re(e[n])),n++;let c=(e,t,n)=>{let i=r[t];return`<${n}${i&&i!==`left`?` style="text-align:${i}"`:``}>${a(e)}</${n}>`},l=i.some(e=>e!==``);t.push(`<div class="tbl"><table>`+(l?`<thead><tr>${i.map((e,t)=>c(e,t,`th`)).join(``)}</tr></thead>`:``)+`<tbody>${s.map(e=>`<tr>${e.map((e,t)=>c(e,t,`td`)).join(``)}</tr>`).join(``)}</tbody></table></div>`);continue}if(Fe.test(o)){t.push(i(r(o.match(Fe)[1])));continue}if(/^\s*$/.test(o)){n++;continue}let c=n,l=[];for(;n<e.length&&!/^\s*$/.test(e[n])&&!/^#{1,6}\s/.test(e[n])&&!e[n].startsWith("```")&&!/^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/.test(e[n])&&!/^\s*&gt;/.test(e[n])&&!Fe.test(e[n])&&!(e[n].includes(`|`)&&n+1<e.length&&ze(e[n+1]));)l.push(e[n++]);n===c&&l.push(e[n++]),t.push(`<p>${l.map(a).join(`<br>`)}</p>`)}return t.join(`
5
5
  `);function r(e){return e.replace(/\t/g,` `).length}function i(t){let o=null,s=[];for(;n<e.length;){let c=e[n].match(Fe);if(!c)break;let l=r(c[1]);if(l<t)break;let u=/^\d/.test(c[2]);if(o===null)o=u;else if(u!==o)break;n++;let d=c[3];for(;n<e.length&&/\S/.test(e[n])&&!Fe.test(e[n])&&!/^#{1,6}\s/.test(e[n])&&!e[n].startsWith("```")&&!/^\s*&gt;/.test(e[n]);)d+=` `+e[n].trim(),n++;let f=``,p=e[n]?.match(Fe);p&&r(p[1])>l&&(f=i(r(p[1])));let m=d.match(/^\[( |x|X)\]\s+(.*)$/),h=m?`<input type="checkbox" disabled${m[1].toLowerCase()===`x`?` checked`:``}> `:``;s.push(`<li>${h}${a(m?m[2]:d)}${f}</li>`)}return o?`<ol>${s.join(``)}</ol>`:`<ul>${s.join(``)}</ul>`}function a(e){let t=[];return e=e.replace(/\u0000/g,``),e=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\ue000${t.length-1}\uE001`)),e=e.replace(/!\[([^\]]*)\]\((https?:\/\/[^)\s]+)(?:\s+&quot;[^)]*&quot;)?\)/g,`<img src="$2" alt="$1" loading="lazy">`),e=e.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)(?:\s+&quot;[^)]*&quot;)?\)/g,`<a href="$2" rel="noopener noreferrer" target="_blank">$1</a>`),e=e.replace(/(?<!["'=\w])(https?:\/\/[^\s<>"')\]]*[^\s<>"')\].,;:!?"')\]])/g,`<a href="$1">$1</a>`),e=e.replace(/\*\*\*([\s\S]+?)\*\*\*/g,`<strong><em>$1</em></strong>`),e=e.replace(/\*\*([\s\S]+?)\*\*/g,`<strong>$1</strong>`),e=e.replace(/(^|[^\w])__(?=\S)([\s\S]*?\S)__(?!\w)/g,`$1<strong>$2</strong>`),e=e.replace(/(^|[^\w*])\*(?!\s)([^*\n]+?)\*(?![\w*])/g,`$1<em>$2</em>`),e=e.replace(/(^|[^\w])_(?!\s)([^_\n]+?)_(?!\w)/g,`$1<em>$2</em>`),e=e.replace(/~~([\s\S]+?)~~/g,`<del>$1</del>`),e.replace(/\ue000(\d+)\ue001/g,(e,n)=>t[+n]??``)}}function Re(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1));let n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e];if(i===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(i==="`"){let n=t.indexOf("`",e+1);if(n!==-1){r+=t.slice(e,n+1),e=n;continue}r+=i;continue}if(i===`|`&&e===t.length-1)break;if(i===`|`){n.push(r.trim()),r=``;continue}r+=i}return n.push(r.trim()),n.filter((e,r)=>!(e===``&&r===n.length-1&&t.endsWith(`|`)))}function ze(e){let t=e.trim();if(!t.includes(`|`)||!t.includes(`-`))return!1;let n=Re(t);return n.every(e=>/^:?-+:?$/.test(e))&&n.some(e=>e!==``)}function Be(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Ve(e){if(e==null||!Number.isFinite(e))return`?`;let t=Math.max(0,e);if(t<1e3)return`${Math.round(t)}ms`;if(t<6e4)return`${(t/1e3).toFixed(1)}s`;if(t<36e5){let e=Math.floor(t/6e4),n=Math.round(t%6e4/1e3);return n?`${e}m ${n}s`:`${e}m`}let n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r?`${n}h ${r}m`:`${n}h`}function He(e,t,n,r=Date.now()){let i=new Map(e);return i.set(t,{text:n.text??``,reasoning:n.reasoning??``,at:r}),i}function Ue(e,t){if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n}function We(e){let t=e;return t?.type===`state`&&t.data?.detail===`llm turn start`}function Ge(e,t,n){if(!e)return!1;if(!e.text)return n!==`running`;if(n!==`running`)return!0;let r=e.text.trim();return t.some(e=>e.type===`message`&&e.data?.role===`assistant`&&String(e.data.content??``).trim()===r)}function Ke(e){if(!e)return!1;let t=e.data?.actor;return!(typeof t==`string`&&t.length>0)}function qe(e,t){if(!t.length)return e;let n=e.reduce((e,t)=>Math.max(e,t.seq),0),r=t.map((e,t)=>({...e,seq:n+1+t}));return[...e,...r]}function Je(e,t){return t===void 0||t<=e.seq?e:{...e,seq:t}}function Ye(e){let t=e.event;return t===`status`||t===`audit-started`||t===`audit`||t===`audit-failed`?t:`other`}function Xe(e){let t=e.trim().toLowerCase();return t===``||t===`(no detail)`||t===`no detail`||t===`(none)`||t===`(empty)`}function Ze(e,t){let n=String(e??``).trim();return Xe(n)?Xe(t)?``:t:n}function Qe(e){switch(Ye(e)){case`audit-started`:return{label:`🔍 completion audit started`,detail:String(e.verify??``).trim()||`checking the verification contract…`,tone:``,markdown:!1,hasCard:!0};case`audit`:{let t=!Xe(String(e.feedback??``));return e.verdict===`approved`?{label:`✅ audit: approved`,detail:Ze(e.feedback??``,``),tone:`ok`,markdown:!0,hasCard:t}:{label:`⚠ audit: changes required`,detail:Ze(e.feedback??``,``),tone:`warn`,markdown:!0,hasCard:t}}case`audit-failed`:return{label:`🔍 audit unavailable — finish accepted`,detail:String(e.detail??``).trim()||`the auditor could not be reached`,tone:`err`,markdown:!1,hasCard:!0};case`status`:{let t=String(e.status??``).trim();return t?t===`done`?{label:`🏁 finish claimed — pending audit`,detail:`the agent called finish(goalComplete=true); the verification contract is now being audited`,tone:``,markdown:!1,hasCard:!0}:t===`active`?{label:`▶ goal reopened`,detail:`the audit rejected the finish — work continues on the same goal`,tone:`warn`,markdown:!1,hasCard:!0}:{label:`🎯 goal ${t||`updated`}`,detail:String(e.text??``).trim(),tone:``,markdown:!1,hasCard:!0}:{label:`🎯 goal status updated`,detail:String(e.text??``).trim()||`no status recorded`,tone:``,markdown:!1,hasCard:!0}}default:{let t=String(e.text??``).trim(),n=String(e.event??``).trim();return{label:n?`🎯 goal ${n}`:`🎯 goal updated`,detail:t||`the "${n||`goal`}" event carried no further detail`,tone:``,markdown:!1,hasCard:!0}}}}function $e(e,t){let n=String(t??``);return/^TIMEOUT after\b/.test(n)?`timeout`:/^ABORTED\b/.test(n)?`aborted`:/^exit=\d+/.test(n)||e===!1?`exit`:n.trim()?`ok`:`empty`}function et(e){switch(e){case`timeout`:return` · TIMED OUT`;case`aborted`:return` · ABORTED`;case`exit`:return` · FAILED`;default:return``}}function tt(e){let t=[];e.outcome!==`empty`&&t.push(e.fmtDur(e.durationMs)),e.timeoutMs&&t.push(`timeout ${Math.round(e.timeoutMs/1e3)}s`);let n=et(e.outcome);return n&&t.push(n.trim()),t.join(` · `)}function nt(e,t=new Set,n=!1,r=new Set){let i=n?e.filter(e=>!e.workspaceMissing):e,a=new Map,o=[];for(let e of i)e.parent&&i.some(t=>t.id===e.parent)?(a.has(e.parent)||a.set(e.parent,[]),a.get(e.parent).unshift(e)):o.push(e);let s=[],c=(e,n)=>{for(let o of e){if(n===0&&r.has(it(i,o))){s.push({a:o,depth:n});continue}s.push({a:o,depth:n});let e=a.get(o.id);e?.length&&!t.has(o.id)&&c(e,n+1)}},l=[],u=new Map;for(let e of o){let t=rt(i,e.id),n=u.get(t);n?n.push(e):(u.set(t,[e]),l.push(t))}for(let e of l)c(u.get(e),0);return s}function rt(e,t,n=new Set){let r=e.find(e=>e.id===t);return r?!r.parent||n.has(t)?r.workspace||``:(n.add(t),rt(e,r.parent,n)||r.workspace||``):``}function it(e,t){let n=t.id,r=new Set;for(;;){let t=e.find(e=>e.id===n);if(!t?.parent||r.has(n))break;r.add(n),n=t.parent}return`chat:${n||t.id}`}function at(e){let t=new Map;for(let n of e){if(n.parent)continue;let r=rt(e,n.id);r&&t.set(r,(t.get(r)??0)+1)}return t}function ot(e,t,n=new Set){let r=[],i=null;for(let a of t){let t=rt(e,a.a.id);if(!t){r.push({a:a.a,depth:a.depth});continue}if(t!==i&&(i=t,r.push({a:a.a,depth:0,headerOnly:!0,wsHeader:t,wsCollapsedGroup:n.has(`ws:${t}`)})),!n.has(`ws:${t}`)){if(n.has(it(e,a.a))){r.push({a:a.a,depth:a.depth,chatCollapsedGroup:!0});continue}r.push({a:a.a,depth:a.depth})}}return r}var st=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=(e,t)=>{for(var n in t)st(e,n,{get:t[n],enumerable:!0})},z=(e,t,n,r)=>{for(var i=r>1?void 0:r?ct(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&st(t,n,i),i},B=(e,t)=>(n,r)=>t(n,r,e),ut=`Terminal input`,dt={get:()=>ut,set:e=>ut=e},ft=`Too much output to announce, navigate to rows manually to read`,pt={get:()=>ft,set:e=>ft=e};function mt(e){return e.replace(/\r?\n/g,`\r`)}function ht(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function gt(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function _t(e,t,n,r){e.stopPropagation(),e.clipboardData&&vt(e.clipboardData.getData(`text/plain`),t,n,r)}function vt(e,t,n,r){e=mt(e),e=ht(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function yt(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function bt(e,t,n,r,i){yt(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function xt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function V(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var St=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Ct=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},wt=``,Tt=` `,Et=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Dt}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Dt=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ot=class e extends Et{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Dt,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?xt(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},kt=`di$target`,At=`di$dependencies`,jt=new Map;function Mt(e){return e[At]||[]}function H(e){if(jt.has(e))return jt.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Nt(t,e,r)};return t._id=e,jt.set(e,t),t}function Nt(e,t,n){t[kt]===t?t[At].push({id:e,index:n}):(t[At]=[{id:e,index:n}],t[kt]=t)}var Pt=H(`BufferService`),Ft=H(`CoreMouseService`),It=H(`CoreService`),Lt=H(`CharsetService`),Rt=H(`InstantiationService`),zt=H(`LogService`),Bt=H(`OptionsService`),Vt=H(`OscLinkService`),Ht=H(`UnicodeService`),Ut=H(`DecorationService`),Wt=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Ot,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Gt(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Wt=z([B(0,Pt),B(1,Bt),B(2,Vt)],Wt);function Gt(e,t){if(confirm(`Do you want to navigate to ${t}?
6
6
 
7
7
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Kt=H(`CharSizeService`),qt=H(`CoreBrowserService`),Jt=H(`MouseService`),Yt=H(`RenderService`),Xt=H(`SelectionService`),Zt=H(`CharacterJoinerService`),Qt=H(`ThemeService`),$t=H(`LinkProviderService`),en=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?sn.isErrorNoTelemetry(e)?new sn(e.message+`
@@ -21,10 +21,10 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
21
21
  - task two"title="shared with the agent \\u2014 it may check items off via set_todo; your unsaved edits win until you save"style="width:100%;background:var(--bg-darkest);border:none;border-radius:6px;padding:6px 8px;color:var(--fg);font-family:ui-monospace,Menlo,monospace;font-size:12.5px;resize:vertical">`),vf=F(`<div class="content mdpreview"style="max-height:40vh;padding:8px 10px">`),yf=F(`<span class=fsize>`),bf=F(`<div><span class=ficon></span><span class=fname>`),xf=F(`<h3 title="the agent's workspace — lazy-loaded, dotfiles hidden; click a folder to expand, a file to preview"style=display:flex;align-items:center;gap:6px>🗂 files <span class=muted style=text-transform:none;letter-spacing:0>· `),Sf=F(`<div class=filebox>`),Cf=F(`<div class=muted style=padding:6px>`),wf=F(`<img>`),Tf=F(`<div class=mediapreview><div class="meta muted"> preview`),Ef=F(`<button title="rendered markdown">👁 preview`),Df=F(`<button title="edit and save back to the workspace">✎ edit`),Of=F(`<div class=filetoolbar><button title="syntax-highlighted source">&lt;/> code`),kf=F(`<div class=fileeditor><textarea class=mono></textarea><div class=filerow-actions><span class=muted> bytes</span><button class=savebtn>`),Af=F(`<div class=mono style=margin:0;color:var(--dim)>(binary file — inspect it from the terminal)`),jf=F(`<div class="content mdpreview">`),Mf=F(`<video controls>`),Nf=F(`<audio controls>`),Pf=F(`<div class=filepreview>`),Ff=F(`<div class=muted style=padding-top:6px;font-size:11.5px>… truncated (first 100 KB)`),If=F(`<div class=muted style=padding:8px;font-size:12px>✨ highlighting <!>…`),Lf=F(`<pre class=mono style=max-height:62vh;overflow:auto;white-space:pre-wrap;margin:0>`),Rf=F(`<div class=muted style=font-size:11.5px;margin-top:-6px>`),zf=F(`<span style=color:var(--fg)>`),Bf=F(`<div class=muted style=font-size:11.5px;margin-top:-8px> models found at this endpoint`),Vf=F(`<div class=overlay style=background:var(--bg-darkest)><div class=modal style=max-width:560px><div class=modal-head><b>🫖 welcome to teapot</b></div><p class=muted style="margin:0 0 10px;font-size:13px">first run — pick an OpenAI-compatible provider and you're done. everything below can be changed later in ⚙ settings.</p><form style=display:flex;flex-direction:column;gap:12px><div style=display:flex;gap:6px;flex-wrap:wrap></div><label>base url<input type=text class="w100 mono"list=wiz-preset-urls><datalist id=wiz-preset-urls></datalist></label><label>api key <input type=password class=w100 placeholder="(local providers may not need one)"></label><label>default model<input type=text class="w100 mono"list=wiz-model-list><datalist id=wiz-model-list></datalist></label><fieldset><legend>first agent</legend><label>workspace directory<input type=text class="w100 mono"></label><label title="asks for this password when opening the UI or API from another machine — plain-HTTP LAN traffic is NOT encrypted"style=margin-top:4px>protect the API with a password? <input type=password class=w100 placeholder="(optional — LAN traffic is still plain HTTP)"></label></fieldset><button type=submit style="background:var(--acc);border:none;border-radius:8px;color:#fff;padding:9px 14px;font-weight:600;cursor:pointer">`),Hf=F(`<button type=button>`),Uf=F(`<div class=muted style=font-size:11.5px;margin-top:-8px>models appear here automatically once the endpoint answers GET /models`),Wf=F(`<label><input type=number min=0>`),Gf=F(`<div class=muted style=font-size:11.5px;margin-top:4px>⚠ configured default provider <code></code> has no provider row here<!> Add a provider named <code></code> or pick a default below; otherwise agents fall back to the first provider.`),Kf=F(`<form style=display:flex;flex-direction:column;gap:14px><fieldset><legend>providers</legend><button type=button>+ add custom</button><div style=display:flex;gap:6px;flex-wrap:wrap;margin-top:6px><span class=muted style=font-size:11.5px>quick-add:</span></div><div><label title="agents without an explicit provider use this one"style=display:flex;align-items:center;gap:6px;margin-top:6px>default provider<select><option value>(none — first provider wins)</option></select></label></div></fieldset><fieldset><legend>agent runtime</legend><div class=cfggrid><label title="auto-compact threshold in k tokens. Leave EMPTY to derive per model (75% of its context window) — recommended, since models differ wildly in window size. Set only to force an absolute cap across all models.">compact budget (k tok)<input type=number min=0 placeholder="(derive: 75% of window)"></label></div></fieldset><fieldset><legend>scheduled tasks</legend><button type=button>+ add task</button></fieldset><fieldset><legend>agents (read-only — edit config file or use +)</legend></fieldset><fieldset><legend>live update</legend><div class=cfgrow><span class=muted>current version: </span><button type=button style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:6px 14px;cursor:pointer">update & restart</button><span class=muted style=margin-left:8px;font-size:12px>gracefully stops all agents, spawns new process, then reloads this page</span></div></fieldset><button type=submit style="align-self:flex-end;background:var(--acc);border:none;border-radius:6px;color:#fff;padding:6px 14px;cursor:pointer">save settings`),qf=F(`<div class=cfgrow><input class=cfgname placeholder=name><input placeholder=https://…/v1><input placeholder="api key"type=password><input placeholder="default model"><button type=button class=danger title="remove provider">✕`),Jf=F(`<button type=button>+ `),Yf=F(`<div class=cfgcol><div class=cfgrow><input placeholder=id><input placeholder="agent id"><input placeholder="every 30m / cron"><label style=display:flex;gap:3px;align-items:center;white-space:nowrap;color:var(--dim);font-size:11px><input type=checkbox>fork</label><button type=button class=danger>✕</button></div><textarea rows=2 placeholder="prompt to send">`),Xf=F(`<span class=muted>🧩 sub of @`),Zf=F(`<div class=cfgrow><b></b><span class=muted>`),Qf=new Map;function $f(e){let t=Qf.get(e);if(t!==void 0)return t;let n=Ie(e);return Qf.set(e,n),Qf.size>500&&Qf.delete(Qf.keys().next().value),n}var ep=[`minimal`,`low`,`medium`,`high`],tp=1100,np={prompt:{name:`you`,icon:`🟧`,color:`#faa81a`},user:{name:`you`,icon:`🟧`,color:`#faa81a`},message:{name:`agent`,icon:`🫖`,color:`#5865f2`},progress:{name:`progress`,icon:`📈`,color:`#3ba55d`},question:{name:`agent`,icon:`❓`,color:`#5865f2`}},rp={name:`harness`,icon:`📣`,color:`#3ba55d`},[ip,ap]=v(``),op,Q=e=>{ap(e),clearTimeout(op),op=setTimeout(()=>ap(``),3200)},sp=!1,cp=[{key:`dark`,label:`Dark`,mode:`dark`,sw:[`#1a1c22`,`#2b2e39`,`#5865f2`]},{key:`midnight`,label:`Midnight`,mode:`dark`,sw:[`#0d0f18`,`#252a42`,`#8b7cf7`]},{key:`tea`,label:`Milk Tea`,mode:`dark`,sw:[`#241c16`,`#493b2d`,`#d98e32`]},{key:`coffee`,label:`Coffee`,mode:`dark`,sw:[`#191410`,`#403527`,`#c68a4b`]},{key:`matcha`,label:`Matcha`,mode:`dark`,sw:[`#1b2217`,`#3c4a33`,`#8db64e`]},{key:`matrix`,label:`Matrix`,mode:`dark`,sw:[`#060a06`,`#18301d`,`#2fd558`]},{key:`sunset`,label:`Sunset`,mode:`dark`,sw:[`#1c1422`,`#452f52`,`#f2784b`]},{key:`light`,label:`Light`,mode:`light`,sw:[`#eceef4`,`#ffffff`,`#4757d8`]},{key:`strawberry`,label:`Strawberry`,mode:`light`,sw:[`#fbe4ea`,`#fffafb`,`#e05575`]},{key:`ramune`,label:`Ramune`,mode:`light`,sw:[`#ddeff7`,`#fbfeff`,`#1d86ae`]}];function lp(){let e=``,t=``;try{let n=getComputedStyle(document.documentElement);e=n.getPropertyValue(`--term-bg`).trim(),t=n.getPropertyValue(`--term-fg`).trim()}catch{}return{background:e||`#0d0e12`,foreground:t||`#dcdee4`}}var up=e=>{if(e.data?.actor)return{name:`@${String(e.data.actor)}`,icon:`🧩`,color:`#3ba0c9`};if(e.type===`tool_call`||e.type===`tool_result`)return{name:String(e.data?.name??`tool`),icon:`⚙`,color:`#3ba0c9`};if(e.type===`prompt`){let t=String(e.data?.source??`user`);return t===`user`?np.prompt:t.startsWith(`scheduler:`)?{name:t.slice(10),icon:`📣`,color:`#3ba55d`}:rp}return np[e.type]??{name:e.type,icon:`•`,color:`#9298a5`}},dp=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`,`state`,`error`,`fork`,`goal`,`todo`,`question`,`decision`,`compaction`,`system_note`]),fp=new Set([`system_note`]),pp=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function $(e,t){let n=localStorage.getItem(`teapot.token`),r=new Headers(t?.headers);n&&!r.has(`authorization`)&&r.set(`authorization`,`Bearer ${n}`);let i=await fetch(e,{...t,headers:r});if(!i.ok){i.status===401&&window.dispatchEvent(new CustomEvent(`teapot:unauthorized`));let t=null;try{t=await i.json()}catch{}let n=(t&&typeof t==`object`&&`error`in t?String(t.error):``)||`${e}: HTTP ${i.status}`;throw Object.assign(Error(n),{payload:t})}return i.json()}var mp=location.hash.match(/[#&]token=([^&]+)/);mp&&(localStorage.setItem(`teapot.token`,decodeURIComponent(mp[1])),history.replaceState(null,``,location.pathname+location.search));var hp=()=>{let e=localStorage.getItem(`teapot.token`);return e?`?token=${encodeURIComponent(e)}`:``};function gp(){let[e,t]=v([]),[n,r]=v(null),[i,a]=v(``),[o,s]=v(new Map),[c,l]=v(new Map),u=!1;async function d(e=!1){if(!(u&&!e)){u=!0;try{let e=await $(`/api/sessions`),t=new Map,n=new Map;for(let r of e.sessions??[]){t.set(r.id,r.agentId);let e=n.get(r.agentId)??[];e.push(r.id),n.set(r.agentId,e)}s(t),l(n)}catch{}}}let[f,p]=v([]),[m,h]=v(0),[g,_]=v([]),[ee,te]=v(null),T=new Map,[ne,E]=v(T.get(n()??``)??``),D=e=>{E(e);let t=n();t&&(e?T.set(t,e):T.delete(t))},[O,re]=v({providers:{}}),[k,ie]=v(!1),[ae,oe]=v(!1),se=()=>window.innerWidth<=tp,[ce,A]=v(se());C(()=>{let e=()=>A(se());window.addEventListener(`resize`,e),w(()=>window.removeEventListener(`resize`,e)),e()});let[le,ue]=v(localStorage.getItem(`teapot.panel`)===null?window.innerWidth>tp:localStorage.getItem(`teapot.panel`)===`1`),de=e=>{ue(e),localStorage.setItem(`teapot.panel`,e?`1`:`0`)},fe=()=>de(!le()),pe=()=>{le()&&de(!1)},[me,he]=v(!1),[ge,_e]=v(localStorage.getItem(`teapot.theme`)??`dark`),[ve,ye]=v(localStorage.getItem(`teapot.theme.auto`)===`1`),[be,xe]=v(localStorage.getItem(`teapot.theme.light`)??`light`),[Se,Ce]=v(localStorage.getItem(`teapot.theme.dark`)??`dark`),F=typeof window.matchMedia==`function`?window.matchMedia(`(prefers-color-scheme: light)`):null,[we,ke]=v(F?.matches??!1);C(()=>{let e=e=>ke(e.matches);F?.addEventListener(`change`,e),w(()=>F?.removeEventListener(`change`,e))}),b(()=>{let e=ve()?we()?be():Se():ge();document.documentElement.dataset.theme=e,document.documentElement.dataset.appearance=cp.find(t=>t.key===e)?.mode??`dark`});let[Ae,je]=v(``),[Me,Ne]=v(``),[Pe,Fe]=v(``);b(()=>{let t=n();Fe(S(()=>e().find(e=>e.id===t)?.reasoningEffort??``))});let[Le,Re]=v([]),ze=()=>Object.keys(O().providers??{});async function Be(e){if(e)try{let t=await $(`/api/models?provider=${encodeURIComponent(e)}`);Re(t.models??[])}catch{Re([])}}let Ve=e=>{let t={text:`📄`,image:`🖼️`,audio:`🔊`,video:`🎬`,file:`📎`},n=e=>(e??[`text`]).map(e=>t[e]??e).join(``);return e?.modalities?`${n(e.modalities.input)} → ${n(e.modalities.output)}`:``},Ye=()=>{let e=Me().trim()||V()?.model||``;if(!e)return``;let t=Le().find(t=>t.id===e);if(!t)return``;let n=[],r=Ve(t);r&&r!==`📄 → 📄`&&n.push(r),t.contextLength&&n.push(`ctx ${Ep(t.contextLength)} tok`);let i=e=>e===void 0?``:`${e*1e6>=10?Math.round(e*1e6):+(e*1e6).toFixed(1)}/M`;if(t.pricing){let e=i(t.pricing.prompt),r=i(t.pricing.completion);e&&r?n.push(`${e} in · ${r} out`):(e||r)&&n.push(i(t.pricing.prompt??t.pricing.completion))}return n.join(` · `)},Ze=null;b(()=>{let t=n();if(!t)return;let r=e().find(e=>e.id===t),i=r?.provider||O().defaultProvider||ze()[0]||``;if(r){if(t!==Ze)Ze=t,S(()=>Ae())!==i&&(je(i),Be(i)),S(()=>Me())&&Ne(``);else{let e=S(()=>Ae());!S(()=>Me())&&e!==i&&(je(i),Be(i))}}});let[Qe,$e]=v(!1),[et,tt]=v(!0),[rt,st]=v(0),[ct,lt]=v(null),z=()=>mt().startsWith(`[compact] `),B=()=>z()?mt().slice(10):mt();b(()=>{ct()||pt(e=>e?.text.startsWith(`[compact] `)?null:e)});let[ut,dt]=v(new Map),ft=()=>{let e=n();return e?ut().get(e)??null:null},pt=e=>{let t=n();t&&dt(n=>{let r=new Map(n),i=typeof e==`function`?e(n.get(t)??null):e;return i?r.set(t,{...i,at:Date.now()}):r.delete(t),r})},[mt,ht]=v(``),[gt,_t]=v(0),vt=()=>gt(),[yt,bt]=v(``),xt;b(()=>{if(!ft()){clearTimeout(xt),xt=void 0,ht(``),bt(``);return}xt||=setTimeout(()=>{xt=void 0,ht(ft()?.text??``),bt(ft()?.reasoning??``)},(ft()?.text.length??0)>2e4?250:(ft()?.text.length??0)>6e3?120:60)}),w(()=>clearTimeout(xt)),b(()=>{let e=V()?.status;if(e===`running`||e===`waiting`)return;let t=n();t&&(dt(e=>{if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n}),_t(0))}),b(()=>{let e=mt(),t=ft()?.reasoning??``;!e&&!t||et()&&requestAnimationFrame(()=>{et()&&Vn(!0)})}),b(()=>{let e=V()?.pendingPrompts??0;Et(t=>e>=t.length?t:t.some(e=>e.promptId)?t.filter(e=>!!e.promptId).slice(0,e):t.slice(0,e))}),b(()=>{if(!n())return;let e=()=>{document.visibilityState===`visible`&&requestAnimationFrame(()=>{K()&&(tt(!0),st(0),Vn(!0))})};document.addEventListener(`visibilitychange`,e),w(()=>document.removeEventListener(`visibilitychange`,e))});let V=x(()=>e().find(e=>e.id===n())),St=()=>{let e=V();return e?e.live??(e.status===`running`||e.status===`waiting`):!1},[Ct,wt]=v(null);x(()=>{let e=new Set;for(let t of f())t.type===`tool_result`&&t.data?.name===`ask_user`&&e.add(String(t.data.callId));return e});let[Tt,Et]=v([]),[Dt,Ot]=v([]),[kt,At]=v(localStorage.getItem(`teapot.hideGhosts`)===`1`),[jt,Mt]=v(!1),H=()=>Dt().filter(e=>!e.read).length,Nt=e=>{Ot(t=>{let n=!1,r=t.map(t=>t.read||t.agentId!==e?t:(n=!0,{...t,read:!0}));return n?r:t})},Pt=t=>{let n=Dt().filter(e=>!e.read&&e.agentId===t).length;for(let r of e())r.parent===t&&(n+=Pt(r.id));return n},Ft=0,It=e=>{Ot(t=>[{...e,id:`n${++Ft}`,at:Date.now(),read:!1},...t].slice(0,50))},Lt=(t,n)=>{let r=e().find(e=>e.id===t)?.id??t,i=typeof n.id==`string`?n.id:void 0;n.type===`message`&&n.data?.final===!0?It({agentId:t,kind:`finish`,title:`${r} finished`,body:String(n.data.content??``).slice(0,300),eventId:i}):n.type===`question`?It({agentId:t,kind:`question`,title:`${r} asks a question`,body:String(n.data.question??``).slice(0,300),eventId:i}):n.type===`error`?It({agentId:t,kind:`error`,title:`${r} hit an error`,body:String(n.data.message??``).slice(0,300),eventId:i}):n.type===`progress`&&It({agentId:t,kind:`progress`,title:`${r}: ${String(n.data.doing??`progress`)}`.slice(0,120),body:[n.data.recent&&`recent: ${n.data.recent}`,n.data.next&&`next: ${n.data.next}`].filter(Boolean).join(` · `).slice(0,300),eventId:i})},Rt=e=>{let t=document.querySelector(`[data-eid="${e}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`flash-target`),setTimeout(()=>t.classList.remove(`flash-target`),1600))},zt=x(()=>{let e=new Map,t=new Set,n=new Map,r=new Map;for(let i of f())if(dp.has(i.type)){if(i.type===`tool_call`){let e=n.get(i.data.callId)??[];e.push(i),n.set(i.data.callId,e)}else if(i.type===`tool_result`){let a=n.get(i.data.callId)?.shift();a?(e.set(a.id,i),t.add(i.id)):r.set(i.id,i)}}return{resFor:e,consumed:t,orphanCalls:r}}),[Bt,Vt]=v(new Set),Ht=e=>{e&&Vt(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},Ut=()=>Vt(new Set),Wt=x(()=>{let e=new Set,t=-1,n=-1;for(let e of f())e.type===`question`?t=e.seq:e.type===`prompt`&&e.data?.source===`user`?n=e.seq:e.type===`system_note`&&e.data?.event===`prompt-delivered`&&(n=Math.max(n,e.seq));if(t>=0&&n>t)for(let t of f())t.type===`question`&&t.seq<=n&&e.add(String(t.data?.callId??``));for(let t of Bt())e.add(t);return e}),Gt=x(()=>{let{consumed:e}=zt(),t=``;for(let e of f()){if(e._prevKind=t,!dp.has(e.type))continue;let n=e.data??{};(e.type!==`message`||String(n.content??``).trim()!==``||String(n.reasoning??``).trim()===``)&&(t=e.type===`tool_result`?`tool`:e.type)}let n=f().filter(t=>{if(t.type===`sub`)return!0;if(!dp.has(t.type))return!1;let n=t.type===`tool_call`||t.type===`tool_result`?String(t.data?.name??``):``;if(n===`report_progress`||n===`ask_user`)return!1;if(t.type===`tool_result`)return!e.has(t.id);if(t.type===`message`){let e=String(t.data?.content??``);return e.trim()===``&&String(t.data?.reasoning??``).trim()!==``&&t._prevKind===`tool`||t.data?.progressEcho||!t.data?.final&&e.trim()===`(tool call)`?!1:e.trim()!==``||String(t.data?.reasoning??``).trim()!==``||!!t.data?.final}return!0}),r=[];for(let e of n)if(e.type===`sub`){let t=e.data,n=String(t?.type??`message`);if(n===`state`)continue;r.push({...e,type:n,data:{...t?.data,actor:t?.sub}})}else r.push(e);let i=e=>String(e??``).replace(/\s+/g,` `).trim().toLowerCase(),a=[];for(let e=0;e<r.length;e++){let t=r[e];if(t.type===`message`&&t.data?.role===`assistant`){let n=r[e-1],a=i(t.data.content);if(n?.type===`progress`){let e=n.data;if((a.includes(i(e.doing))||e.recent&&a.includes(i(e.recent)))&&a.length<=Math.max(200,i(e.doing).length*3))continue}if(n?.type===`decision`){let e=n.data,t=i(e.decision);if(t&&a.includes(t)&&a.length<=Math.max(300,t.length*3))continue}}a.push(t)}let o=new Set,s=new Set,c=new Map,l=new Map;for(let e of a){let t=e.data?.promptId;t&&(e.type===`prompt`&&e.data?.source===`user`&&s.add(String(t)),e.type===`system_note`&&e.data?.event===`prompt-delivered`&&(o.add(String(t)),c.set(String(t),e.seq)),e.type===`system_note`&&e.data?.event===`prompt-cancelled`&&l.set(String(t),e.seq))}let u=new Set;for(let e of Tt())e.promptId&&!o.has(e.promptId)&&u.add(e.promptId);let d=a.filter(e=>{if(e.type!==`prompt`||e.data?.source!==`user`)return!0;let t=String(e.data?.promptId??``);return t===``||!u.has(t)});for(let e=0;e<d.length;e++){let t=d[e];if(t.type!==`prompt`||t.data?.source!==`user`)continue;let n=String(t.data?.promptId??``),r=l.get(n);r!==void 0&&t.data&&(t.data.cancelled=!0),d[e]=Je(t,Math.max(c.get(n)??0,r??0)||void 0)}return qe(d,Tt().filter(e=>!e.promptId||!(o.has(e.promptId)&&s.has(e.promptId))).map(e=>qt(e)))}),Kt=new Map;function qt(e){let t=`${e.id}:${e.sent?`s`:`p`}`,n=Kt.get(t);if(n)return n;Kt.size>64&&Kt.clear();let r={id:e.id,seq:2**53-1,ts:new Date(e.at).toISOString(),session:V()?.session??``,branch:V()?.branch??`br0`,parent:null,type:`prompt`,data:{source:`user`,text:e.text,pending:!e.sent,...e.images?.length?{images:e.images}:{},...e.promptId?{promptId:e.promptId}:{}}};return Kt.set(t,r),r}let Jt=()=>$(`/api/config`).then(re).catch(()=>{}),[Yt,Xt]=v(!1);C(()=>{let e=()=>Xt(!0);window.addEventListener(`teapot:unauthorized`,e),w(()=>window.removeEventListener(`teapot:unauthorized`,e))});let[Zt,Qt]=v(``),[$t,en]=v(!1),[tn,nn]=v(!1),rn=``;b(()=>{let t=n(),r=e().find(e=>e.id===t)?.todo??``;t&&t!==rn?(rn=t,nn(!1),Qt(r)):t&&!tn()&&Qt(r)});let an=async()=>{let e=document.getElementById(`todo-notify`)?.checked??!0;if(n())try{await $(`/api/agents/${n()}/todo`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:Zt(),notify:e})}),nn(!1),Q(`tasks saved${e&&Zt().trim()?` & notification queued`:``}`),sn()}catch(e){Q(`save failed: ${e.message}`)}},on=x(()=>{let e=0,t=0;for(let n of Zt().split(`
22
22
  `)){let r=n.match(/^\s*[-*+] \[([ xX])\]/);r&&(e++,r[1].toLowerCase()===`x`&&t++)}return{total:e,done:t}}),sn=()=>$(`/api/agents`).then(e=>{let n=!1;t(t=>{let r=new Map(t.map(e=>[e.id,e]));return t.length!==(e.agents??[]).length&&(n=!0),(e.agents??[]).map(e=>{let t=r.get(e.id);return t||(n=!0),t&&JSON.stringify(t)===JSON.stringify(e)?t:e})}),n&&d()}).catch(()=>{}),cn=()=>$(`/api/metrics`).then(te).catch(()=>{}),[ln,un]=v([]),dn=()=>$(`/api/tasks`).then(e=>un(e.tasks)).catch(()=>{}),fn=e=>ln().filter(t=>t.agent===e),[pn,mn]=v((()=>{try{return new Set(JSON.parse(localStorage.getItem(`teapot.collapsed`)??`[]`))}catch{return new Set}})()),hn=e=>{let t=new Set(pn());t.has(e)?t.delete(e):t.add(e),mn(t),localStorage.setItem(`teapot.collapsed`,JSON.stringify([...t]))},gn=t=>it(e(),t),[_n,vn]=v((()=>{try{let e=JSON.parse(localStorage.getItem(`teapot.wsCollapsed`)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}})()),yn=x(()=>{let e=new Set;for(let t of _n())t.startsWith(`chat:`)&&e.add(t);return e}),bn=x(()=>nt(e(),pn(),kt(),yn())),U=(t,r,i,a)=>{let o=new Set(_n());if(i)o.delete(t),a&&o.delete(a);else{o.add(t),a&&o.delete(a);let i=n();i&&(t===`chat:${i}`||gn(e().find(e=>e.id===i))===t)&&Q(`hid ${r} — click the header to show it`)}vn(o);try{localStorage.setItem(`teapot.wsCollapsed`,JSON.stringify([...o]))}catch{}},xn=e=>e.replace(/\/+$/,``).split(/[/\\]/).pop()||e,Sn=e=>{let t=W().get(e)??0;return`${t} chat${t===1?``:`s`}`},W=x(()=>at(e())),Cn=x(()=>ot(e(),bn(),_n())),wn=2e3,[Tn,G]=v(null),En=new Map;function Dn(e){return`${i()||(n()??`?`)}:${e.id}`}function On(e){let t=Array.from({length:e.length});for(let n=0;n<e.length;n++){let r=e[n],i=Dn(r),a=En.get(i);if(t[n]=a??r,!a&&(En.set(i,r),En.size>6e3)){let e=En.keys().next().value;e!==void 0&&En.delete(e)}}return t}let[kn,An]=v(!1),[jn,Mn]=v(!1),Nn=0,Pn=-1;function Fn(e){p(t=>{let n=new Map;for(let e of t)n.set(e.id,e);for(let t of On(e))n.has(t.id)||n.set(t.id,t);return[...n.values()].sort((e,t)=>e.seq-t.seq)})}async function In(){let e=n();if(!e||jn()||kn())return;if(f().length>=m()){Mn(!0);return}let t=()=>{let e=zn();return e&&e.clientHeight>0?e:null},r=0;for(;r++<20&&!jn()&&n()===e;){let r=t();if(r&&r.scrollHeight>r.clientHeight+40)return;if(f().length>=m()){Mn(!0);return}let i=f().length;if(await Ln(),f().length===i)return;et()&&n()===e&&Vn(!0)}}async function Ln(){let e=n(),t=f()[0];if(!(!e||!t||kn()||jn())){An(!0);try{let r=zn(),a=r?.scrollHeight??0,o=r?.scrollTop??0,s=Tn(),c=i(),l=c&&c!==e?`&session=${encodeURIComponent(c)}`:``,u=(await $(`/api/agents/${e}/events?limit=${wn}&before=${encodeURIComponent(t.id)}${l}${s?`&branch=${encodeURIComponent(s)}`:``}`)).events??[];if(u.length===0){Mn(!0);return}if(n()!==e||f()[0]?.id!==t.id)return;Fn(u),requestAnimationFrame(()=>{if(n()===e){let e=zn();e&&(e.scrollTop=o+(e.scrollHeight-a))}})}catch{}finally{An(!1)}}}async function Rn(e,t){let r=Nn,a=t??i()??``;try{let t=Tn(),i=r!==Pn||!g().length,o=a&&a!==e?`&session=${encodeURIComponent(a)}`:``,[s,c,l]=await Promise.all([$(`/api/agents/${e}/events?limit=${wn}${o}${t?`&branch=${encodeURIComponent(t)}&lineage=true`:``}`),i?$(`/api/agents/${e}/branches`):Promise.resolve({branches:g()}),$(`/api/agents/${e}/skills`).catch(()=>({skills:[]}))]);if(i&&(Pn=r),r!==Nn||n()!==e)return;p(e=>{let t=new Map;for(let n of e)t.set(n.id,n);for(let e of On(s.events))t.set(e.id,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}),h(s.total??s.events.length),_(c.branches),Br(l.skills??[])}catch{}}function zn(){return document.querySelector(`.feed`)}function Bn(){let e=document.querySelector(`.composer textarea`);return 24+Math.min(Math.max((e?.scrollHeight??0)-(e?.clientHeight??0),0),160)}function K(){let e=zn();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<Bn()}function Vn(e=!1){let t=zn();t&&(e||et())&&(t.scrollTop=t.scrollHeight,st(0))}let Hn=new Map;function Un(t,n){if(n&&c().get(t)?.includes(n))return n;let r=e().find(e=>e.id===t)?.session;return r&&c().get(t)?.includes(r)?r:c().get(t)?.[0]??null}async function Wn(e,t=!0,o){let s=n(),l=i(),u=f(),g=m();Nn++,c().size||d();let _=Un(e,o)??e;if(s!==e||_!==l){if(l&&u.length&&(Hn.set(l,{events:u,total:g,at:Date.now()}),Hn.size>6)){let e=[...Hn.entries()].sort((e,t)=>e[1].at-t[1].at)[0];e&&Hn.delete(e[0])}p([]),En.clear(),Ut(),lt(null),st(0),tt(!0),qr=!1,Jr=void 0}r(e),a(_),D(T.get(e)??``),G(null),Mn(!1),An(!1),Et([]),localStorage.setItem(`teapot.session`,e),$n(_,t);let v=Hn.get(_);v?.events.length&&(On(v.events),p(On(v.events)),h(v.total),requestAnimationFrame(()=>{n()===e&&Vn(!0)})),$(`/api/agents/${e}/load`,{method:`POST`}).then(sn).catch(()=>{}),await Rn(e,_),n()===e&&(lt(V()?.ctx?.compacting?{phase:String(V().ctx.compacting)}:null),requestAnimationFrame(()=>{n()===e&&Vn(!0)}),In())}let[Gn,Kn]=v(!1),qn=null,Jn=null;w(()=>qn?.close());let Yn=!1,Xn=null;document.addEventListener(`visibilitychange`,()=>Xn?.()),w(()=>{Xn=null});function Zn(){let e=location.protocol===`https:`?`wss://`:`ws://`;qn=new WebSocket(`${e}${location.host}/api/ws${hp()}`),qn.onopen=()=>Kn(!0),qn.onclose=()=>{Kn(!1),setTimeout(Zn,1500)},qn.onerror=()=>qn?.close();let r=new Set([`state`,`usage`,`session_start`]);qn.onmessage=e=>{let a=JSON.parse(e.data);if(a.kind!==`ping`&&a.kind!==`pong`){if(a.kind===`event`&&We(a.event)){dt(e=>Ue(e,a.agentId));return}if(a.kind===`llm-delta`){if(dt(e=>He(e,a.agentId,a)),a.agentId===n()){let e=String(a.reasoning??``),t=String(a.text??``);e&&!t?gt()||_t(Date.now()):(t||!e&&gt())&&_t(0)}return}if(a.kind===`compaction-progress`){if(a.agentId!==n())return;a.phase===`done`?lt(null):lt({phase:a.phase,summarized:a.summarized});return}if(a.kind===`agent-update`&&a.snapshot){t(e=>{let t=e.findIndex(e=>e.id===a.snapshot.id),n=a.snapshot;if(t===-1)return[...e,n];let r=e[t];return JSON.stringify(r)===JSON.stringify(n)?e:e.map((e,r)=>r===t?n:e)});return}if(a.kind===`event`){let e=a.event?.type,t=a.event?.data??{};if((e===`system_note`&&t.event===`prompt-delivered`&&a.agentId===n()||e===`system_note`&&t.event===`prompt-cancelled`&&a.agentId===n())&&Et(e=>e.filter(e=>e.promptId!==t.promptId)),r.has(e)&&!fp.has(e)||(Lt(a.agentId,a.event),a.event?.agent!==n()))return}if(document.visibilityState===`hidden`){Yn=!0;return}Jn||=setTimeout(i,120)}},Yn=!1;let i=async()=>{if(Jn=null,await sn(),await cn(),n()){let e=f().at(-1)?.id,t=m();if(await Rn(n()),f().at(-1)?.id!==e){let e=ft();e&&e.text?Ge({text:e.text.trim(),reasoning:``,at:e.at},f(),V()?.status)&&pt(null):e&&!e.text&&V()?.status!==`running`&&pt(null),et()?(Vn(!0),Nt(n())):st(rt()+Math.max(0,m()-t))}}};Xn=()=>{document.visibilityState===`visible`&&Yn&&(Yn=!1,i())}}let Qn=()=>decodeURIComponent(location.pathname.split(`/`)[2]??``);function $n(e,t=!0){let n=`/session/${encodeURIComponent(e)}`;t?history.pushState(null,``,n):history.replaceState(null,``,n)}window.addEventListener(`popstate`,()=>{let e=Qn(),t=o().get(e);t&&(t!==n()||e!==i())&&Wn(t,!1,e||null)}),b(()=>{let e=V(),t=e?`${St()?`▶ `:e.status===`error`?`⚠ `:``}${e.id} · teapot`:`teapot`;document.title=H()>0?`(${H()}) ${t}`:t}),window.addEventListener(`keydown`,e=>{let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)){e.key===`Escape`&&t.blur();return}if(e.key===`Escape`){if(k()){ie(!1);return}if(ae()){oe(!1);return}if(me()){he(!1);return}if(Ct()){wt(null);return}if(se()&&le()){pe();return}let e=V();if(e&&St()){$(`/api/agents/${e.id}/stop`,{method:`POST`}).then(sn);return}return}if(!(k()||ae())){if(e.key===`/`)e.preventDefault(),document.querySelector(`.composer textarea`)?.focus();else if(e.key===`d`)fe();else if(e.key===`t`)nr();else if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=bn().map(e=>e.a);if(t.length===0)return;e.preventDefault();let r=t.findIndex(e=>e.id===n()),i=e.key===`ArrowDown`?Math.min(r+1,t.length-1):Math.max(r-1,0);i!==r&&Wn(t[i].id)}}});let[er,tr]=v(localStorage.getItem(`teapot.term`)===`1`),nr=()=>{let e=!er();tr(e),localStorage.setItem(`teapot.term`,e?`1`:`0`)},[rr,ir]=v([]),[ar,or]=v(0),[sr,cr]=v(-1),[lr,ur]=v(!1),[dr,fr]=v(0),[pr,mr]=v(Number(localStorage.getItem(`teapot.termH`))||Math.max(220,Math.round(window.innerHeight*.35))),hr=new Map,gr=0,_r=[null,null],vr=()=>rr()[dr()===0?ar():sr()]??null;function yr(e){if(!rr()[e])return;let t=dr(),n=t===0?ar():sr(),r=t===0?sr():ar(),i=e=>t===0?or(e):cr(e),a=e=>t===0?cr(e):or(e);if(r===e){a(n),i(e);return}n!==e&&i(e)}let br=()=>xr();function xr(e){let t=e??n();if(!t)return;let r=rr().filter(e=>e.agentId===t).length;if(r>=10){Q(`max 10 shells per agent (${t}) — that's already a lot`);return}let i={key:`${t}#${++gr}`,agentId:t,title:r===0?t:`${t}·${r+1}`};ir(e=>[...e,i]);let a=rr().length;dr()===0?or(a):cr(a)}function Sr(e){let t=rr()[e];if(!t)return;let n=hr.get(t.key);if(n){n.ro?.disconnect();try{n.ws.close()}catch{}n.term.dispose(),hr.delete(t.key)}let r=rr().filter((t,n)=>n!==e);ir(r);let i=t=>t===e?-1:t>e?t-1:t;or(e=>Math.min(i(e),r.length-1)),cr(e=>e===-1?-1:Math.min(i(e),r.length-1))}function Cr(){for(let[,e]of hr){e.ro?.disconnect();try{e.ws.close()}catch{}e.term.dispose()}hr.clear()}function wr(e,t){let n=hr.get(e.key);if(n)n.el.parentElement!==t&&(t.appendChild(n.el),setTimeout(()=>{try{n.fit()}catch{}},30));else{let r=document.createElement(`div`);r.className=`termsession`,t.appendChild(r);let i=new Yc({cursorBlink:!0,fontSize:12.5,fontFamily:`ui-monospace, Menlo, Consolas, monospace`,theme:lp()}),a=new Qc;i.loadAddon(a),i.open(r);let o=location.protocol===`https:`?`wss://`:`ws://`,s=new WebSocket(`${o}${location.host}/api/agents/${e.agentId}/term${hp()}`);s.onmessage=e=>{let t=JSON.parse(e.data);t.kind===`data`?i.write(t.data):t.kind===`exit`&&i.write(`\r\n\x1b[2m[terminal exited ${t.code??``}]\x1b[0m\r\n`)},i.onData(e=>{s.readyState===WebSocket.OPEN&&s.send(JSON.stringify({kind:`input`,data:e}))});let c={cols:0,rows:0},l=[],u=()=>{try{a.fit()}catch{}(i.cols!==c.cols||i.rows!==c.rows)&&s.readyState===WebSocket.OPEN&&(c={cols:i.cols,rows:i.rows},s.send(JSON.stringify({kind:`resize`,cols:i.cols,rows:i.rows})))},d=new ResizeObserver(()=>{l[0]&&clearTimeout(l[0]),l[0]=setTimeout(u,250)});d.observe(r),setTimeout(u,60),n={el:r,term:i,fit:a,ws:s,ro:d},hr.set(e.key,n)}return n}function Tr(e){let t=_r[e];if(!t)return;let n=rr()[e===0?ar():sr()];if(!n){[...hr.values()].some(e=>e.el.parentElement===t)&&t.replaceChildren();return}let r=wr(n,t);for(let[e,r]of hr)e!==n.key&&r.el.parentElement===t&&r.el.remove();requestAnimationFrame(()=>{r.el.parentElement!==t&&t.appendChild(r.el);try{r.fit()}catch{}if(dr()===(e===0?0:1))try{r.term.focus()}catch{}})}b(()=>{rr(),lr(),ar(),sr(),pr(),requestAnimationFrame(()=>{Tr(0),lr()&&Tr(1)})});let Er=null;b(()=>{if(!er())return;let e=n();if(e&&e!==Er){if(Er=e,!rr().some(t=>t.agentId===e))xr(e);else{let t=-1;rr().forEach((n,r)=>{n.agentId===e&&(t=r)}),t>=0&&yr(t)}}});let Dr=e=>{e.preventDefault();let t=e.clientY,n=pr(),r=e=>{let r=Math.min(Math.max(n-(e.clientY-t),140),Math.round(window.innerHeight*.85));mr(r)},i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),localStorage.setItem(`teapot.termH`,String(pr())),requestAnimationFrame(()=>{Tr(0),lr()&&Tr(1)})};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Or=()=>{let e=!lr();if(ur(e),e){let e=rr().map((e,t)=>t).filter(e=>e!==ar());(sr()<0||sr()===ar()||sr()>=rr().length)&&cr(e[0]??-1)}requestAnimationFrame(()=>{Tr(0),lr()&&Tr(1)})};w(Cr);let kr=e=>t=>{_r[e]=t,t&&requestAnimationFrame(()=>{Tr(e),lr()&&Tr(1),setTimeout(()=>Tr(e),200)})};C(()=>{Jt(),sn().then(async()=>{await d();let t=Qn(),n=t?o().get(t):void 0,r=(n?e().find(e=>e.id===n):void 0)??e().find(e=>e.id===t&&!o().has(t))??e().find(e=>e.id===localStorage.getItem(`teapot.session`))??e()[0];r&&Wn(r.id,!1,t||null)}),cn(),dn(),Nr(),Zn();let t=setInterval(()=>{cn(),dn()},3e4);w(()=>clearInterval(t))});let Ar=[{cmd:`/start`,desc:`start working toward the goal`},{cmd:`/stop`,desc:`interrupt the running agent`},{cmd:`/fork`,desc:`branch the conversation here`},{cmd:`/goal`,desc:`/goal <text> — set goal & notify the agent`},{cmd:`/compact`,desc:`force a context compaction now`},{cmd:`/skill`,desc:`/skill <name> — force-load a skill and follow it`}],[jr,Mr]=v([]),Nr=()=>$(`/api/personas`).then(e=>Mr(e.personas)).catch(()=>{}),[Pr,Fr]=v(!1),Ir=()=>{let e=ne().match(/^@([A-Za-z0-9._-]*)$/);return e?e[1].toLowerCase():null},Lr=()=>{let t=Ir();return t===null?[]:[...jr().map(e=>({key:e.key,label:`${e.label} — spawns a sub-agent`,kind:`persona`})),...e().filter(e=>e.id!==n()).map(e=>({key:e.id,label:`${e.status} — send directly`,kind:`agent`}))].filter(e=>e.key.toLowerCase().startsWith(t))},Rr=new Set([`start`,`stop`,`fork`,`compact`]),[zr,Br]=v([]),[Vr,Hr]=v(-1),Ur=()=>{let e=ne();if(!e.startsWith(`/`)||e.includes(`
23
23
  `))return[];let t=e.match(/^\/([a-z]*)(?:\s+(.*))?$/i);if(!t)return[];let n=t[1].toLowerCase(),r=(t[2]??``).trim();if(!r&&n!==`skill`){let e=Ar.filter(e=>e.cmd.slice(1).startsWith(n));return e.find(e=>e.cmd.slice(1)===n)&&Rr.has(n)?[]:e.map(e=>({insert:e.cmd+` `,title:e.desc}))}if(n===`skill`){let e=zr().filter(e=>e.name.toLowerCase().startsWith(r.toLowerCase()));return e.length===1&&e[0].name.toLowerCase()===r.toLowerCase()?[]:e.map(e=>({insert:`/skill ${e.name} `,title:e.description||`(bundled skill)`}))}return[]},Wr,Gr=()=>{if(!Wr)return;Kr=!0;let e=et();Wr.style.height=`auto`,Wr.style.height=Qe()?``:`${Math.min(Wr.scrollHeight,360)}px`,requestAnimationFrame(()=>{let t=zn();e&&t&&(t.scrollTop=t.scrollHeight),Kr=!1})},Kr=!1,qr=!1,Jr;b(()=>{ne(),Gr()});let[Yr,Xr]=v([]),Zr=e=>{let t=Array.from(e).filter(e=>e.type.startsWith(`image/`));for(let e of t){if(e.size>8e6){Q(`"${e.name}" is over 8 MB — skipped`);continue}let t=new FileReader;t.onload=()=>{Xr(n=>[...n,{url:String(t.result),name:e.name}].slice(0,4))},t.readAsDataURL(e)}},Qr=async(e,t)=>{let r=t??n();if(!r)return;let i=Yr();try{let t=await $(`/api/agents/${r}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e,start:!0,...i.length?{images:i}:{}})});Et(n=>[...n,{id:`@p${Date.now()}${Math.random().toString(36).slice(2,6)}`,text:e,at:Date.now(),promptId:t.promptId,...i.length?{images:i.map(e=>e.url)}:{}}]),Xr([]),requestAnimationFrame(()=>requestAnimationFrame(()=>Vn(!0)))}catch(t){D(e),console.error(`send failed:`,t)}},$r=async t=>{t.preventDefault();let r=n(),i=ne().trim();if(!(!r||!i)){if(i.startsWith(`@`)){let t=i.indexOf(` `),r=(t===-1?i.slice(1):i.slice(1,t)).toLowerCase(),a=t===-1?``:i.slice(t+1).trim(),o=jr().some(e=>e.key.toLowerCase()===r),s=e().some(e=>e.id.toLowerCase()===r);try{if(o){if(!a){Q(`usage: @${r} <task>`);return}Q(`🧩 spawned ${(await $(`/api/agents/${n()}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({persona:r,task:a,context:Pr()?`fork`:`none`})})).id}${Pr()?` (forked context)`:``}`),sn(),D(``)}else if(s){if(!a){Q(`usage: @${r} <message>`);return}await $(`/api/agents/${encodeURIComponent(r)}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:a,start:!0})}),Q(`→ delivered to @${r}`),D(``)}else{Q(`unknown @${r} — personas: ${jr().map(e=>e.key).join(`, `)||`(none)`}`);return}}catch(e){Q(`@${r} failed: ${e.message}`)}return}if(i.startsWith(`/`)){let e=i.indexOf(` `),t=(e===-1?i.slice(1):i.slice(1,e)).toLowerCase(),n=e===-1?``:i.slice(e+1).trim();if(t===`goal`&&!n){D(`/goal `);return}if(t===`skill`&&!n){D(`/skill `);return}D(``);try{await ei(t,n)}catch(e){throw D(ne()?`${i}\n${ne()}`:i),e}return}D(``),await Qr(i),Qe()&&$e(!1)}},ei=async(e,t)=>{let r=n();if(!r)return;let i=(e,t)=>$(`/api/agents/${r}${e}`,{method:`POST`,headers:{"content-type":`application/json`},...t===void 0?{}:{body:JSON.stringify(t)}}).then(sn);try{if(e===`start`)await i(`/start`);else if(e===`stop`)await i(`/stop`);else if(e===`fork`)await i(`/fork`,{}),await Wn(r);else if(e===`compact`)Q((await i(`/compact`))?.ran?`context compacted`:`nothing to compact yet`);else if(e===`goal`){if(!t){Q(`usage: /goal <text>`);return}await i(`/goal`,{text:t,notify:!0}),Q(`goal saved & notification queued`)}else if(e===`skill`){if(!t){Q(`usage: /skill <name>`);return}await Qr(`[harness] Force-load and follow the skill "${t}" now: call load_skill("${t}") and execute its playbook for the current task.`),Q(`skill "${t}" dispatched`)}else Q(`unknown command "${e}" — /start /stop /fork /goal /skill /compact`)}catch(t){Q(`/${e} failed: ${t.message}`)}},ti,ni=0;b(()=>{e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!ti)return;let e=Math.min(ni,ti.scrollHeight);Math.abs(ti.scrollTop-e)>1&&(ti.scrollTop=e)})})});let ri=e=>()=>n()&&$(`/api/agents/${n()}${e}`,{method:`POST`}).then(sn),[ii,ai]=v(``),[oi,si]=v(``),[ci,li]=v(!1),[ui,q]=v(!0),di=``;b(()=>{let e=n();e&&(V()?.goal,e!==di&&(di=e,li(!1),ai(``),si(``)))});let fi=async e=>{if(e.preventDefault(),!(!n()||!ii().trim()))try{await $(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:ii(),notify:ui(),...oi().trim()?{verify:oi()}:{}})}),ai(``),si(``),li(!1),sn()}catch(e){Q(`goal save failed: ${e.message}`)}};return[j(N,{get when(){return O()?.needsSetup},fallback:null,get children(){return j(Kp,{onDone:()=>location.reload()})}}),j(N,{get when(){return Yt()},get children(){var e=rl();return e.firstChild.firstChild.nextSibling.addEventListener(`submit`,e=>{e.preventDefault();let t=document.getElementById(`pw-input`);localStorage.setItem(`teapot.token`,t.value),location.reload()}),e}}),j(N,{get when(){return!O()?.needsSetup},get children(){var i=jl(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild,l=c.firstChild;l.firstChild;var u=c.nextSibling,m=u.firstChild.firstChild.nextSibling;m.firstChild;var _=m.nextSibling,v=u.nextSibling,S=a.nextSibling,C=S.nextSibling,w=C.firstChild;w.firstChild,R(o,j(M,{get each(){return Cn()},children:t=>[j(N,{get when(){return P(()=>t.wsHeader!==void 0)()&&t.wsHeader!==``},get children(){var e=Ll(),n=e.firstChild;return e.$$click=()=>U(`ws:${t.wsHeader}`,xn(t.wsHeader),t.wsCollapsedGroup===!0,t.collapsedVia),R(n,()=>t.wsCollapsedGroup?`▸`:`▾`),R(e,()=>xn(t.wsHeader),null),R(e,j(N,{get when(){return(W().get(t.wsHeader)??0)>1||t.wsCollapsedGroup},get children(){var e=Il();return R(e,()=>W().get(t.wsHeader)??0),e}}),null),y(()=>I(e,`title`,t.wsCollapsedGroup?`${t.wsHeader} — collapsed (${Sn(t.wsHeader)} hidden). Click to show.`:(W().get(t.wsHeader)??0)>1?`${t.wsHeader} — ${Sn(t.wsHeader)} in this directory`:t.wsHeader||``)),e}}),j(N,{get when(){return P(()=>!t.headerOnly)()&&!t.wsCollapsedGroup},get children(){var r=Hl(),i=r.firstChild,a=i.nextSibling;return r.$$click=()=>{t.chatCollapsedGroup&&U(`chat:${t.a.id}`,t.a.id,!0),Wn(t.a.id)},R(r,j(N,{get when(){return!t.a.parent||e().some(e=>e.parent===t.a.id)},get fallback(){return Ul()},get children(){return(()=>{let e=!t.a.parent,n=e?yn().has(`chat:${t.a.id}`):pn().has(t.a.id);return(()=>{var r=Wl();return r.$$click=r=>{r.stopPropagation(),e?U(`chat:${t.a.id}`,t.a.id,n):hn(t.a.id)},R(r,n?`▸`:`▾`),y(()=>I(r,`title`,e?n?`show ${t.a.id}`:`hide ${t.a.id} and its sub-agents`:n?`expand sub-agents`:`collapse sub-agents`)),r})()})()}}),i),R(a,()=>t.a.id),R(r,(()=>{var e=P(()=>!!t.a.workspaceMissing);return()=>e()?Gl():null})(),null),R(r,j(N,{get when(){return Pt(t.a.id)>0},get children(){var e=Rl();return e.firstChild,R(e,()=>Pt(t.a.id),null),y(()=>I(e,`title`,`${Pt(t.a.id)} unread notification${Pt(t.a.id)>1?`s`:``} (including sub-agents)`)),e}}),null),R(r,j(N,{get when(){return pn().has(t.a.id)},get children(){return(()=>{let n=e().filter(e=>e.parent===t.a.id),r=n.filter(e=>e.live??(e.status===`running`||e.status===`waiting`)).length;return n.length>0?(()=>{var e=Kl();return e.firstChild,L(e,`subcount`+(r>0?` live`:``)),R(e,()=>n.length,null),R(e,r>0?` · ▶${r}`:``,null),y(()=>I(e,`title`,`${n.length} sub-agent${n.length>1?`s`:``} (${r} active)`)),e})():null})()}}),null),R(r,j(N,{get when(){return t.a.parent},get children(){return zl()}}),null),R(r,j(N,{get when(){return fn(t.a.id).length>0},get children(){var e=Bl();return y(()=>I(e,`title`,fn(t.a.id).map(e=>`${e.id}: ${e.schedule}`).join(`
24
- `))),e}}),null),R(r,j(N,{get when(){return t.a.goal.status===`done`},get children(){return Vl()}}),null),y(e=>{var o=`agent-item`+(t.a.id===n()?` sel`:``)+(t.depth>0?` sub-row`:``)+(t.chatCollapsedGroup?` collapsed`:``),s=t.depth>0?`padding-left:${10+t.depth*14}px`:``,c=t.a.parent?`sub-agent of @${t.a.parent}`:void 0,l=`dot ${t.a.status}`,u=t.a.workspaceMissing?` ghost`:``,d=t.a.workspaceMissing?`workspace not found on disk (${t.a.workspace}) — it will be created when this session runs`:void 0;return o!==e.e&&L(r,e.e=o),e.t=Ee(r,s,e.t),c!==e.a&&I(r,`title`,e.a=c),l!==e.o&&L(i,e.o=l),u!==e.i&&L(a,e.i=u),d!==e.n&&I(a,`title`,e.n=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r}})]})),R(s,j(N,{get when(){return me()},get children(){var e=al(),t=e.firstChild.firstChild;return t.addEventListener(`change`,e=>{let t=e.currentTarget.checked;ye(t),localStorage.setItem(`teapot.theme.auto`,t?`1`:`0`)}),R(e,j(N,{get when(){return!ve()},get fallback(){return[(()=>{var e=ql(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>{xe(e.currentTarget.value),localStorage.setItem(`teapot.theme.light`,e.currentTarget.value)}),R(t,j(M,{get each(){return cp.filter(e=>e.mode===`light`)},children:e=>(()=>{var t=Yl();return R(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>t.value=be()),e})(),(()=>{var e=Jl(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>{Ce(e.currentTarget.value),localStorage.setItem(`teapot.theme.dark`,e.currentTarget.value)}),R(t,j(M,{get each(){return cp.filter(e=>e.mode===`dark`)},children:e=>(()=>{var t=Yl();return R(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>t.value=Se()),e})()]},get children(){var e=il();return R(e,j(M,{each:cp,children:e=>(()=>{var t=Xl(),n=t.firstChild;return t.$$click=()=>{_e(e.key),localStorage.setItem(`teapot.theme`,e.key)},R(n,()=>e.sw.map(e=>(()=>{var t=Zl();return De(t,`background`,e),t})())),R(t,()=>e.label,null),y(n=>{var r=`themebtn`+(ge()===e.key?` on`:``),i=`${e.label} (${e.mode})`;return r!==n.e&&L(t,n.e=r),i!==n.t&&I(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()})),e}}),null),y(()=>t.checked=ve()),e}}),c),l.$$click=e=>{e.stopPropagation(),Mt(!jt()),jt()||Ot(e=>e.map(e=>({...e,read:!0})))},R(l,j(N,{get when(){return H()>0},get children(){var e=ol();return R(e,H),e}}),null),R(c,j(kp,{icon:`👻`,get active(){return kt()},get title(){return kt()?`show ghost sessions again (👻 workspace missing on disk)`:`hide ghost sessions (👻 — their workspace directory no longer exists)`},onClick:t=>{t.stopPropagation();let r=!kt();if(At(r),localStorage.setItem(`teapot.hideGhosts`,r?`1`:`0`),r&&n()&&V()?.workspaceMissing){let t=e().find(e=>!e.workspaceMissing);t&&Wn(t.id)}}}),null),R(c,j(kp,{icon:`+`,title:`new agent`,onClick:()=>{Jt(),ie(!0)}}),null),R(c,j(kp,{icon:`🎨`,title:`themes`,onClick:()=>he(!me())}),null),R(c,j(kp,{icon:`⚙`,title:`settings`,onClick:()=>{Jt(),oe(!0)}}),null),R(m,`0.25.1`,null),R(v,j(N,{get when(){return ee()},get children(){return[`master rss `,P(()=>ee().rssMb),`MB · heap `,P(()=>ee().heapUsedMb),`MB`,sl(),`load1 `,P(()=>ee().loadavg1),` · up `,P(()=>Math.floor(ee().uptimeSec/60)),`m`]}})),R(S,j(N,{get when(){return V()?.id},keyed:!0,get fallback(){return Ql()},get children(){return[(()=>{var e=dl(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling;return R(t,()=>V().id),R(n,()=>V().status),R(e,j(N,{get when(){return(V().pendingPrompts??0)>0},get children(){var e=cl(),t=e.firstChild.nextSibling;return t.nextSibling,R(e,()=>V().pendingPrompts,t),R(e,()=>V().status===`stopped`?` (stopped)`:``,null),y(()=>I(e,`title`,V().status===`stopped`?`${V().pendingPrompts} message${(V().pendingPrompts??0)>1?`s`:``} from you are still queued, but this agent is STOPPED — nothing will run until you press start (or it is resumed). Each can be withdrawn with ✕ cancel while it is still queued.`:`${V().pendingPrompts??0} message${(V().pendingPrompts??0)>1?`s`:``} from you waiting in the queue. They will be handed to the model at its next turn boundary — the timeline shows them as "pending (queued)…" until then, and each can be withdrawn with ✕ cancel while it's still queued.`)),e}}),r),R(e,j(N,{get when(){return fn(V().id).length>0},get children(){var e=ll();return e.firstChild,R(e,()=>fn(V().id).length,null),y(()=>I(e,`title`,`scheduled tasks:\n${fn(V().id).map(e=>`${e.schedule} · ${e.id}${e.forked?` (forked)`:``}`).join(`
24
+ `))),e}}),null),R(r,j(N,{get when(){return t.a.goal.status===`done`},get children(){return Vl()}}),null),y(e=>{var o=`agent-item`+(t.a.id===n()?` sel`:``)+(t.depth>0?` sub-row`:``)+(t.chatCollapsedGroup?` collapsed`:``),s=t.depth>0?`padding-left:${10+t.depth*14}px`:``,c=t.a.parent?`sub-agent of @${t.a.parent}`:void 0,l=`dot ${t.a.status}`,u=t.a.workspaceMissing?` ghost`:``,d=t.a.workspaceMissing?`workspace not found on disk (${t.a.workspace}) — it will be created when this session runs`:void 0;return o!==e.e&&L(r,e.e=o),e.t=Ee(r,s,e.t),c!==e.a&&I(r,`title`,e.a=c),l!==e.o&&L(i,e.o=l),u!==e.i&&L(a,e.i=u),d!==e.n&&I(a,`title`,e.n=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r}})]})),R(s,j(N,{get when(){return me()},get children(){var e=al(),t=e.firstChild.firstChild;return t.addEventListener(`change`,e=>{let t=e.currentTarget.checked;ye(t),localStorage.setItem(`teapot.theme.auto`,t?`1`:`0`)}),R(e,j(N,{get when(){return!ve()},get fallback(){return[(()=>{var e=ql(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>{xe(e.currentTarget.value),localStorage.setItem(`teapot.theme.light`,e.currentTarget.value)}),R(t,j(M,{get each(){return cp.filter(e=>e.mode===`light`)},children:e=>(()=>{var t=Yl();return R(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>t.value=be()),e})(),(()=>{var e=Jl(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>{Ce(e.currentTarget.value),localStorage.setItem(`teapot.theme.dark`,e.currentTarget.value)}),R(t,j(M,{get each(){return cp.filter(e=>e.mode===`dark`)},children:e=>(()=>{var t=Yl();return R(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>t.value=Se()),e})()]},get children(){var e=il();return R(e,j(M,{each:cp,children:e=>(()=>{var t=Xl(),n=t.firstChild;return t.$$click=()=>{_e(e.key),localStorage.setItem(`teapot.theme`,e.key)},R(n,()=>e.sw.map(e=>(()=>{var t=Zl();return De(t,`background`,e),t})())),R(t,()=>e.label,null),y(n=>{var r=`themebtn`+(ge()===e.key?` on`:``),i=`${e.label} (${e.mode})`;return r!==n.e&&L(t,n.e=r),i!==n.t&&I(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()})),e}}),null),y(()=>t.checked=ve()),e}}),c),l.$$click=e=>{e.stopPropagation(),Mt(!jt()),jt()||Ot(e=>e.map(e=>({...e,read:!0})))},R(l,j(N,{get when(){return H()>0},get children(){var e=ol();return R(e,H),e}}),null),R(c,j(kp,{icon:`👻`,get active(){return kt()},get title(){return kt()?`show ghost sessions again (👻 workspace missing on disk)`:`hide ghost sessions (👻 — their workspace directory no longer exists)`},onClick:t=>{t.stopPropagation();let r=!kt();if(At(r),localStorage.setItem(`teapot.hideGhosts`,r?`1`:`0`),r&&n()&&V()?.workspaceMissing){let t=e().find(e=>!e.workspaceMissing);t&&Wn(t.id)}}}),null),R(c,j(kp,{icon:`+`,title:`new agent`,onClick:()=>{Jt(),ie(!0)}}),null),R(c,j(kp,{icon:`🎨`,title:`themes`,onClick:()=>he(!me())}),null),R(c,j(kp,{icon:`⚙`,title:`settings`,onClick:()=>{Jt(),oe(!0)}}),null),R(m,`0.25.2`,null),R(v,j(N,{get when(){return ee()},get children(){return[`master rss `,P(()=>ee().rssMb),`MB · heap `,P(()=>ee().heapUsedMb),`MB`,sl(),`load1 `,P(()=>ee().loadavg1),` · up `,P(()=>Math.floor(ee().uptimeSec/60)),`m`]}})),R(S,j(N,{get when(){return V()?.id},keyed:!0,get fallback(){return Ql()},get children(){return[(()=>{var e=dl(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling;return R(t,()=>V().id),R(n,()=>V().status),R(e,j(N,{get when(){return(V().pendingPrompts??0)>0},get children(){var e=cl(),t=e.firstChild.nextSibling;return t.nextSibling,R(e,()=>V().pendingPrompts,t),R(e,()=>V().status===`stopped`?` (stopped)`:``,null),y(()=>I(e,`title`,V().status===`stopped`?`${V().pendingPrompts} message${(V().pendingPrompts??0)>1?`s`:``} from you are still queued, but this agent is STOPPED — nothing will run until you press start (or it is resumed). Each can be withdrawn with ✕ cancel while it is still queued.`:`${V().pendingPrompts??0} message${(V().pendingPrompts??0)>1?`s`:``} from you waiting in the queue. They will be handed to the model at its next turn boundary — the timeline shows them as "pending (queued)…" until then, and each can be withdrawn with ✕ cancel while it's still queued.`)),e}}),r),R(e,j(N,{get when(){return fn(V().id).length>0},get children(){var e=ll();return e.firstChild,R(e,()=>fn(V().id).length,null),y(()=>I(e,`title`,`scheduled tasks:\n${fn(V().id).map(e=>`${e.schedule} · ${e.id}${e.forked?` (forked)`:``}`).join(`
25
25
  `)}`)),e}}),r),R(r,()=>V().model,i),R(r,()=>V().session,a),R(r,()=>V().branch,o),R(r,()=>V().stats.turns,s),R(r,()=>V().stats.toolCalls,null),R(c,j(N,{get when(){return V().statusReason},get children(){var e=ul();return y(()=>I(e,`title`,V().statusReason)),e}}),null),R(c,j(kp,{icon:`⌨`,title:`terminal (t)`,onClick:nr}),null),R(c,j(kp,{icon:`▤`,title:`toggle details panel (d)`,onClick:fe}),null),y(()=>L(n,`badge ${V().status}`)),e})(),(()=>{var e=vl();return e.addEventListener(`scroll`,e=>{if(Kr)return;let t=e.currentTarget,r=K(),i=t.scrollHeight-t.scrollTop-t.clientHeight;if(!r&&Jr!==void 0&&i>Jr+8&&i>24?qr=!0:r&&(qr=!1),Jr=i,t.scrollTop<=4&&n()&&!kn()&&!jn()&&f().length>0&&Ln(),qr&&!r){tt(!1);return}r&&rt()&&st(0),tt(r)}),R(e,j(N,{get when(){return ct()},children:e=>(()=>{var t=$l();return t.firstChild,R(t,(()=>{var t=P(()=>e().phase===`harvesting`);return()=>t()?`saving durable lessons…`:`summarizing ${e().summarized?Ep(e().summarized)+` `:``}older messages…`})(),null),t})()}),null),R(e,j(N,{get when(){return P(()=>!!jn())()&&Gt().length>0},get children(){return fl()}}),null),R(e,j(N,{get when(){return kn()},get children(){return pl()}}),null),R(e,j(N,{get when(){return Gt().length>0},get fallback(){return eu()},get children(){return[j(M,{get each(){return Gt()},children:(e,t)=>j(xp,{e,get prev(){return Gt()[t()-1]},get res(){return zt().resFor.get(e.id)},get orphan(){return zt().orphanCalls.has(e.id)},onOption:e=>void Qr(e),answeredIds:Wt,onAnswered:Ht,get agentActive(){return P(()=>!!St())()&&Ke(e)},onResize:()=>{et()&&requestAnimationFrame(()=>Vn(!0))},get onCancel(){return e.data?.pending&&e.data?.promptId&&e.data?.sent!==!0?()=>{let t=String(e.data.promptId);$(`/api/agents/${n()}/prompt/cancel`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({promptId:t})}).then(e=>{let n=String(e.text??``);D(ne()?`${n}\n\n${ne()}`:n),Et(e=>e.filter(e=>e.promptId!==t)),Q(`message withdrawn — draft restored`)}).catch(()=>Q(`withdraw failed — it may have already been sent`))}:void 0},get onEdit(){return e.type===`prompt`&&e.data?.source===`user`&&!(e.data?.pending&&e.data?.sent!==!0)&&!e.data?.cancelled?()=>wt({eventId:e.id,text:String(e.data?.text??``)}):void 0}})}),j(N,{get when(){return ft()},get children(){var e=_l(),t=e.firstChild.nextSibling;return t.firstChild,R(t,j(N,{get when(){return yt()},get children(){var e=ml(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return R(t,j(vp,{get startedAt(){return vt()}}),null),Oe(e=>{let t=!0;e.addEventListener(`scroll`,()=>{t=e.scrollHeight-e.scrollTop-e.clientHeight<24}),b(()=>{yt(),t&&(e.scrollTop=e.scrollHeight)})},n),R(n,yt),e}}),null),R(t,j(N,{get when(){return mt()},get fallback(){return tu()},get children(){return j(N,{get when(){return z()},get fallback(){return(()=>{var e=gl();return y(()=>e.innerHTML=Ie(mt()+`▍`)),e})()},get children(){return[hl(),(()=>{var e=gl();return y(()=>e.innerHTML=Ie(B()+`▍`)),e})()]}})}}),null),e}})]}}),null),e})(),j(N,{get when(){return er()},get children(){var t=Cl(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=r.nextSibling,c=s.firstChild;n.$$dblclick=()=>{mr(Math.max(220,Math.round(window.innerHeight*.35))),localStorage.setItem(`teapot.termH`,String(pr()))},n.$$pointerdown=Dr,R(i,j(M,{get each(){return rr()},children:(e,t)=>(()=>{var n=nu(),r=n.firstChild.nextSibling;return n.$$click=()=>yr(t()),R(n,()=>e.title,r),r.$$click=e=>{e.stopPropagation(),Sr(t())},y(r=>{var i=`termtab`+(dr()===0&&ar()===t()?` active`:``)+(lr()&&dr()===1&&sr()===t()?` active`:``),a=`${e.title} — click to show in focused pane`;return i!==r.e&&L(n,r.e=i),a!==r.t&&I(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()}),null),R(i,j(kp,{icon:`+`,title:`new shell in this workspace`,onClick:br}),null),R(o,(()=>{var t=P(()=>!!vr());return()=>t()?e().find(e=>e.id===vr().agentId)?.workspace.split(`/`).filter(Boolean).pop():V()?.workspace})()),R(a,j(kp,{icon:`◫`,get title(){return lr()?`single pane`:`split panes (50/50)`},onClick:Or}),null),R(a,j(kp,{icon:`▾`,title:`hide the terminal (shells keep running; reopen with t) — close individual shells with their ✕ tab buttons`,onClick:nr}),null);var l=kr(0);return typeof l==`function`&&Oe(l,c),c.$$pointerdown=()=>fr(0),R(c,j(N,{get when(){return ar()<0||ar()>=rr().length},get children(){return yl()}})),R(s,j(N,{get when(){return lr()},get children(){return[bl(),(()=>{var e=Sl(),t=kr(1);return typeof t==`function`&&Oe(t,e),e.$$pointerdown=()=>fr(1),R(e,j(N,{get when(){return sr()<0||sr()>=rr().length},get children(){return xl()}})),y(()=>e.classList.toggle(`focused`,dr()===1)),e})()]}}),null),y(e=>{var n={height:`${pr()}px`,"--termh":`${pr()}px`},r=!!lr(),i=dr()===0;return e.e=Ee(t,n,e.e),r!==e.t&&s.classList.toggle(`split`,e.t=r),i!==e.a&&c.classList.toggle(`focused`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),t}}),(()=>{var e=kl(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,o=t.nextSibling;R(e,j(N,{get when(){return!et()||rt()>0},get children(){var e=wl();return e.firstChild,e.$$click=()=>Vn(!0),R(e,(()=>{var e=P(()=>rt()>0);return()=>e()?`${rt()} new message${rt()>1?`s`:``}`:`jump to present`})(),null),e}}),t),R(e,j(N,{get when(){return Ur().length>0},get children(){var e=Tl();return R(e,j(M,{get each(){return Ur()},children:(e,t)=>(()=>{var n=ru(),r=n.firstChild,i=r.nextSibling;return n.$$click=()=>{D(e.insert),Hr(-1)},R(r,()=>e.insert.trim()),R(i,()=>e.title),y(r=>{var i=`cmdrow`+(t()===Vr()?` active`:``),a=e.title;return i!==r.e&&L(n,r.e=i),a!==r.t&&I(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()})),e}}),t),R(e,j(N,{get when(){return Lr().length>0},get children(){var e=Tl();return R(e,j(M,{get each(){return Lr()},children:e=>(()=>{var t=iu(),n=t.firstChild;n.firstChild;var r=n.nextSibling;return t.$$click=()=>{D(`@${e.key} `),Hr(-1)},R(n,()=>e.key,null),R(r,()=>e.label),y(()=>I(t,`title`,e.label)),t})()})),e}}),t),t.addEventListener(`submit`,$r),R(t,j(N,{get when(){return Yr().length>0},get children(){var e=El(),t=e.firstChild,n=t.firstChild,r=n.nextSibling;return r.nextSibling,R(e,j(M,{get each(){return Yr()},children:(e,t)=>(()=>{var n=au(),r=n.firstChild,i=r.nextSibling;return i.$$click=()=>Xr(e=>e.filter((e,n)=>n!==t())),y(t=>{var i=e.name,a=e.url,o=e.name;return i!==t.e&&I(n,`title`,t.e=i),a!==t.t&&I(r,`src`,t.t=a),o!==t.a&&I(r,`alt`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}),t),R(t,()=>Yr().length,n),R(t,()=>Yr().length>1?`s`:``,r),e}}),n),n.$$keydown=e=>{let t=Ur();if(t.length>0&&e.key===`ArrowDown`){e.preventDefault(),Hr(e=>Math.min(e+1,t.length-1));return}if(t.length>0&&e.key===`ArrowUp`){e.preventDefault(),Hr(e=>Math.max(e-1,0));return}if(t.length>0&&(e.key===`Tab`||e.key===`Enter`)&&!e.shiftKey&&Vr()>=0&&!sp){e.preventDefault(),D(t[Vr()].insert),Hr(-1);return}if(e.key===`Escape`&&t.length>0){Hr(-1);return}e.key===`Enter`&&!e.shiftKey&&!sp&&(e.preventDefault(),$r(e))},n.$$input=e=>{D(e.currentTarget.value),Hr(0),Gr()},n.addEventListener(`paste`,e=>{let t=Array.from(e.clipboardData?.files??[]).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Zr(t))}),n.addEventListener(`compositionend`,()=>{requestAnimationFrame(()=>{sp=!1})}),n.addEventListener(`compositionstart`,()=>{sp=!0});var s=Wr;return typeof s==`function`?Oe(s,n):Wr=n,R(t,j(N,{get when(){return P(()=>!!ne().startsWith(`@`))()&&ne().includes(` `)},get children(){var e=Dl(),t=e.firstChild;return t.addEventListener(`change`,e=>Fr(e.currentTarget.checked)),y(()=>t.checked=Pr()),e}}),r),r.$$click=()=>{let e=!Qe();$e(e),requestAnimationFrame(()=>Gr())},R(r,()=>Qe()?`⤡`:`⤢`),R(t,j(kp,{icon:`📎`,title:`attach images (or paste them straight into the box)`,onClick:()=>document.getElementById(`composer-file`)?.click()}),i),R(t,j(N,{get when(){return Yr().length},get children(){var e=Ol();return e.firstChild,R(e,()=>Yr().length,null),e}}),i),a.addEventListener(`change`,e=>{e.currentTarget.files?.length&&Zr(e.currentTarget.files),e.currentTarget.value=``}),R(o,()=>ip()||`enter send · shift+enter newline · ↑↓ sessions · / commands & focus · t terminal · d panel · esc interrupt · messages sent while the agent works queue up and land at the next turn boundary`),y(t=>{var i=`composer`+(Qe()?` maximized`:``),a=`message #${V().id} — / for commands · paste or 📎 to attach images`,o=Qe()?`restore composer (hide timeline)`:`maximize composer — hide the timeline and fill the main column`;return i!==t.e&&L(e,t.e=i),a!==t.t&&I(n,`placeholder`,t.t=a),o!==t.a&&I(r,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),y(()=>n.value=ne()),e})()]}})),R(i,j(N,{get when(){return P(()=>!!ce())()&&le()},get children(){var e=Al();return e.$$click=()=>de(!1),e}}),C),C.addEventListener(`scroll`,e=>{ni=e.currentTarget.scrollTop});var te=ti;return typeof te==`function`?Oe(te,C):ti=C,R(w,j(kp,{icon:`✕`,title:`close details panel (esc)`,onClick:pe}),null),R(C,j(N,{get when(){return V()?.id},keyed:!0,fallback:null,children:i=>[ou(),(()=>{var e=su(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.nextSibling,i=t.nextSibling,a=i.firstChild.nextSibling,o=i.nextSibling.firstChild.nextSibling,s=o.firstChild;return R(n,()=>V().id),R(r,()=>V().status),R(a,()=>V().workspace),R(o,()=>V().session,s),R(o,()=>V().branch,null),y(e=>{var t=`badge ${V().status}`,n=V().workspace;return t!==e.e&&L(r,e.e=t),n!==e.t&&I(a,`title`,e.t=n),e},{e:void 0,t:void 0}),e})(),j(N,{get when(){return V().id},keyed:!0,fallback:null,children:e=>j(Hp,{agentId:e,get workspace(){return V().workspace}})}),cu(),(()=>{var e=du(),t=e.firstChild,r=t.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=r.nextSibling;return s.firstChild,t.addEventListener(`change`,e=>{je(e.currentTarget.value),Be(e.currentTarget.value)}),R(t,j(M,{get each(){return ze()},children:e=>(()=>{var t=Yl();return t.value=e,R(t,e,null),R(t,()=>e===O().defaultProvider?` ★`:``,null),t})()})),i.$$input=e=>Ne(e.currentTarget.value),R(a,j(M,{get each(){return Le()},children:e=>(()=>{var t=Yl();return y(()=>t.value=e.id),t})()})),o.$$click=async e=>{if(!n())return;let t=e.currentTarget;t.disabled=!0;try{await $(`/api/agents/${n()}/model`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:Ae(),model:Me().trim()||void 0,contextWindowTokens:Le().find(e=>e.id===(Me().trim()||void 0))?.contextLength})}),t.textContent=`✓ applied`,sn()}catch(e){alert(`model switch failed: ${e.message}`)}finally{setTimeout(()=>{t.textContent=`apply`,t.disabled=!1},1200)}},R(e,j(N,{get when(){return V().effortSupported},get children(){var e=lu(),t=e.firstChild.nextSibling;t.firstChild;var r=t.nextSibling;return t.addEventListener(`change`,e=>Fe(e.currentTarget.value)),R(t,j(M,{each:ep,children:e=>(()=>{var t=Yl();return t.value=e,R(t,e),t})()}),null),r.$$click=async e=>{if(!n())return;let t=e.currentTarget;t.disabled=!0;try{await $(`/api/agents/${n()}/model`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({reasoningEffort:Pe()})}),t.textContent=`✓ applied`,sn()}catch(e){alert(`effort change failed: ${e.message}`)}finally{setTimeout(()=>{t.textContent=`apply`,t.disabled=!1},1200)}},y(()=>t.value=Pe()),e}}),s),R(s,()=>V().model,null),R(s,j(N,{get when(){return Le().length},get children(){return[` · `,P(()=>Le().length),` models loaded`]}}),null),R(e,j(N,{get when(){return Ye()},get children(){var e=uu();return R(e,Ye),e}}),null),y(()=>I(i,`placeholder`,V().model)),y(()=>t.value=Ae()),y(()=>i.value=Me()),e})(),fu(),(()=>{var i=mu(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling;return Te(a,`click`,St()?ri(`/stop`):ri(`/start`),!0),R(a,()=>St()?`■ stop`:`▶ start`),o.$$click=()=>$(`/api/agents/${V().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(async()=>{await d(!0),await Wn(V().id)}),s.$$click=async()=>{let i=n();if(!i||!confirm(`remove agent ${i}? (log is kept)`))return;await $(`/api/agents/${i}`,{method:`DELETE`}).catch(()=>{});let a=e().filter(e=>e.id!==i);t(a),d(!0),a[0]?Wn(a[0].id):(r(null),p([]))},R(i,j(N,{get when(){return e().some(e=>e.parent===n())},get children(){var e=pu();return e.$$click=async()=>{n()&&(Q(`stopped: ${((await $(`/api/agents/${n()}/stop-children`,{method:`POST`})).stopped??[]).join(`, `)||`(none)`}`),sn())},e}}),null),y(e=>{var t=St()?`danger`:`runbtn`,n=St()?`interrupt: aborts the current LLM call; the running tool finishes first`:`run toward the goal (starts the loop)`;return t!==e.e&&L(a,e.e=t),n!==e.t&&I(a,`title`,e.t=n),e},{e:void 0,t:void 0}),i})(),(()=>{var e=hu(),t=e.firstChild.firstChild;return t.addEventListener(`change`,e=>{n()&&$(`/api/agents/${n()}/auto-continue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({value:e.currentTarget.checked})}).then(sn)}),y(()=>t.checked=V().autoContinue??!0),e})(),(()=>{var e=_u();return e.firstChild,R(e,j(N,{get when(){return!!V().goal.text.trim()},get fallback(){return Fu()},get children(){var e=gu();return R(e,()=>V().goal.status),y(()=>L(e,`badge ${V().goal.status===`active`?`running`:V().goal.status}`)),e}}),null),e})(),(()=>{var e=vu();return e.firstChild,R(e,j(M,{each:[`active`,`done`,`paused`],children:e=>(()=>{var t=Iu();return t.$$click=()=>{n()&&$(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:e})}).then(sn)},I(t,`title`,e===`active`?`agent keeps working toward the goal (with auto-continue)`:e===`done`?`mark achieved — auto-continue stops`:`parked on purpose — resume by setting active again`),R(t,e===`active`?`▶ working`:e===`done`?`✓ done`:`⏸ paused`),y(n=>{var r=`goalstate`+(V().goal.text.trim()&&V().goal.status===e?` on ${e}`:``),i=!!V().goal.text.trim()&&V().goal.status===e;return r!==n.e&&L(t,n.e=r),i!==n.t&&(t.disabled=n.t=i),n},{e:void 0,t:void 0}),t})()}),null),e})(),j(N,{get when(){return V().goal.text},get fallback(){return Lu()},get children(){return[(()=>{var e=yu(),t=e.firstChild;return y(()=>t.innerHTML=Ie(String(V().goal.text))),e})(),j(N,{get when(){return V().goal.verify},get children(){var e=bu(),t=e.firstChild.nextSibling;return y(()=>t.innerHTML=Ie(String(V().goal.verify))),e}}),j(N,{get when(){return V().goal.audit},children:e=>(()=>{var t=Ru(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return R(n,()=>e().verdict===`approved`?`✅ audit: approved`:`⚠ audit: changes required`,r),R(r,()=>Tp(e().at)),y(n=>{var r=`card auditcard `+(e().verdict===`approved`?`ok`:`warn`),a=Xe(e().feedback)?Ie(`_the auditor returned a verdict with no detail_`):Ie(e().feedback);return r!==n.e&&L(t,n.e=r),a!==n.t&&(i.innerHTML=n.t=a),n},{e:void 0,t:void 0}),t})()})]}}),xu(),(()=>{var e=Su(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.firstChild.firstChild;return e.addEventListener(`submit`,fi),t.$$input=e=>{ai(e.currentTarget.value),li(!0)},n.$$input=e=>{si(e.currentTarget.value),li(!0)},r.addEventListener(`change`,e=>q(e.currentTarget.checked)),y(()=>t.value=ii()),y(()=>n.value=oi()),y(()=>r.checked=ui()),e})(),(()=>{var e=wu(),t=e.firstChild.nextSibling;return R(e,j(N,{get when(){return on().total>0},get children(){var e=Cu(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,R(e,()=>on().done,t),R(e,()=>on().total,n),y(t=>Ee(e,on().done===on().total?`color:var(--ok)`:`color:var(--warn)`,t)),e}}),t),e})(),j(N,{get when(){return on().total>0},get children(){var e=Tu(),t=e.firstChild;return y(e=>{var n=`barfill `+(on().done===on().total?``:`warn`),r=`${Math.round(on().done/on().total*100)}%`;return n!==e.e&&L(t,e.e=n),r!==e.t&&De(t,`width`,e.t=r),e},{e:void 0,t:void 0}),e}}),j(Vp,{get draft(){return Zt()},get viewMode(){return $t()},onDraft:e=>{Qt(e),nn(!0)}}),(()=>{var e=Eu(),t=e.firstChild,n=t.nextSibling;return R(e,j(kp,{get icon(){return $t()?`👁`:`✎`},get title(){return $t()?`rendered checklist`:`edit markdown`},onClick:()=>en(!$t())}),t),n.$$click=an,e})(),Du(),j(N,{get when(){return V().latestProgress},get fallback(){return zu()},children:e=>(()=>{var t=Wu(),n=t.firstChild,r=n.firstChild.nextSibling,i=n.nextSibling;return R(t,j(N,{get when(){return e().recent},get children(){var t=Bu(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=$f(e().recent)),t}}),i),R(t,j(N,{get when(){return e().problems},get children(){var t=Vu(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=$f(e().problems)),t}}),i),R(t,j(N,{get when(){return e().next},get children(){var t=Hu(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=$f(e().next)),t}}),i),R(t,j(N,{get when(){return e().goalStatus},get children(){var t=Uu(),n=t.firstChild.nextSibling;return R(n,()=>e().goalStatus),t}}),i),R(i,()=>Tp(e().ts)),y(()=>r.innerHTML=$f(e().doing)),t})()}),Ou(),(()=>{var e=ju(),t=e.firstChild,r=t.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling,o=a.firstChild.nextSibling,s=a.nextSibling.firstChild.nextSibling,c=t.nextSibling,l=c.firstChild.nextSibling,u=l.firstChild,d=u.nextSibling;return d.nextSibling,R(i,()=>V().stats.turns),R(o,()=>V().stats.toolCalls),R(s,()=>V().stats.compactions??0),R(l,()=>Ep(V().stats.inputTokens),u),R(l,()=>Ep(V().stats.outputTokens),d),R(c,j(N,{get when(){return(V().stats.cachedInputTokens??0)>0},get children(){var e=ku(),t=e.firstChild.nextSibling;return t.nextSibling,R(e,()=>Math.round(V().stats.cachedInputTokens/Math.max(1,V().stats.inputTokens)*1e3)/10,t),y(()=>I(e,`title`,`${Ep(V().stats.cachedInputTokens)} tokens were served from the provider's prompt cache — billed far cheaper than fresh input`)),e}}),null),R(e,j(N,{get when(){return(V().stats.costUsd??0)>0},get children(){var e=Au(),t=e.firstChild.nextSibling;return t.firstChild,R(t,()=>Dp(V().stats.costUsd??0),null),y(()=>I(e,`title`,`≈ ${(V().stats.costUsd??0).toFixed(4)} this session, from the model's USD/token pricing and per-turn usage. Cached input is estimated at ~10% of the prompt rate; treat as an approximation, not an invoice.`)),e}}),null),R(e,j(N,{get when(){return V().ctx},keyed:!0,get fallback(){return Gu()},children:e=>{let t=x(()=>{let t=e,n=Le().find(e=>e.id===V().model),r=t.window||n?.contextLength||0,i=r?Math.min(999,t.usedTokens/r*100):0;return{usedTokens:t.usedTokens,compactAt:t.compactAt,compacting:t.compacting,window:t.window,effectiveWindow:r,pct:i,cls:r?i>=85?`crit`:i>=70?`warn`:`ok`:``,derivedBudget:r?Math.round(r*.75):0,usingDerived:t.compactAtIsManual!==!0}}),r=()=>t(),i=e=>{let t=Math.round(e*10)/10;return Number.isInteger(t)?String(t):t.toFixed(1)};return(()=>{var e=Xu(),t=e.firstChild,a=t.firstChild.nextSibling,o=a.firstChild.nextSibling;o.nextSibling;var s=t.nextSibling,c=s.firstChild.nextSibling,l=c.firstChild,u=c.nextSibling,d=s.nextSibling,f=d.firstChild.firstChild,p=d.nextSibling,m=p.firstChild.nextSibling;return m.nextSibling,R(a,()=>Ep(r().usedTokens),o),R(t,j(N,{get when(){return r().effectiveWindow},get children(){var e=Ku(),t=e.firstChild;return R(e,()=>i(r().pct),t),R(e,()=>Ep(r().effectiveWindow),null),y(()=>L(e,`pill ${r().cls}`)),e}}),null),R(e,j(N,{get when(){return r().effectiveWindow},get children(){var e=qu(),t=e.firstChild;return y(e=>{var n=`barfill ${r().cls}`,i=`${Math.min(100,r().pct)}%`;return n!==e.e&&L(t,e.e=n),i!==e.t&&De(t,`width`,e.t=i),e},{e:void 0,t:void 0}),e}}),s),R(c,()=>Ep(r().usingDerived?r().derivedBudget:r().compactAt),l),R(u,()=>r().usingDerived?` (75% of window)`:` (manual override)`),R(e,j(N,{get when(){return r().effectiveWindow},get children(){var e=Ju(),t=e.firstChild;return y(e=>{var n=`barfill ${r().cls}`,i=`${Math.min(100,Math.round(r().usedTokens/r().derivedBudget*100))}%`;return n!==e.e&&L(t,e.e=n),i!==e.t&&De(t,`width`,e.t=i),e},{e:void 0,t:void 0}),e}}),d),R(e,j(N,{get when(){return ct()||r().compacting},get children(){var e=Yu(),t=e.firstChild.nextSibling.nextSibling;return R(t,()=>ct()?.phase??String(r().compacting)),e}}),d),f.addEventListener(`change`,e=>{n()&&$(`/api/agents/${n()}/auto-compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({value:e.currentTarget.checked})}).then(sn)}),R(p,()=>Ep(r().compactAt),m),y(()=>f.checked=V().autoCompact!==!1),e})()}}),null),e})(),(()=>{var e=Nu();return e.firstChild.nextSibling,R(e,j(N,{get when(){return Tn()},get children(){var e=Mu(),t=e.firstChild.nextSibling;return R(t,Tn),e}}),null),e})(),j(M,{get each(){return g()},children:e=>(()=>{var t=Zu(),r=t.firstChild,i=r.nextSibling,a=i.firstChild;return t.$$click=()=>{let t=Tn()===e.branch?null:e.branch,r=t!==Tn();G(t),n()&&(r&&(Nn++,p([]),h(0),Mn(!1)),Rn(n()))},R(r,()=>e.branch,null),R(r,()=>e.branch===V().branch?` (current)`:``,null),R(i,()=>e.events,a),y(n=>{var r=`branch-row`+(e.branch===V().branch||e.branch===Tn()?` cur`:``),i=e.branch===Tn()?`click to show all branches again`:`show only ${e.branch}`;return r!==n.e&&L(t,n.e=r),i!==n.t&&I(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()}),Pu(),j(N,{get when(){return ln().length>0},get fallback(){return Qu()},get children(){return j(M,{get each(){return ln()},children:e=>(()=>{var t=ed(),r=t.firstChild,i=r.firstChild,a=i.nextSibling;a.firstChild;var o=r.nextSibling,s=o.firstChild,c=o.nextSibling;return t.$$click=()=>Wn(e.agent),R(i,()=>e.id),R(a,()=>e.agent,null),R(r,j(N,{get when(){return e.forked},get children(){return $u()}}),null),R(o,()=>e.schedule,s),R(o,(()=>{var t=P(()=>!!e.next);return()=>t()?Tp(e.next):`—`})(),null),R(o,(()=>{var t=P(()=>!!e.last);return()=>t()?` · last ${Tp(e.last)}`:` · never ran`})(),null),R(c,()=>Op(e.prompt,90)),y(r=>{var i=`sched-row`+(e.agent===n()?` cur`:``),a=`${Op(e.prompt,200)}\nclick to open #${e.agent}`;return i!==r.e&&L(t,r.e=i),a!==r.t&&I(t,`title`,r.t=a),r},{e:void 0,t:void 0}),t})()})}})]}),null),y(e=>{var t=`layout`+(le()?``:` right-hidden`),n=`iconbtn notifbtn`+(H()>0?` has-unread`:``),r=H()>0?`${H()} unread notifications`:`notifications`,a=`conn`+(Gn()?` ok`:``),o=Gn()?`live (websocket)`:`reconnecting…`,s=`rightbar`+(le()?` open`:``);return t!==e.e&&L(i,e.e=t),n!==e.t&&L(l,e.t=n),r!==e.a&&I(l,`title`,e.a=r),a!==e.o&&L(_,e.o=a),o!==e.i&&I(_,`title`,e.i=o),s!==e.n&&L(C,e.n=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i}}),j(N,{get when(){return jt()},get children(){return[(()=>{var e=Ml();return e.$$click=()=>Mt(!1),e})(),(()=>{var t=Fl(),r=t.firstChild.firstChild.nextSibling,i=r.firstChild;return R(r,j(N,{get when(){return Dt().length>0},get children(){var e=Nl();return e.$$click=()=>Ot([]),e}}),i),i.$$click=()=>Mt(!1),R(t,j(N,{get when(){return Dt().length>0},get fallback(){return td()},get children(){var t=Pl();return R(t,j(M,{get each(){return Dt()},children:t=>(()=>{var r=rd(),i=r.firstChild.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return r.$$click=()=>{Ot(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e)),n()!==t.agentId&&e().some(e=>e.id===t.agentId)&&Wn(t.agentId),Mt(!1),t.eventId&&setTimeout(()=>Rt(t.eventId),n()===t.agentId?60:350)},R(i,(()=>{var e=P(()=>t.kind===`finish`);return()=>e()?`✅`:P(()=>t.kind===`question`)()?`❓`:t.kind===`error`?`⚠️`:`📈`})()),R(a,()=>t.title),R(o,()=>Tp(new Date(t.at).toISOString())),s.$$click=e=>{e.stopPropagation(),Ot(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e))},R(s,()=>t.read?`✓`:`○`),R(r,j(N,{get when(){return t.body},get children(){var e=nd();return R(e,()=>wp(t.body,160)),e}}),null),y(e=>{var n=`notifitem `+t.kind+(t.read?` read`:``),i=`from ${t.agentId}`,a=t.read?`already read`:`mark as read`;return n!==e.e&&L(r,e.e=n),i!==e.t&&I(r,`title`,e.t=i),a!==e.a&&I(s,`title`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r})()})),t}}),null),t})()]}}),j(N,{get when(){return k()},get children(){return j(Np,{get providers(){return Object.keys(O().providers??{})},onClose:()=>ie(!1),onCreated:e=>{ie(!1),sn(),Wn(e)}})}}),j(N,{get when(){return ae()},get children(){return j(qp,{get cfg(){return O()},onClose:()=>oe(!1),onSaved:()=>{Jt(),dn()}})}}),j(N,{get when(){return Ct()},fallback:null,children:e=>{let t=()=>f().findIndex(t=>t.id===e().eventId),r=()=>Math.max(0,f().length-t()-1),[i,a]=v(r()>0?`summarize`:`discard`);return j(Mp,{title:`edit prompt — forks the conversation`,onClose:()=>wt(null),get children(){var t=ad(),o=t.firstChild,s=o.nextSibling,c=s.firstChild;return t.addEventListener(`submit`,async t=>{t.preventDefault();let r=document.getElementById(`edit-text`);try{await $(`/api/agents/${n()}/edit-prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({eventId:e().eventId,text:r.value,tail:i()})}),wt(null),sn();let t=n();t&&await Wn(t)}catch(e){alert(`edit failed: ${e.message}`)}}),R(t,j(N,{get when(){return r()>0},get children(){var e=id(),t=e.firstChild,n=t.firstChild,o=t.nextSibling,s=o.firstChild,c=o.nextSibling.firstChild;return R(t,r,n),s.addEventListener(`change`,()=>a(`summarize`)),c.addEventListener(`change`,()=>a(`discard`)),y(()=>s.checked=i()===`summarize`),y(()=>c.checked=i()===`discard`),e}}),s),c.$$click=()=>wt(null),y(()=>o.value=e().text),t}})}})]}function _p(e){let t=new Date(e.startedAt).getTime(),[n,r]=v(Date.now());C(()=>{let e=setInterval(()=>r(Date.now()),500);w(()=>clearInterval(e))});let i=()=>Ve(Math.max(0,n()-t));return e.inline?(()=>{var t=od();return t.firstChild,R(t,i,null),R(t,(()=>{var t=P(()=>!!e.timeoutMs);return()=>t()?` · timeout ${Math.round(e.timeoutMs/1e3)}s`:``})(),null),t})():(()=>{var e=sd(),t=e.firstChild;return R(e,i,t),e})()}function vp(e){let[t,n]=v(Date.now());return C(()=>{let e=setInterval(()=>n(Date.now()),500);w(()=>clearInterval(e))}),(()=>{var n=cd();return R(n,()=>Ve(Math.max(0,t()-e.startedAt))),n})()}function yp(e){let t=e.e,n=e.res,r=!e.agentActive&&!n,i=t.data??{},a=String(i.name??`tool`),o=()=>n?String(n.data?.result??``):``,s=a,c=``,l=(()=>{var e=ld();return R(e,()=>wp(JSON.stringify(i.args??{},null,1),2e3)),e})(),u=e=>String(i.args?.[e]??``),d=()=>a===`bash`?u(`command`):u(`path`)||JSON.stringify(i.args??{},null,1),f=()=>a===`bash`?Number(u(`timeout_ms`))||void 0:a===`wait_children`?Number(u(`timeout_ms`))||3e5:Number(u(`timeout_ms`))||void 0,p=(e,t=1500)=>(()=>{var n=ud();return R(n,()=>wp(e,t)),n})(),m=(e=4e3)=>n?[P(()=>p(o(),e)),(()=>{var e=dd();return R(e,()=>Ve(n.data?.durationMs),null),R(e,()=>a===`bash`?et($e(n.data?.ok,String(n.data?.result??``))):n.data?.ok===!1?` · FAILED`:``,null),R(e,j(jp,{get text(){return o()}}),null),e})()]:fd();try{switch(a){case`bash`:{let e=u(`command`),t=i.args?.background===!0,r=t?String(o()).match(/job (bg\d+)/)?.[1]??``:``;s=(t?`⏳ `:`$ `)+Op(e,96);let a=u(`timeout_ms`)?Number(u(`timeout_ms`)):void 0,d=$e(n?.data?.ok,n?String(n.data?.result??``):``);c=n?t?`background job${r?` ${r}`:``}${a?` · timeout ${Math.round(a/1e3)}s`:``}`:tt({outcome:d,durationMs:n.data?.durationMs,timeoutMs:a,fmtDur:Ve}):null,l=[t?(()=>{var e=pd(),t=e.firstChild.nextSibling,n=t.firstChild.nextSibling;return n.nextSibling,R(t,r||`?`,n),R(e,r?[` · kill with `,md()]:null,null),e})():null,P(()=>P(()=>e!==s.slice(2))()?p(e,800):null),P(()=>m(6e3))];break}case`read_file`:{s=u(`path`)||`(no path)`;let e=[];u(`pattern`)&&e.push(`grep /${Op(u(`pattern`),40)}/`),Number(i.args?.offset)<0?e.push(`last ${-Number(i.args.offset)} lines`):i.args?.offset&&e.push(`from L${i.args.offset}`),i.args?.limit&&e.push(`≤${i.args.limit} lines`),c=e.join(` · `),l=m(6e3);break}case`write_file`:{let e=String(i.args?.content??``);s=u(`path`)||`(no path)`,c=`${Ep(e.length)} bytes`,l=[P(()=>p(e,1500)),P(()=>P(()=>e.length>1500)()?(()=>{var t=hd(),n=t.firstChild;return R(t,()=>Ep(e.length),n),t})():null),n?(()=>{var e=dd();return R(e,()=>Op(o(),160)),e})():gd()];break}case`edit_file`:s=u(`path`)||`(no path)`,c=i.args?.replace_all===!0?`replace all`:`unique spot`,l=[(()=>{var e=_d();return R(e,()=>wp(`- `+u(`old_text`),900)),e})(),(()=>{var e=vd();return R(e,()=>`+ `+wp(u(`new_text`),900)),e})(),n?(()=>{var e=yd(),t=e.firstChild;return R(e,()=>Op(o(),120),t),R(e,()=>Ve(n.data?.durationMs),null),e})():bd()];break;case`apply_patch`:{let e=u(`patch`).split(`
26
26
  `).filter(e=>e&&!/^---$/.test(e.trim())),t=e.map(e=>e.match(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/)?.[1]).filter(Boolean);s=t.length?`${t.length} file${t.length>1?`s`:``}: ${Op(t.join(`, `),80)}`:`patch`;let r=e.slice(0,60);l=[(()=>{var t=xd();return R(t,()=>r.map(e=>{let t=e.startsWith(`+`)?` add`:e.startsWith(`-`)?` del`:/^\*\*\*|^@@/.test(e)?` meta`:``;return(()=>{var n=Sd();return L(n,`pline`+t),R(n,(()=>{var t=P(()=>e.length>240);return()=>t()?e.slice(0,240)+`…`:e})()),n})()}),null),R(t,(()=>{var t=P(()=>e.length>60);return()=>t()?(()=>{var t=Cd(),n=t.firstChild.nextSibling;return n.nextSibling,R(t,()=>e.length-60,n),t})():null})(),null),t})(),n?(()=>{var e=dd();return R(e,()=>Op(o().split(`
27
- `)[0]??``,140),null),R(e,()=>n.data?.ok===!1?` · FAILED`:``,null),e})():wd()];break}case`list_dir`:s=u(`path`)||`.`,l=m(4e3);break;case`read_url`:{let e=u(`url`);try{let t=new URL(e);e=t.host+t.pathname}catch{}s=Op(e,70),c=`web`,l=[(()=>{var e=dd();return R(e,j(N,{get when(){return/^https?:/i.test(u(`url`))},get fallback(){return(()=>{var e=Ed();return R(e,()=>Op(u(`url`),80)),e})()},get children(){var e=Td();return y(()=>I(e,`href`,u(`url`))),e}})),e})(),P(()=>m(3e3))];break}case`bash_output`:{let e=u(`action`)||`read`;s=`bash_output ${u(`job_id`)||`(?)`}`,c=e,l=m(4e3);break}case`load_skill`:{s=`skill: ${u(`name`)}`;let e=o().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);l=n?[(()=>{var t=gl();return y(()=>t.innerHTML=Ie(e)),t})(),(()=>{var e=dd();return R(e,()=>Ve(n.data?.durationMs)),e})()]:Dd();break}case`save_skill`:{s=`skill: ${u(`name`)}`,c=Op(u(`description`),60);let e=Array.isArray(i.args?.files)?i.args.files.map(e=>e?.name).filter(Boolean):[];l=[P(()=>P(()=>!!e.length)()?(()=>{var t=Od();return t.firstChild,R(t,()=>e.join(`, `),null),t})():null),n?(()=>{var e=yd(),t=e.firstChild;return R(e,()=>Op(o(),160),t),R(e,()=>Ve(n.data?.durationMs),null),e})():kd()];break}}}catch{}return(()=>{var i=jd(),u=i.firstChild,p=u.firstChild;p.firstChild;var m=p.nextSibling,h=m.nextSibling;return i.addEventListener(`toggle`,t=>{t.target.open&&e.onResize?.()}),I(i,`title`,`${a}${c?` — `+c:``}`),R(p,s,null),R(u,j(N,{get when(){return t.data?.actor},get children(){var e=Ad();return e.firstChild,R(e,()=>String(t.data.actor),null),e}}),m),R(m,()=>n?c||``:r?`(result missed)`:a===`bash`||f()?j(_p,{get startedAt(){return t.ts},inline:!0,get timeoutMs(){return f()}}):`running…`),R(h,j(jp,{get text(){return d()},label:`⧉ cmd`,title:`copy the ${a} arguments`}),null),R(h,j(N,{when:n,get children(){return j(jp,{get text(){return o()},label:`⧉ out`,title:`copy this tool's full output`})}}),null),R(i,l,null),y(()=>L(i,`embed`+(n?n.data?.ok===!1?` fail`:` done`:r?` done`:` running`))),i})()}function bp(e){let t=e.data??{};return e.type===`prompt`?String(t.text??``):e.type===`message`?`${typeof t.reasoning==`string`&&t.reasoning.trim()?`<reasoning>\n${t.reasoning}\n</reasoning>\n\n`:``}${String(t.content??``)}`:(e.type,``)}function xp(e){let t=e.e,n=up(t),r=e=>{let t=e.data??{};return e.data?.actor?`sub:${String(e.data.actor)}`:e.type===`tool_call`||e.type===`tool_result`?`agent-tools`:e.type===`prompt`?`src:${String(t.source??`user`)}`:`type:${e.type}`},i=e.prev&&!t.data?.pending&&!e.prev.data?.pending&&!t.data?.cancelled&&r(e.prev)===r(t)&&up(e.prev).name===n.name&&t.session===e.prev.session&&t.branch===e.prev.branch;if(t.type===`fork`){let e=t.data??{};return(()=>{var n=Md(),r=n.firstChild.nextSibling;return r.nextSibling,R(n,()=>String(e.fromBranch??`?`),r),R(n,()=>String(e.newBranch??t.branch),null),n})()}if(t.type===`goal`){let e=Qe(t.data??{});return(()=>{var t=Nd(),n=t.firstChild;return R(n,()=>e.label),R(t,j(N,{get when(){return e.hasCard},get children(){var t=Sd();return y(n=>{var r=`card `+(e.tone===`ok`?`auditcard ok`:e.tone===`warn`?`auditcard`:`verifycard`),i=e.markdown?Ie(e.detail):Ie(`\`\`\`\n${e.detail}\n\`\`\``);return r!==n.e&&L(t,n.e=r),i!==n.t&&(t.innerHTML=n.t=i),n},{e:void 0,t:void 0}),t}}),null),y(()=>L(t,`goalline `+(e.tone===`err`?`err`:e.tone===`warn`?`warn`:``))),t})()}if(t.type===`todo`)return(()=>{var e=Pd(),n=e.firstChild.nextSibling;return n.nextSibling,R(e,()=>String(t.data?.by??`human`),n),e})();if(t.type===`state`)return t.data.from===t.data.to?null:(()=>{var e=Fd(),n=e.firstChild;return R(e,()=>t.data.from,n),R(e,()=>t.data.to,null),R(e,(()=>{var e=P(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>L(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})();if(t.type===`system_note`){let e=String(t.data?.event??``);if(e===`runaway-detected`)return(()=>{var e=Id(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;i.nextSibling;var a=n.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,R(n,()=>String(t.data?.failures),r),R(n,()=>String(t.data?.limit),i),R(a,()=>String(t.data?.lastTool),o),R(a,()=>String(t.data?.lastError??``).slice(0,200),null),y(()=>I(e,`title`,`${t.data?.failures} consecutive tool failures hit the configured limit (${t.data?.limit})`)),e})();if(e===`error-retry`)return(()=>{var e=Ld(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(n,()=>String(t.data?.attempt),r),R(n,()=>Math.round(Number(t.data?.waitMs)/1e3),i),e})();if(e===`background-exit`){let e=t.data?.failed===!0,n=Math.round(Number(t.data?.durationMs??0)/1e3);return(()=>{var r=Sd();return L(r,`divider-msg`+(e?` err`:``)),R(r,()=>(e?`⚠ background job `:`✓ background job `)+String(t.data?.jobId??`?`)+` `+(e?`FAILED (exit ${String(t.data?.code??`?`)})`:`finished (${n}s)`)),y(()=>I(r,`title`,String(t.data?.cmd??``))),r})()}return e===`context-compacted`?(()=>{var e=Rd(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(e,()=>String(t.data?.tokensBefore??`?`),n),R(e,()=>String(t.data?.tokensAfter??`?`),r),R(e,()=>String(t.data?.mode??``),i),e})():e===`context-compaction-started`?(()=>{var e=zd(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(e,()=>String(t.data?.messages??`?`),n),R(e,()=>String(t.data?.tokensBefore??`?`),r),R(e,()=>String(t.data?.reason??`auto`),i),e})():null}return(()=>{var r=Ud(),a=r.firstChild,o=a.nextSibling;return L(a,`avatar avghost`+(i?` ghosted`:``)),R(a,()=>i?``:n.icon),R(o,i&&(()=>{var e=Wd();return y(()=>I(e,`title`,`${pp(t.ts)} · ${t.branch}`)),e})(),null),R(o,j(N,{when:!i,get children(){var r=Hd(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling;return R(i,()=>n.name),R(r,j(N,{get when(){return t.data?.actor},get children(){var e=Ad();return e.firstChild,R(e,()=>String(t.data.actor),null),e}}),a),R(a,(()=>{var e=P(()=>!!t.data?.pending);return()=>e()?`queued…`:P(()=>!!t.data?.cancelled)()?`withdrawn`:pp(t.ts)})()),R(o,()=>t.branch),R(r,j(N,{get when(){return e.onCancel},get children(){var t=Bd();return t.$$click=t=>{t.stopPropagation(),e.onCancel()},t}}),null),R(r,j(N,{get when(){return t.type!==`tool_call`},get children(){return j(jp,{get text(){return bp(t)},label:`⧉ copy`,title:`copy the RAW text of this message (no markdown rendering)`})}}),null),R(r,j(N,{get when(){return e.onEdit},get children(){var t=Vd();return t.$$click=t=>{t.stopPropagation(),e.onEdit()},t}}),null),y(e=>De(i,`color`,n.color)),r}}),null),R(o,j(Cp,{e:t,get res(){return e.res},get orphan(){return e.orphan},get onOption(){return e.onOption},get answeredIds(){return e.answeredIds},get onAnswered(){return e.onAnswered},get agentActive(){return e.agentActive},get onResize(){return e.onResize}}),null),y(e=>{var o=`msg`+(i?` grouped`:``)+(t.data?.pending?` pending`:``)+(t.data?.cancelled?` withdrawn`:``),s=t.id,c=i?`transparent`:n.color+`33`,l=i?`1px solid transparent`:`1px solid ${n.color}66`,u=i?`${pp(t.ts)} · ${t.branch}`:void 0;return o!==e.e&&L(r,e.e=o),s!==e.t&&I(r,`data-eid`,e.t=s),c!==e.a&&De(a,`background`,e.a=c),l!==e.o&&De(a,`border`,e.o=l),u!==e.i&&I(a,`title`,e.i=u),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r})()}function Sp(e){let[t,n]=v(``),r=()=>{let r=t().trim();!r||e.answered||(n(``),e.onOption?.(r))};return(()=>{var i=Gd(),a=i.firstChild,o=a.nextSibling;return a.$$keydown=e=>{e.key===`Enter`&&!e.isComposing&&(e.preventDefault(),r())},a.$$input=e=>n(e.currentTarget.value),o.$$click=r,y(n=>{var r=e.answered?`answered`:`or type your own answer…`,i=e.answered,s=e.answered||!t().trim();return r!==n.e&&I(a,`placeholder`,n.e=r),i!==n.t&&(a.disabled=n.t=i),s!==n.a&&(o.disabled=n.a=s),n},{e:void 0,t:void 0,a:void 0}),y(()=>a.value=t()),i})()}function Cp(e){let t=e.e;switch(t.type){case`prompt`:{let e=t.data?.images??[];return[(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.text??``))),e})(),j(N,{get when(){return e.length},get children(){var t=Kd();return R(t,j(M,{each:e,children:e=>(()=>{var t=qd();return I(t,`src`,e),t})()})),t}})]}case`message`:return[j(N,{get when(){return P(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Jd(),n=e.firstChild;n.firstChild;var r=n.nextSibling;return R(n,(()=>{var e=P(()=>String(t.data.reasoning).length>4e3);return()=>e()?` (${Ep(String(t.data.reasoning).length)} — truncated)`:``})(),null),R(r,()=>wp(String(t.data.reasoning),8e3)),e}}),(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.content??``))),e})(),j(N,{get when(){return t.data.interrupted},get children(){return Yd()}}),j(N,{get when(){return t.data.final},get children(){var e=Xd(),n=e.firstChild;return R(e,j(jp,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:return j(yp,{e:t,get res(){return e.res},get orphan(){return e.orphan},get agentActive(){return e.agentActive},get onResize(){return e.onResize}});case`tool_result`:{let n=String(t.data.result??``),r=String(t.data.name??`tool`),i=t.data.ok!==!1;return(()=>{var a=Qd(),o=a.firstChild,s=o.firstChild.nextSibling,c=o.nextSibling,l=c.nextSibling;return L(a,`embed `+(i?``:`fail`)),R(s,r===`bash`?`$ (bash, call evicted)`:r),R(o,j(jp,{text:n}),null),R(c,()=>wp(n,4e3)),R(l,()=>Ve(t.data.durationMs),null),R(l,()=>r===`bash`?et($e(t.data.ok,n)):i?``:` · FAILED`,null),R(a,j(N,{get when(){return e.orphan},get children(){return Zd()}}),null),y(()=>a.open=e.orphan),a})()}case`decision`:{let e=Array.isArray(t.data?.alternatives)?t.data.alternatives:[];return(()=>{var n=ef(),r=n.firstChild,i=r.firstChild.firstChild.nextSibling,a=r.nextSibling;return R(n,j(N,{get when(){return e.length},get children(){var t=$d();return t.firstChild,R(t,()=>e.join(` / `),null),t}}),null),y(e=>{var n=$f(String(t.data?.decision??``)),r=$f(String(t.data?.rationale??``));return n!==e.e&&(i.innerHTML=e.e=n),r!==e.t&&(a.innerHTML=e.t=r),e},{e:void 0,t:void 0}),n})()}case`question`:{let n=Array.isArray(t.data?.options)?t.data.options:[],r=t.data?.callId?String(t.data.callId):``,i=()=>e.answeredIds?.().has(r)??!1;return(()=>{var a=rf(),o=a.firstChild.firstChild.nextSibling;return R(a,j(N,{get when(){return i()},get children(){return tf()}}),null),R(a,j(N,{get when(){return n.length>0},get children(){var a=nf();return R(a,j(M,{each:n,children:n=>(()=>{var a=af();return a.$$click=()=>{e.onAnswered?.(r);let i=t.data?.actor;i?$(`/api/agents/${encodeURIComponent(String(i))}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:n,start:!0})}).then(()=>Q(`→ answered @${String(t.data.actor)}`)).catch(()=>Q(`answer failed`)):e.onOption?.(n)},R(a,n),y(()=>a.disabled=i()),a})()})),a}}),null),R(a,j(Sp,{get answered(){return i()},get onOption(){return e.onOption}}),null),y(e=>{var n=`embed question`+(i()?` answered`:``),r=$f(String(t.data?.question??``));return n!==e.e&&L(a,e.e=n),r!==e.t&&(o.innerHTML=e.t=r),e},{e:void 0,t:void 0}),a})()}case`progress`:return(()=>{var e=of(),n=e.firstChild.firstChild.nextSibling;return R(e,j(N,{get when(){return t.data.goalStatus},get children(){var e=Uu(),n=e.firstChild.nextSibling;return R(n,()=>String(t.data.goalStatus)),e}}),null),R(e,j(N,{get when(){return t.data.recent},get children(){var e=Bu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.recent))),e}}),null),R(e,j(N,{get when(){return t.data.problems},get children(){var e=Vu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.problems))),e}}),null),R(e,j(N,{get when(){return t.data.next},get children(){var e=Hu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.next))),e}}),null),y(()=>n.innerHTML=$f(String(t.data.doing??``))),e})();case`error`:return(()=>{var e=sf(),n=e.firstChild;return n.firstChild,R(n,()=>String(t.data.message??``),null),e})();case`compaction`:return(()=>{var e=lf(),n=e.firstChild.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,a=i.nextSibling.nextSibling;return a.nextSibling,R(n,()=>String(t.data.mode??``),r),R(n,()=>Ep(Number(t.data.tokensBefore??0)),i),R(n,()=>Ep(Number(t.data.tokensAfter??0)),a),R(n,(()=>{var e=P(()=>!!t.data.summarized);return()=>e()?`${t.data.summarized} summarized`:`${t.data.dropped} dropped`})(),null),R(e,j(N,{get when(){return t.data.summary},get children(){return[cf(),(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.summary))),e})()]}}),null),e})();default:return(()=>{var e=uf();return R(e,()=>wp(JSON.stringify(t.data),200)),e})()}}function wp(e,t){return e.length>t?e.slice(0,t)+` …`:e}function Tp(e){let t=new Date(e).getTime()-Date.now(),n=Math.abs(t),r=n<9e4?`${Math.round(n/1e3)}s`:n<54e5?`${Math.round(n/6e4)}m`:`${(n/36e5).toFixed(1)}h`;return t>=0?`in ${r}`:`${r} ago`}function Ep(e){return e>=1e9?`${+(e/1e9).toFixed(1)}b`:e>=1e6?`${+(e/1e6).toFixed(1)}m`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dp(e){return e>=100?Math.round(e).toLocaleString():e>=10?e.toFixed(1):e>=1?e.toFixed(2):e>=.01?e.toFixed(3):e.toFixed(4)}function Op(e,t){return wp(e.replace(/\s+/g,` `).trim(),t)}function kp(e){return(()=>{var t=df(),n=t.firstChild;return Te(t,`click`,e.onClick,!0),R(n,()=>e.icon),y(n=>{var r=`iconbtn`+(e.active?` active`:``)+(e.class?` `+e.class:``),i=e.title,a=e.style;return r!==n.e&&L(t,n.e=r),i!==n.t&&I(t,`title`,n.t=i),n.a=Ee(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t})()}async function Ap(e){if(!e)return`unsupported`;let t=typeof navigator<`u`?navigator.clipboard?.writeText:void 0;if(typeof t==`function`)try{return await t.call(navigator.clipboard,e),`copied`}catch{}let n=null;try{return n=document.createElement(`textarea`),n.value=e,n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select(),document.execCommand(`copy`)?`copied`:`failed`}catch{return`failed`}finally{n?.remove()}}function jp(e){let[t,n]=v(!1),[r,i]=v(!1),a=t=>{t.preventDefault(),t.stopPropagation(),Ap(e.text??``).then(e=>{if(e===`unsupported`||e===`failed`){i(!0),setTimeout(()=>i(!1),1200);return}n(!0),setTimeout(()=>n(!1),900)})};return(()=>{var n=ff();return n.$$click=a,R(n,(()=>{var n=P(()=>!!t());return()=>n()?`✓`:P(()=>!!r())()?`✗`:e.label??`⧉`})()),y(()=>I(n,`title`,e.title??`copy to clipboard`)),n})()}function Mp(e){return(()=>{var t=pf(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),R(r,()=>e.title),Te(i,`click`,e.onClose,!0),R(n,()=>e.children,null),t})()}function Np(e){let[t,n]=v(`~`),[r,i]=v([]),[a,o]=v(``),[s,c]=v(e.providers[0]??``),[l,u]=v(``),[d,f]=v(``);async function p(e){let r=await $(`/api/fs?path=${encodeURIComponent(e??t())}`);n(r.path),h(r.parent??``),i(r.entries??[])}C(()=>p(t()));let[m,h]=v(``),g=async n=>{n.preventDefault(),f(``);try{let n=await $(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0,start:!1})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return j(Mp,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=hf(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,_=h.nextSibling,v=_.nextSibling,b=f.nextSibling,x=b.nextSibling,S=x.firstChild,C=S.firstChild.nextSibling,w=S.nextSibling,ee=w.firstChild.nextSibling,te=w.nextSibling.firstChild.nextSibling,T=x.nextSibling;return i.addEventListener(`submit`,g),h.$$input=e=>n(e.currentTarget.value),_.$$click=()=>p(t()),v.$$click=()=>m()?p(m()):p(`..`),R(b,j(M,{get each(){return r()},children:e=>(()=>{var n=gf();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),R(n,e,null),n})()})),C.$$input=e=>o(e.currentTarget.value),ee.addEventListener(`change`,e=>c(e.currentTarget.value)),R(ee,j(M,{get each(){return e.providers},children:e=>(()=>{var t=Yl();return R(t,e),t})()})),te.$$input=e=>u(e.currentTarget.value),R(i,j(N,{get when(){return d()},get children(){var e=mf();return R(e,d),e}}),T),y(()=>h.value=t()),y(()=>C.value=a()),y(()=>ee.value=s()),y(()=>te.value=l()),i}})}var Pp=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]),Fp=new Set([`mp4`,`webm`,`mov`,`mkv`,`avi`,`m4v`]),Ip=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function Lp(e){let t=e.split(`.`).pop()?.toLowerCase()??``,n=Rp(e);return n===`image`?`🖼`:n===`video`?`🎬`:n===`audio`?`🎵`:[`ts`,`tsx`,`mts`,`cts`].includes(t)?`🟦`:[`js`,`mjs`,`cjs`,`jsx`].includes(t)?`🟨`:t===`json`||t===`jsonc`?`🧾`:t===`md`||t===`mdx`||t===`markdown`?`📝`:t===`css`||t===`scss`||t===`less`?`🎨`:t===`html`||t===`htm`||t===`svg`?`🌐`:[`py`,`pyi`].includes(t)?`🐍`:t===`rs`?`🦀`:t===`go`?`🐹`:t===`java`||t===`kt`||t===`kts`?`☕`:t===`rb`?`💎`:t===`php`?`🐘`:t===`c`||t===`h`||t===`cpp`||t===`hpp`||t===`cc`?`🧩`:t===`sh`||t===`bash`||t===`zsh`||t===`fish`?`🐚`:t===`sql`?`🗄`:t===`yml`||t===`yaml`||t===`toml`||t===`ini`||t===`conf`?`⚙`:t===`lock`?`🔒`:e===`Dockerfile`||t===`dockerfile`?`🐳`:t===`zip`||t===`gz`||t===`tar`||t===`tgz`||t===`bz2`?`📦`:t===`pdf`?`📕`:t===`txt`||t===`log`?`📄`:`·`}function Rp(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return Pp.has(t)?`image`:Fp.has(t)?`video`:Ip.has(t)?`audio`:null}var zp=new Map,Bp=e=>{let t=zp.get(e);return t||(t={expanded:new Set,preview:null,media:null,viewMode:`code`},zp.set(e,t)),t};function Vp(e){return j(N,{get when(){return e.viewMode},get fallback(){return(()=>{var t=vf();return y(()=>t.innerHTML=$f(e.draft)),t})()},get children(){var t=_f();return t.$$input=t=>e.onDraft(t.currentTarget.value),y(()=>t.value=e.draft),t}})}function Hp(e){let t=Bp(e.agentId),[n,r]=v(new Map),[i,a]=v(t.expanded),[o,s]=v(t.preview),c=e=>{t.preview=e,s(e)},l=e=>{t.expanded=e,a(e)},[u,d]=v(t.media),f=e=>{t.media=e,d(e)},[p,m]=v(t.viewMode),h=e=>{t.viewMode=e,m(e)},[g,_]=v(``),[x,S]=v(localStorage.getItem(`teapot.ignoreMode`)??`dim`),C=()=>{let e=[`dim`,`hide`,`show`],t=e[(e.indexOf(x())+1)%3];S(t),localStorage.setItem(`teapot.ignoreMode`,t)},ee=e=>x()!==`hide`||!e.ignored,[te,T]=v(localStorage.getItem(`teapot.showHidden`)===`1`),ne=()=>{let e=!te(),t=[``,...i()];Promise.all(t.map(async t=>({p:t,rows:await O(t,e)}))).then(t=>{T(e),localStorage.setItem(`teapot.showHidden`,e?`1`:`0`);for(let{p:e,rows:n}of t)n&&re(e,n)})},E=(e,t)=>t.map(t=>({name:String(t.name),path:e?`${e}/${t.name}`:String(t.name),dir:!!t.dir,...typeof t.size==`number`?{size:t.size}:{},...t.ignored?{ignored:!0}:{}}));async function D(e){return O(e,te())}async function O(t,n){try{let r=new URLSearchParams;t&&r.set(`path`,t),n&&r.set(`hidden`,`1`);let i=await $(`/api/agents/${e.agentId}/tree?${r.toString()}`);return E(t,i.entries??[])}catch(e){return _(e.message),null}}let re=(e,n)=>r(r=>{let i=r.get(e);if(!i)return new Map(r).set(e,n);let a=i.map(e=>{let t=n.find(t=>t.path===e.path);return t&&t.dir===e.dir&&t.size===e.size&&t.ignored===e.ignored&&t.name===e.name?e:t??e});for(let e of n)i.some(t=>t.path===e.path)||a.push(e);let o=a.filter(e=>n.some(t=>t.path===e.path)||t.preview?.path===e.path),s=new Map(r);return s.set(e,o),s}),k=``;b(()=>{let t=e.agentId;t!==k&&(k=t,l(new Set),c(null),f(null),r(new Map),D(``).then(e=>{e&&k===t&&r(new Map([[``,e]]))}))});let ie=async e=>{let t=new Set(i());if(t.has(e.path)){t.delete(e.path),l(t);return}if(t.add(e.path),l(t),!n().has(e.path)){let t=await D(e.path);t&&re(e.path,t)}},[ae,oe]=v(``),[se,ce]=v(!1),[A,le]=v(``),[ue,de]=v(!1),fe=e=>/\.(md|markdown|mdx)$/i.test(e),pe=0,me=async e=>{let t=++pe;oe(``),ce(!0);try{let{highlightChunks:n}=await nl(async()=>{let{highlightChunks:e}=await import(`./shiki-DavJK6MV.js`);return{highlightChunks:e}},[]);for await(let r of n(e.path,e.content)){if(pe!==t)return;oe(e=>e+r)}}catch{pe===t&&oe(``)}finally{pe===t&&ce(!1)}};w(()=>{pe++});let he=async(t,n)=>{let r=Rp(t.path);if(r){c({path:t.path,content:``,binary:!0}),f({path:t.path,kind:r}),h(`media`);return}try{let r=await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`);f(null),c({path:t.path,content:r.content??``,binary:r.binary,truncated:r.truncated}),le(r.content??``),h(r.binary?`code`:n),!r.binary&&n!==`md`&&me({path:t.path,content:r.content??``,truncated:r.truncated})}catch(e){Q(`open failed: ${e.message}`)}},ge=async()=>{let t=o();if(!(!t||ue())){de(!0);try{await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:A(),baseContent:t.content})}),c({...t,content:A()}),Q(`saved ${t.path}`)}catch(e){let n=e.payload,r=n&&typeof n==`object`&&n.error===`file changed on disk`?n:null;r?.current===void 0?Q(`save failed: ${e.message}`):confirm(`This file changed on disk since you opened it.
27
+ `)[0]??``,140),null),R(e,()=>n.data?.ok===!1?` · FAILED`:``,null),e})():wd()];break}case`list_dir`:s=u(`path`)||`.`,l=m(4e3);break;case`read_url`:{let e=u(`url`);try{let t=new URL(e);e=t.host+t.pathname}catch{}s=Op(e,70),c=`web`,l=[(()=>{var e=dd();return R(e,j(N,{get when(){return/^https?:/i.test(u(`url`))},get fallback(){return(()=>{var e=Ed();return R(e,()=>Op(u(`url`),80)),e})()},get children(){var e=Td();return y(()=>I(e,`href`,u(`url`))),e}})),e})(),P(()=>m(3e3))];break}case`bash_output`:{let e=u(`action`)||`read`;s=`bash_output ${u(`job_id`)||`(?)`}`,c=e,l=m(4e3);break}case`load_skill`:{s=`skill: ${u(`name`)}`;let e=o().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);l=n?[(()=>{var t=gl();return y(()=>t.innerHTML=Ie(e)),t})(),(()=>{var e=dd();return R(e,()=>Ve(n.data?.durationMs)),e})()]:Dd();break}case`save_skill`:{s=`skill: ${u(`name`)}`,c=Op(u(`description`),60);let e=Array.isArray(i.args?.files)?i.args.files.map(e=>e?.name).filter(Boolean):[];l=[P(()=>P(()=>!!e.length)()?(()=>{var t=Od();return t.firstChild,R(t,()=>e.join(`, `),null),t})():null),n?(()=>{var e=yd(),t=e.firstChild;return R(e,()=>Op(o(),160),t),R(e,()=>Ve(n.data?.durationMs),null),e})():kd()];break}}}catch{}return(()=>{var i=jd(),u=i.firstChild,p=u.firstChild;p.firstChild;var m=p.nextSibling,h=m.nextSibling;return i.addEventListener(`toggle`,t=>{t.target.open&&e.onResize?.()}),I(i,`title`,`${a}${c?` — `+c:``}`),R(p,s,null),R(u,j(N,{get when(){return t.data?.actor},get children(){var e=Ad();return e.firstChild,R(e,()=>String(t.data.actor),null),e}}),m),R(m,()=>n?c||``:r?`(result missed)`:a===`bash`||f()?j(_p,{get startedAt(){return t.ts},inline:!0,get timeoutMs(){return f()}}):`running…`),R(h,j(jp,{get text(){return d()},label:`⧉ cmd`,title:`copy the ${a} arguments`}),null),R(h,j(N,{when:n,get children(){return j(jp,{get text(){return o()},label:`⧉ out`,title:`copy this tool's full output`})}}),null),R(i,l,null),y(()=>L(i,`embed`+(n?n.data?.ok===!1?` fail`:` done`:r?` done`:` running`))),i})()}function bp(e){let t=e.data??{};return e.type===`prompt`?String(t.text??``):e.type===`message`?`${typeof t.reasoning==`string`&&t.reasoning.trim()?`<reasoning>\n${t.reasoning}\n</reasoning>\n\n`:``}${String(t.content??``)}`:(e.type,``)}function xp(e){let t=e.e,n=up(t),r=e=>{let t=e.data??{};return e.data?.actor?`sub:${String(e.data.actor)}`:e.type===`tool_call`||e.type===`tool_result`?`agent-tools`:e.type===`prompt`?`src:${String(t.source??`user`)}`:`type:${e.type}`},i=e.prev&&!t.data?.pending&&!e.prev.data?.pending&&!t.data?.cancelled&&r(e.prev)===r(t)&&up(e.prev).name===n.name&&t.session===e.prev.session&&t.branch===e.prev.branch;if(t.type===`fork`){let e=t.data??{};return(()=>{var n=Md(),r=n.firstChild.nextSibling;return r.nextSibling,R(n,()=>String(e.fromBranch??`?`),r),R(n,()=>String(e.newBranch??t.branch),null),n})()}if(t.type===`goal`){let e=Qe(t.data??{});return(()=>{var t=Nd(),n=t.firstChild;return R(n,()=>e.label),R(t,j(N,{get when(){return e.hasCard},get children(){var t=Sd();return y(n=>{var r=`card `+(e.tone===`ok`?`auditcard ok`:e.tone===`warn`?`auditcard`:`verifycard`),i=e.markdown?Ie(e.detail):Ie(`\`\`\`\n${e.detail}\n\`\`\``);return r!==n.e&&L(t,n.e=r),i!==n.t&&(t.innerHTML=n.t=i),n},{e:void 0,t:void 0}),t}}),null),y(()=>L(t,`goalline `+(e.tone===`err`?`err`:e.tone===`warn`?`warn`:``))),t})()}if(t.type===`todo`)return(()=>{var e=Pd(),n=e.firstChild.nextSibling;return n.nextSibling,R(e,()=>String(t.data?.by??`human`),n),e})();if(t.type===`state`)return t.data.from===t.data.to?null:(()=>{var e=Fd(),n=e.firstChild;return R(e,()=>t.data.from,n),R(e,()=>t.data.to,null),R(e,(()=>{var e=P(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>L(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})();if(t.type===`system_note`){let e=String(t.data?.event??``);if(e===`runaway-detected`)return(()=>{var e=Id(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;i.nextSibling;var a=n.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,R(n,()=>String(t.data?.failures),r),R(n,()=>String(t.data?.limit),i),R(a,()=>String(t.data?.lastTool),o),R(a,()=>String(t.data?.lastError??``).slice(0,200),null),y(()=>I(e,`title`,`${t.data?.failures} consecutive tool failures hit the configured limit (${t.data?.limit})`)),e})();if(e===`error-retry`)return(()=>{var e=Ld(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(n,()=>String(t.data?.attempt),r),R(n,()=>Math.round(Number(t.data?.waitMs)/1e3),i),e})();if(e===`background-exit`){let e=t.data?.failed===!0,n=Math.round(Number(t.data?.durationMs??0)/1e3);return(()=>{var r=Sd();return L(r,`divider-msg`+(e?` err`:``)),R(r,()=>(e?`⚠ background job `:`✓ background job `)+String(t.data?.jobId??`?`)+` `+(e?`FAILED (exit ${String(t.data?.code??`?`)})`:`finished (${n}s)`)),y(()=>I(r,`title`,String(t.data?.cmd??``))),r})()}return e===`context-compacted`?(()=>{var e=Rd(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(e,()=>String(t.data?.tokensBefore??`?`),n),R(e,()=>String(t.data?.tokensAfter??`?`),r),R(e,()=>String(t.data?.mode??``),i),e})():e===`context-compaction-started`?(()=>{var e=zd(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,R(e,()=>String(t.data?.messages??`?`),n),R(e,()=>String(t.data?.tokensBefore??`?`),r),R(e,()=>String(t.data?.reason??`auto`),i),e})():null}return(()=>{var r=Ud(),a=r.firstChild,o=a.nextSibling;return L(a,`avatar avghost`+(i?` ghosted`:``)),R(a,()=>i?``:n.icon),R(o,i&&(()=>{var e=Wd();return y(()=>I(e,`title`,`${pp(t.ts)} · ${t.branch}`)),e})(),null),R(o,j(N,{when:!i,get children(){var r=Hd(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling;return R(i,()=>n.name),R(r,j(N,{get when(){return t.data?.actor},get children(){var e=Ad();return e.firstChild,R(e,()=>String(t.data.actor),null),e}}),a),R(a,(()=>{var e=P(()=>!!t.data?.pending);return()=>e()?`queued…`:P(()=>!!t.data?.cancelled)()?`withdrawn`:pp(t.ts)})()),R(o,()=>t.branch),R(r,j(N,{get when(){return e.onCancel},get children(){var t=Bd();return t.$$click=t=>{t.stopPropagation(),e.onCancel()},t}}),null),R(r,j(N,{get when(){return t.type!==`tool_call`},get children(){return j(jp,{get text(){return bp(t)},label:`⧉ copy`,title:`copy the RAW text of this message (no markdown rendering)`})}}),null),R(r,j(N,{get when(){return e.onEdit},get children(){var t=Vd();return t.$$click=t=>{t.stopPropagation(),e.onEdit()},t}}),null),y(e=>De(i,`color`,n.color)),r}}),null),R(o,j(Cp,{e:t,get res(){return e.res},get orphan(){return e.orphan},get onOption(){return e.onOption},get answeredIds(){return e.answeredIds},get onAnswered(){return e.onAnswered},get agentActive(){return e.agentActive},get onResize(){return e.onResize}}),null),y(e=>{var o=`msg`+(i?` grouped`:``)+(t.data?.pending?` pending`:``)+(t.data?.cancelled?` withdrawn`:``),s=t.id,c=i?`transparent`:n.color+`33`,l=i?`1px solid transparent`:`1px solid ${n.color}66`,u=i?`${pp(t.ts)} · ${t.branch}`:void 0;return o!==e.e&&L(r,e.e=o),s!==e.t&&I(r,`data-eid`,e.t=s),c!==e.a&&De(a,`background`,e.a=c),l!==e.o&&De(a,`border`,e.o=l),u!==e.i&&I(a,`title`,e.i=u),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r})()}function Sp(e){let[t,n]=v(``),r=()=>{let r=t().trim();!r||e.answered||(n(``),e.onOption?.(r))};return(()=>{var i=Gd(),a=i.firstChild,o=a.nextSibling;return a.$$keydown=e=>{e.key===`Enter`&&!e.isComposing&&(e.preventDefault(),r())},a.$$input=e=>n(e.currentTarget.value),o.$$click=r,y(n=>{var r=e.answered?`answered`:`or type your own answer…`,i=e.answered,s=e.answered||!t().trim();return r!==n.e&&I(a,`placeholder`,n.e=r),i!==n.t&&(a.disabled=n.t=i),s!==n.a&&(o.disabled=n.a=s),n},{e:void 0,t:void 0,a:void 0}),y(()=>a.value=t()),i})()}function Cp(e){let t=e.e;switch(t.type){case`prompt`:{let e=t.data?.images??[];return[(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.text??``))),e})(),j(N,{get when(){return e.length},get children(){var t=Kd();return R(t,j(M,{each:e,children:e=>(()=>{var t=qd();return I(t,`src`,e),t})()})),t}})]}case`message`:return[j(N,{get when(){return P(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Jd(),n=e.firstChild;n.firstChild;var r=n.nextSibling;return R(n,(()=>{var e=P(()=>String(t.data.reasoning).length>4e3);return()=>e()?` (${Ep(String(t.data.reasoning).length)} — truncated)`:``})(),null),R(r,()=>wp(String(t.data.reasoning),8e3)),e}}),(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.content??``))),e})(),j(N,{get when(){return t.data.interrupted},get children(){return Yd()}}),j(N,{get when(){return t.data.final},get children(){var e=Xd(),n=e.firstChild;return R(e,j(jp,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:return j(yp,{e:t,get res(){return e.res},get orphan(){return e.orphan},get agentActive(){return e.agentActive},get onResize(){return e.onResize}});case`tool_result`:{let n=String(t.data.result??``),r=String(t.data.name??`tool`),i=t.data.ok!==!1;return(()=>{var a=Qd(),o=a.firstChild,s=o.firstChild.nextSibling,c=o.nextSibling,l=c.nextSibling;return L(a,`embed `+(i?``:`fail`)),R(s,r===`bash`?`$ (bash, call evicted)`:r),R(o,j(jp,{text:n}),null),R(c,()=>wp(n,4e3)),R(l,()=>Ve(t.data.durationMs),null),R(l,()=>r===`bash`?et($e(t.data.ok,n)):i?``:` · FAILED`,null),R(a,j(N,{get when(){return e.orphan},get children(){return Zd()}}),null),y(()=>a.open=e.orphan),a})()}case`decision`:{let e=Array.isArray(t.data?.alternatives)?t.data.alternatives:[];return(()=>{var n=ef(),r=n.firstChild,i=r.firstChild.firstChild.nextSibling,a=r.nextSibling;return R(n,j(N,{get when(){return e.length},get children(){var t=$d();return t.firstChild,R(t,()=>e.join(` / `),null),t}}),null),y(e=>{var n=$f(String(t.data?.decision??``)),r=$f(String(t.data?.rationale??``));return n!==e.e&&(i.innerHTML=e.e=n),r!==e.t&&(a.innerHTML=e.t=r),e},{e:void 0,t:void 0}),n})()}case`question`:{let n=Array.isArray(t.data?.options)?t.data.options:[],r=t.data?.callId?String(t.data.callId):``,i=()=>e.answeredIds?.().has(r)??!1;return(()=>{var a=rf(),o=a.firstChild.firstChild.nextSibling;return R(a,j(N,{get when(){return i()},get children(){return tf()}}),null),R(a,j(N,{get when(){return n.length>0},get children(){var a=nf();return R(a,j(M,{each:n,children:n=>(()=>{var a=af();return a.$$click=()=>{e.onAnswered?.(r);let i=t.data?.actor;i?$(`/api/agents/${encodeURIComponent(String(i))}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:n,start:!0})}).then(()=>Q(`→ answered @${String(t.data.actor)}`)).catch(()=>Q(`answer failed`)):e.onOption?.(n)},R(a,n),y(()=>a.disabled=i()),a})()})),a}}),null),R(a,j(Sp,{get answered(){return i()},get onOption(){return e.onOption}}),null),y(e=>{var n=`embed question`+(i()?` answered`:``),r=$f(String(t.data?.question??``));return n!==e.e&&L(a,e.e=n),r!==e.t&&(o.innerHTML=e.t=r),e},{e:void 0,t:void 0}),a})()}case`progress`:return(()=>{var e=of(),n=e.firstChild.firstChild.nextSibling;return R(e,j(N,{get when(){return t.data.goalStatus},get children(){var e=Uu(),n=e.firstChild.nextSibling;return R(n,()=>String(t.data.goalStatus)),e}}),null),R(e,j(N,{get when(){return t.data.recent},get children(){var e=Bu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.recent))),e}}),null),R(e,j(N,{get when(){return t.data.problems},get children(){var e=Vu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.problems))),e}}),null),R(e,j(N,{get when(){return t.data.next},get children(){var e=Hu(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=$f(String(t.data.next))),e}}),null),y(()=>n.innerHTML=$f(String(t.data.doing??``))),e})();case`error`:return(()=>{var e=sf(),n=e.firstChild;return n.firstChild,R(n,()=>String(t.data.message??``),null),e})();case`compaction`:return(()=>{var e=lf(),n=e.firstChild.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,a=i.nextSibling.nextSibling;return a.nextSibling,R(n,()=>String(t.data.mode??``),r),R(n,()=>Ep(Number(t.data.tokensBefore??0)),i),R(n,()=>Ep(Number(t.data.tokensAfter??0)),a),R(n,(()=>{var e=P(()=>!!t.data.summarized);return()=>e()?`${t.data.summarized} summarized`:`${t.data.dropped} dropped`})(),null),R(e,j(N,{get when(){return t.data.summary},get children(){return[cf(),(()=>{var e=gl();return y(()=>e.innerHTML=$f(String(t.data.summary))),e})()]}}),null),e})();default:return(()=>{var e=uf();return R(e,()=>wp(JSON.stringify(t.data),200)),e})()}}function wp(e,t){return e.length>t?e.slice(0,t)+` …`:e}function Tp(e){let t=new Date(e).getTime()-Date.now(),n=Math.abs(t),r=n<9e4?`${Math.round(n/1e3)}s`:n<54e5?`${Math.round(n/6e4)}m`:`${(n/36e5).toFixed(1)}h`;return t>=0?`in ${r}`:`${r} ago`}function Ep(e){return e>=1e9?`${+(e/1e9).toFixed(1)}b`:e>=1e6?`${+(e/1e6).toFixed(1)}m`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dp(e){return e>=100?Math.round(e).toLocaleString():e>=10?e.toFixed(1):e>=1?e.toFixed(2):e>=.01?e.toFixed(3):e.toFixed(4)}function Op(e,t){return wp(e.replace(/\s+/g,` `).trim(),t)}function kp(e){return(()=>{var t=df(),n=t.firstChild;return Te(t,`click`,e.onClick,!0),R(n,()=>e.icon),y(n=>{var r=`iconbtn`+(e.active?` active`:``)+(e.class?` `+e.class:``),i=e.title,a=e.style;return r!==n.e&&L(t,n.e=r),i!==n.t&&I(t,`title`,n.t=i),n.a=Ee(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t})()}async function Ap(e){if(!e)return`unsupported`;let t=typeof navigator<`u`?navigator.clipboard?.writeText:void 0;if(typeof t==`function`)try{return await t.call(navigator.clipboard,e),`copied`}catch{}let n=null;try{return n=document.createElement(`textarea`),n.value=e,n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select(),document.execCommand(`copy`)?`copied`:`failed`}catch{return`failed`}finally{n?.remove()}}function jp(e){let[t,n]=v(!1),[r,i]=v(!1),a=t=>{t.preventDefault(),t.stopPropagation(),Ap(e.text??``).then(e=>{if(e===`unsupported`||e===`failed`){i(!0),setTimeout(()=>i(!1),1200);return}n(!0),setTimeout(()=>n(!1),900)})};return(()=>{var n=ff();return n.$$click=a,R(n,(()=>{var n=P(()=>!!t());return()=>n()?`✓`:P(()=>!!r())()?`✗`:e.label??`⧉`})()),y(()=>I(n,`title`,e.title??`copy to clipboard`)),n})()}function Mp(e){return(()=>{var t=pf(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),R(r,()=>e.title),Te(i,`click`,e.onClose,!0),R(n,()=>e.children,null),t})()}function Np(e){let[t,n]=v(`~`),[r,i]=v([]),[a,o]=v(``),[s,c]=v(e.providers[0]??``),[l,u]=v(``),[d,f]=v(``);async function p(e){let r=await $(`/api/fs?path=${encodeURIComponent(e??t())}`);n(r.path),h(r.parent??``),i(r.entries??[])}C(()=>p(t()));let[m,h]=v(``),g=async n=>{n.preventDefault(),f(``);try{let n=await $(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0,start:!1})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return j(Mp,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=hf(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,_=h.nextSibling,v=_.nextSibling,b=f.nextSibling,x=b.nextSibling,S=x.firstChild,C=S.firstChild.nextSibling,w=S.nextSibling,ee=w.firstChild.nextSibling,te=w.nextSibling.firstChild.nextSibling,T=x.nextSibling;return i.addEventListener(`submit`,g),h.$$input=e=>n(e.currentTarget.value),_.$$click=()=>p(t()),v.$$click=()=>m()?p(m()):p(`..`),R(b,j(M,{get each(){return r()},children:e=>(()=>{var n=gf();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),R(n,e,null),n})()})),C.$$input=e=>o(e.currentTarget.value),ee.addEventListener(`change`,e=>c(e.currentTarget.value)),R(ee,j(M,{get each(){return e.providers},children:e=>(()=>{var t=Yl();return R(t,e),t})()})),te.$$input=e=>u(e.currentTarget.value),R(i,j(N,{get when(){return d()},get children(){var e=mf();return R(e,d),e}}),T),y(()=>h.value=t()),y(()=>C.value=a()),y(()=>ee.value=s()),y(()=>te.value=l()),i}})}var Pp=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]),Fp=new Set([`mp4`,`webm`,`mov`,`mkv`,`avi`,`m4v`]),Ip=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function Lp(e){let t=e.split(`.`).pop()?.toLowerCase()??``,n=Rp(e);return n===`image`?`🖼`:n===`video`?`🎬`:n===`audio`?`🎵`:[`ts`,`tsx`,`mts`,`cts`].includes(t)?`🟦`:[`js`,`mjs`,`cjs`,`jsx`].includes(t)?`🟨`:t===`json`||t===`jsonc`?`🧾`:t===`md`||t===`mdx`||t===`markdown`?`📝`:t===`css`||t===`scss`||t===`less`?`🎨`:t===`html`||t===`htm`||t===`svg`?`🌐`:[`py`,`pyi`].includes(t)?`🐍`:t===`rs`?`🦀`:t===`go`?`🐹`:t===`java`||t===`kt`||t===`kts`?`☕`:t===`rb`?`💎`:t===`php`?`🐘`:t===`c`||t===`h`||t===`cpp`||t===`hpp`||t===`cc`?`🧩`:t===`sh`||t===`bash`||t===`zsh`||t===`fish`?`🐚`:t===`sql`?`🗄`:t===`yml`||t===`yaml`||t===`toml`||t===`ini`||t===`conf`?`⚙`:t===`lock`?`🔒`:e===`Dockerfile`||t===`dockerfile`?`🐳`:t===`zip`||t===`gz`||t===`tar`||t===`tgz`||t===`bz2`?`📦`:t===`pdf`?`📕`:t===`txt`||t===`log`?`📄`:`·`}function Rp(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return Pp.has(t)?`image`:Fp.has(t)?`video`:Ip.has(t)?`audio`:null}var zp=new Map,Bp=e=>{let t=zp.get(e);return t||(t={expanded:new Set,preview:null,media:null,viewMode:`code`},zp.set(e,t)),t};function Vp(e){return j(N,{get when(){return e.viewMode},get fallback(){return(()=>{var t=vf();return y(()=>t.innerHTML=$f(e.draft)),t})()},get children(){var t=_f();return t.$$input=t=>e.onDraft(t.currentTarget.value),y(()=>t.value=e.draft),t}})}function Hp(e){let t=Bp(e.agentId),[n,r]=v(new Map),[i,a]=v(t.expanded),[o,s]=v(t.preview),c=e=>{t.preview=e,s(e)},l=e=>{t.expanded=e,a(e)},[u,d]=v(t.media),f=e=>{t.media=e,d(e)},[p,m]=v(t.viewMode),h=e=>{t.viewMode=e,m(e)},[g,_]=v(``),[x,S]=v(localStorage.getItem(`teapot.ignoreMode`)??`dim`),C=()=>{let e=[`dim`,`hide`,`show`],t=e[(e.indexOf(x())+1)%3];S(t),localStorage.setItem(`teapot.ignoreMode`,t)},ee=e=>x()!==`hide`||!e.ignored,[te,T]=v(localStorage.getItem(`teapot.showHidden`)===`1`),ne=()=>{let e=!te(),t=[``,...i()];Promise.all(t.map(async t=>({p:t,rows:await O(t,e)}))).then(t=>{T(e),localStorage.setItem(`teapot.showHidden`,e?`1`:`0`);for(let{p:e,rows:n}of t)n&&re(e,n)})},E=(e,t)=>t.map(t=>({name:String(t.name),path:e?`${e}/${t.name}`:String(t.name),dir:!!t.dir,...typeof t.size==`number`?{size:t.size}:{},...t.ignored?{ignored:!0}:{}}));async function D(e){return O(e,te())}async function O(t,n){try{let r=new URLSearchParams;t&&r.set(`path`,t),n&&r.set(`hidden`,`1`);let i=await $(`/api/agents/${e.agentId}/tree?${r.toString()}`);return E(t,i.entries??[])}catch(e){return _(e.message),null}}let re=(e,n)=>r(r=>{let i=r.get(e);if(!i)return new Map(r).set(e,n);let a=i.map(e=>{let t=n.find(t=>t.path===e.path);return t&&t.dir===e.dir&&t.size===e.size&&t.ignored===e.ignored&&t.name===e.name?e:t??e});for(let e of n)i.some(t=>t.path===e.path)||a.push(e);let o=a.filter(e=>n.some(t=>t.path===e.path)||t.preview?.path===e.path),s=new Map(r);return s.set(e,o),s}),k=``;b(()=>{let t=e.agentId;t!==k&&(k=t,l(new Set),c(null),f(null),r(new Map),D(``).then(e=>{e&&k===t&&r(new Map([[``,e]]))}))});let ie=async e=>{let t=new Set(i());if(t.has(e.path)){t.delete(e.path),l(t);return}if(t.add(e.path),l(t),!n().has(e.path)){let t=await D(e.path);t&&re(e.path,t)}},[ae,oe]=v(``),[se,ce]=v(!1),[A,le]=v(``),[ue,de]=v(!1),fe=e=>/\.(md|markdown|mdx)$/i.test(e),pe=0,me=async e=>{let t=++pe;oe(``),ce(!0);try{let{highlightChunks:n}=await nl(async()=>{let{highlightChunks:e}=await import(`./shiki-N1Dpty1W.js`);return{highlightChunks:e}},[]);for await(let r of n(e.path,e.content)){if(pe!==t)return;oe(e=>e+r)}}catch{pe===t&&oe(``)}finally{pe===t&&ce(!1)}};w(()=>{pe++});let he=async(t,n)=>{let r=Rp(t.path);if(r){c({path:t.path,content:``,binary:!0}),f({path:t.path,kind:r}),h(`media`);return}try{let r=await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`);f(null),c({path:t.path,content:r.content??``,binary:r.binary,truncated:r.truncated}),le(r.content??``),h(r.binary?`code`:n),!r.binary&&n!==`md`&&me({path:t.path,content:r.content??``,truncated:r.truncated})}catch(e){Q(`open failed: ${e.message}`)}},ge=async()=>{let t=o();if(!(!t||ue())){de(!0);try{await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:A(),baseContent:t.content})}),c({...t,content:A()}),Q(`saved ${t.path}`)}catch(e){let n=e.payload,r=n&&typeof n==`object`&&n.error===`file changed on disk`?n:null;r?.current===void 0?Q(`save failed: ${e.message}`):confirm(`This file changed on disk since you opened it.
28
28
  OK = load the disk version into the editor (your edits are discarded)
29
- Cancel = keep editing your copy`)?(le(r.current),c({...t,content:r.current}),Q(`loaded the current file from disk`)):Q(`kept your edits — use Save As via bash to force-write`)}finally{de(!1)}}},_e=e=>!e.binary&&!e.truncated,ve=(e,t)=>[(()=>{var n=bf(),r=n.firstChild,a=r.nextSibling;return n.$$click=()=>e.dir?void ie(e):void he(e,`code`),R(r,(()=>{var t=P(()=>!!e.dir);return()=>t()?i().has(e.path)?`▾`:`▸`:Lp(e.name)})()),R(a,()=>e.name),R(n,j(N,{get when(){return P(()=>!e.dir)()&&e.size!==void 0},get children(){var t=yf();return R(t,()=>Ep(e.size)),t}}),null),y(r=>{var i=`filerow`+(e.dir?` isdir`:``)+(e.ignored&&x()===`dim`?` gitignored`:``),a=`padding-left:${t*13+8}px`,o=e.dir?`browse ${e.path}`:`preview ${e.path}`;return i!==r.e&&L(n,r.e=i),r.t=Ee(n,a,r.t),o!==r.a&&I(n,`title`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})(),j(N,{get when(){return P(()=>!!e.dir)()&&i().has(e.path)},get children(){return j(M,{get each(){return(n().get(e.path)??[]).filter(ee)},children:e=>ve(e,t+1)})}})],ye=()=>e.workspace.split(`/`).filter(Boolean).pop()??e.workspace,[be,xe]=v(!1),Se=async()=>{if(!be()){xe(!0);try{let e=[``,...i()],t=await Promise.all(e.map(async e=>({p:e,rows:await O(e,te())})));for(let{p:e,rows:n}of t)n&&re(e,n)}finally{xe(!1)}}};return[(()=>{var e=xf(),t=e.firstChild.nextSibling;return t.firstChild,R(t,ye,null),R(e,j(kp,{class:`filetoggle`,get icon(){return be()?`…`:`⟳`},title:`refresh the tree (root + expanded folders) — open popups are kept`,onClick:()=>void Se()}),null),R(e,j(kp,{class:`filetoggle`,style:`margin-left:auto`,get icon(){return P(()=>x()===`hide`)()?`🙈`:x()===`dim`?`👁`:`✨`},get title(){return`gitignored files: ${x()} — click to cycle (dim → hidden → shown)`},onClick:C}),null),R(e,j(kp,{class:`filetoggle`,get icon(){return te()?`◉.`:`○.`},get title(){return te()?`dotfiles shown — click to hide`:`dotfiles hidden — click to show`},onClick:ne}),null),e})(),(()=>{var e=Sf();return R(e,j(N,{get when(){return(n().get(``)??[]).length>0},get fallback(){return(()=>{var e=Cf();return R(e,()=>g()||`empty workspace`),e})()},get children(){return j(M,{get each(){return(n().get(``)??[]).filter(ee)},children:e=>ve(e,0)})}})),e})(),j(N,{get when(){return o()},children:t=>j(Mp,{get title(){return`🗂 ${t().path}`},onClose:()=>{pe++,c(null),f(null)},get children(){return j(N,{get when(){return u()},get fallback(){return[(()=>{var e=Of(),n=e.firstChild;return R(e,j(N,{get when(){return P(()=>!!fe(t().path))()&&!t().binary},get children(){var e=Ef();return e.$$click=()=>h(`md`),y(()=>L(e,p()===`md`?`on`:``)),e}}),n),n.$$click=()=>{h(`code`),ae()||me({path:t().path,content:t().content,truncated:t().truncated})},R(e,j(N,{get when(){return _e(t())},get children(){var e=Df();return e.$$click=()=>h(`edit`),y(()=>L(e,p()===`edit`?`on`:``)),e}}),null),y(()=>L(n,p()===`code`?`on`:``)),e})(),j(N,{get when(){return!t().binary},get fallback(){return Af()},get children(){return j(N,{get when(){return p()===`edit`},get fallback(){return j(N,{get when(){return P(()=>p()===`md`)()&&fe(t().path)},get fallback(){return j(Up,{get path(){return t().path},get content(){return t().content},get html(){return ae()},get pending(){return se()},get truncated(){return!!t().truncated}})},get children(){var e=jf();return y(()=>e.innerHTML=Ie(t().content)),e}})},get children(){var e=kf(),n=e.firstChild,r=n.nextSibling.firstChild,i=r.firstChild,a=r.nextSibling;return n.$$input=e=>le(e.currentTarget.value),I(n,`spellcheck`,!1),R(r,()=>Ep(A().length),i),a.$$click=()=>void ge(),R(a,()=>ue()?`saving…`:`💾 save`),y(()=>a.disabled=ue()||A()===t().content),y(()=>n.value=A()),e}})}})]},get children(){var t=Tf(),n=t.firstChild,r=n.firstChild;return R(t,j(N,{get when(){return u().kind===`image`},get fallback(){return j(N,{get when(){return u().kind===`video`},get fallback(){return(()=>{var t=Nf();return y(()=>I(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t})()},get children(){var t=Mf();return y(()=>I(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t}})},get children(){var t=wf();return y(n=>{var r=`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`,i=u().path.split(`/`).pop();return r!==n.e&&I(t,`src`,n.e=r),i!==n.t&&I(t,`alt`,n.t=i),n},{e:void 0,t:void 0}),t}}),n),R(n,()=>u().kind,r),t}})}})})]}function Up(e){return[j(N,{get when(){return e.html},get fallback(){return P(()=>!!e.pending)()?(()=>{var t=If(),n=t.firstChild.nextSibling;return n.nextSibling,R(t,()=>e.path.split(`/`).pop(),n),t})():(()=>{var t=Lf();return R(t,()=>e.content),t})()},get children(){var t=Pf();return y(()=>t.innerHTML=e.html),t}}),j(N,{get when(){return e.truncated},get children(){return Ff()}})]}var Wp=[{key:`openrouter`,label:`OpenRouter`,url:`https://openrouter.ai/api/v1`,model:`anthropic/claude-sonnet-4`,hint:`400+ models behind one key — teapot sends app-attribution headers automatically`},{key:`orcarouter`,label:`OrcaRouter`,url:`https://api.orcarouter.ai/v1`,model:`orcarouter/auto`,hint:`zero-markup routing gateway — 'orcarouter/auto' grades each prompt and picks the model`},{key:`openai`,label:`OpenAI`,url:`https://api.openai.com/v1`,model:`gpt-4o-mini`},{key:`llamacpp`,label:`llama.cpp server`,url:`http://localhost:8080/v1`,model:``,hint:`free & local — start it with: llama-server -m ./model.gguf (any model name works)`}],Gp={key:`custom`,label:`Custom`,url:``,model:``,hint:`any OpenAI-compatible /v1 endpoint — vLLM, LM Studio, llama.cpp, a company gateway… fill the fields below`};function Kp(e){let[t,n]=v(Wp[0]),[r,i]=v(Wp[0].url),[a,o]=v(``),[s,c]=v(Wp[0].model),[l,u]=v([]),[d,f]=v(`~/teapot-workspace`),[p,m]=v(``),[h,g]=v(!1),[_,x]=v(``),S=e=>{n(e),e.key!==`custom`&&e.url&&(i(e.url),e.model&&c(e.model))};b(()=>{let e=r().trim(),t=a();if(!/^https?:\/\//.test(e)){u([]);return}let n=setTimeout(async()=>{try{let n=await $(`/api/setup/models?baseUrl=${encodeURIComponent(e)}${t?`&apiKey=${encodeURIComponent(t)}`:``}`);u(n.models??[])}catch{u([])}},600);w(()=>clearTimeout(n))});let C=e=>{let t=l().find(t=>t.id===e.trim());if(!t)return``;let n=[];t.contextLength&&n.push(`ctx ${Ep(t.contextLength)} tok`);let r=e=>e===void 0?``:`$${e*1e6>=10?Math.round(e*1e6):+(e*1e6).toFixed(1)}/M`;if(t.pricing){let e=r(t.pricing.prompt),i=r(t.pricing.completion);e&&i?n.push(`${e} in · ${i} out`):(e||i)&&n.push(r(t.pricing.prompt??t.pricing.completion))}return n.join(` · `)},ee=()=>C(s()),te=async t=>{t.preventDefault(),x(``),g(!0);try{await $(`/api/setup`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({baseUrl:r(),apiKey:a()||void 0,model:s(),workspace:d(),...p()?{password:p()}:{}})}),e.onDone()}catch(e){x(e.message),g(!1)}};return(()=>{var e=Vf(),n=e.firstChild.firstChild.nextSibling.nextSibling,u=n.firstChild,g=u.nextSibling,v=g.firstChild.nextSibling,b=v.nextSibling,x=g.nextSibling,C=x.firstChild.nextSibling,w=x.nextSibling,T=w.firstChild.nextSibling,ne=T.nextSibling,E=w.nextSibling,D=E.firstChild.nextSibling,O=D.firstChild.nextSibling,re=D.nextSibling.firstChild.nextSibling,k=E.nextSibling;return n.addEventListener(`submit`,te),R(u,()=>[...Wp,Gp].map(e=>(()=>{var n=Hf();return n.$$click=()=>S(e),R(n,()=>e.label),y(r=>{var i=`presetbtn`+(t().key===e.key?` active`:``),a=e.hint||e.url;return i!==r.e&&L(n,r.e=i),a!==r.t&&I(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})())),R(n,j(N,{get when(){return t().hint},get children(){var e=Rf();return R(e,()=>t().hint),e}}),g),v.$$input=e=>i(e.currentTarget.value),R(b,()=>Wp.map(e=>(()=>{var t=Yl();return y(()=>t.value=e.url),t})())),C.$$input=e=>o(e.currentTarget.value),T.$$input=e=>c(e.currentTarget.value),R(ne,()=>l().map(e=>(()=>{var t=Yl();return y(()=>t.value=e.id),t})())),R(n,j(N,{get when(){return l().length>0},get fallback(){return Uf()},get children(){var e=Bf(),t=e.firstChild;return R(e,()=>l().length,t),R(e,j(N,{get when(){return ee()},get children(){return[` · `,(()=>{var e=zf();return R(e,ee),e})()]}}),null),e}}),E),O.$$input=e=>f(e.currentTarget.value),re.$$input=e=>m(e.currentTarget.value),R(n,j(N,{get when(){return _()},get children(){var e=mf();return R(e,_),e}}),k),R(k,()=>h()?`saving…`:`finish setup`),y(e=>{var n=t().key===`llamacpp`?`(any name — serves whichever gguf is loaded)`:`(type to filter models from the endpoint)`,r=h();return n!==e.e&&I(T,`placeholder`,e.e=n),r!==e.t&&(k.disabled=e.t=r),e},{e:void 0,t:void 0}),y(()=>v.value=r()),y(()=>C.value=a()),y(()=>T.value=s()),y(()=>O.value=d()),y(()=>re.value=p()),e})()}function qp(e){let[t,n]=v(Object.entries(e.cfg.providers??{}).map(([e,t])=>({name:e,baseUrl:t.baseUrl??``,apiKey:t.apiKey??``,model:t.model??``}))),[r,i]=v(e.cfg.defaultProvider??``),a=()=>e.cfg.defaultProvider??``,o=()=>{let e=[...new Set(t().map(e=>e.name.trim()).filter(Boolean))],n=r();return n&&!e.includes(n)&&e.push(n),e},s=()=>{let e=r();return e?t().some(t=>t.name.trim()===e)?``:e:``},[c,l]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[u,d]=v(e.cfg.progressMinChars??4e3),[f,p]=v(e.cfg.contextTokenBudget==null?null:Math.round(e.cfg.contextTokenBudget/1e3)),[m,h]=v(e.cfg.contextWindowTokens?Math.round(e.cfg.contextWindowTokens/1e3):0),[g,_]=v(e.cfg.maxSpawnDepth??3),[b,x]=v((e.cfg.tasks??[]).map(e=>({...e}))),[S,C]=v(``),w=()=>(e.cfg.agents??[]).map(e=>e.id),ee=()=>{let e={};for(let n of t()){if(!n.name.trim())return C(`provider name is required`),null;if(n.baseUrl&&!/^https?:\/\//.test(n.baseUrl))return C(`provider ${n.name}: baseUrl must start with http(s)://`),null;e[n.name.trim()]={baseUrl:n.baseUrl,...n.apiKey?{apiKey:n.apiKey}:{},...n.model?{model:n.model}:{}}}return e},te=async t=>{t.preventDefault(),C(``);let n=ee();if(!n)return;let i=b().filter(e=>e.id?.trim()||e.prompt?.trim()).map((e,t)=>({id:e.id?.trim()||`task-${t+1}`,agent:e.agent,schedule:e.schedule,prompt:e.prompt,...e.forked?{forked:!0}:{}}));for(let e of i){if(!e.agent){C(`task "${e.id}": agent is required`);return}if(!e.schedule?.trim()){C(`task "${e.id}": schedule is required`);return}}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:n,defaultProvider:r()||void 0,progressIntervalMs:Math.max(1,c())*6e4,progressMinChars:Math.max(100,u()),...f()==null?{}:{contextTokenBudget:Math.max(1,f())*1e3},...m()>0?{contextWindowTokens:m()*1e3}:{},maxSpawnDepth:Math.max(0,g()),tasks:i})}),e.onSaved(),e.onClose()}catch(e){C(e.message)}},T=(e,t,n,r)=>(()=>{var i=Wf(),a=i.firstChild;return I(i,`title`,r),R(i,e,a),a.$$input=e=>n(Number(e.currentTarget.value)),a.value=t,i})();return j(Mp,{title:`settings`,get onClose(){return e.onClose},get children(){var v=Kf(),ee=v.firstChild,ne=ee.firstChild.nextSibling,E=ne.nextSibling;E.firstChild;var D=E.nextSibling.firstChild.firstChild.nextSibling;D.firstChild;var O=ee.nextSibling,re=O.firstChild.nextSibling,k=re.firstChild,ie=k.firstChild.nextSibling,ae=O.nextSibling,oe=ae.firstChild.nextSibling,se=ae.nextSibling;se.firstChild;var ce=se.nextSibling,A=ce.firstChild.nextSibling.firstChild;A.firstChild;var le=A.nextSibling,ue=ce.nextSibling;return v.addEventListener(`submit`,te),R(ee,j(be,{get each(){return t()},children:(e,r)=>(()=>{var i=qf(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling;return a.$$input=e=>n(t().map((t,n)=>n===r?{...t,name:e.currentTarget.value}:t)),o.$$input=e=>n(t().map((t,n)=>n===r?{...t,baseUrl:e.currentTarget.value}:t)),s.$$input=e=>n(t().map((t,n)=>n===r?{...t,apiKey:e.currentTarget.value}:t)),c.$$input=e=>n(t().map((t,n)=>n===r?{...t,model:e.currentTarget.value}:t)),l.$$click=()=>n(t().filter((e,t)=>t!==r)),y(()=>a.value=e().name),y(()=>o.value=e().baseUrl),y(()=>s.value=e().apiKey),y(()=>c.value=e().model),i})()}),ne),ne.$$click=()=>n([...t(),{name:``,baseUrl:``,apiKey:``,model:``}]),R(E,j(M,{each:Wp,children:e=>(()=>{var a=Jf();return a.firstChild,a.$$click=()=>{let a=t().filter(t=>t.name!==e.key);n([...a,{name:e.key,baseUrl:e.url,apiKey:``,model:e.model}]),r()||i(e.key)},R(a,()=>e.label,null),y(()=>I(a,`title`,`fill a ${e.label} row — ${e.url}${e.model?` (model: ${e.model})`:``}`)),a})()}),null),D.addEventListener(`change`,e=>i(e.currentTarget.value)),R(D,j(M,{get each(){return o()},children:e=>(()=>{var t=Yl();return t.value=e,R(t,e),t})()}),null),R(ee,j(N,{get when(){return s()},get children(){var e=Gf(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling;return R(t,s),R(e,()=>s()===a()?` — the dropdown above cannot show it.`:` — it was replaced by your selection.`,n),R(r,s),e}}),null),R(re,()=>T(`progress interval (min)`,c(),e=>l(e),`how often the harness asks for a progress report`),k),R(re,()=>T(`progress min chars`,u(),e=>d(e),`progress prompts wait for this much real output`),k),ie.$$input=e=>p(e.currentTarget.value===``?null:Number(e.currentTarget.value)),R(re,()=>T(`context window (k tok)`,m(),e=>h(e),`model's real window — 0/blank hides the % gauge`),null),R(re,()=>T(`max spawn depth`,g(),e=>_(e),`sub-agent nesting limit (0 = no spawning)`),null),R(ae,j(N,{get when(){return b().length>0},get children(){return j(be,{get each(){return b()},children:(e,t)=>(()=>{var n=Yf(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.firstChild,l=s.nextSibling,u=r.nextSibling;return i.$$input=e=>x(b().map((n,r)=>r===t?{...n,id:e.currentTarget.value}:n)),a.$$input=e=>x(b().map((n,r)=>r===t?{...n,agent:e.currentTarget.value}:n)),o.$$input=e=>x(b().map((n,r)=>r===t?{...n,schedule:e.currentTarget.value}:n)),c.addEventListener(`change`,e=>x(b().map((n,r)=>r===t?{...n,forked:e.currentTarget.checked}:n))),l.$$click=()=>x(b().filter((e,n)=>n!==t)),u.$$input=e=>x(b().map((n,r)=>r===t?{...n,prompt:e.currentTarget.value}:n)),y(()=>i.value=e().id),y(()=>a.value=e().agent),y(()=>o.value=e().schedule),y(()=>c.checked=!!e().forked),y(()=>u.value=e().prompt),n})()})}}),oe),oe.$$click=()=>x([...b(),{id:``,agent:w()[0]??``,schedule:`every 30m`,prompt:``}]),R(se,j(M,{get each(){return e.cfg.agents??[]},children:e=>(()=>{var t=Zf(),n=t.firstChild,r=n.nextSibling;return R(n,()=>e.id),R(r,()=>e.workspace),R(t,j(N,{get when(){return e.parent},get children(){var t=Xf();return t.firstChild,R(t,()=>e.parent,null),t}}),null),t})()}),null),R(A,()=>e.cfg.version??`unknown`,null),le.$$click=async e=>{try{C(``);let t=e.currentTarget;t.disabled=!0,t.textContent=`updating…`;let n=await $(`/api/update/restart`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`restart failed`);t.textContent=`restarting…`;let r=!1;for(let e=0;e<90&&!r;e++){await new Promise(e=>setTimeout(e,1e3));try{let e=await $(`/api/version`);e.version&&e.version!==`0.25.1`&&(r=!0,window.location.reload())}catch{}}if(!r)throw Error(`restart timeout — new server did not come up`)}catch(e){C(e.message)}finally{e.currentTarget.disabled=!1,e.currentTarget.textContent=`update & restart`}},R(v,j(N,{get when(){return S()},get children(){var e=mf();return R(e,S),e}}),ue),y(()=>D.value=r()),y(()=>ie.value=f()??``),v}})}we([`click`,`pointerdown`,`dblclick`,`input`,`keydown`]),Ce(()=>j(gp,{}),document.getElementById(`root`));export{nl as t};
30
- //# sourceMappingURL=index-DLBs15ef.js.map
29
+ Cancel = keep editing your copy`)?(le(r.current),c({...t,content:r.current}),Q(`loaded the current file from disk`)):Q(`kept your edits — use Save As via bash to force-write`)}finally{de(!1)}}},_e=e=>!e.binary&&!e.truncated,ve=(e,t)=>[(()=>{var n=bf(),r=n.firstChild,a=r.nextSibling;return n.$$click=()=>e.dir?void ie(e):void he(e,`code`),R(r,(()=>{var t=P(()=>!!e.dir);return()=>t()?i().has(e.path)?`▾`:`▸`:Lp(e.name)})()),R(a,()=>e.name),R(n,j(N,{get when(){return P(()=>!e.dir)()&&e.size!==void 0},get children(){var t=yf();return R(t,()=>Ep(e.size)),t}}),null),y(r=>{var i=`filerow`+(e.dir?` isdir`:``)+(e.ignored&&x()===`dim`?` gitignored`:``),a=`padding-left:${t*13+8}px`,o=e.dir?`browse ${e.path}`:`preview ${e.path}`;return i!==r.e&&L(n,r.e=i),r.t=Ee(n,a,r.t),o!==r.a&&I(n,`title`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})(),j(N,{get when(){return P(()=>!!e.dir)()&&i().has(e.path)},get children(){return j(M,{get each(){return(n().get(e.path)??[]).filter(ee)},children:e=>ve(e,t+1)})}})],ye=()=>e.workspace.split(`/`).filter(Boolean).pop()??e.workspace,[be,xe]=v(!1),Se=async()=>{if(!be()){xe(!0);try{let e=[``,...i()],t=await Promise.all(e.map(async e=>({p:e,rows:await O(e,te())})));for(let{p:e,rows:n}of t)n&&re(e,n)}finally{xe(!1)}}};return[(()=>{var e=xf(),t=e.firstChild.nextSibling;return t.firstChild,R(t,ye,null),R(e,j(kp,{class:`filetoggle`,get icon(){return be()?`…`:`⟳`},title:`refresh the tree (root + expanded folders) — open popups are kept`,onClick:()=>void Se()}),null),R(e,j(kp,{class:`filetoggle`,style:`margin-left:auto`,get icon(){return P(()=>x()===`hide`)()?`🙈`:x()===`dim`?`👁`:`✨`},get title(){return`gitignored files: ${x()} — click to cycle (dim → hidden → shown)`},onClick:C}),null),R(e,j(kp,{class:`filetoggle`,get icon(){return te()?`◉.`:`○.`},get title(){return te()?`dotfiles shown — click to hide`:`dotfiles hidden — click to show`},onClick:ne}),null),e})(),(()=>{var e=Sf();return R(e,j(N,{get when(){return(n().get(``)??[]).length>0},get fallback(){return(()=>{var e=Cf();return R(e,()=>g()||`empty workspace`),e})()},get children(){return j(M,{get each(){return(n().get(``)??[]).filter(ee)},children:e=>ve(e,0)})}})),e})(),j(N,{get when(){return o()},children:t=>j(Mp,{get title(){return`🗂 ${t().path}`},onClose:()=>{pe++,c(null),f(null)},get children(){return j(N,{get when(){return u()},get fallback(){return[(()=>{var e=Of(),n=e.firstChild;return R(e,j(N,{get when(){return P(()=>!!fe(t().path))()&&!t().binary},get children(){var e=Ef();return e.$$click=()=>h(`md`),y(()=>L(e,p()===`md`?`on`:``)),e}}),n),n.$$click=()=>{h(`code`),ae()||me({path:t().path,content:t().content,truncated:t().truncated})},R(e,j(N,{get when(){return _e(t())},get children(){var e=Df();return e.$$click=()=>h(`edit`),y(()=>L(e,p()===`edit`?`on`:``)),e}}),null),y(()=>L(n,p()===`code`?`on`:``)),e})(),j(N,{get when(){return!t().binary},get fallback(){return Af()},get children(){return j(N,{get when(){return p()===`edit`},get fallback(){return j(N,{get when(){return P(()=>p()===`md`)()&&fe(t().path)},get fallback(){return j(Up,{get path(){return t().path},get content(){return t().content},get html(){return ae()},get pending(){return se()},get truncated(){return!!t().truncated}})},get children(){var e=jf();return y(()=>e.innerHTML=Ie(t().content)),e}})},get children(){var e=kf(),n=e.firstChild,r=n.nextSibling.firstChild,i=r.firstChild,a=r.nextSibling;return n.$$input=e=>le(e.currentTarget.value),I(n,`spellcheck`,!1),R(r,()=>Ep(A().length),i),a.$$click=()=>void ge(),R(a,()=>ue()?`saving…`:`💾 save`),y(()=>a.disabled=ue()||A()===t().content),y(()=>n.value=A()),e}})}})]},get children(){var t=Tf(),n=t.firstChild,r=n.firstChild;return R(t,j(N,{get when(){return u().kind===`image`},get fallback(){return j(N,{get when(){return u().kind===`video`},get fallback(){return(()=>{var t=Nf();return y(()=>I(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t})()},get children(){var t=Mf();return y(()=>I(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t}})},get children(){var t=wf();return y(n=>{var r=`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`,i=u().path.split(`/`).pop();return r!==n.e&&I(t,`src`,n.e=r),i!==n.t&&I(t,`alt`,n.t=i),n},{e:void 0,t:void 0}),t}}),n),R(n,()=>u().kind,r),t}})}})})]}function Up(e){return[j(N,{get when(){return e.html},get fallback(){return P(()=>!!e.pending)()?(()=>{var t=If(),n=t.firstChild.nextSibling;return n.nextSibling,R(t,()=>e.path.split(`/`).pop(),n),t})():(()=>{var t=Lf();return R(t,()=>e.content),t})()},get children(){var t=Pf();return y(()=>t.innerHTML=e.html),t}}),j(N,{get when(){return e.truncated},get children(){return Ff()}})]}var Wp=[{key:`openrouter`,label:`OpenRouter`,url:`https://openrouter.ai/api/v1`,model:`anthropic/claude-sonnet-4`,hint:`400+ models behind one key — teapot sends app-attribution headers automatically`},{key:`orcarouter`,label:`OrcaRouter`,url:`https://api.orcarouter.ai/v1`,model:`orcarouter/auto`,hint:`zero-markup routing gateway — 'orcarouter/auto' grades each prompt and picks the model`},{key:`openai`,label:`OpenAI`,url:`https://api.openai.com/v1`,model:`gpt-4o-mini`},{key:`llamacpp`,label:`llama.cpp server`,url:`http://localhost:8080/v1`,model:``,hint:`free & local — start it with: llama-server -m ./model.gguf (any model name works)`}],Gp={key:`custom`,label:`Custom`,url:``,model:``,hint:`any OpenAI-compatible /v1 endpoint — vLLM, LM Studio, llama.cpp, a company gateway… fill the fields below`};function Kp(e){let[t,n]=v(Wp[0]),[r,i]=v(Wp[0].url),[a,o]=v(``),[s,c]=v(Wp[0].model),[l,u]=v([]),[d,f]=v(`~/teapot-workspace`),[p,m]=v(``),[h,g]=v(!1),[_,x]=v(``),S=e=>{n(e),e.key!==`custom`&&e.url&&(i(e.url),e.model&&c(e.model))};b(()=>{let e=r().trim(),t=a();if(!/^https?:\/\//.test(e)){u([]);return}let n=setTimeout(async()=>{try{let n=await $(`/api/setup/models?baseUrl=${encodeURIComponent(e)}${t?`&apiKey=${encodeURIComponent(t)}`:``}`);u(n.models??[])}catch{u([])}},600);w(()=>clearTimeout(n))});let C=e=>{let t=l().find(t=>t.id===e.trim());if(!t)return``;let n=[];t.contextLength&&n.push(`ctx ${Ep(t.contextLength)} tok`);let r=e=>e===void 0?``:`$${e*1e6>=10?Math.round(e*1e6):+(e*1e6).toFixed(1)}/M`;if(t.pricing){let e=r(t.pricing.prompt),i=r(t.pricing.completion);e&&i?n.push(`${e} in · ${i} out`):(e||i)&&n.push(r(t.pricing.prompt??t.pricing.completion))}return n.join(` · `)},ee=()=>C(s()),te=async t=>{t.preventDefault(),x(``),g(!0);try{await $(`/api/setup`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({baseUrl:r(),apiKey:a()||void 0,model:s(),workspace:d(),...p()?{password:p()}:{}})}),e.onDone()}catch(e){x(e.message),g(!1)}};return(()=>{var e=Vf(),n=e.firstChild.firstChild.nextSibling.nextSibling,u=n.firstChild,g=u.nextSibling,v=g.firstChild.nextSibling,b=v.nextSibling,x=g.nextSibling,C=x.firstChild.nextSibling,w=x.nextSibling,T=w.firstChild.nextSibling,ne=T.nextSibling,E=w.nextSibling,D=E.firstChild.nextSibling,O=D.firstChild.nextSibling,re=D.nextSibling.firstChild.nextSibling,k=E.nextSibling;return n.addEventListener(`submit`,te),R(u,()=>[...Wp,Gp].map(e=>(()=>{var n=Hf();return n.$$click=()=>S(e),R(n,()=>e.label),y(r=>{var i=`presetbtn`+(t().key===e.key?` active`:``),a=e.hint||e.url;return i!==r.e&&L(n,r.e=i),a!==r.t&&I(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})())),R(n,j(N,{get when(){return t().hint},get children(){var e=Rf();return R(e,()=>t().hint),e}}),g),v.$$input=e=>i(e.currentTarget.value),R(b,()=>Wp.map(e=>(()=>{var t=Yl();return y(()=>t.value=e.url),t})())),C.$$input=e=>o(e.currentTarget.value),T.$$input=e=>c(e.currentTarget.value),R(ne,()=>l().map(e=>(()=>{var t=Yl();return y(()=>t.value=e.id),t})())),R(n,j(N,{get when(){return l().length>0},get fallback(){return Uf()},get children(){var e=Bf(),t=e.firstChild;return R(e,()=>l().length,t),R(e,j(N,{get when(){return ee()},get children(){return[` · `,(()=>{var e=zf();return R(e,ee),e})()]}}),null),e}}),E),O.$$input=e=>f(e.currentTarget.value),re.$$input=e=>m(e.currentTarget.value),R(n,j(N,{get when(){return _()},get children(){var e=mf();return R(e,_),e}}),k),R(k,()=>h()?`saving…`:`finish setup`),y(e=>{var n=t().key===`llamacpp`?`(any name — serves whichever gguf is loaded)`:`(type to filter models from the endpoint)`,r=h();return n!==e.e&&I(T,`placeholder`,e.e=n),r!==e.t&&(k.disabled=e.t=r),e},{e:void 0,t:void 0}),y(()=>v.value=r()),y(()=>C.value=a()),y(()=>T.value=s()),y(()=>O.value=d()),y(()=>re.value=p()),e})()}function qp(e){let[t,n]=v(Object.entries(e.cfg.providers??{}).map(([e,t])=>({name:e,baseUrl:t.baseUrl??``,apiKey:t.apiKey??``,model:t.model??``}))),[r,i]=v(e.cfg.defaultProvider??``),a=()=>e.cfg.defaultProvider??``,o=()=>{let e=[...new Set(t().map(e=>e.name.trim()).filter(Boolean))],n=r();return n&&!e.includes(n)&&e.push(n),e},s=()=>{let e=r();return e?t().some(t=>t.name.trim()===e)?``:e:``},[c,l]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[u,d]=v(e.cfg.progressMinChars??4e3),[f,p]=v(e.cfg.contextTokenBudget==null?null:Math.round(e.cfg.contextTokenBudget/1e3)),[m,h]=v(e.cfg.contextWindowTokens?Math.round(e.cfg.contextWindowTokens/1e3):0),[g,_]=v(e.cfg.maxSpawnDepth??3),[b,x]=v((e.cfg.tasks??[]).map(e=>({...e}))),[S,C]=v(``),w=()=>(e.cfg.agents??[]).map(e=>e.id),ee=()=>{let e={};for(let n of t()){if(!n.name.trim())return C(`provider name is required`),null;if(n.baseUrl&&!/^https?:\/\//.test(n.baseUrl))return C(`provider ${n.name}: baseUrl must start with http(s)://`),null;e[n.name.trim()]={baseUrl:n.baseUrl,...n.apiKey?{apiKey:n.apiKey}:{},...n.model?{model:n.model}:{}}}return e},te=async t=>{t.preventDefault(),C(``);let n=ee();if(!n)return;let i=b().filter(e=>e.id?.trim()||e.prompt?.trim()).map((e,t)=>({id:e.id?.trim()||`task-${t+1}`,agent:e.agent,schedule:e.schedule,prompt:e.prompt,...e.forked?{forked:!0}:{}}));for(let e of i){if(!e.agent){C(`task "${e.id}": agent is required`);return}if(!e.schedule?.trim()){C(`task "${e.id}": schedule is required`);return}}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:n,defaultProvider:r()||void 0,progressIntervalMs:Math.max(1,c())*6e4,progressMinChars:Math.max(100,u()),...f()==null?{}:{contextTokenBudget:Math.max(1,f())*1e3},...m()>0?{contextWindowTokens:m()*1e3}:{},maxSpawnDepth:Math.max(0,g()),tasks:i})}),e.onSaved(),e.onClose()}catch(e){C(e.message)}},T=(e,t,n,r)=>(()=>{var i=Wf(),a=i.firstChild;return I(i,`title`,r),R(i,e,a),a.$$input=e=>n(Number(e.currentTarget.value)),a.value=t,i})();return j(Mp,{title:`settings`,get onClose(){return e.onClose},get children(){var v=Kf(),ee=v.firstChild,ne=ee.firstChild.nextSibling,E=ne.nextSibling;E.firstChild;var D=E.nextSibling.firstChild.firstChild.nextSibling;D.firstChild;var O=ee.nextSibling,re=O.firstChild.nextSibling,k=re.firstChild,ie=k.firstChild.nextSibling,ae=O.nextSibling,oe=ae.firstChild.nextSibling,se=ae.nextSibling;se.firstChild;var ce=se.nextSibling,A=ce.firstChild.nextSibling.firstChild;A.firstChild;var le=A.nextSibling,ue=ce.nextSibling;return v.addEventListener(`submit`,te),R(ee,j(be,{get each(){return t()},children:(e,r)=>(()=>{var i=qf(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling;return a.$$input=e=>n(t().map((t,n)=>n===r?{...t,name:e.currentTarget.value}:t)),o.$$input=e=>n(t().map((t,n)=>n===r?{...t,baseUrl:e.currentTarget.value}:t)),s.$$input=e=>n(t().map((t,n)=>n===r?{...t,apiKey:e.currentTarget.value}:t)),c.$$input=e=>n(t().map((t,n)=>n===r?{...t,model:e.currentTarget.value}:t)),l.$$click=()=>n(t().filter((e,t)=>t!==r)),y(()=>a.value=e().name),y(()=>o.value=e().baseUrl),y(()=>s.value=e().apiKey),y(()=>c.value=e().model),i})()}),ne),ne.$$click=()=>n([...t(),{name:``,baseUrl:``,apiKey:``,model:``}]),R(E,j(M,{each:Wp,children:e=>(()=>{var a=Jf();return a.firstChild,a.$$click=()=>{let a=t().filter(t=>t.name!==e.key);n([...a,{name:e.key,baseUrl:e.url,apiKey:``,model:e.model}]),r()||i(e.key)},R(a,()=>e.label,null),y(()=>I(a,`title`,`fill a ${e.label} row — ${e.url}${e.model?` (model: ${e.model})`:``}`)),a})()}),null),D.addEventListener(`change`,e=>i(e.currentTarget.value)),R(D,j(M,{get each(){return o()},children:e=>(()=>{var t=Yl();return t.value=e,R(t,e),t})()}),null),R(ee,j(N,{get when(){return s()},get children(){var e=Gf(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling;return R(t,s),R(e,()=>s()===a()?` — the dropdown above cannot show it.`:` — it was replaced by your selection.`,n),R(r,s),e}}),null),R(re,()=>T(`progress interval (min)`,c(),e=>l(e),`how often the harness asks for a progress report`),k),R(re,()=>T(`progress min chars`,u(),e=>d(e),`progress prompts wait for this much real output`),k),ie.$$input=e=>p(e.currentTarget.value===``?null:Number(e.currentTarget.value)),R(re,()=>T(`context window (k tok)`,m(),e=>h(e),`model's real window — 0/blank hides the % gauge`),null),R(re,()=>T(`max spawn depth`,g(),e=>_(e),`sub-agent nesting limit (0 = no spawning)`),null),R(ae,j(N,{get when(){return b().length>0},get children(){return j(be,{get each(){return b()},children:(e,t)=>(()=>{var n=Yf(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.firstChild,l=s.nextSibling,u=r.nextSibling;return i.$$input=e=>x(b().map((n,r)=>r===t?{...n,id:e.currentTarget.value}:n)),a.$$input=e=>x(b().map((n,r)=>r===t?{...n,agent:e.currentTarget.value}:n)),o.$$input=e=>x(b().map((n,r)=>r===t?{...n,schedule:e.currentTarget.value}:n)),c.addEventListener(`change`,e=>x(b().map((n,r)=>r===t?{...n,forked:e.currentTarget.checked}:n))),l.$$click=()=>x(b().filter((e,n)=>n!==t)),u.$$input=e=>x(b().map((n,r)=>r===t?{...n,prompt:e.currentTarget.value}:n)),y(()=>i.value=e().id),y(()=>a.value=e().agent),y(()=>o.value=e().schedule),y(()=>c.checked=!!e().forked),y(()=>u.value=e().prompt),n})()})}}),oe),oe.$$click=()=>x([...b(),{id:``,agent:w()[0]??``,schedule:`every 30m`,prompt:``}]),R(se,j(M,{get each(){return e.cfg.agents??[]},children:e=>(()=>{var t=Zf(),n=t.firstChild,r=n.nextSibling;return R(n,()=>e.id),R(r,()=>e.workspace),R(t,j(N,{get when(){return e.parent},get children(){var t=Xf();return t.firstChild,R(t,()=>e.parent,null),t}}),null),t})()}),null),R(A,()=>e.cfg.version??`unknown`,null),le.$$click=async e=>{try{C(``);let t=e.currentTarget;t.disabled=!0,t.textContent=`updating…`;let n=await $(`/api/update/restart`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`restart failed`);t.textContent=`restarting…`;let r=!1;for(let e=0;e<90&&!r;e++){await new Promise(e=>setTimeout(e,1e3));try{let e=await $(`/api/version`);e.version&&e.version!==`0.25.2`&&(r=!0,window.location.reload())}catch{}}if(!r)throw Error(`restart timeout — new server did not come up`)}catch(e){C(e.message)}finally{e.currentTarget.disabled=!1,e.currentTarget.textContent=`update & restart`}},R(v,j(N,{get when(){return S()},get children(){var e=mf();return R(e,S),e}}),ue),y(()=>D.value=r()),y(()=>ie.value=f()??``),v}})}we([`click`,`pointerdown`,`dblclick`,`input`,`keydown`]),Ce(()=>j(gp,{}),document.getElementById(`root`));export{nl as t};
30
+ //# sourceMappingURL=index-DDx2AmuD.js.map