@timqi/pier 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/web/public/assets/{activity-B89_hH7q.js → activity-DOr8dWeX.js} +1 -1
  2. package/dist/web/public/assets/activity-DOr8dWeX.js.br +0 -0
  3. package/dist/web/public/assets/activity-DOr8dWeX.js.gz +0 -0
  4. package/dist/web/public/assets/{boards-BeKW0ZXK.js → boards-CneyR23E.js} +1 -1
  5. package/dist/web/public/assets/boards-CneyR23E.js.br +0 -0
  6. package/dist/web/public/assets/boards-CneyR23E.js.gz +0 -0
  7. package/dist/web/public/assets/{explorer-DIuMlaV3.js → explorer-D0srXT1c.js} +1 -1
  8. package/dist/web/public/assets/explorer-D0srXT1c.js.br +0 -0
  9. package/dist/web/public/assets/explorer-D0srXT1c.js.gz +0 -0
  10. package/dist/web/public/assets/{index-DzXDXra_.js → index-DbFu15NN.js} +2 -2
  11. package/dist/web/public/assets/index-DbFu15NN.js.br +0 -0
  12. package/dist/web/public/assets/index-DbFu15NN.js.gz +0 -0
  13. package/dist/web/public/assets/{runs-Cwy0mN8i.js → runs-Cv0A-e08.js} +1 -1
  14. package/dist/web/public/assets/runs-Cv0A-e08.js.br +0 -0
  15. package/dist/web/public/assets/runs-Cv0A-e08.js.gz +0 -0
  16. package/dist/web/public/assets/{settings-DzZLmujq.js → settings-VmCjhGBd.js} +1 -1
  17. package/dist/web/public/assets/settings-VmCjhGBd.js.br +0 -0
  18. package/dist/web/public/assets/settings-VmCjhGBd.js.gz +0 -0
  19. package/dist/web/public/assets/{task-runs-BCakxFk8.js → task-runs-CqpTV644.js} +1 -1
  20. package/dist/web/public/assets/task-runs-CqpTV644.js.br +0 -0
  21. package/dist/web/public/assets/task-runs-CqpTV644.js.gz +0 -0
  22. package/dist/web/public/assets/{tasks-BlzEbk11.js → tasks-BffPVgXg.js} +1 -1
  23. package/dist/web/public/assets/tasks-BffPVgXg.js.br +0 -0
  24. package/dist/web/public/assets/tasks-BffPVgXg.js.gz +0 -0
  25. package/dist/web/public/index.html +1 -1
  26. package/dist/web/public/index.html.br +0 -0
  27. package/dist/web/public/index.html.gz +0 -0
  28. package/package.json +1 -1
  29. package/dist/web/public/assets/activity-B89_hH7q.js.br +0 -0
  30. package/dist/web/public/assets/activity-B89_hH7q.js.gz +0 -0
  31. package/dist/web/public/assets/boards-BeKW0ZXK.js.br +0 -0
  32. package/dist/web/public/assets/boards-BeKW0ZXK.js.gz +0 -0
  33. package/dist/web/public/assets/explorer-DIuMlaV3.js.br +0 -0
  34. package/dist/web/public/assets/explorer-DIuMlaV3.js.gz +0 -0
  35. package/dist/web/public/assets/index-DzXDXra_.js.br +0 -0
  36. package/dist/web/public/assets/index-DzXDXra_.js.gz +0 -0
  37. package/dist/web/public/assets/runs-Cwy0mN8i.js.br +0 -0
  38. package/dist/web/public/assets/runs-Cwy0mN8i.js.gz +0 -0
  39. package/dist/web/public/assets/settings-DzZLmujq.js.br +0 -0
  40. package/dist/web/public/assets/settings-DzZLmujq.js.gz +0 -0
  41. package/dist/web/public/assets/task-runs-BCakxFk8.js.br +0 -0
  42. package/dist/web/public/assets/task-runs-BCakxFk8.js.gz +0 -0
  43. package/dist/web/public/assets/tasks-BlzEbk11.js.br +0 -0
  44. package/dist/web/public/assets/tasks-BlzEbk11.js.gz +0 -0
