hmcp-web 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/api.d.ts +11 -0
- package/dist/api.js +64 -10
- package/dist/model/app-servers.d.ts +85 -0
- package/dist/model/app-servers.js +109 -0
- package/dist/model/import-record.d.ts +80 -0
- package/dist/model/import-record.js +179 -0
- package/dist/model/metrics.js +16 -1
- package/dist/routes/connect-import.d.ts +9 -0
- package/dist/routes/connect-import.js +594 -0
- package/dist/routes/connect.d.ts +36 -0
- package/dist/routes/connect.js +71 -13
- package/dist/routes/github.d.ts +97 -0
- package/dist/routes/github.js +587 -0
- package/dist/routes/guard.d.ts +3 -0
- package/dist/routes/guard.js +166 -0
- package/dist/routes/runtime.d.ts +6 -0
- package/dist/routes/runtime.js +1 -1
- package/dist/routes/servers-add.d.ts +8 -0
- package/dist/routes/servers-add.js +2 -2
- package/dist-ui/assets/{Activity-BqKGpXMN.js → Activity-CZ78RyRO.js} +1 -1
- package/dist-ui/assets/Approvals-DPIlNZsv.js +1 -0
- package/dist-ui/assets/AttachApp-DjSeWCbS.js +5 -0
- package/dist-ui/assets/Connections-qcA96lXh.js +2 -0
- package/dist-ui/assets/{Gallery-B39L2Yma.js → Gallery-DB_OO7Vw.js} +1 -1
- package/dist-ui/assets/{PreApprovals-BsIhjMqb.js → PreApprovals-C4cKajcK.js} +1 -1
- package/dist-ui/assets/{Protection-DlB09ABa.js → Protection-B8h-5YAb.js} +1 -1
- package/dist-ui/assets/{Safety-CN-oHO2h.js → Safety-BQqHyYdo.js} +1 -1
- package/dist-ui/assets/{Settings-BLD7G1Ag.js → Settings-Cx50zZSt.js} +1 -1
- package/dist-ui/assets/StartPage-CdX-v7ej.js +1 -0
- package/dist-ui/assets/{Suggestions-Dp7pofcs.js → Suggestions-CRo5UOTT.js} +1 -1
- package/dist-ui/assets/Tools-xo39lPKB.js +4 -0
- package/dist-ui/assets/index-DttDjRpu.js +16 -0
- package/dist-ui/assets/index-QeJyD5z2.css +2 -0
- package/dist-ui/assets/{kit-DQ7Oxf5n.js → kit-DRVm92_t.js} +1 -1
- package/dist-ui/index.html +3 -3
- package/package.json +4 -4
- package/dist-ui/assets/Approvals-Qo7bCcli.js +0 -1
- package/dist-ui/assets/AttachApp-0zRSPgSY.js +0 -5
- package/dist-ui/assets/Connections-CE0JGe8c.js +0 -2
- package/dist-ui/assets/StartPage-HuZSnmSr.js +0 -1
- package/dist-ui/assets/Tools-Bfot3bx5.js +0 -4
- package/dist-ui/assets/index-Khp0l1zp.js +0 -16
- package/dist-ui/assets/index-Ylyt4DEr.css +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,Ct as n,D as r,E as i,Et as a,F as o,G as s,H as c,I as l,It as u,J as d,K as f,M as p,Nt as ee,Ot as m,Pt as h,T as g,U as _,V as v,Y as te,Z as y,_ as b,_t as x,c as S,gt as ne,ht as C,j as w,kt as T,mt as E,pt as D,q as O,rt as k,s as A,w as j,wt as M,x as re,y as ie,yt as N}from"./kit-DQ7Oxf5n.js";import{Zt as P,a as F,c as ae,l as oe,n as I,o as L,r as se,s as R,t as ce,u as z}from"./index-Khp0l1zp.js";var B=u(),V=T(),H=/^\[redacted:([^\]]+)\]$/,U=/…\[truncated (\d+) chars\]$/,W=/^\[truncated (\d+) items\]$/;function G(e){if(typeof e!=`string`)return null;let t=H.exec(e);return t?t[1]===`key`||t[1]===`circular`||t[1]===`max-depth`?t[1]:`pattern`:U.test(e)?`chars`:W.test(e)?`items`:null}function K(e,t,n=0){if(n>20)return;let r=G(e);r&&t.add(r),Array.isArray(e)?e.forEach(e=>K(e,t,n+1)):e&&typeof e==`object`&&Object.values(e).forEach(e=>K(e,t,n+1))}var q={key:`[redacted:key]`,pattern:`[redacted:<pattern>]`,circular:`[redacted:circular]`,"max-depth":`[redacted:max-depth]`,chars:`…[truncated N chars]`,items:`[truncated N items]`},J={key:`Hidden`,pattern:`Hidden`,circular:`Hidden`,"max-depth":`Hidden`,chars:`Cut short`,items:`Cut short`};function Y({args:e,error:t,meta:n}){let r=new Set;K(e,r);let i=e=>n?.markers.find(t=>t.marker===q[e])?.meaning,a=e&&typeof e==`object`&&!Array.isArray(e)?Object.entries(e):null;return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[t&&(0,V.jsx)(c,{tone:`warn`,title:`Some inputs could not be read back`,children:t}),a===null?e==null?!t&&(0,V.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`The inputs were not recorded.`}):(0,V.jsx)(X,{value:e,meaning:i}):a.length===0?(0,V.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:`This call sent no inputs.`}):(0,V.jsx)(`dl`,{className:`divide-y divide-faint overflow-hidden rounded-2xl bg-sunken/60`,children:a.map(([e,t])=>(0,V.jsxs)(`div`,{className:`grid gap-1 px-4 py-2.5 sm:grid-cols-[minmax(6rem,10rem)_minmax(0,1fr)] sm:gap-4`,children:[(0,V.jsx)(`dt`,{className:`mono pt-px text-[12.5px] break-all text-soft`,children:e}),(0,V.jsx)(`dd`,{className:`min-w-0`,children:(0,V.jsx)(X,{value:t,meaning:i})})]},e))}),r.size>0&&(0,V.jsxs)(`div`,{className:`flex gap-2 text-[12.5px] text-soft`,children:[(0,V.jsx)(m,{name:`eye-off`,size:15,className:`mt-0.5 shrink-0`}),(0,V.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-muted`,children:[`Some values are hidden or cut short in the record `,(0,V.jsx)(b,{term:`redaction`})]}),[...r].map(e=>(0,V.jsxs)(`p`,{children:[(0,V.jsx)(`code`,{className:`mono text-[11.5px]`,children:q[e]}),`: `,i(e)??`not shown in full`]},e))]})]})]})}function X({value:t,meaning:n}){let r=G(t);if(r&&r!==`chars`)return(0,V.jsx)(e,{tone:`neutral`,icon:`eye-off`,title:n(r),children:J[r]});if(typeof t==`string`){let r=U.exec(t),i=r?t.slice(0,r.index):t;return(0,V.jsxs)(`p`,{className:`scrollbar-thin max-h-40 overflow-y-auto text-[13.5px] break-words whitespace-pre-wrap`,children:[i===``?(0,V.jsx)(`span`,{className:`text-soft`,children:`(empty)`}):i,r&&(0,V.jsxs)(e,{tone:`neutral`,className:`ml-1.5 align-middle`,title:n(`chars`),children:[r[1],` more characters not recorded`]})]})}return typeof t==`number`||typeof t==`boolean`||t===null?(0,V.jsx)(`span`,{className:`mono text-[13px]`,children:String(t)}):(0,V.jsx)(`pre`,{className:`scrollbar-thin mono max-h-48 overflow-auto rounded-xl bg-surface px-3 py-2 text-[12px] leading-relaxed whitespace-pre-wrap break-words`,children:JSON.stringify(t,null,2)})}var Z=e=>e instanceof ee&&(e.status===409||e.status===404);function le({approval:e,meta:t,now:n,serverId:a,tenant:s,selecting:u,selected:d,onSelect:f,locked:m,onDecided:_,onRemembered:te}){let x=ie(),[S,ne]=(0,B.useState)(``),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(!1),[O,A]=(0,B.useState)(t?.rememberDefaults.ttlSeconds??3600),[M,re]=(0,B.useState)(t?.rememberDefaults.maxUses??20),[P,oe]=(0,B.useState)(!1),[I,H]=(0,B.useState)(null),U=R(e.tool),W=e.expiresAt-n,G=se(e),K=t?.grantTtlMaxSeconds,q=m||w!==null;async function J(t,n={}){T(n.remember?`remember`:n.classify?`classify-${n.classify}`:t),H(null);let r;try{r=await h.decide(a,e.id,t,S.trim(),s,n.classify,n.remember)}catch(e){T(null),Z(e)?(x.show(`warn`,`This call was already answered, or it ran out of time.`),_()):n.remember&&e instanceof ee&&e.status===422?H(L(e.message)):x.show(`bad`,L(e.message));return}T(null),t===`denied`?x.show(`ok`,`You said no. ${U.label} will not run, and the AI is told you said no.`):r.remembered?(x.show(`ok`,`Approved. Similar calls won't ask until ${ae(r.remembered.expiresAt)}.`),te(r.remembered,e.tool)):r.classifyWarning?x.show(`warn`,L(r.classifyWarning)):r.classified&&n.classify?x.show(`ok`,`Approved, and ${U.label} is now labelled "${k[n.classify].label}". Its calls still ask you.`):x.show(`ok`,`Approved. The call can go ahead.`),_()}let X=O!==null&&(K===void 0||O<=K)&&(P||M!==null&&M>=1);return(0,V.jsxs)(`article`,{"aria-labelledby":`apr-${e.id}`,className:N(`card flex min-w-0 flex-col gap-5 p-5 sm:p-6`,d&&`outline-2 outline-offset-2 outline-[var(--primary)]`),children:[(0,V.jsxs)(`header`,{className:`flex items-start gap-3`,children:[u&&(0,V.jsx)(`span`,{className:`pt-2.5`,children:(0,V.jsx)(j,{checked:d,onChange:f,disabled:q,label:(0,V.jsxs)(`span`,{className:`sr-only`,children:[`Select `,U.label]})})}),(0,V.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-sunken`,children:(0,V.jsx)(y,{effect:e.effect})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`h3`,{id:`apr-${e.id}`,tabIndex:-1,className:`text-[18px] outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)] leading-snug font-medium tracking-[-0.015em] break-words`,children:U.label}),(0,V.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12.5px] text-soft`,children:[U.server&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:U.server}),(0,V.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}),(0,V.jsx)(y,{effect:e.effect,withLabel:!0})]})]})]}),(0,V.jsxs)(`section`,{"aria-label":`What it wants to do`,className:`space-y-2.5`,children:[(0,V.jsx)(`p`,{className:`text-[15px] leading-relaxed [overflow-wrap:anywhere]`,children:ce(e)}),(0,V.jsx)(`p`,{className:`text-[14px] text-muted`,children:z(e)}),e.violations.length>0&&(0,V.jsx)(`ul`,{className:`space-y-1.5 rounded-2xl bg-warn-tint px-4 py-3 text-[13.5px]`,children:e.violations.map(t=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:`mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-warn`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:F(t,e.args)})]},t))}),(0,V.jsx)(`p`,{className:`text-[13px] text-soft`,children:W>0?`If you don't answer by ${o(e.expiresAt)}, it doesn't run. The AI can ask again.`:`This request ran out of time, so it doesn't run. The AI can ask again.`})]}),(0,V.jsxs)(`section`,{"aria-label":`The details it would send`,className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`eyebrow`,children:`The details it would send`}),(0,V.jsx)(Y,{args:e.args,error:e.argsError,meta:t})]}),(0,V.jsxs)(`details`,{className:`group text-[12.5px] text-soft`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer select-none font-medium text-muted`,children:`Details`}),(0,V.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,V.jsx)(`dt`,{children:`Tool`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.tool})}),(0,V.jsx)(`dt`,{children:`Asked by`}),(0,V.jsxs)(`dd`,{children:[e.actor,` `,(0,V.jsx)(`span`,{title:l(e.createdAt),children:v(e.createdAt,n)})]}),(0,V.jsx)(`dt`,{children:`Session`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.session})}),e.ruleId&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{children:`Rule`}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(`code`,{className:`mono break-all`,children:e.ruleId})})]}),(0,V.jsx)(`dt`,{children:`Request`}),(0,V.jsxs)(`dd`,{children:[(0,V.jsx)(`code`,{className:`mono break-all`,children:e.id}),`, expires `,l(e.expiresAt)]})]})]}),(0,V.jsxs)(`div`,{className:`mt-auto space-y-3 border-t border-faint pt-4`,children:[(0,V.jsx)(i,{label:`Note for the activity log`,optional:!0,children:(0,V.jsx)(p,{value:S,onChange:ne,placeholder:`Why you said yes or no`,disabled:q})}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(C,{variant:`primary`,icon:`check`,onClick:()=>J(`granted`),loading:w===`granted`,disabled:q,children:`Approve`}),(0,V.jsx)(C,{variant:`secondary`,icon:`x`,onClick:()=>J(`denied`),loading:w===`denied`,disabled:q,children:`Say no`}),e.rememberAllowed&&!G&&(0,V.jsx)(C,{variant:`ghost`,icon:E?`chevron`:`chevron-right`,"aria-expanded":E,"aria-controls":`remember-${e.id}`,onClick:()=>D(e=>!e),disabled:q,children:`Approve and don't ask again`})]}),G&&(0,V.jsxs)(`div`,{className:`space-y-2.5 rounded-2xl bg-sunken/70 p-4`,children:[(0,V.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Approve and remember this tool as:`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":`Approve and say what this tool does`,children:[`read`,`write`,`destructive`].map(e=>(0,V.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>J(`granted`,{classify:e}),loading:w===`classify-${e}`,disabled:q,title:k[e].explain,children:k[e].label},e))}),(0,V.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:`This approves the call and saves what the tool does in your protection settings. Its calls still ask you; once it is labelled you can set a rule for it on the Tools page.`})]}),E&&e.rememberAllowed&&(0,V.jsxs)(`div`,{id:`remember-${e.id}`,className:`space-y-4 rounded-2xl bg-sunken/70 p-4`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[14px] font-semibold`,children:[`Approve and don't ask again `,(0,V.jsx)(b,{term:`preApproval`})]}),(0,V.jsx)(i,{label:`For how long`,children:(0,V.jsx)(g,{value:O,onChange:A,label:`For how long`,max:K})}),(0,V.jsx)(i,{label:`Up to how many calls`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,V.jsx)(r,{value:P?null:M,onChange:re,min:1,step:1,unit:`calls`,disabled:P||q,className:`w-40`}),(0,V.jsx)(j,{checked:P,onChange:oe,label:`No limit`,disabled:q})]})}),(0,V.jsx)(`p`,{className:`text-[13px] text-muted`,children:`For the time you choose, your AI can make this same request again without asking. Anything different still asks you, including a list with items changed, repeated or left out. You can take it back any time on the Pre-approvals page.`}),I&&(0,V.jsx)(c,{tone:`danger`,title:`Nothing was approved`,role:`alert`,children:I}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{variant:`primary`,icon:`check`,disabled:!X||q,loading:w===`remember`,onClick:()=>J(`granted`,{remember:{ttlSeconds:O,maxUses:P?null:M}}),children:`Approve and remember`}),(0,V.jsx)(C,{variant:`ghost`,onClick:()=>D(!1),disabled:w!==null,children:`Cancel`})]})]})]})]})}var ue={elicit:`On this toolbox your AI app asks you in its own window, so calls usually do not wait here.`,cli:`On this toolbox every call that needs your OK waits here until you answer it.`,both:`Your AI app asks you in its own window when it can. When it cannot, the call waits here.`,deny:`On this toolbox calls that would need your OK are blocked instead, so nothing waits here.`};function Q(){let{serverId:e,tenant:r,nav:i,reload:o}=P(),l=ie(),u=oe(1e3),f=A(()=>h.pending(e,r),[e,r],2e3),p=A(()=>h.approvals(e,r,{limit:200}),[e,r],15e3),m=A(()=>h.redaction(),[]),g=A(()=>h.protection(e,r),[e,r],3e4),y=i.query.get(`id`),b=y!==null&&(f.data??[]).some(e=>e.id===y),T=i.query.get(`tab`)===`history`||y!==null&&f.data!==null&&!b?`history`:`waiting`,k=e=>M(a(i,{tab:e===`waiting`?null:e})),j=(0,B.useMemo)(()=>[...f.data??[]].filter(e=>e.expiresAt>u).sort((e,t)=>e.createdAt-t.createdAt),[f.data,u]),N=(0,B.useMemo)(()=>(p.data??[]).filter(e=>e.state!==`pending`).sort((e,t)=>(t.decidedAt??t.expiresAt)-(e.decidedAt??e.expiresAt)),[p.data]),[F,se]=(0,B.useState)(!1),[ce,z]=(0,B.useState)([]),H=new Set(j.map(e=>e.id)),U=ce.filter(e=>H.has(e)),[W,G]=(0,B.useState)(null),[K,q]=(0,B.useState)(``),[J,Y]=(0,B.useState)(!1),[X,Z]=(0,B.useState)(null),Q=(0,B.useRef)(!1),de=(0,B.useRef)(null),fe=(0,B.useRef)(null);(0,B.useEffect)(()=>{Q.current&&f.data!==null&&(Q.current=!1,(de.current?.querySelector(`article h3[tabindex]`)??fe.current)?.focus())},[f.data]);let me=()=>{f.reload(),p.reload(),g.reload(),o()};async function he(n){Y(!0);let i=0,a=0,o=[];for(let t of U)try{await h.decide(e,t,n,K.trim(),r),i++}catch(e){e instanceof ee&&(e.status===409||e.status===404)?a++:o.push(L(e.message))}Y(!1),G(null),q(``),z([]),se(!1),me();let s=[`${n===`granted`?`Approved`:`Denied`} ${t(i,`call`)}.`];a&&s.push(`${t(a,`call`)} had already been answered or ran out of time.`),o.length&&s.push(`${o.length} failed: ${o[0]}`),l.show(o.length?`bad`:a?`warn`:`ok`,s.join(` `))}let $=g.data?.approvals,ge=$?ue[$.mode]:void 0,_e=j.reduce((e,t)=>e===null||t.expiresAt<e?t.expiresAt:e,null),ve=j[0];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(S,{title:`Waiting for you`,subtitle:`Your AI wanted to do these things. Nothing happens until you decide.`,actions:(0,V.jsx)(C,{variant:F?`primary`:`secondary`,icon:F?`x`:`list`,"aria-pressed":F,disabled:!F&&j.length<2,onClick:()=>{se(e=>!e),z([])},children:F?`Stop selecting`:`Select several`})}),(0,V.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,V.jsx)(E,{tone:`hero`,title:`Waiting now`,loading:f.data===null&&!f.error,value:j.length,sub:ve?`Oldest asked ${v(ve.createdAt,u)}`:`Nothing needs you`}),(0,V.jsxs)(`div`,{className:`contents max-sm:hidden`,children:[(0,V.jsx)(E,{title:`Expires next`,loading:f.data===null&&!f.error,value:_e===null?`None`:I(_e-u),sub:_e===null?`Nothing is waiting`:`A request nobody answers doesn't run`}),(0,V.jsx)(E,{title:`Pre-approvals in use`,loading:g.data===null&&!g.error,value:$?.activeGrantCount??`–`,sub:`Calls they cover skip this page`,href:n(i,`/pre-approvals`),hrefLabel:`Open pre-approvals`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[$&&$.pendingElsewhere>0&&(0,V.jsxs)(c,{tone:`info`,title:`${t($.pendingElsewhere,`call`)} ${$.pendingElsewhere===1?`is`:`are`} waiting for a different customer`,children:[`Choose that customer at the top of the page to answer `,$.pendingElsewhere===1?`it`:`them`,`.`]}),X&&(0,V.jsxs)(c,{tone:`ok`,title:`Pre-approval created`,role:`status`,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(x,{size:`sm`,variant:`secondary`,href:n(i,`/pre-approvals`,{grant:X.grant.id}),children:`Open pre-approval`}),(0,V.jsx)(ne,{icon:`x`,label:`Dismiss message`,size:32,onClick:()=>Z(null)})]}),children:[`Calls like this one to `,R(X.tool).label,` won't ask until `,ae(X.grant.expiresAt),X.grant.maxUses===null?``:`, for up to ${t(X.grant.maxUses,`call`)}`,`.`]})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,V.jsx)(O,{label:`Calls`,value:T,onChange:k,items:[{id:`waiting`,label:`Waiting`,count:j.length},{id:`history`,label:`Decided earlier`,count:N.length}]}),T===`waiting`&&j.length>0&&(0,V.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Oldest first: the call at the top runs out soonest.`})]}),(0,V.jsx)(`div`,{role:`tabpanel`,id:te(T),"aria-labelledby":d(T),className:`mt-5`,children:T===`waiting`?(0,V.jsxs)(V.Fragment,{children:[F&&j.length>0&&(0,V.jsx)(D,{className:`mb-5`,padded:!1,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-5 py-4`,children:[(0,V.jsxs)(`p`,{className:`min-w-0 flex-1 text-[14px]`,children:[(0,V.jsx)(`span`,{className:`tnum font-semibold`,children:U.length}),` of `,t(j.length,`call`),` selected`]}),(0,V.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>z(U.length===j.length?[]:j.map(e=>e.id)),children:U.length===j.length?`Clear selection`:`Select all`}),(0,V.jsx)(C,{size:`sm`,variant:`primary`,icon:`check`,disabled:U.length===0,onClick:()=>G(`granted`),children:`Approve all`}),(0,V.jsx)(C,{size:`sm`,variant:`secondary`,icon:`x`,disabled:U.length===0,onClick:()=>G(`denied`),children:`Deny all`})]})}),f.error&&(0,V.jsx)(`div`,{className:`mb-5`,children:(0,V.jsx)(c,{tone:`danger`,title:`Could not load the calls waiting for you`,role:`alert`,actions:(0,V.jsx)(C,{size:`sm`,icon:`refresh`,onClick:f.reload,children:`Try again`}),children:L(f.error)})}),f.data===null?!f.error&&(0,V.jsx)(`div`,{className:`grid gap-5 xl:grid-cols-2`,children:[0,1].map(e=>(0,V.jsxs)(D,{children:[(0,V.jsx)(s,{height:22,width:`45%`}),(0,V.jsx)(`div`,{className:`mt-5`,children:(0,V.jsx)(s,{lines:4})})]},e))}):j.length===0?(0,V.jsx)(D,{children:(0,V.jsx)(`div`,{ref:fe,tabIndex:-1,className:`outline-none`,children:(0,V.jsxs)(_,{icon:`inbox`,title:`Nothing is waiting for you.`,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(C,{variant:`secondary`,onClick:()=>k(`history`),children:`Show decided calls`}),(0,V.jsx)(x,{variant:`secondary`,href:n(i,`/pre-approvals`),children:`Manage pre-approvals`})]}),children:[`When your AI tries something that needs your OK, it appears here and this page updates by itself.`,` `,ge]})})}):(0,V.jsx)(`div`,{ref:de,className:`grid items-start gap-5 xl:grid-cols-2`,children:j.map(t=>(0,V.jsx)(`div`,{className:t.id===y?`rounded-[22px] ring-2 ring-[var(--focus)] ring-offset-2 ring-offset-[var(--bg)]`:void 0,children:(0,V.jsx)(le,{approval:t,meta:m.data,now:u,serverId:e,tenant:r,selecting:F,selected:F&&U.includes(t.id),onSelect:e=>z(n=>e?[...new Set([...n,t.id])]:n.filter(e=>e!==t.id)),locked:J,onDecided:()=>{Q.current=!0,me()},onRemembered:(e,t)=>Z({grant:e,tool:t})})},t.id))})]}):(0,V.jsx)(pe,{rows:N,error:p.error,loading:p.data===null,retry:p.reload,now:u,focusId:y})}),(0,V.jsxs)(re,{open:W!==null,onClose:()=>!J&&G(null),dismissable:!J,title:W===`granted`?`Approve ${t(U.length,`call`)}?`:`Deny ${t(U.length,`call`)}?`,description:W===`granted`?`Each call runs with exactly the inputs shown on its card. Nothing else is approved.`:`None of these calls will run. Your AI is told they were denied.`,footer:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(C,{variant:`secondary`,onClick:()=>G(null),disabled:J,children:`Go back`}),(0,V.jsx)(C,{variant:W===`granted`?`primary`:`danger`,loading:J,onClick:()=>W&&he(W),children:W===`granted`?`Approve all`:`Deny all`})]}),children:[(0,V.jsx)(`ul`,{className:`mb-4 max-h-48 space-y-1 overflow-y-auto text-[14px]`,children:j.filter(e=>U.includes(e.id)).map(e=>(0,V.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:R(e.tool).label}),(0,V.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.tool})]},e.id))}),(0,V.jsx)(w,{value:K,onChange:q,rows:2,"aria-label":`Note for the activity log, for every selected call`,placeholder:`Note for the activity log (optional)`})]})]})}function de(t){return t.decidedBy?.startsWith(`standing-grant:`)?(0,V.jsx)(e,{tone:`ok`,icon:`key`,children:`Let through by a pre-approval`}):t.state===`granted`||t.state===`used`?(0,V.jsx)(e,{tone:`ok`,icon:`check`,children:`Approved`}):t.state===`denied`?(0,V.jsx)(e,{tone:`bad`,icon:`x`,children:`Denied`}):t.state===`expired`?(0,V.jsx)(e,{tone:`neutral`,icon:`clock`,children:`Expired`}):(0,V.jsx)(e,{children:t.state})}function fe(e){return e.decidedBy?e.decidedBy.startsWith(`standing-grant:`)?(0,V.jsxs)(`span`,{children:[`Pre-approval `,(0,V.jsx)(`code`,{className:`mono text-[12px] text-soft`,children:e.decidedBy.slice(15)})]}):e.decidedBy:(0,V.jsx)(`span`,{className:`text-soft`,children:e.state===`expired`?`Nobody answered`:`Not recorded`})}function pe({rows:e,error:t,loading:n,retry:r,now:i,focusId:a}){let o=[{key:`call`,header:`Call`,cell:e=>(0,V.jsxs)(`span`,{className:`block min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium`,children:R(e.tool).label}),(0,V.jsx)(`code`,{className:`mono block text-[12px] break-all text-soft`,children:e.tool})]})},{key:`result`,header:`Result`,cell:de},{key:`who`,header:`Decided by`,cell:fe},{key:`when`,header:`When`,cell:e=>{let t=e.decidedAt??e.expiresAt;return(0,V.jsx)(`span`,{title:l(t),children:v(t,i)})}},{key:`note`,header:`Note`,cell:e=>e.decisionNote?(0,V.jsx)(`span`,{className:`break-words`,children:e.decisionNote}):(0,V.jsx)(`span`,{className:`text-soft`,children:`None`}),hideOnMobile:!1}];return(0,V.jsxs)(D,{children:[t&&(0,V.jsx)(`div`,{className:`mb-4`,children:(0,V.jsx)(c,{tone:`danger`,title:`Could not load decided calls`,actions:(0,V.jsx)(C,{size:`sm`,icon:`refresh`,onClick:r,children:`Try again`}),children:L(t)})}),n?!t&&(0,V.jsx)(s,{lines:5,height:18}):(0,V.jsx)(f,{caption:`Calls decided earlier`,columns:o,rows:e,rowKey:e=>e.id,selectedKey:a,empty:(0,V.jsx)(_,{icon:`clock`,title:`No calls decided yet`,compact:!0,children:`Calls you approve or deny, and calls that run out of time, are listed here.`})})]})}export{Q as ApprovalsPage};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,Ct as i,E as a,G as o,H as s,It as c,J as l,M as u,N as d,Nt as f,O as p,Ot as m,Pt as h,Tt as g,U as _,V as v,Y as y,Z as b,_t as x,a as S,b as C,bt as w,et as T,ht as E,i as D,jt as ee,k as O,kt as te,n as ne,o as re,q as k,r as A,rt as j,s as ie,t as M,tt as ae,vt as N,w as oe,x as se,xt as ce,y as le,yt as P}from"./kit-DQ7Oxf5n.js";import{$ as F,A as ue,At as I,B as de,Bt as fe,C as L,D as pe,E as me,F as R,Ft as he,G as ge,Gt as _e,H as ve,I as z,J as ye,K as be,Kt as B,L as xe,Lt as V,M as H,N as Se,Nt as U,O as Ce,P as we,Pt as Te,Q as Ee,R as De,S as Oe,T as W,U as ke,Ut as G,V as Ae,Vt as je,W as Me,Wt as Ne,X as K,Y as Pe,Yt as q,b as Fe,ct as Ie,et as J,j as Le,jt as Y,k as Re,m as ze,mn as Be,nn as Ve,nt as He,q as Ue,rt as We,s as X,tt as Ge,x as Ke,z as qe}from"./index-Khp0l1zp.js";var Z=c(),Q=te(),Je=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function Ye(e){let t=Je();return t.name=e.name,t.transport=e.transport,t.onInjection=e.on_injection??``,e.transport===`stdio`?(t.command=e.command,t.args=e.args??[],t.env=We(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=We(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function Xe(e){let t=e.onInjection?{on_injection:e.onInjection}:{};return e.transport===`stdio`?{name:e.name.trim(),transport:`stdio`,...t,command:e.command.trim(),...e.args.length?{args:e.args}:{},...e.env.length?{env:He(e.env)}:{},...e.passEnv.length?{pass_env:e.passEnv}:{},...e.cwd.trim()?{cwd:e.cwd.trim()}:{}}:{name:e.name.trim(),transport:`http`,...t,url:e.url.trim(),...e.headers.length?{headers:He(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function Ze(e,t=[]){if(!/^[a-z0-9_]+$/.test(e.name.trim()))return`Give the server a name of lower-case letters, digits and underscores.`;if(t.includes(e.name.trim()))return`Another connected server is already called “${e.name.trim()}”.`;if(e.transport===`stdio`&&!e.command.trim())return`Say which program starts the server.`;if(e.transport===`http`)try{new URL(e.url.trim())}catch{return`Enter the server's full web address, starting with https://.`}return null}function Qe({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!_e(t)&&!fe(e),f=e.transport===`stdio`?e.env.some(l):e.headers.some(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(a,{label:`Name`,technical:`name`,help:r?`A server's name can't be changed. Remove it and add it again under a new name.`:`Lower-case letters, digits and underscores. Its tools are shown to your AI app as name__tool.`,children:(0,Q.jsx)(u,{value:e.name,onChange:e=>c(`name`,e),mono:!0,disabled:r,placeholder:`files`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Where it runs`}),(0,Q.jsx)(p,{label:`Where it runs`,value:e.transport,onChange:e=>c(`transport`,e),options:[{value:`stdio`,label:`Runs on this computer`},{value:`http`,label:`Remote server`}]})]}),e.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Program to start`,technical:`command`,help:`The program the toolbox runs to start this server, such as npx or a full path.`,children:(0,Q.jsx)(u,{value:e.command,onChange:e=>c(`command`,e),mono:!0,placeholder:`npx`})}),(0,Q.jsx)(a,{label:`What to pass the program`,technical:`args`,optional:!0,help:`One item at a time. Press Enter after each.`,children:(0,Q.jsx)(t,{value:e.args,onChange:e=>c(`args`,e),placeholder:`-y, @modelcontextprotocol/server-filesystem`})}),(0,Q.jsx)(a,{label:`Values it is given`,technical:`env`,optional:!0,help:`Settings the server reads when it starts, such as an access key.`,children:(0,Q.jsx)(F,{value:e.env,onChange:e=>c(`env`,e),keyLabel:`Name of value`,valueLabel:`Value`,addLabel:`Add a value`,secret:i,valueType:`password`,keyPlaceholder:`API_KEY`})}),(0,Q.jsx)(a,{label:`Values passed on from the toolbox`,technical:`pass_env`,optional:!0,help:`Names of values the toolbox already has, given to this server as they are. Nothing else is passed on.`,children:(0,Q.jsx)(t,{value:e.passEnv,onChange:e=>c(`passEnv`,e),placeholder:`GITHUB_TOKEN`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Web address`,technical:`url`,children:(0,Q.jsx)(u,{value:e.url,onChange:e=>c(`url`,e),type:`url`,mono:!0,placeholder:`https://mcp.example.com/mcp`})}),(0,Q.jsx)(a,{label:`Headers sent with every request`,technical:`headers`,optional:!0,help:`Such as an access key the server expects.`,children:(0,Q.jsx)(F,{value:e.headers,onChange:e=>c(`headers`,e),keyLabel:`Header name`,valueLabel:`Header value`,addLabel:`Add a header`,secret:i,valueType:`password`,keyPlaceholder:`authorization`})})]}),o&&f&&(0,Q.jsx)(s,{tone:`warn`,title:`These values are saved in the toolbox's settings file as typed`,children:`A value whose name says it is a key (a TOKEN, KEY, SECRET or PASSWORD) goes into your locked keys instead. If another one is a password or key, give it a name like that, or anyone who can read the file can read it.`}),(0,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?Y[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(O,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:Y.strip.label},{value:`deny`,label:Y.deny.label},{value:`annotate`,label:Y.annotate.label}]})}),e.transport===`stdio`?(0,Q.jsx)(a,{label:`Folder it starts in`,technical:`cwd`,optional:!0,children:(0,Q.jsx)(u,{value:e.cwd,onChange:e=>c(`cwd`,e),mono:!0,placeholder:`/Users/me/project`})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{checked:e.passthrough,onChange:e=>c(`passthrough`,e),label:`Send each caller's own sign-in`,description:`Instead of one shared key, the toolbox passes on the key each AI app connects with. This sends that key to this server.`}),e.passthrough&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Header it goes in`,technical:`credential_passthrough.header`,children:(0,Q.jsx)(u,{value:e.passthroughHeader,onChange:e=>c(`passthroughHeader`,e),mono:!0})}),(0,Q.jsx)(d,{checked:e.passthroughRequired,onChange:e=>c(`passthroughRequired`,e),label:`Refuse calls without a sign-in`,description:`Otherwise a caller with no key of its own falls back to the headers above.`})]})]})]})]})}function $e({compact:e,tab:t,onTab:r,onCatalog:i,onDraft:a}){let[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),d=e&&!c;if((0,Z.useEffect)(()=>{if(d)return;let e=!0;return n.settings().then(t=>e&&s(t.registry.enabled)).catch(()=>e&&s(!0)),()=>{e=!1}},[d]),d){let e=e=>{u(!0),r(e)};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(et,{compact:!0,onPick:i}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Other ways:`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`registry`),children:`search the public list`}),` · `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`paste`),children:`paste instructions from a README`})]})]})}let f=[{id:`popular`,label:`Popular`},...o===!1?[]:[{id:`registry`,label:`Search the public list`}],{id:`paste`,label:`Paste instructions`},{id:`advanced`,label:`Advanced`}],p=t===`registry`&&o===!1?`popular`:t;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(k,{items:f,value:p,onChange:r,label:`Where to find the server`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:y(p),"aria-labelledby":l(p),children:p===`popular`?(0,Q.jsx)(et,{onPick:i}):p===`registry`?(0,Q.jsx)(rt,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(it,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(at,{onDraft:a})})]})}function et({onPick:e,compact:t}){let i=ie(()=>n.catalog(),[]),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(!1),p=i.data?.entries??[],h=a?qe(p,a,l):[...qe(p,a,l)].sort((e,t)=>Number(t.id===tt)-Number(e.id===tt)),g=[...new Set(p.map(e=>e.category))],v=t&&!d&&!a?6:1/0,y=h.slice(0,v);return i.error&&!i.data?(0,Q.jsx)(s,{tone:`danger`,title:`The list of servers could not be loaded`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:V(i.error)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search: files, GitHub, notes…`,"aria-label":`Search servers`,className:`field pl-10`})]}),!t&&g.length>1&&(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Kind of server`,className:`flex flex-wrap gap-1.5`,children:[`all`,...g].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:P(`h-8 rounded-full border-[1.5px] px-3.5 text-[13px] font-semibold transition-colors`,l===e?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:e===`all`?`All`:L[e]},e))})]}),i.data?h.length===0?(0,Q.jsxs)(_,{icon:`search`,title:`Nothing matches`,compact:!0,children:[`Try another word. You can also search the public list, or paste the server's setup instructions, using the `,t?`links below`:`tabs above`,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,role:`status`,children:[r(h.length,`server`),` found`]}),(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:y.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(nt,{entry:t,onPick:()=>e(t)})},t.id))}),y.length<h.length&&(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),children:[`Show all `,h.length]})})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))})]})}var tt=`filesystem`;function nt({entry:t,onPick:n}){let r=De(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===tt?(0,Q.jsx)(e,{tone:`ok`,icon:`check`,children:`Good first choice`}):t.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.summary}),(r.setup.length>0||r.needs.length>0)&&(0,Q.jsxs)(`span`,{className:`mt-auto flex flex-wrap gap-1.5 pt-1`,children:[r.setup.length>0&&(0,Q.jsx)(`span`,{title:`Needs ${r.setup.map(e=>W[e]??e).join(` and `)}. The next screen walks you through it.`,children:(0,Q.jsx)(e,{icon:`wrench`,children:`Needs a little setup`})}),r.needs.map(t=>(0,Q.jsx)(e,{children:t},t))]})]})}function rt({onCatalogId:t,onDraft:i}){let[a,c]=(0,Z.useState)(``),l=w(a.trim(),300),[u,d]=(0,Z.useState)(null),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,T]=(0,Z.useState)(null),D=ie(()=>n.catalog(),[]),ee=l?qe(D.data?.entries??[],l).slice(0,3):[];(0,Z.useEffect)(()=>{if(!l){d(null),h([]),_(null),b(!1);return}let e=!0;return b(!0),n.registrySearch(l).then(t=>{e&&(d(t),h(t.hits),_(null))}).catch(t=>{e&&(t instanceof f&&(t.status===404||t.code===`registry-off`)?_(`Searching the public list is switched off in Settings & help.`):_(V(t)))}).finally(()=>e&&b(!1)),()=>{e=!1}},[l,x]),(0,Z.useEffect)(()=>{if(!u?.loading)return;let e=setTimeout(()=>S(e=>e+1),2e3);return()=>clearTimeout(e)},[u]);let O=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(V(e))).finally(()=>b(!1)))},te=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(V(e))).finally(()=>T(null))):e.draft&&i(e.draft,{})};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`A public directory of servers that anyone can publish to. Only the words you type are sent to it to find matches. Nobody has checked these servers, so look at who made one before you add it.`}),(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search the public list`,"aria-label":`Search the public list`,className:`field pl-10`}),y&&(0,Q.jsx)(`span`,{className:`absolute right-3.5 text-soft`,children:(0,Q.jsx)(N,{})})]}),(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] text-soft`,children:u?.loading?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+ee.length,`server`)}${u.updatedAt?` · list updated ${v(u.updatedAt)}`:``}`:null}),u?.problem&&(0,Q.jsx)(s,{tone:`warn`,children:u.problem}),g&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:()=>S(e=>e+1),children:`Try again`}),children:g}),l?!u&&!g?(0,Q.jsx)(o,{lines:4,height:18}):(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[ee.map(n=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id,n),className:`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:n.name}),(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:n.summary}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`by `,n.publisher.name]})]})},`catalog-${n.id}`)),p.filter(e=>!e.catalogId||!ee.some(t=>t.id===e.catalogId)).map(t=>{let n=!!t.catalogId||!!t.draft;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>te(t),"aria-describedby":n?void 0:`why-${t.name}`,className:P(`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] p-4 text-left transition-colors`,n?`border-line hover:border-[var(--soft)] hover:bg-faint/50`:`cursor-not-allowed border-line bg-sunken/40 opacity-70`),children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:t.title??t.name}),C===t.name&&(0,Q.jsx)(N,{}),t.catalogId?(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`}):n?(0,Q.jsx)(e,{tone:`warn`,children:`From the public list — not checked by us`}):(0,Q.jsx)(e,{children:`Can't be added`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.description}),t.caution&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,className:`mt-0.5 shrink-0`}),t.caution]}),(0,Q.jsxs)(`code`,{className:`mono text-[11.5px] text-soft`,children:[t.name,` · `,t.version]}),!n&&(0,Q.jsx)(`span`,{id:`why-${t.name}`,className:`text-[12.5px] text-soft`,children:t.unsupported??`It can't be started from the public list's description.`})]})},t.name)})]}):(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:`Type the name of a server or a service, such as “weather” or “slack”, to search the public list.`}),u?.nextCursor&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:O,loading:y,children:`Show more`})})]})}function it({onDraft:e,onAdvanced:t}){let[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-paste`,className:`text-[13px] font-semibold`,children:`Paste the setup instructions`}),(0,Q.jsx)(`textarea`,{id:`add-paste`,rows:8,value:i,onChange:e=>{a(e.target.value),u(null)},"aria-describedby":`add-paste-help`,placeholder:`{
|
|
2
|
-
"mcpServers": {
|
|
3
|
-
"weather": { "command": "npx", "args": ["-y", "weather-mcp"] }
|
|
4
|
-
}
|
|
5
|
-
}`,className:`field resize-y font-mono text-[13px]`}),(0,Q.jsx)(`p`,{id:`add-paste-help`,className:`text-[12.5px] text-soft`,children:`Copy the part of the server's instructions page (often called its README) that shows how to add it: a block of settings, a one-line command, or just its web address. Nothing is saved yet, and any keys in it go into your locked keys, never into a settings file.`})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{variant:`primary`,icon:`search`,onClick:()=>{c(!0),f(null),n.paste(i).then(u).catch(e=>f(V(e))).finally(()=>c(!1))},loading:o,disabled:!i.trim(),children:`Read it`})}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),l&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-3`,children:[l.servers.length===0?(0,Q.jsx)(s,{tone:`warn`,title:`No server could be added from that`,children:l.warnings.length>0&&!/didn't look like setup instructions/.test(l.warnings.join(` `))?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):(0,Q.jsxs)(Q.Fragment,{children:[`We couldn't find a server in that. Paste the line that starts with `,(0,Q.jsx)(`code`,{className:`mono`,children:`npx`}),`, `,(0,Q.jsx)(`code`,{className:`mono`,children:`uvx`}),` or`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`docker`}),`, the block that contains `,(0,Q.jsx)(`code`,{className:`mono`,children:`mcpServers`}),`, or the server's web address. You can also add it by hand under`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-semibold underline`,onClick:t,children:`Advanced`}),`.`]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`Found `,r(l.servers.length,`server`),l.recognisedAs&&(0,Q.jsxs)(`span`,{className:`font-normal text-soft`,children:[` · read as `,l.recognisedAs]})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.servers.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>e(t.draft,t.values),className:`flex w-full items-center gap-3 rounded-[18px] border-[1.5px] border-line p-4 text-left hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(m,{name:t.draft.launch.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:t.draft.displayName}),(0,Q.jsx)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:t.draft.launch.transport===`http`?`Remote server · ${t.draft.launch.url}`:`Runs on this computer · ${[t.draft.launch.command,...t.draft.launch.args??[]].join(` `)}`}),t.draft.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:e},e))]}),(0,Q.jsx)(m,{name:`chevron-right`,size:18,className:`shrink-0 text-soft`})]})},`${t.draft.name}-${n}`))})]}),l.servers.length>0&&l.warnings.length>0&&(0,Q.jsx)(s,{tone:`info`,title:`Note`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]})]})}function at({onDraft:e}){let[t,n]=(0,Z.useState)(Je()),[r,i]=(0,Z.useState)(!1),a=Ze(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`For a server you know how to start. Values whose names look like keys (TOKEN, KEY, SECRET, PASSWORD) go into your locked keys rather than the toolbox's settings file.`}),(0,Q.jsx)(Qe,{value:t,onChange:n}),r&&a&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:a}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(E,{variant:`primary`,iconRight:`arrow-right`,onClick:()=>{if(i(!0),a)return;let n=we(Xe(t));e(n.draft,n.values)},children:`Continue`})})]})}function ot({transport:e}){let[t,n]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,Q.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(N,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:ve(t,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`Nothing is saved yet. `,t>2&&(0,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,t,` s)`]})]})]})]})}var st=[`run`,`ask`,`blocked`],ct={run:`Your AI can use these without asking.`,ask:`Once protection is on, each use waits until you say yes.`,blocked:`Once protection is on, your AI can't use these.`};function lt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=H(e),a=Pe(e),o=st.filter(e=>i[e].length>0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 rounded-[18px] bg-ok-tint p-4`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-surface text-ok`,children:(0,Q.jsx)(m,{name:`check`,size:20,strokeWidth:2.2})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:r?`${t} started`:`${t} works`}),(0,Q.jsxs)(`span`,{className:`block text-[13.5px] text-muted`,children:[ke(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(Ge,{sub:n?`What happens when your AI uses each tool once protection is on. Right now your toolbox only watches, so everything runs and is written down. You can change any of this later on the Tools page.`:n===!1?`What happens when your AI uses each tool. Protection is on. You can change any of this later on the Tools page.`:`What happens when your AI uses each tool once protection is on. You can change any of this later on the Tools page.`,children:`What your AI can do`}),(0,Q.jsx)(`div`,{className:P(`grid gap-3`,o.length===2?`md:grid-cols-2`:o.length>=3?`lg:grid-cols-3 md:grid-cols-2`:``),children:o.map(e=>(0,Q.jsx)(ut,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(Ge,{children:a.lines.length>0?`Please check`:`Note`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.lines.map((e,t)=>(0,Q.jsxs)(`li`,{className:P(`flex gap-2 rounded-2xl p-3`,e.tone===`warn`?`bg-warn-tint`:`border border-line`),children:[(0,Q.jsx)(m,{name:e.text.startsWith(`Won't be offered`)?`eye-off`:`warning`,size:17,className:P(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[e.tool&&(0,Q.jsx)(`code`,{className:`mono mr-1 font-semibold`,children:e.tool}),e.text,e.technical&&(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[12.5px] text-soft select-none`,children:`Details`}),(0,Q.jsx)(`p`,{className:`mono mt-1 text-[12px] break-words text-soft`,children:e.technical})]})]})]},t)),a.quiet&&(0,Q.jsx)(`li`,{className:`rounded-2xl border border-line p-3 text-muted`,children:(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer select-none`,children:[a.quiet.text,` `,(0,Q.jsx)(`span`,{className:`text-soft underline`,children:`Details`})]}),(0,Q.jsx)(`ul`,{className:`mt-2 flex max-h-64 flex-col gap-1 overflow-auto text-[12px] text-soft`,children:a.quiet.details.map((e,t)=>(0,Q.jsxs)(`li`,{className:`mono break-words`,children:[e.tool&&(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e.tool,`: `]}),e.text]},t))})]})})]})]})]})}function ut({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=Ce[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:ct[e]}),(0,Q.jsx)(`ul`,{className:P(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":ae[o].label,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Q.jsx)(b,{effect:e.effect}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`block text-[13px] [overflow-wrap:anywhere]`,title:e.description?`${e.name}: ${e.description}`:e.name,children:e.title??X(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:j[e.effect]?.label}),e.packRule&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted`,title:`Decided by a ready-made rule for this server`,children:`Ready-made rule`})]},e.name))}),!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>i(!0),children:[`Show all `,t.length]}),(0,Q.jsxs)(`details`,{className:`mt-2 text-[12px] text-soft`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Q.jsxs)(`p`,{className:`mt-1`,children:[`The server's own names:`,` `,t.map((e,t)=>(0,Q.jsxs)(`span`,{children:[t>0&&`, `,(0,Q.jsx)(`code`,{className:`mono break-normal`,children:re(e.name)})]},e.name))]})]})]})}var dt=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function ft({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=R(t.requires,h),T=Me(t),E=t.launch.transport===`http`?Le(t.launch.url,r):``,D=Ae(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(dt(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let ee=e=>a[e.id]??(o||y[e.id]?be(e,r[e.id]):null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[20px] font-medium tracking-[-0.02em]`,children:t.displayName}),n?.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`}),t.source.kind===`registry`&&(0,Q.jsx)(e,{tone:`warn`,icon:`warning`,children:`From the public list — not checked by us`}),t.source.kind===`paste`&&(0,Q.jsx)(e,{children:`From what you pasted`}),t.requires.map(t=>(0,Q.jsxs)(e,{children:[`Needs `,W[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(A,{text:n?.description??n?.summary??``})})]}),t.warnings.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Before you go on`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl bg-warn-tint px-4 py-3`,children:[(0,Q.jsx)(d,{checked:r.__local_ok===!0,onChange:e=>x(`__local_ok`,e),label:`This is on my own computer or network`,description:D===`loopback`?`This server's address is on this computer. Testing it lets the toolbox reach that address, just for the test. Only tick this if you started that program yourself.`:`This server's address is on your own network (a router or another computer). Testing it lets the toolbox reach that address, just for the test. Only tick this if you know what is there.`}),a.__local_ok&&r.__local_ok!==!0&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),`Tick this first, or choose another server.`]})]}),(0,Q.jsx)(Ke,{missing:w,platform:h?.platform,onRecheck:_,checking:g}),C.length>1&&S&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:`How to run it`}),(0,Q.jsx)(K,{label:`How to run it`,value:S,onChange:c,options:C.map(e=>({value:e.id,title:e.label,body:(0,Q.jsxs)(Q.Fragment,{children:[e.summary??(e.launch.transport===`http`?`Runs on the service's own computers. Nothing to install.`:`Runs on this computer.`),(e.requires??[]).length>0&&(0,Q.jsxs)(`span`,{className:`mt-1 block`,children:[`Needs `,(e.requires??[]).map(e=>W[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:P(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(ne,{steps:t.guide,className:`md:self-start`}),(0,Q.jsxs)(`section`,{"aria-label":`Settings for this server`,className:`flex min-w-0 flex-col gap-5`,children:[T&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Sign in`}),(0,Q.jsx)(Fe,{serverUrl:E,secretName:de(l||t.name),name:t.displayName,signedIn:f,onSignedIn:p,startNonce:v?.kind===`sign-in`?v.nonce:void 0})]}),t.fields.map(e=>(0,Q.jsx)(pt,{field:e,value:r[e.id],storedAs:typeof r[`__saved.${e.id}`]==`string`?r[`__saved.${e.id}`]:void 0,onChange:t=>x(e.id,t),onBlur:()=>b(t=>({...t,[e.id]:!0})),error:ee(e),openFolder:v?.kind===`folder`&&(!v.field||v.field===e.id)?v.nonce:void 0},e.id)),t.fields.length===0&&!T&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:[(0,Q.jsx)(m,{name:`check`,size:17,className:`text-ok`}),` Nothing to fill in. Test it to see what it can do.`]}),(0,Q.jsxs)(Ee,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-server-name`,className:`text-[13px] font-semibold`,children:`Name in your toolbox`}),(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:`name`})]}),(0,Q.jsx)(`input`,{id:`add-server-name`,className:`field font-mono text-[13px]`,value:l,onChange:e=>u(e.target.value),"aria-describedby":`add-server-name-help`,"aria-invalid":!!z(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:P(`text-[12.5px]`,z(l)?`font-medium text-bad`:`text-soft`),children:z(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)(mt,{draft:t})]})]})]}),w.length===0&&t.requires.length>0&&h&&(0,Q.jsx)(`p`,{className:`sr-only`,role:`status`,children:`This computer has everything this server needs.`})]})}function pt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=dt(e.id),c=`${s}-help`,l=`${s}-err`,u=[e.help&&!i?c:null,i?l:null].filter(Boolean).join(` `)||void 0;if(e.kind===`toggle`)return(0,Q.jsx)(d,{checked:t===!0,onChange:n,label:e.label,description:e.help});let f=typeof t==`string`?t:``,p=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],h=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsxs)(`label`,{htmlFor:s,className:`text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&e.kind!==`choice`&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:`optional`})]}),e.technical&&(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:e.technical})]}),g;return g=e.kind===`secret`?(0,Q.jsx)(D,{id:s,value:f,onChange:n,storedAs:o,placeholder:e.placeholder,"aria-describedby":u,invalid:!!i}):e.kind===`folder`||e.kind===`folders`?(0,Q.jsx)(M,{id:s,value:p,multiple:e.kind===`folders`,onChange:t=>{n(e.kind===`folders`?t:t[0]??``),r()},openNonce:a,"aria-describedby":u}):e.kind===`choice`?(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{id:s,value:f,onChange:e=>n(e.target.value),onBlur:r,"aria-describedby":u,"aria-invalid":!!i||void 0,className:`field appearance-none pr-9`,children:(e.choices??[]).map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsx)(m,{name:`chevron`,size:16,className:`pointer-events-none absolute right-3 text-soft`})]}):(0,Q.jsx)(`input`,{id:s,type:e.kind===`url`?`url`:`text`,value:f,onChange:e=>n(e.target.value),onBlur:r,placeholder:e.placeholder??(e.kind===`url`?`https://`:void 0),spellCheck:!1,"aria-describedby":u,"aria-invalid":!!i||void 0,className:P(`field`,e.kind===`url`&&`font-mono text-[13px]`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.kind===`folder`||e.kind===`folders`?(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`font-normal text-soft`,children:`optional`})]}):h,g,e.help&&!i&&(0,Q.jsx)(`p`,{id:c,className:`text-[12.5px] text-soft`,children:(0,Q.jsx)(A,{text:e.help})}),i&&(0,Q.jsxs)(`p`,{id:l,role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),i]})]})}function mt({draft:e}){let t=e.launch,n=e=>typeof e==`string`?e:`${e.prefix??``}<locked key: ${e.field}>`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What it runs`}),t.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:[t.command,...t.args??[]].join(` `)}),Object.entries(t.env??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`=`,n(t)]},e))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:t.url}),Object.entries(t.headers??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`: `,n(t)]},e))]})]})}var $={saved:null},ht=new Set([`brave-search`]);function gt(){$.saved=null}function _t(e){let{gatewayId:t,onDone:r,onCancel:i,initialCatalogId:a,compact:c,fixUpstream:l}=e,[u,d]=(0,Z.useState)(`popular`),[p,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(a??null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(!1),[re,k]=(0,Z.useState)({}),[A,j]=(0,Z.useState)(null),[ie,M]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(!1),[le,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),[fe,L]=(0,Z.useState)(null),[R,he]=(0,Z.useState)($.saved),[_e,ve]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){ve(!0);return}let e=!0;return h.protection(t).then(t=>e&&ve(t.enforcement!==`enforce`)).catch(()=>e&&ve(null)),()=>{e=!1}},[t]);let[be,B]=(0,Z.useState)(null),H=e=>{$.saved=e,he(e)},U=(0,Z.useRef)(null),Ce=R?`done`:A&&A.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{U.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),B(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(me)));S({...Se(e,n),...r}),T(e.name),O(!1),ne(!1),k({}),j(null),I(null),e.requires.length&&!ae&&ke()},Te=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(V(e))).finally(()=>v(null))},[Ee,De]=(0,Z.useState)(!1),W=async(e,t,r)=>{De(!0),b(null);try{let i=(await n.catalog()).entries,a=Re(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Ue(o,e,r),c=a.entry):{draft:o,values:s}=ue(e,r),we(o,c,s),B(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)M({kind:`folder`,field:u([`folder`,`folders`]),nonce:l});else if(t===`replace-key`){let e=u([`secret`]);e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${me}${e}`))),M(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&M({kind:`sign-in`,nonce:l})}catch(e){b(V(e))}finally{De(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&W(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Te(t):v(null)}).catch(e=>{b(V(e)),v(null)})},[a]);let ke=()=>{ce(!0),n.doctor().then(oe).catch(()=>void 0).finally(()=>ce(!1))},G=p?.draft??null,K=G?Me(G):!1,Pe=de(w||G?.name||`server`),q=()=>{if(!G)return;ne(!0),I(null);let e=ge(G,x);if(Object.keys(e).length||z(w)){let t=G.fields.find(t=>e[t.id]);t&&M({kind:`field`,field:t.id,nonce:Date.now()}),j({kind:`error`,text:z(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else K&&!D?j({kind:`error`,text:`Sign in with ${G.displayName} first.`}):Ae(G,x)&&x.__local_ok!==!0?j({kind:`error`,text:`This server's address is on your own computer or network. Tick “This is on my own computer or network” first, or choose another server.`}):(j({kind:`running`}),k({}),n.testServer({...t?{gatewayId:t}:{},draft:G,values:K?{...x,[pe]:Pe}:x,...w.trim()===G.name?{}:{name:w.trim()},...be?{replacing:be}:{}}).then(e=>{if(Object.keys(e.problems).length){k(e.problems);let t=G.fields.find(t=>e.problems[t.id]);t&&M({kind:`field`,field:t.id,nonce:Date.now()}),j({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else j({kind:`done`,res:e})}).catch(e=>j({kind:`error`,text:V(e)})))},Fe=e=>{if(!G)return;let t=Date.now(),n=e=>G.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return q();case`install-runtime`:case`start-runtime`:return ke();case`show-details`:return;case`choose-folder`:{j(null);let e=n([`folder`,`folders`]);if(!e&&G.launch.transport===`stdio`&&p){let e=A?.kind===`done`?A.res.outcome.problem?.detail?.path:void 0,n=ue({name:w||G.name,transport:`stdio`,command:G.launch.command,args:G.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...G,launch:{...G.launch,args:n.draft.launch.args??[]},fields:[...G.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),M({kind:`folder`,field:`folders`,nonce:t})}return M(null)}return M({kind:`folder`,field:e,nonce:t})}case`replace-key`:{j(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${me}${e}`))),M(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Me(G)&&p&&g({...p,draft:ye(G)}),j(null),O(!1),M({kind:`sign-in`,nonce:t});case`check-address`:{j(null);let e=n([`url`,`text`]);return M(e?{kind:`field`,field:e,nonce:t}:null)}}},[J,Le]=(0,Z.useState)(null),Y=async(e,t,n)=>{if(!R)return;Le(null);let{upstreamName:r}=R.result;if(p){H(null),B(r),T(r),Fe(e);return}let i=t;if(!i)try{i=(await Ve(R.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Le(V(e));return}i?(H(null),await W(i,e,n)):Le(`The server "${r}" isn't in your toolbox any more.`)},ze=(0,Z.useRef)(!1),Be=async e=>{if(A?.kind!==`done`||ze.current)return;ze.current=!0,P(!0),I(null);let r;if(t)try{let[e,n]=await Promise.all([Ve(t),h.protection(t)]);r={gateway:e.digest,policy:n.policyWrite.digest}}catch{r=void 0}try{if(!e){let e=await n.install(t??`main`,{probeId:A.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){L(e.loosens);return}}let i=await n.install(t??`main`,{probeId:A.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});L(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;H({result:i,name:G?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?L(Ne(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(L(null),I({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(L(null),I({text:je(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:V(e)}))}finally{ze.current=!1,P(!1)}};(0,Z.useEffect)(()=>{if(!R||R.settled)return;let e=Date.now(),t=R.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=xe(t,R.result.upstreamName,R.result.apply,Date.now()-e,e);H({...R,live:n,settled:i})}).catch(()=>r&&(R.result.apply===`needs-restart`||Date.now()-e>=15e3)&&H({...R,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[R?.result.upstreamName,R?.settled]);let He=()=>{$.saved=null,i?.()},We=()=>{let e=R?.result;$.saved=null,e&&r(e)};if(R)return(0,Q.jsx)(vt,{saved:R,heading:U,onFinish:We,onRewatch:()=>H({...R,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void Y(e,t,n),reopenError:J});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||Ee?(0,Q.jsx)(o,{lines:5}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center rounded-[18px] bg-surface/70`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,Q.jsx)(N,{}),` Opening…`]})}),(0,Q.jsx)($e,{compact:c,tab:u,onTab:d,onCatalog:e=>Te(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:He,children:`Cancel`})})]});let X=p.draft,Ge=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>A?j(null):(g(null),ee({kind:`picker`})),disabled:A?.kind===`running`||le,children:A&&A.kind!==`error`?`Change its settings`:`Choose another server`}),Ke=A?.kind===`done`&&!A.res.outcome.ok?A.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,qe=X.source.kind===`catalog`&&X.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(X.launch.url)?p.entry?.name??X.displayName:void 0,Je={firstSignIn:K?!D:A?.kind===`done`&&!!A.res.signInAvailable,...qe?{desktopApp:qe.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:X.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||X.launch.transport===`stdio`};return Ce===`test`&&A?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,X.displayName]}),A.kind===`running`?(0,Q.jsx)(ot,{transport:X.launch.transport}):A.kind===`done`&&A.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lt,{outcome:A.res.outcome,name:X.displayName,watching:_e,keyUnchecked:X.fields.some(e=>e.kind===`secret`)&&!(X.source.kind===`catalog`&&ht.has(X.source.id))}),A.res.egressHosts.length>0&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 text-[13px] text-soft`,children:[(0,Q.jsx)(m,{name:`shield`,size:16,className:`mt-0.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Saving lets the toolbox reach `,(0,Q.jsx)(`span`,{className:`mono`,children:A.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):A.kind===`done`?(0,Q.jsx)(Oe,{problem:Ke,onFix:Fe,context:Je,extra:(0,Q.jsxs)(Q.Fragment,{children:[A.res.signInAvailable&&!K&&A.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>Fe(`sign-in`),children:`Sign in instead`}),Ie(Ke,Je).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:q,children:`Try again`})]})}):null,F&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:F.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:q,children:`Test it again`}):void 0,children:F.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Ge,A.kind===`done`&&A.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void Be(),loading:le,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!fe,title:`Save ${X.displayName}?`,confirmLabel:`Save and turn on`,consequences:fe??[],busy:le,error:F?.text??null,onCancel:()=>L(null),onConfirm:()=>void Be(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,X.displayName]}),(0,Q.jsx)(ft,{draft:X,entry:p.entry,values:x,onValues:e=>{S(e),k({})},problems:re,tried:te,onVariant:e=>p.entry&&Te(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:O,doctor:ae,doctorBusy:se,onRecheck:ke,focus:ie}),A?.kind===`error`&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[13.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,strokeWidth:2}),` `,A.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[Ge,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:q,disabled:!!_,children:`Test it`})]})]})}function vt({saved:e,heading:t,onFinish:n,onRewatch:r,onReopen:a,reopenError:o}){let{result:c,live:l,settled:u,name:d}=e,f=g(),p=!u,[h,_]=(0,Z.useState)(null),v=l.kind===`problem`||l.kind===`needs-sign-in`;(0,Z.useEffect)(()=>{if(!v||h)return;let e=!0;return Ve(c.gatewayId).then(t=>e&&t.broken===null&&_(t.config.upstreams.find(e=>e.name===c.upstreamName)??null)).catch(()=>void 0),()=>{e=!1}},[v,c.gatewayId,c.upstreamName]);let y,b=null,x=`check`;l.kind===`live`?(y=`Live — ${l.tools} ${l.tools===1?`tool`:`tools`} ready`,b=`${d} is on. Your AI app can use it now, no restart needed.`):c.apply===`not-running`?(y=`${d} is saved`,b=`It turns on when your AI app opens your toolbox. If you haven't connected an app yet, that's the next step.`):c.apply===`needs-restart`||l.kind===`needs-restart`?(y=`${d} is saved. Restart your AI app once`,b=(l.kind===`needs-restart`?l.why:void 0)??`The running toolbox couldn't take this change while running. Quit your AI app and open it again.`,x=`clock`):l.kind===`needs-sign-in`?(y=`Saved, but it needs you to sign in`,b=`Press Sign in again below. It turns on as soon as you're signed in.`,x=`warning`):l.kind===`problem`?(y=`Saved, but it isn't working yet`,x=`warning`):p?(y=`Turning on ${d}…`,x=`clock`):(y=`${d} is saved`,b=`It's still starting. You can see how it's doing on the Connections page.`,x=`clock`);let C=l.kind===`problem`?{name:c.upstreamName,state:`failed`,problem:l.problem,since:``,attempts:0,tool_count:0}:l.kind===`needs-sign-in`?{name:c.upstreamName,state:`needs-sign-in`,since:``,attempts:0,tool_count:0}:null,w=e=>{$.saved=null,ce(i(f,e,{server:c.gatewayId}))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-3 py-6 text-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:P(`grid h-12 w-12 place-items-center rounded-full`,x===`check`?`bg-ok-tint text-ok`:x===`warning`?`bg-warn-tint text-warn`:`bg-sunken text-muted`),children:(0,Q.jsx)(m,{name:x,size:22,strokeWidth:2})}),(0,Q.jsx)(`h2`,{ref:t,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:y}),(0,Q.jsx)(`div`,{className:`max-w-[46ch] text-[14px] text-muted`,children:p&&l.kind===`waiting`?(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:(0,Q.jsx)(S,{state:`connecting`,label:`Starting`})}):b})]}),C&&(0,Q.jsx)(ze,{gatewayId:c.gatewayId,upstream:h??{name:c.upstreamName,transport:`stdio`,command:``},state:C,onEdit:e=>a(e,h,l.kind===`problem`?l.problem.detail?.path:void 0),onFixed:r,onAllowAddress:()=>w(`/protection`)}),o&&(0,Q.jsxs)(s,{tone:`danger`,role:`alert`,title:`The setup screen couldn't be opened again`,children:[o,` You can change this server on the Connections page instead.`]}),(c.summary.length>0||c.created)&&(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13.5px]`,children:[c.created&&(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` Your toolbox is ready. Connect your AI app to it next.`]}),c.summary.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` `,e]},e))]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`primary`,icon:`check`,onClick:n,children:`Done`})})]})}var yt=null;function bt({client:e,projectDir:t,onClose:n,onDone:r}){let i=le(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(yt),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(yt=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{yt=null,n(),r()},_=Te(e.scope),v=()=>{l(!0),d(null),Be.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{yt=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(V(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(se,{open:!0,onClose:g,title:`Connection undone`,description:`Restart ${_} so it uses its own server list again.`,width:580,footer:(0,Q.jsx)(E,{variant:`primary`,onClick:g,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsx)(`p`,{children:e.fileRestored===`bytes`?`Your toolbox was taken out of ${_}, and its settings file is back exactly as it was before.`:e.fileRestored===`removed`?`Your toolbox was taken out of ${_}. Its settings file didn't exist before, so it was removed again.`:`Your toolbox was taken out of ${_}.`}),f.restored.length>0?(0,Q.jsx)(xt,{title:`Servers given back to ${_}`,items:f.restored}):(0,Q.jsxs)(`p`,{className:`text-soft`,children:[_,`'s own servers were never moved, so they keep working as before.`]}),e.copyLeft&&(0,Q.jsxs)(s,{tone:`warn`,title:`A copy of the old settings is kept`,children:[_,`'s settings file changed since it was connected, so a copy of it as it was is kept at `,(0,Q.jsx)(J,{children:e.copyLeft}),`. It holds the old values, including any keys that were written in it. Delete it once you no longer need it.`]}),e.keysKept&&e.keysKept.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Its keys stay in your locked keys (`,e.keysKept.join(`, `),`). Remove them under Settings & help, Locked keys, if nothing else uses them.`]}),e.stillUsedBy&&e.stillUsedBy.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Your toolbox was kept, because `,e.stillUsedBy.join(` and `),` still `,e.stillUsedBy.length===1?`uses`:`use`,` it.`]}),f.deleted.length>0&&(0,Q.jsx)(xt,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(xt,{title:`Files kept`,items:f.leftInPlace,paths:!0}),f.refusedToDelete.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Some files were not deleted`,children:(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:f.refusedToDelete.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(J,{children:e.path}),` `,q(B(e.why))]},e.path))})}),f.registryRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The toolbox was also removed from this console.`}),f.clientAllowRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The “Don't ask me twice” setting was removed from Claude Code.`}),f.clientAllowError&&(0,Q.jsx)(s,{tone:`warn`,children:q(B(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:q(B(f.warning))})]})})}return(0,Q.jsx)(se,{open:!0,onClose:n,tone:`danger`,dismissable:!c,title:`Undo the connection for ${e.label}?`,description:`${_} goes back to reaching its servers directly, without your toolbox checking each call.`,width:580,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`secondary`,onClick:n,disabled:c,children:`Keep it connected`}),(0,Q.jsx)(E,{variant:`danger`,onClick:v,loading:c,children:`Undo connection`})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`ul`,{className:`space-y-2 text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`refresh`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`The app's original server list is put back from the backup made when it was connected.`]}),(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[`The file changed is `,(0,Q.jsx)(J,{children:e.path})]})]})]}),(0,Q.jsx)(oe,{checked:a,onChange:o,label:`Also delete the toolbox's files`,description:`Its settings file and protection settings. Your rules and choices in them are lost. Leave this off to keep them for later. They are kept anyway while another app still uses the toolbox.`}),u&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:u})]})})}function xt({title:e,items:t,empty:n,paths:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:e}),t.length===0?(0,Q.jsx)(`p`,{className:`text-soft`,children:n}):(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.map(e=>(0,Q.jsx)(`li`,{children:r?(0,Q.jsx)(J,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var St={done:null};function Ct({gatewayId:t,onDone:r,compact:i,scope:a}){let c=ie(()=>Be.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(St.done&&(!a||St.done.scope===a)?St.done:null),g=e=>{St.done=e,h(e)},[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{p&&b.current&&(b.current=!1,y.current?.focus())},[p]);let S=c.data?.clients??[],C=(a?S.filter(e=>e.scope===a):S).filter(e=>!i||e.installed!==!1||e.exists).sort((e,t)=>wt(e)-wt(t)),w=e=>{u(e.scope),f(null),n.attach({gatewayId:t,scope:e.scope,...e.projectScoped&&c.data?.projectDir?{projectDir:c.data.projectDir}:{}}).then(t=>{let n=U(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n}),c.reload()}).catch(t=>f({scope:e.scope,text:V(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{ref:y,tabIndex:-1,role:`status`,className:`flex flex-col gap-3 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),p.alreadyConnected?`${p.appLabel} was already connected`:`Restart ${p.appLabel} once`]}),(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:p.alreadyConnected?`Nothing needed changing. Your servers reach it through the toolbox.`:`${p.appLabel} reads its list of servers when it opens, so it needs one restart to find your toolbox. After that, servers you add show up by themselves.`}),p.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:q(B(p.restartHint))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(J,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(J,{children:p.backupPath})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v({...e,canRevert:!0}),children:`Undo`}),!a&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:()=>g(null),children:`Connect another app`})]}),(0,Q.jsx)(bt,{client:_,projectDir:c.data?.projectDir,onClose:()=>v(null),onDone:()=>{g(null),c.reload()}})]})}return c.error&&!c.data?(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:c.reload,children:`Check again`}),children:V(c.error)}):c.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!a&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app you talk to. One click adds your toolbox to it; nothing else in the app changes.`}),C.length===0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`No AI app was found on this computer.`}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`Install one of these, open it once, then come back here and press Check again.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:c.loading,onClick:c.reload,children:`Check again`})]})]}),(0,Q.jsx)(`ul`,{className:P(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=he(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:P(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] border-line p-4`,!n&&!r&&`bg-sunken/40`),children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:P(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:G(t,c.data?.projectDir)}),r?(0,Q.jsx)(e,{tone:`ok`,children:`Connected`}):!n&&(0,Q.jsx)(e,{children:t.error?`Can't be read`:`Not found`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:t.error?q(B(t.error)):r?`It already reaches its servers through a toolbox.`:n?t.serverCount>0?`Adds your toolbox beside the ${t.serverCount} ${t.serverCount===1?`server`:`servers`} it already has. ${t.serverCount===1?`That one keeps`:`Those keep`} working as before, but without the toolbox's protection.`:`Adds your toolbox to it.`:`This app isn't on this computer.`}),d?.scope===t.scope&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:d.text}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[n&&!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:l===t.scope,disabled:!!l&&l!==t.scope,onClick:()=>w(t),children:[`Connect `,U(t.scope)]}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(bt,{client:_,projectDir:c.data.projectDir,onClose:()=>v(null),onDone:c.reload})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:2})},e))})}var wt=e=>e.error?3:e.alreadyAdopted?1:he(e)?0:4;export{Qe as a,Je as c,gt as i,Xe as l,bt as n,Ye as o,_t as r,Ze as s,Ct as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,Ct as i,D as a,E as o,Et as s,G as c,H as l,It as u,J as d,M as f,N as p,Nt as m,O as h,Ot as g,Pt as _,S as v,St as y,U as b,V as x,Y as S,Z as C,_ as w,_t as T,at as E,b as D,bt as O,c as k,et as A,f as j,ft as M,gt as N,ht as P,it as F,k as I,kt as L,l as R,lt as z,m as ee,mt as te,p as ne,pt as re,q as ie,s as ae,st as B,u as oe,vt as se,wt as ce,x as le,xt as ue,y as V,yt as H,z as de}from"./kit-DQ7Oxf5n.js";import{$ as fe,Bt as pe,Ft as me,Ht as he,It as ge,Jt as _e,Kt as U,Lt as W,Mt as ve,Pt as G,Q as ye,Qt as K,Rt as be,Ut as xe,Vt as Se,Wt as Ce,X as we,Yt as q,Z as Te,_ as Ee,an as De,cn as Oe,d as ke,dn as Ae,et as J,f as je,fn as Me,g as Ne,h as Pe,jt as Fe,ln as Ie,m as Le,mn as Re,nn as ze,on as Be,p as Ve,qt as He,rn as Ue,s as We,sn as Ge,tn as Ke,tt as Y,un as qe,v as Je,y as Ye,zt as Xe}from"./index-Khp0l1zp.js";import{a as Ze,c as Qe,i as $e,l as et,n as tt,o as nt,r as rt,s as it,t as at}from"./AttachApp-0zRSPgSY.js";var X=u(),Z=L(),ot=[`Choose an app`,`Choose how it starts`,`Check what will happen`,`Connect`],st={mode:`observe`,posture:`approve-writes`,onUnclassified:`approve`,packs:!0,clientAllow:!1,gatewayName:``,entryName:``,rename:[],copyEnv:!1,allowLocalHttp:!1,strictEgress:!1,relativeConfig:!1,outDir:``,id:``};function ct(e,t,n,r){let i=Object.fromEntries(r.rename.filter(([e,t])=>e.trim()&&t.trim()).map(([e,t])=>[e.trim(),t.trim()]));return{scope:e,...n&&t?{projectDir:t}:{},mode:r.mode,posture:r.posture,onUnclassified:r.onUnclassified,packs:r.packs,...Xe(e)&&r.mode===`enforce`?{clientAllow:r.clientAllow}:{},...r.gatewayName.trim()?{gatewayName:r.gatewayName.trim()}:{},...r.entryName.trim()?{entryName:r.entryName.trim()}:{},...Object.keys(i).length?{rename:i}:{},copyEnv:r.copyEnv,allowLocalHttp:r.allowLocalHttp,strictEgress:r.strictEgress,relativeConfig:r.relativeConfig,...r.outDir.trim()?{outDir:r.outDir.trim()}:{},...r.id.trim()?{id:r.id.trim()}:{}}}var Q={done:null,undo:null};function lt({open:e,onClose:t}){let n=()=>{Q.done=null,Q.undo=null,t()};return(0,Z.jsx)(v,{open:e,onClose:n,title:`Connect an app`,subtitle:`Put your toolbox between one of your AI apps and the servers it uses.`,width:880,children:e&&(0,Z.jsx)(ut,{onClose:n})})}function ut({onClose:e}){let{nav:t,reload:n}=K(),[r,a]=(0,X.useState)(0),[o,s]=(0,X.useState)(``),c=(0,X.useRef)(!1),u=O(o.trim(),450),d=ae(()=>Re.clients(u||void 0),[u]);(0,X.useEffect)(()=>{d.data&&!c.current&&!o&&s(d.data.projectDir)},[d.data]);let[f,p]=(0,X.useState)(null),h=d.data?.clients.find(e=>e.scope===f)??null,[g,_]=(0,X.useState)(st),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(Q.undo),S=e=>{Q.undo=e,x(e)},C=(0,X.useMemo)(()=>h?ct(h.scope,d.data?.projectDir??``,h.projectScoped,g):null,[h,d.data?.projectDir,g]),w=JSON.stringify(C),[T,E]=(0,X.useState)(null),D=r>=2&&C&&T?.key!==w;(0,X.useEffect)(()=>{if(r<2||!C||T?.key===w)return;let e=!0;return Re.plan(C).then(t=>e&&E({key:w,data:t,error:null})).catch(t=>e&&E({key:w,data:null,error:W(t)})),()=>{e=!1}},[r,w]);let[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),[N,F]=(0,X.useState)(Q.done),I=()=>{C&&(A(!0),M(null),Re.apply(C).then(e=>{Q.done=e,F(e)}).catch(e=>{if(e instanceof m&&e.status===409){M({text:`A toolbox with that name is already in the console. Choose another name and try again.`,idTaken:!0});return}let t=e.detail;t?.report&&E({key:w,data:t.report,error:null}),M({text:W(e),blocking:t?.blocking})}).finally(()=>A(!1)))};if(N)return(0,Z.jsx)(wt,{result:N,onClose:()=>{e(),n()},onOpen:r=>{e(),n(),ue(i(t,`/`,{server:r}))}});let L=T?.key===w?T:null,R=!!L?.data&&L.data.blocking.length>0,z=r===0?!!h&&h.exists&&!h.error&&(h.serverCount>0||h.alreadyAdopted):r===1||!!L?.data&&!R;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(oe,{steps:ot,step:r,onStep:e=>a(Math.max(0,e)),canNext:z&&!k,nextLabel:r===2?`Review and connect`:`Continue`,finishLabel:h?`Connect ${G(h.scope)}`:`Connect app`,onFinish:I,busy:k||!!D,children:[r===0&&(0,Z.jsx)(dt,{clients:d,projectDir:o,onProjectDir:e=>{c.current=!0,s(e)},scope:f,onScope:p,onUndo:S,onAttach:y}),r===1&&h&&(0,Z.jsx)(ht,{client:h,choices:g,onChange:_,found:L?.data?.serversFound??T?.data?.serversFound??[]}),r===2&&(D||!L?(0,Z.jsx)(gt,{}):L.error?(0,Z.jsx)(l,{tone:`danger`,title:`The check could not finish`,role:`alert`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>E(null),children:`Check again`}),children:L.error}):(0,Z.jsx)(vt,{plan:L.data,app:G(h.scope)})),r===3&&L?.data&&h&&(0,Z.jsx)(Ct,{plan:L.data,client:h,error:j,id:g.id,onId:e=>_({...g,id:e})})]}),(0,Z.jsx)(Tt,{client:v,onClose:()=>y(null),onDone:()=>d.reload()}),(0,Z.jsx)(tt,{client:b,projectDir:d.data?.projectDir,onClose:()=>S(null),onDone:()=>{d.reload(),n()}})]})}function dt({clients:e,projectDir:t,onProjectDir:n,scope:r,onScope:i,onUndo:a,onAttach:s}){let u=e.data?.clients??[],d=e.error&&!e.data?null:e.error;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app whose tools you want your toolbox to check. The servers it already uses keep working; they are reached through your toolbox instead of directly.`}),(0,Z.jsx)(o,{label:`Project folder`,help:`Some apps keep a server list per project. This is the project they are read from. Use the full path.`,error:d?W(d):null,children:(0,Z.jsx)(f,{value:t,onChange:n,mono:!0,placeholder:`/Users/me/my-project`})}),e.error&&!e.data?(0,Z.jsx)(l,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:e.reload,children:`Check again`}),children:W(e.error)}):e.data?(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":`App to connect`,className:`grid gap-3 sm:grid-cols-2`,children:[...u].sort((e,t)=>ft(e)-ft(t)).map(e=>(0,Z.jsx)(mt,{client:e,selected:r===e.scope,onSelect:()=>i(e.scope),onUndo:()=>a(e),onAttach:()=>s(e)},e.scope))}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Z.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Z.jsx)(c,{lines:3})},e))})]})}var ft=e=>e.error?3:e.alreadyAdopted?1:e.exists&&e.serverCount>0?0:me(e)?2:4,pt=e=>!e.alreadyAdopted&&me(e)&&!(e.exists&&e.serverCount>0);function mt({client:t,selected:n,onSelect:i,onUndo:a,onAttach:o}){let s=t.exists&&!t.error&&(t.serverCount>0||t.alreadyAdopted),c=pt(t),l=(0,X.useId)(),u=xe(t),d=t.error?{tone:`bad`,text:`Can't be read`}:!t.exists&&!c?{tone:`neutral`,text:`Not found`}:t.alreadyAdopted?{tone:`ok`,text:`Connected`}:t.serverCount===0?{tone:`neutral`,text:`No servers yet`}:{tone:`warn`,text:`Not protected`};return(0,Z.jsxs)(`div`,{className:H(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] p-4 transition-colors`,n?`border-primary bg-ok-tint`:`border-line`,!s&&`bg-sunken/40`),children:[(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-labelledby":`${l}-name`,"aria-describedby":`${l}-status ${l}-desc`,disabled:!s,onClick:i,className:`flex min-w-0 flex-col items-start gap-1 text-left disabled:cursor-not-allowed`,children:[(0,Z.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:H(`mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border-[1.5px]`,n?`border-primary bg-primary text-white`:`border-[var(--soft)]`,!s&&`opacity-40`),children:n&&(0,Z.jsx)(g,{name:`check`,size:12,strokeWidth:3})}),(0,Z.jsx)(`span`,{id:`${l}-name`,className:H(`min-w-0 flex-1 text-[15px] font-semibold`,!s&&`text-soft`),children:u}),(0,Z.jsx)(`span`,{id:`${l}-status`,children:(0,Z.jsx)(e,{tone:d.tone,children:d.text})})]}),(0,Z.jsx)(`span`,{id:`${l}-desc`,className:`pl-7 text-[13px] text-soft`,children:t.error?q(U(t.error)):c?`It has no servers yet. Connect it to your toolbox, then add servers there.`:t.exists?t.alreadyAdopted?t.serverCount>1?`Goes through your toolbox. ${r(t.serverCount-1,`new server`)} could be added.`:`Its servers already go through your toolbox.`:t.serverCount===0?`The app has no servers set up, so there is nothing to protect yet.`:`${r(t.serverCount,`server`)} set up, reached directly with nothing checking them.`:`This app's settings file isn't on this computer.`}),t.exists&&(0,Z.jsx)(`span`,{className:`pl-7`,children:(0,Z.jsx)(J,{children:t.path})})]}),c&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`plug`,onClick:o,children:`Connect it to your toolbox`})}),t.canRevert&&(0,Z.jsx)(`div`,{className:`pl-7`,children:(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:a,children:`Undo connection`})})]})}function ht({client:t,choices:n,onChange:r,found:i}){let a=(e,t)=>r({...n,[e]:t}),s=Xe(t.scope);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:`You can switch at any time on the Protection settings page.`,children:[`How it starts `,(0,Z.jsx)(w,{term:`watchOnly`})]}),(0,Z.jsx)(we,{label:`How it starts`,value:n.mode,onChange:e=>a(`mode`,e),options:[{value:`observe`,title:E.observe.label,badge:(0,Z.jsx)(e,{tone:`ok`,children:`Recommended for day one`}),body:`Nothing breaks while you settle in. Every call runs, and the activity log shows what would have been blocked or held, so you can adjust before turning protection on.`},{value:`enforce`,title:E.enforce.label,body:`Rules apply from the first call. Blocked calls stop and changes wait for you, which can interrupt work until the rules fit.`}]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:`What happens to a call no rule mentions.`,children:[`Default stance `,(0,Z.jsx)(w,{term:`defaultStance`})]}),(0,Z.jsx)(we,{label:`Default stance`,columns:3,value:n.posture,onChange:e=>a(`posture`,e),options:Object.keys(B).map(e=>({value:e,title:B[e].label,body:B[e].explain}))})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(o,{label:(0,Z.jsxs)(Z.Fragment,{children:[`Tools nobody has labelled yet `,(0,Z.jsx)(w,{term:`unknownTools`})]}),help:`A tool that hasn't said whether it only looks, makes changes or deletes.`,children:(0,Z.jsx)(h,{label:`Tools nobody has labelled yet`,value:n.onUnclassified,onChange:e=>a(`onUnclassified`,e),options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,Z.jsx)(p,{checked:n.packs,onChange:e=>a(`packs`,e),label:`Use ready-made rules for servers your toolbox knows`,description:`For well-known servers such as file system and GitHub, sensible rules are filled in for each tool so you start with less to decide.`}),(0,Z.jsx)(p,{checked:s&&n.mode===`enforce`&&n.clientAllow,onChange:e=>a(`clientAllow`,e),disabled:!s||n.mode!==`enforce`,label:`Don't ask me twice`,description:s?n.mode===`enforce`?`Claude Code asks before each tool call, and your toolbox asks too when a rule says so. This stops Claude Code asking about your toolbox's tools, so you answer once.`:`Available when protecting. While it only watches, your toolbox never asks, so Claude Code's own question is the only one left.`:`Only Claude Code has this setting. ${G(t.scope)} keeps asking in its own way.`})]}),(0,Z.jsxs)(ye,{title:`More options`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Toolbox name`,technical:`name`,optional:!0,help:`Shown in the console and in the activity log.`,children:(0,Z.jsx)(f,{value:n.gatewayName,onChange:e=>a(`gatewayName`,e),mono:!0,placeholder:`claude-code`})}),(0,Z.jsx)(o,{label:`Name in the app's server list`,optional:!0,technical:`entry name`,help:`What your toolbox is called inside the app.`,children:(0,Z.jsx)(f,{value:n.entryName,onChange:e=>a(`entryName`,e),mono:!0,placeholder:`hmcp`})})]}),(0,Z.jsx)(o,{label:`Rename servers`,optional:!0,help:i.length?`Found in the app: ${i.join(`, `)}. New names use lower-case letters, digits and underscores.`:`The name in the app on the left, the name in your toolbox on the right. Lower-case letters, digits and underscores.`,children:(0,Z.jsx)(fe,{value:n.rename,onChange:e=>a(`rename`,e),keyLabel:`Name in the app`,valueLabel:`Name in your toolbox`,addLabel:`Add a rename`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{checked:n.copyEnv,onChange:e=>a(`copyEnv`,e),label:`Copy keys into the toolbox's settings file`,description:`Gives each server its own copy of the values it needs, such as access keys.`}),n.copyEnv&&(0,Z.jsx)(l,{tone:`warn`,title:`This writes passwords and keys into a file`,children:`The toolbox's settings file will hold them in plain text, outside your locked keys. Anyone who can read that file can read them, so don't share it or put it anywhere others can see. Leave this off unless a server was left out because of its values.`})]}),(0,Z.jsx)(p,{checked:n.allowLocalHttp,onChange:e=>a(`allowLocalHttp`,e),label:`Allow servers on this computer`,description:`Lets your toolbox reach web servers on this computer or your local network. This adds to your allowed addresses for every web server this toolbox reaches, not just one.`}),(0,Z.jsx)(p,{checked:n.strictEgress,onChange:e=>a(`strictEgress`,e),label:`Strict allowed addresses`,description:`Each remote server may be reached only at its exact address and port, rather than anywhere on its host.`}),(0,Z.jsx)(p,{checked:n.relativeConfig,onChange:e=>a(`relativeConfig`,e),label:`Point to the toolbox's settings file by a relative path`,description:`Useful when the project folder is shared or moved, so the app finds the toolbox's settings file wherever the folder lives.`}),(0,Z.jsx)(o,{label:`Folder for the toolbox's files`,optional:!0,help:`A full path. By default they go in a .hmcp folder in the project, or in your home folder for apps that aren't per project.`,children:(0,Z.jsx)(f,{value:n.outDir,onChange:e=>a(`outDir`,e),mono:!0,placeholder:`/Users/me/my-project/.hmcp`})})]})]})}function gt(){let[e,t]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-14 text-center`,children:[(0,Z.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Z.jsx)(se,{size:26})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-[17px] font-medium`,children:`Starting each server to see its tools…`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`This can take up to about 40 seconds. Nothing is changed yet. `,e>2&&(0,Z.jsxs)(`span`,{className:`tnum`,children:[`(`,e,` s)`]})]})]})]})}var _t=[{key:`run`,label:`Runs freely`,icon:`check`,tone:`ok`},{key:`ask`,label:`Asks first`,icon:`clock`,tone:`warn`},{key:`blocked`,label:`Blocked`,icon:`x`,tone:`bad`},{key:`hidden`,label:`Hidden`,icon:`eye-off`,tone:`neutral`}];function vt({plan:t,app:n}){let i=t.starting?.mode!==`enforce`,a=t.tools.filter(e=>e.injection);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t.blocking.length>0&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`This can't be connected yet`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.blocking.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))})}),t.status===`already-adopted`&&t.blocking.length===0&&(0,Z.jsx)(l,{tone:`info`,title:`${n} already goes through your toolbox`,children:`Connecting again only applies the change you chose.`}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:t.existingGateway?`New servers are added to the toolbox this app already uses.`:void 0,children:[`Servers (`,t.upstreams.length,`)`]}),t.upstreams.length===0?(0,Z.jsx)(`p`,{className:`text-[14px] text-soft`,children:`No server can go through your toolbox.`}):(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:t.upstreams.map(t=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-3 rounded-2xl bg-sunken/60 p-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-surface text-muted`,children:(0,Z.jsx)(g,{name:t.transport===`http`?`external`:`server`,size:17})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`code`,{className:`mono text-[13.5px] font-semibold`,children:t.name}),t.originalName!==t.name&&(0,Z.jsxs)(`span`,{className:`text-[12px] text-soft`,children:[`was `,t.originalName]}),t.alreadyFronted&&(0,Z.jsx)(e,{children:`Already connected`})]}),(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:t.transport===`http`?`Remote server · ${t.url}`:`Runs on this computer · ${[t.command,...t.args].join(` `)}`}),(t.envNames.length>0||t.passEnv.length>0||t.headerNames.length>0)&&(0,Z.jsxs)(`span`,{className:`mt-0.5 block text-[12px] text-soft`,children:[`Uses `,(0,Z.jsx)(`span`,{className:`mono`,children:[...t.envNames,...t.passEnv,...t.headerNames].join(`, `)})]}),t.warnings.map(e=>(0,Z.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:q(U(e))},e))]})]},t.name))}),(t.skipped.length>0||t.malformed.length>0)&&(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:[`Left out (`,t.skipped.length+t.malformed.length,`)`]}),(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.skipped.map(e=>{let t=He(e.reason,e.remedy);return(0,Z.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:t.reason}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-soft`,children:t.remedy})]},e.name)}),t.malformed.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-2xl border border-line p-3 text-[13.5px]`,children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Its entry in the app's settings could not be read: `,q(U(e.message))]})]},e.name))]})]})]}),t.probeFailures.length>0&&(0,Z.jsxs)(l,{tone:`danger`,title:`Some servers didn't start or answer`,children:[(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:t.probeFailures.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`mono`,children:e.upstream}),`: `,q(U(e.message))]},e.upstream))}),(0,Z.jsx)(`p`,{className:`mt-1`,children:`Check that each one works in the app on its own, then go back a step and check again.`})]}),t.tools.length>0&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{sub:i?`For now it only watches, so every call runs. This is what will happen once you turn protection on.`:`What happens to each tool from the first call.`,children:[`Tools (`,t.tools.length,`)`]}),(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:_t.map(e=>{let n=t.tools.filter(t=>t.verdict===e.key);return n.length===0?null:(0,Z.jsx)(xt,{label:e.label,icon:e.icon,tone:e.tone,tools:n},e.key)})})]}),(a.length>0||t.findings.length>0||t.namesTooLong.length>0||t.withheld.length>0)&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Worth a look`}),(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl bg-warn-tint p-3`,children:[(0,Z.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` has hidden instructions in its description.`,` `,e.hidden?`The tool will be hidden from your AI app.`:`Your toolbox will deal with them as set in its options.`]})]},`inj-${e.name}`)),yt(t.findings).map(e=>(0,Z.jsx)(bt,{group:e},e.ruleId)),t.namesTooLong.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`warning`,size:17,className:`mt-0.5 shrink-0 text-warn`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` has a name too long for `,n,` (`,e.length,` of `,e.limit,` letters), so it won't be offered. A shorter server name under More options leaves more room.`]})]},`long-${e.name}`)),t.withheld.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`eye-off`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`code`,{className:`mono font-semibold`,children:e.name}),` won't be offered: `,q(U(e.reason))]})]},`w-${e.name}`))]})]}),t.packs.length>0&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Ready-made rules`}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.packs.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-2xl bg-ok-tint p-3 text-[13.5px]`,children:[(0,Z.jsx)(g,{name:`shield-check`,size:18,className:`shrink-0 text-ok`}),(0,Z.jsxs)(`span`,{children:[e.packLabel,` rules for `,(0,Z.jsx)(`code`,{className:`mono`,children:e.upstreamName}),`: `,r(e.rules.length,`rule`),e.unmatched.length>0&&(0,Z.jsxs)(`span`,{className:`text-soft`,children:[` · `,e.unmatched.length,` not used by this server`]})]})]},e.upstreamName))})]}),t.warnings.length>0&&(0,Z.jsx)(l,{tone:`warn`,title:`Before you connect`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))})}),t.files&&(0,Z.jsx)(St,{plan:t})]})}function yt(e){let t=new Map;for(let n of e)t.set(n.ruleId,[...t.get(n.ruleId)??[],n]);return[...t.entries()].map(([e,t])=>({ruleId:e,high:t.some(e=>e.severity===`high`),items:t})).sort((e,t)=>Number(t.high)-Number(e.high))}function bt({group:e}){let[t,n]=(0,X.useState)(!1);return(0,Z.jsxs)(`li`,{className:`flex gap-2 rounded-2xl border border-line p-3`,children:[(0,Z.jsx)(g,{name:`shield`,size:17,className:H(`mt-0.5 shrink-0`,e.high?`text-bad`:`text-warn`)}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:M(e.ruleId)}),(0,Z.jsx)(`span`,{className:`mono text-[11.5px] text-soft`,children:e.ruleId}),e.items.length>1&&(0,Z.jsxs)(`span`,{className:`text-soft`,children:[`· `,e.items.length,` places`]}),e.ruleId in F&&(0,Z.jsx)(w,{term:e.ruleId})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`-ml-3`,"aria-expanded":t,onClick:()=>n(!t),children:t?`Hide details`:`Show details`}),t&&(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5 text-[13px] text-muted`,children:e.items.map((e,t)=>(0,Z.jsx)(`li`,{className:`break-words`,children:q(U(e.message))},t))})]})]})}function xt({label:t,icon:n,tone:r,tools:i}){let[a,o]=(0,X.useState)(i.length<=8),s=a?i:i.slice(0,8);return(0,Z.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Z.jsx)(e,{tone:r,icon:n,children:t}),(0,Z.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:i.length})]}),(0,Z.jsx)(`ul`,{className:`flex flex-col`,children:s.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Z.jsx)(C,{effect:e.effect}),(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 truncate text-[12.5px]`,title:e.name,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[12px] text-soft`,title:e.decidedBy,children:ge(e.decidedBy)})]},e.name))}),!a&&(0,Z.jsxs)(P,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>o(!0),children:[`Show all `,i.length,` tools`]})]})}function St({plan:e}){let t=e.files,n=[[`The app's settings, changed to use your toolbox`,t.clientConfig],[`Backup of the app's settings`,t.wholeFileBackup],[`Record used to undo the connection`,t.backupRecord],[`The toolbox's settings file`,t.gatewayConfig],[t.policyKept?`Protection settings (kept as they are)`:`Protection settings`,t.policy],[`Claude Code permission for “Don't ask me twice”`,t.clientSettings]];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Files that will be written`}),(0,Z.jsx)(`dl`,{className:`flex flex-col gap-2 text-[13px]`,children:n.filter(([,e])=>e).map(([e,t])=>(0,Z.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-[240px_1fr]`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(J,{children:t})})]},e))})]})}function Ct({plan:e,client:t,error:n,id:i,onId:a}){let s=G(t.scope),c=e.starting?.mode!==`enforce`,u=e.upstreams.filter(e=>!e.alreadyFronted).length,d=[[`plug`,u>0?`${r(u,`server`)} in ${t.label} will go through your toolbox.`:`The change you chose is applied to your toolbox.`],[`file`,`A backup of the app's settings is kept, so you can undo this here at any time.`],[c?`eye`:`shield-check`,c?`For now it only watches: everything runs, and the activity log shows what would have been stopped.`:`It starts protecting: your rules apply from the first call.`],[`refresh`,`${s} has to be restarted afterwards to pick up your toolbox.`]];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{children:`When you connect`}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:d.map(([e,t])=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-3 text-[14.5px]`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Z.jsx)(g,{name:e,size:17})}),(0,Z.jsx)(`span`,{className:`pt-1.5`,children:t})]},t))}),n&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`It wasn't connected`,children:n.blocking?.length?(0,Z.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:n.blocking.map(e=>(0,Z.jsx)(`li`,{children:q(U(e))},e))}):n.text}),n?.idTaken&&(0,Z.jsx)(o,{label:`Toolbox name in the console`,technical:`id`,help:`Lower-case letters, digits, dashes and underscores.`,children:(0,Z.jsx)(f,{value:i,onChange:a,mono:!0,placeholder:`claude-code-2`})})]})}function wt({result:e,onClose:t,onOpen:n}){let r=G(e.scope),i=e.applied;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(R,{steps:ot,current:ot.length}),(0,Z.jsxs)(b,{icon:`check`,title:`Done. Restart ${r} so it picks up your toolbox.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[e.registryId&&(0,Z.jsx)(P,{variant:`primary`,icon:`arrow-right`,onClick:()=>n(e.registryId),children:`Open this toolbox`}),(0,Z.jsx)(P,{onClick:t,children:`Close`})]}),children:[i.replaced.length>0?`${i.replaced.join(`, `)} now ${i.replaced.length===1?`goes`:`go`} through your toolbox.`:`Your toolbox is set up as you chose.`,` `,e.starting?.mode===`enforce`?`It is protecting from the first call.`:`For now it only watches, so nothing is blocked yet.`]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Z.jsx)(`p`,{className:`font-semibold`,children:`What was backed up`}),i.wholeFileBackup&&(0,Z.jsxs)(`p`,{children:[`A copy of the app's settings as they were: `,(0,Z.jsx)(J,{children:i.wholeFileBackup})]}),(0,Z.jsxs)(`p`,{children:[`What's needed to undo it: `,(0,Z.jsx)(J,{children:i.backupRecord})]}),i.clientAllowAdded&&(0,Z.jsx)(`p`,{children:`Claude Code won't ask a second time about your toolbox's tools.`})]}),i.literalSecretsInBackup&&(0,Z.jsx)(l,{tone:`warn`,title:`The backups hold a password or key`,children:`A server you connected had a key written out in the app's settings, so both backup files contain it. Keep them private.`}),e.warning&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(e.warning))})]})}function Tt({client:e,onClose:t,onDone:n}){let{servers:r,serverId:i,nav:a}=K(),c=r.filter(e=>e.ok),[l,u]=(0,X.useState)(null),d=l??(c.some(e=>e.id===i)?i:c[0]?.id??null);return e?(0,Z.jsx)(le,{open:!0,onClose:t,title:`Connect ${G(e.scope)} to your toolbox`,width:600,footer:(0,Z.jsx)(P,{onClick:t,children:`Close`}),children:d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length>1&&(0,Z.jsx)(o,{label:`Which toolbox`,children:(0,Z.jsx)(h,{label:`Which toolbox`,value:d,onChange:u,options:c.map(e=>({value:e.id,label:e.label}))})}),(0,Z.jsx)(at,{gatewayId:d,scope:e.scope,onDone:n},d)]}):(0,Z.jsxs)(b,{icon:`server`,title:`You don't have a toolbox yet`,compact:!0,children:[`Adding your first server sets one up. Then come back here and connect `,G(e.scope),`.`,(0,Z.jsx)(`span`,{className:`mt-4 block`,children:(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>ue(s(a,{connect:null,add:`server`})),children:`Add a server`})})]})}):null}var Et={done:null,label:``};function Dt({open:e,onClose:t}){let{reload:n}=K(),r=()=>{let e=!!Et.done;Et.done=null,t(),e&&n()},[i,a]=(0,X.useState)(`new`);return(0,Z.jsx)(v,{open:e,onClose:r,title:`Create a toolbox`,subtitle:`Set up a toolbox yourself, server by server.`,width:760,children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(h,{label:`How to add it`,value:i,onChange:a,options:[{value:`new`,label:`Start from nothing`},{value:`existing`,label:`Use a toolbox settings file I have`}]}),i===`new`?(0,Z.jsx)(Ot,{onClose:r}):(0,Z.jsx)(At,{onClose:r})]})})}function Ot({onClose:e}){let{nav:t,reload:n}=K(),r=V(),[a,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(`observe`),[m,g]=(0,X.useState)(`approve-writes`),[_,v]=(0,X.useState)(`approve`),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)([Qe()]),[C,T]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(Et.done),F=/^[a-z0-9][a-z0-9_-]{0,63}$/.test(a)?null:`Use lower-case letters, digits, dashes and underscores, starting with a letter or digit.`,I=x.map((e,t)=>it(e,x.filter((e,n)=>n!==t).map(e=>e.name.trim()))),L=!F&&I.every(e=>!e);return j?(0,Z.jsx)(kt,{result:j,label:Et.label,onClose:e,onOpen:()=>{e(),ue(i(t,`/`,{server:j.id}))}}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Name`,technical:`name`,help:`Also the name of its folder.`,error:k?F:null,children:(0,Z.jsx)(f,{value:a,onChange:s,mono:!0,placeholder:`work-tools`})}),(0,Z.jsx)(o,{label:`Label in the console`,optional:!0,children:(0,Z.jsx)(f,{value:c,onChange:u,placeholder:`Work tools`})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{children:[`How it starts `,(0,Z.jsx)(w,{term:`watchOnly`})]}),(0,Z.jsx)(we,{label:`How it starts`,value:d,onChange:p,options:[{value:`observe`,title:E.observe.label,body:`Recommended to begin with. Every call runs, and the log shows what would have been stopped.`},{value:`enforce`,title:E.enforce.label,body:E.enforce.explain}]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(Y,{children:[`Default stance `,(0,Z.jsx)(w,{term:`defaultStance`})]}),(0,Z.jsx)(we,{label:`Default stance`,columns:3,value:m,onChange:g,options:Object.keys(B).map(e=>({value:e,title:B[e].label,body:B[e].explain}))})]}),(0,Z.jsxs)(`section`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:(0,Z.jsxs)(Z.Fragment,{children:[`Tools nobody has labelled yet `,(0,Z.jsx)(w,{term:`unknownTools`})]}),children:(0,Z.jsx)(h,{label:`Tools nobody has labelled yet`,value:_,onChange:v,options:[{value:`approve`,label:`Ask me first`},{value:`deny`,label:`Block them`}]})}),(0,Z.jsx)(o,{label:`Folder for its files`,optional:!0,help:`A full path. By default, a folder named after it in your home folder.`,children:(0,Z.jsx)(f,{value:y,onChange:b,mono:!0,placeholder:`~/.hmcp/gateways/work-tools`})})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Y,{sub:`The servers this toolbox sits in front of. A toolbox needs at least one.`,children:[`Connected servers `,(0,Z.jsx)(w,{term:`connectedServer`})]}),x.map((e,t)=>(0,Z.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`p`,{className:`text-[14.5px] font-semibold`,children:[`Server `,t+1]}),x.length>1&&(0,Z.jsx)(N,{icon:`trash`,label:`Remove server ${t+1}`,size:34,onClick:()=>S(x.filter((e,n)=>n!==t))})]}),(0,Z.jsx)(Ze,{value:e,onChange:e=>S(x.map((n,r)=>r===t?e:n)),literalWarning:!0}),k&&I[t]&&(0,Z.jsx)(`p`,{role:`alert`,className:`mt-3 text-[13px] font-medium text-bad`,children:I[t]})]},t)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{icon:`plus`,onClick:()=>S([...x,Qe()]),children:`Add another server`})})]}),D&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`The toolbox wasn't created`,children:D}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:e,disabled:C,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:()=>{A(!0),L&&(T(!0),O(null),Re.createGateway({name:a,...c.trim()?{label:c.trim()}:{},mode:d,posture:m,onUnclassified:_,...y.trim()?{outDir:y.trim()}:{},upstreams:x.map(et)}).then(e=>{Et.done=e,Et.label=c.trim()||a,M(e),r.show(`ok`,`${c.trim()||a} was created.`)}).catch(e=>{let t=e.detail;O(W(e)+(Array.isArray(t)?` ${t.map(e=>q(U(e.message))).join(` `)}`:``))}).finally(()=>T(!1)))},loading:C,children:`Create toolbox`})]})]})}function kt({result:e,label:t,onClose:n,onOpen:r}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(b,{icon:`check`,title:`${t} is ready`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,icon:`arrow-right`,onClick:r,children:`Open this toolbox`}),(0,Z.jsx)(P,{variant:`ghost`,onClick:n,children:`Close`})]}),children:`Its protection settings start the way you chose. Connect your AI app to it next: one click, then restart the app once.`}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`Connect your AI app`}),(0,Z.jsx)(at,{gatewayId:e.id,onDone:()=>void 0})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[18px] bg-sunken/60 p-4 text-[13px]`,children:[(0,Z.jsxs)(`p`,{children:[`Settings file: `,(0,Z.jsx)(J,{children:e.configPath})]}),(0,Z.jsxs)(`p`,{children:[`Protection settings: `,(0,Z.jsx)(J,{children:e.policyPath})]})]}),e.warnings.map(e=>(0,Z.jsxs)(l,{tone:`warn`,children:[q(U(e)),` If one is a password or key, keep that file private.`]},e)),e.warning&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(e.warning))})]})}function At({onClose:e}){let{nav:t,reload:n}=K(),r=V(),[a,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=()=>{p(!0),h(null),_.addServer({kind:`gateway`,label:a.trim()||c.trim(),config_path:c.trim()}).then(o=>{n(),r.show(`ok`,`${a.trim()||`The toolbox`} was added to the console.`),e(),ue(i(t,`/`,{server:o.id}))}).catch(e=>h(W(e))).finally(()=>p(!1))};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`For a toolbox you already set up. The console reads its settings file and nothing else: it doesn't start the toolbox or change the file.`}),(0,Z.jsx)(o,{label:`Label in the console`,children:(0,Z.jsx)(f,{value:a,onChange:s,placeholder:`Work tools`})}),(0,Z.jsx)(o,{label:`Settings file`,technical:`gateway.yaml`,help:`The full path to its settings file.`,children:(0,Z.jsx)(f,{value:c,onChange:u,mono:!0,placeholder:`/Users/me/.hmcp/gateways/work/gateway.yaml`,onEnter:g})}),m&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:m}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:e,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`plus`,onClick:g,loading:d,disabled:!c.trim(),children:`Add toolbox`})]})]})}function jt(e){return ae(()=>Ue(e),[e],3e3)}function Mt(e){return e?e.externallyRunning?{label:`Run by an AI app`,tone:`ok`}:e.state===`running`?{label:`Running here`,tone:`ok`}:e.state===`starting`?{label:`Starting`,tone:`warn`}:e.state===`exited`?{label:e.exitCode===0?`Stopped`:`Stopped with an error`,tone:e.exitCode===0?`neutral`:`bad`}:{label:`Not running`,tone:`neutral`}:{label:`Checking`,tone:`neutral`}}function Nt({token:e,url:t,onClose:n}){return(0,Z.jsx)(le,{open:!!e,onClose:n,dismissable:!1,title:`Copy the password now`,description:`Copy this now; it won't be shown again. Your AI app needs it to connect.`,width:560,footer:(0,Z.jsx)(P,{variant:`primary`,onClick:n,children:`I've copied it`}),children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:e}),(0,Z.jsx)(Te,{text:e,label:`Copy password`})]}),(0,Z.jsxs)(`p`,{className:`text-muted`,children:[`In your AI app's server settings, add a header named `,(0,Z.jsx)(`code`,{className:`mono`,children:`Authorization`}),` with the value`,` `,(0,Z.jsx)(`code`,{className:`mono`,children:`Bearer`}),`, a space, then this password.`,t&&(0,Z.jsxs)(Z.Fragment,{children:[` `,`The server's address is `,(0,Z.jsx)(J,{children:t})]})]})]})})}function Pt({id:n,label:r}){let i=jt(n),{reload:s}=K(),u=V(),[d,f]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(`127.0.0.1`),[E,O]=(0,X.useState)([]),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)(!0),[N,F]=(0,X.useState)(null),I=(e,t=!1)=>{f(e),v(null),(e===`start`?qe(n,{...S===null?{}:{port:S},host:w,...E.length?{allowHosts:E}:{},...k.length?{allowOrigins:k}:{},requireToken:j,...t?{acknowledged:{loosens:!0}}:{}}).then(e=>e.token&&b({token:e.token,url:e.http?.url??null})):e===`stop`?Ae(n):Ge(n)).then(()=>{u.show(`ok`,e===`start`?`${r} started.`:e===`stop`?`${r} stopped.`:`${r} restarted.`),i.reload(),s()}).catch(n=>{e===`start`&&!t&&n instanceof m&&n.needsLoosenAck?F(Ce(n)):v(W(n))}).finally(()=>f(null))};if(i.error&&!i.data)return(0,Z.jsx)(l,{tone:`danger`,title:`Whether your toolbox is running could not be read`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:W(i.error)});let L=i.data;if(!L)return(0,Z.jsx)(c,{lines:4});let R=Mt(L),z=L.state===`running`||L.state===`starting`;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:`power`,size:20})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-[16px] font-semibold`,children:[r,` `,(0,Z.jsx)(e,{tone:R.tone,children:R.label})]}),(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:L.externallyRunning?`Started by an AI app on this computer.`:z&&L.startedAt?`Started ${x(L.startedAt)} by this console.`:L.state===`exited`?`It stopped${L.exitCode===null?L.signal?` (${L.signal})`:``:` with exit code ${L.exitCode}`}.`:`Nothing is running it at the moment.`})]}),z&&L.managed&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(P,{icon:`refresh`,onClick:()=>I(`restart`),loading:d===`restart`,disabled:!!d,children:`Restart toolbox`}),(0,Z.jsx)(P,{variant:`danger`,icon:`stop`,onClick:()=>I(`stop`),loading:d===`stop`,disabled:!!d,children:`Stop toolbox`})]})]}),_&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:_}),L.externallyRunning?(0,Z.jsx)(l,{tone:`info`,title:`An AI app runs this toolbox`,children:`The app starts the toolbox itself when it opens and stops it when it closes, so it can't be started or stopped here. To restart the toolbox, for example after changing its settings, quit and reopen the app.`}):z&&L.http?(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Y,{sub:`Add this as a server in your AI app's settings. The app then reaches every tool through your toolbox.`,children:`Web address`}),L.http.url&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-2xl bg-sunken p-3`,children:[(0,Z.jsx)(`code`,{className:`mono min-w-0 flex-1 text-[13px] break-all`,children:L.http.url}),(0,Z.jsx)(Te,{text:L.http.url,label:`Copy address`})]}),(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:L.http.tokenRequired?`A password is required. It was shown once when the toolbox started; restarting keeps the same one.`:`No password is required, so any program on this computer can reach it.`})]}):(0,Z.jsxs)(`section`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{sub:`Runs your toolbox from this console, so AI apps on this computer can reach it at a web address.`,children:`Start toolbox`}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(o,{label:`Port`,optional:!0,help:`Leave empty to use 7878.`,children:(0,Z.jsx)(a,{value:S,onChange:C,min:1,max:65535})}),(0,Z.jsx)(o,{label:`Address`,help:`This computer only. Your toolbox is never reachable from other computers.`,children:(0,Z.jsx)(h,{label:`Address`,size:`sm`,value:w,onChange:T,options:[{value:`127.0.0.1`,label:`127.0.0.1`},{value:`localhost`,label:`localhost`},{value:`::1`,label:`::1`}]})})]}),(0,Z.jsx)(p,{checked:j,onChange:M,label:`Require a password`,description:`Your AI app must send it to connect, so other programs on this computer can't use your toolbox's tools.`}),(0,Z.jsxs)(ye,{title:`More options`,children:[(0,Z.jsx)(o,{label:`Other names this computer is reached by`,optional:!0,help:`Only if your app uses a name other than the address above.`,children:(0,Z.jsx)(t,{value:E,onChange:O,placeholder:`my-machine.local`})}),(0,Z.jsx)(o,{label:`Web pages allowed to call it`,optional:!0,help:`Only for an AI app that runs in a browser. Scheme, host and port, such as http://localhost:3000.`,children:(0,Z.jsx)(t,{value:k,onChange:A,placeholder:`http://localhost:3000`})})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{variant:`primary`,icon:`play`,onClick:()=>I(`start`),loading:d===`start`,children:`Start toolbox`})})]}),(L.managed||L.log.length>0)&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(Y,{children:`What it has written`}),(0,Z.jsx)(ne,{lines:L.log,height:260,label:`${r} output`,empty:`Nothing yet.`})]}),(0,Z.jsx)(Nt,{token:y?.token??null,url:y?.url??null,onClose:()=>b(null)}),(0,Z.jsx)(D,{open:!!N,title:`Start a toolbox more can reach?`,onCancel:()=>F(null),confirmLabel:`Start toolbox anyway`,busy:d===`start`,consequences:N??[],onConfirm:()=>{F(null),I(`start`,!0)},children:`Besides AI apps on this computer, your toolbox will also answer the callers listed below.`})]})}function Ft({id:e,tab:t,onTab:n,onClose:r,replaceKeyFor:i,onOpened:a}){let{servers:o}=K(),s=o.find(t=>t.id===e);return(0,Z.jsx)(v,{open:!!e,onClose:r,title:s?`${s.label} settings`:`Toolbox settings`,subtitle:`Its connected servers, options, and whether it is running.`,width:820,children:e&&(0,Z.jsx)(It,{id:e,label:s?.label??e,tab:t,onTab:n,replaceKeyFor:i??null,onOpened:a},e)})}function It({id:e,label:t,tab:n,onTab:r,replaceKeyFor:i,onOpened:a}){let o=ae(()=>ze(e),[e]),s=jt(e),u=V(),{reload:f}=K(),p=Ee(e),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(!1),[E,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),j=o.data,M=!!j?.broken,N=M&&(n===`servers`||n===`options`)?`file`:n,F=(e,t,n=`Save a change that lets more through?`,r)=>{if(!j)return Promise.resolve(!1);let i=e=>{u.show(`ok`,t),g(Date.now()),v(e.restartNeeded!==!1),o.reload(),p.reload(),f()};return e(j.digest).then(e=>(i(e),!0)).catch(t=>t instanceof m&&t.needsLoosenAck?new Promise(a=>{O(null),C({title:n,body:r,reasons:Ce(t),run:()=>e(j.digest,{loosens:!0}).then(e=>{i(e),a(!0)})})}):(Se(t)?b(!0):u.show(`bad`,W(t)),!1))},I=s.data,L=!!I&&(I.externallyRunning||I.state===`running`||I.state===`starting`),R=p.data,z=!!R?.processes.some(e=>e.refusal),ee=L&&(R&&R.running?z||!R.applied&&(h===null||Date.now()-h>6e3):_||j&&!j.broken&&j.restartNeededFor.length>0),te=M?[{id:`file`,label:`Settings file`},{id:`run`,label:`Run`}]:[{id:`servers`,label:`Connected servers`,count:j?.config?.upstreams.length},{id:`options`,label:`Toolbox options`},{id:`run`,label:`Run`},{id:`file`,label:`Settings file`}];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[ee&&(0,Z.jsxs)(l,{tone:`warn`,role:`status`,title:`Restart needed for changes to take effect`,actions:I?.managed&&!I.externallyRunning?(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`refresh`,loading:k,onClick:()=>{A(!0),Ge(e).then(()=>{u.show(`ok`,`${t} restarted with the new settings.`),g(null),s.reload(),o.reload()}).catch(e=>u.show(`bad`,W(e))).finally(()=>A(!1))},children:`Restart toolbox`}):void 0,children:[z&&j&&j.restartNeededFor.length>0?`${j.restartNeededFor[0]}`:z?`The running toolbox can only take this change when it starts again. `:`The running toolbox hasn't picked up this change. `,z&&j&&j.restartNeededFor.length>0?``:I?.externallyRunning?`An AI app runs it: quit that app completely and open it again.`:`It still uses the old settings until it restarts.`]}),y&&(0,Z.jsx)(l,{tone:`warn`,title:`This changed since you opened it. Reload and try again.`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:()=>{b(!1),o.reload()},children:`Reload settings`})}),j?.broken&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,title:`This toolbox's settings file can't be loaded`,children:j.broken}),(0,Z.jsx)(ie,{items:te,value:N,onChange:r,label:`Toolbox settings`}),(0,Z.jsx)(`div`,{role:`tabpanel`,id:S(N),"aria-labelledby":d(N),children:N===`run`?(0,Z.jsx)(Pt,{id:e,label:t}):o.error&&!j?(0,Z.jsx)(l,{tone:`danger`,title:`The toolbox's settings file could not be read`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):j?N===`file`?(0,Z.jsx)(Ht,{id:e,file:j,write:F}):j.broken===null&&N===`servers`?(0,Z.jsx)(Lt,{id:e,file:j,write:F,live:R??null,running:L,onReload:()=>{g(Date.now()),o.reload(),p.reload(),f()},start:i?{kind:`replace-key`,server:i}:void 0,onStarted:a}):j.broken===null?(0,Z.jsx)(Bt,{id:e,file:j,write:F},j.digest):null:(0,Z.jsx)(c,{lines:6})}),(0,Z.jsx)(D,{open:!!x,title:x?.title??``,onCancel:()=>C(null),confirmLabel:`Save anyway`,busy:w,error:E,consequences:x?.reasons,onConfirm:()=>{x&&(T(!0),x.run().then(()=>C(null)).catch(e=>O(W(e))).finally(()=>T(!1)))},children:x?.body??`This change lets more through than before, so it needs your confirmation.`})]})}function Lt({id:t,file:n,write:r,live:a,running:o,onReload:s,start:c,onStarted:l}){let u=n.config.upstreams,{nav:d}=K(),f=V(),p=Ye(),[m,h]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(()=>{if(c?.kind===`by-hand`)return{original:null,draft:Qe()};let e=c?u.find(e=>e.name===c.server):void 0;return e&&c?.kind===`replace-key`&&he(e)?null:e?{original:e.name,draft:nt(e)}:null}),[x,S]=(0,X.useState)(()=>{let e=c?.kind===`replace-key`?u.find(e=>e.name===c.server):void 0;return e?he(e):null});(0,X.useEffect)(()=>{c&&l?.()},[]);let[C,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(null),A=Je(t);if(y){let e=u.map(e=>e.name).filter(e=>e!==y.original),i=it(y.draft,e);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(Y,{sub:y.original?`Values shown as kept secret stay as they are unless you type a new one.`:void 0,children:y.original?`Edit ${y.original}`:`Add a server`}),(0,Z.jsx)(Ze,{value:y.draft,onChange:e=>b({...y,draft:e}),nameLocked:!!y.original,secret:n.keptSecret,literalWarning:!0}),C&&i&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-faint pt-5`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:()=>b(null),disabled:E,children:`Cancel`}),(0,Z.jsx)(P,{variant:`primary`,icon:`check`,onClick:()=>{T(!0),!i&&(D(!0),zt(et(y.draft),n.keptSecret).then(e=>r((n,r)=>y.original?Me(t,y.original,e,n,r):Ke(t,e,n,r),y.original?`${e.name} was saved.`:`${e.name} was added.`,`Save this server?`)).then(e=>e&&b(null)).catch(e=>f.show(`bad`,W(e))).finally(()=>D(!1)))},loading:E,children:y.original?`Save server`:`Add server`})]})]})}if(_)return(0,Z.jsx)(rt,{gatewayId:t,fixUpstream:_,onCancel:()=>{$e(),v(null)},onDone:e=>{$e(),v(null),f.show(`ok`,`${e.upstreamName} was saved.`),s()}});if(m)return(0,Z.jsx)(rt,{gatewayId:t,onCancel:()=>{$e(),h(!1)},onDone:e=>{h(!1),f.show(`ok`,`${e.upstreamName} was added.`),s()}});let j=u.length===1;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`The servers this toolbox sits in front of. `,(0,Z.jsx)(w,{term:`connectedServer`})]}),(0,Z.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:null,draft:Qe()})},children:`Add one by hand`}),(0,Z.jsx)(P,{size:`sm`,variant:`primary`,icon:`plus`,onClick:()=>h(!0),children:`Add a server`})]})]}),(0,Z.jsx)(ke,{id:t,upstreams:u,digest:n.digest,onMoved:s}),(0,Z.jsx)(je,{secret:x,onClose:()=>S(null),onSaved:()=>{S(null),f.show(`ok`,`The new key is saved. The server is tried again with it.`),s()}}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map(n=>{let r=Pe(a,n.name),c=(A.data??[]).find(e=>e.server===n.name),l=r&&r.state===`connected`&&c?{...r,state:`failed`,problem:_e(n,c)}:r,u=o&&!!a?.running&&!!l&&(l.state===`failed`||l.state===`needs-sign-in`),f=!u&&Ne(n,p.data??null);return(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 rounded-[18px] border border-line p-3.5`,children:[(0,Z.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:n.transport===`http`?`external`:`server`,size:18})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`mono text-[14px] font-semibold`,children:n.name}),(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-[12.5px] text-soft`,children:n.transport===`http`?`Remote server · ${n.url}`:`Runs on this computer · ${[n.command,...n.args??[]].join(` `)}`}),(0,Z.jsx)(`span`,{className:`mt-1 block`,role:`status`,children:(0,Z.jsx)(Ve,{live:a,running:o,state:l})})]}),n.on_injection&&(0,Z.jsx)(e,{children:Fe[n.on_injection].label}),(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`edit`,onClick:()=>{T(!1),b({original:n.name,draft:nt(n)})},children:`Edit`}),(0,Z.jsx)(N,{icon:`trash`,label:j?`${n.name} is the only server and can't be removed`:`Remove ${n.name}`,size:36,disabled:j,onClick:()=>k(n.name)})]}),u&&l&&(0,Z.jsx)(Le,{gatewayId:t,upstream:n,state:l,onEdit:e=>{if(e===`choose-folder`||e===`replace-key`||e===`sign-in`){let t=l.problem?.detail?.path;v({upstream:n,action:e,...t?{path:t}:{}})}else T(!1),b({original:n.name,draft:nt(n)})},onFixed:s,onAllowAddress:()=>ue(i(d,`/protection`,{server:t}))}),f&&(0,Z.jsx)(Le,{gatewayId:t,upstream:n,state:{name:n.name,state:`needs-sign-in`,since:``,attempts:0,tool_count:0},onEdit:e=>e===`sign-in`?v({upstream:n,action:e}):b({original:n.name,draft:nt(n)}),onFixed:s,onAllowAddress:()=>void 0})]},n.name)})}),j&&(0,Z.jsx)(`p`,{className:`text-[13px] text-soft`,children:`A toolbox needs at least one server, so the last one can't be removed. Add another first, or remove the whole toolbox from the console.`}),(0,Z.jsx)(le,{open:!!O,onClose:()=>k(null),tone:`danger`,title:`Remove ${O}?`,description:Rt(u.find(e=>e.name===O)),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,onClick:()=>k(null),disabled:E,children:`Keep server`}),(0,Z.jsx)(P,{variant:`danger`,loading:E,onClick:()=>{let e=O;D(!0),r(n=>Be(t,e,n),`${e} was removed.`).then(()=>k(null)).finally(()=>D(!1))},children:`Remove server`})]})})]})}function Rt(e){let t=[...Object.values(e?.env??{}),...Object.values(e?.headers??{}),e?.oauth].map(e=>e&&typeof e==`object`&&typeof e.secret==`string`?e.secret:null).filter(e=>e!==null),n=[...new Set(t)];return`Your AI app loses this server's tools, and the protection rules made for them are removed too.`+(n.length>0?` Its locked ${n.length===1?`key`:`keys`} (${n.join(`, `)}) ${n.length===1?`stays`:`stay`} saved; remove ${n.length===1?`it`:`them`} under Settings & help, Locked keys, if you no longer need ${n.length===1?`it`:`them`}.`:``)}async function zt(e,t){let r=async r=>{if(!r)return r;let i={};for(let[a,o]of Object.entries(r))if(typeof o==`string`&&o!==``&&o!==t&&!/\$\{[^}]*\}/.test(o)&&pe(a)){let t=/^(Bearer|Basic|Token) /i.exec(o)?.[0],r=t?o.slice(t.length):o,s=await n.createSecret({label:`${e.name} ${a}`,value:r});i[a]=t?{secret:s.name,prefix:t}:{secret:s.name}}else i[a]=o;return i},i=await r(e.env),a=await r(e.headers);return{...e,...i?{env:i}:{},...a?{headers:a}:{}}}function $({title:e,help:t,technical:n,children:r,onSave:i,dirty:a,busy:o,onReset:s}){return(0,Z.jsxs)(`div`,{className:`grid gap-3 border-b border-faint py-5 first:pt-0 last:border-b-0 md:grid-cols-[1fr_minmax(0,300px)]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-[14.5px] font-semibold`,children:[e,` `,(0,Z.jsx)(`code`,{className:`mono text-[11.5px] font-normal text-soft`,children:n})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-[13px] text-soft`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[r,(i||s)&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[s&&(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:s,disabled:o,children:`Use the default`}),i&&(0,Z.jsx)(P,{size:`sm`,variant:`primary`,onClick:i,disabled:!a,loading:o,children:`Save setting`})]})]})]})}function Bt({id:e,file:t,write:n}){let r=t.config,i=(t.text??``).match(/^(\w+):/gm)?.map(e=>e.slice(0,-1))??[],[o,s]=(0,X.useState)(null),c=(t,r,i,a)=>(s(t),n((n,i)=>Ie(e,t,r,n,i),i,a).finally(()=>s(null))),[l,u]=(0,X.useState)(r.name),[d,m]=(0,X.useState)(r.connect_timeout_ms/1e3),[h,_]=(0,X.useState)(r.on_injection),[v,y]=(0,X.useState)(Object.entries(r.injection_overrides)),[b,x]=(0,X.useState)(r.max_tool_name_length??null),S=r.notify===void 0?`auto`:r.notify?`on`:`off`,C=Object.fromEntries(v.filter(([e])=>e.trim()).map(([e,t])=>[e.trim(),t]));return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)($,{title:`Name`,technical:`name`,help:(0,Z.jsx)(Z.Fragment,{children:`Shown in the activity log and to your AI app. Renaming moves the toolbox to a new identity: tools you turned off, pre-approvals and reviewed tool changes are stored under the old name and stop applying, so it counts as loosening.`}),dirty:l.trim()!==r.name&&!!l.trim(),busy:o===`name`,onSave:()=>c(`name`,l.trim(),`The toolbox was renamed.`,`Rename this toolbox?`),children:(0,Z.jsx)(f,{value:l,onChange:u,mono:!0,"aria-label":`Toolbox name`})}),(0,Z.jsx)($,{title:`Time to wait for each server to start`,technical:`connect_timeout_ms`,help:`Your toolbox connects every server before serving any tool. A slow server gets this long before the toolbox gives up and says which one failed.`,dirty:d!==null&&d*1e3!==r.connect_timeout_ms,busy:o===`connect_timeout_ms`,onSave:()=>c(`connect_timeout_ms`,Math.round(d*1e3),`The start-up wait was saved.`),onReset:i.includes(`connect_timeout_ms`)?()=>c(`connect_timeout_ms`,null,`The start-up wait is back to 20 seconds.`):void 0,children:(0,Z.jsx)(a,{value:d,onChange:m,min:1,unit:`seconds`,"aria-label":`Seconds to wait`})}),(0,Z.jsx)($,{title:(0,Z.jsxs)(Z.Fragment,{children:[`Hidden instructions in tool descriptions `,(0,Z.jsx)(w,{term:`HMCP005`})]}),technical:`on_injection`,help:Fe[h].explain+` Each server can have its own setting too.`,dirty:h!==r.on_injection,busy:o===`on_injection`,onSave:()=>c(`on_injection`,h,`Hidden-instruction handling was saved.`,`Handle hidden instructions less strictly?`),children:(0,Z.jsx)(I,{value:h,onChange:_,"aria-label":`Hidden instructions`,options:[`strip`,`deny`,`annotate`].map(e=>({value:e,label:Fe[e].label}))})}),(0,Z.jsx)($,{title:`Descriptions you checked`,technical:`injection_overrides`,help:`For a tool whose description was flagged by mistake. Name the tool as your AI app sees it, such as files__read_file.`,dirty:JSON.stringify(C)!==JSON.stringify(r.injection_overrides),busy:o===`injection_overrides`,onSave:()=>c(`injection_overrides`,C,`Checked descriptions were saved.`,`Trust these descriptions?`),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v.map(([e,t],n)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(f,{value:e,onChange:e=>y(v.map((t,r)=>r===n?[e,t[1]]:t)),mono:!0,"aria-label":`Tool ${n+1}`,placeholder:`files__read_file`}),(0,Z.jsx)(N,{icon:`trash`,label:`Remove ${e||`row ${n+1}`}`,size:34,onClick:()=>y(v.filter((e,t)=>t!==n))})]},n)).flatMap((e,t)=>[e,(0,Z.jsx)(I,{value:v[t][1],onChange:e=>y(v.map((n,r)=>r===t?[n[0],e]:n)),"aria-label":`How to treat tool ${t+1}`,options:[`accept`,`annotate`,`strip`,`deny`].map(e=>({value:e,label:Fe[e].label}))},`m${t}`)]),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`plus`,onClick:()=>y([...v,[``,`accept`]]),children:`Add a tool`})})]})}),(0,Z.jsx)($,{title:`Put the server's name in front of each tool`,technical:`namespace`,help:`Tools are shown as server__tool, so two servers can't offer look-alike tools. Turning it off renames every tool, so rules and switches naming them stop applying.`,children:(0,Z.jsx)(p,{checked:r.namespace,disabled:o===`namespace`,onChange:e=>c(`namespace`,e,e?`Tool names now include the server.`:`Tool names no longer include the server.`,`Rename every tool?`),label:r.namespace?`On`:`Off`})}),(0,Z.jsx)($,{title:`Apply protection changes without a restart`,technical:`policy_reload`,help:`When the protection settings file changes, the running toolbox picks it up straight away. A file with a mistake is ignored and the old settings stay in force.`,children:(0,Z.jsx)(p,{checked:r.policy_reload,disabled:o===`policy_reload`,onChange:e=>c(`policy_reload`,e,e?`Protection changes now apply straight away.`:`Protection changes now wait for a restart.`),label:r.policy_reload?`On`:`Off`})}),(0,Z.jsx)($,{title:`Longest tool name`,technical:`max_tool_name_length`,help:`AI services refuse a request if any tool name is too long, which breaks every tool at once. A tool with a longer name is held back instead. Empty means no limit.`,dirty:(b??void 0)!==r.max_tool_name_length,busy:o===`max_tool_name_length`,onSave:()=>c(`max_tool_name_length`,b,b?`The name limit was saved.`:`The name limit was removed.`),children:(0,Z.jsx)(a,{value:b,onChange:x,min:1,unit:`letters`,"aria-label":`Longest tool name`})}),(0,Z.jsx)($,{title:`Desktop notifications`,technical:`notify`,help:`Show a notification on this computer when a call waits for you. Automatic means on when an app runs the toolbox on this computer, off when it serves over a web address.`,children:(0,Z.jsx)(I,{value:S,"aria-label":`Desktop notifications`,onChange:e=>c(`notify`,e===`auto`?null:e===`on`,`Notification setting saved.`),options:[{value:`auto`,label:`Automatic`},{value:`on`,label:`On`},{value:`off`,label:`Off`}]})}),(0,Z.jsxs)(`div`,{className:`mt-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-[14.5px] font-semibold`,children:[(0,Z.jsx)(g,{name:`lock`,size:17}),` Settings the console can't change`]}),(0,Z.jsx)(`p`,{className:`mt-1 text-[13px] text-soft`,children:`These decide what the console itself may do. If the console could change them, it could give itself permission, so they can only be changed by editing the file outside the console.`}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-[13.5px] sm:grid-cols-2`,children:[(0,Z.jsx)(Vt,{term:`Console may change protection rules`,technical:`policy_writes`,on:t.guarded.policy_writes}),(0,Z.jsx)(Vt,{term:`Console may reverse an existing decision`,technical:`policy_overrides`,on:t.guarded.policy_overrides})]})]})]})}function Vt({term:t,technical:n,on:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-2xl bg-surface px-3 py-2.5`,children:[(0,Z.jsxs)(`dt`,{children:[t,(0,Z.jsx)(`code`,{className:`mono block text-[11.5px] text-soft`,children:n})]}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(e,{tone:r?`ok`:`neutral`,children:r?`Allowed`:`Not allowed`})})]})}function Ht({id:e,file:t,write:n}){let[i,a]=(0,X.useState)(t.text??``),[o,s]=(0,X.useState)(null),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null);if((0,X.useEffect)(()=>{a(t.text??``),s(null)},[t.digest]),t.text===null)return(0,Z.jsxs)(b,{icon:`file`,title:`This file has to be fixed in a text editor`,children:[`It isn't readable as a settings file at all, so the console can't show it. Open it in a text editor, fix it, then reopen these settings.`,(0,Z.jsx)(`span`,{className:`mt-2 block`,children:(0,Z.jsx)(J,{children:t.path})})]});let h=()=>{u(!0),m(null),De(e,i).then(s).catch(e=>m(W(e))).finally(()=>u(!1))},g=()=>{f(!0),n((t,n)=>Oe(e,i,t,n),t.broken?`The settings file was repaired.`:`The settings file was saved.`,t.broken?`Save the repaired settings file?`:`Save the edited settings file?`,t.broken?`This file couldn't be loaded, so the console can't compare what your fix changes. Check it carefully before saving.`:void 0).finally(()=>f(!1))},_=i!==t.text,v=o&&_;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[`The toolbox's whole settings file, for changes the forms don't cover. Keys in your locked keys appear only by name. A key still written out in the file shows as `,(0,Z.jsx)(`code`,{className:`mono`,children:`[kept secret]`}),`; leave that marker and the stored value is kept. The protection-settings entry and the two settings the console can't change are refused here.`,(0,Z.jsx)(`span`,{className:`mt-1 block`,children:(0,Z.jsx)(J,{children:t.path})})]}),(0,Z.jsx)(ee,{value:i,onChange:e=>{a(e),s(null)},label:`Settings file`,rows:18,error:o&&!o.valid?o.error:null}),p&&(0,Z.jsx)(l,{tone:`danger`,role:`alert`,children:p}),v&&o.valid&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{children:`What changes`}),(0,Z.jsx)(j,{before:t.text??``,after:i,label:`Changes to the settings file`}),t.broken?(0,Z.jsx)(l,{tone:`warn`,title:`Saving needs your confirmation`,children:`This file couldn't be loaded, so the console can't compare what your fix changes.`}):o.loosens.length>0&&(0,Z.jsx)(l,{tone:`warn`,title:`This lets more through`,children:(0,Z.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:o.loosens.map(e=>(0,Z.jsx)(`li`,{children:e},e))})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Z.jsx)(P,{variant:`ghost`,onClick:()=>{a(t.text??``),s(null)},disabled:!_,children:`Undo my edits`}),v&&o.valid?(0,Z.jsx)(P,{variant:`primary`,icon:`check`,onClick:g,loading:d,children:t.broken?`Save repaired file`:`Save settings file`}):(0,Z.jsx)(P,{variant:`primary`,onClick:h,loading:c,disabled:!_,children:`Check changes`})]}),(0,Z.jsxs)(`p`,{className:`text-[12.5px] text-soft`,children:[`Changes to servers reach a running toolbox straight away; anything else applies the next time it starts. `,r(i.split(`
|
|
2
|
-
`).length,`line`),`.`]})]})}var Ut={ok:`bg-ok`,warn:`bg-warn`,bad:`bg-bad`,neutral:`bg-soft`};function Wt(){let{nav:e,servers:t,serverId:n,reload:r}=K(),i=V(),a=e.query,o=(...t)=>ce(s(e,Object.fromEntries(t.map(e=>[e,null])))),c=a.get(`manage`),l=a.get(`tab`)??`servers`,u=t.filter(e=>e.ok),d=u.filter(e=>e.running).length,f=u.filter(e=>e.enforcement===`enforce`).length,p=u.reduce((e,t)=>e+(t.upstreams?.length??0),0),m=u.reduce((e,t)=>e+(t.toolCount??0),0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(k,{title:`Connections`,subtitle:`The toolboxes that protect your AI apps, and the apps and servers they connect.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{href:s(e,{add:`server`}),variant:`primary`,icon:`plus`,children:`Add a server`}),(0,Z.jsx)(T,{href:s(e,{connect:`1`}),icon:`plug`,children:`Connect an app`}),(0,Z.jsx)(T,{href:s(e,{add:`1`}),variant:`ghost`,icon:`shield`,children:`Create a toolbox`})]})}),t.length===0?(0,Z.jsx)(qt,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 lg:gap-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4 lg:gap-5`,children:[(0,Z.jsx)(te,{tone:`hero`,title:`Toolboxes`,value:u.length,sub:u.length?`${f} protecting · ${u.length-f} watch-only`:`None can be loaded`}),(0,Z.jsx)(te,{title:`Running now`,value:d,sub:d===u.length?`All of them`:`${u.length-d} not running`}),(0,Z.jsx)(te,{title:`Connected servers`,value:p,sub:`The servers your toolboxes hold`}),(0,Z.jsx)(te,{title:`Tools`,value:de(m),sub:`Offered to your AI apps`})]}),(0,Z.jsxs)(`section`,{"aria-labelledby":`gateways-h`,children:[(0,Z.jsx)(`h2`,{id:`gateways-h`,className:`sr-only`,children:`Toolboxes`}),(0,Z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 2xl:grid-cols-3 lg:gap-5`,children:t.map(e=>e.ok?(0,Z.jsx)(Jt,{server:e},e.id):(0,Z.jsx)(Yt,{server:e},e.id))})]}),(0,Z.jsx)(Qt,{servers:t})]}),(0,Z.jsx)(lt,{open:a.get(`connect`)===`1`,onClose:()=>o(`connect`)}),(0,Z.jsx)(Dt,{open:a.get(`add`)===`1`,onClose:()=>o(`add`)}),(0,Z.jsx)(Kt,{open:a.get(`add`)===`server`,gatewayId:Gt(a.get(`gateway`),n,u),onClose:()=>o(`add`,`gateway`),onDone:(e,t)=>{o(`add`,`gateway`),i.show(`ok`,t?`${e} was added, and your toolbox was set up.`:`${e} was added.`),r()}}),(0,Z.jsx)(Ft,{id:c&&t.some(e=>e.id===c)?c:null,tab:l,onTab:t=>ce(s(e,{tab:t})),onClose:()=>o(`manage`,`tab`,`key`),replaceKeyFor:a.get(`key`),onOpened:()=>o(`key`)})]})}function Gt(e,t,n){return e&&n.some(t=>t.id===e)?e:t&&n.some(e=>e.id===t)?t:n[0]?.id??null}function Kt({open:e,gatewayId:t,onClose:n,onDone:r}){let{servers:i}=K(),a=i.find(e=>e.id===t)?.label;return(0,Z.jsx)(v,{open:e,onClose:()=>{$e(),n()},title:`Add a server`,subtitle:a?`It joins ${a}. You test it before anything is saved.`:`You test it before anything is saved.`,width:920,children:e&&(0,Z.jsx)(rt,{gatewayId:t,onCancel:n,onDone:e=>r(e.upstreamName,e.created)})})}function qt(){let{nav:e}=K();return(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.2fr_1fr] lg:gap-5`,children:[(0,Z.jsxs)(re,{tone:`hero`,className:`flex flex-col p-7 md:p-8`,children:[(0,Z.jsx)(`span`,{className:`grid h-12 w-12 place-items-center rounded-full bg-white/15`,children:(0,Z.jsx)(g,{name:`shield-check`,size:24})}),(0,Z.jsx)(`h2`,{className:`display mt-5 text-[30px] md:text-[36px]`,children:`Give your AI app its first tools`}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-lg text-[15px] text-on-hero-soft`,children:`Your toolbox sits between your AI app and the servers that give it tools, and decides what runs, what waits for you, and what is blocked. The getting-started guide walks you through it in a few minutes.`}),(0,Z.jsxs)(`div`,{className:`mt-7 flex flex-wrap gap-2.5`,children:[(0,Z.jsx)(T,{href:`/start`,variant:`on-hero`,icon:`arrow-right`,children:`Start the guide`}),(0,Z.jsx)(T,{href:s(e,{add:`server`}),variant:`on-hero`,icon:`plus`,className:`!bg-transparent !text-white ring-1 ring-white/50`,children:`Add a server`})]}),(0,Z.jsxs)(`p`,{className:`mt-4 text-[13px] text-on-hero-soft`,children:[`Already use servers in an app?`,` `,(0,Z.jsx)(`a`,{href:s(e,{connect:`1`}),onClick:y,className:`font-semibold text-white underline underline-offset-2`,children:`Connect that app`}),` `,`and they move behind your toolbox.`]})]}),(0,Z.jsx)(re,{title:`How it works`,children:(0,Z.jsx)(`ol`,{className:`flex flex-col gap-4`,children:[[`Add a server`,`Pick one from the list, such as Files on this computer or GitHub. You're walked through it, and you test it before anything is saved.`],[`Connect your AI app`,`One click adds your toolbox to Claude Desktop, Claude Code, Cursor, VS Code or Windsurf. Restart the app once.`],[`Decide what needs you`,`Tools that only look run freely. Changes wait for you to say yes, and you can adjust that any time.`]].map(([e,t],n)=>(0,Z.jsxs)(`li`,{className:`flex gap-3.5`,children:[(0,Z.jsx)(`span`,{className:`tnum grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-[14px] font-bold text-ok`,children:n+1}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-[15px] font-medium`,children:e}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:t})]})]},e))})})]})}function Jt({server:t}){let{nav:n,reload:r}=K(),a=V(),o=ae(()=>Ue(t.id),[t.id],15e3),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=o.data,m=p?Mt(p):t.running?{label:`Running`,tone:`ok`}:{label:`Not running`,tone:`neutral`},h=E[t.enforcement??`enforce`],_=t.upstreams??[],v=!!p?.managed&&(p.state===`running`||p.state===`starting`),b=e=>s(n,{manage:t.id,tab:e}),x=Ee(t.id),S=Je(t.id),C=be(x.data?.upstreams??[],!!x.data?.running,S.data??[]);return(0,Z.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-5 p-6`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:`shield`,size:20})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label})}),(0,Z.jsx)(N,{icon:`trash`,label:`Remove ${t.label} from the console`,size:36,onClick:()=>f(!0)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(e,{tone:m.tone,icon:`power`,children:m.label}),(0,Z.jsx)(e,{tone:h.tone,icon:t.enforcement===`observe`?`eye`:`shield-check`,title:h.explain,children:h.label}),t.posture&&t.posture in B&&(0,Z.jsx)(e,{children:B[t.posture].label})]}),(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Z.jsx)(`dt`,{className:`text-[12.5px] text-soft`,children:`Tools`}),(0,Z.jsx)(`dd`,{className:`display tnum text-[28px]`,children:t.toolCount??`–`})]}),(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-sunken/60 px-4 py-3`,children:[(0,Z.jsxs)(`dt`,{className:`text-[12.5px] text-soft`,children:[`Connected servers `,(0,Z.jsx)(w,{term:`connectedServer`})]}),(0,Z.jsx)(`dd`,{className:`display tnum text-[28px]`,children:_.length})]})]}),_.length>0&&(0,Z.jsx)(`ul`,{className:`-mt-2 flex flex-wrap gap-1.5`,"aria-label":`Its servers`,children:_.map(e=>{let t=x.data?.running?Pe(x.data,e):null,n=t?.state===`connected`&&(S.data??[]).some(t=>t.server===e),r=n?`bad`:t?ve[t.state].tone:null;return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-full bg-sunken px-2.5 py-0.5 text-[12px]`,children:[r&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:H(`h-2 w-2 rounded-full`,Ut[r])}),(0,Z.jsx)(`code`,{className:`mono`,children:e}),n?(0,Z.jsx)(`span`,{className:`text-muted`,children:`· calls failing`}):t&&t.state!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`· `,ve[t.state].label.toLowerCase()]}),t&&!n&&(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`: `,ve[t.state].label]})]},e)})}),C&&(0,Z.jsxs)(`p`,{className:H(`-mt-2 flex flex-wrap items-center gap-x-2 text-[13px] font-medium`,C.tone===`bad`?`text-bad`:C.tone===`warn`?`text-warn`:`text-ok`),children:[C.text,C.fix&&(0,Z.jsxs)(`a`,{href:b(`servers`),onClick:y,className:`underline underline-offset-2`,children:[`Fix `,C.fix]})]}),t.toolCount===null&&(0,Z.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:`Tools are counted once the toolbox has run.`}),t.tenantError&&(0,Z.jsx)(l,{tone:`warn`,children:q(U(t.tenantError))}),p?.externallyRunning&&(0,Z.jsx)(`p`,{className:`-mt-2 text-[12.5px] text-soft`,children:`An AI app runs this toolbox. Restarting the app restarts it.`}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Z.jsx)(T,{href:i(n,`/`,{server:t.id}),variant:`primary`,size:`sm`,iconRight:`arrow-right`,children:`Open`}),(0,Z.jsx)(T,{href:b(`servers`),size:`sm`,icon:`settings`,children:`Settings`}),v?(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`stop`,loading:c,onClick:()=>{u(!0),Ae(t.id).then(()=>{a.show(`ok`,`${t.label} stopped.`),o.reload(),r()}).catch(e=>a.show(`bad`,W(e))).finally(()=>u(!1))},children:`Stop toolbox`}):!p?.externallyRunning&&(0,Z.jsx)(T,{href:b(`run`),size:`sm`,variant:`ghost`,icon:`play`,children:`Start toolbox`})]}),(0,Z.jsx)(Xt,{server:d?t:null,onClose:()=>f(!1)})]})}function Yt({server:t}){let{nav:n}=K(),[r,i]=(0,X.useState)(!1);return(0,Z.jsxs)(`article`,{className:`card flex min-w-0 flex-col gap-4 border-[1.5px] border-bad/40 p-6`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`span`,{className:`grid h-11 w-11 shrink-0 place-items-center rounded-full bg-bad-tint text-bad`,children:(0,Z.jsx)(g,{name:`warning`,size:20})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`h3`,{className:`truncate text-[19px] leading-tight font-medium tracking-[-0.02em]`,title:t.id,children:t.label})}),(0,Z.jsx)(e,{tone:`bad`,children:`Can't be loaded`})]}),(0,Z.jsx)(`p`,{className:`text-[14px] text-muted`,children:`The console couldn't read this toolbox, so it can't show or protect anything for it.`}),(0,Z.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13px] break-words text-muted`,children:q(U(t.error??`No reason was given.`))}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Z.jsx)(T,{href:s(n,{manage:t.id,tab:`file`}),size:`sm`,variant:`primary`,icon:`edit`,children:`Fix toolbox settings file`}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,icon:`trash`,onClick:()=>i(!0),children:`Remove from console`})]}),(0,Z.jsx)(Xt,{server:r?t:null,onClose:()=>i(!1)})]})}function Xt({server:e,onClose:t}){let{reload:n}=K(),r=V(),[i,a]=(0,X.useState)(!1);return e?(0,Z.jsx)(le,{open:!0,onClose:t,tone:`danger`,dismissable:!i,title:`Remove ${e.label} from the console?`,description:`The console stops showing it. Nothing is deleted.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(P,{variant:`secondary`,onClick:t,disabled:i,children:`Keep it`}),(0,Z.jsx)(P,{variant:`danger`,loading:i,onClick:()=>{a(!0),_.removeServer(e.id).then(()=>{r.show(`ok`,`${e.label} was removed from the console.`),t(),n()}).catch(e=>r.show(`bad`,W(e))).finally(()=>a(!1))},children:`Remove from console`})]}),children:(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[14px] text-muted`,children:[(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`Its files on this computer are kept: the toolbox's settings file, its protection settings, waiting calls and the activity log.`]}),(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`power`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`If this console was running it, it is stopped. If an AI app runs it, it keeps running and keeps protecting that app.`]}),(0,Z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Z.jsx)(g,{name:`plus`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`You can add it back later with Create a toolbox, using its settings file.`]})]})}):null}var Zt={"connect.apply":`App connected`,"connect.revert":`Connection undone`,"connect.create":`Toolbox created`,"gateway.setting":`Toolbox option changed`,"gateway.upstream.add":`Server added`,"gateway.upstream.update":`Server changed`,"gateway.upstream.remove":`Server removed`,"gateway.file":`Toolbox settings file edited`,"gateway.process.start":`Toolbox started`,"gateway.process.stop":`Toolbox stopped`,"policy.reload":`Protection settings reloaded`,"exposure.disable":`Tool turned off`,"exposure.enable":`Tool turned back on`,"approval.decide":`Call answered`,"standing_grant.create":`Pre-approval given`,"standing_grant.revoke":`Pre-approval withdrawn`};function Qt({servers:e}){let{nav:t}=K(),[n,r]=(0,X.useState)(`noteworthy`),a=e.filter(e=>e.ok).map(e=>e.id).join(`,`),o=ae(()=>a?_.combinedAudit({servers:a,limit:`12`,...n===`noteworthy`?{noteworthy:`1`}:{}}):Promise.resolve(null),[a,n],3e4),s=t=>e.find(e=>e.id===t)?.label??t??`A toolbox`,u=o.data;return(0,Z.jsx)(re,{title:`Recent activity across toolboxes`,actions:(0,Z.jsx)(h,{label:`Which activity`,size:`sm`,value:n,onChange:r,options:[{value:`noteworthy`,label:`Needs a look`},{value:`all`,label:`All`}]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u?.sharedPaths.map(e=>(0,Z.jsx)(l,{tone:`info`,title:`${e.servers.map(s).join(` and `)} share one activity log`,children:`That's how they were set up, and it's safe: the tamper check covers them together. Give each toolbox its own log only if you want to check them apart.`},e.path)),u?.broken.map(e=>(0,Z.jsxs)(l,{tone:`info`,children:[s(e.id),`'s activity couldn't be read: `,q(U(e.error))]},e.id)),o.error&&!u?(0,Z.jsx)(l,{tone:`danger`,title:`Activity could not be loaded`,actions:(0,Z.jsx)(P,{size:`sm`,icon:`refresh`,onClick:o.reload,children:`Try again`}),children:W(o.error)}):o.loading&&!u?(0,Z.jsx)(c,{lines:5,height:18}):!u||u.records.length===0?(0,Z.jsx)(b,{icon:`activity`,title:n===`noteworthy`?`Nothing needs a look`:`No activity yet`,compact:!0,children:n===`noteworthy`?`No blocked, held or failed calls lately.`:`Calls appear here once an AI app uses a toolbox's tools.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col`,children:u.records.map(e=>(0,Z.jsx)($t,{record:e,gateway:s(e.serverId),href:i(t,`/activity`,{server:e.serverId??``,seq:String(e.seq)})},`${e.serverId}-${e.seq}-${e.id}`))})]})})}function $t({record:t,gateway:n,href:r}){let i=t.tool.startsWith(`(`)||Zt[t.rule_id]!==void 0,a=i?Zt[t.rule_id]??`Console change`:We(t.tool).label;return(0,Z.jsx)(`li`,{className:`border-b border-faint last:border-b-0`,children:(0,Z.jsxs)(`a`,{href:r,onClick:y,className:`-mx-2 flex items-center gap-3 rounded-2xl px-2 py-2.5 transition-colors hover:bg-faint`,children:[(0,Z.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Z.jsx)(g,{name:i?`settings`:`tool`,size:17})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-[14px] font-medium`,title:i?void 0:t.tool,children:a}),(0,Z.jsxs)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:[n,` · `,x(t.ts)]})]}),!i&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:t.observe?(0,Z.jsxs)(e,{tone:`neutral`,title:`Watch-only: it ran anyway`,children:[`Would be: `,z(t.decision)]}):(0,Z.jsx)(A,{decision:t.decision})})]})})}export{Wt as ConnectionsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,G as n,H as r,It as i,Mt as a,O as o,Ot as s,Pt as c,_ as l,_t as u,ht as d,kt as f,s as p,vt as m,x as h,xt as g,yt as _}from"./kit-DQ7Oxf5n.js";import{Cn as v,Dn as y,En as b,Mn as x,Nn as S,On as ee,Pn as C,Sn as te,Tn as ne,X as w,Z as T,_n as E,at as D,bn as re,gn as ie,hn as O,it as ae,jn as oe,kn as se,ot as k,st as A,vn as j,wn as M,xn as ce,yn as le}from"./index-Khp0l1zp.js";import{i as ue,r as N,t as P}from"./AttachApp-0zRSPgSY.js";var F=i(),I=f(),L=[[`Runs freely`,`fill-allow`],[`Asks you first`,`fill-approve`],[`Blocked`,`fill-deny`]],R=[`Files`,`GitHub`,`Notion`,`and more…`];function z(){let e=(0,F.useId)(),t=`${e}-t`,n=`${e}-d`,r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`title`,{id:t,children:`How hardened-mcp fits in`}),(0,I.jsx)(`desc`,{id:n,children:`Your AI app talks to hardened-mcp, the toolbox. The toolbox checks every action: it runs freely, asks you first, or is blocked. Then it passes allowed actions on to your servers, such as files, GitHub and Notion.`})]});return(0,I.jsxs)(`figure`,{className:`m-0 text-ink`,children:[(0,I.jsxs)(`svg`,{viewBox:`0 0 760 236`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`hidden h-auto w-full sm:block`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:8,y:58}),(0,I.jsx)(V,{x1:190,y1:118,x2:250,y2:118,id:e}),(0,I.jsx)(W,{x:258,y:20}),(0,I.jsx)(V,{x1:508,y1:118,x2:568,y2:118,id:e}),(0,I.jsx)(G,{x:576,y:34})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 320 560`,role:`img`,"aria-labelledby":`${t} ${n}`,className:`mx-auto block h-auto w-full max-w-[320px] sm:hidden`,children:[r,(0,I.jsx)(B,{id:e}),(0,I.jsx)(U,{x:68,y:4}),(0,I.jsx)(V,{x1:160,y1:126,x2:160,y2:160,id:e}),(0,I.jsx)(W,{x:35,y:168}),(0,I.jsx)(V,{x1:160,y1:364,x2:160,y2:398,id:e}),(0,I.jsx)(G,{x:68,y:406,compact:!0})]})]})}function B({id:e}){return(0,I.jsx)(`defs`,{children:(0,I.jsx)(`marker`,{id:`${e}-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,I.jsx)(`path`,{d:`M1 1 9 5 1 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})}function V({x1:e,y1:t,x2:n,y2:r,id:i}){return(0,I.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,className:`stroke-soft text-soft`,strokeWidth:`2`,strokeDasharray:`5 5`,markerEnd:`url(#${i}-arrow)`})}function H({x:e,y:t,children:n,size:r=15,weight:i=600,className:a=`fill-ink`,anchor:o=`middle`}){return(0,I.jsx)(`text`,{x:e,y:t,textAnchor:o,fontSize:r,fontWeight:i,className:a,style:{fontFamily:`var(--font-sans)`},children:n})}function U({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`184`,height:`120`,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsxs)(`g`,{transform:`translate(76 18)`,className:`text-muted`,children:[(0,I.jsx)(`path`,{d:`M4 4h24a4 4 0 0 1 4 4v13a4 4 0 0 1-4 4H14l-7 6v-6H4a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`circle`,{cx:`9`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`16`,cy:`14.5`,r:`1.8`,fill:`currentColor`}),(0,I.jsx)(`circle`,{cx:`23`,cy:`14.5`,r:`1.8`,fill:`currentColor`})]}),(0,I.jsx)(H,{x:92,y:76,children:`Your AI app`}),(0,I.jsx)(H,{x:92,y:98,size:14,weight:500,className:`fill-soft`,children:`Claude, Cursor, VS Code…`})]})}function W({x:e,y:t}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`250`,height:`196`,rx:`26`,className:`fill-green-deep`}),(0,I.jsxs)(`g`,{transform:`translate(110 16)`,className:`text-white`,children:[(0,I.jsx)(`path`,{d:`M15 2 27 6.5v9.4c0 7-4.5 11.8-12 14.8C7.5 27.7 3 22.9 3 15.9V6.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`m9.5 16 4 4 7-8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),(0,I.jsx)(H,{x:125,y:68,size:17,weight:700,className:`fill-white`,children:`hardened-mcp`}),(0,I.jsx)(H,{x:125,y:88,size:14,weight:500,className:`fill-on-hero-soft`,children:`the toolbox that checks every action`}),L.map(([e,t],n)=>(0,I.jsxs)(`g`,{transform:`translate(34 ${108+n*26})`,children:[(0,I.jsx)(`rect`,{width:`182`,height:`22`,rx:`11`,fill:`white`,fillOpacity:`0.12`}),(0,I.jsx)(`circle`,{cx:`14`,cy:`11`,r:`5`,className:t}),(0,I.jsx)(H,{x:28,y:15.5,size:14,weight:600,className:`fill-white`,anchor:`start`,children:e})]},e))]})}function G({x:e,y:t,compact:n}){return(0,I.jsxs)(`g`,{transform:`translate(${e} ${t})`,children:[(0,I.jsx)(`rect`,{width:`176`,height:n?150:168,rx:`22`,className:`fill-surface stroke-line`,strokeWidth:`1.5`}),(0,I.jsx)(H,{x:88,y:28,size:14.5,weight:700,className:`fill-soft`,children:`Your servers`}),R.map((e,t)=>(0,I.jsxs)(`g`,{transform:`translate(18 ${42+t*(n?26:30)})`,children:[(0,I.jsx)(`rect`,{width:`140`,height:`22`,rx:`7`,className:t===R.length-1?`fill-transparent`:`fill-sunken`}),t<R.length-1&&(0,I.jsx)(`circle`,{cx:`13`,cy:`11`,r:`3.5`,className:`fill-ok`}),(0,I.jsx)(H,{x:t<R.length-1?26:8,y:15.5,size:12.5,weight:500,className:`fill-muted`,anchor:`start`,children:e})]},e))]})}function K({text:e}){let t=e.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).filter(Boolean);return(0,I.jsx)(I.Fragment,{children:t.map((e,t)=>e.startsWith("`")?(0,I.jsx)(`code`,{className:`mono rounded-md bg-sunken px-1.5 py-0.5 text-[12.5px] break-words text-ink`,children:e.slice(1,-1)},t):e.startsWith(`**`)?(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:e.slice(2,-2)},t):(0,I.jsx)(`span`,{children:e},t))})}function q({children:e}){return(0,I.jsx)(`p`,{className:`max-w-2xl text-[15.5px] leading-relaxed text-muted`,children:e})}function J({icon:e,title:t,children:n}){return(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e,size:17})}),(0,I.jsxs)(`span`,{className:`min-w-0 pt-0.5`,children:[(0,I.jsx)(`span`,{className:`block text-[15px] font-medium`,children:t}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] leading-relaxed text-soft`,children:n})]})]})}function de(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,I.jsx)(q,{children:`hardened-mcp lets your AI app use tools, like your files, GitHub or Notion. It doesn't give the AI everything. You get a toolbox. Your AI app connects to it, and every action goes through it first. When protection is on, reading runs freely. Every change asks you first. Anything outside the folders and services you gave it is blocked. Everything is written down, so you can always see what your AI did.`}),(0,I.jsx)(`div`,{className:`rounded-[22px] bg-sunken/60 p-4 sm:p-6`,children:(0,I.jsx)(z,{})}),(0,I.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,I.jsxs)(`section`,{"aria-labelledby":`what-mcp`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsxs)(`h2`,{id:`what-mcp`,className:`flex items-center gap-2 text-[16px] font-semibold`,children:[`What's an MCP server? `,(0,I.jsx)(l,{term:`mcp`})]}),(0,I.jsx)(`p`,{className:`mt-2 text-[14px] leading-relaxed text-muted`,children:`It's a small add-on that gives your AI app a set of tools: reading a folder, searching the web, opening an issue on GitHub. MCP is a shared standard, so any AI app can use any of them. You'll add your first one in a minute.`})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-expect`,className:`rounded-[18px] border border-line p-5`,children:[(0,I.jsx)(`h2`,{id:`what-expect`,className:`text-[16px] font-semibold`,children:`What to expect`}),(0,I.jsxs)(`ul`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`About 5 minutes`,children:`Seven short steps. You can skip any of them and come back later from Settings & help.`}),(0,I.jsx)(J,{icon:`lock`,title:`Nothing changes until you say so`,children:`Your AI apps keep working exactly as they do now until you choose to connect one.`}),(0,I.jsx)(J,{icon:`eye`,title:`It starts by watching`,children:`At first your toolbox lets everything run and writes down what it would have asked you about or blocked, so nothing you rely on breaks. In step 6 you choose whether to turn protection on straight away.`})]})]})]})]})}function Y(e,t){let n=t.find(t=>t.id===e),r=e===`node`?t.find(e=>e.id===`npx`):e===`uv`?t.find(e=>e.id===`uvx`):void 0;return!n?.found||r&&!r.found?{status:{tone:`neutral`,label:`Not installed`,icon:`minus`},check:n,state:`missing`}:n?.running===!1?{status:{tone:`warn`,label:`Installed, not running`,icon:`pause`},check:n,state:`stopped`}:{status:{tone:`ok`,label:`Ready`,icon:`check`},check:n,state:`ready`}}function fe({entries:e}){let i=p(()=>t.doctor(),[]),[a,o]=(0,F.useState)(!1),s=i.data,c=A(s?.platform),u=b(e),f=()=>{o(!0),i.reload(),setTimeout(()=>o(!1),700)},m=s?k.map(e=>({rt:e,...Y(e,s.checks)})):[],h=m.filter(e=>e.state!==`ready`),g=m.some(e=>e.rt===`node`&&e.state===`ready`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Most servers need a free helper program to run, such as Node.js. This looks for them on this computer. It only looks; it never installs or changes anything. `,(0,I.jsx)(l,{term:`machineCheck`})]}),i.error&&!s?(0,I.jsx)(r,{tone:`warn`,title:`The check couldn't run`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a,children:`Check again`}),children:`You can skip this step. If a server needs something that's missing, it will tell you when you test it.`}):s?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r,{tone:h.length===0?`ok`:g?`info`:`warn`,role:`status`,title:h.length===0?`Everything is ready`:g?`You're ready for your first server`:`Some servers need something installed first`,actions:(0,I.jsx)(d,{size:`sm`,icon:`refresh`,onClick:f,loading:a||i.loading,children:`Check again`}),children:h.length===0?`This computer has everything servers need.`:g?`Some servers need other helpers, listed below. You don't need them unless you add one of those servers.`:`That's fine. You can carry on and only install something when a server you want needs it.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":`What this computer has`,children:m.map(e=>(0,I.jsx)(X,{rt:e.rt,status:e.status,check:e.check,state:e.state,os:c,needs:u[e.rt]},e.rt))})]}):(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,"aria-label":`Checking your computer`,children:(0,I.jsx)(n,{height:64,lines:3})})]})}function X({rt:t,status:n,check:r,state:i,os:a,needs:s}){let c=ae[t],[l,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(a),h=`install-${t}`;return(0,I.jsxs)(`li`,{className:`rounded-[18px] border border-line p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,I.jsx)(`p`,{className:`flex flex-wrap items-center gap-2 text-[15px] font-semibold`,children:c.name}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[13.5px] text-soft`,children:c.why}),i!==`ready`&&s.length>0&&(0,I.jsxs)(`p`,{className:`mt-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:`Needed by:`}),` `,s.join(`, `)]}),i===`ready`&&(r?.path||r?.version)&&(0,I.jsxs)(`details`,{className:`mt-1 text-[12px] text-soft`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),r?.version&&(0,I.jsxs)(`span`,{className:`mono block`,children:[`Version `,r.version]}),r?.path&&(0,I.jsx)(`code`,{className:`mono block break-all`,children:r.path})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,I.jsx)(e,{tone:n.tone,icon:n.icon,children:n.label}),i!==`ready`&&(0,I.jsx)(d,{size:`sm`,variant:`ghost`,iconRight:`chevron`,"aria-expanded":l,"aria-controls":h,onClick:()=>f(!l),children:i===`stopped`?`How to start it`:`How to install it`})]})]}),l&&i!==`ready`&&(0,I.jsx)(`div`,{id:h,className:`mt-4 border-t border-faint pt-4`,children:i===`stopped`&&c.start?(0,I.jsx)(`p`,{className:`text-[14px] leading-relaxed text-muted`,children:(0,I.jsx)(K,{text:c.start[p]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{size:`sm`,label:`Install steps for ${c.name}: choose your computer`,value:p,onChange:m,options:[`darwin`,`win32`,`linux`].map(e=>({value:e,label:D[e]}))}),(0,I.jsx)(`ol`,{className:`mt-4 flex flex-col gap-3`,children:c.steps[p].map((e,t)=>(0,I.jsxs)(`li`,{className:`flex gap-3`,children:[(0,I.jsx)(`span`,{className:`tnum grid h-6 w-6 shrink-0 place-items-center rounded-full bg-sunken text-[12px] font-bold text-muted`,children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 text-[14px] leading-relaxed text-muted`,children:[(0,I.jsx)(K,{text:e.text}),e.copy&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`mono min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[12.5px] break-all text-ink`,children:e.copy}),(0,I.jsx)(T,{text:e.copy,label:`Copy`})]}),e.link&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(u,{href:e.link.url,external:!0,size:`sm`,iconRight:`external`,children:e.link.label})})]})]},t))})]})})]})}function pe({gatewayId:e,existing:t,added:n,entries:i,onAdded:a,onClosed:o}){let[s,c]=(0,F.useState)(n.length===0&&t.length===0),l=n.at(-1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Pick a server to give your AI app its first tools. Each one comes with step-by-step instructions, and you can test it before anything is saved. If you're not sure, `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Files on this computer`}),` `,`is a good first choice: it lets the AI read and edit files in one folder you choose, and nothing outside it.`]}),l&&(0,I.jsx)(r,{tone:`ok`,role:`status`,title:l.displayName?`${l.displayName} is in your toolbox`:`Added to your toolbox`,children:l.summary.length>0?(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.summary.map(e=>(0,I.jsx)(`li`,{children:e},e))}):`It's saved in your toolbox.`}),!l&&t.length>0&&(0,I.jsxs)(r,{tone:`info`,title:`You already have servers`,children:[`Your toolbox has `,t.map(e=>v(i,e)?.name??e).join(`, `),`. You can add another or carry on.`]}),s?(0,I.jsx)(N,{gatewayId:e,compact:!0,onDone:e=>{a(e),c(!1)},onCancel:n.length>0||t.length>0?()=>{c(!1),o?.()}:void 0}):(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:()=>c(!0),children:`Add another server`})})]})}function me({gatewayId:e,attached:t,onAttached:n,onAddServer:i}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Now tell your AI app about your toolbox. `,(0,I.jsx)(l,{term:`toolbox`}),` Choose the app you use and we add the toolbox to its settings for you. A copy of its old settings is kept, so you can undo this at any time.`]}),(0,I.jsxs)(`div`,{className:`rounded-[18px] bg-sunken/60 p-4 sm:p-5`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-[15px] font-semibold`,children:[(0,I.jsx)(s,{name:`refresh`,size:17,className:`text-ok`}),`Restart your app once`]}),(0,I.jsx)(`p`,{className:`mt-1.5 text-[13.5px] leading-relaxed text-muted`,children:`Your AI app only looks for new tools when it starts. After connecting, quit it completely (not just close the window) and open it again. You only do this once: servers you add or change later appear on their own.`})]}),e?t?(0,I.jsx)(r,{tone:`ok`,role:`status`,title:t.alreadyConnected?`${t.appLabel} was already connected`:`Connected to ${t.appLabel}`,children:t.restartHint||`Quit ${t.appLabel} completely and open it again.`}):(0,I.jsx)(P,{gatewayId:e,compact:!0,onDone:n}):(0,I.jsx)(r,{tone:`info`,title:`Add a server first`,actions:(0,I.jsx)(d,{size:`sm`,variant:`primary`,icon:`arrow-left`,onClick:i,children:`Add a server`}),children:`Your toolbox is made when you add your first server. Then you can connect it to your app here.`})]})}function he({entries:e,servers:t,appLabel:n}){let{prompt:r,entry:i}=S(e,t),a=n??`your AI app`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsxs)(q,{children:[`Open `,a,` and ask it something that uses your new tools`,i?` from ${i.name}`:``,`. Here's a good first one:`]}),(0,I.jsxs)(`figure`,{className:`m-0 rounded-[20px] border-[1.5px] border-primary/40 bg-ok-tint p-5`,children:[(0,I.jsxs)(`blockquote`,{className:`text-[17px] leading-relaxed font-medium text-ink`,children:[`“`,r,`”`]}),(0,I.jsx)(`figcaption`,{className:`mt-4`,children:(0,I.jsx)(T,{text:r,label:`Copy this`})})]}),(0,I.jsxs)(`section`,{"aria-labelledby":`what-see`,children:[(0,I.jsx)(`h2`,{id:`what-see`,className:`text-[16px] font-semibold`,children:`What you'll see`}),(0,I.jsxs)(`ol`,{className:`mt-3 flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`check`,title:`Looking runs straight away`,children:`When the AI only reads something, it just happens. Every action is written down under Activity in this console.`}),(0,I.jsx)(J,{icon:`eye`,title:`At first, changes run too`,children:`A new toolbox starts by watching: everything runs, and Activity notes what would have asked you first or been blocked. In the next step you choose whether it should start protecting you.`}),(0,I.jsxs)(J,{icon:`clock`,title:`Once protection is on, every change asks you first`,children:[`If the AI wants to change something, it stops and tells you it's waiting. The request appears under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Waiting for you`}),` in this console. Approve it or say no there. If you approve, the AI can try again and it goes ahead. Anything outside the folders and services you gave it is blocked.`]}),(0,I.jsxs)(J,{icon:`warning`,title:`If nothing happens`,children:[`Check that you quit `,a,` completely and opened it again. If a tool still doesn't show up, open Connections in this console: each server says whether it's working, and if not, why and how to fix it.`]})]}),(0,I.jsx)(`div`,{className:`mt-5`,children:(0,I.jsx)(u,{href:`/approvals`,external:!0,icon:`clock`,iconRight:`external`,children:`Open Waiting for you`})})]})]})}var Z=`Reading runs straight away. Every change asks you first, here in this console. Anything outside the folders and services you gave it is blocked.`;function ge({gatewayId:t,onAddServer:i,applyRef:a}){let[o,s]=(0,F.useState)(`protect`),[l,u]=(0,F.useState)(!1),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),_=p(()=>t?c.protection(t):Promise.resolve(null),[t]),v=(0,F.useRef)(null),y=(0,F.useRef)(!1),b=_.data?.enforcement===`enforce`||h===`protect`,x=_.data&&!_.data.policyWrite.ok?_.data.policyWrite.why:null,S=async()=>{if(m(null),!t||b||h===`watch`)return!0;if(o===`watch`)return y.current=!0,g(`watch`),!0;if(!_.data)return!1;if(x)return m(x),!1;u(!0);try{return await c.setPolicySetting(t,`enforcement`,`enforce`,_.data.policyWrite.digest),y.current=!0,g(`protect`),_.reload(),!0}catch(e){return m(e.message||`Protection couldn't be turned on.`),!1}finally{u(!1)}};return a&&(a.current=S),(0,F.useEffect)(()=>()=>{a&&(a.current=null)},[a]),(0,F.useEffect)(()=>{y.current&&v.current?.focus()},[b,h]),t?_.loading&&!_.data?(0,I.jsx)(n,{height:180}):b?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsxs)(r,{tone:`ok`,title:`Your toolbox is protecting you`,role:`status`,children:[Z,` Requests appear under `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Waiting for you`}),`.`]})}),(0,I.jsxs)(`ul`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(J,{icon:`clock`,title:`When your AI asks for something`,children:`It stops and tells you it's waiting. Open this console, look at what it wants to do, and approve it or say no.`}),(0,I.jsxs)(J,{icon:`sliders`,title:`Too many questions?`,children:[`Under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` you can let a tool you trust run freely, or approve one for a while.`]})]})]}):h===`watch`?(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)(`div`,{ref:v,tabIndex:-1,className:`outline-none`,children:(0,I.jsx)(r,{tone:`warn`,title:`Your toolbox is only watching for now`,role:`status`,children:`Everything your AI does runs and is written down under Activity. Nothing asks you first and nothing is blocked, so you're not protected yet.`})}),(0,I.jsxs)(q,{children:[`When you're ready, turn protection on under `,(0,I.jsx)(`strong`,{className:`font-semibold text-ink`,children:`Protection settings`}),` `,`(one switch at the top), or come back to this guide from Settings & help.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`ghost`,onClick:()=>g(null),children:`Choose again`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Right now your toolbox only watches: everything your AI does runs, and is written down. Choose whether it should start protecting you now.`}),(0,I.jsx)(w,{label:`How careful should your toolbox be?`,value:o,onChange:s,options:[{value:`protect`,title:`Protect me now`,badge:(0,I.jsx)(e,{tone:`ok`,children:`Recommended`}),body:Z},{value:`watch`,title:`Watch for a few days first`,body:`Everything runs and is written down, and nothing asks you first. You can see what would have asked you, then turn protection on later. Until then, you're not protected.`}]}),x&&(0,I.jsx)(r,{tone:`warn`,title:`This toolbox's protection can't be changed from the console`,children:x}),f&&(0,I.jsx)(r,{tone:`danger`,role:`alert`,title:`Protection wasn't turned on`,children:f}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{variant:`primary`,icon:o===`protect`?`shield-check`:`eye`,loading:l,disabled:!!x&&o===`protect`,onClick:()=>void S(),children:o===`protect`?`Turn on protection`:`Keep watching for now`})})]}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(q,{children:`There's nothing to protect yet. Add a server first, then come back here.`}),(0,I.jsx)(`div`,{children:(0,I.jsx)(d,{icon:`plus`,onClick:i,children:`Add a server`})})]})}var Q=[{href:`/approvals`,icon:`clock`,title:`Waiting for you`,body:`Requests that ask you first. Approve or say no.`},{href:`/tools`,icon:`tool`,title:`Tools`,body:`Every tool your AI can use, and what each one is allowed to do.`},{href:`/connections?add=server`,icon:`plus`,title:`Add more servers`,body:`GitHub, Notion, the web and more, with a guide for each.`},{href:`/protection`,icon:`sliders`,title:`Protection settings`,body:`Choose what runs freely, what asks you first, and what's blocked.`}];function _e({gatewayId:e,onLeave:t}){let n=p(()=>e?c.protection(e):Promise.resolve(null),[e]),i=!!n.data&&n.data.enforcement!==`enforce`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,I.jsx)(q,{children:`Your toolbox is set up. Here's where to go next.`}),i&&(0,I.jsxs)(r,{tone:`warn`,title:`Protection: off (only watching)`,children:[`Everything your AI does runs and is written down, and nothing asks you first. Turn protection on under`,` `,(0,I.jsx)(`strong`,{className:`font-semibold`,children:`Protection settings`}),` when you're ready.`]}),(0,I.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:Q.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:e.href,onClick:n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(e.href))},className:_(`card card-link flex h-full gap-3.5 p-5`),children:[(0,I.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,I.jsx)(s,{name:e.icon,size:19})}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[15.5px] font-semibold`,children:[e.title,(0,I.jsx)(s,{name:`arrow-right`,size:15,className:`text-soft`})]}),(0,I.jsx)(`span`,{className:`mt-0.5 block text-[13.5px] text-soft`,children:e.body})]})]})},e.href))}),(0,I.jsx)(r,{tone:`info`,title:`When you need to approve something, open the console`,children:`Approving requests and signing in to services happen here. Your servers keep working without the console open; anything that asks you first waits until you open it again.`})]})}function $(){let[e,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(`welcome`),[o,l]=(0,F.useState)(!1),[u,f]=(0,F.useState)(null),[p,v]=(0,F.useState)([]),[b,S]=(0,F.useState)([]),[w,T]=(0,F.useState)(null),[D,ae]=(0,F.useState)([]),k=(0,F.useRef)(null),A=(0,F.useRef)(null),[N,P]=(0,F.useState)(!1),L=(0,F.useRef)(!1),[R,z]=(0,F.useState)(O),[B,V]=(0,F.useState)(null),H=(0,F.useRef)(R);H.current=R;let U=(0,F.useRef)(null),[W,G]=(0,F.useState)(0),K=(0,F.useRef)(Promise.resolve()),q=(0,F.useRef)(ie);(0,F.useEffect)(()=>{let e=!0;return t.settings().then(ee,()=>(l(!0),ie)).then(t=>{e&&(q.current=t,n(t),i(oe(t.onboarding)))}),c.servers().then(t=>{if(!e)return;let n=t.filter(e=>e.ok),r=n.find(e=>e.id===`main`)??n[0];r&&(f(r.id),v(r.upstreams??[]))}).catch(()=>void 0),t.catalog().then(t=>e&&ae(t.entries)).catch(()=>void 0),()=>{e=!1}},[]);let J=(0,F.useCallback)(e=>{let r={...q.current,onboarding:e};q.current=r,n(r);let i=()=>t.saveSettings(r).then(()=>l(!1),()=>l(!0));return K.current=K.current.then(i,i),K.current},[]),Y=()=>{let e=H.current;if(e.pending){let t=e.pending;S(e=>x({added:e,gatewayId:null},t).added),f(t.gatewayId)}e.state!==`idle`&&ue(),z(O)},X=e=>{M(r,R)?V(()=>e):e()},Z=(e,t)=>{r===`server`&&e!==`server`&&Y(),L.current=!0,i(e),J(ne(q.current.onboarding,e,t))},Q=async(e=`/`)=>{r===`server`&&Y(),await J(te(q.current.onboarding)),g(e)};(0,F.useEffect)(()=>{if(r===`server`)return a(e=>z(t=>re(t,e)))},[r]),(0,F.useEffect)(()=>{W&&U.current?.querySelector(`button`)?.focus()},[W]),(0,F.useEffect)(()=>{if(!L.current)return;k.current?.focus();let e=matchMedia(`(prefers-reduced-motion: reduce)`).matches;window.scrollTo({top:0,behavior:e?`auto`:`smooth`})},[r]),(0,F.useEffect)(()=>{let e=document.title;return document.title=`Step ${E.indexOf(r)+1} of ${E.length}: ${j[r]} – hardened-mcp`,()=>{document.title=e}},[r]);let $=E.indexOf(r),ye=e?.onboarding.done??[],be=[...p,...C(b,R.pending).map(e=>e.upstreamName)],xe=M(r,R);return(0,I.jsxs)(`div`,{className:`min-h-dvh bg-canvas text-ink`,children:[(0,I.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-faint bg-canvas/95`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-6xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,I.jsx)(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[#2a2623]`,children:(0,I.jsx)(`img`,{src:`/brand/mark.svg`,alt:``,width:24,height:24})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[15px] font-semibold`,children:`Getting started`}),(0,I.jsx)(`span`,{className:`block text-[12.5px] text-soft`,children:`hardened-mcp`})]}),(0,I.jsx)(d,{variant:`ghost`,size:`sm`,iconRight:`arrow-right`,onClick:()=>X(()=>void Q()),children:`Go to the console`})]})}),e?(0,I.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10 lg:py-10`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Guide steps`,className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,I.jsxs)(`div`,{className:`lg:hidden`,children:[(0,I.jsxs)(`p`,{className:`text-[13px] font-semibold text-soft`,children:[`Step `,$+1,` of `,E.length]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-line`,role:`progressbar`,"aria-label":`Progress through the guide`,"aria-valuemin":1,"aria-valuemax":E.length,"aria-valuenow":$+1,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${($+1)/E.length*100}%`}})})]}),(0,I.jsx)(`ol`,{className:`hidden flex-col gap-1 lg:flex`,children:E.map((e,t)=>{let n=e===r,i=ye.includes(e);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>e===r?void 0:X(()=>Z(e)),"aria-current":n?`step`:void 0,className:_(`flex w-full items-center gap-3 rounded-2xl px-3 py-2.5 text-left text-[14px] transition-colors`,n?`bg-surface font-semibold shadow-[var(--shadow-sm)]`:`text-muted hover:bg-faint`),children:[(0,I.jsx)(`span`,{className:_(`tnum grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12.5px] font-bold`,i?`bg-primary text-white`:n?`border-2 border-[var(--primary)] text-ink`:`border-[1.5px] border-line text-soft`),children:i?(0,I.jsx)(s,{name:`check`,size:14,strokeWidth:2.6}):t+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j[e]}),i&&(0,I.jsx)(`span`,{className:`sr-only`,children:`(done)`})]})},e)})})]}),(0,I.jsxs)(`main`,{className:`min-w-0`,children:[(0,I.jsxs)(`article`,{className:`card p-5 sm:p-8`,"aria-labelledby":`start-step-h`,children:[(0,I.jsxs)(`p`,{className:`eyebrow text-soft`,children:[`Step `,$+1,` · `,j[r]]}),(0,I.jsx)(`h1`,{id:`start-step-h`,ref:k,tabIndex:-1,className:`display mt-2 text-[28px] outline-none sm:text-[34px]`,children:le[r]}),(0,I.jsxs)(`div`,{className:`mt-5`,children:[r===`welcome`&&(0,I.jsx)(de,{}),r===`computer`&&(0,I.jsx)(fe,{entries:D}),r===`server`&&(0,I.jsx)(pe,{gatewayId:u,existing:p,added:b,entries:D,onAdded:e=>{f(e.gatewayId),S(t=>C(t,e)),z(O),G(e=>e+1)},onClosed:()=>z(O)}),r===`app`&&(0,I.jsx)(me,{gatewayId:u,attached:w,onAttached:e=>{T(e),G(e=>e+1)},onAddServer:()=>Z(`server`)}),r===`try`&&(0,I.jsx)(he,{entries:D,servers:be,appLabel:w?.appLabel??null}),r===`protect`&&(0,I.jsx)(ge,{gatewayId:u,onAddServer:()=>Z(`server`),applyRef:A}),r===`done`&&(0,I.jsx)(_e,{gatewayId:u,onLeave:e=>void Q(e)})]}),(0,I.jsxs)(`footer`,{className:_(`mt-8 flex-wrap items-center gap-2 border-t border-faint pt-5`,xe?`hidden`:`flex`),children:[$>0&&(0,I.jsx)(d,{variant:`ghost`,icon:`arrow-left`,onClick:()=>Z(se(r)),children:`Back`}),(0,I.jsx)(`span`,{className:`flex-1`}),r!==`done`&&(0,I.jsx)(d,{variant:`ghost`,onClick:()=>X(()=>Z(y(r))),children:`Skip for now`}),(0,I.jsx)(ve,{buttonRef:U,step:r,ready:ce(r,be.length,!!w,R),busy:N,onNext:async()=>{r===`protect`&&A.current&&(P(!0),!await A.current().finally(()=>P(!1)))||Z(y(r),r)},onFinish:()=>void Q()})]})]}),(0,I.jsx)(h,{open:!!B,onClose:()=>V(null),title:`Leave without saving this server?`,description:`You're in the middle of setting up a server. If you leave now, it isn't added, and you'd start it again next time.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{variant:`ghost`,onClick:()=>{let e=B;V(null),e?.()},children:`Leave without saving`}),(0,I.jsx)(d,{variant:`primary`,onClick:()=>V(null),children:`Keep setting it up`})]})}),o&&(0,I.jsx)(`p`,{className:`mt-3 text-center text-[12.5px] text-soft`,role:`status`,children:`Your progress couldn't be saved, so the guide may start over next time. Everything you add is still saved.`})]})]}):(0,I.jsx)(`main`,{className:`flex min-h-[60dvh] items-center justify-center`,children:(0,I.jsxs)(`p`,{role:`status`,className:`flex items-center gap-3 text-soft`,children:[(0,I.jsx)(m,{}),` Getting things ready…`]})})]})}function ve({buttonRef:e,step:t,ready:n,busy:r,onNext:i,onFinish:a}){if(t===`done`)return(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:a,children:`Go to the console`})});let o=t===`welcome`?`Let's start`:t===`try`?`I've tried it`:`Continue`,s=n?null:t===`server`?`Add a server first, or skip for now.`:`Connect an app first, or skip for now.`;return(0,I.jsxs)(I.Fragment,{children:[s&&(0,I.jsx)(`p`,{id:`start-continue-why`,className:`order-last basis-full text-right text-[13px] text-soft`,children:s}),(0,I.jsx)(`span`,{ref:e,className:`contents`,children:(0,I.jsx)(d,{variant:`primary`,iconRight:`arrow-right`,onClick:i,disabled:!n,loading:r,"aria-describedby":s?`start-continue-why`:void 0,children:o})})]})}export{$ as StartPage};
|