teapot-coding-agent 0.11.0 → 0.11.1

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.11.0",
3
+ "version": "0.11.1",
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 +1,2 @@
1
- var e=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(2,Math.floor(u/e.css.cell.width)),rows:Math.max(1,Math.floor(l/e.css.cell.height))}}};export{e as FitAddon};
1
+ var e=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(2,Math.floor(u/e.css.cell.width)),rows:Math.max(1,Math.floor(l/e.css.cell.height))}}};export{e as FitAddon};
2
+ //# sourceMappingURL=addon-fit-DIOBYJe3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon-fit-DIOBYJe3.js","names":[],"sources":["../../node_modules/.pnpm/@xterm+addon-fit@0.11.0/node_modules/@xterm/addon-fit/lib/addon-fit.mjs"],"sourcesContent":["/**\n * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n *\n * Originally forked from (with the author's permission):\n * Fabrice Bellard's javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n */\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nvar h=2,_=1,o=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(r.getPropertyValue(\"height\")),a=Math.max(0,parseInt(r.getPropertyValue(\"width\"))),i=window.getComputedStyle(this._terminal.element),n={top:parseInt(i.getPropertyValue(\"padding-top\")),bottom:parseInt(i.getPropertyValue(\"padding-bottom\")),right:parseInt(i.getPropertyValue(\"padding-right\")),left:parseInt(i.getPropertyValue(\"padding-left\"))},m=n.top+n.bottom,d=n.right+n.left,c=l-m,p=a-d-s;return{cols:Math.max(h,Math.floor(p/t.css.cell.width)),rows:Math.max(_,Math.floor(c/t.css.cell.height))}}};export{o as FitAddon};\n//# sourceMappingURL=addon-fit.mjs.map\n"],"x_google_ignoreList":[0],"mappings":"AAgBA,IAAY,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,kBAAkB,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,WAAW,MAAM,EAAE,IAAI,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE,KAAK,UAAU,OAAO,KAAK,UAAU,OAAO,EAAE,MAAM,KAAK,UAAU,OAAO,EAAE,QAAQ,EAAE,eAAe,MAAM,EAAE,KAAK,UAAU,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,UAAU,QAAQ,cAAc,OAAO,IAAI,EAAE,KAAK,UAAU,MAAM,eAAe,WAAW,GAAG,EAAE,IAAI,KAAK,QAAQ,GAAG,EAAE,IAAI,KAAK,SAAS,EAAE,OAAO,IAAI,EAAE,KAAK,UAAU,QAAQ,aAAa,EAAE,EAAE,KAAK,UAAU,QAAQ,eAAe,OAAO,GAAG,EAAE,OAAO,iBAAiB,KAAK,UAAU,QAAQ,aAAa,EAAE,EAAE,SAAS,EAAE,iBAAiB,QAAQ,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,iBAAiB,OAAO,CAAC,CAAC,EAAE,EAAE,OAAO,iBAAiB,KAAK,UAAU,OAAO,EAAE,EAAE,CAAC,IAAI,SAAS,EAAE,iBAAiB,aAAa,CAAC,EAAE,OAAO,SAAS,EAAE,iBAAiB,gBAAgB,CAAC,EAAE,MAAM,SAAS,EAAE,iBAAiB,eAAe,CAAC,EAAE,KAAK,SAAS,EAAE,iBAAiB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,EAAE,IAAI,KAAK,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
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=ue,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(()=>O(o)));d=o,p=null;try{return E(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[ie.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),ae(n,e))]}function y(e,t,n){T(se(e,t,!1,c))}function b(e,t,n){s=de;let r=se(e,t,!1,c),i=re&&ne(re);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):T(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=se(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,T(r),ie.bind(r)}function S(e){if(p===null)return e();let t=p;p=null;try{return e()}finally{p=t}}function ee(e){b(()=>S(e))}function C(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}var[te,w]=v(!1);function ne(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var re;function ie(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)T(this);else{let e=m;m=null,E(()=>D(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 ae(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&&E(()=>{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&&fe(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function T(e){if(!e.fn)return;O(e);let t=g;oe(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{E(()=>{f&&(f.running=!0),p=d=e,oe(e,e.tValue,t),p=d=null},!1)})}function oe(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(O),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(O),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?ae(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 se(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 ce(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return D(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)T(e);else if((t?e.tState:e.state)===l){let t=m;m=null,E(()=>D(e,n[0]),!1),m=t}}}function E(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return le(n),t}catch(e){n||(h=null),m=null,me(e)}}function le(e){if(m&&=(ue(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,E(()=>{for(let e of n)O(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)O(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}w(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,w(!0);return}}let n=h;h=null,n.length&&E(()=>s(n),!1),t&&t()}function ue(e){for(let t=0;t<e.length;t++)ce(e[t])}function de(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:ce(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++)ce(t[r])}function D(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)&&ce(i):e===l&&D(i,t)}}}function fe(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&&fe(r))}}function O(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--)O(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)k(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)O(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 k(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)k(e.owned[t])}function pe(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function A(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=pe(e);if(!n)throw r;h?h.push({fn(){A(r,n,t)},state:c}):A(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 C(()=>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 j(e,t){return S(()=>e(t||{}))}var M=e=>`Stale read from <${e}>.`;function N(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(_e(()=>e.each,e.children,t||void 0))}function P(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 M(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var F=e=>x(()=>e());function ve(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 I=`_$DX_DELEGATE`;function ye(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():B(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function L(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 be(e,t=window.document){let n=t[I]||(t[I]=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,we))}}function R(e,t,n){V(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function z(e,t){V(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function xe(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 Se(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function Ce(e,t,n){return S(()=>e(t,n))}function B(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return H(e,t,r,n);y(r=>H(e,t(),r,n),r)}function V(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function we(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 H(e,t,n,r,i){let a=V(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=U(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=U(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=H(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(Te(o,t,n,i))return y(()=>n=H(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=U(e,n,r),s)return n}else c?n.length===0?Ee(e,o,r):ve(e,n,o):(n&&U(e),Ee(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=U(e,n,r,t);U(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function Te(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=Te(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=Te(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 Ee(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function U(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 W=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/;function De(e){return G(ke(e.replace(/\r\n/g,`
2
+ `)).split(`
3
+ `))}function G(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(/^```\w*\s*$/.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>${G(r)}</blockquote>`);continue}if(o.includes(`|`)&&n+1<e.length&&Oe(e[n+1])){let r=K(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`),i=K(o);n+=2;let s=[];for(;n<e.length&&/\S/.test(e[n])&&e[n].includes(`|`);)s.push(K(e[n])),n++;let c=(e,t,n)=>{let i=r[t];return`<${n}${i&&i!==`left`?` style="text-align:${i}"`:``}>${a(e)}</${n}>`};t.push(`<div class="tbl"><table><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(W.test(o)){t.push(i(r(o.match(W)[1])));continue}if(/^\s*$/.test(o)){n++;continue}let c=[];for(;n<e.length&&!/^\s*$/.test(e[n])&&!/^#{1,6}\s/.test(e[n])&&!/^```/.test(e[n])&&!/^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/.test(e[n])&&!/^\s*&gt;/.test(e[n])&&!W.test(e[n])&&!(e[n].includes(`|`)&&n+1<e.length&&Oe(e[n+1]));)c.push(e[n++]);t.push(`<p>${c.map(a).join(`<br>`)}</p>`)}return t.join(`
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(W);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])&&!W.test(e[n])&&!/^#{1,6}\s/.test(e[n])&&!/^```/.test(e[n])&&!/^\s*&gt;/.test(e[n]);)d+=` `+e[n].trim(),n++;let f=``,p=e[n]?.match(W);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(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\u0000${t.length-1}\u0000`)),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(/\u0000(\d+)\u0000/g,(e,n)=>t[+n])}}function K(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1));let n=[],r=``;for(let e=0;e<t.length;e++){if(t[e]===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(t[e]===`|`&&e===t.length-1)break;if(t[e]===`|`){n.push(r.trim()),r=``;continue}r+=t[e]}return n.push(r.trim()),n.filter((e,r)=>!(e===``&&r===n.length-1&&t.endsWith(`|`)))}function Oe(e){let t=e.trim();if(!t.includes(`|`)||!t.includes(`-`))return!1;let n=K(t);return n.every(e=>/^:?-+:?$/.test(e))&&n.some(e=>e!==``)}function ke(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var Ae=`modulepreload`,je=function(e){return`/`+e},Me={},Ne=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=je(t,n),t=s(t),t in Me)return;Me[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ae,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Pe=L(`<br>`),Fe=L(`<span class="badge queued">⏳ <!> queued`),Ie=L(`<span class="badge cron">⏰ `),Le=L(`<span class=sub>ℹ`),Re=L(`<header class=chan-head><span class=hash>#</span><span class=title></span><span></span><span class=sub> · <!>/<!> · turns <!> · tools </span><span style=margin-left:auto;display:flex;gap:4px><button class=iconbtn title="terminal (t)">⌨</button><button class=iconbtn title="toggle details panel (d)">▤`),ze=L(`<details class=reasoning><summary>💭 reasoning</summary><div class=mono>`),Be=L(`<div class=content>`),Ve=L(`<div class="msg live"><div class=avatar style="background:#5865f233;border:1px solid #5865f266">🫖</div><div class=msg-body><div class=msg-head><span class=author style=color:var(--acc)>agent</span><span class=ts>streaming…`),He=L(`<div class=feed>`),Ue=L(`<button class=jump>↓ `),We=L(`<div class=termdrawer><div class=termbar><span>⌨ terminal — <span class=mono></span></span><button class=iconbtn title="close terminal (t)">✕</button></div><div class=termhost>`),Ge=L(`<div class=cmds>`),Ke=L(`<div class=composer><form><textarea rows=1></textarea><button type=submit>send</button></form><div class=hint>`),qe=L(`<h3>🎛 session`),Je=L(`<div class="card sesscard"><div class=sessrow><span class=k>agent</span><b></b><span></span></div><div class=sessrow><span class=k>workspace</span><span class="mono ellip"></span></div><div class=sessrow><span class=k>session</span><span class=mono>/`),Ye=L(`<h3>🧦 model`),Xe=L(`<div class=modelbox><select title="provider (OpenAI-compatible endpoint)"></select><div style=display:flex;gap:4px><input type=text list=model-list style=flex:1;min-width:0><datalist id=model-list></datalist><button title="apply to this session — takes effect from the agent's next turn">apply</button></div><div class=meta>current: `),Ze=L(`<h3>⏯ controls`),Qe=L(`<button class=danger title="interrupt: aborts the current LLM call; the running tool finishes first">■ stop`),$e=L(`<div class=btnrow><button title="branch off the conversation here — try things without disturbing the main line">⑂ fork</button><button title="remove agent from teapot (session log stays on disk)">🗑 remove`),et=L(`<div class=ctrlrow><label title="after each round the agent keeps working toward its goal without waiting for input; sending a prompt also starts an idle agent"><input type=checkbox>auto-continue</label><span class=muted>loops while the goal is active`),tt=L(`<h3>🎯 goal <span>`),nt=L(`<form style=display:flex;flex-direction:column;gap:6px;margin-bottom:6px><textarea id=goal-input rows=3 placeholder="set new goal…"style="background:var(--bg-darkest);border:none;border-radius:6px;padding:6px 8px;color:var(--fg);font:inherit;width:100%;resize:vertical"></textarea><div style=display:flex;justify-content:flex-end;align-items:center;gap:10px><label class=muted title="queue a harness prompt telling the agent about the new goal at its next turn boundary"style=display:flex;align-items:center;gap:4px;font-size:11.5px;white-space:nowrap;cursor:pointer><input id=goal-notify type=checkbox checked> notify agent</label><button type=submit style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:4px 12px;cursor:pointer">✓ save`),rt=L(`<div class=card>`),it=L(`<div class=muted style=font-size:11px;margin-top:4px>stored with the session · the model reads it via get_goal() ·`),at=L(`<h3>✅ tasks <span class=muted style=text-transform:none;letter-spacing:0>· todo.md, editable by you and the agent`),ot=L(`<textarea id=todo-input class=mono rows=5 placeholder="- task one
6
+ - task two"title="shared with the agent — 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">`),st=L(`<div style=display:flex;justify-content:flex-end;align-items:center;gap:10px;margin-top:4px><label class=muted title="queue a harness prompt telling the agent the task list changed"style=display:flex;align-items:center;gap:4px;font-size:11.5px;white-space:nowrap;cursor:pointer><input id=todo-notify type=checkbox checked> notify agent</label><button style="background:var(--ok);border:none;border-radius:6px;color:#fff;padding:4px 12px;cursor:pointer">✓ save tasks`),ct=L(`<h3>📈 progress`),lt=L(`<h3>📊 runtime`),ut=L(`<div class="card muted">turns <!> · tools <!> · compacted <!>
7
+ tokens in/out <!>/`),dt=L(`<h3>🌿 branches <span class=muted style=text-transform:none;letter-spacing:0>· click to filter the feed`),ft=L(`<h3>⏰ schedule <span class=muted style=text-transform:none;letter-spacing:0>· cron tasks, all agents · edit in settings`),pt=L(`<div><nav class=sidebar><h1>🫖 teapot<span></span><span style=float:right;display:flex;gap:4px><button class=iconbtn title="new agent">+</button><button class=iconbtn title=settings>⚙</button></span></h1><div class=agent-list></div><div class=metrics></div></nav><section class=channel></section><aside>`),mt=L(`<span class=mini-cron>⏰`),ht=L(`<span title="goal done">✓`),gt=L(`<div><span></span><span>`),_t=L(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),vt=L(`<div class=muted style=display:grid;place-items:center;height:100%>no events yet — say something or press ▶ start`),yt=L(`<div class="content muted">thinking…`),bt=L(`<div class=cmdrow><b></b><span class=muted>`),xt=L(`<option>`),St=L(`<button class=runbtn title="run toward the goal (starts the loop)">▶ start`),Ct=L(`<div class=muted>none yet — the harness asks for a report after real activity, and the agent can report_progress anytime`),wt=L(`<div class=progrow><b>recent</b><span>`),Tt=L(`<div class="progrow warn"><b>⚠ problems</b><span>`),Et=L(`<div class=progrow><b>next</b><span>`),Dt=L(`<div class=progrow><b>goal</b><span>`),Ot=L(`<div class="card prog"><div class=progrow><b>doing</b><span></span></div><div class="meta muted">`),kt=L(`<div><span></span><span> events`),At=L(`<div class=muted>no scheduled tasks — add them in ⚙ settings ("scheduled tasks")`),jt=L(`<span title="runs on a forked branch so chatter stays off the main line">⑂`),Mt=L(`<div><div class=sched-top><b></b><span class=muted>@</span></div><div class="sched-meta mono"> → next </div><div class="sched-prompt muted">`),Nt=L(`<div><div style=font-size:12.5px;margin-bottom:4px> event(s) came after this prompt — what should happen to them on the new branch?</div><label style=display:flex;gap:6px;align-items:center;font-size:13px;color:var(--fg)><input type=radio name=tail>summarize them into a note the agent can still read</label><label style=display:flex;gap:6px;align-items:center;font-size:13px;color:var(--fg)><input type=radio name=tail>discard them entirely (clean timeline)`),Pt=L(`<form style=display:flex;flex-direction:column;gap:10px><textarea id=edit-text class="mono w100"rows=6></textarea><div style=display:flex;justify-content:flex-end;gap:8px><button type=button>cancel</button><button type=submit style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:6px 12px;cursor:pointer">⑂ fork & resend`),Ft=L(`<div class=mono>`),It=L(`<pre class="mono toolbody">`),Lt=L(`<div class=meta>ms`),Rt=L(`<div class=meta>waiting for output…`),zt=L(`<div class=meta>`),q=L(`<div class=meta>writing…`),Bt=L(`<pre class="mono toolbody del">`),Vt=L(`<pre class="mono toolbody add">`),J=L(`<div class=meta> · <!>ms`),Ht=L(`<div class=meta>applying…`),Ut=L(`<pre class="mono toolbody patch">`),Wt=L(`<div>`),Gt=L(`<div class=meta>validating…`),Kt=L(`<div class=meta><a target=_blank rel="noopener noreferrer">open ↗`),qt=L(`<div class=meta>loading…`),Jt=L(`<div class=meta>bundled: `),Yt=L(`<div class=meta>saving…`),Xt=L(`<details><summary><b>⚙ </b><span class=meta>`),Zt=L(`<div class=divider-msg>⑂ forked from <!> → `),Qt=L(`<div class=divider-msg>🎯 goal <!>: `),$t=L(`<div class=divider-msg>✅ tasks updated (<!>)`),en=L(`<div> → `),tn=L(`<div class=avatar>`),nn=L(`<button class=editbtn title="edit this prompt — forks the conversation here (later events are dropped or summarized)">✎ edit`),rn=L(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),an=L(`<div><div class=msg-body>`),on=L(`<span style=width:38px>`),Y=L(`<div class=interrupted>⚠ interrupted — partial output kept`),sn=L(`<div class=msgfoot><span>copy summary`),cn=L(`<details><summary><span class=meta></span></summary><div class=mono></div><div class=meta>ms`),X=L(`<div class=meta>⚠ `),ln=L(`<div class=meta>→ `),un=L(`<div class=embed style=border-color:var(--ok)><div>📈 `),dn=L(`<div class="embed fail"><div class=mono>⚠ `),fn=L(`<div class="content muted">`),pn=L(`<button class=copybtn title="copy to clipboard">`),mn=L(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),hn=L(`<span style=color:var(--err);font-size:13px>`),gn=L(`<form style=display:flex;flex-direction:column;gap:10px><label>workspace directory<div style=display:flex;gap:6px><input type=text class="w100 mono"><button type=button>go</button><button type=button>↑</button></div></label><div class=dirlist></div><div style=display:flex;gap:10px><label style=flex:1>agent name <input type=text placeholder="(directory name)"></label><label>provider<select></select></label><label style=flex:1>model <input type=text placeholder="(provider default)"></label></div><button type=submit style=align-self:flex-end>create & start`),_n=L(`<div class=direntry>📁 `),vn=L(`<form style=display:flex;flex-direction:column;gap:10px><label>providers (<!>)<textarea rows=8 class="mono w100"></textarea></label><div style=display:flex;gap:10px><label style=flex:1>default provider <input type=text></label><label>progress interval (min) <input type=number min=1 style=width:90px></label></div><label>scheduled tasks (JSON array)<textarea rows=7 class="mono w100"></textarea></label><button type=submit style=align-self:flex-end>save`),yn={prompt:{name:`you`,icon:`🟧`,color:`#faa81a`},user:{name:`you`,icon:`🟧`,color:`#faa81a`},message:{name:`agent`,icon:`🫖`,color:`#5865f2`},progress:{name:`progress`,icon:`📈`,color:`#3ba55d`}},bn={name:`harness`,icon:`📣`,color:`#3ba55d`},xn=e=>{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`?yn.prompt:t.startsWith(`scheduler:`)?{name:t.slice(10),icon:`📣`,color:`#3ba55d`}:bn}return yn[e.type]??{name:e.type,icon:`•`,color:`#9298a5`}},Sn=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`,`state`,`error`,`fork`,`goal`,`todo`]),Cn=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function Z(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){let t=``;try{t=(await i.json())?.error??``}catch{}throw Error(t||`${e}: HTTP ${i.status}`)}return i.json()}var wn=location.hash.match(/[#&]token=([^&]+)/);wn&&(localStorage.setItem(`teapot.token`,decodeURIComponent(wn[1])),history.replaceState(null,``,location.pathname+location.search));var Tn=()=>{let e=localStorage.getItem(`teapot.token`);return e?`?token=${encodeURIComponent(e)}`:``};function En(){let[e,t]=v([]),[n,r]=v(null),[i,a]=v([]),[o,s]=v(0),[c,l]=v([]),[u,d]=v(null),[f,p]=v(``),[m,h]=v(localStorage.getItem(`teapot.autostart`)!==`0`),g=e=>{h(e),localStorage.setItem(`teapot.autostart`,e?`1`:`0`)},[_,S]=v({providers:{}}),[te,w]=v(!1),[ne,re]=v(!1),[ie,ae]=v(localStorage.getItem(`teapot.panel`)===null?window.innerWidth>1100:localStorage.getItem(`teapot.panel`)===`1`),T=()=>{let e=!ie();ae(e),localStorage.setItem(`teapot.panel`,e?`1`:`0`)},[oe,se]=v(``),[ce,E]=v(``),[le,ue]=v([]),de=()=>Object.keys(_().providers??{});async function D(e){if(e)try{let t=await Z(`/api/models?provider=${encodeURIComponent(e)}`);ue(t.models??[])}catch{ue([])}}b(()=>{let e=M();e&&(se(e.provider||_().defaultProvider||de()[0]||``),E(``),D(oe()))});let[fe,O]=v(!0),[k,pe]=v(0),[A,me]=v(null),[he,ge]=v(``),_e;b(()=>{if(!A()){clearTimeout(_e),_e=void 0,ge(``);return}_e||=setTimeout(()=>{_e=void 0,ge(A()?.text??``)},60)}),C(()=>clearTimeout(_e));let M=x(()=>e().find(e=>e.id===n())),[ve,I]=v(null),[ye,L]=v([]),be=x(()=>{let e=new Map,t=new Set,n=new Map;for(let r of i())if(Sn.has(r.type)){if(r.type===`tool_call`){let e=n.get(r.data.callId)??[];e.push(r),n.set(r.data.callId,e)}else if(r.type===`tool_result`){let i=n.get(r.data.callId)?.shift();i&&(e.set(i.id,r),t.add(r.id))}}return{resFor:e,consumed:t}}),Se=x(()=>{let{consumed:e}=be(),t=i().filter(t=>Sn.has(t.type)?t.type===`tool_result`?!e.has(t.id):t.type!==`message`||String(t.data?.content??``).trim()!==``||String(t.data?.reasoning??``).trim()!==``||!!t.data?.final:!1),n=ye().filter(e=>!t.some(t=>t.type===`prompt`&&t.data?.source===`user`&&t.data?.text===e.text&&new Date(t.ts).getTime()>=e.at-1e3)).map(e=>({id:e.id,seq:0,ts:new Date(e.at).toISOString(),session:M()?.session??``,branch:M()?.branch??`br0`,parent:null,type:`prompt`,data:{source:`user`,text:e.text,pending:!0}}));return[...t,...n]}),V=()=>Z(`/api/config`).then(S).catch(()=>{}),[we,H]=v(``),[Te,Ee]=v(!1),U=``;b(()=>{let t=n(),r=e().find(e=>e.id===t)?.todo??``;t&&t!==U?(U=t,Ee(!1),H(r)):t&&!Te()&&H(r)});let W=async()=>{let e=document.getElementById(`todo-notify`)?.checked??!0;if(n())try{await Z(`/api/agents/${n()}/todo`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:we(),notify:e})}),Ee(!1),Y(`tasks saved${e&&we().trim()?` & notification queued`:``}`),G()}catch(e){Y(`save failed: ${e.message}`)}},G=()=>Z(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),K=()=>Z(`/api/metrics`).then(d).catch(()=>{}),[Oe,ke]=v([]),Ae=()=>Z(`/api/tasks`).then(e=>ke(e.tasks)).catch(()=>{}),je=e=>Oe().filter(t=>t.agent===e),[Me,Ft]=v(null);async function It(e){try{let t=Me(),[n,r]=await Promise.all([Z(`/api/agents/${e}/events?limit=300${t?`&branch=${encodeURIComponent(t)}`:``}`),Z(`/api/agents/${e}/branches`)]);a(n.events),s(n.total??n.events.length),l(r.branches)}catch{}}function Lt(){return document.querySelector(`.feed`)}function Rt(){let e=Lt();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80}function zt(e=!1){let t=Lt();t&&(e||fe())&&(t.scrollTop=t.scrollHeight,pe(0))}async function q(e,t=!0){r(e),me(null),Ft(null),L([]),localStorage.setItem(`teapot.session`,e),Gt(e,t),Z(`/api/agents/${e}/load`,{method:`POST`}).then(G).catch(()=>{}),await It(e),requestAnimationFrame(()=>zt(!0))}let[Bt,Vt]=v(!1),J=null,Ht=null;C(()=>J?.close());function Ut(){let e=location.protocol===`https:`?`wss://`:`ws://`;J=new WebSocket(`${e}${location.host}/api/ws${Tn()}`),J.onopen=()=>Vt(!0),J.onclose=()=>{Vt(!1),setTimeout(Ut,1500)},J.onerror=()=>J?.close();let t=new Set([`state`,`usage`,`session_start`]),r=null;J.onmessage=e=>{let a=JSON.parse(e.data);if(a.kind!==`ping`&&a.kind!==`pong`){if(a.kind===`llm-delta`){r={id:a.agentId,at:Date.now()},a.agentId===n()&&me({text:a.text??``,reasoning:a.reasoning??``});return}a.kind===`event`&&t.has(a.event?.type)||(Ht||=setTimeout(async()=>{if(Ht=null,await G(),await K(),n()){let e=i().at(-1)?.id,t=o(),a=Date.now();await It(n()),i().at(-1)?.id!==e&&(r?.id===n()&&r.at>=a||me(null),Rt()?zt(!0):pe(k()+Math.max(0,o()-t))),L(e=>e.filter(e=>!i().some(t=>t.type===`prompt`&&t.data?.text===e.text&&new Date(t.ts).getTime()>=e.at-1e3)))}},400))}}}let Wt=()=>decodeURIComponent(location.pathname.split(`/`)[2]??``);function Gt(e,t=!0){let n=`/session/${encodeURIComponent(e)}`;t?history.pushState(null,``,n):history.replaceState(null,``,n)}window.addEventListener(`popstate`,()=>{let t=Wt();t&&e().some(e=>e.id===t)&&t!==n()&&q(t,!1)}),b(()=>{let e=M();document.title=e?`${e.status===`running`?`▶ `:e.status===`error`?`⚠ `:``}${e.id} · teapot`:`teapot`}),window.addEventListener(`keydown`,t=>{let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable)){t.key===`Escape`&&r.blur();return}if(t.key===`Escape`){if(te()){w(!1);return}if(ne()){re(!1);return}let e=M();if(e?.status===`running`){Z(`/api/agents/${e.id}/stop`,{method:`POST`}).then(G);return}ie()&&window.innerWidth<=1100&&ae(!1);return}if(!(te()||ne())){if(t.key===`/`)t.preventDefault(),document.querySelector(`.composer textarea`)?.focus();else if(t.key===`d`)T();else if(t.key===`t`)Jt();else if(t.key===`ArrowDown`||t.key===`ArrowUp`){let r=e();if(r.length===0)return;t.preventDefault();let i=r.findIndex(e=>e.id===n()),a=t.key===`ArrowDown`?Math.min(i+1,r.length-1):Math.max(i-1,0);a!==i&&q(r[a].id)}}});let[Kt,qt]=v(localStorage.getItem(`teapot.term`)===`1`),Jt=()=>{let e=!Kt();qt(e),localStorage.setItem(`teapot.term`,e?`1`:`0`)},Yt=null,Xt=null,Zt=null,Qt=null,$t={cols:0,rows:0},en=null;function tn(){Qt?.disconnect(),Qt=null,Zt?.close(),Zt=null,Xt?.dispose(),Xt=null}function nn(e){tn(),Yt&&Promise.all([Ne(()=>import(`./xterm-C3BHN0de.js`),[]),Ne(()=>import(`./addon-fit-DIOBYJe3.js`),[])]).then(([{Terminal:t},{FitAddon:n}])=>{let r=new t({cursorBlink:!0,fontSize:12.5,fontFamily:`ui-monospace, Menlo, Consolas, monospace`,theme:{background:`#0d0e12`,foreground:`#dcdee4`}}),i=new n;r.loadAddon(i),r.open(Yt),i.fit(),Xt=r;let a=location.protocol===`https:`?`wss://`:`ws://`,o=new WebSocket(`${a}${location.host}/api/agents/${e}/term${Tn()}`);Zt=o,o.onmessage=e=>{let t=JSON.parse(e.data);t.kind===`data`?r.write(t.data):t.kind===`exit`&&r.write(`\r\n\x1b[2m[terminal exited ${t.code??``}]\x1b[0m\r\n`)},r.onData(e=>{o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({kind:`input`,data:e}))});let s=()=>{try{i.fit()}catch{}let{cols:e,rows:t}=r;(e!==$t.cols||t!==$t.rows)&&o.readyState===WebSocket.OPEN&&($t={cols:e,rows:t},o.send(JSON.stringify({kind:`resize`,cols:e,rows:t})))};Qt=new ResizeObserver(()=>{en&&clearTimeout(en),en=setTimeout(s,300)}),Qt.observe(Yt),setTimeout(s,50)})}b(()=>{let e=n();!Kt()||!e?tn():requestAnimationFrame(()=>e&&nn(e))}),C(tn),ee(()=>{V(),G().then(()=>{let t=Wt()||localStorage.getItem(`teapot.session`)||``,n=e().find(e=>e.id===t)??e()[0];n&&q(n.id,!1)}),K(),Ae(),Ut();let t=setInterval(()=>{K(),Ae()},3e4);C(()=>clearInterval(t))});let[rn,an]=v(``),on,Y=e=>{an(e),clearTimeout(on),on=setTimeout(()=>an(``),3200)},sn=[{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`}],cn=()=>{let e=f();return!e.startsWith(`/`)||e.includes(` `)||e.includes(`
8
+ `)?[]:sn.filter(t=>t.cmd.slice(1).startsWith(e.slice(1).toLowerCase()))},X,ln=()=>{X&&(X.style.height=`auto`,X.style.height=`${Math.min(X.scrollHeight,160)}px`)};b(()=>{f(),ln()});let un=async e=>{e.preventDefault();let t=n(),r=f().trim();if(!(!t||!r)){if(r.startsWith(`/`)){let e=r.indexOf(` `),n=(e===-1?r.slice(1):r.slice(1,e)).toLowerCase(),i=e===-1?``:r.slice(e+1).trim(),a=(e,n)=>Z(`/api/agents/${t}${e}`,{method:`POST`,headers:{"content-type":`application/json`},...n===void 0?{}:{body:JSON.stringify(n)}}).then(G);try{if(n===`start`)await a(`/start`);else if(n===`stop`)await a(`/stop`);else if(n===`fork`)await a(`/fork`,{}),await q(t);else if(n===`goal`){if(!i){Y(`usage: /goal <text>`);return}await a(`/goal`,{text:i,notify:!0}),Y(`goal saved & notification queued`)}else{Y(`unknown command "${n}" — /start /stop /fork /goal`);return}p(``)}catch(e){Y(`/${n} failed: ${e.message}`)}return}p(``);try{await Z(`/api/agents/${t}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:r,start:m()})}),L(e=>[...e,{id:`@p${Date.now()}${Math.random().toString(36).slice(2,6)}`,text:r,at:Date.now()}])}catch(e){p(r),console.error(`send failed:`,e)}}},dn=e=>()=>n()&&Z(`/api/agents/${n()}${e}`,{method:`POST`}).then(G),fn=async e=>{e.preventDefault();let t=document.getElementById(`goal-input`),r=document.getElementById(`goal-notify`)?.checked??!0;!n()||!t.value.trim()||(await Z(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.value,notify:r})}),t.value=``,G())};return[(()=>{var i=pt(),o=i.firstChild,s=o.firstChild,l=s.firstChild.nextSibling,d=l.nextSibling.firstChild,h=d.nextSibling,v=s.nextSibling,b=v.nextSibling,x=o.nextSibling,S=x.nextSibling;return d.$$click=()=>{V(),w(!0)},h.$$click=()=>{V(),re(!0)},B(v,j(N,{get each(){return e()},children:e=>(()=>{var t=gt(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>q(e.id),B(i,()=>e.id),B(t,j(P,{get when(){return je(e.id).length>0},get children(){var t=mt();return y(()=>R(t,`title`,je(e.id).map(e=>`${e.id}: ${e.schedule}`).join(`
9
+ `))),t}}),null),B(t,j(P,{get when(){return e.goal.status===`done`},get children(){return ht()}}),null),y(i=>{var a=`agent-item`+(e.id===n()?` sel`:``),o=`dot ${e.status}`;return a!==i.e&&z(t,i.e=a),o!==i.t&&z(r,i.t=o),i},{e:void 0,t:void 0}),t})()})),B(b,j(P,{get when(){return u()},get children(){return[`master rss `,F(()=>u().rssMb),`MB · heap `,F(()=>u().heapUsedMb),`MB`,Pe(),`load1 `,F(()=>u().loadavg1),` · up `,F(()=>Math.floor(u().uptimeSec/60)),`m`]}})),B(x,j(P,{get when(){return M()},get fallback(){return _t()},get children(){return[(()=>{var e=Re(),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,l=c.firstChild,u=l.nextSibling;return B(t,()=>M().id),B(n,()=>M().status),B(e,j(P,{get when(){return(M().pendingPrompts??0)>0},get children(){var e=Fe(),t=e.firstChild.nextSibling;return t.nextSibling,B(e,()=>M().pendingPrompts,t),y(()=>R(e,`title`,`${M().pendingPrompts} prompt(s) waiting — the agent picks them up at the next turn boundary`)),e}}),r),B(e,j(P,{get when(){return je(M().id).length>0},get children(){var e=Ie();return e.firstChild,B(e,()=>je(M().id).length,null),y(()=>R(e,`title`,`scheduled tasks:\n${je(M().id).map(e=>`${e.schedule} · ${e.id}${e.forked?` (forked)`:``}`).join(`
10
+ `)}`)),e}}),r),B(r,()=>M().model,i),B(r,()=>M().session,a),B(r,()=>M().branch,o),B(r,()=>M().stats.turns,s),B(r,()=>M().stats.toolCalls,null),B(c,j(P,{get when(){return M().statusReason},get children(){var e=Le();return y(()=>R(e,`title`,M().statusReason)),e}}),l),l.$$click=Jt,u.$$click=T,y(()=>z(n,`badge ${M().status}`)),e})(),(()=>{var e=He();return e.addEventListener(`scroll`,()=>{let e=Rt();e&&k()&&pe(0),O(e)}),B(e,j(P,{get when(){return Se().length>0},get fallback(){return vt()},get children(){return[j(N,{get each(){return Se()},children:(e,t)=>j(On,{e,get prev(){return Se()[t()-1]},get res(){return be().resFor.get(e.id)},get onEdit(){return e.type===`prompt`&&e.data?.source===`user`?()=>I({eventId:e.id,text:String(e.data?.text??``)}):void 0}})}),j(P,{get when(){return A()},get children(){var e=Ve(),t=e.firstChild.nextSibling;return t.firstChild,B(t,j(P,{get when(){return A().reasoning},get children(){var e=ze(),t=e.firstChild.nextSibling;return B(t,()=>A().reasoning),e}}),null),B(t,j(P,{get when(){return he()},get fallback(){return yt()},get children(){var e=Be();return y(()=>e.innerHTML=De(he()+`▍`)),e}}),null),e}})]}})),e})(),j(P,{get when(){return!fe()||k()>0},get children(){var e=Ue();return e.firstChild,e.$$click=()=>zt(!0),B(e,(()=>{var e=F(()=>k()>0);return()=>e()?`${k()} new message${k()>1?`s`:``}`:`jump to present`})(),null),e}}),j(P,{get when(){return F(()=>!!Kt())()&&M()},get children(){var e=We(),t=e.firstChild,n=t.firstChild,r=n.firstChild.nextSibling,i=n.nextSibling,a=t.nextSibling;return B(r,()=>M().workspace),i.$$click=Jt,Ce(e=>Yt=e,a),e}}),(()=>{var e=Ke(),t=e.firstChild,n=t.firstChild,r=t.nextSibling;B(e,j(P,{get when(){return cn().length>0},get children(){var e=Ge();return B(e,j(N,{get each(){return cn()},children:e=>(()=>{var t=bt(),n=t.firstChild,r=n.nextSibling;return t.$$click=()=>p(e.cmd+` `),B(n,()=>e.cmd),B(r,()=>e.desc),y(()=>R(t,`title`,e.desc)),t})()})),e}}),t),t.addEventListener(`submit`,un),n.$$keydown=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),un(e))},n.$$input=e=>{p(e.currentTarget.value),ln()};var i=X;return typeof i==`function`?Ce(i,n):X=n,B(r,()=>rn()||`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(()=>R(n,`placeholder`,`message #${M().id} — / for commands`)),y(()=>n.value=f()),e})()]}})),B(S,j(P,{get when(){return M()},get children(){return[qe(),(()=>{var e=Je(),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 B(n,()=>M().id),B(r,()=>M().status),B(a,()=>M().workspace),B(o,()=>M().session,s),B(o,()=>M().branch,null),y(e=>{var t=`badge ${M().status}`,n=M().workspace;return t!==e.e&&z(r,e.e=t),n!==e.t&&R(a,`title`,e.t=n),e},{e:void 0,t:void 0}),e})(),Ye(),(()=>{var e=Xe(),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=>{se(e.currentTarget.value),D(e.currentTarget.value)}),B(t,j(N,{get each(){return de()},children:e=>(()=>{var t=xt();return t.value=e,B(t,e,null),B(t,()=>e===_().defaultProvider?` ★`:``,null),t})()})),i.$$input=e=>E(e.currentTarget.value),B(a,j(N,{get each(){return le()},children:e=>(()=>{var t=xt();return t.value=e,t})()})),o.$$click=async e=>{if(!n())return;let t=e.currentTarget;t.disabled=!0;try{await Z(`/api/agents/${n()}/model`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:oe(),model:ce().trim()||void 0})}),t.textContent=`✓ applied`,G()}catch(e){alert(`model switch failed: ${e.message}`)}finally{setTimeout(()=>{t.textContent=`apply`,t.disabled=!1},1200)}},B(s,()=>M().model,null),B(s,j(P,{get when(){return le().length},get children(){return[` · `,F(()=>le().length),` models loaded`]}}),null),y(()=>R(i,`placeholder`,M().model)),y(()=>t.value=oe()),y(()=>i.value=ce()),e})(),Ze(),(()=>{var i=$e(),o=i.firstChild,s=o.nextSibling;return B(i,j(P,{get when(){return M().status===`running`},get fallback(){return(()=>{var e=St();return xe(e,`click`,dn(`/start`),!0),e})()},get children(){var e=Qe();return xe(e,`click`,dn(`/stop`),!0),e}}),o),o.$$click=()=>Z(`/api/agents/${M().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>q(M().id)),s.$$click=async()=>{let i=n();if(!i||!confirm(`remove agent ${i}? (log is kept)`))return;await Z(`/api/agents/${i}`,{method:`DELETE`}).catch(()=>{});let o=e().filter(e=>e.id!==i);t(o),o[0]?q(o[0].id):(r(null),a([]))},i})(),(()=>{var e=et(),t=e.firstChild.firstChild;return t.addEventListener(`change`,e=>g(e.currentTarget.checked)),y(()=>t.checked=m()),e})(),(()=>{var e=tt(),t=e.firstChild.nextSibling;return B(t,()=>M().goal.status),y(()=>z(t,`badge ${M().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=nt();return e.addEventListener(`submit`,fn),e})(),(()=>{var e=rt();return B(e,()=>M().goal.text||`no goal set — the agent has nothing to auto-continue toward`),e})(),(()=>{var e=it();return e.firstChild,B(e,j(P,{get when(){return F(()=>!!M().goal.text)()&&M().goal.status===`active`},children:` auto-continue keeps it working until this is done`}),null),B(e,j(P,{get when(){return!M().goal.text},children:` set one and tick ▶ start to begin`}),null),e})(),at(),(()=>{var e=ot();return e.$$input=e=>{H(e.currentTarget.value),Ee(!0)},y(()=>e.value=we()),e})(),(()=>{var e=st(),t=e.firstChild.nextSibling;return t.$$click=W,e})(),ct(),j(P,{get when(){return M().latestProgress},get fallback(){return Ct()},children:e=>(()=>{var t=Ot(),n=t.firstChild,r=n.firstChild.nextSibling,i=n.nextSibling;return B(r,()=>e().doing),B(t,j(P,{get when(){return e().recent},get children(){var t=wt(),n=t.firstChild.nextSibling;return B(n,()=>e().recent),t}}),i),B(t,j(P,{get when(){return e().problems},get children(){var t=Tt(),n=t.firstChild.nextSibling;return B(n,()=>e().problems),t}}),i),B(t,j(P,{get when(){return e().next},get children(){var t=Et(),n=t.firstChild.nextSibling;return B(n,()=>e().next),t}}),i),B(t,j(P,{get when(){return e().goalStatus},get children(){var t=Dt(),n=t.firstChild.nextSibling;return B(n,()=>e().goalStatus),t}}),i),B(i,()=>An(e().ts)),t})()}),lt(),(()=>{var e=ut(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,B(e,()=>M().stats.turns,t),B(e,()=>M().stats.toolCalls,n),B(e,()=>M().stats.compactions??0,r),B(e,()=>jn(M().stats.inputTokens),i),B(e,()=>jn(M().stats.outputTokens),null),B(e,j(P,{get when(){return M().stats.cachedInputTokens>0},get children(){return[` · `,`cached `,F(()=>Math.round(M().stats.cachedInputTokens/Math.max(1,M().stats.inputTokens)*100)),`% (`,F(()=>jn(M().stats.cachedInputTokens)),`)`]}}),null),B(e,j(P,{get when(){return M().ctx},children:e=>[`
11
+ `,`context ~`,F(()=>jn(e().usedTokens)),` tok`,j(P,{get when(){return e().window},get children(){return[` · `,F(()=>Math.min(999,Math.round(e().usedTokens/e().window*100))),`% of `,F(()=>jn(e().window))]}}),`
12
+ `,`compaction at ~`,F(()=>jn(e().compactAt)),` tok (older turns summarized)`]}),null),e})(),dt(),j(N,{get each(){return c()},children:e=>(()=>{var t=kt(),r=t.firstChild,i=r.nextSibling,a=i.firstChild;return t.$$click=()=>{let t=Me()===e.branch?null:e.branch;Ft(t),n()&&It(n())},B(r,()=>e.branch,null),B(r,()=>e.branch===M().branch?` (current)`:``,null),B(i,()=>e.events,a),y(n=>{var r=`branch-row`+(e.branch===M().branch||e.branch===Me()?` cur`:``),i=e.branch===Me()?`click to show all branches again`:`show only ${e.branch}`;return r!==n.e&&z(t,n.e=r),i!==n.t&&R(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()}),ft(),j(P,{get when(){return Oe().length>0},get fallback(){return At()},get children(){return j(N,{get each(){return Oe()},children:e=>(()=>{var t=Mt(),r=t.firstChild,i=r.firstChild,a=i.nextSibling;a.firstChild;var o=r.nextSibling,s=o.firstChild,c=o.nextSibling;return t.$$click=()=>q(e.agent),B(i,()=>e.id),B(a,()=>e.agent,null),B(r,j(P,{get when(){return e.forked},get children(){return jt()}}),null),B(o,()=>e.schedule,s),B(o,(()=>{var t=F(()=>!!e.next);return()=>t()?An(e.next):`—`})(),null),B(o,(()=>{var t=F(()=>!!e.last);return()=>t()?` · last ${An(e.last)}`:` · never ran`})(),null),B(c,()=>$(e.prompt,90)),y(r=>{var i=`sched-row`+(e.agent===n()?` cur`:``),a=`${$(e.prompt,200)}\nclick to open #${e.agent}`;return i!==r.e&&z(t,r.e=i),a!==r.t&&R(t,`title`,r.t=a),r},{e:void 0,t:void 0}),t})()})}})]}})),y(e=>{var t=`layout`+(ie()?``:` right-hidden`),n=`conn`+(Bt()?` ok`:``),r=Bt()?`live (websocket)`:`reconnecting…`,a=`rightbar`+(ie()?` open`:``);return t!==e.e&&z(i,e.e=t),n!==e.t&&z(l,e.t=n),r!==e.a&&R(l,`title`,e.a=r),a!==e.o&&z(S,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),i})(),j(P,{get when(){return te()},get children(){return j(Pn,{get providers(){return Object.keys(_().providers??{})},onClose:()=>w(!1),onCreated:e=>{w(!1),G(),q(e)}})}}),j(P,{get when(){return ne()},get children(){return j(Fn,{get cfg(){return _()},onClose:()=>re(!1),onSaved:()=>{V(),Ae()}})}}),j(P,{get when(){return ve()},fallback:null,children:e=>{let t=()=>i().findIndex(t=>t.id===e().eventId),r=()=>Math.max(0,i().length-t()-1),[a,o]=v(r()>0?`summarize`:`discard`);return j(Nn,{title:`edit prompt — forks the conversation`,onClose:()=>I(null),get children(){var t=Pt(),i=t.firstChild,s=i.nextSibling,c=s.firstChild;return t.addEventListener(`submit`,async t=>{t.preventDefault();let r=document.getElementById(`edit-text`);try{await Z(`/api/agents/${n()}/edit-prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({eventId:e().eventId,text:r.value,tail:a()})}),I(null),G(),n()&&await q(n())}catch(e){alert(`edit failed: ${e.message}`)}}),B(t,j(P,{get when(){return r()>0},get children(){var e=Nt(),t=e.firstChild,n=t.firstChild,i=t.nextSibling,s=i.firstChild,c=i.nextSibling.firstChild;return B(t,r,n),s.addEventListener(`change`,()=>o(`summarize`)),c.addEventListener(`change`,()=>o(`discard`)),y(()=>s.checked=a()===`summarize`),y(()=>c.checked=a()===`discard`),e}}),s),c.$$click=()=>I(null),y(()=>i.value=e().text),t}})}})]}function Dn(e){let t=e.e,n=e.res,r=t.data??{},i=String(r.name??`tool`),a=()=>n?String(n.data?.result??``):``,o=i,s=``,c=(()=>{var e=Ft();return B(e,()=>Q(JSON.stringify(r.args??{},null,1),2e3)),e})(),l=e=>String(r.args?.[e]??``),u=(e,t=1500)=>(()=>{var n=It();return B(n,()=>Q(e,t)),n})(),d=(e=4e3)=>n?[F(()=>u(a(),e)),(()=>{var e=Lt(),t=e.firstChild;return B(e,()=>n.data?.durationMs,t),B(e,()=>n.data?.ok===!1?` · FAILED`:``,null),B(e,j(Mn,{get text(){return a()}}),null),e})()]:Rt();try{switch(i){case`bash`:{let e=l(`command`);o=`$ `+$(e,96),s=l(`timeout_ms`)?`timeout ${Math.round(Number(l(`timeout_ms`))/1e3)}s`:``,c=[F(()=>F(()=>e!==o.slice(2))()?u(e,800):null),F(()=>d(6e3))];break}case`read_file`:{o=l(`path`)||`(no path)`;let e=[];l(`pattern`)&&e.push(`grep /${$(l(`pattern`),40)}/`),Number(r.args?.offset)<0?e.push(`last ${-Number(r.args.offset)} lines`):r.args?.offset&&e.push(`from L${r.args.offset}`),r.args?.limit&&e.push(`≤${r.args.limit} lines`),s=e.join(` · `),c=d(6e3);break}case`write_file`:{let e=String(r.args?.content??``);o=l(`path`)||`(no path)`,s=`${e.length} bytes`,c=[F(()=>u(e)),n?(()=>{var e=zt();return B(e,()=>$(a(),160)),e})():q()];break}case`edit_file`:o=l(`path`)||`(no path)`,s=r.args?.replace_all===!0?`replace all`:`unique spot`,c=[(()=>{var e=Bt();return B(e,()=>Q(`- `+l(`old_text`),900)),e})(),(()=>{var e=Vt();return B(e,()=>`+ `+Q(l(`new_text`),900)),e})(),n?(()=>{var e=J(),t=e.firstChild,r=t.nextSibling;return r.nextSibling,B(e,()=>$(a(),120),t),B(e,()=>n.data?.durationMs,r),e})():Ht()];break;case`apply_patch`:{let e=l(`patch`).split(`
13
+ `).filter(e=>e&&!/^---$/.test(e.trim())),t=e.map(e=>e.match(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/)?.[1]).filter(Boolean);o=t.length?`${t.length} file${t.length>1?`s`:``}: ${$(t.join(`, `),80)}`:`patch`,c=[(()=>{var t=Ut();return B(t,()=>e.map(e=>{let t=e.startsWith(`+`)?` add`:e.startsWith(`-`)?` del`:/^\*\*\*|^@@/.test(e)?` meta`:``;return(()=>{var n=Wt();return z(n,`pline`+t),B(n,(()=>{var t=F(()=>e.length>240);return()=>t()?e.slice(0,240)+`…`:e})()),n})()})),t})(),n?(()=>{var e=zt();return B(e,()=>$(a().split(`
14
+ `)[0]??``,140),null),B(e,()=>n.data?.ok===!1?` · FAILED`:``,null),e})():Gt()];break}case`list_dir`:o=l(`path`)||`.`,c=d(4e3);break;case`read_url`:{let e=l(`url`);try{let t=new URL(e);e=t.host+t.pathname}catch{}o=$(e,70),s=`web`,c=[(()=>{var e=Kt(),t=e.firstChild;return y(()=>R(t,`href`,l(`url`))),e})(),F(()=>d(3e3))];break}case`load_skill`:{o=`skill: ${l(`name`)}`;let e=a().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);c=n?[(()=>{var t=Be();return y(()=>t.innerHTML=De(e)),t})(),(()=>{var e=Lt(),t=e.firstChild;return B(e,()=>n.data?.durationMs,t),e})()]:qt();break}case`save_skill`:{o=`skill: ${l(`name`)}`,s=$(l(`description`),60);let e=Array.isArray(r.args?.files)?r.args.files.map(e=>e?.name).filter(Boolean):[];c=[F(()=>F(()=>!!e.length)()?(()=>{var t=Jt();return t.firstChild,B(t,()=>e.join(`, `),null),t})():null),n?(()=>{var e=J(),t=e.firstChild,r=t.nextSibling;return r.nextSibling,B(e,()=>$(a(),160),t),B(e,()=>n.data?.durationMs,r),e})():Yt()];break}}}catch{}return(()=>{var e=Xt(),t=e.firstChild.firstChild;t.firstChild;var r=t.nextSibling;return R(e,`title`,`${i}${s?` — `+s:``}`),B(t,o,null),B(r,n?s||``:`running…`),B(e,c,null),y(()=>z(e,`embed`+(n?n.data?.ok===!1?` fail`:` done`:` running`))),e})()}function On(e){let t=e.e,n=xn(t),r=e.prev&&e.prev.type===t.type&&xn(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=Zt(),r=n.firstChild.nextSibling;return r.nextSibling,B(n,()=>String(e.fromBranch??`?`),r),B(n,()=>String(e.newBranch??t.branch),null),n})()}if(t.type===`goal`){let e=t.data??{},n=e.event===`status`?`marked ${String(e.status??``)}`:$(String(e.text??``),80);return(()=>{var t=Qt(),r=t.firstChild.nextSibling;return r.nextSibling,B(t,()=>String(e.event??``),r),B(t,n,null),t})()}return t.type===`todo`?(()=>{var e=$t(),n=e.firstChild.nextSibling;return n.nextSibling,B(e,()=>String(t.data?.by??`human`),n),e})():t.type===`state`?t.data.from===t.data.to?null:(()=>{var e=en(),n=e.firstChild;return B(e,()=>t.data.from,n),B(e,()=>t.data.to,null),B(e,(()=>{var e=F(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>z(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var i=an(),a=i.firstChild;return B(i,j(P,{when:!r,get fallback(){return on()},get children(){var e=tn();return B(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&Se(e,`background`,t.e=r),i!==t.t&&Se(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),a),B(a,j(P,{when:!r,get children(){var r=rn(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling;return B(i,()=>n.name),B(a,(()=>{var e=F(()=>!!t.data?.pending);return()=>e()?`pending…`:Cn(t.ts)})()),B(o,()=>t.branch),B(r,j(P,{get when(){return e.onEdit},get children(){var t=nn();return t.$$click=t=>{t.stopPropagation(),e.onEdit()},t}}),null),y(e=>Se(i,`color`,n.color)),r}}),null),B(a,j(kn,{e:t,get res(){return e.res}}),null),y(()=>z(i,`msg`+(r?` grouped`:``)+(t.data?.pending?` pending`:``))),i})()}function kn(e){let t=e.e;switch(t.type){case`prompt`:return(()=>{var e=Be();return y(()=>e.innerHTML=De(String(t.data.text??``))),e})();case`message`:return[j(P,{get when(){return F(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=ze(),n=e.firstChild.nextSibling;return B(n,()=>String(t.data.reasoning)),e}}),(()=>{var e=Be();return y(()=>e.innerHTML=De(String(t.data.content??``))),e})(),j(P,{get when(){return t.data.interrupted},get children(){return Y()}}),j(P,{get when(){return t.data.final},get children(){var e=sn(),n=e.firstChild;return B(e,j(Mn,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:return j(Dn,{e:t,get res(){return e.res}});case`tool_result`:{let e=String(t.data.result);return(()=>{var n=cn(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling,s=o.firstChild;return B(i,()=>$(e,120)),B(r,j(Mn,{text:e}),null),B(a,()=>Q(e,4e3)),B(o,()=>t.data.durationMs,s),B(o,()=>t.data.ok?``:` · FAILED`,null),y(()=>z(n,`embed`+(t.data.ok?``:` fail`))),n})()}case`progress`:return(()=>{var e=un(),n=e.firstChild;return n.firstChild,B(n,()=>String(t.data.doing??``),null),B(e,j(P,{get when(){return t.data.recent},get children(){var e=zt();return B(e,()=>String(t.data.recent)),e}}),null),B(e,j(P,{get when(){return t.data.problems},get children(){var e=X();return e.firstChild,B(e,()=>String(t.data.problems),null),e}}),null),B(e,j(P,{get when(){return t.data.next},get children(){var e=ln();return e.firstChild,B(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=dn(),n=e.firstChild;return n.firstChild,B(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=fn();return B(e,()=>Q(JSON.stringify(t.data),200)),e})()}}function Q(e,t){return e.length>t?e.slice(0,t)+` …`:e}function An(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 jn(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 $(e,t){return Q(e.replace(/\s+/g,` `).trim(),t)}function Mn(e){let[t,n]=v(!1);return(()=>{var r=pn();return r.$$click=t=>{t.stopPropagation(),navigator.clipboard.writeText(e.text).then(()=>{n(!0),setTimeout(()=>n(!1),900)})},B(r,()=>t()?`✓`:`⧉`),r})()}function Nn(e){return(()=>{var t=mn(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),B(r,()=>e.title),xe(i,`click`,e.onClose,!0),B(n,()=>e.children,null),t})()}function Pn(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 t=await Z(`/api/fs${e?`?path=${encodeURIComponent(e)}`:``}`);n(t.path),i(t.entries)}ee(()=>p(t()));let m=async n=>{n.preventDefault(),f(``);try{let n=await Z(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return j(Nn,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=gn(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,g=h.nextSibling,_=g.nextSibling,v=f.nextSibling,b=v.nextSibling,x=b.firstChild,S=x.firstChild.nextSibling,ee=x.nextSibling,C=ee.firstChild.nextSibling,te=ee.nextSibling.firstChild.nextSibling,w=b.nextSibling;return i.addEventListener(`submit`,m),h.$$input=e=>n(e.currentTarget.value),g.$$click=()=>p(t()),_.$$click=()=>p(`..`),B(v,j(N,{get each(){return r()},children:e=>(()=>{var n=_n();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),B(n,e,null),n})()})),S.$$input=e=>o(e.currentTarget.value),C.addEventListener(`change`,e=>c(e.currentTarget.value)),B(C,j(N,{get each(){return e.providers},children:e=>(()=>{var t=xt();return B(t,e),t})()})),te.$$input=e=>u(e.currentTarget.value),B(i,j(P,{get when(){return d()},get children(){var e=hn();return B(e,d),e}}),w),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>C.value=s()),y(()=>te.value=l()),i}})}function Fn(e){let[t,n]=v(JSON.stringify(Object.fromEntries(Object.entries(e.cfg.providers??{}).map(([e,t])=>[e,{baseUrl:t.baseUrl,apiKey:t.apiKey??``,model:t.model??``}])),null,2)),[r,i]=v(e.cfg.defaultProvider??Object.keys(e.cfg.providers??{})[0]??``),[a,o]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[s,c]=v(JSON.stringify(e.cfg.tasks??[],null,2)),[l,u]=v(``),d=async n=>{n.preventDefault(),u(``);let i,o;try{i=JSON.parse(t())}catch{return u(`providers: invalid JSON`)}try{o=JSON.parse(s())}catch{return u(`tasks: invalid JSON`)}try{await Z(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:i,defaultProvider:r(),progressIntervalMs:Math.max(1,a())*6e4,tasks:o})}),e.onSaved(),e.onClose()}catch(e){u(String(e.message))}};return j(Nn,{title:`settings`,get onClose(){return e.onClose},get children(){var u=vn(),f=u.firstChild,p=f.firstChild.nextSibling,m=p.nextSibling.nextSibling,h=f.nextSibling,g=h.firstChild,_=g.firstChild.nextSibling,v=g.nextSibling.firstChild.nextSibling,b=h.nextSibling,x=b.firstChild.nextSibling,S=b.nextSibling;return u.addEventListener(`submit`,d),B(f,()=>e.cfg.configPath,p),m.$$input=e=>n(e.currentTarget.value),_.$$input=e=>i(e.currentTarget.value),v.$$input=e=>o(Number(e.currentTarget.value)),x.$$input=e=>c(e.currentTarget.value),B(u,j(P,{get when(){return l()},get children(){var e=hn();return B(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}be([`click`,`input`,`keydown`]),ye(()=>j(En,{}),document.getElementById(`root`));
15
+ //# sourceMappingURL=index-DJNTl8c0.js.map