hmcp-web 0.1.0 → 0.2.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.
Files changed (46) hide show
  1. package/README.md +3 -2
  2. package/dist/api.d.ts +11 -0
  3. package/dist/api.js +64 -10
  4. package/dist/model/app-servers.d.ts +85 -0
  5. package/dist/model/app-servers.js +109 -0
  6. package/dist/model/import-record.d.ts +80 -0
  7. package/dist/model/import-record.js +179 -0
  8. package/dist/model/metrics.js +16 -1
  9. package/dist/model/protection.d.ts +1 -0
  10. package/dist/model/protection.js +6 -2
  11. package/dist/routes/connect-import.d.ts +9 -0
  12. package/dist/routes/connect-import.js +594 -0
  13. package/dist/routes/connect.d.ts +36 -0
  14. package/dist/routes/connect.js +71 -13
  15. package/dist/routes/github.d.ts +97 -0
  16. package/dist/routes/github.js +587 -0
  17. package/dist/routes/guard.d.ts +3 -0
  18. package/dist/routes/guard.js +166 -0
  19. package/dist/routes/runtime.d.ts +6 -0
  20. package/dist/routes/runtime.js +1 -1
  21. package/dist/routes/servers-add.d.ts +8 -0
  22. package/dist/routes/servers-add.js +2 -2
  23. package/dist-ui/assets/{Activity-BqKGpXMN.js → Activity-Dgo5oK2r.js} +1 -1
  24. package/dist-ui/assets/Approvals-C5_8rBkL.js +1 -0
  25. package/dist-ui/assets/AttachApp-BRW1mJ7X.js +5 -0
  26. package/dist-ui/assets/Connections-BHsXRdYI.js +2 -0
  27. package/dist-ui/assets/{Gallery-B39L2Yma.js → Gallery-DB_OO7Vw.js} +1 -1
  28. package/dist-ui/assets/{PreApprovals-BsIhjMqb.js → PreApprovals-CXcU-_ug.js} +1 -1
  29. package/dist-ui/assets/{Protection-DlB09ABa.js → Protection-BF5OlzGC.js} +1 -1
  30. package/dist-ui/assets/{Safety-CN-oHO2h.js → Safety-DVb8sdbt.js} +1 -1
  31. package/dist-ui/assets/{Settings-BLD7G1Ag.js → Settings-XjNZ-wo-.js} +1 -1
  32. package/dist-ui/assets/StartPage-D8WBBhDy.js +1 -0
  33. package/dist-ui/assets/{Suggestions-Dp7pofcs.js → Suggestions-HZyd0jDU.js} +1 -1
  34. package/dist-ui/assets/Tools-GMaKxxIG.js +4 -0
  35. package/dist-ui/assets/index-CvZ3niHA.css +2 -0
  36. package/dist-ui/assets/index-DbHZ_SUd.js +16 -0
  37. package/dist-ui/assets/{kit-DQ7Oxf5n.js → kit-DRVm92_t.js} +1 -1
  38. package/dist-ui/index.html +3 -3
  39. package/package.json +4 -4
  40. package/dist-ui/assets/Approvals-Qo7bCcli.js +0 -1
  41. package/dist-ui/assets/AttachApp-0zRSPgSY.js +0 -5
  42. package/dist-ui/assets/Connections-CE0JGe8c.js +0 -2
  43. package/dist-ui/assets/StartPage-HuZSnmSr.js +0 -1
  44. package/dist-ui/assets/Tools-Bfot3bx5.js +0 -4
  45. package/dist-ui/assets/index-Khp0l1zp.js +0 -16
  46. package/dist-ui/assets/index-Ylyt4DEr.css +0 -2
