@jyork0828/pi-pilot 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jyork0828/pi-pilot",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "description": "Browser UI for the pi coding agent.",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "README.md"
15
15
  ],
16
16
  "dependencies": {
17
- "@earendil-works/pi-coding-agent": "0.75.4",
17
+ "@earendil-works/pi-coding-agent": "0.78.0",
18
18
  "@hono/node-server": "^1.13.7",
19
19
  "hono": "^4.6.14",
20
20
  "typebox": "1.1.38",
@@ -0,0 +1 @@
1
+ import{j as e,r as c}from"./markdown-CY-Rm0E5.js";import{_ as k,r as u,b as I,A as T,a as E,y as _,x as b,t as P,v as R,w as B,B as y,u as D,ac as W,ab as z,j as F,E as H,g as M,I as L,X as S,e as K,f as O,Q as U,C as V,h as $,c as G,H as g,m as Q}from"./index-CX2ohSDO.js";import"./shiki-BZ0sbaMe.js";const X=()=>Math.min(window.innerWidth*.7,960);function se({open:t,onClose:o}){const{width:r,isResizing:a,onMouseDown:i,onDoubleClick:s}=k({storageKey:I,defaultWidth:T,min:E,max:X,side:"left",enabled:t});return t?e.jsxs("aside",{className:"relative flex h-full shrink-0 flex-col border-l border-border bg-popover",style:{width:`${r}px`},children:[e.jsx("div",{onMouseDown:i,onDoubleClick:s,className:u("absolute left-0 top-0 z-30 h-full w-px cursor-col-resize","bg-transparent hover:bg-brand/60 transition-colors",a&&"bg-brand"),"aria-label":"Resize artifacts panel",title:"Drag to resize · double-click to reset",children:e.jsx("div",{className:"absolute inset-y-0 -left-2 -right-2"})}),e.jsx(Y,{onClose:o})]}):null}function Y({onClose:t}){const o=_(n=>n.items),r=b(n=>n.selectedToolCallId),a=b(n=>n.select),i=c.useMemo(()=>P(o),[o]),s=R(i,r)??B(i),[d,x]=c.useState("preview"),N=s==null?void 0:s.toolCallId;if(c.useEffect(()=>{x("preview")},[N]),!s)return e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"Artifacts",onClose:t}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-8 text-center",children:[e.jsx(y,{className:"h-6 w-6 text-muted-foreground/50"}),e.jsxs("p",{className:"text-[12.5px] leading-relaxed text-muted-foreground",children:["No artifacts yet. When the agent publishes one with"," ",e.jsx("span",{className:"font-mono text-[11.5px]",children:"create_artifact"}),", it shows up here."]})]})]});const p=D(i),f=W(i,s.id),l=z(i,s),m=n=>{const C=f.findIndex(A=>A.toolCallId===s.toolCallId),h=f[C+n];h&&a(h.toolCallId)};return e.jsxs(e.Fragment,{children:[e.jsx(j,{title:s.title,onClose:t}),p.length>1&&e.jsx("div",{className:"flex gap-1 overflow-x-auto border-b border-border-soft px-2 py-1.5",children:p.map(n=>e.jsx("button",{type:"button",onClick:()=>a(n.toolCallId),title:n.title,className:u("max-w-[160px] shrink-0 truncate rounded-md px-2 py-0.5 text-[11.5px] font-medium transition-colors",n.id===s.id?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:n.title},n.id))}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-border-soft px-3 py-1.5",children:[e.jsx(F,{tone:"ghost",children:s.type}),l.count>1&&e.jsxs("div",{className:"flex items-center gap-0.5 text-muted-foreground",children:[e.jsx(w,{dir:"prev",disabled:l.index<=1,onClick:()=>m(-1)}),e.jsxs("span",{className:"font-mono text-[11px] tabular-nums",children:["v",l.index,"/",l.count]}),e.jsx(w,{dir:"next",disabled:l.index>=l.count,onClick:()=>m(1)})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(s.type==="html"||s.type==="svg")&&e.jsxs("div",{className:"flex items-center gap-0.5 rounded-md border border-border-soft bg-card p-0.5 text-[11px] font-medium",children:[e.jsx(v,{active:d==="preview",onClick:()=>x("preview"),icon:e.jsx(H,{className:"h-3 w-3"}),label:"Preview"}),e.jsx(v,{active:d==="code",onClick:()=>x("code"),icon:e.jsx(M,{className:"h-3 w-3"}),label:"Code"})]}),e.jsx(J,{content:s.content})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(q,{record:s,view:d})})]})}function q({record:t,view:o}){const{type:r,content:a,language:i}=t;return r==="markdown"?e.jsx("div",{className:"px-4 py-3",children:e.jsx(G,{text:a})}):r==="code"?e.jsx(g,{code:a,lang:i,className:"px-4 py-3"}):o==="code"?e.jsx(g,{code:a,lang:r,className:"px-4 py-3"}):e.jsx(Q,{code:a,lang:r})}function j({title:t,onClose:o}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[e.jsx(y,{className:"h-3.5 w-3.5 shrink-0 text-brand"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium text-foreground",title:t,children:t}),e.jsx(L,{title:"Close",onClick:o,"aria-label":"Close artifacts panel",children:e.jsx(S,{className:"h-3.5 w-3.5"})})]})}function v({active:t,onClick:o,icon:r,label:a}){return e.jsxs("button",{type:"button",onClick:o,"aria-pressed":t,className:u("flex items-center gap-1 rounded-[5px] px-1.5 py-0.5 transition-colors",t?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:text-foreground"),children:[r,a]})}function w({dir:t,disabled:o,onClick:r}){return e.jsx("button",{type:"button",onClick:r,disabled:o,"aria-label":t==="prev"?"Previous version":"Next version",className:"rounded p-0.5 transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",children:t==="prev"?e.jsx(K,{className:"h-3.5 w-3.5"}):e.jsx(O,{className:"h-3.5 w-3.5"})})}function J({content:t}){const o=U(s=>s.pushToast),[r,a]=c.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1200)}catch{o({id:`copy-${Date.now()}`,workspaceId:"",message:"Copy failed — clipboard not available",notifyType:"warning"})}};return e.jsx("button",{type:"button",onClick:i,title:"Copy content","aria-label":"Copy artifact content",className:"rounded-md border border-border-soft bg-card p-1 text-muted-foreground transition-colors hover:text-foreground",children:r?e.jsx(V,{className:"h-3 w-3 text-signal-ok"}):e.jsx($,{className:"h-3 w-3"})})}export{se as ArtifactsPanel};
@@ -0,0 +1,19 @@
1
+ import{j as e,r as x}from"./markdown-CY-Rm0E5.js";import{s as ee,D as te,X as _,K as se,J as re,a6 as ne,V as oe,a9 as ae,a8 as le,L as B,r as P,P as ie,$ as de,Z as ce,n as g,o as xe,I as F,R as me,N as ue,F as z,M as pe,k as he,j as ge,i as fe,p as be,a1 as je,T as Ne,aa as ye,a5 as ve}from"./index-CX2ohSDO.js";import"./shiki-BZ0sbaMe.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ke=ee("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);function we({workspaceId:t,request:s,onClose:r}){return e.jsxs(te,{open:!0,onClose:r,className:"m-4 h-full max-h-[90vh] w-full max-w-3xl",children:[e.jsx(Se,{kind:s.kind,mode:s.mode,onClose:r}),s.mode==="create"?e.jsx(Pe,{workspaceId:t,kind:s.kind,defaultScope:s.defaultScope,onDone:r}):e.jsx(Ce,{workspaceId:t,kind:s.kind,filePath:s.filePath,onDone:r})]})}function Se({kind:t,mode:s,onClose:r}){const a=s==="create"?t==="skill"?"New skill":"New prompt template":t==="skill"?"Edit skill":"Edit prompt template";return e.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:a}),e.jsx("button",{type:"button",onClick:r,className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":"Close editor",children:e.jsx(_,{className:"h-4 w-4"})})]})}function Pe({workspaceId:t,kind:s,defaultScope:r,onDone:a}){var v,k;const[o,l]=x.useState(r),[i,n]=x.useState(""),[d,u]=x.useState(""),[h,f]=x.useState(""),[m,b]=x.useState(!1),[c,p]=x.useState(s==="skill"?Ee:""),j=se(t),N=re(t),S=j.isPending||N.isPending,C=((v=j.error)==null?void 0:v.message)??((k=N.error)==null?void 0:k.message),y=async()=>{try{s==="skill"?await j.mutateAsync({scope:o,name:i.trim(),description:d.trim(),body:c,disableModelInvocation:m||void 0}):await N.mutateAsync({scope:o,name:i.trim(),description:d.trim(),argumentHint:h.trim()||void 0,body:c}),a()}catch{}},E=!S&&i.trim().length>0&&d.trim().length>0&&c.length>0;return e.jsx(O,{kind:s,scope:o,onScopeChange:l,scopeLocked:!1,name:i,onNameChange:n,description:d,onDescriptionChange:u,argumentHint:h,onArgumentHintChange:f,disableModelInvocation:m,onDisableModelInvocationChange:b,body:c,onBodyChange:p,submitLabel:"Create",canSubmit:E,pending:S,error:C,onSubmit:y,onCancel:a})}function Ce({workspaceId:t,kind:s,filePath:r,onDone:a}){var R,H,I;const o=ne(t,s==="skill"?r:void 0),l=oe(t,s==="prompt"?r:void 0),i=s==="skill"?o.data:l.data,n=(R=s==="skill"?o.error:l.error)==null?void 0:R.message,d=s==="skill"?o.isLoading:l.isLoading,[u,h]=x.useState(!1),[f]=x.useState(void 0),[m,b]=x.useState(""),[c,p]=x.useState(""),[j,N]=x.useState(""),[S,C]=x.useState(!1),[y,E]=x.useState("");x.useEffect(()=>{!i||u||(b(i.name),p(i.description),N(i.argumentHint??""),C(!!i.disableModelInvocation),E(i.body),h(!0))},[i,u]);const v=ae(t),k=le(t),$=v.isPending||k.isPending,Q=((H=v.error)==null?void 0:H.message)??((I=k.error)==null?void 0:I.message),Y=async()=>{try{s==="skill"?await v.mutateAsync({filePath:r,name:m.trim(),description:c.trim(),body:y,disableModelInvocation:S||void 0}):await k.mutateAsync({filePath:r,name:m.trim(),description:c.trim(),argumentHint:j.trim()||void 0,body:y}),a()}catch{}};if(d)return e.jsxs("div",{className:"flex flex-1 items-center justify-center text-muted-foreground",children:[e.jsx(B,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"ml-2 text-xs",children:"Loading file\\u2026"})]});if(n||!i)return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-4 text-xs text-signal-error",children:[e.jsx("p",{children:n??"Failed to load file"}),e.jsx("button",{type:"button",onClick:a,className:"rounded-md border border-input bg-background px-3 py-1.5 text-foreground",children:"Close"})]});const q=u&&!$&&m.trim().length>0&&c.trim().length>0&&y.length>0;return e.jsx(O,{kind:s,scope:f??i.scope,onScopeChange:()=>{},scopeLocked:!0,scopeLockedReason:"Move the file on disk to change scope.",name:m,onNameChange:b,description:c,onDescriptionChange:p,argumentHint:j,onArgumentHintChange:N,disableModelInvocation:S,onDisableModelInvocationChange:C,body:y,onBodyChange:E,filePath:i.filePath,submitLabel:"Save",canSubmit:q,pending:$,error:Q,onSubmit:Y,onCancel:a})}function O(t){return e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),t.canSubmit&&t.onSubmit()},children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-4",children:[t.filePath&&e.jsx("p",{className:"truncate font-mono text-[10px] text-muted-foreground",title:t.filePath,children:t.filePath}),e.jsxs(w,{label:"Scope",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx(U,{active:t.scope==="project",onClick:()=>t.onScopeChange("project"),disabled:t.scopeLocked,children:"Project"}),e.jsx(U,{active:t.scope==="user",onClick:()=>t.onScopeChange("user"),disabled:t.scopeLocked,children:"User"})]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:t.scopeLocked?t.scopeLockedReason??"Scope is fixed for existing files.":t.scope==="project"?`Lives in <workspace>/.pi/${t.kind==="skill"?"skills":"prompts"}/`:`Lives in ~/.pi/agent/${t.kind==="skill"?"skills":"prompts"}/`})]}),e.jsxs(w,{label:t.kind==="skill"?"Name":"Name (becomes /name)",children:[e.jsx("input",{type:"text",value:t.name,onChange:s=>t.onNameChange(s.target.value),placeholder:t.kind==="skill"?"pdf-tools":"review-pr",className:"w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm font-mono outline-none focus:ring-1 focus:ring-ring"}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Lowercase a-z, 0-9, hyphens",t.kind==="prompt"?" or underscores":"","; 1\\u201364 chars."]})]}),e.jsx(w,{label:"Description",children:e.jsx("textarea",{value:t.description,onChange:s=>t.onDescriptionChange(s.target.value),rows:2,placeholder:t.kind==="skill"?"What this skill does and when to use it. Be specific.":"What this prompt template does.",className:"w-full resize-y rounded-md border border-input bg-background px-3 py-1.5 text-sm outline-none focus:ring-1 focus:ring-ring"})}),t.kind==="skill"?e.jsx(w,{label:"",children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t.disableModelInvocation,onChange:s=>t.onDisableModelInvocationChange(s.target.checked),className:"mt-0.5 accent-primary"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Manual invocation only"}),e.jsxs("span",{className:"block text-muted-foreground",children:["Hide from the system prompt. Users must explicitly run /skill:",t.name||"name","."]})]})]})}):e.jsxs(w,{label:"Argument hint (optional)",children:[e.jsx("input",{type:"text",value:t.argumentHint,onChange:s=>t.onArgumentHintChange(s.target.value),placeholder:"<file> [--flag]",className:"w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm font-mono outline-none focus:ring-1 focus:ring-ring"}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Shown in autocomplete, e.g. ",e.jsx("code",{className:"font-mono",children:"<PR-URL>"}),"."]})]}),e.jsxs(w,{label:"Body (markdown)",children:[e.jsx("textarea",{value:t.body,onChange:s=>t.onBodyChange(s.target.value),rows:14,spellCheck:!1,className:"w-full resize-y rounded-md border border-input bg-background px-3 py-1.5 text-sm font-mono outline-none focus:ring-1 focus:ring-ring"}),t.kind==="prompt"&&e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Use ",e.jsx("code",{className:"font-mono",children:"$1"}),", ",e.jsx("code",{className:"font-mono",children:"$2"}),", ",e.jsx("code",{className:"font-mono",children:"$@"}),", ",e.jsxs("code",{className:"font-mono",children:["$","{@:N}"]}),", ",e.jsxs("code",{className:"font-mono",children:["$","{@:N:L}"]})," for arguments."]})]}),t.error&&e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-3 py-1.5 text-xs text-signal-error",children:t.error})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-2",children:[e.jsx("button",{type:"button",onClick:t.onCancel,disabled:t.pending,className:"rounded-md border border-input bg-background px-3 py-1.5 text-sm text-foreground hover:bg-accent disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:!t.canSubmit,className:"inline-flex items-center gap-1 rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground disabled:opacity-50",children:[t.pending&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),t.submitLabel]})]})]})}function w({label:t,children:s}){return e.jsxs("div",{children:[t&&e.jsx("label",{className:"mb-1 block text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),s]})}function U({active:t,disabled:s,onClick:r,children:a}){return e.jsx("button",{type:"button",onClick:r,disabled:s,className:P("rounded-md border px-3 py-1 text-xs transition-colors",t?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-foreground hover:bg-accent",s&&"cursor-not-allowed opacity-60 hover:bg-background"),children:a})}const Ee=`# Skill name
7
+
8
+ Describe what the skill does, when to use it, and any setup steps.
9
+
10
+ ## Usage
11
+
12
+ \`\`\`bash
13
+ ./scripts/example.sh <input>
14
+ \`\`\`
15
+ `;function Ue({workspaceId:t,open:s,onClose:r}){return s?e.jsx("aside",{className:`flex h-full ${ie} shrink-0 flex-col border-l border-border bg-popover`,children:e.jsx(De,{workspaceId:t,onClose:r})}):null}function De({workspaceId:t,onClose:s}){const{data:r,isLoading:a,error:o}=de(t),l=ce(t),[i,n]=x.useState("skills"),[d,u]=x.useState(null),h=c=>u({kind:c,mode:"create",defaultScope:"project"}),f=(c,p)=>u({kind:c,mode:"edit",filePath:p}),m={skills:(r==null?void 0:r.skills.length)??0,prompts:(r==null?void 0:r.prompts.length)??0,extensions:((r==null?void 0:r.builtinExtensions.length)??0)+((r==null?void 0:r.extensions.filter(c=>c.source.label!=="inline").length)??0)},b=m.skills+m.prompts+m.extensions;return a?e.jsxs(e.Fragment,{children:[e.jsx(L,{total:0,onReload:()=>l.mutate(),reloading:l.isPending,onClose:s}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex gap-1 border-b border-border-soft px-3 pb-1 pt-2",children:[e.jsx(g,{className:"h-6 w-20 rounded-md"}),e.jsx(g,{className:"h-6 w-24 rounded-md"}),e.jsx(g,{className:"h-6 w-28 rounded-md"})]}),e.jsxs("div",{className:"flex-1 space-y-2 p-3",children:[e.jsx(g,{className:"h-7 w-24 rounded-md"}),Array.from({length:4}).map((c,p)=>e.jsxs("div",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(g,{className:"h-3.5 w-32"}),e.jsx(g,{className:"h-3 w-12 rounded-full"})]}),e.jsx(xe,{className:"mt-2",rows:2}),e.jsx(g,{className:"mt-2 h-2.5 w-40"})]},p))]})]})]}):o||!r?e.jsxs(e.Fragment,{children:[e.jsx(L,{total:0,onReload:()=>l.mutate(),reloading:l.isPending,onClose:s}),e.jsx("p",{className:"px-4 py-4 text-center text-[12.5px] text-signal-error",children:(o==null?void 0:o.message)??"Failed to load resources"})]}):e.jsxs(e.Fragment,{children:[e.jsx(L,{total:b,onReload:()=>l.mutate(),reloading:l.isPending,onClose:s}),l.isError&&e.jsx("p",{className:"border-b border-error-ghost bg-error-ghost px-4 py-1.5 text-[11.5px] text-signal-error",children:l.error.message}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex gap-1 border-b border-border-soft px-3 pb-1 pt-2",children:[e.jsx(T,{active:i==="skills",onClick:()=>n("skills"),label:"Skills",count:m.skills}),e.jsx(T,{active:i==="prompts",onClick:()=>n("prompts"),label:"Prompts",count:m.prompts}),e.jsx(T,{active:i==="extensions",onClick:()=>n("extensions"),label:"Extensions",count:m.extensions})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[i==="skills"&&e.jsx(Le,{workspaceId:t,skills:r.skills,onNew:()=>h("skill"),onEdit:c=>f("skill",c.filePath)}),i==="prompts"&&e.jsx(Te,{workspaceId:t,prompts:r.prompts,onNew:()=>h("prompt"),onEdit:c=>f("prompt",c.filePath)}),i==="extensions"&&e.jsx(Be,{workspaceId:t,builtinExtensions:r.builtinExtensions,extensionsEnabled:r.extensionsEnabled,extensions:r.extensions,errors:r.extensionErrors,disabledExtensions:r.disabledExtensions})]})]}),d&&e.jsx(we,{workspaceId:t,request:d,onClose:()=>u(null)})]})}function L({total:t,onReload:s,reloading:r,onClose:a}){return e.jsxs("header",{className:"flex h-[44px] items-center gap-1 border-b border-border-soft px-4",children:[e.jsxs("span",{className:"text-[13px] font-medium tracking-[-0.005em] text-foreground",children:["Resources",t>0&&e.jsx("span",{className:"ml-1.5 text-muted-foreground/60",children:t})]}),e.jsx("span",{className:"flex-1"}),e.jsx(F,{onClick:s,disabled:r,title:"Reload resources","aria-label":"Reload resources",children:e.jsx(me,{className:P("h-3.5 w-3.5",r&&"animate-spin")})}),e.jsx(F,{onClick:a,title:"Close","aria-label":"Close resources panel",children:e.jsx(_,{className:"h-3.5 w-3.5"})})]})}function T({active:t,onClick:s,label:r,count:a}){return e.jsxs("button",{type:"button",onClick:s,className:P("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ring-brand-focus",t?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[e.jsx("span",{children:r}),e.jsx("span",{className:"font-mono text-[10.5px] tabular-nums opacity-70",children:a})]})}function Le({workspaceId:t,skills:s,onNew:r,onEdit:a}){const o=ue(t),l=z(),i=async n=>{await l({title:"Delete skill",message:`Delete skill "${n.name}"?
16
+
17
+ This removes ${n.filePath} and any sibling files in its directory.`,confirmLabel:"Delete",variant:"danger"})&&o.mutate({filePath:n.filePath})};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(G,{label:"New skill",onClick:r}),o.isError&&e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-2.5 py-1.5 text-[11.5px] text-signal-error",children:o.error.message}),s.length===0?e.jsx(Z,{text:"No skills discovered."}):e.jsx("ul",{className:"flex flex-col gap-2",children:s.map(n=>{var d;return e.jsxs("li",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5 transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:n.name}),e.jsx(A,{source:n.source})]}),n.description&&e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:n.description}),n.disableModelInvocation&&e.jsxs("p",{className:"mt-1 text-[11.5px] italic text-muted-foreground",children:["Manual invocation only (/skill:",n.name,")"]}),e.jsx(M,{path:n.filePath}),n.managed?e.jsx(K,{onEdit:()=>a(n),onDelete:()=>i(n),deleting:o.isPending&&((d=o.variables)==null?void 0:d.filePath)===n.filePath}):e.jsx(J,{kind:"skill",source:n.source})]},n.filePath)})})]})}function Te({workspaceId:t,prompts:s,onNew:r,onEdit:a}){const o=pe(t),l=z(),i=async n=>{await l({title:"Delete prompt",message:`Delete prompt template /${n.name}?
18
+
19
+ ${n.filePath}`,confirmLabel:"Delete",variant:"danger"})&&o.mutate({filePath:n.filePath})};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(G,{label:"New prompt",onClick:r}),o.isError&&e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-2.5 py-1.5 text-[11.5px] text-signal-error",children:o.error.message}),s.length===0?e.jsx(Z,{text:"No prompt templates discovered."}):e.jsx("ul",{className:"flex flex-col gap-2",children:s.map(n=>{var d;return e.jsxs("li",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5 transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("span",{className:"truncate text-[13px] font-medium text-foreground",children:["/",n.name,n.argumentHint&&e.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:n.argumentHint})]}),e.jsx(A,{source:n.source})]}),n.description&&e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:n.description}),e.jsxs("details",{className:"mt-1.5 text-[12px]",children:[e.jsx("summary",{className:"cursor-pointer select-none rounded px-1 -mx-1 text-muted-foreground hover:text-foreground",children:"View template"}),e.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-md border border-border-soft bg-muted p-2 font-mono text-[11.5px] leading-relaxed text-foreground",children:n.content})]}),e.jsx(M,{path:n.filePath}),n.managed?e.jsx(K,{onEdit:()=>a(n),onDelete:()=>i(n),deleting:o.isPending&&((d=o.variables)==null?void 0:d.filePath)===n.filePath}):e.jsx(J,{kind:"prompt",source:n.source})]},n.filePath)})})]})}function Be({workspaceId:t,builtinExtensions:s,extensionsEnabled:r,extensions:a,errors:o,disabledExtensions:l}){const i=a.filter(n=>n.source.label!=="inline");return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Me,{workspaceId:t,builtins:s}),e.jsx(Ae,{workspaceId:t}),e.jsx($e,{extensionsEnabled:r,extensions:i,errors:o,disabledExtensions:l})]})}function Ae({workspaceId:t}){var i,n;const{data:s}=ye(),r=ve(),a=s==null?void 0:s.find(d=>d.id===t);if(!a)return null;const o=r.isPending&&((i=r.variables)==null?void 0:i.id)===a.id,l=o?((n=r.variables)==null?void 0:n.trustProjectAgents)??a.trustProjectAgents:a.trustProjectAgents;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx(D,{children:"Project agents"}),r.isError&&e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-2.5 py-1.5 text-[11.5px] text-signal-error",children:r.error.message}),e.jsxs("div",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5 transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"truncate text-[13px] font-medium text-foreground",children:["Trust ",e.jsx("span",{className:"font-mono text-[12px]",children:".pi/agents/"})," in this workspace"]}),e.jsx(V,{checked:l,disabled:o,onChange:d=>r.mutate({id:a.id,trustProjectAgents:d}),label:`${l?"Distrust":"Trust"} project agents`})]}),e.jsxs("p",{className:"mt-1 text-[12px] leading-relaxed text-muted-foreground",children:["When on, the subagent roster also loads agent definitions from this repo's ",e.jsx("span",{className:"font-mono text-[11px]",children:".pi/agents/*.md"})," ","(highest precedence). Off by default: repo files define subagent system prompts, so only enable this for repositories you trust."]})]})]})}function Me({workspaceId:t,builtins:s}){var o;const r=je(t),a=r.isPending?(o=r.variables)==null?void 0:o.id:void 0;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx(D,{children:"Built-in"}),e.jsx("p",{className:"text-[11.5px] leading-relaxed text-muted-foreground/80",children:"Master switches that apply to every conversation — turning one off removes its tools and commands everywhere. To keep an extension on but hide individual tools in a single conversation, use Settings → Session → Tools."}),r.isError&&e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-2.5 py-1.5 text-[11.5px] text-signal-error",children:r.error.message}),e.jsx("ul",{className:"flex flex-col gap-2",children:s.map(l=>{const i=a===l.id,n=i&&r.variables?r.variables.enabled:l.enabled;return e.jsxs("li",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5 transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Ne,{tool:l.id,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:l.name})]}),e.jsx(V,{checked:n,disabled:i,onChange:d=>r.mutate({id:l.id,enabled:d}),label:`${n?"Disable":"Enable"} ${l.name}`})]}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-muted-foreground",children:l.description}),e.jsx(X,{facets:[{label:"tools",items:l.tools},{label:"commands",items:l.commands.map(d=>`/${d}`)}].filter(d=>d.items.length>0)})]},l.id)})})]})}function V({checked:t,disabled:s,onChange:r,label:a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":a,title:a,disabled:s,onClick:()=>r(!t),className:P("relative inline-flex h-[18px] w-[32px] shrink-0 items-center rounded-full border transition-colors ring-brand-focus disabled:cursor-not-allowed disabled:opacity-60",t?"border-brand-subtle bg-brand":"border-border bg-muted"),children:e.jsx("span",{className:P("inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-[15px]":"translate-x-[2px]")})})}function $e({extensionsEnabled:t,extensions:s,errors:r,disabledExtensions:a}){return t?e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx(D,{children:"Third-party"}),s.length===0&&r.length===0&&e.jsxs("div",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-3",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"Extensions enabled, none installed"}),e.jsxs("p",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:[e.jsx("code",{className:"rounded bg-muted px-1 font-mono",children:"PI_PILOT_ENABLE_EXTENSIONS=1"})," is set but no extension modules were discovered under"," ",e.jsx("code",{className:"rounded bg-muted px-1 font-mono",children:"~/.pi/agent/extensions/"})," or"," ",e.jsx("code",{className:"rounded bg-muted px-1 font-mono",children:".pi/extensions/"}),"."]})]}),r.map(o=>e.jsxs("div",{className:"rounded-[10px] border border-error-ghost bg-error-ghost px-3 py-2.5 text-[12px] text-signal-error",children:[e.jsx("p",{className:"text-[11.5px] font-medium",children:"Failed to load"}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-signal-error/80",children:o.path}),e.jsx("p",{className:"mt-1 break-words",children:o.error})]},o.path)),s.map(o=>e.jsxs("div",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-2.5 transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:W(o.path)}),e.jsx(A,{source:o.source})]}),e.jsx(Re,{ext:o}),e.jsx(M,{path:o.resolvedPath})]},o.resolvedPath))]}):e.jsxs("section",{className:"flex flex-col gap-3",children:[e.jsx(D,{children:"Third-party"}),e.jsxs("div",{className:"rounded-[10px] border border-border-soft bg-card px-3 py-3",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"Third-party extensions are not supported"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:"The pi extension system is built for a terminal UI (custom renderers, ANSI themes, keyboard overlays). These APIs cannot be bridged to the Web in any meaningful way, so pi-pilot does not load extensions from disk by default."}),e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-muted-foreground",children:"Skills, prompts, and the built-in extensions above work as usual; only third-party extension modules are skipped."})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("p",{className:"px-1 text-[12px] font-medium text-muted-foreground",children:"Detected but disabled"}),a.map(o=>e.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] border border-border-soft bg-muted/50 px-2.5 py-1.5",title:o,children:[e.jsx(ke,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:W(o)})]},o))]})]})}function D({children:t}){return e.jsx("h3",{className:"text-[11.5px] font-medium text-muted-foreground",children:t})}function Re({ext:t}){const s=[{label:"tools",items:t.tools},{label:"commands",items:t.commands.map(r=>`/${r}`)},{label:"flags",items:t.flags.map(r=>`--${r}`)},{label:"shortcuts",items:t.shortcuts}].filter(r=>r.items.length>0);return s.length===0?e.jsx("p",{className:"mt-1.5 text-[11.5px] italic text-muted-foreground",children:"No registrations."}):e.jsx(X,{facets:s})}function X({facets:t}){return e.jsx("dl",{className:"mt-1.5 flex flex-col gap-1 text-[11.5px]",children:t.map(s=>e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("dt",{className:"shrink-0 text-muted-foreground",children:[s.label,":"]}),e.jsx("dd",{className:"flex flex-wrap gap-1",children:s.items.map(r=>e.jsx("span",{className:"rounded border border-border-soft bg-muted px-1.5 py-px font-mono text-[10.5px] text-foreground",children:r},r))})]},s.label))})}function G({label:t,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,className:"group inline-flex items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-transparent px-2 py-2 text-[12px] font-medium text-muted-foreground transition-colors hover:border-brand-subtle hover:text-brand ring-brand-focus",children:[e.jsx(he,{className:"h-3 w-3 transition-transform group-hover:rotate-90"}),t]})}function J({kind:t,source:s}){return e.jsxs("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:["Read-only · ",t," from ",s.label]})}function K({onEdit:t,onDelete:s,deleting:r}){return e.jsxs("div",{className:"mt-2 flex justify-end gap-1.5",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1 text-[11.5px] font-medium text-foreground transition-colors hover:border-brand-subtle hover:text-brand ring-brand-focus",children:[e.jsx(fe,{className:"h-3 w-3"})," Edit"]}),e.jsxs("button",{type:"button",onClick:s,disabled:r,className:"inline-flex items-center gap-1.5 rounded-md border border-error-ghost bg-card px-2.5 py-1 text-[11.5px] font-medium text-signal-error transition-colors hover:bg-error-ghost disabled:opacity-50 ring-brand-focus",children:[r?e.jsx(B,{className:"h-3 w-3 animate-spin"}):e.jsx(be,{className:"h-3 w-3"})," ","Delete"]})]})}function A({source:t}){const s=t.scope==="user"?"default":t.scope==="project"?"brand":"warn";return e.jsx(ge,{tone:s,className:"shrink-0",children:e.jsx("span",{title:t.label,children:t.scope})})}function M({path:t}){return e.jsx("p",{className:"mt-1.5 truncate font-mono text-[10.5px] tracking-[-0.005em] text-muted-foreground",title:t,children:t})}function Z({text:t}){return e.jsx("p",{className:"py-8 text-center text-[12.5px] text-muted-foreground",children:t})}function W(t){return t.replace(/\/+$/,"").split("/").at(-1)||t}export{Ue as ResourcesPanel};
@@ -0,0 +1,16 @@
1
+ import{r as l,j as n}from"./markdown-CY-Rm0E5.js";import{s as D,y as L,a0 as Y,ad as O,Q as Z,P as ee,G as X,L as q,I as V,X as te,f as ne,d as se,r as j}from"./index-CX2ohSDO.js";import"./shiki-BZ0sbaMe.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const re=D("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ae=D("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ie=D("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function oe(e,a,o=null){if(a==="all")return e.slice();const s=new Set;for(const c of e)(le(c,a)||c.id===o)&&s.add(c.id);const i=new Map;for(const c of e)i.set(c.id,c);const u=a==="labeled",r=new Set(s);for(const c of s){let d=i.get(c);for(;d!=null&&d.parentId;){const p=i.get(d.parentId);if(!p)break;(u||p.childCount>1)&&r.add(p.id),d=p}}return e.filter(c=>r.has(c.id))}function le(e,a){switch(a){case"default":return G(e)||ce(e)&&ue(e)||e.entryType==="compaction"||e.entryType==="branch_summary"||e.label!=null;case"user-only":return G(e);case"labeled":return e.label!=null;case"all":return!0}}function G(e){return e.entryType==="message"&&e.messageRole==="user"}function ce(e){return e.entryType==="message"&&e.messageRole==="assistant"}function ue(e){return e.preview.trim().length>0}function M(e){const a=new Map;for(const o of e)a.set(o.id,o);return a}function de(e,a=M(e)){const o=new Map;for(const s of e){if(!s.parentId){o.set(s.id,0);continue}const i=a.get(s.parentId);if(!i){o.set(s.id,0);continue}const u=o.get(i.id)??0;i.childCount>1&&!s.active?o.set(s.id,u+1):o.set(s.id,u)}return o}function pe(e,a,o=M(e)){const s=new Map;for(const i of e){if(!i.parentId){s.set(i.id,!0);continue}const u=o.get(i.parentId);if(!u){s.set(i.id,!0);continue}const r=s.get(u.id)??!0,d=!(u.childCount>1&&!i.active)||a.has(u.id);s.set(i.id,r&&d)}return s}function fe(e,a=M(e)){const o=new Map;for(const s of e){if(!s.parentId||s.active)continue;const i=a.get(s.parentId);!i||i.childCount<=1||o.set(s.parentId,(o.get(s.parentId)??0)+1)}return o}function me(e,a){if(e==="message")switch(a){case"user":return"User";case"assistant":return"Assistant";case"toolResult":return"Tool result";case"bashExecution":return"Bash";case"custom":return"Extension";case"branchSummary":return"Branch summary";case"compactionSummary":return"Compaction summary";default:return"Message"}switch(e){case"compaction":return"Compaction";case"branch_summary":return"Branch summary";case"model_change":return"Model change";case"thinking_level_change":return"Thinking";case"custom":return"Custom";case"custom_message":return"Extension";case"label":return"Label";case"session_info":return"Session info";default:return e}}function xe(e,a,o){const s=o?"":" opacity-50";if(e==="message")switch(a){case"user":return"text-brand"+s;case"assistant":return"text-foreground"+s;default:return"text-muted-foreground"+s}switch(e){case"compaction":return"text-signal-warn"+s;case"branch_summary":return"text-signal-ok"+s;default:return"text-muted-foreground"+s}}const he=[{value:"default",label:"Default"},{value:"user-only",label:"User only"},{value:"all",label:"All entries"},{value:"labeled",label:"Labeled"}];function Ne({workspaceId:e,open:a,onClose:o}){const s=L(t=>t.running),i=L(t=>t.switching),u=L(t=>t.setSwitching),{data:r,isFetching:c}=Y(e,a),[d,p]=l.useState("user-only"),[h,x]=l.useState(null),[g,v]=l.useState(()=>new Set),f=l.useRef(null),C=l.useRef(0);l.useEffect(()=>()=>{var t;(t=f.current)==null||t.call(f),f.current=null},[]);const k=l.useMemo(()=>r?oe(r.nodes,d,r.leafId):[],[r,d]),b=l.useMemo(()=>r?M(r.nodes):new Map,[r]),z=l.useMemo(()=>r?de(r.nodes,b):new Map,[r,b]),J=l.useMemo(()=>r?fe(r.nodes,b):new Map,[r,b]),T=l.useMemo(()=>r?r.nodes.filter(t=>t.childCount>1).map(t=>t.id):[],[r]),S=T.some(t=>g.has(t)),R=l.useMemo(()=>r?pe(r.nodes,g,b):new Map,[r,g,b]),E=l.useMemo(()=>k.filter(t=>R.get(t.id)??!0),[k,R]),w=l.useMemo(()=>{let t=null;for(const m of(r==null?void 0:r.nodes)??[])(!t||m.timestamp>t.timestamp)&&(t=m);return t},[r]),Q=l.useCallback(t=>{v(m=>{const y=new Set(m);return y.has(t)?y.delete(t):y.add(t),y})},[]),$=l.useCallback(()=>v(new Set(T)),[T]),W=l.useCallback(()=>v(new Set),[]),A=l.useCallback(t=>{var U;if(s||i||h)return;const m=++C.current;x(t.id),u(!0),O.send({type:"navigate_tree",workspaceId:e,targetId:t.id}),(U=f.current)==null||U.call(f);const y=setTimeout(()=>{m===C.current&&(x(null),u(!1),N())},3e4),K=O.on(I=>{if(I.type==="navigate_tree_result"){if(m!==C.current)return;x(null),I.cancelled&&Z.getState().pushToast({id:`nav-cancelled-${Date.now()}`,workspaceId:e,message:"Tree navigation was cancelled.",notifyType:"info"}),N();return}if(I.type==="error"&&I.command==="navigate_tree"){if(m!==C.current)return;x(null),u(!1),N()}}),N=()=>{clearTimeout(y),K(),f.current===N&&(f.current=null)};f.current=N},[e,s,i,h,u]);if(!a)return null;const P=s||i||!!h,B=!w||w.id===(r==null?void 0:r.leafId),_=!!r&&r.nodes.some(t=>t.entryType==="message");return n.jsxs("aside",{className:`flex h-full ${ee} shrink-0 flex-col border-l border-border bg-popover`,children:[n.jsxs("header",{className:"flex h-[44px] items-center justify-between border-b border-border-soft px-4",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-medium tracking-[-0.005em] text-foreground",children:[n.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{children:"Session Tree"}),c&&n.jsx(q,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),n.jsxs("div",{className:"flex items-center gap-0.5",children:[w&&n.jsx(V,{onClick:()=>{w&&A(w)},disabled:P||B,title:B?"Already at the latest":"Jump to latest",children:n.jsx(re,{className:"h-3.5 w-3.5"})}),n.jsx(V,{onClick:o,title:"Close",children:n.jsx(te,{className:"h-3.5 w-3.5"})})]})]}),n.jsxs("div",{className:"flex items-center gap-2 border-b border-border-soft px-3 py-1.5",children:[n.jsx(ae,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("select",{value:d,onChange:t=>p(t.target.value),className:"flex-1 bg-transparent text-[11.5px] text-foreground outline-none",children:he.map(t=>n.jsx("option",{value:t.value,children:t.label},t.value))}),T.length>0&&n.jsx("button",{type:"button",onClick:S?W:$,title:S?"Collapse all branches":"Expand all branches",className:"shrink-0 rounded px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground ring-brand-focus",children:S?"Collapse all":"Expand all"}),r&&n.jsxs("span",{className:"shrink-0 font-mono text-[10.5px] tabular-nums text-muted-foreground",children:[E.length,"/",r.nodes.length]})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[!r&&!c&&n.jsx(F,{children:"No session tree available."}),r&&!_&&n.jsx(F,{children:"No conversation yet — send a message and it’ll appear here."}),_&&k.length===0&&n.jsx(F,{children:"Nothing matches this filter — try “All entries”."}),_&&k.length>0&&E.length===0&&n.jsxs("div",{className:"px-4 py-6 text-center text-[11.5px] leading-relaxed text-muted-foreground",children:["Matching entries are inside collapsed branches."," ",n.jsx("button",{type:"button",onClick:$,className:"rounded font-medium text-brand transition-colors hover:underline ring-brand-focus",children:"Expand all"})]}),E.map(t=>n.jsx(ge,{node:t,indent:z.get(t.id)??0,isFork:t.childCount>1,collapsed:t.childCount>1&&!g.has(t.id),hiddenCount:J.get(t.id)??0,onToggle:Q,isNavigating:h===t.id,disabled:P,onNavigate:A},t.id))]}),(s||i)&&n.jsx("div",{className:"border-t border-border-soft px-3 py-2 text-[10.5px] text-muted-foreground",children:s?"Navigation disabled while agent is running.":"Navigating…"})]})}function F({children:e}){return n.jsx("div",{className:"px-4 py-6 text-center text-[11.5px] leading-relaxed text-muted-foreground",children:e})}const H=14;function ge({node:e,indent:a,isFork:o,collapsed:s,hiddenCount:i,onToggle:u,isNavigating:r,disabled:c,onNavigate:d}){const p=e.isLeaf,h=xe(e.entryType,e.messageRole,e.active),x=me(e.entryType,e.messageRole),g=10+a*H,v=c||p;return n.jsxs("div",{className:j("group/tree-row relative flex w-full items-center text-left transition-colors","hover:bg-accent/60",p&&"bg-brand-ghost hover:bg-brand-subtle"),style:{paddingLeft:`${g}px`},children:[a>0&&n.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 w-px bg-border-soft",style:{left:`${10+(a-1)*H+5}px`}}),o?n.jsx("button",{type:"button",onClick:()=>u(e.id),"aria-expanded":!s,title:s?`Expand ${i} branch${i===1?"":"es"}`:"Collapse branches",className:"flex w-[18px] shrink-0 items-center justify-center self-stretch text-muted-foreground transition-colors hover:text-foreground ring-brand-focus",children:s?n.jsx(ne,{className:"h-3 w-3"}):n.jsx(se,{className:"h-3 w-3"})}):n.jsx("span",{"aria-hidden":!0,className:"w-[18px] shrink-0"}),n.jsxs("button",{type:"button",onClick:()=>d(e),disabled:v,"aria-current":p?"location":void 0,title:p?"Current position":c?"Navigation unavailable right now":`Navigate to this ${x.toLowerCase()}`,className:j("flex min-w-0 flex-1 items-center gap-2 py-[5px] pr-2.5 text-left","focus:outline-none focus-visible:bg-accent/60","disabled:cursor-default"),children:[n.jsx("span",{className:j("h-[7px] w-[7px] shrink-0 rounded-full bg-current",h)}),n.jsx("span",{className:j("shrink-0 text-[9.5px] font-medium uppercase tracking-wide",e.active?"text-muted-foreground":"text-muted-foreground/60"),children:x}),o&&n.jsxs("span",{title:`${i} alternate branch${i===1?"":"es"}`,className:"inline-flex shrink-0 items-center gap-0.5 text-[9px] font-medium text-muted-foreground tabular-nums",children:[n.jsx(X,{className:"h-2.5 w-2.5"}),i]}),n.jsx("span",{className:j("min-w-0 flex-1 truncate text-[11px]",e.active?"text-foreground/90":"text-muted-foreground"),children:e.preview||"—"}),e.label&&n.jsx("span",{className:"shrink-0 rounded bg-brand-tint px-1 py-px text-[9px] font-medium text-brand",children:e.label}),p&&n.jsx(ie,{className:"h-3 w-3 shrink-0 text-brand"}),r&&n.jsx(q,{className:"h-3 w-3 shrink-0 animate-spin text-brand"}),n.jsx("span",{className:"shrink-0 font-mono text-[9.5px] tabular-nums text-muted-foreground opacity-0 transition-opacity group-hover/tree-row:opacity-100",children:be(e.timestamp)})]})]})}function be(e){const a=new Date(e);return Number.isNaN(a.getTime())?"":a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}export{Ne as SessionTree};
@@ -0,0 +1,51 @@
1
+ import{r as x,j as e}from"./markdown-CY-Rm0E5.js";import{s as v,W as le,Y as N,U as k,q as y,L as $,k as ie,F as fe,i as te,p as se,r as u,D as ve,l as ye,S as je,a7 as Ne,O as re,y as ne,z as ke,a2 as Se,d as we,C as Ce,a3 as Ee,a4 as Te}from"./index-CX2ohSDO.js";import"./shiki-BZ0sbaMe.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Le=v("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Pe=v("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ae=v("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const De=v("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ie=v("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const _e=v("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const qe=v("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Ke=v("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
42
+ * @license lucide-react v0.468.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Re=v("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
47
+ * @license lucide-react v0.468.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Fe=v("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),xe=["web-search"];function ue(s){s.invalidateQueries({queryKey:xe})}function Oe(){return le({queryKey:xe,queryFn:()=>y("/api/web-search")})}function Ue(){const s=N();return k({mutationFn:t=>y("/api/web-search",{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>ue(s)})}function We(){const s=N();return k({mutationFn:()=>y("/api/web-search",{method:"DELETE"}),onSuccess:()=>ue(s)})}const me=["model-configs"];function P(s){s.invalidateQueries({queryKey:me}),s.invalidateQueries({queryKey:["config"]})}function $e(){return le({queryKey:me,queryFn:()=>y("/api/model-configs")})}function ze(){const s=N();return k({mutationFn:t=>y("/api/model-configs/providers",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>P(s)})}function He(){const s=N();return k({mutationFn:t=>y(`/api/model-configs/providers?name=${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>P(s)})}function Je(){const s=N();return k({mutationFn:({provider:t,model:n})=>y(`/api/model-configs/providers/${encodeURIComponent(t)}/models`,{method:"POST",body:JSON.stringify({model:n})}),onSuccess:()=>P(s)})}function Be(){const s=N();return k({mutationFn:({provider:t,modelId:n,model:r})=>y(`/api/model-configs/providers/${encodeURIComponent(t)}/models/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({model:r})}),onSuccess:()=>P(s)})}function Ye(){const s=N();return k({mutationFn:({provider:t,modelId:n})=>y(`/api/model-configs/providers/${encodeURIComponent(t)}/models/${encodeURIComponent(n)}`,{method:"DELETE"}),onSuccess:()=>P(s)})}const oe=["anthropic-messages","openai-completions","openai-responses","azure-openai-responses","openai-codex-responses","mistral-conversations","bedrock-converse-stream","google-generative-ai","google-vertex"],b="h-8 w-full rounded-lg border border-border-soft bg-background px-2.5 text-[13px] text-foreground outline-none transition-colors focus:border-brand-subtle disabled:opacity-50",K="rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground";function Ge(){const{data:s,isLoading:t,error:n}=$e(),[r,o]=x.useState(null),[a,c]=x.useState(null);if(t)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-[12px] text-muted-foreground",children:[e.jsx($,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Loading…"})]});if(n||!s)return e.jsx("p",{className:"rounded-lg border border-error-ghost bg-error-ghost px-4 py-3 text-center text-[12px] text-signal-error",children:(n==null?void 0:n.message)??"Failed to load model config"});const d=Object.entries(s.config.providers);return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[12px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:["Providers · ",d.length]}),e.jsxs("button",{type:"button",onClick:()=>o({mode:"add"}),className:"flex h-8 items-center gap-1.5 rounded-lg bg-brand px-3 text-[13px] font-medium text-brand-foreground transition-colors hover:bg-brand-strong",children:[e.jsx(ie,{className:"h-3.5 w-3.5"})," Add provider"]})]}),d.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-card/40 px-4 py-10 text-center",children:[e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"No providers yet."}),e.jsx("button",{type:"button",onClick:()=>o({mode:"add"}),className:"mt-1.5 text-[13px] font-medium text-brand hover:underline",children:"Add your first provider"})]}):d.map(([l,i])=>e.jsx(Ve,{name:l,config:i,onEdit:()=>o({mode:"edit",name:l,config:i}),onAddModel:()=>c({provider:l,model:null}),onEditModel:p=>c({provider:l,model:p})},l)),r&&e.jsx(Qe,{initialName:r.mode==="edit"?r.name:"",initialConfig:r.mode==="edit"?r.config:null,onClose:()=>o(null)}),a&&e.jsx(Xe,{provider:a.provider,initialModel:a.model,onClose:()=>c(null)})]})}function Ve({name:s,config:t,onEdit:n,onAddModel:r,onEditModel:o}){const a=He(),c=Ye(),d=fe();return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border-soft bg-card",children:[e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13.5px] font-semibold text-foreground",children:s}),e.jsx("span",{className:"shrink-0 rounded-md bg-muted px-1.5 py-0.5 font-mono text-[10.5px] text-muted-foreground",children:t.api})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11.5px] text-muted-foreground",children:[e.jsx("span",{className:"truncate font-mono",children:t.baseUrl}),t.apiKey&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ae,{className:"h-3 w-3"}),e.jsx("span",{className:"font-mono",children:t.apiKey})]})]})]}),e.jsx("button",{type:"button",onClick:n,className:K,title:"Edit provider",children:e.jsx(te,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:async()=>{await d({title:"Delete provider",message:`Delete provider "${s}" and all its models?`,confirmLabel:"Delete",variant:"danger"})&&a.mutate(s)},className:u(K,"hover:bg-error-subtle hover:text-signal-error"),title:"Delete provider",children:e.jsx(se,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"border-t border-border-soft",children:[t.models.length===0?e.jsx("p",{className:"px-4 py-3 text-[12px] text-muted-foreground",children:"No models yet."}):t.models.map(l=>e.jsxs("div",{className:"group flex items-center gap-2.5 border-b border-border-soft/60 px-4 py-2 last:border-b-0 hover:bg-muted/40",children:[e.jsx("span",{className:"truncate text-[13px] text-foreground",children:l.name}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",children:l.id}),l.reasoning&&e.jsx("span",{className:"shrink-0 rounded-md bg-brand-tint px-1.5 py-0.5 text-[10px] font-medium text-brand",children:"Reasoning"}),e.jsxs("div",{className:"flex shrink-0 items-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{type:"button",onClick:()=>o(l),className:u(K,"p-1"),title:"Edit model",children:e.jsx(te,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:async()=>{await d({title:"Delete model",message:`Delete model "${l.name}"?`,confirmLabel:"Delete",variant:"danger"})&&c.mutate({provider:s,modelId:l.id})},className:u(K,"p-1 hover:bg-error-subtle hover:text-signal-error"),title:"Delete model",children:e.jsx(se,{className:"h-3 w-3"})})]})]},l.id)),e.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center gap-1.5 border-t border-border-soft px-4 py-2 text-[12px] font-medium text-brand/80 transition-colors hover:bg-brand-whisper hover:text-brand",children:[e.jsx(ie,{className:"h-3 w-3"})," Add model"]})]})]})}function Qe({initialName:s,initialConfig:t,onClose:n}){var T,_;const r=!!t,[o,a]=x.useState(s),[c,d]=x.useState((t==null?void 0:t.baseUrl)??""),l=!!(t!=null&&t.api)&&!oe.includes(t.api),[i,p]=x.useState(l?"__custom__":(t==null?void 0:t.api)??"anthropic-messages"),[f,A]=x.useState(l?t.api:""),[C,D]=x.useState(""),I=t==null?void 0:t.apiKey,[E,R]=x.useState(((T=t==null?void 0:t.compat)==null?void 0:T.forceAdaptiveThinking)===!0),S=ze(),[F,w]=x.useState(null),O=h=>{h.preventDefault(),w(null);const q=i==="__custom__"?f:i;if(!q)return w("API type is required.");if(!r&&!C.trim())return w("API key is required.");const j={...t==null?void 0:t.compat};E?j.forceAdaptiveThinking=!0:delete j.forceAdaptiveThinking;const U={baseUrl:c,api:q,apiKey:C.trim(),...Object.keys(j).length?{compat:j}:{},models:(t==null?void 0:t.models)??[]};S.mutate({name:o,provider:U},{onSuccess:n})};return e.jsxs(pe,{title:r?"Edit provider":"New provider",onClose:n,onSubmit:O,submitLabel:r?"Update":"Create",pending:S.isPending,error:F??((_=S.error)==null?void 0:_.message),children:[e.jsx(g,{label:"Name",required:!0,children:e.jsx("input",{value:o,onChange:h=>a(h.target.value),placeholder:"e.g. my-provider",disabled:r,className:u(b,"font-mono"),required:!0})}),e.jsx(g,{label:"Base URL",required:!0,children:e.jsx("input",{value:c,onChange:h=>d(h.target.value),placeholder:"https://api.example.com",className:u(b,"font-mono"),required:!0})}),e.jsxs(g,{label:"API type",required:!0,children:[e.jsxs("select",{value:i,onChange:h=>p(h.target.value),className:b,children:[oe.map(h=>e.jsx("option",{value:h,children:h},h)),e.jsx("option",{value:"__custom__",children:"Custom…"})]}),i==="__custom__"&&e.jsx("input",{value:f,onChange:h=>A(h.target.value),placeholder:"custom-api-type",className:u(b,"mt-2 font-mono"),required:!0})]}),e.jsx(g,{label:"API key",required:!r,children:e.jsx("input",{type:"password",value:C,onChange:h=>D(h.target.value),placeholder:r&&I?`Leave blank to keep ${I}`:"sk-…",className:u(b,"font-mono"),required:!r})}),e.jsx(he,{checked:E,onChange:R,label:"Force adaptive thinking"})]})}function Xe({provider:s,initialModel:t,onClose:n}){var Y,G,V,Q,X,Z,M;const r=!!t,[o,a]=x.useState((t==null?void 0:t.id)??""),[c,d]=x.useState((t==null?void 0:t.name)??""),[l,i]=x.useState((t==null?void 0:t.reasoning)??!0),[p,f]=x.useState(String((t==null?void 0:t.contextWindow)??2e5)),[A,C]=x.useState(String((t==null?void 0:t.maxTokens)??32e3)),[D,I]=x.useState(String(((Y=t==null?void 0:t.cost)==null?void 0:Y.input)??0)),[E,R]=x.useState(String(((G=t==null?void 0:t.cost)==null?void 0:G.output)??0)),[S,F]=x.useState(String(((V=t==null?void 0:t.cost)==null?void 0:V.cacheRead)??0)),[w,O]=x.useState(String(((Q=t==null?void 0:t.cost)==null?void 0:Q.cacheWrite)??0)),[T,_]=x.useState(((X=t==null?void 0:t.thinkingLevelMap)==null?void 0:X.high)??"high"),[h,q]=x.useState(((Z=t==null?void 0:t.thinkingLevelMap)==null?void 0:Z.xhigh)??"max"),[j,U]=x.useState(t!=null&&t.headers?JSON.stringify(t.headers,null,2):""),z=Je(),H=Be(),J=r?H:z,[ge,B]=x.useState(null),be=m=>{m.preventDefault(),B(null);let W;if(j.trim())try{W=JSON.parse(j)}catch{return B("Headers must be valid JSON.")}const ee={id:o,name:c,reasoning:l,input:["text"],contextWindow:Number(p),maxTokens:Number(A),cost:{input:Number(D),output:Number(E),cacheRead:Number(S),cacheWrite:Number(w)},...l?{thinkingLevelMap:{high:T,xhigh:h}}:{},...W?{headers:W}:{}};r?H.mutate({provider:s,modelId:t.id,model:ee},{onSuccess:n}):z.mutate({provider:s,model:ee},{onSuccess:n})};return e.jsxs(pe,{title:r?"Edit model":"New model",subtitle:s,onClose:n,onSubmit:be,submitLabel:r?"Update":"Create",pending:J.isPending,error:ge??((M=J.error)==null?void 0:M.message),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(g,{label:"Model ID",required:!0,children:e.jsx("input",{value:o,onChange:m=>a(m.target.value),placeholder:"claude-opus-4-8",disabled:r,className:u(b,"font-mono"),required:!0})}),e.jsx(g,{label:"Display name",required:!0,children:e.jsx("input",{value:c,onChange:m=>d(m.target.value),placeholder:"Claude Opus 4.8",className:b,required:!0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(g,{label:"Context window",children:e.jsx("input",{type:"number",value:p,onChange:m=>f(m.target.value),className:u(b,"font-mono")})}),e.jsx(g,{label:"Max tokens",children:e.jsx("input",{type:"number",value:A,onChange:m=>C(m.target.value),className:u(b,"font-mono")})})]}),e.jsx(he,{checked:l,onChange:i,label:"Supports reasoning"}),l&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(g,{label:"Thinking High maps to",children:e.jsx("input",{value:T,onChange:m=>_(m.target.value),placeholder:"high",className:b})}),e.jsx(g,{label:"Thinking XHigh maps to",children:e.jsx("input",{value:h,onChange:m=>q(m.target.value),placeholder:"max",className:b})})]}),e.jsxs("div",{className:"rounded-lg border border-border-soft p-3",children:[e.jsx("span",{className:"mb-2.5 block text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Cost · per million tokens"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(g,{label:"Input",children:e.jsx("input",{type:"number",step:"0.01",value:D,onChange:m=>I(m.target.value),className:u(b,"font-mono")})}),e.jsx(g,{label:"Output",children:e.jsx("input",{type:"number",step:"0.01",value:E,onChange:m=>R(m.target.value),className:u(b,"font-mono")})}),e.jsx(g,{label:"Cache read",children:e.jsx("input",{type:"number",step:"0.01",value:S,onChange:m=>F(m.target.value),className:u(b,"font-mono")})}),e.jsx(g,{label:"Cache write",children:e.jsx("input",{type:"number",step:"0.01",value:w,onChange:m=>O(m.target.value),className:u(b,"font-mono")})})]})]}),e.jsx(g,{label:"Custom headers (JSON)",children:e.jsx("textarea",{value:j,onChange:m=>U(m.target.value),placeholder:'{"User-Agent": "…"}',rows:3,className:"w-full resize-none rounded-lg border border-border-soft bg-background px-2.5 py-2 font-mono text-[13px] text-foreground outline-none transition-colors focus:border-brand-subtle"})})]})}function pe({title:s,subtitle:t,onClose:n,onSubmit:r,submitLabel:o,pending:a,error:c,children:d}){return e.jsx(ve,{open:!0,onClose:n,className:"max-h-[85vh] w-[520px] max-w-[92vw]",children:e.jsxs("form",{onSubmit:r,className:"flex max-h-[85vh] flex-col",children:[e.jsxs("header",{className:"flex shrink-0 items-baseline gap-2 border-b border-border-soft px-5 py-3.5",children:[e.jsx("span",{className:"text-[14px] font-semibold text-foreground",children:s}),t&&e.jsxs("span",{className:"font-mono text-[12px] text-muted-foreground",children:["· ",t]})]}),e.jsx("div",{className:"flex flex-col gap-3.5 overflow-y-auto px-5 py-4",children:d}),c&&e.jsx("p",{className:"mx-5 mb-1 shrink-0 rounded-md border border-error-ghost bg-error-ghost px-3 py-1.5 text-[12px] text-signal-error",children:c}),e.jsxs("footer",{className:"flex shrink-0 justify-end gap-2 border-t border-border-soft px-5 py-3",children:[e.jsx("button",{type:"button",onClick:n,className:"h-8 rounded-lg border border-border-soft px-4 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:a,className:"h-8 rounded-lg bg-brand px-4 text-[13px] font-medium text-brand-foreground transition-colors hover:bg-brand-strong disabled:opacity-50",children:a?"Saving…":o})]})]})})}function g({label:s,required:t,children:n}){return e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1.5 block text-[12px] font-medium text-muted-foreground",children:[s,t&&e.jsx("span",{className:"text-signal-error",children:" *"})]}),n]})}function he({checked:s,onChange:t,label:n}){return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:r=>t(r.target.checked),className:"h-3.5 w-3.5 accent-[hsl(var(--brand))]"}),e.jsx("span",{className:"text-[13px] text-foreground",children:n})]})}const ae=[{id:"general",label:"General",icon:_e},{id:"session",label:"Session",icon:Fe},{id:"models",label:"Models",icon:qe},{id:"web-search",label:"Web search",icon:Pe}];function pt({workspaceId:s,onBack:t}){var a;const[n,r]=x.useState("general"),[o]=x.useState(()=>{try{const c=localStorage.getItem(ye);if(c){const d=parseInt(c,10);if(!isNaN(d)&&d>=200)return d}}catch{}return je});return e.jsxs("div",{className:"flex h-full w-full bg-background",children:[e.jsxs("nav",{className:"flex shrink-0 flex-col border-r border-border bg-popover",style:{width:`${o}px`},children:[e.jsx("header",{className:"flex h-[60px] shrink-0 items-center gap-2 px-3",children:e.jsxs("button",{type:"button",onClick:t,className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[e.jsx(Le,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Back"})]})}),e.jsx("div",{className:"flex flex-1 flex-col gap-0.5 px-2 py-1",children:ae.map(c=>e.jsxs("button",{type:"button",onClick:()=>r(c.id),className:u("flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium transition-colors",n===c.id?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[e.jsx(c.icon,{className:"h-4 w-4"}),c.label]},c.id))})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[e.jsx("header",{className:"flex h-[60px] shrink-0 items-center border-b border-border-soft px-8",children:e.jsx("h1",{className:"text-[17px] font-semibold tracking-[-0.015em] text-foreground",children:((a=ae.find(c=>c.id===n))==null?void 0:a.label)??"Settings"})}),e.jsxs("div",{className:"mx-auto w-full max-w-2xl px-8 py-8",children:[n==="general"&&e.jsx(et,{}),n==="session"&&e.jsx(tt,{workspaceId:s}),n==="models"&&e.jsx(dt,{}),n==="web-search"&&e.jsx(ct,{})]})]})]})}const Ze=[{value:"system",label:"System",icon:De},{value:"light",label:"Light",icon:Re},{value:"dark",label:"Dark",icon:Ie}],Me=[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}];function et(){const{choice:s,setTheme:t}=Ne(),n=re(o=>o.density),r=re(o=>o.setDensity);return e.jsx("div",{className:"flex flex-col gap-5",children:e.jsx(L,{title:"Appearance",description:"How pi-pilot looks on this device. Stored locally — it doesn't sync.",children:e.jsxs(it,{children:[e.jsx(de,{label:"Theme",description:"Follow the system, or lock to light or dark.",children:e.jsx(ce,{options:Ze.map(o=>({value:o.value,label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(o.icon,{className:"h-3 w-3"}),e.jsx("span",{children:o.label})]})})),value:s,onChange:o=>t(o)})}),e.jsx(de,{label:"Density",description:"Comfortable spacing, or denser rows that fit more on screen.",children:e.jsx(ce,{options:Me.map(o=>({value:o.value,label:o.label})),value:n,onChange:o=>r(o)})})]})})})}function tt({workspaceId:s}){const t=ne(r=>r.sessionPath),n=ne(r=>r.running);return s?e.jsx(st,{workspaceId:s,sessionPath:t,running:n}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Ke,{className:"mb-3 h-8 w-8 text-muted-foreground/40"}),e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"Select a workspace first to configure the active session."})]})}function st({workspaceId:s,sessionPath:t,running:n}){const{data:r,isLoading:o,error:a}=ke(s,t);return o?e.jsxs("div",{className:"flex items-center justify-center py-16 text-[12px] text-muted-foreground",children:[e.jsx($,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Loading config…"})]}):a||!r?e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-4 py-3 text-center text-[12px] text-signal-error",children:(a==null?void 0:a.message)??"Failed to load config"}):e.jsxs("div",{className:"flex flex-col gap-5",children:[n&&e.jsx("p",{className:"rounded-md border border-brand-ghost bg-brand-ghost px-4 py-2 text-center text-[12px] text-brand",children:"Read-only while the agent is running"}),e.jsx(L,{title:"Model",children:e.jsx(rt,{workspaceId:s,currentModel:r.currentModel,availableModels:r.availableModels,disabled:n})}),e.jsx(L,{title:"Thinking level",children:e.jsx(ot,{workspaceId:s,level:r.thinkingLevel,availableLevels:r.availableThinkingLevels,disabled:n})}),e.jsx(L,{title:"Tools",children:e.jsx(at,{workspaceId:s,activeTools:r.activeTools,allTools:r.allTools,disabled:n})})]})}function rt({workspaceId:s,currentModel:t,availableModels:n,disabled:r}){const o=Se(s),[a,c]=x.useState(!1),d=x.useRef(null),l=t?`${t.provider}/${t.modelId}`:"";return x.useEffect(()=>{if(!a)return;const i=f=>{d.current&&!d.current.contains(f.target)&&c(!1)},p=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",i),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",p)}},[a]),e.jsxs("div",{ref:d,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>c(i=>!i),disabled:r||o.isPending,className:u("flex h-9 w-full items-center gap-2 rounded-lg border bg-card px-3.5 text-[13px] text-foreground transition-colors","disabled:cursor-not-allowed disabled:opacity-50",a?"border-brand-subtle":"border-border-soft hover:border-border"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:(t==null?void 0:t.name)??"Select model"}),e.jsx(we,{className:u("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",a&&"rotate-180")})]}),a&&e.jsx("div",{className:"absolute left-0 right-0 top-full z-50 mt-1 max-h-72 overflow-y-auto rounded-lg border border-border bg-popover shadow-panel",children:n.map(i=>{const p=`${i.provider}/${i.modelId}`,f=p===l;return e.jsxs("button",{type:"button",onClick:()=>{c(!1),f||o.mutate({provider:i.provider,modelId:i.modelId})},title:`${i.provider}/${i.modelId}`,className:u("flex w-full items-center gap-2.5 px-4 py-2 text-left text-[13px] transition-colors",f?"bg-brand-ghost text-brand-strong":"text-foreground hover:bg-accent/60"),children:[e.jsx(Ce,{className:u("h-3 w-3 shrink-0",f?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate",children:i.name}),e.jsxs("span",{className:u("truncate font-mono text-[11px]",f?"text-brand":"text-muted-foreground"),children:[i.provider,"/",i.modelId]})]})]},p)})}),o.isError&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-signal-error",children:o.error.message})]})}const nt={off:"Off",minimal:"Min",low:"Low",medium:"Med",high:"High",xhigh:"Max"};function ot({workspaceId:s,level:t,availableLevels:n,disabled:r}){const o=Ee(s);return n.length===0?e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"Current model has no thinking support."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-0.5 rounded-lg border border-border bg-card p-1",children:n.map(a=>e.jsx("button",{type:"button",onClick:()=>o.mutate({level:a}),disabled:r||o.isPending,className:u("min-w-0 flex-1 truncate rounded-md px-2 py-2 text-[12.5px] font-medium transition-colors",a===t?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:text-foreground",(r||o.isPending)&&"opacity-50"),children:nt[a]??a},a))}),o.isError&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-signal-error",children:o.error.message})]})}function at({workspaceId:s,activeTools:t,allTools:n,disabled:r}){const o=Te(s),a=new Set(t),c=(d,l)=>{const i=l?[...t,d]:t.filter(p=>p!==d);o.mutate({tools:i})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[t.length," of ",n.length," enabled"]}),e.jsx("p",{className:"text-[11.5px] leading-relaxed text-muted-foreground/80",children:"Applies to this conversation only. To turn an entire built-in extension and all its tools on or off across every conversation, use Resources → Extensions."})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:n.map(d=>e.jsx("li",{children:e.jsxs("label",{className:u("flex cursor-pointer items-start gap-3 rounded-lg border border-border-soft bg-card px-4 py-2.5 transition-colors hover:border-border",a.has(d.name)&&"border-brand-whisper bg-brand-whisper",(r||o.isPending)&&"pointer-events-none opacity-50"),children:[e.jsx("input",{type:"checkbox",checked:a.has(d.name),onChange:l=>c(d.name,l.target.checked),disabled:r||o.isPending,className:"mt-[3px] h-3.5 w-3.5 shrink-0 accent-[hsl(var(--brand))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-[12.5px] text-foreground",children:d.name}),d.builtinExtension&&e.jsx("span",{className:"rounded-full border border-border-soft bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground",children:d.builtinExtension})]}),d.description&&e.jsx("span",{className:"mt-0.5 block text-[12px] text-muted-foreground",children:d.description})]})]})},d.name))}),o.isError&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-signal-error",children:o.error.message})]})}function dt(){return e.jsx(Ge,{})}function ct(){const{data:s,isLoading:t,error:n}=Oe(),r=Ue(),o=We(),[a,c]=x.useState(""),d=a.trim(),l=()=>{d&&r.mutate({apiKey:d},{onSuccess:()=>c("")})},i=r.error??o.error;return e.jsx("div",{className:"flex flex-col gap-5",children:e.jsx(L,{title:"Tavily API key",children:t?e.jsxs("div",{className:"flex items-center justify-center py-8 text-[12px] text-muted-foreground",children:[e.jsx($,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Loading…"})]}):n?e.jsx("p",{className:"rounded-md border border-error-ghost bg-error-ghost px-4 py-3 text-center text-[12px] text-signal-error",children:n.message}):e.jsxs(e.Fragment,{children:[e.jsx(lt,{status:s}),e.jsxs("div",{className:"flex flex-col gap-2.5 rounded-lg border border-border-soft bg-card px-4 py-3",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted-foreground",children:(s==null?void 0:s.source)==="settings"?"Replace key":"Add key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"password",value:a,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&l()},placeholder:"tvly-…",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-lg border border-border-soft bg-background px-3 font-mono text-[13px] leading-none text-foreground outline-none transition-colors focus:border-brand-subtle"}),e.jsx("button",{type:"button",onClick:l,disabled:!d||r.isPending,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-lg bg-brand px-4 text-[13px] font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-40",children:r.isPending?"Saving…":"Save"})]}),(s==null?void 0:s.source)==="settings"&&e.jsx("button",{type:"button",onClick:()=>o.mutate(),disabled:o.isPending,className:"self-start text-[12px] font-medium text-muted-foreground transition-colors hover:text-signal-error disabled:opacity-50",children:o.isPending?"Removing…":"Remove saved key"}),i&&e.jsx("p",{className:"text-[11.5px] text-signal-error",children:i.message})]}),e.jsxs("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:["Powers the ",e.jsx("span",{className:"font-mono text-foreground",children:"web_search"})," and"," ",e.jsx("span",{className:"font-mono text-foreground",children:"web_fetch"})," tools. Get a free key at"," ",e.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noreferrer noopener",className:"text-brand hover:underline",children:"app.tavily.com"}),". A key saved here overrides the"," ",e.jsx("span",{className:"font-mono text-foreground",children:"TAVILY_API_KEY"})," environment variable."]})]})})})}function lt({status:s}){const t=(s==null?void 0:s.configured)??!1,n=(s==null?void 0:s.source)??"none",r=n==="settings"?"saved in settings":n==="env"?"from TAVILY_API_KEY env":"";return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-border-soft bg-card px-4 py-3",children:[e.jsx("span",{className:u("h-1.5 w-1.5 shrink-0 rounded-full",t?"bg-signal-ok":"bg-muted-foreground/40")}),t?e.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[13px]",children:[e.jsx("span",{className:"text-foreground",children:"Configured"}),e.jsx("span",{className:"text-[12px] text-muted-foreground",children:r}),(s==null?void 0:s.hint)&&e.jsx("span",{className:"font-mono text-[12px] text-muted-foreground/70",children:s.hint})]}):e.jsx("span",{className:"text-[13px] text-muted-foreground",children:"Not configured"})]})}function L({title:s,description:t,children:n}){return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:s}),t&&e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-muted-foreground/80",children:t})]}),e.jsx("div",{className:"flex flex-col gap-3",children:n})]})}function it({children:s}){return e.jsx("div",{className:"divide-y divide-border-soft overflow-hidden rounded-xl border border-border-soft bg-card",children:s})}function de({label:s,description:t,children:n}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] text-foreground",children:s}),t&&e.jsx("div",{className:"mt-0.5 text-[12px] leading-snug text-muted-foreground",children:t})]}),n]})}function ce({options:s,value:t,onChange:n}){return e.jsx("div",{className:"flex gap-0.5 rounded-md border border-border bg-card p-0.5",children:s.map(r=>e.jsx("button",{type:"button",onClick:()=>n(r.value),className:u("rounded-[5px] px-2.5 py-1 text-[12px] font-medium transition-colors",r.value===t?"bg-brand-ghost text-brand-strong":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}export{pt as SettingsPage};