hmcp-web 0.2.1 → 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 +21 -1
- package/dist/model/protection.js +68 -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-CXcU-_ug.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-XjNZ-wo-.js → Settings-DZ4P3Us6.js} +1 -1
- package/dist-ui/assets/StartPage-Bke6mrv5.js +1 -0
- package/dist-ui/assets/{Suggestions-HZyd0jDU.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-Dgo5oK2r.js +0 -1
- package/dist-ui/assets/Approvals-C5_8rBkL.js +0 -1
- package/dist-ui/assets/AttachApp-BRW1mJ7X.js +0 -5
- package/dist-ui/assets/Connections-BHsXRdYI.js +0 -2
- package/dist-ui/assets/Protection-BF5OlzGC.js +0 -1
- package/dist-ui/assets/Safety-DVb8sdbt.js +0 -1
- package/dist-ui/assets/StartPage-D8WBBhDy.js +0 -1
- package/dist-ui/assets/Tools-GMaKxxIG.js +0 -4
- package/dist-ui/assets/index-DbHZ_SUd.js +0 -16
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,G as n,H as r,It as i,Mt as a,O as o,Ot as s,Pt as c,_ as l,_t as u,ht as d,kt as f,s as p,vt as m,x as h,xt as g,yt as _}from"./kit-DRVm92_t.js";import{An as v,Bn as y,Fn as b,Gn as x,Hn as S,In as ee,Kn as C,Ln as te,Mn as ne,Nn as re,On as w,Pn as ie,Rn as ae,Vn as oe,Wn as se,X as T,Z as E,at as ce,it as D,jn as O,kn as le,ot as k,qn as A,st as j,zn as M}from"./index-DbHZ_SUd.js";import{a as N,o as ue,r as P,t as F}from"./AttachApp-BRW1mJ7X.js";var I=i(),L=f(),R=[[`Runs freely`,`fill-allow`],[`Asks you first`,`fill-approve`],[`Blocked`,`fill-deny`]],z=[`Files`,`GitHub`,`Notion`,`and more…`];function B(){let e=(0,I.useId)(),t=`${e}-t`,n=`${e}-d`,r=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`title`,{id:t,children:`How hardened-mcp fits in`}),(0,L.jsx)(`desc`,{id:n,children:`Your AI app talks to hardened-mcp, the toolbox. The toolbox checks every action: it runs freely, asks you first, or is blocked. Then it passes allowed actions on to your servers, such as files, GitHub and Notion.`})]});return(0,L.jsxs)(`figure`,{className:`m-0 text-ink`,children:[(0,L.jsxs)(`svg`,{viewBox:`0 0 760 236`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`hidden h-auto w-full sm:block`,children:[r,(0,L.jsx)(V,{id:e}),(0,L.jsx)(W,{x:8,y:58}),(0,L.jsx)(H,{x1:190,y1:118,x2:250,y2:118,id:e}),(0,L.jsx)(G,{x:258,y:20}),(0,L.jsx)(H,{x1:508,y1:118,x2:568,y2:118,id:e}),(0,L.jsx)(K,{x:576,y:34})]}),(0,L.jsxs)(`svg`,{viewBox:`0 0 320 560`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`mx-auto block h-auto w-full max-w-[320px] sm:hidden`,children:[r,(0,L.jsx)(V,{id:e}),(0,L.jsx)(W,{x:68,y:4}),(0,L.jsx)(H,{x1:160,y1:126,x2:160,y2:160,id:e}),(0,L.jsx)(G,{x:35,y:168}),(0,L.jsx)(H,{x1:160,y1:364,x2:160,y2:398,id:e}),(0,L.jsx)(K,{x:68,y:406,compact:!0})]})]})}function V({id:e}){return(0,L.jsx)(`defs`,{children:(0,L.jsx)(`marker`,{id:`${e}-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,L.jsx)(`path`,{d:`M1 1 9 5 1 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function H({x1:e,y1:t,x2:n,y2:r,id:i}){return(0,L.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,className:`stroke-soft text-soft`,strokeWidth:`2`,strokeDasharray:`5 5`,markerEnd:`url(#${i}-arrow)`})}function U({x:e,y:t,children:n,size:r=15,weight:i=600,className:a=`fill-ink`,anchor:o=`middle`}){return(0,L.jsx)(`text`,{x:e,y:t,textAnchor:o,fontSize:r,fontWeight:i,className:a,style:{fontFamily:`var(--font-sans)`},children:n})}function W({x:e,y:t}){return(0,L.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,L.jsx)(`rect`,{width:`184`,height:`120`,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,L.jsxs)(`g`,{transform:`translate(76 18)`,className:`text-muted`,children:[(0,L.jsx)(`path`,{d:`M4 4h24a4 4 0 0 1 4 4v13a4 4 0 0 1-4 4H14l-7 6v-6H4a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,L.jsx)(`circle`,{cx:`9`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`16`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`23`,cy:`14.5`,r:`1.8`,fill:`currentColor`})]}),(0,L.jsx)(U,{x:92,y:76,children:`Your AI app`}),(0,L.jsx)(U,{x:92,y:98,size:14,weight:500,className:`fill-soft`,children:`Claude, Cursor, VS Code…`})]})}function G({x:e,y:t}){return(0,L.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,L.jsx)(`rect`,{width:`250`,height:`196`,rx:`26`,className:`fill-green-deep`}),(0,L.jsxs)(`g`,{transform:`translate(110 16)`,className:`text-white`,children:[(0,L.jsx)(`path`,{d:`M15 2 27 6.5v9.4c0 7-4.5 11.8-12 14.8C7.5 27.7 3 22.9 3 15.9V6.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`m9.5 16 4 4 7-8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),(0,L.jsx)(U,{x:125,y:68,size:17,weight:700,className:`fill-white`,children:`hardened-mcp`}),(0,L.jsx)(U,{x:125,y:88,size:14,weight:500,className:`fill-on-hero-soft`,children:`the toolbox that checks every action`}),R.map(([e,t],n)=>(0,L.jsxs)(`g`,{transform:`translate(34 ${108+n*26})`,children:[(0,L.jsx)(`rect`,{width:`182`,height:`22`,rx:`11`,fill:`white`,fillOpacity:`0.12`}),(0,L.jsx)(`circle`,{cx:`14`,cy:`11`,r:`5`,className:t}),(0,L.jsx)(U,{x:28,y:15.5,size:14,weight:600,className:`fill-white`,anchor:`start`,children:e})]},e))]})}function K({x:e,y:t,compact:n}){return(0,L.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,L.jsx)(`rect`,{width:`176`,height:n?150:168,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,L.jsx)(U,{x:88,y:28,size:14.5,weight:700,className:`fill-soft`,children:`Your servers`}),z.map((e,t)=>(0,L.jsxs)(`g`,{transform:`translate(18 ${42+t*(n?26:30)})`,children:[(0,L.jsx)(`rect`,{width:`140`,height:`22`,rx:`7`,className:t===z.length-1?`fill-transparent`:`fill-sunken`}),t<z.length-1&&(0,L.jsx)(`circle`,{cx:`13`,cy:`11`,r:`3.5`,className:`fill-ok`}),(0,L.jsx)(U,{x:t<z.length-1?26:8,y:15.5,size:12.5,weight:500,className:`fill-muted`,anchor:`start`,children:e})]},e))]})}function q({text:e}){let t=e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).filter(Boolean);return(0,L.jsx)(L.Fragment,{children:t.map((e,t)=>e.startsWith("`")?(0,L.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] break-words text-ink`,children:e.slice(1,-1)},t):e.startsWith(`**`)?(0,L.jsx)(`strong`,{className:`font-semibold text-ink`,children:e.slice(2,-2)},t):(0,L.jsx)(`span`,{children:e},t))})}function J({children:e}){return(0,L.jsx)(`p`,{className:`max-w-2xl text-[15.5px] leading-relaxed text-muted`,children:e})}function Y({icon:e,title:t,children:n}){return(0,L.jsxs)(`li`,{className:`flex gap-3`,children:[(0,L.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,L.jsx)(s,{name:e,size:17})}),(0,L.jsxs)(`span`,{className:`min-w-0 pt-0.5`,children:[(0,L.jsx)(`span`,{className:`block text-[15px] font-medium`,children:t}),(0,L.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] leading-relaxed text-soft`,children:n})]})]})}function de(){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,L.jsx)(J,{children:`hardened-mcp lets your AI app use tools, like your files, GitHub or Notion. It doesn't give the AI everything. You get a toolbox. Your AI app connects to it, and every action goes through it first. When protection is on, reading runs freely. Every change asks you first. Anything outside the folders and services you gave it is blocked. Everything is written down, so you can always see what your AI did.`}),(0,L.jsx)(`div`,{className:`rounded-[22px] bg-sunken/60 p-4 sm:p-6`,children:(0,L.jsx)(B,{})}),(0,L.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,L.jsxs)(`section`,{"aria-labelledby":`what-mcp`,className:`rounded-[18px] border border-line p-5`,children:[(0,L.jsxs)(`h2`,{id:`what-mcp`,className:`flex items-center gap-2 text-[16px] font-semibold`,children:[`What's an MCP server? `,(0,L.jsx)(l,{term:`mcp`})]}),(0,L.jsx)(`p`,{className:`mt-2 text-[14px] leading-relaxed text-muted`,children:`It's a small add-on that gives your AI app a set of tools: reading a folder, searching the web, opening an issue on GitHub. MCP is a shared standard, so any AI app can use any of them. You'll add your first one in a minute.`})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`what-expect`,className:`rounded-[18px] border border-line p-5`,children:[(0,L.jsx)(`h2`,{id:`what-expect`,className:`text-[16px] font-semibold`,children:`What to expect`}),(0,L.jsxs)(`ul`,{className:`mt-3 flex flex-col gap-3`,children:[(0,L.jsx)(Y,{icon:`clock`,title:`About 5 minutes`,children:`Seven short steps. You can skip any of them and come back later from Settings & help.`}),(0,L.jsx)(Y,{icon:`lock`,title:`Nothing changes until you say so`,children:`Your AI apps keep working exactly as they do now until you choose to connect one.`}),(0,L.jsx)(Y,{icon:`eye`,title:`It starts by watching`,children:`At first your toolbox lets everything run and writes down what it would have asked you about or blocked, so nothing you rely on breaks. In step 6 you choose whether to turn protection on straight away.`})]})]})]})]})}function X(e,t){let n=t.find(t=>t.id===e),r=e===`node`?t.find(e=>e.id===`npx`):e===`uv`?t.find(e=>e.id===`uvx`):void 0;return!n?.found||r&&!r.found?{status:{tone:`neutral`,label:`Not installed`,icon:`minus`},check:n,state:`missing`}:n?.running===!1?{status:{tone:`warn`,label:`Installed, not running`,icon:`pause`},check:n,state:`stopped`}:{status:{tone:`ok`,label:`Ready`,icon:`check`},check:n,state:`ready`}}function fe({entries:e}){let i=p(()=>t.doctor(),[]),[a,o]=(0,I.useState)(!1),s=i.data,c=j(s?.platform),u=M(e),f=()=>{o(!0),i.reload(),setTimeout(()=>o(!1),700)},m=s?k.map(e=>({rt:e,...X(e,s.checks)})):[],h=m.filter(e=>e.state!==`ready`),g=m.some(e=>e.rt===`node`&&e.state===`ready`);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(J,{children:[`Most servers need a free helper program to run, such as Node.js. This looks for them on this computer. It only looks; it never installs or changes anything. `,(0,L.jsx)(l,{term:`machineCheck`})]}),i.error&&!s?(0,L.jsx)(r,{tone:`warn`,title:`The check couldn't run`,actions:(0,L.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a,children:`Check again`}),children:`You can skip this step. If a server needs something that's missing, it will tell you when you test it.`}):s?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(r,{tone:h.length===0?`ok`:g?`info`:`warn`,role:`status`,title:h.length===0?`Everything is ready`:g?`You're ready for your first server`:`Some servers need something installed first`,actions:(0,L.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a||i.loading,children:`Check again`}),children:h.length===0?`This computer has everything servers need.`:g?`Some servers need other helpers, listed below. You don't need them unless you add one of those servers.`:`That's fine. You can carry on and only install something when a server you want needs it.`}),(0,L.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`What this computer has`,children:m.map(e=>(0,L.jsx)(Z,{rt:e.rt,status:e.status,check:e.check,state:e.state,os:c,needs:u[e.rt]},e.rt))})]}):(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,"aria-label":`Checking your computer`,children:(0,L.jsx)(n,{height:64,lines:3})})]})}function Z({rt:t,status:n,check:r,state:i,os:a,needs:s}){let c=D[t],[l,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(a),h=`install-${t}`;return(0,L.jsxs)(`li`,{className:`rounded-[18px] border border-line p-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,L.jsx)(`p`,{className:`flex flex-wrap items-center gap-2 text-[15px] font-semibold`,children:c.name}),(0,L.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:c.why}),i!==`ready`&&s.length>0&&(0,L.jsxs)(`p`,{className:`mt-1.5 text-[13px] text-muted`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Needed by:`}),` `,s.join(`, `)]}),i===`ready`&&(r?.path||r?.version)&&(0,L.jsxs)(`details`,{className:`mt-1 text-[12px] text-soft`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),r?.version&&(0,L.jsxs)(`span`,{className:`mono block`,children:[`Version `,r.version]}),r?.path&&(0,L.jsx)(`code`,{className:`mono block break-all`,children:r.path})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,L.jsx)(e,{tone:n.tone,icon:n.icon,children:n.label}),i!==`ready`&&(0,L.jsx)(d,{size:`sm`,variant:`ghost`,iconRight:`chevron`,"aria-expanded":l,"aria-controls":h,onClick:()=>f(!l),children:i===`stopped`?`How to start it`:`How to install it`})]})]}),l&&i!==`ready`&&(0,L.jsx)(`div`,{id:h,className:`mt-4 border-t border-faint pt-4`,children:i===`stopped`&&c.start?(0,L.jsx)(`p`,{className:`text-[14px] leading-relaxed text-muted`,children:(0,L.jsx)(q,{text:c.start[p]})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(o,{size:`sm`,label:`Install steps for ${c.name}: choose your computer`,value:p,onChange:m,options:[`darwin`,`win32`,`linux`].map(e=>({value:e,label:ce[e]}))}),(0,L.jsx)(`ol`,{className:`mt-4 flex flex-col gap-3`,children:c.steps[p].map((e,t)=>(0,L.jsxs)(`li`,{className:`flex gap-3`,children:[(0,L.jsx)(`span`,{className:`tnum grid h-6 w-6 shrink-0 place-items-center rounded-full bg-sunken text-[12px] font-bold text-muted`,children:t+1}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 text-[14px] leading-relaxed text-muted`,children:[(0,L.jsx)(q,{text:e.text}),e.copy&&(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`code`,{className:`mono min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[12.5px] break-all text-ink`,children:e.copy}),(0,L.jsx)(E,{text:e.copy,label:`Copy`})]}),e.link&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(u,{href:e.link.url,external:!0,size:`sm`,iconRight:`external`,children:e.link.label})})]})]},t))})]})})]})}function pe({gatewayId:e,existing:t,added:n,entries:i,onAdded:a,onClosed:o}){let[s,c]=(0,I.useState)(n.length===0&&t.length===0),l=n.at(-1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(J,{children:[`Pick a server to give your AI app its first tools. Each one comes with step-by-step instructions, and you can test it before anything is saved. If you're not sure, `,(0,L.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Files on this computer`}),` `,`is a good first choice: it lets the AI read and edit files in one folder you choose, and nothing outside it.`]}),l&&(0,L.jsx)(r,{tone:`ok`,role:`status`,title:l.displayName?`${l.displayName} is in your toolbox`:`Added to your toolbox`,children:l.summary.length>0?(0,L.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.summary.map(e=>(0,L.jsx)(`li`,{children:e},e))}):`It's saved in your toolbox.`}),!l&&t.length>0&&(0,L.jsxs)(r,{tone:`info`,title:`You already have servers`,children:[`Your toolbox has `,t.map(e=>ee(i,e)?.name??e).join(`, `),`. You can add another or carry on.`]}),s?(0,L.jsx)(N,{gatewayId:e,compact:!0,onDone:e=>{a(e),c(!1)},onCancel:n.length>0||t.length>0?()=>{c(!1),o?.()}:void 0}):(0,L.jsx)(`div`,{children:(0,L.jsx)(d,{icon:`plus`,onClick:()=>c(!0),children:`Add another server`})})]})}function me({gatewayId:e,attached:t,onAttached:n,onAddServer:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(J,{children:[`Now tell your AI app about your toolbox. `,(0,L.jsx)(l,{term:`toolbox`}),` Choose the app you use and we add the toolbox to its settings for you. A copy of its old settings is kept, so you can undo this at any time.`]}),(0,L.jsxs)(`div`,{className:`rounded-[18px] bg-sunken/60 p-4 sm:p-5`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[(0,L.jsx)(s,{name:`refresh`,size:17,className:`text-ok`}),`Restart your app once`]}),(0,L.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-muted`,children:`Your AI app only looks for new tools when it starts. After connecting, quit it completely (not just close the window) and open it again. You only do this once: servers you add or change later appear on their own.`})]}),e?t?(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(r,{tone:`ok`,role:`status`,title:t.alreadyConnected?`${t.appLabel} was already connected`:`Connected to ${t.appLabel}`,children:t.restartHint||`Quit ${t.appLabel} completely and open it again.`}),t.scope&&(0,L.jsx)(P,{scope:t.scope})]}):(0,L.jsx)(F,{gatewayId:e,compact:!0,onDone:n}):(0,L.jsx)(r,{tone:`info`,title:`Add a server first`,actions:(0,L.jsx)(d,{size:`sm`,variant:`primary`,icon:`arrow-left`,onClick:i,children:`Add a server`}),children:`Your toolbox is made when you add your first server. Then you can connect it to your app here.`})]})}function he({entries:e,servers:t,appLabel:n}){let{prompt:r,entry:i}=C(e,t),a=n??`your AI app`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(J,{children:[`Open `,a,` and ask it something that uses your new tools`,i?` from ${i.name}`:``,`. Here's a good first one:`]}),(0,L.jsxs)(`figure`,{className:`m-0 rounded-[20px] border-[1.5px] border-primary/40 bg-ok-tint p-5`,children:[(0,L.jsxs)(`blockquote`,{className:`text-[17px] leading-relaxed font-medium text-ink`,children:[`“`,r,`”`]}),(0,L.jsx)(`figcaption`,{className:`mt-4`,children:(0,L.jsx)(E,{text:r,label:`Copy this`})})]}),(0,L.jsxs)(`section`,{"aria-labelledby":`what-see`,children:[(0,L.jsx)(`h2`,{id:`what-see`,className:`text-[16px] font-semibold`,children:`What you'll see`}),(0,L.jsxs)(`ol`,{className:`mt-3 flex flex-col gap-3`,children:[(0,L.jsx)(Y,{icon:`check`,title:`Looking runs straight away`,children:`When the AI only reads something, it just happens. Every action is written down under Activity in this console.`}),(0,L.jsx)(Y,{icon:`eye`,title:`At first, changes run too`,children:`A new toolbox starts by watching: everything runs, and Activity notes what would have asked you first or been blocked. In the next step you choose whether it should start protecting you.`}),(0,L.jsxs)(Y,{icon:`clock`,title:`Once protection is on, every change asks you first`,children:[`If the AI wants to change something, it stops and tells you it's waiting. The request appears under`,` `,(0,L.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Waiting for you`}),` in this console. Approve it or say no there. If you approve, the AI can try again and it goes ahead. Anything outside the folders and services you gave it is blocked.`]}),(0,L.jsxs)(Y,{icon:`warning`,title:`If nothing happens`,children:[`Check that you quit `,a,` completely and opened it again. If a tool still doesn't show up, open Connections in this console: each server says whether it's working, and if not, why and how to fix it.`]})]}),(0,L.jsx)(`div`,{className:`mt-5`,children:(0,L.jsx)(u,{href:`/approvals`,external:!0,icon:`clock`,iconRight:`external`,children:`Open Waiting for you`})})]})]})}var Q=`Reading runs straight away. Every change asks you first, here in this console. Anything outside the folders and services you gave it is blocked.`;function ge({gatewayId:t,onAddServer:i,applyRef:a}){let[o,s]=(0,I.useState)(`protect`),[l,u]=(0,I.useState)(!1),[f,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(null),_=p(()=>t?c.protection(t):Promise.resolve(null),[t]),v=(0,I.useRef)(null),y=(0,I.useRef)(!1),b=_.data?.enforcement===`enforce`||h===`protect`,x=_.data&&!_.data.policyWrite.ok?_.data.policyWrite.why:null,S=async()=>{if(m(null),!t||b||h===`watch`)return!0;if(o===`watch`)return y.current=!0,g(`watch`),!0;if(!_.data)return!1;if(x)return m(x),!1;u(!0);try{return await c.setPolicySetting(t,`enforcement`,`enforce`,_.data.policyWrite.digest),y.current=!0,g(`protect`),_.reload(),!0}catch(e){return m(e.message||`Protection couldn't be turned on.`),!1}finally{u(!1)}};return a&&(a.current=S),(0,I.useEffect)(()=>()=>{a&&(a.current=null)},[a]),(0,I.useEffect)(()=>{y.current&&v.current?.focus()},[b,h]),t?_.loading&&!_.data?(0,L.jsx)(n,{height:180}):b?(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,L.jsxs)(r,{tone:`ok`,title:`Your toolbox is protecting you`,role:`status`,children:[Q,` Requests appear under `,(0,L.jsx)(`strong`,{className:`font-semibold`,children:`Waiting for you`}),`.`]})}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(Y,{icon:`clock`,title:`When your AI asks for something`,children:`It stops and tells you it's waiting. Open this console, look at what it wants to do, and approve it or say no.`}),(0,L.jsxs)(Y,{icon:`sliders`,title:`Too many questions?`,children:[`Under `,(0,L.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` you can let a tool you trust run freely, or approve one for a while.`]})]})]}):h===`watch`?(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,L.jsx)(r,{tone:`warn`,title:`Your toolbox is only watching for now`,role:`status`,children:`Everything your AI does runs and is written down under Activity. Nothing asks you first and nothing is blocked, so you're not protected yet.`})}),(0,L.jsxs)(J,{children:[`When you're ready, turn protection on under `,(0,L.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` `,`(one switch at the top), or come back to this guide from Settings & help.`]}),(0,L.jsx)(`div`,{children:(0,L.jsx)(d,{variant:`ghost`,onClick:()=>g(null),children:`Choose again`})})]}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(J,{children:`Right now your toolbox only watches: everything your AI does runs, and is written down. Choose whether it should start protecting you now.`}),(0,L.jsx)(T,{label:`How careful should your toolbox be?`,value:o,onChange:s,options:[{value:`protect`,title:`Protect me now`,badge:(0,L.jsx)(e,{tone:`ok`,children:`Recommended`}),body:Q},{value:`watch`,title:`Watch for a few days first`,body:`Everything runs and is written down, and nothing asks you first. You can see what would have asked you, then turn protection on later. Until then, you're not protected.`}]}),x&&(0,L.jsx)(r,{tone:`warn`,title:`This toolbox's protection can't be changed from the console`,children:x}),f&&(0,L.jsx)(r,{tone:`danger`,role:`alert`,title:`Protection wasn't turned on`,children:f}),(0,L.jsx)(`div`,{children:(0,L.jsx)(d,{variant:`primary`,icon:o===`protect`?`shield-check`:`eye`,loading:l,disabled:!!x&&o===`protect`,onClick:()=>void S(),children:o===`protect`?`Turn on protection`:`Keep watching for now`})})]}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(J,{children:`There's nothing to protect yet. Add a server first, then come back here.`}),(0,L.jsx)(`div`,{children:(0,L.jsx)(d,{icon:`plus`,onClick:i,children:`Add a server`})})]})}var $=[{href:`/approvals`,icon:`clock`,title:`Waiting for you`,body:`Requests that ask you first. Approve or say no.`},{href:`/tools`,icon:`tool`,title:`Tools`,body:`Every tool your AI can use, and what each one is allowed to do.`},{href:`/connections?add=server`,icon:`plus`,title:`Add more servers`,body:`GitHub, Notion, the web and more, with a guide for each.`},{href:`/protection`,icon:`sliders`,title:`Protection settings`,body:`Choose what runs freely, what asks you first, and what's blocked.`}];function _e({gatewayId:e,onLeave:t}){let n=p(()=>e?c.protection(e):Promise.resolve(null),[e]),i=!!n.data&&n.data.enforcement!==`enforce`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(J,{children:`Your toolbox is set up. Here's where to go next.`}),i&&(0,L.jsxs)(r,{tone:`warn`,title:`Protection: off (only watching)`,children:[`Everything your AI does runs and is written down, and nothing asks you first. Turn protection on under`,` `,(0,L.jsx)(`strong`,{className:`font-semibold`,children:`Protection settings`}),` when you're ready.`]}),(0,L.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:$.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`a`,{href:e.href,onClick:n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(e.href))},className:_(`card card-link flex h-full gap-3.5 p-5`),children:[(0,L.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,L.jsx)(s,{name:e.icon,size:19})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[15.5px] font-semibold`,children:[e.title,(0,L.jsx)(s,{name:`arrow-right`,size:15,className:`text-soft`})]}),(0,L.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:e.body})]})]})},e.href))}),(0,L.jsx)(r,{tone:`info`,title:`When you need to approve something, open the console`,children:`Approving requests and signing in to services happen here. Your servers keep working without the console open; anything that asks you first waits until you open it again.`})]})}function ve(){let[e,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(`welcome`),[o,l]=(0,I.useState)(!1),[u,f]=(0,I.useState)(null),[p,ee]=(0,I.useState)([]),[C,T]=(0,I.useState)([]),[E,ce]=(0,I.useState)(null),[D,k]=(0,I.useState)([]),j=(0,I.useRef)(null),M=(0,I.useRef)(null),[N,P]=(0,I.useState)(!1),F=(0,I.useRef)(!1),[R,z]=(0,I.useState)(w),[B,V]=(0,I.useState)(null),H=(0,I.useRef)(R);H.current=R;let U=(0,I.useRef)(null),[W,G]=(0,I.useState)(0),K=(0,I.useRef)(Promise.resolve()),q=(0,I.useRef)(le);(0,I.useEffect)(()=>{let e=!0;return t.settings().then(oe,()=>(l(!0),le)).then(t=>{e&&(q.current=t,n(t),i(se(t.onboarding)))}),c.servers().then(t=>{if(!e)return;let n=t.filter(e=>e.ok),r=n.find(e=>e.id===`main`)??n[0];r&&(f(r.id),ee(r.upstreams??[]))}).catch(()=>void 0),t.catalog().then(t=>e&&k(t.entries)).catch(()=>void 0),()=>{e=!1}},[]);let J=(0,I.useCallback)(e=>{let r={...q.current,onboarding:e};q.current=r,n(r);let i=()=>t.saveSettings(r).then(()=>l(!1),()=>l(!0));return K.current=K.current.then(i,i),K.current},[]),Y=()=>{let e=H.current;if(e.pending){let t=e.pending;T(e=>x({added:e,gatewayId:null},t).added),f(t.gatewayId)}e.state!==`idle`&&ue(),z(w)},X=e=>{te(r,R)?V(()=>e):e()},Z=(e,t)=>{r===`server`&&e!==`server`&&Y(),F.current=!0,i(e),J(ae(q.current.onboarding,e,t))},Q=async(e=`/`)=>{r===`server`&&Y(),await J(b(q.current.onboarding)),g(e)};(0,I.useEffect)(()=>{if(r===`server`)return a(e=>z(t=>re(t,e)))},[r]),(0,I.useEffect)(()=>{W&&U.current?.querySelector(`button`)?.focus()},[W]),(0,I.useEffect)(()=>{if(!F.current)return;j.current?.focus();let e=matchMedia(`(prefers-reduced-motion: reduce)`).matches;window.scrollTo({top:0,behavior:e?`auto`:`smooth`})},[r]),(0,I.useEffect)(()=>{let e=document.title;return document.title=`Step ${v.indexOf(r)+1} of ${v.length}: ${O[r]} – hardened-mcp`,()=>{document.title=e}},[r]);let $=v.indexOf(r),ve=e?.onboarding.done??[],be=[...p,...A(C,R.pending).map(e=>e.upstreamName)],xe=te(r,R);return(0,L.jsxs)(`div`,{className:`min-h-dvh bg-canvas text-ink`,children:[(0,L.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-faint bg-canvas/95`,children:(0,L.jsxs)(`div`,{className:`mx-auto flex max-w-6xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,L.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[#2a2623]`,children:(0,L.jsx)(`img`,{src:`/brand/mark.svg`,alt:``,width:24,height:24})}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-[15px] font-semibold`,children:`Getting started`}),(0,L.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:`hardened-mcp`})]}),(0,L.jsx)(d,{variant:`ghost`,size:`sm`,iconRight:`arrow-right`,onClick:()=>X(()=>void Q()),children:`Go to the console`})]})}),e?(0,L.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10 lg:py-10`,children:[(0,L.jsxs)(`nav`,{"aria-label":`Guide steps`,className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,L.jsxs)(`div`,{className:`lg:hidden`,children:[(0,L.jsxs)(`p`,{className:`text-[13px] font-semibold text-soft`,children:[`Step `,$+1,` of `,v.length]}),(0,L.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-line`,role:`progressbar`,"aria-label":`Progress through the guide`,"aria-valuemin":1,"aria-valuemax":v.length,"aria-valuenow":$+1,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${($+1)/v.length*100}%`}})})]}),(0,L.jsx)(`ol`,{className:`hidden flex-col gap-1 lg:flex`,children:v.map((e,t)=>{let n=e===r,i=ve.includes(e);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>e===r?void 0:X(()=>Z(e)),"aria-current":n?`step`:void 0,className:_(`flex w-full items-center gap-3 rounded-2xl px-3 py-2.5 text-left text-[14px] transition-colors`,n?`bg-surface font-semibold shadow-[var(--shadow-sm)]`:`text-muted hover:bg-faint`),children:[(0,L.jsx)(`span`,{className:_(`tnum grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12.5px] font-bold`,i?`bg-primary text-white`:n?`border-2 border-[var(--primary)] text-ink`:`border-[1.5px] border-line text-soft`),children:i?(0,L.jsx)(s,{name:`check`,size:14,strokeWidth:2.6}):t+1}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:O[e]}),i&&(0,L.jsx)(`span`,{className:`sr-only`,children:`(done)`})]})},e)})})]}),(0,L.jsxs)(`main`,{className:`min-w-0`,children:[(0,L.jsxs)(`article`,{className:`card p-5 sm:p-8`,"aria-labelledby":`start-step-h`,children:[(0,L.jsxs)(`p`,{className:`eyebrow text-soft`,children:[`Step `,$+1,` · `,O[r]]}),(0,L.jsx)(`h1`,{id:`start-step-h`,ref:j,tabIndex:-1,className:`display mt-2 text-[28px] outline-none sm:text-[34px]`,children:ne[r]}),(0,L.jsxs)(`div`,{className:`mt-5`,children:[r===`welcome`&&(0,L.jsx)(de,{}),r===`computer`&&(0,L.jsx)(fe,{entries:D}),r===`server`&&(0,L.jsx)(pe,{gatewayId:u,existing:p,added:C,entries:D,onAdded:e=>{f(e.gatewayId),T(t=>A(t,e)),z(w),G(e=>e+1)},onClosed:()=>z(w)}),r===`app`&&(0,L.jsx)(me,{gatewayId:u,attached:E,onAttached:e=>{ce(e),G(e=>e+1)},onAddServer:()=>Z(`server`)}),r===`try`&&(0,L.jsx)(he,{entries:D,servers:be,appLabel:E?.appLabel??null}),r===`protect`&&(0,L.jsx)(ge,{gatewayId:u,onAddServer:()=>Z(`server`),applyRef:M}),r===`done`&&(0,L.jsx)(_e,{gatewayId:u,onLeave:e=>void Q(e)})]}),(0,L.jsxs)(`footer`,{className:_(`mt-8 flex-wrap items-center gap-2 border-t border-faint pt-5`,xe?`hidden`:`flex`),children:[$>0&&(0,L.jsx)(d,{variant:`ghost`,icon:`arrow-left`,onClick:()=>Z(S(r)),children:`Back`}),(0,L.jsx)(`span`,{className:`flex-1`}),r!==`done`&&(0,L.jsx)(d,{variant:`ghost`,onClick:()=>X(()=>Z(y(r))),children:`Skip for now`}),(0,L.jsx)(ye,{buttonRef:U,step:r,ready:ie(r,be.length,!!E,R),busy:N,onNext:async()=>{r===`protect`&&M.current&&(P(!0),!await M.current().finally(()=>P(!1)))||Z(y(r),r)},onFinish:()=>void Q()})]})]}),(0,L.jsx)(h,{open:!!B,onClose:()=>V(null),title:`Leave without saving this server?`,description:`You're in the middle of setting up a server. If you leave now, it isn't added, and you'd start it again next time.`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(d,{variant:`ghost`,onClick:()=>{let e=B;V(null),e?.()},children:`Leave without saving`}),(0,L.jsx)(d,{variant:`primary`,onClick:()=>V(null),children:`Keep setting it up`})]})}),o&&(0,L.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-soft`,role:`status`,children:`Your progress couldn't be saved, so the guide may start over next time. Everything you add is still saved.`})]})]}):(0,L.jsx)(`main`,{className:`flex min-h-[60dvh] items-center justify-center`,children:(0,L.jsxs)(`p`,{role:`status`,className:`flex items-center gap-3 text-soft`,children:[(0,L.jsx)(m,{}),` Getting things ready…`]})})]})}function ye({buttonRef:e,step:t,ready:n,busy:r,onNext:i,onFinish:a}){if(t===`done`)return(0,L.jsx)(`span`,{ref:e,className:`contents`,children:(0,L.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:a,children:`Go to the console`})});let o=t===`welcome`?`Let's start`:t===`try`?`I've tried it`:`Continue`,s=n?null:t===`server`?`Add a server first, or skip for now.`:`Connect an app first, or skip for now.`;return(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(`p`,{id:`start-continue-why`,className:`order-last basis-full text-right text-[13px] text-soft`,children:s}),(0,L.jsx)(`span`,{ref:e,className:`contents`,children:(0,L.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:i,disabled:!n,loading:r,"aria-describedby":s?`start-continue-why`:void 0,children:o})})]})}export{ve as StartPage};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,Ct as r,D as i,E as a,Et as o,G as s,H as c,I as l,It as u,J as d,M as f,N as p,Nt as m,O as h,Ot as g,Pt as _,Q as v,S as y,U as b,V as x,Y as S,Z as C,_ as w,_t as ee,bt as te,c as ne,d as re,et as T,f as ie,ft as ae,gt as oe,ht as E,k as se,kt as D,lt as ce,ot as O,pt as k,q as le,rt as A,s as ue,st as j,w as M,wt as de,x as N,y as P,yt as F}from"./kit-DRVm92_t.js";import{_n as fe,bn as I,fn as L,gn as pe,pn as R,s as z,un as me}from"./index-DbHZ_SUd.js";var B=u(),V=[`allow`,`approve`,`deny`,`unlabelled`,`off`,`changed`],he={allow:`Runs freely`,approve:`Asks you first`,deny:`Blocked`,unlabelled:`Not labelled`,off:`Turned off`,changed:`Changed`};function ge(e){return e!==null&&V.includes(e)}function H(e){return e.exposure.disabled?`off`:e.effect===null&&!e.reclassifiedTo?`unlabelled`:e.verdict.kind}function U(e){let t=e.reclassifiedTo??e.effect;return t===`read`||t===`write`||t===`destructive`?t:null}function W(e){return e.standingGrants.some(e=>e.covers)}function _e(e){if(e.exposure.disabled)return`Turned off. Your AI can't see it, and every call to it is blocked.`;if(e.hiddenByPolicy)return`Hidden from your AI, because its description carried hidden instructions.`;let t=e.effect===null&&!e.reclassifiedTo;if(e.unreachable)return`Asks you first, but approvals are switched off, so it can never run.`;if(t)return e.verdict.kind===`approve`?`Asks you first, because nobody has said what it does yet.`:`Blocked, because nobody has said what it does yet.`;if(e.verdict.kind===`deny`)return`Blocked. Your AI can see it, but every call to it is refused.`;let n=e.bounds;return e.verdict.kind===`approve`?n?n.onViolation===`approve`?`Asks you first before it runs. Its inputs also have limits, listed below.`:`Asks you first before it runs, and a call that breaks the limits below is blocked.`:`Asks you first before it runs.`:n?`Runs freely while its inputs stay within the limits below. A call outside them ${ve(n.onViolation)}.`:`Runs freely, without asking anyone.`}function ve(e){return e===`approve`?`asks you first`:`is blocked`}function G(e,t){let n=[];return t&&n.push({key:`changed`,text:`Changed`,tone:`warn`}),e.injection&&e.injection.length>0&&n.push({key:`inj`,text:`Hidden instructions found`,tone:`bad`}),e.unreachable&&n.push({key:`unreach`,text:`Can never run`,tone:`bad`}),e.bounds&&n.push({key:`bounds`,text:`Has limits`,tone:`neutral`}),W(e)&&n.push({key:`grant`,text:`Pre-approved`,tone:`ok`}),n}function ye(e,t){let{ruleId:n,reason:r,kind:i}=e,a=i===`allow`?`runs freely`:i===`approve`?`asks you first`:`is blocked`;return n===`exposure.disabled`?`Someone turned this tool off.`:n.startsWith(`tenant.`)?`The customer check stopped it: ${J(r)}`:n===`defaults.on_unclassified`?`Nobody has said what it does, and your setting for unlabelled tools is that they ${i===`approve`?`ask you first`:`are blocked`}.`:n===`defaults.mode`?t?`No rule mentions it, so your default stance decides. ${j[t].explain}`:`No rule mentions it, so your default stance decides.`:/^rule ".*" \(.*\) says (allow|approve|deny) for /.test(r)?`A rule in your protection settings says it ${a}.`:`A rule in your protection settings says it ${a}, because: “${r}”`}var be={policy:`A rule in your protection settings says what it does.`,annotation:`The connected server describes it this way. Nothing in your settings overrides it.`,name:`Guessed from the tool's name.`,unclassified:`Nobody has said what it does.`},K={max:`At most`,min:`At least`,enum:`Must be one of`,maxLength:`Longest text`,maxItems:`Most items`,within:`Must stay inside folder`,host:`Allowed websites`};function xe(e){return e===`number`||e===`integer`?[`max`,`min`,`enum`]:e===`string`?[`enum`,`maxLength`,`within`,`host`]:e===`array`?[`maxItems`]:e===`boolean`?[`enum`]:[`max`,`min`,`enum`,`maxLength`,`maxItems`,`within`,`host`]}function Se(e){return e.pattern!==void 0||e.coerce!==void 0||e.required!==void 0}function Ce(e){let t=[];e.min!==void 0&&t.push(`at least ${e.min}`),e.max!==void 0&&t.push(`at most ${e.max}`),e.maxLength!==void 0&&t.push(`at most ${e.maxLength} characters`),e.maxItems!==void 0&&t.push(`at most ${e.maxItems} items`),e.sum_max!==void 0&&t.push(`${e.sum_max} in total`),e.count_max!==void 0&&t.push(`in at most ${e.count_max} places`),e.enum&&t.push(`one of ${e.enum.map(String).join(`, `)}`),e.const===null?t.push(`only empty (null)`):e.const!==void 0&&t.push(`exactly ${String(e.const)}`),e.within&&t.push(`inside ${typeof e.within==`string`?e.within:e.within.join(` or `)}`),e.host&&t.push(`a web address on ${e.host.join(`, `)}`),e.pattern&&t.push(`matching a pattern set in the settings file`);let n=t.length?`must be ${t.join(`, `)}`:`is limited`;return e.optional?`${n}, or left out`:n}function q(e){return e?e.paths.map(t=>`${t} ${Ce(e.constraints[t]??{})}`):[]}var we={allow:`Inputs no limit mentions are let through.`,approve:`A call with an input no limit mentions asks you first.`,deny:`A call with an input no limit mentions is blocked.`};function J(e){let t=e.split(/(?<=[.;])\s+/).filter(e=>!/\b(hmcp-gateway|hmcp|npx)\s+[a-z]/i.test(e)&&!/(^|\s)--[a-z][\w-]*/.test(e)),n=(t.length?t:[`The toolbox refused this change.`]).join(` `).replace(/`/g,``);return n.charAt(0).toUpperCase()+n.slice(1)}function Y(e){return J(e instanceof Error?e.message:String(e))}function Te(e){return e instanceof m&&e.status===409}var Ee=`This changed since you opened it. Reload and try again.`;function De(e,t=64){return e.split(`
|
|
2
|
-
`).map(e=>{let n=[],r=``;for(let i of e.split(/\s+/))r&&r.length+i.length+1>t?(n.push(r),r=i):r=r?`${r} ${i}`:i;return n.push(r),n.join(`
|
|
3
|
-
`)}).join(`
|
|
4
|
-
`)}var X=D(),Oe={effect:`What it does (looks, changes or deletes)`,description:`Its description`,"input schema":`The inputs it takes`,annotations:`The hints its server gives about it`};function ke(e){return e.previousKnown?e.changes.length===0?[`Its details changed.`]:e.changes.map(e=>Oe[e]??e):[`Something changed, but the earlier version wasn't kept, so the toolbox can't show what.`]}function Ae({serverId:e,data:t,error:r,loading:i,reload:a,onAccepted:o}){let l=P(),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1);async function v(t){p(!0);try{let n=t?await R(e,t):await L(e);l.show(`ok`,n.accepted.length===1?`Accepted the change to ${n.accepted[0]}.`:`Accepted ${n.accepted.length} changed tools.`),d(null),n.restartNeeded&&(h(`checking`),pe(e).then(h,()=>h(null))),a(),o()}catch(e){l.show(`bad`,`Not accepted. ${Y(e)}`)}finally{p(!1)}}async function y(){_(!0);try{let t=await I(e);l.show(`ok`,`The toolbox restarted. Accepted tools are available again.`),t.warning&&l.show(`warn`,J(t.warning)),h(null),a(),o()}catch(e){l.show(`bad`,`The toolbox didn't restart. ${Y(e)}`)}finally{_(!1)}}if(r&&!t)return(0,X.jsx)(c,{tone:`danger`,title:`Changed tools couldn't be loaded`,actions:(0,X.jsx)(E,{size:`sm`,icon:`refresh`,onClick:a,children:`Try again`}),children:Y(r)});if(!t)return(0,X.jsx)(k,{children:(0,X.jsx)(s,{lines:5})});let S=t.changed;return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[m&&(0,X.jsx)(c,{tone:`warn`,title:`Restart the toolbox to bring accepted tools back`,actions:m!==`checking`&&m.managed&&(0,X.jsx)(E,{variant:`primary`,size:`sm`,icon:`refresh`,loading:g,onClick:()=>void y(),children:`Restart gateway`}),children:m===`checking`?`Checking how this toolbox is running…`:m.managed?`Some accepted tools were held back from your AI. They come back once the toolbox restarts.`:m.externalHint?`Some accepted tools were held back from your AI. ${J(m.externalHint.replace(/\s+--\s+/g,`, `))}`:`Some accepted tools were held back from your AI. They come back the next time the AI app that runs this toolbox starts it again, so restart that app.`}),!t.live&&(0,X.jsx)(c,{tone:`warn`,title:`The toolbox isn't running, so changes can't be checked right now`,children:`The list below is what it reported last time. Changes can be accepted once it is running again.`}),(0,X.jsxs)(k,{title:(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Changed tools `,(0,X.jsx)(w,{term:`changedTools`})]}),actions:S.length>1&&(0,X.jsx)(E,{size:`sm`,variant:`primary`,icon:`check`,disabled:!t.live,onClick:()=>d({tool:null}),children:`Accept all`}),children:[(0,X.jsx)(`p`,{className:`-mt-2 mb-4 text-[13.5px] text-soft`,children:t.onToolChange===`deny`?`A changed tool is held back from your AI until you accept it.`:`A changed tool keeps working, and the change is noted in the activity log until you accept it.`}),S.length===0?(0,X.jsx)(b,{icon:`shield-check`,title:`No tools have changed`,compact:!0,children:`Every tool matches what was accepted before. The toolbox checks again each time it starts and when a connected server updates its list.`}):(0,X.jsx)(`ul`,{className:`space-y-3`,children:S.map(e=>(0,X.jsx)(je,{change:e,live:t.live,loading:i,onAccept:()=>d({tool:e.tool})},e.tool))})]}),t.pins.length>0&&(0,X.jsx)(k,{padded:!1,children:(0,X.jsxs)(`details`,{className:`group p-6`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between gap-3 text-[17px] font-medium tracking-[-0.015em]`,children:[`Reviewed tools`,(0,X.jsx)(`span`,{className:`text-[13px] font-normal text-soft`,children:n(t.pins.length,`tool`)})]}),(0,X.jsx)(`p`,{className:`mt-2 text-[13.5px] text-soft`,children:`The version of each tool that was last accepted. A tool is compared against this every time the toolbox sees it.`}),(0,X.jsx)(`ul`,{className:`mt-3 divide-y divide-faint`,children:t.pins.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-0.5 py-2.5`,children:[(0,X.jsx)(`code`,{className:`font-mono text-[13.5px] break-all`,children:e.tool}),(0,X.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`Accepted `,x(e.pinnedAt),` by `,e.pinnedBy,(0,X.jsx)(`span`,{className:`ml-2 font-mono text-[11px]`,children:e.digest.slice(0,12)})]})]},e.tool))})]})}),(0,X.jsx)(N,{open:u!==null,onClose:()=>d(null),title:u?.tool?`Accept the change to ${u.tool}?`:`Accept all ${S.length} changed tools?`,description:`Accepting means you've looked at what changed and you're fine with it. The new version becomes the one future changes are compared against.`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:()=>d(null),disabled:f,children:`Cancel`}),(0,X.jsx)(E,{variant:`primary`,icon:`check`,loading:f,onClick:()=>void v(u?.tool??null),children:u?.tool?`Accept change`:`Accept all`})]}),children:(0,X.jsxs)(`p`,{className:`text-[14px] text-muted`,children:[`Accepting doesn't change what the tool is allowed to do. Your rules still decide that.`,t.onToolChange===`deny`&&` A tool that was held back becomes available again after the toolbox restarts.`]})})]})}function je({change:t,live:n,loading:r,onAccept:i}){let a=t.was;return(0,X.jsxs)(`li`,{className:`rounded-[20px] border border-line p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`code`,{className:`font-mono text-[14.5px] font-medium break-all`,children:t.tool}),t.withheld?(0,X.jsx)(e,{tone:`bad`,icon:`lock`,children:`Held back until reviewed`}):(0,X.jsx)(e,{tone:`warn`,icon:`refresh`,children:`Changed`})]}),(0,X.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Noticed `,x(t.detectedAt),` · last accepted `,x(t.pinnedAt),` by `,t.pinnedBy]})]}),(0,X.jsx)(E,{size:`sm`,variant:`primary`,icon:`check`,onClick:i,disabled:!n||r,children:`Accept change`})]}),(0,X.jsx)(`ul`,{className:`mt-3 space-y-1`,children:ke(t).map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2 text-[13.5px]`,children:[(0,X.jsx)(`span`,{className:`mt-[8px] h-1.5 w-1.5 shrink-0 rounded-full bg-warn`,"aria-hidden":!0}),e]},e))}),a&&(0,X.jsxs)(`details`,{className:`mt-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`See what changed`}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[a.effect!==t.now.effect&&(0,X.jsxs)(`p`,{className:`text-[13.5px]`,children:[`What it does: `,(0,X.jsx)(`strong`,{children:A[a.effect??`unknown`].label}),` →`,` `,(0,X.jsx)(`strong`,{children:A[t.now.effect??`unknown`].label})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Description`}),(0,X.jsx)(ie,{before:De(a.description),after:De(t.now.description),label:`Description of ${t.tool}, before and after`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Inputs`}),(0,X.jsx)(ie,{before:JSON.stringify(a.inputSchema??{},null,2),after:JSON.stringify(t.now.inputSchema??{},null,2),label:`Inputs of ${t.tool}, before and after`})]}),JSON.stringify(a.annotations)!==JSON.stringify(t.now.annotations)&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1.5 text-[12.5px] font-semibold text-soft`,children:`Hints from its server`}),(0,X.jsx)(ie,{before:JSON.stringify(a.annotations??{},null,2),after:JSON.stringify(t.now.annotations??{},null,2),label:`Hints for ${t.tool}, before and after`})]})]})]})]})}function Me(e){return e?e.surface.neverPublished?`This toolbox hasn't reported its tools yet. Start it once, then you can turn tools off here.`:e.surface.live?null:`The toolbox isn't running, so this list can't be confirmed as current. Start the toolbox to turn tools on or off.`:null}function Ne(e){let t=P(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null),o=Me(e.protection);async function s(n,i,a){r(n.name);try{let r=await _.setExposure(e.serverId,n.name,i,a,e.tenant);return t.show(`ok`,i?`${n.name} is turned off. Your AI can't see it or use it.`:`${n.name} is back on. The normal rules decide what it may do.`),r.warning&&t.show(`warn`,Y(r.warning)),e.onChanged(),!0}catch(e){return t.show(`bad`,`${n.name} was not changed. ${Y(e)}`),!1}finally{r(null)}}function c(e,t,n=``){let r=U(e);!t&&(r===`write`||r===`destructive`)?a({tool:e,reason:n}):s(e,t,n)}let l=i,u=l?l.tool.verdict.kind===`allow`?`run freely, without asking anyone`:l.tool.verdict.kind===`approve`?`ask you first every time`:`still be blocked`:``;return{blocked:o,busy:e=>n===e,set:c,dialog:(0,X.jsx)(N,{open:l!==null,onClose:()=>a(null),title:l?`Turn ${l.tool.name} back on?`:``,description:`Turning a tool on doesn't allow it. It goes back to following your normal rules.`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:()=>a(null),children:`Keep it off`}),(0,X.jsx)(E,{variant:`primary`,icon:`power`,loading:n===l?.tool.name,onClick:async()=>{l&&await s(l.tool,!1,l.reason)&&a(null)},children:`Turn tool on`})]}),children:l&&(0,X.jsxs)(`div`,{className:`space-y-3 text-[14px] text-muted`,children:[(0,X.jsxs)(`p`,{children:[`This tool `,U(l.tool)===`destructive`?`deletes things`:`makes changes`,`. Under your rules today it would `,(0,X.jsx)(`strong`,{className:`text-ink`,children:u}),` (`,ce(l.tool.verdict.kind),`).`]}),(0,X.jsx)(`p`,{children:`The change is written to the activity log and takes effect on the next call.`})]})})}}var Pe=[{value:`deny`,label:`Block them`,hint:`A tool nobody has labelled can't run at all until someone says what it does.`,icon:`x`},{value:`approve`,label:`Ask me first`,hint:`Each call to an unlabelled tool waits for you to approve it, so a new tool is a question rather than a wall.`,icon:`clock`}];function Fe({open:e,serverId:t,tenant:n,protection:r,onClose:i,onSaved:a,onReload:o}){let s=P(),l=r.onUnclassified===`approve`?`approve`:`deny`,[u,d]=(0,B.useState)(l),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),v=r.policyWrite,y=r.surface.unclassifiedCount;async function b(){p(!0),h(null);try{let e=await _.setUnclassifiedPosture(t,u,v.digest,n);s.show(`ok`,u===`approve`?`Unlabelled tools now ask you first. The toolbox applies this within about a second.`:`Unlabelled tools are now blocked. The toolbox applies this within about a second.`),e.warning&&s.show(`warn`,J(e.warning)),a(),i()}catch(e){h({text:Te(e)?Ee:Y(e),stale:Te(e)})}finally{p(!1)}}return(0,X.jsx)(N,{open:e,onClose:i,title:`What happens to unlabelled tools`,description:(0,X.jsxs)(X.Fragment,{children:[`A tool is unlabelled when nobody has said whether it looks, makes changes or deletes.`,` `,y>0?`${y===1?`One tool on this toolbox is`:`${y} tools on this toolbox are`} unlabelled right now.`:`Every tool on this toolbox is labelled right now, so this only affects tools that appear later.`]}),width:560,footer:(0,X.jsxs)(X.Fragment,{children:[m?.stale&&(0,X.jsx)(E,{variant:`ghost`,icon:`refresh`,className:`mr-auto`,onClick:()=>{h(null),o()},children:`Reload`}),(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:f,children:`Cancel`}),(0,X.jsx)(E,{variant:`primary`,onClick:()=>void b(),disabled:!v.ok||u===l,loading:f,children:`Save setting`})]}),children:(0,X.jsxs)(`div`,{className:`space-y-4 text-[14px]`,children:[(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":`What happens to unlabelled tools`,className:`space-y-2`,children:Pe.map(e=>{let t=u===e.value;return(0,X.jsxs)(`label`,{className:F(`flex cursor-pointer gap-3 rounded-[18px] border-[1.5px] p-4 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--focus)]`,t?`border-primary bg-ok-tint`:`border-line hover:border-[var(--soft)]`),children:[(0,X.jsx)(`input`,{type:`radio`,name:`unlabelled`,checked:t,onChange:()=>d(e.value),className:`sr-only`}),(0,X.jsx)(g,{name:e.icon,size:20,strokeWidth:2,className:F(`mt-0.5 shrink-0`,t?`text-ok`:`text-soft`)}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold`,children:[e.label,e.value===l&&(0,X.jsx)(`span`,{className:`text-[12px] font-medium text-soft`,children:`current setting`})]}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[13px] text-soft`,children:e.hint})]})]},e.value)})}),(0,X.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Either way, nothing unlabelled runs without you. Labelling a tool, from its panel, is how it starts following your normal rules. `,(0,X.jsx)(`code`,{className:`font-mono text-[11.5px]`,children:`defaults.on_unclassified`})]}),!v.ok&&(0,X.jsx)(c,{tone:`warn`,title:`This toolbox's settings can't be changed from here`,children:J(v.why??`The settings file is not writable.`)}),m&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:m.text})]})})}var Ie=[`max`,`min`,`enum`,`maxLength`,`maxItems`,`within`,`host`];function Le(e){let t={};for(let[n,r]of Object.entries(e??{})){let e={},i={};for(let[t,n]of Object.entries(r))Ie.includes(t)?e[t]=t===`enum`?n.map(String):n:t!==`optional`&&(i[t]=n);t[n]={values:e,optional:r.optional===!0,carried:i}}return t}function Re(e){return e==null||e===``||Array.isArray(e)&&e.length===0}function ze(e){return Object.values(e).some(e=>Object.values(e.values).some(Re))}function Be(e,t){return e.map(e=>(t===`number`||t===`integer`)&&e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):t===`boolean`&&(e===`true`||e===`false`)?e===`true`:e)}function Ve(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t.args.find(e=>e.name===r)?.type,a={...i.carried};for(let[t,n]of Object.entries(i.values))Re(n)||(a[t]=t===`enum`?Be(n,e):t===`within`?n.trim():n);Object.keys(a).length!==0&&(i.optional&&(a.optional=!0),n[r]=a)}return n}function He({tool:e,draft:t,setDraft:n,onViolation:r,setOnViolation:i,unknownArgs:o,setUnknownArgs:s}){let[c,l]=(0,B.useState)(``),u=[...new Set([...e.args.map(e=>e.name),...Object.keys(t)])],d=(e,r)=>{let i=t[e]??{values:{},optional:!1,carried:{}};n({...t,[e]:r(i)})},p=(e,t,n)=>d(e,e=>{let r={...e.values};return n===void 0?delete r[t]:r[t]=n,{...e,values:r}});return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u.length===0&&(0,X.jsx)(`p`,{className:`rounded-2xl bg-sunken p-4 text-[13.5px] text-soft`,children:`This tool takes no inputs, so there is nothing to limit.`}),(0,X.jsx)(`ul`,{className:`space-y-3`,children:u.map(n=>{let r=e.args.find(e=>e.name===n),i=t[n],a=Object.keys(i?.values??{}),o=xe(r?.type).filter(e=>!a.includes(e));return(0,X.jsxs)(`li`,{className:`rounded-2xl border border-line p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`code`,{className:`font-mono text-[13.5px] font-medium break-all`,children:n}),(0,X.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[r?.type??`any type`,` · `,r?r.required?`required`:`optional`:`nested input`]})]}),r?.description&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[12.5px] text-soft`,children:r.description}),a.length>0&&(0,X.jsx)(`div`,{className:`mt-3 space-y-2.5`,children:a.map(e=>(0,X.jsx)(Ue,{path:n,limit:e,value:i.values[e]??null,onChange:t=>p(n,e,t),onRemove:()=>p(n,e,void 0)},e))}),Object.keys(i?.carried??{}).length>0&&(0,X.jsxs)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:[`Also kept as written in the settings file:`,` `,(0,X.jsx)(`code`,{className:`font-mono`,children:Object.keys(i.carried).join(`, `)})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[o.length>0&&(0,X.jsx)(se,{"aria-label":`Add a limit to ${n}`,value:``,className:`w-56`,onChange:e=>{e&&p(n,e,e===`enum`||e===`host`?[]:e===`within`?``:null)},options:[{value:``,label:`Add a limit…`},...o.map(e=>({value:e,label:K[e]}))]}),a.length>0&&r&&!r.required&&(0,X.jsx)(M,{checked:i?.optional===!0,onChange:e=>d(n,t=>({...t,optional:e})),label:`It's fine to leave this input out`})]})]},n)})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,X.jsx)(a,{label:`Limit a nested input`,className:`min-w-0 flex-1 basis-56`,children:(0,X.jsx)(f,{value:c,onChange:l,mono:!0,placeholder:`items[].qty`,onEnter:()=>m()})}),(0,X.jsx)(E,{icon:`plus`,disabled:c.trim()===``||u.includes(c.trim()),onClick:m,children:`Add input`})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[12.5px] text-soft`,children:`For a value inside a list or object, such as items[].qty.`})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(a,{label:`If a call breaks a limit`,technical:`on_violation`,children:(0,X.jsx)(h,{label:`If a call breaks a limit`,value:r,onChange:i,options:[{value:`deny`,label:`Block it`},{value:`approve`,label:`Ask me`}]})}),(0,X.jsx)(a,{label:`Inputs no limit mentions`,technical:`unknown_args`,children:(0,X.jsx)(h,{label:`Inputs no limit mentions`,value:o,onChange:s,options:[{value:`allow`,label:`Allow`},{value:`approve`,label:`Ask me`},{value:`deny`,label:`Block`}]})})]})]});function m(){let e=c.trim();e&&!u.includes(e)&&(n({...t,[e]:{values:{max:null},optional:!1,carried:{}}}),l(``))}}function Ue({path:e,limit:n,value:r,onChange:a,onRemove:o}){let s=`${K[n]} (${e})`,c;return c=n===`enum`||n===`host`?(0,X.jsx)(t,{"aria-label":s,value:r??[],onChange:a,placeholder:n===`host`?`example.com, or .example.com for every address under it`:`Type a value and press Enter`,validate:n===`host`?e=>/[\s/:]/.test(e)?`Type just the website name, such as example.com`:null:void 0}):n===`within`?(0,X.jsx)(f,{"aria-label":s,value:r??``,onChange:a,mono:!0,placeholder:`/Users/you/project`}):(0,X.jsx)(i,{"aria-label":s,value:r??null,onChange:a,min:n===`maxLength`?1:n===`maxItems`?0:void 0,step:n===`maxLength`||n===`maxItems`?1:void 0,unit:n===`maxLength`?`chars`:n===`maxItems`?`items`:void 0}),(0,X.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-start gap-x-2 gap-y-1 sm:grid-cols-[176px_1fr_auto] sm:items-center`,children:[(0,X.jsx)(`span`,{className:`col-span-2 text-[13px] font-semibold sm:col-span-1`,children:K[n]}),(0,X.jsx)(`div`,{className:`min-w-0`,children:c}),(0,X.jsx)(oe,{icon:`x`,label:`Remove ${K[n].toLowerCase()} from ${e}`,size:34,onClick:o})]})}var We=[{value:`read`,label:`Looks only`,hint:`Reads or looks things up. Changes nothing.`,icon:`eye`},{value:`write`,label:`Makes changes`,hint:`Creates, edits, sends or adds something.`,icon:`edit`},{value:`destructive`,label:`Deletes`,hint:`Removes something, or does what can't be undone.`,icon:`trash`}],Ge=[{value:`allow`,label:`Run freely`,hint:`Nobody is asked.`,icon:`check`},{value:`approve`,label:`Ask me first`,hint:`Every call waits for you to approve it.`,icon:`clock`},{value:`deny`,label:`Block it`,hint:`Every call is refused.`,icon:`x`}];function Ke({open:e,serverId:t,tenant:n,tool:r,protection:i,onClose:o,onSaved:s}){let l=P(),[u,d]=(0,B.useState)(U(r)),[p,m]=(0,B.useState)(U(r)===null?null:r.verdict.kind),[h,g]=(0,B.useState)(``),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(()=>Le(r.bounds?.constraints)),[S,C]=(0,B.useState)(r.bounds?.onViolation??`deny`),[ee,ne]=(0,B.useState)(r.bounds?.unknownArgs??`allow`),[T,ie]=(0,B.useState)(!1),[ae,oe]=(0,B.useState)(!1),[se,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(null),[le,A]=(0,B.useState)(null),[ue,j]=(0,B.useState)(0),[M,de]=(0,B.useState)(!1),[F,fe]=(0,B.useState)(null),[I,L]=(0,B.useState)(null),pe=Object.values((O?.preview.bounds??r.bounds)?.constraints??{}).some(e=>Se(e)),R=(0,B.useMemo)(()=>{if(!u||!p)return null;let e={tool:r.name,effect:u,decision:p};return h.trim()&&(e.reason=h.trim()),v&&(e.args=Ve(b,r),e.on_violation=S,e.unknown_args=ee),e},[r,u,p,h,v,b,S,ee]),z=te(R?JSON.stringify(R):``,350);(0,B.useEffect)(()=>{if(!e||!z){k(null);return}let r=!0;return A(null),_.toolRulePreview(t,JSON.parse(z),n).then(e=>{r&&(k({key:z,preview:e}),v||(x(Le(e.bounds?.constraints)),C(e.bounds?.onViolation??`deny`),ne(e.bounds?.unknownArgs??`allow`)))}).catch(e=>r&&A(Y(e))),()=>{r=!1}},[e,z,t,n,ue]);let me=R?JSON.stringify(R):``,V=O&&O.key===me?O.preview:null,he=V!==null,ge=O?.preview??null,H=ge?ge.bounds:r.bounds,W=V?.overriddenReason!=null,_e=W&&V?.overridesAllowed===!1,ve=V?.dropsBounds!=null,G=u===`destructive`&&p===`allow`,ye=v&&ze(b),be=V?.writable.ok===!1,K=V!==null&&he&&!le&&!M&&!be&&!_e&&!ye&&(!W||T)&&(!ve||ae)&&(!G||se);async function xe(){if(V&&R){de(!0),fe(null);try{let e=await _.setToolRule(t,{...R,expectedDigest:V.expectedDigest,acknowledged:{...W?{overrideDeny:V.overriddenReason.ruleId}:{},...ve?{dropBounds:!0}:{},...G?{destructiveAllow:!0}:{}}},n);L({yaml:e.yaml,reloads:V.reloads}),l.show(`ok`,`Saved what ${r.name} may do.`),e.warning&&l.show(`warn`,J(e.warning)),s()}catch(e){Te(e)?(fe({text:Ee,stale:!0}),k(null),j(e=>e+1)):fe({text:Y(e),stale:!1})}finally{de(!1)}}}if(I)return(0,X.jsx)(N,{open:e,onClose:o,title:`Saved`,width:600,footer:(0,X.jsx)(E,{variant:`primary`,onClick:o,children:`Close`}),children:(0,X.jsxs)(`div`,{className:`space-y-4 text-[14px]`,children:[(0,X.jsxs)(`p`,{className:`text-muted`,children:[`The rule for `,(0,X.jsx)(`code`,{className:`font-mono text-ink`,children:r.name}),` is in your protection settings.`,` `,I.reloads?`The running gateway applies it within about a second. No restart is needed.`:`This toolbox only reads its settings when it starts, so restart it to apply this.`]}),(0,X.jsxs)(`details`,{className:`group`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show what was written`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(re,{label:`The rule that was written`,children:I.yaml})})]})]})});let Ce=V?.approvalsReachable===!1;return(0,X.jsx)(N,{open:e,onClose:o,title:(0,X.jsxs)(X.Fragment,{children:[`Change what `,(0,X.jsx)(`span`,{className:`font-mono text-[0.9em]`,children:r.name}),` may do`]}),description:`Your answer is saved as a rule in your protection settings.`,width:720,footer:(0,X.jsxs)(X.Fragment,{children:[F?.stale&&(0,X.jsx)(E,{variant:`ghost`,icon:`refresh`,onClick:()=>j(e=>e+1),className:`mr-auto`,children:`Reload preview`}),(0,X.jsx)(E,{variant:`secondary`,onClick:o,disabled:M,children:`Cancel`}),(0,X.jsx)(E,{variant:`primary`,onClick:()=>void xe(),disabled:!K,loading:M,children:`Save rule`})]}),children:(0,X.jsxs)(`div`,{className:`space-y-6 pb-1 text-[14px]`,children:[i?.tenant&&(0,X.jsx)(c,{tone:`info`,title:`This applies to every customer`,children:`A rule changes the protection settings, which every customer of this toolbox shares. Turning a tool off is the only change kept for one customer.`}),r.injection&&r.injection.length>0&&(0,X.jsx)(c,{tone:`danger`,title:`Judge this tool by its name and inputs`,children:`Its description carried hidden instructions written to steer whoever reads it, so it isn't repeated here.`}),(0,X.jsx)(qe,{legend:`What does this tool do?`,name:`rule-effect`,value:u,onChange:d,options:We}),(0,X.jsx)(qe,{legend:`What should happen when your AI uses it?`,name:`rule-decision`,value:p,onChange:m,options:Ge.map(e=>e.value===`approve`&&Ce?{...e,disabled:!0,hint:`Approvals are switched off on this toolbox, so nobody could answer.`}:e)}),(0,X.jsxs)(`section`,{className:`rounded-[20px] bg-sunken/60 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[`Limits on its inputs `,(0,X.jsx)(w,{term:`limits`})]}),(0,X.jsx)(`p`,{className:`mt-1 text-[13px] text-soft`,children:pe?`These limits include one written into the settings file by hand that can't be edited here. They are kept exactly as they are.`:v?`Set the values this tool may be called with.`:H?ge?.carriedFrom?`Carried over from the rule ${ge.carriedFrom}, which governs it today: ${q(H).join(`; `)}.`:`Kept as they are: ${q(H).join(`; `)}.`:`None. Every input is passed on as your AI sends it.`})]}),!v&&!pe&&(0,X.jsx)(E,{size:`sm`,icon:H?`edit`:`plus`,onClick:()=>y(!0),children:H?`Edit limits`:`Add limits on its inputs`})]}),v&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(He,{tool:r,draft:b,setDraft:x,onViolation:S,setOnViolation:C,unknownArgs:ee,setUnknownArgs:ne}),ye&&(0,X.jsx)(`p`,{className:`mt-3 text-[13px] font-medium text-warn`,children:`Fill in every limit you added, or remove it.`})]})]}),(0,X.jsx)(a,{label:`Reason`,optional:!0,help:`Saved with the rule and in the activity log. When a call is blocked, your AI is told this reason.`,children:(0,X.jsx)(f,{value:h,onChange:g,placeholder:`For example: finance signs these off by hand`})}),(0,X.jsx)(Je,{tool:r,preview:V,loading:R!==null&&V===null&&!le,error:le,incomplete:R===null}),V&&he&&(0,X.jsxs)(`div`,{className:`space-y-3`,children:[be&&(0,X.jsx)(c,{tone:`warn`,title:`This toolbox's settings can't be changed from here`,children:J(V.writable.why??`The settings file is not writable.`)}),_e?(0,X.jsxs)(c,{tone:`info`,title:`This toolbox doesn't allow reversing a rule from here`,children:[`The rule `,(0,X.jsx)(`code`,{className:`font-mono`,children:V.overriddenReason.ruleId}),` stays as it is. It can only be changed in the settings file itself.`]}):W&&(0,X.jsxs)(Ze,{title:`This reverses a rule somebody wrote`,checked:T,onChange:ie,label:`Reverse the rule ${V.overriddenReason.ruleId} anyway`,children:[`The rule `,(0,X.jsx)(`code`,{className:`font-mono`,children:V.overriddenReason.ruleId}),` says`,` `,(0,X.jsx)(`strong`,{children:ce(V.overriddenReason.decision).toLowerCase()}),` for this tool`,V.overriddenReason.reason?(0,X.jsxs)(X.Fragment,{children:[`, because: “`,V.overriddenReason.reason,`”`]}):`.`]}),ve&&(0,X.jsxs)(Ze,{title:`This removes the limits on its inputs`,checked:ae,onChange:oe,label:`Remove the limits on its inputs`,children:[`Today: `,q(V.currentBounds).join(`; `)||`limited`,`. After this, nothing checks what the tool is called with.`]}),G&&(0,X.jsx)(Ze,{title:`Your AI could delete things without asking`,checked:se,onChange:D,label:`Let a tool that deletes things run with nobody asked`,children:`“Ask me first” keeps it just as usable, with you approving each call.`})]}),F&&(0,X.jsx)(c,{tone:`danger`,role:`alert`,title:F.stale?`Not saved`:`The toolbox refused this change`,children:F.text})]})})}function qe({legend:e,name:t,value:n,onChange:r,options:i}){return(0,X.jsxs)(`fieldset`,{children:[(0,X.jsx)(`legend`,{className:`mb-2.5 text-[15px] font-semibold`,children:e}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:i.map(e=>{let i=n===e.value;return(0,X.jsxs)(`label`,{className:F(`relative flex cursor-pointer flex-col gap-1 rounded-[18px] border-[1.5px] p-3.5 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--focus)]`,i?`border-primary bg-ok-tint`:`border-line hover:border-[var(--soft)]`,e.disabled&&`cursor-not-allowed opacity-55`),children:[(0,X.jsx)(`input`,{type:`radio`,name:t,value:e.value,checked:i,disabled:e.disabled,onChange:()=>r(e.value),className:`sr-only`}),(0,X.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold`,children:[(0,X.jsx)(g,{name:e.icon,size:17,strokeWidth:2,className:i?`text-ok`:`text-soft`}),e.label,i&&(0,X.jsx)(g,{name:`check`,size:16,strokeWidth:2.4,className:`ml-auto text-ok`})]}),(0,X.jsx)(`span`,{className:`text-[12.5px] leading-snug text-soft`,children:e.hint})]},e.value)})})]})}function Je({tool:e,preview:t,loading:n,error:r,incomplete:i}){return(0,X.jsxs)(`section`,{"aria-live":`polite`,className:`rounded-[20px] border-[1.5px] border-line p-4`,children:[(0,X.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:`What changes`}),i?(0,X.jsx)(`p`,{className:`mt-2 text-[13.5px] text-soft`,children:`Answer both questions above to see what changes.`}):r?(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-[13.5px] font-medium text-bad`,children:r}):n||!t?(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(s,{lines:3})}):(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,X.jsx)(`span`,{className:`text-[13px] text-soft`,children:`Now`}),(0,X.jsx)(T,{decision:t.current.kind}),(0,X.jsx)(g,{name:`arrow-right`,size:18,className:`text-soft`,label:`becomes`}),(0,X.jsx)(`span`,{className:`text-[13px] text-soft`,children:`After`}),(0,X.jsx)(T,{decision:t.verdict.kind})]}),(0,X.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:Ye(e.name,t)}),(0,X.jsx)(Xe,{preview:t}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the rule that will be written`}),(0,X.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,X.jsx)(re,{label:`The rule that will be written`,children:t.yaml}),t.policyPath&&(0,X.jsx)(`p`,{className:`font-mono text-[11.5px] break-all text-soft`,children:t.policyPath})]})]})]})]})}function Ye(e,t){let n=`After saving, every call to ${e} ${t.verdict.kind===`allow`?`runs freely`:t.verdict.kind===`approve`?`asks you first`:`is blocked`}`;return t.bounds&&t.verdict.kind!==`deny`?n+=` while its inputs stay within limits (${q(t.bounds).join(`; `)}). A call outside them ${t.bounds.onViolation===`approve`?`asks you first`:`is blocked`}. ${we[t.bounds.unknownArgs]}`:n+=`.`,n}function Xe({preview:e}){let t=[];return e.loosens&&t.push({key:`loosens`,tone:`warn`,text:`This lets your AI do more with this tool than it can today. The safety check will point this out if a tool that changes or deletes things runs without asking.`}),e.overridden&&t.push({key:`overridden`,tone:`warn`,text:J(e.overridden)}),e.nameContradiction&&t.push({key:`name`,tone:`warn`,text:J(e.nameContradiction)}),e.strandedRule&&t.push({key:`stranded`,tone:`info`,text:(0,X.jsxs)(X.Fragment,{children:[`The rule `,(0,X.jsx)(`code`,{className:`font-mono`,children:e.strandedRule}),` no longer applies to any tool after this. It stays in your settings, and undoing this change brings it back.`]})}),e.reloads||t.push({key:`reload`,tone:`info`,text:`This toolbox only reads its settings when it starts, so this applies after a restart.`}),t.length===0?null:(0,X.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,X.jsxs)(`li`,{className:F(`flex gap-2.5 rounded-2xl px-3.5 py-2.5 text-[13px]`,e.tone===`warn`?`bg-warn-tint`:`bg-info-tint`),children:[(0,X.jsx)(g,{name:e.tone===`warn`?`warning`:`info`,size:16,strokeWidth:2,className:F(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,X.jsx)(`span`,{className:`text-ink`,children:e.text})]},e.key))})}function Ze({title:e,children:t,checked:n,onChange:r,label:i}){return(0,X.jsxs)(`div`,{className:`rounded-[18px] border-[1.5px] border-bad/45 bg-bad-tint/50 p-4`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-2 font-semibold text-bad`,children:[(0,X.jsx)(g,{name:`warning`,size:17,strokeWidth:2}),e]}),(0,X.jsx)(`div`,{className:`mt-1 text-[13.5px] text-muted`,children:t}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(M,{checked:n,onChange:r,label:i})})]})}var Qe=[`read`,`write`,`destructive`,`unsure`,`off`],$e={read:`Looks at things`,write:`Makes changes`,destructive:`Deletes or overwrites`,unsure:`We're not sure what it does`,off:`Turned off`};function Z(e){let t=H(e);return t===`off`?`off`:t===`unlabelled`?`unsure`:U(e)??`unsure`}function et(e){return Qe.map(t=>({key:t,tools:e.filter(e=>Z(e)===t)})).filter(e=>e.tools.length>0)}function tt(e){return`${e} ${e===1?`tool`:`tools`}`}function nt(e,t){if(e.exposure.disabled)return`off`;if(t.withheld?.has(e.name))return`held`;if(e.hiddenByPolicy)return`hidden`;let n=e.verdict.kind,r=W(e);return t.observe?n===`allow`?`allow`:n===`deny`?`would-deny`:e.unreachable&&!r?`would-never`:`would-approve`:n===`deny`?`deny`:n===`approve`?r?t.approvalsOff?`granted-only`:`granted`:e.unreachable||t.approvalsOff?`never`:`approve`:e.bounds?`limited`:`allow`}var rt={off:`Turned off`,held:`Held back: it changed since you approved it`,hidden:`Hidden: had hidden instructions`,never:`Can never run`,deny:`Blocked`,approve:`Asks you first`,granted:`Pre-approved within limits`,"granted-only":`Pre-approved calls only; others can never run`,limited:`Runs within limits`,allow:`Runs freely`,"would-deny":`Would be blocked`,"would-approve":`Would ask you first`,"would-never":`Would never run`},it=new Set([`off`,`held`,`hidden`,`never`,`deny`]);function at(e,t){return it.has(nt(e,t))}function ot(e,t){return rt[nt(e,t)]}function st(e,t){let n=nt(e,t);return n===`allow`||n===`limited`?`ok`:n===`approve`||n===`granted`||n===`granted-only`?`warn`:n===`off`||n.startsWith(`would-`)?`soft`:`bad`}var ct=[`allow`,`limited`,`granted`,`granted-only`,`approve`,`would-approve`,`would-never`,`would-deny`,`never`,`deny`,`held`,`hidden`,`off`],lt={allow:[`runs freely`,`run freely`],limited:[`runs within limits`,`run within limits`],granted:[`pre-approved`,`pre-approved`],"granted-only":[`runs only pre-approved calls`,`run only pre-approved calls`],approve:[`asks you first`,`ask you first`],"would-approve":[`would ask you first`,`would ask you first`],"would-never":[`would never run`,`would never run`],"would-deny":[`would be blocked`,`would be blocked`],never:[`can never run`,`can never run`],deny:[`blocked`,`blocked`],held:[`held back`,`held back`],hidden:[`hidden`,`hidden`],off:[`turned off`,`turned off`]},ut=(e,t)=>e.map(e=>nt(e,t));function dt(e){let t=new Set(e);return t.size===1?[...t][0]:null}function ft(e,t){let n=new Map;for(let r of ut(e,t))n.set(r,(n.get(r)??0)+1);return ct.filter(e=>n.has(e)).map(e=>{let t=n.get(e);return`${t} ${lt[e][t===1?0:1]}`}).join(`, `)}var pt=e=>e.every(e=>e===`allow`||e.startsWith(`would-`));function mt(e,t){let n=t?`it`:`they`;switch(e){case`allow`:return`, so ${n} ${t?`runs`:`run`} freely`;case`approve`:return`, so ${n} ${t?`asks`:`ask`} you first`;case`deny`:return t?`, so it's blocked`:`, so they're blocked`;case`never`:return`, so ${n} can never run`;case`would-approve`:return`. ${t?`It runs`:`They run`} for now, and would ask you first`;case`would-deny`:return`. ${t?`It runs`:`They run`} for now, and would be blocked`;default:return null}}function ht(e,t,n){let r=t.length===1;if(e===`off`)return r?`Your AI can't see it or use it`:`Your AI can't see or use these`;let i=ut(t,n),a=dt(i);if(e===`unsure`){let e=r?`We're not sure what this does`:`We're not sure what these do`,i=a?mt(a,r):null;return i?`${e}${i}`:a?`${e}. ${rt[a]}`:`${e}. Mixed: ${ft(t,n)}`}let o=n.observe&&pt(i)&&i.some(e=>e.startsWith(`would-`));return a?o?`Runs for now; ${rt[a].toLowerCase()}`:rt[a]:`${o?`Runs for now. `:``}Mixed: ${ft(t,n)}`}var gt=[`inj`,`unreach`,`changed`,`bounds`,`grant`],_t={inj:e=>`${e} with hidden instructions`,unreach:e=>`${e} can never run`,changed:e=>`${e} changed`,bounds:e=>`${e} ${e===1?`has`:`have`} limits`,grant:e=>`${e} pre-approved`};function vt(e,t){let n=new Map;for(let r of e)for(let e of G(r,t.has(r.name)))n.set(e.key,{n:(n.get(e.key)?.n??0)+1,tone:e.tone});return gt.filter(e=>n.has(e)).map(e=>({key:e,text:_t[e](n.get(e).n),tone:n.get(e).tone}))}function Q(e,t,n,r=0){let i=[];return e&&i.push(e===1?`the one tool that's turned off`:`the ${e} tools that are turned off`),r&&i.push(r===1?`the one tool held back because it changed`:`the ${r} tools held back because they changed`),t&&i.push(t===1?`the one tool hidden for carrying hidden instructions`:`the ${t} tools hidden for carrying hidden instructions`),n&&i.push(n===1?`the one tool we're not sure about`:`the ${n} tools we're not sure about`),i.length?`Apart from ${i.join(` and `)}, `:``}function yt(e,t){let n=e.length,r=e.filter(e=>e.verdict.ruleId.startsWith(`tenant.`)).length,i=e.filter(e=>e.verdict.ruleId===`defaults.mode`).length;return r===n?`, because the toolbox needs to know which customer each call is for`:r>0?`, because of the customer check and your other settings`:i===n?t?`, because your default stance is “${j[t].label}”`:`, because of your default stance`:i===0?` by rules in your protection settings`:`, because of your default stance and your rules`}function bt(e){let t=dt(e.map(e=>e.bounds?.onViolation??null));return t?`a call outside them ${ve(t)}`:`what happens outside them depends on the tool`}function xt(e,t,n){let r=t.filter(e=>Z(e)===`off`),i=t.filter(e=>Z(e)!==`off`),a=i.filter(e=>n.withheld?.has(e.name)),o=i.filter(e=>!n.withheld?.has(e.name)),s=o.filter(e=>e.hiddenByPolicy),c=o.filter(e=>!e.hiddenByPolicy&&Z(e)===`unsure`),l=o.filter(e=>!e.hiddenByPolicy&&Z(e)!==`unsure`),u=e=>nt(e,n),d=(e,t)=>e?t:t[0].toUpperCase()+t.slice(1);if(l.length===0&&c.length===0)return s.length===0&&a.length===0?`Every tool from ${e} is turned off.`:r.length===0&&a.length===0?`Every tool from ${e} is hidden, because their descriptions carried hidden instructions.`:`Nothing from ${e} can run: its tools are turned off, hidden or held back.`;if(n.observe){let t=Q(r.length,s.length,0,a.length);return`${t}${d(t,`everything`)} from ${e} runs for now, because your toolbox is only watching.`}if(l.length===0){let t=Q(r.length,s.length,0,a.length),n=dt(c.map(u)),i=n===`allow`||n===`approve`||n===`deny`||n===`never`?mt(n,!1):null;return`${t}${d(t,`we're`)} not sure what ${e}'s tools do${i??` yet`}.`}let f=l.map(u),p=dt(f),m=e=>c.filter(t=>!e(u(t))).length;if(f.every(e=>e===`deny`||e===`never`)){let t=Q(0,0,m(e=>it.has(e)));return p===`deny`?`${t}${d(t,`everything`)} from ${e} is blocked${yt(l,n.stance)}.`:p===`never`?`${t}${d(t,`everything`)} from ${e} would ask you first, but approvals are switched off, so none of it can run.`:`${t}${d(t,`nothing`)} from ${e} can run: ${ft(l,n)}.`}let h=l.filter(e=>Z(e)===`read`),g=l.filter(e=>Z(e)!==`read`),_=dt(h.map(u)),v=dt(g.map(u)),y=_===`allow`?`can look at things freely`:_===`limited`?`can look at things within limits you set (${bt(h)})`:null,b=g.length===0?``:v===`approve`?`; anything that changes something asks you first`:v===`granted`?`; anything that changes something asks you first, apart from calls you pre-approved`:v===`granted-only`?`; anything that changes something runs only if you pre-approved it, because approvals are switched off`:v===`deny`?`; anything that changes something is blocked`:v===`never`?`; anything that changes something can never run, because approvals are switched off`:null;if(h.length>0&&y&&b!==null)return`${Q(r.length,s.length,c.length,a.length)}${e} ${y}${b}.`;if(p===`allow`||p===`approve`){let t=Q(r.length,s.length,m(e=>e===p),a.length),i=p===`allow`?`runs freely, without asking you`:`asks you first`;return`${t}${d(t,`everything`)} from ${e} ${i}${yt(l,n.stance)}.`}if(p===`limited`){let t=Q(r.length,s.length,c.length,a.length);return`${t}${d(t,`everything`)} from ${e} runs freely within limits you set; ${bt(l)}.`}if(p===`granted`){let t=Q(r.length,s.length,c.length,a.length);return`${t}${d(t,`everything`)} from ${e} asks you first, apart from calls you pre-approved.`}if(p===`granted-only`){let t=Q(r.length,s.length,c.length,a.length);return`${t}${d(t,`everything`)} from ${e} runs only calls you pre-approved, because approvals are switched off.`}return`${Q(r.length,s.length,c.length,a.length)}${e}'s tools are mixed: ${ft(l,n)}.`}function St(e,t){let n=t.trim().toLowerCase();return!n||`${z(e.name).label} ${e.name} ${e.description}`.toLowerCase().includes(n)}function Ct(e,t,n,r=[],i=new Set){let a=t.trim()!==``,o=new Set(e.map(e=>e.upstream));if(!a)for(let e of r)o.add(e);return[...o].sort((e,t)=>e.localeCompare(t)).flatMap(r=>{let a=e.filter(e=>e.upstream===r);if(a.length===0)return[{name:r,why:``,groups:[]}];let o=a.filter(e=>St(e,t)).sort((e,t)=>e.name.localeCompare(t.name));if(o.length===0)return[];let s=et(o).map(e=>{let t=vt(e.tools,i);return{key:e.key,label:$e[e.key],count:tt(e.tools.length),status:ht(e.key,e.tools,n),flags:t,urgent:t.some(e=>e.tone===`bad`),tools:e.tools}});return[{name:r,why:xt(r,a,n),groups:s}]})}function wt({tools:e,changed:t,selected:n,onOpen:r,exposure:i}){return(0,X.jsx)(`ul`,{className:`divide-y divide-faint`,children:e.map(e=>(0,X.jsx)(Et,{tool:e,changed:t.has(e.name),selected:n===e.name,onOpen:()=>r(e.name),exposure:i},e.name))})}var Tt={read:`bg-ok-tint`,write:`bg-warn-tint`,destructive:`bg-bad-tint`,unknown:`bg-sunken`};function Et({tool:t,changed:n,selected:r,onOpen:i,exposure:a}){let o=H(t),s=U(t),c=t.exposure.disabled;return(0,X.jsxs)(`li`,{onClick:i,className:F(`-mx-3 flex cursor-pointer flex-wrap items-center gap-x-4 gap-y-2 rounded-2xl px-3 py-3.5 transition-colors hover:bg-faint/70 sm:flex-nowrap`,r&&`bg-faint`),children:[(0,X.jsx)(`span`,{className:F(`grid h-11 w-11 shrink-0 place-items-center rounded-full`,Tt[s??`unknown`],c&&`opacity-50`),title:A[s??`unknown`].label,children:(0,X.jsx)(C,{effect:s})}),(0,X.jsxs)(`div`,{className:F(`min-w-0 flex-1 basis-[calc(100%-64px)] sm:basis-auto`,c&&`opacity-70`),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`max-w-full truncate rounded font-mono text-[14px] font-medium text-ink hover:underline`,"aria-label":`Open ${t.name}`,children:t.name}),(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-soft`,children:[`on `,t.upstream]})]}),(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[13px] text-soft`,children:At(t.description)||(0,X.jsx)(`span`,{className:`italic`,children:`No description`})}),(0,X.jsx)(kt,{tool:t,changed:n})]}),(0,X.jsxs)(`div`,{className:`ml-[60px] flex min-w-0 flex-wrap items-center gap-2 sm:ml-0 sm:shrink-0 sm:flex-nowrap`,children:[o===`off`?(0,X.jsx)(e,{tone:`neutral`,icon:`power`,children:`Turned off`}):o===`unlabelled`?(0,X.jsx)(e,{tone:t.verdict.kind===`approve`?`warn`:`bad`,icon:`help`,title:`Nobody has said what this tool does yet`,children:t.verdict.kind===`approve`?`Not labelled · asks`:`Not labelled · blocked`}):(0,X.jsx)(T,{decision:t.verdict.kind}),(0,X.jsx)(Dt,{tool:t,exposure:a})]})]})}function Dt({tool:e,exposure:t}){let n=e.exposure.disabled;return(0,X.jsx)(E,{size:`sm`,variant:`ghost`,icon:`power`,loading:t.busy(e.name),disabled:t.blocked!==null,title:t.blocked??void 0,onClick:r=>{r.stopPropagation(),t.set(e,!n)},"aria-label":`${n?`Turn on`:`Turn off`} ${e.name}`,className:`justify-center sm:w-[104px]`,children:n?`Turn on`:`Turn off`})}var Ot={changed:`refresh`,inj:`warning`,unreach:`lock`,bounds:`sliders`,grant:`key`};function kt({tool:t,changed:n}){let r=G(t,n);return r.length===0?null:(0,X.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:r.map(t=>(0,X.jsx)(e,{tone:t.tone,icon:Ot[t.key],className:`py-0 text-[11.5px]`,children:t.text},t.key))})}function At(e){let t=/^\[description withheld by hmcp-gateway: it contained text that ([^\]]+)\]/.exec(e);return t?`Description hidden from your AI: it contained text that ${t[1]}.`:e}function jt({protection:e,tools:t,query:n,onClearQuery:r,changed:i,selected:a,onOpen:o,exposure:c,configured:l,withheld:u,connectionsHref:d,onPosture:f}){let[p,m]=(0,B.useState)(()=>new Map),h=e?.defaults.mode??null,_=e?.enforcement===`observe`,v=e?.approvals?.mode===`deny`,y=(0,B.useMemo)(()=>({observe:_,approvalsOff:v,withheld:u}),[_,v,u]),x=(0,B.useMemo)(()=>Ct(t,n,{stance:h,...y},l,i),[t,n,h,y,l,i]);if(!e)return(0,X.jsx)(k,{children:(0,X.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,X.jsx)(s,{lines:2}),(0,X.jsx)(s,{lines:3})]})});if(t.length===0)return(0,X.jsx)(k,{children:(0,X.jsx)(b,{icon:`tool`,title:`No tools yet`,children:e.surface.neverPublished?`Start the toolbox once and the tools its connected servers offer will appear here.`:`The connected servers on this toolbox don't offer any tools.`})});if(x.length===0)return(0,X.jsx)(k,{children:(0,X.jsx)(b,{icon:`search`,title:`No tools match`,compact:!0,actions:(0,X.jsx)(E,{onClick:r,children:`Clear search`}),children:`Nothing on this toolbox matches what you typed.`})});let S=n.trim()!==``;return(0,X.jsx)(`div`,{className:`space-y-5`,children:x.map(e=>(0,X.jsx)(k,{title:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,X.jsx)(g,{name:`server`,size:20,className:`text-soft`}),e.name]}),children:e.groups.length===0?(0,X.jsxs)(`p`,{className:`text-[14.5px] text-muted`,children:[`No tools listed yet. If it should have some, it may not have connected:`,` `,(0,X.jsx)(`a`,{href:d,className:`font-semibold underline underline-offset-2`,children:`check it on Connections`}),`.`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-[14.5px] text-muted`,children:e.why}),(0,X.jsx)(`ul`,{className:`mt-3 divide-y divide-faint`,children:e.groups.map(t=>{let n=`${e.name}\n${t.key}`,r=S||(p.get(n)??t.urgent);return(0,X.jsx)(Mt,{group:t,open:r,forced:S,onToggle:()=>m(e=>new Map(e).set(n,!r)),changed:i,selected:a,onOpen:o,exposure:c,status:y,onPosture:f},t.key)})})]})},e.name))})}function Mt({group:t,open:n,forced:r,onToggle:i,changed:a,selected:o,onOpen:s,exposure:c,status:l,onPosture:u}){let d=(0,B.useId)(),f=t.key===`read`||t.key===`write`||t.key===`destructive`?t.key:null;return(0,X.jsxs)(`li`,{className:`py-1`,children:[(0,X.jsxs)(`div`,{className:`-mx-3 flex items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":n,disabled:r,"aria-controls":d,title:r?`Every group is open while you search. Clear the search to fold them.`:void 0,onClick:i,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 rounded-2xl px-3 py-3 text-left transition-colors enabled:hover:bg-faint/70`,children:[(0,X.jsx)(g,{name:`chevron`,size:18,className:F(`shrink-0 text-soft transition-transform`,!n&&`-rotate-90`)}),(0,X.jsx)(`span`,{className:F(`grid h-9 w-9 shrink-0 place-items-center rounded-full`,Tt[f??`unknown`]),children:t.key===`off`?(0,X.jsx)(g,{name:`power`,size:16,className:`text-soft`}):(0,X.jsx)(C,{effect:f})}),(0,X.jsx)(`span`,{className:`font-semibold text-ink`,children:t.label}),(0,X.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.count}),(0,X.jsx)(`span`,{className:`basis-full pl-[66px] text-[13.5px] text-muted sm:ml-auto sm:basis-auto sm:pl-0 sm:text-right`,children:t.status}),t.flags.length>0&&(0,X.jsx)(`span`,{className:`flex basis-full flex-wrap gap-1.5 pl-[66px]`,children:t.flags.map(t=>(0,X.jsx)(e,{tone:t.tone,icon:Ot[t.key],className:`py-0 text-[11.5px]`,children:t.text},t.key))})]}),t.key===`unsure`&&(0,X.jsx)(E,{size:`sm`,variant:`ghost`,onClick:u,"aria-label":`Change what happens to tools we're not sure about`,children:`Change`})]}),(0,X.jsx)(`ul`,{id:d,hidden:!n,className:`mb-2 divide-y divide-faint pl-8`,children:t.tools.map(e=>(0,X.jsx)(Pt,{tool:e,changed:a.has(e.name),selected:o===e.name,onOpen:()=>s(e.name),exposure:c,status:l},e.name))})]})}var Nt={ok:`text-ok`,warn:`text-warn`,bad:`text-bad`,soft:`text-soft`};function Pt({tool:e,changed:t,selected:n,onOpen:r,exposure:i,status:a}){let o=z(e.name).label;return(0,X.jsxs)(`li`,{onClick:r,className:F(`-mx-3 flex cursor-pointer flex-wrap items-center gap-x-4 gap-y-2 rounded-2xl px-3 py-3 transition-colors hover:bg-faint/70 sm:flex-nowrap`,n&&`bg-faint`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-full sm:basis-auto`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},className:`max-w-full truncate rounded text-left text-[14.5px] font-medium text-ink hover:underline`,"aria-label":`Open ${o} (${e.name})`,children:o}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-[12px] text-soft`,children:e.name}),(0,X.jsx)(kt,{tool:e,changed:t})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:F(`text-[13.5px] font-semibold`,Nt[st(e,a)]),children:ot(e,a)}),at(e,a)?(0,X.jsx)(E,{size:`sm`,variant:`ghost`,icon:`sliders`,onClick:e=>{e.stopPropagation(),r()},"aria-label":`Change what ${o} may do`,title:e.name,className:`justify-center sm:w-[104px]`,children:`Change`}):(0,X.jsx)(Dt,{tool:e,exposure:i})]})]})}function Ft({name:e,serverId:t,tenant:n,protection:r,listTool:i,version:a,nav:o,exposure:l,ruleBlocked:u,onClose:d,onEditRule:f,onPosture:p,onChanged:m}){let{data:h,error:g,loading:v,reload:b}=ue(()=>e?_.tool(t,e,n):Promise.resolve(null),[t,e,n,a]),x=h&&h.name===e?h:null,S=x??i;return(0,X.jsx)(y,{open:e!==null,onClose:d,width:620,title:(0,X.jsx)(`span`,{className:`font-mono text-[18px] break-all`,children:e}),subtitle:S?(0,X.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(C,{effect:U(S),withLabel:!0}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsxs)(`span`,{children:[`on `,(0,X.jsx)(`span`,{className:`font-medium text-muted`,children:S.upstream})]}),(0,X.jsx)(w,{term:`connectedServer`})]}):void 0,children:g&&!S?(0,X.jsx)(c,{tone:`danger`,title:`This tool couldn't be loaded`,actions:(0,X.jsx)(E,{size:`sm`,icon:`refresh`,onClick:b,children:`Try again`}),children:Y(g)}):S?(0,X.jsxs)(`div`,{className:`space-y-8`,children:[(0,X.jsx)(It,{tool:S}),(0,X.jsx)(Lt,{tool:S,protection:r,serverId:t,tenant:n,ruleBlocked:u,onEditRule:()=>f(S),onPosture:p,onChanged:m}),(0,X.jsx)(Bt,{tool:S}),(0,X.jsx)(Vt,{tool:S,loading:v&&!x}),(0,X.jsx)(Ht,{tool:S,nav:o}),(0,X.jsx)(Ut,{tool:x,loading:v&&!x,nav:o}),(0,X.jsx)(Wt,{tool:S,exposure:l,perCustomer:!!r?.tenant},S.name)]}):(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(s,{height:20,lines:3}),(0,X.jsx)(s,{height:40}),(0,X.jsx)(s,{lines:4})]})})}function $({title:e,aside:t,children:n}){return(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`header`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`flex items-center gap-2 text-[16px] font-semibold tracking-[-0.01em]`,children:e}),t]}),n]})}function It({tool:e}){let t=e.rawDescription!==e.description,n=e.injection??[],r=n.length>0&&!e.hiddenByPolicy&&!t;return(0,X.jsxs)($,{title:t?`What your AI is told about it`:`What ${e.upstream} says about it`,children:[(0,X.jsx)(`p`,{className:`text-[14.5px] whitespace-pre-wrap text-ink`,children:e.description||(0,X.jsx)(`span`,{className:`text-soft italic`,children:`The connected server gave no description.`})}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[12.5px] text-soft`,children:`This is the description your AI sees.`}),n.length>0&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsxs)(c,{tone:r?`info`:`danger`,title:e.hiddenByPolicy?`Hidden instructions found, so the tool is hidden`:r?`Hidden instructions found, and accepted after review`:`Hidden instructions found and removed`,children:[`The connected server's description contained text aimed at your AI rather than at you, such as telling it to ignore its rules.`,` `,e.hiddenByPolicy?`The toolbox keeps this tool away from your AI entirely.`:r?`Someone reviewed it and chose to pass the text through unchanged. It doesn't change what the tool may do.`:`The toolbox changed the description before your AI saw it.`,(0,X.jsx)(`span`,{className:`mt-1.5 block font-mono text-[11.5px] text-soft`,children:n.map(e=>ae(e)===e?e:`${e} (${ae(e)})`).join(`, `)})]})}),t&&(0,X.jsxs)(`details`,{className:`mt-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`What ${e.upstream} originally said`}),(0,X.jsx)(`p`,{className:`mt-2 mb-2 text-[12.5px] text-soft`,children:`What the connected server sent (removed lines) and what your AI sees instead (added lines).`}),(0,X.jsx)(ie,{before:De(e.rawDescription),after:De(e.description),label:`Original and shown description`})]})]})}function Lt({tool:e,protection:t,serverId:n,tenant:r,ruleBlocked:i,onEditRule:a,onPosture:o,onChanged:s}){let[l,u]=(0,B.useState)(!1),d=e.effect===null&&!e.reclassifiedTo,f=e.exposure.disabled?`deny`:e.verdict.kind;return(0,X.jsxs)($,{title:`What it's allowed to do`,children:[(0,X.jsxs)(`div`,{className:`rounded-[20px] bg-sunken/70 p-5`,children:[(0,X.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,X.jsx)(T,{decision:f,label:e.exposure.disabled?`Turned off`:void 0})}),(0,X.jsx)(`p`,{className:`display mt-3 text-[22px] leading-snug`,children:_e(e)}),t?.enforcement===`observe`&&e.verdict.kind!==`allow`&&!e.exposure.disabled&&(0,X.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:`That starts once protection is on. Your toolbox is only watching now, so for the moment it runs.`}),!e.exposure.disabled&&(0,X.jsxs)(`dl`,{className:`mt-4 space-y-2 text-[13.5px]`,children:[(0,X.jsxs)(Rt,{label:`Why`,children:[ye(e.verdict,t?.defaults.mode??null),(0,X.jsx)(`code`,{className:`mt-0.5 block font-mono text-[11.5px] break-all text-soft`,children:e.verdict.ruleId})]}),(0,X.jsxs)(Rt,{label:`Labelled as`,children:[A[U(e)??`unknown`].label,`.`,` `,(0,X.jsx)(`span`,{className:`text-soft`,children:be[e.effectSource]??e.effectSource}),e.reclassifiedTo&&e.effect&&(0,X.jsxs)(`span`,{className:`block text-[12.5px] text-soft`,children:[`The connected server calls it “`,A[e.effect]?.label??e.effect,`”; a rule changed that.`]})]}),e.consoleRule&&(0,X.jsx)(Rt,{label:`Set by`,children:`You, from this console. Use “Undo my change” to remove it.`})]}),(0,X.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,X.jsx)(E,{variant:`primary`,icon:`sliders`,onClick:a,disabled:i!==null,children:`Change what it may do`}),e.consoleRule&&(0,X.jsx)(E,{icon:`refresh`,onClick:()=>u(!0),disabled:i!==null,children:`Undo my change`}),d&&(0,X.jsx)(E,{variant:`ghost`,onClick:o,children:`Change the setting for unlabelled tools`})]}),i&&(0,X.jsx)(`p`,{className:`mt-2 text-[12.5px] text-soft`,children:i})]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[t?.runtime.policyApplied===!1&&(0,X.jsxs)(c,{tone:`warn`,title:`The running gateway hasn't picked up the latest settings`,children:[`What's shown here is the settings file. The toolbox still uses the version it read when it started`,` `,t.runtime.startedAt?x(t.runtime.startedAt):`earlier`,`. Restart it to apply the newer one.`]}),e.boundsDrift&&(0,X.jsxs)(c,{tone:`info`,title:`These limits no longer match the rule they were copied from`,children:[`When this rule was saved it copied the limits from`,` `,(0,X.jsx)(`code`,{className:`font-mono text-[12px]`,children:e.boundsDrift.ruleId}),`. That rule has changed since:`,(0,X.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5`,children:e.boundsDrift.differences.map(e=>(0,X.jsx)(`li`,{children:J(e)},e))}),(0,X.jsx)(`span`,{className:`mt-1.5 block`,children:`This tool still follows its own copy. Change what it may do to take the newer limits, or leave it if these are the ones you want.`})]})]}),l&&(0,X.jsx)(zt,{serverId:n,tenant:r,tool:e,protection:t,onClose:()=>u(!1),onDone:()=>{u(!1),s()}})]})}function Rt({label:e,children:t}){return(0,X.jsxs)(`div`,{className:`grid gap-x-4 gap-y-0.5 sm:grid-cols-[110px_1fr]`,children:[(0,X.jsx)(`dt`,{className:`font-semibold text-soft`,children:e}),(0,X.jsx)(`dd`,{className:`min-w-0 text-ink`,children:t})]})}function zt({serverId:e,tenant:t,tool:n,protection:r,onClose:i,onDone:a}){let o=P(),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(0);(0,B.useEffect)(()=>{let r=!0;return u(null),_.clearPreview(e,n.name,t).then(e=>r&&u(e),e=>r&&f({text:Y(e),stale:!1})),()=>{r=!1}},[e,n.name,t,h]);async function v(){if(l){m(!0),f(null);try{let r=await _.clearToolRule(e,n.name,l.expectedDigest,t);o.show(`ok`,`Your change to ${n.name} is undone. The toolbox applies it within about a second.`),r.warning&&o.show(`warn`,J(r.warning)),a()}catch(e){f({text:Te(e)?Ee:Y(e),stale:Te(e)})}finally{m(!1)}}}let y=l?.verdict.kind===`allow`?`run freely`:l?.verdict.kind===`approve`?`ask you first`:`be blocked`;return(0,X.jsx)(N,{open:!0,onClose:i,title:`Undo your change to ${n.name}?`,description:`This removes the rule you saved here. The tool goes back to whatever your other settings say.`,footer:(0,X.jsxs)(X.Fragment,{children:[d?.stale&&(0,X.jsx)(E,{variant:`ghost`,icon:`refresh`,className:`mr-auto`,onClick:()=>{f(null),g(e=>e+1)},children:`Reload`}),(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:p,children:`Keep my change`}),(0,X.jsx)(E,{variant:`primary`,onClick:()=>void v(),disabled:!l,loading:p,children:`Undo change`})]}),children:(0,X.jsxs)(`div`,{className:`space-y-3 text-[14px]`,children:[!l&&!d&&(0,X.jsx)(s,{lines:3}),l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,X.jsx)(`span`,{className:`text-[13px] text-soft`,children:`Afterwards it will`}),(0,X.jsx)(T,{decision:l.verdict.kind})]}),(0,X.jsxs)(`p`,{className:`text-muted`,children:[`Every call to `,(0,X.jsx)(`code`,{className:`font-mono text-ink`,children:n.name}),` will `,y,l.verdict.ruleId.startsWith(`defaults.`)?`, by your default settings`:``,`.`,l.bounds?` Limits: ${q(l.bounds).join(`; `)}.`:``]}),l.becomesUnclassified&&(0,X.jsx)(c,{tone:`warn`,title:`Nothing else says what this tool does`,children:`Your change was the only label on this tool. Without it, it is treated as not labelled again.`}),r?.tenant&&(0,X.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`This affects every customer of this toolbox.`}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the rule being removed`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(re,{label:`The rule being removed`,children:l.yaml})})]})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:d.text})]})})}function Bt({tool:e}){let t=e.bounds;return(0,X.jsx)($,{title:(0,X.jsxs)(X.Fragment,{children:[`Limits on its inputs `,(0,X.jsx)(w,{term:`limits`})]}),children:t?(0,X.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,X.jsx)(`ul`,{className:`space-y-1.5`,children:t.paths.map((e,n)=>(0,X.jsxs)(`li`,{className:`flex gap-2.5 text-[14px]`,children:[(0,X.jsx)(`span`,{className:`mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--soft)]`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`code`,{className:`font-mono text-[13px] font-medium`,children:e}),` `,q(t)[n].slice(e.length+1)]})]},e))}),(0,X.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`A call that breaks a limit `,t.onViolation===`approve`?`asks you first`:`is blocked`,`.`,` `,we[t.unknownArgs]]}),(0,X.jsx)(`p`,{className:`font-mono text-[11.5px] text-soft`,children:t.ruleId})]}):(0,X.jsx)(`p`,{className:`text-[14px] text-soft`,children:`No limits. Every input is passed on as your AI sends it.`})})}function Vt({tool:t,loading:n}){return(0,X.jsxs)($,{title:`Inputs`,children:[t.args.length===0?(0,X.jsx)(`p`,{className:`text-[14px] text-soft`,children:`This tool takes no inputs.`}):(0,X.jsx)(`ul`,{className:`divide-y divide-faint rounded-[18px] border border-line`,children:t.args.map(t=>(0,X.jsxs)(`li`,{className:`px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`code`,{className:`font-mono text-[13.5px] font-medium break-all`,children:t.name}),(0,X.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[t.type??`any type`,t.format?`, ${t.format}`:``,` · `,t.required?`required`:`optional`]}),t.constrainedByRule&&(0,X.jsx)(e,{tone:`neutral`,icon:`sliders`,className:`py-0 text-[11.5px]`,children:`Limited`})]}),t.description&&(0,X.jsx)(`p`,{className:`mt-1 text-[13px] text-muted`,children:t.description}),t.enumValues&&(0,X.jsxs)(`p`,{className:`mt-1 text-[12.5px] text-soft`,children:[`Accepts: `,(0,X.jsx)(`span`,{className:`font-mono`,children:t.enumValues.join(`, `)})]}),t.defaultValue!==null&&(0,X.jsxs)(`p`,{className:t.defaultIsUrl?`mt-1 text-[12.5px] text-warn`:`mt-1 text-[12.5px] text-soft`,children:[`If left out: `,(0,X.jsx)(`span`,{className:`font-mono break-all`,children:t.defaultValue}),t.defaultIsUrl&&` (a web address the connected server contacts on its own; your network limits don't cover it)`]})]},t.name))}),t.schemaClosed===!1&&(0,X.jsx)(`p`,{className:`mt-2 text-[13px] text-warn`,children:`The connected server accepts inputs beyond the ones listed here, and passes them on as given.`}),(0,X.jsxs)(`details`,{className:`mt-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-semibold text-soft`,children:`Show the full input definition`}),(0,X.jsx)(`div`,{className:`mt-2`,children:n?(0,X.jsx)(s,{lines:4}):(0,X.jsx)(re,{copy:!0,label:`Input definition`,children:JSON.stringify(t.inputSchema??{},null,2)})})]})]})}function Ht({tool:t,nav:n}){return(0,X.jsx)($,{title:(0,X.jsxs)(X.Fragment,{children:[`Pre-approvals that cover it `,(0,X.jsx)(w,{term:`preApproval`})]}),aside:(0,X.jsx)(ee,{href:r(n,`/pre-approvals`),size:`sm`,variant:`ghost`,iconRight:`arrow-right`,children:`Open pre-approvals`}),children:t.standingGrants.length===0?(0,X.jsx)(`p`,{className:`text-[14px] text-soft`,children:`None. When this tool asks first, you decide each call.`}):(0,X.jsx)(`ul`,{className:`space-y-2`,children:t.standingGrants.map(t=>(0,X.jsxs)(`li`,{className:`rounded-[18px] border border-line px-4 py-3 text-[13.5px]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(e,{tone:t.covers?`ok`:`neutral`,icon:t.covers?`check`:`x`,children:t.covers?`Covers this tool`:`Doesn't apply`}),(0,X.jsxs)(`span`,{className:`text-soft`,children:[t.uses,` of `,t.maxUses??`unlimited`,` uses · ends `,x(t.expiresAt)]})]}),t.reason&&(0,X.jsx)(`p`,{className:`mt-1.5 text-ink`,children:t.reason}),!t.covers&&(0,X.jsx)(`p`,{className:`mt-1 text-soft`,children:J(t.why)}),t.covers&&t.heldBounds.length>0&&(0,X.jsxs)(`p`,{className:`mt-1 text-soft`,children:[`A call that breaks the limit on `,(0,X.jsx)(`span`,{className:`font-mono`,children:t.heldBounds.join(`, `)}),` still asks you, because this pre-approval doesn't limit that input.`]}),(0,X.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-soft`,children:t.grantId})]},t.grantId))})})}function Ut({tool:t,loading:n,nav:i}){let a=t?.activity??[];return(0,X.jsx)($,{title:`Recent activity`,aside:t&&(0,X.jsx)(ee,{href:r(i,`/activity`,{tool:t.name}),size:`sm`,variant:`ghost`,iconRight:`arrow-right`,children:`Open activity`}),children:n?(0,X.jsx)(s,{lines:3}):a.length===0?(0,X.jsx)(`p`,{className:`text-[14px] text-soft`,children:`Your AI hasn't used this tool yet.`}):(0,X.jsx)(`ul`,{className:`divide-y divide-faint`,children:a.map(t=>{let n=O[t.outcome];return(0,X.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1 py-2.5`,children:[(0,X.jsx)(`span`,{className:`w-24 shrink-0 text-[12.5px] text-soft`,title:l(t.ts),children:x(t.ts)}),(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(T,{decision:t.decision}),n&&(0,X.jsx)(e,{tone:n.tone,className:`py-0 text-[11.5px]`,children:n.label}),t.observe&&(0,X.jsx)(e,{tone:`neutral`,className:`py-0 text-[11.5px]`,children:`Watch-only`})]}),t.reason&&(0,X.jsx)(`span`,{className:`w-full text-[12.5px] text-soft sm:pl-[108px]`,children:J(t.reason)})]},t.id)})})})}function Wt({tool:e,exposure:t,perCustomer:n}){let[r,i]=(0,B.useState)(``),o=e.exposure.disabled;return(0,X.jsx)($,{title:(0,X.jsxs)(X.Fragment,{children:[`Turn off this tool `,(0,X.jsx)(w,{term:`killSwitch`})]}),children:(0,X.jsxs)(`div`,{className:`space-y-4 rounded-[20px] border border-line p-5`,children:[(0,X.jsx)(p,{checked:o,onChange:n=>t.set(e,n,n?r.trim():``),disabled:t.blocked!==null||t.busy(e.name),label:o?`This tool is turned off`:`Turn off this tool`,description:o?`Your AI can't see it, and every call is blocked${e.exposure.setBy?`. Turned off by ${e.exposure.setBy}`:``}${e.exposure.setAt?` ${x(e.exposure.setAt)}`:``}.`:`Hides it from your AI and blocks every call, even in watch-only mode.`}),o&&e.exposure.reason&&(0,X.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Reason given: `,(0,X.jsx)(`span`,{className:`text-ink`,children:e.exposure.reason})]}),!o&&(0,X.jsx)(a,{label:`Reason`,optional:!0,help:`Saved in the activity log with the change.`,children:(0,X.jsx)(f,{value:r,onChange:i,placeholder:`For example: misbehaving since the last update`,disabled:t.blocked!==null})}),(0,X.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[`Turning it back on returns it to your normal rules. It never makes it allowed on its own`,e.exposure.policyWouldExpose?`.`:`: your rules block this tool anyway.`,n&&` This switch is kept separately for each customer.`]}),t.blocked&&(0,X.jsx)(c,{tone:`warn`,title:`Not available right now`,children:t.blocked})]})})}var Gt=`hmcp.tools.look`;function Kt(){try{return localStorage.getItem(Gt)===`detailed`?`detailed`:`simple`}catch{return`simple`}}function qt(e){try{localStorage.setItem(Gt,e)}catch{}}var Jt={allow:`allow`,approve:`approve`,deny:`deny`,unlabelled:`unclassified`,off:null,changed:null};function Yt(){let{server:e,serverId:t,tenant:i,nav:a,reload:l}=me(),u=ue(()=>_.protection(t,i),[t,i],3e4),f=ue(()=>fe(t),[t],3e4),[p,m]=(0,B.useState)(0),[g,v]=(0,B.useState)(``),[y,C]=(0,B.useState)(`any`),[w,te]=(0,B.useState)(null),[re,T]=(0,B.useState)(!1),[ie,ae]=(0,B.useState)(Kt),oe=(0,B.useRef)(void 0);(0,B.useEffect)(()=>()=>clearTimeout(oe.current),[]);let D=u.data,ce=a.query.get(`tool`),O=a.query.get(`verdict`),A=ge(O)?O:null,j=a.query.get(`view`)===`changed`?`changed`:`all`,M=a.query.get(`list`),N=M===`detailed`||M===`simple`?M:ie,P=()=>{u.reload(),f.reload(),m(e=>e+1),l()},F=()=>{P(),clearTimeout(oe.current),oe.current=setTimeout(P,1500)},I=Ne({serverId:t,tenant:i,protection:D,onChanged:P}),L=(0,B.useMemo)(()=>D?.tools??[],[D]),pe=(0,B.useMemo)(()=>e?.upstreams??[],[e]),R=(0,B.useMemo)(()=>new Set((f.data?.changed??[]).map(e=>e.tool)),[f.data]),z=(0,B.useMemo)(()=>new Set((f.data?.changed??[]).filter(e=>e.withheld).map(e=>e.tool)),[f.data]),W=(0,B.useMemo)(()=>{let e={allow:0,approve:0,deny:0,unlabelled:0,off:0,changed:0};for(let t of L)e[H(t)]++,R.has(t.name)&&e.changed++;return e},[L,R]),_e=(0,B.useMemo)(()=>{let e=g.trim().toLowerCase();return L.filter(t=>!((A===`changed`?!R.has(t.name):A!==null&&H(t)!==A)||y!==`any`&&U(t)!==y||e&&!`${t.name} ${t.description} ${t.upstream}`.toLowerCase().includes(e))).sort((e,t)=>e.upstream.localeCompare(t.upstream)||e.name.localeCompare(t.name))},[L,A,y,g,R]),ve=D?D.surface.neverPublished?`Your toolbox hasn't run yet, so there's no list of its tools to set a rule on. Open your AI app once, then come back.`:D.policyWrite.ok?null:J(D.policyWrite.why??`This toolbox's settings can't be changed from here.`):null,G=f.data?.changed.length??0,ye=e=>de(o(a,{verdict:e})),be=e=>de(o(a,{view:e===`changed`?e:null})),K=e=>de(o(a,{tool:e}));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{title:`Tools`,subtitle:`Everything your AI can use through your toolbox, and what each one is allowed to do.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{icon:`help`,onClick:()=>T(!0),disabled:!D,children:`What happens to unlabelled tools`}),G>0&&(0,X.jsxs)(E,{variant:`primary`,icon:`refresh`,onClick:()=>be(`changed`),children:[`Review changed tools (`,G,`)`]})]})}),D?.enforcement===`observe`&&(0,X.jsx)(`div`,{className:`mb-5`,children:(0,X.jsx)(c,{tone:`warn`,title:`Only watching: every tool runs for now`,children:`Your toolbox isn't protecting you yet, so nothing below asks you first or is blocked today. The labels say what happens once protection is on.`})}),(0,X.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(le,{label:`Tool views`,value:j,onChange:be,items:[{id:`all`,label:`All tools`,count:D?L.length:void 0},{id:`changed`,label:`Changed tools`,count:G}]}),j===`all`&&(0,X.jsx)(h,{label:`How to show tools`,size:`sm`,value:N,onChange:e=>{qt(e),ae(e),de(o(a,{list:e===`detailed`?e:null}))},options:[{value:`simple`,label:`Simple`},{value:`detailed`,label:`Detailed`}]})]}),(0,X.jsx)(`div`,{role:`tabpanel`,id:S(j),"aria-labelledby":d(j),className:`space-y-5`,children:j===`changed`?(0,X.jsx)(Ae,{serverId:t,data:f.data,error:f.error,loading:f.loading,reload:f.reload,onAccepted:P}):u.error&&!D?(0,X.jsx)(c,{tone:`danger`,title:`The tool list couldn't be loaded`,actions:(0,X.jsx)(E,{size:`sm`,icon:`refresh`,onClick:u.reload,children:`Try again`}),children:Y(u.error)}):(0,X.jsxs)(X.Fragment,{children:[D&&I.blocked&&(0,X.jsx)(c,{tone:`warn`,title:D.surface.neverPublished?`No tool list yet`:`The toolbox isn't running`,children:D.surface.neverPublished?`This toolbox hasn't reported which tools its connected servers offer. Start it once and they appear here.`:`This is the list it reported ${D.surface.publishedAt?x(D.surface.publishedAt):`last time`}. Start the toolbox to turn tools off or change their rules.`}),N===`simple`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(Xt,{value:g,onChange:v}),(0,X.jsx)(ee,{href:r(a,`/protection`,{focus:`stance`}),icon:`sliders`,children:`Change how careful to be (all servers)`})]}),(0,X.jsx)(jt,{protection:D,tools:L,query:g,onClearQuery:()=>v(``),changed:R,selected:ce,onOpen:K,exposure:I,configured:pe,withheld:z,connectionsHref:r(a,`/connections`),onPosture:()=>T(!0)})]}):(0,X.jsxs)(k,{padded:!1,children:[(0,X.jsxs)(`div`,{className:`space-y-4 border-b border-faint p-5 sm:p-6`,children:[(0,X.jsx)(`div`,{role:`group`,"aria-label":`Show tools that`,className:`flex flex-wrap gap-2`,children:V.map(e=>(0,X.jsx)(Zt,{label:he[e],count:D?W[e]:null,dot:Jt[e],icon:e===`off`?`power`:e===`changed`?`refresh`:null,on:A===e,onClick:()=>ye(A===e?null:e)},e))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,X.jsx)(Xt,{value:g,onChange:v}),(0,X.jsx)(se,{"aria-label":`Show tools by what they do`,value:y,onChange:C,className:`w-full sm:w-52`,options:[{value:`any`,label:`Any kind of tool`},{value:`read`,label:`Looks only`},{value:`write`,label:`Makes changes`},{value:`destructive`,label:`Deletes`}]})]})]}),(0,X.jsx)(`div`,{className:`px-5 pt-1 pb-3 sm:px-6`,children:D?L.length===0?(0,X.jsx)(b,{icon:`tool`,title:`No tools yet`,children:D.surface.neverPublished?`Start the toolbox once and the tools its connected servers offer will appear here.`:`The connected servers on this toolbox don't offer any tools.`}):_e.length===0?(0,X.jsx)(b,{icon:`search`,title:`No tools match`,compact:!0,actions:(0,X.jsx)(E,{onClick:()=>{v(``),C(`any`),ye(null)},children:`Clear filters`}),children:`Nothing on this toolbox matches what you picked.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`sr-only`,"aria-live":`polite`,children:[n(_e.length,`tool`),` shown`]}),(0,X.jsx)(wt,{tools:_e,changed:R,selected:ce,onOpen:K,exposure:I})]}):(0,X.jsx)(`div`,{className:`space-y-5 py-4`,"aria-busy":!0,children:[0,1,2,3].map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(`span`,{className:`skeleton h-11 w-11 shrink-0 rounded-full`}),(0,X.jsx)(`div`,{className:`flex-1`,children:(0,X.jsx)(s,{lines:2})})]},e))})})]})]})}),(0,X.jsx)(Ft,{name:ce,serverId:t,tenant:i,protection:D,listTool:L.find(e=>e.name===ce)??null,version:p,nav:a,exposure:I,ruleBlocked:ve,onClose:()=>K(null),onEditRule:te,onPosture:()=>T(!0),onChanged:F}),w&&(0,X.jsx)(Ke,{open:!0,serverId:t,tenant:i,tool:w,protection:D,onClose:()=>te(null),onSaved:F},w.name),D&&re&&(0,X.jsx)(Fe,{open:!0,serverId:t,tenant:i,protection:D,onClose:()=>T(!1),onSaved:F,onReload:u.reload}),I.dialog]})}function Xt({value:e,onChange:t}){return(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-60`,children:[(0,X.jsx)(g,{name:`search`,size:18,className:`pointer-events-none absolute top-1/2 left-3.5 -translate-y-1/2 text-soft`}),(0,X.jsx)(f,{type:`search`,value:e,onChange:t,placeholder:`Search by name or description`,"aria-label":`Search tools by name or description`,className:`pl-10`})]})}function Zt({label:e,count:t,dot:n,icon:r,on:i,onClick:a}){return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:a,className:F(`inline-flex h-10 items-center gap-2 rounded-full border-[1.5px] px-4 text-[13.5px] font-semibold transition-colors active:scale-[.98]`,i?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:[n&&(i?(0,X.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":!0}):(0,X.jsx)(v,{decision:n})),r&&(0,X.jsx)(g,{name:r,size:15,strokeWidth:2}),e,(0,X.jsx)(`span`,{className:F(`tnum rounded-full px-1.5 text-[12px]`,i?`bg-white/20`:`bg-faint`),children:t??`–`})]})}export{Yt as ToolsPage};
|