@@ -1,4 +1,4 @@
1
- import{G as e,H as t,O as n,P as r,R as i,S as a,V as o,W as s,Z as c,q as l,v as u}from"./index-DzXDXra_.js";var d=(e,t={})=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n},f=e=>e===null?`-`:o(Date.now()-e),p={light:{edge:`#a3a3a3`,callback:`#0891b2`,message:`#d97706`,scheduler:{fill:`#f5f3ff`,stroke:`#a78bfa`,text:`#5b21b6`},console:{fill:`#eff6ff`,stroke:`#93c5fd`,text:`#1d4ed8`},task:{fill:`#fffbeb`,stroke:`#fbbf24`,text:`#92400e`},process:{fill:`#f5f5f5`,stroke:`#a3a3a3`,text:`#525252`,dash:`4 3`},streaming:{fill:`#ffffff`,stroke:`#10b981`,text:`#262626`},idle:{fill:`#fafafa`,stroke:`#d4d4d4`,text:`#737373`}},dark:{edge:`#7a7a7a`,callback:`#3fc3dd`,message:`#e0a13a`,scheduler:{fill:`#2b2440`,stroke:`#7d63c9`,text:`#c9b8f5`},console:{fill:`#1f2a3d`,stroke:`#4a7fbf`,text:`#a8c8f0`},task:{fill:`#3a2f1c`,stroke:`#b8862a`,text:`#f0d49a`},process:{fill:`#262626`,stroke:`#5c5c5c`,text:`#a3a3a3`,dash:`4 3`},streaming:{fill:`#22302a`,stroke:`#10b981`,text:`#e5e5e5`},idle:{fill:`#212121`,stroke:`#4a4a4a`,text:`#9a9a9a`}}},m=()=>p[document.documentElement.dataset.theme===`dark`?`dark`:`light`];function h(o,p,h){let g=`sessions`,_=`active`,v={sessions:[],runs:[],messages:[]},y=``,b=e(async()=>{let e=_,n=await l(`/api/activity?scope=${e}`,`Failed to load activity`);if(!n.ok){y=``,o.replaceChildren(t(`p`,`p-4 text-[13px] text-red-600`,n.error));return}if(e!==_)return;let r=JSON.stringify(n.value);if(`${e}:${r}`===y)return;y=`${e}:${r}`;let i=n.value;v={...i,sessions:i.sessions.map(e=>({...e,title:c(e.title)}))},x()});function x(){let e=r(n([[`Sessions`,`sessions`],[`Relationships`,`dependencies`]],g,e=>{g=e,x()}),t(`span`,`ml-auto text-[11.5px] text-neutral-400`,`${v.sessions.length} sessions · ${v.runs.length} runs`),n([[`Current`,`active`],[`Last 24h`,`recent`]],_,e=>{_=e,x(),b()})),i=t(`div`,`automation-list min-h-0 flex-1 overflow-auto`);g===`sessions`?S(i):w(i),o.replaceChildren(e,i)}function S(e){let n=document.createElement(`table`);n.className=`w-full table-fixed text-left text-[12.5px]`,n.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase tracking-wide text-neutral-400 shadow-[inset_0_-1px_0_var(--color-neutral-200)]"><tr>
1
+ import{G as e,H as t,O as n,P as r,R as i,S as a,V as o,W as s,Z as c,q as l,v as u}from"./index-DbFu15NN.js";var d=(e,t={})=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n},f=e=>e===null?`-`:o(Date.now()-e),p={light:{edge:`#a3a3a3`,callback:`#0891b2`,message:`#d97706`,scheduler:{fill:`#f5f3ff`,stroke:`#a78bfa`,text:`#5b21b6`},console:{fill:`#eff6ff`,stroke:`#93c5fd`,text:`#1d4ed8`},task:{fill:`#fffbeb`,stroke:`#fbbf24`,text:`#92400e`},process:{fill:`#f5f5f5`,stroke:`#a3a3a3`,text:`#525252`,dash:`4 3`},streaming:{fill:`#ffffff`,stroke:`#10b981`,text:`#262626`},idle:{fill:`#fafafa`,stroke:`#d4d4d4`,text:`#737373`}},dark:{edge:`#7a7a7a`,callback:`#3fc3dd`,message:`#e0a13a`,scheduler:{fill:`#2b2440`,stroke:`#7d63c9`,text:`#c9b8f5`},console:{fill:`#1f2a3d`,stroke:`#4a7fbf`,text:`#a8c8f0`},task:{fill:`#3a2f1c`,stroke:`#b8862a`,text:`#f0d49a`},process:{fill:`#262626`,stroke:`#5c5c5c`,text:`#a3a3a3`,dash:`4 3`},streaming:{fill:`#22302a`,stroke:`#10b981`,text:`#e5e5e5`},idle:{fill:`#212121`,stroke:`#4a4a4a`,text:`#9a9a9a`}}},m=()=>p[document.documentElement.dataset.theme===`dark`?`dark`:`light`];function h(o,p,h){let g=`sessions`,_=`active`,v={sessions:[],runs:[],messages:[]},y=``,b=e(async()=>{let e=_,n=await l(`/api/activity?scope=${e}`,`Failed to load activity`);if(!n.ok){y=``,o.replaceChildren(t(`p`,`p-4 text-[13px] text-red-600`,n.error));return}if(e!==_)return;let r=JSON.stringify(n.value);if(`${e}:${r}`===y)return;y=`${e}:${r}`;let i=n.value;v={...i,sessions:i.sessions.map(e=>({...e,title:c(e.title)}))},x()});function x(){let e=r(n([[`Sessions`,`sessions`],[`Relationships`,`dependencies`]],g,e=>{g=e,x()}),t(`span`,`ml-auto text-[11.5px] text-neutral-400`,`${v.sessions.length} sessions · ${v.runs.length} runs`),n([[`Current`,`active`],[`Last 24h`,`recent`]],_,e=>{_=e,x(),b()})),i=t(`div`,`automation-list min-h-0 flex-1 overflow-auto`);g===`sessions`?S(i):w(i),o.replaceChildren(e,i)}function S(e){let n=document.createElement(`table`);n.className=`w-full table-fixed text-left text-[12.5px]`,n.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase tracking-wide text-neutral-400 shadow-[inset_0_-1px_0_var(--color-neutral-200)]"><tr>
2
2
  <th class="w-[50%] px-4 py-2 font-semibold md:w-[34%]">Session</th>
3
3
  <th class="hidden w-[38%] px-2 py-2 font-semibold md:table-cell">Project</th>
4
4
  <th class="px-2 py-2 font-semibold md:w-[14%]">State</th>
@@ -1 +1 @@
1
- import{E as e,H as t,K as n,N as r,R as i,S as a,U as o,X as s,Y as c,q as l,x as u,y as d,z as f}from"./index-DzXDXra_.js";var p=e=>e.public&&e.token?`/p/${e.slug}-${e.token}/`:`/boards/${e.slug}/`;function m(m,h){let g=[],_=``,v=t(`header`,`pagehead sticky top-[-8px] z-30 max-md:hidden`,e(`Boards`)),y=t(`div`,`px-4 pb-5 pt-1`);m.append(t(`div`,`min-h-0 flex-1 overflow-y-auto`,v,y));async function b(e,t){let r=await s(`/api/boards/${e.slug}`,{public:t},`PATCH`);if(r.ok)return e.token=(await r.json().catch(()=>({}))).token??``,w();_=await n(r,`Could not change ${e.slug}`),await T()}async function x(e){_=await c(`/api/boards/${e}`,`DELETE`,`Could not delete ${e}`)??``,await T()}function S(e){let n=t(`div`,`group flex flex-col gap-1 py-2.5`),i=document.createElement(`a`);i.className=`min-w-0 flex-1 truncate text-[13px] font-medium text-neutral-800 hover:text-indigo-700 max-md:basis-full`,i.href=p(e),i.target=`_blank`,i.rel=`noreferrer`,i.textContent=e.title;let a=t(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,i),s=r(``,``,e.public,t=>{e.public=t,b(e,t)});s.className=`flex flex-none cursor-pointer items-center gap-1.5 text-[11.5px] text-neutral-500`,s.append(t(`span`,``,`Public`));let c=d(`Delete`,`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100 pointer-coarse:opacity-100`);c.title=`Renames the folder on disk; nothing is erased`,c.onclick=()=>void x(e.slug);let l=f(`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-indigo-600 group-hover:opacity-100 pointer-coarse:opacity-100`,()=>`${location.origin}${p(e)}`);l.title=`Copy the board's link`,a.append(t(`div`,`ml-auto flex flex-none items-center gap-2`,s,l,c)),n.append(a);let u=t(`div`,`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-neutral-500`);u.append(t(`span`,`min-w-0 break-all font-mono text-neutral-400`,e.slug)),e.description&&u.append(t(`span`,`min-w-0 truncate`,e.description)),u.append(t(`span`,`flex-none text-neutral-400`,o(Date.parse(e.updatedAt))));for(let t of e.sessions){let e=d(t.slice(0,8),`flex-none cursor-pointer font-mono text-indigo-600 hover:underline`);e.title=`Open session ${t}`,e.onclick=()=>h(t),u.append(e)}if(e.public&&e.token){let n=t(`span`,`min-w-0 break-all font-mono text-neutral-400`,p(e));n.title=`Public URL — anyone holding this link can read the board, no password`,u.append(n)}return n.append(u),n}let C=[{title:`Public`,hint:`Readable at /p/<slug>-<token>/ by anyone holding the link.`,wanted:!0},{title:`Private`,hint:`Reachable from the Console only.`,wanted:!1}];function w(){let e=t(`div`,`mx-auto flex w-full max-w-3xl flex-col gap-4`);g.length===0&&e.append(a(`No boards yet. Ask an agent to build one — it writes a folder under ~/.pier/boards.`));for(let{title:n,hint:r,wanted:i}of C){let a=g.filter(e=>e.public===i);a.length!==0&&e.append(u(n,r,t(`div`,`flex flex-col divide-y divide-neutral-200/70`,...a.map(S))))}y.replaceChildren(..._?[t(`p`,`mb-3 text-[13px] text-red-600`,_)]:[],e)}async function T(){let e=await l(`/api/boards`,`Could not load boards`);if(!e.ok)return _=e.error,w();g=e.value,w(),_=``}let E=i(m,()=>void T());return window.addEventListener(`focus`,()=>{E.visible&&T()}),E}export{m as createBoardsView};
1
+ import{E as e,H as t,K as n,N as r,R as i,S as a,U as o,X as s,Y as c,q as l,x as u,y as d,z as f}from"./index-DbFu15NN.js";var p=e=>e.public&&e.token?`/p/${e.slug}-${e.token}/`:`/boards/${e.slug}/`;function m(m,h){let g=[],_=``,v=t(`header`,`pagehead sticky top-[-8px] z-30 max-md:hidden`,e(`Boards`)),y=t(`div`,`px-4 pb-5 pt-1`);m.append(t(`div`,`min-h-0 flex-1 overflow-y-auto`,v,y));async function b(e,t){let r=await s(`/api/boards/${e.slug}`,{public:t},`PATCH`);if(r.ok)return e.token=(await r.json().catch(()=>({}))).token??``,w();_=await n(r,`Could not change ${e.slug}`),await T()}async function x(e){_=await c(`/api/boards/${e}`,`DELETE`,`Could not delete ${e}`)??``,await T()}function S(e){let n=t(`div`,`group flex flex-col gap-1 py-2.5`),i=document.createElement(`a`);i.className=`min-w-0 flex-1 truncate text-[13px] font-medium text-neutral-800 hover:text-indigo-700 max-md:basis-full`,i.href=p(e),i.target=`_blank`,i.rel=`noreferrer`,i.textContent=e.title;let a=t(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,i),s=r(``,``,e.public,t=>{e.public=t,b(e,t)});s.className=`flex flex-none cursor-pointer items-center gap-1.5 text-[11.5px] text-neutral-500`,s.append(t(`span`,``,`Public`));let c=d(`Delete`,`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100 pointer-coarse:opacity-100`);c.title=`Renames the folder on disk; nothing is erased`,c.onclick=()=>void x(e.slug);let l=f(`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-indigo-600 group-hover:opacity-100 pointer-coarse:opacity-100`,()=>`${location.origin}${p(e)}`);l.title=`Copy the board's link`,a.append(t(`div`,`ml-auto flex flex-none items-center gap-2`,s,l,c)),n.append(a);let u=t(`div`,`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-neutral-500`);u.append(t(`span`,`min-w-0 break-all font-mono text-neutral-400`,e.slug)),e.description&&u.append(t(`span`,`min-w-0 truncate`,e.description)),u.append(t(`span`,`flex-none text-neutral-400`,o(Date.parse(e.updatedAt))));for(let t of e.sessions){let e=d(t.slice(0,8),`flex-none cursor-pointer font-mono text-indigo-600 hover:underline`);e.title=`Open session ${t}`,e.onclick=()=>h(t),u.append(e)}if(e.public&&e.token){let n=t(`span`,`min-w-0 break-all font-mono text-neutral-400`,p(e));n.title=`Public URL — anyone holding this link can read the board, no password`,u.append(n)}return n.append(u),n}let C=[{title:`Public`,hint:`Readable at /p/<slug>-<token>/ by anyone holding the link.`,wanted:!0},{title:`Private`,hint:`Reachable from the Console only.`,wanted:!1}];function w(){let e=t(`div`,`mx-auto flex w-full max-w-3xl flex-col gap-4`);g.length===0&&e.append(a(`No boards yet. Ask an agent to build one — it writes a folder under ~/.pier/boards.`));for(let{title:n,hint:r,wanted:i}of C){let a=g.filter(e=>e.public===i);a.length!==0&&e.append(u(n,r,t(`div`,`flex flex-col divide-y divide-neutral-200/70`,...a.map(S))))}y.replaceChildren(..._?[t(`p`,`mb-3 text-[13px] text-red-600`,_)]:[],e)}async function T(){let e=await l(`/api/boards`,`Could not load boards`);if(!e.ok)return _=e.error,w();g=e.value,w(),_=``}let E=i(m,()=>void T());return window.addEventListener(`focus`,()=>{E.visible&&T()}),E}export{m as createBoardsView};
@@ -1,4 +1,4 @@
1
- import{$ as e,B as t,H as n,J as r,L as i,R as a,U as o,a as s,at as c,c as l,d as u,et as d,f,i as p,it as m,o as h,p as g}from"./index-DzXDXra_.js";var ee=[[`path`,{d:`M12 5v14`}],[`path`,{d:`m19 12-7 7-7-7`}]],te=[[`path`,{d:`M12 22v-6`}],[`path`,{d:`M12 8V2`}],[`path`,{d:`M4 12H2`}],[`path`,{d:`M10 12H8`}],[`path`,{d:`M16 12h-2`}],[`path`,{d:`M22 12h-2`}],[`path`,{d:`m15 19-3-3-3 3`}],[`path`,{d:`m15 5-3 3-3-3`}]],ne=[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`}]],re=[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`}],[`circle`,{cx:`6`,cy:`18`,r:`3`}]],_=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],v=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`},ie=e=>[e.subject,e.body,[[e.author,e.email?`<${e.email}>`:``].filter(Boolean).join(` `),e.at?v(e.at):``].filter(Boolean).join(` · `)].filter(Boolean).join(`
1
+ import{$ as e,B as t,H as n,J as r,L as i,R as a,U as o,a as s,at as c,c as l,d as u,et as d,f,i as p,it as m,o as h,p as g}from"./index-DbFu15NN.js";var ee=[[`path`,{d:`M12 5v14`}],[`path`,{d:`m19 12-7 7-7-7`}]],te=[[`path`,{d:`M12 22v-6`}],[`path`,{d:`M12 8V2`}],[`path`,{d:`M4 12H2`}],[`path`,{d:`M10 12H8`}],[`path`,{d:`M16 12h-2`}],[`path`,{d:`M22 12h-2`}],[`path`,{d:`m15 19-3-3-3 3`}],[`path`,{d:`m15 5-3 3-3-3`}]],ne=[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`}]],re=[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`}],[`circle`,{cx:`6`,cy:`18`,r:`3`}]],_=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],v=e=>{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`},ie=e=>[e.subject,e.body,[[e.author,e.email?`<${e.email}>`:``].filter(Boolean).join(` `),e.at?v(e.at):``].filter(Boolean).join(` · `)].filter(Boolean).join(`
2
2
 
3
3
  `),y=null;function b(){y&&(y.remove(),y=null,document.removeEventListener(`pointerdown`,b,!0),window.removeEventListener(`scroll`,b,!0))}function x(e,t){e.onmouseenter=()=>{b();let r=t();if(!r)return;y=n(`div`,`pointer-events-none fixed z-50 max-w-96 whitespace-pre-wrap rounded-lg bg-neutral-800/95 px-3 py-2 font-sans text-[11.5px] leading-snug text-neutral-100 shadow-lg`),y.textContent=r,document.body.append(y),document.addEventListener(`pointerdown`,b,!0),window.addEventListener(`scroll`,b,!0);let i=e.getBoundingClientRect();y.style.left=`${Math.max(8,Math.min(i.left,window.innerWidth-y.offsetWidth-8))}px`,y.style.top=i.bottom+6+y.offsetHeight>window.innerHeight?`${i.top-y.offsetHeight-6}px`:`${i.bottom+6}px`},e.onmouseleave=b}function S(t,r,i){let a=n(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-1 text-left hover:bg-neutral-100`,e(m,`h-3 w-3 text-indigo-600 ${t.value===r?``:`invisible`}`),n(`span`,`inline-flex flex-none items-center gap-1.5 font-mono text-[11.5px] text-neutral-800`,t.label??t.value));return t.subject&&a.append(n(`span`,`min-w-0 truncate text-[11px] text-neutral-400`,t.subject)),t.author&&a.append(n(`span`,`ml-auto flex-none pl-1.5 text-[10.5px] text-neutral-400`,`${t.author} · ${t.at?o(t.at):``}`)),x(a,()=>ie(t)),a.onclick=()=>i(t.value),a}function ae(t,r,i,a,o){let{base:c,head:l}=i,u=()=>l&&c===`${l}~1`?l:``,d=u()?`commit`:`compare`,f=r.commits[0],p=e=>[...e?[{value:``,label:`Working tree`,subject:`the files on disk, uncommitted changes included`}]:[],{...f,value:`HEAD`},...r.refs.map(e=>({value:e.name,subject:e.subject})),...r.commits.map(e=>({...e,value:e.hash}))],m=n(`div`,`flex w-[38rem] max-w-full flex-col`);function g(){let t=(e,t)=>{let r=n(`button`,`cursor-pointer rounded-full px-2.5 py-0.5 text-[11.5px] ${d===t?`bg-indigo-50 font-medium text-indigo-700`:`text-neutral-500 hover:bg-neutral-100`}`,e);return r.onclick=()=>{d=t,g()},r},i=(e,t,r,i)=>n(`div`,`flex min-w-0 flex-1 flex-col`,n(`div`,`flex-none px-2 pb-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),n(`div`,`min-h-0 flex-1 overflow-y-auto`,...t.map(e=>S(e,r,i)))),f=d===`compare`?n(`div`,`flex h-72 min-h-0 divide-x divide-neutral-200 pb-1`,i(`base`,p(!1),c,e=>{c=e,g(),a(c,l)}),i(`to`,p(!0),l,e=>{l=e,g(),a(c,l)})):n(`div`,`flex h-72 min-h-0 flex-col overflow-y-auto pb-1`,...r.commits.map(e=>S({value:e.hash,...e},u(),e=>{c=`${e}~1`,l=e,s(),a(c,l)}))),h=n(`div`,`flex-none border-t border-neutral-200`,S({value:o,label:`${o} ↔ Working tree`,subject:`back to the default: the main line's tip vs the files on disk`},c===o&&l===``?o:``,()=>{c=o,l=``,g(),a(c,l)}));h.querySelector(`button > span`).prepend(e(_)),m.replaceChildren(n(`div`,`flex flex-none items-center gap-1 border-b border-neutral-200 px-2 py-1.5`,t(`Compare two points`,`compare`),t(`One commit`,`commit`)),f,...d===`compare`?[h]:[])}g(),h(t,m)}var oe=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,se={A:`text-emerald-600`,M:`text-amber-600`,D:`text-red-600`},ce=30,C=`pier.filesPrefs`,w=50,T=()=>{try{let e=JSON.parse(localStorage.getItem(C)??`{}`);return e&&typeof e==`object`?e:{}}catch{return{}}},E=e=>{let t=e?T()[e]:void 0;return typeof t?.cwd==`string`&&typeof t.base==`string`&&typeof t.head==`string`?{cwd:t.cwd,base:t.base,head:t.head}:null},le=(e,t)=>{let n=T();delete n[e],n[e]=t;let r=Object.keys(n);for(let e of r.slice(0,Math.max(0,r.length-w)))delete n[e];try{localStorage.setItem(C,JSON.stringify(n))}catch(e){console.warn(`Files: could not remember this folder`,e)}},D=(e,t=`indigo`)=>{let r=n(`button`,`min-w-0 cursor-pointer truncate rounded-md px-2 py-0.5 text-left font-mono text-[11.5px] ${t===`indigo`?`bg-indigo-50 font-medium text-indigo-700 hover:bg-indigo-100`:`bg-neutral-100 text-neutral-600 hover:bg-neutral-200`}`,e);return r.type=`button`,r};function O(o,s,m,h){let _=``,v=``,y={branch:null,refs:[],commits:[],worktrees:[]},b=`HEAD`,S=``,C=new Map,w=!0,T=!1,O=[],k=new Set,A=null,j=null,ue=n(`header`,`pagehead`),M=n(`div`,`flex-none border-b border-neutral-200`),N=n(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),de=n(`aside`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[12.5px] max-md:h-2/5 max-md:w-full max-md:border-b max-md:border-r-0`,M,N),P=n(`div`,`h-full min-w-0 overflow-auto`),F=n(`div`,`pointer-events-none absolute inset-y-0 right-0 z-20 hidden w-2`),fe=n(`section`,`relative min-h-0 min-w-0 flex-1`,P,F);o.append(ue,n(`div`,`flex min-h-0 flex-1 max-md:flex-col`,de,fe));let I=(e,t)=>`/api/explorer/${e}?${new URLSearchParams({root:_,...t})}`,L=(e,t)=>`/api/fs/${e}?${new URLSearchParams({root:_,...t})}`,R=(e,t=`text-neutral-400`)=>n(`p`,`px-4 py-3 text-[12.5px] ${t}`,e),z=e=>{let t=0;for(let n of C.keys())n.startsWith(`${e}/`)&&t++;return t};function B(e,t){let n=new Set(t.map(e=>e.name)),r=e?`${e}/`:``;for(let[e,i]of C){if(i.status!==`D`||!e.startsWith(r))continue;let a=e.slice(r.length).split(`/`)[0];n.has(a)||(n.add(a),t.push({name:a,dir:e.slice(r.length).includes(`/`)}))}let i=t;return w&&y.branch&&(i=t.filter(e=>e.dir?z(`${r}${e.name}`)>0:C.has(`${r}${e.name}`))),i.sort((e,t)=>Number(t.dir)-Number(e.dir)||e.name.localeCompare(t.name)),i.map(e=>e.dir?pe(`${r}${e.name}`,e.name):me(`${r}${e.name}`,e.name))}async function V(e,t){try{let{entries:n}=await r(L(`ls`,{path:t}),`could not list this folder`);e.replaceChildren(...B(t,n)),e.childElementCount||e.append(R(w?`No changes.`:`Empty.`))}catch(n){let r=B(t,[]);r.length?e.replaceChildren(...r):e.replaceChildren(R(String(n),`text-red-600`))}}function pe(e,r){let i=z(e),a=[n(`span`,`truncate`,r)];i&&a.push(n(`span`,`ml-auto flex-none rounded bg-amber-100/80 px-1 font-mono text-[10px] text-amber-700`,String(i)));let{el:o,summary:s}=t(``,a);s.className+=` px-2 py-0.5 hover:bg-neutral-100`;let c=n(`div`,`pl-3`);o.append(c);let l=!1,u=()=>{l||(l=!0,c.append(R(`…`)),V(c,e))};return o.ontoggle=()=>{k[o.open?`add`:`delete`](e),o.open&&u()},(w&&y.branch&&!T||k.has(e))&&(o.open=!0,u()),o}function H(e){j?.classList.remove(`bg-indigo-50`,`text-indigo-700`),j=e,e.classList.add(`bg-indigo-50`,`text-indigo-700`)}function me(e,t){let r=C.get(e)?.status,i=n(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-0.5 pl-6 text-left hover:bg-neutral-100`,n(`span`,`truncate`,t));return r&&i.append(n(`span`,`ml-auto flex-none font-mono text-[10.5px] font-semibold ${se[r]??`text-neutral-500`}`,r)),i.title=e,e===A&&H(i),i.onclick=()=>{H(i),A=e,_e(e)},i}let U=()=>void V(N,``),W=(e,t)=>[...e?[n(`span`,`flex-none font-mono text-[10.5px] font-semibold text-emerald-600`,`+${e}`)]:[],...t?[n(`span`,`flex-none font-mono text-[10.5px] font-semibold text-red-600`,`−${t}`)]:[]];function G(e,t,r){let a=C.get(e),o=n(`div`,`sticky top-0 z-10 flex items-center gap-2 border-b border-neutral-200 bg-white px-4 py-1.5 font-mono text-[11.5px] text-neutral-500`,n(`span`,`truncate`,e));a&&(o.append(n(`span`,`flex-none font-semibold ${se[a.status]??``}`,a.status)),o.append(...W(a.add,a.del)));let s=n(`div`,`ml-auto flex flex-none items-center gap-2`);if(r&&s.append(r),t){let t=document.createElement(`a`);t.className=`flex-none text-neutral-400 hover:text-indigo-700 hover:underline`,t.href=L(`file`,{path:e}),t.download=i(e),t.textContent=`Download`,s.append(t)}return o.append(s),o}function he(e){let t=0;for(;t<e.length;){if(e[t].tone!==`del`){t++;continue}let n=t;for(;t<e.length&&e[t].tone===`del`;)t++;let r=t;for(;t<e.length&&e[t].tone===`add`;)t++;let i=Math.min(r-n,t-r);for(let t=0;t<i;t++){let i=e[n+t],a=e[r+t],o=Math.min(i.text.length,a.text.length),s=0;for(;s<o&&i.text[s]===a.text[s];)s++;let c=0;for(;c<o-s&&i.text[i.text.length-1-c]===a.text[a.text.length-1-c];)c++;s+c!==0&&(i.mark=[s,i.text.length-c],a.mark=[s,a.text.length-c])}}}let K=we();function q(){F.classList.add(`hidden`),F.replaceChildren(),K.set([],[])}let ge=0,J=e=>e===ge;function _e(e){let t=++ge;return C.has(e)?Te(e,t):ve(e,t)}async function ve(e,t){if(!J(t))return;q();let r=L(`file`,{path:e}),i=n(`div`,`min-w-0`);if(P.classList.remove(`flex`,`flex-col`),P.replaceChildren(G(e,!0),i),oe.test(e)){let e=n(`img`,`max-w-full p-4`);e.src=r,e.onerror=()=>i.replaceChildren(R(`Could not load image.`,`text-red-600`)),i.append(e);return}if(e.toLowerCase().endsWith(`.pdf`)){let t=document.createElement(`iframe`);t.className=`h-full w-full`,t.src=r,P.replaceChildren(G(e,!0),t),P.classList.add(`flex`,`flex-col`);return}i.append(R(`…`));let a=await fetch(r);if(!J(t))return;if(!a.ok){let{error:e}=await a.json().catch(()=>({}));i.replaceChildren(R(e??`HTTP ${a.status}`,`text-red-600`));return}if(!(a.headers.get(`content-type`)??``).startsWith(`text/plain`)){i.replaceChildren(R(`Binary file — use Download.`));return}let o=f(await a.text());if(!J(t))return;let s=await g(e);J(t)&&i.replaceChildren(u(o,s))}function ye(e){let t=[],n=0,r=0,i=!1,a=e.split(`
4
4
  `);a.at(-1)===``&&a.pop();for(let e of a){let a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(a){i&&t.push({nums:[``,``],text:`⋯`,tone:``}),[n,r]=[Number(a[1]),Number(a[2])],i=!0;continue}!i||e.startsWith(`\\`)||(e.startsWith(`+`)?t.push({nums:[``,r++],text:e.slice(1),tone:`add`}):e.startsWith(`-`)?t.push({nums:[n++,``],text:e.slice(1),tone:`del`}):t.push({nums:[n++,r++],text:e.slice(1),tone:``}))}return t}function be(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n].tone;if(!r)continue;let i=t.at(-1);i&&i.end===n-1?(i.end=n,(r===`add`&&i.tone===`del`||r===`del`&&i.tone===`add`)&&(i.tone=`mixed`)):t.push({start:n,end:n,tone:r})}return t}let xe={add:`bg-emerald-400`,del:`bg-red-400`,mixed:`bg-amber-400`};function Se(e,t,r){F.replaceChildren(...e.map(e=>{let i=n(`button`,`pointer-events-auto absolute w-full cursor-pointer ${xe[e.tone]}`);return i.style.top=`${e.start/t*100}%`,i.style.height=`${Math.max(.4,(e.end-e.start+1)/t*100)}%`,i.title=`line ${Ce(r,e.start)}`,i.onclick=()=>r[e.start].scrollIntoView({block:`center`}),i})),F.classList.remove(`hidden`)}let Ce=(e,t)=>e[t]?.querySelector(`span`)?.textContent?.trim()||String(t+1);function we(){let t=[],r=[],i=-1,a=n(`span`,`flex-none text-[10.5px] text-neutral-400`),s=e=>{t.length&&(i=(i+e+t.length)%t.length,r[t[i].start].scrollIntoView({block:`center`}),a.textContent=`${i+1}/${t.length}`)},u=()=>t.length>0&&!o.classList.contains(`hidden`),d=(t,r,i,a)=>{let o=n(`button`,`icon-btn flex-none`,e(t));return o.onclick=()=>s(r),l(o,a,i,()=>s(r),u),o};return{el:n(`div`,`flex flex-none items-center gap-1`,a,d(c,-1,`Previous change`,[`p`,`k`]),d(ee,1,`Next change`,[`n`,`j`])),set(e,n){t=e,r=n,i=-1,a.textContent=`${e.length} change${e.length===1?``:`s`}`}}}async function Te(e,t){q(),P.classList.remove(`flex`,`flex-col`);let n=C.get(e)?.status!==`D`;P.replaceChildren(G(e,n),R(`…`));try{let{diff:i}=await r(I(`diff`,{base:b,head:S,file:e,context:`99999`}),`could not read this diff`);if(!J(t))return;if(!i||/^Binary files /m.test(i))return ve(e,t);let a=ye(i);he(a);let o=await g(e);if(!J(t))return;let s=u(a,o),c=[...s.children],l=be(a);K.set(l,c),P.replaceChildren(G(e,n,K.el),s),Se(l,a.length,c)}catch(n){J(t)&&P.replaceChildren(G(e,!1),R(String(n),`text-red-600`))}}let Y=()=>S&&b===`${S}~1`?S:``,Ee=()=>y.commits.find(e=>e.hash===Y())?.subject??``,De=()=>Y()?`${Y()} — ${Ee()||`commit`}`:`${b} ↔ ${S||`working tree`}`,Oe=(t,r,i,a)=>{let o=n(`button`,`flex h-6 w-6 flex-none cursor-pointer items-center justify-center rounded-md ${i?`bg-indigo-50 text-indigo-700`:`text-neutral-400 hover:bg-neutral-100 hover:text-neutral-700`}`);return o.append(e(t)),o.title=r,o.setAttribute(`aria-label`,r),o.setAttribute(`aria-pressed`,String(i)),o.onclick=a,o};function X(){let e=Oe(ne,`Show only files that differ`,w,()=>{w=!w,X(),U()}),t=Oe(te,T?`Restore folders`:`Collapse all folders`,T,()=>{if(T=!T,T)O=[...k],k.clear();else for(let e of O)k.add(e);X(),U()});if(!y.branch){M.replaceChildren(n(`div`,`flex items-center justify-end gap-1 p-1.5`,t));return}let r=D(De());if(Y()){let e=y.commits.find(e=>e.hash===Y());x(r,()=>e?ie(e):``)}else r.title=`Choose what to diff`;r.onclick=async()=>{await Me(),ae(r,y,{base:b,head:S},(e,t)=>{b=e,S=t,Z()},$())};let[i,a]=[0,0];for(let e of C.values())i+=e.add,a+=e.del;M.replaceChildren(n(`div`,`flex flex-col gap-1 p-2`,r,n(`div`,`flex items-center gap-1.5 pl-1`,n(`span`,`text-[11px] text-neutral-400`,`${C.size} changed file${C.size===1?``:`s`}`),...W(i,a),n(`span`,`ml-auto`),e,t)))}let ke=()=>{v&&_&&le(v,{cwd:_,base:b,head:S})},Ae=e=>{let t=e.replace(/~\d+$/,``);return!t||t===`HEAD`||y.refs.some(e=>e.name===t)||y.commits.some(e=>e.hash===t)};async function je(){if(C=new Map,!y.branch)return;let{files:e}=await r(I(`diff`,{base:b,head:S}),`could not read what changed`);for(let t of e)C.set(t.path,{status:t.status,add:t.add,del:t.del});if(C.size<=ce)for(let e of C.keys()){let t=e.split(`/`);for(let e=1;e<t.length;e++)k.add(t.slice(0,e).join(`/`))}}async function Z(){ke();try{await je()}catch(e){X(),N.replaceChildren(R(String(e),`text-red-600`));return}X(),U(),A&&_e(A)}function Q(){let t=D(_||`Choose a folder…`,`neutral`);t.className+=` max-w-72`,t.title=`Switch folder`,t.onclick=()=>p(t,y.worktrees.map(e=>({path:e.path,...e.branch?{hint:e.branch}:{}})),_||void 0,m);let r=n(`button`,`icon-btn`,e(d));r.type=`button`,r.title=`Close Files`,r.setAttribute(`aria-label`,`Close Files`),r.onclick=h,r.classList.add(`ml-auto`),ue.replaceChildren(t,n(`span`,`flex min-w-0 items-center gap-1 truncate font-mono text-[11.5px] text-neutral-400`,...y.branch?[e(re),n(`span`,`truncate`,y.branch)]:[`no git`]),r)}async function Me(){if(_)try{y=await r(I(`git`,{}),`could not read this repository`),Q()}catch(e){P.replaceChildren(R(String(e),`text-red-600`))}}let $=()=>y.refs.some(e=>e.name===`main`)?`main`:y.refs.some(e=>e.name===`master`)?`master`:`HEAD`;async function Ne(){if(Q(),A=null,j=null,k.clear(),q(),P.classList.remove(`flex`,`flex-col`),P.replaceChildren(R(`Select a file.`)),!_){M.replaceChildren(),N.replaceChildren(),P.replaceChildren(R(`No folder yet — pick one from the chip above.`));return}try{y=await r(I(`git`,{}),`could not read this repository`)}catch(e){y={branch:null,refs:[],commits:[],worktrees:[]},P.replaceChildren(R(String(e),`text-red-600`))}let e=E(v),t=e&&e.cwd===_&&Ae(e.base)&&Ae(e.head)?e:null;b=t?.base??$(),S=t?.head??``,Q(),await Z()}return a(o,e=>{let t=s(),n=t?.id??``,r=e?.startsWith(`/`)?e:(n===v?_:``)||E(n)?.cwd||t?.cwd||``;if(r===_&&n===v&&N.childElementCount){Q(),Me().then(Z);return}v=n,_=r,Ne()},()=>{q(),P.classList.remove(`flex`,`flex-col`),P.replaceChildren(R(`Select a file.`))})}export{O as createExplorerView};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-BlzEbk11.js","assets/task-runs-BCakxFk8.js","assets/runs-Cwy0mN8i.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-BffPVgXg.js","assets/task-runs-CqpTV644.js","assets/runs-Cv0A-e08.js"])))=>i.map(i=>d[i]);
2
2
  (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},t=([e,n,r])=>{let i=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(n).forEach(e=>{i.setAttribute(e,String(n[e]))}),r?.length&&r.forEach(e=>{let n=t(e);i.appendChild(n)}),i},n=(n,r={})=>t([`svg`,{...e,...r},n]),r=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],i=[[`path`,{d:`M7 7h10v10`}],[`path`,{d:`M7 17 17 7`}]],a=[[`path`,{d:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]],o=[[`path`,{d:`M20 6 9 17l-5-5`}]],s=[[`path`,{d:`m6 9 6 6 6-6`}]],c=[[`path`,{d:`m15 18-6-6 6-6`}]],l=[[`path`,{d:`m9 18 6-6-6-6`}]],u=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}],[`path`,{d:`M12 17h.01`}]],d=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],ee=[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`}],[`path`,{d:`m9 10-5 5 5 5`}]],f=[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]],p=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],te=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],ne=[[`path`,{d:`M12 10v6`}],[`path`,{d:`M9 13h6`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]],re=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],ie=[[`path`,{d:`M13 5h8`}],[`path`,{d:`M13 12h8`}],[`path`,{d:`M13 19h8`}],[`path`,{d:`m3 17 2 2 4-4`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`}]],m=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],ae=[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],oe=[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}]],se=[[`path`,{d:`M5 12h14`}]],ce=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],h=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],le=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`}]],ue=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],de=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],fe=[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}]],pe=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],me=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],he=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]],ge=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],_e=[[`path`,{d:`M9 14 4 9l5-5`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`}]],ve=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],g=(e,t=`h-3.5 w-3.5`)=>n(e,{class:`flex-none ${t}`,"aria-hidden":`true`,focusable:`false`});function ye(){let e={ArrowUp:a,ChevronLeft:c,ChevronRight:l,Clock:d,Ellipsis:p,LayoutDashboard:re,ListTodo:ie,Menu:ae,Plus:de,RotateCw:fe,Search:pe,Settings:me,Square:he,Undo2:_e,X:ve};for(let t of document.querySelectorAll(`[data-icon]`)){let n=e[t.dataset.icon];if(!n)throw Error(`Unknown shell icon: ${t.dataset.icon}`);t.replaceChildren(g(n,`h-full w-full`))}let t=g(s);t.setAttribute(`stroke`,`#737373`),document.documentElement.style.setProperty(`--select-chevron`,`url("data:image/svg+xml,${encodeURIComponent(t.outerHTML)}")`)}var be=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function xe(e){let t=[],n=e=>`\uE010${t.push(e)-1}\uE011`,r=e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e));return r=r.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(e,t)=>{let n=``,r=``,i=t;for(;i.length>1&&be.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&be.test(i.at(-1));)r=i.at(-1)+r,i=i.slice(0,-1);return n||r?`${n}**${i}**${r}`:e}),r.replace(/\uE010(\d+)\uE011/g,(e,n)=>t[Number(n)]??``)}var _=e=>!e.text.trim()&&e.suggestions.length===0,Se=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),Ce=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},we=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,Te=/\[([^\]\r\n]+)\]/g,Ee=5,De=/<silent>([\s\S]*?)<\/silent>/gi;function Oe(e){let t=[...e.matchAll(De)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function ke(e,t){let n=Ae(e),r=Oe(e),i=we.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(Te)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,Ee);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var Ae=e=>xe(e.replace(De,``).trim()),v=/^(?:\s|[-*+>]|\d+[.)])/;function je(e,t=0){let n=e.lastIndexOf(`
3
3
  `)+1,r=``,i=!1,a=t,o=-1,s=``;for(let c=t;c<n;){let t=e.indexOf(`
4
4
  `,c),n=e.slice(c,t);c=t+1;let l=/^\s*(`{3,}|~{3,})(.*)$/.exec(n);if(!r&&!i&&!n.trim()){o<0&&s&&(o=c);continue}!r&&!i&&o>=0&&!(v.test(s)&&v.test(n))&&(a=o);let u=l?.[1]??``;if(!r&&u&&!i?r=u:r&&u[0]===r[0]&&u.length>=r.length&&!l?.[2]?.trim()&&(r=``),!r&&(!u||i))for(let e of n.matchAll(/<(\/?)silent>/gi))i=!e[1];o=-1,s=n}return a}var y=/^\[(?:([^\n[\]<>]*)<([^\n[\]<>]+)>)? ?((?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})?\]\n/;function Me(e){let t=y.exec(e);return!t?.[2]&&!t?.[3]?{text:e}:{...t[1]?{name:t[1]}:{},...t[2]?{id:t[2]}:{},...t[3]?{when:t[3]}:{},text:e.slice(t[0].length)}}var Ne=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,Pe=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function Fe(e){if(!e)return e;let{text:t}=Me(e);return t===e?e:t.replace(Ne,``).replace(Pe,`$1`).replace(/\s+/g,` `).trim()||e}function Ie(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var b=(e,t,n=`POST`)=>fetch(e,{method:n,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function x(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function Le(e,t,n){let r;try{r=await fetch(e,n)}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}if(!r.ok)return{ok:!1,error:await x(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function Re(e,t,n){let r=await Le(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function ze(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await x(r,n)}catch(e){return`${n}: ${String(e)}`}}function Be(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ve(e){if(Array.isArray(e))return e}function He(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ue(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
@@ -82,4 +82,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
82
82
  `),o=W.sessionState()===`idle`&&e===`auto`;o?W.setState(`streaming`):yc(),(o||e===`steer`)&&(_c(a),H(`user`,a,!1,Date.now()),jo(!0));let s=await b(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await x(s,`send failed`);await W.reload(i),H(`error`,e)}}finally{t===void 0&&(Fc=!1)}}}async function Lc(e){let t=W.sessionId();if(!t)return;Sc([],[]);let n=await b(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await x(n,`Queue ${e} failed`);await W.reload(t),W.sessionId()===t&&H(`error`,r)}}async function Rc(){let e=W.sessionId();if(!e||uc.has(e))return;uc.add(e);let t=lc,n=kc,r=document.activeElement;try{Mc();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await x(i,`Could not recall queued messages`);W.sessionId()===e&&H(`error`,t);return}let{messages:a}=await i.json(),o=W.sessionId()===e;if(a.length)try{let t=o?G.value:sessionStorage.getItem(Oc(e))??``,i=(t?[t,...a]:a).join(`
83
83
  `);o&&(G.value=i,Pc(),n===kc&&W.chatVisible()&&document.activeElement===r&&G.focus()),Mc(e,i)}catch(t){H(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
84
84
  `)}`)}o&&t===lc&&Sc([],[])}finally{uc.delete(e)}}function zc(e){W=e,Ac(),pc(),mc();let t=()=>{let e=W.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};tc.onclick=t,qs(tc,`Stop the running turn`,t,()=>W.sessionState()===`streaming`&&W.chatVisible()),L(`#queue-steer`).onclick=()=>void Lc(`steer`),L(`#queue-restart`).onclick=()=>void Lc(`restart`),L(`#queue-recall`).onclick=()=>void Rc(),Zs.onsubmit=e=>{e.preventDefault(),Ic(`auto`)},Ys(G,[`/`],`Write a message`,hc,W.chatVisible),G.onfocus=Ao,G.oninput=()=>{Pc(),Mc()};let n=!matchMedia(`(pointer: coarse)`).matches;G.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ic(`auto`))},G.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&Tc(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),G.setRangeText(n,G.selectionStart??0,G.selectionEnd??0,`end`),Pc(),Mc())},V.ondragover=e=>e.preventDefault(),V.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])Tc(t)},L(`#attach`).onclick=()=>sc.click(),sc.onchange=()=>{for(let e of sc.files??[])Tc(e);sc.value=``},yc()}var Bc=`pier.push`,Vc=`/sw.js`,Hc=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Uc=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Wc(){return window.isSecureContext?Hc()&&!Uc()?`On iPhone and iPad, notifications work only from the installed app: Share → Add to Home Screen, then open Pier from that icon.`:!(`serviceWorker`in navigator)||!(`PushManager`in window)||!(`Notification`in window)?`This browser has no Web Push support.`:``:`Notifications need HTTPS. Reach this Pier through its public URL, not over plain http.`}var Gc=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],Kc=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function qc(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Gc,`Linux`)} · ${t(Kc,`browser`)}${Uc()?` (installed)`:``}`}var Jc=e=>{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},Yc=null;async function Xc(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(Yc??=await navigator.serviceWorker.register(Vc,{scope:`/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),Yc)}var Zc=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function Qc(e){let{publicKey:t}=await Re(`/api/push`,`Could not read this instance's push key`),n=Jc(t),r=await e.pushManager.getSubscription();if(r){if(Zc(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function $c(e){return b(`/api/push/subscribe`,{...e.toJSON(),label:qc()})}async function el(){rl();let e=await Xc();if(!(!e||localStorage.getItem(Bc)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await $c(await Qc(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var tl=null,nl=null;function rl(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),tl=e,nl?.()}),window.addEventListener(`appinstalled`,()=>{tl=null,nl?.()})}function il(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function al(){let e=R(`span`,`text-[11.5px]`,``),t=Xr(`Send a test notification`),n=R(`div`,`flex items-center gap-3`,t,e),r=R(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Bc)===`on`;async function a(){pi(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Bc,`off`),c(),pi(e,`failed`,t===`denied`?`Notifications are blocked for this site — allow them in the browser's site settings, then try again.`:`No answer to the permission prompt.`);let n=await Xc();if(!n)return pi(e,`failed`,`This browser refused to register a service worker.`);try{let t=await $c(await Qc(n));if(!t.ok)return pi(e,`failed`,await x(t,`Could not register this browser`));localStorage.setItem(Bc,`on`),c(),pi(e,`saved`,`This browser will be notified when a turn finishes unseen.`)}catch(t){pi(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function o(){localStorage.setItem(Bc,`off`),c();let t=await(await Xc())?.pushManager.getSubscription();t&&(await b(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),pi(e,`idle`,`This browser will not be notified.`)}t.onclick=()=>{pi(e,`saving`,`sending…`),(async()=>{let t=await b(`/api/push/test`,{});if(!t.ok)return pi(e,`failed`,await x(t,`Could not send`));let{sent:n,failed:r}=await t.json();pi(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function s(){if(!tl)return[];let e=Xr(`Install Pier`,!0);return e.onclick=()=>{let e=tl;e&&e.prompt().then(()=>e.userChoice).finally(()=>{tl=null,c()})},[R(`div`,`flex items-center gap-3`,e,R(`span`,`text-[11.5px] leading-snug text-neutral-500`,`Its own window and icon — and where notifications look like an app's.`))]}function c(){let e=Wc();if(e){r.replaceChildren(...s(),R(`p`,`text-[12.5px] leading-snug text-neutral-500`,e));return}let c=i()&&Notification.permission===`granted`;t.disabled=!c,r.replaceChildren(...s(),di(`Notify this device`,`A turn that finishes while nobody is looking at it becomes a notification here. Per browser — each device is enabled on its own.`,c,e=>void(e?a():o())),n)}return nl=c,c(),ii(`Notifications`,`Web Push, so a finished turn reaches you with the workbench closed. Installed — Chrome's address-bar icon, or Share → Add to Home Screen on iOS — Pier notifies you the way an app does.`,r)}var K=null,ol=null,sl=null;function cl(e){K&&!K.contains(e.target)&&e.target!==sl&&q()}var ll={ArrowDown:1,ArrowUp:-1},ul={n:1,j:1,p:-1,k:-1},dl=()=>K!==null;function fl(e){if(!(e.altKey||e.metaKey||e.shiftKey||!e.key))return e.ctrlKey?ul[e.key.toLowerCase()]:ll[e.key]}function pl(e,t){let n=[...e.querySelectorAll(`button:not(:disabled)`)];if(!n.length)return!1;let r=n.indexOf(document.activeElement);return n[t===`first`?0:t===`last`?n.length-1:r<0?t>0?0:n.length-1:(r+t+n.length)%n.length]?.focus(),!0}function ml(e){if(e.dataset.menu===`true`)return{rows:e,ends:!0};let t=e.querySelector(`[data-list]`);return t?{rows:t,ends:!1}:null}function hl(e){let t=K?ml(K):null;if(t){let n=(t.ends?e.key===`Home`?`first`:e.key===`End`?`last`:void 0:void 0)??fl(e);if(n!==void 0&&pl(t.rows,n)){e.preventDefault();return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),q())}function gl(e){K&&!K.contains(e.target)&&q()}function q(){if(!K)return;document.removeEventListener(`pointerdown`,cl,!0),document.removeEventListener(`focusin`,cl,!0),document.removeEventListener(`keydown`,hl,!0),window.removeEventListener(`scroll`,gl,!0),window.removeEventListener(`resize`,q);let e=K;K=null,sl?.remove(),sl=null,e.contains(document.activeElement)&&ol?.focus({preventScroll:!0}),ol?.removeAttribute(`aria-expanded`),ol=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var _l=null;function vl(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:_l?.anchor===e?{top:_l.top,left:_l.left}:n}var yl=()=>window.innerWidth<640;function bl(e,t){q(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=yl();K=R(`div`,`glass-menu fixed z-50 border border-neutral-200 p-2 font-sans leading-6 ${n?`rounded-3xl inset-x-2 bottom-2 max-h-[70dvh] overflow-y-auto pb-[calc(0.25rem+env(safe-area-inset-bottom))] text-[16px]`:`rounded-2xl min-w-60 max-w-[min(42rem,calc(100vw-1rem))] max-h-[calc(100dvh-1rem)] overflow-y-auto text-[15px]`}`),K.dataset.presentation=n?`sheet`:`popover`,K.append(t);let r=e.closest(`dialog[open]`)??document.body;if(n&&(sl=R(`div`,`fixed inset-0 z-50 bg-black/15`),sl.onclick=e=>{e.stopPropagation(),q()},r.append(sl)),r.append(K),!n){let t=vl(e);_l={anchor:e,...t},K.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-K.offsetHeight-8))}px`,K.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-K.offsetWidth-8))}px`}ol=e,ol.setAttribute(`aria-expanded`,`true`),K.tabIndex=-1,(K.querySelector(`button, input, select, [tabindex='0']`)??K).focus({preventScroll:!0}),document.addEventListener(`pointerdown`,cl,!0),document.addEventListener(`focusin`,cl,!0),document.addEventListener(`keydown`,hl,!0),window.addEventListener(`scroll`,gl,!0),window.addEventListener(`resize`,q)}function xl(e){let t=R(`button`,`flex w-full cursor-pointer items-center gap-2 rounded-xl px-3 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100 ${yl()?`min-h-12 py-3`:`min-h-10 py-2`}`,...e.checked===void 0?[]:[g(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`)],R(`span`,`min-w-0 truncate`,e.label));if(e.hint){let n=R(`span`,`ml-auto max-w-28 shrink-[999] truncate text-[13px] text-neutral-500`,e.hint);n.title=e.hint,t.append(n)}return t.onclick=()=>e.onSelect(),t}function Sl(e,t,n){let r=R(`div`,``);if(n&&yl()){let e=R(`button`,`icon-btn h-11 w-11`,g(ve));e.setAttribute(`aria-label`,`Close session actions`),e.onclick=q,r.append(R(`div`,`flex items-center gap-3 border-b border-neutral-200 px-3 pb-1 mb-1`,R(`span`,`min-w-0 flex-1 truncate text-sm font-medium text-neutral-500`,n),e))}for(let e of t)e.separatorBefore&&r.append(R(`hr`,`my-2 border-neutral-200`)),r.append(xl(e));bl(e,r),K&&(K.dataset.menu=`true`,K.setAttribute(`aria-label`,n?`Actions for ${n}`:`Actions`),K.setAttribute(`role`,`group`))}var Cl=async e=>{let t=await Le(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},wl=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),Tl=`flex w-full min-h-10 cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100`,El=`font-mono text-[0.875rem]`,Dl=(e,t,n)=>{let r=Zr(e,`${Tl} ${t}`);return r.onclick=n,r};function Ol(e,t){let n=R(`div`,`mt-2 flex-none border-t border-neutral-200 pt-2`),r=Dl(`New folder`,`text-neutral-500`,()=>{let r=document.createElement(`input`);r.className=`w-full rounded-xl border-0 bg-neutral-100 px-3 py-2 ${El} focus:outline-none`,r.placeholder=`folder-name`;let i=R(`p`,`hidden px-3 pt-1 text-[0.8125rem] text-red-600`);r.onkeydown=async n=>{if(n.key!==`Enter`)return;n.preventDefault();let a=await b(`/api/fs/mkdir`,{path:e,name:r.value});if(!a.ok){i.textContent=(await a.json()).error??`could not create`,i.classList.remove(`hidden`);return}t((await a.json()).path)},n.replaceChildren(r,i),r.focus()});return r.prepend(g(de)),n.append(r),n}function kl(e,t,n){let r=e=>{n(e),q()};async function i(t){let n=await Cl(t);if(!n)return;let a=R(`div`,`flex max-h-[60dvh] w-full flex-col sm:w-88`),o=Zr(`Use`,`btn btn-primary ml-auto flex-none px-3 py-1 text-[0.8125rem]`);o.onclick=()=>r(n.path);let s=document.createElement(`input`);s.className=`min-w-0 flex-1 border-0 bg-transparent ${El} text-neutral-600 focus:outline-none`,s.value=n.path,s.spellcheck=!1,s.title=`Type or paste a path, then Enter`,s.onfocus=()=>s.select();let c=R(`p`,`hidden flex-none px-3 pb-1 text-[0.8125rem] text-red-600`);s.onkeydown=async e=>{if(e.key!==`Enter`)return;e.preventDefault(),e.stopPropagation();let t=s.value.trim();if(!t)return;let n=await Cl(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=R(`div`,`mb-2 flex flex-none items-center gap-2 border-b border-neutral-200 px-3 pb-2 pt-1`,s,o),u=R(`div`,`min-h-0 flex-1 overflow-y-auto`);u.dataset.list=``,n.parent&&u.append(Dl(`../`,`${El} text-neutral-500`,()=>void i(n.parent)));let d=wl(n);for(let e of d)u.append(Dl(e,`truncate`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(R(`p`,`px-3 py-2 text-[0.8125rem] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,Ol(n.path,e=>void i(e))),bl(e,a)}i(t)}function Al(e,t,n,r){Sl(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{q(),r(e.path)}})),{label:`Browse…`,onSelect:()=>kl(e,n||void 0,r)}])}var jl=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function Ml(e,t){let n=Zr(`Browse…`,`flex-none cursor-pointer rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-600 hover:bg-neutral-100`);return n.onclick=()=>kl(n,e.value.trim()||void 0,jl(e,t)),n}function Nl(e,t,n){let r=document.createElement(`input`);return r.className=`min-w-0 flex-1 rounded-md border border-neutral-300 bg-white px-2 py-1 font-mono text-[12.5px] focus:border-indigo-400 focus:outline-none`,r.value=e,r.placeholder=t,r.oninput=()=>n(r.value),{el:R(`div`,`flex items-center gap-1.5`,r,Ml(r,n)),input:r}}var J=L(`#sidebar`),Pl=L(`#drawer-scrim`),Fl=L(`#mobile-title`),Il=L(`#mobile-menu`),Ll=L(`#session-meta`);function Rl(){delete J.dataset.open,Pl.classList.add(`hidden`),Kl()}function zl(e,t){Fl.textContent=e,Fl.classList.toggle(`cursor-pointer`,t),Il.classList.toggle(`hidden`,!t)}var Bl=`pier.railClosed`;localStorage.getItem(Bl)===`1`&&(document.body.dataset.rail=`closed`);function Vl(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(Bl,e?`1`:`0`),Kl()}function Hl(){if(J.dataset.open!==void 0)return Rl();J.dataset.open=``,Pl.classList.remove(`hidden`),Kl()}var Ul=window.matchMedia(`(width < 48rem)`),Wl=()=>Ul.matches;function Gl(){Wl()?L(`#mobile-bar`).append(Ll):L(`#chat-menu`).before(Ll)}function Kl(){let e=Wl()&&J.dataset.open!==void 0,t=L(`main`);t.inert=e,J.inert=Wl()?!e:document.body.dataset.rail===`closed`,L(`#drawer-toggle`).setAttribute(`aria-expanded`,String(e)),e&&!J.contains(document.activeElement)&&L(`#new-session`).focus(),J.inert&&J.contains(document.activeElement)&&L(Wl()?`#drawer-toggle`:`#rail-toggle`).focus()}var ql=[L(`#rail-toggle`),L(`#drawer-toggle`)],Jl=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Yl=e=>e===1?R(`span`,`${Jl} h-2 w-2`):R(`span`,`${Jl} flex h-3.5 min-w-3.5 items-center justify-center px-0.5 text-[9px] font-semibold text-white`,e>9?`9+`:String(e));function Xl(e){for(let t of ql)t.querySelector(`.attention`)?.remove(),e&&t.append(Yl(e))}var Zl=20,Ql=.35,$l=8;function eu(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{J.style.transition=`none`,J.style.transform=`translateX(${String(e-i)}px)`,Pl.style.transition=`none`,Pl.classList.remove(`hidden`),Pl.style.opacity=String(e/i)},o=t=>{J.style.transition=``,J.style.transform=``,Pl.style.transition=``,Pl.style.opacity=``,t?(J.dataset.open=``,Pl.classList.remove(`hidden`),Kl()):Rl(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Wl()||a.touches.length!==1))return;let o=a.touches[0],s=J.dataset.open!==void 0;if(i=J.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Zl||a.target?.closest(`button, a, input, textarea, select`))return;a.preventDefault()}e=o.clientX,t=o.clientY,n=!s},{passive:!1}),window.addEventListener(`touchmove`,o=>{if(e<0)return;let s=o.touches[0],c=s.clientX-e;if(!r){if(Math.abs(s.clientY-t)>Math.abs(c))return void(e=-1);if(Math.abs(c)<$l)return;r=!0}o.preventDefault(),a(Math.max(0,Math.min(i,n?c:i+c)))},{passive:!1});let s=()=>{if(e<0)return;if(!r)return void(e=-1);let t=J.getBoundingClientRect().right;o(n?t>i*Ql:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function tu(e){eu(),Kl(),Gl(),Ul.addEventListener(`change`,()=>{Rl(),Gl()}),L(`#drawer-toggle`).setAttribute(`aria-controls`,`sidebar`),J.addEventListener(`keydown`,e=>{if(!(!Wl()||J.dataset.open===void 0||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),Rl();else if(e.key===`Tab`){let t=[...J.querySelectorAll(`button, a[href], summary`)].filter(e=>e.getClientRects().length&&!e.matches(`:disabled`)),n=e.shiftKey?t.at(-1):t[0],r=e.shiftKey?t[0]:t.at(-1);document.activeElement===r&&(e.preventDefault(),n?.focus())}}}),L(`#drawer-toggle`).onclick=Hl,Pl.onclick=Rl,Il.onclick=()=>e.sessionMenu(Il),Fl.onclick=()=>{Il.classList.contains(`hidden`)||e.sessionInfo(Fl)};let t=L(`#rail-toggle`);t.onclick=()=>Vl(document.body.dataset.rail!==`closed`),Ks(t,`meta+b`,`Toggle sidebar`,()=>Wl()?Hl():Vl(document.body.dataset.rail!==`closed`))}var Y,nu=L(`#session-list`),ru=L(`#new-session`),iu=e=>e.modified??e.createdAt;function au(e){return{top:e.filter(e=>e.rank!==void 0).sort((e,t)=>(e.rank??0)-(t.rank??0)),rest:e.filter(e=>e.rank===void 0).sort((e,t)=>t.createdAt-e.createdAt)}}function ou(e,t){let{top:n,rest:r}=au(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}function su(e,t,n){let{top:r,rest:i}=au(e),a=[...r,...i];if(!a.length)return;let o=a.findIndex(e=>e.id===t),s=o<0?a[0]:a[(o+n+a.length)%a.length];return s&&s.id!==t?s.id:void 0}var cu=8,lu=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function uu(e){let t=lu(e),n=new Set(t);return t.filter(e=>{let t=e.lastIndexOf(`/`),r=e.indexOf(`.`,t+2);return r<0||!n.has(e.slice(0,r))})}var du=`session-more hidden h-7 w-7 flex-none cursor-pointer items-center justify-center rounded-lg text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`,fu=e=>e.unread,pu=e=>`${e} subagent${e>1?`s`:``} running`;function mu(e){let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:fu(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:e.activeRuns>0?[`bg-sky-500`,pu(e.activeRuns)]:null;if(!t)return[];let n=R(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function hu(e){let t=window.prompt(`Session name — empty resets it to the first message`,e.title??``);if(t===null)return;let n=e.title,r=t=>{e.title=t,Su(),Y.onTitleChanged()};r(t.trim()||void 0),(await b(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var gu=`flex-none text-xs font-medium uppercase leading-5 text-neutral-500`,_u=e=>e.channel&&e.channel!==`web`?[R(`span`,gu,e.channel[0]??``)]:[];function vu(e,t=R(`button`,du,g(p))){let n=e.id===Y.currentId(),r=R(`li`,`flex items-center gap-1 hover:bg-neutral-100 ${n?`bg-indigo-50 hover:bg-indigo-50`:``}`);t.setAttribute(`type`,`button`),t.setAttribute(`aria-label`,`Session actions: ${e.title??`untitled`}`),t.title=`Session actions`,t.onclick=n=>{n.stopPropagation(),Y.sessionMenu(t,e)};let i=R(`button`,`session-open flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-lg text-left`,R(`span`,`min-w-0 flex-1 truncate`,e.title??`untitled`),...mu(e));return i.setAttribute(`type`,`button`),n&&i.setAttribute(`aria-current`,`page`),i.onclick=()=>Y.select(e.id),r.dataset.sessionId=e.id,r.append(i,..._u(e),t),r.title=[e.cwd,`active ${Rr(iu(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
85
- `),r}var yu=()=>`${Y.currentId()??``}\n${xu}\n${JSON.stringify(Y.sessions())}`,bu=``,xu=20;function Su(){let e=yu();if(e===bu)return;bu=e;let t=Y.sessions(),n=t.filter(fu);Xl(n.length),il(n.length);let{rows:r,hidden:i}=ou(t,xu),a=nu.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>vu(e,e.id===o?a:void 0));if(i>0){let e=R(`button`,`session-open w-full cursor-pointer rounded-lg text-left text-sm text-neutral-500`,`Load more (${i})`);e.id=`session-load-more`,e.setAttribute(`type`,`button`),e.onclick=()=>{xu+=20,Su(),nu.querySelectorAll(`.session-open`)[r.length]?.focus()},s.push(R(`li`,`hover:bg-neutral-100`,e))}let c=document.activeElement,l=c?.closest(`[data-session-id]`)?.dataset.sessionId,u=c?.classList.contains(`session-more`)?`.session-more`:`.session-open`;if(nu.replaceChildren(...s.length?[R(`ul`,`pb-1`,...s)]:[R(`p`,`px-3 py-2 text-sm leading-normal text-neutral-500`,`No sessions yet — create one.`)]),l){let e=[...nu.querySelectorAll(`[data-session-id]`)].find(e=>e.dataset.sessionId===l);e?.querySelector(`.session-open`)?.focus({preventScroll:!0}),u===`.session-more`&&e?.querySelector(u)?.focus({preventScroll:!0})}else c?.id===`session-load-more`&&(nu.querySelector(`#session-load-more`)??nu.querySelector(`.session-open`)??L(`#new-session`)).focus({preventScroll:!0});td()}function Cu(){if(ru.getAttribute(`aria-expanded`)===`true`)return q();let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd,t=uu(Y.sessions()).slice(0,cu);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return kl(ru,void 0,Y.createSession);Al(ru,t.map(e=>({path:e,hint:Br(e)})),e,Y.createSession)}function wu(e){Y=e,ru.onclick=Cu,Ks(ru,`shift+o`,`New session`,Cu,Hs);let t=e=>{let t=su(Y.sessions(),Y.currentId(),e);t&&Y.select(t)};Xs(`shift+[`,()=>t(-1),Hs),Xs(`shift+]`,()=>t(1),Hs)}var Tu,Eu=L(`#palette`),Du=L(`#palette-input`),Ou=L(`#palette-list`),ku=L(`#palette-count`),Au=[{name:`tasks`,icon:ie,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,icon:ie,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,icon:ie,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,icon:re,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,icon:me,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],ju=7,Mu=3,Nu=8,Pu=80,Fu=``,Iu,Lu,Ru;function zu(e){Fu!==e&&(clearTimeout(Ru),Lu?.abort(),Lu=void 0,Fu=e,Iu=void 0,e&&(Ru=setTimeout(()=>{let t=Lu=new AbortController;Le(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||Fu!==e||(Lu=void 0,Iu=n.ok?{hits:n.value.hits}:{error:n.error},Eu.open&&ed())})},Pu)))}var Bu=[],Vu=0;function Hu(e){if(Bu.length){Vu=(e+Bu.length)%Bu.length;for(let[e,{el:t}]of Bu.entries())t.classList.toggle(`bg-indigo-50`,e===Vu),t.setAttribute(`aria-selected`,String(e===Vu));Bu[Vu]?.el.scrollIntoView({block:`nearest`})}}var Uu=e=>e.hit?.at??e.session?.createdAt;function Wu(e){let t=R(`span`,`min-w-0 flex-1 truncate text-neutral-500`),[n=``,r=``]=e.replaceAll(/\s+/g,` `).split(``,2),[i=``,a=``]=r.split(``,2);return t.append(n,R(`span`,`font-medium text-neutral-800`,i),a),t}var Gu=`flex min-w-0 flex-1 items-baseline gap-2`,Ku=`shrink-0 truncate`,qu=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,Ju=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,Yu=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function Xu(e){let t=R(`li`,`palette-row flex cursor-pointer items-center gap-3 rounded-[10px] px-2 leading-5 ${e.hit?`py-1.5`:`min-h-10`}`);t.setAttribute(`role`,`option`),t.append(R(`span`,Yu,g(e.icon,`h-4 w-4`)));let n=R(`div`,`flex min-w-0 flex-1 flex-col`),r=R(`div`,`flex items-center gap-2`);e.session&&r.append(...mu(e.session));let i=R(`span`,Gu,R(`span`,`${Ku} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(R(`span`,qu,e.detail)),r.append(i);let a=Uu(e);return a!==void 0&&r.append(R(`span`,Ju,Rr(a))),n.append(r),e.hit&&n.append(R(`div`,`flex items-baseline gap-2 text-[0.8125rem] leading-5`,R(`span`,`flex-none text-[0.75rem] text-neutral-400`,e.hit.role===`user`?`You`:`Agent`),Wu(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var Zu=e=>R(`li`,`px-2 pb-1.5 pt-4 text-[0.6875rem] font-semibold leading-4 tracking-[0.02em] text-neutral-400 first:pt-2`,e);function Qu(e,t){let n=R(`li`,`px-2 py-2 pl-12 text-[0.8125rem] leading-5 text-neutral-400`,e);return t&&(n.title=t),n}var $u=e=>e.channel&&e.channel!==`web`?e.channel:``;function ed(){let e=Du.value.trim(),t=e.toLowerCase(),n=e=>e.toLowerCase().includes(t),r=e=>()=>{Eu.close(),e()},i=Tu.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=au(i),c=[...o,...s],l=e=>({icon:oe,label:e.title??Vr(e.cwd),detail:[Br(e.cwd),$u(e)].filter(Boolean).join(` · `),open:r(()=>void Tu.select(e.id)),session:e}),u=e=>({icon:ne,label:Vr(e),detail:e,open:r(()=>void Tu.createSession(e))}),d=Au.filter(t=>!e||n(`${t.label} ${t.detail}`)).map(({name:e,icon:t,label:n,detail:i})=>({icon:t,label:n,detail:i,open:r(()=>Tu.openConsole(e))})),ee={icon:ne,label:`New session in…`,detail:`Pick a directory`,open:r(Cu)},f=[];if(e){let t=uu(i).filter(e=>n(Br(e))).slice(0,Mu),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${$u(e)}`)).slice(0,Nu),s=new Set(o.map(e=>e.id)),p=o.map(l);if(Fu!==e||!Iu)p.push(Qu(`Searching messages…`));else if(`error`in Iu)p.push(Qu(`Message search unavailable`,Iu.error));else{for(let e of Iu.hits){if(p.length>=Nu)break;let t=a.get(e.sessionId);!t||s.has(t.id)||p.push({...l(t),hit:e,open:r(()=>void Tu.select(t.id).then(()=>No(e.role,e.at)))})}p.length||p.push(Qu(`No sessions match`))}f.push([`Actions`,[...t.map(u),...n(ee.label)?[ee]:[],...d]],[`Sessions`,p])}else{let e=c.filter(e=>e.state===`streaming`),t=a.get(Tu.currentId()??``);f.push([`Running`,e.map(l)],[`Recent`,c.filter(e=>e.state!==`streaming`).slice(0,ju).map(l)],[`Actions`,[...t?[u(t.cwd)]:[],ee]],[`Console`,d])}Bu=[];let p=[];for(let[e,t]of f)if(t.length){p.push(Zu(e));for(let e of t){if(e instanceof HTMLElement){p.push(e);continue}let t=Xu(e);Bu.push({el:t,open:e.open}),p.push(t)}}Ou.replaceChildren(...p.length?p:[Qu(`Nothing matches`)]),ku.textContent=`${Bu.length} ${Bu.length===1?`row`:`rows`}`,Hu(Math.min(Vu,Math.max(0,Bu.length-1)))}function td(){Eu.open&&ed()}function nd(){if(Eu.open)return Eu.close();Du.value=``,Vu=0,zu(``),ed(),Eu.showModal(),Du.focus(),Tu.loadSessions().then(td)}function rd(e){Tu=e;let t=L(`#open-palette`);t.onclick=nd,Ks(t,`k`,`Search sessions, messages and Console`,nd,()=>Eu.open||dl()),Eu.onclick=e=>{e.target===Eu&&Eu.close()},Eu.onclose=()=>zu(``),Du.oninput=()=>{Vu=0,zu(Du.value.trim()),ed()},Du.onkeydown=e=>{let t=fl(e);if(t!==void 0){e.preventDefault(),Hu(Vu+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),Bu[Vu]?.open())}}var id=0,ad=e=>`${e.provider}/${e.id}`,od=null;async function sd(){let{modelMenu:e}=await Re(`/api/settings`,`Could not read the pinned model menu`);return e}function cd(e){let t=R(`button`,`flex w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-100`,g(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`),R(`span`,`truncate`,e.label));return e.hint&&t.append(R(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),e.title&&(t.title=e.title),t.onclick=()=>e.onSelect(),t}function ld({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=n,s=R(`div`,`flex w-full min-w-0 flex-col sm:min-w-72`),c=R(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),u=document.createElement(`input`);if(u.type=`search`,u.placeholder=`Search models`,u.setAttribute(`aria-label`,`Search models`),u.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,c.append(u),r.length){let e=document.createElement(`details`),t=R(`span`,`ml-auto font-medium text-indigo-700`,Se(o)),n=R(`summary`,`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-xl px-3 text-sm text-neutral-700 hover:bg-neutral-100 [&::-webkit-details-marker]:hidden`,R(`span`,`font-medium`,`Reasoning effort`),t,g(l,`chev h-3 w-3 text-neutral-400`)),i=R(`fieldset`,`grid grid-cols-2 gap-1 rounded-xl bg-neutral-50 p-1`);i.append(R(`legend`,`sr-only`,`Reasoning effort`));let s=`reasoning-${++id}`;for(let e of r){let n=document.createElement(`input`);n.type=`radio`,n.name=s,n.value=e,n.checked=e===o,n.className=`peer sr-only`,n.onchange=()=>{n.checked&&(o=e,t.textContent=Se(o),p(u.value),a(o))},i.append(R(`label`,`relative cursor-pointer`,n,R(`span`,`flex min-h-11 items-center rounded-lg border border-transparent px-3 text-sm text-neutral-700 hover:bg-neutral-100 peer-checked:border-indigo-200 peer-checked:bg-indigo-50 peer-checked:font-semibold peer-checked:text-indigo-700 peer-focus-visible:outline-2 peer-focus-visible:outline-indigo-500`,Se(e))))}e.append(n,i),c.append(e)}let d=R(`div`,`max-h-72 overflow-y-auto py-1`),ee=new Map(e.map(e=>[ad(e),e])),f=e=>{let n=(od??[]).map(e=>({e,model:ee.get(ad(e))})).filter(t=>!!t.model&&(!e||ad(t.model).toLowerCase().includes(e)));n.length&&d.append(R(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Pinned`),...n.map(({e,model:n})=>cd({label:n.id,hint:Se(e.thinking),title:e.note,checked:!!t&&ad(t)===ad(n)&&o===e.thinking,onSelect:()=>i(n,e.thinking)})),R(`div`,`my-1 border-t border-neutral-100`))},p=n=>{d.replaceChildren();let r=n.trim().toLowerCase();f(r);let a=new Map;for(let t of e){if(r&&!ad(t).toLowerCase().includes(r))continue;let e=a.get(t.provider);e?e.push(t):a.set(t.provider,[t])}if(!a.size){d.append(R(`div`,`px-3 py-2 text-[12.5px] text-neutral-400`,e.length?`No matching models.`:`No models available.`));return}for(let[e,n]of a){let a=n.some(e=>!!t&&ad(t)===ad(e)),o=document.createElement(`details`);o.open=a||r.length>0;let s=R(`summary`,`flex cursor-pointer select-none items-center gap-1.5 px-3 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400 hover:bg-neutral-100`,g(l,`chev h-3 w-3`),R(`span`,`truncate`,e),R(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>cd({label:e.id,checked:!!t&&ad(t)===ad(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>p(u.value),p(``),sd().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(od);od=e,t&&p(u.value)}).catch(e=>js(`model menu unavailable`,e)),s.append(c,d),queueMicrotask(()=>u.focus()),s}function ud(e,t,n,r){let i=Zr(t.model?`${t.model.id}${t.thinking?` · ${Se(t.thinking)}`:``}`:t.thinking?`Pi default · ${Se(t.thinking)}`:`Pi default`,`${oi} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return i.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,i.onclick=()=>{let e=ld({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Da],onPick:(e,n)=>{q(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>{t={...t,thinking:e},r(t)}}),a=Zr(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);a.onclick=()=>{q(),r({model:null,thinking:null})};let o=R(`div`,`flex flex-col`);o.append(e,R(`div`,`border-t border-neutral-200`),a),bl(i,o)},ai(e,i)}var X;function dd(e){X=e,Xs(fd,()=>{X.currentSession()&&(q(),X.toggleFiles())},Hs)}var fd=`i`,pd=L(`#chat-title`),md=L(`#chat-menu`),hd=L(`#session-meta`),gd=null,_d=new Map,vd=e=>`${e.provider}/${e.id}`,Z=null,yd=null,bd=null,xd=null;function Sd(){Z=null,yd=null,bd=null,xd=null,jd()}function Cd(e,t,n,r){Z=e,yd=t,bd=n,xd=r,Dd()}function wd(e){xd=e.completedAt,yd&&={...yd,tokens:e.tokens},jd()}var Td=null;function Ed(e){Td=e===null?null:Vr(e),Dd()}function Dd(){let e=X.currentSession();e&&(Td=null),pd.textContent=e?e.title??Vr(e.cwd):Td??X.currentId()??`no session`,pd.classList.toggle(`cursor-pointer`,!!e),pd.title=e?`Session info`:``,pd.onclick=e?()=>Md(pd,e):null,md.classList.toggle(`hidden`,!e),e&&(md.onclick=()=>Ld(md,e)),jd(),X.syncBar()}var Od=70,kd=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),Ad=e=>e.tokens===null?`?/${Ce(e.contextWindow)}`:`${Ce(e.tokens)}/${Ce(e.contextWindow)} · ${100-kd(e.tokens,e)}% left`;function jd(){let e=yd,t=e?.tokens??null,n=X.currentId(),r=X.currentSession()?.activeRuns??0,i=[];if(r>0){let e=R(`button`,`flex flex-none cursor-pointer items-center gap-1 rounded bg-sky-50 px-1.5 py-px font-medium text-sky-700 hover:bg-sky-100`,g(m,`spinner h-3 w-3`),`${r} running`);e.title=`${pu(r)} · show the newest`,e.onclick=()=>{Po()||H(`error`,`no run card left in this transcript — reload the session to see it`)},i.push(e)}if(!n&&Td&&i.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,g(m,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=R(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void Nd(r,n),r};Z&&i.push(e(Z.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),bd&&i.push(e(bd,`text-neutral-500 hover:text-indigo-700`))}let a=0;if(e&&t!==null){a=kd(t,e);let n=a>=90?`text-red-700`:a>=Od?`text-amber-700`:`text-neutral-500`;i.push(R(`span`,`flex-none font-mono ${n}`,Ce(t).toLowerCase()))}let o=i.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);hd.replaceChildren(...o),hd.classList.toggle(`hidden`,i.length===0),hd.classList.toggle(`flex`,i.length>0),hd.toggleAttribute(`data-urgent`,!n&&!!Td||r>0||a>=Od)}function Md(e,t,n=!1){let i=[[`Directory`,t.cwd],[`Session`,t.id]],a=t.id===X.currentId();if(a&&(i.push([`Model`,Z?.id??`—`]),i.push([`Reasoning`,bd??`—`]),i.push([`Context`,yd?Ad(yd):`—`])),i.push([`Created`,Hr(t.createdAt),zr(t.createdAt)]),a){let e=xd;i.push(e===null?[`Last reply`,`—`]:[`Last reply`,Hr(e),zr(e)])}let o=R(`div`,`w-[min(26rem,calc(100vw-2rem))] max-sm:w-full rounded-xl bg-white px-3 py-3 font-sans text-[15px] leading-normal`),s=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(ve));s.setAttribute(`aria-label`,`Close session info`),s.onclick=q;let c=R(`div`,`sticky top-0 z-10 flex items-start gap-2 bg-white pb-2`,R(`div`,`min-w-0 flex-1`,R(`div`,`text-sm font-medium text-neutral-500`,`Session info`),R(`h2`,`mt-1 [overflow-wrap:anywhere] text-lg leading-7 font-semibold text-neutral-900`,t.title??Vr(t.cwd))),s);if(n){let n=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(r));n.setAttribute(`aria-label`,`Back to session actions`),n.onclick=()=>Ld(e,t),c.prepend(n)}o.append(c);let l=R(`dl`,``);for(let[e,t,n]of i){let r=e===`Directory`||e===`Session`,i=R(`dd`,`min-w-0 flex items-start gap-2 text-neutral-700 ${r?`font-mono text-sm leading-6`:``}`,R(`span`,`min-w-0 flex-1 [overflow-wrap:anywhere]`,t));if(r){let n=Jr(`min-h-11 min-w-11 sm:min-h-8 shrink-0 cursor-pointer rounded-lg px-2 py-1 text-[13px] font-sans text-neutral-500 hover:bg-neutral-100 focus-visible:outline-2`,()=>t);n.setAttribute(`aria-label`,`Copy ${e.toLowerCase()}`),i.append(n)}n&&i.firstElementChild?.append(R(`span`,`ml-2 inline-block font-sans text-[13px] leading-5 text-neutral-500`,n));let a=e===`Model`||e===`Created`;l.append(R(`div`,`grid gap-1 py-1.5 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3 ${a?`mt-2 border-t border-neutral-200 pt-2.5`:``}`,R(`dt`,`text-[15px] text-neutral-500`,e===`Session`?`Session ID`:e),i))}o.append(l),bl(e,o)}async function Nd(e,t,n){let i=R(`div`,`px-3 py-3 text-[15px] text-neutral-500`,`Loading models…`),a=R(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,i),o=i;if(n){let t=R(`button`,`icon-btn h-11 w-11`,g(r));t.setAttribute(`aria-label`,`Back to session actions`),t.onclick=()=>Ld(e,n);let i=R(`button`,`icon-btn h-11 w-11`,g(ve));i.setAttribute(`aria-label`,`Close model picker`),i.onclick=q;let o=R(`span`,`min-w-0 flex-1 truncate text-sm font-medium`,n.title??Vr(n.cwd));o.title=o.textContent??``,a.prepend(R(`div`,`flex items-center gap-2 border-b border-neutral-200 pb-2 mb-2`,t,o,i))}bl(e,a);let s=()=>o.isConnected&&!o.closest(`[inert]`),c=``,l=(n,r,i)=>{let s=JSON.stringify([n,r,i]);if(s===c)return;c=s;let l=ld({models:n,current:t===X.currentId()?Z:null,thinkingLevel:r,thinkingLevels:i,onPick:(e,n)=>{q(),Pd(t,e,n)},onThinkingPick:e=>void Id(t,e)});o.replaceWith(l),o=l,bl(e,a)},u=t===X.currentId()&&Z?_d.get(vd(Z)):void 0;gd&&u&&bd&&l(gd,bd,u);try{let[e,n]=await Promise.all([Re(`/api/sessions/${t}/models`,`Could not load models`),Re(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(gd=e,t===X.currentId()&&Z&&_d.set(vd(Z),n.levels),!s())return;l(e,n.level,n.levels)}catch(e){c?H(`error`,`model options are stale: ${String(e)}`):s()?(i.textContent=`Could not load models: ${String(e)}`,i.setAttribute(`role`,`alert`)):H(`error`,`model options failed: ${String(e)}`)}}async function Pd(e,t,n){await Fd(e,t)&&n&&await Id(e,n)}async function Fd(e,t){let n=Z;e===X.currentId()&&(Z=t,Dd());let r=await b(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Z=n,Dd()),H(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Z=i,Dd()),!0}async function Id(e,t){let n=await b(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){H(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===X.currentId()&&(bd=r,jd())}function Ld(e,t){let n=t.id===X.currentId();Sl(e,[{label:`Rename…`,onSelect:()=>{q(),hu(t)}},{label:`Session info`,onSelect:()=>Md(e,t,!0)},{label:`New session here`,separatorBefore:!0,hint:Br(t.cwd),onSelect:()=>{q(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Vs(fd):``,onSelect:()=>{q(),X.openFiles(n?void 0:t.cwd)}},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?Z?.id??`…`:``,onSelect:()=>void Nd(e,t.id,t)}],t.title??Vr(t.cwd))}var Rd=`pier.theme`,zd=[`system`,`light`,`dark`],Bd=window.matchMedia(`(prefers-color-scheme: dark)`),Vd={system:ce,light:ge,dark:h},Hd=()=>{let e=null;try{e=localStorage.getItem(Rd)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},Ud=()=>{let e=Hd();return e===`system`?Bd.matches?`dark`:`light`:e};function Wd(){let e=Ud();document.documentElement.dataset.theme=e;let t=getComputedStyle(document.documentElement).getPropertyValue(`--workbench-canvas`).trim();L(`meta[name="theme-color"]`).setAttribute(`content`,t),window.dispatchEvent(new Event(`pier:theme`))}function Gd(){let e=L(`#theme-toggle`),t=()=>{let t=Hd();e.title=`Theme: ${t}${t===`system`?` (${Ud()})`:``}`,e.replaceChildren(g(Vd[t])),e.setAttribute(`aria-label`,e.title),Wd()};e.onclick=()=>{let e=zd[(zd.indexOf(Hd())+1)%zd.length];try{e===`system`?localStorage.removeItem(Rd):localStorage.setItem(Rd,e)}catch{}t()},Bd.addEventListener(`change`,t),t()}var Kd=`https://github.com/timqi/pier`,qd=[`text-neutral-400`,`hover:text-neutral-700`],Jd=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Yd=18e5,Xd=null,Zd=L(`#version`);function Qd(e){let t=Xd?.available===!0&&Xd.latest!==null;Zd.textContent=`v${e}`,Zd.title=t?`Pier ${Xd?.latest} is out`:``,Zd.classList.remove(...t?qd:Jd),Zd.classList.add(...t?Jd:qd)}var $d=(e,t=`px-3 py-1 text-[12px] leading-snug text-neutral-500`)=>R(`p`,t,e);function ef(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Xd)return e.append($d(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Xd,o=R(`span`,``,``),s=(e,t)=>pi(o,e?`failed`:`idle`,t),c=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(e.append($d(r?`Pier ${n} is out`:`Pier ${t}`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`),$d(r?`You are running ${t}.`:n===null?`The registry could not be reached, so this may not be the latest.`:`This is the latest release.`)),a&&e.append($d(a,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`)),r&&i&&!a){let e=Xr(`Update now`,!0);e.onclick=()=>void(async()=>{e.disabled=!0,s(!1,`starting the updater…`);let t=await b(`/api/update`,{});if(!t.ok)return e.disabled=!1,s(!0,await x(t,`Could not update`));let{draining:n}=await t.json();s(!1,n?`Waiting for running work to finish — Pier then installs and restarts.`:`Installing — Pier restarts once it is on disk, and this page reconnects on its own.`)})(),c.append(e)}c.append(Object.assign(R(`a`,`btn text-[12.5px] no-underline`,`Source`),{href:r?`${Kd}/releases`:Kd,target:`_blank`,rel:`noreferrer`,title:`Pier is free software (AGPL-3.0)`})),e.append(c,R(`div`,`px-3`,o)),r&&!i&&!a&&e.append($d(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=di(`Update automatically`,i?`Installs a new release once nothing is running — no turn in flight, no task run.`:`Needs the systemd service (pier service install); nothing here can restart Pier.`,Xd.autoUpdate,e=>void(async()=>{Xd&&(Xd.autoUpdate=e);let t=await b(`/api/settings`,{autoUpdate:e},`PUT`);t.ok||(Xd&&(Xd.autoUpdate=!e),u&&(u.checked=!e),s(!0,await x(t,`Could not save`)))})()),u=l.querySelector(`input`);return u&&(u.disabled=!i),e.append(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function tf(e){let t=await Le(`/api/update`,`Update check failed`);t.ok&&Qd((Xd=t.value).current||e)}function nf(e){Qd(e),Zd.onclick=e=>{e.preventDefault(),bl(Zd,ef())};let t=()=>void tf(e);t(),setInterval(t,Yd)}var Q,rf=L(`#chat-header`),af=L(`#chat-title`),of=[rf,V,L(`#composer`)],sf=()=>mf===null,cf,lf,uf,df=new Map,ff=new Map,pf=new Map,mf=null,hf=0,gf=[`files`],_f=new Map,vf={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},yf=[`tasks`,`runs`,`activity`],bf=`Automation`,xf=L(`#automation-view`),Sf=L(`#automation-tabs`),Cf=e=>yf.includes(e)?`tasks`:e;function wf(e,t){let n=e!==null&&yf.includes(e);if(xf.classList.toggle(`hidden`,!n),xf.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=Xr(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!cf,e.onclick=()=>cf?.create(),r.push(e)}Sf.replaceChildren(Qr(bf),...yf.map(t=>ti(vf[t],t===e,()=>kf(t))),...r)}var Tf=e=>cf?.refresh(e),Ef=()=>lf?.refresh(),Df=()=>uf?.refresh();function Of(){mf?zl(yf.includes(mf)?bf:vf[mf],!1):zl(af.textContent??``,Q.currentSession()!==void 0)}function kf(e,t,n){if(gf.includes(e)){let t=Vf();t&&(t.kind!==`console`||t.name!==e)&&_f.set(e,t)}Uf({kind:`console`,name:e,arg:t,query:n}),Rl(),mf=e;for(let e of of)e.classList.add(`hidden`);bc();for(let[t,n]of df)t!==e&&n.hide();for(let[t,n]of pf)n.classList.toggle(`bg-indigo-50`,t===Cf(e));wf(e,t),Of(),Af(e,t,n,++hf)}async function Af(e,t,n,r){let i=df.get(e);if(!i){let t=ff.get(e);if(!t){let n=L(`#${e}-view`);t=Kf[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),Wr(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${vf[e]} — reload the page.`))))),ff.set(e,t)}i=await t,df.set(e,i),ff.delete(e)}mf===e&&r===hf&&(i.show(t,n),e===`tasks`&&wf(e,t))}var jf=e=>kf(`tasks`,e),Mf=(e={},t)=>kf(`runs`,t,new URLSearchParams(e).toString()),Nf=e=>Mf({},e),Pf=e=>kf(`files`,e),Ff=(e,t)=>{mf===e?Lf(e):kf(e,t)},If=e=>Ff(`files`,e);function Lf(e){let t=Q.currentId(),n=_f.get(e)??(t?{kind:`session`,id:t}:null);_f.delete(e),n?Uf(n):(history.replaceState(null,``,`#/`),Rf())}function Rf(){if(mf){mf=null;for(let e of df.values())e.hide();for(let e of pf.values())e.classList.remove(`bg-indigo-50`);wf(null);for(let e of of)e.classList.remove(`hidden`);bc(),Of(),Q.maybeAckRead()}}var zf=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,Bf={config:`files`,channels:`channels`,providers:`models`};function Vf(){let e=location.hash.replace(/^#\/?/,``),t=e.indexOf(`?`),[n=``,r]=(t<0?e:e.slice(0,t)).split(`/`),i=t<0?void 0:e.slice(t+1)||void 0,a;try{a=r?decodeURIComponent(r):void 0}catch{return null}return Bf[n]?{kind:`console`,name:`settings`,arg:Bf[n]}:Object.hasOwn(vf,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var Hf=!1;function Uf(e,t=!1){if(Hf)return;let n=zf(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var Wf=e=>Uf({kind:`session`,id:e});function Gf(){let e=Vf(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=au(t),o=r??n??(i[0]??a[0])?.id??null;Hf=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?kf(e.name,e.arg,e.query):Rf(),o||Dd()}finally{Hf=!1}e?.kind!==`console`&&o&&Uf({kind:`session`,id:o},!0)}var Kf={tasks:async e=>cf=(await Di(async()=>{let{createTasksView:e}=await import(`./tasks-BlzEbk11.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Q.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Q.loadSessions,Q.select,()=>Q.currentId(),Mf,jf),runs:async e=>lf=(await Di(async()=>{let{createRunsView:e}=await import(`./runs-Cwy0mN8i.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,Mf,jf),activity:async e=>uf=(await Di(async()=>{let{createActivityView:e}=await import(`./activity-B89_hH7q.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,Nf),boards:async e=>(await Di(async()=>{let{createBoardsView:e}=await import(`./boards-BeKW0ZXK.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Di(async()=>{let{createExplorerView:e}=await import(`./explorer-DIuMlaV3.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>kf(`files`,e),()=>Lf(`files`)),settings:async e=>(await Di(async()=>{let{createSettingsView:e}=await import(`./settings-DzZLmujq.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>lu(Q.sessions()),e=>kf(`settings`,e))};function qf(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);pf.set(e,t),t.onclick=()=>kf(e)}let t=L(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Gf}var Jf=[],Yf=null,Xf=0,Zf=0,Qf=!1,$=null,$f=`idle`,ep=null,tp=0,np=!1,rp=!1;async function ip(e){let t=++Xf;++Zf,Qf=!1,Rf(),Rl(),$=null,ep?.close(),ep=null,Ss(),xc([]),Sd(),Ed(e),Cs(!0),rp=!0,yc();let n=await b(`/api/sessions`,{cwd:e});if(t!==Xf)return;if(rp=!1,!n.ok){Cs(!1),Ed(null),yc(),H(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Xf&&(Jf.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await hp(r),$===r&&hc())}function ap(e){Jf=e.map(e=>({...e,title:Fe(e.title)})),Jf.sort((e,t)=>t.createdAt-e.createdAt),Su(),Dd(),sp()}var op=Ie(async()=>{ap(await Re(`/api/sessions`,`Could not load sessions`))});function sp(){if(document.hidden||!document.hasFocus()||!sf())return;let e=Jf.find(e=>e.id===$);e?.unread&&(e.unread=!1,Su(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function cp(){return Jf.find(e=>e.id===$)??(Yf&&Yf.id===$?Yf:void 0)}async function lp(e){let t=await Le(`/api/sessions/${e}`,`failed to load session`);$!==e||!t.ok||(Yf={...t.value,title:Fe(t.value.title)},Dd())}function up(e,t){let n=Jf.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Su(),Dd())}function dp(e){$f=e;let t=Jf.find(e=>e.id===$);t&&(t.state=e),Su(),Dd(),yc(),e===`idle`&&op()}function fp(e){if(!(e.sessionId!==$||e.seq<=tp))switch(tp=e.seq,e.type){case`turn-start`:np=!0;break;case`system-input`:vs(),Go(e.text,e.origin);break;case`task-status`:Ha(e.run);break;case`user-message`:{let t=Me(e.text).text;if(up(e.sessionId,t),gc(t))break;vs(),H(`user`,e.text,!1,e.ts),jo();break}case`text-start`:vs();break;case`text-delta`:_s(e.text);break;case`thinking-delta`:vs(),_o(e.ts,e.text);break;case`tool-start`:vs(),ho(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:go(e.toolCallId,e.isError,e.output);break;case`turn-end`:np=!1,bs(e.text,e.meta),e.meta&&wd(e.meta);break;case`queue-state`:Sc(e.steering,e.followUp);break;case`queue-recovery`:xc(e.batches,e.uncertain);break;case`context-compacted`:vs(),H(`system`,`Context compacted — ${Ce(e.before)} → ${Ce(e.after)}`,!1,e.ts),jo();break;case`error`:po(),H(`error`,e.message);break;case`state`:e.state===`idle`&&np&&(np=!1,xs()),e.state===`idle`&&Sc([],[]),dp(e.state)}}function pp(){let e=new EventSource(`/api/events`);e.onopen=()=>{op(),Tf(),Ef(),Df()},e.onerror=()=>Is(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){op();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){Tf(t.type===`task-run-changed`?t.taskId:void 0),Ef(),Df(),t.type===`task-run-changed`&&op();return}if(Df(),t.sessionId===$)return;let n=Jf.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Su())}}function mp(e,t,n){ep?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>ep===r&&$===e&&n===Zf;r.onmessage=e=>{i()&&fp(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&gp(e)}),r.onerror=()=>{i()&&Is(r,`Session`)},ep=r}async function hp(e){Rf(),Rl(),Wf(e),!(e===$&&(ep||Qf))&&(++Xf,++Zf,rp=!1,Mc(),$=e,Yf=null,Jf.some(t=>t.id===e)||lp(e),$f=Jf.find(t=>t.id===e)?.state??`idle`,Nc(e),Su(),Dd(),sp(),await gp(e))}async function gp(e){if($!==e)return;let t=++Zf;ep?.close(),ep=null,Qf=!0,Ss(),Sc([],[]),xc([]),Sd(),np=!1,vc(),tp=0,Cs(!0);let n=await Le(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==Zf)return;if(Qf=!1,!n.ok){Cs(!1),H(`error`,n.error);return}let r=n.value;ws(r.turns,r.state,r.backgroundRuns),tp=r.lastSeq,np=r.state===`streaming`,dp(r.state),Sc(r.queue.steering,r.queue.followUp),xc(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Cd(r.model,r.context,r.thinkingLevel,i),mp(e,`${r.epoch}:${r.lastSeq}`,t)}Ms(),ye(),Fs(),Gd();var _p=async e=>{$===e&&await gp(e)};Co({sessionId:()=>$,sessionState:()=>$f,select:e=>void hp(e),showRun:Nf,send:(e,t)=>void Ic(e,t),ownTurn:e=>{_c(e),dp(`streaming`)},reload:_p}),zc({sessionId:()=>$,starting:()=>rp,sessionState:()=>$f,chatVisible:sf,setState:dp,reload:_p}),tu({sessionMenu:e=>{let t=cp();t&&Ld(e,t)},sessionInfo:e=>{let t=cp();t&&Md(e,t)}}),wu({sessions:()=>Jf,currentId:()=>$,select:e=>void hp(e),sessionMenu:Ld,createSession:ip,onTitleChanged:Dd}),rd({sessions:()=>Jf,loadSessions:op,currentId:()=>$,select:hp,createSession:ip,openConsole:kf}),dd({currentId:()=>$,currentSession:cp,createSession:e=>void ip(e),syncBar:Of,openFiles:Pf,toggleFiles:If}),qf({sessions:()=>Jf,loadSessions:op,currentId:()=>$,currentSession:cp,select:e=>void hp(e),maybeAckRead:sp}),nf(`0.1.1`),el(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,sp),window.addEventListener(`focus`,sp),pp(),op().then(Gf);export{g as $,pi as A,Yr as B,ai as C,ti as D,Qr as E,_i as F,Ie as G,R as H,zr as I,Re as J,x as K,Br as L,ui as M,di as N,ei as O,$r as P,Se as Q,Wr as R,hi as S,ci as T,Rr as U,Ur as V,Vr as W,b as X,ze as Y,Fe as Z,fi as _,q as a,a as at,Xr as b,Ys as c,Li as d,ve as et,Ii as f,ri as g,ni as h,Al as i,o as it,si as j,li as k,Da as l,oi as m,ld as n,m as nt,bl as o,Ni as p,Le as q,Nl as r,l as rt,al as s,ud as t,de as tt,Oa as u,mi as v,gi as w,ii as x,Zr as y,Jr as z};
85
+ `),r}var yu=()=>`${Y.currentId()??``}\n${xu}\n${JSON.stringify(Y.sessions())}`,bu=``,xu=20;function Su(){let e=yu();if(e===bu)return;bu=e;let t=Y.sessions(),n=t.filter(fu);Xl(n.length),il(n.length);let{rows:r,hidden:i}=ou(t,xu),a=nu.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>vu(e,e.id===o?a:void 0));if(i>0){let e=R(`button`,`session-open w-full cursor-pointer rounded-lg text-left text-sm text-neutral-500`,`Load more (${i})`);e.id=`session-load-more`,e.setAttribute(`type`,`button`),e.onclick=()=>{xu+=20,Su(),nu.querySelectorAll(`.session-open`)[r.length]?.focus()},s.push(R(`li`,`hover:bg-neutral-100`,e))}let c=document.activeElement,l=c?.closest(`[data-session-id]`)?.dataset.sessionId,u=c?.classList.contains(`session-more`)?`.session-more`:`.session-open`;if(nu.replaceChildren(...s.length?[R(`ul`,`pb-1`,...s)]:[R(`p`,`px-3 py-2 text-sm leading-normal text-neutral-500`,`No sessions yet — create one.`)]),l){let e=[...nu.querySelectorAll(`[data-session-id]`)].find(e=>e.dataset.sessionId===l);e?.querySelector(`.session-open`)?.focus({preventScroll:!0}),u===`.session-more`&&e?.querySelector(u)?.focus({preventScroll:!0})}else c?.id===`session-load-more`&&(nu.querySelector(`#session-load-more`)??nu.querySelector(`.session-open`)??L(`#new-session`)).focus({preventScroll:!0});td()}function Cu(){if(ru.getAttribute(`aria-expanded`)===`true`)return q();let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd,t=uu(Y.sessions()).slice(0,cu);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return kl(ru,void 0,Y.createSession);Al(ru,t.map(e=>({path:e,hint:Br(e)})),e,Y.createSession)}function wu(e){Y=e,ru.onclick=Cu,Ks(ru,`shift+o`,`New session`,Cu,Hs);let t=e=>{let t=su(Y.sessions(),Y.currentId(),e);t&&Y.select(t)};Xs(`shift+[`,()=>t(-1),Hs),Xs(`shift+]`,()=>t(1),Hs)}var Tu,Eu=L(`#palette`),Du=L(`#palette-input`),Ou=L(`#palette-list`),ku=L(`#palette-count`),Au=[{name:`tasks`,icon:ie,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,icon:ie,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,icon:ie,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,icon:re,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,icon:me,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],ju=7,Mu=3,Nu=8,Pu=80,Fu=``,Iu,Lu,Ru;function zu(e){Fu!==e&&(clearTimeout(Ru),Lu?.abort(),Lu=void 0,Fu=e,Iu=void 0,e&&(Ru=setTimeout(()=>{let t=Lu=new AbortController;Le(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||Fu!==e||(Lu=void 0,Iu=n.ok?{hits:n.value.hits}:{error:n.error},Eu.open&&ed())})},Pu)))}var Bu=[],Vu=0;function Hu(e){if(Bu.length){Vu=(e+Bu.length)%Bu.length;for(let[e,{el:t}]of Bu.entries())t.classList.toggle(`bg-indigo-50`,e===Vu),t.setAttribute(`aria-selected`,String(e===Vu));Bu[Vu]?.el.scrollIntoView({block:`nearest`})}}var Uu=e=>e.hit?.at??e.session?.createdAt;function Wu(e){let t=R(`span`,`min-w-0 flex-1 truncate text-neutral-500`),[n=``,r=``]=e.replaceAll(/\s+/g,` `).split(``,2),[i=``,a=``]=r.split(``,2);return t.append(n,R(`span`,`font-medium text-neutral-800`,i),a),t}var Gu=`flex min-w-0 flex-1 items-baseline gap-2`,Ku=`shrink-0 truncate`,qu=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,Ju=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,Yu=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function Xu(e){let t=R(`li`,`palette-row flex cursor-pointer items-center gap-3 rounded-[10px] px-2 leading-5 ${e.hit?`py-1.5`:`min-h-10`}`);t.setAttribute(`role`,`option`),t.append(R(`span`,Yu,g(e.icon,`h-4 w-4`)));let n=R(`div`,`flex min-w-0 flex-1 flex-col`),r=R(`div`,`flex items-center gap-2`);e.session&&r.append(...mu(e.session));let i=R(`span`,Gu,R(`span`,`${Ku} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(R(`span`,qu,e.detail)),r.append(i);let a=Uu(e);return a!==void 0&&r.append(R(`span`,Ju,Rr(a))),n.append(r),e.hit&&n.append(R(`div`,`flex items-baseline gap-2 text-[0.8125rem] leading-5`,R(`span`,`flex-none text-[0.75rem] text-neutral-400`,e.hit.role===`user`?`You`:`Agent`),Wu(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var Zu=e=>R(`li`,`px-2 pb-1.5 pt-4 text-[0.6875rem] font-semibold leading-4 tracking-[0.02em] text-neutral-400 first:pt-2`,e);function Qu(e,t){let n=R(`li`,`px-2 py-2 pl-12 text-[0.8125rem] leading-5 text-neutral-400`,e);return t&&(n.title=t),n}var $u=e=>e.channel&&e.channel!==`web`?e.channel:``;function ed(){let e=Du.value.trim(),t=e.toLowerCase(),n=e=>e.toLowerCase().includes(t),r=e=>()=>{Eu.close(),e()},i=Tu.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=au(i),c=[...o,...s],l=e=>({icon:oe,label:e.title??Vr(e.cwd),detail:[Br(e.cwd),$u(e)].filter(Boolean).join(` · `),open:r(()=>void Tu.select(e.id)),session:e}),u=e=>({icon:ne,label:Vr(e),detail:e,open:r(()=>void Tu.createSession(e))}),d=Au.filter(t=>!e||n(`${t.label} ${t.detail}`)).map(({name:e,icon:t,label:n,detail:i})=>({icon:t,label:n,detail:i,open:r(()=>Tu.openConsole(e))})),ee={icon:ne,label:`New session in…`,detail:`Pick a directory`,open:r(Cu)},f=[];if(e){let t=uu(i).filter(e=>n(Br(e))).slice(0,Mu),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${$u(e)}`)).slice(0,Nu),s=new Set(o.map(e=>e.id)),p=o.map(l);if(Fu!==e||!Iu)p.push(Qu(`Searching messages…`));else if(`error`in Iu)p.push(Qu(`Message search unavailable`,Iu.error));else{for(let e of Iu.hits){if(p.length>=Nu)break;let t=a.get(e.sessionId);!t||s.has(t.id)||p.push({...l(t),hit:e,open:r(()=>void Tu.select(t.id).then(()=>No(e.role,e.at)))})}p.length||p.push(Qu(`No sessions match`))}f.push([`Actions`,[...t.map(u),...n(ee.label)?[ee]:[],...d]],[`Sessions`,p])}else{let e=c.filter(e=>e.state===`streaming`),t=a.get(Tu.currentId()??``);f.push([`Running`,e.map(l)],[`Recent`,c.filter(e=>e.state!==`streaming`).slice(0,ju).map(l)],[`Actions`,[...t?[u(t.cwd)]:[],ee]],[`Console`,d])}Bu=[];let p=[];for(let[e,t]of f)if(t.length){p.push(Zu(e));for(let e of t){if(e instanceof HTMLElement){p.push(e);continue}let t=Xu(e);Bu.push({el:t,open:e.open}),p.push(t)}}Ou.replaceChildren(...p.length?p:[Qu(`Nothing matches`)]),ku.textContent=`${Bu.length} ${Bu.length===1?`row`:`rows`}`,Hu(Math.min(Vu,Math.max(0,Bu.length-1)))}function td(){Eu.open&&ed()}function nd(){if(Eu.open)return Eu.close();Du.value=``,Vu=0,zu(``),ed(),Eu.showModal(),Du.focus(),Tu.loadSessions().then(td)}function rd(e){Tu=e;let t=L(`#open-palette`);t.onclick=nd,Ks(t,`k`,`Search sessions, messages and Console`,nd,()=>Eu.open||dl()),Eu.onclick=e=>{e.target===Eu&&Eu.close()},Eu.onclose=()=>zu(``),Du.oninput=()=>{Vu=0,zu(Du.value.trim()),ed()},Du.onkeydown=e=>{let t=fl(e);if(t!==void 0){e.preventDefault(),Hu(Vu+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),Bu[Vu]?.open())}}var id=0,ad=e=>`${e.provider}/${e.id}`,od=null;async function sd(){let{modelMenu:e}=await Re(`/api/settings`,`Could not read the pinned model menu`);return e}function cd(e){let t=R(`button`,`flex w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-100`,g(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`),R(`span`,`truncate`,e.label));return e.hint&&t.append(R(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),e.title&&(t.title=e.title),t.onclick=()=>e.onSelect(),t}function ld({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=n,s=R(`div`,`flex w-full min-w-0 flex-col sm:min-w-72`),c=R(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),u=document.createElement(`input`);if(u.type=`search`,u.placeholder=`Search models`,u.setAttribute(`aria-label`,`Search models`),u.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,c.append(u),r.length){let e=document.createElement(`details`),t=R(`span`,`ml-auto font-medium text-indigo-700`,Se(o)),n=R(`summary`,`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-xl px-3 text-sm text-neutral-700 hover:bg-neutral-100 [&::-webkit-details-marker]:hidden`,R(`span`,`font-medium`,`Reasoning effort`),t,g(l,`chev h-3 w-3 text-neutral-400`)),i=R(`fieldset`,`grid grid-cols-2 gap-1 rounded-xl bg-neutral-50 p-1`);i.append(R(`legend`,`sr-only`,`Reasoning effort`));let s=`reasoning-${++id}`;for(let e of r){let n=document.createElement(`input`);n.type=`radio`,n.name=s,n.value=e,n.checked=e===o,n.className=`peer sr-only`,n.onchange=()=>{n.checked&&(o=e,t.textContent=Se(o),p(u.value),a(o))},i.append(R(`label`,`relative cursor-pointer`,n,R(`span`,`flex min-h-11 items-center rounded-lg border border-transparent px-3 text-sm text-neutral-700 hover:bg-neutral-100 peer-checked:border-indigo-200 peer-checked:bg-indigo-50 peer-checked:font-semibold peer-checked:text-indigo-700 peer-focus-visible:outline-2 peer-focus-visible:outline-indigo-500`,Se(e))))}e.append(n,i),c.append(e)}let d=R(`div`,`max-h-72 overflow-y-auto py-1`),ee=new Map(e.map(e=>[ad(e),e])),f=e=>{let n=(od??[]).map(e=>({e,model:ee.get(ad(e))})).filter(t=>!!t.model&&(!e||ad(t.model).toLowerCase().includes(e)));n.length&&d.append(R(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Pinned`),...n.map(({e,model:n})=>cd({label:n.id,hint:Se(e.thinking),title:e.note,checked:!!t&&ad(t)===ad(n)&&o===e.thinking,onSelect:()=>i(n,e.thinking)})),R(`div`,`my-1 border-t border-neutral-100`))},p=n=>{d.replaceChildren();let r=n.trim().toLowerCase();f(r);let a=new Map;for(let t of e){if(r&&!ad(t).toLowerCase().includes(r))continue;let e=a.get(t.provider);e?e.push(t):a.set(t.provider,[t])}if(!a.size){d.append(R(`div`,`px-3 py-2 text-[12.5px] text-neutral-400`,e.length?`No matching models.`:`No models available.`));return}for(let[e,n]of a){let a=n.some(e=>!!t&&ad(t)===ad(e)),o=document.createElement(`details`);o.open=a||r.length>0;let s=R(`summary`,`flex cursor-pointer select-none items-center gap-1.5 px-3 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400 hover:bg-neutral-100`,g(l,`chev h-3 w-3`),R(`span`,`truncate`,e),R(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>cd({label:e.id,checked:!!t&&ad(t)===ad(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>p(u.value),p(``),sd().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(od);od=e,t&&p(u.value)}).catch(e=>js(`model menu unavailable`,e)),s.append(c,d),queueMicrotask(()=>u.focus()),s}function ud(e,t,n,r){let i=Zr(t.model?`${t.model.id}${t.thinking?` · ${Se(t.thinking)}`:``}`:t.thinking?`Pi default · ${Se(t.thinking)}`:`Pi default`,`${oi} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return i.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,i.onclick=()=>{let e=ld({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Da],onPick:(e,n)=>{q(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>{t={...t,thinking:e},r(t)}}),a=Zr(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);a.onclick=()=>{q(),r({model:null,thinking:null})};let o=R(`div`,`flex flex-col`);o.append(e,R(`div`,`border-t border-neutral-200`),a),bl(i,o)},ai(e,i)}var X;function dd(e){X=e,Xs(fd,()=>{X.currentSession()&&(q(),X.toggleFiles())},Hs)}var fd=`i`,pd=L(`#chat-title`),md=L(`#chat-menu`),hd=L(`#session-meta`),gd=null,_d=new Map,vd=e=>`${e.provider}/${e.id}`,Z=null,yd=null,bd=null,xd=null;function Sd(){Z=null,yd=null,bd=null,xd=null,jd()}function Cd(e,t,n,r){Z=e,yd=t,bd=n,xd=r,Dd()}function wd(e){xd=e.completedAt,yd&&={...yd,tokens:e.tokens},jd()}var Td=null;function Ed(e){Td=e===null?null:Vr(e),Dd()}function Dd(){let e=X.currentSession();e&&(Td=null),pd.textContent=e?e.title??Vr(e.cwd):Td??X.currentId()??`no session`,pd.classList.toggle(`cursor-pointer`,!!e),pd.title=e?`Session info`:``,pd.onclick=e?()=>Md(pd,e):null,md.classList.toggle(`hidden`,!e),e&&(md.onclick=()=>Ld(md,e)),jd(),X.syncBar()}var Od=70,kd=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),Ad=e=>e.tokens===null?`?/${Ce(e.contextWindow)}`:`${Ce(e.tokens)}/${Ce(e.contextWindow)} · ${100-kd(e.tokens,e)}% left`;function jd(){let e=yd,t=e?.tokens??null,n=X.currentId(),r=X.currentSession()?.activeRuns??0,i=[];if(r>0){let e=R(`button`,`flex flex-none cursor-pointer items-center gap-1 rounded bg-sky-50 px-1.5 py-px font-medium text-sky-700 hover:bg-sky-100`,g(m,`spinner h-3 w-3`),`${r} running`);e.title=`${pu(r)} · show the newest`,e.onclick=()=>{Po()||H(`error`,`no run card left in this transcript — reload the session to see it`)},i.push(e)}if(!n&&Td&&i.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,g(m,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=R(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void Nd(r,n),r};Z&&i.push(e(Z.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),bd&&i.push(e(bd,`text-neutral-500 hover:text-indigo-700`))}let a=0;if(e&&t!==null){a=kd(t,e);let n=a>=90?`text-red-700`:a>=Od?`text-amber-700`:`text-neutral-500`;i.push(R(`span`,`flex-none font-mono ${n}`,Ce(t).toLowerCase()))}let o=i.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);hd.replaceChildren(...o),hd.classList.toggle(`hidden`,i.length===0),hd.classList.toggle(`flex`,i.length>0),hd.toggleAttribute(`data-urgent`,!n&&!!Td||r>0||a>=Od)}function Md(e,t,n=!1){let i=[[`Directory`,t.cwd],[`Session`,t.id]],a=t.id===X.currentId();if(a&&(i.push([`Model`,Z?.id??`—`]),i.push([`Reasoning`,bd??`—`]),i.push([`Context`,yd?Ad(yd):`—`])),i.push([`Created`,Hr(t.createdAt),zr(t.createdAt)]),a){let e=xd;i.push(e===null?[`Last reply`,`—`]:[`Last reply`,Hr(e),zr(e)])}let o=R(`div`,`w-[min(26rem,calc(100vw-2rem))] max-sm:w-full rounded-xl bg-white px-3 py-3 font-sans text-[15px] leading-normal`),s=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(ve));s.setAttribute(`aria-label`,`Close session info`),s.onclick=q;let c=R(`div`,`sticky top-0 z-10 flex items-start gap-2 bg-white pb-2`,R(`div`,`min-w-0 flex-1`,R(`div`,`text-sm font-medium text-neutral-500`,`Session info`),R(`h2`,`mt-1 [overflow-wrap:anywhere] text-lg leading-7 font-semibold text-neutral-900`,t.title??Vr(t.cwd))),s);if(n){let n=R(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,g(r));n.setAttribute(`aria-label`,`Back to session actions`),n.onclick=()=>Ld(e,t),c.prepend(n)}o.append(c);let l=R(`dl`,``);for(let[e,t,n]of i){let r=e===`Directory`||e===`Session`,i=R(`dd`,`min-w-0 flex items-start gap-2 text-neutral-700 ${r?`font-mono text-sm leading-6`:``}`,R(`span`,`min-w-0 flex-1 [overflow-wrap:anywhere]`,t));if(r){let n=Jr(`min-h-11 min-w-11 sm:min-h-8 shrink-0 cursor-pointer rounded-lg px-2 py-1 text-[13px] font-sans text-neutral-500 hover:bg-neutral-100 focus-visible:outline-2`,()=>t);n.setAttribute(`aria-label`,`Copy ${e.toLowerCase()}`),i.append(n)}n&&i.firstElementChild?.append(R(`span`,`ml-2 inline-block font-sans text-[13px] leading-5 text-neutral-500`,n));let a=e===`Model`||e===`Created`;l.append(R(`div`,`grid gap-1 py-1.5 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3 ${a?`mt-2 border-t border-neutral-200 pt-2.5`:``}`,R(`dt`,`text-[15px] text-neutral-500`,e===`Session`?`Session ID`:e),i))}o.append(l),bl(e,o)}async function Nd(e,t,n){let i=R(`div`,`px-3 py-3 text-[15px] text-neutral-500`,`Loading models…`),a=R(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,i),o=i;if(n){let t=R(`button`,`icon-btn h-11 w-11`,g(r));t.setAttribute(`aria-label`,`Back to session actions`),t.onclick=()=>Ld(e,n);let i=R(`button`,`icon-btn h-11 w-11`,g(ve));i.setAttribute(`aria-label`,`Close model picker`),i.onclick=q;let o=R(`span`,`min-w-0 flex-1 truncate text-sm font-medium`,n.title??Vr(n.cwd));o.title=o.textContent??``,a.prepend(R(`div`,`flex items-center gap-2 border-b border-neutral-200 pb-2 mb-2`,t,o,i))}bl(e,a);let s=()=>o.isConnected&&!o.closest(`[inert]`),c=``,l=(n,r,i)=>{let s=JSON.stringify([n,r,i]);if(s===c)return;c=s;let l=ld({models:n,current:t===X.currentId()?Z:null,thinkingLevel:r,thinkingLevels:i,onPick:(e,n)=>{q(),Pd(t,e,n)},onThinkingPick:e=>void Id(t,e)});o.replaceWith(l),o=l,bl(e,a)},u=t===X.currentId()&&Z?_d.get(vd(Z)):void 0;gd&&u&&bd&&l(gd,bd,u);try{let[e,n]=await Promise.all([Re(`/api/sessions/${t}/models`,`Could not load models`),Re(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(gd=e,t===X.currentId()&&Z&&_d.set(vd(Z),n.levels),!s())return;l(e,n.level,n.levels)}catch(e){c?H(`error`,`model options are stale: ${String(e)}`):s()?(i.textContent=`Could not load models: ${String(e)}`,i.setAttribute(`role`,`alert`)):H(`error`,`model options failed: ${String(e)}`)}}async function Pd(e,t,n){await Fd(e,t)&&n&&await Id(e,n)}async function Fd(e,t){let n=Z;e===X.currentId()&&(Z=t,Dd());let r=await b(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Z=n,Dd()),H(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Z=i,Dd()),!0}async function Id(e,t){let n=await b(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){H(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===X.currentId()&&(bd=r,jd())}function Ld(e,t){let n=t.id===X.currentId();Sl(e,[{label:`Rename…`,onSelect:()=>{q(),hu(t)}},{label:`Session info`,onSelect:()=>Md(e,t,!0)},{label:`New session here`,separatorBefore:!0,hint:Br(t.cwd),onSelect:()=>{q(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Vs(fd):``,onSelect:()=>{q(),X.openFiles(n?void 0:t.cwd)}},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?Z?.id??`…`:``,onSelect:()=>void Nd(e,t.id,t)}],t.title??Vr(t.cwd))}var Rd=`pier.theme`,zd=[`system`,`light`,`dark`],Bd=window.matchMedia(`(prefers-color-scheme: dark)`),Vd={system:ce,light:ge,dark:h},Hd=()=>{let e=null;try{e=localStorage.getItem(Rd)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},Ud=()=>{let e=Hd();return e===`system`?Bd.matches?`dark`:`light`:e};function Wd(){let e=Ud();document.documentElement.dataset.theme=e;let t=getComputedStyle(document.documentElement).getPropertyValue(`--workbench-canvas`).trim();L(`meta[name="theme-color"]`).setAttribute(`content`,t),window.dispatchEvent(new Event(`pier:theme`))}function Gd(){let e=L(`#theme-toggle`),t=()=>{let t=Hd();e.title=`Theme: ${t}${t===`system`?` (${Ud()})`:``}`,e.replaceChildren(g(Vd[t])),e.setAttribute(`aria-label`,e.title),Wd()};e.onclick=()=>{let e=zd[(zd.indexOf(Hd())+1)%zd.length];try{e===`system`?localStorage.removeItem(Rd):localStorage.setItem(Rd,e)}catch{}t()},Bd.addEventListener(`change`,t),t()}var Kd=`https://github.com/timqi/pier`,qd=[`text-neutral-400`,`hover:text-neutral-700`],Jd=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Yd=18e5,Xd=null,Zd=L(`#version`);function Qd(e){let t=Xd?.available===!0&&Xd.latest!==null;Zd.textContent=`v${e}`,Zd.title=t?`Pier ${Xd?.latest} is out`:``,Zd.classList.remove(...t?qd:Jd),Zd.classList.add(...t?Jd:qd)}var $d=(e,t=`px-3 py-1 text-[12px] leading-snug text-neutral-500`)=>R(`p`,t,e);function ef(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Xd)return e.append($d(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Xd,o=R(`span`,``,``),s=(e,t)=>pi(o,e?`failed`:`idle`,t),c=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(e.append($d(r?`Pier ${n} is out`:`Pier ${t}`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`),$d(r?`You are running ${t}.`:n===null?`The registry could not be reached, so this may not be the latest.`:`This is the latest release.`)),a&&e.append($d(a,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`)),r&&i&&!a){let e=Xr(`Update now`,!0);e.onclick=()=>void(async()=>{e.disabled=!0,s(!1,`starting the updater…`);let t=await b(`/api/update`,{});if(!t.ok)return e.disabled=!1,s(!0,await x(t,`Could not update`));let{draining:n}=await t.json();s(!1,n?`Waiting for running work to finish — Pier then installs and restarts.`:`Installing — Pier restarts once it is on disk, and this page reconnects on its own.`)})(),c.append(e)}c.append(Object.assign(R(`a`,`btn text-[12.5px] no-underline`,`Source`),{href:r?`${Kd}/releases`:Kd,target:`_blank`,rel:`noreferrer`,title:`Pier is free software (AGPL-3.0)`})),e.append(c,R(`div`,`px-3`,o)),r&&!i&&!a&&e.append($d(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=di(`Update automatically`,i?`Installs a new release once nothing is running — no turn in flight, no task run.`:`Needs the systemd service (pier service install); nothing here can restart Pier.`,Xd.autoUpdate,e=>void(async()=>{Xd&&(Xd.autoUpdate=e);let t=await b(`/api/settings`,{autoUpdate:e},`PUT`);t.ok||(Xd&&(Xd.autoUpdate=!e),u&&(u.checked=!e),s(!0,await x(t,`Could not save`)))})()),u=l.querySelector(`input`);return u&&(u.disabled=!i),e.append(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function tf(e){let t=await Le(`/api/update`,`Update check failed`);t.ok&&Qd((Xd=t.value).current||e)}function nf(e){Qd(e),Zd.onclick=e=>{e.preventDefault(),bl(Zd,ef())};let t=()=>void tf(e);t(),setInterval(t,Yd)}var Q,rf=L(`#chat-header`),af=L(`#chat-title`),of=[rf,V,L(`#composer`)],sf=()=>mf===null,cf,lf,uf,df=new Map,ff=new Map,pf=new Map,mf=null,hf=0,gf=[`files`],_f=new Map,vf={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},yf=[`tasks`,`runs`,`activity`],bf=`Automation`,xf=L(`#automation-view`),Sf=L(`#automation-tabs`),Cf=e=>yf.includes(e)?`tasks`:e;function wf(e,t){let n=e!==null&&yf.includes(e);if(xf.classList.toggle(`hidden`,!n),xf.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=Xr(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!cf,e.onclick=()=>cf?.create(),r.push(e)}Sf.replaceChildren(Qr(bf),...yf.map(t=>ti(vf[t],t===e,()=>kf(t))),...r)}var Tf=e=>cf?.refresh(e),Ef=()=>lf?.refresh(),Df=()=>uf?.refresh();function Of(){mf?zl(yf.includes(mf)?bf:vf[mf],!1):zl(af.textContent??``,Q.currentSession()!==void 0)}function kf(e,t,n){if(gf.includes(e)){let t=Vf();t&&(t.kind!==`console`||t.name!==e)&&_f.set(e,t)}Uf({kind:`console`,name:e,arg:t,query:n}),Rl(),mf=e;for(let e of of)e.classList.add(`hidden`);bc();for(let[t,n]of df)t!==e&&n.hide();for(let[t,n]of pf)n.classList.toggle(`bg-indigo-50`,t===Cf(e));wf(e,t),Of(),Af(e,t,n,++hf)}async function Af(e,t,n,r){let i=df.get(e);if(!i){let t=ff.get(e);if(!t){let n=L(`#${e}-view`);t=Kf[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),Wr(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${vf[e]} — reload the page.`))))),ff.set(e,t)}i=await t,df.set(e,i),ff.delete(e)}mf===e&&r===hf&&(i.show(t,n),e===`tasks`&&wf(e,t))}var jf=e=>kf(`tasks`,e),Mf=(e={},t)=>kf(`runs`,t,new URLSearchParams(e).toString()),Nf=e=>Mf({},e),Pf=e=>kf(`files`,e),Ff=(e,t)=>{mf===e?Lf(e):kf(e,t)},If=e=>Ff(`files`,e);function Lf(e){let t=Q.currentId(),n=_f.get(e)??(t?{kind:`session`,id:t}:null);_f.delete(e),n?Uf(n):(history.replaceState(null,``,`#/`),Rf())}function Rf(){if(mf){mf=null;for(let e of df.values())e.hide();for(let e of pf.values())e.classList.remove(`bg-indigo-50`);wf(null);for(let e of of)e.classList.remove(`hidden`);bc(),Of(),Q.maybeAckRead()}}var zf=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,Bf={config:`files`,channels:`channels`,providers:`models`};function Vf(){let e=location.hash.replace(/^#\/?/,``),t=e.indexOf(`?`),[n=``,r]=(t<0?e:e.slice(0,t)).split(`/`),i=t<0?void 0:e.slice(t+1)||void 0,a;try{a=r?decodeURIComponent(r):void 0}catch{return null}return Bf[n]?{kind:`console`,name:`settings`,arg:Bf[n]}:Object.hasOwn(vf,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var Hf=!1;function Uf(e,t=!1){if(Hf)return;let n=zf(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var Wf=e=>Uf({kind:`session`,id:e});function Gf(){let e=Vf(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=au(t),o=r??n??(i[0]??a[0])?.id??null;Hf=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?kf(e.name,e.arg,e.query):Rf(),o||Dd()}finally{Hf=!1}e?.kind!==`console`&&o&&Uf({kind:`session`,id:o},!0)}var Kf={tasks:async e=>cf=(await Di(async()=>{let{createTasksView:e}=await import(`./tasks-BffPVgXg.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Q.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Q.loadSessions,Q.select,()=>Q.currentId(),Mf,jf),runs:async e=>lf=(await Di(async()=>{let{createRunsView:e}=await import(`./runs-Cv0A-e08.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,Mf,jf),activity:async e=>uf=(await Di(async()=>{let{createActivityView:e}=await import(`./activity-DOr8dWeX.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,Nf),boards:async e=>(await Di(async()=>{let{createBoardsView:e}=await import(`./boards-CneyR23E.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Di(async()=>{let{createExplorerView:e}=await import(`./explorer-D0srXT1c.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>kf(`files`,e),()=>Lf(`files`)),settings:async e=>(await Di(async()=>{let{createSettingsView:e}=await import(`./settings-VmCjhGBd.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>lu(Q.sessions()),e=>kf(`settings`,e))};function qf(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);pf.set(e,t),t.onclick=()=>kf(e)}let t=L(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Gf}var Jf=[],Yf=null,Xf=0,Zf=0,Qf=!1,$=null,$f=`idle`,ep=null,tp=0,np=!1,rp=!1;async function ip(e){let t=++Xf;++Zf,Qf=!1,Rf(),Rl(),$=null,ep?.close(),ep=null,Ss(),xc([]),Sd(),Ed(e),Cs(!0),rp=!0,yc();let n=await b(`/api/sessions`,{cwd:e});if(t!==Xf)return;if(rp=!1,!n.ok){Cs(!1),Ed(null),yc(),H(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Xf&&(Jf.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await hp(r),$===r&&hc())}function ap(e){Jf=e.map(e=>({...e,title:Fe(e.title)})),Jf.sort((e,t)=>t.createdAt-e.createdAt),Su(),Dd(),sp()}var op=Ie(async()=>{ap(await Re(`/api/sessions`,`Could not load sessions`))});function sp(){if(document.hidden||!document.hasFocus()||!sf())return;let e=Jf.find(e=>e.id===$);e?.unread&&(e.unread=!1,Su(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function cp(){return Jf.find(e=>e.id===$)??(Yf&&Yf.id===$?Yf:void 0)}async function lp(e){let t=await Le(`/api/sessions/${e}`,`failed to load session`);$!==e||!t.ok||(Yf={...t.value,title:Fe(t.value.title)},Dd())}function up(e,t){let n=Jf.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Su(),Dd())}function dp(e){$f=e;let t=Jf.find(e=>e.id===$);t&&(t.state=e),Su(),Dd(),yc(),e===`idle`&&op()}function fp(e){if(!(e.sessionId!==$||e.seq<=tp))switch(tp=e.seq,e.type){case`turn-start`:np=!0;break;case`system-input`:vs(),Go(e.text,e.origin);break;case`task-status`:Ha(e.run);break;case`user-message`:{let t=Me(e.text).text;if(up(e.sessionId,t),gc(t))break;vs(),H(`user`,e.text,!1,e.ts),jo();break}case`text-start`:vs();break;case`text-delta`:_s(e.text);break;case`thinking-delta`:vs(),_o(e.ts,e.text);break;case`tool-start`:vs(),ho(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:go(e.toolCallId,e.isError,e.output);break;case`turn-end`:np=!1,bs(e.text,e.meta),e.meta&&wd(e.meta);break;case`queue-state`:Sc(e.steering,e.followUp);break;case`queue-recovery`:xc(e.batches,e.uncertain);break;case`context-compacted`:vs(),H(`system`,`Context compacted — ${Ce(e.before)} → ${Ce(e.after)}`,!1,e.ts),jo();break;case`error`:po(),H(`error`,e.message);break;case`state`:e.state===`idle`&&np&&(np=!1,xs()),e.state===`idle`&&Sc([],[]),dp(e.state)}}function pp(){let e=new EventSource(`/api/events`);e.onopen=()=>{op(),Tf(),Ef(),Df()},e.onerror=()=>Is(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){op();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){Tf(t.type===`task-run-changed`?t.taskId:void 0),Ef(),Df(),t.type===`task-run-changed`&&op();return}if(Df(),t.sessionId===$)return;let n=Jf.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Su())}}function mp(e,t,n){ep?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>ep===r&&$===e&&n===Zf;r.onmessage=e=>{i()&&fp(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&gp(e)}),r.onerror=()=>{i()&&Is(r,`Session`)},ep=r}async function hp(e){Rf(),Rl(),Wf(e),!(e===$&&(ep||Qf))&&(++Xf,++Zf,rp=!1,Mc(),$=e,Yf=null,Jf.some(t=>t.id===e)||lp(e),$f=Jf.find(t=>t.id===e)?.state??`idle`,Nc(e),Su(),Dd(),sp(),await gp(e))}async function gp(e){if($!==e)return;let t=++Zf;ep?.close(),ep=null,Qf=!0,Ss(),Sc([],[]),xc([]),Sd(),np=!1,vc(),tp=0,Cs(!0);let n=await Le(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==Zf)return;if(Qf=!1,!n.ok){Cs(!1),H(`error`,n.error);return}let r=n.value;ws(r.turns,r.state,r.backgroundRuns),tp=r.lastSeq,np=r.state===`streaming`,dp(r.state),Sc(r.queue.steering,r.queue.followUp),xc(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Cd(r.model,r.context,r.thinkingLevel,i),mp(e,`${r.epoch}:${r.lastSeq}`,t)}Ms(),ye(),Fs(),Gd();var _p=async e=>{$===e&&await gp(e)};Co({sessionId:()=>$,sessionState:()=>$f,select:e=>void hp(e),showRun:Nf,send:(e,t)=>void Ic(e,t),ownTurn:e=>{_c(e),dp(`streaming`)},reload:_p}),zc({sessionId:()=>$,starting:()=>rp,sessionState:()=>$f,chatVisible:sf,setState:dp,reload:_p}),tu({sessionMenu:e=>{let t=cp();t&&Ld(e,t)},sessionInfo:e=>{let t=cp();t&&Md(e,t)}}),wu({sessions:()=>Jf,currentId:()=>$,select:e=>void hp(e),sessionMenu:Ld,createSession:ip,onTitleChanged:Dd}),rd({sessions:()=>Jf,loadSessions:op,currentId:()=>$,select:hp,createSession:ip,openConsole:kf}),dd({currentId:()=>$,currentSession:cp,createSession:e=>void ip(e),syncBar:Of,openFiles:Pf,toggleFiles:If}),qf({sessions:()=>Jf,loadSessions:op,currentId:()=>$,currentSession:cp,select:e=>void hp(e),maybeAckRead:sp}),nf(`0.1.2`),el(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,sp),window.addEventListener(`focus`,sp),pp(),op().then(Gf);export{g as $,pi as A,Yr as B,ai as C,ti as D,Qr as E,_i as F,Ie as G,R as H,zr as I,Re as J,x as K,Br as L,ui as M,di as N,ei as O,$r as P,Se as Q,Wr as R,hi as S,ci as T,Rr as U,Ur as V,Vr as W,b as X,ze as Y,Fe as Z,fi as _,q as a,a as at,Xr as b,Ys as c,Li as d,ve as et,Ii as f,ri as g,ni as h,Al as i,o as it,si as j,li as k,Da as l,oi as m,ld as n,m as nt,bl as o,Ni as p,Le as q,Nl as r,l as rt,al as s,ud as t,de as tt,Oa as u,mi as v,gi as w,ii as x,Zr as y,Jr as z};
@@ -1 +1 @@
1
- import{$ as e,G as t,H as n,R as r,S as i,Y as a,b as o,k as s,m as c,q as l,rt as u}from"./index-DzXDXra_.js";import{c as d,i as f,n as p,o as m,s as h}from"./task-runs-BCakxFk8.js";function g(g,_,v,y){let b=new URLSearchParams,x=[],S=``,C=n(`div`,`automation-list min-h-0 flex-1 overflow-auto`),w,T={selectedId:null,rawOpen:!1,scrollTop:0,drawn:``},E=(e,t)=>v(Object.fromEntries(e),t),D=e=>{g.querySelector(`[role=alert]`)?.remove();let t=n(`p`,`p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),g.append(t)},O={openSession:_,openTask:y,openRun:e=>E(b,e),mutate:async e=>{let t=await a(e,`POST`,`Run update failed`);t?D(t):await k()}},k=t(async()=>{let e=T.selectedId;if(e)return f(C,e,()=>E(b),O,T);let t=b.toString(),n=await l(`/api/task-runs?${t}`,`Could not load runs`);if(t!==b.toString()||T.selectedId)return;if(!n.ok)return D(n.error);g.querySelector(`[role=alert]`)?.remove();let r=JSON.stringify(n.value);S!==t+r&&(S=t+r,P(n.value))});function A(e,t){let n=new URLSearchParams(b);t?n.set(e,t):n.delete(e),n.delete(`cursor`),E(n)}function j(){if(S=``,C=n(`div`,`automation-list min-h-0 flex-1 overflow-auto`),w=void 0,T.selectedId){g.replaceChildren(C);return}g.replaceChildren(N(),C)}function M(){let e=x.map(e=>[e.name+(e.archived?` (archived)`:``),e.id]),t=b.get(`taskId`);return t&&!x.some(e=>e.id===t)&&e.push([t,t]),[[`All tasks`,``],...e]}function N(){let t=n(`div`,`automation-filters run-filters`),r=(e,r,i)=>{let a=s(i,b.get(r)??``);return a.dataset.active=String(!!b.get(r)),a.setAttribute(`aria-label`,e),a.onchange=()=>A(r,a.value),t.append(n(`label`,`filter-field ${r===`taskId`?`filter-wide`:``}`,n(`span`,``,e),a)),a};r(`State`,`state`,[[`All states`,``],...[`queued`,`running`,`succeeded`,`failed`,`cancelled`,`interrupted`,`skipped`].map(e=>[e,e])]),r(`Source`,`source`,[[`All sources`,``],...[`manual`,`agent`,`cron`,`watch`,`task`].map(e=>[e,e])]),w=r(`Task`,`taskId`,M());let i=n(`details`,`filter-dates`),a=Number(b.has(`since`))+Number(b.has(`until`));i.open=a>0,i.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 py-1 text-[12px] text-neutral-600`,e(u,`chev h-3 w-3`),a?`Date range (${a})`:`Date range`));let l=n(`div`,`filter-date-fields`);for(let[e,t]of[[`From`,`since`],[`Through`,`until`]]){let r=n(`input`,c);r.type=`datetime-local`,r.setAttribute(`aria-label`,e);let i=b.get(t);if(i){let e=new Date(Number(i));Number.isFinite(e.getTime())&&(r.value=new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16))}r.dataset.active=String(!!r.value),r.onchange=()=>A(t,r.value?String(new Date(r.value).getTime()):``),l.append(n(`label`,`filter-field`,n(`span`,``,e),r))}i.append(l);let d=n(`input`,`h-4 w-4 flex-none`);d.type=`checkbox`,d.checked=b.get(`showUnmatched`)===`true`,d.onchange=()=>A(`showUnmatched`,d.checked?`true`:``);let f=n(`label`,`flex min-h-10 cursor-pointer items-center gap-2 text-[11.5px] text-neutral-500`,d,`Show unmatched probes`),p=[...b.keys()].filter(e=>e!==`cursor`).length,m=o(p?`Reset filters (${p})`:`Reset filters`);return m.classList.add(`filter-action`),m.disabled=!p,m.onclick=()=>v({}),t.append(i,n(`div`,`filter-footer`,f,m)),t}function P(e){let t=n(`div`,`divide-y divide-neutral-100`);for(let r of e.runs){let e=n(`div`,`px-4 py-3 text-[12px] transition-colors hover:bg-neutral-50`),i=n(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 text-left md:grid-cols-[minmax(0,1fr)_12rem_5rem]`);i.setAttribute(`type`,`button`),i.onclick=()=>E(b,r.id),i.append(n(`span`,`flex min-w-0 items-center gap-2`,h(r),n(`span`,`min-w-0 truncate font-medium text-neutral-800`,r.context.definition.name)),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400 md:order-2`,d(r)),n(`span`,`col-span-2 text-neutral-500 md:order-1 md:col-span-1`,p(r.queuedAt)),n(`span`,`col-span-2 break-all font-mono text-[11px] text-neutral-400 md:order-3 md:col-span-3`,`${r.id} · ${r.triggerSource}`)),e.append(i);let a=m(r);a&&e.append(n(`p`,`mt-1.5 inline-block break-words rounded-md bg-amber-50 px-2 py-0.5 text-[11.5px] text-amber-700 ring-1 ring-amber-200`,a));let o=n(`div`,`mt-1.5 flex flex-wrap gap-1.5 text-[11px] text-neutral-500`),s=`max-w-full break-all rounded-md bg-neutral-100 px-1.5 py-0.5 text-left`,c=(e,t)=>{let r=n(`button`,`${s} cursor-pointer transition-colors hover:bg-neutral-200 hover:text-neutral-800`,e);r.setAttribute(`type`,`button`),r.onclick=t,o.append(r)};if(r.parentRunId&&c(`Parent ${r.parentRunId}`,()=>E(b,r.parentRunId)),r.resumedFromRunId&&c(`Resumed from ${r.resumedFromRunId}`,()=>E(b,r.resumedFromRunId)),r.result?.type===`task`){let e=r.result.runId;c(`Child result ${e}`,()=>E(b,e))}r.groupId&&o.append(n(`span`,s,`Group ${r.groupId}`)),o.childElementCount&&e.append(o),t.append(e)}e.runs.length||t.append(n(`div`,`p-4`,i(`No matching runs.`)));let r=n(`div`,`flex items-center gap-3 border-t border-neutral-200 p-4`);if(b.has(`cursor`)){let e=o(`Newest`);e.onclick=()=>A(`cursor`,``),r.append(e)}if(e.nextCursor){let t=o(`Older runs`);t.onclick=()=>{let t=new URLSearchParams(b);t.set(`cursor`,JSON.stringify(e.nextCursor)),E(t)},r.append(t)}let a=C.scrollTop;C.replaceChildren(t,r),C.scrollTop=a}async function F(){let e=await l(`/api/tasks?kind=task`,`Could not load task filters`);if(!e.ok)return D(e.error);JSON.stringify(x)!==JSON.stringify(e.value)&&(x=e.value,!T.selectedId&&w?.isConnected&&(w.replaceChildren(...M().map(([e,t])=>new Option(e,t))),w.value=b.get(`taskId`)??``))}let I=r(g,(e,t)=>{b=new URLSearchParams(t),T.selectedId!==(e||null)&&(T.rawOpen=!1,T.scrollTop=0),T.selectedId=e||null,j(),k(),e||F()});return Object.assign(I,{refresh(){I.visible&&k()}})}export{g as createRunsView};
1
+ import{$ as e,G as t,H as n,R as r,S as i,Y as a,b as o,k as s,m as c,q as l,rt as u}from"./index-DbFu15NN.js";import{c as d,i as f,n as p,o as m,s as h}from"./task-runs-CqpTV644.js";function g(g,_,v,y){let b=new URLSearchParams,x=[],S=``,C=n(`div`,`automation-list min-h-0 flex-1 overflow-auto`),w,T={selectedId:null,rawOpen:!1,scrollTop:0,drawn:``},E=(e,t)=>v(Object.fromEntries(e),t),D=e=>{g.querySelector(`[role=alert]`)?.remove();let t=n(`p`,`p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),g.append(t)},O={openSession:_,openTask:y,openRun:e=>E(b,e),mutate:async e=>{let t=await a(e,`POST`,`Run update failed`);t?D(t):await k()}},k=t(async()=>{let e=T.selectedId;if(e)return f(C,e,()=>E(b),O,T);let t=b.toString(),n=await l(`/api/task-runs?${t}`,`Could not load runs`);if(t!==b.toString()||T.selectedId)return;if(!n.ok)return D(n.error);g.querySelector(`[role=alert]`)?.remove();let r=JSON.stringify(n.value);S!==t+r&&(S=t+r,P(n.value))});function A(e,t){let n=new URLSearchParams(b);t?n.set(e,t):n.delete(e),n.delete(`cursor`),E(n)}function j(){if(S=``,C=n(`div`,`automation-list min-h-0 flex-1 overflow-auto`),w=void 0,T.selectedId){g.replaceChildren(C);return}g.replaceChildren(N(),C)}function M(){let e=x.map(e=>[e.name+(e.archived?` (archived)`:``),e.id]),t=b.get(`taskId`);return t&&!x.some(e=>e.id===t)&&e.push([t,t]),[[`All tasks`,``],...e]}function N(){let t=n(`div`,`automation-filters run-filters`),r=(e,r,i)=>{let a=s(i,b.get(r)??``);return a.dataset.active=String(!!b.get(r)),a.setAttribute(`aria-label`,e),a.onchange=()=>A(r,a.value),t.append(n(`label`,`filter-field ${r===`taskId`?`filter-wide`:``}`,n(`span`,``,e),a)),a};r(`State`,`state`,[[`All states`,``],...[`queued`,`running`,`succeeded`,`failed`,`cancelled`,`interrupted`,`skipped`].map(e=>[e,e])]),r(`Source`,`source`,[[`All sources`,``],...[`manual`,`agent`,`cron`,`watch`,`task`].map(e=>[e,e])]),w=r(`Task`,`taskId`,M());let i=n(`details`,`filter-dates`),a=Number(b.has(`since`))+Number(b.has(`until`));i.open=a>0,i.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 py-1 text-[12px] text-neutral-600`,e(u,`chev h-3 w-3`),a?`Date range (${a})`:`Date range`));let l=n(`div`,`filter-date-fields`);for(let[e,t]of[[`From`,`since`],[`Through`,`until`]]){let r=n(`input`,c);r.type=`datetime-local`,r.setAttribute(`aria-label`,e);let i=b.get(t);if(i){let e=new Date(Number(i));Number.isFinite(e.getTime())&&(r.value=new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16))}r.dataset.active=String(!!r.value),r.onchange=()=>A(t,r.value?String(new Date(r.value).getTime()):``),l.append(n(`label`,`filter-field`,n(`span`,``,e),r))}i.append(l);let d=n(`input`,`h-4 w-4 flex-none`);d.type=`checkbox`,d.checked=b.get(`showUnmatched`)===`true`,d.onchange=()=>A(`showUnmatched`,d.checked?`true`:``);let f=n(`label`,`flex min-h-10 cursor-pointer items-center gap-2 text-[11.5px] text-neutral-500`,d,`Show unmatched probes`),p=[...b.keys()].filter(e=>e!==`cursor`).length,m=o(p?`Reset filters (${p})`:`Reset filters`);return m.classList.add(`filter-action`),m.disabled=!p,m.onclick=()=>v({}),t.append(i,n(`div`,`filter-footer`,f,m)),t}function P(e){let t=n(`div`,`divide-y divide-neutral-100`);for(let r of e.runs){let e=n(`div`,`px-4 py-3 text-[12px] transition-colors hover:bg-neutral-50`),i=n(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 text-left md:grid-cols-[minmax(0,1fr)_12rem_5rem]`);i.setAttribute(`type`,`button`),i.onclick=()=>E(b,r.id),i.append(n(`span`,`flex min-w-0 items-center gap-2`,h(r),n(`span`,`min-w-0 truncate font-medium text-neutral-800`,r.context.definition.name)),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400 md:order-2`,d(r)),n(`span`,`col-span-2 text-neutral-500 md:order-1 md:col-span-1`,p(r.queuedAt)),n(`span`,`col-span-2 break-all font-mono text-[11px] text-neutral-400 md:order-3 md:col-span-3`,`${r.id} · ${r.triggerSource}`)),e.append(i);let a=m(r);a&&e.append(n(`p`,`mt-1.5 inline-block break-words rounded-md bg-amber-50 px-2 py-0.5 text-[11.5px] text-amber-700 ring-1 ring-amber-200`,a));let o=n(`div`,`mt-1.5 flex flex-wrap gap-1.5 text-[11px] text-neutral-500`),s=`max-w-full break-all rounded-md bg-neutral-100 px-1.5 py-0.5 text-left`,c=(e,t)=>{let r=n(`button`,`${s} cursor-pointer transition-colors hover:bg-neutral-200 hover:text-neutral-800`,e);r.setAttribute(`type`,`button`),r.onclick=t,o.append(r)};if(r.parentRunId&&c(`Parent ${r.parentRunId}`,()=>E(b,r.parentRunId)),r.resumedFromRunId&&c(`Resumed from ${r.resumedFromRunId}`,()=>E(b,r.resumedFromRunId)),r.result?.type===`task`){let e=r.result.runId;c(`Child result ${e}`,()=>E(b,e))}r.groupId&&o.append(n(`span`,s,`Group ${r.groupId}`)),o.childElementCount&&e.append(o),t.append(e)}e.runs.length||t.append(n(`div`,`p-4`,i(`No matching runs.`)));let r=n(`div`,`flex items-center gap-3 border-t border-neutral-200 p-4`);if(b.has(`cursor`)){let e=o(`Newest`);e.onclick=()=>A(`cursor`,``),r.append(e)}if(e.nextCursor){let t=o(`Older runs`);t.onclick=()=>{let t=new URLSearchParams(b);t.set(`cursor`,JSON.stringify(e.nextCursor)),E(t)},r.append(t)}let a=C.scrollTop;C.replaceChildren(t,r),C.scrollTop=a}async function F(){let e=await l(`/api/tasks?kind=task`,`Could not load task filters`);if(!e.ok)return D(e.error);JSON.stringify(x)!==JSON.stringify(e.value)&&(x=e.value,!T.selectedId&&w?.isConnected&&(w.replaceChildren(...M().map(([e,t])=>new Option(e,t))),w.value=b.get(`taskId`)??``))}let I=r(g,(e,t)=>{b=new URLSearchParams(t),T.selectedId!==(e||null)&&(T.rawOpen=!1,T.scrollTop=0),T.selectedId=e||null,j(),k(),e||F()});return Object.assign(I,{refresh(){I.visible&&k()}})}export{g as createRunsView};
@@ -1,4 +1,4 @@
1
- import{$ as e,A as t,C as n,D as r,E as i,F as a,H as o,I as s,K as c,L as l,M as u,N as d,O as f,Q as p,R as m,S as h,T as g,X as _,_ as v,a as y,b,d as x,f as S,g as C,h as w,it as T,j as E,k as D,l as O,m as k,n as A,nt as j,o as M,p as N,q as P,r as F,rt as I,s as ee,t as L,tt as R,v as te,w as z,x as B,y as V,z as H}from"./index-DzXDXra_.js";var ne=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`M10 14 21 3`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}]],re=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],U={display_information:{name:`Pier`,description:`Coding agent sessions in Slack threads`,background_color:`#262626`},features:{bot_user:{display_name:`Pier`,always_online:!1},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:[`chat:write`,`reactions:write`,`channels:history`,`channels:read`,`groups:history`,`groups:read`,`im:history`,`im:write`,`mpim:history`,`mpim:read`,`mpim:write`,`users:read`,`files:read`,`files:write`]}},settings:{event_subscriptions:{bot_events:[`message.channels`,`message.groups`,`message.im`,`message.mpim`]},interactivity:{is_enabled:!0},socket_mode_enabled:!0,token_rotation_enabled:!1}},W=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(U))}`,G=()=>z(`Getting a bot token`,[`Open [@BotFather](https://t.me/BotFather) in Telegram.`,"Send `/newbot`, pick a display name, then a username ending in `bot`.","Copy the token it prints (`123456789:AA…`) and paste it here.","Send `/setprivacy` → `Disable` if the bot should see plain group messages. Left enabled it only ever receives mentions, replies and commands — the usual reason a bot looks dead in a group.","Send `/setjoingroups` → `Enable`, then add the bot to your group or forum."]),K=(e=`left`)=>z(`Enabling topics on a group`,["In Telegram open the group → `Edit` → turn on `Topics`. Owner only; group size no longer matters.","The group becomes a forum supergroup and the existing chat becomes its `General` topic.","Make the bot an admin with `Manage Topics`. That is the one right topic creation needs — without it Pier logs the failure and answers in General instead.","Send one message in the group so Pier discovers it, then enable it under `Chats` below.","After that, a message in General opens its own topic with its own session. A reply, or anything starting with `/`, stays where it was sent."],e);function q(){let t=b(`Create Slack app`,!0);t.append(e(ne)),t.classList.add(`inline-flex`,`items-center`,`gap-1.5`),t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(W(),`_blank`,`noreferrer`);let n=H(`btn w-fit text-[12.5px]`,()=>JSON.stringify(U,null,2));return z(`Creating a Slack app`,[a(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,t),"`Install to Workspace` → allow. Then `OAuth & Permissions` → copy the bot token (`xoxb-…`) into the field above.","`Basic Information` → `App-Level Tokens` → `Generate` with scope `connections:write`. Paste that `xapp-…` token below. The manifest cannot mint this one for you.","In Slack, invite the bot where you want it: `/invite @Pier`. It answers in threads only, so it never adds noise to the channel.",a(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var ie=()=>z(`What agent access allows`,["Gives agent sessions a `slack` tool: read a channel's history for a time range, read one thread, and post, edit or delete a message.",`Editing and deleting reach only what Pier's own bot posted — Slack refuses either on anyone else's message.`,`Pier performs every call itself — the bot token is never given to the agent, and Slack's own membership rules still apply, so the bot reaches only channels it was invited to.`,`Every read fetches live from Slack — Pier keeps no message archive.`,`This includes sessions started by tasks and subagents. Switch it off if an agent should never post to your workspace on its own.`,`The tool is only given to sessions opened while Slack is connected and this is on, so an unused tool costs no context. A session opened earlier keeps it, and a call made after you switch it off is refused with the reason.`]),J=(e=`left`)=>z(`How Slack threads work here`,[`Pier never posts in a channel's main flow. A message in the channel is answered in *its own thread*; a message in a thread is answered in that thread.`,`Each thread is its own Pi session, so one channel hosts many parallel sessions.`,`The same applies in a DM: every new message you send there starts its own thread and its own session. Reply *inside* a thread to continue that conversation.`,"Inside a thread Pier already owns, no `@mention` is needed — continuing that thread is addressing it.","Commands are bare words after a mention: `@bot settings`, `@bot stop`, `@bot bind <code>`. Slack's client swallows an unregistered `/command` before it ever reaches an app."],e),ae=()=>z(`Creating a Feishu app`,["On [open.feishu.cn](https://open.feishu.cn/app) create a 企业自建应用 (custom app). `Credentials & Basic Info` shows the App ID (`cli_…`) and App Secret — paste both here.","`Add Features` → enable **Bot** (机器人).","`Permissions` (权限管理), add: `im:message` (read messages), `im:message:send_as_bot` (send), `im:resource` (attachments, both directions), `im:message.reactions:create` + `:read` + `:delete` (the 👀 receipt), `im:chat:readonly` (chat names for this page), `contact:user.base:readonly` (speaker names).","`Events & Callbacks` → set the mode to **长连接 (long connection)** — no public URL needed. Under Events subscribe `im.message.receive_v1` (接收消息); Callbacks gain `card.action.trigger` automatically once cards are sent, add it if listed.",`**Publish a version** (版本管理与发布 → 创建版本 → 申请发布). Nothing above takes effect until this is approved — the usual reason a configured bot stays silent.`,`Add the bot to a group (群设置 → 群机器人), or DM it directly.`]),Y=(e=`left`)=>z(`How Lark topics work here`,[`Pier never posts in a chat's main flow. A message in the chat is answered in *its own topic* (话题); a message inside a topic is answered there.`,`Each topic is its own Pi session, so one group hosts many parallel sessions.`,`The same applies in a DM: every new message starts its own topic and its own session. Reply *inside* a topic to continue that conversation.`,`Inside a topic Pier already owns, no @mention is needed — continuing that topic is addressing it.`,"Commands are slash words: `/stop`, `/settings`, `/bind <code>`. A bare @mention with nothing else also opens the settings panel."],e),oe=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],X=(e,t)=>o(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,o(`span`,``,e),t),Z={dm:`bg-sky-50 text-sky-700 ring-sky-200`,group:`bg-neutral-100 text-neutral-600 ring-neutral-200`,forum:`bg-violet-50 text-violet-700 ring-violet-200`},se=`pier.channelsPlatform`;function ce(t){let r=localStorage.getItem(se),i=oe.some(([e])=>e===r)?r:`telegram`,a=null,s=[],c=o(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),l=o(`div`,`pagehead pagehead-hug sticky top-[-8px] z-30`,c),u=o(`div`,`px-4 pb-5 pt-4`);t.append(o(`div`,`min-h-0 flex-1 overflow-y-auto`,l,u));function p(){l.replaceChildren(f(oe.map(([e,t])=>[t,e]),i,e=>{g&&O(),i=e,localStorage.setItem(se,e),k()}),c)}let g,y=!1,x=null;function S(t){if(c.replaceChildren(),t!==`clean`){if(c.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${v[t]}`,t===`saving`)c.append(e(j,`spinner`),o(`span`,``,`Saving…`));else if(t===`saved`)c.append(e(T),o(`span`,``,`Saved`)),setTimeout(()=>{c.textContent?.includes(`Saved`)&&S(`clean`)},2e3);else{let t=V(`Retry`,`cursor-pointer underline`);t.onclick=O,c.append(e(re),o(`span`,``,`Save failed`),t)}}}function C(){S(`saving`),clearTimeout(g),g=setTimeout(O,500)}let w=e=>t=>{e(t),C()};async function D(e){y=!0,S(`saving`);try{S((await _(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{S(`failed`)}finally{y=!1;let e=x;x=null,e&&D(e)}}function O(){if(clearTimeout(g),g=void 0,!a)return;let e={platform:i,config:a};y?x=e:D(e)}async function k(){if(!s.length){let e=await P(`/api/models`,`Could not load the model catalog`);e.ok&&(s=e.value)}let e=await P(`/api/channels/${i}`,`Failed to load`);if(!e.ok){a=null,p(),u.replaceChildren(h(e.error));return}a=e.value,S(`clean`),R()}function A(e){let t=i===`slack`,r=i===`lark`,a=E(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,w(t=>e.token=t),!0),o=E(e.appToken,r?``:`xapp-…`,w(t=>e.appToken=t),!0),s=F(e.cwd,`(pier process cwd)`,w(t=>e.cwd=t));return B(`Connection`,t?`Pier connects over Socket Mode; no public URL or webhook needed.`:r?`Pier connects over Feishu's WebSocket long connection; no public URL or webhook needed.`:`Pier polls Telegram for updates; no public URL or webhook needed.`,d(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,w(t=>{e.enabled=t,p()})),n(r?`App ID`:`Bot token`,a,{hint:`Stored locally, shown masked once saved.`,help:i===`telegram`?G():t?q():ae()}),...t?[n(`App-level token`,o,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),d(`Agent access`,`Let agent sessions read channel history and post through the slack tool. Off makes the tool refuse; inbound messages are unaffected.`,e.agentTool,w(t=>e.agentTool=t),ie())]:[],...r?[n(`App Secret`,o,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],n(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function M(e){return B(`Defaults for new chats`,`Copied into a group the first time the bot sees it; changing them here never touches a group that already exists. DMs are always bound-users-only.`,d(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,w(t=>e.requireMention=t)),d(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,w(t=>e.requireBind=t)),...i===`slack`?[X(`Thread mode: always on`,J())]:i===`lark`?[X(`Thread mode: always on`,Y())]:[d(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,w(t=>e.topicMode=t),K())],L(`Model & reasoning`,e,s,w(t=>{e.model=t.model,e.thinking=t.thinking,R()})))}function N(e){let t=o(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=o(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,o(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=b(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${i}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let a=o(`div`,`flex flex-col`);e.users.length||a.append(h(`No bound users yet.`));for(let t of e.users){let e=V(`Remove`,`cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100 pointer-coarse:opacity-100`);e.onclick=async()=>{await fetch(`/api/channels/${i}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await k()},a.append(o(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,o(`span`,`flex h-6 w-6 flex-none items-center justify-center rounded-full bg-neutral-100 text-[11px] font-semibold text-neutral-500`,(t.name[0]??`?`).toUpperCase()),o(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),o(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return B(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,a,o(`div`,`flex flex-col gap-2`,r,n))}function I(e,t){let r=o(`div`,`rounded-xl border px-3.5 py-3 transition-colors ${t.enabled?`border-neutral-200 bg-white`:`border-neutral-200 bg-neutral-50/60`}`),a=o(`div`,`flex items-center gap-2`,o(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),te(t.kind,Z[t.kind]),o(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),c=d(``,``,t.enabled,w(e=>{t.enabled=e,R()}));c.classList.add(`flex-none`,`items-center`),a.append(c);let l=o(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?l.append(o(`span`,`text-[13px] text-neutral-400`,i===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):l.append(d(`Require mention`,``,t.requireMention,w(e=>t.requireMention=e)),d(`Require bind`,``,t.requireBind,w(e=>t.requireBind=e)),i===`slack`?X(`Thread mode: always on`,J(`right`)):i===`lark`?X(`Thread mode: always on`,Y(`right`)):t.kind===`forum`?d(`Topic mode`,``,t.topicMode,w(e=>t.topicMode=e),K(`right`)):X(`Topic mode: forum groups only`,K(`right`)));let u=F(t.cwd,``,w(e=>t.cwd=e)),f=o(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,n(`Working directory`,u.el),L(`Model & reasoning`,t,s,w(e=>{t.model=e.model,t.thinking=e.thinking,R()})));return r.append(a,l,f),r}function ee(e){let t=o(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>I(e,t))):t.append(h(`None yet. Chats appear here after the bot sees a message in them.`)),B(i===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function R(){if(!a)return;p();let e=o(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(A(a),M(a),N(a),ee(a)),u.replaceChildren(e)}return m(t,()=>void k(),()=>{g&&O()})}function le(){let e=o(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),r=o(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),i=o(`p`,`text-[12px] break-words`),a=o(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),s=o(`section`,`flex min-w-0 flex-col gap-3`);r.append(o(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),i,a,s),e.append(r);let l=null,u=!1,f=!1,p=0,m=``,h=!1,g=e=>e?new Date(e).toLocaleString():`Never`;async function v(){let e=p,n=await P(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(f||e!==p)){if(!n.ok){t(i,`failed`,n.error);return}l=n.value,h||(m=l.sourceUrl),S()}}async function y(e){if(!u){++p,u=!0,S(),t(i,`saving`,`Working...`);try{let n=await _(`/api/config-sync`,{action:e,...e===`subscribe`?{url:m}:{}});if(!n.ok)throw Error(await c(n,`Configuration sync failed`));let r=await n.json();l=r,h=!1,m=r.sourceUrl,t(i,`saved`,r.result??`Saved`)}catch(e){t(i,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await v()}finally{u=!1,f||S()}}}function x(e,t){let n=b(e);return n.disabled=u,n.onclick=()=>{y(t)},n}function S(){if(!l||f)return;if(a.replaceChildren(o(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),l.publishedPath){let e=`${l.publicUrl||window.location.origin}${l.publishedPath}`,t=E(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),a.append(t,o(`div`,`flex flex-wrap items-center gap-2`,H(`btn text-[12px]`,()=>e),x(`Revoke link`,`revoke`)))}else a.append(o(`div`,``,x(`Generate link`,`publish`)));a.append(o(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts, model definitions, the default model and its reasoning effort. API keys, headers and endpoints stay private.`));let e=E(m,`https://example.com/config-sync/...`,e=>{m=e,h=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=u||l.enabled;let t=d(`Automatic sync`,``,l.enabled,e=>{y(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=u;let r=o(`div`,`flex flex-wrap items-center gap-3`,t);l.enabled&&r.append(x(`Sync now`,`sync`)),s.replaceChildren(o(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),n(`Source URL`,e),r);let i=o(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,g(l.lastChecked)],[`Last applied`,g(l.lastApplied)],[`Next check`,l.enabled?g(l.nextRunAt):`Paused`]])i.append(o(`dt`,`text-neutral-500`,e),o(`dd`,`min-w-0 break-words text-neutral-700`,t));if(s.append(i),l.error&&s.append(o(`p`,`text-[12px] break-words text-red-600`,l.error)),l.needsReload&&s.append(o(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),l.taskId){let e=o(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(l.taskId)}`,s.append(e)}}v();let C=setInterval(()=>{!u&&!h&&v()},15e3);return{el:e,dispose:()=>{f=!0,clearInterval(C)}}}var ue=`${w} flex flex-col overflow-hidden`,de=`${C} flex flex-none items-center`;async function fe(e,t){let n;try{n=await _(`/api/settings`,e,`PUT`)}catch(e){return{outcome:{state:`failed`,text:`Could not save: ${String(e)}`}}}if(!n.ok)return{outcome:{state:`failed`,text:await c(n,`could not save`)}};let r;try{r=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return r.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${r.toolsSync.reason}`},answer:r}:r.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:r}:{outcome:{state:`saved`,text:t},answer:r}}function pe(e,t){return e.enabled?{body:{tool:{name:e.name,on:!1}},saved:`Switched ${e.name} off — the next run uninstalls it. Remove it again once its binary is gone.`}:{body:{customTools:t.filter(t=>t.name!==e.name)},saved:`Removed ${e.name}.`}}function me(r,i){let a=`global`,s=null,u=0,f=0,p=``,g=null,v=[],y=``,b=null,C=null,w=()=>{C?.dispose(),C=null},T=()=>{w(),++f,C=le(),R.replaceChildren(C.el)},D=[],O=()=>v.filter(e=>e.kind===`extension`),A=e=>e.source===`binary`&&e.custom===!0,j=()=>v.filter(e=>e.kind===`tool`),M=document.createElement(`select`);M.className=`${k} select`,M.onchange=()=>{w(),a=M.value,s=null,J.clear(),U()};let F=o(`div`,`${de} flex-col items-stretch gap-1.5 px-3 py-2.5`);F.append(o(`span`,`field-label`,`Scope`),M);let ee=o(`div`,`min-h-0 flex-1 overflow-y-auto py-1.5`),L=o(`nav`,`${ue} w-64 flex-none text-[13px] leading-5 max-md:max-h-48 max-md:w-full`);L.append(F,ee);let R=o(`div`,`${ue} min-w-0 flex-1`),z=o(`div`,`flex min-h-0 flex-1 gap-3 px-4 pb-4 pt-1 max-md:flex-col`);z.append(L,R),r.append(z);let B=(e=``)=>`?scope=${encodeURIComponent(a)}${e}`;async function V(){if(a!==`global`){v=[],y=``;return}let e=await P(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}H(e.value),y=``}function H(e){v=e.catalog,D=e.customTools,b=e.toolsTaskId}async function ne(e,t){let{outcome:n,answer:r}=await fe(e,t);return r&&(H(r),Y(g)),n}function re(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function U(){let e=++u;f++;let[t]=await Promise.all([P(`/api/config${B()}`,`failed to load config`,{cache:`no-store`}),V()]);if(e!==u)return;if(!t.ok){Y(null),X(t.error);return}let n=t.value;a===`global`&&n.dir&&(p=n.dir,ve()),g=n,Y(n),s?s.type===`sync`&&T():oe()}function W(e){return o(`div`,`px-3 pb-1 pt-3 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let G=()=>{let e=o(`span`,`flex-none rounded bg-neutral-100 px-1 text-[10px] font-semibold uppercase tracking-wide text-neutral-500`,`link`);return e.title=`Reached through a symlink`,e},K=()=>o(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function q(e,t,n,r,i=0,a){let s=o(`button`,`config-row flex w-full cursor-pointer items-center gap-1.5 py-1.5 pr-3 text-left transition-colors hover:bg-neutral-100 ${t?`bg-indigo-50 font-medium hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(o(`span`,`truncate`,e)),a&&s.append(a),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function ie(e){let t={files:[],dirs:new Map,link:!0};for(let n of e){let e=n.name.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||r.dirs.set(t,e={files:[],dirs:new Map,link:!0}),e.link&&=n.link,r=e}r.files.push({name:e[e.length-1],link:n.link})}return t}let J=new Set;function ae(t,n,r,i,a,s){let c=[];for(let[l,u]of n.dirs){let n=r?`${r}/${l}`:l,d=`${t}:${n}`,f=document.createElement(`details`);f.open=J.has(d),f.ontoggle=()=>f.open?J.add(d):J.delete(d);let p=o(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);p.style.paddingLeft=`${20+i*14}px`,p.title=n,p.append(e(I,`chev h-3 w-3`),o(`span`,`truncate text-neutral-600`,l)),u.link&&p.append(G()),f.append(p,...ae(t,u,n,i+1,a,s)),c.push(f)}for(let e of n.files){let n={type:`resource`,kind:t,name:r?`${r}/${e.name}`:e.name};c.push(q(e.name,a(n),!1,()=>s(n),i,e.link?G():void 0))}return c}function Y(e){if(!e){ee.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(s),n=t=>{w(),s=t,Y(e),t.type===`file`?se(t.name):t.type===`bundled`?Q(t.name):t.type===`tools`?$():t.type===`sync`?T():_e(t.kind,t.name)},r=[];if(a===`global`){let e={type:`sync`};r.push(W(`Instance`),q(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(W(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(q(i.name,t(e),!i.exists,()=>n(e)))}if(a===`global`){r.push(W(`bundled with Pier`)),y?r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):O().length||r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of O()){let i={type:`bundled`,name:e.name};r.push(q(e.name,t(i),!1,()=>n(i),0,e.enabled?K():void 0))}if(!y){let e={type:`tools`},i=j().filter(e=>e.enabled).length;r.push(q(`command-line tools`,t(e),!1,()=>n(e),0,i?K():void 0))}}for(let i of[`extensions`,`skills`]){r.push(W(`${i} (read-only)`));let a=e.resources[i];a.length||r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...ae(i,ie(a),``,0,t,n))}ee.replaceChildren(...r)}function oe(){R.replaceChildren(o(`div`,`flex min-h-0 flex-1 items-center justify-center p-6`,h(`Select a file to edit, or browse extensions and skills.`)))}function X(e){R.replaceChildren(o(`p`,`px-4 py-3 text-[12.5px] leading-relaxed text-red-600`,e))}let Z=(e,...t)=>o(`div`,`${de} gap-3 px-4 py-2.5`,o(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function se(e){let n=++f,r=await P(`/api/config/files/${encodeURIComponent(e)}${B()}`,`failed to load ${e}`,{cache:`no-store`});if(!r.ok){n===f&&X(r.error);return}if(n!==f)return;let{content:i}=r.value,a=i,s=o(`span`,`text-[11.5px] text-neutral-400`,``),l=o(`button`,`btn btn-primary text-[12.5px]`,`Save`),u=document.createElement(`textarea`);u.className=`block min-h-0 flex-1 resize-none bg-white p-4 font-mono text-[13px] leading-relaxed focus:outline-none`,u.spellcheck=!1,u.value=i;let d=async()=>{if(l.disabled)return;let n=u.value;l.disabled=!0,t(s,`saving`,`saving…`);try{let r=await _(`/api/config/files/${encodeURIComponent(e)}${B()}`,{content:n,expected:a},`PUT`);if(!r.ok)return t(s,`failed`,await c(r,`save failed`));let i=await r.json();a=i.content,u.value===n?(u.value=i.content,t(s,`saved`,`saved — applies to new sessions`)):t(s,`idle`,`saved; newer changes are unsaved`)}catch(e){t(s,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}},p=o(`button`,`btn text-[12.5px]`,`Edit`),m=o(`button`,`btn text-[12.5px]`,`View`),h=(...e)=>o(`div`,`ml-auto flex flex-none items-center gap-2`,...e),g=()=>{R.replaceChildren(Z(e,s,h(m,l)),u),u.focus()},v=async()=>{let t=await N(e);n===f&&R.replaceChildren(Z(e,s,h(p)),o(`div`,`min-h-0 flex-1 overflow-auto`,x(S(u.value),t)))};p.onclick=g,m.onclick=()=>void v(),l.onclick=()=>void d(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),d())},u.oninput=()=>{t(s,`idle`,`unsaved changes`)},await v()}function ce(e){if(!b)return null;let t=o(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(b)}`,t}let me=()=>{let e=o(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function he(e){if(e.source!==`binary`)return``;let{spec:t,error:n,installed:r,version:i,path:a}=e.binary;return n?`${t} — ${n}`:r?`${t} — ${i??`unknown version`} at ${a??`an unknown path`}`:`${t} — not installed`}function Q(e,n){f++;let r=v.find(t=>t.name===e&&t.kind===`extension`);if(!r)return X(`unknown extension: ${e}`);let i=o(`span`,`text-[11.5px] text-neutral-400`,``);n&&t(i,n.state,n.text);let a=ce(`every run of the update task`);R.replaceChildren(Z(r.name,o(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,r.source===`binary`?`installed by Pier`:`ships with Pier`)),o(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,o(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,r.summary),o(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(r.source===`bundled`?r.adds:[]).flatMap(e=>[o(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),o(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...r.source===`binary`?[o(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),o(`dd`,`font-mono text-[12px] leading-snug ${r.binary.error?`text-red-600`:`text-neutral-500`}`,he(r))]:[]),d(`Enabled`,r.source===`binary`?`Installed into Pier's own bin directory, first on the PATH every session and task inherits; it registers its own Pi extension. Switching it off uninstalls both.`:`Loaded from inside Pier — nothing is installed and no update touches your own extensions. A session mid-turn keeps the tools it started with; the next message picks this up.`,r.enabled,t=>void ge(r.name,t,t=>Q(e,t))),o(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...r.source===`binary`?a?[`A daily task installs and updates it — its history is `,a,`.`]:[`Its installs run as the daily update task.`]:[`An extension of your own that registers the same tool wins: this copy stands down and says so in the log.`]),i))}function $(e,r={name:``,toml:``}){f++;let i=o(`span`,`text-[11.5px] text-neutral-400`,``);e&&t(i,e.state,e.text);let a=j(),s=ce(`the update task`),c=e=>{let t=o(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,o(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,o(`span`,`font-mono`,e.name),...A(e)?[te(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),o(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||he(e)),...e.summary?[o(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,he(e))]:[]),n=d(``,``,e.enabled,t=>void ge(e.name,t,e=>$(e))),r=o(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=pe(e,D);ne(t.body,t.saved).then(e=>$(e))},o(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...A(e)?[r]:[],n)},l={...r},u=o(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),p=E(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),m=document.createElement(`textarea`);m.className=`${k} h-24 resize-y font-mono leading-snug`,m.spellcheck=!1,m.value=l.toml,m.placeholder=`spec = "github:owner/repo"
1
+ import{$ as e,A as t,C as n,D as r,E as i,F as a,H as o,I as s,K as c,L as l,M as u,N as d,O as f,Q as p,R as m,S as h,T as g,X as _,_ as v,a as y,b,d as x,f as S,g as C,h as w,it as T,j as E,k as D,l as O,m as k,n as A,nt as j,o as M,p as N,q as P,r as F,rt as I,s as ee,t as L,tt as R,v as te,w as z,x as B,y as V,z as H}from"./index-DbFu15NN.js";var ne=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`M10 14 21 3`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}]],re=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],U={display_information:{name:`Pier`,description:`Coding agent sessions in Slack threads`,background_color:`#262626`},features:{bot_user:{display_name:`Pier`,always_online:!1},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:[`chat:write`,`reactions:write`,`channels:history`,`channels:read`,`groups:history`,`groups:read`,`im:history`,`im:write`,`mpim:history`,`mpim:read`,`mpim:write`,`users:read`,`files:read`,`files:write`]}},settings:{event_subscriptions:{bot_events:[`message.channels`,`message.groups`,`message.im`,`message.mpim`]},interactivity:{is_enabled:!0},socket_mode_enabled:!0,token_rotation_enabled:!1}},W=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(U))}`,G=()=>z(`Getting a bot token`,[`Open [@BotFather](https://t.me/BotFather) in Telegram.`,"Send `/newbot`, pick a display name, then a username ending in `bot`.","Copy the token it prints (`123456789:AA…`) and paste it here.","Send `/setprivacy` → `Disable` if the bot should see plain group messages. Left enabled it only ever receives mentions, replies and commands — the usual reason a bot looks dead in a group.","Send `/setjoingroups` → `Enable`, then add the bot to your group or forum."]),K=(e=`left`)=>z(`Enabling topics on a group`,["In Telegram open the group → `Edit` → turn on `Topics`. Owner only; group size no longer matters.","The group becomes a forum supergroup and the existing chat becomes its `General` topic.","Make the bot an admin with `Manage Topics`. That is the one right topic creation needs — without it Pier logs the failure and answers in General instead.","Send one message in the group so Pier discovers it, then enable it under `Chats` below.","After that, a message in General opens its own topic with its own session. A reply, or anything starting with `/`, stays where it was sent."],e);function q(){let t=b(`Create Slack app`,!0);t.append(e(ne)),t.classList.add(`inline-flex`,`items-center`,`gap-1.5`),t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(W(),`_blank`,`noreferrer`);let n=H(`btn w-fit text-[12.5px]`,()=>JSON.stringify(U,null,2));return z(`Creating a Slack app`,[a(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,t),"`Install to Workspace` → allow. Then `OAuth & Permissions` → copy the bot token (`xoxb-…`) into the field above.","`Basic Information` → `App-Level Tokens` → `Generate` with scope `connections:write`. Paste that `xapp-…` token below. The manifest cannot mint this one for you.","In Slack, invite the bot where you want it: `/invite @Pier`. It answers in threads only, so it never adds noise to the channel.",a(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var ie=()=>z(`What agent access allows`,["Gives agent sessions a `slack` tool: read a channel's history for a time range, read one thread, and post, edit or delete a message.",`Editing and deleting reach only what Pier's own bot posted — Slack refuses either on anyone else's message.`,`Pier performs every call itself — the bot token is never given to the agent, and Slack's own membership rules still apply, so the bot reaches only channels it was invited to.`,`Every read fetches live from Slack — Pier keeps no message archive.`,`This includes sessions started by tasks and subagents. Switch it off if an agent should never post to your workspace on its own.`,`The tool is only given to sessions opened while Slack is connected and this is on, so an unused tool costs no context. A session opened earlier keeps it, and a call made after you switch it off is refused with the reason.`]),J=(e=`left`)=>z(`How Slack threads work here`,[`Pier never posts in a channel's main flow. A message in the channel is answered in *its own thread*; a message in a thread is answered in that thread.`,`Each thread is its own Pi session, so one channel hosts many parallel sessions.`,`The same applies in a DM: every new message you send there starts its own thread and its own session. Reply *inside* a thread to continue that conversation.`,"Inside a thread Pier already owns, no `@mention` is needed — continuing that thread is addressing it.","Commands are bare words after a mention: `@bot settings`, `@bot stop`, `@bot bind <code>`. Slack's client swallows an unregistered `/command` before it ever reaches an app."],e),ae=()=>z(`Creating a Feishu app`,["On [open.feishu.cn](https://open.feishu.cn/app) create a 企业自建应用 (custom app). `Credentials & Basic Info` shows the App ID (`cli_…`) and App Secret — paste both here.","`Add Features` → enable **Bot** (机器人).","`Permissions` (权限管理), add: `im:message` (read messages), `im:message:send_as_bot` (send), `im:resource` (attachments, both directions), `im:message.reactions:create` + `:read` + `:delete` (the 👀 receipt), `im:chat:readonly` (chat names for this page), `contact:user.base:readonly` (speaker names).","`Events & Callbacks` → set the mode to **长连接 (long connection)** — no public URL needed. Under Events subscribe `im.message.receive_v1` (接收消息); Callbacks gain `card.action.trigger` automatically once cards are sent, add it if listed.",`**Publish a version** (版本管理与发布 → 创建版本 → 申请发布). Nothing above takes effect until this is approved — the usual reason a configured bot stays silent.`,`Add the bot to a group (群设置 → 群机器人), or DM it directly.`]),Y=(e=`left`)=>z(`How Lark topics work here`,[`Pier never posts in a chat's main flow. A message in the chat is answered in *its own topic* (话题); a message inside a topic is answered there.`,`Each topic is its own Pi session, so one group hosts many parallel sessions.`,`The same applies in a DM: every new message starts its own topic and its own session. Reply *inside* a topic to continue that conversation.`,`Inside a topic Pier already owns, no @mention is needed — continuing that topic is addressing it.`,"Commands are slash words: `/stop`, `/settings`, `/bind <code>`. A bare @mention with nothing else also opens the settings panel."],e),oe=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],X=(e,t)=>o(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,o(`span`,``,e),t),Z={dm:`bg-sky-50 text-sky-700 ring-sky-200`,group:`bg-neutral-100 text-neutral-600 ring-neutral-200`,forum:`bg-violet-50 text-violet-700 ring-violet-200`},se=`pier.channelsPlatform`;function ce(t){let r=localStorage.getItem(se),i=oe.some(([e])=>e===r)?r:`telegram`,a=null,s=[],c=o(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),l=o(`div`,`pagehead pagehead-hug sticky top-[-8px] z-30`,c),u=o(`div`,`px-4 pb-5 pt-4`);t.append(o(`div`,`min-h-0 flex-1 overflow-y-auto`,l,u));function p(){l.replaceChildren(f(oe.map(([e,t])=>[t,e]),i,e=>{g&&O(),i=e,localStorage.setItem(se,e),k()}),c)}let g,y=!1,x=null;function S(t){if(c.replaceChildren(),t!==`clean`){if(c.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${v[t]}`,t===`saving`)c.append(e(j,`spinner`),o(`span`,``,`Saving…`));else if(t===`saved`)c.append(e(T),o(`span`,``,`Saved`)),setTimeout(()=>{c.textContent?.includes(`Saved`)&&S(`clean`)},2e3);else{let t=V(`Retry`,`cursor-pointer underline`);t.onclick=O,c.append(e(re),o(`span`,``,`Save failed`),t)}}}function C(){S(`saving`),clearTimeout(g),g=setTimeout(O,500)}let w=e=>t=>{e(t),C()};async function D(e){y=!0,S(`saving`);try{S((await _(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{S(`failed`)}finally{y=!1;let e=x;x=null,e&&D(e)}}function O(){if(clearTimeout(g),g=void 0,!a)return;let e={platform:i,config:a};y?x=e:D(e)}async function k(){if(!s.length){let e=await P(`/api/models`,`Could not load the model catalog`);e.ok&&(s=e.value)}let e=await P(`/api/channels/${i}`,`Failed to load`);if(!e.ok){a=null,p(),u.replaceChildren(h(e.error));return}a=e.value,S(`clean`),R()}function A(e){let t=i===`slack`,r=i===`lark`,a=E(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,w(t=>e.token=t),!0),o=E(e.appToken,r?``:`xapp-…`,w(t=>e.appToken=t),!0),s=F(e.cwd,`(pier process cwd)`,w(t=>e.cwd=t));return B(`Connection`,t?`Pier connects over Socket Mode; no public URL or webhook needed.`:r?`Pier connects over Feishu's WebSocket long connection; no public URL or webhook needed.`:`Pier polls Telegram for updates; no public URL or webhook needed.`,d(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,w(t=>{e.enabled=t,p()})),n(r?`App ID`:`Bot token`,a,{hint:`Stored locally, shown masked once saved.`,help:i===`telegram`?G():t?q():ae()}),...t?[n(`App-level token`,o,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),d(`Agent access`,`Let agent sessions read channel history and post through the slack tool. Off makes the tool refuse; inbound messages are unaffected.`,e.agentTool,w(t=>e.agentTool=t),ie())]:[],...r?[n(`App Secret`,o,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],n(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function M(e){return B(`Defaults for new chats`,`Copied into a group the first time the bot sees it; changing them here never touches a group that already exists. DMs are always bound-users-only.`,d(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,w(t=>e.requireMention=t)),d(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,w(t=>e.requireBind=t)),...i===`slack`?[X(`Thread mode: always on`,J())]:i===`lark`?[X(`Thread mode: always on`,Y())]:[d(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,w(t=>e.topicMode=t),K())],L(`Model & reasoning`,e,s,w(t=>{e.model=t.model,e.thinking=t.thinking,R()})))}function N(e){let t=o(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=o(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,o(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=b(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${i}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let a=o(`div`,`flex flex-col`);e.users.length||a.append(h(`No bound users yet.`));for(let t of e.users){let e=V(`Remove`,`cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100 pointer-coarse:opacity-100`);e.onclick=async()=>{await fetch(`/api/channels/${i}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await k()},a.append(o(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,o(`span`,`flex h-6 w-6 flex-none items-center justify-center rounded-full bg-neutral-100 text-[11px] font-semibold text-neutral-500`,(t.name[0]??`?`).toUpperCase()),o(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),o(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return B(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,a,o(`div`,`flex flex-col gap-2`,r,n))}function I(e,t){let r=o(`div`,`rounded-xl border px-3.5 py-3 transition-colors ${t.enabled?`border-neutral-200 bg-white`:`border-neutral-200 bg-neutral-50/60`}`),a=o(`div`,`flex items-center gap-2`,o(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),te(t.kind,Z[t.kind]),o(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),c=d(``,``,t.enabled,w(e=>{t.enabled=e,R()}));c.classList.add(`flex-none`,`items-center`),a.append(c);let l=o(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?l.append(o(`span`,`text-[13px] text-neutral-400`,i===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):l.append(d(`Require mention`,``,t.requireMention,w(e=>t.requireMention=e)),d(`Require bind`,``,t.requireBind,w(e=>t.requireBind=e)),i===`slack`?X(`Thread mode: always on`,J(`right`)):i===`lark`?X(`Thread mode: always on`,Y(`right`)):t.kind===`forum`?d(`Topic mode`,``,t.topicMode,w(e=>t.topicMode=e),K(`right`)):X(`Topic mode: forum groups only`,K(`right`)));let u=F(t.cwd,``,w(e=>t.cwd=e)),f=o(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,n(`Working directory`,u.el),L(`Model & reasoning`,t,s,w(e=>{t.model=e.model,t.thinking=e.thinking,R()})));return r.append(a,l,f),r}function ee(e){let t=o(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>I(e,t))):t.append(h(`None yet. Chats appear here after the bot sees a message in them.`)),B(i===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function R(){if(!a)return;p();let e=o(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(A(a),M(a),N(a),ee(a)),u.replaceChildren(e)}return m(t,()=>void k(),()=>{g&&O()})}function le(){let e=o(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),r=o(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),i=o(`p`,`text-[12px] break-words`),a=o(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),s=o(`section`,`flex min-w-0 flex-col gap-3`);r.append(o(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),i,a,s),e.append(r);let l=null,u=!1,f=!1,p=0,m=``,h=!1,g=e=>e?new Date(e).toLocaleString():`Never`;async function v(){let e=p,n=await P(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(f||e!==p)){if(!n.ok){t(i,`failed`,n.error);return}l=n.value,h||(m=l.sourceUrl),S()}}async function y(e){if(!u){++p,u=!0,S(),t(i,`saving`,`Working...`);try{let n=await _(`/api/config-sync`,{action:e,...e===`subscribe`?{url:m}:{}});if(!n.ok)throw Error(await c(n,`Configuration sync failed`));let r=await n.json();l=r,h=!1,m=r.sourceUrl,t(i,`saved`,r.result??`Saved`)}catch(e){t(i,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await v()}finally{u=!1,f||S()}}}function x(e,t){let n=b(e);return n.disabled=u,n.onclick=()=>{y(t)},n}function S(){if(!l||f)return;if(a.replaceChildren(o(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),l.publishedPath){let e=`${l.publicUrl||window.location.origin}${l.publishedPath}`,t=E(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),a.append(t,o(`div`,`flex flex-wrap items-center gap-2`,H(`btn text-[12px]`,()=>e),x(`Revoke link`,`revoke`)))}else a.append(o(`div`,``,x(`Generate link`,`publish`)));a.append(o(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts, model definitions, the default model and its reasoning effort. API keys, headers and endpoints stay private.`));let e=E(m,`https://example.com/config-sync/...`,e=>{m=e,h=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=u||l.enabled;let t=d(`Automatic sync`,``,l.enabled,e=>{y(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=u;let r=o(`div`,`flex flex-wrap items-center gap-3`,t);l.enabled&&r.append(x(`Sync now`,`sync`)),s.replaceChildren(o(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),n(`Source URL`,e),r);let i=o(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,g(l.lastChecked)],[`Last applied`,g(l.lastApplied)],[`Next check`,l.enabled?g(l.nextRunAt):`Paused`]])i.append(o(`dt`,`text-neutral-500`,e),o(`dd`,`min-w-0 break-words text-neutral-700`,t));if(s.append(i),l.error&&s.append(o(`p`,`text-[12px] break-words text-red-600`,l.error)),l.needsReload&&s.append(o(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),l.taskId){let e=o(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(l.taskId)}`,s.append(e)}}v();let C=setInterval(()=>{!u&&!h&&v()},15e3);return{el:e,dispose:()=>{f=!0,clearInterval(C)}}}var ue=`${w} flex flex-col overflow-hidden`,de=`${C} flex flex-none items-center`;async function fe(e,t){let n;try{n=await _(`/api/settings`,e,`PUT`)}catch(e){return{outcome:{state:`failed`,text:`Could not save: ${String(e)}`}}}if(!n.ok)return{outcome:{state:`failed`,text:await c(n,`could not save`)}};let r;try{r=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return r.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${r.toolsSync.reason}`},answer:r}:r.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:r}:{outcome:{state:`saved`,text:t},answer:r}}function pe(e,t){return e.enabled?{body:{tool:{name:e.name,on:!1}},saved:`Switched ${e.name} off — the next run uninstalls it. Remove it again once its binary is gone.`}:{body:{customTools:t.filter(t=>t.name!==e.name)},saved:`Removed ${e.name}.`}}function me(r,i){let a=`global`,s=null,u=0,f=0,p=``,g=null,v=[],y=``,b=null,C=null,w=()=>{C?.dispose(),C=null},T=()=>{w(),++f,C=le(),R.replaceChildren(C.el)},D=[],O=()=>v.filter(e=>e.kind===`extension`),A=e=>e.source===`binary`&&e.custom===!0,j=()=>v.filter(e=>e.kind===`tool`),M=document.createElement(`select`);M.className=`${k} select`,M.onchange=()=>{w(),a=M.value,s=null,J.clear(),U()};let F=o(`div`,`${de} flex-col items-stretch gap-1.5 px-3 py-2.5`);F.append(o(`span`,`field-label`,`Scope`),M);let ee=o(`div`,`min-h-0 flex-1 overflow-y-auto py-1.5`),L=o(`nav`,`${ue} w-64 flex-none text-[13px] leading-5 max-md:max-h-48 max-md:w-full`);L.append(F,ee);let R=o(`div`,`${ue} min-w-0 flex-1`),z=o(`div`,`flex min-h-0 flex-1 gap-3 px-4 pb-4 pt-1 max-md:flex-col`);z.append(L,R),r.append(z);let B=(e=``)=>`?scope=${encodeURIComponent(a)}${e}`;async function V(){if(a!==`global`){v=[],y=``;return}let e=await P(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}H(e.value),y=``}function H(e){v=e.catalog,D=e.customTools,b=e.toolsTaskId}async function ne(e,t){let{outcome:n,answer:r}=await fe(e,t);return r&&(H(r),Y(g)),n}function re(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function U(){let e=++u;f++;let[t]=await Promise.all([P(`/api/config${B()}`,`failed to load config`,{cache:`no-store`}),V()]);if(e!==u)return;if(!t.ok){Y(null),X(t.error);return}let n=t.value;a===`global`&&n.dir&&(p=n.dir,ve()),g=n,Y(n),s?s.type===`sync`&&T():oe()}function W(e){return o(`div`,`px-3 pb-1 pt-3 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let G=()=>{let e=o(`span`,`flex-none rounded bg-neutral-100 px-1 text-[10px] font-semibold uppercase tracking-wide text-neutral-500`,`link`);return e.title=`Reached through a symlink`,e},K=()=>o(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function q(e,t,n,r,i=0,a){let s=o(`button`,`config-row flex w-full cursor-pointer items-center gap-1.5 py-1.5 pr-3 text-left transition-colors hover:bg-neutral-100 ${t?`bg-indigo-50 font-medium hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(o(`span`,`truncate`,e)),a&&s.append(a),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function ie(e){let t={files:[],dirs:new Map,link:!0};for(let n of e){let e=n.name.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||r.dirs.set(t,e={files:[],dirs:new Map,link:!0}),e.link&&=n.link,r=e}r.files.push({name:e[e.length-1],link:n.link})}return t}let J=new Set;function ae(t,n,r,i,a,s){let c=[];for(let[l,u]of n.dirs){let n=r?`${r}/${l}`:l,d=`${t}:${n}`,f=document.createElement(`details`);f.open=J.has(d),f.ontoggle=()=>f.open?J.add(d):J.delete(d);let p=o(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);p.style.paddingLeft=`${20+i*14}px`,p.title=n,p.append(e(I,`chev h-3 w-3`),o(`span`,`truncate text-neutral-600`,l)),u.link&&p.append(G()),f.append(p,...ae(t,u,n,i+1,a,s)),c.push(f)}for(let e of n.files){let n={type:`resource`,kind:t,name:r?`${r}/${e.name}`:e.name};c.push(q(e.name,a(n),!1,()=>s(n),i,e.link?G():void 0))}return c}function Y(e){if(!e){ee.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(s),n=t=>{w(),s=t,Y(e),t.type===`file`?se(t.name):t.type===`bundled`?Q(t.name):t.type===`tools`?$():t.type===`sync`?T():_e(t.kind,t.name)},r=[];if(a===`global`){let e={type:`sync`};r.push(W(`Instance`),q(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(W(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(q(i.name,t(e),!i.exists,()=>n(e)))}if(a===`global`){r.push(W(`bundled with Pier`)),y?r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):O().length||r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of O()){let i={type:`bundled`,name:e.name};r.push(q(e.name,t(i),!1,()=>n(i),0,e.enabled?K():void 0))}if(!y){let e={type:`tools`},i=j().filter(e=>e.enabled).length;r.push(q(`command-line tools`,t(e),!1,()=>n(e),0,i?K():void 0))}}for(let i of[`extensions`,`skills`]){r.push(W(`${i} (read-only)`));let a=e.resources[i];a.length||r.push(o(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...ae(i,ie(a),``,0,t,n))}ee.replaceChildren(...r)}function oe(){R.replaceChildren(o(`div`,`flex min-h-0 flex-1 items-center justify-center p-6`,h(`Select a file to edit, or browse extensions and skills.`)))}function X(e){R.replaceChildren(o(`p`,`px-4 py-3 text-[12.5px] leading-relaxed text-red-600`,e))}let Z=(e,...t)=>o(`div`,`${de} gap-3 px-4 py-2.5`,o(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function se(e){let n=++f,r=await P(`/api/config/files/${encodeURIComponent(e)}${B()}`,`failed to load ${e}`,{cache:`no-store`});if(!r.ok){n===f&&X(r.error);return}if(n!==f)return;let{content:i}=r.value,a=i,s=o(`span`,`text-[11.5px] text-neutral-400`,``),l=o(`button`,`btn btn-primary text-[12.5px]`,`Save`),u=document.createElement(`textarea`);u.className=`block min-h-0 flex-1 resize-none bg-white p-4 font-mono text-[13px] leading-relaxed focus:outline-none`,u.spellcheck=!1,u.value=i;let d=async()=>{if(l.disabled)return;let n=u.value;l.disabled=!0,t(s,`saving`,`saving…`);try{let r=await _(`/api/config/files/${encodeURIComponent(e)}${B()}`,{content:n,expected:a},`PUT`);if(!r.ok)return t(s,`failed`,await c(r,`save failed`));let i=await r.json();a=i.content,u.value===n?(u.value=i.content,t(s,`saved`,`saved — applies to new sessions`)):t(s,`idle`,`saved; newer changes are unsaved`)}catch(e){t(s,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}},p=o(`button`,`btn text-[12.5px]`,`Edit`),m=o(`button`,`btn text-[12.5px]`,`View`),h=(...e)=>o(`div`,`ml-auto flex flex-none items-center gap-2`,...e),g=()=>{R.replaceChildren(Z(e,s,h(m,l)),u),u.focus()},v=async()=>{let t=await N(e);n===f&&R.replaceChildren(Z(e,s,h(p)),o(`div`,`min-h-0 flex-1 overflow-auto`,x(S(u.value),t)))};p.onclick=g,m.onclick=()=>void v(),l.onclick=()=>void d(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),d())},u.oninput=()=>{t(s,`idle`,`unsaved changes`)},await v()}function ce(e){if(!b)return null;let t=o(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(b)}`,t}let me=()=>{let e=o(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function he(e){if(e.source!==`binary`)return``;let{spec:t,error:n,installed:r,version:i,path:a}=e.binary;return n?`${t} — ${n}`:r?`${t} — ${i??`unknown version`} at ${a??`an unknown path`}`:`${t} — not installed`}function Q(e,n){f++;let r=v.find(t=>t.name===e&&t.kind===`extension`);if(!r)return X(`unknown extension: ${e}`);let i=o(`span`,`text-[11.5px] text-neutral-400`,``);n&&t(i,n.state,n.text);let a=ce(`every run of the update task`);R.replaceChildren(Z(r.name,o(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,r.source===`binary`?`installed by Pier`:`ships with Pier`)),o(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,o(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,r.summary),o(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(r.source===`bundled`?r.adds:[]).flatMap(e=>[o(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),o(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...r.source===`binary`?[o(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),o(`dd`,`font-mono text-[12px] leading-snug ${r.binary.error?`text-red-600`:`text-neutral-500`}`,he(r))]:[]),d(`Enabled`,r.source===`binary`?`Installed into Pier's own bin directory, first on the PATH every session and task inherits; it registers its own Pi extension. Switching it off uninstalls both.`:`Loaded from inside Pier — nothing is installed and no update touches your own extensions. A session mid-turn keeps the tools it started with; the next message picks this up.`,r.enabled,t=>void ge(r.name,t,t=>Q(e,t))),o(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...r.source===`binary`?a?[`A daily task installs and updates it — its history is `,a,`.`]:[`Its installs run as the daily update task.`]:[`An extension of your own that registers the same tool wins: this copy stands down and says so in the log.`]),i))}function $(e,r={name:``,toml:``}){f++;let i=o(`span`,`text-[11.5px] text-neutral-400`,``);e&&t(i,e.state,e.text);let a=j(),s=ce(`the update task`),c=e=>{let t=o(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,o(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,o(`span`,`font-mono`,e.name),...A(e)?[te(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),o(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||he(e)),...e.summary?[o(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,he(e))]:[]),n=d(``,``,e.enabled,t=>void ge(e.name,t,e=>$(e))),r=o(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=pe(e,D);ne(t.body,t.saved).then(e=>$(e))},o(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...A(e)?[r]:[],n)},l={...r},u=o(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),p=E(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),m=document.createElement(`textarea`);m.className=`${k} h-24 resize-y font-mono leading-snug`,m.spellcheck=!1,m.value=l.toml,m.placeholder=`spec = "github:owner/repo"
2
2
  exe = "tool"`,m.oninput=()=>l.toml=m.value;let h=o(`button`,`btn btn-primary text-[12.5px]`,`Add`);h.onclick=()=>{let e={name:l.name.trim(),toml:l.toml.trim()};if(!e.name||!e.toml)return t(i,`failed`,`A custom tool needs a name and a block with a spec line.`);h.disabled=!0,ne({customTools:[...D,e],tool:{name:e.name,on:!0}},`Added ${e.name} — installing now.`).then(e=>$(e,e.state===`failed`?l:void 0))},R.replaceChildren(Z(`command-line tools`,o(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`installed by Pier`)),o(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,o(`p`,`max-w-2xl text-[12.5px] leading-relaxed text-neutral-500`,`Pier writes no downloader: `,me(),` does the work — a declarative installer that resolves a spec like `,o(`span`,`font-mono text-[11.5px]`,`github:owner/repo`),` to the right release asset for this machine, verifies it, and upgrades in place. Pier bootstraps it, generates its config from the switches below, and keeps its files under Pier's own directory — your own ubix setup is untouched.`),y?o(`p`,`max-w-2xl text-[12.5px] text-red-600`,y):o(`div`,`flex max-w-2xl flex-col`,...a.map(c)),o(`div`,`flex max-w-2xl flex-col gap-2 border-t border-neutral-200 pt-4`,o(`span`,`text-[12.5px] font-medium text-neutral-600`,`Add one of your own`),n(`Name`,p),n(`The block Pier writes under the header`,m,{hint:`A line that opens a section of its own is refused, because it could rewrite the rest of the file.`}),o(`div`,`flex items-center gap-3`,u,h)),o(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...s?[`Installs and daily updates run as `,s,` — output, failures and all.`]:[`Switching one on creates the daily task that installs it and keeps it current.`]),i))}async function ge(e,t,n){let r=v.find(t=>t.name===e);n(await ne(re(e,t),r?.source===`binary`?t?`Saved — installing now; watch the run.`:`Saved — uninstalling in the next run.`:`Saved — sessions take it on their next message.`))}async function _e(e,t){let n=++f,r=await P(`/api/config/resource${B(`&kind=${e}&name=${encodeURIComponent(t)}`)}`,`failed to load ${t}`,{cache:`no-store`});if(!r.ok){n===f&&X(r.error);return}if(n!==f)return;let{content:i}=r.value,a=await N(t);n===f&&R.replaceChildren(Z(t,o(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`read-only`)),o(`div`,`min-h-0 flex-1 overflow-auto`,x(S(i),a)))}function ve(){M.replaceChildren(new Option(p?`Global (${p})`:`Global`,`global`),...i().map(e=>new Option(`${l(e)} — ${e}`,e))),[...M.options].some(e=>e.value===a)||(a=`global`),M.value=a}return m(r,()=>{ve(),U()},w)}var he=`medium`,Q=e=>`${e.provider}/${e.id}`,$=`Off — the first message is the title`,ge=[`hardest reasoning — architecture, gnarly debugging`,`long autonomous implementation runs`,`balanced default — implementation, review`,`cheap & fast — listings, extraction, simple checks`,`cross-vendor second opinion`];function _e(){let r=[],i=[],a=!1,s,l=o(`span`,`text-[11.5px]`,``),u=o(`span`,`text-[11.5px]`,``),d=o(`div`,`flex items-center gap-3`),f=b(`Save menu`,!0),m=o(`div`,`flex min-w-0 flex-col gap-2`),v=o(`div`,`flex items-center gap-2`),x=o(`div`,`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-6`);function S(){a=!0,t(l,`idle`,`unsaved changes`)}function C(e){let t=g(e.note??``);t.classList.remove(`w-full`),t.classList.add(`min-w-0`,`flex-1`),t.placeholder=`why this one — pick a preset or write your own`,t.setAttribute(`list`,`model-menu-notes`),t.oninput=()=>{e.note=t.value,S()};let n=D(O.map(e=>[`thinking: ${p(e)}`,e]),e.thinking);n.classList.replace(`w-full`,`w-44`),n.classList.add(`flex-none`),n.onchange=()=>{e.thinking=n.value,S()};let i=b(`Remove`);i.classList.add(`flex-none`),i.onclick=()=>{r=r.filter(t=>t!==e),S(),E()};let a=o(`span`,`w-52 flex-none truncate font-mono text-[12px] text-neutral-700`,Q(e));return a.title=Q(e),o(`div`,`flex min-w-0 items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 shadow-2xs max-md:flex-wrap`,a,n,t,i)}function w(){let t=i.filter(e=>!r.some(t=>Q(t)===Q(e))),n=b(`Pin model`);n.prepend(e(R)),n.classList.add(`inline-flex`,`items-center`,`gap-1.5`,`flex-none`,`whitespace-nowrap`),n.disabled=t.length===0,n.onclick=()=>{let e=he;M(n,A({models:t,current:null,thinkingLevel:e,thinkingLevels:[...O],onThinkingPick:t=>{e=t},onPick:t=>{y(),r.push({provider:t.provider,id:t.id,thinking:e}),S(),E()}}))},v.replaceChildren(n)}function T(){let e=s,n=e&&!i.some(t=>Q(t)===Q(e))?[e,...i]:i,r=V(e?e.id:$,`${k} flex min-w-0 flex-1 cursor-pointer items-center truncate text-left hover:bg-neutral-50 ${e?`text-neutral-700`:`text-neutral-400`}`);e&&(r.title=Q(e));let a=e=>{y(),(async()=>{t(u,`saving`,`saving…`);let n=await _(`/api/settings`,{titleModel:e&&{provider:e.provider,id:e.id}},`PUT`);if(!n.ok)return t(u,`failed`,await c(n,`Could not save`)),T();s=(await n.json()).titleModel,t(u,`saved`,s?`Saved — names the next new session after its first reply.`:`Off.`),T()})()};r.onclick=()=>{let t=A({models:n,current:e,thinkingLevel:`medium`,thinkingLevels:[],onThinkingPick:()=>{},onPick:a}),i=V($,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);i.onclick=()=>a(null);let s=o(`div`,`flex flex-col`);s.append(t,o(`div`,`border-t border-neutral-200`),i),M(r,s)},d.replaceChildren(r,u)}function E(){m.replaceChildren(...r.length?r.map(C):[h(`Nothing pinned — every picker shows the curated catalog as is.`)]),w(),T()}async function j(){t(l,`saving`,`saving…`);let e=r.map(({provider:e,id:t,thinking:n,note:r})=>({provider:e,id:t,thinking:n,...r?.trim()?{note:r.trim()}:{}})),n=await _(`/api/settings`,{modelMenu:e},`PUT`);if(!n.ok)return t(l,`failed`,await c(n,`Could not save`));r=(await n.json()).modelMenu,a=!1,t(l,`saved`,`Saved — agents see it on their next models call.`),E()}f.onclick=()=>void j();function N(){a||(async()=>{let[e,n]=await Promise.all([P(`/api/settings`,`Could not load the menu`),P(`/api/models`,`Could not load the model catalog`)]);if(!e.ok)return t(l,`failed`,e.error);r=e.value.modelMenu,s=e.value.titleModel,i=n.ok?n.value:[],l.textContent=``,E()})()}let F=o(`datalist`,``);return F.id=`model-menu-notes`,F.append(...ge.map(e=>new Option(e))),x.append(B(`Model menu`,`Which few models this deployment favors, each with a usual reasoning level and one line of intent. Pinned entries lead every model picker, and agents delegating work match your notes against the task instead of guessing ids.`,n(`Pinned models`,m,{hint:`The note is what an agent matches a task against — say when to reach for it, not what it is.`}),n(`Add`,v,{hint:`The list is the live catalog — only models that exist right now can be pinned.`}),o(`div`,`flex items-center gap-3`,f,l),F),B(`Session titles`,`A session is titled by its first message unless a model names it: one short request after the first reply, on the model picked here — a small, cheap one is plenty. A failed request is reported in the session and the first message stays the title.`,n(`Title model`,d))),{el:x,load:N}}var ve=(e,t)=>{let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`http:`&&n.protocol!==`https:`)return null;let r=o(`a`,`text-indigo-600 hover:underline`,t);return r.href=n.href,r.target=`_blank`,r.rel=`noreferrer`,r};function ye(e,t,n,r){let i=document.createElement(`dialog`);i.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let a=o(`div`,`flex flex-col gap-2`),s=o(`div`,`flex flex-col gap-2`),l=o(`p`,`text-[12.5px] text-neutral-400`,`Starting…`),u=b(`Cancel`),d=(e,t)=>{l.className=`text-[12.5px] ${v[e]}`,l.textContent=t};i.append(o(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t),o(`div`,`flex max-h-[65vh] flex-col gap-3 overflow-y-auto px-4 py-3`,a,s,l),o(`div`,`flex justify-end border-t border-neutral-200 px-4 py-2.5`,u)),document.body.append(i),i.showModal();let f=e.id,p=e.state,m,h,y=new Set,x=!1,S=!1,C=async e=>{if(!S){if(e&&p===`running`){S=!0,u.disabled=!0;try{let e=await _(`/api/providers/flows/${f}/cancel`,{});if(!e.ok&&e.status!==404){d(`failed`,await c(e,`Could not cancel authentication flow`));return}}catch(e){d(`failed`,`Could not cancel authentication flow: ${String(e)}`);return}finally{S=!1,u.disabled=!1}}clearTimeout(m),i.close()}};u.onclick=()=>void C(!0),i.oncancel=e=>{e.preventDefault(),C(!0)},i.onclose=()=>{x=!0,clearTimeout(m),i.remove()};let w=e=>{if(e.type===`auth_url`){let t=o(`div`,`flex flex-col gap-1 text-[12.5px] text-neutral-600`);return e.instructions&&t.append(o(`p`,``,e.instructions)),t.append(ve(e.url,`Open authorization page`)??o(`span`,`text-red-600`,`Invalid authorization URL`)),t}if(e.type===`device_code`){let t=o(`div`,`flex flex-col gap-2 text-[12.5px] text-neutral-600`);return t.append(o(`div`,`flex items-center gap-2`,o(`code`,`font-mono text-[17px] font-semibold text-neutral-800`,e.userCode),H(`btn text-[11px]`,()=>e.userCode))),t.append(ve(e.verificationUri,`Open verification page`)??o(`span`,`text-red-600`,`Invalid verification URL`)),t}let t=o(`div`,`text-[12.5px] text-neutral-600`,e.message);if(e.type===`info`)for(let n of e.links??[]){let e=ve(n.url,n.label??n.url);e&&t.append(` `,e)}return t},T=(e,t)=>{h=t.id;let n;if(t.type===`select`){let e=document.createElement(`select`);e.append(...t.options.map(e=>new Option(e.description?`${e.label} — ${e.description}`:e.label,e.id))),n=e}else{let e=g(``,t.type===`secret`?`password`:`text`);e.placeholder=t.placeholder??``,e.autocomplete=`off`,n=e}n.className=`${n.tagName===`SELECT`?`select `:``}w-full rounded-lg border border-neutral-300 bg-white px-2.5 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`;let r=b(`Continue`,!0);r.type=`submit`;let i=o(`form`,`flex flex-col gap-2`,o(`label`,`text-[12.5px] font-medium text-neutral-700`,t.message),n,o(`div`,`flex justify-end`,r));i.onsubmit=i=>{i.preventDefault(),r.disabled=!0,(async()=>{try{let r=await _(`/api/providers/flows/${e.id}/respond`,{promptId:t.id,value:n.value});if(x)return;if(!r.ok){d(`failed`,await c(r,`Could not submit response`));return}y.add(t.id),h=void 0,s.replaceChildren(),d(`saving`,`Waiting for provider…`)}catch(e){x||d(`failed`,`Could not submit response: ${String(e)}`)}finally{r.disabled=!1}})()},s.replaceChildren(i),n.focus()},E=e=>{p=e.state,a.replaceChildren(...e.events.map(w));let t=e.prompt&&!y.has(e.prompt.id)?e.prompt:void 0;if(t?.id!==h&&(t?T(e,t):(h=void 0,s.replaceChildren())),e.state===`running`){d(`saving`,t?`Waiting for your response.`:`Waiting for provider…`);return}clearTimeout(m),s.replaceChildren(),e.state===`succeeded`?d(`saved`,`${n} configured.`):d(`failed`,e.state===`cancelled`?`Cancelled.`:e.error??`Authentication failed.`),u.textContent=`Close`,u.onclick=()=>void C(!1),e.state===`succeeded`&&r()},D=async()=>{if(!(x||p!==`running`))try{let e=await fetch(`/api/providers/flows/${f}`,{cache:`no-store`});if(x)return;if(!e.ok){d(`failed`,await c(e,`Authentication status unavailable`)),e.status===404?p=`failed`:m=setTimeout(()=>void D(),1e3);return}E(await e.json()),p===`running`&&(m=setTimeout(()=>void D(),500))}catch(e){if(x)return;d(`failed`,`Authentication status unavailable: ${String(e)}`),m=setTimeout(()=>void D(),1e3)}};E(e),p===`running`&&(m=setTimeout(()=>void D(),500))}var be=[`anthropic`,`openai`,`openai-codex`,`google`,`openrouter`,`deepseek`],xe=[[`OpenAI Chat Completions`,`openai-completions`],[`OpenAI Responses`,`openai-responses`],[`Anthropic Messages`,`anthropic-messages`],[`Google Generative AI`,`google-generative-ai`]],Se=`__custom__`;async function Ce(e){let n=b(`Add provider`,!0);n.classList.add(`ml-auto`);let r=o(`div`,`flex flex-none items-center gap-3 rounded-t-3xl ${C} px-4 py-2`,o(`h2`,`text-[13px] font-semibold text-neutral-700`,`Providers`),n),i=o(`div`,`min-h-0 flex-1 overflow-y-auto`);e.replaceChildren(r,i);let a=[],s=``,l=async()=>{i.replaceChildren(o(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Loading…`));try{let[e,t]=await Promise.all([P(`/api/providers`,`Could not load providers`,{cache:`no-store`}),P(`/api/models`,`the model catalog could not be read`,{cache:`no-store`})]);if(a=t.ok?t.value:[],s=t.ok?``:t.error,!e.ok){i.replaceChildren(h(e.error));return}let r=e.value;n.onclick=()=>Te(r,void 0,l),m(r)}catch(e){i.replaceChildren(h(`Could not load providers: ${String(e)}`))}},u=async e=>{if(window.confirm(`Remove the stored credential for ${e.name}?`))try{let t=await _(`/api/providers/${encodeURIComponent(e.id)}/logout`,{});if(!t.ok){window.alert(await c(t,`Could not remove credential`));return}await l()}catch(e){window.alert(`Could not remove credential: ${String(e)}`)}},d=e=>[...new Set([...(e.models??[]).map(e=>e.id),...a.filter(t=>t.provider===e.id).map(e=>e.id)])],f=(e,t)=>o(`div`,`flex flex-col gap-1`,o(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),o(`pre`,`max-h-56 overflow-auto whitespace-pre-wrap break-all rounded-md bg-neutral-50 p-2 font-mono text-[11.5px] leading-relaxed text-neutral-600`,t)),p=async(e,t)=>{try{let n=await _(`/api/providers/${encodeURIComponent(e)}/check`,{model:t});return n.ok?await n.json():await c(n,`Could not test`)}catch(e){return`Could not test: ${String(e)}`}},m=e=>{let n=e.filter(e=>e.configured);if(!n.length){i.replaceChildren(h(`No providers configured.`));return}i.replaceChildren(...n.map(n=>{let r=o(`div`,`min-w-0 flex-1`,o(`div`,`truncate text-[13px] font-medium text-neutral-700`,n.name),o(`div`,`truncate font-mono text-[11px] text-neutral-400`,n.id)),i=n.stored===`api_key`?`API key`:n.stored===`oauth`?`OAuth`:n.source??`configured`,a=n.endpoint??`Default endpoint`,c=o(`div`,`flex min-w-32 flex-col items-start gap-1`,te(`configured`,`bg-emerald-50 text-emerald-700 ring-emerald-200`),o(`span`,`max-w-48 truncate text-[11px] text-neutral-500`,i),o(`span`,`max-w-48 truncate text-[11px] text-neutral-400`,a));c.title=a;let m=o(`span`,`text-[11.5px]`,``),h=o(`div`,`hidden flex-col gap-2 px-4 pb-3`,m),g=o(`div`,`flex flex-wrap justify-end gap-1.5`),_=d(n);if(!_.length)t(m,`idle`,s||`No models to test: none are configured here.`),h.classList.replace(`hidden`,`flex`);else{let e=D([[`Model to test…`,``],..._.map(e=>[e,e])],``);e.classList.add(`max-w-52`,`text-[12px]`);let r=b(`Test`);r.disabled=!0,e.onchange=()=>r.disabled=!e.value,r.onclick=()=>{let i=e.value;r.disabled=!0,h.replaceChildren(m),h.classList.replace(`hidden`,`flex`),t(m,`saving`,`asking ${i}…`),p(n.id,i).then(e=>{if(r.disabled=!1,typeof e==`string`)return t(m,`failed`,e);t(m,e.ok?`saved`:`failed`,`${e.model} ${e.ok?`answered`:`did not answer`} in ${e.ms} ms`),h.append(f(`sent`,e.request||`(the request was never made)`),f(e.ok?`answered`:`replied`,e.response))})},g.append(e,r)}if(n.builtin||n.api&&n.models){let t=b(`Edit`);t.onclick=()=>Te(e,n,l),g.append(t)}if(n.stored){let e=b(`Remove credential`);e.onclick=()=>void u(n),g.append(e)}return o(`div`,`border-b border-neutral-100`,o(`div`,`grid grid-cols-[minmax(8rem,1fr)_minmax(8rem,auto)_minmax(9rem,auto)] items-center gap-3 px-4 py-2.5 max-sm:grid-cols-[1fr_auto]`,r,c,g),h)}))};await l()}function we(e,t){let n=t.filter(e=>!e.configured&&e.methods.length&&(e.builtin||e.api!==void 0&&e.models!==void 0)),r=(t,n)=>{if(!n.length)return;let r=document.createElement(`optgroup`);r.label=t,r.append(...n.map(e=>new Option(e.name,e.id))),e.append(r)};r(`Common`,be.flatMap(e=>n.filter(t=>t.id===e))),r(`More providers`,n.filter(e=>e.builtin&&!be.includes(e.id)).sort((e,t)=>e.name.localeCompare(t.name))),r(`Custom providers`,n.filter(e=>!e.builtin).sort((e,t)=>e.name.localeCompare(t.name))),e.append(new Option(`Custom provider…`,Se))}function Te(e,t,r){let i=document.createElement(`dialog`);i.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let a=document.createElement(`select`);a.className=`${k} select`,t||we(a,e);let s=g(),l=g(),d=g(),f=document.createElement(`select`);f.className=`${k} select`,f.append(...xe.map(([e,t])=>new Option(e,t)));let p=u(``,4);p.placeholder=`model-id
3
3
  another-model-id`;let m=document.createElement(`input`);m.type=`checkbox`;let h=D([[`Up to High`,`high`],[`Up to Extra high`,`xhigh`],[`Up to Max`,`max`]],`high`);h.classList.replace(`w-full`,`w-48`),m.onchange=()=>{h.disabled=!m.checked};let v=document.createElement(`select`);v.className=`${k} select`;let y=o(`div`,`flex flex-col gap-4`),x=o(`span`,`text-[11.5px] text-red-600`,``),S=b(`Cancel`),C=b(t?`Save`:`Add`,!0);C.type=`submit`;let w=()=>t??e.find(e=>e.id===a.value),T=()=>{let e=w(),r=e?!e.builtin:a.value===Se;s.value=e?.id??``,s.disabled=t!==void 0,l.value=e?.name??``,d.value=e?.endpoint??``,f.value=e?.api??`openai-completions`,p.value=e?.models?.map(e=>e.id).join(`
4
4
  `)??``;let i=e?.models?.map(e=>e.reasoning)??[];m.checked=i.length?i.every(Boolean):!e,m.indeterminate=i.some(Boolean)&&!i.every(Boolean);let c=new Set((e?.models??[]).filter(e=>e.reasoning).map(e=>e.effort??`high`)),u=c.size>1;h.replaceChildren(...u?[new Option(`Keep as configured`,``)]:[],new Option(`Up to High`,`high`),new Option(`Up to Extra high`,`xhigh`),new Option(`Up to Max`,`max`)),h.value=u?``:[...c][0]??`high`,h.disabled=!m.checked&&!m.indeterminate;let g=[];e?.configured&&g.push(new Option(`Keep current authentication`,``));let _=e?.methods??[{type:`api_key`,name:`API key`}];for(let t of _.filter(t=>e?.builtin!==!1||t.type===`api_key`))g.push(new Option(t.name,t.type));v.replaceChildren(...g);let b=[];t||b.push(n(`Provider`,a)),r?b.push(n(`Provider ID`,s),n(`Display name`,l),n(`Endpoint`,d),n(`API format`,f),n(`Models`,p),n(`Model capabilities`,o(`div`,`flex flex-wrap items-center gap-3`,o(`label`,`flex items-center gap-2 text-[12.5px] text-neutral-600`,m,o(`span`,``,`Reasoning`)),h),{hint:`Extra high and Max reach the model only if it accepts them; every reasoning model has High.`})):(d.placeholder=`Provider default`,b.push(n(`Endpoint`,d))),b.push(n(`Authentication`,v)),y.replaceChildren(...b)};a.onchange=T,T();let E=o(`form`,`flex flex-col gap-4 px-4 py-3`,y,o(`div`,`flex items-center justify-end gap-2`,x,S,C)),O=!1;S.onclick=()=>{O||i.close()},i.oncancel=e=>{O&&e.preventDefault()},E.onsubmit=e=>{if(e.preventDefault(),O)return;x.textContent=``;let t=w(),n=(t?!t.builtin:a.value===Se)?{kind:`custom`,id:s.value.trim(),...l.value.trim()?{name:l.value.trim()}:{},endpoint:d.value.trim(),api:f.value,models:[...new Set(p.value.split(`
@@ -1,3 +1,3 @@
1
- import{$ as e,H as t,P as n,S as r,V as i,b as a,q as o,rt as s,v as c}from"./index-DzXDXra_.js";var l=e=>e===null?`-`:new Date(e).toLocaleString(),u=e=>e.startedAt===null?`-`:i((e.finishedAt??Date.now())-e.startedAt),d=e=>e.state===`succeeded`&&e.matched===!1?`No match`:e.state,f={queued:`bg-neutral-100 text-neutral-600 ring-neutral-200`,running:`bg-sky-50 text-sky-700 ring-sky-200`,succeeded:`bg-emerald-50 text-emerald-700 ring-emerald-200`,failed:`bg-red-50 text-red-700 ring-red-200`,cancelled:`bg-amber-50 text-amber-700 ring-amber-200`,interrupted:`bg-amber-50 text-amber-700 ring-amber-200`,skipped:`bg-neutral-100 text-neutral-600 ring-neutral-200`};function p(e){let t=d(e);return c(t,t===`No match`?f.skipped:f[e.state],e.state===`running`?`animate-pulse bg-sky-500`:void 0)}function m(e){return e.archived?c(`Archived`,`bg-neutral-50 text-neutral-400 ring-neutral-200`):e.trigger.type===`manual`?c(`Manual`,`bg-neutral-100 text-neutral-600 ring-neutral-200`):e.enabled?c(`Enabled`,`bg-emerald-50 text-emerald-700 ring-emerald-200`):c(`Paused`,`bg-amber-50 text-amber-700 ring-amber-200`)}var h=`px-4 pt-4 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,g=`m-4 mt-2 whitespace-pre-wrap break-words rounded-lg border border-black/[0.06] bg-black/[0.025] px-3 py-2 font-mono text-[12px] leading-snug dark:border-neutral-200 dark:bg-neutral-100`,_=e=>e.trigger.type===`manual`?`Manual`:e.trigger.type===`cron`?`${e.trigger.expression} (${e.trigger.timezone})`:`Every ${e.trigger.intervalSeconds}s · ${e.trigger.mode}`,v=e=>e.action.type===`agent`?`Agent · ${e.action.session.mode}`:e.action.type===`bash`?`Bash`:e.action.type===`system`?`System`:`Task`;function y(e,n){let r=t(`div`,`grid max-w-4xl grid-cols-[6rem_minmax(0,1fr)] gap-x-5 gap-y-3.5 p-4 text-[13px] md:grid-cols-[9.375rem_minmax(0,1fr)]`),i=[[`Status`,e.archived?`Archived`:e.trigger.type===`manual`?`Manual`:e.enabled?`Enabled`:`Paused`],[`Trigger`,_(e)],[`Action`,v(e)],[`Timeout`,`${e.timeoutSeconds}s`],[`Next run`,l(e.nextRunAt)],[`Revision`,String(e.revision)],[`Created by`,e.createdBySessionId??e.creator],[`Callback`,e.callback.type===`session`?e.callback.sessionId:e.callback.type],[`Description`,e.description||`-`]];e.action.type===`agent`&&(i.push([`Session policy`,e.action.session.mode]),e.action.session.mode===`reuse`&&i.push([`Session`,e.action.session.sessionId]),`cwd`in e.action.session&&i.push([`Directory`,e.action.session.cwd]),e.action.launch?.model&&i.push([`Model`,`${e.action.launch.model.provider}/${e.action.launch.model.id}`]),e.action.launch?.thinking&&i.push([`Thinking`,e.action.launch.thinking]),i.push([`Prompt`,e.action.prompt])),e.action.type===`bash`&&i.push([`Directory`,e.action.cwd],[`Script`,e.action.script]),e.action.type===`task`&&i.push([`Target task`,e.action.taskId]),e.action.type===`system`&&i.push([`System action`,e.action.name]),e.trigger.type===`watch`&&i.push([`Probe`,e.trigger.script]);for(let[e,n]of i)r.append(t(`span`,`pt-px text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),t(`pre`,`whitespace-pre-wrap break-words font-mono text-[12.5px] leading-snug`,n));if(e.action.type===`agent`&&e.action.session.mode===`reuse`){let{sessionId:i}=e.action.session,o=a(`Open session`);o.onclick=()=>n(i),r.append(t(`span`,``,``),o)}return r}function b(e){return[e.pendingDecisionId?`Awaiting decision`:``,e.callbackState&&e.callbackState!==`delivered`?`Callback not delivered (${e.callbackState})`:``,e.groupCallbackState&&e.groupCallbackState!==`delivered`?`Group callback not delivered (${e.groupCallbackState})`:``].filter(Boolean).join(` · `)}function x(e,n,i,a){let o=t(`div`,`divide-y divide-neutral-100`);for(let e of n){let n=t(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2.5 text-left text-[12.5px] transition-colors hover:bg-neutral-50 md:grid-cols-[7.5rem_minmax(0,1fr)_7.5rem_6.25rem]`);n.setAttribute(`type`,`button`),n.append(t(`span`,`flex`,p(e)),t(`span`,`truncate text-neutral-500`,l(e.queuedAt)),t(`span`,`text-neutral-500`,e.triggerSource),t(`span`,`text-right font-mono text-[11.5px] text-neutral-400`,u(e))),n.onclick=()=>i(e.id),o.append(n)}n.length||o.append(t(`div`,`p-4`,r(`No runs yet.`))),e.replaceChildren(o),e.scrollTop=a.top,e.onscroll=()=>{a.top=e.scrollTop}}var S=e=>`Exit code: ${e.exitCode??`-`}\nstdout:\n${e.stdout}${e.stdoutTruncated?`
1
+ import{$ as e,H as t,P as n,S as r,V as i,b as a,q as o,rt as s,v as c}from"./index-DbFu15NN.js";var l=e=>e===null?`-`:new Date(e).toLocaleString(),u=e=>e.startedAt===null?`-`:i((e.finishedAt??Date.now())-e.startedAt),d=e=>e.state===`succeeded`&&e.matched===!1?`No match`:e.state,f={queued:`bg-neutral-100 text-neutral-600 ring-neutral-200`,running:`bg-sky-50 text-sky-700 ring-sky-200`,succeeded:`bg-emerald-50 text-emerald-700 ring-emerald-200`,failed:`bg-red-50 text-red-700 ring-red-200`,cancelled:`bg-amber-50 text-amber-700 ring-amber-200`,interrupted:`bg-amber-50 text-amber-700 ring-amber-200`,skipped:`bg-neutral-100 text-neutral-600 ring-neutral-200`};function p(e){let t=d(e);return c(t,t===`No match`?f.skipped:f[e.state],e.state===`running`?`animate-pulse bg-sky-500`:void 0)}function m(e){return e.archived?c(`Archived`,`bg-neutral-50 text-neutral-400 ring-neutral-200`):e.trigger.type===`manual`?c(`Manual`,`bg-neutral-100 text-neutral-600 ring-neutral-200`):e.enabled?c(`Enabled`,`bg-emerald-50 text-emerald-700 ring-emerald-200`):c(`Paused`,`bg-amber-50 text-amber-700 ring-amber-200`)}var h=`px-4 pt-4 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,g=`m-4 mt-2 whitespace-pre-wrap break-words rounded-lg border border-black/[0.06] bg-black/[0.025] px-3 py-2 font-mono text-[12px] leading-snug dark:border-neutral-200 dark:bg-neutral-100`,_=e=>e.trigger.type===`manual`?`Manual`:e.trigger.type===`cron`?`${e.trigger.expression} (${e.trigger.timezone})`:`Every ${e.trigger.intervalSeconds}s · ${e.trigger.mode}`,v=e=>e.action.type===`agent`?`Agent · ${e.action.session.mode}`:e.action.type===`bash`?`Bash`:e.action.type===`system`?`System`:`Task`;function y(e,n){let r=t(`div`,`grid max-w-4xl grid-cols-[6rem_minmax(0,1fr)] gap-x-5 gap-y-3.5 p-4 text-[13px] md:grid-cols-[9.375rem_minmax(0,1fr)]`),i=[[`Status`,e.archived?`Archived`:e.trigger.type===`manual`?`Manual`:e.enabled?`Enabled`:`Paused`],[`Trigger`,_(e)],[`Action`,v(e)],[`Timeout`,`${e.timeoutSeconds}s`],[`Next run`,l(e.nextRunAt)],[`Revision`,String(e.revision)],[`Created by`,e.createdBySessionId??e.creator],[`Callback`,e.callback.type===`session`?e.callback.sessionId:e.callback.type],[`Description`,e.description||`-`]];e.action.type===`agent`&&(i.push([`Session policy`,e.action.session.mode]),e.action.session.mode===`reuse`&&i.push([`Session`,e.action.session.sessionId]),`cwd`in e.action.session&&i.push([`Directory`,e.action.session.cwd]),e.action.launch?.model&&i.push([`Model`,`${e.action.launch.model.provider}/${e.action.launch.model.id}`]),e.action.launch?.thinking&&i.push([`Thinking`,e.action.launch.thinking]),i.push([`Prompt`,e.action.prompt])),e.action.type===`bash`&&i.push([`Directory`,e.action.cwd],[`Script`,e.action.script]),e.action.type===`task`&&i.push([`Target task`,e.action.taskId]),e.action.type===`system`&&i.push([`System action`,e.action.name]),e.trigger.type===`watch`&&i.push([`Probe`,e.trigger.script]);for(let[e,n]of i)r.append(t(`span`,`pt-px text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),t(`pre`,`whitespace-pre-wrap break-words font-mono text-[12.5px] leading-snug`,n));if(e.action.type===`agent`&&e.action.session.mode===`reuse`){let{sessionId:i}=e.action.session,o=a(`Open session`);o.onclick=()=>n(i),r.append(t(`span`,``,``),o)}return r}function b(e){return[e.pendingDecisionId?`Awaiting decision`:``,e.callbackState&&e.callbackState!==`delivered`?`Callback not delivered (${e.callbackState})`:``,e.groupCallbackState&&e.groupCallbackState!==`delivered`?`Group callback not delivered (${e.groupCallbackState})`:``].filter(Boolean).join(` · `)}function x(e,n,i,a){let o=t(`div`,`divide-y divide-neutral-100`);for(let e of n){let n=t(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2.5 text-left text-[12.5px] transition-colors hover:bg-neutral-50 md:grid-cols-[7.5rem_minmax(0,1fr)_7.5rem_6.25rem]`);n.setAttribute(`type`,`button`),n.append(t(`span`,`flex`,p(e)),t(`span`,`truncate text-neutral-500`,l(e.queuedAt)),t(`span`,`text-neutral-500`,e.triggerSource),t(`span`,`text-right font-mono text-[11.5px] text-neutral-400`,u(e))),n.onclick=()=>i(e.id),o.append(n)}n.length||o.append(t(`div`,`p-4`,r(`No runs yet.`))),e.replaceChildren(o),e.scrollTop=a.top,e.onscroll=()=>{a.top=e.scrollTop}}var S=e=>`Exit code: ${e.exitCode??`-`}\nstdout:\n${e.stdout}${e.stdoutTruncated?`
2
2
  [stdout truncated]`:``}\nstderr:\n${e.stderr}${e.stderrTruncated?`
3
3
  [stderr truncated]`:``}`;async function C(r,i,c,d,f){let m=String(Number(r.dataset.runRequest??0)+1);r.dataset.runRequest=m,r.onscroll=()=>{f.scrollTop=r.scrollTop};let _=a(`Runs`);_.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,_.onclick=()=>{f.selectedId=null,f.scrollTop=0,c()};let v=n(_,e(s,`h-3.5 w-3.5 text-neutral-400`),t(`span`,`min-w-0 truncate font-mono text-[12px] text-neutral-500`,i)),C=r.dataset.runId!==i;C&&(r.dataset.runId=i,r.replaceChildren(v,t(`p`,`p-4 text-[13px] text-neutral-500`,`Loading run...`)));let[w,T]=await Promise.all([o(`/api/task-runs/${i}`,`Could not load the run`),o(`/api/task-runs/${i}/messages`,`Could not load the run's messages`)]);if(!r.isConnected||r.dataset.runRequest!==m||f.selectedId!==i)return;if(!w.ok){let e=await o(`/api/task-groups/${i}`,w.error);if(!r.isConnected||r.dataset.runRequest!==m||f.selectedId!==i)return;if(f.drawn=``,!e.ok){r.replaceChildren(v,t(`p`,`p-4 text-[13px] text-red-600`,w.error));return}let{group:n,members:a}=e.value,s=t(`div`,`min-w-0`);r.replaceChildren(v,t(`div`,`border-b border-neutral-100 bg-neutral-50/60 px-4 py-3 text-[12.5px] text-neutral-600`,[`Task group \u00b7 join ${n.join}`,`${String(a.length)} runs`,n.callbackState?`callback ${n.callbackState}`:``].filter(Boolean).join(` · `)),s),x(s,a,d.openRun,{top:0});return}let E=w.value,D=T.ok?T.value:[],O=JSON.stringify([E,T]);if(!C&&f.drawn===O)return;if(f.drawn=O,E.targetSessionId){let e=a(`Open session`);e.classList.add(`ml-auto`),e.onclick=()=>d.openSession(E.targetSessionId),v.append(e)}if(E.state===`queued`||E.state===`running`){let e=a(`Stop run`);e.onclick=()=>{window.confirm(`Stop this run of "${E.context.definition.name}"?`)&&d.mutate(`/api/task-runs/${E.id}/cancel`)},v.append(e)}let k=t(`div`,`min-w-0`),A=b(E);k.append(t(`div`,`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-neutral-100 bg-neutral-50/60 px-4 py-3 text-[12.5px]`,t(`span`,`flex items-center gap-2`,p(E),t(`span`,`font-medium`,E.context.definition.name)),...A?[t(`span`,`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 ring-1 ring-amber-200`,A)]:[],t(`span`,`text-neutral-500`,l(E.queuedAt)),t(`span`,`text-neutral-500`,E.triggerSource),t(`span`,`font-mono text-[11.5px] text-neutral-400`,u(E))));let j=t(`div`,`flex flex-wrap items-center gap-2 border-b border-neutral-100 px-4 py-3 text-[12px]`),M=(e,t)=>{let n=a(e);n.classList.add(`max-w-full`,`break-all`,`!whitespace-normal`),n.onclick=t,j.append(n)};if(E.context.definition.kind===`task`&&M(`Task: ${E.context.definition.name}`,()=>d.openTask(E.taskId)),E.parentRunId&&M(`Parent: ${E.parentRunId}`,()=>d.openRun(E.parentRunId)),E.resumedFromRunId&&M(`Resumed from: ${E.resumedFromRunId}`,()=>d.openRun(E.resumedFromRunId)),E.result?.type===`task`){let e=E.result.runId;M(`Child result: ${e}`,()=>d.openRun(e))}E.groupId&&j.append(t(`span`,`break-all font-mono text-[11.5px] text-neutral-500`,`Group: ${E.groupId}`)),k.append(j);for(let e of[E.error,E.skipReason,E.callbackError])e&&k.append(t(`p`,`m-4 whitespace-pre-wrap break-words rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-[12.5px] text-red-700`,e));if(E.result){let e=E.result,n=e.type===`agent`||e.type===`system`?e.text:e.type===`bash`?S(e):e.type===`task`?`Child run: ${e.runId}`:`Watch did not match.`;k.append(t(`h3`,h,`Result`),t(`pre`,g,n||`No output.`))}E.probe&&k.append(t(`h3`,h,`Watch probe: ${E.matched===null?`not evaluated`:E.matched?`matched`:`not matched`}`),t(`pre`,g,S(E.probe)));let N=t(`details`,`border-t border-neutral-200`);if(N.append(t(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,e(s,`chev h-3 w-3`),`Configuration snapshot (revision ${E.taskRevision})`),y(E.context.definition,d.openSession)),k.append(N),T.ok||k.append(t(`p`,`m-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-[12.5px] text-red-700`,T.error)),D.length){let e=t(`div`,`mt-2 divide-y divide-neutral-100 border-t border-neutral-100`);for(let n of D){let r=t(`div`,`grid grid-cols-[auto_1fr] gap-3 px-4 py-2 text-[12px] md:grid-cols-[6.25rem_6.25rem_minmax(0,1fr)]`);r.append(t(`span`,`font-medium`,n.kind),t(`span`,`text-neutral-500`,n.state),t(`span`,`col-span-2 whitespace-pre-wrap break-words md:col-span-1`,n.content)),n.error&&r.append(t(`span`,`col-span-2 break-words text-red-600 md:col-span-3`,n.error)),e.append(r)}k.append(t(`div`,`border-t border-neutral-200`,t(`div`,h,`Messages`),e))}let P=t(`details`,`border-t border-neutral-200`);P.open=f.rawOpen,P.ontoggle=()=>{P.isConnected&&(f.rawOpen=P.open)},P.append(t(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,e(s,`chev h-3 w-3`),`Raw record`),t(`pre`,g,JSON.stringify(E,null,2))),k.append(P),r.replaceChildren(v,k),r.scrollTop=f.scrollTop,r.onscroll=()=>{f.scrollTop=r.scrollTop}}export{x as a,u as c,C as i,m as l,l as n,b as o,y as r,p as s,v as t,_ as u};
@@ -1,4 +1,4 @@
1
- import{$ as e,C as t,G as n,H as r,K as i,M as a,O as o,P as s,Q as c,R as l,S as u,T as d,X as f,Y as p,b as m,k as h,l as g,m as _,q as v,rt as y,u as b,v as x}from"./index-DzXDXra_.js";import{a as S,c as C,l as w,n as T,r as E,s as D,t as O,u as k}from"./task-runs-BCakxFk8.js";function A(e,t){let n=e.map(e=>[`${e.title??`Untitled`} · ${e.cwd}`,e.id]);return t&&!n.some(([,e])=>e===t)&&n.push([`Current session · ${t}`,t]),n}function j(e,n){let i=document.createElement(`dialog`);i.className=`m-auto w-[38.75rem] max-w-[94vw] rounded-lg border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20`;let o=document.createElement(`form`);o.className=`flex max-h-[88vh] flex-col`;let s=r(`span`,`mr-auto text-[12px] text-red-600`),l=r(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,n?`Edit task`:`New task`),u=r(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),f=d(n?.name??``);f.required=!0;let p=d(n?.description??``),_=d(String(n?.timeoutSeconds??3600),`number`);_.min=`1`,_.max=`86400`;let v=h([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],n?.trigger.type??`manual`),y=h([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],n?.action.type??`bash`),x=h([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],n?.callback.type??`none`),S=n?.callback.type===`session`?n.callback.sessionId:null,C=h(A(e.sessions(),S),S??``),w=t(`Callback session`,C);w.classList.toggle(`hidden`,x.value!==`session`),x.onchange=()=>w.classList.toggle(`hidden`,x.value!==`session`),u.append(t(`Name`,f),t(`Description`,p),t(`Trigger`,v),t(`Action`,y),t(`Callback`,x),w,t(`Timeout (seconds)`,_));let T=r(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);u.append(T);let E=()=>{T.replaceChildren();let l,u,m,S,w,E;if(v.value===`cron`)l=d(n?.trigger.type===`cron`?n.trigger.expression:`0 9 * * *`),u=d(n?.trigger.type===`cron`?n.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),T.append(t(`Cron`,l),t(`Timezone`,u));else if(v.value===`watch`){m=a(n?.trigger.type===`watch`?n.trigger.script:``,4),E=d(n?.trigger.type===`watch`?n.trigger.cwd:e.sessions()[0]?.cwd??``),S=d(String(n?.trigger.type===`watch`?n.trigger.intervalSeconds:60),`number`),w=h([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],n?.trigger.type===`watch`?n.trigger.mode:`repeat`);let r=t(`Probe script (0=match, 1=no match)`,m);r.classList.add(`col-span-2`),T.append(r,t(`Probe directory`,E),t(`Interval (seconds)`,S),t(`Mode`,w))}let D,O,k,j,N,P,F,I,L,R;if(y.value===`bash`){O=d(n?.action.type===`bash`?n.action.cwd:e.sessions()[0]?.cwd??``),D=a(n?.action.type===`bash`?n.action.script:``,6);let i=t(`Bash script`,D);i.classList.add(`col-span-2`),T.append(t(`Working directory`,O),r(`span`,``),i)}else if(y.value===`agent`){let r=e.sessions(),i=n?.action.type===`agent`?n.action:null,o=i?.session.mode===`reuse`?i.session.sessionId:``,s=A(r,o||null);k=h([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`]],i?.session.mode===`reuse`?`reuse`:`fresh`),j=h(s,o||s[0]?.[1]||``);let l=i&&`cwd`in i.session?i.session.cwd??``:``;N=d(l||r[0]?.cwd||``),P=a(i?.prompt??``,6),F=h([[`Project default`,``],...g.map(e=>[c(e),e])],i?.launch?.thinking??``),I=d(i?.launch?.model?.provider??``),L=d(i?.launch?.model?.id??``);let u=t(`Session`,j),f=t(`Child directory`,N),p=[t(`Thinking`,F),t(`Model provider (optional)`,I),t(`Model id (optional)`,L)],m=()=>{let e=k?.value===`reuse`;u.classList.toggle(`hidden`,!e),f.classList.toggle(`hidden`,e);for(let t of p)t.classList.toggle(`hidden`,e)};k.onchange=m,m();let _=t(`Prompt`,P);_.classList.add(`col-span-2`),T.append(t(`Session policy`,k),u,f,...p,_)}else R=h(e.tasks().filter(e=>e.id!==n?.id&&!e.archived).map(e=>[e.name,e.id]),n?.action.type===`task`?n.action.taskId:``),T.append(t(`Target task`,R));o.onsubmit=t=>{t.preventDefault();let r=v.value===`manual`?{type:`manual`}:v.value===`cron`?{type:`cron`,expression:l.value,timezone:u.value}:{type:`watch`,script:m.value,cwd:E.value,intervalSeconds:Number(S.value),mode:w.value},a=y.value===`agent`&&k.value!==`reuse`?{...b(F.value)?{thinking:F.value}:{},...I.value.trim()&&L.value.trim()?{model:{provider:I.value.trim(),id:L.value.trim()}}:{}}:void 0,o=y.value===`bash`?{type:`bash`,cwd:O.value,script:D.value}:y.value===`agent`?{type:`agent`,prompt:P.value,session:k.value===`reuse`?{mode:`reuse`,sessionId:j.value}:{mode:`fresh`,cwd:N.value},...a?{launch:a}:{}}:{type:`task`,taskId:R.value},c=x.value===`origin`?{type:`origin`}:x.value===`session`?{type:`session`,sessionId:C.value}:{type:`none`},d={name:f.value,description:p.value,trigger:r,action:o,callback:c,timeoutSeconds:Number(_.value)};s.textContent=``,M(n?.id,d,i,s,e.onSaved)}};v.onchange=E,y.onchange=E,E();let D=m(`Cancel`);D.onclick=()=>i.close();let O=m(`Save`,!0);O.type=`submit`;let k=r(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);k.append(s,D,O),o.append(l,u,k),i.append(o),i.addEventListener(`close`,()=>i.remove()),document.body.append(i),i.showModal(),f.focus()}async function M(e,t,n,r,i){let a=await f(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!a.ok){r.textContent=(await a.json()).error??`Task save failed`;return}let o=await a.json(),s=`task`in o?o.task:o;n.close(),i(s.id)}function N(t,a,c,d,g,b,A){let M=[],N=[],P=null,F=`active`,I=`all`,L=``,R=`runs`,z={top:0},B=0,V=0,H=``,U=n(async()=>{if(P||!$.visible)return;let e=B,t=`${F}:${I}`,n=await v(`/api/tasks?state=${F}&kind=task`,`Failed to load tasks`);if(!$.visible||e!==B||t!==`${F}:${I}`)return;if(!n.ok)return H=``,K(n.error);let r=JSON.stringify(n.value);t+r!==H&&(H=t+r,M=n.value,I!==`all`&&(M=M.filter(e=>e.trigger.type===I)),X())}),W=n(async()=>{P&&$.visible&&await ae(P)});function G(){return P?W():U()}function K(e){t.querySelector(`[role=alert]`)?.remove();let n=r(`p`,`flex-none p-4 text-[13px] text-red-600`,e);n.setAttribute(`role`,`alert`),t.append(n)}async function q(){let e=P,t=await v(`/api/tasks?state=active`,`Failed to load tasks`);return!t.ok&&$.visible&&P===e&&K(t.error),t.ok?t.value:N}let J={sessions:a,tasks:()=>N,onSaved:e=>{Y(e),R=`definition`,A(e)}},ee=(e,t)=>s(...e,r(`div`,`ml-auto flex flex-wrap items-center gap-2 max-md:w-full`,...t));function Y(e){P=e,B++,R=`runs`,z.top=0}function te(){P=null,B++,X()}function ne(){!$.visible||P!==null||Promise.all([c(),q()]).then(([,e])=>{!$.visible||P!==null||(N=e,j(J))})}function X(){let e=[],n=(t,n,i,a)=>{let o=h(n,i);o.setAttribute(`aria-label`,t),o.dataset.active=String(i!==n[0]?.[1]),o.onchange=()=>{o.dataset.active=String(o.value!==n[0]?.[1]),a(o.value),V=0,G()},e.push(r(`label`,`filter-field`,r(`span`,``,t),o))},i=r(`input`,_);i.type=`search`,i.placeholder=`Search tasks`,i.setAttribute(`aria-label`,`Search tasks`),i.value=L,i.dataset.active=String(!!L),i.oninput=()=>{L=i.value,i.dataset.active=String(!!L),s()},e.push(r(`label`,`filter-field filter-search`,r(`span`,``,`Search`),i)),n(`Status`,[[`Current`,`active`],[`Archived`,`archived`]],F,e=>{F=e}),n(`Trigger`,[[`All triggers`,`all`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`]],I,e=>{I=e});let a=document.createElement(`table`);a.className=`w-full table-fixed text-left text-[12.5px]`,a.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase tracking-wide text-neutral-400 shadow-[inset_0_-1px_0_var(--color-neutral-200)]"><tr>
1
+ import{$ as e,C as t,G as n,H as r,K as i,M as a,O as o,P as s,Q as c,R as l,S as u,T as d,X as f,Y as p,b as m,k as h,l as g,m as _,q as v,rt as y,u as b,v as x}from"./index-DbFu15NN.js";import{a as S,c as C,l as w,n as T,r as E,s as D,t as O,u as k}from"./task-runs-CqpTV644.js";function A(e,t){let n=e.map(e=>[`${e.title??`Untitled`} · ${e.cwd}`,e.id]);return t&&!n.some(([,e])=>e===t)&&n.push([`Current session · ${t}`,t]),n}function j(e,n){let i=document.createElement(`dialog`);i.className=`m-auto w-[38.75rem] max-w-[94vw] rounded-lg border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20`;let o=document.createElement(`form`);o.className=`flex max-h-[88vh] flex-col`;let s=r(`span`,`mr-auto text-[12px] text-red-600`),l=r(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,n?`Edit task`:`New task`),u=r(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),f=d(n?.name??``);f.required=!0;let p=d(n?.description??``),_=d(String(n?.timeoutSeconds??3600),`number`);_.min=`1`,_.max=`86400`;let v=h([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],n?.trigger.type??`manual`),y=h([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],n?.action.type??`bash`),x=h([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],n?.callback.type??`none`),S=n?.callback.type===`session`?n.callback.sessionId:null,C=h(A(e.sessions(),S),S??``),w=t(`Callback session`,C);w.classList.toggle(`hidden`,x.value!==`session`),x.onchange=()=>w.classList.toggle(`hidden`,x.value!==`session`),u.append(t(`Name`,f),t(`Description`,p),t(`Trigger`,v),t(`Action`,y),t(`Callback`,x),w,t(`Timeout (seconds)`,_));let T=r(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);u.append(T);let E=()=>{T.replaceChildren();let l,u,m,S,w,E;if(v.value===`cron`)l=d(n?.trigger.type===`cron`?n.trigger.expression:`0 9 * * *`),u=d(n?.trigger.type===`cron`?n.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),T.append(t(`Cron`,l),t(`Timezone`,u));else if(v.value===`watch`){m=a(n?.trigger.type===`watch`?n.trigger.script:``,4),E=d(n?.trigger.type===`watch`?n.trigger.cwd:e.sessions()[0]?.cwd??``),S=d(String(n?.trigger.type===`watch`?n.trigger.intervalSeconds:60),`number`),w=h([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],n?.trigger.type===`watch`?n.trigger.mode:`repeat`);let r=t(`Probe script (0=match, 1=no match)`,m);r.classList.add(`col-span-2`),T.append(r,t(`Probe directory`,E),t(`Interval (seconds)`,S),t(`Mode`,w))}let D,O,k,j,N,P,F,I,L,R;if(y.value===`bash`){O=d(n?.action.type===`bash`?n.action.cwd:e.sessions()[0]?.cwd??``),D=a(n?.action.type===`bash`?n.action.script:``,6);let i=t(`Bash script`,D);i.classList.add(`col-span-2`),T.append(t(`Working directory`,O),r(`span`,``),i)}else if(y.value===`agent`){let r=e.sessions(),i=n?.action.type===`agent`?n.action:null,o=i?.session.mode===`reuse`?i.session.sessionId:``,s=A(r,o||null);k=h([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`]],i?.session.mode===`reuse`?`reuse`:`fresh`),j=h(s,o||s[0]?.[1]||``);let l=i&&`cwd`in i.session?i.session.cwd??``:``;N=d(l||r[0]?.cwd||``),P=a(i?.prompt??``,6),F=h([[`Project default`,``],...g.map(e=>[c(e),e])],i?.launch?.thinking??``),I=d(i?.launch?.model?.provider??``),L=d(i?.launch?.model?.id??``);let u=t(`Session`,j),f=t(`Child directory`,N),p=[t(`Thinking`,F),t(`Model provider (optional)`,I),t(`Model id (optional)`,L)],m=()=>{let e=k?.value===`reuse`;u.classList.toggle(`hidden`,!e),f.classList.toggle(`hidden`,e);for(let t of p)t.classList.toggle(`hidden`,e)};k.onchange=m,m();let _=t(`Prompt`,P);_.classList.add(`col-span-2`),T.append(t(`Session policy`,k),u,f,...p,_)}else R=h(e.tasks().filter(e=>e.id!==n?.id&&!e.archived).map(e=>[e.name,e.id]),n?.action.type===`task`?n.action.taskId:``),T.append(t(`Target task`,R));o.onsubmit=t=>{t.preventDefault();let r=v.value===`manual`?{type:`manual`}:v.value===`cron`?{type:`cron`,expression:l.value,timezone:u.value}:{type:`watch`,script:m.value,cwd:E.value,intervalSeconds:Number(S.value),mode:w.value},a=y.value===`agent`&&k.value!==`reuse`?{...b(F.value)?{thinking:F.value}:{},...I.value.trim()&&L.value.trim()?{model:{provider:I.value.trim(),id:L.value.trim()}}:{}}:void 0,o=y.value===`bash`?{type:`bash`,cwd:O.value,script:D.value}:y.value===`agent`?{type:`agent`,prompt:P.value,session:k.value===`reuse`?{mode:`reuse`,sessionId:j.value}:{mode:`fresh`,cwd:N.value},...a?{launch:a}:{}}:{type:`task`,taskId:R.value},c=x.value===`origin`?{type:`origin`}:x.value===`session`?{type:`session`,sessionId:C.value}:{type:`none`},d={name:f.value,description:p.value,trigger:r,action:o,callback:c,timeoutSeconds:Number(_.value)};s.textContent=``,M(n?.id,d,i,s,e.onSaved)}};v.onchange=E,y.onchange=E,E();let D=m(`Cancel`);D.onclick=()=>i.close();let O=m(`Save`,!0);O.type=`submit`;let k=r(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);k.append(s,D,O),o.append(l,u,k),i.append(o),i.addEventListener(`close`,()=>i.remove()),document.body.append(i),i.showModal(),f.focus()}async function M(e,t,n,r,i){let a=await f(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!a.ok){r.textContent=(await a.json()).error??`Task save failed`;return}let o=await a.json(),s=`task`in o?o.task:o;n.close(),i(s.id)}function N(t,a,c,d,g,b,A){let M=[],N=[],P=null,F=`active`,I=`all`,L=``,R=`runs`,z={top:0},B=0,V=0,H=``,U=n(async()=>{if(P||!$.visible)return;let e=B,t=`${F}:${I}`,n=await v(`/api/tasks?state=${F}&kind=task`,`Failed to load tasks`);if(!$.visible||e!==B||t!==`${F}:${I}`)return;if(!n.ok)return H=``,K(n.error);let r=JSON.stringify(n.value);t+r!==H&&(H=t+r,M=n.value,I!==`all`&&(M=M.filter(e=>e.trigger.type===I)),X())}),W=n(async()=>{P&&$.visible&&await ae(P)});function G(){return P?W():U()}function K(e){t.querySelector(`[role=alert]`)?.remove();let n=r(`p`,`flex-none p-4 text-[13px] text-red-600`,e);n.setAttribute(`role`,`alert`),t.append(n)}async function q(){let e=P,t=await v(`/api/tasks?state=active`,`Failed to load tasks`);return!t.ok&&$.visible&&P===e&&K(t.error),t.ok?t.value:N}let J={sessions:a,tasks:()=>N,onSaved:e=>{Y(e),R=`definition`,A(e)}},ee=(e,t)=>s(...e,r(`div`,`ml-auto flex flex-wrap items-center gap-2 max-md:w-full`,...t));function Y(e){P=e,B++,R=`runs`,z.top=0}function te(){P=null,B++,X()}function ne(){!$.visible||P!==null||Promise.all([c(),q()]).then(([,e])=>{!$.visible||P!==null||(N=e,j(J))})}function X(){let e=[],n=(t,n,i,a)=>{let o=h(n,i);o.setAttribute(`aria-label`,t),o.dataset.active=String(i!==n[0]?.[1]),o.onchange=()=>{o.dataset.active=String(o.value!==n[0]?.[1]),a(o.value),V=0,G()},e.push(r(`label`,`filter-field`,r(`span`,``,t),o))},i=r(`input`,_);i.type=`search`,i.placeholder=`Search tasks`,i.setAttribute(`aria-label`,`Search tasks`),i.value=L,i.dataset.active=String(!!L),i.oninput=()=>{L=i.value,i.dataset.active=String(!!L),s()},e.push(r(`label`,`filter-field filter-search`,r(`span`,``,`Search`),i)),n(`Status`,[[`Current`,`active`],[`Archived`,`archived`]],F,e=>{F=e}),n(`Trigger`,[[`All triggers`,`all`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`]],I,e=>{I=e});let a=document.createElement(`table`);a.className=`w-full table-fixed text-left text-[12.5px]`,a.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase tracking-wide text-neutral-400 shadow-[inset_0_-1px_0_var(--color-neutral-200)]"><tr>
2
2
  <th class="w-[42%] px-4 py-2 font-semibold md:w-[24%]">Name</th><th class="hidden w-[10%] px-2 py-2 font-semibold md:table-cell">Action</th>
3
3
  <th class="hidden w-[23%] px-2 py-2 font-semibold md:table-cell">Trigger</th><th class="hidden w-[17%] px-2 py-2 font-semibold md:table-cell">Next</th>
4
4
  <th class="px-2 py-2 font-semibold md:w-[14%]">Last result</th><th class="w-[6rem] px-2 py-2 font-semibold"></th></tr></thead>`;let o=document.createElement(`tbody`),s=()=>{let e=M.filter(e=>`${e.name} ${e.description??``}`.toLowerCase().includes(L.toLowerCase()));o.replaceChildren(...e.map(re)),c.classList.toggle(`hidden`,e.length>0)};a.append(o);let c=r(`div`,`p-4`,u(`No matching tasks.`)),l=r(`div`,`automation-list min-h-0 flex-1 overflow-auto`,a,c);s(),l.onscroll=()=>{V=l.scrollTop},t.replaceChildren(r(`div`,`automation-filters task-filters`,...e),l),l.scrollTop=V}function re(e){let t=document.createElement(`tr`);t.className=`cursor-pointer border-b border-neutral-100 transition-colors hover:bg-neutral-50`,t.onclick=()=>A(e.id);let n=m(e.name);n.className=`min-w-0 cursor-pointer truncate text-left font-medium text-neutral-800`,n.title=e.name,t.append(r(`td`,`py-2.5 pl-4 pr-2`,r(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,n,w(e),...ie(e)),r(`div`,`truncate text-[11px] text-neutral-400`,e.description||``),r(`div`,`truncate text-[11px] text-neutral-400 md:hidden`,k(e))));for(let n of[O(e),k(e),T(e.nextRunAt)]){let e=r(`td`,`hidden truncate px-2 py-2.5 text-neutral-600 md:table-cell`,n);e.title=n,t.append(e)}t.append(r(`td`,`px-2 py-2.5`,e.lastRun?r(`div`,`flex`,D(e.lastRun)):r(`div`,`text-neutral-400`,`–`),r(`div`,`mt-0.5 font-mono text-[11px] text-neutral-400`,e.lastRun?C(e.lastRun):``)));let i=m(`Run now`);return i.disabled=e.archived,i.onclick=t=>{t.stopPropagation(),Z(e.id)},t.append(r(`td`,`px-2 py-1 text-right`,i)),t}function ie(e){if(!e.createdBySessionId)return[];let t=x(`agent`,`bg-violet-50 text-violet-700 ring-violet-200`);return t.title=`Created by session ${e.createdBySessionId}`,[t]}async function ae(n){let i=++B,a=t.querySelector(`[data-task-detail]`),[l,u]=await Promise.all([v(`/api/tasks/${n}`,`Failed to load task`),v(`/api/tasks/${n}/runs`,`Failed to load the task's runs`)]);if(!$.visible||i!==B||P!==n)return;if(!l.ok)return K(l.error);if(!u.ok)return K(u.error);let f=l.value,p=u.value,h=m(`Tasks`);h.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,h.onclick=()=>A();let g=r(`span`,`flex min-w-0 items-center gap-2`,h,e(y,`h-3.5 w-3.5 text-neutral-400`),r(`span`,`truncate font-medium`,f.name),w(f)),_=m(`Run now`,!0);_.disabled=f.archived,_.onclick=()=>void Z(f.id);let x=m(f.enabled?`Pause schedule`:`Resume schedule`);x.disabled=f.archived||f.action.type===`system`||f.trigger.type===`manual`,x.onclick=()=>void Q(`/api/tasks/${f.id}/${f.enabled?`pause`:`resume`}`);let C=m(`Edit`);C.disabled=f.archived||f.action.type===`system`,C.onclick=()=>{!$.visible||P!==f.id||Promise.all([c(),q()]).then(([,e])=>{!$.visible||P!==f.id||(N=e,j(J,f))})};let T=m(`Archive`);T.disabled=f.archived||f.action.type===`system`,T.onclick=()=>void Q(`/api/tasks/${f.id}/archive`);let D=s(),O=r(`div`,`automation-list min-h-0 flex-1 overflow-auto`);O.dataset.taskDetail=n;let k=m(`All runs`);k.onclick=()=>b({taskId:f.id});let M=()=>{D.replaceChildren(o([[`Recent runs (${p.length})`,`runs`],[`Definition`,`definition`]],R,e=>{R=e,M()}),r(`span`,`ml-auto`,k)),R===`runs`?S(O,p,e=>b({},e),z):(O.onscroll=null,O.replaceChildren(E(f,d)))},F=a?.scrollTop??0;t.replaceChildren(ee([g],[_,...f.trigger.type===`manual`?[]:[x],C,T]),D,O),M(),O.scrollTop=F}async function Z(e){try{let t=await f(`/api/tasks/${e}/run`,{sourceSessionId:g()});if(!t.ok)return K(await i(t,`Failed to run task`));b({},(await t.json()).runId)}catch(e){K(`Failed to run task: ${String(e)}`)}}async function Q(e){let t=await p(e,`POST`,`Task update failed`);if(t)return K(t);await G()}let $=l(t,e=>{e&&e!==P&&Y(e),e||te(),t.childElementCount||X(),G()});return Object.assign($,{create:ne,refresh(e){$.visible&&(!P||!e||P===e)&&G()}})}export{N as createTasksView};
@@ -37,7 +37,7 @@
37
37
  which style.css pays for with the safe-area inset. -->
38
38
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
39
39
  <title>Pier</title>
40
- <script type="module" crossorigin src="/assets/index-DzXDXra_.js"></script>
40
+ <script type="module" crossorigin src="/assets/index-DbFu15NN.js"></script>
41
41
  <link rel="stylesheet" crossorigin href="/assets/index-eqQLVS8Q.css">
42
42
  </head>
43
43
  <!-- The document never scrolls: this is a fixed-viewport workbench, and every
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timqi/pier",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A self-hosted workspace for coding agents: web workbench and IM channels in front of Pi sessions",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": "github:timqi/pier",