@versot/vaguspi 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +302 -25
- package/dist/bin.js.map +3 -3
- package/gui/assets/index-Dl4o9eCz.js +19 -0
- package/gui/assets/settings-V9zrDr2c.js +60 -0
- package/gui/assets/vendor-CkEpMl6t.js +40 -0
- package/gui/index.html +7 -3
- package/package.json +1 -1
- package/gui/assets/index-BC6qaWvB.js +0 -26
- package/gui/assets/index-CBwrpcqx.js +0 -60
- package/gui/assets/vendor-BtP0CW_r.js +0 -32
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var Ze=Object.defineProperty;var Xe=(r,o,t)=>o in r?Ze(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var Z=(r,o,t)=>Xe(r,typeof o!="symbol"?o+"":o,t);import{r as c,j as e}from"./vendor-CkEpMl6t.js";const Qe={color:{primary:"#4f8cff",bg:"#0f1117",sidebarBg:"#12141a",sidebarHover:"#1b1f2b",surface:"#161922",fg:"#e6e8ee",muted:"#8b90a0",border:"#2a2e3a",success:"#3fb950",warning:"#d29922",error:"#f85149",accent:"#79c0ff"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},qe={color:{primary:"#2563eb",bg:"#ffffff",sidebarBg:"#f6f7f9",sidebarHover:"#eceef1",surface:"#f3f4f6",fg:"#1f2937",muted:"#6b7280",border:"#e5e7eb",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",accent:"#3b82f6"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},Fe=Qe,eo={bg:"#ffffff",header:"#f6f8fa",border:"#d0d7de",text:"#24292f",keyword:"#cf222e",fn:"#8250df",type:"#953800",prop:"#0550ae",str:"#0a3069"},oo={bg:"#0d1117",header:"#161b22",border:"#30363d",text:"#c9d1d9",keyword:"#ff7b72",fn:"#d2a8ff",type:"#ffa657",prop:"#79c0ff",str:"#a5d6ff"};function ro(r){return r==="GitHub Light"?eo:oo}function no(r,o){const t=[],n=/("(?:[^"\\]|\\.)*")|([a-zA-Z_$][\w$]*)(?=\s*:\s*[A-Z][A-Za-z0-9]*)|\b(const|let|var|function|return|import|export|from|new|type|interface|extends|async|await)\b|([a-zA-Z_$][\w$]*)(?=\s*:)|(#[0-9a-fA-F]{3,8}\b)|\b(true|false|null|undefined)\b|\b(\d+(?:\.\d+)?)\b/g;let i=0,a;for(;(a=n.exec(r))!==null;){a.index>i&&t.push({text:r.slice(i,a.index)});const[,s,d,f,p,m,g,k]=a;s!==void 0?t.push({text:s,color:o.str}):d!==void 0?t.push({text:d,color:o.fn}):f!==void 0?t.push({text:f,color:o.keyword}):p!==void 0?t.push({text:p,color:o.prop}):m!==void 0?t.push({text:m,color:o.str}):g!==void 0?t.push({text:g,color:o.keyword}):k!==void 0&&t.push({text:k,color:o.prop}),i=n.lastIndex}return i<r.length&&t.push({text:r.slice(i)}),t}class Zo{constructor(o,t={}){Z(this,"transport");Z(this,"nextId",0);Z(this,"pending",new Map);Z(this,"eventListeners",new Set);Z(this,"requestTimeoutMs");Z(this,"unsubscribe");Z(this,"closed",!1);this.transport=o,this.requestTimeoutMs=t.requestTimeoutMs??3e5,this.unsubscribe=o.onFrame(n=>this.handleFrame(n))}request(o,t){if(this.closed)return Promise.reject(new Error("client is closed"));const n=this.nextId++,i=String(n);return new Promise((a,s)=>{const d=setTimeout(()=>{this.pending.delete(i),s(new Error(`request timed out: ${o}`))},this.requestTimeoutMs);this.pending.set(i,{resolve:a,reject:s,timer:d}),this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:n,method:o,params:t}})})}notify(o,t){this.closed||this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:null,method:o,params:t}})}onEvent(o){return this.eventListeners.add(o),()=>this.eventListeners.delete(o)}close(){if(!this.closed){this.closed=!0,this.unsubscribe();for(const[,o]of this.pending)clearTimeout(o.timer),o.reject(new Error("client closed"));this.pending.clear(),this.transport.close()}}handleFrame(o){if(o.type==="event"){for(const i of this.eventListeners)i(o.payload.event);return}if(o.type!=="response")return;const t=String(o.payload.id),n=this.pending.get(t);n&&(this.pending.delete(t),clearTimeout(n.timer),this.settle(n,o.payload))}settle(o,t){if(t.error){const n=new Error(`${t.error.message} (code ${t.error.code})`);t.error.data!==void 0&&(n.data=t.error.data),o.reject(n);return}o.resolve(t.result)}}const Pe="vagus.theme.v2",we=c.createContext(void 0);function to(){var r,o;return typeof window<"u"&&((o=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)"))==null?void 0:o.matches)===!0}function io(){const r=localStorage.getItem(Pe);return r==="light"||r==="dark"||r==="system"?r:"light"}function Xo({children:r}){const[o,t]=c.useState(io),[n,i]=c.useState(to),a=o==="system"?n?"dark":"light":o;c.useEffect(()=>{localStorage.setItem(Pe,o),document.documentElement.setAttribute("data-theme",a)},[o,a]),c.useEffect(()=>{if(o!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=p=>i(p.matches);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[o]);const s=c.useMemo(()=>({theme:a,preference:o,tokens:a==="light"?qe:Fe,setPreference:t,toggleTheme:()=>t(d=>d==="light"?"dark":"light")}),[a,o]);return e.jsx(we.Provider,{value:s,children:r})}function _(){const r=c.useContext(we);return r||{theme:"dark",preference:"dark",tokens:Fe,setPreference:()=>{},toggleTheme:()=>{}}}function re(){const r=c.useContext(we);return r?r.tokens:Fe}const Oe="vagus.appearance.v1",ee={uiFontSize:14,showLineNumbers:!0,wrapLongLines:!0,codeFontSize:12},He=c.createContext(void 0);function so(){try{const r=localStorage.getItem(Oe);if(r===null)return ee;const o=JSON.parse(r);return{uiFontSize:typeof o.uiFontSize=="number"?o.uiFontSize:ee.uiFontSize,showLineNumbers:typeof o.showLineNumbers=="boolean"?o.showLineNumbers:ee.showLineNumbers,wrapLongLines:typeof o.wrapLongLines=="boolean"?o.wrapLongLines:ee.wrapLongLines,codeFontSize:typeof o.codeFontSize=="number"?o.codeFontSize:ee.codeFontSize}}catch{return ee}}function Qo({children:r}){const[o,t]=c.useState(so);c.useEffect(()=>{localStorage.setItem(Oe,JSON.stringify(o))},[o]);const n=c.useMemo(()=>({...o,update:i=>t(a=>({...a,...i}))}),[o]);return e.jsx(He.Provider,{value:n,children:r})}function lo(){const r=c.useContext(He);return r||{...ee,update:()=>{}}}function ao({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"}),e.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),e.jsx("path",{d:"M8 21H3v-5"})]})}function uo({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),e.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),e.jsx("path",{d:"M12 22V12"})]})}function Me({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),e.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function co({size:r=13}){return e.jsx("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})}function po({size:r=15}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function go({size:r=15}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),e.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),e.jsx("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),e.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]})}function xo({size:r=13}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function Ke({size:r=13}){return e.jsx("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}function fo({providers:r,selectedId:o,adding:t,onSelect:n,onAdd:i,t:a}){const{theme:s}=_();return e.jsxs("div",{style:{width:220,flexShrink:0,borderRight:`1px solid ${a.color.border}`,padding:10,background:s==="light"?"#ffffff":a.color.surface},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 10px 6px"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:a.color.muted,letterSpacing:"0.04em"},children:"自定义供应商"}),e.jsx("button",{onClick:i,title:"添加供应商",onMouseEnter:d=>d.currentTarget.style.color=a.color.fg,onMouseLeave:d=>d.currentTarget.style.color=a.color.muted,style:{background:"transparent",border:"none",color:a.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Ke,{size:14})})]}),r.length===0&&!t&&e.jsx("div",{style:{fontSize:12,color:a.color.muted,padding:"8px 10px"},children:"暂无供应商"}),r.map(d=>{const f=o===d.id&&!t,p=d.enabled!==!1;return e.jsxs("div",{onClick:()=>n(d.id),onMouseEnter:m=>{f||(m.currentTarget.style.background=a.color.surface)},onMouseLeave:m=>{f||(m.currentTarget.style.background="transparent")},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:9,fontSize:13,color:a.color.fg,cursor:"pointer",transition:"background 0.15s",background:f?a.color.border:"transparent"},children:[e.jsx(uo,{size:14}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.id}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p?"#10B981":a.color.muted,flexShrink:0}})]},d.id)})]})}const Ae=[{value:"openai-completions",label:"OpenAI Completions (/v1/chat/completions)"},{value:"openai-responses",label:"OpenAI Responses (/v1/responses)"},{value:"anthropic-messages",label:"Anthropic Messages (/v1/messages)"},{value:"google-generative-ai",label:"Google Gemini (/v1beta/models)"}];function ho(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${Math.round(r/1e3)}K`:String(r)}function _e({value:r,onChange:o,t}){var d;const[n,i]=c.useState(!1),a=he(),s=((d=Ae.find(f=>f.value===r))==null?void 0:d.label)??r;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,background:a,border:`1px solid ${t.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,color:t.color.fg,cursor:"pointer"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),n&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:a,border:`1px solid ${t.color.border}`,borderRadius:10,padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.25)"},children:Ae.map(f=>{const p=f.value===r;return e.jsxs("button",{type:"button",onClick:()=>{o(f.value),i(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",border:"none",background:p?t.color.border:"transparent",color:t.color.fg,borderRadius:7,padding:"7px 10px",fontSize:12.5,cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:f.label}),p&&e.jsx("span",{style:{color:t.color.primary},children:"✓"})]},f.value)})})]})}function X({label:r,children:o}){const t=re();return e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,color:t.color.muted,marginBottom:6},children:r}),o]})}function ke({title:r,description:o,children:t}){const{theme:n}=_(),i=re(),a=n==="light"?"#ffffff":i.color.surface;return e.jsxs("div",{style:{marginBottom:30},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:i.color.fg,marginBottom:4},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:12,color:i.color.muted,marginBottom:10,lineHeight:1.5},children:o}),e.jsx("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:12,overflow:"hidden"},children:t})]})}function he(){const{theme:r}=_(),o=re();return r==="light"?"#ffffff":o.color.surface}function ue({label:r,hint:o,control:t,t:n,last:i=!1}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,padding:"13px 18px",borderBottom:i?"none":`1px solid ${n.color.border}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:13,color:n.color.fg},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:n.color.muted,marginTop:3,lineHeight:1.5},children:o})]}),e.jsx("div",{style:{flexShrink:0},children:t})]})}function mo({options:r,value:o,onChange:t,t:n}){return e.jsx("div",{style:{display:"inline-flex",background:n.color.bg,border:`1px solid ${n.color.border}`,borderRadius:9,padding:3,gap:2},children:r.map(i=>{const a=i.value===o;return e.jsx("button",{onClick:()=>t(i.value),style:{border:"none",background:a?n.color.surface:"transparent",color:a?n.color.fg:n.color.muted,borderRadius:6,padding:"5px 14px",fontSize:12.5,fontWeight:a?500:400,cursor:"pointer",transition:"all 0.15s",whiteSpace:"nowrap"},children:i.label},i.value)})})}function ze({checked:r,onChange:o,t}){return e.jsx("button",{role:"switch","aria-checked":r,onClick:()=>o(!r),style:{width:34,height:20,borderRadius:99,border:"none",cursor:"pointer",flexShrink:0,background:r?t.color.accent:t.color.border,position:"relative",transition:"background 0.15s"},children:e.jsx("span",{style:{position:"absolute",top:2,left:r?16:2,width:16,height:16,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.25)",transition:"left 0.15s"}})})}function Te({value:r,onChange:o,min:t=10,max:n=20,t:i}){const[a,s]=c.useState(String(r));c.useEffect(()=>{s(String(r))},[r]);const d=p=>{const m=p.trim();if(m===""){s(String(r));return}const g=Number(m);Number.isFinite(g)?o(Math.min(n,Math.max(t,Math.round(g)))):s(String(r))},f={width:26,height:30,border:"none",background:"transparent",color:i.color.muted,fontSize:15,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",border:`1px solid ${i.color.border}`,borderRadius:8,overflow:"hidden",background:i.color.bg},children:[e.jsx("button",{onClick:()=>o(Math.max(t,r-1)),style:f,"aria-label":"减小字号",children:"−"}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,onChange:p=>s(p.target.value.replace(/[^\d]/g,"")),onBlur:()=>d(a),onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()},"aria-label":"字号",style:{width:40,height:30,border:"none",outline:"none",textAlign:"center",background:"transparent",color:i.color.fg,fontSize:12.5}}),e.jsx("button",{onClick:()=>o(Math.min(n,r+1)),style:f,"aria-label":"增大字号",children:"+"}),e.jsx("span",{style:{paddingRight:10,fontSize:12,color:i.color.muted},children:"px"})]})}function bo({form:r,setForm:o,onAdd:t,canAdd:n,inputStyle:i,t:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:a.color.fg},children:"添加模型供应商"}),e.jsx("div",{style:{fontSize:12,color:a.color.muted,margin:"4px 0 20px"},children:"配置一个完全自定义的 API 端点和初始模型"}),e.jsx(X,{label:"名称",children:e.jsx("input",{style:i,placeholder:"如:openai",value:r.id,onChange:s=>o({...r,id:s.target.value})})}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:i,placeholder:"https://api.example.com/v1",value:r.baseUrl,onChange:s=>o({...r,baseUrl:s.target.value})})}),e.jsx(X,{label:"API Key",children:e.jsx("input",{style:i,type:"password",placeholder:"输入 API Key(可选)",value:r.apiKey,onChange:s=>o({...r,apiKey:s.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:r.api,onChange:s=>o({...r,api:s}),t:a})}),e.jsx("button",{onClick:t,disabled:!n,onMouseEnter:s=>{n&&(s.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:s=>{s.currentTarget.style.filter="none"},style:{width:"100%",background:n?a.color.primary:a.color.border,color:n?"#fff":a.color.muted,border:"none",borderRadius:10,padding:"11px 16px",fontSize:13.5,fontWeight:500,cursor:n?"pointer":"default",transition:"filter 0.15s"},children:"添加供应商"})]})}function Ue(r,o){return r==="light"?"#ffffff":o.color.surface}function yo({open:r,form:o,setForm:t,onAdd:n,onClose:i,inputStyle:a,t:s,onProbe:d,provider:f}){const{theme:p}=_(),[m,g]=c.useState("idle"),k=c.useRef(void 0);return r?e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:i,children:e.jsxs("div",{style:{background:Ue(p,s),border:`1px solid ${s.color.border}`,borderRadius:14,padding:22,width:400,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:C=>C.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:s.color.fg},children:"添加模型"}),e.jsx("div",{style:{fontSize:12,color:s.color.muted,margin:"4px 0 18px"},children:"配置模型的标识与参数,保存后可在聊天中选用。"}),e.jsx(X,{label:"模型 ID",children:e.jsx("input",{style:a,autoFocus:!0,placeholder:"如 gpt-4o(自动探测兼容配置)",value:o.id,onChange:C=>{const D=C.target.value;if(t(F=>({...F,id:D})),k.current!==void 0&&window.clearTimeout(k.current),d&&f&&D.trim()!==""){const F=D.trim();g("probing"),k.current=window.setTimeout(()=>{k.current=void 0,d({baseUrl:f.baseUrl,api:f.api,apiKey:f.apiKey,model:F}).then(h=>{h.ok&&h.compat?(t(j=>{var S;return j.id.trim()===F?{...j,compat:h.compat??void 0,reasoning:h.reasoning,vision:((S=h.input)==null?void 0:S.includes("image"))??j.vision}:j}),g("ok")):g("fail")}).catch(()=>g("fail"))},600)}else g("idle")},onKeyDown:C=>{C.key==="Enter"&&o.id.trim()!==""&&m!=="probing"&&n()}})}),(()=>{if(o.id.trim()!==""){if(m==="probing")return e.jsx("div",{style:{fontSize:11.5,color:"#6366f1",background:"rgba(99,102,241,0.08)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"正在自动探测模型能力…"});if(m==="ok")return e.jsx("div",{style:{fontSize:11.5,color:"#10B981",background:"rgba(16,185,129,0.1)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"✓ 自动探测完成:compat/图片/思考配置已自动填入"});if(m==="fail")return e.jsx("div",{style:{fontSize:11.5,color:"#E5484D",background:"rgba(229,72,77,0.08)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"自动探测失败 — 请检查 baseUrl / apiKey,或稍后重试"})}return null})(),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:s.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"2000000",value:o.contextWindow,onChange:C=>t({...o,contextWindow:C.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:s.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"131072",value:o.maxTokens,onChange:C=>t({...o,maxTokens:C.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,cursor:"pointer",fontSize:12.5,color:s.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:o.vision,onChange:C=>t({...o,vision:C.target.checked}),style:{width:15,height:15,accentColor:s.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:s.color.muted,fontSize:11},children:"(决定聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:20},children:[e.jsx("button",{onClick:i,style:{background:"transparent",border:`1px solid ${s.color.border}`,color:s.color.muted,borderRadius:8,padding:"7px 18px",fontSize:12.5,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:n,disabled:o.id.trim()===""||m==="probing",onMouseEnter:C=>{o.id.trim()!==""&&m!=="probing"&&(C.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:C=>{C.currentTarget.style.filter="none"},style:{background:s.color.primary,color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:o.id.trim()===""||m==="probing"?"not-allowed":"pointer",transition:"filter 0.15s",opacity:o.id.trim()===""||m==="probing"?.5:1},children:m==="probing"?"正在探测…":"添加"})]})]})}):null}function jo({confirmDeleteId:r,providers:o,onConfirm:t,onClose:n,t:i}){var s;const{theme:a}=_();return r===null?null:e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:n,children:e.jsxs("div",{style:{background:Ue(a,i),border:`1px solid ${i.color.border}`,borderRadius:14,padding:22,width:340,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:d=>d.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:i.color.fg},children:"删除供应商"}),e.jsxs("div",{style:{fontSize:12.5,color:i.color.muted,margin:"10px 0 22px",lineHeight:1.7},children:["确定删除供应商 ",e.jsxs("span",{style:{color:i.color.fg,fontWeight:500},children:["“",((s=o.find(d=>d.id===r))==null?void 0:s.id)??r,"”"]})," 吗?其下模型将一并移除,此操作不可撤销。"]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:n,style:{background:"transparent",border:`1px solid ${i.color.border}`,color:i.color.muted,borderRadius:8,padding:"7px 18px",fontSize:12.5,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:()=>{t(r),n()},onMouseEnter:d=>d.currentTarget.style.filter="brightness(1.15)",onMouseLeave:d=>d.currentTarget.style.filter="none",style:{background:"#E5484D",color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:"pointer",transition:"filter 0.15s"},children:"确认删除"})]})]})})}function vo({provider:r,detail:o,setDetail:t,showKey:n,setShowKey:i,testingId:a,testResult:s,editingModelId:d,modelForm:f,setModelForm:p,addModelOpen:m,addModelForm:g,setAddModelForm:k,confirmDeleteId:C,providers:D,onToggleEnabled:F,onDelete:h,onConfirmDelete:j,onTest:S,onAddModel:z,onRemoveModel:W,onStartEdit:E,onSaveEdit:I,onCancelEdit:O,onCancelDelete:l,onOpenAddModel:v,onCloseAddModel:B,inputStyle:A,t:x,onProbe:R}){const{theme:N}=_(),T=r,Y=N==="light"?"#ffffff":x.color.surface;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsx("input",{style:{...A,flex:1,minWidth:120,fontWeight:600,fontSize:14},value:o.id,onChange:b=>t({...o,id:b.target.value}),"aria-label":"供应商名称"}),e.jsxs("div",{style:{display:"inline-flex",background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:2,gap:2,flexShrink:0},children:[e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled!==!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled!==!1?"#10B981":"transparent",color:T.enabled!==!1?"#fff":x.color.muted,transition:"filter 0.15s"},children:"已启用"}),e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled===!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled===!1?x.color.fg:"transparent",color:T.enabled===!1?x.color.bg:x.color.muted,transition:"filter 0.15s"},children:"禁用"})]}),e.jsx("button",{onClick:h,title:"删除供应商",onMouseEnter:b=>{b.currentTarget.style.borderColor="#E5484D",b.currentTarget.style.color="#E5484D"},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:8,width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:e.jsx(Me,{})})]}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:A,placeholder:"https://api.example.com/v1",value:o.baseUrl,onChange:b=>t({...o,baseUrl:b.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:o.api,onChange:b=>t({...o,api:b}),t:x})}),e.jsx(X,{label:"API Key",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:{...A,flex:1},type:n?"text":"password",placeholder:"留空保持不变",value:o.apiKey,onChange:b=>t({...o,apiKey:b.target.value})}),e.jsx("button",{onClick:()=>i(!n),title:n?"隐藏":"显示",onMouseEnter:b=>b.currentTarget.style.color=x.color.fg,onMouseLeave:b=>b.currentTarget.style.color=x.color.muted,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:8,width:34,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:n?e.jsx(go,{}):e.jsx(po,{})})]})}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:x.color.fg,marginBottom:8},children:"模型列表"}),T.models.length===0&&e.jsx("div",{style:{fontSize:12,color:x.color.muted,marginBottom:10},children:"暂无模型 — 添加一个以在聊天中可用。"}),T.models.map(b=>e.jsxs("div",{children:[e.jsxs("div",{onMouseEnter:L=>L.currentTarget.style.background=x.color.border,onMouseLeave:L=>L.currentTarget.style.background=Y,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,background:Y,marginBottom:6,fontSize:13,transition:"background 0.15s"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name??b.id}),b.contextWindow!==void 0&&e.jsx("span",{style:{fontSize:11,color:x.color.fg,background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:"2px 8px",flexShrink:0},children:ho(b.contextWindow)}),a===b.id?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",style:{color:x.color.primary},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3",strokeDasharray:"40",strokeLinecap:"round",opacity:"0.35"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]}):e.jsx("span",{role:"button","aria-label":`测试 ${b.id}`,onClick:()=>S(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(xo,{size:13})}),e.jsx("span",{role:"button","aria-label":`编辑 ${b.id}`,onClick:()=>E(b),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(co,{size:13})}),e.jsx("span",{role:"button","aria-label":`删除模型 ${b.id}`,onClick:()=>W(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Me,{size:13})})]}),(s==null?void 0:s.modelId)===b.id&&e.jsx("div",{style:{marginBottom:8},children:s.ok?e.jsx("span",{style:{fontSize:12,color:"#10B981",background:"rgba(16,185,129,0.12)",borderRadius:6,padding:"3px 10px",display:"inline-block"},children:"连接成功!"}):e.jsx("span",{style:{fontSize:12,color:"#E5484D",background:"rgba(229,72,77,0.1)",borderRadius:6,padding:"3px 10px",display:"inline-block"},children:s.status===0?"无法连接":s.reason==="auth"?"认证失败":s.reason==="model"?"模型不存在":`连接失败 (HTTP ${s.status})`})}),d===b.id&&e.jsxs("div",{style:{background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:8,padding:"10px 12px",marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:x.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"128000",value:f.contextWindow,onChange:L=>p({...f,contextWindow:L.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:x.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"8192",value:f.maxTokens,onChange:L=>p({...f,maxTokens:L.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:12,cursor:"pointer",fontSize:12.5,color:x.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:f.vision,onChange:L=>p({...f,vision:L.target.checked}),style:{width:15,height:15,accentColor:x.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:x.color.muted,fontSize:11},children:"(聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:10},children:[e.jsx("button",{onClick:O,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:7,padding:"5px 14px",fontSize:12,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:I,style:{background:x.color.primary,color:"#fff",border:"none",borderRadius:7,padding:"5px 14px",fontSize:12,fontWeight:500,cursor:"pointer"},children:"保存"})]})]})]},b.id)),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:12},children:e.jsxs("button",{onClick:v,onMouseEnter:b=>{b.currentTarget.style.borderColor=x.color.fg,b.currentTarget.style.color=x.color.fg},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px dashed ${x.color.border}`,color:x.color.muted,borderRadius:9,padding:"8px 18px",fontSize:12.5,cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"all 0.15s"},children:[e.jsx(Ke,{size:13})," 添加模型"]})}),e.jsx(yo,{open:m,form:g,setForm:k,onAdd:z,onClose:B,inputStyle:A,t:x,onProbe:R,provider:r}),e.jsx(jo,{confirmDeleteId:C,providers:D,onConfirm:j,onClose:l,t:x})]})}function ko({providers:r,inputStyle:o,t,onSave:n,onRefresh:i,onTest:a,onProbe:s}){const[d,f]=c.useState(null),[p,m]=c.useState(!1),[g,k]=c.useState({id:"",baseUrl:"",api:"openai-completions",apiKey:""}),[C,D]=c.useState(!1),[F,h]=c.useState({id:"",baseUrl:"",apiKey:"",api:"openai-completions"}),[j,S]=c.useState(!1),[z,W]=c.useState({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),[E,I]=c.useState(null),[O,l]=c.useState(null),[v,B]=c.useState(null),[A,x]=c.useState({contextWindow:"",maxTokens:"",vision:!0}),[R,N]=c.useState(void 0),T=d!==null&&!p?r.find(y=>y.id===d)??null:null,Y=y=>{const M=r.find(P=>P.id===y);if(!M)return;f(y),m(!1),B(null),N(void 0);const H={id:M.id,baseUrl:M.baseUrl,api:M.api,apiKey:M.apiKey??""};U.current=JSON.stringify(H),k(H)},b=()=>{m(!0),f(null),B(null),h({id:"",baseUrl:"",apiKey:"",api:"openai-completions"})},L=()=>{const y=F.id.trim(),M=F.baseUrl.trim();if(!y||!M)return;n([...r,{id:y,baseUrl:M,api:F.api,apiKey:F.apiKey.trim()||void 0,models:[]}]);const H={id:y,baseUrl:M,api:F.api,apiKey:F.apiKey};U.current=JSON.stringify(H),m(!1),f(y),k(H)},Q=y=>{n(r.filter(M=>M.id!==y)),d===y&&(f(null),U.current="",k({id:"",baseUrl:"",api:"openai-completions",apiKey:""}))};c.useEffect(()=>{if(!p&&d===null&&r.length>0){const y=r[0];y!==void 0&&Y(y.id)}},[p,r.length,d]);const U=c.useRef("");c.useEffect(()=>{if(d===null||!r.find(P=>P.id===d))return;const M=JSON.stringify(g);if(M===U.current)return;const H=window.setTimeout(()=>{(async()=>{const P=g.id.trim(),je=g.baseUrl.trim();P&&(U.current=M,await n(r.map(te=>te.id===d?{...te,id:P,baseUrl:je||te.baseUrl,api:g.api,apiKey:g.apiKey.trim()!==""?g.apiKey.trim():te.apiKey}:te)),P!==d&&f(P))})()},700);return()=>window.clearTimeout(H)},[g,d]);const ce=()=>{T&&n(r.map(y=>y.id===T.id?{...y,enabled:y.enabled===!1}:y))},ae=async y=>{if(!T)return;l(y),N(void 0);const M=await a({baseUrl:g.baseUrl.trim()||T.baseUrl,api:g.api||T.api,apiKey:g.apiKey.trim()||T.apiKey,model:y});N({modelId:y,...M}),l(null)},me=()=>{if(!T)return;const y=z.id.trim();if(!y)return;const M=z.compat,H=z.reasoning;n(r.map(P=>P.id===T.id?{...P,models:[...P.models,{id:y,contextWindow:z.contextWindow!==""?Number(z.contextWindow):void 0,maxTokens:z.maxTokens!==""?Number(z.maxTokens):void 0,input:z.vision?["text","image"]:["text"],...H!==void 0?{reasoning:H}:{},...M?{compat:M}:{}}]}:P)),S(!1)},ne=y=>{T&&(n(r.map(M=>M.id===T.id?{...M,models:M.models.filter(H=>H.id!==y)}:M)),v===y&&B(null))},be=y=>{var M;B(y.id),x({contextWindow:y.contextWindow!==void 0?String(y.contextWindow):"",maxTokens:y.maxTokens!==void 0?String(y.maxTokens):"",vision:((M=y.input)==null?void 0:M.includes("image"))??!0})},ye=()=>{!T||v===null||(n(r.map(y=>y.id===T.id?{...y,models:y.models.map(M=>M.id===v?{...M,contextWindow:A.contextWindow!==""?Number(A.contextWindow):void 0,maxTokens:A.maxTokens!==""?Number(A.maxTokens):void 0,input:A.vision?["text","image"]:["text"]}:M)}:y)),B(null))},pe=F.id.trim()!==""&&F.baseUrl.trim()!=="";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",marginBottom:20},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:t.color.fg},children:"模型设置"}),e.jsx("div",{style:{fontSize:13,color:t.color.muted,margin:"4px 0 0"},children:"管理自定义模型供应商,配置后可在聊天时选择使用。"})]}),e.jsx("button",{onClick:i,title:"刷新配置",style:{background:"transparent",border:`1px solid ${t.color.border}`,color:t.color.muted,borderRadius:8,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:e.jsx(ao,{})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${t.color.border}`,borderRadius:14,overflow:"hidden",background:t.color.bg},children:[e.jsx(fo,{providers:r,selectedId:d,adding:p,onSelect:Y,onAdd:b,t}),e.jsx("div",{style:{flex:1,padding:"22px 24px",minWidth:0},children:!p&&T!==null?e.jsx(vo,{provider:T,detail:g,setDetail:k,showKey:C,setShowKey:D,testingId:O,testResult:R,editingModelId:v,modelForm:A,setModelForm:x,addModelOpen:j,addModelForm:z,setAddModelForm:W,confirmDeleteId:E,providers:r,onToggleEnabled:ce,onDelete:()=>I(d),onConfirmDelete:y=>Q(y),onTest:ae,onAddModel:me,onRemoveModel:ne,onStartEdit:be,onSaveEdit:ye,onCancelEdit:()=>B(null),onCancelDelete:()=>I(null),onOpenAddModel:()=>{W({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),S(!0)},onCloseAddModel:()=>S(!1),inputStyle:o,t,onProbe:s}):e.jsx(bo,{form:F,setForm:h,onAdd:L,canAdd:pe,inputStyle:o,t})})]})]})}const So=["const themePreview: ThemeConfig = {",' surface: "sidebar",',' accent: "#339CFF",'," contrast: 45,","};"];function Le({title:r,themeName:o,dark:t,active:n,showLineNumbers:i,codeFontSize:a,t:s}){const d=ro(o),f=n?"当前生效":t?"深色":"浅色";return e.jsxs("div",{style:{flex:"1 1 300px",background:d.bg,border:`1px solid ${d.border}`,borderRadius:12,overflow:"hidden",boxShadow:n?`0 0 0 1.5px ${s.color.accent}`:"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:d.header,borderBottom:`1px solid ${d.border}`},children:[e.jsx("span",{style:{fontSize:12,color:d.text,opacity:.85},children:r}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,color:d.text,opacity:.6},children:o}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:n?"#fff":d.text,background:n?s.color.accent:"transparent",border:n?"none":`1px solid ${d.border}`,borderRadius:99,padding:"2px 10px"},children:f})]})]}),e.jsx("div",{style:{padding:"12px 0 14px",fontSize:a,lineHeight:1.65,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:d.text},children:So.map((p,m)=>e.jsxs("div",{style:{display:"flex",paddingLeft:16,paddingRight:16},children:[i&&e.jsx("span",{style:{width:26,flexShrink:0,textAlign:"right",marginRight:14,color:d.text,opacity:.35,userSelect:"none"},children:m+1}),e.jsx("span",{style:{whiteSpace:"pre"},children:no(p,d).map((g,k)=>g.color!==void 0?e.jsx("span",{style:{color:g.color},children:g.text},k):g.text)})]},m))})]})}function Fo({draft:r,onChange:o,t}){const{theme:n,preference:i,setPreference:a}=_();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:t.color.fg},children:"外观"}),e.jsxs("div",{style:{marginTop:24},children:[e.jsxs(ke,{title:"界面设置",description:"设置应用主题和界面文字大小。",children:[e.jsx(ue,{label:"界面主题",hint:"选择浅色、深色或跟随系统主题。",control:e.jsx(mo,{options:[{value:"light",label:"浅色"},{value:"dark",label:"深色"},{value:"system",label:"跟随系统"}],value:i,onChange:a,t}),t}),e.jsx(ue,{label:"界面字号",hint:"调整应用界面的文字大小,图标和布局尺寸不受影响。",last:!0,control:e.jsx(Te,{value:r.uiFontSize,onChange:s=>o({uiFontSize:s}),t}),t})]}),e.jsxs(ke,{title:"代码设置",description:"设置代码内容的主题、字号和显示方式,不受界面字号影响。",children:[e.jsx(ue,{label:"显示行号",hint:"在代码内容和差异视图中显示行号。",control:e.jsx(ze,{checked:r.showLineNumbers,onChange:s=>o({showLineNumbers:s}),t}),t}),e.jsx(ue,{label:"长行自动换行",hint:"代码内容过长时自动换行。",control:e.jsx(ze,{checked:r.wrapLongLines,onChange:s=>o({wrapLongLines:s}),t}),t}),e.jsx(ue,{label:"代码字号",hint:"调整代码块、文件预览和差异视图的默认字号。",last:!0,control:e.jsx(Te,{value:r.codeFontSize,onChange:s=>o({codeFontSize:s}),min:10,max:24,t}),t})]}),e.jsx(ke,{title:"代码预览",description:"同时预览浅色与深色代码主题,当前界面使用的主题会标记为“当前生效”。",children:e.jsxs("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:18},children:[e.jsx(Le,{title:"浅色预览",themeName:"GitHub Light",dark:!1,active:n==="light",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t}),e.jsx(Le,{title:"深色预览",themeName:"GitHub Dark",dark:!0,active:n==="dark",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t})]})})]})]})}const oe=864e5,Ie=["#6366F1","#22D3EE","#FBBF24","#F472B6","#34D399","#A78BFA","#F87171","#60A5FA"],wo=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],Co=["#272b33","#0e4429","#006d32","#26a641","#39d353"];function le(r){return r>=1e9?`${(r/1e9).toFixed(2)}G`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(Math.round(r))}function Je(r){return r>=1e3?`$${(r/1e3).toFixed(2)}K`:r>=100?`$${r.toFixed(1)}`:`$${r.toFixed(2)}`}function We(r){return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Bo(r){const o=[...new Set(r.map(s=>Math.floor(s.ts/oe)))].toSorted((s,d)=>s-d);let t=0,n=0;for(let s=0;s<o.length;s++)n=s===0||o[s]===(o[s-1]??0)+1?n+1:1,n>t&&(t=n);const i=Math.floor(Date.now()/oe);let a=0;for(let s=o.length-1;s>=0&&o[s]===i-a;s--)a++;return{current:a,longest:t}}function Eo(r){const o=new Map;for(const t of r)for(const[n,i]of Object.entries(t.byModel))o.set(n,(o.get(n)??0)+i);return[...o.entries()].map(([t,n])=>({model:t,tokens:n})).toSorted((t,n)=>n.tokens-t.tokens)}function se({label:r,value:o,sub:t,accent:n}){const i=re(),a=he();return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:"18px 20px",display:"flex",flexDirection:"column",gap:6},children:[e.jsx("div",{style:{fontSize:12,color:i.color.muted,fontWeight:500},children:r}),e.jsx("div",{style:{fontSize:26,fontWeight:700,color:n??i.color.fg,letterSpacing:"-0.02em",fontVariantNumeric:"tabular-nums"},children:o}),t!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:i.color.muted},children:t})]})}function Do({daily:r}){const o=re(),{theme:t}=_(),[n,i]=c.useState(null),a=t==="light"?wo:Co,s=new Date;s.setHours(0,0,0,0);const d=s.getTime(),f=d-52*7*oe,p=new Map,m=new Map,g=Math.max(...r.map(l=>l.tokens),0),k=g>0?Math.log2(g):1;for(const l of r){const v=We(new Date(l.ts)),B=l.tokens===0?0:Math.max(1,Math.min(4,Math.round(Math.log2(l.tokens)/k*4)));p.set(v,B),m.set(v,l.tokens)}const C=new Date(f),D=new Date(C);D.setDate(D.getDate()-(C.getDay()+6)%7);const F=D.getTime(),h=[];for(let l=0;F+l*7*oe<d+oe;l++)h.push(F+l*7*oe);const j=13,S=3,z=20,W=h.length*(j+S),E=7*(j+S)+z,I=["","Mon","","Wed","","Fri",""],O=[];{let l=-1,v=0;for(let B=0;B<h.length;B++){const A=h[B];if(A===void 0)continue;const x=new Date(A),R=x.getFullYear()*100+x.getMonth();if(R!==l){if(l!==-1){const N=B*(j+S)-v;O.push({x:v+N/2,label:`${l%100+1}月`})}l=R,v=B*(j+S)}}if(l!==-1){const B=h.length*(j+S)-v;O.push({x:v+B/2,label:`${l%100+1}月`})}}return e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",position:"relative"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:S,paddingTop:14},children:I.map((l,v)=>e.jsx("div",{style:{height:j,lineHeight:`${j}px`,fontSize:9,color:o.color.muted,textAlign:"right",paddingRight:4},children:l},v))}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("svg",{viewBox:`0 0 ${W} ${E}`,width:"100%",preserveAspectRatio:"xMinYMin meet",style:{display:"block"},children:[h.map((l,v)=>Array.from({length:7},(B,A)=>{const x=new Date(new Date(l).getTime()+A*oe),R=We(x),N=x.getTime()>d,T=N?0:p.get(R)??0,Y=a[T]??a[0],b=v*(j+S),L=A*(j+S),Q=N?0:m.get(R)??0;return e.jsx("rect",{x:b,y:L,width:j,height:j,rx:2.5,fill:Y,onMouseMove:U=>{N||i({x:U.clientX,y:U.clientY,date:R,tokens:Q})},onMouseLeave:()=>i(null)},R)})),O.map((l,v)=>e.jsx("text",{x:l.x,y:7*(j+S)+z-4,fontSize:9,fill:o.color.muted,textAnchor:"middle",children:l.label},`${l.label}-${v}`))]})}),n!==null&&e.jsxs("div",{style:{position:"fixed",left:n.x+12,top:n.y+12,zIndex:200,pointerEvents:"none",background:o.color.surface,border:`1px solid ${o.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:o.color.fg,minWidth:110},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:n.date}),e.jsx("div",{style:{color:o.color.muted},children:n.tokens>0?`${le(n.tokens)} tokens`:"无活跃"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,alignSelf:"flex-end",fontSize:10,color:o.color.muted},children:[e.jsx("span",{children:"较少"}),a.map(l=>e.jsx("span",{style:{width:10,height:10,borderRadius:2,background:l,display:"inline-block"}},l)),e.jsx("span",{children:"较多"})]})]})}function $e({title:r,rows:o,total:t,mode:n}){const i=re(),a=he(),s=o.slice(0,6),d=o.slice(6).reduce((p,m)=>p+m.value,0),f=d>0?[...s,{model:"其他",value:d}]:s;return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:i.color.fg,marginBottom:16},children:r}),f.length===0?e.jsx("div",{style:{fontSize:12,color:i.color.muted,padding:"8px 0"},children:"暂无数据。"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:13},children:f.map((p,m)=>{const g=t>0?p.value/t*100:0,k=Ie[m%Ie.length],C=p.model==="其他",[D,F]=C?[void 0,"其他"]:p.model.split("/");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:9,height:9,borderRadius:3,background:k,flexShrink:0}}),e.jsxs("span",{style:{flex:1,fontSize:13,color:i.color.fg,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[D!==void 0&&e.jsxs("span",{style:{color:i.color.muted},children:[D,"/"]}),F]}),e.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:i.color.fg,fontVariantNumeric:"tabular-nums"},children:n==="cost"?Je(p.value):le(p.value)}),e.jsxs("span",{style:{width:44,fontSize:11,color:i.color.muted,textAlign:"right"},children:[g.toFixed(1),"%"]})]}),e.jsx("div",{style:{height:5,borderRadius:3,background:i.color.border,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${Math.max(1,g)}%`,background:k,borderRadius:3}})})]},p.model)})})]})}function Mo({stats:r,t:o}){const t=he(),n=c.useMemo(()=>(r==null?void 0:r.daily)??[],[r]),i=n.reduce((E,I)=>E+I.tokens,0),a=(r==null?void 0:r.totalCost)??0,s=(r==null?void 0:r.sessionCount)??n.reduce((E,I)=>E+I.sessions,0),d=(r==null?void 0:r.messageCount)??n.reduce((E,I)=>E+I.messages,0),f=n.length,p=(r==null?void 0:r.peakTokens)??0,m=(r==null?void 0:r.maxDurationMs)??0,g=c.useMemo(()=>Bo(n),[n]),k=c.useMemo(()=>Eo(n),[n]),C=n.length>0?n[0]:void 0,D=n.length>0?n[n.length-1]:void 0,F=C!==void 0?new Date(C.ts):null,h=D!==void 0?new Date(D.ts):null,j=f>0?i/f:0,S=m>0?(m/36e5).toFixed(1):"—",z=c.useMemo(()=>((r==null?void 0:r.perModel)??[]).map(E=>({model:E.model,value:E.cost})).toSorted((E,I)=>I.value-E.value),[r]),W=z.reduce((E,I)=>E+I.value,0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:22},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[e.jsx("span",{style:{fontSize:20,fontWeight:600,color:o.color.fg},children:"使用统计"}),e.jsx("span",{style:{fontSize:13,color:o.color.muted,borderBottom:`2px solid ${o.color.primary}`,paddingBottom:2},children:"应用用量"})]})}),r===null?e.jsx("div",{style:{color:o.color.muted,fontSize:13,padding:"60px 0",textAlign:"center"},children:"加载中…"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:14},children:[e.jsx(se,{label:"Tokens 总用量",value:le(i),sub:"input + output(不含缓存复读)"}),e.jsx(se,{label:"总花费",value:Je(a),accent:"#F472B6",sub:j>0?`日均 ${le(j)} tokens`:void 0}),e.jsx(se,{label:"峰值单会话",value:le(p),sub:S!=="—"?`最长会话 ${S} 小时`:"暂无"}),e.jsx(se,{label:"会话数",value:String(s)}),e.jsx(se,{label:"消息数",value:String(d)}),e.jsx(se,{label:"活跃天数",value:String(f),sub:F!==null?`自 ${F.getFullYear()}年${F.getMonth()+1}月起`:"暂无数据"})]}),e.jsxs("div",{style:{background:t,border:`1px solid ${o.color.border}`,borderRadius:14,padding:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:o.color.fg},children:"活跃热力图"}),e.jsx("div",{style:{fontSize:12,color:o.color.muted},children:i>0?`累计 ${le(i)} tokens · 当前连击 ${g.current} 天`:"暂无活跃数据"})]}),n.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"暂无活跃数据。"}):e.jsx(Do,{daily:n})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(340px, 1fr))",gap:16},children:[e.jsx($e,{title:"模型用量(Token 占比)",rows:k.map(E=>({model:E.model,value:E.tokens})),total:i,mode:"tokens"}),e.jsx($e,{title:"模型花费(USD 占比)",rows:z,total:W,mode:"cost"})]}),e.jsxs("div",{style:{display:"flex",gap:28,fontSize:12,color:o.color.muted,paddingTop:4,flexWrap:"wrap"},children:[e.jsxs("span",{children:["最长连击 ",e.jsx("b",{style:{color:o.color.fg},children:g.longest})," 天"]}),e.jsxs("span",{children:["最近活跃 ",e.jsx("b",{style:{color:o.color.fg},children:h!==null?`${h.getMonth()+1}月${h.getDate()}日`:"—"})]}),F!==null&&e.jsxs("span",{children:["起始于 ",e.jsxs("b",{style:{color:o.color.fg},children:[F.getFullYear(),"年",F.getMonth()+1,"月",F.getDate(),"日"]})]})]})]})]})}const Ao=`
|
|
2
|
+
@keyframes vagus-fade-up {
|
|
3
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
4
|
+
to { opacity: 1; transform: translateY(0); }
|
|
5
|
+
}
|
|
6
|
+
@keyframes vagus-pop {
|
|
7
|
+
0% { opacity: 0; transform: scale(0.96); }
|
|
8
|
+
60% { opacity: 1; transform: scale(1.01); }
|
|
9
|
+
100% { opacity: 1; transform: scale(1); }
|
|
10
|
+
}
|
|
11
|
+
@keyframes vagus-shimmer {
|
|
12
|
+
0% { background-position: -400px 0; }
|
|
13
|
+
100% { background-position: 400px 0; }
|
|
14
|
+
}
|
|
15
|
+
@keyframes vagus-pulse {
|
|
16
|
+
0%, 100% { opacity: 1; }
|
|
17
|
+
50% { opacity: 0.35; }
|
|
18
|
+
}
|
|
19
|
+
@keyframes vagus-spin {
|
|
20
|
+
to { transform: rotate(360deg); }
|
|
21
|
+
}
|
|
22
|
+
.vagus-mcp-input:focus { border-color: var(--vagus-focus, #4f8cff) !important; box-shadow: 0 0 0 3px var(--vagus-focus-ring, rgba(79,140,255,0.18)) !important; }
|
|
23
|
+
.vagus-mcp-btn-press:active { transform: scale(0.96); }
|
|
24
|
+
.vagus-mcp-lift { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease; }
|
|
25
|
+
.vagus-mcp-lift:hover { transform: translateY(-1px); }
|
|
26
|
+
`;function zo(r){if(typeof r.command=="string"){const o=Array.isArray(r.args)?r.args.join(" "):"";return`${r.command}${o?" "+o:""}`}return typeof r.url=="string"?r.url:JSON.stringify(r).slice(0,80)}function To(r){return r.type==="http"||typeof r.url=="string"?{label:"HTTP",color:"#3fb950"}:{label:"STDIO",color:"#4f8cff"}}function Lo(){return e.jsx("svg",{width:"52",height:"52",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22v-5M9 8V2M15 8V2M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8h12z"})})}function Io(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})})}function Re(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}function Wo(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}function $o(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Ro(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"7",rx:"2"}),e.jsx("rect",{x:"3",y:"13",width:"18",height:"7",rx:"2"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"})]})}function No(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"}),e.jsx("path",{d:"M19 15l.9 2.1L22 18l-2.1.9L19 21l-.9-2.1L16 18l2.1-.9L19 15z"})]})}function Po(r){const o=/("(?:[^"\\]|\\.)*"(?=\s*:))|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(true|false|null)|([\]{}[,:])/g,t=[];let n=0,i=0,a;for(;(a=o.exec(r))!==null;){a.index>n&&t.push(r.slice(n,a.index));const[s,d,f,p,m]=a;let g="#8b90a0";d?g="#79c0ff":f?g="#7ee787":p?g="#e3b341":m&&(g="#d2a8ff"),t.push(e.jsx("span",{style:{color:g},children:s},i++)),n=a.index+s.length}return n<r.length&&t.push(r.slice(n)),t}function Ve({request:r,t:o}){const{theme:t}=_(),n=t!=="light",[i,a]=c.useState([]),[s,d]=c.useState(!0),[f,p]=c.useState(null),[m,g]=c.useState(!1),[k,C]=c.useState(null),[D,F]=c.useState("form"),[h,j]=c.useState(""),[S,z]=c.useState("stdio"),[W,E]=c.useState(""),[I,O]=c.useState(""),[l,v]=c.useState("30000"),[B,A]=c.useState(""),[x,R]=c.useState(""),[N,T]=c.useState(""),[Y,b]=c.useState(null),[L,Q]=c.useState(null),[U,ce]=c.useState(!1),ae=o.color.primary,me=n?`${ae}33`:`${ae}22`,ne=n?"0 1px 2px rgba(0,0,0,0.25), 0 6px 20px rgba(0,0,0,0.18)":"0 1px 2px rgba(15,23,42,0.04), 0 6px 20px rgba(15,23,42,0.06)",be=n?"radial-gradient(120% 180% at 85% -20%, rgba(79,140,255,0.22), transparent 55%), radial-gradient(100% 160% at 10% -30%, rgba(121,192,255,0.12), transparent 50%)":"radial-gradient(120% 180% at 85% -20%, rgba(37,99,235,0.10), transparent 55%), radial-gradient(100% 160% at 10% -30%, rgba(59,130,246,0.06), transparent 50%)",ye=n?"linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 37%, rgba(255,255,255,0.04) 63%)":"linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.09) 37%, rgba(0,0,0,0.04) 63%)",pe=c.useCallback(async()=>Promise.resolve(!0),[]);c.useEffect(()=>{pe()},[pe]);const y=c.useCallback(async()=>{d(!0);try{const u=await r("mcp.list");a(u),p(null)}catch(u){p(u instanceof Error?u.message:"加载失败")}finally{d(!1)}},[r]);c.useEffect(()=>{y()},[y]);const M=async()=>{if(p(null),D==="json"){let u;try{u=JSON.parse(N)}catch{p("JSON 格式无效");return}const w=u,K=w.mcpServers??w,J=Object.entries(K);if(J.length===0){p("未找到服务器配置");return}for(const[V,$]of J){const De=await r(k?"mcp.update":"mcp.add",{name:V,config:typeof $=="object"&&$!==null?$:{}});if(!De.ok){p(`「${V}」${De.error??(k?"更新失败":"添加失败")}`);return}}T("")}else{if(!h.trim()){p("请输入名称");return}if(S==="stdio"&&!W.trim()){p("请输入命令");return}if(S==="http"&&!x.trim()){p("请输入 URL");return}let u;if(B.trim())try{u=JSON.parse(B)}catch{p("环境变量 JSON 格式无效");return}const w=Number.parseInt(l,10),K=S==="stdio"?{command:W.trim(),args:I.split(/\s+/).map($=>$.trim()).filter(Boolean),...w>0?{timeout:w}:{},...u?{env:u}:{}}:{type:"http",url:x.trim(),...w>0?{timeout:w}:{}},V=await r(k?"mcp.update":"mcp.add",{name:h.trim(),config:K});if(!V.ok){p(V.error??(k?"更新失败":"添加失败"));return}j(""),E(""),O(""),R(""),A("")}g(!1),C(null),await y(),r("session.reload",{})},H=u=>{C(u),g(!0),F("form"),p(null),j(u.name);const w=u.config,K=w.type==="http"||typeof w.url=="string";z(K?"http":"stdio"),K?(R(typeof w.url=="string"?w.url:""),E(""),O("")):(E(typeof w.command=="string"?w.command:""),O(Array.isArray(w.args)?w.args.join(" "):""),R("")),v(typeof w.timeout=="number"?String(w.timeout):"30000"),A(w.env&&typeof w.env=="object"&&Object.keys(w.env).length>0?JSON.stringify(w.env,null,2):""),T(JSON.stringify({[u.name]:w},null,2))},P=()=>{g(!1),C(null),p(null)},je=async u=>{Q(u);try{const w=await r("mcp.remove",{name:u});if(!w.ok){p(w.error??"移除失败"),Q(null);return}await y(),r("session.reload",{})}catch(w){p(w instanceof Error?w.message:"移除失败")}finally{Q(null)}},Ce=(()=>{if(S==="stdio"){if(!W.trim())return null;let w;if(B.trim())try{w=JSON.parse(B)}catch{return null}const K=Number.parseInt(l,10);return{command:W.trim(),args:I.split(/\s+/).map(J=>J.trim()).filter(Boolean),...K>0?{timeout:K}:{},...w?{env:w}:{}}}if(!x.trim())return null;const u=Number.parseInt(l,10);return{type:"http",url:x.trim(),...u>0?{timeout:u}:{}}})(),de=D==="json"?N.trim()?N:null:Ce===null?null:JSON.stringify({[h.trim()||"server-name"]:Ce},null,2),Ye=async()=>{if(de!==null)try{await navigator.clipboard.writeText(de),ce(!0),setTimeout(()=>ce(!1),1600)}catch{}},ie={width:"100%",background:n?o.color.bg:"#ffffff",border:`1px solid ${o.color.border}`,borderRadius:10,padding:"9px 12px",fontSize:13,outline:"none",color:o.color.fg,fontFamily:"inherit",boxSizing:"border-box",transition:"border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease"},Be={...ie,fontFamily:"monospace",fontSize:12,minHeight:160,resize:"vertical",lineHeight:1.6,background:o.color.bg},q={fontSize:12,fontWeight:600,color:o.color.fg,marginBottom:6,display:"block",letterSpacing:"0.01em"},ge={fontSize:11,color:o.color.muted,marginTop:6,lineHeight:1.5},G={marginBottom:18},Ee={borderRadius:10,padding:"9px 18px",fontSize:13,cursor:"pointer",fontWeight:600,background:`linear-gradient(180deg, ${o.color.primary}, ${n?"#3d74e0":"#1d4fd7"})`,color:"#fff",border:"none",display:"inline-flex",alignItems:"center",gap:7,boxShadow:n?"0 1px 0 rgba(255,255,255,0.12) inset, 0 2px 8px rgba(79,140,255,0.35)":"0 1px 0 rgba(255,255,255,0.5) inset, 0 2px 8px rgba(37,99,235,0.28)",transition:"filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease"},ve={borderRadius:10,padding:"9px 16px",fontSize:13,cursor:"pointer",fontWeight:500,background:n?o.color.surface:"#ffffff",color:o.color.fg,border:`1px solid ${o.color.border}`,display:"inline-flex",alignItems:"center",gap:6,transition:"background 0.15s ease, border-color 0.15s ease"},Ge={...ve,color:o.color.muted,border:"none",background:"transparent",padding:"6px 10px",borderRadius:8};return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("style",{children:Ao}),e.jsx("div",{style:{position:"relative",background:be,border:`1px solid ${o.color.border}`,borderRadius:14,padding:"22px 24px",marginBottom:24,overflow:"hidden"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:11,flexShrink:0,background:`linear-gradient(135deg, ${o.color.primary}22, ${o.color.accent}11)`,border:`1px solid ${o.color.primary}30`,display:"flex",alignItems:"center",justifyContent:"center",color:o.color.primary},children:e.jsx(Ro,{})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:19,fontWeight:650,color:o.color.fg,letterSpacing:"-0.01em"},children:"MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,marginTop:3,lineHeight:1.5},children:"连接 Model Context Protocol 服务器,扩展 AI 助手的能力"})]})]})}),s&&e.jsx("div",{style:{fontSize:13,color:o.color.muted,padding:40,textAlign:"center"},children:e.jsx("span",{style:{display:"inline-block",animation:"vagus-pulse 1.4s ease-in-out infinite"},children:"加载 MCP 配置…"})}),!s&&e.jsxs(e.Fragment,{children:[!m&&e.jsxs("div",{style:{animation:"vagus-fade-up 0.35s ease both"},children:[f&&e.jsxs("div",{style:{fontSize:13,color:"#e5484d",background:n?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)",border:`1px solid ${n?"rgba(248,81,73,0.25)":"rgba(220,38,38,0.2)"}`,borderRadius:10,padding:"9px 14px",marginBottom:16,display:"flex",alignItems:"center",gap:9,animation:"vagus-pop 0.25s ease both"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01",stroke:"#fff",strokeWidth:"2",fill:"none"})]}),f]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:o.color.success,display:"inline-block",animation:"vagus-pulse 2.5s ease-in-out infinite"}}),e.jsxs("span",{style:{fontSize:13,color:o.color.muted},children:[i.length," 个服务器已配置"]})]})}),e.jsxs("button",{onClick:()=>g(!0),className:"vagus-mcp-btn-press",style:Ee,onMouseEnter:u=>{u.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:u=>{u.currentTarget.style.filter="none"},children:[e.jsx(Re,{})," 新建 MCP 服务器"]})]}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[0,1,2].map(u=>e.jsx("div",{style:{height:62,borderRadius:12,background:ye,backgroundSize:"800px 100%",animation:"vagus-shimmer 1.6s linear infinite",border:`1px solid ${o.color.border}`}},u))}),!s&&i.length===0&&e.jsxs("div",{style:{padding:56,textAlign:"center",border:`1.5px dashed ${o.color.border}`,borderRadius:16,animation:"vagus-fade-up 0.35s ease both"},children:[e.jsx("div",{style:{color:o.color.muted,marginBottom:14,opacity:.8},children:e.jsx(Lo,{})}),e.jsx("div",{style:{fontSize:15,fontWeight:600,color:o.color.fg,marginBottom:6},children:"还没有配置 MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,lineHeight:1.6},children:"添加一台服务器,让 AI 助手获得新的能力"})]}),!s&&i.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:i.map((u,w)=>{const K=To(u.config),J=Y===u.name,V=L===u.name;return e.jsxs("div",{onMouseEnter:()=>b(u.name),onMouseLeave:()=>b(null),className:"vagus-mcp-lift",style:{display:"flex",alignItems:"center",gap:14,background:J?n?"rgba(255,255,255,0.03)":"#fbfcfe":o.color.surface,border:`1px solid ${J?o.color.primary+"55":o.color.border}`,borderRadius:13,padding:"13px 16px",boxShadow:J?ne:"none",opacity:V?.45:1,transition:"opacity 0.2s ease",animation:"vagus-fade-up 0.35s ease both",animationDelay:`${Math.min(w*45,200)}ms`},children:[e.jsx("div",{style:{width:44,height:26,borderRadius:8,background:`${K.color}1c`,color:K.color,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,letterSpacing:"0.06em",border:`1px solid ${K.color}30`},children:K.label}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13.5,fontWeight:600,color:o.color.fg,marginBottom:3,display:"flex",alignItems:"center",gap:8},children:[u.name,e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o.color.success,display:"inline-block",animation:J?"vagus-pulse 1.8s ease-in-out infinite":"none",opacity:.9}})]}),e.jsx("div",{style:{fontSize:12,color:o.color.muted,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:zo(u.config)})]}),e.jsxs("button",{onClick:()=>H(u),className:"vagus-mcp-btn-press",style:ve,onMouseEnter:$=>{$.currentTarget.style.borderColor=o.color.primary,$.currentTarget.style.color=o.color.primary},onMouseLeave:$=>{$.currentTarget.style.borderColor=o.color.border,$.currentTarget.style.color=o.color.fg},children:[e.jsx($o,{})," 编辑"]}),e.jsx("button",{onClick:()=>void je(u.name),disabled:V,className:"vagus-mcp-btn-press",style:{...Ge,opacity:V?.6:1},onMouseEnter:$=>{$.currentTarget.style.color=o.color.error,$.currentTarget.style.background=n?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)"},onMouseLeave:$=>{$.currentTarget.style.color=o.color.muted,$.currentTarget.style.background="transparent"},children:V?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",border:`2px solid ${o.color.error}40`,borderTopColor:o.color.error,animation:"vagus-spin 0.7s linear infinite",display:"inline-block"}}),"移除中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Io,{})," 移除"]})})]},u.name)})})]}),m&&e.jsxs("div",{style:{animation:"vagus-fade-up 0.3s ease both"},children:[e.jsxs("button",{onClick:P,style:{border:"none",background:"none",color:o.color.muted,fontSize:12.5,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5,marginBottom:18,padding:"4px 8px 4px 0",transition:"color 0.15s ease"},onMouseEnter:u=>{u.currentTarget.style.color=o.color.fg},onMouseLeave:u=>{u.currentTarget.style.color=o.color.muted},children:[e.jsx(Wo,{})," 返回列表"]}),e.jsx("div",{style:{fontSize:17,fontWeight:650,color:o.color.fg,marginBottom:4,letterSpacing:"-0.01em"},children:k?"编辑 MCP 服务器":"新建 MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,marginBottom:22,lineHeight:1.5},children:k?`修改「${k.name}」的配置,保存后自动生效`:"填写配置,实时预览生成的 MCP 配置 JSON"}),e.jsxs("div",{style:{display:"flex",position:"relative",background:n?o.color.bg:"#f1f2f4",borderRadius:11,padding:4,marginBottom:22,border:`1px solid ${o.color.border}`},children:[e.jsx("div",{style:{position:"absolute",top:4,bottom:4,left:D==="form"?4:"calc(50% + 0px)",width:"calc(50% - 8px)",background:n?o.color.surface:"#ffffff",borderRadius:8,boxShadow:n?"0 1px 0 rgba(255,255,255,0.06) inset, 0 2px 8px rgba(0,0,0,0.25)":"0 1px 0 rgba(255,255,255,0.8) inset, 0 1px 4px rgba(0,0,0,0.10)",transition:"left 0.22s cubic-bezier(0.22, 1, 0.36, 1)"}}),["form","json"].map(u=>e.jsx("div",{onClick:()=>F(u),style:{flex:1,textAlign:"center",padding:"8px 0",fontSize:13,cursor:"pointer",position:"relative",zIndex:1,color:D===u?o.color.fg:o.color.muted,fontWeight:D===u?600:400,transition:"color 0.2s ease"},children:u==="form"?"表单":"JSON"},u))]}),f&&e.jsxs("div",{style:{fontSize:13,color:"#e5484d",background:n?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)",border:`1px solid ${n?"rgba(248,81,73,0.25)":"rgba(220,38,38,0.2)"}`,borderRadius:10,padding:"9px 14px",marginBottom:16,display:"flex",alignItems:"center",gap:9,animation:"vagus-pop 0.25s ease both"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01",stroke:"#fff",strokeWidth:"2",fill:"none"})]}),f]}),e.jsxs("div",{style:{display:"flex",gap:20,alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1,minWidth:0,minHeight:400},children:[D==="form"&&e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"22px 24px",boxShadow:ne},children:[e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:q,children:"名称"}),e.jsx("input",{className:"vagus-mcp-input",style:ie,placeholder:"my-mcp-server",value:h,onChange:u=>j(u.target.value)})]}),e.jsxs("div",{style:{...G,marginBottom:20},children:[e.jsx("label",{style:q,children:"连接方式"}),e.jsx("div",{style:{display:"flex",gap:10},children:["stdio","http"].map(u=>{const w=S===u;return e.jsx("button",{onClick:()=>z(u),className:"vagus-mcp-btn-press",style:{flex:1,padding:"10px 0",borderRadius:10,fontSize:13,cursor:"pointer",background:w?`linear-gradient(180deg, ${o.color.primary}, ${n?"#3d74e0":"#1d4fd7"})`:n?o.color.bg:"#ffffff",color:w?"#fff":o.color.fg,border:w?"none":`1px solid ${o.color.border}`,fontWeight:w?600:400,boxShadow:w?n?"0 2px 10px rgba(79,140,255,0.30)":"0 2px 10px rgba(37,99,235,0.22)":"none",transition:"all 0.18s ease"},children:u==="stdio"?"stdio(本地命令)":"http(远程)"},u)})})]}),e.jsx("div",{style:{height:1,background:o.color.border,margin:"2px 0 20px",opacity:.7}}),S==="stdio"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:q,children:"命令"}),e.jsx("input",{className:"vagus-mcp-input",style:{...ie,fontFamily:"monospace",fontSize:12.5},placeholder:"npx",value:W,onChange:u=>E(u.target.value)})]}),e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:q,children:"参数"}),e.jsx("input",{className:"vagus-mcp-input",style:{...ie,fontFamily:"monospace",fontSize:12.5},placeholder:"-y @modelcontextprotocol/server-memory",value:I,onChange:u=>O(u.target.value)}),e.jsx("div",{style:ge,children:"多个参数用空格分隔"})]})]}):e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:q,children:"URL"}),e.jsx("input",{className:"vagus-mcp-input",style:{...ie,fontFamily:"monospace",fontSize:12.5},placeholder:"https://mcp.example.com",value:x,onChange:u=>R(u.target.value)})]}),e.jsx("div",{style:{height:1,background:o.color.border,margin:"2px 0 20px",opacity:.7}}),e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:q,children:"超时时间(毫秒)"}),e.jsx("input",{className:"vagus-mcp-input",style:{...ie,maxWidth:220},placeholder:"30000",value:l,onChange:u=>v(u.target.value)}),e.jsx("div",{style:ge,children:"默认 30000 ms(30 秒),设为 0 表示不限制"})]}),S==="stdio"&&e.jsxs("div",{style:{...G,marginBottom:0},children:[e.jsx("label",{style:q,children:"环境变量(可选)"}),e.jsx("textarea",{className:"vagus-mcp-input",style:{...Be,minHeight:100},placeholder:JSON.stringify({MY_API_KEY:"your-key"},null,2),value:B,onChange:u=>A(u.target.value)}),e.jsx("div",{style:ge,children:"JSON 格式,留空则不设置"})]})]}),D==="json"&&e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"22px 24px",boxShadow:ne},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:14},children:[e.jsx(No,{}),e.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:o.color.fg,letterSpacing:"0.02em"},children:"完整配置"})]}),e.jsxs("div",{style:{...G,marginBottom:0},children:[e.jsx("textarea",{className:"vagus-mcp-input",style:{...Be,minHeight:200},placeholder:JSON.stringify({"my-mcp-server":{type:"http",url:""}},null,2),value:N,onChange:u=>T(u.target.value)}),e.jsxs("div",{style:ge,children:["支持 ","{",'"server-name": ',"{...}","}"," 或 ","{",'"mcpServers": ',"{",'"server-name": ',"{...}","}","}",",可一次添加多台"]})]})]})]}),e.jsx("div",{style:{width:340,flexShrink:0,position:"sticky",top:0},children:e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"16px 18px",boxShadow:ne},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:o.color.muted,letterSpacing:"0.06em",textTransform:"uppercase"},children:"预生成配置"}),e.jsx("button",{onClick:()=>void Ye(),style:{border:`1px solid ${o.color.border}`,background:"transparent",borderRadius:6,padding:"3px 8px",fontSize:10.5,color:o.color.muted,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:u=>{u.currentTarget.style.borderColor=o.color.primary,u.currentTarget.style.color=o.color.primary},onMouseLeave:u=>{u.currentTarget.style.borderColor=o.color.border,u.currentTarget.style.color=o.color.muted},children:U?"✓ 已复制":"复制"})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:12,lineHeight:1.6,whiteSpace:"pre",background:n?"rgba(0,0,0,0.2)":"rgba(0,0,0,0.02)",borderRadius:8,padding:"10px 12px",boxSizing:"border-box",overflow:"visible"},children:de===null?e.jsxs("span",{style:{color:o.color.muted,opacity:.5},children:[`{
|
|
27
|
+
"server-name": {
|
|
28
|
+
}
|
|
29
|
+
`,e.jsx("span",{style:{animation:"vagus-pulse 1.4s ease-in-out infinite"},children:D==="json"?" // 在此粘贴或输入 MCP 配置 JSON":" // 填写左侧表单自动生成"}),`
|
|
30
|
+
}`]}):e.jsxs(e.Fragment,{children:[Po(de),e.jsx("div",{style:{height:4}}),e.jsxs("div",{style:{fontSize:10.5,color:o.color.muted,opacity:.5,whiteSpace:"nowrap"},children:[JSON.stringify(de).length," B"]})]})})]})})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[e.jsxs("button",{onClick:()=>void M(),className:"vagus-mcp-btn-press",style:Ee,onMouseEnter:u=>{u.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:u=>{u.currentTarget.style.filter="none"},children:[e.jsx(Re,{})," ",k?"保存":"添加"]}),e.jsx("button",{onClick:P,className:"vagus-mcp-btn-press",style:ve,children:"取消"})]})]})]}),e.jsx("style",{children:`
|
|
31
|
+
:root { --vagus-focus: ${ae}; --vagus-focus-ring: ${me}; }
|
|
32
|
+
`})]})}const Ne={wrench:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14.7 6.3a4.5 4.5 0 0 0-6.4 6.4L3 18v3h3l5.3-5.3a4.5 4.5 0 0 0 6.4-6.4l-3 3-2.3-2.3 3-3z"})}),box:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 17l9 4 9-4M3 12l9 4 9-4M3 7l9 4 9-4-9-4z"})}),puzzle:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 7a4 4 0 1 1 3 6.9c-.8-.4-1.3-1.2-1.3-2.1V9h-2.8A2.8 2.8 0 0 1 10 6.2c0-.8.3-1.5.8-2.1A4 4 0 0 1 14 7z"}),e.jsx("path",{d:"M4 14a4 4 0 0 0 6.9 3A4 4 0 0 0 5 12.7h2.8V10A2.8 2.8 0 0 1 11.8 8c.8 0 1.5.3 2.1.8a4 4 0 0 0-3 6.9V14H7.6z"})]})},Oo=e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]});let xe;function Ho({request:r,t:o}){const{theme:t}=_(),n=t!=="light",[i,a]=c.useState(()=>xe??[]),[s,d]=c.useState(xe===void 0),[f,p]=c.useState(null),[m,g]=c.useState(null),k=c.useCallback(h=>{xe=h,a(h)},[]);c.useEffect(()=>{let h=!1;return(async()=>{try{const j=await r("skills.list");h||(k(j),p(null))}catch(j){!h&&xe===void 0&&p(j instanceof Error?j.message:"加载失败")}finally{h||d(!1)}})(),()=>{h=!0}},[k,r]);const C=c.useCallback(async h=>{g(h.name),p(null);try{const j=await r("skills.setEnabled",{name:h.name,enabled:!h.enabled});k(j)}catch(j){p(j instanceof Error?j.message:"切换失败")}finally{g(null)}},[k,r]),D=i.filter(h=>h.source==="agents").length,F={local:{label:"本地",accent:"#818cf8",icon:"wrench"},agents:{label:"共享",accent:"#34d399",icon:"box"},package:{label:"包",accent:"#f59e0b",icon:"puzzle"},project:{label:"项目",accent:"#3b82f6",icon:"layers"}};return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:22},children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,letterSpacing:"-0.02em",color:o.color.fg},children:"技能"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginTop:8,fontSize:12.5,color:o.color.muted},children:[e.jsx("span",{children:"全局可复用的技能包,按名称去重"}),!s&&i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsxs("span",{children:[i.length," 个技能"]}),e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsxs("span",{children:[D," 共享"]})]})]})]}),f&&e.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:9,fontSize:12.5,lineHeight:1.55,color:o.color.error,background:n?"rgba(248,81,73,0.09)":"rgba(220,38,38,0.05)",border:`1px solid ${n?"rgba(248,81,73,0.24)":"rgba(220,38,38,0.18)"}`,borderRadius:11,padding:"10px 13px",marginBottom:18},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{marginTop:1,flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v5M12 17h.01"})]}),e.jsx("span",{children:f})]}),s&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11,padding:"40px 0",color:o.color.muted,fontSize:13},children:[e.jsx("span",{style:{width:13,height:13,flexShrink:0,border:"2px solid currentColor",borderRightColor:"transparent",borderRadius:"50%",animation:"sk-spin 700ms linear infinite"}}),"正在读取技能…"]}),!s&&i.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:200,color:o.color.muted},children:[e.jsx("div",{style:{width:42,height:42,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",color:o.color.muted,background:n?"rgba(15,17,23,0.5)":"rgba(245,246,250,0.9)",marginBottom:12},children:Ne.box}),e.jsx("div",{style:{color:o.color.fg,fontSize:14,fontWeight:650},children:"暂无全局技能"}),e.jsx("div",{style:{marginTop:5,fontSize:12.5},children:"在 ~/.pi/agent/skills/ 或 ~/.agents/skills/ 添加 SKILL.md。"})]}),!s&&i.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:i.map((h,j)=>{const S=F[h.source]??{label:"其他",accent:"#8b90a0",icon:"box"},z=j===i.length-1;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",alignItems:"center",gap:13,padding:"11px 10px",borderRadius:10,borderBottom:z?"none":`1px solid ${o.color.border}`,transition:"background 140ms ease",opacity:m===h.name?.6:1},onMouseEnter:W=>{W.currentTarget.style.background=n?"rgba(129,140,248,0.07)":"rgba(99,102,241,0.05)"},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{width:38,height:38,borderRadius:10,flexShrink:0,background:`${S.accent}16`,color:S.accent,border:`1px solid ${S.accent}28`,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{transform:"scale(1.1)",display:"flex"},children:Ne[S.icon]??Oo})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.jsx("h3",{style:{margin:0,fontSize:13.5,lineHeight:1.3,fontWeight:660,color:o.color.fg},children:h.name}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,lineHeight:1,fontWeight:650,color:S.accent,background:`${S.accent}16`,border:`1px solid ${S.accent}28`,borderRadius:999,padding:"2.5px 7px"},children:S.label})]}),h.description&&e.jsx("p",{style:{margin:"3px 0 0",fontSize:12,lineHeight:1.5,color:o.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.description}),e.jsx("div",{style:{marginTop:4,fontSize:10.5,color:o.color.muted,fontFamily:o.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.path})]}),e.jsx("button",{role:"switch","aria-checked":h.enabled,"aria-label":`${h.enabled?"禁用":"启用"}技能 ${h.name}`,disabled:m===h.name,onClick:()=>void C(h),style:{width:40,height:22,borderRadius:99,border:"none",cursor:"pointer",position:"relative",flexShrink:0,background:h.enabled?"linear-gradient(120deg, #818cf8, #8b5cf6)":o.color.border,transition:"background 150ms ease"},children:e.jsx("span",{style:{position:"absolute",top:2,left:h.enabled?20:2,width:18,height:18,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.25)",transition:"left 150ms ease"}})})]},`${h.source}:${h.name}`)})}),e.jsx("style",{children:`
|
|
33
|
+
@keyframes sk-spin { to { transform: rotate(360deg); } }
|
|
34
|
+
@media (prefers-reduced-motion: reduce) {
|
|
35
|
+
[data-theme] * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
|
|
36
|
+
}
|
|
37
|
+
`})]})}function Ko({providers:r,usageStats:o,onClose:t,onSave:n,onRefresh:i,onTest:a,cat:s,onCatChange:d,onProbe:f,request:p,projectCwd:m}){const g=re(),k=lo(),[C,D]=c.useState(()=>({uiFontSize:k.uiFontSize,showLineNumbers:k.showLineNumbers,wrapLongLines:k.wrapLongLines,codeFontSize:k.codeFontSize})),F=E=>D(I=>({...I,...E})),h=()=>{k.update(C),t()},j=E=>({display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:9,fontSize:13,cursor:"pointer",background:E?g.color.surface:"transparent",color:E?g.color.fg:g.color.muted,fontWeight:E?500:400}),S={fontSize:11,fontWeight:600,color:g.color.muted,padding:"14px 10px 6px",letterSpacing:"0.05em"},{theme:z}=_(),W={width:"100%",background:z==="light"?"#ffffff":g.color.surface,border:`1px solid ${g.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,outline:"none",color:g.color.fg};return e.jsxs("div",{style:{flex:1,display:"flex",minHeight:0,background:g.color.bg,fontSize:14},children:[e.jsxs("aside",{style:{width:220,flexShrink:0,borderRight:`1px solid ${g.color.border}`,padding:"20px 12px",display:"flex",flexDirection:"column",gap:4,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 10px 14px"},children:[e.jsx("span",{style:{fontSize:15,fontWeight:600,color:g.color.fg},children:"设置"}),e.jsx("button",{onClick:h,style:{marginLeft:"auto",border:"none",background:"none",color:g.color.muted,fontSize:12,cursor:"pointer"},children:"← 返回"})]}),e.jsx("div",{style:S,children:"基础设置"}),e.jsxs("div",{style:j(s==="appearance"),onClick:()=>d("appearance"),children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})}),"外观"]}),e.jsxs("div",{style:j(s==="models"),onClick:()=>d("models"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"模型设置"]}),e.jsx("div",{style:S,children:"Agents 能力"}),e.jsxs("div",{style:j(s==="mcp"),onClick:()=>d("mcp"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"}),e.jsx("path",{d:"M13.5 6.5l4 4"})]}),"MCP 服务器"]}),e.jsxs("div",{style:j(s==="skills"),onClick:()=>d("skills"),children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M14.7 6.3a4.5 4.5 0 0 0-6.4 6.4L3 18v3h3l5.3-5.3a4.5 4.5 0 0 0 6.4-6.4l-3 3-2.3-2.3 3-3z"})}),"技能"]}),e.jsx("div",{style:S,children:"数据与统计"}),e.jsxs("div",{style:j(s==="usage"),onClick:()=>d("usage"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 3v18h18"}),e.jsx("path",{d:"M7 14l4-4 3 3 5-6"})]}),"使用统计"]})]}),e.jsx("main",{style:{flex:1,overflowY:"auto",minWidth:0,padding:"28px 36px 60px",scrollbarGutter:"stable"},children:e.jsxs("div",{style:{maxWidth:980,margin:"0 auto"},children:[s==="usage"&&e.jsx(Mo,{stats:o,t:g}),s==="models"&&e.jsx(ko,{providers:r,inputStyle:W,t:g,onSave:n,onRefresh:i,onTest:a,onProbe:f}),s==="appearance"&&e.jsx(Fo,{draft:C,onChange:F,t:g}),s==="mcp"&&e.jsx(Ve,{request:p,t:g}),s==="skills"&&e.jsx(Ho,{request:p,t:g})]})})]})}const _o=["npm:@foo/pi-tools","git:github.com/user/repo","/absolute/path/to/package"],Se="linear-gradient(120deg, #818cf8 0%, #a78bfa 55%, #c084fc 100%)";let fe;function Uo(r){const o=[];return r.resources.extensions>0&&o.push(`${r.resources.extensions} 扩展`),r.resources.skills>0&&o.push(`${r.resources.skills} 技能`),r.resources.prompts>0&&o.push(`${r.resources.prompts} 模板`),r.resources.themes>0&&o.push(`${r.resources.themes} 主题`),o.length>0?o.join(" · "):"未声明资源"}function Jo({request:r,t:o,onClose:t}){const{theme:n}=_(),i=n!=="light",[a,s]=c.useState(()=>fe??[]),[d,f]=c.useState(fe===void 0),[p,m]=c.useState(null),[g,k]=c.useState(null),[C,D]=c.useState(""),[F,h]=c.useState(!1),[j,S]=c.useState(null),z=c.useCallback(l=>{fe=l,s(l)},[]),W=c.useCallback(async()=>{const l=await r("plugin.list");z(l),m(null)},[z,r]);c.useEffect(()=>{let l=!1;return(async()=>{try{const v=await r("plugin.list");l||(z(v),m(null))}catch(v){!l&&fe===void 0&&m(v instanceof Error?v.message:"加载失败")}finally{l||f(!1)}})(),()=>{l=!0}},[z,r]);const E=async l=>{const v=l.trim();if(!v){m("请输入包源,例如 npm:@foo/pi-tools");return}h(!0),m(null);try{const B=await r("plugin.install",{source:v});if(!B.ok){m(B.error??"安装失败");return}D(""),await W()}catch(B){m(B instanceof Error?B.message:"安装失败")}finally{h(!1)}},I=async l=>{k(l),m(null);try{const v=await r("plugin.uninstall",{source:l});if(!v.ok){m(v.error??"卸载失败");return}await W()}catch(v){m(v instanceof Error?v.message:"卸载失败")}finally{k(null)}},O=a.reduce((l,v)=>(l.extensions+=v.resources.extensions,l.skills+=v.resources.skills,l.prompts+=v.resources.prompts,l.themes+=v.resources.themes,l),{extensions:0,skills:0,prompts:0,themes:0});return e.jsxs("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:o.color.bg,color:o.color.fg,overflow:"hidden",fontFamily:o.font.sans},children:[e.jsx("style",{children:`
|
|
38
|
+
.piweb-pkg * { box-sizing: border-box; }
|
|
39
|
+
.piweb-pkg-back:focus-visible, .piweb-pkg-action:focus-visible, .piweb-pkg-install:focus-visible {
|
|
40
|
+
outline: 3px solid rgba(129,140,248,0.4);
|
|
41
|
+
outline-offset: 2px;
|
|
42
|
+
}
|
|
43
|
+
.piweb-pkg-action:active:not(:disabled) { transform: scale(0.97); }
|
|
44
|
+
.piweb-pkg-action:disabled { cursor: wait !important; opacity: 0.6; }
|
|
45
|
+
.piweb-pkg-spinner {
|
|
46
|
+
width: 13px; height: 13px; flex-shrink: 0;
|
|
47
|
+
border: 2px solid currentColor;
|
|
48
|
+
border-right-color: transparent;
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
animation: piweb-pkg-spin 700ms linear infinite;
|
|
51
|
+
}
|
|
52
|
+
@keyframes piweb-pkg-spin { to { transform: rotate(360deg); } }
|
|
53
|
+
@media (prefers-reduced-motion: reduce) {
|
|
54
|
+
.piweb-pkg *, .piweb-pkg *::before, .piweb-pkg *::after {
|
|
55
|
+
animation-duration: 0.01ms !important;
|
|
56
|
+
animation-iteration-count: 1 !important;
|
|
57
|
+
transition-duration: 0.01ms !important;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`}),e.jsxs("header",{style:{flex:"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"0 18px",height:54,borderBottom:`1px solid ${o.color.border}`,background:i?"rgba(15,17,23,0.88)":"rgba(255,255,255,0.9)",backdropFilter:"blur(12px)",position:"relative",zIndex:2},children:[e.jsx("div",{style:{position:"absolute",left:0,right:0,top:0,height:2,background:Se,opacity:.9,pointerEvents:"none"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("button",{className:"piweb-pkg-back",onClick:t,"aria-label":"返回上一页",style:{width:40,height:40,border:`1px solid ${o.color.border}`,borderRadius:9,background:"transparent",color:o.color.muted,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"color 150ms ease, border-color 150ms ease, background 150ms ease"},onMouseEnter:l=>{l.currentTarget.style.color="#a5b4fc",l.currentTarget.style.borderColor="rgba(129,140,248,0.5)",l.currentTarget.style.background="rgba(129,140,248,0.09)"},onMouseLeave:l=>{l.currentTarget.style.color=o.color.muted,l.currentTarget.style.borderColor=o.color.border,l.currentTarget.style.background="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),e.jsx("div",{style:{fontSize:14,fontWeight:680,letterSpacing:"-0.01em",color:o.color.fg},children:"Pi 包管理"})]}),e.jsxs("div",{"aria-live":"polite",style:{display:"inline-flex",alignItems:"center",gap:7,fontSize:11.5,fontWeight:550,color:o.color.muted},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}),a.filter(l=>l.installed).length," 已安装"]}),O.extensions>0&&e.jsxs("span",{children:["· ",O.extensions," 扩展"]})]})]}),e.jsx("main",{className:"piweb-pkg-scroll",style:{flex:1,overflowY:"auto",padding:"26px 32px 60px",scrollbarGutter:"stable",background:i?"radial-gradient(1100px 380px at 50% -140px, rgba(99,102,241,0.14), transparent 72%)":"radial-gradient(1100px 380px at 50% -140px, rgba(99,102,241,0.09), transparent 72%)"},children:e.jsxs("div",{style:{width:"100%",maxWidth:980,margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:22,textAlign:"center"},children:[e.jsx("h1",{style:{margin:0,fontSize:28,lineHeight:1.15,fontWeight:760,letterSpacing:"-0.025em",background:Se,WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent"},children:"Pi 包管理"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:8,marginTop:9,fontSize:12.5,color:o.color.muted},children:[e.jsx("span",{children:"与 pi CLI 完全互通 —— 这里安装的包,"}),e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11.5,color:o.color.fg,background:o.color.surface,padding:"1px 6px",borderRadius:5},children:"pi list"}),e.jsx("span",{children:"同样可见,反之亦然"})]})]}),e.jsxs("div",{style:{display:"flex",gap:9,marginBottom:22,padding:14,borderRadius:14,background:i?"rgba(129,140,248,0.06)":"rgba(99,102,241,0.05)",border:`1px solid ${i?"rgba(129,140,248,0.18)":"rgba(99,102,241,0.16)"}`},children:[e.jsx("input",{className:"piweb-pkg-install",value:C,onChange:l=>D(l.target.value),onKeyDown:l=>{l.key==="Enter"&&E(C)},placeholder:"输入包源安装,例如 npm:@foo/pi-tools","aria-label":"Pi 包源",style:{flex:1,minWidth:0,height:40,borderRadius:9,border:`1px solid ${o.color.border}`,background:i?"rgba(0,0,0,0.25)":"#ffffff",padding:"0 13px",fontSize:13,fontFamily:o.font.mono,color:o.color.fg,outline:"none"},onFocus:l=>{l.currentTarget.style.borderColor="rgba(129,140,248,0.6)"},onBlur:l=>{l.currentTarget.style.borderColor=o.color.border}}),e.jsxs("button",{className:"piweb-pkg-action",onClick:()=>void E(C),disabled:F,style:{height:40,padding:"0 20px",borderRadius:9,border:"none",background:Se,color:"#fff",fontSize:13,fontWeight:650,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:7,boxShadow:"0 4px 12px rgba(99,102,241,0.24)"},children:[F&&e.jsx("span",{className:"piweb-pkg-spinner"}),F?"安装中":"安装"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:20,fontSize:11.5,color:o.color.muted,flexWrap:"wrap"},children:[e.jsx("span",{children:"支持:"}),_o.map(l=>e.jsx("button",{onClick:()=>D(l),style:{fontFamily:o.font.mono,fontSize:11,color:"#a5b4fc",background:"rgba(129,140,248,0.09)",border:`1px solid ${i?"rgba(129,140,248,0.22)":"rgba(99,102,241,0.18)"}`,borderRadius:999,padding:"3px 9px",cursor:"pointer"},children:l},l)),e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsx("span",{children:e.jsx("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noreferrer",style:{color:"#a5b4fc",textDecoration:"none"},children:"浏览 pi.dev/packages ↗"})})]}),p&&e.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:9,fontSize:12.5,lineHeight:1.55,color:o.color.error,background:i?"rgba(248,81,73,0.09)":"rgba(220,38,38,0.05)",border:`1px solid ${i?"rgba(248,81,73,0.24)":"rgba(220,38,38,0.18)"}`,borderRadius:11,padding:"10px 13px",marginBottom:18},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{marginTop:1,flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v5M12 17h.01"})]}),e.jsx("span",{children:p})]}),d&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:11,padding:"40px 0",color:o.color.muted,fontSize:13},children:[e.jsx("span",{className:"piweb-pkg-spinner"}),"正在读取已安装的包…"]}),!d&&a.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:220,color:o.color.muted},children:[e.jsx("div",{style:{width:42,height:42,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",color:"#a5b4fc",background:"rgba(129,140,248,0.1)",marginBottom:12,fontSize:18},children:"📦"}),e.jsx("div",{style:{color:o.color.fg,fontSize:14,fontWeight:650},children:"还没有安装任何 pi 包"}),e.jsxs("div",{style:{marginTop:5,fontSize:12.5,textAlign:"center"},children:["在上面输入 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11.5,color:o.color.fg},children:"npm:@包名"})," 安装,或到"," ",e.jsx("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noreferrer",style:{color:"#a5b4fc"},children:"pi.dev/packages"})," ","浏览生态。"]})]}),!d&&a.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:a.map(l=>{const v=j===l.source,B=g===l.source;return e.jsxs("article",{className:"piweb-pkg-row",onMouseEnter:()=>S(l.source),onMouseLeave:()=>S(null),style:{display:"flex",alignItems:"center",gap:13,padding:"12px 14px",borderRadius:12,border:`1px solid ${o.color.border}`,background:v?i?"rgba(129,140,248,0.07)":"rgba(99,102,241,0.04)":"transparent",borderLeft:v?"3px solid #818cf8":"3px solid transparent",paddingLeft:v?11:14,transition:"background 140ms ease, border-left-color 140ms ease, padding-left 140ms ease",opacity:B?.6:1},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:10,flexShrink:0,background:"rgba(129,140,248,0.1)",color:"#a5b4fc",border:"1px solid rgba(129,140,248,0.22)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 7a4 4 0 1 1 3 6.9c-.8-.4-1.3-1.2-1.3-2.1V9h-2.8A2.8 2.8 0 0 1 10 6.2c0-.8.3-1.5.8-2.1A4 4 0 0 1 14 7z"}),e.jsx("path",{d:"M4 14a4 4 0 0 0 6.9 3A4 4 0 0 0 5 12.7h2.8V10A2.8 2.8 0 0 1 11.8 8c.8 0 1.5.3 2.1.8a4 4 0 0 0-3 6.9V14H7.6z"})]})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("code",{style:{fontSize:12.5,fontWeight:650,color:o.color.fg,fontFamily:o.font.mono},children:l.source}),e.jsx("span",{style:{fontSize:10,fontWeight:650,letterSpacing:"0.02em",color:l.scope==="user"?"#a5b4fc":o.color.muted,background:l.scope==="user"?"rgba(129,140,248,0.1)":"transparent",border:`1px solid ${l.scope==="user"?"rgba(129,140,248,0.25)":o.color.border}`,borderRadius:999,padding:"2px 7px"},children:l.scope==="user"?"全局":"项目"}),l.installed?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:650,color:"#3fb950",background:"rgba(63,185,80,0.09)",border:"1px solid rgba(63,185,80,0.16)",borderRadius:999,padding:"2.5px 7px"},children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}),"已安装"]}):e.jsx("span",{style:{fontSize:10,fontWeight:650,color:o.color.warning,background:"rgba(210,153,34,0.09)",border:"1px solid rgba(210,153,34,0.18)",borderRadius:999,padding:"2.5px 7px"},children:"未安装"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:7,marginTop:4,fontSize:11,color:o.color.muted},children:[e.jsx("span",{children:Uo(l)}),l.installedPath&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:10.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:300},children:l.installedPath})]})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsxs("button",{className:"piweb-pkg-action",onClick:()=>void I(l.source),disabled:B,"aria-label":`卸载 ${l.source}`,style:{minHeight:34,borderRadius:8,padding:"0 13px",fontSize:12,cursor:"pointer",fontWeight:600,border:`1px solid ${o.color.border}`,background:"transparent",color:o.color.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},onMouseEnter:A=>{B||(A.currentTarget.style.borderColor=o.color.error,A.currentTarget.style.color=o.color.error,A.currentTarget.style.background=i?"rgba(248,81,73,0.06)":"rgba(220,38,38,0.04)")},onMouseLeave:A=>{A.currentTarget.style.borderColor=o.color.border,A.currentTarget.style.color=o.color.fg,A.currentTarget.style.background="transparent"},children:[B&&e.jsx("span",{className:"piweb-pkg-spinner"}),B?"卸载中":"卸载"]})})]},l.source)})}),e.jsxs("div",{style:{marginTop:26,fontSize:11.5,lineHeight:1.7,color:o.color.muted,textAlign:"center"},children:["在 pi TUI 中用 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11,color:o.color.fg},children:"pi install npm:<包名>"})," 安装的包同样出现在这里。",e.jsx("br",{}),"卸载请到 TUI 使用 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11,color:o.color.fg},children:"pi remove"}),',或在这里点击"卸载"。']})]})})]})}const qo=Object.freeze(Object.defineProperty({__proto__:null,McpView:Ve,PluginsView:Jo,SettingsView:Ko},Symbol.toStringTag,{value:"Module"}));export{Qo as A,oo as D,Zo as J,eo as L,Xo as T,_ as a,lo as b,no as h,qo as i,re as u};
|