hmcp-web 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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-BHB_ha4i.js";import{$n as v,Bn as y,Fn as b,Gn as x,Hn as S,In as C,Jn as ee,Kn as te,Ln as ne,Nn as w,Pn as re,Qn as ie,Rn as ae,Un as oe,Vn as se,Wn as ce,X as T,Xn as le,Yn as ue,Z as E,at as D,er as O,it as k,ot as de,qn as fe,st as A,tr as pe,zn as me}from"./index-Cm4wG2zz.js";import{o as he,r as j,s as ge,t as _e}from"./AttachApp-COr1547c.js";import{n as M,p as N,t as P}from"./connect-app-words-CT8Fytzv.js";var F=i(),I=f(),L=[[`Runs freely`,`fill-allow`],[`Asks you first`,`fill-approve`],[`Blocked`,`fill-deny`]],R=[`Files`,`GitHub`,`Notion`,`and more…`];function z(){let e=(0,F.useId)(),t=`${e}-t`,n=`${e}-d`,r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`title`,{id:t,children:`How hardened-mcp fits in`}),(0,I.jsx)(`desc`,{id:n,children:`Your AI app talks to hardened-mcp, the toolbox. The toolbox checks every action: it runs freely, asks you first, or is blocked. Then it passes allowed actions on to your servers, such as files, GitHub and Notion.`})]});return(0,I.jsxs)(`figure`,{className:`m-0 text-ink`,children:[(0,I.jsxs)(`svg`,{viewBox:`0 0 760 236`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`hidden h-auto w-full sm:block`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:8,y:58}),(0,I.jsx)(V,{x1:190,y1:118,x2:250,y2:118,id:e}),(0,I.jsx)(W,{x:258,y:20}),(0,I.jsx)(V,{x1:508,y1:118,x2:568,y2:118,id:e}),(0,I.jsx)(G,{x:576,y:34})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 320 560`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`mx-auto block h-auto w-full max-w-[320px] sm:hidden`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:68,y:4}),(0,I.jsx)(V,{x1:160,y1:126,x2:160,y2:160,id:e}),(0,I.jsx)(W,{x:35,y:168}),(0,I.jsx)(V,{x1:160,y1:364,x2:160,y2:398,id:e}),(0,I.jsx)(G,{x:68,y:406,compact:!0})]})]})}function B({id:e}){return(0,I.jsx)(`defs`,{children:(0,I.jsx)(`marker`,{id:`${e}-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,I.jsx)(`path`,{d:`M1 1 9 5 1 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function V({x1:e,y1:t,x2:n,y2:r,id:i}){return(0,I.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,className:`stroke-soft text-soft`,strokeWidth:`2`,strokeDasharray:`5 5`,markerEnd:`url(#${i}-arrow)`})}function H({x:e,y:t,children:n,size:r=15,weight:i=600,className:a=`fill-ink`,anchor:o=`middle`}){return(0,I.jsx)(`text`,{x:e,y:t,textAnchor:o,fontSize:r,fontWeight:i,className:a,style:{fontFamily:`var(--font-sans)`},children:n})}function U({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`184`,height:`120`,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsxs)(`g`,{transform:`translate(76 18)`,className:`text-muted`,children:[(0,I.jsx)(`path`,{d:`M4 4h24a4 4 0 0 1 4 4v13a4 4 0 0 1-4 4H14l-7 6v-6H4a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`circle`,{cx:`9`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`16`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`23`,cy:`14.5`,r:`1.8`,fill:`currentColor`})]}),(0,I.jsx)(H,{x:92,y:76,children:`Your AI app`}),(0,I.jsx)(H,{x:92,y:98,size:14,weight:500,className:`fill-soft`,children:`Claude, Cursor, VS Code…`})]})}function W({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`250`,height:`196`,rx:`26`,className:`fill-green-deep`}),(0,I.jsxs)(`g`,{transform:`translate(110 16)`,className:`text-white`,children:[(0,I.jsx)(`path`,{d:`M15 2 27 6.5v9.4c0 7-4.5 11.8-12 14.8C7.5 27.7 3 22.9 3 15.9V6.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`m9.5 16 4 4 7-8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),(0,I.jsx)(H,{x:125,y:68,size:17,weight:700,className:`fill-white`,children:`hardened-mcp`}),(0,I.jsx)(H,{x:125,y:88,size:14,weight:500,className:`fill-on-hero-soft`,children:`the toolbox that checks every action`}),L.map(([e,t],n)=>(0,I.jsxs)(`g`,{transform:`translate(34 ${108+n*26})`,children:[(0,I.jsx)(`rect`,{width:`182`,height:`22`,rx:`11`,fill:`white`,fillOpacity:`0.12`}),(0,I.jsx)(`circle`,{cx:`14`,cy:`11`,r:`5`,className:t}),(0,I.jsx)(H,{x:28,y:15.5,size:14,weight:600,className:`fill-white`,anchor:`start`,children:e})]},e))]})}function G({x:e,y:t,compact:n}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`176`,height:n?150:168,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsx)(H,{x:88,y:28,size:14.5,weight:700,className:`fill-soft`,children:`Your servers`}),R.map((e,t)=>(0,I.jsxs)(`g`,{transform:`translate(18 ${42+t*(n?26:30)})`,children:[(0,I.jsx)(`rect`,{width:`140`,height:`22`,rx:`7`,className:t===R.length-1?`fill-transparent`:`fill-sunken`}),t<R.length-1&&(0,I.jsx)(`circle`,{cx:`13`,cy:`11`,r:`3.5`,className:`fill-ok`}),(0,I.jsx)(H,{x:t<R.length-1?26:8,y:15.5,size:12.5,weight:500,className:`fill-muted`,anchor:`start`,children:e})]},e))]})}function K({text:e}){let t=e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).filter(Boolean);return(0,I.jsx)(I.Fragment,{children:t.map((e,t)=>e.startsWith("`")?(0,I.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] break-words text-ink`,children:e.slice(1,-1)},t):e.startsWith(`**`)?(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:e.slice(2,-2)},t):(0,I.jsx)(`span`,{children:e},t))})}function q({children:e}){return(0,I.jsx)(`p`,{className:`max-w-2xl text-[15.5px] leading-relaxed text-muted`,children:e})}function J({icon:e,title:t,children:n}){return(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e,size:17})}),(0,I.jsxs)(`span`,{className:`min-w-0 pt-0.5`,children:[(0,I.jsx)(`span`,{className:`block text-[15px] font-medium`,children:t}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] leading-relaxed text-soft`,children:n})]})]})}function ve(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,I.jsx)(q,{children:`hardened-mcp lets your AI app use tools, like your files, GitHub or Notion. It doesn't give the AI everything. You get a toolbox. Your AI app connects to it, and every action goes through it first. When protection is on, reading runs freely. Every change asks you first. Anything outside the folders and services you gave it is blocked. Everything is written down, so you can always see what your AI did.`}),(0,I.jsx)(`div`,{className:`rounded-[22px] bg-sunken/60 p-4 sm:p-6`,children:(0,I.jsx)(z,{})}),(0,I.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,I.jsxs)(`section`,{"aria-labelledby":`what-mcp`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsxs)(`h2`,{id:`what-mcp`,className:`flex items-center gap-2 text-[16px] font-semibold`,children:[`What's an MCP server? `,(0,I.jsx)(l,{term:`mcp`})]}),(0,I.jsx)(`p`,{className:`mt-2 text-[14px] leading-relaxed text-muted`,children:`It's a small add-on that gives your AI app a set of tools: reading a folder, searching the web, opening an issue on GitHub. MCP is a shared standard, so any AI app can use any of them. In a minute you'll bring in the ones your AI app already has, or add your first one.`})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-expect`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsx)(`h2`,{id:`what-expect`,className:`text-[16px] font-semibold`,children:`What to expect`}),(0,I.jsxs)(`ul`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`About 5 minutes`,children:`Seven short steps. You can skip any of them and come back later from Settings & help.`}),(0,I.jsx)(J,{icon:`lock`,title:`Nothing changes until you say so`,children:`Your AI apps keep working exactly as they do now until you choose to connect one.`}),(0,I.jsx)(J,{icon:`eye`,title:`It starts by watching`,children:`At first your toolbox lets everything run and writes down what it would have asked you about or blocked, so nothing you rely on breaks. In step 6 you choose whether to turn protection on straight away.`})]})]})]})]})}function Y(e,t){let n=t.find(t=>t.id===e),r=e===`node`?t.find(e=>e.id===`npx`):e===`uv`?t.find(e=>e.id===`uvx`):void 0;return!n?.found||r&&!r.found?{status:{tone:`neutral`,label:`Not installed`,icon:`minus`},check:n,state:`missing`}:n?.running===!1?{status:{tone:`warn`,label:`Installed, not running`,icon:`pause`},check:n,state:`stopped`}:{status:{tone:`ok`,label:`Ready`,icon:`check`},check:n,state:`ready`}}function ye({entries:e}){let i=p(()=>t.doctor(),[]),[a,o]=(0,F.useState)(!1),s=i.data,c=A(s?.platform),u=fe(e),f=()=>{o(!0),i.reload(),setTimeout(()=>o(!1),700)},m=s?de.map(e=>({rt:e,...Y(e,s.checks)})):[],h=m.filter(e=>e.state!==`ready`),g=m.some(e=>e.rt===`node`&&e.state===`ready`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Most servers need a free helper program to run, such as Node.js. This looks for them on this computer. It only looks; it never installs or changes anything. `,(0,I.jsx)(l,{term:`machineCheck`})]}),i.error&&!s?(0,I.jsx)(r,{tone:`warn`,title:`The check couldn't run`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a,children:`Check again`}),children:`You can skip this step. If a server needs something that's missing, it will tell you when you test it.`}):s?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{tone:h.length===0?`ok`:g?`info`:`warn`,role:`status`,title:h.length===0?`Everything is ready`:g?`You're ready for your first server`:`Some servers need something installed first`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a||i.loading,children:`Check again`}),children:h.length===0?`This computer has everything servers need.`:g?`Some servers need other helpers, listed below. You don't need them unless you add one of those servers.`:`That's fine. You can carry on and only install something when a server you want needs it.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`What this computer has`,children:m.map(e=>(0,I.jsx)(X,{rt:e.rt,status:e.status,check:e.check,state:e.state,os:c,needs:u[e.rt]},e.rt))})]}):(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,"aria-label":`Checking your computer`,children:(0,I.jsx)(n,{height:64,lines:3})})]})}function X({rt:t,status:n,check:r,state:i,os:a,needs:s}){let c=k[t],[l,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(a),h=`install-${t}`;return(0,I.jsxs)(`li`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,I.jsx)(`p`,{className:`flex flex-wrap items-center gap-2 text-[15px] font-semibold`,children:c.name}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:c.why}),i!==`ready`&&s.length>0&&(0,I.jsxs)(`p`,{className:`mt-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:`Needed by:`}),` `,s.join(`, `)]}),i===`ready`&&(r?.path||r?.version)&&(0,I.jsxs)(`details`,{className:`mt-1 text-[12px] text-soft`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),r?.version&&(0,I.jsxs)(`span`,{className:`mono block`,children:[`Version `,r.version]}),r?.path&&(0,I.jsx)(`code`,{className:`mono block break-all`,children:r.path})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,I.jsx)(e,{tone:n.tone,icon:n.icon,children:n.label}),i!==`ready`&&(0,I.jsx)(d,{size:`sm`,variant:`ghost`,iconRight:`chevron`,"aria-expanded":l,"aria-controls":h,onClick:()=>f(!l),children:i===`stopped`?`How to start it`:`How to install it`})]})]}),l&&i!==`ready`&&(0,I.jsx)(`div`,{id:h,className:`mt-4 border-t border-faint pt-4`,children:i===`stopped`&&c.start?(0,I.jsx)(`p`,{className:`text-[14px] leading-relaxed text-muted`,children:(0,I.jsx)(K,{text:c.start[p]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{size:`sm`,label:`Install steps for ${c.name}: choose your computer`,value:p,onChange:m,options:[`darwin`,`win32`,`linux`].map(e=>({value:e,label:D[e]}))}),(0,I.jsx)(`ol`,{className:`mt-4 flex flex-col gap-3`,children:c.steps[p].map((e,t)=>(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`tnum grid h-6 w-6 shrink-0 place-items-center rounded-full bg-sunken text-[12px] font-bold text-muted`,children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 text-[14px] leading-relaxed text-muted`,children:[(0,I.jsx)(K,{text:e.text}),e.copy&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`mono min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[12.5px] break-all text-ink`,children:e.copy}),(0,I.jsx)(E,{text:e.copy,label:`Copy`})]}),e.link&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(u,{href:e.link.url,external:!0,size:`sm`,iconRight:`external`,children:e.link.label})})]})]},t))})]})})]})}function be({gatewayId:e,existing:t,added:n,entries:i,onAdded:a,onClosed:o}){let[s,c]=(0,F.useState)(n.length===0&&t.length===0),l=n.at(-1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Pick a server to give your AI app its first tools. Each one comes with step-by-step instructions, and you can test it before anything is saved. If you're not sure, `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Files on this computer`}),` `,`is a good first choice: it lets the AI read and edit files in one folder you choose, and nothing outside it.`]}),l&&(0,I.jsx)(r,{tone:`ok`,role:`status`,title:l.displayName?`${l.displayName} is in your toolbox`:`Added to your toolbox`,children:l.summary.length>0?(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.summary.map(e=>(0,I.jsx)(`li`,{children:e},e))}):`It's saved in your toolbox.`}),!l&&t.length>0&&(0,I.jsxs)(r,{tone:`info`,title:`You already have servers`,children:[`Your toolbox has `,t.map(e=>oe(i,e)?.name??e).join(`, `),`. You can add another or carry on.`]}),s?(0,I.jsx)(he,{gatewayId:e,compact:!0,onDone:e=>{a(e),c(!1)},onCancel:n.length>0||t.length>0?()=>{c(!1),o?.()}:void 0}):(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:()=>c(!0),children:`Add another server`})})]})}var Z=(e,t)=>`/tools?server=${encodeURIComponent(e)}&app=${encodeURIComponent(t)}`;function xe({gatewayId:e,onAttached:t,onConnected:n,onUndone:r,onNeedsServer:i,onAddServer:a,onProtect:o}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[N,` `,(0,I.jsx)(l,{term:`toolbox`})]}),(0,I.jsxs)(`div`,{className:`rounded-[18px] bg-sunken/60 p-4 sm:p-5`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[(0,I.jsx)(s,{name:`refresh`,size:17,className:`text-ok`}),`Restart your app once`]}),(0,I.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-muted`,children:`Your AI app only looks for new tools when it starts. After connecting, quit it completely (not just close the window) and open it again. You only do this once: servers you add or change later appear on their own.`})]}),(0,I.jsx)(j,{newTab:!0,keep:!0,toolsHref:Z,protect:()=>({onClick:o}),addServer:{onClick:a},onConnected:n,onNeedsServer:i,onUndone:r}),(0,I.jsxs)(`details`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-[14px] font-semibold select-none`,children:M}),(0,I.jsx)(`p`,{className:`mt-2 text-[13.5px] text-muted`,children:P}),(0,I.jsx)(`div`,{className:`mt-3`,children:e?(0,I.jsx)(_e,{gatewayId:e,compact:!0,onDone:t}):(0,I.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`These need a toolbox. Connect an app above, or add a server first.`})})]})]})}function Se({entries:e,servers:t,appLabel:n}){let{prompt:r,entry:i}=O(e,t),a=n??`your AI app`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Open `,a,` and ask it something that uses your new tools`,i?` from ${i.name}`:``,`. Here's a good first one:`]}),(0,I.jsxs)(`figure`,{className:`m-0 rounded-[20px] border-[1.5px] border-primary/40 bg-ok-tint p-5`,children:[(0,I.jsxs)(`blockquote`,{className:`text-[17px] leading-relaxed font-medium text-ink`,children:[`“`,r,`”`]}),(0,I.jsx)(`figcaption`,{className:`mt-4`,children:(0,I.jsx)(E,{text:r,label:`Copy this`})})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-see`,children:[(0,I.jsx)(`h2`,{id:`what-see`,className:`text-[16px] font-semibold`,children:`What you'll see`}),(0,I.jsxs)(`ol`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`check`,title:`Looking runs straight away`,children:`When the AI only reads something, it just happens. Every action is written down under Activity in this console.`}),(0,I.jsx)(J,{icon:`eye`,title:`At first, changes run too`,children:`A new toolbox starts by watching: everything runs, and Activity notes what would have asked you first or been blocked. In the next step you choose whether it should start protecting you.`}),(0,I.jsxs)(J,{icon:`clock`,title:`Once protection is on, every change asks you first`,children:[`If the AI wants to change something, it stops and tells you it's waiting. The request appears under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Waiting for you`}),` in this console. Approve it or say no there. If you approve, the AI can try again and it goes ahead. Anything outside the folders and services you gave it is blocked.`]}),(0,I.jsxs)(J,{icon:`warning`,title:`If nothing happens`,children:[`Check that you quit `,a,` completely and opened it again. If a tool still doesn't show up, open Connections in this console: each server says whether it's working, and if not, why and how to fix it.`]})]}),(0,I.jsx)(`div`,{className:`mt-5`,children:(0,I.jsx)(u,{href:`/approvals`,external:!0,icon:`clock`,iconRight:`external`,children:`Open Waiting for you`})})]})]})}var 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 Ce({gatewayId:t,onAddServer:i,applyRef:a}){let[o,s]=(0,F.useState)(`protect`),[l,u]=(0,F.useState)(!1),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),_=p(()=>t?c.protection(t):Promise.resolve(null),[t]),v=(0,F.useRef)(null),y=(0,F.useRef)(!1),b=_.data?.enforcement===`enforce`||h===`protect`,x=_.data&&!_.data.policyWrite.ok?_.data.policyWrite.why:null,S=async()=>{if(m(null),!t||b||h===`watch`)return!0;if(o===`watch`)return y.current=!0,g(`watch`),!0;if(!_.data)return!1;if(x)return m(x),!1;u(!0);try{return await c.setPolicySetting(t,`enforcement`,`enforce`,_.data.policyWrite.digest),y.current=!0,g(`protect`),_.reload(),!0}catch(e){return m(e.message||`Protection couldn't be turned on.`),!1}finally{u(!1)}};return a&&(a.current=S),(0,F.useEffect)(()=>()=>{a&&(a.current=null)},[a]),(0,F.useEffect)(()=>{y.current&&v.current?.focus()},[b,h]),t?_.loading&&!_.data?(0,I.jsx)(n,{height:180}):b?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsxs)(r,{tone:`ok`,title:`Your toolbox is protecting you`,role:`status`,children:[Q,` Requests appear under `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Waiting for you`}),`.`]})}),(0,I.jsxs)(`ul`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`When your AI asks for something`,children:`It stops and tells you it's waiting. Open this console, look at what it wants to do, and approve it or say no.`}),(0,I.jsxs)(J,{icon:`sliders`,title:`Too many questions?`,children:[`Under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` you can let a tool you trust run freely, or approve one for a while.`]})]})]}):h===`watch`?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsx)(r,{tone:`warn`,title:`Your toolbox is only watching for now`,role:`status`,children:`Everything your AI does runs and is written down under Activity. Nothing asks you first and nothing is blocked, so you're not protected yet.`})}),(0,I.jsxs)(q,{children:[`When you're ready, turn protection on under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` `,`(one switch at the top), or come back to this guide from Settings & help.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`ghost`,onClick:()=>g(null),children:`Choose again`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Right now your toolbox only watches: everything your AI does runs, and is written down. Choose whether it should start protecting you now.`}),(0,I.jsx)(T,{label:`How careful should your toolbox be?`,value:o,onChange:s,options:[{value:`protect`,title:`Protect me now`,badge:(0,I.jsx)(e,{tone:`ok`,children:`Recommended`}),body: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,I.jsx)(r,{tone:`warn`,title:`This toolbox's protection can't be changed from the console`,children:x}),f&&(0,I.jsx)(r,{tone:`danger`,role:`alert`,title:`Protection wasn't turned on`,children:f}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`primary`,icon:o===`protect`?`shield-check`:`eye`,loading:l,disabled:!!x&&o===`protect`,onClick:()=>void S(),children:o===`protect`?`Turn on protection`:`Keep watching for now`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(q,{children:`There's nothing to protect yet. Add a server first, then come back here.`}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:i,children:`Add a server`})})]})}var $=[{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 we({gatewayId:e,onLeave:t}){let n=p(()=>e?c.protection(e):Promise.resolve(null),[e]),i=!!n.data&&n.data.enforcement!==`enforce`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Your toolbox is set up. Here's where to go next.`}),i&&(0,I.jsxs)(r,{tone:`warn`,title:`Protection: off (only watching)`,children:[`Everything your AI does runs and is written down, and nothing asks you first. Turn protection on under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Protection settings`}),` when you're ready.`]}),(0,I.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:$.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:e.href,onClick:n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(e.href))},className:_(`card card-link flex h-full gap-3.5 p-5`),children:[(0,I.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e.icon,size:19})}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[15.5px] font-semibold`,children:[e.title,(0,I.jsx)(s,{name:`arrow-right`,size:15,className:`text-soft`})]}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:e.body})]})]})},e.href))}),(0,I.jsx)(r,{tone:`info`,title:`When you need to approve something, open the console`,children:`Approving requests and signing in to services happen here. Your servers keep working without the console open; anything that asks you first waits until you open it again.`})]})}function Te(){let[e,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(`welcome`),[o,l]=(0,F.useState)(!1),[u,f]=(0,F.useState)(null),[p,oe]=(0,F.useState)([]),[T,E]=(0,F.useState)([]),[D,O]=(0,F.useState)(null),[k,de]=(0,F.useState)([]),[fe,A]=(0,F.useState)(!1),he=(0,F.useRef)(null),j=(0,F.useRef)(null),[_e,M]=(0,F.useState)(!1),N=(0,F.useRef)(!1),[P,L]=(0,F.useState)(w),[R,z]=(0,F.useState)(null),B=(0,F.useRef)(P);B.current=P;let V=(0,F.useRef)(null),[H,U]=(0,F.useState)(0),W=(0,F.useRef)(Promise.resolve()),G=(0,F.useRef)(re),K=(0,F.useCallback)((e,t={})=>c.servers().then(n=>{let r=n.filter(e=>e.ok),i=r.find(t=>t.id===e)??r.find(e=>e.id===`main`)??r[0],a=i?.upstreams??[];return t.isLive&&!t.isLive()||!i&&!t.clear||(f(i?.id??null),oe(a)),a}).catch(()=>null),[]);(0,F.useEffect)(()=>{let e=!0;return t.settings().then(ue,()=>(l(!0),re)).then(t=>{e&&(G.current=t,n(t),i(ie(t.onboarding)))}),K(null,{isLive:()=>e}),t.catalog().then(t=>e&&de(t.entries)).catch(()=>void 0),()=>{e=!1}},[K]);let q=(0,F.useCallback)(e=>{let r={...G.current,onboarding:e};G.current=r,n(r);let i=()=>t.saveSettings(r).then(()=>l(!1),()=>l(!0));return W.current=W.current.then(i,i),W.current},[]),J=()=>{let e=B.current;if(e.pending){let t=e.pending;E(e=>v({added:e,gatewayId:null},t).added),f(t.gatewayId)}e.state!==`idle`&&ge(),L(w)},Y=e=>{ce(r,P)?z(()=>e):e()},X=(e,t)=>{r===`server`&&e!==`server`&&(J(),A(!1)),N.current=!0,i(e),q(te(G.current.onboarding,e,t))},Z=async(e=`/`)=>{r===`server`&&J(),await q(S(G.current.onboarding)),g(e)};(0,F.useEffect)(()=>{if(r===`server`)return a(e=>L(t=>ae(t,e)))},[r]),(0,F.useEffect)(()=>{H&&V.current?.querySelector(`button`)?.focus()},[H]),(0,F.useEffect)(()=>{if(!N.current)return;he.current?.focus();let e=matchMedia(`(prefers-reduced-motion: reduce)`).matches;window.scrollTo({top:0,behavior:e?`auto`:`smooth`})},[r]),(0,F.useEffect)(()=>{let e=document.title;return document.title=`Step ${b.indexOf(r)+1} of ${b.length}: ${C[r]} – hardened-mcp`,()=>{document.title=e}},[r]);let Q=b.indexOf(r),$=e?.onboarding.done??[],Te=[...p,...pe(T,P.pending).map(e=>e.upstreamName)],De=ce(r,P);return(0,I.jsxs)(`div`,{className:`min-h-dvh bg-canvas text-ink`,children:[(0,I.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-faint bg-canvas/95`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-6xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[#2a2623]`,children:(0,I.jsx)(`img`,{src:`/brand/mark.svg`,alt:``,width:24,height:24})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[15px] font-semibold`,children:`Getting started`}),(0,I.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:`hardened-mcp`})]}),(0,I.jsx)(d,{variant:`ghost`,size:`sm`,iconRight:`arrow-right`,onClick:()=>Y(()=>void Z()),children:`Go to the console`})]})}),e?(0,I.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10 lg:py-10`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Guide steps`,className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,I.jsxs)(`div`,{className:`lg:hidden`,children:[(0,I.jsxs)(`p`,{className:`text-[13px] font-semibold text-soft`,children:[`Step `,Q+1,` of `,b.length]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-line`,role:`progressbar`,"aria-label":`Progress through the guide`,"aria-valuemin":1,"aria-valuemax":b.length,"aria-valuenow":Q+1,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${(Q+1)/b.length*100}%`}})})]}),(0,I.jsx)(`ol`,{className:`hidden flex-col gap-1 lg:flex`,children:b.map((e,t)=>{let n=e===r,i=$.includes(e);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>e===r?void 0:Y(()=>X(e)),"aria-current":n?`step`:void 0,className:_(`flex w-full items-center gap-3 rounded-2xl px-3 py-2.5 text-left text-[14px] transition-colors`,n?`bg-surface font-semibold shadow-[var(--shadow-sm)]`:`text-muted hover:bg-faint`),children:[(0,I.jsx)(`span`,{className:_(`tnum grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12.5px] font-bold`,i?`bg-primary text-white`:n?`border-2 border-[var(--primary)] text-ink`:`border-[1.5px] border-line text-soft`),children:i?(0,I.jsx)(s,{name:`check`,size:14,strokeWidth:2.6}):t+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:C[e]}),i&&(0,I.jsx)(`span`,{className:`sr-only`,children:`(done)`})]})},e)})})]}),(0,I.jsxs)(`main`,{className:`min-w-0`,children:[(0,I.jsxs)(`article`,{className:`card p-5 sm:p-8`,"aria-labelledby":`start-step-h`,children:[(0,I.jsxs)(`p`,{className:`eyebrow text-soft`,children:[`Step `,Q+1,` · `,C[r]]}),(0,I.jsx)(`h1`,{id:`start-step-h`,ref:he,tabIndex:-1,className:`display mt-2 text-[28px] outline-none sm:text-[34px]`,children:ne[r]}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[r===`welcome`&&(0,I.jsx)(ve,{}),r===`computer`&&(0,I.jsx)(ye,{entries:k}),r===`server`&&(0,I.jsx)(be,{gatewayId:u,existing:p,added:T,entries:k,onAdded:e=>{f(e.gatewayId),E(t=>pe(t,e)),L(w),U(e=>e+1)},onClosed:()=>L(w)}),r===`app`&&(0,I.jsx)(xe,{gatewayId:u,onAttached:e=>{O(e),U(e=>e+1)},onConnected:(e,t)=>{O({configPath:e.configPath,entryName:``,backupPath:e.backupPath,alreadyConnected:e.alreadyConnected,restartHint:e.restartHint,appLabel:t.label,scope:t.scope}),f(e.toolbox.id),A(!1),K(e.toolbox.id),y(e)&&q(x(G.current.onboarding,`server`)),U(e=>e+1)},onUndone:()=>{O(null),K(u,{clear:!0}).then(e=>{e&&q(me(G.current.onboarding,e.length))})},onNeedsServer:()=>A(!0),onAddServer:()=>{A(!0),X(`server`)},onProtect:()=>X(`protect`)}),r===`try`&&(0,I.jsx)(Se,{entries:k,servers:Te,appLabel:D?.appLabel??null}),r===`protect`&&(0,I.jsx)(Ce,{gatewayId:u,onAddServer:()=>X(`server`),applyRef:j}),r===`done`&&(0,I.jsx)(we,{gatewayId:u,onLeave:e=>void Z(e)})]}),(0,I.jsxs)(`footer`,{className:_(`mt-8 flex-wrap items-center gap-2 border-t border-faint pt-5`,De?`hidden`:`flex`),children:[Q>0&&(0,I.jsx)(d,{variant:`ghost`,icon:`arrow-left`,onClick:()=>X(le(r)),children:`Back`}),(0,I.jsx)(`span`,{className:`flex-1`}),r!==`done`&&(0,I.jsx)(d,{variant:`ghost`,onClick:()=>Y(()=>X(ee(r,$,!1))),children:`Skip for now`}),(0,I.jsx)(Ee,{buttonRef:V,step:r,ready:se(r,Te.length,!!D,P),busy:_e,onNext:async()=>{r===`protect`&&j.current&&(M(!0),!await j.current().finally(()=>M(!1)))||X(ee(r,$,fe),r)},onFinish:()=>void Z()})]})]}),(0,I.jsx)(h,{open:!!R,onClose:()=>z(null),title:`Leave without saving this server?`,description:`You're in the middle of setting up a server. If you leave now, it isn't added, and you'd start it again next time.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{variant:`ghost`,onClick:()=>{let e=R;z(null),e?.()},children:`Leave without saving`}),(0,I.jsx)(d,{variant:`primary`,onClick:()=>z(null),children:`Keep setting it up`})]})}),o&&(0,I.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-soft`,role:`status`,children:`Your progress couldn't be saved, so the guide may start over next time. Everything you add is still saved.`})]})]}):(0,I.jsx)(`main`,{className:`flex min-h-[60dvh] items-center justify-center`,children:(0,I.jsxs)(`p`,{role:`status`,className:`flex items-center gap-3 text-soft`,children:[(0,I.jsx)(m,{}),` Getting things ready…`]})})]})}function Ee({buttonRef:e,step:t,ready:n,busy:r,onNext:i,onFinish:a}){if(t===`done`)return(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:a,children:`Go to the console`})});let o=t===`welcome`?`Let's start`:t===`try`?`I've tried it`:`Continue`,s=n?null:t===`server`?`Add a server first, or skip for now.`:`Connect an app first, or skip for now.`;return(0,I.jsxs)(I.Fragment,{children:[s&&(0,I.jsx)(`p`,{id:`start-continue-why`,className:`order-last basis-full text-right text-[13px] text-soft`,children:s}),(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:i,disabled:!n,loading:r,"aria-describedby":s?`start-continue-why`:void 0,children:o})})]})}export{Te as StartPage};
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-BHB_ha4i.js";import{$n as v,Bn as y,Fn as b,Gn as x,Hn as S,In as C,Jn as ee,Kn as te,Ln as ne,Nn as w,Pn as re,Qn as ie,Rn as ae,Un as oe,Vn as se,Wn as ce,X as T,Xn as le,Yn as ue,Z as E,at as D,er as O,it as k,ot as de,qn as fe,st as A,tr as pe,zn as me}from"./index-DywhXnhV.js";import{o as he,r as j,s as ge,t as _e}from"./AttachApp-eNBD48eb.js";import{n as M,p as N,t as P}from"./connect-app-words-Dy16Vpfd.js";var F=i(),I=f(),L=[[`Runs freely`,`fill-allow`],[`Asks you first`,`fill-approve`],[`Blocked`,`fill-deny`]],R=[`Files`,`GitHub`,`Notion`,`and more…`];function z(){let e=(0,F.useId)(),t=`${e}-t`,n=`${e}-d`,r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`title`,{id:t,children:`How hardened-mcp fits in`}),(0,I.jsx)(`desc`,{id:n,children:`Your AI app talks to hardened-mcp, the toolbox. The toolbox checks every action: it runs freely, asks you first, or is blocked. Then it passes allowed actions on to your servers, such as files, GitHub and Notion.`})]});return(0,I.jsxs)(`figure`,{className:`m-0 text-ink`,children:[(0,I.jsxs)(`svg`,{viewBox:`0 0 760 236`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`hidden h-auto w-full sm:block`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:8,y:58}),(0,I.jsx)(V,{x1:190,y1:118,x2:250,y2:118,id:e}),(0,I.jsx)(W,{x:258,y:20}),(0,I.jsx)(V,{x1:508,y1:118,x2:568,y2:118,id:e}),(0,I.jsx)(G,{x:576,y:34})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 320 560`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`mx-auto block h-auto w-full max-w-[320px] sm:hidden`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:68,y:4}),(0,I.jsx)(V,{x1:160,y1:126,x2:160,y2:160,id:e}),(0,I.jsx)(W,{x:35,y:168}),(0,I.jsx)(V,{x1:160,y1:364,x2:160,y2:398,id:e}),(0,I.jsx)(G,{x:68,y:406,compact:!0})]})]})}function B({id:e}){return(0,I.jsx)(`defs`,{children:(0,I.jsx)(`marker`,{id:`${e}-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,I.jsx)(`path`,{d:`M1 1 9 5 1 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function V({x1:e,y1:t,x2:n,y2:r,id:i}){return(0,I.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,className:`stroke-soft text-soft`,strokeWidth:`2`,strokeDasharray:`5 5`,markerEnd:`url(#${i}-arrow)`})}function H({x:e,y:t,children:n,size:r=15,weight:i=600,className:a=`fill-ink`,anchor:o=`middle`}){return(0,I.jsx)(`text`,{x:e,y:t,textAnchor:o,fontSize:r,fontWeight:i,className:a,style:{fontFamily:`var(--font-sans)`},children:n})}function U({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`184`,height:`120`,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsxs)(`g`,{transform:`translate(76 18)`,className:`text-muted`,children:[(0,I.jsx)(`path`,{d:`M4 4h24a4 4 0 0 1 4 4v13a4 4 0 0 1-4 4H14l-7 6v-6H4a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`circle`,{cx:`9`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`16`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`23`,cy:`14.5`,r:`1.8`,fill:`currentColor`})]}),(0,I.jsx)(H,{x:92,y:76,children:`Your AI app`}),(0,I.jsx)(H,{x:92,y:98,size:14,weight:500,className:`fill-soft`,children:`Claude, Cursor, VS Code…`})]})}function W({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`250`,height:`196`,rx:`26`,className:`fill-green-deep`}),(0,I.jsxs)(`g`,{transform:`translate(110 16)`,className:`text-white`,children:[(0,I.jsx)(`path`,{d:`M15 2 27 6.5v9.4c0 7-4.5 11.8-12 14.8C7.5 27.7 3 22.9 3 15.9V6.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`m9.5 16 4 4 7-8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),(0,I.jsx)(H,{x:125,y:68,size:17,weight:700,className:`fill-white`,children:`hardened-mcp`}),(0,I.jsx)(H,{x:125,y:88,size:14,weight:500,className:`fill-on-hero-soft`,children:`the toolbox that checks every action`}),L.map(([e,t],n)=>(0,I.jsxs)(`g`,{transform:`translate(34 ${108+n*26})`,children:[(0,I.jsx)(`rect`,{width:`182`,height:`22`,rx:`11`,fill:`white`,fillOpacity:`0.12`}),(0,I.jsx)(`circle`,{cx:`14`,cy:`11`,r:`5`,className:t}),(0,I.jsx)(H,{x:28,y:15.5,size:14,weight:600,className:`fill-white`,anchor:`start`,children:e})]},e))]})}function G({x:e,y:t,compact:n}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`176`,height:n?150:168,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsx)(H,{x:88,y:28,size:14.5,weight:700,className:`fill-soft`,children:`Your servers`}),R.map((e,t)=>(0,I.jsxs)(`g`,{transform:`translate(18 ${42+t*(n?26:30)})`,children:[(0,I.jsx)(`rect`,{width:`140`,height:`22`,rx:`7`,className:t===R.length-1?`fill-transparent`:`fill-sunken`}),t<R.length-1&&(0,I.jsx)(`circle`,{cx:`13`,cy:`11`,r:`3.5`,className:`fill-ok`}),(0,I.jsx)(H,{x:t<R.length-1?26:8,y:15.5,size:12.5,weight:500,className:`fill-muted`,anchor:`start`,children:e})]},e))]})}function K({text:e}){let t=e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).filter(Boolean);return(0,I.jsx)(I.Fragment,{children:t.map((e,t)=>e.startsWith("`")?(0,I.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] break-words text-ink`,children:e.slice(1,-1)},t):e.startsWith(`**`)?(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:e.slice(2,-2)},t):(0,I.jsx)(`span`,{children:e},t))})}function q({children:e}){return(0,I.jsx)(`p`,{className:`max-w-2xl text-[15.5px] leading-relaxed text-muted`,children:e})}function J({icon:e,title:t,children:n}){return(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e,size:17})}),(0,I.jsxs)(`span`,{className:`min-w-0 pt-0.5`,children:[(0,I.jsx)(`span`,{className:`block text-[15px] font-medium`,children:t}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] leading-relaxed text-soft`,children:n})]})]})}function ve(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,I.jsx)(q,{children:`hardened-mcp lets your AI app use tools, like your files, GitHub or Notion. It doesn't give the AI everything. You get a toolbox. Your AI app connects to it, and every action goes through it first. When protection is on, reading runs freely. Every change asks you first. Anything outside the folders and services you gave it is blocked. Everything is written down, so you can always see what your AI did.`}),(0,I.jsx)(`div`,{className:`rounded-[22px] bg-sunken/60 p-4 sm:p-6`,children:(0,I.jsx)(z,{})}),(0,I.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,I.jsxs)(`section`,{"aria-labelledby":`what-mcp`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsxs)(`h2`,{id:`what-mcp`,className:`flex items-center gap-2 text-[16px] font-semibold`,children:[`What's an MCP server? `,(0,I.jsx)(l,{term:`mcp`})]}),(0,I.jsx)(`p`,{className:`mt-2 text-[14px] leading-relaxed text-muted`,children:`It's a small add-on that gives your AI app a set of tools: reading a folder, searching the web, opening an issue on GitHub. MCP is a shared standard, so any AI app can use any of them. In a minute you'll bring in the ones your AI app already has, or add your first one.`})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-expect`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsx)(`h2`,{id:`what-expect`,className:`text-[16px] font-semibold`,children:`What to expect`}),(0,I.jsxs)(`ul`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`About 5 minutes`,children:`Seven short steps. You can skip any of them and come back later from Settings & help.`}),(0,I.jsx)(J,{icon:`lock`,title:`Nothing changes until you say so`,children:`Your AI apps keep working exactly as they do now until you choose to connect one.`}),(0,I.jsx)(J,{icon:`eye`,title:`It starts by watching`,children:`At first your toolbox lets everything run and writes down what it would have asked you about or blocked, so nothing you rely on breaks. In step 6 you choose whether to turn protection on straight away.`})]})]})]})]})}function Y(e,t){let n=t.find(t=>t.id===e),r=e===`node`?t.find(e=>e.id===`npx`):e===`uv`?t.find(e=>e.id===`uvx`):void 0;return!n?.found||r&&!r.found?{status:{tone:`neutral`,label:`Not installed`,icon:`minus`},check:n,state:`missing`}:n?.running===!1?{status:{tone:`warn`,label:`Installed, not running`,icon:`pause`},check:n,state:`stopped`}:{status:{tone:`ok`,label:`Ready`,icon:`check`},check:n,state:`ready`}}function ye({entries:e}){let i=p(()=>t.doctor(),[]),[a,o]=(0,F.useState)(!1),s=i.data,c=A(s?.platform),u=fe(e),f=()=>{o(!0),i.reload(),setTimeout(()=>o(!1),700)},m=s?de.map(e=>({rt:e,...Y(e,s.checks)})):[],h=m.filter(e=>e.state!==`ready`),g=m.some(e=>e.rt===`node`&&e.state===`ready`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Most servers need a free helper program to run, such as Node.js. This looks for them on this computer. It only looks; it never installs or changes anything. `,(0,I.jsx)(l,{term:`machineCheck`})]}),i.error&&!s?(0,I.jsx)(r,{tone:`warn`,title:`The check couldn't run`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a,children:`Check again`}),children:`You can skip this step. If a server needs something that's missing, it will tell you when you test it.`}):s?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{tone:h.length===0?`ok`:g?`info`:`warn`,role:`status`,title:h.length===0?`Everything is ready`:g?`You're ready for your first server`:`Some servers need something installed first`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a||i.loading,children:`Check again`}),children:h.length===0?`This computer has everything servers need.`:g?`Some servers need other helpers, listed below. You don't need them unless you add one of those servers.`:`That's fine. You can carry on and only install something when a server you want needs it.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`What this computer has`,children:m.map(e=>(0,I.jsx)(X,{rt:e.rt,status:e.status,check:e.check,state:e.state,os:c,needs:u[e.rt]},e.rt))})]}):(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,"aria-label":`Checking your computer`,children:(0,I.jsx)(n,{height:64,lines:3})})]})}function X({rt:t,status:n,check:r,state:i,os:a,needs:s}){let c=k[t],[l,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(a),h=`install-${t}`;return(0,I.jsxs)(`li`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,I.jsx)(`p`,{className:`flex flex-wrap items-center gap-2 text-[15px] font-semibold`,children:c.name}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:c.why}),i!==`ready`&&s.length>0&&(0,I.jsxs)(`p`,{className:`mt-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:`Needed by:`}),` `,s.join(`, `)]}),i===`ready`&&(r?.path||r?.version)&&(0,I.jsxs)(`details`,{className:`mt-1 text-[12px] text-soft`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),r?.version&&(0,I.jsxs)(`span`,{className:`mono block`,children:[`Version `,r.version]}),r?.path&&(0,I.jsx)(`code`,{className:`mono block break-all`,children:r.path})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,I.jsx)(e,{tone:n.tone,icon:n.icon,children:n.label}),i!==`ready`&&(0,I.jsx)(d,{size:`sm`,variant:`ghost`,iconRight:`chevron`,"aria-expanded":l,"aria-controls":h,onClick:()=>f(!l),children:i===`stopped`?`How to start it`:`How to install it`})]})]}),l&&i!==`ready`&&(0,I.jsx)(`div`,{id:h,className:`mt-4 border-t border-faint pt-4`,children:i===`stopped`&&c.start?(0,I.jsx)(`p`,{className:`text-[14px] leading-relaxed text-muted`,children:(0,I.jsx)(K,{text:c.start[p]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{size:`sm`,label:`Install steps for ${c.name}: choose your computer`,value:p,onChange:m,options:[`darwin`,`win32`,`linux`].map(e=>({value:e,label:D[e]}))}),(0,I.jsx)(`ol`,{className:`mt-4 flex flex-col gap-3`,children:c.steps[p].map((e,t)=>(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`tnum grid h-6 w-6 shrink-0 place-items-center rounded-full bg-sunken text-[12px] font-bold text-muted`,children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 text-[14px] leading-relaxed text-muted`,children:[(0,I.jsx)(K,{text:e.text}),e.copy&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`mono min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[12.5px] break-all text-ink`,children:e.copy}),(0,I.jsx)(E,{text:e.copy,label:`Copy`})]}),e.link&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(u,{href:e.link.url,external:!0,size:`sm`,iconRight:`external`,children:e.link.label})})]})]},t))})]})})]})}function be({gatewayId:e,existing:t,added:n,entries:i,onAdded:a,onClosed:o}){let[s,c]=(0,F.useState)(n.length===0&&t.length===0),l=n.at(-1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Pick a server to give your AI app its first tools. Each one comes with step-by-step instructions, and you can test it before anything is saved. If you're not sure, `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Files on this computer`}),` `,`is a good first choice: it lets the AI read and edit files in one folder you choose, and nothing outside it.`]}),l&&(0,I.jsx)(r,{tone:`ok`,role:`status`,title:l.displayName?`${l.displayName} is in your toolbox`:`Added to your toolbox`,children:l.summary.length>0?(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.summary.map(e=>(0,I.jsx)(`li`,{children:e},e))}):`It's saved in your toolbox.`}),!l&&t.length>0&&(0,I.jsxs)(r,{tone:`info`,title:`You already have servers`,children:[`Your toolbox has `,t.map(e=>oe(i,e)?.name??e).join(`, `),`. You can add another or carry on.`]}),s?(0,I.jsx)(he,{gatewayId:e,compact:!0,onDone:e=>{a(e),c(!1)},onCancel:n.length>0||t.length>0?()=>{c(!1),o?.()}:void 0}):(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:()=>c(!0),children:`Add another server`})})]})}var Z=(e,t)=>`/tools?server=${encodeURIComponent(e)}&app=${encodeURIComponent(t)}`;function xe({gatewayId:e,onAttached:t,onConnected:n,onUndone:r,onNeedsServer:i,onAddServer:a,onProtect:o}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[N,` `,(0,I.jsx)(l,{term:`toolbox`})]}),(0,I.jsxs)(`div`,{className:`rounded-[18px] bg-sunken/60 p-4 sm:p-5`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[(0,I.jsx)(s,{name:`refresh`,size:17,className:`text-ok`}),`Restart your app once`]}),(0,I.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-muted`,children:`Your AI app only looks for new tools when it starts. After connecting, quit it completely (not just close the window) and open it again. You only do this once: servers you add or change later appear on their own.`})]}),(0,I.jsx)(j,{newTab:!0,keep:!0,toolsHref:Z,protect:()=>({onClick:o}),addServer:{onClick:a},onConnected:n,onNeedsServer:i,onUndone:r}),(0,I.jsxs)(`details`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-[14px] font-semibold select-none`,children:M}),(0,I.jsx)(`p`,{className:`mt-2 text-[13.5px] text-muted`,children:P}),(0,I.jsx)(`div`,{className:`mt-3`,children:e?(0,I.jsx)(_e,{gatewayId:e,compact:!0,onDone:t}):(0,I.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`These need a toolbox. Connect an app above, or add a server first.`})})]})]})}function Se({entries:e,servers:t,appLabel:n}){let{prompt:r,entry:i}=O(e,t),a=n??`your AI app`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Open `,a,` and ask it something that uses your new tools`,i?` from ${i.name}`:``,`. Here's a good first one:`]}),(0,I.jsxs)(`figure`,{className:`m-0 rounded-[20px] border-[1.5px] border-primary/40 bg-ok-tint p-5`,children:[(0,I.jsxs)(`blockquote`,{className:`text-[17px] leading-relaxed font-medium text-ink`,children:[`“`,r,`”`]}),(0,I.jsx)(`figcaption`,{className:`mt-4`,children:(0,I.jsx)(E,{text:r,label:`Copy this`})})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-see`,children:[(0,I.jsx)(`h2`,{id:`what-see`,className:`text-[16px] font-semibold`,children:`What you'll see`}),(0,I.jsxs)(`ol`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`check`,title:`Looking runs straight away`,children:`When the AI only reads something, it just happens. Every action is written down under Activity in this console.`}),(0,I.jsx)(J,{icon:`eye`,title:`At first, changes run too`,children:`A new toolbox starts by watching: everything runs, and Activity notes what would have asked you first or been blocked. In the next step you choose whether it should start protecting you.`}),(0,I.jsxs)(J,{icon:`clock`,title:`Once protection is on, every change asks you first`,children:[`If the AI wants to change something, it stops and tells you it's waiting. The request appears under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Waiting for you`}),` in this console. Approve it or say no there. If you approve, the AI can try again and it goes ahead. Anything outside the folders and services you gave it is blocked.`]}),(0,I.jsxs)(J,{icon:`warning`,title:`If nothing happens`,children:[`Check that you quit `,a,` completely and opened it again. If a tool still doesn't show up, open Connections in this console: each server says whether it's working, and if not, why and how to fix it.`]})]}),(0,I.jsx)(`div`,{className:`mt-5`,children:(0,I.jsx)(u,{href:`/approvals`,external:!0,icon:`clock`,iconRight:`external`,children:`Open Waiting for you`})})]})]})}var 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 Ce({gatewayId:t,onAddServer:i,applyRef:a}){let[o,s]=(0,F.useState)(`protect`),[l,u]=(0,F.useState)(!1),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),_=p(()=>t?c.protection(t):Promise.resolve(null),[t]),v=(0,F.useRef)(null),y=(0,F.useRef)(!1),b=_.data?.enforcement===`enforce`||h===`protect`,x=_.data&&!_.data.policyWrite.ok?_.data.policyWrite.why:null,S=async()=>{if(m(null),!t||b||h===`watch`)return!0;if(o===`watch`)return y.current=!0,g(`watch`),!0;if(!_.data)return!1;if(x)return m(x),!1;u(!0);try{return await c.setPolicySetting(t,`enforcement`,`enforce`,_.data.policyWrite.digest),y.current=!0,g(`protect`),_.reload(),!0}catch(e){return m(e.message||`Protection couldn't be turned on.`),!1}finally{u(!1)}};return a&&(a.current=S),(0,F.useEffect)(()=>()=>{a&&(a.current=null)},[a]),(0,F.useEffect)(()=>{y.current&&v.current?.focus()},[b,h]),t?_.loading&&!_.data?(0,I.jsx)(n,{height:180}):b?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsxs)(r,{tone:`ok`,title:`Your toolbox is protecting you`,role:`status`,children:[Q,` Requests appear under `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Waiting for you`}),`.`]})}),(0,I.jsxs)(`ul`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`When your AI asks for something`,children:`It stops and tells you it's waiting. Open this console, look at what it wants to do, and approve it or say no.`}),(0,I.jsxs)(J,{icon:`sliders`,title:`Too many questions?`,children:[`Under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` you can let a tool you trust run freely, or approve one for a while.`]})]})]}):h===`watch`?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsx)(r,{tone:`warn`,title:`Your toolbox is only watching for now`,role:`status`,children:`Everything your AI does runs and is written down under Activity. Nothing asks you first and nothing is blocked, so you're not protected yet.`})}),(0,I.jsxs)(q,{children:[`When you're ready, turn protection on under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` `,`(one switch at the top), or come back to this guide from Settings & help.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`ghost`,onClick:()=>g(null),children:`Choose again`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Right now your toolbox only watches: everything your AI does runs, and is written down. Choose whether it should start protecting you now.`}),(0,I.jsx)(T,{label:`How careful should your toolbox be?`,value:o,onChange:s,options:[{value:`protect`,title:`Protect me now`,badge:(0,I.jsx)(e,{tone:`ok`,children:`Recommended`}),body: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,I.jsx)(r,{tone:`warn`,title:`This toolbox's protection can't be changed from the console`,children:x}),f&&(0,I.jsx)(r,{tone:`danger`,role:`alert`,title:`Protection wasn't turned on`,children:f}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`primary`,icon:o===`protect`?`shield-check`:`eye`,loading:l,disabled:!!x&&o===`protect`,onClick:()=>void S(),children:o===`protect`?`Turn on protection`:`Keep watching for now`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(q,{children:`There's nothing to protect yet. Add a server first, then come back here.`}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:i,children:`Add a server`})})]})}var $=[{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 we({gatewayId:e,onLeave:t}){let n=p(()=>e?c.protection(e):Promise.resolve(null),[e]),i=!!n.data&&n.data.enforcement!==`enforce`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Your toolbox is set up. Here's where to go next.`}),i&&(0,I.jsxs)(r,{tone:`warn`,title:`Protection: off (only watching)`,children:[`Everything your AI does runs and is written down, and nothing asks you first. Turn protection on under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Protection settings`}),` when you're ready.`]}),(0,I.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:$.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:e.href,onClick:n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(e.href))},className:_(`card card-link flex h-full gap-3.5 p-5`),children:[(0,I.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e.icon,size:19})}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[15.5px] font-semibold`,children:[e.title,(0,I.jsx)(s,{name:`arrow-right`,size:15,className:`text-soft`})]}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:e.body})]})]})},e.href))}),(0,I.jsx)(r,{tone:`info`,title:`When you need to approve something, open the console`,children:`Approving requests and signing in to services happen here. Your servers keep working without the console open; anything that asks you first waits until you open it again.`})]})}function Te(){let[e,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(`welcome`),[o,l]=(0,F.useState)(!1),[u,f]=(0,F.useState)(null),[p,oe]=(0,F.useState)([]),[T,E]=(0,F.useState)([]),[D,O]=(0,F.useState)(null),[k,de]=(0,F.useState)([]),[fe,A]=(0,F.useState)(!1),he=(0,F.useRef)(null),j=(0,F.useRef)(null),[_e,M]=(0,F.useState)(!1),N=(0,F.useRef)(!1),[P,L]=(0,F.useState)(w),[R,z]=(0,F.useState)(null),B=(0,F.useRef)(P);B.current=P;let V=(0,F.useRef)(null),[H,U]=(0,F.useState)(0),W=(0,F.useRef)(Promise.resolve()),G=(0,F.useRef)(re),K=(0,F.useCallback)((e,t={})=>c.servers().then(n=>{let r=n.filter(e=>e.ok),i=r.find(t=>t.id===e)??r.find(e=>e.id===`main`)??r[0],a=i?.upstreams??[];return t.isLive&&!t.isLive()||!i&&!t.clear||(f(i?.id??null),oe(a)),a}).catch(()=>null),[]);(0,F.useEffect)(()=>{let e=!0;return t.settings().then(ue,()=>(l(!0),re)).then(t=>{e&&(G.current=t,n(t),i(ie(t.onboarding)))}),K(null,{isLive:()=>e}),t.catalog().then(t=>e&&de(t.entries)).catch(()=>void 0),()=>{e=!1}},[K]);let q=(0,F.useCallback)(e=>{let r={...G.current,onboarding:e};G.current=r,n(r);let i=()=>t.saveSettings(r).then(()=>l(!1),()=>l(!0));return W.current=W.current.then(i,i),W.current},[]),J=()=>{let e=B.current;if(e.pending){let t=e.pending;E(e=>v({added:e,gatewayId:null},t).added),f(t.gatewayId)}e.state!==`idle`&&ge(),L(w)},Y=e=>{ce(r,P)?z(()=>e):e()},X=(e,t)=>{r===`server`&&e!==`server`&&(J(),A(!1)),N.current=!0,i(e),q(te(G.current.onboarding,e,t))},Z=async(e=`/`)=>{r===`server`&&J(),await q(S(G.current.onboarding)),g(e)};(0,F.useEffect)(()=>{if(r===`server`)return a(e=>L(t=>ae(t,e)))},[r]),(0,F.useEffect)(()=>{H&&V.current?.querySelector(`button`)?.focus()},[H]),(0,F.useEffect)(()=>{if(!N.current)return;he.current?.focus();let e=matchMedia(`(prefers-reduced-motion: reduce)`).matches;window.scrollTo({top:0,behavior:e?`auto`:`smooth`})},[r]),(0,F.useEffect)(()=>{let e=document.title;return document.title=`Step ${b.indexOf(r)+1} of ${b.length}: ${C[r]} – hardened-mcp`,()=>{document.title=e}},[r]);let Q=b.indexOf(r),$=e?.onboarding.done??[],Te=[...p,...pe(T,P.pending).map(e=>e.upstreamName)],De=ce(r,P);return(0,I.jsxs)(`div`,{className:`min-h-dvh bg-canvas text-ink`,children:[(0,I.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-faint bg-canvas/95`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-6xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[#2a2623]`,children:(0,I.jsx)(`img`,{src:`/brand/mark.svg`,alt:``,width:24,height:24})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[15px] font-semibold`,children:`Getting started`}),(0,I.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:`hardened-mcp`})]}),(0,I.jsx)(d,{variant:`ghost`,size:`sm`,iconRight:`arrow-right`,onClick:()=>Y(()=>void Z()),children:`Go to the console`})]})}),e?(0,I.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10 lg:py-10`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Guide steps`,className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,I.jsxs)(`div`,{className:`lg:hidden`,children:[(0,I.jsxs)(`p`,{className:`text-[13px] font-semibold text-soft`,children:[`Step `,Q+1,` of `,b.length]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-line`,role:`progressbar`,"aria-label":`Progress through the guide`,"aria-valuemin":1,"aria-valuemax":b.length,"aria-valuenow":Q+1,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${(Q+1)/b.length*100}%`}})})]}),(0,I.jsx)(`ol`,{className:`hidden flex-col gap-1 lg:flex`,children:b.map((e,t)=>{let n=e===r,i=$.includes(e);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>e===r?void 0:Y(()=>X(e)),"aria-current":n?`step`:void 0,className:_(`flex w-full items-center gap-3 rounded-2xl px-3 py-2.5 text-left text-[14px] transition-colors`,n?`bg-surface font-semibold shadow-[var(--shadow-sm)]`:`text-muted hover:bg-faint`),children:[(0,I.jsx)(`span`,{className:_(`tnum grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12.5px] font-bold`,i?`bg-primary text-white`:n?`border-2 border-[var(--primary)] text-ink`:`border-[1.5px] border-line text-soft`),children:i?(0,I.jsx)(s,{name:`check`,size:14,strokeWidth:2.6}):t+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:C[e]}),i&&(0,I.jsx)(`span`,{className:`sr-only`,children:`(done)`})]})},e)})})]}),(0,I.jsxs)(`main`,{className:`min-w-0`,children:[(0,I.jsxs)(`article`,{className:`card p-5 sm:p-8`,"aria-labelledby":`start-step-h`,children:[(0,I.jsxs)(`p`,{className:`eyebrow text-soft`,children:[`Step `,Q+1,` · `,C[r]]}),(0,I.jsx)(`h1`,{id:`start-step-h`,ref:he,tabIndex:-1,className:`display mt-2 text-[28px] outline-none sm:text-[34px]`,children:ne[r]}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[r===`welcome`&&(0,I.jsx)(ve,{}),r===`computer`&&(0,I.jsx)(ye,{entries:k}),r===`server`&&(0,I.jsx)(be,{gatewayId:u,existing:p,added:T,entries:k,onAdded:e=>{f(e.gatewayId),E(t=>pe(t,e)),L(w),U(e=>e+1)},onClosed:()=>L(w)}),r===`app`&&(0,I.jsx)(xe,{gatewayId:u,onAttached:e=>{O(e),U(e=>e+1)},onConnected:(e,t)=>{O({configPath:e.configPath,entryName:``,backupPath:e.backupPath,alreadyConnected:e.alreadyConnected,restartHint:e.restartHint,appLabel:t.label,scope:t.scope}),f(e.toolbox.id),A(!1),K(e.toolbox.id),y(e)&&q(x(G.current.onboarding,`server`)),U(e=>e+1)},onUndone:()=>{O(null),K(u,{clear:!0}).then(e=>{e&&q(me(G.current.onboarding,e.length))})},onNeedsServer:()=>A(!0),onAddServer:()=>{A(!0),X(`server`)},onProtect:()=>X(`protect`)}),r===`try`&&(0,I.jsx)(Se,{entries:k,servers:Te,appLabel:D?.appLabel??null}),r===`protect`&&(0,I.jsx)(Ce,{gatewayId:u,onAddServer:()=>X(`server`),applyRef:j}),r===`done`&&(0,I.jsx)(we,{gatewayId:u,onLeave:e=>void Z(e)})]}),(0,I.jsxs)(`footer`,{className:_(`mt-8 flex-wrap items-center gap-2 border-t border-faint pt-5`,De?`hidden`:`flex`),children:[Q>0&&(0,I.jsx)(d,{variant:`ghost`,icon:`arrow-left`,onClick:()=>X(le(r)),children:`Back`}),(0,I.jsx)(`span`,{className:`flex-1`}),r!==`done`&&(0,I.jsx)(d,{variant:`ghost`,onClick:()=>Y(()=>X(ee(r,$,!1))),children:`Skip for now`}),(0,I.jsx)(Ee,{buttonRef:V,step:r,ready:se(r,Te.length,!!D,P),busy:_e,onNext:async()=>{r===`protect`&&j.current&&(M(!0),!await j.current().finally(()=>M(!1)))||X(ee(r,$,fe),r)},onFinish:()=>void Z()})]})]}),(0,I.jsx)(h,{open:!!R,onClose:()=>z(null),title:`Leave without saving this server?`,description:`You're in the middle of setting up a server. If you leave now, it isn't added, and you'd start it again next time.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{variant:`ghost`,onClick:()=>{let e=R;z(null),e?.()},children:`Leave without saving`}),(0,I.jsx)(d,{variant:`primary`,onClick:()=>z(null),children:`Keep setting it up`})]})}),o&&(0,I.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-soft`,role:`status`,children:`Your progress couldn't be saved, so the guide may start over next time. Everything you add is still saved.`})]})]}):(0,I.jsx)(`main`,{className:`flex min-h-[60dvh] items-center justify-center`,children:(0,I.jsxs)(`p`,{role:`status`,className:`flex items-center gap-3 text-soft`,children:[(0,I.jsx)(m,{}),` Getting things ready…`]})})]})}function Ee({buttonRef:e,step:t,ready:n,busy:r,onNext:i,onFinish:a}){if(t===`done`)return(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:a,children:`Go to the console`})});let o=t===`welcome`?`Let's start`:t===`try`?`I've tried it`:`Continue`,s=n?null:t===`server`?`Add a server first, or skip for now.`:`Connect an app first, or skip for now.`;return(0,I.jsxs)(I.Fragment,{children:[s&&(0,I.jsx)(`p`,{id:`start-continue-why`,className:`order-last basis-full text-right text-[13px] text-soft`,children:s}),(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:i,disabled:!n,loading:r,"aria-describedby":s?`start-continue-why`:void 0,children:o})})]})}export{Te as StartPage};
@@ -1 +1 @@
1
- import{$ as e,B as t,Ct as n,Et as r,G as i,H as a,It as o,Nt as s,O as c,Ot as l,Pt as u,U as d,W as f,Z as p,_ as m,_t as h,b as g,c as _,d as v,et as y,ht as b,kt as x,mt as S,pt as C,s as w,w as T,wt as E,x as D,y as O,z as k}from"./kit-BHB_ha4i.js";import{dt as A,ft as j,ht as M,lt as N,mt as P,pn as F,pt as I,ut as L}from"./index-Cm4wG2zz.js";var R=o(),z=`Suggested from what watch-only mode recorded`;async function B(e,t,n){if(!A(n.match)&&n.effect){let r={tool:n.match,effect:n.effect,decision:n.decision,...n.args?{args:n.args}:{},...n.on_violation?{on_violation:n.on_violation}:{},...n.unknown_args?{unknown_args:n.unknown_args}:{},reason:n.reason??z};return{kind:`tool`,body:r,preview:await u.toolRulePreview(e,r,t)}}let r={...n,reason:n.reason??z};return{kind:`rules`,rule:r,preview:await u.previewRules(e,{op:`add`,rule:r,index:0},t)}}function V(e){if(e.kind===`tool`){let t=e.preview,n=t.overriddenReason;return{override:n,drop:t.dropsBounds,destructive:e.body.effect===`destructive`&&e.body.decision===`allow`,loosens:t.loosens,refused:t.writable.ok?n&&!t.overridesAllowed?`This toolbox does not let the console reverse rule ${n.ruleId}. Change it in the protection settings file instead.`:null:t.writable.why??`The protection settings file cannot be changed from here.`}}let t=e.preview;return{override:null,drop:null,destructive:!1,loosens:t.loosens,refused:t.writable.ok?t.loosens&&!t.overridesAllowed?`This toolbox lets the console tighten its rules but not loosen them.`:null:t.writable.why??`The protection settings file cannot be changed from here.`}}async function H(e,t,n,r){if(n.kind===`tool`){let i=n.preview,a={...r.override&&i.overriddenReason?{overrideDeny:i.overriddenReason.ruleId}:{},...r.drop&&i.dropsBounds?{dropBounds:!0}:{},...r.destructive?{destructiveAllow:!0}:{}};return{warning:(await u.setToolRule(e,{...n.body,expectedDigest:i.expectedDigest,...Object.keys(a).length>0?{acknowledged:a}:{}},t)).warning}}return{warning:(await u.addRule(e,n.rule,n.preview.expectedDigest,0,r.loosens?{loosens:!0}:void 0,t)).warning}}var U=e=>e instanceof s&&e.needsLoosenAck,W=x();function G({serverId:e,tenant:t,rule:n,onClose:r,onApplied:o}){let s=O(),[c,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,_]=(0,R.useState)({override:!1,drop:!1,destructive:!1}),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(!1),E=(0,R.useCallback)(()=>{u(null),f(null),m(null),_({override:!1,drop:!1,destructive:!1}),B(e,t,n).then(u).catch(e=>f(I(e.message)))},[e,t,n]);(0,R.useEffect)(E,[E]);let k=c?V(c):null,A=c!==null&&k!==null&&!k.refused&&(!k.override||h.override)&&(!k.drop||h.drop)&&(!k.destructive||h.destructive);async function M(i){if(c){w(!0),m(null);try{let{warning:a}=await H(e,t,c,{...h,loosens:i});s.show(`ok`,`Rule applied for ${n.match}.`),a&&s.show(`warn`,I(a)),o(),r()}catch(e){!i&&U(e)?S(!0):(S(!1),m(j(e)?{text:N,stale:!0}:{text:I(e.message),stale:!1}))}finally{w(!1)}}}let F=P(n);if(x&&c){let e=c.kind===`rules`?c.preview.loosenReasons.map(I):[];return(0,W.jsx)(g,{open:!0,title:`Let these calls run without asking?`,confirmLabel:`Apply rule`,busy:C,error:p?.text,onCancel:()=>S(!1),onConfirm:()=>void M(!0),consequences:e.length>0?e:[`Calls to ${n.match} that today ask you first will run on their own while their inputs look like the ones seen.`],children:`This rule lets more through than your settings do now. Calls outside what was seen still ask you or are blocked.`})}return(0,W.jsx)(D,{open:!0,onClose:r,dismissable:!C,width:600,title:`Apply suggested rule`,description:(0,W.jsxs)(W.Fragment,{children:[F.lead,` `,(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-ink`,children:F.subject}),F.rest]}),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{variant:`secondary`,onClick:r,disabled:C,children:`Cancel`}),(0,W.jsx)(b,{variant:`primary`,disabled:!A,loading:C,onClick:()=>k?.loosens?S(!0):void M(!1),children:`Apply rule`})]}),children:(0,W.jsx)(`div`,{className:`space-y-4 pb-1 text-[14px]`,children:d?(0,W.jsx)(a,{tone:`danger`,title:`The rule could not be checked`,actions:(0,W.jsx)(b,{size:`sm`,onClick:E,children:`Try again`}),children:d}):!c||!k?(0,W.jsx)(i,{lines:4}):(0,W.jsxs)(W.Fragment,{children:[c.kind===`tool`?(0,W.jsxs)(`div`,{className:`rounded-2xl bg-sunken px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`What changes for this tool`}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Now`}),(0,W.jsx)(y,{decision:c.preview.current.kind}),(0,W.jsx)(l,{name:`arrow-right`,size:16,className:`text-soft`}),(0,W.jsx)(`span`,{className:`text-[13px] text-muted`,children:`After`}),(0,W.jsx)(y,{decision:c.preview.verdict.kind})]}),c.preview.bounds&&c.preview.verdict.kind!==`deny`&&(0,W.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted`,children:[`That holds while its inputs stay within the limits below. A call outside them`,` `,c.preview.bounds.onViolation===`approve`?`asks you first`:`is blocked`,`.`]})]}):(0,W.jsxs)(`div`,{className:`rounded-2xl bg-sunken px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`What changes`}),c.preview.changes.length===0?(0,W.jsx)(`p`,{className:`mt-1 text-[13px] text-muted`,children:`No tool this toolbox serves changes how it is handled.`}):(0,W.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:c.preview.changes.map(e=>(0,W.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.tool}),(0,W.jsx)(y,{decision:e.before}),(0,W.jsx)(l,{name:`arrow-right`,size:14,className:`text-soft`}),(0,W.jsx)(y,{decision:e.after})]},e.tool))})]}),k.refused&&(0,W.jsx)(a,{tone:`info`,title:`This cannot be applied from here`,children:I(k.refused)}),c.kind===`tool`&&c.preview.overridden&&(0,W.jsx)(a,{tone:`warn`,children:I(c.preview.overridden)}),c.kind===`tool`&&c.preview.nameContradiction&&(0,W.jsx)(a,{tone:`warn`,children:I(c.preview.nameContradiction)}),c.kind===`tool`&&!c.preview.reloads&&(0,W.jsx)(`p`,{className:`text-[13px] text-muted`,children:`This toolbox reads its settings only when it starts, so the rule applies after a restart.`}),!k.refused&&(k.override||k.drop||k.destructive)&&(0,W.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-bad/40 px-4 py-3`,children:[k.override&&(0,W.jsx)(T,{checked:h.override,onChange:e=>_(t=>({...t,override:e})),label:`Reverse rule ${k.override.ruleId}`,description:`Someone set this tool to "${k.override.decision}" with the note "${k.override.reason}". This rule overrides that.`}),k.drop&&(0,W.jsx)(T,{checked:h.drop,onChange:e=>_(t=>({...t,drop:e})),label:`Drop the input limits this tool has today`,description:`Rule ${k.drop} limits this tool's inputs now. Those limits would no longer apply.`}),k.destructive&&(0,W.jsx)(T,{checked:h.destructive,onChange:e=>_(t=>({...t,destructive:e})),label:`Let a tool that deletes run without asking`,description:`Your AI app could remove things with nobody asked first.`})]}),p&&(0,W.jsx)(a,{tone:`danger`,role:`alert`,actions:p.stale?(0,W.jsx)(b,{size:`sm`,onClick:E,children:`Reload preview`}):void 0,children:p.text}),(0,W.jsxs)(`details`,{className:`group`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-medium text-muted select-none`,children:`Show the rule as written in the settings file`}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(v,{label:`Rule as written`,maxHeight:240,children:(c.kind,c.preview.yaml??``)})})]})]})})})}var K=[{value:`24h`,label:`Last 24 hours`,ms:864e5,phrase:`in the last 24 hours`},{value:`7d`,label:`Last 7 days`,ms:6048e5,phrase:`in the last 7 days`},{value:`all`,label:`Everything`,ms:null,phrase:`so far`}];function q(){let{serverId:t,tenant:o,nav:s}=F(),l=s.query.get(`since`),f=l===`24h`||l===`7d`?l:`all`,p=K.find(e=>e.value===f),g=(0,R.useMemo)(()=>p.ms?new Date(Date.now()-p.ms).toISOString():void 0,[p]),v=w(()=>u.suggestions(t,g),[t,g]),y=w(()=>u.protection(t,o),[t,o]),[x,T]=(0,R.useState)(null),[D,O]=(0,R.useState)(new Set),[A,j]=(0,R.useState)(!1),M=v.data,N=y.data,P=e=>D.has(e.id)||Y(e,N),L=M?M.rules.filter(e=>!P(e)):[],z=(e,t={})=>n(s,e,t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{title:`Suggestions`,subtitle:`Rules drawn from what your AI app did while the toolbox was in watch-only mode.`,actions:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(c,{size:`sm`,label:`Calls since`,value:f,onChange:e=>E(r(s,{since:e===`all`?null:e})),options:K.map(e=>({value:e.value,label:e.label}))}),M&&M.rules.length>0&&(0,W.jsx)(b,{variant:`primary`,icon:`check`,disabled:L.length===0,onClick:()=>j(!0),children:`Apply all safe suggestions`})]})}),N?.enforcement===`enforce`&&M&&M.calls>0&&(0,W.jsx)(`div`,{className:`mb-4`,children:(0,W.jsx)(a,{tone:`info`,title:`This toolbox is protecting`,children:`Suggestions come from calls recorded in watch-only mode. Those already recorded are shown below; new calls add nothing here until the toolbox is in watch-only mode again.`})}),v.error&&!M?(0,W.jsx)(a,{tone:`danger`,title:`The suggestions could not be loaded`,actions:(0,W.jsx)(b,{size:`sm`,onClick:v.reload,children:`Try again`}),children:I(v.error)}):M?M.calls===0?(0,W.jsx)(C,{children:(0,W.jsx)(d,{level:2,icon:`lightbulb`,title:`No calls recorded in watch-only mode ${p.phrase}`,actions:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(h,{href:z(`/protection`,{focus:`mode`}),variant:`primary`,children:`Open protection mode`}),f!==`all`&&(0,W.jsx)(b,{variant:`secondary`,onClick:()=>E(r(s,{since:null})),children:`Show everything`})]}),children:N?.enforcement===`enforce`?`This toolbox is protecting, so calls are not recorded for suggestions. Switch it to watch-only for a while, use your AI app as you normally would, and suggestions appear here.`:`Suggestions appear after your AI app has been used for a while with the toolbox in watch-only mode. Use it as you normally would, then come back.`})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,W.jsx)(S,{title:`Calls seen`,value:k(M.calls),sub:J(M)}),(0,W.jsx)(S,{title:`Would run`,value:k(M.wouldRun),sub:`without asking you`}),(0,W.jsx)(S,{title:`Would ask you`,value:k(M.wouldAsk),sub:`before running`,href:z(`/approvals`),hrefLabel:`Open waiting calls`}),(0,W.jsx)(S,{title:`Would be blocked`,value:k(M.wouldRefuse),sub:`had protection been on`})]}),(0,W.jsxs)(`p`,{className:`mt-3 flex items-center gap-1.5 text-[13px] text-soft`,children:[`Every one of these calls ran. The numbers say what would have happened had your rules been applied.`,(0,W.jsx)(m,{term:`watchOnly`})]}),(0,W.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(X,{title:`Tools nobody has labelled yet`,empty:`Every tool that was called has a label.`,intro:M.onUnclassified===`deny`?`Nobody has said what these do, so with protection on every call to them is blocked. Label each one once.`:`Nobody has said what these do, so with protection on every call to them asks you. Label each one once.`,items:M.unclassified,nav:s,trailing:e=>(0,W.jsx)(h,{size:`sm`,variant:`secondary`,href:n(s,`/tools`,{tool:e.tool}),children:`Label tool`})}),(0,W.jsx)(X,{title:`Calls that would be blocked`,empty:`No call would have been blocked.`,intro:`A rule or setting would stop these. Change it if they should run.`,items:M.refused,nav:s,detail:e=>(0,W.jsxs)(W.Fragment,{children:[I(e.reason),` `,(0,W.jsx)(`span`,{className:`font-mono text-[11.5px]`,children:e.ruleId})]})})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(X,{title:`Calls that would ask you`,empty:`No call would have waited for you.`,intro:`These would wait for your approval each time. Where the calls looked alike, a rule below lets the usual ones run.`,items:M.asked,nav:s,detail:e=>I(e.why),trailing:t=>t.suggested?(0,W.jsx)(e,{tone:`ok`,icon:`lightbulb`,children:`Rule suggested`}):null})}),(0,W.jsxs)(`section`,{className:`mt-8`,"aria-labelledby":`suggested-rules`,children:[(0,W.jsxs)(`header`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{id:`suggested-rules`,className:`text-[22px] font-medium tracking-[-0.02em]`,children:`Suggested rules`}),(0,W.jsx)(m,{term:`rule`}),y.error&&!N&&(0,W.jsx)(e,{tone:`warn`,children:`Could not check which are already applied`})]}),M.rules.length===0?(0,W.jsx)(C,{children:(0,W.jsx)(d,{icon:`lightbulb`,title:`No rules to suggest`,compact:!0,children:`A rule is suggested when a tool asked you at least three times with inputs that look alike. Tools that delete things are always left to you.`})}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:M.rules.map(e=>(0,W.jsx)(Z,{rule:e,note:M.notes[e.id],done:P(e),canWrite:N?.policyWrite.ok??!0,onApply:()=>T(e)},e.id))})]})]}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[0,1,2,3].map(e=>(0,W.jsx)(C,{children:(0,W.jsx)(i,{lines:3,height:18})},e))}),x&&(0,W.jsx)(G,{serverId:t,tenant:o,rule:x,onClose:()=>T(null),onApplied:()=>{O(e=>new Set(e).add(x.id)),y.reload()}}),A&&M&&(0,W.jsx)(Q,{serverId:t,tenant:o,rules:L,onClose:()=>j(!1),onApplied:e=>O(t=>new Set(t).add(e)),onDone:()=>{v.reload(),y.reload()}})]})}function J(e){return!e.from||!e.to?`recorded in watch-only mode`:`${new Date(e.from).toLocaleDateString(void 0,{day:`numeric`,month:`short`})} to ${new Date(e.to).toLocaleDateString(void 0,{day:`numeric`,month:`short`})}`}function Y(e,t){if(!t)return!1;let n=t.tools.find(t=>t.name===e.match);return!!n&&n.consoleRule!==null&&n.verdict.kind===e.decision}function X({title:r,intro:i,empty:a,items:o,nav:s,detail:c,trailing:l}){return(0,W.jsx)(C,{title:r,actions:(0,W.jsx)(e,{tone:`neutral`,children:t(o.length,`tool`)}),children:o.length===0?(0,W.jsx)(d,{icon:`check`,title:a,compact:!0}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`-mt-2 mb-2 text-[13px] text-soft`,children:i}),(0,W.jsx)(`div`,{className:`-my-1`,children:o.map(e=>(0,W.jsx)(f,{leading:(0,W.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken`,children:(0,W.jsx)(p,{effect:e.effect})}),title:(0,W.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.tool}),sub:(0,W.jsxs)(W.Fragment,{children:[`Called `,t(e.calls,`time`),c&&(0,W.jsxs)(W.Fragment,{children:[` · `,c(e)]})]}),trailing:l?.(e)??(0,W.jsx)(h,{size:`sm`,variant:`ghost`,href:n(s,`/tools`,{tool:e.tool}),children:`Open tool`})},e.tool))})]})})}function Z({rule:t,note:n,done:r,canWrite:i,onApply:a}){let o=P(t),s=Object.entries(t.args??{});return(0,W.jsxs)(C,{as:`article`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`p`,{className:`text-[17px] leading-snug font-medium tracking-[-0.01em]`,children:[o.lead,` `,(0,W.jsx)(`span`,{className:`font-mono text-[15px] break-all`,children:o.subject}),o.rest]}),(0,W.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-soft`,children:t.id})]}),r?(0,W.jsx)(e,{tone:`ok`,icon:`check`,children:`Applied`}):(0,W.jsx)(b,{variant:`primary`,size:`sm`,onClick:a,disabled:!i,title:i?void 0:`The protection settings file cannot be changed from here`,children:`Apply rule`})]}),n&&(0,W.jsxs)(`p`,{className:`mt-3 text-[13px] text-muted`,children:[`Based on `,n.charAt(0).toLowerCase()+n.slice(1)]}),s.length>0&&(0,W.jsx)(`ul`,{className:`mt-3 space-y-1 rounded-2xl bg-sunken px-4 py-3 text-[13px]`,children:s.map(([e,t])=>(0,W.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[12px] text-ink`,children:e}),(0,W.jsx)(`span`,{className:`text-muted`,children:L(t)})]},e))}),(0,W.jsxs)(`details`,{className:`mt-3`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-medium text-muted select-none`,children:`Show the rule as written`}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(v,{label:`Rule ${t.id}`,maxHeight:260,copy:!0,children:M(t)})})]})]})}function Q({serverId:e,tenant:n,rules:r,onClose:i,onApplied:a,onDone:o}){let s=O(),[c,l]=(0,R.useState)(()=>r.map(e=>({rule:e,state:`waiting`}))),[u,d]=(0,R.useState)(`ready`);async function f(){d(`running`);let i=(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),c=0;for(let[t,o]of r.entries()){i(t,{state:`checking`});try{let r=await B(e,n,o),s=V(r),l=s.refused?I(s.refused):s.loosens?`Lets calls run without asking. Apply it on its own to confirm.`:s.override||s.drop||s.destructive?`Needs your confirmation. Apply it on its own.`:null;if(l){i(t,{state:`skipped`,why:l});continue}let{warning:u}=await H(e,n,r,{});c++,a(o.id),i(t,{state:`applied`,...u?{why:I(u)}:{}})}catch(e){i(t,{state:`failed`,why:j(e)?N:I(e.message)})}}d(`done`),c>0&&s.show(`ok`,`${t(c,`rule`)} applied.`),o()}let p=c.filter(e=>e.state===`applied`).length,m=c.filter(e=>e.state===`skipped`).length,h=c.filter(e=>e.state===`failed`).length,g=c.findIndex(e=>e.state===`checking`);return(0,W.jsx)(D,{open:!0,onClose:i,dismissable:u!==`running`,width:600,title:`Apply all safe suggestions`,description:u===`ready`?`Only rules that let nothing more through than today are applied. Any that would let calls run without asking you are skipped, so you can look at each on its own.`:u===`running`?`Checking ${g+1} of ${c.length}`:`${t(p,`rule`)} applied, ${m} skipped${h?`, ${h} failed`:``}.`,footer:u===`ready`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{variant:`secondary`,onClick:i,children:`Cancel`}),(0,W.jsx)(b,{variant:`primary`,onClick:()=>void f(),children:`Check and apply ${t(c.length,`rule`)}`})]}):(0,W.jsx)(b,{variant:`primary`,onClick:i,disabled:u===`running`,loading:u===`running`,children:`Close summary`}),children:(0,W.jsx)(`ul`,{className:`space-y-2 pb-1`,"aria-live":`polite`,children:c.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 rounded-2xl bg-sunken px-3 py-2.5`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate font-mono text-[13px]`,children:e.rule.match}),e.why&&(0,W.jsx)(`span`,{className:`mt-0.5 block text-[12.5px] text-soft`,children:e.why})]}),(0,W.jsx)($,{state:e.state})]},e.rule.id))})})}function $({state:t}){return t===`applied`?(0,W.jsx)(e,{tone:`ok`,icon:`check`,children:`Applied`}):t===`skipped`?(0,W.jsx)(e,{tone:`warn`,children:`Skipped`}):t===`failed`?(0,W.jsx)(e,{tone:`bad`,icon:`x`,children:`Not applied`}):t===`checking`?(0,W.jsx)(e,{tone:`neutral`,children:`Checking`}):(0,W.jsx)(e,{tone:`neutral`,children:`Waiting`})}export{q as SuggestionsPage};
1
+ import{$ as e,B as t,Ct as n,Et as r,G as i,H as a,It as o,Nt as s,O as c,Ot as l,Pt as u,U as d,W as f,Z as p,_ as m,_t as h,b as g,c as _,d as v,et as y,ht as b,kt as x,mt as S,pt as C,s as w,w as T,wt as E,x as D,y as O,z as k}from"./kit-BHB_ha4i.js";import{dt as A,ft as j,ht as M,lt as N,mt as P,pn as F,pt as I,ut as L}from"./index-DywhXnhV.js";var R=o(),z=`Suggested from what watch-only mode recorded`;async function B(e,t,n){if(!A(n.match)&&n.effect){let r={tool:n.match,effect:n.effect,decision:n.decision,...n.args?{args:n.args}:{},...n.on_violation?{on_violation:n.on_violation}:{},...n.unknown_args?{unknown_args:n.unknown_args}:{},reason:n.reason??z};return{kind:`tool`,body:r,preview:await u.toolRulePreview(e,r,t)}}let r={...n,reason:n.reason??z};return{kind:`rules`,rule:r,preview:await u.previewRules(e,{op:`add`,rule:r,index:0},t)}}function V(e){if(e.kind===`tool`){let t=e.preview,n=t.overriddenReason;return{override:n,drop:t.dropsBounds,destructive:e.body.effect===`destructive`&&e.body.decision===`allow`,loosens:t.loosens,refused:t.writable.ok?n&&!t.overridesAllowed?`This toolbox does not let the console reverse rule ${n.ruleId}. Change it in the protection settings file instead.`:null:t.writable.why??`The protection settings file cannot be changed from here.`}}let t=e.preview;return{override:null,drop:null,destructive:!1,loosens:t.loosens,refused:t.writable.ok?t.loosens&&!t.overridesAllowed?`This toolbox lets the console tighten its rules but not loosen them.`:null:t.writable.why??`The protection settings file cannot be changed from here.`}}async function H(e,t,n,r){if(n.kind===`tool`){let i=n.preview,a={...r.override&&i.overriddenReason?{overrideDeny:i.overriddenReason.ruleId}:{},...r.drop&&i.dropsBounds?{dropBounds:!0}:{},...r.destructive?{destructiveAllow:!0}:{}};return{warning:(await u.setToolRule(e,{...n.body,expectedDigest:i.expectedDigest,...Object.keys(a).length>0?{acknowledged:a}:{}},t)).warning}}return{warning:(await u.addRule(e,n.rule,n.preview.expectedDigest,0,r.loosens?{loosens:!0}:void 0,t)).warning}}var U=e=>e instanceof s&&e.needsLoosenAck,W=x();function G({serverId:e,tenant:t,rule:n,onClose:r,onApplied:o}){let s=O(),[c,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,_]=(0,R.useState)({override:!1,drop:!1,destructive:!1}),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(!1),E=(0,R.useCallback)(()=>{u(null),f(null),m(null),_({override:!1,drop:!1,destructive:!1}),B(e,t,n).then(u).catch(e=>f(I(e.message)))},[e,t,n]);(0,R.useEffect)(E,[E]);let k=c?V(c):null,A=c!==null&&k!==null&&!k.refused&&(!k.override||h.override)&&(!k.drop||h.drop)&&(!k.destructive||h.destructive);async function M(i){if(c){w(!0),m(null);try{let{warning:a}=await H(e,t,c,{...h,loosens:i});s.show(`ok`,`Rule applied for ${n.match}.`),a&&s.show(`warn`,I(a)),o(),r()}catch(e){!i&&U(e)?S(!0):(S(!1),m(j(e)?{text:N,stale:!0}:{text:I(e.message),stale:!1}))}finally{w(!1)}}}let F=P(n);if(x&&c){let e=c.kind===`rules`?c.preview.loosenReasons.map(I):[];return(0,W.jsx)(g,{open:!0,title:`Let these calls run without asking?`,confirmLabel:`Apply rule`,busy:C,error:p?.text,onCancel:()=>S(!1),onConfirm:()=>void M(!0),consequences:e.length>0?e:[`Calls to ${n.match} that today ask you first will run on their own while their inputs look like the ones seen.`],children:`This rule lets more through than your settings do now. Calls outside what was seen still ask you or are blocked.`})}return(0,W.jsx)(D,{open:!0,onClose:r,dismissable:!C,width:600,title:`Apply suggested rule`,description:(0,W.jsxs)(W.Fragment,{children:[F.lead,` `,(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-ink`,children:F.subject}),F.rest]}),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{variant:`secondary`,onClick:r,disabled:C,children:`Cancel`}),(0,W.jsx)(b,{variant:`primary`,disabled:!A,loading:C,onClick:()=>k?.loosens?S(!0):void M(!1),children:`Apply rule`})]}),children:(0,W.jsx)(`div`,{className:`space-y-4 pb-1 text-[14px]`,children:d?(0,W.jsx)(a,{tone:`danger`,title:`The rule could not be checked`,actions:(0,W.jsx)(b,{size:`sm`,onClick:E,children:`Try again`}),children:d}):!c||!k?(0,W.jsx)(i,{lines:4}):(0,W.jsxs)(W.Fragment,{children:[c.kind===`tool`?(0,W.jsxs)(`div`,{className:`rounded-2xl bg-sunken px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`What changes for this tool`}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Now`}),(0,W.jsx)(y,{decision:c.preview.current.kind}),(0,W.jsx)(l,{name:`arrow-right`,size:16,className:`text-soft`}),(0,W.jsx)(`span`,{className:`text-[13px] text-muted`,children:`After`}),(0,W.jsx)(y,{decision:c.preview.verdict.kind})]}),c.preview.bounds&&c.preview.verdict.kind!==`deny`&&(0,W.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted`,children:[`That holds while its inputs stay within the limits below. A call outside them`,` `,c.preview.bounds.onViolation===`approve`?`asks you first`:`is blocked`,`.`]})]}):(0,W.jsxs)(`div`,{className:`rounded-2xl bg-sunken px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`What changes`}),c.preview.changes.length===0?(0,W.jsx)(`p`,{className:`mt-1 text-[13px] text-muted`,children:`No tool this toolbox serves changes how it is handled.`}):(0,W.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:c.preview.changes.map(e=>(0,W.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.tool}),(0,W.jsx)(y,{decision:e.before}),(0,W.jsx)(l,{name:`arrow-right`,size:14,className:`text-soft`}),(0,W.jsx)(y,{decision:e.after})]},e.tool))})]}),k.refused&&(0,W.jsx)(a,{tone:`info`,title:`This cannot be applied from here`,children:I(k.refused)}),c.kind===`tool`&&c.preview.overridden&&(0,W.jsx)(a,{tone:`warn`,children:I(c.preview.overridden)}),c.kind===`tool`&&c.preview.nameContradiction&&(0,W.jsx)(a,{tone:`warn`,children:I(c.preview.nameContradiction)}),c.kind===`tool`&&!c.preview.reloads&&(0,W.jsx)(`p`,{className:`text-[13px] text-muted`,children:`This toolbox reads its settings only when it starts, so the rule applies after a restart.`}),!k.refused&&(k.override||k.drop||k.destructive)&&(0,W.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-bad/40 px-4 py-3`,children:[k.override&&(0,W.jsx)(T,{checked:h.override,onChange:e=>_(t=>({...t,override:e})),label:`Reverse rule ${k.override.ruleId}`,description:`Someone set this tool to "${k.override.decision}" with the note "${k.override.reason}". This rule overrides that.`}),k.drop&&(0,W.jsx)(T,{checked:h.drop,onChange:e=>_(t=>({...t,drop:e})),label:`Drop the input limits this tool has today`,description:`Rule ${k.drop} limits this tool's inputs now. Those limits would no longer apply.`}),k.destructive&&(0,W.jsx)(T,{checked:h.destructive,onChange:e=>_(t=>({...t,destructive:e})),label:`Let a tool that deletes run without asking`,description:`Your AI app could remove things with nobody asked first.`})]}),p&&(0,W.jsx)(a,{tone:`danger`,role:`alert`,actions:p.stale?(0,W.jsx)(b,{size:`sm`,onClick:E,children:`Reload preview`}):void 0,children:p.text}),(0,W.jsxs)(`details`,{className:`group`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-medium text-muted select-none`,children:`Show the rule as written in the settings file`}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(v,{label:`Rule as written`,maxHeight:240,children:(c.kind,c.preview.yaml??``)})})]})]})})})}var K=[{value:`24h`,label:`Last 24 hours`,ms:864e5,phrase:`in the last 24 hours`},{value:`7d`,label:`Last 7 days`,ms:6048e5,phrase:`in the last 7 days`},{value:`all`,label:`Everything`,ms:null,phrase:`so far`}];function q(){let{serverId:t,tenant:o,nav:s}=F(),l=s.query.get(`since`),f=l===`24h`||l===`7d`?l:`all`,p=K.find(e=>e.value===f),g=(0,R.useMemo)(()=>p.ms?new Date(Date.now()-p.ms).toISOString():void 0,[p]),v=w(()=>u.suggestions(t,g),[t,g]),y=w(()=>u.protection(t,o),[t,o]),[x,T]=(0,R.useState)(null),[D,O]=(0,R.useState)(new Set),[A,j]=(0,R.useState)(!1),M=v.data,N=y.data,P=e=>D.has(e.id)||Y(e,N),L=M?M.rules.filter(e=>!P(e)):[],z=(e,t={})=>n(s,e,t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{title:`Suggestions`,subtitle:`Rules drawn from what your AI app did while the toolbox was in watch-only mode.`,actions:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(c,{size:`sm`,label:`Calls since`,value:f,onChange:e=>E(r(s,{since:e===`all`?null:e})),options:K.map(e=>({value:e.value,label:e.label}))}),M&&M.rules.length>0&&(0,W.jsx)(b,{variant:`primary`,icon:`check`,disabled:L.length===0,onClick:()=>j(!0),children:`Apply all safe suggestions`})]})}),N?.enforcement===`enforce`&&M&&M.calls>0&&(0,W.jsx)(`div`,{className:`mb-4`,children:(0,W.jsx)(a,{tone:`info`,title:`This toolbox is protecting`,children:`Suggestions come from calls recorded in watch-only mode. Those already recorded are shown below; new calls add nothing here until the toolbox is in watch-only mode again.`})}),v.error&&!M?(0,W.jsx)(a,{tone:`danger`,title:`The suggestions could not be loaded`,actions:(0,W.jsx)(b,{size:`sm`,onClick:v.reload,children:`Try again`}),children:I(v.error)}):M?M.calls===0?(0,W.jsx)(C,{children:(0,W.jsx)(d,{level:2,icon:`lightbulb`,title:`No calls recorded in watch-only mode ${p.phrase}`,actions:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(h,{href:z(`/protection`,{focus:`mode`}),variant:`primary`,children:`Open protection mode`}),f!==`all`&&(0,W.jsx)(b,{variant:`secondary`,onClick:()=>E(r(s,{since:null})),children:`Show everything`})]}),children:N?.enforcement===`enforce`?`This toolbox is protecting, so calls are not recorded for suggestions. Switch it to watch-only for a while, use your AI app as you normally would, and suggestions appear here.`:`Suggestions appear after your AI app has been used for a while with the toolbox in watch-only mode. Use it as you normally would, then come back.`})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,W.jsx)(S,{title:`Calls seen`,value:k(M.calls),sub:J(M)}),(0,W.jsx)(S,{title:`Would run`,value:k(M.wouldRun),sub:`without asking you`}),(0,W.jsx)(S,{title:`Would ask you`,value:k(M.wouldAsk),sub:`before running`,href:z(`/approvals`),hrefLabel:`Open waiting calls`}),(0,W.jsx)(S,{title:`Would be blocked`,value:k(M.wouldRefuse),sub:`had protection been on`})]}),(0,W.jsxs)(`p`,{className:`mt-3 flex items-center gap-1.5 text-[13px] text-soft`,children:[`Every one of these calls ran. The numbers say what would have happened had your rules been applied.`,(0,W.jsx)(m,{term:`watchOnly`})]}),(0,W.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(X,{title:`Tools nobody has labelled yet`,empty:`Every tool that was called has a label.`,intro:M.onUnclassified===`deny`?`Nobody has said what these do, so with protection on every call to them is blocked. Label each one once.`:`Nobody has said what these do, so with protection on every call to them asks you. Label each one once.`,items:M.unclassified,nav:s,trailing:e=>(0,W.jsx)(h,{size:`sm`,variant:`secondary`,href:n(s,`/tools`,{tool:e.tool}),children:`Label tool`})}),(0,W.jsx)(X,{title:`Calls that would be blocked`,empty:`No call would have been blocked.`,intro:`A rule or setting would stop these. Change it if they should run.`,items:M.refused,nav:s,detail:e=>(0,W.jsxs)(W.Fragment,{children:[I(e.reason),` `,(0,W.jsx)(`span`,{className:`font-mono text-[11.5px]`,children:e.ruleId})]})})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(X,{title:`Calls that would ask you`,empty:`No call would have waited for you.`,intro:`These would wait for your approval each time. Where the calls looked alike, a rule below lets the usual ones run.`,items:M.asked,nav:s,detail:e=>I(e.why),trailing:t=>t.suggested?(0,W.jsx)(e,{tone:`ok`,icon:`lightbulb`,children:`Rule suggested`}):null})}),(0,W.jsxs)(`section`,{className:`mt-8`,"aria-labelledby":`suggested-rules`,children:[(0,W.jsxs)(`header`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{id:`suggested-rules`,className:`text-[22px] font-medium tracking-[-0.02em]`,children:`Suggested rules`}),(0,W.jsx)(m,{term:`rule`}),y.error&&!N&&(0,W.jsx)(e,{tone:`warn`,children:`Could not check which are already applied`})]}),M.rules.length===0?(0,W.jsx)(C,{children:(0,W.jsx)(d,{icon:`lightbulb`,title:`No rules to suggest`,compact:!0,children:`A rule is suggested when a tool asked you at least three times with inputs that look alike. Tools that delete things are always left to you.`})}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:M.rules.map(e=>(0,W.jsx)(Z,{rule:e,note:M.notes[e.id],done:P(e),canWrite:N?.policyWrite.ok??!0,onApply:()=>T(e)},e.id))})]})]}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4`,children:[0,1,2,3].map(e=>(0,W.jsx)(C,{children:(0,W.jsx)(i,{lines:3,height:18})},e))}),x&&(0,W.jsx)(G,{serverId:t,tenant:o,rule:x,onClose:()=>T(null),onApplied:()=>{O(e=>new Set(e).add(x.id)),y.reload()}}),A&&M&&(0,W.jsx)(Q,{serverId:t,tenant:o,rules:L,onClose:()=>j(!1),onApplied:e=>O(t=>new Set(t).add(e)),onDone:()=>{v.reload(),y.reload()}})]})}function J(e){return!e.from||!e.to?`recorded in watch-only mode`:`${new Date(e.from).toLocaleDateString(void 0,{day:`numeric`,month:`short`})} to ${new Date(e.to).toLocaleDateString(void 0,{day:`numeric`,month:`short`})}`}function Y(e,t){if(!t)return!1;let n=t.tools.find(t=>t.name===e.match);return!!n&&n.consoleRule!==null&&n.verdict.kind===e.decision}function X({title:r,intro:i,empty:a,items:o,nav:s,detail:c,trailing:l}){return(0,W.jsx)(C,{title:r,actions:(0,W.jsx)(e,{tone:`neutral`,children:t(o.length,`tool`)}),children:o.length===0?(0,W.jsx)(d,{icon:`check`,title:a,compact:!0}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`-mt-2 mb-2 text-[13px] text-soft`,children:i}),(0,W.jsx)(`div`,{className:`-my-1`,children:o.map(e=>(0,W.jsx)(f,{leading:(0,W.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken`,children:(0,W.jsx)(p,{effect:e.effect})}),title:(0,W.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.tool}),sub:(0,W.jsxs)(W.Fragment,{children:[`Called `,t(e.calls,`time`),c&&(0,W.jsxs)(W.Fragment,{children:[` · `,c(e)]})]}),trailing:l?.(e)??(0,W.jsx)(h,{size:`sm`,variant:`ghost`,href:n(s,`/tools`,{tool:e.tool}),children:`Open tool`})},e.tool))})]})})}function Z({rule:t,note:n,done:r,canWrite:i,onApply:a}){let o=P(t),s=Object.entries(t.args??{});return(0,W.jsxs)(C,{as:`article`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`p`,{className:`text-[17px] leading-snug font-medium tracking-[-0.01em]`,children:[o.lead,` `,(0,W.jsx)(`span`,{className:`font-mono text-[15px] break-all`,children:o.subject}),o.rest]}),(0,W.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-soft`,children:t.id})]}),r?(0,W.jsx)(e,{tone:`ok`,icon:`check`,children:`Applied`}):(0,W.jsx)(b,{variant:`primary`,size:`sm`,onClick:a,disabled:!i,title:i?void 0:`The protection settings file cannot be changed from here`,children:`Apply rule`})]}),n&&(0,W.jsxs)(`p`,{className:`mt-3 text-[13px] text-muted`,children:[`Based on `,n.charAt(0).toLowerCase()+n.slice(1)]}),s.length>0&&(0,W.jsx)(`ul`,{className:`mt-3 space-y-1 rounded-2xl bg-sunken px-4 py-3 text-[13px]`,children:s.map(([e,t])=>(0,W.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[12px] text-ink`,children:e}),(0,W.jsx)(`span`,{className:`text-muted`,children:L(t)})]},e))}),(0,W.jsxs)(`details`,{className:`mt-3`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-[13px] font-medium text-muted select-none`,children:`Show the rule as written`}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(v,{label:`Rule ${t.id}`,maxHeight:260,copy:!0,children:M(t)})})]})]})}function Q({serverId:e,tenant:n,rules:r,onClose:i,onApplied:a,onDone:o}){let s=O(),[c,l]=(0,R.useState)(()=>r.map(e=>({rule:e,state:`waiting`}))),[u,d]=(0,R.useState)(`ready`);async function f(){d(`running`);let i=(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),c=0;for(let[t,o]of r.entries()){i(t,{state:`checking`});try{let r=await B(e,n,o),s=V(r),l=s.refused?I(s.refused):s.loosens?`Lets calls run without asking. Apply it on its own to confirm.`:s.override||s.drop||s.destructive?`Needs your confirmation. Apply it on its own.`:null;if(l){i(t,{state:`skipped`,why:l});continue}let{warning:u}=await H(e,n,r,{});c++,a(o.id),i(t,{state:`applied`,...u?{why:I(u)}:{}})}catch(e){i(t,{state:`failed`,why:j(e)?N:I(e.message)})}}d(`done`),c>0&&s.show(`ok`,`${t(c,`rule`)} applied.`),o()}let p=c.filter(e=>e.state===`applied`).length,m=c.filter(e=>e.state===`skipped`).length,h=c.filter(e=>e.state===`failed`).length,g=c.findIndex(e=>e.state===`checking`);return(0,W.jsx)(D,{open:!0,onClose:i,dismissable:u!==`running`,width:600,title:`Apply all safe suggestions`,description:u===`ready`?`Only rules that let nothing more through than today are applied. Any that would let calls run without asking you are skipped, so you can look at each on its own.`:u===`running`?`Checking ${g+1} of ${c.length}`:`${t(p,`rule`)} applied, ${m} skipped${h?`, ${h} failed`:``}.`,footer:u===`ready`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{variant:`secondary`,onClick:i,children:`Cancel`}),(0,W.jsx)(b,{variant:`primary`,onClick:()=>void f(),children:`Check and apply ${t(c.length,`rule`)}`})]}):(0,W.jsx)(b,{variant:`primary`,onClick:i,disabled:u===`running`,loading:u===`running`,children:`Close summary`}),children:(0,W.jsx)(`ul`,{className:`space-y-2 pb-1`,"aria-live":`polite`,children:c.map(e=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 rounded-2xl bg-sunken px-3 py-2.5`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate font-mono text-[13px]`,children:e.rule.match}),e.why&&(0,W.jsx)(`span`,{className:`mt-0.5 block text-[12.5px] text-soft`,children:e.why})]}),(0,W.jsx)($,{state:e.state})]},e.rule.id))})})}function $({state:t}){return t===`applied`?(0,W.jsx)(e,{tone:`ok`,icon:`check`,children:`Applied`}):t===`skipped`?(0,W.jsx)(e,{tone:`warn`,children:`Skipped`}):t===`failed`?(0,W.jsx)(e,{tone:`bad`,icon:`x`,children:`Not applied`}):t===`checking`?(0,W.jsx)(e,{tone:`neutral`,children:`Checking`}):(0,W.jsx)(e,{tone:`neutral`,children:`Waiting`})}export{q as SuggestionsPage};