pikiclaw 0.3.32 → 0.3.34

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.
Files changed (78) hide show
  1. package/dashboard/dist/assets/{AgentTab-DF-OpQEU.js → AgentTab-DYtMGHpC.js} +1 -1
  2. package/dashboard/dist/assets/BrandIcon-DHaeSgX8.js +1 -0
  3. package/dashboard/dist/assets/{DirBrowser-DL_OIY61.js → DirBrowser-DRg-wxu3.js} +1 -1
  4. package/dashboard/dist/assets/ExtensionsTab-KsnTj9HM.js +1 -0
  5. package/dashboard/dist/assets/IMAccessTab-bD_RJqfb.js +1 -0
  6. package/dashboard/dist/assets/{Modal-CzmUyl8t.js → Modal-DxYHCIeK.js} +1 -1
  7. package/dashboard/dist/assets/Modals-CDGPHZxx.js +1 -0
  8. package/dashboard/dist/assets/PermissionsTab-DQeaSUNi.js +1 -0
  9. package/dashboard/dist/assets/{Select-CqNUDiiW.js → Select-CtTWpzUC.js} +1 -1
  10. package/dashboard/dist/assets/SessionPanel-BtE77tDC.js +1 -0
  11. package/dashboard/dist/assets/{SystemTab-dJF6btCO.js → SystemTab-D5khpzb6.js} +1 -1
  12. package/dashboard/dist/assets/index-CypsxtrZ.js +3 -0
  13. package/dashboard/dist/assets/index-DIJ7MPen.js +16 -0
  14. package/dashboard/dist/assets/index-wGnw5EXO.css +1 -0
  15. package/dashboard/dist/assets/shared-JcpxfGic.js +1 -0
  16. package/dashboard/dist/index.html +2 -2
  17. package/dist/agent/drivers/claude.js +184 -101
  18. package/dist/agent/drivers/codex.js +19 -6
  19. package/dist/agent/drivers/gemini.js +25 -1
  20. package/dist/agent/index.js +1 -1
  21. package/dist/agent/mcp/bridge.js +38 -98
  22. package/dist/agent/mcp/extensions.js +36 -7
  23. package/dist/agent/mcp/oauth.js +38 -16
  24. package/dist/agent/mcp/session-server.js +0 -8
  25. package/dist/agent/session.js +11 -3
  26. package/dist/agent/skills.js +36 -0
  27. package/dist/agent/stream.js +75 -12
  28. package/dist/agent/utils.js +2 -0
  29. package/dist/bot/bot.js +29 -5
  30. package/dist/bot/render-shared.js +7 -0
  31. package/dist/bot/session-hub.js +39 -4
  32. package/dist/browser-profile.js +15 -12
  33. package/dist/catalog/mcp-servers.js +15 -1
  34. package/dist/channels/dingtalk/bot.js +532 -0
  35. package/dist/channels/dingtalk/channel.js +268 -0
  36. package/dist/channels/discord/bot.js +535 -0
  37. package/dist/channels/discord/channel.js +245 -0
  38. package/dist/channels/feishu/bot.js +7 -0
  39. package/dist/channels/feishu/channel.js +11 -4
  40. package/dist/channels/health.js +109 -0
  41. package/dist/channels/slack/bot.js +537 -0
  42. package/dist/channels/slack/channel.js +283 -0
  43. package/dist/channels/telegram/bot.js +7 -0
  44. package/dist/channels/telegram/channel.js +11 -5
  45. package/dist/channels/wecom/bot.js +541 -0
  46. package/dist/channels/wecom/channel.js +479 -0
  47. package/dist/channels/weixin/api.js +31 -3
  48. package/dist/channels/weixin/bot.js +9 -1
  49. package/dist/channels/weixin/channel.js +54 -24
  50. package/dist/cli/channel-supervisor.js +266 -0
  51. package/dist/cli/channels.js +16 -0
  52. package/dist/cli/main.js +16 -40
  53. package/dist/cli/onboarding.js +73 -1
  54. package/dist/core/config/user-config.js +16 -0
  55. package/dist/core/config/validation.js +199 -1
  56. package/dist/core/constants.js +65 -22
  57. package/dist/dashboard/platform.js +4 -143
  58. package/dist/dashboard/routes/agents.js +52 -8
  59. package/dist/dashboard/routes/config.js +46 -55
  60. package/dist/dashboard/routes/extensions.js +24 -0
  61. package/dist/dashboard/runtime.js +170 -46
  62. package/dist/model/index.js +1 -1
  63. package/dist/model/injector.js +142 -91
  64. package/dist/model/provider-models.js +56 -1
  65. package/package.json +9 -3
  66. package/dashboard/dist/assets/BrandIcon-D6bX6xOW.js +0 -1
  67. package/dashboard/dist/assets/ExtensionsTab-ia67Q6uS.js +0 -1
  68. package/dashboard/dist/assets/IMAccessTab-U9xiotD0.js +0 -1
  69. package/dashboard/dist/assets/Modals-F2LmTiab.js +0 -1
  70. package/dashboard/dist/assets/PermissionsTab-Y1MYlnVZ.js +0 -1
  71. package/dashboard/dist/assets/SessionPanel-CHwjOhZe.js +0 -1
  72. package/dashboard/dist/assets/appium-Ra-JU1qL.png +0 -0
  73. package/dashboard/dist/assets/index-COeEMXhW.js +0 -3
  74. package/dashboard/dist/assets/index-CURCCMRT.css +0 -1
  75. package/dashboard/dist/assets/index-C_0nuTx3.js +0 -16
  76. package/dashboard/dist/assets/shared-fBjJ1p7o.js +0 -1
  77. package/dist/agent/mcp/playwright-proxy.js +0 -300
  78. package/dist/agent/mcp/tools/desktop.js +0 -443
