@pi-outpost/embed 0.59.1 → 0.60.0

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.
@@ -702,7 +702,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
702
702
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
703
703
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
704
704
  SOFTWARE.
705
- `,ki=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`GrapesJS`,`Poster editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],Ai=[{name:`pi-outpost`,license:`MIT`,text:Oi},...Di];function ji(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(null);return(0,i.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,o.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),Ai.map(e=>(0,o.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,o.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,o.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsxs)(`section`,{className:`pb-5`,children:[(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,o.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,o.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,o.jsx)(`dl`,{className:`mt-3 space-y-3`,children:ki.map(([e,t])=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,o.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function Mi(e){if(e.removed)return`removed — still running until pi-outpost restarts`;if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function Ni(e){let t=e.trim().replace(/^npm:/,``),n=t.lastIndexOf(`@`);return n>0?{name:t.slice(0,n),version:t.slice(n+1)}:{name:t}}var Pi=e=>`${e.scope}:${e.name}`,Fi=(e,t)=>e===`user`?`all projects`:`the ${t} project`,Ii=`w-16 shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,Li=`w-16 shrink-0 rounded border border-transparent px-1.5 py-0.5 text-zinc-600 hover:bg-zinc-100 hover:text-red-700 disabled:opacity-50 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-red-400`,Ri=`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,zi=`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,Bi=`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,Vi=()=>(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`${Ii} invisible`,children:`Update`});function Hi({packages:e,update:t,locked:n,onCheck:r,onUpdate:a,edits:s}){let[c,l]=(0,i.useState)(null);if(e===null||e.length===0&&!s)return null;let u=t?.status===`pending`?t.source:null,d=s?.change??null,f=d?.status===`pending`?d:null,p=u!==null||f!==null||s?.lookup?.status===`pending`,m=!n&&s!==void 0;function h(e){if(u===e.source&&e.check?.state===`newer`)return{text:`updating to ${e.check.latest}…`,warn:!1};if(f&&f.key===Pi(e)){if(f.action===`remove`)return{text:`removing…`,warn:!1};if(f.action===`restore`)return{text:`reinstalling ${e.loaded??``}…`,warn:!1}}return t&&t.status!==`pending`&&t.status!==`installed`&&t.source===e.source?{text:t.message,warn:!0}:d&&(d.status===`failed`||d.status===`refused`)&&d.key===Pi(e)&&d.action!==`install`?{text:d.message,warn:!0}:{text:Mi(e),warn:!1}}return(0,o.jsxs)(`div`,{className:`mt-3 text-xs`,"data-testid":`pi-packages`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),e.length>0&&(0,o.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),e.length===0&&(0,o.jsx)(`p`,{className:`text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-packages-empty`,children:`No packages installed`}),(0,o.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=Pi(e),r=e.check?.state===`newer`&&!e.restartNeeded&&!e.removed?e.check.latest:void 0,i=c?.key===t?c.kind:null,{text:u,warn:d}=h(e);return(0,o.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium ${e.removed?`text-zinc-400 line-through dark:text-zinc-500`:`text-zinc-700 dark:text-zinc-200`}`,title:e.source,children:e.name}),!n&&(r?(0,o.jsx)(`button`,{type:`button`,disabled:p||i!==null,onClick:()=>l({kind:`update`,key:t}),className:Ii,children:`Update`}):(0,o.jsx)(Vi,{})),m&&(e.removed?(0,o.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>s.onRestore(e),className:Ii,title:`Put ${e.name} back as it was`,children:`Undo`}):(0,o.jsx)(`button`,{type:`button`,disabled:p||i!==null,onClick:()=>l({kind:`remove`,key:t}),className:Li,"aria-label":`Remove ${e.name}`,children:`Remove`}))]}),(0,o.jsxs)(`div`,{className:`truncate ${d?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,title:u,children:[e.scope===`project`&&(0,o.jsx)(`span`,{children:`this project · `}),(0,o.jsx)(`span`,{"data-testid":`pi-package-status`,children:u})]}),r&&i===`update`&&(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{l(null),a(e.source)},className:zi,children:[`Install `,r]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:Bi,children:`Cancel`})]})]}),s&&i===`remove`&&(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`Removes `,e.name,` from `,e.scope===`user`?`the agent's settings (all projects)`:`the ${s.projectName} project's settings`,` `,`and uninstalls it. The agent keeps running it until pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{l(null),s.onRemove(e)},className:zi,children:`Remove`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:Bi,children:`Cancel`})]})]})]},`${t}:${e.source}`)})}),m&&(0,o.jsx)(Ui,{edits:s,busy:p},s.projectName)]})}function Ui({edits:e,busy:t}){let[n,r]=(0,i.useState)(!1),[a,s]=(0,i.useState)(``),[c,l]=(0,i.useState)(`user`),u=(0,i.useRef)(null),{lookup:d,change:f}=e,p=f?.status===`pending`&&f.action===`install`?f:null,m=f&&f.action===`install`&&(f.status===`failed`||f.status===`refused`)?f.message:null,h=Ni(a),g=d&&d.name===h.name&&d.version===h.version&&d.scope===c?d:null;(0,i.useEffect)(()=>{f?.action===`install`&&f.status===`installed`&&(r(!1),s(``),l(`user`))},[f]),(0,i.useEffect)(()=>{n&&g?.status!==`found`&&u.current?.focus()},[n,g?.status]);let _=()=>{r(!1),s(``),l(`user`),e.onCloseLookup()};if(p)return(0,o.jsxs)(`p`,{className:`mt-1 text-zinc-500 dark:text-zinc-400`,role:`status`,children:[`installing `,p.key.slice(p.key.indexOf(`:`)+1),`…`]});if(!n)return(0,o.jsxs)(o.Fragment,{children:[m&&(0,o.jsx)(`p`,{className:`mt-1 text-amber-700 dark:text-amber-400`,role:`alert`,children:m}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(!0),className:`mt-1 text-zinc-500 underline hover:text-zinc-800 disabled:opacity-50 dark:hover:text-zinc-200`,children:`Add a package`})]});if(g?.status===`found`)return(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-add-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This installs code that runs with the agent's privileges: `,g.name,` `,g.resolved,g.version===void 0?``:` (pinned)`,`, for `,Fi(g.scope,e.projectName),`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>e.onInstall(g.name,g.version,g.scope,g.resolved),className:zi,children:[`Install `,g.name]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>e.onCloseLookup(),className:Bi,children:`Cancel`})]})]});let v=g?g.status===`refused`?g.message:null:m;return(0,o.jsxs)(`form`,{className:`mt-1 rounded border border-zinc-200 p-2 dark:border-zinc-700`,onSubmit:n=>{n.preventDefault(),h.name&&!t&&e.onLookup(h.name,h.version,c)},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),_())},children:[(0,o.jsx)(`label`,{className:`block text-zinc-600 dark:text-zinc-400`,htmlFor:`pi-package-name`,children:`npm package`}),(0,o.jsx)(`input`,{id:`pi-package-name`,ref:u,value:a,onChange:e=>s(e.target.value),disabled:g?.status===`pending`,autoComplete:`off`,spellCheck:!1,placeholder:`openlore, @scope/name or name@1.2.3`,className:`mt-0.5 w-full rounded border border-zinc-300 bg-white px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-blue-400 dark:border-zinc-600 dark:bg-zinc-800`}),(0,o.jsxs)(`fieldset`,{className:`mt-2 flex flex-wrap gap-x-3 text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`legend`,{className:`sr-only`,children:`Install for`}),(0,o.jsxs)(`label`,{children:[(0,o.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:c===`user`,onChange:()=>l(`user`)}),` all projects`]}),(0,o.jsxs)(`label`,{children:[(0,o.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:c===`project`,onChange:()=>l(`project`)}),` this project only (`,e.projectName,`)`]})]}),(0,o.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:_,className:`rounded px-2 py-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-700`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`submit`,disabled:t||!h.name,className:Ii.replace(`w-16 `,``),children:`Install…`})]}),(0,o.jsx)(`p`,{className:`mt-1 min-h-[1rem] ${v?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,role:v?`alert`:`status`,children:v??(g?.status===`pending`?`looking up ${g.name}…`:``)})]})}function Wi({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[a,s]=(0,i.useState)(!1);return e.length===0?null:(0,o.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,o.jsxs)(`p`,{children:[`Waiting on a restart to take effect: `,e.join(`, `),`.`]}),t?n?(0,o.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):a?(0,o.jsxs)(`div`,{className:`mt-1`,children:[(0,o.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var Gi=30,Ki={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function qi({skills:e,groups:t,enabled:n,onChange:r,disabled:a=!1,bound:s}){let[c,l]=(0,i.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[u,d]=(0,i.useState)(``),[f,p]=(0,i.useState)(!1),m=u.trim().toLocaleLowerCase(),h=m!==``||f,g=e=>(!f||n.has(e.relativePath))&&(!m||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(m)),_=new Map;for(let t of e)_.set(t.group,[..._.get(t.group)??[],t]);let v=e.filter(e=>n.has(e.relativePath)).length,y=h?e.filter(g).length:e.length,b=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},x=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},S=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,v,` of `,e.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:a||v===e.length,onClick:()=>b(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,disabled:a||v===0,onClick:()=>b(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:s.kind===`count`?`This repository holds more skills than the ${s.limit} listed here.`:`Folders deeper than ${s.limit} levels were not searched for skills.`}):null,e.length>0?(0,o.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:u,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,o.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${f?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,v,`)`]})]}):null,!h&&v>0&&v<=Gi?(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,o.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,o.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,o.jsx)(Ji,{skill:e,checked:!0})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:a,onClick:()=>x(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,h&&y===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:f&&!m?`No skill is on.`:`No skill matches.`}):null,(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=_.get(e.path)??[],r=h?t.filter(g):t;if(h&&r.length===0)return null;let i=r.filter(e=>n.has(e.relativePath)).length,s=h||c.has(e.path);return(0,o.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,o.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>S(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,o.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[i,`/`,r.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,o.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:a||i===r.length,onClick:()=>b(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:a||i===0,onClick:()=>b(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,o.jsx)(`li`,{children:(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${a?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:a,onChange:()=>x(e.relativePath),className:`mt-0.5`}),(0,o.jsxs)(`span`,{className:`min-w-0`,children:[(0,o.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,o.jsx)(`span`,{title:e.description,style:Ki,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,o.jsx)(Ji,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function Ji({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,o.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,o.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function Yi(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function Xi(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function Zi(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function Qi(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var $i={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ea(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function ta(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function na(e){let t=ta(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function ra(e,t){let n=ta(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${ta(e)}/${i||`agent-resources`}`}function ia({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,o.jsxs)(`span`,{children:[e,`s`]}),(0,o.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,o.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function aa({preview:e,busy:t,error:n,onApply:r,onCancel:a}){let[s,c]=(0,i.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(()=>new Set),p=e.mode===`collection`,m=(0,i.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),h=(0,i.useMemo)(()=>Yi(e.skills,e.repositoryName),[e.skills,e.repositoryName]),g=e.roots.filter(e=>e.kind===`extension`&&s.has(`extension:${e.path}`)),_=g.length>0&&!l,v=t||!p&&s.size===0||_,y=()=>{let t=g.map(e=>e.path);p?r([],t,[...d]):r(e.roots.filter(e=>e.kind===`skill`&&s.has(`skill:${e.path}`)).map(e=>e.path),t)},b=e=>{u(!1),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,o.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:v,onClick:y,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),_?(0,o.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,p?(0,o.jsx)(qi,{skills:m,groups:h,enabled:d,onChange:f,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:s.has(t),disabled:e.locked,onChange:()=>b(t)}),(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,o.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),g.length>0?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function oa(e){let t=(0,i.useRef)(null),n=(0,i.useRef)(e.onClose),r=(0,i.useRef)(!1),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(`all`),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(`skill`),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)(!1),[w,T]=(0,i.useState)(``),[E,D]=(0,i.useState)(``),[O,k]=(0,i.useState)(!1),[A,j]=(0,i.useState)(``),[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)({}),[I,ee]=(0,i.useState)(null),[L,R]=(0,i.useState)(null),te=(0,i.useMemo)(()=>ea(e.inventory),[e.inventory]),z=(0,i.useMemo)(()=>{let e=c.trim().toLocaleLowerCase();return te.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=u===`all`?r:r.filter(e=>e.kind===u),a=n&&u!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&u===`all`)||f&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),c=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...c===void 0?{}:{onCount:c}}]:[]})},[te,f,u,c]),B=z.find(e=>e.id===a)??z[0]??null;if((0,i.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,i.useEffect)(()=>{F(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||Zi(a,Xi(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,i.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,i.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,i.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!O&&D(t.path)},[O,e.operations.clonePath]),(0,i.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&h(null)},[e.operations.enrollment]),(0,i.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,h(null),_(null),C(!1))},[e.applyState]),!e.open)return null;let V=B&&`repository`in B?B.repository:null,H=V?e.operations.updates[V.id]:void 0,U=V?.assessment,W=U?.status===`updateable`&&U.token&&U.localRevision&&U.upstreamRevision,G=()=>{let t=b.trim();t&&(v===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ne=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},re=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ie=V?.collection,ae=ie?Xi(ie):[],oe=new Set(V&&P[V.id]?P[V.id]:ae),se=ie?[...new Set([...oe,...ae])].filter(e=>oe.has(e)!==ae.includes(e)).length:0,K=V?e.operations.skills?.[V.id]:void 0,ce=e=>{if(!V)return;let t=V.id;F(n=>{let r={...n};return Zi(e,ae)?delete r[t]:r[t]=[...e],r})},le=()=>{if(!V)return;let e=V.id;F(t=>{let n={...t};return delete n[e],n})},ue=()=>{if(!V||!ie)return;let t=new Set(ie.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(V.id,[...oe].filter(e=>t.has(e)))},de=L?e.operations.removals?.[L.id]:void 0,fe=de?.status===`error`||de?.result?.status===`removed-delete-failed`;return(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,o.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,o.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,o.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,o.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,o.jsx)(`input`,{"aria-label":`Search resources`,value:c,onChange:e=>l(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,o.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded px-2 py-1 text-[11px] ${u===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,o.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded px-2 py-1 text-[11px] ${f?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,o.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[z.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${B?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,o.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,o.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?$i[e.repository.assessment.status]:e.reason})]},e.id)),z.length===0?(0,o.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,o.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(`local`),_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,o.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[L&&de?(0,o.jsxs)(`div`,{role:fe?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${fe?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,o.jsx)(`p`,{className:`min-w-0 break-words`,children:Qi(L.name,de)}),de.status===`loading`?null:(0,o.jsx)(`button`,{type:`button`,onClick:()=>R(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,m===`local`?(0,o.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":v===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{y(t),C(!1)},className:`rounded-md px-3 py-1.5 text-xs ${v===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local resource folder`,value:b,onChange:e=>{C(!1),x(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),g===`local`?(0,o.jsx)(xi,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{C(!1),x(t),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,v===`extension`?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!b.trim()||e.applyState?.status===`applying`||v===`extension`&&(!S||e.extensionLock),onClick:G,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):m===`git`?(0,o.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,o.jsx)(aa,{onCancel:()=>{h(null),_(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,o.jsx)(`input`,{"aria-label":`Repository address`,value:w,onChange:e=>T(e.target.value),onBlur:()=>{let t=w.trim();t&&(k(!1),j(t),e.onSuggestClonePath(w))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local clone folder`,value:E,onChange:e=>{k(!0),D(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`clone-parent`),e.onBrowseServerPath(na(E))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&w.trim()===A?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,g===`clone-parent`?(0,o.jsx)(xi,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{D(ra(t,E)),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!w.trim()||!E.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(w,E),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):B?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`h3`,{className:`text-xl font-semibold`,children:B.name}),V?(0,o.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:$i[V.assessment.status]}):null]}),(0,o.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in B?B.path:B.reason}),U?.branch?(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[U.branch,U.upstream?` → ${U.upstream}`:``]}):null,V?.removal&&!V.removal.allowed?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:V.removal.reason}):null]}),V?(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[V.removal?.allowed?(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[V.id]?.status===`loading`,onClick:()=>ee(V),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(V.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),W||H?.status===`loading`?(0,o.jsx)(`button`,{type:`button`,disabled:H?.status===`loading`,onClick:()=>V.containsExtensions?N(V):re(V),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:H?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),U?.reason?(0,o.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${U.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[U.reason,U.status===`dirty`?(0,o.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,U?.hasSubmodules?(0,o.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,H?.status===`ready`?(0,o.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:H.result?.status===`updated`&&H.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:H.result?.status===`updated`?`Repository updated and runtimes reloaded.`:H.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:H.result?.reason}):null,H?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:H.message}):null,ie&&V&&u!==`extension`?(0,o.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[se>0||K?.status===`loading`?(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsx)(`span`,{children:K?.status===`loading`?`Applying…`:`${se} pending change${se===1?``:`s`} — applying replaces the session`}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:K?.status===`loading`,onClick:le,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,o.jsx)(`button`,{type:`button`,disabled:K?.status===`loading`||se===0,onClick:ue,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,K?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:K.message}):null,(0,o.jsx)(qi,{skills:ie.skills,groups:ie.groups,enabled:oe,onChange:ce,disabled:K?.status===`loading`,...ie.bound?{bound:ie.bound}:{}},V.id),B.resources.some(e=>e.kind===`extension`)?(0,o.jsx)(ia,{kind:`extension`,resources:B.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ne}):null]}):(0,o.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,o.jsx)(ia,{kind:`skill`,resources:B.resources.filter(e=>e.kind===`skill`),onRemove:ne}),(0,o.jsx)(ia,{kind:`extension`,resources:B.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ne})]})]}):(0,o.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),M?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,o.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[M.name,` contains extensions that run with the agent's privileges. Confirm updating `,M.assessment.localRevision?.slice(0,8),` to `,M.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{re(M,!0),N(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,I?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,I.name,`?`]}),(0,o.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:I.removal?.deletesFiles?(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,I.name,` and deletes `,(0,o.jsx)(`span`,{className:`font-mono`,children:I.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,I.name,`. pi-outpost does not manage `,(0,o.jsx)(`span`,{className:`font-mono`,children:I.removal?.path??I.path}),`, so its files will be kept.`]})}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>ee(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(I.id),R({id:I.id,name:I.name}),ee(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:I.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var sa=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,ca=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function la({event:e}){switch(e.type){case`auth_url`:return(0,o.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,o.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,o.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,o.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function ua({prompt:e,onAnswer:t}){let[n,r]=(0,i.useState)(``),a=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:ca,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,o.jsx)(`input`,{className:`${sa} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),a&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,o.jsx)(`button`,{type:`button`,className:ca,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function da({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,o.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,o.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,o.jsx)(la,{event:e},t)),e.prompt&&(0,o.jsx)(ua,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,o.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:i,children:`Close`})]}):(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:r,children:`Cancel`})]})]})}function fa(e){return[...e].sort((e,t)=>e.localeCompare(t))}function pa(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function ma(e,t){return e===`models_json_key`?`models.json`:t??e}function ha({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:a,onDismissLogin:s,onLogoutProvider:c,extensionPaths:l,configuredExtensionPaths:u,userExtensionPaths:d,extensionLock:f,piPackages:p=null,piPackageUpdate:m=null,piPackageEdits:h,canRestartServer:g=!1,serverRestarting:_=!1,onCheckPiPackages:v,onUpdatePiPackage:y,onRestartServer:b,onRestartSession:x,restartNeeded:S=[],tools:C,commands:w,sandbox:T,showRoots:E=!0,gitUnavailable:D,userSkillPaths:O,serverBrowse:k,pickerBlocked:A=!1,onPickerOpened:j,applyState:M,agentResources:N=null,agentResourceOperations:P={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:F,onBrowseServerPath:I,onCloseServerBrowser:ee,onUpdateConfig:L,onSuggestAgentResourceClonePath:R=()=>{},onCloneAgentResourceRepository:te=()=>{},onEnrollAgentResourceRepository:z=()=>{},onSetAgentResourceSkills:B=()=>{},onRemoveAgentResourceRepository:V=()=>{},onRefreshAgentResourceRepositories:H=()=>{},onUpdateAgentResourceRepository:U=()=>{}}){let[W,G]=(0,i.useState)(!1),[ne,re]=(0,i.useState)(!1),ie=(0,i.useRef)(new Map),[ae,oe]=(0,i.useState)(!1),se=(0,i.useRef)(null),[K,ce]=(0,i.useState)(``),[le,ue]=(0,i.useState)(``),[de,fe]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(null),_e=(e,r)=>{if(t&&!t.done){a?.(),s?.();let e=ie.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,i.useEffect)(()=>{A&&he!==null&&ge(null)},[A,he]);let ve=Kt(()=>{(W||he!==null)&&Ee()}),ye=C.filter(e=>e.active),be=C.filter(e=>!e.active),xe=w.filter(e=>e.source===`skill`),Se=[...C].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Ce=M?.status===`applying`,we=M?.status===`error`?M.message:null;(0,i.useEffect)(()=>{T&&(ce(T.root),ue(T.writableRoot??``),fe(T.allowWrite),me(T.allowBash))},[T]);let Te=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Te.current&&M===null&&Ee(),Te.current=Ce},[M,Ce]);function Ee(){re(!1),G(!1),ge(null),ee()}function De(e,t){j?.(),ge(e),I(t.trim()||`/`)}function Oe(e){he===`root`?ce(e):he===`writableRoot`&&ue(e),ge(null),ee()}let ke=T!==null&&(K!==T.root||(le.trim()||void 0)!==(T.writableRoot||void 0)||de!==T.allowWrite||pe!==T.allowBash);function Ae(){T&&ke&&L({sandbox:{root:K,allowWrite:de,allowBash:pe,writableRoot:le.trim()||void 0}})}let je=E&&T?.rootEditable!==!1,Me=he!==null&&!A&&(0,o.jsx)(xi,{label:he===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:k,onBrowse:I,onSelect:Oe,onCancel:()=>{ge(null),ee()}});return(0,o.jsxs)(`div`,{className:`relative`,ref:ve,children:[(0,o.jsx)(`button`,{ref:se,type:`button`,onClick:()=>{re(!1),W?Ee():G(!0)},title:`Settings`,"aria-label":`Settings`,className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),W&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[ne&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>re(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,o.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:ne?`Credits`:`Settings`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:ne?(0,o.jsx)(ji,{}):(0,o.jsxs)(o.Fragment,{children:[D&&(0,o.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),D.reason===`no-repository`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,o.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,o.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:D.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,o.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:D.message}),D.reason===`no-executable`&&(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,o.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,o.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,o.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,o.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,o.jsxs)(`details`,{ref:e=>{e?ie.current.set(n.id,e):ie.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,o.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${ma(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,o.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:pa(n.source,n.label)}),!e.locked&&(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>c?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,o.jsx)(`div`,{className:`mt-2`,children:(0,o.jsx)(da,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>a?.(),onDismiss:()=>s?.()})})]})]})},n.id))}),e.locked&&(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),C.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`Tool inventory unavailable for this runtime`}):(0,o.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ye.length,` tools active`,be.length?` · ${be.length} inactive`:``]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Se.map(e=>(0,o.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{children:e.name}),(0,o.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),xe.length===0?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-600 dark:text-zinc-400`,children:`No skills loaded`}):(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[xe.length,` skills loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fa(xe.map(e=>e.name)).map(e=>(0,o.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{G(!1),oe(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage agent resources`})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),l===null?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):l.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,o.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[l.length,` `,l.length===1?`extension`:`extensions`,` loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fa(l).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u.length>0&&(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[u.length,` configured by this deployment`]}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:fa(u).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),f?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,o.jsx)(Hi,{packages:p,update:m,locked:f,onCheck:()=>v?.(),onUpdate:e=>y?.(e),...h?{edits:h}:{}}),(0,o.jsx)(Wi,{reasons:S,canRestart:g,restarting:_,onRestart:()=>b?.()})]}),T&&(0,o.jsxs)(`section`,{children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:je?`Sandbox`:`Agent permissions`}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[!je&&(0,o.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,o.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:T.projectRoot??T.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),je&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,T.locks?.root?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:K,onChange:e=>ce(e.target.value),disabled:T.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:T.locks?.root,onClick:()=>De(`root`,K),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),he===`root`&&Me,(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,T.locks?.writableRoot?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:le,onChange:e=>ue(e.target.value),disabled:T.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:T.locks?.writableRoot,onClick:()=>De(`writableRoot`,le||K),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),he===`writableRoot`&&Me]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.target.checked),disabled:T.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,T.locks?.allowWrite?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>me(e.target.checked),disabled:T.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,T.locks?.allowBash?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!T&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,o.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[we&&(0,o.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:we}),(0,o.jsx)(`button`,{type:`button`,disabled:Ce||ke&&!K.trim(),onClick:ke?Ae:x,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Ce?`Restarting…`:ke?`Apply & restart session`:`Restart session`}),(0,o.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:ke?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),F&&(0,o.jsxs)(`section`,{className:`mt-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,o.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsxs)(`p`,{children:[`pi-outpost: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.piOutpost})]}),F.piSdk&&(0,o.jsxs)(`p`,{children:[`pi SDK: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.piSdk})]}),F.agent&&(0,o.jsxs)(`p`,{children:[`agent: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.agent})]})]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>re(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,o.jsx)(oa,{open:ae,inventory:N,operations:P,extensionLock:f,userSkillPaths:O,userExtensionPaths:d,serverBrowse:k,applyState:M,onClose:()=>{oe(!1),ee(),se.current?.focus()},onBrowseServerPath:e=>{j?.(),I(e)},onCloseServerBrowser:ee,onUpdateConfig:L,onSuggestClonePath:R,onCloneRepository:te,onEnrollRepository:z,onSetSkills:B,onRemoveRepository:V,onRefresh:H,onUpdate:U})]})}function ga(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function _a(e){return e.flatMap(e=>[e,..._a(e.children)])}function va({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,o.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var ya=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function ba({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:s}=e,c=s.tipId??s.entryId;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,o.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),a()},title:n?`unavailable while the agent is running`:s.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(Qr,{row:e,laneCount:t,colorOf:Yr}),(0,o.jsx)(`span`,{className:`min-w-0 truncate ${s.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:s.text||`(empty)`}),e.forkTo.length>0&&(0,o.jsxs)(va,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,o.jsxs)(va,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,o.jsx)(va,{tone:`current`,children:`current`}),s.label&&(0,o.jsx)(va,{tone:`label`,children:s.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:ya,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{i(s.entryId),a()},title:`fork a new session from this point`,className:ya,children:`⑂ fork`})]})}function xa({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:a}){let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),d=Kt(()=>c(!1));(0,i.useEffect)(()=>{s&&e===null&&n()},[s,e]);let f=(0,i.useMemo)(()=>e&&e.length>0?ga(e):null,[e]),p=(0,i.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return _a(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,o.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),s&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[f.rows.length,` turn`,f.rows.length===1?``:`s`,` · `,f.branchPoints,` branch point`,f.branchPoints===1?``:`s`]})]}),(0,o.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,o.jsx)(ba,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:r,onFork:a,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),c(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,o.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,o.jsx)(va,{tone:`current`,children:`on current branch`}),e.label&&(0,o.jsx)(va,{tone:`label`,children:e.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),c(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:ya,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{a(e.entryId),c(!1)},title:`fork a new session from this point`,className:ya,children:`⑂ fork`})]},e.entryId))})]})]})]})}var Sa=200;function Ca({initial:e,onCommit:t,onCancel:n}){let[r,a]=(0,i.useState)(e);return(0,o.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function wa({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:s,onCancelRename:c}){return n?(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsx)(Ca,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,o.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,o.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,o.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,o.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,o.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function Ta({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:a,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(null),_=Kt(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,i.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),Sa);return()=>clearTimeout(e)},[d,v,y]);function b(){f(!1),g(null)}let x=y&&(t?.status!==`loaded`||t.query!==v),S=y?x?null:t?.results??null:e;return(0,o.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{d?b():(f(!0),m(``),g(null),u(),s())},className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),d&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,o.jsx)(wa,{session:e,isCurrent:e.id===n,renaming:h===e.path,onSwitch:()=>{r(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&a(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function Ea({filters:e,onFilterChange:t}){let[n,r]=(0,i.useState)(!1),a=Kt(()=>r(!1)),s=vt(e),c=s>0?`Filter · ${s} hidden`:`Filter`;return(0,o.jsxs)(`div`,{className:`relative`,ref:a,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${pi} ${s>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:c}),n&&(0,o.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:pt.map(n=>(0,o.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,o.jsx)(`span`,{children:mt[n]})]},n))})]})}function Da({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>wn(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=(0,i.useRef)(null),[u,d]=(0,i.useState)(!1),f=Kt(()=>d(!1));if((0,i.useLayoutEffect)(()=>{c.current=null,s(!1),d(!1)},[r]),(0,i.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{if(c.current!==null){e.clientWidth>c.current+64&&(c.current=null,s(!1),d(!1));return}let t=Array.from(l.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1),n=e.firstElementChild?.getBoundingClientRect(),r=n&&n.height>0&&Array.from(e.children).some(e=>e.getBoundingClientRect().top>=n.bottom);(t||r||e.scrollWidth>e.clientWidth+1)&&(c.current=e.clientWidth,s(!0))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,a,r]),n.length===0)return null;if(!a)return(0,o.jsx)(`div`,{ref:l,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,o.jsx)(`span`,{title:wn(t),className:`${pi} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,o.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,o.jsx)(Tn,{text:t})})},e))});let p=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,o.jsxs)(`div`,{ref:f,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&u&&(e.stopPropagation(),d(!1))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),"aria-expanded":u,title:n.map(([,e])=>wn(e)).join(`
705
+ `,ki=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`GrapesJS`,`Poster editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],Ai=[{name:`pi-outpost`,license:`MIT`,text:Oi},...Di];function ji(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(null);return(0,i.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,o.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),Ai.map(e=>(0,o.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,o.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,o.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsxs)(`section`,{className:`pb-5`,children:[(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,o.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,o.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,o.jsx)(`dl`,{className:`mt-3 space-y-3`,children:ki.map(([e,t])=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,o.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function Mi(e){if(e.removed)return`removed — still running until pi-outpost restarts`;if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function Ni(e){let t=e.trim().replace(/^npm:/,``),n=t.lastIndexOf(`@`);return n>0?{name:t.slice(0,n),version:t.slice(n+1)}:{name:t}}var Pi=e=>`${e.scope}:${e.name}`,Fi=(e,t)=>e===`user`?`all projects`:`the ${t} project`,Ii=`w-16 shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,Li=`w-16 shrink-0 rounded border border-transparent px-1.5 py-0.5 text-zinc-600 hover:bg-zinc-100 hover:text-red-700 disabled:opacity-50 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-red-400`,Ri=`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,zi=`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,Bi=`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,Vi=()=>(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`${Ii} invisible`,children:`Update`});function Hi({packages:e,update:t,locked:n,onCheck:r,onUpdate:a,edits:s}){let[c,l]=(0,i.useState)(null);if(e===null||e.length===0&&!s)return null;let u=t?.status===`pending`?t.source:null,d=s?.change??null,f=d?.status===`pending`?d:null,p=u!==null||f!==null||s?.lookup?.status===`pending`,m=!n&&s!==void 0;function h(e){if(u===e.source&&e.check?.state===`newer`)return{text:`updating to ${e.check.latest}…`,warn:!1};if(f&&f.key===Pi(e)){if(f.action===`remove`)return{text:`removing…`,warn:!1};if(f.action===`restore`)return{text:`reinstalling ${e.loaded??``}…`,warn:!1}}return t&&t.status!==`pending`&&t.status!==`installed`&&t.source===e.source?{text:t.message,warn:!0}:d&&(d.status===`failed`||d.status===`refused`)&&d.key===Pi(e)&&d.action!==`install`?{text:d.message,warn:!0}:{text:Mi(e),warn:!1}}return(0,o.jsxs)(`div`,{className:`mt-3 text-xs`,"data-testid":`pi-packages`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),e.length>0&&(0,o.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),e.length===0&&(0,o.jsx)(`p`,{className:`text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-packages-empty`,children:`No packages installed`}),(0,o.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=Pi(e),r=e.check?.state===`newer`&&!e.restartNeeded&&!e.removed?e.check.latest:void 0,i=c?.key===t?c.kind:null,{text:u,warn:d}=h(e);return(0,o.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium ${e.removed?`text-zinc-400 line-through dark:text-zinc-500`:`text-zinc-700 dark:text-zinc-200`}`,title:e.source,children:e.name}),!n&&(r?(0,o.jsx)(`button`,{type:`button`,disabled:p||i!==null,onClick:()=>l({kind:`update`,key:t}),className:Ii,children:`Update`}):(0,o.jsx)(Vi,{})),m&&(e.removed?(0,o.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>s.onRestore(e),className:Ii,title:`Put ${e.name} back as it was`,children:`Undo`}):(0,o.jsx)(`button`,{type:`button`,disabled:p||i!==null,onClick:()=>l({kind:`remove`,key:t}),className:Li,"aria-label":`Remove ${e.name}`,children:`Remove`}))]}),(0,o.jsxs)(`div`,{className:`truncate ${d?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,title:u,children:[e.scope===`project`&&(0,o.jsx)(`span`,{children:`this project · `}),(0,o.jsx)(`span`,{"data-testid":`pi-package-status`,children:u})]}),r&&i===`update`&&(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{l(null),a(e.source)},className:zi,children:[`Install `,r]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:Bi,children:`Cancel`})]})]}),s&&i===`remove`&&(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`Removes `,e.name,` from `,e.scope===`user`?`the agent's settings (all projects)`:`the ${s.projectName} project's settings`,` `,`and uninstalls it. The agent keeps running it until pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{l(null),s.onRemove(e)},className:zi,children:`Remove`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:Bi,children:`Cancel`})]})]})]},`${t}:${e.source}`)})}),m&&(0,o.jsx)(Ui,{edits:s,busy:p},s.projectName)]})}function Ui({edits:e,busy:t}){let[n,r]=(0,i.useState)(!1),[a,s]=(0,i.useState)(``),[c,l]=(0,i.useState)(`user`),u=(0,i.useRef)(null),{lookup:d,change:f}=e,p=f?.status===`pending`&&f.action===`install`?f:null,m=f&&f.action===`install`&&(f.status===`failed`||f.status===`refused`)?f.message:null,h=Ni(a),g=d&&d.name===h.name&&d.version===h.version&&d.scope===c?d:null;(0,i.useEffect)(()=>{f?.action===`install`&&f.status===`installed`&&(r(!1),s(``),l(`user`))},[f]),(0,i.useEffect)(()=>{n&&g?.status!==`found`&&u.current?.focus()},[n,g?.status]);let _=()=>{r(!1),s(``),l(`user`),e.onCloseLookup()};if(p)return(0,o.jsxs)(`p`,{className:`mt-1 text-zinc-500 dark:text-zinc-400`,role:`status`,children:[`installing `,p.key.slice(p.key.indexOf(`:`)+1),`…`]});if(!n)return(0,o.jsxs)(o.Fragment,{children:[m&&(0,o.jsx)(`p`,{className:`mt-1 text-amber-700 dark:text-amber-400`,role:`alert`,children:m}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(!0),className:`mt-1 text-zinc-500 underline hover:text-zinc-800 disabled:opacity-50 dark:hover:text-zinc-200`,children:`Add a package`})]});if(g?.status===`found`)return(0,o.jsxs)(`div`,{className:Ri,"data-testid":`pi-package-add-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This installs code that runs with the agent's privileges: `,g.name,` `,g.resolved,g.version===void 0?``:` (pinned)`,`, for `,Fi(g.scope,e.projectName),`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>e.onInstall(g.name,g.version,g.scope,g.resolved),className:zi,children:[`Install `,g.name]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>e.onCloseLookup(),className:Bi,children:`Cancel`})]})]});let v=g?g.status===`refused`?g.message:null:m;return(0,o.jsxs)(`form`,{className:`mt-1 rounded border border-zinc-200 p-2 dark:border-zinc-700`,onSubmit:n=>{n.preventDefault(),h.name&&!t&&e.onLookup(h.name,h.version,c)},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),_())},children:[(0,o.jsx)(`label`,{className:`block text-zinc-600 dark:text-zinc-400`,htmlFor:`pi-package-name`,children:`npm package`}),(0,o.jsx)(`input`,{id:`pi-package-name`,ref:u,value:a,onChange:e=>s(e.target.value),disabled:g?.status===`pending`,autoComplete:`off`,spellCheck:!1,placeholder:`openlore, @scope/name or name@1.2.3`,className:`mt-0.5 w-full rounded border border-zinc-300 bg-white px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-blue-400 dark:border-zinc-600 dark:bg-zinc-800`}),(0,o.jsxs)(`fieldset`,{className:`mt-2 flex flex-wrap gap-x-3 text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`legend`,{className:`sr-only`,children:`Install for`}),(0,o.jsxs)(`label`,{children:[(0,o.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:c===`user`,onChange:()=>l(`user`)}),` all projects`]}),(0,o.jsxs)(`label`,{children:[(0,o.jsx)(`input`,{type:`radio`,name:`pi-package-scope`,checked:c===`project`,onChange:()=>l(`project`)}),` this project only (`,e.projectName,`)`]})]}),(0,o.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:_,className:`rounded px-2 py-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-700`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`submit`,disabled:t||!h.name,className:Ii.replace(`w-16 `,``),children:`Install…`})]}),(0,o.jsx)(`p`,{className:`mt-1 min-h-[1rem] ${v?`text-amber-700 dark:text-amber-400`:`text-zinc-500 dark:text-zinc-400`}`,role:v?`alert`:`status`,children:v??(g?.status===`pending`?`looking up ${g.name}…`:``)})]})}function Wi({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[a,s]=(0,i.useState)(!1);return e.length===0?null:(0,o.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,o.jsxs)(`p`,{children:[`Waiting on a restart to take effect: `,e.join(`, `),`.`]}),t?n?(0,o.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):a?(0,o.jsxs)(`div`,{className:`mt-1`,children:[(0,o.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var Gi=30,Ki={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function qi({skills:e,groups:t,enabled:n,onChange:r,disabled:a=!1,bound:s}){let[c,l]=(0,i.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[u,d]=(0,i.useState)(``),[f,p]=(0,i.useState)(!1),m=u.trim().toLocaleLowerCase(),h=m!==``||f,g=e=>(!f||n.has(e.relativePath))&&(!m||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(m)),_=new Map;for(let t of e)_.set(t.group,[..._.get(t.group)??[],t]);let v=e.filter(e=>n.has(e.relativePath)).length,y=h?e.filter(g).length:e.length,b=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},x=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},S=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,v,` of `,e.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:a||v===e.length,onClick:()=>b(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,disabled:a||v===0,onClick:()=>b(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:s.kind===`count`?`This repository holds more skills than the ${s.limit} listed here.`:`Folders deeper than ${s.limit} levels were not searched for skills.`}):null,e.length>0?(0,o.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:u,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,o.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${f?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,v,`)`]})]}):null,!h&&v>0&&v<=Gi?(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,o.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,o.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,o.jsx)(Ji,{skill:e,checked:!0})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:a,onClick:()=>x(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,h&&y===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:f&&!m?`No skill is on.`:`No skill matches.`}):null,(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=_.get(e.path)??[],r=h?t.filter(g):t;if(h&&r.length===0)return null;let i=r.filter(e=>n.has(e.relativePath)).length,s=h||c.has(e.path);return(0,o.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,o.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>S(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,o.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[i,`/`,r.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,o.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:a||i===r.length,onClick:()=>b(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:a||i===0,onClick:()=>b(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,o.jsx)(`li`,{children:(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${a?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:a,onChange:()=>x(e.relativePath),className:`mt-0.5`}),(0,o.jsxs)(`span`,{className:`min-w-0`,children:[(0,o.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,o.jsx)(`span`,{title:e.description,style:Ki,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,o.jsx)(Ji,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function Ji({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,o.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,o.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function Yi(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function Xi(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function Zi(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function Qi(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var $i={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ea(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function ta(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function na(e){let t=ta(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function ra(e,t){let n=ta(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${ta(e)}/${i||`agent-resources`}`}function ia({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,o.jsxs)(`span`,{children:[e,`s`]}),(0,o.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,o.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`}),e.kind===`extension`&&e.userRoot&&e.userRoot!==e.path?(0,o.jsxs)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.userRoot,children:[(0,o.jsx)(`span`,{children:`Folder: `}),(0,o.jsx)(`span`,{children:e.userRoot})]}):null]},e.id))})]})}function aa({preview:e,busy:t,error:n,onApply:r,onCancel:a}){let[s,c]=(0,i.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(()=>new Set),p=e.mode===`collection`,m=(0,i.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),h=(0,i.useMemo)(()=>Yi(e.skills,e.repositoryName),[e.skills,e.repositoryName]),g=e.roots.filter(e=>e.kind===`extension`&&s.has(`extension:${e.path}`)),_=g.length>0&&!l,v=t||!p&&s.size===0||_,y=()=>{let t=g.map(e=>e.path);p?r([],t,[...d]):r(e.roots.filter(e=>e.kind===`skill`&&s.has(`skill:${e.path}`)).map(e=>e.path),t)},b=e=>{u(!1),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,o.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:v,onClick:y,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),_?(0,o.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,p?(0,o.jsx)(qi,{skills:m,groups:h,enabled:d,onChange:f,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:s.has(t),disabled:e.locked,onChange:()=>b(t)}),(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,o.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),g.length>0?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function oa(e){let t=(0,i.useRef)(null),n=(0,i.useRef)(e.onClose),r=(0,i.useRef)(!1),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(`all`),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(`skill`),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)(!1),[w,T]=(0,i.useState)(``),[E,D]=(0,i.useState)(``),[O,k]=(0,i.useState)(!1),[A,j]=(0,i.useState)(``),[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)({}),[I,ee]=(0,i.useState)(null),[L,R]=(0,i.useState)(null),te=(0,i.useMemo)(()=>ea(e.inventory),[e.inventory]),z=(0,i.useMemo)(()=>{let e=c.trim().toLocaleLowerCase();return te.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=u===`all`?r:r.filter(e=>e.kind===u),a=n&&u!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&u===`all`)||f&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),c=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...c===void 0?{}:{onCount:c}}]:[]})},[te,f,u,c]),B=z.find(e=>e.id===a)??z[0]??null;if((0,i.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,i.useEffect)(()=>{F(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||Zi(a,Xi(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,i.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,i.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,i.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!O&&D(t.path)},[O,e.operations.clonePath]),(0,i.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&h(null)},[e.operations.enrollment]),(0,i.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,h(null),_(null),C(!1))},[e.applyState]),!e.open)return null;let V=B&&`repository`in B?B.repository:null,H=V?e.operations.updates[V.id]:void 0,U=V?.assessment,W=U?.status===`updateable`&&U.token&&U.localRevision&&U.upstreamRevision,G=()=>{let t=b.trim();t&&(v===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ne=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},re=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},ie=V?.collection,ae=ie?Xi(ie):[],oe=new Set(V&&P[V.id]?P[V.id]:ae),se=ie?[...new Set([...oe,...ae])].filter(e=>oe.has(e)!==ae.includes(e)).length:0,K=V?e.operations.skills?.[V.id]:void 0,ce=e=>{if(!V)return;let t=V.id;F(n=>{let r={...n};return Zi(e,ae)?delete r[t]:r[t]=[...e],r})},le=()=>{if(!V)return;let e=V.id;F(t=>{let n={...t};return delete n[e],n})},ue=()=>{if(!V||!ie)return;let t=new Set(ie.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(V.id,[...oe].filter(e=>t.has(e)))},de=L?e.operations.removals?.[L.id]:void 0,fe=de?.status===`error`||de?.result?.status===`removed-delete-failed`;return(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,o.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,o.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,o.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,o.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,o.jsx)(`input`,{"aria-label":`Search resources`,value:c,onChange:e=>l(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,o.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded px-2 py-1 text-[11px] ${u===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,o.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded px-2 py-1 text-[11px] ${f?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,o.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[z.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${B?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,o.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,o.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?$i[e.repository.assessment.status]:e.reason})]},e.id)),z.length===0?(0,o.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,o.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(`local`),_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,o.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[L&&de?(0,o.jsxs)(`div`,{role:fe?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${fe?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,o.jsx)(`p`,{className:`min-w-0 break-words`,children:Qi(L.name,de)}),de.status===`loading`?null:(0,o.jsx)(`button`,{type:`button`,onClick:()=>R(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,m===`local`?(0,o.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":v===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{y(t),C(!1)},className:`rounded-md px-3 py-1.5 text-xs ${v===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local resource folder`,value:b,onChange:e=>{C(!1),x(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),g===`local`?(0,o.jsx)(xi,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{C(!1),x(t),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,v===`extension`?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!b.trim()||e.applyState?.status===`applying`||v===`extension`&&(!S||e.extensionLock),onClick:G,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):m===`git`?(0,o.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,o.jsx)(aa,{onCancel:()=>{h(null),_(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,o.jsx)(`input`,{"aria-label":`Repository address`,value:w,onChange:e=>T(e.target.value),onBlur:()=>{let t=w.trim();t&&(k(!1),j(t),e.onSuggestClonePath(w))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local clone folder`,value:E,onChange:e=>{k(!0),D(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`clone-parent`),e.onBrowseServerPath(na(E))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&w.trim()===A?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,g===`clone-parent`?(0,o.jsx)(xi,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{D(ra(t,E)),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!w.trim()||!E.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(w,E),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):B?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`h3`,{className:`text-xl font-semibold`,children:B.name}),V?(0,o.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:$i[V.assessment.status]}):null]}),(0,o.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in B?B.path:B.reason}),U?.branch?(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[U.branch,U.upstream?` → ${U.upstream}`:``]}):null,V?.removal&&!V.removal.allowed?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:V.removal.reason}):null]}),V?(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[V.removal?.allowed?(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[V.id]?.status===`loading`,onClick:()=>ee(V),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(V.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),W||H?.status===`loading`?(0,o.jsx)(`button`,{type:`button`,disabled:H?.status===`loading`,onClick:()=>V.containsExtensions?N(V):re(V),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:H?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),U?.reason?(0,o.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${U.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[U.reason,U.status===`dirty`?(0,o.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,U?.hasSubmodules?(0,o.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,H?.status===`ready`?(0,o.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:H.result?.status===`updated`&&H.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:H.result?.status===`updated`?`Repository updated and runtimes reloaded.`:H.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:H.result?.reason}):null,H?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:H.message}):null,ie&&V&&u!==`extension`?(0,o.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[se>0||K?.status===`loading`?(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsx)(`span`,{children:K?.status===`loading`?`Applying…`:`${se} pending change${se===1?``:`s`} — applying replaces the session`}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:K?.status===`loading`,onClick:le,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,o.jsx)(`button`,{type:`button`,disabled:K?.status===`loading`||se===0,onClick:ue,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,K?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:K.message}):null,(0,o.jsx)(qi,{skills:ie.skills,groups:ie.groups,enabled:oe,onChange:ce,disabled:K?.status===`loading`,...ie.bound?{bound:ie.bound}:{}},V.id),B.resources.some(e=>e.kind===`extension`)?(0,o.jsx)(ia,{kind:`extension`,resources:B.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ne}):null]}):(0,o.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,o.jsx)(ia,{kind:`skill`,resources:B.resources.filter(e=>e.kind===`skill`),onRemove:ne}),(0,o.jsx)(ia,{kind:`extension`,resources:B.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ne})]})]}):(0,o.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),M?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,o.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[M.name,` contains extensions that run with the agent's privileges. Confirm updating `,M.assessment.localRevision?.slice(0,8),` to `,M.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{re(M,!0),N(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,I?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,I.name,`?`]}),(0,o.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:I.removal?.deletesFiles?(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,I.name,` and deletes `,(0,o.jsx)(`span`,{className:`font-mono`,children:I.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,I.name,`. pi-outpost does not manage `,(0,o.jsx)(`span`,{className:`font-mono`,children:I.removal?.path??I.path}),`, so its files will be kept.`]})}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>ee(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(I.id),R({id:I.id,name:I.name}),ee(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:I.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var sa=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,ca=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function la({event:e}){switch(e.type){case`auth_url`:return(0,o.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,o.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,o.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,o.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function ua({prompt:e,onAnswer:t}){let[n,r]=(0,i.useState)(``),a=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:ca,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,o.jsx)(`input`,{className:`${sa} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),a&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,o.jsx)(`button`,{type:`button`,className:ca,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function da({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,o.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,o.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,o.jsx)(la,{event:e},t)),e.prompt&&(0,o.jsx)(ua,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,o.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:i,children:`Close`})]}):(0,o.jsx)(`button`,{type:`button`,className:ca,onClick:r,children:`Cancel`})]})]})}function fa(e){return[...e].sort((e,t)=>e.localeCompare(t))}function pa(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function ma(e,t){return e===`models_json_key`?`models.json`:t??e}function ha({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:a,onDismissLogin:s,onLogoutProvider:c,extensionPaths:l,configuredExtensionPaths:u,userExtensionPaths:d,extensionLock:f,piPackages:p=null,piPackageUpdate:m=null,piPackageEdits:h,canRestartServer:g=!1,serverRestarting:_=!1,onCheckPiPackages:v,onUpdatePiPackage:y,onRestartServer:b,onRestartSession:x,restartNeeded:S=[],tools:C,commands:w,sandbox:T,showRoots:E=!0,gitUnavailable:D,userSkillPaths:O,serverBrowse:k,pickerBlocked:A=!1,onPickerOpened:j,applyState:M,agentResources:N=null,agentResourceOperations:P={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:F,onBrowseServerPath:I,onCloseServerBrowser:ee,onUpdateConfig:L,onSuggestAgentResourceClonePath:R=()=>{},onCloneAgentResourceRepository:te=()=>{},onEnrollAgentResourceRepository:z=()=>{},onSetAgentResourceSkills:B=()=>{},onRemoveAgentResourceRepository:V=()=>{},onRefreshAgentResourceRepositories:H=()=>{},onUpdateAgentResourceRepository:U=()=>{}}){let[W,G]=(0,i.useState)(!1),[ne,re]=(0,i.useState)(!1),ie=(0,i.useRef)(new Map),[ae,oe]=(0,i.useState)(!1),se=(0,i.useRef)(null),[K,ce]=(0,i.useState)(``),[le,ue]=(0,i.useState)(``),[de,fe]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(null),_e=(e,r)=>{if(t&&!t.done){a?.(),s?.();let e=ie.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,i.useEffect)(()=>{A&&he!==null&&ge(null)},[A,he]);let ve=Kt(()=>{(W||he!==null)&&Ee()}),ye=C.filter(e=>e.active),be=C.filter(e=>!e.active),xe=w.filter(e=>e.source===`skill`),Se=[...C].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Ce=M?.status===`applying`,we=M?.status===`error`?M.message:null;(0,i.useEffect)(()=>{T&&(ce(T.root),ue(T.writableRoot??``),fe(T.allowWrite),me(T.allowBash))},[T]);let Te=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Te.current&&M===null&&Ee(),Te.current=Ce},[M,Ce]);function Ee(){re(!1),G(!1),ge(null),ee()}function De(e,t){j?.(),ge(e),I(t.trim()||`/`)}function Oe(e){he===`root`?ce(e):he===`writableRoot`&&ue(e),ge(null),ee()}let ke=T!==null&&(K!==T.root||(le.trim()||void 0)!==(T.writableRoot||void 0)||de!==T.allowWrite||pe!==T.allowBash);function Ae(){T&&ke&&L({sandbox:{root:K,allowWrite:de,allowBash:pe,writableRoot:le.trim()||void 0}})}let je=E&&T?.rootEditable!==!1,Me=he!==null&&!A&&(0,o.jsx)(xi,{label:he===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:k,onBrowse:I,onSelect:Oe,onCancel:()=>{ge(null),ee()}});return(0,o.jsxs)(`div`,{className:`relative`,ref:ve,children:[(0,o.jsx)(`button`,{ref:se,type:`button`,onClick:()=>{re(!1),W?Ee():G(!0)},title:`Settings`,"aria-label":`Settings`,className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),W&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[ne&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>re(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,o.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:ne?`Credits`:`Settings`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:ne?(0,o.jsx)(ji,{}):(0,o.jsxs)(o.Fragment,{children:[D&&(0,o.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),D.reason===`no-repository`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,o.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,o.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:D.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,o.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:D.message}),D.reason===`no-executable`&&(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,o.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,o.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,o.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,o.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,o.jsxs)(`details`,{ref:e=>{e?ie.current.set(n.id,e):ie.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,o.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${ma(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,o.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:pa(n.source,n.label)}),!e.locked&&(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>c?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,o.jsx)(`div`,{className:`mt-2`,children:(0,o.jsx)(da,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>a?.(),onDismiss:()=>s?.()})})]})]})},n.id))}),e.locked&&(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),C.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`Tool inventory unavailable for this runtime`}):(0,o.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ye.length,` tools active`,be.length?` · ${be.length} inactive`:``]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Se.map(e=>(0,o.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{children:e.name}),(0,o.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),xe.length===0?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-600 dark:text-zinc-400`,children:`No skills loaded`}):(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[xe.length,` skills loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fa(xe.map(e=>e.name)).map(e=>(0,o.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{G(!1),oe(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage agent resources`})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),l===null?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):l.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,o.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[l.length,` `,l.length===1?`extension`:`extensions`,` loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fa(l).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),u.length>0&&(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[u.length,` configured by this deployment`]}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:fa(u).map(e=>(0,o.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),f?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,o.jsx)(Hi,{packages:p,update:m,locked:f,onCheck:()=>v?.(),onUpdate:e=>y?.(e),...h?{edits:h}:{}}),(0,o.jsx)(Wi,{reasons:S,canRestart:g,restarting:_,onRestart:()=>b?.()})]}),T&&(0,o.jsxs)(`section`,{children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:je?`Sandbox`:`Agent permissions`}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[!je&&(0,o.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,o.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:T.projectRoot??T.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),je&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,T.locks?.root?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:K,onChange:e=>ce(e.target.value),disabled:T.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:T.locks?.root,onClick:()=>De(`root`,K),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),he===`root`&&Me,(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,T.locks?.writableRoot?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:le,onChange:e=>ue(e.target.value),disabled:T.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:T.locks?.writableRoot,onClick:()=>De(`writableRoot`,le||K),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),he===`writableRoot`&&Me]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.target.checked),disabled:T.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,T.locks?.allowWrite?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>me(e.target.checked),disabled:T.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,T.locks?.allowBash?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!T&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,o.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[we&&(0,o.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:we}),(0,o.jsx)(`button`,{type:`button`,disabled:Ce||ke&&!K.trim(),onClick:ke?Ae:x,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:Ce?`Restarting…`:ke?`Apply & restart session`:`Restart session`}),(0,o.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:ke?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),F&&(0,o.jsxs)(`section`,{className:`mt-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,o.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsxs)(`p`,{children:[`pi-outpost: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.piOutpost})]}),F.piSdk&&(0,o.jsxs)(`p`,{children:[`pi SDK: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.piSdk})]}),F.agent&&(0,o.jsxs)(`p`,{children:[`agent: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:F.agent})]})]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>re(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,o.jsx)(oa,{open:ae,inventory:N,operations:P,extensionLock:f,userSkillPaths:O,userExtensionPaths:d,serverBrowse:k,applyState:M,onClose:()=>{oe(!1),ee(),se.current?.focus()},onBrowseServerPath:e=>{j?.(),I(e)},onCloseServerBrowser:ee,onUpdateConfig:L,onSuggestClonePath:R,onCloneRepository:te,onEnrollRepository:z,onSetSkills:B,onRemoveRepository:V,onRefresh:H,onUpdate:U})]})}function ga(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0)n.delete(o);else{for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function _a(e){return e.flatMap(e=>[e,..._a(e.children)])}function va({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,o.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var ya=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function ba({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:s}=e,c=s.tipId??s.entryId;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,o.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),a()},title:n?`unavailable while the agent is running`:s.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(Qr,{row:e,laneCount:t,colorOf:Yr}),(0,o.jsx)(`span`,{className:`min-w-0 truncate ${s.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:s.text||`(empty)`}),e.forkTo.length>0&&(0,o.jsxs)(va,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,o.jsxs)(va,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,o.jsx)(va,{tone:`current`,children:`current`}),s.label&&(0,o.jsx)(va,{tone:`label`,children:s.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:ya,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{i(s.entryId),a()},title:`fork a new session from this point`,className:ya,children:`⑂ fork`})]})}function xa({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:a}){let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),d=Kt(()=>c(!1));(0,i.useEffect)(()=>{s&&e===null&&n()},[s,e]);let f=(0,i.useMemo)(()=>e&&e.length>0?ga(e):null,[e]),p=(0,i.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return _a(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,o.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),s&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,o.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[f.rows.length,` turn`,f.rows.length===1?``:`s`,` · `,f.branchPoints,` branch point`,f.branchPoints===1?``:`s`]})]}),(0,o.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,o.jsx)(ba,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:r,onFork:a,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.tipId??e.entryId),c(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,o.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,o.jsx)(va,{tone:`current`,children:`on current branch`}),e.label&&(0,o.jsx)(va,{tone:`label`,children:e.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(e.entryId),c(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:ya,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{a(e.entryId),c(!1)},title:`fork a new session from this point`,className:ya,children:`⑂ fork`})]},e.entryId))})]})]})]})}var Sa=200;function Ca({initial:e,onCommit:t,onCancel:n}){let[r,a]=(0,i.useState)(e);return(0,o.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function wa({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:s,onCancelRename:c}){return n?(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsx)(Ca,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,o.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,o.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,o.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``,!t&&e.liveIn?(0,o.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:a,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&!e.liveIn&&(0,o.jsx)(`button`,{type:`button`,onClick:i,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function Ta({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:a,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(null),_=Kt(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,i.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),Sa);return()=>clearTimeout(e)},[d,v,y]);function b(){f(!1),g(null)}let x=y&&(t?.status!==`loaded`||t.query!==v),S=y?x?null:t?.results??null:e;return(0,o.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{d?b():(f(!0),m(``),g(null),u(),s())},className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),d&&(0,o.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsx)(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,o.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,o.jsx)(wa,{session:e,isCurrent:e.id===n,renaming:h===e.path,onSwitch:()=>{r(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&a(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function Ea({filters:e,onFilterChange:t}){let[n,r]=(0,i.useState)(!1),a=Kt(()=>r(!1)),s=vt(e),c=s>0?`Filter · ${s} hidden`:`Filter`;return(0,o.jsxs)(`div`,{className:`relative`,ref:a,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${pi} ${s>0?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:c}),n&&(0,o.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:pt.map(n=>(0,o.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,o.jsx)(`span`,{children:mt[n]})]},n))})]})}function Da({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>wn(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=(0,i.useRef)(null),[u,d]=(0,i.useState)(!1),f=Kt(()=>d(!1));if((0,i.useLayoutEffect)(()=>{c.current=null,s(!1),d(!1)},[r]),(0,i.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{if(c.current!==null){e.clientWidth>c.current+64&&(c.current=null,s(!1),d(!1));return}let t=Array.from(l.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1),n=e.firstElementChild?.getBoundingClientRect(),r=n&&n.height>0&&Array.from(e.children).some(e=>e.getBoundingClientRect().top>=n.bottom);(t||r||e.scrollWidth>e.clientWidth+1)&&(c.current=e.clientWidth,s(!0))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,a,r]),n.length===0)return null;if(!a)return(0,o.jsx)(`div`,{ref:l,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,o.jsx)(`span`,{title:wn(t),className:`${pi} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,o.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,o.jsx)(Tn,{text:t})})},e))});let p=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,o.jsxs)(`div`,{ref:f,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&u&&(e.stopPropagation(),d(!1))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),"aria-expanded":u,title:n.map(([,e])=>wn(e)).join(`
706
706
  `),className:`${pi} border-zinc-200 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:[p,` ▾`]}),u&&(0,o.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,o.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:(0,o.jsx)(Tn,{text:t})},e))})]})}function Oa({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=Kt(()=>s(!1));(0,i.useEffect)(()=>{a&&l.current?.querySelector(`[aria-checked="true"]`)?.focus()},[a]);let u={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,o.jsxs)(`div`,{ref:l,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),s(!1),c.current?.focus()),a&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(l.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,o.jsx)(`button`,{ref:c,type:`button`,onClick:()=>s(e=>!e),title:`Theme: ${u}`,"aria-label":`Theme: ${u}`,"aria-haspopup":`menu`,"aria-expanded":a,className:`${pi} border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),a&&(0,o.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,o.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),s(!1),c.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function ka(e){let{isStreaming:t,connected:n}=e,[r,a]=(0,i.useState)(null);return(0,o.jsxs)(`header`,{ref:a,className:`relative z-30 flex min-w-0 flex-wrap items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,o.jsx)(bi,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,o.jsx)(Ci,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${pi} ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${pi} ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,o.jsx)(Ei,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onCloseLog:e.onCloseGitLog,onShowCommit:e.onShowCommit}),(0,o.jsx)(`span`,{title:e.title??void 0,className:`hidden min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight sm:block`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,o.jsx)(Da,{statuses:e.statuses,bar:r}),(0,o.jsxs)(`div`,{className:`ml-auto flex w-full max-w-full shrink-0 flex-wrap items-center gap-1 sm:w-auto sm:gap-1.5`,children:[(0,o.jsx)(Ea,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,o.jsx)(Oa,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,o.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${pi} border-emerald-300 text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,o.jsx)(xa,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,o.jsx)(Ta,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,o.jsx)(ha,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,...e.piPackageEdits?{piPackageEdits:e.piPackageEdits}:{},canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,o.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Aa(e,t){let n=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>je(e)!==t);for(let e of[...n.current.keys()])r.some(t=>je(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(je(e))!==e.activity){n.current.set(je(e),e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${je(e)}`})}catch{}}}},[e,t])}var ja={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},Ma=e=>e.map(e=>ja[e]??e),Na=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function Pa(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${Na(e.checkedAt)}. A command could not:`,...Ma(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${ja[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
707
707
  `);case`partial`:return[`${n} is confined by ${e.runner}, checked at ${Na(e.checkedAt)}, except one thing: a command can read the server's process environment, which holds ${e.exposed.join(`, `)}.`,`Move these out of the server's environment — provider keys belong in the agent directory.`,`A command could not:`,...Ma(e.refused).map(e=>`• ${e}`)].join(`
708
708
  `);case`leaking`:return[`${n} is NOT confined as configured: under ${e.runner}, checked at ${Na(e.checkedAt)}, a command could:`,...Ma(e.reached).map(e=>`• ${e}`),`The configuration is unchanged: fix the runner or its host, or stop using it.`].join(`
@@ -6609,23 +6609,31 @@ function eo({ kind: e, resources: t, removalLocked: n = !1, onRemove: r }) {
6609
6609
  className: "mt-3 space-y-2",
6610
6610
  children: t.map((e) => /* @__PURE__ */ G("li", {
6611
6611
  className: "rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70",
6612
- children: [/* @__PURE__ */ G("div", {
6613
- className: "flex items-center justify-between gap-2",
6614
- children: [/* @__PURE__ */ W("p", {
6615
- className: "truncate text-sm font-medium text-zinc-700 dark:text-zinc-200",
6616
- children: e.name
6617
- }), e.userRoot && !n ? /* @__PURE__ */ W("button", {
6618
- type: "button",
6619
- "aria-label": `Remove ${e.userRoot}`,
6620
- onClick: () => r(e),
6621
- className: "text-xs text-zinc-500 hover:text-red-600",
6622
- children: "Remove"
6623
- }) : null]
6624
- }), /* @__PURE__ */ W("p", {
6625
- className: "mt-0.5 truncate font-mono text-[11px] text-zinc-400",
6626
- title: e.path,
6627
- children: e.path ?? e.unavailableReason ?? "Path unavailable"
6628
- })]
6612
+ children: [
6613
+ /* @__PURE__ */ G("div", {
6614
+ className: "flex items-center justify-between gap-2",
6615
+ children: [/* @__PURE__ */ W("p", {
6616
+ className: "truncate text-sm font-medium text-zinc-700 dark:text-zinc-200",
6617
+ children: e.name
6618
+ }), e.userRoot && !n ? /* @__PURE__ */ W("button", {
6619
+ type: "button",
6620
+ "aria-label": `Remove ${e.userRoot}`,
6621
+ onClick: () => r(e),
6622
+ className: "text-xs text-zinc-500 hover:text-red-600",
6623
+ children: "Remove"
6624
+ }) : null]
6625
+ }),
6626
+ /* @__PURE__ */ W("p", {
6627
+ className: "mt-0.5 truncate font-mono text-[11px] text-zinc-400",
6628
+ title: e.path,
6629
+ children: e.path ?? e.unavailableReason ?? "Path unavailable"
6630
+ }),
6631
+ e.kind === "extension" && e.userRoot && e.userRoot !== e.path ? /* @__PURE__ */ G("p", {
6632
+ className: "mt-0.5 truncate font-mono text-[11px] text-zinc-500",
6633
+ title: e.userRoot,
6634
+ children: [/* @__PURE__ */ W("span", { children: "Folder: " }), /* @__PURE__ */ W("span", { children: e.userRoot })]
6635
+ }) : null
6636
+ ]
6629
6637
  }, e.id))
6630
6638
  })]
6631
6639
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-outpost/embed",
3
- "version": "0.59.1",
3
+ "version": "0.60.0",
4
4
  "type": "module",
5
5
  "description": "Mount pi-outpost as a Shadow-DOM-isolated widget inside another web app.",
6
6
  "license": "MIT",