6 lines
58 KiB
JavaScript
6 lines
58 KiB
JavaScript
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{B as a,Ft as o,G as s,I as c,Lt as l,Mt as u,N as d,P as f,R as p,S as m,U as h,W as g,Wt as _,Zt as v,_t as y,c as b,et as x,ft as S,h as C,l as w,lt as T,m as E,on as D,ot as O,pt as k,q as ee,qt as A,rn as j,rt as te,tt as ne,ut as M,x as re,y as ie,yt as N}from"./semi-65W_4I1v.js";import{B as ae,E as oe,F as P,I as se,L as F,_ as ce,a as I,b as L,c as le,d as R,l as ue,m as de,o as fe,p as pe,r as z,s as me,u as he,x as B,y as ge}from"./index-C6SML8F9.js";import{r as _e}from"./agent-handoff-DzQOcr38.js";var V=e(t(),1);function ve(e=`op`){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`${e}-${crypto.randomUUID()}`:`${e}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var ye={plugin_bearer_required:[`pluginHub.errorBearerRequired`,`需要 Bearer 登录凭据才能访问插件平台`],plugin_invalid_request:[`pluginHub.errorInvalidRequest`,`请求参数不合法,请检查插件 ID(仅限小写字母、数字和连字符)、标题与仓库地址`],plugin_invalid_source:[`pluginHub.errorInvalidSource`,`仅支持公开的 GitHub HTTPS 仓库地址及合法分支/Tag/Commit`],plugin_ambiguous_git_ref:[`pluginHub.errorAmbiguousRef`,`分支与 Tag 同名,请填写完整引用(如 refs/tags/xxx 或 refs/heads/xxx)`],plugin_source_not_found:[`pluginHub.errorSourceNotFound`,`未找到目标仓库或指定版本`],plugin_invalid_manifest:[`pluginHub.errorInvalidManifest`,`插件 Manifest 格式或字段校验未通过`],plugin_github_rate_limited:[`pluginHub.errorRateLimited`,`GitHub API 触发限流,建议配置 plugins.egress.github_token_env 后重试`],plugin_source_unavailable:[`pluginHub.errorSourceUnavailable`,`无法连接上游仓库,请检查网络或插件代理配置`],plugin_manifest_required:[`pluginHub.errorManifestRequired`,`该仓库未自带 csai-plugin.yaml,请先补全 Manifest 草案`],plugin_manifest_source_mismatch:[`pluginHub.errorSourceMismatch`,`Manifest 中的仓库地址或版本与探测结果不一致`],plugin_artifact_not_approved:[`pluginHub.errorArtifactNotApproved`,`当前宿主策略未批准该制品摘要,请联系管理员或核对批准策略`],plugin_operation_conflict:[`pluginHub.errorOperationConflict`,`该插件已有正在执行的变更任务,请等待当前操作完成`],plugin_plan_stale:[`pluginHub.errorPlanStale`,`安装计划已过期或已被消费,请重新生成锁定计划`],plugin_runtime_unavailable:[`pluginHub.errorRuntimeUnavailable`,`插件运行调度器尚未就绪,请稍后重试`],plugin_artifact_unavailable:[`pluginHub.errorArtifactUnavailable`,`未找到适配当前系统架构的可安装制品或镜像`],plugin_llm_binding_invalid:[`pluginHub.errorLLMBindingInvalid`,`所选模型通道无效或与该插件声明的协议不兼容`],plugin_llm_gateway_unavailable:[`pluginHub.errorLLMGatewayUnavailable`,`CSAI 插件模型网关未就绪`],plugin_web_unavailable:[`pluginHub.errorWebUnavailable`,`插件 WebUI 代理未就绪或应用尚未健康启动`],plugin_embed_origin_or_permission_rejected:[`pluginHub.errorEmbedRejected`,`无权访问该插件工作区或请求来源校验未通过`],plugin_record_not_found:[`pluginHub.errorNotFound`,`未找到对应的插件记录或计划已过期`],docker_cli_missing:[`pluginHub.errorDockerCliMissing`,`宿主未安装 Docker CLI / Engine,容器类插件无法启动`],docker_daemon_unavailable:[`pluginHub.errorDockerDaemonUnavailable`,`宿主 Docker 服务未启动,或当前运行用户无权访问 docker.sock`],docker_compose_missing:[`pluginHub.errorDockerComposeMissing`,`宿主缺少 Docker Compose v2 插件`],docker_engine_unsupported:[`pluginHub.errorDockerEngineUnsupported`,`宿主 Docker Engine 版本过低或不满足隔离档位要求`],docker_socket_missing:[`pluginHub.errorDockerSocketMissing`,`容器内未挂载 /var/run/docker.sock`],git_missing:[`pluginHub.errorGitMissing`,`宿主未安装 Git 工具`],plugin_install_failed:[`pluginHub.errorInstallFailed`,`插件安装失败,请查看运行日志或交给 Agent 排错修复`]};function H(e,t,n){let r=ye[typeof t==`string`?t:t?.payload?.error||(typeof t?.message==`string`?t.message:``)];return r?e(r[0],null,r[1]):(typeof t==`string`?t:t?.message)||n||e(`common.loadFailed`,null,`操作失败`)}function be({driver:e,probe:t,hostOS:n,hostArch:r,pluginTitle:i}){return[`请帮我在当前 CyberStrikeAI 宿主机上安装并配置插件平台缺少的运行驱动「${e}」。`,``,`### 当前诊断信息`,`- 宿主机平台:${n||`unknown`}/${r||`unknown`}`,`- 缺少驱动:${e}`,`- 预检错误码:${t?.code||`unavailable`}`,t?.guidance?`- 官方提示:${t.guidance}`:``,t?.install_command?`- 参考安装命令:\`${t.install_command}\``:``,i?`- 待安装插件:${i}`:``,``,`### 请按以下步骤协助完成`,`1. 先检查当前宿主机系统发行版、当前运行用户、包管理器以及目标依赖(如 Docker / Docker Compose / Git)与服务/权限状态;`,`2. 使用官方软件源或受信任方式安装并启动缺少的依赖(涉及 sudo 或系统变更时请清晰说明并走审批确认);`,"3. 如果安装了 Docker,请同时确认 `dockerd` 已开机自启、Compose v2 可用,并检查当前运行 CyberStrikeAI 的用户是否有权限访问 `/var/run/docker.sock`;","4. 执行验证命令确认驱动已正常可用(例如 `docker version && docker compose version` 或 `git --version`);","5. 完成后告诉我是否需要重启 CyberStrikeAI 服务(例如新增 `docker` 用户组后),以便我回到「能力平台」继续一键安装插件。"].filter(Boolean).join(`
|
||
`)}function xe({install:e,logs:t,hostOS:n,hostArch:r}){let i=(Array.isArray(t)?t:[]).slice(-40).map(e=>`[${e.created_at||``}] ${e.line}`).join(`
|
||
`);return[`我在 CyberStrikeAI 插件化能力平台中安装/运行插件「${e?.title||e?.plugin_id||`未知插件`}」失败,请帮我排查根因并直接在宿主机上修复缺少的运行环境或依赖。`,``,`### 插件状态与诊断信息`,`- 插件名称:${e?.title||`—`} (${e?.plugin_id||`—`})`,`- 实例 ID:${e?.id||`—`}`,`- 运行驱动:${e?.driver||`—`}`,`- 当前状态:${e?.observed_state||`failed`}`,`- 最近错误码:${e?.last_error_code||`plugin_install_failed`}`,e?.repository?`- 源码仓库:${e.repository}`:``,n?`- 宿主机平台:${n}/${r||``}`:``,``,`### 最近插件脱敏日志`,"```text",i||`(暂无日志输出,请直接检查对应驱动的宿主机运行环境)`,"```",``,`### 请协助完成`,`1. 根据错误码和日志定位失败根因(例如缺少 Docker / Compose / Git / Go / Node.js、dockerd 未启动、docker.sock 权限不足、端口或网络问题等);`,`2. 如果缺少运行环境或依赖,请直接帮我在宿主机上安装并配置就绪(涉及提权或系统改动时按审批确认);`,`3. 验证宿主机依赖已恢复正常,并告诉我接下来回到「能力平台」直接点击重试/启动即可。`].filter(Boolean).join(`
|
||
`)}function Se(e){switch(String(e||``).toLowerCase()){case`healthy`:return`green`;case`starting`:case`installing`:case`stopping`:return`blue`;case`degraded`:case`cleanup_pending`:return`amber`;case`failed`:return`red`;default:return`grey`}}function Ce(e,t){let n={healthy:[`pluginHub.stateHealthy`,`运行中`],starting:[`pluginHub.stateStarting`,`启动中`],installing:[`pluginHub.stateInstalling`,`安装中`],stopping:[`pluginHub.stateStopping`,`停止中`],stopped:[`pluginHub.stateStopped`,`已停止`],degraded:[`pluginHub.stateDegraded`,`状态异常`],failed:[`pluginHub.stateFailed`,`失败`],cleanup_pending:[`pluginHub.stateCleanupPending`,`待清理`],removed:[`pluginHub.stateRemoved`,`已卸载`]}[String(t||``).toLowerCase()];return n?e(n[0],null,n[1]):t||`—`}function U(e,t){let n={auto:[`pluginHub.driverAuto`,`自动择优(Release → Git → 容器)`],release:[`pluginHub.driverRelease`,`Release 预编译包`],git:[`pluginHub.driverGit`,`Git 源码构建`],container:[`pluginHub.driverContainer`,`Docker / Compose 容器`],compose:[`pluginHub.driverCompose`,`Docker Compose`]}[String(t||``).toLowerCase()];return n?e(n[0],null,n[1]):t||`—`}var W={listCatalog:()=>F.get(`/plugins/catalog`),saveCatalog:e=>F.post(`/plugins/catalog`,e),deleteCatalog:e=>F.del(`/plugins/catalog/${encodeURIComponent(e)}`),restoreCatalog:()=>F.post(`/plugins/catalog/restore`,{}),listInstalls:()=>F.get(`/plugins/installs`),getInstall:e=>F.get(`/plugins/installs/${encodeURIComponent(e)}`),listLLMChannels:()=>F.get(`/plugins/llm/channels`),probes:(e=`standard`)=>F.get(`/plugins/runtime/probes`,{isolation:e}),inspectGit:(e,t)=>F.post(`/plugins/imports/inspect`,{repository:e.trim(),revision:(t||``).trim()}),createPlan:e=>F.post(`/plugins/install-plans`,e),install:({planId:e,planDigest:t,autoBindLLM:n})=>F.post(`/plugins/installs`,{kind:`install`,plan_id:e,plan_digest:t,idempotency_key:ve(`install`),auto_bind_llm:n}),operate:(e,t,n={})=>F.post(`/plugins/installs/${encodeURIComponent(e)}/operations`,{kind:t,idempotency_key:ve(t),...n}),getOperation:e=>F.get(`/plugins/operations/${encodeURIComponent(e)}`),readLogs:(e,t=0,n=100)=>F.get(`/plugins/installs/${encodeURIComponent(e)}/logs`,{after:t,limit:n}),issueEmbedSession:e=>F.post(`/plugins/installs/${encodeURIComponent(e)}/embed-sessions`,{}),patchLLM:(e,t)=>F.patch(`/plugins/installs/${encodeURIComponent(e)}/llm`,t)};function we(e,{after:t=0,onEntry:n,onError:r,onClose:i}={}){let a=new AbortController,o=ae(),s={Accept:`text/event-stream`};o&&(s.Authorization=`Bearer ${o}`);let c=`/api/plugins/installs/${encodeURIComponent(e)}/logs?after=${encodeURIComponent(String(t))}`;return(async()=>{try{let e=await fetch(c,{method:`GET`,headers:s,signal:a.signal});if(e.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!e.ok||!e.body)throw Error(`HTTP ${e.status}`);let t=e.body.getReader(),r=new TextDecoder,o=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;o+=r.decode(i,{stream:!0});let a;for(;(a=o.indexOf(`
|
||
`))>=0;){let e=o.slice(0,a).replace(/\r$/,``);if(o=o.slice(a+1),!e.startsWith(`data:`))continue;let t=e.slice(5).trim();if(t)try{n?.(JSON.parse(t))}catch{}}}i?.()}catch(e){if(e?.name===`AbortError`){i?.();return}r?.(e)}})(),()=>a.abort()}function Te(e){let t=e?.repository||`https://github.com/owner/repo`,n=t.split(`/`).pop()||`my-plugin`,r=n.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)||`my-plugin`;return(e?.candidates||[]).includes(`container`)?JSON.stringify({apiVersion:`plugins.csai.io/v1`,kind:`WebPlugin`,metadata:{id:r,title:n,summary:`Imported container WebUI plugin`,version:`1.0.0`,repository:t},distribution:[{type:`container`,mode:`docker`,services:[{name:`web`,role:`web`,image:`ghcr.io/${t.replace(`https://github.com/`,``).toLowerCase()}:latest`,containerPort:8080,resources:{memoryMiB:512,pids:128}}]}],web:{route:`root`,entryPath:`/`,healthPath:`/`,allowHealthRedirect:!0},access:{mode:`plugin_login`},permissions:{persistentData:!1,modelGateway:!1,egress:[]}},null,2):JSON.stringify({apiVersion:`plugins.csai.io/v1`,kind:`WebPlugin`,metadata:{id:r,title:n,summary:`Imported Git WebUI plugin`,version:`1.0.0`,repository:t},distribution:[{type:`git`,url:t,revision:e?.resolved_ref||e?.commit||`main`,dependencies:[{name:`git`,minVersion:`2.30`},{name:`go`,minVersion:`1.22`}],build:[{program:`go`,args:[`build`,`-o`,`dist/app`,`.`]}],outputRoot:`dist`}],launch:{entrypoint:`app`,env:{PORT:`listen_port`,HOST:`listen_host`}},web:{route:`root`,entryPath:`/`,healthPath:`/`,allowHealthRedirect:!0},access:{mode:`platform`},permissions:{persistentData:!1,modelGateway:!1,egress:[]}},null,2)}var G=e(r(),1),{Text:Ee}=s;function De(e,t,n){let r=document.createElement(`form`);r.method=`POST`,r.action=e,r.target=n,r.style.display=`none`;let i=document.createElement(`input`);i.type=`hidden`,i.name=`ticket`,i.value=t,r.appendChild(i),document.body.appendChild(r),r.submit(),r.remove()}function Oe({install:e,canManage:t,onBack:n,onOpenDetail:r,onOpenLogs:i}){let a=P(),o=`csai-plugin-frame-${(0,V.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,s=(0,V.useRef)(null),[l,f]=(0,V.useState)(!0),[m,h]=(0,V.useState)(``),[v,b]=(0,V.useState)(null),[S,C]=(0,V.useState)(!1),w=(0,V.useCallback)(async()=>{if(e?.id){f(!0),h(``);try{let t=await W.issueEmbedSession(e.id);b(t),requestAnimationFrame(()=>{De(t.action,t.ticket,o)})}catch(e){h(H(a,e,a(`pluginHub.embedInitFailed`,null,`无法建立插件工作区会话`))),f(!1)}}},[e?.id,o,a]);(0,V.useEffect)(()=>{w()},[w]);let T=async()=>{try{let t=await W.issueEmbedSession(e.id),n=`csai-plugin-standalone-${Date.now()}`;window.open(`about:blank`,n,`noopener`),De(t.action,t.ticket,n)}catch(e){L(H(a,e,a(`pluginHub.embedInitFailed`,null,`无法打开独立窗口`)))}};return(0,V.useEffect)(()=>{let e=()=>{document.fullscreenElement||C(!1)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),(0,G.jsxs)(`div`,{ref:s,className:`cs-ph-workspace ${S?`is-expanded`:``}`,children:[(0,G.jsxs)(`div`,{className:`cs-ph-workspace-bar`,children:[(0,G.jsxs)(`div`,{className:`cs-ph-workspace-title`,children:[(0,G.jsx)(p,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(_,{}),onClick:n,children:a(`pluginHub.backToHub`,null,`返回能力平台`)}),(0,G.jsx)(Ee,{strong:!0,ellipsis:!0,style:{maxWidth:260},children:e.title||e.plugin_id}),(0,G.jsx)(d,{size:`small`,color:Se(e.observed_state),shape:`square`,children:Ce(a,e.observed_state)}),v?.origin&&(0,G.jsx)(Ee,{type:`tertiary`,size:`small`,className:`cs-ph-mono`,ellipsis:!0,style:{maxWidth:260},children:v.origin})]}),(0,G.jsxs)(c,{spacing:6,wrap:!0,children:[(0,G.jsx)(D,{content:a(`pluginHub.reconnectSession`,null,`刷新 / 重新建立隔离会话`),children:(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(M,{}),onClick:w,loading:l,children:a(`common.refresh`,null,`刷新`)})}),(0,G.jsx)(D,{content:a(`pluginHub.openFirstPartyTip`,null,`若浏览器严格拦截跨站 Cookie,可在独立首方窗口中打开`),children:(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(u,{}),onClick:T,children:a(`pluginHub.openStandalone`,null,`独立窗口`)})}),t&&(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(x,{}),onClick:i,children:a(`pluginHub.logs`,null,`日志`)}),(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(O,{}),onClick:r,children:a(`pluginHub.settingsAndDetail`,null,`详情与模型`)}),(0,G.jsx)(p,{size:`small`,icon:S?(0,G.jsx)(y,{}):(0,G.jsx)(N,{}),onClick:async()=>{let e=s.current;if(e){if(document.fullscreenElement){try{await document.exitFullscreen()}catch{}C(!1)}else{if(e.requestFullscreen)try{await e.requestFullscreen(),C(!0);return}catch{}C(e=>!e)}}},children:S?a(`pluginHub.exitFullscreen`,null,`退出全屏`):a(`mobile.fullscreen`,null,`全屏`)})]})]}),(0,G.jsxs)(`div`,{className:`cs-ph-workspace-frame-wrap`,children:[(0,G.jsx)(`iframe`,{name:o,title:e.title||e.plugin_id,className:`cs-ph-workspace-iframe`,sandbox:`allow-scripts allow-same-origin allow-forms allow-downloads`,allow:`clipboard-read; clipboard-write`,onLoad:()=>f(!1)}),l&&!m&&(0,G.jsxs)(`div`,{className:`cs-ph-workspace-overlay`,children:[(0,G.jsx)(g,{size:`large`}),(0,G.jsx)(Ee,{type:`tertiary`,children:a(`pluginHub.connectingWorkspace`,null,`正在建立隔离代理会话并加载插件页面…`)})]}),m&&(0,G.jsxs)(`div`,{className:`cs-ph-workspace-overlay`,children:[(0,G.jsx)(Ee,{type:`danger`,strong:!0,children:m}),(0,G.jsx)(Ee,{type:`tertiary`,size:`small`,children:a(`pluginHub.embedTroubleshooting`,null,`请确认插件处于运行中状态;若浏览器限制跨站 Cookie,可点击上方「独立窗口」以首方会话打开。`)}),(0,G.jsxs)(c,{children:[(0,G.jsx)(p,{theme:`solid`,type:`primary`,onClick:w,children:a(`pluginHub.retryConnect`,null,`重试连接`)}),(0,G.jsx)(p,{icon:(0,G.jsx)(u,{}),onClick:T,children:a(`pluginHub.openStandalone`,null,`独立窗口`)})]})]})]})]})}var{Text:K,Paragraph:q}=s;function ke({planResponse:e,channels:t,visible:n,canUseAgent:r,onCancel:i,onConfirmed:o,onAskAgentDriverFix:s}){let l=P(),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1);(0,V.useEffect)(()=>{n&&(h(!0),b(e?.driver_probe||null))},[n,e?.plan?.id,e?.driver_probe]);let C=e?.plan,w=e?.manifest,T=C?.artifact,E=y||e?.driver_probe||null,D=!(!E||E.available),O=!!w?.llm?.bindings?.length,k=(0,V.useMemo)(()=>(t||[]).find(e=>e.is_default)||(t||[])[0]||null,[t]),ee=(0,V.useMemo)(()=>!O||!k?!1:w.llm.bindings.some(e=>e.protocol===k.protocol),[O,k,w]);return(0,G.jsx)(le,{title:l(`pluginHub.planApprovalTitle`,null,`确认插件安装计划`),visible:n,onCancel:i,width:680,footer:(0,G.jsxs)(c,{children:[(0,G.jsx)(p,{onClick:i,children:l(`common.cancel`,null,`取消`)}),(0,G.jsx)(p,{theme:`solid`,type:`primary`,loading:g,disabled:!e?.can_confirm||D,onClick:async()=>{if(C&&e?.plan_digest){_(!0);try{let t=await W.install({planId:C.id,planDigest:e.plan_digest,autoBindLLM:O?m:void 0});B(l(`pluginHub.installQueued`,null,`安装任务已提交,正在后台准备并启动`)),o?.(t)}catch(e){L(H(l,e,l(`pluginHub.installFailed`,null,`提交安装失败`)))}finally{_(!1)}}},children:D?l(`pluginHub.driverMissingBtn`,null,`缺少运行驱动,请先安装依赖`):l(`pluginHub.confirmInstall`,null,`确认并一键安装`)})]}),children:C&&w&&(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,children:[D&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,title:l(`pluginHub.driverMissingTitle`,{driver:U(l,T?.driver)},`当前宿主机缺少所需驱动:${U(l,T?.driver)}`),description:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginTop:4},children:[(0,G.jsx)(K,{size:`small`,children:H(l,E.code,E.guidance)}),E.install_command&&(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flexWrap:`wrap`},children:[(0,G.jsx)(`code`,{className:`cs-ph-mono`,style:{fontSize:12,padding:`4px 8px`,borderRadius:4,background:`var(--semi-color-fill-1)`,wordBreak:`break-all`},children:E.install_command}),(0,G.jsx)(fe,{text:E.install_command,label:l(`common.copy`,null,`复制`)})]}),(0,G.jsxs)(c,{wrap:!0,children:[r&&s&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,icon:(0,G.jsx)(v,{}),onClick:()=>s({driver:T?.driver,probe:E,hostOS:e.host_os,hostArch:e.host_arch,pluginTitle:w.metadata?.title||w.metadata?.id}),children:l(`pluginHub.askAgentInstallDriver`,null,`交给 CSAI Agent 自动安装配置`)}),E.download_url&&(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(u,{}),onClick:()=>window.open(E.download_url,`_blank`,`noopener,noreferrer`),children:l(`pluginHub.officialDownload`,null,`官方下载`)}),(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(M,{}),loading:x,onClick:async()=>{if(C&&T?.driver){S(!0);try{let e=await W.probes(C.isolation||`standard`),t=(w?.distribution||[]).some(e=>e.type===T.driver&&e.mode===`compose`),n=T.driver===`container`&&t?`compose`:T.driver,r=e?.drivers?.[n]||e?.drivers?.[T.driver];r&&(b(r),r.available&&B(l(`pluginHub.driverNowReady`,null,`运行驱动已就绪,可以继续一键安装`)))}catch(e){L(H(l,e))}finally{S(!1)}}},children:l(`pluginHub.recheckDriver`,null,`重新检测`)})]})]})}),!e.can_confirm&&(0,G.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,description:l(`pluginHub.hostApprovalRequiredBanner`,null,`当前宿主开启了 host_config_only 策略,需要先将下方 Manifest 与制品摘要写入 config.yaml 的 plugins.approved_artifacts 后方可安装。`)}),(0,G.jsx)(R,{columns:2,items:[{label:l(`pluginHub.pluginTitle`,null,`插件名称`),value:`${w.metadata?.title||w.metadata?.id} (${w.metadata?.version||`—`})`},{label:l(`pluginHub.repository`,null,`原作者仓库`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:w.metadata?.repository})},{label:l(`pluginHub.driver`,null,`运行驱动`),value:U(l,T?.driver)},{label:l(`pluginHub.isolation`,null,`隔离档位`),value:C.isolation},{label:l(`pluginHub.platform`,null,`目标平台`),value:`${C.platform?.os}/${C.platform?.arch}`},{label:l(`pluginHub.approvalPolicy`,null,`审批策略`),value:e.approval_policy||`admin_confirm`},{label:`Manifest SHA-256`,value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:C.manifestSha256})},{label:l(`pluginHub.artifactDigest`,null,`锁定制品摘要`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:e.artifact_digest})}]}),T?.driver===`git`&&(0,G.jsx)(R,{columns:1,items:[{label:l(`pluginHub.lockedCommit`,null,`锁定 Git Commit`),value:(0,G.jsxs)(`span`,{className:`cs-ph-mono`,children:[T.commit,` (`,T.requestedRef,`)`]})}]}),T?.driver===`release`&&(0,G.jsx)(R,{columns:1,items:[{label:l(`pluginHub.lockedReleaseAsset`,null,`锁定 Release 制品`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:T.assetURL})},{label:`SHA-256`,value:(0,G.jsxs)(`span`,{className:`cs-ph-mono`,children:[T.sha256,` (`,T.verification,`)`]})}]}),T?.driver===`container`&&Array.isArray(T.services)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,children:l(`pluginHub.lockedImages`,null,`锁定容器镜像 Digest`)}),(0,G.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:6},children:T.services.map(e=>(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsxs)(c,{children:[(0,G.jsx)(d,{color:`blue`,size:`small`,children:e.name}),(0,G.jsx)(K,{size:`small`,className:`cs-ph-mono`,children:e.requestedImage})]}),(0,G.jsxs)(K,{type:`tertiary`,size:`small`,className:`cs-ph-mono`,children:[e.repository,`@`,e.manifestDigest]})]},e.name))})]}),(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsx)(K,{strong:!0,children:l(`pluginHub.declaredPermissions`,null,`声明权限摘要`)}),(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsxs)(d,{color:w.permissions?.persistentData?`amber`:`grey`,children:[l(`pluginHub.permPersistentData`,null,`持久化数据卷`),`: `,w.permissions?.persistentData?`Yes`:`No`]}),(0,G.jsxs)(d,{color:w.permissions?.modelGateway?`blue`:`grey`,children:[l(`pluginHub.permModelGateway`,null,`CSAI 模型网关`),`: `,w.permissions?.modelGateway?`Yes`:`No`]}),(w.permissions?.egress||[]).map(e=>(0,G.jsx)(d,{color:`purple`,children:e},e))]})]}),O&&(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsx)(f,{checked:m,onChange:e=>h(!!e.target.checked),children:l(`pluginHub.autoBindDefaultLLM`,null,`安装时自动复用 CSAI 默认模型通道(开箱即用,不泄露真实上游 API Key)`)}),k?(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:ee?l(`pluginHub.defaultChannelMatch`,{name:`${k.name} (${k.model})`},`当前默认通道:${k.name} (${k.model}),协议匹配,启动即自动注入。`):l(`pluginHub.defaultChannelMismatch`,{name:`${k.name} (${k.protocol})`},`当前默认通道 ${k.name} (${k.protocol}) 与该插件声明协议不同,安装后可在插件设置中指定通道。`)}):(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:l(`pluginHub.noDefaultChannelHint`,null,`尚未在 CSAI 系统设置中配置模型通道,安装后可随时在插件详情中绑定模型。`)})]}),(0,G.jsx)(he,{value:w,collapsed:!0,title:`Manifest`})]})})}function Ae({visible:e,onCancel:t,onSaved:n}){let r=P(),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(``),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(!1);(0,V.useEffect)(()=>{e&&(a(``),s(``),u(``),f(``),_(``),y(``))},[e]);let w=e=>{let t=String(e||``).trim().replace(/\.git$/i,``).replace(/\/+$/,``).split(`/`).pop()||``;return{seg:t,slug:t.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)}};return(0,G.jsx)(le,{title:r(`pluginHub.addCatalogTitle`,null,`新增能力市场插件`),visible:e,onCancel:t,width:680,footer:(0,G.jsxs)(c,{children:[(0,G.jsx)(p,{onClick:t,children:r(`common.cancel`,null,`取消`)}),(0,G.jsx)(p,{theme:`solid`,type:`primary`,loading:S,onClick:async()=>{if(!i.trim()&&!v.trim())L(r(`pluginHub.catalogRepoRequired`,null,`请填写 GitHub 仓库地址或提供 Manifest`));else{C(!0);try{let e=await W.saveCatalog({id:l.trim(),title:d.trim(),repository:i.trim(),revision:o.trim(),summary:g.trim(),manifest:v.trim()});B(r(`pluginHub.catalogSaved`,null,`已保存到能力市场`)),n?.(e?.item)}catch(e){L(H(r,e,r(`pluginHub.catalogSaveFailed`,null,`保存到能力市场失败`)))}finally{C(!1)}}},children:r(`pluginHub.saveToMarket`,null,`保存到能力市场`)})]}),children:(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,children:[(0,G.jsx)(q,{type:`tertiary`,style:{margin:0},children:r(`pluginHub.addCatalogDesc`,null,`将公开 GitHub 仓库收录到本机能力市场。留空 Manifest 将以「支持探测导入」模式展示;提供合法 YAML/JSON Manifest 后将直接支持「一键下载安装」。`)}),(0,G.jsxs)(c,{style:{width:`100%`},align:`end`,wrap:!0,children:[(0,G.jsxs)(`div`,{style:{flex:2,minWidth:260},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.repositoryURL`,null,`GitHub 仓库地址`)}),(0,G.jsx)(h,{value:i,onChange:e=>{a(e);let{seg:t,slug:n}=w(e);!l&&n&&/^[a-z]/.test(n)&&u(n),!d&&t&&f(t)},placeholder:`https://github.com/owner/repo`,style:{marginTop:4}})]}),(0,G.jsxs)(`div`,{style:{flex:1,minWidth:130},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.revisionOptional`,null,`分支 / Tag(可选)`)}),(0,G.jsx)(h,{value:o,onChange:s,placeholder:`main / v1.0.0`,style:{marginTop:4}})]}),(0,G.jsx)(p,{loading:b,onClick:async()=>{if(i.trim()){x(!0);try{let e=(await W.inspectGit(i,o))?.inspection;if(e?.repository&&a(e.repository),e?.manifest){let t=e.manifest;t.metadata?.id&&u(t.metadata.id),t.metadata?.title&&f(t.metadata.title),t.metadata?.summary&&_(t.metadata.summary),y(JSON.stringify(t,null,2)),B(r(`pluginHub.catalogProbeWithManifest`,null,`已探测到仓库自带 Manifest,保存后支持一键安装`))}else{let{seg:t,slug:n}=w(e?.repository||i);!l&&n&&/^[a-z]/.test(n)&&u(n),!d&&t&&f(t),B(r(`pluginHub.catalogProbeSuccess`,null,`仓库只读探测完成,已自动填充基础信息`))}}catch(e){L(H(r,e,r(`pluginHub.inspectFailed`,null,`探测仓库失败`)))}finally{x(!1)}}},disabled:!i.trim(),children:r(`pluginHub.probeAndFill`,null,`探测并自动填充`)})]}),(0,G.jsxs)(c,{style:{width:`100%`},wrap:!0,children:[(0,G.jsxs)(`div`,{style:{flex:1,minWidth:220},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.pluginId`,null,`插件标识 ID`)}),(0,G.jsx)(h,{value:l,onChange:u,placeholder:`my-security-tool`,style:{marginTop:4}})]}),(0,G.jsxs)(`div`,{style:{flex:1,minWidth:220},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.pluginTitle`,null,`显示名称`)}),(0,G.jsx)(h,{value:d,onChange:f,placeholder:`My Security Tool`,style:{marginTop:4}})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.catalogSummaryLabel`,null,`功能简介`)}),(0,G.jsx)(h,{value:g,onChange:_,placeholder:r(`pluginHub.catalogSummaryPlaceholder`,null,`简述该开源安全工具的用途、架构或特性`),style:{marginTop:4}})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:r(`pluginHub.catalogManifestOptional`,null,`插件 Manifest(可选,支持 YAML 或 JSON)`)}),(0,G.jsx)(m,{className:`cs-ph-code-editor`,value:v,onChange:y,placeholder:r(`pluginHub.catalogManifestPlaceholder`,null,`可选:粘贴 csai-plugin.yaml 或 JSON 声明;点击上方「探测并自动填充」可自动抓取仓库根目录的 csai-plugin.yaml`),autosize:{minRows:8,maxRows:18},style:{marginTop:4}})]})]})})}function je({visible:e,initialEntry:t,onCancel:n,onPlanReady:r,onCatalogSaved:i}){let a=P(),[o,s]=(0,V.useState)(``),[l,u]=(0,V.useState)(``),[f,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)(`auto`),[C,w]=(0,V.useState)(`standard`),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)(!1);(0,V.useEffect)(()=>{e&&t?.repository&&(s(t.repository),u(t.revision||``),v(null),b(``))},[e,t]);let k=async()=>{if(o.trim()){g(!0),v(null);try{let e=await W.inspectGit(o,l);v(e),e?.inspection?.manifest?b(JSON.stringify(e.inspection.manifest,null,2)):b(Te(e?.inspection)),B(a(`pluginHub.inspectSucceeded`,null,`仓库只读探测完成`))}catch(e){L(H(a,e,a(`pluginHub.inspectFailed`,null,`探测仓库失败`)))}finally{g(!1)}}},ee=async()=>{if(!_?.id)return;let e;try{e=JSON.parse(y)}catch{L(a(`pluginHub.manifestJsonInvalid`,null,`Manifest 草案需为合法 JSON 格式`));return}E(!0);try{let t=await W.createPlan({inspection_id:_.id,manifest:e,driver:x,isolation:C});r?.(t)}catch(e){L(H(a,e,a(`pluginHub.createPlanFailed`,null,`生成锁定安装计划失败`)))}finally{E(!1)}},A=async()=>{if(_?.inspection){O(!0);try{await W.saveCatalog({repository:_.inspection.repository||o.trim(),revision:l.trim(),manifest:y.trim()}),B(a(`pluginHub.catalogSaved`,null,`已保存到能力市场`)),i?.()}catch(e){L(H(a,e,a(`pluginHub.catalogSaveFailed`,null,`保存到能力市场失败`)))}finally{O(!1)}}},j=_?.inspection;return(0,G.jsx)(le,{title:a(`pluginHub.importTitle`,null,`手工导入 Git 仓库插件`),visible:e,onCancel:n,width:720,footer:(0,G.jsxs)(c,{children:[(0,G.jsx)(p,{onClick:n,children:a(`common.cancel`,null,`取消`)}),(0,G.jsx)(p,{loading:D,disabled:!_?.inspection||!y.trim(),onClick:A,children:a(`pluginHub.saveToMarket`,null,`保存到能力市场`)}),(0,G.jsx)(p,{theme:`solid`,type:`primary`,loading:T,disabled:!_?.id||!y.trim(),onClick:ee,children:a(`pluginHub.generatePlan`,null,`生成锁定安装计划`)})]}),children:(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,children:[(0,G.jsx)(q,{type:`tertiary`,style:{margin:0},children:a(`pluginHub.importDesc`,null,`输入公开 GitHub HTTPS 仓库地址后,CSAI 会以只读方式解析 Commit、根目录 csai-plugin.yaml 及构建/容器线索,不会执行任何第三方代码。`)}),(0,G.jsxs)(c,{style:{width:`100%`},align:`end`,wrap:!0,children:[(0,G.jsxs)(`div`,{style:{flex:2,minWidth:280},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:a(`pluginHub.repositoryURL`,null,`GitHub 仓库地址`)}),(0,G.jsx)(h,{value:o,onChange:s,placeholder:`https://github.com/owner/repo`,style:{marginTop:4}})]}),(0,G.jsxs)(`div`,{style:{flex:1,minWidth:140},children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:a(`pluginHub.revisionOptional`,null,`分支 / Tag / Commit(可选)`)}),(0,G.jsx)(h,{value:l,onChange:u,placeholder:`main / v1.0.0`,style:{marginTop:4}})]}),(0,G.jsx)(p,{theme:`solid`,type:`primary`,loading:f,onClick:k,children:a(`pluginHub.inspectRepo`,null,`只读探测`)})]}),j&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsx)(R,{columns:2,items:[{label:a(`pluginHub.repository`,null,`标准化仓库`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:j.repository})},{label:a(`pluginHub.resolvedRef`,null,`解析引用`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:j.resolved_ref})},{label:`Commit`,value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:j.commit})},{label:a(`pluginHub.detectedCandidates`,null,`候选驱动`),value:(j.candidates||[]).map(e=>(0,G.jsx)(d,{size:`small`,style:{marginInlineEnd:4},children:e},e))}]}),j.evidence?.length>0&&(0,G.jsxs)(c,{wrap:!0,style:{marginTop:6},children:[(0,G.jsxs)(K,{size:`small`,type:`tertiary`,children:[a(`pluginHub.detectedFiles`,null,`检测到文件`),`:`]}),j.evidence.map(e=>(0,G.jsx)(d,{size:`small`,color:`cyan`,children:e},e))]}),j.release?.tag&&(0,G.jsxs)(K,{size:`small`,type:`tertiary`,children:[`Release `,j.release.tag,`: `,(j.release.assets||[]).slice(0,6).join(`, `)||`—`]})]}),(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:a(`pluginHub.driver`,null,`安装驱动`)}),(0,G.jsx)(ie,{value:x,onChange:S,style:{width:240,display:`block`,marginTop:4},optionList:[{value:`auto`,label:U(a,`auto`)},{value:`release`,label:U(a,`release`)},{value:`git`,label:U(a,`git`)},{value:`container`,label:U(a,`container`)}]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:a(`pluginHub.isolation`,null,`隔离档位`)}),(0,G.jsx)(ie,{value:C,onChange:w,style:{width:200,display:`block`,marginTop:4},optionList:[{value:`standard`,label:a(`pluginHub.isolationStandard`,null,`standard(非 root 单机默认)`)},{value:`strict`,label:a(`pluginHub.isolationStrict`,null,`strict(强制容器隔离)`)}]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(c,{style:{justifyContent:`space-between`,width:`100%`,marginBottom:4},children:(0,G.jsx)(K,{strong:!0,size:`small`,children:j.manifest?a(`pluginHub.manifestFromRepo`,null,`已从仓库读取 csai-plugin.yaml(可审阅)`):a(`pluginHub.manifestDraftLabel`,null,`仓库无自带 Manifest,请编辑以下接入草案(JSON)`)})}),(0,G.jsx)(m,{className:`cs-ph-code-editor`,value:y,onChange:b,autosize:{minRows:12,maxRows:22}})]})]})]})})}function Me({installId:e,initialTab:t=`overview`,visible:n,canManage:r,canUseAgent:i,channels:o,onCancel:s,onRestartRequested:l,onChanged:u,onAskAgentTroubleshoot:f}){let m=P(),[h,g]=(0,V.useState)(t),[_,y]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1),[T,D]=(0,V.useState)(`follow_default`),[O,k]=(0,V.useState)(``),[ee,A]=(0,V.useState)(4),[j,te]=(0,V.useState)(60),[ne,N]=(0,V.useState)(2e6),[ae,oe]=(0,V.useState)(!1),[se,F]=(0,V.useState)(!1),[ce,I]=(0,V.useState)([]),[ue,de]=(0,V.useState)(!1),pe=(0,V.useRef)(null),z=(0,V.useRef)(null);(0,V.useEffect)(()=>{n&&g(t||`overview`)},[n,t,e]);let me=async()=>{if(e){S(!0);try{let t=await W.getInstall(e);y(t);let n=Array.isArray(t?.llm_bindings)?t.llm_bindings[0]:null;n?(D(n.mode||`follow_default`),k(n.channel_id||``),A(n.concurrency||4),te(n.rpm||60),N(n.token_budget||2e6)):(D(`follow_default`),k(``)),F(!1)}catch(e){L(H(m,e))}finally{S(!1)}}};(0,V.useEffect)(()=>{n&&e&&me()},[n,e]),(0,V.useEffect)(()=>{if(!n||!e||h!==`logs`||!r){z.current?.(),z.current=null,de(!1);return}let t=!0;return I([]),(async()=>{try{let n=await W.readLogs(e,0,200);if(!t)return;let r=Array.isArray(n?.items)?n.items:[];I(r),de(!0),z.current=we(e,{after:n?.next_cursor||0,onEntry:e=>{I(t=>[...t.slice(-499),e])},onClose:()=>de(!1),onError:()=>de(!1)})}catch(e){t&&L(H(m,e))}})(),()=>{t=!1,z.current?.(),z.current=null,de(!1)}},[n,e,h,r]),(0,V.useEffect)(()=>{pe.current&&(pe.current.scrollTop=pe.current.scrollHeight)},[ce]);let he=async()=>{if(e){oe(!0);try{let t={mode:T,channel_id:T===`channel`?O:``,limits:{concurrency:Number(ee)||4,rpm:Number(j)||60,token_budget:Number(ne)||2e6}},n=await W.patchLLM(e,t);B(m(`pluginHub.llmSaved`,null,`模型通道绑定已更新`)),F(!!n?.restart_required),await me(),u?.()}catch(e){L(H(m,e,m(`pluginHub.llmSaveFailed`,null,`保存模型配置失败`)))}finally{oe(!1)}}},ge=(0,V.useMemo)(()=>new Set((_?.llm_declared?.bindings||[]).map(e=>e.protocol)),[_]),_e=(0,V.useMemo)(()=>(o||[]).filter(e=>ge.size===0||ge.has(e.protocol)),[o,ge]),ve=(0,V.useMemo)(()=>ce.map(e=>`[${e.created_at||``}] ${e.line}`).join(`
|
||
`),[ce]);return(0,G.jsxs)(le,{title:_?.title||_?.plugin_id||m(`pluginHub.detailTitle`,null,`插件详情`),visible:n,onCancel:s,width:760,children:[(0,G.jsxs)(b,{activeKey:h,onChange:g,children:[(0,G.jsx)(w,{tab:m(`pluginHub.tabOverview`,null,`概览与权限`),itemKey:`overview`,children:_&&(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,style:{marginTop:12},children:[(_.observed_state===`failed`||_.observed_state===`degraded`)&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,title:H(m,_.last_error_code,m(`pluginHub.errorInstallFailed`,null,`插件安装或运行异常`)),description:(0,G.jsxs)(c,{wrap:!0,style:{marginTop:4},children:[i&&f&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,icon:(0,G.jsx)(v,{}),onClick:()=>f(_),children:m(`pluginHub.askAgentTroubleshoot`,null,`交给 CSAI Agent 排错并修复`)}),r&&(0,G.jsx)(p,{size:`small`,onClick:()=>g(`logs`),children:m(`pluginHub.viewLogs`,null,`查看运行日志`)})]})}),(0,G.jsx)(R,{columns:2,items:[{label:m(`pluginHub.installId`,null,`实例 ID`),value:(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:_.id})},{label:m(`pluginHub.pluginId`,null,`插件标识`),value:_.plugin_id},{label:m(`pluginHub.version`,null,`版本`),value:_.version||`—`},{label:m(`pluginHub.driver`,null,`驱动`),value:U(m,_.driver)},{label:m(`pluginHub.observedState`,null,`运行状态`),value:(0,G.jsx)(d,{color:Se(_.observed_state),children:Ce(m,_.observed_state)})},{label:m(`pluginHub.proxyMode`,null,`代理隔离模式`),value:_.proxy_mode||`port`},{label:m(`pluginHub.repository`,null,`源码仓库`),value:_.repository?(0,G.jsx)(`span`,{className:`cs-ph-mono`,children:_.repository}):`—`},{label:m(`pluginHub.lastError`,null,`最近错误`),value:_.last_error_code||`—`}]}),_.summary&&(0,G.jsx)(q,{type:`tertiary`,children:_.summary}),_.permissions&&(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsx)(K,{strong:!0,children:m(`pluginHub.declaredPermissions`,null,`声明权限`)}),(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsxs)(d,{children:[m(`pluginHub.permPersistentData`,null,`持久化数据卷`),`: `,_.permissions.persistentData?`Yes`:`No`]}),(0,G.jsxs)(d,{children:[m(`pluginHub.permModelGateway`,null,`CSAI 模型网关`),`: `,_.permissions.modelGateway?`Yes`:`No`]}),(_.permissions.egress||[]).map(e=>(0,G.jsx)(d,{color:`purple`,children:e},e))]})]}),_.extensions?.capabilities?.length>0&&(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsx)(K,{strong:!0,children:m(`pluginHub.declaredExtensions`,null,`声明的扩展能力(MCP / OpenAPI 预留)`)}),(0,G.jsx)(c,{wrap:!0,children:_.extensions.capabilities.map(e=>(0,G.jsxs)(d,{color:`cyan`,children:[e.id,` (`,e.transport,` `,e.path,`)`]},e.id))})]})]})}),_?.llm_declared&&(0,G.jsx)(w,{tab:m(`pluginHub.tabLLM`,null,`CSAI 模型绑定`),itemKey:`llm`,children:(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,style:{marginTop:12},children:[se&&(0,G.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,description:(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsx)(`span`,{children:m(`pluginHub.restartRequiredForLLM`,null,`模型绑定已更新,重启插件后将立即注入新的 CSAI 网关凭据。`)}),r&&l&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,onClick:()=>l(_),children:m(`pluginHub.restartNow`,null,`立即重启生效`)})]})}),(0,G.jsx)(q,{type:`tertiary`,style:{margin:0},children:m(`pluginHub.llmBindingDesc`,null,`CSAI 通过本地模型网关向插件注入隔离 Token 与通道配置,插件无法接触您的真实上游 API Key。`)}),(0,G.jsxs)(C,{value:T,onChange:e=>D(e.target.value),disabled:!r,children:[(0,G.jsx)(E,{value:`follow_default`,children:m(`pluginHub.llmModeFollowDefault`,null,`跟随 CSAI 默认模型通道`)}),(0,G.jsx)(E,{value:`channel`,children:m(`pluginHub.llmModeChannel`,null,`指定 CSAI 模型通道`)}),(0,G.jsx)(E,{value:`disabled`,children:m(`pluginHub.llmModeDisabled`,null,`关闭模型托管`)})]}),T===`channel`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{strong:!0,size:`small`,children:m(`pluginHub.selectChannel`,null,`选择兼容通道`)}),(0,G.jsx)(ie,{value:O,onChange:k,disabled:!r,style:{width:`100%`,marginTop:4},placeholder:m(`pluginHub.selectChannelPlaceholder`,null,`请选择在 CSAI 系统设置中配置的模型通道`),optionList:_e.map(e=>({value:e.id,label:`${e.name} (${e.model} · ${e.provider})${e.is_default?` [Default]`:``}`}))})]}),T!==`disabled`&&(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{size:`small`,type:`tertiary`,children:m(`pluginHub.limitConcurrency`,null,`并发上限`)}),(0,G.jsx)(re,{value:ee,onChange:A,min:1,max:32,disabled:!r,style:{display:`block`,marginTop:4}})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{size:`small`,type:`tertiary`,children:m(`pluginHub.limitRPM`,null,`每分钟请求 (RPM)`)}),(0,G.jsx)(re,{value:j,onChange:te,min:1,max:1e3,disabled:!r,style:{display:`block`,marginTop:4}})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{size:`small`,type:`tertiary`,children:m(`pluginHub.limitTokenBudget`,null,`每日 Token 预算`)}),(0,G.jsx)(re,{value:ne,onChange:N,min:1e3,step:1e5,disabled:!r,style:{display:`block`,marginTop:4,width:180}})]})]}),r&&(0,G.jsx)(`div`,{children:(0,G.jsx)(p,{theme:`solid`,type:`primary`,loading:ae,onClick:he,children:m(`pluginHub.saveLLM`,null,`保存模型配置`)})})]})}),r&&(0,G.jsx)(w,{tab:m(`pluginHub.logs`,null,`运行日志`),itemKey:`logs`,children:(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,style:{marginTop:12},children:[(0,G.jsxs)(c,{style:{justifyContent:`space-between`,width:`100%`},children:[(0,G.jsxs)(c,{children:[(0,G.jsx)(d,{color:ue?`green`:`grey`,children:ue?m(`pluginHub.logStreaming`,null,`SSE 实时追踪中`):m(`pluginHub.logPaused`,null,`已停止追踪`)}),(0,G.jsxs)(K,{size:`small`,type:`tertiary`,children:[ce.length,` lines`]})]}),(0,G.jsxs)(c,{children:[(0,G.jsx)(fe,{text:ve,label:m(`common.copy`,null,`复制`)}),(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(M,{}),onClick:()=>g(`overview`)||setTimeout(()=>g(`logs`),0),children:m(`common.refresh`,null,`刷新`)})]})]}),(0,G.jsx)(`pre`,{ref:pe,className:`cs-ph-log-box`,children:ve||m(`pluginHub.noLogs`,null,`暂无运行日志`)})]})})]}),x&&!_&&(0,G.jsx)(K,{type:`tertiary`,children:m(`common.loading`,null,`加载中…`)})]})}function Ne({visible:e,canUseAgent:t,onCancel:n,onAskAgentDriverFix:r}){let i=P(),[o,s]=(0,V.useState)(`standard`),[l,f]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),g=async(e=o)=>{h(!0);try{let t=await W.probes(e);f(t)}catch(e){L(H(i,e))}finally{h(!1)}};return(0,V.useEffect)(()=>{e&&g(o)},[e,o]),(0,G.jsx)(le,{title:i(`pluginHub.runtimeProbesTitle`,null,`宿主运行环境与驱动预检`),visible:e,onCancel:n,width:660,children:(0,G.jsxs)(`div`,{className:`cs-ph-drawer-stack`,children:[(0,G.jsxs)(c,{style:{justifyContent:`space-between`,width:`100%`},wrap:!0,children:[(0,G.jsxs)(C,{type:`button`,value:o,onChange:e=>s(e.target.value),children:[(0,G.jsx)(E,{value:`standard`,children:`standard`}),(0,G.jsx)(E,{value:`strict`,children:`strict`})]}),(0,G.jsx)(p,{icon:(0,G.jsx)(M,{}),loading:m,onClick:()=>g(o),children:i(`common.refresh`,null,`重新检测`)})]}),l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(R,{columns:2,items:[{label:i(`pluginHub.hostPlatform`,null,`宿主平台`),value:`${l.os}/${l.arch}`},{label:i(`pluginHub.workerReady`,null,`运行调度器`),value:(0,G.jsx)(d,{color:l.execution_enabled?`green`:`amber`,children:l.execution_enabled?i(`pluginHub.ready`,null,`就绪`):i(`pluginHub.notReady`,null,`未就绪`)})}]}),Object.entries(l.drivers||{}).map(([e,n])=>(0,G.jsxs)(`div`,{className:`cs-ph-probe-card`,children:[(0,G.jsxs)(c,{style:{justifyContent:`space-between`,width:`100%`},children:[(0,G.jsx)(K,{strong:!0,children:U(i,e)}),(0,G.jsx)(d,{color:n.available?`green`:`red`,prefixIcon:n.available?(0,G.jsx)(A,{}):(0,G.jsx)(te,{}),children:n.available?i(`pluginHub.available`,null,`可用`):n.code||i(`pluginHub.unavailable`,null,`不可用`)})]}),!n.available&&n.code&&(0,G.jsx)(K,{type:`danger`,size:`small`,children:H(i,n.code,n.guidance)}),n.guidance&&(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:n.guidance}),!n.available&&n.install_command&&(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flexWrap:`wrap`,marginTop:4},children:[(0,G.jsx)(`code`,{className:`cs-ph-mono`,style:{fontSize:12,padding:`4px 8px`,borderRadius:4,background:`var(--semi-color-fill-1)`,wordBreak:`break-all`},children:n.install_command}),(0,G.jsx)(fe,{text:n.install_command,label:i(`common.copy`,null,`复制`)})]}),!n.available&&(t||n.download_url)&&(0,G.jsxs)(c,{wrap:!0,style:{marginTop:6},children:[t&&r&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,icon:(0,G.jsx)(v,{}),onClick:()=>r({driver:e,probe:n,hostOS:l.os,hostArch:l.arch}),children:i(`pluginHub.askAgentInstallDriver`,null,`交给 CSAI Agent 自动安装配置`)}),n.download_url&&(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(u,{}),onClick:()=>window.open(n.download_url,`_blank`,`noopener,noreferrer`),children:i(`pluginHub.officialDownload`,null,`官方下载`)})]})]},e)),l.drivers?.container&&!l.drivers.container.available&&(0,G.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,description:l.os===`linux`?i(`pluginHub.dockerInstallLinuxHint`,null,`Linux / Kali 宿主可直接点击上方「交给 CSAI Agent 自动安装配置」,或手动安装 docker.io 与 docker-compose-plugin 并启动 dockerd,完成后点击「重新检测」。`):i(`pluginHub.dockerInstallDesktopHint`,null,`macOS / Windows 可点击「官方下载」安装并启动 Docker Desktop(或交给 Agent 通过 Homebrew/winget 协助安装),也可优先选择 Release / Git 原生驱动。`)})]})]})})}var{Text:J,Paragraph:Pe}=s;function Y(){let e=P(),t=n(),{hasPermission:r}=se(),s=r(`plugins:manage`),m=r(`plugins:use`),g=r(`chat:write`)&&r(`agent:execute`),[_,y]=i(),C=_.get(`app`)||``,E=_.get(`tab`)||`installed`,[A,re]=(0,V.useState)(``),[ie,N]=(0,V.useState)(!1),[ae,F]=(0,V.useState)(null),[le,R]=(0,V.useState)(!1),[fe,he]=(0,V.useState)(!1),[ve,ye]=(0,V.useState)(!1),[we,Te]=(0,V.useState)(null),[Ee,De]=(0,V.useState)(``),[K,q]=(0,V.useState)(null),[Y,Fe]=(0,V.useState)(null),[Ie,Le]=(0,V.useState)(``),X=I(()=>W.listInstalls(),[]),Z=I(()=>W.listCatalog(),[]),Re=I(()=>W.listLLMChannels(),[]),Q=I(()=>W.probes(`standard`),[],{skip:!s}),$=Array.isArray(X.data?.items)?X.data.items:[],ze=Array.isArray(Z.data?.items)?Z.data.items:[],Be=Number(Z.data?.hidden_builtins||0),Ve=Array.isArray(Re.data?.channels)?Re.data.channels:[],He=(0,V.useMemo)(()=>$.find(e=>e.id===C)||null,[$,C]),Ue=e=>{let t=new URLSearchParams(_);t.set(`tab`,e),t.delete(`app`),y(t,{replace:!0})},We=e=>{let t=new URLSearchParams(_);t.set(`tab`,`installed`),t.set(`app`,e.id),y(t)},Ge=()=>{let e=new URLSearchParams(_);e.delete(`app`),y(e,{replace:!0})},Ke=(0,V.useCallback)(()=>{X.reload({silent:!0}),Z.reload({silent:!0}),Re.reload({silent:!0})},[X,Z,Re]);z(async()=>{if(Y?.id&&s)try{let t=await W.getOperation(Y.id);Fe(t),t.status!==`queued`&&t.status!==`running`&&(X.reload({silent:!0}),t.status===`succeeded`?B(e(`pluginHub.opSucceeded`,{kind:t.kind},`操作 ${t.kind} 已完成`)):t.status===`failed`&&L(e(`pluginHub.opFailed`,{kind:t.kind},`操作 ${t.kind} 失败,请查看插件日志`)))}catch{}},Y&&(Y.status===`queued`||Y.status===`running`)?1500:null);let qe=$.some(e=>[`installing`,`starting`,`stopping`].includes(e.observed_state));z(()=>{X.reload({silent:!0})},qe?3e3:null);let Je=async t=>{if(t.availability!==`plan_available`)F({repository:t.repository,revision:t.revision||``}),N(!0);else{De(t.id);try{let e=await W.createPlan({catalog_id:t.id,driver:`auto`,isolation:`standard`});Te(e)}catch(t){L(H(e,t,e(`pluginHub.createPlanFailed`,null,`生成安装计划失败`)))}finally{De(``)}}},Ye=t=>{ge({title:e(`pluginHub.confirmDeleteCatalogTitle`,{name:t.title||t.id},`从能力市场移除「${t.title||t.id}」?`),content:(0,G.jsx)(J,{type:`tertiary`,children:t.builtin?e(`pluginHub.confirmHideBuiltinDesc`,null,`该条目为内置精选目录项,移除后将在市场中隐藏,可随时通过「恢复默认精选」找回;不会影响已安装的实例。`):e(`pluginHub.confirmDeleteCustomDesc`,null,`将从能力市场永久删除该自定义条目,不会影响已安装的插件实例。`)}),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await W.deleteCatalog(t.id),B(e(`pluginHub.catalogDeleted`,null,`已从能力市场移除`)),Z.reload({silent:!0})}catch(t){L(H(e,t,e(`pluginHub.catalogDeleteFailed`,null,`删除市场条目失败`)))}}})},Xe=async()=>{he(!0);try{await W.restoreCatalog(),B(e(`pluginHub.catalogRestored`,null,`已恢复全部默认精选目录`)),Z.reload({silent:!0})}catch(t){L(H(e,t,e(`pluginHub.catalogRestoreFailed`,null,`恢复默认精选失败`)))}finally{he(!1)}},Ze=(0,V.useCallback)(({driver:n,probe:r,hostOS:i,hostArch:a,pluginTitle:o})=>{let s=be({driver:n,probe:r,hostOS:i||Q.data?.os,hostArch:a||Q.data?.arch,pluginTitle:o});_e({prompt:s,autoSend:!0}),ye(!1),Te(null),B(e(`pluginHub.handoffToAgent`,null,`已将安装任务交给 CSAI Agent,正在跳转对话工作台…`)),t(`/chat`)},[t,Q.data?.arch,Q.data?.os,e]),Qe=(0,V.useCallback)(async n=>{let r=[];try{let e=await W.readLogs(n.id,0,50);r=Array.isArray(e?.items)?e.items:[]}catch{}let i=xe({install:n,logs:r,hostOS:Q.data?.os,hostArch:Q.data?.arch});_e({prompt:i,autoSend:!0}),q(null),B(e(`pluginHub.handoffTroubleshoot`,null,`已将排错与修复任务交给 CSAI Agent,正在跳转对话工作台…`)),t(`/chat`)},[t,Q.data?.arch,Q.data?.os,e]),$e=async(t,n,r={})=>{Le(t.id);try{let i=await W.operate(t.id,n,r);Fe(i),B(e(`pluginHub.opQueued`,{kind:n},`已提交 ${n} 任务`)),X.reload({silent:!0})}catch(t){L(H(e,t))}finally{Le(``)}},et=t=>{let n=!1;ge({title:e(`pluginHub.confirmUninstallTitle`,{name:t.title||t.plugin_id},`卸载插件「${t.title||t.plugin_id}」?`),content:(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,G.jsx)(J,{type:`tertiary`,children:e(`pluginHub.confirmUninstallDesc`,null,`将停止插件进程/容器、撤销代理会话与模型网关 Token,并退役隔离端口。`)}),(0,G.jsx)(f,{onChange:e=>{n=!!e.target.checked},children:e(`pluginHub.purgeDataOption`,null,`同时删除持久化运行数据与卷(默认保留数据)`)})]}),okText:e(`pluginHub.uninstall`,null,`卸载`),onOk:()=>$e(t,`uninstall`,{purge_data:n})})},tt=(0,V.useMemo)(()=>{let e=A.trim().toLowerCase();return e?$.filter(t=>String(t.title||``).toLowerCase().includes(e)||String(t.plugin_id||``).toLowerCase().includes(e)||String(t.driver||``).toLowerCase().includes(e)):$},[$,A]),nt=(0,V.useMemo)(()=>{let e=A.trim().toLowerCase();return e?ze.filter(t=>String(t.title||``).toLowerCase().includes(e)||String(t.id||``).toLowerCase().includes(e)||String(t.summary||``).toLowerCase().includes(e)):ze},[ze,A]),rt=$.filter(e=>e.observed_state===`healthy`).length,it=Q.data?.drivers||{},at=Object.entries(it).filter(([,e])=>e?.available).map(([e])=>e);if(C&&He)return(0,G.jsxs)(`div`,{className:`cs-ph-root`,children:[(0,G.jsx)(Oe,{install:He,canManage:s,onBack:Ge,onOpenDetail:()=>q({id:He.id,tab:`overview`}),onOpenLogs:()=>q({id:He.id,tab:`logs`})}),(0,G.jsx)(Me,{installId:K?.id,initialTab:K?.tab,visible:!!K,canManage:s,canUseAgent:g,channels:Ve,onCancel:()=>q(null),onRestartRequested:e=>$e(e,`restart`),onAskAgentTroubleshoot:Qe,onChanged:Ke})]});let ot=[{title:e(`pluginHub.pluginTitle`,null,`插件应用`),dataIndex:`title`,render:(t,n)=>(0,G.jsxs)(c,{vertical:!0,spacing:2,align:`start`,children:[(0,G.jsxs)(c,{spacing:6,children:[(0,G.jsx)(J,{strong:!0,children:t||n.plugin_id}),(0,G.jsx)(d,{size:`small`,color:`grey`,children:n.plugin_id})]}),n.last_error_code&&(0,G.jsx)(J,{type:`danger`,size:`small`,children:H(e,n.last_error_code,n.last_error_code)})]})},{title:e(`pluginHub.observedState`,null,`运行状态`),dataIndex:`observed_state`,width:130,render:t=>(0,G.jsx)(d,{color:Se(t),shape:`square`,children:Ce(e,t)})},{title:e(`pluginHub.driver`,null,`驱动`),dataIndex:`driver`,width:160,render:t=>U(e,t)},{title:e(`pluginHub.updatedAt`,null,`更新时间`),dataIndex:`updated_at`,width:170,render:e=>oe(e)},{title:e(`common.actions`,null,`操作`),width:300,render:(t,n)=>{let r=n.observed_state===`healthy`,i=Ie===n.id||[`installing`,`starting`,`stopping`].includes(n.observed_state);return(0,G.jsxs)(c,{spacing:4,wrap:!0,children:[m&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,icon:(0,G.jsx)(u,{}),disabled:!r,onClick:()=>We(n),children:e(`pluginHub.openWorkspace`,null,`打开应用`)}),s&&!r&&(0,G.jsx)(D,{content:n.observed_state===`failed`?e(`pluginHub.retryInstallOrStart`,null,`重试安装 / 启动`):e(`pluginHub.start`,null,`启动`),children:(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(k,{}),loading:i,onClick:()=>$e(n,`start`)})}),g&&(n.observed_state===`failed`||n.observed_state===`degraded`)&&(0,G.jsx)(p,{size:`small`,theme:`light`,type:`warning`,icon:(0,G.jsx)(v,{}),onClick:()=>Qe(n),children:e(`pluginHub.agentFixBtn`,null,`Agent 排错`)}),s&&r&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{content:e(`pluginHub.restart`,null,`重启`),children:(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(ne,{}),loading:i,onClick:()=>$e(n,`restart`)})}),(0,G.jsx)(D,{content:e(`pluginHub.stop`,null,`停止`),children:(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(te,{}),loading:i,onClick:()=>$e(n,`stop`)})})]}),s&&(0,G.jsx)(D,{content:e(`pluginHub.logs`,null,`实时日志`),children:(0,G.jsx)(p,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(x,{}),onClick:()=>q({id:n.id,tab:`logs`})})}),(0,G.jsx)(D,{content:e(`pluginHub.settingsAndDetail`,null,`详情与模型绑定`),children:(0,G.jsx)(p,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(O,{}),onClick:()=>q({id:n.id,tab:`overview`})})}),s&&(0,G.jsx)(D,{content:e(`pluginHub.uninstall`,null,`卸载`),children:(0,G.jsx)(p,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,G.jsx)(l,{}),onClick:()=>et(n)})})]})}}];return(0,G.jsxs)(`div`,{className:`cs-ph-root`,children:[(0,G.jsx)(pe,{title:e(`pluginHub.title`,null,`插件化能力平台`),description:e(`pluginHub.subtitle`,null,`按需拉取独立红队与安全开源项目,保留原作者仓库隔离,支持页面无缝内嵌与 CSAI 模型通道统一复用。`),extra:(0,G.jsxs)(c,{wrap:!0,children:[s&&(0,G.jsx)(p,{icon:(0,G.jsx)(ee,{}),onClick:()=>ye(!0),children:e(`pluginHub.runtimeProbes`,null,`运行环境预检`)}),s&&(0,G.jsx)(p,{theme:`solid`,type:`primary`,icon:(0,G.jsx)(S,{}),onClick:()=>N(!0),children:e(`pluginHub.importGit`,null,`手工导入 Git 仓库`)}),(0,G.jsx)(p,{icon:(0,G.jsx)(M,{}),onClick:Ke,loading:X.loading||Z.loading,children:e(`common.refresh`,null,`刷新`)})]})}),(0,G.jsx)(ce,{columns:4,metrics:[{id:`installed`,label:e(`pluginHub.statInstalled`,null,`已安装插件`),value:$.length,icon:(0,G.jsx)(j,{}),onClick:()=>Ue(`installed`)},{id:`healthy`,label:e(`pluginHub.statRunning`,null,`运行中应用`),value:rt,tone:rt>0?`success`:void 0,icon:(0,G.jsx)(k,{}),onClick:()=>Ue(`installed`)},{id:`catalog`,label:e(`pluginHub.statCatalog`,null,`官方精选目录`),value:ze.length,icon:(0,G.jsx)(o,{}),onClick:()=>Ue(`market`)},{id:`drivers`,label:e(`pluginHub.statDrivers`,null,`宿主可用驱动`),value:s&&at.length?at.join(` / `):`—`,detail:Q.data?`${Q.data.os}/${Q.data.arch}`:void 0,icon:(0,G.jsx)(v,{}),onClick:s?()=>ye(!0):void 0}]}),Y&&(0,G.jsx)(a,{type:Y.status===`failed`?`danger`:Y.status===`succeeded`?`success`:`info`,bordered:!0,onClose:()=>Fe(null),description:(0,G.jsxs)(c,{wrap:!0,children:[(0,G.jsxs)(J,{strong:!0,children:[e(`pluginHub.latestOperation`,null,`最近任务`),`: `,Y.kind]}),(0,G.jsx)(d,{size:`small`,color:Y.status===`succeeded`?`green`:Y.status===`failed`?`red`:`blue`,children:Y.status}),s&&Y.install_id&&(0,G.jsx)(p,{size:`small`,theme:`borderless`,onClick:()=>q({id:Y.install_id,tab:`logs`}),children:e(`pluginHub.viewLogs`,null,`查看日志`)})]})}),(0,G.jsxs)(de,{children:[(0,G.jsx)(ue,{error:X.error||Z.error,onRetry:Ke}),(0,G.jsxs)(b,{activeKey:E,onChange:Ue,tabBarExtraContent:(0,G.jsx)(h,{prefix:(0,G.jsx)(T,{}),value:A,onChange:re,placeholder:e(`pluginHub.searchPlaceholder`,null,`搜索插件名称或描述`),style:{width:260},showClear:!0}),children:[(0,G.jsx)(w,{tab:`${e(`pluginHub.tabInstalled`,null,`已安装应用`)} (${$.length})`,itemKey:`installed`,children:(0,G.jsx)(`div`,{style:{marginTop:12},children:(0,G.jsx)(me,{columns:ot,dataSource:tt,loading:X.loading,emptyText:e(`pluginHub.emptyInstalled`,null,`暂未安装插件,可切换到「能力市场」一键下载或手工导入 Git 仓库`)})})}),(0,G.jsxs)(w,{tab:`${e(`pluginHub.marketTitle`,null,`能力市场`)} (${ze.length})`,itemKey:`market`,children:[s&&(0,G.jsxs)(c,{style:{justifyContent:`space-between`,width:`100%`,marginTop:12},wrap:!0,children:[(0,G.jsx)(J,{type:`tertiary`,size:`small`,children:e(`pluginHub.marketManageHint`,null,`支持自由新增开源仓库或删除/隐藏条目;已安装的插件不受市场目录变更影响。`)}),(0,G.jsxs)(c,{wrap:!0,children:[Be>0&&(0,G.jsx)(p,{size:`small`,icon:(0,G.jsx)(M,{}),loading:fe,onClick:Xe,children:e(`pluginHub.restoreBuiltins`,{count:Be},`恢复默认精选 (${Be})`)}),(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,icon:(0,G.jsx)(S,{}),onClick:()=>R(!0),children:e(`pluginHub.addCatalogBtn`,null,`新增市场插件`)})]})]}),(0,G.jsx)(`div`,{className:`cs-ph-catalog-grid`,style:{marginTop:14},children:nt.length===0?(0,G.jsx)(J,{type:`tertiary`,style:{padding:`16px 0`},children:e(`pluginHub.emptyMarket`,null,`当前能力市场暂无匹配条目,可点击「新增市场插件」添加。`)}):nt.map(t=>{let n=$.find(e=>e.plugin_id===t.id),r=t.availability===`plan_available`;return(0,G.jsxs)(`div`,{className:`cs-ph-card`,children:[(0,G.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,G.jsxs)(`div`,{className:`cs-ph-card-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(c,{spacing:6,children:[(0,G.jsx)(J,{strong:!0,size:`normal`,children:t.title}),!t.builtin&&(0,G.jsx)(d,{size:`small`,color:`violet`,children:e(`pluginHub.catalogCustomBadge`,null,`自定义`)})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(J,{type:`tertiary`,size:`small`,className:`cs-ph-mono`,children:t.id})})]}),(0,G.jsx)(d,{size:`small`,color:r?`green`:`blue`,children:r?e(`pluginHub.catalogOneClick`,null,`支持一键安装`):e(`pluginHub.catalogInspectOnly`,null,`支持探测导入`)})]}),(0,G.jsx)(Pe,{type:`tertiary`,size:`small`,style:{margin:0},children:t.summary||e(`pluginHub.noSummary`,null,`暂无简介`)}),(0,G.jsx)(`div`,{className:`cs-ph-card-meta`,children:(0,G.jsx)(`a`,{href:t.repository,target:`_blank`,rel:`noreferrer`,style:{fontSize:12},children:t.repository.replace(`https://github.com/`,`github.com/`)})})]}),(0,G.jsxs)(`div`,{className:`cs-ph-card-footer`,children:[n?(0,G.jsxs)(d,{color:Se(n.observed_state),children:[e(`pluginHub.installedBadge`,null,`已安装`),` · `,Ce(e,n.observed_state)]}):(0,G.jsx)(J,{type:`tertiary`,size:`small`,children:e(`pluginHub.externalRepoHint`,null,`代码保留在原作者仓库`)}),(0,G.jsxs)(c,{spacing:6,children:[s&&(0,G.jsx)(D,{content:t.builtin?e(`pluginHub.hideBuiltinTooltip`,null,`从市场隐藏`):e(`common.delete`,null,`删除`),children:(0,G.jsx)(p,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,G.jsx)(l,{}),onClick:()=>Ye(t)})}),n&&m&&n.observed_state===`healthy`&&(0,G.jsx)(p,{size:`small`,theme:`solid`,type:`primary`,onClick:()=>We(n),children:e(`pluginHub.openWorkspace`,null,`打开应用`)}),!n&&s&&(0,G.jsx)(p,{size:`small`,theme:r?`solid`:`light`,type:`primary`,icon:(0,G.jsx)(o,{}),loading:Ee===t.id,onClick:()=>Je(t),children:r?e(`pluginHub.oneClickInstall`,null,`一键下载安装`):e(`pluginHub.inspectAndImport`,null,`探测并导入`)})]})]})]},t.id)})})]})]})]}),(0,G.jsx)(Ae,{visible:le,onCancel:()=>R(!1),onSaved:()=>{R(!1),Z.reload({silent:!0})}}),(0,G.jsx)(je,{visible:ie,initialEntry:ae,onCancel:()=>{N(!1),F(null)},onCatalogSaved:()=>Z.reload({silent:!0}),onPlanReady:e=>{N(!1),F(null),Te(e)}}),(0,G.jsx)(ke,{planResponse:we,channels:Ve,visible:!!we,canUseAgent:g,onCancel:()=>Te(null),onAskAgentDriverFix:Ze,onConfirmed:e=>{Te(null),Fe(e),Ue(`installed`),X.reload({silent:!0})}}),(0,G.jsx)(Me,{installId:K?.id,initialTab:K?.tab,visible:!!K,canManage:s,canUseAgent:g,channels:Ve,onCancel:()=>q(null),onRestartRequested:e=>$e(e,`restart`),onAskAgentTroubleshoot:Qe,onChanged:Ke}),(0,G.jsx)(Ne,{visible:ve,canUseAgent:g,onCancel:()=>ye(!1),onAskAgentDriverFix:Ze})]})}export{Y as default}; |