@xopcai/xopc 0.0.462 → 0.0.463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/_locales/en/messages.json +1 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
- package/dist/browser-ext/dist/assets/{auth-CQmxIyWw.js → auth-YPMDpWOW.js} +32 -1
- package/dist/browser-ext/dist/background.js +24 -19
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +7 -7
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-C_rlXuEe.js +1 -0
- package/dist/gateway/static/root/assets/{apps-page-QLOYw2QR.js → apps-page-D1qzENN_.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DpKnqajR.js → automations-page-HYFnPiNG.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-BXT_EDON.js → automations-workspace-JCQ1IXFk.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-CnU0htlO.js → capabilities-page-kPv2dOzf.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-U2a7d6wP.js → chat-page-CalELOKj.js} +6 -6
- package/dist/gateway/static/root/assets/{connectors-page-Bs29RvXz.js → connectors-page-B9mpz_Rt.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CEBDMkde.js → index-DUo6H0PC.js} +4 -4
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DCIEL5bA.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-D_l5jkV9.js → note-detail-panel-DsXb1qjW.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-R4uJroeD.js → notes-page-BTpiOw67.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BsONyPfQ.js → personal-page-I3IGVSJh.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-nSDw8sfo.js → plugin-details-dialog-F08k_k2u.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-xNSy6SAv.js → project-detail-page-Dy46uSEt.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-Dwb_N8L-.js → route-preload-ChTaYgpA.js} +2 -2
- package/dist/gateway/static/root/assets/{service-recommendation-list-DDlMyPvC.js → service-recommendation-list-BmRtbJz2.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-8MiJzbbl.js → settings-page-C39lKVRv.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DxKXoBbE.js → task-detail-page-D1dNWTnP.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-UvWbDUXi.js → work-discovery-overlay-BJ15p4rH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BM1HsYz6.js → work-discovery-page-8XciWNs5.js} +1 -1
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/session-runner.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.js +8 -1
- package/dist/src/agent/mcp/connection-setup.js +46 -42
- package/dist/src/agent/mcp/conversation-setup.js +13 -8
- package/dist/src/agent/mcp/discovery.d.ts +22 -1
- package/dist/src/agent/mcp/discovery.js +19 -3
- package/dist/src/agent/mcp/managed-discovery.d.ts +8 -0
- package/dist/src/agent/mcp/managed-discovery.js +77 -0
- package/dist/src/agent/mcp/tool-catalog.js +1 -1
- package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +6 -2
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +10 -7
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-configuration.js +12 -4
- package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/connectors/connection-recovery-service.js +38 -5
- package/dist/src/connectors/excluded-connectors.d.ts +1 -0
- package/dist/src/connectors/excluded-connectors.js +5 -1
- package/dist/src/connectors/plugin-connection.d.ts +10 -0
- package/dist/src/connectors/plugin-connection.js +105 -0
- package/dist/src/extensions/agent-plugins/setup.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/gateway/hono/middleware/auth.js +1 -1
- package/dist/src/gateway/hono/routes/agent-plugins.js +2 -2
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.js +11 -11
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +2 -2
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/notifications/service.js +2 -2
- package/dist/src/phone/stream-gateway.js +1 -1
- package/dist/src/tui/tui-management.js +2 -2
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CikzCYAG.js +0 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CsTSmjmX.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{a as d,i as f,o as p,r as m,s as h,t as g}from"./dist-CY7CS_D3.js";import{t as _}from"./arrow-left-D880xG-P.js";import{t as v}from"./chevron-down-ccbiQQz_.js";import{t as y}from"./working-directory-picker-modal-BGZduAXV.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as te}from"./circle-BoO4YvTx.js";import{t as x}from"./file-archive-DanfQJNe.js";import{t as S}from"./folder-open-CyzJ19I9.js";import{t as ne}from"./loader-circle-CifKLtgG.js";import{t as re}from"./package-wATCyihJ.js";import{t as C}from"./shield-check-BU58siTV.js";import{t as w}from"./upload-rrb46c3c.js";import{t as T}from"./cn-0WouolD0.js";import{t as ie}from"./skeleton-DzdOeGYz.js";import{a as E}from"./vendor-swr-CdRzEUwF.js";import{t as D}from"./button-Cc4hUNTt.js";import{t as ae}from"./capability-links-MZdYfPKx.js";import{t as O}from"./browser-BLJWD7WI.js";import{t as k}from"./capability-icon-CmvCZOJX.js";var oe=n(),A=r();function j(e){let t=(0,oe.c)(30),{data:n,zh:r}=e,i=r?`插件内容与范围`:`Contents and access`,a;t[0]===i?a=t[1]:(a=(0,A.jsx)(`h4`,{className:`font-medium text-fg`,children:i}),t[0]=i,t[1]=a);let o=r?`新增技能:`:`Skills: `,s;t[2]!==n.latestVersion.componentIndex?.skills||t[3]!==r?(s=n.latestVersion.componentIndex?.skills.join(`, `)||(r?`目录未提供清单`:`Not listed in catalog`),t[2]=n.latestVersion.componentIndex?.skills,t[3]=r,t[4]=s):s=t[4];let c;t[5]!==o||t[6]!==s?(c=(0,A.jsxs)(`p`,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l=r?`工具连接:`:`Tool connections: `,u;t[8]!==n.latestVersion.componentIndex?.mcpServers||t[9]!==r?(u=n.latestVersion.componentIndex?.mcpServers.map(M).join(`, `)||(r?`目录未提供清单`:`Not listed in catalog`),t[8]=n.latestVersion.componentIndex?.mcpServers,t[9]=r,t[10]=u):u=t[10];let d;t[11]!==l||t[12]!==u?(d=(0,A.jsxs)(`p`,{children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13];let f=r?`运行范围:`:`Runtime scope: `,p=n.latestVersion.riskTier===`local-exec`?r?`包含本机代码执行,可能访问本机文件或网络`:`Includes local code execution; may access local files or networks`:n.latestVersion.riskTier===`network`?r?`包含网络服务调用;数据范围取决于账号授权`:`Includes network service calls; data scope depends on authorization`:n.latestVersion.riskTier===`content`?r?`目录标记为内容能力`:`Catalog classifies this as content capabilities`:r?`目录未声明,请查看说明与来源`:`Not declared; review documentation and source`,m;t[14]!==p||t[15]!==f?(m=(0,A.jsxs)(`p`,{children:[f,p]}),t[14]=p,t[15]=f,t[16]=m):m=t[16];let h=r?`授权与来源`:`Authorization and source`,g;t[17]===h?g=t[18]:(g=(0,A.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:h}),t[17]=h,t[18]=g);let _=r?`发布者认证只验证来源,不授予操作权限。账号授权与依赖需另行设置。未列出权限不代表没有文件或外部访问。`:`Publisher verification does not grant permissions. Accounts and dependencies require separate setup. Missing scope metadata does not mean no file or external access.`,v;t[19]===_?v=t[20]:(v=(0,A.jsx)(`p`,{className:`mt-2 leading-5`,children:_}),t[19]=_,t[20]=v);let y;t[21]!==g||t[22]!==v?(y=(0,A.jsxs)(`details`,{className:`text-xs`,children:[g,v]}),t[21]=g,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==m||t[25]!==y||t[26]!==a||t[27]!==c||t[28]!==d?(b=(0,A.jsxs)(`section`,{className:`mt-4 space-y-2 rounded-lg border border-edge p-4 text-sm text-fg-muted`,children:[a,c,d,m,y]}),t[24]=m,t[25]=y,t[26]=a,t[27]=c,t[28]=d,t[29]=b):b=t[29],b}function M(e){return`${e.name} (${e.transport})`}var N=e(O(),1),P=e(t(),1);function F(e){let t=(0,oe.c)(6),{fields:n,values:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Object.entries(n),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,A.jsx)(A.Fragment,{children:a.map(e=>{let[t,n]=e;return(0,A.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{children:[n.title,n.required?` *`:``]}),n.type===`boolean`?(0,A.jsx)(`input`,{type:`checkbox`,checked:r[t]===!0,onChange:e=>i({...r,[t]:e.target.checked})}):(0,A.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,type:n.sensitive?`password`:n.type===`number`?`number`:`text`,required:n.required,autoComplete:`off`,value:String(r[t]??``),onChange:e=>i({...r,[t]:n.type===`number`?Number(e.target.value):e.target.value})})]},t)})}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function se(e){let t=(0,oe.c)(62),{account:n,fields:r,zh:i,busy:a,attempt:o,initialMethod:s,onBack:c,onConnect:l,onSave:u,onRedirect:d,onSkip:f}=e,[p,m]=(0,P.useState)(s&&n.methods.some(e=>e.id===s)?s:n.methods[0]?.id??``),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[0]=h):h=t[0];let[g,v]=(0,P.useState)(h),[y,b]=(0,P.useState)(``),[ee,te]=(0,P.useState)(),x;t[1]===p?x=t[2]:(x=e=>e.id===p,t[1]=p,t[2]=x);let S=n.methods.find(x),re;t[3]===i?re=t[4]:(re=(e,t)=>i?e:t,t[3]=i,t[4]=re);let C=re,w=o?.challenge?.type===`qr`?o.challenge.url:void 0,T,E;t[5]===w?(T=t[6],E=t[7]):(T=()=>{let e=!1;return te(void 0),w&&N.toDataURL(w,{width:240,margin:2}).then(t=>{e||te(t)}).catch(L),()=>{e=!0}},E=[w],t[5]=w,t[6]=T,t[7]=E),(0,P.useEffect)(T,E);let ae;t[8]===o?ae=t[9]:(ae=o&&![`cancelled`,`error`,`connected`].includes(o.state),t[8]=o,t[9]=ae);let O=ae,k=o?.authorizationUrl??o?.challenge?.url,j=`连接 ${n.title}`,M=`Connect ${n.title}`,se;t[10]!==C||t[11]!==j||t[12]!==M?(se=C(j,M),t[10]=C,t[11]=j,t[12]=M,t[13]=se):se=t[13];let R;t[14]===C?R=t[15]:(R=C(`返回插件详情`,`Back to plugin details`),t[14]=C,t[15]=R);let z;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(_,{className:`size-4`}),t[16]=z):z=t[16];let B;t[17]!==c||t[18]!==R?(B=(0,A.jsx)(D,{variant:`ghost`,className:`shrink-0`,onClick:c,"aria-label":R,children:z}),t[17]=c,t[18]=R,t[19]=B):B=t[19];let V;t[20]===C?V=t[21]:(V=C(`连接 `,`Connect `),t[20]=C,t[21]=V);let H;t[22]!==n.title||t[23]!==V?(H=(0,A.jsxs)(`h3`,{className:`text-base font-semibold`,children:[V,n.title]}),t[22]=n.title,t[23]=V,t[24]=H):H=t[24];let U;t[25]!==n.description||t[26]!==C?(U=n.description??C(`完成授权后自动检查连接。也可以稍后在详情页继续。`,`The connection is checked after authorization. You can also continue later in plugin details.`),t[25]=n.description,t[26]=C,t[27]=U):U=t[27];let W;t[28]===U?W=t[29]:(W=(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:U}),t[28]=U,t[29]=W);let G;t[30]!==H||t[31]!==W?(G=(0,A.jsxs)(`div`,{children:[H,W]}),t[30]=H,t[31]=W,t[32]=G):G=t[32];let K;t[33]!==B||t[34]!==G?(K=(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,G]}),t[33]=B,t[34]=G,t[35]=K):K=t[35];let q;t[36]!==n.methods||t[37]!==O||t[38]!==a||t[39]!==p||t[40]!==C?(q=n.methods.length>1?(0,A.jsx)(`div`,{role:`tablist`,"aria-label":C(`授权方式`,`Authorization methods`),className:`flex flex-wrap gap-2 rounded-lg bg-surface-inset p-1.5`,children:n.methods.map(e=>(0,A.jsx)(`button`,{role:`tab`,type:`button`,"aria-selected":p===e.id,className:`min-h-10 rounded-md px-3 text-sm ${p===e.id?`bg-surface-panel font-medium text-fg`:`text-fg-muted`}`,disabled:a||!!O,onClick:()=>{m(e.id),v({})},children:e.title},e.id))}):null,t[36]=n.methods,t[37]=O,t[38]=a,t[39]=p,t[40]=C,t[41]=q):q=t[41];let J=S?.instructions?.length||S?.helpUrl?(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[S.instructions?.length?(0,A.jsx)(`ol`,{className:`list-decimal space-y-2 pl-5`,children:S.instructions.map(I)}):null,S.helpUrl?(0,A.jsx)(`a`,{className:`text-accent underline`,href:S.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:C(`打开官方配置说明`,`Open setup instructions`)}):null]}):null,Y=(S?.type===`form`||S?.fields?.length)&&!O?(0,A.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),u(S.id,g)},children:[(0,A.jsx)(F,{fields:Object.fromEntries((S.fields??[]).filter(e=>r[e]).map(e=>[e,{...r[e],required:!0}])),values:g,onChange:v}),(0,A.jsxs)(D,{type:`submit`,disabled:a||!S.fields?.every(e=>g[e]!==void 0&&g[e]!==``),children:[a?(0,A.jsx)(ne,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,C(`保存并连接`,`Save and connect`)]})]}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[O?null:(0,A.jsx)(D,{disabled:a,onClick:()=>l(p),children:C(`连接账号`,`Connect account`)}),O?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:o.challenge?.message??(o.state===`preparing`?C(`正在准备登录…`,`Preparing sign-in…`):C(`请完成登录,返回后会自动继续。`,`Finish signing in. Installation continues automatically.`))}):null,w&&O?ee?(0,A.jsx)(`img`,{src:ee,alt:C(`使用 ${n.title} 扫码授权`,`Scan to authorize ${n.title}`),className:`mx-auto size-60 max-w-full rounded-lg`}):(0,A.jsx)(ie,{className:`mx-auto size-60`}):null,k&&O?(0,A.jsx)(`a`,{href:k,target:`_blank`,rel:`noopener noreferrer`,className:`inline-block text-sm text-accent underline`,children:w?C(`也可以打开授权页面`,`Or open the authorization page`):C(`打开登录页面`,`Open sign-in page`)}):null,o?.expiresAt&&O?(0,A.jsxs)(`p`,{className:`text-center text-xs text-fg-muted`,children:[C(`本次授权有效期至 `,`This sign-in expires at `),new Date(o.expiresAt).toLocaleTimeString()]}):null,o?.error?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error}):null,o?.acceptsRedirect&&O?(0,A.jsxs)(`details`,{className:`text-sm`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:C(`登录后没有自动返回?`,`Did sign-in not return automatically?`)}),(0,A.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),d(y)},children:[(0,A.jsxs)(`label`,{children:[C(`登录回调地址`,`Sign-in callback URL`),(0,A.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),className:`mt-1 w-full rounded-lg border border-edge bg-surface-inset p-2`})]}),(0,A.jsx)(D,{type:`submit`,disabled:a||!y,children:C(`继续登录`,`Continue sign-in`)})]})]}):null]}),X;t[42]===C?X=t[43]:(X=C(`暂时跳过`,`Skip for now`),t[42]=C,t[43]=X);let Z;t[44]!==a||t[45]!==f||t[46]!==X?(Z=(0,A.jsx)(D,{variant:`secondary`,disabled:a,onClick:f,children:X}),t[44]=a,t[45]=f,t[46]=X,t[47]=Z):Z=t[47];let Q;t[48]===C?Q=t[49]:(Q=C(`相关功能暂不可用,可随时在插件详情中授权。`,`Features requiring this account stay unavailable. Connect later in plugin details.`),t[48]=C,t[49]=Q);let ce;t[50]===Q?ce=t[51]:(ce=(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Q}),t[50]=Q,t[51]=ce);let le;t[52]!==Z||t[53]!==ce?(le=(0,A.jsxs)(`div`,{className:`border-t border-edge pt-4`,children:[Z,ce]}),t[52]=Z,t[53]=ce,t[54]=le):le=t[54];let ue;return t[55]!==se||t[56]!==K||t[57]!==q||t[58]!==J||t[59]!==Y||t[60]!==le?(ue=(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":se,children:[K,q,J,Y,le]}),t[55]=se,t[56]=K,t[57]=q,t[58]=J,t[59]=Y,t[60]=le,t[61]=ue):ue=t[61],ue}function I(e,t){return(0,A.jsx)(`li`,{children:e},t)}function L(){}async function R(e,t=`GET`,n){let r=await l(s(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function z({extension:e,zh:t,onChanged:n,onStart:r,onInstalled:i,initialConnect:o=!1}){let s=`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,[c,l]=(0,P.useState)(),[u,d]=(0,P.useState)({}),[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(``),[g,_]=(0,P.useState)({}),[v,y]=(0,P.useState)(null),[x,S]=(0,P.useState)(``),[re,C]=(0,P.useState)(null),[w,T]=(0,P.useState)(!1),E=(0,P.useRef)(new Set),ae=(0,P.useRef)(new Set),O=(0,P.useRef)(void 0),k=(0,P.useRef)(null),oe=(0,P.useRef)(new Set),j=(e,n)=>t?e:n,M=e.setup?.authorizations??[],N=new Set(M.flatMap(e=>e.servers)),I=[...M,...(c?.connections??[]).filter(t=>!N.has(t.name)&&(e.components?.mcp.find(e=>e.name===t.name)?.type!==`stdio`||t.state===`token_required`)).map(t=>{let n=t.state===`token_required`||t.state===`auth_unknown`||e.components?.mcp.find(e=>e.name===t.name)?.connectionAuth?.mode===`api-key`;return{id:t.name,title:t.name,servers:[t.name],methods:[{id:n?`api-key`:`oauth`,title:n?j(`访问令牌`,`Access token`):j(`浏览器登录`,`Browser sign-in`),type:n?`form`:`oauth`,...n?{fields:[`__apiKey`]}:{server:t.name}}]}})],L=e=>e.servers.every(e=>c?.connections.find(t=>t.name===e)?.state===`connected`)&&(!M.some(t=>t.id===e.id)||c?.authorizations?.find(t=>t.id===e.id)?.state===`connected`),z=(c?.authorizations??[]).flatMap(e=>(e.issues??[]).map(t=>({...t,account:I.find(t=>t.id===e.id)}))),B=I.filter(e=>!L(e)),V=c?.installed||c?.state===`completed`,H=e.setup?.userConfig??{},U=new Set(M.flatMap(e=>e.methods.flatMap(e=>e.fields??[]))),W=Object.fromEntries(Object.entries(H).filter(([e])=>!U.has(e))),G=c?.error===`Connection verification failed. Check the credentials or login status and try again.`?j(`连接验证未通过,请检查凭据或登录状态后重试。`,c.error):c?.error,K=Object.fromEntries(Object.entries(H).filter(([e])=>c?.missingConfig?.includes(e))),q=f||c?.state===`running`,J=I.find(e=>e.id===re);(0,P.useEffect)(()=>{let e=!1;return R(`${s}/setup`).then(t=>{e||l(t)}).catch(t=>{e||(l(null),h(String(t)))}),()=>{e=!0}},[s]),(0,P.useEffect)(()=>{if(c?.state!==`running`)return;let e=!1,t=!1,r=setInterval(()=>{t||(t=!0,R(`${s}/setup`).then(t=>{e||(l(t),t?.state!==`running`&&n())}).catch(t=>{e||h(String(t))}).finally(()=>{t=!1}))},750);return()=>{e=!0,clearInterval(r)}},[s,c?.state]),(0,P.useEffect)(()=>{if(!c||!c.connections.some(e=>[`oauth_required`,`error`].includes(e.state)))return;let e=!1;return R(`${s}/setup/reusable`).then(t=>{e||_(t)}).catch(()=>{e||_({})}),()=>{e=!0}},[s,c?.revision]),(0,P.useEffect)(()=>{if(!x||c?.state===`completed`)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await R(`${s}/setup/auth/${encodeURIComponent(x)}`);e||y(t)}catch(t){e||h(String(t))}finally{t=!1}}};n();let r=setInterval(()=>void n(),1500),i=()=>void n();return window.addEventListener(`focus`,i),()=>{e=!0,clearInterval(r),window.removeEventListener(`focus`,i)}},[s,x,c?.state]),(0,P.useEffect)(()=>{let e=v?.authorizationUrl??(v?.challenge?.type===`url`?v.challenge.url:void 0);if(!v)return;if(v.error||[`cancelled`,`error`,`connected`].includes(v.state)){k.current?.close(),k.current=null;return}if(!e){v.challenge?.type===`qr`&&(k.current?.close(),k.current=null);return}let t=`${v.id}:${e}`;if(oe.current.has(t))return;oe.current.add(t);let n=k.current;k.current=null,n&&!n.closed?n.location.replace(e):window.open(e,`_blank`,`noopener,noreferrer`)},[v]);async function Y(e,t={},r=c?.revision){p(!0),h(``);try{let a=await R(`${s}/setup`,`POST`,{action:e,expectedRevision:r,...e===`start`?{}:{idempotencyKey:crypto.randomUUID()},...t}),o=e===`configure`&&M.find(e=>e.id===t.authorization)?.methods.some(e=>e.id===t.method&&e.type===`cli`);return([`reuse`,`start`].includes(e)||e===`configure`&&!o)&&(d({}),T(!1),a=await R(`${s}/setup`,`POST`,{action:`prepare`,expectedRevision:a.revision,idempotencyKey:crypto.randomUUID()})),l(a),await n(),[`complete`,`defer`].includes(e)&&(C(null),y(null),S(``),k.current?.close(),k.current=null,i?.()),a}catch(e){h(e instanceof Error?e.message:String(e));try{l(await R(`${s}/setup`))}catch{}return null}finally{p(!1)}}(0,P.useEffect)(()=>{if(!c||q||m||[`cancelled`,`running`,`failed`].includes(c.state)||c.state===`completed`)return;let e,t=``;if(c.state===`pending`?(e=`prepare`,t=`prepare:${s}:${c.revision}`):v?.state===`connected`&&(e=`prepare`,t=`auth:${s}:${v.id}`),e&&!E.current.has(t)){E.current.add(t),Y(e);return}c.resources===`ready`&&!c.missingConfig?.length&&!c.partial&&c.connections.every(e=>e.state===`connected`)&&(c.authorizations??[]).every(e=>e.state===`connected`)&&(t=`complete:${s}:${c.revision}`,E.current.has(t)||(E.current.add(t),Y(`complete`)))},[c,v,q,m,s]),(0,P.useEffect)(()=>{q||!c||c.state===`cancelled`||(J&&c.revision!==O.current&&L(J)?(C(null),y(null),S(``)):(!V||o)&&c.resources===`ready`&&(!c.missingConfig?.length||o&&!c.missingConfig.some(e=>e in W))&&!re&&B[0]&&!ae.current.has(B[0].id)&&(ae.current.add(B[0].id),O.current=c.revision,C(B[0].id)))},[c,q,V,re,o]);function X(e,t){let n=e.methods.find(e=>e.id===t),r=n?.type===`oauth`||n?.type===`cli`?window.open(`about:blank`,`_blank`):null;r&&(r.opener=null),k.current=r,y(null),Y(`authorize`,{server:e.id,...M.some(t=>t.id===e.id)?{method:t}:{}}).then(t=>{t?S(e.id):(r?.close(),k.current=null)})}async function Z(t,n,r){if(n===`api-key`&&!M.some(e=>e.id===t.id)){p(!0),h(``);try{let n=e.components?.mcp.find(e=>e.name===t.id);await R(`${s}/mcp/${encodeURIComponent(t.id)}/auth`,`PUT`,{mode:`api-key`,secrets:[{target:n.type===`stdio`?`env`:`headers`,key:n.connectionAuth?.headerName??(n.type===`stdio`?`API_KEY`:`Authorization`),prefix:n.connectionAuth?.prefix??(n.type===`stdio`?``:`Bearer `),value:r.__apiKey}]});let i=await R(`${s}/setup`);l(i),p(!1),await Y(`prepare`,{},i.revision);return}catch(e){h(String(e)),p(!1);return}p(!1)}else if(t.methods.find(e=>e.id===n)?.type===`cli`){let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null),k.current=e,y(null);let i=await Y(`configure`,{authorization:t.id,method:n,values:r},c?.revision);i&&await Y(`authorize`,{server:t.id,method:n},i.revision)?S(t.id):(e?.close(),k.current=null)}else await Y(`configure`,{authorization:t.id,method:n,values:r})}if(c===void 0)return(0,A.jsx)(ie,{className:`h-40 w-full`});let Q=()=>{Y(`defer`)};return J?(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsx)(se,{initialMethod:c?.authorizations?.find(e=>e.id===J.id)?.method,account:J,fields:{...H,__apiKey:{type:`string`,title:j(`访问令牌`,`Access token`),required:!0,sensitive:!0}},zh:t,busy:q,attempt:v,onBack:()=>C(null),onConnect:e=>X(J,e),onSave:(e,t)=>void Z(J,e,t),onRedirect:e=>{p(!0),R(`${s}/setup/auth/${encodeURIComponent(x)}/redirect`,`POST`,{url:e}).catch(e=>h(String(e))).finally(()=>p(!1))},onSkip:Q},`${J.id}:${c?.authorizations?.find(e=>e.id===J.id)?.method??``}`),g[J.id]?.map(e=>(0,A.jsxs)(D,{disabled:q,variant:`secondary`,onClick:()=>void Y(`reuse`,{server:J.id,sourceServerId:e.id}),children:[j(`使用已登录账号:`,`Use signed-in account: `),e.name]},e.id)),m||G&&J.servers.some(e=>c?.connections.find(t=>t.name===e)?.state===`error`)?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:m||G}):null]}):(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":j(`插件安装与授权`,`Plugin setup`),children:[V?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:j(`安装完成`,`Installation complete`)}),(0,A.jsx)(`p`,{role:`status`,className:`mt-1 text-sm text-fg-muted`,children:e.activationEligible===!1?j(`插件已停用。`,`Plugin is disabled.`):c?.partial||B.length||z.length||c?.missingConfig?.length?j(`插件已安装,部分功能仍需要授权。`,`Plugin installed. Some features still need authorization.`):j(`所有 Agent 均可使用。可在 Agent 设置中单独调整。`,`Available to all agents. Customize individual agents in Agent settings.`)})]}):(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:j(`安装准备`,`Installation setup`)}),(0,A.jsx)(`ol`,{className:`mt-4 space-y-4 text-sm`,"aria-live":`polite`,children:[{name:j(`准备资源`,`Prepare resources`),done:c?.resources===`ready`,running:q&&c?.resources!==`ready`},{name:j(`授权账号`,`Authorize accounts`),done:c?.resources===`ready`&&!c?.missingConfig?.length&&B.length===0,running:!1},{name:j(`加载可用工具`,`Load available tools`),done:!1,running:q&&c?.resources===`ready`}].map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-3`,children:[e.done?(0,A.jsx)(ee,{className:`size-5 text-accent`,"aria-hidden":!0}):e.running?(0,A.jsx)(ne,{className:`size-5 animate-spin text-accent`,"aria-hidden":!0}):(0,A.jsx)(te,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),e.name]},e.name))}),(0,A.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:j(`安装后所有 Agent 均可使用,可在各自的设置中调整。`,`Available to all agents after installation. Customize individual agents in Agent settings.`)})]}),!c||c.state===`cancelled`?(0,A.jsx)(D,{disabled:f||e.readiness===`blocked`,onClick:()=>void Y(`start`),children:j(`继续安装`,`Continue installation`)}):(0,A.jsxs)(A.Fragment,{children:[c.missingConfig?.length||w?(0,A.jsxs)(`form`,{className:`space-y-4 rounded-xl border border-edge p-4`,onSubmit:e=>{e.preventDefault(),Y(`configure`,{values:u})},children:[(0,A.jsx)(`h4`,{className:`font-medium`,children:j(`补充配置`,`Required configuration`)}),(0,A.jsx)(F,{fields:w?W:K,values:u,onChange:d}),(0,A.jsx)(D,{type:`submit`,disabled:q||!Object.keys(u).length,children:j(`继续`,`Continue`)})]}):null,V&&(B.length||c.missingConfig?.length)?(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(b,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:j(`需要授权`,`Authorization required`)}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:j(`授权后即可使用相关功能。已就绪的功能可继续使用。`,`Connect these accounts to use their features. Ready features remain available.`)})]})]}):null,z.length?(0,A.jsx)(`div`,{className:`space-y-3`,"aria-label":j(`需要补充权限`,`Additional permissions required`),children:z.map(e=>(0,A.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`text-fg-muted`,children:j(`账号已连接,以下权限尚未就绪;其他已授权功能可继续使用。`,`Account connected. These permissions are not ready; other authorized features remain available.`)}),e.scopes.length?(0,A.jsx)(`p`,{className:`break-all font-mono text-xs`,children:e.scopes.join(`, `)}):null,(0,A.jsx)(`ol`,{className:`list-inside list-decimal space-y-1 text-fg-muted`,children:e.instructions.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.helpUrl?(0,A.jsx)(D,{variant:`secondary`,asChild:!0,children:(0,A.jsx)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:j(`前往开通应用权限`,`Open application permissions`)})}):null,e.method&&e.account?(0,A.jsx)(D,{disabled:q,onClick:()=>{O.current=c.revision,C(e.account.id),X(e.account,e.method)},children:j(`补充授权`,`Grant missing permissions`)}):null,(0,A.jsx)(D,{variant:`secondary`,disabled:q,onClick:()=>void Y(`prepare`),children:j(`重新检查权限`,`Check permissions again`)})]})]},`${e.account?.id}:${e.id}`))}):null,I.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`h4`,{className:`text-sm font-medium`,children:j(`账号与连接`,`Accounts and connections`)}),I.map(e=>(0,A.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`flex items-center justify-between gap-3 rounded-lg border border-edge p-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:L(e)?j(`已连接`,`Connected`):j(`需要授权`,`Authorization required`)})]}),(0,A.jsx)(D,{variant:L(e)?`secondary`:`primary`,disabled:q||c.resources!==`ready`,onClick:()=>{y(null),S(``),O.current=c.revision,C(e.id)},children:L(e)?j(`重新授权`,`Reconnect`):j(`连接账号`,`Connect account`)})]},e.id))]}):null,!V&&c.resources===`ready`?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(D,{variant:`secondary`,disabled:q,onClick:Q,children:j(`暂时跳过`,`Skip for now`)}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:j(`先完成安装,稍后在详情页授权。未授权的功能暂不可用。`,`Finish installation and connect later in plugin details. Unauthenticated features remain unavailable.`)})]}):null,V&&Object.keys(W).length&&!w?(0,A.jsx)(D,{variant:`ghost`,disabled:q,onClick:()=>T(!0),children:j(`修改插件配置`,`Edit plugin configuration`)}):null,V&&!z.length&&M.some(e=>e.methods.some(e=>e.type===`cli`))?(0,A.jsx)(D,{variant:`secondary`,disabled:q,onClick:()=>void Y(`prepare`),children:j(`检查连接与权限`,`Check connection and permissions`)}):null,!q&&(m||[`failed`,`interrupted`].includes(c.state)||c.connections.some(e=>e.state===`error`))?(0,A.jsx)(D,{variant:`secondary`,onClick:()=>void Y(`prepare`),children:j(`重试检查`,`Retry checks`)}):null,V?null:(0,A.jsx)(D,{variant:`ghost`,disabled:f,onClick:()=>void Y(`cancel`),children:j(`取消安装`,`Cancel installation`)}),V&&!B.length&&!c.missingConfig?.length?e.setup?.tasks?.map(t=>(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-inset p-4 text-sm`,children:[(0,A.jsx)(`p`,{children:t}),(0,A.jsx)(D,{asChild:!0,disabled:!e.active,children:(0,A.jsx)(a,{to:`/chat/new?${new URLSearchParams({draft:t,projectScope:`none`})}`,state:{forceNewChat:!0},onClick:t=>{e.active?r?.():t.preventDefault()},children:j(`开始这个任务`,`Start this task`)})})]},t)):null]}),q?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:j(`正在准备,可关闭后继续。`,`Preparing. You can close this window and resume.`)}):null,c?.error&&!c.deferred&&!c.missingConfig?.length?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:G}):null,m?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:m}):null]})}var B=`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;function V(e,t){if(e.startsWith(`content.skills:`)){let n=e.slice(15);return t?`提供技能:${n}`:`Add skill: ${n}`}if(e.startsWith(`runtime.mcp.stdio:`)){let n=e.slice(18).split(`:`,1)[0];return t?`在 Gateway 上运行工具服务:${n}`:`Run a tool service on the Gateway: ${n}`}if(e.startsWith(`network.mcp:`)){let n=e.slice(12).split(`:`,1)[0];return t?`连接外部工具服务:${n}`:`Connect to an external tool service: ${n}`}return e.startsWith(`runtime.capability-access:`)?t?`按账号授权启用相关技能和工具`:`Enable skills and tools according to account authorization`:e.startsWith(`runtime.authorization:`)?t?`在本机运行账号登录程序:${e.split(`:`)[1]}`:`Run account sign-in locally: ${e.split(`:`)[1]}`:e.startsWith(`runtime.resource:`)?t?`下载可执行资源:${e.split(`:`)[1]}`:`Download executable resource: ${e.split(`:`)[1]}`:e.startsWith(`network.resource:`)?t?`下载并校验资源:${e.split(`:`)[1]}`:`Download and verify resource: ${e.split(`:`)[1]}`:e}function H(e,t){return t?.publisher?.verification!==`verified`||t.latestVersion.riskTier&&t.latestVersion.riskTier!==`content`?!0:e.addedCapabilities.some(e=>!e.startsWith(`content.skills:`))}async function U(e,t,n){let r=await l(s(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function W({extension:e,onClose:t,onUninstalled:n,initialSource:r=``,marketplace:a,autoInstall:s=!1}){let l=c(e=>e.language),_=l.startsWith(`zh`),b=a?.localizations?.[_?`zh-CN`:`en`],te=b?.displayName??a?.name,ie=b?.description??a?.description,O=(0,P.useId)(),{mutate:oe}=E(),[M,N]=(0,P.useState)(e),[F,se]=(0,P.useState)(r||e?.installationSource||``),[I,L]=(0,P.useState)(null),[R,W]=(0,P.useState)([]),[G,K]=(0,P.useState)(!1),[q,J]=(0,P.useState)(``),[Y,X]=(0,P.useState)(!1),[Z,Q]=(0,P.useState)(!1),[ce,le]=(0,P.useState)(!1),[ue,de]=(0,P.useState)(!1),[fe,pe]=(0,P.useState)(!1),[me,he]=(0,P.useState)(!1),ge=o(),_e=i(),[ve,ye]=(0,P.useState)(!1),be=(0,P.useRef)(!1),xe=`/api/extensions/agent-plugins/${encodeURIComponent(M?.pluginId??``)}`,Se=F.trim().startsWith(`store:`),Ce=()=>oe(`gateway-extensions-list`);async function $(e){K(!0),J(``);try{await e()}catch(e){J(e instanceof Error?e.message:String(e))}finally{K(!1)}}function we(e){se(e),L(null),W([]),J(``)}let Te=typeof window<`u`?window.electronAPI?.file:void 0,Ee=/^(?:\/|[A-Za-z]:[\\/])/.test(F.trim())?F.trim():void 0;async function De(){if(!Te?.openDirectory){pe(!0);return}let e=await Te.openDirectory(Ee?{defaultPath:Ee}:void 0);e&&we(e)}async function Oe(){if(!Te?.openFile){pe(!0);return}let e=await Te.openFile({...Ee?{defaultPath:Ee}:{},extensions:[`zip`]});e&&we(e)}function ke(e){return[...e.dataTransfer.types].some(e=>e===`Files`||e===`text/plain`||e===`text/uri-list`)}function Ae(e){if(!ke(e))return;e.preventDefault(),de(!1);let t=Array.from(e.dataTransfer.files);if(t.length){if(t.length>1){J(_?`一次只能选择一个插件目录或 ZIP。`:`Choose one plugin directory or ZIP at a time.`);return}let e=Te?.getPathForFile?.(t[0]);e?we(e):J(_?`浏览器无法读取本机文件路径,请使用“选择文件或目录”选择安装包。`:`The browser cannot read local file paths. Use Choose file or folder to select the package.`);return}let n=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);n.trim()&&we(n.trim().split(/\r?\n/)[0])}async function je(e){let t=await U(`${xe}/activation`,`POST`,{enabled:e});N(t),await Ce()}async function Me(e){let t=!M,n=await U(t?`/api/extensions/install`:`${xe}/update`,`POST`,{source:F,reviewHash:e.reviewHash,...e.layout?{setup:!0}:{}});N(n),await Ce(),!e.layout&&t&&!n.activationEligible&&n.readiness!==`blocked`&&n.pluginId&&(n=await U(`/api/extensions/agent-plugins/${encodeURIComponent(n.pluginId)}/activation`,`POST`,{enabled:!0}),N(n),await Ce()),L(null),ye(!e.layout&&t&&n.activationEligible===!0)}async function Ne(){let e=await U(`/api/extensions/inspect`,`POST`,{source:F});if(H(e,a)){L(e);return}await Me(e)}(0,P.useEffect)(()=>{e&&!e.setup&&N(e)},[e]),(0,P.useEffect)(()=>{if(!e?.setup||!e.pluginId)return;let t=!1;return U(`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,`GET`).then(e=>{t||N(e)}).catch(()=>{}),()=>{t=!0}},[e?.pluginId]),(0,P.useEffect)(()=>{!s||M||!Se||be.current||(be.current=!0,$(Ne))},[s,M,Se]);let Pe=s&&!M&&Se&&!be.current;return(0,A.jsx)(g,{defaultOpen:!0,onOpenChange:e=>!e&&t(),children:(0,A.jsxs)(p,{children:[(0,A.jsx)(d,{className:`fixed inset-0 z-[130] bg-scrim`}),(0,A.jsxs)(m,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(38rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,A.jsx)(k,{iconUrl:M?.branding?.iconUrl??a?.branding?.iconUrl,fallback:re}),(0,A.jsx)(h,{className:`font-semibold`,children:M?.name??te??(_?`安装插件`:`Install plugin`)})]}),(0,A.jsx)(D,{variant:`ghost`,onClick:t,children:_?`关闭`:`Close`})]}),(0,A.jsx)(f,{className:`sr-only`,children:_?`安装、组件、账号连接和权限`:`Installation, components, connections and permissions`}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-auto space-y-4 overflow-y-auto overscroll-contain p-4`,children:[!M&&Se?(0,A.jsxs)(`section`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,A.jsx)(C,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:te??I?.manifest.name??F.slice(6)}),ie?(0,A.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ie}):null,(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:a?.publisher?.verification===`verified`?_?`已认证发布者 · 安装后所有智能体均可使用`:`Verified publisher · available to all agents after installation`:_?`安装前会检查来源和所需权限`:`Source and required permissions are checked before installation`})]})]}),a?(0,A.jsx)(j,{data:a,zh:_}):null,I?null:(0,A.jsxs)(D,{className:`w-full`,disabled:G||Pe,onClick:()=>void $(Ne),children:[G||Pe?(0,A.jsx)(ne,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,G||Pe?_?`正在安全检查并安装…`:`Checking and installing…`:_?`一键安装`:`Install`]})]}):null,M?(0,A.jsxs)(A.Fragment,{children:[ve?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-4`,children:[(0,A.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:_?`插件已安装并启用`:`Plugin installed and enabled`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?`请继续检查账号连接、依赖与可用状态,再在对话中试用。`:`It is ready to use in your conversations.`})]})]}):null,(!M.setup||M.readiness!==`setup_required`)&&!M.activationEligible?(0,A.jsxs)(`div`,{role:`status`,className:`space-y-3 rounded-lg border border-accent/25 bg-accent-soft p-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-accent-fg`,children:_?`插件已安装,当前尚未启用`:`Plugin installed. It is not enabled yet.`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?`启用后,Skills 和 MCP 才会加入 Agent 运行时。`:`Enable it to make its skills and MCP servers available to the Agent runtime.`})]}),(0,A.jsx)(D,{disabled:G||M.readiness===`blocked`,onClick:()=>void $(()=>je(!0)),children:_?`启用插件`:`Enable plugin`})]}):null,M.setup?(0,A.jsx)(z,{extension:M,zh:_,onStart:t,onInstalled:()=>{t(),ge(ae(M.pluginId,`installed`,!1,_e.pathname+_e.search))},onChanged:async()=>{let e=await U(`${xe}`,`GET`);N(e),await Ce()}}):null,(0,A.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:_?`插件详情`:`Plugin details`}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[_?`插件`:`Plugin`,` · `,M.version,` · `,M.readiness&&{ready:_?`已就绪`:`Ready`,setup_required:_?`待连接`:`Setup required`,degraded:_?`部分不可用`:`Partially available`,blocked:_?`已阻止`:`Blocked`}[M.readiness]]}),M.provenance?(0,A.jsxs)(`p`,{className:`break-words text-xs text-fg-muted`,children:[M.provenance.publisherVerification===`verified`?_?`已认证发布者`:`Verified publisher`:_?`社区发布者`:`Community publisher`,` · `,M.provenance.packageName,`@`,M.provenance.version,` · SHA-256 `,M.provenance.sha256.slice(0,12),`…`,M.provenance.riskTier?` · ${M.provenance.riskTier}`:``]}):null,(0,A.jsx)(`p`,{className:`text-sm`,children:M.description}),M.installationSource?(0,A.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[_?`来源:`:`Source: `,M.installationSource,M.resolvedCommit?` · ${M.resolvedCommit.slice(0,12)}`:``]}):null,M.activationEligible?(0,A.jsx)(D,{disabled:G,variant:`secondary`,onClick:()=>void $(()=>je(!1)),children:_?`停用`:`Disable`}):null,M.canRollback?(0,A.jsx)(D,{disabled:G,variant:`secondary`,onClick:()=>void $(async()=>{N(await U(`${xe}/rollback`,`POST`)),await Ce()}),children:_?`回滚上一版本`:`Roll back`}):null]})]}),M.diagnostics?.map((e,t)=>(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.component,`: `,e.message]},t))]}):null,M?(0,A.jsxs)(D,{variant:`ghost`,className:`px-0`,"aria-expanded":me,onClick:()=>he(e=>!e),children:[(0,A.jsx)(v,{className:T(`size-4 transition-transform motion-reduce:transition-none`,me&&`rotate-180`),"aria-hidden":!0}),_?`高级操作`:`Advanced actions`]}):null,!M&&!Se||me?(0,A.jsxs)(`form`,{className:T(`space-y-3`,M&&`border-t border-edge pt-4`),onSubmit:e=>{e.preventDefault(),$(async()=>{let e=await U(`/api/extensions/inspect`,`POST`,{source:F});e.candidates?(W(e.candidates),L(null)):(W([]),L(e))})},children:[(0,A.jsxs)(`div`,{"data-testid":`plugin-source-dropzone`,className:T(`rounded-xl border border-dashed p-3 transition-colors`,ue?`border-accent bg-accent-soft`:`border-edge bg-surface-inset/40`),onDragEnter:e=>{ke(e)&&(e.preventDefault(),de(!0))},onDragOver:e=>{ke(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,de(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||de(!1)},onDrop:Ae,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-start gap-2`,children:[(0,A.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:O,className:`block text-sm font-medium`,children:M?_?`更新包来源`:`Update package source`:_?`安装包来源`:`Package source`}),(0,A.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:_?`输入 github:组织/仓库、Git / ZIP 地址或宿主目录;marketplace 可选择插件。`:`Enter github:owner/repo, a Git / ZIP URL or a Gateway directory. Marketplaces let you choose a plugin.`})]})]}),(0,A.jsx)(`input`,{id:O,className:B,value:F,onChange:e=>we(e.target.value),placeholder:_?`/插件目录/或/插件.zip`:`/plugin/folder/or/plugin.zip`,autoComplete:`off`,spellCheck:!1,required:!0}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Te?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(D,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void $(De),children:[(0,A.jsx)(S,{className:`size-4`,"aria-hidden":!0}),_?`选择目录`:`Choose directory`]}),(0,A.jsxs)(D,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void $(Oe),children:[(0,A.jsx)(x,{className:`size-4`,"aria-hidden":!0}),_?`选择 ZIP`:`Choose ZIP`]})]}):(0,A.jsxs)(D,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>pe(!0),children:[(0,A.jsx)(S,{className:`size-4`,"aria-hidden":!0}),_?`选择文件或目录`:`Choose file or folder`]})})]}),(0,A.jsx)(D,{type:`submit`,variant:`secondary`,disabled:G||!F,children:_?`检查安装包`:`Inspect package`})]}):null,R.length?(0,A.jsx)(`div`,{className:`space-y-2`,"aria-label":_?`选择插件`:`Choose a plugin`,children:R.map(e=>(0,A.jsx)(D,{variant:`secondary`,className:`w-full justify-start`,onClick:()=>{we(e.source),$(async()=>L(await U(`/api/extensions/inspect`,`POST`,{source:e.source})))},children:e.name},e.source))}):null,I?(0,A.jsxs)(`div`,{role:`region`,"aria-labelledby":`plugin-authorization-title`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(C,{className:`mt-0.5 size-5 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{id:`plugin-authorization-title`,className:`font-medium text-fg`,children:_?`需要你的授权`:`Your authorization is required`}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:_?`此插件需要以下新增能力。确认后自动准备资源,按需登录账号,所有智能体均可使用。`:`Review these capabilities. Resources are prepared automatically; sign in if needed. Available to all agents.`})]})]}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":_?`插件新增能力`:`Added plugin capabilities`,className:`max-h-[min(28vh,14rem)] space-y-2 overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-panel p-3 break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:I.addedCapabilities.map(e=>(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`•`}),(0,A.jsx)(`span`,{children:V(e,_)})]},e))}),I.diagnostics.map((e,t)=>(0,A.jsxs)(`p`,{children:[e.component,`: `,e.message]},t))]}):null,M&&me?(0,A.jsx)(`div`,{className:`border-t border-edge pt-4`,children:ce?(0,A.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,A.jsx)(`p`,{children:_?`卸载保留账号凭据;服务端授权需到相应服务撤销。`:`Credentials are retained. Revoke provider authorization in the service itself.`}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>X(e.target.checked)}),_?`同时删除插件数据`:`Also delete plugin data`]}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Z,onChange:e=>Q(e.target.checked)}),_?`同时删除本地凭据`:`Also delete local credentials`]}),(0,A.jsx)(D,{disabled:G,onClick:()=>void $(async()=>{await U(xe,`DELETE`,{removeData:Y,removeCredentials:Z}),await Ce(),(n??t)()}),children:_?`确认卸载`:`Confirm uninstall`})]}):(0,A.jsx)(D,{variant:`ghost`,disabled:G,onClick:()=>le(!0),children:_?`卸载插件`:`Uninstall`})}):null,q?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:q}):null]}),I?(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,A.jsx)(D,{variant:`ghost`,disabled:G,onClick:()=>L(null),children:_?`取消`:`Cancel`}),(0,A.jsxs)(D,{disabled:G||!!M&&I.manifest.name!==M.name,onClick:()=>void $(()=>Me(I)),children:[G?(0,A.jsx)(ne,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,_?`授权并安装`:`Authorize and install`]})]}):null]}),Te?null:(0,A.jsx)(y,{open:fe,onOpenChange:pe,initialAbsolutePath:Ee,onConfirm:async e=>we(e),wd:u(l).chat.workingDirectory,selectKind:`file-or-directory`,fileExtensions:[`zip`],title:_?`选择插件安装包`:`Choose plugin package`,description:_?`选择插件目录或 ZIP 文件。`:`Choose a plugin directory or ZIP file.`,confirmLabel:_?`使用此来源`:`Use this source`,nested:!0})]})})}export{z as n,j as r,W as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,n as s,o as c}from"./locale-store-Dy1EByeG.js";import{t as l}from"./messages-BAnhwALN.js";import{a as u,i as d,o as f,r as ee,s as p,t as m}from"./dist-CY7CS_D3.js";import{t as h}from"./check-DUBLcKHA.js";import{t as g}from"./secret-input-DsjfQmDn.js";import{t as te}from"./key-round-DWbpyU2U.js";import{t as _}from"./link-2-D_ZKYUW7.js";import{t as v}from"./loader-circle-CifKLtgG.js";import{t as y}from"./lock-keyhole-DEK5kH0u.js";import{t as b}from"./x-B_N4OPjy.js";import{t as x}from"./skeleton-DzdOeGYz.js";import{i as S}from"./vendor-swr-CdRzEUwF.js";import{t as C}from"./button-Cc4hUNTt.js";var w=n(),T=e(t(),1),E=r(),D={zh:{title:`连接服务`,secret:`访问密钥`,hint:`仅保存到凭据服务,不进入聊天或模型。`,invalidToken:`密钥未被接受,请核对后重新输入。`,submit:`保存并连接`,login:`继续登录`,waiting:`在服务页面完成授权,这里会自动继续。`,check:`重新检查`,checking:`正在验证连接`,cancel:`取消连接`,back:`返回对话`,close:`暂时关闭`,later:`稍后继续`,done:`完成`,failed:`暂时无法连接,请检查服务地址或权限后重试。`,expired:`请求已过期,请回到对话重新发起。`,cancelled:`此连接请求已取消。`,reload:`配置已保存。重启 Gateway 后,连接才能生效。`,details:`连接详情`,approve:`允许这次连接`,approval:`确认连接到这个服务`,shared:`连接将供此网关的助手使用,不会授予微信用户管理权限。`,identity:`来自微信私聊`,endpoint:`服务地址`,purpose:`要完成的事`,tokenDescription:`输入服务提供的访问密钥,即可继续原来的任务。`,accessDeniedToken:`服务拒绝了当前访问。若此服务需要 Token,请在这里输入;账号或服务权限也可能需要检查。`,connected:`已连接`,continuing:`正在原微信对话中继续处理,无需发送“继续”。`,delivered:`结果已发送到原微信对话。`,returnWeixin:`现在可以关闭此页,返回微信。`,closed:`返回微信即可继续对话`,reopen:`继续配置`,deliveryFailed:`连接已完成,结果暂未发送到微信。重发不会重新执行任务。`,retryDelivery:`重试发送结果`,secure:`安全连接`,loading:`正在准备连接`,checkingDescription:`正在检查服务和所需权限。`},en:{title:`Connect service`,secret:`Access key`,hint:`Saved to credential storage, never chat or the model.`,invalidToken:`This key was rejected. Check it and try again.`,submit:`Save and connect`,login:`Continue sign-in`,waiting:`Finish authorizing on the service page. This will continue automatically.`,check:`Check again`,checking:`Verifying connection`,cancel:`Cancel connection`,back:`Return to chat`,close:`Close for now`,later:`Continue later`,done:`Done`,failed:`Unable to connect. Check the service address or permissions and try again.`,expired:`This request expired. Return to chat to start again.`,cancelled:`This connection request was cancelled.`,reload:`Configuration is saved. Restart the Gateway to activate the connection.`,details:`Connection details`,approve:`Approve this connection`,approval:`Confirm this service connection`,shared:`The connection is shared with this Gateway’s assistants. It grants no administration rights to Weixin users.`,identity:`From a Weixin chat`,endpoint:`Service address`,purpose:`Your request`,tokenDescription:`Enter the access key from your service to continue your task.`,accessDeniedToken:`The service refused access. If it requires a Token, enter it here. Account or service permissions may also need attention.`,connected:`Connected`,continuing:`Continuing in the original Weixin chat. No follow-up message needed.`,delivered:`The result was sent to your original Weixin chat.`,returnWeixin:`You can close this page and return to Weixin.`,closed:`Return to Weixin to continue chatting`,reopen:`Continue setup`,deliveryFailed:`Connected, but the result could not be sent to Weixin. Resending will not run the task again.`,retryDelivery:`Retry result delivery`,secure:`Secure connection`,loading:`Preparing connection`,checkingDescription:`Checking the service and required permissions.`}};function O({setupId:e,onClose:t}){let n=s(e=>e.language),r=D[n],i=`/api/mcp/setup/${encodeURIComponent(e)}`,{data:a,error:_,mutate:w}=S(i,async e=>(await c(o(e))).payload,{refreshInterval:e=>e&&(e.returnChannel===`weixin`&&e.phase===`ready`&&![`delivered`,`failed`].includes(e.replyDelivery??``)||![`ready`,`cancelled`].includes(e.phase))?1e3:0}),[O,k]=(0,T.useState)(``),[A,j]=(0,T.useState)({}),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),I=(0,T.useRef)(``),L=(0,T.useRef)(null),R=async(e,t)=>{if(!(!a||M)){N(!0),F(!1);try{await c(o(i),{method:`POST`,body:JSON.stringify({action:e,expectedVersion:a.version,...t?{value:t}:{}})}),await w()}catch{F(!0),await w()}finally{N(!1)}}};(0,T.useEffect)(()=>{if(!a||M||a.expired||a.phase===`cancelled`)return;if(a.phase===`ready`&&!a.reloadRequired&&a.returnChannel!==`weixin`){t(a);return}if(P)return;let n=a.requiresRecheck||a.phase===`planned`||[`connected`,`error`,`cancelled`].includes(a.authState??``)?`advance`:a.phase===`oauth_required`?`authorize`:void 0,r=`${e}:${a.version}:${n}`;n&&I.current!==r&&(I.current=r,R(n))},[a,M,P,t,e]);let z=!!(a?.expired||a?.phase===`cancelled`),B=a?.secretFields?.length?a.secretFields:[{id:`token`,label:r.secret}],V=!!(O||Object.values(A).some(Boolean)),H=!!(a?.nextRetryAt&&a.nextRetryAt>Date.now()),U=B.every(e=>(e.id===`token`?O:A[e.id]??``).trim()),W=a?.phase===`ready`&&!a.reloadRequired&&!z,G=a?.phase===`approval_required`&&!z?a.approval:void 0,K=a?.phase===`approval_required`&&!z?a.planApproval:void 0,q=!!(G||K),J=a&&(a.phase===`token_required`||a.phase===`auth_unknown`&&a.canProvideToken||a.phase===`blocked`&&(a.canReplaceToken||a.canProvideToken))&&!a.requiresRecheck&&!z&&!a.reloadRequired,Y=a?.phase===`authorizing`&&!z&&!a.reloadRequired,X=W&&a?.returnChannel===`weixin`&&a.replyDelivery===`failed`,Z=(a?.phase===`blocked`||a?.phase===`auth_unknown`)&&!J&&!z,ne=a?.expired?r.expired:a?.phase===`cancelled`?r.cancelled:a?.reloadRequired?r.reload:W?X?r.deliveryFailed:a?.replyDelivery===`delivered`?r.delivered:r.continuing:q?r.approval:H?n===`zh`?`服务要求等待,将在 ${new Date(a.nextRetryAt).toLocaleTimeString()} 后有限重试。`:`Waiting until ${new Date(a.nextRetryAt).toLocaleTimeString()} before a bounded retry.`:a?.phase===`auth_unknown`?n===`zh`?`认证方式尚未确定。若服务提供 Token,可在此输入;如需 OAuth,请核实接入资料后重新检查。`:`Authentication is not yet determined. Enter a Token only if your service provides one; for OAuth, verify the integration guide and recheck.`:J?a.canProvideToken?r.accessDeniedToken:r.tokenDescription:Y?r.waiting:_||Z||P?r.failed:r.checkingDescription,Q=()=>{M||(k(``),j({}),t(a))},$=`min-h-12 w-full rounded-xl text-[15px]`,re=W?h:J?te:y;return(0,E.jsx)(m,{open:!0,onOpenChange:e=>{e||Q()},children:(0,E.jsxs)(f,{children:[(0,E.jsx)(u,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-sm`}),(0,E.jsxs)(ee,{onOpenAutoFocus:e=>{e.preventDefault(),L.current?.focus()},onPointerDownOutside:e=>{(M||V)&&e.preventDefault()},onEscapeKeyDown:e=>{M&&e.preventDefault()},className:`fixed inset-x-0 bottom-0 z-[70] flex h-[min(36rem,calc(100dvh-1rem))] flex-col overflow-hidden rounded-t-3xl border border-edge bg-surface-overlay text-fg shadow-elevated sm:inset-x-auto sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:h-[min(36rem,calc(100dvh-3rem))] sm:w-[28rem] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-3xl`,children:[(0,E.jsxs)(`header`,{className:`relative shrink-0 px-6 pb-5 pt-8 text-center sm:px-8`,children:[(0,E.jsx)(C,{variant:`ghost`,className:`absolute right-2 top-2 size-11 rounded-full p-0`,"aria-label":r.close,disabled:M,onClick:Q,children:(0,E.jsx)(b,{className:`size-4`,"aria-hidden":!0})}),(0,E.jsx)(`div`,{className:`mx-auto mb-4 flex size-12 items-center justify-center rounded-2xl bg-surface-hover`,children:(0,E.jsx)(re,{className:`size-6 text-accent-fg`,strokeWidth:1.6,"aria-hidden":!0})}),(0,E.jsx)(p,{ref:L,tabIndex:-1,className:`break-words text-xl font-semibold tracking-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:W?r.connected:a?.displayName||r.title}),a?(0,E.jsx)(`p`,{className:`mt-1 truncate text-[13px] text-fg-muted`,title:a.endpointOrigin,children:a.endpointOrigin}):null,(0,E.jsx)(d,{role:!J&&(_||P||Z||a?.expired||a?.reloadRequired)?`alert`:void 0,className:`mt-3 text-sm leading-relaxed text-fg-muted`,children:ne})]}),(0,E.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-4 sm:px-8`,"aria-busy":M,children:[!a&&!_?(0,E.jsxs)(`div`,{role:`status`,"aria-label":r.loading,className:`space-y-3`,children:[(0,E.jsx)(x,{className:`h-12 w-full rounded-xl`}),(0,E.jsx)(x,{className:`h-4 w-3/4`})]}):null,G?(0,E.jsxs)(`section`,{className:`space-y-3`,children:[(0,E.jsxs)(`dl`,{className:`space-y-3 rounded-2xl bg-surface-base p-4 text-sm`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`mb-1 text-xs text-fg-muted`,children:r.identity}),(0,E.jsxs)(`dd`,{className:`break-all`,children:[G.accountId,` / `,G.peerId]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`mb-1 text-xs text-fg-muted`,children:r.endpoint}),(0,E.jsx)(`dd`,{className:`break-all`,children:G.endpoint})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`mb-1 text-xs text-fg-muted`,children:r.purpose}),(0,E.jsx)(`dd`,{className:`break-words leading-relaxed`,children:G.purpose})]})]}),(0,E.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:r.shared}),K?(0,E.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base p-3 text-xs`,children:[(0,E.jsx)(`p`,{children:n===`zh`?`同时审阅本次来源与执行计划:`:`Also review this source and execution plan:`}),(0,E.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:JSON.stringify(K,null,2)})]}):null]}):K?(0,E.jsxs)(`section`,{className:`space-y-3 text-sm`,children:[(0,E.jsx)(`p`,{className:`break-all`,children:K.endpoint}),(0,E.jsx)(`p`,{children:K.purpose}),K.execution?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{children:n===`zh`?`将在 Gateway 主机运行以下程序,可能下载指定依赖,并按该主机的进程权限访问文件和网络。`:`This program runs on the Gateway host, may download the specified dependency and can access files and network with that process’s permissions.`}),(0,E.jsx)(`pre`,{className:`whitespace-pre-wrap break-all rounded-xl bg-surface-base p-3 text-xs`,children:JSON.stringify(K.execution,null,2)})]}):(0,E.jsx)(`p`,{children:n===`zh`?`来源归属尚未独立核实。请确认服务和以下资料来源后连接。`:`Publisher ownership has not been independently verified. Review the service and sources before connecting.`}),K.sources.map(e=>(0,E.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`block break-all text-accent-fg`,children:e.url},e.url))]}):J?(0,E.jsxs)(`form`,{id:`mcp-setup-secret-form`,className:`space-y-3`,onSubmit:e=>{e.preventDefault();let t=a.secretFields?.length?Object.fromEntries(B.map(e=>[e.id,e.id===`token`?O:A[e.id]??``])):O;k(``),j({}),R(`token`,t)},children:[B.map(e=>(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(`label`,{htmlFor:`mcp-setup-${e.id}`,className:`block text-sm font-medium`,children:e.label}),(0,E.jsx)(g,{id:`mcp-setup-${e.id}`,value:e.id===`token`?O:A[e.id]??``,onChange:t=>{e.id===`token`?k(t):j(n=>({...n,[e.id]:t})),F(!1)},disabled:M||H,autoComplete:`off`,hideCopy:!0,className:`[&_button]:size-11 [&_button]:p-3`,ariaDescribedBy:`mcp-secret-hint`,ariaInvalid:a.errorCode===`credential_rejected`||P,inputClassName:`min-h-12 rounded-xl pr-14 text-base`,labels:l(n).connectorsSettings.secretInputLabels})]},e.id)),a.helpUrl?(0,E.jsx)(`a`,{href:a.helpUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-accent-fg`,children:n===`zh`?`获取访问密钥`:`Get an access key`}):null,(0,E.jsxs)(`p`,{id:`mcp-secret-hint`,className:`flex items-start gap-1.5 text-xs leading-relaxed text-fg-muted`,children:[(0,E.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),r.hint]}),a.errorCode===`credential_rejected`||P||a.phase===`blocked`&&!a.canProvideToken?(0,E.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:a.errorCode===`credential_rejected`?r.invalidToken:r.failed}):null]}):W&&a?.returnChannel===`weixin`?(0,E.jsx)(`p`,{role:`status`,className:`py-5 text-center text-sm text-fg-muted`,children:r.returnWeixin}):_||P||Z||a?.expired||a?.reloadRequired?null:!z&&!Y?(0,E.jsxs)(`div`,{role:`status`,"aria-label":r.checking,className:`space-y-3`,children:[(0,E.jsx)(x,{className:`h-12 w-full rounded-xl`}),(0,E.jsx)(x,{className:`h-4 w-2/3`})]}):null,a&&!z&&!W?(0,E.jsxs)(`details`,{className:`mt-5 text-sm text-fg-muted`,children:[(0,E.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.details}),(0,E.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[G?null:(0,E.jsx)(`p`,{className:`break-all text-xs`,children:a.endpointOrigin}),a.phase===`approval_required`?null:(0,E.jsx)(C,{variant:`ghost`,className:`min-h-11 w-full justify-start text-xs`,disabled:M||H,onClick:()=>{I.current=``,R(`advance`)},children:r.check}),(0,E.jsx)(C,{variant:`ghost`,className:`min-h-11 w-full justify-start text-xs`,disabled:M,onClick:()=>void R(`cancel`),children:r.cancel})]})]}):null]}),(0,E.jsxs)(`footer`,{className:`shrink-0 space-y-2 border-t border-edge/60 px-6 pt-4 pb-[max(1.25rem,env(safe-area-inset-bottom))] sm:px-8`,children:[q?(0,E.jsxs)(C,{variant:`primary`,className:$,disabled:M,onClick:()=>void R(`approve`),children:[M?(0,E.jsx)(v,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):null,r.approve]}):J?(0,E.jsxs)(C,{variant:`primary`,className:$,form:`mcp-setup-secret-form`,type:`submit`,disabled:M||!U,children:[M?(0,E.jsx)(v,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):null,M?r.checking:r.submit]}):Y&&a?.authorizationUrl?(0,E.jsx)(C,{asChild:!0,variant:`primary`,className:$,children:(0,E.jsx)(`a`,{href:a.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,children:r.login})}):X?(0,E.jsx)(C,{variant:`primary`,className:$,disabled:M,onClick:()=>void R(`retry_delivery`),children:r.retryDelivery}):Z||a?.reloadRequired||_?(0,E.jsx)(C,{variant:`primary`,className:$,disabled:M||H,onClick:()=>{I.current=``,a?R(`advance`):w()},children:r.check}):W||z?(0,E.jsx)(C,{variant:`primary`,className:$,onClick:Q,children:a?.returnChannel===`weixin`?r.done:r.back}):null,!W&&!z?(0,E.jsx)(C,{variant:`ghost`,className:`min-h-11 w-full rounded-xl text-sm`,disabled:M,onClick:Q,children:r.later}):null]})]})]})})}function k(){let e=(0,w.c)(8),{setupId:t}=i(),n=t===void 0?``:t,r=a(),o=s(A),[c,l]=(0,T.useState)(!1),u;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>l(!1),e[0]=u):u=e[0];let d;e[1]===n?d=e[2]:(d=[n],e[1]=n,e[2]=d),(0,T.useEffect)(u,d);let f;return e[3]!==c||e[4]!==o||e[5]!==r||e[6]!==n?(f=(0,E.jsx)(`main`,{className:`flex h-full min-h-0 items-center justify-center bg-surface-base p-6`,children:c?(0,E.jsxs)(`section`,{className:`max-w-xs space-y-4 text-center`,children:[(0,E.jsx)(_,{className:`mx-auto size-6 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`h1`,{className:`text-lg font-medium text-fg`,children:D[o].closed}),(0,E.jsx)(C,{onClick:()=>l(!1),children:D[o].reopen})]}):(0,E.jsx)(O,{setupId:n,onClose:e=>{e?.returnChannel===`weixin`?l(!0):r(e?`/chat/${e.conversationId}`:`/chat`,{replace:!0})}})}),e[3]=c,e[4]=o,e[5]=r,e[6]=n,e[7]=f):f=e[7],f}function A(e){return e.language}export{O as McpConversationSetupDialog,k as McpConversationSetupPage};
|