@@ -1 +1 @@
1
- import{r as s,j as e,b as Ce}from"./react-vendor-DTcmqLiz.js";import{c as H,u as Q,k as $,g as J,b as Ae,a as Z,B as F,S as te,E as me}from"./index-COeEMXhW.js";import{B as ae}from"./BrandIcon-D6bX6xOW.js";import{M as ge,a as be,L as U,I as W}from"./Modal-CzmUyl8t.js";import{S as se}from"./Select-CqNUDiiW.js";import{S as oe,A as ye}from"./shared-fBjJ1p7o.js";import"./router-emLofBBH.js";function pe(t,n){return!!(t&&n instanceof Node&&t.contains(n))}function Ee(t,n){if(n.length===0)return!0;const l=`${t.label} ${t.description||""} ${t.meta||""}`.toLowerCase();return n.every(i=>l.includes(i))}function Ie({value:t,options:n,onChange:l,className:i,placeholder:m="—",disabled:c=!1,searchPlaceholder:d="Search models...",noMatchesText:b="No matches",currentLabel:r="Current"}){const o=n.find(j=>j.value===t),v=n.length<=1,[g,A]=s.useState(!1),[I,k]=s.useState(""),[P,N]=s.useState(null),S=s.useRef(null),a=s.useRef(null),p=s.useRef(null);s.useEffect(()=>{if(!g)return;const j=C=>{pe(S.current,C.target)||pe(a.current,C.target)||A(!1)},L=C=>{C.key==="Escape"&&A(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",L)}},[g]),s.useEffect(()=>{g||k("")},[g]),s.useEffect(()=>{if(g){const j=window.setTimeout(()=>p.current?.focus(),0);return()=>window.clearTimeout(j)}},[g]),s.useLayoutEffect(()=>{if(!g)return;const j=()=>{const L=S.current;if(!L)return;const C=L.getBoundingClientRect(),K=window.innerHeight-C.bottom-12,O=C.top-12,B=K<280&&O>K,X=Math.max(220,Math.min(360,B?O:K));N({left:C.left,top:B?Math.max(12,C.top-X-8):C.bottom+8,width:C.width,maxHeight:X})};return j(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[g]);const w=s.useMemo(()=>I.trim().toLowerCase().split(/\s+/).filter(Boolean),[I]),M=s.useMemo(()=>n.filter(j=>j.value!==t&&Ee(j,w)),[n,t,w]);if(v)return e.jsx("div",{className:H("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",c&&"cursor-not-allowed",i),children:e.jsx("span",{className:H("truncate",!o&&"text-fg-6"),children:o?.label||m})});const y=j=>{c||(l(j),A(!1))},z=(j,L)=>e.jsxs("button",{type:"button",role:"option","aria-selected":L,onClick:()=>y(j.value),className:H("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:j.label}),j.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:j.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"})})]},j.value),q=g&&P?Ce.createPortal(e.jsxs("div",{ref:a,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:P.left,top:P.top,width:P.width,maxHeight:P.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:p,type:"text",value:I,onChange:j=>k(j.target.value),placeholder:d,spellCheck:!1,autoComplete:"off",className:H("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:r}),z(o,!0),e.jsx("div",{className:"my-1.5 border-t border-edge"})]}),M.length>0?M.map(j=>z(j,!1)):e.jsx("div",{className:"px-3 py-3 text-center text-[12px] text-fg-5",children:b})]})]}),document.body):null;return e.jsxs("div",{ref:S,className:H("relative",i),children:[e.jsxs("button",{type:"button",disabled:c,"aria-haspopup":"listbox","aria-expanded":g,onClick:()=>A(j=>!j),className:H("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",g&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:H("min-w-0 flex-1 truncate",!o&&"text-fg-5"),children:o?.label||m}),e.jsx("span",{className:H("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",g&&"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"})})})]}),q]})}const re=[{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 Me(t){return t==="zh-CN"?{sectionTitle:"模型供应商",sectionHint:"连接你自己的模型供应商,凭据加密存入系统 Keychain,可绑定到任意一个智能体。",templatesLabel:"快捷接入",configuredLabel:"已配置",emptyTitle:"尚未连接任何供应商",emptyHint:"点击上方任一模板开始接入。",validate:"校验",validating:"校验中",edit:"编辑",remove:"删除",removeConfirm:"删除该供应商?已绑定的智能体会自动恢复为官方 Auth。",unbound:"尚未被任何智能体使用",modalAddTitle:"接入模型供应商",modalAddHint:n=>n?`已套用 ${n} 模板,仅需粘贴 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:"凭据",templateConnected:"已接入",modelsAvailable:n=>`可用 ${n} 个模型`}:{sectionTitle:"Model Providers",sectionHint:"Connect your own model providers. Keys are encrypted in the OS keychain and can be bound to any agent.",templatesLabel:"Quick Connect",configuredLabel:"Connected",emptyTitle:"No providers connected yet",emptyHint:"Pick any template above to get started.",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",modalAddTitle:"Connect Model Provider",modalAddHint:n=>n?`Pre-filled from the ${n} 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",templateConnected:"Connected",modelsAvailable:n=>`${n} models available`}}const ce={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 he(t,n){return n==="zh-CN"?ce[t].zh:ce[t].en}async function de(t){return(await fetch(t)).json()}async function ne(t,n,l){return(await fetch(n,{method:t,headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0})).json()}function je(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}function Le({v:t,copy:n}){if(!t||t.state==="unknown")return e.jsx($,{variant:"muted",children:n.validationUnvalidated});if(t.state==="ready"){const l=t.modelCount?` · ${n.modelsAvailable(t.modelCount)}`:"";return e.jsxs($,{variant:"ok",children:[n.validationReady,l]})}return t.state==="invalid"?e.jsx($,{variant:"err",children:n.validationInvalid}):e.jsx($,{variant:"warn",children:n.validationError})}function Pe({template:t,locale:n,connected:l,onPick:i}){const m=n==="zh-CN"?t.name.zh:t.name.en,c=n==="zh-CN"?t.blurb.zh:t.blurb.en,d=n==="zh-CN"?"已接入":"Connected";return e.jsxs("button",{type:"button",onClick:()=>i(t),className:"group relative flex flex-col items-start gap-2 rounded-md border border-edge bg-panel-alt px-3.5 py-3 text-left transition hover:border-edge-strong hover:bg-panel",children:[l&&e.jsxs("span",{className:"absolute right-2 top-2 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",style:{borderColor:"var(--th-badge-ok-border)",backgroundColor:"var(--th-badge-ok-bg)",color:"var(--th-badge-ok-text)",borderWidth:1},children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),d]}),e.jsx(ae,{brand:t.id,size:28}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-semibold tracking-tight text-fg group-hover:text-fg",children:m}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-fg-5 line-clamp-2",children:c})]})]})}function ue(t,n){return{name:n==="zh-CN"?`${t.name.zh}`:`${t.name.en}`,kind:t.kind,baseURL:t.baseURL,credMode:"paste",apiKey:"",envVar:t.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}}function Se({open:t,copy:n,locale:l,initial:i,initialTemplateName:m,existingProvider:c,onClose:d,onSaved:b}){const[r,o]=s.useState(()=>i||ue(re[0],l)),[v,g]=s.useState(!1),[A,I]=s.useState(null);s.useEffect(()=>{t&&(o(i||ue(re[0],l)),I(null))},[t,i,l]);const k=!!c,P=!!m||k,N=s.useCallback(async()=>{I(null),g(!0);try{const a=r.credMode==="env"?{source:"env",varName:r.envVar.trim()}:r.credMode==="command"?{source:"command",argv:r.cmdLine.trim().split(/\s+/).filter(Boolean)}:null;let p;if(k&&c){const M={name:r.name.trim()||c.name,baseURL:r.baseURL.trim()};r.credMode==="paste"&&r.apiKey?M.apiKey=r.apiKey:a&&(M.credentialRef=a);const y=await ne("PATCH",`/api/models/providers/${c.id}`,M);if(!y.ok){I(y.error||"Failed to update provider");return}p=c.id}else{const M={kind:r.kind,name:r.name.trim()||`${he(r.kind,l)}`,baseURL:r.baseURL.trim()};r.credMode==="paste"?M.apiKey=r.apiKey:a&&(M.credentialRef=a);const y=await ne("POST","/api/models/providers",M);if(!y.ok||!y.provider){I(y.error||"Failed to create provider");return}p=y.provider.id}const w=await ne("POST",`/api/models/providers/${p}/validate`);if(b(),w.validation&&w.validation.state!=="ready"){I(`${n.validationInvalid}: ${w.validation.detail}`);return}d()}catch(a){I(a?.message||String(a))}finally{g(!1)}},[r,k,c,l,b,d,n.validationInvalid]),S=!v&&r.name.trim().length>0&&r.baseURL.trim().length>0&&(r.credMode!=="paste"||(k?!0:r.apiKey.length>0))&&(r.credMode!=="env"||r.envVar.trim().length>0)&&(r.credMode!=="command"||r.cmdLine.trim().length>0);return e.jsxs(ge,{open:t,onClose:d,children:[e.jsx(be,{title:k?n.modalEditTitle:n.modalAddTitle,description:k?n.modalEditHint:n.modalAddHint(m||null),onClose:d}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(U,{children:n.fieldName}),e.jsx(W,{value:r.name,onChange:a=>o(p=>({...p,name:a.target.value})),placeholder:n.fieldNamePlaceholder})]}),P?e.jsxs("div",{children:[e.jsx(U,{children:n.fieldBaseURL}),e.jsx(W,{value:r.baseURL,onChange:a=>o(p=>({...p,baseURL:a.target.value})),placeholder:"https://…"})]}):e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(U,{children:n.fieldKind}),e.jsx(se,{value:r.kind,options:Object.keys(ce).map(a=>({value:a,label:he(a,l)})),onChange:a=>o(p=>({...p,kind:a}))})]}),e.jsxs("div",{children:[e.jsx(U,{children:n.fieldBaseURL}),e.jsx(W,{value:r.baseURL,onChange:a=>o(p=>({...p,baseURL:a.target.value})),placeholder:"https://…"})]})]}),e.jsxs("div",{children:[e.jsx(U,{children:n.fieldCredentialSource}),e.jsx(se,{value:r.credMode,options:[{value:"paste",label:n.credPaste},{value:"env",label:n.credEnv},{value:"command",label:n.credCommand}],onChange:a=>o(p=>({...p,credMode:a}))})]}),r.credMode==="paste"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldApiKey}),e.jsx(W,{type:"password",value:r.apiKey,onChange:a=>o(p=>({...p,apiKey:a.target.value})),placeholder:k?"••••••••":"sk-…"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:n.fieldApiKeyHint})]}),r.credMode==="env"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldEnvVar}),e.jsx(W,{value:r.envVar,onChange:a=>o(p=>({...p,envVar:a.target.value})),placeholder:"OPENROUTER_API_KEY"})]}),r.credMode==="command"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldCommand}),e.jsx(W,{value:r.cmdLine,onChange:a=>o(p=>({...p,cmdLine:a.target.value})),placeholder:"op read op://Personal/OpenRouter/key"})]}),A&&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:A})]}),e.jsx("div",{className:"mt-6 border-t border-edge pt-4",children:e.jsx(ye,{primary:{label:v?n.saving:n.save,onClick:N,disabled:!S},secondary:{label:n.cancel,onClick:d}})})]})}function Ne(){const[t,n]=s.useState([]),[l,i]=s.useState([]),[m,c]=s.useState({}),d=s.useCallback(async()=>{const[r,o,v]=await Promise.all([de("/api/models/providers"),de("/api/models/profiles"),de("/api/models/agents")]);n(r.providers||[]),i(o.profiles||[]);const g={};for(const A of v.bindings||[])g[A.agent]=A.activeProfileId;c(g)},[]),b=s.useCallback(async(r,o)=>{await ne("POST",`/api/models/agents/${r}/active`,{profileId:o}),await d()},[d]);return s.useEffect(()=>{d()},[d]),{providers:t,profiles:l,bindings:m,reload:d,setActiveProfile:b}}function Re({provider:t,copy:n,boundAgents:l,onEdit:i,onRemove:m}){const c=je(t);return e.jsx("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:c,size:22})}),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-[15px] font-semibold tracking-tight text-fg",children:t.name}),e.jsx(Le,{v:t.validation,copy:n})]}),e.jsx("div",{className:"mt-1 truncate text-[11px] font-mono text-fg-5",title:t.baseURL,children:t.baseURL}),t.validation?.detail&&t.validation.state!=="ready"&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-4",children:t.validation.detail}),l.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:l.map(d=>{const b=J(d);return e.jsxs("span",{className:"inline-flex h-5 items-center gap-1 rounded-full border border-edge bg-panel-alt px-2 text-[11px] text-fg-3",children:[e.jsx(ae,{brand:d,size:11}),e.jsx("span",{children:b.shortLabel})]},d)})}):e.jsx("div",{className:"mt-2 text-[11px] text-fg-5",children:n.unbound})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3 self-start text-[12px]",children:[e.jsx("button",{type:"button",onClick:i,className:"text-fg-4 transition hover:text-fg-2",children:n.edit}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:m,className:"text-fg-4 transition hover:text-[var(--th-err)]",children:n.remove})]})]})})}function Te({snapshot:t}={}){const n=Ne(),l=t??n,{providers:i,profiles:m,bindings:c,reload:d}=l,b=Q(a=>a.locale),r=s.useMemo(()=>Me(b),[b]);Q(a=>a.toast);const[o,v]=s.useState(null),g=s.useMemo(()=>{const a=new Map,p=new Map(m.map(w=>[w.id,w]));for(const[w,M]of Object.entries(c)){if(!M)continue;const y=p.get(M);y&&(a.has(y.providerId)||a.set(y.providerId,[]),a.get(y.providerId).push(w))}return a},[c,m]),A=s.useCallback(async a=>{confirm(r.removeConfirm)&&(await ne("DELETE",`/api/models/providers/${a.id}`),await d())},[r,d]),I=s.useMemo(()=>{if(!o||o.kind!=="edit")return null;const{provider:a}=o;return{name:a.name,kind:a.kind,baseURL:a.baseURL,credMode:"paste",apiKey:"",envVar:re.find(p=>p.kind===a.kind)?.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}},[o]),k=s.useMemo(()=>!o||o.kind!=="add"?null:ue(o.template,b),[o,b]),P=o&&o.kind==="add"&&o.template.id!=="custom"?b==="zh-CN"?o.template.name.zh:o.template.name.en:null,N=s.useMemo(()=>{const a=new Map;for(const p of i){const w=je(p);a.has(w)||a.set(w,p)}return a},[i]),S=s.useCallback(a=>{if(a.id!=="custom"){const p=N.get(a.id);if(p){v({kind:"edit",provider:p});return}}v({kind:"add",template:a})},[N]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:r.templatesLabel}),e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:re.map(a=>e.jsx(Pe,{template:a,locale:b,connected:a.id!=="custom"&&N.has(a.id),onPick:S},a.id))})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:r.configuredLabel}),i.length===0&&e.jsx(oe,{className:"border-dashed",children:e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:"custom",size:20})}),e.jsx("div",{className:"mt-3 text-[14px] font-semibold tracking-tight text-fg",children:r.emptyTitle}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-4",children:r.emptyHint})]})}),i.map(a=>e.jsx(Re,{provider:a,copy:r,locale:b,boundAgents:g.get(a.id)||[],onEdit:()=>v({kind:"edit",provider:a}),onRemove:()=>A(a)},a.id))]}),o&&e.jsx(Se,{open:!0,copy:r,locale:b,initial:o.kind==="edit"?I:k,initialTemplateName:P,existingProvider:o.kind==="edit"?o.provider:void 0,onClose:()=>v(null),onSaved:d})]})}const le="__native__",_e=["claude","codex","gemini","hermes"];function xe(t){return t===void 0||!Number.isFinite(t)?null:t===0?"$0":t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:t<10?`$${t.toFixed(2)}`:`$${t.toFixed(1)}`}function Oe(t){return!t||!Number.isFinite(t)?null:t>=1e6?`${Math.round(t/1e5)/10}M ctx`:t>=1e3?`${Math.round(t/1e3)}K ctx`:`${t} ctx`}function De(t){if(!t||!Number.isFinite(t))return null;const n=t>32e9?t:t*1e3,l=new Date(n);return Number.isNaN(l.getTime())?null:l.toLocaleDateString(void 0,{year:"numeric",month:"short"})}function Ue(t){const n=t.id,l=[],i=t.name?.trim();i&&i.toLowerCase()!==t.id.toLowerCase()&&l.push(i);const m=xe(t.pricePromptUsd),c=xe(t.priceCompletionUsd);m&&c?l.push(`${m} / ${c} per 1M`):m&&l.push(`${m} prompt / 1M`);const d=Oe(t.contextLength);d&&l.push(d);const b=De(t.created);return b&&l.push(b),{label:n,description:l.length?l.join(" · "):void 0}}function ze(t){return t==="hermes"}function Ke(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}function He(t,n){const l=t.bindings[n];if(!l)return null;const i=t.profiles.find(c=>c.id===l);if(!i)return null;const m=t.providers.find(c=>c.id===i.providerId);return m?{profileId:i.id,providerId:m.id,providerName:m.name,providerBrand:Ke(m),modelId:i.modelId,effort:i.effort||null}:null}function $e(t){return t==="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 供应商;接入后可在上方任一智能体卡片的「供应商」下拉中选用。",rowProvider:"供应商",rowModel:"模型",rowEffort:"推理强度",providerNative:"官方(CLI 内置认证)",providerNativeFromAgent:"智能体自身配置",effortDefault:"默认",modelLoading:"正在拉取模型列表…",modelEmpty:"该供应商未返回模型列表,请使用自定义输入。",modelCustomToggle:"改为自定义输入",modelListToggle:"从列表选择",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"搜索模型",modelSearchEmpty:"没有匹配的模型",modelCurrentLabel:"当前",saveChanges:"保存",saving:"保存中…",cancel:"撤销",saved:"已保存",configError:"保存失败",externalNativeNote:n=>`Hermes 当前从 ${n||"~/.hermes/config.yaml"} 读取这些值;切换为某个 BYOK 供应商可由 pikiclaw 接管。`}:{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.",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…",cancel:"Reset",saved:"Saved",configError:"Save failed",externalNativeNote:n=>`Hermes reads these values from ${n||"~/.hermes/config.yaml"}; pick a BYOK provider to let pikiclaw take over.`}}function Fe(t,n){const l=t.filter(m=>m.installed);return(l.length?l:t).map(m=>({value:m.agent,label:`${J(m.agent).label} · ${m.installed?m.version||n.installed:n.notInstalled}`}))}function Be(t){return t.selectedModel?t.selectedModel:t.models.length?t.models[0].id:""}function ve(t,n){t({defaultAgent:n.defaultAgent,agents:n.agents})}function Ve(t,n,l){if(l)return{providerId:l.providerId,modelId:l.modelId,effort:l.effort||"",modelMode:"list"};const i=n?.nativeConfig||null;return{providerId:le,modelId:i?.model||n?.selectedModel||"",effort:i?.effort||n?.selectedEffort||"",modelMode:"list"}}function Ye(t,n){return t.providerId===n.providerId&&t.modelId.trim()===n.modelId.trim()&&(t.effort||"")===(n.effort||"")}function Ge({agentId:t,agentStatus:n,boundInfo:l,copy:i,layer:m,toast:c,onSaved:d}){const b=ze(t),r=n.nativeConfig||null,o=s.useMemo(()=>Ve(t,n,l),[t,n,l]),[v,g]=s.useState(o),[A,I]=s.useState(!1),[k,P]=s.useState(null);s.useEffect(()=>{g(o),P(null)},[o]);const N=v.providerId===le,S=N&&b,[a,p]=s.useState([]),[w,M]=s.useState(!1),[y,z]=s.useState(null);s.useEffect(()=>{if(N){p([]),z(null),M(!1);return}let h=!1;return M(!0),z(null),fetch(`/api/models/providers/${v.providerId}/models`).then(u=>u.json()).then(u=>{h||(u.ok?u.modelInfos&&u.modelInfos.length?p(u.modelInfos):p((u.models||[]).map(E=>({id:E}))):(z(u.error||"Failed to load models"),p([])))}).catch(u=>{h||(z(u?.message||String(u)),p([]))}).finally(()=>{h||M(!1)}),()=>{h=!0}},[v.providerId,N]);const q=s.useMemo(()=>a.map(h=>h.id),[a]),j=s.useMemo(()=>n.models.map(h=>h.id),[n]),L=N?j:q;s.useEffect(()=>{if(!w){if(N){v.modelMode==="custom"&&g(h=>({...h,modelMode:"list"}));return}L.length===0&&v.modelMode==="list"&&g(h=>({...h,modelMode:"custom"}))}},[L,w,v.modelMode,N]);const C=s.useMemo(()=>{const h=b?`${i.providerNativeFromAgent}${r?.provider?` · ${r.provider}`:""}`:i.providerNative,u=[{value:le,label:h}];for(const E of m.providers)u.push({value:E.id,label:E.name});return u},[b,r,m.providers,i.providerNative,i.providerNativeFromAgent]),R=s.useMemo(()=>{const h=me[t]||me.claude;return[{value:"",label:i.effortDefault},...h.map(u=>({value:u,label:u}))]},[t,i.effortDefault]),K=s.useMemo(()=>{let h;return N?h=n.models.map(u=>{const E=u.alias?.toLowerCase().replace(/[\s_-]/g,""),V=u.id.toLowerCase().replace(/[\s_-]/g,""),_=u.alias&&E!==V;return{value:u.id,label:u.id,description:_?u.alias:void 0}}):h=a.map(u=>({value:u.id,...Ue(u)})),v.modelMode==="list"&&v.modelId&&!h.some(u=>u.value===v.modelId)&&h.unshift({value:v.modelId,label:v.modelId}),h},[N,n.models,a,v.modelMode,v.modelId]),O=!Ye(v,o),B=!A&&O&&(S||!!v.modelId.trim()),X=s.useCallback(async()=>{P(null),I(!0);try{const h=v.effort||null,u=v.modelId.trim();if(N){const E=m.bindings[t],V=E?m.profiles.find(_=>_.id===E):null;if(E&&await m.setActiveProfile(t,null),V&&await fetch(`/api/models/profiles/${V.id}`,{method:"DELETE"}),!b){const _={agent:t};if(u&&u!==(n.selectedModel||"")&&(_.model=u),h!==(n.selectedEffort||null)&&(_.effort=h),Object.keys(_).length>1){const Y=await Z.updateRuntimeAgent(_);if(!Y.ok)throw new Error(Y.error||"Failed to update agent")}}}else{const E=m.providers.find(D=>D.id===v.providerId);if(!E)throw new Error("Provider not found");const V=J(t),_=m.bindings[t],Y=_?m.profiles.find(D=>D.id===_):null,ie={providerId:E.id,modelId:u,effort:h,name:`${V.label} · ${E.name}`};let G=Y?.id;if(Y){const D=await fetch(`/api/models/profiles/${Y.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)}).then(ee=>ee.json());if(!D.ok)throw new Error(D.error||"Failed to update profile")}else{const D=await fetch("/api/models/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)}).then(ee=>ee.json());if(!D.ok)throw new Error(D.error||"Failed to create profile");G=D.profile?.id}G&&await m.setActiveProfile(t,G)}await Promise.resolve(d()),c(i.saved)}catch(h){const u=h?.message||String(h);P(u),c(`${i.configError}: ${u}`,!1)}finally{I(!1)}},[t,n,i,v,b,N,m,d,c]);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(U,{className:"!mb-1 text-[11px]",children:i.rowProvider}),e.jsx(se,{value:v.providerId,options:C,onChange:h=>g(u=>{if(h===u.providerId)return u;const E={...u,providerId:h,modelId:"",modelMode:"list"};return h===le&&(E.modelId=Be(n),E.effort=n.nativeConfig?.effort||n.selectedEffort||""),E})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx(U,{className:"!mb-0 text-[11px]",children:i.rowModel}),!S&&!N&&e.jsx("button",{type:"button",onClick:()=>g(h=>({...h,modelMode:h.modelMode==="list"?"custom":"list"})),className:"text-[10px] text-fg-5 underline-offset-2 transition hover:text-fg-3 hover:underline",children:v.modelMode==="list"?i.modelCustomToggle:i.modelListToggle})]}),S?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:r?.model||i.noModel})}):v.modelMode==="list"?w&&!N?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(te,{className:"h-3.5 w-3.5"}),i.modelLoading]}):e.jsx(Ie,{value:v.modelId,options:K,onChange:h=>g(u=>({...u,modelId:h})),placeholder:L.length?"—":i.modelEmpty,searchPlaceholder:i.modelSearchPlaceholder,noMatchesText:i.modelSearchEmpty,currentLabel:i.modelCurrentLabel}):e.jsx(W,{value:v.modelId,onChange:h=>g(u=>({...u,modelId:h.target.value})),placeholder:i.modelCustomPlaceholder})]}),e.jsxs("div",{children:[e.jsx(U,{className:"!mb-1 text-[11px]",children:i.rowEffort}),S?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:r?.effort||i.effortDefault})}):e.jsx(se,{value:v.effort,options:R,onChange:h=>g(u=>({...u,effort:h}))})]})]}),S&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:i.externalNativeNote(r?.configPath||"")}),(k||y)&&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||y}),O&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>g(o),disabled:A,children:i.cancel}),e.jsx(F,{variant:"primary",size:"sm",disabled:!B,onClick:()=>{X()},children:A?i.saving:i.saveChanges})]})]})}function qe({agent:t,copy:n,t:l,installing:i,onInstall:m,updatingAgent:c,checkingAgent:d,onUpdate:b,onCheckUpdate:r,loading:o=!1,layer:v,boundInfo:g,toast:A,onConfigSaved:I}){const k=J(t.agent),P=t.version||n.noVersion,N=k.advantageKey?l(k.advantageKey):"";return e.jsxs("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:t.agent,size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[15px] font-semibold text-fg",children:k.label}),t.isDefault&&e.jsx($,{variant:"accent",children:n.defaultBadge}),o?e.jsxs($,{variant:"muted",children:[e.jsx(te,{className:"h-3 w-3"})," ",l("status.loading")]}):t.installed?e.jsx($,{variant:"ok",children:n.installed}):e.jsx($,{variant:"warn",children:n.notInstalled}),t.installed&&t.updateAvailable&&e.jsx($,{variant:"warn",children:n.updateAvailable})]}),e.jsxs("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-5",children:[n.versionLabel,": ",P,t.latestVersion&&t.updateAvailable&&e.jsxs("span",{className:"ml-1.5 text-amber-400",children:["→ ",t.latestVersion]}),t.latestVersion&&!t.updateAvailable&&t.installed&&e.jsx("span",{className:"ml-1.5 text-emerald-400",children:"✓"})]})]})]}),e.jsxs("div",{className:H("flex shrink-0 flex-col items-end gap-1.5"),children:[o&&e.jsxs("div",{className:"inline-flex h-7 items-center gap-2 rounded-md border border-edge bg-transparent px-2.5 text-[11px] text-fg-5",children:[e.jsx(te,{className:"h-3 w-3"}),l("status.loading")]}),!o&&!t.installed&&e.jsx(F,{variant:"primary",size:"sm",disabled:i,onClick:()=>m(t),children:i?n.installing:n.install}),!o&&t.installed&&t.updateAvailable&&e.jsx(F,{variant:"outline",size:"sm",disabled:c,onClick:()=>b(t),children:c?n.updating:n.update}),!o&&t.installed&&!t.updateAvailable&&e.jsx(F,{variant:"ghost",size:"sm",disabled:d,onClick:()=>r(t),className:"gap-1.5 text-[11px]",children:d?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-3 w-3"})," ",n.checking]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",n.checkUpdate]})})]})]}),N&&e.jsx("div",{className:"mt-2 text-[12px] leading-relaxed text-fg-4",children:N}),!o&&!t.installed&&e.jsx("div",{className:"mt-3 rounded-md border border-dashed border-edge bg-panel-alt px-3 py-2.5 text-[12px] leading-relaxed text-fg-4",children:n.notInstalledHint}),!o&&t.installed&&e.jsx("div",{className:"mt-3 border-t border-edge pt-3",children:e.jsx(Ge,{agentId:t.agent,agentStatus:t,boundInfo:g,copy:n,layer:v,toast:A,onSaved:I})}),!o&&t.installed&&t.updateAvailable&&t.updateStatus==="skipped"&&t.updateDetail&&e.jsxs("div",{className:"mt-2 text-[11px] leading-relaxed",style:{color:"var(--th-badge-warn-text)"},children:[n.updateSkipped,": ",t.updateDetail]}),!o&&t.installed&&t.updateStatus==="failed"&&t.updateDetail&&e.jsxs("div",{className:"mt-2 text-[11px] leading-relaxed",style:{color:"var(--th-badge-err-text)"},children:[n.updateFailed,": ",t.updateDetail]})]})}function We({label:t,value:n,hint:l,loading:i=!1}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt px-3.5 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:t}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[13px] font-semibold text-fg-2",children:[i&&e.jsx(te,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n})]}),l&&e.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-fg-5",children:l})]})}function at(){const t=Q(f=>f.locale),n=Q(f=>f.toast),l=Q(f=>f.agentStatus),i=Q(f=>f.setAgentStatus),m=Q(f=>f.refreshAgentStatus),c=s.useMemo(()=>Ae(t),[t]),d=s.useMemo(()=>$e(t),[t]),b=Ne(),[r,o]=s.useState(l?{defaultAgent:l.defaultAgent,agents:l.agents}:null),[v,g]=s.useState(!l),[A,I]=s.useState(null),[k,P]=s.useState(!1),[N,S]=s.useState(null),[a,p]=s.useState(!1),[w,M]=s.useState("codex"),[y,z]=s.useState(null),[q,j]=s.useState(null),L=s.useRef(!!l);s.useEffect(()=>{l&&(ve(o,l),L.current||(L.current=!0,g(!1)))},[l]);const C=s.useCallback(f=>{ve(o,f),i(f)},[i]),R=s.useCallback(async()=>{L.current||g(!0);try{const f=await Z.getAgentStatus();return C(f),I(null),L.current=!0,f}catch(f){const x=f instanceof Error?f.message:d.loadFailed;return I(x),L.current||n(x,!1),null}finally{g(!1)}},[C,d.loadFailed,n]);s.useEffect(()=>{l?m():R()},[]);const K=s.useMemo(()=>{const f=r?.agents||[],x=new Map(f.map(T=>[T.agent,T]));return _e.map(T=>{const fe=x.get(T);if(fe)return fe;const we=J(T);return{agent:T,label:we.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:r?.defaultAgent===T,models:[],usage:null}})},[r]),O=r?.defaultAgent||"codex",B=K.find(f=>f.agent===O)||null,h=K.filter(f=>f.installed).length>0,u=Fe(K,d),E=s.useCallback(async f=>{P(!0);try{const x=await Z.updateRuntimeAgent(f);if(!x.ok)throw new Error(x.error||c("config.applyFailed"));return C(x),x}catch(x){const T=x instanceof Error?x.message:c("config.applyFailed");return n(T,!1),R(),null}finally{P(!1)}},[C,R,c,n]);s.useEffect(()=>{a&&M(O)},[O,a]);const V=s.useCallback(async()=>{if(w===O){p(!1);return}await E({defaultAgent:w})&&(n(d.defaultsSaved),p(!1))},[d.defaultsSaved,O,w,n,E]),_=s.useCallback(async f=>{if(!N){S(f.agent);try{const x=await Z.installAgent(f.agent);if(!x.ok)throw new Error(x.error||c("config.agentInstallFailed"));C(x),n(c("config.agentInstalled"))}catch(x){const T=x instanceof Error?x.message:c("config.agentInstallFailed");n(T,!1),R()}finally{S(x=>x===f.agent?null:x)}}},[C,N,R,c,n]),Y=s.useCallback(async f=>{if(!y){z(f.agent);try{const x=await Z.updateAgent(f.agent);if(!x.ok)throw new Error(x.error||c("config.agentInstallFailed"));C(x),n(d.upToDate)}catch(x){const T=x instanceof Error?x.message:d.updateFailed;n(T,!1),R()}finally{z(x=>x===f.agent?null:x)}}},[C,d.updateFailed,d.upToDate,R,c,n,y]),ie=s.useCallback(async f=>{if(!q){j(f.agent);try{const x=await Z.checkAgentUpdate(f.agent);if(!x.ok)throw new Error(x.error||d.loadFailed);C(x)}catch(x){const T=x instanceof Error?x.message:d.loadFailed;n(T,!1),R()}finally{j(x=>x===f.agent?null:x)}}},[C,q,d.loadFailed,R,n]),G=v&&!r,D=G?c("status.loading"):B?J(B.agent).label:d.notInstalled,ee=G?c("status.loading"):B?.installed?d.installed:d.notInstalled,ke=s.useCallback(async()=>{await b.reload(),await R()},[b,R]);return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsx("section",{className:"space-y-3",children:e.jsxs(oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.defaultsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.defaultsHint})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{variant:"secondary",onClick:()=>p(!0),disabled:k||!h,children:d.editDefaults})})]}),e.jsx(We,{label:d.defaultAgent,value:D,hint:ee,loading:G})]})}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),e.jsx("div",{className:"space-y-3",children:K.map(f=>e.jsx(qe,{agent:f,copy:d,t:c,installing:N===f.agent,loading:G,onInstall:_,updatingAgent:y===f.agent,checkingAgent:q===f.agent,onUpdate:Y,onCheckUpdate:ie,layer:b,boundInfo:He(b,f.agent),toast:n,onConfigSaved:ke},f.agent))})]}),A&&e.jsx(oe,{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:A}),e.jsx(F,{variant:"outline",size:"sm",onClick:()=>{R()},children:c("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(Te,{snapshot:b})]}),e.jsxs(ge,{open:a,onClose:()=>p(!1),children:[e.jsx(be,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>p(!1)}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(U,{children:d.defaultAgent}),e.jsx(se,{value:w,options:u,onChange:f=>M(f),disabled:k||!h,placeholder:d.notInstalled})]})}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(F,{variant:"ghost",onClick:()=>p(!1),children:c("modal.cancel")}),e.jsx(F,{variant:"primary",disabled:k||w===O,onClick:()=>{V()},children:c(k?"config.validating":"modal.save")})]})]})]})}export{at as AgentTab,at as default};
1
+ import{r as i,j as e,b as Ce}from"./react-vendor-DTcmqLiz.js";import{c as H,u as Q,k as $,g as J,b as Ae,a as Z,B as F,S as te,E as me}from"./index-CypsxtrZ.js";import{B as ae}from"./BrandIcon-DHaeSgX8.js";import{M as ge,a as be,L as U,I as W}from"./Modal-DxYHCIeK.js";import{S as ie}from"./Select-CtTWpzUC.js";import{S as oe,A as ye}from"./shared-JcpxfGic.js";import"./router-emLofBBH.js";function pe(t,n){return!!(t&&n instanceof Node&&t.contains(n))}function Ee(t,n){if(n.length===0)return!0;const l=`${t.label} ${t.description||""} ${t.meta||""}`.toLowerCase();return n.every(s=>l.includes(s))}function Ie({value:t,options:n,onChange:l,className:s,placeholder:m="—",disabled:c=!1,searchPlaceholder:d="Search models...",noMatchesText:b="No matches",currentLabel:r="Current"}){const o=n.find(j=>j.value===t),v=n.length<=1,[g,A]=i.useState(!1),[I,k]=i.useState(""),[S,N]=i.useState(null),P=i.useRef(null),a=i.useRef(null),p=i.useRef(null);i.useEffect(()=>{if(!g)return;const j=C=>{pe(P.current,C.target)||pe(a.current,C.target)||A(!1)},L=C=>{C.key==="Escape"&&A(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",L)}},[g]),i.useEffect(()=>{g||k("")},[g]),i.useEffect(()=>{if(g){const j=window.setTimeout(()=>p.current?.focus(),0);return()=>window.clearTimeout(j)}},[g]),i.useLayoutEffect(()=>{if(!g)return;const j=()=>{const L=P.current;if(!L)return;const C=L.getBoundingClientRect(),K=window.innerHeight-C.bottom-12,O=C.top-12,B=K<280&&O>K,X=Math.max(220,Math.min(360,B?O:K));N({left:C.left,top:B?Math.max(12,C.top-X-8):C.bottom+8,width:C.width,maxHeight:X})};return j(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[g]);const w=i.useMemo(()=>I.trim().toLowerCase().split(/\s+/).filter(Boolean),[I]),M=i.useMemo(()=>n.filter(j=>j.value!==t&&Ee(j,w)),[n,t,w]);if(v)return e.jsx("div",{className:H("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",c&&"cursor-not-allowed",s),children:e.jsx("span",{className:H("truncate",!o&&"text-fg-6"),children:o?.label||m})});const y=j=>{c||(l(j),A(!1))},z=(j,L)=>e.jsxs("button",{type:"button",role:"option","aria-selected":L,onClick:()=>y(j.value),className:H("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:j.label}),j.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:j.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"})})]},j.value),q=g&&S?Ce.createPortal(e.jsxs("div",{ref:a,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:S.left,top:S.top,width:S.width,maxHeight:S.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:p,type:"text",value:I,onChange:j=>k(j.target.value),placeholder:d,spellCheck:!1,autoComplete:"off",className:H("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:r}),z(o,!0),e.jsx("div",{className:"my-1.5 border-t border-edge"})]}),M.length>0?M.map(j=>z(j,!1)):e.jsx("div",{className:"px-3 py-3 text-center text-[12px] text-fg-5",children:b})]})]}),document.body):null;return e.jsxs("div",{ref:P,className:H("relative",s),children:[e.jsxs("button",{type:"button",disabled:c,"aria-haspopup":"listbox","aria-expanded":g,onClick:()=>A(j=>!j),className:H("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",g&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:H("min-w-0 flex-1 truncate",!o&&"text-fg-5"),children:o?.label||m}),e.jsx("span",{className:H("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",g&&"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"})})})]}),q]})}const re=[{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 Me(t){return t==="zh-CN"?{sectionTitle:"模型供应商",sectionHint:"连接你自己的模型供应商,凭据加密存入系统 Keychain,可绑定到任意一个智能体。",templatesLabel:"快捷接入",configuredLabel:"已配置",emptyTitle:"尚未连接任何供应商",emptyHint:"点击上方任一模板开始接入。",validate:"校验",validating:"校验中",edit:"编辑",remove:"删除",removeConfirm:"删除该供应商?已绑定的智能体会自动恢复为官方 Auth。",unbound:"尚未被任何智能体使用",modalAddTitle:"接入模型供应商",modalAddHint:n=>n?`已套用 ${n} 模板,仅需粘贴 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:"凭据",templateConnected:"已接入",modelsAvailable:n=>`可用 ${n} 个模型`}:{sectionTitle:"Model Providers",sectionHint:"Connect your own model providers. Keys are encrypted in the OS keychain and can be bound to any agent.",templatesLabel:"Quick Connect",configuredLabel:"Connected",emptyTitle:"No providers connected yet",emptyHint:"Pick any template above to get started.",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",modalAddTitle:"Connect Model Provider",modalAddHint:n=>n?`Pre-filled from the ${n} 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",templateConnected:"Connected",modelsAvailable:n=>`${n} models available`}}const ce={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 he(t,n){return n==="zh-CN"?ce[t].zh:ce[t].en}async function de(t){return(await fetch(t)).json()}async function ne(t,n,l){return(await fetch(n,{method:t,headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0})).json()}function je(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}function Le({v:t,copy:n}){if(!t||t.state==="unknown")return e.jsx($,{variant:"muted",children:n.validationUnvalidated});if(t.state==="ready"){const l=t.modelCount?` · ${n.modelsAvailable(t.modelCount)}`:"";return e.jsxs($,{variant:"ok",children:[n.validationReady,l]})}return t.state==="invalid"?e.jsx($,{variant:"err",children:n.validationInvalid}):e.jsx($,{variant:"warn",children:n.validationError})}function Se({template:t,locale:n,connected:l,onPick:s}){const m=n==="zh-CN"?t.name.zh:t.name.en,c=n==="zh-CN"?t.blurb.zh:t.blurb.en,d=n==="zh-CN"?"已接入":"Connected";return e.jsxs("button",{type:"button",onClick:()=>s(t),className:"group relative flex flex-col items-start gap-2 rounded-md border border-edge bg-panel-alt px-3.5 py-3 text-left transition hover:border-edge-strong hover:bg-panel",children:[l&&e.jsxs("span",{className:"absolute right-2 top-2 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",style:{borderColor:"var(--th-badge-ok-border)",backgroundColor:"var(--th-badge-ok-bg)",color:"var(--th-badge-ok-text)",borderWidth:1},children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),d]}),e.jsx(ae,{brand:t.id,size:28}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-semibold tracking-tight text-fg group-hover:text-fg",children:m}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-fg-5 line-clamp-2",children:c})]})]})}function ue(t,n){return{name:n==="zh-CN"?`${t.name.zh}`:`${t.name.en}`,kind:t.kind,baseURL:t.baseURL,credMode:"paste",apiKey:"",envVar:t.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}}function Pe({open:t,copy:n,locale:l,initial:s,initialTemplateName:m,existingProvider:c,onClose:d,onSaved:b}){const[r,o]=i.useState(()=>s||ue(re[0],l)),[v,g]=i.useState(!1),[A,I]=i.useState(null);i.useEffect(()=>{t&&(o(s||ue(re[0],l)),I(null))},[t,s,l]);const k=!!c,S=!!m||k,N=i.useCallback(async()=>{I(null),g(!0);try{const a=r.credMode==="env"?{source:"env",varName:r.envVar.trim()}:r.credMode==="command"?{source:"command",argv:r.cmdLine.trim().split(/\s+/).filter(Boolean)}:null;let p;if(k&&c){const M={name:r.name.trim()||c.name,baseURL:r.baseURL.trim()};r.credMode==="paste"&&r.apiKey?M.apiKey=r.apiKey:a&&(M.credentialRef=a);const y=await ne("PATCH",`/api/models/providers/${c.id}`,M);if(!y.ok){I(y.error||"Failed to update provider");return}p=c.id}else{const M={kind:r.kind,name:r.name.trim()||`${he(r.kind,l)}`,baseURL:r.baseURL.trim()};r.credMode==="paste"?M.apiKey=r.apiKey:a&&(M.credentialRef=a);const y=await ne("POST","/api/models/providers",M);if(!y.ok||!y.provider){I(y.error||"Failed to create provider");return}p=y.provider.id}const w=await ne("POST",`/api/models/providers/${p}/validate`);if(b(),w.validation&&w.validation.state!=="ready"){I(`${n.validationInvalid}: ${w.validation.detail}`);return}d()}catch(a){I(a?.message||String(a))}finally{g(!1)}},[r,k,c,l,b,d,n.validationInvalid]),P=!v&&r.name.trim().length>0&&r.baseURL.trim().length>0&&(r.credMode!=="paste"||(k?!0:r.apiKey.length>0))&&(r.credMode!=="env"||r.envVar.trim().length>0)&&(r.credMode!=="command"||r.cmdLine.trim().length>0);return e.jsxs(ge,{open:t,onClose:d,children:[e.jsx(be,{title:k?n.modalEditTitle:n.modalAddTitle,description:k?n.modalEditHint:n.modalAddHint(m||null),onClose:d}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(U,{children:n.fieldName}),e.jsx(W,{value:r.name,onChange:a=>o(p=>({...p,name:a.target.value})),placeholder:n.fieldNamePlaceholder})]}),S?e.jsxs("div",{children:[e.jsx(U,{children:n.fieldBaseURL}),e.jsx(W,{value:r.baseURL,onChange:a=>o(p=>({...p,baseURL:a.target.value})),placeholder:"https://…"})]}):e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(U,{children:n.fieldKind}),e.jsx(ie,{value:r.kind,options:Object.keys(ce).map(a=>({value:a,label:he(a,l)})),onChange:a=>o(p=>({...p,kind:a}))})]}),e.jsxs("div",{children:[e.jsx(U,{children:n.fieldBaseURL}),e.jsx(W,{value:r.baseURL,onChange:a=>o(p=>({...p,baseURL:a.target.value})),placeholder:"https://…"})]})]}),e.jsxs("div",{children:[e.jsx(U,{children:n.fieldCredentialSource}),e.jsx(ie,{value:r.credMode,options:[{value:"paste",label:n.credPaste},{value:"env",label:n.credEnv},{value:"command",label:n.credCommand}],onChange:a=>o(p=>({...p,credMode:a}))})]}),r.credMode==="paste"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldApiKey}),e.jsx(W,{type:"password",value:r.apiKey,onChange:a=>o(p=>({...p,apiKey:a.target.value})),placeholder:k?"••••••••":"sk-…"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:n.fieldApiKeyHint})]}),r.credMode==="env"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldEnvVar}),e.jsx(W,{value:r.envVar,onChange:a=>o(p=>({...p,envVar:a.target.value})),placeholder:"OPENROUTER_API_KEY"})]}),r.credMode==="command"&&e.jsxs("div",{children:[e.jsx(U,{children:n.fieldCommand}),e.jsx(W,{value:r.cmdLine,onChange:a=>o(p=>({...p,cmdLine:a.target.value})),placeholder:"op read op://Personal/OpenRouter/key"})]}),A&&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:A})]}),e.jsx("div",{className:"mt-6 border-t border-edge pt-4",children:e.jsx(ye,{primary:{label:v?n.saving:n.save,onClick:N,disabled:!P},secondary:{label:n.cancel,onClick:d}})})]})}function Ne(){const[t,n]=i.useState([]),[l,s]=i.useState([]),[m,c]=i.useState({}),d=i.useCallback(async()=>{const[r,o,v]=await Promise.all([de("/api/models/providers"),de("/api/models/profiles"),de("/api/models/agents")]);n(r.providers||[]),s(o.profiles||[]);const g={};for(const A of v.bindings||[])g[A.agent]=A.activeProfileId;c(g)},[]),b=i.useCallback(async(r,o)=>{await ne("POST",`/api/models/agents/${r}/active`,{profileId:o}),await d()},[d]);return i.useEffect(()=>{d()},[d]),{providers:t,profiles:l,bindings:m,reload:d,setActiveProfile:b}}function Re({provider:t,copy:n,boundAgents:l,onEdit:s,onRemove:m}){const c=je(t);return e.jsx("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:c,size:22})}),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-[15px] font-semibold tracking-tight text-fg",children:t.name}),e.jsx(Le,{v:t.validation,copy:n})]}),e.jsx("div",{className:"mt-1 truncate text-[11px] font-mono text-fg-5",title:t.baseURL,children:t.baseURL}),t.validation?.detail&&t.validation.state!=="ready"&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-4",children:t.validation.detail}),l.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:l.map(d=>{const b=J(d);return e.jsxs("span",{className:"inline-flex h-5 items-center gap-1 rounded-full border border-edge bg-panel-alt px-2 text-[11px] text-fg-3",children:[e.jsx(ae,{brand:d,size:11}),e.jsx("span",{children:b.shortLabel})]},d)})}):e.jsx("div",{className:"mt-2 text-[11px] text-fg-5",children:n.unbound})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3 self-start text-[12px]",children:[e.jsx("button",{type:"button",onClick:s,className:"text-fg-4 transition hover:text-fg-2",children:n.edit}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:m,className:"text-fg-4 transition hover:text-[var(--th-err)]",children:n.remove})]})]})})}function Te({snapshot:t}={}){const n=Ne(),l=t??n,{providers:s,profiles:m,bindings:c,reload:d}=l,b=Q(a=>a.locale),r=i.useMemo(()=>Me(b),[b]);Q(a=>a.toast);const[o,v]=i.useState(null),g=i.useMemo(()=>{const a=new Map,p=new Map(m.map(w=>[w.id,w]));for(const[w,M]of Object.entries(c)){if(!M)continue;const y=p.get(M);y&&(a.has(y.providerId)||a.set(y.providerId,[]),a.get(y.providerId).push(w))}return a},[c,m]),A=i.useCallback(async a=>{confirm(r.removeConfirm)&&(await ne("DELETE",`/api/models/providers/${a.id}`),await d())},[r,d]),I=i.useMemo(()=>{if(!o||o.kind!=="edit")return null;const{provider:a}=o;return{name:a.name,kind:a.kind,baseURL:a.baseURL,credMode:"paste",apiKey:"",envVar:re.find(p=>p.kind===a.kind)?.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}},[o]),k=i.useMemo(()=>!o||o.kind!=="add"?null:ue(o.template,b),[o,b]),S=o&&o.kind==="add"&&o.template.id!=="custom"?b==="zh-CN"?o.template.name.zh:o.template.name.en:null,N=i.useMemo(()=>{const a=new Map;for(const p of s){const w=je(p);a.has(w)||a.set(w,p)}return a},[s]),P=i.useCallback(a=>{if(a.id!=="custom"){const p=N.get(a.id);if(p){v({kind:"edit",provider:p});return}}v({kind:"add",template:a})},[N]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:r.templatesLabel}),e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:re.map(a=>e.jsx(Se,{template:a,locale:b,connected:a.id!=="custom"&&N.has(a.id),onPick:P},a.id))})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:r.configuredLabel}),s.length===0&&e.jsx(oe,{className:"border-dashed",children:e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:"custom",size:20})}),e.jsx("div",{className:"mt-3 text-[14px] font-semibold tracking-tight text-fg",children:r.emptyTitle}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-4",children:r.emptyHint})]})}),s.map(a=>e.jsx(Re,{provider:a,copy:r,locale:b,boundAgents:g.get(a.id)||[],onEdit:()=>v({kind:"edit",provider:a}),onRemove:()=>A(a)},a.id))]}),o&&e.jsx(Pe,{open:!0,copy:r,locale:b,initial:o.kind==="edit"?I:k,initialTemplateName:S,existingProvider:o.kind==="edit"?o.provider:void 0,onClose:()=>v(null),onSaved:d})]})}const le="__native__",_e=["claude","codex","gemini","hermes"];function xe(t){return t===void 0||!Number.isFinite(t)?null:t===0?"$0":t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:t<10?`$${t.toFixed(2)}`:`$${t.toFixed(1)}`}function Oe(t){return!t||!Number.isFinite(t)?null:t>=1e6?`${Math.round(t/1e5)/10}M ctx`:t>=1e3?`${Math.round(t/1e3)}K ctx`:`${t} ctx`}function De(t){if(!t||!Number.isFinite(t))return null;const n=t>32e9?t:t*1e3,l=new Date(n);return Number.isNaN(l.getTime())?null:l.toLocaleDateString(void 0,{year:"numeric",month:"short"})}function Ue(t){const n=t.id,l=[],s=t.name?.trim();s&&s.toLowerCase()!==t.id.toLowerCase()&&l.push(s);const m=xe(t.pricePromptUsd),c=xe(t.priceCompletionUsd);m&&c?l.push(`${m} / ${c} per 1M`):m&&l.push(`${m} prompt / 1M`);const d=Oe(t.contextLength);d&&l.push(d);const b=De(t.created);return b&&l.push(b),{label:n,description:l.length?l.join(" · "):void 0}}function ze(t){return t==="hermes"}function Ke(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}function He(t,n){const l=t.bindings[n];if(!l)return null;const s=t.profiles.find(c=>c.id===l);if(!s)return null;const m=t.providers.find(c=>c.id===s.providerId);return m?{profileId:s.id,providerId:m.id,providerName:m.name,providerBrand:Ke(m),modelId:s.modelId,effort:s.effort||null}:null}function $e(t){return t==="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 供应商;接入后可在上方任一智能体卡片的「供应商」下拉中选用。",rowProvider:"供应商",rowModel:"模型",rowEffort:"推理强度",providerNative:"官方(CLI 内置认证)",providerNativeFromAgent:"智能体自身配置",effortDefault:"默认",modelLoading:"正在拉取模型列表…",modelEmpty:"该供应商未返回模型列表,请使用自定义输入。",modelCustomToggle:"改为自定义输入",modelListToggle:"从列表选择",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"搜索模型",modelSearchEmpty:"没有匹配的模型",modelCurrentLabel:"当前",saveChanges:"保存",saving:"保存中…",cancel:"撤销",saved:"已保存",configError:"保存失败",externalNativeNote:n=>`Hermes 当前从 ${n||"~/.hermes/config.yaml"} 读取这些值;切换为某个 BYOK 供应商可由 pikiclaw 接管。`}:{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.",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…",cancel:"Reset",saved:"Saved",configError:"Save failed",externalNativeNote:n=>`Hermes reads these values from ${n||"~/.hermes/config.yaml"}; pick a BYOK provider to let pikiclaw take over.`}}function Fe(t,n){const l=t.filter(m=>m.installed);return(l.length?l:t).map(m=>({value:m.agent,label:`${J(m.agent).label} · ${m.installed?m.version||n.installed:n.notInstalled}`}))}function Be(t){return t.nativeSelectedModel?t.nativeSelectedModel:t.nativeConfig?.model?t.nativeConfig.model:t.models.length?t.models[0].id:""}function ve(t,n){t({defaultAgent:n.defaultAgent,agents:n.agents})}function Ve(t,n,l){if(l)return{providerId:l.providerId,modelId:l.modelId,effort:l.effort||"",modelMode:"list"};const s=n?.nativeConfig||null;return{providerId:le,modelId:s?.model||n?.selectedModel||"",effort:s?.effort||n?.selectedEffort||"",modelMode:"list"}}function Ye(t,n){return t.providerId===n.providerId&&t.modelId.trim()===n.modelId.trim()&&(t.effort||"")===(n.effort||"")}function Ge({agentId:t,agentStatus:n,boundInfo:l,copy:s,layer:m,toast:c,onSaved:d}){const b=ze(t),r=n.nativeConfig||null,o=i.useMemo(()=>Ve(t,n,l),[t,n,l]),[v,g]=i.useState(o),[A,I]=i.useState(!1),[k,S]=i.useState(null);i.useEffect(()=>{g(o),S(null)},[o]);const N=v.providerId===le,P=N&&b,[a,p]=i.useState([]),[w,M]=i.useState(!1),[y,z]=i.useState(null);i.useEffect(()=>{if(N){p([]),z(null),M(!1);return}let h=!1;return M(!0),z(null),fetch(`/api/models/providers/${v.providerId}/models`).then(u=>u.json()).then(u=>{h||(u.ok?u.modelInfos&&u.modelInfos.length?p(u.modelInfos):p((u.models||[]).map(E=>({id:E}))):(z(u.error||"Failed to load models"),p([])))}).catch(u=>{h||(z(u?.message||String(u)),p([]))}).finally(()=>{h||M(!1)}),()=>{h=!0}},[v.providerId,N]);const q=i.useMemo(()=>a.map(h=>h.id),[a]),j=i.useMemo(()=>n.models.map(h=>h.id),[n]),L=N?j:q;i.useEffect(()=>{if(!w){if(N){v.modelMode==="custom"&&g(h=>({...h,modelMode:"list"}));return}L.length===0&&v.modelMode==="list"&&g(h=>({...h,modelMode:"custom"}))}},[L,w,v.modelMode,N]);const C=i.useMemo(()=>{const h=b?`${s.providerNativeFromAgent}${r?.provider?` · ${r.provider}`:""}`:s.providerNative,u=[{value:le,label:h}];for(const E of m.providers)u.push({value:E.id,label:E.name});return u},[b,r,m.providers,s.providerNative,s.providerNativeFromAgent]),R=i.useMemo(()=>{const h=me[t]||me.claude;return[{value:"",label:s.effortDefault},...h.map(u=>({value:u,label:u}))]},[t,s.effortDefault]),K=i.useMemo(()=>{let h;return N?h=n.models.map(u=>{const E=u.alias?.toLowerCase().replace(/[\s_-]/g,""),V=u.id.toLowerCase().replace(/[\s_-]/g,""),_=u.alias&&E!==V;return{value:u.id,label:u.id,description:_?u.alias:void 0}}):h=a.map(u=>({value:u.id,...Ue(u)})),v.modelMode==="list"&&v.modelId&&!h.some(u=>u.value===v.modelId)&&h.unshift({value:v.modelId,label:v.modelId}),h},[N,n.models,a,v.modelMode,v.modelId]),O=!Ye(v,o),B=!A&&O&&(P||!!v.modelId.trim()),X=i.useCallback(async()=>{S(null),I(!0);try{const h=v.effort||null,u=v.modelId.trim();if(N){const E=m.bindings[t],V=E?m.profiles.find(_=>_.id===E):null;if(E&&await m.setActiveProfile(t,null),V&&await fetch(`/api/models/profiles/${V.id}`,{method:"DELETE"}),!b){const _={agent:t};if(u&&u!==(n.selectedModel||"")&&(_.model=u),h!==(n.selectedEffort||null)&&(_.effort=h),Object.keys(_).length>1){const Y=await Z.updateRuntimeAgent(_);if(!Y.ok)throw new Error(Y.error||"Failed to update agent")}}}else{const E=m.providers.find(D=>D.id===v.providerId);if(!E)throw new Error("Provider not found");const V=J(t),_=m.bindings[t],Y=_?m.profiles.find(D=>D.id===_):null,se={providerId:E.id,modelId:u,effort:h,name:`${V.label} · ${E.name}`};let G=Y?.id;if(Y){const D=await fetch(`/api/models/profiles/${Y.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}).then(ee=>ee.json());if(!D.ok)throw new Error(D.error||"Failed to update profile")}else{const D=await fetch("/api/models/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}).then(ee=>ee.json());if(!D.ok)throw new Error(D.error||"Failed to create profile");G=D.profile?.id}G&&await m.setActiveProfile(t,G)}await Promise.resolve(d()),c(s.saved)}catch(h){const u=h?.message||String(h);S(u),c(`${s.configError}: ${u}`,!1)}finally{I(!1)}},[t,n,s,v,b,N,m,d,c]);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(U,{className:"!mb-1 text-[11px]",children:s.rowProvider}),e.jsx(ie,{value:v.providerId,options:C,onChange:h=>g(u=>{if(h===u.providerId)return u;const E={...u,providerId:h,modelId:"",modelMode:"list"};return h===le&&(E.modelId=Be(n),E.effort=n.nativeSelectedEffort||n.nativeConfig?.effort||""),E})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx(U,{className:"!mb-0 text-[11px]",children:s.rowModel}),!P&&!N&&e.jsx("button",{type:"button",onClick:()=>g(h=>({...h,modelMode:h.modelMode==="list"?"custom":"list"})),className:"text-[10px] text-fg-5 underline-offset-2 transition hover:text-fg-3 hover:underline",children:v.modelMode==="list"?s.modelCustomToggle:s.modelListToggle})]}),P?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:r?.model||s.noModel})}):v.modelMode==="list"?w&&!N?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(te,{className:"h-3.5 w-3.5"}),s.modelLoading]}):e.jsx(Ie,{value:v.modelId,options:K,onChange:h=>g(u=>({...u,modelId:h})),placeholder:L.length?"—":s.modelEmpty,searchPlaceholder:s.modelSearchPlaceholder,noMatchesText:s.modelSearchEmpty,currentLabel:s.modelCurrentLabel}):e.jsx(W,{value:v.modelId,onChange:h=>g(u=>({...u,modelId:h.target.value})),placeholder:s.modelCustomPlaceholder})]}),e.jsxs("div",{children:[e.jsx(U,{className:"!mb-1 text-[11px]",children:s.rowEffort}),P?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:r?.effort||s.effortDefault})}):e.jsx(ie,{value:v.effort,options:R,onChange:h=>g(u=>({...u,effort:h}))})]})]}),P&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:s.externalNativeNote(r?.configPath||"")}),(k||y)&&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||y}),O&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>g(o),disabled:A,children:s.cancel}),e.jsx(F,{variant:"primary",size:"sm",disabled:!B,onClick:()=>{X()},children:A?s.saving:s.saveChanges})]})]})}function qe({agent:t,copy:n,t:l,installing:s,onInstall:m,updatingAgent:c,checkingAgent:d,onUpdate:b,onCheckUpdate:r,loading:o=!1,layer:v,boundInfo:g,toast:A,onConfigSaved:I}){const k=J(t.agent),S=t.version||n.noVersion,N=k.advantageKey?l(k.advantageKey):"";return e.jsxs("div",{className:"glass rounded-md border border-edge px-4 py-3 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(ae,{brand:t.agent,size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[15px] font-semibold text-fg",children:k.label}),t.isDefault&&e.jsx($,{variant:"accent",children:n.defaultBadge}),o?e.jsxs($,{variant:"muted",children:[e.jsx(te,{className:"h-3 w-3"})," ",l("status.loading")]}):t.installed?e.jsx($,{variant:"ok",children:n.installed}):e.jsx($,{variant:"warn",children:n.notInstalled}),t.installed&&t.updateAvailable&&e.jsx($,{variant:"warn",children:n.updateAvailable})]}),e.jsxs("div",{className:"mt-1 text-[12px] leading-relaxed text-fg-5",children:[n.versionLabel,": ",S,t.latestVersion&&t.updateAvailable&&e.jsxs("span",{className:"ml-1.5 text-amber-400",children:["→ ",t.latestVersion]}),t.latestVersion&&!t.updateAvailable&&t.installed&&e.jsx("span",{className:"ml-1.5 text-emerald-400",children:"✓"})]})]})]}),e.jsxs("div",{className:H("flex shrink-0 flex-col items-end gap-1.5"),children:[o&&e.jsxs("div",{className:"inline-flex h-7 items-center gap-2 rounded-md border border-edge bg-transparent px-2.5 text-[11px] text-fg-5",children:[e.jsx(te,{className:"h-3 w-3"}),l("status.loading")]}),!o&&!t.installed&&e.jsx(F,{variant:"primary",size:"sm",disabled:s,onClick:()=>m(t),children:s?n.installing:n.install}),!o&&t.installed&&t.updateAvailable&&e.jsx(F,{variant:"outline",size:"sm",disabled:c,onClick:()=>b(t),children:c?n.updating:n.update}),!o&&t.installed&&!t.updateAvailable&&e.jsx(F,{variant:"ghost",size:"sm",disabled:d,onClick:()=>r(t),className:"gap-1.5 text-[11px]",children:d?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-3 w-3"})," ",n.checking]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",n.checkUpdate]})})]})]}),N&&e.jsx("div",{className:"mt-2 text-[12px] leading-relaxed text-fg-4",children:N}),!o&&!t.installed&&e.jsx("div",{className:"mt-3 rounded-md border border-dashed border-edge bg-panel-alt px-3 py-2.5 text-[12px] leading-relaxed text-fg-4",children:n.notInstalledHint}),!o&&t.installed&&e.jsx("div",{className:"mt-3 border-t border-edge pt-3",children:e.jsx(Ge,{agentId:t.agent,agentStatus:t,boundInfo:g,copy:n,layer:v,toast:A,onSaved:I})}),!o&&t.installed&&t.updateAvailable&&t.updateStatus==="skipped"&&t.updateDetail&&e.jsxs("div",{className:"mt-2 text-[11px] leading-relaxed",style:{color:"var(--th-badge-warn-text)"},children:[n.updateSkipped,": ",t.updateDetail]}),!o&&t.installed&&t.updateStatus==="failed"&&t.updateDetail&&e.jsxs("div",{className:"mt-2 text-[11px] leading-relaxed",style:{color:"var(--th-badge-err-text)"},children:[n.updateFailed,": ",t.updateDetail]})]})}function We({label:t,value:n,hint:l,loading:s=!1}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-panel-alt px-3.5 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:t}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[13px] font-semibold text-fg-2",children:[s&&e.jsx(te,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n})]}),l&&e.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-fg-5",children:l})]})}function at(){const t=Q(f=>f.locale),n=Q(f=>f.toast),l=Q(f=>f.agentStatus),s=Q(f=>f.setAgentStatus),m=Q(f=>f.refreshAgentStatus),c=i.useMemo(()=>Ae(t),[t]),d=i.useMemo(()=>$e(t),[t]),b=Ne(),[r,o]=i.useState(l?{defaultAgent:l.defaultAgent,agents:l.agents}:null),[v,g]=i.useState(!l),[A,I]=i.useState(null),[k,S]=i.useState(!1),[N,P]=i.useState(null),[a,p]=i.useState(!1),[w,M]=i.useState("codex"),[y,z]=i.useState(null),[q,j]=i.useState(null),L=i.useRef(!!l);i.useEffect(()=>{l&&(ve(o,l),L.current||(L.current=!0,g(!1)))},[l]);const C=i.useCallback(f=>{ve(o,f),s(f)},[s]),R=i.useCallback(async()=>{L.current||g(!0);try{const f=await Z.getAgentStatus();return C(f),I(null),L.current=!0,f}catch(f){const x=f instanceof Error?f.message:d.loadFailed;return I(x),L.current||n(x,!1),null}finally{g(!1)}},[C,d.loadFailed,n]);i.useEffect(()=>{l?m():R()},[]);const K=i.useMemo(()=>{const f=r?.agents||[],x=new Map(f.map(T=>[T.agent,T]));return _e.map(T=>{const fe=x.get(T);if(fe)return fe;const we=J(T);return{agent:T,label:we.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:r?.defaultAgent===T,models:[],usage:null}})},[r]),O=r?.defaultAgent||"codex",B=K.find(f=>f.agent===O)||null,h=K.filter(f=>f.installed).length>0,u=Fe(K,d),E=i.useCallback(async f=>{S(!0);try{const x=await Z.updateRuntimeAgent(f);if(!x.ok)throw new Error(x.error||c("config.applyFailed"));return C(x),x}catch(x){const T=x instanceof Error?x.message:c("config.applyFailed");return n(T,!1),R(),null}finally{S(!1)}},[C,R,c,n]);i.useEffect(()=>{a&&M(O)},[O,a]);const V=i.useCallback(async()=>{if(w===O){p(!1);return}await E({defaultAgent:w})&&(n(d.defaultsSaved),p(!1))},[d.defaultsSaved,O,w,n,E]),_=i.useCallback(async f=>{if(!N){P(f.agent);try{const x=await Z.installAgent(f.agent);if(!x.ok)throw new Error(x.error||c("config.agentInstallFailed"));C(x),n(c("config.agentInstalled"))}catch(x){const T=x instanceof Error?x.message:c("config.agentInstallFailed");n(T,!1),R()}finally{P(x=>x===f.agent?null:x)}}},[C,N,R,c,n]),Y=i.useCallback(async f=>{if(!y){z(f.agent);try{const x=await Z.updateAgent(f.agent);if(!x.ok)throw new Error(x.error||c("config.agentInstallFailed"));C(x),n(d.upToDate)}catch(x){const T=x instanceof Error?x.message:d.updateFailed;n(T,!1),R()}finally{z(x=>x===f.agent?null:x)}}},[C,d.updateFailed,d.upToDate,R,c,n,y]),se=i.useCallback(async f=>{if(!q){j(f.agent);try{const x=await Z.checkAgentUpdate(f.agent);if(!x.ok)throw new Error(x.error||d.loadFailed);C(x)}catch(x){const T=x instanceof Error?x.message:d.loadFailed;n(T,!1),R()}finally{j(x=>x===f.agent?null:x)}}},[C,q,d.loadFailed,R,n]),G=v&&!r,D=G?c("status.loading"):B?J(B.agent).label:d.notInstalled,ee=G?c("status.loading"):B?.installed?d.installed:d.notInstalled,ke=i.useCallback(async()=>{await b.reload(),await R()},[b,R]);return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsx("section",{className:"space-y-3",children:e.jsxs(oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.defaultsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.defaultsHint})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{variant:"secondary",onClick:()=>p(!0),disabled:k||!h,children:d.editDefaults})})]}),e.jsx(We,{label:d.defaultAgent,value:D,hint:ee,loading:G})]})}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),e.jsx("div",{className:"space-y-3",children:K.map(f=>e.jsx(qe,{agent:f,copy:d,t:c,installing:N===f.agent,loading:G,onInstall:_,updatingAgent:y===f.agent,checkingAgent:q===f.agent,onUpdate:Y,onCheckUpdate:se,layer:b,boundInfo:He(b,f.agent),toast:n,onConfigSaved:ke},f.agent))})]}),A&&e.jsx(oe,{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:A}),e.jsx(F,{variant:"outline",size:"sm",onClick:()=>{R()},children:c("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(Te,{snapshot:b})]}),e.jsxs(ge,{open:a,onClose:()=>p(!1),children:[e.jsx(be,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>p(!1)}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(U,{children:d.defaultAgent}),e.jsx(ie,{value:w,options:u,onChange:f=>M(f),disabled:k||!h,placeholder:d.notInstalled})]})}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(F,{variant:"ghost",onClick:()=>p(!1),children:c("modal.cancel")}),e.jsx(F,{variant:"primary",disabled:k||w===O,onClick:()=>{V()},children:c(k?"config.validating":"modal.save")})]})]})]})}export{at as AgentTab,at as default};
@@ -0,0 +1 @@
1
+ import{j as s}from"./react-vendor-DTcmqLiz.js";import{c as g}from"./index-CypsxtrZ.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",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='%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",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='%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",v="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",m="/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,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAg+SURBVHgB3VtrbFRFFD673XbbuoBY1EJCUy2gP2hK9YcJJTwSCaYEef0AKxGqhGCaqJAISgImYoz1BxETkOADIabKD+WVkvhIpE1LjIm0DcQUgXStQZCIgta+drvrfHf20nt3Z2bn3n2Vfsnkbne7j+87Z86cOWeuhzQQjUYXsstyNnAtZ+NeGpu4xUZnbJzweDxnKBUw4hvY6InevehhY4OKo0dCvJxdjrExh8YHgmwsYh4RjH/BG/8EI7+eXTpo/JAHytnoYNxWxL9g84DYPxyj8Y0NzBMOm3/cESDm9rB81gPc7b5obPDHkwIeNojKSr2UASBQVpvTwSpAD3FXyShAsK1zhNq7Ruj8lQidvxwxnpOhcobXEKKmKo+W1uSlS5ROJkA1HhgCxCLlIcoQQLDp6zCdbg8b5FMBBNm8uoDqlvgoRdQzET41BciI9UH2wFcham4LU7oBT9i+PiUhgkyAhzxRnuR8T2kEiDceGU7Z2jqAAG83+I244QKLIMB77MHLlAb0Xo9Qw7tDWSFuBbzh1J5CN/FhL95RRWnAgS9DNH/TQNbJAxB+2dZB4+oQC+ABf1MKS59bq8+bk0ezK7xUWZHHHntjS9+oGyNw9l6PGqvE6bNhrTiCANl6sJgc4BYEiJJLNLOo3tA4pFzGrADp2rk+qnvK53jOQmisJJ+zobI0AuNrbOjCtQCNh4fpHTZ08AwLVHVL8g0BUgXIr9s1aHiGDF1NxdrxwJUAuuRBeN82f0YyOoggmxZLa3z02e5C0oFjAXTIgzCIp8PiMmDaIejKpkPw5D1a08yRADrkN6/ON+ag9cuv/Un0Sy/R9ZtEv7PHfQNs9BP9229/79QpRIEiomnsOnM6e8zi2awy+Xch8C7bOiB8DbnBi+y3JIO2ADrkzS8F4Va2rTp3kY94ok4woZiLsYBl7tWPJAoCAUQrELzv1J4iSgYtARDt1+0clL4Oaze9VUQ/93jvkM4U4CVL52Ke88cfsPxjx74hEv0mTINkSCoA5hjmmmypy/d5afnCQgpe86ZkaTeACJUPR6j+TfEX66wGSQWoquuXBhqQnz610LjmEhd7+oTPIylCcqSC8lWkt6qkY9qDuScP5OeLf4NOgibdS4K4Kug9UOKnwgJ98pivs1gwKy3hUT4gyFixMmCVwGphrBy/UcYhFQBRX6bgpICPJk9ULzGI3rUsWD3+KI/eExyl6ByIKZeYCC3nmDt3clFECIUikt/pMg+A9TH3RUg27x9jZDcu59d0A6tLczsfJoaGIxS8Kv6tOsmQ0AMaFa4/ZXKBkDwi8sanuatnChDVEJh9z0cnuRChsNz6Oh4gFKCtS/yhhX4vTQzY3wLCO5/PjMVlML8TQqzaJt4PmNHfnDYywySYskmx3bz/Pr/t7zWLiY68kV3yVoBU/6D4t86v5oaCALs/kX9GggCnJTssuH1x4ejmBvN8y1p3wS1dUBmrJrYRQxBF7PjiW/FnJAjQ1iWu7EyeNBr1QR7ul2vIYhWyv7mVnFpLB3/u45PiPYlNAFWTIlDMFTWDXa6hsv7iJ3hFCO5v7ktA3rp6mLAJ0PuHPOXFwJwbC+QB1Ur10hpOK35T1tqR+L8JHiCC38//LdPLnC5AXmZ9lN8wBWB9LJVWQJD4ZMruAZIPLfDx9TRX0d6KZCm6WRBF0BNljvFeoZXMe70eg3yurW/W/2VARdjc/vZJtuZKD1Ah1+QRnFEIlXkpiFvL4bJS2rWb9r+1BMBmY2oJ5RToP6hK4WiNWRHQzE9sAlTOEFdxB9mGI165bAGWb2gcNMpyMlhd34Rs5xgPW2JfVirePGDH1f0r8gNXHVjX0GmC1LIegKgTJKslxHuyTbZ5VfI6/o8XQlmt+YE0Ap6KPKy+f7tf+NoliQAoylhhEwDbR1kz46/bIdaXc91GdATeae5XluPMlrhoy4uMTzYFZsYFx4QgCJcSIRKJ0vtHh7Tnlhtwqw/Q64IytxXJzgPEJ0AmREt5wifgxIWskHD1Rphe2aPXEHUCBDrU9mH1ZG32pORPyK2PfUw8Ej4F5Lc/J28vf/PDsHI9dgKQBXGU39DgSAZMz9aDRUryMusbDRWBANK+gKzlZAJCwVvQC3TS/YVwze0jjk+MJev7q8gDqCA5EsDJsRNYprLCS7Mr8hKWUpzyuP1flC5cGWGEI449J1mnGSsTyB/9Tv4ZIA4BRFB2hsygpHsCJN0QdZqtONfNyl2H1EkPXH//q/JUXqs36PIAkmvA2ohDMqtf6uXu3tKh/hyU61CzVO1jtLrDIL9mxzB1B9N/4NEKFXGjSRIjrtN9Bvn923hrXQXt8wFws2d3henC5WFpLd4NzORr86rEM0RmSQsD1RzdTDSZ21vh6Jgc9tgfMgscPBamf/pC1D/g7kwg6gvoMcws89GmFTzvAFkQxOkR8zSJm9QbyQ4Cnub23Tgm5/jmCKSacMWrN6KsLj9CA2xgx4hscSQy2qszu7b5rKKE4S/IY8NeXk8X4PIvsGr12icdve2M66OysFjzWb4E5Rpo0KBe6aJHsTflw9Jm8VFUcMwkzO7z2sUpVasWpfW4vNm5zeQZIcxxHJiqrUm5K8WPy+NRum+YQPDqYCL81M2vqRx0gHXNrvD86rS24kZvmADcBEMnQIECU8SM9qISG6o1IGieDywtyVjv0bA+HoyJm6ayDNtNU3e2cbEnttD4R731BkrbPhZzgl1WEldpvAGcQP649UnVrbNYGstpfAA3U6/UunUWwD/GgkQ98ftu71YEiVu9WkQe0Cr0x5Il3FaL+4uwUozl2+eDbLSwcVzn9vn/AWPIqLtnLYy9AAAAAElFTkSuQmCC",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={claude:a,codex:h,gemini:r,telegram:A,feishu:n,weixin:w,slack:x,discord:d,dingtalk:f,wecom:v,playwright:m,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},Q={custom:{letter:"+",color:"#94a3b8",bg:"rgba(148,163,184,0.12)"}};function S({brand:t,size:e=18,className:i}){const l=I[t];if(l)return s.jsx("img",{src:l,alt:"","aria-hidden":"true",draggable:!1,className:g("shrink-0 object-contain select-none",i),style:{width:e,height:e}});const c=Q[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",i),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{S 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-COeEMXhW.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};
1
+ import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-CypsxtrZ.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 d,j as e}from"./react-vendor-DTcmqLiz.js";import{u as P,T as pe,m as ge,c as O,a as L,o as V,S as $,B as S,k as te}from"./index-CypsxtrZ.js";import{B as me}from"./BrandIcon-DHaeSgX8.js";import{M as G,a as W,I as B}from"./Modal-DxYHCIeK.js";import{a as fe,b as je,d as ve}from"./shared-JcpxfGic.js";import"./router-emLofBBH.js";function a(t,s,n){return t==="zh-CN"?s:n}function ae(t,s){return s.type==="mcp-oauth"?a(t,"OAuth","OAuth"):s.type==="credentials"?a(t,"API Key","API Key"):a(t,"无需配置","No auth")}const be={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"}},ye={hex:"#6b7280"};function q(t,s){const n=(t||"").toLowerCase(),r=be[n]||ye,l=r.letter||(s||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,2).toUpperCase()||"?";return{hex:r.hex,letter:l}}function A(t,s){const n=t.replace("#",""),r=n.length===3?n.split("").map(x=>x+x).join(""):n.padEnd(6,"0").slice(0,6),l=parseInt(r.slice(0,2),16),c=parseInt(r.slice(2,4),16),h=parseInt(r.slice(4,6),16);return`rgba(${l}, ${c}, ${h}, ${s})`}function Y(t,s,n=[]){const[r,l]=d.useState(()=>{try{const g=localStorage.getItem(t);return g?JSON.parse(g):null}catch{return null}}),[c,h]=d.useState(!1),x=d.useRef(!0);d.useEffect(()=>()=>{x.current=!1},[]);const p=d.useCallback(async()=>{h(!0);try{const g=await s();if(!x.current)return;l(g);try{localStorage.setItem(t,JSON.stringify(g))}catch{}}finally{x.current&&h(!1)}},[t,...n]);return d.useEffect(()=>{p()},[p]),{data:r,loading:c,refresh:p}}const F=()=>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"})]}),re=({size:t=14})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),U=({size:t=12})=>e.jsxs("svg",{width:t,height:t,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"})]}),ke=({size:t=12})=>e.jsxs("svg",{width:t,height:t,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:t=12})=>e.jsxs("svg",{width:t,height:t,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:t=12})=>e.jsxs("svg",{width:t,height:t,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"})]}),le=new Set(["claude","codex","gemini","telegram","feishu","weixin","playwright","vscode","cursor","windsurf","finder"]),we={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"},Ce=new Set(["stripe"]);function Se(t,s){if(s)return s;if(!t||le.has(t))return;const n=we[t];if(n)return`https://api.iconify.design/${n}.svg`}function H({iconSlug:t,iconUrl:s,name:n,size:r=32,className:l}){const{hex:c,letter:h}=q(t,n),[x,p]=d.useState(!1),g=Se(t,s),b=t&&le.has(t),o=b||!!g&&!x,f=!!t&&Ce.has(t),m=Math.round(r*(f?.92:.76));return o?e.jsxs("div",{className:O("relative flex shrink-0 items-center justify-center overflow-hidden rounded-xl bg-white",l),style:{width:r,height:r,boxShadow:`0 0 0 1px ${A(c,.18)}, 0 4px 12px ${A(c,.14)}`},children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0",style:{background:`linear-gradient(135deg, ${A(c,.06)} 0%, transparent 70%)`}}),b?e.jsx(me,{brand:t,size:m}):e.jsx("img",{src:g,alt:"",width:m,height:m,loading:"lazy",decoding:"async",onError:()=>p(!0),className:"relative"})]}):e.jsxs("div",{className:O("relative flex shrink-0 items-center justify-center overflow-hidden rounded-xl font-semibold text-white",l),style:{width:r,height:r,background:`linear-gradient(135deg, ${A(c,1)} 0%, ${A(c,.82)} 100%)`,boxShadow:`0 1px 0 rgba(255,255,255,0.08) inset, 0 6px 14px ${A(c,.28)}`,fontSize:Math.max(10,Math.round(r*.36)),letterSpacing:h.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:h})]})}function Ie({state:t,locale:s}){return t==="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(U,{size:10}),a(s,"已连接","Connected")]}):t==="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(ke,{size:10}),a(s,"已停用","Paused")]}):t==="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(s,"待授权","Needs auth")]}):t==="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(s,"异常","Unhealthy")]}):null}function Le({open:t,onClose:s,locale:n,item:r,initial:l,onSubmit:c}){const[h,x]=d.useState({}),[p,g]=d.useState(!1);if(d.useEffect(()=>{if(t&&r&&r.auth.type==="credentials"){const o={};for(const f of r.auth.fields)o[f.key]=l?.[f.key]||"";x(o)}},[t,r,l]),!r||r.auth.type!=="credentials")return null;const b=r.auth.fields.some(o=>o.required&&!(h[o.key]||"").trim()),N=async()=>{g(!0);try{await c(h)}finally{g(!1)}};return e.jsxs(G,{open:t,onClose:s,children:[e.jsx(W,{title:a(n,`配置 ${r.name}`,`Configure ${r.name}`),description:n==="zh-CN"?r.descriptionZh:r.description,onClose:s}),e.jsxs("div",{className:"space-y-3",children:[r.auth.fields.map(o=>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"?o.labelZh:o.label,o.required&&e.jsx("span",{className:"ml-1 text-err",children:"*"})]}),o.helpUrl&&e.jsxs("a",{href:o.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(F,{})]})]}),e.jsx(B,{value:h[o.key]||"",onChange:f=>x({...h,[o.key]:f.target.value}),type:o.secret?"password":"text",placeholder:o.placeholder,className:"font-mono text-[12px]"})]},o.key)),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-edge pt-3",children:[e.jsx(S,{variant:"ghost",onClick:s,children:a(n,"取消","Cancel")}),e.jsx(S,{variant:"primary",disabled:p||b,onClick:N,children:p?e.jsx($,{}):a(n,"保存并启用","Save & Enable")})]})]})]})}function ze({open:t,onClose:s,locale:n,scope:r,workdir:l,onAdded:c}){const h=P(j=>j.toast),[x,p]=d.useState(""),[g,b]=d.useState("stdio"),[N,o]=d.useState("npx"),[f,m]=d.useState(""),[C,z]=d.useState(""),[M,u]=d.useState([]),[w,_]=d.useState(!1);d.useEffect(()=>{t&&(p(""),b("stdio"),o("npx"),m(""),z(""),u([]))},[t]);const R=async()=>{if(x.trim()){_(!0);try{const j={};for(const{k:y,v:I}of M)y.trim()&&(j[y.trim()]=I);const v=g==="http"?{type:"http",url:C.trim(),enabled:!0,...Object.keys(j).length?{headers:j}:{}}:{type:"stdio",command:N.trim(),args:f.trim()?f.trim().split(/\s+/):[],enabled:!0,...Object.keys(j).length?{env:j}:{}};await L.addCustomMcp(x.trim(),v,r,l),h(a(n,`${x} 已添加`,`${x} added`),!0),c(),s()}catch(j){h(j?.message||"Failed",!1)}finally{_(!1)}}};return e.jsxs(G,{open:t,onClose:s,wide:!0,children:[e.jsx(W,{title:a(n,"添加自定义 MCP 服务","Add Custom MCP Server"),description:a(n,"不在推荐列表中的自定义服务。","For servers not in the recommended catalog."),onClose:s}),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(B,{value:x,onChange:j=>p(j.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(j=>e.jsx("button",{onClick:()=>b(j),className:O("flex-1 rounded-md border px-3 py-1.5 text-[12px] font-medium transition-colors",g===j?"border-primary/40 bg-primary/10 text-primary":"border-edge bg-inset/50 text-fg-4 hover:bg-inset"),children:j},j))})]})]}),g==="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(B,{value:N,onChange:j=>o(j.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(B,{value:f,onChange:j=>m(j.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(B,{value:C,onChange:j=>z(j.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:g==="http"?a(n,"Headers","Headers"):a(n,"环境变量","Env")}),e.jsxs("button",{className:"text-[11px] font-medium text-primary hover:text-primary/80",onClick:()=>u([...M,{k:"",v:""}]),children:["+ ",a(n,"添加","Add")]})]}),M.length>0&&e.jsx("div",{className:"space-y-1 rounded-md border border-edge bg-inset/40 p-2",children:M.map((j,v)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{className:"w-2/5 !h-7 !text-[12px] font-mono",value:j.k,onChange:y=>{const I=[...M];I[v]={...I[v],k:y.target.value},u(I)},placeholder:"KEY"}),e.jsx(B,{className:"flex-1 !h-7 !text-[12px] font-mono",value:j.v,onChange:y=>{const I=[...M];I[v]={...I[v],v:y.target.value},u(I)},type:/token|secret|key|bearer/i.test(j.k)?"password":"text",placeholder:"value"}),e.jsx("button",{className:"shrink-0 rounded p-1 text-fg-5 hover:text-err",onClick:()=>u(M.filter((y,I)=>I!==v)),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"})]})})]},v))})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-edge pt-3",children:[e.jsx(S,{variant:"ghost",onClick:s,children:a(n,"取消","Cancel")}),e.jsx(S,{variant:"primary",disabled:!x.trim()||w,onClick:R,children:w?e.jsx($,{}):a(n,"添加","Add")})]})]})]})}function Me({open:t,onClose:s,locale:n,scope:r,workdir:l,onInstalled:c}){const h=P(m=>m.toast),[x,p]=d.useState(""),[g,b]=d.useState(""),[N,o]=d.useState(!1);d.useEffect(()=>{t&&(p(""),b(""))},[t]);const f=async()=>{if(x.trim()){o(!0);try{const m=await L.installSkill(x.trim(),r==="global",g.trim()||void 0,l);m.ok?(h(a(n,"技能安装成功","Skill installed"),!0),c(),s()):h(m.error||"Failed",!1)}catch(m){h(m?.message||"Failed",!1)}finally{o(!1)}}};return e.jsxs(G,{open:t,onClose:s,children:[e.jsx(W,{title:a(n,"安装自定义技能","Install Custom Skill"),description:a(n,"通过 npx skills add 从 GitHub 仓库安装。","Installs via npx skills add from a GitHub repo."),onClose:s}),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(B,{value:x,onChange:m=>p(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(B,{value:g,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(S,{variant:"ghost",onClick:s,children:a(n,"取消","Cancel")}),e.jsx(S,{variant:"primary",disabled:!x.trim()||N,onClick:f,children:N?e.jsx($,{}):a(n,"安装","Install")})]})]})]})}function _e(t,s){return new Promise(n=>{const r=window.open(t,"pikiclaw_mcp_oauth","width=640,height=780,noopener=no");if(!r){n(!1);return}let l=!1;const c=p=>{l||(l=!0,window.removeEventListener("message",h),clearInterval(x),n(p))},h=p=>{const g=p.data;if(!(!g||g.type!=="mcp-oauth")&&!(s&&g.state!==s)){c(!!g.ok);try{r.close()}catch{}}};window.addEventListener("message",h);const x=setInterval(()=>{r.closed&&c(!1)},500)})}function se({item:t,locale:s,busy:n,index:r,onPrimary:l,onRemove:c,onReauth:h,onReconfigure:x}){const{hex:p}=q(t.iconSlug,t.name),g=(()=>{switch(t.state){case"ready":return a(s,"停用","Pause");case"unhealthy":return a(s,"停用","Pause");case"disabled":return a(s,"启用","Enable");case"needs_auth":return t.auth.type==="mcp-oauth"?a(s,"授权","Authorize"):a(s,"配置","Configure");default:return a(s,"启用","Enable")}})(),b={background:`linear-gradient(140deg, ${A(p,.05)} 0%, ${A(p,.01)} 60%, transparent 100%)`,borderColor:A(p,.18),animationDelay:`${Math.min(r,8)*40}ms`};return e.jsxs("div",{className:O("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:A(p,.35)}}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx(H,{iconSlug:t.iconSlug,iconUrl:t.iconUrl,name:t.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:t.name}),t.homepage&&e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-fg-3 transition-colors",children:e.jsx(F,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[12px] leading-snug text-fg-4",children:s==="zh-CN"?t.descriptionZh:t.description})]}),e.jsx(Ie,{state:t.state,locale:s})]}),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:p,opacity:.8}}),ae(s,t.auth)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t.installed&&t.state!=="needs_auth"&&h&&e.jsx(S,{variant:"ghost",size:"sm",onClick:h,disabled:n,children:a(s,"重新授权","Re-auth")}),t.installed&&t.state!=="needs_auth"&&x&&e.jsx(S,{variant:"ghost",size:"sm",onClick:x,disabled:n,children:a(s,"编辑","Edit")}),e.jsx(S,{variant:t.state==="disabled"||t.state==="needs_auth"?"primary":"ghost",size:"sm",onClick:l,disabled:n,children:n?e.jsx($,{}):g}),t.installed&&c&&e.jsx(S,{variant:"ghost",size:"sm",onClick:c,disabled:n,className:"hover:!text-err",children:a(s,"移除","Remove")})]})]})]})}function ne({item:t,locale:s,busy:n,index:r,onPrimary:l}){const c=t.auth.type==="none"?a(s,"一键启用","One-click enable"):a(s,"授权并启用","Authorize & enable");return e.jsxs("div",{className:O("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(r,12)*30}ms`},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{iconSlug:t.iconSlug,iconUrl:t.iconUrl,name:t.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:t.name}),t.homepage&&e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-fg-3 transition-colors",children:e.jsx(F,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[12px] leading-snug text-fg-4",children:s==="zh-CN"?t.descriptionZh:t.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:ae(s,t.auth)}),e.jsx(S,{variant:"outline",size:"sm",onClick:l,disabled:n,className:"group-hover:border-edge-h",children:n?e.jsx($,{}):c})]})]})}function Ae({item:t,locale:s,busy:n,index:r,onInstall:l,onRemove:c}){return e.jsxs("div",{className:O("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(r,12)*30}ms`},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-white",style:{background:"linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%)",boxShadow:"0 6px 16px rgba(245, 158, 11, 0.25)"},children:e.jsx(re,{size:14})}),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:t.name}),t.homepage&&e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-fg-3 transition-colors",children:e.jsx(F,{})})]}),e.jsx("div",{className:"mt-0.5 line-clamp-2 text-[12px] leading-snug text-fg-4",children:s==="zh-CN"?t.descriptionZh:t.description})]}),t.installed&&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(U,{size:10}),a(s,"已安装","Installed")]})]}),e.jsxs("div",{className:"mt-auto flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-0.5",children:[e.jsx("span",{className:"truncate text-[11px] text-fg-5",children:t.source}),(t.stars!==void 0||t.pushedAt)&&e.jsxs("span",{className:"flex items-center gap-2 text-[10.5px] text-fg-5",children:[t.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}),$e(t.stars)]}),t.pushedAt&&e.jsxs("span",{children:["· ",Re(t.pushedAt,s)]})]})]}),t.installed?e.jsx(S,{variant:"ghost",size:"sm",onClick:c,disabled:n,className:"hover:!text-err",children:n?e.jsx($,{}):a(s,"移除","Remove")}):e.jsx(S,{variant:"outline",size:"sm",onClick:l,disabled:n,children:n?e.jsx($,{}):a(s,"安装","Install")})]})]})}const Ee=({size:t=12})=>e.jsx("svg",{width:t,height:t,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 $e(t){return t>=1e4?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Re(t,s){const n=Date.parse(t);if(!Number.isFinite(n))return"";const r=Date.now()-n,l=1440*60*1e3,c=Math.max(1,Math.floor(r/l));if(c<30)return s==="zh-CN"?`${c} 天前`:`${c}d ago`;const h=Math.floor(c/30);if(h<12)return s==="zh-CN"?`${h} 个月前`:`${h}mo ago`;const x=Math.floor(h/12);return s==="zh-CN"?`${x} 年前`:`${x}y ago`}const K={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 Te(t){const s=new Map;for(const n of t){const r=s.get(n.category)||[];r.push(n),s.set(n.category,r)}return[...s.entries()].sort((n,r)=>(K[n[0]]?.order??99)-(K[r[0]]?.order??99)).map(([n,r])=>({key:n,items:r}))}function oe({scope:t,workdir:s,locale:n,onOpenBrowserSetup:r}){const l=P(i=>i.toast),c=`pikiclaw.mcp.catalog.${t}.${s||""}`,{data:h,loading:x,refresh:p}=Y(c,async()=>(await L.getMcpCatalog(s,t)).items||[],[s,t]),[g,b]=d.useState(""),[N,o]=d.useState(null),[f,m]=d.useState(!1),[C,z]=d.useState(null),M=h||[],u=d.useMemo(()=>M.filter(i=>!i.installed||i.scope===t||!i.scope),[M,t]),w=d.useMemo(()=>{if(!g.trim())return u;const i=g.trim().toLowerCase();return u.filter(k=>k.name.toLowerCase().includes(i)||k.description.toLowerCase().includes(i)||k.descriptionZh.includes(i)||k.id.toLowerCase().includes(i))},[u,g]),_=d.useMemo(()=>w.filter(i=>i.isBuiltin),[w]),R=d.useMemo(()=>w.filter(i=>!i.isBuiltin&&(i.state==="ready"||i.state==="unhealthy")),[w]),j=d.useMemo(()=>Te(w.filter(i=>!i.isBuiltin&&i.state!=="ready"&&i.state!=="unhealthy")),[w]),v=d.useCallback(async(i,k)=>{if(i.isRecommended){z(i.id);try{const T=await L.installMcp(i.id,t,k,s,!0);if(!T.ok)throw new Error(T.error||"install failed");return await p(),T.enabled??!1}catch(T){return l(T?.message||"Failed",!1),!1}finally{z(null)}}},[t,s,p,l]),y=d.useCallback(async i=>{z(i.id);try{if(!i.installed){const ee=await L.installMcp(i.id,t,void 0,s,!1);if(!ee.ok)throw new Error(ee.error||"install failed")}const k=await L.startMcpOAuth(i.id);if(!k.ok||!k.authUrl||!k.state)throw new Error(k.error||"oauth start failed");await _e(k.authUrl,k.state)?(await L.toggleMcp(i.id,!0,t,s),l(a(n,`${i.name} 授权成功`,`${i.name} authorized`),!0)):l(a(n,"授权未完成","Authorization not completed"),!1),await p()}catch(k){l(k?.message||"OAuth failed",!1)}finally{z(null)}},[t,s,n,l,p]),I=d.useCallback(async(i,k)=>{if(i.installedKey){z(i.id);try{await L.toggleMcp(i.installedKey,k,i.scope==="workspace"?"workspace":"global",s),await p()}catch(T){l(T?.message||"Failed",!1)}finally{z(null)}}},[s,p,l]),E=d.useCallback(async i=>{if(i.installedKey){z(i.id);try{await L.removeMcp(i.installedKey,i.scope==="workspace"?"workspace":"global",i.isRecommended?i.id:void 0,s),await p()}catch(k){l(k?.message||"Failed",!1)}finally{z(null)}}},[s,p,l]),D=d.useCallback(async i=>{if(!N)return;await v(N,i)!==!1&&o(null)},[N,v]),Q=d.useCallback(i=>{if(i.state==="ready"||i.state==="unhealthy"){I(i,!1);return}if(i.state==="disabled"){I(i,!0);return}if(i.state==="needs_auth"){if(i.auth.type==="mcp-oauth"){y(i);return}if(i.auth.type==="credentials"){o(i);return}}},[I,y]),X=d.useCallback(i=>{if(i.state==="disabled"){I(i,!0);return}if(i.state==="needs_auth"){if(i.auth.type==="mcp-oauth"){y(i);return}if(i.auth.type==="credentials"){o(i);return}}if(i.auth.type==="mcp-oauth"){y(i);return}if(i.auth.type==="credentials"){o(i);return}v(i)},[y,v,I]),ue=x&&!h;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(V,{children:"MCP Servers"}),!x&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:[R.length," ",a(n,"在用","in use")," · ",u.length-R.length-_.length," ",a(n,"可添加","available")]}),x&&e.jsx($,{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:g,onChange:i=>b(i.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"})]})})]}),ue?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx($,{})}):e.jsxs("div",{className:"space-y-5",children:[_.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:_.map((i,k)=>i.installed?e.jsx(se,{item:i,locale:n,busy:C===i.id,index:k,onPrimary:()=>Q(i),onReconfigure:r},i.id):e.jsx(ne,{item:i,locale:n,busy:C===i.id,index:k,onPrimary:()=>X(i)},i.id))})]}),R.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:R.map((i,k)=>e.jsx(se,{item:i,locale:n,busy:C===i.id,index:k,onPrimary:()=>Q(i),onRemove:()=>{E(i)},onReauth:i.auth.type==="mcp-oauth"?()=>{y(i)}:void 0,onReconfigure:i.auth.type==="credentials"?()=>o(i):void 0},i.id))})]}),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-fg-5"}),R.length===0?a(n,"推荐的服务","Recommended services"):a(n,"更多可选","More options")]}),e.jsx("div",{className:"space-y-4",children:j.map(i=>e.jsx(Be,{groupKey:i.key,locale:n,children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:i.items.map((k,T)=>e.jsx(ne,{item:k,locale:n,busy:C===k.id,index:T,onPrimary:()=>X(k)},k.id))})},i.key))})]}),_.length===0&&R.length===0&&j.length===0&&e.jsx(J,{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(Le,{open:!!N,onClose:()=>o(null),locale:n,item:N,initial:N?.config?.env||N?.config?.headers,onSubmit:D}),e.jsx(ze,{open:f,onClose:()=>m(!1),locale:n,scope:t,workdir:s,onAdded:p})]})}function Be({groupKey:t,locale:s,children:n}){const r=K[t],l=r?a(s,r.zh,r.en):t;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-medium text-fg-5",children:l}),n]})}function J({title:t,subtitle:s}){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:t}),s&&e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:s})]})}function ce({scope:t,workdir:s,locale:n}){const r=P(u=>u.toast),l=`pikiclaw.skills.catalog.${t}.${s||""}`,{data:c,loading:h,refresh:x}=Y(l,async()=>{const u=await L.getSkillsCatalog(s,t);return{items:u.items||[],installed:u.installed||[]}},[s,t]),[p,g]=d.useState(!1),[b,N]=d.useState(null),o=c?.items||[],f=d.useMemo(()=>{const u=c?.installed||[],w=t==="global"?"global":"project";return u.filter(_=>_.scope===w)},[c,t]),m=d.useMemo(()=>f.filter(u=>!o.some(w=>w.installedNames.includes(u.name))),[f,o]),C=d.useCallback(async u=>{N(u.id);try{const w=await L.installSkill(u.source,t==="global",void 0,s);w.ok?(r(a(n,`${u.name} 已安装`,`${u.name} installed`),!0),await x()):r(w.error||"Failed",!1)}catch(w){r(w?.message||"Failed",!1)}finally{N(null)}},[t,s,n,r,x]),z=d.useCallback(async u=>{N(u);try{const w=await L.removeExtensionSkill(u,t==="global",s);w.ok?(r(a(n,`${u} 已移除`,`${u} removed`),!0),await x()):r(w.error||"Failed",!1)}catch(w){r(w?.message||"Failed",!1)}finally{N(null)}},[t,s,n,r,x]),M=h&&!c;return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(V,{children:"Skills"}),!h&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:[f.length," ",a(n,"已安装","installed")]}),h&&e.jsx($,{className:"h-3 w-3"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>g(!0),children:["+ ",a(n,"从 GitHub 安装","Install from GitHub")]})]}),M?e.jsx("div",{className:"flex items-center justify-center py-10",children:e.jsx($,{})}):o.length===0&&m.length===0?e.jsx(J,{title:a(n,"暂无可用的技能包","No skill packs available"),subtitle:a(n,"从 GitHub 导入一个开始使用","Import from GitHub to get started")}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:o.map((u,w)=>e.jsx(Ae,{item:u,locale:n,busy:b===u.id,index:w,onInstall:()=>{C(u)},onRemove:()=>u.installedNames.forEach(_=>{z(_)})},u.id))}),m.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-medium text-fg-5",children:a(n,"自定义技能","Custom skills")}),e.jsx("div",{className:"space-y-1.5",children:m.map(u=>e.jsxs(fe,{children:[e.jsx(je,{icon:e.jsx(re,{size:14}),title:u.label||u.name,subtitle:u.description||void 0,badge:e.jsx(te,{variant:"ok",children:a(n,"已安装","Installed")})}),e.jsx("div",{className:"min-w-0 xl:col-span-2",children:u.mcpRequires?.length?e.jsxs(te,{variant:"muted",children:["MCP: ",u.mcpRequires.join(", ")]}):null}),e.jsx(ve,{children:e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{z(u.name)},disabled:b===u.name,className:"hover:!text-err",children:a(n,"移除","Remove")})})]},u.name))})]})]}),e.jsx(Me,{open:p,onClose:()=>g(!1),locale:n,scope:t,workdir:s,onInstalled:x})]})}const Z={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 de({state:t,locale:s}){return t==="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(U,{size:10}),a(s,"已登录","Signed in")]}):t==="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(s,"待登录","Sign-in needed")]}):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:a(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:"..."})}function Pe({chunks:t,running:s,emptyHint:n}){const r=d.useRef(null);d.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[t.length]);const l=t.join("");return e.jsx("div",{ref:r,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:s?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx($,{})," ",n||"Starting…"]}):n||"No output yet"})})}function Oe({cli:t,locale:s,onSignedIn:n,onCancel:r}){const[l,c]=d.useState([]),[h,x]=d.useState(!1),[p,g]=d.useState(null),[b,N]=d.useState(null),[o,f]=d.useState(null),m=d.useRef(null),C=d.useCallback(()=>{try{m.current?.close()}catch{}m.current=null},[]);d.useEffect(()=>C,[C]);const z=d.useCallback(async()=>{c([]),f(null),N(null),x(!0);try{const v=await L.startCliAuth(t.id);if(!v.ok||!v.sessionId)throw new Error(v.error||"start failed");g(v.sessionId);const y=new EventSource(`/api/extensions/cli/auth/stream?sessionId=${encodeURIComponent(v.sessionId)}`);m.current=y,y.onmessage=I=>{try{const E=JSON.parse(I.data);E.type==="output"?c(D=>D.length>400?[...D.slice(-400),E.chunk]:[...D,E.chunk]):E.type==="status"?N(E.status.state==="ready"?a(s,"已检测到登录成功","Sign-in detected"):a(s,"等待授权完成…","Waiting for authorization…")):E.type==="error"?f(E.message||"error"):E.type==="done"&&(x(!1),C(),E.ok&&n())}catch{}},y.addEventListener("close",()=>{x(!1),C()}),y.onerror=()=>{h&&f(a(s,"连接中断","Stream disconnected"))}}catch(v){x(!1),f(v?.message||"failed to start sign-in")}},[t.id,C,s,n,h]),M=d.useCallback(async()=>{if(p)try{await L.cancelCliAuth(p)}catch{}C(),x(!1),r()},[p,C,r]),[u,w]=d.useState({}),[_,R]=d.useState(!1),j=d.useCallback(async()=>{R(!0),f(null);try{const v=await L.applyCliToken(t.id,u);v.ok?n():f(v.error||a(s,"应用凭据失败","Failed to apply credentials"))}catch(v){f(v?.message||"failed")}finally{R(!1)}},[t.id,u,s,n]);if(t.auth.type==="oauth-web"){const v=s==="zh-CN"&&t.auth.loginHintZh||t.auth.loginHint;return e.jsxs("div",{className:"space-y-3",children:[v&&e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:v}),e.jsx(Pe,{chunks:l,running:h,emptyHint:a(s,"点击「开始登录」后将在此展示命令行输出",'Click "Start sign-in" to stream CLI output here')}),o&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:o}),b&&!o&&e.jsx("div",{className:"text-[12px] text-[var(--th-ok)]",children:b}),e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsx(S,{variant:"outline",size:"sm",onClick:M,children:a(s,"中止","Abort")}):e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"primary",size:"sm",onClick:z,children:a(s,"开始登录","Start sign-in")}),e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:a(s,"取消","Cancel")})]})})]})}if(t.auth.type==="token"){const v=s==="zh-CN"&&t.auth.loginHintZh||t.auth.loginHint;return e.jsxs("div",{className:"space-y-3",children:[v&&e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:v}),e.jsx("div",{className:"space-y-2",children:(t.auth.tokenFields||[]).map(y=>e.jsxs("label",{className:"block text-[12px]",children:[e.jsxs("div",{className:"mb-1 text-fg-3",children:[s==="zh-CN"?y.labelZh:y.label,y.required&&e.jsx("span",{className:"ml-1 text-[var(--th-err)]",children:"*"})]}),e.jsx(B,{type:y.secret?"password":"text",value:u[y.key]||"",onChange:I=>w(E=>({...E,[y.key]:I.target.value})),placeholder:y.placeholder||"",className:"w-full"}),y.helpUrl&&e.jsxs("a",{className:"mt-1 inline-block text-[11px] text-primary hover:underline",href:y.helpUrl,target:"_blank",rel:"noreferrer",children:[a(s,"如何获取","How to get this")," ↗"]})]},y.key))}),o&&e.jsx("div",{className:"text-[12px] text-[var(--th-err)]",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"primary",size:"sm",onClick:j,disabled:_,children:_?a(s,"验证中…","Verifying…"):a(s,"保存并验证","Save & verify")}),e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:a(s,"取消","Cancel")})]})]})}return null}function Fe({commands:t,locale:s}){return e.jsx("div",{className:"space-y-2",children:t.map((n,r)=>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(s,"复制到剪贴板","Copy to clipboard"),children:a(s,"复制","Copy")})]})]},r))})}function De({cli:t,open:s,onClose:n,onChanged:r,locale:l}){const[c,h]=d.useState(!1),[x,p]=d.useState(!1),[g,b]=d.useState(null);d.useEffect(()=>{s||(h(!1),b(null))},[s]);const N=d.useMemo(()=>t?t.install[t.platform]||[]:[],[t]);if(!t)return null;const o=t.state!=="not_installed",f=t.state==="ready",m=async()=>{p(!0),b(null);try{const C=await L.logoutCli(t.id);C.ok||b(C.error||a(l,"登出失败","Logout failed")),r()}catch(C){b(C?.message||"failed")}finally{p(!1)}};return e.jsxs(G,{open:s,onClose:n,wide:!0,children:[e.jsx(W,{title:t.name,description:l==="zh-CN"?t.descriptionZh:t.description,onClose:n}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(H,{iconSlug:t.iconSlug,iconUrl:t.iconUrl,name:t.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:[t.name,t.homepage&&e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-fg-5 hover:text-primary",children:e.jsx(F,{})})]}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11.5px] text-fg-4",children:[de({state:t.state,locale:l}),t.version&&e.jsxs("span",{className:"font-mono text-fg-5",children:["v",t.version]}),f&&t.authDetail&&e.jsxs("span",{className:"truncate text-fg-5",children:["· ",t.authDetail]})]})]})]}),!o&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("div",{className:"text-[12px] font-semibold text-fg-3",children:a(l,"安装","Install")}),e.jsx("div",{className:"text-[11.5px] leading-relaxed text-fg-5",children: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.")}),N.length>0?e.jsx(Fe,{commands:N,locale:l}):e.jsx("div",{className:"text-[12px] text-fg-5",children:a(l,"请查看官方文档","Check the official installation docs")}),t.install.docs&&e.jsxs("a",{href:t.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(S,{variant:"outline",size:"sm",onClick:r,children:a(l,"我已安装,重新检测","I've installed, re-check")})})]}),o&&t.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")}),f&&!c&&e.jsx(S,{variant:"ghost",size:"sm",onClick:m,disabled:x,children:x?a(l,"登出中…","Signing out…"):a(l,"登出","Sign out")})]}),g&&e.jsx("div",{className:"text-[11.5px] text-[var(--th-err)]",children:g}),f&&!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(U,{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(S,{variant:"outline",size:"sm",onClick:()=>h(!0),children:a(l,"重新登录","Re-authenticate")})})]}):e.jsx(Oe,{cli:t,locale:l,onSignedIn:()=>{h(!1),r()},onCancel:()=>h(!1)})]}),o&&t.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(U,{size:12}),e.jsx("span",{children:a(l,"无需授权 — 可直接使用。","No authentication required — ready to use.")})]})})]})]})}function Ue({item:t,onClick:s,locale:n,animationDelay:r}){const{hex:l}=q(t.iconSlug,t.name);return e.jsxs("button",{type:"button",onClick:s,className:"animate-in-up group relative w-full 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, ${A(l,.06)} 0%, ${A(l,.02)} 100%), var(--th-panel)`,animationDelay:r},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, ${A(l,.18)}, transparent 70%)`}}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx(H,{iconSlug:t.iconSlug,iconUrl:t.iconUrl,name:t.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:t.name}),de({state:t.state,locale:n})]}),e.jsxs("div",{className:"mt-0.5 truncate text-[11.5px] text-fg-5",children:[t.version?e.jsxs("span",{className:"font-mono",children:["v",t.version]}):null,t.version&&t.authDetail?" · ":null,t.authDetail]}),e.jsx("div",{className:"mt-1 truncate text-[11.5px] text-fg-4",children:n==="zh-CN"?t.descriptionZh:t.description})]})]})]})}function He({item:t,onClick:s,locale:n,animationDelay:r}){const{hex:l}=q(t.iconSlug,t.name),c=t.state==="not_installed"?a(n,"安装","Install"):t.state==="installed_not_auth"?a(n,"登录","Sign in"):a(n,"查看","Details");return e.jsxs("button",{type:"button",onClick:s,className:"animate-in-up group relative w-full 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:r},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{iconSlug:t.iconSlug,iconUrl:t.iconUrl,name:t.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:t.name}),t.homepage&&e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-fg-5 transition-colors hover:text-primary",children:e.jsx(F,{})})]}),e.jsx("div",{className:"mt-0.5 truncate text-[11.5px] text-fg-4",children:n==="zh-CN"?t.descriptionZh:t.description})]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-fg-5",children:t.auth.type==="oauth-web"?a(n,"浏览器授权","OAuth"):t.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:`${A(l,.08)}`,color:l},children:c})]})]})}function xe({locale:t,scope:s}){const{data:n,loading:r,refresh:l}=Y("pikiclaw:cli:catalog",async()=>{const o=await L.getCliCatalog();if(!o.ok)throw new Error(o.error||"failed");return o.items||[]},[]),[c,h]=d.useState(null),x=d.useMemo(()=>{const o=n||[];return o},[n,s]),p=c&&x.find(o=>o.id===c)||null,g=x.filter(o=>o.state==="ready"),b=x.filter(o=>o.state!=="ready"),N=d.useMemo(()=>{const o=new Map;for(const f of b){const m=f.category;o.has(m)||o.set(m,[]),o.get(m).push(f)}return[...o.entries()].sort(([f],[m])=>(Z[f]?.order??99)-(Z[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(V,{children:a(t,"CLI 工具","CLI Tools")}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-5",children:[e.jsxs("span",{children:[g.length," ",a(t,"已登录","signed in")," · ",b.length," ",a(t,"可用","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:r?a(t,"刷新中…","Refreshing…"):a(t,"刷新","Refresh")})]})]}),s==="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(t,"CLI 工具安装于机器层面,项目视图下同样可见。","CLI tools are installed machine-wide and are shown here for convenience.")}),g.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(t,"已登录","Signed in")]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:g.map((o,f)=>e.jsx(Ue,{item:o,locale:t,animationDelay:`${Math.min(f,12)*30}ms`,onClick:()=>h(o.id)},o.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(t,"推荐工具","Available")]}),N.map(([o,f])=>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:t==="zh-CN"?Z[o]?.zh||o:Z[o]?.en||o}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:f.map((m,C)=>e.jsx(He,{item:m,locale:t,animationDelay:`${Math.min(C,12)*30}ms`,onClick:()=>h(m.id)},m.id))})]},o))]}),!r&&x.length===0&&e.jsx(J,{title:a(t,"暂无可用 CLI","No CLI tools available"),subtitle:a(t,"稍后再试,或重启一下服务。","Try again later, or restart the service.")}),e.jsx(De,{cli:p,open:!!p,onClose:()=>h(null),onChanged:()=>{l()},locale:t})]})}function he({active:t,onChange:s,locale:n,counts:r}){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(pe,{className:"w-fit bg-panel/80 backdrop-blur",children:l.map(c=>e.jsxs(ge,{active:t===c.id,onClick:()=>s(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}),r?.[c.id]!==void 0&&e.jsx("span",{className:O("ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold",t===c.id?"bg-primary/12 text-primary":"bg-inset/70 text-fg-5"),children:r[c.id]})]},c.id))})}function Ye({onOpenBrowserSetup:t}){const s=P(x=>x.locale),r=P(x=>x.state)?.config?.workdir||"",[l,c]=d.useState(()=>{try{const x=localStorage.getItem("pikiclaw:extensions:tab");return x==="mcp"||x==="cli"||x==="skill"?x:"mcp"}catch{return"mcp"}}),h=d.useCallback(x=>{c(x);try{localStorage.setItem("pikiclaw:extensions:tab",x)}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(s,"管理一次授权即可全局复用的服务与工具。项目专属的扩展请在工作台侧栏配置。","One-time authorization, use everywhere. Project-specific extensions live in the Workbench sidebar.")})}),e.jsx(he,{active:l,onChange:h,locale:s})]}),e.jsxs("div",{className:"animate-in-fade",children:[l==="mcp"&&e.jsx("div",{className:"space-y-7",children:e.jsx(oe,{scope:"global",workdir:r,locale:s,onOpenBrowserSetup:t})}),l==="cli"&&e.jsx(xe,{locale:s,scope:"global"}),l==="skill"&&e.jsx(ce,{scope:"global",workdir:r,locale:s})]},l)]})}function Je({workdir:t}){const s=P(c=>c.locale),[n,r]=d.useState(()=>{try{const c=localStorage.getItem("pikiclaw:extensions-ws:tab");return c==="mcp"||c==="cli"||c==="skill"?c:"mcp"}catch{return"mcp"}}),l=d.useCallback(c=>{r(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(s,"仅对当前工作区生效 — 依赖项目目录的本地服务和专属技能包。","Scoped to this workspace — local services that depend on project context and project-specific skill packs.")}),e.jsx(he,{active:n,onChange:l,locale:s})]}),e.jsxs("div",{className:"animate-in-fade",children:[n==="mcp"&&e.jsx(oe,{scope:"workspace",workdir:t,locale:s}),n==="cli"&&e.jsx(xe,{locale:s,scope:"workspace"}),n==="skill"&&e.jsx(ce,{scope:"workspace",workdir:t,locale:s})]},n)]})}export{Ye as ExtensionsTab,Je as WorkspaceExtensionsBody};
@@ -0,0 +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-CypsxtrZ.js";import{B as A}from"./BrandIcon-DHaeSgX8.js";import{a as B,b as L,c as S,d as T}from"./shared-JcpxfGic.js";import"./router-emLofBBH.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-COeEMXhW.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};
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-CypsxtrZ.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};