@inspectr/mcplab 0.6.0 → 0.6.1

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.
@@ -127,7 +127,7 @@ You can add a description to the \`${Fl}\` by passing a \`${y8}\` component as a
127
127
 
128
128
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Fl}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
129
129
 
130
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},fme=f8,pme=p8,j8=h8,N8=m8,C8=b8,_8=S8,A8=g8,E8=x8;const bs=fme,hme=pme,P8=v.forwardRef(({className:e,...t},n)=>s.jsx(j8,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));P8.displayName=j8.displayName;const Va=v.forwardRef(({className:e,...t},n)=>s.jsxs(hme,{children:[s.jsx(P8,{}),s.jsx(N8,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Va.displayName=N8.displayName;const Ha=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ha.displayName="AlertDialogHeader";const Ka=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ka.displayName="AlertDialogFooter";const Ga=v.forwardRef(({className:e,...t},n)=>s.jsx(A8,{ref:n,className:Se("text-lg font-semibold",e),...t}));Ga.displayName=A8.displayName;const Ya=v.forwardRef(({className:e,...t},n)=>s.jsx(E8,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));Ya.displayName=E8.displayName;const Xa=v.forwardRef(({className:e,...t},n)=>s.jsx(C8,{ref:n,className:Se(zj(),e),...t}));Xa.displayName=C8.displayName;const Qa=v.forwardRef(({className:e,...t},n)=>s.jsx(_8,{ref:n,className:Se(zj({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Qa.displayName=_8.displayName;const mme=()=>{const{servers:e,setServers:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=p=>p.name?.trim()||p.id,d=async p=>{const y=`${c(p)}-copy`;let g=y,S=1;for(;e.some(x=>(x.name?.trim()||x.id)===g);)g=`${y}-${S}`,S+=1;const b={...structuredClone(p),id:`srv-${Date.now()}`,name:g};await t([...e,b]),Pe({title:"Server duplicated",description:`Created ${g}.`})},f=async p=>{await t(e.filter(y=>y.id!==p.id)),Pe({title:"Server deleted",description:`${c(p)} was removed.`}),o(null)},h=p=>p.transport==="stdio"?[p.command,...p.args||[]].filter(Boolean).join(" "):p.url||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(e$,{className:"h-6 w-6"}),"Servers"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable MCP server definitions shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No servers configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]}):s.jsx(ze,{children:s.jsx(Ue,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Transport"}),s.jsx(Qe,{children:"Endpoint"}),s.jsx(Qe,{children:"Auth"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(p=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(Be,{className:"font-medium",children:c(p)}),s.jsx(Be,{children:s.jsx(Ke,{variant:"secondary",className:"font-mono text-xs",children:p.transport})}),s.jsx(Be,{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h(p)})}),s.jsx(Be,{children:!p.authType||p.authType==="none"?s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):s.jsx(Ke,{variant:"outline",className:"text-xs",children:p.authType})}),s.jsx(Be,{className:"text-right",onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(p),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{d(p)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},p.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:p=>!p&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?c(i):""})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&f(i)},children:"Delete Server"})]})]})})]})},tM={stdio:"Check that the command is installed and the args are correct",sse:"Check that the server is running and the URL is reachable","streamable-http":"Check that the server is running and the URL is reachable"},vme=()=>({id:`srv-${Date.now()}`,name:"",transport:"stdio",authType:"none",oauthRedirectUrl:"http://localhost:6274/oauth/"}),gme=()=>{const{serverId:e}=Mo(),t=wa(),{servers:n,setServers:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(R=>R.id===o||R.name===o),d=R=>R.name?.trim()||R.id,[f,h]=v.useState(()=>c??vme()),[p,y]=v.useState(!1),[g,S]=v.useState(!1),[b,x]=v.useState({status:"idle"}),[j,N]=v.useState(!1);v.useEffect(()=>{c&&h(c)},[c]);const _=R=>{h($=>({...$,authType:R,...R!=="oauth2"?{oauthClientId:void 0,oauthClientSecret:void 0,oauthRedirectUrl:void 0,oauthScope:void 0}:{oauthRedirectUrl:$.oauthRedirectUrl||"http://localhost:6274/oauth/"}}))},P=async()=>{N(!0),x({status:"loading"});try{const $=(await a.discoverToolsForAnalysis({serverNames:[d(f)]})).servers[0];$&&$.warnings.length===0?x({status:"success",toolNames:$.tools.map(z=>z.name),toolCount:$.tools.length,testedAt:new Date().toISOString()}):x({status:"error",message:$?.warnings[0]??"Connection failed",testedAt:new Date().toISOString()})}catch(R){x({status:"error",message:R instanceof Error?R.message:String(R),testedAt:new Date().toISOString()})}},A=async()=>{if(!f.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}S(!0);try{if(i)await r([...n,f]),Pe({title:"Server created"}),t(`/libraries/servers/${encodeURIComponent(f.id)}`);else{const R=n.map($=>$.id===c?.id?f:$);await r(R),Pe({title:"Server saved"}),f.id!==o&&t(`/libraries/servers/${encodeURIComponent(f.id)}`,{replace:!0})}}finally{S(!1)}},O=async()=>{const R=n.filter($=>$.id!==c?.id);await r(R),Pe({title:"Server deleted"}),t("/libraries/servers")},k=()=>f.transport==="stdio"?[f.command,...f.args||[]].filter(Boolean).join(" "):f.url||"";return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Server "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Server":d(f)})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{P()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),j&&s.jsxs(ze,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>N(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(Ue,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Server:"}),s.jsx("span",{className:"font-medium text-foreground",children:d(f)}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Transport:"}),s.jsx("span",{className:"font-medium text-foreground",children:f.transport}),k()&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsx("code",{className:"font-mono text-xs",children:k()})]})]}),b.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Connecting to MCP server…"]}),b.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",b.toolCount," tool",b.toolCount!==1?"s":""]}),b.toolNames.length>0&&s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"First 5 tools:"}),s.jsx("ul",{className:"space-y-0.5",children:b.toolNames.slice(0,5).map(R=>s.jsx("li",{className:"font-mono text-xs",children:R},R))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]}),b.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," — ",b.message]}),tM[f.transport]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",tM[f.transport]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]})]})]}),s.jsxs(ze,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(Ue,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:f.name,onChange:R=>h($=>({...$,name:R.target.value})),placeholder:"e.g. Filesystem MCP"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Transport"}),s.jsxs(sn,{value:f.transport,onValueChange:R=>h($=>({...$,transport:R})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"stdio",children:"stdio"}),s.jsx(at,{value:"sse",children:"SSE"}),s.jsx(at,{value:"streamable-http",children:"Streamable HTTP"})]})]})]})]}),f.transport==="stdio"?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Command"}),s.jsx(ht,{value:f.command||"",onChange:R=>h($=>({...$,command:R.target.value})),placeholder:"npx",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Args (comma-separated)"}),s.jsx(ht,{value:(f.args||[]).join(", "),onChange:R=>h($=>({...$,args:R.target.value.split(",").map(z=>z.trim()).filter(Boolean)})),placeholder:"-y, @mcp/server",className:"font-mono text-xs"})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"URL"}),s.jsx(ht,{value:f.url||"",onChange:R=>h($=>({...$,url:R.target.value})),placeholder:"http://localhost:3001/sse",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Auth Type"}),s.jsxs(sn,{value:f.authType||"none",onValueChange:R=>_(R),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"none",children:"None"}),s.jsx(at,{value:"bearer",children:"Bearer Token"}),s.jsx(at,{value:"api-key",children:"API Key"}),s.jsx(at,{value:"oauth2",children:"OAuth 2.0"})]})]})]}),f.authType&&f.authType!=="none"&&f.authType!=="oauth2"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:f.authType==="bearer"?"Token":"API Key"}),s.jsx(ht,{type:"password",value:f.authValue||"",onChange:R=>h($=>({...$,authValue:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),f.authType==="oauth2"&&s.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"OAuth 2.0 Flow"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client ID"}),s.jsx(ht,{value:f.oauthClientId||"",onChange:R=>h($=>({...$,oauthClientId:R.target.value})),placeholder:"your-client-id",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client Secret (optional)"}),s.jsx(ht,{type:"password",value:f.oauthClientSecret||"",onChange:R=>h($=>({...$,oauthClientSecret:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Redirect URL"}),s.jsx(ht,{value:f.oauthRedirectUrl||"http://localhost:6274/oauth/",onChange:R=>h($=>({...$,oauthRedirectUrl:R.target.value})),placeholder:"http://localhost:6274/oauth/",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Scope (space-separated)"}),s.jsx(ht,{value:f.oauthScope||"",onChange:R=>h($=>({...$,oauthScope:R.target.value})),placeholder:"openid profile mcp",className:"font-mono text-xs"})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>y(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/servers"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{A()},disabled:g,children:[g&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Server":"Save"]})]})]})]})]}),s.jsx(bs,{open:p,onOpenChange:y,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove the server"," ",s.jsx("span",{className:"font-mono",children:f.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{O()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},yme=()=>{const{agents:e,setAgents:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=async f=>{const h=`${f.name}-copy`;let p=h,y=1;for(;e.some(S=>S.name===p);)p=`${h}-${y}`,y+=1;const g={...structuredClone(f),id:`agt-${Date.now()}`,name:p};await t([...e,g]),Pe({title:"Agent duplicated",description:`Created ${p}.`})},d=async f=>{await t(e.filter(h=>h.id!==f.id)),Pe({title:"Agent deleted",description:`${f.name} was removed.`}),o(null)};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(ha,{className:"h-6 w-6"}),"Agents"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable agent profiles shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]}):s.jsx(ze,{children:s.jsx(Ue,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Provider"}),s.jsx(Qe,{children:"Model"}),s.jsx(Qe,{children:"Max Tokens"}),s.jsx(Qe,{children:"Temperature"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(f=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(Be,{className:"font-medium",children:f.name}),s.jsx(Be,{children:s.jsx(aB,{provider:f.provider})}),s.jsx(Be,{children:s.jsx("span",{className:"font-mono text-xs",children:f.model})}),s.jsx(Be,{className:"font-mono text-xs",children:f.maxTokens}),s.jsx(Be,{className:"font-mono text-xs",children:f.temperature.toFixed(2)}),s.jsx(Be,{className:"text-right",onClick:h=>h.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(f),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{c(f)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},f.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:f=>!f&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?.name})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&d(i)},children:"Delete Agent"})]})]})})]})};var O8=["PageUp","PageDown"],k8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R8={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Uc="Slider",[cj,xme,bme]=Hd(Uc),[T8]=ir(Uc,[bme]),[wme,Yv]=T8(Uc),I8=v.forwardRef((e,t)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[r],value:h,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:g=!1,form:S,...b}=e,x=v.useRef(new Set),j=v.useRef(0),_=o==="horizontal"?Sme:jme,[P=[],A]=na({prop:h,defaultProp:f,onChange:B=>{[...x.current][j.current]?.focus(),p(B)}}),O=v.useRef(P);function k(B){const D=Eme(P,B);z(B,D)}function R(B){z(B,j.current)}function $(){const B=O.current[j.current];P[j.current]!==B&&y(P)}function z(B,D,{commit:K}={commit:!1}){const U=Rme(i),V=Tme(Math.round((B-r)/i)*i+r,U),X=Vd(V,[r,a]);A((Z=[])=>{const T=_me(Z,X,D);if(kme(T,d*i)){j.current=T.indexOf(X);const L=String(T)!==String(Z);return L&&K&&y(T),L?T:Z}else return Z})}return s.jsx(wme,{scope:e.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:j,thumbs:x.current,values:P,orientation:o,form:S,children:s.jsx(cj.Provider,{scope:e.__scopeSlider,children:s.jsx(cj.Slot,{scope:e.__scopeSlider,children:s.jsx(_,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:Ae(b.onPointerDown,()=>{c||(O.current=P)}),min:r,max:a,inverted:g,onSlideStart:c?void 0:k,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:$,onHomeKeyDown:()=>!c&&z(r,0,{commit:!0}),onEndKeyDown:()=>!c&&z(a,P.length-1,{commit:!0}),onStepKeyDown:({event:B,direction:D})=>{if(!c){const V=O8.includes(B.key)||B.shiftKey&&k8.includes(B.key)?10:1,X=j.current,Z=P[X],T=i*V*D;z(Z+T,X,{commit:!0})}}})})})})});I8.displayName=Uc;var[M8,$8]=T8(Uc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Sme=v.forwardRef((e,t)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:d,onStepKeyDown:f,...h}=e,[p,y]=v.useState(null),g=ut(t,_=>y(_)),S=v.useRef(void 0),b=Lc(a),x=b==="ltr",j=x&&!i||!x&&i;function N(_){const P=S.current||p.getBoundingClientRect(),A=[0,P.width],k=uC(A,j?[n,r]:[r,n]);return S.current=P,k(_-P.left)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:j?"left":"right",endEdge:j?"right":"left",direction:j?1:-1,size:"width",children:s.jsx(D8,{dir:b,"data-orientation":"horizontal",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const P=N(_.clientX);o?.(P)},onSlideMove:_=>{const P=N(_.clientX);c?.(P)},onSlideEnd:()=>{S.current=void 0,d?.()},onStepKeyDown:_=>{const A=R8[j?"from-left":"from-right"].includes(_.key);f?.({event:_,direction:A?-1:1})}})})}),jme=v.forwardRef((e,t)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:d,...f}=e,h=v.useRef(null),p=ut(t,h),y=v.useRef(void 0),g=!a;function S(b){const x=y.current||h.current.getBoundingClientRect(),j=[0,x.height],_=uC(j,g?[r,n]:[n,r]);return y.current=x,_(b-x.top)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:s.jsx(D8,{"data-orientation":"vertical",...f,ref:p,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=S(b.clientY);i?.(x)},onSlideMove:b=>{const x=S(b.clientY);o?.(x)},onSlideEnd:()=>{y.current=void 0,c?.()},onStepKeyDown:b=>{const j=R8[g?"from-bottom":"from-top"].includes(b.key);d?.({event:b,direction:j?-1:1})}})})}),D8=v.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:d,...f}=e,h=Yv(Uc,n);return s.jsx(De.span,{...f,ref:t,onKeyDown:Ae(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(c(p),p.preventDefault()):O8.concat(k8).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:Ae(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Ae(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&a(p)}),onPointerUp:Ae(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),i(p))})})}),L8="SliderTrack",F8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(L8,n);return s.jsx(De.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});F8.displayName=L8;var uj="SliderRange",B8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(uj,n),i=$8(uj,n),o=v.useRef(null),c=ut(t,o),d=a.values.length,f=a.values.map(y=>q8(y,a.min,a.max)),h=d>1?Math.min(...f):0,p=100-Math.max(...f);return s.jsx(De.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:p+"%"}})});B8.displayName=uj;var dj="SliderThumb",z8=v.forwardRef((e,t)=>{const n=xme(e.__scopeSlider),[r,a]=v.useState(null),i=ut(t,c=>a(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(Nme,{...e,ref:i,index:o})}),Nme=v.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:a,...i}=e,o=Yv(dj,n),c=$8(dj,n),[d,f]=v.useState(null),h=ut(t,N=>f(N)),p=d?o.form||!!d.closest("form"):!0,y=km(d),g=o.values[r],S=g===void 0?0:q8(g,o.min,o.max),b=Ame(r,o.values.length),x=y?.[c.size],j=x?Pme(x,S,c.direction):0;return v.useEffect(()=>{if(d)return o.thumbs.add(d),()=>{o.thumbs.delete(d)}},[d,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${S}% + ${j}px)`},children:[s.jsx(cj.ItemSlot,{scope:e.__scopeSlider,children:s.jsx(De.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":g,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:h,style:g===void 0?{display:"none"}:e.style,onFocus:Ae(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&s.jsx(U8,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:g},r)]})});z8.displayName=dj;var Cme="RadioBubbleInput",U8=v.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(a,r),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("input",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});U8.displayName=Cme;function _me(e=[],t,n){const r=[...e];return r[n]=t,r.sort((a,i)=>a-i)}function q8(e,t,n){const i=100/(n-t)*(e-t);return Vd(i,[0,100])}function Ame(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Eme(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),r=Math.min(...n);return n.indexOf(r)}function Pme(e,t,n){const r=e/2,i=uC([0,50],[0,r]);return(r-i(t)*n)*n}function Ome(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function kme(e,t){if(t>0){const n=Ome(e);return Math.min(...n)>=t}return!0}function uC(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Rme(e){return(String(e).split(".")[1]||"").length}function Tme(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var W8=I8,Ime=F8,Mme=B8,$me=z8;const V8=v.forwardRef(({className:e,...t},n)=>s.jsxs(W8,{ref:n,className:Se("relative flex w-full touch-none select-none items-center",e),...t,children:[s.jsx(Ime,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:s.jsx(Mme,{className:"absolute h-full bg-primary"})}),s.jsx($me,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));V8.displayName=W8.displayName;function Dme(e){const t=Lme(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Bme);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Lme(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ume(a),c=zme(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fme=Symbol("radix.slottable");function Bme(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fme}function zme(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ume(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xv="Popover",[H8]=ir(Xv,[Di]),vf=Di(),[qme,Vi]=H8(Xv),K8=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,c=vf(t),d=v.useRef(null),[f,h]=v.useState(!1),[p,y]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Xv});return s.jsx(Rm,{...c,children:s.jsx(qme,{scope:t,contentId:Hn(),triggerRef:d,open:p,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:f,onCustomAnchorAdd:v.useCallback(()=>h(!0),[]),onCustomAnchorRemove:v.useCallback(()=>h(!1),[]),modal:o,children:n})})};K8.displayName=Xv;var G8="PopoverAnchor",Wme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(G8,n),i=vf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:c}=a;return v.useEffect(()=>(o(),()=>c()),[o,c]),s.jsx(Yd,{...i,...r,ref:t})});Wme.displayName=G8;var Y8="PopoverTrigger",X8=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(Y8,n),i=vf(n),o=ut(t,a.triggerRef),c=s.jsx(De.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":tz(a.open),...r,ref:o,onClick:Ae(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:s.jsx(Yd,{asChild:!0,...i,children:c})});X8.displayName=Y8;var dC="PopoverPortal",[Vme,Hme]=H8(dC,{forceMount:void 0}),Q8=e=>{const{__scopePopover:t,forceMount:n,children:r,container:a}=e,i=Vi(dC,t);return s.jsx(Vme,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Q8.displayName=dC;var bc="PopoverContent",J8=v.forwardRef((e,t)=>{const n=Hme(bc,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,i=Vi(bc,e.__scopePopover);return s.jsx(Gn,{present:r||i.open,children:i.modal?s.jsx(Gme,{...a,ref:t}):s.jsx(Yme,{...a,ref:t})})});J8.displayName=bc;var Kme=Dme("PopoverContent.RemoveScroll"),Gme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(null),a=ut(t,r),i=v.useRef(!1);return v.useEffect(()=>{const o=r.current;if(o)return Hm(o)},[]),s.jsx(Qd,{as:Kme,allowPinchZoom:!0,children:s.jsx(Z8,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,o=>{o.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Ae(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Yme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(!1),a=v.useRef(!1);return s.jsx(Z8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z8=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...p}=e,y=Vi(bc,n),g=vf(n);return Wm(),s.jsx(Xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>y.onOpenChange(!1),children:s.jsx(Tm,{"data-state":tz(y.open),role:"dialog",id:y.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ez="PopoverClose",Xme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(ez,n);return s.jsx(De.button,{type:"button",...r,ref:t,onClick:Ae(e.onClick,()=>a.onOpenChange(!1))})});Xme.displayName=ez;var Qme="PopoverArrow",Jme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=vf(n);return s.jsx(Im,{...a,...r,ref:t})});Jme.displayName=Qme;function tz(e){return e?"open":"closed"}var Zme=K8,eve=X8,tve=Q8,nz=J8;const nve=Zme,rve=eve,rz=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>s.jsx(tve,{children:s.jsx(nz,{ref:a,align:t,sideOffset:n,className:Se("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));rz.displayName=nz.displayName;var nM=1,ave=.9,sve=.8,ive=.17,r1=.1,a1=.999,ove=.9999,lve=.99,cve=/[\\\/_+.#"@\[\(\{&]/,uve=/[\\\/_+.#"@\[\(\{&]/g,dve=/[\s-]/,az=/[\s-]/g;function fj(e,t,n,r,a,i,o){if(i===t.length)return a===e.length?nM:lve;var c=`${a},${i}`;if(o[c]!==void 0)return o[c];for(var d=r.charAt(i),f=n.indexOf(d,a),h=0,p,y,g,S;f>=0;)p=fj(e,t,n,r,f+1,i+1,o),p>h&&(f===a?p*=nM:cve.test(e.charAt(f-1))?(p*=sve,g=e.slice(a,f-1).match(uve),g&&a>0&&(p*=Math.pow(a1,g.length))):dve.test(e.charAt(f-1))?(p*=ave,S=e.slice(a,f-1).match(az),S&&a>0&&(p*=Math.pow(a1,S.length))):(p*=ive,a>0&&(p*=Math.pow(a1,f-a))),e.charAt(f)!==t.charAt(i)&&(p*=ove)),(p<r1&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(y=fj(e,t,n,r,f+1,i+2,o),y*r1>p&&(p=y*r1)),p>h&&(h=p),f=n.indexOf(d,f+1);return o[c]=h,h}function rM(e){return e.toLowerCase().replace(az," ")}function fve(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fj(e,t,rM(e),rM(t),0,0,{})}var Du='[cmdk-group=""]',s1='[cmdk-group-items=""]',pve='[cmdk-group-heading=""]',sz='[cmdk-item=""]',aM=`${sz}:not([aria-disabled="true"])`,pj="cmdk-item-select",Sl="data-value",hve=(e,t,n)=>fve(e,t,n),iz=v.createContext(void 0),gf=()=>v.useContext(iz),oz=v.createContext(void 0),fC=()=>v.useContext(oz),lz=v.createContext(void 0),cz=v.forwardRef((e,t)=>{let n=jl(()=>{var M,ee;return{search:"",value:(ee=(M=e.value)!=null?M:e.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=jl(()=>new Set),a=jl(()=>new Map),i=jl(()=>new Map),o=jl(()=>new Set),c=uz(e),{label:d,children:f,value:h,onValueChange:p,filter:y,shouldFilter:g,loop:S,disablePointerSelection:b=!1,vimBindings:x=!0,...j}=e,N=Hn(),_=Hn(),P=Hn(),A=v.useRef(null),O=Cve();Ro(()=>{if(h!==void 0){let M=h.trim();n.current.value=M,k.emit()}},[h]),Ro(()=>{O(6,K)},[]);let k=v.useMemo(()=>({subscribe:M=>(o.current.add(M),()=>o.current.delete(M)),snapshot:()=>n.current,setState:(M,ee,W)=>{var J,ye,ae,ue;if(!Object.is(n.current[M],ee)){if(n.current[M]=ee,M==="search")D(),z(),O(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ie=document.getElementById(P);ie?ie.focus():(J=document.getElementById(N))==null||J.focus()}if(O(7,()=>{var ie;n.current.selectedItemId=(ie=U())==null?void 0:ie.id,k.emit()}),W||O(5,K),((ye=c.current)==null?void 0:ye.value)!==void 0){let ie=ee??"";(ue=(ae=c.current).onValueChange)==null||ue.call(ae,ie);return}}k.emit()}},emit:()=>{o.current.forEach(M=>M())}}),[]),R=v.useMemo(()=>({value:(M,ee,W)=>{var J;ee!==((J=i.current.get(M))==null?void 0:J.value)&&(i.current.set(M,{value:ee,keywords:W}),n.current.filtered.items.set(M,$(ee,W)),O(2,()=>{z(),k.emit()}))},item:(M,ee)=>(r.current.add(M),ee&&(a.current.has(ee)?a.current.get(ee).add(M):a.current.set(ee,new Set([M]))),O(3,()=>{D(),z(),n.current.value||B(),k.emit()}),()=>{i.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let W=U();O(4,()=>{D(),W?.getAttribute("id")===M&&B(),k.emit()})}),group:M=>(a.current.has(M)||a.current.set(M,new Set),()=>{i.current.delete(M),a.current.delete(M)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:N,inputId:P,labelId:_,listInnerRef:A}),[]);function $(M,ee){var W,J;let ye=(J=(W=c.current)==null?void 0:W.filter)!=null?J:hve;return M?ye(M,n.current.search,ee):0}function z(){if(!n.current.search||c.current.shouldFilter===!1)return;let M=n.current.filtered.items,ee=[];n.current.filtered.groups.forEach(J=>{let ye=a.current.get(J),ae=0;ye.forEach(ue=>{let ie=M.get(ue);ae=Math.max(ie,ae)}),ee.push([J,ae])});let W=A.current;V().sort((J,ye)=>{var ae,ue;let ie=J.getAttribute("id"),ve=ye.getAttribute("id");return((ae=M.get(ve))!=null?ae:0)-((ue=M.get(ie))!=null?ue:0)}).forEach(J=>{let ye=J.closest(s1);ye?ye.appendChild(J.parentElement===ye?J:J.closest(`${s1} > *`)):W.appendChild(J.parentElement===W?J:J.closest(`${s1} > *`))}),ee.sort((J,ye)=>ye[1]-J[1]).forEach(J=>{var ye;let ae=(ye=A.current)==null?void 0:ye.querySelector(`${Du}[${Sl}="${encodeURIComponent(J[0])}"]`);ae?.parentElement.appendChild(ae)})}function B(){let M=V().find(W=>W.getAttribute("aria-disabled")!=="true"),ee=M?.getAttribute(Sl);k.setState("value",ee||void 0)}function D(){var M,ee,W,J;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ae of r.current){let ue=(ee=(M=i.current.get(ae))==null?void 0:M.value)!=null?ee:"",ie=(J=(W=i.current.get(ae))==null?void 0:W.keywords)!=null?J:[],ve=$(ue,ie);n.current.filtered.items.set(ae,ve),ve>0&&ye++}for(let[ae,ue]of a.current)for(let ie of ue)if(n.current.filtered.items.get(ie)>0){n.current.filtered.groups.add(ae);break}n.current.filtered.count=ye}function K(){var M,ee,W;let J=U();J&&(((M=J.parentElement)==null?void 0:M.firstChild)===J&&((W=(ee=J.closest(Du))==null?void 0:ee.querySelector(pve))==null||W.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function U(){var M;return(M=A.current)==null?void 0:M.querySelector(`${sz}[aria-selected="true"]`)}function V(){var M;return Array.from(((M=A.current)==null?void 0:M.querySelectorAll(aM))||[])}function X(M){let ee=V()[M];ee&&k.setState("value",ee.getAttribute(Sl))}function Z(M){var ee;let W=U(),J=V(),ye=J.findIndex(ue=>ue===W),ae=J[ye+M];(ee=c.current)!=null&&ee.loop&&(ae=ye+M<0?J[J.length-1]:ye+M===J.length?J[0]:J[ye+M]),ae&&k.setState("value",ae.getAttribute(Sl))}function T(M){let ee=U(),W=ee?.closest(Du),J;for(;W&&!J;)W=M>0?jve(W,Du):Nve(W,Du),J=W?.querySelector(aM);J?k.setState("value",J.getAttribute(Sl)):Z(M)}let L=()=>X(V().length-1),Q=M=>{M.preventDefault(),M.metaKey?L():M.altKey?T(1):Z(1)},F=M=>{M.preventDefault(),M.metaKey?X(0):M.altKey?T(-1):Z(-1)};return v.createElement(De.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:M=>{var ee;(ee=j.onKeyDown)==null||ee.call(j,M);let W=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||W))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&Q(M);break}case"ArrowDown":{Q(M);break}case"p":case"k":{x&&M.ctrlKey&&F(M);break}case"ArrowUp":{F(M);break}case"Home":{M.preventDefault(),X(0);break}case"End":{M.preventDefault(),L();break}case"Enter":{M.preventDefault();let J=U();if(J){let ye=new Event(pj);J.dispatchEvent(ye)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Ave},d),Qv(e,M=>v.createElement(oz.Provider,{value:k},v.createElement(iz.Provider,{value:R},M))))}),mve=v.forwardRef((e,t)=>{var n,r;let a=Hn(),i=v.useRef(null),o=v.useContext(lz),c=gf(),d=uz(e),f=(r=(n=d.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;Ro(()=>{if(!f)return c.item(a,o?.id)},[f]);let h=dz(a,i,[e.value,e.children,i],e.keywords),p=fC(),y=$i(O=>O.value&&O.value===h.current),g=$i(O=>f||c.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);v.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(pj,S),()=>O.removeEventListener(pj,S)},[g,e.onSelect,e.disabled]);function S(){var O,k;b(),(k=(O=d.current).onSelect)==null||k.call(O,h.current)}function b(){p.setState("value",h.current,!0)}if(!g)return null;let{disabled:x,value:j,onSelect:N,forceMount:_,keywords:P,...A}=e;return v.createElement(De.div,{ref:jr(i,t),...A,id:a,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||c.getDisablePointerSelection()?void 0:b,onClick:x?void 0:S},e.children)}),vve=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...i}=e,o=Hn(),c=v.useRef(null),d=v.useRef(null),f=Hn(),h=gf(),p=$i(g=>a||h.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);Ro(()=>h.group(o),[]),dz(o,c,[e.value,e.heading,d]);let y=v.useMemo(()=>({id:o,forceMount:a}),[a]);return v.createElement(De.div,{ref:jr(c,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&v.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Qv(e,g=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},v.createElement(lz.Provider,{value:y},g))))}),gve=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),i=$i(o=>!o.search);return!n&&!i?null:v.createElement(De.div,{ref:jr(a,t),...r,"cmdk-separator":"",role:"separator"})}),yve=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,a=e.value!=null,i=fC(),o=$i(f=>f.search),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),v.createElement(De.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:o,onChange:f=>{a||i.setState("search",f.target.value),n?.(f.target.value)}})}),xve=v.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...a}=e,i=v.useRef(null),o=v.useRef(null),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{if(o.current&&i.current){let f=o.current,h=i.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let g=f.offsetHeight;h.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return y.observe(f),()=>{cancelAnimationFrame(p),y.unobserve(f)}}},[]),v.createElement(De.div,{ref:jr(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:d.listId},Qv(e,f=>v.createElement("div",{ref:jr(o,d.listInnerRef),"cmdk-list-sizer":""},f)))}),bve=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...c}=e;return v.createElement(Gm,{open:n,onOpenChange:r},v.createElement(Ym,{container:o},v.createElement(Pc,{"cmdk-overlay":"",className:a}),v.createElement(Oc,{"aria-label":e.label,"cmdk-dialog":"",className:i},v.createElement(cz,{ref:t,...c}))))}),wve=v.forwardRef((e,t)=>$i(n=>n.filtered.count===0)?v.createElement(De.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sve=v.forwardRef((e,t)=>{let{progress:n,children:r,label:a="Loading...",...i}=e;return v.createElement(De.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Qv(e,o=>v.createElement("div",{"aria-hidden":!0},o)))}),$r=Object.assign(cz,{List:xve,Item:mve,Input:yve,Group:vve,Separator:gve,Dialog:bve,Empty:wve,Loading:Sve});function jve(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nve(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function uz(e){let t=v.useRef(e);return Ro(()=>{t.current=e}),t}var Ro=typeof window>"u"?v.useEffect:v.useLayoutEffect;function jl(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function $i(e){let t=fC(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function dz(e,t,n,r=[]){let a=v.useRef(),i=gf();return Ro(()=>{var o;let c=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():a.current}})(),d=r.map(f=>f.trim());i.value(e,c,d),(o=t.current)==null||o.setAttribute(Sl,c),a.current=c}),a}var Cve=()=>{let[e,t]=v.useState(),n=jl(()=>new Map);return Ro(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,a)=>{n.current.set(r,a),t({})}};function _ve(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qv({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(_ve(t),{ref:t.ref},n(t.props.children)):n(t)}var Ave={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const fz=v.forwardRef(({className:e,...t},n)=>s.jsx($r,{ref:n,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));fz.displayName=$r.displayName;const pz=v.forwardRef(({className:e,...t},n)=>s.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[s.jsx(Sj,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx($r.Input,{ref:n,className:Se("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));pz.displayName=$r.Input.displayName;const hz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.List,{ref:n,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));hz.displayName=$r.List.displayName;const mz=v.forwardRef((e,t)=>s.jsx($r.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));mz.displayName=$r.Empty.displayName;const vz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Group,{ref:n,className:Se("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));vz.displayName=$r.Group.displayName;const Eve=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Separator,{ref:n,className:Se("-mx-1 h-px bg-border",e),...t}));Eve.displayName=$r.Separator.displayName;const hj=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Item,{ref:n,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));hj.displayName=$r.Item.displayName;const sM={openai:["gpt-4o","gpt-4o-mini","gpt-4-turbo","o1","o1-mini"],anthropic:["claude-3-5-sonnet-latest","claude-3-5-haiku-latest","claude-3-opus-latest"],azure:["gpt-4o","gpt-4-turbo"],google:["gemini-2.0-flash","gemini-1.5-pro"],custom:[]},iM={anthropic:"Check that `ANTHROPIC_API_KEY` is set in your environment",openai:"Check that `OPENAI_API_KEY` is set in your environment",azure:"Check that Azure OpenAI env vars are configured in your environment"},Pve=()=>({id:`agt-${Date.now()}`,name:"",provider:"openai",model:"gpt-4o",temperature:0,maxTokens:4096}),Ove=()=>{const{agentName:e}=Mo(),t=wa(),{agents:n,setAgents:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(T=>T.id===o)??n.find(T=>T.name===o),[d,f]=v.useState(()=>c??Pve()),[h,p]=v.useState(!1),[y,g]=v.useState(!1),[S,b]=v.useState({status:"idle"}),[x,j]=v.useState(!1),[N,_]=v.useState([]),[P,A]=v.useState(!1),[O,k]=v.useState(!1),[R,$]=v.useState(!1);v.useEffect(()=>{c&&f(c)},[c]);const z=d.provider==="anthropic"||d.provider==="openai"||d.provider==="azure",B=Array.from(new Set([...sM[d.provider]||[],...N])),D=B.includes(d.model),K=R||!!d.model&&!D,U=async()=>{if(j(!0),d.provider==="google"||d.provider==="custom"){b({status:"unsupported"});return}b({status:"loading"});try{const T=await a.listProviderModels(d.provider);b({status:"success",items:T.items,source:T.source,kind:T.kind,testedAt:new Date().toISOString()})}catch(T){b({status:"error",message:T instanceof Error?T.message:String(T),testedAt:new Date().toISOString()})}},V=async()=>{if(!z){Pe({title:"Provider discovery not supported",description:"Model discovery is available for Anthropic, OpenAI, and Azure OpenAI."});return}A(!0);try{const T=await a.listProviderModels(d.provider);_(T.items),Pe({title:T.kind==="deployments"?"Deployments loaded":"Models loaded",description:`${T.items.length} ${T.kind} from ${T.source}`})}catch(T){Pe({title:"Could not load provider models",description:String(T instanceof Error?T.message:T),variant:"destructive"})}finally{A(!1)}},X=async()=>{if(!d.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}g(!0);try{if(i)await r([...n,d]),Pe({title:"Agent created"}),t(`/libraries/agents/${encodeURIComponent(d.id)}`);else{const T=n.map(L=>L.id===c?.id?d:L);await r(T),Pe({title:"Agent saved"}),d.id!==o&&t(`/libraries/agents/${encodeURIComponent(d.id)}`,{replace:!0})}}finally{g(!1)}},Z=async()=>{const T=n.filter(L=>L.id!==c?.id);await r(T),Pe({title:"Agent deleted"}),t("/libraries/agents")};return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Agent "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Agent":d.name})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{U()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),x&&s.jsxs(ze,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>j(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(Ue,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Provider:"}),s.jsx("span",{className:"font-medium text-foreground",children:d.provider}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsxs("code",{className:"font-mono text-xs",children:["/api/providers/models?provider=",d.provider]})]}),S.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Testing connection..."]}),S.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",S.items.length," ",S.kind," from"," ",S.source]}),s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsxs("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:["First 5 ",S.kind,":"]}),s.jsx("ul",{className:"space-y-0.5",children:S.items.slice(0,5).map(T=>s.jsx("li",{className:"font-mono text-xs",children:T},T))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," —"," ",S.message]}),iM[d.provider]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",iM[d.provider]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="unsupported"&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground",children:["Connection testing is not supported for the"," ",s.jsx("span",{className:"font-medium",children:d.provider})," provider. Supported providers: Anthropic, OpenAI, Azure OpenAI."]})]})]}),s.jsxs(ze,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(Ue,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:d.name,onChange:T=>f(L=>({...L,name:T.target.value})),placeholder:"e.g. GPT-4o"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Provider"}),s.jsxs(sn,{value:d.provider,onValueChange:T=>f(L=>({...L,provider:T,model:sM[T]?.[0]||""})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"openai",children:"OpenAI"}),s.jsx(at,{value:"anthropic",children:"Anthropic"}),s.jsx(at,{value:"azure",children:"Azure OpenAI"}),s.jsx(at,{value:"google",children:"Google"}),s.jsx(at,{value:"custom",children:"Custom"})]})]})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:d.provider==="azure"?"Deployment":"Model"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(nve,{open:O,onOpenChange:k,children:[s.jsx(rve,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"outline",role:"combobox","aria-expanded":O,className:"h-9 flex-1 justify-between font-mono text-xs",children:[s.jsx("span",{className:"truncate text-left",children:d.model||"Select model..."}),s.jsx(qt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(rz,{className:"w-[420px] p-0",align:"start",children:s.jsxs(fz,{children:[s.jsx(pz,{placeholder:`Search ${d.provider==="azure"?"deployments":"models"}...`}),s.jsxs(hz,{children:[s.jsxs(mz,{children:["No ",d.provider==="azure"?"deployments":"models"," found."]}),s.jsxs(vz,{heading:d.provider==="azure"?"Deployments":"Models",children:[B.map(T=>s.jsxs(hj,{value:T,onSelect:L=>{f(Q=>({...Q,model:L})),$(!1),k(!1)},children:[s.jsx(ql,{className:Se("mr-2 h-4 w-4",d.model===T?"opacity-100":"opacity-0")}),s.jsx("span",{className:"font-mono text-xs",children:T})]},T)),s.jsx(hj,{value:"__custom_model_id__",onSelect:()=>{$(!0),k(!1)},children:s.jsx("span",{className:"font-medium",children:d.provider==="azure"?"Custom deployment ID...":"Custom model ID..."})})]})]})]})})]}),z&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0 text-xs",onClick:()=>{V()},disabled:P,title:d.provider==="azure"?"Fetch Azure OpenAI deployments":`Fetch ${d.provider} models`,children:[P?s.jsx(sr,{className:"mr-1 h-3 w-3 animate-spin"}):s.jsx(Fa,{className:"mr-1 h-3 w-3"}),d.provider==="azure"?"Fetch Deployments":"Fetch Models"]})]}),K&&s.jsx(ht,{value:d.model,onChange:T=>f(L=>({...L,model:T.target.value})),placeholder:d.provider==="azure"?"Type deployment name manually":"Type model name manually",className:"font-mono text-xs"}),N.length>0&&s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Loaded ",N.length," ",d.provider==="azure"?"deployment names":"models"," from provider discovery."]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Tokens"}),s.jsx(ht,{type:"number",min:1,max:128e3,value:d.maxTokens,onChange:T=>f(L=>({...L,maxTokens:parseInt(T.target.value)||0})),className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Me,{children:"Temperature"}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:d.temperature.toFixed(2)})]}),s.jsx(V8,{value:[d.temperature],onValueChange:([T])=>f(L=>({...L,temperature:T})),min:0,max:2,step:.01})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"System Prompt"}),s.jsx(Ks,{value:d.systemPrompt||"",onChange:T=>f(L=>({...L,systemPrompt:T.target.value})),placeholder:"Optional system prompt...",rows:3,className:"text-xs"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/agents"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{X()},disabled:y,children:[y&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Agent":"Save"]})]})]})]})]}),s.jsx(bs,{open:h,onOpenChange:p,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove the agent"," ",s.jsx("span",{className:"font-mono",children:d.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{Z()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},oM="mcplab.resultAssistantScenarioHandoff",lM=()=>{const{testCaseId:e}=Mo(),[t,n]=Ec(),r=wa(),{source:a}=On(),{scenarios:i,setScenarios:o,agents:c,servers:d,reload:f,loading:h}=qa(),[p,y]=v.useState(""),[g,S]=v.useState("all"),[b,x]=v.useState("name"),[j,N]=v.useState("asc"),[_,P]=v.useState(""),[A,O]=v.useState(null),[k,R]=v.useState("idle"),[$,z]=v.useState(""),[B,D]=v.useState(""),[K,U]=v.useState(0),[V,X]=v.useState(null),Z=v.useRef(null),T=v.useRef(!1),L=v.useRef(!1),Q=v.useRef(null),F=v.useRef(0),M=e?decodeURIComponent(e):void 0,ee=M?i.findIndex(re=>re.id===M):-1,W=ee>=0?i[ee]:void 0,J=async re=>{if(!W||ee<0||!re)return;const me=[...i];me[ee]=re,await o(me)},ye=async()=>{const re=Q.current;if(!re||!W)return;if(T.current){L.current=!0;return}T.current=!0,L.current=!1;const me=++F.current;R("saving"),z("");try{await J(re),me===F.current&&R("saved")}catch(Ne){const tt=Ne instanceof Error?Ne.message:String(Ne);me===F.current&&(R("error"),z(tt)),Pe({title:"Could not save scenario",description:tt,variant:"destructive"})}finally{T.current=!1,L.current&&(L.current=!1,ye())}},ae=re=>{Q.current=re,R("dirty"),z(""),Z.current&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{Z.current=null,ye()},700)},ue=async()=>{const re=`scn-${Date.now()}`;let me=re,Ne=1;for(;i.some(je=>je.id===me);)me=`${re}-${Ne}`,Ne+=1;const tt={id:me,name:"",serverIds:[],prompt:"",evalRules:[],extractRules:[]};await o([...i,tt]),r(`/libraries/test-cases/${encodeURIComponent(me)}`),Pe({title:"Test case created",description:`Opened ${me} for editing.`})},ie=re=>{const me=(re||`scn-${Date.now()}`).trim().replace(/\s+/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||`scn-${Date.now()}`;let Ne=me,tt=1;for(;i.some(je=>je.id===Ne);)Ne=`${me}-${tt}`,tt+=1;return Ne},ve=async(re,me=!1)=>{const Ne=ie(`${re.id}-copy`),tt={...structuredClone(re),id:Ne,name:re.name?`${re.name} (Copy)`:""};await o([...i,tt]),Pe({title:"Test case duplicated",description:`Created ${tt.id}.`}),me&&r(`/libraries/test-cases/${encodeURIComponent(tt.id)}`)},Oe=async re=>{Z.current&&(window.clearTimeout(Z.current),Z.current=null);const me=i.filter(Ne=>Ne.id!==re.id);await o(me),Pe({title:"Test case deleted",description:`${re.id} was removed.`}),W?.id===re.id&&(O(null),Q.current=null,R("idle"),z(""),r("/libraries/test-cases"))},oe=re=>re.map(me=>d.find(Ne=>Ne.id===me)).filter(Boolean).map(me=>me?.name||me?.id).filter(Boolean),he=v.useMemo(()=>{const re=new Set;for(const me of i)for(const Ne of oe(me.serverIds))re.add(Ne);return Array.from(re).sort((me,Ne)=>me.localeCompare(Ne))},[i,d]),xe=v.useMemo(()=>{const re=p.trim().toLowerCase(),me=i.filter(Ne=>{const tt=(Ne.name||"").toLowerCase(),je=Ne.id.toLowerCase(),et=(Ne.prompt||"").toLowerCase(),dt=oe(Ne.serverIds);return g!=="all"&&!dt.includes(g)?!1:re?tt.includes(re)||je.includes(re)||et.includes(re)||dt.some(Pt=>Pt.toLowerCase().includes(re)):!0});return me.sort((Ne,tt)=>{const je=oe(Ne.serverIds),et=oe(tt.serverIds);let dt=0;switch(b){case"id":dt=Ne.id.localeCompare(tt.id);break;case"servers":dt=je.length-et.length;break;case"evalRules":dt=Ne.evalRules.length-tt.evalRules.length;break;case"extractRules":dt=Ne.extractRules.length-tt.extractRules.length;break;default:dt=(Ne.name||Ne.id).localeCompare(tt.name||tt.id);break}return dt===0&&(dt=Ne.id.localeCompare(tt.id)),j==="asc"?dt:-dt}),me},[i,p,g,b,j,d]);v.useEffect(()=>{let re=!0;return a.getWorkspaceSettings().then(me=>{!re||!me||P(me.scenarioAssistantAgentName??"")}).catch(()=>{re&&P("")}),()=>{re=!1}},[a]),v.useEffect(()=>{if(M&&t.get("assistantHandoff")==="1")try{const re=window.sessionStorage.getItem(oM);if(!re)return;const me=JSON.parse(re);if(!me||me.scenarioId!==M||!me.prompt)return;D(String(me.prompt)),U(Date.now()),window.sessionStorage.removeItem(oM);const Ne=new URLSearchParams(t);Ne.delete("assistantHandoff"),n(Ne,{replace:!0}),Pe({title:"Suggestion sent to Scenario Assistant",description:"Review the suggestion and apply changes in the scenario editor."})}catch{}},[M,t,n]),v.useEffect(()=>{W?(O(structuredClone(W)),Q.current=structuredClone(W),R("idle"),z("")):(O(null),Q.current=null,R("idle"),z("")),Z.current&&(window.clearTimeout(Z.current),Z.current=null),T.current=!1,L.current=!1},[W]),v.useEffect(()=>()=>{Z.current&&window.clearTimeout(Z.current)},[]);const Ie=_||c[0]?.name||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(t$,{className:"h-6 w-6"}),"Manage Test Cases"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable test case templates shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[W&&s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>r("/libraries/test-cases"),children:[s.jsx(xo,{className:"mr-2 h-4 w-4"}),"Back to Overview"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{f()},disabled:h,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),!W&&s.jsxs(se,{type:"button",size:"sm",onClick:()=>{ue()},children:[s.jsx(us,{className:"mr-1.5 h-3.5 w-3.5"}),"Add Test Case"]})]})]}),!W&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 rounded-md border bg-muted/30 p-3 md:grid-cols-[1.6fr_1fr_1fr_auto]",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Search"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sj,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),s.jsx(ht,{value:p,onChange:re=>y(re.target.value),placeholder:"Search by name, id, prompt, server...",className:"h-8 pl-8 text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Server Filter"}),s.jsxs(sn,{value:g,onValueChange:S,children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All servers"}),he.map(re=>s.jsx(at,{value:re,children:re},re))]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Sort By"}),s.jsxs(sn,{value:b,onValueChange:re=>x(re),children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"name",children:"Name"}),s.jsx(at,{value:"id",children:"ID"}),s.jsx(at,{value:"servers",children:"# Servers"}),s.jsx(at,{value:"evalRules",children:"# Eval Rules"}),s.jsx(at,{value:"extractRules",children:"# Extract Rules"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Direction"}),s.jsxs(sn,{value:j,onValueChange:re=>N(re),children:[s.jsx(Jt,{className:"h-8 w-28 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"asc",children:"Ascending"}),s.jsx(at,{value:"desc",children:"Descending"})]})]})]})]}),s.jsx(ze,{children:s.jsxs(Ue,{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",xe.length," of ",i.length," test case",i.length!==1?"s":"","."]}),M&&!W&&s.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Test case ",s.jsx("code",{className:"font-mono",children:M})," was not found."]}),i.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No library test cases yet."}):xe.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No test cases match the current filters."}):s.jsx("div",{className:"grid gap-3",children:xe.map(re=>{const me=M===re.id,Ne=`/libraries/test-cases/${encodeURIComponent(re.id)}`,tt=oe(re.serverIds);return s.jsx("div",{className:`rounded-lg border p-3 ${me?"border-primary bg-primary/5":""}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(yt,{to:Ne,className:"font-medium truncate hover:underline",children:re.name||re.id}),s.jsx(Ke,{variant:"outline",className:"font-mono text-[10px]",children:re.id}),me&&s.jsx(Ke,{children:"Selected"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground flex flex-wrap gap-x-3 gap-y-1",children:[s.jsxs("span",{children:[tt.length," server",tt.length!==1?"s":""]}),s.jsxs("span",{children:[re.evalRules.length," eval rule",re.evalRules.length!==1?"s":""]}),s.jsxs("span",{children:[re.extractRules.length," extract rule",re.extractRules.length!==1?"s":""]})]}),tt.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:tt.map(je=>s.jsx(Ke,{variant:"secondary",className:"text-[10px]",children:je},`${re.id}-${je}`))})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(re),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(re)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsx(se,{type:"button",size:"sm",variant:me?"default":"outline",asChild:!0,children:s.jsxs(yt,{to:Ne,children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})})]})]})},re.id)})})]})})]}),W&&A?s.jsxs(ze,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{children:s.jsx(_t,{className:"text-base",children:"Edit Test Case"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(A,!0)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(A),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})]})]}),s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{children:["Focused editor for ",s.jsx("code",{className:"font-mono",children:W.id}),"."]}),s.jsx(Ke,{variant:"outline",className:`text-[10px] ${k==="saving"?"border-amber-300 text-amber-700":k==="saved"?"border-emerald-300 text-emerald-700":k==="error"?"border-destructive/40 text-destructive":k==="dirty"?"border-sky-300 text-sky-700":""}`,children:k==="saving"?"Saving...":k==="saved"?"Saved":k==="error"?"Save failed":k==="dirty"?"Unsaved changes":"Ready"}),k==="error"&&$&&s.jsx("span",{className:"text-[11px] text-destructive",children:$})]})})]}),s.jsx(Ue,{className:"pt-3",children:s.jsx(lj,{scenarios:[A],agents:c,servers:d,defaultAssistantAgentName:Ie,assistantInitialPromptByScenarioId:B&&A?.id?{[A.id]:B}:void 0,assistantAutoOpenNonceByScenarioId:A?.id&&K?{[A.id]:K}:void 0,onChange:re=>{const me=re[0];me&&(O(me),ae(me))},allowAdd:!1})})]}):null,s.jsx(bs,{open:!!V,onOpenChange:re=>!re&&X(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete test case?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-medium",children:V?.name||V?.id})," ","from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V&&(Oe(V),X(null))},children:"Delete Test Case"})]})]})})]})},kve=()=>{const{source:e}=On(),{agents:t,reload:n,loading:r}=qa(),[a,i]=v.useState(!1),[o,c]=v.useState(!1),[d,f]=v.useState(""),h=v.useMemo(()=>d||t[0]?.name||"",[d,t]),p=async()=>{i(!0);try{const S=await e.getWorkspaceSettings();f(S?.scenarioAssistantAgentName??"")}catch(S){f(""),Pe({title:"Could not load settings",description:S instanceof Error?S.message:String(S),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{p()},[e]);const y=async S=>{f(S),c(!0);try{await e.updateWorkspaceSettings({scenarioAssistantAgentName:S||void 0}),Pe({title:"Settings updated",description:S?`Scenario Assistant Agent set to ${S}.`:"Scenario Assistant Agent cleared (will use first available agent by default)."})}catch(b){Pe({title:"Could not save settings",description:b instanceof Error?b.message:String(b),variant:"destructive"})}finally{c(!1)}},g=async()=>{await Promise.all([n(),p()])};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(jj,{className:"h-6 w-6"}),"Settings"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace-level MCP Lab settings and defaults."})]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{g()},disabled:r||a,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),s.jsxs(ze,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsx(_t,{className:"text-base",children:"Scenario Assistant"}),s.jsx(Ds,{children:"Default assistant model used on library test case pages. If unset, MCP Lab uses the first available agent automatically."})]}),s.jsxs(Ue,{className:"grid gap-3 md:grid-cols-[1.3fr_auto] md:items-end",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Assistant Agent"}),s.jsxs(sn,{value:h||"__none__",onValueChange:S=>{y(S==="__none__"?"":S)},disabled:o,children:[s.jsx(Jt,{className:"h-9 text-sm",children:s.jsx(on,{placeholder:"Select assistant agent"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"__none__",children:"None (use first agent)"}),t.map(S=>s.jsxs(at,{value:S.name||S.id,children:[S.name||S.id," · ",S.model]},S.id))]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Applies to `/libraries/test-cases/:testCaseId`. MCP Evaluation editors can still override the assistant agent from their evaluation context."})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:"Saved in workspace settings"})]})]})]})};var Jv="Checkbox",[Rve]=ir(Jv),[Tve,pC]=Rve(Jv);function Ive(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:c,onCheckedChange:d,required:f,value:h="on",internal_do_not_use_render:p}=e,[y,g]=na({prop:n,defaultProp:a??!1,onChange:d,caller:Jv}),[S,b]=v.useState(null),[x,j]=v.useState(null),N=v.useRef(!1),_=S?!!o||!!S.closest("form"):!0,P={checked:y,disabled:i,setChecked:g,control:S,setControl:b,name:c,form:o,value:h,hasConsumerStoppedPropagationRef:N,required:f,defaultChecked:ki(a)?!1:a,isFormControl:_,bubbleInput:x,setBubbleInput:j};return s.jsx(Tve,{scope:t,...P,children:Mve(p)?p(P):r})}var gz="CheckboxTrigger",yz=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:i,value:o,disabled:c,checked:d,required:f,setControl:h,setChecked:p,hasConsumerStoppedPropagationRef:y,isFormControl:g,bubbleInput:S}=pC(gz,e),b=ut(a,h),x=v.useRef(d);return v.useEffect(()=>{const j=i?.form;if(j){const N=()=>p(x.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,p]),s.jsx(De.button,{type:"button",role:"checkbox","aria-checked":ki(d)?"mixed":d,"aria-required":f,"data-state":jz(d),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:b,onKeyDown:Ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ae(n,j=>{p(N=>ki(N)?!0:!N),S&&g&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});yz.displayName=gz;var hC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d,onCheckedChange:f,form:h,...p}=e;return s.jsx(Ive,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:c,required:o,onCheckedChange:f,name:r,form:h,value:d,internal_do_not_use_render:({isFormControl:y})=>s.jsxs(s.Fragment,{children:[s.jsx(yz,{...p,ref:t,__scopeCheckbox:n}),y&&s.jsx(Sz,{__scopeCheckbox:n})]})})});hC.displayName=Jv;var xz="CheckboxIndicator",bz=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,i=pC(xz,n);return s.jsx(Gn,{present:r||ki(i.checked)||i.checked===!0,children:s.jsx(De.span,{"data-state":jz(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});bz.displayName=xz;var wz="CheckboxBubbleInput",Sz=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:c,disabled:d,name:f,value:h,form:p,bubbleInput:y,setBubbleInput:g}=pC(wz,e),S=ut(n,g),b=Fv(i),x=km(r);v.useEffect(()=>{const N=y;if(!N)return;const _=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(_,"checked").set,O=!a.current;if(b!==i&&A){const k=new Event("click",{bubbles:O});N.indeterminate=ki(i),A.call(N,ki(i)?!1:i),N.dispatchEvent(k)}},[y,b,i,a]);const j=v.useRef(ki(i)?!1:i);return s.jsx(De.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:c,disabled:d,name:f,value:h,form:p,...t,tabIndex:-1,ref:S,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sz.displayName=wz;function Mve(e){return typeof e=="function"}function ki(e){return e==="indeterminate"}function jz(e){return ki(e)?"indeterminate":e?"checked":"unchecked"}const va=v.forwardRef(({className:e,...t},n)=>s.jsx(hC,{ref:n,className:Se("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(bz,{className:Se("flex items-center justify-center text-current"),children:s.jsx(ql,{className:"h-4 w-4"})})}));va.displayName=hC.displayName;const $ve=Io("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Bl=v.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert",className:Se($ve({variant:t}),e),...n}));Bl.displayName="Alert";const zl=v.forwardRef(({className:e,...t},n)=>s.jsx("h5",{ref:n,className:Se("mb-1 font-medium leading-none tracking-tight",e),...t}));zl.displayName="AlertTitle";const Ul=v.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:Se("text-sm [&_p]:leading-relaxed",e),...t}));Ul.displayName="AlertDescription";function Dve(e,t=[]){let n=[];function r(i,o){const c=v.createContext(o);c.displayName=i+"Context";const d=n.length;n=[...n,o];const f=p=>{const{scope:y,children:g,...S}=p,b=y?.[e]?.[d]||c,x=v.useMemo(()=>S,Object.values(S));return s.jsx(b.Provider,{value:x,children:g})};f.displayName=i+"Provider";function h(p,y){const g=y?.[e]?.[d]||c,S=v.useContext(g);if(S)return S;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[f,h]}const a=()=>{const i=n.map(o=>v.createContext(o));return function(c){const d=c?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return a.scopeName=e,[r,Lve(a,...t)]}function Lve(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(i)[`__scope${f}`];return{...c,...p}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nz=Fve.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),mC="Progress",vC=100,[Bve]=Dve(mC),[zve,Uve]=Bve(mC),Cz=v.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=qve,...o}=e;(a||a===0)&&!cM(a)&&console.error(Wve(`${a}`,"Progress"));const c=cM(a)?a:vC;r!==null&&!uM(r,c)&&console.error(Vve(`${r}`,"Progress"));const d=uM(r,c)?r:null,f=bm(d)?i(d,c):void 0;return s.jsx(zve,{scope:n,value:d,max:c,children:s.jsx(Nz.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":bm(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":Ez(d,c),"data-value":d??void 0,"data-max":c,...o,ref:t})})});Cz.displayName=mC;var _z="ProgressIndicator",Az=v.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,a=Uve(_z,n);return s.jsx(Nz.div,{"data-state":Ez(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})});Az.displayName=_z;function qve(e,t){return`${Math.round(e/t*100)}%`}function Ez(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function bm(e){return typeof e=="number"}function cM(e){return bm(e)&&!isNaN(e)&&e>0}function uM(e,t){return bm(e)&&!isNaN(e)&&e<=t&&e>=0}function Wve(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${vC}\`.`}function Vve(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
130
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},fme=f8,pme=p8,j8=h8,N8=m8,C8=b8,_8=S8,A8=g8,E8=x8;const bs=fme,hme=pme,P8=v.forwardRef(({className:e,...t},n)=>s.jsx(j8,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));P8.displayName=j8.displayName;const Va=v.forwardRef(({className:e,...t},n)=>s.jsxs(hme,{children:[s.jsx(P8,{}),s.jsx(N8,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Va.displayName=N8.displayName;const Ha=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ha.displayName="AlertDialogHeader";const Ka=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ka.displayName="AlertDialogFooter";const Ga=v.forwardRef(({className:e,...t},n)=>s.jsx(A8,{ref:n,className:Se("text-lg font-semibold",e),...t}));Ga.displayName=A8.displayName;const Ya=v.forwardRef(({className:e,...t},n)=>s.jsx(E8,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));Ya.displayName=E8.displayName;const Xa=v.forwardRef(({className:e,...t},n)=>s.jsx(C8,{ref:n,className:Se(zj(),e),...t}));Xa.displayName=C8.displayName;const Qa=v.forwardRef(({className:e,...t},n)=>s.jsx(_8,{ref:n,className:Se(zj({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Qa.displayName=_8.displayName;const mme=()=>{const{servers:e,setServers:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=p=>p.name?.trim()||p.id,d=async p=>{const y=`${c(p)}-copy`;let g=y,S=1;for(;e.some(x=>(x.name?.trim()||x.id)===g);)g=`${y}-${S}`,S+=1;const b={...structuredClone(p),id:`srv-${Date.now()}`,name:g};await t([...e,b]),Pe({title:"Server duplicated",description:`Created ${g}.`})},f=async p=>{await t(e.filter(y=>y.id!==p.id)),Pe({title:"Server deleted",description:`${c(p)} was removed.`}),o(null)},h=p=>p.transport==="stdio"?[p.command,...p.args||[]].filter(Boolean).join(" "):p.url||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(e$,{className:"h-6 w-6"}),"Servers"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable MCP server definitions shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No servers configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]}):s.jsx(ze,{children:s.jsx(Ue,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Transport"}),s.jsx(Qe,{children:"Endpoint"}),s.jsx(Qe,{children:"Auth"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(p=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(Be,{className:"font-medium",children:c(p)}),s.jsx(Be,{children:s.jsx(Ke,{variant:"secondary",className:"font-mono text-xs",children:p.transport})}),s.jsx(Be,{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h(p)})}),s.jsx(Be,{children:!p.authType||p.authType==="none"?s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):s.jsx(Ke,{variant:"outline",className:"text-xs",children:p.authType})}),s.jsx(Be,{className:"text-right",onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(p),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{d(p)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},p.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:p=>!p&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?c(i):""})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&f(i)},children:"Delete Server"})]})]})})]})},tM={stdio:"Check that the command is installed and the args are correct",sse:"Check that the server is running and the URL is reachable","streamable-http":"Check that the server is running and the URL is reachable"},vme=()=>({id:`srv-${Date.now()}`,name:"",transport:"stdio",authType:"none",oauthRedirectUrl:"http://localhost:6274/oauth/"}),gme=()=>{const{serverId:e}=Mo(),t=wa(),{servers:n,setServers:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(R=>R.id===o||R.name===o),d=R=>R.name?.trim()||R.id,[f,h]=v.useState(()=>c??vme()),[p,y]=v.useState(!1),[g,S]=v.useState(!1),[b,x]=v.useState({status:"idle"}),[j,N]=v.useState(!1);v.useEffect(()=>{c&&h(c)},[c]);const _=R=>{h($=>({...$,authType:R,...R!=="oauth2"?{oauthClientId:void 0,oauthClientSecret:void 0,oauthRedirectUrl:void 0,oauthScope:void 0}:{oauthRedirectUrl:$.oauthRedirectUrl||"http://localhost:6274/oauth/"}}))},P=async()=>{N(!0),x({status:"loading"});try{const $=(await a.discoverToolsForAnalysis({serverNames:[f.id]})).servers[0];$&&$.warnings.length===0?x({status:"success",toolNames:$.tools.map(z=>z.name),toolCount:$.tools.length,testedAt:new Date().toISOString()}):x({status:"error",message:$?.warnings[0]??"Connection failed",testedAt:new Date().toISOString()})}catch(R){x({status:"error",message:R instanceof Error?R.message:String(R),testedAt:new Date().toISOString()})}},A=async()=>{if(!f.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}S(!0);try{if(i)await r([...n,f]),Pe({title:"Server created"}),t(`/libraries/servers/${encodeURIComponent(f.id)}`);else{const R=n.map($=>$.id===c?.id?f:$);await r(R),Pe({title:"Server saved"}),f.id!==o&&t(`/libraries/servers/${encodeURIComponent(f.id)}`,{replace:!0})}}finally{S(!1)}},O=async()=>{const R=n.filter($=>$.id!==c?.id);await r(R),Pe({title:"Server deleted"}),t("/libraries/servers")},k=()=>f.transport==="stdio"?[f.command,...f.args||[]].filter(Boolean).join(" "):f.url||"";return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Server "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Server":d(f)})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{P()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),j&&s.jsxs(ze,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>N(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(Ue,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Server:"}),s.jsx("span",{className:"font-medium text-foreground",children:d(f)}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Transport:"}),s.jsx("span",{className:"font-medium text-foreground",children:f.transport}),k()&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsx("code",{className:"font-mono text-xs",children:k()})]})]}),b.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Connecting to MCP server…"]}),b.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",b.toolCount," tool",b.toolCount!==1?"s":""]}),b.toolNames.length>0&&s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"First 5 tools:"}),s.jsx("ul",{className:"space-y-0.5",children:b.toolNames.slice(0,5).map(R=>s.jsx("li",{className:"font-mono text-xs",children:R},R))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]}),b.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," — ",b.message]}),tM[f.transport]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",tM[f.transport]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]})]})]}),s.jsxs(ze,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(Ue,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:f.name,onChange:R=>h($=>({...$,name:R.target.value})),placeholder:"e.g. Filesystem MCP"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Transport"}),s.jsxs(sn,{value:f.transport,onValueChange:R=>h($=>({...$,transport:R})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"stdio",children:"stdio"}),s.jsx(at,{value:"sse",children:"SSE"}),s.jsx(at,{value:"streamable-http",children:"Streamable HTTP"})]})]})]})]}),f.transport==="stdio"?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Command"}),s.jsx(ht,{value:f.command||"",onChange:R=>h($=>({...$,command:R.target.value})),placeholder:"npx",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Args (comma-separated)"}),s.jsx(ht,{value:(f.args||[]).join(", "),onChange:R=>h($=>({...$,args:R.target.value.split(",").map(z=>z.trim()).filter(Boolean)})),placeholder:"-y, @mcp/server",className:"font-mono text-xs"})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"URL"}),s.jsx(ht,{value:f.url||"",onChange:R=>h($=>({...$,url:R.target.value})),placeholder:"http://localhost:3001/sse",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Auth Type"}),s.jsxs(sn,{value:f.authType||"none",onValueChange:R=>_(R),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"none",children:"None"}),s.jsx(at,{value:"bearer",children:"Bearer Token"}),s.jsx(at,{value:"api-key",children:"API Key"}),s.jsx(at,{value:"oauth2",children:"OAuth 2.0"})]})]})]}),f.authType&&f.authType!=="none"&&f.authType!=="oauth2"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:f.authType==="bearer"?"Token":"API Key"}),s.jsx(ht,{type:"password",value:f.authValue||"",onChange:R=>h($=>({...$,authValue:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),f.authType==="oauth2"&&s.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"OAuth 2.0 Flow"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client ID"}),s.jsx(ht,{value:f.oauthClientId||"",onChange:R=>h($=>({...$,oauthClientId:R.target.value})),placeholder:"your-client-id",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client Secret (optional)"}),s.jsx(ht,{type:"password",value:f.oauthClientSecret||"",onChange:R=>h($=>({...$,oauthClientSecret:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Redirect URL"}),s.jsx(ht,{value:f.oauthRedirectUrl||"http://localhost:6274/oauth/",onChange:R=>h($=>({...$,oauthRedirectUrl:R.target.value})),placeholder:"http://localhost:6274/oauth/",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Scope (space-separated)"}),s.jsx(ht,{value:f.oauthScope||"",onChange:R=>h($=>({...$,oauthScope:R.target.value})),placeholder:"openid profile mcp",className:"font-mono text-xs"})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>y(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/servers"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{A()},disabled:g,children:[g&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Server":"Save"]})]})]})]})]}),s.jsx(bs,{open:p,onOpenChange:y,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove the server"," ",s.jsx("span",{className:"font-mono",children:f.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{O()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},yme=()=>{const{agents:e,setAgents:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=async f=>{const h=`${f.name}-copy`;let p=h,y=1;for(;e.some(S=>S.name===p);)p=`${h}-${y}`,y+=1;const g={...structuredClone(f),id:`agt-${Date.now()}`,name:p};await t([...e,g]),Pe({title:"Agent duplicated",description:`Created ${p}.`})},d=async f=>{await t(e.filter(h=>h.id!==f.id)),Pe({title:"Agent deleted",description:`${f.name} was removed.`}),o(null)};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(ha,{className:"h-6 w-6"}),"Agents"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable agent profiles shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]}):s.jsx(ze,{children:s.jsx(Ue,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Provider"}),s.jsx(Qe,{children:"Model"}),s.jsx(Qe,{children:"Max Tokens"}),s.jsx(Qe,{children:"Temperature"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(f=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(Be,{className:"font-medium",children:f.name}),s.jsx(Be,{children:s.jsx(aB,{provider:f.provider})}),s.jsx(Be,{children:s.jsx("span",{className:"font-mono text-xs",children:f.model})}),s.jsx(Be,{className:"font-mono text-xs",children:f.maxTokens}),s.jsx(Be,{className:"font-mono text-xs",children:f.temperature.toFixed(2)}),s.jsx(Be,{className:"text-right",onClick:h=>h.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(f),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{c(f)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},f.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:f=>!f&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?.name})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&d(i)},children:"Delete Agent"})]})]})})]})};var O8=["PageUp","PageDown"],k8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R8={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Uc="Slider",[cj,xme,bme]=Hd(Uc),[T8]=ir(Uc,[bme]),[wme,Yv]=T8(Uc),I8=v.forwardRef((e,t)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[r],value:h,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:g=!1,form:S,...b}=e,x=v.useRef(new Set),j=v.useRef(0),_=o==="horizontal"?Sme:jme,[P=[],A]=na({prop:h,defaultProp:f,onChange:B=>{[...x.current][j.current]?.focus(),p(B)}}),O=v.useRef(P);function k(B){const D=Eme(P,B);z(B,D)}function R(B){z(B,j.current)}function $(){const B=O.current[j.current];P[j.current]!==B&&y(P)}function z(B,D,{commit:K}={commit:!1}){const U=Rme(i),V=Tme(Math.round((B-r)/i)*i+r,U),X=Vd(V,[r,a]);A((Z=[])=>{const T=_me(Z,X,D);if(kme(T,d*i)){j.current=T.indexOf(X);const L=String(T)!==String(Z);return L&&K&&y(T),L?T:Z}else return Z})}return s.jsx(wme,{scope:e.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:j,thumbs:x.current,values:P,orientation:o,form:S,children:s.jsx(cj.Provider,{scope:e.__scopeSlider,children:s.jsx(cj.Slot,{scope:e.__scopeSlider,children:s.jsx(_,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:Ae(b.onPointerDown,()=>{c||(O.current=P)}),min:r,max:a,inverted:g,onSlideStart:c?void 0:k,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:$,onHomeKeyDown:()=>!c&&z(r,0,{commit:!0}),onEndKeyDown:()=>!c&&z(a,P.length-1,{commit:!0}),onStepKeyDown:({event:B,direction:D})=>{if(!c){const V=O8.includes(B.key)||B.shiftKey&&k8.includes(B.key)?10:1,X=j.current,Z=P[X],T=i*V*D;z(Z+T,X,{commit:!0})}}})})})})});I8.displayName=Uc;var[M8,$8]=T8(Uc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Sme=v.forwardRef((e,t)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:d,onStepKeyDown:f,...h}=e,[p,y]=v.useState(null),g=ut(t,_=>y(_)),S=v.useRef(void 0),b=Lc(a),x=b==="ltr",j=x&&!i||!x&&i;function N(_){const P=S.current||p.getBoundingClientRect(),A=[0,P.width],k=uC(A,j?[n,r]:[r,n]);return S.current=P,k(_-P.left)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:j?"left":"right",endEdge:j?"right":"left",direction:j?1:-1,size:"width",children:s.jsx(D8,{dir:b,"data-orientation":"horizontal",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const P=N(_.clientX);o?.(P)},onSlideMove:_=>{const P=N(_.clientX);c?.(P)},onSlideEnd:()=>{S.current=void 0,d?.()},onStepKeyDown:_=>{const A=R8[j?"from-left":"from-right"].includes(_.key);f?.({event:_,direction:A?-1:1})}})})}),jme=v.forwardRef((e,t)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:d,...f}=e,h=v.useRef(null),p=ut(t,h),y=v.useRef(void 0),g=!a;function S(b){const x=y.current||h.current.getBoundingClientRect(),j=[0,x.height],_=uC(j,g?[r,n]:[n,r]);return y.current=x,_(b-x.top)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:s.jsx(D8,{"data-orientation":"vertical",...f,ref:p,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=S(b.clientY);i?.(x)},onSlideMove:b=>{const x=S(b.clientY);o?.(x)},onSlideEnd:()=>{y.current=void 0,c?.()},onStepKeyDown:b=>{const j=R8[g?"from-bottom":"from-top"].includes(b.key);d?.({event:b,direction:j?-1:1})}})})}),D8=v.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:d,...f}=e,h=Yv(Uc,n);return s.jsx(De.span,{...f,ref:t,onKeyDown:Ae(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(c(p),p.preventDefault()):O8.concat(k8).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:Ae(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Ae(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&a(p)}),onPointerUp:Ae(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),i(p))})})}),L8="SliderTrack",F8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(L8,n);return s.jsx(De.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});F8.displayName=L8;var uj="SliderRange",B8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(uj,n),i=$8(uj,n),o=v.useRef(null),c=ut(t,o),d=a.values.length,f=a.values.map(y=>q8(y,a.min,a.max)),h=d>1?Math.min(...f):0,p=100-Math.max(...f);return s.jsx(De.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:p+"%"}})});B8.displayName=uj;var dj="SliderThumb",z8=v.forwardRef((e,t)=>{const n=xme(e.__scopeSlider),[r,a]=v.useState(null),i=ut(t,c=>a(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(Nme,{...e,ref:i,index:o})}),Nme=v.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:a,...i}=e,o=Yv(dj,n),c=$8(dj,n),[d,f]=v.useState(null),h=ut(t,N=>f(N)),p=d?o.form||!!d.closest("form"):!0,y=km(d),g=o.values[r],S=g===void 0?0:q8(g,o.min,o.max),b=Ame(r,o.values.length),x=y?.[c.size],j=x?Pme(x,S,c.direction):0;return v.useEffect(()=>{if(d)return o.thumbs.add(d),()=>{o.thumbs.delete(d)}},[d,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${S}% + ${j}px)`},children:[s.jsx(cj.ItemSlot,{scope:e.__scopeSlider,children:s.jsx(De.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":g,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:h,style:g===void 0?{display:"none"}:e.style,onFocus:Ae(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&s.jsx(U8,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:g},r)]})});z8.displayName=dj;var Cme="RadioBubbleInput",U8=v.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(a,r),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("input",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});U8.displayName=Cme;function _me(e=[],t,n){const r=[...e];return r[n]=t,r.sort((a,i)=>a-i)}function q8(e,t,n){const i=100/(n-t)*(e-t);return Vd(i,[0,100])}function Ame(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Eme(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),r=Math.min(...n);return n.indexOf(r)}function Pme(e,t,n){const r=e/2,i=uC([0,50],[0,r]);return(r-i(t)*n)*n}function Ome(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function kme(e,t){if(t>0){const n=Ome(e);return Math.min(...n)>=t}return!0}function uC(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Rme(e){return(String(e).split(".")[1]||"").length}function Tme(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var W8=I8,Ime=F8,Mme=B8,$me=z8;const V8=v.forwardRef(({className:e,...t},n)=>s.jsxs(W8,{ref:n,className:Se("relative flex w-full touch-none select-none items-center",e),...t,children:[s.jsx(Ime,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:s.jsx(Mme,{className:"absolute h-full bg-primary"})}),s.jsx($me,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));V8.displayName=W8.displayName;function Dme(e){const t=Lme(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Bme);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Lme(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ume(a),c=zme(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fme=Symbol("radix.slottable");function Bme(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fme}function zme(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ume(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xv="Popover",[H8]=ir(Xv,[Di]),vf=Di(),[qme,Vi]=H8(Xv),K8=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,c=vf(t),d=v.useRef(null),[f,h]=v.useState(!1),[p,y]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Xv});return s.jsx(Rm,{...c,children:s.jsx(qme,{scope:t,contentId:Hn(),triggerRef:d,open:p,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:f,onCustomAnchorAdd:v.useCallback(()=>h(!0),[]),onCustomAnchorRemove:v.useCallback(()=>h(!1),[]),modal:o,children:n})})};K8.displayName=Xv;var G8="PopoverAnchor",Wme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(G8,n),i=vf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:c}=a;return v.useEffect(()=>(o(),()=>c()),[o,c]),s.jsx(Yd,{...i,...r,ref:t})});Wme.displayName=G8;var Y8="PopoverTrigger",X8=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(Y8,n),i=vf(n),o=ut(t,a.triggerRef),c=s.jsx(De.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":tz(a.open),...r,ref:o,onClick:Ae(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:s.jsx(Yd,{asChild:!0,...i,children:c})});X8.displayName=Y8;var dC="PopoverPortal",[Vme,Hme]=H8(dC,{forceMount:void 0}),Q8=e=>{const{__scopePopover:t,forceMount:n,children:r,container:a}=e,i=Vi(dC,t);return s.jsx(Vme,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Q8.displayName=dC;var bc="PopoverContent",J8=v.forwardRef((e,t)=>{const n=Hme(bc,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,i=Vi(bc,e.__scopePopover);return s.jsx(Gn,{present:r||i.open,children:i.modal?s.jsx(Gme,{...a,ref:t}):s.jsx(Yme,{...a,ref:t})})});J8.displayName=bc;var Kme=Dme("PopoverContent.RemoveScroll"),Gme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(null),a=ut(t,r),i=v.useRef(!1);return v.useEffect(()=>{const o=r.current;if(o)return Hm(o)},[]),s.jsx(Qd,{as:Kme,allowPinchZoom:!0,children:s.jsx(Z8,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,o=>{o.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Ae(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Yme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(!1),a=v.useRef(!1);return s.jsx(Z8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z8=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...p}=e,y=Vi(bc,n),g=vf(n);return Wm(),s.jsx(Xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>y.onOpenChange(!1),children:s.jsx(Tm,{"data-state":tz(y.open),role:"dialog",id:y.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ez="PopoverClose",Xme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(ez,n);return s.jsx(De.button,{type:"button",...r,ref:t,onClick:Ae(e.onClick,()=>a.onOpenChange(!1))})});Xme.displayName=ez;var Qme="PopoverArrow",Jme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=vf(n);return s.jsx(Im,{...a,...r,ref:t})});Jme.displayName=Qme;function tz(e){return e?"open":"closed"}var Zme=K8,eve=X8,tve=Q8,nz=J8;const nve=Zme,rve=eve,rz=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>s.jsx(tve,{children:s.jsx(nz,{ref:a,align:t,sideOffset:n,className:Se("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));rz.displayName=nz.displayName;var nM=1,ave=.9,sve=.8,ive=.17,r1=.1,a1=.999,ove=.9999,lve=.99,cve=/[\\\/_+.#"@\[\(\{&]/,uve=/[\\\/_+.#"@\[\(\{&]/g,dve=/[\s-]/,az=/[\s-]/g;function fj(e,t,n,r,a,i,o){if(i===t.length)return a===e.length?nM:lve;var c=`${a},${i}`;if(o[c]!==void 0)return o[c];for(var d=r.charAt(i),f=n.indexOf(d,a),h=0,p,y,g,S;f>=0;)p=fj(e,t,n,r,f+1,i+1,o),p>h&&(f===a?p*=nM:cve.test(e.charAt(f-1))?(p*=sve,g=e.slice(a,f-1).match(uve),g&&a>0&&(p*=Math.pow(a1,g.length))):dve.test(e.charAt(f-1))?(p*=ave,S=e.slice(a,f-1).match(az),S&&a>0&&(p*=Math.pow(a1,S.length))):(p*=ive,a>0&&(p*=Math.pow(a1,f-a))),e.charAt(f)!==t.charAt(i)&&(p*=ove)),(p<r1&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(y=fj(e,t,n,r,f+1,i+2,o),y*r1>p&&(p=y*r1)),p>h&&(h=p),f=n.indexOf(d,f+1);return o[c]=h,h}function rM(e){return e.toLowerCase().replace(az," ")}function fve(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fj(e,t,rM(e),rM(t),0,0,{})}var Du='[cmdk-group=""]',s1='[cmdk-group-items=""]',pve='[cmdk-group-heading=""]',sz='[cmdk-item=""]',aM=`${sz}:not([aria-disabled="true"])`,pj="cmdk-item-select",Sl="data-value",hve=(e,t,n)=>fve(e,t,n),iz=v.createContext(void 0),gf=()=>v.useContext(iz),oz=v.createContext(void 0),fC=()=>v.useContext(oz),lz=v.createContext(void 0),cz=v.forwardRef((e,t)=>{let n=jl(()=>{var M,ee;return{search:"",value:(ee=(M=e.value)!=null?M:e.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=jl(()=>new Set),a=jl(()=>new Map),i=jl(()=>new Map),o=jl(()=>new Set),c=uz(e),{label:d,children:f,value:h,onValueChange:p,filter:y,shouldFilter:g,loop:S,disablePointerSelection:b=!1,vimBindings:x=!0,...j}=e,N=Hn(),_=Hn(),P=Hn(),A=v.useRef(null),O=Cve();Ro(()=>{if(h!==void 0){let M=h.trim();n.current.value=M,k.emit()}},[h]),Ro(()=>{O(6,K)},[]);let k=v.useMemo(()=>({subscribe:M=>(o.current.add(M),()=>o.current.delete(M)),snapshot:()=>n.current,setState:(M,ee,W)=>{var J,ye,ae,ue;if(!Object.is(n.current[M],ee)){if(n.current[M]=ee,M==="search")D(),z(),O(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ie=document.getElementById(P);ie?ie.focus():(J=document.getElementById(N))==null||J.focus()}if(O(7,()=>{var ie;n.current.selectedItemId=(ie=U())==null?void 0:ie.id,k.emit()}),W||O(5,K),((ye=c.current)==null?void 0:ye.value)!==void 0){let ie=ee??"";(ue=(ae=c.current).onValueChange)==null||ue.call(ae,ie);return}}k.emit()}},emit:()=>{o.current.forEach(M=>M())}}),[]),R=v.useMemo(()=>({value:(M,ee,W)=>{var J;ee!==((J=i.current.get(M))==null?void 0:J.value)&&(i.current.set(M,{value:ee,keywords:W}),n.current.filtered.items.set(M,$(ee,W)),O(2,()=>{z(),k.emit()}))},item:(M,ee)=>(r.current.add(M),ee&&(a.current.has(ee)?a.current.get(ee).add(M):a.current.set(ee,new Set([M]))),O(3,()=>{D(),z(),n.current.value||B(),k.emit()}),()=>{i.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let W=U();O(4,()=>{D(),W?.getAttribute("id")===M&&B(),k.emit()})}),group:M=>(a.current.has(M)||a.current.set(M,new Set),()=>{i.current.delete(M),a.current.delete(M)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:N,inputId:P,labelId:_,listInnerRef:A}),[]);function $(M,ee){var W,J;let ye=(J=(W=c.current)==null?void 0:W.filter)!=null?J:hve;return M?ye(M,n.current.search,ee):0}function z(){if(!n.current.search||c.current.shouldFilter===!1)return;let M=n.current.filtered.items,ee=[];n.current.filtered.groups.forEach(J=>{let ye=a.current.get(J),ae=0;ye.forEach(ue=>{let ie=M.get(ue);ae=Math.max(ie,ae)}),ee.push([J,ae])});let W=A.current;V().sort((J,ye)=>{var ae,ue;let ie=J.getAttribute("id"),ve=ye.getAttribute("id");return((ae=M.get(ve))!=null?ae:0)-((ue=M.get(ie))!=null?ue:0)}).forEach(J=>{let ye=J.closest(s1);ye?ye.appendChild(J.parentElement===ye?J:J.closest(`${s1} > *`)):W.appendChild(J.parentElement===W?J:J.closest(`${s1} > *`))}),ee.sort((J,ye)=>ye[1]-J[1]).forEach(J=>{var ye;let ae=(ye=A.current)==null?void 0:ye.querySelector(`${Du}[${Sl}="${encodeURIComponent(J[0])}"]`);ae?.parentElement.appendChild(ae)})}function B(){let M=V().find(W=>W.getAttribute("aria-disabled")!=="true"),ee=M?.getAttribute(Sl);k.setState("value",ee||void 0)}function D(){var M,ee,W,J;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ae of r.current){let ue=(ee=(M=i.current.get(ae))==null?void 0:M.value)!=null?ee:"",ie=(J=(W=i.current.get(ae))==null?void 0:W.keywords)!=null?J:[],ve=$(ue,ie);n.current.filtered.items.set(ae,ve),ve>0&&ye++}for(let[ae,ue]of a.current)for(let ie of ue)if(n.current.filtered.items.get(ie)>0){n.current.filtered.groups.add(ae);break}n.current.filtered.count=ye}function K(){var M,ee,W;let J=U();J&&(((M=J.parentElement)==null?void 0:M.firstChild)===J&&((W=(ee=J.closest(Du))==null?void 0:ee.querySelector(pve))==null||W.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function U(){var M;return(M=A.current)==null?void 0:M.querySelector(`${sz}[aria-selected="true"]`)}function V(){var M;return Array.from(((M=A.current)==null?void 0:M.querySelectorAll(aM))||[])}function X(M){let ee=V()[M];ee&&k.setState("value",ee.getAttribute(Sl))}function Z(M){var ee;let W=U(),J=V(),ye=J.findIndex(ue=>ue===W),ae=J[ye+M];(ee=c.current)!=null&&ee.loop&&(ae=ye+M<0?J[J.length-1]:ye+M===J.length?J[0]:J[ye+M]),ae&&k.setState("value",ae.getAttribute(Sl))}function T(M){let ee=U(),W=ee?.closest(Du),J;for(;W&&!J;)W=M>0?jve(W,Du):Nve(W,Du),J=W?.querySelector(aM);J?k.setState("value",J.getAttribute(Sl)):Z(M)}let L=()=>X(V().length-1),Q=M=>{M.preventDefault(),M.metaKey?L():M.altKey?T(1):Z(1)},F=M=>{M.preventDefault(),M.metaKey?X(0):M.altKey?T(-1):Z(-1)};return v.createElement(De.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:M=>{var ee;(ee=j.onKeyDown)==null||ee.call(j,M);let W=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||W))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&Q(M);break}case"ArrowDown":{Q(M);break}case"p":case"k":{x&&M.ctrlKey&&F(M);break}case"ArrowUp":{F(M);break}case"Home":{M.preventDefault(),X(0);break}case"End":{M.preventDefault(),L();break}case"Enter":{M.preventDefault();let J=U();if(J){let ye=new Event(pj);J.dispatchEvent(ye)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Ave},d),Qv(e,M=>v.createElement(oz.Provider,{value:k},v.createElement(iz.Provider,{value:R},M))))}),mve=v.forwardRef((e,t)=>{var n,r;let a=Hn(),i=v.useRef(null),o=v.useContext(lz),c=gf(),d=uz(e),f=(r=(n=d.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;Ro(()=>{if(!f)return c.item(a,o?.id)},[f]);let h=dz(a,i,[e.value,e.children,i],e.keywords),p=fC(),y=$i(O=>O.value&&O.value===h.current),g=$i(O=>f||c.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);v.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(pj,S),()=>O.removeEventListener(pj,S)},[g,e.onSelect,e.disabled]);function S(){var O,k;b(),(k=(O=d.current).onSelect)==null||k.call(O,h.current)}function b(){p.setState("value",h.current,!0)}if(!g)return null;let{disabled:x,value:j,onSelect:N,forceMount:_,keywords:P,...A}=e;return v.createElement(De.div,{ref:jr(i,t),...A,id:a,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||c.getDisablePointerSelection()?void 0:b,onClick:x?void 0:S},e.children)}),vve=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...i}=e,o=Hn(),c=v.useRef(null),d=v.useRef(null),f=Hn(),h=gf(),p=$i(g=>a||h.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);Ro(()=>h.group(o),[]),dz(o,c,[e.value,e.heading,d]);let y=v.useMemo(()=>({id:o,forceMount:a}),[a]);return v.createElement(De.div,{ref:jr(c,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&v.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Qv(e,g=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},v.createElement(lz.Provider,{value:y},g))))}),gve=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),i=$i(o=>!o.search);return!n&&!i?null:v.createElement(De.div,{ref:jr(a,t),...r,"cmdk-separator":"",role:"separator"})}),yve=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,a=e.value!=null,i=fC(),o=$i(f=>f.search),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),v.createElement(De.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:o,onChange:f=>{a||i.setState("search",f.target.value),n?.(f.target.value)}})}),xve=v.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...a}=e,i=v.useRef(null),o=v.useRef(null),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{if(o.current&&i.current){let f=o.current,h=i.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let g=f.offsetHeight;h.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return y.observe(f),()=>{cancelAnimationFrame(p),y.unobserve(f)}}},[]),v.createElement(De.div,{ref:jr(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:d.listId},Qv(e,f=>v.createElement("div",{ref:jr(o,d.listInnerRef),"cmdk-list-sizer":""},f)))}),bve=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...c}=e;return v.createElement(Gm,{open:n,onOpenChange:r},v.createElement(Ym,{container:o},v.createElement(Pc,{"cmdk-overlay":"",className:a}),v.createElement(Oc,{"aria-label":e.label,"cmdk-dialog":"",className:i},v.createElement(cz,{ref:t,...c}))))}),wve=v.forwardRef((e,t)=>$i(n=>n.filtered.count===0)?v.createElement(De.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sve=v.forwardRef((e,t)=>{let{progress:n,children:r,label:a="Loading...",...i}=e;return v.createElement(De.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Qv(e,o=>v.createElement("div",{"aria-hidden":!0},o)))}),$r=Object.assign(cz,{List:xve,Item:mve,Input:yve,Group:vve,Separator:gve,Dialog:bve,Empty:wve,Loading:Sve});function jve(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nve(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function uz(e){let t=v.useRef(e);return Ro(()=>{t.current=e}),t}var Ro=typeof window>"u"?v.useEffect:v.useLayoutEffect;function jl(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function $i(e){let t=fC(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function dz(e,t,n,r=[]){let a=v.useRef(),i=gf();return Ro(()=>{var o;let c=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():a.current}})(),d=r.map(f=>f.trim());i.value(e,c,d),(o=t.current)==null||o.setAttribute(Sl,c),a.current=c}),a}var Cve=()=>{let[e,t]=v.useState(),n=jl(()=>new Map);return Ro(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,a)=>{n.current.set(r,a),t({})}};function _ve(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qv({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(_ve(t),{ref:t.ref},n(t.props.children)):n(t)}var Ave={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const fz=v.forwardRef(({className:e,...t},n)=>s.jsx($r,{ref:n,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));fz.displayName=$r.displayName;const pz=v.forwardRef(({className:e,...t},n)=>s.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[s.jsx(Sj,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx($r.Input,{ref:n,className:Se("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));pz.displayName=$r.Input.displayName;const hz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.List,{ref:n,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));hz.displayName=$r.List.displayName;const mz=v.forwardRef((e,t)=>s.jsx($r.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));mz.displayName=$r.Empty.displayName;const vz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Group,{ref:n,className:Se("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));vz.displayName=$r.Group.displayName;const Eve=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Separator,{ref:n,className:Se("-mx-1 h-px bg-border",e),...t}));Eve.displayName=$r.Separator.displayName;const hj=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Item,{ref:n,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));hj.displayName=$r.Item.displayName;const sM={openai:["gpt-4o","gpt-4o-mini","gpt-4-turbo","o1","o1-mini"],anthropic:["claude-3-5-sonnet-latest","claude-3-5-haiku-latest","claude-3-opus-latest"],azure:["gpt-4o","gpt-4-turbo"],google:["gemini-2.0-flash","gemini-1.5-pro"],custom:[]},iM={anthropic:"Check that `ANTHROPIC_API_KEY` is set in your environment",openai:"Check that `OPENAI_API_KEY` is set in your environment",azure:"Check that Azure OpenAI env vars are configured in your environment"},Pve=()=>({id:`agt-${Date.now()}`,name:"",provider:"openai",model:"gpt-4o",temperature:0,maxTokens:4096}),Ove=()=>{const{agentName:e}=Mo(),t=wa(),{agents:n,setAgents:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(T=>T.id===o)??n.find(T=>T.name===o),[d,f]=v.useState(()=>c??Pve()),[h,p]=v.useState(!1),[y,g]=v.useState(!1),[S,b]=v.useState({status:"idle"}),[x,j]=v.useState(!1),[N,_]=v.useState([]),[P,A]=v.useState(!1),[O,k]=v.useState(!1),[R,$]=v.useState(!1);v.useEffect(()=>{c&&f(c)},[c]);const z=d.provider==="anthropic"||d.provider==="openai"||d.provider==="azure",B=Array.from(new Set([...sM[d.provider]||[],...N])),D=B.includes(d.model),K=R||!!d.model&&!D,U=async()=>{if(j(!0),d.provider==="google"||d.provider==="custom"){b({status:"unsupported"});return}b({status:"loading"});try{const T=await a.listProviderModels(d.provider);b({status:"success",items:T.items,source:T.source,kind:T.kind,testedAt:new Date().toISOString()})}catch(T){b({status:"error",message:T instanceof Error?T.message:String(T),testedAt:new Date().toISOString()})}},V=async()=>{if(!z){Pe({title:"Provider discovery not supported",description:"Model discovery is available for Anthropic, OpenAI, and Azure OpenAI."});return}A(!0);try{const T=await a.listProviderModels(d.provider);_(T.items),Pe({title:T.kind==="deployments"?"Deployments loaded":"Models loaded",description:`${T.items.length} ${T.kind} from ${T.source}`})}catch(T){Pe({title:"Could not load provider models",description:String(T instanceof Error?T.message:T),variant:"destructive"})}finally{A(!1)}},X=async()=>{if(!d.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}g(!0);try{if(i)await r([...n,d]),Pe({title:"Agent created"}),t(`/libraries/agents/${encodeURIComponent(d.id)}`);else{const T=n.map(L=>L.id===c?.id?d:L);await r(T),Pe({title:"Agent saved"}),d.id!==o&&t(`/libraries/agents/${encodeURIComponent(d.id)}`,{replace:!0})}}finally{g(!1)}},Z=async()=>{const T=n.filter(L=>L.id!==c?.id);await r(T),Pe({title:"Agent deleted"}),t("/libraries/agents")};return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Agent "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Agent":d.name})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{U()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),x&&s.jsxs(ze,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>j(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(Ue,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Provider:"}),s.jsx("span",{className:"font-medium text-foreground",children:d.provider}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsxs("code",{className:"font-mono text-xs",children:["/api/providers/models?provider=",d.provider]})]}),S.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Testing connection..."]}),S.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",S.items.length," ",S.kind," from"," ",S.source]}),s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsxs("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:["First 5 ",S.kind,":"]}),s.jsx("ul",{className:"space-y-0.5",children:S.items.slice(0,5).map(T=>s.jsx("li",{className:"font-mono text-xs",children:T},T))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," —"," ",S.message]}),iM[d.provider]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",iM[d.provider]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="unsupported"&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground",children:["Connection testing is not supported for the"," ",s.jsx("span",{className:"font-medium",children:d.provider})," provider. Supported providers: Anthropic, OpenAI, Azure OpenAI."]})]})]}),s.jsxs(ze,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(Ue,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:d.name,onChange:T=>f(L=>({...L,name:T.target.value})),placeholder:"e.g. GPT-4o"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Provider"}),s.jsxs(sn,{value:d.provider,onValueChange:T=>f(L=>({...L,provider:T,model:sM[T]?.[0]||""})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"openai",children:"OpenAI"}),s.jsx(at,{value:"anthropic",children:"Anthropic"}),s.jsx(at,{value:"azure",children:"Azure OpenAI"}),s.jsx(at,{value:"google",children:"Google"}),s.jsx(at,{value:"custom",children:"Custom"})]})]})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:d.provider==="azure"?"Deployment":"Model"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(nve,{open:O,onOpenChange:k,children:[s.jsx(rve,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"outline",role:"combobox","aria-expanded":O,className:"h-9 flex-1 justify-between font-mono text-xs",children:[s.jsx("span",{className:"truncate text-left",children:d.model||"Select model..."}),s.jsx(qt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(rz,{className:"w-[420px] p-0",align:"start",children:s.jsxs(fz,{children:[s.jsx(pz,{placeholder:`Search ${d.provider==="azure"?"deployments":"models"}...`}),s.jsxs(hz,{children:[s.jsxs(mz,{children:["No ",d.provider==="azure"?"deployments":"models"," found."]}),s.jsxs(vz,{heading:d.provider==="azure"?"Deployments":"Models",children:[B.map(T=>s.jsxs(hj,{value:T,onSelect:L=>{f(Q=>({...Q,model:L})),$(!1),k(!1)},children:[s.jsx(ql,{className:Se("mr-2 h-4 w-4",d.model===T?"opacity-100":"opacity-0")}),s.jsx("span",{className:"font-mono text-xs",children:T})]},T)),s.jsx(hj,{value:"__custom_model_id__",onSelect:()=>{$(!0),k(!1)},children:s.jsx("span",{className:"font-medium",children:d.provider==="azure"?"Custom deployment ID...":"Custom model ID..."})})]})]})]})})]}),z&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0 text-xs",onClick:()=>{V()},disabled:P,title:d.provider==="azure"?"Fetch Azure OpenAI deployments":`Fetch ${d.provider} models`,children:[P?s.jsx(sr,{className:"mr-1 h-3 w-3 animate-spin"}):s.jsx(Fa,{className:"mr-1 h-3 w-3"}),d.provider==="azure"?"Fetch Deployments":"Fetch Models"]})]}),K&&s.jsx(ht,{value:d.model,onChange:T=>f(L=>({...L,model:T.target.value})),placeholder:d.provider==="azure"?"Type deployment name manually":"Type model name manually",className:"font-mono text-xs"}),N.length>0&&s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Loaded ",N.length," ",d.provider==="azure"?"deployment names":"models"," from provider discovery."]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Tokens"}),s.jsx(ht,{type:"number",min:1,max:128e3,value:d.maxTokens,onChange:T=>f(L=>({...L,maxTokens:parseInt(T.target.value)||0})),className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Me,{children:"Temperature"}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:d.temperature.toFixed(2)})]}),s.jsx(V8,{value:[d.temperature],onValueChange:([T])=>f(L=>({...L,temperature:T})),min:0,max:2,step:.01})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"System Prompt"}),s.jsx(Ks,{value:d.systemPrompt||"",onChange:T=>f(L=>({...L,systemPrompt:T.target.value})),placeholder:"Optional system prompt...",rows:3,className:"text-xs"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/agents"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{X()},disabled:y,children:[y&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Agent":"Save"]})]})]})]})]}),s.jsx(bs,{open:h,onOpenChange:p,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove the agent"," ",s.jsx("span",{className:"font-mono",children:d.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{Z()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},oM="mcplab.resultAssistantScenarioHandoff",lM=()=>{const{testCaseId:e}=Mo(),[t,n]=Ec(),r=wa(),{source:a}=On(),{scenarios:i,setScenarios:o,agents:c,servers:d,reload:f,loading:h}=qa(),[p,y]=v.useState(""),[g,S]=v.useState("all"),[b,x]=v.useState("name"),[j,N]=v.useState("asc"),[_,P]=v.useState(""),[A,O]=v.useState(null),[k,R]=v.useState("idle"),[$,z]=v.useState(""),[B,D]=v.useState(""),[K,U]=v.useState(0),[V,X]=v.useState(null),Z=v.useRef(null),T=v.useRef(!1),L=v.useRef(!1),Q=v.useRef(null),F=v.useRef(0),M=e?decodeURIComponent(e):void 0,ee=M?i.findIndex(re=>re.id===M):-1,W=ee>=0?i[ee]:void 0,J=async re=>{if(!W||ee<0||!re)return;const me=[...i];me[ee]=re,await o(me)},ye=async()=>{const re=Q.current;if(!re||!W)return;if(T.current){L.current=!0;return}T.current=!0,L.current=!1;const me=++F.current;R("saving"),z("");try{await J(re),me===F.current&&R("saved")}catch(Ne){const tt=Ne instanceof Error?Ne.message:String(Ne);me===F.current&&(R("error"),z(tt)),Pe({title:"Could not save scenario",description:tt,variant:"destructive"})}finally{T.current=!1,L.current&&(L.current=!1,ye())}},ae=re=>{Q.current=re,R("dirty"),z(""),Z.current&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{Z.current=null,ye()},700)},ue=async()=>{const re=`scn-${Date.now()}`;let me=re,Ne=1;for(;i.some(je=>je.id===me);)me=`${re}-${Ne}`,Ne+=1;const tt={id:me,name:"",serverIds:[],prompt:"",evalRules:[],extractRules:[]};await o([...i,tt]),r(`/libraries/test-cases/${encodeURIComponent(me)}`),Pe({title:"Test case created",description:`Opened ${me} for editing.`})},ie=re=>{const me=(re||`scn-${Date.now()}`).trim().replace(/\s+/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||`scn-${Date.now()}`;let Ne=me,tt=1;for(;i.some(je=>je.id===Ne);)Ne=`${me}-${tt}`,tt+=1;return Ne},ve=async(re,me=!1)=>{const Ne=ie(`${re.id}-copy`),tt={...structuredClone(re),id:Ne,name:re.name?`${re.name} (Copy)`:""};await o([...i,tt]),Pe({title:"Test case duplicated",description:`Created ${tt.id}.`}),me&&r(`/libraries/test-cases/${encodeURIComponent(tt.id)}`)},Oe=async re=>{Z.current&&(window.clearTimeout(Z.current),Z.current=null);const me=i.filter(Ne=>Ne.id!==re.id);await o(me),Pe({title:"Test case deleted",description:`${re.id} was removed.`}),W?.id===re.id&&(O(null),Q.current=null,R("idle"),z(""),r("/libraries/test-cases"))},oe=re=>re.map(me=>d.find(Ne=>Ne.id===me)).filter(Boolean).map(me=>me?.name||me?.id).filter(Boolean),he=v.useMemo(()=>{const re=new Set;for(const me of i)for(const Ne of oe(me.serverIds))re.add(Ne);return Array.from(re).sort((me,Ne)=>me.localeCompare(Ne))},[i,d]),xe=v.useMemo(()=>{const re=p.trim().toLowerCase(),me=i.filter(Ne=>{const tt=(Ne.name||"").toLowerCase(),je=Ne.id.toLowerCase(),et=(Ne.prompt||"").toLowerCase(),dt=oe(Ne.serverIds);return g!=="all"&&!dt.includes(g)?!1:re?tt.includes(re)||je.includes(re)||et.includes(re)||dt.some(Pt=>Pt.toLowerCase().includes(re)):!0});return me.sort((Ne,tt)=>{const je=oe(Ne.serverIds),et=oe(tt.serverIds);let dt=0;switch(b){case"id":dt=Ne.id.localeCompare(tt.id);break;case"servers":dt=je.length-et.length;break;case"evalRules":dt=Ne.evalRules.length-tt.evalRules.length;break;case"extractRules":dt=Ne.extractRules.length-tt.extractRules.length;break;default:dt=(Ne.name||Ne.id).localeCompare(tt.name||tt.id);break}return dt===0&&(dt=Ne.id.localeCompare(tt.id)),j==="asc"?dt:-dt}),me},[i,p,g,b,j,d]);v.useEffect(()=>{let re=!0;return a.getWorkspaceSettings().then(me=>{!re||!me||P(me.scenarioAssistantAgentName??"")}).catch(()=>{re&&P("")}),()=>{re=!1}},[a]),v.useEffect(()=>{if(M&&t.get("assistantHandoff")==="1")try{const re=window.sessionStorage.getItem(oM);if(!re)return;const me=JSON.parse(re);if(!me||me.scenarioId!==M||!me.prompt)return;D(String(me.prompt)),U(Date.now()),window.sessionStorage.removeItem(oM);const Ne=new URLSearchParams(t);Ne.delete("assistantHandoff"),n(Ne,{replace:!0}),Pe({title:"Suggestion sent to Scenario Assistant",description:"Review the suggestion and apply changes in the scenario editor."})}catch{}},[M,t,n]),v.useEffect(()=>{W?(O(structuredClone(W)),Q.current=structuredClone(W),R("idle"),z("")):(O(null),Q.current=null,R("idle"),z("")),Z.current&&(window.clearTimeout(Z.current),Z.current=null),T.current=!1,L.current=!1},[W]),v.useEffect(()=>()=>{Z.current&&window.clearTimeout(Z.current)},[]);const Ie=_||c[0]?.name||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(t$,{className:"h-6 w-6"}),"Manage Test Cases"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable test case templates shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[W&&s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>r("/libraries/test-cases"),children:[s.jsx(xo,{className:"mr-2 h-4 w-4"}),"Back to Overview"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{f()},disabled:h,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),!W&&s.jsxs(se,{type:"button",size:"sm",onClick:()=>{ue()},children:[s.jsx(us,{className:"mr-1.5 h-3.5 w-3.5"}),"Add Test Case"]})]})]}),!W&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 rounded-md border bg-muted/30 p-3 md:grid-cols-[1.6fr_1fr_1fr_auto]",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Search"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sj,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),s.jsx(ht,{value:p,onChange:re=>y(re.target.value),placeholder:"Search by name, id, prompt, server...",className:"h-8 pl-8 text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Server Filter"}),s.jsxs(sn,{value:g,onValueChange:S,children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All servers"}),he.map(re=>s.jsx(at,{value:re,children:re},re))]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Sort By"}),s.jsxs(sn,{value:b,onValueChange:re=>x(re),children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"name",children:"Name"}),s.jsx(at,{value:"id",children:"ID"}),s.jsx(at,{value:"servers",children:"# Servers"}),s.jsx(at,{value:"evalRules",children:"# Eval Rules"}),s.jsx(at,{value:"extractRules",children:"# Extract Rules"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Direction"}),s.jsxs(sn,{value:j,onValueChange:re=>N(re),children:[s.jsx(Jt,{className:"h-8 w-28 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"asc",children:"Ascending"}),s.jsx(at,{value:"desc",children:"Descending"})]})]})]})]}),s.jsx(ze,{children:s.jsxs(Ue,{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",xe.length," of ",i.length," test case",i.length!==1?"s":"","."]}),M&&!W&&s.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Test case ",s.jsx("code",{className:"font-mono",children:M})," was not found."]}),i.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No library test cases yet."}):xe.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No test cases match the current filters."}):s.jsx("div",{className:"grid gap-3",children:xe.map(re=>{const me=M===re.id,Ne=`/libraries/test-cases/${encodeURIComponent(re.id)}`,tt=oe(re.serverIds);return s.jsx("div",{className:`rounded-lg border p-3 ${me?"border-primary bg-primary/5":""}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(yt,{to:Ne,className:"font-medium truncate hover:underline",children:re.name||re.id}),s.jsx(Ke,{variant:"outline",className:"font-mono text-[10px]",children:re.id}),me&&s.jsx(Ke,{children:"Selected"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground flex flex-wrap gap-x-3 gap-y-1",children:[s.jsxs("span",{children:[tt.length," server",tt.length!==1?"s":""]}),s.jsxs("span",{children:[re.evalRules.length," eval rule",re.evalRules.length!==1?"s":""]}),s.jsxs("span",{children:[re.extractRules.length," extract rule",re.extractRules.length!==1?"s":""]})]}),tt.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:tt.map(je=>s.jsx(Ke,{variant:"secondary",className:"text-[10px]",children:je},`${re.id}-${je}`))})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(re),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(re)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsx(se,{type:"button",size:"sm",variant:me?"default":"outline",asChild:!0,children:s.jsxs(yt,{to:Ne,children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})})]})]})},re.id)})})]})})]}),W&&A?s.jsxs(ze,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{children:s.jsx(_t,{className:"text-base",children:"Edit Test Case"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(A,!0)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(A),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})]})]}),s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{children:["Focused editor for ",s.jsx("code",{className:"font-mono",children:W.id}),"."]}),s.jsx(Ke,{variant:"outline",className:`text-[10px] ${k==="saving"?"border-amber-300 text-amber-700":k==="saved"?"border-emerald-300 text-emerald-700":k==="error"?"border-destructive/40 text-destructive":k==="dirty"?"border-sky-300 text-sky-700":""}`,children:k==="saving"?"Saving...":k==="saved"?"Saved":k==="error"?"Save failed":k==="dirty"?"Unsaved changes":"Ready"}),k==="error"&&$&&s.jsx("span",{className:"text-[11px] text-destructive",children:$})]})})]}),s.jsx(Ue,{className:"pt-3",children:s.jsx(lj,{scenarios:[A],agents:c,servers:d,defaultAssistantAgentName:Ie,assistantInitialPromptByScenarioId:B&&A?.id?{[A.id]:B}:void 0,assistantAutoOpenNonceByScenarioId:A?.id&&K?{[A.id]:K}:void 0,onChange:re=>{const me=re[0];me&&(O(me),ae(me))},allowAdd:!1})})]}):null,s.jsx(bs,{open:!!V,onOpenChange:re=>!re&&X(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete test case?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-medium",children:V?.name||V?.id})," ","from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V&&(Oe(V),X(null))},children:"Delete Test Case"})]})]})})]})},kve=()=>{const{source:e}=On(),{agents:t,reload:n,loading:r}=qa(),[a,i]=v.useState(!1),[o,c]=v.useState(!1),[d,f]=v.useState(""),h=v.useMemo(()=>d||t[0]?.name||"",[d,t]),p=async()=>{i(!0);try{const S=await e.getWorkspaceSettings();f(S?.scenarioAssistantAgentName??"")}catch(S){f(""),Pe({title:"Could not load settings",description:S instanceof Error?S.message:String(S),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{p()},[e]);const y=async S=>{f(S),c(!0);try{await e.updateWorkspaceSettings({scenarioAssistantAgentName:S||void 0}),Pe({title:"Settings updated",description:S?`Scenario Assistant Agent set to ${S}.`:"Scenario Assistant Agent cleared (will use first available agent by default)."})}catch(b){Pe({title:"Could not save settings",description:b instanceof Error?b.message:String(b),variant:"destructive"})}finally{c(!1)}},g=async()=>{await Promise.all([n(),p()])};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(jj,{className:"h-6 w-6"}),"Settings"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace-level MCP Lab settings and defaults."})]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{g()},disabled:r||a,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),s.jsxs(ze,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsx(_t,{className:"text-base",children:"Scenario Assistant"}),s.jsx(Ds,{children:"Default assistant model used on library test case pages. If unset, MCP Lab uses the first available agent automatically."})]}),s.jsxs(Ue,{className:"grid gap-3 md:grid-cols-[1.3fr_auto] md:items-end",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Assistant Agent"}),s.jsxs(sn,{value:h||"__none__",onValueChange:S=>{y(S==="__none__"?"":S)},disabled:o,children:[s.jsx(Jt,{className:"h-9 text-sm",children:s.jsx(on,{placeholder:"Select assistant agent"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"__none__",children:"None (use first agent)"}),t.map(S=>s.jsxs(at,{value:S.name||S.id,children:[S.name||S.id," · ",S.model]},S.id))]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Applies to `/libraries/test-cases/:testCaseId`. MCP Evaluation editors can still override the assistant agent from their evaluation context."})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:"Saved in workspace settings"})]})]})]})};var Jv="Checkbox",[Rve]=ir(Jv),[Tve,pC]=Rve(Jv);function Ive(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:c,onCheckedChange:d,required:f,value:h="on",internal_do_not_use_render:p}=e,[y,g]=na({prop:n,defaultProp:a??!1,onChange:d,caller:Jv}),[S,b]=v.useState(null),[x,j]=v.useState(null),N=v.useRef(!1),_=S?!!o||!!S.closest("form"):!0,P={checked:y,disabled:i,setChecked:g,control:S,setControl:b,name:c,form:o,value:h,hasConsumerStoppedPropagationRef:N,required:f,defaultChecked:ki(a)?!1:a,isFormControl:_,bubbleInput:x,setBubbleInput:j};return s.jsx(Tve,{scope:t,...P,children:Mve(p)?p(P):r})}var gz="CheckboxTrigger",yz=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:i,value:o,disabled:c,checked:d,required:f,setControl:h,setChecked:p,hasConsumerStoppedPropagationRef:y,isFormControl:g,bubbleInput:S}=pC(gz,e),b=ut(a,h),x=v.useRef(d);return v.useEffect(()=>{const j=i?.form;if(j){const N=()=>p(x.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,p]),s.jsx(De.button,{type:"button",role:"checkbox","aria-checked":ki(d)?"mixed":d,"aria-required":f,"data-state":jz(d),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:b,onKeyDown:Ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ae(n,j=>{p(N=>ki(N)?!0:!N),S&&g&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});yz.displayName=gz;var hC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d,onCheckedChange:f,form:h,...p}=e;return s.jsx(Ive,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:c,required:o,onCheckedChange:f,name:r,form:h,value:d,internal_do_not_use_render:({isFormControl:y})=>s.jsxs(s.Fragment,{children:[s.jsx(yz,{...p,ref:t,__scopeCheckbox:n}),y&&s.jsx(Sz,{__scopeCheckbox:n})]})})});hC.displayName=Jv;var xz="CheckboxIndicator",bz=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,i=pC(xz,n);return s.jsx(Gn,{present:r||ki(i.checked)||i.checked===!0,children:s.jsx(De.span,{"data-state":jz(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});bz.displayName=xz;var wz="CheckboxBubbleInput",Sz=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:c,disabled:d,name:f,value:h,form:p,bubbleInput:y,setBubbleInput:g}=pC(wz,e),S=ut(n,g),b=Fv(i),x=km(r);v.useEffect(()=>{const N=y;if(!N)return;const _=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(_,"checked").set,O=!a.current;if(b!==i&&A){const k=new Event("click",{bubbles:O});N.indeterminate=ki(i),A.call(N,ki(i)?!1:i),N.dispatchEvent(k)}},[y,b,i,a]);const j=v.useRef(ki(i)?!1:i);return s.jsx(De.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:c,disabled:d,name:f,value:h,form:p,...t,tabIndex:-1,ref:S,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sz.displayName=wz;function Mve(e){return typeof e=="function"}function ki(e){return e==="indeterminate"}function jz(e){return ki(e)?"indeterminate":e?"checked":"unchecked"}const va=v.forwardRef(({className:e,...t},n)=>s.jsx(hC,{ref:n,className:Se("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(bz,{className:Se("flex items-center justify-center text-current"),children:s.jsx(ql,{className:"h-4 w-4"})})}));va.displayName=hC.displayName;const $ve=Io("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Bl=v.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert",className:Se($ve({variant:t}),e),...n}));Bl.displayName="Alert";const zl=v.forwardRef(({className:e,...t},n)=>s.jsx("h5",{ref:n,className:Se("mb-1 font-medium leading-none tracking-tight",e),...t}));zl.displayName="AlertTitle";const Ul=v.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:Se("text-sm [&_p]:leading-relaxed",e),...t}));Ul.displayName="AlertDescription";function Dve(e,t=[]){let n=[];function r(i,o){const c=v.createContext(o);c.displayName=i+"Context";const d=n.length;n=[...n,o];const f=p=>{const{scope:y,children:g,...S}=p,b=y?.[e]?.[d]||c,x=v.useMemo(()=>S,Object.values(S));return s.jsx(b.Provider,{value:x,children:g})};f.displayName=i+"Provider";function h(p,y){const g=y?.[e]?.[d]||c,S=v.useContext(g);if(S)return S;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[f,h]}const a=()=>{const i=n.map(o=>v.createContext(o));return function(c){const d=c?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return a.scopeName=e,[r,Lve(a,...t)]}function Lve(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(i)[`__scope${f}`];return{...c,...p}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nz=Fve.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),mC="Progress",vC=100,[Bve]=Dve(mC),[zve,Uve]=Bve(mC),Cz=v.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=qve,...o}=e;(a||a===0)&&!cM(a)&&console.error(Wve(`${a}`,"Progress"));const c=cM(a)?a:vC;r!==null&&!uM(r,c)&&console.error(Vve(`${r}`,"Progress"));const d=uM(r,c)?r:null,f=bm(d)?i(d,c):void 0;return s.jsx(zve,{scope:n,value:d,max:c,children:s.jsx(Nz.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":bm(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":Ez(d,c),"data-value":d??void 0,"data-max":c,...o,ref:t})})});Cz.displayName=mC;var _z="ProgressIndicator",Az=v.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,a=Uve(_z,n);return s.jsx(Nz.div,{"data-state":Ez(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})});Az.displayName=_z;function qve(e,t){return`${Math.round(e/t*100)}%`}function Ez(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function bm(e){return typeof e=="number"}function cM(e){return bm(e)&&!isNaN(e)&&e>0}function uM(e,t){return bm(e)&&!isNaN(e)&&e<=t&&e>=0}function Wve(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${vC}\`.`}function Vve(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
131
131
  - a positive number
132
132
  - less than the value passed to \`max\` (or ${vC} if no \`max\` prop is set)
133
133
  - \`null\` or \`undefined\` if the progress is indeterminate.
@@ -16,7 +16,7 @@
16
16
  <meta name="twitter:card" content="summary_large_image" />
17
17
  <meta name="twitter:site" content="@Inspectr" />
18
18
  <meta name="twitter:image" content="" />
19
- <script type="module" crossorigin src="/assets/index-DP361exO.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-CbXSJnQA.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-D5Ew6sJk.css">
21
21
  </head>
22
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspectr/mcplab",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "MCPLab - Test and evaluate MCP servers with LLMs — run evals, compare agents and launch the MCPLab web app",
5
5
  "license": "MIT",
6
6
  "homepage": "https://mcplab.inspectr.dev",