teapot-coding-agent 0.36.8 → 0.36.9
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/dist/index.js +15 -2
- package/package.json +1 -1
- package/public/assets/{index-D0vhYAVd.js → index-CoH7Vqvo.js} +5 -5
- package/public/assets/{index-D0vhYAVd.js.map → index-CoH7Vqvo.js.map} +1 -1
- package/public/assets/index-DtUaInbZ.css +1 -0
- package/public/assets/{shiki-D3K-t1Ea.js → shiki-BKqf8YtI.js} +2 -2
- package/public/assets/{shiki-D3K-t1Ea.js.map → shiki-BKqf8YtI.js.map} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-CxEGtdCg.css +0 -1
package/dist/index.js
CHANGED
|
@@ -142,8 +142,21 @@ async function main() {
|
|
|
142
142
|
const noAuth = !(process.env.TEAPOT_API_TOKEN || master.config.password);
|
|
143
143
|
const beyondLoopback = !!config.host && config.host !== "127.0.0.1" && config.host !== "localhost";
|
|
144
144
|
if (noAuth) {
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
/**
|
|
146
|
+
* On LOOPBACK this is the normal, safe default — so say so plainly instead of printing an
|
|
147
|
+
* alarming "no API token set" on every start.
|
|
148
|
+
*
|
|
149
|
+
* Asked as "no API token setはなんだろう": nothing is wrong. A fresh install has no password
|
|
150
|
+
* because the setup wizard has to reach the API to set one, and binding 127.0.0.1 means only
|
|
151
|
+
* processes on this machine can connect. The message now states that, and is written to stdout
|
|
152
|
+
* at info level — `console.error` made a healthy start look like a fault.
|
|
153
|
+
*
|
|
154
|
+
* The WARNING branch is unchanged and still goes to stderr: that one IS a problem.
|
|
155
|
+
*/
|
|
156
|
+
if (!beyondLoopback) {
|
|
157
|
+
console.log("[teapot] auth: none needed — bound to loopback only, so only this machine can reach /api. " +
|
|
158
|
+
"Set TEAPOT_API_TOKEN or config.password before exposing this port.");
|
|
159
|
+
}
|
|
147
160
|
if (beyondLoopback) {
|
|
148
161
|
console.error(`[teapot] WARNING: bound to ${config.host} with NO auth — anyone who can reach this port can ` +
|
|
149
162
|
"drive the agents. Set TEAPOT_API_TOKEN or config.password now.");
|
package/package.json
CHANGED
|
@@ -22,10 +22,10 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
22
22
|
`)){let r=n.match(/^\s*[-*+] \[([ xX])\]/);r&&(e++,r[1].toLowerCase()===`x`&&t++)}return{total:e,done:t}});function _r(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);return t&&JSON.stringify(t)===JSON.stringify(e)?t:e})}let V=()=>$(`/api/agents`).then(e=>{let n=!1;t(t=>(t.length!==(e.agents??[]).length&&(n=!0),(e.agents??[]).some(e=>!t.some(t=>t.id===e.id))&&(n=!0),_r(t,e.agents??[]))),n&&p()}).catch(()=>{}),vr=()=>$(`/api/metrics`).then(re).catch(()=>{}),[yr,br]=v([]),xr=()=>$(`/api/tasks`).then(e=>br(e.tasks)).catch(()=>{}),Sr=e=>yr().filter(t=>t.agent===e),[Cr,wr]=v((()=>{try{let e=JSON.parse(localStorage.getItem(`teapot.expandedSubs`)??`[]`);return new Set(e.filter(e=>typeof e==`string`))}catch{return new Set}})()),[Tr,Er]=v((()=>{try{let e=JSON.parse(localStorage.getItem(`teapot.collapsed`)??`[]`);return new Set(e.filter(e=>typeof e==`string`&&!e.startsWith(`chat:`)))}catch{return new Set}})()),Dr=e=>Tr().has(e)||!Cr().has(e),Or=e=>{let t=new Set(Cr());if(t.has(e)?t.delete(e):t.add(e),wr(t),localStorage.setItem(`teapot.expandedSubs`,JSON.stringify([...t])),t.has(e)&&Tr().has(e)){let t=new Set(Tr());t.delete(e),Er(t),localStorage.setItem(`teapot.collapsed`,JSON.stringify([...t]))}},kr=t=>Pt(e(),t),[Ar,jr]=v((()=>{try{let e=JSON.parse(localStorage.getItem(`teapot.wsCollapsed`)??`[]`),t=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(Number(localStorage.getItem(`teapot.wsCollapsed.v`)??`0`)<2){let e=t.filter(e=>!e.startsWith(`chat:`));return t.length-e.length>0&&localStorage.setItem(`teapot.wsCollapsed`,JSON.stringify(e)),localStorage.setItem(`teapot.wsCollapsed.v`,`2`),new Set(e)}return new Set(t)}catch{return new Set}})()),Mr=x(()=>{let e=new Set;for(let t of Ar())t.startsWith(`chat:`)&&e.add(t);return e}),Nr=x(()=>kt(e(),new Set(e().filter(e=>Dr(e.id)).map(e=>e.id)),In(),Mr())),Pr=(t,r,i,a)=>{let o=new Set(Ar());if(i)o.delete(t),a&&o.delete(a);else{o.add(t),a&&o.delete(a);let i=n();i&&(t===`chat:${i}`||kr(e().find(e=>e.id===i))===t)&&Q(`hid ${r} — click the header to show it`)}jr(o);try{localStorage.setItem(`teapot.wsCollapsed`,JSON.stringify([...o]))}catch{}},Fr=e=>e.replace(/\/+$/,``).split(/[/\\]/).pop()||e,Ir=e=>{let t=Lr().get(e)??0;return`${t} chat${t===1?``:`s`}`},Lr=x(()=>Ft(e())),Rr=x(()=>It(e(),Nr(),Ar())),zr=2e3,[Br,Vr]=v(null),H=new Map;function Hr(e){return`${i()||(n()??`?`)}:${e.id}`}function Ur(e){let t=Array.from({length:e.length});for(let n=0;n<e.length;n++){let r=e[n],i=Hr(r),a=H.get(i);if(t[n]=a??r,!a&&(H.set(i,r),H.size>6e3)){let e=H.keys().next().value;e!==void 0&&H.delete(e)}}return t}let[U,Wr]=v(!1),[Gr,Kr]=v(!1),[W,qr]=v(!1),Jr=0,Yr=-1;function Xr(e){let t=Ur(e);h(e=>{if(t.length>0&&e.length>0){let n=e[e.length-1],r=t.every(e=>e.seq>n.seq),i=new Set(e.map(e=>e.id));if(r&&t.every(e=>!i.has(e.id)))return[...e,...t]}let n=new Map;for(let t of e)n.set(t.id,t);let r=!1;for(let e of t)n.has(e.id)||(n.set(e.id,e),r=!0);return r?[...n.values()].sort((e,t)=>e.seq-t.seq):e})}async function Zr(){let e=n();if(!e||W()||U()||Ct())return;if(m().length>=g()){qr(!0);return}let t=()=>{let e=ei();return e&&e.clientHeight>0?e:null},r=0;for(;r++<20&&!W()&&n()===e;){let r=t();if(r&&r.scrollHeight>r.clientHeight+40)return;if(m().length>=g()){qr(!0);return}let i=m().length;if(await Qr(),m().length===i)return;ln(ti())&&n()===e&&ii(!0)}}async function Qr(){let e=n(),t=m()[0];if(e&&t&&!U()&&!W()){Wr(!0);try{let r=ei(),a=r?.scrollHeight??0,o=r?.scrollTop??0,s=Br(),c=i(),l=c&&c!==e?`&session=${encodeURIComponent(c)}`:``,u=(await $(`/api/agents/${e}/events?limit=${zr}&before=${encodeURIComponent(t.id)}${l}${s?`&branch=${encodeURIComponent(s)}&lineage=true`:``}`)).events??[];if(u.length===0){qr(!0);return}if(n()!==e||m()[0]?.id!==t.id)return;Xr(u),requestAnimationFrame(()=>{if(n()===e){let e=ei();e&&(e.scrollTop=o+(e.scrollHeight-a))}})}catch{}finally{Wr(!1)}}}async function $r(e,t){let r=Jr,a=t??i()??``;try{let t=Br(),i=r!==Yr||!te().length;m().length||Kr(!0);let o=a&&a!==e?`&session=${encodeURIComponent(a)}`:``;$(`/api/agents/${e}/skills`).then(t=>{r===Jr&&n()===e&&ia(t.skills??[])}).catch(()=>{});let[s,c]=await Promise.all([$(`/api/agents/${e}/events?limit=${zr}${o}${t?`&branch=${encodeURIComponent(t)}&lineage=true`:``}`),i?$(`/api/agents/${e}/branches`):Promise.resolve({branches:te()})]);if(i&&(Yr=r),r!==Jr||n()!==e)return;h(e=>{let t=new Map;for(let n of e)t.set(n.id,n);for(let e of Ur(s.events))t.set(e.id,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}),_(s.total??s.events.length),ne(c.branches)}catch{}finally{Kr(!1)}}function ei(){return document.querySelector(`.feed`)}function ti(){let e=ei();return e?{top:e.scrollTop,height:e.scrollHeight,viewport:e.clientHeight}:null}function ni(){return ln(ti())}function ri(){let e=ei();e&&(e.scrollTop=e.scrollHeight,_a={top:e.scrollTop,height:e.scrollHeight},Et(0))}function ii(e=!1){(e||Ct())&&ri()}let ai=new Map,oi=(t,n)=>Ut(c().get(t),e().find(e=>e.id===t)?.session,n);async function si(e,t=!0,o){let s=n(),l=i(),u=m(),d=g();Jr++,c().size||p();let f=oi(e,o)??e;if(s!==e||f!==l){if(l&&u.length&&(ai.set(l,{events:u,total:d,at:Date.now()}),ai.size>6)){let e=[...ai.entries()].sort((e,t)=>e[1].at-t[1].at)[0];e&&ai.delete(e[0])}h([]),H.clear(),Qn(),Rt(null),Et(0),wt(!0),ga=void 0}r(e),a(f),E(T.get(e)??``),Vr(null),qr(!1),Wr(!1),Nn(l||s||`?`,z()),B(Mn(f||e)),localStorage.setItem(`teapot.session`,e),vi(f,t);let v=ai.get(f);v?.events.length&&(Ur(v.events),h(Ur(v.events)),_(v.total),requestAnimationFrame(()=>{n()===e&&ii(!0)})),$(`/api/agents/${e}/load`,{method:`POST`}).then(V).catch(()=>{}),await $r(e,f),n()===e&&(Xt(t=>{let n=t.get(e)??null,r=Ze(n,m(),R()?.status);if(r===n)return t;let i=new Map(t);return r?i.set(e,r):i.delete(e),i}),Rt(R()?.ctx?.compacting?{phase:String(R().ctx.compacting)}:null),requestAnimationFrame(()=>{n()===e&&ii(!0)}),Zr())}let[G,ci]=v(!1),li=null,ui=null;C(()=>li?.close());let di=!1,fi=null;document.addEventListener(`visibilitychange`,()=>fi?.()),C(()=>{fi=null});let pi=!0,mi=null;async function hi(){let e=n(),t=m().at(-1)?.id,r=i(),a=document.visibilityState===`hidden`;if(!e||!t)di=!0,a||mi?.();else try{let n=r&&r!==e?`&session=${encodeURIComponent(r)}`:``,i=Br(),o=await $(`/api/agents/${e}/events?after=${encodeURIComponent(t)}${n}${i?`&branch=${encodeURIComponent(i)}&lineage=true`:``}`),s=o.events??[];o.gap?(h(Ur(s)),_(s.length)):s.length&&(Xr(s),_(e=>e+s.length)),await V(),s.length&&!a&&vr()}catch{di=!0}}function gi(){pi=!0;let r=location.protocol===`https:`?`wss://`:`ws://`,a=new WebSocket(`${r}${location.host}/api/ws${Th()}`);li=a,a.onopen=()=>{ci(!0),pi?pi=!1:hi()},a.onclose=()=>{ci(!1),setTimeout(gi,1500)},a.onerror=()=>a.close();let o=new Set([`state`,`usage`,`session_start`]);a.onmessage=r=>{let c=JSON.parse(r.data);if(c.kind===`ping`)try{a.send(JSON.stringify({kind:`pong`}))}catch{}else if(c.kind!==`pong`){if(c.kind===`hello`&&Array.isArray(c.agents)){t(e=>_r(e,c.agents));let n=e();Xt(e=>Xe(e,e=>n.find(t=>t.id===e)?.status))}else if(c.kind===`event`&&Ge(c.event))Xt(e=>We(e,c.agentId));else if(c.kind===`llm-delta`){if(!Kt(c,n(),i()))return;if(Xt(e=>Ue(e,c.agentId,c)),c.agentId===n()){let e=String(c.reasoning??``),t=String(c.text??``);e&&!t?hn()||gn(Date.now()):t&&gn(0)}}else if(c.kind===`compaction-progress`){if(c.agentId!==n())return;c.phase===`done`?Rt(null):Rt({phase:c.phase,summarized:c.summarized})}else if(c.kind===`agent-update`&&c.snapshot)t(e=>{let t=e.findIndex(e=>e.id===c.snapshot.id),n=c.snapshot;return t===-1?[...e,n]:_r(e,e.map((e,n)=>n===t?c.snapshot:e))});else{if(c.kind===`event`){let e=c.event?.type,t=c.event?.data??{};if((e===`system_note`&&t.event===`prompt-delivered`&&c.agentId===n()||e===`system_note`&&t.event===`prompt-cancelled`&&c.agentId===n())&&Nn(jn(),z().filter(e=>e.promptId!==t.promptId)),o.has(e)&&!bh.has(e)||(Kn(c.agentId,c.event),c.event?.agent!==n())||!Gt(c.event,n(),i()))return;if(Xr([c.event]),c.event?.type===`message`&&c.event.data?.role===`assistant`){let e=Zt();e&&qe(e,m(),R()?.status)&&Qt(null)}if(di=!0,document.visibilityState!==`visible`||ui)return;ui=setTimeout(s,60)}document.visibilityState===`hidden`?di=!0:ui||=setTimeout(s,120)}}},di=!1;let s=async()=>{if(ui=null,await V(),await vr(),n()){let e=m().at(-1)?.id,t=m().length;await $r(n());let r=Zt();r&&!Ze(r,m(),R()?.status)&&Qt(null),m().at(-1)?.id!==e&&(Ct()?(ri(),Vn(n())):(Et(e=>e+Math.max(0,m().length-t)),At(ti())))}};mi=s,fi=()=>{document.visibilityState===`visible`&&n()&&(di?(di=!1,s()):m().at(-1)?.id?hi():(di=!0,s()))}}let _i=()=>decodeURIComponent(location.pathname.split(`/`)[2]??``);function vi(e,t=!0){let n=`/session/${encodeURIComponent(e)}`;t?history.pushState(null,``,n):history.replaceState(null,``,n)}window.addEventListener(`popstate`,()=>{let e=_i(),t=o().get(e);t&&(t!==n()||e!==i())&&si(t,!1,e||null)}),b(()=>{let e=R(),t=e?`${Tn()?`▶ `:e.status===`error`?`⚠ `:``}${e.id} · teapot`:`teapot`;document.title=Bn()>0?`(${Bn()}) ${t}`:t});let yi=()=>se()||de()||On()!==null||me()&&Te();window.addEventListener(`keydown`,e=>{let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable))e.key===`Escape`&&t.blur();else if(e.key===`Escape`){if(se()){ce(!1);return}if(de()){k(!1);return}if(On()){kn(null);return}if(me()&&Te()){Me();return}let e=R();if(e&&Tn()){$(`/api/agents/${e.id}/stop`,{method:`POST`}).then(V);return}}else if(!yi()){if(e.key===`/`)e.preventDefault(),document.querySelector(`.composer textarea`)?.focus();else if(e.key===`d`)je();else if(e.key===`t`)Si();else if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=Nr().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&&si(t[i].id)}}});let[bi,xi]=v(localStorage.getItem(`teapot.term`)===`1`),Si=()=>{let e=!bi();xi(e),localStorage.setItem(`teapot.term`,e?`1`:`0`)},[Ci,wi]=v([]),[Ti,Ei]=v(0),[Di,Oi]=v(-1),[K,ki]=v(!1),[Ai,ji]=v(0),[Mi,Ni]=v(Number(localStorage.getItem(`teapot.termH`))||Math.max(220,Math.round(window.innerHeight*.35))),Pi=new Map,Fi=[null,null],Ii=()=>Ci()[Ai()===0?Ti():Di()]??null;function Li(e){if(!Ci()[e])return;let t=Ai(),n=t===0?Ti():Di(),r=t===0?Di():Ti(),i=e=>t===0?Ei(e):Oi(e);r===e?((e=>t===0?Oi(e):Ei(e))(n),i(e)):n!==e&&i(e)}let Ri=()=>zi();async function zi(e){let t=e??n();if(t){if(Ci().filter(e=>e.agentId===t).length>=10)Q(`max 10 shells per agent (${t}) — that's already a lot`);else try{let e=(await $(`/api/terminals`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({agentId:t})})).terminal;if(!e){Q(`could not open a shell`);return}let n=yu(Ci());wi(t=>[...t,{key:e.id,agentId:e.agentId,title:e.title}]),Ai()===0?Ei(n):Oi(n)}catch(e){Q(`could not open a shell: ${e.message}`)}}}function Bi(e){let t=Ci()[e];if(!t)return;$(`/api/terminals/${encodeURIComponent(t.key)}`,{method:`DELETE`}).catch(()=>{});let n=Pi.get(t.key);if(n){n.ro?.disconnect();try{n.ws.close()}catch{}n.term.dispose(),Pi.delete(t.key)}let r=Ci().filter((t,n)=>n!==e);wi(r),Ei(t=>xu(t,e,r.length)),Oi(t=>t===-1?-1:xu(t,e,r.length))}b(()=>{ze(),Ie(),nt(),Ve(),$e();for(let[,e]of Pi)Yt(e.term)});function Vi(){for(let[,e]of Pi){e.ro?.disconnect();try{e.ws.close()}catch{}e.term.dispose()}Pi.clear()}function Hi(e,t){let n=Pi.get(e.key);if(n&&Yt(n.term),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 hu({cursorBlink:!0,fontSize:12.5,fontFamily:`ui-monospace, Menlo, Consolas, monospace`,theme:Jt()}),a=new vu;i.loadAddon(a),i.open(r);let o=location.protocol===`https:`?`wss://`:`ws://`,s=new WebSocket(`${o}${location.host}/api/agents/${encodeURIComponent(e.agentId)}/term?terminal=${encodeURIComponent(e.key)}${Th()}`);s.onmessage=t=>{let n=JSON.parse(t.data);n.kind===`data`?i.write(n.data):n.kind===`exit`?(i.write(`\r\n\x1b[2m[terminal exited ${n.code??``}]\x1b[0m\r\n`),wi(t=>t.filter(t=>t.key!==e.key)),Pi.get(e.key)?.term.dispose(),Pi.delete(e.key)):n.kind===`attach`&&n.error&&i.write(`\r\n\x1b[2m[${n.error}]\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=[],d=()=>{try{a.fit()}catch{}s.readyState===WebSocket.OPEN?(i.cols!==c.cols||i.rows!==c.rows)&&(c={cols:i.cols,rows:i.rows},s.send(JSON.stringify({kind:`resize`,cols:i.cols,rows:i.rows}))):f()};function f(){l||=setInterval(()=>{Pi.has(e.key)?s.readyState===WebSocket.OPEN&&(clearInterval(l),l=void 0,d()):(clearInterval(l),l=void 0)},400)}s.addEventListener(`open`,()=>d());let p=r.parentElement??r,m=new ResizeObserver(()=>{u[0]&&clearTimeout(u[0]),u[0]=setTimeout(d,250)});m.observe(p),p!==r&&m.observe(r),setTimeout(d,60),n={el:r,term:i,fit:a,ws:s,ro:m},Pi.set(e.key,n)}return n}function Ui(e){let t=Fi[e];if(!t)return;let n=Ci()[e===0?Ti():Di()];if(!n){[...Pi.values()].some(e=>e.el.parentElement===t)&&t.replaceChildren();return}let r=Hi(n,t);for(let[e,r]of Pi)e!==n.key&&r.el.parentElement===t&&r.el.remove();requestAnimationFrame(()=>{r.el.parentElement!==t&&t.appendChild(r.el);try{r.fit()}catch{}if(Ai()===(e===0?0:1))try{r.term.focus()}catch{}})}b(()=>{Ci(),K(),Ti(),Di(),Mi(),requestAnimationFrame(()=>{Ui(0),K()&&Ui(1)})});let Wi=null;b(()=>{if(!bi())return;let e=n();if(!e||e===Wi)return;Wi=e;let t=Ci().map((e,t)=>({t:e,i:t})).filter(t=>t.t.agentId===e);t.length&&Li(t[t.length-1].i)}),b(()=>{let e=Ci().length,t=bu(Ti(),e);if(t!==Ti()&&Ei(t),K()){let t=bu(Di(),e);t!==Di()&&Oi(t)}});let Gi=e=>{e.preventDefault();let t=e.clientY,n=Mi(),r=e=>{let r=Math.min(Math.max(n-(e.clientY-t),140),Math.round(window.innerHeight*.85));Ni(r)},i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),localStorage.setItem(`teapot.termH`,String(Mi())),requestAnimationFrame(()=>{Ui(0),K()&&Ui(1)})};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Ki=()=>{let e=!K();ki(e),e&&(Di()<0||Di()===Ti()||Di()>=Ci().length)&&Oi(Su(Ti(),Ci().length)),requestAnimationFrame(()=>{Ui(0),K()&&Ui(1)})};C(Vi);let qi=e=>t=>{Fi[e]=t,t&&requestAnimationFrame(()=>{Ui(e),K()&&Ui(1),setTimeout(()=>Ui(e),200)})};ee(()=>{ar(),V().then(async()=>{await p();let t=_i(),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&&si(r.id,!1,t||null)}),vr(),xr(),Zi(),gi(),$(`/api/terminals`).then(e=>{let t=e.terminals??[];t.length&&(wi(t.map(e=>({key:e.id,agentId:e.agentId,title:e.title}))),bi()&&(Ei(0),Oi(-1)))}).catch(()=>{});let t=setInterval(()=>{vr(),xr()},3e4);C(()=>clearInterval(t))});let Ji=[{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`}],[Yi,Xi]=v([]),Zi=()=>$(`/api/personas`).then(e=>Xi(e.personas)).catch(()=>{}),[Qi,$i]=v(!1),ea=()=>{let e=ie().match(/^@([A-Za-z0-9._-]*)$/);return e?e[1].toLowerCase():null},ta=()=>{let t=ea();return t===null?[]:[...Yi().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))},na=new Set([`start`,`stop`,`fork`,`compact`]),[ra,ia]=v([]),[aa,oa]=v(null),[sa,ca]=v(-1),la=()=>{let e=ie();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=Ji.filter(e=>e.cmd.slice(1).startsWith(n));return e.find(e=>e.cmd.slice(1)===n)&&na.has(n)?[]:e.map(e=>({insert:e.cmd+` `,title:e.desc}))}if(n===`skill`){let e=ra().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[]},ua,da,fa,pa=!1;function ma(e){if(!da){da=document.createElement(`div`),da.setAttribute(`aria-hidden`,`true`);let e=da.style;e.position=`absolute`,e.visibility=`hidden`,e.pointerEvents=`none`,e.top=`0`,e.left=`-9999px`,e.whiteSpace=`pre-wrap`,e.overflowWrap=`anywhere`,e.wordBreak=`break-word`,da.dataset.mirror=``}let t=getComputedStyle(e);for(let e of[`font-family`,`font-size`,`font-weight`,`line-height`,`letter-spacing`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`,`border-top-width`,`border-bottom-width`,`box-sizing`])da.style.setProperty(e,t.getPropertyValue(e));if(da.style.width=`${e.clientWidth}px`,da.setAttribute(`data-mirror-text`,e.value.endsWith(`
|
|
24
24
|
`)?`${e.value} `:e.value),fa||(fa=document.createElement(`div`),fa.setAttribute(`aria-hidden`,`true`),fa.style.cssText=`position:absolute;left:-9999px;top:0;pointer-events:none`,document.body.appendChild(fa)),da.parentElement!==fa&&fa.appendChild(da),!pa){let e=document.createElement(`style`);e.textContent=`[data-mirror]::after{content:attr(data-mirror-text);white-space:pre-wrap;display:block}`,document.head.appendChild(e),pa=!0}return da.scrollHeight}let ha=()=>{if(!ua)return;let e=bt();if(!ua.value&&!e){ua.style.height=``;return}let t=ma(ua),n=e?-1:mn(t,360);ua.style.height=n===-1?``:`${n}px`},ga,_a=null,va,ya=null,ba=0,xa=240,Sa=4,Ca;b(()=>{let e=ie();ua&&an(gh)&&(on(ua.value,e)&&(ua.value=e),ha())}),ee(()=>{let e=0,t=()=>{e||=requestAnimationFrame(()=>{e=0,ha()})};window.addEventListener(`resize`,t),C(()=>{window.removeEventListener(`resize`,t),e&&cancelAnimationFrame(e)})});let[wa,Ta]=v([]),Ea=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=()=>{Ta(n=>[...n,{url:String(t.result),name:e.name}].slice(0,4))},t.readAsDataURL(e)}},Da=async(e,t)=>{let r=t??n();if(!r)return;let i=wa();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}:{}})});Nn(jn(),[...z(),{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)}:{}}]),Ta([]),bt()&&xt(!1),ha(),Ct()&&requestAnimationFrame(()=>{Ct()&&ri()})}catch(t){E(e),console.error(`send failed:`,t)}},Oa=async t=>{t.preventDefault();let r=n(),i=ie().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=Yi().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:Qi()?`fork`:`none`})})).id}${Qi()?` (forked context)`:``}`),V(),E(``)}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}`),E(``)}else{Q(`unknown @${r} — personas: ${Yi().map(e=>e.key).join(`, `)||`(none)`}`);return}}catch(e){Q(`@${r} failed: ${e.message}`)}}else 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){E(`/goal `);return}if(t===`skill`&&!n){E(`/skill `);return}E(``);try{await ka(t,n)}catch(e){throw E(ie()?`${i}\n${ie()}`:i),e}}else E(``),await Da(i)}},ka=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(V);try{if(e===`start`)await i(`/start`);else if(e===`stop`)await i(`/stop`);else if(e===`fork`)await i(`/fork`,{}),await si(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 Da(`[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}`)}},Aa,q=0;b(()=>{e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!Aa)return;let e=Math.min(q,Aa.scrollHeight);Math.abs(Aa.scrollTop-e)>1&&(Aa.scrollTop=e)})})});let ja=e=>()=>n()&&$(`/api/agents/${n()}${e}`,{method:`POST`}).then(V),Ma=async()=>{let i=n();if(!i)return;let a=new Set([i,...Nt(e(),i).map(e=>e.id)]),o=a.size-1;if(!confirm(`archive agent ${i}?\n\n`+(o>0?`Its ${o} sub-agent${o===1?``:`s`} will be archived too.\n\n`:``)+`They stop running and leave the list, but the config and full session history are KEPT — restore any of them from ⚙ settings → archive.`))return;await $(`/api/agents/${i}/archive`,{method:`POST`}).catch(()=>{}),t(e().filter(e=>!a.has(e.id))),p(!0);let s=Cu(e(),a);s?si(s.id):(r(null),h([]))},Na=async()=>{n()&&(Q(`stopped: ${((await $(`/api/agents/${n()}/stop-children`,{method:`POST`})).stopped??[]).join(`, `)||`(none)`}`),V())},Pa=()=>$(`/api/agents/${R().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(async()=>{await p(!0),await si(R().id)}),[Fa,Ia]=v(``),[La,Ra]=v(``),[za,Ba]=v(!1),[Va,Ha]=v(!0),Ua=``;b(()=>{let e=n();e&&(R()?.goal,e!==Ua&&(Ua=e,Ba(!1),Ia(``),Ra(``)))});let Wa=async e=>{if(e.preventDefault(),n()&&Fa().trim())try{await $(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:Fa(),notify:Va(),...La().trim()?{verify:La()}:{}})}),Ia(``),Ra(``),Ba(!1),V()}catch(e){Q(`goal save failed: ${e.message}`)}};return[A(M,{get when(){return or()},get children(){var e=Au();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}}),A(M,{get when(){return ue()},children:e=>(()=>{var t=ud(),n=t.firstChild;return y(t=>{var r=e(),i=le.map(t=>`${e()}?w=${t} ${t}w`).join(`, `);return r!==t.e&&F(n,`src`,t.e=r),i!==t.t&&F(n,`srcset`,t.t=i),t},{e:void 0,t:void 0}),t})()}),(()=>{var t=ad(),r=t.firstChild,i=r.firstChild,a=i.nextSibling.firstChild,o=a.firstChild;o.firstChild;var s=a.nextSibling,c=s.firstChild.firstChild.nextSibling;c.firstChild;var l=c.nextSibling,d=s.nextSibling,f=r.nextSibling,p=f.nextSibling,g=p.firstChild;g.firstChild,L(t,A(M,{get when(){return N(()=>!!he())()&&Ne()},get children(){var e=ju();return e.$$click=Fe,e}}),r),L(r,A(M,{get when(){return he()},get children(){var e=Mu(),t=e.firstChild.nextSibling;return t.$$click=Fe,e}}),i),L(i,A(j,{get each(){return Rr()},children:t=>[A(M,{get when(){return N(()=>t.wsHeader!==void 0)()&&t.wsHeader!==``},get children(){var e=fd(),n=e.firstChild;return e.$$click=()=>Pr(`ws:${t.wsHeader}`,Fr(t.wsHeader),t.wsCollapsedGroup===!0,t.collapsedVia),L(n,()=>t.wsCollapsedGroup?`▸`:`▾`),L(e,()=>Fr(t.wsHeader),null),L(e,A(M,{get when(){return(Lr().get(t.wsHeader)??0)>1||t.wsCollapsedGroup},get children(){var e=dd();return L(e,()=>Lr().get(t.wsHeader)??0),e}}),null),y(()=>F(e,`title`,t.wsCollapsedGroup?`${t.wsHeader} — collapsed (${Ir(t.wsHeader)} hidden). Click to show.`:(Lr().get(t.wsHeader)??0)>1?`${t.wsHeader} — ${Ir(t.wsHeader)} in this directory`:t.wsHeader||``)),e}}),A(M,{get when(){return N(()=>!t.headerOnly)()&&!t.wsCollapsedGroup},get children(){var r=_d(),i=r.firstChild,a=i.nextSibling;return r.$$click=()=>si(t.a.id),L(r,A(M,{get when(){return jt({isSub:!!t.a.parent,collapsed:t.chatCollapsedGroup===!0,hasChildren:e().some(e=>e.parent===t.a.id)})},get fallback(){return vd()},get children(){return(()=>{let e=!t.a.parent,n=e&&Mr().has(`chat:${t.a.id}`)||Dr(t.a.id);return(()=>{var r=yd();return r.$$click=r=>{if(r.stopPropagation(),e){if(n){if(!Cr().has(t.a.id)){let e=new Set(Cr());e.add(t.a.id),wr(e),localStorage.setItem(`teapot.expandedSubs`,JSON.stringify([...e]))}if(Tr().has(t.a.id)){let e=new Set(Tr());e.delete(t.a.id),Er(e),localStorage.setItem(`teapot.collapsed`,JSON.stringify([...e]))}}else if(Cr().has(t.a.id)){let e=new Set(Cr());e.delete(t.a.id),wr(e),localStorage.setItem(`teapot.expandedSubs`,JSON.stringify([...e]))}Pr(`chat:${t.a.id}`,t.a.id,n)}else Or(t.a.id)},L(r,n?`▸`:`▾`),y(()=>F(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),L(a,()=>t.a.sessionTitle??u().get(t.a.session??``)??t.a.id),L(r,(()=>{var e=N(()=>!!t.a.workspaceMissing);return()=>e()?bd():null})(),null),L(r,A(M,{get when(){return Un(t.a.id)>0},get children(){var e=pd();return e.firstChild,L(e,()=>Un(t.a.id),null),y(()=>F(e,`title`,`${Un(t.a.id)} unread notification${Un(t.a.id)>1?`s`:``} (including sub-agents)`)),e}}),null),L(r,A(M,{get when(){return Dr(t.a.id)||t.chatCollapsedGroup===!0&&Mr().has(`chat:${t.a.id}`)},get children(){return(()=>{let n=Nt(e(),t.a.id),r=n.filter(e=>e.live??(e.status===`running`||e.status===`waiting`||e.status===`needs_operator`)).length;return n.length>0?(()=>{var e=xd();return e.firstChild,I(e,`subcount`+(r>0?` live`:``)),L(e,()=>n.length,null),L(e,r>0?` · ▶${r}`:``,null),y(()=>F(e,`title`,`${n.length} sub-agent${n.length>1?`s`:``} (${r} active)`)),e})():null})()}}),null),L(r,A(M,{get when(){return t.a.parent},get children(){return md()}}),null),L(r,A(M,{get when(){return Sr(t.a.id).length>0},get children(){var e=hd();return y(()=>F(e,`title`,Sr(t.a.id).map(e=>`${e.id}: ${e.schedule}`).join(`
|
|
25
|
-
`))),e}}),null),L(r,A(M,{get when(){return t.a.goal.status===`done`},get children(){return gd()}}),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?(()=>{let e=Mt(t.a.id,Yi().map(e=>e.key));return e?`sub-agent of @${t.a.parent} — "${e}"`:`sub-agent of @${t.a.parent}`})():void 0,l=`dot ${t.a.status}`,d=t.a.status===`needs_operator`?`waiting for your answer`:t.a.status===`waiting`?`waiting on its own work — resumes by itself`:t.a.status,f=t.a.workspaceMissing?` ghost`:``,p=t.a.workspaceMissing?`workspace not found on disk (${t.a.workspace}) — it will be created when this session runs`:t.a.sessionTitle??u().get(t.a.session??``)?`${t.a.sessionTitle??u().get(t.a.session??``)} — ${t.a.id}`:t.a.id;return o!==e.e&&I(r,e.e=o),e.t=De(r,s,e.t),c!==e.a&&F(r,`title`,e.a=c),l!==e.o&&I(i,e.o=l),d!==e.i&&F(i,`title`,e.i=d),f!==e.n&&I(a,e.n=f),p!==e.s&&F(a,`title`,e.s=p),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r}})]})),o.$$click=e=>{e.stopPropagation(),zn(!Rn()),Rn()||Fn(e=>e.map(e=>({...e,read:!0})))},L(o,A(M,{get when(){return Bn()>0},get children(){var e=Nu();return L(e,Bn),e}}),null),L(a,A(Uh,{icon:`👻`,get active(){return In()},get title(){return In()?`show ghost sessions again (👻 workspace missing on disk)`:`hide ghost sessions (👻 — their workspace directory no longer exists)`},onClick:t=>{t.stopPropagation();let r=!In();if(Ln(r),localStorage.setItem(`teapot.hideGhosts`,r?`1`:`0`),r&&n()&&R()?.workspaceMissing){let t=e().find(e=>!e.workspaceMissing);t&&si(t.id)}}}),null),L(a,A(Uh,{icon:`+`,title:`new agent`,onClick:()=>{ar(),ce(!0)}}),null),L(a,A(Uh,{icon:`⚙`,title:`settings`,onClick:()=>{ar(),k(!0)}}),null),L(c,`0.36.
|
|
26
|
-
`)}`)),e}}),o),L(o,()=>R().model,s),L(o,()=>R().session,c),L(o,()=>R().branch,l),L(o,()=>R().stats.turns,u),L(o,()=>R().stats.toolCalls,d),p.$$click=()=>(Tn()?ja(`/stop`):ja(`/start`))(),L(p,()=>Tn()?`■ stop`:`▶ start`),L(f,A(M,{get when(){return e().some(e=>e.parent===n())},get children(){return A(Uh,{icon:`⏹`,title:`stop every sub-agent this agent spawned (descendants included)`,onClick:Na})}}),m),L(f,A(Uh,{icon:`🗄`,title:`archive this agent — reversible: it leaves the list but keeps its config and history (restore in ⚙ settings → archive)`,onClick:Ma}),null),L(f,A(Uh,{icon:`⑂`,title:`fork: branch off the conversation here — try things without disturbing the main line`,onClick:Pa}),null),L(f,A(Uh,{icon:`⌨`,title:`terminal (t)`,onClick:Si}),null),L(f,A(Uh,{icon:`▤`,title:`toggle details panel (d)`,get active(){return Te()},onClick:je}),null),y(e=>{var t=`badge ${R().status}`,n=R().statusReason&&!/^(round complete|prompt|api start|goal set|created via web|start)$/.test(R().statusReason)?`${R().status} — ${R().statusReason}`:void 0,r=`${R().model} · ${R().session}/${R().branch} · turns ${R().stats.turns} · tools ${R().stats.toolCalls}`,i=`runbtn`+(Tn()?` danger`:``),s=Tn()?`interrupt: aborts the current LLM call; the running tool finishes first`:`run toward the goal (starts the loop)`;return t!==e.e&&I(a,e.e=t),n!==e.t&&F(a,`title`,e.t=n),r!==e.a&&F(o,`title`,e.a=r),i!==e.o&&I(p,e.o=i),s!==e.i&&F(p,`title`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})(),(()=>{var e=Gu();return e.addEventListener(`scroll`,e=>{let t=e.currentTarget,r={top:t.scrollTop,height:t.scrollHeight,viewport:t.clientHeight},i=un(r,_a,va,Ca);i===`layout`&&!Ct()&&Sa>0&&Math.abs(r.height-(va??r.height))>1&&(Sa--,Se(t,ya)),_a=null,va=r.height,Ca=r.viewport,At(r);let a=Ct(),o=performance.now();o-ba>100&&(ba=o,ya=P(t));let s=fn(a,i,r);s!==a&&wt(s),i===`reader`&&(Sa=4),s&&i!==`reader`?(Tt()&&Et(0),Hn(),dn(s,r)&&cn(r)>0&&ri()):s&&ln(r)&&(Tt()&&Et(0),Hn()),r.top<=4&&n()&&!U()&&!W()&&m().length>0&&Qr()}),ke(e=>we(e),e),L(e,A(M,{get when(){return Lt()},children:e=>(()=>{var t=Cd();return t.firstChild,L(t,(()=>{var t=N(()=>e().phase===`harvesting`);return()=>t()?`saving durable lessons…`:`summarizing ${e().summarized?Bh(e().summarized)+` `:``}older messages…`})(),null),t})()}),null),L(e,A(M,{get when(){return N(()=>!!W())()&&er().length>0},get children(){return zu()}}),null),L(e,A(M,{get when(){return U()},get children(){return Bu()}}),null),L(e,A(M,{get when(){return er().length>0},get fallback(){return N(()=>!!Gr())()?wd():Td()},get children(){return[A(j,{get each(){return er()},children:e=>A(Fh,{e,prev:()=>nr(e,-1),next:()=>nr(e,1),get showBranch(){return te().length>1},res:()=>Jn().resFor.get(e.id),get orphan(){return Jn().orphanCalls.has(e.id)},onOption:e=>void Da(e),answeredIds:$n,onAnswered:Zn,get agentActive(){return N(()=>!!En())()&&Ye(e)},onResize:()=>{Ct()&&ri()},get onCancel(){return e.data?.source===`user`&&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??``);E(ie()?`${n}\n\n${ie()}`:n),Nn(jn(),z().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&&!Tn()?()=>kn({eventId:e.id,text:String(e.data?.text??``)}):void 0}})}),A(M,{get when(){return N(()=>!!En())()&&Zt()},get children(){var e=Wu(),t=e.firstChild.nextSibling;return t.firstChild,L(t,A(M,{get when(){return vn().trim()!==``},get children(){var e=Vu(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return L(t,A(Oh,{get startedAt(){return _n()}}),null),ke(e=>{let t=!0;e.addEventListener(`scroll`,()=>{t=e.scrollHeight-e.scrollTop-e.clientHeight<24}),b(()=>{vn(),t&&(e.scrollTop=e.scrollHeight)})},n),L(n,vn),e}}),null),L(t,A(M,{get when(){return en()},get fallback(){return Ed()},get children(){return A(M,{get when(){return zt()},get fallback(){return(()=>{var e=Uu();return y(()=>e.innerHTML=Le(en()+`▍`)),e})()},get children(){return[Hu(),(()=>{var e=Uu();return y(()=>e.innerHTML=Le(Bt()+`▍`)),e})()]}})}}),null),e}})]}}),null),e})(),A(M,{get when(){return bi()},get children(){var t=Xu(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=r.nextSibling,c=s.firstChild;n.$$dblclick=()=>{Ni(Math.max(220,Math.round(window.innerHeight*.35))),localStorage.setItem(`teapot.termH`,String(Mi()))},n.$$pointerdown=Gi,L(i,A(j,{get each(){return Ci()},children:(e,t)=>(()=>{var n=Dd(),r=n.firstChild.nextSibling;return n.$$click=()=>Li(t()),L(n,()=>e.title,r),r.$$click=e=>{e.stopPropagation(),Bi(t())},y(r=>{var i=`termtab`+(Ai()===0&&Ti()===t()?` active`:``)+(K()&&Ai()===1&&Di()===t()?` active`:``),a=`${e.title} — click to show in focused pane`;return i!==r.e&&I(n,r.e=i),a!==r.t&&F(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()}),null),L(i,A(Uh,{icon:`+`,title:`new shell in this workspace`,onClick:Ri}),null),L(o,(()=>{var t=N(()=>!!Ii());return()=>t()?e().find(e=>e.id===Ii().agentId)?.workspace.split(`/`).filter(Boolean).pop():R()?.workspace})()),L(a,A(Uh,{icon:`◫`,get title(){return K()?`single pane`:`split panes (50/50)`},onClick:Ki}),null),L(a,A(Uh,{icon:`▾`,title:`hide the terminal (shells keep running; reopen with t) — close individual shells with their ✕ tab buttons`,onClick:Si}),null);var l=qi(0);return typeof l==`function`&&ke(l,c),c.$$pointerdown=()=>ji(0),L(c,A(M,{get when(){return Ti()<0||Ti()>=Ci().length},get children(){return Ku()}})),L(s,A(M,{get when(){return K()},get children(){return[qu(),(()=>{var e=Yu(),t=qi(1);return typeof t==`function`&&ke(t,e),e.$$pointerdown=()=>ji(1),L(e,A(M,{get when(){return Di()<0||Di()>=Ci().length},get children(){return Ju()}})),y(()=>e.classList.toggle(`focused`,Ai()===1)),e})()]}}),null),y(e=>{var n={height:`${Mi()}px`},r=!!K(),i=Ai()===0;return e.e=De(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=rd(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling;return L(e,A(M,{get when(){return N(()=>Dt()>32)()&&!Ct()},get children(){var e=Zu();return e.firstChild,e.$$click=()=>{ii(!0),Hn()},L(e,(()=>{var e=N(()=>Tt()>0);return()=>e()?`${Tt()} new message${Tt()>1?`s`:``}`:`jump to present`})(),null),e}}),t),L(e,A(M,{get when(){return la().length>0},get children(){var e=Qu();return L(e,A(j,{get each(){return la()},children:(e,t)=>(()=>{var n=Od(),r=n.firstChild,i=r.nextSibling;return n.$$click=()=>{E(e.insert),ca(-1)},L(r,()=>e.insert.trim()),L(i,()=>e.title),y(r=>{var i=`cmdrow`+(t()===sa()?` active`:``),a=e.title;return i!==r.e&&I(n,r.e=i),a!==r.t&&F(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()})),e}}),t),L(e,A(M,{get when(){return ta().length>0},get children(){var e=Qu();return L(e,A(j,{get each(){return ta()},children:e=>(()=>{var t=kd(),n=t.firstChild;n.firstChild;var r=n.nextSibling;return t.$$click=()=>{E(`@${e.key} `),ca(-1)},L(n,()=>e.key,null),L(r,()=>e.label),y(()=>F(t,`title`,e.label)),t})()})),e}}),t),t.addEventListener(`submit`,Oa),L(t,A(M,{get when(){return wa().length>0},get children(){var e=$u(),t=e.firstChild,n=t.firstChild,r=n.nextSibling;return r.nextSibling,L(e,A(j,{get each(){return wa()},children:(e,t)=>(()=>{var n=Ad(),r=n.firstChild,i=r.nextSibling;return i.$$click=()=>Ta(e=>e.filter((e,n)=>n!==t())),y(t=>{var i=e.name,a=e.url,o=e.name;return i!==t.e&&F(n,`title`,t.e=i),a!==t.t&&F(r,`src`,t.t=a),o!==t.a&&F(r,`alt`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}),t),L(t,()=>wa().length,n),L(t,()=>wa().length>1?`s`:``,r),e}}),n),n.$$keydown=e=>{let t=la();t.length>0&&e.key===`ArrowDown`?(e.preventDefault(),ca(e=>Math.min(e+1,t.length-1))):t.length>0&&e.key===`ArrowUp`?(e.preventDefault(),ca(e=>Math.max(e-1,0))):t.length>0&&(e.key===`Tab`||e.key===`Enter`)&&!e.shiftKey&&sa()>=0&&!gh?(e.preventDefault(),E(t[sa()].insert),ca(-1)):e.key===`Escape`&&t.length>0?ca(-1):e.key===`Enter`&&!e.shiftKey&&!gh&&!bt()&&(e.preventDefault(),Oa(e))},n.$$input=e=>{E(e.currentTarget.value),ca(0),ha()},n.addEventListener(`paste`,e=>{let t=Array.from(e.clipboardData?.files??[]).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Ea(t))}),n.addEventListener(`compositionend`,()=>{requestAnimationFrame(()=>{gh=!1}),E(ua?.value??``)}),n.addEventListener(`compositionstart`,()=>{gh=!0}),ke(e=>{ua=e,e.value=ie()},n),L(t,A(M,{get when(){return N(()=>!!ie().startsWith(`@`))()&&ie().includes(` `)},get children(){var e=ed(),t=e.firstChild;return t.addEventListener(`change`,e=>$i(e.currentTarget.checked)),y(()=>t.checked=Qi()),e}}),r),r.$$click=()=>{let e=!bt();xt(e),requestAnimationFrame(()=>ha())},L(r,()=>bt()?`⤡`:`⤢`),L(t,A(Uh,{icon:`📎`,title:`attach images (or paste them straight into the box)`,onClick:()=>document.getElementById(`composer-file`)?.click()}),i),L(t,A(M,{get when(){return wa().length},get children(){var e=td();return e.firstChild,L(e,()=>wa().length,null),e}}),i),a.addEventListener(`change`,e=>{e.currentTarget.files?.length&&Ea(e.currentTarget.files),e.currentTarget.value=``}),L(e,A(M,{get when(){return ph()},get children(){var e=nd();return L(e,ph),e}}),null),y(t=>{var i=`composer`+(bt()?` maximized`:``),a=`message #${R().id} — / for commands · paste or 📎 to attach images`,o=bt()?`restore composer (hide timeline)`:`maximize composer — hide the timeline and fill the main column`;return i!==t.e&&I(e,t.e=i),a!==t.t&&F(n,`placeholder`,t.t=a),o!==t.a&&F(r,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),e})()]}})),L(t,A(M,{get when(){return N(()=>!!he())()&&Te()},get children(){var e=id();return e.$$click=()=>Ae(!1),e}}),p),p.addEventListener(`scroll`,e=>{q=e.currentTarget.scrollTop});var v=Aa;return typeof v==`function`?ke(v,p):Aa=p,L(g,A(Uh,{icon:`✕`,title:`close details panel (esc)`,onClick:Me}),null),L(p,A(M,{get when(){return R()?.id},keyed:!0,fallback:null,children:t=>[A(M,{get when(){return R().id},keyed:!0,fallback:null,children:e=>A(rg,{agentId:e,get workspace(){return R().workspace}})}),jd(),(()=>{var t=Pd(),r=t.firstChild,i=r.nextSibling,a=i.firstChild,o=a.nextSibling,s=i.nextSibling,c=s.firstChild,l=s.nextSibling;return l.firstChild,r.addEventListener(`change`,t=>{let r=t.currentTarget.value;yt=!0,at(r),st(tn(D().providers,r,e().find(e=>e.id===n()))),pt(r)}),L(r,A(j,{get each(){return ft()},children:e=>(()=>{var t=tf();return t.value=e,L(t,e,null),L(t,()=>e===D().defaultProvider?` ★`:``,null),t})()})),a.$$input=e=>st(e.currentTarget.value),L(o,A(j,{get each(){return ut()},children:e=>(()=>{var t=tf();return y(()=>t.value=e.id),t})()})),L(t,A(M,{get when(){return R().effortSupported},get children(){var e=Md(),t=e.firstChild.nextSibling;return t.firstChild,t.addEventListener(`change`,e=>lt(e.currentTarget.value)),L(t,A(j,{get each(){return N(()=>!!R().effortOptions?.length)()?R().effortOptions:lh},children:e=>(()=>{var t=tf();return t.value=e,L(t,e),t})()}),null),y(()=>t.value=ct()),e}}),s),c.$$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:it(),model:ot().trim()||void 0,contextWindowTokens:ut().find(e=>e.id===(ot().trim()||void 0))?.contextLength,...R().effortSupported?{reasoningEffort:ct()}:{}})}),t.textContent=`✓ applied`,V()}catch(e){alert(`apply failed: ${e.message}`)}finally{setTimeout(()=>{t.textContent=`apply`,t.disabled=!1},1200)}},L(l,()=>R().model,null),L(l,A(M,{get when(){return ut().length},get children(){return[` · `,N(()=>ut().length),` models loaded`]}}),null),L(t,A(M,{get when(){return _t()},get children(){var e=Nd();return L(e,_t),e}}),null),y(()=>F(a,`placeholder`,nn(D().providers,it(),R(),$t(R(),D().providers,D().defaultProvider)))),y(()=>r.value=it()),y(()=>a.value=ot()),t})(),(()=>{var e=Fd(),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(V)}),y(()=>t.checked=R().autoContinue??!0),e})(),(()=>{var e=Ld();return e.firstChild,L(e,A(M,{get when(){return!!R().goal.text.trim()},get fallback(){return nf()},get children(){var e=Id();return L(e,()=>R().goal.status),y(()=>I(e,`badge ${R().goal.status===`active`?`running`:R().goal.status}`)),e}}),null),e})(),(()=>{var e=Rd();return e.firstChild,L(e,A(j,{each:[`active`,`done`,`paused`],children:e=>(()=>{var t=rf();return t.$$click=()=>{n()&&$(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:e})}).then(V)},F(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`),L(t,e===`active`?`▶ working`:e===`done`?`✓ done`:`⏸ paused`),y(n=>{var r=`goalstate`+(R().goal.text.trim()&&R().goal.status===e?` on ${e}`:``),i=!!R().goal.text.trim()&&R().goal.status===e;return r!==n.e&&I(t,n.e=r),i!==n.t&&(t.disabled=n.t=i),n},{e:void 0,t:void 0}),t})()}),null),e})(),A(M,{get when(){return R().goal.text},get fallback(){return af()},get children(){return[(()=>{var e=zd(),t=e.firstChild;return y(()=>t.innerHTML=Le(String(R().goal.text))),e})(),A(M,{get when(){return R().goal.verify},get children(){var e=Bd(),t=e.firstChild.nextSibling;return y(()=>t.innerHTML=Le(String(R().goal.verify))),e}}),A(M,{get when(){return R().goal.audit},children:e=>(()=>{var t=of(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return L(n,()=>e().verdict===`approved`?`✅ audit: approved`:`⚠ audit: changes required`,r),L(r,()=>zh(e().at)),y(n=>{var r=`card auditcard `+(e().verdict===`approved`?`ok`:`warn`),a=gt(e().feedback)?Le(`_the auditor returned a verdict with no detail_`):Le(e().feedback);return r!==n.e&&I(t,n.e=r),a!==n.t&&(i.innerHTML=n.t=a),n},{e:void 0,t:void 0}),t})()})]}}),(()=>{var e=Vd(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.firstChild.firstChild;return e.addEventListener(`submit`,Wa),t.$$input=e=>{Ia(e.currentTarget.value),Ba(!0)},n.$$input=e=>{Ra(e.currentTarget.value),Ba(!0)},r.addEventListener(`change`,e=>Ha(e.currentTarget.checked)),y(()=>t.value=Fa()),y(()=>n.value=La()),y(()=>r.checked=Va()),e})(),(()=>{var e=Ud(),t=e.firstChild.nextSibling;return L(e,A(M,{get when(){return gr().total>0},get children(){var e=Hd(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,L(e,()=>gr().done,t),L(e,()=>gr().total,n),y(t=>De(e,gr().done===gr().total?`color:var(--ok)`:`color:var(--warn)`,t)),e}}),t),e})(),A(M,{get when(){return gr().total>0},get children(){var e=Wd(),t=e.firstChild;return y(e=>{var n=`barfill `+(gr().done===gr().total?``:`warn`),r=`${Math.round(gr().done/gr().total*100)}%`;return n!==e.e&&I(t,e.e=n),r!==e.t&&Oe(t,`width`,e.t=r),e},{e:void 0,t:void 0}),e}}),A(ng,{get draft(){return cr()},get preview(){return ur()},onDraft:e=>{lr(e),pr(!0)}}),(()=>{var e=Gd(),t=e.firstChild,n=t.nextSibling;return L(e,A(Uh,{get icon(){return ur()?`✎`:`👁`},get title(){return ur()?`edit markdown`:`rendered checklist`},onClick:()=>dr(!ur())}),t),n.$$click=hr,e})(),Kd(),A(M,{get when(){return R().latestProgress},get fallback(){return sf()},children:e=>(()=>{var t=ff(),n=t.firstChild,r=n.firstChild.nextSibling,i=n.nextSibling;return L(t,A(M,{get when(){return e().recent},get children(){var t=cf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().recent)),t}}),i),L(t,A(M,{get when(){return e().problems},get children(){var t=lf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().problems)),t}}),i),L(t,A(M,{get when(){return e().next},get children(){var t=uf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().next)),t}}),i),L(t,A(M,{get when(){return e().goalStatus},get children(){var t=df(),n=t.firstChild.nextSibling;return L(n,()=>e().goalStatus),t}}),i),L(i,()=>zh(e().ts)),y(()=>r.innerHTML=ch(e().doing)),t})()}),qd(),(()=>{var e=Xd(),t=e.firstChild,r=t.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling,o=a.firstChild.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling,l=s.nextSibling,u=l.firstChild.nextSibling,d=l.nextSibling,f=d.firstChild.nextSibling;return L(e,A(M,{get when(){return R().ctx},keyed:!0,get fallback(){return pf()},children:e=>{let t=x(()=>{let t=e,n=ut().find(e=>e.id===R().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=_f(),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;return L(a,()=>Bh(r().usedTokens),o),L(t,A(M,{get when(){return r().effectiveWindow},get children(){var e=mf(),t=e.firstChild;return L(e,()=>i(r().pct),t),L(e,()=>Bh(r().effectiveWindow),null),y(()=>I(e,`pill ${r().cls}`)),e}}),null),L(e,A(M,{get when(){return r().effectiveWindow},get children(){var e=hf(),t=e.firstChild;return y(e=>{var n=`barfill ${r().cls}`,i=`${Math.min(100,r().pct)}%`;return n!==e.e&&I(t,e.e=n),i!==e.t&&Oe(t,`width`,e.t=i),e},{e:void 0,t:void 0}),e}}),s),L(c,()=>Bh(r().usingDerived?r().derivedBudget:r().compactAt),l),L(u,()=>r().usingDerived?`75% of window`:`manual`),L(e,A(M,{get when(){return Lt()||r().compacting},get children(){var e=gf(),t=e.firstChild.nextSibling.nextSibling;return L(t,()=>Lt()?.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(V)}),y(()=>f.checked=R().autoCompact!==!1),e})()}}),t),L(i,()=>Bh(R().stats.inputTokens)),L(o,()=>Bh(R().stats.outputTokens)),L(c,()=>R().stats.turns),L(u,()=>R().stats.toolCalls),L(f,()=>R().stats.compactions??0),L(t,A(M,{get when(){return(R().stats.costUsd??0)>0},get children(){var e=Jd(),t=e.firstChild.nextSibling;return t.firstChild,L(t,()=>Vh(R().stats.costUsd??0),null),y(()=>F(e,`title`,`≈ ${(R().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),L(t,A(M,{get when(){return(R().stats.cachedInputTokens??0)>0},get children(){var e=Yd(),t=e.firstChild.nextSibling,n=t.firstChild;return L(t,()=>Math.round(R().stats.cachedInputTokens/Math.max(1,R().stats.inputTokens)*100),n),y(()=>F(e,`title`,`${Bh(R().stats.cachedInputTokens)} input tokens were served from the provider's prompt cache — billed far cheaper than fresh input`)),e}}),null),y(()=>F(d,`title`,`how many times old turns were summarized into notes to make room. ${R().stats.compactions?`Each one keeps the recent stretch verbatim.`:`Not yet — the context has fit so far.`}`)),e})(),(()=>{var e=Qd();return e.firstChild.nextSibling,L(e,A(M,{get when(){return Br()},get children(){var e=Zd(),t=e.firstChild.nextSibling;return L(t,Br),e}}),null),e})(),A(j,{get each(){return te()},children:e=>(()=>{var t=vf(),r=t.firstChild,i=r.nextSibling,a=i.firstChild;return t.$$click=()=>{let t=Br()===e.branch?null:e.branch,r=t!==Br();Vr(t),n()&&(r&&(Jr++,h([]),_(0),qr(!1)),$r(n()))},L(r,()=>e.branch,null),L(r,()=>e.branch===R().branch?` (current)`:``,null),L(i,()=>e.events,a),y(n=>{var r=`branch-row`+(e.branch===R().branch||e.branch===Br()?` cur`:``),i=e.branch===Br()?`click to show all branches again`:`show only ${e.branch}`;return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()}),(()=>{var e=ef();return e.firstChild,L(e,A(M,{get when(){return yr().length>0},get children(){var e=$d(),t=e.firstChild.nextSibling;return t.nextSibling,L(e,()=>yr().length,t),e}}),null),e})(),A(M,{get when(){return yr().length>0},get fallback(){return yf()},get children(){return A(j,{get each(){return yr()},children:e=>(()=>{var t=xf(),r=t.firstChild,i=r.firstChild,a=i.nextSibling;a.firstChild;var o=r.nextSibling,s=o.firstChild,c=o.nextSibling;return t.$$click=()=>si(e.agent),L(i,()=>e.id),L(a,()=>e.agent,null),L(r,A(M,{get when(){return e.forked},get children(){return bf()}}),null),L(o,()=>e.schedule,s),L(o,(()=>{var t=N(()=>!!e.next);return()=>t()?zh(e.next):`—`})(),null),L(o,(()=>{var t=N(()=>!!e.last);return()=>t()?` · last ${zh(e.last)}`:` · never ran`})(),null),L(c,()=>Hh(e.prompt,90)),y(r=>{var i=`sched-row`+(e.agent===n()?` cur`:``),a=`${Hh(e.prompt,200)}\nclick to open #${e.agent}`;return i!==r.e&&I(t,r.e=i),a!==r.t&&F(t,`title`,r.t=a),r},{e:void 0,t:void 0}),t})()})}})]}),null),y(e=>{var n=`layout`+(Te()?``:` right-hidden`)+(Ne()?` left-open`:``),i=`sidebar`+(Ne()?` open`:``),a=`iconbtn notifbtn`+(Bn()>0?` has-unread`:``),s=Bn()>0?`${Bn()} unread notifications`:`notifications`,c=`conn`+(G()?` ok`:``),u=G()?`live (websocket)`:`reconnecting…`,d={"--termh":`${Mi()}px`},m=`rightbar`+(Te()?` open`:``);return n!==e.e&&I(t,e.e=n),i!==e.t&&I(r,e.t=i),a!==e.a&&I(o,e.a=a),s!==e.o&&F(o,`title`,e.o=s),c!==e.i&&I(l,e.i=c),u!==e.n&&F(l,`title`,e.n=u),e.s=De(f,d,e.s),m!==e.h&&I(p,e.h=m),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),t})(),A(M,{get when(){return Rn()},get children(){return[(()=>{var e=od();return e.$$click=()=>zn(!1),e})(),(()=>{var t=ld(),r=t.firstChild.firstChild.nextSibling,i=r.firstChild;return L(r,A(M,{get when(){return Pn().length>0},get children(){var e=sd();return e.$$click=()=>Fn([]),e}}),i),i.$$click=()=>zn(!1),L(t,A(M,{get when(){return Pn().length>0},get fallback(){return Sf()},get children(){var t=cd();return L(t,A(j,{get each(){return Pn()},children:t=>(()=>{var r=wf(),i=r.firstChild.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return r.$$click=()=>{Fn(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e)),n()!==t.agentId&&e().some(e=>e.id===t.agentId)&&si(t.agentId),zn(!1),t.eventId&&setTimeout(()=>qn(t.eventId),n()===t.agentId?60:350)},L(i,(()=>{var e=N(()=>t.kind===`finish`);return()=>e()?`✅`:N(()=>t.kind===`question`)()?`❓`:t.kind===`error`?`⚠️`:`📈`})()),L(a,()=>t.title),L(o,()=>zh(new Date(t.at).toISOString())),s.$$click=e=>{e.stopPropagation(),Fn(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e))},L(s,()=>t.read?`✓`:`○`),L(r,A(M,{get when(){return t.body},get children(){var e=Cf();return L(e,()=>Rh(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&&I(r,e.e=n),i!==e.t&&F(r,`title`,e.t=i),a!==e.a&&F(s,`title`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r})()})),t}}),null),t})()]}}),A(M,{get when(){return se()},get children(){return A(Kh,{get providers(){return Object.keys(D().providers??{})},onClose:()=>ce(!1),onCreated:e=>{ce(!1),V(),si(e)}})}}),A(M,{get when(){return de()},get children(){return A(sg,{get cfg(){return D()},onClose:()=>k(!1),announcedOAuth:pe,get skills(){return ra()},get hasSelection(){return!!n()},get agentId(){return n()},get features(){return aa()},onSaved:()=>{ar(),xr()},theme:{themes:Ke,activeId:Ie,paintedId:O,auto:ze,setAuto:Be,dark:$e,setDark:et,light:Ve,setLight:He,setThemes:Je,setActive:Re}})}}),A(M,{get when(){return On()},fallback:null,children:e=>{let t=()=>m().findIndex(t=>t.id===e().eventId),r=()=>Math.max(0,m().length-t()-1),[i,a]=v(r()>0?`summarize`:`discard`);return A(Gh,{title:`edit prompt — forks the conversation`,onClose:()=>kn(null),get children(){var t=Ef(),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()})}),kn(null),V();let t=n();t&&await si(t)}catch(e){alert(`edit failed: ${e.message}`)}}),L(t,A(M,{get when(){return r()>0},get children(){var e=Tf(),t=e.firstChild,n=t.firstChild,o=t.nextSibling,s=o.firstChild,c=o.nextSibling.firstChild;return L(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=()=>kn(null),y(()=>o.value=e().text),t}})}})]}function Dh(e){let t=new Date(e.startedAt).getTime(),[n,r]=v(Date.now());ee(()=>{let e=setInterval(()=>r(Date.now()),500);C(()=>clearInterval(e))});let i=()=>He(Math.max(0,n()-t));return e.inline?(()=>{var t=Df();return t.firstChild,L(t,i,null),L(t,(()=>{var t=N(()=>!!e.timeoutMs);return()=>t()?` · timeout ${Math.round(e.timeoutMs/1e3)}s`:``})(),null),t})():(()=>{var e=Of(),t=e.firstChild;return L(e,i,t),e})()}function Oh(e){let[t,n]=v(Date.now());return ee(()=>{let e=setInterval(()=>n(Date.now()),500);C(()=>clearInterval(e))}),e.startedAt?(()=>{var n=kf();return L(n,()=>He(Math.max(0,t()-e.startedAt))),n})():null}var kh=new Map,Ah=400;function jh(e,t){if(kh.size>=Ah){let e=kh.keys().next();e.done||kh.delete(e.value)}kh.set(e,t)}function Mh(e){let t=()=>e.lang?`${e.lang}::${e.text.length}::${e.text}`:``,[n,r]=v((e.lang?kh.get(t()):void 0)??``);return b(()=>{let n=t(),i=e.text,a=e.lang;if(!a||!i.trim()){r(``);return}let o=kh.get(n);o===void 0?(async()=>{try{let{highlightLangChunks:e}=await ku(async()=>{let{highlightLangChunks:e}=await import(`./shiki-D3K-t1Ea.js`);return{highlightLangChunks:e}},[]),o=``;for await(let t of e(a,i))o+=t;if(!o)return;jh(n,o),t()===n&&r(o)}catch{}})():r(o)}),A(M,{get when(){return!!n()},get fallback(){return(()=>{var t=jf();return L(t,()=>e.text),t})()},get children(){var e=Af();return y(()=>e.innerHTML=n()),e}})}function Nh(e){let t=e.e,n=Bt(e.prev,t),r=x(()=>e.res?.(),void 0,{equals:(e,t)=>e?.id===t?.id}),i=()=>r(),a=()=>!e.agentActive&&!i(),o=t.data??{},s=String(o.name??`tool`),c=()=>String(i()?.data?.result??``),l=e=>String(o.args?.[e]??``),u=()=>s===`bash`?l(`command`):l(`path`)||JSON.stringify(o.args??{},null,1),d=()=>s===`bash`?Number(l(`timeout_ms`))||void 0:s===`wait_children`?Number(l(`timeout_ms`))||3e5:Number(l(`timeout_ms`))||void 0,f=(e,t=1500,n)=>A(Mh,{get text(){return Rh(e,t)},lang:n}),p=(e=2e3)=>A(Mh,{get text(){return Rh(JSON.stringify(o.args??{},null,1),e)},lang:`json`}),m=(e=4e3)=>(()=>{let t=i();return t?[N(()=>f(c(),e,xt(c()))),(()=>{var e=Mf();return L(e,()=>He(t.data?.durationMs),null),L(e,()=>s===`bash`?Zt(Xt(t.data?.ok,String(t.data?.result??``))):t.data?.ok===!1?` · FAILED`:``,null),L(e,A(Wh,{get text(){return c()}}),null),e})()]:Nf()})(),h=x(()=>{i();let e=s,t=``,n=p(2e3);try{switch(s){case`bash`:{let r=l(`command`),a=o.args?.background===!0,s=a?String(c()).match(/job (bg\d+)/)?.[1]??``:``;e=(a?`⏳ `:`$ `)+Hh(r,96);let u=l(`timeout_ms`)?Number(l(`timeout_ms`)):void 0,d=i(),p=Xt(d?.data?.ok,d?String(d.data?.result??``):``);t=d?a?`background job${s?` ${s}`:``}${u?` · timeout ${Math.round(u/1e3)}s`:``}`:Qt({outcome:p,durationMs:d.data?.durationMs,timeoutMs:u,fmtDur:He}):null,n=[a?(()=>{var e=Pf(),t=e.firstChild.nextSibling,n=t.firstChild.nextSibling;return n.nextSibling,L(t,s||`?`,n),L(e,s?[` · kill with `,Ff()]:null,null),e})():null,N(()=>N(()=>r!==e.slice(2))()?f(r,800,`shellscript`):null),N(()=>m(6e3))];break}case`read_file`:{e=l(`path`)||`(no path)`;let r=[];l(`pattern`)&&r.push(`grep /${Hh(l(`pattern`),40)}/`),Number(o.args?.offset)<0?r.push(`last ${-Number(o.args.offset)} lines`):o.args?.offset&&r.push(`from L${o.args.offset}`),o.args?.limit&&r.push(`≤${o.args.limit} lines`),t=r.join(` · `),n=m(6e3);break}case`write_file`:{let r=String(o.args?.content??``);e=l(`path`)||`(no path)`,t=`${Bh(r.length)} bytes`,n=[N(()=>f(r,1500)),N(()=>N(()=>r.length>1500)()?(()=>{var e=If(),t=e.firstChild;return L(e,()=>Bh(r.length),t),e})():null),N(()=>N(()=>!!i())()?(()=>{var e=Mf();return L(e,()=>Hh(c(),160)),e})():Lf())];break}case`edit_file`:e=l(`path`)||`(no path)`,t=o.args?.replace_all===!0?`replace all`:`unique spot`,n=[(()=>{var e=Rf();return L(e,()=>Rh(`- `+l(`old_text`),900)),e})(),(()=>{var e=zf();return L(e,()=>`+ `+Rh(l(`new_text`),900)),e})(),N(()=>N(()=>!!i())()?(()=>{var e=Bf(),t=e.firstChild;return L(e,()=>Hh(c(),120),t),L(e,()=>He(i().data?.durationMs),null),e})():Vf())];break;case`apply_patch`:{let t=l(`patch`).split(`
|
|
25
|
+
`))),e}}),null),L(r,A(M,{get when(){return t.a.goal.status===`done`},get children(){return gd()}}),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?(()=>{let e=Mt(t.a.id,Yi().map(e=>e.key));return e?`sub-agent of @${t.a.parent} — "${e}"`:`sub-agent of @${t.a.parent}`})():void 0,l=`dot ${t.a.status}`,d=t.a.status===`needs_operator`?`waiting for your answer`:t.a.status===`waiting`?`waiting on its own work — resumes by itself`:t.a.status,f=t.a.workspaceMissing?` ghost`:``,p=t.a.workspaceMissing?`workspace not found on disk (${t.a.workspace}) — it will be created when this session runs`:t.a.sessionTitle??u().get(t.a.session??``)?`${t.a.sessionTitle??u().get(t.a.session??``)} — ${t.a.id}`:t.a.id;return o!==e.e&&I(r,e.e=o),e.t=De(r,s,e.t),c!==e.a&&F(r,`title`,e.a=c),l!==e.o&&I(i,e.o=l),d!==e.i&&F(i,`title`,e.i=d),f!==e.n&&I(a,e.n=f),p!==e.s&&F(a,`title`,e.s=p),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r}})]})),o.$$click=e=>{e.stopPropagation(),zn(!Rn()),Rn()||Fn(e=>e.map(e=>({...e,read:!0})))},L(o,A(M,{get when(){return Bn()>0},get children(){var e=Nu();return L(e,Bn),e}}),null),L(a,A(Uh,{icon:`👻`,get active(){return In()},get title(){return In()?`show ghost sessions again (👻 workspace missing on disk)`:`hide ghost sessions (👻 — their workspace directory no longer exists)`},onClick:t=>{t.stopPropagation();let r=!In();if(Ln(r),localStorage.setItem(`teapot.hideGhosts`,r?`1`:`0`),r&&n()&&R()?.workspaceMissing){let t=e().find(e=>!e.workspaceMissing);t&&si(t.id)}}}),null),L(a,A(Uh,{icon:`+`,title:`new agent`,onClick:()=>{ar(),ce(!0)}}),null),L(a,A(Uh,{icon:`⚙`,title:`settings`,onClick:()=>{ar(),k(!0)}}),null),L(c,`0.36.9`,null),L(d,A(M,{get when(){return w()},get children(){return[`master rss `,N(()=>w().rssMb),`MB · heap `,N(()=>w().heapUsedMb),`MB`,Pu(),`load1 `,N(()=>w().loadavg1),` · up `,N(()=>Math.floor(w().uptimeSec/60)),`m`]}})),L(f,A(M,{get when(){return R()?.id},keyed:!0,get fallback(){return Sd()},get children(){return[(()=>{var t=Ru(),r=t.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.firstChild,c=s.nextSibling,l=c.nextSibling.nextSibling,u=l.nextSibling.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=o.nextSibling,p=f.firstChild,m=p.nextSibling;return L(t,A(M,{get when(){return he()},get children(){var e=Fu();return e.$$click=()=>Pe(!Ne()),y(()=>F(e,`aria-expanded`,Ne())),e}}),r),L(i,()=>R().id),L(a,()=>R().status),L(t,A(M,{get when(){return(R().pendingPromptIds?.length??R().pendingPrompts??0)>0},get children(){var e=Iu(),t=e.firstChild.nextSibling;return t.nextSibling,L(e,()=>R().pendingPromptIds?.length??R().pendingPrompts,t),L(e,()=>R().status===`stopped`?` (stopped)`:``,null),y(()=>F(e,`title`,R().status===`stopped`?`${R().pendingPromptIds?.length??R().pendingPrompts??0} message${(R().pendingPromptIds?.length??R().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.`:`${R().pendingPromptIds?.length??R().pendingPrompts??0} message${(R().pendingPromptIds?.length??R().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}}),o),L(t,A(M,{get when(){return Sr(R().id).length>0},get children(){var e=Lu();return e.firstChild,L(e,()=>Sr(R().id).length,null),y(()=>F(e,`title`,`scheduled tasks:\n${Sr(R().id).map(e=>`${e.schedule} · ${e.id}${e.forked?` (forked)`:``}`).join(`
|
|
26
|
+
`)}`)),e}}),o),L(o,()=>R().model,s),L(o,()=>R().session,c),L(o,()=>R().branch,l),L(o,()=>R().stats.turns,u),L(o,()=>R().stats.toolCalls,d),p.$$click=()=>(Tn()?ja(`/stop`):ja(`/start`))(),L(p,()=>Tn()?`■ stop`:`▶ start`),L(f,A(M,{get when(){return e().some(e=>e.parent===n())},get children(){return A(Uh,{icon:`⏹`,title:`stop every sub-agent this agent spawned (descendants included)`,onClick:Na})}}),m),L(f,A(Uh,{icon:`🗄`,title:`archive this agent — reversible: it leaves the list but keeps its config and history (restore in ⚙ settings → archive)`,onClick:Ma}),null),L(f,A(Uh,{icon:`⑂`,title:`fork: branch off the conversation here — try things without disturbing the main line`,onClick:Pa}),null),L(f,A(Uh,{icon:`⌨`,title:`terminal (t)`,onClick:Si}),null),L(f,A(Uh,{icon:`▤`,title:`toggle details panel (d)`,get active(){return Te()},onClick:je}),null),y(e=>{var t=`badge ${R().status}`,n=R().statusReason&&!/^(round complete|prompt|api start|goal set|created via web|start)$/.test(R().statusReason)?`${R().status} — ${R().statusReason}`:void 0,r=`${R().model} · ${R().session}/${R().branch} · turns ${R().stats.turns} · tools ${R().stats.toolCalls}`,i=`runbtn`+(Tn()?` danger`:``),s=Tn()?`interrupt: aborts the current LLM call; the running tool finishes first`:`run toward the goal (starts the loop)`;return t!==e.e&&I(a,e.e=t),n!==e.t&&F(a,`title`,e.t=n),r!==e.a&&F(o,`title`,e.a=r),i!==e.o&&I(p,e.o=i),s!==e.i&&F(p,`title`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})(),(()=>{var e=Gu();return e.addEventListener(`scroll`,e=>{let t=e.currentTarget,r={top:t.scrollTop,height:t.scrollHeight,viewport:t.clientHeight},i=un(r,_a,va,Ca);i===`layout`&&!Ct()&&Sa>0&&Math.abs(r.height-(va??r.height))>1&&(Sa--,Se(t,ya)),_a=null,va=r.height,Ca=r.viewport,At(r);let a=Ct(),o=performance.now();o-ba>100&&(ba=o,ya=P(t));let s=fn(a,i,r);s!==a&&wt(s),i===`reader`&&(Sa=4),s&&i!==`reader`?(Tt()&&Et(0),Hn(),dn(s,r)&&cn(r)>0&&ri()):s&&ln(r)&&(Tt()&&Et(0),Hn()),r.top<=4&&n()&&!U()&&!W()&&m().length>0&&Qr()}),ke(e=>we(e),e),L(e,A(M,{get when(){return Lt()},children:e=>(()=>{var t=Cd();return t.firstChild,L(t,(()=>{var t=N(()=>e().phase===`harvesting`);return()=>t()?`saving durable lessons…`:`summarizing ${e().summarized?Bh(e().summarized)+` `:``}older messages…`})(),null),t})()}),null),L(e,A(M,{get when(){return N(()=>!!W())()&&er().length>0},get children(){return zu()}}),null),L(e,A(M,{get when(){return U()},get children(){return Bu()}}),null),L(e,A(M,{get when(){return er().length>0},get fallback(){return N(()=>!!Gr())()?wd():Td()},get children(){return[A(j,{get each(){return er()},children:e=>A(Fh,{e,prev:()=>nr(e,-1),next:()=>nr(e,1),get showBranch(){return te().length>1},res:()=>Jn().resFor.get(e.id),get orphan(){return Jn().orphanCalls.has(e.id)},onOption:e=>void Da(e),answeredIds:$n,onAnswered:Zn,get agentActive(){return N(()=>!!En())()&&Ye(e)},onResize:()=>{Ct()&&ri()},get onCancel(){return e.data?.source===`user`&&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??``);E(ie()?`${n}\n\n${ie()}`:n),Nn(jn(),z().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&&!Tn()?()=>kn({eventId:e.id,text:String(e.data?.text??``)}):void 0}})}),A(M,{get when(){return N(()=>!!En())()&&Zt()},get children(){var e=Wu(),t=e.firstChild.nextSibling;return t.firstChild,L(t,A(M,{get when(){return vn().trim()!==``},get children(){var e=Vu(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return L(t,A(Oh,{get startedAt(){return _n()}}),null),ke(e=>{let t=!0;e.addEventListener(`scroll`,()=>{t=e.scrollHeight-e.scrollTop-e.clientHeight<24}),b(()=>{vn(),t&&(e.scrollTop=e.scrollHeight)})},n),L(n,vn),e}}),null),L(t,A(M,{get when(){return en()},get fallback(){return Ed()},get children(){return A(M,{get when(){return zt()},get fallback(){return(()=>{var e=Uu();return y(()=>e.innerHTML=Le(en()+`▍`)),e})()},get children(){return[Hu(),(()=>{var e=Uu();return y(()=>e.innerHTML=Le(Bt()+`▍`)),e})()]}})}}),null),e}})]}}),null),e})(),A(M,{get when(){return bi()},get children(){var t=Xu(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=r.nextSibling,c=s.firstChild;n.$$dblclick=()=>{Ni(Math.max(220,Math.round(window.innerHeight*.35))),localStorage.setItem(`teapot.termH`,String(Mi()))},n.$$pointerdown=Gi,L(i,A(j,{get each(){return Ci()},children:(e,t)=>(()=>{var n=Dd(),r=n.firstChild.nextSibling;return n.$$click=()=>Li(t()),L(n,()=>e.title,r),r.$$click=e=>{e.stopPropagation(),Bi(t())},y(r=>{var i=`termtab`+(Ai()===0&&Ti()===t()?` active`:``)+(K()&&Ai()===1&&Di()===t()?` active`:``),a=`${e.title} — click to show in focused pane`;return i!==r.e&&I(n,r.e=i),a!==r.t&&F(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()}),null),L(i,A(Uh,{icon:`+`,title:`new shell in this workspace`,onClick:Ri}),null),L(o,(()=>{var t=N(()=>!!Ii());return()=>t()?e().find(e=>e.id===Ii().agentId)?.workspace.split(`/`).filter(Boolean).pop():R()?.workspace})()),L(a,A(Uh,{icon:`◫`,get title(){return K()?`single pane`:`split panes (50/50)`},onClick:Ki}),null),L(a,A(Uh,{icon:`▾`,title:`hide the terminal (shells keep running; reopen with t) — close individual shells with their ✕ tab buttons`,onClick:Si}),null);var l=qi(0);return typeof l==`function`&&ke(l,c),c.$$pointerdown=()=>ji(0),L(c,A(M,{get when(){return Ti()<0||Ti()>=Ci().length},get children(){return Ku()}})),L(s,A(M,{get when(){return K()},get children(){return[qu(),(()=>{var e=Yu(),t=qi(1);return typeof t==`function`&&ke(t,e),e.$$pointerdown=()=>ji(1),L(e,A(M,{get when(){return Di()<0||Di()>=Ci().length},get children(){return Ju()}})),y(()=>e.classList.toggle(`focused`,Ai()===1)),e})()]}}),null),y(e=>{var n={height:`${Mi()}px`},r=!!K(),i=Ai()===0;return e.e=De(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=rd(),t=e.firstChild,n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling;return L(e,A(M,{get when(){return N(()=>Dt()>32)()&&!Ct()},get children(){var e=Zu();return e.firstChild,e.$$click=()=>{ii(!0),Hn()},L(e,(()=>{var e=N(()=>Tt()>0);return()=>e()?`${Tt()} new message${Tt()>1?`s`:``}`:`jump to present`})(),null),e}}),t),L(e,A(M,{get when(){return la().length>0},get children(){var e=Qu();return L(e,A(j,{get each(){return la()},children:(e,t)=>(()=>{var n=Od(),r=n.firstChild,i=r.nextSibling;return n.$$click=()=>{E(e.insert),ca(-1)},L(r,()=>e.insert.trim()),L(i,()=>e.title),y(r=>{var i=`cmdrow`+(t()===sa()?` active`:``),a=e.title;return i!==r.e&&I(n,r.e=i),a!==r.t&&F(n,`title`,r.t=a),r},{e:void 0,t:void 0}),n})()})),e}}),t),L(e,A(M,{get when(){return ta().length>0},get children(){var e=Qu();return L(e,A(j,{get each(){return ta()},children:e=>(()=>{var t=kd(),n=t.firstChild;n.firstChild;var r=n.nextSibling;return t.$$click=()=>{E(`@${e.key} `),ca(-1)},L(n,()=>e.key,null),L(r,()=>e.label),y(()=>F(t,`title`,e.label)),t})()})),e}}),t),t.addEventListener(`submit`,Oa),L(t,A(M,{get when(){return wa().length>0},get children(){var e=$u(),t=e.firstChild,n=t.firstChild,r=n.nextSibling;return r.nextSibling,L(e,A(j,{get each(){return wa()},children:(e,t)=>(()=>{var n=Ad(),r=n.firstChild,i=r.nextSibling;return i.$$click=()=>Ta(e=>e.filter((e,n)=>n!==t())),y(t=>{var i=e.name,a=e.url,o=e.name;return i!==t.e&&F(n,`title`,t.e=i),a!==t.t&&F(r,`src`,t.t=a),o!==t.a&&F(r,`alt`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}),t),L(t,()=>wa().length,n),L(t,()=>wa().length>1?`s`:``,r),e}}),n),n.$$keydown=e=>{let t=la();t.length>0&&e.key===`ArrowDown`?(e.preventDefault(),ca(e=>Math.min(e+1,t.length-1))):t.length>0&&e.key===`ArrowUp`?(e.preventDefault(),ca(e=>Math.max(e-1,0))):t.length>0&&(e.key===`Tab`||e.key===`Enter`)&&!e.shiftKey&&sa()>=0&&!gh?(e.preventDefault(),E(t[sa()].insert),ca(-1)):e.key===`Escape`&&t.length>0?ca(-1):e.key===`Enter`&&!e.shiftKey&&!gh&&!bt()&&(e.preventDefault(),Oa(e))},n.$$input=e=>{E(e.currentTarget.value),ca(0),ha()},n.addEventListener(`paste`,e=>{let t=Array.from(e.clipboardData?.files??[]).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Ea(t))}),n.addEventListener(`compositionend`,()=>{requestAnimationFrame(()=>{gh=!1}),E(ua?.value??``)}),n.addEventListener(`compositionstart`,()=>{gh=!0}),ke(e=>{ua=e,e.value=ie()},n),L(t,A(M,{get when(){return N(()=>!!ie().startsWith(`@`))()&&ie().includes(` `)},get children(){var e=ed(),t=e.firstChild;return t.addEventListener(`change`,e=>$i(e.currentTarget.checked)),y(()=>t.checked=Qi()),e}}),r),r.$$click=()=>{let e=!bt();xt(e),requestAnimationFrame(()=>ha())},L(r,()=>bt()?`⤡`:`⤢`),L(t,A(Uh,{icon:`📎`,title:`attach images (or paste them straight into the box)`,onClick:()=>document.getElementById(`composer-file`)?.click()}),i),L(t,A(M,{get when(){return wa().length},get children(){var e=td();return e.firstChild,L(e,()=>wa().length,null),e}}),i),a.addEventListener(`change`,e=>{e.currentTarget.files?.length&&Ea(e.currentTarget.files),e.currentTarget.value=``}),L(e,A(M,{get when(){return ph()},get children(){var e=nd();return L(e,ph),e}}),null),y(t=>{var i=`composer`+(bt()?` maximized`:``),a=`message #${R().id} — / for commands · paste or 📎 to attach images`,o=bt()?`restore composer (hide timeline)`:`maximize composer — hide the timeline and fill the main column`;return i!==t.e&&I(e,t.e=i),a!==t.t&&F(n,`placeholder`,t.t=a),o!==t.a&&F(r,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),e})()]}})),L(t,A(M,{get when(){return N(()=>!!he())()&&Te()},get children(){var e=id();return e.$$click=()=>Ae(!1),e}}),p),p.addEventListener(`scroll`,e=>{q=e.currentTarget.scrollTop});var v=Aa;return typeof v==`function`?ke(v,p):Aa=p,L(g,A(Uh,{icon:`✕`,title:`close details panel (esc)`,onClick:Me}),null),L(p,A(M,{get when(){return R()?.id},keyed:!0,fallback:null,children:t=>[A(M,{get when(){return R().id},keyed:!0,fallback:null,children:e=>A(rg,{agentId:e,get workspace(){return R().workspace}})}),jd(),(()=>{var t=Pd(),r=t.firstChild,i=r.nextSibling,a=i.firstChild,o=a.nextSibling,s=i.nextSibling,c=s.firstChild,l=s.nextSibling;return l.firstChild,r.addEventListener(`change`,t=>{let r=t.currentTarget.value;yt=!0,at(r),st(tn(D().providers,r,e().find(e=>e.id===n()))),pt(r)}),L(r,A(j,{get each(){return ft()},children:e=>(()=>{var t=tf();return t.value=e,L(t,e,null),L(t,()=>e===D().defaultProvider?` ★`:``,null),t})()})),a.$$input=e=>st(e.currentTarget.value),L(o,A(j,{get each(){return ut()},children:e=>(()=>{var t=tf();return y(()=>t.value=e.id),t})()})),L(t,A(M,{get when(){return R().effortSupported},get children(){var e=Md(),t=e.firstChild.nextSibling;return t.firstChild,t.addEventListener(`change`,e=>lt(e.currentTarget.value)),L(t,A(j,{get each(){return N(()=>!!R().effortOptions?.length)()?R().effortOptions:lh},children:e=>(()=>{var t=tf();return t.value=e,L(t,e),t})()}),null),y(()=>t.value=ct()),e}}),s),c.$$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:it(),model:ot().trim()||void 0,contextWindowTokens:ut().find(e=>e.id===(ot().trim()||void 0))?.contextLength,...R().effortSupported?{reasoningEffort:ct()}:{}})}),t.textContent=`✓ applied`,V()}catch(e){alert(`apply failed: ${e.message}`)}finally{setTimeout(()=>{t.textContent=`apply`,t.disabled=!1},1200)}},L(l,()=>R().model,null),L(l,A(M,{get when(){return ut().length},get children(){return[` · `,N(()=>ut().length),` models loaded`]}}),null),L(t,A(M,{get when(){return _t()},get children(){var e=Nd();return L(e,_t),e}}),null),y(()=>F(a,`placeholder`,nn(D().providers,it(),R(),$t(R(),D().providers,D().defaultProvider)))),y(()=>r.value=it()),y(()=>a.value=ot()),t})(),(()=>{var e=Fd(),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(V)}),y(()=>t.checked=R().autoContinue??!0),e})(),(()=>{var e=Ld();return e.firstChild,L(e,A(M,{get when(){return!!R().goal.text.trim()},get fallback(){return nf()},get children(){var e=Id();return L(e,()=>R().goal.status),y(()=>I(e,`badge ${R().goal.status===`active`?`running`:R().goal.status}`)),e}}),null),e})(),(()=>{var e=Rd();return e.firstChild,L(e,A(j,{each:[`active`,`done`,`paused`],children:e=>(()=>{var t=rf();return t.$$click=()=>{n()&&$(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:e})}).then(V)},F(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`),L(t,e===`active`?`▶ working`:e===`done`?`✓ done`:`⏸ paused`),y(n=>{var r=`goalstate`+(R().goal.text.trim()&&R().goal.status===e?` on ${e}`:``),i=!!R().goal.text.trim()&&R().goal.status===e;return r!==n.e&&I(t,n.e=r),i!==n.t&&(t.disabled=n.t=i),n},{e:void 0,t:void 0}),t})()}),null),e})(),A(M,{get when(){return R().goal.text},get fallback(){return af()},get children(){return[(()=>{var e=zd(),t=e.firstChild;return y(()=>t.innerHTML=Le(String(R().goal.text))),e})(),A(M,{get when(){return R().goal.verify},get children(){var e=Bd(),t=e.firstChild.nextSibling;return y(()=>t.innerHTML=Le(String(R().goal.verify))),e}}),A(M,{get when(){return R().goal.audit},children:e=>(()=>{var t=of(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return L(n,()=>e().verdict===`approved`?`✅ audit: approved`:`⚠ audit: changes required`,r),L(r,()=>zh(e().at)),y(n=>{var r=`card auditcard `+(e().verdict===`approved`?`ok`:`warn`),a=gt(e().feedback)?Le(`_the auditor returned a verdict with no detail_`):Le(e().feedback);return r!==n.e&&I(t,n.e=r),a!==n.t&&(i.innerHTML=n.t=a),n},{e:void 0,t:void 0}),t})()})]}}),(()=>{var e=Vd(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.firstChild.firstChild;return e.addEventListener(`submit`,Wa),t.$$input=e=>{Ia(e.currentTarget.value),Ba(!0)},n.$$input=e=>{Ra(e.currentTarget.value),Ba(!0)},r.addEventListener(`change`,e=>Ha(e.currentTarget.checked)),y(()=>t.value=Fa()),y(()=>n.value=La()),y(()=>r.checked=Va()),e})(),(()=>{var e=Ud(),t=e.firstChild.nextSibling;return L(e,A(M,{get when(){return gr().total>0},get children(){var e=Hd(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,L(e,()=>gr().done,t),L(e,()=>gr().total,n),y(t=>De(e,gr().done===gr().total?`color:var(--ok)`:`color:var(--warn)`,t)),e}}),t),e})(),A(M,{get when(){return gr().total>0},get children(){var e=Wd(),t=e.firstChild;return y(e=>{var n=`barfill `+(gr().done===gr().total?``:`warn`),r=`${Math.round(gr().done/gr().total*100)}%`;return n!==e.e&&I(t,e.e=n),r!==e.t&&Oe(t,`width`,e.t=r),e},{e:void 0,t:void 0}),e}}),A(ng,{get draft(){return cr()},get preview(){return ur()},onDraft:e=>{lr(e),pr(!0)}}),(()=>{var e=Gd(),t=e.firstChild,n=t.nextSibling;return L(e,A(Uh,{get icon(){return ur()?`✎`:`👁`},get title(){return ur()?`edit markdown`:`rendered checklist`},onClick:()=>dr(!ur())}),t),n.$$click=hr,e})(),Kd(),A(M,{get when(){return R().latestProgress},get fallback(){return sf()},children:e=>(()=>{var t=ff(),n=t.firstChild,r=n.firstChild.nextSibling,i=n.nextSibling;return L(t,A(M,{get when(){return e().recent},get children(){var t=cf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().recent)),t}}),i),L(t,A(M,{get when(){return e().problems},get children(){var t=lf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().problems)),t}}),i),L(t,A(M,{get when(){return e().next},get children(){var t=uf(),n=t.firstChild.nextSibling;return y(()=>n.innerHTML=ch(e().next)),t}}),i),L(t,A(M,{get when(){return e().goalStatus},get children(){var t=df(),n=t.firstChild.nextSibling;return L(n,()=>e().goalStatus),t}}),i),L(i,()=>zh(e().ts)),y(()=>r.innerHTML=ch(e().doing)),t})()}),qd(),(()=>{var e=Xd(),t=e.firstChild,r=t.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling,o=a.firstChild.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling,l=s.nextSibling,u=l.firstChild.nextSibling,d=l.nextSibling,f=d.firstChild.nextSibling;return L(e,A(M,{get when(){return R().ctx},keyed:!0,get fallback(){return pf()},children:e=>{let t=x(()=>{let t=e,n=ut().find(e=>e.id===R().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=_f(),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;return L(a,()=>Bh(r().usedTokens),o),L(t,A(M,{get when(){return r().effectiveWindow},get children(){var e=mf(),t=e.firstChild;return L(e,()=>i(r().pct),t),L(e,()=>Bh(r().effectiveWindow),null),y(()=>I(e,`pill ${r().cls}`)),e}}),null),L(e,A(M,{get when(){return r().effectiveWindow},get children(){var e=hf(),t=e.firstChild;return y(e=>{var n=`barfill ${r().cls}`,i=`${Math.min(100,r().pct)}%`;return n!==e.e&&I(t,e.e=n),i!==e.t&&Oe(t,`width`,e.t=i),e},{e:void 0,t:void 0}),e}}),s),L(c,()=>Bh(r().usingDerived?r().derivedBudget:r().compactAt),l),L(u,()=>r().usingDerived?`75% of window`:`manual`),L(e,A(M,{get when(){return Lt()||r().compacting},get children(){var e=gf(),t=e.firstChild.nextSibling.nextSibling;return L(t,()=>Lt()?.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(V)}),y(()=>f.checked=R().autoCompact!==!1),e})()}}),t),L(i,()=>Bh(R().stats.inputTokens)),L(o,()=>Bh(R().stats.outputTokens)),L(c,()=>R().stats.turns),L(u,()=>R().stats.toolCalls),L(f,()=>R().stats.compactions??0),L(t,A(M,{get when(){return(R().stats.costUsd??0)>0},get children(){var e=Jd(),t=e.firstChild.nextSibling;return t.firstChild,L(t,()=>Vh(R().stats.costUsd??0),null),y(()=>F(e,`title`,`≈ ${(R().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),L(t,A(M,{get when(){return(R().stats.cachedInputTokens??0)>0},get children(){var e=Yd(),t=e.firstChild.nextSibling,n=t.firstChild;return L(t,()=>Math.round(R().stats.cachedInputTokens/Math.max(1,R().stats.inputTokens)*100),n),y(()=>F(e,`title`,`${Bh(R().stats.cachedInputTokens)} input tokens were served from the provider's prompt cache — billed far cheaper than fresh input`)),e}}),null),y(()=>F(d,`title`,`how many times old turns were summarized into notes to make room. ${R().stats.compactions?`Each one keeps the recent stretch verbatim.`:`Not yet — the context has fit so far.`}`)),e})(),(()=>{var e=Qd();return e.firstChild.nextSibling,L(e,A(M,{get when(){return Br()},get children(){var e=Zd(),t=e.firstChild.nextSibling;return L(t,Br),e}}),null),e})(),A(j,{get each(){return te()},children:e=>(()=>{var t=vf(),r=t.firstChild,i=r.nextSibling,a=i.firstChild;return t.$$click=()=>{let t=Br()===e.branch?null:e.branch,r=t!==Br();Vr(t),n()&&(r&&(Jr++,h([]),_(0),qr(!1)),$r(n()))},L(r,()=>e.branch,null),L(r,()=>e.branch===R().branch?` (current)`:``,null),L(i,()=>e.events,a),y(n=>{var r=`branch-row`+(e.branch===R().branch||e.branch===Br()?` cur`:``),i=e.branch===Br()?`click to show all branches again`:`show only ${e.branch}`;return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),n},{e:void 0,t:void 0}),t})()}),(()=>{var e=ef();return e.firstChild,L(e,A(M,{get when(){return yr().length>0},get children(){var e=$d(),t=e.firstChild.nextSibling;return t.nextSibling,L(e,()=>yr().length,t),e}}),null),e})(),A(M,{get when(){return yr().length>0},get fallback(){return yf()},get children(){return A(j,{get each(){return yr()},children:e=>(()=>{var t=xf(),r=t.firstChild,i=r.firstChild,a=i.nextSibling;a.firstChild;var o=r.nextSibling,s=o.firstChild,c=o.nextSibling;return t.$$click=()=>si(e.agent),L(i,()=>e.id),L(a,()=>e.agent,null),L(r,A(M,{get when(){return e.forked},get children(){return bf()}}),null),L(o,()=>e.schedule,s),L(o,(()=>{var t=N(()=>!!e.next);return()=>t()?zh(e.next):`—`})(),null),L(o,(()=>{var t=N(()=>!!e.last);return()=>t()?` · last ${zh(e.last)}`:` · never ran`})(),null),L(c,()=>Hh(e.prompt,90)),y(r=>{var i=`sched-row`+(e.agent===n()?` cur`:``),a=`${Hh(e.prompt,200)}\nclick to open #${e.agent}`;return i!==r.e&&I(t,r.e=i),a!==r.t&&F(t,`title`,r.t=a),r},{e:void 0,t:void 0}),t})()})}})]}),null),y(e=>{var n=`layout`+(Te()?``:` right-hidden`)+(Ne()?` left-open`:``),i=`sidebar`+(Ne()?` open`:``),a=`iconbtn notifbtn`+(Bn()>0?` has-unread`:``),s=Bn()>0?`${Bn()} unread notifications`:`notifications`,c=`conn`+(G()?` ok`:``),u=G()?`live (websocket)`:`reconnecting…`,d={"--termh":`${Mi()}px`},m=`rightbar`+(Te()?` open`:``);return n!==e.e&&I(t,e.e=n),i!==e.t&&I(r,e.t=i),a!==e.a&&I(o,e.a=a),s!==e.o&&F(o,`title`,e.o=s),c!==e.i&&I(l,e.i=c),u!==e.n&&F(l,`title`,e.n=u),e.s=De(f,d,e.s),m!==e.h&&I(p,e.h=m),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),t})(),A(M,{get when(){return Rn()},get children(){return[(()=>{var e=od();return e.$$click=()=>zn(!1),e})(),(()=>{var t=ld(),r=t.firstChild.firstChild.nextSibling,i=r.firstChild;return L(r,A(M,{get when(){return Pn().length>0},get children(){var e=sd();return e.$$click=()=>Fn([]),e}}),i),i.$$click=()=>zn(!1),L(t,A(M,{get when(){return Pn().length>0},get fallback(){return Sf()},get children(){var t=cd();return L(t,A(j,{get each(){return Pn()},children:t=>(()=>{var r=wf(),i=r.firstChild.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return r.$$click=()=>{Fn(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e)),n()!==t.agentId&&e().some(e=>e.id===t.agentId)&&si(t.agentId),zn(!1),t.eventId&&setTimeout(()=>qn(t.eventId),n()===t.agentId?60:350)},L(i,(()=>{var e=N(()=>t.kind===`finish`);return()=>e()?`✅`:N(()=>t.kind===`question`)()?`❓`:t.kind===`error`?`⚠️`:`📈`})()),L(a,()=>t.title),L(o,()=>zh(new Date(t.at).toISOString())),s.$$click=e=>{e.stopPropagation(),Fn(e=>e.map(e=>e.id===t.id?{...e,read:!0}:e))},L(s,()=>t.read?`✓`:`○`),L(r,A(M,{get when(){return t.body},get children(){var e=Cf();return L(e,()=>Rh(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&&I(r,e.e=n),i!==e.t&&F(r,`title`,e.t=i),a!==e.a&&F(s,`title`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r})()})),t}}),null),t})()]}}),A(M,{get when(){return se()},get children(){return A(Kh,{get providers(){return Object.keys(D().providers??{})},onClose:()=>ce(!1),onCreated:e=>{ce(!1),V(),si(e)}})}}),A(M,{get when(){return de()},get children(){return A(sg,{get cfg(){return D()},onClose:()=>k(!1),announcedOAuth:pe,get skills(){return ra()},get hasSelection(){return!!n()},get agentId(){return n()},get features(){return aa()},onSaved:()=>{ar(),xr()},theme:{themes:Ke,activeId:Ie,paintedId:O,auto:ze,setAuto:Be,dark:$e,setDark:et,light:Ve,setLight:He,setThemes:Je,setActive:Re}})}}),A(M,{get when(){return On()},fallback:null,children:e=>{let t=()=>m().findIndex(t=>t.id===e().eventId),r=()=>Math.max(0,m().length-t()-1),[i,a]=v(r()>0?`summarize`:`discard`);return A(Gh,{title:`edit prompt — forks the conversation`,onClose:()=>kn(null),get children(){var t=Ef(),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()})}),kn(null),V();let t=n();t&&await si(t)}catch(e){alert(`edit failed: ${e.message}`)}}),L(t,A(M,{get when(){return r()>0},get children(){var e=Tf(),t=e.firstChild,n=t.firstChild,o=t.nextSibling,s=o.firstChild,c=o.nextSibling.firstChild;return L(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=()=>kn(null),y(()=>o.value=e().text),t}})}})]}function Dh(e){let t=new Date(e.startedAt).getTime(),[n,r]=v(Date.now());ee(()=>{let e=setInterval(()=>r(Date.now()),500);C(()=>clearInterval(e))});let i=()=>He(Math.max(0,n()-t));return e.inline?(()=>{var t=Df();return t.firstChild,L(t,i,null),L(t,(()=>{var t=N(()=>!!e.timeoutMs);return()=>t()?` · timeout ${Math.round(e.timeoutMs/1e3)}s`:``})(),null),t})():(()=>{var e=Of(),t=e.firstChild;return L(e,i,t),e})()}function Oh(e){let[t,n]=v(Date.now());return ee(()=>{let e=setInterval(()=>n(Date.now()),500);C(()=>clearInterval(e))}),e.startedAt?(()=>{var n=kf();return L(n,()=>He(Math.max(0,t()-e.startedAt))),n})():null}var kh=new Map,Ah=400;function jh(e,t){if(kh.size>=Ah){let e=kh.keys().next();e.done||kh.delete(e.value)}kh.set(e,t)}function Mh(e){let t=()=>e.lang?`${e.lang}::${e.text.length}::${e.text}`:``,[n,r]=v((e.lang?kh.get(t()):void 0)??``);return b(()=>{let n=t(),i=e.text,a=e.lang;if(!a||!i.trim()){r(``);return}let o=kh.get(n);o===void 0?(async()=>{try{let{highlightLangChunks:e}=await ku(async()=>{let{highlightLangChunks:e}=await import(`./shiki-BKqf8YtI.js`);return{highlightLangChunks:e}},[]),o=``;for await(let t of e(a,i))o+=t;if(!o)return;jh(n,o),t()===n&&r(o)}catch{}})():r(o)}),A(M,{get when(){return!!n()},get fallback(){return(()=>{var t=jf();return L(t,()=>e.text),t})()},get children(){var e=Af();return y(()=>e.innerHTML=n()),e}})}function Nh(e){let t=e.e,n=Bt(e.prev,t),r=x(()=>e.res?.(),void 0,{equals:(e,t)=>e?.id===t?.id}),i=()=>r(),a=()=>!e.agentActive&&!i(),o=t.data??{},s=String(o.name??`tool`),c=()=>String(i()?.data?.result??``),l=e=>String(o.args?.[e]??``),u=()=>s===`bash`?l(`command`):l(`path`)||JSON.stringify(o.args??{},null,1),d=()=>s===`bash`?Number(l(`timeout_ms`))||void 0:s===`wait_children`?Number(l(`timeout_ms`))||3e5:Number(l(`timeout_ms`))||void 0,f=(e,t=1500,n)=>A(Mh,{get text(){return Rh(e,t)},lang:n}),p=(e=2e3)=>A(Mh,{get text(){return Rh(JSON.stringify(o.args??{},null,1),e)},lang:`json`}),m=(e=4e3)=>(()=>{let t=i();return t?[N(()=>f(c(),e,xt(c()))),(()=>{var e=Mf();return L(e,()=>He(t.data?.durationMs),null),L(e,()=>s===`bash`?Zt(Xt(t.data?.ok,String(t.data?.result??``))):t.data?.ok===!1?` · FAILED`:``,null),L(e,A(Wh,{get text(){return c()}}),null),e})()]:Nf()})(),h=x(()=>{i();let e=s,t=``,n=p(2e3);try{switch(s){case`bash`:{let r=l(`command`),a=o.args?.background===!0,s=a?String(c()).match(/job (bg\d+)/)?.[1]??``:``;e=(a?`⏳ `:`$ `)+Hh(r,96);let u=l(`timeout_ms`)?Number(l(`timeout_ms`)):void 0,d=i(),p=Xt(d?.data?.ok,d?String(d.data?.result??``):``);t=d?a?`background job${s?` ${s}`:``}${u?` · timeout ${Math.round(u/1e3)}s`:``}`:Qt({outcome:p,durationMs:d.data?.durationMs,timeoutMs:u,fmtDur:He}):null,n=[a?(()=>{var e=Pf(),t=e.firstChild.nextSibling,n=t.firstChild.nextSibling;return n.nextSibling,L(t,s||`?`,n),L(e,s?[` · kill with `,Ff()]:null,null),e})():null,N(()=>N(()=>r!==e.slice(2))()?f(r,800,`shellscript`):null),N(()=>m(6e3))];break}case`read_file`:{e=l(`path`)||`(no path)`;let r=[];l(`pattern`)&&r.push(`grep /${Hh(l(`pattern`),40)}/`),Number(o.args?.offset)<0?r.push(`last ${-Number(o.args.offset)} lines`):o.args?.offset&&r.push(`from L${o.args.offset}`),o.args?.limit&&r.push(`≤${o.args.limit} lines`),t=r.join(` · `),n=m(6e3);break}case`write_file`:{let r=String(o.args?.content??``);e=l(`path`)||`(no path)`,t=`${Bh(r.length)} bytes`,n=[N(()=>f(r,1500)),N(()=>N(()=>r.length>1500)()?(()=>{var e=If(),t=e.firstChild;return L(e,()=>Bh(r.length),t),e})():null),N(()=>N(()=>!!i())()?(()=>{var e=Mf();return L(e,()=>Hh(c(),160)),e})():Lf())];break}case`edit_file`:e=l(`path`)||`(no path)`,t=o.args?.replace_all===!0?`replace all`:`unique spot`,n=[(()=>{var e=Rf();return L(e,()=>Rh(`- `+l(`old_text`),900)),e})(),(()=>{var e=zf();return L(e,()=>`+ `+Rh(l(`new_text`),900)),e})(),N(()=>N(()=>!!i())()?(()=>{var e=Bf(),t=e.firstChild;return L(e,()=>Hh(c(),120),t),L(e,()=>He(i().data?.durationMs),null),e})():Vf())];break;case`apply_patch`:{let t=l(`patch`).split(`
|
|
27
27
|
`).filter(e=>e&&!/^---$/.test(e.trim())),r=t.map(e=>e.match(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/)?.[1]).filter(Boolean);e=r.length?`${r.length} file${r.length>1?`s`:``}: ${Hh(r.join(`, `),80)}`:`patch`;let a=t.slice(0,60);n=[(()=>{var e=Hf();return L(e,()=>a.map(e=>{let t=e.startsWith(`+`)?` add`:e.startsWith(`-`)?` del`:/^\*\*\*|^@@/.test(e)?` meta`:``;return(()=>{var n=Uf();return I(n,`pline`+t),L(n,(()=>{var t=N(()=>e.length>240);return()=>t()?e.slice(0,240)+`…`:e})()),n})()}),null),L(e,(()=>{var e=N(()=>t.length>60);return()=>e()?(()=>{var e=Wf(),n=e.firstChild.nextSibling;return n.nextSibling,L(e,()=>t.length-60,n),e})():null})(),null),e})(),N(()=>N(()=>!!i())()?(()=>{var e=Mf();return L(e,()=>Hh(c().split(`
|
|
28
|
-
`)[0]??``,140),null),L(e,()=>i().data?.ok===!1?` · FAILED`:``,null),e})():Gf())];break}case`list_dir`:e=l(`path`)||`.`,n=m(4e3);break;case`read_url`:{let r=l(`url`);try{let e=new URL(r);r=e.host+e.pathname}catch{}e=Hh(r,70),t=`web`,n=[(()=>{var e=Mf();return L(e,A(M,{get when(){return/^https?:/i.test(l(`url`))},get fallback(){return(()=>{var e=qf();return L(e,()=>Hh(l(`url`),80)),e})()},get children(){var e=Kf();return y(()=>F(e,`href`,l(`url`))),e}})),e})(),N(()=>m(3e3))];break}case`bash_output`:{let r=l(`action`)||`read`;e=`bash_output ${l(`job_id`)||`(?)`}`,t=r,n=m(4e3);break}case`load_skill`:{e=`skill: ${l(`name`)}`;let t=c().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);n=i()?[(()=>{var e=Uu();return y(()=>e.innerHTML=Le(t)),e})(),(()=>{var e=Mf();return L(e,()=>He(i().data?.durationMs)),e})()]:Jf();break}case`save_skill`:{e=`skill: ${l(`name`)}`,t=Hh(l(`description`),60);let r=Array.isArray(o.args?.files)?o.args.files.map(e=>e?.name).filter(Boolean):[];n=[N(()=>N(()=>!!r.length)()?(()=>{var e=Yf();return e.firstChild,L(e,()=>r.join(`, `),null),e})():null),N(()=>N(()=>!!i())()?(()=>{var e=Bf(),t=e.firstChild;return L(e,()=>Hh(c(),160),t),L(e,()=>He(i().data?.durationMs),null),e})():Xf())];break}default:e=s,t=i()?He(i().data?.durationMs):null,n=[N(()=>p(2e3)),N(()=>m(4e3))]}}catch{}return{label:e,hint:t,body:n,key:`${i()?.id??`none`}|${e}|${t??``}`}},void 0,{equals:(e,t)=>e.key===t.key});return(()=>{var r=Qf(),o=r.firstChild,l=o.firstChild,f=l.nextSibling,p=f.nextSibling;return r.addEventListener(`toggle`,t=>{t.target.open&&e.onResize?.()}),L(l,()=>h().label),L(o,A(M,{get when(){return t.data?.actor},get children(){var e=Zf();return e.firstChild,L(e,()=>String(t.data.actor),null),e}}),f),L(f,(()=>{var e=N(()=>!!i());return()=>e()?h().hint||``:N(()=>!!a())()?`(result missed)`:N(()=>!!(s===`bash`||d()))()?A(Dh,{get startedAt(){return t.ts},inline:!0,get timeoutMs(){return d()}}):`running…`})()),L(p,A(Wh,{get text(){return u()},label:`⧉ cmd`,title:`copy the ${s} arguments`}),null),L(p,A(M,{get when(){return i()},get children(){return A(Wh,{get text(){return c()},label:`⧉ out`,title:`copy this tool's full output`})}}),null),L(r,()=>h().body,null),y(e=>{var t=`embed`+(n?` grouped`:``)+(i()?i().data?.ok===!1?` fail`:` done`:a()?` done`:` running`),o=`${s}${h().hint?` — `+h().hint:``}`;return t!==e.e&&I(r,e.e=t),o!==e.t&&F(r,`title`,e.t=o),e},{e:void 0,t:void 0}),r})()}function Ph(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 Fh(e){let t=e.e,n=vh(t),r=()=>Bt(e.prev?.(),t),i=()=>{let n=e.next?.();return!!n&&Bt(t,n)};if(t.type===`fork`){let e=t.data??{};return(()=>{var n=$f(),r=n.firstChild.nextSibling;return r.nextSibling,L(n,()=>String(e.fromBranch??`?`),r),L(n,()=>String(e.newBranch??t.branch),null),n})()}if(t.type===`goal`){let e=vt(t.data??{});return(()=>{var t=ep(),n=t.firstChild;return L(n,()=>e.label),L(t,A(M,{get when(){return e.hasCard},get children(){var t=Uf();return y(n=>{var r=`card `+(e.tone===`ok`?`auditcard ok`:e.tone===`warn`?`auditcard`:`verifycard`),i=e.markdown?Le(e.detail):Le(`\`\`\`\n${e.detail}\n\`\`\``);return r!==n.e&&I(t,n.e=r),i!==n.t&&(t.innerHTML=n.t=i),n},{e:void 0,t:void 0}),t}}),null),y(()=>I(t,`goalline `+(e.tone===`err`?`err`:e.tone===`warn`?`warn`:``))),t})()}if(t.type===`todo`)return(()=>{var e=tp(),n=e.firstChild.nextSibling;return n.nextSibling,L(e,()=>String(t.data?.by??`human`),n),e})();if(t.type===`state`)return t.data.from===t.data.to?null:(()=>{var e=np(),n=e.firstChild;return L(e,()=>t.data.from,n),L(e,()=>t.data.to,null),L(e,(()=>{var e=N(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>I(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=rp(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;i.nextSibling;var a=n.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,L(n,()=>String(t.data?.failures),r),L(n,()=>String(t.data?.limit),i),L(a,()=>String(t.data?.lastTool),o),L(a,()=>String(t.data?.lastError??``).slice(0,200),null),y(()=>F(e,`title`,`${t.data?.failures} consecutive tool failures hit the configured limit (${t.data?.limit})`)),e})();if(e===`error-retry`)return(()=>{var e=ip(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(n,()=>String(t.data?.attempt),r),L(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=Uf();return I(r,`divider-msg`+(e?` err`:``)),L(r,()=>(e?`⚠ background job `:`✓ background job `)+String(t.data?.jobId??`?`)+` `+(e?`FAILED (exit ${String(t.data?.code??`?`)})`:`finished (${n}s)`)),y(()=>F(r,`title`,String(t.data?.cmd??``))),r})()}return e===`context-compacted`?(()=>{var e=ap(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(e,()=>String(t.data?.tokensBefore??`?`),n),L(e,()=>String(t.data?.tokensAfter??`?`),r),L(e,()=>String(t.data?.mode??``),i),e})():e===`context-compaction-started`?(()=>{var e=op(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(e,()=>String(t.data?.messages??`?`),n),L(e,()=>String(t.data?.tokensBefore??`?`),r),L(e,()=>String(t.data?.reason??`auto`),i),e})():null}return(()=>{var a=dp(),o=a.firstChild,s=o.nextSibling;return L(o,(()=>{var e=N(()=>!!r());return()=>e()?``:n.icon})()),L(s,(()=>{var e=N(()=>!!r());return()=>e()&&(()=>{var e=fp();return y(()=>F(e,`title`,`${Ch(t.ts)} · ${t.branch}`)),e})()})(),null),L(s,A(M,{get when(){return!r()},get children(){var r=up(),i=r.firstChild,a=i.nextSibling;return L(i,()=>n.name),L(r,A(M,{get when(){return t.data?.actor},get children(){var e=Zf();return e.firstChild,L(e,()=>String(t.data.actor),null),e}}),a),L(a,(()=>{var e=N(()=>!!t.data?.pending);return()=>e()?`queued…`:N(()=>!!t.data?.cancelled)()?`withdrawn`:Ch(t.ts)})()),L(r,A(M,{get when(){return e.showBranch},get children(){var e=sp();return L(e,()=>t.branch),e}}),null),L(r,A(M,{get when(){return e.onCancel},get children(){var t=cp();return t.$$click=t=>{t.stopPropagation(),e.onCancel()},t}}),null),L(r,A(M,{get when(){return t.type!==`tool_call`},get children(){return A(Wh,{get text(){return Ph(t)},label:`⧉ copy`,title:`copy the RAW text of this message (no markdown rendering)`})}}),null),L(r,A(M,{get when(){return e.onEdit},get children(){var t=lp();return t.$$click=t=>{t.stopPropagation(),e.onEdit()},t}}),null),y(e=>Oe(i,`color`,n.color)),r}}),null),L(s,A(Lh,{e:t,get prev(){return e.prev?.()},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 s=`msg`+(r()?` grouped`:``)+(i()?` next-grouped`:``)+(t.data?.pending?` pending`:``)+(t.data?.cancelled?` withdrawn`:``),c=t.id,l=`avatar avghost`+(r()?` ghosted`:``),u=r()?`transparent`:n.color+`33`,d=r()?`1px solid transparent`:`1px solid ${n.color}66`,f=r()?`${Ch(t.ts)} · ${t.branch}`:void 0;return s!==e.e&&I(a,e.e=s),c!==e.t&&F(a,`data-eid`,e.t=c),l!==e.a&&I(o,e.a=l),u!==e.o&&Oe(o,`background`,e.o=u),d!==e.i&&Oe(o,`border`,e.i=d),f!==e.n&&F(o,`title`,e.n=f),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a})()}function Ih(e){let[t,n]=v(``),r=()=>{let r=t().trim();r&&!e.answered&&(n(``),e.onOption?.(r))};return(()=>{var i=pp(),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&&F(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 Lh(e){let t=e.e;switch(t.type){case`prompt`:{let e=t.data?.images??[];return[(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.text??``))),e})(),A(M,{get when(){return e.length},get children(){var t=mp();return L(t,A(j,{each:e,children:e=>(()=>{var t=hp();return F(t,`src`,e),t})()})),t}})]}case`message`:return[A(M,{get when(){return N(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=gp(),n=e.firstChild;n.firstChild;var r=n.nextSibling;return L(n,(()=>{var e=N(()=>String(t.data.reasoning).length>4e3);return()=>e()?` (${Bh(String(t.data.reasoning).length)} — truncated)`:``})(),null),L(r,()=>Rh(String(t.data.reasoning),8e3)),e}}),(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.content??``))),e})(),A(M,{get when(){return t.data.interrupted},get children(){return _p()}}),A(M,{get when(){return t.data.final},get children(){var e=vp(),n=e.firstChild;return L(e,A(Wh,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:return A(Nh,{e:t,get prev(){return e.prev},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=bp(),o=a.firstChild,s=o.firstChild,c=o.nextSibling,l=c.nextSibling;return I(a,`embed `+(i?``:`fail`)),L(s,r===`bash`?`$ (bash, call evicted)`:r),L(o,A(Wh,{text:n}),null),L(c,()=>Rh(n,4e3)),L(l,()=>He(t.data.durationMs),null),L(l,()=>r===`bash`?Zt(Xt(t.data.ok,n)):i?``:` · FAILED`,null),L(a,A(M,{get when(){return e.orphan},get children(){return yp()}}),null),y(()=>a.open=e.orphan),a})()}case`decision`:{let e=Array.isArray(t.data?.alternatives)?t.data.alternatives:[];return(()=>{var n=Sp(),r=n.firstChild,i=r.firstChild.firstChild.nextSibling,a=r.nextSibling;return L(n,A(M,{get when(){return e.length},get children(){var t=xp();return t.firstChild,L(t,()=>e.join(` / `),null),t}}),null),y(e=>{var n=ch(String(t.data?.decision??``)),r=ch(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=Tp(),o=a.firstChild.firstChild.nextSibling;return L(a,A(M,{get when(){return i()},get children(){return Cp()}}),null),L(a,A(M,{get when(){return n.length>0},get children(){var a=wp();return L(a,A(j,{each:n,children:n=>(()=>{var a=Ep();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)},L(a,n),y(()=>a.disabled=i()),a})()})),a}}),null),L(a,A(Ih,{get answered(){return i()},get onOption(){return e.onOption}}),null),y(e=>{var n=`embed question`+(i()?` answered`:``),r=ch(String(t.data?.question??``));return n!==e.e&&I(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=Dp(),n=e.firstChild.firstChild.nextSibling;return L(e,A(M,{get when(){return t.data.goalStatus},get children(){var e=df(),n=e.firstChild.nextSibling;return L(n,()=>String(t.data.goalStatus)),e}}),null),L(e,A(M,{get when(){return t.data.recent},get children(){var e=cf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.recent))),e}}),null),L(e,A(M,{get when(){return t.data.problems},get children(){var e=lf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.problems))),e}}),null),L(e,A(M,{get when(){return t.data.next},get children(){var e=uf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.next))),e}}),null),y(()=>n.innerHTML=ch(String(t.data.doing??``))),e})();case`error`:return(()=>{var e=Op(),n=e.firstChild;return n.firstChild,L(n,()=>String(t.data.message??``),null),e})();case`compaction`:return(()=>{var e=Ap(),n=e.firstChild.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,a=i.nextSibling.nextSibling;return a.nextSibling,L(n,()=>String(t.data.mode??``),r),L(n,()=>Bh(Number(t.data.tokensBefore??0)),i),L(n,()=>Bh(Number(t.data.tokensAfter??0)),a),L(n,(()=>{var e=N(()=>!!t.data.summarized);return()=>e()?`${t.data.summarized} summarized`:`${t.data.dropped} dropped`})(),null),L(e,A(M,{get when(){return t.data.summary},get children(){return[kp(),(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.summary))),e})()]}}),null),e})();default:return(()=>{var e=jp();return L(e,()=>Rh(JSON.stringify(t.data),200)),e})()}}function Rh(e,t){return e.length>t?e.slice(0,t)+` …`:e}function zh(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 Bh(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 Vh(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 Hh(e,t){return Rh(e.replace(/\s+/g,` `).trim(),t)}function Uh(e){return(()=>{var t=Mp(),n=t.firstChild;return Ee(t,`click`,e.onClick,!0),L(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&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),n.a=De(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t})()}function Wh(e){let[t,n]=v(!1),[r,i]=v(!1),a=t=>{t.preventDefault(),t.stopPropagation(),Lt(e.text??``).then(e=>{e===`unsupported`||e===`failed`?(i(!0),setTimeout(()=>i(!1),1200)):(n(!0),setTimeout(()=>n(!1),900))})};return(()=>{var n=Np();return n.$$click=a,L(n,(()=>{var n=N(()=>!!t());return()=>n()?`✓`:N(()=>!!r())()?`✗`:e.label??`⧉`})()),y(()=>F(n,`title`,e.title??`copy to clipboard`)),n})()}function Gh(e){return(()=>{var t=Pp(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),L(r,()=>e.title),Ee(i,`click`,e.onClose,!0),L(n,()=>e.children,null),t})()}function Kh(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??[])}ee(()=>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 A(Gh,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=Ip(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,_=h.nextSibling,v=_.nextSibling,b=f.nextSibling,x=b.nextSibling,S=x.firstChild,ee=S.firstChild.nextSibling,C=S.nextSibling,te=C.firstChild.nextSibling,ne=C.nextSibling.firstChild.nextSibling,w=x.nextSibling;return i.addEventListener(`submit`,g),h.$$input=e=>n(e.currentTarget.value),_.$$click=()=>p(t()),v.$$click=()=>m()?p(m()):p(`..`),L(b,A(j,{get each(){return r()},children:e=>(()=>{var n=Lp();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),L(n,e,null),n})()})),ee.$$input=e=>o(e.currentTarget.value),te.addEventListener(`change`,e=>c(e.currentTarget.value)),L(te,A(j,{get each(){return e.providers},children:e=>(()=>{var t=tf();return L(t,e),t})()})),ne.$$input=e=>u(e.currentTarget.value),L(i,A(M,{get when(){return d()},get children(){var e=Fp();return L(e,d),e}}),w),y(()=>h.value=t()),y(()=>ee.value=a()),y(()=>te.value=s()),y(()=>ne.value=l()),i}})}var qh=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]),Jh=new Set([`mp4`,`webm`,`mov`,`mkv`,`avi`,`m4v`]),Yh=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function Xh(e){let t=e.split(`.`).pop()?.toLowerCase()??``,n=Zh(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 Zh(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return qh.has(t)?`image`:Jh.has(t)?`video`:Yh.has(t)?`audio`:null}var Qh=new Map,$h=e=>{let t=Qh.get(e);return t||(t={expanded:new Set,preview:null,media:null,viewMode:`code`},Qh.set(e,t)),t};function eg(e){let t=()=>e.palette,n=()=>Et(e.surfaceAlpha,e.backgroundDim);return(()=>{var r=Bp(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling,f=d.nextSibling,p=f.nextSibling,m=p.nextSibling;return L(r,A(M,{get when(){return e.backgroundImage},get children(){return[(()=>{var t=Rp();return y(n=>Oe(t,`background-image`,Ot(e.backgroundImage))),t})(),(()=>{var e=zp();return y(r=>Oe(e,`background`,Dt(t().bgDark,n().dim))),e})()]}}),i),y(h=>{var g=t().bgDark,_=t().bgDarkest,v=e.backgroundImage?String(n().panel):`1`,y=t().bgDarkest,b=e.backgroundImage?String(n().panel):`1`,x=t().bgMid,S=e.backgroundImage?String(n().raised):`1`,ee=t().fg,C=t().acc,te=t().dim,ne=t().acc,w=t().dim,re=t().ok,T=t().warn,ie=t().err;return g!==h.e&&Oe(r,`background`,h.e=g),_!==h.t&&Oe(i,`background`,h.t=_),v!==h.a&&Oe(i,`opacity`,h.a=v),y!==h.o&&Oe(a,`background`,h.o=y),b!==h.i&&Oe(a,`opacity`,h.i=b),x!==h.n&&Oe(o,`background`,h.n=x),S!==h.s&&Oe(o,`opacity`,h.s=S),ee!==h.h&&Oe(s,`background`,h.h=ee),C!==h.r&&Oe(c,`background`,h.r=C),te!==h.d&&Oe(l,`background`,h.d=te),ne!==h.l&&Oe(u,`background`,h.l=ne),w!==h.u&&Oe(d,`background`,h.u=w),re!==h.c&&Oe(f,`background`,h.c=re),T!==h.w&&Oe(p,`background`,h.w=T),ie!==h.m&&Oe(m,`background`,h.m=ie),h},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0}),r})()}function tg(e){let[t,n]=v(e.themes().some(t=>t.id===e.activeId)?e.activeId:e.themes()[0]?.id??``),r=()=>{let n=e.themes();return n.find(e=>e.id===t())??n.find(t=>t.id===e.activeId)??n[0]},[i,a]=v({}),o,s=t=>{let n=r()?.id;if(!n)return;let i=e.themes().map(e=>e.id===n?t(e):e);e.onChange(i)},c=(e,t)=>{let n=En(t);n&&s(t=>({...t,palette:{...t.palette,[e]:n}}))},l=()=>{let t=e.themes().find(t=>t.id===e.paintedId),r=_h.find(t=>t.key===e.paintedId),i=t??r??_h[0],a=getComputedStyle(document.documentElement),o={..._n};for(let{key:e,cssVar:t}of hn){let n=En(a.getPropertyValue(t));n&&(o[e]=n)}let s=R(e.themes().map(e=>e.id).concat(_h.map(e=>e.key))),c={id:s,label:`${i.label}${t?``:` copy`}`.slice(0,40),mode:i.mode,palette:o,...t?.backgroundImage?{backgroundImage:t.backgroundImage,backgroundDim:t.backgroundDim,surfaceAlpha:t.surfaceAlpha}:{}};e.onChange([...e.themes(),c]),n(s),e.onPick(s)},u=async t=>{if(t){if(!/^image\//.test(t.type))Q(`that file is ${JSON.stringify(t.type||`unknown`)} — pick an image`);else{Q(`uploading ${t.name} (${Math.round(t.size/1024)}KB)…`);try{let n=await fetch(`/api/assets`,{method:`POST`,headers:{"content-type":t.type},body:t}).then(async e=>({ok:e.ok,body:await e.json().catch(()=>null)}));if(!n.ok||!n.body?.url){Q(n.body?.error??`upload failed`);return}s(e=>({...e,backgroundImage:n.body.url,backgroundImageBytes:n.body.bytes}));let i=r()?.id;i&&e.onPick(i),Q(`background image set`)}catch(e){Q(`upload failed: ${e.message}`)}}}};return(()=>{var d=Hp(),f=d.firstChild.nextSibling,p=f.firstChild;return p.$$click=l,L(f,A(M,{get when(){return e.themes().length>0},get children(){var r=Vp();return r.addEventListener(`change`,t=>{n(t.currentTarget.value),e.onPick(t.currentTarget.value)}),L(r,A(j,{get each(){return e.themes()},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.id),t})()})),y(()=>r.value=t()),r}}),null),L(d,A(M,{get when(){return N(()=>!!(r()&&e.themes().some(t=>t.id===e.activeId)))()?r():null},get fallback(){return(()=>{var t=Up();return L(t,(()=>{var t=N(()=>e.themes().length===0);return()=>t()?[`no custom themes yet — press `,Wp(),` to start from the palette you are using.`]:[`the editor shows when one of your themes is ACTIVE — pick one under "your themes" above (or press `,Wp(),`).`]})()),t})()},children:t=>[(()=>{var e=Gp(),t=e.firstChild.firstChild.nextSibling;return t.addEventListener(`change`,e=>s(t=>({...t,mode:e.currentTarget.value}))),y(()=>t.value=r().mode),e})(),(()=>{var e=Kp();return L(e,A(j,{each:hn,children:e=>(()=>{var t=Qp(),n=t.firstChild,o=n.nextSibling,s=o.nextSibling;return n.$$input=t=>c(e.key,t.currentTarget.value),L(o,()=>e.label),s.addEventListener(`blur`,()=>a(t=>{let n={...t};return delete n[e.key],n})),s.$$input=t=>{let n=t.currentTarget.value;a(t=>({...t,[e.key]:n})),c(e.key,n)},F(s,`spellcheck`,!1),y(()=>F(t,`title`,e.cssVar)),y(()=>n.value=En(r().palette[e.key])??`#000000`),y(()=>s.value=i()[e.key]??r().palette[e.key]),t})()})),e})(),(()=>{var t=qp(),i=t.firstChild,a=i.nextSibling;return i.$$click=()=>s(e=>({...e,palette:{..._n}})),a.$$click=()=>{let t=r()?.id;t&&(e.onChange(e.themes().filter(e=>e.id!==t)),n(e.themes().find(e=>e.id!==t)?.id??``))},t})(),Jp(),(()=>{var e=Xp(),t=e.firstChild,n=t.nextSibling;t.$$click=()=>o?.click(),L(t,()=>r().backgroundImage?`🖼 replace image…`:`🖼 choose image…`),n.addEventListener(`change`,e=>{e.stopPropagation(),u(e.currentTarget.files?.[0]),e.currentTarget.value=``}),n.$$input=e=>e.stopPropagation();var i=o;return typeof i==`function`?ke(i,n):o=n,L(e,A(M,{get when(){return r().backgroundImage},get children(){var e=Yp(),t=e.firstChild,n=t.nextSibling;n.firstChild;var i=n.nextSibling.firstChild,a=i.firstChild.nextSibling,o=a.nextSibling,c=o.firstChild,l=i.nextSibling,u=l.firstChild.nextSibling,d=u.nextSibling,f=d.firstChild,p=l.nextSibling;return L(n,()=>{let e=r()?.backgroundImageBytes;return e?` — ${Math.max(1,Math.round(e/1024))} KB`:``},null),a.$$input=e=>s(t=>({...t,backgroundDim:Number(e.currentTarget.value)})),L(o,()=>Math.round((r().backgroundDim??.55)*100),c),u.$$input=e=>s(t=>({...t,surfaceAlpha:Number(e.currentTarget.value)})),L(d,()=>Math.round((r().surfaceAlpha??.82)*100),f),p.$$click=()=>s(e=>({...e,backgroundImage:void 0})),y(()=>F(t,`src`,r().backgroundImage)),y(()=>a.value=r().backgroundDim??.55),y(()=>u.value=r().surfaceAlpha??.82),e}}),null),e})(),Zp()]}),null),d})()}function ng(e){let t=Number(localStorage.getItem(`teapot.todoH`)??``),[n,r]=v(Number.isFinite(t)&&t>0?t:0),i=()=>n()>0?{height:`${n()}px`}:void 0,a=e=>{let t=new ResizeObserver(()=>{let t=e.offsetHeight;t<=0||r(e=>Math.abs(e-t)<1?e:(localStorage.setItem(`teapot.todoH`,String(t)),t))});t.observe(e),C(()=>t.disconnect())};return A(M,{get when(){return e.preview},get fallback(){return(()=>{var t=em();return t.$$input=t=>e.onDraft(t.currentTarget.value),ke(a,t),y(e=>De(t,i(),e)),y(()=>t.value=e.draft),t})()},get children(){var t=$p();return ke(a,t),y(n=>{var r=i(),a=ch(e.draft);return n.e=De(t,r,n.e),a!==n.t&&(t.innerHTML=n.t=a),n},{e:void 0,t:void 0}),t}})}function rg(e){let t=$h(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`),ee=()=>{let e=[`dim`,`hide`,`show`],t=e[(e.indexOf(x())+1)%3];S(t),localStorage.setItem(`teapot.ignoreMode`,t)},te=e=>x()!==`hide`||!e.ignored,[ne,w]=v(localStorage.getItem(`teapot.showHidden`)===`1`),re=()=>{let e=!ne(),t=[``,...i()];Promise.all(t.map(async t=>({p:t,rows:await ae(t,e)}))).then(t=>{w(e),localStorage.setItem(`teapot.showHidden`,e?`1`:`0`);for(let{p:e,rows:n}of t)n&&E(e,n)})},T=(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 ie(e){return ae(e,ne())}async function ae(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 T(t,i.entries??[])}catch(e){return _(e.message),null}}let E=(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}),D=``;b(()=>{let t=e.agentId;t!==D&&(D=t,l(new Set),c(null),f(null),r(new Map),ie(``).then(e=>{e&&D===t&&r(new Map([[``,e]]))}))});let oe=async e=>{let t=new Set(i());if(t.has(e.path))t.delete(e.path),l(t);else if(t.add(e.path),l(t),!n().has(e.path)){let t=await ie(e.path);t&&E(e.path,t)}},[se,ce]=v(``),[le,ue]=v(!1),[O,de]=v(``),[k,fe]=v(!1),pe=e=>/\.(md|markdown|mdx)$/i.test(e),me=0,he=async e=>{let t=++me;ce(``),ue(!0);try{let{highlightChunks:n}=await ku(async()=>{let{highlightChunks:e}=await import(`./shiki-D3K-t1Ea.js`);return{highlightChunks:e}},[]);for await(let r of n(e.path,e.content)){if(me!==t)return;ce(e=>e+r)}}catch{me===t&&ce(``)}finally{me===t&&ue(!1)}};C(()=>{me++});let ge=async(t,n)=>{let r=Zh(t.path);if(r)c({path:t.path,content:``,binary:!0}),f({path:t.path,kind:r}),h(`media`);else 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}),de(r.content??``),h(r.binary?`code`:n),!r.binary&&n!==`md`&&he({path:t.path,content:r.content??``,truncated:r.truncated})}catch(e){Q(`open failed: ${e.message}`)}},_e=async()=>{let t=o();if(t&&!k()){fe(!0);try{await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:O(),baseContent:t.content})}),c({...t,content:O()}),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
|
+
`)[0]??``,140),null),L(e,()=>i().data?.ok===!1?` · FAILED`:``,null),e})():Gf())];break}case`list_dir`:e=l(`path`)||`.`,n=m(4e3);break;case`read_url`:{let r=l(`url`);try{let e=new URL(r);r=e.host+e.pathname}catch{}e=Hh(r,70),t=`web`,n=[(()=>{var e=Mf();return L(e,A(M,{get when(){return/^https?:/i.test(l(`url`))},get fallback(){return(()=>{var e=qf();return L(e,()=>Hh(l(`url`),80)),e})()},get children(){var e=Kf();return y(()=>F(e,`href`,l(`url`))),e}})),e})(),N(()=>m(3e3))];break}case`bash_output`:{let r=l(`action`)||`read`;e=`bash_output ${l(`job_id`)||`(?)`}`,t=r,n=m(4e3);break}case`load_skill`:{e=`skill: ${l(`name`)}`;let t=c().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);n=i()?[(()=>{var e=Uu();return y(()=>e.innerHTML=Le(t)),e})(),(()=>{var e=Mf();return L(e,()=>He(i().data?.durationMs)),e})()]:Jf();break}case`save_skill`:{e=`skill: ${l(`name`)}`,t=Hh(l(`description`),60);let r=Array.isArray(o.args?.files)?o.args.files.map(e=>e?.name).filter(Boolean):[];n=[N(()=>N(()=>!!r.length)()?(()=>{var e=Yf();return e.firstChild,L(e,()=>r.join(`, `),null),e})():null),N(()=>N(()=>!!i())()?(()=>{var e=Bf(),t=e.firstChild;return L(e,()=>Hh(c(),160),t),L(e,()=>He(i().data?.durationMs),null),e})():Xf())];break}default:e=s,t=i()?He(i().data?.durationMs):null,n=[N(()=>p(2e3)),N(()=>m(4e3))]}}catch{}return{label:e,hint:t,body:n,key:`${i()?.id??`none`}|${e}|${t??``}`}},void 0,{equals:(e,t)=>e.key===t.key});return(()=>{var r=Qf(),o=r.firstChild,l=o.firstChild,f=l.nextSibling,p=f.nextSibling;return r.addEventListener(`toggle`,t=>{t.target.open&&e.onResize?.()}),L(l,()=>h().label),L(o,A(M,{get when(){return t.data?.actor},get children(){var e=Zf();return e.firstChild,L(e,()=>String(t.data.actor),null),e}}),f),L(f,(()=>{var e=N(()=>!!i());return()=>e()?h().hint||``:N(()=>!!a())()?`(result missed)`:N(()=>!!(s===`bash`||d()))()?A(Dh,{get startedAt(){return t.ts},inline:!0,get timeoutMs(){return d()}}):`running…`})()),L(p,A(Wh,{get text(){return u()},label:`⧉ cmd`,title:`copy the ${s} arguments`}),null),L(p,A(M,{get when(){return i()},get children(){return A(Wh,{get text(){return c()},label:`⧉ out`,title:`copy this tool's full output`})}}),null),L(r,()=>h().body,null),y(e=>{var t=`embed`+(n?` grouped`:``)+(i()?i().data?.ok===!1?` fail`:` done`:a()?` done`:` running`),o=`${s}${h().hint?` — `+h().hint:``}`;return t!==e.e&&I(r,e.e=t),o!==e.t&&F(r,`title`,e.t=o),e},{e:void 0,t:void 0}),r})()}function Ph(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 Fh(e){let t=e.e,n=vh(t),r=()=>Bt(e.prev?.(),t),i=()=>{let n=e.next?.();return!!n&&Bt(t,n)};if(t.type===`fork`){let e=t.data??{};return(()=>{var n=$f(),r=n.firstChild.nextSibling;return r.nextSibling,L(n,()=>String(e.fromBranch??`?`),r),L(n,()=>String(e.newBranch??t.branch),null),n})()}if(t.type===`goal`){let e=vt(t.data??{});return(()=>{var t=ep(),n=t.firstChild;return L(n,()=>e.label),L(t,A(M,{get when(){return e.hasCard},get children(){var t=Uf();return y(n=>{var r=`card `+(e.tone===`ok`?`auditcard ok`:e.tone===`warn`?`auditcard`:`verifycard`),i=e.markdown?Le(e.detail):Le(`\`\`\`\n${e.detail}\n\`\`\``);return r!==n.e&&I(t,n.e=r),i!==n.t&&(t.innerHTML=n.t=i),n},{e:void 0,t:void 0}),t}}),null),y(()=>I(t,`goalline `+(e.tone===`err`?`err`:e.tone===`warn`?`warn`:``))),t})()}if(t.type===`todo`)return(()=>{var e=tp(),n=e.firstChild.nextSibling;return n.nextSibling,L(e,()=>String(t.data?.by??`human`),n),e})();if(t.type===`state`)return t.data.from===t.data.to?null:(()=>{var e=np(),n=e.firstChild;return L(e,()=>t.data.from,n),L(e,()=>t.data.to,null),L(e,(()=>{var e=N(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>I(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=rp(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;i.nextSibling;var a=n.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,L(n,()=>String(t.data?.failures),r),L(n,()=>String(t.data?.limit),i),L(a,()=>String(t.data?.lastTool),o),L(a,()=>String(t.data?.lastError??``).slice(0,200),null),y(()=>F(e,`title`,`${t.data?.failures} consecutive tool failures hit the configured limit (${t.data?.limit})`)),e})();if(e===`error-retry`)return(()=>{var e=ip(),n=e.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(n,()=>String(t.data?.attempt),r),L(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=Uf();return I(r,`divider-msg`+(e?` err`:``)),L(r,()=>(e?`⚠ background job `:`✓ background job `)+String(t.data?.jobId??`?`)+` `+(e?`FAILED (exit ${String(t.data?.code??`?`)})`:`finished (${n}s)`)),y(()=>F(r,`title`,String(t.data?.cmd??``))),r})()}return e===`context-compacted`?(()=>{var e=ap(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(e,()=>String(t.data?.tokensBefore??`?`),n),L(e,()=>String(t.data?.tokensAfter??`?`),r),L(e,()=>String(t.data?.mode??``),i),e})():e===`context-compaction-started`?(()=>{var e=op(),n=e.firstChild.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,L(e,()=>String(t.data?.messages??`?`),n),L(e,()=>String(t.data?.tokensBefore??`?`),r),L(e,()=>String(t.data?.reason??`auto`),i),e})():null}return(()=>{var a=dp(),o=a.firstChild,s=o.nextSibling;return L(o,(()=>{var e=N(()=>!!r());return()=>e()?``:n.icon})()),L(s,(()=>{var e=N(()=>!!r());return()=>e()&&(()=>{var e=fp();return y(()=>F(e,`title`,`${Ch(t.ts)} · ${t.branch}`)),e})()})(),null),L(s,A(M,{get when(){return!r()},get children(){var r=up(),i=r.firstChild,a=i.nextSibling;return L(i,()=>n.name),L(r,A(M,{get when(){return t.data?.actor},get children(){var e=Zf();return e.firstChild,L(e,()=>String(t.data.actor),null),e}}),a),L(a,(()=>{var e=N(()=>!!t.data?.pending);return()=>e()?`queued…`:N(()=>!!t.data?.cancelled)()?`withdrawn`:Ch(t.ts)})()),L(r,A(M,{get when(){return e.showBranch},get children(){var e=sp();return L(e,()=>t.branch),e}}),null),L(r,A(M,{get when(){return e.onCancel},get children(){var t=cp();return t.$$click=t=>{t.stopPropagation(),e.onCancel()},t}}),null),L(r,A(M,{get when(){return t.type!==`tool_call`},get children(){return A(Wh,{get text(){return Ph(t)},label:`⧉ copy`,title:`copy the RAW text of this message (no markdown rendering)`})}}),null),L(r,A(M,{get when(){return e.onEdit},get children(){var t=lp();return t.$$click=t=>{t.stopPropagation(),e.onEdit()},t}}),null),y(e=>Oe(i,`color`,n.color)),r}}),null),L(s,A(Lh,{e:t,get prev(){return e.prev?.()},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 s=`msg`+(r()?` grouped`:``)+(i()?` next-grouped`:``)+(t.data?.pending?` pending`:``)+(t.data?.cancelled?` withdrawn`:``),c=t.id,l=`avatar avghost`+(r()?` ghosted`:``),u=r()?`transparent`:n.color+`33`,d=r()?`1px solid transparent`:`1px solid ${n.color}66`,f=r()?`${Ch(t.ts)} · ${t.branch}`:void 0;return s!==e.e&&I(a,e.e=s),c!==e.t&&F(a,`data-eid`,e.t=c),l!==e.a&&I(o,e.a=l),u!==e.o&&Oe(o,`background`,e.o=u),d!==e.i&&Oe(o,`border`,e.i=d),f!==e.n&&F(o,`title`,e.n=f),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a})()}function Ih(e){let[t,n]=v(``),r=()=>{let r=t().trim();r&&!e.answered&&(n(``),e.onOption?.(r))};return(()=>{var i=pp(),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&&F(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 Lh(e){let t=e.e;switch(t.type){case`prompt`:{let e=t.data?.images??[];return[(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.text??``))),e})(),A(M,{get when(){return e.length},get children(){var t=mp();return L(t,A(j,{each:e,children:e=>(()=>{var t=hp();return F(t,`src`,e),t})()})),t}})]}case`message`:return[A(M,{get when(){return N(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=gp(),n=e.firstChild;n.firstChild;var r=n.nextSibling;return L(n,(()=>{var e=N(()=>String(t.data.reasoning).length>4e3);return()=>e()?` (${Bh(String(t.data.reasoning).length)} — truncated)`:``})(),null),L(r,()=>Rh(String(t.data.reasoning),8e3)),e}}),(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.content??``))),e})(),A(M,{get when(){return t.data.interrupted},get children(){return _p()}}),A(M,{get when(){return t.data.final},get children(){var e=vp(),n=e.firstChild;return L(e,A(Wh,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:return A(Nh,{e:t,get prev(){return e.prev},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=bp(),o=a.firstChild,s=o.firstChild,c=o.nextSibling,l=c.nextSibling;return I(a,`embed `+(i?``:`fail`)),L(s,r===`bash`?`$ (bash, call evicted)`:r),L(o,A(Wh,{text:n}),null),L(c,()=>Rh(n,4e3)),L(l,()=>He(t.data.durationMs),null),L(l,()=>r===`bash`?Zt(Xt(t.data.ok,n)):i?``:` · FAILED`,null),L(a,A(M,{get when(){return e.orphan},get children(){return yp()}}),null),y(()=>a.open=e.orphan),a})()}case`decision`:{let e=Array.isArray(t.data?.alternatives)?t.data.alternatives:[];return(()=>{var n=Sp(),r=n.firstChild,i=r.firstChild.firstChild.nextSibling,a=r.nextSibling;return L(n,A(M,{get when(){return e.length},get children(){var t=xp();return t.firstChild,L(t,()=>e.join(` / `),null),t}}),null),y(e=>{var n=ch(String(t.data?.decision??``)),r=ch(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=Tp(),o=a.firstChild.firstChild.nextSibling;return L(a,A(M,{get when(){return i()},get children(){return Cp()}}),null),L(a,A(M,{get when(){return n.length>0},get children(){var a=wp();return L(a,A(j,{each:n,children:n=>(()=>{var a=Ep();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)},L(a,n),y(()=>a.disabled=i()),a})()})),a}}),null),L(a,A(Ih,{get answered(){return i()},get onOption(){return e.onOption}}),null),y(e=>{var n=`embed question`+(i()?` answered`:``),r=ch(String(t.data?.question??``));return n!==e.e&&I(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=Dp(),n=e.firstChild.firstChild.nextSibling;return L(e,A(M,{get when(){return t.data.goalStatus},get children(){var e=df(),n=e.firstChild.nextSibling;return L(n,()=>String(t.data.goalStatus)),e}}),null),L(e,A(M,{get when(){return t.data.recent},get children(){var e=cf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.recent))),e}}),null),L(e,A(M,{get when(){return t.data.problems},get children(){var e=lf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.problems))),e}}),null),L(e,A(M,{get when(){return t.data.next},get children(){var e=uf(),n=e.firstChild.nextSibling;return y(()=>n.innerHTML=ch(String(t.data.next))),e}}),null),y(()=>n.innerHTML=ch(String(t.data.doing??``))),e})();case`error`:return(()=>{var e=Op(),n=e.firstChild;return n.firstChild,L(n,()=>String(t.data.message??``),null),e})();case`compaction`:return(()=>{var e=Ap(),n=e.firstChild.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,a=i.nextSibling.nextSibling;return a.nextSibling,L(n,()=>String(t.data.mode??``),r),L(n,()=>Bh(Number(t.data.tokensBefore??0)),i),L(n,()=>Bh(Number(t.data.tokensAfter??0)),a),L(n,(()=>{var e=N(()=>!!t.data.summarized);return()=>e()?`${t.data.summarized} summarized`:`${t.data.dropped} dropped`})(),null),L(e,A(M,{get when(){return t.data.summary},get children(){return[kp(),(()=>{var e=Uu();return y(()=>e.innerHTML=ch(String(t.data.summary))),e})()]}}),null),e})();default:return(()=>{var e=jp();return L(e,()=>Rh(JSON.stringify(t.data),200)),e})()}}function Rh(e,t){return e.length>t?e.slice(0,t)+` …`:e}function zh(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 Bh(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 Vh(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 Hh(e,t){return Rh(e.replace(/\s+/g,` `).trim(),t)}function Uh(e){return(()=>{var t=Mp(),n=t.firstChild;return Ee(t,`click`,e.onClick,!0),L(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&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),n.a=De(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t})()}function Wh(e){let[t,n]=v(!1),[r,i]=v(!1),a=t=>{t.preventDefault(),t.stopPropagation(),Lt(e.text??``).then(e=>{e===`unsupported`||e===`failed`?(i(!0),setTimeout(()=>i(!1),1200)):(n(!0),setTimeout(()=>n(!1),900))})};return(()=>{var n=Np();return n.$$click=a,L(n,(()=>{var n=N(()=>!!t());return()=>n()?`✓`:N(()=>!!r())()?`✗`:e.label??`⧉`})()),y(()=>F(n,`title`,e.title??`copy to clipboard`)),n})()}function Gh(e){return(()=>{var t=Pp(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),L(r,()=>e.title),Ee(i,`click`,e.onClose,!0),L(n,()=>e.children,null),t})()}function Kh(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??[])}ee(()=>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 A(Gh,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=Ip(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,_=h.nextSibling,v=_.nextSibling,b=f.nextSibling,x=b.nextSibling,S=x.firstChild,ee=S.firstChild.nextSibling,C=S.nextSibling,te=C.firstChild.nextSibling,ne=C.nextSibling.firstChild.nextSibling,w=x.nextSibling;return i.addEventListener(`submit`,g),h.$$input=e=>n(e.currentTarget.value),_.$$click=()=>p(t()),v.$$click=()=>m()?p(m()):p(`..`),L(b,A(j,{get each(){return r()},children:e=>(()=>{var n=Lp();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),L(n,e,null),n})()})),ee.$$input=e=>o(e.currentTarget.value),te.addEventListener(`change`,e=>c(e.currentTarget.value)),L(te,A(j,{get each(){return e.providers},children:e=>(()=>{var t=tf();return L(t,e),t})()})),ne.$$input=e=>u(e.currentTarget.value),L(i,A(M,{get when(){return d()},get children(){var e=Fp();return L(e,d),e}}),w),y(()=>h.value=t()),y(()=>ee.value=a()),y(()=>te.value=s()),y(()=>ne.value=l()),i}})}var qh=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]),Jh=new Set([`mp4`,`webm`,`mov`,`mkv`,`avi`,`m4v`]),Yh=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function Xh(e){let t=e.split(`.`).pop()?.toLowerCase()??``,n=Zh(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 Zh(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return qh.has(t)?`image`:Jh.has(t)?`video`:Yh.has(t)?`audio`:null}var Qh=new Map,$h=e=>{let t=Qh.get(e);return t||(t={expanded:new Set,preview:null,media:null,viewMode:`code`},Qh.set(e,t)),t};function eg(e){let t=()=>e.palette,n=()=>Et(e.surfaceAlpha,e.backgroundDim);return(()=>{var r=Bp(),i=r.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling,f=d.nextSibling,p=f.nextSibling,m=p.nextSibling;return L(r,A(M,{get when(){return e.backgroundImage},get children(){return[(()=>{var t=Rp();return y(n=>Oe(t,`background-image`,Ot(e.backgroundImage))),t})(),(()=>{var e=zp();return y(r=>Oe(e,`background`,Dt(t().bgDark,n().dim))),e})()]}}),i),y(h=>{var g=t().bgDark,_=t().bgDarkest,v=e.backgroundImage?String(n().panel):`1`,y=t().bgDarkest,b=e.backgroundImage?String(n().panel):`1`,x=t().bgMid,S=e.backgroundImage?String(n().raised):`1`,ee=t().fg,C=t().acc,te=t().dim,ne=t().acc,w=t().dim,re=t().ok,T=t().warn,ie=t().err;return g!==h.e&&Oe(r,`background`,h.e=g),_!==h.t&&Oe(i,`background`,h.t=_),v!==h.a&&Oe(i,`opacity`,h.a=v),y!==h.o&&Oe(a,`background`,h.o=y),b!==h.i&&Oe(a,`opacity`,h.i=b),x!==h.n&&Oe(o,`background`,h.n=x),S!==h.s&&Oe(o,`opacity`,h.s=S),ee!==h.h&&Oe(s,`background`,h.h=ee),C!==h.r&&Oe(c,`background`,h.r=C),te!==h.d&&Oe(l,`background`,h.d=te),ne!==h.l&&Oe(u,`background`,h.l=ne),w!==h.u&&Oe(d,`background`,h.u=w),re!==h.c&&Oe(f,`background`,h.c=re),T!==h.w&&Oe(p,`background`,h.w=T),ie!==h.m&&Oe(m,`background`,h.m=ie),h},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0}),r})()}function tg(e){let[t,n]=v(e.themes().some(t=>t.id===e.activeId)?e.activeId:e.themes()[0]?.id??``),r=()=>{let n=e.themes();return n.find(e=>e.id===t())??n.find(t=>t.id===e.activeId)??n[0]},[i,a]=v({}),o,s=t=>{let n=r()?.id;if(!n)return;let i=e.themes().map(e=>e.id===n?t(e):e);e.onChange(i)},c=(e,t)=>{let n=En(t);n&&s(t=>({...t,palette:{...t.palette,[e]:n}}))},l=()=>{let t=e.themes().find(t=>t.id===e.paintedId),r=_h.find(t=>t.key===e.paintedId),i=t??r??_h[0],a=getComputedStyle(document.documentElement),o={..._n};for(let{key:e,cssVar:t}of hn){let n=En(a.getPropertyValue(t));n&&(o[e]=n)}let s=R(e.themes().map(e=>e.id).concat(_h.map(e=>e.key))),c={id:s,label:`${i.label}${t?``:` copy`}`.slice(0,40),mode:i.mode,palette:o,...t?.backgroundImage?{backgroundImage:t.backgroundImage,backgroundDim:t.backgroundDim,surfaceAlpha:t.surfaceAlpha}:{}};e.onChange([...e.themes(),c]),n(s),e.onPick(s)},u=async t=>{if(t){if(!/^image\//.test(t.type))Q(`that file is ${JSON.stringify(t.type||`unknown`)} — pick an image`);else{Q(`uploading ${t.name} (${Math.round(t.size/1024)}KB)…`);try{let n=await fetch(`/api/assets`,{method:`POST`,headers:{"content-type":t.type},body:t}).then(async e=>({ok:e.ok,body:await e.json().catch(()=>null)}));if(!n.ok||!n.body?.url){Q(n.body?.error??`upload failed`);return}s(e=>({...e,backgroundImage:n.body.url,backgroundImageBytes:n.body.bytes}));let i=r()?.id;i&&e.onPick(i),Q(`background image set`)}catch(e){Q(`upload failed: ${e.message}`)}}}};return(()=>{var d=Hp(),f=d.firstChild.nextSibling,p=f.firstChild;return p.$$click=l,L(f,A(M,{get when(){return e.themes().length>0},get children(){var r=Vp();return r.addEventListener(`change`,t=>{n(t.currentTarget.value),e.onPick(t.currentTarget.value)}),L(r,A(j,{get each(){return e.themes()},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.id),t})()})),y(()=>r.value=t()),r}}),null),L(d,A(M,{get when(){return N(()=>!!(r()&&e.themes().some(t=>t.id===e.activeId)))()?r():null},get fallback(){return(()=>{var t=Up();return L(t,(()=>{var t=N(()=>e.themes().length===0);return()=>t()?[`no custom themes yet — press `,Wp(),` to start from the palette you are using.`]:[`the editor shows when one of your themes is ACTIVE — pick one under "your themes" above (or press `,Wp(),`).`]})()),t})()},children:t=>[(()=>{var e=Gp(),t=e.firstChild.firstChild.nextSibling;return t.addEventListener(`change`,e=>s(t=>({...t,mode:e.currentTarget.value}))),y(()=>t.value=r().mode),e})(),(()=>{var e=Kp();return L(e,A(j,{each:hn,children:e=>(()=>{var t=Qp(),n=t.firstChild,o=n.nextSibling,s=o.nextSibling;return n.$$input=t=>c(e.key,t.currentTarget.value),L(o,()=>e.label),s.addEventListener(`blur`,()=>a(t=>{let n={...t};return delete n[e.key],n})),s.$$input=t=>{let n=t.currentTarget.value;a(t=>({...t,[e.key]:n})),c(e.key,n)},F(s,`spellcheck`,!1),y(()=>F(t,`title`,e.cssVar)),y(()=>n.value=En(r().palette[e.key])??`#000000`),y(()=>s.value=i()[e.key]??r().palette[e.key]),t})()})),e})(),(()=>{var t=qp(),i=t.firstChild,a=i.nextSibling;return i.$$click=()=>s(e=>({...e,palette:{..._n}})),a.$$click=()=>{let t=r()?.id;t&&(e.onChange(e.themes().filter(e=>e.id!==t)),n(e.themes().find(e=>e.id!==t)?.id??``))},t})(),Jp(),(()=>{var e=Xp(),t=e.firstChild,n=t.nextSibling;t.$$click=()=>o?.click(),L(t,()=>r().backgroundImage?`🖼 replace image…`:`🖼 choose image…`),n.addEventListener(`change`,e=>{e.stopPropagation(),u(e.currentTarget.files?.[0]),e.currentTarget.value=``}),n.$$input=e=>e.stopPropagation();var i=o;return typeof i==`function`?ke(i,n):o=n,L(e,A(M,{get when(){return r().backgroundImage},get children(){var e=Yp(),t=e.firstChild,n=t.nextSibling;n.firstChild;var i=n.nextSibling.firstChild,a=i.firstChild.nextSibling,o=a.nextSibling,c=o.firstChild,l=i.nextSibling,u=l.firstChild.nextSibling,d=u.nextSibling,f=d.firstChild,p=l.nextSibling;return L(n,()=>{let e=r()?.backgroundImageBytes;return e?` — ${Math.max(1,Math.round(e/1024))} KB`:``},null),a.$$input=e=>s(t=>({...t,backgroundDim:Number(e.currentTarget.value)})),L(o,()=>Math.round((r().backgroundDim??.55)*100),c),u.$$input=e=>s(t=>({...t,surfaceAlpha:Number(e.currentTarget.value)})),L(d,()=>Math.round((r().surfaceAlpha??.82)*100),f),p.$$click=()=>s(e=>({...e,backgroundImage:void 0})),y(()=>F(t,`src`,r().backgroundImage)),y(()=>a.value=r().backgroundDim??.55),y(()=>u.value=r().surfaceAlpha??.82),e}}),null),e})(),Zp()]}),null),d})()}function ng(e){let t=Number(localStorage.getItem(`teapot.todoH`)??``),[n,r]=v(Number.isFinite(t)&&t>0?t:0),i=()=>n()>0?{height:`${n()}px`}:void 0,a=e=>{let t=new ResizeObserver(()=>{let t=e.offsetHeight;t<=0||r(e=>Math.abs(e-t)<1?e:(localStorage.setItem(`teapot.todoH`,String(t)),t))});t.observe(e),C(()=>t.disconnect())};return A(M,{get when(){return e.preview},get fallback(){return(()=>{var t=em();return t.$$input=t=>e.onDraft(t.currentTarget.value),ke(a,t),y(e=>De(t,i(),e)),y(()=>t.value=e.draft),t})()},get children(){var t=$p();return ke(a,t),y(n=>{var r=i(),a=ch(e.draft);return n.e=De(t,r,n.e),a!==n.t&&(t.innerHTML=n.t=a),n},{e:void 0,t:void 0}),t}})}function rg(e){let t=$h(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`),ee=()=>{let e=[`dim`,`hide`,`show`],t=e[(e.indexOf(x())+1)%3];S(t),localStorage.setItem(`teapot.ignoreMode`,t)},te=e=>x()!==`hide`||!e.ignored,[ne,w]=v(localStorage.getItem(`teapot.showHidden`)===`1`),re=()=>{let e=!ne(),t=[``,...i()];Promise.all(t.map(async t=>({p:t,rows:await ae(t,e)}))).then(t=>{w(e),localStorage.setItem(`teapot.showHidden`,e?`1`:`0`);for(let{p:e,rows:n}of t)n&&E(e,n)})},T=(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 ie(e){return ae(e,ne())}async function ae(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 T(t,i.entries??[])}catch(e){return _(e.message),null}}let E=(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}),D=``;b(()=>{let t=e.agentId;t!==D&&(D=t,l(new Set),c(null),f(null),r(new Map),ie(``).then(e=>{e&&D===t&&r(new Map([[``,e]]))}))});let oe=async e=>{let t=new Set(i());if(t.has(e.path))t.delete(e.path),l(t);else if(t.add(e.path),l(t),!n().has(e.path)){let t=await ie(e.path);t&&E(e.path,t)}},[se,ce]=v(``),[le,ue]=v(!1),[O,de]=v(``),[k,fe]=v(!1),pe=e=>/\.(md|markdown|mdx)$/i.test(e),me=0,he=async e=>{let t=++me;ce(``),ue(!0);try{let{highlightChunks:n}=await ku(async()=>{let{highlightChunks:e}=await import(`./shiki-BKqf8YtI.js`);return{highlightChunks:e}},[]);for await(let r of n(e.path,e.content)){if(me!==t)return;ce(e=>e+r)}}catch{me===t&&ce(``)}finally{me===t&&ue(!1)}};C(()=>{me++});let ge=async(t,n)=>{let r=Zh(t.path);if(r)c({path:t.path,content:``,binary:!0}),f({path:t.path,kind:r}),h(`media`);else 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}),de(r.content??``),h(r.binary?`code`:n),!r.binary&&n!==`md`&&he({path:t.path,content:r.content??``,truncated:r.truncated})}catch(e){Q(`open failed: ${e.message}`)}},_e=async()=>{let t=o();if(t&&!k()){fe(!0);try{await $(`/api/agents/${e.agentId}/file?path=${encodeURIComponent(t.path)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:O(),baseContent:t.content})}),c({...t,content:O()}),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.
|
|
29
29
|
OK = load the disk version into the editor (your edits are discarded)
|
|
30
|
-
Cancel = keep editing your copy`)?(de(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{fe(!1)}}},ve=e=>!e.binary&&!e.truncated,ye=(e,t)=>[(()=>{var n=nm(),r=n.firstChild,a=r.nextSibling;return n.$$click=()=>e.dir?void oe(e):void ge(e,`code`),L(r,(()=>{var t=N(()=>!!e.dir);return()=>t()?i().has(e.path)?`▾`:`▸`:Xh(e.name)})()),L(a,()=>e.name),L(n,A(M,{get when(){return N(()=>!e.dir)()&&e.size!==void 0},get children(){var t=tm();return L(t,()=>Bh(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&&I(n,r.e=i),r.t=De(n,a,r.t),o!==r.a&&F(n,`title`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})(),A(M,{get when(){return N(()=>!!e.dir)()&&i().has(e.path)},get children(){return A(j,{get each(){return(n().get(e.path)??[]).filter(te)},children:e=>ye(e,t+1)})}})],be=()=>e.workspace.split(`/`).filter(Boolean).pop()??e.workspace,[xe,Se]=v(!1),Ce=async()=>{if(!xe()){Se(!0);try{let e=[``,...i()],t=await Promise.all(e.map(async e=>({p:e,rows:await ae(e,ne())})));for(let{p:e,rows:n}of t)n&&E(e,n)}finally{Se(!1)}}};return[(()=>{var e=rm(),t=e.firstChild.nextSibling;return t.firstChild,L(t,be,null),L(e,A(Uh,{class:`filetoggle`,get icon(){return xe()?`…`:`⟳`},title:`refresh the tree (root + expanded folders) — open popups are kept`,onClick:()=>void Ce()}),null),L(e,A(Uh,{class:`filetoggle`,style:`margin-left:auto`,get icon(){return N(()=>x()===`hide`)()?`🙈`:x()===`dim`?`👁`:`✨`},get title(){return`gitignored files: ${x()} — click to cycle (dim → hidden → shown)`},onClick:ee}),null),L(e,A(Uh,{class:`filetoggle`,get icon(){return ne()?`◉.`:`○.`},get title(){return ne()?`dotfiles shown — click to hide`:`dotfiles hidden — click to show`},onClick:re}),null),e})(),(()=>{var e=im();return L(e,A(M,{get when(){return(n().get(``)??[]).length>0},get fallback(){return(()=>{var e=am();return L(e,()=>g()||`empty workspace`),e})()},get children(){return A(j,{get each(){return(n().get(``)??[]).filter(te)},children:e=>ye(e,0)})}})),e})(),A(M,{get when(){return o()},children:t=>A(Gh,{get title(){return`🗂 ${t().path}`},onClose:()=>{me++,c(null),f(null)},get children(){return A(M,{get when(){return u()},get fallback(){return[(()=>{var e=um(),n=e.firstChild;return L(e,A(M,{get when(){return N(()=>!!pe(t().path))()&&!t().binary},get children(){var e=cm();return e.$$click=()=>h(`md`),y(()=>I(e,p()===`md`?`on`:``)),e}}),n),n.$$click=()=>{h(`code`),se()||he({path:t().path,content:t().content,truncated:t().truncated})},L(e,A(M,{get when(){return ve(t())},get children(){var e=lm();return e.$$click=()=>h(`edit`),y(()=>I(e,p()===`edit`?`on`:``)),e}}),null),y(()=>I(n,p()===`code`?`on`:``)),e})(),A(M,{get when(){return!t().binary},get fallback(){return fm()},get children(){return A(M,{get when(){return p()===`edit`},get fallback(){return A(M,{get when(){return N(()=>p()===`md`)()&&pe(t().path)},get fallback(){return A(ig,{get path(){return t().path},get content(){return t().content},get html(){return se()},get pending(){return le()},get truncated(){return!!t().truncated}})},get children(){var e=pm();return y(()=>e.innerHTML=Le(t().content)),e}})},get children(){var e=dm(),n=e.firstChild,r=n.nextSibling.firstChild,i=r.firstChild,a=r.nextSibling;return n.$$input=e=>de(e.currentTarget.value),F(n,`spellcheck`,!1),L(r,()=>Bh(O().length),i),a.$$click=()=>void _e(),L(a,()=>k()?`saving…`:`💾 save`),y(()=>a.disabled=k()||O()===t().content),y(()=>n.value=O()),e}})}})]},get children(){var t=sm(),n=t.firstChild,r=n.firstChild;return L(t,A(M,{get when(){return u().kind===`image`},get fallback(){return A(M,{get when(){return u().kind===`video`},get fallback(){return(()=>{var t=hm();return y(()=>F(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t})()},get children(){var t=mm();return y(()=>F(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t}})},get children(){var t=om();return y(n=>{var r=`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`,i=u().path.split(`/`).pop();return r!==n.e&&F(t,`src`,n.e=r),i!==n.t&&F(t,`alt`,n.t=i),n},{e:void 0,t:void 0}),t}}),n),L(n,()=>u().kind,r),t}})}})})]}function ig(e){return[A(M,{get when(){return e.html},get fallback(){return N(()=>!!e.pending)()?(()=>{var t=vm(),n=t.firstChild.nextSibling;return n.nextSibling,L(t,()=>e.path.split(`/`).pop(),n),t})():(()=>{var t=ym();return L(t,()=>e.content),t})()},get children(){var t=gm();return y(()=>t.innerHTML=e.html),t}}),A(M,{get when(){return e.truncated},get children(){return _m()}})]}var ag=[{key:`openrouter`,label:`OpenRouter`,url:`https://openrouter.ai/api/v1`,model:``,hint:`400+ models behind one key — teapot sends app-attribution headers automatically`},{key:`orcarouter`,label:`OrcaRouter`,url:`https://api.orcarouter.ai/v1`,model:``,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:``,hint:`your account's models — pick from the list once the endpoint answers`},{key:`opencode-go`,label:`OpenCode Go`,url:`https://opencode.ai/zen/go/v1`,model:``,hint:`OpenCode's open-model subscription — teapot sends the required x-opencode-session header; choose a chat/completions model`},{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)`}];function og(e){return(()=>{var t=bm(),n=t.firstChild;return L(t,()=>e.label,n),n.$$input=t=>e.onValue(Number(t.currentTarget.value)),y(()=>F(t,`title`,e.hint)),y(()=>n.value=e.value),t})()}function sg(e){let t=(e,t)=>{let n=Array.isArray(t?.apiKeys)&&t.apiKeys.length?t.apiKeys.filter(e=>typeof e==`string`&&e.trim()):t?.apiKey?[String(t.apiKey)]:[``];return{name:e,baseUrl:t?.baseUrl??``,apiKeys:n.length?n:[``],model:t?.model??``}},[n,r]=v(Object.entries(e.cfg.providers??{}).map(([e,n])=>t(e,n))),[i,a]=v(e.cfg.defaultProvider??``),o=()=>e.cfg.defaultProvider??``,s=()=>{let e=[...new Set(n().map(e=>e.name.trim()).filter(Boolean))],t=i();return t&&!e.includes(t)&&e.push(t),e},c=()=>{let e=i();return e?n().some(t=>t.name.trim()===e)?``:e:``},[l,u]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[d,f]=v(e.cfg.progressMinChars??4e3),[p,m]=v(e.cfg.contextTokenBudget==null?null:Math.round(e.cfg.contextTokenBudget/1e3)),[h,g]=v(e.cfg.contextWindowTokens?Math.round(e.cfg.contextWindowTokens/1e3):0),[_,x]=v(e.cfg.maxSpawnDepth??3),[S,ee]=v(!!e.cfg.shortContext),[C,te]=v((e.cfg.tasks??[]).map(e=>({...e}))),[ne,w]=v((e.cfg.mcpServers??[]).map(e=>({...e}))),[re,T]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>[t,e.headers?JSON.stringify(e.headers):``]))),[ie,ae]=v({}),[E,D]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=e.headers??{},r=Object.keys(n);if(!r.length)return[t,`none`];let i=r.length===1?r[0]:``;return i===`Authorization`&&/^Bearer /i.test(n[i]??``)?[t,`bearer`]:[t,r.length===1?`header`:`json`]}))),[oe,se]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=e.headers??{},r=Object.keys(n);if(r.length!==1)return[t,``];let i=r[0];return[t,i===`Authorization`?(n[i]??``).replace(/^Bearer /i,``):n[i]??``]}))),[ce,le]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=Object.keys(e.headers??{}),r=n.length===1?n[0]:``;return[t,r&&r!==`Authorization`?r:``]}))),[ue,O]=v({}),[de,k]=v({}),[fe,pe]=v({}),me=e=>{let t=String(e??``).trim();if(!t)return null;let n=fe()[t];return n&&(n.required||n.authorized)?n:null},he=async()=>{let e=await $(`/api/mcp`).catch(()=>null);k(Object.fromEntries((e?.states??[]).map(e=>[e.name,e])))},ge=async e=>{let t=String(e??``).trim();if(!t)return;let n=await $(`/api/mcp/oauth/status?name=${encodeURIComponent(t)}`).catch(()=>null);n&&!n.error&&pe(e=>({...e,[t]:n}))},_e=async(t,n)=>{if(!n.name){O(e=>({...e,[t]:{kind:`err`,text:`give it a name first`}}));return}O(e=>({...e,[t]:{kind:`testing`,text:`discovering the authorization server…`}}));let r=await $(`/api/mcp/oauth/start`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n.name})}).catch(()=>null);if(r?.alreadyAuthorized){O(e=>({...e,[t]:{kind:`ok`,text:`already authorized`}})),await ge(n.name),await he();return}if(!r?.ok||!r.url){O(e=>({...e,[t]:{kind:`err`,text:r?.error??`no response`}})),await ge(n.name);return}window.open(r.url,`_blank`,`noopener`),O(e=>({...e,[t]:{kind:`testing`,text:`waiting for you to finish in the browser…`}}));let i=Date.now()+3e5;for(;Date.now()<i;){await new Promise(e=>setTimeout(e,1e3));let r=await $(`/api/mcp/oauth/status?name=${encodeURIComponent(n.name)}`).catch(()=>null);if(r&&!r.error){if(pe(e=>({...e,[t]:r})),r.authorized){O(e=>({...e,[t]:{kind:`ok`,text:`authorized — the tools are available now`}})),await he(),e.onSaved();return}if(r.flow?.phase===`error`){O(e=>({...e,[t]:{kind:`err`,text:r.flow.message??r.lastError??`authorization failed`}}));return}}}O(e=>({...e,[t]:{kind:`err`,text:`authorization timed out`}}))};b(()=>{be()===`mcp`&&(he(),ne().forEach((e,t)=>{e.name&&ge(e.name)}))});let[ve,ye]=v(``),[be,Se]=v(`providers`),Ce=(t,n)=>{let{slot:r}=yt(e.theme.auto(),n);r===`dark`?e.theme.setDark(t):r===`light`?e.theme.setLight(t):e.theme.setActive(t)},we=t=>bt({auto:e.theme.auto(),fixed:e.theme.activeId(),dark:e.theme.dark(),light:e.theme.light(),prefersLight:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: light)`).matches})===t,[P,Te]=v([]),Ee=async()=>{let e=await $(`/api/archived`).catch(()=>null);Te(e?.agents??[])},De=()=>P().filter(e=>!e.parent);b(()=>{be()===`archive`&&Ee()});let Oe=[{key:`providers`,label:`🧦 providers`,hint:`endpoints, API keys, default models`},{key:`appearance`,label:`🎨 appearance`,hint:`theme, custom palettes, background image`},{key:`runtime`,label:`⚙️ runtime`,hint:`context budget, retries, spawn depth`},{key:`tasks`,label:`⏰ scheduled tasks`,hint:`cron prompts run against an agent`},{key:`mcp`,label:`🔌 MCP servers`,hint:`external tool servers exposed to every agent`},{key:`archive`,label:`🗄 archive`,hint:`agents you put away — restore or delete for good`},{key:`agents`,label:`👥 agents`,hint:`what exists (read-only)`},{key:`update`,label:`⬆️ live update`,hint:`restart onto a newer build`},{key:`skills`,label:`🧠 skills`,hint:`reusable playbooks available to the selected session`},{key:`help`,label:`❔ help`,hint:`keyboard shortcuts and what each toggle does`}],ke=()=>(e.cfg.agents??[]).map(e=>e.id),Ae=()=>e.theme.themes(),je=()=>e.theme.activeId(),Me=t=>e.theme.setActive(t),Ne=()=>e.theme.auto(),Pe=t=>e.theme.setAuto(t),Fe=()=>e.theme.dark(),Ie=t=>e.theme.setDark(t),Le=()=>e.theme.light(),Re=t=>e.theme.setLight(t),ze=t=>e.theme.setThemes(t),Be=e=>vn[e]??_n,Ve=()=>{let e={};for(let t of n()){if(!t.name.trim())return ye(`provider name is required`),null;if(t.baseUrl&&!/^https?:\/\//.test(t.baseUrl))return ye(`provider ${t.name}: baseUrl must start with http(s)://`),null;let n=t.apiKeys.map(e=>e.trim()).filter(Boolean);e[t.name.trim()]={baseUrl:t.baseUrl,...n.length?{apiKeys:n,apiKey:n[0]}:{},...t.model?{model:t.model}:{}}}return e},[He,Ue]=v(`idle`),We=e=>{ye(e),Ue(e=>e===`saving`?`idle`:e)},Ge=async t=>{t.preventDefault(),ye(``),Ue(`saving`);let n=Ve();if(!n)return Ue(`idle`);let r=C().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 r){if(!e.agent)return We(`task "${e.id}": agent is required`);if(!e.schedule?.trim())return We(`task "${e.id}": schedule is required`)}let a=[],o=new Set;for(let e of ne()){let t=String(e.name??``).trim(),n=String(e.url??``).trim(),r=e.transport??`http`,i=String(e.command??``).trim();if(t||n||i){if(!t)return We(`MCP: a server needs a name`);if(o.has(t))return We(`MCP: two servers are named "${t}"`);if(o.add(t),r===`stdio`?!i:!n)return We(`MCP "${t}": ${r===`stdio`?`a command is`:`a url is`} required`);a.push({name:t,transport:r,enabled:e.enabled!==!1,...n?{url:n}:{},...r===`stdio`?{command:i,...e.args?.length?{args:e.args}:{}}:{},...e.headers&&Object.keys(e.headers).length?{headers:e.headers}:{}})}}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:n,defaultProvider:i()||void 0,progressIntervalMs:Math.max(1,l())*6e4,progressMinChars:Math.max(100,d()),...p()==null?{}:{contextTokenBudget:Math.max(1,p())*1e3},...h()>0?{contextWindowTokens:h()*1e3}:{},maxSpawnDepth:Math.max(0,_()),shortContext:S(),tasks:r,mcpServers:a})}),await he(),await Promise.all(a.map((e,t)=>e.name?ge(e.name):Promise.resolve())),setTimeout(()=>{he(),a.forEach((e,t)=>{e.name&&ge(e.name)})},1200),e.onSaved();let t=new Set(a.map(e=>e.name).filter(Boolean)),o=ne().filter(e=>{let n=String(e.name??``).trim();return t.has(n)&&fe()[n]?.required&&!fe()[n]?.authorized}).filter(t=>!e.announcedOAuth.has(String(t.name??``)));if(o.length>0){for(let t of o)e.announcedOAuth.add(String(t.name??``));Q(`${o.map(e=>String(e.name??``).trim()).filter(Boolean).join(`, `)||`a saved MCP server`} needs authorization — 🔑 authorize in MCP servers`)}Ue(`saved`),setTimeout(()=>{Ue(`idle`),e.onClose()},400)}catch(e){ye(e.message),Ue(`error`),setTimeout(()=>Ue(`idle`),1600)}};return A(Gh,{title:`settings`,get onClose(){return e.onClose},get children(){var t=wm(),b=t.firstChild,k=b.firstChild,pe=k.nextSibling.firstChild,he=pe.firstChild.nextSibling,P=he.nextSibling;P.firstChild;var Te=P.nextSibling.firstChild.firstChild.nextSibling;Te.firstChild;var Ve=pe.nextSibling,Ue=Ve.firstChild.nextSibling,We=Ue.firstChild.firstChild.nextSibling,Ke=Ue.nextSibling,qe=Ve.nextSibling,Je=qe.firstChild.nextSibling,Ye=Je.firstChild,Xe=Ye.firstChild.nextSibling,Ze=Je.nextSibling.firstChild,Qe=qe.nextSibling,$e=Qe.firstChild.nextSibling.nextSibling,et=Qe.nextSibling,tt=et.firstChild.nextSibling,nt=et.nextSibling;nt.firstChild;var rt=nt.nextSibling;rt.firstChild;var it=rt.nextSibling,at=it.firstChild.nextSibling.firstChild;at.firstChild;var ot=at.nextSibling,st=it.nextSibling,ct=st.firstChild.nextSibling.firstChild,lt=ct.firstChild.nextSibling,ut=ct.nextSibling.firstChild.nextSibling,dt=st.nextSibling,ft=b.nextSibling,pt=ft.firstChild;return t.addEventListener(`submit`,Ge),L(k,A(j,{each:Oe,children:e=>(()=>{var t=Tm(),n=t.firstChild;return t.$$click=()=>Se(e.key),L(n,()=>e.label),y(n=>{var r=`cfgmenu-item`+(be()===e.key?` on`:``),i=e.hint,a=be()===e.key?`page`:void 0;return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-current`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),L(pe,A(xe,{get each(){return n()},children:(e,t)=>(()=>{var i=Em(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.firstChild;return a.$$input=e=>r(n().map((n,r)=>r===t?{...n,name:e.currentTarget.value}:n)),o.$$input=e=>r(n().map((n,r)=>r===t?{...n,baseUrl:e.currentTarget.value}:n)),s.$$input=e=>r(n().map((n,r)=>r===t?{...n,model:e.currentTarget.value}:n)),c.$$click=()=>r(n().filter((e,n)=>n!==t)),L(l,A(j,{get each(){return e().apiKeys},children:(i,a)=>(()=>{var o=Om(),s=o.firstChild;return s.$$input=e=>r(n().map((n,r)=>r===t?{...n,apiKeys:n.apiKeys.map((t,n)=>n===a()?e.currentTarget.value:t)}:n)),s.value=i,L(o,A(M,{get when(){return e().apiKeys.length>1},get children(){var e=Dm();return e.$$click=()=>r(n().map((e,n)=>n===t?{...e,apiKeys:e.apiKeys.filter((e,t)=>t!==a())}:e)),e}}),null),y(()=>F(s,`placeholder`,a()===0?`api key`:`api key (backup)`)),o})()}),u),u.$$click=()=>r(n().map((e,n)=>n===t?{...e,apiKeys:[...e.apiKeys,``]}:e)),y(()=>a.value=e().name),y(()=>o.value=e().baseUrl),y(()=>s.value=e().model),i})()}),he),he.$$click=()=>r([...n(),{name:``,baseUrl:``,apiKeys:[``],model:``}]),L(P,A(j,{each:ag,children:e=>(()=>{var t=km();return t.firstChild,t.$$click=()=>{let t=n().filter(t=>t.name!==e.key);r([...t,{name:e.key,baseUrl:e.url,apiKeys:[``],model:e.model}]),i()||a(e.key)},L(t,()=>e.label,null),y(()=>F(t,`title`,`fill a ${e.label} row — ${e.url}${e.model?` (model: ${e.model})`:``}`)),t})()}),null),Te.addEventListener(`change`,e=>a(e.currentTarget.value)),L(Te,A(j,{get each(){return s()},children:e=>(()=>{var t=tf();return t.value=e,L(t,e),t})()}),null),L(pe,A(M,{get when(){return c()},get children(){var e=xm(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling;return L(t,c),L(e,()=>c()===o()?` — the dropdown above cannot show it.`:` — it was replaced by your selection.`,n),L(r,c),e}}),null),We.addEventListener(`change`,e=>{Pe(e.currentTarget.checked),localStorage.setItem(`teapot.theme.auto`,e.currentTarget.checked?`1`:`0`)}),L(Ve,A(M,{get when(){return Ne()},get children(){var e=Sm(),t=e.firstChild,n=t.firstChild.nextSibling,r=t.nextSibling.firstChild.nextSibling;return n.addEventListener(`change`,e=>{Ie(e.currentTarget.value),localStorage.setItem(`teapot.theme.dark`,e.currentTarget.value)}),L(n,A(j,{get each(){return Ae().filter(e=>e.mode===`dark`).map(e=>({key:e.id,label:`${e.label} (custom)`})).concat(_h.filter(e=>e.mode===`dark`))},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.key),t})()})),r.addEventListener(`change`,e=>{Re(e.currentTarget.value),localStorage.setItem(`teapot.theme.light`,e.currentTarget.value)}),L(r,A(j,{get each(){return Ae().filter(e=>e.mode===`light`).map(e=>({key:e.id,label:`${e.label} (custom)`})).concat(_h.filter(e=>e.mode===`light`))},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>n.value=Fe()),y(()=>r.value=Le()),e}}),Ke),L(Ve,A(j,{each:[{mode:`dark`,title:`dark themes`},{mode:`light`,title:`light themes`}],children:e=>A(M,{get when(){return[...Ae(),..._h].some(t=>t.mode===e.mode)},get children(){return[(()=>{var t=Am();return L(t,()=>e.title),t})(),(()=>{var t=jm();return L(t,A(j,{get each(){return Ae().filter(t=>t.mode===e.mode)},children:e=>(()=>{var t=Mm(),n=t.firstChild,r=n.nextSibling,i=r.firstChild;return t.$$click=()=>Ce(e.id,e.mode),L(n,A(eg,{get palette(){return e.palette},get backgroundImage(){return e.backgroundImage},get surfaceAlpha(){return e.surfaceAlpha},get backgroundDim(){return e.backgroundDim}})),L(r,()=>e.label,i),y(n=>{var r=`themecard`+(we(e.id)?` on`:``),i=`${e.label} (custom)${e.backgroundImage?` · with a background image`:``}`,a=we(e.id);return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-pressed`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}),null),L(t,A(j,{get each(){return _h.filter(t=>t.mode===e.mode)},children:e=>(()=>{var t=Nm(),n=t.firstChild,r=n.nextSibling;return t.$$click=()=>Ce(e.key,e.mode),L(n,A(eg,{get palette(){return Be(e.key)}})),L(r,()=>e.label),y(n=>{var r=`themecard`+(we(e.key)?` on`:``),i=`${e.label} (${e.mode})`,a=we(e.key);return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-pressed`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}),null),t})()]}})}),null),L(Ve,A(tg,{themes:Ae,get activeId(){return je()},get paintedId(){return e.theme.paintedId()},onChange:e=>{let t=Sn(e),n=e;if(!t.ok){let t=e.map(e=>e.backgroundImage?{...e,backgroundImage:void 0,backgroundDim:void 0,surfaceAlpha:void 0,backgroundImageBytes:void 0}:e),r=Sn(t);if(r.ok)n=t,Q(`storage was full — saved without the background image(s)`);else{Q(r.error??`could not save theme`);return}}ze(n);let r=e=>n.some(t=>t.id===e)||_h.some(t=>t.key===e);r(je())||(Me(`dark`),localStorage.setItem(`teapot.theme`,`dark`)),r(Fe())||(Ie(`dark`),localStorage.setItem(`teapot.theme.dark`,`dark`)),r(Le())||(Re(`light`),localStorage.setItem(`teapot.theme.light`,`light`))},onPick:e=>{let t=Ae().find(t=>t.id===e)?.mode??_h.find(t=>t.key===e)?.mode??`dark`,n=yt(Ne(),t);n.slot===`dark`?Ie(e):n.slot===`light`?Re(e):Me(e),localStorage.setItem(n.key,e)}}),null),L(Je,A(og,{label:`progress interval (min)`,get value(){return l()},onValue:e=>u(e),hint:`how often the harness asks for a progress report`}),Ye),L(Je,A(og,{label:`progress min chars`,get value(){return d()},onValue:e=>f(e),hint:`progress prompts wait for this much real output`}),Ye),Xe.$$input=e=>m(e.currentTarget.value===``?null:Number(e.currentTarget.value)),L(Je,A(og,{label:`context window (k tok)`,get value(){return h()},onValue:e=>g(e),hint:`model's real window — 0/blank hides the % gauge`}),null),L(Je,A(og,{label:`max spawn depth`,get value(){return _()},onValue:e=>x(e),hint:`sub-agent nesting limit (0 = no spawning)`}),null),Ze.addEventListener(`change`,e=>ee(e.currentTarget.checked)),L(Qe,A(M,{get when(){return ne().length>0},get fallback(){return Pm()},get children(){return A(xe,{get each(){return ne()},children:(e,t)=>{let n=()=>de()[e().name],r=e=>w(ne().map((n,r)=>r===t?{...n,...e}:n));return(()=>{var i=Gm(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.firstChild,u=c.nextSibling,d=a.nextSibling,f=d.firstChild,p=d.nextSibling,m=p.firstChild,h=m.firstChild,g=p.nextSibling,_=g.firstChild;return o.$$input=e=>r({name:e.currentTarget.value}),s.$$input=e=>r({url:e.currentTarget.value}),l.addEventListener(`change`,e=>r({enabled:e.currentTarget.checked})),u.$$click=()=>w(ne().filter((e,n)=>n!==t)),f.addEventListener(`change`,e=>r({transport:e.currentTarget.value})),L(d,A(M,{get when(){return e().transport===`stdio`},get children(){return[(()=>{var t=Fm();return t.$$input=e=>r({command:e.currentTarget.value}),y(()=>t.value=e().command??``),t})(),(()=>{var t=Im();return t.$$input=e=>r({args:e.currentTarget.value.split(` `).filter(Boolean)}),y(()=>t.value=(e().args??[]).join(` `)),t})()]}}),null),m.addEventListener(`change`,e=>{let n=e.currentTarget.value;if(D(e=>({...e,[t]:n})),n===`none`)r({headers:void 0});else if(n===`bearer`){let e=oe()[t]??``;r({headers:e?{Authorization:`Bearer ${e}`}:void 0})}else if(n===`header`){let e=ce()[t]??``,n=oe()[t]??``;r({headers:e&&n?{[e]:n}:void 0})}}),L(m,A(M,{get when(){return me(String(e().name??``))},children:e=>(()=>{var t=Km();return L(t,()=>e().authorized?`OAuth — authorized`:`OAuth — authorization needed`),t})()}),h),L(p,A(M,{get when(){return E()[t]===`bearer`},get children(){var e=Lm();return e.$$input=e=>{let n=e.currentTarget.value;se(e=>({...e,[t]:n})),r({headers:n?{Authorization:`Bearer ${n}`}:void 0})},y(()=>e.value=oe()[t]??``),e}}),null),L(p,A(M,{get when(){return E()[t]===`header`},get children(){return[(()=>{var e=Rm();return e.$$input=e=>{let n=e.currentTarget.value;le(e=>({...e,[t]:n}));let i=oe()[t]??``;r({headers:n&&i?{[n]:i}:void 0})},y(()=>e.value=ce()[t]??``),e})(),(()=>{var e=zm();return e.$$input=e=>{let n=e.currentTarget.value;se(e=>({...e,[t]:n}));let i=ce()[t]??``;r({headers:i&&n?{[i]:n}:void 0})},y(()=>e.value=oe()[t]??``),e})()]}}),null),L(i,A(M,{get when(){return E()[t]===`json`},get children(){var e=Bm(),n=e.firstChild;return n.$$input=e=>{let n=e.currentTarget.value;if(T(e=>({...e,[t]:n})),!n.trim())r({headers:void 0});else try{let e=JSON.parse(n);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`not an object`);r({headers:e}),ae(e=>({...e,[t]:``}))}catch{ae(e=>({...e,[t]:`must be a JSON object — not applied`}))}},y(()=>n.value=re()[t]??``),e}}),g),_.$$click=async()=>{let e=ne()[t];if(!e.name){O(e=>({...e,[t]:{kind:`err`,text:`give it a name first`}}));return}O(e=>({...e,[t]:{kind:`testing`,text:`connecting…`}}));let n=await $(`/api/mcp/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}).catch(()=>null);O(e=>({...e,[t]:n?.ok?{kind:`ok`,text:`${n.tools?.length??0} tool${n.tools?.length===1?``:`s`}`,tools:n.tools??[]}:{kind:`err`,text:n?.error??`no response`,...n?.needsOAuth?{needsOAuth:!0}:{}}})),n?.ok||await ge(e.name)},L(g,A(M,{get when(){return N(()=>!!fe()[String(e().name??``).trim()]?.required)()&&!fe()[String(e().name??``).trim()]?.authorized},get children(){var n=Vm();return n.$$click=()=>void _e(t,e()),n}}),null),L(g,A(M,{get when(){return fe()[String(e().name??``).trim()]?.authorized},get children(){return[Hm(),(()=>{var n=Um();return n.$$click=async()=>{await $(`/api/mcp/oauth/disconnect`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e().name})}).catch(()=>{}),await ge(e().name),O(e=>({...e,[t]:{kind:`ok`,text:`disconnected`}}))},n})()]}}),null),L(g,A(M,{get when(){return n()},get children(){var e=Id();return L(e,(()=>{var e=N(()=>n()?.status===`connected`);return()=>e()?`● ${n()?.tools} tools`:N(()=>n()?.status===`error`)()?`● error`:n()?.status===`disabled`?`● off`:`● idle`})()),y(t=>{var r=`mcpstate `+(n()?.status??``),i=n()?.lastError??``;return r!==t.e&&I(e,t.e=r),i!==t.t&&F(e,`title`,t.t=i),t},{e:void 0,t:void 0}),e}}),null),L(i,A(M,{get when(){return ie()[t]},get children(){var e=Wm();return L(e,()=>ie()[t]),e}}),null),L(i,A(M,{get when(){return ue()[t]},children:e=>(()=>{var t=Ym(),n=t.firstChild,r=n.firstChild;return L(r,()=>e().text),L(n,A(M,{get when(){return e().needsOAuth},get children(){return qm()}}),null),L(t,A(M,{get when(){return(e().tools?.length??0)>0},get children(){var t=Jm();return L(t,A(j,{get each(){return e().tools??[]},children:e=>(()=>{var t=Zm(),n=t.firstChild;return L(n,()=>e.name),L(t,A(M,{get when(){return e.description},get children(){var t=Xm();return L(t,()=>e.description),t}}),null),y(()=>F(t,`title`,e.description??``)),t})()})),t}}),null),y(()=>I(t,`mcpresult `+(e().kind===`err`?`err`:`ok`))),t})()}),null),y(()=>o.value=e().name),y(()=>s.value=e().url??``),y(()=>l.checked=e().enabled!==!1),y(()=>f.value=e().transport??`http`),y(()=>m.value=me(String(e().name??``))?`oauth`:E()[t]??`none`),i})()}})}}),$e),$e.$$click=()=>w([...ne(),{name:``,url:``,transport:`http`,enabled:!0}]),L(et,A(M,{get when(){return C().length>0},get children(){return A(xe,{get each(){return C()},children:(e,t)=>(()=>{var n=Qm(),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=>te(C().map((n,r)=>r===t?{...n,id:e.currentTarget.value}:n)),a.$$input=e=>te(C().map((n,r)=>r===t?{...n,agent:e.currentTarget.value}:n)),o.$$input=e=>te(C().map((n,r)=>r===t?{...n,schedule:e.currentTarget.value}:n)),c.addEventListener(`change`,e=>te(C().map((n,r)=>r===t?{...n,forked:e.currentTarget.checked}:n))),l.$$click=()=>te(C().filter((e,n)=>n!==t)),u.$$input=e=>te(C().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})()})}}),tt),tt.$$click=()=>te([...C(),{id:``,agent:ke()[0]??``,schedule:`every 30m`,prompt:``}]),L(nt,A(M,{get when(){return De().length>0},get fallback(){return $m()},get children(){return A(j,{get each(){return De()},children:t=>(()=>{var n=eh(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=a.nextSibling,c=r.nextSibling,l=c.nextSibling;return L(i,()=>t.id),L(a,()=>t.sessions,o),L(a,()=>t.sessions===1?``:`s`,null),L(a,(()=>{var e=N(()=>(t.subs??0)>0);return()=>e()?` · +${t.subs} sub-agent${t.subs===1?``:`s`} (restored together)`:``})(),null),L(a,(()=>{var e=N(()=>!!t.archivedAt);return()=>e()?` · archived ${zh(new Date(t.archivedAt).toISOString())}`:``})(),null),L(s,()=>t.workspace),c.$$click=async()=>{let n=await $(`/api/agents/${t.id}/restore`,{method:`POST`}).catch(()=>null);await Ee(),e.onSaved();let r=(n?.ids?.length??1)-1;Q((n?.live===!1?`restored ${t.id} — it could not be started (check its provider)`:`restored ${t.id}`)+(r>0?` + ${r} sub-agent${r===1?``:`s`}`:``))},l.$$click=async()=>{confirm(`PERMANENTLY DELETE ${t.id}?\n\n${t.sessions} session${t.sessions===1?``:`s`} of history will be erased from disk along with the config entry. This cannot be undone — archiving was the reversible option.`)&&(await $(`/api/agents/${t.id}/purge`,{method:`DELETE`}).catch(()=>{}),await Ee(),e.onSaved(),Q(`deleted ${t.id} for good`))},y(()=>F(s,`title`,t.workspace)),n})()})}}),null),L(rt,A(j,{get each(){return e.cfg.agents??[]},children:e=>(()=>{var t=nh(),n=t.firstChild,r=n.nextSibling;return L(n,()=>e.id),L(r,()=>e.workspace),L(t,A(M,{get when(){return e.parent},get children(){var t=th();return t.firstChild,L(t,()=>e.parent,null),t}}),null),t})()}),null),L(at,()=>e.cfg.version??`unknown`,null),ot.$$click=async e=>{try{ye(``);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=null,i=!1;for(let e=0;e<120&&!i;e++){await new Promise(e=>setTimeout(e,1e3));try{let e=await $(`/api/version`);if(!e.version)continue;r===null&&(r=e.uptimeSeconds??null),(e.version!==`0.36.8`||typeof e.uptimeSeconds==`number`&&r!==null&&e.uptimeSeconds<r)&&(i=!0,window.location.reload())}catch{}}if(!i)throw Error(`restart timeout — new server did not come up`)}catch(e){ye(e.message)}finally{e.currentTarget.disabled=!1,e.currentTarget.textContent=`update & restart`}},L(lt,(()=>{var t=N(()=>!!e.features);return()=>t()?N(()=>!!e.features.imageResize.available)()?`on — ${e.features.imageResize.tool}, long edge ≤ ${e.features.imageResize.maxEdge}px`:`off — no ffmpeg / ImageMagick found; uploads are served as-is`:`checking…`})()),L(ut,(()=>{var t=N(()=>!!e.features);return()=>t()?N(()=>!!e.features.pty.available)()?`on — ${e.features.pty.provider}`:`off — no pty provider; terminals run on plain pipes (no resize)`:`checking…`})()),L(st,A(M,{get when(){return e.skills.length>0},get fallback(){return(()=>{var t=rh();return L(t,()=>e.hasSelection?`this session has no skills yet — the agent saves them with save_skill once a procedure proves itself`:`select a session to see the skills available to it`),t})()},get children(){var t=Cm();return L(t,A(j,{get each(){return e.skills},children:t=>{let[n,r]=v(!1),[i,a]=v(null),[o,s]=v(``),c=async()=>{if(n())return r(!1);if(r(!0),i()===null&&e.agentId)try{let n=await $(`/api/agents/${e.agentId}/skills/${encodeURIComponent(t.name)}`);a(String(n.text??``))}catch(e){s(e.message)}};return(()=>{var e=ah(),r=e.firstChild,a=r.firstChild,s=a.nextSibling,l=s.nextSibling;return r.$$click=c,L(a,()=>n()?`▾`:`▸`),L(s,()=>t.name),L(l,()=>t.description),L(e,A(M,{get when(){return n()},get children(){return A(M,{get when(){return i()!==null},get fallback(){return(()=>{var e=oh();return L(e,()=>o()||`loading…`),e})()},get children(){var e=ih();return y(()=>e.innerHTML=ch(String(i()??``))),e}})}}),null),y(()=>e.classList.toggle(`open`,!!n())),e})()}})),t}}),null),L(ft,A(M,{get when(){return ve()},get children(){var e=Fp();return L(e,ve),e}}),pt),L(pt,(()=>{var e=N(()=>He()===`saving`);return()=>e()?`saving…`:N(()=>He()===`saved`)()?`✓ saved`:He()===`error`?`✕ failed`:`save settings`})()),y(e=>{var t=be()!==`providers`,n=be()!==`appearance`,r=be()!==`runtime`,i=be()!==`mcp`,a=be()!==`tasks`,o=be()!==`archive`,s=be()!==`agents`,c=be()!==`update`,l=be()!==`skills`,u=be()!==`help`,d=He()===`saved`,f=He()===`error`,p=He()===`saving`;return t!==e.e&&pe.classList.toggle(`hide`,e.e=t),n!==e.t&&Ve.classList.toggle(`hide`,e.t=n),r!==e.a&&qe.classList.toggle(`hide`,e.a=r),i!==e.o&&Qe.classList.toggle(`hide`,e.o=i),a!==e.i&&et.classList.toggle(`hide`,e.i=a),o!==e.n&&nt.classList.toggle(`hide`,e.n=o),s!==e.s&&rt.classList.toggle(`hide`,e.s=s),c!==e.h&&it.classList.toggle(`hide`,e.h=c),l!==e.r&&st.classList.toggle(`hide`,e.r=l),u!==e.d&&dt.classList.toggle(`hide`,e.d=u),d!==e.l&&pt.classList.toggle(`saved`,e.l=d),f!==e.u&&pt.classList.toggle(`error`,e.u=f),p!==e.c&&(pt.disabled=e.c=p),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0}),y(()=>Te.value=i()),y(()=>We.checked=Ne()),y(()=>Xe.value=p()??``),y(()=>Ze.checked=S()),t}})}Te([`click`,`pointerdown`,`dblclick`,`input`,`keydown`]),we(()=>A(Eh,{}),document.getElementById(`root`));export{ku as t};
|
|
31
|
-
//# sourceMappingURL=index-
|
|
30
|
+
Cancel = keep editing your copy`)?(de(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{fe(!1)}}},ve=e=>!e.binary&&!e.truncated,ye=(e,t)=>[(()=>{var n=nm(),r=n.firstChild,a=r.nextSibling;return n.$$click=()=>e.dir?void oe(e):void ge(e,`code`),L(r,(()=>{var t=N(()=>!!e.dir);return()=>t()?i().has(e.path)?`▾`:`▸`:Xh(e.name)})()),L(a,()=>e.name),L(n,A(M,{get when(){return N(()=>!e.dir)()&&e.size!==void 0},get children(){var t=tm();return L(t,()=>Bh(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&&I(n,r.e=i),r.t=De(n,a,r.t),o!==r.a&&F(n,`title`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})(),A(M,{get when(){return N(()=>!!e.dir)()&&i().has(e.path)},get children(){return A(j,{get each(){return(n().get(e.path)??[]).filter(te)},children:e=>ye(e,t+1)})}})],be=()=>e.workspace.split(`/`).filter(Boolean).pop()??e.workspace,[xe,Se]=v(!1),Ce=async()=>{if(!xe()){Se(!0);try{let e=[``,...i()],t=await Promise.all(e.map(async e=>({p:e,rows:await ae(e,ne())})));for(let{p:e,rows:n}of t)n&&E(e,n)}finally{Se(!1)}}};return[(()=>{var e=rm(),t=e.firstChild.nextSibling;return t.firstChild,L(t,be,null),L(e,A(Uh,{class:`filetoggle`,get icon(){return xe()?`…`:`⟳`},title:`refresh the tree (root + expanded folders) — open popups are kept`,onClick:()=>void Ce()}),null),L(e,A(Uh,{class:`filetoggle`,style:`margin-left:auto`,get icon(){return N(()=>x()===`hide`)()?`🙈`:x()===`dim`?`👁`:`✨`},get title(){return`gitignored files: ${x()} — click to cycle (dim → hidden → shown)`},onClick:ee}),null),L(e,A(Uh,{class:`filetoggle`,get icon(){return ne()?`◉.`:`○.`},get title(){return ne()?`dotfiles shown — click to hide`:`dotfiles hidden — click to show`},onClick:re}),null),e})(),(()=>{var e=im();return L(e,A(M,{get when(){return(n().get(``)??[]).length>0},get fallback(){return(()=>{var e=am();return L(e,()=>g()||`empty workspace`),e})()},get children(){return A(j,{get each(){return(n().get(``)??[]).filter(te)},children:e=>ye(e,0)})}})),e})(),A(M,{get when(){return o()},children:t=>A(Gh,{get title(){return`🗂 ${t().path}`},onClose:()=>{me++,c(null),f(null)},get children(){return A(M,{get when(){return u()},get fallback(){return[(()=>{var e=um(),n=e.firstChild;return L(e,A(M,{get when(){return N(()=>!!pe(t().path))()&&!t().binary},get children(){var e=cm();return e.$$click=()=>h(`md`),y(()=>I(e,p()===`md`?`on`:``)),e}}),n),n.$$click=()=>{h(`code`),se()||he({path:t().path,content:t().content,truncated:t().truncated})},L(e,A(M,{get when(){return ve(t())},get children(){var e=lm();return e.$$click=()=>h(`edit`),y(()=>I(e,p()===`edit`?`on`:``)),e}}),null),y(()=>I(n,p()===`code`?`on`:``)),e})(),A(M,{get when(){return!t().binary},get fallback(){return fm()},get children(){return A(M,{get when(){return p()===`edit`},get fallback(){return A(M,{get when(){return N(()=>p()===`md`)()&&pe(t().path)},get fallback(){return A(ig,{get path(){return t().path},get content(){return t().content},get html(){return se()},get pending(){return le()},get truncated(){return!!t().truncated}})},get children(){var e=pm();return y(()=>e.innerHTML=Le(t().content)),e}})},get children(){var e=dm(),n=e.firstChild,r=n.nextSibling.firstChild,i=r.firstChild,a=r.nextSibling;return n.$$input=e=>de(e.currentTarget.value),F(n,`spellcheck`,!1),L(r,()=>Bh(O().length),i),a.$$click=()=>void _e(),L(a,()=>k()?`saving…`:`💾 save`),y(()=>a.disabled=k()||O()===t().content),y(()=>n.value=O()),e}})}})]},get children(){var t=sm(),n=t.firstChild,r=n.firstChild;return L(t,A(M,{get when(){return u().kind===`image`},get fallback(){return A(M,{get when(){return u().kind===`video`},get fallback(){return(()=>{var t=hm();return y(()=>F(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t})()},get children(){var t=mm();return y(()=>F(t,`src`,`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`)),t}})},get children(){var t=om();return y(n=>{var r=`/api/agents/${e.agentId}/raw?path=${encodeURIComponent(u().path)}`,i=u().path.split(`/`).pop();return r!==n.e&&F(t,`src`,n.e=r),i!==n.t&&F(t,`alt`,n.t=i),n},{e:void 0,t:void 0}),t}}),n),L(n,()=>u().kind,r),t}})}})})]}function ig(e){return[A(M,{get when(){return e.html},get fallback(){return N(()=>!!e.pending)()?(()=>{var t=vm(),n=t.firstChild.nextSibling;return n.nextSibling,L(t,()=>e.path.split(`/`).pop(),n),t})():(()=>{var t=ym();return L(t,()=>e.content),t})()},get children(){var t=gm();return y(()=>t.innerHTML=e.html),t}}),A(M,{get when(){return e.truncated},get children(){return _m()}})]}var ag=[{key:`openrouter`,label:`OpenRouter`,url:`https://openrouter.ai/api/v1`,model:``,hint:`400+ models behind one key — teapot sends app-attribution headers automatically`},{key:`orcarouter`,label:`OrcaRouter`,url:`https://api.orcarouter.ai/v1`,model:``,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:``,hint:`your account's models — pick from the list once the endpoint answers`},{key:`opencode-go`,label:`OpenCode Go`,url:`https://opencode.ai/zen/go/v1`,model:``,hint:`OpenCode's open-model subscription — teapot sends the required x-opencode-session header; choose a chat/completions model`},{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)`}];function og(e){return(()=>{var t=bm(),n=t.firstChild;return L(t,()=>e.label,n),n.$$input=t=>e.onValue(Number(t.currentTarget.value)),y(()=>F(t,`title`,e.hint)),y(()=>n.value=e.value),t})()}function sg(e){let t=(e,t)=>{let n=Array.isArray(t?.apiKeys)&&t.apiKeys.length?t.apiKeys.filter(e=>typeof e==`string`&&e.trim()):t?.apiKey?[String(t.apiKey)]:[``];return{name:e,baseUrl:t?.baseUrl??``,apiKeys:n.length?n:[``],model:t?.model??``}},[n,r]=v(Object.entries(e.cfg.providers??{}).map(([e,n])=>t(e,n))),[i,a]=v(e.cfg.defaultProvider??``),o=()=>e.cfg.defaultProvider??``,s=()=>{let e=[...new Set(n().map(e=>e.name.trim()).filter(Boolean))],t=i();return t&&!e.includes(t)&&e.push(t),e},c=()=>{let e=i();return e?n().some(t=>t.name.trim()===e)?``:e:``},[l,u]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[d,f]=v(e.cfg.progressMinChars??4e3),[p,m]=v(e.cfg.contextTokenBudget==null?null:Math.round(e.cfg.contextTokenBudget/1e3)),[h,g]=v(e.cfg.contextWindowTokens?Math.round(e.cfg.contextWindowTokens/1e3):0),[_,x]=v(e.cfg.maxSpawnDepth??3),[S,ee]=v(!!e.cfg.shortContext),[C,te]=v((e.cfg.tasks??[]).map(e=>({...e}))),[ne,w]=v((e.cfg.mcpServers??[]).map(e=>({...e}))),[re,T]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>[t,e.headers?JSON.stringify(e.headers):``]))),[ie,ae]=v({}),[E,D]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=e.headers??{},r=Object.keys(n);if(!r.length)return[t,`none`];let i=r.length===1?r[0]:``;return i===`Authorization`&&/^Bearer /i.test(n[i]??``)?[t,`bearer`]:[t,r.length===1?`header`:`json`]}))),[oe,se]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=e.headers??{},r=Object.keys(n);if(r.length!==1)return[t,``];let i=r[0];return[t,i===`Authorization`?(n[i]??``).replace(/^Bearer /i,``):n[i]??``]}))),[ce,le]=v(Object.fromEntries((e.cfg.mcpServers??[]).map((e,t)=>{let n=Object.keys(e.headers??{}),r=n.length===1?n[0]:``;return[t,r&&r!==`Authorization`?r:``]}))),[ue,O]=v({}),[de,k]=v({}),[fe,pe]=v({}),me=e=>{let t=String(e??``).trim();if(!t)return null;let n=fe()[t];return n&&(n.required||n.authorized)?n:null},he=async()=>{let e=await $(`/api/mcp`).catch(()=>null);k(Object.fromEntries((e?.states??[]).map(e=>[e.name,e])))},ge=async e=>{let t=String(e??``).trim();if(!t)return;let n=await $(`/api/mcp/oauth/status?name=${encodeURIComponent(t)}`).catch(()=>null);n&&!n.error&&pe(e=>({...e,[t]:n}))},_e=async(t,n)=>{if(!n.name){O(e=>({...e,[t]:{kind:`err`,text:`give it a name first`}}));return}O(e=>({...e,[t]:{kind:`testing`,text:`discovering the authorization server…`}}));let r=await $(`/api/mcp/oauth/start`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n.name})}).catch(()=>null);if(r?.alreadyAuthorized){O(e=>({...e,[t]:{kind:`ok`,text:`already authorized`}})),await ge(n.name),await he();return}if(!r?.ok||!r.url){O(e=>({...e,[t]:{kind:`err`,text:r?.error??`no response`}})),await ge(n.name);return}window.open(r.url,`_blank`,`noopener`),O(e=>({...e,[t]:{kind:`testing`,text:`waiting for you to finish in the browser…`}}));let i=Date.now()+3e5;for(;Date.now()<i;){await new Promise(e=>setTimeout(e,1e3));let r=await $(`/api/mcp/oauth/status?name=${encodeURIComponent(n.name)}`).catch(()=>null);if(r&&!r.error){if(pe(e=>({...e,[t]:r})),r.authorized){O(e=>({...e,[t]:{kind:`ok`,text:`authorized — the tools are available now`}})),await he(),e.onSaved();return}if(r.flow?.phase===`error`){O(e=>({...e,[t]:{kind:`err`,text:r.flow.message??r.lastError??`authorization failed`}}));return}}}O(e=>({...e,[t]:{kind:`err`,text:`authorization timed out`}}))};b(()=>{be()===`mcp`&&(he(),ne().forEach((e,t)=>{e.name&&ge(e.name)}))});let[ve,ye]=v(``),[be,Se]=v(`providers`),Ce=(t,n)=>{let{slot:r}=yt(e.theme.auto(),n);r===`dark`?e.theme.setDark(t):r===`light`?e.theme.setLight(t):e.theme.setActive(t)},we=t=>bt({auto:e.theme.auto(),fixed:e.theme.activeId(),dark:e.theme.dark(),light:e.theme.light(),prefersLight:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: light)`).matches})===t,[P,Te]=v([]),Ee=async()=>{let e=await $(`/api/archived`).catch(()=>null);Te(e?.agents??[])},De=()=>P().filter(e=>!e.parent);b(()=>{be()===`archive`&&Ee()});let Oe=[{key:`providers`,label:`🧦 providers`,hint:`endpoints, API keys, default models`},{key:`appearance`,label:`🎨 appearance`,hint:`theme, custom palettes, background image`},{key:`runtime`,label:`⚙️ runtime`,hint:`context budget, retries, spawn depth`},{key:`tasks`,label:`⏰ scheduled tasks`,hint:`cron prompts run against an agent`},{key:`mcp`,label:`🔌 MCP servers`,hint:`external tool servers exposed to every agent`},{key:`archive`,label:`🗄 archive`,hint:`agents you put away — restore or delete for good`},{key:`agents`,label:`👥 agents`,hint:`what exists (read-only)`},{key:`update`,label:`⬆️ live update`,hint:`restart onto a newer build`},{key:`skills`,label:`🧠 skills`,hint:`reusable playbooks available to the selected session`},{key:`help`,label:`❔ help`,hint:`keyboard shortcuts and what each toggle does`}],ke=()=>(e.cfg.agents??[]).map(e=>e.id),Ae=()=>e.theme.themes(),je=()=>e.theme.activeId(),Me=t=>e.theme.setActive(t),Ne=()=>e.theme.auto(),Pe=t=>e.theme.setAuto(t),Fe=()=>e.theme.dark(),Ie=t=>e.theme.setDark(t),Le=()=>e.theme.light(),Re=t=>e.theme.setLight(t),ze=t=>e.theme.setThemes(t),Be=e=>vn[e]??_n,Ve=()=>{let e={};for(let t of n()){if(!t.name.trim())return ye(`provider name is required`),null;if(t.baseUrl&&!/^https?:\/\//.test(t.baseUrl))return ye(`provider ${t.name}: baseUrl must start with http(s)://`),null;let n=t.apiKeys.map(e=>e.trim()).filter(Boolean);e[t.name.trim()]={baseUrl:t.baseUrl,...n.length?{apiKeys:n,apiKey:n[0]}:{},...t.model?{model:t.model}:{}}}return e},[He,Ue]=v(`idle`),We=e=>{ye(e),Ue(e=>e===`saving`?`idle`:e)},Ge=async t=>{t.preventDefault(),ye(``),Ue(`saving`);let n=Ve();if(!n)return Ue(`idle`);let r=C().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 r){if(!e.agent)return We(`task "${e.id}": agent is required`);if(!e.schedule?.trim())return We(`task "${e.id}": schedule is required`)}let a=[],o=new Set;for(let e of ne()){let t=String(e.name??``).trim(),n=String(e.url??``).trim(),r=e.transport??`http`,i=String(e.command??``).trim();if(t||n||i){if(!t)return We(`MCP: a server needs a name`);if(o.has(t))return We(`MCP: two servers are named "${t}"`);if(o.add(t),r===`stdio`?!i:!n)return We(`MCP "${t}": ${r===`stdio`?`a command is`:`a url is`} required`);a.push({name:t,transport:r,enabled:e.enabled!==!1,...n?{url:n}:{},...r===`stdio`?{command:i,...e.args?.length?{args:e.args}:{}}:{},...e.headers&&Object.keys(e.headers).length?{headers:e.headers}:{}})}}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:n,defaultProvider:i()||void 0,progressIntervalMs:Math.max(1,l())*6e4,progressMinChars:Math.max(100,d()),...p()==null?{}:{contextTokenBudget:Math.max(1,p())*1e3},...h()>0?{contextWindowTokens:h()*1e3}:{},maxSpawnDepth:Math.max(0,_()),shortContext:S(),tasks:r,mcpServers:a})}),await he(),await Promise.all(a.map((e,t)=>e.name?ge(e.name):Promise.resolve())),setTimeout(()=>{he(),a.forEach((e,t)=>{e.name&&ge(e.name)})},1200),e.onSaved();let t=new Set(a.map(e=>e.name).filter(Boolean)),o=ne().filter(e=>{let n=String(e.name??``).trim();return t.has(n)&&fe()[n]?.required&&!fe()[n]?.authorized}).filter(t=>!e.announcedOAuth.has(String(t.name??``)));if(o.length>0){for(let t of o)e.announcedOAuth.add(String(t.name??``));Q(`${o.map(e=>String(e.name??``).trim()).filter(Boolean).join(`, `)||`a saved MCP server`} needs authorization — 🔑 authorize in MCP servers`)}Ue(`saved`),setTimeout(()=>{Ue(`idle`),e.onClose()},400)}catch(e){ye(e.message),Ue(`error`),setTimeout(()=>Ue(`idle`),1600)}};return A(Gh,{title:`settings`,get onClose(){return e.onClose},get children(){var t=wm(),b=t.firstChild,k=b.firstChild,pe=k.nextSibling.firstChild,he=pe.firstChild.nextSibling,P=he.nextSibling;P.firstChild;var Te=P.nextSibling.firstChild.firstChild.nextSibling;Te.firstChild;var Ve=pe.nextSibling,Ue=Ve.firstChild.nextSibling,We=Ue.firstChild.firstChild.nextSibling,Ke=Ue.nextSibling,qe=Ve.nextSibling,Je=qe.firstChild.nextSibling,Ye=Je.firstChild,Xe=Ye.firstChild.nextSibling,Ze=Je.nextSibling.firstChild,Qe=qe.nextSibling,$e=Qe.firstChild.nextSibling.nextSibling,et=Qe.nextSibling,tt=et.firstChild.nextSibling,nt=et.nextSibling;nt.firstChild;var rt=nt.nextSibling;rt.firstChild;var it=rt.nextSibling,at=it.firstChild.nextSibling.firstChild;at.firstChild;var ot=at.nextSibling,st=it.nextSibling,ct=st.firstChild.nextSibling.firstChild,lt=ct.firstChild.nextSibling,ut=ct.nextSibling.firstChild.nextSibling,dt=st.nextSibling,ft=b.nextSibling,pt=ft.firstChild;return t.addEventListener(`submit`,Ge),L(k,A(j,{each:Oe,children:e=>(()=>{var t=Tm(),n=t.firstChild;return t.$$click=()=>Se(e.key),L(n,()=>e.label),y(n=>{var r=`cfgmenu-item`+(be()===e.key?` on`:``),i=e.hint,a=be()===e.key?`page`:void 0;return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-current`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),L(pe,A(xe,{get each(){return n()},children:(e,t)=>(()=>{var i=Em(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.firstChild;return a.$$input=e=>r(n().map((n,r)=>r===t?{...n,name:e.currentTarget.value}:n)),o.$$input=e=>r(n().map((n,r)=>r===t?{...n,baseUrl:e.currentTarget.value}:n)),s.$$input=e=>r(n().map((n,r)=>r===t?{...n,model:e.currentTarget.value}:n)),c.$$click=()=>r(n().filter((e,n)=>n!==t)),L(l,A(j,{get each(){return e().apiKeys},children:(i,a)=>(()=>{var o=Om(),s=o.firstChild;return s.$$input=e=>r(n().map((n,r)=>r===t?{...n,apiKeys:n.apiKeys.map((t,n)=>n===a()?e.currentTarget.value:t)}:n)),s.value=i,L(o,A(M,{get when(){return e().apiKeys.length>1},get children(){var e=Dm();return e.$$click=()=>r(n().map((e,n)=>n===t?{...e,apiKeys:e.apiKeys.filter((e,t)=>t!==a())}:e)),e}}),null),y(()=>F(s,`placeholder`,a()===0?`api key`:`api key (backup)`)),o})()}),u),u.$$click=()=>r(n().map((e,n)=>n===t?{...e,apiKeys:[...e.apiKeys,``]}:e)),y(()=>a.value=e().name),y(()=>o.value=e().baseUrl),y(()=>s.value=e().model),i})()}),he),he.$$click=()=>r([...n(),{name:``,baseUrl:``,apiKeys:[``],model:``}]),L(P,A(j,{each:ag,children:e=>(()=>{var t=km();return t.firstChild,t.$$click=()=>{let t=n().filter(t=>t.name!==e.key);r([...t,{name:e.key,baseUrl:e.url,apiKeys:[``],model:e.model}]),i()||a(e.key)},L(t,()=>e.label,null),y(()=>F(t,`title`,`fill a ${e.label} row — ${e.url}${e.model?` (model: ${e.model})`:``}`)),t})()}),null),Te.addEventListener(`change`,e=>a(e.currentTarget.value)),L(Te,A(j,{get each(){return s()},children:e=>(()=>{var t=tf();return t.value=e,L(t,e),t})()}),null),L(pe,A(M,{get when(){return c()},get children(){var e=xm(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling;return L(t,c),L(e,()=>c()===o()?` — the dropdown above cannot show it.`:` — it was replaced by your selection.`,n),L(r,c),e}}),null),We.addEventListener(`change`,e=>{Pe(e.currentTarget.checked),localStorage.setItem(`teapot.theme.auto`,e.currentTarget.checked?`1`:`0`)}),L(Ve,A(M,{get when(){return Ne()},get children(){var e=Sm(),t=e.firstChild,n=t.firstChild.nextSibling,r=t.nextSibling.firstChild.nextSibling;return n.addEventListener(`change`,e=>{Ie(e.currentTarget.value),localStorage.setItem(`teapot.theme.dark`,e.currentTarget.value)}),L(n,A(j,{get each(){return Ae().filter(e=>e.mode===`dark`).map(e=>({key:e.id,label:`${e.label} (custom)`})).concat(_h.filter(e=>e.mode===`dark`))},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.key),t})()})),r.addEventListener(`change`,e=>{Re(e.currentTarget.value),localStorage.setItem(`teapot.theme.light`,e.currentTarget.value)}),L(r,A(j,{get each(){return Ae().filter(e=>e.mode===`light`).map(e=>({key:e.id,label:`${e.label} (custom)`})).concat(_h.filter(e=>e.mode===`light`))},children:e=>(()=>{var t=tf();return L(t,()=>e.label),y(()=>t.value=e.key),t})()})),y(()=>n.value=Fe()),y(()=>r.value=Le()),e}}),Ke),L(Ve,A(j,{each:[{mode:`dark`,title:`dark themes`},{mode:`light`,title:`light themes`}],children:e=>A(M,{get when(){return[...Ae(),..._h].some(t=>t.mode===e.mode)},get children(){return[(()=>{var t=Am();return L(t,()=>e.title),t})(),(()=>{var t=jm();return L(t,A(j,{get each(){return Ae().filter(t=>t.mode===e.mode)},children:e=>(()=>{var t=Mm(),n=t.firstChild,r=n.nextSibling,i=r.firstChild;return t.$$click=()=>Ce(e.id,e.mode),L(n,A(eg,{get palette(){return e.palette},get backgroundImage(){return e.backgroundImage},get surfaceAlpha(){return e.surfaceAlpha},get backgroundDim(){return e.backgroundDim}})),L(r,()=>e.label,i),y(n=>{var r=`themecard`+(we(e.id)?` on`:``),i=`${e.label} (custom)${e.backgroundImage?` · with a background image`:``}`,a=we(e.id);return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-pressed`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}),null),L(t,A(j,{get each(){return _h.filter(t=>t.mode===e.mode)},children:e=>(()=>{var t=Nm(),n=t.firstChild,r=n.nextSibling;return t.$$click=()=>Ce(e.key,e.mode),L(n,A(eg,{get palette(){return Be(e.key)}})),L(r,()=>e.label),y(n=>{var r=`themecard`+(we(e.key)?` on`:``),i=`${e.label} (${e.mode})`,a=we(e.key);return r!==n.e&&I(t,n.e=r),i!==n.t&&F(t,`title`,n.t=i),a!==n.a&&F(t,`aria-pressed`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}),null),t})()]}})}),null),L(Ve,A(tg,{themes:Ae,get activeId(){return je()},get paintedId(){return e.theme.paintedId()},onChange:e=>{let t=Sn(e),n=e;if(!t.ok){let t=e.map(e=>e.backgroundImage?{...e,backgroundImage:void 0,backgroundDim:void 0,surfaceAlpha:void 0,backgroundImageBytes:void 0}:e),r=Sn(t);if(r.ok)n=t,Q(`storage was full — saved without the background image(s)`);else{Q(r.error??`could not save theme`);return}}ze(n);let r=e=>n.some(t=>t.id===e)||_h.some(t=>t.key===e);r(je())||(Me(`dark`),localStorage.setItem(`teapot.theme`,`dark`)),r(Fe())||(Ie(`dark`),localStorage.setItem(`teapot.theme.dark`,`dark`)),r(Le())||(Re(`light`),localStorage.setItem(`teapot.theme.light`,`light`))},onPick:e=>{let t=Ae().find(t=>t.id===e)?.mode??_h.find(t=>t.key===e)?.mode??`dark`,n=yt(Ne(),t);n.slot===`dark`?Ie(e):n.slot===`light`?Re(e):Me(e),localStorage.setItem(n.key,e)}}),null),L(Je,A(og,{label:`progress interval (min)`,get value(){return l()},onValue:e=>u(e),hint:`how often the harness asks for a progress report`}),Ye),L(Je,A(og,{label:`progress min chars`,get value(){return d()},onValue:e=>f(e),hint:`progress prompts wait for this much real output`}),Ye),Xe.$$input=e=>m(e.currentTarget.value===``?null:Number(e.currentTarget.value)),L(Je,A(og,{label:`context window (k tok)`,get value(){return h()},onValue:e=>g(e),hint:`model's real window — 0/blank hides the % gauge`}),null),L(Je,A(og,{label:`max spawn depth`,get value(){return _()},onValue:e=>x(e),hint:`sub-agent nesting limit (0 = no spawning)`}),null),Ze.addEventListener(`change`,e=>ee(e.currentTarget.checked)),L(Qe,A(M,{get when(){return ne().length>0},get fallback(){return Pm()},get children(){return A(xe,{get each(){return ne()},children:(e,t)=>{let n=()=>de()[e().name],r=e=>w(ne().map((n,r)=>r===t?{...n,...e}:n));return(()=>{var i=Gm(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.firstChild,u=c.nextSibling,d=a.nextSibling,f=d.firstChild,p=d.nextSibling,m=p.firstChild,h=m.firstChild,g=p.nextSibling,_=g.firstChild;return o.$$input=e=>r({name:e.currentTarget.value}),s.$$input=e=>r({url:e.currentTarget.value}),l.addEventListener(`change`,e=>r({enabled:e.currentTarget.checked})),u.$$click=()=>w(ne().filter((e,n)=>n!==t)),f.addEventListener(`change`,e=>r({transport:e.currentTarget.value})),L(d,A(M,{get when(){return e().transport===`stdio`},get children(){return[(()=>{var t=Fm();return t.$$input=e=>r({command:e.currentTarget.value}),y(()=>t.value=e().command??``),t})(),(()=>{var t=Im();return t.$$input=e=>r({args:e.currentTarget.value.split(` `).filter(Boolean)}),y(()=>t.value=(e().args??[]).join(` `)),t})()]}}),null),m.addEventListener(`change`,e=>{let n=e.currentTarget.value;if(D(e=>({...e,[t]:n})),n===`none`)r({headers:void 0});else if(n===`bearer`){let e=oe()[t]??``;r({headers:e?{Authorization:`Bearer ${e}`}:void 0})}else if(n===`header`){let e=ce()[t]??``,n=oe()[t]??``;r({headers:e&&n?{[e]:n}:void 0})}}),L(m,A(M,{get when(){return me(String(e().name??``))},children:e=>(()=>{var t=Km();return L(t,()=>e().authorized?`OAuth — authorized`:`OAuth — authorization needed`),t})()}),h),L(p,A(M,{get when(){return E()[t]===`bearer`},get children(){var e=Lm();return e.$$input=e=>{let n=e.currentTarget.value;se(e=>({...e,[t]:n})),r({headers:n?{Authorization:`Bearer ${n}`}:void 0})},y(()=>e.value=oe()[t]??``),e}}),null),L(p,A(M,{get when(){return E()[t]===`header`},get children(){return[(()=>{var e=Rm();return e.$$input=e=>{let n=e.currentTarget.value;le(e=>({...e,[t]:n}));let i=oe()[t]??``;r({headers:n&&i?{[n]:i}:void 0})},y(()=>e.value=ce()[t]??``),e})(),(()=>{var e=zm();return e.$$input=e=>{let n=e.currentTarget.value;se(e=>({...e,[t]:n}));let i=ce()[t]??``;r({headers:i&&n?{[i]:n}:void 0})},y(()=>e.value=oe()[t]??``),e})()]}}),null),L(i,A(M,{get when(){return E()[t]===`json`},get children(){var e=Bm(),n=e.firstChild;return n.$$input=e=>{let n=e.currentTarget.value;if(T(e=>({...e,[t]:n})),!n.trim())r({headers:void 0});else try{let e=JSON.parse(n);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`not an object`);r({headers:e}),ae(e=>({...e,[t]:``}))}catch{ae(e=>({...e,[t]:`must be a JSON object — not applied`}))}},y(()=>n.value=re()[t]??``),e}}),g),_.$$click=async()=>{let e=ne()[t];if(!e.name){O(e=>({...e,[t]:{kind:`err`,text:`give it a name first`}}));return}O(e=>({...e,[t]:{kind:`testing`,text:`connecting…`}}));let n=await $(`/api/mcp/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}).catch(()=>null);O(e=>({...e,[t]:n?.ok?{kind:`ok`,text:`${n.tools?.length??0} tool${n.tools?.length===1?``:`s`}`,tools:n.tools??[]}:{kind:`err`,text:n?.error??`no response`,...n?.needsOAuth?{needsOAuth:!0}:{}}})),n?.ok||await ge(e.name)},L(g,A(M,{get when(){return N(()=>!!fe()[String(e().name??``).trim()]?.required)()&&!fe()[String(e().name??``).trim()]?.authorized},get children(){var n=Vm();return n.$$click=()=>void _e(t,e()),n}}),null),L(g,A(M,{get when(){return fe()[String(e().name??``).trim()]?.authorized},get children(){return[Hm(),(()=>{var n=Um();return n.$$click=async()=>{await $(`/api/mcp/oauth/disconnect`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e().name})}).catch(()=>{}),await ge(e().name),O(e=>({...e,[t]:{kind:`ok`,text:`disconnected`}}))},n})()]}}),null),L(g,A(M,{get when(){return n()},get children(){var e=Id();return L(e,(()=>{var e=N(()=>n()?.status===`connected`);return()=>e()?`● ${n()?.tools} tools`:N(()=>n()?.status===`error`)()?`● error`:n()?.status===`disabled`?`● off`:`● idle`})()),y(t=>{var r=`mcpstate `+(n()?.status??``),i=n()?.lastError??``;return r!==t.e&&I(e,t.e=r),i!==t.t&&F(e,`title`,t.t=i),t},{e:void 0,t:void 0}),e}}),null),L(i,A(M,{get when(){return ie()[t]},get children(){var e=Wm();return L(e,()=>ie()[t]),e}}),null),L(i,A(M,{get when(){return ue()[t]},children:e=>(()=>{var t=Ym(),n=t.firstChild,r=n.firstChild;return L(r,()=>e().text),L(n,A(M,{get when(){return e().needsOAuth},get children(){return qm()}}),null),L(t,A(M,{get when(){return(e().tools?.length??0)>0},get children(){var t=Jm();return L(t,A(j,{get each(){return e().tools??[]},children:e=>(()=>{var t=Zm(),n=t.firstChild;return L(n,()=>e.name),L(t,A(M,{get when(){return e.description},get children(){var t=Xm();return L(t,()=>e.description),t}}),null),y(()=>F(t,`title`,e.description??``)),t})()})),t}}),null),y(()=>I(t,`mcpresult `+(e().kind===`err`?`err`:`ok`))),t})()}),null),y(()=>o.value=e().name),y(()=>s.value=e().url??``),y(()=>l.checked=e().enabled!==!1),y(()=>f.value=e().transport??`http`),y(()=>m.value=me(String(e().name??``))?`oauth`:E()[t]??`none`),i})()}})}}),$e),$e.$$click=()=>w([...ne(),{name:``,url:``,transport:`http`,enabled:!0}]),L(et,A(M,{get when(){return C().length>0},get children(){return A(xe,{get each(){return C()},children:(e,t)=>(()=>{var n=Qm(),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=>te(C().map((n,r)=>r===t?{...n,id:e.currentTarget.value}:n)),a.$$input=e=>te(C().map((n,r)=>r===t?{...n,agent:e.currentTarget.value}:n)),o.$$input=e=>te(C().map((n,r)=>r===t?{...n,schedule:e.currentTarget.value}:n)),c.addEventListener(`change`,e=>te(C().map((n,r)=>r===t?{...n,forked:e.currentTarget.checked}:n))),l.$$click=()=>te(C().filter((e,n)=>n!==t)),u.$$input=e=>te(C().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})()})}}),tt),tt.$$click=()=>te([...C(),{id:``,agent:ke()[0]??``,schedule:`every 30m`,prompt:``}]),L(nt,A(M,{get when(){return De().length>0},get fallback(){return $m()},get children(){return A(j,{get each(){return De()},children:t=>(()=>{var n=eh(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=a.nextSibling,c=r.nextSibling,l=c.nextSibling;return L(i,()=>t.id),L(a,()=>t.sessions,o),L(a,()=>t.sessions===1?``:`s`,null),L(a,(()=>{var e=N(()=>(t.subs??0)>0);return()=>e()?` · +${t.subs} sub-agent${t.subs===1?``:`s`} (restored together)`:``})(),null),L(a,(()=>{var e=N(()=>!!t.archivedAt);return()=>e()?` · archived ${zh(new Date(t.archivedAt).toISOString())}`:``})(),null),L(s,()=>t.workspace),c.$$click=async()=>{let n=await $(`/api/agents/${t.id}/restore`,{method:`POST`}).catch(()=>null);await Ee(),e.onSaved();let r=(n?.ids?.length??1)-1;Q((n?.live===!1?`restored ${t.id} — it could not be started (check its provider)`:`restored ${t.id}`)+(r>0?` + ${r} sub-agent${r===1?``:`s`}`:``))},l.$$click=async()=>{confirm(`PERMANENTLY DELETE ${t.id}?\n\n${t.sessions} session${t.sessions===1?``:`s`} of history will be erased from disk along with the config entry. This cannot be undone — archiving was the reversible option.`)&&(await $(`/api/agents/${t.id}/purge`,{method:`DELETE`}).catch(()=>{}),await Ee(),e.onSaved(),Q(`deleted ${t.id} for good`))},y(()=>F(s,`title`,t.workspace)),n})()})}}),null),L(rt,A(j,{get each(){return e.cfg.agents??[]},children:e=>(()=>{var t=nh(),n=t.firstChild,r=n.nextSibling;return L(n,()=>e.id),L(r,()=>e.workspace),L(t,A(M,{get when(){return e.parent},get children(){var t=th();return t.firstChild,L(t,()=>e.parent,null),t}}),null),t})()}),null),L(at,()=>e.cfg.version??`unknown`,null),ot.$$click=async e=>{try{ye(``);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=null,i=!1;for(let e=0;e<120&&!i;e++){await new Promise(e=>setTimeout(e,1e3));try{let e=await $(`/api/version`);if(!e.version)continue;r===null&&(r=e.uptimeSeconds??null),(e.version!==`0.36.9`||typeof e.uptimeSeconds==`number`&&r!==null&&e.uptimeSeconds<r)&&(i=!0,window.location.reload())}catch{}}if(!i)throw Error(`restart timeout — new server did not come up`)}catch(e){ye(e.message)}finally{e.currentTarget.disabled=!1,e.currentTarget.textContent=`update & restart`}},L(lt,(()=>{var t=N(()=>!!e.features);return()=>t()?N(()=>!!e.features.imageResize.available)()?`on — ${e.features.imageResize.tool}, long edge ≤ ${e.features.imageResize.maxEdge}px`:`off — no ffmpeg / ImageMagick found; uploads are served as-is`:`checking…`})()),L(ut,(()=>{var t=N(()=>!!e.features);return()=>t()?N(()=>!!e.features.pty.available)()?`on — ${e.features.pty.provider}`:`off — no pty provider; terminals run on plain pipes (no resize)`:`checking…`})()),L(st,A(M,{get when(){return e.skills.length>0},get fallback(){return(()=>{var t=rh();return L(t,()=>e.hasSelection?`this session has no skills yet — the agent saves them with save_skill once a procedure proves itself`:`select a session to see the skills available to it`),t})()},get children(){var t=Cm();return L(t,A(j,{get each(){return e.skills},children:t=>{let[n,r]=v(!1),[i,a]=v(null),[o,s]=v(``),c=async()=>{if(n())return r(!1);if(r(!0),i()===null&&e.agentId)try{let n=await $(`/api/agents/${e.agentId}/skills/${encodeURIComponent(t.name)}`);a(String(n.text??``))}catch(e){s(e.message)}};return(()=>{var e=ah(),r=e.firstChild,a=r.firstChild,s=a.nextSibling,l=s.nextSibling;return r.$$click=c,L(a,()=>n()?`▾`:`▸`),L(s,()=>t.name),L(l,()=>t.description),L(e,A(M,{get when(){return n()},get children(){return A(M,{get when(){return i()!==null},get fallback(){return(()=>{var e=oh();return L(e,()=>o()||`loading…`),e})()},get children(){var e=ih();return y(()=>e.innerHTML=ch(String(i()??``))),e}})}}),null),y(()=>e.classList.toggle(`open`,!!n())),e})()}})),t}}),null),L(ft,A(M,{get when(){return ve()},get children(){var e=Fp();return L(e,ve),e}}),pt),L(pt,(()=>{var e=N(()=>He()===`saving`);return()=>e()?`saving…`:N(()=>He()===`saved`)()?`✓ saved`:He()===`error`?`✕ failed`:`save settings`})()),y(e=>{var t=be()!==`providers`,n=be()!==`appearance`,r=be()!==`runtime`,i=be()!==`mcp`,a=be()!==`tasks`,o=be()!==`archive`,s=be()!==`agents`,c=be()!==`update`,l=be()!==`skills`,u=be()!==`help`,d=He()===`saved`,f=He()===`error`,p=He()===`saving`;return t!==e.e&&pe.classList.toggle(`hide`,e.e=t),n!==e.t&&Ve.classList.toggle(`hide`,e.t=n),r!==e.a&&qe.classList.toggle(`hide`,e.a=r),i!==e.o&&Qe.classList.toggle(`hide`,e.o=i),a!==e.i&&et.classList.toggle(`hide`,e.i=a),o!==e.n&&nt.classList.toggle(`hide`,e.n=o),s!==e.s&&rt.classList.toggle(`hide`,e.s=s),c!==e.h&&it.classList.toggle(`hide`,e.h=c),l!==e.r&&st.classList.toggle(`hide`,e.r=l),u!==e.d&&dt.classList.toggle(`hide`,e.d=u),d!==e.l&&pt.classList.toggle(`saved`,e.l=d),f!==e.u&&pt.classList.toggle(`error`,e.u=f),p!==e.c&&(pt.disabled=e.c=p),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0}),y(()=>Te.value=i()),y(()=>We.checked=Ne()),y(()=>Xe.value=p()??``),y(()=>Ze.checked=S()),t}})}Te([`click`,`pointerdown`,`dblclick`,`input`,`keydown`]),we(()=>A(Eh,{}),document.getElementById(`root`));export{ku as t};
|
|
31
|
+
//# sourceMappingURL=index-CoH7Vqvo.js.map
|