jishushell 0.4.10 → 0.4.24
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/Dockerfile.hermes-slim +193 -0
- package/INSTALL-NOTICE +10 -12
- package/apps/hermes-container.yaml +35 -0
- package/apps/ollama-binary.yaml +200 -0
- package/apps/ollama-cpu-container.yaml +37 -0
- package/apps/ollama-with-hollama-binary.yaml +195 -0
- package/apps/openclaw-binary.yaml +69 -0
- package/apps/openclaw-container.yaml +37 -0
- package/apps/openclaw-with-ollama-container.yaml +42 -0
- package/apps/openclaw-with-searxng-container.yaml +136 -0
- package/apps/openwebui-container.yaml +53 -0
- package/apps/playwright-container.yaml +120 -0
- package/apps/searxng-container.yaml +115 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +15 -14
- package/dist/auth.js.map +1 -1
- package/dist/cli/app.d.ts +4 -0
- package/dist/cli/app.js +814 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/backup.d.ts +3 -0
- package/dist/cli/backup.js +434 -0
- package/dist/cli/backup.js.map +1 -0
- package/dist/{doctor.d.ts → cli/doctor.d.ts} +7 -1
- package/dist/{doctor.js → cli/doctor.js} +377 -22
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/helpers.d.ts +4 -0
- package/dist/cli/helpers.js +32 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/job.d.ts +4 -0
- package/dist/cli/job.js +198 -0
- package/dist/cli/job.js.map +1 -0
- package/dist/cli/llm.d.ts +25 -0
- package/dist/cli/llm.js +599 -0
- package/dist/cli/llm.js.map +1 -0
- package/dist/cli/managed-list.d.ts +30 -0
- package/dist/cli/managed-list.js +129 -0
- package/dist/cli/managed-list.js.map +1 -0
- package/dist/cli/panel.d.ts +26 -0
- package/dist/cli/panel.js +804 -0
- package/dist/cli/panel.js.map +1 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +12 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli.js +48 -776
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +69 -0
- package/dist/config.js +268 -7
- package/dist/config.js.map +1 -1
- package/dist/control.d.ts +17 -41
- package/dist/control.js +61 -1323
- package/dist/control.js.map +1 -1
- package/dist/install.d.ts +16 -0
- package/dist/install.js +75 -26
- package/dist/install.js.map +1 -1
- package/dist/routes/agent-apps.d.ts +15 -0
- package/dist/routes/agent-apps.js +78 -0
- package/dist/routes/agent-apps.js.map +1 -0
- package/dist/routes/apps.d.ts +3 -0
- package/dist/routes/apps.js +278 -0
- package/dist/routes/apps.js.map +1 -0
- package/dist/routes/backup.js +3 -3
- package/dist/routes/backup.js.map +1 -1
- package/dist/routes/instances.d.ts +6 -0
- package/dist/routes/instances.js +863 -874
- package/dist/routes/instances.js.map +1 -1
- package/dist/routes/llm.d.ts +15 -0
- package/dist/routes/llm.js +247 -0
- package/dist/routes/llm.js.map +1 -0
- package/dist/routes/runtime.d.ts +15 -0
- package/dist/routes/runtime.js +69 -0
- package/dist/routes/runtime.js.map +1 -0
- package/dist/routes/setup.js +131 -9
- package/dist/routes/setup.js.map +1 -1
- package/dist/routes/system.js +56 -9
- package/dist/routes/system.js.map +1 -1
- package/dist/server.js +107 -7
- package/dist/server.js.map +1 -1
- package/dist/services/agent-apps/catalog.d.ts +30 -0
- package/dist/services/agent-apps/catalog.js +60 -0
- package/dist/services/agent-apps/catalog.js.map +1 -0
- package/dist/services/agent-apps/index.d.ts +36 -0
- package/dist/services/agent-apps/index.js +171 -0
- package/dist/services/agent-apps/index.js.map +1 -0
- package/dist/services/agent-apps/installers/adapter-probes.d.ts +49 -0
- package/dist/services/agent-apps/installers/adapter-probes.js +223 -0
- package/dist/services/agent-apps/installers/adapter-probes.js.map +1 -0
- package/dist/services/agent-apps/installers/adapter.d.ts +30 -0
- package/dist/services/agent-apps/installers/adapter.js +171 -0
- package/dist/services/agent-apps/installers/adapter.js.map +1 -0
- package/dist/services/agent-apps/installers/registry-probe.d.ts +38 -0
- package/dist/services/agent-apps/installers/registry-probe.js +183 -0
- package/dist/services/agent-apps/installers/registry-probe.js.map +1 -0
- package/dist/services/agent-apps/installers/shell-script.d.ts +47 -0
- package/dist/services/agent-apps/installers/shell-script.js +471 -0
- package/dist/services/agent-apps/installers/shell-script.js.map +1 -0
- package/dist/services/agent-apps/types.d.ts +125 -0
- package/dist/services/agent-apps/types.js +17 -0
- package/dist/services/agent-apps/types.js.map +1 -0
- package/dist/services/app/app-compiler.d.ts +15 -0
- package/dist/services/app/app-compiler.js +172 -0
- package/dist/services/app/app-compiler.js.map +1 -0
- package/dist/services/app/app-manager.d.ts +142 -0
- package/dist/services/app/app-manager.js +1988 -0
- package/dist/services/app/app-manager.js.map +1 -0
- package/dist/services/app/custom-manager.d.ts +27 -0
- package/dist/services/app/custom-manager.js +285 -0
- package/dist/services/app/custom-manager.js.map +1 -0
- package/dist/services/app/hermes-agent-manager.d.ts +20 -0
- package/dist/services/app/hermes-agent-manager.js +289 -0
- package/dist/services/app/hermes-agent-manager.js.map +1 -0
- package/dist/services/app/id-normalizer.d.ts +27 -0
- package/dist/services/app/id-normalizer.js +77 -0
- package/dist/services/app/id-normalizer.js.map +1 -0
- package/dist/services/app/ollama-manager.d.ts +18 -0
- package/dist/services/app/ollama-manager.js +207 -0
- package/dist/services/app/ollama-manager.js.map +1 -0
- package/dist/services/app/openclaw-manager.d.ts +63 -0
- package/dist/services/app/openclaw-manager.js +1178 -0
- package/dist/services/app/openclaw-manager.js.map +1 -0
- package/dist/services/app/paths.d.ts +47 -0
- package/dist/services/app/paths.js +68 -0
- package/dist/services/app/paths.js.map +1 -0
- package/dist/services/app/registry.d.ts +17 -0
- package/dist/services/app/registry.js +31 -0
- package/dist/services/app/registry.js.map +1 -0
- package/dist/services/app/remote-spec.d.ts +14 -0
- package/dist/services/app/remote-spec.js +58 -0
- package/dist/services/app/remote-spec.js.map +1 -0
- package/dist/services/app/terminal-session-manager.d.ts +27 -0
- package/dist/services/app/terminal-session-manager.js +157 -0
- package/dist/services/app/terminal-session-manager.js.map +1 -0
- package/dist/services/app/types.d.ts +72 -0
- package/dist/services/app/types.js +16 -0
- package/dist/services/app/types.js.map +1 -0
- package/dist/services/backup-manager.js +60 -22
- package/dist/services/backup-manager.js.map +1 -1
- package/dist/services/instance-manager.d.ts +125 -34
- package/dist/services/instance-manager.js +679 -1043
- package/dist/services/instance-manager.js.map +1 -1
- package/dist/services/llm-proxy/adapters.js +5 -1
- package/dist/services/llm-proxy/adapters.js.map +1 -1
- package/dist/services/llm-proxy/circuit-breaker.js +10 -2
- package/dist/services/llm-proxy/circuit-breaker.js.map +1 -1
- package/dist/services/llm-proxy/index.d.ts +43 -0
- package/dist/services/llm-proxy/index.js +120 -5
- package/dist/services/llm-proxy/index.js.map +1 -1
- package/dist/services/llm-proxy/ssrf.js +1 -1
- package/dist/services/llm-proxy/ssrf.js.map +1 -1
- package/dist/services/nomad-manager.d.ts +260 -3
- package/dist/services/nomad-manager.js +2921 -341
- package/dist/services/nomad-manager.js.map +1 -1
- package/dist/services/panel-manager.d.ts +50 -0
- package/dist/services/panel-manager.js +443 -0
- package/dist/services/panel-manager.js.map +1 -0
- package/dist/services/plugin-installer.js +28 -2
- package/dist/services/plugin-installer.js.map +1 -1
- package/dist/services/process-manager.js +42 -7
- package/dist/services/process-manager.js.map +1 -1
- package/dist/services/runtime/adapters/custom.d.ts +20 -0
- package/dist/services/runtime/adapters/custom.js +90 -0
- package/dist/services/runtime/adapters/custom.js.map +1 -0
- package/dist/services/runtime/adapters/hermes.d.ts +174 -0
- package/dist/services/runtime/adapters/hermes.js +1316 -0
- package/dist/services/runtime/adapters/hermes.js.map +1 -0
- package/dist/services/runtime/adapters/openclaw-routes.d.ts +17 -0
- package/dist/services/runtime/adapters/openclaw-routes.js +946 -0
- package/dist/services/runtime/adapters/openclaw-routes.js.map +1 -0
- package/dist/services/runtime/adapters/openclaw.d.ts +188 -0
- package/dist/services/runtime/adapters/openclaw.js +2195 -0
- package/dist/services/runtime/adapters/openclaw.js.map +1 -0
- package/dist/services/runtime/errors.d.ts +28 -0
- package/dist/services/runtime/errors.js +31 -0
- package/dist/services/runtime/errors.js.map +1 -0
- package/dist/services/runtime/index.d.ts +34 -0
- package/dist/services/runtime/index.js +51 -0
- package/dist/services/runtime/index.js.map +1 -0
- package/dist/services/runtime/instance.d.ts +24 -0
- package/dist/services/runtime/instance.js +143 -0
- package/dist/services/runtime/instance.js.map +1 -0
- package/dist/services/runtime/migrations.d.ts +15 -0
- package/dist/services/runtime/migrations.js +25 -0
- package/dist/services/runtime/migrations.js.map +1 -0
- package/dist/services/runtime/registry.d.ts +13 -0
- package/dist/services/runtime/registry.js +32 -0
- package/dist/services/runtime/registry.js.map +1 -0
- package/dist/services/runtime/types.d.ts +545 -0
- package/dist/services/runtime/types.js +14 -0
- package/dist/services/runtime/types.js.map +1 -0
- package/dist/services/setup-manager.d.ts +70 -29
- package/dist/services/setup-manager.js +591 -625
- package/dist/services/setup-manager.js.map +1 -1
- package/dist/services/task-registry.d.ts +44 -0
- package/dist/services/task-registry.js +74 -0
- package/dist/services/task-registry.js.map +1 -0
- package/dist/services/telemetry/heartbeat.d.ts +6 -6
- package/dist/services/telemetry/heartbeat.js +29 -30
- package/dist/services/telemetry/heartbeat.js.map +1 -1
- package/dist/services/update-manager.d.ts +47 -0
- package/dist/services/update-manager.js +305 -0
- package/dist/services/update-manager.js.map +1 -0
- package/dist/types.d.ts +222 -0
- package/dist/utils/docker-host.d.ts +15 -0
- package/dist/utils/docker-host.js +64 -0
- package/dist/utils/docker-host.js.map +1 -0
- package/install/jishu-install.sh +303 -37
- package/install/post-install.sh +64 -5
- package/package.json +19 -5
- package/public/assets/Dashboard-B-JoOjBQ.js +1 -0
- package/public/assets/HermesChatPanel-mFSureyc.js +1 -0
- package/public/assets/HermesConfigForm-DvR05LK1.js +4 -0
- package/public/assets/InitPassword-CVA8wQA6.js +1 -0
- package/public/assets/InstanceDetail-DcZW2QGO.js +91 -0
- package/public/assets/{Login-CUoEZOWR.js → Login-BWsZH2mu.js} +1 -1
- package/public/assets/NewInstance-BCIrAd86.js +1 -0
- package/public/assets/Settings-xkDcduFz.js +1 -0
- package/public/assets/Setup-Cfuwj4gV.js +1 -0
- package/public/assets/WeixinLoginPanel-CnjR8xMu.js +9 -0
- package/public/assets/index-CPhVFEsx.css +1 -0
- package/public/assets/index-DQsM6Joa.js +19 -0
- package/public/assets/input-paste-CrNVAyOy.js +1 -0
- package/public/assets/{providers-lBSOjUWy.js → providers-V-vwrExZ.js} +1 -1
- package/public/assets/registry-B4UFJdpA.js +2 -0
- package/public/assets/{usePolling-CK0DfI4h.js → usePolling-Do5Erqm_.js} +1 -1
- package/public/assets/vendor-i18n-ucpM0OR0.js +9 -0
- package/public/assets/{vendor-react-B1-3Yrt-.js → vendor-react-Bk1hRGiY.js} +1 -1
- package/public/favicon.png +0 -0
- package/public/index.html +9 -4
- package/public/logos/hermes.png +0 -0
- package/public/logos/ollama.png +0 -0
- package/public/logos/openclaw.svg +60 -0
- package/scripts/build-hermes-image.sh +21 -0
- package/scripts/build-local.sh +54 -0
- package/scripts/check-adapter-isolation.ts +293 -0
- package/scripts/fixtures/instances/hermes-sample/instance.json +37 -0
- package/scripts/fixtures/instances/legacy-openclaw-sample/instance.json +7 -0
- package/scripts/smoke/hermes-bootstrap.sh +195 -0
- package/templates/hermes-entrypoint.sh +154 -0
- package/dist/doctor.js.map +0 -1
- package/install/jishu-install-china.sh +0 -3092
- package/public/assets/Dashboard-DhsrzJ4F.js +0 -1
- package/public/assets/InitPassword-BjubiVdd.js +0 -1
- package/public/assets/InstanceDetail-DMcywsof.js +0 -17
- package/public/assets/NewInstance-Bk0G4EiJ.js +0 -1
- package/public/assets/Settings-D5tHL_h5.js +0 -1
- package/public/assets/Setup-4t6E3Rut.js +0 -1
- package/public/assets/index-BJ47MWpF.css +0 -1
- package/public/assets/index-DbX85irc.js +0 -16
- package/public/assets/vendor-i18n-CfW0RvgE.js +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as A,k as K,j as e,L as R,l as F,m as U,n as W,o as T,p as D,q as I,t as P,v as q,w as G,x as H}from"./index-DbX85irc.js";import{r as l,u as O}from"./vendor-react-B1-3Yrt-.js";import{u as z}from"./usePolling-CK0DfI4h.js";import{u as S}from"./vendor-i18n-CfW0RvgE.js";function J(t){if(!t)return"-";const n=Math.floor(t/86400),d=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return n>0?`${n}d ${d}h`:d>0?`${d}h ${r}m`:`${r}m`}function Q({status:t}){const{t:n}=S(),r={running:{cls:"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",labelKey:"status.running"},pending:{cls:"bg-amber-500/10 text-amber-400 border border-amber-500/20",labelKey:"status.starting"},failed:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.failed"},dead:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.crashed"}}[t]||{cls:"bg-[var(--card)] text-muted border border-[var(--border)]",labelKey:"status.stopped"};return e.jsx("span",{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium ${r.cls}`,children:n(r.labelKey)})}function te(){const{t}=S(["dashboard","common"]),[n,d]=l.useState([]),[r,B]=l.useState(null),[h,v]=l.useState(""),[f,y]=l.useState(""),[p,N]=l.useState(!1),[o,w]=l.useState(null),[k,C]=l.useState(!1),g=O(),{showToast:c}=A(),m=()=>{T().then(s=>{d(s),y("")}).catch(s=>y(s.message||t("common:error.loadFailed"))),D().then(B).catch(()=>{})};z(m,1e4),l.useEffect(()=>{K().then(s=>{s.hasUpdate&&w({currentVersion:s.currentVersion,latestVersion:s.latestVersion})}).catch(()=>{})},[]);const V=async()=>{if(window.confirm(t("update.confirm",{currentVersion:o==null?void 0:o.currentVersion,latestVersion:o==null?void 0:o.latestVersion}))){C(!0);try{await I(),c(t("update.started"),"success"),w(null)}catch(s){c(s.message||t("update.failed"),"error")}finally{C(!1)}}},E=async()=>{if(window.confirm(t("engine.restartConfirm"))){N(!0);try{await P(),c(t("engine.restarted"),"success"),setTimeout(m,2e3)}catch(s){c(s.message||t("engine.restartFailed"),"error")}finally{N(!1)}}},j=async(s,a,i)=>{s.stopPropagation(),v(`${i}-${a}`);try{a==="start"&&await q(i),a==="stop"&&await G(i),a==="restart"&&await H(i),c(t(`common:action.${a}Done`),"success"),setTimeout(m,1e3)}catch(b){c(b.message||t("common:error.operationFailed"),"error")}finally{v("")}},M=n.filter(s=>{var a;return((a=s.service)==null?void 0:a.status)==="running"}).length,u=!!r&&r.disk.percent>90,L=r?[{label:t("stats.runningInstances"),value:`${M} / ${n.length}`,sub:r.nomad_running?t("stats.engineRunning"):t("stats.engineStopped"),subColor:r.nomad_running?"text-emerald-400":"text-red-400",icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]"},{label:t("stats.cpu"),value:`${r.cpu_percent}%`,sub:r.temperature?`${r.temperature}°C`:null,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),e.jsx("rect",{x:"9",y:"9",width:"6",height:"6"}),e.jsx("line",{x1:"9",y1:"2",x2:"9",y2:"4"}),e.jsx("line",{x1:"15",y1:"2",x2:"15",y2:"4"}),e.jsx("line",{x1:"9",y1:"20",x2:"9",y2:"22"}),e.jsx("line",{x1:"15",y1:"20",x2:"15",y2:"22"}),e.jsx("line",{x1:"20",y1:"9",x2:"22",y2:"9"}),e.jsx("line",{x1:"20",y1:"15",x2:"22",y2:"15"}),e.jsx("line",{x1:"2",y1:"9",x2:"4",y2:"9"}),e.jsx("line",{x1:"2",y1:"15",x2:"4",y2:"15"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]",warn:r.cpu_percent>90},{label:t("stats.memory"),value:`${r.memory.percent}%`,sub:`${r.memory.used_mb}MB / ${r.memory.total_mb}MB`,icon:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M6 19v-8m4 8v-4m4 4v-6m4 6v-2"})}),iconColor:"text-[#00D4AA]",glowColor:"rgba(0,212,170,0.12)",accent:"border-l-2 border-l-[#00D4AA]"},{label:t("stats.disk"),value:`${r.disk.percent}%`,sub:`${r.disk.used_gb}GB / ${r.disk.total_gb}GB`,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0018 0V5"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"22"})]}),iconColor:u?"text-red-400":"text-[#0066FF]",glowColor:u?"rgba(239,68,68,0.12)":"rgba(0,102,255,0.12)",accent:u?"border-l-2 border-l-red-400":"border-l-2 border-l-[#0066FF]",warn:u}]:[];return e.jsxs("div",{className:"p-4 max-w-5xl mx-auto",children:[o&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 bg-amber-500/10 border border-amber-500/30 rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 2v6m0 0 2-2m-2 2-2-2M4.93 10.93A10 10 0 1 0 21 12"})}),e.jsxs("span",{className:"text-amber-300",children:[t("update.found"),e.jsx("span",{className:"font-mono text-amber-200 ml-1",children:o.currentVersion}),e.jsx("span",{className:"mx-1 text-amber-500",children:"→"}),e.jsx("span",{className:"font-mono text-amber-200",children:o.latestVersion})]})]}),e.jsx("button",{onClick:V,disabled:k,className:"shrink-0 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-xs font-semibold px-3 py-1 rounded-md transition-colors",children:t(k?"update.upgrading":"update.upgradeNow")})]}),e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-semibold text-foreground",children:t("title")}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:t("subtitle")})]}),e.jsx(R,{})]}),r&&e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:L.map(s=>e.jsxs("div",{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 relative overflow-hidden hover:border-[var(--border-hover)] hover:bg-[var(--card-hover)] transition-all duration-200 ${s.accent}`,children:[e.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 rounded-full opacity-60 pointer-events-none",style:{background:`radial-gradient(circle, ${s.glowColor} 0%, transparent 70%)`}}),e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[11px] text-muted",children:s.label}),e.jsx("span",{className:`${s.iconColor} opacity-80`,children:s.icon})]}),e.jsx("div",{className:`text-lg font-semibold ${s.warn?"text-red-400":"text-foreground"}`,children:s.value}),s.sub&&e.jsx("div",{className:`text-[11px] mt-0.5 truncate ${s.subColor??"text-muted"}`,children:s.sub})]},s.label))}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:t("instances.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>g("/instances/new"),className:"bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all duration-200 shadow-[0_0_12px_rgba(0,102,255,0.3)]",children:t("instances.new")}),e.jsx("button",{onClick:()=>g("/instances/new?import=true"),className:"px-3 py-1.5 rounded-md text-xs font-medium text-muted border border-[var(--border)] bg-[var(--card)] hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-200",children:t("instances.import")}),e.jsxs("button",{onClick:E,disabled:p,title:t("instances.restartEngineTitle"),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-red-400 border border-red-500/20 bg-red-500/5 hover:bg-red-500/15 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200",children:[e.jsx(F,{className:`w-3 h-3 ${p?"animate-spin":""}`}),t(p?"instances.restarting":"instances.restartEngine")]})]})]}),f?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("p",{className:"text-sm text-red-400 mb-2",children:t("instances.loadError",{error:f})}),e.jsx("button",{onClick:m,className:"text-xs text-muted hover:text-foreground underline",children:t("common:action.retry")})]}):n.length===0?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("div",{className:"text-muted opacity-40 mb-3",children:e.jsxs("svg",{className:"w-8 h-8 mx-auto",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}),e.jsx("p",{className:"text-sm text-muted mb-1",children:t("instances.empty")}),e.jsx("p",{className:"text-xs text-muted opacity-60",children:t("instances.emptyHint")})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.name")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.status")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden sm:table-cell",children:t("table.uptime")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden md:table-cell",children:t("table.memory")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:t("table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:n.map(s=>{var b,$,_;const a=((b=s.service)==null?void 0:b.status)||"stopped",i=a==="running";return e.jsxs("tr",{className:"hover:bg-[var(--card-hover)] cursor-pointer transition-colors duration-150",onClick:()=>g(`/instances/${s.id}`),children:[e.jsxs("td",{className:"px-4 py-2.5",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.name}),e.jsx("div",{className:"text-xs text-muted font-mono",children:s.id})]}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Q,{status:a}),(($=s.auto_backup)==null?void 0:$.enabled)&&e.jsx("span",{className:`text-xs leading-none ${s.auto_backup.last_backup_ok===!1?"text-red-400":"text-green-400"}`,title:s.auto_backup.last_backup_ok===!1?"Backup failed":"Backup OK",children:s.auto_backup.last_backup_ok===!1?"⚠":"●"})]})}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden sm:table-cell font-mono text-xs",children:i?J(s.service.uptime):"-"}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden md:table-cell font-mono text-xs",children:(_=s.service)!=null&&_.memory_mb?`${s.service.memory_mb} MB`:"-"}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:e.jsx("div",{className:"inline-flex items-center gap-1",children:i||a==="pending"?e.jsxs(e.Fragment,{children:[e.jsx("button",{title:t("common:action.restart"),onClick:x=>j(x,"restart",s.id),disabled:!!h,className:"p-1.5 rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-colors duration-150",children:e.jsx(F,{className:"w-3.5 h-3.5"})}),e.jsx("button",{title:t("common:action.stop"),onClick:x=>j(x,"stop",s.id),disabled:!!h,className:"p-1.5 rounded-md text-muted hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(U,{className:"w-3.5 h-3.5"})})]}):e.jsx("button",{title:t("common:action.start"),onClick:x=>j(x,"start",s.id),disabled:!!h,className:"p-1.5 rounded-md text-muted hover:text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(W,{className:"w-3.5 h-3.5"})})})})]},s.id)})})]})]})]})}export{te as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,T as j,I as v,a as w,c as N,s as y}from"./index-DbX85irc.js";import{r}from"./vendor-react-B1-3Yrt-.js";import{u as F}from"./vendor-i18n-CfW0RvgE.js";const x="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function _({onDone:p}){const{t}=F("auth"),[s,h]=r.useState(""),[n,b]=r.useState(""),[o,f]=r.useState(!1),[l,d]=r.useState(""),[c,m]=r.useState(!1),u=s.length>=8&&s===n,g=async a=>{if(a.preventDefault(),!!u){d(""),m(!0);try{const i=await N(s);y(i.token),p()}catch(i){d(i.message||t("init.failed"))}finally{m(!1)}}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden",children:[e.jsx("div",{className:"grid-bg absolute inset-0 pointer-events-none"}),e.jsx("div",{className:"absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[300px] rounded-full bg-[#0066FF]/[0.07] blur-[90px] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(j,{className:"w-40 h-40 mx-auto mb-4 object-contain"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:t("init.title")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[l&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5",children:l}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.password")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:o?"text":"password",value:s,onChange:a=>h(a.target.value),placeholder:t("init.passwordPlaceholder"),className:`${x} pr-10`,autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>f(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors duration-200",children:o?e.jsx(v,{}):e.jsx(w,{})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.confirm")}),e.jsx("input",{type:o?"text":"password",value:n,onChange:a=>b(a.target.value),placeholder:t("init.confirmPlaceholder"),className:x}),s&&n&&s!==n&&e.jsx("p",{className:"text-red-400 text-xs mt-1.5",children:t("init.mismatch")})]}),e.jsx("button",{type:"submit",disabled:c||!u,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:c?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),t("init.loading")]}):t("init.submit")})]})]})]})}export{_ as default};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DbX85irc.js","assets/vendor-react-B1-3Yrt-.js","assets/vendor-i18n-CfW0RvgE.js","assets/index-BJ47MWpF.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e,y as es,z as Es,I as Ms,a as As,_ as Bt,A as Ut,B as ts,C as ss,D as rs,E as as,F as Ps,l as ls,G as Is,H as Rs,J as Ls,K as zt,M as Ds,N as Ts,O as Vs,P as _s,Q as $s,R as Os,S as Bs,U as Us,h as zs,k as qs,V as We,W as ft,X as Ks,Y as Hs,Z as qt,$ as Kt,a0 as Ht,a1 as Ws,a2 as Js,a3 as Wt,a4 as Jt,a5 as Qs,a6 as Gs,q as Ys,a7 as Xs,a8 as Zs,v as er,w as tr,x as Qt,a9 as sr,aa as rr}from"./index-DbX85irc.js";import{e as ee,r as p,u as ns,d as ar}from"./vendor-react-B1-3Yrt-.js";import{u as lr}from"./usePolling-CK0DfI4h.js";import{P as Ze}from"./providers-lBSOjUWy.js";import{u as Ae,i as nr}from"./vendor-i18n-CfW0RvgE.js";var or=Object.defineProperty,st=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,Gt=(r,c,n)=>c in r?or(r,c,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[c]=n,gt=(r,c)=>{for(var n in c||(c={}))os.call(c,n)&&Gt(r,n,c[n]);if(st)for(var n of st(c))is.call(c,n)&&Gt(r,n,c[n]);return r},bt=(r,c)=>{var n={};for(var h in r)os.call(r,h)&&c.indexOf(h)<0&&(n[h]=r[h]);if(r!=null&&st)for(var h of st(r))c.indexOf(h)<0&&is.call(r,h)&&(n[h]=r[h]);return n};/**
|
|
3
|
-
* @license QR Code generator library (TypeScript)
|
|
4
|
-
* Copyright (c) Project Nayuki.
|
|
5
|
-
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/var $e;(r=>{const c=class O{constructor(t,a,l,i){if(this.version=t,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],t<O.MIN_VERSION||t>O.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;let m=[];for(let g=0;g<this.size;g++)m.push(!1);for(let g=0;g<this.size;g++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const y=this.addEccAndInterleave(l);if(this.drawCodewords(y),i==-1){let g=1e9;for(let F=0;F<8;F++){this.applyMask(F),this.drawFormatBits(F);const j=this.getPenaltyScore();j<g&&(i=F,g=j),this.applyMask(F)}}s(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(t,a){const l=r.QrSegment.makeSegments(t);return O.encodeSegments(l,a)}static encodeBinary(t,a){const l=r.QrSegment.makeBytes(t);return O.encodeSegments([l],a)}static encodeSegments(t,a,l=1,i=40,m=-1,y=!0){if(!(O.MIN_VERSION<=l&&l<=i&&i<=O.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,F;for(g=l;;g++){const S=O.getNumDataCodewords(g,a)*8,$=x.getTotalBits(t,g);if($<=S){F=$;break}if(g>=i)throw new RangeError("Data too long")}for(const S of[O.Ecc.MEDIUM,O.Ecc.QUARTILE,O.Ecc.HIGH])y&&F<=O.getNumDataCodewords(g,S)*8&&(a=S);let j=[];for(const S of t){n(S.mode.modeBits,4,j),n(S.numChars,S.mode.numCharCountBits(g),j);for(const $ of S.getData())j.push($)}s(j.length==F);const V=O.getNumDataCodewords(g,a)*8;s(j.length<=V),n(0,Math.min(4,V-j.length),j),n(0,(8-j.length%8)%8,j),s(j.length%8==0);for(let S=236;j.length<V;S^=253)n(S,8,j);let R=[];for(;R.length*8<j.length;)R.push(0);return j.forEach((S,$)=>R[$>>>3]|=S<<7-($&7)),new O(g,a,R,m)}getModule(t,a){return 0<=t&&t<this.size&&0<=a&&a<this.size&&this.modules[a][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),a=t.length;for(let l=0;l<a;l++)for(let i=0;i<a;i++)l==0&&i==0||l==0&&i==a-1||l==a-1&&i==0||this.drawAlignmentPattern(t[l],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const a=this.errorCorrectionLevel.formatBits<<3|t;let l=a;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const i=(a<<10|l)^21522;s(i>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,h(i,m));this.setFunctionModule(8,7,h(i,6)),this.setFunctionModule(8,8,h(i,7)),this.setFunctionModule(7,8,h(i,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,h(i,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,h(i,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,h(i,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let l=0;l<12;l++)t=t<<1^(t>>>11)*7973;const a=this.version<<12|t;s(a>>>18==0);for(let l=0;l<18;l++){const i=h(a,l),m=this.size-11+l%3,y=Math.floor(l/3);this.setFunctionModule(m,y,i),this.setFunctionModule(y,m,i)}}drawFinderPattern(t,a){for(let l=-4;l<=4;l++)for(let i=-4;i<=4;i++){const m=Math.max(Math.abs(i),Math.abs(l)),y=t+i,g=a+l;0<=y&&y<this.size&&0<=g&&g<this.size&&this.setFunctionModule(y,g,m!=2&&m!=4)}}drawAlignmentPattern(t,a){for(let l=-2;l<=2;l++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,a+l,Math.max(Math.abs(i),Math.abs(l))!=1)}setFunctionModule(t,a,l){this.modules[a][t]=l,this.isFunction[a][t]=!0}addEccAndInterleave(t){const a=this.version,l=this.errorCorrectionLevel;if(t.length!=O.getNumDataCodewords(a,l))throw new RangeError("Invalid argument");const i=O.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][a],m=O.ECC_CODEWORDS_PER_BLOCK[l.ordinal][a],y=Math.floor(O.getNumRawDataModules(a)/8),g=i-y%i,F=Math.floor(y/i);let j=[];const V=O.reedSolomonComputeDivisor(m);for(let S=0,$=0;S<i;S++){let M=t.slice($,$+F-m+(S<g?0:1));$+=M.length;const I=O.reedSolomonComputeRemainder(M,V);S<g&&M.push(0),j.push(M.concat(I))}let R=[];for(let S=0;S<j[0].length;S++)j.forEach(($,M)=>{(S!=F-m||M>=g)&&R.push($[S])});return s(R.length==y),R}drawCodewords(t){if(t.length!=Math.floor(O.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let i=0;i<this.size;i++)for(let m=0;m<2;m++){const y=l-m,F=(l+1&2)==0?this.size-1-i:i;!this.isFunction[F][y]&&a<t.length*8&&(this.modules[F][y]=h(t[a>>>3],7-(a&7)),a++)}}s(a==t.length*8)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let l=0;l<this.size;l++){let i;switch(t){case 0:i=(l+a)%2==0;break;case 1:i=a%2==0;break;case 2:i=l%3==0;break;case 3:i=(l+a)%3==0;break;case 4:i=(Math.floor(l/3)+Math.floor(a/2))%2==0;break;case 5:i=l*a%2+l*a%3==0;break;case 6:i=(l*a%2+l*a%3)%2==0;break;case 7:i=((l+a)%2+l*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][l]&&i&&(this.modules[a][l]=!this.modules[a][l])}}getPenaltyScore(){let t=0;for(let m=0;m<this.size;m++){let y=!1,g=0,F=[0,0,0,0,0,0,0];for(let j=0;j<this.size;j++)this.modules[m][j]==y?(g++,g==5?t+=O.PENALTY_N1:g>5&&t++):(this.finderPenaltyAddHistory(g,F),y||(t+=this.finderPenaltyCountPatterns(F)*O.PENALTY_N3),y=this.modules[m][j],g=1);t+=this.finderPenaltyTerminateAndCount(y,g,F)*O.PENALTY_N3}for(let m=0;m<this.size;m++){let y=!1,g=0,F=[0,0,0,0,0,0,0];for(let j=0;j<this.size;j++)this.modules[j][m]==y?(g++,g==5?t+=O.PENALTY_N1:g>5&&t++):(this.finderPenaltyAddHistory(g,F),y||(t+=this.finderPenaltyCountPatterns(F)*O.PENALTY_N3),y=this.modules[j][m],g=1);t+=this.finderPenaltyTerminateAndCount(y,g,F)*O.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let y=0;y<this.size-1;y++){const g=this.modules[m][y];g==this.modules[m][y+1]&&g==this.modules[m+1][y]&&g==this.modules[m+1][y+1]&&(t+=O.PENALTY_N2)}let a=0;for(const m of this.modules)a=m.reduce((y,g)=>y+(g?1:0),a);const l=this.size*this.size,i=Math.ceil(Math.abs(a*20-l*10)/l)-1;return s(0<=i&&i<=9),t+=i*O.PENALTY_N4,s(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{const t=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(t*2-2))*2;let l=[6];for(let i=this.size-7;l.length<t;i-=a)l.splice(1,0,i);return l}}static getNumRawDataModules(t){if(t<O.MIN_VERSION||t>O.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*t+128)*t+64;if(t>=2){const l=Math.floor(t/7)+2;a-=(25*l-10)*l-55,t>=7&&(a-=36)}return s(208<=a&&a<=29648),a}static getNumDataCodewords(t,a){return Math.floor(O.getNumRawDataModules(t)/8)-O.ECC_CODEWORDS_PER_BLOCK[a.ordinal][t]*O.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let a=[];for(let i=0;i<t-1;i++)a.push(0);a.push(1);let l=1;for(let i=0;i<t;i++){for(let m=0;m<a.length;m++)a[m]=O.reedSolomonMultiply(a[m],l),m+1<a.length&&(a[m]^=a[m+1]);l=O.reedSolomonMultiply(l,2)}return a}static reedSolomonComputeRemainder(t,a){let l=a.map(i=>0);for(const i of t){const m=i^l.shift();l.push(0),a.forEach((y,g)=>l[g]^=O.reedSolomonMultiply(y,m))}return l}static reedSolomonMultiply(t,a){if(t>>>8||a>>>8)throw new RangeError("Byte out of range");let l=0;for(let i=7;i>=0;i--)l=l<<1^(l>>>7)*285,l^=(a>>>i&1)*t;return s(l>>>8==0),l}finderPenaltyCountPatterns(t){const a=t[1];s(a<=this.size*3);const l=a>0&&t[2]==a&&t[3]==a*3&&t[4]==a&&t[5]==a;return(l&&t[0]>=a*4&&t[6]>=a?1:0)+(l&&t[6]>=a*4&&t[0]>=a?1:0)}finderPenaltyTerminateAndCount(t,a,l){return t&&(this.finderPenaltyAddHistory(a,l),a=0),a+=this.size,this.finderPenaltyAddHistory(a,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(t,a){a[0]==0&&(t+=this.size),a.pop(),a.unshift(t)}};c.MIN_VERSION=1,c.MAX_VERSION=40,c.PENALTY_N1=3,c.PENALTY_N2=3,c.PENALTY_N3=40,c.PENALTY_N4=10,c.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],c.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=c;function n(N,t,a){if(t<0||t>31||N>>>t)throw new RangeError("Value out of range");for(let l=t-1;l>=0;l--)a.push(N>>>l&1)}function h(N,t){return(N>>>t&1)!=0}function s(N){if(!N)throw new Error("Assertion error")}const u=class Y{constructor(t,a,l){if(this.mode=t,this.numChars=a,this.bitData=l,a<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(t){let a=[];for(const l of t)n(l,8,a);return new Y(Y.Mode.BYTE,t.length,a)}static makeNumeric(t){if(!Y.isNumeric(t))throw new RangeError("String contains non-numeric characters");let a=[];for(let l=0;l<t.length;){const i=Math.min(t.length-l,3);n(parseInt(t.substring(l,l+i),10),i*3+1,a),l+=i}return new Y(Y.Mode.NUMERIC,t.length,a)}static makeAlphanumeric(t){if(!Y.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],l;for(l=0;l+2<=t.length;l+=2){let i=Y.ALPHANUMERIC_CHARSET.indexOf(t.charAt(l))*45;i+=Y.ALPHANUMERIC_CHARSET.indexOf(t.charAt(l+1)),n(i,11,a)}return l<t.length&&n(Y.ALPHANUMERIC_CHARSET.indexOf(t.charAt(l)),6,a),new Y(Y.Mode.ALPHANUMERIC,t.length,a)}static makeSegments(t){return t==""?[]:Y.isNumeric(t)?[Y.makeNumeric(t)]:Y.isAlphanumeric(t)?[Y.makeAlphanumeric(t)]:[Y.makeBytes(Y.toUtf8ByteArray(t))]}static makeEci(t){let a=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)n(t,8,a);else if(t<16384)n(2,2,a),n(t,14,a);else if(t<1e6)n(6,3,a),n(t,21,a);else throw new RangeError("ECI assignment value out of range");return new Y(Y.Mode.ECI,0,a)}static isNumeric(t){return Y.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return Y.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(t,a){let l=0;for(const i of t){const m=i.mode.numCharCountBits(a);if(i.numChars>=1<<m)return 1/0;l+=4+m+i.bitData.length}return l}static toUtf8ByteArray(t){t=encodeURI(t);let a=[];for(let l=0;l<t.length;l++)t.charAt(l)!="%"?a.push(t.charCodeAt(l)):(a.push(parseInt(t.substring(l+1,l+3),16)),l+=2);return a}};u.NUMERIC_REGEX=/^[0-9]*$/,u.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,u.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let x=u;r.QrSegment=u})($e||($e={}));(r=>{(c=>{const n=class{constructor(s,u){this.ordinal=s,this.formatBits=u}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),c.Ecc=n})(r.QrCode||(r.QrCode={}))})($e||($e={}));(r=>{(c=>{const n=class{constructor(s,u){this.modeBits=s,this.numBitsCharCount=u}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),c.Mode=n})(r.QrSegment||(r.QrSegment={}))})($e||($e={}));var Ke=$e;/**
|
|
7
|
-
* @license qrcode.react
|
|
8
|
-
* Copyright (c) Paul O'Shannessy
|
|
9
|
-
* SPDX-License-Identifier: ISC
|
|
10
|
-
*/var ir={L:Ke.QrCode.Ecc.LOW,M:Ke.QrCode.Ecc.MEDIUM,Q:Ke.QrCode.Ecc.QUARTILE,H:Ke.QrCode.Ecc.HIGH},cs=128,ds="L",us="#FFFFFF",ms="#000000",hs=!1,xs=1,cr=4,dr=0,ur=.1;function fs(r,c=0){const n=[];return r.forEach(function(h,s){let u=null;h.forEach(function(x,N){if(!x&&u!==null){n.push(`M${u+c} ${s+c}h${N-u}v1H${u+c}z`),u=null;return}if(N===h.length-1){if(!x)return;u===null?n.push(`M${N+c},${s+c} h1v1H${N+c}z`):n.push(`M${u+c},${s+c} h${N+1-u}v1H${u+c}z`);return}x&&u===null&&(u=N)})}),n.join("")}function ps(r,c){return r.slice().map((n,h)=>h<c.y||h>=c.y+c.h?n:n.map((s,u)=>u<c.x||u>=c.x+c.w?s:!1))}function mr(r,c,n,h){if(h==null)return null;const s=r.length+n*2,u=Math.floor(c*ur),x=s/c,N=(h.width||u)*x,t=(h.height||u)*x,a=h.x==null?r.length/2-N/2:h.x*x,l=h.y==null?r.length/2-t/2:h.y*x,i=h.opacity==null?1:h.opacity;let m=null;if(h.excavate){let g=Math.floor(a),F=Math.floor(l),j=Math.ceil(N+a-g),V=Math.ceil(t+l-F);m={x:g,y:F,w:j,h:V}}const y=h.crossOrigin;return{x:a,y:l,h:t,w:N,excavation:m,opacity:i,crossOrigin:y}}function hr(r,c){return c!=null?Math.max(Math.floor(c),0):r?cr:dr}function gs({value:r,level:c,minVersion:n,includeMargin:h,marginSize:s,imageSettings:u,size:x,boostLevel:N}){let t=ee.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((F,j)=>(F.push(...Ke.QrSegment.makeSegments(j)),F),[]);return Ke.QrCode.encodeSegments(g,ir[c],n,void 0,void 0,N)},[r,c,n,N]);const{cells:a,margin:l,numCells:i,calculatedImageSettings:m}=ee.useMemo(()=>{let y=t.getModules();const g=hr(h,s),F=y.length+g*2,j=mr(y,x,g,u);return{cells:y,margin:g,numCells:F,calculatedImageSettings:j}},[t,x,u,h,s]);return{qrcode:t,margin:l,cells:a,numCells:i,calculatedImageSettings:m}}var xr=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),fr=ee.forwardRef(function(c,n){const h=c,{value:s,size:u=cs,level:x=ds,bgColor:N=us,fgColor:t=ms,includeMargin:a=hs,minVersion:l=xs,boostLevel:i,marginSize:m,imageSettings:y}=h,F=bt(h,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=F,V=bt(F,["style"]),R=y==null?void 0:y.src,S=ee.useRef(null),$=ee.useRef(null),M=ee.useCallback(ae=>{S.current=ae,typeof n=="function"?n(ae):n&&(n.current=ae)},[n]),[I,B]=ee.useState(!1),{margin:z,cells:te,numCells:pe,calculatedImageSettings:Q}=gs({value:s,level:x,minVersion:l,boostLevel:i,includeMargin:a,marginSize:m,imageSettings:y,size:u});ee.useEffect(()=>{if(S.current!=null){const ae=S.current,Z=ae.getContext("2d");if(!Z)return;let ce=te;const X=$.current,ge=Q!=null&&X!==null&&X.complete&&X.naturalHeight!==0&&X.naturalWidth!==0;ge&&Q.excavation!=null&&(ce=ps(te,Q.excavation));const ne=window.devicePixelRatio||1;ae.height=ae.width=u*ne;const ue=u/pe*ne;Z.scale(ue,ue),Z.fillStyle=N,Z.fillRect(0,0,pe,pe),Z.fillStyle=t,xr?Z.fill(new Path2D(fs(ce,z))):te.forEach(function(d,b){d.forEach(function(E,_){E&&Z.fillRect(_+z,b+z,1,1)})}),Q&&(Z.globalAlpha=Q.opacity),ge&&Z.drawImage(X,Q.x+z,Q.y+z,Q.w,Q.h)}}),ee.useEffect(()=>{B(!1)},[R]);const ie=gt({height:u,width:u},j);let W=null;return R!=null&&(W=ee.createElement("img",{src:R,key:R,style:{display:"none"},onLoad:()=>{B(!0)},ref:$,crossOrigin:Q==null?void 0:Q.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",gt({style:ie,height:u,width:u,ref:M,role:"img"},V)),W)});fr.displayName="QRCodeCanvas";var rt=ee.forwardRef(function(c,n){const h=c,{value:s,size:u=cs,level:x=ds,bgColor:N=us,fgColor:t=ms,includeMargin:a=hs,minVersion:l=xs,boostLevel:i,title:m,marginSize:y,imageSettings:g}=h,F=bt(h,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:V,numCells:R,calculatedImageSettings:S}=gs({value:s,level:x,minVersion:l,boostLevel:i,includeMargin:a,marginSize:y,imageSettings:g,size:u});let $=V,M=null;g!=null&&S!=null&&(S.excavation!=null&&($=ps(V,S.excavation)),M=ee.createElement("image",{href:g.src,height:S.h,width:S.w,x:S.x+j,y:S.y+j,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const I=fs($,j);return ee.createElement("svg",gt({height:u,width:u,viewBox:`0 0 ${R} ${R}`,ref:n,role:"img"},F),!!m&&ee.createElement("title",null,m),ee.createElement("path",{fill:N,d:`M0,0 h${R}v${R}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:t,d:I,shapeRendering:"crispEdges"}),M)});rt.displayName="QRCodeSVG";const Qe=[{id:"feishu",labelKey:"configForm.channel.feishu",fields:[],defaults:{connectionMode:"websocket"}},{id:"openclaw-weixin",labelKey:"configForm.channel.openclaw-weixin",fields:[],defaults:{}},{id:"telegram",labelKey:"configForm.channel.telegram",fields:[{key:"botToken",label:"Bot Token",type:"password",placeholder:"From @BotFather"}]},{id:"discord",labelKey:"configForm.channel.discord",fields:[{key:"token",label:"Bot Token",type:"password",placeholder:"From Discord Developer Portal"}]},{id:"slack",labelKey:"configForm.channel.slack",fields:[{key:"botToken",label:"Bot Token (xoxb-...)",type:"password",placeholder:"xoxb-..."},{key:"appToken",label:"App Token (xapp-...)",type:"password",placeholder:"xapp-..."}]},{id:"whatsapp",labelKey:"configForm.channel.whatsapp",fields:[],defaults:{}},{id:"msteams",labelKey:"configForm.channel.msteams",fields:[{key:"appId",label:"App ID",placeholder:"Azure App Registration ID"},{key:"appPassword",label:"App Password",type:"password",placeholder:"Azure App Secret"},{key:"tenantId",label:"Tenant ID",placeholder:"Azure AD Tenant ID"}]},{id:"signal",labelKey:"configForm.channel.signal",fields:[{key:"account",label:"Phone (E.164)",placeholder:"+8613800138000"}]},{id:"line",labelKey:"configForm.channel.line",fields:[{key:"channelAccessToken",label:"Channel Access Token",type:"password",placeholder:"From LINE Developers"},{key:"channelSecret",label:"Channel Secret",type:"password",placeholder:"LINE Channel Secret"}]},{id:"googlechat",labelKey:"configForm.channel.googlechat",fields:[{key:"serviceAccountFile",label:"Service Account JSON Path",placeholder:"/path/to/service-account.json"}]}];function Me(r,c,n){const h=structuredClone(r),s=c.split(".");let u=h;for(let x=0;x<s.length-1;x++)u[s[x]]===void 0&&(u[s[x]]={}),u=u[s[x]];return u[s[s.length-1]]=n,h}const bs="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200",pr="w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function oe({label:r,hint:c,children:n}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:r}),n,c&&e.jsx("p",{className:"text-xs text-muted mt-1 opacity-60",children:c})]})}function gr({value:r,saved:c,onChange:n,placeholder:h}){const{t:s}=Ae("instance"),[u,x]=p.useState(!1),N="••••••••••••••••••••••••••••••";return c&&!u&&!r?e.jsx("div",{className:"relative",children:e.jsx("input",{type:"password",value:N,readOnly:!0,onFocus:()=>x(!0),className:`${bs} cursor-text`,title:s("config.clickToEdit")})}):e.jsx(we,{value:r,onChange:n,placeholder:h,type:"password",mono:!0})}function we({value:r,onChange:c,placeholder:n,type:h="text",mono:s}){const[u,x]=p.useState(!1),N=h==="password";return e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:N&&!u?"password":"text",value:r||"",onChange:t=>c(t.target.value),placeholder:n,className:`${bs} ${s?"font-mono text-[13px]":""} ${N?"pr-9":""}`}),N&&e.jsx("button",{type:"button",onClick:()=>x(!u),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground",children:u?e.jsx(Ms,{className:"w-3.5 h-3.5"}):e.jsx(As,{className:"w-3.5 h-3.5"})})]})}function Je({value:r,onChange:c,children:n}){return e.jsx("select",{value:r||"",onChange:h=>c(h.target.value),className:pr,children:n})}function Yt({checked:r,onChange:c,label:n}){return e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>c(!r),className:`w-9 h-5 rounded-full relative transition-colors duration-200 ${r?"bg-[#0066FF]":"bg-[var(--input-bg)]"}`,children:e.jsx("div",{className:`w-3.5 h-3.5 bg-white rounded-full absolute top-[3px] transition-transform duration-200 ${r?"left-[18px]":"left-[3px]"}`})}),e.jsx("span",{className:"text-sm text-muted",children:n})]})}function Xt({title:r,defaultOpen:c=!0,id:n,children:h}){const[s,u]=p.useState(c);return e.jsxs("div",{id:n,className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-[var(--border-hover)] transition-colors duration-200",children:[e.jsxs("button",{type:"button",onClick:()=>u(!s),className:"w-full px-4 py-3 flex items-center justify-between text-left hover:bg-[var(--card-hover)] transition-colors duration-150",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:r}),s?e.jsx(es,{className:"w-4 h-4 text-muted"}):e.jsx(Es,{className:"w-4 h-4 text-muted"})]}),s&&e.jsx("div",{className:"px-4 pb-4 space-y-4 border-t border-[var(--border)] pt-4",children:h})]})}const pt=["feishu","openclaw-weixin"],br={feishu:"feishu",lark:"feishu","openclaw-weixin":"openclaw-weixin"};function vr({config:r,onChange:c,instanceId:n,isRunning:h=!1,pluginStatuses:s={},onInstallPlugin:u}){var ge,ne,ue;const{t:x}=Ae(["instance","common"]),N=(d,b)=>c(Me(r,d,b)),t=((ge=r==null?void 0:r["x-jishushell"])==null?void 0:ge.proxy)||{},a=t.upstream||{},l=a.providerId||"",i=Ze.find(d=>d.id===l),m=a.models||[],y=i?i.models.map(d=>({id:d.id,name:d.name,contextWindow:d.contextWindow})):m.map(d=>({id:d.id,name:d.name||d.id,contextWindow:d.contextWindow})),g=a.selectedModelId||((ne=y[0])==null?void 0:ne.id)||"",F=y.find(d=>d.id===g)||y[0]||{},j=m.find(d=>d.id===g)||(F.id?F:{id:"",name:"",contextWindow:0}),V=t.proxy||{},R=d=>{var _;const b=Ze.find(q=>q.id===d);if(!b||a.apiKey&&!window.confirm(x("configForm.switchProviderConfirm")))return;const E=JSON.parse(JSON.stringify(r));E["x-jishushell"]||(E["x-jishushell"]={}),E["x-jishushell"].proxy||(E["x-jishushell"].proxy={}),E["x-jishushell"].proxy.upstream={providerId:b.id,baseUrl:b.baseUrl,api:b.api,authHeader:b.authHeader===!0,headers:b.headers||{},models:b.models.map(q=>({id:q.id,name:q.name,contextWindow:q.contextWindow})),selectedModelId:((_=b.models[0])==null?void 0:_.id)||"",apiKey:"",hasApiKey:!1,clearApiKey:!1},c(E)},S=d=>{N("x-jishushell.proxy.upstream.selectedModelId",d)},$=(d,b)=>{N(`x-jishushell.proxy.upstream.${d}`,b)},M=(r==null?void 0:r.channels)||{},I=Object.keys(M),B=(d,b,E)=>N(`channels.${d}.${b}`,E),z={},te=d=>{const b=Qe.find(q=>q.id===d),E=JSON.parse(JSON.stringify(r));E.channels||(E.channels={});const _=z[d]||d;if(b){const q={enabled:!0,...b.defaults};b.fields.forEach(me=>{q[me.key]=""}),E.channels[_]=q}else E.channels[_]={enabled:!0};c(E)},pe=d=>{const b=JSON.parse(JSON.stringify(r));delete b.channels[d],c(b)},[Q,ie]=p.useState(!1),[W,ae]=p.useState(!(a.hasApiKey&&l)),Z={"moonshot-coding":"configForm.hint.moonshot-coding",volcengine:"configForm.hint.volcengine",byteplus:"configForm.hint.byteplus",openrouter:"configForm.hint.openrouter",ollama:"configForm.hint.ollama",vllm:"configForm.hint.vllm",sglang:"configForm.hint.sglang"},ce=Z[l]?x(Z[l]):void 0,X=[...new Set(Ze.map(d=>d.group))];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Xt,{title:x("configForm.modelConfig"),children:[e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 text-sm text-muted",children:[e.jsx("div",{className:"font-medium text-foreground mb-1",children:x("configForm.proxyChain")}),e.jsx("p",{children:x("configForm.proxyChainDesc")}),e.jsxs("div",{className:"mt-2 text-xs text-muted opacity-60 space-y-1",children:[e.jsxs("div",{children:[x("configForm.proxyAddress")," ",e.jsx("span",{className:"font-mono",children:V.proxyBaseUrl||x("configForm.notConfigured")})]}),e.jsxs("div",{children:[x("configForm.proxyStatus")," ",V.running?x("configForm.running"):x("configForm.notRunning"),x("configForm.virtualKeyLabel")," ",V.hasVirtualKey?x("configForm.generated"):x("configForm.notGenerated")]})]})]}),!W&&e.jsx("button",{type:"button",onClick:()=>ae(!0),className:"text-xs text-[#0066FF] hover:text-[#0066FF]/80 transition-colors",children:x("configForm.editModelConfig")}),W&&e.jsx(oe,{label:x("configForm.upstreamProvider"),hint:x("configForm.upstreamProviderHint"),children:e.jsxs(Je,{value:l,onChange:R,children:[e.jsx("option",{value:"",children:x("configForm.selectProvider")}),!i&&l&&e.jsxs("option",{value:l,children:[l," ",x("configForm.custom")]}),X.map(d=>e.jsx("optgroup",{label:x(`configForm.providerGroup.${d}`,{defaultValue:d}),children:Ze.filter(b=>b.group===d).map(b=>e.jsx("option",{value:b.id,children:x(`configForm.providerLabel.${b.id}`,{defaultValue:b.label})},b.id))},d))]})}),W&&ce&&e.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/10 border border-amber-500/20 rounded-lg px-3 py-2.5 text-xs text-amber-400",children:[e.jsx("span",{className:"shrink-0 mt-0.5",children:"⚠"}),e.jsx("span",{children:ce})]}),W&&!["ollama","vllm","sglang"].includes(l)&&l&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{label:x("configForm.upstreamApiKey"),hint:a.hasApiKey&&!a.clearApiKey?x("configForm.apiKeyHintSaved"):x("configForm.apiKeyHintNew"),children:[e.jsx(gr,{value:a.apiKey||"",saved:a.hasApiKey&&!a.clearApiKey,onChange:d=>{let b=Me(r,"x-jishushell.proxy.upstream.apiKey",d);d&&(b=Me(b,"x-jishushell.proxy.upstream.clearApiKey",!1)),c(b)},placeholder:x("configForm.enterApiKey")}),a.hasApiKey&&e.jsx("button",{type:"button",onClick:()=>{let d=Me(r,"x-jishushell.proxy.upstream.apiKey","");d=Me(d,"x-jishushell.proxy.upstream.clearApiKey",!a.clearApiKey),c(d)},className:`mt-2 text-xs ${a.clearApiKey?"text-red-400":"text-muted hover:text-foreground"} transition-colors`,children:a.clearApiKey?x("configForm.markedForClear"):x("configForm.clearSavedApiKey")})]}),y.length>0&&e.jsx(oe,{label:x("configForm.upstreamModel"),hint:x("configForm.upstreamModelHint"),children:e.jsx(Je,{value:g,onChange:S,children:y.map(d=>e.jsxs("option",{value:d.id,children:[d.name," (",Math.round(d.contextWindow/1e3),"K)"]},d.id))})})]}),W&&["ollama","vllm","sglang"].includes(l)&&e.jsxs("div",{className:"space-y-4 border-t border-[var(--border)] pt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(oe,{label:"Base URL",hint:x("configForm.localServiceAddress"),children:e.jsx(we,{value:a.baseUrl||"",onChange:d=>$("baseUrl",d),placeholder:"http://127.0.0.1:11434",mono:!0})}),e.jsx(oe,{label:x("configForm.apiProtocol"),children:e.jsxs(Je,{value:a.api||"openai-completions",onChange:d=>$("api",d),children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Compatible"}),e.jsx("option",{value:"ollama",children:"Ollama"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(oe,{label:x("configForm.modelId"),hint:x("configForm.modelIdHint"),children:e.jsx(we,{value:j.id==="default"?"":j.id,onChange:d=>{const b=[...m],E=b.findIndex(q=>q.id===g);E>=0?b[E]={...j,id:d||"default"}:b.push({id:d||"default",name:d||"default",contextWindow:j.contextWindow||0});let _=Me(r,"x-jishushell.proxy.upstream.models",b);_=Me(_,"x-jishushell.proxy.upstream.selectedModelId",d||"default"),c(_)},placeholder:"llama3",mono:!0})}),e.jsx(oe,{label:x("configForm.modelName"),children:e.jsx(we,{value:j.name==="default"?"":j.name||"",onChange:d=>{const b=[...m],E=b.findIndex(_=>_.id===g);E>=0?b[E]={...j,name:d||j.id}:b.push({id:j.id||"default",name:d||"default",contextWindow:j.contextWindow||0}),$("models",b)},placeholder:x("configForm.modelNamePlaceholder")})}),e.jsx(oe,{label:x("configForm.contextWindow"),children:e.jsx(we,{value:String(j.contextWindow||""),onChange:d=>{const b=[...m],E=b.findIndex(_=>_.id===g);E>=0?b[E]={...j,contextWindow:parseInt(d)||0}:b.push({id:j.id||"default",name:j.name||"default",contextWindow:parseInt(d)||0}),$("models",b)},placeholder:"128000",mono:!0})})]})]}),W&&!["ollama","vllm","sglang"].includes(l)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>ie(!Q),className:"text-xs text-muted hover:text-foreground transition-colors",children:x(Q?"configForm.collapseAdvanced":"configForm.advancedOptions")}),Q&&e.jsxs("div",{className:"space-y-4 border-t border-[var(--border)] pt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(oe,{label:x("configForm.upstreamBaseUrl"),children:e.jsx(we,{value:a.baseUrl||"",onChange:d=>$("baseUrl",d),placeholder:x("configForm.baseUrlPlaceholder"),mono:!0})}),e.jsx(oe,{label:x("configForm.upstreamApiProtocol"),children:e.jsxs(Je,{value:a.api||"openai-completions",onChange:d=>$("api",d),children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Compatible"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"}),e.jsx("option",{value:"google-generative-ai",children:"Google Generative AI"}),e.jsx("option",{value:"ollama",children:"Ollama"})]})})]}),l&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(oe,{label:x("configForm.modelId"),children:e.jsx(we,{value:j.id,onChange:d=>{const b=[...m],E=b.findIndex(q=>q.id===g);E>=0?b[E]={...j,id:d}:b.push({...j,id:d});let _=Me(r,"x-jishushell.proxy.upstream.models",b);_=Me(_,"x-jishushell.proxy.upstream.selectedModelId",d),c(_)},placeholder:"model-id",mono:!0})}),e.jsx(oe,{label:x("configForm.modelName"),children:e.jsx(we,{value:j.name||"",onChange:d=>{const b=[...m],E=b.findIndex(_=>_.id===g);E>=0?b[E]={...j,name:d}:b.push({...j,name:d}),$("models",b)},placeholder:"Model Name"})}),e.jsx(oe,{label:x("configForm.contextWindow"),children:e.jsx(we,{value:String(j.contextWindow||""),onChange:d=>{const b=[...m],E=b.findIndex(_=>_.id===g);E>=0?b[E]={...j,contextWindow:parseInt(d)||0}:b.push({...j,contextWindow:parseInt(d)||0}),$("models",b)},placeholder:"200000",mono:!0})})]}),e.jsx("div",{className:"text-xs text-muted bg-[var(--card)] border border-[var(--border)] rounded-md p-3",children:x("configForm.proxyNote")})]})]})]}),e.jsxs(Xt,{title:x("configForm.imChannelConfig"),id:"im-channel-section",children:[e.jsx(oe,{label:x("configForm.sessionIsolation"),hint:x("configForm.sessionIsolationHint"),children:e.jsxs(Je,{value:((ue=r==null?void 0:r.session)==null?void 0:ue.dmScope)||"main",onChange:d=>N("session.dmScope",d),children:[e.jsx("option",{value:"main",children:x("configForm.sessionMain")}),e.jsx("option",{value:"per-peer",children:x("configForm.sessionPerPeer")}),e.jsx("option",{value:"per-channel-peer",children:x("configForm.sessionPerChannelPeer")}),e.jsx("option",{value:"per-account-channel-peer",children:x("configForm.sessionPerAccountChannelPeer")})]})}),pt.map(d=>{Qe.find(G=>G.id===d);const b=x(`configForm.channel.${d}`,{defaultValue:d}),E=M[d]||{enabled:!0},_=E.enabled!==!1,q=br[d]||d,me=s[q],T=d==="openclaw-weixin"?"#07C160":"#3370FF";return e.jsxs("div",{className:"border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:b}),e.jsx("span",{className:"text-[11px] text-muted font-mono",children:d})]}),e.jsx(Yt,{checked:_,onChange:G=>{M[d]||te(d),B(d,"enabled",G)},label:x(_?"common:label.enabled":"common:label.disabled")})]}),_&&(me==="installing"?e.jsx("div",{className:"rounded-md px-4 py-3",style:{background:`${T}10`,borderColor:`${T}30`,borderWidth:1,borderStyle:"solid"},children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:T},children:[e.jsx("div",{className:"w-4 h-4 border-2 rounded-full animate-spin",style:{borderColor:`${T}30`,borderTopColor:T}}),e.jsx("span",{children:x("configForm.pluginInstalling",{label:b})})]})}):me!=="installed"?e.jsxs("div",{className:"rounded-md px-4 py-3",style:{background:`${T}08`,borderColor:`${T}30`,borderWidth:1,borderStyle:"dashed"},children:[e.jsx("button",{onClick:()=>u==null?void 0:u(q),className:"px-4 py-2 text-white rounded-md text-xs font-medium hover:opacity-90 transition-opacity",style:{background:T},children:x("configForm.installPlugin",{label:b})}),e.jsx("p",{className:"text-xs text-muted mt-2",children:x("configForm.installPluginHint",{label:b})})]}):e.jsxs(e.Fragment,{children:[(d==="feishu"||d==="lark")&&e.jsx(jr,{instanceId:n,channelKey:d,existingAppId:E.appId,existingDomain:E.domain||d,onConfigured:()=>{n&&Bt(async()=>{const{getConfig:G}=await import("./index-DbX85irc.js").then(se=>se.aj);return{getConfig:G}},__vite__mapDeps([0,1,2,3])).then(({getConfig:G})=>{G(n).then(se=>{se&&c(se)})})}}),d==="openclaw-weixin"&&e.jsx(wr,{instanceId:n,onConfigured:()=>{n&&Bt(async()=>{const{getConfig:G}=await import("./index-DbX85irc.js").then(se=>se.aj);return{getConfig:G}},__vite__mapDeps([0,1,2,3])).then(({getConfig:G})=>{G(n).then(se=>{se&&c(se)})})}})]}))]},d)}),I.filter(d=>!pt.includes(d)).map(d=>{const b=M[d],E=Qe.find(T=>T.id===d),_=x(`configForm.channel.${d}`,{defaultValue:d}),q=(E==null?void 0:E.fields)||[],me=E?[]:Object.keys(b).filter(T=>T!=="enabled"&&typeof b[T]=="string");return e.jsxs("div",{className:"border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:_}),E&&e.jsx("span",{className:"text-[11px] text-muted font-mono",children:d})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Yt,{checked:b.enabled!==!1,onChange:T=>B(d,"enabled",T),label:b.enabled!==!1?x("common:label.enabled"):x("common:label.disabled")}),e.jsx("button",{onClick:()=>pe(d),className:"text-xs text-red-400 hover:text-red-300 transition-colors",children:x("configForm.remove")})]})]}),b.enabled!==!1&&q.length>0&&e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:q.map(T=>e.jsx(oe,{label:T.label,children:e.jsx(we,{value:b[T.key]||"",onChange:G=>B(d,T.key,G),placeholder:T.placeholder,type:T.type||"text",mono:!0})},T.key))}),b.enabled!==!1&&me.length>0&&e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:me.map(T=>e.jsx(oe,{label:T,children:e.jsx(we,{value:b[T]||"",onChange:G=>B(d,T,G),placeholder:T,type:T.toLowerCase().includes("secret")||T.toLowerCase().includes("token")||T.toLowerCase().includes("password")?"password":"text",mono:!0})},T))}),b.enabled!==!1&&d==="whatsapp"&&q.length===0&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-md px-3 py-2 text-xs text-amber-400",children:[e.jsx("p",{className:"font-medium mb-1",children:x("configForm.whatsappTitle")}),e.jsx("p",{children:x("configForm.whatsappHint")})]})]},d)}),e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:x("configForm.addImChannel")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Qe.filter(d=>{if(pt.includes(d.id))return!1;const b=z[d.id]||d.id;return!I.includes(b)&&!I.includes(d.id)}).map(d=>e.jsxs("button",{onClick:()=>te(d.id),className:"px-3 py-1.5 text-xs border border-dashed rounded-md transition-colors duration-150 border-[var(--border)] text-muted hover:border-[var(--border-hover)] hover:text-foreground",children:["+ ",x(d.labelKey,{defaultValue:d.id})]},d.id))})]})]})]})}function jr({instanceId:r,channelKey:c,existingAppId:n,existingDomain:h,onConfigured:s}){const{t:u}=Ae(["instance","common"]);(c||h)==="lark"||u("configForm.feishu.platformFeishu");const[N,t]=p.useState(""),[a,l]=p.useState(""),[i,m]=p.useState("idle"),[y,g]=p.useState(""),[F,j]=p.useState(""),V=p.useRef(!1),R=p.useRef(!1),S=async()=>{if(r){R.current=!1,m("loading"),g(""),t("");try{let I=null;for(let B=0;B<3;B++){if(R.current)return;try{if(I=await ts(r,c),I!=null&&I.qrcodeUrl)break}catch{B<2&&await new Promise(z=>setTimeout(z,1500))}}if(R.current)return;I!=null&&I.qrcodeUrl?(t(I.qrcodeUrl),l(I.sessionKey),m("waiting"),g(u("configForm.feishu.scanHint")),$(I.sessionKey)):(m("error"),g(u("qr.getFailed")))}catch{R.current||(m("error"),g(u("qr.getFailed")))}}},$=I=>{if(!r||V.current)return;V.current=!0;const B=async()=>{if(V.current)try{const z=await rs(r,I);if(z.connected){V.current=!1,m("confirmed"),g(z.message||u("qr.loginSuccess")),j(z.domain||"feishu"),t(""),s==null||s();return}if(z.status==="expired"){V.current=!1,m("error"),g(z.message||u("qr.expired"));return}setTimeout(B,3e3)}catch{V.current&&setTimeout(B,3e3)}};B()};if(p.useEffect(()=>()=>{V.current=!1},[]),i==="confirmed")return e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[e.jsx("span",{className:"text-lg",children:"✓"}),e.jsx("span",{className:"font-medium",children:y})]}),e.jsx("p",{className:"text-xs text-muted mt-1",children:u("configForm.feishu.platform",{platform:u(F==="lark"?"configForm.feishu.platformLark":"configForm.feishu.platformFeishu")})})]});if(i==="idle"||i==="error")return e.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[n&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:u("configForm.feishu.added")}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-emerald-400",children:"✓"}),e.jsx("code",{className:"font-mono text-foreground/70",children:n}),e.jsx("span",{className:"text-muted opacity-60",children:h==="lark"?"Lark":u("configForm.feishu.platformFeishu")})]})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:S,className:"px-4 py-2 bg-[#3370FF] text-white rounded-md text-xs font-medium hover:bg-[#3370FF]/90 transition-colors",children:u("configForm.feishu.addBot")}),e.jsx("p",{className:"text-xs text-muted mt-2",children:u("configForm.feishu.addBotHint")})]})]});const M=()=>{R.current=!0,V.current=!1,m("idle"),g(""),t(""),l("")};return e.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[N?e.jsx(rt,{value:N,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#3370FF]/30 border-t-[#3370FF] rounded-full animate-spin"})}),e.jsx("div",{className:"text-sm text-muted",children:i==="loading"?u("configForm.feishu.gettingQr"):y}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:M,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:u("configForm.feishu.cancel")}),e.jsx("button",{onClick:()=>{M(),setTimeout(S,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:u("configForm.feishu.refresh")})]})]})})}function wr({instanceId:r,onConfigured:c}){const{t:n,i18n:h}=Ae(["instance","common"]),[s,u]=p.useState(""),[x,N]=p.useState(""),[t,a]=p.useState("idle"),[l,i]=p.useState(""),[m,y]=p.useState(""),[g,F]=p.useState([]),j=p.useRef(!1),V=p.useRef(!1);p.useEffect(()=>{r&&Ut(r).then(M=>{var I;(I=M==null?void 0:M.accounts)!=null&&I.length&&F(M.accounts)}).catch(()=>{})},[r]);const R=async()=>{if(r){V.current=!1,a("loading"),i(""),u("");try{let M=null;for(let I=0;I<3;I++){if(V.current)return;try{if(M=await ss(r),M!=null&&M.qrcodeUrl)break}catch{I<2&&await new Promise(B=>setTimeout(B,1500))}}if(V.current)return;M!=null&&M.qrcodeUrl?(u(M.qrcodeUrl),N(M.sessionKey),a("waiting"),i(n("configForm.weixin.scanHint")),S(M.sessionKey)):(a("error"),i(n("qr.getFailed")))}catch{V.current||(a("error"),i(n("qr.getFailed")))}}},S=M=>{if(!r||j.current)return;j.current=!0;const I=async()=>{if(j.current)try{const B=await as(r,M);if(B.connected){j.current=!1,a("confirmed"),i(B.message||n("qr.loginSuccess")),y(B.accountId||""),u(""),r&&Ut(r).then(z=>{z!=null&&z.accounts&&F(z.accounts)}).catch(()=>{}),c==null||c();return}if(B.status==="scaned")a("scaned"),i(B.message||n("qr.scaned"));else if(B.status==="refreshed"&&B.qrcodeUrl)u(B.qrcodeUrl),a("waiting"),i(n("qr.refreshed"));else if(B.status==="expired"){j.current=!1,a("error"),i(B.message||n("qr.expired"));return}setTimeout(I,2e3)}catch{j.current&&setTimeout(I,3e3)}};I()};if(p.useEffect(()=>()=>{j.current=!1},[]),t==="confirmed")return e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[e.jsx("span",{className:"text-lg",children:"✓"}),e.jsx("span",{className:"font-medium",children:l})]}),m&&e.jsxs("p",{className:"text-xs text-muted mt-1",children:[n("configForm.weixin.accountId")," ",e.jsx("code",{className:"font-mono",children:m})]}),e.jsx("p",{className:"text-xs text-muted mt-1",children:n("configForm.weixin.restartHint")}),e.jsx("button",{onClick:R,className:"mt-2 px-3 py-1 text-xs border border-emerald-500/30 rounded text-emerald-400 hover:bg-emerald-500/10 transition-colors",children:n("configForm.weixin.addAnother")})]});if(t==="idle"||t==="error")return e.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[g.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:n("configForm.weixin.added")}),g.map(M=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsx("span",{className:"text-emerald-400",children:"✓"}),e.jsx("code",{className:"font-mono text-foreground/70",children:M.accountId}),M.savedAt&&e.jsx("span",{className:"text-muted opacity-60",children:new Date(M.savedAt).toLocaleDateString(h.language==="zh"?"zh-CN":"en-US")})]},M.accountId))]}),e.jsxs("div",{children:[e.jsx("button",{onClick:R,className:"px-4 py-2 bg-[#07C160] text-white rounded-md text-xs font-medium hover:bg-[#07C160]/90 transition-colors",children:n("configForm.weixin.addClawBot")}),e.jsx("p",{className:"text-xs text-muted mt-2",children:n("configForm.weixin.addClawBotHint",{extra:g.length>0?n("configForm.weixin.addClawBotHintRestart"):n("configForm.weixin.addClawBotHintMulti")})})]})]});const $=()=>{V.current=!0,j.current=!1,a("idle"),i(""),u(""),N("")};return e.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s?e.jsx(rt,{value:s,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#07C160]/30 border-t-[#07C160] rounded-full animate-spin"})}),e.jsx("div",{className:"flex items-center gap-2 text-sm",children:t==="scaned"?e.jsxs("span",{className:"text-[#07C160] font-medium",children:["👀 ",l]}):t==="loading"?e.jsx("span",{className:"text-muted",children:n("configForm.weixin.gettingQr")}):e.jsx("span",{className:"text-muted",children:l})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:$,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:n("configForm.weixin.cancel")}),e.jsx("button",{onClick:()=>{$(),setTimeout(R,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:n("configForm.weixin.refresh")})]})]})})}const kr="im",yr="即时通讯",Nr="💬",Cr=[{id:"feishu",label:"飞书 / Lark",desc:"飞书机器人(WebSocket 模式)"},{id:"openclaw-weixin",label:"微信",desc:"微信扫码接入"}],Fr={id:kr,label:yr,emoji:Nr,items:Cr},Sr="skills",Er="常用 Skill",Mr="⚡",Ar=[{id:"hubs",label:"热门Hub",emoji:"🌐",skills:[{id:"clawhub",type:"hub",label:"ClawHub",desc:"OpenClaw 官方 Skill 市场",url:"https://clawhub.ai/",installMsg:""},{id:"skillhub-tencent",type:"hub",label:"腾讯 SkillHub",desc:"腾讯技能中心,官方出品",url:"https://skillhub.tencent.com/",installMsg:""},{id:"skills-sh",type:"hub",label:"Skills.sh",desc:"第三方 Skill 聚合社区",url:"https://skills.sh/",installMsg:""},{id:"lobehub-skills",type:"hub",label:"LobeHub Skills",desc:"LobeHub 社区 Skill 市场",url:"https://lobehub.com/skills",installMsg:""},{id:"findskills",type:"hub",label:"FindSkills.org",desc:"开源 Skill 搜索与聚合平台",url:"https://www.findskills.org/",installMsg:""},{id:"playbooks-skills",type:"hub",label:"Playbooks Skills",desc:"Playbooks 社区 Skill 目录",url:"https://playbooks.com/skills",installMsg:""}]},{id:"general",label:"通用基础",emoji:"🧠",skills:[{id:"skill-vetter",label:"Skill Vetter",desc:"安全审计 Skill,安装前建议先审查",installMsg:"根据以下链接安装skill:https://clawhub.ai/spclaudehome/skill-vetter",autoInstall:!0,slashCmd:"/skill-vetter",checkDirs:["skill-vetter","Skill Vetter","SkillVetter","vetter"]},{id:"self-improving-agent-cn",label:"Self-Improving CN Agent",desc:"自我优化的 Agent,持续改进任务执行",installMsg:"根据以下链接安装skill:https://clawhub.ai/zhengxinjipai/self-improving-agent-cn",autoInstall:!0,slashCmd:"/self-improving-agent-cn",checkDirs:["self-improving-agent-cn","SelfImprovingAgentCn","self_improving_agent_cn"]},{id:"proactive-agent",label:"Proactive Agent",desc:"主动式 Agent,自动感知并提前完成任务",installMsg:"根据以下链接安装skill:https://clawhub.ai/bestrocky/proactive-agent-lite",autoInstall:!0,slashCmd:"/proactive-agent",checkDirs:["proactive-agent-lite","proactive-agent","ProactiveAgent","proactive_agent"]},{id:"multi-search-engine",label:"Multi Search Engine",desc:"多搜索引擎聚合搜索",installMsg:"根据以下链接安装skill:https://clawhub.ai/gpyangyoujun/multi-search-engine",autoInstall:!0,slashCmd:"/multi-search-engine",checkDirs:["multi-search-engine","MultiSearchEngine","multi_search_engine"]},{id:"exa-web-search-free",label:"Exa Web Search Free",desc:"免费 Exa 网页语义搜索",installMsg:"根据以下链接安装skill:https://clawhub.ai/whiteknight07/exa-web-search-free",autoInstall:!0,slashCmd:"/exa-web-search-free",checkDirs:["exa-web-search-free","ExaWebSearchFree","exa_web_search_free"]},{id:"filesystem",label:"Filesystem",desc:"本地文件系统读写与管理",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/filesystem",autoInstall:!0,slashCmd:"/filesystem",checkDirs:["filesystem","steipete-filesystem"]},{id:"summarize",label:"Summarize",desc:"内容摘要与总结提炼",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/summarize",autoInstall:!0,slashCmd:"/summarize",checkDirs:["summarize","steipete-summarize"]},{id:"baidu-search",label:"百度搜索",desc:"百度搜索引擎集成",installMsg:"根据以下链接安装skill:https://clawhub.ai/ide-rea/baidu-search",autoInstall:!0,slashCmd:"/baidu-search",checkDirs:["baidu-search","BaiduSearch"]},{id:"agent-browser-clawdbot",label:"Agent Browser",desc:"AI 驱动的网页浏览与自动化操作",installMsg:"根据以下链接安装skill:https://clawhub.ai/matrixy/agent-browser-clawdbot",autoInstall:!0,slashCmd:"/agent-browser-clawdbot",checkDirs:["agent-browser-clawdbot","agent-browser","AgentBrowser"]},{id:"automation-workflows",label:"Automation Workflows",desc:"自动化工作流编排与执行",installMsg:"根据以下链接安装skill:https://clawhub.ai/jk-0001/automation-workflows",autoInstall:!0,slashCmd:"/automation-workflows",checkDirs:["automation-workflows","AutomationWorkflows"]},{id:"evolver",label:"Evolver",desc:"Agent 自动进化与能力迭代",installMsg:"根据以下链接安装skill:https://clawhub.ai/autogame-17/evolver",autoInstall:!0,slashCmd:"/evolver",checkDirs:["evolver","autogame-evolver"]}]},{id:"productivity",label:"工作效率",emoji:"💼",skills:[{id:"pdf-reader",label:"PDF Reader",desc:"PDF 文档读取与分析",installMsg:"根据以下链接安装skill:https://clawhub.ai/awspace/pdf",autoInstall:!0,slashCmd:"/pdf",checkDirs:["pdf","pdf-reader","awspace-pdf"]},{id:"powerpoint-pptx",label:"PowerPoint / PPTX",desc:"PPT 演示文稿生成与编辑",installMsg:"根据以下链接安装skill:https://clawhub.ai/ivangdavila/powerpoint-pptx",autoInstall:!0,slashCmd:"/powerpoint-pptx",checkDirs:["powerpoint-pptx","powerpoint","pptx"]},{id:"word-docx",label:"Word / DOCX",desc:"Word 文档生成与编辑",installMsg:"根据以下链接安装skill:https://clawhub.ai/ivangdavila/word-docx",autoInstall:!0,slashCmd:"/word-docx",checkDirs:["word-docx","word","docx"]},{id:"excel-xlsx",label:"Excel / XLSX",desc:"Excel 表格生成与数据处理",installMsg:"根据以下链接安装skill:https://clawhub.ai/ivangdavila/excel-xlsx",autoInstall:!0,slashCmd:"/excel-xlsx",checkDirs:["excel-xlsx","excel","xlsx"]},{id:"ai-ppt-generator",label:"AI PPT Generator",desc:"AI 自动生成 PPT 演示文稿",installMsg:"根据以下链接安装skill:https://clawhub.ai/ide-rea/ai-ppt-generator",autoInstall:!0,slashCmd:"/ai-ppt-generator",checkDirs:["ai-ppt-generator","AiPptGenerator"]},{id:"nano-banana-pro",label:"Nano Banana Pro",desc:"轻量高效的任务执行与流程优化",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/nano-banana-pro",autoInstall:!0,slashCmd:"/nano-banana-pro",checkDirs:["nano-banana-pro","NanoBananaPro"]},{id:"ppt-generator",label:"PPT Generator",desc:"PPT 演示文稿智能生成",installMsg:"根据以下链接安装skill:https://clawhub.ai/wwlyzzyorg/ppt-generator",autoInstall:!0,slashCmd:"/ppt-generator",checkDirs:["ppt-generator","PptGenerator"]},{id:"marketing-mode",label:"Marketing Mode",desc:"营销文案与推广内容创作",installMsg:"根据以下链接安装skill:https://clawhub.ai/thesethrose/marketing-mode",autoInstall:!0,slashCmd:"/marketing-mode",checkDirs:["marketing-mode","MarketingMode"]},{id:"data-analysis",label:"Data Analysis",desc:"数据分析与可视化报告生成",installMsg:"根据以下链接安装skill:https://clawhub.ai/ivangdavila/data-analysis",autoInstall:!0,slashCmd:"/data-analysis",checkDirs:["data-analysis","DataAnalysis"]}]},{id:"life",label:"生活辅助",emoji:"🏠",skills:[{id:"todo-manager",label:"Todo Manager",desc:"任务与待办事项管理",installMsg:"根据以下链接安装skill:https://clawhub.ai/aeoleader/todo-manager",autoInstall:!0,slashCmd:"/todo-manager",checkDirs:["todo-manager","todo","TodoManager"]},{id:"12306",label:"12306 火车票",desc:"查询与购买 12306 火车票",installMsg:"根据以下链接安装skill:https://clawhub.ai/kirorab/12306",autoInstall:!0,slashCmd:"/12306",checkDirs:["12306","kirorab-12306"]},{id:"youtube-watcher",label:"YouTube Watcher",desc:"YouTube 视频摘要与内容分析",installMsg:"根据以下链接安装skill:https://clawhub.ai/michaelgathara/youtube-watcher",autoInstall:!0,slashCmd:"/youtube-watcher",checkDirs:["youtube-watcher","youtube","YoutubeWatcher"]},{id:"xiaohongshu-cn",label:"小红书助手",desc:"小红书内容创作与运营辅助",installMsg:"根据以下链接安装skill:https://clawhub.ai/guohongbin-git/xiaohongshu-cn",autoInstall:!0,slashCmd:"/xiaohongshu-cn",checkDirs:["xiaohongshu-cn","xiaohongshu","XiaohongshuCn"]},{id:"wechat-mp-cn",label:"微信公众号助手",desc:"微信公众号内容创作与发布辅助",installMsg:"根据以下链接安装skill:https://clawhub.ai/guohongbin-git/wechat-mp-cn",autoInstall:!0,slashCmd:"/wechat-mp-cn",checkDirs:["wechat-mp-cn","wechat-mp","WechatMpCn"]},{id:"weather",label:"Weather",desc:"实时天气查询与预报",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/weather",autoInstall:!0,slashCmd:"/weather",checkDirs:["weather","steipete-weather"]},{id:"stock-analysis",label:"Stock Analysis",desc:"股票行情分析与投资参考",installMsg:"根据以下链接安装skill:https://clawhub.ai/udiedrichsen/stock-analysis",autoInstall:!0,slashCmd:"/stock-analysis",checkDirs:["stock-analysis","StockAnalysis"]},{id:"news-summary",label:"News Summary",desc:"新闻资讯聚合与摘要生成",installMsg:"根据以下链接安装skill:https://clawhub.ai/joargp/news-summary",autoInstall:!0,slashCmd:"/news-summary",checkDirs:["news-summary","NewsSummary"]}]},{id:"dev",label:"开发工具",emoji:"🛠️",skills:[{id:"github",label:"GitHub",desc:"GitHub 仓库管理与代码协作",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/github",autoInstall:!0,slashCmd:"/github",checkDirs:["github","GitHub","steipete-github"]},{id:"gemini",label:"Gemini",desc:"Google Gemini 模型接入与调用",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/gemini",autoInstall:!0,slashCmd:"/gemini",checkDirs:["gemini","Gemini","steipete-gemini"]},{id:"api-gateway",label:"API Gateway",desc:"API 接口管理与请求代理",installMsg:"根据以下链接安装skill:https://clawhub.ai/byungkyu/api-gateway",autoInstall:!0,slashCmd:"/api-gateway",checkDirs:["api-gateway","ApiGateway"]},{id:"mcporter",label:"MCPorter",desc:"MCP 服务器管理工具",installMsg:"根据以下链接安装skill:https://clawhub.ai/steipete/mcporter",autoInstall:!0,slashCmd:"/mcporter",checkDirs:["mcporter","MCPorter","steipete-mcporter"]},{id:"session-logs",label:"Session Logs",desc:"会话日志记录与回放分析",installMsg:"根据以下链接安装skill:https://clawhub.ai/guogang1024/session-logs",autoInstall:!0,slashCmd:"/session-logs",checkDirs:["session-logs","SessionLogs"]}]}],et={id:Sr,label:Er,emoji:Mr,groups:Ar},Pr="mcp",Ir="常用 MCP",Rr="🔌",Lr=[{id:"12306-mcp",label:"12306-MCP车票查询工具",desc:"12306-MCP车票查询工具",mcpJson:{"12306-mcp":{command:"npx",args:["-y","12306-mcp"]}}},{id:"bing-search",label:"Bing 搜索",desc:"必应搜索引擎 MCP 接入",mcpJson:{"bing-search":{command:"npx",args:["-y","bing-cn-mcp"]}}},{id:"fxbaogao-mcp",label:"发现报告",desc:"发现报告研究报告检索与阅读",mcpJson:{"fxbaogao-mcp":{command:"uvx",args:["fxbaogao-mcp@latest"]}}}],Dr={id:Pr,label:Ir,emoji:Rr,items:Lr},Tr="slash",Vr="常用 /命令",_r="/",$r=[{label:"会话",items:[{id:"slash-new",label:"/new",desc:"开启新会话",cmd:"/new",send:!0},{id:"slash-reset",label:"/reset",desc:"重置当前会话",cmd:"/reset",send:!0},{id:"slash-compact",label:"/compact",desc:"压缩会话上下文",cmd:"/compact",send:!0},{id:"slash-stop",label:"/stop",desc:"停止当前运行",cmd:"/stop",send:!0},{id:"slash-clear",label:"/clear",desc:"清空聊天记录",cmd:"/clear",send:!0},{id:"slash-focus",label:"/focus",desc:"切换专注模式",cmd:"/focus",send:!0}]},{label:"模型",items:[{id:"slash-model",label:"/model <name>",desc:"查看或切换模型",cmd:"/model ",send:!1},{id:"slash-think",label:"/think <level>",desc:"设置思考深度",cmd:"/think ",send:!1},{id:"slash-verbose",label:"/verbose <on|off|full>",desc:"切换详细输出模式",cmd:"/verbose ",send:!1},{id:"slash-fast",label:"/fast <status|on|off>",desc:"切换快速模式",cmd:"/fast ",send:!1}]},{label:"工具",items:[{id:"slash-help",label:"/help",desc:"查看可用命令",cmd:"/help",send:!0},{id:"slash-status",label:"/status",desc:"显示会话状态(agent)",cmd:"/status",send:!0},{id:"slash-export",label:"/export",desc:"导出会话为 Markdown",cmd:"/export",send:!0},{id:"slash-usage",label:"/usage",desc:"显示 Token 用量",cmd:"/usage",send:!0}]}],Or={id:Tr,label:Vr,emoji:_r,groups:$r};function Br({gatewayLaunchUrl:r,gatewayReady:c,isRunning:n,isPending:h,iframeLoaded:s,actionLoading:u,onAction:x,onReload:N,onIframeLoad:t}){const{t:a}=Ae("instance");return e.jsx("div",{className:"overflow-hidden rounded-[22px] border border-[var(--border)] bg-[var(--card)] shadow-[0_18px_48px_rgba(15,23,42,0.06)]",children:e.jsxs("div",{className:"relative",style:{height:"calc(100vh - 160px)",minHeight:"500px"},children:[(!n||!c||!s)&&e.jsx("div",{className:`absolute inset-0 w-full h-full bg-[var(--card)] flex flex-col items-center justify-center z-10 transition-opacity duration-300 ${s?"opacity-0 pointer-events-none":"opacity-100"}`,children:n?c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin mb-3"}),e.jsx("div",{className:"text-sm text-foreground/60",children:a("chat.loadingChat")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin mb-3"}),e.jsx("div",{className:"text-sm text-foreground/60",children:a("chat.waitingGateway")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-4xl mb-4 opacity-40",children:"💬"}),e.jsx("div",{className:"text-sm text-foreground/60 font-medium mb-1",children:a("chat.notReady")}),e.jsx("div",{className:"text-xs text-muted mb-4",children:a("chat.startHint")}),e.jsx("button",{onClick:()=>x("start"),disabled:!!u||h,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:a(u==="start"||h?"action.starting":"chat.startInstance")})]})}),c&&r&&e.jsx("iframe",{id:"gateway-iframe",src:r,className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals",allow:"microphone; camera; clipboard-write",onLoad:t})]})})}function Ur({logs:r,logSearch:c,logType:n,logsEndRef:h,onSearchChange:s,onLogTypeChange:u,onRefresh:x,onCopy:N}){const{t}=Ae("instance"),a=c?r.filter(l=>l.toLowerCase().includes(c.toLowerCase())):r;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Ps,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted"}),e.jsx("input",{type:"text",value:c,onChange:l=>s(l.target.value),placeholder:t("logs.searchPlaceholder"),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md pl-9 pr-3 py-1.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors"})]}),e.jsx("div",{className:"flex items-center gap-1",children:["stderr","stdout"].map(l=>e.jsx("button",{onClick:()=>u(l),className:`px-2.5 py-1.5 text-xs rounded-md transition-colors duration-150 ${n===l?"bg-[#0066FF] text-white":"text-muted hover:bg-[var(--card-hover)]"}`,children:l},l))}),e.jsx("button",{onClick:x,className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-colors",title:t("common:action.refresh"),children:e.jsx(ls,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:N,className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-colors",title:t("common:action.copyAll"),children:e.jsx(Is,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"bg-black/60 border border-[var(--border)] rounded-xl font-mono text-[13px] p-4 min-h-[400px] lg:min-h-[500px] overflow-auto max-h-[70vh]",children:[a.length===0?e.jsx("p",{className:"text-muted",children:t("logs.empty")}):a.map((l,i)=>{const m=/error|ERR|panic|fatal/i.test(l),y=/warn|WARN/i.test(l);return e.jsx("div",{className:`whitespace-pre-wrap break-all leading-5 ${m?"text-red-400 bg-red-950/20":y?"text-amber-400":"text-foreground opacity-70"}`,children:l},`${i}-${l.slice(0,32)}`)}),e.jsx("div",{ref:h})]})]})}function zr({usage:r,onRefresh:c}){const{t:n}=Ae("instance");if(!r)return e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[1,2,3].map(s=>e.jsx("div",{className:"h-20 bg-[var(--card)] rounded-lg"},s))}),e.jsx("div",{className:"h-60 bg-[var(--card)] rounded-lg"})]})});const h=nr.language==="zh"?"zh-CN":"en-US";return e.jsxs("div",{className:"space-y-4",children:[r.totals.totalTokens===0&&r.totals.messages>0&&e.jsx("div",{className:"bg-[var(--card)] border border-[var(--border)] text-muted text-sm rounded-lg px-4 py-3",children:n("usage.noTokenData")}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3",children:[{label:n("usage.messages"),value:r.totals.messages.toLocaleString()},{label:n("usage.totalTokens"),value:r.totals.totalTokens.toLocaleString()},{label:n("usage.totalCost"),value:`$${r.totals.costTotal.toFixed(4)}`}].map(s=>e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4 hover:border-[var(--border-hover)] transition-colors",children:[e.jsx("div",{className:"text-xs text-muted mb-1",children:s.label}),e.jsx("div",{className:"text-2xl font-semibold text-foreground",children:s.value})]},s.label))}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[n("usage.sessions")," (",r.sessions.length,")"]}),e.jsx("button",{onClick:c,className:"text-xs text-muted hover:text-foreground transition-colors",children:n("common:action.refresh")})]}),r.sessions.length===0?e.jsx("p",{className:"text-muted text-sm p-4",children:n("usage.noSessions")}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left font-medium px-4 py-2",children:n("usage.time")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:n("usage.model")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:n("usage.source")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:n("usage.messagesShort")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:n("usage.input")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:n("usage.output")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:n("usage.tokens")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:n("usage.cost")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:r.sessions.map(s=>e.jsxs("tr",{className:"hover:bg-[var(--card-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-muted whitespace-nowrap",children:s.lastMessage?new Date(s.lastMessage).toLocaleString(h,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}),e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-muted",children:s.model||"-"}),e.jsxs("td",{className:"px-4 py-2 text-muted",children:[s.channel&&e.jsx("span",{className:"inline-block bg-[var(--card-hover)] text-muted text-[11px] px-1.5 py-0.5 rounded mr-1 font-medium",children:s.channel}),e.jsx("span",{className:"text-xs text-muted opacity-60",children:s.origin?s.origin.length>20?s.origin.slice(0,20)+"...":s.origin:""})]}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-muted",children:s.usage.messages}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:s.usage.input.toLocaleString()}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:s.usage.output.toLocaleString()}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:s.usage.totalTokens.toLocaleString()}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:["$",s.usage.costTotal.toFixed(4)]})]},s.key))})]})})]})]})}function qr({instanceId:r,instanceName:c,showToast:n,onRestoreComplete:h,openBackup:s,openManage:u,openExport:x,onDialogClose:N}){var Ce;const{t}=Ae("instance"),a=ns(),[l,i]=p.useState(!1),[m,y]=p.useState(!1),[g,F]=p.useState(null),[j,V]=p.useState(null),[R,S]=p.useState(!1),[$,M]=p.useState(!1),[I,B]=p.useState(null),[z,te]=p.useState(null),[pe,Q]=p.useState([]),[ie,W]=p.useState(!1),[ae,Z]=p.useState(!1),[ce,X]=p.useState("home"),[ge,ne]=p.useState(""),[ue,d]=p.useState(""),[b,E]=p.useState("");p.useEffect(()=>{s&&i(!0)},[s]),p.useEffect(()=>{u&&(be(),y(!0))},[u]),p.useEffect(()=>{x&&S(!0)},[x]);const[_,q]=p.useState(null),[me,T]=p.useState(""),[G,se]=p.useState("");p.useEffect(()=>{!l&&!m&&!R&&!g&&!j&&!z&&!I&&!_&&(N==null||N())},[l,m,R,g,j,z,I,_]);const[fe,ke]=p.useState({enabled:!1}),[he,ye]=p.useState(!1),be=p.useCallback(async()=>{try{const[w,L]=await Promise.all([Rs(r),Ls(r).catch(()=>({enabled:!1}))]);Q(Array.isArray(w)?w:[]),ke(L)}catch{}},[r]);p.useEffect(()=>{be()},[be]),p.useEffect(()=>{if(!_)return;let w=!1;return(async()=>{var J,H,le;for(;!w;)try{const re=await Vs(_);if(w)break;if(se(re.progress||""),re.status==="completed"){if(q(null),T(""),W(!1),re.operation==="manual-backup")te({type:"success",title:t("backup.created",{defaultValue:"备份完成"}),detail:(J=re.result)!=null&&J.filename?`${re.result.filename} (${Pe(re.result.size||0)})`:""}),be();else if(re.operation==="export")B(re.result);else if(re.operation==="restore"){const xe=re.result||{};xe.ok?te({type:"success",title:t("backup.restoreSuccess",{defaultValue:"恢复完成"}),detail:xe.api_key_status==="lost"?t("backup.apiKeyLost",{defaultValue:"备份来自不同平台/架构,请确认 API Key 配置是否仍然适用。"}):((H=xe.warnings)==null?void 0:H.join(`
|
|
11
|
-
`))||"",actions:xe.api_key_status==="lost"?[{label:t("backup.configApiKey",{defaultValue:"配置 API Key"}),onClick:()=>{te(null),a(`/instances/${r}/config`)}}]:void 0}):te({type:"error",title:xe.rolled_back?t("backup.restoreFailedRolledBack",{defaultValue:"恢复失败 — 已自动回滚"}):t("backup.restoreFailed",{defaultValue:"恢复失败"}),detail:((le=xe.warnings)==null?void 0:le.join(`
|
|
12
|
-
`))||""}),be(),h==null||h()}break}else if(re.status==="failed"){q(null),T(""),W(!1),n(re.error||"Operation failed","error");break}await new Promise(xe=>setTimeout(xe,1500))}catch{break}})(),()=>{w=!0}},[_]);const Te=async()=>{W(!0),i(!1);try{const w=await _s(r,{include_sessions:ae,scope:ce});w.job_id?(q(w.job_id),T("manual-backup"),se("Queued...")):(te({type:"success",title:t("backup.created",{defaultValue:"备份完成"}),detail:`${w.filename} (${Pe(w.size)})`}),W(!1),be())}catch(w){n(w.message||t("backup.failed",{defaultValue:"备份失败"}),"error"),W(!1)}finally{Z(!1),X("home")}},Oe=async w=>{var L,J;W(!0),F(null),ne("");try{const H=await $s(r,w);if(H.job_id)q(H.job_id),T("restore"),se("Queued...");else{if(H.ok){const le=(L=H.warnings)!=null&&L.length?H.warnings.join(`
|
|
13
|
-
`):"";te({type:"success",title:t("backup.restoreSuccess",{defaultValue:"恢复完成"}),detail:H.api_key_status==="lost"?t("backup.apiKeyLost",{defaultValue:"备份来自不同平台/架构,请确认 API Key 配置是否仍然适用。"}):le||t("backup.restoreOk",{defaultValue:"实例已恢复。"}),actions:H.api_key_status==="lost"?[{label:t("backup.configApiKey",{defaultValue:"配置 API Key"}),onClick:()=>{te(null),a(`/instances/${r}/config`)}}]:void 0}),h==null||h()}else te({type:"error",title:H.rolled_back?t("backup.restoreFailedRolledBack",{defaultValue:"恢复失败 — 已自动回滚"}):t("backup.restoreFailed",{defaultValue:"恢复失败"}),detail:((J=H.warnings)==null?void 0:J.join(`
|
|
14
|
-
`))||""});be(),W(!1)}}catch(H){n(H.message||"Restore failed","error"),W(!1)}},U=async w=>{var L;if(!(!ue||!b)){W(!0);try{const J=await Os({source_id:r,backup_file:w,new_id:ue,new_name:b});V(null),J.ok?(n(t("backup.createFromBackupOk",{defaultValue:"新实例创建成功"}),"success"),(L=J.warnings)!=null&&L.length&&J.warnings.forEach(H=>n(H,"info")),a(`/instances/${J.instance_id}/config`)):n(J.detail||t("backup.createFromBackupFail",{defaultValue:"创建失败"}),"error")}catch(J){n(J.message||"Failed","error")}finally{W(!1),d(""),E("")}}},Se=async w=>{try{await Bs(r,w),n(t("backup.deleted",{defaultValue:"已删除"}),"info"),be()}catch(L){n(L.message||"Delete failed","error")}},at=async()=>{W(!0),S(!1);try{const w=await Us(r,{include_sessions:$});w.job_id?(q(w.job_id),T("export"),se("Queued...")):(B(w),W(!1))}catch(w){n(w.message||"Export failed","error"),W(!1)}finally{M(!1)}};function Pe(w){return w<1024?`${w}B`:w<1024*1024?`${(w/1024).toFixed(1)}KB`:`${(w/(1024*1024)).toFixed(1)}MB`}function Ie(w){const L=new Date(w),J=L.getFullYear(),H=L.getMonth()+1,le=L.getDate(),re=String(L.getHours()).padStart(2,"0"),xe=String(L.getMinutes()).padStart(2,"0"),ve=String(L.getSeconds()).padStart(2,"0");return`${J}/${H}/${le} ${re}:${xe}:${ve}`}function He(w){return w==="auto-backup"?t("backup.typeAuto",{defaultValue:"自动"}):w==="pre-restore"?t("backup.typePreRestore",{defaultValue:"恢复前"}):t("backup.typeManual",{defaultValue:"手动"})}const Ve="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200",Ee="px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-150",Ne="px-4 py-2 border border-[var(--border)] text-muted rounded-md text-sm font-medium hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-150";return e.jsxs(e.Fragment,{children:[_&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 max-w-sm w-full mx-4 space-y-4 shadow-2xl text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("span",{className:"w-8 h-8 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin"})}),e.jsx("p",{className:"text-sm text-foreground",children:G||t("backup.processing",{defaultValue:"处理中..."})}),e.jsx("p",{className:"text-xs text-muted",children:t("backup.queueNote",{defaultValue:"任务将按顺序执行"})})]})}),l&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{i(!1),Z(!1),X("home")},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",onClick:w=>w.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-2",children:t("backup.createTitle",{defaultValue:"创建备份"})}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("backup.createDesc",{defaultValue:"备份当前实例的配置、插件和数据。"})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"backup-scope",value:"home",checked:ce==="home",onChange:()=>X("home"),className:"mt-1"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:t("backup.scopeFull",{defaultValue:"完整备份(含运行时)"})}),e.jsx("div",{className:"text-xs text-[var(--muted)]",children:t("backup.scopeFullDesc",{defaultValue:"包含升级后的 OpenClaw 运行时——恢复后保持当前版本"})})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"backup-scope",value:"state",checked:ce==="state",onChange:()=>X("state"),className:"mt-1"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:t("backup.scopeState",{defaultValue:"仅数据(更小、可移植)"})}),e.jsx("div",{className:"text-xs text-[var(--muted)]",children:t("backup.scopeStateDesc",{defaultValue:"仅 .openclaw/ 数据——体积小,兼容官方 OpenClaw 格式"})})]})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted cursor-pointer mb-5",children:[e.jsx("input",{type:"checkbox",checked:ae,onChange:w=>Z(w.target.checked),className:"rounded border-[var(--border)] bg-[var(--input-bg)]"}),t("backup.includeSessions",{defaultValue:"包含对话历史(体积较大)"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:`flex-1 ${Ne}`,onClick:()=>{i(!1),Z(!1),X("home")},children:t("common:action.cancel",{defaultValue:"取消"})}),e.jsx("button",{className:`flex-1 ${Ee}`,onClick:Te,disabled:ie,children:ie?t("backup.creating",{defaultValue:"备份中..."}):t("backup.create",{defaultValue:"备份"})})]})]})}),m&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>y(!1),children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-2xl shadow-2xl flex flex-col max-h-[80vh]",onClick:w=>w.stopPropagation(),children:[e.jsxs("h3",{className:"text-base font-semibold text-foreground mb-3 flex-shrink-0",children:[t("backup.manageTitle",{defaultValue:"备份管理"}),e.jsxs("span",{className:"text-muted font-normal",children:[" — ",c]})]}),e.jsx("div",{className:"bg-[var(--input-bg)] border border-[var(--border)] rounded-lg px-4 py-3 mb-3 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted",children:t("backup.autoBackup",{defaultValue:"自动备份"})}),fe.enabled&&e.jsxs("span",{className:"text-muted opacity-70",children:[t("backup.interval",{defaultValue:"每{{h}}小时备份",h:fe.interval_hours||24})," | ",t("backup.keep",{defaultValue:"保留{{n}}份",n:fe.keep_count||3})]}),fe.enabled&&fe.last_backup_ok===!1&&e.jsxs("span",{className:"text-red-400 text-xs",children:["(",t("backup.failed",{defaultValue:"失败"}),")"]})]}),e.jsx("button",{disabled:he,onClick:async w=>{w.stopPropagation(),ye(!0);try{fe.enabled?await zt(r,{enabled:!1}):(await zt(r,{enabled:!0,interval_hours:24,keep_count:3}),n(t("backup.autoEnabled",{defaultValue:"自动备份已开启"}),"success")),await be()}catch(L){n(L.message||"Failed","error")}finally{ye(!1)}},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 ${he?"opacity-40":""} ${fe.enabled?"bg-green-500":"bg-[var(--border)]"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform duration-200 ${fe.enabled?"translate-x-4":"translate-x-0.5"}`})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:pe.length===0?e.jsx("p",{className:"text-sm text-muted py-6 text-center",children:t("backup.noBackups",{defaultValue:"暂无备份"})}):e.jsx("div",{className:"space-y-2",children:pe.map(w=>e.jsxs("div",{className:"flex items-center justify-between bg-[var(--card)] border border-[var(--border)] rounded-lg px-4 py-3 hover:border-[var(--border-hover)] transition-colors duration-150",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-[var(--input-bg)] border border-[var(--border)] text-muted font-medium flex-shrink-0",children:He(w.type)}),e.jsx("span",{className:"text-sm text-foreground truncate",children:Ie(w.created_at)}),e.jsx("span",{className:"text-xs text-muted flex-shrink-0",children:Pe(w.size)})]})}),e.jsxs("div",{className:"flex items-center gap-1 ml-3 flex-shrink-0",children:[e.jsx("button",{title:t("backup.restore",{defaultValue:"恢复"}),className:"p-2 rounded-md hover:bg-[var(--card-hover)] text-muted hover:text-foreground transition-colors duration-150 text-base",onClick:()=>{ne(""),F(w.filename)},children:"↩"}),e.jsx("button",{title:t("backup.createNew",{defaultValue:"创建新实例"}),className:"p-2 rounded-md hover:bg-[var(--card-hover)] text-muted hover:text-foreground transition-colors duration-150 text-base",onClick:()=>{d(""),E(""),V(w.filename)},children:"⊕"}),w.type!=="pre-restore"&&e.jsx("a",{href:Ds(r,w.filename),download:!0,title:t("backup.download",{defaultValue:"下载"}),className:"p-2 rounded-md hover:bg-[var(--card-hover)] text-muted hover:text-foreground transition-colors duration-150 text-base underline decoration-current underline-offset-2",children:"⬇"}),e.jsx("button",{title:t("backup.delete",{defaultValue:"删除"}),className:"p-2 rounded-md hover:bg-red-500/10 text-muted hover:text-red-400 transition-colors duration-150 text-base",onClick:()=>Se(w.filename),children:"🗑"})]})]},w.filename))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 mt-4 border-t border-[var(--border)] flex-shrink-0",children:[e.jsx("button",{className:Ne,onClick:()=>y(!1),children:t("common:action.close",{defaultValue:"关闭"})}),e.jsx("button",{className:Ee,onClick:()=>{y(!1),i(!0)},children:t("backup.createNew2",{defaultValue:"创建新备份"})})]})]})}),g&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{F(null),ne("")},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",onClick:w=>w.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-amber-400 mb-2",children:t("backup.restoreTitle",{defaultValue:"恢复将覆盖当前数据"})}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("backup.restoreDesc",{defaultValue:"已自动创建恢复前备份,如有问题可回滚。"})}),e.jsx("p",{className:"text-sm text-muted mb-2",children:t("backup.restoreConfirmLabel",{defaultValue:"输入实例名确认恢复:"})}),e.jsx("input",{type:"text",value:ge,onChange:w=>ne(w.target.value),placeholder:c,className:`${Ve} mb-4 focus:ring-amber-500/60 focus:border-amber-500/60`,autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:`flex-1 ${Ne}`,onClick:()=>{F(null),ne("")},children:t("common:action.cancel",{defaultValue:"取消"})}),e.jsx("button",{className:"flex-1 px-4 py-2 bg-red-600 text-white rounded-md text-sm font-medium hover:bg-red-700 disabled:opacity-40 transition-colors duration-150",onClick:()=>Oe(g),disabled:ie||ge!==c,children:ie?t("backup.restoring",{defaultValue:"恢复中..."}):t("backup.confirmRestore",{defaultValue:"确认恢复"})})]})]})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{V(null),d(""),E("")},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",onClick:w=>w.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-4",children:t("backup.createFromTitle",{defaultValue:"从备份创建新实例"})}),e.jsxs("div",{className:"space-y-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("backup.newName",{defaultValue:"新实例名称"})}),e.jsx("input",{type:"text",value:b,onChange:w=>E(w.target.value),placeholder:t("backup.newNamePlaceholder",{defaultValue:"我的 Agent 副本"}),className:Ve,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("backup.newId",{defaultValue:"新实例 ID"})}),e.jsx("input",{type:"text",value:ue,onChange:w=>d(w.target.value),placeholder:t("backup.newIdPlaceholder",{defaultValue:"my-agent-copy"}),className:`${Ve} font-mono text-[13px]`})]})]}),e.jsx("p",{className:"text-xs text-muted opacity-70 mb-4",children:t("backup.createFromNote",{defaultValue:"API Key 和 IM 凭证不会复制,需自行配置。"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:`flex-1 ${Ne}`,onClick:()=>{V(null),d(""),E("")},children:t("common:action.cancel",{defaultValue:"取消"})}),e.jsx("button",{className:`flex-1 ${Ee}`,onClick:()=>U(j),disabled:ie||!ue||!b,children:ie?t("backup.creatingInstance",{defaultValue:"创建中..."}):t("backup.createInstance",{defaultValue:"创建"})})]})]})}),R&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50",onClick:()=>S(!1),children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 max-w-md w-full mx-4 space-y-4 shadow-2xl",onClick:w=>w.stopPropagation(),children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t("backup.exportTitle",{defaultValue:"导出(分享)"})}),e.jsx("p",{className:"text-sm text-muted",children:t("backup.exportDesc",{defaultValue:"生成可分享的导出包,API Key 和凭证将自动移除。"})}),e.jsxs("div",{className:"bg-[var(--input-bg)] border border-[var(--border)] rounded-lg p-3 space-y-1.5 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),t("backup.exportConfig",{defaultValue:"配置 (openclaw.json, 已清洗)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),t("backup.exportPlugins",{defaultValue:"插件 (extensions)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),t("backup.exportWorkspace",{defaultValue:"工作区 / Skills"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-red-400",children:"✗"}),t("backup.exportNoKeys",{defaultValue:"API Key / 凭证 — 已移除"})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:w=>M(w.target.checked),className:"rounded border-[var(--border)] bg-[var(--input-bg)]"}),t("backup.exportIncludeSessions",{defaultValue:"包含对话历史"})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{className:Ne,onClick:()=>S(!1),children:t("common:action.cancel",{defaultValue:"取消"})}),e.jsx("button",{className:Ee,onClick:at,disabled:ie,children:ie?t("backup.exporting",{defaultValue:"导出中..."}):t("backup.exportBtn",{defaultValue:"导出"})})]})]})}),I&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 max-w-md w-full mx-4 space-y-4 shadow-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-green-400",children:t("backup.exportDone",{defaultValue:"导出完成"})}),e.jsxs("p",{className:"text-sm text-muted",children:[I.filename," (",Pe(I.size),")"]}),I.warnings&&I.warnings.length>0&&e.jsx("div",{className:"space-y-1",children:I.warnings.map((w,L)=>e.jsx("p",{className:"text-xs text-amber-400",children:w},L))}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("a",{href:Ts(r,I.filename),download:!0,className:Ee+" inline-block text-center no-underline",children:t("backup.downloadExport",{defaultValue:"下载"})}),e.jsx("button",{className:Ne,onClick:()=>B(null),children:t("common:action.close",{defaultValue:"关闭"})})]})]})}),z&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",children:[e.jsx("h3",{className:`text-base font-semibold mb-2 ${z.type==="success"?"text-green-400":"text-red-400"}`,children:z.title}),z.detail&&e.jsx("p",{className:"text-sm text-muted mb-4 whitespace-pre-wrap",children:z.detail}),e.jsxs("div",{className:"flex justify-end gap-2",children:[(Ce=z.actions)==null?void 0:Ce.map((w,L)=>e.jsx("button",{className:Ee,onClick:w.onClick,children:w.label},L)),e.jsx("button",{className:Ne,onClick:()=>te(null),children:t("common:action.close",{defaultValue:"关闭"})})]})]})})]})}function Kr(r,c){if(r==null)return"-";const n=Math.floor(r/86400),h=Math.floor(r%86400/3600),s=Math.floor(r%3600/60);return n>0?c("instance:uptime.days",{d:n,h}):h>0?c("instance:uptime.hours",{h,m:s}):c("instance:uptime.minutes",{m:s})}const tt=[Fr,et,Dr,Or];function Hr(r){for(const c of tt){const n=s=>(s==null?void 0:s.find(u=>u.id===r))??null;if(c.groups)for(const s of c.groups){const u=n(s.items);if(u)return u}const h=n(c.items);if(h)return h}return null}function Zt(r,c){const n=JSON.parse(JSON.stringify(r??{})),h=Qe.find(x=>x.id===c);if(h){if(n.channels||(n.channels={}),n.plugins||(n.plugins={}),n.plugins.entries||(n.plugins.entries={}),n.channels[c])n.channels[c].enabled=!0;else{const x={enabled:!0,...h.defaults??{}};h.fields.forEach(N=>{N.key in x||(x[N.key]="")}),n.channels[c]=x}return n.plugins.entries[c]||(n.plugins.entries[c]={enabled:!0}),n}const s={"skill-vetter":{"skill-vetter":{enabled:!0}},"skill-finder":{"skill-finder":{enabled:!0}},"skill-browser":{"skill-browser":{enabled:!0}}};if(c in s)return n.skills||(n.skills={}),Object.assign(n.skills,s[c]),n;const u={};return c in u&&(n.mcp||(n.mcp={}),n.mcp.servers||(n.mcp.servers={}),Object.assign(n.mcp.servers,u[c])),n}function Wr(r){var h,s,u;const c=(s=(h=r==null?void 0:r.runtime)==null?void 0:h.env)==null?void 0:s.OPENCLAW_GATEWAY_PORT;if(c)return String(c);const n=((u=r==null?void 0:r.runtime)==null?void 0:u.args)||[];for(let x=0;x<n.length;x++){if(n[x]==="--port"&&x+1<n.length)return String(n[x+1]);if(typeof n[x]=="string"&&n[x].startsWith("--port="))return String(n[x].slice(7))}return"-"}function ta(){var Rt,Lt,Dt,Tt,Vt,_t,$t;const{id:r,tab:c}=ar(),n=ns(),{showToast:h}=zs(),{t:s}=Ae(["instance","common","data"]),[u,x]=p.useState(null),[N,t]=p.useState(c==="overview"?"chat":c||"chat"),[a,l]=p.useState(null),[i,m]=p.useState(!1),[y,g]=p.useState(""),[F,j]=p.useState(!1),[V,R]=p.useState(""),[S,$]=p.useState([]),[M,I]=p.useState("stderr"),[B,z]=p.useState(""),[te,pe]=p.useState(null),[Q,ie]=p.useState(""),[W,ae]=p.useState(!1),[Z,ce]=p.useState(!1),[X,ge]=p.useState(""),[ne,ue]=p.useState(!1),[d,b]=p.useState(!1),[E,_]=p.useState(""),[q,me]=p.useState(!1),[T,G]=p.useState(!1),[se,fe]=p.useState(null),[ke,he]=p.useState(!1),[ye,be]=p.useState("im"),[Te,Oe]=p.useState("general"),[U,Se]=p.useState(null),[at,Pe]=p.useState({}),[Ie,He]=p.useState(""),[Ve,Ee]=p.useState(""),[Ne,Re]=p.useState(""),[Ce,w]=p.useState({servers:[],installed:!1,loading:!1}),[L,J]=p.useState(null),H=p.useRef(!1),le=p.useRef(!1),[re,xe]=p.useState(!1),[ve,vt]=p.useState(null),[jt,wt]=p.useState(!1),lt=p.useRef(null),nt=p.useRef(null),[kt,yt]=p.useState(!1),Nt=p.useRef(r),ot=p.useRef(re);Nt.current=r,ot.current=re,p.useEffect(()=>{qs().then(o=>{o.hasUpdate&&vt({currentVersion:o.currentVersion,latestVersion:o.latestVersion})}).catch(()=>{})},[]);const vs=async()=>{if(window.confirm(s("update.confirm",{currentVersion:ve==null?void 0:ve.currentVersion,latestVersion:ve==null?void 0:ve.latestVersion}))){wt(!0);try{await Ys(),h(s("update.started"),"success"),vt(null)}catch(o){h(o.message||s("update.failed"),"error")}finally{wt(!1)}}};p.useEffect(()=>{ke&&r&&We(r).then(Se).catch(()=>{})},[ke,r]),p.useEffect(()=>{ke&&ye==="mcp"&&r&&(w(o=>({...o,loading:!0})),ft(r).then(o=>w({servers:o.servers,installed:o.installed,loading:!1})).catch(()=>w(o=>({...o,loading:!1}))))},[ke,ye,r]),p.useEffect(()=>{c&&t(c==="overview"?"chat":c)},[c]),p.useEffect(()=>{kt&&N==="config"&&a&&(yt(!1),j(!1),setTimeout(()=>{const o=document.getElementById("im-channel-section");o?o.scrollIntoView({behavior:"smooth",block:"start"}):window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"})},200))},[kt,N,a]);const Be=p.useCallback(()=>{const o=Nt.current;o&&!ot.current&&Ks(o).then(x).catch(()=>{})},[h]);p.useEffect(()=>{Be(),r&&(ce(!1),Hs(r).then(f=>{const v=typeof(f==null?void 0:f.url)=="string"?f.url.trim():"";if(!v)throw new Error("No gateway launch URL returned");ie(v)}).catch(f=>{ie(""),h((f==null?void 0:f.message)||s("gatewayLaunchFailed"),"error")}));const o=setInterval(Be,5e3);return()=>clearInterval(o)},[r,Be]);const Ct=((Rt=u==null?void 0:u.service)==null?void 0:Rt.status)==="running",Ft=p.useRef(!1);Ft.current=W,p.useEffect(()=>{if(!Q||!Ct){ae(!1),ce(!1);return}if(Ft.current)return;let o=!1,f=0;const v=60,k=()=>{o||f>=v||(f++,fetch(Q,{method:"HEAD",credentials:"include"}).then(C=>{!o&&C.ok&&ae(!0)}).catch(()=>{}))};k();const D=setInterval(k,3e3);return()=>{o=!0,clearInterval(D)}},[Q,Ct]);const[je,it]=p.useState({}),St=Object.values(je).includes("installing"),Ge=p.useRef(new Set),ct=p.useRef(h);ct.current=h;const dt=p.useRef(s);dt.current=s,p.useEffect(()=>{if(!r||!(N==="config"||St))return;let f=!1;const v=()=>{f||qt(r).then(D=>{var A;if(f)return;const C={};for(const[P,K]of Object.entries(D.plugins))C[P]=K.status;for(const P of Ge.current){const K=C[P];if(K==="installed")ct.current(dt.current(P==="feishu"?"feishu.pluginInstalled":"weixin.pluginInstalled"),"success"),Ge.current.delete(P);else if(K==="failed"||K==="not_installed"){const de=(A=D.plugins[P])==null?void 0:A.error;ct.current(dt.current(P==="feishu"?"feishu.pluginFailed":"weixin.pluginFailed")+(de?": "+de:""),"error"),Ge.current.delete(P)}}it(C)}).catch(()=>{})};v();const k=setInterval(v,3e3);return()=>{f=!0,clearInterval(k)}},[r,N,St]),p.useEffect(()=>{ke&&r&&qt(r).then(o=>{const f={};for(const[v,k]of Object.entries(o.plugins))f[v]=k.status;it(f)}).catch(()=>{})},[ke,r]);const Et=o=>{r&&(Xs(r,o).catch(()=>{}),it(f=>({...f,[o]:"installing"})),Ge.current.add(o),h(s(o==="feishu"?"feishu.installing":"weixin.installing"),"info"))};p.useEffect(()=>{if(!i)return;const o=f=>{f.preventDefault()};return window.addEventListener("beforeunload",o),()=>window.removeEventListener("beforeunload",o)},[i]),p.useEffect(()=>{N==="config"&&r&&Kt(r).then(o=>{const f=nt.current;nt.current=null;const v=f?Zt(o,f):o;l(v),R(JSON.stringify(v,null,2)),m(!!f)}).catch(()=>{}),N==="usage"&&r&&Ht(r).then(pe).catch(()=>{})},[N,r]);const ut=()=>{r&&Zs(r,200,M).then(o=>{var v;$(o.lines);const f=(v=lt.current)==null?void 0:v.parentElement;f&&f.scrollHeight-f.scrollTop-f.clientHeight<80&&setTimeout(()=>{var D;return(D=lt.current)==null?void 0:D.scrollIntoView({behavior:"smooth"})},100)}).catch(()=>{})};lr(ut,3e3,N==="logs"&&!!r),p.useEffect(()=>{N==="logs"&&ut()},[M]);const Ye=async o=>{if(r){ge(o);try{o==="start"&&await er(r),o==="stop"&&await tr(r),o==="restart"&&await Qt(r),h(s(o==="start"?"action.startHint":o==="stop"?"action.stopDone":"action.restartHint"),o==="stop"?"success":"info"),(o==="start"||o==="restart")&&n(`/instances/${r}`),setTimeout(Be,1e3)}catch(f){h(f.message||s("common:error.operationFailed"),"error")}finally{ge("")}}},Mt=async o=>{if(!r)return;he(!1),H.current=!1;const f=o==="feishu"?"feishu":"openclaw-weixin",v=je[f];if(v==="installing"){h(s(o==="feishu"?"feishu.waitingInstall":"weixin.waitingInstall"),"info");return}if(v!=="installed"){Et(f);return}le.current=!1,J({type:o,qrUrl:"",sessionKey:"",status:"loading",message:s("qr.gettingQr")});try{let k=null;for(let C=0;C<3;C++){if(le.current)return;try{if(k=o==="feishu"?await ts(r):await ss(r),k!=null&&k.qrcodeUrl)break}catch{C<2&&await new Promise(A=>setTimeout(A,1500))}}if(le.current)return;if(!(k!=null&&k.qrcodeUrl)){J(C=>C?{...C,status:"error",message:s("qr.getFailed")}:null);return}J({type:o,qrUrl:k.qrcodeUrl,sessionKey:k.sessionKey,status:"waiting",message:s(o==="feishu"?"qr.scanFeishu":"qr.scanWeixin")}),H.current=!0;const D=async C=>{if(!(!H.current||le.current))try{const A=o==="feishu"?await rs(r,C):await as(r,C);if(le.current)return;if(A.connected){H.current=!1,J(P=>P?{...P,qrUrl:"",status:"confirmed",message:A.message||s("qr.loginSuccess")}:null);return}if(A.status==="expired"){H.current=!1,J(P=>P?{...P,status:"error",message:A.message||s("qr.expired")}:null);return}A.status==="refreshed"&&A.qrcodeUrl?J(P=>P?{...P,qrUrl:A.qrcodeUrl,message:s("qr.refreshed")}:null):A.status==="scaned"&&J(P=>P?{...P,status:"scaned",message:A.message||s("qr.scaned")}:null),setTimeout(()=>D(C),2e3)}catch{H.current&&!le.current&&setTimeout(()=>D(C),3e3)}};setTimeout(()=>D(k.sessionKey),2e3)}catch{le.current||J(k=>k?{...k,status:"error",message:s("qr.getFailed")}:null)}},_e=(o,f)=>{let v=0;const k=()=>{var D;try{const C=document.getElementById("gateway-iframe");if(!C){++v<50&&setTimeout(k,200);return}const A=C.contentDocument;if(!A||A.readyState==="loading"){++v<50&&setTimeout(k,200);return}const P=A.querySelector("openclaw-app");if(!P){++v<50&&setTimeout(k,200);return}if(f){if(!P.connected&&++v<50){setTimeout(k,200);return}P.handleSendChat(o)}else P.chatMessage=o}catch{const C=document.getElementById("gateway-iframe");(D=C==null?void 0:C.contentWindow)==null||D.postMessage({type:"jishu:inject-cmd",cmd:o,send:f},"*")}};N!=="chat"?(Le("chat"),setTimeout(k,800)):setTimeout(k,100)},Xe=o=>{if(he(!1),o==="feishu"||o==="openclaw-weixin"){Mt(o==="feishu"?"feishu":"weixin");return}const f=Hr(o);if(f&&f.cmd!==void 0){_e(f.cmd,f.send!==!1);return}if(a!==null&&N==="config"){const v=Zt(a,o);l(v),R(JSON.stringify(v,null,2)),m(!0),h(s("config.presetAdded"),"info")}else nt.current=o,Le("config"),h(s("config.navigatingToConfig"),"info")},js=o=>{l(o),R(JSON.stringify(o,null,2)),m(!0)},ws=o=>{R(o),m(!0);try{l(JSON.parse(o)),g("")}catch{g(s("config.jsonError"))}},ks=o=>{var D,C,A;if(!o)return"{}";const f=JSON.parse(JSON.stringify(o)),v=(D=f==null?void 0:f.models)==null?void 0:D.providers;if(v&&typeof v=="object")for(const[P,K]of Object.entries(v))P.startsWith("js-")&&(K!=null&&K.apiKey)&&(K.apiKey="(proxy token, auto-managed)");const k=(A=(C=f==null?void 0:f["x-jishushell"])==null?void 0:C.proxy)==null?void 0:A.upstream;return k&&k.apiKey===""&&k.hasApiKey&&(k.apiKey="(saved, leave empty to keep, enter new value to update)"),JSON.stringify(f,null,2)},At=o=>{var D,C,A;const f=JSON.parse(o),v=(C=(D=f==null?void 0:f["x-jishushell"])==null?void 0:D.proxy)==null?void 0:C.upstream;(v==null?void 0:v.apiKey)==="(saved, leave empty to keep, enter new value to update)"&&delete v.apiKey;const k=(A=f==null?void 0:f.models)==null?void 0:A.providers;if(k&&typeof k=="object")for(const[P,K]of Object.entries(k))P.startsWith("js-")&&(K==null?void 0:K.apiKey)==="(proxy token, auto-managed)"&&delete K.apiKey;return f},Pt=async o=>{if(!(!r||!a)){g(""),ue(!0);try{const f=At(F?V:JSON.stringify(a)),v=await sr(r,f);if(v!=null&&v.config&&(l(v.config),R(JSON.stringify(v.config,null,2))),m(!1),o)try{await Qt(r),h(s("config.savedAndRestarted"),"success"),t("chat"),n(`/instances/${r}`,{replace:!0})}catch(k){h(s("config.savedButRestartFailed",{error:k.message||""}),"error"),g(s("config.restartFailed",{error:k.message||""}))}else h(s("config.saved"),"success");setTimeout(Be,1e3)}catch(f){g(f instanceof SyntaxError?s("config.jsonParseError",{error:f.message}):f.message||s("common:error.saveFailed"))}finally{ue(!1)}}},ys=async()=>{var o;if(!(!r||E.trim()!==((o=u==null?void 0:u.name)==null?void 0:o.trim())||re)){ot.current=!0,xe(!0);try{await rr(r,q),n("/",{replace:!0})}catch(f){h(f.message||s("common:error.deleteFailed"),"error"),xe(!1)}}},Le=o=>{if(i&&N==="config"&&o!=="config"){if(!window.confirm(s("config.unsavedWarning")))return;m(!1)}t(o),n(`/instances/${r}/${o}`,{replace:!0})};if(!u)return e.jsx("div",{className:"p-6 max-w-5xl mx-auto",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-6 w-48 bg-[var(--card)] rounded"}),e.jsx("div",{className:"h-10 w-full bg-[var(--card)] rounded"}),e.jsx("div",{className:"h-40 bg-[var(--card)] rounded-lg"})]})});const Ue=((Lt=u.service)==null?void 0:Lt.status)||"stopped",ze=Ue==="running",qe=Ue==="pending",mt=Ue==="failed"||Ue==="dead",It=ze,Ns=s(ze?"common:status.running":qe?"common:status.starting":Ue==="failed"?"common:status.failed":Ue==="dead"?"common:status.crashed":"common:status.stopped"),Cs=ze?"text-emerald-400":qe?"text-amber-400":mt?"text-red-400":"text-muted",Fs=ze?"bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.6)]":qe?"bg-amber-400 animate-pulse shadow-[0_0_6px_rgba(251,191,36,0.5)]":mt?"bg-red-500 shadow-[0_0_6px_rgba(239,68,68,0.6)]":"bg-[var(--muted)] opacity-40";return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto",children:[ve&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 bg-amber-500/10 border border-amber-500/30 rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 2v6m0 0 2-2m-2 2-2-2M4.93 10.93A10 10 0 1 0 21 12"})}),e.jsxs("span",{className:"text-amber-300",children:[s("update.found"),e.jsx("span",{className:"font-mono text-amber-200 ml-1",children:ve.currentVersion}),e.jsx("span",{className:"mx-1 text-amber-500",children:"→"}),e.jsx("span",{className:"font-mono text-amber-200",children:ve.latestVersion})]})]}),e.jsx("button",{onClick:vs,disabled:jt,className:"shrink-0 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-xs font-semibold px-3 py-1 rounded-md transition-colors",children:s(jt?"update.upgrading":"update.upgradeNow")})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:u.name}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${Fs}`}),e.jsx("span",{className:`text-xs font-medium ${Cs}`,children:Ns}),ze&&!W&&e.jsx("span",{className:"text-[11px] text-amber-400/90",children:s("status.gatewayPending")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N==="chat"&&e.jsxs(e.Fragment,{children:[e.jsx("a",{href:Q||void 0,target:"_blank",rel:"noopener noreferrer","aria-disabled":!Q,title:s("openInWindow"),className:`p-1.5 border border-[var(--border)] rounded-md transition-all duration-150 ${Q?"text-muted hover:text-foreground hover:bg-[var(--card-hover)] cursor-pointer":"pointer-events-none text-muted opacity-30"}`,children:e.jsx(Ws,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{ae(!1),ce(!1)},disabled:!Q,title:s("reload"),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-all duration-150",children:e.jsx(ls,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>Le("config"),title:s("tab.config"),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-all duration-150 relative",children:[e.jsx(Js,{className:"w-4 h-4"}),i&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-amber-400"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>he(o=>!o),title:s("quickSkill"),className:"flex items-center gap-1 px-2.5 py-1.5 border border-[#0066FF]/30 rounded-md text-xs font-medium text-[#0066FF] bg-[#0066FF]/5 hover:bg-[#0066FF]/10 transition-all duration-150",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),e.jsx("span",{className:"hidden sm:inline",children:s("quickSkill")}),e.jsx(es,{className:`w-3 h-3 transition-transform duration-150 ${ke?"rotate-180":""}`})]}),ke&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>he(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-80 bg-background border border-[var(--border)] rounded-lg shadow-2xl z-20 overflow-hidden",children:[e.jsx("div",{className:"flex border-b border-[var(--border)]",children:["im","skills","mcp","slash"].map(o=>{const f={im:{emoji:"💬",label:s("quickSkill.im")},skills:{emoji:"⚡",label:s("quickSkill.skills")},mcp:{emoji:"🔌",label:s("quickSkill.mcp")},slash:{emoji:"/",label:s("quickSkill.slash")}}[o];return e.jsxs("button",{onClick:v=>{v.stopPropagation(),be(o)},className:`flex-1 py-2 flex flex-col items-center gap-0.5 text-[10px] font-medium transition-colors border-b-2 ${ye===o?"text-[#0066FF] border-[#0066FF] bg-[#0066FF]/5":"text-muted border-transparent hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-sm leading-none",children:f.emoji}),e.jsx("span",{children:f.label})]},o)})}),e.jsxs("div",{className:"max-h-[480px] overflow-y-auto",children:[ye==="im"&&e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>Xe("feishu"),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-[#3370FF]/30 bg-[#3370FF]/5 hover:bg-[#3370FF]/10 transition-all duration-150",children:[e.jsx("img",{src:"https://s1.aigei.com/src/img/png/5a/5ad236651e0c4a6b940d2e1d2bf29749.png?imageMogr2/auto-orient/thumbnail/!282x282r/gravity/Center/crop/282x282/quality/85/%7CimageView2/2/w/282&e=2051020800&token=P7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL:bcW1ujPdX64WlxeEm9SpuJ5H2KY=",alt:s("channel.feishu"),className:"w-8 h-8 rounded-md flex-shrink-0",onError:o=>{o.target.style.display="none"}}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-[#3370FF]",children:s("channel.feishu")}),e.jsx("div",{className:"text-[11px] text-muted mt-0.5",children:je.feishu==="installing"?s("quickSkill.pluginInstalling"):je.feishu!=="installed"?s("quickSkill.clickToInstall"):U!=null&&U.im.feishu?`✓ ${s("quickSkill.bound")}`:s("quickSkill.scanToBind")})]}),je.feishu==="installing"&&e.jsx("div",{className:"w-4 h-4 border-2 border-[#3370FF]/30 border-t-[#3370FF] rounded-full animate-spin flex-shrink-0"}),je.feishu==="installed"&&(U==null?void 0:U.im.feishu)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 font-medium flex-shrink-0",children:s("quickSkill.bound")})]}),e.jsxs("button",{onClick:()=>Xe("openclaw-weixin"),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-[#07C160]/30 bg-[#07C160]/5 hover:bg-[#07C160]/10 transition-all duration-150",children:[e.jsx("img",{src:"https://sgnewres.wechat.com/t/ofs-wechat/newsroom-web/res/_next/static/media/wechat-with-color.7a890de8.svg",alt:s("channel.weixin"),className:"w-8 h-8 rounded-md flex-shrink-0",onError:o=>{o.target.style.display="none"}}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-[#07C160]",children:s("channel.weixin")}),e.jsx("div",{className:"text-[11px] text-muted mt-0.5",children:je["openclaw-weixin"]==="installing"?s("quickSkill.pluginInstalling"):je["openclaw-weixin"]!=="installed"?s("quickSkill.clickToInstall"):U!=null&&U.im.weixin?`✓ ${s("quickSkill.bound")}`:s("quickSkill.scanToBind")})]}),je["openclaw-weixin"]==="installing"&&e.jsx("div",{className:"w-4 h-4 border-2 border-[#07C160]/30 border-t-[#07C160] rounded-full animate-spin flex-shrink-0"}),je["openclaw-weixin"]==="installed"&&(U==null?void 0:U.im.weixin)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 font-medium flex-shrink-0",children:s("quickSkill.bound")})]}),e.jsxs("button",{onClick:()=>{he(!1),Le("config"),yt(!0)},className:"w-full flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-[11px] text-muted hover:text-foreground hover:bg-[var(--card-hover)] border border-dashed border-[var(--border)] transition-all duration-150",children:[e.jsx("span",{children:s("quickSkill.moreImConfig")}),e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})]}),ye==="skills"&&e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-[var(--border)]/60 flex gap-1.5 flex-shrink-0",children:[e.jsx("input",{type:"text",value:Ie,onChange:o=>He(o.target.value),onKeyDown:o=>{o.key==="Enter"&&Ie.trim()&&(he(!1),_e(`安装 ${Ie.trim()}`,!0),He(""))},placeholder:s("quickSkill.customSkillPlaceholder"),className:"flex-1 min-w-0 text-[11px] bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1 text-foreground placeholder:text-muted outline-none focus:border-[#0066FF]/60"}),e.jsx("button",{disabled:!Ie.trim(),onClick:()=>{Ie.trim()&&(he(!1),_e(`安装 ${Ie.trim()}`,!0),He(""))},className:"flex-shrink-0 text-[11px] px-2 py-1 rounded bg-[#0066FF]/10 text-[#0066FF] hover:bg-[#0066FF]/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:s("quickSkill.install")})]}),e.jsxs("div",{className:"flex",style:{height:"380px"},children:[e.jsxs("div",{className:"flex flex-col border-r border-[var(--border)]/60 bg-[var(--card)] flex-shrink-0",style:{width:"72px"},children:[et.groups.map(o=>e.jsxs("button",{onMouseEnter:f=>{f.stopPropagation(),Oe(o.id)},onClick:f=>{f.stopPropagation(),Oe(o.id)},className:`flex flex-col items-center justify-center gap-0.5 py-3 px-1 text-center transition-colors border-l-2 flex-shrink-0 ${Te===o.id?"border-[#0066FF] bg-[#0066FF]/5 text-foreground":"border-transparent text-muted hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-base leading-none",children:o.emoji}),e.jsx("span",{className:"text-[9px] font-medium leading-tight mt-0.5 whitespace-pre-wrap break-all",children:s(`data:skills.group.${o.id}`,{defaultValue:o.label})})]},o.id)),e.jsxs("button",{onMouseEnter:o=>{o.stopPropagation(),Oe("installed")},onClick:o=>{o.stopPropagation(),Oe("installed")},className:`flex flex-col items-center justify-center gap-0.5 py-3 px-1 text-center transition-colors border-l-2 flex-shrink-0 ${Te==="installed"?"border-[#0066FF] bg-[#0066FF]/5 text-foreground":"border-transparent text-muted hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-base leading-none",children:"📦"}),e.jsx("span",{className:"text-[9px] font-medium leading-tight mt-0.5 whitespace-pre-wrap break-all",children:s("quickSkill.allInstalled")})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",children:[Te==="installed"&&(()=>{if(U===null)return e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:s("quickSkill.loading")});const o=U.installedSkillDirs??[],f={};return et.groups.forEach(v=>{v.skills.forEach(k=>{var D;(D=k.checkDirs)==null||D.forEach(C=>{f[C.toLowerCase()]=v.label})})}),o.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:s("quickSkill.noInstalled")}):e.jsx(e.Fragment,{children:o.map(v=>{const k=f[v.toLowerCase()];return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2 border-b border-[var(--border)]/30",children:[e.jsxs("button",{className:"flex-1 min-w-0 text-left",onClick:()=>{he(!1),_e(`/skill ${v} `,!1)},children:[e.jsx("div",{className:"text-xs font-semibold text-foreground font-mono truncate",children:v}),k&&e.jsx("div",{className:"text-[10px] text-muted mt-0.5",children:k})]}),e.jsx("span",{className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-emerald-500/15 text-emerald-400",children:s("quickSkill.installed")}),e.jsx("button",{onClick:async()=>{if(!(!r||!window.confirm(s("delete.skillConfirm",{name:v}))))try{await Wt(r,v);const D=await We(r);Se(D)}catch(D){h(D.message||s("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:s("common:action.delete")})]},v)})})})(),Te!=="installed"&&(()=>{const o=et.groups.find(k=>k.id===Te),f=(o==null?void 0:o.skills)??[];if(f.length===0)return e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:s("quickSkill.noSkills")});const v=((U==null?void 0:U.installedSkillDirs)??[]).map(k=>k.toLowerCase());return e.jsx(e.Fragment,{children:f.map(k=>{var P;if(k.type==="hub")return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2 border-b border-[var(--border)]/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground break-words",children:s(`data:skills.${k.id}.label`,{defaultValue:k.label})}),e.jsx("div",{className:"text-[10px] text-muted leading-tight mt-0.5 break-words",children:s(`data:skills.${k.id}.desc`,{defaultValue:k.desc})}),e.jsx("div",{className:"text-[9px] text-muted/60 leading-tight mt-0.5 break-all",children:k.url})]}),e.jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",onClick:K=>K.stopPropagation(),title:"在新标签页打开",className:"flex-shrink-0 text-[11px] px-1.5 py-0.5 rounded-full font-medium bg-[var(--border)] text-muted hover:bg-[#0066FF]/15 hover:text-[#0066FF] transition-colors no-underline",children:"🔗"})]},k.id);const D=U!==null&&k.checkDirs.some(K=>v.includes(K.toLowerCase())),C=at[k.id]??!1,A=((P=U==null?void 0:U.installedSkillDirs)==null?void 0:P.find(K=>k.checkDirs.some(de=>de.toLowerCase()===K.toLowerCase())))??k.id;return e.jsxs("button",{disabled:C,onClick:()=>{if(he(!1),D)_e(`/skill ${A} `,!1);else{Pe(Fe=>({...Fe,[k.id]:!0})),_e(k.installMsg,k.autoInstall!==!1);let K=0;const de=setInterval(async()=>{K+=5e3;try{const Fe=await We(r);Se(Fe);const ht=((Fe==null?void 0:Fe.installedSkillDirs)??[]).map(De=>De.toLowerCase());k.checkDirs.some(De=>ht.includes(De.toLowerCase()))&&(clearInterval(de),Pe(De=>({...De,[k.id]:!1})))}catch{}K>=6e4&&(clearInterval(de),Pe(Fe=>({...Fe,[k.id]:!1})))},5e3)}},className:"w-full text-left px-3 py-2 hover:bg-[var(--card-hover)] transition-colors flex items-center gap-2 disabled:opacity-60 border-b border-[var(--border)]/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground break-words",children:s(`data:skills.${k.id}.label`,{defaultValue:k.label})}),e.jsx("div",{className:"text-[10px] text-muted leading-tight mt-0.5 break-words",children:s(`data:skills.${k.id}.desc`,{defaultValue:k.desc})})]}),e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${C?"bg-amber-500/15 text-amber-400":U===null?"bg-[var(--border)] text-muted":D?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:C?s("quickSkill.installing"):U===null?"…":s(D?"quickSkill.installed":"quickSkill.install")}),D&&!C&&e.jsx("button",{onClick:async K=>{if(K.stopPropagation(),!(!r||!window.confirm(s("delete.skillConfirm",{name:A}))))try{await Wt(r,A);const de=await We(r);Se(de)}catch(de){h(de.message||s("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:s("common:action.delete")})]},k.id)})})})()]})]})]}),ye==="mcp"&&e.jsxs("div",{className:"py-1",children:[(()=>{const o=!!(U!=null&&U.mcporterInstalled||Ce.installed),f=U===null&&Ce.loading;return e.jsxs("button",{onClick:()=>{o||(he(!1),_e("安装 https://clawhub.ai/steipete/mcporter",!0))},className:"w-full text-left px-3 py-2.5 hover:bg-[var(--card-hover)] transition-colors flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:"MCPorter"}),e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5",children:s("quickSkill.mcporterDesc")})]}),e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${f?"bg-[var(--border)] text-muted":o?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:f?"…":s(o?"quickSkill.installed":"quickSkill.install")})]})})(),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border)]/40",children:[e.jsx("div",{className:"text-[10px] text-muted mb-1.5",children:s("quickSkill.mcpJsonLabel")}),e.jsx("textarea",{rows:3,value:Ve,onChange:o=>{Ee(o.target.value),Re("")},placeholder:`{
|
|
15
|
-
"serverName": { "command": "npx", "args": [...] }
|
|
16
|
-
}`,className:"w-full text-[11px] font-mono bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 text-foreground placeholder:text-muted/50 outline-none focus:border-[#0066FF]/60 resize-none"}),Ne&&e.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:Ne}),e.jsx("button",{disabled:!Ve.trim()||!r,onClick:async()=>{let o;try{const f=JSON.parse(Ve.trim());if(typeof f!="object"||Array.isArray(f)||f===null)throw new Error("not-object");if(f.mcpServers&&typeof f.mcpServers=="object"&&!Array.isArray(f.mcpServers)?o=f.mcpServers:f.servers&&typeof f.servers=="object"&&!Array.isArray(f.servers)?o=f.servers:o=f,Object.keys(o).length===0)throw new Error("empty");for(const[v,k]of Object.entries(o)){if(typeof k!="object"||Array.isArray(k)||k===null)throw new Error(s("quickSkill.mcpJsonValueNotObject",{name:v}));const D=k;if(!D.command&&!D.baseUrl&&!D.url)throw new Error(s("quickSkill.mcpJsonMissingField",{name:v}))}}catch(f){const v=f==null?void 0:f.message;v==="not-object"?Re(s("quickSkill.mcpJsonNotObject")):v==="empty"?Re(s("quickSkill.mcpJsonEmpty")):v!=null&&v.startsWith('"')?Re(v):Re(s("quickSkill.mcpJsonParseFailed",{error:v||""}));return}try{const f=await Jt(r,o);Ee(""),Re(""),h(s("quickSkill.mcpWritten"),"success"),Se(v=>v&&{...v,mcporterServers:f.mcpServers}),w(v=>({...v,loading:!0})),ft(r).then(v=>w({servers:v.servers,installed:v.installed,loading:!1})).catch(()=>w(v=>({...v,loading:!1})))}catch(f){Re(f.message||s("quickSkill.mcpWriteFailed"))}},className:"mt-1.5 w-full text-[11px] px-2 py-1 rounded bg-[#0066FF]/10 text-[#0066FF] hover:bg-[#0066FF]/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:s("quickSkill.addToConfig")})]}),(((Dt=tt.find(o=>o.id==="mcp"))==null?void 0:Dt.items)??[]).map(o=>{const f=Object.keys((U==null?void 0:U.mcporterServers)??{}),v=Ce.servers.map(C=>C.name),k=o.mcpJson?Object.keys(o.mcpJson):[],D=k.length>0&&k.some(C=>f.includes(C)||v.includes(C));return e.jsxs("button",{onClick:async()=>{if(o.mcpJson&&r)try{const C=await Jt(r,o.mcpJson);h(s("quickSkill.mcpAdded",{label:o.label}),"success"),Se(A=>A&&{...A,mcporterServers:C.mcpServers}),w(A=>({...A,loading:!0})),ft(r).then(A=>w({servers:A.servers,installed:A.installed,loading:!1})).catch(()=>w(A=>({...A,loading:!1})))}catch(C){h(C.message||s("quickSkill.mcpAddFailed"),"error")}else Xe(o.id)},className:"w-full text-left px-3 py-2.5 hover:bg-[var(--card-hover)] transition-colors border-t border-[var(--border)]/40 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:s(`data:mcp.${o.id}.label`,{defaultValue:o.label})}),e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5",children:s(`data:mcp.${o.id}.desc`,{defaultValue:o.desc})})]}),o.mcpJson&&e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${D?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:s(D?"quickSkill.configured":"quickSkill.oneClickConfig")})]},o.id)}),(()=>{var D;const o=(U==null?void 0:U.mcporterServers)??{},f=new Set((((D=tt.find(C=>C.id==="mcp"))==null?void 0:D.items)??[]).flatMap(C=>C.mcpJson?Object.keys(C.mcpJson):[])),v=Object.keys(o).filter(C=>!f.has(C));if(v.length===0)return null;const k={};for(const C of Ce.servers)k[C.name]=C;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2 pb-0.5 text-[9px] font-semibold text-muted/60 uppercase tracking-widest border-t border-[var(--border)]/40 mt-1",children:s("quickSkill.mcporterConfigured")}),v.map(C=>{var De;const A=o[C],P=k[C],K=(P==null?void 0:P.transport)??(A!=null&&A.baseUrl?`HTTP ${A.baseUrl}`:A!=null&&A.command?`${A.command} ${(A.args??[]).join(" ")}`.trim():""),de=(P==null?void 0:P.status)==="ok",Fe=P?de?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400":(Ce.loading,"bg-[var(--border)] text-muted"),ht=Ce.loading&&!P?s("quickSkill.detecting"):P?de?(De=P.tools)!=null&&De.length?s("quickSkill.statusNormalWithTools",{count:P.tools.length}):s("quickSkill.statusNormal"):P.status:s("quickSkill.configured");return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground font-mono",children:C}),K&&e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5 truncate",children:K})]}),e.jsxs("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${Fe} flex items-center gap-1`,children:[Ce.loading&&!P&&e.jsx("span",{className:"w-2 h-2 border border-muted/40 border-t-muted rounded-full animate-spin"}),ht]}),e.jsx("button",{onClick:async()=>{if(!(!r||!window.confirm(s("delete.mcpConfirm",{name:C}))))try{await Qs(r,C);const xt=await We(r);Se(xt),w(Ot=>({...Ot,servers:Ot.servers.filter(Ss=>Ss.name!==C)}))}catch(xt){h(xt.message||s("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:s("common:action.delete")})]},C)})]})})()]}),ye==="slash"&&e.jsx("div",{className:"py-1",children:(((Tt=tt.find(o=>o.id==="slash"))==null?void 0:Tt.groups)??[]).map((o,f)=>e.jsxs("div",{children:[f>0&&e.jsx("div",{className:"border-t border-[var(--border)]/40 mx-3 my-0.5"}),e.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-[9px] font-semibold text-muted/60 uppercase tracking-widest",children:s(`data:slash.group.${o.label}`,{defaultValue:o.label})}),o.items.map(v=>e.jsxs("button",{onClick:()=>Xe(v.id),className:"w-full text-left px-3 py-1 hover:bg-[var(--card-hover)] transition-colors",children:[e.jsx("div",{className:"text-xs font-medium text-foreground font-mono",children:v.label}),e.jsx("div",{className:"text-[11px] text-muted leading-tight",children:s(`data:slash.${v.id}.desc`,{defaultValue:v.desc})})]},v.id))]},o.label))})]})]})]})]}),ze||qe?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Ye("restart"),disabled:!!X||qe,className:"px-3 py-1.5 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:s(X==="restart"?"action.restarting":"common:action.restart")}),e.jsx("button",{onClick:()=>Ye("stop"),disabled:!!X,className:"px-3 py-1.5 bg-red-600 text-white rounded-md text-xs font-medium hover:bg-red-700 disabled:opacity-40 transition-all duration-200",children:s(X==="stop"?"action.stopping":"common:action.stop")})]}):e.jsx("button",{onClick:()=>Ye("start"),disabled:!!X,className:"px-3 py-1.5 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:s(X==="start"?"action.starting":"common:action.start")}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>G(!T),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-all duration-150",children:e.jsx(Gs,{className:"w-4 h-4"})}),T&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>G(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-40 bg-background border border-[var(--border)] rounded-lg shadow-2xl py-1 z-20",children:[e.jsx("button",{onClick:()=>{G(!1),Le("logs")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:s("tab.logs")}),e.jsx("button",{onClick:()=>{G(!1),Le("usage")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:s("tab.usage")}),e.jsx("div",{className:"border-t border-[var(--border)] my-1"}),e.jsx("button",{onClick:()=>{G(!1),fe("manage")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:s("backup.manageMenu",{defaultValue:"备份管理"})}),e.jsx("button",{onClick:()=>{G(!1),fe("export")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:s("backup.export",{defaultValue:"导出(分享)"})}),e.jsx("div",{className:"border-t border-[var(--border)] my-1"}),e.jsx("button",{onClick:()=>{G(!1),b(!0),me(!1)},className:"w-full text-left px-3 py-2 text-sm text-red-400 hover:bg-red-500/10 transition-colors",children:s("delete.title")})]})]})]})]})]}),r&&e.jsx(qr,{instanceId:r,instanceName:(u==null?void 0:u.name)||r,showToast:h,onRestoreComplete:Be,openBackup:se==="backup",openManage:se==="manage",openExport:se==="export",onDialogClose:()=>fe(null)}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted mb-3",children:[e.jsx("button",{onClick:()=>n("/"),className:"hover:text-foreground transition-colors",children:s("backToOverview")}),e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{children:["📊 ",((Vt=u.service)==null?void 0:Vt.memory_mb)!=null?`${u.service.memory_mb} MB`:"-"]}),e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{children:["⏱ ",Kr((_t=u.service)==null?void 0:_t.uptime,s)]}),e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{children:["🔌 ",s("port",{port:Wr(u)})]})]}),mt&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-3 flex items-center justify-between mb-3",children:[e.jsx("span",{children:s("failedHint")}),e.jsx("button",{onClick:()=>Le("logs"),className:"text-red-400 underline text-sm font-medium",children:s("viewLogs")})]}),N!=="chat"&&e.jsx("button",{onClick:()=>Le("chat"),className:"flex items-center gap-1 text-xs text-[#0066FF] hover:text-[#0066FF]/80 mb-3 transition-colors",children:s("backToChat")}),N==="chat"&&e.jsx(Br,{gatewayLaunchUrl:Q,gatewayReady:W,isRunning:It,isPending:qe,iframeLoaded:Z,actionLoading:X,onAction:Ye,onReload:()=>{ae(!1),ce(!1)},onIframeLoad:()=>ce(!0)}),N==="config"&&a&&e.jsxs("div",{className:"space-y-4",children:[i&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-lg px-4 py-2.5 flex items-center justify-between",children:[e.jsx("span",{children:s("config.modified")}),e.jsx("button",{onClick:()=>{l(null),Kt(r).then(o=>{l(o),R(JSON.stringify(o,null,2)),m(!1)})},className:"text-xs text-amber-400 hover:underline",children:s("config.discard")})]}),y&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-2.5",children:y}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>j(!1),className:`px-3 py-1.5 text-xs rounded-md transition-colors duration-150 ${F?"text-muted hover:bg-[var(--card-hover)]":"bg-[#0066FF] text-white"}`,children:s("config.form")}),e.jsx("button",{onClick:()=>{R(ks(a)),j(!0)},className:`px-3 py-1.5 text-xs rounded-md transition-colors duration-150 ${F?"bg-[#0066FF] text-white":"text-muted hover:bg-[var(--card-hover)]"}`,children:s("config.json")})]}),F?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"bg-[#0066FF]/10 border border-[#0066FF]/20 rounded-lg px-3 py-2 text-xs text-[#0066FF]/80 space-y-1",children:[e.jsx("div",{className:"font-medium text-[#0066FF]/90",children:s("config.jsonHelp")}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:s("config.jsonHelp1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("config.jsonHelp2")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("config.jsonHelp3")}})]})]}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 flex items-center justify-between",children:e.jsx("span",{className:"text-xs font-medium text-muted",children:"openclaw.json"})}),e.jsx("textarea",{value:V,onChange:o=>ws(o.target.value),className:"w-full font-mono text-[13px] p-4 min-h-[400px] lg:min-h-[500px] focus:outline-none resize-y text-foreground bg-transparent",spellCheck:!1})]})]}):e.jsx(vr,{config:a,onChange:js,instanceId:r,isRunning:It,pluginStatuses:je,onInstallPlugin:Et}),e.jsxs("div",{className:"flex gap-2 sticky bottom-0 backdrop-blur-sm py-3 -mx-6 px-6 border-t border-[var(--border)] mt-4",style:{background:"color-mix(in srgb, var(--background) 85%, transparent)"},children:[e.jsx("button",{onClick:()=>Pt(!1),disabled:!i||ne,className:"px-4 py-2 border border-[var(--border)] text-muted rounded-md text-sm font-medium hover:bg-[var(--card-hover)] hover:text-foreground disabled:opacity-40 transition-all duration-200",children:s(ne?"config.saving":"config.save")}),e.jsx("button",{onClick:()=>Pt(!0),disabled:ne,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:s(ne?"config.processing":"config.saveAndRestart")})]})]}),N==="logs"&&e.jsx(Ur,{logs:S,logSearch:B,logType:M,logsEndRef:lt,onSearchChange:z,onLogTypeChange:I,onRefresh:ut,onCopy:()=>{const o=B?S.filter(f=>f.toLowerCase().includes(B.toLowerCase())):S;navigator.clipboard.writeText(o.join(`
|
|
17
|
-
`)).then(()=>h(s("logs.copied"),"success")).catch(()=>h(s("logs.copyFailed"),"error"))}}),N==="usage"&&e.jsx(zr,{usage:te,onRefresh:()=>Ht(r).then(pe).catch(()=>{})}),L&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{le.current=!0,H.current=!1,J(null)},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-xs shadow-2xl",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s(L.type==="feishu"?"qr.feishuTitle":"qr.weixinTitle")}),e.jsx("button",{onClick:()=>{le.current=!0,H.current=!1,J(null)},className:"text-muted hover:text-foreground transition-colors text-lg leading-none",children:"✕"})]}),e.jsx("div",{className:"flex flex-col items-center gap-3",children:L.status==="confirmed"?e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-5 text-center w-full",children:[e.jsx("div",{className:"text-3xl mb-2",children:"✓"}),e.jsx("div",{className:"text-emerald-400 font-medium text-sm",children:L.message}),e.jsx("p",{className:"text-xs text-muted mt-1",children:s("qr.credSaved")})]}):L.status==="loading"?e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:`w-8 h-8 border-2 rounded-full animate-spin ${L.type==="feishu"?"border-[#3370FF]/30 border-t-[#3370FF]":"border-[#07C160]/30 border-t-[#07C160]"}`})}):L.status==="error"?e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-md px-4 py-4 text-center w-full",children:[e.jsx("div",{className:"text-red-400 text-sm",children:L.message}),e.jsx("button",{onClick:o=>{o.stopPropagation(),Mt(L.type)},className:`mt-3 px-4 py-1.5 text-white rounded-md text-xs font-medium transition-colors ${L.type==="feishu"?"bg-[#3370FF] hover:bg-[#3370FF]/90":"bg-[#07C160] hover:bg-[#07C160]/90"}`,children:s("qr.retry")})]}):e.jsxs(e.Fragment,{children:[L.qrUrl?e.jsx(rt,{value:L.qrUrl,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:`w-8 h-8 border-2 rounded-full animate-spin ${L.type==="feishu"?"border-[#3370FF]/30 border-t-[#3370FF]":"border-[#07C160]/30 border-t-[#07C160]"}`})}),e.jsx("div",{className:"flex items-center gap-2 text-sm",children:L.status==="scaned"?e.jsxs("span",{className:`font-medium ${L.type==="weixin"?"text-[#07C160]":"text-[#3370FF]"}`,children:["👀 ",L.message]}):e.jsx("span",{className:"text-muted",children:L.message})})]})}),L.status==="confirmed"&&e.jsx("button",{onClick:()=>{le.current=!0,H.current=!1,J(null)},className:"mt-4 w-full py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 transition-colors",children:s("common:action.close")})]})}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{b(!1),me(!1)},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",onClick:o=>o.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-2",children:s("delete.title")}),e.jsxs("p",{className:"text-sm text-muted mb-4",children:[s("delete.warningBefore"),e.jsx("strong",{className:"text-foreground",children:u.name}),s("delete.warningAfter")]}),e.jsx("p",{className:"text-sm text-muted mb-3",children:s("delete.confirmHint")}),e.jsx("input",{type:"text",value:E,onChange:o=>_(o.target.value),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground mb-4 focus:outline-none focus:ring-1 focus:ring-red-500/60 focus:border-red-500/60 transition-colors",placeholder:u.name}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted cursor-pointer mb-4",children:[e.jsx("input",{type:"checkbox",checked:q,onChange:o=>me(o.target.checked),className:"rounded border-[var(--border)] bg-[var(--input-bg)]"}),s("delete.purgeBackups",{defaultValue:"同时删除备份"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{b(!1),_(""),me(!1)},className:"flex-1 py-2 border border-[var(--border)] text-muted rounded-md text-sm font-medium hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-150",children:s("common:action.cancel")}),e.jsx("button",{onClick:ys,disabled:E.trim()!==(($t=u.name)==null?void 0:$t.trim()),className:"flex-1 py-2 bg-red-600 text-white rounded-md text-sm font-medium hover:bg-red-700 disabled:opacity-40 transition-colors",children:s("delete.confirm")})]})]})})]})}export{ta as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,ab as R,ac as T,ad as K,h as O,o as U,ae as J}from"./index-DbX85irc.js";import{u as D,r,f as W}from"./vendor-react-B1-3Yrt-.js";import{u as L}from"./vendor-i18n-CfW0RvgE.js";function q({onClose:t,showToast:c}){const{t:n}=L("newInstance"),o=D(),[x,b]=r.useState("upload"),[j,p]=r.useState(!1),[y,d]=r.useState(""),[u,F]=r.useState(null),S=r.useRef(null),[v,E]=r.useState(""),[i,$]=r.useState(null),[N,I]=r.useState([]),[_,V]=r.useState(0),[g,w]=r.useState(""),[h,k]=r.useState(""),[C,M]=r.useState(!1);function a(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,63)}function f(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}const A=async()=>{var s;if(u){p(!0),d("");try{const l=await R(u);E(l.temp_id);const m=await T(l.temp_id);$(m.manifest),I(m.warnings||[]),V(m.estimated_size||0),(s=m.manifest)!=null&&s.name&&(k(m.manifest.name),C||w(a(m.manifest.name))),b("preview")}catch(l){d(l.message||"Upload failed")}finally{p(!1)}}},P=async()=>{var s;if(!(!g||!h||!v)){p(!0),d(""),b("creating");try{const l=await K({temp_id:v,id:g,name:h});l.ok?(c(n("import.success",{defaultValue:"导入成功"}),"success"),(s=l.warnings)!=null&&s.length&&l.warnings.forEach(m=>c(m,"info")),o(`/instances/${l.instance_id}/config`)):(d(l.detail||n("import.failed",{defaultValue:"导入失败"})),b("preview"))}catch(l){d(l.message||"Import failed"),b("preview")}finally{p(!1)}}},B="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";return e.jsxs("div",{className:"space-y-4",children:[y&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5",children:y}),x==="upload"&&e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"text-xs text-muted bg-card border border-[var(--border)] rounded-md p-3",children:n("import.uploadDesc",{defaultValue:"上传 .tar.gz 文件(支持 JishuShell 导出包、备份包、OpenClaw 官方备份)"})}),e.jsx("input",{ref:S,type:"file",accept:".tar.gz,.tgz",onChange:s=>{var l;return F(((l=s.target.files)==null?void 0:l[0])||null)},className:"hidden"}),e.jsx("button",{type:"button",onClick:()=>{var s;return(s=S.current)==null?void 0:s.click()},className:"w-full flex items-center justify-center gap-2 px-4 py-3 border border-dashed border-[var(--border)] rounded-lg text-sm text-muted hover:text-foreground hover:border-[#0066FF]/40 hover:bg-[var(--input-bg)] transition-colors cursor-pointer",children:u?e.jsxs("span",{className:"text-foreground truncate",children:[u.name," (",(u.size/1024/1024).toFixed(1),"MB)"]}):n("import.selectFile",{defaultValue:"点击选择 .tar.gz 文件"})})]}),x==="preview"&&i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-5 space-y-4",children:[e.jsxs("div",{className:"bg-[var(--input-bg)] border border-[var(--border)] rounded-lg p-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:n("import.name",{defaultValue:"名称"})}),e.jsx("span",{className:"text-foreground",children:i.name||"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:n("import.type",{defaultValue:"类型"})}),e.jsx("span",{className:"text-foreground",children:i.type||"unknown"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:n("import.size",{defaultValue:"大小"})}),e.jsx("span",{className:"text-foreground",children:f(_)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted",children:n("import.platform",{defaultValue:"平台"})}),e.jsxs("span",{className:"text-foreground",children:[i.platform||"-"," / ",i.arch||"-"]})]}),i.has_sessions===!1&&e.jsx("div",{className:"text-amber-400 text-xs",children:n("import.noSessions",{defaultValue:"不含对话历史"})})]}),N.length>0&&e.jsx("div",{className:"space-y-1",children:N.map((s,l)=>e.jsx("p",{className:"text-xs text-amber-400",children:s},l))}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:n("name.label",{defaultValue:"实例名称"})}),e.jsx("input",{type:"text",value:h,onChange:s=>{k(s.target.value),C||w(a(s.target.value))},className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:n("id.label",{defaultValue:"实例 ID"})}),e.jsx("input",{type:"text",value:g,onChange:s=>{w(s.target.value),M(!0)},className:`${B} font-mono text-[13px]`})]})]}),e.jsx("button",{className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",onClick:P,disabled:!g||!h||j,children:n("import.create",{defaultValue:"创建实例"})})]}),x==="upload"&&e.jsx("button",{className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",onClick:A,disabled:!u||j,children:j?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),n("import.uploading",{defaultValue:"上传中..."})]}):n("import.upload",{defaultValue:"上传并预览"})}),x==="creating"&&e.jsxs("div",{className:"flex items-center justify-center py-8 gap-3",children:[e.jsx("span",{className:"w-4 h-4 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-muted",children:n("import.creating",{defaultValue:"正在创建实例..."})})]})]})}function G(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,63)}const z="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function Y(){const{t}=L("newInstance"),[c,n]=r.useState(""),[o,x]=r.useState(""),[b,j]=r.useState(!1),[p,y]=r.useState(""),[d,u]=r.useState(""),[F,S]=r.useState([]),[v,E]=r.useState(!0),[i,$]=r.useState(!1),[N,I]=r.useState(""),[_,V]=r.useState(!1),[g]=W(),w=g.get("import")==="true",h=D(),{showToast:k}=O();r.useEffect(()=>{U().then(S).catch(()=>{})},[]);const C=a=>{n(a),b||x(G(a))},M=async a=>{if(a.preventDefault(),!(!o||!c)){I(""),V(!0);try{const f=await J({id:o,name:c,description:p,clone_from:d||void 0,clone_options:d?{include_sessions:i,include_memory:v}:void 0});h(f!=null&&f.autoStarted?`/instances/${o}`:`/instances/${o}/config`)}catch(f){I(f.message||t("failed"))}finally{V(!1)}}};return w?e.jsxs("div",{className:"p-6 max-w-lg mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:t("import.title",{defaultValue:"导入实例"})}),e.jsx("p",{className:"text-sm text-muted mt-0.5",children:t("import.subtitle",{defaultValue:"从文件导入 OpenClaw 实例"})})]}),e.jsx(q,{onClose:()=>h("/instances/new"),showToast:k})]}):e.jsxs("div",{className:"p-6 max-w-lg mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:t("title")}),e.jsx("p",{className:"text-sm text-muted mt-0.5",children:t("subtitle")})]}),e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[N&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5",children:N}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"text-xs text-muted bg-card border border-[var(--border)] rounded-md p-3",children:t("info")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("name.label")}),e.jsx("input",{type:"text",value:c,onChange:a=>C(a.target.value),placeholder:t("name.placeholder"),className:z,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("id.label")}),e.jsx("input",{type:"text",value:o,onChange:a=>{x(a.target.value),j(!0)},placeholder:t("id.placeholder"),className:`${z} font-mono text-[13px]`}),e.jsx("p",{className:"text-xs text-muted mt-1",children:c&&!o?e.jsx("span",{className:"text-amber-400",children:t("id.invalid")}):t("id.hint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("description.label")}),e.jsx("input",{type:"text",value:p,onChange:a=>y(a.target.value),placeholder:t("description.placeholder"),className:z})]}),F.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("clone.label")}),e.jsxs("select",{value:d,onChange:a=>u(a.target.value),className:`${z} appearance-none`,children:[e.jsx("option",{value:"",className:"bg-background text-foreground",children:t("clone.none")}),F.map(a=>e.jsx("option",{value:a.id,className:"bg-background text-foreground",children:a.name},a.id))]}),d&&e.jsxs("div",{className:"bg-[var(--input-bg)] border border-[var(--border)] rounded-lg p-4 space-y-2 mt-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:t("clone.preview",{defaultValue:"将复制以下内容:"})}),e.jsxs("div",{className:"space-y-1.5 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),e.jsx("span",{children:t("clone.config",{defaultValue:"Agent 配置 (openclaw.json)"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),e.jsx("span",{children:t("clone.plugins",{defaultValue:"插件 (extensions)"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),e.jsx("span",{children:t("clone.workspace",{defaultValue:"工作区 / Skills / 人设文件"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-400",children:"✓"}),e.jsx("span",{children:t("clone.apikey",{defaultValue:"API Key 配置"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:a=>E(a.target.checked),className:"rounded border-[var(--border)] bg-[var(--input-bg)]"}),e.jsx("span",{children:t("clone.memory",{defaultValue:"Agent 记忆"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:a=>$(a.target.checked),className:"rounded border-[var(--border)] bg-[var(--input-bg)]"}),e.jsx("span",{children:t("clone.sessions",{defaultValue:"对话历史"})})]})]}),e.jsx("p",{className:"text-xs text-muted mt-2 opacity-70",children:t("clone.channelNote",{defaultValue:"IM 通道凭证不会复制(同一通道不能绑定多个实例)"})})]})]})]}),e.jsx("button",{type:"submit",disabled:_||!o||!c,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:_?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),t("loading")]}):t("submit")})]})]})}export{Y as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{af as G,ag as H,ah as U,o as V,J,j as e,I as K,a as A,e as W,ai as q,s as z}from"./index-DbX85irc.js";import{r}from"./vendor-react-B1-3Yrt-.js";import{P as x}from"./providers-lBSOjUWy.js";import{u as Q}from"./vendor-i18n-CfW0RvgE.js";function le(){const{t}=Q(["settings","setup","instance"]),{system:d,showToast:m}=G(),[h,N]=r.useState(""),[b,w]=r.useState(""),[p,B]=r.useState(!1),[i,S]=r.useState(""),[v,f]=r.useState(""),[g,M]=r.useState(!1),[k,j]=r.useState(""),[P,F]=r.useState(!1),[_,C]=r.useState(!1),[E,y]=r.useState(!1),[X,D]=r.useState([]),[Y,I]=r.useState(!1),[Z,ee]=r.useState(!1),[se,O]=r.useState(!1);r.useEffect(()=>{H().then(s=>{s.configured&&s.providerId&&(S(s.providerId),j(s.selectedModelId||""),y(!!s.hasApiKey)),C(!0)}).catch(()=>C(!0))},[]),r.useEffect(()=>{I(!0),U().then(D).catch(()=>{}).finally(()=>I(!1)),V().then(async s=>{try{const l=await Promise.all(s.map(n=>J(n.id).catch(()=>({enabled:!1})))),o=s.length>0&&l.every(n=>n==null?void 0:n.enabled);O(o)}catch{}}).catch(()=>{})},[]);const L=async()=>{var l;if(!i)return;const s=x.find(o=>o.id===i);if(s){F(!0);try{await W({providerId:s.id,baseUrl:s.baseUrl,api:s.api,authHeader:s.authHeader||!1,models:s.models,selectedModelId:k||((l=s.models[0])==null?void 0:l.id)||"",apiKey:v||""}),m(t("setup:provider.saved"),"success"),f(""),y(!0)}catch(o){m(o.message||t("setup:provider.saveFailed"),"error")}finally{F(!1)}}},T=async s=>{s.preventDefault();try{const l=await q(h,b);l.token&&z(l.token),m(t("password.updated"),"success"),N(""),w("")}catch(l){m(l.message||t("password.failed"),"error")}},u="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:t("title")}),e.jsx("p",{className:"text-sm text-muted mt-0.5",children:t("subtitle")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:t("proxy.title")}),e.jsx("p",{className:"text-sm text-muted mt-1",children:t("proxy.desc")})]}),e.jsx("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-3",children:t("proxy.status")})]}),_&&(()=>{var $;const s=x.find(a=>a.id===i),l=[...new Set(x.map(a=>a.group))],o=(s==null?void 0:s.models)||[],n=["ollama","vllm","sglang"].includes(i),R=i&&(n||v.trim()||E);return e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-1",children:t("setup:provider.title")}),e.jsx("p",{className:"text-sm text-muted mb-3",children:t("setup:provider.desc")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.label")}),e.jsxs("select",{value:i,onChange:a=>{S(a.target.value),j(""),f(""),y(!1)},className:u,children:[e.jsx("option",{value:"",children:t("setup:provider.placeholder")}),l.map(a=>e.jsx("optgroup",{label:t(`instance:configForm.providerGroup.${a}`,{defaultValue:a}),children:x.filter(c=>c.group===a).map(c=>e.jsx("option",{value:c.id,children:t(`instance:configForm.providerLabel.${c.id}`,{defaultValue:c.label})},c.id))},a))]})]}),i&&!n&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.apiKey")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:g?"text":"password",value:v,onChange:a=>f(a.target.value),placeholder:t(E?"setup:provider.apiKeyConfigured":"setup:provider.apiKeyPlaceholder"),className:`${u} pr-9 font-mono`}),e.jsx("button",{type:"button",onClick:()=>M(!g),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors",children:g?e.jsx(K,{className:"w-3.5 h-3.5"}):e.jsx(A,{className:"w-3.5 h-3.5"})})]})]}),s&&o.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.defaultModel")}),e.jsx("select",{value:k||(($=o[0])==null?void 0:$.id)||"",onChange:a=>j(a.target.value),className:u,children:o.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",Math.round(a.contextWindow/1e3),"K)"]},a.id))})]}),e.jsx("button",{onClick:L,disabled:!R||P,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:t(P?"setup:provider.saving":"setup:provider.save")})]})]})})(),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-3",children:t("password.title")}),e.jsxs("form",{onSubmit:T,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted mb-1.5",children:t("password.current")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:p?"text":"password",value:h,onChange:s=>N(s.target.value),placeholder:t("password.currentPlaceholder"),className:`${u} pr-9`}),e.jsx("button",{type:"button",onClick:()=>B(!p),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors",children:p?e.jsx(K,{className:"w-3.5 h-3.5"}):e.jsx(A,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted mb-1.5",children:t("password.new")}),e.jsx("input",{type:p?"text":"password",value:b,onChange:s=>w(s.target.value),placeholder:t("password.newPlaceholder"),className:u})]}),e.jsx("button",{type:"submit",disabled:!h||b.length<8,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:t("password.submit")})]})]}),d&&e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-3",children:t("system.title")}),e.jsxs("div",{className:"space-y-3",children:[[{label:t("system.cpuUsage"),value:`${d.cpu_percent}%`,percent:d.cpu_percent,warn:d.cpu_percent>90,color:"bg-[#0066FF]"},{label:t("system.memory"),value:`${d.memory.used_mb}MB / ${d.memory.total_mb}MB (${d.memory.percent}%)`,percent:d.memory.percent,warn:!1,color:"bg-[#00D4AA]"},{label:t("system.disk"),value:`${d.disk.used_gb}GB / ${d.disk.total_gb}GB (${d.disk.percent}%)`,percent:d.disk.percent,warn:d.disk.percent>90,color:"bg-[#0066FF]"}].map(s=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1.5",children:[e.jsx("span",{className:"text-muted",children:s.label}),e.jsx("span",{className:`font-medium font-mono text-[13px] ${s.warn?"text-red-400":"text-foreground"}`,children:s.value})]}),e.jsx("div",{className:"w-full bg-[var(--input-bg)] rounded-full h-1.5",children:e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-500 ${s.warn?"bg-red-500":s.color}`,style:{width:`${s.percent}%`}})})]},s.label)),d.temperature&&e.jsxs("div",{className:"flex justify-between text-sm pt-2 border-t border-[var(--border)]",children:[e.jsx("span",{className:"text-muted",children:t("system.cpuTemp")}),e.jsxs("span",{className:"font-medium font-mono text-[13px] text-foreground",children:[d.temperature,"°C"]})]})]})]}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-2",children:t("about.title")}),e.jsx("div",{className:"text-sm text-muted space-y-1",children:e.jsxs("p",{children:["JishuShell ","0.4.10"]})})]})]})]})}export{le as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as Z,d as pe,j as e,T as be,e as ee,i as y,f as he,r as ge,u as fe}from"./index-DbX85irc.js";import{r as c}from"./vendor-react-B1-3Yrt-.js";import{P as T}from"./providers-lBSOjUWy.js";import{u as te}from"./vendor-i18n-CfW0RvgE.js";const F=[{id:"check",label:"环境检测"},{id:"node",label:"Node.js"},{id:"docker",label:"Docker"},{id:"nomad",label:"Nomad"},{id:"openclaw",label:"OpenClaw"},{id:"provider",label:"模型配置"},{id:"done",label:"完成"}];function ve({ok:l}){return l?e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.7)]"}):e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--border)]"})}function D({dep:l,label:s,required:t,extra:S}){const{t:i}=te("setup"),f=l.needsUpgrade;return e.jsxs("div",{className:"flex items-center justify-between py-2.5 border-b border-[var(--border)] last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[f?e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 shadow-[0_0_6px_rgba(251,191,36,0.6)]"}):e.jsx(ve,{ok:l.installed}),e.jsx("span",{className:"text-sm text-foreground",children:s||l.name}),f&&e.jsx("span",{className:"text-xs text-amber-400",children:i("versionTooOld")}),t&&!l.installed&&!f&&e.jsx("span",{className:"text-xs text-red-400",children:i("required")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[S,e.jsx("span",{className:"text-xs text-muted font-mono",children:l.installed?l.version||"installed":"not installed"})]})]})}function w(){return e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"})}function se(l){return/失败|error|denied|forbidden|unauthorized/i.test(l)?"error":/完成|已就绪|已启动|已存在|成功|built|installed/i.test(l)?"success":/正在|等待|下载|安装|构建|启动|升级|progress|exporting|transferring/i.test(l)?"progress":"info"}function je(l){switch(l){case"progress":return{dot:"bg-sky-400 shadow-[0_0_8px_rgba(56,189,248,0.55)]",text:"text-sky-100"};case"success":return{dot:"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.55)]",text:"text-emerald-100"};case"error":return{dot:"bg-red-400 shadow-[0_0_8px_rgba(248,113,113,0.55)]",text:"text-red-200"};default:return{dot:"bg-slate-500 shadow-[0_0_8px_rgba(148,163,184,0.35)]",text:"text-slate-200/90"}}}function Fe({onDone:l}){var J,Q,X,Y;const{t:s}=te(["setup","common","instance"]),[t,S]=c.useState(null),[i,f]=c.useState("check"),[u,k]=c.useState(null),[R,M]=c.useState([]),[_,v]=c.useState(""),[B,$]=c.useState(!1),[g,re]=c.useState(""),[E,ne]=c.useState(""),[P,de]=c.useState(!1),[A,O]=c.useState(""),[q,z]=c.useState(!1),K=c.useRef(new Set),W=c.useCallback((n,r)=>{if(K.current.has(n))return;K.current.add(n);const d=r==="openclaw-docker"?s("setup:dockerImageBuild"):r==="docker"?s("setup:dockerInstall"):r==="openclaw"?s("setup:openclawInstall"):r;k(r),p(s("setup:resumeTask",{label:d}),"progress"),U(n,d).then(()=>{x(!0)}).catch(o=>{v(o.message||s("setup:taskFailed"))}).finally(()=>{k(null)})},[]),x=c.useCallback((n=!1)=>{Z().then(r=>{var d;if(S(r),(d=r.runningTasks)!=null&&d.length)for(const o of r.runningTasks)W(o.id,o.name);if(!n&&r.ready){f("provider");return}}).catch(()=>{})},[l,W]);c.useEffect(()=>{x()},[x]),c.useEffect(()=>{var r,d;if(i!=="nomad"||!((r=t==null?void 0:t.nomad)!=null&&r.installed)||(d=t==null?void 0:t.nomad)!=null&&d.running)return;const n=setInterval(()=>{x(!0)},3e3);return()=>clearInterval(n)},[i,(J=t==null?void 0:t.nomad)==null?void 0:J.installed,(Q=t==null?void 0:t.nomad)==null?void 0:Q.running,x]);const p=(n,r=se(n))=>M(d=>[...d,{message:n,tone:r}].slice(-200)),ae=(n,r)=>r.type==="progress"&&typeof r.progress=="number"?`${n}: ${r.message} [${r.progress}%]`:r.type==="done"?`${n}: ${r.message}`:r.type==="error"?s("setup:taskErrorPrefix",{label:n,message:r.message}):r.message,U=async(n,r)=>{let d=0,o=0,a=s("setup:taskCompleted",{label:r});const b=Date.now()+30*60*1e3;for(;Date.now()<b;){try{const m=await pe(n);o=0;const h=m.events.slice(d);d=m.events.length;for(const j of h){const xe=j.type==="done"?"success":j.type==="error"?"error":j.type==="progress"?"progress":se(j.message);p(ae(r,j),xe),j.message&&(a=j.message)}if(m.status==="done")return a;if(m.status==="error")throw new Error(a)}catch(m){if(o+=1,o>=5)throw new Error((m==null?void 0:m.message)||s("setup:taskStatusFailed",{label:r}))}const L=Math.min(1e3+d*200,3e3);await new Promise(m=>setTimeout(m,L))}throw new Error(s("setup:taskTimeout",{label:r}))},N=async(n,r,d)=>{k(n),v(""),p(s("setup:installing",{label:r}),"progress");try{const o=await d();let a=o.message||s("setup:taskStarted",{label:r});return o!=null&&o.taskId?a=await U(o.taskId,r):p(`${r}: ${a}`,"success"),x(!0),!0}catch(o){const a=o.message||s("setup:defaultInstallFailed");return p(s("setup:installFailed",{label:r,error:a}),"error"),v(a),!1}finally{k(null)}},V=async()=>{await N("node","Node.js",()=>fe())},oe=async()=>{await N("docker","Docker",()=>y("docker"))},[H,G]=c.useState(!1),le=async()=>{const n=await N("openclaw",s("setup:dockerImageBuild"),()=>y("openclaw"));G(n),x(!0)},ie=async()=>{const n=await N("openclaw-docker",s("setup:dockerImageBuild"),()=>y("openclaw-docker"));G(n),x(!0)},ce=async()=>{var r;if(await N("nomad","Nomad",()=>y("nomad"))){p(s("setup:configuringNomadSystemd"),"progress"),k("nomad-systemd");try{await y("nomad-systemd"),p(s("setup:nomadServiceStarted"),"success")}catch{try{await he("nomad"),p(s("setup:nomadStarted"),"success")}catch(d){p(s("setup:nomadStartFailed",{error:d.message}),"error"),v(d.message)}}k(null),p(s("setup:waitingNomad"),"progress");for(let d=0;d<10;d++){await new Promise(a=>setTimeout(a,2e3));const o=await Z();if((r=o.nomad)!=null&&r.running){S(o),p(s("setup:nomadReady"),"success");return}}x(!0)}},I=!!((X=t==null?void 0:t.node)!=null&&X.installed)&&!((Y=t==null?void 0:t.node)!=null&&Y.needsUpgrade),C=async()=>{var o,a,b,L,m;const n=F.findIndex(h=>h.id===i);if(n>=F.length-1)return;let r=n+1;for(;r<F.length-1;){const h=F[r].id;if(h==="node"&&I){r++;continue}if(h==="docker"&&((o=t==null?void 0:t.docker)!=null&&o.installed)&&((a=t==null?void 0:t.docker)!=null&&a.running)){r++;continue}if(h==="nomad"&&((b=t==null?void 0:t.nomad)!=null&&b.installed)&&((L=t==null?void 0:t.nomad)!=null&&L.running)){r++;continue}if(h==="openclaw"&&((m=t==null?void 0:t.openclaw)!=null&&m.installed)&&(t!=null&&t.dockerImageReady)){r++;continue}break}const d=F[r].id;if(v(""),M([]),d==="done"){f("done"),$(!0);try{await ge({installNomad:!1,buildDockerImage:!1})}catch(h){v(h.message||s("setup:configWriteFailed"))}finally{$(!1)}}else f(d)},ue=n=>{if(!t)return!1;switch(n){case"check":return I;case"node":return I;case"docker":return t.docker.installed&&t.docker.running;case"nomad":return t.nomad.installed&&t.nomad.running;case"openclaw":return t.openclaw.installed&&(H||t.dockerImageReady);case"provider":return!0;case"done":return!0;default:return!1}},me=async()=>{var r;if(!g)return!1;const n=T.find(d=>d.id===g);if(!n)return!1;z(!0);try{return await ee({providerId:n.id,baseUrl:n.baseUrl,api:n.api,authHeader:n.authHeader||!1,models:n.models,selectedModelId:A||((r=n.models[0])==null?void 0:r.id)||"",apiKey:E||""}),!0}catch(d){return v(d.message||s("setup:saveFailed")),!1}finally{z(!1)}};return t?e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden",children:[e.jsx("div",{className:"grid-bg absolute inset-0 pointer-events-none"}),e.jsx("div",{className:"absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[400px] rounded-full bg-[#0066FF]/[0.06] blur-[100px] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-lg relative z-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(be,{className:"w-48 h-48 mx-auto mb-4 object-contain"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:s("setup:title")})]}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-xl p-6 backdrop-blur-sm",children:[i==="check"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:check.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:check.desc")}),e.jsx("p",{className:"text-xs text-muted mb-1.5 font-medium",children:s("setup:check.requiredComponents")}),e.jsxs("div",{className:"bg-card rounded-md border border-[var(--border)] px-4",children:[e.jsx(D,{dep:t.node,label:"Node.js",required:!0,extra:t.node.needsUpgrade?e.jsx("button",{onClick:V,disabled:!!u,className:"text-xs bg-amber-500/20 text-amber-400 border border-amber-500/30 rounded px-2 py-0.5 hover:bg-amber-500/30 disabled:opacity-40 transition-colors duration-200",children:s(u==="node"?"setup:check.upgrading":"setup:check.upgrade")}):void 0}),e.jsx(D,{dep:t.docker,label:"Docker",required:!0}),e.jsx(D,{dep:t.nomad,label:"Nomad",required:!0}),e.jsx(D,{dep:t.openclaw,label:"OpenClaw",required:!0})]})]}),i==="node"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:node.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:node.desc")}),I?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:s("setup:node.ready",{version:t.node.version})}):t.hasSudo?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:s("setup:node.currentVersion",{version:t.node.version})}),e.jsx("button",{onClick:V,disabled:!!u,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:u?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(w,{}),s("setup:node.upgrading")]}):s("setup:node.upgradeBtn")}),e.jsx("p",{className:"text-xs text-muted",children:s("setup:node.sudoRequired")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:s("setup:node.noSudo",{version:t.node.version})}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:s("setup:node.contactAdmin")}),e.jsx("code",{className:"text-xs text-foreground font-mono block whitespace-pre-wrap",children:"curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs"})]}),e.jsx("button",{onClick:()=>x(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:s("setup:node.refreshAfterInstall")})]})]}),i==="docker"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:docker.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:docker.desc")}),t.docker.installed&&t.docker.running?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:s("setup:docker.running",{version:t.docker.version})}):t.docker.installed&&!t.docker.running?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:s("setup:docker.notRunning")}),e.jsx("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:e.jsx("code",{className:"text-xs text-foreground font-mono block",children:"sudo systemctl start docker"})}),e.jsx("button",{onClick:()=>x(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:s("setup:docker.refreshAfterStart")})]}):t.hasSudo?e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:oe,disabled:!!u,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:u?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(w,{}),s("setup:docker.installing")]}):s("setup:docker.installBtn")}),e.jsx("p",{className:"text-xs text-muted",children:s("setup:docker.sudoRequired")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:s("setup:docker.noSudo")}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:s("setup:docker.contactAdmin")}),e.jsx("code",{className:"text-xs text-foreground font-mono block",children:"curl -fsSL https://get.docker.com | sh"})]}),e.jsx("button",{onClick:()=>x(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:s("setup:docker.refreshAfterInstall")})]})]}),i==="nomad"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:nomad.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:nomad.desc")}),t.nomad.installed&&t.nomad.running?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:s("setup:nomad.running",{version:t.nomad.version})}):t.nomad.installed?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:[e.jsx(w,{}),e.jsx("span",{children:s("setup:nomad.starting")})]})}):e.jsx("button",{onClick:ce,disabled:!!u,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:u?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(w,{}),s("setup:nomad.installing")]}):s("setup:nomad.installBtn")})]}),i==="openclaw"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:openclaw.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:openclaw.desc")}),t.openclaw.installed?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:s("setup:openclaw.installed",{version:t.openclaw.version})}),u==="openclaw-docker"?e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:[e.jsx(w,{}),e.jsx("span",{children:s("setup:openclaw.buildingImage")})]}):!H&&!t.dockerImageReady?e.jsx("button",{onClick:ie,disabled:!!u,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:s("setup:openclaw.buildImageBtn")}):null]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:le,disabled:!!u,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:u?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(w,{}),s("setup:openclaw.installing")]}):s("setup:openclaw.installBtn")}),e.jsx("p",{className:"text-xs text-muted",children:s("setup:openclaw.npmHint")})]})]}),i==="done"&&e.jsx("div",{className:"text-center py-4",children:B?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-2 border-white/10 border-t-[#0066FF] rounded-full animate-spin"})}),e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:done.finalizing")}),e.jsx("p",{className:"text-sm text-muted",children:s("setup:done.finalizingDesc")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:done.complete")}),e.jsx("p",{className:"text-sm text-muted",children:s("setup:done.completeDesc")})]})}),i==="provider"&&(()=>{var o;const n=T.find(a=>a.id===g),r=[...new Set(T.map(a=>a.group))],d=(n==null?void 0:n.models)||[];return e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:s("setup:provider.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:s("setup:provider.desc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:s("setup:provider.label")}),e.jsxs("select",{value:g,onChange:a=>{re(a.target.value),O("")},className:"w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60",children:[e.jsx("option",{value:"",children:s("setup:provider.placeholder")}),r.map(a=>e.jsx("optgroup",{label:s(`instance:configForm.providerGroup.${a}`,{defaultValue:a}),children:T.filter(b=>b.group===a).map(b=>e.jsx("option",{value:b.id,children:s(`instance:configForm.providerLabel.${b.id}`,{defaultValue:b.label})},b.id))},a))]})]}),g&&!["ollama","vllm","sglang"].includes(g)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:s("setup:provider.apiKey")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:P?"text":"password",value:E,onChange:a=>ne(a.target.value),placeholder:s("setup:provider.apiKeyPlaceholder"),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 pr-9 text-sm text-foreground font-mono placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60"}),e.jsx("button",{type:"button",onClick:()=>de(!P),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:P?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"}):e.jsxs(e.Fragment,{children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})})]})]}),n&&d.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:s("setup:provider.defaultModel")}),e.jsx("select",{value:A||((o=d[0])==null?void 0:o.id)||"",onChange:a=>O(a.target.value),className:"w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60",children:d.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",Math.round(a.contextWindow/1e3),"K)"]},a.id))})]})]})]})})(),R.length>0&&i!=="done"&&e.jsxs("div",{className:"mt-4 rounded-lg border border-[var(--border)] bg-[linear-gradient(180deg,rgba(2,6,23,0.96),rgba(15,23,42,0.92))] p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] max-h-40 overflow-y-auto",children:[R.map((n,r)=>{const d=je(n.tone);return e.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[e.jsx("span",{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${d.dot}`}),e.jsx("div",{className:`min-w-0 whitespace-pre-wrap break-words text-xs font-mono leading-5 ${d.text}`,children:n.message})]},r)}),e.jsx("div",{className:"pointer-events-none sticky bottom-0 h-4 bg-gradient-to-t from-slate-950/85 to-transparent"})]}),_&&e.jsx("div",{className:"mt-4 bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-md px-3 py-2.5",children:_})]}),e.jsx("div",{className:"flex justify-between mt-6",children:i==="provider"?(()=>{const n=["ollama","vllm","sglang"].includes(g),r=g&&(n||E.trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:async()=>{await ee({skipped:!0}).catch(()=>{}),C()},className:"bg-[var(--card)] border border-[var(--border)] text-foreground rounded-md px-6 py-2 text-sm font-medium hover:bg-[var(--card-hover)] transition-all duration-200",children:s("setup:provider.skip")}),e.jsx("button",{onClick:async()=>{await me()&&C()},disabled:!r||q,className:"bg-[#0066FF] text-white rounded-md px-6 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)]",children:s(q?"setup:provider.saving":"setup:provider.saveAndContinue")})]})})():i!=="done"?e.jsxs(e.Fragment,{children:[e.jsx("div",{}),e.jsx("button",{onClick:C,disabled:!ue(i)||!!u,className:"bg-[#0066FF] text-white rounded-md px-6 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:s("setup:nav.next")})]}):e.jsx("button",{onClick:_?()=>C():l,disabled:B,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)]",children:s(_?"setup:nav.retry":"setup:nav.enterPanel")})})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border)] border-t-foreground rounded-full animate-spin"})})}export{Fe as default};
|