hmcp-web 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +15 -0
- package/dist/api.js +36 -8
- package/dist/model/app-connect-note.d.ts +114 -0
- package/dist/model/app-connect-note.js +199 -0
- package/dist/model/app-servers.d.ts +24 -1
- package/dist/model/app-servers.js +54 -6
- package/dist/model/apps.d.ts +24 -0
- package/dist/model/apps.js +18 -0
- package/dist/model/bring-in.d.ts +185 -0
- package/dist/model/bring-in.js +756 -0
- package/dist/model/console-settings.d.ts +2 -2
- package/dist/model/import-record.d.ts +4 -0
- package/dist/model/import-record.js +22 -1
- package/dist/model/new-toolbox.d.ts +84 -0
- package/dist/model/new-toolbox.js +209 -0
- package/dist/model/protection.d.ts +4 -1
- package/dist/model/protection.js +12 -9
- package/dist/model/provisional-tools.d.ts +56 -0
- package/dist/model/provisional-tools.js +145 -0
- package/dist/model/server-names.d.ts +25 -0
- package/dist/model/server-names.js +158 -0
- package/dist/model/toolbox-label.d.ts +22 -0
- package/dist/model/toolbox-label.js +42 -0
- package/dist/model/tools.d.ts +20 -5
- package/dist/model/tools.js +22 -11
- package/dist/routes/connect-app.d.ts +54 -0
- package/dist/routes/connect-app.js +1049 -0
- package/dist/routes/connect-import.d.ts +21 -6
- package/dist/routes/connect-import.js +162 -546
- package/dist/routes/connect.d.ts +30 -0
- package/dist/routes/connect.js +74 -126
- package/dist/routes/github.js +2 -1
- package/dist/routes/guard.js +4 -0
- package/dist/routes/runtime.js +21 -22
- package/dist/routes/servers-add.d.ts +1 -0
- package/dist/routes/servers-add.js +6 -5
- package/dist-ui/assets/Activity-CQw7bFh4.js +1 -0
- package/dist-ui/assets/Approvals-_rFRWRyy.js +1 -0
- package/dist-ui/assets/AttachApp-eNBD48eb.js +5 -0
- package/dist-ui/assets/Connections-_AV8r8_W.js +2 -0
- package/dist-ui/assets/{Gallery-DB_OO7Vw.js → Gallery-0iiv1H9e.js} +3 -3
- package/dist-ui/assets/{PreApprovals-C-2ZGYfc.js → PreApprovals-Bwrhm8hr.js} +1 -1
- package/dist-ui/assets/Protection-CM1fEDmQ.js +1 -0
- package/dist-ui/assets/Safety-BbtS6-Sw.js +1 -0
- package/dist-ui/assets/{Settings-CSyTOe8X.js → Settings-BjarVZaa.js} +1 -1
- package/dist-ui/assets/StartPage-CUFNfiyY.js +1 -0
- package/dist-ui/assets/{Suggestions-CaQ_ifWR.js → Suggestions-CfqM3_Ik.js} +1 -1
- package/dist-ui/assets/Tools-jM5XlNbn.js +4 -0
- package/dist-ui/assets/connect-app-words-Dy16Vpfd.js +1 -0
- package/dist-ui/assets/index-DywhXnhV.js +16 -0
- package/dist-ui/assets/{kit-DRVm92_t.js → kit-BHB_ha4i.js} +1 -1
- package/dist-ui/assets/server-name-D9u6r07i.js +1 -0
- package/dist-ui/index.html +3 -2
- package/package.json +4 -4
- package/dist-ui/assets/Activity-CoVSFaRd.js +0 -1
- package/dist-ui/assets/Approvals-BSEDgiNu.js +0 -1
- package/dist-ui/assets/AttachApp-Cpm6DOaX.js +0 -5
- package/dist-ui/assets/Connections-D5Xd9vH8.js +0 -2
- package/dist-ui/assets/Protection-B4Ltb5iP.js +0 -1
- package/dist-ui/assets/Safety-CSQhoL9D.js +0 -1
- package/dist-ui/assets/StartPage-JBVzYXce.js +0 -1
- package/dist-ui/assets/Tools-CDl6irG1.js +0 -4
- package/dist-ui/assets/index-CTvq_isK.js +0 -16
|
@@ -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 O,k,kt as A,n as ee,o as te,q as j,r as M,rt as N,s as ne,t as P,tt as re,vt as ie,w as ae,x as oe,xt as se,y as ce,yt as F}from"./kit-DRVm92_t.js";import{$ as I,$t as le,A as ue,At as de,B as fe,Bt as L,C as R,D as pe,Dn as me,E as he,F as ge,Ft as _e,G as ve,Gt as ye,H as be,I as xe,It as z,J as Se,Jt as B,K as Ce,Kt as we,L as Te,Lt as Ee,M as De,Mt as V,N as Oe,O as ke,P as Ae,Pt as H,Q as U,Qt as je,R as Me,Rt as W,S as Ne,T as G,U as Pe,Ut as K,V as Fe,Vt as Ie,W as Le,X as Re,Y as ze,Yt as Be,Zt as Ve,an as q,b as He,cn as J,ct as Ue,en as Y,et as X,hn as We,in as Ge,j as Ke,k as qe,ln as Je,m as Ye,nt as Xe,on as Ze,q as Qe,rn as $e,rt as et,s as tt,tt as nt,x as rt,z as it}from"./index-CTvq_isK.js";var Z=c(),Q=A(),at=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function ot(e){let t=at();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=et(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=et(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function st(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:Xe(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:Xe(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function ct(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 lt({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!le(t)&&!B(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)(I,{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)(I,{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)(U,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?V[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(k,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:V.strip.label},{value:`deny`,label:V.deny.label},{value:`annotate`,label:V.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 ut({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)(dt,{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)(j,{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)(dt,{onPick:i}):p===`registry`?(0,Q.jsx)(mt,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(ht,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(gt,{onDraft:a})})]})}function dt({onPick:e,compact:t}){let i=ne(()=>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?it(p,a,l):[...it(p,a,l)].sort((e,t)=>Number(t.id===ft)-Number(e.id===ft)),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:K(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:F(`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`:R[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)(pt,{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 ft=`filesystem`;function pt({entry:t,onPick:n}){let r=Me(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===ft?(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=>G[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 mt({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=ne(()=>n.catalog(),[]),O=l?it(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.`):_(K(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 k=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(K(e))).finally(()=>b(!1)))},A=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(K(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)(ie,{})})]}),(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)(ie,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+O.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:[O.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||!O.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:()=>A(t),"aria-describedby":n?void 0:`why-${t.name}`,className:F(`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)(ie,{}),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:k,loading:y,children:`Show more`})})]})}function ht({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(K(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 gt({onDraft:e}){let[t,n]=(0,Z.useState)(at()),[r,i]=(0,Z.useState)(!1),a=ct(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)(lt,{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=Ae(st(t));e(n.draft,n.values)},children:`Continue`})})]})}function _t({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)(ie,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:be(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 vt=[`run`,`ask`,`blocked`],yt={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 bt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=De(e),a=ze(e),o=vt.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:[Pe(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(nt,{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:F(`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)(xt,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(nt,{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:F(`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:F(`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 xt({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=ke[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:yt[e]}),(0,Q.jsx)(`ul`,{className:F(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":re[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??tt(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:N[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:te(e.name)})]},e.name))]})]})]})}var St=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function Ct({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=ge(t.requires,h),T=Le(t),E=t.launch.transport===`http`?Ke(t.launch.url,r):``,D=Fe(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(St(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let O=e=>a[e.id]??(o||y[e.id]?Ce(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 `,G[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(M,{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)(rt,{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)(Re,{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=>G[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:F(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(ee,{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)(He,{serverUrl:E,secretName:fe(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)(wt,{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:O(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)(U,{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":!!xe(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:F(`text-[12.5px]`,xe(l)?`font-medium text-bad`:`text-soft`),children:xe(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)(Tt,{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 wt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=St(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)(P,{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:F(`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)(M,{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 Tt({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},Et=new Set([`brave-search`]);function Dt(){$.saved=null}function Ot(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,k]=(0,Z.useState)(!1),[A,ee]=(0,Z.useState)(!1),[te,j]=(0,Z.useState)({}),[M,N]=(0,Z.useState)(null),[ne,P]=(0,Z.useState)(null),[re,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,F]=(0,Z.useState)(!1),[I,le]=(0,Z.useState)(null),[de,L]=(0,Z.useState)(null),[R,me]=(0,Z.useState)($.saved),[ge,_e]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){_e(!0);return}let e=!0;return h.protection(t).then(t=>e&&_e(t.enforcement!==`enforce`)).catch(()=>e&&_e(null)),()=>{e=!1}},[t]);let[ye,be]=(0,Z.useState)(null),z=e=>{$.saved=e,me(e)},B=(0,Z.useRef)(null),Ce=R?`done`:M&&M.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{B.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),be(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(he)));S({...Oe(e,n),...r}),T(e.name),k(!1),ee(!1),j({}),N(null),le(null),e.requires.length&&!re&&Ae()},Ee=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(K(e))).finally(()=>v(null))},[De,V]=(0,Z.useState)(!1),ke=async(e,t,r)=>{V(!0),b(null);try{let i=(await n.catalog()).entries,a=qe(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Qe(o,e,r),c=a.entry):{draft:o,values:s}=ue(e,r),we(o,c,s),be(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)P({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!==`${he}${e}`))),P(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&P({kind:`sign-in`,nonce:l})}catch(e){b(K(e))}finally{V(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&ke(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?Ee(t):v(null)}).catch(e=>{b(K(e)),v(null)})},[a]);let Ae=()=>{se(!0),n.doctor().then(ae).catch(()=>void 0).finally(()=>se(!1))},H=p?.draft??null,U=H?Le(H):!1,Me=fe(w||H?.name||`server`),W=()=>{if(!H)return;ee(!0),le(null);let e=ve(H,x);if(Object.keys(e).length||xe(w)){let t=H.fields.find(t=>e[t.id]);t&&P({kind:`field`,field:t.id,nonce:Date.now()}),N({kind:`error`,text:xe(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else U&&!D?N({kind:`error`,text:`Sign in with ${H.displayName} first.`}):Fe(H,x)&&x.__local_ok!==!0?N({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.`}):(N({kind:`running`}),j({}),n.testServer({...t?{gatewayId:t}:{},draft:H,values:U?{...x,[pe]:Me}:x,...w.trim()===H.name?{}:{name:w.trim()},...ye?{replacing:ye}:{}}).then(e=>{if(Object.keys(e.problems).length){j(e.problems);let t=H.fields.find(t=>e.problems[t.id]);t&&P({kind:`field`,field:t.id,nonce:Date.now()}),N({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else N({kind:`done`,res:e})}).catch(e=>N({kind:`error`,text:K(e)})))},G=e=>{if(!H)return;let t=Date.now(),n=e=>H.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return W();case`install-runtime`:case`start-runtime`:return Ae();case`show-details`:return;case`choose-folder`:{N(null);let e=n([`folder`,`folders`]);if(!e&&H.launch.transport===`stdio`&&p){let e=M?.kind===`done`?M.res.outcome.problem?.detail?.path:void 0,n=ue({name:w||H.name,transport:`stdio`,command:H.launch.command,args:H.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...H,launch:{...H.launch,args:n.draft.launch.args??[]},fields:[...H.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),P({kind:`folder`,field:`folders`,nonce:t})}return P(null)}return P({kind:`folder`,field:e,nonce:t})}case`replace-key`:{N(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${he}${e}`))),P(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Le(H)&&p&&g({...p,draft:Se(H)}),N(null),k(!1),P({kind:`sign-in`,nonce:t});case`check-address`:{N(null);let e=n([`url`,`text`]);return P(e?{kind:`field`,field:e,nonce:t}:null)}}},[Pe,Ie]=(0,Z.useState)(null),Re=async(e,t,n)=>{if(!R)return;Ie(null);let{upstreamName:r}=R.result;if(p){z(null),be(r),T(r),G(e);return}let i=t;if(!i)try{i=(await We(R.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Ie(K(e));return}i?(z(null),await ke(i,e,n)):Ie(`The server "${r}" isn't in your toolbox any more.`)},ze=(0,Z.useRef)(!1),Ve=async e=>{if(M?.kind!==`done`||ze.current)return;ze.current=!0,F(!0),le(null);let r;if(t)try{let[e,n]=await Promise.all([We(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:M.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:M.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});L(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;z({result:i,name:H?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?L(je(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(L(null),le({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(L(null),le({text:Be(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:K(e)}))}finally{ze.current=!1,F(!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}=Te(t,R.result.upstreamName,R.result.apply,Date.now()-e,e);z({...R,live:n,settled:i})}).catch(()=>r&&(R.result.apply===`needs-restart`||Date.now()-e>=15e3)&&z({...R,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[R?.result.upstreamName,R?.settled]);let q=()=>{$.saved=null,i?.()},He=()=>{let e=R?.result;$.saved=null,e&&r(e)};if(R)return(0,Q.jsx)(kt,{saved:R,heading:B,onFinish:He,onRewatch:()=>z({...R,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void Re(e,t,n),reopenError:Pe});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:B,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||De?(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)(ie,{}),` Opening…`]})}),(0,Q.jsx)(ut,{compact:c,tab:u,onTab:d,onCatalog:e=>Ee(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:q,children:`Cancel`})})]});let J=p.draft,Y=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>M?N(null):(g(null),O({kind:`picker`})),disabled:M?.kind===`running`||ce,children:M&&M.kind!==`error`?`Change its settings`:`Choose another server`}),X=M?.kind===`done`&&!M.res.outcome.ok?M.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,Ge=J.source.kind===`catalog`&&J.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(J.launch.url)?p.entry?.name??J.displayName:void 0,Ke={firstSignIn:U?!D:M?.kind===`done`&&!!M.res.signInAvailable,...Ge?{desktopApp:Ge.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:J.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||J.launch.transport===`stdio`};return Ce===`test`&&M?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:B,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,J.displayName]}),M.kind===`running`?(0,Q.jsx)(_t,{transport:J.launch.transport}):M.kind===`done`&&M.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bt,{outcome:M.res.outcome,name:J.displayName,watching:ge,keyUnchecked:J.fields.some(e=>e.kind===`secret`)&&!(J.source.kind===`catalog`&&Et.has(J.source.id))}),M.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:M.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):M.kind===`done`?(0,Q.jsx)(Ne,{problem:X,onFix:G,context:Ke,extra:(0,Q.jsxs)(Q.Fragment,{children:[M.res.signInAvailable&&!U&&M.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>G(`sign-in`),children:`Sign in instead`}),Ue(X,Ke).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:W,children:`Try again`})]})}):null,I&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:I.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:W,children:`Test it again`}):void 0,children:I.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Y,M.kind===`done`&&M.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void Ve(),loading:ce,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!de,title:`Save ${J.displayName}?`,confirmLabel:`Save and turn on`,consequences:de??[],busy:ce,error:I?.text??null,onCancel:()=>L(null),onConfirm:()=>void Ve(!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:B,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,J.displayName]}),(0,Q.jsx)(Ct,{draft:J,entry:p.entry,values:x,onValues:e=>{S(e),j({})},problems:te,tried:A,onVariant:e=>p.entry&&Ee(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:k,doctor:re,doctorBusy:oe,onRecheck:Ae,focus:ne}),M?.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}),` `,M.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Y,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:W,disabled:!!_,children:`Test it`})]})]})}function kt({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 We(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,se(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:F(`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)(Ye,{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 At={};function jt({scope:t,projectDir:n}){let r=ne(()=>me.clients(n),[n]),i=r.data?.clients.find(e=>e.scope===t)??null,[a,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(At[t]??null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=e=>{At[t]=e??void 0,_(e)};if(!i)return r.error?(0,Q.jsx)(s,{tone:`danger`,children:K(r.error)}):(0,Q.jsx)(o,{lines:3});if(!i.attachedTo)return null;let w=H(t),T=i.servers??[],D=e=>T.find(t=>t.source===`extension`&&t.extensionId===e),O=a??new Set(ye(T)),k=T.filter(e=>e.importable&&!(e.source===`extension`&&e.inToolbox)),A=k.filter(e=>O.has(Ze(e))),ee=(e,t)=>{let n=new Set(O);t?n.add(Ze(e)):n.delete(Ze(e)),c(n)},te=e=>{u(!0),f(null),me.importServers({scope:t,names:A.filter(e=>e.source===`config`).map(e=>e.name),extensions:A.filter(e=>e.source===`extension`).map(e=>e.extensionId),...i.projectScoped&&r.data?.projectDir?{projectDir:r.data.projectDir}:{},acknowledged:e}).then(e=>{h(null),c(null),S(e),r.reload()}).catch(t=>{t.detail?.needs===`loosens`&&!e?h(je(t)):(h(null),f(K(t)))}).finally(()=>u(!1))},j=v&&(0,Q.jsxs)(s,{tone:`warn`,title:`Give these servers back to ${w}?`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>y(!1),disabled:l,children:`Keep them in the toolbox`}),(0,Q.jsx)(E,{size:`sm`,variant:`danger`,onClick:()=>{u(!0),f(null),me.undoImport(t,i.projectScoped?r.data?.projectDir:void 0).then(e=>{y(!1),S(null),x(e),r.reload()}).catch(e=>f(K(e))).finally(()=>u(!1))},loading:l,children:`Give them back`})]}),children:[`They are taken out of your toolbox and put back in `,w,`'s own settings, the way they were. Keys saved for them are removed if nothing else uses them.`]});if(g){let t=g.extensionsToSwitchOff.map(e=>({...e,enabled:D(e.id)?.enabled??e.enabled}));return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers brought in`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2 rounded-[18px] bg-ok-tint p-5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[16px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:19,className:`text-ok`,strokeWidth:2.2}),we(w,g.imported.length+g.takenOut.length)]}),t.some(e=>e.enabled)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:J(t.filter(e=>e.enabled).map(e=>e.name))}),g.imported.length+g.takenOut.length>0&&(0,Q.jsxs)(`ul`,{className:`space-y-1 text-[14px]`,children:[g.imported.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` `,`— as “`,e.upstream,`”, `,e.tools===1?`1 tool`:`${e.tools} tools`,e.keysLocked.length>0?`; ${e.keysLocked.join(`, `)} kept in your locked keys`:``]})]},`i-${e.name}`)),g.takenOut.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — your toolbox already had it; `,w,`'s own copy was taken out`]})]},`t-${e.name}`))]}),g.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:q(Y(g.restartHint))})]}),g.failures.length>0&&(0,Q.jsxs)(s,{tone:`warn`,title:`${g.failures.length===1?`This one stayed`:`These stayed`} in ${w}`,children:[g.failures.length===1?`It`:`They`,` didn't connect when tested, so nothing about `,g.failures.length===1?`it`:`them`,` was changed.`,(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:g.failures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,q(Y(e.message))]},e.name))})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Switch these off in Claude`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium`,children:t.name}),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:Je(t.name)})]},t.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`refresh`,loading:r.loading,onClick:r.reload,children:`Check again`})})]}),g.otherApps.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[g.otherApps.join(` and `),` `,g.otherApps.length===1?`uses`:`use`,` this toolbox too, so `,g.otherApps.length===1?`it gets`:`they get`,` these servers as well.`]}),g.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(Y(g.warning))}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),j,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo`}),(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>S(null),children:`Done`})]})]})}return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers ${w} runs itself`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Bring its servers into your toolbox`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:T.length>0?`${w} runs these servers itself, so your toolbox doesn't check what they do. Each one you choose is tested first; the ones that connect run through your toolbox instead and are taken out of ${w}'s own settings. A backup is kept, so you can undo it.`:`${w} has no servers of its own to bring in.`})]}),b&&(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:`Given back to ${w}`,children:[b.restored.length>0?`${b.restored.join(`, `)} ${b.restored.length===1?`is`:`are`} back in ${w}'s own settings. `:``,b.extensions.length>0?`Switch ${b.extensions.map(e=>e.name).join(` and `)} back on in Claude, under Settings, then Extensions, if you want Claude to run ${b.extensions.length===1?`it`:`them`} itself. `:``,q(Y(b.restartHint))]}),T.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:$e(w)}),T.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:T.map(e=>(0,Q.jsx)(`li`,{className:`rounded-[14px] border border-line p-3`,children:(0,Q.jsx)(Mt,{server:e,app:w,checked:O.has(Ze(e)),onChange:t=>ee(e,t)})},Ze(e)))}),t===`claude-desktop`&&(0,Q.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Connectors added on claude.ai live in your Claude account, not on this computer, so they can't be listed here.`}),(i.imported?.length??0)>0&&!b&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Brought in earlier: `,i.imported.map(e=>e.name).join(`, `),`.`]}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),j,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0&&(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,disabled:A.length===0||l&&!p,loading:l&&!p,onClick:()=>te(!1),children:l&&!p?`Testing each one…`:Ee(A.length)}),i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo bringing them in`})]}),(0,Q.jsx)(C,{open:p!==null,onCancel:()=>h(null),onConfirm:()=>te(!0),title:`Let your toolbox reach these servers?`,consequences:p??[],confirmLabel:`Bring them in`,cancelLabel:`Don't bring them in`,busy:l,children:`At least one of these servers runs on this computer or your local network, which your toolbox only reaches once its allowed addresses are widened.`})]})}function Mt({server:t,app:n,checked:r,onChange:i}){let a=(0,Q.jsxs)(`span`,{className:`ml-2 inline-flex flex-wrap gap-1.5 align-middle`,children:[t.source===`extension`&&(0,Q.jsx)(e,{children:`Extension`}),t.inToolbox&&t.source===`config`&&(0,Q.jsx)(e,{tone:`warn`,children:`In both`}),t.inToolbox&&t.source===`extension`&&(t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})),!t.importable&&(0,Q.jsx)(e,{children:`Can't be brought in`})]}),o=t.importable?t.inToolbox&&t.source===`config`?`Your toolbox already has it (as “${t.inToolbox}”), and ${n} still runs its own copy. Tick it to take ${n}'s copy out.`:t.inToolbox?t.enabled?`Your toolbox already has it. ${Je(t.name)}`:`Your toolbox has it, and it is switched off in Claude.`:[t.source===`extension`?`A Claude extension. It isn't changed here; you switch it off in Claude afterwards.`:null,t.keysLocked.length>0?`${t.keysLocked.join(`, `)} ${t.keysLocked.length===1?`goes`:`go`} into your locked keys.`:null,t.needsLocalHttp?`It runs on this computer or your local network, so you'll be asked to confirm.`:null,t.upstreamName&&t.upstreamName!==t.name?`In your toolbox it will be called “${t.upstreamName}”.`:null].filter(Boolean).join(` `):q(Y(t.reason??`It can't be brought in.`));return!t.importable||t.inToolbox&&t.source===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px]`,children:[(0,Q.jsxs)(`span`,{className:t.importable?`font-medium`:`font-medium text-soft`,children:[t.name,a]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:o})]}):(0,Q.jsx)(ae,{checked:r,onChange:i,label:(0,Q.jsxs)(`span`,{className:`font-medium`,children:[t.name,a]}),description:o||void 0})}function Nt({client:e,projectDir:t}){let[n,r]=(0,Z.useState)(!1);if(!e.attachedTo)return null;let i=H(e.scope);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>r(!0),children:`Bring in servers`}),(0,Q.jsx)(oe,{open:n,onClose:()=>r(!1),title:`Bring ${i}'s servers into your toolbox`,width:640,footer:(0,Q.jsx)(E,{onClick:()=>r(!1),children:`Close`}),children:(0,Q.jsx)(jt,{scope:e.scope,...t?{projectDir:t}:{}})})]})}var Pt=null;function Ft({client:e,projectDir:t,onClose:n,onDone:r}){let i=ce(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(Pt),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(Pt=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{Pt=null,n(),r()},_=_e(e.scope),v=()=>{l(!0),d(null),me.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{Pt=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(K(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(oe,{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)(It,{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)(X,{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.`]}),f.importedNote&&(0,Q.jsx)(`p`,{className:`text-soft`,children:q(Y(f.importedNote))}),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)(It,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(It,{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)(X,{children:e.path}),` `,q(Y(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(Y(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(Y(f.warning))})]})})}return(0,Q.jsx)(oe,{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)(X,{children:e.path})]})]})]}),(0,Q.jsx)(ae,{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 It({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)(X,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var Lt={done:null};function Rt({gatewayId:t,onDone:r,compact:i,scope:a}){let c=ne(()=>me.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(Lt.done&&(!a||Lt.done.scope===a)?Lt.done:null),g=e=>{Lt.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)=>zt(e)-zt(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=H(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n,scope:e.scope}),c.reload()}).catch(t=>f({scope:e.scope,text:K(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null,t=e?.servers?Ge(e.servers).length:0;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.${t>0?` Its own servers still run directly; bring them in below.`:``}`:`${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(Y(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)(X,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(X,{children:p.backupPath})]})]}),e?.attachedTo&&(0,Q.jsx)(jt,{scope:e.scope,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),(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)(Ft,{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:K(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:[de.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:F(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=W(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:F(`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:F(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:Ve(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(Y(t.error)):r?L(t.servers,Ie(t)):n?z(t.servers?.length??t.serverCount):`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 `,H(t.scope)]}),r&&(0,Q.jsx)(Nt,{client:t,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(Ft,{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 zt=e=>e.error?3:e.alreadyAdopted?1:W(e)?0:4;export{Ot as a,ot as c,st as d,Nt as i,ct as l,Ft as n,Dt as o,jt as r,lt as s,Rt as t,at as u};
|
|
@@ -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 B,st as V,u as ae,vt as oe,w as se,wt as ce,x as le,xt as ue,y as H,yt as de,z as fe}from"./kit-DRVm92_t.js";import{$ as pe,Bt as me,Cn as he,Dn as ge,Ft as U,Ht as _e,Jt as ve,Mt as ye,Nt as be,Q as xe,Qt as Se,Rt as Ce,Sn as we,Tn as Te,Ut as W,Vt as Ee,Wt as De,X as Oe,Xt as ke,Yt as Ae,Z as je,Zt as Me,_ as Ne,an as G,bn as Pe,d as Fe,dn as K,en as q,et as J,f as Ie,g as Le,gn as Re,h as ze,hn as Be,m as Ve,mn as He,nn as Ue,p as We,qt as Ge,s as Ke,tn as qe,tt as Y,v as Je,vn as Ye,wn as Xe,xn as Ze,y as Qe,yn as $e,zt as et}from"./index-CTvq_isK.js";import{a as tt,c as nt,d as rt,i as it,l as at,n as ot,o as st,s as ct,t as lt,u as ut}from"./AttachApp-Cpm6DOaX.js";var X=u(),Z=L(),dt=[`Choose an app`,`Choose how it starts`,`Check what will happen`,`Connect`],ft={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 pt(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,...Ge(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 mt={done:null,undo:null};function ht({open:e,onClose:t}){let n=()=>{mt.done=null,mt.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)(gt,{onClose:n})})}function gt({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=B(()=>ge.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)(ft),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(mt.undo),S=e=>{mt.undo=e,x(e)},C=(0,X.useMemo)(()=>h?pt(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 ge.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)(mt.done),I=()=>{C&&(A(!0),M(null),ge.apply(C).then(e=>{mt.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)(At,{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)(ae,{steps:dt,step:r,onStep:e=>a(Math.max(0,e)),canNext:z&&!k,nextLabel:r===2?`Review and connect`:`Continue`,finishLabel:h?`Connect ${U(h.scope)}`:`Connect app`,onFinish:I,busy:k||!!D,children:[r===0&&(0,Z.jsx)(_t,{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)(xt,{client:h,choices:g,onChange:_,found:L?.data?.serversFound??T?.data?.serversFound??[]}),r===2&&(D||!L?(0,Z.jsx)(St,{}):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)(wt,{plan:L.data,app:U(h.scope)})),r===3&&L?.data&&h&&(0,Z.jsx)(kt,{plan:L.data,client:h,error:j,id:g.id,onId:e=>_({...g,id:e})})]}),(0,Z.jsx)(jt,{client:v,onClose:()=>y(null),onDone:()=>d.reload()}),(0,Z.jsx)(ot,{client:b,projectDir:d.data?.projectDir,onClose:()=>S(null),onDone:()=>{d.reload(),n()}})]})}function _t({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)=>vt(e)-vt(t)).map(t=>(0,Z.jsx)(bt,{client:t,projectDir:e.data?.projectDir,selected:r===t.scope,onSelect:()=>i(t.scope),onUndo:()=>a(t),onAttach:()=>s(t)},t.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 vt=e=>e.error?3:e.alreadyAdopted?1:e.exists&&e.serverCount>0?0:Ce(e)?2:4,yt=e=>!e.alreadyAdopted&&Ce(e)&&!(e.exists&&e.serverCount>0);function bt({client:t,projectDir:n,selected:i,onSelect:a,onUndo:o,onAttach:s}){let c=t.exists&&!t.error&&(t.serverCount>0||t.alreadyAdopted)&&!t.attachedTo,l=yt(t),u=(0,X.useId)(),d=Me(t),f=t.error?{tone:`bad`,text:`Can't be read`}:!t.exists&&!l?{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:de(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] p-4 transition-colors`,i?`border-primary bg-ok-tint`:`border-line`,!c&&`bg-sunken/40`),children:[(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"aria-labelledby":`${u}-name`,"aria-describedby":`${u}-status ${u}-desc`,disabled:!c,onClick:a,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:de(`mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border-[1.5px]`,i?`border-primary bg-primary text-white`:`border-[var(--soft)]`,!c&&`opacity-40`),children:i&&(0,Z.jsx)(g,{name:`check`,size:12,strokeWidth:3})}),(0,Z.jsx)(`span`,{id:`${u}-name`,className:de(`min-w-0 flex-1 text-[15px] font-semibold`,!c&&`text-soft`),children:d}),(0,Z.jsx)(`span`,{id:`${u}-status`,children:(0,Z.jsx)(e,{tone:f.tone,children:f.text})})]}),(0,Z.jsx)(`span`,{id:`${u}-desc`,className:`pl-7 text-[13px] text-soft`,children:t.error?G(q(t.error)):l?`It has no servers yet. Connect it to your toolbox, then add servers there.`:t.exists?t.alreadyAdopted?t.servers?me(t.servers,Ee(t)):et(t.serverCount):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})})]}),l&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`plug`,onClick:s,children:`Connect it to your toolbox`})}),t.attachedTo&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(it,{client:t,...n?{projectDir:n}:{}})}),t.canRevert&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:o,children:`Undo connection`})})]})}function xt({client:t,choices:n,onChange:r,found:i}){let a=(e,t)=>r({...n,[e]:t}),s=Ge(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)(Oe,{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)(Oe,{label:`Default stance`,columns:3,value:n.posture,onChange:e=>a(`posture`,e),options:Object.keys(V).map(e=>({value:e,title:V[e].label,body:V[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. ${U(t.scope)} keeps asking in its own way.`})]}),(0,Z.jsxs)(xe,{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)(pe,{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 St(){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)(oe,{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 Ct=[{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 wt({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:G(q(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:G(q(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=qe(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: `,G(q(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}),`: `,G(q(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:Ct.map(e=>{let n=t.tools.filter(t=>t.verdict===e.key);return n.length===0?null:(0,Z.jsx)(Dt,{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}`)),Tt(t.findings).map(e=>(0,Z.jsx)(Et,{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: `,G(q(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:G(q(e))},e))})}),t.files&&(0,Z.jsx)(Ot,{plan:t})]})}function Tt(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 Et({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:de(`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:G(q(e.message))},t))})]})]})}function Dt({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:_e(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 Ot({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 kt({plan:e,client:t,error:n,id:i,onId:a}){let s=U(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:G(q(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 At({result:e,onClose:t,onOpen:n}){let r=U(e.scope),i=e.applied;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(R,{steps:dt,current:dt.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:G(q(e.warning))})]})}function jt({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 ${U(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)(lt,{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 `,U(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 Q={done:null,label:``};function Mt({open:e,onClose:t}){let{reload:n}=K(),r=()=>{let e=!!Q.done;Q.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)(Nt,{onClose:r}):(0,Z.jsx)(Ft,{onClose:r})]})})}function Nt({onClose:e}){let{nav:t,reload:n}=K(),r=H(),[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)([ut()]),[C,T]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(Q.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)=>at(e,x.filter((e,n)=>n!==t).map(e=>e.name.trim()))),L=!F&&I.every(e=>!e);return j?(0,Z.jsx)(Pt,{result:j,label:Q.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)(Oe,{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)(Oe,{label:`Default stance`,columns:3,value:m,onChange:g,options:Object.keys(V).map(e=>({value:e,title:V[e].label,body:V[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)(ct,{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,ut()]),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),ge.createGateway({name:a,...c.trim()?{label:c.trim()}:{},mode:d,posture:m,onUnclassified:_,...y.trim()?{outDir:y.trim()}:{},upstreams:x.map(rt)}).then(e=>{Q.done=e,Q.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=>G(q(e.message))).join(` `)}`:``))}).finally(()=>T(!1)))},loading:C,children:`Create toolbox`})]})]})}function Pt({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)(lt,{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:[G(q(e)),` If one is a password or key, keep that file private.`]},e)),e.warning&&(0,Z.jsx)(l,{tone:`warn`,children:G(q(e.warning))})]})}function Ft({onClose:e}){let{nav:t,reload:n}=K(),r=H(),[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 It(){return document.cookie.match(/(?:^|;\s*)hmcp_csrf=([^;]+)/)?.[1]??``}async function Lt(e,t={}){let n={...t.headers??{}};t.method&&t.method!==`GET`&&(n[`Content-Type`]=`application/json`,n[`X-HMCP-CSRF`]=It());let r=await fetch(e,{...t,headers:n}),i=await r.text(),a=i?JSON.parse(i):null;if(!r.ok){let e=a?.error??{code:`unknown`,message:r.statusText};throw new m(r.status,e.code,e.message)}return a}var Rt=e=>({method:`POST`,body:JSON.stringify(e)}),zt=(e,t)=>`/api/v1/servers/${encodeURIComponent(e.gatewayId)}/github/${encodeURIComponent(e.upstream)}/${t}`,Bt={doors:()=>Lt(`/api/v1/github-doors`),claudeCode:e=>Lt(`/api/v1/github-doors/claude-code`,Rt({scope:`user`,close:e,confirm:!0})),confirm:(e,t)=>Lt(`/api/v1/github-doors/confirm`,Rt({door:e,done:t})),setChanges:(e,t)=>Lt(zt(e,`changes`),Rt({allow:t,expectedDigest:e.digest,confirm:!0})),check:e=>Lt(zt(e,`check`),Rt({}))},Vt=`Make hmcp the only way to change GitHub`,Ht=`hmcp can ask you before each GitHub change only when the change goes through it. These are the other ways a change could reach GitHub from this computer.`,Ut=`Claude Code enforces these rules, but a prefix rule makes a way around them much harder, not impossible. For a guarantee, also log gh out and remove saved GitHub git credentials.`,Wt=`Your GitHub server can only look. To let Claude make changes through hmcp, switch it below, or edit it and choose 'Look and make changes'.`,Gt=`Not checked yet — press Check it works to see what each change will meet.`,Kt=`Once it's switched, press Check it works to see what each change will meet.`,qt=`Let Claude change GitHub through hmcp`,Jt=`Back to only looking`,Yt=`Your GitHub server can make changes.`,Xt=`For a company: a Claude Team/Enterprise admin can block connector tools for everyone, and a GitHub organisation owner can restrict which apps may reach the organisation's repositories (Organisation settings → Third-party access).`,Zt=e=>V[e]?.label??e;function Qt(e){if(e===null)return`What happens to a change couldn't be worked out, because this toolbox's protection settings can't be read.`;if(e.kind===`unchecked`)return Gt;if(e.kind===`no-changes`)return`It doesn't offer any tools that make changes.`;let t;switch(e.kind){case`waits`:t=`Each change waits for you to say yes`;break;case`refused`:t=`Changes will be refused while your stance is “${Zt(e.posture)}”; switch to “Ask before changes” to allow them with approval`;break;case`partly-refused`:t=`Some changes are refused under your toolbox's settings (${(e.tools??[]).join(`, `)}); the rest wait for you to say yes`;break;case`runs`:t=`Some changes run without asking you: ${(e.tools??[]).join(`, `)}. Change them to “Ask me first” on the Tools page`;break;case`observe`:t=`Changes run without asking while the toolbox only watches`}return e.preApproved?`${t}, but a pre-approval lets some changes run without asking.`:`${t}.`}function $t(e){return e.state===`open`?{label:`Open`,tone:`bad`}:e.state===`unknown`?{label:`Can't check`,tone:`warn`}:e.state===`harder`?{label:`Made harder`,tone:`neutral`}:e.confirmed?{label:`Closed (you confirmed)`,tone:`ok`}:{label:`Closed (checked)`,tone:`ok`}}function en(){let e=H(),t=B(()=>Bt.doors(),[]),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)({}),o=t.data;if(!o||o.servers.length===0)return null;let s=(n,i,a)=>{r(n),i().then(()=>{e.show(`ok`,a),t.reload()}).catch(t=>e.show(`bad`,W(t))).finally(()=>r(null))};return(0,Z.jsx)(re,{title:Vt,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:Ht}),o.servers.map(o=>(0,Z.jsx)(tn,{server:o,busy:n,check:i[`${o.gatewayId}/${o.upstream}`]??null,onSwitch:n=>{r(`switch:${o.upstream}`),Bt.setChanges(o,n).then(r=>{let i=r.servers.find(e=>e.gatewayId===o.gatewayId&&e.upstream===o.upstream);e.show(`ok`,n?`Claude can now change GitHub through hmcp. ${Qt(i?.changes??null)}`:`Your GitHub server can only look again.`),r.note&&e.show(`info`,r.note),t.reload()}).catch(t=>e.show(`bad`,W(t))).finally(()=>r(null))},onCheck:()=>{r(`check:${o.upstream}`),Bt.check(o).then(e=>{a(t=>({...t,[`${o.gatewayId}/${o.upstream}`]:e})),t.reload()}).catch(t=>e.show(`bad`,W(t))).finally(()=>r(null))}},`${o.gatewayId}/${o.upstream}`)),(0,Z.jsx)(`ul`,{className:`flex flex-col`,children:o.doors.map(e=>(0,Z.jsx)(nn,{door:e,busy:n,onBlock:e=>s(`claude-code`,()=>Bt.claudeCode(e),e?`GitHub is blocked in Claude Code. Restart Claude Code to be sure it's applied.`:`The block was taken out of Claude Code's settings.`),onConfirm:t=>s(`confirm:${e.id}`,()=>Bt.confirm(e.id,t),t?`Noted as done.`:`Noted as not done yet.`)},e.id))}),(0,Z.jsx)(l,{tone:`info`,children:Ut}),(0,Z.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:Xt})]})})}function tn({server:e,busy:t,check:n,onSwitch:r,onCheck:i}){return e.access===null?null:(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[14px]`,children:[(0,Z.jsxs)(`p`,{className:`font-medium`,children:[(0,Z.jsx)(`code`,{className:`mono`,children:e.upstream}),` in `,e.gatewayLabel]}),(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:e.access===`readonly`?Wt:Yt}),(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:e.access===`readonly`?Kt:Qt(e.changes)}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:e.access===`readonly`?(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`shield-check`,loading:t===`switch:${e.upstream}`,onClick:()=>r(!0),children:qt}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`check`,loading:t===`check:${e.upstream}`,onClick:i,children:`Check it works`}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`eye`,loading:t===`switch:${e.upstream}`,onClick:()=>r(!1),children:Jt})]})}),n&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:n.lines.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:e.ok?`check`:`warning`,size:17,className:e.ok?`mt-0.5 shrink-0 text-ok`:`mt-0.5 shrink-0 text-bad`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:e.ok?`Passed: `:`Needs a look: `}),e.text]})]},e.text))}),(0,Z.jsx)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:n.note})]})]})}function nn({door:t,busy:n,onBlock:r,onConfirm:i}){let a=$t(t),o=t.links!==void 0;return(0,Z.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-faint py-3 last:border-b-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[15px] font-medium`,children:t.label}),(0,Z.jsx)(e,{tone:a.tone,children:a.label})]}),(0,Z.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:t.detail}),o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.links.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsx)(T,{href:e.url,external:!0,size:`sm`,icon:`external`,className:`shrink-0`,children:e.label}),(0,Z.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.press})]},e.url))}),t.why&&(0,Z.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:t.why}),(0,Z.jsx)(se,{checked:t.confirmed===!0,disabled:n===`confirm:${t.id}`,onChange:i,label:`I've done this`})]}):t.state!==`closed`&&t.fix.length>0&&(0,Z.jsx)(`ol`,{className:`ml-5 list-decimal text-[13px] text-muted`,children:t.fix.map(e=>(0,Z.jsx)(`li`,{children:e},e))}),t.id===`claude-code-terminal`&&t.state===`harder`&&(0,Z.jsx)(`p`,{className:`text-[13px] text-muted`,children:`Claude Code enforces these rules, but a prefix rule makes a way around them much harder, not impossible. For a guarantee, also log gh out and remove saved GitHub git credentials.`}),t.id===`claude-code-terminal`&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.state!==`closed`&&t.state!==`harder`&&(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`lock`,loading:n===`claude-code`,onClick:()=>r(!0),children:`Block GitHub in Claude Code (all projects)`}),t.undoable?.includes(`user`)&&(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:n===`claude-code`,onClick:()=>r(!1),children:`Undo`})]})]})}function rn({servers:t,serverId:n}){let r=H(),i=B(()=>ge.guard(),[],3e4),[a,o]=(0,X.useState)(!1),s=t.filter(e=>e.ok),c=s.find(e=>e.id===n)??s[0];if(!c)return null;let u=i.data?.installed===!0,d=u?s.find(e=>e.id===i.data?.serverId):void 0,f=e=>{o(!0),ge.setGuard(e,c.id).then(t=>{r.show(`ok`,`${e?`Turned on`:`Turned off`}. ${t.restartHint}`),t.warning&&r.show(`warn`,t.warning),i.reload()}).catch(e=>r.show(`bad`,W(e))).finally(()=>o(!1))};return(0,Z.jsx)(re,{title:`Guard every Claude Code tool with hmcp`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Every tool Claude Code uses — connectors, plugins, the terminal and file edits — is checked by your toolbox first. Restart Claude Code after turning this on.`}),(0,Z.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[`Reading web pages counts as looking, so it runs without asking. A web address can carry information out, and the guard does not stop that unless a rule names `,(0,Z.jsx)(`code`,{className:`mono`,children:`claude-code__WebFetch`}),`.`]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(e,{tone:u?i.data?.changedByHand?`warn`:`ok`:`neutral`,icon:`shield`,children:u?`On, checked by ${d?.label??`a toolbox`}${i.data?.changedByHand?` (changed by hand)`:``}`:`Off`}),(0,Z.jsx)(`span`,{className:`text-[12.5px] text-soft`,children:`All projects`})]}),i.error&&(0,Z.jsx)(l,{tone:`warn`,children:i.error}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{size:`sm`,variant:u?`ghost`:`primary`,loading:a,onClick:()=>f(!u),children:u?`Turn off`:`Turn on, checked by ${c.label}`})})]})})}function an(e){return B(()=>Re(e),[e],3e3)}function on(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 sn({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)(je,{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 cn({id:n,label:r}){let i=an(n),{reload:s}=K(),u=H(),[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`?he(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`?Xe(n):Pe(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(Se(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=on(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)(je,{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)(xe,{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)(sn,{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 ln({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)(un,{id:e,label:s?.label??e,tab:t,onTab:n,replaceKeyFor:i??null,onOpened:a},e)})}function un({id:e,label:t,tab:n,onTab:r,replaceKeyFor:i,onOpened:a}){let o=B(()=>Be(e),[e]),s=an(e),u=H(),{reload:f}=K(),p=Ne(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:Se(t),run:()=>e(j.digest,{loosens:!0}).then(e=>{i(e),a(!0)})})}):(Ae(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),Pe(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)(cn,{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)(gn,{id:e,file:j,write:F}):j.broken===null&&N===`servers`?(0,Z.jsx)(dn,{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)(mn,{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 dn({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=H(),p=Qe(),[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:ut()};let e=c?u.find(e=>e.name===c.server):void 0;return e&&c?.kind===`replace-key`&&ke(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?ke(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=at(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)(ct,{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),pn(rt(y.draft),n.keptSecret).then(e=>r((n,r)=>y.original?Te(t,y.original,e,n,r):He(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)(tt,{gatewayId:t,fixUpstream:_,onCancel:()=>{st(),v(null)},onDone:e=>{st(),v(null),f.show(`ok`,`${e.upstreamName} was saved.`),s()}});if(m)return(0,Z.jsx)(tt,{gatewayId:t,onCancel:()=>{st(),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:ut()})},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)(Fe,{id:t,upstreams:u,digest:n.digest,onMoved:s}),(0,Z.jsx)(Ie,{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=ze(a,n.name),c=(A.data??[]).find(e=>e.server===n.name),l=r&&r.state===`connected`&&c?{...r,state:`failed`,problem:Ue(n,c)}:r,u=o&&!!a?.running&&!!l&&(l.state===`failed`||l.state===`needs-sign-in`),f=!u&&Le(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)(We,{live:a,running:o,state:l})})]}),n.on_injection&&(0,Z.jsx)(e,{children:ye[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)(Ve,{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)(Ve,{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:fn(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=>$e(t,e,n),`${e} was removed.`).then(()=>k(null)).finally(()=>D(!1))},children:`Remove server`})]})})]})}function fn(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 pn(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)&&ve(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 mn({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)=>we(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:ye[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:ye[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:ye[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)(hn,{term:`Console may change protection rules`,technical:`policy_writes`,on:t.guarded.policy_writes}),(0,Z.jsx)(hn,{term:`Console may reverse an existing decision`,technical:`policy_overrides`,on:t.guarded.policy_overrides})]})]})]})}function hn({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 gn({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),Ye(e,i).then(s).catch(e=>m(W(e))).finally(()=>u(!1))},g=()=>{f(!0),n((t,n)=>Ze(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 _n={ok:`bg-ok`,warn:`bg-warn`,bad:`bg-bad`,neutral:`bg-soft`};function vn(){let{nav:e,servers:t,serverId:n,reload:r}=K(),i=H(),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)(xn,{}):(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:fe(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)(Sn,{server:e},e.id):(0,Z.jsx)(Cn,{server:e},e.id))})]}),(0,Z.jsx)(en,{}),(0,Z.jsx)(rn,{servers:t,serverId:n}),(0,Z.jsx)(En,{servers:t})]}),(0,Z.jsx)(ht,{open:a.get(`connect`)===`1`,onClose:()=>o(`connect`)}),(0,Z.jsx)(Mt,{open:a.get(`add`)===`1`,onClose:()=>o(`add`)}),(0,Z.jsx)(bn,{open:a.get(`add`)===`server`,gatewayId:yn(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)(ln,{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 yn(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 bn({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:()=>{st(),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)(tt,{gatewayId:t,onCancel:n,onDone:e=>r(e.upstreamName,e.created)})})}function xn(){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 bring its servers into 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, Codex, the ChatGPT desktop app, GitHub Copilot CLI, Antigravity CLI, Devin Desktop, Junie or Roo Code. 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 Sn({server:t}){let{nav:n,reload:r}=K(),a=H(),o=B(()=>Re(t.id),[t.id],15e3),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=o.data,m=p?on(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=Ne(t.id),S=Je(t.id),C=De(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 V&&(0,Z.jsx)(e,{children:V[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?ze(x.data,e):null,n=t?.state===`connected`&&(S.data??[]).some(t=>t.server===e),r=n?`bad`:t?be[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:de(`h-2 w-2 rounded-full`,_n[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:[`· `,be[t.state].label.toLowerCase()]}),t&&!n&&(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`: `,be[t.state].label]})]},e)})}),C&&(0,Z.jsxs)(`p`,{className:de(`-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:G(q(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),Xe(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)(wn,{server:d?t:null,onClose:()=>f(!1)})]})}function Cn({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:G(q(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)(wn,{server:r?t:null,onClose:()=>i(!1)})]})}function wn({server:e,onClose:t}){let{reload:n}=K(),r=H(),[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 Tn={"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`,"github.claude-code.block":`GitHub blocked in Claude Code`,"github.claude-code.unblock":`GitHub block in Claude Code undone`,"github.changes.on":`GitHub changes switched on`,"github.changes.off":`GitHub set back to only looking`};function En({servers:e}){let{nav:t}=K(),[n,r]=(0,X.useState)(`noteworthy`),a=e.filter(e=>e.ok).map(e=>e.id).join(`,`),o=B(()=>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: `,G(q(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)(Dn,{record:e,gateway:s(e.serverId),href:i(t,`/activity`,{server:e.serverId??``,seq:String(e.seq)})},`${e.serverId}-${e.seq}-${e.id}`))})]})})}function Dn({record:t,gateway:n,href:r}){let i=t.tool.startsWith(`(`)||Tn[t.rule_id]!==void 0,a=i?Tn[t.rule_id]??`Console change`:Ke(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{vn as ConnectionsPage};
|
|
@@ -1 +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,It as l,L as u,M as d,N as f,Nt as p,O as m,Ot as h,P as g,Pt as _,Q as v,R as y,U as b,Z as x,_ as S,_t as C,b as w,c as T,d as ee,et as E,f as te,gt as D,ht as O,it as ne,k,kt as A,m as j,mt as M,nt as N,pt as P,rt as F,s as I,st as L,tt as re,vt as R,w as z,wt as ie,x as ae,y as B,yt as V,z as oe}from"./kit-DRVm92_t.js";import{bn as H,gn as U,un as se}from"./index-CTvq_isK.js";var W=l(),G=A(),ce=(0,W.createContext)(null);function K(){let e=(0,W.useContext)(ce);if(!e)throw Error(`useWriter outside the Protection page`);return e}var le=new Set([`enforcement`,`defaults.mode`,`defaults.on_unclassified`,`approvals.mode`,`approvals.ttl_seconds`,`approvals.single_use`]),ue=[`egress.`],de=e=>le.has(e)||e===`egress`||ue.some(t=>e.startsWith(t));function q(e){if(/policy_overrides/.test(e))return`This toolbox only lets the console make settings stricter, so this change has to be made in the settings file by whoever manages the toolbox.`;if(/policy_writes/.test(e))return`This toolbox is set up to refuse changes from the console.`;if(/written inline/.test(e))return`These settings live inside the toolbox's own configuration, so the console can show them but not change them.`;if(/no tenant block/.test(e))return`This toolbox does not keep customers apart, so there is nothing to change here.`;if(/already /.test(e)&&/is already/.test(e))return`That is already the current setting.`;let t=e.replace(/`?(?:npx\s+)?hmcp(?:-gateway|-web)?\s[^`.;)]*`?/g,`the console`).replace(/\s--[a-z][\w-]*/g,``).replace(/`/g,``);return t=t.charAt(0).toUpperCase()+t.slice(1),t}var fe={enforcement:`Protection mode`,on_tool_change:`Changed tools`,"defaults.mode":`The default stance`,"defaults.on_unclassified":`Unlabelled tools`,"approvals.mode":`Where you're asked`,"approvals.ttl_seconds":`How long a request waits`,"approvals.single_use":`One approval per call`,tool_budget:`The tool limit`,"audit.enabled":`The activity log`,"audit.hash_chain":`The tamper check`,"audit.record_args":`Recording inputs`,"audit.on_failure":`What happens if the log can't be written`,"tenant.on_mismatch":`Wrong-customer handling`,"tenant.required":`Requiring a customer`},pe={"read-only":`Only let it look`,"approve-writes":`Ask before changes`,locked:`Lock everything`,enforce:`Protecting`,observe:`Watch-only`};function me(e){let t=/^([\w.]+) goes from (.+) to (.+)$/.exec(e);if(t&&(fe[t[1]]||/^(egress|results|audit)\./.test(t[1]))){let e=fe[t[1]]??`The setting ${t[1]}`,n=e=>{let t=e.replace(/^"|"$/g,``);return pe[t]??t};return`${e} goes from ${n(t[2])} to ${n(t[3])}`}return e.replace(/\bfrom allow\b/g,`from Runs freely`).replace(/\bfrom approve\b/g,`from Asks you first`).replace(/\bfrom deny\b/g,`from Blocked`).replace(/\bto allow\b/g,`to Runs freely`).replace(/\bto approve\b/g,`to Asks you first`).replace(/\bto deny\b/g,`to Blocked`).replace(/\bsays allow\b/g,`lets tools run freely`).replace(/\bsays approve\b/g,`asks you first`).replace(/\bsaid allow\b/g,`let tools run freely`).replace(/\bsaid approve\b/g,`asked you first`).replace(/\bsaid deny\b/g,`blocked them`).replace(/\ba write tool\b/g,`a tool that makes changes`).replace(/\ba destructive tool\b/g,`a tool that deletes`).replace(/\ba read tool\b/g,`a tool that only looks`).replace(/argument bounds/g,`input limits`).replace(/within bounds/g,`within limits`).replace(/the tenant block/g,`customers`).replace(/`/g,``)}function he({serverId:e,tenant:t,canWrite:n,canLoosen:r,digestRef:i,reloadsLive:a,onWritten:o,onReload:s,children:c}){let l=B(),[u,d]=(0,W.useState)(null),[f,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),[v,y]=(0,W.useState)(!1),b=(0,W.useRef)(o);b.current=o;let x=(0,W.useCallback)((e,t)=>{i.current=e.digest,l.show(`ok`,t||!a?`Saved. The toolbox applies it the next time it starts.`:`Saved. The toolbox applies it within a second.`),e.warning&&l.show(`warn`,q(e.warning)),b.current()},[i,a,l]),S=(0,W.useCallback)(async(e,t,n={})=>{let i=()=>new Promise(r=>{g(null),d({copy:t,resolve:r,run:async()=>{let t=await e({loosens:!0});n.done?.(t),x(t,n.restart??!1)}})});if(n.knownLoosens)return r?i():(l.show(`bad`,q(`policy_overrides`)),!1);try{let t=await e();return n.done?.(t),x(t,n.restart??!1),!0}catch(e){return e instanceof p&&e.needsLoosenAck?i():e instanceof p&&e.status===409?(y(!0),!1):(l.show(`bad`,q(e.message)),!1)}},[r,x,l]),C=(0,W.useCallback)((n,r)=>S(a=>_.setPolicySetting(e,n,r,i.current,a,t),_e(n,r),{restart:!de(n)}),[i,S,e,t]),T=async()=>{if(u){m(!0);try{await u.run(),u.resolve(!0),d(null)}catch(e){e instanceof p&&e.status===409?(u.resolve(!1),d(null),y(!0)):g(q(e.message))}finally{m(!1)}}},ee={serverId:e,tenant:t,canWrite:n,canLoosen:r,digest:()=>i.current,guarded:S,saveSetting:C};return(0,G.jsxs)(ce.Provider,{value:ee,children:[c,(0,G.jsx)(w,{open:u!==null,title:u?.copy.title??``,consequences:u?.copy.consequences??[],confirmLabel:u?.copy.confirmLabel??`Save setting`,busy:f,error:h,onCancel:()=>{u?.resolve(!1),d(null)},onConfirm:T,children:u?.copy.body}),(0,G.jsx)(ae,{open:v,onClose:()=>y(!1),title:`These settings changed since you opened them`,description:`This changed since you opened it. Reload and try again. Someone else, or the settings file itself, made a change in the meantime, and saving now could undo it.`,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(O,{variant:`secondary`,onClick:()=>y(!1),children:`Close`}),(0,G.jsx)(O,{variant:`primary`,icon:`refresh`,onClick:()=>{y(!1),s()},children:`Reload settings`})]})})]})}var ge=e=>Array.isArray(e)?e.join(`, `):String(e);function _e(e,t){let n=(e,t,n=`Save setting`)=>({title:e,body:`This lets more through than your settings do now.`,consequences:[t],confirmLabel:n});switch(e){case`enforcement`:return{title:`Switch to watch-only?`,body:`Your rules stop being applied. The activity log keeps noting what they would have done, so you can review it later.`,consequences:[`Every call runs, including calls your rules block.`,`Nothing waits for your approval.`,`Tools you turned off stay off.`],confirmLabel:`Switch to watch-only`};case`on_tool_change`:return n(`Keep serving changed tools?`,`A tool whose description or inputs change keeps working before anyone reviews it.`,`Keep serving changed tools`);case`defaults.mode`:return n(`Change the default stance?`,t===`approve-writes`?`Tools no rule mentions can make changes and delete things, once you approve each call.`:`Tools no rule mentions can look at information without asking.`,`Change default stance`);case`defaults.on_unclassified`:return n(`Ask about unlabelled tools instead of blocking them?`,`A tool nobody has labelled can run once you approve the call.`,`Ask me instead`);case`results.on_injection`:return n(`Let more tool answers through?`,t===`allow`?`Answers that contain hidden instructions reach your AI app with no warning attached.`:`Answers that contain hidden instructions reach your AI app, marked as untrusted.`,`Change what happens`);case`results.on_secret`:return n(`Let more tool answers through?`,t===`allow`?`Answers that contain a password or key reach your AI app, and nothing is noted in the log.`:`Answers that contain a password or key reach your AI app. The log notes each one.`,`Change what happens`);case`approvals.mode`:return n(`Change how you're asked?`,t===`cli`?`Calls that need approval can run once someone approves them in the console, instead of being blocked.`:`Requests can be answered from inside the AI app, which is a window the AI app itself controls.`,`Change how you're asked`);case`approvals.ttl_seconds`:return n(`Let requests wait longer?`,`A request stays open longer, so a call can be approved later than before.`);case`approvals.single_use`:return n(`Let one approval cover several calls?`,`One approval can release more than one identical call.`,`Allow repeat use`);case`tool_budget`:return n(`Raise the tool limit?`,`Your AI app can be shown more tools at once, which makes them harder to review.`,`Raise tool limit`);case`egress.allow`:return n(`Allow more websites?`,`Connected servers can reach more of the internet. The list becomes: ${ge(t)||`none`}.`,`Allow these websites`);case`egress.methods`:return n(`Allow more request types?`,`Connected servers can send these request types: ${ge(t)}. Types other than GET and HEAD can change things on other websites.`,`Allow these request types`);case`egress.max_body_bytes`:return n(`Allow bigger answers?`,`Connected servers can receive larger answers from websites.`);case`egress.max_request_body_bytes`:return n(`Allow bigger requests?`,`Connected servers can send more data out to websites.`);case`egress.timeout_ms`:return n(`Wait longer for websites?`,`A slow website can hold a call open for longer.`);case`egress.max_redirects`:return n(`Follow more redirects?`,`A website can send a request on to another address, which is then checked against your list again.`);case`egress.block_private_ips`:return n(`Allow your private network?`,`Connected servers can reach this computer and other devices on your own network.`,`Allow private network`);case`egress.allow_http`:return n(`Allow unencrypted requests?`,`Connected servers can send requests that anyone on the network path can read or alter.`,`Allow unencrypted requests`);case`egress.allow_ip_literals`:return n(`Allow raw IP addresses?`,`Connected servers can reach an address written as numbers, such as 203.0.113.5, rather than a website name.`,`Allow IP addresses`);case`audit.enabled`:return n(`Turn off the activity log?`,`Calls stop being recorded, so you could not see or prove what your AI did.`,`Turn off activity log`);case`audit.hash_chain`:return n(`Turn off the tamper check?`,`If someone edits or removes a log entry, nothing would show it.`,`Turn off tamper check`);case`audit.record_args`:return n(`Stop recording inputs?`,`The log no longer shows what each call was asked to do.`,`Stop recording inputs`);case`audit.redact`:return n(`Stop hiding these inputs?`,`Inputs with the names you removed are written to the log as they are, which may include secrets.`,`Stop hiding them`);case`audit.on_failure`:return n(`Run calls the log can't record?`,`If the log can't be written, calls still run, and nothing records them.`,`Run them anyway`);case`tenant.on_mismatch`:return n(`Replace the wrong customer instead of blocking?`,`A call that names the wrong customer is quietly corrected rather than stopped, so you won't see the attempt as a block.`,`Replace instead`);case`tenant.required`:return n(`Let the toolbox start without a customer?`,`The toolbox can start, and serve calls, without knowing which customer it is for.`,`Allow it`)}}var ve=(0,W.createContext)(null);function J({id:e,title:t,intro:n,actions:r,children:i}){let a=(0,W.useContext)(ve)===e;return(0,G.jsx)(`div`,{id:e,className:V(`scroll-mt-6 rounded-[var(--radius-card)] transition-shadow duration-300`,a&&`shadow-[0_0_0_3px_var(--focus)]`),children:(0,G.jsxs)(P,{title:t,titleId:`${e}-title`,actions:r,children:[n&&(0,G.jsx)(`p`,{className:`-mt-2 mb-5 max-w-3xl text-[14px] text-soft`,children:n}),i]})})}function Y({label:e,explain:t,yamlKey:n,saving:r,wide:i,children:a}){let{canWrite:o}=K(),s=o&&!de(n);return(0,G.jsxs)(`div`,{className:V(`grid gap-4 border-t border-faint py-5 first:border-t-0 first:pt-0 last:pb-0`,!i&&`md:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] md:gap-8`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 max-w-xl text-[13.5px] text-soft`,children:t}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,G.jsx)(`code`,{className:`mono text-[11.5px] text-soft`,children:n}),s&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-soft`,children:[(0,G.jsx)(h,{name:`refresh`,size:12,strokeWidth:2}),`Applies after a restart`]}),r&&(0,G.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1.5 text-[12px] font-medium text-muted`,children:[(0,G.jsx)(R,{size:12}),`Saving`]})]})]}),(0,G.jsx)(`div`,{className:`min-w-0`,children:a})]})}function X({label:e,value:t,options:n,onChange:r,disabled:i,columns:a=2,size:o=`md`}){return(0,G.jsx)(`div`,{role:`radiogroup`,"aria-label":e,onKeyDown:e=>{let t=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(!t)return;e.preventDefault();let n=[...e.currentTarget.querySelectorAll(`[role=radio]`)];n[(n.indexOf(document.activeElement)+t+n.length)%n.length]?.focus()},className:V(`grid gap-3`,a===2&&`sm:grid-cols-2`,a===3&&`md:grid-cols-3`,a===4&&`sm:grid-cols-2 xl:grid-cols-4`),children:n.map(e=>{let n=e.value===t;return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,disabled:i,onClick:()=>!n&&r(e.value),className:V(`group relative flex h-full flex-col items-start rounded-[18px] border-[1.5px] text-left transition-[border-color,background-color,transform] duration-150 ease-[var(--ease-out)]`,o===`md`?`p-5`:`px-4 py-3.5`,n?`border-[var(--primary)] bg-ok-tint`:`border-line bg-surface hover:border-[var(--soft)]`,i?`cursor-not-allowed`:`active:scale-[.99]`,i&&!n&&`opacity-60`),children:[(0,G.jsxs)(`span`,{className:`flex w-full items-start gap-3`,children:[e.icon&&o===`md`&&(0,G.jsx)(`span`,{className:V(`grid h-10 w-10 shrink-0 place-items-center rounded-full`,n?`bg-primary text-white`:`bg-sunken text-muted`),children:(0,G.jsx)(h,{name:e.icon,size:20})}),(0,G.jsx)(`span`,{className:V(`min-w-0 flex-1 font-semibold`,o===`md`?`pt-2 text-[16px]`:`text-[14px]`),children:e.title}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:V(`mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border-[1.5px]`,n?`border-[var(--primary)] bg-primary text-white`:`border-line`),children:n&&(0,G.jsx)(h,{name:`check`,size:12,strokeWidth:3})})]}),e.body&&(0,G.jsx)(`span`,{className:V(`block text-[13px] text-muted`,o===`md`?`mt-3`:`mt-1`),children:e.body})]},e.value)})})}function Z(e,t){let n=K(),[r,i]=(0,W.useState)(null);return{value:r??t,saving:r!==null,choose:async t=>{i(t),await n.saveSetting(e,t),i(null)},disabled:!n.canWrite||r!==null}}function Q({path:e,label:t,explain:n,checked:r,on:i,off:a}){let o=Z(e,r);return(0,G.jsx)(Y,{label:t,explain:n,yamlKey:e,saving:o.saving,children:(0,G.jsx)(`div`,{className:`rounded-2xl bg-sunken px-4 py-3`,children:(0,G.jsx)(f,{checked:o.value,onChange:e=>void o.choose(e),disabled:o.disabled,label:(0,G.jsx)(`span`,{className:`sr-only`,children:t}),description:(0,G.jsx)(`span`,{className:`text-[13.5px] font-medium text-ink`,children:o.value?i:a})})})})}function ye(e,t){let n=K(),[r,i]=(0,W.useState)(t),[a,o]=(0,W.useState)(!1),s=JSON.stringify(t),c=(0,W.useRef)(s);return(0,W.useEffect)(()=>{c.current!==s&&(c.current=s,i(t))},[s]),{draft:r,setDraft:i,dirty:JSON.stringify(r)!==s,saving:a,save:async(t=r)=>{o(!0),await n.saveSetting(e,t),o(!1)},reset:()=>i(t),disabled:!n.canWrite||a}}function be({dirty:e,saving:t,invalid:n,onSave:r,onReset:i}){return!e&&!t?null:(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsx)(O,{variant:`primary`,size:`sm`,icon:`check`,onClick:r,loading:t,disabled:n,children:`Save setting`}),(0,G.jsx)(O,{variant:`ghost`,size:`sm`,onClick:i,disabled:t,children:`Undo edit`})]})}function xe({children:e}){return(0,G.jsxs)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:[`Saved value: `,e]})}function $({path:e,label:t,explain:n,current:r,units:a,min:o=1,max:s,show:c}){let l=ye(e,r),u=()=>[...a].reverse().find(e=>r%e.size===0)??a[0],[d,f]=(0,W.useState)(u),[p,m]=(0,W.useState)(r/d.size),h=`${r}`,g=(0,W.useRef)(h);(0,W.useEffect)(()=>{if(g.current!==h){g.current=h;let e=u();f(e),m(r/e.size)}},[h]);let _=p===null?null:Math.round(p*d.size),v=_===null||!Number.isFinite(_)||_<o||s!==void 0&&_>s,y=_!==r,b=(0,W.useId)();return(0,G.jsxs)(Y,{label:t,explain:n,yamlKey:e,saving:l.saving,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(i,{id:b,"aria-label":t,value:p,onChange:m,min:0,disabled:l.disabled,className:`w-36`}),a.length>1?(0,G.jsx)(k,{"aria-label":`${t} unit`,value:d.label,onChange:e=>{let t=a.find(t=>t.label===e);_!==null&&m(Number((_/t.size).toFixed(3))),f(t)},options:a.map(e=>({value:e.label,label:e.label})),disabled:l.disabled,className:`w-28`}):(0,G.jsx)(`span`,{className:`text-[13.5px] text-soft`,children:a[0].label})]}),y&&v&&(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-[12.5px] font-medium text-bad`,children:s===void 0?`Use a number of at least ${c(o)}.`:`Use a whole number from ${c(o)} to ${c(s)}.`}),(0,G.jsx)(xe,{children:c(r)}),(0,G.jsx)(be,{dirty:y,saving:l.saving,invalid:v,onSave:()=>_!==null&&void l.save(_),onReset:()=>{f(u()),m(r/u().size)}})]})}function Se(e,t){let n=`^`,r=0;for(let t of e)t===`*`?n+=`.*`:t===`?`?n+=`.`:t===`{`?(n+=`(?:`,r++):t===`}`&&r>0?(n+=`)`,r--):n+=t===`,`&&r>0?`|`:t.replace(/[.+^${}()|[\]\\]/g,`\\$&`);try{return RegExp(n+`$`).test(t)}catch{return!1}}function Ce({changes:t,reasons:n,live:r}){return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[t.length===0?(0,G.jsx)(`p`,{className:`rounded-2xl bg-sunken px-4 py-3 text-[13.5px] text-muted`,children:r?`No tool's outcome changes. Tools the toolbox serves today are decided the same way as before.`:`The toolbox is not reporting its tools right now, so the console cannot list which tools this affects.`}):(0,G.jsx)(`ul`,{className:`divide-y divide-[var(--faint)] rounded-2xl border border-line`,"aria-label":`What changes`,children:t.map(t=>(0,G.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3`,children:[(0,G.jsx)(`code`,{className:`mono min-w-0 flex-1 basis-40 text-[13px] break-all`,children:t.tool}),(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[t.before===t.after?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E,{decision:t.after}),(0,G.jsx)(`span`,{className:`text-[12.5px] text-soft`,children:`with different input limits`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E,{decision:t.before}),(0,G.jsx)(h,{name:`arrow-right`,size:16,className:`text-soft`,label:`becomes`}),(0,G.jsx)(E,{decision:t.after})]}),t.loosens&&(0,G.jsx)(e,{tone:`bad`,children:`Lets more through`})]})]},t.tool))}),n.length>0&&(0,G.jsxs)(`div`,{className:`rounded-2xl bg-bad-tint px-4 py-3 text-[13.5px]`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-bad`,children:`This lets more through:`}),(0,G.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-5 text-ink`,children:n.map(e=>(0,G.jsx)(`li`,{children:me(e)},e))})]})]})}function we({live:e}){let t=K(),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,v]=(0,W.useState)(null),y=async()=>{l(!0),a(null);try{let e=await _.policyFile(t.serverId,t.tenant);r(e),d(e.text??``),p(null)}catch(e){a(q(e.message))}finally{l(!1)}},b=n?.text??``,x=u!==b,S=f?.text===u?f.result:null,C=!t.canWrite||!n?.writable.ok;return(0,G.jsx)(J,{id:`file`,title:`Edit settings file (advanced)`,intro:`Every setting on this page lives in one file. Edit it as text when you need something the controls above don't offer. The console checks your edit before saving, and a file with a mistake is never saved.`,children:n?n.text===null?(0,G.jsx)(c,{tone:`danger`,title:`The settings file could not be read`,children:n.readError?q(n.readError):`The toolbox's settings are written inside its own configuration, so there is no separate file to edit.`}):(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Text patterns (regular expressions) can't be added from here, because a badly written one can slow every call down. Patterns already in the file can stay or be removed.`}),(0,G.jsx)(j,{label:`Settings file`,value:u,onChange:d,readOnly:C,rows:20}),!C&&(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(O,{onClick:async()=>{h(`preview`),v(null);try{p({text:u,result:await _.previewPolicyFile(t.serverId,u,t.tenant)})}catch(e){v(q(e.message))}finally{h(null)}},loading:m===`preview`,disabled:!x||m!==null,icon:`eye`,children:`Preview changes`}),(0,G.jsx)(O,{variant:`primary`,icon:`check`,onClick:async()=>{if(!S||!n)return;h(`save`);let e=await t.guarded(e=>_.writePolicyFile(t.serverId,u,S.expectedDigest,e,t.tenant),{title:`Save a settings file that lets more through?`,body:`After this change, some calls that are blocked or held today would run.`,consequences:S.loosenReasons.length?S.loosenReasons.map(me):[`Some settings would be less strict.`],confirmLabel:`Save file`},{knownLoosens:S.loosens});h(null),e&&await y()},loading:m===`save`,disabled:!S?.valid||m!==null,children:`Save file`}),(0,G.jsx)(O,{variant:`ghost`,onClick:()=>d(b),disabled:!x||m!==null,children:`Discard edits`})]}),g&&(0,G.jsx)(c,{tone:`danger`,children:g}),m===`preview`&&(0,G.jsx)(s,{lines:4,height:16}),S&&(0,G.jsx)(`div`,{className:`space-y-4 rounded-2xl border border-line p-4`,children:S.valid?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-2 text-[14px] font-semibold`,children:`Lines you changed`}),(0,G.jsx)(te,{before:b,after:u,label:`Lines you changed`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-2 text-[14px] font-semibold`,children:`What changes for your tools`}),(0,G.jsx)(Ce,{changes:S.changes,reasons:S.loosenReasons,live:e})]})]}):(0,G.jsx)(c,{tone:`danger`,title:`This file has a mistake, so it can't be saved`,role:`alert`,children:(0,G.jsx)(`pre`,{className:`mt-1 font-mono text-[12.5px] whitespace-pre-wrap`,children:q(S.error??``)})})}),x&&!S&&m===null&&(0,G.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`Preview your changes to save them.`})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(O,{icon:`file`,onClick:y,loading:o,children:`Open settings file`}),i&&(0,G.jsx)(`div`,{className:`basis-full`,children:(0,G.jsx)(c,{tone:`danger`,actions:(0,G.jsx)(O,{size:`sm`,onClick:y,children:`Try again`}),children:i})})]})})}var Te={read:`only look`,write:`make changes`,destructive:`delete`},Ee={deny:`blocked`,approve:`held for you`},De={allow:`let through`,approve:`held for you`,deny:`blocked`};function Oe(e,t){let n=[];return t.min!==void 0&&t.max!==void 0?n.push(`${t.min} to ${t.max}`):t.max===void 0?t.min!==void 0&&n.push(`at least ${t.min}`):n.push(`at most ${t.max}`),t.maxLength!==void 0&&n.push(`up to ${t.maxLength} characters`),t.maxItems!==void 0&&n.push(`up to ${t.maxItems} items`),t.enum&&n.push(`one of ${t.enum.map(String).join(`, `)}`),t.within&&n.push(`inside ${String(t.within)}`),Array.isArray(t.host)&&n.push(`only ${t.host.join(`, `)}`),t.pattern&&n.push(`matching a text pattern`),t.optional&&n.push(`may be left out`),`${e}: ${n.join(`, `)||`limited`}`}function ke(e,t){return{title:`Make a change that lets more through?`,body:`After this change, some calls that are blocked or held today would run.`,consequences:e.loosenReasons.length?e.loosenReasons.map(me):[`Some tools would be decided less strictly.`],confirmLabel:t}}function Ae({p:e,full:t,fullError:n}){let r=K(),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),l=(0,W.useMemo)(()=>new Map((t??[]).map(e=>[e.id,e])),[t]),u=e.rules,d=u.map(e=>e.id),f=e.surface.live,p=(e,t)=>{let n=[...d];[n[e],n[e+t]]=[n[e+t],n[e]],s({body:{op:`order`,order:n},title:`Move ${d[e]} ${t<0?`up`:`down`}?`,confirm:t<0?`Move rule up`:`Move rule down`})};return(0,G.jsxs)(J,{id:`rules`,title:`Rules`,intro:(0,G.jsxs)(G.Fragment,{children:[`Rules are checked from the top. The first rule that matches a tool decides what happens to it, so order matters. `,(0,G.jsx)(S,{term:`rule`})]}),actions:r.canWrite&&(0,G.jsx)(O,{variant:`primary`,size:`sm`,icon:`plus`,onClick:()=>a({mode:`add`}),disabled:!t,children:`Add rule`}),children:[n&&(0,G.jsx)(`div`,{className:`mb-4`,children:(0,G.jsxs)(c,{tone:`warn`,children:[`The rules could not be read in full, so they can't be edited right now. `,q(n)]})}),u.length===0?(0,G.jsx)(b,{compact:!0,icon:`list`,title:`No rules yet`,actions:r.canWrite&&(0,G.jsx)(O,{variant:`primary`,icon:`plus`,onClick:()=>a({mode:`add`}),disabled:!t,children:`Add rule`}),children:`Every call is decided by the default stance above. Add a rule to treat some tools differently.`}):(0,G.jsx)(`ol`,{className:`space-y-3`,"aria-label":`Rules, in the order they are checked`,children:u.map((e,t)=>(0,G.jsx)(je,{r:e,index:t,count:u.length,live:f,full:l.get(e.id),canEdit:r.canWrite&&l.has(e.id),onEdit:()=>a({mode:`edit`,rule:l.get(e.id)}),onDelete:()=>s({body:{op:`delete`,ruleId:e.id},title:`Delete ${e.id}?`,confirm:`Delete rule`}),onMove:e=>p(t,e)},e.id))}),i&&t&&(0,G.jsx)(Re,{rule:i.mode===`edit`?i.rule:null,rules:t,tools:e.tools.map(e=>e.name),live:f,onClose:()=>a(null)},i.mode===`edit`?i.rule.id:`add`),o&&(0,G.jsx)(Me,{...o,live:f,onClose:()=>s(null)})]})}function je({r:e,full:t,index:r,count:i,live:a,canEdit:o,onEdit:s,onDelete:c,onMove:l}){let[u,d]=(0,W.useState)(!1),f=u?e.matchedTools:e.matchedTools.slice(0,6),p=e.effect,m=t?.args?Object.entries(t.args).map(([e,t])=>Oe(e,t)):e.argConstraints;return(0,G.jsx)(`li`,{className:`rounded-[18px] border-[1.5px] border-line bg-surface p-4 sm:p-5`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-3`,children:[(0,G.jsx)(`span`,{className:`tnum grid h-8 w-8 shrink-0 place-items-center rounded-full bg-sunken text-[13px] font-bold`,"aria-label":`Position ${r+1}`,children:r+1}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-[15px] leading-snug`,children:[(0,G.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[13px] break-all`,children:e.match}),p&&Te[p]&&(0,G.jsxs)(`span`,{children:[`that `,Te[p]]}),(0,G.jsx)(h,{name:`arrow-right`,size:16,className:`text-soft`,label:`then`}),(0,G.jsx)(E,{decision:e.decision})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[12.5px] text-soft`,children:[(0,G.jsx)(`code`,{className:`mono text-[11.5px]`,children:e.id}),p&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Labels them `,(0,G.jsx)(x,{effect:p,withLabel:!0})]})]}),e.reason&&(0,G.jsxs)(`p`,{className:`mt-2 text-[13.5px] text-muted`,children:[`“`,e.reason,`”`]}),m.length>0&&(0,G.jsxs)(`div`,{className:`mt-3 text-[13px]`,children:[(0,G.jsx)(`span`,{className:`text-soft`,children:`Input limits: `}),(0,G.jsx)(`span`,{className:`inline-flex flex-wrap gap-1.5 align-middle`,children:m.map(e=>(0,G.jsx)(`span`,{className:`rounded-md bg-sunken px-2 py-0.5 text-[12.5px] text-ink`,children:e},e))}),(0,G.jsxs)(`p`,{className:`mt-1 text-soft`,children:[`Calls outside the limits are`,` `,Ee[e.onViolation]??e.onViolation,`. Anything else the tool is sent is`,` `,De[e.unknownArgs]??e.unknownArgs,`.`]})]}),(0,G.jsx)(`div`,{className:`mt-3 text-[13px]`,children:e.matchedTools.length===0?(0,G.jsx)(`span`,{className:`text-soft`,children:a?`Matches no tool the toolbox serves right now.`:`The toolbox is not reporting its tools, so matches are unknown.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`text-soft`,children:[`Applies to `,n(e.matchedTools.length,`tool`),`:`,` `]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1.5 align-middle`,children:[f.map(e=>(0,G.jsx)(`code`,{className:`mono rounded-full border border-line px-2 py-0.5 text-[12px]`,children:e},e)),e.matchedTools.length>6&&(0,G.jsx)(`button`,{type:`button`,className:`text-[12.5px] font-semibold text-ink underline underline-offset-2`,onClick:()=>d(!u),children:u?`Show fewer`:`Show ${e.matchedTools.length-6} more`})]})]})}),e.shadowedBy&&(0,G.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-[13px] text-warn`,children:[(0,G.jsx)(h,{name:`warning`,size:15,className:`mt-0.5 shrink-0`,strokeWidth:2}),(0,G.jsxs)(`span`,{children:[`Never used:`,` `,(0,G.jsx)(`code`,{className:`mono text-[12px]`,children:e.shadowedBy}),` is higher up and matches these tools first.`]})]})]}),o&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 max-sm:w-full max-sm:justify-end`,children:[(0,G.jsx)(D,{icon:`chevron`,className:`rotate-180`,label:`Move ${e.id} up`,size:36,variant:`soft`,disabled:r===0,onClick:()=>l(-1)}),(0,G.jsx)(D,{icon:`chevron`,label:`Move ${e.id} down`,size:36,variant:`soft`,disabled:r===i-1,onClick:()=>l(1)}),(0,G.jsx)(O,{size:`sm`,icon:`edit`,onClick:s,"aria-label":`Edit rule ${e.id}`,children:`Edit`}),(0,G.jsx)(D,{icon:`trash`,label:`Delete rule ${e.id}`,size:36,onClick:c})]})]})})}function Me({body:e,title:t,confirm:n,live:r,onClose:i}){let a=K(),[o,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{_.previewRules(a.serverId,e,a.tenant).then(l,e=>d(q(e.message)))},[]),(0,G.jsxs)(ae,{open:!0,onClose:i,title:t,width:600,description:e.op===`delete`?`The rule is removed from the settings file. Tools it decided fall through to the next matching rule, or to the default stance.`:`Rules are checked from the top, so moving one can change which rule decides a tool.`,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(O,{variant:`secondary`,onClick:i,disabled:f,children:`Cancel`}),(0,G.jsx)(O,{variant:e.op===`delete`?`danger`:`primary`,onClick:async()=>{if(!o)return;p(!0);let t=await a.guarded(t=>e.op===`delete`?_.deleteRule(a.serverId,e.ruleId,o.expectedDigest,t,a.tenant):_.orderRules(a.serverId,e.order,o.expectedDigest,t,a.tenant),ke(o,n),{knownLoosens:o.loosens});p(!1),t&&i()},loading:f,disabled:!o,children:n})]}),children:[(0,G.jsx)(`h3`,{className:`mb-2 text-[14px] font-semibold`,children:`What changes`}),u?(0,G.jsx)(c,{tone:`danger`,children:u}):o?(0,G.jsx)(Ce,{changes:o.changes,reasons:o.loosenReasons,live:r}):(0,G.jsx)(s,{lines:3,height:18})]})}var Ne=[`max`,`min`,`maxLength`,`maxItems`,`enum`,`optional`],Pe=1;function Fe(e,t){let n={};for(let[e,r]of Object.entries(t))Ne.includes(e)||(n[e]=r);return{key:Pe++,path:e,max:t.max??null,min:t.min??null,maxLength:t.maxLength??null,maxItems:t.maxItems??null,values:(t.enum??[]).map(String),typed:t.enum??[],optional:!!t.optional,extra:n}}function Ie(e){let t={...e.extra};return e.max!==null&&(t.max=e.max),e.min!==null&&(t.min=e.min),e.maxLength!==null&&(t.maxLength=e.maxLength),e.maxItems!==null&&(t.maxItems=e.maxItems),e.values.length&&(t.enum=e.values.map(t=>e.typed.find(e=>String(e)===t)??t)),e.optional&&(t.optional=!0),t}var Le={pattern:`a text pattern`,coerce:`number conversion`,within:`a folder`,host:`allowed websites`,required:`required`,sum_max:`a total`,count_max:`a count`,const:`a fixed value`};function Re({rule:e,rules:t,tools:r,live:i,onClose:o}){let s=K(),l=e===null,[u,f]=(0,W.useState)(e?.id??``),[p,h]=(0,W.useState)(e?.match??``),[g,v]=(0,W.useState)(e?.effect??``),[y,b]=(0,W.useState)(e?.decision??`approve`),[x,C]=(0,W.useState)(()=>Object.entries(e?.args??{}).map(([e,t])=>Fe(e,t))),[w,T]=(0,W.useState)(e?.on_violation??`deny`),[E,te]=(0,W.useState)(e?.unknown_args??`allow`),[D,ne]=(0,W.useState)(e?.reason??``),[A,j]=(0,W.useState)(t.length),[M,N]=(0,W.useState)(null),[P,I]=(0,W.useState)(null),[L,R]=(0,W.useState)(!1),z=(0,W.useMemo)(()=>p.trim()?r.filter(e=>Se(p.trim(),e)):[],[p,r]),ie=l?u.trim()?/\s/.test(u)?`Use no spaces, for example ask-before-writes.`:t.some(e=>e.id===u.trim())?`Another rule already has this name.`:null:`Give the rule a short name.`:null,B=p.trim()?null:`Say which tools this rule is for.`,V=x.map(e=>e.path.trim()?x.filter(t=>t.path.trim()===e.path.trim()).length>1?`This input is listed twice.`:e.maxLength!==null&&(e.maxLength<1||!Number.isInteger(e.maxLength))?`Longest text must be a whole number of at least 1.`:e.maxItems!==null&&(e.maxItems<0||!Number.isInteger(e.maxItems))?`Most items must be a whole number.`:null:`Name the input.`),oe=!!ie||!!B||V.some(Boolean),H=()=>{let t={id:l?u.trim():e.id,match:p.trim(),decision:y};return g&&(t.effect=g),x.length?(t.args=Object.fromEntries(x.map(e=>[e.path.trim(),Ie(e)])),t.on_violation=w,t.unknown_args=E):l||(e.on_violation&&(t.on_violation=e.on_violation),e.unknown_args&&(t.unknown_args=e.unknown_args)),D.trim()&&(t.reason=D.trim()),t},U=e=>t=>{e(t),N(null),I(null)},se=async()=>{R(!0),I(null);try{let t=l?{op:`add`,rule:H(),index:A}:{op:`set`,ruleId:e.id,rule:H()};N(await _.previewRules(s.serverId,t,s.tenant))}catch(e){I(q(e.message))}finally{R(!1)}},ce=async()=>{if(!M)return;R(!0);let t=H(),n=await s.guarded(n=>l?_.addRule(s.serverId,t,M.expectedDigest,A,n,s.tenant):_.setRule(s.serverId,e.id,t,M.expectedDigest,n,s.tenant),ke(M,`Save rule`),{knownLoosens:M.loosens});R(!1),n&&o()},le=(e,t)=>U(C)(x.map(n=>n.key===e?{...n,...t}:n));return(0,G.jsx)(ae,{open:!0,onClose:o,dismissable:!L,width:720,title:l?`Add a rule`:`Edit rule`,description:M?`Check what this does to your tools, then save it.`:`Say which tools this is for and what should happen when your AI calls them.`,footer:M?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(O,{variant:`ghost`,icon:`arrow-left`,onClick:()=>N(null),disabled:L,children:`Back to the rule`}),(0,G.jsx)(O,{variant:`primary`,icon:`check`,onClick:ce,loading:L,children:`Save rule`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(O,{variant:`secondary`,onClick:o,disabled:L,children:`Cancel`}),(0,G.jsx)(O,{variant:`primary`,onClick:se,loading:L,disabled:oe,children:`Preview changes`})]}),children:M?(0,G.jsxs)(`div`,{className:`space-y-5 pb-1`,children:[(0,G.jsx)(Ce,{changes:M.changes,reasons:M.loosenReasons,live:i}),M.yaml&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-2 text-[13px] font-semibold text-soft`,children:`As it will be written in the settings file`}),(0,G.jsx)(ee,{label:`The rule as written`,children:M.yaml})]})]}):(0,G.jsxs)(`div`,{className:`space-y-5 pb-1`,children:[P&&(0,G.jsx)(c,{tone:`danger`,children:P}),l?(0,G.jsx)(a,{label:`Rule name`,help:`Shown in the activity log next to every call this rule decides.`,error:u?ie:null,children:(0,G.jsx)(d,{value:u,onChange:U(f),mono:!0,placeholder:`ask-before-writes`})}):(0,G.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`Rule name`,` `,(0,G.jsx)(`code`,{className:`mono ml-1 rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] text-ink`,children:e.id}),(0,G.jsx)(`span`,{className:`block text-[12.5px]`,children:`The name cannot be changed, because the activity log refers to it.`})]}),(0,G.jsx)(a,{label:`Which tools`,technical:`match`,help:(0,G.jsxs)(G.Fragment,{children:[`A tool name, or a pattern where * stands for any text, such as fs.* or *__delete_*.`,` `,p.trim()&&(z.length?`Matches ${n(z.length,`tool`)}: ${z.slice(0,5).join(`, `)}${z.length>5?`…`:``}`:`Matches no tool served right now.`)]}),error:p?B:null,children:(0,G.jsx)(d,{value:p,onChange:U(h),mono:!0,placeholder:`notes__create_*`})}),(0,G.jsx)(a,{label:`What should happen`,technical:`decision`,children:(0,G.jsx)(m,{label:`What should happen`,value:y,onChange:U(b),options:[`allow`,`approve`,`deny`].map(e=>({value:e,label:re[e].label}))})}),(0,G.jsx)(a,{label:`What these tools do`,technical:`effect`,help:`Labels the matching tools. The label decides how the default stance and your safety check treat them.`,optional:!0,children:(0,G.jsx)(k,{value:g,onChange:U(v),options:[{value:``,label:`Leave as the tool describes itself`},{value:`read`,label:`${F.read.label}: ${F.read.explain}`},{value:`write`,label:`${F.write.label}: ${F.write.explain}`},{value:`destructive`,label:`${F.destructive.label}: ${F.destructive.explain}`}]})}),(0,G.jsxs)(`fieldset`,{className:`rounded-2xl border border-line p-4`,children:[(0,G.jsxs)(`legend`,{className:`px-1 text-[13px] font-semibold`,children:[`Input limits `,(0,G.jsx)(S,{term:`limits`})]}),(0,G.jsx)(`p`,{className:`mb-3 text-[12.5px] text-soft`,children:`Allowed values for the tool's inputs. Text patterns can't be added from here; ones already in the settings file are kept as they are.`}),(0,G.jsx)(`div`,{className:`space-y-3`,children:x.map((e,t)=>(0,G.jsx)(ze,{a:e,error:V[t]??null,onChange:t=>le(e.key,t),onRemove:()=>U(C)(x.filter(t=>t.key!==e.key))},e.key))}),(0,G.jsx)(O,{size:`sm`,variant:`ghost`,icon:`plus`,className:`mt-2`,onClick:()=>U(C)([...x,{key:Pe++,path:``,max:null,min:null,maxLength:null,maxItems:null,values:[],typed:[],optional:!1,extra:{}}]),children:`Add a limit`}),x.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 grid gap-4 border-t border-faint pt-4 sm:grid-cols-2`,children:[(0,G.jsx)(a,{label:`A call outside the limits`,technical:`on_violation`,children:(0,G.jsx)(m,{label:`A call outside the limits`,size:`sm`,value:w,onChange:U(T),options:[{value:`deny`,label:`Block it`},{value:`approve`,label:`Ask me`}]})}),(0,G.jsx)(a,{label:`Anything else the tool is sent`,technical:`unknown_args`,help:`Inputs your limits don't mention. Letting them through means an extra input like force: true isn't checked.`,children:(0,G.jsx)(m,{label:`Anything else the tool is sent`,size:`sm`,value:E,onChange:U(te),options:[{value:`deny`,label:`Block it`},{value:`approve`,label:`Ask me first`},{value:`allow`,label:`Let it through`}]})})]})]}),(0,G.jsx)(a,{label:`Why this rule exists`,technical:`reason`,optional:!0,help:`A note for whoever reads the settings later.`,children:(0,G.jsx)(d,{value:D,onChange:U(ne)})}),l&&(0,G.jsx)(a,{label:`Where in the list`,help:`Rules higher up are checked first.`,children:(0,G.jsx)(k,{value:String(A),onChange:e=>U(j)(Number(e)),options:[...t.length?[{value:`0`,label:`At the top, checked first`}]:[],...t.slice(0,-1).map((e,t)=>({value:String(t+1),label:`After ${e.id}`})),{value:String(t.length),label:t.length?`At the end, after ${t[t.length-1].id}`:`First rule`}]})})]})})}function ze({a:n,error:r,onChange:o,onRemove:s}){let c=Object.keys(n.extra);return(0,G.jsxs)(`div`,{className:`rounded-xl bg-sunken p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsx)(a,{label:`Input name`,className:`min-w-0 flex-1`,error:r,children:(0,G.jsx)(d,{value:n.path,onChange:e=>o({path:e}),mono:!0,placeholder:`body`})}),(0,G.jsx)(D,{icon:`x`,label:`Remove the limit on ${n.path||`this input`}`,size:36,onClick:s})]}),(0,G.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 md:grid-cols-4`,children:[(0,G.jsx)(a,{label:`Largest number`,children:(0,G.jsx)(i,{value:n.max,onChange:e=>o({max:e})})}),(0,G.jsx)(a,{label:`Smallest number`,children:(0,G.jsx)(i,{value:n.min,onChange:e=>o({min:e})})}),(0,G.jsx)(a,{label:`Longest text`,children:(0,G.jsx)(i,{value:n.maxLength,onChange:e=>o({maxLength:e}),min:1,unit:`chars`})}),(0,G.jsx)(a,{label:`Most items`,children:(0,G.jsx)(i,{value:n.maxItems,onChange:e=>o({maxItems:e}),min:0})})]}),(0,G.jsx)(`div`,{className:`mt-3`,children:(0,G.jsx)(a,{label:`Only these values`,optional:!0,children:(0,G.jsx)(t,{value:n.values,onChange:e=>o({values:e}),placeholder:`Type a value and press Enter`})})}),(0,G.jsx)(`div`,{className:`mt-3`,children:(0,G.jsx)(z,{checked:n.optional,onChange:e=>o({optional:e}),label:`The AI may leave this input out`,description:`Otherwise a call without it is outside the limits.`})}),c.length>0&&(0,G.jsxs)(`p`,{className:`mt-3 flex items-center gap-1.5 text-[12.5px] text-soft`,children:[(0,G.jsx)(e,{tone:`neutral`,icon:`lock`,children:`Kept as written`}),c.map(e=>Le[e]??e).join(`, `)]})]})}function Be({p:e,nav:t}){let n=Z(`enforcement`,e.enforcement);return(0,G.jsx)(J,{id:`mode`,title:`Mode`,intro:`Whether the toolbox applies your settings, or only watches and notes what it would have done.`,children:(0,G.jsxs)(Y,{label:`Protection mode`,explain:(0,G.jsxs)(G.Fragment,{children:[`Watch-only is for learning what your AI does before you set rules.`,` `,(0,G.jsx)(S,{term:`watchOnly`})]}),yamlKey:`enforcement`,saving:n.saving,wide:!0,children:[(0,G.jsx)(X,{label:`Protection mode`,value:n.value,onChange:e=>void n.choose(e),disabled:n.disabled,options:[{value:`enforce`,title:`Protecting`,icon:`shield-check`,body:(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsx)(`li`,{children:`Blocked calls stop before they reach the tool.`}),(0,G.jsx)(`li`,{children:`Calls that need you wait for your approval.`}),(0,G.jsx)(`li`,{children:`Everything is written to the activity log.`})]})},{value:`observe`,title:`Watch-only`,icon:`eye`,body:(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsx)(`li`,{children:`Every call runs, even ones your rules would block.`}),(0,G.jsx)(`li`,{children:`Nothing waits for you.`}),(0,G.jsx)(`li`,{children:`The log notes what would have happened. Tools you turned off stay off.`})]})}]}),n.value===`observe`&&(0,G.jsx)(`div`,{className:`mt-4`,children:(0,G.jsx)(c,{tone:`warn`,title:`Your AI is not being protected right now`,actions:(0,G.jsx)(C,{href:r(t,`/suggestions`),variant:`secondary`,size:`sm`,icon:`lightbulb`,children:`See suggested rules`}),children:`Suggestions turns what watch-only saw into rules, so you can switch protection on without blocking work you rely on.`})})]})})}var Ve={"read-only":[`allow`,`deny`,`deny`],"approve-writes":[`allow`,`approve`,`approve`],locked:[`deny`,`deny`,`deny`]},He={allow:`run`,approve:`ask you first`,deny:`are blocked`};function Ue({stance:e}){let[t,n,r]=Ve[e],i=(e,t)=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(v,{decision:t}),(0,G.jsxs)(`span`,{children:[e,` `,He[t]]})]});return(0,G.jsxs)(`span`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`block`,children:L[e].explain}),(0,G.jsxs)(`ul`,{className:`mt-3 space-y-1.5`,children:[i(`Tools that look`,t),i(`Tools that make changes`,n),i(`Tools that delete`,r)]})]})}function We({p:e}){let t=Z(`defaults.mode`,e.defaults.mode??`read-only`),r=Z(`defaults.on_unclassified`,e.defaults.onUnclassified),i=Z(`on_tool_change`,e.onToolChange);return(0,G.jsxs)(J,{id:`stance`,title:`Default stance`,intro:`What happens to a call that none of your rules mention. Rules always come first.`,children:[(0,G.jsx)(Y,{label:`For tools no rule mentions`,explain:(0,G.jsxs)(G.Fragment,{children:[`Choose how careful to be by default. `,(0,G.jsx)(S,{term:`defaultStance`})]}),yamlKey:`defaults.mode`,saving:t.saving,wide:!0,children:(0,G.jsx)(X,{label:`Default stance`,columns:3,value:t.value,onChange:e=>void t.choose(e),disabled:t.disabled,options:[{value:`read-only`,title:`Only let it look`,icon:`eye`,body:(0,G.jsx)(Ue,{stance:`read-only`})},{value:`approve-writes`,title:`Ask before changes`,icon:`clock`,body:(0,G.jsx)(Ue,{stance:`approve-writes`})},{value:`locked`,title:`Lock everything`,icon:`lock`,body:(0,G.jsx)(Ue,{stance:`locked`})}]})}),(0,G.jsx)(Y,{label:`Tools nobody has labelled`,explain:(0,G.jsxs)(G.Fragment,{children:[`A tool that nobody has marked as looking, changing or deleting.`,` `,e.surface.unclassifiedCount>0&&(0,G.jsxs)(`strong`,{className:`font-semibold text-ink`,children:[n(e.surface.unclassifiedCount,`tool`),` like this right now.`,` `]}),(0,G.jsx)(S,{term:`unknownTools`})]}),yamlKey:`defaults.on_unclassified`,saving:r.saving,children:(0,G.jsx)(X,{label:`Tools nobody has labelled`,size:`sm`,value:r.value,onChange:e=>void r.choose(e),disabled:r.disabled,options:[{value:`deny`,title:`Block them`,body:`Nothing unlabelled runs. The safest choice.`},{value:`approve`,title:`Ask me`,body:`Each call waits for you to approve or block it.`}]})}),(0,G.jsx)(Y,{label:`When a tool changes after you reviewed it`,explain:(0,G.jsxs)(G.Fragment,{children:[`A tool's description or inputs can change when its server is updated, or when someone changes what it does without telling you.`,` `,(0,G.jsx)(S,{term:`changedTools`})]}),yamlKey:`on_tool_change`,saving:i.saving,children:(0,G.jsx)(X,{label:`When a tool changes after you reviewed it`,size:`sm`,value:i.value,onChange:e=>void i.choose(e),disabled:i.disabled,options:[{value:`warn`,title:`Warn me`,body:`The tool keeps working, and the change is listed for you to review.`},{value:`deny`,title:`Block it until I review`,body:`The tool is held back until you accept the change.`}]})})]})}function Ge({p:e}){let t=Z(`approvals.mode`,e.approvals.mode);return(0,G.jsxs)(J,{id:`approvals`,title:`How you're asked`,intro:(0,G.jsxs)(G.Fragment,{children:[`When a call needs your approval, where the question appears and how long it waits. `,(0,G.jsx)(S,{term:`approval`})]}),children:[(0,G.jsx)(Y,{label:`Where you're asked`,explain:`The AI app can only show a question if it supports it, so asking in both places is the most reliable.`,yamlKey:`approvals.mode`,saving:t.saving,children:(0,G.jsx)(X,{label:`Where you're asked`,size:`sm`,value:t.value,onChange:e=>void t.choose(e),disabled:t.disabled,options:[{value:`both`,title:`Both`,body:`In the AI app when it can, otherwise here in the console.`},{value:`elicit`,title:`In the AI app`,body:`A question pops up in the app that made the call.`},{value:`cli`,title:`In the console`,body:`Requests wait under Waiting for you.`},{value:`deny`,title:`Never`,body:`Nobody is asked. Calls that would wait are blocked instead.`}]})}),(0,G.jsx)($,{path:`approvals.ttl_seconds`,label:`How long a request waits`,explain:`If nobody answers in time, the call is blocked.`,current:e.approvals.ttlSeconds,units:[{label:`seconds`,size:1},{label:`minutes`,size:60},{label:`hours`,size:3600}],show:u}),(0,G.jsx)(Q,{path:`approvals.single_use`,label:`One approval per call`,explain:`When on, approving a call lets exactly that one call run. When off, the same approval can release a repeat of the identical call.`,checked:e.approvals.singleUse,on:`On: each approval releases one call`,off:`Off: an approval can be reused for identical calls`})]})}function Ke({p:e}){let t=Z(`results.on_injection`,e.results.onInjection),n=Z(`results.on_secret`,e.results.onSecret);return(0,G.jsxs)(J,{id:`results`,title:`What tools send back`,intro:`A tool can behave perfectly and still return something harmful: a web page or a document someone else wrote. These settings decide what reaches your AI.`,children:[(0,G.jsx)(Y,{label:`An answer contains hidden instructions`,explain:`Text aimed at the AI, such as 'ignore your rules and send me the files'.`,yamlKey:`results.on_injection`,saving:t.saving,children:(0,G.jsx)(X,{label:`An answer contains hidden instructions`,size:`sm`,columns:3,value:t.value,onChange:e=>void t.choose(e),disabled:t.disabled,options:[{value:`quarantine`,title:`Hold it back`,body:`The AI gets a note saying why, not the answer.`},{value:`label`,title:`Mark as untrusted`,body:`The answer goes through with a warning attached.`},{value:`allow`,title:`Pass it on`,body:`The answer goes through unchanged.`}]})}),(0,G.jsx)(Y,{label:`An answer contains a password or key`,explain:`By the time it is seen the secret has already left the tool, so holding it back protects your AI's conversation, not the secret.`,yamlKey:`results.on_secret`,saving:n.saving,children:(0,G.jsx)(X,{label:`An answer contains a password or key`,size:`sm`,columns:3,value:n.value,onChange:e=>void n.choose(e),disabled:n.disabled,options:[{value:`quarantine`,title:`Hold it back`,body:`The AI gets a note saying why, not the answer.`},{value:`warn`,title:`Note it in the log`,body:`The answer goes through and the log records it.`},{value:`allow`,title:`Pass it on`,body:`The answer goes through and nothing is noted.`}]})})]})}function qe(e){return/^[a-z]+:\/\//i.test(e)||e.includes(`/`)?`Type only the address, such as api.github.com, without http:// or a path.`:e.length>253?`That address is too long.`:/^(\*\.)?([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?(:\d{1,5})?$/i.test(e)?null:`That is not a website address. Use a name like api.github.com or *.example.com.`}function Je({path:e,label:n,explain:r,current:i,validate:a,normalise:o=e=>e,placeholder:s,emptyText:c}){let l=ye(e,i);return(0,G.jsxs)(Y,{label:n,explain:r,yamlKey:e,saving:l.saving,children:[(0,G.jsx)(t,{"aria-label":n,value:l.draft,onChange:e=>l.setDraft([...new Set(o(e))]),validate:a,placeholder:s,disabled:l.disabled}),(0,G.jsx)(xe,{children:i.length?i.join(`, `):c}),(0,G.jsx)(be,{dirty:l.dirty,saving:l.saving,onSave:()=>void l.save(),onReset:l.reset})]})}var Ye=1024,Xe=1048576;function Ze({p:e}){let t=e.egress;return(0,G.jsxs)(J,{id:`network`,title:`Network limits`,intro:(0,G.jsxs)(G.Fragment,{children:[`Where your toolbox may reach on the internet for servers on the web, and how big or slow those requests may be. A server that runs on your computer reaches the internet itself, so these limits don't cover it.`,` `,(0,G.jsx)(S,{term:`networkLimits`})]}),children:[(0,G.jsx)(Je,{path:`egress.allow`,label:`Allowed addresses`,explain:`Your toolbox reaches web servers only at these addresses. *.example.com covers every address under example.com. Servers that run on your computer aren't limited by this list.`,current:t.allow,validate:qe,normalise:e=>e.map(e=>e.toLowerCase()),placeholder:`Type an address and press Enter`,emptyText:`none, so nothing can be reached`}),(0,G.jsx)(Je,{path:`egress.methods`,label:`Allowed request types`,explain:`GET and HEAD only read. POST, PUT, PATCH and DELETE can change things on other websites.`,current:t.methods,validate:e=>/^[A-Za-z]{1,16}$/.test(e)?null:`Use a request type such as GET or POST.`,normalise:e=>e.map(e=>e.toUpperCase()),placeholder:`GET, POST…`,emptyText:`none`}),(0,G.jsx)($,{path:`egress.max_body_bytes`,label:`Largest answer from a website`,explain:`Answers bigger than this are cut off.`,current:t.maxBodyBytes,units:[{label:`KB`,size:Ye},{label:`MB`,size:Xe}],show:g}),(0,G.jsx)($,{path:`egress.max_request_body_bytes`,label:`Largest request to a website`,explain:`Limits how much data a connected server can send out in one request.`,current:t.maxRequestBodyBytes,units:[{label:`KB`,size:Ye},{label:`MB`,size:Xe}],show:g}),(0,G.jsx)($,{path:`egress.timeout_ms`,label:`How long to wait for a website`,explain:`A request that takes longer is stopped.`,current:t.timeoutMs,units:[{label:`seconds`,size:1e3}],show:y}),(0,G.jsx)($,{path:`egress.max_redirects`,label:`Redirects to follow`,explain:`When a website sends a request on to another address. Each new address is checked against your list again. 0 follows none.`,current:t.maxRedirects,min:0,max:100,units:[{label:`redirects`,size:1}],show:e=>String(e)}),(0,G.jsx)(Q,{path:`egress.block_private_ips`,label:`Block your private network`,explain:`Stops connected servers from reaching this computer and other devices on your home or office network.`,checked:t.blockPrivateIps,on:`On: your own network is off limits`,off:`Off: your own network can be reached`}),(0,G.jsx)(Q,{path:`egress.allow_http`,label:`Allow unencrypted requests`,explain:`Addresses starting with http:// rather than https://. Anyone on the network path can read or change them.`,checked:t.allowHttp,on:`On: unencrypted requests are allowed`,off:`Off: only encrypted requests`}),(0,G.jsx)(Q,{path:`egress.allow_ip_literals`,label:`Allow raw IP addresses`,explain:`Addresses written as numbers, such as 203.0.113.5, instead of a website name.`,checked:t.allowIpLiterals,on:`On: numeric addresses are allowed`,off:`Off: only website names`})]})}var Qe={env:`a setting on the computer the toolbox runs on`,header:`a header on each incoming request`,"jwt-claim":`the sign-in token the toolbox is given`,"jwt-verified":`each caller's verified sign-in token`,static:`a fixed name in the settings file`};function $e({p:t}){let n=t.tenant;return(0,G.jsx)(J,{id:`customers`,title:`Customers`,intro:(0,G.jsxs)(G.Fragment,{children:[`When one toolbox serves several customers, it keeps each one's calls and data apart. `,(0,G.jsx)(S,{term:`customer`})]}),children:n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`mb-5 grid gap-3 rounded-2xl bg-sunken px-4 py-4 text-[14px] sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`Where the customer comes from`}),(0,G.jsxs)(`dd`,{className:`mt-0.5 font-medium`,children:[Qe[n.sourceKind]??n.sourceKind,n.sourceName&&(0,G.jsx)(`code`,{className:`mono ml-2 text-[12px] text-soft`,children:n.sourceName})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`The input that names the customer`}),(0,G.jsxs)(`dd`,{className:`mt-0.5`,children:[(0,G.jsx)(`code`,{className:`mono text-[13px]`,children:n.field}),n.aliases.length>0&&(0,G.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[` `,`(also `,n.aliases.join(`, `),`)`]})]})]}),(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`Right now`}),(0,G.jsx)(`dd`,{className:`mt-0.5`,children:n.error?(0,G.jsxs)(`span`,{className:`text-bad`,children:[`The toolbox could not work out the customer: `,n.error]}):n.resolved?(0,G.jsx)(e,{tone:`ok`,icon:`check`,children:`Customer known`}):(0,G.jsx)(e,{tone:`warn`,icon:`warning`,children:`Not known yet; it is read from each call`})})]})]}),(0,G.jsx)(et,{p:t})]}):(0,G.jsx)(`p`,{className:`rounded-2xl bg-sunken px-4 py-3.5 text-[14px] text-muted`,children:`This toolbox serves a single customer, so there is nothing to keep apart. Customer separation is set up in the settings file, under the advanced editor below.`})})}function et({p:e}){let t=e.tenant,n=Z(`tenant.on_mismatch`,t.onMismatch);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:`A call names the wrong customer`,explain:`The AI asked for a different customer's data than the one it is working for.`,yamlKey:`tenant.on_mismatch`,saving:n.saving,children:(0,G.jsx)(X,{label:`A call names the wrong customer`,size:`sm`,value:n.value,onChange:e=>void n.choose(e),disabled:n.disabled,options:[{value:`deny`,title:`Block the call`,body:`The attempt shows up in the log as blocked.`},{value:`override`,title:`Replace it`,body:`The right customer is quietly put in, and the call runs.`}]})}),(0,G.jsx)(Q,{path:`tenant.required`,label:`A customer is required`,explain:`When on, the toolbox refuses to start unless it knows which customer it serves.`,checked:t.required,on:`On: no customer, no start`,off:`Off: it can start without one`})]})}function tt({p:t,nav:i}){let a=t.audit,o=Z(`audit.on_failure`,a.onFailure);return(0,G.jsxs)(J,{id:`activity-log`,title:`Activity log`,intro:(0,G.jsxs)(G.Fragment,{children:[`The record of every call and every change. `,(0,G.jsx)(S,{term:`activityLog`})]}),actions:(0,G.jsx)(C,{href:r(i,`/activity`),size:`sm`,iconRight:`arrow-right`,children:`Open activity log`}),children:[(0,G.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-center gap-x-4 gap-y-2 rounded-2xl bg-sunken px-4 py-3.5 text-[13.5px]`,children:[a.verify.written?a.verify.ok?(0,G.jsx)(e,{tone:`ok`,icon:`check`,children:`Log intact`}):(0,G.jsxs)(e,{tone:`bad`,icon:`warning`,children:[n(a.verify.problemCount,`problem`),` found`]}):(0,G.jsx)(e,{tone:`neutral`,children:`Nothing recorded yet`}),a.verify.written&&(0,G.jsxs)(`span`,{className:`text-muted`,children:[n(a.verify.count,`entry`,`entries`),` checked`]}),(0,G.jsxs)(`span`,{className:`min-w-0 basis-full text-soft sm:basis-auto`,children:[`Saved at`,` `,(0,G.jsx)(`code`,{className:`mono text-[12px] break-all text-muted`,children:a.path})]})]}),(0,G.jsx)(Q,{path:`audit.enabled`,label:`Keep an activity log`,explain:`Turning it off means you could not see or prove what your AI did.`,checked:a.enabled,on:`On: every call is recorded`,off:`Off: nothing is recorded`}),(0,G.jsx)(Q,{path:`audit.hash_chain`,label:`Tamper check`,explain:(0,G.jsxs)(G.Fragment,{children:[`Each entry carries a fingerprint of the one before, so an edited or deleted entry shows up. `,(0,G.jsx)(S,{term:`hashChain`})]}),checked:a.hashChain,on:`On: edits to the log are detectable`,off:`Off: edits would go unnoticed`}),(0,G.jsx)(Q,{path:`audit.record_args`,label:`Record what each call asked for`,explain:`The inputs of each call, with passwords and keys hidden. Without them you see that a call happened, not what it did.`,checked:a.recordArgs,on:`On: inputs are recorded, secrets hidden`,off:`Off: only that a call happened`}),(0,G.jsx)(Je,{path:`audit.redact`,label:`More inputs to hide`,explain:(0,G.jsxs)(G.Fragment,{children:[`Common secret names such as password and token are always hidden. Add other input names whose values should never be written down.`,` `,(0,G.jsx)(S,{term:`redaction`})]}),current:a.redact,validate:e=>/\s/.test(e)?`Input names have no spaces.`:e.length>200?`That name is too long.`:null,placeholder:`Type an input name and press Enter`,emptyText:`only the built-in list`}),(0,G.jsx)(Y,{label:`If the log can't be written`,explain:`For example when the disk is full. Blocked calls stay blocked either way.`,yamlKey:`audit.on_failure`,saving:o.saving,children:(0,G.jsx)(X,{label:`If the log can't be written`,size:`sm`,value:o.value,onChange:e=>void o.choose(e),disabled:o.disabled,options:[{value:`refuse`,title:`Refuse the call`,body:`Nothing runs unrecorded.`},{value:`continue`,title:`Run it anyway`,body:`The call runs, with no record of it.`}]})})]})}function nt({p:t}){let r=t.toolBudget;return(0,G.jsxs)(J,{id:`tool-limit`,title:`Tool limit`,intro:(0,G.jsxs)(G.Fragment,{children:[`The most tools your AI app is shown at once.`,` `,(0,G.jsx)(S,{term:`toolBudget`})]}),children:[(0,G.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,G.jsxs)(`span`,{className:`display tnum text-[40px]`,children:[r.enabled,(0,G.jsxs)(`span`,{className:`text-soft`,children:[` / `,r.budget]})]}),(0,G.jsx)(`span`,{className:`text-[13.5px] text-soft`,children:`tools shown now`}),!r.ok&&(0,G.jsx)(e,{tone:`warn`,icon:`warning`,children:`Over the limit`})]}),(0,G.jsx)($,{path:`tool_budget`,label:`Most tools shown`,explain:`Fewer tools are easier to review and harder for the AI to confuse.`,current:r.budget,units:[{label:`tools`,size:1}],show:e=>n(e,`tool`)})]})}function rt({p:e}){let t=e.tools.filter(e=>e.exposure?.disabled).length,r=e.rules.filter(e=>e.argConstraints.length>0).length,i=[t?`${n(t,`tool`)} turned off.`:`No tools are turned off.`,e.tenant?`Customers are kept apart, by ${e.tenant.field}.`:`Not set up: this toolbox serves one customer.`,r?`${n(r,`rule`)} set input limits.`:`No rule sets input limits.`,`Unlabelled tools are ${e.defaults.onUnclassified===`deny`?`blocked`:`held for you`}.${e.surface.unclassifiedCount?` ${n(e.surface.unclassifiedCount,`tool`)} unlabelled now.`:``}`,e.rules.length?`${n(e.rules.length,`rule`)}, checked top to bottom.`:`No rules yet.`,`${L[e.defaults.mode??`read-only`]?.label??e.defaults.mode}.`];return(0,G.jsxs)(J,{id:`checks`,title:`How each call is checked`,intro:`Every call your AI makes goes through these checks in order. The first one that gives an answer decides.`,children:[e.enforcement===`observe`&&(0,G.jsx)(`div`,{className:`mb-5`,children:(0,G.jsx)(c,{tone:`warn`,children:`In watch-only mode the checks still run, but only to note what they would have decided.`})}),(0,G.jsx)(`ol`,{className:`relative`,children:N.map((e,t)=>({key:e,here:i[t]})).filter(t=>e.tenant||t.key!==`step2Customer`).map(({key:e,here:t},n,r)=>{let i=ne[e],a=n===r.length-1;return(0,G.jsxs)(`li`,{className:`relative flex gap-4 pb-6 last:pb-0`,children:[!a&&(0,G.jsx)(`span`,{"aria-hidden":!0,className:`absolute top-10 bottom-1 left-[19px] w-0.5 rounded-full bg-line`}),(0,G.jsx)(`span`,{className:`tnum grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-[14px] font-bold text-ink`,children:n+1}),(0,G.jsxs)(`div`,{className:`min-w-0 pt-1.5`,children:[(0,G.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:i.plain.replace(/^\d+\.\s*/,``)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:i.explain}),(0,G.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[13px] text-muted`,children:[(0,G.jsx)(h,{name:`chevron-right`,size:14,className:`mt-0.5 shrink-0 text-soft`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-semibold`,children:`Here: `}),t]})]}),(0,G.jsxs)(`details`,{className:`mt-1.5 text-[11.5px] text-soft`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Technical name`}),(0,G.jsx)(`code`,{className:`mono`,children:i.technical})]})]})]},e)})})]})}var it=[{id:`mode`,label:`Mode`},{id:`stance`,label:`Default stance`},{id:`approvals`,label:`How you're asked`},{id:`results`,label:`What tools send back`},{id:`network`,label:`Network limits`},{id:`customers`,label:`Customers`},{id:`activity-log`,label:`Activity log`},{id:`tool-limit`,label:`Tool limit`},{id:`rules`,label:`Rules`},{id:`checks`,label:`How each call is checked`},{id:`file`,label:`Edit settings file`}],at=()=>typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function ot(){let{serverId:e,tenant:t,nav:r,reload:i}=se(),a=I(()=>_.protection(e,t),[e,t],15e3),l=I(()=>_.policy(e,t),[e,t],5e3),u=a.data,d=(0,W.useRef)(``);(0,W.useEffect)(()=>{u&&(d.current=u.policyWrite.digest)},[u]);let[f,p]=(0,W.useState)(0),m=(0,W.useRef)([]);(0,W.useEffect)(()=>()=>m.current.forEach(clearTimeout),[]);let h=(0,W.useCallback)(()=>{a.reload(),l.reload(),i()},[a.reload,l.reload,i]),g=()=>{p(Date.now()),a.reload(),l.reload(),m.current.push(window.setTimeout(h,1500),window.setTimeout(()=>p(0),4e3))},v=r.query.get(`focus`)??r.query.get(`section`),[y,b]=(0,W.useState)(null),x=(0,W.useCallback)(e=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:at()?`auto`:`smooth`,block:`start`}),b(e),window.setTimeout(()=>b(t=>t===e?null:t),2200))},[]),S=u!==null;(0,W.useEffect)(()=>{v&&S&&requestAnimationFrame(()=>x(v))},[v,S,x]);let C=e=>{x(e),ie(o(r,{focus:e,section:null}))},[w,ee]=(0,W.useState)(`mode`);if((0,W.useEffect)(()=>{if(!S||typeof IntersectionObserver>`u`)return;let e=new Map,t=new IntersectionObserver(t=>{for(let n of t)e.set(n.target.id,n.isIntersecting);let n=it.find(t=>e.get(t.id));n&&ee(n.id)},{rootMargin:`-10% 0px -60% 0px`});for(let e of it){let n=document.getElementById(e.id);n&&t.observe(n)}return()=>t.disconnect()},[S]),a.error&&!u)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{title:`Protection settings`,subtitle:`How this toolbox decides what your AI may do.`}),(0,G.jsx)(c,{tone:`danger`,title:`The settings could not be loaded`,role:`alert`,actions:(0,G.jsx)(O,{onClick:a.reload,icon:`refresh`,children:`Try again`}),children:q(a.error)})]});if(!u)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{title:`Protection settings`,subtitle:`How this toolbox decides what your AI may do.`}),(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[0,1,2,3].map(e=>(0,G.jsx)(M,{title:` `,value:``,loading:!0},e))}),(0,G.jsx)(`div`,{className:`mt-5 space-y-5`,children:[0,1].map(e=>(0,G.jsxs)(P,{children:[(0,G.jsx)(s,{height:22,width:`30%`}),(0,G.jsx)(`div`,{className:`mt-5`,children:(0,G.jsx)(s,{lines:4,height:16})})]},e))})]});let E=u.policyWrite,te=l.data?.runningDigest??null,D=te!==null&&te!==E.digest&&f===0,ne=E.ok&&!E.why,A=l.data?.policy?.rules??null,j=u.enforcement===`enforce`;return(0,G.jsxs)(he,{serverId:e,tenant:t,canWrite:E.ok,canLoosen:E.overrides,digestRef:d,reloadsLive:ne,onWritten:g,onReload:h,children:[(0,G.jsx)(T,{title:`Protection settings`,subtitle:`How this toolbox decides what your AI may do.`,meta:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 text-[13px] text-soft`,children:[`Settings file`,(0,G.jsx)(`code`,{className:`mono text-[12px] break-all text-soft`,children:E.path??u.runtime.policyPath??`inside the toolbox's configuration`})]}),actions:(0,G.jsx)(O,{icon:`refresh`,onClick:h,loading:a.loading&&l.loading,children:`Reload settings`})}),(0,G.jsxs)(`div`,{className:`mb-5 space-y-3`,children:[D&&(0,G.jsx)(st,{serverId:e}),!E.ok&&(0,G.jsx)(c,{tone:`info`,title:`These settings can't be changed from the console`,children:/inline/.test(E.why??``)?`They are written inside the toolbox's own configuration rather than in a separate file, so the console can show them but not change them. Everything below is read-only.`:/policy_writes/.test(E.why??``)?`Whoever set up this toolbox chose that its settings change only when they update it, never from the console. Everything below is read-only.`:`${q(E.why??`The settings file can't be written.`)} Everything below is read-only.`}),E.ok&&!E.overrides&&(0,G.jsx)(c,{tone:`info`,title:`The console can only make these settings stricter`,children:`Whoever set up this toolbox allows tightening from here, but not loosening. A change that lets more through has to be made by them.`}),E.ok&&E.why&&(0,G.jsx)(c,{tone:`info`,title:`Changes apply when the toolbox restarts`,children:`This toolbox is set not to re-read its settings while running, so anything you save here takes effect the next time it starts.`}),a.error&&(0,G.jsxs)(c,{tone:`warn`,actions:(0,G.jsx)(O,{size:`sm`,onClick:a.reload,children:`Try again`}),children:[`The latest settings could not be loaded, so this page may be out of date. `,q(a.error)]})]}),(0,G.jsxs)(`div`,{className:`mb-5 grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4`,children:[(0,G.jsx)(M,{title:`Protection`,tone:j?`hero`:`plain`,value:j?`On`:`Off`,sub:j?`Protecting: your rules are applied`:`Watch-only: nothing is blocked`}),(0,G.jsx)(M,{title:`Rules`,value:oe(u.rules.length),sub:`Checked from the top; first match decides`}),(0,G.jsx)(M,{title:`Tools shown`,value:`${u.toolBudget.enabled}/${u.toolBudget.budget}`,sub:u.toolBudget.ok?`Within your tool limit`:`Over your tool limit`}),(0,G.jsx)(M,{title:`Activity log`,value:u.audit.enabled?`On`:`Off`,sub:u.audit.enabled?u.audit.verify.ok?`Intact · ${n(u.audit.verify.count,`entry`,`entries`)}`:`Problems found`:`Calls are not being recorded`})]}),(0,G.jsxs)(`div`,{className:`xl:grid xl:grid-cols-[200px_minmax(0,1fr)] xl:gap-6`,children:[(0,G.jsxs)(`nav`,{"aria-label":`Sections`,className:`mb-5 xl:mb-0`,children:[(0,G.jsxs)(`div`,{className:`xl:hidden`,children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-[13px] font-semibold`,htmlFor:`protection-jump`,children:`Jump to section`}),(0,G.jsx)(k,{id:`protection-jump`,value:w,onChange:C,options:it.map(e=>({value:e.id,label:e.label}))})]}),(0,G.jsx)(`ul`,{className:`sticky top-4 hidden space-y-0.5 xl:block`,children:it.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`a`,{href:`#${e.id}`,"aria-current":w===e.id?`location`:void 0,onClick:t=>{t.preventDefault(),C(e.id)},className:V(`block rounded-full px-3.5 py-2 text-[13.5px] transition-colors`,w===e.id?`bg-surface font-semibold text-ink shadow-[var(--shadow-sm)]`:`text-soft hover:text-ink`),children:e.label})},e.id))})]}),(0,G.jsx)(ve.Provider,{value:y,children:(0,G.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,G.jsx)(Be,{p:u,nav:r}),(0,G.jsx)(We,{p:u}),(0,G.jsx)(Ge,{p:u}),(0,G.jsx)(Ke,{p:u}),(0,G.jsx)(Ze,{p:u}),(0,G.jsx)($e,{p:u}),(0,G.jsx)(tt,{p:u,nav:r}),(0,G.jsx)(nt,{p:u}),(0,G.jsx)(Ae,{p:u,full:A,fullError:l.error&&!l.data?l.error:null}),(0,G.jsx)(rt,{p:u}),(0,G.jsx)(we,{live:u.surface.live})]})})]})]})}function st({serverId:e}){let t=B(),n=I(()=>U(e),[e]),[r,i]=(0,W.useState)(!1),a=n.data?.managed&&n.data.state===`running`;return(0,G.jsxs)(c,{tone:`warn`,role:`status`,title:`The toolbox is still using an older version of these settings`,actions:a&&(0,G.jsx)(O,{size:`sm`,icon:`refresh`,loading:r,onClick:async()=>{i(!0);try{await H(e),t.show(`ok`,`Toolbox restarted with the current settings.`)}catch(e){t.show(`bad`,q(e.message))}finally{i(!1)}},children:`Restart toolbox`}),children:[`It picks up changes within a second; if this stays, the file may have an error. The activity log, customers, what tools send back, changed-tool handling and the tool limit only change when the toolbox restarts`,n.data?.externallyRunning?`, and an AI app is running it, so restart that app.`:`.`]})}export{ot as ProtectionPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,G as r,H as i,It as a,Ot as o,Pt as s,U as c,V as l,_t as u,c as d,ft as f,ht as p,it as m,kt as h,mt as g,pt as _,s as v,y,z as b}from"./kit-DRVm92_t.js";import{Et as x,un as S}from"./index-CTvq_isK.js";var C=a(),w=[[/^Set audit\.enabled to true\.?$/,`Turn the activity log on in Protection settings.`],[/^Set audit\.hash_chain to true\.?$/,`Turn on the activity log's tamper check in Protection settings.`],[/^Set approvals\.mode to "both".*$/,`Let calls that ask first reach a person, or switch the default stance to Looks only.`],[/^Disable the tools an agent does not need, or raise tool_budget deliberately\.?$/,`Turn off the tools your AI app does not need, or raise the tool limit on purpose.`],[/^Deny this tool in policy, or let the gateway strip the description before advertising it\.?$/,`Block this tool, or let the toolbox remove the hidden text before your AI app sees it.`],[/^Fix the description where it is declared, or deny the tool in policy\.?$/,`Fix the description where the tool is defined, or block the tool.`],[/^Add a maxLength\.?$/,`Set a maximum length for this input.`],[/^Add a maxItems\.?$/,`Set a maximum number of items for this input.`],[/^Give the field an explicit type\.?$/,`Say what kind of value this input takes.`],[/^Use https\.?$/,`Use a secure (https) address.`],[/^Set a full https:\/\/ base URL\.?$/,`Use a full, secure (https) address for the server.`]],T=[[/decision: approve \(or deny\)/g,`“Asks you first” (or “Blocked”)`],[/decision: approve/g,`“Asks you first”`],[/decision: deny/g,`“Blocked”`],[/on_violation: approve/g,`“ask you when inputs break the limits”`],[/unknown_args: deny/g,`“block inputs no limit mentions”`],[/argument bounds/g,`input limits`],[/tenantParams/g,`the customer fields the toolbox fills in`],[/a tenant block/g,`customer separation`],[/paginationCap/g,`a result cap`],[/egress\.max_body_bytes/g,`the largest allowed answer size in network limits`],[/egress\.allow_http/g,`“Allow plain http” in network limits`],[/egress\.allow/g,`the allowed addresses in network limits`],[/tool_budget/g,`the tool limit`],[/\bin policy\b/g,`in your protection settings`],[/\bthe policy\b/g,`your protection settings`],[/\bpolicy rule\b/g,`rule`],[/\bupstream\b/g,`connected server`],[/\bagent\b/g,`AI app`],[/ - /g,`; `]];function E(e){return e.replace(/`?(?:npx\s+)?hmcp(?:-gateway)?\s[^`.;]*`?/g,``).replace(/\s--[a-z][\w-]*/g,``).replace(/\s{2,}/g,` `).trim()}function D(e){let t=E(e);for(let[e,n]of w)if(e.test(t))return n;let n=t;for(let[e,t]of T)n=n.replace(e,t);return n}function O(e){return E(e).replace(/\b(?:an |the )?upstream MCP server's advertised text\b/g,`the connected server's own text`).replace(/\bthe model's context\b/g,`what the AI reads`).replace(/\bupstream\b/g,`connected server`).replace(/\bagent\b/g,`AI app`)}function k(e){let t=e.location.path;if(!t)return{tool:null,setting:null};let n=t.split(`.`),r=n[0];return[`policy`,`api`,`audit`,`approvals`,`egress`,`tenant`].includes(r)||n.length<2?{tool:null,setting:t}:{tool:n[1]??null,setting:n.slice(2).join(`.`)||null}}function A(e,t){let{tool:r,setting:i}=k(e),a=e=>({href:n(t,`/tools`,r?{tool:r}:{}),label:r?e:`Open tools`}),o=(e,r)=>({href:n(t,`/protection`,{section:e}),label:r});switch(e.ruleId){case`HMCP001`:return i?.startsWith(`policy.rules.`)?o(`rules`,`Edit this rule`):a(`Review this tool`);case`HMCP002`:return o(`customers`,`Open customer settings`);case`HMCP003`:case`HMCP004`:case`HMCP005`:case`HMCP006`:return a(`Review this tool`);case`HMCP007`:return o(`network`,`Open network limits`);case`HMCP009`:return r?a(`Review this tool`):{href:n(t,`/tools`),label:`Open tools`};case`HMCP010`:return i===`approvals.mode`?o(`approvals`,`Open approval settings`):o(`activity-log`,`Open activity log settings`);default:return null}}var j={hasPaginationCap:{title:`Whether list tools cap their results`,explain:`Tools connected this way do not say whether they limit how many results they return, so the result-cap check had nothing to look at.`},tenantParams:{title:`Which input names the customer`,explain:`Only tools built from an API description say which input carries the customer. Customer separation in your settings was still checked, but not each tool's inputs.`},"method / path":{title:`The web address each tool calls`,explain:`Tools connected this way have no web address of their own, so per-call checks on them could not run. The connected servers' addresses were still checked against your network limits.`}};function M(e){let t=j[e.field],n=e.rules.filter(e=>e!==`HMCP008`);return t?{...t,rules:n}:{title:e.field,explain:e.why,rules:n}}var N=h(),P={high:{title:`Fix soon`,explain:`Could let your AI app do harm or leak data.`,tone:`bad`},medium:{title:`Worth fixing`,explain:`Weakens protection, but needs something else to go wrong first.`,tone:`warn`},low:{title:`Good to tidy`,explain:`Small gaps that make the setup harder to review.`,tone:`neutral`}};function F(){let{serverId:e,server:n,tenant:r,nav:a}=S(),o=y(),l=v(()=>s.scan(e,r),[e,r]),[u,f]=(0,C.useState)(!1),m=l.data;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(d,{title:`Safety check`,subtitle:`An automatic review of how this toolbox is set up.`,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(p,{variant:`primary`,icon:`refresh`,onClick:l.reload,loading:l.loading&&!!m,children:`Run check again`}),(0,N.jsx)(p,{icon:`download`,onClick:async()=>{f(!0);try{let t=await s.scanSarif(e,r);x(`safety-check-${n.id}.sarif`,`application/sarif+json`,JSON.stringify(t,null,2)),o.show(`ok`,`Report downloaded`)}catch(e){o.show(`bad`,`The report could not be made: ${e.message}`)}finally{f(!1)}},loading:u,children:`Download report (SARIF)`})]})}),l.error?(0,N.jsx)(i,{tone:`danger`,title:`The safety check could not run`,actions:(0,N.jsx)(p,{size:`sm`,onClick:l.reload,children:`Try again`}),children:l.error}):m?(0,N.jsxs)(`div`,{className:`space-y-5`,children:[(0,N.jsx)(L,{report:m,nav:a}),(0,N.jsx)(R,{report:m}),m.findings.length===0?(0,N.jsx)(_,{children:(0,N.jsx)(c,{icon:`shield-check`,title:`No problems found`,children:m.scanned>0?`Every check that could run over ${t(m.scanned,`tool`)} and your settings came back clean.`:`Your settings came back clean. No tools were checked, because the toolbox has not reported any.`})}):[`high`,`medium`,`low`].map(e=>(0,N.jsx)(z,{severity:e,findings:m.findings.filter(t=>t.severity===e),nav:a},e)),(0,N.jsx)(U,{report:m})]}):(0,N.jsx)(I,{})]})}function I(){return(0,N.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,N.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 xl:grid-cols-4`,children:[0,1,2,3].map(e=>(0,N.jsx)(g,{title:e===0?`Things to fix`:P[[`high`,`medium`,`low`][e-1]].title,value:``,loading:!0,tone:e===0?`hero`:`plain`},e))}),(0,N.jsx)(_,{children:(0,N.jsx)(r,{lines:4,height:16})})]})}function L({report:e,nav:t}){let r=e.surface;if(r.live)return null;let a=(0,N.jsx)(u,{size:`sm`,href:n(t,`/connections`),children:`Open connections`});return r.neverPublished?(0,N.jsx)(i,{tone:`warn`,title:`Only your settings were checked`,actions:a,children:`This toolbox has never run, so the check does not know its tools yet. Some checks need the toolbox running. Start it, then run the check again.`}):(0,N.jsxs)(i,{tone:`warn`,title:`The toolbox is not running`,actions:a,children:[`The tools checked are the ones it reported`,r.publishedAt?` ${l(r.publishedAt)}`:` when it last ran`,`. Some checks need the toolbox running to be sure they are still current.`]})}function R({report:e}){let n=e.findings.length,r=t=>e.counts[t]??e.findings.filter(e=>e.severity===t).length;return(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:gap-5 xl:grid-cols-4`,children:[(0,N.jsx)(`div`,{className:`col-span-2 grid sm:col-span-1`,children:(0,N.jsx)(g,{tone:`hero`,title:`Things to fix`,value:n===0?(0,N.jsx)(o,{name:`shield-check`,size:52,strokeWidth:1.6,label:`No problems`}):b(n),sub:n===0?`No problems found`:`Across ${t(e.scanned,`tool`)} and your settings`})}),[`high`,`medium`,`low`].map(e=>(0,N.jsx)(g,{title:P[e].title,value:b(r(e)),sub:P[e].explain},e))]})}function z({severity:n,findings:r,nav:i}){if(r.length===0)return null;let a=new Map;for(let e of r)a.set(e.ruleId,[...a.get(e.ruleId)??[],e]);let o=P[n];return(0,N.jsxs)(`section`,{"aria-labelledby":`sev-${n}`,className:`space-y-4`,children:[(0,N.jsxs)(`h2`,{id:`sev-${n}`,className:`flex flex-wrap items-center gap-3 pt-2 text-[21px] font-medium tracking-[-0.02em]`,children:[o.title,(0,N.jsx)(e,{tone:o.tone,children:t(r.length,`finding`)}),(0,N.jsx)(`span`,{className:`text-[13.5px] font-normal tracking-normal text-soft`,children:o.explain})]}),(0,N.jsx)(`div`,{className:`space-y-5`,children:[...a.entries()].map(([e,t])=>(0,N.jsx)(V,{ruleId:e,group:t,nav:i},e))})]})}var B=4;function V({ruleId:e,group:n,nav:r}){let[i,a]=(0,C.useState)(!1),o=m[e],s=f(e)===e?n[0].title:f(e),c=i?n:n.slice(0,B);return(0,N.jsxs)(_,{as:`article`,children:[(0,N.jsxs)(`header`,{className:`mb-3`,children:[(0,N.jsx)(`h3`,{className:`text-[19px] leading-tight font-medium tracking-[-0.02em]`,children:s}),(0,N.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[12px] text-soft`,children:[(0,N.jsx)(`code`,{className:`mono`,children:e}),n.length>1&&(0,N.jsxs)(`span`,{children:[`· `,t(n.length,`place`)]})]})]}),o&&(0,N.jsxs)(`div`,{className:`mb-4`,children:[(0,N.jsx)(`p`,{className:`text-[12px] font-semibold tracking-wide text-soft uppercase`,children:`What it means for you`}),(0,N.jsx)(`p`,{className:`mt-1 text-[14px] leading-relaxed text-muted`,children:o.explain})]}),(0,N.jsx)(`ul`,{className:`grid gap-3 xl:grid-cols-2`,children:c.map((e,t)=>(0,N.jsx)(H,{finding:e,nav:r},`${e.location.path??``}-${t}`))}),n.length>B&&(0,N.jsx)(p,{size:`sm`,variant:`ghost`,icon:i?`minus`:`plus`,className:`mt-3`,onClick:()=>a(!i),children:i?`Show fewer places`:`Show ${n.length-B} more places`})]})}function H({finding:e,nav:t}){let{tool:n,setting:r}=k(e),i=A(e,t);return(0,N.jsxs)(`li`,{className:`flex min-w-0 flex-col rounded-2xl bg-sunken/60 p-4 [overflow-wrap:anywhere]`,children:[(0,N.jsx)(`p`,{className:`text-[14px] leading-relaxed`,children:O(e.message)}),(0,N.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface px-3.5 py-2.5`,children:[(0,N.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[12.5px] font-semibold text-ok`,children:[(0,N.jsx)(o,{name:`tool`,size:14,strokeWidth:2}),`How to fix`]}),(0,N.jsx)(`p`,{className:`mt-0.5 text-[13.5px] leading-relaxed`,children:D(e.fix)})]}),(0,N.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center justify-between gap-3 pt-3`,children:[(0,N.jsxs)(`p`,{className:`min-w-0 text-[12.5px] text-soft`,children:[(0,N.jsx)(`span`,{className:`font-semibold`,children:`Where: `}),n?(0,N.jsxs)(N.Fragment,{children:[`tool `,(0,N.jsx)(`code`,{className:`mono break-all text-ink`,children:n})]}):r?(0,N.jsx)(`code`,{className:`mono break-all`,children:r}):`your protection settings`,n&&r&&(0,N.jsxs)(`code`,{className:`mono ml-1.5 break-all`,children:[`(`,r,`)`]})]}),i&&(0,N.jsx)(u,{size:`sm`,href:i.href,iconRight:`arrow-right`,children:i.label})]})]})}function U({report:e}){return e.gaps.length===0?null:(0,N.jsxs)(_,{title:`What the check couldn't look at`,children:[(0,N.jsx)(`p`,{className:`mb-4 max-w-3xl text-[14px] text-muted`,children:`Some checks need details that tools connected through a toolbox do not share. Those checks stayed quiet because they had nothing to read, not because they passed.`}),(0,N.jsx)(`ul`,{className:`grid gap-3 md:grid-cols-3`,children:e.gaps.map(e=>{let t=M(e);return(0,N.jsxs)(`li`,{className:`rounded-2xl border border-faint p-4`,children:[(0,N.jsxs)(`p`,{className:`flex items-center gap-2 text-[14.5px] font-medium`,children:[(0,N.jsx)(o,{name:`eye-off`,size:16,className:`shrink-0 text-soft`}),t.title]}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-soft`,children:t.explain}),t.rules.length>0&&(0,N.jsx)(`p`,{className:`mt-2 flex flex-wrap gap-1.5`,children:t.rules.map(e=>(0,N.jsx)(`code`,{className:`mono text-[11.5px] text-soft`,children:e},e))})]},e.field)})})]})}export{F as SafetyPage};
|