@timqi/pier 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/public/assets/{activity-BJ7YoxQo.js → activity-B44nbhXy.js} +1 -1
- package/dist/web/public/assets/activity-B44nbhXy.js.br +0 -0
- package/dist/web/public/assets/activity-B44nbhXy.js.gz +0 -0
- package/dist/web/public/assets/{boards-7GDMK7s8.js → boards-CeiKKBaY.js} +1 -1
- package/dist/web/public/assets/boards-CeiKKBaY.js.br +0 -0
- package/dist/web/public/assets/boards-CeiKKBaY.js.gz +0 -0
- package/dist/web/public/assets/{code-8o-S-MIZ.js → code-I0lxXuvE.js} +1 -1
- package/dist/web/public/assets/{explorer-DBusW0TA.js → explorer-BOeDogsY.js} +1 -1
- package/dist/web/public/assets/explorer-BOeDogsY.js.br +0 -0
- package/dist/web/public/assets/explorer-BOeDogsY.js.gz +0 -0
- package/dist/web/public/assets/{index-CquEUmXo.js → index-BmKvoulH.js} +2 -2
- package/dist/web/public/assets/index-BmKvoulH.js.br +0 -0
- package/dist/web/public/assets/index-BmKvoulH.js.gz +0 -0
- package/dist/web/public/assets/{runs-BjcdVVmW.js → runs-C4OlQT7W.js} +1 -1
- package/dist/web/public/assets/runs-C4OlQT7W.js.br +0 -0
- package/dist/web/public/assets/runs-C4OlQT7W.js.gz +0 -0
- package/dist/web/public/assets/{settings-DH3Nlk9f.js → settings-Cn8i_QiP.js} +1 -1
- package/dist/web/public/assets/settings-Cn8i_QiP.js.br +0 -0
- package/dist/web/public/assets/settings-Cn8i_QiP.js.gz +0 -0
- package/dist/web/public/assets/{task-runs-DsOxAyRj.js → task-runs-BW06ZEVz.js} +1 -1
- package/dist/web/public/assets/task-runs-BW06ZEVz.js.br +0 -0
- package/dist/web/public/assets/task-runs-BW06ZEVz.js.gz +0 -0
- package/dist/web/public/assets/{tasks-CYfdrdF2.js → tasks-DZzYlKsd.js} +1 -1
- package/dist/web/public/assets/tasks-DZzYlKsd.js.br +0 -0
- package/dist/web/public/assets/tasks-DZzYlKsd.js.gz +0 -0
- package/dist/web/public/index.html +1 -1
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/package.json +1 -1
- package/dist/web/public/assets/activity-BJ7YoxQo.js.br +0 -0
- package/dist/web/public/assets/activity-BJ7YoxQo.js.gz +0 -0
- package/dist/web/public/assets/boards-7GDMK7s8.js.br +0 -0
- package/dist/web/public/assets/boards-7GDMK7s8.js.gz +0 -0
- package/dist/web/public/assets/explorer-DBusW0TA.js.br +0 -0
- package/dist/web/public/assets/explorer-DBusW0TA.js.gz +0 -0
- package/dist/web/public/assets/index-CquEUmXo.js.br +0 -0
- package/dist/web/public/assets/index-CquEUmXo.js.gz +0 -0
- package/dist/web/public/assets/runs-BjcdVVmW.js.br +0 -0
- package/dist/web/public/assets/runs-BjcdVVmW.js.gz +0 -0
- package/dist/web/public/assets/settings-DH3Nlk9f.js.br +0 -0
- package/dist/web/public/assets/settings-DH3Nlk9f.js.gz +0 -0
- package/dist/web/public/assets/task-runs-DsOxAyRj.js.br +0 -0
- package/dist/web/public/assets/task-runs-DsOxAyRj.js.gz +0 -0
- package/dist/web/public/assets/tasks-CYfdrdF2.js.br +0 -0
- package/dist/web/public/assets/tasks-CYfdrdF2.js.gz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,C as t,H as n,I as r,K as i,L as a,N as o,k as s,m as c,v as l,z as u}from"./index-
|
|
1
|
+
import{B as e,C as t,H as n,I as r,K as i,L as a,N as o,k as s,m as c,v as l,z as u}from"./index-BmKvoulH.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?`-`:r(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(r,p,h){let g=`sessions`,_=`active`,v={sessions:[],runs:[],messages:[]},y=``,b=e(async()=>{let e=_,t=await n(`/api/activity?scope=${e}`,`Failed to load activity`);if(!t.ok){y=``,r.replaceChildren(a(`p`,`p-4 text-[13px] text-red-600`,t.error));return}if(e!==_)return;let o=JSON.stringify(t.value);if(`${e}:${o}`===y)return;y=`${e}:${o}`;let s=t.value;v={...s,sessions:s.sessions.map(e=>({...e,title:i(e.title)}))},x()});function x(){let e=s(t([[`Sessions`,`sessions`],[`Relationships`,`dependencies`]],g,e=>{g=e,x()}),a(`span`,`ml-auto text-[11.5px] text-neutral-400`,`${v.sessions.length} sessions · ${v.runs.length} runs`),t([[`Current`,`active`],[`Last 24h`,`recent`]],_,e=>{_=e,x(),b()})),n=a(`div`,`min-h-0 flex-1 overflow-auto`);g===`sessions`?S(n):w(n),r.replaceChildren(e,n)}function S(e){let t=document.createElement(`table`);t.className=`w-full table-fixed text-left text-[12.5px]`,t.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>
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as e,H as t,L as n,N as r,O as i,P as a,R as o,V as s,W as c,h as l}from"./index-
|
|
1
|
+
import{G as e,H as t,L as n,N as r,O as i,P as a,R as o,V as s,W as c,h as l}from"./index-BmKvoulH.js";var u=e=>e.public&&e.token?`/p/${e.slug}-${e.token}/`:`/boards/${e.slug}/`;function d(d,f){let p=[],m=``,h=n(`header`,`sticky top-0 z-30 flex h-10 items-center gap-3 border-b border-neutral-200 bg-white px-4`,n(`span`,`font-medium max-md:hidden`,`Boards`)),g=n(`div`,`px-4 py-5`);d.append(n(`div`,`min-h-0 flex-1 overflow-y-auto`,h,g));async function _(t,n){let r=await e(`/api/boards/${t.slug}`,{public:n},`PATCH`);if(r.ok)return t.token=(await r.json().catch(()=>({}))).token??``,x();m=await s(r,`Could not change ${t.slug}`),await S()}async function v(e){m=await c(`/api/boards/${e}`,`DELETE`,`Could not delete ${e}`)??``,await S()}function y(e){let t=n(`div`,`group flex flex-col gap-1 border-b border-neutral-200/70 px-1 py-2.5 last:border-b-0`),r=document.createElement(`a`);r.className=`truncate font-medium text-neutral-800 hover:text-indigo-700`,r.href=u(e),r.target=`_blank`,r.rel=`noreferrer`,r.textContent=e.title;let s=n(`div`,`flex items-center gap-2`,r,n(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,e.slug)),c=i(``,``,e.public,t=>{e.public=t,_(e,t)});c.className=`ml-auto flex flex-none cursor-pointer items-center gap-1.5 text-[11.5px] text-neutral-500`,c.append(n(`span`,``,`Public`));let d=l(`Delete`,`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100`);d.title=`Renames the folder on disk; nothing is erased`,d.onclick=()=>void v(e.slug);let p=a(`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-indigo-600 group-hover:opacity-100`,()=>`${location.origin}${u(e)}`);p.title=`Copy the board's link`,s.append(c,p,d),t.append(s);let m=n(`div`,`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-neutral-500`);e.description&&m.append(n(`span`,`min-w-0 truncate`,e.description)),m.append(n(`span`,`flex-none text-neutral-400`,o(Date.parse(e.updatedAt))));for(let t of e.sessions){let e=l(t.slice(0,8),`flex-none cursor-pointer font-mono text-indigo-600 hover:underline`);e.title=`Open session ${t}`,e.onclick=()=>f(t),m.append(e)}if(e.public&&e.token){let t=n(`span`,`flex-none font-mono text-neutral-400`,u(e));t.title=`Public URL — anyone holding this link can read the board, no password`,m.append(t)}return t.append(m),t}let b=[{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 x(){let e=n(`div`,`mx-auto flex max-w-3xl flex-col`);p.length===0&&e.append(n(`p`,`rounded-xl border border-dashed border-neutral-300 px-4 py-6 text-center text-[12.5px] text-neutral-500`,`No boards yet. Ask an agent to build one — it writes a folder under ~/.pier/boards.`));for(let{title:t,hint:r,wanted:i}of b){let a=p.filter(e=>e.public===i);if(a.length===0)continue;let o=n(`section`,`mb-6`);o.append(n(`h2`,`text-[13px] font-semibold text-neutral-700`,t)),o.append(n(`p`,`mb-1 text-[11.5px] leading-snug text-neutral-500`,r));let s=n(`div`,`rounded-xl border border-neutral-200 bg-white px-3`);s.append(...a.map(y)),o.append(s),e.append(o)}g.replaceChildren(...m?[n(`p`,`mb-3 text-[13px] text-red-600`,m)]:[],e)}async function S(){let e=await t(`/api/boards`,`Could not load boards`);if(!e.ok)return m=e.error,x();p=e.value,x(),m=``}let C=r(d,()=>void S());return window.addEventListener(`focus`,()=>{C.visible&&S()}),C}export{d as createBoardsView};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e,d as t}from"./index-
|
|
1
|
+
import{L as e,d as t}from"./index-BmKvoulH.js";var n=2e4,r=e=>e.map((e,t)=>({nums:[t+1],text:e,tone:``}));function i(t,r){let i=t.length<=n?r:null,o=Math.max(2,...t.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),s=e(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let n of t){let t=e(`div`,`flex pl-2 pr-4 ${n.tone===`add`?`bg-emerald-50`:n.tone===`del`?`bg-red-50`:``}`);for(let r of n.nums){let n=e(`span`,`flex-none select-none pr-1.5 text-right text-neutral-300`,r===``?``:String(r));n.style.width=`calc(${o}ch + 0.375rem)`,t.append(n)}t.append(a(n,i)),s.append(t)}return s}function a(n,r){let i=`min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]`;if(!n.mark||n.mark[0]>=n.mark[1]){let e=t(n.text,r);return e.className=i,e}let[a,o]=n.mark,s=t(n.text.slice(a,o),r);return s.className=`rounded-xs ${n.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,e(`span`,i,t(n.text.slice(0,a),r),s,t(n.text.slice(o),r))}export{r as n,i as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as e,L as t,M as n,N as r,R as i,U as a,a as o,i as s,n as c,s as l,u}from"./index-
|
|
1
|
+
import{F as e,L as t,M as n,N as r,R as i,U as a,a as o,i as s,n as c,s as l,u}from"./index-BmKvoulH.js";import{n as d,t as f}from"./code-I0lxXuvE.js";var p=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())}`},m=e=>[e.subject,e.body,[[e.author,e.email?`<${e.email}>`:``].filter(Boolean).join(` `),e.at?p(e.at):``].filter(Boolean).join(` · `)].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`),h=null;function g(){h&&(h.remove(),h=null,document.removeEventListener(`pointerdown`,g,!0),window.removeEventListener(`scroll`,g,!0))}function _(e,n){e.onmouseenter=()=>{g();let r=n();if(!r)return;h=t(`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`),h.textContent=r,document.body.append(h),document.addEventListener(`pointerdown`,g,!0),window.addEventListener(`scroll`,g,!0);let i=e.getBoundingClientRect();h.style.left=`${Math.max(8,Math.min(i.left,window.innerWidth-h.offsetWidth-8))}px`,h.style.top=i.bottom+6+h.offsetHeight>window.innerHeight?`${i.top-h.offsetHeight-6}px`:`${i.bottom+6}px`},e.onmouseleave=g}function v(e,n,r){let a=t(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-1 text-left hover:bg-neutral-100`,t(`span`,`w-3 flex-none text-indigo-600`,e.value===n?`✓`:``),t(`span`,`flex-none font-mono text-[11.5px] text-neutral-800`,e.label??e.value));return e.subject&&a.append(t(`span`,`min-w-0 truncate text-[11px] text-neutral-400`,e.subject)),e.author&&a.append(t(`span`,`ml-auto flex-none pl-1.5 text-[10.5px] text-neutral-400`,`${e.author} · ${e.at?i(e.at):``}`)),_(a,()=>m(e)),a.onclick=()=>r(e.value),a}function ee(e,n,r,i,a){let{base:c,head:l}=r,u=()=>l&&c===`${l}~1`?l:``,d=u()?`commit`:`compare`,f=n.commits[0],p=e=>[...e?[{value:``,label:`Working tree`,subject:`the files on disk, uncommitted changes included`}]:[],{...f,value:`HEAD`},...n.refs.map(e=>({value:e.name,subject:e.subject})),...n.commits.map(e=>({...e,value:e.hash}))],m=t(`div`,`flex w-[38rem] max-w-full flex-col`);function h(){let e=(e,n)=>{let r=t(`button`,`cursor-pointer rounded-full px-2.5 py-0.5 text-[11.5px] ${d===n?`bg-indigo-50 font-medium text-indigo-700`:`text-neutral-500 hover:bg-neutral-100`}`,e);return r.onclick=()=>{d=n,h()},r},r=(e,n,r,i)=>t(`div`,`flex min-w-0 flex-1 flex-col`,t(`div`,`flex-none px-2 pb-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),t(`div`,`min-h-0 flex-1 overflow-y-auto`,...n.map(e=>v(e,r,i)))),o=d===`compare`?t(`div`,`flex h-72 min-h-0 divide-x divide-neutral-200 pb-1`,r(`base`,p(!1),c,e=>{c=e,h(),i(c,l)}),r(`to`,p(!0),l,e=>{l=e,h(),i(c,l)})):t(`div`,`flex h-72 min-h-0 flex-col overflow-y-auto pb-1`,...n.commits.map(e=>v({value:e.hash,...e},u(),e=>{c=`${e}~1`,l=e,s(),i(c,l)}))),f=t(`div`,`flex-none border-t border-neutral-200`,v({value:a,label:`↺ ${a} ↔ Working tree`,subject:`back to the default: the main line's tip vs the files on disk`},c===a&&l===``?a:``,()=>{c=a,l=``,h(),i(c,l)}));m.replaceChildren(t(`div`,`flex flex-none items-center gap-1 border-b border-neutral-200 px-2 py-1.5`,e(`Compare two points`,`compare`),e(`One commit`,`commit`)),o,...d===`compare`?[f]:[])}h(),o(e,m)}var te=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,ne={A:`text-emerald-600`,M:`text-amber-600`,D:`text-red-600`},re=30,y=`pier.filesPrefs`,b=50,x=()=>{try{let e=JSON.parse(localStorage.getItem(y)??`{}`);return e&&typeof e==`object`?e:{}}catch{return{}}},S=e=>{let t=e?x()[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},ie=(e,t)=>{let n=x();delete n[e],n[e]=t;let r=Object.keys(n);for(let e of r.slice(0,Math.max(0,r.length-b)))delete n[e];try{localStorage.setItem(y,JSON.stringify(n))}catch(e){console.warn(`Files: could not remember this folder`,e)}},C=(e,n=`indigo`)=>{let r=t(`button`,`min-w-0 cursor-pointer truncate rounded-md px-2 py-0.5 text-left font-mono text-[11.5px] ${n===`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 w(i,o,s,p){let h=``,g=``,v={branch:null,refs:[],commits:[],worktrees:[]},y=`HEAD`,b=``,x=new Map,w=!0,T=!1,ae=[],E=new Set,D=null,O=null,k=t(`header`,`flex h-10 flex-none items-center gap-2 border-b border-neutral-200 bg-white px-3`),A=t(`div`,`flex-none border-b border-neutral-200`),j=t(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),oe=t(`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`,A,j),M=t(`div`,`h-full min-w-0 overflow-auto`),N=t(`div`,`pointer-events-none absolute inset-y-0 right-0 z-20 hidden w-2`),se=t(`section`,`relative min-h-0 min-w-0 flex-1`,M,N);i.append(k,t(`div`,`flex min-h-0 flex-1 max-md:flex-col`,oe,se));let P=(e,t)=>`/api/explorer/${e}?${new URLSearchParams({root:h,...t})}`,F=(e,t)=>`/api/fs/${e}?${new URLSearchParams({root:h,...t})}`,I=(e,n=`text-neutral-400`)=>t(`p`,`px-4 py-3 text-[12.5px] ${n}`,e),L=e=>{let t=0;for(let n of x.keys())n.startsWith(`${e}/`)&&t++;return t};function R(e,t){let n=new Set(t.map(e=>e.name)),r=e?`${e}/`:``;for(let[e,i]of x){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&&v.branch&&(i=t.filter(e=>e.dir?L(`${r}${e.name}`)>0:x.has(`${r}${e.name}`))),i.sort((e,t)=>Number(t.dir)-Number(e.dir)||e.name.localeCompare(t.name)),i.map(e=>e.dir?ce(`${r}${e.name}`,e.name):le(`${r}${e.name}`,e.name))}async function z(e,t){try{let{entries:n}=await a(F(`ls`,{path:t}),`could not list this folder`);e.replaceChildren(...R(t,n)),e.childElementCount||e.append(I(w?`No changes.`:`Empty.`))}catch(n){let r=R(t,[]);r.length?e.replaceChildren(...r):e.replaceChildren(I(String(n),`text-red-600`))}}function ce(n,r){let i=L(n),a=[t(`span`,`truncate`,r)];i&&a.push(t(`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}=e(``,a);s.className+=` px-2 py-0.5 hover:bg-neutral-100`;let c=t(`div`,`pl-3`);o.append(c);let l=!1,u=()=>{l||(l=!0,c.append(I(`…`)),z(c,n))};return o.ontoggle=()=>{E[o.open?`add`:`delete`](n),o.open&&u()},(w&&v.branch&&!T||E.has(n))&&(o.open=!0,u()),o}function B(e){O?.classList.remove(`bg-indigo-50`,`text-indigo-700`),O=e,e.classList.add(`bg-indigo-50`,`text-indigo-700`)}function le(e,n){let r=x.get(e)?.status,i=t(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-0.5 pl-6 text-left hover:bg-neutral-100`,t(`span`,`truncate`,n));return r&&i.append(t(`span`,`ml-auto flex-none font-mono text-[10.5px] font-semibold ${ne[r]??`text-neutral-500`}`,r)),i.title=e,e===D&&B(i),i.onclick=()=>{B(i),D=e,de(e)},i}let V=()=>void z(j,``),H=(e,n)=>[...e?[t(`span`,`flex-none font-mono text-[10.5px] font-semibold text-emerald-600`,`+${e}`)]:[],...n?[t(`span`,`flex-none font-mono text-[10.5px] font-semibold text-red-600`,`−${n}`)]:[]];function U(e,r,i){let a=x.get(e),o=t(`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`,t(`span`,`truncate`,e));a&&(o.append(t(`span`,`flex-none font-semibold ${ne[a.status]??``}`,a.status)),o.append(...H(a.add,a.del)));let s=t(`div`,`ml-auto flex flex-none items-center gap-2`);if(i&&s.append(i),r){let t=document.createElement(`a`);t.className=`flex-none text-neutral-400 hover:text-indigo-700 hover:underline`,t.href=F(`file`,{path:e}),t.download=n(e),t.textContent=`Download`,s.append(t)}return o.append(s),o}function ue(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 W=_e();function G(){N.classList.add(`hidden`),N.replaceChildren(),W.set([],[])}let K=0,q=e=>e===K;function de(e){let t=++K;return x.has(e)?ve(e,t):J(e,t)}async function J(e,n){if(!q(n))return;G();let r=F(`file`,{path:e}),i=t(`div`,`min-w-0`);if(M.classList.remove(`flex`,`flex-col`),M.replaceChildren(U(e,!0),i),te.test(e)){let e=t(`img`,`max-w-full p-4`);e.src=r,e.onerror=()=>i.replaceChildren(I(`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,M.replaceChildren(U(e,!0),t),M.classList.add(`flex`,`flex-col`);return}i.append(I(`…`));let a=await fetch(r);if(!q(n))return;if(!a.ok){let{error:e}=await a.json().catch(()=>({}));i.replaceChildren(I(e??`HTTP ${a.status}`,`text-red-600`));return}if(!(a.headers.get(`content-type`)??``).startsWith(`text/plain`)){i.replaceChildren(I(`Binary file — use Download.`));return}let o=(await a.text()).split(`
|
|
4
4
|
`);if(!q(n))return;o.at(-1)===``&&o.pop();let s=await u(e);q(n)&&i.replaceChildren(f(d(o),s))}function fe(e){let t=[],n=0,r=0,i=!1,a=e.split(`
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-DZzYlKsd.js","assets/task-runs-BW06ZEVz.js","assets/runs-C4OlQT7W.js","assets/explorer-BOeDogsY.js","assets/code-I0lxXuvE.js","assets/settings-Cn8i_QiP.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=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function t(t){let n=[],r=e=>`\uE010${n.push(e)-1}\uE011`,i=t.replace(/```[\s\S]*?```/g,e=>r(e)).replace(/`[^`\n]+`/g,e=>r(e));return i=i.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(t,n)=>{let r=``,i=``,a=n;for(;a.length>1&&e.test(a[0]);)r+=a[0],a=a.slice(1);for(;a.length>1&&e.test(a.at(-1));)i=a.at(-1)+i,a=a.slice(0,-1);return r||i?`${r}**${a}**${i}`:t}),i.replace(/\uE010(\d+)\uE011/g,(e,t)=>n[Number(t)]??``)}var n=e=>!e.text.trim()&&e.suggestions.length===0,r=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),i=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},a=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,o=/\[([^\]\r\n]+)\]/g,s=5,c=/<silent>([\s\S]*?)<\/silent>/gi;function l(e){let t=[...e.matchAll(c)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function u(e,t){let n=d(e),r=l(e),i=a.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let c=[...i[1].matchAll(o)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,s);return c.length?{text:n.slice(0,i.index).trimEnd(),suggestions:c,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var d=e=>t(e.replace(c,``).trim()),ee=/^(?:\s|[-*+>]|\d+[.)])/;function f(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&&!(ee.test(s)&&ee.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 p=/^\[(?:([^\n[\]<>]*)<([^\n[\]<>]+)>)? ?((?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})?\]\n/;function te(e){let t=p.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)}}function ne(e){if(!e)return e;let{text:t}=te(e);return t===e?e:t.replace(/\s+/g,` `).trim()||e}function re(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var m=(e,t,n=`POST`)=>fetch(e,{method:n,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function h(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function g(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 h(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function ie(e,t,n){let r=await g(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function ae(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await h(r,n)}catch(e){return`${n}: ${String(e)}`}}function oe(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 _(e){if(Array.isArray(e))return e}function se(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 ce(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
@@ -81,4 +81,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
81
81
|
`),o=U.sessionState()===`idle`&&e===`auto`;o?U.setState(`streaming`):us(),(o||e===`steer`)&&(cs(a),V(`user`,a,!1,Date.now()),ka(!0));let s=await m(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await h(s,`send failed`);await U.reload(i),V(`error`,e)}}finally{t===void 0&&(Cs=!1)}}}async function Ts(e){let t=U.sessionId();if(!t)return;ps([],[]);let n=await m(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await h(n,`Queue ${e} failed`);await U.reload(t),U.sessionId()===t&&V(`error`,r)}}async function Es(){let e=U.sessionId();if(!e||ns.has(e))return;ns.add(e);let t=ts,n=ys,r=document.activeElement;try{bs();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await h(i,`Could not recall queued messages`);U.sessionId()===e&&V(`error`,t);return}let{messages:a}=await i.json(),o=U.sessionId()===e;if(a.length)try{let t=o?W.value:localStorage.getItem(vs(e))??``,i=(t?[t,...a]:a).join(`
|
|
82
82
|
`);o&&(W.value=i,Ss(),n===ys&&U.chatVisible()&&document.activeElement===r&&W.focus()),bs(e,i)}catch(t){V(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
|
|
83
83
|
`)}`)}o&&t===ts&&ps([],[])}finally{ns.delete(e)}}function Ds(e){U=e,as();let t=()=>{let e=U.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};qo.onclick=t,zo(qo,`Stop the running turn`,t,()=>U.sessionState()===`streaming`&&U.chatVisible()),L(`#queue-steer`).onclick=()=>void Ts(`steer`),L(`#queue-restart`).onclick=()=>void Ts(`restart`),L(`#queue-recall`).onclick=()=>void Es(),Uo.onsubmit=e=>{e.preventDefault(),ws(`auto`)},Vo(W,[`/`],`Write a message`,os,U.chatVisible),W.onfocus=Oa,W.oninput=()=>{Ss(),bs()};let n=!matchMedia(`(pointer: coarse)`).matches;W.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ws(`auto`))},W.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&gs(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),W.setRangeText(n,W.selectionStart??0,W.selectionEnd??0,`end`),Ss(),bs())},B.ondragover=e=>e.preventDefault(),B.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])gs(t)},L(`#attach`).onclick=()=>$o.click(),$o.onchange=()=>{for(let e of $o.files??[])gs(e);$o.value=``},us()}var Os=`pier.push`,ks=`/sw.js`,As=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),js=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Ms(){return window.isSecureContext?As()&&!js()?`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 Ns=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],Ps=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Fs(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Ns,`Linux`)} · ${t(Ps,`browser`)}${js()?` (installed)`:``}`}var Is=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},Ls=null;async function Rs(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(Ls??=await navigator.serviceWorker.register(ks,{scope:`/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),Ls)}var zs=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function Bs(e){let{publicKey:t}=await ie(`/api/push`,`Could not read this instance's push key`),n=Is(t),r=await e.pushManager.getSubscription();if(r){if(zs(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function Vs(e){return m(`/api/push/subscribe`,{...e.toJSON(),label:Fs()})}async function Hs(){Gs();let e=await Rs();if(!(!e||localStorage.getItem(Os)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await Vs(await Bs(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var Us=null,Ws=null;function Gs(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Us=e,Ws?.()}),window.addEventListener(`appinstalled`,()=>{Us=null,Ws?.()})}function Ks(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function qs(){let e=R(`span`,`text-[11.5px]`,``),t=fr(`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(Os)===`on`;async function a(){Er(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Os,`off`),c(),Er(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 Rs();if(!n)return Er(e,`failed`,`This browser refused to register a service worker.`);try{let t=await Vs(await Bs(n));if(!t.ok)return Er(e,`failed`,await h(t,`Could not register this browser`));localStorage.setItem(Os,`on`),c(),Er(e,`saved`,`This browser will be notified when a turn finishes unseen.`)}catch(t){Er(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function o(){localStorage.setItem(Os,`off`),c();let t=await(await Rs())?.pushManager.getSubscription();t&&(await m(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),Er(e,`idle`,`This browser will not be notified.`)}t.onclick=()=>{Er(e,`saving`,`sending…`),(async()=>{let t=await m(`/api/push/test`,{});if(!t.ok)return Er(e,`failed`,await h(t,`Could not send`));let{sent:n,failed:r}=await t.json();Er(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function s(){if(!Us)return[];let e=fr(`Install Pier`,!0);return e.onclick=()=>{let e=Us;e&&e.prompt().then(()=>e.userChoice).finally(()=>{Us=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=Ms();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(),wr(`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 Ws=c,c(),_r(`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 G=null;function Js(e){G&&!G.contains(e.target)&&K()}function Ys(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),K())}function Xs(e){G&&!G.contains(e.target)&&K()}function K(){G&&=(document.removeEventListener(`pointerdown`,Js,!0),document.removeEventListener(`keydown`,Ys,!0),window.removeEventListener(`scroll`,Xs,!0),window.removeEventListener(`resize`,K),G.remove(),null)}var Zs=null;function Qs(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:Zs?.anchor===e?{top:Zs.top,left:Zs.left}:n}var $s=()=>window.innerWidth<640;function ec(e,t){K();let n=$s();if(G=R(`div`,`fixed z-50 rounded-lg border border-neutral-200 bg-white py-1 shadow-lg ${n?`inset-x-2 bottom-2 max-h-[70dvh] overflow-y-auto pb-[calc(0.25rem+env(safe-area-inset-bottom))] text-[16px]`:`min-w-52 max-w-[min(42rem,calc(100vw-1rem))] text-[13px]`}`),G.append(t),(e.closest(`dialog[open]`)??document.body).append(G),!n){let t=Qs(e);Zs={anchor:e,...t},G.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-G.offsetHeight-8))}px`,G.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-G.offsetWidth-8))}px`}document.addEventListener(`pointerdown`,Js,!0),document.addEventListener(`keydown`,Ys,!0),window.addEventListener(`scroll`,Xs,!0),window.addEventListener(`resize`,K)}function tc(e){let t=R(`button`,`flex w-full cursor-pointer items-center gap-2 px-3 text-left hover:bg-neutral-100 active:bg-neutral-100 ${$s()?`py-3`:`py-1.5`}`,R(`span`,`flex-none w-3 text-indigo-600`,e.checked?`✓`:``),R(`span`,`truncate`,e.label));return e.hint&&t.append(R(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),t.onclick=()=>e.onSelect(),t}function nc(e,t){ec(e,R(`div`,``,...t.map(tc)))}var q=e=>`${e.provider}/${e.id}`,rc=`pier.modelFavorites`,ic=e=>`${q(e)}@${e.thinking}`,ac=null;async function oc(){let{modelMenu:e}=await ie(`/api/settings`,`Could not read the pinned model menu`);return e}function sc(){try{let e=JSON.parse(localStorage.getItem(rc)??`[]`);return Array.isArray(e)?e.filter(e=>{let t=e;return!!t&&typeof t==`object`&&typeof t.provider==`string`&&typeof t.id==`string`&&typeof t.thinking==`string`}):[]}catch{return[]}}function cc(e){let t=R(`button`,`flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-3 py-1.5 text-left`,R(`span`,`w-3 flex-none text-indigo-600`,e.checked?`✓`:``),R(`span`,`truncate`,e.label));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();let n=R(`button`,`flex-none cursor-pointer px-2 py-1.5 leading-none ${e.starred?`text-amber-500`:`text-neutral-300 opacity-0 hover:text-amber-500 group-hover/row:opacity-100`}`,e.starred?`★`:`☆`);return n.title=e.starred?`Unstar`:`Star this model + reasoning`,n.onclick=t=>{t.stopPropagation(),e.onStar()},R(`div`,`group/row flex w-full items-center hover:bg-neutral-100`,t,n)}function lc({models:e,current:t,thinkingLevel:n,thinkingLevels:i,onPick:a,onThinkingPick:o}){let s=sc(),c=n,l=R(`div`,`flex w-72 flex-col`),u=R(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),d=document.createElement(`input`);if(d.type=`search`,d.placeholder=`Search models`,d.setAttribute(`aria-label`,`Search models`),d.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,u.append(d),i.length){let e=R(`label`,`flex items-center gap-2 px-1 text-[12px] text-neutral-500`),t=document.createElement(`select`);t.className=`select ml-auto rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-700 focus:border-indigo-400 focus:outline-none`,t.setAttribute(`aria-label`,`Reasoning level`);for(let e of i){let n=document.createElement(`option`);n.value=e,n.textContent=r(e),t.append(n)}t.value=n,t.onchange=()=>{c=t.value,re(d.value),o(c)},e.append(R(`span`,`font-medium`,`Reasoning`),t),u.append(e)}let ee=e=>{let t=ic(e);s=s.some(e=>ic(e)===t)?s.filter(e=>ic(e)!==t):[...s,e],localStorage.setItem(rc,JSON.stringify(s)),re(d.value)},f=(e,t)=>s.some(n=>ic(n)===`${q(e)}@${t}`),p=R(`div`,`max-h-72 overflow-y-auto py-1`),te=new Map(e.map(e=>[q(e),e])),ne=(e,n,i)=>{let o=n.map(e=>({e,model:te.get(q(e))})).filter(e=>!!e.model&&(!i||q(e.model).toLowerCase().includes(i)));o.length&&p.append(R(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),...o.map(({e,model:n})=>{let i=e.thinking??c;return cc({label:n.id,hint:e.thinking?r(e.thinking):void 0,title:e.note,checked:!!t&&q(t)===q(n)&&c===i,starred:f(n,i),onSelect:()=>a(n,e.thinking),onStar:()=>ee({provider:n.provider,id:n.id,thinking:i})})}),R(`div`,`my-1 border-t border-neutral-100`))},re=n=>{p.replaceChildren();let r=n.trim().toLowerCase();ne(`Pinned`,ac??[],r),ne(`Starred`,s,r);let i=new Map;for(let t of e){if(r&&!q(t).toLowerCase().includes(r))continue;let e=i.get(t.provider);e?e.push(t):i.set(t.provider,[t])}if(!i.size){p.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 i){let i=n.some(e=>!!t&&q(t)===q(e)),o=document.createElement(`details`);o.open=i||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`,R(`span`,`chev`,`▶`),R(`span`,`truncate`,e),R(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>cc({label:e.id,checked:!!t&&q(t)===q(e),starred:f(e,c),onSelect:()=>a(e),onStar:()=>ee({provider:e.provider,id:e.id,thinking:c})}))),p.append(o)}};return d.oninput=()=>re(d.value),re(``),oc().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(ac);ac=e,t&&re(d.value)}).catch(e=>To(`model menu unavailable`,e)),l.append(u,p),queueMicrotask(()=>d.focus()),l}function uc(e,t,n,i){let a=pr(t.model?`${t.model.id}${t.thinking?` · ${r(t.thinking)}`:``}`:t.thinking?`Pi default · ${r(t.thinking)}`:`Pi default`,`${yr} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return a.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,a.onclick=()=>{let e=lc({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Oi],onPick:(e,n)=>{K(),i({model:e,thinking:n??t.thinking})},onThinkingPick:e=>i({...t,thinking:e})}),r=pr(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);r.onclick=()=>{K(),i({model:null,thinking:null})};let o=R(`div`,`flex flex-col`);o.append(e,R(`div`,`border-t border-neutral-200`),r),ec(a,o)},vr(e,a)}var dc=async e=>{let t=await g(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},fc=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),pc=(e,t,n)=>{let r=pr(e,`flex w-full cursor-pointer items-center gap-1.5 px-3 py-1 text-left ${t}`);return r.onclick=n,r};function mc(e,t){let n=R(`div`,`flex-none border-t border-neutral-200`),r=pc(`+ New folder`,`text-[12px] text-neutral-500 hover:bg-neutral-100`,()=>{let r=document.createElement(`input`);r.className=`w-full border-0 bg-transparent px-3 py-1 font-mono text-[12.5px] focus:outline-none`,r.placeholder=`folder-name`;let i=R(`p`,`hidden px-3 pb-1 text-[11.5px] text-red-600`);r.onkeydown=async n=>{if(n.key!==`Enter`)return;n.preventDefault();let a=await m(`/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 n.append(r),n}function hc(e,t,n){let r=e=>{n(e),K()};async function i(t){let n=await dc(t);if(!n)return;let a=R(`div`,`flex max-h-80 w-80 flex-col`),o=pr(`Use`,`ml-auto flex-none cursor-pointer rounded bg-indigo-600 px-2 py-0.5 text-[11.5px] text-white dark:text-neutral-50`);o.onclick=()=>r(n.path);let s=document.createElement(`input`);s.className=`min-w-0 flex-1 border-0 bg-transparent font-mono text-[11.5px] text-neutral-500 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-[11.5px] 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 dc(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`,`flex flex-none items-center gap-2 border-b border-neutral-200 px-3 py-1.5`,s,o),u=R(`div`,`min-h-0 flex-1 overflow-y-auto py-0.5 text-[12.5px]`);n.parent&&u.append(pc(`../`,`font-mono text-neutral-500 hover:bg-neutral-100`,()=>void i(n.parent)));let d=fc(n);for(let e of d)u.append(pc(e,`truncate hover:bg-neutral-100`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(R(`p`,`px-3 py-1.5 text-[12px] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,mc(n.path,e=>void i(e))),ec(e,a)}i(t)}function gc(e,t,n,r){nc(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{K(),r(e.path)}})),{label:`Browse…`,onSelect:()=>hc(e,n||void 0,r)}])}var _c=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function vc(e,t){let n=pr(`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=()=>hc(n,e.value.trim()||void 0,_c(e,t)),n}function yc(e,t){let n=_c(e);e.classList.add(`select`),e.title=`Pick a project folder, or type a path`,e.onclick=()=>{let r=e.value.trim()||void 0,i=t();if(i.length)return gc(e,i,r,n);hc(e,r,n)},e.addEventListener(`input`,()=>K())}function bc(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,vc(r,n)),input:r}}var xc=L(`#sidebar`),Sc=L(`#drawer-scrim`),Cc=L(`#mobile-title`),wc=L(`#mobile-menu`);function Tc(){delete xc.dataset.open,Sc.classList.add(`hidden`)}function Ec(e,t){Cc.textContent=e,Cc.classList.toggle(`cursor-pointer`,t),wc.classList.toggle(`hidden`,!t)}var Dc=`pier.railClosed`;localStorage.getItem(Dc)===`1`&&(document.body.dataset.rail=`closed`);function Oc(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(Dc,e?`1`:`0`)}function kc(){if(xc.dataset.open!==void 0)return Tc();xc.dataset.open=``,Sc.classList.remove(`hidden`)}var Ac=()=>window.innerWidth<768,jc=[L(`#rail-toggle`),L(`#drawer-toggle`)],Mc=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Nc=e=>e===1?R(`span`,`${Mc} h-2 w-2`):R(`span`,`${Mc} 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 Pc(e){for(let t of jc)t.querySelector(`.attention`)?.remove(),e&&t.append(Nc(e))}var Fc=20,Ic=.35,Lc=8;function Rc(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{xc.style.transition=`none`,xc.style.transform=`translateX(${String(e-i)}px)`,Sc.classList.remove(`hidden`),Sc.style.opacity=String(e/i)},o=t=>{xc.style.transition=``,xc.style.transform=``,Sc.style.opacity=``,t?(xc.dataset.open=``,Sc.classList.remove(`hidden`)):Tc(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Ac()||a.touches.length!==1))return;let o=a.touches[0],s=xc.dataset.open!==void 0;if(i=xc.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Fc||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)<Lc)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=xc.getBoundingClientRect().right;o(n?t>i*Ic:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function zc(e){Rc(),L(`#drawer-toggle`).onclick=kc,Sc.onclick=Tc,wc.onclick=()=>e.sessionMenu(wc),Cc.onclick=()=>{wc.classList.contains(`hidden`)||e.sessionInfo(Cc)};let t=L(`#rail-toggle`);t.onclick=()=>Oc(document.body.dataset.rail!==`closed`),Ro(t,`meta+b`,`Toggle sidebar`,()=>Ac()?kc():Oc(document.body.dataset.rail!==`closed`))}var J,Bc=L(`#project-tree`),Vc=L(`#archive-dialog`),Hc=L(`#archive-list`),Uc=L(`#archive-search`),Wc=L(`#archive-count`),Gc=L(`#new-dialog`),Kc=`pier.collapsedProjects`,qc=new Set(Jc());function Jc(){try{let e=JSON.parse(localStorage.getItem(Kc)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Yc(e,t){t?qc.add(e):qc.delete(e),localStorage.setItem(Kc,JSON.stringify([...qc]))}function Xc(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return n}var Zc=e=>Xc(e,e=>e.cwd),Qc=e=>e.repo??e.cwd,$c=e=>e.endsWith(`/.git`)?e.slice(0,-5):void 0,el=(e,t)=>tr($c(e)??t[0]?.cwd??e);function tl(e,t){let n=$c(e),r=[...new Set(t.map(e=>e.cwd))];return n&&r.includes(n)?[n,...r.filter(e=>e!==n)]:r}function nl(e,t){return e===t?0:e===void 0?-1:t===void 0?1:e-t}function rl(e){let t=[...Xc(e,Qc)].map(([e,t])=>[e,[...t].sort((e,t)=>(e.branch??e.cwd).localeCompare(t.branch??t.cwd)||nl(e.sort,t.sort)||t.createdAt-e.createdAt)]),n=e=>{let t=e.map(e=>e.projectSort).filter(e=>e!==void 0);return t.length?Math.min(...t):void 0},r=e=>Math.min(...e.map(e=>e.createdAt));return t.sort(([,e],[,t])=>nl(n(e),n(t))||r(t)-r(e))}function il(e,t,n,r){let i=e.filter(e=>e!==t);return i.splice(i.indexOf(n)+ +!!r,0,t),i}var al=()=>rl(J.sessions().filter(e=>e.listed)),ol=()=>al().flatMap(([e,t])=>tl(e,t).map(e=>{let n=t.find(t=>t.cwd===e)?.branch;return{path:e,...n?{hint:n}:{}}}));function sl(e,t,n,r){let i=new Map(e.map((e,t)=>[e,t]));for(let e of J.sessions()){let r=i.get(t(e));r!==void 0&&n(e,r)}Dl();let a=()=>void J.loadSessions();m(`/api/projects/order`,r).then(e=>{e.ok||a()},a)}function cl(e,t,n,r){let i=al().find(([t])=>t===e);if(!i)return;let a=il(i[1].map(e=>e.id),t,n,r);sl(a,e=>e.id,(e,t)=>e.sort=t,{sessions:a})}function ll(e,t,n){let r=al(),i=il(r.map(([e])=>e),e,t,n);sl(i,Qc,(e,t)=>e.projectSort=t,{projects:i.flatMap(e=>{let t=r.find(([t])=>t===e);return t?tl(e,t[1]):[]})})}var ul=null;function dl(e,t){e.style.boxShadow=t===null?``:`inset 0 ${t?-2:2}px 0 0 #818cf8`}function fl(e,t,n,r){e.draggable=!0,e.ondragstart=e=>{e.stopPropagation(),ul={list:t,key:n},e.dataTransfer?.setData(`text/plain`,n)},e.ondragend=()=>{ul=null,Dl(!0)};let i=t=>{let n=e.getBoundingClientRect();return t.clientY>n.top+n.height/2},a=e=>!ul||ul.list!==t||ul.key===n?!1:(e.preventDefault(),e.stopPropagation(),!0);e.ondragover=t=>{a(t)&&dl(e,i(t))},e.ondragleave=()=>dl(e,null),e.ondrop=t=>{let n=ul?.key;dl(e,null),a(t)&&n&&r(n,i(t))}}var pl=`hidden flex-none rounded px-1 leading-none text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700 group-hover:block pointer-coarse:block`,ml=e=>e.unread&&e.listed;function hl(e){let[t,n]=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:ml(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:e.activeRuns>0?[`bg-sky-500`,`${e.activeRuns} subagent${e.activeRuns>1?`s`:``} running`]:[`bg-neutral-300`,`idle`],r=R(`span`,`h-2 w-2 flex-none rounded-full ${t}`);return r.title=n,r}async function gl(e,t,n,r,i){let a=t=>{e(t),Dl(),J.onPinsChanged()};a(t),(await m(r,i)).ok||a(n)}async function _l(e){let t=window.prompt(`Session name — empty resets it to the first message`,e.title??``);t!==null&&await gl(t=>e.title=t,t.trim()||void 0,e.title,`/api/sessions/${e.id}/rename`,{name:t})}var vl=(e,t)=>gl(t=>e.listed=t,t,!t,`/api/sessions/${e.id}/pin`,{pinned:t}),yl=(e,t)=>e.find(e=>e.cwd===t)?.branch??tr(t),bl=`flex-none truncate rounded bg-neutral-200/70 px-1 font-mono text-[10px] leading-[15px] text-neutral-500`,xl={telegram:`tg`};function Sl(e){if(!e.channel||e.channel===`web`)return[];let t=R(`span`,bl,xl[e.channel]??e.channel);return t.title=`answering ${e.channel}`,[t]}function Cl(e){let t=R(`li`,`group flex cursor-pointer items-center gap-1.5 py-1.5 pl-6 pr-3 hover:bg-neutral-100 ${e.id===J.currentId()?`bg-indigo-50 hover:bg-indigo-50`:``}`),n=R(`button`,pl,`⋯`);n.title=`Session actions`,n.onclick=t=>{t.stopPropagation(),J.sessionMenu(n,e)};let r=R(`button`,pl,`✓`);r.title=`Done — remove from Projects (the session and its transcript stay)`,r.onclick=t=>{t.stopPropagation(),vl(e,!1)},t.append(hl(e),R(`span`,`truncate`,e.title??`untitled`),R(`div`,`ml-auto flex flex-none items-center gap-1`,...Sl(e),r,n)),t.onclick=()=>J.select(e.id),t.title=`Drag to reorder`;let i=Qc(e);return fl(t,i,e.id,(t,n)=>cl(i,t,e.id,n)),t}function wl(e,t){let n=tl(e,t),r=n[0]??e,i=R(`span`,`flex-none text-[11px] text-neutral-400 group-hover:hidden`,String(t.length)),a=R(`button`,pl,`⋯`);a.title=`Project actions`,a.onclick=e=>{e.preventDefault(),e.stopPropagation(),nc(a,[...n.map(e=>({label:n.length>1?`New session in ${yl(t,e)}`:`New session here`,hint:tr(e),onSelect:()=>{K(),J.createSession(e)}})),{label:`Browse files`,onSelect:()=>{K(),J.openFiles(r)}},{label:`Remove ${t.length} session${t.length>1?`s`:``} from Projects`,onSelect:()=>{K();for(let e of t)vl(e,!1)}}])};let{el:o,summary:s}=ur(`border-b border-neutral-200/70`,[R(`span`,`truncate font-mono text-[11px] font-semibold uppercase tracking-wide text-neutral-500`,el(e,t)),R(`div`,`ml-auto flex flex-none items-center gap-1.5`,i,a)]);s.className+=` group px-3 py-1.5 hover:bg-neutral-100`,s.title=`${n.join(`
|
|
84
|
-
`)}\nDrag to reorder`,fl(s,``,e,(t,n)=>ll(t,e,n)),o.open=!qc.has(e),o.ontoggle=()=>Yc(e,!o.open);let c=R(`ul`,`pb-1`);return c.append(...t.map(Cl)),o.append(c),o}var Tl=()=>`${J.currentId()??``}\n${JSON.stringify(J.sessions())}`,El=``;function Dl(e=!1){let t=Tl();if(t===El&&!e)return;El=t;let n=J.sessions().filter(ml);Pc(n.length),Ks(n.filter(e=>e.channel===`web`).length);let r=al();Bc.replaceChildren(...r.length?r.map(([e,t])=>wl(e,t)):[R(`p`,`px-3 py-2 text-[12.5px] leading-snug text-neutral-400`,`No projects yet — create a session, or pin one from All sessions.`)]),Vc.open&&Ll()}var Ol=[{name:`tasks`,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],kl=[],Al=0,jl={ArrowDown:1,ArrowUp:-1},Ml={n:1,j:1,p:-1,k:-1};function Nl(e){if(kl.length){Al=(e+kl.length)%kl.length;for(let[e,{el:t}]of kl.entries())t.classList.toggle(`bg-indigo-100`,e===Al),t.classList.toggle(`border-indigo-500`,e===Al);kl[Al]?.el.scrollIntoView({block:`nearest`})}}function Pl(e){let t=R(`button`,`flex-none rounded px-1.5 py-0.5 text-[11.5px] ${e.listed?`bg-indigo-50 text-indigo-600`:`text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`}`,e.listed?`pinned`:`pin`);return t.title=e.listed?`Remove from Projects`:`Pin to Projects`,t.onclick=t=>{t.stopPropagation(),vl(e,!e.listed)},t}function Fl(e){let t=R(`li`,`flex cursor-pointer items-center gap-2 border-l-2 border-transparent px-3 py-1.5 hover:bg-neutral-100`);return t.append(e.session?hl(e.session):R(`span`,`h-2 w-2 flex-none`)),t.append(R(`span`,`min-w-0 flex-1 truncate`,e.label),R(`span`,`max-w-[45%] flex-none truncate text-[11.5px] text-neutral-400`,e.detail)),e.session&&t.append(R(`span`,`flex-none text-[11px] text-neutral-400`,$n(e.session.createdAt)),Pl(e.session)),t.onclick=e.open,t}var Il=e=>R(`li`,`px-3 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-400`,e);function Ll(){let e=Uc.value.trim().toLowerCase(),t=t=>!e||t.toLowerCase().includes(e),n=e=>()=>{Vc.close(),e()},r=e=>e.channel&&e.channel!==`web`?e.channel:``,i=J.sessions().filter(e=>t(`${e.title??``} ${e.cwd} ${r(e)}`)),a=(e,t)=>t.createdAt-e.createdAt,o=e=>({label:e.title??nr(e.cwd),detail:[tr(e.cwd),r(e)].filter(Boolean).join(` · `),open:n(()=>J.select(e.id)),session:e}),s=i.filter(e=>e.state===`streaming`),c=i.filter(e=>e.state!==`streaming`),l=[`Console`,Ol.filter(e=>t(`${e.label} ${e.detail}`)).map(({name:e,label:t,detail:r})=>({label:t,detail:r,open:n(()=>J.openConsole(e))}))],u=[[`Running`,s.sort(a).map(o)],[`Projects`,c.filter(e=>e.listed).sort(a).map(o)],[`Other sessions`,c.filter(e=>!e.listed).sort(a).map(o)]];e?u.unshift(l):u.push(l),kl=[];let d=[];for(let[e,t]of u)if(t.length){d.push(Il(e));for(let e of t){let t=Fl(e);kl.push({el:t,open:e.open}),d.push(t)}}Hc.replaceChildren(...d.length?d:[R(`li`,`px-3 py-3 text-[13px] text-neutral-400`,`Nothing matches.`)]),Wc.textContent=String(kl.length),Nl(Al)}function Rl(){if(Vc.open)return Vc.close();Uc.value=``,Al=0,Ll(),Vc.showModal(),Uc.focus(),J.loadSessions().then(()=>{Vc.open&&Ll()})}function zl(e){J=e,yc(L(`#new-cwd`),ol);let t=L(`#new-session`),n=()=>{let e=J.sessions().find(e=>e.id===J.currentId())?.cwd??``,t=L(`#new-cwd`);t.value=e,Gc.showModal(),t.select()};t.onclick=n,Ro(t,`shift+o`,`New session`,n,()=>Gc.open),L(`#new-cancel`).onclick=()=>Gc.close(),L(`#new-form`).onsubmit=()=>void J.createSession(L(`#new-cwd`).value.trim());let r=L(`#open-archive`);r.onclick=Rl,Ro(r,`k`,`Search sessions and Console`,Rl,()=>Vc.open),L(`#archive-close`).onclick=()=>Vc.close(),Uc.oninput=()=>{Al=0,Ll()},Uc.onkeydown=e=>{let t=e.altKey||e.metaKey||e.shiftKey||!e.key?void 0:e.ctrlKey?Ml[e.key.toLowerCase()]:jl[e.key];if(t!==void 0){e.preventDefault(),Nl(Al+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),kl[Al]?.open())}}var Y;function Bl(e){Y=e,Ho(Hl,()=>{let e=Y.currentSession();e&&(K(),vl(e,!e.listed))},Vl),Ho(Ul,()=>{Y.currentSession()&&(K(),Y.toggleFiles())},Vl)}var Vl=()=>document.querySelector(`dialog[open]`)!==null,Hl=`d`,Ul=`i`,Wl=L(`#chat-title`),Gl=L(`#chat-menu`),Kl=L(`#session-meta`),ql=null,Jl=null,Yl=null,Xl=null;function Zl(){ql=null,Jl=null,Yl=null,Xl=null,au()}function Ql(e,t,n,r){ql=e,Jl=t,Yl=n,Xl=r,nu()}function $l(e){Xl=e.completedAt,Jl&&={...Jl,tokens:e.tokens},au()}var eu=null;function tu(e){eu=e===null?null:nr(e),nu()}function nu(){let e=Y.currentSession();e&&(eu=null),Wl.textContent=e?e.title??nr(e.cwd):eu??`no session`,Wl.classList.toggle(`cursor-pointer`,!!e),Wl.title=e?`Session info`:``,Wl.onclick=e?()=>ou(Wl,e):null,Gl.classList.toggle(`hidden`,!e),e&&(Gl.onclick=()=>fu(Gl,e)),au(),Y.syncBar()}var ru=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),iu=e=>e.tokens===null?`?/${i(e.contextWindow)}`:`${i(e.tokens)}/${i(e.contextWindow)} · ${100-ru(e.tokens,e)}% left`;function au(){let e=Jl,t=e?.tokens??null,n=Y.currentId(),r=[];if(!n&&eu&&r.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,R(`span`,`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 su(r,n),r};ql&&r.push(e(ql.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Yl&&r.push(e(Yl,`text-neutral-500 hover:text-indigo-700`))}if(e&&t!==null){let n=ru(t,e),a=n>=90?`text-red-700`:n>=70?`text-amber-700`:`text-neutral-500`;r.push(R(`span`,`flex-none font-mono ${a}`,i(t).toLowerCase()))}let a=r.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);Kl.replaceChildren(...a),Kl.classList.toggle(`hidden`,r.length===0),Kl.classList.toggle(`flex`,r.length>0)}function ou(e,t){let n=[[`Title`,t.title??`untitled`],[`Directory`,t.cwd],[`Session`,t.id]],r=t.id===Y.currentId();if(r&&(n.push([`Model`,ql?.id??`—`]),n.push([`Reasoning`,Yl??`—`]),n.push([`Context`,Jl?iu(Jl):`—`])),n.push([`Created`,rr(t.createdAt),er(t.createdAt)]),r){let e=Xl;n.push(e===null?[`Last reply`,`—`]:[`Last reply`,rr(e),er(e)])}let i=R(`div`,`flex max-w-80 flex-col gap-1.5 px-3 py-2`);for(let[e,t,r]of n){let n=R(`div`,`flex items-center gap-1.5`,R(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),lr(`cursor-pointer text-[10.5px] uppercase tracking-wide text-neutral-400 opacity-0 hover:text-neutral-700 focus:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100`,()=>t)),a=R(`span`,`break-all font-mono text-[12px] text-neutral-700`,t);r&&a.append(R(`span`,`ml-1.5 font-sans text-[11px] text-neutral-400`,r)),i.append(R(`div`,`group flex flex-col`,n,a))}ec(e,i)}async function su(e,t){try{let[n,r]=await Promise.all([ie(`/api/sessions/${t}/models`,`Could not load models`),ie(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);ec(e,lc({models:n,current:t===Y.currentId()?ql:null,thinkingLevel:r.level,thinkingLevels:r.levels,onPick:(e,n)=>{K(),cu(t,e,n)},onThinkingPick:e=>void uu(t,e)}))}catch(e){V(`error`,`model options failed: ${String(e)}`)}}async function cu(e,t,n){await lu(e,t)&&n&&await uu(e,n)}async function lu(e,t){let n=ql;e===Y.currentId()&&(ql=t,nu());let r=await m(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===Y.currentId()&&(ql=n,nu()),V(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===Y.currentId()&&i&&(ql=i,nu()),!0}async function uu(e,t){let n=await m(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){V(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===Y.currentId()&&(Yl=r,au())}async function du(e){let t=await m(`/api/sessions/${e}/compact`,{});t.ok||V(`error`,`compact failed: ${await h(t,`no reason given`)}`)}function fu(e,t){let n=t.id===Y.currentId();nc(e,[{label:`Session info`,onSelect:()=>ou(e,t)},{label:`Rename…`,onSelect:()=>{K(),_l(t)}},{label:t.listed?`Done — remove from Projects`:`Pin to Projects`,hint:n?Fo(Hl):``,onSelect:()=>{K(),vl(t,!t.listed)}},{label:`Model`,hint:n?ql?.id??`…`:``,onSelect:()=>void su(e,t.id)},{label:`Compact context`,onSelect:()=>{K(),du(t.id)}},{label:`New session here`,hint:tr(t.cwd),onSelect:()=>{K(),Y.createSession(t.cwd)}},{label:`Browse files`,hint:n?Fo(Ul):``,onSelect:()=>{K(),Y.openFiles(n?void 0:t.cwd)}}])}var pu=`pier.theme`,mu=[`system`,`light`,`dark`],hu=window.matchMedia(`(prefers-color-scheme: dark)`),gu={system:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="5.25"/><path d="M8 2.75a5.25 5.25 0 0 0 0 10.5z" fill="currentColor" stroke="none"/></svg>`,light:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="3.1"/><path d="M8 1.5v1.4M8 13.1v1.4M1.5 8h1.4M13.1 8h1.4M3.4 3.4l1 1M11.6 11.6l1 1M12.6 3.4l-1 1M4.4 11.6l-1 1"/></svg>`,dark:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" class="h-3.5 w-3.5"><path d="M13 9.4A5.6 5.6 0 0 1 6.6 3a5.6 5.6 0 1 0 6.4 6.4z"/></svg>`},_u=()=>{let e=null;try{e=localStorage.getItem(pu)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},vu=()=>{let e=_u();return e===`system`?hu.matches?`dark`:`light`:e};function yu(){let e=vu();document.documentElement.dataset.theme=e,L(`meta[name="theme-color"]`).setAttribute(`content`,e===`dark`?`#1c1c1c`:`#fafafa`),window.dispatchEvent(new Event(`pier:theme`))}function bu(){let e=L(`#theme-toggle`),t=()=>{let t=_u();e.title=`Theme: ${t}${t===`system`?` (${vu()})`:``}`,e.innerHTML=gu[t],yu()};e.onclick=()=>{let e=mu[(mu.indexOf(_u())+1)%mu.length];try{e===`system`?localStorage.removeItem(pu):localStorage.setItem(pu,e)}catch{}t()},hu.addEventListener(`change`,t),t()}var xu=`https://github.com/timqi/pier`,Su=[`text-neutral-400`,`hover:text-neutral-700`],Cu=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],wu=18e5,X=null,Tu=L(`#version`);function Eu(e){let t=X?.available===!0&&X.latest!==null;Tu.textContent=`v${e}`,Tu.title=t?`Pier ${X?.latest} is out`:``,Tu.classList.remove(...t?Su:Cu),Tu.classList.add(...t?Cu:Su)}var Du=e=>R(`p`,`px-3 py-1 text-[12px] leading-snug text-neutral-500`,e);function Ou(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!X)return e.append(Du(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=X;e.append(R(`p`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`,r?`Pier ${n} is out`:`Pier ${t}`)),e.append(Du(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.`));let o=R(`span`,`px-3 text-[11.5px] text-neutral-400`,``),s=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(a&&e.append(R(`p`,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`,a)),r&&i&&!a){let e=fr(`Update now`,!0);e.onclick=()=>{e.disabled=!0,o.className=`px-3 text-[11.5px] text-neutral-400`,o.textContent=`starting the updater…`,(async()=>{let t=await m(`/api/update`,{});if(!t.ok){e.disabled=!1,o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not update`);return}let{draining:n}=await t.json();o.textContent=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.`})()},s.append(e)}let c=R(`a`,`btn text-[12.5px] no-underline`,`Source`);c.href=r?`${xu}/releases`:xu,c.target=`_blank`,c.rel=`noreferrer`,c.title=`Pier is free software (AGPL-3.0)`,s.append(c),e.append(s,o),r&&!i&&!a&&e.append(Du(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=wr(`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.`,X.autoUpdate,e=>{X&&(X.autoUpdate=e),(async()=>{let t=await m(`/api/settings`,{autoUpdate:e},`PUT`);if(t.ok)return;X&&(X.autoUpdate=!e);let n=l.querySelector(`input`);n&&(n.checked=!e),o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not save`)})()});if(!i){let e=l.querySelector(`input`);e&&(e.disabled=!0)}return e.append(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function ku(e){let t=await g(`/api/update`,`Update check failed`);t.ok&&(X=t.value,Eu(X.current||e))}function Au(e){Eu(e),Tu.onclick=e=>{e.preventDefault(),ec(Tu,Ou())};let t=()=>void ku(e).catch(()=>{});t(),setInterval(t,wu)}var Z,ju=L(`#chat-header`),Mu=L(`#chat-title`),Nu=[ju,B,L(`#composer`)],Pu=()=>Vu===null,Fu,Iu,Lu,Ru=new Map,zu=new Map,Bu=new Map,Vu=null,Hu=0,Uu=[`files`],Wu=new Map,Gu={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Ku=[`tasks`,`runs`,`activity`],qu=`Automation`,Ju=L(`#automation-view`),Yu=L(`#automation-tabs`),Xu=e=>Ku.includes(e)?`tasks`:e;function Zu(e){let t=e!==null&&Ku.includes(e);Ju.classList.toggle(`hidden`,!t),Ju.classList.toggle(`flex`,t),t&&Yu.replaceChildren(...Ku.map(t=>gr(Gu[t],t===e,()=>nd(t))))}var Qu=e=>Fu?.refresh(e),$u=()=>Iu?.refresh(),ed=()=>Lu?.refresh();function td(){Vu?Ec(Ku.includes(Vu)?qu:Gu[Vu],!1):Ec(Mu.textContent??``,Z.currentSession()!==void 0)}function nd(e,t,n){if(Uu.includes(e)){let t=md();t&&(t.kind!==`console`||t.name!==e)&&Wu.set(e,t)}gd({kind:`console`,name:e,arg:t,query:n}),Tc(),Vu=e;for(let e of Nu)e.classList.add(`hidden`);ds();for(let[t,n]of Ru)t!==e&&n.hide();for(let[t,n]of Bu)n.classList.toggle(`bg-indigo-50`,t===Xu(e));Zu(e),td(),rd(e,t,n,++Hu)}async function rd(e,t,n,r){let i=Ru.get(e);if(!i){let t=zu.get(e);if(!t){let n=L(`#${e}-view`);t=yd[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),ar(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Gu[e]} — reload the page.`))))),zu.set(e,t)}i=await t,Ru.set(e,i),zu.delete(e)}Vu===e&&r===Hu&&i.show(t,n)}var id=e=>nd(`tasks`,e),ad=(e={},t)=>nd(`runs`,t,new URLSearchParams(e).toString()),od=e=>ad({},e),sd=e=>nd(`files`,e),cd=(e,t)=>{Vu===e?ud(e):nd(e,t)},ld=e=>cd(`files`,e);function ud(e){let t=Z.currentId(),n=Wu.get(e)??(t?{kind:`session`,id:t}:null);Wu.delete(e),n?gd(n):(history.replaceState(null,``,`#/`),dd())}function dd(){if(Vu){Vu=null;for(let e of Ru.values())e.hide();for(let e of Bu.values())e.classList.remove(`bg-indigo-50`);Zu(null);for(let e of Nu)e.classList.remove(`hidden`);ds(),td(),Z.maybeAckRead()}}var fd=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,pd={config:`files`,channels:`channels`,providers:`models`};function md(){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 pd[n]?{kind:`console`,name:`settings`,arg:pd[n]}:Object.hasOwn(Gu,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var hd=!1;function gd(e,t=!1){if(hd)return;let n=fd(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var _d=e=>gd({kind:`session`,id:e});function vd(){let e=md(),t=Z.sessions(),n=Z.currentId(),r=(e?.kind===`session`?e.id:null)??n??(t.find(e=>e.listed)??t[0])?.id??null;hd=!0;try{r&&r!==n&&Z.select(r),e?.kind===`console`?nd(e.name,e.arg,e.query):dd(),r||nu()}finally{hd=!1}e?.kind!==`console`&&r&&gd({kind:`session`,id:r},!0)}var yd={tasks:async e=>Fu=(await hi(async()=>{let{createTasksView:e}=await import(`./tasks-CYfdrdF2.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Z.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Z.loadSessions,Z.select,()=>Z.currentId(),ad,id),runs:async e=>Iu=(await hi(async()=>{let{createRunsView:e}=await import(`./runs-BjcdVVmW.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Z.select,ad,id),activity:async e=>Lu=(await hi(async()=>{let{createActivityView:e}=await import(`./activity-BJ7YoxQo.js`);return{createActivityView:e}},[])).createActivityView(e,Z.select,od),boards:async e=>(await hi(async()=>{let{createBoardsView:e}=await import(`./boards-7GDMK7s8.js`);return{createBoardsView:e}},[])).createBoardsView(e,Z.select),files:async e=>(await hi(async()=>{let{createExplorerView:e}=await import(`./explorer-DBusW0TA.js`);return{createExplorerView:e}},__vite__mapDeps([3,4]))).createExplorerView(e,()=>Z.currentSession(),e=>nd(`files`,e),()=>ud(`files`)),settings:async e=>(await hi(async()=>{let{createSettingsView:e}=await import(`./settings-DH3Nlk9f.js`);return{createSettingsView:e}},__vite__mapDeps([5,4]))).createSettingsView(e,()=>[...Zc(Z.sessions()).keys()],e=>nd(`settings`,e))};function bd(e){Z=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);Bu.set(e,t),t.onclick=()=>nd(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=vd}var Q=[],xd=0,Sd=0,Cd=!1,$=null,wd=`idle`,Td=null,Ed=0,Dd=!1,Od=!1;async function kd(e){let t=++xd;++Sd,Cd=!1,dd(),Tc(),$=null,Td?.close(),Td=null,go(),fs([]),Zl(),tu(e),_o(!0),Od=!0,us();let n=await m(`/api/sessions`,{cwd:e});if(t!==xd)return;if(Od=!1,!n.ok){_o(!1),tu(null),us(),V(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();if(t!==xd)return;let{repo:i,branch:a}=Q.find(t=>t.cwd===e)??{};Q.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,listed:!0,unread:!1,channel:`web`,activeRuns:0,repo:i,branch:a}),await Bd(r),$===r&&os()}function Ad(e,t){let n=e.map(e=>({...e,title:ne(e.title)}));if(t)Q=n;else{let e=new Map(n.map(e=>[e.id,e]));Q=Q.map(t=>e.get(t.id)??(t.listed?{...t,listed:!1}:t));let t=new Set(Q.map(e=>e.id));Q.push(...n.filter(e=>!t.has(e.id)))}Q.sort((e,t)=>t.createdAt-e.createdAt),Dl(),Nd()}var jd=re(async()=>{Ad(await ie(`/api/projects`,`Could not load projects`),!1)}),Md=re(async()=>{Ad(await ie(`/api/sessions`,`Could not load sessions`),!0)});function Nd(){if(document.hidden||!document.hasFocus()||!Pu())return;let e=Q.find(e=>e.id===$);e?.unread&&(e.unread=!1,Dl(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Pd(){return Q.find(e=>e.id===$)}function Fd(e,t){let n=Q.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Dl(),nu())}function Id(e){wd=e;let t=Q.find(e=>e.id===$);t&&(t.state=e),Dl(),nu(),us(),e===`idle`&&jd()}function Ld(e){if(!(e.sessionId!==$||e.seq<=Ed))switch(Ed=e.seq,e.type){case`turn-start`:Dd=!0;break;case`system-input`:po(),za(e.text,e.origin);break;case`task-status`:Wi(e.run);break;case`user-message`:{let t=te(e.text).text;if(Fd(e.sessionId,t),ss(t))break;po(),V(`user`,e.text,!1,e.ts),ka();break}case`text-delta`:fo(e.text);break;case`thinking-delta`:ga(e.ts,e.text);break;case`tool-start`:po(),ma(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:ha(e.toolCallId,e.isError,e.output);break;case`turn-end`:Dd=!1,mo(e.text,e.meta),e.meta&&$l(e.meta);break;case`queue-state`:ps(e.steering,e.followUp);break;case`queue-recovery`:fs(e.batches,e.uncertain);break;case`context-compacted`:po(),V(`system`,`Context compacted — ${i(e.before)} → ${i(e.after)}`,!1,e.ts),ka();break;case`error`:fa(),V(`error`,e.message);break;case`state`:e.state===`idle`&&Dd&&(Dd=!1,ho()),e.state===`idle`&&ps([],[]),Id(e.state)}}function Rd(){let e=new EventSource(`/api/events`);e.onopen=()=>void jd(),e.onerror=()=>Ao(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){jd();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){Qu(t.type===`task-run-changed`?t.taskId:void 0),$u(),ed(),t.type===`task-run-changed`&&jd();return}if(ed(),t.sessionId===$)return;let n=Q.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Dl())}}function zd(e,t,n){Td?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>Td===r&&$===e&&n===Sd;r.onmessage=e=>{i()&&Ld(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&Vd(e)}),r.onerror=()=>{i()&&Ao(r,`Session`)},Td=r}async function Bd(e){dd(),Tc(),_d(e);let t=Q.some(t=>t.id===e);if(e===$&&t&&(Td||Cd))return;let n=++xd;if(++Sd,Od=!1,bs(),$=e,wd=Q.find(t=>t.id===e)?.state??`idle`,xs(e),Dl(),nu(),Nd(),t)return await Vd(e);Td?.close(),Td=null,go(),_o(!0),await Md(),n===xd&&$===e&&await Vd(e,!Q.some(t=>t.id===e))}async function Vd(e,t=!1){if($!==e)return;let n=++Sd;if(Td?.close(),Td=null,Cd=!0,go(),ps([],[]),fs([]),Zl(),Dd=!1,ls(),Ed=0,_o(!0),t){Cd=!1,_o(!1),V(`error`,`session not found: ${e}`);return}let r=await g(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||n!==Sd)return;if(Cd=!1,!r.ok){_o(!1),V(`error`,r.error);return}let i=r.value;vo(i.turns,i.state,i.backgroundRuns),Ed=i.lastSeq,Dd=i.state===`streaming`,Id(i.state),ps(i.queue.steering,i.queue.followUp),fs(i.queueRecovery,i.queueUncertain);let a=i.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Ql(i.model,i.context,i.thinkingLevel,a),zd(e,`${i.epoch}:${i.lastSeq}`,n)}Eo(),ko(),bu();var Hd=async e=>{$===e&&await Vd(e)};Sa({sessionId:()=>$,sessionState:()=>wd,select:e=>void Bd(e),showRun:od,send:(e,t)=>void ws(e,t),ownTurn:e=>{cs(e),Id(`streaming`)},reload:Hd}),Ds({sessionId:()=>$,starting:()=>Od,sessionState:()=>wd,chatVisible:Pu,setState:Id,reload:Hd}),zc({sessionMenu:e=>{let t=Pd();t&&fu(e,t)},sessionInfo:e=>{let t=Pd();t&&ou(e,t)}}),zl({sessions:()=>Q,loadSessions:Md,currentId:()=>$,select:e=>void Bd(e),sessionMenu:fu,createSession:kd,openFiles:sd,openConsole:nd,onPinsChanged:nu}),Bl({currentId:()=>$,currentSession:Pd,createSession:e=>void kd(e),syncBar:td,openFiles:sd,toggleFiles:ld}),bd({sessions:()=>Q,loadSessions:Md,currentId:()=>$,currentSession:Pd,select:e=>void Bd(e),maybeAckRead:Nd}),Au(`0.0.26`),Hs(),document.addEventListener(`visibilitychange`,Nd),window.addEventListener(`focus`,Nd),Rd(),jd().then(vd);export{Ar as A,re as B,hr as C,Cr as D,br as E,ur as F,m as G,g as H,ir as I,ne as K,R as L,tr as M,ar as N,wr as O,lr as P,$n as R,gr as S,Er as T,ie as U,h as V,ae as W,_r as _,ec as a,kr as b,Oi as c,Si as d,yr as f,fr as g,pr as h,K as i,er as j,mr as k,ki as l,Dr as m,gc as n,qs as o,Tr as p,r as q,uc as r,Vo as s,bc as t,xi as u,Or as v,Sr as w,xr as x,vr as y,nr as z};
|
|
84
|
+
`)}\nDrag to reorder`,fl(s,``,e,(t,n)=>ll(t,e,n)),o.open=!qc.has(e),o.ontoggle=()=>Yc(e,!o.open);let c=R(`ul`,`pb-1`);return c.append(...t.map(Cl)),o.append(c),o}var Tl=()=>`${J.currentId()??``}\n${JSON.stringify(J.sessions())}`,El=``;function Dl(e=!1){let t=Tl();if(t===El&&!e)return;El=t;let n=J.sessions().filter(ml);Pc(n.length),Ks(n.filter(e=>e.channel===`web`).length);let r=al();Bc.replaceChildren(...r.length?r.map(([e,t])=>wl(e,t)):[R(`p`,`px-3 py-2 text-[12.5px] leading-snug text-neutral-400`,`No projects yet — create a session, or pin one from All sessions.`)]),Vc.open&&Ll()}var Ol=[{name:`tasks`,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],kl=[],Al=0,jl={ArrowDown:1,ArrowUp:-1},Ml={n:1,j:1,p:-1,k:-1};function Nl(e){if(kl.length){Al=(e+kl.length)%kl.length;for(let[e,{el:t}]of kl.entries())t.classList.toggle(`bg-indigo-100`,e===Al),t.classList.toggle(`border-indigo-500`,e===Al);kl[Al]?.el.scrollIntoView({block:`nearest`})}}function Pl(e){let t=R(`button`,`flex-none rounded px-1.5 py-0.5 text-[11.5px] ${e.listed?`bg-indigo-50 text-indigo-600`:`text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`}`,e.listed?`pinned`:`pin`);return t.title=e.listed?`Remove from Projects`:`Pin to Projects`,t.onclick=t=>{t.stopPropagation(),vl(e,!e.listed)},t}function Fl(e){let t=R(`li`,`flex cursor-pointer items-center gap-2 border-l-2 border-transparent px-3 py-1.5 hover:bg-neutral-100`);return t.append(e.session?hl(e.session):R(`span`,`h-2 w-2 flex-none`)),t.append(R(`span`,`min-w-0 flex-1 truncate`,e.label),R(`span`,`max-w-[45%] flex-none truncate text-[11.5px] text-neutral-400`,e.detail)),e.session&&t.append(R(`span`,`flex-none text-[11px] text-neutral-400`,$n(e.session.createdAt)),Pl(e.session)),t.onclick=e.open,t}var Il=e=>R(`li`,`px-3 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-400`,e);function Ll(){let e=Uc.value.trim().toLowerCase(),t=t=>!e||t.toLowerCase().includes(e),n=e=>()=>{Vc.close(),e()},r=e=>e.channel&&e.channel!==`web`?e.channel:``,i=J.sessions().filter(e=>t(`${e.title??``} ${e.cwd} ${r(e)}`)),a=(e,t)=>t.createdAt-e.createdAt,o=e=>({label:e.title??nr(e.cwd),detail:[tr(e.cwd),r(e)].filter(Boolean).join(` · `),open:n(()=>J.select(e.id)),session:e}),s=i.filter(e=>e.state===`streaming`),c=i.filter(e=>e.state!==`streaming`),l=[`Console`,Ol.filter(e=>t(`${e.label} ${e.detail}`)).map(({name:e,label:t,detail:r})=>({label:t,detail:r,open:n(()=>J.openConsole(e))}))],u=[[`Running`,s.sort(a).map(o)],[`Projects`,c.filter(e=>e.listed).sort(a).map(o)],[`Other sessions`,c.filter(e=>!e.listed).sort(a).map(o)]];e?u.unshift(l):u.push(l),kl=[];let d=[];for(let[e,t]of u)if(t.length){d.push(Il(e));for(let e of t){let t=Fl(e);kl.push({el:t,open:e.open}),d.push(t)}}Hc.replaceChildren(...d.length?d:[R(`li`,`px-3 py-3 text-[13px] text-neutral-400`,`Nothing matches.`)]),Wc.textContent=String(kl.length),Nl(Al)}function Rl(){if(Vc.open)return Vc.close();Uc.value=``,Al=0,Ll(),Vc.showModal(),Uc.focus(),J.loadSessions().then(()=>{Vc.open&&Ll()})}function zl(e){J=e,yc(L(`#new-cwd`),ol);let t=L(`#new-session`),n=()=>{let e=J.sessions().find(e=>e.id===J.currentId())?.cwd??``,t=L(`#new-cwd`);t.value=e,Gc.showModal(),t.select()};t.onclick=n,Ro(t,`shift+o`,`New session`,n,()=>Gc.open),L(`#new-cancel`).onclick=()=>Gc.close(),L(`#new-form`).onsubmit=()=>void J.createSession(L(`#new-cwd`).value.trim());let r=L(`#open-archive`);r.onclick=Rl,Ro(r,`k`,`Search sessions and Console`,Rl,()=>Vc.open),L(`#archive-close`).onclick=()=>Vc.close(),Uc.oninput=()=>{Al=0,Ll()},Uc.onkeydown=e=>{let t=e.altKey||e.metaKey||e.shiftKey||!e.key?void 0:e.ctrlKey?Ml[e.key.toLowerCase()]:jl[e.key];if(t!==void 0){e.preventDefault(),Nl(Al+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),kl[Al]?.open())}}var Y;function Bl(e){Y=e,Ho(Hl,()=>{let e=Y.currentSession();e&&(K(),vl(e,!e.listed))},Vl),Ho(Ul,()=>{Y.currentSession()&&(K(),Y.toggleFiles())},Vl)}var Vl=()=>document.querySelector(`dialog[open]`)!==null,Hl=`d`,Ul=`i`,Wl=L(`#chat-title`),Gl=L(`#chat-menu`),Kl=L(`#session-meta`),ql=null,Jl=null,Yl=null,Xl=null;function Zl(){ql=null,Jl=null,Yl=null,Xl=null,au()}function Ql(e,t,n,r){ql=e,Jl=t,Yl=n,Xl=r,nu()}function $l(e){Xl=e.completedAt,Jl&&={...Jl,tokens:e.tokens},au()}var eu=null;function tu(e){eu=e===null?null:nr(e),nu()}function nu(){let e=Y.currentSession();e&&(eu=null),Wl.textContent=e?e.title??nr(e.cwd):eu??`no session`,Wl.classList.toggle(`cursor-pointer`,!!e),Wl.title=e?`Session info`:``,Wl.onclick=e?()=>ou(Wl,e):null,Gl.classList.toggle(`hidden`,!e),e&&(Gl.onclick=()=>fu(Gl,e)),au(),Y.syncBar()}var ru=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),iu=e=>e.tokens===null?`?/${i(e.contextWindow)}`:`${i(e.tokens)}/${i(e.contextWindow)} · ${100-ru(e.tokens,e)}% left`;function au(){let e=Jl,t=e?.tokens??null,n=Y.currentId(),r=[];if(!n&&eu&&r.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,R(`span`,`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 su(r,n),r};ql&&r.push(e(ql.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Yl&&r.push(e(Yl,`text-neutral-500 hover:text-indigo-700`))}if(e&&t!==null){let n=ru(t,e),a=n>=90?`text-red-700`:n>=70?`text-amber-700`:`text-neutral-500`;r.push(R(`span`,`flex-none font-mono ${a}`,i(t).toLowerCase()))}let a=r.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);Kl.replaceChildren(...a),Kl.classList.toggle(`hidden`,r.length===0),Kl.classList.toggle(`flex`,r.length>0)}function ou(e,t){let n=[[`Title`,t.title??`untitled`],[`Directory`,t.cwd],[`Session`,t.id]],r=t.id===Y.currentId();if(r&&(n.push([`Model`,ql?.id??`—`]),n.push([`Reasoning`,Yl??`—`]),n.push([`Context`,Jl?iu(Jl):`—`])),n.push([`Created`,rr(t.createdAt),er(t.createdAt)]),r){let e=Xl;n.push(e===null?[`Last reply`,`—`]:[`Last reply`,rr(e),er(e)])}let i=R(`div`,`flex max-w-80 flex-col gap-1.5 px-3 py-2`);for(let[e,t,r]of n){let n=R(`div`,`flex items-center gap-1.5`,R(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),lr(`cursor-pointer text-[10.5px] uppercase tracking-wide text-neutral-400 opacity-0 hover:text-neutral-700 focus:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100`,()=>t)),a=R(`span`,`break-all font-mono text-[12px] text-neutral-700`,t);r&&a.append(R(`span`,`ml-1.5 font-sans text-[11px] text-neutral-400`,r)),i.append(R(`div`,`group flex flex-col`,n,a))}ec(e,i)}async function su(e,t){try{let[n,r]=await Promise.all([ie(`/api/sessions/${t}/models`,`Could not load models`),ie(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);ec(e,lc({models:n,current:t===Y.currentId()?ql:null,thinkingLevel:r.level,thinkingLevels:r.levels,onPick:(e,n)=>{K(),cu(t,e,n)},onThinkingPick:e=>void uu(t,e)}))}catch(e){V(`error`,`model options failed: ${String(e)}`)}}async function cu(e,t,n){await lu(e,t)&&n&&await uu(e,n)}async function lu(e,t){let n=ql;e===Y.currentId()&&(ql=t,nu());let r=await m(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===Y.currentId()&&(ql=n,nu()),V(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===Y.currentId()&&i&&(ql=i,nu()),!0}async function uu(e,t){let n=await m(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){V(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===Y.currentId()&&(Yl=r,au())}async function du(e){let t=await m(`/api/sessions/${e}/compact`,{});t.ok||V(`error`,`compact failed: ${await h(t,`no reason given`)}`)}function fu(e,t){let n=t.id===Y.currentId();nc(e,[{label:`Session info`,onSelect:()=>ou(e,t)},{label:`Rename…`,onSelect:()=>{K(),_l(t)}},{label:t.listed?`Done — remove from Projects`:`Pin to Projects`,hint:n?Fo(Hl):``,onSelect:()=>{K(),vl(t,!t.listed)}},{label:`Model`,hint:n?ql?.id??`…`:``,onSelect:()=>void su(e,t.id)},{label:`Compact context`,onSelect:()=>{K(),du(t.id)}},{label:`New session here`,hint:tr(t.cwd),onSelect:()=>{K(),Y.createSession(t.cwd)}},{label:`Browse files`,hint:n?Fo(Ul):``,onSelect:()=>{K(),Y.openFiles(n?void 0:t.cwd)}}])}var pu=`pier.theme`,mu=[`system`,`light`,`dark`],hu=window.matchMedia(`(prefers-color-scheme: dark)`),gu={system:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="5.25"/><path d="M8 2.75a5.25 5.25 0 0 0 0 10.5z" fill="currentColor" stroke="none"/></svg>`,light:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="3.1"/><path d="M8 1.5v1.4M8 13.1v1.4M1.5 8h1.4M13.1 8h1.4M3.4 3.4l1 1M11.6 11.6l1 1M12.6 3.4l-1 1M4.4 11.6l-1 1"/></svg>`,dark:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" class="h-3.5 w-3.5"><path d="M13 9.4A5.6 5.6 0 0 1 6.6 3a5.6 5.6 0 1 0 6.4 6.4z"/></svg>`},_u=()=>{let e=null;try{e=localStorage.getItem(pu)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},vu=()=>{let e=_u();return e===`system`?hu.matches?`dark`:`light`:e};function yu(){let e=vu();document.documentElement.dataset.theme=e,L(`meta[name="theme-color"]`).setAttribute(`content`,e===`dark`?`#1c1c1c`:`#fafafa`),window.dispatchEvent(new Event(`pier:theme`))}function bu(){let e=L(`#theme-toggle`),t=()=>{let t=_u();e.title=`Theme: ${t}${t===`system`?` (${vu()})`:``}`,e.innerHTML=gu[t],yu()};e.onclick=()=>{let e=mu[(mu.indexOf(_u())+1)%mu.length];try{e===`system`?localStorage.removeItem(pu):localStorage.setItem(pu,e)}catch{}t()},hu.addEventListener(`change`,t),t()}var xu=`https://github.com/timqi/pier`,Su=[`text-neutral-400`,`hover:text-neutral-700`],Cu=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],wu=18e5,X=null,Tu=L(`#version`);function Eu(e){let t=X?.available===!0&&X.latest!==null;Tu.textContent=`v${e}`,Tu.title=t?`Pier ${X?.latest} is out`:``,Tu.classList.remove(...t?Su:Cu),Tu.classList.add(...t?Cu:Su)}var Du=e=>R(`p`,`px-3 py-1 text-[12px] leading-snug text-neutral-500`,e);function Ou(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!X)return e.append(Du(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=X;e.append(R(`p`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`,r?`Pier ${n} is out`:`Pier ${t}`)),e.append(Du(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.`));let o=R(`span`,`px-3 text-[11.5px] text-neutral-400`,``),s=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(a&&e.append(R(`p`,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`,a)),r&&i&&!a){let e=fr(`Update now`,!0);e.onclick=()=>{e.disabled=!0,o.className=`px-3 text-[11.5px] text-neutral-400`,o.textContent=`starting the updater…`,(async()=>{let t=await m(`/api/update`,{});if(!t.ok){e.disabled=!1,o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not update`);return}let{draining:n}=await t.json();o.textContent=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.`})()},s.append(e)}let c=R(`a`,`btn text-[12.5px] no-underline`,`Source`);c.href=r?`${xu}/releases`:xu,c.target=`_blank`,c.rel=`noreferrer`,c.title=`Pier is free software (AGPL-3.0)`,s.append(c),e.append(s,o),r&&!i&&!a&&e.append(Du(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=wr(`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.`,X.autoUpdate,e=>{X&&(X.autoUpdate=e),(async()=>{let t=await m(`/api/settings`,{autoUpdate:e},`PUT`);if(t.ok)return;X&&(X.autoUpdate=!e);let n=l.querySelector(`input`);n&&(n.checked=!e),o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not save`)})()});if(!i){let e=l.querySelector(`input`);e&&(e.disabled=!0)}return e.append(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function ku(e){let t=await g(`/api/update`,`Update check failed`);t.ok&&(X=t.value,Eu(X.current||e))}function Au(e){Eu(e),Tu.onclick=e=>{e.preventDefault(),ec(Tu,Ou())};let t=()=>void ku(e).catch(()=>{});t(),setInterval(t,wu)}var Z,ju=L(`#chat-header`),Mu=L(`#chat-title`),Nu=[ju,B,L(`#composer`)],Pu=()=>Vu===null,Fu,Iu,Lu,Ru=new Map,zu=new Map,Bu=new Map,Vu=null,Hu=0,Uu=[`files`],Wu=new Map,Gu={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Ku=[`tasks`,`runs`,`activity`],qu=`Automation`,Ju=L(`#automation-view`),Yu=L(`#automation-tabs`),Xu=e=>Ku.includes(e)?`tasks`:e;function Zu(e){let t=e!==null&&Ku.includes(e);Ju.classList.toggle(`hidden`,!t),Ju.classList.toggle(`flex`,t),t&&Yu.replaceChildren(...Ku.map(t=>gr(Gu[t],t===e,()=>nd(t))))}var Qu=e=>Fu?.refresh(e),$u=()=>Iu?.refresh(),ed=()=>Lu?.refresh();function td(){Vu?Ec(Ku.includes(Vu)?qu:Gu[Vu],!1):Ec(Mu.textContent??``,Z.currentSession()!==void 0)}function nd(e,t,n){if(Uu.includes(e)){let t=md();t&&(t.kind!==`console`||t.name!==e)&&Wu.set(e,t)}gd({kind:`console`,name:e,arg:t,query:n}),Tc(),Vu=e;for(let e of Nu)e.classList.add(`hidden`);ds();for(let[t,n]of Ru)t!==e&&n.hide();for(let[t,n]of Bu)n.classList.toggle(`bg-indigo-50`,t===Xu(e));Zu(e),td(),rd(e,t,n,++Hu)}async function rd(e,t,n,r){let i=Ru.get(e);if(!i){let t=zu.get(e);if(!t){let n=L(`#${e}-view`);t=yd[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),ar(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Gu[e]} — reload the page.`))))),zu.set(e,t)}i=await t,Ru.set(e,i),zu.delete(e)}Vu===e&&r===Hu&&i.show(t,n)}var id=e=>nd(`tasks`,e),ad=(e={},t)=>nd(`runs`,t,new URLSearchParams(e).toString()),od=e=>ad({},e),sd=e=>nd(`files`,e),cd=(e,t)=>{Vu===e?ud(e):nd(e,t)},ld=e=>cd(`files`,e);function ud(e){let t=Z.currentId(),n=Wu.get(e)??(t?{kind:`session`,id:t}:null);Wu.delete(e),n?gd(n):(history.replaceState(null,``,`#/`),dd())}function dd(){if(Vu){Vu=null;for(let e of Ru.values())e.hide();for(let e of Bu.values())e.classList.remove(`bg-indigo-50`);Zu(null);for(let e of Nu)e.classList.remove(`hidden`);ds(),td(),Z.maybeAckRead()}}var fd=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,pd={config:`files`,channels:`channels`,providers:`models`};function md(){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 pd[n]?{kind:`console`,name:`settings`,arg:pd[n]}:Object.hasOwn(Gu,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var hd=!1;function gd(e,t=!1){if(hd)return;let n=fd(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var _d=e=>gd({kind:`session`,id:e});function vd(){let e=md(),t=Z.sessions(),n=Z.currentId(),r=(e?.kind===`session`?e.id:null)??n??(t.find(e=>e.listed)??t[0])?.id??null;hd=!0;try{r&&r!==n&&Z.select(r),e?.kind===`console`?nd(e.name,e.arg,e.query):dd(),r||nu()}finally{hd=!1}e?.kind!==`console`&&r&&gd({kind:`session`,id:r},!0)}var yd={tasks:async e=>Fu=(await hi(async()=>{let{createTasksView:e}=await import(`./tasks-DZzYlKsd.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Z.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Z.loadSessions,Z.select,()=>Z.currentId(),ad,id),runs:async e=>Iu=(await hi(async()=>{let{createRunsView:e}=await import(`./runs-C4OlQT7W.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Z.select,ad,id),activity:async e=>Lu=(await hi(async()=>{let{createActivityView:e}=await import(`./activity-B44nbhXy.js`);return{createActivityView:e}},[])).createActivityView(e,Z.select,od),boards:async e=>(await hi(async()=>{let{createBoardsView:e}=await import(`./boards-CeiKKBaY.js`);return{createBoardsView:e}},[])).createBoardsView(e,Z.select),files:async e=>(await hi(async()=>{let{createExplorerView:e}=await import(`./explorer-BOeDogsY.js`);return{createExplorerView:e}},__vite__mapDeps([3,4]))).createExplorerView(e,()=>Z.currentSession(),e=>nd(`files`,e),()=>ud(`files`)),settings:async e=>(await hi(async()=>{let{createSettingsView:e}=await import(`./settings-Cn8i_QiP.js`);return{createSettingsView:e}},__vite__mapDeps([5,4]))).createSettingsView(e,()=>[...Zc(Z.sessions()).keys()],e=>nd(`settings`,e))};function bd(e){Z=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);Bu.set(e,t),t.onclick=()=>nd(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=vd}var Q=[],xd=0,Sd=0,Cd=!1,$=null,wd=`idle`,Td=null,Ed=0,Dd=!1,Od=!1;async function kd(e){let t=++xd;++Sd,Cd=!1,dd(),Tc(),$=null,Td?.close(),Td=null,go(),fs([]),Zl(),tu(e),_o(!0),Od=!0,us();let n=await m(`/api/sessions`,{cwd:e});if(t!==xd)return;if(Od=!1,!n.ok){_o(!1),tu(null),us(),V(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();if(t!==xd)return;let{repo:i,branch:a}=Q.find(t=>t.cwd===e)??{};Q.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,listed:!0,unread:!1,channel:`web`,activeRuns:0,repo:i,branch:a}),await Bd(r),$===r&&os()}function Ad(e,t){let n=e.map(e=>({...e,title:ne(e.title)}));if(t)Q=n;else{let e=new Map(n.map(e=>[e.id,e]));Q=Q.map(t=>e.get(t.id)??(t.listed?{...t,listed:!1}:t));let t=new Set(Q.map(e=>e.id));Q.push(...n.filter(e=>!t.has(e.id)))}Q.sort((e,t)=>t.createdAt-e.createdAt),Dl(),Nd()}var jd=re(async()=>{Ad(await ie(`/api/projects`,`Could not load projects`),!1)}),Md=re(async()=>{Ad(await ie(`/api/sessions`,`Could not load sessions`),!0)});function Nd(){if(document.hidden||!document.hasFocus()||!Pu())return;let e=Q.find(e=>e.id===$);e?.unread&&(e.unread=!1,Dl(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Pd(){return Q.find(e=>e.id===$)}function Fd(e,t){let n=Q.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Dl(),nu())}function Id(e){wd=e;let t=Q.find(e=>e.id===$);t&&(t.state=e),Dl(),nu(),us(),e===`idle`&&jd()}function Ld(e){if(!(e.sessionId!==$||e.seq<=Ed))switch(Ed=e.seq,e.type){case`turn-start`:Dd=!0;break;case`system-input`:po(),za(e.text,e.origin);break;case`task-status`:Wi(e.run);break;case`user-message`:{let t=te(e.text).text;if(Fd(e.sessionId,t),ss(t))break;po(),V(`user`,e.text,!1,e.ts),ka();break}case`text-delta`:fo(e.text);break;case`thinking-delta`:ga(e.ts,e.text);break;case`tool-start`:po(),ma(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:ha(e.toolCallId,e.isError,e.output);break;case`turn-end`:Dd=!1,mo(e.text,e.meta),e.meta&&$l(e.meta);break;case`queue-state`:ps(e.steering,e.followUp);break;case`queue-recovery`:fs(e.batches,e.uncertain);break;case`context-compacted`:po(),V(`system`,`Context compacted — ${i(e.before)} → ${i(e.after)}`,!1,e.ts),ka();break;case`error`:fa(),V(`error`,e.message);break;case`state`:e.state===`idle`&&Dd&&(Dd=!1,ho()),e.state===`idle`&&ps([],[]),Id(e.state)}}function Rd(){let e=new EventSource(`/api/events`);e.onopen=()=>void jd(),e.onerror=()=>Ao(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){jd();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){Qu(t.type===`task-run-changed`?t.taskId:void 0),$u(),ed(),t.type===`task-run-changed`&&jd();return}if(ed(),t.sessionId===$)return;let n=Q.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Dl())}}function zd(e,t,n){Td?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>Td===r&&$===e&&n===Sd;r.onmessage=e=>{i()&&Ld(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&Vd(e)}),r.onerror=()=>{i()&&Ao(r,`Session`)},Td=r}async function Bd(e){dd(),Tc(),_d(e);let t=Q.some(t=>t.id===e);if(e===$&&t&&(Td||Cd))return;let n=++xd;if(++Sd,Od=!1,bs(),$=e,wd=Q.find(t=>t.id===e)?.state??`idle`,xs(e),Dl(),nu(),Nd(),t)return await Vd(e);Td?.close(),Td=null,go(),_o(!0),await Md(),n===xd&&$===e&&await Vd(e,!Q.some(t=>t.id===e))}async function Vd(e,t=!1){if($!==e)return;let n=++Sd;if(Td?.close(),Td=null,Cd=!0,go(),ps([],[]),fs([]),Zl(),Dd=!1,ls(),Ed=0,_o(!0),t){Cd=!1,_o(!1),V(`error`,`session not found: ${e}`);return}let r=await g(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||n!==Sd)return;if(Cd=!1,!r.ok){_o(!1),V(`error`,r.error);return}let i=r.value;vo(i.turns,i.state,i.backgroundRuns),Ed=i.lastSeq,Dd=i.state===`streaming`,Id(i.state),ps(i.queue.steering,i.queue.followUp),fs(i.queueRecovery,i.queueUncertain);let a=i.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Ql(i.model,i.context,i.thinkingLevel,a),zd(e,`${i.epoch}:${i.lastSeq}`,n)}Eo(),ko(),bu();var Hd=async e=>{$===e&&await Vd(e)};Sa({sessionId:()=>$,sessionState:()=>wd,select:e=>void Bd(e),showRun:od,send:(e,t)=>void ws(e,t),ownTurn:e=>{cs(e),Id(`streaming`)},reload:Hd}),Ds({sessionId:()=>$,starting:()=>Od,sessionState:()=>wd,chatVisible:Pu,setState:Id,reload:Hd}),zc({sessionMenu:e=>{let t=Pd();t&&fu(e,t)},sessionInfo:e=>{let t=Pd();t&&ou(e,t)}}),zl({sessions:()=>Q,loadSessions:Md,currentId:()=>$,select:e=>void Bd(e),sessionMenu:fu,createSession:kd,openFiles:sd,openConsole:nd,onPinsChanged:nu}),Bl({currentId:()=>$,currentSession:Pd,createSession:e=>void kd(e),syncBar:td,openFiles:sd,toggleFiles:ld}),bd({sessions:()=>Q,loadSessions:Md,currentId:()=>$,currentSession:Pd,select:e=>void Bd(e),maybeAckRead:Nd}),Au(`0.0.27`),Hs(),document.addEventListener(`visibilitychange`,Nd),window.addEventListener(`focus`,Nd),Rd(),jd().then(vd);export{Ar as A,re as B,hr as C,Cr as D,br as E,ur as F,m as G,g as H,ir as I,ne as K,R as L,tr as M,ar as N,wr as O,lr as P,$n as R,gr as S,Er as T,ie as U,h as V,ae as W,_r as _,ec as a,kr as b,Oi as c,Si as d,yr as f,fr as g,pr as h,K as i,er as j,mr as k,ki as l,Dr as m,gc as n,qs as o,Tr as p,r as q,uc as r,Vo as s,bc as t,xi as u,Or as v,Sr as w,xr as x,vr as y,nr as z};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,H as t,L as n,N as r,W as i,f as a,g as o,k as s,v as c,w as l}from"./index-
|
|
1
|
+
import{B as e,H as t,L as n,N as r,W as i,f as a,g as o,k as s,v as c,w as l}from"./index-BmKvoulH.js";import{c as u,i as d,n as f,o as p,s as m}from"./task-runs-BW06ZEVz.js";function h(h,g,_,v){let y=new URLSearchParams,b=[],x=``,S=n(`div`,`min-h-0 flex-1 overflow-auto`),C=n(`div`,``),w={selectedId:null,rawOpen:!1,scrollTop:0,drawn:``},T=(e,t)=>_(Object.fromEntries(e),t),E=e=>{h.querySelector(`[role=alert]`)?.remove();let t=n(`p`,`p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),h.append(t)},D={openSession:g,openTask:v,openRun:e=>T(y,e),mutate:async e=>{let t=await i(e,`POST`,`Run update failed`);t?E(t):await O()}},O=e(async()=>{let e=w.selectedId;if(e)return d(S,e,()=>T(y),D,w);let n=y.toString(),r=await t(`/api/task-runs?${n}`,`Could not load runs`);if(n!==y.toString()||w.selectedId)return;if(!r.ok)return E(r.error);h.querySelector(`[role=alert]`)?.remove();let i=JSON.stringify(r.value);x!==n+i&&(x=n+i,M(r.value))});function k(e,t){let n=new URLSearchParams(y);t?n.set(e,t):n.delete(e),n.delete(`cursor`),T(n)}function A(){if(x=``,S=n(`div`,`min-h-0 flex-1 overflow-auto`),w.selectedId){h.replaceChildren(S);return}C=j(),h.replaceChildren(C,S)}function j(){let e=s();e.classList.add(`text-[12px]`,`text-neutral-500`);let t=(t,n,r)=>{let i=l(r,y.get(n)??``);i.classList.add(`!w-auto`,`max-w-full`,`pr-8`),i.setAttribute(`aria-label`,t),i.onchange=()=>k(n,i.value),e.append(i)};t(`State`,`state`,[[`All states`,``],...[`queued`,`running`,`succeeded`,`failed`,`cancelled`,`interrupted`,`skipped`].map(e=>[e,e])]),t(`Source`,`source`,[[`All sources`,``],...[`manual`,`agent`,`cron`,`watch`,`task`].map(e=>[e,e])]);let r=b.map(e=>[e.name+(e.archived?` (archived)`:``),e.id]),i=y.get(`taskId`);i&&!b.some(e=>e.id===i)&&r.push([i,i]),t(`Task`,`taskId`,[[`All tasks`,``],...r]);for(let[t,r]of[[`From`,`since`],[`Through`,`until`]]){let i=n(`input`,`${a} !w-auto min-w-0`);i.type=`datetime-local`,i.setAttribute(`aria-label`,t);let o=y.get(r);if(o){let e=new Date(Number(o));Number.isFinite(e.getTime())&&(i.value=new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16))}i.onchange=()=>k(r,i.value?String(new Date(i.value).getTime()):``),e.append(n(`label`,`flex min-w-0 items-center gap-2`,t,i))}let c=[...y.keys()].filter(e=>e!==`cursor`&&e!==`showUnmatched`).length,u=o(c?`Reset filters (${c})`:`Reset filters`);return u.classList.add(`ml-auto`),u.disabled=!c,u.onclick=()=>_({}),e.append(u),e}function M(e){let t=n(`input`,``);t.type=`checkbox`,t.checked=y.get(`showUnmatched`)===`true`,t.onchange=()=>k(`showUnmatched`,t.checked?`true`:``);let r=n(`label`,`flex items-center gap-2 border-b border-neutral-100 bg-neutral-50/60 px-4 py-1.5 text-[11.5px] text-neutral-500`,t,`Show unmatched probes`),i=n(`div`,`divide-y divide-neutral-100`);for(let t of e.runs){let e=n(`div`,`px-4 py-3 text-[12px] transition-colors hover:bg-neutral-50`),r=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]`);r.setAttribute(`type`,`button`),r.onclick=()=>T(y,t.id),r.append(n(`span`,`flex min-w-0 items-center gap-2`,m(t),n(`span`,`min-w-0 truncate font-medium text-neutral-800`,t.context.definition.name)),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400 md:order-2`,u(t)),n(`span`,`col-span-2 text-neutral-500 md:order-1 md:col-span-1`,f(t.queuedAt)),n(`span`,`col-span-2 break-all font-mono text-[11px] text-neutral-400 md:order-3 md:col-span-3`,`${t.id} · ${t.triggerSource}`)),e.append(r);let a=p(t);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(t.parentRunId&&c(`Parent ${t.parentRunId}`,()=>T(y,t.parentRunId)),t.resumedFromRunId&&c(`Resumed from ${t.resumedFromRunId}`,()=>T(y,t.resumedFromRunId)),t.result?.type===`task`){let e=t.result.runId;c(`Child result ${e}`,()=>T(y,e))}t.groupId&&o.append(n(`span`,s,`Group ${t.groupId}`)),o.childElementCount&&e.append(o),i.append(e)}e.runs.length||i.append(n(`div`,`p-4`,c(`No matching runs.`)));let a=n(`div`,`flex items-center gap-3 border-t border-neutral-200 p-4`);if(y.has(`cursor`)){let e=o(`Newest`);e.onclick=()=>k(`cursor`,``),a.append(e)}if(e.nextCursor){let t=o(`Older runs`);t.onclick=()=>{let t=new URLSearchParams(y);t.set(`cursor`,JSON.stringify(e.nextCursor)),T(t)},a.append(t)}let s=S.scrollTop;S.replaceChildren(r,i,a),S.scrollTop=s}async function N(){let e=await t(`/api/tasks?kind=task`,`Could not load task filters`);if(!e.ok)return E(e.error);if(JSON.stringify(b)!==JSON.stringify(e.value)&&(b=e.value,!w.selectedId&&C.isConnected)){let e=j();C.replaceWith(e),C=e}}let P=r(h,(e,t)=>{y=new URLSearchParams(t),w.selectedId!==(e||null)&&(w.rawOpen=!1,w.scrollTop=0),w.selectedId=e||null,A(),O(),e||N()});return Object.assign(P,{refresh(){P.visible&&O()}})}export{h as createRunsView};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,D as t,E as n,G as r,H as i,L as a,M as o,N as s,O as c,P as l,S as u,T as d,V as f,_ as p,b as m,c as h,f as g,g as _,h as v,j as y,m as b,o as x,p as S,q as C,r as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./index-CquEUmXo.js";import{n as j,t as M}from"./code-8o-S-MIZ.js";var N={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}},P=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(N))}`,F=()=>m(`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."]),I=(e=`left`)=>m(`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 L(){let t=_(`Create Slack app ↗`,!0);t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(P(),`_blank`,`noreferrer`);let n=l(`btn w-fit text-[12.5px]`,()=>JSON.stringify(N,null,2));return m(`Creating a Slack app`,[e(`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.",e(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var R=()=>m(`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.`]),z=(e=`left`)=>m(`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),ee=()=>m(`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.`]),B=(e=`left`)=>m(`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),V=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],H=(e,t)=>a(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,a(`span`,``,e),t),te={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`},U=`pier.channelsPlatform`;function ne(e){let t=localStorage.getItem(U),o=V.some(([e])=>e===t)?t:`telegram`,l=null,d=[],f=a(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),m=a(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,f),h=a(`div`,`px-4 py-5`);e.append(a(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,m,h));function g(){m.replaceChildren(...V.map(([e,t])=>u(t,e===o,()=>{y&&M(),o=e,localStorage.setItem(U,e),N()})),f)}let y,x=!1,C=null;function E(e){if(f.replaceChildren(),e!==`clean`){if(f.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${S[e]}`,e===`saving`)f.append(a(`span`,`spinner`),a(`span`,``,`Saving…`));else if(e===`saved`)f.append(a(`span`,``,`✓`),a(`span`,``,`Saved`)),setTimeout(()=>{f.textContent?.includes(`Saved`)&&E(`clean`)},2e3);else{let e=v(`Retry`,`cursor-pointer underline`);e.onclick=M,f.append(a(`span`,``,`⚠`),a(`span`,``,`Save failed`),e)}}}function O(){E(`saving`),clearTimeout(y),y=setTimeout(M,500)}let k=e=>t=>{e(t),O()};async function j(e){x=!0,E(`saving`);try{E((await r(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{E(`failed`)}finally{x=!1;let e=C;C=null,e&&j(e)}}function M(){if(clearTimeout(y),y=void 0,!l)return;let e={platform:o,config:l};x?C=e:j(e)}async function N(){if(!d.length){let e=await i(`/api/models`,`Could not load the model catalog`);e.ok&&(d=e.value)}let e=await i(`/api/channels/${o}`,`Failed to load`);if(!e.ok){l=null,g(),h.replaceChildren(D(e.error));return}l=e.value,E(`clean`),W()}function P(e){let t=o===`slack`,r=o===`lark`,i=n(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,k(t=>e.token=t),!0),a=n(e.appToken,r?``:`xapp-…`,k(t=>e.appToken=t),!0),s=T(e.cwd,`(pier process cwd)`,k(t=>e.cwd=t));return p(`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.`,c(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,k(t=>{e.enabled=t,g()})),A(r?`App ID`:`Bot token`,i,{hint:`Stored locally, shown masked once saved.`,help:o===`telegram`?F():t?L():ee()}),...t?[A(`App-level token`,a,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),c(`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,k(t=>e.agentTool=t),R())]:[],...r?[A(`App Secret`,a,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],A(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function ne(e){return p(`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.`,c(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,k(t=>e.requireMention=t)),c(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,k(t=>e.requireBind=t)),...o===`slack`?[H(`Thread mode: always on`,z())]:o===`lark`?[H(`Thread mode: always on`,B())]:[c(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,k(t=>e.topicMode=t),I())],w(`Model & reasoning`,e,d,k(t=>{e.model=t.model,e.thinking=t.thinking,W()})))}function re(e){let t=a(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=a(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,a(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=_(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${o}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let i=a(`div`,`flex flex-col`);e.users.length||i.append(D(`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`);e.onclick=async()=>{await fetch(`/api/channels/${o}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await N()},i.append(a(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,a(`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()),a(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),a(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return p(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,i,a(`div`,`flex flex-col gap-2`,r,n))}function ie(e,t){let n=a(`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`}`),r=a(`div`,`flex items-center gap-2`,a(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),b(t.kind,te[t.kind]),a(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),i=c(``,``,t.enabled,k(e=>{t.enabled=e,W()}));i.classList.add(`flex-none`,`items-center`),r.append(i);let s=a(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?s.append(a(`span`,`text-[13px] text-neutral-400`,o===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):s.append(c(`Require mention`,``,t.requireMention,k(e=>t.requireMention=e)),c(`Require bind`,``,t.requireBind,k(e=>t.requireBind=e)),o===`slack`?H(`Thread mode: always on`,z(`right`)):o===`lark`?H(`Thread mode: always on`,B(`right`)):t.kind===`forum`?c(`Topic mode`,``,t.topicMode,k(e=>t.topicMode=e),I(`right`)):H(`Topic mode: forum groups only`,I(`right`)));let l=T(t.cwd,``,k(e=>t.cwd=e)),u=a(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,A(`Working directory`,l.el),w(`Model & reasoning`,t,d,k(e=>{t.model=e.model,t.thinking=e.thinking,W()})));return n.append(r,s,u),n}function ae(e){let t=a(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>ie(e,t))):t.append(D(`None yet. Chats appear here after the bot sees a message in them.`)),p(o===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function W(){if(!l)return;g();let e=a(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(P(l),ne(l),re(l),ae(l)),h.replaceChildren(e)}return s(e,()=>void N(),()=>{y&&M()})}function re(){let e=a(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),t=a(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),o=a(`p`,`text-[12px] break-words`),s=a(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),u=a(`section`,`flex min-w-0 flex-col gap-3`);t.append(a(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),o,s,u),e.append(t);let p=null,m=!1,h=!1,g=0,v=``,y=!1,b=e=>e?new Date(e).toLocaleString():`Never`;async function x(){let e=g,t=await i(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(h||e!==g)){if(!t.ok){d(o,`failed`,t.error);return}p=t.value,y||(v=p.sourceUrl),w()}}async function S(e){if(!m){++g,m=!0,w(),d(o,`saving`,`Working...`);try{let t=await r(`/api/config-sync`,{action:e,...e===`subscribe`?{url:v}:{}});if(!t.ok)throw Error(await f(t,`Configuration sync failed`));let n=await t.json();p=n,y=!1,v=n.sourceUrl,d(o,`saved`,n.result??`Saved`)}catch(e){d(o,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await x()}finally{m=!1,h||w()}}}function C(e,t){let n=_(e);return n.disabled=m,n.onclick=()=>{S(t)},n}function w(){if(!p||h)return;if(s.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),p.publishedPath){let e=`${p.publicUrl||window.location.origin}${p.publishedPath}`,t=n(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),s.append(t,a(`div`,`flex flex-wrap items-center gap-2`,l(`btn text-[12px]`,()=>e),C(`Revoke link`,`revoke`)))}else s.append(a(`div`,``,C(`Generate link`,`publish`)));s.append(a(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts and model definitions. API keys, headers and endpoints stay private.`));let e=n(v,`https://example.com/config-sync/...`,e=>{v=e,y=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=m||p.enabled;let t=c(`Automatic sync`,``,p.enabled,e=>{S(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=m;let r=a(`div`,`flex flex-wrap items-center gap-3`,t);p.enabled&&r.append(C(`Sync now`,`sync`)),u.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),A(`Source URL`,e),r);let i=a(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,b(p.lastChecked)],[`Last applied`,b(p.lastApplied)],[`Next check`,p.enabled?b(p.nextRunAt):`Paused`]])i.append(a(`dt`,`text-neutral-500`,e),a(`dd`,`min-w-0 break-words text-neutral-700`,t));if(u.append(i),p.error&&u.append(a(`p`,`text-[12px] break-words text-red-600`,p.error)),p.needsReload&&u.append(a(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),p.taskId){let e=a(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(p.taskId)}`,u.append(e)}}x();let T=setInterval(()=>{!m&&!y&&x()},15e3);return{el:e,dispose:()=>{h=!0,clearInterval(T)}}}async function ie(e,t){let n;try{n=await r(`/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 f(n,`could not save`)}};let i;try{i=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return i.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${i.toolsSync.reason}`},answer:i}:i.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:i}:{outcome:{state:`saved`,text:t},answer:i}}function ae(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 W(e,t){let l=`global`,u=null,p=0,m=0,h=``,_=null,v=[],y=``,x=null,S=null,C=()=>{S?.dispose(),S=null},w=()=>{C(),++m,S=re(),L.replaceChildren(S.el)},T=[],D=()=>v.filter(e=>e.kind===`extension`),O=e=>e.source===`binary`&&e.custom===!0,k=()=>v.filter(e=>e.kind===`tool`),N=document.createElement(`select`);N.className=`select w-full rounded-md border border-neutral-300 px-2 py-1 text-[12.5px] focus:border-indigo-400 focus:outline-none`,N.onchange=()=>{C(),l=N.value,u=null,K.clear(),te()};let P=a(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);P.append(a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),N);let F=a(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),I=a(`nav`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[13px] max-md:max-h-48 max-md:w-full max-md:border-r-0 max-md:border-b`);I.append(P,F);let L=a(`div`,`flex min-w-0 flex-1 flex-col`),R=a(`div`,`flex min-h-0 flex-1 max-md:flex-col`);R.append(I,L),e.append(R);let z=(e=``)=>`?scope=${encodeURIComponent(l)}${e}`;async function ee(){if(l!==`global`){v=[],y=``;return}let e=await i(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}B(e.value),y=``}function B(e){v=e.catalog,T=e.customTools,x=e.toolsTaskId}async function V(e,t){let{outcome:n,answer:r}=await ie(e,t);return r&&(B(r),J(_)),n}function H(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function te(){let e=++p;m++;let[t]=await Promise.all([i(`/api/config${z()}`,`failed to load config`,{cache:`no-store`}),ee()]);if(e!==p)return;if(!t.ok){J(null),Y(t.error);return}let n=t.value;l===`global`&&n.dir&&(h=n.dir,pe()),_=n,J(n),u?u.type===`sync`&&w():se()}function U(e){return a(`div`,`px-3 pb-0.5 pt-2.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let ne=()=>{let e=a(`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},W=()=>a(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function G(e,t,n,r,i=0,o){let s=a(`button`,`flex w-full cursor-pointer items-center gap-1.5 py-1 pr-3 text-left hover:bg-neutral-100 ${t?`bg-indigo-50 hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(a(`span`,`truncate`,e)),o&&s.append(o),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function oe(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 K=new Set;function q(e,t,n,r,i,o){let s=[];for(let[c,l]of t.dirs){let t=n?`${n}/${c}`:c,u=`${e}:${t}`,d=document.createElement(`details`);d.open=K.has(u),d.ontoggle=()=>d.open?K.add(u):K.delete(u);let f=a(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);f.style.paddingLeft=`${20+r*14}px`,f.title=t,f.append(a(`span`,`chev`,`▶`),a(`span`,`truncate text-neutral-600`,c)),l.link&&f.append(ne()),d.append(f,...q(e,l,t,r+1,i,o)),s.push(d)}for(let a of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${a.name}`:a.name};s.push(G(a.name,i(t),!1,()=>o(t),r,a.link?ne():void 0))}return s}function J(e){if(!e){F.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(u),n=t=>{C(),u=t,J(e),t.type===`file`?ce(t.name):t.type===`bundled`?ue(t.name):t.type===`tools`?$():t.type===`sync`?w():fe(t.kind,t.name)},r=[];if(l===`global`){let e={type:`sync`};r.push(U(`Instance`),G(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(U(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(G(i.name,t(e),!i.exists,()=>n(e)))}if(l===`global`){r.push(U(`bundled with Pier`)),y?r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):D().length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of D()){let i={type:`bundled`,name:e.name};r.push(G(e.name,t(i),!1,()=>n(i),0,e.enabled?W():void 0))}if(!y){let e={type:`tools`},i=k().filter(e=>e.enabled).length;r.push(G(`command-line tools`,t(e),!1,()=>n(e),0,i?W():void 0))}}for(let i of[`extensions`,`skills`]){r.push(U(`${i} (read-only)`));let o=e.resources[i];o.length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...q(i,oe(o),``,0,t,n))}F.replaceChildren(...r)}function se(){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function Y(e){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let X=(e,...t)=>a(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,a(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function ce(e){let t=++m,n=await i(`/api/config/files/${encodeURIComponent(e)}${z()}`,`failed to load ${e}`,{cache:`no-store`});if(!n.ok){t===m&&Y(n.error);return}if(t!==m)return;let{content:o}=n.value,s=o,c=a(`span`,`text-[11.5px] text-neutral-400`,``),l=a(`button`,`btn btn-primary ml-auto 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=o;let p=async()=>{if(l.disabled)return;let t=u.value;l.disabled=!0,d(c,`saving`,`saving…`);try{let n=await r(`/api/config/files/${encodeURIComponent(e)}${z()}`,{content:t,expected:s},`PUT`);if(!n.ok)return d(c,`failed`,await f(n,`save failed`));let i=await n.json();s=i.content,u.value===t?(u.value=i.content,d(c,`saved`,`saved — applies to new sessions`)):d(c,`idle`,`saved; newer changes are unsaved`)}catch(e){d(c,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}};l.onclick=()=>void p(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p())},u.oninput=()=>{d(c,`idle`,`unsaved changes`)},L.replaceChildren(X(e,c,l),u),u.focus()}function le(e){if(!x)return null;let t=a(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(x)}`,t}let Z=()=>{let e=a(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function Q(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 ue(e,t){m++;let n=v.find(t=>t.name===e&&t.kind===`extension`);if(!n)return Y(`unknown extension: ${e}`);let r=a(`span`,`text-[11.5px] text-neutral-400`,``);t&&d(r,t.state,t.text);let i=le(`every run of the update task`);L.replaceChildren(X(n.name,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,n.source===`binary`?`installed by Pier`:`ships with Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,n.summary),a(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(n.source===`bundled`?n.adds:[]).flatMap(e=>[a(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),a(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...n.source===`binary`?[a(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),a(`dd`,`font-mono text-[12px] leading-snug ${n.binary.error?`text-red-600`:`text-neutral-500`}`,Q(n))]:[]),c(`Enabled`,n.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.`,n.enabled,t=>void de(n.name,t,t=>ue(e,t))),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...n.source===`binary`?i?[`A daily task installs and updates it — its history is `,i,`.`]:[`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.`]),r))}function $(e,t={name:``,toml:``}){m++;let r=a(`span`,`text-[11.5px] text-neutral-400`,``);e&&d(r,e.state,e.text);let i=k(),o=le(`the update task`),s=e=>{let t=a(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,a(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,a(`span`,`font-mono`,e.name),...O(e)?[b(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),a(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||Q(e)),...e.summary?[a(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,Q(e))]:[]),n=c(``,``,e.enabled,t=>void de(e.name,t,e=>$(e))),r=a(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=ae(e,T);V(t.body,t.saved).then(e=>$(e))},a(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...O(e)?[r]:[],n)},l={...t},u=a(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),f=n(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),p=document.createElement(`textarea`);p.className=`${g} h-24 resize-y font-mono leading-snug`,p.spellcheck=!1,p.value=l.toml,p.placeholder=`spec = "github:owner/repo"
|
|
1
|
+
import{A as e,D as t,E as n,G as r,H as i,L as a,M as o,N as s,O as c,P as l,S as u,T as d,V as f,_ as p,b as m,c as h,f as g,g as _,h as v,j as y,m as b,o as x,p as S,q as C,r as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./index-BmKvoulH.js";import{n as j,t as M}from"./code-I0lxXuvE.js";var N={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}},P=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(N))}`,F=()=>m(`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."]),I=(e=`left`)=>m(`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 L(){let t=_(`Create Slack app ↗`,!0);t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(P(),`_blank`,`noreferrer`);let n=l(`btn w-fit text-[12.5px]`,()=>JSON.stringify(N,null,2));return m(`Creating a Slack app`,[e(`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.",e(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var R=()=>m(`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.`]),z=(e=`left`)=>m(`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),ee=()=>m(`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.`]),B=(e=`left`)=>m(`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),V=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],H=(e,t)=>a(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,a(`span`,``,e),t),te={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`},U=`pier.channelsPlatform`;function ne(e){let t=localStorage.getItem(U),o=V.some(([e])=>e===t)?t:`telegram`,l=null,d=[],f=a(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),m=a(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,f),h=a(`div`,`px-4 py-5`);e.append(a(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,m,h));function g(){m.replaceChildren(...V.map(([e,t])=>u(t,e===o,()=>{y&&M(),o=e,localStorage.setItem(U,e),N()})),f)}let y,x=!1,C=null;function E(e){if(f.replaceChildren(),e!==`clean`){if(f.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${S[e]}`,e===`saving`)f.append(a(`span`,`spinner`),a(`span`,``,`Saving…`));else if(e===`saved`)f.append(a(`span`,``,`✓`),a(`span`,``,`Saved`)),setTimeout(()=>{f.textContent?.includes(`Saved`)&&E(`clean`)},2e3);else{let e=v(`Retry`,`cursor-pointer underline`);e.onclick=M,f.append(a(`span`,``,`⚠`),a(`span`,``,`Save failed`),e)}}}function O(){E(`saving`),clearTimeout(y),y=setTimeout(M,500)}let k=e=>t=>{e(t),O()};async function j(e){x=!0,E(`saving`);try{E((await r(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{E(`failed`)}finally{x=!1;let e=C;C=null,e&&j(e)}}function M(){if(clearTimeout(y),y=void 0,!l)return;let e={platform:o,config:l};x?C=e:j(e)}async function N(){if(!d.length){let e=await i(`/api/models`,`Could not load the model catalog`);e.ok&&(d=e.value)}let e=await i(`/api/channels/${o}`,`Failed to load`);if(!e.ok){l=null,g(),h.replaceChildren(D(e.error));return}l=e.value,E(`clean`),W()}function P(e){let t=o===`slack`,r=o===`lark`,i=n(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,k(t=>e.token=t),!0),a=n(e.appToken,r?``:`xapp-…`,k(t=>e.appToken=t),!0),s=T(e.cwd,`(pier process cwd)`,k(t=>e.cwd=t));return p(`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.`,c(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,k(t=>{e.enabled=t,g()})),A(r?`App ID`:`Bot token`,i,{hint:`Stored locally, shown masked once saved.`,help:o===`telegram`?F():t?L():ee()}),...t?[A(`App-level token`,a,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),c(`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,k(t=>e.agentTool=t),R())]:[],...r?[A(`App Secret`,a,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],A(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function ne(e){return p(`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.`,c(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,k(t=>e.requireMention=t)),c(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,k(t=>e.requireBind=t)),...o===`slack`?[H(`Thread mode: always on`,z())]:o===`lark`?[H(`Thread mode: always on`,B())]:[c(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,k(t=>e.topicMode=t),I())],w(`Model & reasoning`,e,d,k(t=>{e.model=t.model,e.thinking=t.thinking,W()})))}function re(e){let t=a(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=a(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,a(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=_(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${o}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let i=a(`div`,`flex flex-col`);e.users.length||i.append(D(`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`);e.onclick=async()=>{await fetch(`/api/channels/${o}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await N()},i.append(a(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,a(`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()),a(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),a(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return p(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,i,a(`div`,`flex flex-col gap-2`,r,n))}function ie(e,t){let n=a(`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`}`),r=a(`div`,`flex items-center gap-2`,a(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),b(t.kind,te[t.kind]),a(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),i=c(``,``,t.enabled,k(e=>{t.enabled=e,W()}));i.classList.add(`flex-none`,`items-center`),r.append(i);let s=a(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?s.append(a(`span`,`text-[13px] text-neutral-400`,o===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):s.append(c(`Require mention`,``,t.requireMention,k(e=>t.requireMention=e)),c(`Require bind`,``,t.requireBind,k(e=>t.requireBind=e)),o===`slack`?H(`Thread mode: always on`,z(`right`)):o===`lark`?H(`Thread mode: always on`,B(`right`)):t.kind===`forum`?c(`Topic mode`,``,t.topicMode,k(e=>t.topicMode=e),I(`right`)):H(`Topic mode: forum groups only`,I(`right`)));let l=T(t.cwd,``,k(e=>t.cwd=e)),u=a(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,A(`Working directory`,l.el),w(`Model & reasoning`,t,d,k(e=>{t.model=e.model,t.thinking=e.thinking,W()})));return n.append(r,s,u),n}function ae(e){let t=a(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>ie(e,t))):t.append(D(`None yet. Chats appear here after the bot sees a message in them.`)),p(o===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function W(){if(!l)return;g();let e=a(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(P(l),ne(l),re(l),ae(l)),h.replaceChildren(e)}return s(e,()=>void N(),()=>{y&&M()})}function re(){let e=a(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),t=a(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),o=a(`p`,`text-[12px] break-words`),s=a(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),u=a(`section`,`flex min-w-0 flex-col gap-3`);t.append(a(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),o,s,u),e.append(t);let p=null,m=!1,h=!1,g=0,v=``,y=!1,b=e=>e?new Date(e).toLocaleString():`Never`;async function x(){let e=g,t=await i(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(h||e!==g)){if(!t.ok){d(o,`failed`,t.error);return}p=t.value,y||(v=p.sourceUrl),w()}}async function S(e){if(!m){++g,m=!0,w(),d(o,`saving`,`Working...`);try{let t=await r(`/api/config-sync`,{action:e,...e===`subscribe`?{url:v}:{}});if(!t.ok)throw Error(await f(t,`Configuration sync failed`));let n=await t.json();p=n,y=!1,v=n.sourceUrl,d(o,`saved`,n.result??`Saved`)}catch(e){d(o,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await x()}finally{m=!1,h||w()}}}function C(e,t){let n=_(e);return n.disabled=m,n.onclick=()=>{S(t)},n}function w(){if(!p||h)return;if(s.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),p.publishedPath){let e=`${p.publicUrl||window.location.origin}${p.publishedPath}`,t=n(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),s.append(t,a(`div`,`flex flex-wrap items-center gap-2`,l(`btn text-[12px]`,()=>e),C(`Revoke link`,`revoke`)))}else s.append(a(`div`,``,C(`Generate link`,`publish`)));s.append(a(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts and model definitions. API keys, headers and endpoints stay private.`));let e=n(v,`https://example.com/config-sync/...`,e=>{v=e,y=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=m||p.enabled;let t=c(`Automatic sync`,``,p.enabled,e=>{S(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=m;let r=a(`div`,`flex flex-wrap items-center gap-3`,t);p.enabled&&r.append(C(`Sync now`,`sync`)),u.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),A(`Source URL`,e),r);let i=a(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,b(p.lastChecked)],[`Last applied`,b(p.lastApplied)],[`Next check`,p.enabled?b(p.nextRunAt):`Paused`]])i.append(a(`dt`,`text-neutral-500`,e),a(`dd`,`min-w-0 break-words text-neutral-700`,t));if(u.append(i),p.error&&u.append(a(`p`,`text-[12px] break-words text-red-600`,p.error)),p.needsReload&&u.append(a(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),p.taskId){let e=a(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(p.taskId)}`,u.append(e)}}x();let T=setInterval(()=>{!m&&!y&&x()},15e3);return{el:e,dispose:()=>{h=!0,clearInterval(T)}}}async function ie(e,t){let n;try{n=await r(`/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 f(n,`could not save`)}};let i;try{i=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return i.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${i.toolsSync.reason}`},answer:i}:i.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:i}:{outcome:{state:`saved`,text:t},answer:i}}function ae(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 W(e,t){let l=`global`,u=null,p=0,m=0,h=``,_=null,v=[],y=``,x=null,S=null,C=()=>{S?.dispose(),S=null},w=()=>{C(),++m,S=re(),L.replaceChildren(S.el)},T=[],D=()=>v.filter(e=>e.kind===`extension`),O=e=>e.source===`binary`&&e.custom===!0,k=()=>v.filter(e=>e.kind===`tool`),N=document.createElement(`select`);N.className=`select w-full rounded-md border border-neutral-300 px-2 py-1 text-[12.5px] focus:border-indigo-400 focus:outline-none`,N.onchange=()=>{C(),l=N.value,u=null,K.clear(),te()};let P=a(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);P.append(a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),N);let F=a(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),I=a(`nav`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[13px] max-md:max-h-48 max-md:w-full max-md:border-r-0 max-md:border-b`);I.append(P,F);let L=a(`div`,`flex min-w-0 flex-1 flex-col`),R=a(`div`,`flex min-h-0 flex-1 max-md:flex-col`);R.append(I,L),e.append(R);let z=(e=``)=>`?scope=${encodeURIComponent(l)}${e}`;async function ee(){if(l!==`global`){v=[],y=``;return}let e=await i(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}B(e.value),y=``}function B(e){v=e.catalog,T=e.customTools,x=e.toolsTaskId}async function V(e,t){let{outcome:n,answer:r}=await ie(e,t);return r&&(B(r),J(_)),n}function H(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function te(){let e=++p;m++;let[t]=await Promise.all([i(`/api/config${z()}`,`failed to load config`,{cache:`no-store`}),ee()]);if(e!==p)return;if(!t.ok){J(null),Y(t.error);return}let n=t.value;l===`global`&&n.dir&&(h=n.dir,pe()),_=n,J(n),u?u.type===`sync`&&w():se()}function U(e){return a(`div`,`px-3 pb-0.5 pt-2.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let ne=()=>{let e=a(`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},W=()=>a(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function G(e,t,n,r,i=0,o){let s=a(`button`,`flex w-full cursor-pointer items-center gap-1.5 py-1 pr-3 text-left hover:bg-neutral-100 ${t?`bg-indigo-50 hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(a(`span`,`truncate`,e)),o&&s.append(o),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function oe(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 K=new Set;function q(e,t,n,r,i,o){let s=[];for(let[c,l]of t.dirs){let t=n?`${n}/${c}`:c,u=`${e}:${t}`,d=document.createElement(`details`);d.open=K.has(u),d.ontoggle=()=>d.open?K.add(u):K.delete(u);let f=a(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);f.style.paddingLeft=`${20+r*14}px`,f.title=t,f.append(a(`span`,`chev`,`▶`),a(`span`,`truncate text-neutral-600`,c)),l.link&&f.append(ne()),d.append(f,...q(e,l,t,r+1,i,o)),s.push(d)}for(let a of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${a.name}`:a.name};s.push(G(a.name,i(t),!1,()=>o(t),r,a.link?ne():void 0))}return s}function J(e){if(!e){F.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(u),n=t=>{C(),u=t,J(e),t.type===`file`?ce(t.name):t.type===`bundled`?ue(t.name):t.type===`tools`?$():t.type===`sync`?w():fe(t.kind,t.name)},r=[];if(l===`global`){let e={type:`sync`};r.push(U(`Instance`),G(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(U(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(G(i.name,t(e),!i.exists,()=>n(e)))}if(l===`global`){r.push(U(`bundled with Pier`)),y?r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):D().length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of D()){let i={type:`bundled`,name:e.name};r.push(G(e.name,t(i),!1,()=>n(i),0,e.enabled?W():void 0))}if(!y){let e={type:`tools`},i=k().filter(e=>e.enabled).length;r.push(G(`command-line tools`,t(e),!1,()=>n(e),0,i?W():void 0))}}for(let i of[`extensions`,`skills`]){r.push(U(`${i} (read-only)`));let o=e.resources[i];o.length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...q(i,oe(o),``,0,t,n))}F.replaceChildren(...r)}function se(){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function Y(e){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let X=(e,...t)=>a(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,a(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function ce(e){let t=++m,n=await i(`/api/config/files/${encodeURIComponent(e)}${z()}`,`failed to load ${e}`,{cache:`no-store`});if(!n.ok){t===m&&Y(n.error);return}if(t!==m)return;let{content:o}=n.value,s=o,c=a(`span`,`text-[11.5px] text-neutral-400`,``),l=a(`button`,`btn btn-primary ml-auto 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=o;let p=async()=>{if(l.disabled)return;let t=u.value;l.disabled=!0,d(c,`saving`,`saving…`);try{let n=await r(`/api/config/files/${encodeURIComponent(e)}${z()}`,{content:t,expected:s},`PUT`);if(!n.ok)return d(c,`failed`,await f(n,`save failed`));let i=await n.json();s=i.content,u.value===t?(u.value=i.content,d(c,`saved`,`saved — applies to new sessions`)):d(c,`idle`,`saved; newer changes are unsaved`)}catch(e){d(c,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}};l.onclick=()=>void p(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p())},u.oninput=()=>{d(c,`idle`,`unsaved changes`)},L.replaceChildren(X(e,c,l),u),u.focus()}function le(e){if(!x)return null;let t=a(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(x)}`,t}let Z=()=>{let e=a(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function Q(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 ue(e,t){m++;let n=v.find(t=>t.name===e&&t.kind===`extension`);if(!n)return Y(`unknown extension: ${e}`);let r=a(`span`,`text-[11.5px] text-neutral-400`,``);t&&d(r,t.state,t.text);let i=le(`every run of the update task`);L.replaceChildren(X(n.name,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,n.source===`binary`?`installed by Pier`:`ships with Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,n.summary),a(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(n.source===`bundled`?n.adds:[]).flatMap(e=>[a(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),a(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...n.source===`binary`?[a(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),a(`dd`,`font-mono text-[12px] leading-snug ${n.binary.error?`text-red-600`:`text-neutral-500`}`,Q(n))]:[]),c(`Enabled`,n.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.`,n.enabled,t=>void de(n.name,t,t=>ue(e,t))),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...n.source===`binary`?i?[`A daily task installs and updates it — its history is `,i,`.`]:[`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.`]),r))}function $(e,t={name:``,toml:``}){m++;let r=a(`span`,`text-[11.5px] text-neutral-400`,``);e&&d(r,e.state,e.text);let i=k(),o=le(`the update task`),s=e=>{let t=a(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,a(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,a(`span`,`font-mono`,e.name),...O(e)?[b(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),a(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||Q(e)),...e.summary?[a(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,Q(e))]:[]),n=c(``,``,e.enabled,t=>void de(e.name,t,e=>$(e))),r=a(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=ae(e,T);V(t.body,t.saved).then(e=>$(e))},a(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...O(e)?[r]:[],n)},l={...t},u=a(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),f=n(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),p=document.createElement(`textarea`);p.className=`${g} h-24 resize-y font-mono leading-snug`,p.spellcheck=!1,p.value=l.toml,p.placeholder=`spec = "github:owner/repo"
|
|
2
2
|
exe = "tool"`,p.oninput=()=>l.toml=p.value;let h=a(`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 d(r,`failed`,`A custom tool needs a name and a block with a spec line.`);h.disabled=!0,V({customTools:[...T,e],tool:{name:e.name,on:!0}},`Added ${e.name} — installing now.`).then(e=>$(e,e.state===`failed`?l:void 0))},L.replaceChildren(X(`command-line tools`,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`installed by Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[12.5px] leading-relaxed text-neutral-500`,`Pier writes no downloader: `,Z(),` does the work — a declarative installer that resolves a spec like `,a(`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?a(`p`,`max-w-2xl text-[12.5px] text-red-600`,y):a(`div`,`flex max-w-2xl flex-col`,...i.map(s)),a(`div`,`flex max-w-2xl flex-col gap-2 border-t border-neutral-200 pt-4`,a(`span`,`text-[12.5px] font-medium text-neutral-600`,`Add one of your own`),A(`Name`,f),A(`The block Pier writes under the header`,p,{hint:`A line that opens a section of its own is refused, because it could rewrite the rest of the file.`}),a(`div`,`flex items-center gap-3`,u,h)),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...o?[`Installs and daily updates run as `,o,` — output, failures and all.`]:[`Switching one on creates the daily task that installs it and keeps it current.`]),r))}async function de(e,t,n){let r=v.find(t=>t.name===e);n(await V(H(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 fe(e,t){let n=++m,r=await i(`/api/config/resource${z(`&kind=${e}&name=${encodeURIComponent(t)}`)}`,`failed to load ${t}`,{cache:`no-store`});if(!r.ok){n===m&&Y(r.error);return}if(n!==m)return;let{content:o}=r.value,s=o.split(`
|
|
3
3
|
`);s.at(-1)===``&&s.pop();let c=await E(t);n===m&&L.replaceChildren(X(t,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`read-only`)),a(`div`,`min-h-0 flex-1 overflow-auto`,M(j(s),c)))}function pe(){N.replaceChildren(new Option(h?`Global (${h})`:`Global`,`global`),...t().map(e=>new Option(`${o(e)} — ${e}`,e))),[...N.options].some(e=>e.value===l)||(l=`global`),N.value=l}return s(e,()=>{pe(),te()},C)}var G=e=>`${e.provider}/${e.id}`,oe=[`hardest reasoning — architecture, gnarly debugging`,`long autonomous implementation runs`,`balanced default — implementation, review`,`cheap & fast — listings, extraction, simple checks`,`cross-vendor second opinion`];function K(){let e=[],t=[],n=!1,o=a(`span`,`text-[11.5px]`,``),s=_(`Save menu`,!0),c=a(`div`,`flex min-w-0 flex-col gap-2`),l=a(`div`,`flex items-center gap-2`),u=a(`div`,`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-6`);function m(){n=!0,d(o,`idle`,`unsaved changes`)}function g(t){let n=k(t.note??``);n.classList.remove(`w-full`),n.classList.add(`min-w-0`,`flex-1`),n.placeholder=`why this one — pick a preset or write your own`,n.setAttribute(`list`,`model-menu-notes`),n.oninput=()=>{t.note=n.value,m()};let r=O([[`thinking: model default`,``],...h.map(e=>[`thinking: ${C(e)}`,e])],t.thinking??``);r.classList.replace(`w-full`,`w-44`),r.classList.add(`flex-none`),r.onchange=()=>{r.value?t.thinking=r.value:delete t.thinking,m()};let i=_(`Remove`);i.classList.add(`flex-none`),i.onclick=()=>{e=e.filter(e=>e!==t),m(),y()};let o=a(`span`,`w-52 flex-none truncate font-mono text-[12px] text-neutral-700`,G(t));return o.title=G(t),a(`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`,o,r,n,i)}function v(){let n=t.filter(t=>!e.some(e=>G(e)===G(t))),r=O(n.map(e=>[G(e),G(e)]),n[0]?G(n[0]):``);r.classList.replace(`w-full`,`flex-1`),r.classList.add(`min-w-0`);let i=_(`+ Pin model`);i.classList.add(`flex-none`,`whitespace-nowrap`),i.disabled=n.length===0,i.onclick=()=>{let t=n.find(e=>G(e)===r.value);t&&(e.push({...t}),m(),y())},l.replaceChildren(r,i)}function y(){c.replaceChildren(...e.length?e.map(g):[D(`Nothing pinned — every picker shows the curated catalog as is.`)]),v()}async function b(){d(o,`saving`,`saving…`);let t=e.map(({provider:e,id:t,thinking:n,note:r})=>({provider:e,id:t,...n?{thinking:n}:{},...r?.trim()?{note:r.trim()}:{}})),i=await r(`/api/settings`,{modelMenu:t},`PUT`);if(!i.ok)return d(o,`failed`,await f(i,`Could not save`));e=(await i.json()).modelMenu,n=!1,d(o,`saved`,`Saved — agents see it on their next models call.`),y()}s.onclick=()=>void b();function x(){n||(async()=>{let[n,r]=await Promise.all([i(`/api/settings`,`Could not load the menu`),i(`/api/models`,`Could not load the model catalog`)]);if(!n.ok)return d(o,`failed`,n.error);e=n.value.modelMenu,t=r.ok?r.value:[],o.textContent=``,y()})()}let S=a(`datalist`,``);return S.id=`model-menu-notes`,S.append(...oe.map(e=>new Option(e))),u.append(p(`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.`,A(`Pinned models`,c,{hint:`The note is what an agent matches a task against — say when to reach for it, not what it is.`}),A(`Add`,l,{hint:`The list is the live catalog — only models that exist right now can be pinned.`}),a(`div`,`flex items-center gap-3`,s,o),S)),{el:u,load:x}}var q=(e,t)=>{let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`http:`&&n.protocol!==`https:`)return null;let r=a(`a`,`text-indigo-600 hover:underline`,t);return r.href=n.href,r.target=`_blank`,r.rel=`noreferrer`,r};function J(e,t,n,i){let o=document.createElement(`dialog`);o.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let s=a(`div`,`flex flex-col gap-2`),c=a(`div`,`flex flex-col gap-2`),u=a(`p`,`text-[12.5px] text-neutral-400`,`Starting…`),d=_(`Cancel`),p=(e,t)=>{u.className=`text-[12.5px] ${S[e]}`,u.textContent=t};o.append(a(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t),a(`div`,`flex max-h-[65vh] flex-col gap-3 overflow-y-auto px-4 py-3`,s,c,u),a(`div`,`flex justify-end border-t border-neutral-200 px-4 py-2.5`,d)),document.body.append(o),o.showModal();let m=e.id,h=e.state,g,v,y=new Set,b=!1,x=!1,C=async e=>{if(!x){if(e&&h===`running`){x=!0,d.disabled=!0;try{let e=await r(`/api/providers/flows/${m}/cancel`,{});if(!e.ok&&e.status!==404){p(`failed`,await f(e,`Could not cancel authentication flow`));return}}catch(e){p(`failed`,`Could not cancel authentication flow: ${String(e)}`);return}finally{x=!1,d.disabled=!1}}clearTimeout(g),o.close()}};d.onclick=()=>void C(!0),o.oncancel=e=>{e.preventDefault(),C(!0)},o.onclose=()=>{b=!0,clearTimeout(g),o.remove()};let w=e=>{if(e.type===`auth_url`){let t=a(`div`,`flex flex-col gap-1 text-[12.5px] text-neutral-600`);return e.instructions&&t.append(a(`p`,``,e.instructions)),t.append(q(e.url,`Open authorization page`)??a(`span`,`text-red-600`,`Invalid authorization URL`)),t}if(e.type===`device_code`){let t=a(`div`,`flex flex-col gap-2 text-[12.5px] text-neutral-600`);return t.append(a(`div`,`flex items-center gap-2`,a(`code`,`font-mono text-[17px] font-semibold text-neutral-800`,e.userCode),l(`btn text-[11px]`,()=>e.userCode))),t.append(q(e.verificationUri,`Open verification page`)??a(`span`,`text-red-600`,`Invalid verification URL`)),t}let t=a(`div`,`text-[12.5px] text-neutral-600`,e.message);if(e.type===`info`)for(let n of e.links??[]){let e=q(n.url,n.label??n.url);e&&t.append(` `,e)}return t},T=(e,t)=>{v=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=k(``,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 i=_(`Continue`,!0);i.type=`submit`;let o=a(`form`,`flex flex-col gap-2`,a(`label`,`text-[12.5px] font-medium text-neutral-700`,t.message),n,a(`div`,`flex justify-end`,i));o.onsubmit=a=>{a.preventDefault(),i.disabled=!0,(async()=>{try{let i=await r(`/api/providers/flows/${e.id}/respond`,{promptId:t.id,value:n.value});if(b)return;if(!i.ok){p(`failed`,await f(i,`Could not submit response`));return}y.add(t.id),v=void 0,c.replaceChildren(),p(`saving`,`Waiting for provider…`)}catch(e){b||p(`failed`,`Could not submit response: ${String(e)}`)}finally{i.disabled=!1}})()},c.replaceChildren(o),n.focus()},E=e=>{h=e.state,s.replaceChildren(...e.events.map(w));let t=e.prompt&&!y.has(e.prompt.id)?e.prompt:void 0;if(t?.id!==v&&(t?T(e,t):(v=void 0,c.replaceChildren())),e.state===`running`){p(`saving`,t?`Waiting for your response.`:`Waiting for provider…`);return}clearTimeout(g),c.replaceChildren(),e.state===`succeeded`?p(`saved`,`${n} configured.`):p(`failed`,e.state===`cancelled`?`Cancelled.`:e.error??`Authentication failed.`),d.textContent=`Close`,d.onclick=()=>void C(!1),e.state===`succeeded`&&i()},D=async()=>{if(!(b||h!==`running`))try{let e=await fetch(`/api/providers/flows/${m}`,{cache:`no-store`});if(b)return;if(!e.ok){p(`failed`,await f(e,`Authentication status unavailable`)),e.status===404?h=`failed`:g=setTimeout(()=>void D(),1e3);return}E(await e.json()),h===`running`&&(g=setTimeout(()=>void D(),500))}catch(e){if(b)return;p(`failed`,`Authentication status unavailable: ${String(e)}`),g=setTimeout(()=>void D(),1e3)}};E(e),h===`running`&&(g=setTimeout(()=>void D(),500))}var se=[`anthropic`,`openai`,`openai-codex`,`google`,`openrouter`,`deepseek`],Y=[[`OpenAI Chat Completions`,`openai-completions`],[`OpenAI Responses`,`openai-responses`],[`Anthropic Messages`,`anthropic-messages`],[`Google Generative AI`,`google-generative-ai`]],X=`__custom__`;async function ce(e){let t=_(`Add provider`,!0);t.classList.add(`ml-auto`);let n=a(`div`,`flex flex-none items-center gap-3 rounded-t-xl border-b border-neutral-200/70 bg-neutral-50/70 px-4 py-2`,a(`h2`,`text-[13px] font-semibold text-neutral-700`,`Providers`),t),o=a(`div`,`min-h-0 flex-1 overflow-y-auto`);e.replaceChildren(n,o);let s=[],c=``,l=async()=>{o.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Loading…`));try{let[e,n]=await Promise.all([i(`/api/providers`,`Could not load providers`,{cache:`no-store`}),i(`/api/models`,`the model catalog could not be read`,{cache:`no-store`})]);if(s=n.ok?n.value:[],c=n.ok?``:n.error,!e.ok){o.replaceChildren(D(e.error));return}let r=e.value;t.onclick=()=>Z(r,void 0,l),g(r)}catch(e){o.replaceChildren(D(`Could not load providers: ${String(e)}`))}},u=async e=>{if(window.confirm(`Remove the stored credential for ${e.name}?`))try{let t=await r(`/api/providers/${encodeURIComponent(e.id)}/logout`,{});if(!t.ok){window.alert(await f(t,`Could not remove credential`));return}await l()}catch(e){window.alert(`Could not remove credential: ${String(e)}`)}},p=e=>[...new Set([...(e.models??[]).map(e=>e.id),...s.filter(t=>t.provider===e.id).map(e=>e.id)])],m=(e,t)=>a(`div`,`flex flex-col gap-1`,a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),a(`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)),h=async(e,t)=>{try{let n=await r(`/api/providers/${encodeURIComponent(e)}/check`,{model:t});return n.ok?await n.json():await f(n,`Could not test`)}catch(e){return`Could not test: ${String(e)}`}},g=e=>{let t=e.filter(e=>e.configured);if(!t.length){o.replaceChildren(D(`No providers configured.`));return}o.replaceChildren(...t.map(t=>{let n=a(`div`,`min-w-0 flex-1`,a(`div`,`truncate text-[13px] font-medium text-neutral-700`,t.name),a(`div`,`truncate font-mono text-[11px] text-neutral-400`,t.id)),r=t.stored===`api_key`?`API key`:t.stored===`oauth`?`OAuth`:t.source??`configured`,i=t.endpoint??`Default endpoint`,o=a(`div`,`flex min-w-32 flex-col items-start gap-1`,b(`configured`,`bg-emerald-50 text-emerald-700 ring-emerald-200`),a(`span`,`max-w-48 truncate text-[11px] text-neutral-500`,r),a(`span`,`max-w-48 truncate text-[11px] text-neutral-400`,i));o.title=i;let s=a(`span`,`text-[11.5px]`,``),f=a(`div`,`hidden flex-col gap-2 px-4 pb-3`,s),g=a(`div`,`flex flex-wrap justify-end gap-1.5`),v=p(t);if(!v.length)d(s,`idle`,c||`No models to test: none are configured here.`),f.classList.replace(`hidden`,`flex`);else{let e=O([[`Model to test…`,``],...v.map(e=>[e,e])],``);e.classList.add(`max-w-52`,`text-[12px]`);let n=_(`Test`);n.disabled=!0,e.onchange=()=>n.disabled=!e.value,n.onclick=()=>{let r=e.value;n.disabled=!0,f.replaceChildren(s),f.classList.replace(`hidden`,`flex`),d(s,`saving`,`asking ${r}…`),h(t.id,r).then(e=>{if(n.disabled=!1,typeof e==`string`)return d(s,`failed`,e);d(s,e.ok?`saved`:`failed`,`${e.model} ${e.ok?`answered`:`did not answer`} in ${e.ms} ms`),f.append(m(`sent`,e.request||`(the request was never made)`),m(e.ok?`answered`:`replied`,e.response))})},g.append(e,n)}if(t.builtin||t.api&&t.models){let n=_(`Edit`);n.onclick=()=>Z(e,t,l),g.append(n)}if(t.stored){let e=_(`Remove credential`);e.onclick=()=>void u(t),g.append(e)}return a(`div`,`border-b border-neutral-100`,a(`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]`,n,o,g),f)}))};await l()}function le(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`,se.flatMap(e=>n.filter(t=>t.id===e))),r(`More providers`,n.filter(e=>e.builtin&&!se.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…`,X))}function Z(e,n,i){let o=document.createElement(`dialog`);o.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let s=document.createElement(`select`);s.className=`${g} select`,n||le(s,e);let c=k(),l=k(),u=k(),d=document.createElement(`select`);d.className=`${g} select`,d.append(...Y.map(([e,t])=>new Option(e,t)));let p=t(``,4);p.placeholder=`model-id
|
|
4
4
|
another-model-id`;let m=document.createElement(`input`);m.type=`checkbox`;let h=document.createElement(`select`);h.className=`${g} select`;let v=a(`div`,`flex flex-col gap-4`),y=a(`span`,`text-[11.5px] text-red-600`,``),b=_(`Cancel`),x=_(n?`Save`:`Add`,!0);x.type=`submit`;let S=()=>n??e.find(e=>e.id===s.value),C=()=>{let e=S(),t=e?!e.builtin:s.value===X;c.value=e?.id??``,c.disabled=n!==void 0,l.value=e?.name??``,u.value=e?.endpoint??``,d.value=e?.api??`openai-completions`,p.value=e?.models?.map(e=>e.id).join(`
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{H as e,I as t,L as n,g as r,k as i,m as a,v as o}from"./index-
|
|
1
|
+
import{H as e,I as t,L as n,g as r,k as i,m as a,v as o}from"./index-BmKvoulH.js";var s=e=>e===null?`-`:new Date(e).toLocaleString(),c=e=>e.startedAt===null?`-`:t((e.finishedAt??Date.now())-e.startedAt),l=e=>e.state===`succeeded`&&e.matched===!1?`No match`:e.state,u={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 d(e){let t=l(e);return a(t,t===`No match`?u.skipped:u[e.state],e.state===`running`?`animate-pulse bg-sky-500`:void 0)}function f(e){return e.archived?a(`Archived`,`bg-neutral-50 text-neutral-400 ring-neutral-200`):e.trigger.type===`manual`?a(`Manual`,`bg-neutral-100 text-neutral-600 ring-neutral-200`):e.enabled?a(`Enabled`,`bg-emerald-50 text-emerald-700 ring-emerald-200`):a(`Paused`,`bg-amber-50 text-amber-700 ring-amber-200`)}var p=`px-4 pt-4 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,m=`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`,h=e=>e.trigger.type===`manual`?`Manual`:e.trigger.type===`cron`?`${e.trigger.expression} (${e.trigger.timezone})`:`Every ${e.trigger.intervalSeconds}s · ${e.trigger.mode}`,g=e=>e.action.type===`agent`?`Agent · ${e.action.session.mode}`:e.action.type===`bash`?`Bash`:e.action.type===`system`?`System`:`Task`;function _(e,t){let i=n(`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)]`),a=[[`Status`,e.archived?`Archived`:e.trigger.type===`manual`?`Manual`:e.enabled?`Enabled`:`Paused`],[`Trigger`,h(e)],[`Action`,g(e)],[`Timeout`,`${e.timeoutSeconds}s`],[`Next run`,s(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`&&(a.push([`Session policy`,e.action.session.mode]),e.action.session.mode===`reuse`&&a.push([`Session`,e.action.session.sessionId]),`cwd`in e.action.session&&a.push([`Directory`,e.action.session.cwd]),e.action.launch?.model&&a.push([`Model`,`${e.action.launch.model.provider}/${e.action.launch.model.id}`]),e.action.launch?.thinking&&a.push([`Thinking`,e.action.launch.thinking]),a.push([`Prompt`,e.action.prompt])),e.action.type===`bash`&&a.push([`Directory`,e.action.cwd],[`Script`,e.action.script]),e.action.type===`task`&&a.push([`Target task`,e.action.taskId]),e.action.type===`system`&&a.push([`System action`,e.action.name]),e.trigger.type===`watch`&&a.push([`Probe`,e.trigger.script]);for(let[e,t]of a)i.append(n(`span`,`pt-px text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),n(`pre`,`whitespace-pre-wrap break-words font-mono text-[12.5px] leading-snug`,t));if(e.action.type===`agent`&&e.action.session.mode===`reuse`){let{sessionId:a}=e.action.session,o=r(`Open session`);o.onclick=()=>t(a),i.append(n(`span`,``,``),o)}return i}function v(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 y(e,t,r,i){let a=n(`div`,`divide-y divide-neutral-100`);for(let e of t){let t=n(`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]`);t.setAttribute(`type`,`button`),t.append(n(`span`,`flex`,d(e)),n(`span`,`truncate text-neutral-500`,s(e.queuedAt)),n(`span`,`text-neutral-500`,e.triggerSource),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400`,c(e))),t.onclick=()=>r(e.id),a.append(t)}t.length||a.append(n(`div`,`p-4`,o(`No runs yet.`))),e.replaceChildren(a),e.scrollTop=i.top,e.onscroll=()=>{i.top=e.scrollTop}}var b=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 x(t,a,o,l,u){let f=String(Number(t.dataset.runRequest??0)+1);t.dataset.runRequest=f,t.onscroll=()=>{u.scrollTop=t.scrollTop};let h=r(`Runs`);h.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,h.onclick=()=>{u.selectedId=null,u.scrollTop=0,o()};let g=i(h,n(`span`,`text-neutral-400`,`›`),n(`span`,`min-w-0 truncate font-mono text-[12px] text-neutral-500`,a)),x=t.dataset.runId!==a;x&&(t.dataset.runId=a,t.replaceChildren(g,n(`p`,`p-4 text-[13px] text-neutral-500`,`Loading run...`)));let[S,C]=await Promise.all([e(`/api/task-runs/${a}`,`Could not load the run`),e(`/api/task-runs/${a}/messages`,`Could not load the run's messages`)]);if(!t.isConnected||t.dataset.runRequest!==f||u.selectedId!==a)return;if(!S.ok){let r=await e(`/api/task-groups/${a}`,S.error);if(!t.isConnected||t.dataset.runRequest!==f||u.selectedId!==a)return;if(u.drawn=``,!r.ok){t.replaceChildren(g,n(`p`,`p-4 text-[13px] text-red-600`,S.error));return}let{group:i,members:o}=r.value,s=n(`div`,`min-w-0`);t.replaceChildren(g,n(`div`,`border-b border-neutral-100 bg-neutral-50/60 px-4 py-3 text-[12.5px] text-neutral-600`,[`Task group \u00b7 join ${i.join}`,`${String(o.length)} runs`,i.callbackState?`callback ${i.callbackState}`:``].filter(Boolean).join(` · `)),s),y(s,o,l.openRun,{top:0});return}let w=S.value,T=C.ok?C.value:[],E=JSON.stringify([w,C]);if(!x&&u.drawn===E)return;if(u.drawn=E,w.targetSessionId){let e=r(`Open session`);e.classList.add(`ml-auto`),e.onclick=()=>l.openSession(w.targetSessionId),g.append(e)}if(w.state===`queued`||w.state===`running`){let e=r(`Stop run`);e.onclick=()=>{window.confirm(`Stop this run of "${w.context.definition.name}"?`)&&l.mutate(`/api/task-runs/${w.id}/cancel`)},g.append(e)}let D=n(`div`,`min-w-0`),O=v(w);D.append(n(`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]`,n(`span`,`flex items-center gap-2`,d(w),n(`span`,`font-medium`,w.context.definition.name)),...O?[n(`span`,`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 ring-1 ring-amber-200`,O)]:[],n(`span`,`text-neutral-500`,s(w.queuedAt)),n(`span`,`text-neutral-500`,w.triggerSource),n(`span`,`font-mono text-[11.5px] text-neutral-400`,c(w))));let k=n(`div`,`flex flex-wrap items-center gap-2 border-b border-neutral-100 px-4 py-3 text-[12px]`),A=(e,t)=>{let n=r(e);n.classList.add(`max-w-full`,`break-all`,`!whitespace-normal`),n.onclick=t,k.append(n)};if(w.context.definition.kind===`task`&&A(`Task: ${w.context.definition.name}`,()=>l.openTask(w.taskId)),w.parentRunId&&A(`Parent: ${w.parentRunId}`,()=>l.openRun(w.parentRunId)),w.resumedFromRunId&&A(`Resumed from: ${w.resumedFromRunId}`,()=>l.openRun(w.resumedFromRunId)),w.result?.type===`task`){let e=w.result.runId;A(`Child result: ${e}`,()=>l.openRun(e))}w.groupId&&k.append(n(`span`,`break-all font-mono text-[11.5px] text-neutral-500`,`Group: ${w.groupId}`)),D.append(k);for(let e of[w.error,w.skipReason,w.callbackError])e&&D.append(n(`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(w.result){let e=w.result,t=e.type===`agent`||e.type===`system`?e.text:e.type===`bash`?b(e):e.type===`task`?`Child run: ${e.runId}`:`Watch did not match.`;D.append(n(`h3`,p,`Result`),n(`pre`,m,t||`No output.`))}w.probe&&D.append(n(`h3`,p,`Watch probe: ${w.matched===null?`not evaluated`:w.matched?`matched`:`not matched`}`),n(`pre`,m,b(w.probe)));let j=n(`details`,`border-t border-neutral-200`);if(j.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,n(`span`,`chev`,`▶`),`Configuration snapshot (revision ${w.taskRevision})`),_(w.context.definition,l.openSession)),D.append(j),C.ok||D.append(n(`p`,`m-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-[12.5px] text-red-700`,C.error)),T.length){let e=n(`div`,`mt-2 divide-y divide-neutral-100 border-t border-neutral-100`);for(let t of T){let r=n(`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(n(`span`,`font-medium`,t.kind),n(`span`,`text-neutral-500`,t.state),n(`span`,`col-span-2 whitespace-pre-wrap break-words md:col-span-1`,t.content)),t.error&&r.append(n(`span`,`col-span-2 break-words text-red-600 md:col-span-3`,t.error)),e.append(r)}D.append(n(`div`,`border-t border-neutral-200`,n(`div`,p,`Messages`),e))}let M=n(`details`,`border-t border-neutral-200`);M.open=u.rawOpen,M.ontoggle=()=>{M.isConnected&&(u.rawOpen=M.open)},M.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,n(`span`,`chev`,`▶`),`Raw record`),n(`pre`,m,JSON.stringify(w,null,2))),D.append(M),t.replaceChildren(g,D),t.scrollTop=u.scrollTop,t.onscroll=()=>{u.scrollTop=t.scrollTop}}export{y as a,c,x as i,f as l,s as n,v as o,_ as r,d as s,g as t,h as u};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,C as t,D as n,G as r,H as i,L as a,N as o,V as s,W as c,c as l,f as u,g as d,k as f,l as p,m,q as h,v as g,w as _,x as v,y}from"./index-
|
|
1
|
+
import{B as e,C as t,D as n,G as r,H as i,L as a,N as o,V as s,W as c,c as l,f as u,g as d,k as f,l as p,m,q as h,v as g,w as _,x as v,y}from"./index-BmKvoulH.js";import{a as b,c as x,l as S,n as C,r as w,s as T,t as E,u as D}from"./task-runs-BW06ZEVz.js";function O(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 k(e,t){let r=document.createElement(`dialog`);r.className=`m-auto w-[38.75rem] max-w-[94vw] rounded-lg border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20`;let i=document.createElement(`form`);i.className=`flex max-h-[88vh] flex-col`;let o=a(`span`,`mr-auto text-[12px] text-red-600`),s=a(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,t?`Edit task`:`New task`),c=a(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),u=v(t?.name??``);u.required=!0;let f=v(t?.description??``),m=v(String(t?.timeoutSeconds??900),`number`);m.min=`1`,m.max=`86400`;let g=_([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],t?.trigger.type??`manual`),b=_([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],t?.action.type??`bash`),x=_([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],t?.callback.type??`none`),S=t?.callback.type===`session`?t.callback.sessionId:null,C=_(O(e.sessions(),S),S??``),w=y(`Callback session`,C);w.classList.toggle(`hidden`,x.value!==`session`),x.onchange=()=>w.classList.toggle(`hidden`,x.value!==`session`),c.append(y(`Name`,u),y(`Description`,f),y(`Trigger`,g),y(`Action`,b),y(`Callback`,x),w,y(`Timeout (seconds)`,m));let T=a(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);c.append(T);let E=()=>{T.replaceChildren();let s,c,d,S,w,E;if(g.value===`cron`)s=v(t?.trigger.type===`cron`?t.trigger.expression:`0 9 * * *`),c=v(t?.trigger.type===`cron`?t.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),T.append(y(`Cron`,s),y(`Timezone`,c));else if(g.value===`watch`){d=n(t?.trigger.type===`watch`?t.trigger.script:``,4),E=v(t?.trigger.type===`watch`?t.trigger.cwd:e.sessions()[0]?.cwd??``),S=v(String(t?.trigger.type===`watch`?t.trigger.intervalSeconds:60),`number`),w=_([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],t?.trigger.type===`watch`?t.trigger.mode:`repeat`);let r=y(`Probe script (0=match, 1=no match)`,d);r.classList.add(`col-span-2`),T.append(r,y(`Probe directory`,E),y(`Interval (seconds)`,S),y(`Mode`,w))}let D,k,j,M,N,P,F,I,L,R;if(b.value===`bash`){k=v(t?.action.type===`bash`?t.action.cwd:e.sessions()[0]?.cwd??``),D=n(t?.action.type===`bash`?t.action.script:``,6);let r=y(`Bash script`,D);r.classList.add(`col-span-2`),T.append(y(`Working directory`,k),a(`span`,``),r)}else if(b.value===`agent`){let r=e.sessions(),i=t?.action.type===`agent`?t.action:null,a=i?.session.mode===`reuse`?i.session.sessionId:``,o=O(r,a||null);j=_([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`]],i?.session.mode===`reuse`?`reuse`:`fresh`),M=_(o,a||o[0]?.[1]||``);let s=i&&`cwd`in i.session?i.session.cwd??``:``;N=v(s||r[0]?.cwd||``),P=n(i?.prompt??``,6),F=_([[`Project default`,``],...l.map(e=>[h(e),e])],i?.launch?.thinking??``),I=v(i?.launch?.model?.provider??``),L=v(i?.launch?.model?.id??``);let c=y(`Session`,M),u=y(`Child directory`,N),d=[y(`Thinking`,F),y(`Model provider (optional)`,I),y(`Model id (optional)`,L)],f=()=>{let e=j?.value===`reuse`;c.classList.toggle(`hidden`,!e),u.classList.toggle(`hidden`,e);for(let t of d)t.classList.toggle(`hidden`,e)};j.onchange=f,f();let p=y(`Prompt`,P);p.classList.add(`col-span-2`),T.append(y(`Session policy`,j),c,u,...d,p)}else R=_(e.tasks().filter(e=>e.id!==t?.id&&!e.archived).map(e=>[e.name,e.id]),t?.action.type===`task`?t.action.taskId:``),T.append(y(`Target task`,R));i.onsubmit=n=>{n.preventDefault();let i=g.value===`manual`?{type:`manual`}:g.value===`cron`?{type:`cron`,expression:s.value,timezone:c.value}:{type:`watch`,script:d.value,cwd:E.value,intervalSeconds:Number(S.value),mode:w.value},a=b.value===`agent`&&j.value!==`reuse`?{...p(F.value)?{thinking:F.value}:{},...I.value.trim()&&L.value.trim()?{model:{provider:I.value.trim(),id:L.value.trim()}}:{}}:void 0,l=b.value===`bash`?{type:`bash`,cwd:k.value,script:D.value}:b.value===`agent`?{type:`agent`,prompt:P.value,session:j.value===`reuse`?{mode:`reuse`,sessionId:M.value}:{mode:`fresh`,cwd:N.value},...a?{launch:a}:{}}:{type:`task`,taskId:R.value},h=x.value===`origin`?{type:`origin`}:x.value===`session`?{type:`session`,sessionId:C.value}:{type:`none`},_={name:u.value,description:f.value,trigger:i,action:l,callback:h,timeoutSeconds:Number(m.value)};o.textContent=``,A(t?.id,_,r,o,e.onSaved)}};g.onchange=E,b.onchange=E,E();let D=d(`Cancel`);D.onclick=()=>r.close();let k=d(`Save`,!0);k.type=`submit`;let j=a(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);j.append(o,D,k),i.append(s,c,j),r.append(i),r.addEventListener(`close`,()=>r.remove()),document.body.append(r),r.showModal(),u.focus()}async function A(e,t,n,i,a){let o=await r(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!o.ok){i.textContent=(await o.json()).error??`Task save failed`;return}let s=await o.json(),c=`task`in s?s.task:s;n.close(),a(c.id)}function j(n,l,p,h,v,y,O){let A=[],j=[],M=null,N=`active`,P=`all`,F=``,I=`runs`,L={top:0},R=0,z=0,B=``,V=e(async()=>{if(M||!$.visible)return;let e=R,t=`${N}:${P}`,n=await i(`/api/tasks?state=${N}&kind=task`,`Failed to load tasks`);if(!$.visible||e!==R||t!==`${N}:${P}`)return;if(!n.ok)return B=``,W(n.error);let r=JSON.stringify(n.value);t+r!==B&&(B=t+r,A=n.value,P!==`all`&&(A=A.filter(e=>e.trigger.type===P)),X())}),H=e(async()=>{M&&$.visible&&await ne(M)});function U(){return M?H():V()}function W(e){n.querySelector(`[role=alert]`)?.remove();let t=a(`p`,`flex-none p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),n.append(t)}async function G(){let e=M,t=await i(`/api/tasks?state=active`,`Failed to load tasks`);return!t.ok&&$.visible&&M===e&&W(t.error),t.ok?t.value:j}let K={sessions:l,tasks:()=>j,onSaved:e=>{J(e),I=`definition`,O(e)}},q=(e,t)=>f(...e,a(`div`,`ml-auto flex flex-wrap items-center gap-2 max-md:w-full`,...t));function J(e){M=e,R++,I=`runs`,L.top=0}function Y(){M=null,R++,X()}function X(){let e=d(`New task`,!0);e.onclick=()=>{!$.visible||M!==null||Promise.all([p(),G()]).then(([,e])=>{!$.visible||M!==null||(j=e,k(K))})};let t=[],r=(e,n,r,i)=>{let a=_(n,r);a.setAttribute(`aria-label`,e),a.classList.add(`!w-auto`,`pr-8`),a.onchange=()=>{i(a.value),z=0,U()},t.push(a)},i=a(`input`,`${u} !w-48 max-md:!w-full`);i.type=`search`,i.placeholder=`Search tasks`,i.setAttribute(`aria-label`,`Search tasks`),i.value=F,i.oninput=()=>{F=i.value,c()},t.push(i),r(`Status`,[[`Current`,`active`],[`Archived`,`archived`]],N,e=>{N=e}),r(`Trigger`,[[`All triggers`,`all`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`]],P,e=>{P=e});let o=document.createElement(`table`);o.className=`w-full table-fixed text-left text-[12.5px]`,o.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 s=document.createElement(`tbody`),c=()=>{let e=A.filter(e=>`${e.name} ${e.description??``}`.toLowerCase().includes(F.toLowerCase()));s.replaceChildren(...e.map(ee)),l.classList.toggle(`hidden`,e.length>0)};o.append(s);let l=a(`div`,`p-4`,g(`No matching tasks.`)),f=a(`div`,`min-h-0 flex-1 overflow-auto`,o,l);c(),f.onscroll=()=>{z=f.scrollTop},n.replaceChildren(q(t,[e]),f),f.scrollTop=z}function ee(e){let t=document.createElement(`tr`);t.className=`cursor-pointer border-b border-neutral-100 transition-colors hover:bg-neutral-50`,t.onclick=()=>O(e.id);let n=d(e.name);n.className=`min-w-0 cursor-pointer truncate text-left font-medium text-neutral-800`,n.title=e.name,t.append(a(`td`,`py-2.5 pl-4 pr-2`,a(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,n,S(e),...te(e)),a(`div`,`truncate text-[11px] text-neutral-400`,e.description||``),a(`div`,`truncate text-[11px] text-neutral-400 md:hidden`,D(e))));for(let n of[E(e),D(e),C(e.nextRunAt)]){let e=a(`td`,`hidden truncate px-2 py-2.5 text-neutral-600 md:table-cell`,n);e.title=n,t.append(e)}t.append(a(`td`,`px-2 py-2.5`,e.lastRun?a(`div`,`flex`,T(e.lastRun)):a(`div`,`text-neutral-400`,`–`),a(`div`,`mt-0.5 font-mono text-[11px] text-neutral-400`,e.lastRun?x(e.lastRun):``)));let r=d(`Run now`);return r.disabled=e.archived,r.onclick=t=>{t.stopPropagation(),Z(e.id)},t.append(a(`td`,`px-2 py-1 text-right`,r)),t}function te(e){if(!e.createdBySessionId)return[];let t=m(`agent`,`bg-violet-50 text-violet-700 ring-violet-200`);return t.title=`Created by session ${e.createdBySessionId}`,[t]}async function ne(e){let r=++R,o=n.querySelector(`[data-task-detail]`),[s,c]=await Promise.all([i(`/api/tasks/${e}`,`Failed to load task`),i(`/api/tasks/${e}/runs`,`Failed to load the task's runs`)]);if(!$.visible||r!==R||M!==e)return;if(!s.ok)return W(s.error);if(!c.ok)return W(c.error);let l=s.value,u=c.value,m=d(`Tasks`);m.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,m.onclick=()=>O();let g=a(`span`,`flex min-w-0 items-center gap-2`,m,a(`span`,`text-neutral-400`,`›`),a(`span`,`truncate font-medium`,l.name),S(l)),_=d(`Run now`,!0);_.disabled=l.archived,_.onclick=()=>void Z(l.id);let v=d(l.enabled?`Pause schedule`:`Resume schedule`);v.disabled=l.archived||l.action.type===`system`||l.trigger.type===`manual`,v.onclick=()=>void Q(`/api/tasks/${l.id}/${l.enabled?`pause`:`resume`}`);let x=d(`Edit`);x.disabled=l.archived||l.action.type===`system`,x.onclick=()=>{!$.visible||M!==l.id||Promise.all([p(),G()]).then(([,e])=>{!$.visible||M!==l.id||(j=e,k(K,l))})};let C=d(`Archive`);C.disabled=l.archived||l.action.type===`system`,C.onclick=()=>void Q(`/api/tasks/${l.id}/archive`);let T=f(),E=a(`div`,`min-h-0 flex-1 overflow-auto`);E.dataset.taskDetail=e;let D=d(`All runs`);D.onclick=()=>y({taskId:l.id});let A=()=>{T.replaceChildren(t([[`Recent runs (${u.length})`,`runs`],[`Definition`,`definition`]],I,e=>{I=e,A()}),a(`span`,`ml-auto`,D)),I===`runs`?b(E,u,e=>y({},e),L):(E.onscroll=null,E.replaceChildren(w(l,h)))},N=o?.scrollTop??0;n.replaceChildren(q([g],[_,...l.trigger.type===`manual`?[]:[v],x,C]),T,E),A(),E.scrollTop=N}async function Z(e){try{let t=await r(`/api/tasks/${e}/run`,{sourceSessionId:v()});if(!t.ok)return W(await s(t,`Failed to run task`));y({},(await t.json()).runId)}catch(e){W(`Failed to run task: ${String(e)}`)}}async function Q(e){let t=await c(e,`POST`,`Task update failed`);if(t)return W(t);await U()}let $=o(n,e=>{e&&e!==M&&J(e),e||Y(),n.childElementCount||X(),U()});return Object.assign($,{refresh(e){$.visible&&(!M||!e||M===e)&&U()}})}export{j as createTasksView};
|
|
Binary file
|
|
Binary file
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
which style.css pays for with the safe-area inset. -->
|
|
34
34
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
35
35
|
<title>Pier</title>
|
|
36
|
-
<script type="module" crossorigin src="/assets/index-
|
|
36
|
+
<script type="module" crossorigin src="/assets/index-BmKvoulH.js"></script>
|
|
37
37
|
<link rel="stylesheet" crossorigin href="/assets/index-CZeL3DfU.css">
|
|
38
38
|
</head>
|
|
39
39
|
<!-- The document never scrolls: this is a fixed-viewport workbench, and every
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|