hmcp-web 0.2.2 → 0.2.3
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 +6 -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 +755 -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 +1018 -0
- package/dist/routes/connect-import.d.ts +21 -6
- package/dist/routes/connect-import.js +162 -546
- package/dist/routes/connect.d.ts +11 -0
- package/dist/routes/connect.js +28 -116
- 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-BSf4lBm-.js +1 -0
- package/dist-ui/assets/Approvals-CDz3zYpl.js +1 -0
- package/dist-ui/assets/AttachApp-COr1547c.js +5 -0
- package/dist-ui/assets/Connections-ClW5R6ea.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-DYDKgSpr.js} +1 -1
- package/dist-ui/assets/Protection-DMtABpM7.js +1 -0
- package/dist-ui/assets/Safety-BLTF2fqV.js +1 -0
- package/dist-ui/assets/{Settings-CSyTOe8X.js → Settings-DZ4P3Us6.js} +1 -1
- package/dist-ui/assets/StartPage-Bke6mrv5.js +1 -0
- package/dist-ui/assets/{Suggestions-CaQ_ifWR.js → Suggestions-kAWUILyw.js} +1 -1
- package/dist-ui/assets/Tools-BdXSeKeL.js +4 -0
- package/dist-ui/assets/connect-app-words-CT8Fytzv.js +1 -0
- package/dist-ui/assets/index-Cm4wG2zz.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
|
@@ -0,0 +1,5 @@
|
|
|
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 j,o as ee,q as M,r as N,rt as P,s as F,t as I,tt as te,vt as ne,w as re,x as ie,xt as ae,y as oe,yt as L}from"./kit-BHB_ha4i.js";import{$ as se,A as ce,B as le,Bt as ue,C as de,D as fe,E as pe,F as R,Ft as z,G as me,H as he,I as ge,J as _e,Jt as ve,K as ye,Kt as B,L as be,Lt as V,M as xe,Mn as H,N as Se,Nt as U,O as Ce,P as we,Q as Te,Qt as Ee,R as De,Rt as Oe,S as ke,T as Ae,U as je,Ut as W,V as Me,Vt as G,W as Ne,Wt as Pe,X as Fe,Y as Ie,Yt as Le,Zt as Re,b as ze,bn as Be,cn as K,ct as Ve,dn as He,en as Ue,et as q,fn as J,j as We,k as Ge,ln as Y,m as Ke,nn as qe,nt as Je,on as Ye,q as Xe,rn as X,rt as Ze,s as Qe,sn as $e,tn as et,tt,x as nt,z as rt,zt as it}from"./index-Cm4wG2zz.js";import{A as at,B as ot,C as st,D as ct,E as lt,F as ut,G as dt,H as ft,I as pt,K as mt,L as ht,M as gt,O as _t,R as vt,S as yt,T as bt,U as xt,V as St,W as Ct,b as wt,d as Tt,f as Et,j as Dt,k as Ot,w as kt,x as At,y as jt,z as Mt}from"./connect-app-words-CT8Fytzv.js";var Z=c(),Q=A(),Nt=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function Pt(e){let t=Nt();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=Ze(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=Ze(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function Ft(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:Je(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:Je(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function It(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&&!qe(t)&&!Re(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)(se,{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)(se,{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)(Te,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?z[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:z.strip.label},{value:`deny`,label:z.deny.label},{value:`annotate`,label:z.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 Rt({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)(zt,{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)(M,{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)(zt,{onPick:i}):p===`registry`?(0,Q.jsx)(Ht,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(Ut,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(Wt,{onDraft:a})})]})}function zt({onPick:e,compact:t}){let i=F(()=>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?rt(p,a,l):[...rt(p,a,l)].sort((e,t)=>Number(t.id===Bt)-Number(e.id===Bt)),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:B(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:L(`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`:de[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)(Vt,{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 Bt=`filesystem`;function Vt({entry:t,onPick:n}){let r=De(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===Bt?(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=>Ae[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 Ht({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=F(()=>n.catalog(),[]),O=l?rt(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.`):_(B(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=>_(B(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=>_(B(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)(ne,{})})]}),(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)(ne,{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:L(`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)(ne,{}),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 Ut({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(B(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 Wt({onDraft:e}){let[t,n]=(0,Z.useState)(Nt()),[r,i]=(0,Z.useState)(!1),a=It(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=we(Ft(t));e(n.draft,n.values)},children:`Continue`})})]})}function Gt({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)(ne,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:he(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 Kt=[`run`,`ask`,`blocked`],qt={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 Jt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=xe(e),a=Ie(e),o=Kt.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:[je(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{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:L(`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)(Yt,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{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:L(`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:L(`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 Yt({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=Ce[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:qt[e]}),(0,Q.jsx)(`ul`,{className:L(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":te[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??Qe(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:P[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:ee(e.name)})]},e.name))]})]})]})}var Xt=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function Zt({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=R(t.requires,h),T=Ne(t),E=t.launch.transport===`http`?We(t.launch.url,r):``,D=Me(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(Xt(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let O=e=>a[e.id]??(o||y[e.id]?ye(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 `,Ae[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(N,{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)(nt,{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)(Fe,{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=>Ae[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:L(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(j,{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)(ze,{serverUrl:E,secretName:le(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)(Qt,{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)(Te,{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":!!ge(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:L(`text-[12.5px]`,ge(l)?`font-medium text-bad`:`text-soft`),children:ge(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)($t,{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 Qt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=Xt(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)(I,{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:L(`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)(N,{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 $t({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},en=new Set([`brave-search`]);function tn(){$.saved=null}function nn(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,j]=(0,Z.useState)(!1),[ee,M]=(0,Z.useState)({}),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),[te,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(!1),[oe,L]=(0,Z.useState)(!1),[se,ue]=(0,Z.useState)(null),[de,R]=(0,Z.useState)(null),[z,he]=(0,Z.useState)($.saved),[ve,ye]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){ye(!0);return}let e=!0;return h.protection(t).then(t=>e&&ye(t.enforcement!==`enforce`)).catch(()=>e&&ye(null)),()=>{e=!1}},[t]);let[V,xe]=(0,Z.useState)(null),H=e=>{$.saved=e,he(e)},U=(0,Z.useRef)(null),Ce=z?`done`:N&&N.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{U.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),xe(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(pe)));S({...Se(e,n),...r}),T(e.name),k(!1),j(!1),M({}),P(null),ue(null),e.requires.length&&!te&&je()},Te=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(B(e))).finally(()=>v(null))},[De,Oe]=(0,Z.useState)(!1),Ae=async(e,t,r)=>{Oe(!0),b(null);try{let i=(await n.catalog()).entries,a=Ge(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Xe(o,e,r),c=a.entry):{draft:o,values:s}=ce(e,r),we(o,c,s),xe(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)I({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!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&I({kind:`sign-in`,nonce:l})}catch(e){b(B(e))}finally{Oe(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&Ae(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Te(t):v(null)}).catch(e=>{b(B(e)),v(null)})},[a]);let je=()=>{ae(!0),n.doctor().then(re).catch(()=>void 0).finally(()=>ae(!1))},W=p?.draft??null,G=W?Ne(W):!1,Pe=le(w||W?.name||`server`),Fe=()=>{if(!W)return;j(!0),ue(null);let e=me(W,x);if(Object.keys(e).length||ge(w)){let t=W.fields.find(t=>e[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:ge(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else G&&!D?P({kind:`error`,text:`Sign in with ${W.displayName} first.`}):Me(W,x)&&x.__local_ok!==!0?P({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.`}):(P({kind:`running`}),M({}),n.testServer({...t?{gatewayId:t}:{},draft:W,values:G?{...x,[fe]:Pe}:x,...w.trim()===W.name?{}:{name:w.trim()},...V?{replacing:V}:{}}).then(e=>{if(Object.keys(e.problems).length){M(e.problems);let t=W.fields.find(t=>e.problems[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else P({kind:`done`,res:e})}).catch(e=>P({kind:`error`,text:B(e)})))},Ie=e=>{if(!W)return;let t=Date.now(),n=e=>W.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return Fe();case`install-runtime`:case`start-runtime`:return je();case`show-details`:return;case`choose-folder`:{P(null);let e=n([`folder`,`folders`]);if(!e&&W.launch.transport===`stdio`&&p){let e=N?.kind===`done`?N.res.outcome.problem?.detail?.path:void 0,n=ce({name:w||W.name,transport:`stdio`,command:W.launch.command,args:W.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...W,launch:{...W.launch,args:n.draft.launch.args??[]},fields:[...W.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),I({kind:`folder`,field:`folders`,nonce:t})}return I(null)}return I({kind:`folder`,field:e,nonce:t})}case`replace-key`:{P(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Ne(W)&&p&&g({...p,draft:_e(W)}),P(null),k(!1),I({kind:`sign-in`,nonce:t});case`check-address`:{P(null);let e=n([`url`,`text`]);return I(e?{kind:`field`,field:e,nonce:t}:null)}}},[Le,Re]=(0,Z.useState)(null),ze=async(e,t,n)=>{if(!z)return;Re(null);let{upstreamName:r}=z.result;if(p){H(null),xe(r),T(r),Ie(e);return}let i=t;if(!i)try{i=(await Be(z.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Re(B(e));return}i?(H(null),await Ae(i,e,n)):Re(`The server "${r}" isn't in your toolbox any more.`)},K=(0,Z.useRef)(!1),He=async e=>{if(N?.kind!==`done`||K.current)return;K.current=!0,L(!0),ue(null);let r;if(t)try{let[e,n]=await Promise.all([Be(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:N.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){R(e.loosens);return}}let i=await n.install(t??`main`,{probeId:N.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});R(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;H({result:i,name:W?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?R(et(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(R(null),ue({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(R(null),ue({text:Ee(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:B(e)}))}finally{K.current=!1,L(!1)}};(0,Z.useEffect)(()=>{if(!z||z.settled)return;let e=Date.now(),t=z.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=be(t,z.result.upstreamName,z.result.apply,Date.now()-e,e);H({...z,live:n,settled:i})}).catch(()=>r&&(z.result.apply===`needs-restart`||Date.now()-e>=15e3)&&H({...z,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[z?.result.upstreamName,z?.settled]);let Ue=()=>{$.saved=null,i?.()},q=()=>{let e=z?.result;$.saved=null,e&&r(e)};if(z)return(0,Q.jsx)(rn,{saved:z,heading:U,onFinish:q,onRewatch:()=>H({...z,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void ze(e,t,n),reopenError:Le});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||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)(ne,{}),` Opening…`]})}),(0,Q.jsx)(Rt,{compact:c,tab:u,onTab:d,onCatalog:e=>Te(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:Ue,children:`Cancel`})})]});let J=p.draft,We=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>N?P(null):(g(null),O({kind:`picker`})),disabled:N?.kind===`running`||oe,children:N&&N.kind!==`error`?`Change its settings`:`Choose another server`}),Y=N?.kind===`done`&&!N.res.outcome.ok?N.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,Ke=J.source.kind===`catalog`&&J.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(J.launch.url)?p.entry?.name??J.displayName:void 0,qe={firstSignIn:G?!D:N?.kind===`done`&&!!N.res.signInAvailable,...Ke?{desktopApp:Ke.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:J.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||J.launch.transport===`stdio`};return Ce===`test`&&N?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,J.displayName]}),N.kind===`running`?(0,Q.jsx)(Gt,{transport:J.launch.transport}):N.kind===`done`&&N.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Jt,{outcome:N.res.outcome,name:J.displayName,watching:ve,keyUnchecked:J.fields.some(e=>e.kind===`secret`)&&!(J.source.kind===`catalog`&&en.has(J.source.id))}),N.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:N.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):N.kind===`done`?(0,Q.jsx)(ke,{problem:Y,onFix:Ie,context:qe,extra:(0,Q.jsxs)(Q.Fragment,{children:[N.res.signInAvailable&&!G&&N.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>Ie(`sign-in`),children:`Sign in instead`}),Ve(Y,qe).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Try again`})]})}):null,se&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:se.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Test it again`}):void 0,children:se.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,N.kind===`done`&&N.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void He(),loading:oe,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!de,title:`Save ${J.displayName}?`,confirmLabel:`Save and turn on`,consequences:de??[],busy:oe,error:se?.text??null,onCancel:()=>R(null),onConfirm:()=>void He(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,J.displayName]}),(0,Q.jsx)(Zt,{draft:J,entry:p.entry,values:x,onValues:e=>{S(e),M({})},problems:ee,tried:A,onVariant:e=>p.entry&&Te(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:k,doctor:te,doctorBusy:ie,onRecheck:je,focus:F}),N?.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}),` `,N.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:Fe,disabled:!!_,children:`Test it`})]})]})}function rn({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 Be(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,ae(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:L(`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)(Ke,{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 an={};function on({scope:t,projectDir:n}){let r=F(()=>H.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)(an[t]??null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=e=>{an[t]=e??void 0,_(e)};if(!i)return r.error?(0,Q.jsx)(s,{tone:`danger`,children:B(r.error)}):(0,Q.jsx)(o,{lines:3});if(!i.attachedTo)return null;let w=V(t),T=i.servers??[],D=e=>T.find(t=>t.source===`extension`&&t.extensionId===e),O=a??new Set(ve(T)),k=T.filter(e=>e.importable&&!(e.source===`extension`&&e.inToolbox)),A=k.filter(e=>O.has(Y(e))),j=(e,t)=>{let n=new Set(O);t?n.add(Y(e)):n.delete(Y(e)),c(n)},ee=e=>{u(!0),f(null),H.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(et(t)):(h(null),f(B(t)))}).finally(()=>u(!1))},M=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),H.undoImport(t,i.projectScoped?r.data?.projectDir:void 0).then(e=>{y(!1),S(null),x(e),r.reload()}).catch(e=>f(B(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}),Le(w,g.imported.length+g.takenOut.length)]}),t.some(e=>e.enabled)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:He(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:K(X(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,`:`]}),` `,K(X(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:J(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:K(X(g.warning))}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),M,(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. `:``,K(X(b.restartHint))]}),T.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:Ye(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)(sn,{server:e,app:w,checked:O.has(Y(e)),onChange:t=>j(e,t)})},Y(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}),M,(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:()=>ee(!1),children:l&&!p?`Testing each one…`:ue(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:()=>ee(!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 sn({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. ${J(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(` `):K(X(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)(re,{checked:r,onChange:i,label:(0,Q.jsxs)(`span`,{className:`font-medium`,children:[t.name,a]}),description:o||void 0})}function cn({client:e,projectDir:t}){let[n,r]=(0,Z.useState)(!1);if(!e.attachedTo)return null;let i=V(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)(ie,{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)(on,{scope:e.scope,...t?{projectDir:t}:{}})})]})}function ln({title:e,children:t}){return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:e}),t]})}function un({go:e,icon:t,variant:n,newTab:r,children:i}){return e.href===void 0?(0,Q.jsx)(E,{size:`sm`,variant:n,icon:t,onClick:e.onClick,children:i}):(0,Q.jsx)(x,{href:e.href,size:`sm`,variant:n,icon:t,external:r,children:i})}function dn(e){let t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null);return{busy:n,error:i,run:n=>{t.current||(t.current=!0,r(n.id),a(null),H.undoApp(n.id).then(t=>e(t,n)).catch(e=>a({app:n.id,text:B(e)})).finally(()=>{t.current=!1,r(null)}))}}}function fn({app:e,undone:t,onAnother:n}){let r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>r.current?.focus(),[]),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{ref:r,tabIndex:-1,className:`outline-none`,children:(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:Ct(e.label,t.disconnected),children:[xt(t),` `,t.note&&K(X(t.note)),` `,K(X(t.restartHint))]})}),(t.removed.length>0||t.keptInToolbox.length>0||t.guardRemoved)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[t.removed.length>0&&(0,Q.jsx)(`p`,{children:pt(t.removed)}),t.keptInToolbox.length>0&&(0,Q.jsx)(`p`,{children:bt(t.keptInToolbox)}),t.guardRemoved&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions are no longer recorded.`})]}),t.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(t.warning))}),n&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:n,children:`Back to the apps`})})]})}function pn(e){let{result:t}=e;return t.status===`needs-server`?(0,Q.jsx)(mn,{...e,result:t}):(0,Q.jsx)(gn,{...e,result:t})}function mn({app:e,result:t,addServer:n,newTab:r,onAnother:i}){let a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>a.current?.focus(),[]);let o=t.left.length>0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`status`,children:[(0,Q.jsx)(`div`,{ref:a,tabIndex:-1,className:`outline-none`,children:(0,Q.jsx)(s,{tone:`info`,title:Ot(e.label,o),actions:(0,Q.jsx)(un,{go:n,icon:`plus`,variant:`primary`,newTab:r,children:`Add a server`}),children:_t(e.label,o)})}),o&&(0,Q.jsx)(ln,{title:`Why ${e.label}'s servers stay where they are`,children:(0,Q.jsx)(hn,{left:t.left})}),i&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:i,children:`Back to the apps`})})]})}function hn({left:e}){return(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[14px]`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`minus`,size:16,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — `,K(X(e.why))]})]})]},e.name))})}function gn({app:t,result:n,toolsHref:r,protect:i,newTab:a,extensionOn:o,onCheckAgain:c,onUndone:l,onAnother:u}){let d=F(()=>h.protection(n.toolbox.id),[n.toolbox.id]),f=dn(e=>l(e)),[p,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(null);(0,Z.useEffect)(()=>_.current?.focus(),[]);let v=f.error?.text??null,y=n.left.some(e=>e.kind===`needs-ok`),b=n.extensionsToSwitchOff.map(e=>({...e,enabled:o?.(e.id)??e.enabled})),S=mt(d.data?.enforcement);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{ref:_,tabIndex:-1,role:`status`,className:`flex flex-col gap-1 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}),ht(n,t.label)]}),(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`→ `,K(X(n.restartHint))]})]}),(0,Q.jsxs)(ln,{title:ct(n,t.label),children:[n.imported.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-wrap gap-1.5`,"aria-label":`Servers that moved`,children:n.imported.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-full bg-sunken px-2.5 py-0.5 text-[13px]`,children:[e.name,` `,(0,Q.jsxs)(`span`,{className:`text-soft`,children:[`· `,st(e.tools,`tool`)]})]},e.upstream))}),(0,Q.jsx)(x,{href:r,size:`sm`,iconRight:`arrow-right`,external:a,children:`See tools`})]}),n.takenOut.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:St(t.label,n.takenOut.map(e=>e.name))})]}),n.left.length>0&&(0,Q.jsxs)(ln,{title:lt(t.label),children:[(0,Q.jsx)(hn,{left:n.left}),y&&!p&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,icon:`eye`,onClick:()=>g(!0),children:`Review`})}),y&&p&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`Some servers need your OK before they can move`}),(0,Q.jsx)(on,{scope:t.scope})]})]}),n.allowedHosts.length>0&&(0,Q.jsxs)(ln,{title:`Web addresses your toolbox may now reach`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`The servers you moved live at these addresses, so your toolbox was allowed to connect to them.`}),(0,Q.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Web addresses your toolbox may now reach`,children:n.allowedHosts.map(e=>(0,Q.jsx)(`li`,{className:`mono rounded-full bg-sunken px-2.5 py-0.5 text-[12.5px]`,children:e},e))})]}),b.some(e=>e.enabled)&&(0,Q.jsxs)(ln,{title:Mt(b.filter(e=>e.enabled).length),children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:b.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[14px] font-medium`,children:[ot(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:J(t.name)})]},t.id))}),c&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:c,children:`Check again`})})]}),n.notRecorded.length>0&&(0,Q.jsx)(ln,{title:`Not recorded`,children:(0,Q.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-[13.5px] text-muted`,children:n.notRecorded.map(e=>(0,Q.jsx)(`li`,{children:K(e)},e))})}),(n.guard||S||n.otherApps.length>0)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[n.guard&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions (reading and editing files, running commands, opening web pages) are recorded too.`}),S&&(0,Q.jsx)(`p`,{children:S}),n.otherApps.length>0&&(0,Q.jsx)(`p`,{children:at(n.otherApps)})]}),n.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(n.warning))}),v&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:v}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Q.jsx)(un,{go:i,icon:`shield-check`,variant:`primary`,newTab:a,children:`Protect me`}),n.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:f.busy===t.id,onClick:()=>f.run(t),children:ft(t.label)}),u&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:u,children:`Connect another app`})]}),(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)(q,{children:n.configPath})]}),(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:n.backupPath})]})]})]})}function _n(e,t){return t||(e.toolbox?.needsConfirm?e.toolbox:null)}function vn(e,t){let n=_n(e,t.asked);return{...e.id===`claude-code`?{guard:t.guard}:{},...n&&t.confirmed===n.id?{toolbox:n.id}:{}}}function yn(e,t,n){if(!e.installed||e.error||yt(e.connection))return!1;let r=_n(e,n);return!r||t===r.id}function bn(e){return e.kind===`result`&&e.result.status===`connected`?{app:e.app,result:e.result}:null}var xn={kept:null};function Sn(e){xn.kept=bn(e)}function Cn(){xn.kept=null}function wn({toolsHref:e,protect:t,addServer:n,newTab:r,keep:i,onConnected:a,onNeedsServer:c,onUndone:l}){let u=F(()=>H.apps(),[]),[d,p]=(0,Z.useState)(null),m=(0,Z.useRef)(!1),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)({}),[S,C]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(()=>i&&xn.kept?{kind:`result`,...xn.kept}:null),D=(e,t)=>{i&&Sn(t),T(e)},O=(0,Z.useRef)(null),k=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{w===null&&k.current&&(k.current=!1,O.current?.focus())},[w]);let A=(e,t)=>{D({kind:`undone`,app:t,undone:e},{kind:`undone`}),l?.(e,t),u.reload()},j=dn((e,t)=>A(e,u.data?.apps.find(e=>e.id===t.id)??{id:t.id,label:t.id})),ee=e=>{m.current||(m.current=!0,p(e.id),g(t=>({...t,[e.id]:``})),H.connectApp(e.id,vn(e,{guard:_,confirmed:y[e.id],asked:S[e.id]})).then(t=>{D({kind:`result`,app:e,result:t},{kind:`result`,app:e,result:t}),t.status===`connected`?a?.(t,e):c?.(e),u.reload()}).catch(t=>{let n=t instanceof f?t.detail:void 0;t instanceof f&&t.status===409&&n?.needs===`toolbox`&&(C(t=>({...t,[e.id]:n.toolbox})),b(t=>({...t,[e.id]:void 0})),u.reload()),g(n=>({...n,[e.id]:B(t)}))}).finally(()=>{m.current=!1,p(null)}))},M=()=>{k.current=!0,D(null,{kind:`back`})};if(w?.kind===`undone`)return(0,Q.jsx)(fn,{app:w.app,undone:w.undone,onAnother:M});if(w){let i=u.data?.apps.find(e=>e.id===w.app.id),a=w.result;return(0,Q.jsx)(pn,{app:w.app,result:a,toolsHref:a.status===`connected`?e(a.toolbox.id,w.app.id):``,protect:a.status===`connected`?t(a.toolbox.id):n,addServer:n,newTab:r,extensionOn:e=>i?.servers.find(t=>t.source===`extension`&&t.extensionId===e)?.enabled,onCheckAgain:u.reload,onUndone:e=>A(e,w.app),onAnother:M})}if(u.error&&!u.data)return(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:u.reload,children:`Check again`}),children:B(u.error)});if(!u.data)return(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,"aria-busy":`true`,"aria-label":`Looking for your AI apps`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))});let N=u.data.apps.filter(e=>e.installed),P=u.data.apps.filter(e=>!e.installed),I=d?u.data.apps.find(e=>e.id===d)?.label??null:null;return(0,Q.jsxs)(`div`,{ref:O,tabIndex:-1,className:`flex flex-col gap-4 outline-none`,children:[N.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:Et}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:Tt}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[U.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:u.loading,onClick:u.reload,children:`Check again`})]})]}):(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,"aria-label":`Your AI apps`,children:N.map(e=>(0,Q.jsx)(Tn,{app:e,busy:d,busyLabel:I,error:h[e.id]||(j.error?.app===e.id?j.error.text:null),guard:_,onGuard:v,confirmed:y[e.id],onConfirm:t=>b(n=>({...n,[e.id]:t})),asked:S[e.id],onConnect:()=>ee(e),undoing:j.busy===e.id,onUndo:()=>j.run(e)},e.id))}),P.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-muted`,children:[`Not on this computer`,`:`]}),` `,P.map(e=>e.label).join(` · `)]}),u.data.cloud.length>0&&(0,Q.jsxs)(`section`,{"aria-labelledby":`cloud-apps-h`,className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Q.jsx)(`h3`,{id:`cloud-apps-h`,className:`text-[14px] font-semibold`,children:`Can't be connected from here`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[13px] text-muted`,children:u.data.cloud.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-ink`,children:[e.label,`:`]}),` `,e.note]},e.label))})]})]})}function Tn({app:t,busy:n,busyLabel:r,error:i,guard:a,onGuard:o,confirmed:s,onConfirm:c,asked:l,onConnect:u,undoing:d,onUndo:f}){let{moving:p,staying:h}=gt(t),g=_n(t,l),_=yt(t.connection),v=yn(t,s,l),y=!!n&&n!==t.id;return(0,Q.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2.5 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold`,children:t.label}),t.connected&&(0,Q.jsx)(e,{tone:`ok`,children:`Connected`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:Dt(t)}),p.length>0&&(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`Moves: `,p.map(e=>e.name).join(`, `)]}),h.length>0&&(0,Q.jsxs)(`details`,{className:`text-[13px]`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-muted select-none`,children:[`Why `,h.length===1?`1 stays`:`${h.length} stay`]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:h.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:[`— `,vt(e)]})]},`${e.scope}:${e.source}:${e.name}`))})]}),t.running&&(0,Q.jsxs)(`p`,{className:`flex gap-2 text-[13px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,className:`mt-0.5 shrink-0`}),ut(t.label)]}),t.error&&(0,Q.jsx)(`p`,{className:`text-[13px] text-bad`,children:K(X(t.error))}),_&&(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:_}),t.id===`claude-code`&&!_&&(0,Q.jsx)(re,{checked:a,onChange:o,label:`Also record what Claude Code does by itself (reading and editing files, running commands)`,description:kt(g&&g.id!==t.toolbox?.id?{mode:null}:t.toolbox)}),g&&!_&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-2xl bg-sunken/60 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:wt(t.label,g)}),(0,Q.jsx)(re,{checked:s===g.id,onChange:e=>c(e?g.id:void 0),label:jt(g.label)})]}),i&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),y&&r&&(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:dt(r)}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:n===t.id,disabled:!v||y,onClick:u,children:At(t.label,t.connected)}),t.connected&&t.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:d,disabled:!!n,onClick:f,children:ft(t.label)})]})]})}var En=null;function Dn({client:e,projectDir:t,onClose:n,onDone:r}){let i=oe(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(En),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(En=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{En=null,n(),r()},_=Oe(e.scope),v=()=>{l(!0),d(null),H.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{En=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(B(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(ie,{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)(On,{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)(q,{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:K(X(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)(On,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(On,{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)(q,{children:e.path}),` `,K(X(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:K(X(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(f.warning))})]})})}return(0,Q.jsx)(ie,{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)(q,{children:e.path})]})]})]}),(0,Q.jsx)(re,{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 On({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)(q,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var kn={done:null};function An({gatewayId:t,onDone:r,compact:i,scope:a}){let c=F(()=>H.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(kn.done&&(!a||kn.done.scope===a)?kn.done:null),g=e=>{kn.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)=>jn(e)-jn(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=V(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:B(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null,t=e?.servers?$e(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:K(X(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)(q,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:p.backupPath})]})]}),e?.attachedTo&&(0,Q.jsx)(on,{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)(Dn,{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:B(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:[U.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:L(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=G(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:L(`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:L(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:Ue(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?K(X(t.error)):r?W(t.servers,Pe(t)):n?it(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 `,V(t.scope)]}),r&&(0,Q.jsx)(cn,{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)(Dn,{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 jn=e=>e.error?3:e.alreadyAdopted?1:G(e)?0:4;export{cn as a,Lt as c,Nt as d,Ft as f,Cn as i,Pt as l,Dn as n,nn as o,wn as r,tn as s,An as t,It as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 U,z as de}from"./kit-BHB_ha4i.js";import{r as fe,t as pe}from"./server-name-D9u6r07i.js";import{$ as me,$t as he,An as ge,Cn as _e,Dn as ve,En as ye,Ft as be,Gt as xe,Ht as Se,It as Ce,Kt as W,Mn as we,On as Te,Q as Ee,Qt as De,Rt as G,Tn as Oe,Ut as ke,Vt as Ae,Wt as je,X as Me,Xt as Ne,Z as Pe,Zt as Fe,_ as Ie,an as Le,bn as Re,cn as K,d as ze,en as Be,et as q,f as Ve,g as He,h as Ue,hn as We,in as Ge,kn as Ke,m as qe,mn as J,p as Je,qt as Ye,rn as Y,s as Xe,tn as Ze,tt as X,v as Qe,wn as $e,xn as et,y as tt,yn as nt}from"./index-Cm4wG2zz.js";import{a as rt,c as it,d as at,f as ot,i as st,l as ct,n as lt,o as ut,r as dt,s as ft,t as pt,u as mt}from"./AttachApp-COr1547c.js";import{m as ht,p as gt}from"./connect-app-words-CT8Fytzv.js";var Z=u(),Q=L(),_t=[`Choose an app`,`Choose how it starts`,`Check what will happen`,`Connect`],vt={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 yt(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,...Ne(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 bt={done:null,undo:null};function xt({open:e,onClose:t}){let n=()=>{bt.done=null,bt.undo=null,t()};return(0,Q.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,Q.jsx)(St,{onClose:n})})}function St({onClose:e}){let{nav:t,reload:n}=J(),[r,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(``),c=(0,Z.useRef)(!1),u=O(o.trim(),450),d=B(()=>we.clients(u||void 0),[u]);(0,Z.useEffect)(()=>{d.data&&!c.current&&!o&&s(d.data.projectDir)},[d.data]);let[f,p]=(0,Z.useState)(null),h=d.data?.clients.find(e=>e.scope===f)??null,[g,_]=(0,Z.useState)(vt),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(bt.undo),S=e=>{bt.undo=e,x(e)},C=(0,Z.useMemo)(()=>h?yt(h.scope,d.data?.projectDir??``,h.projectScoped,g):null,[h,d.data?.projectDir,g]),w=JSON.stringify(C),[T,E]=(0,Z.useState)(null),D=r>=2&&C&&T?.key!==w;(0,Z.useEffect)(()=>{if(r<2||!C||T?.key===w)return;let e=!0;return we.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,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[N,F]=(0,Z.useState)(bt.done),I=()=>{C&&(A(!0),M(null),we.apply(C).then(e=>{bt.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,Q.jsx)(It,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{steps:_t,step:r,onStep:e=>a(Math.max(0,e)),canNext:z&&!k,nextLabel:r===2?`Review and connect`:`Continue`,finishLabel:h?`Connect ${G(h.scope)}`:`Connect app`,onFinish:I,busy:k||!!D,children:[r===0&&(0,Q.jsx)(Ct,{clients:d,projectDir:o,onProjectDir:e=>{c.current=!0,s(e)},scope:f,onScope:p,onUndo:S,onAttach:y}),r===1&&h&&(0,Q.jsx)(Dt,{client:h,choices:g,onChange:_,found:L?.data?.serversFound??T?.data?.serversFound??[]}),r===2&&(D||!L?(0,Q.jsx)(Ot,{}):L.error?(0,Q.jsx)(l,{tone:`danger`,title:`The check could not finish`,role:`alert`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>E(null),children:`Check again`}),children:L.error}):(0,Q.jsx)(At,{plan:L.data,app:G(h.scope)})),r===3&&L?.data&&h&&(0,Q.jsx)(Ft,{plan:L.data,client:h,error:j,id:g.id,onId:e=>_({...g,id:e})})]}),(0,Q.jsx)(Lt,{client:v,onClose:()=>y(null),onDone:()=>d.reload()}),(0,Q.jsx)(lt,{client:b,projectDir:d.data?.projectDir,onClose:()=>S(null),onDone:()=>{d.reload(),n()}})]})}function Ct({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,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.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,Q.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,Q.jsx)(f,{value:t,onChange:n,mono:!0,placeholder:`/Users/me/my-project`})}),e.error&&!e.data?(0,Q.jsx)(l,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:e.reload,children:`Check again`}),children:W(e.error)}):e.data?(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`App to connect`,className:`grid gap-3 sm:grid-cols-2`,children:[...u].sort((e,t)=>wt(e)-wt(t)).map(t=>(0,Q.jsx)(Et,{client:t,projectDir:e.data?.projectDir,selected:r===t.scope,onSelect:()=>i(t.scope),onUndo:()=>a(t),onAttach:()=>s(t)},t.scope))}):(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)(c,{lines:3})},e))})]})}var wt=e=>e.error?3:e.alreadyAdopted?1:e.exists&&e.serverCount>0?0:Ae(e)?2:4,Tt=e=>!e.alreadyAdopted&&Ae(e)&&!(e.exists&&e.serverCount>0);function Et({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=Tt(t),u=(0,Z.useId)(),d=Be(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,Q.jsxs)(`div`,{className:U(`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,Q.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,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:U(`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,Q.jsx)(g,{name:`check`,size:12,strokeWidth:3})}),(0,Q.jsx)(`span`,{id:`${u}-name`,className:U(`min-w-0 flex-1 text-[15px] font-semibold`,!c&&`text-soft`),children:d}),(0,Q.jsx)(`span`,{id:`${u}-status`,children:(0,Q.jsx)(e,{tone:f.tone,children:f.text})})]}),(0,Q.jsx)(`span`,{id:`${u}-desc`,className:`pl-7 text-[13px] text-soft`,children:t.error?K(Y(t.error)):l?`It has no servers yet. Connect it to your toolbox, then add servers there.`:t.exists?t.alreadyAdopted?t.servers?ke(t.servers,je(t)):Se(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,Q.jsx)(`span`,{className:`pl-7`,children:(0,Q.jsx)(q,{children:t.path})})]}),l&&(0,Q.jsx)(`div`,{className:`pl-7`,children:(0,Q.jsx)(P,{size:`sm`,variant:`primary`,icon:`plug`,onClick:s,children:`Connect it to your toolbox`})}),t.attachedTo&&(0,Q.jsx)(`div`,{className:`pl-7`,children:(0,Q.jsx)(rt,{client:t,...n?{projectDir:n}:{}})}),t.canRevert&&(0,Q.jsx)(`div`,{className:`pl-7`,children:(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:o,children:`Undo connection`})})]})}function Dt({client:t,choices:n,onChange:r,found:i}){let a=(e,t)=>r({...n,[e]:t}),s=Ne(t.scope);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{sub:`You can switch at any time on the Protection settings page.`,children:[`How it starts `,(0,Q.jsx)(w,{term:`watchOnly`})]}),(0,Q.jsx)(Me,{label:`How it starts`,value:n.mode,onChange:e=>a(`mode`,e),options:[{value:`observe`,title:E.observe.label,badge:(0,Q.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,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{sub:`What happens to a call no rule mentions.`,children:[`How careful the toolbox is `,(0,Q.jsx)(w,{term:`defaultStance`})]}),(0,Q.jsx)(Me,{label:`How careful the toolbox is`,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,Q.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(o,{label:(0,Q.jsxs)(Q.Fragment,{children:[`Tools nobody has labelled yet `,(0,Q.jsx)(w,{term:`unknownTools`})]}),help:`A tool that hasn't said whether it only looks, makes changes or deletes.`,children:(0,Q.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,Q.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,Q.jsx)(p,{checked:s&&n.mode===`enforce`&&n.clientAllow,onChange:e=>a(`clientAllow`,e),disabled:!s||n.mode!==`enforce`,label:`Don't ask me twice`,description:s?n.mode===`enforce`?`Claude Code asks before each tool call, and your toolbox asks too when a rule says so. This stops Claude Code asking about your toolbox's tools, so you answer once.`:`Available when protecting. While it only watches, your toolbox never asks, so Claude Code's own question is the only one left.`:`Only Claude Code has this setting. ${G(t.scope)} keeps asking in its own way.`})]}),(0,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Q.jsx)(o,{label:`Toolbox name`,technical:`name`,optional:!0,help:`Shown in the console and in the activity log.`,children:(0,Q.jsx)(f,{value:n.gatewayName,onChange:e=>a(`gatewayName`,e),mono:!0,placeholder:`claude-code`})}),(0,Q.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,Q.jsx)(f,{value:n.entryName,onChange:e=>a(`entryName`,e),mono:!0,placeholder:`hmcp`})})]}),(0,Q.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,Q.jsx)(me,{value:n.rename,onChange:e=>a(`rename`,e),keyLabel:`Name in the app`,valueLabel:`Name in your toolbox`,addLabel:`Add a rename`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.jsx)(f,{value:n.outDir,onChange:e=>a(`outDir`,e),mono:!0,placeholder:`/Users/me/my-project/.hmcp`})})]})]})}function Ot(){let[e,t]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>t(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-14 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)(oe,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:`Starting each server to see its tools…`}),(0,Q.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,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,e,` s)`]})]})]})]})}var kt=[{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 At({plan:t,app:n}){let i=t.starting?.mode!==`enforce`,a=t.tools.filter(e=>e.injection);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t.blocking.length>0&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,title:`This can't be connected yet`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.blocking.map(e=>(0,Q.jsx)(`li`,{children:K(Y(e))},e))})}),t.status===`already-adopted`&&t.blocking.length===0&&(0,Q.jsx)(l,{tone:`info`,title:`${n} already goes through your toolbox`,children:`Connecting again only applies the change you chose.`}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{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,Q.jsx)(`p`,{className:`text-[14px] text-soft`,children:`No server can go through your toolbox.`}):(0,Q.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:t.upstreams.map(t=>(0,Q.jsxs)(`li`,{className:`flex min-w-0 gap-3 rounded-2xl bg-sunken/60 p-3`,children:[(0,Q.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-surface text-muted`,children:(0,Q.jsx)(g,{name:t.transport===`http`?`external`:`server`,size:17})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`mono text-[13.5px] font-semibold`,children:t.name}),t.originalName!==t.name&&(0,Q.jsxs)(`span`,{className:`text-[12px] text-soft`,children:[`was `,t.originalName]}),t.alreadyFronted&&(0,Q.jsx)(e,{children:`Already connected`})]}),(0,Q.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,Q.jsxs)(`span`,{className:`mt-0.5 block text-[12px] text-soft`,children:[`Uses `,(0,Q.jsx)(`span`,{className:`mono`,children:[...t.envNames,...t.passEnv,...t.headerNames].join(`, `)})]}),t.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:K(Y(e))},e))]})]},t.name))}),(t.skipped.length>0||t.malformed.length>0)&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:[`Left out (`,t.skipped.length+t.malformed.length,`)`]}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.skipped.map(e=>{let t=Ge(e.reason,e.remedy);return(0,Q.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Q.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted`,children:t.reason}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-soft`,children:t.remedy})]},e.name)}),t.malformed.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Q.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Q.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Its entry in the app's settings could not be read: `,K(Y(e.message))]})]},e.name))]})]})]}),t.probeFailures.length>0&&(0,Q.jsxs)(l,{tone:`danger`,title:`Some servers didn't start or answer`,children:[(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:t.probeFailures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`mono`,children:e.upstream}),`: `,K(Y(e.message))]},e.upstream))}),(0,Q.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,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{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,Q.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:kt.map(e=>{let n=t.tools.filter(t=>t.verdict===e.key);return n.length===0?null:(0,Q.jsx)(Nt,{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,Q.jsxs)(`section`,{children:[(0,Q.jsx)(X,{children:`Worth a look`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2 rounded-2xl bg-warn-tint p-3`,children:[(0,Q.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Q.jsxs)(`span`,{children:[(0,Q.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}`)),jt(t.findings).map(e=>(0,Q.jsx)(Mt,{group:e},e.ruleId)),t.namesTooLong.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Q.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Q.jsxs)(`span`,{children:[(0,Q.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,Q.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Q.jsx)(g,{name:`eye-off`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` won't be offered: `,K(Y(e.reason))]})]},`w-${e.name}`))]})]}),t.packs.length>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(X,{children:`Ready-made rules`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.packs.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3 rounded-2xl bg-ok-tint p-3 text-[13.5px]`,children:[(0,Q.jsx)(g,{name:`shield-check`,size:18,className:`shrink-0 text-ok`}),(0,Q.jsxs)(`span`,{children:[e.packLabel,` rules for `,(0,Q.jsx)(`code`,{className:`mono`,children:e.upstreamName}),`: `,r(e.rules.length,`rule`),e.unmatched.length>0&&(0,Q.jsxs)(`span`,{className:`text-soft`,children:[` · `,e.unmatched.length,` not used by this server`]})]})]},e.upstreamName))})]}),t.warnings.length>0&&(0,Q.jsx)(l,{tone:`warn`,title:`Before you connect`,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:K(Y(e))},e))})}),t.files&&(0,Q.jsx)(Pt,{plan:t})]})}function jt(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 Mt({group:e}){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Q.jsx)(g,{name:`shield`,size:17,className:U(`mt-0.5 shrink-0`,e.high?`text-bad`:`text-warn`)}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`font-semibold`,children:M(e.ruleId)}),(0,Q.jsx)(`span`,{className:`mono text-[11.5px] text-soft`,children:e.ruleId}),e.items.length>1&&(0,Q.jsxs)(`span`,{className:`text-soft`,children:[`· `,e.items.length,` places`]}),e.ruleId in F&&(0,Q.jsx)(w,{term:e.ruleId})]}),(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,className:`-ml-3`,"aria-expanded":t,onClick:()=>n(!t),children:t?`Hide details`:`Show details`}),t&&(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5 text-[13px] text-muted`,children:e.items.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:K(Y(e.message))},t))})]})]})}function Nt({label:t,icon:n,tone:r,tools:i}){let[a,o]=(0,Z.useState)(i.length<=8),s=a?i:i.slice(0,8);return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Q.jsx)(e,{tone:r,icon:n,children:t}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:i.length})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col`,children:s.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)(C,{effect:e.effect}),(0,Q.jsx)(`code`,{className:`mono min-w-0 flex-1 truncate text-[12.5px]`,title:e.name,children:e.name}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[12px] text-soft`,title:e.decidedBy,children:xe(e.decidedBy)})]},e.name))}),!a&&(0,Q.jsxs)(P,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>o(!0),children:[`Show all `,i.length,` tools`]})]})}function Pt({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,Q.jsxs)(`section`,{children:[(0,Q.jsx)(X,{children:`Files that will be written`}),(0,Q.jsx)(`dl`,{className:`flex flex-col gap-2 text-[13px]`,children:n.filter(([,e])=>e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-[240px_1fr]`,children:[(0,Q.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(q,{children:t})})]},e))})]})}function Ft({plan:e,client:t,error:n,id:i,onId:a}){let s=G(t.scope),c=e.starting?.mode!==`enforce`,u=e.upstreams.filter(e=>!e.alreadyFronted).length,d=[[`plug`,u>0?`${r(u,`server`)} in ${t.label} will go through your toolbox.`:`The change you chose is applied to your toolbox.`],[`file`,`A backup of the app's settings is kept, so you can undo this here at any time.`],[c?`eye`:`shield-check`,c?`For now it only watches: everything runs, and the activity log shows what would have been stopped.`:`It starts protecting: your rules apply from the first call.`],[`refresh`,`${s} has to be restarted afterwards to pick up your toolbox.`]];return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(X,{children:`When you connect`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:d.map(([e,t])=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-3 text-[14.5px]`,children:[(0,Q.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(g,{name:e,size:17})}),(0,Q.jsx)(`span`,{className:`pt-1.5`,children:t})]},t))}),n&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,title:`It wasn't connected`,children:n.blocking?.length?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:n.blocking.map(e=>(0,Q.jsx)(`li`,{children:K(Y(e))},e))}):n.text}),n?.idTaken&&(0,Q.jsx)(o,{label:`Toolbox name in the console`,technical:`id`,help:`Lower-case letters, digits, dashes and underscores.`,children:(0,Q.jsx)(f,{value:i,onChange:a,mono:!0,placeholder:`claude-code-2`})})]})}function It({result:e,onClose:t,onOpen:n}){let r=G(e.scope),i=e.applied;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(R,{steps:_t,current:_t.length}),(0,Q.jsxs)(b,{icon:`check`,title:`Done. Restart ${r} so it picks up your toolbox.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[e.registryId&&(0,Q.jsx)(P,{variant:`primary`,icon:`arrow-right`,onClick:()=>n(e.registryId),children:`Open this toolbox`}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What was backed up`}),i.wholeFileBackup&&(0,Q.jsxs)(`p`,{children:[`A copy of the app's settings as they were: `,(0,Q.jsx)(q,{children:i.wholeFileBackup})]}),(0,Q.jsxs)(`p`,{children:[`What's needed to undo it: `,(0,Q.jsx)(q,{children:i.backupRecord})]}),i.clientAllowAdded&&(0,Q.jsx)(`p`,{children:`Claude Code won't ask a second time about your toolbox's tools.`})]}),i.literalSecretsInBackup&&(0,Q.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,Q.jsx)(l,{tone:`warn`,children:K(Y(e.warning))})]})}function Lt({client:e,onClose:t,onDone:n}){let{servers:r,serverId:i,nav:a}=J(),c=r.filter(e=>e.ok),[l,u]=(0,Z.useState)(null),d=l??(c.some(e=>e.id===i)?i:c[0]?.id??null);return e?(0,Q.jsx)(le,{open:!0,onClose:t,title:`Connect ${G(e.scope)} to your toolbox`,width:600,footer:(0,Q.jsx)(P,{onClick:t,children:`Close`}),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length>1&&(0,Q.jsx)(o,{label:`Which toolbox`,children:(0,Q.jsx)(h,{label:`Which toolbox`,value:d,onChange:u,options:c.map(e=>({value:e.id,label:e.label}))})}),(0,Q.jsx)(pt,{gatewayId:d,scope:e.scope,onDone:n},d)]}):(0,Q.jsxs)(b,{icon:`server`,title:`You don't have a toolbox yet`,compact:!0,children:[`Adding your first server sets one up. Then come back here and connect `,G(e.scope),`.`,(0,Q.jsx)(`span`,{className:`mt-4 block`,children:(0,Q.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>ue(s(a,{connect:null,add:`server`})),children:`Add a server`})})]})}):null}var Rt={done:null,label:``};function zt({open:e,onClose:t}){let{reload:n}=J(),r=()=>{let e=!!Rt.done;Rt.done=null,t(),e&&n()},[i,a]=(0,Z.useState)(`new`);return(0,Q.jsx)(v,{open:e,onClose:r,title:`Create a toolbox`,subtitle:`Set up a toolbox yourself, server by server.`,width:760,children:e&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.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,Q.jsx)(Bt,{onClose:r}):(0,Q.jsx)(Ht,{onClose:r})]})})}function Bt({onClose:e}){let{nav:t,reload:n}=J(),r=H(),[a,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(`observe`),[m,g]=(0,Z.useState)(`approve-writes`),[_,v]=(0,Z.useState)(`approve`),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)([at()]),[C,T]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(Rt.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)=>mt(e,x.filter((e,n)=>n!==t).map(e=>e.name.trim()))),L=!F&&I.every(e=>!e);return j?(0,Q.jsx)(Vt,{result:j,label:Rt.label,onClose:e,onOpen:()=>{e(),ue(i(t,`/`,{server:j.id}))}}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Q.jsx)(o,{label:`Name`,technical:`name`,help:`Also the name of its folder.`,error:k?F:null,children:(0,Q.jsx)(f,{value:a,onChange:s,mono:!0,placeholder:`work-tools`})}),(0,Q.jsx)(o,{label:`Label in the console`,optional:!0,children:(0,Q.jsx)(f,{value:c,onChange:u,placeholder:`Work tools`})})]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{children:[`How it starts `,(0,Q.jsx)(w,{term:`watchOnly`})]}),(0,Q.jsx)(Me,{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,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(X,{children:[`How careful the toolbox is `,(0,Q.jsx)(w,{term:`defaultStance`})]}),(0,Q.jsx)(Me,{label:`How careful the toolbox is`,columns:3,value:m,onChange:g,options:Object.keys(V).map(e=>({value:e,title:V[e].label,body:V[e].explain}))})]}),(0,Q.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Q.jsx)(o,{label:(0,Q.jsxs)(Q.Fragment,{children:[`Tools nobody has labelled yet `,(0,Q.jsx)(w,{term:`unknownTools`})]}),children:(0,Q.jsx)(h,{label:`Tools nobody has labelled yet`,value:_,onChange:v,options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,Q.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,Q.jsx)(f,{value:y,onChange:b,mono:!0,placeholder:`~/.hmcp/gateways/work-tools`})})]}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(X,{sub:`The servers this toolbox sits in front of. A toolbox needs at least one.`,children:[`Connected servers `,(0,Q.jsx)(w,{term:`connectedServer`})]}),x.map((e,t)=>(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-[14.5px] font-semibold`,children:[`Server `,t+1]}),x.length>1&&(0,Q.jsx)(N,{icon:`trash`,label:`Remove server ${t+1}`,size:34,onClick:()=>S(x.filter((e,n)=>n!==t))})]}),(0,Q.jsx)(it,{value:e,onChange:e=>S(x.map((n,r)=>r===t?e:n)),literalWarning:!0}),k&&I[t]&&(0,Q.jsx)(`p`,{role:`alert`,className:`mt-3 text-[13px] font-medium text-bad`,children:I[t]})]},t)),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(P,{icon:`plus`,onClick:()=>S([...x,at()]),children:`Add another server`})})]}),D&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,title:`The toolbox wasn't created`,children:D}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:e,disabled:C,children:`Cancel`}),(0,Q.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>{A(!0),L&&(T(!0),O(null),we.createGateway({name:a,...c.trim()?{label:c.trim()}:{},mode:d,posture:m,onUnclassified:_,...y.trim()?{outDir:y.trim()}:{},upstreams:x.map(ot)}).then(e=>{Rt.done=e,Rt.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=>K(Y(e.message))).join(` `)}`:``))}).finally(()=>T(!1)))},loading:C,children:`Create toolbox`})]})]})}function Vt({result:e,label:t,onClose:n,onOpen:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(b,{icon:`check`,title:`${t} is ready`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{variant:`secondary`,icon:`arrow-right`,onClick:r,children:`Open this toolbox`}),(0,Q.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,Q.jsxs)(`section`,{children:[(0,Q.jsx)(X,{children:`Connect your AI app`}),(0,Q.jsx)(pt,{gatewayId:e.id,onDone:()=>void 0})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Q.jsxs)(`p`,{children:[`Settings file: `,(0,Q.jsx)(q,{children:e.configPath})]}),(0,Q.jsxs)(`p`,{children:[`Protection settings: `,(0,Q.jsx)(q,{children:e.policyPath})]})]}),e.warnings.map(e=>(0,Q.jsxs)(l,{tone:`warn`,children:[K(Y(e)),` If one is a password or key, keep that file private.`]},e)),e.warning&&(0,Q.jsx)(l,{tone:`warn`,children:K(Y(e.warning))})]})}function Ht({onClose:e}){let{nav:t,reload:n}=J(),r=H(),[a,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=()=>{p(!0),h(null),_.addServer({kind:`gateway`,...a.trim()?{label:a.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,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.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,Q.jsx)(o,{label:`Label in the console`,optional:!0,help:`Left empty, it's named after the toolbox.`,children:(0,Q.jsx)(f,{value:a,onChange:s,placeholder:`Work tools`})}),(0,Q.jsx)(o,{label:`Settings file`,technical:`gateway.yaml`,help:`The full path to its settings file.`,children:(0,Q.jsx)(f,{value:c,onChange:u,mono:!0,placeholder:`/Users/me/.hmcp/gateways/work/gateway.yaml`,onEnter:g})}),m&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,children:m}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-faint pt-5`,children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:e,children:`Cancel`}),(0,Q.jsx)(P,{variant:`primary`,icon:`plus`,onClick:g,loading:d,disabled:!c.trim(),children:`Add toolbox`})]})]})}function Ut(){return document.cookie.match(/(?:^|;\s*)hmcp_csrf=([^;]+)/)?.[1]??``}async function Wt(e,t={}){let n={...t.headers??{}};t.method&&t.method!==`GET`&&(n[`Content-Type`]=`application/json`,n[`X-HMCP-CSRF`]=Ut());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 Gt=e=>({method:`POST`,body:JSON.stringify(e)}),Kt=(e,t)=>`/api/v1/servers/${encodeURIComponent(e.gatewayId)}/github/${encodeURIComponent(e.upstream)}/${t}`,qt={doors:()=>Wt(`/api/v1/github-doors`),claudeCode:e=>Wt(`/api/v1/github-doors/claude-code`,Gt({scope:`user`,close:e,confirm:!0})),confirm:(e,t)=>Wt(`/api/v1/github-doors/confirm`,Gt({door:e,done:t})),setChanges:(e,t)=>Wt(Kt(e,`changes`),Gt({allow:t,expectedDigest:e.digest,confirm:!0})),check:e=>Wt(Kt(e,`check`),Gt({}))},Jt=`Make hmcp the only way to change GitHub`,Yt=`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.`,Xt=`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.`,Zt=`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'.`,Qt=`Not checked yet — press Check it works to see what each change will meet.`,$t=`Once it's switched, press Check it works to see what each change will meet.`,en=`Let Claude change GitHub through hmcp`,tn=`Back to only looking`,nn=`Your GitHub server can make changes.`,rn=`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).`,an=e=>V[e]?.label??e;function on(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 Qt;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 the toolbox is set to “${an(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 sn(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 cn(){let e=H(),t=B(()=>qt.doors(),[]),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.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,Q.jsx)(re,{title:Jt,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:Yt}),o.servers.map(o=>(0,Q.jsx)(ln,{server:o,busy:n,check:i[`${o.gatewayId}/${o.upstream}`]??null,onSwitch:n=>{r(`switch:${o.upstream}`),qt.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. ${on(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}`),qt.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,Q.jsx)(`ul`,{className:`flex flex-col`,children:o.doors.map(e=>(0,Q.jsx)(un,{door:e,busy:n,onBlock:e=>s(`claude-code`,()=>qt.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}`,()=>qt.confirm(e.id,t),t?`Noted as done.`:`Noted as not done yet.`)},e.id))}),(0,Q.jsx)(l,{tone:`info`,children:Xt}),(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:rn})]})})}function ln({server:e,busy:t,check:n,onSwitch:r,onCheck:i}){let a=We()(e.upstream,e.gatewayId);return e.access===null?null:(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[14px]`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[a,` in `,e.gatewayLabel,pe(e.upstream,a)&&(0,Q.jsx)(`span`,{className:`ml-2 font-mono text-[12px] font-normal text-soft`,children:e.upstream})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted`,children:e.access===`readonly`?Zt:nn}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted`,children:e.access===`readonly`?$t:on(e.changes)}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:e.access===`readonly`?(0,Q.jsx)(P,{size:`sm`,variant:`primary`,icon:`shield-check`,loading:t===`switch:${e.upstream}`,onClick:()=>r(!0),children:en}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{size:`sm`,variant:`primary`,icon:`check`,loading:t===`check:${e.upstream}`,onClick:i,children:`Check it works`}),(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`eye`,loading:t===`switch:${e.upstream}`,onClick:()=>r(!1),children:tn})]})}),n&&(0,Q.jsxs)(`div`,{className:`mt-3`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:n.lines.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.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,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:e.ok?`Passed: `:`Needs a look: `}),e.text]})]},e.text))}),(0,Q.jsx)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:n.note})]})]})}function un({door:t,busy:n,onBlock:r,onConfirm:i}){let a=sn(t),o=t.links!==void 0;return(0,Q.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-faint py-3 last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[15px] font-medium`,children:t.label}),(0,Q.jsx)(e,{tone:a.tone,children:a.label})]}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:t.detail}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.links.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsx)(T,{href:e.url,external:!0,size:`sm`,icon:`external`,className:`shrink-0`,children:e.label}),(0,Q.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.press})]},e.url))}),t.why&&(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:t.why}),(0,Q.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,Q.jsx)(`ol`,{className:`ml-5 list-decimal text-[13px] text-muted`,children:t.fix.map(e=>(0,Q.jsx)(`li`,{children:e},e))}),t.id===`claude-code-terminal`&&t.state===`harder`&&(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.state!==`closed`&&t.state!==`harder`&&(0,Q.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,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:n===`claude-code`,onClick:()=>r(!1),children:`Undo`})]})]})}function dn({servers:t,serverId:n}){let r=H(),i=B(()=>we.guard(),[],3e4),[a,o]=(0,Z.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),we.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,Q.jsx)(re,{title:`Guard every Claude Code tool with hmcp`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.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,Q.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,Q.jsx)(`code`,{className:`mono`,children:`claude-code__WebFetch`}),`.`]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.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,Q.jsx)(`span`,{className:`text-[12.5px] text-soft`,children:`All projects`})]}),i.error&&(0,Q.jsx)(l,{tone:`warn`,children:i.error}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(P,{size:`sm`,variant:u?`ghost`:`primary`,loading:a,onClick:()=>f(!u),children:u?`Turn off`:`Turn on, checked by ${c.label}`})})]})})}function fn(e){return B(()=>et(e),[e],3e3)}function pn(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 mn({token:e,url:t,onClose:n}){return(0,Q.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,Q.jsx)(P,{variant:`primary`,onClick:n,children:`I've copied it`}),children:e&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Q.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:e}),(0,Q.jsx)(Pe,{text:e,label:`Copy password`})]}),(0,Q.jsxs)(`p`,{className:`text-muted`,children:[`In your AI app's server settings, add a header named `,(0,Q.jsx)(`code`,{className:`mono`,children:`Authorization`}),` with the value`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`Bearer`}),`, a space, then this password.`,t&&(0,Q.jsxs)(Q.Fragment,{children:[` `,`The server's address is `,(0,Q.jsx)(q,{children:t})]})]})]})})}function hn({id:n,label:r}){let i=fn(n),{reload:s}=J(),u=H(),[d,f]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(`127.0.0.1`),[E,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)(!0),[N,F]=(0,Z.useState)(null),I=(e,t=!1)=>{f(e),v(null),(e===`start`?Te(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`?Ke(n):Oe(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(Ze(n)):v(W(n))}).finally(()=>f(null))};if(i.error&&!i.data)return(0,Q.jsx)(l,{tone:`danger`,title:`Whether your toolbox is running could not be read`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:W(i.error)});let L=i.data;if(!L)return(0,Q.jsx)(c,{lines:4});let R=pn(L),z=L.state===`running`||L.state===`starting`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`grid h-11 w-11 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(g,{name:`power`,size:20})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-[16px] font-semibold`,children:[r,` `,(0,Q.jsx)(e,{tone:R.tone,children:R.label})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(P,{icon:`refresh`,onClick:()=>I(`restart`),loading:d===`restart`,disabled:!!d,children:`Restart toolbox`}),(0,Q.jsx)(P,{variant:`danger`,icon:`stop`,onClick:()=>I(`stop`),loading:d===`stop`,disabled:!!d,children:`Stop toolbox`})]})]}),_&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,children:_}),L.externallyRunning?(0,Q.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,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(X,{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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Q.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:L.http.url}),(0,Q.jsx)(Pe,{text:L.http.url,label:`Copy address`})]}),(0,Q.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,Q.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(X,{sub:`Runs your toolbox from this console, so AI apps on this computer can reach it at a web address.`,children:`Start toolbox`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Q.jsx)(o,{label:`Port`,optional:!0,help:`Leave empty to use 7878.`,children:(0,Q.jsx)(a,{value:S,onChange:C,min:1,max:65535})}),(0,Q.jsx)(o,{label:`Address`,help:`This computer only. Your toolbox is never reachable from other computers.`,children:(0,Q.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,Q.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,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.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,Q.jsx)(t,{value:E,onChange:O,placeholder:`my-machine.local`})}),(0,Q.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,Q.jsx)(t,{value:k,onChange:A,placeholder:`http://localhost:3000`})})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(P,{variant:`primary`,icon:`play`,onClick:()=>I(`start`),loading:d===`start`,children:`Start toolbox`})})]}),(L.managed||L.log.length>0)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(X,{children:`What it has written`}),(0,Q.jsx)(ne,{lines:L.log,height:260,label:`${r} output`,empty:`Nothing yet.`})]}),(0,Q.jsx)(mn,{token:y?.token??null,url:y?.url??null,onClose:()=>b(null)}),(0,Q.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 gn({id:e,tab:t,onTab:n,onClose:r,replaceKeyFor:i,onOpened:a}){let{servers:o}=J(),s=o.find(t=>t.id===e);return(0,Q.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,Q.jsx)(_n,{id:e,label:s?.label??e,tab:t,onTab:n,replaceKeyFor:i??null,onOpened:a},e)})}function _n({id:e,label:t,tab:n,onTab:r,replaceKeyFor:i,onOpened:a}){let o=B(()=>Re(e),[e]),s=fn(e),u=H(),{reload:f}=J(),p=Ie(e),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.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:Ze(t),run:()=>e(j.digest,{loosens:!0}).then(e=>{i(e),a(!0)})})}):(De(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,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[ee&&(0,Q.jsxs)(l,{tone:`warn`,role:`status`,title:`Restart needed for changes to take effect`,actions:I?.managed&&!I.externallyRunning?(0,Q.jsx)(P,{size:`sm`,variant:`primary`,icon:`refresh`,loading:k,onClick:()=>{A(!0),Oe(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,Q.jsx)(l,{tone:`warn`,title:`This changed since you opened it. Reload and try again.`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>{b(!1),o.reload()},children:`Reload settings`})}),j?.broken&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,title:`This toolbox's settings file can't be loaded`,children:j.broken}),(0,Q.jsx)(ie,{items:te,value:N,onChange:r,label:`Toolbox settings`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:S(N),"aria-labelledby":d(N),children:N===`run`?(0,Q.jsx)(hn,{id:e,label:t}):o.error&&!j?(0,Q.jsx)(l,{tone:`danger`,title:`The toolbox's settings file could not be read`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):j?N===`file`?(0,Q.jsx)(Cn,{id:e,file:j,write:F}):j.broken===null&&N===`servers`?(0,Q.jsx)(vn,{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,Q.jsx)(xn,{id:e,file:j,write:F},j.digest):null:(0,Q.jsx)(c,{lines:6})}),(0,Q.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 vn({id:t,file:n,write:r,live:a,running:o,onReload:s,start:c,onStarted:l}){let u=n.config.upstreams,{nav:d}=J(),f=H(),p=tt(),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(()=>{if(c?.kind===`by-hand`)return{original:null,draft:at()};let e=c?u.find(e=>e.name===c.server):void 0;return e&&c?.kind===`replace-key`&&he(e)?null:e?{original:e.name,draft:ct(e)}:null}),[x,S]=(0,Z.useState)(()=>{let e=c?.kind===`replace-key`?u.find(e=>e.name===c.server):void 0;return e?he(e):null});(0,Z.useEffect)(()=>{c&&l?.()},[]);let[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),A=Qe(t);if(y){let e=u.map(e=>e.name).filter(e=>e!==y.original),i=mt(y.draft,e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(X,{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,Q.jsx)(it,{value:y.draft,onChange:e=>b({...y,draft:e}),nameLocked:!!y.original,secret:n.keptSecret,literalWarning:!0}),C&&i&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:()=>b(null),disabled:E,children:`Cancel`}),(0,Q.jsx)(P,{variant:`primary`,icon:`check`,onClick:()=>{T(!0),!i&&(D(!0),bn(ot(y.draft),n.keptSecret).then(e=>r((n,r)=>y.original?ge(t,y.original,e,n,r):nt(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,Q.jsx)(ut,{gatewayId:t,fixUpstream:_,onCancel:()=>{ft(),v(null)},onDone:e=>{ft(),v(null),f.show(`ok`,`${e.upstreamName} was saved.`),s()}});if(m)return(0,Q.jsx)(ut,{gatewayId:t,onCancel:()=>{ft(),h(!1)},onDone:e=>{h(!1),f.show(`ok`,`${e.upstreamName} was added.`),s()}});let j=u.length===1;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`The servers this toolbox sits in front of. `,(0,Q.jsx)(w,{term:`connectedServer`})]}),(0,Q.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:null,draft:at()})},children:`Add one by hand`}),(0,Q.jsx)(P,{size:`sm`,variant:`primary`,icon:`plus`,onClick:()=>h(!0),children:`Add a server`})]})]}),(0,Q.jsx)(ze,{id:t,upstreams:u,digest:n.digest,onMoved:s}),(0,Q.jsx)(Ve,{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,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map(n=>{let r=Ue(a,n.name),c=(A.data??[]).find(e=>e.server===n.name),l=r&&r.state===`connected`&&c?{...r,state:`failed`,problem:Le(n,c)}:r,u=o&&!!a?.running&&!!l&&(l.state===`failed`||l.state===`needs-sign-in`),f=!u&&He(n,p.data??null);return(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 rounded-[18px] border border-line p-3.5`,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)(g,{name:n.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`code`,{className:`mono text-[14px] font-semibold`,children:n.name}),(0,Q.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,Q.jsx)(`span`,{className:`mt-1 block`,role:`status`,children:(0,Q.jsx)(Je,{live:a,running:o,state:l})})]}),n.on_injection&&(0,Q.jsx)(e,{children:be[n.on_injection].label}),(0,Q.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:n.name,draft:ct(n)})},children:`Edit`}),(0,Q.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,Q.jsx)(qe,{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:ct(n)})},onFixed:s,onAllowAddress:()=>ue(i(d,`/protection`,{server:t}))}),f&&(0,Q.jsx)(qe,{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:ct(n)}),onFixed:s,onAllowAddress:()=>void 0})]},n.name)})}),j&&(0,Q.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,Q.jsx)(le,{open:!!O,onClose:()=>k(null),tone:`danger`,title:`Remove ${O}?`,description:yn(u.find(e=>e.name===O)),footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{variant:`secondary`,onClick:()=>k(null),disabled:E,children:`Keep server`}),(0,Q.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 yn(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 bn(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)&&Fe(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,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-[14.5px] font-semibold`,children:[e,` `,(0,Q.jsx)(`code`,{className:`mono text-[11.5px] font-normal text-soft`,children:n})]}),(0,Q.jsx)(`div`,{className:`mt-1 text-[13px] text-soft`,children:t})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[r,(i||s)&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[s&&(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,onClick:s,disabled:o,children:`Use the default`}),i&&(0,Q.jsx)(P,{size:`sm`,variant:`primary`,onClick:i,disabled:!a,loading:o,children:`Save setting`})]})]})]})}function xn({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,Z.useState)(null),c=(t,r,i,a)=>(s(t),n((n,i)=>ve(e,t,r,n,i),i,a).finally(()=>s(null))),[l,u]=(0,Z.useState)(r.name),[d,m]=(0,Z.useState)(r.connect_timeout_ms/1e3),[h,_]=(0,Z.useState)(r.on_injection),[v,y]=(0,Z.useState)(Object.entries(r.injection_overrides)),[b,x]=(0,Z.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,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)($,{title:`Name`,technical:`name`,help:(0,Q.jsx)(Q.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,Q.jsx)(f,{value:l,onChange:u,mono:!0,"aria-label":`Toolbox name`})}),(0,Q.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,Q.jsx)(a,{value:d,onChange:m,min:1,unit:`seconds`,"aria-label":`Seconds to wait`})}),(0,Q.jsx)($,{title:(0,Q.jsxs)(Q.Fragment,{children:[`Hidden instructions in tool descriptions `,(0,Q.jsx)(w,{term:`HMCP005`})]}),technical:`on_injection`,help:be[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,Q.jsx)(I,{value:h,onChange:_,"aria-label":`Hidden instructions`,options:[`strip`,`deny`,`annotate`].map(e=>({value:e,label:be[e].label}))})}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v.map(([e,t],n)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.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,Q.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:be[e].label}))},`m${t}`)]),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`plus`,onClick:()=>y([...v,[``,`accept`]]),children:`Add a tool`})})]})}),(0,Q.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,Q.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,Q.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,Q.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,Q.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,Q.jsx)(a,{value:b,onChange:x,min:1,unit:`letters`,"aria-label":`Longest tool name`})}),(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`mt-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-[14.5px] font-semibold`,children:[(0,Q.jsx)(g,{name:`lock`,size:17}),` Settings the console can't change`]}),(0,Q.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,Q.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-[13.5px] sm:grid-cols-2`,children:[(0,Q.jsx)(Sn,{term:`Console may change protection rules`,technical:`policy_writes`,on:t.guarded.policy_writes}),(0,Q.jsx)(Sn,{term:`Console may reverse an existing decision`,technical:`policy_overrides`,on:t.guarded.policy_overrides})]})]})]})}function Sn({term:t,technical:n,on:r}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-2xl bg-surface px-3 py-2.5`,children:[(0,Q.jsxs)(`dt`,{children:[t,(0,Q.jsx)(`code`,{className:`mono block text-[11.5px] text-soft`,children:n})]}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(e,{tone:r?`ok`:`neutral`,children:r?`Allowed`:`Not allowed`})})]})}function Cn({id:e,file:t,write:n}){let[i,a]=(0,Z.useState)(t.text??``),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{a(t.text??``),s(null)},[t.digest]),t.text===null)return(0,Q.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,Q.jsx)(`span`,{className:`mt-2 block`,children:(0,Q.jsx)(q,{children:t.path})})]});let h=()=>{u(!0),m(null),_e(e,i).then(s).catch(e=>m(W(e))).finally(()=>u(!1))},g=()=>{f(!0),n((t,n)=>ye(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,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.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,Q.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,Q.jsx)(`span`,{className:`mt-1 block`,children:(0,Q.jsx)(q,{children:t.path})})]}),(0,Q.jsx)(ee,{value:i,onChange:e=>{a(e),s(null)},label:`Settings file`,rows:18,error:o&&!o.valid?o.error:null}),p&&(0,Q.jsx)(l,{tone:`danger`,role:`alert`,children:p}),v&&o.valid&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{children:`What changes`}),(0,Q.jsx)(j,{before:t.text??``,after:i,label:`Changes to the settings file`}),t.broken?(0,Q.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,Q.jsx)(l,{tone:`warn`,title:`This lets more through`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:o.loosens.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:()=>{a(t.text??``),s(null)},disabled:!_,children:`Undo my edits`}),v&&o.valid?(0,Q.jsx)(P,{variant:`primary`,icon:`check`,onClick:g,loading:d,children:t.broken?`Save repaired file`:`Save settings file`}):(0,Q.jsx)(P,{variant:`primary`,onClick:h,loading:c,disabled:!_,children:`Check changes`})]}),(0,Q.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 wn={ok:`bg-ok`,warn:`bg-warn`,bad:`bg-bad`,neutral:`bg-soft`};function Tn(){let{nav:e,servers:t,serverId:n,reload:r}=J(),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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(k,{title:`Connections`,subtitle:`The toolboxes that protect your AI apps, and the apps and servers they connect.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{href:s(e,{connect:`1`}),variant:`primary`,icon:`plug`,children:ht}),(0,Q.jsx)(T,{href:s(e,{add:`server`}),icon:`plus`,children:`Add a server`}),(0,Q.jsx)(T,{href:s(e,{add:`1`}),variant:`ghost`,icon:`shield`,children:`Create a toolbox`})]})}),t.length===0?(0,Q.jsx)(kn,{}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 lg:gap-5`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4 lg:gap-5`,children:[(0,Q.jsx)(te,{tone:`hero`,title:`Toolboxes`,value:u.length,sub:u.length?`${f} protecting · ${u.length-f} watch-only`:`None can be loaded`}),(0,Q.jsx)(te,{title:`Running now`,value:d,sub:d===u.length?`All of them`:`${u.length-d} not running`}),(0,Q.jsx)(te,{title:`Connected servers`,value:p,sub:`The servers your toolboxes hold`}),(0,Q.jsx)(te,{title:`Tools`,value:de(m),sub:`Offered to your AI apps`})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`gateways-h`,children:[(0,Q.jsx)(`h2`,{id:`gateways-h`,className:`sr-only`,children:`Toolboxes`}),(0,Q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 2xl:grid-cols-3 lg:gap-5`,children:t.map(e=>e.ok?(0,Q.jsx)(An,{server:e},e.id):(0,Q.jsx)(jn,{server:e},e.id))})]}),(0,Q.jsx)(cn,{}),(0,Q.jsx)(dn,{servers:t,serverId:n}),(0,Q.jsx)(Pn,{servers:t})]}),(0,Q.jsx)(On,{open:a.get(`connect`)===`1`,onClose:()=>o(`connect`)}),(0,Q.jsx)(xt,{open:a.get(`connect`)===`advanced`,onClose:()=>o(`connect`)}),(0,Q.jsx)(zt,{open:a.get(`add`)===`1`,onClose:()=>o(`add`)}),(0,Q.jsx)(Dn,{open:a.get(`add`)===`server`,gatewayId:En(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,Q.jsx)(gn,{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 En(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 Dn({open:e,gatewayId:t,onClose:n,onDone:r}){let{servers:i}=J(),a=i.find(e=>e.id===t)?.label;return(0,Q.jsx)(v,{open:e,onClose:()=>{ft(),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,Q.jsx)(ut,{gatewayId:t,onCancel:n,onDone:e=>r(e.upstreamName,e.created)})})}function On({open:e,onClose:t}){let{nav:n,reload:r}=J();return(0,Z.useEffect)(()=>{e||st()},[e]),(0,Q.jsx)(v,{open:e,onClose:()=>{st(),t()},title:ht,subtitle:gt,width:880,children:e&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(dt,{toolsHref:(e,t)=>i(n,`/tools`,{server:e,app:t}),protect:e=>({href:i(n,`/protection`,{server:e})}),addServer:{href:s(n,{connect:null,add:`server`})},onConnected:r,onUndone:r}),(0,Q.jsxs)(`details`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[14px] font-semibold select-none`,children:`Advanced`}),(0,Q.jsx)(`p`,{className:`mt-2 text-[13.5px] text-muted`,children:`For one project folder only, a different toolbox, Roo Code, or adding your toolbox to an app without moving its servers.`}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(T,{href:s(n,{connect:`advanced`}),size:`sm`,icon:`settings`,children:`Connect step by step`})})]})]})})}function kn(){let{nav:e}=J();return(0,Q.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.2fr_1fr] lg:gap-5`,children:[(0,Q.jsxs)(re,{tone:`hero`,className:`flex flex-col p-7 md:p-8`,children:[(0,Q.jsx)(`span`,{className:`grid h-12 w-12 place-items-center rounded-full bg-white/15`,children:(0,Q.jsx)(g,{name:`shield-check`,size:24})}),(0,Q.jsx)(`h2`,{className:`display mt-5 text-[30px] md:text-[36px]`,children:`Give your AI app its first tools`}),(0,Q.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,Q.jsxs)(`div`,{className:`mt-7 flex flex-wrap gap-2.5`,children:[(0,Q.jsx)(T,{href:`/start`,variant:`on-hero`,icon:`arrow-right`,children:`Start the guide`}),(0,Q.jsx)(T,{href:s(e,{connect:`1`}),variant:`on-hero`,icon:`plug`,className:`!bg-transparent !text-white ring-1 ring-white/50`,children:ht})]}),(0,Q.jsxs)(`p`,{className:`mt-4 text-[13px] text-on-hero-soft`,children:[`No servers in your app yet?`,` `,(0,Q.jsx)(`a`,{href:s(e,{add:`server`}),onClick:y,className:`font-semibold text-white underline underline-offset-2`,children:`Add a server`}),` `,`and your toolbox is made with it.`]})]}),(0,Q.jsx)(re,{title:`How it works`,children:(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4`,children:[[`Connect your AI app`,`Pick Claude Desktop, Claude Code, Codex, the ChatGPT desktop app, Cursor, VS Code or another app. The servers it already has move into your toolbox in one click. Restart the app once.`],[`Add a server`,`Want more tools? 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.`],[`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,Q.jsxs)(`li`,{className:`flex gap-3.5`,children:[(0,Q.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,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-medium`,children:e}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:t})]})]},e))})})]})}function An({server:t}){let{nav:n,reload:a}=J(),o=H(),c=B(()=>et(t.id),[t.id],15e3),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=c.data,h=m?pn(m):t.running?{label:`Running`,tone:`ok`}:{label:`Not running`,tone:`neutral`},_=E[t.enforcement??`enforce`],v=t.upstreams??[],b=!!m?.managed&&(m.state===`running`||m.state===`starting`),x=e=>s(n,{manage:t.id,tab:e}),S=Ie(t.id),C=Qe(t.id),D=Ye(S.data?.upstreams??[],!!S.data?.running,C.data??[]);return(0,Q.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-5 p-6`,children:[(0,Q.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(g,{name:`shield`,size:20})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label}),t.configPath&&(0,Q.jsx)(`p`,{className:`mono mt-1 truncate text-[12px] text-soft`,title:t.configPath,children:t.configPath})]}),(0,Q.jsx)(N,{icon:`trash`,label:`Remove ${t.label} from the console`,size:36,onClick:()=>p(!0)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(e,{tone:h.tone,icon:`power`,children:h.label}),(0,Q.jsx)(e,{tone:_.tone,icon:t.enforcement===`observe`?`eye`:`shield-check`,title:_.explain,children:_.label}),t.posture&&t.posture in V&&(0,Q.jsx)(e,{children:V[t.posture].label})]}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Q.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`Tools`}),(0,Q.jsx)(`dd`,{className:`display tnum text-[28px]`,children:t.toolCount??`–`})]}),(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Q.jsxs)(`dt`,{className:`text-[12.5px] text-soft`,children:[`Connected servers `,(0,Q.jsx)(w,{term:`connectedServer`})]}),(0,Q.jsx)(`dd`,{className:`display tnum text-[28px]`,children:v.length})]})]}),v.length>0&&(0,Q.jsx)(`ul`,{className:`-mt-2 flex flex-wrap gap-1.5`,"aria-label":`Its servers`,children:v.map(e=>{let n=S.data?.running?Ue(S.data,e):null,r=n?.state===`connected`&&(C.data??[]).some(t=>t.server===e),i=r?`bad`:n?Ce[n.state].tone:null;return(0,Q.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-full bg-sunken px-2.5 py-0.5 text-[12px]`,children:[i&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:U(`h-2 w-2 rounded-full`,wn[i])}),(0,Q.jsx)(`span`,{title:e,children:fe(e,t.displayNames)}),r?(0,Q.jsx)(`span`,{className:`text-muted`,children:`· calls failing`}):n&&n.state!==`connected`&&(0,Q.jsxs)(`span`,{className:`text-muted`,children:[`· `,Ce[n.state].label.toLowerCase()]}),n&&!r&&(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,Ce[n.state].label]})]},e)})}),D&&(0,Q.jsxs)(`p`,{className:U(`-mt-2 flex flex-wrap items-center gap-x-2 text-[13px] font-medium`,D.tone===`bad`?`text-bad`:D.tone===`warn`?`text-warn`:`text-ok`),children:[D.text,D.fix&&(0,Q.jsxs)(`a`,{href:x(`servers`),onClick:y,className:`underline underline-offset-2`,children:[`Fix `,D.fix]})]}),t.toolCount===null&&(0,Q.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:t.provisionalToolCount?`${r(t.provisionalToolCount,`tool`)} found when its servers were tested. They're counted for real once the toolbox has run.`:`Tools are counted once the toolbox has run.`}),t.tenantError&&(0,Q.jsx)(l,{tone:`warn`,children:K(Y(t.tenantError))}),m?.externallyRunning&&(0,Q.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:`An AI app runs this toolbox. Restarting the app restarts it.`}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Q.jsx)(T,{href:i(n,`/`,{server:t.id}),variant:`primary`,size:`sm`,iconRight:`arrow-right`,children:`Open`}),(0,Q.jsx)(T,{href:x(`servers`),size:`sm`,icon:`settings`,children:`Settings`}),b?(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`stop`,loading:u,onClick:()=>{d(!0),Ke(t.id).then(()=>{o.show(`ok`,`${t.label} stopped.`),c.reload(),a()}).catch(e=>o.show(`bad`,W(e))).finally(()=>d(!1))},children:`Stop toolbox`}):!m?.externallyRunning&&(0,Q.jsx)(T,{href:x(`run`),size:`sm`,variant:`ghost`,icon:`play`,children:`Start toolbox`})]}),(0,Q.jsx)(Mn,{server:f?t:null,onClose:()=>p(!1)})]})}function jn({server:t}){let{nav:n}=J(),[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-4 border-[1.5px] border-bad/40 p-6`,children:[(0,Q.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-bad-tint text-bad`,children:(0,Q.jsx)(g,{name:`warning`,size:20})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label}),t.configPath&&(0,Q.jsx)(`p`,{className:`mono mt-1 truncate text-[12px] text-soft`,title:t.configPath,children:t.configPath})]}),(0,Q.jsx)(e,{tone:`bad`,children:`Can't be loaded`})]}),(0,Q.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,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13px] break-words text-muted`,children:K(Y(t.error??`No reason was given.`))}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Q.jsx)(T,{href:s(n,{manage:t.id,tab:`file`}),size:`sm`,variant:`primary`,icon:`edit`,children:`Fix toolbox settings file`}),(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,icon:`trash`,onClick:()=>i(!0),children:`Remove from console`})]}),(0,Q.jsx)(Mn,{server:r?t:null,onClose:()=>i(!1)})]})}function Mn({server:e,onClose:t}){let{reload:n}=J(),r=H(),[i,a]=(0,Z.useState)(!1);return e?(0,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{variant:`secondary`,onClick:t,disabled:i,children:`Keep it`}),(0,Q.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,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[14px] text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.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,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.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,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.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 Nn={"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 Pn({servers:e}){let{nav:t}=J(),[n,r]=(0,Z.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,Q.jsx)(re,{title:`Recent activity across toolboxes`,actions:(0,Q.jsx)(h,{label:`Which activity`,size:`sm`,value:n,onChange:r,options:[{value:`noteworthy`,label:`Needs a look`},{value:`all`,label:`All`}]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u?.sharedPaths.map(e=>(0,Q.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,Q.jsxs)(l,{tone:`info`,children:[s(e.id),`'s activity couldn't be read: `,K(Y(e.error))]},e.id)),o.error&&!u?(0,Q.jsx)(l,{tone:`danger`,title:`Activity could not be loaded`,actions:(0,Q.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):o.loading&&!u?(0,Q.jsx)(c,{lines:5,height:18}):!u||u.records.length===0?(0,Q.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,Q.jsx)(`ul`,{className:`flex flex-col`,children:u.records.map(e=>(0,Q.jsx)(Fn,{record:e,gateway:s(e.serverId),href:i(t,`/activity`,{server:e.serverId??``,seq:String(e.seq)})},`${e.serverId}-${e.seq}-${e.id}`))})]})})}function Fn({record:t,gateway:n,href:r}){let i=t.tool.startsWith(`(`)||Nn[t.rule_id]!==void 0,a=i?Nn[t.rule_id]??`Console change`:Xe(t.tool).label;return(0,Q.jsx)(`li`,{className:`border-b border-faint last:border-b-0`,children:(0,Q.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,Q.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(g,{name:i?`settings`:`tool`,size:17})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-[14px] font-medium`,title:i?void 0:t.tool,children:a}),(0,Q.jsxs)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:[n,` · `,x(t.ts)]})]}),!i&&(0,Q.jsx)(`span`,{className:`shrink-0`,children:t.observe?(0,Q.jsxs)(e,{tone:`neutral`,title:`Watch-only: it ran anyway`,children:[`Would be: `,z(t.decision)]}):(0,Q.jsx)(A,{decision:t.decision})})]})})}export{Tn as ConnectionsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,A as t,D as n,Dt as r,E as i,G as a,H as o,It as s,K as c,M as ee,N as te,O as l,Ot as u,S as d,T as f,U as p,W as m,X as h,Z as g,_,b as v,c as y,d as b,et as x,f as S,g as C,gt as w,h as T,ht as E,k as D,kt as O,m as ne,mt as k,p as re,pt as A,q as j,u as M,w as N,x as P,y as F}from"./kit-
|
|
1
|
+
import{$ as e,A as t,D as n,Dt as r,E as i,G as a,H as o,It as s,K as c,M as ee,N as te,O as l,Ot as u,S as d,T as f,U as p,W as m,X as h,Z as g,_,b as v,c as y,d as b,et as x,f as S,g as C,gt as w,h as T,ht as E,k as D,kt as O,m as ne,mt as k,p as re,pt as A,q as j,u as M,w as N,x as P,y as F}from"./kit-BHB_ha4i.js";var I=s(),L=O();function R(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{title:`Component kit`,subtitle:`Every building block of the console, in both themes.`,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(E,{variant:`primary`,icon:`plus`,children:`Add rule`}),(0,L.jsx)(E,{children:`Run safety check`})]})}),(0,L.jsx)(G,{}),(0,L.jsxs)(`div`,{className:`mt-6 flex flex-col gap-8`,children:[(0,L.jsxs)(`div`,{className:`theme-light rounded-[28px] p-4 sm:p-6`,children:[(0,L.jsx)(`p`,{className:`eyebrow mb-4`,children:`Light`}),(0,L.jsx)(H,{})]}),(0,L.jsxs)(`div`,{className:`theme-dark rounded-[28px] p-4 sm:p-6`,children:[(0,L.jsx)(`p`,{className:`eyebrow mb-4`,children:`Dark`}),(0,L.jsx)(H,{})]})]})]})}var z=`version: 1
|
|
2
2
|
defaults:
|
|
3
3
|
mode: approve-writes
|
|
4
4
|
on_unclassified: deny
|
|
@@ -11,7 +11,7 @@ audit:
|
|
|
11
11
|
hash_chain: true`,B=z.replace(`on_unclassified: deny`,`on_unclassified: approve`).replace(` decision: allow`,` decision: allow
|
|
12
12
|
- id: no-deletes
|
|
13
13
|
match: { tool: "fs.delete_*" }
|
|
14
|
-
decision: deny`),V=[{label:`Mon`,allow:30,approve:4,deny:2},{label:`Tue`,allow:52,approve:9,deny:5},{label:`Wed`,allow:41,approve:3,deny:1},{label:`Thu`},{label:`Fri`,allow:64,approve:12,deny:7},{label:`Sat`,allow:12,approve:1,deny:0},{label:`Sun`}];function H(){let[s,d]=(0,I.useState)(`all`),[v,y]=(0,I.useState)(`24h`),[O,P]=(0,I.useState)(`Nightly cleanup job`),[F,R]=(0,I.useState)(25),[H,G]=(0,I.useState)(`approve`),[K,q]=(0,I.useState)(!0),[J,Y]=(0,I.useState)(!1),[ie,X]=(0,I.useState)([`api.github.com`,`*.example.com`]),[ae,oe]=(0,I.useState)(3600),[Z,se]=(0,I.useState)(z),[Q,$]=(0,I.useState)(1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(U,{title:`Stat cards`,children:(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,L.jsx)(k,{tone:`hero`,title:`Allowed`,value:`1,284`,delta:5,sub:`More than last week`,href:`#`}),(0,L.jsx)(k,{title:`Waiting`,value:`3`,sub:`Oldest 4 min ago`,href:`#`}),(0,L.jsx)(k,{title:`Blocked`,value:`27`,delta:-2,sub:`Fewer than last week`,href:`#`}),(0,L.jsx)(k,{title:`Tools protected`,value:`18`,sub:`2 not labelled yet`,href:`#`,loading:!0})]})}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.4fr_1fr]`,children:[(0,L.jsx)(A,{title:`Calls this week`,actions:(0,L.jsx)(l,{label:`Time range`,size:`sm`,value:v,onChange:y,options:[{value:`1h`,label:`1h`},{value:`24h`,label:`24h`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}]}),children:(0,L.jsx)(T,{data:V,label:`Calls per day, by decision`})}),(0,L.jsx)(A,{title:`How your tools are set`,children:(0,L.jsx)(C,{label:`11 run freely, 5 ask first, 2 blocked`,center:`61%`,caption:`Run freely`,segments:[{label:`Runs freely`,value:11,mark:`allow`},{label:`Asks you first`,value:5,mark:`approve`},{label:`Blocked`,value:2,mark:`deny`}]})})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,L.jsx)(A,{title:`Busiest tools`,children:(0,L.jsx)(T,{mode:`single`,height:140,label:`Calls per tool`,data:[{label:`read`,value:40},{label:`list`,value:22},{label:`write`,value:31},{label:`move`,value:0},{label:`del`,value:6}]})}),(0,L.jsxs)(A,{title:`Tools`,actions:(0,L.jsx)(E,{size:`sm`,icon:`plus`,children:`Add rule`}),children:[(0,L.jsx)(m,{icon:`eye`,iconTone:`ok`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.read_file`}),sub:`Looks only · Runs freely`,trailing:(0,L.jsx)(x,{decision:`allow`}),href:`#`}),(0,L.jsx)(m,{icon:`edit`,iconTone:`warn`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.write_file`}),sub:`Makes changes · Asks you first`,trailing:(0,L.jsx)(x,{decision:`approve`}),href:`#`}),(0,L.jsx)(m,{icon:`trash`,iconTone:`bad`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.delete_tree`}),sub:`Deletes · Blocked`,trailing:(0,L.jsx)(x,{decision:`deny`}),href:`#`})]}),(0,L.jsxs)(A,{tone:`hero`,title:`Toolbox status`,children:[(0,L.jsx)(`p`,{className:`display text-[34px]`,children:`Running`}),(0,L.jsx)(`p`,{className:`mt-1 text-[13px] text-on-hero-soft`,children:`Protecting · log intact · 0 changed tools`}),(0,L.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,L.jsx)(w,{icon:`pause`,label:`Stop
|
|
14
|
+
decision: deny`),V=[{label:`Mon`,allow:30,approve:4,deny:2},{label:`Tue`,allow:52,approve:9,deny:5},{label:`Wed`,allow:41,approve:3,deny:1},{label:`Thu`},{label:`Fri`,allow:64,approve:12,deny:7},{label:`Sat`,allow:12,approve:1,deny:0},{label:`Sun`}];function H(){let[s,d]=(0,I.useState)(`all`),[v,y]=(0,I.useState)(`24h`),[O,P]=(0,I.useState)(`Nightly cleanup job`),[F,R]=(0,I.useState)(25),[H,G]=(0,I.useState)(`approve`),[K,q]=(0,I.useState)(!0),[J,Y]=(0,I.useState)(!1),[ie,X]=(0,I.useState)([`api.github.com`,`*.example.com`]),[ae,oe]=(0,I.useState)(3600),[Z,se]=(0,I.useState)(z),[Q,$]=(0,I.useState)(1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(U,{title:`Stat cards`,children:(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,L.jsx)(k,{tone:`hero`,title:`Allowed`,value:`1,284`,delta:5,sub:`More than last week`,href:`#`}),(0,L.jsx)(k,{title:`Waiting`,value:`3`,sub:`Oldest 4 min ago`,href:`#`}),(0,L.jsx)(k,{title:`Blocked`,value:`27`,delta:-2,sub:`Fewer than last week`,href:`#`}),(0,L.jsx)(k,{title:`Tools protected`,value:`18`,sub:`2 not labelled yet`,href:`#`,loading:!0})]})}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.4fr_1fr]`,children:[(0,L.jsx)(A,{title:`Calls this week`,actions:(0,L.jsx)(l,{label:`Time range`,size:`sm`,value:v,onChange:y,options:[{value:`1h`,label:`1h`},{value:`24h`,label:`24h`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}]}),children:(0,L.jsx)(T,{data:V,label:`Calls per day, by decision`})}),(0,L.jsx)(A,{title:`How your tools are set`,children:(0,L.jsx)(C,{label:`11 run freely, 5 ask first, 2 blocked`,center:`61%`,caption:`Run freely`,segments:[{label:`Runs freely`,value:11,mark:`allow`},{label:`Asks you first`,value:5,mark:`approve`},{label:`Blocked`,value:2,mark:`deny`}]})})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,L.jsx)(A,{title:`Busiest tools`,children:(0,L.jsx)(T,{mode:`single`,height:140,label:`Calls per tool`,data:[{label:`read`,value:40},{label:`list`,value:22},{label:`write`,value:31},{label:`move`,value:0},{label:`del`,value:6}]})}),(0,L.jsxs)(A,{title:`Tools`,actions:(0,L.jsx)(E,{size:`sm`,icon:`plus`,children:`Add rule`}),children:[(0,L.jsx)(m,{icon:`eye`,iconTone:`ok`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.read_file`}),sub:`Looks only · Runs freely`,trailing:(0,L.jsx)(x,{decision:`allow`}),href:`#`}),(0,L.jsx)(m,{icon:`edit`,iconTone:`warn`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.write_file`}),sub:`Makes changes · Asks you first`,trailing:(0,L.jsx)(x,{decision:`approve`}),href:`#`}),(0,L.jsx)(m,{icon:`trash`,iconTone:`bad`,title:(0,L.jsx)(`span`,{className:`font-mono text-[13.5px]`,children:`fs.delete_tree`}),sub:`Deletes · Blocked`,trailing:(0,L.jsx)(x,{decision:`deny`}),href:`#`})]}),(0,L.jsxs)(A,{tone:`hero`,title:`Toolbox status`,children:[(0,L.jsx)(`p`,{className:`display text-[34px]`,children:`Running`}),(0,L.jsx)(`p`,{className:`mt-1 text-[13px] text-on-hero-soft`,children:`Protecting · log intact · 0 changed tools`}),(0,L.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,L.jsx)(w,{icon:`pause`,label:`Stop toolbox`,variant:`hero`}),(0,L.jsx)(w,{icon:`refresh`,label:`Restart toolbox`,variant:`hero`})]})]})]}),(0,L.jsx)(U,{title:`Buttons`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(E,{variant:`primary`,icon:`check`,children:`Approve call`}),(0,L.jsx)(E,{variant:`secondary`,children:`Run safety check`}),(0,L.jsx)(E,{variant:`ghost`,icon:`filter`,children:`Filter list`}),(0,L.jsx)(E,{variant:`danger`,icon:`power`,children:`Turn off tool`}),(0,L.jsx)(E,{variant:`primary`,loading:!0,children:`Saving setting`}),(0,L.jsx)(E,{size:`sm`,children:`Small`}),(0,L.jsx)(E,{size:`lg`,variant:`primary`,children:`Large`}),(0,L.jsx)(E,{disabled:!0,children:`Disabled`}),(0,L.jsx)(w,{icon:`arrow-up-right`,label:`Open`,variant:`outline`}),(0,L.jsx)(w,{icon:`bell`,label:`Waiting`,variant:`soft`,badge:3}),(0,L.jsx)(w,{icon:`settings`,label:`Settings`})]})}),(0,L.jsx)(U,{title:`Pills, effects and badges`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(x,{decision:`allow`}),(0,L.jsx)(x,{decision:`approve`}),(0,L.jsx)(x,{decision:`deny`}),(0,L.jsx)(e,{children:`Not labelled yet`}),(0,L.jsx)(e,{tone:`ok`,icon:`check`,children:`Log intact`}),(0,L.jsx)(g,{effect:`read`,withLabel:!0}),(0,L.jsx)(g,{effect:`write`,withLabel:!0}),(0,L.jsx)(g,{effect:`destructive`,withLabel:!0}),(0,L.jsx)(g,{effect:null,withLabel:!0}),(0,L.jsx)(h,{count:12}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[14px]`,children:[`Pre-approval `,(0,L.jsx)(_,{term:`preApproval`})]}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[14px]`,children:[`HMCP005 `,(0,L.jsx)(_,{term:`HMCP005`})]})]})}),(0,L.jsx)(U,{title:`Banners`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(o,{tone:`info`,title:`Restart needed`,children:`The toolbox reads this setting when it starts.`}),(0,L.jsx)(o,{tone:`warn`,title:`Toolbox not running`,actions:(0,L.jsx)(E,{size:`sm`,children:`Start toolbox`}),children:`Tool switches need a running toolbox.`}),(0,L.jsx)(o,{tone:`danger`,title:`Watch-only mode. Nothing is being blocked.`,actions:(0,L.jsx)(E,{size:`sm`,variant:`primary`,children:`Start protecting`})}),(0,L.jsx)(o,{tone:`ok`,title:`Log intact`,children:`1,402 entries checked.`})]})}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsxs)(A,{title:`Tabs and table`,actions:(0,L.jsx)(W,{}),children:[(0,L.jsx)(j,{label:`Tool filter`,value:s,onChange:d,items:[{id:`all`,label:`All`,count:18},{id:`read`,label:`Looks only`,count:11},{id:`write`,label:`Makes changes`,count:7}]}),(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(c,{caption:`Tools`,rowKey:e=>e.name,onRowClick:()=>void 0,rows:[{name:`fs.read_file`,effect:`read`,d:`allow`,n:412},{name:`fs.write_file`,effect:`write`,d:`approve`,n:37},{name:`fs.delete_tree`,effect:`destructive`,d:`deny`,n:2}],columns:[{key:`name`,header:`Tool`,cell:e=>(0,L.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name})},{key:`effect`,header:`Does`,cell:e=>(0,L.jsx)(g,{effect:e.effect,withLabel:!0})},{key:`d`,header:`Decision`,cell:e=>(0,L.jsx)(x,{decision:e.d})},{key:`n`,header:`Calls`,align:`right`,cell:e=>(0,L.jsx)(`span`,{className:`tnum`,children:e.n})}]})})]}),(0,L.jsxs)(A,{title:`Empty and loading`,children:[(0,L.jsx)(p,{icon:`inbox`,title:`Nothing waiting for you`,compact:!0,actions:(0,L.jsx)(E,{size:`sm`,children:`See history`}),children:`Calls that ask first will show up here.`}),(0,L.jsx)(a,{lines:3})]})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(A,{title:`Form fields`,children:(0,L.jsxs)(`div`,{className:`grid gap-5`,children:[(0,L.jsx)(i,{label:`Reason`,help:`Shown in the activity log.`,technical:`reason`,children:(0,L.jsx)(ee,{value:O,onChange:P})}),(0,L.jsx)(i,{label:`Max results`,error:F!==null&&F>100?`Use 100 or fewer.`:null,children:(0,L.jsx)(n,{value:F,onChange:R,unit:`items`})}),(0,L.jsx)(i,{label:`Tools not labelled yet`,technical:`defaults.on_unclassified`,children:(0,L.jsx)(D,{value:H,onChange:G,options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,L.jsx)(i,{label:`Allowed hosts`,help:`Press Enter after each one.`,children:(0,L.jsx)(t,{value:ie,onChange:X})}),(0,L.jsx)(i,{label:`Pre-approve for`,children:(0,L.jsx)(f,{value:ae,onChange:oe,max:604800})}),(0,L.jsx)(te,{checked:K,onChange:q,label:`Record call inputs`,description:`Secrets are hidden before writing.`}),(0,L.jsx)(N,{checked:J,onChange:Y,label:`Only problems`,description:`Hide calls that ran normally.`})]})}),(0,L.jsx)(A,{title:`Wizard`,children:(0,L.jsx)(M,{steps:[`Choose apps`,`Review plan`,`Options`,`Done`],step:Q,onStep:$,finishLabel:`Connect apps`,onFinish:()=>$(0),children:(0,L.jsxs)(`p`,{className:`text-[14px] text-muted`,children:[`Step `,Q+1,` body goes here.`]})})})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(A,{title:`Policy file`,children:(0,L.jsx)(ne,{label:`Policy file`,value:Z,onChange:se,rows:12})}),(0,L.jsx)(A,{title:`Changes`,children:(0,L.jsx)(S,{before:z,after:Z===z?B:Z,context:2})})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(A,{title:`Code block`,children:(0,L.jsx)(b,{copy:!0,children:`{
|
|
15
15
|
"path": "/home/me/notes.txt",
|
|
16
16
|
"token": "[redacted:secret]"
|
|
17
|
-
}`})}),(0,L.jsx)(A,{title:`
|
|
17
|
+
}`})}),(0,L.jsx)(A,{title:`Toolbox log`,children:(0,L.jsx)(re,{height:200,lines:Array.from({length:30},(e,t)=>`12:0${t%10}:1${t%6} gateway: tools/call fs.read_file allow (${t})`)})})]}),(0,L.jsx)(U,{title:`Icons`,children:(0,L.jsx)(`div`,{className:`flex flex-wrap gap-3 text-muted`,children:r.map(e=>(0,L.jsx)(`span`,{title:e,className:`grid h-11 w-11 place-items-center rounded-xl bg-surface`,children:(0,L.jsx)(u,{name:e,size:22})},e))})})]})}function U({title:e,children:t}){return(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h2`,{className:`mb-3 text-[15px] font-semibold text-muted`,children:e}),t]})}function W(){let e=F();return(0,L.jsx)(E,{size:`sm`,onClick:()=>e.show(`ok`,`Tool turned off. Your AI apps can no longer call it.`),children:`Show toast`})}function G(){let[e,t]=(0,I.useState)(!1),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(E,{onClick:()=>t(!0),icon:`arrow-left`,children:`Open drawer`}),(0,L.jsx)(E,{onClick:()=>r(!0),children:`Open dialog`}),(0,L.jsx)(E,{variant:`danger`,onClick:()=>a(!0),children:`Switch to watch-only`}),(0,L.jsx)(d,{open:e,onClose:()=>t(!1),title:(0,L.jsx)(`span`,{className:`font-mono`,children:`fs.write_file`}),subtitle:`Makes changes · from filesystem`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(E,{variant:`ghost`,onClick:()=>t(!1),children:`Close panel`}),(0,L.jsx)(E,{variant:`danger`,icon:`power`,children:`Turn off tool`})]}),children:(0,L.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Writes a file inside the allowed folders.`})}),(0,L.jsx)(P,{open:n,onClose:()=>r(!1),title:`Ask before this tool runs?`,description:`Every call to fs.write_file will wait for you.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(E,{onClick:()=>r(!1),children:`Cancel`}),(0,L.jsx)(E,{variant:`primary`,onClick:()=>r(!1),children:`Save rule`})]})}),(0,L.jsx)(v,{open:i,onCancel:()=>a(!1),onConfirm:()=>a(!1),title:`Switch to watch-only?`,confirmLabel:`Switch to watch-only`,consequences:[`Blocked calls will run.`,`Nothing will wait for your approval.`],children:`Your rules stay in place but stop being applied. The activity log keeps noting what would have happened.`})]})}export{R as Gallery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,D as r,E as i,G as a,H as o,I as s,It as c,K as l,L as u,M as d,Nt as ee,O as te,Pt as f,S as p,T as ne,U as m,V as h,Z as g,_,bt as re,c as v,gt as y,ht as b,j as ie,k as x,kt as S,mt as C,pt as w,rt as T,s as E,w as D,x as O,y as k}from"./kit-DRVm92_t.js";import{c as A,i as j,l as M,o as N,s as P,un as F}from"./index-CTvq_isK.js";var I=c(),L=S(),R=[{value:`max`,label:`is at most`},{value:`min`,label:`is at least`},{value:`enum`,label:`is one of`},{value:`maxLength`,label:`has at most N characters`},{value:`maxItems`,label:`has at most N items`},{value:`within`,label:`is a path inside the folder`},{value:`host`,label:`is a web address on`}],z=(e=``)=>({arg:e,kind:`max`,value:``,values:[]});function B(e,t){if(t===`number`||t===`integer`){let t=Number(e);return Number.isFinite(t)?t:e}if(t===`boolean`)return e===`true`||e!==`false`&&e;if(t===`string`)return e;if(e===`true`||e===`false`)return e===`true`;let n=Number(e);return e.trim()!==``&&Number.isFinite(n)?n:e}function V(e,t={}){let n={};for(let r of e){let e=r.arg.trim();if(!e)return{constraints:n,error:`Each limit needs the name of an input.`};let i=n[e]??={},a=Number(r.value),o=r.value.trim()!==``&&Number.isFinite(a);switch(r.kind){case`max`:case`min`:if(!o)return{constraints:n,error:`Give a number for the limit on ${e}.`};i[r.kind]=a;break;case`maxLength`:case`maxItems`:if(!o||!Number.isInteger(a)||a<+(r.kind===`maxLength`))return{constraints:n,error:`Give a whole number for the limit on ${e}.`};i[r.kind]=a;break;case`enum`:if(r.values.length===0)return{constraints:n,error:`List at least one allowed value for ${e}.`};i.enum=r.values.map(n=>B(n,t[e]));break;case`within`:if(!/^(\/|[a-zA-Z]:[\\/])/.test(r.value.trim()))return{constraints:n,error:`The folder for ${e} must be a full path, starting with /.`};i.within=r.value.trim();break;case`host`:if(r.values.length===0)return{constraints:n,error:`List at least one website for ${e}.`};i.host=r.values}}return{constraints:n,error:null}}function H({rows:e,onChange:n,argNames:r,disabled:i}){let a=(t,r)=>n(e.map((e,n)=>n===t?{...e,...r}:e));return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[e.map((o,s)=>(0,L.jsxs)(`div`,{className:`grid gap-2 rounded-2xl border border-line p-3 sm:grid-cols-[minmax(0,9rem)_minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-start`,children:[r&&r.length>0?(0,L.jsx)(x,{"aria-label":`Input for limit ${s+1}`,value:o.arg,onChange:e=>a(s,{arg:e}),disabled:i,options:[{value:``,label:`Choose input`},...r.map(e=>({value:e,label:e}))]}):(0,L.jsx)(d,{"aria-label":`Input for limit ${s+1}`,value:o.arg,onChange:e=>a(s,{arg:e}),placeholder:`input name`,mono:!0,disabled:i}),(0,L.jsx)(x,{"aria-label":`Kind of limit ${s+1}`,value:o.kind,onChange:e=>a(s,{kind:e}),options:R,disabled:i}),o.kind===`enum`||o.kind===`host`?(0,L.jsx)(t,{"aria-label":`Allowed values for limit ${s+1}`,value:o.values,onChange:e=>a(s,{values:e}),placeholder:o.kind===`host`?`example.com, then Enter`:`a value, then Enter`,disabled:i}):(0,L.jsx)(d,{"aria-label":`Value for limit ${s+1}`,value:o.value,onChange:e=>a(s,{value:e}),placeholder:o.kind===`within`?`/home/me/projects`:`a number`,mono:o.kind===`within`,disabled:i}),(0,L.jsx)(y,{icon:`trash`,label:`Remove limit ${s+1}`,size:40,onClick:()=>n(e.filter((e,t)=>t!==s)),disabled:i})]},s)),(0,L.jsx)(b,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>n([...e,z(r?.length===1?r[0]:``)]),disabled:i,children:`Add input limit`})]})}var U=`__pattern__`;function W(e){let t;return/matches a family of tools/.test(e)?{uses:`A pattern covers several tools, so it also needs a use limit or an input limit.`}:(t=/may not last longer than (\d+) days/.exec(e))?{ttl:`The longest a pre-approval can last is ${t[1]} days.`}:/expires_at is in the past/.test(e)?{ttl:`Choose how long it should last.`}:/unclosed brace/.test(e)?{tool:`This pattern has a { without a matching }.`}:(t=/constraint "(.+?)" is not a usable argument path/.exec(e))?{limits:`"${t[1]}" is not an input name that can be checked.`}:/within must be an absolute path/.test(e)?{limits:`A folder must be a full path, starting with /.`}:/"reason"/.test(e)?{reason:`Say why you are adding this. It is kept in the activity log.`}:/"tool_match"/.test(e)?{tool:`Choose a tool, or type a pattern.`}:/"max_uses"/.test(e)?{uses:`Use a whole number of 1 or more, or choose no limit.`}:{general:N(e)}}function G({open:e,onClose:t,serverId:n,tenant:s,tools:c,ttlMax:l,onCreated:te}){let[m,h]=(0,I.useState)(``),[g,v]=(0,I.useState)(``),[y,S]=(0,I.useState)(``),[C,w]=(0,I.useState)([]),[E,O]=(0,I.useState)(3600),[k,A]=(0,I.useState)(20),[j,M]=(0,I.useState)(!1),[F,R]=(0,I.useState)(``),[z,B]=(0,I.useState)(!1),[G,K]=(0,I.useState)({}),[q,J]=(0,I.useState)(!1);(0,I.useEffect)(()=>{e&&(h(``),v(``),S(``),w([]),O(3600),A(20),M(!1),R(``),B(!1),K({}))},[e]);let Y=m===U,X=(Y?g:m).trim(),Z=Y?void 0:c?.find(e=>e.name===m),Q=V(C,(0,I.useMemo)(()=>Object.fromEntries((Z?.args??[]).map(e=>[e.name,e.type??``])),[Z])),oe={tool_match:X,effect:y||null,constraints:Q.constraints,ttl_seconds:E??0,max_uses:j?null:k},se=JSON.stringify(oe),ce=re(se,250),[$,le]=(0,I.useState)(null),[ue,de]=(0,I.useState)(null),[fe,pe]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!e)return;let t=JSON.parse(ce);if(!t.tool_match||Q.error||!t.ttl_seconds){le(null),de(null);return}let r=!0;return pe(!0),f.previewGrant(n,{...t,reason:`preview`},s).then(e=>{r&&(le(e),de(null))}).catch(e=>{if(!r)return;le(null);let t=W(e.message);de(Object.values(t)[0]??N(e.message))}).finally(()=>r&&pe(!1)),()=>{r=!1}},[ce,e,n,s]);let me=$?.tools.filter(e=>e.covers)??[],he=y===`destructive`||me.some(e=>e.effect===`destructive`)||Z?.effect===`destructive`;async function ge(){let e={};if(X||(e.tool=Y?`Type a pattern.`:`Choose a tool.`),E===null?e.ttl=`Choose how long it should last.`:l!==void 0&&E>l&&(e.ttl=`The longest a pre-approval can last is ${u(l)}.`),!j&&(k===null||k<1||!Number.isInteger(k))&&(e.uses=`Use a whole number of 1 or more, or choose no limit.`),Q.error&&(e.limits=Q.error),F.trim()||(e.reason=`Say why you are adding this. It is kept in the activity log.`),K(e),!(Object.keys(e).length>0)){J(!0);try{te(await f.createGrant(n,{...oe,reason:F.trim()},s))}catch(e){K(e instanceof ee&&e.status===422?W(e.message):{general:N(e.message)})}finally{J(!1)}}}let _e=[{value:``,label:c===null?`Loading tools…`:`Choose a tool`},...(c??[]).map(e=>({value:e.name,label:`${P(e.name).label} · ${e.name}`})),{value:U,label:`Several tools, by pattern…`}];return(0,L.jsx)(p,{open:e,onClose:()=>!q&&t(),width:640,title:`Add pre-approval`,subtitle:`Let a kind of call run without asking you, for a limited time.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{variant:`ghost`,onClick:t,disabled:q,children:`Cancel`}),(0,L.jsx)(b,{variant:`primary`,icon:`check`,loading:q,disabled:he&&!z,onClick:ge,children:`Save pre-approval`})]}),children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(i,{label:`Which tool`,error:G.tool,children:(0,L.jsx)(x,{value:m,onChange:h,options:_e})}),Y&&(0,L.jsx)(i,{label:`Tool pattern`,error:G.tool,help:`Use * for any run of characters. For example notes__* covers every tool from the notes server. A pattern also needs a use limit or an input limit.`,children:(0,L.jsx)(d,{value:g,onChange:v,placeholder:`notes__create_*`,mono:!0,autoFocus:!0})}),(0,L.jsx)(i,{label:`Only when the tool`,help:`Leave this on any to go by what each tool does already.`,children:(0,L.jsx)(x,{value:y,onChange:S,options:[{value:``,label:`Any`},{value:`read`,label:T.read.label},{value:`write`,label:T.write.label},{value:`destructive`,label:T.destructive.label}]})}),(0,L.jsx)(i,{label:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Input limits `,(0,L.jsx)(_,{term:`limits`})]}),optional:!0,error:G.limits,help:`Calls covered by this must stay inside every limit you add.`,children:(0,L.jsx)(H,{rows:C,onChange:w,argNames:Z?Z.args.map(e=>e.name):null,disabled:q})}),(0,L.jsx)(i,{label:`For how long`,error:G.ttl,help:l?`Up to ${u(l)}.`:void 0,children:(0,L.jsx)(ne,{value:E,onChange:O,label:`For how long`,max:l})}),(0,L.jsx)(i,{label:`Up to how many calls`,error:G.uses,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,L.jsx)(r,{value:j?null:k,onChange:A,min:1,step:1,unit:`calls`,disabled:j,className:`w-40`}),(0,L.jsx)(D,{checked:j,onChange:M,label:`No limit`})]})}),(0,L.jsx)(i,{label:`Reason`,error:G.reason,help:`Kept in the activity log with your name.`,children:(0,L.jsx)(ie,{value:F,onChange:R,rows:2,placeholder:`For example: tidying notes this week, agreed with the team`})}),(0,L.jsxs)(`section`,{"aria-live":`polite`,className:`space-y-3 rounded-2xl bg-sunken/70 p-4`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:`What this would cover`}),X?Q.error?(0,L.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`Finish the input limits to see what this would cover.`}):ue?(0,L.jsx)(`p`,{className:`text-[13.5px] text-warn`,children:ue}):$?(0,L.jsx)(ae,{preview:$,covered:me,byPattern:Y}):fe&&(0,L.jsx)(a,{lines:3}):(0,L.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`Choose a tool to see which calls this would let through.`})]}),he&&(0,L.jsxs)(`div`,{className:`space-y-3 rounded-2xl bg-bad-tint p-4`,children:[(0,L.jsx)(`p`,{className:`text-[13.5px]`,children:`This covers a tool that deletes. Calls to it would run without asking you, within the limits above.`}),(0,L.jsx)(D,{checked:z,onChange:B,label:`I understand deletes will run without asking.`})]}),G.general&&(0,L.jsx)(o,{tone:`danger`,title:`The pre-approval was not saved`,role:`alert`,children:G.general})]})})}function ae({preview:e,covered:t,byPattern:r}){if(!e.surfaceKnown)return(0,L.jsxs)(`p`,{className:`text-[13.5px] text-warn`,children:[`Can't tell which tools this covers right now.`,` `,e.surfaceUnknownWhy?N(e.surfaceUnknownWhy):`The toolbox has not reported its tools.`]});let i=e.tools.length-t.length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:t.length===0?`This covers none of the tools this toolbox has right now.`:`It covers ${n(t.length,`tool`)} until ${A(e.expiresAt)}.`}),t.length>0&&(0,L.jsx)(`ul`,{className:`space-y-2.5`,children:t.map(e=>(0,L.jsxs)(`li`,{className:`rounded-xl bg-surface px-3 py-2.5`,children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,L.jsx)(g,{effect:e.effect}),(0,L.jsx)(`span`,{className:`text-[14px] font-medium`,children:P(e.name).label}),(0,L.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.name})]}),e.heldBounds.length>0&&(0,L.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Calls that break your rule's limit on `,e.heldBounds.join(`, `),` still ask you. Add a limit for`,` `,e.heldBounds.length===1?`it`:`them`,` here to cover those too.`]}),e.unknownArgsHeld&&(0,L.jsx)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:`Calls that send an input your rule does not mention still ask you.`})]},e.name))}),(0,L.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[i>0&&`${n(i,`other tool`)} ${i===1?`is`:`are`} not covered. `,r&&`A tool added later that fits the pattern would be covered too. `,`It never lets through anything your rules block.`]})]})}var K={active:{label:`Active`,tone:`ok`},expired:{label:`Expired`,tone:`neutral`},exhausted:{label:`Used up`,tone:`neutral`},revoked:{label:`Revoked`,tone:`bad`}};function q(){let{serverId:t,tenant:n,nav:r,reload:i}=F(),c=k(),u=M(3e4),d=r.query.get(`grant`)??r.query.get(`id`),[p,ne]=(0,I.useState)(r.query.get(`id`)?`all`:`active`),_=E(()=>f.grants(t,n,{state:p}),[t,n,p],15e3),re=E(()=>f.tools(t,n),[t,n]),y=E(()=>f.redaction(),[]),[ie,x]=(0,I.useState)(!1),[S,T]=(0,I.useState)(null),[D,R]=(0,I.useState)(!1),[z,B]=(0,I.useState)(null),V=_.data??[],H=V.filter(e=>e.state===`active`&&e.expiresAt>u),U=H.reduce((e,t)=>e+t.uses,0),W=H.reduce((e,t)=>e===null||t.expiresAt<e?t.expiresAt:e,null);async function ae(){if(S){R(!0),B(null);try{let e=await f.revokeGrant(t,S.id,n);e.warning?c.show(`warn`,`Revoked, but ${N(e.warning).replace(/^The grant was revoked but /i,``)}`):c.show(`ok`,`Pre-approval revoked. Calls it covered will ask you again.`),T(null),_.reload(),i()}catch(e){e instanceof ee&&(e.status===409||e.status===404)?(c.show(`warn`,`This pre-approval had already ended.`),T(null),_.reload()):B(N(e.message))}finally{R(!1)}}}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(v,{title:`Pre-approvals`,subtitle:`Let a kind of call run without asking you, until a time or a number of uses runs out. A pre-approval can never allow something your rules block.`,actions:(0,L.jsx)(b,{variant:`primary`,icon:`plus`,onClick:()=>x(!0),children:`Add pre-approval`})}),(0,L.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,L.jsx)(C,{tone:`hero`,title:`Active now`,value:H.length,loading:_.data===null&&!_.error,sub:H.length?`Each one ends by itself`:`Every held call asks you`}),(0,L.jsx)(C,{title:`Calls let through`,value:U,loading:_.data===null&&!_.error,sub:`By the active pre-approvals so far`}),(0,L.jsx)(C,{title:`Ends soonest`,value:W===null?`None`:h(W,u),loading:_.data===null&&!_.error,sub:W===null?`Nothing is active`:`At ${A(W)}`})]}),(0,L.jsxs)(w,{className:`mt-6`,title:`Your pre-approvals`,actions:(0,L.jsx)(te,{label:`Show`,size:`sm`,value:p,onChange:ne,options:[{value:`active`,label:`Active`},{value:`all`,label:`All`}]}),children:[_.error&&(0,L.jsx)(`div`,{className:`mb-4`,children:(0,L.jsx)(o,{tone:`danger`,title:`Could not load pre-approvals`,actions:(0,L.jsx)(b,{size:`sm`,icon:`refresh`,onClick:_.reload,children:`Try again`}),children:N(_.error)})}),_.data===null?!_.error&&(0,L.jsx)(a,{lines:4,height:20}):(0,L.jsx)(l,{caption:`Pre-approvals`,columns:[{key:`tools`,header:`Which tools`,width:`w-[15rem]`,cell:e=>{let t=/[*?{]/.test(e.toolMatch);return(0,L.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,L.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,L.jsx)(g,{effect:e.effect})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:t?`Tools matching a pattern`:P(e.toolMatch).label}),(0,L.jsx)(`code`,{className:`mono block text-[12px] break-all text-soft`,children:e.toolMatch}),e.effect&&(0,L.jsxs)(`span`,{className:`block text-[12px] text-soft`,children:[`Only tools that: `,J[e.effect]??e.effect]})]})]})}},{key:`limits`,header:`Limits`,cell:e=>{let t=j(e.constraints);return e.olderVersion&&t.length===0?(0,L.jsx)(`span`,{className:`text-soft`,children:`Only a call with no inputs at all`}):t.length===0?(0,L.jsx)(`span`,{className:`text-soft`,children:`No input limits`}):(0,L.jsx)(`ul`,{className:`space-y-0.5 text-[13px]`,children:t.map(([e,t])=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`code`,{className:`mono text-[12px]`,children:e}),` `,t]},e))})}},{key:`uses`,header:`Uses`,cell:e=>(0,L.jsx)(Y,{grant:e})},{key:`expires`,header:`Expires`,cell:e=>(0,L.jsxs)(`span`,{className:`block`,children:[(0,L.jsx)(`span`,{className:`block`,children:e.state===`active`?h(e.expiresAt,u):e.state===`expired`?`Ended`:`–`}),(0,L.jsx)(`span`,{className:`block text-[12px] text-soft`,children:s(e.expiresAt)})]})},{key:`reason`,header:`Reason`,cell:e=>(0,L.jsxs)(`span`,{className:`block max-w-[18rem] min-w-0`,children:[(0,L.jsx)(`span`,{className:`block break-words`,children:e.reason}),(0,L.jsxs)(`span`,{className:`block text-[12px] text-soft`,children:[`Added by `,e.createdBy,` `,h(Math.min(e.createdAt,u),u),e.revokedBy&&`. Revoked by ${e.revokedBy}`]})]})},{key:`state`,header:`State`,cell:t=>{let n=K[t.state]??{label:t.state,tone:`neutral`};return t.olderVersion&&t.state===`active`?(0,L.jsxs)(`span`,{className:`block max-w-[12rem]`,children:[(0,L.jsx)(e,{tone:`warn`,children:`Needs approving again`}),(0,L.jsx)(`span`,{className:`mt-1 block text-[12px] text-soft`,children:`Made by an older version. Approve the next call with "don't ask again" to remember it.`})]}):(0,L.jsx)(e,{tone:n.tone,children:n.label})}},{key:`act`,header:`Action`,align:`right`,cell:e=>e.state===`active`?(0,L.jsx)(b,{size:`sm`,variant:`secondary`,onClick:()=>(B(null),T(e)),children:`Revoke`}):(0,L.jsx)(`span`,{className:`text-soft`,children:`–`})}],rows:V,rowKey:e=>e.id,selectedKey:d,empty:(0,L.jsx)(m,{icon:`key`,title:p===`active`?`No active pre-approvals`:`No pre-approvals yet`,actions:(0,L.jsx)(b,{variant:`primary`,icon:`plus`,onClick:()=>x(!0),children:`Add pre-approval`}),children:`Without one, every call your rules hold waits for you on the Waiting for you page. You can also add one while approving a call there.`})})]}),(0,L.jsx)(G,{open:ie,onClose:()=>x(!1),serverId:t,tenant:n,tools:re.data,ttlMax:y.data?.grantTtlMaxSeconds,onCreated:e=>{x(!1),c.show(`ok`,`Pre-approval saved. It ends ${h(e.expiresAt)}.`),_.reload(),i()}}),(0,L.jsx)(O,{open:S!==null,onClose:()=>!D&&T(null),dismissable:!D,tone:`danger`,title:`Revoke this pre-approval?`,description:`Calls it covered will ask you again from now on. This cannot be undone, but you can add a new one.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{variant:`secondary`,onClick:()=>T(null),disabled:D,children:`Keep it`}),(0,L.jsx)(b,{variant:`danger`,loading:D,onClick:ae,children:`Revoke pre-approval`})]}),children:S&&(0,L.jsxs)(`div`,{className:`space-y-2 text-[14px]`,children:[(0,L.jsxs)(`p`,{children:[(0,L.jsx)(`code`,{className:`mono`,children:S.toolMatch}),`, `,S.uses,` of`,` `,S.maxUses===null?`unlimited`:S.maxUses,` uses, ends `,h(S.expiresAt),`.`]}),(0,L.jsx)(`p`,{className:`text-soft`,children:S.reason}),z&&(0,L.jsx)(`p`,{role:`alert`,className:`font-medium text-bad`,children:z})]})})]})}var J={read:`look only`,write:`make changes`,destructive:`delete`};function Y({grant:e}){if(e.maxUses===null)return(0,L.jsxs)(`span`,{className:`block`,children:[(0,L.jsx)(`span`,{className:`tnum block`,children:n(e.uses,`use`)}),(0,L.jsx)(`span`,{className:`block text-[12px] text-soft`,children:`no limit`})]});let t=Math.min(100,Math.round(e.uses/Math.max(1,e.maxUses)*100));return(0,L.jsxs)(`span`,{className:`block w-28`,children:[(0,L.jsxs)(`span`,{className:`tnum block text-[13.5px]`,children:[e.uses,` of `,e.maxUses,` used`]}),(0,L.jsx)(`span`,{className:`mt-1.5 block h-1.5 overflow-hidden rounded-full bg-sunken`,role:`meter`,"aria-label":`Uses`,"aria-valuemin":0,"aria-valuemax":e.maxUses,"aria-valuenow":e.uses,children:(0,L.jsx)(`span`,{className:`block h-full rounded-full ${t>=100?`bg-soft`:`bg-primary`}`,style:{width:`${t}%`}})})]})}export{q as PreApprovalsPage};
|
|
1
|
+
import{$ as e,A as t,B as n,D as r,E as i,G as a,H as o,I as s,It as c,K as l,L as u,M as d,Nt as ee,O as te,Pt as f,S as p,T as ne,U as m,V as h,Z as g,_,bt as re,c as v,gt as y,ht as b,j as ie,k as x,kt as S,mt as C,pt as w,rt as T,s as E,w as D,x as O,y as k}from"./kit-BHB_ha4i.js";import{c as A,i as j,l as M,o as N,pn as P,s as F}from"./index-Cm4wG2zz.js";var I=c(),L=S(),R=[{value:`max`,label:`is at most`},{value:`min`,label:`is at least`},{value:`enum`,label:`is one of`},{value:`maxLength`,label:`has at most N characters`},{value:`maxItems`,label:`has at most N items`},{value:`within`,label:`is a path inside the folder`},{value:`host`,label:`is a web address on`}],z=(e=``)=>({arg:e,kind:`max`,value:``,values:[]});function B(e,t){if(t===`number`||t===`integer`){let t=Number(e);return Number.isFinite(t)?t:e}if(t===`boolean`)return e===`true`||e!==`false`&&e;if(t===`string`)return e;if(e===`true`||e===`false`)return e===`true`;let n=Number(e);return e.trim()!==``&&Number.isFinite(n)?n:e}function V(e,t={}){let n={};for(let r of e){let e=r.arg.trim();if(!e)return{constraints:n,error:`Each limit needs the name of an input.`};let i=n[e]??={},a=Number(r.value),o=r.value.trim()!==``&&Number.isFinite(a);switch(r.kind){case`max`:case`min`:if(!o)return{constraints:n,error:`Give a number for the limit on ${e}.`};i[r.kind]=a;break;case`maxLength`:case`maxItems`:if(!o||!Number.isInteger(a)||a<+(r.kind===`maxLength`))return{constraints:n,error:`Give a whole number for the limit on ${e}.`};i[r.kind]=a;break;case`enum`:if(r.values.length===0)return{constraints:n,error:`List at least one allowed value for ${e}.`};i.enum=r.values.map(n=>B(n,t[e]));break;case`within`:if(!/^(\/|[a-zA-Z]:[\\/])/.test(r.value.trim()))return{constraints:n,error:`The folder for ${e} must be a full path, starting with /.`};i.within=r.value.trim();break;case`host`:if(r.values.length===0)return{constraints:n,error:`List at least one website for ${e}.`};i.host=r.values}}return{constraints:n,error:null}}function H({rows:e,onChange:n,argNames:r,disabled:i}){let a=(t,r)=>n(e.map((e,n)=>n===t?{...e,...r}:e));return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[e.map((o,s)=>(0,L.jsxs)(`div`,{className:`grid gap-2 rounded-2xl border border-line p-3 sm:grid-cols-[minmax(0,9rem)_minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-start`,children:[r&&r.length>0?(0,L.jsx)(x,{"aria-label":`Input for limit ${s+1}`,value:o.arg,onChange:e=>a(s,{arg:e}),disabled:i,options:[{value:``,label:`Choose input`},...r.map(e=>({value:e,label:e}))]}):(0,L.jsx)(d,{"aria-label":`Input for limit ${s+1}`,value:o.arg,onChange:e=>a(s,{arg:e}),placeholder:`input name`,mono:!0,disabled:i}),(0,L.jsx)(x,{"aria-label":`Kind of limit ${s+1}`,value:o.kind,onChange:e=>a(s,{kind:e}),options:R,disabled:i}),o.kind===`enum`||o.kind===`host`?(0,L.jsx)(t,{"aria-label":`Allowed values for limit ${s+1}`,value:o.values,onChange:e=>a(s,{values:e}),placeholder:o.kind===`host`?`example.com, then Enter`:`a value, then Enter`,disabled:i}):(0,L.jsx)(d,{"aria-label":`Value for limit ${s+1}`,value:o.value,onChange:e=>a(s,{value:e}),placeholder:o.kind===`within`?`/home/me/projects`:`a number`,mono:o.kind===`within`,disabled:i}),(0,L.jsx)(y,{icon:`trash`,label:`Remove limit ${s+1}`,size:40,onClick:()=>n(e.filter((e,t)=>t!==s)),disabled:i})]},s)),(0,L.jsx)(b,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>n([...e,z(r?.length===1?r[0]:``)]),disabled:i,children:`Add input limit`})]})}var U=`__pattern__`;function W(e){let t;return/matches a family of tools/.test(e)?{uses:`A pattern covers several tools, so it also needs a use limit or an input limit.`}:(t=/may not last longer than (\d+) days/.exec(e))?{ttl:`The longest a pre-approval can last is ${t[1]} days.`}:/expires_at is in the past/.test(e)?{ttl:`Choose how long it should last.`}:/unclosed brace/.test(e)?{tool:`This pattern has a { without a matching }.`}:(t=/constraint "(.+?)" is not a usable argument path/.exec(e))?{limits:`"${t[1]}" is not an input name that can be checked.`}:/within must be an absolute path/.test(e)?{limits:`A folder must be a full path, starting with /.`}:/"reason"/.test(e)?{reason:`Say why you are adding this. It is kept in the activity log.`}:/"tool_match"/.test(e)?{tool:`Choose a tool, or type a pattern.`}:/"max_uses"/.test(e)?{uses:`Use a whole number of 1 or more, or choose no limit.`}:{general:N(e)}}function G({open:e,onClose:t,serverId:n,tenant:s,tools:c,ttlMax:l,onCreated:te}){let[m,h]=(0,I.useState)(``),[g,v]=(0,I.useState)(``),[y,S]=(0,I.useState)(``),[C,w]=(0,I.useState)([]),[E,O]=(0,I.useState)(3600),[k,A]=(0,I.useState)(20),[j,M]=(0,I.useState)(!1),[P,R]=(0,I.useState)(``),[z,B]=(0,I.useState)(!1),[G,K]=(0,I.useState)({}),[q,J]=(0,I.useState)(!1);(0,I.useEffect)(()=>{e&&(h(``),v(``),S(``),w([]),O(3600),A(20),M(!1),R(``),B(!1),K({}))},[e]);let Y=m===U,X=(Y?g:m).trim(),Z=Y?void 0:c?.find(e=>e.name===m),Q=V(C,(0,I.useMemo)(()=>Object.fromEntries((Z?.args??[]).map(e=>[e.name,e.type??``])),[Z])),oe={tool_match:X,effect:y||null,constraints:Q.constraints,ttl_seconds:E??0,max_uses:j?null:k},se=JSON.stringify(oe),ce=re(se,250),[$,le]=(0,I.useState)(null),[ue,de]=(0,I.useState)(null),[fe,pe]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!e)return;let t=JSON.parse(ce);if(!t.tool_match||Q.error||!t.ttl_seconds){le(null),de(null);return}let r=!0;return pe(!0),f.previewGrant(n,{...t,reason:`preview`},s).then(e=>{r&&(le(e),de(null))}).catch(e=>{if(!r)return;le(null);let t=W(e.message);de(Object.values(t)[0]??N(e.message))}).finally(()=>r&&pe(!1)),()=>{r=!1}},[ce,e,n,s]);let me=$?.tools.filter(e=>e.covers)??[],he=y===`destructive`||me.some(e=>e.effect===`destructive`)||Z?.effect===`destructive`;async function ge(){let e={};if(X||(e.tool=Y?`Type a pattern.`:`Choose a tool.`),E===null?e.ttl=`Choose how long it should last.`:l!==void 0&&E>l&&(e.ttl=`The longest a pre-approval can last is ${u(l)}.`),!j&&(k===null||k<1||!Number.isInteger(k))&&(e.uses=`Use a whole number of 1 or more, or choose no limit.`),Q.error&&(e.limits=Q.error),P.trim()||(e.reason=`Say why you are adding this. It is kept in the activity log.`),K(e),!(Object.keys(e).length>0)){J(!0);try{te(await f.createGrant(n,{...oe,reason:P.trim()},s))}catch(e){K(e instanceof ee&&e.status===422?W(e.message):{general:N(e.message)})}finally{J(!1)}}}let _e=[{value:``,label:c===null?`Loading tools…`:`Choose a tool`},...(c??[]).map(e=>({value:e.name,label:`${F(e.name).label} · ${e.name}`})),{value:U,label:`Several tools, by pattern…`}];return(0,L.jsx)(p,{open:e,onClose:()=>!q&&t(),width:640,title:`Add pre-approval`,subtitle:`Let a kind of call run without asking you, for a limited time.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{variant:`ghost`,onClick:t,disabled:q,children:`Cancel`}),(0,L.jsx)(b,{variant:`primary`,icon:`check`,loading:q,disabled:he&&!z,onClick:ge,children:`Save pre-approval`})]}),children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(i,{label:`Which tool`,error:G.tool,children:(0,L.jsx)(x,{value:m,onChange:h,options:_e})}),Y&&(0,L.jsx)(i,{label:`Tool pattern`,error:G.tool,help:`Use * for any run of characters. For example notes__* covers every tool from the notes server. A pattern also needs a use limit or an input limit.`,children:(0,L.jsx)(d,{value:g,onChange:v,placeholder:`notes__create_*`,mono:!0,autoFocus:!0})}),(0,L.jsx)(i,{label:`Only when the tool`,help:`Leave this on any to go by what each tool does already.`,children:(0,L.jsx)(x,{value:y,onChange:S,options:[{value:``,label:`Any`},{value:`read`,label:T.read.label},{value:`write`,label:T.write.label},{value:`destructive`,label:T.destructive.label}]})}),(0,L.jsx)(i,{label:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Input limits `,(0,L.jsx)(_,{term:`limits`})]}),optional:!0,error:G.limits,help:`Calls covered by this must stay inside every limit you add.`,children:(0,L.jsx)(H,{rows:C,onChange:w,argNames:Z?Z.args.map(e=>e.name):null,disabled:q})}),(0,L.jsx)(i,{label:`For how long`,error:G.ttl,help:l?`Up to ${u(l)}.`:void 0,children:(0,L.jsx)(ne,{value:E,onChange:O,label:`For how long`,max:l})}),(0,L.jsx)(i,{label:`Up to how many calls`,error:G.uses,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,L.jsx)(r,{value:j?null:k,onChange:A,min:1,step:1,unit:`calls`,disabled:j,className:`w-40`}),(0,L.jsx)(D,{checked:j,onChange:M,label:`No limit`})]})}),(0,L.jsx)(i,{label:`Reason`,error:G.reason,help:`Kept in the activity log with your name.`,children:(0,L.jsx)(ie,{value:P,onChange:R,rows:2,placeholder:`For example: tidying notes this week, agreed with the team`})}),(0,L.jsxs)(`section`,{"aria-live":`polite`,className:`space-y-3 rounded-2xl bg-sunken/70 p-4`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:`What this would cover`}),X?Q.error?(0,L.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`Finish the input limits to see what this would cover.`}):ue?(0,L.jsx)(`p`,{className:`text-[13.5px] text-warn`,children:ue}):$?(0,L.jsx)(ae,{preview:$,covered:me,byPattern:Y}):fe&&(0,L.jsx)(a,{lines:3}):(0,L.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`Choose a tool to see which calls this would let through.`})]}),he&&(0,L.jsxs)(`div`,{className:`space-y-3 rounded-2xl bg-bad-tint p-4`,children:[(0,L.jsx)(`p`,{className:`text-[13.5px]`,children:`This covers a tool that deletes. Calls to it would run without asking you, within the limits above.`}),(0,L.jsx)(D,{checked:z,onChange:B,label:`I understand deletes will run without asking.`})]}),G.general&&(0,L.jsx)(o,{tone:`danger`,title:`The pre-approval was not saved`,role:`alert`,children:G.general})]})})}function ae({preview:e,covered:t,byPattern:r}){if(!e.surfaceKnown)return(0,L.jsxs)(`p`,{className:`text-[13.5px] text-warn`,children:[`Can't tell which tools this covers right now.`,` `,e.surfaceUnknownWhy?N(e.surfaceUnknownWhy):`The toolbox has not reported its tools.`]});let i=e.tools.length-t.length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:t.length===0?`This covers none of the tools this toolbox has right now.`:`It covers ${n(t.length,`tool`)} until ${A(e.expiresAt)}.`}),t.length>0&&(0,L.jsx)(`ul`,{className:`space-y-2.5`,children:t.map(e=>(0,L.jsxs)(`li`,{className:`rounded-xl bg-surface px-3 py-2.5`,children:[(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,L.jsx)(g,{effect:e.effect}),(0,L.jsx)(`span`,{className:`text-[14px] font-medium`,children:F(e.name).label}),(0,L.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.name})]}),e.heldBounds.length>0&&(0,L.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Calls that break your rule's limit on `,e.heldBounds.join(`, `),` still ask you. Add a limit for`,` `,e.heldBounds.length===1?`it`:`them`,` here to cover those too.`]}),e.unknownArgsHeld&&(0,L.jsx)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:`Calls that send an input your rule does not mention still ask you.`})]},e.name))}),(0,L.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[i>0&&`${n(i,`other tool`)} ${i===1?`is`:`are`} not covered. `,r&&`A tool added later that fits the pattern would be covered too. `,`It never lets through anything your rules block.`]})]})}var K={active:{label:`Active`,tone:`ok`},expired:{label:`Expired`,tone:`neutral`},exhausted:{label:`Used up`,tone:`neutral`},revoked:{label:`Revoked`,tone:`bad`}};function q(){let{serverId:t,tenant:n,nav:r,reload:i}=P(),c=k(),u=M(3e4),d=r.query.get(`grant`)??r.query.get(`id`),[p,ne]=(0,I.useState)(r.query.get(`id`)?`all`:`active`),_=E(()=>f.grants(t,n,{state:p}),[t,n,p],15e3),re=E(()=>f.tools(t,n),[t,n]),y=E(()=>f.redaction(),[]),[ie,x]=(0,I.useState)(!1),[S,T]=(0,I.useState)(null),[D,R]=(0,I.useState)(!1),[z,B]=(0,I.useState)(null),V=_.data??[],H=V.filter(e=>e.state===`active`&&e.expiresAt>u),U=H.reduce((e,t)=>e+t.uses,0),W=H.reduce((e,t)=>e===null||t.expiresAt<e?t.expiresAt:e,null);async function ae(){if(S){R(!0),B(null);try{let e=await f.revokeGrant(t,S.id,n);e.warning?c.show(`warn`,`Revoked, but ${N(e.warning).replace(/^The grant was revoked but /i,``)}`):c.show(`ok`,`Pre-approval revoked. Calls it covered will ask you again.`),T(null),_.reload(),i()}catch(e){e instanceof ee&&(e.status===409||e.status===404)?(c.show(`warn`,`This pre-approval had already ended.`),T(null),_.reload()):B(N(e.message))}finally{R(!1)}}}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(v,{title:`Pre-approvals`,subtitle:`Let a kind of call run without asking you, until a time or a number of uses runs out. A pre-approval can never allow something your rules block.`,actions:(0,L.jsx)(b,{variant:`primary`,icon:`plus`,onClick:()=>x(!0),children:`Add pre-approval`})}),(0,L.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,L.jsx)(C,{tone:`hero`,title:`Active now`,value:H.length,loading:_.data===null&&!_.error,sub:H.length?`Each one ends by itself`:`Every held call asks you`}),(0,L.jsx)(C,{title:`Calls let through`,value:U,loading:_.data===null&&!_.error,sub:`By the active pre-approvals so far`}),(0,L.jsx)(C,{title:`Ends soonest`,value:W===null?`None`:h(W,u),loading:_.data===null&&!_.error,sub:W===null?`Nothing is active`:`At ${A(W)}`})]}),(0,L.jsxs)(w,{className:`mt-6`,title:`Your pre-approvals`,actions:(0,L.jsx)(te,{label:`Show`,size:`sm`,value:p,onChange:ne,options:[{value:`active`,label:`Active`},{value:`all`,label:`All`}]}),children:[_.error&&(0,L.jsx)(`div`,{className:`mb-4`,children:(0,L.jsx)(o,{tone:`danger`,title:`Could not load pre-approvals`,actions:(0,L.jsx)(b,{size:`sm`,icon:`refresh`,onClick:_.reload,children:`Try again`}),children:N(_.error)})}),_.data===null?!_.error&&(0,L.jsx)(a,{lines:4,height:20}):(0,L.jsx)(l,{caption:`Pre-approvals`,columns:[{key:`tools`,header:`Which tools`,width:`w-[15rem]`,cell:e=>{let t=/[*?{]/.test(e.toolMatch);return(0,L.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,L.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,L.jsx)(g,{effect:e.effect})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:t?`Tools matching a pattern`:F(e.toolMatch).label}),(0,L.jsx)(`code`,{className:`mono block text-[12px] break-all text-soft`,children:e.toolMatch}),e.effect&&(0,L.jsxs)(`span`,{className:`block text-[12px] text-soft`,children:[`Only tools that: `,J[e.effect]??e.effect]})]})]})}},{key:`limits`,header:`Limits`,cell:e=>{let t=j(e.constraints);return e.olderVersion&&t.length===0?(0,L.jsx)(`span`,{className:`text-soft`,children:`Only a call with no inputs at all`}):t.length===0?(0,L.jsx)(`span`,{className:`text-soft`,children:`No input limits`}):(0,L.jsx)(`ul`,{className:`space-y-0.5 text-[13px]`,children:t.map(([e,t])=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`code`,{className:`mono text-[12px]`,children:e}),` `,t]},e))})}},{key:`uses`,header:`Uses`,cell:e=>(0,L.jsx)(Y,{grant:e})},{key:`expires`,header:`Expires`,cell:e=>(0,L.jsxs)(`span`,{className:`block`,children:[(0,L.jsx)(`span`,{className:`block`,children:e.state===`active`?h(e.expiresAt,u):e.state===`expired`?`Ended`:`–`}),(0,L.jsx)(`span`,{className:`block text-[12px] text-soft`,children:s(e.expiresAt)})]})},{key:`reason`,header:`Reason`,cell:e=>(0,L.jsxs)(`span`,{className:`block max-w-[18rem] min-w-0`,children:[(0,L.jsx)(`span`,{className:`block break-words`,children:e.reason}),(0,L.jsxs)(`span`,{className:`block text-[12px] text-soft`,children:[`Added by `,e.createdBy,` `,h(Math.min(e.createdAt,u),u),e.revokedBy&&`. Revoked by ${e.revokedBy}`]})]})},{key:`state`,header:`State`,cell:t=>{let n=K[t.state]??{label:t.state,tone:`neutral`};return t.olderVersion&&t.state===`active`?(0,L.jsxs)(`span`,{className:`block max-w-[12rem]`,children:[(0,L.jsx)(e,{tone:`warn`,children:`Needs approving again`}),(0,L.jsx)(`span`,{className:`mt-1 block text-[12px] text-soft`,children:`Made by an older version. Approve the next call with "don't ask again" to remember it.`})]}):(0,L.jsx)(e,{tone:n.tone,children:n.label})}},{key:`act`,header:`Action`,align:`right`,cell:e=>e.state===`active`?(0,L.jsx)(b,{size:`sm`,variant:`secondary`,onClick:()=>(B(null),T(e)),children:`Revoke`}):(0,L.jsx)(`span`,{className:`text-soft`,children:`–`})}],rows:V,rowKey:e=>e.id,selectedKey:d,empty:(0,L.jsx)(m,{icon:`key`,title:p===`active`?`No active pre-approvals`:`No pre-approvals yet`,actions:(0,L.jsx)(b,{variant:`primary`,icon:`plus`,onClick:()=>x(!0),children:`Add pre-approval`}),children:`Without one, every call your rules hold waits for you on the Waiting for you page. You can also add one while approving a call there.`})})]}),(0,L.jsx)(G,{open:ie,onClose:()=>x(!1),serverId:t,tenant:n,tools:re.data,ttlMax:y.data?.grantTtlMaxSeconds,onCreated:e=>{x(!1),c.show(`ok`,`Pre-approval saved. It ends ${h(e.expiresAt)}.`),_.reload(),i()}}),(0,L.jsx)(O,{open:S!==null,onClose:()=>!D&&T(null),dismissable:!D,tone:`danger`,title:`Revoke this pre-approval?`,description:`Calls it covered will ask you again from now on. This cannot be undone, but you can add a new one.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{variant:`secondary`,onClick:()=>T(null),disabled:D,children:`Keep it`}),(0,L.jsx)(b,{variant:`danger`,loading:D,onClick:ae,children:`Revoke pre-approval`})]}),children:S&&(0,L.jsxs)(`div`,{className:`space-y-2 text-[14px]`,children:[(0,L.jsxs)(`p`,{children:[(0,L.jsx)(`code`,{className:`mono`,children:S.toolMatch}),`, `,S.uses,` of`,` `,S.maxUses===null?`unlimited`:S.maxUses,` uses, ends `,h(S.expiresAt),`.`]}),(0,L.jsx)(`p`,{className:`text-soft`,children:S.reason}),z&&(0,L.jsx)(`p`,{role:`alert`,className:`font-medium text-bad`,children:z})]})})]})}var J={read:`look only`,write:`make changes`,destructive:`delete`};function Y({grant:e}){if(e.maxUses===null)return(0,L.jsxs)(`span`,{className:`block`,children:[(0,L.jsx)(`span`,{className:`tnum block`,children:n(e.uses,`use`)}),(0,L.jsx)(`span`,{className:`block text-[12px] text-soft`,children:`no limit`})]});let t=Math.min(100,Math.round(e.uses/Math.max(1,e.maxUses)*100));return(0,L.jsxs)(`span`,{className:`block w-28`,children:[(0,L.jsxs)(`span`,{className:`tnum block text-[13.5px]`,children:[e.uses,` of `,e.maxUses,` used`]}),(0,L.jsx)(`span`,{className:`mt-1.5 block h-1.5 overflow-hidden rounded-full bg-sunken`,role:`meter`,"aria-label":`Uses`,"aria-valuemin":0,"aria-valuemax":e.maxUses,"aria-valuenow":e.uses,children:(0,L.jsx)(`span`,{className:`block h-full rounded-full ${t>=100?`bg-soft`:`bg-primary`}`,style:{width:`${t}%`}})})]})}export{q as PreApprovalsPage};
|