@@ -1,5 +0,0 @@
1
- import{$ as e,A as t,At as n,B as r,Ct as i,E as a,G as o,H as s,It as c,J as l,M as u,N as d,Nt as f,O as p,Ot as m,Pt as h,Tt as g,U as _,V as v,Y as y,Z as b,_t as x,a as S,b as C,bt as w,et as T,ht as E,i as D,jt as ee,k as O,kt as te,n as ne,o as re,q as k,r as A,rt as j,s as ie,t as M,tt as ae,vt as N,w as oe,x as se,xt as ce,y as le,yt as P}from"./kit-DQ7Oxf5n.js";import{$ as F,A as ue,At as I,B as de,Bt as fe,C as L,D as pe,E as me,F as R,Ft as he,G as ge,Gt as _e,H as ve,I as z,J as ye,K as be,Kt as B,L as xe,Lt as V,M as H,N as Se,Nt as U,O as Ce,P as we,Pt as Te,Q as Ee,R as De,S as Oe,T as W,U as ke,Ut as G,V as Ae,Vt as je,W as Me,Wt as Ne,X as K,Y as Pe,Yt as q,b as Fe,ct as Ie,et as J,j as Le,jt as Y,k as Re,m as ze,mn as Be,nn as Ve,nt as He,q as Ue,rt as We,s as X,tt as Ge,x as Ke,z as qe}from"./index-Khp0l1zp.js";var Z=c(),Q=te(),Je=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function Ye(e){let t=Je();return t.name=e.name,t.transport=e.transport,t.onInjection=e.on_injection??``,e.transport===`stdio`?(t.command=e.command,t.args=e.args??[],t.env=We(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=We(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function Xe(e){let t=e.onInjection?{on_injection:e.onInjection}:{};return e.transport===`stdio`?{name:e.name.trim(),transport:`stdio`,...t,command:e.command.trim(),...e.args.length?{args:e.args}:{},...e.env.length?{env:He(e.env)}:{},...e.passEnv.length?{pass_env:e.passEnv}:{},...e.cwd.trim()?{cwd:e.cwd.trim()}:{}}:{name:e.name.trim(),transport:`http`,...t,url:e.url.trim(),...e.headers.length?{headers:He(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function Ze(e,t=[]){if(!/^[a-z0-9_]+$/.test(e.name.trim()))return`Give the server a name of lower-case letters, digits and underscores.`;if(t.includes(e.name.trim()))return`Another connected server is already called “${e.name.trim()}”.`;if(e.transport===`stdio`&&!e.command.trim())return`Say which program starts the server.`;if(e.transport===`http`)try{new URL(e.url.trim())}catch{return`Enter the server's full web address, starting with https://.`}return null}function Qe({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!_e(t)&&!fe(e),f=e.transport===`stdio`?e.env.some(l):e.headers.some(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(a,{label:`Name`,technical:`name`,help:r?`A server's name can't be changed. Remove it and add it again under a new name.`:`Lower-case letters, digits and underscores. Its tools are shown to your AI app as name__tool.`,children:(0,Q.jsx)(u,{value:e.name,onChange:e=>c(`name`,e),mono:!0,disabled:r,placeholder:`files`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Where it runs`}),(0,Q.jsx)(p,{label:`Where it runs`,value:e.transport,onChange:e=>c(`transport`,e),options:[{value:`stdio`,label:`Runs on this computer`},{value:`http`,label:`Remote server`}]})]}),e.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Program to start`,technical:`command`,help:`The program the toolbox runs to start this server, such as npx or a full path.`,children:(0,Q.jsx)(u,{value:e.command,onChange:e=>c(`command`,e),mono:!0,placeholder:`npx`})}),(0,Q.jsx)(a,{label:`What to pass the program`,technical:`args`,optional:!0,help:`One item at a time. Press Enter after each.`,children:(0,Q.jsx)(t,{value:e.args,onChange:e=>c(`args`,e),placeholder:`-y, @modelcontextprotocol/server-filesystem`})}),(0,Q.jsx)(a,{label:`Values it is given`,technical:`env`,optional:!0,help:`Settings the server reads when it starts, such as an access key.`,children:(0,Q.jsx)(F,{value:e.env,onChange:e=>c(`env`,e),keyLabel:`Name of value`,valueLabel:`Value`,addLabel:`Add a value`,secret:i,valueType:`password`,keyPlaceholder:`API_KEY`})}),(0,Q.jsx)(a,{label:`Values passed on from the toolbox`,technical:`pass_env`,optional:!0,help:`Names of values the toolbox already has, given to this server as they are. Nothing else is passed on.`,children:(0,Q.jsx)(t,{value:e.passEnv,onChange:e=>c(`passEnv`,e),placeholder:`GITHUB_TOKEN`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Web address`,technical:`url`,children:(0,Q.jsx)(u,{value:e.url,onChange:e=>c(`url`,e),type:`url`,mono:!0,placeholder:`https://mcp.example.com/mcp`})}),(0,Q.jsx)(a,{label:`Headers sent with every request`,technical:`headers`,optional:!0,help:`Such as an access key the server expects.`,children:(0,Q.jsx)(F,{value:e.headers,onChange:e=>c(`headers`,e),keyLabel:`Header name`,valueLabel:`Header value`,addLabel:`Add a header`,secret:i,valueType:`password`,keyPlaceholder:`authorization`})})]}),o&&f&&(0,Q.jsx)(s,{tone:`warn`,title:`These values are saved in the toolbox's settings file as typed`,children:`A value whose name says it is a key (a TOKEN, KEY, SECRET or PASSWORD) goes into your locked keys instead. If another one is a password or key, give it a name like that, or anyone who can read the file can read it.`}),(0,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?Y[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(O,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:Y.strip.label},{value:`deny`,label:Y.deny.label},{value:`annotate`,label:Y.annotate.label}]})}),e.transport===`stdio`?(0,Q.jsx)(a,{label:`Folder it starts in`,technical:`cwd`,optional:!0,children:(0,Q.jsx)(u,{value:e.cwd,onChange:e=>c(`cwd`,e),mono:!0,placeholder:`/Users/me/project`})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{checked:e.passthrough,onChange:e=>c(`passthrough`,e),label:`Send each caller's own sign-in`,description:`Instead of one shared key, the toolbox passes on the key each AI app connects with. This sends that key to this server.`}),e.passthrough&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Header it goes in`,technical:`credential_passthrough.header`,children:(0,Q.jsx)(u,{value:e.passthroughHeader,onChange:e=>c(`passthroughHeader`,e),mono:!0})}),(0,Q.jsx)(d,{checked:e.passthroughRequired,onChange:e=>c(`passthroughRequired`,e),label:`Refuse calls without a sign-in`,description:`Otherwise a caller with no key of its own falls back to the headers above.`})]})]})]})]})}function $e({compact:e,tab:t,onTab:r,onCatalog:i,onDraft:a}){let[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),d=e&&!c;if((0,Z.useEffect)(()=>{if(d)return;let e=!0;return n.settings().then(t=>e&&s(t.registry.enabled)).catch(()=>e&&s(!0)),()=>{e=!1}},[d]),d){let e=e=>{u(!0),r(e)};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(et,{compact:!0,onPick:i}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Other ways:`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`registry`),children:`search the public list`}),` · `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`paste`),children:`paste instructions from a README`})]})]})}let f=[{id:`popular`,label:`Popular`},...o===!1?[]:[{id:`registry`,label:`Search the public list`}],{id:`paste`,label:`Paste instructions`},{id:`advanced`,label:`Advanced`}],p=t===`registry`&&o===!1?`popular`:t;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(k,{items:f,value:p,onChange:r,label:`Where to find the server`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:y(p),"aria-labelledby":l(p),children:p===`popular`?(0,Q.jsx)(et,{onPick:i}):p===`registry`?(0,Q.jsx)(rt,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(it,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(at,{onDraft:a})})]})}function et({onPick:e,compact:t}){let i=ie(()=>n.catalog(),[]),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(!1),p=i.data?.entries??[],h=a?qe(p,a,l):[...qe(p,a,l)].sort((e,t)=>Number(t.id===tt)-Number(e.id===tt)),g=[...new Set(p.map(e=>e.category))],v=t&&!d&&!a?6:1/0,y=h.slice(0,v);return i.error&&!i.data?(0,Q.jsx)(s,{tone:`danger`,title:`The list of servers could not be loaded`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:V(i.error)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search: files, GitHub, notes…`,"aria-label":`Search servers`,className:`field pl-10`})]}),!t&&g.length>1&&(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Kind of server`,className:`flex flex-wrap gap-1.5`,children:[`all`,...g].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:P(`h-8 rounded-full border-[1.5px] px-3.5 text-[13px] font-semibold transition-colors`,l===e?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:e===`all`?`All`:L[e]},e))})]}),i.data?h.length===0?(0,Q.jsxs)(_,{icon:`search`,title:`Nothing matches`,compact:!0,children:[`Try another word. You can also search the public list, or paste the server's setup instructions, using the `,t?`links below`:`tabs above`,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,role:`status`,children:[r(h.length,`server`),` found`]}),(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:y.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(nt,{entry:t,onPick:()=>e(t)})},t.id))}),y.length<h.length&&(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),children:[`Show all `,h.length]})})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))})]})}var tt=`filesystem`;function nt({entry:t,onPick:n}){let r=De(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===tt?(0,Q.jsx)(e,{tone:`ok`,icon:`check`,children:`Good first choice`}):t.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.summary}),(r.setup.length>0||r.needs.length>0)&&(0,Q.jsxs)(`span`,{className:`mt-auto flex flex-wrap gap-1.5 pt-1`,children:[r.setup.length>0&&(0,Q.jsx)(`span`,{title:`Needs ${r.setup.map(e=>W[e]??e).join(` and `)}. The next screen walks you through it.`,children:(0,Q.jsx)(e,{icon:`wrench`,children:`Needs a little setup`})}),r.needs.map(t=>(0,Q.jsx)(e,{children:t},t))]})]})}function rt({onCatalogId:t,onDraft:i}){let[a,c]=(0,Z.useState)(``),l=w(a.trim(),300),[u,d]=(0,Z.useState)(null),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,T]=(0,Z.useState)(null),D=ie(()=>n.catalog(),[]),ee=l?qe(D.data?.entries??[],l).slice(0,3):[];(0,Z.useEffect)(()=>{if(!l){d(null),h([]),_(null),b(!1);return}let e=!0;return b(!0),n.registrySearch(l).then(t=>{e&&(d(t),h(t.hits),_(null))}).catch(t=>{e&&(t instanceof f&&(t.status===404||t.code===`registry-off`)?_(`Searching the public list is switched off in Settings & help.`):_(V(t)))}).finally(()=>e&&b(!1)),()=>{e=!1}},[l,x]),(0,Z.useEffect)(()=>{if(!u?.loading)return;let e=setTimeout(()=>S(e=>e+1),2e3);return()=>clearTimeout(e)},[u]);let O=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(V(e))).finally(()=>b(!1)))},te=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(V(e))).finally(()=>T(null))):e.draft&&i(e.draft,{})};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`A public directory of servers that anyone can publish to. Only the words you type are sent to it to find matches. Nobody has checked these servers, so look at who made one before you add it.`}),(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search the public list`,"aria-label":`Search the public list`,className:`field pl-10`}),y&&(0,Q.jsx)(`span`,{className:`absolute right-3.5 text-soft`,children:(0,Q.jsx)(N,{})})]}),(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] text-soft`,children:u?.loading?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+ee.length,`server`)}${u.updatedAt?` · list updated ${v(u.updatedAt)}`:``}`:null}),u?.problem&&(0,Q.jsx)(s,{tone:`warn`,children:u.problem}),g&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:()=>S(e=>e+1),children:`Try again`}),children:g}),l?!u&&!g?(0,Q.jsx)(o,{lines:4,height:18}):(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[ee.map(n=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id,n),className:`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:n.name}),(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:n.summary}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`by `,n.publisher.name]})]})},`catalog-${n.id}`)),p.filter(e=>!e.catalogId||!ee.some(t=>t.id===e.catalogId)).map(t=>{let n=!!t.catalogId||!!t.draft;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>te(t),"aria-describedby":n?void 0:`why-${t.name}`,className:P(`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] p-4 text-left transition-colors`,n?`border-line hover:border-[var(--soft)] hover:bg-faint/50`:`cursor-not-allowed border-line bg-sunken/40 opacity-70`),children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:t.title??t.name}),C===t.name&&(0,Q.jsx)(N,{}),t.catalogId?(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`}):n?(0,Q.jsx)(e,{tone:`warn`,children:`From the public list — not checked by us`}):(0,Q.jsx)(e,{children:`Can't be added`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.description}),t.caution&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,className:`mt-0.5 shrink-0`}),t.caution]}),(0,Q.jsxs)(`code`,{className:`mono text-[11.5px] text-soft`,children:[t.name,` · `,t.version]}),!n&&(0,Q.jsx)(`span`,{id:`why-${t.name}`,className:`text-[12.5px] text-soft`,children:t.unsupported??`It can't be started from the public list's description.`})]})},t.name)})]}):(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:`Type the name of a server or a service, such as “weather” or “slack”, to search the public list.`}),u?.nextCursor&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:O,loading:y,children:`Show more`})})]})}function it({onDraft:e,onAdvanced:t}){let[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-paste`,className:`text-[13px] font-semibold`,children:`Paste the setup instructions`}),(0,Q.jsx)(`textarea`,{id:`add-paste`,rows:8,value:i,onChange:e=>{a(e.target.value),u(null)},"aria-describedby":`add-paste-help`,placeholder:`{
2
- "mcpServers": {
3
- "weather": { "command": "npx", "args": ["-y", "weather-mcp"] }
4
- }
5
- }`,className:`field resize-y font-mono text-[13px]`}),(0,Q.jsx)(`p`,{id:`add-paste-help`,className:`text-[12.5px] text-soft`,children:`Copy the part of the server's instructions page (often called its README) that shows how to add it: a block of settings, a one-line command, or just its web address. Nothing is saved yet, and any keys in it go into your locked keys, never into a settings file.`})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{variant:`primary`,icon:`search`,onClick:()=>{c(!0),f(null),n.paste(i).then(u).catch(e=>f(V(e))).finally(()=>c(!1))},loading:o,disabled:!i.trim(),children:`Read it`})}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),l&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-3`,children:[l.servers.length===0?(0,Q.jsx)(s,{tone:`warn`,title:`No server could be added from that`,children:l.warnings.length>0&&!/didn't look like setup instructions/.test(l.warnings.join(` `))?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):(0,Q.jsxs)(Q.Fragment,{children:[`We couldn't find a server in that. Paste the line that starts with `,(0,Q.jsx)(`code`,{className:`mono`,children:`npx`}),`, `,(0,Q.jsx)(`code`,{className:`mono`,children:`uvx`}),` or`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`docker`}),`, the block that contains `,(0,Q.jsx)(`code`,{className:`mono`,children:`mcpServers`}),`, or the server's web address. You can also add it by hand under`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-semibold underline`,onClick:t,children:`Advanced`}),`.`]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`Found `,r(l.servers.length,`server`),l.recognisedAs&&(0,Q.jsxs)(`span`,{className:`font-normal text-soft`,children:[` · read as `,l.recognisedAs]})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.servers.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>e(t.draft,t.values),className:`flex w-full items-center gap-3 rounded-[18px] border-[1.5px] border-line p-4 text-left hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(m,{name:t.draft.launch.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:t.draft.displayName}),(0,Q.jsx)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:t.draft.launch.transport===`http`?`Remote server · ${t.draft.launch.url}`:`Runs on this computer · ${[t.draft.launch.command,...t.draft.launch.args??[]].join(` `)}`}),t.draft.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:e},e))]}),(0,Q.jsx)(m,{name:`chevron-right`,size:18,className:`shrink-0 text-soft`})]})},`${t.draft.name}-${n}`))})]}),l.servers.length>0&&l.warnings.length>0&&(0,Q.jsx)(s,{tone:`info`,title:`Note`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]})]})}function at({onDraft:e}){let[t,n]=(0,Z.useState)(Je()),[r,i]=(0,Z.useState)(!1),a=Ze(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`For a server you know how to start. Values whose names look like keys (TOKEN, KEY, SECRET, PASSWORD) go into your locked keys rather than the toolbox's settings file.`}),(0,Q.jsx)(Qe,{value:t,onChange:n}),r&&a&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:a}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(E,{variant:`primary`,iconRight:`arrow-right`,onClick:()=>{if(i(!0),a)return;let n=we(Xe(t));e(n.draft,n.values)},children:`Continue`})})]})}function ot({transport:e}){let[t,n]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,Q.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(N,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:ve(t,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`Nothing is saved yet. `,t>2&&(0,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,t,` s)`]})]})]})]})}var st=[`run`,`ask`,`blocked`],ct={run:`Your AI can use these without asking.`,ask:`Once protection is on, each use waits until you say yes.`,blocked:`Once protection is on, your AI can't use these.`};function lt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=H(e),a=Pe(e),o=st.filter(e=>i[e].length>0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 rounded-[18px] bg-ok-tint p-4`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-surface text-ok`,children:(0,Q.jsx)(m,{name:`check`,size:20,strokeWidth:2.2})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:r?`${t} started`:`${t} works`}),(0,Q.jsxs)(`span`,{className:`block text-[13.5px] text-muted`,children:[ke(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(Ge,{sub:n?`What happens when your AI uses each tool once protection is on. Right now your toolbox only watches, so everything runs and is written down. You can change any of this later on the Tools page.`:n===!1?`What happens when your AI uses each tool. Protection is on. You can change any of this later on the Tools page.`:`What happens when your AI uses each tool once protection is on. You can change any of this later on the Tools page.`,children:`What your AI can do`}),(0,Q.jsx)(`div`,{className:P(`grid gap-3`,o.length===2?`md:grid-cols-2`:o.length>=3?`lg:grid-cols-3 md:grid-cols-2`:``),children:o.map(e=>(0,Q.jsx)(ut,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(Ge,{children:a.lines.length>0?`Please check`:`Note`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.lines.map((e,t)=>(0,Q.jsxs)(`li`,{className:P(`flex gap-2 rounded-2xl p-3`,e.tone===`warn`?`bg-warn-tint`:`border border-line`),children:[(0,Q.jsx)(m,{name:e.text.startsWith(`Won't be offered`)?`eye-off`:`warning`,size:17,className:P(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[e.tool&&(0,Q.jsx)(`code`,{className:`mono mr-1 font-semibold`,children:e.tool}),e.text,e.technical&&(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[12.5px] text-soft select-none`,children:`Details`}),(0,Q.jsx)(`p`,{className:`mono mt-1 text-[12px] break-words text-soft`,children:e.technical})]})]})]},t)),a.quiet&&(0,Q.jsx)(`li`,{className:`rounded-2xl border border-line p-3 text-muted`,children:(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer select-none`,children:[a.quiet.text,` `,(0,Q.jsx)(`span`,{className:`text-soft underline`,children:`Details`})]}),(0,Q.jsx)(`ul`,{className:`mt-2 flex max-h-64 flex-col gap-1 overflow-auto text-[12px] text-soft`,children:a.quiet.details.map((e,t)=>(0,Q.jsxs)(`li`,{className:`mono break-words`,children:[e.tool&&(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e.tool,`: `]}),e.text]},t))})]})})]})]})]})}function ut({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=Ce[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:ct[e]}),(0,Q.jsx)(`ul`,{className:P(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":ae[o].label,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Q.jsx)(b,{effect:e.effect}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`block text-[13px] [overflow-wrap:anywhere]`,title:e.description?`${e.name}: ${e.description}`:e.name,children:e.title??X(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:j[e.effect]?.label}),e.packRule&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted`,title:`Decided by a ready-made rule for this server`,children:`Ready-made rule`})]},e.name))}),!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>i(!0),children:[`Show all `,t.length]}),(0,Q.jsxs)(`details`,{className:`mt-2 text-[12px] text-soft`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Q.jsxs)(`p`,{className:`mt-1`,children:[`The server's own names:`,` `,t.map((e,t)=>(0,Q.jsxs)(`span`,{children:[t>0&&`, `,(0,Q.jsx)(`code`,{className:`mono break-normal`,children:re(e.name)})]},e.name))]})]})]})}var dt=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function ft({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=R(t.requires,h),T=Me(t),E=t.launch.transport===`http`?Le(t.launch.url,r):``,D=Ae(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(dt(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let ee=e=>a[e.id]??(o||y[e.id]?be(e,r[e.id]):null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[20px] font-medium tracking-[-0.02em]`,children:t.displayName}),n?.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`}),t.source.kind===`registry`&&(0,Q.jsx)(e,{tone:`warn`,icon:`warning`,children:`From the public list — not checked by us`}),t.source.kind===`paste`&&(0,Q.jsx)(e,{children:`From what you pasted`}),t.requires.map(t=>(0,Q.jsxs)(e,{children:[`Needs `,W[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(A,{text:n?.description??n?.summary??``})})]}),t.warnings.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Before you go on`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl bg-warn-tint px-4 py-3`,children:[(0,Q.jsx)(d,{checked:r.__local_ok===!0,onChange:e=>x(`__local_ok`,e),label:`This is on my own computer or network`,description:D===`loopback`?`This server's address is on this computer. Testing it lets the toolbox reach that address, just for the test. Only tick this if you started that program yourself.`:`This server's address is on your own network (a router or another computer). Testing it lets the toolbox reach that address, just for the test. Only tick this if you know what is there.`}),a.__local_ok&&r.__local_ok!==!0&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),`Tick this first, or choose another server.`]})]}),(0,Q.jsx)(Ke,{missing:w,platform:h?.platform,onRecheck:_,checking:g}),C.length>1&&S&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:`How to run it`}),(0,Q.jsx)(K,{label:`How to run it`,value:S,onChange:c,options:C.map(e=>({value:e.id,title:e.label,body:(0,Q.jsxs)(Q.Fragment,{children:[e.summary??(e.launch.transport===`http`?`Runs on the service's own computers. Nothing to install.`:`Runs on this computer.`),(e.requires??[]).length>0&&(0,Q.jsxs)(`span`,{className:`mt-1 block`,children:[`Needs `,(e.requires??[]).map(e=>W[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:P(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(ne,{steps:t.guide,className:`md:self-start`}),(0,Q.jsxs)(`section`,{"aria-label":`Settings for this server`,className:`flex min-w-0 flex-col gap-5`,children:[T&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Sign in`}),(0,Q.jsx)(Fe,{serverUrl:E,secretName:de(l||t.name),name:t.displayName,signedIn:f,onSignedIn:p,startNonce:v?.kind===`sign-in`?v.nonce:void 0})]}),t.fields.map(e=>(0,Q.jsx)(pt,{field:e,value:r[e.id],storedAs:typeof r[`__saved.${e.id}`]==`string`?r[`__saved.${e.id}`]:void 0,onChange:t=>x(e.id,t),onBlur:()=>b(t=>({...t,[e.id]:!0})),error:ee(e),openFolder:v?.kind===`folder`&&(!v.field||v.field===e.id)?v.nonce:void 0},e.id)),t.fields.length===0&&!T&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:[(0,Q.jsx)(m,{name:`check`,size:17,className:`text-ok`}),` Nothing to fill in. Test it to see what it can do.`]}),(0,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-server-name`,className:`text-[13px] font-semibold`,children:`Name in your toolbox`}),(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:`name`})]}),(0,Q.jsx)(`input`,{id:`add-server-name`,className:`field font-mono text-[13px]`,value:l,onChange:e=>u(e.target.value),"aria-describedby":`add-server-name-help`,"aria-invalid":!!z(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:P(`text-[12.5px]`,z(l)?`font-medium text-bad`:`text-soft`),children:z(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)(mt,{draft:t})]})]})]}),w.length===0&&t.requires.length>0&&h&&(0,Q.jsx)(`p`,{className:`sr-only`,role:`status`,children:`This computer has everything this server needs.`})]})}function pt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=dt(e.id),c=`${s}-help`,l=`${s}-err`,u=[e.help&&!i?c:null,i?l:null].filter(Boolean).join(` `)||void 0;if(e.kind===`toggle`)return(0,Q.jsx)(d,{checked:t===!0,onChange:n,label:e.label,description:e.help});let f=typeof t==`string`?t:``,p=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],h=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsxs)(`label`,{htmlFor:s,className:`text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&e.kind!==`choice`&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:`optional`})]}),e.technical&&(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:e.technical})]}),g;return g=e.kind===`secret`?(0,Q.jsx)(D,{id:s,value:f,onChange:n,storedAs:o,placeholder:e.placeholder,"aria-describedby":u,invalid:!!i}):e.kind===`folder`||e.kind===`folders`?(0,Q.jsx)(M,{id:s,value:p,multiple:e.kind===`folders`,onChange:t=>{n(e.kind===`folders`?t:t[0]??``),r()},openNonce:a,"aria-describedby":u}):e.kind===`choice`?(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{id:s,value:f,onChange:e=>n(e.target.value),onBlur:r,"aria-describedby":u,"aria-invalid":!!i||void 0,className:`field appearance-none pr-9`,children:(e.choices??[]).map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsx)(m,{name:`chevron`,size:16,className:`pointer-events-none absolute right-3 text-soft`})]}):(0,Q.jsx)(`input`,{id:s,type:e.kind===`url`?`url`:`text`,value:f,onChange:e=>n(e.target.value),onBlur:r,placeholder:e.placeholder??(e.kind===`url`?`https://`:void 0),spellCheck:!1,"aria-describedby":u,"aria-invalid":!!i||void 0,className:P(`field`,e.kind===`url`&&`font-mono text-[13px]`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.kind===`folder`||e.kind===`folders`?(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`font-normal text-soft`,children:`optional`})]}):h,g,e.help&&!i&&(0,Q.jsx)(`p`,{id:c,className:`text-[12.5px] text-soft`,children:(0,Q.jsx)(A,{text:e.help})}),i&&(0,Q.jsxs)(`p`,{id:l,role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),i]})]})}function mt({draft:e}){let t=e.launch,n=e=>typeof e==`string`?e:`${e.prefix??``}<locked key: ${e.field}>`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What it runs`}),t.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:[t.command,...t.args??[]].join(` `)}),Object.entries(t.env??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`=`,n(t)]},e))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:t.url}),Object.entries(t.headers??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`: `,n(t)]},e))]})]})}var $={saved:null},ht=new Set([`brave-search`]);function gt(){$.saved=null}function _t(e){let{gatewayId:t,onDone:r,onCancel:i,initialCatalogId:a,compact:c,fixUpstream:l}=e,[u,d]=(0,Z.useState)(`popular`),[p,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(a??null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(!1),[re,k]=(0,Z.useState)({}),[A,j]=(0,Z.useState)(null),[ie,M]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(!1),[le,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),[fe,L]=(0,Z.useState)(null),[R,he]=(0,Z.useState)($.saved),[_e,ve]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){ve(!0);return}let e=!0;return h.protection(t).then(t=>e&&ve(t.enforcement!==`enforce`)).catch(()=>e&&ve(null)),()=>{e=!1}},[t]);let[be,B]=(0,Z.useState)(null),H=e=>{$.saved=e,he(e)},U=(0,Z.useRef)(null),Ce=R?`done`:A&&A.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{U.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),B(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(me)));S({...Se(e,n),...r}),T(e.name),O(!1),ne(!1),k({}),j(null),I(null),e.requires.length&&!ae&&ke()},Te=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(V(e))).finally(()=>v(null))},[Ee,De]=(0,Z.useState)(!1),W=async(e,t,r)=>{De(!0),b(null);try{let i=(await n.catalog()).entries,a=Re(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Ue(o,e,r),c=a.entry):{draft:o,values:s}=ue(e,r),we(o,c,s),B(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)M({kind:`folder`,field:u([`folder`,`folders`]),nonce:l});else if(t===`replace-key`){let e=u([`secret`]);e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${me}${e}`))),M(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&M({kind:`sign-in`,nonce:l})}catch(e){b(V(e))}finally{De(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&W(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Te(t):v(null)}).catch(e=>{b(V(e)),v(null)})},[a]);let ke=()=>{ce(!0),n.doctor().then(oe).catch(()=>void 0).finally(()=>ce(!1))},G=p?.draft??null,K=G?Me(G):!1,Pe=de(w||G?.name||`server`),q=()=>{if(!G)return;ne(!0),I(null);let e=ge(G,x);if(Object.keys(e).length||z(w)){let t=G.fields.find(t=>e[t.id]);t&&M({kind:`field`,field:t.id,nonce:Date.now()}),j({kind:`error`,text:z(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else K&&!D?j({kind:`error`,text:`Sign in with ${G.displayName} first.`}):Ae(G,x)&&x.__local_ok!==!0?j({kind:`error`,text:`This server's address is on your own computer or network. Tick “This is on my own computer or network” first, or choose another server.`}):(j({kind:`running`}),k({}),n.testServer({...t?{gatewayId:t}:{},draft:G,values:K?{...x,[pe]:Pe}:x,...w.trim()===G.name?{}:{name:w.trim()},...be?{replacing:be}:{}}).then(e=>{if(Object.keys(e.problems).length){k(e.problems);let t=G.fields.find(t=>e.problems[t.id]);t&&M({kind:`field`,field:t.id,nonce:Date.now()}),j({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else j({kind:`done`,res:e})}).catch(e=>j({kind:`error`,text:V(e)})))},Fe=e=>{if(!G)return;let t=Date.now(),n=e=>G.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return q();case`install-runtime`:case`start-runtime`:return ke();case`show-details`:return;case`choose-folder`:{j(null);let e=n([`folder`,`folders`]);if(!e&&G.launch.transport===`stdio`&&p){let e=A?.kind===`done`?A.res.outcome.problem?.detail?.path:void 0,n=ue({name:w||G.name,transport:`stdio`,command:G.launch.command,args:G.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...G,launch:{...G.launch,args:n.draft.launch.args??[]},fields:[...G.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),M({kind:`folder`,field:`folders`,nonce:t})}return M(null)}return M({kind:`folder`,field:e,nonce:t})}case`replace-key`:{j(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${me}${e}`))),M(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Me(G)&&p&&g({...p,draft:ye(G)}),j(null),O(!1),M({kind:`sign-in`,nonce:t});case`check-address`:{j(null);let e=n([`url`,`text`]);return M(e?{kind:`field`,field:e,nonce:t}:null)}}},[J,Le]=(0,Z.useState)(null),Y=async(e,t,n)=>{if(!R)return;Le(null);let{upstreamName:r}=R.result;if(p){H(null),B(r),T(r),Fe(e);return}let i=t;if(!i)try{i=(await Ve(R.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Le(V(e));return}i?(H(null),await W(i,e,n)):Le(`The server "${r}" isn't in your toolbox any more.`)},ze=(0,Z.useRef)(!1),Be=async e=>{if(A?.kind!==`done`||ze.current)return;ze.current=!0,P(!0),I(null);let r;if(t)try{let[e,n]=await Promise.all([Ve(t),h.protection(t)]);r={gateway:e.digest,policy:n.policyWrite.digest}}catch{r=void 0}try{if(!e){let e=await n.install(t??`main`,{probeId:A.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){L(e.loosens);return}}let i=await n.install(t??`main`,{probeId:A.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});L(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;H({result:i,name:G?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?L(Ne(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(L(null),I({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(L(null),I({text:je(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:V(e)}))}finally{ze.current=!1,P(!1)}};(0,Z.useEffect)(()=>{if(!R||R.settled)return;let e=Date.now(),t=R.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=xe(t,R.result.upstreamName,R.result.apply,Date.now()-e,e);H({...R,live:n,settled:i})}).catch(()=>r&&(R.result.apply===`needs-restart`||Date.now()-e>=15e3)&&H({...R,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[R?.result.upstreamName,R?.settled]);let He=()=>{$.saved=null,i?.()},We=()=>{let e=R?.result;$.saved=null,e&&r(e)};if(R)return(0,Q.jsx)(vt,{saved:R,heading:U,onFinish:We,onRewatch:()=>H({...R,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void Y(e,t,n),reopenError:J});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||Ee?(0,Q.jsx)(o,{lines:5}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center rounded-[18px] bg-surface/70`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,Q.jsx)(N,{}),` Opening…`]})}),(0,Q.jsx)($e,{compact:c,tab:u,onTab:d,onCatalog:e=>Te(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:He,children:`Cancel`})})]});let X=p.draft,Ge=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>A?j(null):(g(null),ee({kind:`picker`})),disabled:A?.kind===`running`||le,children:A&&A.kind!==`error`?`Change its settings`:`Choose another server`}),Ke=A?.kind===`done`&&!A.res.outcome.ok?A.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,qe=X.source.kind===`catalog`&&X.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(X.launch.url)?p.entry?.name??X.displayName:void 0,Je={firstSignIn:K?!D:A?.kind===`done`&&!!A.res.signInAvailable,...qe?{desktopApp:qe.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:X.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||X.launch.transport===`stdio`};return Ce===`test`&&A?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,X.displayName]}),A.kind===`running`?(0,Q.jsx)(ot,{transport:X.launch.transport}):A.kind===`done`&&A.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lt,{outcome:A.res.outcome,name:X.displayName,watching:_e,keyUnchecked:X.fields.some(e=>e.kind===`secret`)&&!(X.source.kind===`catalog`&&ht.has(X.source.id))}),A.res.egressHosts.length>0&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 text-[13px] text-soft`,children:[(0,Q.jsx)(m,{name:`shield`,size:16,className:`mt-0.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Saving lets the toolbox reach `,(0,Q.jsx)(`span`,{className:`mono`,children:A.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):A.kind===`done`?(0,Q.jsx)(Oe,{problem:Ke,onFix:Fe,context:Je,extra:(0,Q.jsxs)(Q.Fragment,{children:[A.res.signInAvailable&&!K&&A.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>Fe(`sign-in`),children:`Sign in instead`}),Ie(Ke,Je).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:q,children:`Try again`})]})}):null,F&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:F.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:q,children:`Test it again`}):void 0,children:F.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Ge,A.kind===`done`&&A.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void Be(),loading:le,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!fe,title:`Save ${X.displayName}?`,confirmLabel:`Save and turn on`,consequences:fe??[],busy:le,error:F?.text??null,onCancel:()=>L(null),onConfirm:()=>void Be(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,X.displayName]}),(0,Q.jsx)(ft,{draft:X,entry:p.entry,values:x,onValues:e=>{S(e),k({})},problems:re,tried:te,onVariant:e=>p.entry&&Te(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:O,doctor:ae,doctorBusy:se,onRecheck:ke,focus:ie}),A?.kind===`error`&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[13.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,strokeWidth:2}),` `,A.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Ge,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:q,disabled:!!_,children:`Test it`})]})]})}function vt({saved:e,heading:t,onFinish:n,onRewatch:r,onReopen:a,reopenError:o}){let{result:c,live:l,settled:u,name:d}=e,f=g(),p=!u,[h,_]=(0,Z.useState)(null),v=l.kind===`problem`||l.kind===`needs-sign-in`;(0,Z.useEffect)(()=>{if(!v||h)return;let e=!0;return Ve(c.gatewayId).then(t=>e&&t.broken===null&&_(t.config.upstreams.find(e=>e.name===c.upstreamName)??null)).catch(()=>void 0),()=>{e=!1}},[v,c.gatewayId,c.upstreamName]);let y,b=null,x=`check`;l.kind===`live`?(y=`Live — ${l.tools} ${l.tools===1?`tool`:`tools`} ready`,b=`${d} is on. Your AI app can use it now, no restart needed.`):c.apply===`not-running`?(y=`${d} is saved`,b=`It turns on when your AI app opens your toolbox. If you haven't connected an app yet, that's the next step.`):c.apply===`needs-restart`||l.kind===`needs-restart`?(y=`${d} is saved. Restart your AI app once`,b=(l.kind===`needs-restart`?l.why:void 0)??`The running toolbox couldn't take this change while running. Quit your AI app and open it again.`,x=`clock`):l.kind===`needs-sign-in`?(y=`Saved, but it needs you to sign in`,b=`Press Sign in again below. It turns on as soon as you're signed in.`,x=`warning`):l.kind===`problem`?(y=`Saved, but it isn't working yet`,x=`warning`):p?(y=`Turning on ${d}…`,x=`clock`):(y=`${d} is saved`,b=`It's still starting. You can see how it's doing on the Connections page.`,x=`clock`);let C=l.kind===`problem`?{name:c.upstreamName,state:`failed`,problem:l.problem,since:``,attempts:0,tool_count:0}:l.kind===`needs-sign-in`?{name:c.upstreamName,state:`needs-sign-in`,since:``,attempts:0,tool_count:0}:null,w=e=>{$.saved=null,ce(i(f,e,{server:c.gatewayId}))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-3 py-6 text-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:P(`grid h-12 w-12 place-items-center rounded-full`,x===`check`?`bg-ok-tint text-ok`:x===`warning`?`bg-warn-tint text-warn`:`bg-sunken text-muted`),children:(0,Q.jsx)(m,{name:x,size:22,strokeWidth:2})}),(0,Q.jsx)(`h2`,{ref:t,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:y}),(0,Q.jsx)(`div`,{className:`max-w-[46ch] text-[14px] text-muted`,children:p&&l.kind===`waiting`?(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:(0,Q.jsx)(S,{state:`connecting`,label:`Starting`})}):b})]}),C&&(0,Q.jsx)(ze,{gatewayId:c.gatewayId,upstream:h??{name:c.upstreamName,transport:`stdio`,command:``},state:C,onEdit:e=>a(e,h,l.kind===`problem`?l.problem.detail?.path:void 0),onFixed:r,onAllowAddress:()=>w(`/protection`)}),o&&(0,Q.jsxs)(s,{tone:`danger`,role:`alert`,title:`The setup screen couldn't be opened again`,children:[o,` You can change this server on the Connections page instead.`]}),(c.summary.length>0||c.created)&&(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13.5px]`,children:[c.created&&(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` Your toolbox is ready. Connect your AI app to it next.`]}),c.summary.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` `,e]},e))]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`primary`,icon:`check`,onClick:n,children:`Done`})})]})}var yt=null;function bt({client:e,projectDir:t,onClose:n,onDone:r}){let i=le(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(yt),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(yt=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{yt=null,n(),r()},_=Te(e.scope),v=()=>{l(!0),d(null),Be.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{yt=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(V(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(se,{open:!0,onClose:g,title:`Connection undone`,description:`Restart ${_} so it uses its own server list again.`,width:580,footer:(0,Q.jsx)(E,{variant:`primary`,onClick:g,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsx)(`p`,{children:e.fileRestored===`bytes`?`Your toolbox was taken out of ${_}, and its settings file is back exactly as it was before.`:e.fileRestored===`removed`?`Your toolbox was taken out of ${_}. Its settings file didn't exist before, so it was removed again.`:`Your toolbox was taken out of ${_}.`}),f.restored.length>0?(0,Q.jsx)(xt,{title:`Servers given back to ${_}`,items:f.restored}):(0,Q.jsxs)(`p`,{className:`text-soft`,children:[_,`'s own servers were never moved, so they keep working as before.`]}),e.copyLeft&&(0,Q.jsxs)(s,{tone:`warn`,title:`A copy of the old settings is kept`,children:[_,`'s settings file changed since it was connected, so a copy of it as it was is kept at `,(0,Q.jsx)(J,{children:e.copyLeft}),`. It holds the old values, including any keys that were written in it. Delete it once you no longer need it.`]}),e.keysKept&&e.keysKept.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Its keys stay in your locked keys (`,e.keysKept.join(`, `),`). Remove them under Settings & help, Locked keys, if nothing else uses them.`]}),e.stillUsedBy&&e.stillUsedBy.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Your toolbox was kept, because `,e.stillUsedBy.join(` and `),` still `,e.stillUsedBy.length===1?`uses`:`use`,` it.`]}),f.deleted.length>0&&(0,Q.jsx)(xt,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(xt,{title:`Files kept`,items:f.leftInPlace,paths:!0}),f.refusedToDelete.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Some files were not deleted`,children:(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:f.refusedToDelete.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(J,{children:e.path}),` `,q(B(e.why))]},e.path))})}),f.registryRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The toolbox was also removed from this console.`}),f.clientAllowRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The “Don't ask me twice” setting was removed from Claude Code.`}),f.clientAllowError&&(0,Q.jsx)(s,{tone:`warn`,children:q(B(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(B(f.warning))})]})})}return(0,Q.jsx)(se,{open:!0,onClose:n,tone:`danger`,dismissable:!c,title:`Undo the connection for ${e.label}?`,description:`${_} goes back to reaching its servers directly, without your toolbox checking each call.`,width:580,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`secondary`,onClick:n,disabled:c,children:`Keep it connected`}),(0,Q.jsx)(E,{variant:`danger`,onClick:v,loading:c,children:`Undo connection`})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`ul`,{className:`space-y-2 text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`refresh`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`The app's original server list is put back from the backup made when it was connected.`]}),(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[`The file changed is `,(0,Q.jsx)(J,{children:e.path})]})]})]}),(0,Q.jsx)(oe,{checked:a,onChange:o,label:`Also delete the toolbox's files`,description:`Its settings file and protection settings. Your rules and choices in them are lost. Leave this off to keep them for later. They are kept anyway while another app still uses the toolbox.`}),u&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:u})]})})}function xt({title:e,items:t,empty:n,paths:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:e}),t.length===0?(0,Q.jsx)(`p`,{className:`text-soft`,children:n}):(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.map(e=>(0,Q.jsx)(`li`,{children:r?(0,Q.jsx)(J,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var St={done:null};function Ct({gatewayId:t,onDone:r,compact:i,scope:a}){let c=ie(()=>Be.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(St.done&&(!a||St.done.scope===a)?St.done:null),g=e=>{St.done=e,h(e)},[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{p&&b.current&&(b.current=!1,y.current?.focus())},[p]);let S=c.data?.clients??[],C=(a?S.filter(e=>e.scope===a):S).filter(e=>!i||e.installed!==!1||e.exists).sort((e,t)=>wt(e)-wt(t)),w=e=>{u(e.scope),f(null),n.attach({gatewayId:t,scope:e.scope,...e.projectScoped&&c.data?.projectDir?{projectDir:c.data.projectDir}:{}}).then(t=>{let n=U(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n}),c.reload()}).catch(t=>f({scope:e.scope,text:V(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{ref:y,tabIndex:-1,role:`status`,className:`flex flex-col gap-3 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),p.alreadyConnected?`${p.appLabel} was already connected`:`Restart ${p.appLabel} once`]}),(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:p.alreadyConnected?`Nothing needed changing. Your servers reach it through the toolbox.`:`${p.appLabel} reads its list of servers when it opens, so it needs one restart to find your toolbox. After that, servers you add show up by themselves.`}),p.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:q(B(p.restartHint))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(J,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(J,{children:p.backupPath})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v({...e,canRevert:!0}),children:`Undo`}),!a&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:()=>g(null),children:`Connect another app`})]}),(0,Q.jsx)(bt,{client:_,projectDir:c.data?.projectDir,onClose:()=>v(null),onDone:()=>{g(null),c.reload()}})]})}return c.error&&!c.data?(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:c.reload,children:`Check again`}),children:V(c.error)}):c.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!a&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app you talk to. One click adds your toolbox to it; nothing else in the app changes.`}),C.length===0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`No AI app was found on this computer.`}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`Install one of these, open it once, then come back here and press Check again.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:c.loading,onClick:c.reload,children:`Check again`})]})]}),(0,Q.jsx)(`ul`,{className:P(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=he(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:P(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] border-line p-4`,!n&&!r&&`bg-sunken/40`),children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:P(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:G(t,c.data?.projectDir)}),r?(0,Q.jsx)(e,{tone:`ok`,children:`Connected`}):!n&&(0,Q.jsx)(e,{children:t.error?`Can't be read`:`Not found`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:t.error?q(B(t.error)):r?`It already reaches its servers through a toolbox.`:n?t.serverCount>0?`Adds your toolbox beside the ${t.serverCount} ${t.serverCount===1?`server`:`servers`} it already has. ${t.serverCount===1?`That one keeps`:`Those keep`} working as before, but without the toolbox's protection.`:`Adds your toolbox to it.`:`This app isn't on this computer.`}),d?.scope===t.scope&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:d.text}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[n&&!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:l===t.scope,disabled:!!l&&l!==t.scope,onClick:()=>w(t),children:[`Connect `,U(t.scope)]}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(bt,{client:_,projectDir:c.data.projectDir,onClose:()=>v(null),onDone:c.reload})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:2})},e))})}var wt=e=>e.error?3:e.alreadyAdopted?1:he(e)?0:4;export{Qe as a,Je as c,gt as i,Xe as l,bt as n,Ye as o,_t as r,Ze as s,Ct as t};
@@ -1,2 +0,0 @@
1
- import{$ as e,A as t,At as n,B as r,Ct as i,D as a,E as o,Et as s,G as c,H as l,It as u,J as d,M as f,N as p,Nt as m,O as h,Ot as g,Pt as _,S as v,St as y,U as b,V as x,Y as S,Z as C,_ as w,_t as T,at as E,b as D,bt as O,c as k,et as A,f as j,ft as M,gt as N,ht as P,it as F,k as I,kt as L,l as R,lt as z,m as ee,mt as te,p as ne,pt as re,q as ie,s as ae,st as B,u as oe,vt as se,wt as ce,x as le,xt as ue,y as V,yt as H,z as de}from"./kit-DQ7Oxf5n.js";import{$ as fe,Bt as pe,Ft as me,Ht as he,It as ge,Jt as _e,Kt as U,Lt as W,Mt as ve,Pt as G,Q as ye,Qt as K,Rt as be,Ut as xe,Vt as Se,Wt as Ce,X as we,Yt as q,Z as Te,_ as Ee,an as De,cn as Oe,d as ke,dn as Ae,et as J,f as je,fn as Me,g as Ne,h as Pe,jt as Fe,ln as Ie,m as Le,mn as Re,nn as ze,on as Be,p as Ve,qt as He,rn as Ue,s as We,sn as Ge,tn as Ke,tt as Y,un as qe,v as Je,y as Ye,zt as Xe}from"./index-Khp0l1zp.js";import{a as Ze,c as Qe,i as $e,l as et,n as tt,o as nt,r as rt,s as it,t as at}from"./AttachApp-0zRSPgSY.js";var X=u(),Z=L(),ot=[`Choose an app`,`Choose how it starts`,`Check what will happen`,`Connect`],st={mode:`observe`,posture:`approve-writes`,onUnclassified:`approve`,packs:!0,clientAllow:!1,gatewayName:``,entryName:``,rename:[],copyEnv:!1,allowLocalHttp:!1,strictEgress:!1,relativeConfig:!1,outDir:``,id:``};function ct(e,t,n,r){let i=Object.fromEntries(r.rename.filter(([e,t])=>e.trim()&&t.trim()).map(([e,t])=>[e.trim(),t.trim()]));return{scope:e,...n&&t?{projectDir:t}:{},mode:r.mode,posture:r.posture,onUnclassified:r.onUnclassified,packs:r.packs,...Xe(e)&&r.mode===`enforce`?{clientAllow:r.clientAllow}:{},...r.gatewayName.trim()?{gatewayName:r.gatewayName.trim()}:{},...r.entryName.trim()?{entryName:r.entryName.trim()}:{},...Object.keys(i).length?{rename:i}:{},copyEnv:r.copyEnv,allowLocalHttp:r.allowLocalHttp,strictEgress:r.strictEgress,relativeConfig:r.relativeConfig,...r.outDir.trim()?{outDir:r.outDir.trim()}:{},...r.id.trim()?{id:r.id.trim()}:{}}}var Q={done:null,undo:null};function lt({open:e,onClose:t}){let n=()=>{Q.done=null,Q.undo=null,t()};return(0,Z.jsx)(v,{open:e,onClose:n,title:`Connect an app`,subtitle:`Put your toolbox between one of your AI apps and the servers it uses.`,width:880,children:e&&(0,Z.jsx)(ut,{onClose:n})})}function ut({onClose:e}){let{nav:t,reload:n}=K(),[r,a]=(0,X.useState)(0),[o,s]=(0,X.useState)(``),c=(0,X.useRef)(!1),u=O(o.trim(),450),d=ae(()=>Re.clients(u||void 0),[u]);(0,X.useEffect)(()=>{d.data&&!c.current&&!o&&s(d.data.projectDir)},[d.data]);let[f,p]=(0,X.useState)(null),h=d.data?.clients.find(e=>e.scope===f)??null,[g,_]=(0,X.useState)(st),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(Q.undo),S=e=>{Q.undo=e,x(e)},C=(0,X.useMemo)(()=>h?ct(h.scope,d.data?.projectDir??``,h.projectScoped,g):null,[h,d.data?.projectDir,g]),w=JSON.stringify(C),[T,E]=(0,X.useState)(null),D=r>=2&&C&&T?.key!==w;(0,X.useEffect)(()=>{if(r<2||!C||T?.key===w)return;let e=!0;return Re.plan(C).then(t=>e&&E({key:w,data:t,error:null})).catch(t=>e&&E({key:w,data:null,error:W(t)})),()=>{e=!1}},[r,w]);let[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),[N,F]=(0,X.useState)(Q.done),I=()=>{C&&(A(!0),M(null),Re.apply(C).then(e=>{Q.done=e,F(e)}).catch(e=>{if(e instanceof m&&e.status===409){M({text:`A toolbox with that name is already in the console. Choose another name and try again.`,idTaken:!0});return}let t=e.detail;t?.report&&E({key:w,data:t.report,error:null}),M({text:W(e),blocking:t?.blocking})}).finally(()=>A(!1)))};if(N)return(0,Z.jsx)(wt,{result:N,onClose:()=>{e(),n()},onOpen:r=>{e(),n(),ue(i(t,`/`,{server:r}))}});let L=T?.key===w?T:null,R=!!L?.data&&L.data.blocking.length>0,z=r===0?!!h&&h.exists&&!h.error&&(h.serverCount>0||h.alreadyAdopted):r===1||!!L?.data&&!R;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(oe,{steps:ot,step:r,onStep:e=>a(Math.max(0,e)),canNext:z&&!k,nextLabel:r===2?`Review and connect`:`Continue`,finishLabel:h?`Connect ${G(h.scope)}`:`Connect app`,onFinish:I,busy:k||!!D,children:[r===0&&(0,Z.jsx)(dt,{clients:d,projectDir:o,onProjectDir:e=>{c.current=!0,s(e)},scope:f,onScope:p,onUndo:S,onAttach:y}),r===1&&h&&(0,Z.jsx)(ht,{client:h,choices:g,onChange:_,found:L?.data?.serversFound??T?.data?.serversFound??[]}),r===2&&(D||!L?(0,Z.jsx)(gt,{}):L.error?(0,Z.jsx)(l,{tone:`danger`,title:`The check could not finish`,role:`alert`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>E(null),children:`Check again`}),children:L.error}):(0,Z.jsx)(vt,{plan:L.data,app:G(h.scope)})),r===3&&L?.data&&h&&(0,Z.jsx)(Ct,{plan:L.data,client:h,error:j,id:g.id,onId:e=>_({...g,id:e})})]}),(0,Z.jsx)(Tt,{client:v,onClose:()=>y(null),onDone:()=>d.reload()}),(0,Z.jsx)(tt,{client:b,projectDir:d.data?.projectDir,onClose:()=>S(null),onDone:()=>{d.reload(),n()}})]})}function dt({clients:e,projectDir:t,onProjectDir:n,scope:r,onScope:i,onUndo:a,onAttach:s}){let u=e.data?.clients??[],d=e.error&&!e.data?null:e.error;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app whose tools you want your toolbox to check. The servers it already uses keep working; they are reached through your toolbox instead of directly.`}),(0,Z.jsx)(o,{label:`Project folder`,help:`Some apps keep a server list per project. This is the project they are read from. Use the full path.`,error:d?W(d):null,children:(0,Z.jsx)(f,{value:t,onChange:n,mono:!0,placeholder:`/Users/me/my-project`})}),e.error&&!e.data?(0,Z.jsx)(l,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:e.reload,children:`Check again`}),children:W(e.error)}):e.data?(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":`App to connect`,className:`grid gap-3 sm:grid-cols-2`,children:[...u].sort((e,t)=>ft(e)-ft(t)).map(e=>(0,Z.jsx)(mt,{client:e,selected:r===e.scope,onSelect:()=>i(e.scope),onUndo:()=>a(e),onAttach:()=>s(e)},e.scope))}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Z.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Z.jsx)(c,{lines:3})},e))})]})}var ft=e=>e.error?3:e.alreadyAdopted?1:e.exists&&e.serverCount>0?0:me(e)?2:4,pt=e=>!e.alreadyAdopted&&me(e)&&!(e.exists&&e.serverCount>0);function mt({client:t,selected:n,onSelect:i,onUndo:a,onAttach:o}){let s=t.exists&&!t.error&&(t.serverCount>0||t.alreadyAdopted),c=pt(t),l=(0,X.useId)(),u=xe(t),d=t.error?{tone:`bad`,text:`Can't be read`}:!t.exists&&!c?{tone:`neutral`,text:`Not found`}:t.alreadyAdopted?{tone:`ok`,text:`Connected`}:t.serverCount===0?{tone:`neutral`,text:`No servers yet`}:{tone:`warn`,text:`Not protected`};return(0,Z.jsxs)(`div`,{className:H(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] p-4 transition-colors`,n?`border-primary bg-ok-tint`:`border-line`,!s&&`bg-sunken/40`),children:[(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-labelledby":`${l}-name`,"aria-describedby":`${l}-status ${l}-desc`,disabled:!s,onClick:i,className:`flex min-w-0 flex-col items-start gap-1 text-left disabled:cursor-not-allowed`,children:[(0,Z.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:H(`mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border-[1.5px]`,n?`border-primary bg-primary text-white`:`border-[var(--soft)]`,!s&&`opacity-40`),children:n&&(0,Z.jsx)(g,{name:`check`,size:12,strokeWidth:3})}),(0,Z.jsx)(`span`,{id:`${l}-name`,className:H(`min-w-0 flex-1 text-[15px] font-semibold`,!s&&`text-soft`),children:u}),(0,Z.jsx)(`span`,{id:`${l}-status`,children:(0,Z.jsx)(e,{tone:d.tone,children:d.text})})]}),(0,Z.jsx)(`span`,{id:`${l}-desc`,className:`pl-7 text-[13px] text-soft`,children:t.error?q(U(t.error)):c?`It has no servers yet. Connect it to your toolbox, then add servers there.`:t.exists?t.alreadyAdopted?t.serverCount>1?`Goes through your toolbox. ${r(t.serverCount-1,`new server`)} could be added.`:`Its servers already go through your toolbox.`:t.serverCount===0?`The app has no servers set up, so there is nothing to protect yet.`:`${r(t.serverCount,`server`)} set up, reached directly with nothing checking them.`:`This app's settings file isn't on this computer.`}),t.exists&&(0,Z.jsx)(`span`,{className:`pl-7`,children:(0,Z.jsx)(J,{children:t.path})})]}),c&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`plug`,onClick:o,children:`Connect it to your toolbox`})}),t.canRevert&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:a,children:`Undo connection`})})]})}function ht({client:t,choices:n,onChange:r,found:i}){let a=(e,t)=>r({...n,[e]:t}),s=Xe(t.scope);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:`You can switch at any time on the Protection settings page.`,children:[`How it starts `,(0,Z.jsx)(w,{term:`watchOnly`})]}),(0,Z.jsx)(we,{label:`How it starts`,value:n.mode,onChange:e=>a(`mode`,e),options:[{value:`observe`,title:E.observe.label,badge:(0,Z.jsx)(e,{tone:`ok`,children:`Recommended for day one`}),body:`Nothing breaks while you settle in. Every call runs, and the activity log shows what would have been blocked or held, so you can adjust before turning protection on.`},{value:`enforce`,title:E.enforce.label,body:`Rules apply from the first call. Blocked calls stop and changes wait for you, which can interrupt work until the rules fit.`}]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:`What happens to a call no rule mentions.`,children:[`Default stance `,(0,Z.jsx)(w,{term:`defaultStance`})]}),(0,Z.jsx)(we,{label:`Default stance`,columns:3,value:n.posture,onChange:e=>a(`posture`,e),options:Object.keys(B).map(e=>({value:e,title:B[e].label,body:B[e].explain}))})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(o,{label:(0,Z.jsxs)(Z.Fragment,{children:[`Tools nobody has labelled yet `,(0,Z.jsx)(w,{term:`unknownTools`})]}),help:`A tool that hasn't said whether it only looks, makes changes or deletes.`,children:(0,Z.jsx)(h,{label:`Tools nobody has labelled yet`,value:n.onUnclassified,onChange:e=>a(`onUnclassified`,e),options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,Z.jsx)(p,{checked:n.packs,onChange:e=>a(`packs`,e),label:`Use ready-made rules for servers your toolbox knows`,description:`For well-known servers such as file system and GitHub, sensible rules are filled in for each tool so you start with less to decide.`}),(0,Z.jsx)(p,{checked:s&&n.mode===`enforce`&&n.clientAllow,onChange:e=>a(`clientAllow`,e),disabled:!s||n.mode!==`enforce`,label:`Don't ask me twice`,description:s?n.mode===`enforce`?`Claude Code asks before each tool call, and your toolbox asks too when a rule says so. This stops Claude Code asking about your toolbox's tools, so you answer once.`:`Available when protecting. While it only watches, your toolbox never asks, so Claude Code's own question is the only one left.`:`Only Claude Code has this setting. ${G(t.scope)} keeps asking in its own way.`})]}),(0,Z.jsxs)(ye,{title:`More options`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Toolbox name`,technical:`name`,optional:!0,help:`Shown in the console and in the activity log.`,children:(0,Z.jsx)(f,{value:n.gatewayName,onChange:e=>a(`gatewayName`,e),mono:!0,placeholder:`claude-code`})}),(0,Z.jsx)(o,{label:`Name in the app's server list`,optional:!0,technical:`entry name`,help:`What your toolbox is called inside the app.`,children:(0,Z.jsx)(f,{value:n.entryName,onChange:e=>a(`entryName`,e),mono:!0,placeholder:`hmcp`})})]}),(0,Z.jsx)(o,{label:`Rename servers`,optional:!0,help:i.length?`Found in the app: ${i.join(`, `)}. New names use lower-case letters, digits and underscores.`:`The name in the app on the left, the name in your toolbox on the right. Lower-case letters, digits and underscores.`,children:(0,Z.jsx)(fe,{value:n.rename,onChange:e=>a(`rename`,e),keyLabel:`Name in the app`,valueLabel:`Name in your toolbox`,addLabel:`Add a rename`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{checked:n.copyEnv,onChange:e=>a(`copyEnv`,e),label:`Copy keys into the toolbox's settings file`,description:`Gives each server its own copy of the values it needs, such as access keys.`}),n.copyEnv&&(0,Z.jsx)(l,{tone:`warn`,title:`This writes passwords and keys into a file`,children:`The toolbox's settings file will hold them in plain text, outside your locked keys. Anyone who can read that file can read them, so don't share it or put it anywhere others can see. Leave this off unless a server was left out because of its values.`})]}),(0,Z.jsx)(p,{checked:n.allowLocalHttp,onChange:e=>a(`allowLocalHttp`,e),label:`Allow servers on this computer`,description:`Lets your toolbox reach web servers on this computer or your local network. This adds to your allowed addresses for every web server this toolbox reaches, not just one.`}),(0,Z.jsx)(p,{checked:n.strictEgress,onChange:e=>a(`strictEgress`,e),label:`Strict allowed addresses`,description:`Each remote server may be reached only at its exact address and port, rather than anywhere on its host.`}),(0,Z.jsx)(p,{checked:n.relativeConfig,onChange:e=>a(`relativeConfig`,e),label:`Point to the toolbox's settings file by a relative path`,description:`Useful when the project folder is shared or moved, so the app finds the toolbox's settings file wherever the folder lives.`}),(0,Z.jsx)(o,{label:`Folder for the toolbox's files`,optional:!0,help:`A full path. By default they go in a .hmcp folder in the project, or in your home folder for apps that aren't per project.`,children:(0,Z.jsx)(f,{value:n.outDir,onChange:e=>a(`outDir`,e),mono:!0,placeholder:`/Users/me/my-project/.hmcp`})})]})]})}function gt(){let[e,t]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-14 text-center`,children:[(0,Z.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Z.jsx)(se,{size:26})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-[17px] font-medium`,children:`Starting each server to see its tools…`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`This can take up to about 40 seconds. Nothing is changed yet. `,e>2&&(0,Z.jsxs)(`span`,{className:`tnum`,children:[`(`,e,` s)`]})]})]})]})}var _t=[{key:`run`,label:`Runs freely`,icon:`check`,tone:`ok`},{key:`ask`,label:`Asks first`,icon:`clock`,tone:`warn`},{key:`blocked`,label:`Blocked`,icon:`x`,tone:`bad`},{key:`hidden`,label:`Hidden`,icon:`eye-off`,tone:`neutral`}];function vt({plan:t,app:n}){let i=t.starting?.mode!==`enforce`,a=t.tools.filter(e=>e.injection);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t.blocking.length>0&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`This can't be connected yet`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.blocking.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))})}),t.status===`already-adopted`&&t.blocking.length===0&&(0,Z.jsx)(l,{tone:`info`,title:`${n} already goes through your toolbox`,children:`Connecting again only applies the change you chose.`}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:t.existingGateway?`New servers are added to the toolbox this app already uses.`:void 0,children:[`Servers (`,t.upstreams.length,`)`]}),t.upstreams.length===0?(0,Z.jsx)(`p`,{className:`text-[14px] text-soft`,children:`No server can go through your toolbox.`}):(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:t.upstreams.map(t=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-3 rounded-2xl bg-sunken/60 p-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-surface text-muted`,children:(0,Z.jsx)(g,{name:t.transport===`http`?`external`:`server`,size:17})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`code`,{className:`mono text-[13.5px] font-semibold`,children:t.name}),t.originalName!==t.name&&(0,Z.jsxs)(`span`,{className:`text-[12px] text-soft`,children:[`was `,t.originalName]}),t.alreadyFronted&&(0,Z.jsx)(e,{children:`Already connected`})]}),(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:t.transport===`http`?`Remote server · ${t.url}`:`Runs on this computer · ${[t.command,...t.args].join(` `)}`}),(t.envNames.length>0||t.passEnv.length>0||t.headerNames.length>0)&&(0,Z.jsxs)(`span`,{className:`mt-0.5 block text-[12px] text-soft`,children:[`Uses `,(0,Z.jsx)(`span`,{className:`mono`,children:[...t.envNames,...t.passEnv,...t.headerNames].join(`, `)})]}),t.warnings.map(e=>(0,Z.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:q(U(e))},e))]})]},t.name))}),(t.skipped.length>0||t.malformed.length>0)&&(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:[`Left out (`,t.skipped.length+t.malformed.length,`)`]}),(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.skipped.map(e=>{let t=He(e.reason,e.remedy);return(0,Z.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:t.reason}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-soft`,children:t.remedy})]},e.name)}),t.malformed.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Its entry in the app's settings could not be read: `,q(U(e.message))]})]},e.name))]})]})]}),t.probeFailures.length>0&&(0,Z.jsxs)(l,{tone:`danger`,title:`Some servers didn't start or answer`,children:[(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:t.probeFailures.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`mono`,children:e.upstream}),`: `,q(U(e.message))]},e.upstream))}),(0,Z.jsx)(`p`,{className:`mt-1`,children:`Check that each one works in the app on its own, then go back a step and check again.`})]}),t.tools.length>0&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:i?`For now it only watches, so every call runs. This is what will happen once you turn protection on.`:`What happens to each tool from the first call.`,children:[`Tools (`,t.tools.length,`)`]}),(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:_t.map(e=>{let n=t.tools.filter(t=>t.verdict===e.key);return n.length===0?null:(0,Z.jsx)(xt,{label:e.label,icon:e.icon,tone:e.tone,tools:n},e.key)})})]}),(a.length>0||t.findings.length>0||t.namesTooLong.length>0||t.withheld.length>0)&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Worth a look`}),(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl bg-warn-tint p-3`,children:[(0,Z.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` has hidden instructions in its description.`,` `,e.hidden?`The tool will be hidden from your AI app.`:`Your toolbox will deal with them as set in its options.`]})]},`inj-${e.name}`)),yt(t.findings).map(e=>(0,Z.jsx)(bt,{group:e},e.ruleId)),t.namesTooLong.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` has a name too long for `,n,` (`,e.length,` of `,e.limit,` letters), so it won't be offered. A shorter server name under More options leaves more room.`]})]},`long-${e.name}`)),t.withheld.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`eye-off`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` won't be offered: `,q(U(e.reason))]})]},`w-${e.name}`))]})]}),t.packs.length>0&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Ready-made rules`}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.packs.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-2xl bg-ok-tint p-3 text-[13.5px]`,children:[(0,Z.jsx)(g,{name:`shield-check`,size:18,className:`shrink-0 text-ok`}),(0,Z.jsxs)(`span`,{children:[e.packLabel,` rules for `,(0,Z.jsx)(`code`,{className:`mono`,children:e.upstreamName}),`: `,r(e.rules.length,`rule`),e.unmatched.length>0&&(0,Z.jsxs)(`span`,{className:`text-soft`,children:[` · `,e.unmatched.length,` not used by this server`]})]})]},e.upstreamName))})]}),t.warnings.length>0&&(0,Z.jsx)(l,{tone:`warn`,title:`Before you connect`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))})}),t.files&&(0,Z.jsx)(St,{plan:t})]})}function yt(e){let t=new Map;for(let n of e)t.set(n.ruleId,[...t.get(n.ruleId)??[],n]);return[...t.entries()].map(([e,t])=>({ruleId:e,high:t.some(e=>e.severity===`high`),items:t})).sort((e,t)=>Number(t.high)-Number(e.high))}function bt({group:e}){let[t,n]=(0,X.useState)(!1);return(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`shield`,size:17,className:H(`mt-0.5 shrink-0`,e.high?`text-bad`:`text-warn`)}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:M(e.ruleId)}),(0,Z.jsx)(`span`,{className:`mono text-[11.5px] text-soft`,children:e.ruleId}),e.items.length>1&&(0,Z.jsxs)(`span`,{className:`text-soft`,children:[`· `,e.items.length,` places`]}),e.ruleId in F&&(0,Z.jsx)(w,{term:e.ruleId})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`-ml-3`,"aria-expanded":t,onClick:()=>n(!t),children:t?`Hide details`:`Show details`}),t&&(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5 text-[13px] text-muted`,children:e.items.map((e,t)=>(0,Z.jsx)(`li`,{className:`break-words`,children:q(U(e.message))},t))})]})]})}function xt({label:t,icon:n,tone:r,tools:i}){let[a,o]=(0,X.useState)(i.length<=8),s=a?i:i.slice(0,8);return(0,Z.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Z.jsx)(e,{tone:r,icon:n,children:t}),(0,Z.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:i.length})]}),(0,Z.jsx)(`ul`,{className:`flex flex-col`,children:s.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Z.jsx)(C,{effect:e.effect}),(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 truncate text-[12.5px]`,title:e.name,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[12px] text-soft`,title:e.decidedBy,children:ge(e.decidedBy)})]},e.name))}),!a&&(0,Z.jsxs)(P,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>o(!0),children:[`Show all `,i.length,` tools`]})]})}function St({plan:e}){let t=e.files,n=[[`The app's settings, changed to use your toolbox`,t.clientConfig],[`Backup of the app's settings`,t.wholeFileBackup],[`Record used to undo the connection`,t.backupRecord],[`The toolbox's settings file`,t.gatewayConfig],[t.policyKept?`Protection settings (kept as they are)`:`Protection settings`,t.policy],[`Claude Code permission for “Don't ask me twice”`,t.clientSettings]];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Files that will be written`}),(0,Z.jsx)(`dl`,{className:`flex flex-col gap-2 text-[13px]`,children:n.filter(([,e])=>e).map(([e,t])=>(0,Z.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-[240px_1fr]`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(J,{children:t})})]},e))})]})}function Ct({plan:e,client:t,error:n,id:i,onId:a}){let s=G(t.scope),c=e.starting?.mode!==`enforce`,u=e.upstreams.filter(e=>!e.alreadyFronted).length,d=[[`plug`,u>0?`${r(u,`server`)} in ${t.label} will go through your toolbox.`:`The change you chose is applied to your toolbox.`],[`file`,`A backup of the app's settings is kept, so you can undo this here at any time.`],[c?`eye`:`shield-check`,c?`For now it only watches: everything runs, and the activity log shows what would have been stopped.`:`It starts protecting: your rules apply from the first call.`],[`refresh`,`${s} has to be restarted afterwards to pick up your toolbox.`]];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{children:`When you connect`}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:d.map(([e,t])=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-3 text-[14.5px]`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Z.jsx)(g,{name:e,size:17})}),(0,Z.jsx)(`span`,{className:`pt-1.5`,children:t})]},t))}),n&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`It wasn't connected`,children:n.blocking?.length?(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:n.blocking.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))}):n.text}),n?.idTaken&&(0,Z.jsx)(o,{label:`Toolbox name in the console`,technical:`id`,help:`Lower-case letters, digits, dashes and underscores.`,children:(0,Z.jsx)(f,{value:i,onChange:a,mono:!0,placeholder:`claude-code-2`})})]})}function wt({result:e,onClose:t,onOpen:n}){let r=G(e.scope),i=e.applied;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(R,{steps:ot,current:ot.length}),(0,Z.jsxs)(b,{icon:`check`,title:`Done. Restart ${r} so it picks up your toolbox.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[e.registryId&&(0,Z.jsx)(P,{variant:`primary`,icon:`arrow-right`,onClick:()=>n(e.registryId),children:`Open this toolbox`}),(0,Z.jsx)(P,{onClick:t,children:`Close`})]}),children:[i.replaced.length>0?`${i.replaced.join(`, `)} now ${i.replaced.length===1?`goes`:`go`} through your toolbox.`:`Your toolbox is set up as you chose.`,` `,e.starting?.mode===`enforce`?`It is protecting from the first call.`:`For now it only watches, so nothing is blocked yet.`]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Z.jsx)(`p`,{className:`font-semibold`,children:`What was backed up`}),i.wholeFileBackup&&(0,Z.jsxs)(`p`,{children:[`A copy of the app's settings as they were: `,(0,Z.jsx)(J,{children:i.wholeFileBackup})]}),(0,Z.jsxs)(`p`,{children:[`What's needed to undo it: `,(0,Z.jsx)(J,{children:i.backupRecord})]}),i.clientAllowAdded&&(0,Z.jsx)(`p`,{children:`Claude Code won't ask a second time about your toolbox's tools.`})]}),i.literalSecretsInBackup&&(0,Z.jsx)(l,{tone:`warn`,title:`The backups hold a password or key`,children:`A server you connected had a key written out in the app's settings, so both backup files contain it. Keep them private.`}),e.warning&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(e.warning))})]})}function Tt({client:e,onClose:t,onDone:n}){let{servers:r,serverId:i,nav:a}=K(),c=r.filter(e=>e.ok),[l,u]=(0,X.useState)(null),d=l??(c.some(e=>e.id===i)?i:c[0]?.id??null);return e?(0,Z.jsx)(le,{open:!0,onClose:t,title:`Connect ${G(e.scope)} to your toolbox`,width:600,footer:(0,Z.jsx)(P,{onClick:t,children:`Close`}),children:d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length>1&&(0,Z.jsx)(o,{label:`Which toolbox`,children:(0,Z.jsx)(h,{label:`Which toolbox`,value:d,onChange:u,options:c.map(e=>({value:e.id,label:e.label}))})}),(0,Z.jsx)(at,{gatewayId:d,scope:e.scope,onDone:n},d)]}):(0,Z.jsxs)(b,{icon:`server`,title:`You don't have a toolbox yet`,compact:!0,children:[`Adding your first server sets one up. Then come back here and connect `,G(e.scope),`.`,(0,Z.jsx)(`span`,{className:`mt-4 block`,children:(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>ue(s(a,{connect:null,add:`server`})),children:`Add a server`})})]})}):null}var Et={done:null,label:``};function Dt({open:e,onClose:t}){let{reload:n}=K(),r=()=>{let e=!!Et.done;Et.done=null,t(),e&&n()},[i,a]=(0,X.useState)(`new`);return(0,Z.jsx)(v,{open:e,onClose:r,title:`Create a toolbox`,subtitle:`Set up a toolbox yourself, server by server.`,width:760,children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(h,{label:`How to add it`,value:i,onChange:a,options:[{value:`new`,label:`Start from nothing`},{value:`existing`,label:`Use a toolbox settings file I have`}]}),i===`new`?(0,Z.jsx)(Ot,{onClose:r}):(0,Z.jsx)(At,{onClose:r})]})})}function Ot({onClose:e}){let{nav:t,reload:n}=K(),r=V(),[a,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(`observe`),[m,g]=(0,X.useState)(`approve-writes`),[_,v]=(0,X.useState)(`approve`),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)([Qe()]),[C,T]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(Et.done),F=/^[a-z0-9][a-z0-9_-]{0,63}$/.test(a)?null:`Use lower-case letters, digits, dashes and underscores, starting with a letter or digit.`,I=x.map((e,t)=>it(e,x.filter((e,n)=>n!==t).map(e=>e.name.trim()))),L=!F&&I.every(e=>!e);return j?(0,Z.jsx)(kt,{result:j,label:Et.label,onClose:e,onOpen:()=>{e(),ue(i(t,`/`,{server:j.id}))}}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Name`,technical:`name`,help:`Also the name of its folder.`,error:k?F:null,children:(0,Z.jsx)(f,{value:a,onChange:s,mono:!0,placeholder:`work-tools`})}),(0,Z.jsx)(o,{label:`Label in the console`,optional:!0,children:(0,Z.jsx)(f,{value:c,onChange:u,placeholder:`Work tools`})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{children:[`How it starts `,(0,Z.jsx)(w,{term:`watchOnly`})]}),(0,Z.jsx)(we,{label:`How it starts`,value:d,onChange:p,options:[{value:`observe`,title:E.observe.label,body:`Recommended to begin with. Every call runs, and the log shows what would have been stopped.`},{value:`enforce`,title:E.enforce.label,body:E.enforce.explain}]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{children:[`Default stance `,(0,Z.jsx)(w,{term:`defaultStance`})]}),(0,Z.jsx)(we,{label:`Default stance`,columns:3,value:m,onChange:g,options:Object.keys(B).map(e=>({value:e,title:B[e].label,body:B[e].explain}))})]}),(0,Z.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:(0,Z.jsxs)(Z.Fragment,{children:[`Tools nobody has labelled yet `,(0,Z.jsx)(w,{term:`unknownTools`})]}),children:(0,Z.jsx)(h,{label:`Tools nobody has labelled yet`,value:_,onChange:v,options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,Z.jsx)(o,{label:`Folder for its files`,optional:!0,help:`A full path. By default, a folder named after it in your home folder.`,children:(0,Z.jsx)(f,{value:y,onChange:b,mono:!0,placeholder:`~/.hmcp/gateways/work-tools`})})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Y,{sub:`The servers this toolbox sits in front of. A toolbox needs at least one.`,children:[`Connected servers `,(0,Z.jsx)(w,{term:`connectedServer`})]}),x.map((e,t)=>(0,Z.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`p`,{className:`text-[14.5px] font-semibold`,children:[`Server `,t+1]}),x.length>1&&(0,Z.jsx)(N,{icon:`trash`,label:`Remove server ${t+1}`,size:34,onClick:()=>S(x.filter((e,n)=>n!==t))})]}),(0,Z.jsx)(Ze,{value:e,onChange:e=>S(x.map((n,r)=>r===t?e:n)),literalWarning:!0}),k&&I[t]&&(0,Z.jsx)(`p`,{role:`alert`,className:`mt-3 text-[13px] font-medium text-bad`,children:I[t]})]},t)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{icon:`plus`,onClick:()=>S([...x,Qe()]),children:`Add another server`})})]}),D&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`The toolbox wasn't created`,children:D}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:e,disabled:C,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>{A(!0),L&&(T(!0),O(null),Re.createGateway({name:a,...c.trim()?{label:c.trim()}:{},mode:d,posture:m,onUnclassified:_,...y.trim()?{outDir:y.trim()}:{},upstreams:x.map(et)}).then(e=>{Et.done=e,Et.label=c.trim()||a,M(e),r.show(`ok`,`${c.trim()||a} was created.`)}).catch(e=>{let t=e.detail;O(W(e)+(Array.isArray(t)?` ${t.map(e=>q(U(e.message))).join(` `)}`:``))}).finally(()=>T(!1)))},loading:C,children:`Create toolbox`})]})]})}function kt({result:e,label:t,onClose:n,onOpen:r}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(b,{icon:`check`,title:`${t} is ready`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,icon:`arrow-right`,onClick:r,children:`Open this toolbox`}),(0,Z.jsx)(P,{variant:`ghost`,onClick:n,children:`Close`})]}),children:`Its protection settings start the way you chose. Connect your AI app to it next: one click, then restart the app once.`}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Connect your AI app`}),(0,Z.jsx)(at,{gatewayId:e.id,onDone:()=>void 0})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Z.jsxs)(`p`,{children:[`Settings file: `,(0,Z.jsx)(J,{children:e.configPath})]}),(0,Z.jsxs)(`p`,{children:[`Protection settings: `,(0,Z.jsx)(J,{children:e.policyPath})]})]}),e.warnings.map(e=>(0,Z.jsxs)(l,{tone:`warn`,children:[q(U(e)),` If one is a password or key, keep that file private.`]},e)),e.warning&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(e.warning))})]})}function At({onClose:e}){let{nav:t,reload:n}=K(),r=V(),[a,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=()=>{p(!0),h(null),_.addServer({kind:`gateway`,label:a.trim()||c.trim(),config_path:c.trim()}).then(o=>{n(),r.show(`ok`,`${a.trim()||`The toolbox`} was added to the console.`),e(),ue(i(t,`/`,{server:o.id}))}).catch(e=>h(W(e))).finally(()=>p(!1))};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`For a toolbox you already set up. The console reads its settings file and nothing else: it doesn't start the toolbox or change the file.`}),(0,Z.jsx)(o,{label:`Label in the console`,children:(0,Z.jsx)(f,{value:a,onChange:s,placeholder:`Work tools`})}),(0,Z.jsx)(o,{label:`Settings file`,technical:`gateway.yaml`,help:`The full path to its settings file.`,children:(0,Z.jsx)(f,{value:c,onChange:u,mono:!0,placeholder:`/Users/me/.hmcp/gateways/work/gateway.yaml`,onEnter:g})}),m&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:m}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:e,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:g,loading:d,disabled:!c.trim(),children:`Add toolbox`})]})]})}function jt(e){return ae(()=>Ue(e),[e],3e3)}function Mt(e){return e?e.externallyRunning?{label:`Run by an AI app`,tone:`ok`}:e.state===`running`?{label:`Running here`,tone:`ok`}:e.state===`starting`?{label:`Starting`,tone:`warn`}:e.state===`exited`?{label:e.exitCode===0?`Stopped`:`Stopped with an error`,tone:e.exitCode===0?`neutral`:`bad`}:{label:`Not running`,tone:`neutral`}:{label:`Checking`,tone:`neutral`}}function Nt({token:e,url:t,onClose:n}){return(0,Z.jsx)(le,{open:!!e,onClose:n,dismissable:!1,title:`Copy the password now`,description:`Copy this now; it won't be shown again. Your AI app needs it to connect.`,width:560,footer:(0,Z.jsx)(P,{variant:`primary`,onClick:n,children:`I've copied it`}),children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:e}),(0,Z.jsx)(Te,{text:e,label:`Copy password`})]}),(0,Z.jsxs)(`p`,{className:`text-muted`,children:[`In your AI app's server settings, add a header named `,(0,Z.jsx)(`code`,{className:`mono`,children:`Authorization`}),` with the value`,` `,(0,Z.jsx)(`code`,{className:`mono`,children:`Bearer`}),`, a space, then this password.`,t&&(0,Z.jsxs)(Z.Fragment,{children:[` `,`The server's address is `,(0,Z.jsx)(J,{children:t})]})]})]})})}function Pt({id:n,label:r}){let i=jt(n),{reload:s}=K(),u=V(),[d,f]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(`127.0.0.1`),[E,O]=(0,X.useState)([]),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)(!0),[N,F]=(0,X.useState)(null),I=(e,t=!1)=>{f(e),v(null),(e===`start`?qe(n,{...S===null?{}:{port:S},host:w,...E.length?{allowHosts:E}:{},...k.length?{allowOrigins:k}:{},requireToken:j,...t?{acknowledged:{loosens:!0}}:{}}).then(e=>e.token&&b({token:e.token,url:e.http?.url??null})):e===`stop`?Ae(n):Ge(n)).then(()=>{u.show(`ok`,e===`start`?`${r} started.`:e===`stop`?`${r} stopped.`:`${r} restarted.`),i.reload(),s()}).catch(n=>{e===`start`&&!t&&n instanceof m&&n.needsLoosenAck?F(Ce(n)):v(W(n))}).finally(()=>f(null))};if(i.error&&!i.data)return(0,Z.jsx)(l,{tone:`danger`,title:`Whether your toolbox is running could not be read`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:W(i.error)});let L=i.data;if(!L)return(0,Z.jsx)(c,{lines:4});let R=Mt(L),z=L.state===`running`||L.state===`starting`;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:`power`,size:20})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-[16px] font-semibold`,children:[r,` `,(0,Z.jsx)(e,{tone:R.tone,children:R.label})]}),(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:L.externallyRunning?`Started by an AI app on this computer.`:z&&L.startedAt?`Started ${x(L.startedAt)} by this console.`:L.state===`exited`?`It stopped${L.exitCode===null?L.signal?` (${L.signal})`:``:` with exit code ${L.exitCode}`}.`:`Nothing is running it at the moment.`})]}),z&&L.managed&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(P,{icon:`refresh`,onClick:()=>I(`restart`),loading:d===`restart`,disabled:!!d,children:`Restart toolbox`}),(0,Z.jsx)(P,{variant:`danger`,icon:`stop`,onClick:()=>I(`stop`),loading:d===`stop`,disabled:!!d,children:`Stop toolbox`})]})]}),_&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:_}),L.externallyRunning?(0,Z.jsx)(l,{tone:`info`,title:`An AI app runs this toolbox`,children:`The app starts the toolbox itself when it opens and stops it when it closes, so it can't be started or stopped here. To restart the toolbox, for example after changing its settings, quit and reopen the app.`}):z&&L.http?(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Y,{sub:`Add this as a server in your AI app's settings. The app then reaches every tool through your toolbox.`,children:`Web address`}),L.http.url&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:L.http.url}),(0,Z.jsx)(Te,{text:L.http.url,label:`Copy address`})]}),(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:L.http.tokenRequired?`A password is required. It was shown once when the toolbox started; restarting keeps the same one.`:`No password is required, so any program on this computer can reach it.`})]}):(0,Z.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{sub:`Runs your toolbox from this console, so AI apps on this computer can reach it at a web address.`,children:`Start toolbox`}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Port`,optional:!0,help:`Leave empty to use 7878.`,children:(0,Z.jsx)(a,{value:S,onChange:C,min:1,max:65535})}),(0,Z.jsx)(o,{label:`Address`,help:`This computer only. Your toolbox is never reachable from other computers.`,children:(0,Z.jsx)(h,{label:`Address`,size:`sm`,value:w,onChange:T,options:[{value:`127.0.0.1`,label:`127.0.0.1`},{value:`localhost`,label:`localhost`},{value:`::1`,label:`::1`}]})})]}),(0,Z.jsx)(p,{checked:j,onChange:M,label:`Require a password`,description:`Your AI app must send it to connect, so other programs on this computer can't use your toolbox's tools.`}),(0,Z.jsxs)(ye,{title:`More options`,children:[(0,Z.jsx)(o,{label:`Other names this computer is reached by`,optional:!0,help:`Only if your app uses a name other than the address above.`,children:(0,Z.jsx)(t,{value:E,onChange:O,placeholder:`my-machine.local`})}),(0,Z.jsx)(o,{label:`Web pages allowed to call it`,optional:!0,help:`Only for an AI app that runs in a browser. Scheme, host and port, such as http://localhost:3000.`,children:(0,Z.jsx)(t,{value:k,onChange:A,placeholder:`http://localhost:3000`})})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{variant:`primary`,icon:`play`,onClick:()=>I(`start`),loading:d===`start`,children:`Start toolbox`})})]}),(L.managed||L.log.length>0)&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`What it has written`}),(0,Z.jsx)(ne,{lines:L.log,height:260,label:`${r} output`,empty:`Nothing yet.`})]}),(0,Z.jsx)(Nt,{token:y?.token??null,url:y?.url??null,onClose:()=>b(null)}),(0,Z.jsx)(D,{open:!!N,title:`Start a toolbox more can reach?`,onCancel:()=>F(null),confirmLabel:`Start toolbox anyway`,busy:d===`start`,consequences:N??[],onConfirm:()=>{F(null),I(`start`,!0)},children:`Besides AI apps on this computer, your toolbox will also answer the callers listed below.`})]})}function Ft({id:e,tab:t,onTab:n,onClose:r,replaceKeyFor:i,onOpened:a}){let{servers:o}=K(),s=o.find(t=>t.id===e);return(0,Z.jsx)(v,{open:!!e,onClose:r,title:s?`${s.label} settings`:`Toolbox settings`,subtitle:`Its connected servers, options, and whether it is running.`,width:820,children:e&&(0,Z.jsx)(It,{id:e,label:s?.label??e,tab:t,onTab:n,replaceKeyFor:i??null,onOpened:a},e)})}function It({id:e,label:t,tab:n,onTab:r,replaceKeyFor:i,onOpened:a}){let o=ae(()=>ze(e),[e]),s=jt(e),u=V(),{reload:f}=K(),p=Ee(e),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(!1),[E,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),j=o.data,M=!!j?.broken,N=M&&(n===`servers`||n===`options`)?`file`:n,F=(e,t,n=`Save a change that lets more through?`,r)=>{if(!j)return Promise.resolve(!1);let i=e=>{u.show(`ok`,t),g(Date.now()),v(e.restartNeeded!==!1),o.reload(),p.reload(),f()};return e(j.digest).then(e=>(i(e),!0)).catch(t=>t instanceof m&&t.needsLoosenAck?new Promise(a=>{O(null),C({title:n,body:r,reasons:Ce(t),run:()=>e(j.digest,{loosens:!0}).then(e=>{i(e),a(!0)})})}):(Se(t)?b(!0):u.show(`bad`,W(t)),!1))},I=s.data,L=!!I&&(I.externallyRunning||I.state===`running`||I.state===`starting`),R=p.data,z=!!R?.processes.some(e=>e.refusal),ee=L&&(R&&R.running?z||!R.applied&&(h===null||Date.now()-h>6e3):_||j&&!j.broken&&j.restartNeededFor.length>0),te=M?[{id:`file`,label:`Settings file`},{id:`run`,label:`Run`}]:[{id:`servers`,label:`Connected servers`,count:j?.config?.upstreams.length},{id:`options`,label:`Toolbox options`},{id:`run`,label:`Run`},{id:`file`,label:`Settings file`}];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[ee&&(0,Z.jsxs)(l,{tone:`warn`,role:`status`,title:`Restart needed for changes to take effect`,actions:I?.managed&&!I.externallyRunning?(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`refresh`,loading:k,onClick:()=>{A(!0),Ge(e).then(()=>{u.show(`ok`,`${t} restarted with the new settings.`),g(null),s.reload(),o.reload()}).catch(e=>u.show(`bad`,W(e))).finally(()=>A(!1))},children:`Restart toolbox`}):void 0,children:[z&&j&&j.restartNeededFor.length>0?`${j.restartNeededFor[0]}`:z?`The running toolbox can only take this change when it starts again. `:`The running toolbox hasn't picked up this change. `,z&&j&&j.restartNeededFor.length>0?``:I?.externallyRunning?`An AI app runs it: quit that app completely and open it again.`:`It still uses the old settings until it restarts.`]}),y&&(0,Z.jsx)(l,{tone:`warn`,title:`This changed since you opened it. Reload and try again.`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>{b(!1),o.reload()},children:`Reload settings`})}),j?.broken&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`This toolbox's settings file can't be loaded`,children:j.broken}),(0,Z.jsx)(ie,{items:te,value:N,onChange:r,label:`Toolbox settings`}),(0,Z.jsx)(`div`,{role:`tabpanel`,id:S(N),"aria-labelledby":d(N),children:N===`run`?(0,Z.jsx)(Pt,{id:e,label:t}):o.error&&!j?(0,Z.jsx)(l,{tone:`danger`,title:`The toolbox's settings file could not be read`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):j?N===`file`?(0,Z.jsx)(Ht,{id:e,file:j,write:F}):j.broken===null&&N===`servers`?(0,Z.jsx)(Lt,{id:e,file:j,write:F,live:R??null,running:L,onReload:()=>{g(Date.now()),o.reload(),p.reload(),f()},start:i?{kind:`replace-key`,server:i}:void 0,onStarted:a}):j.broken===null?(0,Z.jsx)(Bt,{id:e,file:j,write:F},j.digest):null:(0,Z.jsx)(c,{lines:6})}),(0,Z.jsx)(D,{open:!!x,title:x?.title??``,onCancel:()=>C(null),confirmLabel:`Save anyway`,busy:w,error:E,consequences:x?.reasons,onConfirm:()=>{x&&(T(!0),x.run().then(()=>C(null)).catch(e=>O(W(e))).finally(()=>T(!1)))},children:x?.body??`This change lets more through than before, so it needs your confirmation.`})]})}function Lt({id:t,file:n,write:r,live:a,running:o,onReload:s,start:c,onStarted:l}){let u=n.config.upstreams,{nav:d}=K(),f=V(),p=Ye(),[m,h]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(()=>{if(c?.kind===`by-hand`)return{original:null,draft:Qe()};let e=c?u.find(e=>e.name===c.server):void 0;return e&&c?.kind===`replace-key`&&he(e)?null:e?{original:e.name,draft:nt(e)}:null}),[x,S]=(0,X.useState)(()=>{let e=c?.kind===`replace-key`?u.find(e=>e.name===c.server):void 0;return e?he(e):null});(0,X.useEffect)(()=>{c&&l?.()},[]);let[C,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(null),A=Je(t);if(y){let e=u.map(e=>e.name).filter(e=>e!==y.original),i=it(y.draft,e);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{sub:y.original?`Values shown as kept secret stay as they are unless you type a new one.`:void 0,children:y.original?`Edit ${y.original}`:`Add a server`}),(0,Z.jsx)(Ze,{value:y.draft,onChange:e=>b({...y,draft:e}),nameLocked:!!y.original,secret:n.keptSecret,literalWarning:!0}),C&&i&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:()=>b(null),disabled:E,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`check`,onClick:()=>{T(!0),!i&&(D(!0),zt(et(y.draft),n.keptSecret).then(e=>r((n,r)=>y.original?Me(t,y.original,e,n,r):Ke(t,e,n,r),y.original?`${e.name} was saved.`:`${e.name} was added.`,`Save this server?`)).then(e=>e&&b(null)).catch(e=>f.show(`bad`,W(e))).finally(()=>D(!1)))},loading:E,children:y.original?`Save server`:`Add server`})]})]})}if(_)return(0,Z.jsx)(rt,{gatewayId:t,fixUpstream:_,onCancel:()=>{$e(),v(null)},onDone:e=>{$e(),v(null),f.show(`ok`,`${e.upstreamName} was saved.`),s()}});if(m)return(0,Z.jsx)(rt,{gatewayId:t,onCancel:()=>{$e(),h(!1)},onDone:e=>{h(!1),f.show(`ok`,`${e.upstreamName} was added.`),s()}});let j=u.length===1;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`The servers this toolbox sits in front of. `,(0,Z.jsx)(w,{term:`connectedServer`})]}),(0,Z.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:null,draft:Qe()})},children:`Add one by hand`}),(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`plus`,onClick:()=>h(!0),children:`Add a server`})]})]}),(0,Z.jsx)(ke,{id:t,upstreams:u,digest:n.digest,onMoved:s}),(0,Z.jsx)(je,{secret:x,onClose:()=>S(null),onSaved:()=>{S(null),f.show(`ok`,`The new key is saved. The server is tried again with it.`),s()}}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map(n=>{let r=Pe(a,n.name),c=(A.data??[]).find(e=>e.server===n.name),l=r&&r.state===`connected`&&c?{...r,state:`failed`,problem:_e(n,c)}:r,u=o&&!!a?.running&&!!l&&(l.state===`failed`||l.state===`needs-sign-in`),f=!u&&Ne(n,p.data??null);return(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 rounded-[18px] border border-line p-3.5`,children:[(0,Z.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:n.transport===`http`?`external`:`server`,size:18})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`mono text-[14px] font-semibold`,children:n.name}),(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:n.transport===`http`?`Remote server · ${n.url}`:`Runs on this computer · ${[n.command,...n.args??[]].join(` `)}`}),(0,Z.jsx)(`span`,{className:`mt-1 block`,role:`status`,children:(0,Z.jsx)(Ve,{live:a,running:o,state:l})})]}),n.on_injection&&(0,Z.jsx)(e,{children:Fe[n.on_injection].label}),(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:n.name,draft:nt(n)})},children:`Edit`}),(0,Z.jsx)(N,{icon:`trash`,label:j?`${n.name} is the only server and can't be removed`:`Remove ${n.name}`,size:36,disabled:j,onClick:()=>k(n.name)})]}),u&&l&&(0,Z.jsx)(Le,{gatewayId:t,upstream:n,state:l,onEdit:e=>{if(e===`choose-folder`||e===`replace-key`||e===`sign-in`){let t=l.problem?.detail?.path;v({upstream:n,action:e,...t?{path:t}:{}})}else T(!1),b({original:n.name,draft:nt(n)})},onFixed:s,onAllowAddress:()=>ue(i(d,`/protection`,{server:t}))}),f&&(0,Z.jsx)(Le,{gatewayId:t,upstream:n,state:{name:n.name,state:`needs-sign-in`,since:``,attempts:0,tool_count:0},onEdit:e=>e===`sign-in`?v({upstream:n,action:e}):b({original:n.name,draft:nt(n)}),onFixed:s,onAllowAddress:()=>void 0})]},n.name)})}),j&&(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:`A toolbox needs at least one server, so the last one can't be removed. Add another first, or remove the whole toolbox from the console.`}),(0,Z.jsx)(le,{open:!!O,onClose:()=>k(null),tone:`danger`,title:`Remove ${O}?`,description:Rt(u.find(e=>e.name===O)),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,onClick:()=>k(null),disabled:E,children:`Keep server`}),(0,Z.jsx)(P,{variant:`danger`,loading:E,onClick:()=>{let e=O;D(!0),r(n=>Be(t,e,n),`${e} was removed.`).then(()=>k(null)).finally(()=>D(!1))},children:`Remove server`})]})})]})}function Rt(e){let t=[...Object.values(e?.env??{}),...Object.values(e?.headers??{}),e?.oauth].map(e=>e&&typeof e==`object`&&typeof e.secret==`string`?e.secret:null).filter(e=>e!==null),n=[...new Set(t)];return`Your AI app loses this server's tools, and the protection rules made for them are removed too.`+(n.length>0?` Its locked ${n.length===1?`key`:`keys`} (${n.join(`, `)}) ${n.length===1?`stays`:`stay`} saved; remove ${n.length===1?`it`:`them`} under Settings & help, Locked keys, if you no longer need ${n.length===1?`it`:`them`}.`:``)}async function zt(e,t){let r=async r=>{if(!r)return r;let i={};for(let[a,o]of Object.entries(r))if(typeof o==`string`&&o!==``&&o!==t&&!/\$\{[^}]*\}/.test(o)&&pe(a)){let t=/^(Bearer|Basic|Token) /i.exec(o)?.[0],r=t?o.slice(t.length):o,s=await n.createSecret({label:`${e.name} ${a}`,value:r});i[a]=t?{secret:s.name,prefix:t}:{secret:s.name}}else i[a]=o;return i},i=await r(e.env),a=await r(e.headers);return{...e,...i?{env:i}:{},...a?{headers:a}:{}}}function $({title:e,help:t,technical:n,children:r,onSave:i,dirty:a,busy:o,onReset:s}){return(0,Z.jsxs)(`div`,{className:`grid gap-3 border-b border-faint py-5 first:pt-0 last:border-b-0 md:grid-cols-[1fr_minmax(0,300px)]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-[14.5px] font-semibold`,children:[e,` `,(0,Z.jsx)(`code`,{className:`mono text-[11.5px] font-normal text-soft`,children:n})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-[13px] text-soft`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[r,(i||s)&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[s&&(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:s,disabled:o,children:`Use the default`}),i&&(0,Z.jsx)(P,{size:`sm`,variant:`primary`,onClick:i,disabled:!a,loading:o,children:`Save setting`})]})]})]})}function Bt({id:e,file:t,write:n}){let r=t.config,i=(t.text??``).match(/^(\w+):/gm)?.map(e=>e.slice(0,-1))??[],[o,s]=(0,X.useState)(null),c=(t,r,i,a)=>(s(t),n((n,i)=>Ie(e,t,r,n,i),i,a).finally(()=>s(null))),[l,u]=(0,X.useState)(r.name),[d,m]=(0,X.useState)(r.connect_timeout_ms/1e3),[h,_]=(0,X.useState)(r.on_injection),[v,y]=(0,X.useState)(Object.entries(r.injection_overrides)),[b,x]=(0,X.useState)(r.max_tool_name_length??null),S=r.notify===void 0?`auto`:r.notify?`on`:`off`,C=Object.fromEntries(v.filter(([e])=>e.trim()).map(([e,t])=>[e.trim(),t]));return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)($,{title:`Name`,technical:`name`,help:(0,Z.jsx)(Z.Fragment,{children:`Shown in the activity log and to your AI app. Renaming moves the toolbox to a new identity: tools you turned off, pre-approvals and reviewed tool changes are stored under the old name and stop applying, so it counts as loosening.`}),dirty:l.trim()!==r.name&&!!l.trim(),busy:o===`name`,onSave:()=>c(`name`,l.trim(),`The toolbox was renamed.`,`Rename this toolbox?`),children:(0,Z.jsx)(f,{value:l,onChange:u,mono:!0,"aria-label":`Toolbox name`})}),(0,Z.jsx)($,{title:`Time to wait for each server to start`,technical:`connect_timeout_ms`,help:`Your toolbox connects every server before serving any tool. A slow server gets this long before the toolbox gives up and says which one failed.`,dirty:d!==null&&d*1e3!==r.connect_timeout_ms,busy:o===`connect_timeout_ms`,onSave:()=>c(`connect_timeout_ms`,Math.round(d*1e3),`The start-up wait was saved.`),onReset:i.includes(`connect_timeout_ms`)?()=>c(`connect_timeout_ms`,null,`The start-up wait is back to 20 seconds.`):void 0,children:(0,Z.jsx)(a,{value:d,onChange:m,min:1,unit:`seconds`,"aria-label":`Seconds to wait`})}),(0,Z.jsx)($,{title:(0,Z.jsxs)(Z.Fragment,{children:[`Hidden instructions in tool descriptions `,(0,Z.jsx)(w,{term:`HMCP005`})]}),technical:`on_injection`,help:Fe[h].explain+` Each server can have its own setting too.`,dirty:h!==r.on_injection,busy:o===`on_injection`,onSave:()=>c(`on_injection`,h,`Hidden-instruction handling was saved.`,`Handle hidden instructions less strictly?`),children:(0,Z.jsx)(I,{value:h,onChange:_,"aria-label":`Hidden instructions`,options:[`strip`,`deny`,`annotate`].map(e=>({value:e,label:Fe[e].label}))})}),(0,Z.jsx)($,{title:`Descriptions you checked`,technical:`injection_overrides`,help:`For a tool whose description was flagged by mistake. Name the tool as your AI app sees it, such as files__read_file.`,dirty:JSON.stringify(C)!==JSON.stringify(r.injection_overrides),busy:o===`injection_overrides`,onSave:()=>c(`injection_overrides`,C,`Checked descriptions were saved.`,`Trust these descriptions?`),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v.map(([e,t],n)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(f,{value:e,onChange:e=>y(v.map((t,r)=>r===n?[e,t[1]]:t)),mono:!0,"aria-label":`Tool ${n+1}`,placeholder:`files__read_file`}),(0,Z.jsx)(N,{icon:`trash`,label:`Remove ${e||`row ${n+1}`}`,size:34,onClick:()=>y(v.filter((e,t)=>t!==n))})]},n)).flatMap((e,t)=>[e,(0,Z.jsx)(I,{value:v[t][1],onChange:e=>y(v.map((n,r)=>r===t?[n[0],e]:n)),"aria-label":`How to treat tool ${t+1}`,options:[`accept`,`annotate`,`strip`,`deny`].map(e=>({value:e,label:Fe[e].label}))},`m${t}`)]),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`plus`,onClick:()=>y([...v,[``,`accept`]]),children:`Add a tool`})})]})}),(0,Z.jsx)($,{title:`Put the server's name in front of each tool`,technical:`namespace`,help:`Tools are shown as server__tool, so two servers can't offer look-alike tools. Turning it off renames every tool, so rules and switches naming them stop applying.`,children:(0,Z.jsx)(p,{checked:r.namespace,disabled:o===`namespace`,onChange:e=>c(`namespace`,e,e?`Tool names now include the server.`:`Tool names no longer include the server.`,`Rename every tool?`),label:r.namespace?`On`:`Off`})}),(0,Z.jsx)($,{title:`Apply protection changes without a restart`,technical:`policy_reload`,help:`When the protection settings file changes, the running toolbox picks it up straight away. A file with a mistake is ignored and the old settings stay in force.`,children:(0,Z.jsx)(p,{checked:r.policy_reload,disabled:o===`policy_reload`,onChange:e=>c(`policy_reload`,e,e?`Protection changes now apply straight away.`:`Protection changes now wait for a restart.`),label:r.policy_reload?`On`:`Off`})}),(0,Z.jsx)($,{title:`Longest tool name`,technical:`max_tool_name_length`,help:`AI services refuse a request if any tool name is too long, which breaks every tool at once. A tool with a longer name is held back instead. Empty means no limit.`,dirty:(b??void 0)!==r.max_tool_name_length,busy:o===`max_tool_name_length`,onSave:()=>c(`max_tool_name_length`,b,b?`The name limit was saved.`:`The name limit was removed.`),children:(0,Z.jsx)(a,{value:b,onChange:x,min:1,unit:`letters`,"aria-label":`Longest tool name`})}),(0,Z.jsx)($,{title:`Desktop notifications`,technical:`notify`,help:`Show a notification on this computer when a call waits for you. Automatic means on when an app runs the toolbox on this computer, off when it serves over a web address.`,children:(0,Z.jsx)(I,{value:S,"aria-label":`Desktop notifications`,onChange:e=>c(`notify`,e===`auto`?null:e===`on`,`Notification setting saved.`),options:[{value:`auto`,label:`Automatic`},{value:`on`,label:`On`},{value:`off`,label:`Off`}]})}),(0,Z.jsxs)(`div`,{className:`mt-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[14.5px] font-semibold`,children:[(0,Z.jsx)(g,{name:`lock`,size:17}),` Settings the console can't change`]}),(0,Z.jsx)(`p`,{className:`mt-1 text-[13px] text-soft`,children:`These decide what the console itself may do. If the console could change them, it could give itself permission, so they can only be changed by editing the file outside the console.`}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-[13.5px] sm:grid-cols-2`,children:[(0,Z.jsx)(Vt,{term:`Console may change protection rules`,technical:`policy_writes`,on:t.guarded.policy_writes}),(0,Z.jsx)(Vt,{term:`Console may reverse an existing decision`,technical:`policy_overrides`,on:t.guarded.policy_overrides})]})]})]})}function Vt({term:t,technical:n,on:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-2xl bg-surface px-3 py-2.5`,children:[(0,Z.jsxs)(`dt`,{children:[t,(0,Z.jsx)(`code`,{className:`mono block text-[11.5px] text-soft`,children:n})]}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(e,{tone:r?`ok`:`neutral`,children:r?`Allowed`:`Not allowed`})})]})}function Ht({id:e,file:t,write:n}){let[i,a]=(0,X.useState)(t.text??``),[o,s]=(0,X.useState)(null),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null);if((0,X.useEffect)(()=>{a(t.text??``),s(null)},[t.digest]),t.text===null)return(0,Z.jsxs)(b,{icon:`file`,title:`This file has to be fixed in a text editor`,children:[`It isn't readable as a settings file at all, so the console can't show it. Open it in a text editor, fix it, then reopen these settings.`,(0,Z.jsx)(`span`,{className:`mt-2 block`,children:(0,Z.jsx)(J,{children:t.path})})]});let h=()=>{u(!0),m(null),De(e,i).then(s).catch(e=>m(W(e))).finally(()=>u(!1))},g=()=>{f(!0),n((t,n)=>Oe(e,i,t,n),t.broken?`The settings file was repaired.`:`The settings file was saved.`,t.broken?`Save the repaired settings file?`:`Save the edited settings file?`,t.broken?`This file couldn't be loaded, so the console can't compare what your fix changes. Check it carefully before saving.`:void 0).finally(()=>f(!1))},_=i!==t.text,v=o&&_;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`The toolbox's whole settings file, for changes the forms don't cover. Keys in your locked keys appear only by name. A key still written out in the file shows as `,(0,Z.jsx)(`code`,{className:`mono`,children:`[kept secret]`}),`; leave that marker and the stored value is kept. The protection-settings entry and the two settings the console can't change are refused here.`,(0,Z.jsx)(`span`,{className:`mt-1 block`,children:(0,Z.jsx)(J,{children:t.path})})]}),(0,Z.jsx)(ee,{value:i,onChange:e=>{a(e),s(null)},label:`Settings file`,rows:18,error:o&&!o.valid?o.error:null}),p&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:p}),v&&o.valid&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{children:`What changes`}),(0,Z.jsx)(j,{before:t.text??``,after:i,label:`Changes to the settings file`}),t.broken?(0,Z.jsx)(l,{tone:`warn`,title:`Saving needs your confirmation`,children:`This file couldn't be loaded, so the console can't compare what your fix changes.`}):o.loosens.length>0&&(0,Z.jsx)(l,{tone:`warn`,title:`This lets more through`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:o.loosens.map(e=>(0,Z.jsx)(`li`,{children:e},e))})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:()=>{a(t.text??``),s(null)},disabled:!_,children:`Undo my edits`}),v&&o.valid?(0,Z.jsx)(P,{variant:`primary`,icon:`check`,onClick:g,loading:d,children:t.broken?`Save repaired file`:`Save settings file`}):(0,Z.jsx)(P,{variant:`primary`,onClick:h,loading:c,disabled:!_,children:`Check changes`})]}),(0,Z.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[`Changes to servers reach a running toolbox straight away; anything else applies the next time it starts. `,r(i.split(`
2
- `).length,`line`),`.`]})]})}var Ut={ok:`bg-ok`,warn:`bg-warn`,bad:`bg-bad`,neutral:`bg-soft`};function Wt(){let{nav:e,servers:t,serverId:n,reload:r}=K(),i=V(),a=e.query,o=(...t)=>ce(s(e,Object.fromEntries(t.map(e=>[e,null])))),c=a.get(`manage`),l=a.get(`tab`)??`servers`,u=t.filter(e=>e.ok),d=u.filter(e=>e.running).length,f=u.filter(e=>e.enforcement===`enforce`).length,p=u.reduce((e,t)=>e+(t.upstreams?.length??0),0),m=u.reduce((e,t)=>e+(t.toolCount??0),0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(k,{title:`Connections`,subtitle:`The toolboxes that protect your AI apps, and the apps and servers they connect.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{href:s(e,{add:`server`}),variant:`primary`,icon:`plus`,children:`Add a server`}),(0,Z.jsx)(T,{href:s(e,{connect:`1`}),icon:`plug`,children:`Connect an app`}),(0,Z.jsx)(T,{href:s(e,{add:`1`}),variant:`ghost`,icon:`shield`,children:`Create a toolbox`})]})}),t.length===0?(0,Z.jsx)(qt,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 lg:gap-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4 lg:gap-5`,children:[(0,Z.jsx)(te,{tone:`hero`,title:`Toolboxes`,value:u.length,sub:u.length?`${f} protecting · ${u.length-f} watch-only`:`None can be loaded`}),(0,Z.jsx)(te,{title:`Running now`,value:d,sub:d===u.length?`All of them`:`${u.length-d} not running`}),(0,Z.jsx)(te,{title:`Connected servers`,value:p,sub:`The servers your toolboxes hold`}),(0,Z.jsx)(te,{title:`Tools`,value:de(m),sub:`Offered to your AI apps`})]}),(0,Z.jsxs)(`section`,{"aria-labelledby":`gateways-h`,children:[(0,Z.jsx)(`h2`,{id:`gateways-h`,className:`sr-only`,children:`Toolboxes`}),(0,Z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 2xl:grid-cols-3 lg:gap-5`,children:t.map(e=>e.ok?(0,Z.jsx)(Jt,{server:e},e.id):(0,Z.jsx)(Yt,{server:e},e.id))})]}),(0,Z.jsx)(Qt,{servers:t})]}),(0,Z.jsx)(lt,{open:a.get(`connect`)===`1`,onClose:()=>o(`connect`)}),(0,Z.jsx)(Dt,{open:a.get(`add`)===`1`,onClose:()=>o(`add`)}),(0,Z.jsx)(Kt,{open:a.get(`add`)===`server`,gatewayId:Gt(a.get(`gateway`),n,u),onClose:()=>o(`add`,`gateway`),onDone:(e,t)=>{o(`add`,`gateway`),i.show(`ok`,t?`${e} was added, and your toolbox was set up.`:`${e} was added.`),r()}}),(0,Z.jsx)(Ft,{id:c&&t.some(e=>e.id===c)?c:null,tab:l,onTab:t=>ce(s(e,{tab:t})),onClose:()=>o(`manage`,`tab`,`key`),replaceKeyFor:a.get(`key`),onOpened:()=>o(`key`)})]})}function Gt(e,t,n){return e&&n.some(t=>t.id===e)?e:t&&n.some(e=>e.id===t)?t:n[0]?.id??null}function Kt({open:e,gatewayId:t,onClose:n,onDone:r}){let{servers:i}=K(),a=i.find(e=>e.id===t)?.label;return(0,Z.jsx)(v,{open:e,onClose:()=>{$e(),n()},title:`Add a server`,subtitle:a?`It joins ${a}. You test it before anything is saved.`:`You test it before anything is saved.`,width:920,children:e&&(0,Z.jsx)(rt,{gatewayId:t,onCancel:n,onDone:e=>r(e.upstreamName,e.created)})})}function qt(){let{nav:e}=K();return(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.2fr_1fr] lg:gap-5`,children:[(0,Z.jsxs)(re,{tone:`hero`,className:`flex flex-col p-7 md:p-8`,children:[(0,Z.jsx)(`span`,{className:`grid h-12 w-12 place-items-center rounded-full bg-white/15`,children:(0,Z.jsx)(g,{name:`shield-check`,size:24})}),(0,Z.jsx)(`h2`,{className:`display mt-5 text-[30px] md:text-[36px]`,children:`Give your AI app its first tools`}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-lg text-[15px] text-on-hero-soft`,children:`Your toolbox sits between your AI app and the servers that give it tools, and decides what runs, what waits for you, and what is blocked. The getting-started guide walks you through it in a few minutes.`}),(0,Z.jsxs)(`div`,{className:`mt-7 flex flex-wrap gap-2.5`,children:[(0,Z.jsx)(T,{href:`/start`,variant:`on-hero`,icon:`arrow-right`,children:`Start the guide`}),(0,Z.jsx)(T,{href:s(e,{add:`server`}),variant:`on-hero`,icon:`plus`,className:`!bg-transparent !text-white ring-1 ring-white/50`,children:`Add a server`})]}),(0,Z.jsxs)(`p`,{className:`mt-4 text-[13px] text-on-hero-soft`,children:[`Already use servers in an app?`,` `,(0,Z.jsx)(`a`,{href:s(e,{connect:`1`}),onClick:y,className:`font-semibold text-white underline underline-offset-2`,children:`Connect that app`}),` `,`and they move behind your toolbox.`]})]}),(0,Z.jsx)(re,{title:`How it works`,children:(0,Z.jsx)(`ol`,{className:`flex flex-col gap-4`,children:[[`Add a server`,`Pick one from the list, such as Files on this computer or GitHub. You're walked through it, and you test it before anything is saved.`],[`Connect your AI app`,`One click adds your toolbox to Claude Desktop, Claude Code, Cursor, VS Code or Windsurf. Restart the app once.`],[`Decide what needs you`,`Tools that only look run freely. Changes wait for you to say yes, and you can adjust that any time.`]].map(([e,t],n)=>(0,Z.jsxs)(`li`,{className:`flex gap-3.5`,children:[(0,Z.jsx)(`span`,{className:`tnum grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-[14px] font-bold text-ok`,children:n+1}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-[15px] font-medium`,children:e}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:t})]})]},e))})})]})}function Jt({server:t}){let{nav:n,reload:r}=K(),a=V(),o=ae(()=>Ue(t.id),[t.id],15e3),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=o.data,m=p?Mt(p):t.running?{label:`Running`,tone:`ok`}:{label:`Not running`,tone:`neutral`},h=E[t.enforcement??`enforce`],_=t.upstreams??[],v=!!p?.managed&&(p.state===`running`||p.state===`starting`),b=e=>s(n,{manage:t.id,tab:e}),x=Ee(t.id),S=Je(t.id),C=be(x.data?.upstreams??[],!!x.data?.running,S.data??[]);return(0,Z.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-5 p-6`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:`shield`,size:20})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label})}),(0,Z.jsx)(N,{icon:`trash`,label:`Remove ${t.label} from the console`,size:36,onClick:()=>f(!0)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(e,{tone:m.tone,icon:`power`,children:m.label}),(0,Z.jsx)(e,{tone:h.tone,icon:t.enforcement===`observe`?`eye`:`shield-check`,title:h.explain,children:h.label}),t.posture&&t.posture in B&&(0,Z.jsx)(e,{children:B[t.posture].label})]}),(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Z.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`Tools`}),(0,Z.jsx)(`dd`,{className:`display tnum text-[28px]`,children:t.toolCount??`–`})]}),(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Z.jsxs)(`dt`,{className:`text-[12.5px] text-soft`,children:[`Connected servers `,(0,Z.jsx)(w,{term:`connectedServer`})]}),(0,Z.jsx)(`dd`,{className:`display tnum text-[28px]`,children:_.length})]})]}),_.length>0&&(0,Z.jsx)(`ul`,{className:`-mt-2 flex flex-wrap gap-1.5`,"aria-label":`Its servers`,children:_.map(e=>{let t=x.data?.running?Pe(x.data,e):null,n=t?.state===`connected`&&(S.data??[]).some(t=>t.server===e),r=n?`bad`:t?ve[t.state].tone:null;return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-full bg-sunken px-2.5 py-0.5 text-[12px]`,children:[r&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:H(`h-2 w-2 rounded-full`,Ut[r])}),(0,Z.jsx)(`code`,{className:`mono`,children:e}),n?(0,Z.jsx)(`span`,{className:`text-muted`,children:`· calls failing`}):t&&t.state!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`· `,ve[t.state].label.toLowerCase()]}),t&&!n&&(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`: `,ve[t.state].label]})]},e)})}),C&&(0,Z.jsxs)(`p`,{className:H(`-mt-2 flex flex-wrap items-center gap-x-2 text-[13px] font-medium`,C.tone===`bad`?`text-bad`:C.tone===`warn`?`text-warn`:`text-ok`),children:[C.text,C.fix&&(0,Z.jsxs)(`a`,{href:b(`servers`),onClick:y,className:`underline underline-offset-2`,children:[`Fix `,C.fix]})]}),t.toolCount===null&&(0,Z.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:`Tools are counted once the toolbox has run.`}),t.tenantError&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(t.tenantError))}),p?.externallyRunning&&(0,Z.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:`An AI app runs this toolbox. Restarting the app restarts it.`}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Z.jsx)(T,{href:i(n,`/`,{server:t.id}),variant:`primary`,size:`sm`,iconRight:`arrow-right`,children:`Open`}),(0,Z.jsx)(T,{href:b(`servers`),size:`sm`,icon:`settings`,children:`Settings`}),v?(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`stop`,loading:c,onClick:()=>{u(!0),Ae(t.id).then(()=>{a.show(`ok`,`${t.label} stopped.`),o.reload(),r()}).catch(e=>a.show(`bad`,W(e))).finally(()=>u(!1))},children:`Stop toolbox`}):!p?.externallyRunning&&(0,Z.jsx)(T,{href:b(`run`),size:`sm`,variant:`ghost`,icon:`play`,children:`Start toolbox`})]}),(0,Z.jsx)(Xt,{server:d?t:null,onClose:()=>f(!1)})]})}function Yt({server:t}){let{nav:n}=K(),[r,i]=(0,X.useState)(!1);return(0,Z.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-4 border-[1.5px] border-bad/40 p-6`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-bad-tint text-bad`,children:(0,Z.jsx)(g,{name:`warning`,size:20})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label})}),(0,Z.jsx)(e,{tone:`bad`,children:`Can't be loaded`})]}),(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`The console couldn't read this toolbox, so it can't show or protect anything for it.`}),(0,Z.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13px] break-words text-muted`,children:q(U(t.error??`No reason was given.`))}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Z.jsx)(T,{href:s(n,{manage:t.id,tab:`file`}),size:`sm`,variant:`primary`,icon:`edit`,children:`Fix toolbox settings file`}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`trash`,onClick:()=>i(!0),children:`Remove from console`})]}),(0,Z.jsx)(Xt,{server:r?t:null,onClose:()=>i(!1)})]})}function Xt({server:e,onClose:t}){let{reload:n}=K(),r=V(),[i,a]=(0,X.useState)(!1);return e?(0,Z.jsx)(le,{open:!0,onClose:t,tone:`danger`,dismissable:!i,title:`Remove ${e.label} from the console?`,description:`The console stops showing it. Nothing is deleted.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,onClick:t,disabled:i,children:`Keep it`}),(0,Z.jsx)(P,{variant:`danger`,loading:i,onClick:()=>{a(!0),_.removeServer(e.id).then(()=>{r.show(`ok`,`${e.label} was removed from the console.`),t(),n()}).catch(e=>r.show(`bad`,W(e))).finally(()=>a(!1))},children:`Remove from console`})]}),children:(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[14px] text-muted`,children:[(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`Its files on this computer are kept: the toolbox's settings file, its protection settings, waiting calls and the activity log.`]}),(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`power`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`If this console was running it, it is stopped. If an AI app runs it, it keeps running and keeps protecting that app.`]}),(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`plus`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`You can add it back later with Create a toolbox, using its settings file.`]})]})}):null}var Zt={"connect.apply":`App connected`,"connect.revert":`Connection undone`,"connect.create":`Toolbox created`,"gateway.setting":`Toolbox option changed`,"gateway.upstream.add":`Server added`,"gateway.upstream.update":`Server changed`,"gateway.upstream.remove":`Server removed`,"gateway.file":`Toolbox settings file edited`,"gateway.process.start":`Toolbox started`,"gateway.process.stop":`Toolbox stopped`,"policy.reload":`Protection settings reloaded`,"exposure.disable":`Tool turned off`,"exposure.enable":`Tool turned back on`,"approval.decide":`Call answered`,"standing_grant.create":`Pre-approval given`,"standing_grant.revoke":`Pre-approval withdrawn`};function Qt({servers:e}){let{nav:t}=K(),[n,r]=(0,X.useState)(`noteworthy`),a=e.filter(e=>e.ok).map(e=>e.id).join(`,`),o=ae(()=>a?_.combinedAudit({servers:a,limit:`12`,...n===`noteworthy`?{noteworthy:`1`}:{}}):Promise.resolve(null),[a,n],3e4),s=t=>e.find(e=>e.id===t)?.label??t??`A toolbox`,u=o.data;return(0,Z.jsx)(re,{title:`Recent activity across toolboxes`,actions:(0,Z.jsx)(h,{label:`Which activity`,size:`sm`,value:n,onChange:r,options:[{value:`noteworthy`,label:`Needs a look`},{value:`all`,label:`All`}]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u?.sharedPaths.map(e=>(0,Z.jsx)(l,{tone:`info`,title:`${e.servers.map(s).join(` and `)} share one activity log`,children:`That's how they were set up, and it's safe: the tamper check covers them together. Give each toolbox its own log only if you want to check them apart.`},e.path)),u?.broken.map(e=>(0,Z.jsxs)(l,{tone:`info`,children:[s(e.id),`'s activity couldn't be read: `,q(U(e.error))]},e.id)),o.error&&!u?(0,Z.jsx)(l,{tone:`danger`,title:`Activity could not be loaded`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):o.loading&&!u?(0,Z.jsx)(c,{lines:5,height:18}):!u||u.records.length===0?(0,Z.jsx)(b,{icon:`activity`,title:n===`noteworthy`?`Nothing needs a look`:`No activity yet`,compact:!0,children:n===`noteworthy`?`No blocked, held or failed calls lately.`:`Calls appear here once an AI app uses a toolbox's tools.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col`,children:u.records.map(e=>(0,Z.jsx)($t,{record:e,gateway:s(e.serverId),href:i(t,`/activity`,{server:e.serverId??``,seq:String(e.seq)})},`${e.serverId}-${e.seq}-${e.id}`))})]})})}function $t({record:t,gateway:n,href:r}){let i=t.tool.startsWith(`(`)||Zt[t.rule_id]!==void 0,a=i?Zt[t.rule_id]??`Console change`:We(t.tool).label;return(0,Z.jsx)(`li`,{className:`border-b border-faint last:border-b-0`,children:(0,Z.jsxs)(`a`,{href:r,onClick:y,className:`-mx-2 flex items-center gap-3 rounded-2xl px-2 py-2.5 transition-colors hover:bg-faint`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:i?`settings`:`tool`,size:17})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-[14px] font-medium`,title:i?void 0:t.tool,children:a}),(0,Z.jsxs)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:[n,` · `,x(t.ts)]})]}),!i&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:t.observe?(0,Z.jsxs)(e,{tone:`neutral`,title:`Watch-only: it ran anyway`,children:[`Would be: `,z(t.decision)]}):(0,Z.jsx)(A,{decision:t.decision})})]})})}export{Wt as ConnectionsPage};
@@ -1 +0,0 @@
1
- import{$ as e,At as t,G as n,H as r,It as i,Mt as a,O as o,Ot as s,Pt as c,_ as l,_t as u,ht as d,kt as f,s as p,vt as m,x as h,xt as g,yt as _}from"./kit-DQ7Oxf5n.js";import{Cn as v,Dn as y,En as b,Mn as x,Nn as S,On as ee,Pn as C,Sn as te,Tn as ne,X as w,Z as T,_n as E,at as D,bn as re,gn as ie,hn as O,it as ae,jn as oe,kn as se,ot as k,st as A,vn as j,wn as M,xn as ce,yn as le}from"./index-Khp0l1zp.js";import{i as ue,r as N,t as P}from"./AttachApp-0zRSPgSY.js";var F=i(),I=f(),L=[[`Runs freely`,`fill-allow`],[`Asks you first`,`fill-approve`],[`Blocked`,`fill-deny`]],R=[`Files`,`GitHub`,`Notion`,`and more…`];function z(){let e=(0,F.useId)(),t=`${e}-t`,n=`${e}-d`,r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`title`,{id:t,children:`How hardened-mcp fits in`}),(0,I.jsx)(`desc`,{id:n,children:`Your AI app talks to hardened-mcp, the toolbox. The toolbox checks every action: it runs freely, asks you first, or is blocked. Then it passes allowed actions on to your servers, such as files, GitHub and Notion.`})]});return(0,I.jsxs)(`figure`,{className:`m-0 text-ink`,children:[(0,I.jsxs)(`svg`,{viewBox:`0 0 760 236`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`hidden h-auto w-full sm:block`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:8,y:58}),(0,I.jsx)(V,{x1:190,y1:118,x2:250,y2:118,id:e}),(0,I.jsx)(W,{x:258,y:20}),(0,I.jsx)(V,{x1:508,y1:118,x2:568,y2:118,id:e}),(0,I.jsx)(G,{x:576,y:34})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 320 560`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`mx-auto block h-auto w-full max-w-[320px] sm:hidden`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:68,y:4}),(0,I.jsx)(V,{x1:160,y1:126,x2:160,y2:160,id:e}),(0,I.jsx)(W,{x:35,y:168}),(0,I.jsx)(V,{x1:160,y1:364,x2:160,y2:398,id:e}),(0,I.jsx)(G,{x:68,y:406,compact:!0})]})]})}function B({id:e}){return(0,I.jsx)(`defs`,{children:(0,I.jsx)(`marker`,{id:`${e}-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,I.jsx)(`path`,{d:`M1 1 9 5 1 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function V({x1:e,y1:t,x2:n,y2:r,id:i}){return(0,I.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,className:`stroke-soft text-soft`,strokeWidth:`2`,strokeDasharray:`5 5`,markerEnd:`url(#${i}-arrow)`})}function H({x:e,y:t,children:n,size:r=15,weight:i=600,className:a=`fill-ink`,anchor:o=`middle`}){return(0,I.jsx)(`text`,{x:e,y:t,textAnchor:o,fontSize:r,fontWeight:i,className:a,style:{fontFamily:`var(--font-sans)`},children:n})}function U({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`184`,height:`120`,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsxs)(`g`,{transform:`translate(76 18)`,className:`text-muted`,children:[(0,I.jsx)(`path`,{d:`M4 4h24a4 4 0 0 1 4 4v13a4 4 0 0 1-4 4H14l-7 6v-6H4a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`circle`,{cx:`9`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`16`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`23`,cy:`14.5`,r:`1.8`,fill:`currentColor`})]}),(0,I.jsx)(H,{x:92,y:76,children:`Your AI app`}),(0,I.jsx)(H,{x:92,y:98,size:14,weight:500,className:`fill-soft`,children:`Claude, Cursor, VS Code…`})]})}function W({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`250`,height:`196`,rx:`26`,className:`fill-green-deep`}),(0,I.jsxs)(`g`,{transform:`translate(110 16)`,className:`text-white`,children:[(0,I.jsx)(`path`,{d:`M15 2 27 6.5v9.4c0 7-4.5 11.8-12 14.8C7.5 27.7 3 22.9 3 15.9V6.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`m9.5 16 4 4 7-8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),(0,I.jsx)(H,{x:125,y:68,size:17,weight:700,className:`fill-white`,children:`hardened-mcp`}),(0,I.jsx)(H,{x:125,y:88,size:14,weight:500,className:`fill-on-hero-soft`,children:`the toolbox that checks every action`}),L.map(([e,t],n)=>(0,I.jsxs)(`g`,{transform:`translate(34 ${108+n*26})`,children:[(0,I.jsx)(`rect`,{width:`182`,height:`22`,rx:`11`,fill:`white`,fillOpacity:`0.12`}),(0,I.jsx)(`circle`,{cx:`14`,cy:`11`,r:`5`,className:t}),(0,I.jsx)(H,{x:28,y:15.5,size:14,weight:600,className:`fill-white`,anchor:`start`,children:e})]},e))]})}function G({x:e,y:t,compact:n}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`176`,height:n?150:168,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsx)(H,{x:88,y:28,size:14.5,weight:700,className:`fill-soft`,children:`Your servers`}),R.map((e,t)=>(0,I.jsxs)(`g`,{transform:`translate(18 ${42+t*(n?26:30)})`,children:[(0,I.jsx)(`rect`,{width:`140`,height:`22`,rx:`7`,className:t===R.length-1?`fill-transparent`:`fill-sunken`}),t<R.length-1&&(0,I.jsx)(`circle`,{cx:`13`,cy:`11`,r:`3.5`,className:`fill-ok`}),(0,I.jsx)(H,{x:t<R.length-1?26:8,y:15.5,size:12.5,weight:500,className:`fill-muted`,anchor:`start`,children:e})]},e))]})}function K({text:e}){let t=e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).filter(Boolean);return(0,I.jsx)(I.Fragment,{children:t.map((e,t)=>e.startsWith("`")?(0,I.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] break-words text-ink`,children:e.slice(1,-1)},t):e.startsWith(`**`)?(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:e.slice(2,-2)},t):(0,I.jsx)(`span`,{children:e},t))})}function q({children:e}){return(0,I.jsx)(`p`,{className:`max-w-2xl text-[15.5px] leading-relaxed text-muted`,children:e})}function J({icon:e,title:t,children:n}){return(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e,size:17})}),(0,I.jsxs)(`span`,{className:`min-w-0 pt-0.5`,children:[(0,I.jsx)(`span`,{className:`block text-[15px] font-medium`,children:t}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] leading-relaxed text-soft`,children:n})]})]})}function de(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,I.jsx)(q,{children:`hardened-mcp lets your AI app use tools, like your files, GitHub or Notion. It doesn't give the AI everything. You get a toolbox. Your AI app connects to it, and every action goes through it first. When protection is on, reading runs freely. Every change asks you first. Anything outside the folders and services you gave it is blocked. Everything is written down, so you can always see what your AI did.`}),(0,I.jsx)(`div`,{className:`rounded-[22px] bg-sunken/60 p-4 sm:p-6`,children:(0,I.jsx)(z,{})}),(0,I.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,I.jsxs)(`section`,{"aria-labelledby":`what-mcp`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsxs)(`h2`,{id:`what-mcp`,className:`flex items-center gap-2 text-[16px] font-semibold`,children:[`What's an MCP server? `,(0,I.jsx)(l,{term:`mcp`})]}),(0,I.jsx)(`p`,{className:`mt-2 text-[14px] leading-relaxed text-muted`,children:`It's a small add-on that gives your AI app a set of tools: reading a folder, searching the web, opening an issue on GitHub. MCP is a shared standard, so any AI app can use any of them. You'll add your first one in a minute.`})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-expect`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsx)(`h2`,{id:`what-expect`,className:`text-[16px] font-semibold`,children:`What to expect`}),(0,I.jsxs)(`ul`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`About 5 minutes`,children:`Seven short steps. You can skip any of them and come back later from Settings & help.`}),(0,I.jsx)(J,{icon:`lock`,title:`Nothing changes until you say so`,children:`Your AI apps keep working exactly as they do now until you choose to connect one.`}),(0,I.jsx)(J,{icon:`eye`,title:`It starts by watching`,children:`At first your toolbox lets everything run and writes down what it would have asked you about or blocked, so nothing you rely on breaks. In step 6 you choose whether to turn protection on straight away.`})]})]})]})]})}function Y(e,t){let n=t.find(t=>t.id===e),r=e===`node`?t.find(e=>e.id===`npx`):e===`uv`?t.find(e=>e.id===`uvx`):void 0;return!n?.found||r&&!r.found?{status:{tone:`neutral`,label:`Not installed`,icon:`minus`},check:n,state:`missing`}:n?.running===!1?{status:{tone:`warn`,label:`Installed, not running`,icon:`pause`},check:n,state:`stopped`}:{status:{tone:`ok`,label:`Ready`,icon:`check`},check:n,state:`ready`}}function fe({entries:e}){let i=p(()=>t.doctor(),[]),[a,o]=(0,F.useState)(!1),s=i.data,c=A(s?.platform),u=b(e),f=()=>{o(!0),i.reload(),setTimeout(()=>o(!1),700)},m=s?k.map(e=>({rt:e,...Y(e,s.checks)})):[],h=m.filter(e=>e.state!==`ready`),g=m.some(e=>e.rt===`node`&&e.state===`ready`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Most servers need a free helper program to run, such as Node.js. This looks for them on this computer. It only looks; it never installs or changes anything. `,(0,I.jsx)(l,{term:`machineCheck`})]}),i.error&&!s?(0,I.jsx)(r,{tone:`warn`,title:`The check couldn't run`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a,children:`Check again`}),children:`You can skip this step. If a server needs something that's missing, it will tell you when you test it.`}):s?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{tone:h.length===0?`ok`:g?`info`:`warn`,role:`status`,title:h.length===0?`Everything is ready`:g?`You're ready for your first server`:`Some servers need something installed first`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a||i.loading,children:`Check again`}),children:h.length===0?`This computer has everything servers need.`:g?`Some servers need other helpers, listed below. You don't need them unless you add one of those servers.`:`That's fine. You can carry on and only install something when a server you want needs it.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`What this computer has`,children:m.map(e=>(0,I.jsx)(X,{rt:e.rt,status:e.status,check:e.check,state:e.state,os:c,needs:u[e.rt]},e.rt))})]}):(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,"aria-label":`Checking your computer`,children:(0,I.jsx)(n,{height:64,lines:3})})]})}function X({rt:t,status:n,check:r,state:i,os:a,needs:s}){let c=ae[t],[l,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(a),h=`install-${t}`;return(0,I.jsxs)(`li`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,I.jsx)(`p`,{className:`flex flex-wrap items-center gap-2 text-[15px] font-semibold`,children:c.name}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:c.why}),i!==`ready`&&s.length>0&&(0,I.jsxs)(`p`,{className:`mt-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:`Needed by:`}),` `,s.join(`, `)]}),i===`ready`&&(r?.path||r?.version)&&(0,I.jsxs)(`details`,{className:`mt-1 text-[12px] text-soft`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),r?.version&&(0,I.jsxs)(`span`,{className:`mono block`,children:[`Version `,r.version]}),r?.path&&(0,I.jsx)(`code`,{className:`mono block break-all`,children:r.path})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,I.jsx)(e,{tone:n.tone,icon:n.icon,children:n.label}),i!==`ready`&&(0,I.jsx)(d,{size:`sm`,variant:`ghost`,iconRight:`chevron`,"aria-expanded":l,"aria-controls":h,onClick:()=>f(!l),children:i===`stopped`?`How to start it`:`How to install it`})]})]}),l&&i!==`ready`&&(0,I.jsx)(`div`,{id:h,className:`mt-4 border-t border-faint pt-4`,children:i===`stopped`&&c.start?(0,I.jsx)(`p`,{className:`text-[14px] leading-relaxed text-muted`,children:(0,I.jsx)(K,{text:c.start[p]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{size:`sm`,label:`Install steps for ${c.name}: choose your computer`,value:p,onChange:m,options:[`darwin`,`win32`,`linux`].map(e=>({value:e,label:D[e]}))}),(0,I.jsx)(`ol`,{className:`mt-4 flex flex-col gap-3`,children:c.steps[p].map((e,t)=>(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`tnum grid h-6 w-6 shrink-0 place-items-center rounded-full bg-sunken text-[12px] font-bold text-muted`,children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 text-[14px] leading-relaxed text-muted`,children:[(0,I.jsx)(K,{text:e.text}),e.copy&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`mono min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[12.5px] break-all text-ink`,children:e.copy}),(0,I.jsx)(T,{text:e.copy,label:`Copy`})]}),e.link&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(u,{href:e.link.url,external:!0,size:`sm`,iconRight:`external`,children:e.link.label})})]})]},t))})]})})]})}function pe({gatewayId:e,existing:t,added:n,entries:i,onAdded:a,onClosed:o}){let[s,c]=(0,F.useState)(n.length===0&&t.length===0),l=n.at(-1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Pick a server to give your AI app its first tools. Each one comes with step-by-step instructions, and you can test it before anything is saved. If you're not sure, `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Files on this computer`}),` `,`is a good first choice: it lets the AI read and edit files in one folder you choose, and nothing outside it.`]}),l&&(0,I.jsx)(r,{tone:`ok`,role:`status`,title:l.displayName?`${l.displayName} is in your toolbox`:`Added to your toolbox`,children:l.summary.length>0?(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.summary.map(e=>(0,I.jsx)(`li`,{children:e},e))}):`It's saved in your toolbox.`}),!l&&t.length>0&&(0,I.jsxs)(r,{tone:`info`,title:`You already have servers`,children:[`Your toolbox has `,t.map(e=>v(i,e)?.name??e).join(`, `),`. You can add another or carry on.`]}),s?(0,I.jsx)(N,{gatewayId:e,compact:!0,onDone:e=>{a(e),c(!1)},onCancel:n.length>0||t.length>0?()=>{c(!1),o?.()}:void 0}):(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:()=>c(!0),children:`Add another server`})})]})}function me({gatewayId:e,attached:t,onAttached:n,onAddServer:i}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Now tell your AI app about your toolbox. `,(0,I.jsx)(l,{term:`toolbox`}),` Choose the app you use and we add the toolbox to its settings for you. A copy of its old settings is kept, so you can undo this at any time.`]}),(0,I.jsxs)(`div`,{className:`rounded-[18px] bg-sunken/60 p-4 sm:p-5`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[(0,I.jsx)(s,{name:`refresh`,size:17,className:`text-ok`}),`Restart your app once`]}),(0,I.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-muted`,children:`Your AI app only looks for new tools when it starts. After connecting, quit it completely (not just close the window) and open it again. You only do this once: servers you add or change later appear on their own.`})]}),e?t?(0,I.jsx)(r,{tone:`ok`,role:`status`,title:t.alreadyConnected?`${t.appLabel} was already connected`:`Connected to ${t.appLabel}`,children:t.restartHint||`Quit ${t.appLabel} completely and open it again.`}):(0,I.jsx)(P,{gatewayId:e,compact:!0,onDone:n}):(0,I.jsx)(r,{tone:`info`,title:`Add a server first`,actions:(0,I.jsx)(d,{size:`sm`,variant:`primary`,icon:`arrow-left`,onClick:i,children:`Add a server`}),children:`Your toolbox is made when you add your first server. Then you can connect it to your app here.`})]})}function he({entries:e,servers:t,appLabel:n}){let{prompt:r,entry:i}=S(e,t),a=n??`your AI app`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Open `,a,` and ask it something that uses your new tools`,i?` from ${i.name}`:``,`. Here's a good first one:`]}),(0,I.jsxs)(`figure`,{className:`m-0 rounded-[20px] border-[1.5px] border-primary/40 bg-ok-tint p-5`,children:[(0,I.jsxs)(`blockquote`,{className:`text-[17px] leading-relaxed font-medium text-ink`,children:[`“`,r,`”`]}),(0,I.jsx)(`figcaption`,{className:`mt-4`,children:(0,I.jsx)(T,{text:r,label:`Copy this`})})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-see`,children:[(0,I.jsx)(`h2`,{id:`what-see`,className:`text-[16px] font-semibold`,children:`What you'll see`}),(0,I.jsxs)(`ol`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`check`,title:`Looking runs straight away`,children:`When the AI only reads something, it just happens. Every action is written down under Activity in this console.`}),(0,I.jsx)(J,{icon:`eye`,title:`At first, changes run too`,children:`A new toolbox starts by watching: everything runs, and Activity notes what would have asked you first or been blocked. In the next step you choose whether it should start protecting you.`}),(0,I.jsxs)(J,{icon:`clock`,title:`Once protection is on, every change asks you first`,children:[`If the AI wants to change something, it stops and tells you it's waiting. The request appears under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Waiting for you`}),` in this console. Approve it or say no there. If you approve, the AI can try again and it goes ahead. Anything outside the folders and services you gave it is blocked.`]}),(0,I.jsxs)(J,{icon:`warning`,title:`If nothing happens`,children:[`Check that you quit `,a,` completely and opened it again. If a tool still doesn't show up, open Connections in this console: each server says whether it's working, and if not, why and how to fix it.`]})]}),(0,I.jsx)(`div`,{className:`mt-5`,children:(0,I.jsx)(u,{href:`/approvals`,external:!0,icon:`clock`,iconRight:`external`,children:`Open Waiting for you`})})]})]})}var Z=`Reading runs straight away. Every change asks you first, here in this console. Anything outside the folders and services you gave it is blocked.`;function ge({gatewayId:t,onAddServer:i,applyRef:a}){let[o,s]=(0,F.useState)(`protect`),[l,u]=(0,F.useState)(!1),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),_=p(()=>t?c.protection(t):Promise.resolve(null),[t]),v=(0,F.useRef)(null),y=(0,F.useRef)(!1),b=_.data?.enforcement===`enforce`||h===`protect`,x=_.data&&!_.data.policyWrite.ok?_.data.policyWrite.why:null,S=async()=>{if(m(null),!t||b||h===`watch`)return!0;if(o===`watch`)return y.current=!0,g(`watch`),!0;if(!_.data)return!1;if(x)return m(x),!1;u(!0);try{return await c.setPolicySetting(t,`enforcement`,`enforce`,_.data.policyWrite.digest),y.current=!0,g(`protect`),_.reload(),!0}catch(e){return m(e.message||`Protection couldn't be turned on.`),!1}finally{u(!1)}};return a&&(a.current=S),(0,F.useEffect)(()=>()=>{a&&(a.current=null)},[a]),(0,F.useEffect)(()=>{y.current&&v.current?.focus()},[b,h]),t?_.loading&&!_.data?(0,I.jsx)(n,{height:180}):b?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsxs)(r,{tone:`ok`,title:`Your toolbox is protecting you`,role:`status`,children:[Z,` Requests appear under `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Waiting for you`}),`.`]})}),(0,I.jsxs)(`ul`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`When your AI asks for something`,children:`It stops and tells you it's waiting. Open this console, look at what it wants to do, and approve it or say no.`}),(0,I.jsxs)(J,{icon:`sliders`,title:`Too many questions?`,children:[`Under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` you can let a tool you trust run freely, or approve one for a while.`]})]})]}):h===`watch`?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsx)(r,{tone:`warn`,title:`Your toolbox is only watching for now`,role:`status`,children:`Everything your AI does runs and is written down under Activity. Nothing asks you first and nothing is blocked, so you're not protected yet.`})}),(0,I.jsxs)(q,{children:[`When you're ready, turn protection on under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` `,`(one switch at the top), or come back to this guide from Settings & help.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`ghost`,onClick:()=>g(null),children:`Choose again`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Right now your toolbox only watches: everything your AI does runs, and is written down. Choose whether it should start protecting you now.`}),(0,I.jsx)(w,{label:`How careful should your toolbox be?`,value:o,onChange:s,options:[{value:`protect`,title:`Protect me now`,badge:(0,I.jsx)(e,{tone:`ok`,children:`Recommended`}),body:Z},{value:`watch`,title:`Watch for a few days first`,body:`Everything runs and is written down, and nothing asks you first. You can see what would have asked you, then turn protection on later. Until then, you're not protected.`}]}),x&&(0,I.jsx)(r,{tone:`warn`,title:`This toolbox's protection can't be changed from the console`,children:x}),f&&(0,I.jsx)(r,{tone:`danger`,role:`alert`,title:`Protection wasn't turned on`,children:f}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`primary`,icon:o===`protect`?`shield-check`:`eye`,loading:l,disabled:!!x&&o===`protect`,onClick:()=>void S(),children:o===`protect`?`Turn on protection`:`Keep watching for now`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(q,{children:`There's nothing to protect yet. Add a server first, then come back here.`}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:i,children:`Add a server`})})]})}var Q=[{href:`/approvals`,icon:`clock`,title:`Waiting for you`,body:`Requests that ask you first. Approve or say no.`},{href:`/tools`,icon:`tool`,title:`Tools`,body:`Every tool your AI can use, and what each one is allowed to do.`},{href:`/connections?add=server`,icon:`plus`,title:`Add more servers`,body:`GitHub, Notion, the web and more, with a guide for each.`},{href:`/protection`,icon:`sliders`,title:`Protection settings`,body:`Choose what runs freely, what asks you first, and what's blocked.`}];function _e({gatewayId:e,onLeave:t}){let n=p(()=>e?c.protection(e):Promise.resolve(null),[e]),i=!!n.data&&n.data.enforcement!==`enforce`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Your toolbox is set up. Here's where to go next.`}),i&&(0,I.jsxs)(r,{tone:`warn`,title:`Protection: off (only watching)`,children:[`Everything your AI does runs and is written down, and nothing asks you first. Turn protection on under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Protection settings`}),` when you're ready.`]}),(0,I.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:Q.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:e.href,onClick:n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(e.href))},className:_(`card card-link flex h-full gap-3.5 p-5`),children:[(0,I.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e.icon,size:19})}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[15.5px] font-semibold`,children:[e.title,(0,I.jsx)(s,{name:`arrow-right`,size:15,className:`text-soft`})]}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:e.body})]})]})},e.href))}),(0,I.jsx)(r,{tone:`info`,title:`When you need to approve something, open the console`,children:`Approving requests and signing in to services happen here. Your servers keep working without the console open; anything that asks you first waits until you open it again.`})]})}function $(){let[e,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(`welcome`),[o,l]=(0,F.useState)(!1),[u,f]=(0,F.useState)(null),[p,v]=(0,F.useState)([]),[b,S]=(0,F.useState)([]),[w,T]=(0,F.useState)(null),[D,ae]=(0,F.useState)([]),k=(0,F.useRef)(null),A=(0,F.useRef)(null),[N,P]=(0,F.useState)(!1),L=(0,F.useRef)(!1),[R,z]=(0,F.useState)(O),[B,V]=(0,F.useState)(null),H=(0,F.useRef)(R);H.current=R;let U=(0,F.useRef)(null),[W,G]=(0,F.useState)(0),K=(0,F.useRef)(Promise.resolve()),q=(0,F.useRef)(ie);(0,F.useEffect)(()=>{let e=!0;return t.settings().then(ee,()=>(l(!0),ie)).then(t=>{e&&(q.current=t,n(t),i(oe(t.onboarding)))}),c.servers().then(t=>{if(!e)return;let n=t.filter(e=>e.ok),r=n.find(e=>e.id===`main`)??n[0];r&&(f(r.id),v(r.upstreams??[]))}).catch(()=>void 0),t.catalog().then(t=>e&&ae(t.entries)).catch(()=>void 0),()=>{e=!1}},[]);let J=(0,F.useCallback)(e=>{let r={...q.current,onboarding:e};q.current=r,n(r);let i=()=>t.saveSettings(r).then(()=>l(!1),()=>l(!0));return K.current=K.current.then(i,i),K.current},[]),Y=()=>{let e=H.current;if(e.pending){let t=e.pending;S(e=>x({added:e,gatewayId:null},t).added),f(t.gatewayId)}e.state!==`idle`&&ue(),z(O)},X=e=>{M(r,R)?V(()=>e):e()},Z=(e,t)=>{r===`server`&&e!==`server`&&Y(),L.current=!0,i(e),J(ne(q.current.onboarding,e,t))},Q=async(e=`/`)=>{r===`server`&&Y(),await J(te(q.current.onboarding)),g(e)};(0,F.useEffect)(()=>{if(r===`server`)return a(e=>z(t=>re(t,e)))},[r]),(0,F.useEffect)(()=>{W&&U.current?.querySelector(`button`)?.focus()},[W]),(0,F.useEffect)(()=>{if(!L.current)return;k.current?.focus();let e=matchMedia(`(prefers-reduced-motion: reduce)`).matches;window.scrollTo({top:0,behavior:e?`auto`:`smooth`})},[r]),(0,F.useEffect)(()=>{let e=document.title;return document.title=`Step ${E.indexOf(r)+1} of ${E.length}: ${j[r]} – hardened-mcp`,()=>{document.title=e}},[r]);let $=E.indexOf(r),ye=e?.onboarding.done??[],be=[...p,...C(b,R.pending).map(e=>e.upstreamName)],xe=M(r,R);return(0,I.jsxs)(`div`,{className:`min-h-dvh bg-canvas text-ink`,children:[(0,I.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-faint bg-canvas/95`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-6xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[#2a2623]`,children:(0,I.jsx)(`img`,{src:`/brand/mark.svg`,alt:``,width:24,height:24})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[15px] font-semibold`,children:`Getting started`}),(0,I.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:`hardened-mcp`})]}),(0,I.jsx)(d,{variant:`ghost`,size:`sm`,iconRight:`arrow-right`,onClick:()=>X(()=>void Q()),children:`Go to the console`})]})}),e?(0,I.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10 lg:py-10`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Guide steps`,className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,I.jsxs)(`div`,{className:`lg:hidden`,children:[(0,I.jsxs)(`p`,{className:`text-[13px] font-semibold text-soft`,children:[`Step `,$+1,` of `,E.length]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-line`,role:`progressbar`,"aria-label":`Progress through the guide`,"aria-valuemin":1,"aria-valuemax":E.length,"aria-valuenow":$+1,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${($+1)/E.length*100}%`}})})]}),(0,I.jsx)(`ol`,{className:`hidden flex-col gap-1 lg:flex`,children:E.map((e,t)=>{let n=e===r,i=ye.includes(e);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>e===r?void 0:X(()=>Z(e)),"aria-current":n?`step`:void 0,className:_(`flex w-full items-center gap-3 rounded-2xl px-3 py-2.5 text-left text-[14px] transition-colors`,n?`bg-surface font-semibold shadow-[var(--shadow-sm)]`:`text-muted hover:bg-faint`),children:[(0,I.jsx)(`span`,{className:_(`tnum grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12.5px] font-bold`,i?`bg-primary text-white`:n?`border-2 border-[var(--primary)] text-ink`:`border-[1.5px] border-line text-soft`),children:i?(0,I.jsx)(s,{name:`check`,size:14,strokeWidth:2.6}):t+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j[e]}),i&&(0,I.jsx)(`span`,{className:`sr-only`,children:`(done)`})]})},e)})})]}),(0,I.jsxs)(`main`,{className:`min-w-0`,children:[(0,I.jsxs)(`article`,{className:`card p-5 sm:p-8`,"aria-labelledby":`start-step-h`,children:[(0,I.jsxs)(`p`,{className:`eyebrow text-soft`,children:[`Step `,$+1,` · `,j[r]]}),(0,I.jsx)(`h1`,{id:`start-step-h`,ref:k,tabIndex:-1,className:`display mt-2 text-[28px] outline-none sm:text-[34px]`,children:le[r]}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[r===`welcome`&&(0,I.jsx)(de,{}),r===`computer`&&(0,I.jsx)(fe,{entries:D}),r===`server`&&(0,I.jsx)(pe,{gatewayId:u,existing:p,added:b,entries:D,onAdded:e=>{f(e.gatewayId),S(t=>C(t,e)),z(O),G(e=>e+1)},onClosed:()=>z(O)}),r===`app`&&(0,I.jsx)(me,{gatewayId:u,attached:w,onAttached:e=>{T(e),G(e=>e+1)},onAddServer:()=>Z(`server`)}),r===`try`&&(0,I.jsx)(he,{entries:D,servers:be,appLabel:w?.appLabel??null}),r===`protect`&&(0,I.jsx)(ge,{gatewayId:u,onAddServer:()=>Z(`server`),applyRef:A}),r===`done`&&(0,I.jsx)(_e,{gatewayId:u,onLeave:e=>void Q(e)})]}),(0,I.jsxs)(`footer`,{className:_(`mt-8 flex-wrap items-center gap-2 border-t border-faint pt-5`,xe?`hidden`:`flex`),children:[$>0&&(0,I.jsx)(d,{variant:`ghost`,icon:`arrow-left`,onClick:()=>Z(se(r)),children:`Back`}),(0,I.jsx)(`span`,{className:`flex-1`}),r!==`done`&&(0,I.jsx)(d,{variant:`ghost`,onClick:()=>X(()=>Z(y(r))),children:`Skip for now`}),(0,I.jsx)(ve,{buttonRef:U,step:r,ready:ce(r,be.length,!!w,R),busy:N,onNext:async()=>{r===`protect`&&A.current&&(P(!0),!await A.current().finally(()=>P(!1)))||Z(y(r),r)},onFinish:()=>void Q()})]})]}),(0,I.jsx)(h,{open:!!B,onClose:()=>V(null),title:`Leave without saving this server?`,description:`You're in the middle of setting up a server. If you leave now, it isn't added, and you'd start it again next time.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{variant:`ghost`,onClick:()=>{let e=B;V(null),e?.()},children:`Leave without saving`}),(0,I.jsx)(d,{variant:`primary`,onClick:()=>V(null),children:`Keep setting it up`})]})}),o&&(0,I.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-soft`,role:`status`,children:`Your progress couldn't be saved, so the guide may start over next time. Everything you add is still saved.`})]})]}):(0,I.jsx)(`main`,{className:`flex min-h-[60dvh] items-center justify-center`,children:(0,I.jsxs)(`p`,{role:`status`,className:`flex items-center gap-3 text-soft`,children:[(0,I.jsx)(m,{}),` Getting things ready…`]})})]})}function ve({buttonRef:e,step:t,ready:n,busy:r,onNext:i,onFinish:a}){if(t===`done`)return(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:a,children:`Go to the console`})});let o=t===`welcome`?`Let's start`:t===`try`?`I've tried it`:`Continue`,s=n?null:t===`server`?`Add a server first, or skip for now.`:`Connect an app first, or skip for now.`;return(0,I.jsxs)(I.Fragment,{children:[s&&(0,I.jsx)(`p`,{id:`start-continue-why`,className:`order-last basis-full text-right text-[13px] text-soft`,children:s}),(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:i,disabled:!n,loading:r,"aria-describedby":s?`start-continue-why`:void 0,children:o})})]})}export{$ as StartPage};
@@ -1,4 +0,0 @@
1
- import{$ as e,A as t,B as n,Ct as r,D as i,E as a,Et as o,G as s,H as c,I as l,It as u,J as d,M as f,N as p,Nt as m,O as h,Ot as g,Pt as _,Q as v,S as y,U as b,V as x,Y as S,Z as C,_ as w,_t as T,bt as ee,c as te,d as E,et as D,f as O,ft as ne,gt as k,ht as A,k as re,kt as j,lt as M,ot as N,pt as P,q as ie,rt as F,s as ae,st as I,w as L,wt as oe,x as R,y as z,yt as B}from"./kit-DQ7Oxf5n.js";import{$t as V,Zt as se,en as ce,in as le,rn as H,sn as U}from"./index-Khp0l1zp.js";var W=u(),ue=[`allow`,`approve`,`deny`,`unlabelled`,`off`,`changed`],G={allow:`Runs freely`,approve:`Asks you first`,deny:`Blocked`,unlabelled:`Not labelled`,off:`Turned off`,changed:`Changed`};function de(e){return e!==null&&ue.includes(e)}function K(e){return e.exposure.disabled?`off`:e.effect===null&&!e.reclassifiedTo?`unlabelled`:e.verdict.kind}function q(e){let t=e.reclassifiedTo??e.effect;return t===`read`||t===`write`||t===`destructive`?t:null}function J(e){return e.standingGrants.some(e=>e.covers)}function fe(e){if(e.exposure.disabled)return`Turned off. Your AI can't see it, and every call to it is blocked.`;if(e.hiddenByPolicy)return`Hidden from your AI, because its description carried hidden instructions.`;let t=e.effect===null&&!e.reclassifiedTo;if(e.unreachable)return`Asks you first, but approvals are switched off, so it can never run.`;if(t)return e.verdict.kind===`approve`?`Asks you first, because nobody has said what it does yet.`:`Blocked, because nobody has said what it does yet.`;if(e.verdict.kind===`deny`)return`Blocked. Your AI can see it, but every call to it is refused.`;let n=e.bounds;return e.verdict.kind===`approve`?n?n.onViolation===`approve`?`Asks you first before it runs. Its inputs also have limits, listed below.`:`Asks you first before it runs, and a call that breaks the limits below is blocked.`:`Asks you first before it runs.`:n?`Runs freely while its inputs stay within the limits below. A call outside them ${n.onViolation===`approve`?`asks you first`:`is blocked`}.`:`Runs freely, without asking anyone.`}function pe(e,t){let{ruleId:n,reason:r,kind:i}=e,a=i===`allow`?`runs freely`:i===`approve`?`asks you first`:`is blocked`;return n===`exposure.disabled`?`Someone turned this tool off.`:n.startsWith(`tenant.`)?`The customer check stopped it: ${X(r)}`:n===`defaults.on_unclassified`?`Nobody has said what it does, and your setting for unlabelled tools is that they ${i===`approve`?`ask you first`:`are blocked`}.`:n===`defaults.mode`?t?`No rule mentions it, so your default stance decides. ${I[t].explain}`:`No rule mentions it, so your default stance decides.`:/^rule ".*" \(.*\) says (allow|approve|deny) for /.test(r)?`A rule in your protection settings says it ${a}.`:`A rule in your protection settings says it ${a}, because: “${r}”`}var me={policy:`A rule in your protection settings says what it does.`,annotation:`The connected server describes it this way. Nothing in your settings overrides it.`,name:`Guessed from the tool's name.`,unclassified:`Nobody has said what it does.`},Y={max:`At most`,min:`At least`,enum:`Must be one of`,maxLength:`Longest text`,maxItems:`Most items`,within:`Must stay inside folder`,host:`Allowed websites`};function he(e){return e===`number`||e===`integer`?[`max`,`min`,`enum`]:e===`string`?[`enum`,`maxLength`,`within`,`host`]:e===`array`?[`maxItems`]:e===`boolean`?[`enum`]:[`max`,`min`,`enum`,`maxLength`,`maxItems`,`within`,`host`]}function ge(e){return e.pattern!==void 0||e.coerce!==void 0||e.required!==void 0}function _e(e){let t=[];e.min!==void 0&&t.push(`at least ${e.min}`),e.max!==void 0&&t.push(`at most ${e.max}`),e.maxLength!==void 0&&t.push(`at most ${e.maxLength} characters`),e.maxItems!==void 0&&t.push(`at most ${e.maxItems} items`),e.sum_max!==void 0&&t.push(`${e.sum_max} in total`),e.count_max!==void 0&&t.push(`in at most ${e.count_max} places`),e.enum&&t.push(`one of ${e.enum.map(String).join(`, `)}`),e.const===null?t.push(`only empty (null)`):e.const!==void 0&&t.push(`exactly ${String(e.const)}`),e.within&&t.push(`inside ${typeof e.within==`string`?e.within:e.within.join(` or `)}`),e.host&&t.push(`a web address on ${e.host.join(`, `)}`),e.pattern&&t.push(`matching a pattern set in the settings file`);let n=t.length?`must be ${t.join(`, `)}`:`is limited`;return e.optional?`${n}, or left out`:n}function ve(e){return e?e.paths.map(t=>`${t} ${_e(e.constraints[t]??{})}`):[]}var ye={allow:`Inputs no limit mentions are let through.`,approve:`A call with an input no limit mentions asks you first.`,deny:`A call with an input no limit mentions is blocked.`};function X(e){let t=e.split(/(?<=[.;])\s+/).filter(e=>!/\b(hmcp-gateway|hmcp|npx)\s+[a-z]/i.test(e)&&!/(^|\s)--[a-z][\w-]*/.test(e)),n=(t.length?t:[`The toolbox refused this change.`]).join(` `).replace(/`/g,``);return n.charAt(0).toUpperCase()+n.slice(1)}function Z(e){return X(e instanceof Error?e.message:String(e))}function be(e){return e instanceof m&&e.status===409}var xe=`This changed since you opened it. Reload and try again.`;function Se(e,t=64){return e.split(`
2
- `).map(e=>{let n=[],r=``;for(let i of e.split(/\s+/))r&&r.length+i.length+1>t?(n.push(r),r=i):r=r?`${r} ${i}`:i;return n.push(r),n.join(`
3
- `)}).join(`
4
- `)}var Q=j(),Ce={effect:`What it does (looks, changes or deletes)`,description:`Its description`,"input schema":`The inputs it takes`,annotations:`The hints its server gives about it`};function we(e){return e.previousKnown?e.changes.length===0?[`Its details changed.`]:e.changes.map(e=>Ce[e]??e):[`Something changed, but the earlier version wasn't kept, so the toolbox can't show what.`]}function Te({serverId:e,data:t,error:r,loading:i,reload:a,onAccepted:o}){let l=z(),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1);async function v(t){p(!0);try{let n=t?await ce(e,t):await V(e);l.show(`ok`,n.accepted.length===1?`Accepted the change to ${n.accepted[0]}.`:`Accepted ${n.accepted.length} changed tools.`),d(null),n.restartNeeded&&(h(`checking`),H(e).then(h,()=>h(null))),a(),o()}catch(e){l.show(`bad`,`Not accepted. ${Z(e)}`)}finally{p(!1)}}async function y(){_(!0);try{let t=await U(e);l.show(`ok`,`The toolbox restarted. Accepted tools are available again.`),t.warning&&l.show(`warn`,X(t.warning)),h(null),a(),o()}catch(e){l.show(`bad`,`The toolbox didn't restart. ${Z(e)}`)}finally{_(!1)}}if(r&&!t)return(0,Q.jsx)(c,{tone:`danger`,title:`Changed tools couldn't be loaded`,actions:(0,Q.jsx)(A,{size:`sm`,icon:`refresh`,onClick:a,children:`Try again`}),children:Z(r)});if(!t)return(0,Q.jsx)(P,{children:(0,Q.jsx)(s,{lines:5})});let S=t.changed;return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[m&&(0,Q.jsx)(c,{tone:`warn`,title:`Restart the toolbox to bring accepted tools back`,actions:m!==`checking`&&m.managed&&(0,Q.jsx)(A,{variant:`primary`,size:`sm`,icon:`refresh`,loading:g,onClick:()=>void y(),children:`Restart gateway`}),children:m===`checking`?`Checking how this toolbox is running…`:m.managed?`Some accepted tools were held back from your AI. They come back once the toolbox restarts.`:m.externalHint?`Some accepted tools were held back from your AI. ${X(m.externalHint.replace(/\s+--\s+/g,`, `))}`:`Some accepted tools were held back from your AI. They come back the next time the AI app that runs this toolbox starts it again, so restart that app.`}),!t.live&&(0,Q.jsx)(c,{tone:`warn`,title:`The toolbox isn't running, so changes can't be checked right now`,children:`The list below is what it reported last time. Changes can be accepted once it is running again.`}),(0,Q.jsxs)(P,{title:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Changed tools `,(0,Q.jsx)(w,{term:`changedTools`})]}),actions:S.length>1&&(0,Q.jsx)(A,{size:`sm`,variant:`primary`,icon:`check`,disabled:!t.live,onClick:()=>d({tool:null}),children:`Accept all`}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 mb-4 text-[13.5px] text-soft`,children:t.onToolChange===`deny`?`A changed tool is held back from your AI until you accept it.`:`A changed tool keeps working, and the change is noted in the activity log until you accept it.`}),S.length===0?(0,Q.jsx)(b,{icon:`shield-check`,title:`No tools have changed`,compact:!0,children:`Every tool matches what was accepted before. The toolbox checks again each time it starts and when a connected server updates its list.`}):(0,Q.jsx)(`ul`,{className:`space-y-3`,children:S.map(e=>(0,Q.jsx)(Ee,{change:e,live:t.live,loading:i,onAccept:()=>d({tool:e.tool})},e.tool))})]}),t.pins.length>0&&(0,Q.jsx)(P,{padded:!1,children:(0,Q.jsxs)(`details`,{className:`group p-6`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between gap-3 text-[17px] font-medium tracking-[-0.015em]`,children:[`Reviewed tools`,(0,Q.jsx)(`span`,{className:`text-[13px] font-normal text-soft`,children:n(t.pins.length,`tool`)})]}),(0,Q.jsx)(`p`,{className:`mt-2 text-[13.5px] text-soft`,children:`The version of each tool that was last accepted. A tool is compared against this every time the toolbox sees it.`}),(0,Q.jsx)(`ul`,{className:`mt-3 divide-y divide-faint`,children:t.pins.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-0.5 py-2.5`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-[13.5px] break-all`,children:e.tool}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`Accepted `,x(e.pinnedAt),` by `,e.pinnedBy,(0,Q.jsx)(`span`,{className:`ml-2 font-mono text-[11px]`,children:e.digest.slice(0,12)})]})]},e.tool))})]})}),(0,Q.jsx)(R,{open:u!==null,onClose:()=>d(null),title:u?.tool?`Accept the change to ${u.tool}?`:`Accept all ${S.length} changed tools?`,description:`Accepting means you've looked at what changed and you're fine with it. The new version becomes the one future changes are compared against.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{variant:`secondary`,onClick:()=>d(null),disabled:f,children:`Cancel`}),(0,Q.jsx)(A,{variant:`primary`,icon:`check`,loading:f,onClick:()=>void v(u?.tool??null),children:u?.tool?`Accept change`:`Accept all`})]}),children:(0,Q.jsxs)(`p`,{className:`text-[14px] text-muted`,children:[`Accepting doesn't change what the tool is allowed to do. Your rules still decide that.`,t.onToolChange===`deny`&&` A tool that was held back becomes available again after the toolbox restarts.`]})})]})}function Ee({change:t,live:n,loading:r,onAccept:i}){let a=t.was;return(0,Q.jsxs)(`li`,{className:`rounded-[20px] border border-line p-4 sm:p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-[14.5px] font-medium break-all`,children:t.tool}),t.withheld?(0,Q.jsx)(e,{tone:`bad`,icon:`lock`,children:`Held back until reviewed`}):(0,Q.jsx)(e,{tone:`warn`,icon:`refresh`,children:`Changed`})]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Noticed `,x(t.detectedAt),` · last accepted `,x(t.pinnedAt),` by `,t.pinnedBy]})]}),(0,Q.jsx)(A,{size:`sm`,variant:`primary`,icon:`check`,onClick:i,disabled:!n||r,children:`Accept change`})]}),(0,Q.jsx)(`ul`,{className:`mt-3 space-y-1`,children:we(t).map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2 text-[13.5px]`,children:[(0,Q.jsx)(`span`,{className:`mt-[8px] h-1.5 w-1.5 shrink-0 rounded-full bg-warn`,"aria-hidden":!0}),e]},e))}),a&&(0,Q.jsxs)(`details`,{className:`mt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`See what changed`}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[a.effect!==t.now.effect&&(0,Q.jsxs)(`p`,{className:`text-[13.5px]`,children:[`What it does: `,(0,Q.jsx)(`strong`,{children:F[a.effect??`unknown`].label}),` →`,` `,(0,Q.jsx)(`strong`,{children:F[t.now.effect??`unknown`].label})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Description`}),(0,Q.jsx)(O,{before:Se(a.description),after:Se(t.now.description),label:`Description of ${t.tool}, before and after`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Inputs`}),(0,Q.jsx)(O,{before:JSON.stringify(a.inputSchema??{},null,2),after:JSON.stringify(t.now.inputSchema??{},null,2),label:`Inputs of ${t.tool}, before and after`})]}),JSON.stringify(a.annotations)!==JSON.stringify(t.now.annotations)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Hints from its server`}),(0,Q.jsx)(O,{before:JSON.stringify(a.annotations??{},null,2),after:JSON.stringify(t.now.annotations??{},null,2),label:`Hints for ${t.tool}, before and after`})]})]})]})]})}function De(e){return e?e.surface.neverPublished?`This toolbox hasn't reported its tools yet. Start it once, then you can turn tools off here.`:e.surface.live?null:`The toolbox isn't running, so this list can't be confirmed as current. Start the toolbox to turn tools on or off.`:null}function Oe(e){let t=z(),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),o=De(e.protection);async function s(n,i,a){r(n.name);try{let r=await _.setExposure(e.serverId,n.name,i,a,e.tenant);return t.show(`ok`,i?`${n.name} is turned off. Your AI can't see it or use it.`:`${n.name} is back on. The normal rules decide what it may do.`),r.warning&&t.show(`warn`,Z(r.warning)),e.onChanged(),!0}catch(e){return t.show(`bad`,`${n.name} was not changed. ${Z(e)}`),!1}finally{r(null)}}function c(e,t,n=``){let r=q(e);!t&&(r===`write`||r===`destructive`)?a({tool:e,reason:n}):s(e,t,n)}let l=i,u=l?l.tool.verdict.kind===`allow`?`run freely, without asking anyone`:l.tool.verdict.kind===`approve`?`ask you first every time`:`still be blocked`:``;return{blocked:o,busy:e=>n===e,set:c,dialog:(0,Q.jsx)(R,{open:l!==null,onClose:()=>a(null),title:l?`Turn ${l.tool.name} back on?`:``,description:`Turning a tool on doesn't allow it. It goes back to following your normal rules.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{variant:`secondary`,onClick:()=>a(null),children:`Keep it off`}),(0,Q.jsx)(A,{variant:`primary`,icon:`power`,loading:n===l?.tool.name,onClick:async()=>{l&&await s(l.tool,!1,l.reason)&&a(null)},children:`Turn tool on`})]}),children:l&&(0,Q.jsxs)(`div`,{className:`space-y-3 text-[14px] text-muted`,children:[(0,Q.jsxs)(`p`,{children:[`This tool `,q(l.tool)===`destructive`?`deletes things`:`makes changes`,`. Under your rules today it would `,(0,Q.jsx)(`strong`,{className:`text-ink`,children:u}),` (`,M(l.tool.verdict.kind),`).`]}),(0,Q.jsx)(`p`,{children:`The change is written to the activity log and takes effect on the next call.`})]})})}}var ke=[{value:`deny`,label:`Block them`,hint:`A tool nobody has labelled can't run at all until someone says what it does.`,icon:`x`},{value:`approve`,label:`Ask me first`,hint:`Each call to an unlabelled tool waits for you to approve it, so a new tool is a question rather than a wall.`,icon:`clock`}];function Ae({open:e,serverId:t,tenant:n,protection:r,onClose:i,onSaved:a,onReload:o}){let s=z(),l=r.onUnclassified===`approve`?`approve`:`deny`,[u,d]=(0,W.useState)(l),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),v=r.policyWrite,y=r.surface.unclassifiedCount;async function b(){p(!0),h(null);try{let e=await _.setUnclassifiedPosture(t,u,v.digest,n);s.show(`ok`,u===`approve`?`Unlabelled tools now ask you first. The toolbox applies this within about a second.`:`Unlabelled tools are now blocked. The toolbox applies this within about a second.`),e.warning&&s.show(`warn`,X(e.warning)),a(),i()}catch(e){h({text:be(e)?xe:Z(e),stale:be(e)})}finally{p(!1)}}return(0,Q.jsx)(R,{open:e,onClose:i,title:`What happens to unlabelled tools`,description:(0,Q.jsxs)(Q.Fragment,{children:[`A tool is unlabelled when nobody has said whether it looks, makes changes or deletes.`,` `,y>0?`${y===1?`One tool on this toolbox is`:`${y} tools on this toolbox are`} unlabelled right now.`:`Every tool on this toolbox is labelled right now, so this only affects tools that appear later.`]}),width:560,footer:(0,Q.jsxs)(Q.Fragment,{children:[m?.stale&&(0,Q.jsx)(A,{variant:`ghost`,icon:`refresh`,className:`mr-auto`,onClick:()=>{h(null),o()},children:`Reload`}),(0,Q.jsx)(A,{variant:`secondary`,onClick:i,disabled:f,children:`Cancel`}),(0,Q.jsx)(A,{variant:`primary`,onClick:()=>void b(),disabled:!v.ok||u===l,loading:f,children:`Save setting`})]}),children:(0,Q.jsxs)(`div`,{className:`space-y-4 text-[14px]`,children:[(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`What happens to unlabelled tools`,className:`space-y-2`,children:ke.map(e=>{let t=u===e.value;return(0,Q.jsxs)(`label`,{className:B(`flex cursor-pointer gap-3 rounded-[18px] border-[1.5px] p-4 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--focus)]`,t?`border-primary bg-ok-tint`:`border-line hover:border-[var(--soft)]`),children:[(0,Q.jsx)(`input`,{type:`radio`,name:`unlabelled`,checked:t,onChange:()=>d(e.value),className:`sr-only`}),(0,Q.jsx)(g,{name:e.icon,size:20,strokeWidth:2,className:B(`mt-0.5 shrink-0`,t?`text-ok`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold`,children:[e.label,e.value===l&&(0,Q.jsx)(`span`,{className:`text-[12px] font-medium text-soft`,children:`current setting`})]}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[13px] text-soft`,children:e.hint})]})]},e.value)})}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Either way, nothing unlabelled runs without you. Labelling a tool, from its panel, is how it starts following your normal rules. `,(0,Q.jsx)(`code`,{className:`font-mono text-[11.5px]`,children:`defaults.on_unclassified`})]}),!v.ok&&(0,Q.jsx)(c,{tone:`warn`,title:`This toolbox's settings can't be changed from here`,children:X(v.why??`The settings file is not writable.`)}),m&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:m.text})]})})}var je=[`max`,`min`,`enum`,`maxLength`,`maxItems`,`within`,`host`];function Me(e){let t={};for(let[n,r]of Object.entries(e??{})){let e={},i={};for(let[t,n]of Object.entries(r))je.includes(t)?e[t]=t===`enum`?n.map(String):n:t!==`optional`&&(i[t]=n);t[n]={values:e,optional:r.optional===!0,carried:i}}return t}function Ne(e){return e==null||e===``||Array.isArray(e)&&e.length===0}function Pe(e){return Object.values(e).some(e=>Object.values(e.values).some(Ne))}function Fe(e,t){return e.map(e=>(t===`number`||t===`integer`)&&e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):t===`boolean`&&(e===`true`||e===`false`)?e===`true`:e)}function Ie(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t.args.find(e=>e.name===r)?.type,a={...i.carried};for(let[t,n]of Object.entries(i.values))Ne(n)||(a[t]=t===`enum`?Fe(n,e):t===`within`?n.trim():n);Object.keys(a).length!==0&&(i.optional&&(a.optional=!0),n[r]=a)}return n}function Le({tool:e,draft:t,setDraft:n,onViolation:r,setOnViolation:i,unknownArgs:o,setUnknownArgs:s}){let[c,l]=(0,W.useState)(``),u=[...new Set([...e.args.map(e=>e.name),...Object.keys(t)])],d=(e,r)=>{let i=t[e]??{values:{},optional:!1,carried:{}};n({...t,[e]:r(i)})},p=(e,t,n)=>d(e,e=>{let r={...e.values};return n===void 0?delete r[t]:r[t]=n,{...e,values:r}});return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[u.length===0&&(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken p-4 text-[13.5px] text-soft`,children:`This tool takes no inputs, so there is nothing to limit.`}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:u.map(n=>{let r=e.args.find(e=>e.name===n),i=t[n],a=Object.keys(i?.values??{}),o=he(r?.type).filter(e=>!a.includes(e));return(0,Q.jsxs)(`li`,{className:`rounded-2xl border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-[13.5px] font-medium break-all`,children:n}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[r?.type??`any type`,` · `,r?r.required?`required`:`optional`:`nested input`]})]}),r?.description&&(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[12.5px] text-soft`,children:r.description}),a.length>0&&(0,Q.jsx)(`div`,{className:`mt-3 space-y-2.5`,children:a.map(e=>(0,Q.jsx)(Re,{path:n,limit:e,value:i.values[e]??null,onChange:t=>p(n,e,t),onRemove:()=>p(n,e,void 0)},e))}),Object.keys(i?.carried??{}).length>0&&(0,Q.jsxs)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:[`Also kept as written in the settings file:`,` `,(0,Q.jsx)(`code`,{className:`font-mono`,children:Object.keys(i.carried).join(`, `)})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[o.length>0&&(0,Q.jsx)(re,{"aria-label":`Add a limit to ${n}`,value:``,className:`w-56`,onChange:e=>{e&&p(n,e,e===`enum`||e===`host`?[]:e===`within`?``:null)},options:[{value:``,label:`Add a limit…`},...o.map(e=>({value:e,label:Y[e]}))]}),a.length>0&&r&&!r.required&&(0,Q.jsx)(L,{checked:i?.optional===!0,onChange:e=>d(n,t=>({...t,optional:e})),label:`It's fine to leave this input out`})]})]},n)})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,Q.jsx)(a,{label:`Limit a nested input`,className:`min-w-0 flex-1 basis-56`,children:(0,Q.jsx)(f,{value:c,onChange:l,mono:!0,placeholder:`items[].qty`,onEnter:()=>m()})}),(0,Q.jsx)(A,{icon:`plus`,disabled:c.trim()===``||u.includes(c.trim()),onClick:m,children:`Add input`})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[12.5px] text-soft`,children:`For a value inside a list or object, such as items[].qty.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)(a,{label:`If a call breaks a limit`,technical:`on_violation`,children:(0,Q.jsx)(h,{label:`If a call breaks a limit`,value:r,onChange:i,options:[{value:`deny`,label:`Block it`},{value:`approve`,label:`Ask me`}]})}),(0,Q.jsx)(a,{label:`Inputs no limit mentions`,technical:`unknown_args`,children:(0,Q.jsx)(h,{label:`Inputs no limit mentions`,value:o,onChange:s,options:[{value:`allow`,label:`Allow`},{value:`approve`,label:`Ask me`},{value:`deny`,label:`Block`}]})})]})]});function m(){let e=c.trim();e&&!u.includes(e)&&(n({...t,[e]:{values:{max:null},optional:!1,carried:{}}}),l(``))}}function Re({path:e,limit:n,value:r,onChange:a,onRemove:o}){let s=`${Y[n]} (${e})`,c;return c=n===`enum`||n===`host`?(0,Q.jsx)(t,{"aria-label":s,value:r??[],onChange:a,placeholder:n===`host`?`example.com, or .example.com for every address under it`:`Type a value and press Enter`,validate:n===`host`?e=>/[\s/:]/.test(e)?`Type just the website name, such as example.com`:null:void 0}):n===`within`?(0,Q.jsx)(f,{"aria-label":s,value:r??``,onChange:a,mono:!0,placeholder:`/Users/you/project`}):(0,Q.jsx)(i,{"aria-label":s,value:r??null,onChange:a,min:n===`maxLength`?1:n===`maxItems`?0:void 0,step:n===`maxLength`||n===`maxItems`?1:void 0,unit:n===`maxLength`?`chars`:n===`maxItems`?`items`:void 0}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-start gap-x-2 gap-y-1 sm:grid-cols-[176px_1fr_auto] sm:items-center`,children:[(0,Q.jsx)(`span`,{className:`col-span-2 text-[13px] font-semibold sm:col-span-1`,children:Y[n]}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:c}),(0,Q.jsx)(k,{icon:`x`,label:`Remove ${Y[n].toLowerCase()} from ${e}`,size:34,onClick:o})]})}var ze=[{value:`read`,label:`Looks only`,hint:`Reads or looks things up. Changes nothing.`,icon:`eye`},{value:`write`,label:`Makes changes`,hint:`Creates, edits, sends or adds something.`,icon:`edit`},{value:`destructive`,label:`Deletes`,hint:`Removes something, or does what can't be undone.`,icon:`trash`}],Be=[{value:`allow`,label:`Run freely`,hint:`Nobody is asked.`,icon:`check`},{value:`approve`,label:`Ask me first`,hint:`Every call waits for you to approve it.`,icon:`clock`},{value:`deny`,label:`Block it`,hint:`Every call is refused.`,icon:`x`}];function Ve({open:e,serverId:t,tenant:n,tool:r,protection:i,onClose:o,onSaved:s}){let l=z(),[u,d]=(0,W.useState)(q(r)),[p,m]=(0,W.useState)(q(r)===null?null:r.verdict.kind),[h,g]=(0,W.useState)(``),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(()=>Me(r.bounds?.constraints)),[S,C]=(0,W.useState)(r.bounds?.onViolation??`deny`),[T,te]=(0,W.useState)(r.bounds?.unknownArgs??`allow`),[D,O]=(0,W.useState)(!1),[ne,k]=(0,W.useState)(!1),[re,j]=(0,W.useState)(!1),[N,P]=(0,W.useState)(null),[ie,F]=(0,W.useState)(null),[ae,I]=(0,W.useState)(0),[L,oe]=(0,W.useState)(!1),[B,V]=(0,W.useState)(null),[se,ce]=(0,W.useState)(null),le=Object.values((N?.preview.bounds??r.bounds)?.constraints??{}).some(e=>ge(e)),H=(0,W.useMemo)(()=>{if(!u||!p)return null;let e={tool:r.name,effect:u,decision:p};return h.trim()&&(e.reason=h.trim()),v&&(e.args=Ie(b,r),e.on_violation=S,e.unknown_args=T),e},[r,u,p,h,v,b,S,T]),U=ee(H?JSON.stringify(H):``,350);(0,W.useEffect)(()=>{if(!e||!U){P(null);return}let r=!0;return F(null),_.toolRulePreview(t,JSON.parse(U),n).then(e=>{r&&(P({key:U,preview:e}),v||(x(Me(e.bounds?.constraints)),C(e.bounds?.onViolation??`deny`),te(e.bounds?.unknownArgs??`allow`)))}).catch(e=>r&&F(Z(e))),()=>{r=!1}},[e,U,t,n,ae]);let ue=H?JSON.stringify(H):``,G=N&&N.key===ue?N.preview:null,de=G!==null,K=N?.preview??null,J=K?K.bounds:r.bounds,fe=G?.overriddenReason!=null,pe=fe&&G?.overridesAllowed===!1,me=G?.dropsBounds!=null,Y=u===`destructive`&&p===`allow`,he=v&&Pe(b),_e=G?.writable.ok===!1,ye=G!==null&&de&&!ie&&!L&&!_e&&!pe&&!he&&(!fe||D)&&(!me||ne)&&(!Y||re);async function Se(){if(G&&H){oe(!0),V(null);try{let e=await _.setToolRule(t,{...H,expectedDigest:G.expectedDigest,acknowledged:{...fe?{overrideDeny:G.overriddenReason.ruleId}:{},...me?{dropBounds:!0}:{},...Y?{destructiveAllow:!0}:{}}},n);ce({yaml:e.yaml,reloads:G.reloads}),l.show(`ok`,`Saved what ${r.name} may do.`),e.warning&&l.show(`warn`,X(e.warning)),s()}catch(e){be(e)?(V({text:xe,stale:!0}),P(null),I(e=>e+1)):V({text:Z(e),stale:!1})}finally{oe(!1)}}}if(se)return(0,Q.jsx)(R,{open:e,onClose:o,title:`Saved`,width:600,footer:(0,Q.jsx)(A,{variant:`primary`,onClick:o,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`space-y-4 text-[14px]`,children:[(0,Q.jsxs)(`p`,{className:`text-muted`,children:[`The rule for `,(0,Q.jsx)(`code`,{className:`font-mono text-ink`,children:r.name}),` is in your protection settings.`,` `,se.reloads?`The running gateway applies it within about a second. No restart is needed.`:`This toolbox only reads its settings when it starts, so restart it to apply this.`]}),(0,Q.jsxs)(`details`,{className:`group`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show what was written`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(E,{label:`The rule that was written`,children:se.yaml})})]})]})});let Ce=G?.approvalsReachable===!1;return(0,Q.jsx)(R,{open:e,onClose:o,title:(0,Q.jsxs)(Q.Fragment,{children:[`Change what `,(0,Q.jsx)(`span`,{className:`font-mono text-[0.9em]`,children:r.name}),` may do`]}),description:`Your answer is saved as a rule in your protection settings.`,width:720,footer:(0,Q.jsxs)(Q.Fragment,{children:[B?.stale&&(0,Q.jsx)(A,{variant:`ghost`,icon:`refresh`,onClick:()=>I(e=>e+1),className:`mr-auto`,children:`Reload preview`}),(0,Q.jsx)(A,{variant:`secondary`,onClick:o,disabled:L,children:`Cancel`}),(0,Q.jsx)(A,{variant:`primary`,onClick:()=>void Se(),disabled:!ye,loading:L,children:`Save rule`})]}),children:(0,Q.jsxs)(`div`,{className:`space-y-6 pb-1 text-[14px]`,children:[i?.tenant&&(0,Q.jsx)(c,{tone:`info`,title:`This applies to every customer`,children:`A rule changes the protection settings, which every customer of this toolbox shares. Turning a tool off is the only change kept for one customer.`}),r.injection&&r.injection.length>0&&(0,Q.jsx)(c,{tone:`danger`,title:`Judge this tool by its name and inputs`,children:`Its description carried hidden instructions written to steer whoever reads it, so it isn't repeated here.`}),(0,Q.jsx)(He,{legend:`What does this tool do?`,name:`rule-effect`,value:u,onChange:d,options:ze}),(0,Q.jsx)(He,{legend:`What should happen when your AI uses it?`,name:`rule-decision`,value:p,onChange:m,options:Be.map(e=>e.value===`approve`&&Ce?{...e,disabled:!0,hint:`Approvals are switched off on this toolbox, so nobody could answer.`}:e)}),(0,Q.jsxs)(`section`,{className:`rounded-[20px] bg-sunken/60 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[`Limits on its inputs `,(0,Q.jsx)(w,{term:`limits`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-soft`,children:le?`These limits include one written into the settings file by hand that can't be edited here. They are kept exactly as they are.`:v?`Set the values this tool may be called with.`:J?K?.carriedFrom?`Carried over from the rule ${K.carriedFrom}, which governs it today: ${ve(J).join(`; `)}.`:`Kept as they are: ${ve(J).join(`; `)}.`:`None. Every input is passed on as your AI sends it.`})]}),!v&&!le&&(0,Q.jsx)(A,{size:`sm`,icon:J?`edit`:`plus`,onClick:()=>y(!0),children:J?`Edit limits`:`Add limits on its inputs`})]}),v&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(Le,{tool:r,draft:b,setDraft:x,onViolation:S,setOnViolation:C,unknownArgs:T,setUnknownArgs:te}),he&&(0,Q.jsx)(`p`,{className:`mt-3 text-[13px] font-medium text-warn`,children:`Fill in every limit you added, or remove it.`})]})]}),(0,Q.jsx)(a,{label:`Reason`,optional:!0,help:`Saved with the rule and in the activity log. When a call is blocked, your AI is told this reason.`,children:(0,Q.jsx)(f,{value:h,onChange:g,placeholder:`For example: finance signs these off by hand`})}),(0,Q.jsx)(Ue,{tool:r,preview:G,loading:H!==null&&G===null&&!ie,error:ie,incomplete:H===null}),G&&de&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[_e&&(0,Q.jsx)(c,{tone:`warn`,title:`This toolbox's settings can't be changed from here`,children:X(G.writable.why??`The settings file is not writable.`)}),pe?(0,Q.jsxs)(c,{tone:`info`,title:`This toolbox doesn't allow reversing a rule from here`,children:[`The rule `,(0,Q.jsx)(`code`,{className:`font-mono`,children:G.overriddenReason.ruleId}),` stays as it is. It can only be changed in the settings file itself.`]}):fe&&(0,Q.jsxs)(Ke,{title:`This reverses a rule somebody wrote`,checked:D,onChange:O,label:`Reverse the rule ${G.overriddenReason.ruleId} anyway`,children:[`The rule `,(0,Q.jsx)(`code`,{className:`font-mono`,children:G.overriddenReason.ruleId}),` says`,` `,(0,Q.jsx)(`strong`,{children:M(G.overriddenReason.decision).toLowerCase()}),` for this tool`,G.overriddenReason.reason?(0,Q.jsxs)(Q.Fragment,{children:[`, because: “`,G.overriddenReason.reason,`”`]}):`.`]}),me&&(0,Q.jsxs)(Ke,{title:`This removes the limits on its inputs`,checked:ne,onChange:k,label:`Remove the limits on its inputs`,children:[`Today: `,ve(G.currentBounds).join(`; `)||`limited`,`. After this, nothing checks what the tool is called with.`]}),Y&&(0,Q.jsx)(Ke,{title:`Your AI could delete things without asking`,checked:re,onChange:j,label:`Let a tool that deletes things run with nobody asked`,children:`“Ask me first” keeps it just as usable, with you approving each call.`})]}),B&&(0,Q.jsx)(c,{tone:`danger`,role:`alert`,title:B.stale?`Not saved`:`The toolbox refused this change`,children:B.text})]})})}function He({legend:e,name:t,value:n,onChange:r,options:i}){return(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{className:`mb-2.5 text-[15px] font-semibold`,children:e}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:i.map(e=>{let i=n===e.value;return(0,Q.jsxs)(`label`,{className:B(`relative flex cursor-pointer flex-col gap-1 rounded-[18px] border-[1.5px] p-3.5 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--focus)]`,i?`border-primary bg-ok-tint`:`border-line hover:border-[var(--soft)]`,e.disabled&&`cursor-not-allowed opacity-55`),children:[(0,Q.jsx)(`input`,{type:`radio`,name:t,value:e.value,checked:i,disabled:e.disabled,onChange:()=>r(e.value),className:`sr-only`}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold`,children:[(0,Q.jsx)(g,{name:e.icon,size:17,strokeWidth:2,className:i?`text-ok`:`text-soft`}),e.label,i&&(0,Q.jsx)(g,{name:`check`,size:16,strokeWidth:2.4,className:`ml-auto text-ok`})]}),(0,Q.jsx)(`span`,{className:`text-[12.5px] leading-snug text-soft`,children:e.hint})]},e.value)})})]})}function Ue({tool:e,preview:t,loading:n,error:r,incomplete:i}){return(0,Q.jsxs)(`section`,{"aria-live":`polite`,className:`rounded-[20px] border-[1.5px] border-line p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:`What changes`}),i?(0,Q.jsx)(`p`,{className:`mt-2 text-[13.5px] text-soft`,children:`Answer both questions above to see what changes.`}):r?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-[13.5px] font-medium text-bad`,children:r}):n||!t?(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(s,{lines:3})}):(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:`Now`}),(0,Q.jsx)(D,{decision:t.current.kind}),(0,Q.jsx)(g,{name:`arrow-right`,size:18,className:`text-soft`,label:`becomes`}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:`After`}),(0,Q.jsx)(D,{decision:t.verdict.kind})]}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:We(e.name,t)}),(0,Q.jsx)(Ge,{preview:t}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the rule that will be written`}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,Q.jsx)(E,{label:`The rule that will be written`,children:t.yaml}),t.policyPath&&(0,Q.jsx)(`p`,{className:`font-mono text-[11.5px] break-all text-soft`,children:t.policyPath})]})]})]})]})}function We(e,t){let n=`After saving, every call to ${e} ${t.verdict.kind===`allow`?`runs freely`:t.verdict.kind===`approve`?`asks you first`:`is blocked`}`;return t.bounds&&t.verdict.kind!==`deny`?n+=` while its inputs stay within limits (${ve(t.bounds).join(`; `)}). A call outside them ${t.bounds.onViolation===`approve`?`asks you first`:`is blocked`}. ${ye[t.bounds.unknownArgs]}`:n+=`.`,n}function Ge({preview:e}){let t=[];return e.loosens&&t.push({key:`loosens`,tone:`warn`,text:`This lets your AI do more with this tool than it can today. The safety check will point this out if a tool that changes or deletes things runs without asking.`}),e.overridden&&t.push({key:`overridden`,tone:`warn`,text:X(e.overridden)}),e.nameContradiction&&t.push({key:`name`,tone:`warn`,text:X(e.nameContradiction)}),e.strandedRule&&t.push({key:`stranded`,tone:`info`,text:(0,Q.jsxs)(Q.Fragment,{children:[`The rule `,(0,Q.jsx)(`code`,{className:`font-mono`,children:e.strandedRule}),` no longer applies to any tool after this. It stays in your settings, and undoing this change brings it back.`]})}),e.reloads||t.push({key:`reload`,tone:`info`,text:`This toolbox only reads its settings when it starts, so this applies after a restart.`}),t.length===0?null:(0,Q.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:B(`flex gap-2.5 rounded-2xl px-3.5 py-2.5 text-[13px]`,e.tone===`warn`?`bg-warn-tint`:`bg-info-tint`),children:[(0,Q.jsx)(g,{name:e.tone===`warn`?`warning`:`info`,size:16,strokeWidth:2,className:B(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsx)(`span`,{className:`text-ink`,children:e.text})]},e.key))})}function Ke({title:e,children:t,checked:n,onChange:r,label:i}){return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border-[1.5px] border-bad/45 bg-bad-tint/50 p-4`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 font-semibold text-bad`,children:[(0,Q.jsx)(g,{name:`warning`,size:17,strokeWidth:2}),e]}),(0,Q.jsx)(`div`,{className:`mt-1 text-[13.5px] text-muted`,children:t}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(L,{checked:n,onChange:r,label:i})})]})}function qe({name:e,serverId:t,tenant:n,protection:r,listTool:i,version:a,nav:o,exposure:l,ruleBlocked:u,onClose:d,onEditRule:f,onPosture:p,onChanged:m}){let{data:h,error:g,loading:v,reload:b}=ae(()=>e?_.tool(t,e,n):Promise.resolve(null),[t,e,n,a]),x=h&&h.name===e?h:null,S=x??i;return(0,Q.jsx)(y,{open:e!==null,onClose:d,width:620,title:(0,Q.jsx)(`span`,{className:`font-mono text-[18px] break-all`,children:e}),subtitle:S?(0,Q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(C,{effect:q(S),withLabel:!0}),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Q.jsxs)(`span`,{children:[`on `,(0,Q.jsx)(`span`,{className:`font-medium text-muted`,children:S.upstream})]}),(0,Q.jsx)(w,{term:`connectedServer`})]}):void 0,children:g&&!S?(0,Q.jsx)(c,{tone:`danger`,title:`This tool couldn't be loaded`,actions:(0,Q.jsx)(A,{size:`sm`,icon:`refresh`,onClick:b,children:`Try again`}),children:Z(g)}):S?(0,Q.jsxs)(`div`,{className:`space-y-8`,children:[(0,Q.jsx)(Je,{tool:S}),(0,Q.jsx)(Ye,{tool:S,protection:r,serverId:t,tenant:n,ruleBlocked:u,onEditRule:()=>f(S),onPosture:p,onChanged:m}),(0,Q.jsx)(Qe,{tool:S}),(0,Q.jsx)($e,{tool:S,loading:v&&!x}),(0,Q.jsx)(et,{tool:S,nav:o}),(0,Q.jsx)(tt,{tool:x,loading:v&&!x,nav:o}),(0,Q.jsx)(nt,{tool:S,exposure:l,perCustomer:!!r?.tenant},S.name)]}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(s,{height:20,lines:3}),(0,Q.jsx)(s,{height:40}),(0,Q.jsx)(s,{lines:4})]})})}function $({title:e,aside:t,children:n}){return(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`header`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`flex items-center gap-2 text-[16px] font-semibold tracking-[-0.01em]`,children:e}),t]}),n]})}function Je({tool:e}){let t=e.rawDescription!==e.description,n=e.injection??[],r=n.length>0&&!e.hiddenByPolicy&&!t;return(0,Q.jsxs)($,{title:`What it does`,children:[(0,Q.jsx)(`p`,{className:`text-[14.5px] whitespace-pre-wrap text-ink`,children:e.description||(0,Q.jsx)(`span`,{className:`text-soft italic`,children:`The connected server gave no description.`})}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[12.5px] text-soft`,children:`This is the description your AI sees.`}),n.length>0&&(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(c,{tone:r?`info`:`danger`,title:e.hiddenByPolicy?`Hidden instructions found, so the tool is hidden`:r?`Hidden instructions found, and accepted after review`:`Hidden instructions found and removed`,children:[`The connected server's description contained text aimed at your AI rather than at you, such as telling it to ignore its rules.`,` `,e.hiddenByPolicy?`The toolbox keeps this tool away from your AI entirely.`:r?`Someone reviewed it and chose to pass the text through unchanged. It doesn't change what the tool may do.`:`The toolbox changed the description before your AI saw it.`,(0,Q.jsx)(`span`,{className:`mt-1.5 block font-mono text-[11.5px] text-soft`,children:n.map(e=>ne(e)===e?e:`${e} (${ne(e)})`).join(`, `)})]})}),t&&(0,Q.jsxs)(`details`,{className:`mt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show original`}),(0,Q.jsx)(`p`,{className:`mt-2 mb-2 text-[12.5px] text-soft`,children:`What the connected server sent (removed lines) and what your AI sees instead (added lines).`}),(0,Q.jsx)(O,{before:Se(e.rawDescription),after:Se(e.description),label:`Original and shown description`})]})]})}function Ye({tool:e,protection:t,serverId:n,tenant:r,ruleBlocked:i,onEditRule:a,onPosture:o,onChanged:s}){let[l,u]=(0,W.useState)(!1),d=e.effect===null&&!e.reclassifiedTo,f=e.exposure.disabled?`deny`:e.verdict.kind;return(0,Q.jsxs)($,{title:`What it's allowed to do`,children:[(0,Q.jsxs)(`div`,{className:`rounded-[20px] bg-sunken/70 p-5`,children:[(0,Q.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,Q.jsx)(D,{decision:f,label:e.exposure.disabled?`Turned off`:void 0})}),(0,Q.jsx)(`p`,{className:`display mt-3 text-[22px] leading-snug`,children:fe(e)}),t?.enforcement===`observe`&&e.verdict.kind!==`allow`&&!e.exposure.disabled&&(0,Q.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:`That starts once protection is on. Your toolbox is only watching now, so for the moment it runs.`}),!e.exposure.disabled&&(0,Q.jsxs)(`dl`,{className:`mt-4 space-y-2 text-[13.5px]`,children:[(0,Q.jsxs)(Xe,{label:`Why`,children:[pe(e.verdict,t?.defaults.mode??null),(0,Q.jsx)(`code`,{className:`mt-0.5 block font-mono text-[11.5px] break-all text-soft`,children:e.verdict.ruleId})]}),(0,Q.jsxs)(Xe,{label:`Labelled as`,children:[F[q(e)??`unknown`].label,`.`,` `,(0,Q.jsx)(`span`,{className:`text-soft`,children:me[e.effectSource]??e.effectSource}),e.reclassifiedTo&&e.effect&&(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-soft`,children:[`The connected server calls it “`,F[e.effect]?.label??e.effect,`”; a rule changed that.`]})]}),e.consoleRule&&(0,Q.jsx)(Xe,{label:`Set by`,children:`You, from this console. Use “Undo my change” to remove it.`})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,Q.jsx)(A,{variant:`primary`,icon:`sliders`,onClick:a,disabled:i!==null,children:`Change what it may do`}),e.consoleRule&&(0,Q.jsx)(A,{icon:`refresh`,onClick:()=>u(!0),disabled:i!==null,children:`Undo my change`}),d&&(0,Q.jsx)(A,{variant:`ghost`,onClick:o,children:`Change the setting for unlabelled tools`})]}),i&&(0,Q.jsx)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:i})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[t?.runtime.policyApplied===!1&&(0,Q.jsxs)(c,{tone:`warn`,title:`The running gateway hasn't picked up the latest settings`,children:[`What's shown here is the settings file. The toolbox still uses the version it read when it started`,` `,t.runtime.startedAt?x(t.runtime.startedAt):`earlier`,`. Restart it to apply the newer one.`]}),e.boundsDrift&&(0,Q.jsxs)(c,{tone:`info`,title:`These limits no longer match the rule they were copied from`,children:[`When this rule was saved it copied the limits from`,` `,(0,Q.jsx)(`code`,{className:`font-mono text-[12px]`,children:e.boundsDrift.ruleId}),`. That rule has changed since:`,(0,Q.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5`,children:e.boundsDrift.differences.map(e=>(0,Q.jsx)(`li`,{children:X(e)},e))}),(0,Q.jsx)(`span`,{className:`mt-1.5 block`,children:`This tool still follows its own copy. Change what it may do to take the newer limits, or leave it if these are the ones you want.`})]})]}),l&&(0,Q.jsx)(Ze,{serverId:n,tenant:r,tool:e,protection:t,onClose:()=>u(!1),onDone:()=>{u(!1),s()}})]})}function Xe({label:e,children:t}){return(0,Q.jsxs)(`div`,{className:`grid gap-x-4 gap-y-0.5 sm:grid-cols-[110px_1fr]`,children:[(0,Q.jsx)(`dt`,{className:`font-semibold text-soft`,children:e}),(0,Q.jsx)(`dd`,{className:`min-w-0 text-ink`,children:t})]})}function Ze({serverId:e,tenant:t,tool:n,protection:r,onClose:i,onDone:a}){let o=z(),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(0);(0,W.useEffect)(()=>{let r=!0;return u(null),_.clearPreview(e,n.name,t).then(e=>r&&u(e),e=>r&&f({text:Z(e),stale:!1})),()=>{r=!1}},[e,n.name,t,h]);async function v(){if(l){m(!0),f(null);try{let r=await _.clearToolRule(e,n.name,l.expectedDigest,t);o.show(`ok`,`Your change to ${n.name} is undone. The toolbox applies it within about a second.`),r.warning&&o.show(`warn`,X(r.warning)),a()}catch(e){f({text:be(e)?xe:Z(e),stale:be(e)})}finally{m(!1)}}}let y=l?.verdict.kind===`allow`?`run freely`:l?.verdict.kind===`approve`?`ask you first`:`be blocked`;return(0,Q.jsx)(R,{open:!0,onClose:i,title:`Undo your change to ${n.name}?`,description:`This removes the rule you saved here. The tool goes back to whatever your other settings say.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[d?.stale&&(0,Q.jsx)(A,{variant:`ghost`,icon:`refresh`,className:`mr-auto`,onClick:()=>{f(null),g(e=>e+1)},children:`Reload`}),(0,Q.jsx)(A,{variant:`secondary`,onClick:i,disabled:p,children:`Keep my change`}),(0,Q.jsx)(A,{variant:`primary`,onClick:()=>void v(),disabled:!l,loading:p,children:`Undo change`})]}),children:(0,Q.jsxs)(`div`,{className:`space-y-3 text-[14px]`,children:[!l&&!d&&(0,Q.jsx)(s,{lines:3}),l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:`Afterwards it will`}),(0,Q.jsx)(D,{decision:l.verdict.kind})]}),(0,Q.jsxs)(`p`,{className:`text-muted`,children:[`Every call to `,(0,Q.jsx)(`code`,{className:`font-mono text-ink`,children:n.name}),` will `,y,l.verdict.ruleId.startsWith(`defaults.`)?`, by your default settings`:``,`.`,l.bounds?` Limits: ${ve(l.bounds).join(`; `)}.`:``]}),l.becomesUnclassified&&(0,Q.jsx)(c,{tone:`warn`,title:`Nothing else says what this tool does`,children:`Your change was the only label on this tool. Without it, it is treated as not labelled again.`}),r?.tenant&&(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`This affects every customer of this toolbox.`}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the rule being removed`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(E,{label:`The rule being removed`,children:l.yaml})})]})]}),d&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:d.text})]})})}function Qe({tool:e}){let t=e.bounds;return(0,Q.jsx)($,{title:(0,Q.jsxs)(Q.Fragment,{children:[`Limits on its inputs `,(0,Q.jsx)(w,{term:`limits`})]}),children:t?(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Q.jsx)(`ul`,{className:`space-y-1.5`,children:t.paths.map((e,n)=>(0,Q.jsxs)(`li`,{className:`flex gap-2.5 text-[14px]`,children:[(0,Q.jsx)(`span`,{className:`mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--soft)]`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`code`,{className:`font-mono text-[13px] font-medium`,children:e}),` `,ve(t)[n].slice(e.length+1)]})]},e))}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`A call that breaks a limit `,t.onViolation===`approve`?`asks you first`:`is blocked`,`.`,` `,ye[t.unknownArgs]]}),(0,Q.jsx)(`p`,{className:`font-mono text-[11.5px] text-soft`,children:t.ruleId})]}):(0,Q.jsx)(`p`,{className:`text-[14px] text-soft`,children:`No limits. Every input is passed on as your AI sends it.`})})}function $e({tool:t,loading:n}){return(0,Q.jsxs)($,{title:`Inputs`,children:[t.args.length===0?(0,Q.jsx)(`p`,{className:`text-[14px] text-soft`,children:`This tool takes no inputs.`}):(0,Q.jsx)(`ul`,{className:`divide-y divide-faint rounded-[18px] border border-line`,children:t.args.map(t=>(0,Q.jsxs)(`li`,{className:`px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`code`,{className:`font-mono text-[13.5px] font-medium break-all`,children:t.name}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[t.type??`any type`,t.format?`, ${t.format}`:``,` · `,t.required?`required`:`optional`]}),t.constrainedByRule&&(0,Q.jsx)(e,{tone:`neutral`,icon:`sliders`,className:`py-0 text-[11.5px]`,children:`Limited`})]}),t.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted`,children:t.description}),t.enumValues&&(0,Q.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Accepts: `,(0,Q.jsx)(`span`,{className:`font-mono`,children:t.enumValues.join(`, `)})]}),t.defaultValue!==null&&(0,Q.jsxs)(`p`,{className:t.defaultIsUrl?`mt-1 text-[12.5px] text-warn`:`mt-1 text-[12.5px] text-soft`,children:[`If left out: `,(0,Q.jsx)(`span`,{className:`font-mono break-all`,children:t.defaultValue}),t.defaultIsUrl&&` (a web address the connected server contacts on its own; your network limits don't cover it)`]})]},t.name))}),t.schemaClosed===!1&&(0,Q.jsx)(`p`,{className:`mt-2 text-[13px] text-warn`,children:`The connected server accepts inputs beyond the ones listed here, and passes them on as given.`}),(0,Q.jsxs)(`details`,{className:`mt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the full input definition`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:n?(0,Q.jsx)(s,{lines:4}):(0,Q.jsx)(E,{copy:!0,label:`Input definition`,children:JSON.stringify(t.inputSchema??{},null,2)})})]})]})}function et({tool:t,nav:n}){return(0,Q.jsx)($,{title:(0,Q.jsxs)(Q.Fragment,{children:[`Pre-approvals that cover it `,(0,Q.jsx)(w,{term:`preApproval`})]}),aside:(0,Q.jsx)(T,{href:r(n,`/pre-approvals`),size:`sm`,variant:`ghost`,iconRight:`arrow-right`,children:`Open pre-approvals`}),children:t.standingGrants.length===0?(0,Q.jsx)(`p`,{className:`text-[14px] text-soft`,children:`None. When this tool asks first, you decide each call.`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:t.standingGrants.map(t=>(0,Q.jsxs)(`li`,{className:`rounded-[18px] border border-line px-4 py-3 text-[13.5px]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(e,{tone:t.covers?`ok`:`neutral`,icon:t.covers?`check`:`x`,children:t.covers?`Covers this tool`:`Doesn't apply`}),(0,Q.jsxs)(`span`,{className:`text-soft`,children:[t.uses,` of `,t.maxUses??`unlimited`,` uses · ends `,x(t.expiresAt)]})]}),t.reason&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-ink`,children:t.reason}),!t.covers&&(0,Q.jsx)(`p`,{className:`mt-1 text-soft`,children:X(t.why)}),t.covers&&t.heldBounds.length>0&&(0,Q.jsxs)(`p`,{className:`mt-1 text-soft`,children:[`A call that breaks the limit on `,(0,Q.jsx)(`span`,{className:`font-mono`,children:t.heldBounds.join(`, `)}),` still asks you, because this pre-approval doesn't limit that input.`]}),(0,Q.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-soft`,children:t.grantId})]},t.grantId))})})}function tt({tool:t,loading:n,nav:i}){let a=t?.activity??[];return(0,Q.jsx)($,{title:`Recent activity`,aside:t&&(0,Q.jsx)(T,{href:r(i,`/activity`,{tool:t.name}),size:`sm`,variant:`ghost`,iconRight:`arrow-right`,children:`Open activity`}),children:n?(0,Q.jsx)(s,{lines:3}):a.length===0?(0,Q.jsx)(`p`,{className:`text-[14px] text-soft`,children:`Your AI hasn't used this tool yet.`}):(0,Q.jsx)(`ul`,{className:`divide-y divide-faint`,children:a.map(t=>{let n=N[t.outcome];return(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1 py-2.5`,children:[(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-[12.5px] text-soft`,title:l(t.ts),children:x(t.ts)}),(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(D,{decision:t.decision}),n&&(0,Q.jsx)(e,{tone:n.tone,className:`py-0 text-[11.5px]`,children:n.label}),t.observe&&(0,Q.jsx)(e,{tone:`neutral`,className:`py-0 text-[11.5px]`,children:`Watch-only`})]}),t.reason&&(0,Q.jsx)(`span`,{className:`w-full text-[12.5px] text-soft sm:pl-[108px]`,children:X(t.reason)})]},t.id)})})})}function nt({tool:e,exposure:t,perCustomer:n}){let[r,i]=(0,W.useState)(``),o=e.exposure.disabled;return(0,Q.jsx)($,{title:(0,Q.jsxs)(Q.Fragment,{children:[`Turn off this tool `,(0,Q.jsx)(w,{term:`killSwitch`})]}),children:(0,Q.jsxs)(`div`,{className:`space-y-4 rounded-[20px] border border-line p-5`,children:[(0,Q.jsx)(p,{checked:o,onChange:n=>t.set(e,n,n?r.trim():``),disabled:t.blocked!==null||t.busy(e.name),label:o?`This tool is turned off`:`Turn off this tool`,description:o?`Your AI can't see it, and every call is blocked${e.exposure.setBy?`. Turned off by ${e.exposure.setBy}`:``}${e.exposure.setAt?` ${x(e.exposure.setAt)}`:``}.`:`Hides it from your AI and blocks every call, even in watch-only mode.`}),o&&e.exposure.reason&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Reason given: `,(0,Q.jsx)(`span`,{className:`text-ink`,children:e.exposure.reason})]}),!o&&(0,Q.jsx)(a,{label:`Reason`,optional:!0,help:`Saved in the activity log with the change.`,children:(0,Q.jsx)(f,{value:r,onChange:i,placeholder:`For example: misbehaving since the last update`,disabled:t.blocked!==null})}),(0,Q.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[`Turning it back on returns it to your normal rules. It never makes it allowed on its own`,e.exposure.policyWouldExpose?`.`:`: your rules block this tool anyway.`,n&&` This switch is kept separately for each customer.`]}),t.blocked&&(0,Q.jsx)(c,{tone:`warn`,title:`Not available right now`,children:t.blocked})]})})}function rt({tools:e,changed:t,selected:n,onOpen:r,exposure:i}){return(0,Q.jsx)(`ul`,{className:`divide-y divide-faint`,children:e.map(e=>(0,Q.jsx)(at,{tool:e,changed:t.has(e.name),selected:n===e.name,onOpen:()=>r(e.name),exposure:i},e.name))})}var it={read:`bg-ok-tint`,write:`bg-warn-tint`,destructive:`bg-bad-tint`,unknown:`bg-sunken`};function at({tool:t,changed:n,selected:r,onOpen:i,exposure:a}){let o=K(t),s=q(t),c=t.exposure.disabled,l=a.busy(t.name);return(0,Q.jsxs)(`li`,{onClick:i,className:B(`-mx-3 flex cursor-pointer flex-wrap items-center gap-x-4 gap-y-2 rounded-2xl px-3 py-3.5 transition-colors hover:bg-faint/70 sm:flex-nowrap`,r&&`bg-faint`),children:[(0,Q.jsx)(`span`,{className:B(`grid h-11 w-11 shrink-0 place-items-center rounded-full`,it[s??`unknown`],c&&`opacity-50`),title:F[s??`unknown`].label,children:(0,Q.jsx)(C,{effect:s})}),(0,Q.jsxs)(`div`,{className:B(`min-w-0 flex-1 basis-[calc(100%-64px)] sm:basis-auto`,c&&`opacity-70`),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`max-w-full truncate rounded font-mono text-[14px] font-medium text-ink hover:underline`,"aria-label":`Open ${t.name}`,children:t.name}),(0,Q.jsxs)(`span`,{className:`truncate text-[12.5px] text-soft`,children:[`on `,t.upstream]})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[13px] text-soft`,children:st(t.description)||(0,Q.jsx)(`span`,{className:`italic`,children:`No description`})}),(0,Q.jsx)(ot,{tool:t,changed:n})]}),(0,Q.jsxs)(`div`,{className:`ml-[60px] flex min-w-0 flex-wrap items-center gap-2 sm:ml-0 sm:shrink-0 sm:flex-nowrap`,children:[o===`off`?(0,Q.jsx)(e,{tone:`neutral`,icon:`power`,children:`Turned off`}):o===`unlabelled`?(0,Q.jsx)(e,{tone:t.verdict.kind===`approve`?`warn`:`bad`,icon:`help`,title:`Nobody has said what this tool does yet`,children:t.verdict.kind===`approve`?`Not labelled · asks`:`Not labelled · blocked`}):(0,Q.jsx)(D,{decision:t.verdict.kind}),(0,Q.jsx)(A,{size:`sm`,variant:`ghost`,icon:`power`,loading:l,disabled:a.blocked!==null,title:a.blocked??void 0,onClick:e=>{e.stopPropagation(),a.set(t,!c)},"aria-label":`${c?`Turn on`:`Turn off`} ${t.name}`,className:`justify-center sm:w-[104px]`,children:c?`Turn on`:`Turn off`})]})]})}function ot({tool:t,changed:n}){let r=[];return n&&r.push({key:`changed`,text:`Changed`,tone:`warn`,icon:`refresh`}),t.injection&&t.injection.length>0&&r.push({key:`inj`,text:`Hidden instructions found`,tone:`bad`,icon:`warning`}),t.unreachable&&r.push({key:`unreach`,text:`Can never run`,tone:`bad`,icon:`lock`}),t.bounds&&r.push({key:`bounds`,text:`Has limits`,tone:`neutral`,icon:`sliders`}),J(t)&&r.push({key:`grant`,text:`Pre-approved`,tone:`ok`,icon:`key`}),r.length===0?null:(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:r.map(t=>(0,Q.jsx)(e,{tone:t.tone,icon:t.icon,className:`py-0 text-[11.5px]`,children:t.text},t.key))})}function st(e){let t=/^\[description withheld by hmcp-gateway: it contained text that ([^\]]+)\]/.exec(e);return t?`Description hidden from your AI: it contained text that ${t[1]}.`:e}var ct={allow:`allow`,approve:`approve`,deny:`deny`,unlabelled:`unclassified`,off:null,changed:null};function lt(){let{serverId:e,tenant:t,nav:r,reload:i}=se(),a=ae(()=>_.protection(e,t),[e,t],3e4),l=ae(()=>le(e),[e],3e4),[u,p]=(0,W.useState)(0),[m,h]=(0,W.useState)(``),[v,y]=(0,W.useState)(`any`),[C,w]=(0,W.useState)(null),[T,ee]=(0,W.useState)(!1),E=(0,W.useRef)(void 0);(0,W.useEffect)(()=>()=>clearTimeout(E.current),[]);let D=a.data,O=r.query.get(`tool`),ne=r.query.get(`verdict`),k=de(ne)?ne:null,j=r.query.get(`view`)===`changed`?`changed`:`all`,M=()=>{a.reload(),l.reload(),p(e=>e+1),i()},N=()=>{M(),clearTimeout(E.current),E.current=setTimeout(M,1500)},F=Oe({serverId:e,tenant:t,protection:D,onChanged:M}),I=(0,W.useMemo)(()=>D?.tools??[],[D]),L=(0,W.useMemo)(()=>new Set((l.data?.changed??[]).map(e=>e.tool)),[l.data]),R=(0,W.useMemo)(()=>{let e={allow:0,approve:0,deny:0,unlabelled:0,off:0,changed:0};for(let t of I)e[K(t)]++,L.has(t.name)&&e.changed++;return e},[I,L]),z=(0,W.useMemo)(()=>{let e=m.trim().toLowerCase();return I.filter(t=>!((k===`changed`?!L.has(t.name):k!==null&&K(t)!==k)||v!==`any`&&q(t)!==v||e&&!`${t.name} ${t.description} ${t.upstream}`.toLowerCase().includes(e))).sort((e,t)=>e.upstream.localeCompare(t.upstream)||e.name.localeCompare(t.name))},[I,k,v,m,L]),B=D?D.surface.neverPublished?`Your toolbox hasn't run yet, so there's no list of its tools to set a rule on. Open your AI app once, then come back.`:D.policyWrite.ok?null:X(D.policyWrite.why??`This toolbox's settings can't be changed from here.`):null,V=l.data?.changed.length??0,ce=e=>oe(o(r,{verdict:e})),H=e=>oe(o(r,{view:e===`changed`?e:null})),U=e=>oe(o(r,{tool:e}));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(te,{title:`Tools`,subtitle:`Everything your AI can use through your toolbox, and what each one is allowed to do.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{icon:`help`,onClick:()=>ee(!0),disabled:!D,children:`What happens to unlabelled tools`}),V>0&&(0,Q.jsxs)(A,{variant:`primary`,icon:`refresh`,onClick:()=>H(`changed`),children:[`Review changed tools (`,V,`)`]})]})}),D?.enforcement===`observe`&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(c,{tone:`warn`,title:`Only watching: every tool runs for now`,children:`Your toolbox isn't protecting you yet, so nothing below asks you first or is blocked today. The labels say what happens once protection is on.`})}),(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(ie,{label:`Tool views`,value:j,onChange:H,items:[{id:`all`,label:`All tools`,count:D?I.length:void 0},{id:`changed`,label:`Changed tools`,count:V}]})}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:S(j),"aria-labelledby":d(j),className:`space-y-5`,children:j===`changed`?(0,Q.jsx)(Te,{serverId:e,data:l.data,error:l.error,loading:l.loading,reload:l.reload,onAccepted:M}):a.error&&!D?(0,Q.jsx)(c,{tone:`danger`,title:`The tool list couldn't be loaded`,actions:(0,Q.jsx)(A,{size:`sm`,icon:`refresh`,onClick:a.reload,children:`Try again`}),children:Z(a.error)}):(0,Q.jsxs)(Q.Fragment,{children:[D&&F.blocked&&(0,Q.jsx)(c,{tone:`warn`,title:D.surface.neverPublished?`No tool list yet`:`The toolbox isn't running`,children:D.surface.neverPublished?`This toolbox hasn't reported which tools its connected servers offer. Start it once and they appear here.`:`This is the list it reported ${D.surface.publishedAt?x(D.surface.publishedAt):`last time`}. Start the toolbox to turn tools off or change their rules.`}),(0,Q.jsxs)(P,{padded:!1,children:[(0,Q.jsxs)(`div`,{className:`space-y-4 border-b border-faint p-5 sm:p-6`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Show tools that`,className:`flex flex-wrap gap-2`,children:ue.map(e=>(0,Q.jsx)(ut,{label:G[e],count:D?R[e]:null,dot:ct[e],icon:e===`off`?`power`:e===`changed`?`refresh`:null,on:k===e,onClick:()=>ce(k===e?null:e)},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-60`,children:[(0,Q.jsx)(g,{name:`search`,size:18,className:`pointer-events-none absolute top-1/2 left-3.5 -translate-y-1/2 text-soft`}),(0,Q.jsx)(f,{type:`search`,value:m,onChange:h,placeholder:`Search by name or description`,"aria-label":`Search tools by name or description`,className:`pl-10`})]}),(0,Q.jsx)(re,{"aria-label":`Show tools by what they do`,value:v,onChange:y,className:`w-full sm:w-52`,options:[{value:`any`,label:`Any kind of tool`},{value:`read`,label:`Looks only`},{value:`write`,label:`Makes changes`},{value:`destructive`,label:`Deletes`}]})]})]}),(0,Q.jsx)(`div`,{className:`px-5 pt-1 pb-3 sm:px-6`,children:D?I.length===0?(0,Q.jsx)(b,{icon:`tool`,title:`No tools yet`,children:D.surface.neverPublished?`Start the toolbox once and the tools its connected servers offer will appear here.`:`The connected servers on this toolbox don't offer any tools.`}):z.length===0?(0,Q.jsx)(b,{icon:`search`,title:`No tools match`,compact:!0,actions:(0,Q.jsx)(A,{onClick:()=>{h(``),y(`any`),ce(null)},children:`Clear filters`}),children:`Nothing on this toolbox matches what you picked.`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,"aria-live":`polite`,children:[n(z.length,`tool`),` shown`]}),(0,Q.jsx)(rt,{tools:z,changed:L,selected:O,onOpen:U,exposure:F})]}):(0,Q.jsx)(`div`,{className:`space-y-5 py-4`,"aria-busy":!0,children:[0,1,2,3].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`span`,{className:`skeleton h-11 w-11 shrink-0 rounded-full`}),(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(s,{lines:2})})]},e))})})]})]})}),(0,Q.jsx)(qe,{name:O,serverId:e,tenant:t,protection:D,listTool:I.find(e=>e.name===O)??null,version:u,nav:r,exposure:F,ruleBlocked:B,onClose:()=>U(null),onEditRule:w,onPosture:()=>ee(!0),onChanged:N}),C&&(0,Q.jsx)(Ve,{open:!0,serverId:e,tenant:t,tool:C,protection:D,onClose:()=>w(null),onSaved:N},C.name),D&&T&&(0,Q.jsx)(Ae,{open:!0,serverId:e,tenant:t,protection:D,onClose:()=>ee(!1),onSaved:N,onReload:a.reload}),F.dialog]})}function ut({label:e,count:t,dot:n,icon:r,on:i,onClick:a}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:a,className:B(`inline-flex h-10 items-center gap-2 rounded-full border-[1.5px] px-4 text-[13.5px] font-semibold transition-colors active:scale-[.98]`,i?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:[n&&(i?(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":!0}):(0,Q.jsx)(v,{decision:n})),r&&(0,Q.jsx)(g,{name:r,size:15,strokeWidth:2}),e,(0,Q.jsx)(`span`,{className:B(`tnum rounded-full px-1.5 text-[12px]`,i?`bg-white/20`:`bg-faint`),children:t??`–`})]})}export{lt as ToolsPage};