pikiclaw 0.3.40 → 0.3.42
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/dashboard/dist/assets/AgentTab-DuUaqZFx.js +1 -0
- package/dashboard/dist/assets/{BrandIcon-KSnFdk62.js → BrandIcon-BeVfjldz.js} +1 -1
- package/dashboard/dist/assets/{DirBrowser-BqA8ssEC.js → DirBrowser-F-EiHGCd.js} +1 -1
- package/dashboard/dist/assets/ExtensionsTab-Cs-q2PNv.js +1 -0
- package/dashboard/dist/assets/{IMAccessTab-6L_l5Y5A.js → IMAccessTab-DTw2cNTU.js} +1 -1
- package/dashboard/dist/assets/{Modal-Dk3jQZ_G.js → Modal-at8vOOy7.js} +1 -1
- package/dashboard/dist/assets/{Modals-BoS_lRW5.js → Modals-CMKQyEvy.js} +1 -1
- package/dashboard/dist/assets/{Select-CCtTUA2O.js → Select-DXx4Fe8N.js} +1 -1
- package/dashboard/dist/assets/{SessionPanel-DA6GsYqZ.js → SessionPanel-DTn-S4G4.js} +1 -1
- package/dashboard/dist/assets/{SystemTab-BQV-kjCS.js → SystemTab-QlXGo8x4.js} +1 -1
- package/dashboard/dist/assets/index-C71Zl38I.js +19 -0
- package/dashboard/dist/assets/index-Cn_xngY_.js +5 -0
- package/dashboard/dist/assets/{shared-CVa9npgA.js → shared-rL_oA8FR.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/agent/handover.js +130 -0
- package/dist/agent/index.js +1 -1
- package/dist/agent/session.js +25 -11
- package/dist/agent/utils.js +18 -2
- package/dist/bot/bot.js +64 -59
- package/dist/catalog/mcp-servers.js +2 -1
- package/dist/dashboard/routes/sessions.js +7 -1
- package/dist/dashboard/session-control.js +30 -1
- package/package.json +1 -1
- package/dashboard/dist/assets/AgentTab-DmKQYVz1.js +0 -1
- package/dashboard/dist/assets/ExtensionsTab-B86en9KI.js +0 -1
- package/dashboard/dist/assets/index-BS_RBT-T.js +0 -5
- package/dashboard/dist/assets/index-C-Dh421o.js +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e,b as Oe}from"./react-vendor-DTcmqLiz.js";import{c as X,u as Y,k as O,a as q,B as K,S as Z,b as De,g as ae,E as we}from"./index-Cn_xngY_.js";import{B as ne}from"./BrandIcon-BeVfjldz.js";import{M as me,a as fe,L as G,I as te}from"./Modal-at8vOOy7.js";import{S as oe}from"./Select-DXx4Fe8N.js";import{A as Ee,S as $e}from"./shared-rL_oA8FR.js";import"./router-Cav8lq-m.js";function Ce(n,t){return!!(n&&t instanceof Node&&n.contains(t))}function He(n,t){if(t.length===0)return!0;const a=`${n.label} ${n.description||""} ${n.meta||""}`.toLowerCase();return t.every(s=>a.includes(s))}function Fe({value:n,options:t,onChange:a,className:s,placeholder:l="—",disabled:r=!1,searchPlaceholder:d="Search models...",noMatchesText:C="No matches",currentLabel:I="Current"}){const o=t.find(u=>u.value===n),v=t.length<=1,[m,c]=i.useState(!1),[k,b]=i.useState(""),[E,H]=i.useState(null),D=i.useRef(null),y=i.useRef(null),x=i.useRef(null);i.useEffect(()=>{if(!m)return;const u=P=>{Ce(D.current,P.target)||Ce(y.current,P.target)||c(!1)},L=P=>{P.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",L)}},[m]),i.useEffect(()=>{m||b("")},[m]),i.useEffect(()=>{if(m){const u=window.setTimeout(()=>x.current?.focus(),0);return()=>window.clearTimeout(u)}},[m]),i.useLayoutEffect(()=>{if(!m)return;const u=()=>{const L=D.current;if(!L)return;const P=L.getBoundingClientRect(),M=window.innerHeight-P.bottom-12,A=P.top-12,R=M<280&&A>M,z=Math.max(220,Math.min(360,R?A:M));H({left:P.left,top:R?Math.max(12,P.top-z-8):P.bottom+8,width:P.width,maxHeight:z})};return u(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[m]);const p=i.useMemo(()=>k.trim().toLowerCase().split(/\s+/).filter(Boolean),[k]),f=i.useMemo(()=>t.filter(u=>u.value!==n&&He(u,p)),[t,n,p]);if(v)return e.jsx("div",{className:X("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",r&&"cursor-not-allowed",s),children:e.jsx("span",{className:X("truncate",!o&&"text-fg-6"),children:o?.label||l})});const S=u=>{r||(a(u),c(!1))},w=(u,L)=>e.jsxs("button",{type:"button",role:"option","aria-selected":L,onClick:()=>S(u.value),className:X("flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",L?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.label}),u.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:u.meta})]})}),L&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"mt-0.5 shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},u.value),$=m&&E?Oe.createPortal(e.jsxs("div",{ref:y,role:"listbox",className:"fixed z-[220] flex flex-col overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:E.left,top:E.top,width:E.width,maxHeight:E.maxHeight},children:[e.jsxs("div",{className:"relative px-1.5 pt-1 pb-2",children:[e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-3.5 flex items-center text-fg-5",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),e.jsx("input",{ref:x,type:"text",value:k,onChange:u=>b(u.target.value),placeholder:d,spellCheck:!1,autoComplete:"off",className:X("h-8 w-full rounded-md border border-control-border bg-control pl-7 pr-2 text-[12px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","placeholder:text-fg-5","focus:border-control-border-h focus:bg-control-h focus:shadow-[0_0_0_4px_var(--th-glow-a)]")})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:I}),w(o,!0),e.jsx("div",{className:"my-1.5 border-t border-edge"})]}),f.length>0?f.map(u=>w(u,!1)):e.jsx("div",{className:"px-3 py-3 text-center text-[12px] text-fg-5",children:C})]})]}),document.body):null;return e.jsxs("div",{ref:D,className:X("relative",s),children:[e.jsxs("button",{type:"button",disabled:r,"aria-haspopup":"listbox","aria-expanded":m,onClick:()=>c(u=>!u),className:X("flex h-9 w-full items-center rounded-md border border-control-border bg-control px-3 pr-8 text-left text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-control-border-h hover:bg-control-h","focus-visible:border-control-border-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:bg-panel-alt disabled:border-edge disabled:text-fg-5","disabled:shadow-none disabled:hover:border-edge disabled:hover:bg-panel-alt",m&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:X("min-w-0 flex-1 truncate",!o&&"text-fg-5"),children:o?.label||l}),e.jsx("span",{className:X("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",m&&"rotate-180"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$]})}const ie=[{id:"openrouter",kind:"openai-compatible",name:{zh:"OpenRouter",en:"OpenRouter"},blurb:{zh:"一个 key 通行 300+ 模型",en:"One key, 300+ models"},baseURL:"https://openrouter.ai/api/v1",envVar:"OPENROUTER_API_KEY",defaultModel:"anthropic/claude-sonnet-4"},{id:"qwen",kind:"openai-compatible",name:{zh:"通义千问 Qwen",en:"Alibaba Qwen"},blurb:{zh:"阿里云 DashScope",en:"Alibaba DashScope"},baseURL:"https://dashscope.aliyuncs.com/compatible-mode/v1",envVar:"DASHSCOPE_API_KEY",defaultModel:"qwen3-max"},{id:"doubao",kind:"openai-compatible",name:{zh:"豆包 Seed",en:"Doubao Seed"},blurb:{zh:"字节跳动 · 火山方舟",en:"ByteDance Volcengine Ark"},baseURL:"https://ark.cn-beijing.volces.com/api/v3",envVar:"ARK_API_KEY",defaultModel:"doubao-seed-1-6-250615"},{id:"glm",kind:"openai-compatible",name:{zh:"智谱 GLM",en:"Zhipu GLM"},blurb:{zh:"GLM-4.6 / Z.AI",en:"GLM-4.6 / Z.AI"},baseURL:"https://open.bigmodel.cn/api/paas/v4",envVar:"ZAI_API_KEY",defaultModel:"glm-4.6"},{id:"minimax",kind:"openai-compatible",name:{zh:"MiniMax",en:"MiniMax"},blurb:{zh:"M2 / abab",en:"M2 / abab"},baseURL:"https://api.minimax.chat/v1",envVar:"MINIMAX_API_KEY",defaultModel:"MiniMax-M2"},{id:"deepseek",kind:"openai-compatible",name:{zh:"DeepSeek",en:"DeepSeek"},blurb:{zh:"深度求索官方 API",en:"DeepSeek official API"},baseURL:"https://api.deepseek.com",envVar:"DEEPSEEK_API_KEY",defaultModel:"deepseek-chat"},{id:"anthropic",kind:"anthropic",name:{zh:"Anthropic 直连",en:"Anthropic Direct"},blurb:{zh:"Claude 官方 API",en:"Official Claude API"},baseURL:"https://api.anthropic.com",envVar:"ANTHROPIC_API_KEY",defaultModel:"claude-sonnet-4-5"},{id:"google",kind:"google",name:{zh:"Google AI Studio",en:"Google AI Studio"},blurb:{zh:"Gemini 官方 API",en:"Official Gemini API"},baseURL:"https://generativelanguage.googleapis.com/v1beta",envVar:"GEMINI_API_KEY",defaultModel:"gemini-2.5-pro"},{id:"openai",kind:"openai",name:{zh:"OpenAI 直连",en:"OpenAI Direct"},blurb:{zh:"gpt-5 / o-系列",en:"gpt-5 / o-series"},baseURL:"https://api.openai.com/v1",envVar:"OPENAI_API_KEY",defaultModel:"gpt-5"},{id:"custom",kind:"openai-compatible",name:{zh:"自定义端点",en:"Custom"},blurb:{zh:"其他 OpenAI 兼容端点",en:"Other OpenAI-compatible endpoint"},baseURL:"",envVar:""}];function Ue(n){return n==="zh-CN"?{sectionTitle:"模型供应商",sectionHint:"连接你自己的模型供应商,凭据加密存入系统 Keychain,可绑定到任意一个智能体。",addLabel:"接入新供应商",validate:"校验",validating:"校验中",edit:"编辑",remove:"删除",removeConfirm:"删除该供应商?已绑定的智能体会自动恢复为官方 Auth。",unbound:"尚未被任何智能体使用",boundOne:"已绑定",boundN:t=>`${t} 个智能体在用`,notConnected:"未接入",modalAddTitle:"接入模型供应商",modalAddHint:t=>t?`已套用 ${t} 模板,仅需粘贴 API Key。`:"填入端点和凭据,保存后即可在智能体卡片上选用。",modalEditTitle:"编辑供应商配置",modalEditHint:"修改端点、凭据或模型参数。修改凭据会清空已校验状态。",fieldName:"配置名称",fieldNamePlaceholder:"例如:OpenRouter · 个人",fieldKind:"API 类型",fieldBaseURL:"Base URL",fieldCredentialSource:"凭据来源",fieldApiKey:"API Key",fieldApiKeyHint:"通过 @napi-rs/keyring 写入系统 Keychain,setting.json 仅保存引用。",fieldEnvVar:"环境变量名",fieldCommand:"获取命令(执行结果作为 key)",fieldModelId:"模型 ID",fieldEffort:"推理强度",fieldEffortHelp:"可用范围由模型决定,留空表示沿用模型默认值。",effortHermesNote:"Hermes 当前从 ~/.hermes/config.yaml 读取推理强度,Profile 上的 effort 暂仅做记录。",credPaste:"粘贴 API Key(推荐,写入系统 Keychain)",credEnv:"从环境变量读取",credCommand:"运行命令获取(1Password / pass / gh 等)",effortDefault:"(沿用默认)",cancel:"取消",save:"保存",saving:"保存中",validationReady:"已就绪",validationInvalid:"凭据无效",validationError:"网络/服务错误",validationUnvalidated:"未校验",providerOnlyHint:"保存后回到智能体卡片,点击「BYOK」选择具体的模型与推理强度。",credentialLabel:"凭据",modelsAvailable:t=>`可用 ${t} 个模型`}:{sectionTitle:"Model Providers",sectionHint:"Connect your own model providers. Keys are encrypted in the OS keychain and can be bound to any agent.",addLabel:"Add provider",validate:"Validate",validating:"Validating",edit:"Edit",remove:"Remove",removeConfirm:"Remove this provider? Bound agents will fall back to native auth.",unbound:"Not used by any agent yet",boundOne:"Bound to",boundN:t=>`${t} agents in use`,notConnected:"Not connected",modalAddTitle:"Connect Model Provider",modalAddHint:t=>t?`Pre-filled from the ${t} template — just paste your API key.`:"Enter endpoint and credential. After saving, choose models on the agent cards above.",modalEditTitle:"Edit Provider",modalEditHint:"Update the endpoint, credential, or model. Changing the credential clears the validated state.",fieldName:"Display name",fieldNamePlaceholder:"e.g. OpenRouter · Personal",fieldKind:"API kind",fieldBaseURL:"Base URL",fieldCredentialSource:"Credential source",fieldApiKey:"API key",fieldApiKeyHint:"Stored in the OS keychain via @napi-rs/keyring; setting.json keeps only a reference.",fieldEnvVar:"Environment variable name",fieldCommand:"Command (stdout becomes the key)",fieldModelId:"Model ID",fieldEffort:"Reasoning effort",fieldEffortHelp:"Available values depend on the chosen model; leave blank to use the default.",effortHermesNote:"Hermes currently reads reasoning_effort from ~/.hermes/config.yaml; Profile.effort is recorded only for now.",credPaste:"Paste API key (recommended — stored in OS keychain)",credEnv:"Read from environment variable",credCommand:"Run a command (1Password / pass / gh, …)",effortDefault:"(default)",cancel:"Cancel",save:"Save",saving:"Saving",validationReady:"Ready",validationInvalid:"Invalid",validationError:"Error",validationUnvalidated:"Not validated",providerOnlyHint:'After saving, head back to an agent card and click "BYOK" to choose the model and effort.',credentialLabel:"Credential",modelsAvailable:t=>`${t} models available`}}const ge={anthropic:{zh:"Anthropic 原生",en:"Anthropic native"},openai:{zh:"OpenAI 原生",en:"OpenAI native"},"openai-compatible":{zh:"OpenAI 兼容",en:"OpenAI-compatible"},google:{zh:"Google AI Studio",en:"Google AI Studio"}};function ke(n,t){return t==="zh-CN"?ge[n].zh:ge[n].en}async function pe(n){return(await fetch(n)).json()}async function re(n,t,a){return(await fetch(t,{method:n,headers:{"Content-Type":"application/json"},body:a?JSON.stringify(a):void 0})).json()}function Le(n){const t=(()=>{try{return new URL(n.baseURL)}catch{return null}})(),a=t?.host.toLowerCase()??"",s=t?.port??"";return(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="11434"?"ollama":(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="1234"?"lmstudio":a.includes("openrouter")?"openrouter":a.includes("anthropic")?"anthropic":a.includes("deepseek")?"deepseek":a.includes("googleapis")||a.includes("vertex")?"google":a.includes("openai.com")?"openai":a.includes("dashscope")||a.includes("qwen")||a.includes("aliyun")?"qwen":a.includes("volces")||a.includes("volcengine")||a.includes("doubao")?"doubao":a.includes("bigmodel")||a.includes("zhipu")||a.includes("z.ai")?"glm":a.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function ze({desc:n,copy:t,locale:a,onPick:s}){const{provider:l,template:r,boundAgents:d=[]}=n,C=!!l,I=l?Le(l):r?.id??"custom",o=l?.name??(r?a==="zh-CN"?r.name.zh:r.name.en:""),v=r?a==="zh-CN"?r.blurb.zh:r.blurb.en:"",m=l?.validation?.state??null,c=()=>{if(!l)return null;if(m==="ready"){const b=l.validation?.modelCount;return e.jsx(O,{variant:"ok",children:b!=null?t.modelsAvailable(b):t.validationReady})}return m==="invalid"?e.jsx(O,{variant:"err",children:t.validationInvalid}):m==="error"?e.jsx(O,{variant:"warn",children:t.validationError}):e.jsx(O,{variant:"warn",children:t.validationUnvalidated})},k=()=>C&&d.length>0?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] text-fg-5",children:[e.jsx("span",{className:"shrink-0",children:t.boundN(d.length)}),e.jsx("div",{className:"flex items-center gap-0.5",children:d.slice(0,4).map(b=>e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-edge bg-panel",title:b,children:e.jsx(ne,{brand:b,size:10})},b))})]}):C&&l.validation?.detail&&m!=="ready"?e.jsx("div",{className:"truncate text-[11.5px] leading-relaxed text-fg-4",title:l.validation.detail,children:l.validation.detail}):e.jsx("div",{className:"truncate text-[11.5px] leading-relaxed text-fg-5",title:v,children:v});return e.jsxs("button",{type:"button",onClick:()=>s(n),className:"group relative flex h-[104px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(ne,{brand:I,size:32}),c()]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg group-hover:text-fg",children:o}),e.jsx("div",{className:"mt-1",children:k()})]})]})}function xe(n,t){return{name:t==="zh-CN"?`${n.name.zh}`:`${n.name.en}`,kind:n.kind,baseURL:n.baseURL,credMode:"paste",apiKey:"",envVar:n.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}}function _e({open:n,copy:t,locale:a,initial:s,initialTemplateName:l,existingProvider:r,onClose:d,onSaved:C,onRemove:I}){const[o,v]=i.useState(()=>s||xe(ie[0],a)),[m,c]=i.useState(!1),[k,b]=i.useState(null);i.useEffect(()=>{n&&(v(s||xe(ie[0],a)),b(null))},[n,s,a]);const E=!!r,H=!!l||E,D=i.useCallback(async()=>{b(null),c(!0);try{const x=o.credMode==="env"?{source:"env",varName:o.envVar.trim()}:o.credMode==="command"?{source:"command",argv:o.cmdLine.trim().split(/\s+/).filter(Boolean)}:null;let p;if(E&&r){const S={name:o.name.trim()||r.name,baseURL:o.baseURL.trim()};o.credMode==="paste"&&o.apiKey?S.apiKey=o.apiKey:x&&(S.credentialRef=x);const w=await re("PATCH",`/api/models/providers/${r.id}`,S);if(!w.ok){b(w.error||"Failed to update provider");return}p=r.id}else{const S={kind:o.kind,name:o.name.trim()||`${ke(o.kind,a)}`,baseURL:o.baseURL.trim()};o.credMode==="paste"?S.apiKey=o.apiKey:x&&(S.credentialRef=x);const w=await re("POST","/api/models/providers",S);if(!w.ok||!w.provider){b(w.error||"Failed to create provider");return}p=w.provider.id}const f=await re("POST",`/api/models/providers/${p}/validate`);if(C(),f.validation&&f.validation.state!=="ready"){b(`${t.validationInvalid}: ${f.validation.detail}`);return}d()}catch(x){b(x?.message||String(x))}finally{c(!1)}},[o,E,r,a,C,d,t.validationInvalid]),y=!m&&o.name.trim().length>0&&o.baseURL.trim().length>0&&(o.credMode!=="paste"||(E?!0:o.apiKey.length>0))&&(o.credMode!=="env"||o.envVar.trim().length>0)&&(o.credMode!=="command"||o.cmdLine.trim().length>0);return e.jsxs(me,{open:n,onClose:d,children:[e.jsx(fe,{title:E?t.modalEditTitle:t.modalAddTitle,description:E?t.modalEditHint:t.modalAddHint(l||null),onClose:d}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{children:t.fieldName}),e.jsx(te,{value:o.name,onChange:x=>v(p=>({...p,name:x.target.value})),placeholder:t.fieldNamePlaceholder})]}),H?e.jsxs("div",{children:[e.jsx(G,{children:t.fieldBaseURL}),e.jsx(te,{value:o.baseURL,onChange:x=>v(p=>({...p,baseURL:x.target.value})),placeholder:"https://…"})]}):e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(G,{children:t.fieldKind}),e.jsx(oe,{value:o.kind,options:Object.keys(ge).map(x=>({value:x,label:ke(x,a)})),onChange:x=>v(p=>({...p,kind:x}))})]}),e.jsxs("div",{children:[e.jsx(G,{children:t.fieldBaseURL}),e.jsx(te,{value:o.baseURL,onChange:x=>v(p=>({...p,baseURL:x.target.value})),placeholder:"https://…"})]})]}),e.jsxs("div",{children:[e.jsx(G,{children:t.fieldCredentialSource}),e.jsx(oe,{value:o.credMode,options:[{value:"paste",label:t.credPaste},{value:"env",label:t.credEnv},{value:"command",label:t.credCommand}],onChange:x=>v(p=>({...p,credMode:x}))})]}),o.credMode==="paste"&&e.jsxs("div",{children:[e.jsx(G,{children:t.fieldApiKey}),e.jsx(te,{type:"password",value:o.apiKey,onChange:x=>v(p=>({...p,apiKey:x.target.value})),placeholder:E?"••••••••":"sk-…"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldApiKeyHint})]}),o.credMode==="env"&&e.jsxs("div",{children:[e.jsx(G,{children:t.fieldEnvVar}),e.jsx(te,{value:o.envVar,onChange:x=>v(p=>({...p,envVar:x.target.value})),placeholder:"OPENROUTER_API_KEY"})]}),o.credMode==="command"&&e.jsxs("div",{children:[e.jsx(G,{children:t.fieldCommand}),e.jsx(te,{value:o.cmdLine,onChange:x=>v(p=>({...p,cmdLine:x.target.value})),placeholder:"op read op://Personal/OpenRouter/key"})]}),k&&e.jsx("div",{className:"rounded-md border border-rose-700/40 bg-rose-900/20 px-3 py-2 text-xs text-rose-200",children:k})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-2 border-t border-edge pt-4",children:[e.jsx("div",{children:E&&I&&e.jsx("button",{type:"button",onClick:()=>{I()},className:"text-[12px] text-fg-5 transition hover:text-[var(--th-err)]",children:t.remove})}),e.jsx(Ee,{primary:{label:m?t.saving:t.save,onClick:D,disabled:!y},secondary:{label:t.cancel,onClick:d}})]})]})}function Re(){const[n,t]=i.useState([]),[a,s]=i.useState([]),[l,r]=i.useState({}),d=i.useCallback(async()=>{const[I,o,v]=await Promise.all([pe("/api/models/providers"),pe("/api/models/profiles"),pe("/api/models/agents")]);t(I.providers||[]),s(o.profiles||[]);const m={};for(const c of v.bindings||[])m[c.agent]=c.activeProfileId;r(m)},[]),C=i.useCallback(async(I,o)=>{await re("POST",`/api/models/agents/${I}/active`,{profileId:o}),await d()},[d]);return i.useEffect(()=>{d()},[d]),{providers:n,profiles:a,bindings:l,reload:d,setActiveProfile:C}}function Me(n){return n.replace(/\/+$/,"").replace(/^http:\/\/localhost(?=[:/]|$)/i,"http://127.0.0.1").replace(/^https:\/\/localhost(?=[:/]|$)/i,"https://127.0.0.1")}function Ie(n,t){const a=Me(n.baseURL);return t.some(s=>Me(s.openAIBaseURL)===a)}function Ke({snapshot:n,localBackends:t}={}){const a=Re(),s=n??a,{providers:l,profiles:r,bindings:d,reload:C}=s,I=t??[],o=Y(f=>f.locale),v=i.useMemo(()=>Ue(o),[o]);Y(f=>f.toast);const[m,c]=i.useState(null),k=i.useMemo(()=>{const f=new Map,S=new Map(r.map(w=>[w.id,w]));for(const[w,$]of Object.entries(d)){if(!$)continue;const u=S.get($);u&&(f.has(u.providerId)||f.set(u.providerId,[]),f.get(u.providerId).push(w))}return f},[d,r]),b=i.useCallback(async f=>{confirm(v.removeConfirm)&&(await re("DELETE",`/api/models/providers/${f.id}`),await C())},[v,C]),E=i.useMemo(()=>{if(!m||m.kind!=="edit")return null;const{provider:f}=m;return{name:f.name,kind:f.kind,baseURL:f.baseURL,credMode:"paste",apiKey:"",envVar:ie.find(S=>S.kind===f.kind)?.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}},[m]),H=i.useMemo(()=>!m||m.kind!=="add"?null:xe(m.template,o),[m,o]),D=m&&m.kind==="add"&&m.template.id!=="custom"?o==="zh-CN"?m.template.name.zh:m.template.name.en:null,y=i.useMemo(()=>{const f=new Map;for(const S of l){const w=Le(S);f.has(w)||f.set(w,S)}return f},[l]),x=i.useMemo(()=>{const f=l.filter(u=>!Ie(u,I)),S=new Set,w=[];for(const u of ie){if(u.id==="custom")continue;const L=y.get(u.id);L&&!Ie(L,I)?(S.add(L.id),w.push({template:u,provider:L,boundAgents:k.get(L.id)??[]})):w.push({template:u})}for(const u of f)S.has(u.id)||w.push({provider:u,boundAgents:k.get(u.id)??[]});const $=ie.find(u=>u.id==="custom");return $&&w.push({template:$}),w},[l,y,I,k]),p=i.useCallback(f=>{if(f.provider){c({kind:"edit",provider:f.provider});return}f.template&&c({kind:"add",template:f.template})},[]);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:x.map((f,S)=>e.jsx(ze,{desc:f,copy:v,locale:o,onPick:p},f.provider?.id??`tpl-${f.template?.id??S}`))}),m&&e.jsx(_e,{open:!0,copy:v,locale:o,initial:m.kind==="edit"?E:H,initialTemplateName:D,existingProvider:m.kind==="edit"?m.provider:void 0,onClose:()=>c(null),onSaved:C,onRemove:m.kind==="edit"?async()=>{await b(m.provider),c(null)}:void 0})]})}const Ve=4;function Ge(n){return n==="zh-CN"?{sectionLabel:"接入本地后端",hostLabel:"本机",hostUnknown:"检测中…",refresh:"刷新",refreshing:"刷新中…",loadFailed:"加载失败",tileStatusDetected:"已运行",tileStatusNotDetected:"未检测到",tileStatusConnected:"已接入",tileBadgeReadyToConnect:"可接入",tileBadgeConnectedWithModels:t=>`可用 ${t} 个模型`,tileBlurbOllama:"本地一键拉取开源模型,OpenAI 兼容端口",tileBlurbLmstudio:"可视化加载 GGUF 模型,零配置 OpenAI 端口",tileNotDetectedHint:"未在本机检测到,点击查看安装与接入流程",tileInstalledModels:t=>`已下载 ${t} 个模型`,modalTitle:t=>`接入 ${t}`,modalDescription:t=>`按顺序完成 3 步:检测后端、安装/校验模型、接入到智能体。完成后 ${t} 会作为一个供应商出现在上方模型供应商列表中。`,stepStatus:"后端状态",stepModels:"模型",stepConnect:"接入智能体",statusRunning:"已运行",statusNotRunning:"未在本机检测到此后端",statusRecheck:"重新检测",statusRechecking:"检测中…",statusInstallHint:t=>`安装并启动 ${t},然后点击重新检测。`,statusHomepageCta:"官网",modelsInstalledHeader:t=>`已安装(${t})`,modelsInstalledEmpty:"尚未下载任何模型。",modelsRecommendedHeader:"推荐安装",modelsBackendOffline:"启动后端后即可在此安装和管理模型。",fitOk:"推荐",fitTight:"勉强可跑",fitNoGo:"内存不足",modelInstalledBadge:"已安装",pullCta:"下载",pullInProgress:"下载中",pullCancel:"取消",pullStatusManifest:"获取清单…",pullStatusVerifying:"校验中…",pullStatusWriting:"写入中…",pullStatusDone:"下载完成",pullFailed:"下载失败",pullCommandHint:"LM Studio 没有 HTTP 拉取接口,请在终端执行:",copyCommand:"复制命令",copied:"已复制",connectCta:"接入",connecting:"接入中…",connectedBadge:"已接入",connectHint:"接入后会作为一个供应商出现在「模型供应商」中,并可绑定到任意智能体卡片。",connectAvailableHint:"后端已就绪,可立即接入。即使尚未下载模型,也可以稍后再来下载。",connectNeedsBackend:"请先启动后端后再接入。",closeBtn:"完成",cancelBtn:"取消",toastConnected:"已接入,可在智能体卡片选择该供应商",toastAlreadyConnected:"此后端已接入",toastConnectFailed:"接入失败",toastPulled:"模型已下载"}:{sectionLabel:"Connect local backend",hostLabel:"This Mac",hostUnknown:"Detecting…",refresh:"Refresh",refreshing:"Refreshing…",loadFailed:"Failed to load local backends",tileStatusDetected:"Running",tileStatusNotDetected:"Not detected",tileStatusConnected:"Connected",tileBadgeReadyToConnect:"Ready to connect",tileBadgeConnectedWithModels:t=>`${t} models available`,tileBlurbOllama:"One-click open-source models, OpenAI-compatible endpoint",tileBlurbLmstudio:"Visual GGUF loader, zero-config OpenAI endpoint",tileNotDetectedHint:"Not detected on this machine — click to see install + connect steps",tileInstalledModels:t=>`${t} models pulled`,modalTitle:t=>`Connect ${t}`,modalDescription:t=>`Walk through 3 steps: detect the backend, install/verify models, connect to agents. After connecting, ${t} appears as a provider in the Model Providers list above.`,stepStatus:"Backend status",stepModels:"Models",stepConnect:"Connect to agents",statusRunning:"Running",statusNotRunning:"Backend not detected on this machine",statusRecheck:"Re-check",statusRechecking:"Checking…",statusInstallHint:t=>`Install and launch ${t}, then click Re-check.`,statusHomepageCta:"Homepage",modelsInstalledHeader:t=>`Installed (${t})`,modelsInstalledEmpty:"No models pulled yet.",modelsRecommendedHeader:"Recommended",modelsBackendOffline:"Launch the backend to install or manage models here.",fitOk:"Recommended",fitTight:"Tight fit",fitNoGo:"Not enough RAM",modelInstalledBadge:"Installed",pullCta:"Download",pullInProgress:"Downloading",pullCancel:"Cancel",pullStatusManifest:"Fetching manifest…",pullStatusVerifying:"Verifying…",pullStatusWriting:"Writing manifest…",pullStatusDone:"Download complete",pullFailed:"Download failed",pullCommandHint:"LM Studio has no HTTP pull API; run this in a terminal:",copyCommand:"Copy",copied:"Copied",connectCta:"Connect",connecting:"Connecting…",connectedBadge:"Connected",connectHint:"Once connected, this backend appears as a provider in Model Providers above and can be bound to any agent card.",connectAvailableHint:"Backend is ready. You can connect now and pull models later.",connectNeedsBackend:"Start the backend first, then connect.",closeBtn:"Done",cancelBtn:"Cancel",toastConnected:"Connected — pick it in any agent's Provider dropdown",toastAlreadyConnected:"Backend is already connected",toastConnectFailed:"Connect failed",toastPulled:"Model downloaded"}}function ve(n,t){return n===null?"tight":n>=t+Ve?"ok":n>=t?"tight":"no-go"}function We(n,t){return n==="ollama"&&t.ollamaTag?`ollama pull ${t.ollamaTag}`:n==="lmstudio"&&t.lmstudioId?`lms get ${t.lmstudioId}`:null}function Ye(n){return!n||!Number.isFinite(n)?"—":`${(n/1024**3).toFixed(0)} GB`}function qe(n){if(!n||!Number.isFinite(n))return"";const t=n/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(n/1024**2).toFixed(0)} MB`}function Ze(n,t){return t.filter(a=>n==="ollama"?!!a.ollamaTag:!!a.lmstudioId)}function be(n,t){const a=t.id==="ollama"?n.ollamaTag:n.lmstudioId;if(!a)return null;const s=a.split(":")[0].toLowerCase();for(const l of t.models)if(l.id.toLowerCase().startsWith(s))return l.id;return null}const Pe={status:"idle",fraction:null,phase:"",error:null};function Qe(n,t){if(n.error)return{phase:n.error,fraction:null};const a=(n.status||"").toLowerCase();return a.startsWith("pulling manifest")?{phase:t.pullStatusManifest,fraction:null}:a.startsWith("verifying")?{phase:t.pullStatusVerifying,fraction:null}:a.startsWith("writing")?{phase:t.pullStatusWriting,fraction:null}:a==="success"?{phase:t.pullStatusDone,fraction:1}:a.startsWith("downloading")&&typeof n.total=="number"&&typeof n.completed=="number"&&n.total>0?{phase:`${Math.round(n.completed/n.total*100)}%`,fraction:n.completed/n.total}:{phase:n.status||"",fraction:null}}function Be(){const[n,t]=i.useState([]),[a,s]=i.useState([]),[l,r]=i.useState(!0),[d,C]=i.useState(null),I=i.useCallback(async()=>{r(!0),C(null);try{const o=await q.probeLocalModels();if(!o.ok)throw new Error(o.error||"Failed to load local backends");t(o.backends||[]),s(o.catalog||[])}catch(o){C(o?.message||String(o))}finally{r(!1)}},[]);return i.useEffect(()=>{I()},[I]),{backends:n,catalog:a,loading:l,error:d,refresh:I}}function Je({backend:n,copy:t,onClick:a}){const s=!!n.existingProviderId,l=n.id==="ollama"?t.tileBlurbOllama:t.tileBlurbLmstudio,r=s?e.jsx(O,{variant:"ok",children:n.models.length>0?t.tileBadgeConnectedWithModels(n.models.length):t.tileStatusConnected}):n.detected?e.jsx(O,{variant:"warn",children:t.tileBadgeReadyToConnect}):null,d=n.detected?`${n.version?`v${n.version} · `:""}${t.tileInstalledModels(n.models.length)}`:l;return e.jsxs("button",{type:"button",onClick:a,className:"group relative flex h-[104px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(ne,{brand:n.id,size:32}),r]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg group-hover:text-fg",children:n.label}),e.jsx("div",{className:"mt-1 truncate text-[11.5px] leading-relaxed text-fg-5",title:d,children:d})]})]})}function he({index:n,label:t,done:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold ${a?"border-transparent bg-[var(--th-badge-accent-bg)] text-[var(--th-badge-accent-text)]":"border-edge bg-panel-alt text-fg-4"}`,children:a?"✓":n}),e.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-[0.16em] text-fg-3",children:t})]})}function Xe({name:n,sizeBytes:t}){return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-edge bg-panel-alt px-2 py-0.5 text-[11px] text-fg-3",children:[e.jsx("span",{className:"truncate font-mono",children:n}),t?e.jsx("span",{className:"shrink-0 text-fg-5",children:qe(t)}):null]})}function et({entry:n,backend:t,totalRamGb:a,pull:s,copy:l,locale:r,onStartPull:d,onCancelPull:C,onCopyHint:I}){const o=ve(a,n.minRamGb),v=r==="zh-CN"?n.descriptionZh:n.description,m=be(n,t),c=t.id==="ollama",k=We(t.id,n);let b="none";return!m&&o!=="no-go"&&(c&&t.detected&&n.ollamaTag?b="pull":c&&!t.detected?b="wait":!c&&k&&(b="lm-copy")),e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3 py-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[13px] font-semibold text-fg",children:n.name}),e.jsx("span",{className:"text-[11px] text-fg-5",children:n.publisher}),o==="ok"&&e.jsx(O,{variant:"ok",children:l.fitOk}),o==="tight"&&e.jsx(O,{variant:"warn",children:l.fitTight}),o==="no-go"&&e.jsx(O,{variant:"err",children:l.fitNoGo}),m&&e.jsx(O,{variant:"accent",children:l.modelInstalledBadge})]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-4",children:v}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] text-fg-5",children:[e.jsxs("span",{children:[n.paramsB,"B params"]}),e.jsxs("span",{children:[n.sizeGb," GB on disk"]}),e.jsxs("span",{children:["≥ ",n.minRamGb," GB RAM"]}),n.homepage&&e.jsx("a",{href:n.homepage,target:"_blank",rel:"noreferrer",className:"text-accent underline-offset-2 hover:underline",children:r==="zh-CN"?"模型主页":"Model card"})]}),(s.status==="running"||s.status==="error")&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-fg-4",children:[e.jsx("span",{children:s.status==="error"?`${l.pullFailed}: ${s.error}`:s.phase}),s.status==="running"&&e.jsx("button",{type:"button",onClick:()=>C(n),className:"text-[11px] text-fg-5 underline-offset-2 hover:text-fg-3 hover:underline",children:l.pullCancel})]}),e.jsx("div",{className:"mt-1 h-1 w-full overflow-hidden rounded-full bg-panel",children:e.jsx("div",{className:s.status==="error"?"h-full bg-rose-500/70":"h-full bg-accent",style:{width:s.fraction!==null?`${Math.max(2,Math.round(s.fraction*100))}%`:"12%",transition:"width 200ms linear",animation:s.fraction===null&&s.status==="running"?"pulse 1.6s ease-in-out infinite":void 0}})})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 self-start",children:[b==="pull"&&e.jsx(K,{variant:"primary",size:"sm",disabled:s.status==="running",onClick:()=>d(n),children:s.status==="running"?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-3 w-3"})," ",s.phase||l.pullInProgress]}):l.pullCta}),b==="lm-copy"&&k&&e.jsx("button",{type:"button",onClick:()=>I(k),className:"rounded-md border border-edge bg-panel px-2 py-1 font-mono text-[11px] text-fg-3 transition hover:border-edge-strong hover:bg-panel-alt",title:l.copyCommand,children:k}),b==="wait"&&e.jsx("span",{className:"text-[11px] text-fg-5",children:l.connectNeedsBackend})]})]})})}function tt({open:n,backend:t,catalog:a,totalRamGb:s,copy:l,locale:r,busyConnect:d,onClose:C,onConnect:I,onRefresh:o,onStartPull:v,onCancelPull:m,pulls:c,onCopyHint:k}){const[b,E]=i.useState(!1);i.useEffect(()=>{E(!1)},[t?.detected,t?.id]);const H=i.useMemo(()=>t?Ze(t.id,a).sort((p,f)=>{const S=ve(s,p.minRamGb),w=ve(s,f.minRamGb),$=P=>P==="ok"?0:P==="tight"?1:2,u=be(p,t)?0:1,L=be(f,t)?0:1;return u!==L?u-L:$(S)-$(w)}):[],[t,a,s]);if(!t)return null;const D=t.id==="ollama",y=!!t.existingProviderId,x=async()=>{E(!0);try{await o()}finally{E(!1)}};return e.jsxs(me,{open:n,onClose:C,wide:!0,children:[e.jsx(fe,{title:l.modalTitle(t.label),description:l.modalDescription(t.label),onClose:C}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx(he,{index:1,label:l.stepStatus,done:t.detected}),e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel",children:e.jsx(ne,{brand:t.id,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-fg",children:t.label}),t.detected?e.jsx(O,{variant:"ok",children:l.statusRunning}):e.jsx(O,{variant:"muted",children:l.tileStatusNotDetected})]}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.detected?e.jsxs(e.Fragment,{children:[t.version&&e.jsxs(e.Fragment,{children:["v",t.version," · "]}),e.jsx("span",{className:"font-mono",children:t.baseURL})]}):e.jsx(e.Fragment,{children:l.statusInstallHint(t.label)})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!t.detected&&t.installHint.brewFormula&&e.jsxs("code",{className:"rounded-md border border-edge bg-panel px-2 py-1 text-[11px] text-fg-3",children:["brew install ",t.installHint.brewFormula]}),!t.detected&&e.jsx("a",{href:t.installHint.homepage,target:"_blank",rel:"noreferrer",className:"text-[12px] text-accent underline-offset-2 hover:underline",children:l.statusHomepageCta}),e.jsx(K,{variant:"outline",size:"sm",disabled:b,onClick:()=>{x()},children:b?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-3 w-3"})," ",l.statusRechecking]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",l.statusRecheck]})})]})]})})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx(he,{index:2,label:l.stepModels,done:t.detected&&t.models.length>0}),t.detected?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:[e.jsx("div",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsInstalledHeader(t.models.length)}),t.models.length===0?e.jsx("div",{className:"text-[12px] text-fg-5",children:l.modelsInstalledEmpty}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(p=>e.jsx(Xe,{name:p.id,sizeBytes:p.sizeBytes},p.id))})]}),H.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsRecommendedHeader}),e.jsx("div",{className:"space-y-1.5",children:H.map(p=>e.jsx(et,{entry:p,backend:t,totalRamGb:s,pull:c[p.id]??Pe,copy:l,locale:r,onStartPull:v,onCancelPull:m,onCopyHint:k},p.id))}),!D&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:l.pullCommandHint})]})]}):e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3 text-[12px] text-fg-5",children:l.modelsBackendOffline})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx(he,{index:3,label:l.stepConnect,done:y}),e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:y?e.jsx(O,{variant:"accent",children:l.connectedBadge}):t.detected?e.jsx(O,{variant:"ok",children:l.statusRunning}):e.jsx(O,{variant:"muted",children:l.tileStatusNotDetected})}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-4",children:y?l.connectHint:t.detected?l.connectAvailableHint:l.connectNeedsBackend})]}),!y&&e.jsx(K,{variant:"primary",size:"sm",disabled:!t.detected||d,onClick:()=>{I(t)},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-3 w-3"})," ",l.connecting]}):l.connectCta})]})})]})]}),e.jsx("div",{className:"mt-6 border-t border-edge pt-4",children:e.jsx(Ee,{primary:{label:l.closeBtn,onClick:C},secondary:y?void 0:{label:l.cancelBtn,onClick:C}})})]})}function nt({snapshot:n,onConnected:t}){const a=Y(M=>M.locale),s=Y(M=>M.toast),l=Y(M=>M.host),r=i.useMemo(()=>Ge(a),[a]),d=Be(),C=n??d,{backends:I,catalog:o,loading:v,error:m,refresh:c}=C,[k,b]=i.useState(null),[E,H]=i.useState(null),[D,y]=i.useState({}),x=i.useRef({}),p=i.useMemo(()=>I.find(M=>M.id===k)??null,[I,k]),f=i.useCallback(async M=>{H(M.id);try{const A=await q.connectLocalBackend(M.id);if(!A.ok)throw new Error(A.error||r.toastConnectFailed);s(A.alreadyConnected?r.toastAlreadyConnected:r.toastConnected),await c(),t&&await t()}catch(A){s(`${r.toastConnectFailed}: ${A?.message||String(A)}`,!1)}finally{H(null)}},[r,t,c,s]),S=i.useCallback(M=>{navigator.clipboard?.writeText(M),s(r.copied)},[r.copied,s]),w=i.useCallback((M,A)=>{y(R=>({...R,[M]:{...R[M]??Pe,...A}}))},[]),$=i.useCallback(async M=>{if(!M.ollamaTag)return;const A=M.id;w(A,{status:"running",fraction:null,phase:r.pullStatusManifest,error:null});const R=q.pullLocalModel("ollama",M.ollamaTag);x.current[A]=R.cancel;let z=!1;try{for await(const B of R.events){if(B.error)throw new Error(B.error);const{phase:W,fraction:j}=Qe(B,r);w(A,{phase:W,fraction:j??null}),B.status==="success"&&(z=!0)}if(z){w(A,{status:"done",fraction:1,phase:r.pullStatusDone,error:null}),s(r.toastPulled),await c();const B=I.find(W=>W.id==="ollama");if(B&&!B.existingProviderId)try{await q.connectLocalBackend("ollama"),await c()}catch{}t&&await t()}else w(A,{status:"error",error:r.pullFailed,fraction:null})}catch(B){const W=B?.name==="AbortError"?r.pullCancel:B?.message||String(B);w(A,{status:"error",error:W,fraction:null})}finally{delete x.current[A]}},[I,r,t,c,s,w]),u=i.useCallback(M=>{const A=x.current[M.id];A&&A()},[]);i.useEffect(()=>()=>{for(const M of Object.values(x.current))try{M()}catch{}},[]);const L=l?.totalMem?l.totalMem/1024**3:null,P=l?`${l.cpuModel||l.arch} · ${Ye(l.totalMem)} RAM`:r.hostUnknown,V=I.length>0?I:[{id:"ollama",label:"Ollama",detected:!1,baseURL:"http://127.0.0.1:11434",openAIBaseURL:"http://127.0.0.1:11434/v1",models:[],existingProviderId:null,installHint:{homepage:"https://ollama.com/download",brewFormula:"ollama"}},{id:"lmstudio",label:"LM Studio",detected:!1,baseURL:"http://127.0.0.1:1234",openAIBaseURL:"http://127.0.0.1:1234/v1",models:[],existingProviderId:null,installHint:{homepage:"https://lmstudio.ai/"}}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[12px] text-fg-5",children:[e.jsx("span",{className:"font-semibold uppercase tracking-[0.14em] text-fg-5",children:r.hostLabel}),e.jsx("span",{className:"mx-2 text-fg-6",children:"·"}),e.jsx("span",{className:"text-fg-3",children:P})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{c()},disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-3 w-3"})," ",r.refreshing]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",r.refresh]})})]}),e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:r.sectionLabel}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:V.map(M=>e.jsx(Je,{backend:M,copy:r,locale:a,onClick:()=>b(M.id)},M.id))})]}),m&&e.jsx("div",{className:"rounded-md border border-rose-700/40 bg-rose-900/20 px-3 py-2 text-xs text-rose-200",children:m}),e.jsx(tt,{open:k!==null,backend:p,catalog:o,totalRamGb:L,copy:r,locale:a,busyConnect:!!p&&E===p.id,onClose:()=>b(null),onConnect:f,onRefresh:c,onStartPull:$,onCancelPull:u,pulls:D,onCopyHint:S})]})}const ue="__native__",at=["claude","codex","gemini","hermes"];function Ae(n){return n===void 0||!Number.isFinite(n)?null:n===0?"$0":n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:n<10?`$${n.toFixed(2)}`:`$${n.toFixed(1)}`}function lt(n){return!n||!Number.isFinite(n)?null:n>=1e6?`${Math.round(n/1e5)/10}M ctx`:n>=1e3?`${Math.round(n/1e3)}K ctx`:`${n} ctx`}function st(n){if(!n||!Number.isFinite(n))return null;const t=n>32e9?n:n*1e3,a=new Date(t);return Number.isNaN(a.getTime())?null:a.toLocaleDateString(void 0,{year:"numeric",month:"short"})}function it(n){const t=n.id,a=[],s=n.name?.trim();s&&s.toLowerCase()!==n.id.toLowerCase()&&a.push(s);const l=Ae(n.pricePromptUsd),r=Ae(n.priceCompletionUsd);l&&r?a.push(`${l} / ${r} per 1M`):l&&a.push(`${l} prompt / 1M`);const d=lt(n.contextLength);d&&a.push(d);const C=st(n.created);return C&&a.push(C),{label:t,description:a.length?a.join(" · "):void 0}}function rt(n){return n==="hermes"}function ot(n){const t=(n||"").toLowerCase().trim();return t==="openrouter"?"openrouter":t==="anthropic"?"anthropic":t==="openai"?"openai":t==="google"||t==="gemini"?"google":t==="deepseek"?"deepseek":t==="qwen"||t==="dashscope"?"qwen":t==="doubao"||t==="volces"||t==="volcengine"?"doubao":t==="glm"||t==="zhipu"||t==="bigmodel"?"glm":t==="minimax"?"minimax":"custom"}function dt(n){const t=(()=>{try{return new URL(n.baseURL).host.toLowerCase()}catch{return""}})();return t.includes("openrouter")?"openrouter":t.includes("anthropic")?"anthropic":t.includes("deepseek")?"deepseek":t.includes("googleapis")||t.includes("vertex")?"google":t.includes("openai.com")?"openai":t.includes("dashscope")||t.includes("qwen")||t.includes("aliyun")?"qwen":t.includes("volces")||t.includes("volcengine")||t.includes("doubao")?"doubao":t.includes("bigmodel")||t.includes("zhipu")||t.includes("z.ai")?"glm":t.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function Se(n,t){const a=n.bindings[t];if(!a)return null;const s=n.profiles.find(r=>r.id===a);if(!s)return null;const l=n.providers.find(r=>r.id===s.providerId);return l?{profileId:s.id,providerId:l.id,providerName:l.name,providerBrand:dt(l),modelId:s.modelId,effort:s.effort||null}:null}function ct(n){return n==="zh-CN"?{defaultsTitle:"新会话默认值",defaultsHint:"决定新建对话默认走哪个智能体。具体模型与推理强度由该智能体卡片下的「供应商 / 模型 / 推理强度」决定。",defaultsEditTitle:"修改默认智能体",defaultsEditHint:"选择新建对话默认走哪个智能体。",defaultsSaved:"默认智能体已更新",editDefaults:"修改默认",agentsTitle:"可用智能体",defaultAgent:"默认智能体",installLabel:"安装状态",versionLabel:"版本",defaultBadge:"默认",installed:"已安装",notInstalled:"未安装",notInstalledHint:"安装该智能体的本地 CLI 后即可在此配置供应商与模型。",noModel:"未设置",noVersion:"版本未知",loadFailed:"无法加载智能体状态",updateAvailable:"有新版本",updateSkipped:"自动更新已跳过",updateFailed:"自动更新失败",update:"升级",updating:"升级中…",checkUpdate:"检查更新",checking:"检查中…",upToDate:"已是最新",install:"安装",installing:"安装中…",modelsTitle:"模型供应商",modelsHint:"接入 BYOK 供应商;接入后可在上方任一智能体卡片的「供应商」下拉中选用。",localTitle:"本地模型",localHint:"在本机检测 Ollama / LM Studio 并按内存推荐合适的开源模型;接入后会作为一个供应商出现在智能体卡片中。",rowProvider:"供应商",rowModel:"模型",rowEffort:"推理强度",providerNative:"官方(CLI 内置认证)",providerNativeFromAgent:"智能体自身配置",effortDefault:"默认",modelLoading:"正在拉取模型列表…",modelEmpty:"该供应商未返回模型列表,请使用自定义输入。",modelCustomToggle:"改为自定义输入",modelListToggle:"从列表选择",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"搜索模型",modelSearchEmpty:"没有匹配的模型",modelCurrentLabel:"当前",saveChanges:"保存",saving:"保存中…",saved:"已保存",configError:"保存失败",externalNativeNote:t=>`Hermes 当前从 ${t||"~/.hermes/config.yaml"} 读取这些值;切换为某个 BYOK 供应商可由 pikiclaw 接管。`,configure:"配置",configModalTitle:t=>`配置 ${t}`,rowSummaryNative:"官方认证",rowSummaryNoModel:"未选模型",rowSummaryNoEffort:"默认强度"}:{defaultsTitle:"New Session Defaults",defaultsHint:"Pick which agent new sessions use by default. Provider / Model / Effort live on each agent card below.",defaultsEditTitle:"Change Default Agent",defaultsEditHint:"Which agent should new sessions use by default?",defaultsSaved:"Default agent updated",editDefaults:"Change default",agentsTitle:"Available Agents",defaultAgent:"Default Agent",installLabel:"Install",versionLabel:"Version",defaultBadge:"Default",installed:"Installed",notInstalled:"Not installed",notInstalledHint:"Install the local CLI for this agent to configure its provider and model.",noModel:"Not set",noVersion:"Version unavailable",loadFailed:"Failed to load agent status",updateAvailable:"Update available",updateSkipped:"Auto-update skipped",updateFailed:"Auto-update failed",update:"Update",updating:"Updating…",checkUpdate:"Check update",checking:"Checking…",upToDate:"Up to date",install:"Install",installing:"Installing…",modelsTitle:"Model Providers",modelsHint:"Connect BYOK providers; pick one in any agent card above.",localTitle:"Local Models",localHint:"Detect Ollama / LM Studio on this machine and surface coding models that fit your RAM. Connected backends show up as a provider on the agent cards.",rowProvider:"Provider",rowModel:"Model",rowEffort:"Effort",providerNative:"Native (CLI auth)",providerNativeFromAgent:"agent's own config",effortDefault:"default",modelLoading:"Loading model list…",modelEmpty:"Provider returned no model list — use custom input.",modelCustomToggle:"Use custom input",modelListToggle:"Pick from list",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"Search models",modelSearchEmpty:"No matching models",modelCurrentLabel:"Current",saveChanges:"Save",saving:"Saving…",saved:"Saved",configError:"Save failed",externalNativeNote:t=>`Hermes reads these values from ${t||"~/.hermes/config.yaml"}; pick a BYOK provider to let pikiclaw take over.`,configure:"Configure",configModalTitle:t=>`Configure ${t}`,rowSummaryNative:"Native auth",rowSummaryNoModel:"No model",rowSummaryNoEffort:"Default effort"}}function ut(n,t){const a=n.filter(l=>l.installed);return(a.length?a:n).map(l=>({value:l.agent,label:`${ae(l.agent).label} · ${l.installed?l.version||t.installed:t.notInstalled}`}))}function mt(n){return n.nativeSelectedModel?n.nativeSelectedModel:n.nativeConfig?.model?n.nativeConfig.model:n.models.length?n.models[0].id:""}function ye(n,t){n({defaultAgent:t.defaultAgent,agents:t.agents})}function ft(n,t,a){if(a)return{providerId:a.providerId,modelId:a.modelId,effort:a.effort||"",modelMode:"list"};const s=t?.nativeConfig||null;return{providerId:ue,modelId:s?.model||t?.selectedModel||"",effort:s?.effort||t?.selectedEffort||"",modelMode:"list"}}function pt(n,t){return n.providerId===t.providerId&&n.modelId.trim()===t.modelId.trim()&&(n.effort||"")===(t.effort||"")}function ht({agentId:n,agentStatus:t,boundInfo:a,copy:s,layer:l,toast:r,onSaved:d,onCancel:C,t:I}){const o=rt(n),v=t.nativeConfig||null,m=i.useMemo(()=>ft(n,t,a),[n,t,a]),[c,k]=i.useState(m),[b,E]=i.useState(!1),[H,D]=i.useState(null);i.useEffect(()=>{k(m),D(null)},[m]);const y=c.providerId===ue,x=y&&o,[p,f]=i.useState([]),[S,w]=i.useState(!1),[$,u]=i.useState(null);i.useEffect(()=>{if(y){f([]),u(null),w(!1);return}let j=!1;return w(!0),u(null),fetch(`/api/models/providers/${c.providerId}/models`).then(h=>h.json()).then(h=>{j||(h.ok?h.modelInfos&&h.modelInfos.length?f(h.modelInfos):f((h.models||[]).map(T=>({id:T}))):(u(h.error||"Failed to load models"),f([])))}).catch(h=>{j||(u(h?.message||String(h)),f([]))}).finally(()=>{j||w(!1)}),()=>{j=!0}},[c.providerId,y]);const L=i.useMemo(()=>p.map(j=>j.id),[p]),P=i.useMemo(()=>t.models.map(j=>j.id),[t]),V=y?P:L;i.useEffect(()=>{if(!S){if(y){c.modelMode==="custom"&&k(j=>({...j,modelMode:"list"}));return}V.length===0&&c.modelMode==="list"&&k(j=>({...j,modelMode:"custom"}))}},[V,S,c.modelMode,y]);const M=i.useMemo(()=>{const j=o?`${s.providerNativeFromAgent}${v?.provider?` · ${v.provider}`:""}`:s.providerNative,h=[{value:ue,label:j}];for(const T of l.providers)h.push({value:T.id,label:T.name});return h},[o,v,l.providers,s.providerNative,s.providerNativeFromAgent]),A=i.useMemo(()=>{const j=we[n]||we.claude;return[{value:"",label:s.effortDefault},...j.map(h=>({value:h,label:h}))]},[n,s.effortDefault]),R=i.useMemo(()=>{let j;return y?j=t.models.map(h=>{const T=h.alias?.toLowerCase().replace(/[\s_-]/g,""),Q=h.id.toLowerCase().replace(/[\s_-]/g,""),_=h.alias&&T!==Q;return{value:h.id,label:h.id,description:_?h.alias:void 0}}):j=p.map(h=>({value:h.id,...it(h)})),c.modelMode==="list"&&c.modelId&&!j.some(h=>h.value===c.modelId)&&j.unshift({value:c.modelId,label:c.modelId}),j},[y,t.models,p,c.modelMode,c.modelId]),z=!pt(c,m),B=!b&&z&&(x||!!c.modelId.trim()),W=i.useCallback(async()=>{D(null),E(!0);try{const j=c.effort||null,h=c.modelId.trim();if(y){const T=l.bindings[n],Q=T?l.profiles.find(_=>_.id===T):null;if(T&&await l.setActiveProfile(n,null),Q&&await fetch(`/api/models/profiles/${Q.id}`,{method:"DELETE"}),!o){const _={agent:n};if(h&&h!==(t.selectedModel||"")&&(_.model=h),j!==(t.selectedEffort||null)&&(_.effort=j),Object.keys(_).length>1){const J=await q.updateRuntimeAgent(_);if(!J.ok)throw new Error(J.error||"Failed to update agent")}}}else{const T=l.providers.find(F=>F.id===c.providerId);if(!T)throw new Error("Provider not found");const Q=ae(n),_=l.bindings[n],J=_?l.profiles.find(F=>F.id===_):null,de={providerId:T.id,modelId:h,effort:j,name:`${Q.label} · ${T.name}`};let le=J?.id;if(J){const F=await fetch(`/api/models/profiles/${J.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(de)}).then(se=>se.json());if(!F.ok)throw new Error(F.error||"Failed to update profile")}else{const F=await fetch("/api/models/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(de)}).then(se=>se.json());if(!F.ok)throw new Error(F.error||"Failed to create profile");le=F.profile?.id}le&&await l.setActiveProfile(n,le)}await Promise.resolve(d()),r(s.saved)}catch(j){const h=j?.message||String(j);D(h),r(`${s.configError}: ${h}`,!1)}finally{E(!1)}},[n,t,s,c,o,y,l,d,r]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx(G,{className:"!mb-1 text-[11px]",children:s.rowProvider}),e.jsx(oe,{value:c.providerId,options:M,onChange:j=>k(h=>{if(j===h.providerId)return h;const T={...h,providerId:j,modelId:"",modelMode:"list"};return j===ue&&(T.modelId=mt(t),T.effort=t.nativeSelectedEffort||t.nativeConfig?.effort||""),T})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx(G,{className:"!mb-0 text-[11px]",children:s.rowModel}),!x&&!y&&e.jsx("button",{type:"button",onClick:()=>k(j=>({...j,modelMode:j.modelMode==="list"?"custom":"list"})),className:"text-[10px] text-fg-5 underline-offset-2 transition hover:text-fg-3 hover:underline",children:c.modelMode==="list"?s.modelCustomToggle:s.modelListToggle})]}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"truncate font-mono",children:v?.model||s.noModel})}):c.modelMode==="list"?S&&!y?e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-5",children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),s.modelLoading]}):e.jsx(Fe,{value:c.modelId,options:R,onChange:j=>k(h=>({...h,modelId:j})),placeholder:V.length?"—":s.modelEmpty,searchPlaceholder:s.modelSearchPlaceholder,noMatchesText:s.modelSearchEmpty,currentLabel:s.modelCurrentLabel}):e.jsx(te,{value:c.modelId,onChange:j=>k(h=>({...h,modelId:j.target.value})),placeholder:s.modelCustomPlaceholder})]}),e.jsxs("div",{children:[e.jsx(G,{className:"!mb-1 text-[11px]",children:s.rowEffort}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"font-mono",children:v?.effort||s.effortDefault})}):e.jsx(oe,{value:c.effort,options:A,onChange:j=>k(h=>({...h,effort:j}))})]})]}),x&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:s.externalNativeNote(v?.configPath||"")}),(H||$)&&e.jsx("div",{className:"rounded-md border border-rose-700/40 bg-rose-900/20 px-3 py-2 text-xs text-rose-200",children:H||$}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:C,disabled:b,children:I("modal.cancel")}),e.jsxs(K,{variant:"primary",size:"sm",disabled:!B,onClick:()=>{W()},children:[b&&e.jsx(Z,{className:"h-3 w-3"}),b?s.saving:s.saveChanges]})]})]})}function gt(n,t,a){if(t)return{providerBrand:t.providerBrand,providerLabel:t.providerName,modelText:t.modelId||a.rowSummaryNoModel,effortText:t.effort||a.rowSummaryNoEffort};const s=n.nativeConfig||null,l=s?.provider||null;return{providerBrand:ot(l),providerLabel:a.rowSummaryNative,modelText:n.nativeSelectedModel||s?.model||n.selectedModel||a.rowSummaryNoModel,effortText:n.nativeSelectedEffort||s?.effort||n.selectedEffort||a.rowSummaryNoEffort}}function xt({agent:n,copy:t,t:a,installing:s,onInstall:l,updatingAgent:r,checkingAgent:d,onUpdate:C,onCheckUpdate:I,onEdit:o,loading:v=!1,boundInfo:m}){const c=ae(n.agent),k=c.advantageKey?a(c.advantageKey):"",b=n.installed?gt(n,m,t):null;return e.jsxs("div",{className:"glass rounded-md border border-edge px-3.5 py-2.5 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",title:k||void 0,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ne,{brand:n.agent,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[14px] font-semibold tracking-tight text-fg",children:c.label}),n.isDefault&&e.jsx(O,{variant:"accent",children:t.defaultBadge}),v?e.jsxs(O,{variant:"muted",children:[e.jsx(Z,{className:"h-3 w-3"})," ",a("status.loading")]}):n.installed?e.jsx(O,{variant:"ok",children:t.installed}):e.jsx(O,{variant:"muted",children:t.notInstalled}),n.installed&&n.updateAvailable&&e.jsx(O,{variant:"warn",children:t.updateAvailable}),n.installed&&n.version&&e.jsxs("span",{className:"text-[11px] font-mono text-fg-5",children:["v",n.version]}),n.latestVersion&&n.updateAvailable&&e.jsxs("span",{className:"text-[11px] text-amber-400",children:["→ ",n.latestVersion]})]}),b?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ne,{brand:b.providerBrand,size:11}),e.jsx("span",{className:"text-fg-3",children:b.providerLabel})]}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-mono text-fg-3",children:b.modelText}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{children:b.effortText})]}):k?e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-fg-5",children:k}):null]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[v&&e.jsx("div",{className:"inline-flex h-7 items-center gap-2 px-2 text-[11px] text-fg-5",children:e.jsx(Z,{className:"h-3 w-3"})}),!v&&!n.installed&&e.jsx(K,{variant:"primary",size:"sm",disabled:s,onClick:()=>l(n),children:s?t.installing:t.install}),!v&&n.installed&&n.updateAvailable&&e.jsx(K,{variant:"outline",size:"sm",disabled:r,onClick:()=>C(n),children:r?t.updating:t.update}),!v&&n.installed&&!n.updateAvailable&&e.jsx(K,{variant:"ghost",size:"icon",disabled:d,onClick:()=>I(n),title:t.checkUpdate,"aria-label":t.checkUpdate,className:"h-7 w-7",children:d?e.jsx(Z,{className:"h-3 w-3"}):e.jsx("span",{"aria-hidden":"true",children:"↻"})}),!v&&n.installed&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(n),children:t.configure})]})]}),!v&&n.installed&&n.updateAvailable&&n.updateStatus==="skipped"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-warn-text)"},children:[t.updateSkipped,": ",n.updateDetail]}),!v&&n.installed&&n.updateStatus==="failed"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-err-text)"},children:[t.updateFailed,": ",n.updateDetail]})]})}function Mt(){const n=Y(g=>g.locale),t=Y(g=>g.toast),a=Y(g=>g.agentStatus),s=Y(g=>g.setAgentStatus),l=Y(g=>g.refreshAgentStatus),r=i.useMemo(()=>De(n),[n]),d=i.useMemo(()=>ct(n),[n]),C=Re(),I=Be(),[o,v]=i.useState(a?{defaultAgent:a.defaultAgent,agents:a.agents}:null),[m,c]=i.useState(!a),[k,b]=i.useState(null),[E,H]=i.useState(!1),[D,y]=i.useState(null),[x,p]=i.useState(!1),[f,S]=i.useState("codex"),[w,$]=i.useState(null),[u,L]=i.useState(null),[P,V]=i.useState(null),M=i.useRef(!!a);i.useEffect(()=>{a&&(ye(v,a),M.current||(M.current=!0,c(!1)))},[a]);const A=i.useCallback(g=>{ye(v,g),s(g)},[s]),R=i.useCallback(async()=>{M.current||c(!0);try{const g=await q.getAgentStatus();return A(g),b(null),M.current=!0,g}catch(g){const N=g instanceof Error?g.message:d.loadFailed;return b(N),M.current||t(N,!1),null}finally{c(!1)}},[A,d.loadFailed,t]);i.useEffect(()=>{a?l():R()},[]);const z=i.useMemo(()=>{const g=o?.agents||[],N=new Map(g.map(U=>[U.agent,U]));return at.map(U=>{const Ne=N.get(U);if(Ne)return Ne;const Te=ae(U);return{agent:U,label:Te.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:o?.defaultAgent===U,models:[],usage:null}})},[o]),B=o?.defaultAgent||"codex",W=z.find(g=>g.agent===B)||null,h=z.filter(g=>g.installed).length>0,T=ut(z,d),Q=i.useCallback(async g=>{H(!0);try{const N=await q.updateRuntimeAgent(g);if(!N.ok)throw new Error(N.error||r("config.applyFailed"));return A(N),N}catch(N){const U=N instanceof Error?N.message:r("config.applyFailed");return t(U,!1),R(),null}finally{H(!1)}},[A,R,r,t]);i.useEffect(()=>{x&&S(B)},[B,x]);const _=i.useCallback(async()=>{if(f===B){p(!1);return}await Q({defaultAgent:f})&&(t(d.defaultsSaved),p(!1))},[d.defaultsSaved,B,f,t,Q]),J=i.useCallback(async g=>{if(!D){y(g.agent);try{const N=await q.installAgent(g.agent);if(!N.ok)throw new Error(N.error||r("config.agentInstallFailed"));A(N),t(r("config.agentInstalled"))}catch(N){const U=N instanceof Error?N.message:r("config.agentInstallFailed");t(U,!1),R()}finally{y(N=>N===g.agent?null:N)}}},[A,D,R,r,t]),de=i.useCallback(async g=>{if(!w){$(g.agent);try{const N=await q.updateAgent(g.agent);if(!N.ok)throw new Error(N.error||r("config.agentInstallFailed"));A(N),t(d.upToDate)}catch(N){const U=N instanceof Error?N.message:d.updateFailed;t(U,!1),R()}finally{$(N=>N===g.agent?null:N)}}},[A,d.updateFailed,d.upToDate,R,r,t,w]),le=i.useCallback(async g=>{if(!u){L(g.agent);try{const N=await q.checkAgentUpdate(g.agent);if(!N.ok)throw new Error(N.error||d.loadFailed);A(N)}catch(N){const U=N instanceof Error?N.message:d.loadFailed;t(U,!1),R()}finally{L(N=>N===g.agent?null:N)}}},[A,u,d.loadFailed,R,t]),F=m&&!o,se=F?r("status.loading"):W?ae(W.agent).label:d.notInstalled;F?r("status.loading"):W?.installed?d.installed:d.notInstalled;const je=i.useCallback(async()=>{await C.reload(),await R()},[C,R]),ee=P?z.find(g=>g.agent===P)??null:null,ce=ee?ae(ee.agent):null;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),F?e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-5",children:[e.jsx(Z,{className:"h-3 w-3"}),e.jsx("span",{children:d.defaultAgent})]}):e.jsxs("button",{type:"button",onClick:()=>p(!0),disabled:E||!h,title:d.editDefaults,className:"group inline-flex items-center gap-1.5 rounded-full border border-edge bg-panel-alt px-3 py-1 text-[12px] transition hover:border-edge-strong hover:bg-panel disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"text-fg-5 group-hover:text-fg-4",children:d.defaultAgent}),e.jsx(ne,{brand:B,size:14}),e.jsx("span",{className:"font-semibold text-fg-2",children:se}),e.jsx("svg",{className:"text-fg-6 transition group-hover:text-fg-3",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-2",children:z.map(g=>e.jsx(xt,{agent:g,copy:d,t:r,installing:D===g.agent,loading:F,onInstall:J,updatingAgent:w===g.agent,checkingAgent:u===g.agent,onUpdate:de,onCheckUpdate:le,onEdit:N=>V(N.agent),boundInfo:Se(C,g.agent)},g.agent))})]}),k&&e.jsx($e,{className:"border-amber-500/20 bg-amber-500/5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[13px] text-fg-2",children:k}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{R()},children:r("sessions.retry")})]})}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.modelsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.modelsHint})]})}),e.jsx(Ke,{snapshot:C,localBackends:I.backends})]}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.localTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.localHint})]})}),e.jsx(nt,{snapshot:I,onConnected:je})]}),e.jsx(me,{open:!!ee,onClose:()=>V(null),wide:!0,children:ee&&ce&&e.jsxs(e.Fragment,{children:[e.jsx(fe,{title:d.configModalTitle(ce.label),description:ce.advantageKey?r(ce.advantageKey):void 0,onClose:()=>V(null)}),e.jsx(ht,{agentId:ee.agent,agentStatus:ee,boundInfo:Se(C,ee.agent),copy:d,layer:C,toast:t,t:r,onSaved:async()=>{await je(),V(null)},onCancel:()=>V(null)})]})}),e.jsxs(me,{open:x,onClose:()=>p(!1),children:[e.jsx(fe,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>p(!1)}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(G,{children:d.defaultAgent}),e.jsx(oe,{value:f,options:T,onChange:g=>S(g),disabled:E||!h,placeholder:d.notInstalled})]})}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",onClick:()=>p(!1),children:r("modal.cancel")}),e.jsx(K,{variant:"primary",disabled:E||f===B,onClick:()=>{_()},children:r(E?"config.validating":"modal.save")})]})]})]})}export{Mt as AgentTab,Mt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./react-vendor-DTcmqLiz.js";import{c as g}from"./index-BS_RBT-T.js";const a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",h="/assets/codex-DYadqqp0.png",n="/assets/feishu-C4OMrjCW.ico",r="/assets/gemini-BYkEpiWr.svg",A="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3clinearGradient%20x1='50%25'%20y1='0%25'%20x2='50%25'%20y2='100%25'%20id='linearGradient-1'%3e%3cstop%20stop-color='%2338AEEB'%20offset='0%25'%3e%3c/stop%3e%3cstop%20stop-color='%23279AD1'%20offset='100%25'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='Artboard'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20id='Oval'%20fill='url(%23linearGradient-1)'%20cx='8'%20cy='8'%20r='8'%3e%3c/circle%3e%3cpath%20d='M3.17026167,7.83635602%20C5.78750201,6.74265999%207.53273882,6.02162863%208.40597211,5.67326193%20C10.8992306,4.67860423%2011.2454541,4.53439191%2011.5831299,4.52864956%20C11.6573986,4.52743168%2011.8385417,4.55776042%2011.9798438,4.67645833%20C12.1211458,4.79515625%2012.1635786,4.87206678%2012.1755371,4.93908691%20C12.1874957,5.00610705%2012.1862759,5.21456762%2012.1744385,5.3338623%20C12.0393279,6.69547283%2011.5259342,9.83829771%2011.2285121,11.3633248%20C11.1026617,12.008621%2010.8548582,12.2249854%2010.6149558,12.2461596%20C10.0935924,12.2921758%209.69769267,11.9156852%209.19272668,11.5981993%20C8.40255458,11.1013965%208.13911734,10.9180161%207.3721185,10.4332283%20C6.48571864,9.87297217%206.85080034,9.6784879%207.35595703,9.17524981%20C7.48815894,9.04355001%209.67825076,7.04590073%209.71077046,6.86250183%20C9.7391276,6.70257812%209.7494847,6.68189389%209.67664063,6.60973958%20C9.60379655,6.53758527%209.51674192,6.54658941%209.46083149,6.55876051%20C9.38158015,6.57601267%208.17521836,7.33962686%205.84174612,8.84960308%20C5.48344358,9.08558775%205.15890428,9.20056741%204.86812819,9.19454205%20C4.54757089,9.18789957%203.93094724,9.02070014%203.47255094,8.87778221%20C2.91030922,8.70248755%202.46345069,8.609808%202.50236203,8.31210343%20C2.52262946,8.15704047%202.74526267,7.998458%203.17026167,7.83635602%20Z'%20id='Path-3'%20fill='%23FFFFFF'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",w="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20d='M42%2033c-16.569%200-30%2011.64-30%2026%200%208.084%204.283%2015.306%2011.008%2020.073L18%2095l20.832-8.102A37.33%2037.33%200%200%200%2042%2087c16.569%200%2030-11.64%2030-26S58.569%2033%2042%2033Z'%20fill='%23fff'/%3e%3cpath%20d='M85%2048c-13.807%200-25%209.402-25%2021%200%2011.598%2011.193%2021%2025%2021%202.545%200%205-.319%207.29-.91L109%2095l-4.772-12.27C109.078%2079.05%20112%2074.232%20112%2069c0-11.598-12.193-21-27-21Z'%20fill='%23fff'%20opacity='.95'/%3e%3ccircle%20cx='33'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='50'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='77'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='92'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3c/svg%3e",d="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%234A154B'/%3e%3crect%20x='50'%20y='14'%20width='28'%20height='44'%20rx='14'%20fill='%232EB67D'/%3e%3crect%20x='70'%20y='50'%20width='44'%20height='28'%20rx='14'%20fill='%23ECB22E'/%3e%3crect%20x='50'%20y='70'%20width='28'%20height='44'%20rx='14'%20fill='%23E01E5A'/%3e%3crect%20x='14'%20y='50'%20width='44'%20height='28'%20rx='14'%20fill='%2336C5F0'/%3e%3c/svg%3e",x="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%235865F2'/%3e%3cpath%20fill='%23fff'%20d='M89.4%2036.9c-5.6-2.6-11.6-4.4-17.9-5.5l-.8%201.6c5.9%201%2011.2%202.6%2016.1%205-6-3-12.7-5-19.8-6-1.5-.2-2.9-.3-4.4-.4-.5%200-1%200-1.5%200s-1%200-1.5%200c-1.5%200-2.9.2-4.4.4-7.1%201-13.8%203-19.8%206%204.9-2.4%2010.2-4%2016.1-5l-.8-1.6C44.2%2032.5%2038.2%2034.3%2032.6%2036.9%2022%2053%2019%2068.7%2020.5%2084.3c8.1%206%2016%209.6%2023.7%2012%201.5-2.1%202.9-4.3%204.1-6.6-2.4-.9-4.6-2-6.8-3.3.6-.4%201.1-.9%201.7-1.3%2013.5%206.3%2028%206.3%2041.4%200%20.6.4%201.1.9%201.7%201.3-2.1%201.3-4.4%202.4-6.8%203.3%201.2%202.3%202.6%204.5%204.1%206.6%207.7-2.4%2015.6-6%2023.7-12%201.7-18.1-2.9-33.7-12.9-47.4ZM52.3%2074.8c-4.4%200-8-4.1-8-9.1s3.5-9.1%208-9.1c4.4%200%208%204.1%208%209.1s-3.6%209.1-8%209.1Zm23.5%200c-4.4%200-8-4.1-8-9.1s3.5-9.1%208-9.1c4.4%200%208%204.1%208%209.1s-3.5%209.1-8%209.1Z'/%3e%3c/svg%3e",f="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%231989FA'/%3e%3cpath%20fill='%23fff'%20d='M64.6%2026.5c-21%200-38%2017-38%2038%200%2021%2017%2038%2038%2038%206%200%2011.7-1.4%2016.7-3.9l21.3%204.6-7.6-19c4.6-5.7%207.4-12.9%207.4-20.7%200-21-17.1-37.9-37.8-37.9Zm-1.2%2053.8%205.5-13.6c-3.8.2-7.5.4-11.3.5L70.4%2049c-3.4%200-6.5.1-9.4.3l3.9-13.5h11.7l-3.8%2013.4c2.4-.1%204.6-.3%206.7-.5l-9.8%2017.6c4.6-.1%208.8-.3%2012.5-.6L63.4%2080.3Z'/%3e%3c/svg%3e",m="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20fill='%23fff'%20d='M32%2030h36c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H56l-14%2012%204-12h-14c-8%200-14-6-14-14V44c0-8%206-14%2014-14Z'/%3e%3cpath%20fill='%23fff'%20opacity='.55'%20d='M56%2054h32c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H80l-14%2012%204-12h-14c-8%200-14-6-14-14V68c0-8%206-14%2014-14Z'/%3e%3ccircle%20cx='44'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='60'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='72'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3ccircle%20cx='86'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3c/svg%3e",v="/assets/playwright-BldPFZgC.ico",C="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",L="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",B="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",y="/assets/hermes-BAarh-tH.png",u="/assets/openrouter-CsJ_bD5Q.ico",D="/assets/anthropic-BAdojD7P.ico",E="/assets/deepseek-BeYNZEk0.ico",F="/assets/qwen-xykkX0_y.png",b="/assets/doubao-DloFDuFR.png",z="data:image/png;base64,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",J="/assets/minimax-PuEGTfrF.ico",k="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='currentColor'%20aria-label='OpenAI'%3e%3cpath%20d='M22.282%209.821a5.985%205.985%200%200%200-.516-4.91%206.046%206.046%200%200%200-6.51-2.9A6.065%206.065%200%200%200%204.981%204.18a5.985%205.985%200%200%200-3.998%202.9%206.046%206.046%200%200%200%20.743%207.097%205.98%205.98%200%200%200%20.51%204.911%206.051%206.051%200%200%200%206.515%202.9A5.985%205.985%200%200%200%2013.26%2024a6.056%206.056%200%200%200%205.772-4.206%205.99%205.99%200%200%200%203.997-2.9%206.056%206.056%200%200%200-.747-7.073zM13.26%2022.43a4.476%204.476%200%200%201-2.876-1.04l.141-.081%204.779-2.758a.795.795%200%200%200%20.392-.681v-6.737l2.02%201.168a.071.071%200%200%201%20.038.052v5.583a4.504%204.504%200%200%201-4.494%204.494zM3.6%2018.304a4.47%204.47%200%200%201-.535-3.014l.142.085%204.783%202.759a.771.771%200%200%200%20.78%200l5.843-3.369v2.332a.08.08%200%200%201-.033.062L9.74%2019.95a4.5%204.5%200%200%201-6.14-1.646zM2.34%207.896a4.485%204.485%200%200%201%202.366-1.973V11.6a.766.766%200%200%200%20.388.677l5.815%203.355-2.02%201.168a.076.076%200%200%201-.071%200l-4.83-2.786A4.504%204.504%200%200%201%202.34%207.872zm16.597%203.855l-5.833-3.387L15.119%207.2a.076.076%200%200%201%20.071%200l4.83%202.791a4.494%204.494%200%200%201-.676%208.105v-5.678a.79.79%200%200%200-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776%200%200%200-.785%200L9.409%209.23V6.897a.066.066%200%200%201%20.028-.061l4.83-2.787a4.5%204.5%200%200%201%206.68%204.66zm-12.64%204.135l-2.02-1.164a.08.08%200%200%201-.038-.057V6.075a4.5%204.5%200%200%201%207.375-3.453l-.142.08L8.704%205.46a.795.795%200%200%200-.393.681zm1.097-2.365l2.602-1.5%202.607%201.5v3l-2.597%201.5-2.607-1.5z'/%3e%3c/svg%3e",I="/assets/ollama-Bt9O-2K_.png",P="/assets/lmstudio-syaFPWNA.png",Q={claude:a,codex:h,gemini:r,telegram:A,feishu:n,weixin:w,slack:d,discord:x,dingtalk:f,wecom:m,playwright:v,vscode:C,cursor:L,windsurf:p,finder:B,hermes:y,openrouter:u,anthropic:D,deepseek:E,google:r,qwen:F,doubao:b,glm:z,minimax:J,openai:k,ollama:I,lmstudio:P},N={custom:{letter:"+",color:"#94a3b8",bg:"rgba(148,163,184,0.12)"}};function Z({brand:t,size:e=18,className:l}){const i=Q[t];if(i)return s.jsx("img",{src:i,alt:"","aria-hidden":"true",draggable:!1,className:g("shrink-0 object-contain select-none",l),style:{width:e,height:e}});const c=N[t];if(!c)return null;const o=c.letter.length>1;return s.jsx("span",{"aria-hidden":"true",className:g("inline-flex shrink-0 items-center justify-center rounded-md font-semibold tracking-tight select-none",l),style:{width:e,height:e,background:c.bg,color:c.color,fontSize:Math.round(e*(o?.42:.55)),lineHeight:1,letterSpacing:o?"-0.02em":"normal"},children:c.letter})}export{Z as B};
|
|
1
|
+
import{j as s}from"./react-vendor-DTcmqLiz.js";import{c as g}from"./index-Cn_xngY_.js";const a="data:image/png;base64,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",h="/assets/codex-DYadqqp0.png",n="/assets/feishu-C4OMrjCW.ico",r="/assets/gemini-BYkEpiWr.svg",A="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3clinearGradient%20x1='50%25'%20y1='0%25'%20x2='50%25'%20y2='100%25'%20id='linearGradient-1'%3e%3cstop%20stop-color='%2338AEEB'%20offset='0%25'%3e%3c/stop%3e%3cstop%20stop-color='%23279AD1'%20offset='100%25'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='Artboard'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20id='Oval'%20fill='url(%23linearGradient-1)'%20cx='8'%20cy='8'%20r='8'%3e%3c/circle%3e%3cpath%20d='M3.17026167,7.83635602%20C5.78750201,6.74265999%207.53273882,6.02162863%208.40597211,5.67326193%20C10.8992306,4.67860423%2011.2454541,4.53439191%2011.5831299,4.52864956%20C11.6573986,4.52743168%2011.8385417,4.55776042%2011.9798438,4.67645833%20C12.1211458,4.79515625%2012.1635786,4.87206678%2012.1755371,4.93908691%20C12.1874957,5.00610705%2012.1862759,5.21456762%2012.1744385,5.3338623%20C12.0393279,6.69547283%2011.5259342,9.83829771%2011.2285121,11.3633248%20C11.1026617,12.008621%2010.8548582,12.2249854%2010.6149558,12.2461596%20C10.0935924,12.2921758%209.69769267,11.9156852%209.19272668,11.5981993%20C8.40255458,11.1013965%208.13911734,10.9180161%207.3721185,10.4332283%20C6.48571864,9.87297217%206.85080034,9.6784879%207.35595703,9.17524981%20C7.48815894,9.04355001%209.67825076,7.04590073%209.71077046,6.86250183%20C9.7391276,6.70257812%209.7494847,6.68189389%209.67664063,6.60973958%20C9.60379655,6.53758527%209.51674192,6.54658941%209.46083149,6.55876051%20C9.38158015,6.57601267%208.17521836,7.33962686%205.84174612,8.84960308%20C5.48344358,9.08558775%205.15890428,9.20056741%204.86812819,9.19454205%20C4.54757089,9.18789957%203.93094724,9.02070014%203.47255094,8.87778221%20C2.91030922,8.70248755%202.46345069,8.609808%202.50236203,8.31210343%20C2.52262946,8.15704047%202.74526267,7.998458%203.17026167,7.83635602%20Z'%20id='Path-3'%20fill='%23FFFFFF'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",w="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20d='M42%2033c-16.569%200-30%2011.64-30%2026%200%208.084%204.283%2015.306%2011.008%2020.073L18%2095l20.832-8.102A37.33%2037.33%200%200%200%2042%2087c16.569%200%2030-11.64%2030-26S58.569%2033%2042%2033Z'%20fill='%23fff'/%3e%3cpath%20d='M85%2048c-13.807%200-25%209.402-25%2021%200%2011.598%2011.193%2021%2025%2021%202.545%200%205-.319%207.29-.91L109%2095l-4.772-12.27C109.078%2079.05%20112%2074.232%20112%2069c0-11.598-12.193-21-27-21Z'%20fill='%23fff'%20opacity='.95'/%3e%3ccircle%20cx='33'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='50'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='77'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='92'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3c/svg%3e",d="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%234A154B'/%3e%3crect%20x='50'%20y='14'%20width='28'%20height='44'%20rx='14'%20fill='%232EB67D'/%3e%3crect%20x='70'%20y='50'%20width='44'%20height='28'%20rx='14'%20fill='%23ECB22E'/%3e%3crect%20x='50'%20y='70'%20width='28'%20height='44'%20rx='14'%20fill='%23E01E5A'/%3e%3crect%20x='14'%20y='50'%20width='44'%20height='28'%20rx='14'%20fill='%2336C5F0'/%3e%3c/svg%3e",x="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%235865F2'/%3e%3cpath%20fill='%23fff'%20d='M89.4%2036.9c-5.6-2.6-11.6-4.4-17.9-5.5l-.8%201.6c5.9%201%2011.2%202.6%2016.1%205-6-3-12.7-5-19.8-6-1.5-.2-2.9-.3-4.4-.4-.5%200-1%200-1.5%200s-1%200-1.5%200c-1.5%200-2.9.2-4.4.4-7.1%201-13.8%203-19.8%206%204.9-2.4%2010.2-4%2016.1-5l-.8-1.6C44.2%2032.5%2038.2%2034.3%2032.6%2036.9%2022%2053%2019%2068.7%2020.5%2084.3c8.1%206%2016%209.6%2023.7%2012%201.5-2.1%202.9-4.3%204.1-6.6-2.4-.9-4.6-2-6.8-3.3.6-.4%201.1-.9%201.7-1.3%2013.5%206.3%2028%206.3%2041.4%200%20.6.4%201.1.9%201.7%201.3-2.1%201.3-4.4%202.4-6.8%203.3%201.2%202.3%202.6%204.5%204.1%206.6%207.7-2.4%2015.6-6%2023.7-12%201.7-18.1-2.9-33.7-12.9-47.4ZM52.3%2074.8c-4.4%200-8-4.1-8-9.1s3.5-9.1%208-9.1c4.4%200%208%204.1%208%209.1s-3.6%209.1-8%209.1Zm23.5%200c-4.4%200-8-4.1-8-9.1s3.5-9.1%208-9.1c4.4%200%208%204.1%208%209.1s-3.5%209.1-8%209.1Z'/%3e%3c/svg%3e",f="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%231989FA'/%3e%3cpath%20fill='%23fff'%20d='M64.6%2026.5c-21%200-38%2017-38%2038%200%2021%2017%2038%2038%2038%206%200%2011.7-1.4%2016.7-3.9l21.3%204.6-7.6-19c4.6-5.7%207.4-12.9%207.4-20.7%200-21-17.1-37.9-37.8-37.9Zm-1.2%2053.8%205.5-13.6c-3.8.2-7.5.4-11.3.5L70.4%2049c-3.4%200-6.5.1-9.4.3l3.9-13.5h11.7l-3.8%2013.4c2.4-.1%204.6-.3%206.7-.5l-9.8%2017.6c4.6-.1%208.8-.3%2012.5-.6L63.4%2080.3Z'/%3e%3c/svg%3e",m="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20fill='%23fff'%20d='M32%2030h36c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H56l-14%2012%204-12h-14c-8%200-14-6-14-14V44c0-8%206-14%2014-14Z'/%3e%3cpath%20fill='%23fff'%20opacity='.55'%20d='M56%2054h32c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H80l-14%2012%204-12h-14c-8%200-14-6-14-14V68c0-8%206-14%2014-14Z'/%3e%3ccircle%20cx='44'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='60'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='72'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3ccircle%20cx='86'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3c/svg%3e",v="/assets/playwright-BldPFZgC.ico",C="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",L="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",B="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",y="/assets/hermes-BAarh-tH.png",u="/assets/openrouter-CsJ_bD5Q.ico",D="/assets/anthropic-BAdojD7P.ico",E="/assets/deepseek-BeYNZEk0.ico",F="/assets/qwen-xykkX0_y.png",b="/assets/doubao-DloFDuFR.png",z="data:image/png;base64,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",J="/assets/minimax-PuEGTfrF.ico",k="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='currentColor'%20aria-label='OpenAI'%3e%3cpath%20d='M22.282%209.821a5.985%205.985%200%200%200-.516-4.91%206.046%206.046%200%200%200-6.51-2.9A6.065%206.065%200%200%200%204.981%204.18a5.985%205.985%200%200%200-3.998%202.9%206.046%206.046%200%200%200%20.743%207.097%205.98%205.98%200%200%200%20.51%204.911%206.051%206.051%200%200%200%206.515%202.9A5.985%205.985%200%200%200%2013.26%2024a6.056%206.056%200%200%200%205.772-4.206%205.99%205.99%200%200%200%203.997-2.9%206.056%206.056%200%200%200-.747-7.073zM13.26%2022.43a4.476%204.476%200%200%201-2.876-1.04l.141-.081%204.779-2.758a.795.795%200%200%200%20.392-.681v-6.737l2.02%201.168a.071.071%200%200%201%20.038.052v5.583a4.504%204.504%200%200%201-4.494%204.494zM3.6%2018.304a4.47%204.47%200%200%201-.535-3.014l.142.085%204.783%202.759a.771.771%200%200%200%20.78%200l5.843-3.369v2.332a.08.08%200%200%201-.033.062L9.74%2019.95a4.5%204.5%200%200%201-6.14-1.646zM2.34%207.896a4.485%204.485%200%200%201%202.366-1.973V11.6a.766.766%200%200%200%20.388.677l5.815%203.355-2.02%201.168a.076.076%200%200%201-.071%200l-4.83-2.786A4.504%204.504%200%200%201%202.34%207.872zm16.597%203.855l-5.833-3.387L15.119%207.2a.076.076%200%200%201%20.071%200l4.83%202.791a4.494%204.494%200%200%201-.676%208.105v-5.678a.79.79%200%200%200-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776%200%200%200-.785%200L9.409%209.23V6.897a.066.066%200%200%201%20.028-.061l4.83-2.787a4.5%204.5%200%200%201%206.68%204.66zm-12.64%204.135l-2.02-1.164a.08.08%200%200%201-.038-.057V6.075a4.5%204.5%200%200%201%207.375-3.453l-.142.08L8.704%205.46a.795.795%200%200%200-.393.681zm1.097-2.365l2.602-1.5%202.607%201.5v3l-2.597%201.5-2.607-1.5z'/%3e%3c/svg%3e",I="/assets/ollama-Bt9O-2K_.png",P="/assets/lmstudio-syaFPWNA.png",Q={claude:a,codex:h,gemini:r,telegram:A,feishu:n,weixin:w,slack:d,discord:x,dingtalk:f,wecom:m,playwright:v,vscode:C,cursor:L,windsurf:p,finder:B,hermes:y,openrouter:u,anthropic:D,deepseek:E,google:r,qwen:F,doubao:b,glm:z,minimax:J,openai:k,ollama:I,lmstudio:P},N={custom:{letter:"+",color:"#94a3b8",bg:"rgba(148,163,184,0.12)"}};function Z({brand:t,size:e=18,className:l}){const i=Q[t];if(i)return s.jsx("img",{src:i,alt:"","aria-hidden":"true",draggable:!1,className:g("shrink-0 object-contain select-none",l),style:{width:e,height:e}});const c=N[t];if(!c)return null;const o=c.letter.length>1;return s.jsx("span",{"aria-hidden":"true",className:g("inline-flex shrink-0 items-center justify-center rounded-md font-semibold tracking-tight select-none",l),style:{width:e,height:e,background:c.bg,color:c.color,fontSize:Math.round(e*(o?.42:.55)),lineHeight:1,letterSpacing:o?"-0.02em":"normal"},children:c.letter})}export{Z as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-
|
|
1
|
+
import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-Cn_xngY_.js";function W({initialPath:x,maxHeight:j=420,minHeight:N=200,onSelect:p,compact:l,t:o}){const[y,k]=r.useState(""),[h,m]=r.useState(""),[g,w]=r.useState([]),[i,S]=r.useState(""),[C,$]=r.useState(!1),[D,B]=r.useState([]),[E,c]=r.useState(!1),[u,d]=r.useState(""),a=r.useCallback(async t=>{c(!0),d("");try{const s=await I.lsDir(t);if(!s.ok){d(s.error||o("modal.cannotRead")),c(!1);return}k(s.path),m(s.path),w(s.dirs),S(s.parent),$(s.isGit);const G=s.path.split("/").filter(Boolean);let v="";B(G.map(b=>(v+="/"+b,{label:b,path:v}))),p?.(s.path,s.isGit)}catch{d(o("modal.loadFailed"))}finally{c(!1)}},[o,p]);r.useEffect(()=>{x!==void 0&&a(x||void 0)},[]);const n=l?"text-[11px]":"text-xs",f=l?"py-[5px]":"py-[7px]";return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1 ${l?"text-[10px]":"text-[11px]"} font-mono text-fg-4 mb-2 flex-wrap`,children:[e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a("/"),children:"~"}),D.map((t,s)=>e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-6",children:"/"}),e.jsx("span",{className:"cursor-pointer hover:text-fg-2 transition-colors",onClick:()=>a(t.path),children:t.label})]},s)),C&&e.jsx(P,{variant:"accent",className:"ml-1 !text-[9px] !py-0 !px-1.5",children:"git"})]}),e.jsxs("div",{className:"relative",children:[!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-5 rounded-t-lg",style:{background:"linear-gradient(to bottom, var(--th-panel-alt), rgba(0, 0, 0, 0))"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-5 rounded-b-lg",style:{background:"linear-gradient(to top, var(--th-panel-alt), rgba(0, 0, 0, 0))"}})]}),e.jsx("div",{className:"border border-edge rounded-lg overflow-y-auto overscroll-contain scroll-smooth bg-panel-alt",style:{maxHeight:j,minHeight:N,scrollbarGutter:"stable"},children:E?e.jsx("div",{className:`${n} text-fg-5 p-4 text-center flex items-center justify-center gap-2`,children:e.jsx(z,{className:"h-3 w-3 text-fg-5"})}):u?e.jsx("div",{className:`${n} text-red-500/70 p-4`,children:u}):e.jsxs(e.Fragment,{children:[i&&i!==y&&e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors border-b border-edge`,onClick:()=>a(i),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),e.jsx("span",{className:`${n} text-fg-4`,children:".."})]}),g.length===0&&!i&&e.jsx("div",{className:`${n} text-fg-5 p-4 text-center`,children:o("modal.emptyDir")}),g.map(t=>e.jsxs("div",{className:`flex items-center gap-2 px-3 ${f} cursor-pointer hover:bg-panel transition-colors`,onClick:()=>a(t.path),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:t.name===".git"?"var(--th-primary)":"currentColor",strokeWidth:"1.8",className:"text-fg-5 shrink-0",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{className:`${n} text-fg-3`,children:t.name})]},t.path))]})})]}),e.jsx("div",{className:"mt-2",children:e.jsx("input",{className:`w-full rounded-lg border border-edge bg-inset px-2.5 py-1.5 ${n} font-mono text-fg outline-none placeholder:text-fg-5 focus:border-edge-h transition-colors`,placeholder:o("modal.manualInput"),value:h,onChange:t=>m(t.target.value),onKeyDown:t=>{t.key==="Enter"&&a(h)}})})]})}export{W as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,j as e}from"./react-vendor-DTcmqLiz.js";import{u as G,T as fe,m as ge,c as B,a as _,o as Q,S as P,B as z}from"./index-Cn_xngY_.js";import{B as ve}from"./BrandIcon-BeVfjldz.js";import{M as q,a as K,I as T}from"./Modal-at8vOOy7.js";import"./router-Cav8lq-m.js";function a(s,t,n){return s==="zh-CN"?t:n}function le(s,t){return t.type==="mcp-oauth"?a(s,"OAuth","OAuth"):t.type==="credentials"?a(s,"API Key","API Key"):a(s,"无需配置","No auth")}const je={github:{hex:"#24292f",letter:"GH"},atlassian:{hex:"#0052cc",letter:"A"},notion:{hex:"#111827",letter:"N"},linear:{hex:"#5e6ad2",letter:"L"},sentry:{hex:"#362d59",letter:"S"},cloudflare:{hex:"#f6821f",letter:"CF"},gamma:{hex:"#9f2eff",letter:"G"},huggingface:{hex:"#ff9d00",letter:"HF"},slack:{hex:"#4a154b",letter:"S"},lark:{hex:"#00d6b9",letter:"L"},feishu:{hex:"#00d6b9",letter:"F"},stripe:{hex:"#635bff",letter:"S"},perplexity:{hex:"#20b8cd",letter:"P"},brave:{hex:"#fb542b",letter:"B"},filesystem:{hex:"#64748b",letter:"FS"},fetch:{hex:"#0ea5e9",letter:"F"},memory:{hex:"#a855f7",letter:"M"},time:{hex:"#10b981",letter:"T"},sqlite:{hex:"#0369a1",letter:"SQ"},postgres:{hex:"#336791",letter:"PG"}},be={hex:"#6b7280"};function W(s,t){const n=(s||"").toLowerCase(),i=je[n]||be,l=i.letter||(t||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,2).toUpperCase()||"?";return{hex:i.hex,letter:l}}function E(s,t){const n=s.replace("#",""),i=n.length===3?n.split("").map(u=>u+u).join(""):n.padEnd(6,"0").slice(0,6),l=parseInt(i.slice(0,2),16),c=parseInt(i.slice(2,4),16),x=parseInt(i.slice(4,6),16);return`rgba(${l}, ${c}, ${x}, ${t})`}function X(s,t,n=[]){const[i,l]=o.useState(()=>{try{const p=localStorage.getItem(s);return p?JSON.parse(p):null}catch{return null}}),[c,x]=o.useState(!1),u=o.useRef(!0);o.useEffect(()=>()=>{u.current=!1},[]);const h=o.useCallback(async()=>{x(!0);try{const p=await t();if(!u.current)return;l(p);try{localStorage.setItem(s,JSON.stringify(p))}catch{}}finally{u.current&&x(!1)}},[s,...n]);return o.useEffect(()=>{h()},[h]),{data:i,loading:c,refresh:h}}const U=()=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Z=({size:s=12})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),ye=({size:s=12})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18.36 6.64a9 9 0 1 1-12.73 0"}),e.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"12"})]}),ie=({size:s=12})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),Ne=({size:s=12})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),oe=new Set(["claude","codex","gemini","telegram","feishu","weixin","playwright","vscode","cursor","windsurf","finder"]),ke={github:"logos:github-icon",atlassian:"logos:atlassian",notion:"logos:notion-icon",linear:"logos:linear-icon",sentry:"logos:sentry-icon",cloudflare:"logos:cloudflare-icon","cloudflare-docs":"logos:cloudflare-icon","cloudflare-bindings":"logos:cloudflare-icon","cloudflare-observability":"logos:cloudflare-icon",slack:"logos:slack-icon",lark:"icon-park:lark",feishu:"icon-park:lark",stripe:"logos:stripe",perplexity:"logos:perplexity-icon",brave:"logos:brave","brave-search":"logos:brave",huggingface:"logos:hugging-face-icon",postgres:"logos:postgresql",postgresql:"logos:postgresql",sqlite:"logos:sqlite",vercel:"logos:vercel-icon",netlify:"logos:netlify-icon",supabase:"logos:supabase-icon",heroku:"logos:heroku-icon",docker:"logos:docker-icon",pnpm:"logos:pnpm",aws:"logos:aws","google-cloud":"logos:google-cloud",googlecloud:"logos:google-cloud",amazonwebservices:"logos:aws"},we=new Set(["stripe"]);function Ce(s,t){if(t)return t;if(!s||oe.has(s))return;const n=ke[s];if(n)return`https://api.iconify.design/${n}.svg`}function F({iconSlug:s,iconUrl:t,name:n,size:i=32,className:l}){const{hex:c,letter:x}=W(s,n),[u,h]=o.useState(!1),p=Ce(s,t),b=s&&oe.has(s),d=b||!!p&&!u,v=!!s&&we.has(s),m=Math.round(i*(v?.92:.76));return d?e.jsxs("div",{className:B("relative flex shrink-0 items-center justify-center overflow-hidden rounded-xl bg-white",l),style:{width:i,height:i,boxShadow:`0 0 0 1px ${E(c,.18)}, 0 4px 12px ${E(c,.14)}`},children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{background:`linear-gradient(135deg, ${E(c,.06)} 0%, transparent 70%)`}}),b?e.jsx(ve,{brand:s,size:m}):e.jsx("img",{src:p,alt:"",width:m,height:m,loading:"lazy",decoding:"async",onError:()=>h(!0),className:"relative"})]}):e.jsxs("div",{className:B("relative flex shrink-0 items-center justify-center overflow-hidden rounded-xl font-semibold text-white",l),style:{width:i,height:i,background:`linear-gradient(135deg, ${E(c,1)} 0%, ${E(c,.82)} 100%)`,boxShadow:`0 1px 0 rgba(255,255,255,0.08) inset, 0 6px 14px ${E(c,.28)}`,fontSize:Math.max(10,Math.round(i*.36)),letterSpacing:x.length>1?"-0.02em":0},children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at 30% 20%, rgba(255,255,255,0.22), transparent 55%)"}}),e.jsx("span",{className:"relative",children:x})]})}function Se({state:s,locale:t}){return s==="ready"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-[var(--th-ok)]",style:{background:"color-mix(in oklab, var(--th-ok) 12%, transparent)"},children:[e.jsx(Z,{size:10}),a(t,"已连接","Connected")]}):s==="disabled"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-edge bg-inset/60 px-2 py-0.5 text-[10px] font-medium text-fg-5",children:[e.jsx(ye,{size:10}),a(t,"已停用","Paused")]}):s==="needs_auth"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-[var(--th-warn)]",style:{background:"color-mix(in oklab, var(--th-warn) 12%, transparent)"},children:[e.jsx(ie,{size:10}),a(t,"待授权","Needs auth")]}):s==="unhealthy"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-[var(--th-err)]",style:{background:"color-mix(in oklab, var(--th-err) 12%, transparent)"},children:[e.jsx(Ne,{size:10}),a(t,"异常","Unhealthy")]}):null}function Ie({open:s,onClose:t,locale:n,item:i,initial:l,onSubmit:c}){const[x,u]=o.useState({}),[h,p]=o.useState(!1);if(o.useEffect(()=>{if(s&&i&&i.auth.type==="credentials"){const d={};for(const v of i.auth.fields)d[v.key]=l?.[v.key]||"";u(d)}},[s,i,l]),!i||i.auth.type!=="credentials")return null;const b=i.auth.fields.some(d=>d.required&&!(x[d.key]||"").trim()),y=async()=>{p(!0);try{await c(x)}finally{p(!1)}};return e.jsxs(q,{open:s,onClose:t,children:[e.jsx(K,{title:a(n,`配置 ${i.name}`,`Configure ${i.name}`),description:n==="zh-CN"?i.descriptionZh:i.description,onClose:t}),e.jsxs("div",{className:"space-y-3",children:[i.auth.fields.map(d=>e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:[n==="zh-CN"?d.labelZh:d.label,d.required&&e.jsx("span",{className:"ml-1 text-err",children:"*"})]}),d.helpUrl&&e.jsxs("a",{href:d.helpUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[11px] text-primary hover:text-primary/80",children:[a(n,"获取","Get one")," ",e.jsx(U,{})]})]}),e.jsx(T,{value:x[d.key]||"",onChange:v=>u({...x,[d.key]:v.target.value}),type:d.secret?"password":"text",placeholder:d.placeholder,className:"font-mono text-[12px]"})]},d.key)),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-edge pt-3",children:[e.jsx(z,{variant:"ghost",onClick:t,children:a(n,"取消","Cancel")}),e.jsx(z,{variant:"primary",disabled:h||b,onClick:y,children:h?e.jsx(P,{}):a(n,"保存并启用","Save & Enable")})]})]})]})}function ze({open:s,onClose:t,locale:n,scope:i,workdir:l,onAdded:c}){const x=G(f=>f.toast),[u,h]=o.useState(""),[p,b]=o.useState("stdio"),[y,d]=o.useState("npx"),[v,m]=o.useState(""),[S,$]=o.useState(""),[A,I]=o.useState([]),[L,j]=o.useState(!1);o.useEffect(()=>{s&&(h(""),b("stdio"),d("npx"),m(""),$(""),I([]))},[s]);const w=async()=>{if(u.trim()){j(!0);try{const f={};for(const{k:C,v:M}of A)C.trim()&&(f[C.trim()]=M);const N=p==="http"?{type:"http",url:S.trim(),enabled:!0,...Object.keys(f).length?{headers:f}:{}}:{type:"stdio",command:y.trim(),args:v.trim()?v.trim().split(/\s+/):[],enabled:!0,...Object.keys(f).length?{env:f}:{}};await _.addCustomMcp(u.trim(),N,i,l),x(a(n,`${u} 已添加`,`${u} added`),!0),c(),t()}catch(f){x(f?.message||"Failed",!1)}finally{j(!1)}}};return e.jsxs(q,{open:s,onClose:t,wide:!0,children:[e.jsx(K,{title:a(n,"添加自定义 MCP 服务","Add Custom MCP Server"),description:a(n,"不在推荐列表中的自定义服务。","For servers not in the recommended catalog."),onClose:t}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"名称","Name")}),e.jsx(T,{value:u,onChange:f=>h(f.target.value),placeholder:"my-server"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"传输","Transport")}),e.jsx("div",{className:"flex gap-1.5",children:["stdio","http"].map(f=>e.jsx("button",{onClick:()=>b(f),className:B("flex-1 rounded-md border px-3 py-1.5 text-[12px] font-medium transition-colors",p===f?"border-primary/40 bg-primary/10 text-primary":"border-edge bg-inset/50 text-fg-4 hover:bg-inset"),children:f},f))})]})]}),p==="stdio"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"命令","Command")}),e.jsx(T,{value:y,onChange:f=>d(f.target.value),className:"font-mono",placeholder:"npx"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"参数","Arguments")}),e.jsx(T,{value:v,onChange:f=>m(f.target.value),className:"font-mono",placeholder:"-y @example/server"})]})]}):e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:"URL"}),e.jsx(T,{value:S,onChange:f=>$(f.target.value),className:"font-mono",placeholder:"https://example.com/mcp"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:p==="http"?a(n,"Headers","Headers"):a(n,"环境变量","Env")}),e.jsxs("button",{className:"text-[11px] font-medium text-primary hover:text-primary/80",onClick:()=>I([...A,{k:"",v:""}]),children:["+ ",a(n,"添加","Add")]})]}),A.length>0&&e.jsx("div",{className:"space-y-1 rounded-md border border-edge bg-inset/40 p-2",children:A.map((f,N)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{className:"w-2/5 !h-7 !text-[12px] font-mono",value:f.k,onChange:C=>{const M=[...A];M[N]={...M[N],k:C.target.value},I(M)},placeholder:"KEY"}),e.jsx(T,{className:"flex-1 !h-7 !text-[12px] font-mono",value:f.v,onChange:C=>{const M=[...A];M[N]={...M[N],v:C.target.value},I(M)},type:/token|secret|key|bearer/i.test(f.k)?"password":"text",placeholder:"value"}),e.jsx("button",{className:"shrink-0 rounded p-1 text-fg-5 hover:text-err",onClick:()=>I(A.filter((C,M)=>M!==N)),children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},N))})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-edge pt-3",children:[e.jsx(z,{variant:"ghost",onClick:t,children:a(n,"取消","Cancel")}),e.jsx(z,{variant:"primary",disabled:!u.trim()||L,onClick:w,children:L?e.jsx(P,{}):a(n,"添加","Add")})]})]})]})}function Le({open:s,onClose:t,locale:n,scope:i,workdir:l,onInstalled:c}){const x=G(m=>m.toast),[u,h]=o.useState(""),[p,b]=o.useState(""),[y,d]=o.useState(!1);o.useEffect(()=>{s&&(h(""),b(""))},[s]);const v=async()=>{if(u.trim()){d(!0);try{const m=await _.installSkill(u.trim(),i==="global",p.trim()||void 0,l);m.ok?(x(a(n,"技能安装成功","Skill installed"),!0),c(),t()):x(m.error||"Failed",!1)}catch(m){x(m?.message||"Failed",!1)}finally{d(!1)}}};return e.jsxs(q,{open:s,onClose:t,children:[e.jsx(K,{title:a(n,"安装自定义技能","Install Custom Skill"),description:a(n,"通过 npx skills add 从 GitHub 仓库安装。","Installs via npx skills add from a GitHub repo."),onClose:t}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"GitHub 来源","GitHub Source")}),e.jsx(T,{value:u,onChange:m=>h(m.target.value),placeholder:"owner/repo",className:"font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:a(n,"指定技能(可选)","Specific skill (optional)")}),e.jsx(T,{value:p,onChange:m=>b(m.target.value),placeholder:a(n,"留空安装全部","Leave empty for all")})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-edge pt-3",children:[e.jsx(z,{variant:"ghost",onClick:t,children:a(n,"取消","Cancel")}),e.jsx(z,{variant:"primary",disabled:!u.trim()||y,onClick:v,children:y?e.jsx(P,{}):a(n,"安装","Install")})]})]})]})}function Me(s,t){return new Promise(n=>{const i=window.open(s,"pikiclaw_mcp_oauth","width=640,height=780,noopener=no");if(!i){n(!1);return}let l=!1;const c=h=>{l||(l=!0,window.removeEventListener("message",x),clearInterval(u),n(h))},x=h=>{const p=h.data;if(!(!p||p.type!=="mcp-oauth")&&!(t&&p.state!==t)){c(!!p.ok);try{i.close()}catch{}}};window.addEventListener("message",x);const u=setInterval(()=>{i.closed&&c(!1)},500)})}function ae({item:s,locale:t,busy:n,index:i,onPrimary:l,onRemove:c,onReauth:x,onReconfigure:u}){const{hex:h}=W(s.iconSlug,s.name),p=(()=>{switch(s.state){case"ready":return a(t,"停用","Pause");case"unhealthy":return a(t,"停用","Pause");case"disabled":return a(t,"启用","Enable");case"needs_auth":return s.auth.type==="mcp-oauth"?a(t,"授权","Authorize"):a(t,"配置","Configure");default:return a(t,"启用","Enable")}})(),b={background:`linear-gradient(140deg, ${E(h,.05)} 0%, ${E(h,.01)} 60%, transparent 100%)`,borderColor:E(h,.18),animationDelay:`${Math.min(i,8)*40}ms`};return e.jsxs("div",{className:B("group relative overflow-hidden rounded-xl border p-4","transition-[transform,box-shadow,border-color] duration-200","hover:-translate-y-0.5 hover:shadow-[0_12px_28px_rgba(15,23,42,0.09)]","animate-in-up"),style:b,children:[e.jsx("div",{className:"pointer-events-none absolute -right-12 -top-12 h-32 w-32 rounded-full opacity-40 blur-2xl transition-opacity duration-300 group-hover:opacity-60",style:{background:E(h,.35)}}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx(F,{iconSlug:s.iconSlug,iconUrl:s.iconUrl,name:s.name,size:36}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold text-fg",children:s.name}),s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-fg-3 transition-colors",children:e.jsx(U,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[12px] leading-snug text-fg-4",children:t==="zh-CN"?s.descriptionZh:s.description})]}),e.jsx(Se,{state:s.state,locale:t})]}),e.jsxs("div",{className:"relative mt-3 flex items-center justify-between border-t border-edge/60 pt-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-fg-5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{background:h,opacity:.8}}),le(t,s.auth)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[s.installed&&s.state!=="needs_auth"&&x&&e.jsx(z,{variant:"ghost",size:"sm",onClick:x,disabled:n,children:a(t,"重新授权","Re-auth")}),s.installed&&s.state!=="needs_auth"&&u&&e.jsx(z,{variant:"ghost",size:"sm",onClick:u,disabled:n,children:a(t,"编辑","Edit")}),e.jsx(z,{variant:s.state==="disabled"||s.state==="needs_auth"?"primary":"ghost",size:"sm",onClick:l,disabled:n,children:n?e.jsx(P,{}):p}),s.installed&&c&&e.jsx(z,{variant:"ghost",size:"sm",onClick:c,disabled:n,className:"hover:!text-err",children:a(t,"移除","Remove")})]})]})]})}function re({item:s,locale:t,busy:n,index:i,onPrimary:l}){const c=s.auth.type==="none"?a(t,"一键启用","One-click enable"):a(t,"授权并启用","Authorize & enable");return e.jsxs("div",{className:B("group relative flex flex-col gap-3 rounded-xl border border-edge bg-panel-alt p-4","transition-[transform,box-shadow,border-color] duration-200","hover:-translate-y-0.5 hover:border-edge-h hover:shadow-[0_12px_28px_rgba(15,23,42,0.09)]","animate-in-up"),style:{animationDelay:`${Math.min(i,12)*30}ms`},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(F,{iconSlug:s.iconSlug,iconUrl:s.iconUrl,name:s.name,size:32}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[13.5px] font-semibold text-fg",children:s.name}),s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-fg-3 transition-colors",children:e.jsx(U,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[12px] leading-snug text-fg-4",children:t==="zh-CN"?s.descriptionZh:s.description})]})]}),e.jsxs("div",{className:"mt-auto flex items-center justify-between",children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] text-fg-5",children:le(t,s.auth)}),e.jsx(z,{variant:"outline",size:"sm",onClick:l,disabled:n,className:"group-hover:border-edge-h",children:n?e.jsx(P,{}):c})]})]})}function _e(s,t){const n=s.installedNames.length;if(typeof s.totalCount=="number"){const i=s.partial?`${s.totalCount}+`:String(s.totalCount);return t==="zh-CN"?`${n} / ${i} 已安装`:`${n} / ${i} installed`}return n>0?t==="zh-CN"?`${n} 已安装`:`${n} installed`:a(t,"未安装","Not installed")}function $e({item:s,locale:t,animationDelay:n,onClick:i}){const{hex:l}=W(void 0,s.name);return e.jsxs("button",{type:"button",onClick:i,className:"animate-in-up group relative flex min-h-[112px] w-full flex-col overflow-hidden rounded-2xl border border-edge/70 bg-panel p-4 text-left transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_12px_28px_rgba(15,23,42,0.09)] focus-visible:outline-none focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",style:{background:`linear-gradient(135deg, ${E(l,.06)} 0%, ${E(l,.02)} 100%), var(--th-panel)`,animationDelay:n},children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute -right-10 -top-10 h-28 w-28 rounded-full opacity-60",style:{background:`radial-gradient(closest-side, ${E(l,.18)}, transparent 70%)`}}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx(F,{iconUrl:s.iconUrl,name:s.name,size:36}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-fg",children:s.name}),s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"text-fg-5 transition-colors hover:text-primary",children:e.jsx(U,{})})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-[var(--th-ok)] shrink-0",style:{background:"color-mix(in oklab, var(--th-ok) 12%, transparent)"},children:[e.jsx(Z,{size:10}),_e(s,t)]})]}),e.jsx("div",{className:"mt-0.5 truncate text-[11.5px] text-fg-5",children:s.source}),e.jsx("div",{className:"mt-1 line-clamp-2 text-[11.5px] text-fg-4",children:t==="zh-CN"?s.descriptionZh:s.description})]})]}),e.jsxs("div",{className:"relative mt-auto pt-3 flex items-center justify-between text-[10.5px] text-fg-5",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[s.stars!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 font-medium text-fg-4",children:[e.jsx(ee,{size:10}),se(s.stars)]}),s.pushedAt&&e.jsx("span",{children:ce(s.pushedAt,t)})]}),e.jsx("span",{className:"text-fg-5 group-hover:text-primary transition-colors",children:a(t,"管理 →","Manage →")})]})]})}function Ae({item:s,locale:t,animationDelay:n,onClick:i}){const{hex:l}=W(void 0,s.name);return e.jsxs("button",{type:"button",onClick:i,className:"animate-in-up group relative flex min-h-[112px] w-full flex-col overflow-hidden rounded-2xl border border-edge/60 bg-panel p-4 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge hover:shadow-[0_12px_28px_rgba(15,23,42,0.07)] focus-visible:outline-none focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",style:{animationDelay:n},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(F,{iconUrl:s.iconUrl,name:s.name,size:32}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-fg",children:s.name}),s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"text-fg-5 transition-colors hover:text-primary",children:e.jsx(U,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[11.5px] text-fg-4",children:t==="zh-CN"?s.descriptionZh:s.description})]})]}),e.jsxs("div",{className:"mt-auto pt-3 flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[11px] text-fg-5",children:[s.stars!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 font-medium text-fg-4",children:[e.jsx(ee,{size:10}),se(s.stars)]}),typeof s.totalCount=="number"&&e.jsxs("span",{children:["· ",s.partial?`${s.totalCount}+`:s.totalCount," skills"]})]}),e.jsx("span",{className:"inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-semibold transition-colors group-hover:text-primary",style:{background:`${E(l,.08)}`,color:l},children:a(t,"查看 →","Browse →")})]})]})}function Ee({item:s,open:t,onClose:n,onChanged:i,locale:l,scope:c,workdir:x,installedSkills:u}){const h=G(g=>g.toast),[p,b]=o.useState(null),[y,d]=o.useState(!1),[v,m]=o.useState(null),[S,$]=o.useState(!1),[A,I]=o.useState(null),[L,j]=o.useState(null),[w,f]=o.useState("");o.useEffect(()=>{if(!t||!s)return;let g=!1;return d(!0),m(null),f(""),(async()=>{try{const r=await _.listRepoSkills(s.source);if(g)return;r.ok?(b(r.skills),$(!!r.partial)):(m(r.error||"failed to list"),b([]))}catch(r){if(g)return;m(r?.message||"failed"),b([])}finally{g||d(!1)}})(),()=>{g=!0}},[t,s?.source]);const N=o.useMemo(()=>{const g=new Set,r=c==="global"?"global":"project";for(const k of u)k.scope===r&&g.add(k.name.toLowerCase());return g},[u,c]),C=o.useMemo(()=>{const g=p||[],r=w.trim().toLowerCase();return r?g.filter(k=>k.name.toLowerCase().includes(r)):g},[p,w]),M=o.useMemo(()=>p?p.filter(g=>N.has(g.name.toLowerCase())).length:0,[p,N]),R=o.useCallback(async g=>{if(s){I(g);try{const r=await _.installSkill(s.source,c==="global",g,x);r.ok?(h(a(l,`${g} 已安装`,`${g} installed`),!0),i()):h(r.error||"Failed",!1)}catch(r){h(r?.message||"Failed",!1)}finally{I(null)}}},[s,c,x,l,h,i]),D=o.useCallback(async g=>{I(g);try{const r=await _.removeExtensionSkill(g,c==="global",x);r.ok?(h(a(l,`${g} 已移除`,`${g} removed`),!0),i()):h(r.error||"Failed",!1)}catch(r){h(r?.message||"Failed",!1)}finally{I(null)}},[c,x,l,h,i]),V=o.useCallback(async()=>{if(s){j("install");try{const g=await _.installSkill(s.source,c==="global",void 0,x);g.ok?(h(a(l,"全部安装完成","All skills installed"),!0),i()):h(g.error||"Failed",!1)}catch(g){h(g?.message||"Failed",!1)}finally{j(null)}}},[s,c,x,l,h,i]),Y=o.useCallback(async()=>{if(!(!s||!p)){j("remove");try{const g=p.map(r=>r.name).filter(r=>N.has(r.toLowerCase()));for(const r of g)await _.removeExtensionSkill(r,c==="global",x);h(a(l,"已移除该集合下的全部技能","Removed all skills from this collection"),!0),i()}catch(g){h(g?.message||"Failed",!1)}finally{j(null)}}},[s,p,N,c,x,l,h,i]);return s?e.jsxs(q,{open:t,onClose:n,wide:!0,children:[e.jsx(K,{title:s.name,description:l==="zh-CN"?s.descriptionZh:s.description,onClose:n}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{iconUrl:s.iconUrl,name:s.name,size:44}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-fg",children:[s.name,s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-primary",children:e.jsx(U,{})})]}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11.5px] text-fg-4",children:[e.jsx("span",{className:"truncate text-fg-5",children:s.source}),s.stars!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-fg-5",children:[e.jsx(ee,{size:10}),se(s.stars)]}),s.pushedAt&&e.jsxs("span",{className:"text-fg-5",children:["· ",ce(s.pushedAt,l)]})]})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[12px] font-semibold text-fg-3",children:[a(l,"该集合下的技能","Skills in this collection"),p&&e.jsxs("span",{className:"ml-2 text-[11px] font-normal text-fg-5",children:[M," / ",S?`${p.length}+`:p.length," ",a(l,"已安装","installed")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"outline",size:"sm",onClick:V,disabled:L!==null||y,children:L==="install"?e.jsx(P,{}):a(l,"全部安装","Install all")}),M>0&&e.jsx(z,{variant:"ghost",size:"sm",onClick:Y,disabled:L!==null,className:"hover:!text-err",children:L==="remove"?e.jsx(P,{}):a(l,"全部移除","Remove all")})]})]}),p&&p.length>6&&e.jsx(T,{type:"text",value:w,onChange:g=>f(g.target.value),placeholder:a(l,"搜索技能…","Search skills…"),className:"w-full"}),y?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(P,{})}):v?e.jsxs("div",{className:"rounded-lg border border-edge/70 bg-panel/60 p-3 text-[12px] text-fg-4",children:[a(l,"无法从 GitHub 拉取技能列表(可能是网络或速率限制)。你仍可以使用上方的「全部安装」按钮一次性安装该集合。",'Could not list skills from GitHub (network or rate-limit). You can still use "Install all" to grab the whole collection.'),e.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-fg-5",children:v})]}):C.length===0?e.jsx("div",{className:"rounded-lg border border-edge/70 bg-panel/60 p-3 text-center text-[12px] text-fg-5",children:w?a(l,"没有匹配的技能","No matching skills"):a(l,"该集合暂无可识别的技能","No discoverable skills in this collection")}):e.jsx("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-edge/70 bg-panel/40",children:C.map((g,r)=>{const k=N.has(g.name.toLowerCase()),O=A===g.name;return e.jsxs("div",{className:B("flex items-center justify-between gap-3 px-3 py-2 text-[12px]",r>0&&"border-t border-edge/40"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[k&&e.jsx(Z,{size:12}),e.jsx("span",{className:B("truncate font-medium",k?"text-[var(--th-ok)]":"text-fg-2"),children:g.name})]}),g.description&&e.jsx("div",{className:"mt-0.5 line-clamp-1 text-[11px] text-fg-5",children:g.description})]}),k?e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{D(g.name)},disabled:O||L!==null,className:"hover:!text-err",children:O?e.jsx(P,{}):a(l,"移除","Remove")}):e.jsx(z,{variant:"outline",size:"sm",onClick:()=>{R(g.name)},disabled:O||L!==null,children:O?e.jsx(P,{}):a(l,"安装","Install")})]},g.name)})}),S&&e.jsx("div",{className:"text-[11px] text-fg-5",children:a(l,"仓库内技能数量较多,仅显示前 1000 个。可使用上方搜索或直接打开仓库浏览全部。","Showing the first 1000 skills. Use search or open the repo on GitHub for the full list.")})]})]})]}):null}const ee=({size:s=12})=>e.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:e.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});function se(s){return s>=1e4?`${(s/1e3).toFixed(1).replace(/\.0$/,"")}k`:s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function ce(s,t){const n=Date.parse(s);if(!Number.isFinite(n))return"";const i=Date.now()-n,l=1440*60*1e3,c=Math.max(1,Math.floor(i/l));if(c<30)return t==="zh-CN"?`${c} 天前`:`${c}d ago`;const x=Math.floor(c/30);if(x<12)return t==="zh-CN"?`${x} 个月前`:`${x}mo ago`;const u=Math.floor(x/12);return t==="zh-CN"?`${u} 年前`:`${u}y ago`}const H={dev:{zh:"开发工具",en:"Development",order:0},productivity:{zh:"生产力",en:"Productivity",order:1},communication:{zh:"协作沟通",en:"Communication",order:2},data:{zh:"数据",en:"Data",order:3},search:{zh:"搜索",en:"Search",order:4},utility:{zh:"工具",en:"Utility",order:5},custom:{zh:"自定义",en:"Custom",order:6}};function Re(s){const t=new Map;for(const n of s){const i=t.get(n.category)||[];i.push(n),t.set(n.category,i)}return[...t.entries()].sort((n,i)=>(H[n[0]]?.order??99)-(H[i[0]]?.order??99)).map(([n,i])=>({key:n,items:i}))}function de({scope:s,workdir:t,locale:n,onOpenBrowserSetup:i}){const l=G(r=>r.toast),c=`pikiclaw.mcp.catalog.${s}.${t||""}`,{data:x,loading:u,refresh:h}=X(c,async()=>(await _.getMcpCatalog(t,s)).items||[],[t,s]),[p,b]=o.useState(""),[y,d]=o.useState(null),[v,m]=o.useState(!1),[S,$]=o.useState(null),A=x||[],I=o.useMemo(()=>A.filter(r=>!r.installed||r.scope===s||!r.scope),[A,s]),L=o.useMemo(()=>{if(!p.trim())return I;const r=p.trim().toLowerCase();return I.filter(k=>k.name.toLowerCase().includes(r)||k.description.toLowerCase().includes(r)||k.descriptionZh.includes(r)||k.id.toLowerCase().includes(r))},[I,p]),j=o.useMemo(()=>L.filter(r=>r.isBuiltin),[L]),w=o.useMemo(()=>L.filter(r=>!r.isBuiltin&&(r.state==="ready"||r.state==="unhealthy")),[L]),f=o.useMemo(()=>Re(L.filter(r=>!r.isBuiltin&&r.state!=="ready"&&r.state!=="unhealthy")),[L]),N=o.useCallback(async(r,k)=>{if(r.isRecommended){$(r.id);try{const O=await _.installMcp(r.id,s,k,t,!0);if(!O.ok)throw new Error(O.error||"install failed");return await h(),O.enabled??!1}catch(O){return l(O?.message||"Failed",!1),!1}finally{$(null)}}},[s,t,h,l]),C=o.useCallback(async r=>{$(r.id);try{if(!r.installed){const ne=await _.installMcp(r.id,s,void 0,t,!1);if(!ne.ok)throw new Error(ne.error||"install failed")}const k=await _.startMcpOAuth(r.id);if(!k.ok||!k.authUrl||!k.state)throw new Error(k.error||"oauth start failed");await Me(k.authUrl,k.state)?(await _.toggleMcp(r.id,!0,s,t),l(a(n,`${r.name} 授权成功`,`${r.name} authorized`),!0)):l(a(n,"授权未完成","Authorization not completed"),!1),await h()}catch(k){l(k?.message||"OAuth failed",!1)}finally{$(null)}},[s,t,n,l,h]),M=o.useCallback(async(r,k)=>{if(r.installedKey){$(r.id);try{await _.toggleMcp(r.installedKey,k,r.scope==="workspace"?"workspace":"global",t),await h()}catch(O){l(O?.message||"Failed",!1)}finally{$(null)}}},[t,h,l]),R=o.useCallback(async r=>{if(r.installedKey){$(r.id);try{await _.removeMcp(r.installedKey,r.scope==="workspace"?"workspace":"global",r.isRecommended?r.id:void 0,t),await h()}catch(k){l(k?.message||"Failed",!1)}finally{$(null)}}},[t,h,l]),D=o.useCallback(async r=>{if(!y)return;await N(y,r)!==!1&&d(null)},[y,N]),V=o.useCallback(r=>{if(r.state==="ready"||r.state==="unhealthy"){M(r,!1);return}if(r.state==="disabled"){M(r,!0);return}if(r.state==="needs_auth"){if(r.auth.type==="mcp-oauth"){C(r);return}if(r.auth.type==="credentials"){d(r);return}}},[M,C]),Y=o.useCallback(r=>{if(r.state==="disabled"){M(r,!0);return}if(r.state==="needs_auth"){if(r.auth.type==="mcp-oauth"){C(r);return}if(r.auth.type==="credentials"){d(r);return}}if(r.auth.type==="mcp-oauth"){C(r);return}if(r.auth.type==="credentials"){d(r);return}N(r)},[C,N,M]),g=u&&!x;return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{children:"MCP Servers"}),!u&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:[w.length," ",a(n,"在用","in use")," · ",I.length-w.length-j.length," ",a(n,"可添加","available")]}),u&&e.jsx(P,{className:"h-3 w-3"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:p,onChange:r=>b(r.target.value),placeholder:a(n,"搜索...","Search..."),className:"h-7 w-52 rounded-md border border-edge bg-inset/50 pl-7 pr-2.5 text-[12px] text-fg outline-none placeholder:text-fg-5/50 focus:border-primary/30 focus:bg-inset"})]})})]}),g?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(P,{})}):e.jsxs("div",{className:"space-y-5",children:[j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--th-accent,#7c3aed)]"}),a(n,"内置(pikiclaw 优化)","Built-in (optimized by pikiclaw)")]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:j.map((r,k)=>r.installed?e.jsx(ae,{item:r,locale:n,busy:S===r.id,index:k,onPrimary:()=>V(r),onReconfigure:r.id==="pikiclaw-browser"?i:void 0},r.id):e.jsx(re,{item:r,locale:n,busy:S===r.id,index:k,onPrimary:()=>Y(r)},r.id))})]}),w.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--th-ok)]"}),a(n,"在用","In use")]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:w.map((r,k)=>e.jsx(ae,{item:r,locale:n,busy:S===r.id,index:k,onPrimary:()=>V(r),onRemove:()=>{R(r)},onReauth:r.auth.type==="mcp-oauth"?()=>{C(r)}:void 0,onReconfigure:r.auth.type==="credentials"?()=>d(r):void 0},r.id))})]}),f.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5"}),w.length===0?a(n,"推荐的服务","Recommended services"):a(n,"更多可选","More options")]}),e.jsx("div",{className:"space-y-4",children:f.map(r=>e.jsx(Oe,{groupKey:r.key,locale:n,children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:r.items.map((k,O)=>e.jsx(re,{item:k,locale:n,busy:S===k.id,index:O,onPrimary:()=>Y(k)},k.id))})},r.key))})]}),j.length===0&&w.length===0&&f.length===0&&e.jsx(te,{title:a(n,"没有匹配的服务","No matching services"),subtitle:a(n,"试试别的关键词","Try a different search term")})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{className:"text-[12px] text-fg-4 hover:text-fg-2 transition-colors",onClick:()=>m(!0),children:["+ ",a(n,"添加自定义 MCP","Add custom MCP")]})}),e.jsx(Ie,{open:!!y,onClose:()=>d(null),locale:n,item:y,initial:y?.config?.env||y?.config?.headers,onSubmit:D}),e.jsx(ze,{open:v,onClose:()=>m(!1),locale:n,scope:s,workdir:t,onAdded:h})]})}function Oe({groupKey:s,locale:t,children:n}){const i=H[s],l=i?a(t,i.zh,i.en):s;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-medium text-fg-5",children:l}),n]})}function te({title:s,subtitle:t}){return e.jsxs("div",{className:"rounded-xl border border-dashed border-edge py-10 text-center",children:[e.jsx("div",{className:"text-[13px] font-medium text-fg-3",children:s}),t&&e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:t})]})}function xe({scope:s,workdir:t,locale:n}){const i=`pikiclaw.skills.catalog.${s}.${t||""}`,{data:l,loading:c,refresh:x}=X(i,async()=>{const j=await _.getSkillsCatalog(t,s);return{items:j.items||[],installed:j.installed||[]}},[t,s]),[u,h]=o.useState(!1),[p,b]=o.useState(null),y=l?.items||[],d=l?.installed||[],v=o.useMemo(()=>{const j=s==="global"?"global":"project";return d.filter(w=>w.scope===j)},[d,s]),m=o.useMemo(()=>y.filter(j=>j.installedNames.length>0),[y]),S=o.useMemo(()=>y.filter(j=>j.installedNames.length===0),[y]),$=o.useMemo(()=>{const j=new Map;for(const w of S){const f=w.category;j.has(f)||j.set(f,[]),j.get(f).push(w)}return[...j.entries()].sort(([w],[f])=>(H[w]?.order??99)-(H[f]?.order??99))},[S]),A=p&&y.find(j=>j.id===p)||null,I=c&&!l,L=v.length;return e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{children:"Skills"}),!c&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:[L," ",a(n,"已安装","installed")," · ",S.length," ",a(n,"可用","available")]}),c&&e.jsx(P,{className:"h-3 w-3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{x()},children:c?a(n,"刷新中…","Refreshing…"):a(n,"刷新","Refresh")}),e.jsxs(z,{variant:"outline",size:"sm",onClick:()=>h(!0),children:["+ ",a(n,"从 GitHub 安装","Install from GitHub")]})]})]}),I?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx(P,{})}):y.length===0?e.jsx(te,{title:a(n,"暂无可用的技能包","No skill packs available"),subtitle:a(n,"从 GitHub 导入一个开始使用","Import from GitHub to get started")}):e.jsxs(e.Fragment,{children:[m.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-fg-3",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--th-ok)]"}),a(n,"已安装","Installed")]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:m.map((j,w)=>e.jsx($e,{item:j,locale:n,animationDelay:`${Math.min(w,12)*30}ms`,onClick:()=>b(j.id)},j.id))})]}),S.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-fg-3",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-fg-5/50"}),a(n,"推荐","Available")]}),$.map(([j,w])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-fg-5",children:n==="zh-CN"?H[j]?.zh||j:H[j]?.en||j}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:w.map((f,N)=>e.jsx(Ae,{item:f,locale:n,animationDelay:`${Math.min(N,12)*30}ms`,onClick:()=>b(f.id)},f.id))})]},j))]})]}),e.jsx(Ee,{item:A,open:!!A,onClose:()=>b(null),onChanged:()=>{x()},locale:n,scope:s,workdir:t,installedSkills:d}),e.jsx(Le,{open:u,onClose:()=>h(!1),locale:n,scope:s,workdir:t,onInstalled:x})]})}const J={dev:{zh:"开发工具",en:"Developer",order:1},cloud:{zh:"云平台",en:"Cloud",order:2},data:{zh:"数据",en:"Data",order:3},productivity:{zh:"生产力",en:"Productivity",order:4}};function ue({state:s,locale:t}){return s==="ready"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-[var(--th-ok)]",style:{background:"color-mix(in oklab, var(--th-ok) 12%, transparent)"},children:[e.jsx(Z,{size:10}),a(t,"已登录","Signed in")]}):s==="installed_not_auth"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold text-amber-600 dark:text-amber-400",style:{background:"color-mix(in oklab, #f59e0b 14%, transparent)"},children:[e.jsx(ie,{size:10}),a(t,"待登录","Sign-in needed")]}):s==="not_installed"?e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full border border-edge bg-inset/60 px-2 py-0.5 text-[10px] font-medium text-fg-5",children:a(t,"未安装","Not installed")}):e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full border border-edge bg-inset/60 px-2 py-0.5 text-[10px] font-medium text-fg-5",children:"..."})}function he({chunks:s,running:t,emptyHint:n}){const i=o.useRef(null);o.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s.length]);const l=s.join("");return e.jsx("div",{ref:i,className:"relative h-56 overflow-auto rounded-xl border border-edge/60 bg-[#0b0f16] p-3 font-mono text-[11.5px] leading-[1.55] text-[#cdd6f4] scrollbar-thin",style:{boxShadow:"0 1px 0 rgba(255,255,255,0.03) inset"},children:l?e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:l}):e.jsx("div",{className:"flex h-full items-center justify-center text-[#6c7086]",children:t?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(P,{})," ",n||"Starting…"]}):n||"No output yet"})})}function Pe({cli:s,locale:t,onInstalled:n}){const[i,l]=o.useState([]),[c,x]=o.useState(!1),[u,h]=o.useState(null),[p,b]=o.useState(null),[y,d]=o.useState(null),v=o.useRef(null),m=o.useCallback(()=>{try{v.current?.close()}catch{}v.current=null},[]);o.useEffect(()=>m,[m]);const S=o.useCallback(async()=>{l([]),b(null),d(null),x(!0);try{const I=await _.startCliInstall(s.id);if(!I.ok||!I.sessionId)throw new Error(I.error||"start failed");h(I.sessionId);const L=new EventSource(`/api/extensions/cli/auth/stream?sessionId=${encodeURIComponent(I.sessionId)}`);v.current=L,L.onmessage=j=>{try{const w=JSON.parse(j.data);w.type==="output"?l(f=>f.length>400?[...f.slice(-400),w.chunk]:[...f,w.chunk]):w.type==="error"?b(w.message||"error"):w.type==="done"&&(x(!1),d(!!w.ok),m(),w.ok&&n())}catch{}},L.addEventListener("close",()=>{x(!1),m()}),L.onerror=()=>{c&&b(a(t,"连接中断","Stream disconnected"))}}catch(I){x(!1),b(I?.message||"failed to start install")}},[s.id,m,t,n,c]),$=o.useCallback(async()=>{if(u)try{await _.cancelCliAuth(u)}catch{}m(),x(!1)},[u,m]);if(!s.autoInstall)return null;const A=c||i.length>0||y!==null;return e.jsxs("div",{className:"space-y-3 rounded-lg border border-edge/70 bg-panel/60 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[12px] text-fg-3",children:a(t,`通过 ${s.autoInstall.label} 直接在本机自动安装,无需复制命令。`,`Run the ${s.autoInstall.label} install locally — no copy-paste needed.`)}),c?e.jsx(z,{variant:"outline",size:"sm",onClick:$,children:a(t,"中止","Abort")}):e.jsx(z,{variant:"primary",size:"sm",onClick:S,disabled:y===!0,children:y===!0?a(t,"已安装","Installed"):y===!1?a(t,"重试安装","Retry install"):a(t,"一键安装","Auto-install")})]}),A&&e.jsx(he,{chunks:i,running:c,emptyHint:a(t,"安装进度将在此显示","Install output will appear here")}),p&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:p}),y===!1&&!p&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:a(t,"安装未成功,请查看上方输出排查。","Install did not complete — check the output above.")})]})}function Te({cli:s,locale:t,onSignedIn:n,onCancel:i}){const[l,c]=o.useState([]),[x,u]=o.useState(!1),[h,p]=o.useState(null),[b,y]=o.useState(null),[d,v]=o.useState(null),m=o.useRef(null),S=o.useCallback(()=>{try{m.current?.close()}catch{}m.current=null},[]);o.useEffect(()=>S,[S]);const $=o.useCallback(async()=>{c([]),v(null),y(null),u(!0);try{const N=await _.startCliAuth(s.id);if(!N.ok||!N.sessionId)throw new Error(N.error||"start failed");p(N.sessionId);const C=new EventSource(`/api/extensions/cli/auth/stream?sessionId=${encodeURIComponent(N.sessionId)}`);m.current=C,C.onmessage=M=>{try{const R=JSON.parse(M.data);R.type==="output"?c(D=>D.length>400?[...D.slice(-400),R.chunk]:[...D,R.chunk]):R.type==="status"?y(R.status.state==="ready"?a(t,"已检测到登录成功","Sign-in detected"):a(t,"等待授权完成…","Waiting for authorization…")):R.type==="error"?v(R.message||"error"):R.type==="done"&&(u(!1),S(),R.ok&&n())}catch{}},C.addEventListener("close",()=>{u(!1),S()}),C.onerror=()=>{x&&v(a(t,"连接中断","Stream disconnected"))}}catch(N){u(!1),v(N?.message||"failed to start sign-in")}},[s.id,S,t,n,x]),A=o.useCallback(async()=>{if(h)try{await _.cancelCliAuth(h)}catch{}S(),u(!1),i()},[h,S,i]),[I,L]=o.useState({}),[j,w]=o.useState(!1),f=o.useCallback(async()=>{w(!0),v(null);try{const N=await _.applyCliToken(s.id,I);N.ok?n():v(N.error||a(t,"应用凭据失败","Failed to apply credentials"))}catch(N){v(N?.message||"failed")}finally{w(!1)}},[s.id,I,t,n]);if(s.auth.type==="oauth-web"){const N=t==="zh-CN"&&s.auth.loginHintZh||s.auth.loginHint;return e.jsxs("div",{className:"space-y-3",children:[N&&e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:N}),e.jsx(he,{chunks:l,running:x,emptyHint:a(t,"点击「开始登录」后将在此展示命令行输出",'Click "Start sign-in" to stream CLI output here')}),d&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:d}),b&&!d&&e.jsx("div",{className:"text-[12px] text-[var(--th-ok)]",children:b}),e.jsx("div",{className:"flex items-center gap-2",children:x?e.jsx(z,{variant:"outline",size:"sm",onClick:A,children:a(t,"中止","Abort")}):e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"primary",size:"sm",onClick:$,children:a(t,"开始登录","Start sign-in")}),e.jsx(z,{variant:"ghost",size:"sm",onClick:i,children:a(t,"取消","Cancel")})]})})]})}if(s.auth.type==="token"){const N=t==="zh-CN"&&s.auth.loginHintZh||s.auth.loginHint;return e.jsxs("div",{className:"space-y-3",children:[N&&e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:N}),e.jsx("div",{className:"space-y-2",children:(s.auth.tokenFields||[]).map(C=>e.jsxs("label",{className:"block text-[12px]",children:[e.jsxs("div",{className:"mb-1 text-fg-3",children:[t==="zh-CN"?C.labelZh:C.label,C.required&&e.jsx("span",{className:"ml-1 text-[var(--th-err)]",children:"*"})]}),e.jsx(T,{type:C.secret?"password":"text",value:I[C.key]||"",onChange:M=>L(R=>({...R,[C.key]:M.target.value})),placeholder:C.placeholder||"",className:"w-full"}),C.helpUrl&&e.jsxs("a",{className:"mt-1 inline-block text-[11px] text-primary hover:underline",href:C.helpUrl,target:"_blank",rel:"noreferrer",children:[a(t,"如何获取","How to get this")," ↗"]})]},C.key))}),d&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:d}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"primary",size:"sm",onClick:f,disabled:j,children:j?a(t,"验证中…","Verifying…"):a(t,"保存并验证","Save & verify")}),e.jsx(z,{variant:"ghost",size:"sm",onClick:i,children:a(t,"取消","Cancel")})]})]})}return null}function Be({commands:s,locale:t}){return e.jsx("div",{className:"space-y-2",children:s.map((n,i)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-edge/70 bg-panel/60",children:[n.label&&e.jsx("div",{className:"flex items-center justify-between border-b border-edge/50 bg-panel-alt/40 px-3 py-1 text-[11px] font-medium text-fg-4",children:e.jsx("span",{children:n.label})}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 font-mono text-[12px] text-fg-2",children:[e.jsx("span",{className:"mt-[2px] select-none text-fg-5",children:"$"}),e.jsx("code",{className:"min-w-0 flex-1 break-all",children:n.cmd}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(n.cmd)},className:"shrink-0 rounded px-2 py-0.5 text-[10.5px] text-fg-5 transition-colors hover:bg-panel-h hover:text-fg-2",title:a(t,"复制到剪贴板","Copy to clipboard"),children:a(t,"复制","Copy")})]})]},i))})}function Ue({cli:s,open:t,onClose:n,onChanged:i,locale:l}){const[c,x]=o.useState(!1),[u,h]=o.useState(!1),[p,b]=o.useState(null);o.useEffect(()=>{t||(x(!1),b(null))},[t]);const y=o.useMemo(()=>s?s.install[s.platform]||[]:[],[s]);if(!s)return null;const d=s.state!=="not_installed",v=s.state==="ready",m=async()=>{h(!0),b(null);try{const S=await _.logoutCli(s.id);S.ok||b(S.error||a(l,"登出失败","Logout failed")),i()}catch(S){b(S?.message||"failed")}finally{h(!1)}};return e.jsxs(q,{open:t,onClose:n,wide:!0,children:[e.jsx(K,{title:s.name,description:l==="zh-CN"?s.descriptionZh:s.description,onClose:n}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{iconSlug:s.iconSlug,iconUrl:s.iconUrl,name:s.name,size:44}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-fg",children:[s.name,s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-primary",children:e.jsx(U,{})})]}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11.5px] text-fg-4",children:[ue({state:s.state,locale:l}),s.version&&e.jsxs("span",{className:"font-mono text-fg-5",children:["v",s.version]}),v&&s.authDetail&&e.jsxs("span",{className:"truncate text-fg-5",children:["· ",s.authDetail]})]})]})]}),!d&&e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"text-[12px] font-semibold text-fg-3",children:a(l,"安装","Install")}),s.autoInstall&&e.jsx(Pe,{cli:s,locale:l,onInstalled:i}),e.jsx("div",{className:"text-[11.5px] leading-relaxed text-fg-5",children:s.autoInstall?a(l,"或手动复制命令到终端执行。","Or copy a command below and run it in your terminal."):a(l,"复制下面的命令到终端运行。我们不自动代为安装 — 包管理器往往需要 sudo 或交互式确认。","Copy a command below and run it in your terminal. We don't auto-install — package managers often need sudo or interactive confirmation.")}),y.length>0?e.jsx(Be,{commands:y,locale:l}):e.jsx("div",{className:"text-[12px] text-fg-5",children:a(l,"请查看官方文档","Check the official installation docs")}),s.install.docs&&e.jsxs("a",{href:s.install.docs,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[11.5px] text-primary hover:underline",children:[a(l,"查看安装文档","Installation docs")," ↗"]}),e.jsx("div",{className:"pt-2",children:e.jsx(z,{variant:"outline",size:"sm",onClick:i,children:a(l,"我已安装,重新检测","I've installed, re-check")})})]}),d&&s.auth.type!=="none"&&e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[12px] font-semibold text-fg-3",children:a(l,"登录","Sign in")}),v&&!c&&e.jsx(z,{variant:"ghost",size:"sm",onClick:m,disabled:u,children:u?a(l,"登出中…","Signing out…"):a(l,"登出","Sign out")})]}),p&&e.jsx("div",{className:"text-[11.5px] text-[var(--th-err)]",children:p}),v&&!c?e.jsxs("div",{className:"rounded-lg border border-edge/70 bg-panel/60 p-3 text-[12px] text-fg-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{size:12}),e.jsx("span",{children:a(l,"你已经登录,命令行工具可直接使用。","Already signed in — the CLI is ready to use.")})]}),e.jsx("div",{className:"mt-2",children:e.jsx(z,{variant:"outline",size:"sm",onClick:()=>x(!0),children:a(l,"重新登录","Re-authenticate")})})]}):e.jsx(Te,{cli:s,locale:l,onSignedIn:()=>{x(!1),i()},onCancel:()=>x(!1)})]}),d&&s.auth.type==="none"&&e.jsx("section",{className:"rounded-lg border border-edge/70 bg-panel/60 p-3 text-[12px] text-fg-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{size:12}),e.jsx("span",{children:a(l,"无需授权 — 可直接使用。","No authentication required — ready to use.")})]})})]})]})}function Fe({item:s,onClick:t,locale:n,animationDelay:i}){const{hex:l}=W(s.iconSlug,s.name);return e.jsxs("button",{type:"button",onClick:t,className:"animate-in-up group relative flex min-h-[112px] w-full flex-col overflow-hidden rounded-2xl border border-edge/70 bg-panel p-4 text-left transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_12px_28px_rgba(15,23,42,0.09)] focus-visible:outline-none focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",style:{background:`linear-gradient(135deg, ${E(l,.06)} 0%, ${E(l,.02)} 100%), var(--th-panel)`,animationDelay:i},children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute -right-10 -top-10 h-28 w-28 rounded-full opacity-60",style:{background:`radial-gradient(closest-side, ${E(l,.18)}, transparent 70%)`}}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx(F,{iconSlug:s.iconSlug,iconUrl:s.iconUrl,name:s.name,size:36}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold text-fg",children:s.name}),ue({state:s.state,locale:n})]}),e.jsxs("div",{className:"mt-0.5 truncate text-[11.5px] text-fg-5",children:[s.version?e.jsxs("span",{className:"font-mono",children:["v",s.version]}):null,s.version&&s.authDetail?" · ":null,s.authDetail]}),e.jsx("div",{className:"mt-1 truncate text-[11.5px] text-fg-4",children:n==="zh-CN"?s.descriptionZh:s.description})]})]})]})}function De({item:s,onClick:t,locale:n,animationDelay:i}){const{hex:l}=W(s.iconSlug,s.name),c=s.state==="not_installed"?a(n,"安装","Install"):s.state==="installed_not_auth"?a(n,"登录","Sign in"):a(n,"查看","Details");return e.jsxs("button",{type:"button",onClick:t,className:"animate-in-up group relative flex min-h-[112px] w-full flex-col overflow-hidden rounded-2xl border border-edge/60 bg-panel p-4 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge hover:shadow-[0_12px_28px_rgba(15,23,42,0.07)] focus-visible:outline-none focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",style:{animationDelay:i},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(F,{iconSlug:s.iconSlug,iconUrl:s.iconUrl,name:s.name,size:32}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-fg",children:s.name}),s.homepage&&e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-fg-5 transition-colors hover:text-primary",children:e.jsx(U,{})})]}),e.jsx("div",{className:"mt-0.5 truncate text-[11.5px] text-fg-4",children:n==="zh-CN"?s.descriptionZh:s.description})]})]}),e.jsxs("div",{className:"mt-auto pt-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-fg-5",children:s.auth.type==="oauth-web"?a(n,"浏览器授权","OAuth"):s.auth.type==="token"?a(n,"Token","Token"):a(n,"免配置","No auth")}),e.jsx("span",{className:"inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-semibold transition-colors group-hover:text-primary",style:{background:`${E(l,.08)}`,color:l},children:c})]})]})}function pe({locale:s,scope:t}){const{data:n,loading:i,refresh:l}=X("pikiclaw:cli:catalog",async()=>{const d=await _.getCliCatalog();if(!d.ok)throw new Error(d.error||"failed");return d.items||[]},[]),[c,x]=o.useState(null),u=o.useMemo(()=>{const d=n||[];return d},[n,t]),h=c&&u.find(d=>d.id===c)||null,p=u.filter(d=>d.state==="ready"),b=u.filter(d=>d.state!=="ready"),y=o.useMemo(()=>{const d=new Map;for(const v of b){const m=v.category;d.has(m)||d.set(m,[]),d.get(m).push(v)}return[...d.entries()].sort(([v],[m])=>(J[v]?.order??99)-(J[m]?.order??99))},[b]);return e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Q,{children:a(s,"CLI 工具","CLI Tools")}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-5",children:[e.jsxs("span",{children:[p.length," ",a(s,"已登录","signed in")," · ",b.length," ",a(s,"可用","available")]}),e.jsx("button",{type:"button",onClick:()=>{l()},className:"rounded px-2 py-0.5 text-fg-5 transition-colors hover:bg-panel-h hover:text-fg-2",children:i?a(s,"刷新中…","Refreshing…"):a(s,"刷新","Refresh")})]})]}),t==="workspace"&&e.jsx("div",{className:"rounded-lg border border-edge/60 bg-inset/40 px-3 py-2 text-[11.5px] text-fg-4",children:a(s,"CLI 工具安装于机器层面,项目视图下同样可见。","CLI tools are installed machine-wide and are shown here for convenience.")}),p.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-fg-3",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--th-ok)]"}),a(s,"已登录","Signed in")]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:p.map((d,v)=>e.jsx(Fe,{item:d,locale:s,animationDelay:`${Math.min(v,12)*30}ms`,onClick:()=>x(d.id)},d.id))})]}),b.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-fg-3",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-fg-5/50"}),a(s,"推荐工具","Available")]}),y.map(([d,v])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-fg-5",children:s==="zh-CN"?J[d]?.zh||d:J[d]?.en||d}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:v.map((m,S)=>e.jsx(De,{item:m,locale:s,animationDelay:`${Math.min(S,12)*30}ms`,onClick:()=>x(m.id)},m.id))})]},d))]}),!i&&u.length===0&&e.jsx(te,{title:a(s,"暂无可用 CLI","No CLI tools available"),subtitle:a(s,"稍后再试,或重启一下服务。","Try again later, or restart the service.")}),e.jsx(Ue,{cli:h,open:!!h,onClose:()=>x(null),onChanged:()=>{l()},locale:s})]})}function me({active:s,onChange:t,locale:n,counts:i}){const l=[{id:"mcp",labelZh:"MCP 服务",labelEn:"MCP",icon:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("circle",{cx:"4",cy:"5",r:"1.6"}),e.jsx("circle",{cx:"20",cy:"5",r:"1.6"}),e.jsx("circle",{cx:"4",cy:"19",r:"1.6"}),e.jsx("circle",{cx:"20",cy:"19",r:"1.6"}),e.jsx("path",{d:"M6 6 l4 4 M18 6 l-4 4 M6 18 l4 -4 M18 18 l-4 -4"})]})},{id:"cli",labelZh:"命令行",labelEn:"CLI",icon:e.jsxs("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:"M4 17 l5 -5 -5 -5"}),e.jsx("path",{d:"M12 19 h8"})]})},{id:"skill",labelZh:"技能包",labelEn:"Skills",icon: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:"M12 2 l3 7 h7 l-5.5 4.5 2 7.5 L12 17 l-6.5 4 2 -7.5 L2 9 h7 z"})})}];return e.jsx(fe,{className:"w-fit bg-panel/80 backdrop-blur",children:l.map(c=>e.jsxs(ge,{active:s===c.id,onClick:()=>t(c.id),className:"gap-1.5 px-3.5",children:[e.jsx("span",{className:"shrink-0",children:c.icon}),e.jsx("span",{children:n==="zh-CN"?c.labelZh:c.labelEn}),i?.[c.id]!==void 0&&e.jsx("span",{className:B("ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold",s===c.id?"bg-primary/12 text-primary":"bg-inset/70 text-fg-5"),children:i[c.id]})]},c.id))})}function Ke({onOpenBrowserSetup:s}){const t=G(u=>u.locale),i=G(u=>u.state)?.config?.workdir||"",[l,c]=o.useState(()=>{try{const u=localStorage.getItem("pikiclaw:extensions:tab");return u==="mcp"||u==="cli"||u==="skill"?u:"mcp"}catch{return"mcp"}}),x=o.useCallback(u=>{c(u);try{localStorage.setItem("pikiclaw:extensions:tab",u)}catch{}},[]);return e.jsxs("div",{className:"animate-in space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:a(t,"管理一次授权即可全局复用的服务与工具。项目专属的扩展请在工作台侧栏配置。","One-time authorization, use everywhere. Project-specific extensions live in the Workbench sidebar.")})}),e.jsx(me,{active:l,onChange:x,locale:t})]}),e.jsxs("div",{className:"animate-in-fade",children:[l==="mcp"&&e.jsx("div",{className:"space-y-7",children:e.jsx(de,{scope:"global",workdir:i,locale:t,onOpenBrowserSetup:s})}),l==="cli"&&e.jsx(pe,{locale:t,scope:"global"}),l==="skill"&&e.jsx(xe,{scope:"global",workdir:i,locale:t})]},l)]})}function Ve({workdir:s}){const t=G(c=>c.locale),[n,i]=o.useState(()=>{try{const c=localStorage.getItem("pikiclaw:extensions-ws:tab");return c==="mcp"||c==="cli"||c==="skill"?c:"mcp"}catch{return"mcp"}}),l=o.useCallback(c=>{i(c);try{localStorage.setItem("pikiclaw:extensions-ws:tab",c)}catch{}},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:a(t,"仅对当前工作区生效 — 依赖项目目录的本地服务和专属技能包。","Scoped to this workspace — local services that depend on project context and project-specific skill packs.")}),e.jsx(me,{active:n,onChange:l,locale:t})]}),e.jsxs("div",{className:"animate-in-fade",children:[n==="mcp"&&e.jsx(de,{scope:"workspace",workdir:s,locale:t}),n==="cli"&&e.jsx(pe,{locale:t,scope:"workspace"}),n==="skill"&&e.jsx(xe,{scope:"workspace",workdir:s,locale:t})]},n)]})}export{Ke as ExtensionsTab,Ve as WorkspaceExtensionsBody};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as C,j as r}from"./react-vendor-DTcmqLiz.js";import{u as k,l as w,k as D,S as h,B as v}from"./index-
|
|
1
|
+
import{r as C,j as r}from"./react-vendor-DTcmqLiz.js";import{u as k,l as w,k as D,S as h,B as v}from"./index-Cn_xngY_.js";import{B as A}from"./BrandIcon-BeVfjldz.js";import{a as B,b as L,c as S,d as T}from"./shared-rL_oA8FR.js";import"./router-Cav8lq-m.js";function b(t){return t==="zh-CN"?{status:"状态",summary:"接入摘要",loading:"加载中",chats:"个 chat",notConnected:"未接入",configuring:"配置中",connected:"已接入",failed:"配置异常",configure:"去配置",continueSetup:"继续配置",viewSettings:"查看设置",noWeixin:"尚未登录微信账号",noTelegram:"未配置 Bot Token",noFeishu:"未配置 App ID 与应用凭证",noSlack:"未配置 Bot Token 与 App-Level Token",noDiscord:"未配置 Bot Token",noDingtalk:"未配置 AppKey/AppSecret",noWeCom:"未配置智能机器人 Bot ID 与 Secret",pendingValidation:"凭证已保存,等待验证。",connectedReady:"机器人已可正常接收消息。",validationFailed:"校验失败,请检查凭证或网络。",accountLinked:"已绑定账号",tokenSaved:"Token 已保存",appCredentialsSaved:"应用凭证已保存",allowedChats:"允许",notConnectedDetail:"尚未配置账号与接入凭证。"}:{status:"Status",summary:"Summary",loading:"Loading",chats:"chats",notConnected:"Not connected",configuring:"Configuring",connected:"Connected",failed:"Needs attention",configure:"Configure",continueSetup:"Continue setup",viewSettings:"View settings",noWeixin:"Weixin account not connected yet",noTelegram:"Bot token not configured",noFeishu:"App ID and credentials not configured",noSlack:"Bot Token and App-Level Token not configured",noDiscord:"Bot Token not configured",noDingtalk:"AppKey / AppSecret not configured",noWeCom:"Smart Bot ID and Secret not configured",pendingValidation:"Credentials are saved and waiting for validation.",connectedReady:"This channel can receive messages.",validationFailed:"Validation failed. Check credentials or network.",accountLinked:"Account linked",tokenSaved:"Token saved",appCredentialsSaved:"Credentials saved",allowedChats:"Allows",notConnectedDetail:"Account and access credentials have not been configured yet."}}function c(t,e=4,n=4){const a=t.trim();return a?a.length<=e+n+3?a:`${a.slice(0,e)}...${a.slice(-n)}`:""}function $(t){return String(t||"").split(/[\n,;]/).map(e=>e.trim()).filter(Boolean).length}function l(t,e){return String(t?.[e]||"").trim()}function E(t,e){if(!t)return e;try{return new URL(t).host||t}catch{return t}}function I(t,e,n){if(t==="weixin"){const i=l(e,"weixinAccountId"),o=l(e,"weixinBaseUrl");return i?o?`${c(i)} · ${E(o,o)}`:`${n.accountLinked} ${c(i)}`:n.noWeixin}if(t==="telegram"){const i=l(e,"telegramBotToken"),o=$(l(e,"telegramAllowedChatIds"));return i?o>0?`${n.tokenSaved} · ${n.allowedChats} ${o} ${n.chats}`:n.tokenSaved:n.noTelegram}if(t==="feishu"){const i=l(e,"feishuAppId"),o=l(e,"feishuAppSecret");return!i||!o?n.noFeishu:`App ID ${c(i)} · ${n.appCredentialsSaved}`}if(t==="slack"){const i=l(e,"slackBotToken"),o=l(e,"slackAppToken");return!i||!o?n.noSlack:`Bot ${c(i,6,4)} · App ${c(o,6,4)}`}if(t==="discord"){const i=l(e,"discordBotToken");return i?`${n.tokenSaved} · ${c(i,6,4)}`:n.noDiscord}if(t==="dingtalk"){const i=l(e,"dingtalkClientId"),o=l(e,"dingtalkClientSecret");return!i||!o?n.noDingtalk:`AppKey ${c(i,4,4)} · ${n.appCredentialsSaved}`}const a=l(e,"wecomBotId"),u=l(e,"wecomBotSecret");return!a||!u?n.noWeCom:`Bot ${c(a,4,4)} · ${n.appCredentialsSaved}`}function j(t,e){return!t||!t.configured?{statusLabel:e.notConnected,statusVariant:"muted",statusDescription:t?.detail||e.notConnectedDetail,actionLabel:e.configure}:t.ready?{statusLabel:e.connected,statusVariant:"ok",statusDescription:t.detail||e.connectedReady,actionLabel:e.viewSettings}:w(t)?{statusLabel:e.configuring,statusVariant:"accent",statusDescription:t.detail||e.pendingValidation,actionLabel:e.continueSetup}:{statusLabel:e.failed,statusVariant:"warn",statusDescription:t.detail||e.validationFailed,actionLabel:e.continueSetup}}function y({meta:t,locale:e}){const n=b(e);return r.jsxs(B,{children:[r.jsx(L,{icon:r.jsx(A,{brand:t.key,size:32,className:"rounded-md"}),iconWrap:!1,title:t.title,subtitle:t.subtitle}),r.jsxs(S,{label:n.status,children:[r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:r.jsxs(D,{variant:t.statusVariant,children:[t.loading&&r.jsx(h,{className:"h-3 w-3"}),t.statusLabel]})}),r.jsx("div",{className:"mt-1 text-[13px] leading-relaxed text-fg-3 xl:truncate xl:whitespace-nowrap",title:t.statusDescription,children:t.statusDescription})]}),r.jsx(S,{label:t.summaryLabel,children:r.jsx("div",{className:"break-words text-[13px] leading-relaxed text-fg-3",children:t.summary})}),r.jsx(T,{children:r.jsxs(v,{variant:t.channel?.ready?"outline":"primary",size:"sm",onClick:t.onAction,disabled:t.actionDisabled,children:[t.loading&&r.jsx(h,{className:"h-3 w-3"}),t.actionLabel]})})]})}const Z=[{key:"weixin",titleZh:"微信",titleEn:"Weixin",subtitleZh:"二维码登录与账号接入",subtitleEn:"QR login and account routing",actionProp:"onOpenWeixin"},{key:"telegram",titleZh:"Telegram",titleEn:"Telegram",subtitleZh:"Bot Token 与 chat allowlist",subtitleEn:"Bot token and chat allowlist",actionProp:"onOpenTelegram"},{key:"feishu",titleZh:"飞书",titleEn:"Lark / Feishu",subtitleZh:"应用凭证与机器人身份",subtitleEn:"App credentials and bot identity",actionProp:"onOpenFeishu"},{key:"slack",titleZh:"Slack",titleEn:"Slack",subtitleZh:"Socket Mode (xoxb / xapp)",subtitleEn:"Socket Mode (xoxb / xapp)",actionProp:"onOpenSlack"},{key:"discord",titleZh:"Discord",titleEn:"Discord",subtitleZh:"Gateway 长连接 (需开启 Message Content Intent)",subtitleEn:"Gateway WebSocket (requires Message Content Intent)",actionProp:"onOpenDiscord"},{key:"dingtalk",titleZh:"钉钉",titleEn:"DingTalk",subtitleZh:"Stream 长连接 (AppKey / AppSecret)",subtitleEn:"Stream Mode (AppKey / AppSecret)",actionProp:"onOpenDingtalk"},{key:"wecom",titleZh:"企业微信",titleEn:"WeCom",subtitleZh:"智能机器人 WebSocket (Bot ID / Secret)",subtitleEn:"Smart Bot WebSocket (Bot ID / Secret)",actionProp:"onOpenWeCom"}];function P(t){const e=k(s=>s.state),n=k(s=>s.locale),a=b(n),u=!e,i=e?.setupState?.channels||[],o=e?.config||{},f=C.useMemo(()=>Z.map(s=>{const d=i.find(x=>x.channel===s.key)||null,p=n==="zh-CN"?s.titleZh:s.titleEn,g=n==="zh-CN"?s.subtitleZh:s.subtitleEn,m=t[s.actionProp];return u?{key:s.key,title:p,subtitle:g,channel:null,loading:!0,summary:a.loading,summaryLabel:a.summary,statusLabel:a.loading,statusVariant:"muted",statusDescription:a.loading,actionLabel:a.loading,actionDisabled:!0,onAction:m}:{key:s.key,title:p,subtitle:g,channel:d,summary:I(s.key,o,a),summaryLabel:a.summary,...j(d,a),actionDisabled:!1,onAction:m}}),[i,o,a,u,n,t]);return r.jsx("div",{className:"animate-in space-y-3",children:f.map(s=>r.jsx(y,{meta:s,locale:n},s.key))})}export{P as IMAccessTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as i,b as c}from"./react-vendor-DTcmqLiz.js";import{c as o,B as x}from"./index-
|
|
1
|
+
import{j as e,r as i,b as c}from"./react-vendor-DTcmqLiz.js";import{c as o,B as x}from"./index-Cn_xngY_.js";function u({className:t,...r}){return e.jsx("input",{className:o("flex h-9 w-full rounded-md border border-control-border bg-control px-3 py-1.5 text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","placeholder:text-fg-5","hover:border-control-border-h","focus:border-control-border-h focus:bg-control-h focus:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:bg-panel-alt disabled:border-edge disabled:text-fg-5","disabled:shadow-none disabled:hover:border-edge disabled:placeholder:text-fg-6",t),...r})}function h({children:t,className:r}){return e.jsx("label",{className:o("mb-2 block text-sm font-medium text-fg-3",r),children:t})}function f({open:t,onClose:r,wide:a,panelStyle:s,children:l}){return i.useEffect(()=>{if(!t)return;const n=d=>{d.key==="Escape"&&r()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,r]),!t||typeof document>"u"?null:c.createPortal(e.jsxs("div",{className:"fixed inset-0 z-100 flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 backdrop-blur-[10px] backdrop-saturate-125",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--th-overlay) 68%, transparent), color-mix(in oklab, var(--th-overlay) 92%, transparent))"},onClick:r}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at center, color-mix(in oklab, white 12%, transparent), transparent 38%)"}}),e.jsx("div",{className:o("glass-strong relative max-h-[min(88vh,860px)] w-full overflow-hidden rounded-xl border border-edge-h shadow-[0_32px_96px_rgba(2,6,23,0.28),0_8px_24px_rgba(15,23,42,0.08)] animate-scale",a?"max-w-[720px]":"max-w-[480px]"),style:{...s,background:"linear-gradient(180deg, color-mix(in oklab, var(--th-modal-bg) 90%, white 10%), color-mix(in oklab, var(--th-modal-bg) 97%, white 3%))"},children:e.jsx("div",{className:"max-h-[inherit] overflow-y-auto p-6",children:l})})]}),document.body)}function g({title:t,description:r,onClose:a}){return e.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:t}),r&&e.jsx("div",{className:"mt-1 text-sm leading-relaxed text-fg-4",children:r})]}),e.jsx(x,{variant:"ghost",size:"icon",onClick:a,className:"-mr-1 -mt-1 h-8 w-8 shrink-0",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}export{u as I,h as L,f as M,g as a};
|