pikiclaw 0.3.45 → 0.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{AgentTab-DS0jZ2GV.js → AgentTab-DLdePfYx.js} +1 -1
- package/dashboard/dist/assets/{BrandIcon-DSj09eUd.js → BrandIcon-10Ai0NRI.js} +1 -1
- package/dashboard/dist/assets/{DirBrowser-DwzWrIWw.js → DirBrowser-JaTtYg-M.js} +1 -1
- package/dashboard/dist/assets/{ExtensionsTab-DfRScHTz.js → ExtensionsTab-Du35Df2L.js} +1 -1
- package/dashboard/dist/assets/{IMAccessTab-BDoyR2EO.js → IMAccessTab-CEUWgvts.js} +1 -1
- package/dashboard/dist/assets/{Modal-CoNLEvWc.js → Modal-Dky9qH2d.js} +1 -1
- package/dashboard/dist/assets/{Modals-vXVWUz-q.js → Modals-BkreHiCi.js} +1 -1
- package/dashboard/dist/assets/{Select-BmvyKLPe.js → Select-DI_biurT.js} +1 -1
- package/dashboard/dist/assets/SessionPanel-DmngfMVE.js +1 -0
- package/dashboard/dist/assets/{SystemTab-QSfoxx-7.js → SystemTab-Bha1VNx7.js} +1 -1
- package/dashboard/dist/assets/{index-DEXOVIim.js → index-6-_orDYi.js} +2 -2
- package/dashboard/dist/assets/{index-DpUwNPM1.js → index-DGlwhF6x.js} +4 -4
- package/dashboard/dist/assets/{shared-CTAv1sVN.js → shared-DXfu2khL.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/bot/bot.js +63 -15
- package/dist/channels/dingtalk/bot.js +16 -1
- package/dist/channels/discord/bot.js +16 -1
- package/dist/channels/feishu/bot.js +23 -1
- package/dist/channels/slack/bot.js +16 -1
- package/dist/channels/telegram/bot.js +23 -1
- package/dist/channels/wecom/bot.js +16 -1
- package/dist/channels/weixin/bot.js +32 -2
- package/dist/cli/channels.js +6 -1
- package/dist/core/config/user-config.js +62 -1
- package/dist/dashboard/runtime.js +9 -4
- package/package.json +1 -1
- package/dashboard/dist/assets/SessionPanel-CmIIamVj.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e,b as Oe}from"./react-vendor-DTcmqLiz.js";import{c as F,u as $,a as V,B as _,S as G,k as O,b as De,g as Q,E as he,A as Be}from"./index-DEXOVIim.js";import{B as Y}from"./BrandIcon-DSj09eUd.js";import{M as ee,a as te,L as H,I as K}from"./Modal-CoNLEvWc.js";import{S as q}from"./Select-BmvyKLPe.js";import{A as ce,S as Ue}from"./shared-CTAv1sVN.js";import"./router-Cav8lq-m.js";function xe(n,t){return!!(n&&t instanceof Node&&n.contains(t))}function _e(n,t){if(t.length===0)return!0;const a=`${n.label} ${n.description||""} ${n.meta||""}`.toLowerCase();return t.every(s=>a.includes(s))}function we({value:n,options:t,onChange:a,className:s,placeholder:o="—",disabled:l=!1,searchPlaceholder:d="Search models...",noMatchesText:w="No matches",currentLabel:u="Current"}){const i=t.find(m=>m.value===n),g=t.length<=1,[f,j]=r.useState(!1),[p,C]=r.useState(""),[E,A]=r.useState(null),L=r.useRef(null),M=r.useRef(null),x=r.useRef(null);r.useEffect(()=>{if(!f)return;const m=c=>{xe(L.current,c.target)||xe(M.current,c.target)||j(!1)},b=c=>{c.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b)}},[f]),r.useEffect(()=>{f||C("")},[f]),r.useEffect(()=>{if(f){const m=window.setTimeout(()=>x.current?.focus(),0);return()=>window.clearTimeout(m)}},[f]),r.useLayoutEffect(()=>{if(!f)return;const m=()=>{const b=L.current;if(!b)return;const c=b.getBoundingClientRect(),S=window.innerHeight-c.bottom-12,P=c.top-12,D=S<280&&P>S,U=Math.max(220,Math.min(360,D?P:S));A({left:c.left,top:D?Math.max(12,c.top-U-8):c.bottom+8,width:c.width,maxHeight:U})};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[f]);const N=r.useMemo(()=>p.trim().toLowerCase().split(/\s+/).filter(Boolean),[p]),R=r.useMemo(()=>t.filter(m=>m.value!==n&&_e(m,N)),[t,n,N]);if(g)return e.jsx("div",{className:F("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",l&&"cursor-not-allowed",s),children:e.jsx("span",{className:F("truncate",!i&&"text-fg-6"),children:i?.label||o})});const y=m=>{l||(a(m),j(!1))},h=(m,b)=>e.jsxs("button",{type:"button",role:"option","aria-selected":b,onClick:()=>y(m.value),className:F("flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",b?"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.jsxs("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:m.label}),m.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:m.meta})]}),m.description&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-relaxed text-fg-5",children:m.description})]}),b&&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"})})]},m.value),B=m=>{const b=[];let c;for(const v of m)v.group&&v.group!==c?(b.push(e.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:v.group},`__group:${v.group}`)),c=v.group):v.group||(c=void 0),b.push(h(v,!1));return b},z=f&&E?Oe.createPortal(e.jsxs("div",{ref:M,role:"listbox",className:"fixed z-[220] flex flex-col overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:E.left,top:E.top,width:E.width,maxHeight:E.maxHeight},children:[e.jsxs("div",{className:"relative px-1.5 pt-1 pb-2",children:[e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-3.5 flex items-center text-fg-5",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),e.jsx("input",{ref:x,type:"text",value:p,onChange:m=>C(m.target.value),placeholder:d,spellCheck:!1,autoComplete:"off",className:F("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:[i&&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:u}),h(i,!0),e.jsx("div",{className:"my-1.5 border-t border-edge"})]}),R.length>0?B(R):e.jsx("div",{className:"px-3 py-3 text-center text-[12px] text-fg-5",children:w})]})]}),document.body):null;return e.jsxs("div",{ref:L,className:F("relative",s),children:[e.jsxs("button",{type:"button",disabled:l,"aria-haspopup":"listbox","aria-expanded":f,onClick:()=>j(m=>!m),className:F("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",f&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:F("min-w-0 flex-1 truncate",!i&&"text-fg-5"),children:i?.label||o}),e.jsx("span",{className:F("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",f&&"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"})})})]}),z]})}const J=[{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 $e(n){return n==="zh-CN"?{sectionTitle:"模型供应商",sectionHint:"连接你自己的模型供应商,凭据加密存入系统 Keychain,可绑定到任意一个智能体。",addLabel:"接入新供应商",validate:"校验",validating:"校验中",edit:"编辑",remove:"删除",removeConfirm:"删除该供应商?已绑定的智能体会自动恢复为官方 Auth。",unbound:"尚未被任何智能体使用",boundOne:"已绑定",boundN:t=>`${t} 个智能体在用`,notConnected:"未接入",modalAddTitle:"接入模型供应商",modalAddHint:t=>t?`已套用 ${t} 模板,仅需粘贴 API Key。`:"填入端点和凭据,保存后即可在智能体卡片上选用。",modalEditTitle:"编辑供应商配置",modalEditHint:"修改端点、凭据或模型参数。修改凭据会清空已校验状态。",fieldName:"配置名称",fieldNamePlaceholder:"例如:OpenRouter · 个人",fieldKind:"API 类型",fieldBaseURL:"Base URL",fieldCredentialSource:"凭据来源",fieldApiKey:"API Key",fieldApiKeyHint:"通过 @napi-rs/keyring 写入系统 Keychain,setting.json 仅保存引用。",fieldEnvVar:"环境变量名",fieldCommand:"获取命令(执行结果作为 key)",fieldModelId:"模型 ID",fieldEffort:"推理强度",fieldEffortHelp:"可用范围由模型决定,留空表示沿用模型默认值。",effortHermesNote:"Hermes 当前从 ~/.hermes/config.yaml 读取推理强度,Profile 上的 effort 暂仅做记录。",credPaste:"粘贴 API Key(推荐,写入系统 Keychain)",credEnv:"从环境变量读取",credCommand:"运行命令获取(1Password / pass / gh 等)",effortDefault:"(沿用默认)",cancel:"取消",save:"保存",saving:"保存中",validationReady:"已就绪",validationInvalid:"凭据无效",validationError:"网络/服务错误",validationUnvalidated:"未校验",providerOnlyHint:"保存后回到智能体卡片,点击「BYOK」选择具体的模型与推理强度。",credentialLabel:"凭据",modelsAvailable:t=>`可用 ${t} 个模型`}:{sectionTitle:"Model Providers",sectionHint:"Connect your own model providers. Keys are encrypted in the OS keychain and can be bound to any agent.",addLabel:"Add provider",validate:"Validate",validating:"Validating",edit:"Edit",remove:"Remove",removeConfirm:"Remove this provider? Bound agents will fall back to native auth.",unbound:"Not used by any agent yet",boundOne:"Bound to",boundN:t=>`${t} agents in use`,notConnected:"Not connected",modalAddTitle:"Connect Model Provider",modalAddHint:t=>t?`Pre-filled from the ${t} template — just paste your API key.`:"Enter endpoint and credential. After saving, choose models on the agent cards above.",modalEditTitle:"Edit Provider",modalEditHint:"Update the endpoint, credential, or model. Changing the credential clears the validated state.",fieldName:"Display name",fieldNamePlaceholder:"e.g. OpenRouter · Personal",fieldKind:"API kind",fieldBaseURL:"Base URL",fieldCredentialSource:"Credential source",fieldApiKey:"API key",fieldApiKeyHint:"Stored in the OS keychain via @napi-rs/keyring; setting.json keeps only a reference.",fieldEnvVar:"Environment variable name",fieldCommand:"Command (stdout becomes the key)",fieldModelId:"Model ID",fieldEffort:"Reasoning effort",fieldEffortHelp:"Available values depend on the chosen model; leave blank to use the default.",effortHermesNote:"Hermes currently reads reasoning_effort from ~/.hermes/config.yaml; Profile.effort is recorded only for now.",credPaste:"Paste API key (recommended — stored in OS keychain)",credEnv:"Read from environment variable",credCommand:"Run a command (1Password / pass / gh, …)",effortDefault:"(default)",cancel:"Cancel",save:"Save",saving:"Saving",validationReady:"Ready",validationInvalid:"Invalid",validationError:"Error",validationUnvalidated:"Not validated",providerOnlyHint:'After saving, head back to an agent card and click "BYOK" to choose the model and effort.',credentialLabel:"Credential",modelsAvailable:t=>`${t} models available`}}const se={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 ge(n,t){return t==="zh-CN"?se[n].zh:se[n].en}async function le(n){return(await fetch(n)).json()}async function X(n,t,a){return(await fetch(t,{method:n,headers:{"Content-Type":"application/json"},body:a?JSON.stringify(a):void 0})).json()}function Ie(n){const t=(()=>{try{return new URL(n.baseURL)}catch{return null}})(),a=t?.host.toLowerCase()??"",s=t?.port??"";return(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="11434"?"ollama":(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="8080"?"mlx":a.includes("openrouter")?"openrouter":a.includes("anthropic")?"anthropic":a.includes("deepseek")?"deepseek":a.includes("googleapis")||a.includes("vertex")?"google":a.includes("openai.com")?"openai":a.includes("dashscope")||a.includes("qwen")||a.includes("aliyun")?"qwen":a.includes("volces")||a.includes("volcengine")||a.includes("doubao")?"doubao":a.includes("bigmodel")||a.includes("zhipu")||a.includes("z.ai")?"glm":a.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function ze({desc:n,copy:t,locale:a,onPick:s}){const{provider:o,template:l}=n,d=!!o,w=o?Ie(o):l?.id??"custom",u=o?.name??(l?a==="zh-CN"?l.name.zh:l.name.en:""),i=l?a==="zh-CN"?l.blurb.zh:l.blurb.en:"",g=o?.validation?.state??null,f=o?.validation?.modelCount;let j=null,p="";o&&(g==="ready"?(j="bg-emerald-500",p=f!=null?t.modelsAvailable(f):t.validationReady):g==="invalid"?(j="bg-rose-500",p=t.validationInvalid):g==="error"?(j="bg-amber-500",p=t.validationError):(j="bg-fg-6",p=t.validationUnvalidated));const C=d&&o.validation?.detail&&g!=="ready"?o.validation.detail:i;return e.jsxs("button",{type:"button",onClick:()=>s(n),className:"group relative flex h-[68px] items-center gap-2.5 rounded-lg border border-edge bg-panel-alt px-3 py-2 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsx(Y,{brand:w,size:26}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[j&&e.jsx("span",{className:F("inline-block h-[6px] w-[6px] shrink-0 rounded-full",j),title:p}),e.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-fg",children:u})]}),C&&e.jsx("div",{className:"truncate text-[11px] leading-snug text-fg-5",title:C,children:C})]}),g==="ready"&&f!=null&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] text-fg-5",title:t.modelsAvailable(f),children:f})]})}function ie(n,t){return{name:t==="zh-CN"?`${n.name.zh}`:`${n.name.en}`,kind:n.kind,baseURL:n.baseURL,credMode:"paste",apiKey:"",envVar:n.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}}function Fe({open:n,copy:t,locale:a,initial:s,initialTemplateName:o,existingProvider:l,onClose:d,onSaved:w,onRemove:u}){const[i,g]=r.useState(()=>s||ie(J[0],a)),[f,j]=r.useState(!1),[p,C]=r.useState(null);r.useEffect(()=>{n&&(g(s||ie(J[0],a)),C(null))},[n,s,a]);const E=!!l,A=!!o||E,L=r.useCallback(async()=>{C(null),j(!0);try{const x=i.credMode==="env"?{source:"env",varName:i.envVar.trim()}:i.credMode==="command"?{source:"command",argv:i.cmdLine.trim().split(/\s+/).filter(Boolean)}:null;let N;if(E&&l){const y={name:i.name.trim()||l.name,baseURL:i.baseURL.trim()};i.credMode==="paste"&&i.apiKey?y.apiKey=i.apiKey:x&&(y.credentialRef=x);const h=await X("PATCH",`/api/models/providers/${l.id}`,y);if(!h.ok){C(h.error||"Failed to update provider");return}N=l.id}else{const y={kind:i.kind,name:i.name.trim()||`${ge(i.kind,a)}`,baseURL:i.baseURL.trim()};i.credMode==="paste"?y.apiKey=i.apiKey:x&&(y.credentialRef=x);const h=await X("POST","/api/models/providers",y);if(!h.ok||!h.provider){C(h.error||"Failed to create provider");return}N=h.provider.id}const R=await X("POST",`/api/models/providers/${N}/validate`);if(w(),R.validation&&R.validation.state!=="ready"){C(`${t.validationInvalid}: ${R.validation.detail}`);return}d()}catch(x){C(x?.message||String(x))}finally{j(!1)}},[i,E,l,a,w,d,t.validationInvalid]),M=!f&&i.name.trim().length>0&&i.baseURL.trim().length>0&&(i.credMode!=="paste"||(E?!0:i.apiKey.length>0))&&(i.credMode!=="env"||i.envVar.trim().length>0)&&(i.credMode!=="command"||i.cmdLine.trim().length>0);return e.jsxs(ee,{open:n,onClose:d,children:[e.jsx(te,{title:E?t.modalEditTitle:t.modalAddTitle,description:E?t.modalEditHint:t.modalAddHint(o||null),onClose:d}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldName}),e.jsx(K,{value:i.name,onChange:x=>g(N=>({...N,name:x.target.value})),placeholder:t.fieldNamePlaceholder})]}),A?e.jsxs("div",{children:[e.jsx(H,{children:t.fieldBaseURL}),e.jsx(K,{value:i.baseURL,onChange:x=>g(N=>({...N,baseURL:x.target.value})),placeholder:"https://…"})]}):e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldKind}),e.jsx(q,{value:i.kind,options:Object.keys(se).map(x=>({value:x,label:ge(x,a)})),onChange:x=>g(N=>({...N,kind:x}))})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldBaseURL}),e.jsx(K,{value:i.baseURL,onChange:x=>g(N=>({...N,baseURL:x.target.value})),placeholder:"https://…"})]})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldCredentialSource}),e.jsx(q,{value:i.credMode,options:[{value:"paste",label:t.credPaste},{value:"env",label:t.credEnv},{value:"command",label:t.credCommand}],onChange:x=>g(N=>({...N,credMode:x}))})]}),i.credMode==="paste"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldApiKey}),e.jsx(K,{type:"password",value:i.apiKey,onChange:x=>g(N=>({...N,apiKey:x.target.value})),placeholder:E?"••••••••":"sk-…"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldApiKeyHint})]}),i.credMode==="env"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldEnvVar}),e.jsx(K,{value:i.envVar,onChange:x=>g(N=>({...N,envVar:x.target.value})),placeholder:"OPENROUTER_API_KEY"})]}),i.credMode==="command"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldCommand}),e.jsx(K,{value:i.cmdLine,onChange:x=>g(N=>({...N,cmdLine:x.target.value})),placeholder:"op read op://Personal/OpenRouter/key"})]}),p&&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:p})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-2 border-t border-edge pt-4",children:[e.jsx("div",{children:E&&u&&e.jsx("button",{type:"button",onClick:()=>{u()},className:"text-[12px] text-fg-5 transition hover:text-[var(--th-err)]",children:t.remove})}),e.jsx(ce,{primary:{label:f?t.saving:t.save,onClick:L,disabled:!M},secondary:{label:t.cancel,onClick:d}})]})]})}function Me(){const[n,t]=r.useState([]),[a,s]=r.useState([]),[o,l]=r.useState({}),d=r.useCallback(async()=>{const[u,i,g]=await Promise.all([le("/api/models/providers"),le("/api/models/profiles"),le("/api/models/agents")]);t(u.providers||[]),s(i.profiles||[]);const f={};for(const j of g.bindings||[])f[j.agent]=j.activeProfileId;l(f)},[]),w=r.useCallback(async(u,i)=>{await X("POST",`/api/models/agents/${u}/active`,{profileId:i}),await d()},[d]);return r.useEffect(()=>{d()},[d]),{providers:n,profiles:a,bindings:o,reload:d,setActiveProfile:w}}function ve(n){return n.replace(/\/+$/,"").replace(/^http:\/\/localhost(?=[:/]|$)/i,"http://127.0.0.1").replace(/^https:\/\/localhost(?=[:/]|$)/i,"https://127.0.0.1")}function be(n,t){const a=ve(n.baseURL);return t.some(s=>ve(s.openAIBaseURL)===a)}function Ke({snapshot:n,localBackends:t}={}){const a=Me(),s=n??a,{providers:o,reload:l}=s,d=t??[],w=$(M=>M.locale),u=r.useMemo(()=>$e(w),[w]);$(M=>M.toast);const[i,g]=r.useState(null),f=r.useCallback(async M=>{confirm(u.removeConfirm)&&(await X("DELETE",`/api/models/providers/${M.id}`),await l())},[u,l]),j=r.useMemo(()=>{if(!i||i.kind!=="edit")return null;const{provider:M}=i;return{name:M.name,kind:M.kind,baseURL:M.baseURL,credMode:"paste",apiKey:"",envVar:J.find(x=>x.kind===M.kind)?.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}},[i]),p=r.useMemo(()=>!i||i.kind!=="add"?null:ie(i.template,w),[i,w]),C=i&&i.kind==="add"&&i.template.id!=="custom"?w==="zh-CN"?i.template.name.zh:i.template.name.en:null,E=r.useMemo(()=>{const M=new Map;for(const x of o){const N=Ie(x);M.has(N)||M.set(N,x)}return M},[o]),A=r.useMemo(()=>{const M=o.filter(y=>!be(y,d)),x=new Set,N=[];for(const y of J){if(y.id==="custom")continue;const h=E.get(y.id);h&&!be(h,d)?(x.add(h.id),N.push({template:y,provider:h})):N.push({template:y})}for(const y of M)x.has(y.id)||N.push({provider:y});const R=J.find(y=>y.id==="custom");return R&&N.push({template:R}),N},[o,E,d]),L=r.useCallback(M=>{if(M.provider){g({kind:"edit",provider:M.provider});return}M.template&&g({kind:"add",template:M.template})},[]);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:A.map((M,x)=>e.jsx(ze,{desc:M,copy:u,locale:w,onPick:L},M.provider?.id??`tpl-${M.template?.id??x}`))}),i&&e.jsx(Fe,{open:!0,copy:u,locale:w,initial:i.kind==="edit"?j:p,initialTemplateName:C,existingProvider:i.kind==="edit"?i.provider:void 0,onClose:()=>g(null),onSaved:l,onRemove:i.kind==="edit"?async()=>{await f(i.provider),g(null)}:void 0})]})}const Ve=4;function Ge(n){return n==="zh-CN"?{sectionLabel:"本地后端",hostLabel:"本机",hostUnknown:"检测中…",refresh:"刷新",refreshing:"刷新中…",loadFailed:"加载失败",tileStatusDetected:"已运行",tileStatusNotDetected:"未检测到",tileStatusUnsupported:"不支持当前系统",tileBadgeReady:t=>`${t} 个模型已就绪`,tileBlurbOllama:"跨平台默认,CLI 友好,模型下载到本地后常驻",tileBlurbMlx:"Apple Silicon 原生,性能压榨极限,按需启动",tileInstalledModels:t=>`${t} 个模型`,modalTitle:t=>`准备 ${t}`,modalDescription:t=>`安装 ${t}、下载所需模型、核对运行状态——本地模型的全部配置都在这里完成。`,stepStatus:"后端状态",stepModels:"模型",statusRunning:"已运行",statusNotRunning:"未在本机检测到此后端",statusUnsupportedDesc:t=>`${t} 不支持当前系统。`,statusRecheck:"重新检测",statusRechecking:"检测中…",statusInstallHeader:"安装命令",statusInstallDocs:"官方安装文档",statusRunHint:"启动服务(安装后)",statusHomepageCta:"官网",statusAutoAttachedHint:t=>`本地 ${t} 已在运行;继续在下方下载并核对所需模型。`,modelsInstalledHeader:t=>`已就绪(${t})`,modelsInstalledEmpty:"后端在线,但尚未加载任何模型。在终端按下方命令准备一个。",modelsRecommendedHeader:"推荐模型 · 在终端执行以下命令准备",modelsBackendOffline:"启动后端后再返回此处准备模型。",fitOk:"推荐",fitTight:"勉强可跑",fitNoGo:"内存不足",modelInstalledBadge:"已就绪",pullPrefix:"终端执行",copyCommand:"复制",copied:"已复制",closeBtn:"完成"}:{sectionLabel:"Local backends",hostLabel:"This machine",hostUnknown:"Detecting…",refresh:"Refresh",refreshing:"Refreshing…",loadFailed:"Failed to load local backends",tileStatusDetected:"Running",tileStatusNotDetected:"Not detected",tileStatusUnsupported:"Not supported on this OS",tileBadgeReady:t=>`${t} models ready`,tileBlurbOllama:"Cross-platform default, CLI-friendly, models persist on disk",tileBlurbMlx:"Apple Silicon native, peak performance, on-demand launch",tileInstalledModels:t=>`${t} models`,modalTitle:t=>`Prepare ${t}`,modalDescription:t=>`Install ${t}, download the models you want, and verify they're running — all the local-model configuration lives in this panel.`,stepStatus:"Backend status",stepModels:"Models",statusRunning:"Running",statusNotRunning:"Backend not detected on this machine",statusUnsupportedDesc:t=>`${t} does not run on this OS.`,statusRecheck:"Re-check",statusRechecking:"Checking…",statusInstallHeader:"Install commands",statusInstallDocs:"Official install docs",statusRunHint:"Start the server (after install)",statusHomepageCta:"Homepage",statusAutoAttachedHint:t=>`Local ${t} is running. Continue below to download and verify the models you need.`,modelsInstalledHeader:t=>`Ready (${t})`,modelsInstalledEmpty:"Backend is up but no model is loaded. Use the command below to prepare one.",modelsRecommendedHeader:"Recommended models — run these in your terminal",modelsBackendOffline:"Start the backend first, then come back to prepare models.",fitOk:"Recommended",fitTight:"Tight fit",fitNoGo:"Not enough RAM",modelInstalledBadge:"Ready",pullPrefix:"Run in terminal",copyCommand:"Copy",copied:"Copied",closeBtn:"Done"}}function re(n,t){return n===null?"tight":n>=t+Ve?"ok":n>=t?"tight":"no-go"}function Ye(n,t){const a=n.id==="ollama"?t.ollamaTag:t.mlxModel;return a?n.pullCommandTemplate.replace("${model}",a):null}function We(n){return!n||!Number.isFinite(n)?"—":`${(n/1024**3).toFixed(0)} GB`}function qe(n){if(!n||!Number.isFinite(n))return"";const t=n/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(n/1024**2).toFixed(0)} MB`}function Ze(n,t){return t.filter(a=>n.id==="ollama"?!!a.ollamaTag:!!a.mlxModel)}function de(n,t){const a=t.id==="ollama"?n.ollamaTag:n.mlxModel;if(!a)return null;const s=a.split(":")[0].toLowerCase();for(const o of t.models)if(o.id.toLowerCase().startsWith(s))return o.id;return null}function Ce(){const[n,t]=r.useState([]),[a,s]=r.useState([]),[o,l]=r.useState(null),[d,w]=r.useState(!0),[u,i]=r.useState(null),g=r.useCallback(async()=>{w(!0),i(null);try{const f=await V.probeLocalModels();if(!f.ok)throw new Error(f.error||"Failed to load local backends");return t(f.backends||[]),s(f.catalog||[]),l(f.currentOs??null),{addedProviderIds:f.addedProviderIds??[]}}catch(f){return i(f?.message||String(f)),{addedProviderIds:[]}}finally{w(!1)}},[]);return r.useEffect(()=>{g()},[g]),{backends:n,catalog:a,currentOs:o,loading:d,error:u,refresh:g}}function Qe({backend:n,copy:t,onClick:a}){const s=!n.supportedOnThisOs,o=n.id==="ollama"?t.tileBlurbOllama:t.tileBlurbMlx,l=s?e.jsx(O,{variant:"muted",children:t.tileStatusUnsupported}):n.detected?e.jsx(O,{variant:"ok",children:t.tileBadgeReady(n.models.length)}):null,d=n.detected?`${n.version?`v${n.version} · `:""}${t.tileInstalledModels(n.models.length)}`:o;return e.jsxs("button",{type:"button",onClick:a,className:"group relative flex h-[104px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(Y,{brand:n.id,size:32}),l]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg group-hover:text-fg",children:n.label}),e.jsx("div",{className:"mt-1 truncate text-[11.5px] leading-relaxed text-fg-5",title:d,children:d})]})]})}function je({index:n,label:t,done:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold ${a?"border-transparent bg-[var(--th-badge-accent-bg)] text-[var(--th-badge-accent-text)]":"border-edge bg-panel-alt text-fg-4"}`,children:a?"✓":n}),e.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-[0.16em] text-fg-3",children:t})]})}function Je({name:n,sizeBytes:t}){return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-edge bg-panel-alt px-2 py-0.5 text-[11px] text-fg-3",children:[e.jsx("span",{className:"truncate font-mono",children:n}),t?e.jsx("span",{className:"shrink-0 text-fg-5",children:qe(t)}):null]})}function oe({label:n,cmd:t,copy:a,onCopy:s}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 truncate rounded-md border border-edge bg-panel px-2.5 py-1.5 font-mono text-[12px] text-fg-3",title:t,children:[n&&e.jsx("span",{className:"mr-2 text-fg-5",children:n}),t]}),e.jsx("button",{type:"button",onClick:()=>s(t),className:"shrink-0 rounded-md border border-edge bg-panel-alt px-2 py-1 text-[11px] text-fg-3 transition hover:border-edge-strong hover:bg-panel",children:a.copyCommand})]})}function Xe({entry:n,backend:t,totalRamGb:a,copy:s,locale:o,onCopy:l}){const d=re(a,n.minRamGb),w=o==="zh-CN"?n.descriptionZh:n.description,u=de(n,t),i=Ye(t,n);return e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3 py-2.5",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[13px] font-semibold text-fg",children:n.name}),e.jsx("span",{className:"text-[11px] text-fg-5",children:n.publisher}),d==="ok"&&e.jsx(O,{variant:"ok",children:s.fitOk}),d==="tight"&&e.jsx(O,{variant:"warn",children:s.fitTight}),d==="no-go"&&e.jsx(O,{variant:"err",children:s.fitNoGo}),u&&e.jsx(O,{variant:"accent",children:s.modelInstalledBadge})]}),e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:w}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] text-fg-5",children:[e.jsxs("span",{children:[n.paramsB,"B params"]}),e.jsxs("span",{children:[n.sizeGb," GB on disk"]}),e.jsxs("span",{children:["≥ ",n.minRamGb," GB RAM"]}),n.homepage&&e.jsx("a",{href:n.homepage,target:"_blank",rel:"noreferrer",className:"text-accent underline-offset-2 hover:underline",children:o==="zh-CN"?"模型主页":"Model card"})]}),!u&&d!=="no-go"&&i&&e.jsx(oe,{label:s.pullPrefix,cmd:i,copy:s,onCopy:l})]})})}function et({open:n,backend:t,catalog:a,totalRamGb:s,currentOs:o,copy:l,locale:d,onClose:w,onRefresh:u,onCopy:i}){const[g,f]=r.useState(!1);r.useEffect(()=>{f(!1)},[t?.detected,t?.id]);const j=r.useMemo(()=>t?Ze(t,a).sort((A,L)=>{const M=re(s,A.minRamGb),x=re(s,L.minRamGb),N=h=>h==="ok"?0:h==="tight"?1:2,R=de(A,t)?0:1,y=de(L,t)?0:1;return R!==y?R-y:N(M)-N(x)}):[],[t,a,s]);if(!t)return null;const p=!t.supportedOnThisOs,C=o?t.install[o]||[]:[],E=async()=>{f(!0);try{await u()}finally{f(!1)}};return e.jsxs(ee,{open:n,onClose:w,wide:!0,children:[e.jsx(te,{title:l.modalTitle(t.label),description:l.modalDescription(t.label),onClose:w}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx(je,{index:1,label:l.stepStatus,done:t.detected}),e.jsxs("div",{className:"space-y-2 rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel",children:e.jsx(Y,{brand:t.id,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-fg",children:t.label}),p?e.jsx(O,{variant:"muted",children:l.tileStatusUnsupported}):t.detected?e.jsx(O,{variant:"ok",children:l.statusRunning}):e.jsx(O,{variant:"muted",children:l.tileStatusNotDetected})]}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:p?e.jsx(e.Fragment,{children:l.statusUnsupportedDesc(t.label)}):t.detected?e.jsxs(e.Fragment,{children:[t.version&&e.jsxs(e.Fragment,{children:["v",t.version," · "]}),e.jsx("span",{className:"font-mono",children:t.baseURL})]}):e.jsx(e.Fragment,{children:l.statusNotRunning})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-[12px] text-accent underline-offset-2 hover:underline",children:l.statusHomepageCta}),!p&&e.jsx(_,{variant:"outline",size:"sm",disabled:g,onClick:()=>{E()},children:g?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3"})," ",l.statusRechecking]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",l.statusRecheck]})})]})]}),!p&&t.detected&&t.existingProviderId&&e.jsx("div",{className:"rounded-md border border-emerald-700/20 bg-emerald-700/5 px-2.5 py-1.5 text-[11px] leading-relaxed text-emerald-700 dark:text-emerald-300",children:l.statusAutoAttachedHint(t.label)}),!p&&!t.detected&&e.jsxs("div",{className:"space-y-2 pt-1",children:[C.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.statusInstallHeader}),C.map((A,L)=>e.jsx(oe,{label:A.label,cmd:A.cmd,copy:l,onCopy:i},L)),t.install.docs&&e.jsxs("a",{href:t.install.docs,target:"_blank",rel:"noreferrer",className:"text-[11px] text-accent underline-offset-2 hover:underline",children:[l.statusInstallDocs," →"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.statusRunHint}),e.jsx(oe,{label:t.runHint.label,cmd:t.runHint.cmd,copy:l,onCopy:i})]})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx(je,{index:2,label:l.stepModels,done:t.detected&&t.models.length>0}),t.detected?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:[e.jsx("div",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsInstalledHeader(t.models.length)}),t.models.length===0?e.jsx("div",{className:"text-[12px] text-fg-5",children:l.modelsInstalledEmpty}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(A=>e.jsx(Je,{name:A.id,sizeBytes:A.sizeBytes},A.id))})]}),j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsRecommendedHeader}),e.jsx("div",{className:"space-y-1.5",children:j.map(A=>e.jsx(Xe,{entry:A,backend:t,totalRamGb:s,copy:l,locale:d,onCopy:i},A.id))})]})]}):e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3 text-[12px] text-fg-5",children:l.modelsBackendOffline})]})]}),e.jsx("div",{className:"mt-6 border-t border-edge pt-4",children:e.jsx(ce,{primary:{label:l.closeBtn,onClick:w}})})]})}function tt({snapshot:n,onConnected:t}){const a=$(h=>h.locale),s=$(h=>h.host),o=$(h=>h.toast),l=r.useMemo(()=>Ge(a),[a]),d=Ce(),w=n??d,{backends:u,catalog:i,currentOs:g,loading:f,error:j,refresh:p}=w,[C,E]=r.useState(null),A=r.useMemo(()=>u.find(h=>h.id===C)??null,[u,C]),L=r.useRef("");r.useEffect(()=>{const h=u.map(B=>B.existingProviderId||"").join(",");h!==L.current&&(L.current=h,t&&u.some(B=>B.existingProviderId)&&t())},[u,t]);const M=r.useCallback(async()=>{const h=await p();return t&&h.addedProviderIds.length>0&&await t(),h},[p,t]),x=r.useCallback(h=>{navigator.clipboard?.writeText(h),o(l.copied)},[l.copied,o]),N=s?.totalMem?s.totalMem/1024**3:null,R=s?`${s.cpuModel||s.arch} · ${We(s.totalMem)} RAM`:l.hostUnknown,y=u.length>0?u:[{id:"ollama",label:"Ollama",detected:!1,baseURL:"http://127.0.0.1:11434",openAIBaseURL:"http://127.0.0.1:11434/v1",models:[],existingProviderId:null,homepage:"https://ollama.com/",install:{},runHint:{cmd:"ollama serve"},pullCommandTemplate:"ollama pull ${model}",supportedOnThisOs:!0},{id:"mlx",label:"mlx-lm",detected:!1,baseURL:"http://127.0.0.1:8080",openAIBaseURL:"http://127.0.0.1:8080/v1",models:[],existingProviderId:null,homepage:"https://github.com/ml-explore/mlx-lm",install:{},runHint:{cmd:"mlx_lm.server --port 8080"},pullCommandTemplate:"mlx_lm.server --model ${model} --port 8080",supportedOnThisOs:!0}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[12px] text-fg-5",children:[e.jsx("span",{className:"font-semibold uppercase tracking-[0.14em] text-fg-5",children:l.hostLabel}),e.jsx("span",{className:"mx-2 text-fg-6",children:"·"}),e.jsx("span",{className:"text-fg-3",children:R})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>{M()},disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3"})," ",l.refreshing]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",l.refresh]})})]}),e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:l.sectionLabel}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:y.map(h=>e.jsx(Qe,{backend:h,copy:l,locale:a,onClick:()=>E(h.id)},h.id))})]}),j&&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:j}),e.jsx(et,{open:C!==null,backend:A,catalog:i,totalRamGb:N,currentOs:g,copy:l,locale:a,onClose:()=>E(null),onRefresh:M,onCopy:x})]})}function nt(n){return!n||!Number.isFinite(n)?null:n>=1e6?`${Math.round(n/1e5)/10}M ctx`:n>=1e3?`${Math.round(n/1e3)}K ctx`:`${n} ctx`}function ye(n){const t=(()=>{try{return new URL(n.baseURL)}catch{return null}})(),a=t?.host.toLowerCase()??"",s=t?.port??"";return(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="11434"?"ollama":(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="8080"?"mlx":a.includes("openrouter")?"openrouter":a.includes("anthropic")?"anthropic":a.includes("deepseek")?"deepseek":a.includes("googleapis")||a.includes("vertex")?"google":a.includes("openai.com")?"openai":a.includes("dashscope")||a.includes("qwen")||a.includes("aliyun")?"qwen":a.includes("volces")||a.includes("volcengine")||a.includes("doubao")?"doubao":a.includes("bigmodel")||a.includes("zhipu")||a.includes("z.ai")?"glm":a.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function at(n){return n==="zh-CN"?{sectionTitle:"我的模型",sectionHint:"把你常用的模型登记成一条条快捷方式,自由起别名。这是一份纯粹的选择列表——智能体会从这里挑模型,但谁选了什么不会反向显示在这里。",addLabel:"添加模型",empty:"还没有登记任何模型",emptyHint:'先在下方"模型供应商"里接入一个供应商,再点上方"添加模型"把常用的几个固定下来。',addModalTitle:"添加模型",editModalTitle:"编辑模型",fieldName:"显示名",fieldNameHint:"智能体卡片和 IM 选择菜单里会看到的名称;留空则直接用模型 ID。",fieldProvider:"供应商",fieldProviderEmpty:'没有可用的供应商;请先在下方"模型供应商"里接入一个。',fieldProviderLockedHint:'想换别的供应商?关闭这个窗口,先到下方"模型供应商"里接入。',fieldModelId:"模型",fieldModelIdHint:"从供应商 /v1/models 拉到的真实模型列表中挑选。",fieldModelIdLoading:"正在拉取该供应商的模型列表…",fieldModelIdEmpty:"该供应商没有返回模型列表(或还未校验),可手动输入模型 ID。",fieldModelIdToggleManual:"改为手动输入",fieldModelIdToggleList:"从列表选择",fieldModelIdSearchPlaceholder:"搜索模型",fieldModelIdSearchEmpty:"没有匹配的模型",fieldModelIdCurrentLabel:"当前",fieldEffort:"推理强度",effortDefault:"(沿用默认)",cancel:"取消",save:"保存",saving:"保存中",remove:"删除",removeConfirm:"删除这个模型条目?已经选择它的智能体会自动回退到官方认证。",via:"经由"}:{sectionTitle:"My Models",sectionHint:"Register the models you actually use as named shortcuts. A pure selection list — agents pick from here, but who picks what does not bubble back into this view.",addLabel:"Add model",empty:"No models registered yet",emptyHint:"Connect a provider below first, then come back here to pin the few you actually use.",addModalTitle:"Add Model",editModalTitle:"Edit Model",fieldName:"Display name",fieldNameHint:"Shown in agent cards and the IM model picker. Leave empty to use the model id as-is.",fieldProvider:"Provider",fieldProviderEmpty:'No providers configured yet; add one in "Model Providers" below first.',fieldProviderLockedHint:'Want a different provider? Close this dialog and connect one in "Model Providers" below.',fieldModelId:"Model",fieldModelIdHint:"Picked from the provider's live /v1/models list.",fieldModelIdLoading:"Loading the provider's model list…",fieldModelIdEmpty:"This provider returned no model list (or has not been validated yet). Enter a model ID manually.",fieldModelIdToggleManual:"Enter manually",fieldModelIdToggleList:"Pick from list",fieldModelIdSearchPlaceholder:"Search models",fieldModelIdSearchEmpty:"No matching models",fieldModelIdCurrentLabel:"Current",fieldEffort:"Reasoning effort",effortDefault:"(default)",cancel:"Cancel",save:"Save",saving:"Saving",remove:"Remove",removeConfirm:"Remove this model entry? Agents that picked it will fall back to native auth.",via:"via"}}async function Ee(n,t,a){return(await fetch(t,{method:n,headers:{"Content-Type":"application/json"},body:a?JSON.stringify(a):void 0})).json()}const lt=["","low","medium","high","xhigh","max"];function st({open:n,copy:t,providers:a,initial:s,existing:o,onClose:l,onSaved:d,onRemove:w}){const[u,i]=r.useState(s),[g,f]=r.useState(!1),[j,p]=r.useState(null),[C,E]=r.useState(()=>new Map),[A,L]=r.useState(!1),[M,x]=r.useState(null),[N,R]=r.useState(!1);r.useEffect(()=>{n&&(i(s),p(null),R(!1),E(new Map))},[n,s]),r.useEffect(()=>{if(!n)return;const m=u.providerId;if(!m||C.has(m))return;let b=!1;return L(!0),x(null),(async()=>{try{const v=await(await fetch(`/api/models/providers/${m}/models`)).json();if(b)return;const S=v.modelInfos&&v.modelInfos.length>0?v.modelInfos:(v.models||[]).map(P=>({id:P}));E(P=>{const D=new Map(P);return D.set(m,S),D}),!v.ok&&v.error&&x(v.error)}catch(c){b||x(c?.message||String(c))}finally{b||L(!1)}})(),()=>{b=!0}},[n,u.providerId,C]);const y=!!o,h=C.get(u.providerId)??null,B=r.useCallback(async()=>{p(null),f(!0);try{const m={name:u.name.trim()||void 0,providerId:u.providerId,modelId:u.modelId.trim(),effort:u.effort||null},b=y&&o?`/api/models/profiles/${o.id}`:"/api/models/profiles",v=await Ee(y?"PATCH":"POST",b,m);if(!v.ok){p(v.error||"Failed to save");return}d(),l()}catch(m){p(m?.message||String(m))}finally{f(!1)}},[u,y,o,d,l]),z=!g&&!!u.providerId&&u.modelId.trim().length>0;return e.jsxs(ee,{open:n,onClose:l,children:[e.jsx(te,{title:y?t.editModalTitle:t.addModalTitle,description:t.sectionHint,onClose:l}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldProvider}),a.length===0?e.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-700",children:t.fieldProviderEmpty}):(()=>{const m=y||a.length<=1,b=a.find(c=>c.id===u.providerId)??a[0];return m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-10 w-full items-center gap-2.5 rounded-md border border-edge bg-panel-alt px-3",children:[e.jsx(Y,{brand:ye(b),size:20}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-fg-2",children:b.name}),e.jsx("div",{className:"truncate font-mono text-[10.5px] leading-tight text-fg-5",children:b.baseURL})]})]}),!y&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldProviderLockedHint})]}):e.jsx(q,{value:u.providerId,options:a.map(c=>({value:c.id,label:`${c.name} · ${c.baseURL}`})),onChange:c=>i(v=>({...v,providerId:c}))})})()]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-baseline justify-between gap-2",children:[e.jsx(H,{className:"mb-0",children:t.fieldModelId}),h&&h.length>0&&e.jsx("button",{type:"button",onClick:()=>R(m=>!m),className:"text-[11px] text-fg-5 transition hover:text-fg-3",children:N?t.fieldModelIdToggleList:t.fieldModelIdToggleManual})]}),A&&e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-md border border-edge bg-panel-alt px-3 text-[12px] text-fg-5",children:[e.jsx(G,{}),t.fieldModelIdLoading]}),!A&&!N&&h&&h.length>0&&(()=>{const b=[...!h.some(c=>c.id===u.modelId)&&u.modelId?[{value:u.modelId,label:u.modelId,description:t.fieldModelIdCurrentLabel}]:[],...h.map(c=>({value:c.id,label:c.id,description:c.name&&c.name.toLowerCase()!==c.id.toLowerCase()?c.name:void 0,meta:c.contextLength?nt(c.contextLength):void 0}))];return e.jsx(we,{value:u.modelId,options:b,onChange:c=>i(v=>({...v,modelId:c})),searchPlaceholder:t.fieldModelIdSearchPlaceholder,noMatchesText:t.fieldModelIdSearchEmpty,currentLabel:t.fieldModelIdCurrentLabel})})(),!A&&(N||!h||h.length===0)&&e.jsxs(e.Fragment,{children:[e.jsx(K,{value:u.modelId,onChange:m=>i(b=>({...b,modelId:m.target.value})),placeholder:"anthropic/claude-sonnet-4"}),(!h||h.length===0)&&!M&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldModelIdEmpty})]}),M&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-amber-700",children:M}),!N&&h&&h.length>0&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldModelIdHint})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldName}),e.jsx(K,{value:u.name,onChange:m=>i(b=>({...b,name:m.target.value})),placeholder:u.modelId||"anthropic/claude-sonnet-4"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldNameHint})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldEffort}),e.jsx(q,{value:u.effort,options:lt.map(m=>({value:m,label:m||t.effortDefault})),onChange:m=>i(b=>({...b,effort:m}))})]}),j&&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:j})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-2 border-t border-edge pt-4",children:[e.jsx("div",{children:y&&w&&e.jsx("button",{type:"button",onClick:()=>{w()},className:"text-[12px] text-fg-5 transition hover:text-[var(--th-err)]",children:t.remove})}),e.jsx(ce,{primary:{label:g?t.saving:t.save,onClick:B,disabled:!z},secondary:{label:t.cancel,onClick:l}})]})]})}function it({profile:n,provider:t,copy:a,onPick:s}){const o=t?ye(t):"custom";return e.jsxs("button",{type:"button",onClick:s,className:"group relative flex h-[120px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(Y,{brand:o,size:28}),n.effort&&e.jsx(O,{variant:"muted",children:n.effort})]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg",children:n.name}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] leading-relaxed text-fg-4",children:n.modelId}),e.jsxs("div",{className:"mt-1 truncate text-[11.5px] text-fg-5",children:[a.via," ",t?.name??"?"]})]})]})}function rt({onClick:n,label:t}){return e.jsxs("button",{type:"button",onClick:n,className:"flex h-[120px] flex-col items-center justify-center rounded-lg border border-dashed border-edge bg-panel-alt text-fg-4 transition hover:border-edge-strong hover:bg-panel hover:text-fg-2",children:[e.jsx("div",{className:"text-2xl leading-none",children:"+"}),e.jsx("div",{className:"mt-1 text-[12.5px] font-medium tracking-tight",children:t})]})}function dt({snapshot:n}){const{providers:t,profiles:a,reload:s}=n,o=$(p=>p.locale),l=r.useMemo(()=>at(o),[o]),[d,w]=r.useState(null),u=r.useMemo(()=>new Map(t.map(p=>[p.id,p])),[t]),i=r.useCallback(async p=>{confirm(l.removeConfirm)&&(await Ee("DELETE",`/api/models/profiles/${p.id}`),await s())},[l,s]),g=r.useMemo(()=>({name:"",providerId:t[0]?.id??"",modelId:"",effort:""}),[t]),f=r.useMemo(()=>{if(!d||d.kind!=="edit")return null;const p=d.profile;return{name:p.name,providerId:p.providerId,modelId:p.modelId,effort:p.effort||""}},[d]),j=a.length===0;return e.jsxs("div",{className:"space-y-2",children:[j&&e.jsxs("div",{className:"rounded-lg border border-dashed border-edge bg-panel-alt px-4 py-6 text-center",children:[e.jsx("div",{className:"text-[13.5px] font-semibold text-fg-2",children:l.empty}),e.jsx("div",{className:"mx-auto mt-1 max-w-md text-[12px] leading-relaxed text-fg-5",children:l.emptyHint}),t.length>0&&e.jsx("div",{className:"mt-3",children:e.jsx(_,{variant:"primary",size:"sm",onClick:()=>w({kind:"add"}),children:l.addLabel})})]}),!j&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[a.map(p=>e.jsx(it,{profile:p,provider:u.get(p.providerId)??null,copy:l,onPick:()=>w({kind:"edit",profile:p})},p.id)),t.length>0&&e.jsx(rt,{label:l.addLabel,onClick:()=>w({kind:"add"})})]}),d&&e.jsx(st,{open:!0,copy:l,providers:t,initial:d.kind==="edit"?f:g,existing:d.kind==="edit"?d.profile:null,onClose:()=>w(null),onSaved:s,onRemove:d.kind==="edit"?async()=>{await i(d.profile),w(null)}:void 0})]})}const ot=["claude","codex","gemini","hermes"];function ct(n){return n==="hermes"}function ut(n){const t=(n||"").toLowerCase().trim();return t==="openrouter"?"openrouter":t==="anthropic"?"anthropic":t==="openai"?"openai":t==="google"||t==="gemini"?"google":t==="deepseek"?"deepseek":t==="qwen"||t==="dashscope"?"qwen":t==="doubao"||t==="volces"||t==="volcengine"?"doubao":t==="glm"||t==="zhipu"||t==="bigmodel"?"glm":t==="minimax"?"minimax":"custom"}function mt(n){const t=(()=>{try{return new URL(n.baseURL).host.toLowerCase()}catch{return""}})();return t.includes("openrouter")?"openrouter":t.includes("anthropic")?"anthropic":t.includes("deepseek")?"deepseek":t.includes("googleapis")||t.includes("vertex")?"google":t.includes("openai.com")?"openai":t.includes("dashscope")||t.includes("qwen")||t.includes("aliyun")?"qwen":t.includes("volces")||t.includes("volcengine")||t.includes("doubao")?"doubao":t.includes("bigmodel")||t.includes("zhipu")||t.includes("z.ai")?"glm":t.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function Ne(n,t){const a=n.bindings[t];if(!a)return null;const s=n.profiles.find(l=>l.id===a);if(!s)return null;const o=n.providers.find(l=>l.id===s.providerId);return o?{profileId:s.id,providerId:o.id,providerName:o.name,providerBrand:mt(o),modelId:s.modelId,effort:s.effort||null}:null}function ft(n){return n==="zh-CN"?{defaultsTitle:"新会话默认值",defaultsHint:"决定新建对话默认走哪个智能体。具体模型与推理强度由该智能体卡片下的「供应商 / 模型 / 推理强度」决定。",defaultsEditTitle:"修改默认智能体",defaultsEditHint:"选择新建对话默认走哪个智能体。",defaultsSaved:"默认智能体已更新",editDefaults:"修改默认",agentsTitle:"可用智能体",defaultAgent:"默认智能体",installLabel:"安装状态",versionLabel:"版本",defaultBadge:"默认",installed:"已安装",notInstalled:"未安装",notInstalledHint:"安装该智能体的本地 CLI 后即可在此配置供应商与模型。",noModel:"未设置",noVersion:"版本未知",loadFailed:"无法加载智能体状态",updateAvailable:"有新版本",updateSkipped:"自动更新已跳过",updateFailed:"自动更新失败",update:"升级",updating:"升级中…",checkUpdate:"检查更新",checking:"检查中…",upToDate:"已是最新",install:"安装",installing:"安装中…",profilesHint:"把你常用的模型登记成一条条快捷方式,自由起别名。这是一份纯粹的选择列表——智能体(包括 Hermes)会从这里挑模型,但选了谁不会反向显示在这里。",profilesTitle:"我的模型",modelsTitle:"模型供应商",modelsHint:'接入 BYOK 供应商;接入后可在上方"我的模型"里挑选具体模型并固定下来。',localTitle:"本地模型",localHint:"在本机检测 Ollama / mlx-lm 并按内存推荐合适的开源模型;接入后会作为一个供应商出现在智能体卡片中。",rowProvider:"供应商",rowModel:"模型",rowEffort:"推理强度",providerNative:"官方(CLI 内置认证)",providerNativeFromAgent:"智能体自身配置",effortDefault:"默认",modelLoading:"正在拉取模型列表…",modelEmpty:"该供应商未返回模型列表,请使用自定义输入。",modelCustomToggle:"改为自定义输入",modelListToggle:"从列表选择",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"搜索模型",modelSearchEmpty:"没有匹配的模型",modelCurrentLabel:"当前",modelGroupNative:"官方",modelGroupProfiles:"我的模型",modelPickerEmpty:"没有可选模型",modelPickerEmptyHint:'该智能体的官方模型列表为空,且你还没有登记任何"我的模型"。',saveChanges:"保存",saving:"保存中…",saved:"已保存",configError:"保存失败",externalNativeNote:t=>`Hermes 当前从 ${t||"~/.hermes/config.yaml"} 读取这些值;切换为某个 BYOK 供应商可由 pikiclaw 接管。`,configure:"配置",configModalTitle:t=>`配置 ${t}`,rowSummaryNative:"官方认证",rowSummaryNoModel:"未选模型",rowSummaryNoEffort:"默认强度"}:{defaultsTitle:"New Session Defaults",defaultsHint:"Pick which agent new sessions use by default. Provider / Model / Effort live on each agent card below.",defaultsEditTitle:"Change Default Agent",defaultsEditHint:"Which agent should new sessions use by default?",defaultsSaved:"Default agent updated",editDefaults:"Change default",agentsTitle:"Available Agents",defaultAgent:"Default Agent",installLabel:"Install",versionLabel:"Version",defaultBadge:"Default",installed:"Installed",notInstalled:"Not installed",notInstalledHint:"Install the local CLI for this agent to configure its provider and model.",noModel:"Not set",noVersion:"Version unavailable",loadFailed:"Failed to load agent status",updateAvailable:"Update available",updateSkipped:"Auto-update skipped",updateFailed:"Auto-update failed",update:"Update",updating:"Updating…",checkUpdate:"Check update",checking:"Checking…",upToDate:"Up to date",install:"Install",installing:"Installing…",profilesTitle:"My Models",profilesHint:"Register the models you actually use as named shortcuts. A pure selection list — agents (including Hermes) pick from here, but who picks what does not bubble back into this view.",modelsTitle:"Model Providers",modelsHint:'Connect BYOK providers; pin specific models above in "My Models".',localTitle:"Local Models",localHint:"Detect Ollama / mlx-lm on this machine and surface coding models that fit your RAM. Connected backends show up as a provider on the agent cards.",rowProvider:"Provider",rowModel:"Model",rowEffort:"Effort",providerNative:"Native (CLI auth)",providerNativeFromAgent:"agent's own config",effortDefault:"default",modelLoading:"Loading model list…",modelEmpty:"Provider returned no model list — use custom input.",modelCustomToggle:"Use custom input",modelListToggle:"Pick from list",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"Search models",modelSearchEmpty:"No matching models",modelCurrentLabel:"Current",modelGroupNative:"Native",modelGroupProfiles:"My Models",modelPickerEmpty:"No models available",modelPickerEmptyHint:'This agent has no native model list, and no "My Models" entries are registered.',saveChanges:"Save",saving:"Saving…",saved:"Saved",configError:"Save failed",externalNativeNote:t=>`Hermes reads these values from ${t||"~/.hermes/config.yaml"}; pick a BYOK provider to let pikiclaw take over.`,configure:"Configure",configModalTitle:t=>`Configure ${t}`,rowSummaryNative:"Native auth",rowSummaryNoModel:"No model",rowSummaryNoEffort:"Default effort"}}function pt(n,t){const a=n.filter(o=>o.installed);return(a.length?a:n).map(o=>({value:o.agent,label:`${Q(o.agent).label} · ${o.installed?o.version||t.installed:t.notInstalled}`}))}function ke(n,t){n({defaultAgent:t.defaultAgent,agents:t.agents})}function ht(n,t,a){if(a)return{kind:"profile",modelId:a.modelId,profileId:a.profileId,effort:a.effort||""};const s=t?.nativeConfig||null;return{kind:"native",modelId:s?.model||t?.selectedModel||"",profileId:null,effort:s?.effort||t?.selectedEffort||""}}function xt(n,t){return n.kind===t.kind&&(n.profileId||"")===(t.profileId||"")&&n.modelId.trim()===t.modelId.trim()&&(n.effort||"")===(t.effort||"")}function gt(n){return n.kind==="profile"&&n.profileId?`p:${n.profileId}`:`n:${n.modelId}`}function vt(n){return n.startsWith("n:")?{kind:"native",modelId:n.slice(2)}:n.startsWith("p:")?{kind:"profile",profileId:n.slice(2)}:null}function bt({agentId:n,agentStatus:t,boundInfo:a,copy:s,layer:o,toast:l,onSaved:d,onCancel:w,t:u}){const i=ct(n),g=t.nativeConfig||null,f=r.useMemo(()=>ht(n,t,a),[n,t,a]),[j,p]=r.useState(f),[C,E]=r.useState(!1),[A,L]=r.useState(null);r.useEffect(()=>{p(f),L(null)},[f]);const x=j.kind==="native"&&i,N=r.useMemo(()=>{const b=he[n]||he.claude;return[{value:"",label:s.effortDefault},...b.map(c=>({value:c,label:c}))]},[n,s.effortDefault]),R=r.useMemo(()=>{const b=[];if(!i)for(const v of t.models){const S=v.alias?.toLowerCase().replace(/[\s_-]/g,""),P=v.id.toLowerCase().replace(/[\s_-]/g,""),D=v.alias&&S!==P;b.push({value:`n:${v.id}`,label:v.id,description:D?v.alias:void 0,group:s.modelGroupNative})}const c=new Set(Be[n]||[]);for(const v of o.profiles){const S=o.providers.find(Z=>Z.id===v.providerId);if(!S||!c.has(S.kind))continue;const P=S.name,U=v.name.trim().toLowerCase()!==v.modelId.trim().toLowerCase()?`${P} · ${v.modelId}`:P;b.push({value:`p:${v.id}`,label:v.name,description:U,group:s.modelGroupProfiles})}return b},[n,t.models,o.profiles,o.providers,s.modelGroupNative,s.modelGroupProfiles,i]),y=gt(j),h=r.useCallback(b=>{const c=vt(b);if(c)if(c.kind==="native")p(v=>({...v,kind:"native",modelId:c.modelId,profileId:null,effort:v.kind==="profile"?t.nativeSelectedEffort||t.nativeConfig?.effort||"":v.effort}));else{const v=o.profiles.find(S=>S.id===c.profileId);p(S=>({...S,kind:"profile",profileId:c.profileId,modelId:v?.modelId||S.modelId,effort:v?.effort||S.effort}))}},[o.profiles,t.nativeSelectedEffort,t.nativeConfig]),B=!xt(j,f),z=!C&&B&&(x||!!j.modelId.trim()||j.kind==="profile"),m=r.useCallback(async()=>{L(null),E(!0);try{const b=j.effort||null;if(j.kind==="native"){if(o.bindings[n]&&await o.setActiveProfile(n,null),!i){const c={agent:n},v=j.modelId.trim();if(v&&v!==(t.nativeSelectedModel||"")&&(c.model=v),b!==(t.nativeSelectedEffort||null)&&(c.effort=b),Object.keys(c).length>1){const S=await V.updateRuntimeAgent(c);if(!S.ok)throw new Error(S.error||"Failed to update agent")}}}else{if(!j.profileId)throw new Error("No profile selected");if(await o.setActiveProfile(n,j.profileId),b!==(t.selectedEffort||null)){const c=await V.updateRuntimeAgent({agent:n,effort:b});if(!c.ok)throw new Error(c.error||"Failed to update agent")}}await Promise.resolve(d()),l(s.saved)}catch(b){const c=b?.message||String(b);L(c),l(`${s.configError}: ${c}`,!1)}finally{E(!1)}},[n,t,s,j,i,o,d,l]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{children:[e.jsx(H,{className:"!mb-1 text-[11px]",children:s.rowModel}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"truncate font-mono",children:g?.model||s.noModel})}):R.length===0?e.jsxs("div",{className:"rounded-md border border-edge bg-panel-alt px-3 py-3",children:[e.jsx("div",{className:"text-[12px] font-medium text-fg-3",children:s.modelPickerEmpty}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-fg-5",children:s.modelPickerEmptyHint})]}):e.jsx(we,{value:y,options:R,onChange:h,placeholder:"—",searchPlaceholder:s.modelSearchPlaceholder,noMatchesText:s.modelSearchEmpty,currentLabel:s.modelCurrentLabel})]}),e.jsxs("div",{children:[e.jsx(H,{className:"!mb-1 text-[11px]",children:s.rowEffort}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"font-mono",children:g?.effort||s.effortDefault})}):e.jsx(q,{value:j.effort,options:N,onChange:b=>p(c=>({...c,effort:b}))})]})]}),x&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:s.externalNativeNote(g?.configPath||"")}),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.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:w,disabled:C,children:u("modal.cancel")}),e.jsxs(_,{variant:"primary",size:"sm",disabled:!z,onClick:()=>{m()},children:[C&&e.jsx(G,{className:"h-3 w-3"}),C?s.saving:s.saveChanges]})]})]})}function jt(n,t,a){if(t)return{providerBrand:t.providerBrand,providerLabel:t.providerName,modelText:t.modelId||a.rowSummaryNoModel,effortText:t.effort||a.rowSummaryNoEffort};const s=n.nativeConfig||null,o=s?.provider||null;return{providerBrand:ut(o),providerLabel:a.rowSummaryNative,modelText:n.nativeSelectedModel||s?.model||n.selectedModel||a.rowSummaryNoModel,effortText:n.nativeSelectedEffort||s?.effort||n.selectedEffort||a.rowSummaryNoEffort}}function Nt({agent:n,copy:t,t:a,installing:s,onInstall:o,updatingAgent:l,checkingAgent:d,onUpdate:w,onCheckUpdate:u,onEdit:i,loading:g=!1,boundInfo:f}){const j=Q(n.agent),p=j.advantageKey?a(j.advantageKey):"",C=n.installed?jt(n,f,t):null;return e.jsxs("div",{className:"glass rounded-md border border-edge px-3.5 py-2.5 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",title:p||void 0,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(Y,{brand:n.agent,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[14px] font-semibold tracking-tight text-fg",children:j.label}),n.isDefault&&e.jsx(O,{variant:"accent",children:t.defaultBadge}),g?e.jsxs(O,{variant:"muted",children:[e.jsx(G,{className:"h-3 w-3"})," ",a("status.loading")]}):n.installed?e.jsx(O,{variant:"ok",children:t.installed}):e.jsx(O,{variant:"muted",children:t.notInstalled}),n.installed&&n.updateAvailable&&e.jsx(O,{variant:"warn",children:t.updateAvailable}),n.installed&&n.version&&e.jsxs("span",{className:"text-[11px] font-mono text-fg-5",children:["v",n.version]}),n.latestVersion&&n.updateAvailable&&e.jsxs("span",{className:"text-[11px] text-amber-400",children:["→ ",n.latestVersion]})]}),C?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Y,{brand:C.providerBrand,size:11}),e.jsx("span",{className:"text-fg-3",children:C.providerLabel})]}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-mono text-fg-3",children:C.modelText}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{children:C.effortText})]}):p?e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-fg-5",children:p}):null]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[g&&e.jsx("div",{className:"inline-flex h-7 items-center gap-2 px-2 text-[11px] text-fg-5",children:e.jsx(G,{className:"h-3 w-3"})}),!g&&!n.installed&&e.jsx(_,{variant:"primary",size:"sm",disabled:s,onClick:()=>o(n),children:s?t.installing:t.install}),!g&&n.installed&&n.updateAvailable&&e.jsx(_,{variant:"outline",size:"sm",disabled:l,onClick:()=>w(n),children:l?t.updating:t.update}),!g&&n.installed&&!n.updateAvailable&&e.jsx(_,{variant:"ghost",size:"icon",disabled:d,onClick:()=>u(n),title:t.checkUpdate,"aria-label":t.checkUpdate,className:"h-7 w-7",children:d?e.jsx(G,{className:"h-3 w-3"}):e.jsx("span",{"aria-hidden":"true",children:"↻"})}),!g&&n.installed&&e.jsx(_,{variant:"outline",size:"sm",onClick:()=>i(n),children:t.configure})]})]}),!g&&n.installed&&n.updateAvailable&&n.updateStatus==="skipped"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-warn-text)"},children:[t.updateSkipped,": ",n.updateDetail]}),!g&&n.installed&&n.updateStatus==="failed"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-err-text)"},children:[t.updateFailed,": ",n.updateDetail]})]})}function At(){const n=$(k=>k.locale),t=$(k=>k.toast),a=$(k=>k.agentStatus),s=$(k=>k.setAgentStatus),o=$(k=>k.refreshAgentStatus),l=r.useMemo(()=>De(n),[n]),d=r.useMemo(()=>ft(n),[n]),w=Me(),u=Ce(),[i,g]=r.useState(a?{defaultAgent:a.defaultAgent,agents:a.agents}:null),[f,j]=r.useState(!a),[p,C]=r.useState(null),[E,A]=r.useState(!1),[L,M]=r.useState(null),[x,N]=r.useState(!1),[R,y]=r.useState("codex"),[h,B]=r.useState(null),[z,m]=r.useState(null),[b,c]=r.useState(null),v=r.useRef(!!a);r.useEffect(()=>{a&&(ke(g,a),v.current||(v.current=!0,j(!1)))},[a]);const S=r.useCallback(k=>{ke(g,k),s(k)},[s]),P=r.useCallback(async()=>{v.current||j(!0);try{const k=await V.getAgentStatus();return S(k),C(null),v.current=!0,k}catch(k){const I=k instanceof Error?k.message:d.loadFailed;return C(I),v.current||t(I,!1),null}finally{j(!1)}},[S,d.loadFailed,t]);r.useEffect(()=>{a?o():P()},[]);const D=r.useMemo(()=>{const k=i?.agents||[],I=new Map(k.map(T=>[T.agent,T]));return ot.map(T=>{const pe=I.get(T);if(pe)return pe;const He=Q(T);return{agent:T,label:He.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:i?.defaultAgent===T,models:[],usage:null}})},[i]),U=i?.defaultAgent||"codex",Z=D.find(k=>k.agent===U)||null,ue=D.filter(k=>k.installed).length>0,Se=pt(D,d),me=r.useCallback(async k=>{A(!0);try{const I=await V.updateRuntimeAgent(k);if(!I.ok)throw new Error(I.error||l("config.applyFailed"));return S(I),I}catch(I){const T=I instanceof Error?I.message:l("config.applyFailed");return t(T,!1),P(),null}finally{A(!1)}},[S,P,l,t]);r.useEffect(()=>{x&&y(U)},[U,x]);const Ae=r.useCallback(async()=>{if(R===U){N(!1);return}await me({defaultAgent:R})&&(t(d.defaultsSaved),N(!1))},[d.defaultsSaved,U,R,t,me]),Le=r.useCallback(async k=>{if(!L){M(k.agent);try{const I=await V.installAgent(k.agent);if(!I.ok)throw new Error(I.error||l("config.agentInstallFailed"));S(I),t(l("config.agentInstalled"))}catch(I){const T=I instanceof Error?I.message:l("config.agentInstallFailed");t(T,!1),P()}finally{M(I=>I===k.agent?null:I)}}},[S,L,P,l,t]),Re=r.useCallback(async k=>{if(!h){B(k.agent);try{const I=await V.updateAgent(k.agent);if(!I.ok)throw new Error(I.error||l("config.agentInstallFailed"));S(I),t(d.upToDate)}catch(I){const T=I instanceof Error?I.message:d.updateFailed;t(T,!1),P()}finally{B(I=>I===k.agent?null:I)}}},[S,d.updateFailed,d.upToDate,P,l,t,h]),Pe=r.useCallback(async k=>{if(!z){m(k.agent);try{const I=await V.checkAgentUpdate(k.agent);if(!I.ok)throw new Error(I.error||d.loadFailed);S(I)}catch(I){const T=I instanceof Error?I.message:d.loadFailed;t(T,!1),P()}finally{m(I=>I===k.agent?null:I)}}},[S,z,d.loadFailed,P,t]),ne=f&&!i,Te=ne?l("status.loading"):Z?Q(Z.agent).label:d.notInstalled;ne?l("status.loading"):Z?.installed?d.installed:d.notInstalled;const fe=r.useCallback(async()=>{await w.reload(),await P()},[w,P]),W=b?D.find(k=>k.agent===b)??null:null,ae=W?Q(W.agent):null;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),ne?e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-5",children:[e.jsx(G,{className:"h-3 w-3"}),e.jsx("span",{children:d.defaultAgent})]}):e.jsxs("button",{type:"button",onClick:()=>N(!0),disabled:E||!ue,title:d.editDefaults,className:"group inline-flex items-center gap-1.5 rounded-full border border-edge bg-panel-alt px-3 py-1 text-[12px] transition hover:border-edge-strong hover:bg-panel disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"text-fg-5 group-hover:text-fg-4",children:d.defaultAgent}),e.jsx(Y,{brand:U,size:14}),e.jsx("span",{className:"font-semibold text-fg-2",children:Te}),e.jsx("svg",{className:"text-fg-6 transition group-hover:text-fg-3",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-2",children:D.map(k=>e.jsx(Nt,{agent:k,copy:d,t:l,installing:L===k.agent,loading:ne,onInstall:Le,updatingAgent:h===k.agent,checkingAgent:z===k.agent,onUpdate:Re,onCheckUpdate:Pe,onEdit:I=>c(I.agent),boundInfo:Ne(w,k.agent)},k.agent))})]}),p&&e.jsx(Ue,{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:p}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>{P()},children:l("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.profilesTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.profilesHint})]})}),e.jsx(dt,{snapshot:w})]}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.modelsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.modelsHint})]})}),e.jsx(Ke,{snapshot:w,localBackends:u.backends})]}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.localTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.localHint})]})}),e.jsx(tt,{snapshot:u,onConnected:fe})]}),e.jsx(ee,{open:!!W,onClose:()=>c(null),wide:!0,children:W&&ae&&e.jsxs(e.Fragment,{children:[e.jsx(te,{title:d.configModalTitle(ae.label),description:ae.advantageKey?l(ae.advantageKey):void 0,onClose:()=>c(null)}),e.jsx(bt,{agentId:W.agent,agentStatus:W,boundInfo:Ne(w,W.agent),copy:d,layer:w,toast:t,t:l,onSaved:async()=>{await fe(),c(null)},onCancel:()=>c(null)})]})}),e.jsxs(ee,{open:x,onClose:()=>N(!1),children:[e.jsx(te,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>N(!1)}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(H,{children:d.defaultAgent}),e.jsx(q,{value:R,options:Se,onChange:k=>y(k),disabled:E||!ue,placeholder:d.notInstalled})]})}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(_,{variant:"ghost",onClick:()=>N(!1),children:l("modal.cancel")}),e.jsx(_,{variant:"primary",disabled:E||R===U,onClick:()=>{Ae()},children:l(E?"config.validating":"modal.save")})]})]})]})}export{At as AgentTab,At as default};
|
|
1
|
+
import{r,j as e,b as Oe}from"./react-vendor-DTcmqLiz.js";import{c as F,u as $,a as V,B as _,S as G,k as O,b as De,g as Q,E as he,A as Be}from"./index-6-_orDYi.js";import{B as Y}from"./BrandIcon-10Ai0NRI.js";import{M as ee,a as te,L as H,I as K}from"./Modal-Dky9qH2d.js";import{S as q}from"./Select-DI_biurT.js";import{A as ce,S as Ue}from"./shared-DXfu2khL.js";import"./router-Cav8lq-m.js";function xe(n,t){return!!(n&&t instanceof Node&&n.contains(t))}function _e(n,t){if(t.length===0)return!0;const a=`${n.label} ${n.description||""} ${n.meta||""}`.toLowerCase();return t.every(s=>a.includes(s))}function we({value:n,options:t,onChange:a,className:s,placeholder:o="—",disabled:l=!1,searchPlaceholder:d="Search models...",noMatchesText:w="No matches",currentLabel:u="Current"}){const i=t.find(m=>m.value===n),g=t.length<=1,[f,j]=r.useState(!1),[p,C]=r.useState(""),[E,A]=r.useState(null),L=r.useRef(null),M=r.useRef(null),x=r.useRef(null);r.useEffect(()=>{if(!f)return;const m=c=>{xe(L.current,c.target)||xe(M.current,c.target)||j(!1)},b=c=>{c.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b)}},[f]),r.useEffect(()=>{f||C("")},[f]),r.useEffect(()=>{if(f){const m=window.setTimeout(()=>x.current?.focus(),0);return()=>window.clearTimeout(m)}},[f]),r.useLayoutEffect(()=>{if(!f)return;const m=()=>{const b=L.current;if(!b)return;const c=b.getBoundingClientRect(),S=window.innerHeight-c.bottom-12,P=c.top-12,D=S<280&&P>S,U=Math.max(220,Math.min(360,D?P:S));A({left:c.left,top:D?Math.max(12,c.top-U-8):c.bottom+8,width:c.width,maxHeight:U})};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[f]);const N=r.useMemo(()=>p.trim().toLowerCase().split(/\s+/).filter(Boolean),[p]),R=r.useMemo(()=>t.filter(m=>m.value!==n&&_e(m,N)),[t,n,N]);if(g)return e.jsx("div",{className:F("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",l&&"cursor-not-allowed",s),children:e.jsx("span",{className:F("truncate",!i&&"text-fg-6"),children:i?.label||o})});const y=m=>{l||(a(m),j(!1))},h=(m,b)=>e.jsxs("button",{type:"button",role:"option","aria-selected":b,onClick:()=>y(m.value),className:F("flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",b?"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.jsxs("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:m.label}),m.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:m.meta})]}),m.description&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-relaxed text-fg-5",children:m.description})]}),b&&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"})})]},m.value),B=m=>{const b=[];let c;for(const v of m)v.group&&v.group!==c?(b.push(e.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:v.group},`__group:${v.group}`)),c=v.group):v.group||(c=void 0),b.push(h(v,!1));return b},z=f&&E?Oe.createPortal(e.jsxs("div",{ref:M,role:"listbox",className:"fixed z-[220] flex flex-col overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:E.left,top:E.top,width:E.width,maxHeight:E.maxHeight},children:[e.jsxs("div",{className:"relative px-1.5 pt-1 pb-2",children:[e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-3.5 flex items-center text-fg-5",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),e.jsx("input",{ref:x,type:"text",value:p,onChange:m=>C(m.target.value),placeholder:d,spellCheck:!1,autoComplete:"off",className:F("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:[i&&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:u}),h(i,!0),e.jsx("div",{className:"my-1.5 border-t border-edge"})]}),R.length>0?B(R):e.jsx("div",{className:"px-3 py-3 text-center text-[12px] text-fg-5",children:w})]})]}),document.body):null;return e.jsxs("div",{ref:L,className:F("relative",s),children:[e.jsxs("button",{type:"button",disabled:l,"aria-haspopup":"listbox","aria-expanded":f,onClick:()=>j(m=>!m),className:F("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",f&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:F("min-w-0 flex-1 truncate",!i&&"text-fg-5"),children:i?.label||o}),e.jsx("span",{className:F("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",f&&"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"})})})]}),z]})}const J=[{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 $e(n){return n==="zh-CN"?{sectionTitle:"模型供应商",sectionHint:"连接你自己的模型供应商,凭据加密存入系统 Keychain,可绑定到任意一个智能体。",addLabel:"接入新供应商",validate:"校验",validating:"校验中",edit:"编辑",remove:"删除",removeConfirm:"删除该供应商?已绑定的智能体会自动恢复为官方 Auth。",unbound:"尚未被任何智能体使用",boundOne:"已绑定",boundN:t=>`${t} 个智能体在用`,notConnected:"未接入",modalAddTitle:"接入模型供应商",modalAddHint:t=>t?`已套用 ${t} 模板,仅需粘贴 API Key。`:"填入端点和凭据,保存后即可在智能体卡片上选用。",modalEditTitle:"编辑供应商配置",modalEditHint:"修改端点、凭据或模型参数。修改凭据会清空已校验状态。",fieldName:"配置名称",fieldNamePlaceholder:"例如:OpenRouter · 个人",fieldKind:"API 类型",fieldBaseURL:"Base URL",fieldCredentialSource:"凭据来源",fieldApiKey:"API Key",fieldApiKeyHint:"通过 @napi-rs/keyring 写入系统 Keychain,setting.json 仅保存引用。",fieldEnvVar:"环境变量名",fieldCommand:"获取命令(执行结果作为 key)",fieldModelId:"模型 ID",fieldEffort:"推理强度",fieldEffortHelp:"可用范围由模型决定,留空表示沿用模型默认值。",effortHermesNote:"Hermes 当前从 ~/.hermes/config.yaml 读取推理强度,Profile 上的 effort 暂仅做记录。",credPaste:"粘贴 API Key(推荐,写入系统 Keychain)",credEnv:"从环境变量读取",credCommand:"运行命令获取(1Password / pass / gh 等)",effortDefault:"(沿用默认)",cancel:"取消",save:"保存",saving:"保存中",validationReady:"已就绪",validationInvalid:"凭据无效",validationError:"网络/服务错误",validationUnvalidated:"未校验",providerOnlyHint:"保存后回到智能体卡片,点击「BYOK」选择具体的模型与推理强度。",credentialLabel:"凭据",modelsAvailable:t=>`可用 ${t} 个模型`}:{sectionTitle:"Model Providers",sectionHint:"Connect your own model providers. Keys are encrypted in the OS keychain and can be bound to any agent.",addLabel:"Add provider",validate:"Validate",validating:"Validating",edit:"Edit",remove:"Remove",removeConfirm:"Remove this provider? Bound agents will fall back to native auth.",unbound:"Not used by any agent yet",boundOne:"Bound to",boundN:t=>`${t} agents in use`,notConnected:"Not connected",modalAddTitle:"Connect Model Provider",modalAddHint:t=>t?`Pre-filled from the ${t} template — just paste your API key.`:"Enter endpoint and credential. After saving, choose models on the agent cards above.",modalEditTitle:"Edit Provider",modalEditHint:"Update the endpoint, credential, or model. Changing the credential clears the validated state.",fieldName:"Display name",fieldNamePlaceholder:"e.g. OpenRouter · Personal",fieldKind:"API kind",fieldBaseURL:"Base URL",fieldCredentialSource:"Credential source",fieldApiKey:"API key",fieldApiKeyHint:"Stored in the OS keychain via @napi-rs/keyring; setting.json keeps only a reference.",fieldEnvVar:"Environment variable name",fieldCommand:"Command (stdout becomes the key)",fieldModelId:"Model ID",fieldEffort:"Reasoning effort",fieldEffortHelp:"Available values depend on the chosen model; leave blank to use the default.",effortHermesNote:"Hermes currently reads reasoning_effort from ~/.hermes/config.yaml; Profile.effort is recorded only for now.",credPaste:"Paste API key (recommended — stored in OS keychain)",credEnv:"Read from environment variable",credCommand:"Run a command (1Password / pass / gh, …)",effortDefault:"(default)",cancel:"Cancel",save:"Save",saving:"Saving",validationReady:"Ready",validationInvalid:"Invalid",validationError:"Error",validationUnvalidated:"Not validated",providerOnlyHint:'After saving, head back to an agent card and click "BYOK" to choose the model and effort.',credentialLabel:"Credential",modelsAvailable:t=>`${t} models available`}}const se={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 ge(n,t){return t==="zh-CN"?se[n].zh:se[n].en}async function le(n){return(await fetch(n)).json()}async function X(n,t,a){return(await fetch(t,{method:n,headers:{"Content-Type":"application/json"},body:a?JSON.stringify(a):void 0})).json()}function Ie(n){const t=(()=>{try{return new URL(n.baseURL)}catch{return null}})(),a=t?.host.toLowerCase()??"",s=t?.port??"";return(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="11434"?"ollama":(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="8080"?"mlx":a.includes("openrouter")?"openrouter":a.includes("anthropic")?"anthropic":a.includes("deepseek")?"deepseek":a.includes("googleapis")||a.includes("vertex")?"google":a.includes("openai.com")?"openai":a.includes("dashscope")||a.includes("qwen")||a.includes("aliyun")?"qwen":a.includes("volces")||a.includes("volcengine")||a.includes("doubao")?"doubao":a.includes("bigmodel")||a.includes("zhipu")||a.includes("z.ai")?"glm":a.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function ze({desc:n,copy:t,locale:a,onPick:s}){const{provider:o,template:l}=n,d=!!o,w=o?Ie(o):l?.id??"custom",u=o?.name??(l?a==="zh-CN"?l.name.zh:l.name.en:""),i=l?a==="zh-CN"?l.blurb.zh:l.blurb.en:"",g=o?.validation?.state??null,f=o?.validation?.modelCount;let j=null,p="";o&&(g==="ready"?(j="bg-emerald-500",p=f!=null?t.modelsAvailable(f):t.validationReady):g==="invalid"?(j="bg-rose-500",p=t.validationInvalid):g==="error"?(j="bg-amber-500",p=t.validationError):(j="bg-fg-6",p=t.validationUnvalidated));const C=d&&o.validation?.detail&&g!=="ready"?o.validation.detail:i;return e.jsxs("button",{type:"button",onClick:()=>s(n),className:"group relative flex h-[68px] items-center gap-2.5 rounded-lg border border-edge bg-panel-alt px-3 py-2 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsx(Y,{brand:w,size:26}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[j&&e.jsx("span",{className:F("inline-block h-[6px] w-[6px] shrink-0 rounded-full",j),title:p}),e.jsx("span",{className:"truncate text-[13px] font-semibold tracking-tight text-fg",children:u})]}),C&&e.jsx("div",{className:"truncate text-[11px] leading-snug text-fg-5",title:C,children:C})]}),g==="ready"&&f!=null&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] text-fg-5",title:t.modelsAvailable(f),children:f})]})}function ie(n,t){return{name:t==="zh-CN"?`${n.name.zh}`:`${n.name.en}`,kind:n.kind,baseURL:n.baseURL,credMode:"paste",apiKey:"",envVar:n.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}}function Fe({open:n,copy:t,locale:a,initial:s,initialTemplateName:o,existingProvider:l,onClose:d,onSaved:w,onRemove:u}){const[i,g]=r.useState(()=>s||ie(J[0],a)),[f,j]=r.useState(!1),[p,C]=r.useState(null);r.useEffect(()=>{n&&(g(s||ie(J[0],a)),C(null))},[n,s,a]);const E=!!l,A=!!o||E,L=r.useCallback(async()=>{C(null),j(!0);try{const x=i.credMode==="env"?{source:"env",varName:i.envVar.trim()}:i.credMode==="command"?{source:"command",argv:i.cmdLine.trim().split(/\s+/).filter(Boolean)}:null;let N;if(E&&l){const y={name:i.name.trim()||l.name,baseURL:i.baseURL.trim()};i.credMode==="paste"&&i.apiKey?y.apiKey=i.apiKey:x&&(y.credentialRef=x);const h=await X("PATCH",`/api/models/providers/${l.id}`,y);if(!h.ok){C(h.error||"Failed to update provider");return}N=l.id}else{const y={kind:i.kind,name:i.name.trim()||`${ge(i.kind,a)}`,baseURL:i.baseURL.trim()};i.credMode==="paste"?y.apiKey=i.apiKey:x&&(y.credentialRef=x);const h=await X("POST","/api/models/providers",y);if(!h.ok||!h.provider){C(h.error||"Failed to create provider");return}N=h.provider.id}const R=await X("POST",`/api/models/providers/${N}/validate`);if(w(),R.validation&&R.validation.state!=="ready"){C(`${t.validationInvalid}: ${R.validation.detail}`);return}d()}catch(x){C(x?.message||String(x))}finally{j(!1)}},[i,E,l,a,w,d,t.validationInvalid]),M=!f&&i.name.trim().length>0&&i.baseURL.trim().length>0&&(i.credMode!=="paste"||(E?!0:i.apiKey.length>0))&&(i.credMode!=="env"||i.envVar.trim().length>0)&&(i.credMode!=="command"||i.cmdLine.trim().length>0);return e.jsxs(ee,{open:n,onClose:d,children:[e.jsx(te,{title:E?t.modalEditTitle:t.modalAddTitle,description:E?t.modalEditHint:t.modalAddHint(o||null),onClose:d}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldName}),e.jsx(K,{value:i.name,onChange:x=>g(N=>({...N,name:x.target.value})),placeholder:t.fieldNamePlaceholder})]}),A?e.jsxs("div",{children:[e.jsx(H,{children:t.fieldBaseURL}),e.jsx(K,{value:i.baseURL,onChange:x=>g(N=>({...N,baseURL:x.target.value})),placeholder:"https://…"})]}):e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldKind}),e.jsx(q,{value:i.kind,options:Object.keys(se).map(x=>({value:x,label:ge(x,a)})),onChange:x=>g(N=>({...N,kind:x}))})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldBaseURL}),e.jsx(K,{value:i.baseURL,onChange:x=>g(N=>({...N,baseURL:x.target.value})),placeholder:"https://…"})]})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldCredentialSource}),e.jsx(q,{value:i.credMode,options:[{value:"paste",label:t.credPaste},{value:"env",label:t.credEnv},{value:"command",label:t.credCommand}],onChange:x=>g(N=>({...N,credMode:x}))})]}),i.credMode==="paste"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldApiKey}),e.jsx(K,{type:"password",value:i.apiKey,onChange:x=>g(N=>({...N,apiKey:x.target.value})),placeholder:E?"••••••••":"sk-…"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldApiKeyHint})]}),i.credMode==="env"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldEnvVar}),e.jsx(K,{value:i.envVar,onChange:x=>g(N=>({...N,envVar:x.target.value})),placeholder:"OPENROUTER_API_KEY"})]}),i.credMode==="command"&&e.jsxs("div",{children:[e.jsx(H,{children:t.fieldCommand}),e.jsx(K,{value:i.cmdLine,onChange:x=>g(N=>({...N,cmdLine:x.target.value})),placeholder:"op read op://Personal/OpenRouter/key"})]}),p&&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:p})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-2 border-t border-edge pt-4",children:[e.jsx("div",{children:E&&u&&e.jsx("button",{type:"button",onClick:()=>{u()},className:"text-[12px] text-fg-5 transition hover:text-[var(--th-err)]",children:t.remove})}),e.jsx(ce,{primary:{label:f?t.saving:t.save,onClick:L,disabled:!M},secondary:{label:t.cancel,onClick:d}})]})]})}function Me(){const[n,t]=r.useState([]),[a,s]=r.useState([]),[o,l]=r.useState({}),d=r.useCallback(async()=>{const[u,i,g]=await Promise.all([le("/api/models/providers"),le("/api/models/profiles"),le("/api/models/agents")]);t(u.providers||[]),s(i.profiles||[]);const f={};for(const j of g.bindings||[])f[j.agent]=j.activeProfileId;l(f)},[]),w=r.useCallback(async(u,i)=>{await X("POST",`/api/models/agents/${u}/active`,{profileId:i}),await d()},[d]);return r.useEffect(()=>{d()},[d]),{providers:n,profiles:a,bindings:o,reload:d,setActiveProfile:w}}function ve(n){return n.replace(/\/+$/,"").replace(/^http:\/\/localhost(?=[:/]|$)/i,"http://127.0.0.1").replace(/^https:\/\/localhost(?=[:/]|$)/i,"https://127.0.0.1")}function be(n,t){const a=ve(n.baseURL);return t.some(s=>ve(s.openAIBaseURL)===a)}function Ke({snapshot:n,localBackends:t}={}){const a=Me(),s=n??a,{providers:o,reload:l}=s,d=t??[],w=$(M=>M.locale),u=r.useMemo(()=>$e(w),[w]);$(M=>M.toast);const[i,g]=r.useState(null),f=r.useCallback(async M=>{confirm(u.removeConfirm)&&(await X("DELETE",`/api/models/providers/${M.id}`),await l())},[u,l]),j=r.useMemo(()=>{if(!i||i.kind!=="edit")return null;const{provider:M}=i;return{name:M.name,kind:M.kind,baseURL:M.baseURL,credMode:"paste",apiKey:"",envVar:J.find(x=>x.kind===M.kind)?.envVar||"API_KEY",cmdLine:"op read op://Personal/Provider/key"}},[i]),p=r.useMemo(()=>!i||i.kind!=="add"?null:ie(i.template,w),[i,w]),C=i&&i.kind==="add"&&i.template.id!=="custom"?w==="zh-CN"?i.template.name.zh:i.template.name.en:null,E=r.useMemo(()=>{const M=new Map;for(const x of o){const N=Ie(x);M.has(N)||M.set(N,x)}return M},[o]),A=r.useMemo(()=>{const M=o.filter(y=>!be(y,d)),x=new Set,N=[];for(const y of J){if(y.id==="custom")continue;const h=E.get(y.id);h&&!be(h,d)?(x.add(h.id),N.push({template:y,provider:h})):N.push({template:y})}for(const y of M)x.has(y.id)||N.push({provider:y});const R=J.find(y=>y.id==="custom");return R&&N.push({template:R}),N},[o,E,d]),L=r.useCallback(M=>{if(M.provider){g({kind:"edit",provider:M.provider});return}M.template&&g({kind:"add",template:M.template})},[]);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:A.map((M,x)=>e.jsx(ze,{desc:M,copy:u,locale:w,onPick:L},M.provider?.id??`tpl-${M.template?.id??x}`))}),i&&e.jsx(Fe,{open:!0,copy:u,locale:w,initial:i.kind==="edit"?j:p,initialTemplateName:C,existingProvider:i.kind==="edit"?i.provider:void 0,onClose:()=>g(null),onSaved:l,onRemove:i.kind==="edit"?async()=>{await f(i.provider),g(null)}:void 0})]})}const Ve=4;function Ge(n){return n==="zh-CN"?{sectionLabel:"本地后端",hostLabel:"本机",hostUnknown:"检测中…",refresh:"刷新",refreshing:"刷新中…",loadFailed:"加载失败",tileStatusDetected:"已运行",tileStatusNotDetected:"未检测到",tileStatusUnsupported:"不支持当前系统",tileBadgeReady:t=>`${t} 个模型已就绪`,tileBlurbOllama:"跨平台默认,CLI 友好,模型下载到本地后常驻",tileBlurbMlx:"Apple Silicon 原生,性能压榨极限,按需启动",tileInstalledModels:t=>`${t} 个模型`,modalTitle:t=>`准备 ${t}`,modalDescription:t=>`安装 ${t}、下载所需模型、核对运行状态——本地模型的全部配置都在这里完成。`,stepStatus:"后端状态",stepModels:"模型",statusRunning:"已运行",statusNotRunning:"未在本机检测到此后端",statusUnsupportedDesc:t=>`${t} 不支持当前系统。`,statusRecheck:"重新检测",statusRechecking:"检测中…",statusInstallHeader:"安装命令",statusInstallDocs:"官方安装文档",statusRunHint:"启动服务(安装后)",statusHomepageCta:"官网",statusAutoAttachedHint:t=>`本地 ${t} 已在运行;继续在下方下载并核对所需模型。`,modelsInstalledHeader:t=>`已就绪(${t})`,modelsInstalledEmpty:"后端在线,但尚未加载任何模型。在终端按下方命令准备一个。",modelsRecommendedHeader:"推荐模型 · 在终端执行以下命令准备",modelsBackendOffline:"启动后端后再返回此处准备模型。",fitOk:"推荐",fitTight:"勉强可跑",fitNoGo:"内存不足",modelInstalledBadge:"已就绪",pullPrefix:"终端执行",copyCommand:"复制",copied:"已复制",closeBtn:"完成"}:{sectionLabel:"Local backends",hostLabel:"This machine",hostUnknown:"Detecting…",refresh:"Refresh",refreshing:"Refreshing…",loadFailed:"Failed to load local backends",tileStatusDetected:"Running",tileStatusNotDetected:"Not detected",tileStatusUnsupported:"Not supported on this OS",tileBadgeReady:t=>`${t} models ready`,tileBlurbOllama:"Cross-platform default, CLI-friendly, models persist on disk",tileBlurbMlx:"Apple Silicon native, peak performance, on-demand launch",tileInstalledModels:t=>`${t} models`,modalTitle:t=>`Prepare ${t}`,modalDescription:t=>`Install ${t}, download the models you want, and verify they're running — all the local-model configuration lives in this panel.`,stepStatus:"Backend status",stepModels:"Models",statusRunning:"Running",statusNotRunning:"Backend not detected on this machine",statusUnsupportedDesc:t=>`${t} does not run on this OS.`,statusRecheck:"Re-check",statusRechecking:"Checking…",statusInstallHeader:"Install commands",statusInstallDocs:"Official install docs",statusRunHint:"Start the server (after install)",statusHomepageCta:"Homepage",statusAutoAttachedHint:t=>`Local ${t} is running. Continue below to download and verify the models you need.`,modelsInstalledHeader:t=>`Ready (${t})`,modelsInstalledEmpty:"Backend is up but no model is loaded. Use the command below to prepare one.",modelsRecommendedHeader:"Recommended models — run these in your terminal",modelsBackendOffline:"Start the backend first, then come back to prepare models.",fitOk:"Recommended",fitTight:"Tight fit",fitNoGo:"Not enough RAM",modelInstalledBadge:"Ready",pullPrefix:"Run in terminal",copyCommand:"Copy",copied:"Copied",closeBtn:"Done"}}function re(n,t){return n===null?"tight":n>=t+Ve?"ok":n>=t?"tight":"no-go"}function Ye(n,t){const a=n.id==="ollama"?t.ollamaTag:t.mlxModel;return a?n.pullCommandTemplate.replace("${model}",a):null}function We(n){return!n||!Number.isFinite(n)?"—":`${(n/1024**3).toFixed(0)} GB`}function qe(n){if(!n||!Number.isFinite(n))return"";const t=n/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(n/1024**2).toFixed(0)} MB`}function Ze(n,t){return t.filter(a=>n.id==="ollama"?!!a.ollamaTag:!!a.mlxModel)}function de(n,t){const a=t.id==="ollama"?n.ollamaTag:n.mlxModel;if(!a)return null;const s=a.split(":")[0].toLowerCase();for(const o of t.models)if(o.id.toLowerCase().startsWith(s))return o.id;return null}function Ce(){const[n,t]=r.useState([]),[a,s]=r.useState([]),[o,l]=r.useState(null),[d,w]=r.useState(!0),[u,i]=r.useState(null),g=r.useCallback(async()=>{w(!0),i(null);try{const f=await V.probeLocalModels();if(!f.ok)throw new Error(f.error||"Failed to load local backends");return t(f.backends||[]),s(f.catalog||[]),l(f.currentOs??null),{addedProviderIds:f.addedProviderIds??[]}}catch(f){return i(f?.message||String(f)),{addedProviderIds:[]}}finally{w(!1)}},[]);return r.useEffect(()=>{g()},[g]),{backends:n,catalog:a,currentOs:o,loading:d,error:u,refresh:g}}function Qe({backend:n,copy:t,onClick:a}){const s=!n.supportedOnThisOs,o=n.id==="ollama"?t.tileBlurbOllama:t.tileBlurbMlx,l=s?e.jsx(O,{variant:"muted",children:t.tileStatusUnsupported}):n.detected?e.jsx(O,{variant:"ok",children:t.tileBadgeReady(n.models.length)}):null,d=n.detected?`${n.version?`v${n.version} · `:""}${t.tileInstalledModels(n.models.length)}`:o;return e.jsxs("button",{type:"button",onClick:a,className:"group relative flex h-[104px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(Y,{brand:n.id,size:32}),l]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg group-hover:text-fg",children:n.label}),e.jsx("div",{className:"mt-1 truncate text-[11.5px] leading-relaxed text-fg-5",title:d,children:d})]})]})}function je({index:n,label:t,done:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold ${a?"border-transparent bg-[var(--th-badge-accent-bg)] text-[var(--th-badge-accent-text)]":"border-edge bg-panel-alt text-fg-4"}`,children:a?"✓":n}),e.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-[0.16em] text-fg-3",children:t})]})}function Je({name:n,sizeBytes:t}){return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-edge bg-panel-alt px-2 py-0.5 text-[11px] text-fg-3",children:[e.jsx("span",{className:"truncate font-mono",children:n}),t?e.jsx("span",{className:"shrink-0 text-fg-5",children:qe(t)}):null]})}function oe({label:n,cmd:t,copy:a,onCopy:s}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 truncate rounded-md border border-edge bg-panel px-2.5 py-1.5 font-mono text-[12px] text-fg-3",title:t,children:[n&&e.jsx("span",{className:"mr-2 text-fg-5",children:n}),t]}),e.jsx("button",{type:"button",onClick:()=>s(t),className:"shrink-0 rounded-md border border-edge bg-panel-alt px-2 py-1 text-[11px] text-fg-3 transition hover:border-edge-strong hover:bg-panel",children:a.copyCommand})]})}function Xe({entry:n,backend:t,totalRamGb:a,copy:s,locale:o,onCopy:l}){const d=re(a,n.minRamGb),w=o==="zh-CN"?n.descriptionZh:n.description,u=de(n,t),i=Ye(t,n);return e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3 py-2.5",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-[13px] font-semibold text-fg",children:n.name}),e.jsx("span",{className:"text-[11px] text-fg-5",children:n.publisher}),d==="ok"&&e.jsx(O,{variant:"ok",children:s.fitOk}),d==="tight"&&e.jsx(O,{variant:"warn",children:s.fitTight}),d==="no-go"&&e.jsx(O,{variant:"err",children:s.fitNoGo}),u&&e.jsx(O,{variant:"accent",children:s.modelInstalledBadge})]}),e.jsx("div",{className:"text-[12px] leading-relaxed text-fg-4",children:w}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] text-fg-5",children:[e.jsxs("span",{children:[n.paramsB,"B params"]}),e.jsxs("span",{children:[n.sizeGb," GB on disk"]}),e.jsxs("span",{children:["≥ ",n.minRamGb," GB RAM"]}),n.homepage&&e.jsx("a",{href:n.homepage,target:"_blank",rel:"noreferrer",className:"text-accent underline-offset-2 hover:underline",children:o==="zh-CN"?"模型主页":"Model card"})]}),!u&&d!=="no-go"&&i&&e.jsx(oe,{label:s.pullPrefix,cmd:i,copy:s,onCopy:l})]})})}function et({open:n,backend:t,catalog:a,totalRamGb:s,currentOs:o,copy:l,locale:d,onClose:w,onRefresh:u,onCopy:i}){const[g,f]=r.useState(!1);r.useEffect(()=>{f(!1)},[t?.detected,t?.id]);const j=r.useMemo(()=>t?Ze(t,a).sort((A,L)=>{const M=re(s,A.minRamGb),x=re(s,L.minRamGb),N=h=>h==="ok"?0:h==="tight"?1:2,R=de(A,t)?0:1,y=de(L,t)?0:1;return R!==y?R-y:N(M)-N(x)}):[],[t,a,s]);if(!t)return null;const p=!t.supportedOnThisOs,C=o?t.install[o]||[]:[],E=async()=>{f(!0);try{await u()}finally{f(!1)}};return e.jsxs(ee,{open:n,onClose:w,wide:!0,children:[e.jsx(te,{title:l.modalTitle(t.label),description:l.modalDescription(t.label),onClose:w}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx(je,{index:1,label:l.stepStatus,done:t.detected}),e.jsxs("div",{className:"space-y-2 rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel",children:e.jsx(Y,{brand:t.id,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-fg",children:t.label}),p?e.jsx(O,{variant:"muted",children:l.tileStatusUnsupported}):t.detected?e.jsx(O,{variant:"ok",children:l.statusRunning}):e.jsx(O,{variant:"muted",children:l.tileStatusNotDetected})]}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:p?e.jsx(e.Fragment,{children:l.statusUnsupportedDesc(t.label)}):t.detected?e.jsxs(e.Fragment,{children:[t.version&&e.jsxs(e.Fragment,{children:["v",t.version," · "]}),e.jsx("span",{className:"font-mono",children:t.baseURL})]}):e.jsx(e.Fragment,{children:l.statusNotRunning})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("a",{href:t.homepage,target:"_blank",rel:"noreferrer",className:"text-[12px] text-accent underline-offset-2 hover:underline",children:l.statusHomepageCta}),!p&&e.jsx(_,{variant:"outline",size:"sm",disabled:g,onClick:()=>{E()},children:g?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3"})," ",l.statusRechecking]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",l.statusRecheck]})})]})]}),!p&&t.detected&&t.existingProviderId&&e.jsx("div",{className:"rounded-md border border-emerald-700/20 bg-emerald-700/5 px-2.5 py-1.5 text-[11px] leading-relaxed text-emerald-700 dark:text-emerald-300",children:l.statusAutoAttachedHint(t.label)}),!p&&!t.detected&&e.jsxs("div",{className:"space-y-2 pt-1",children:[C.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.statusInstallHeader}),C.map((A,L)=>e.jsx(oe,{label:A.label,cmd:A.cmd,copy:l,onCopy:i},L)),t.install.docs&&e.jsxs("a",{href:t.install.docs,target:"_blank",rel:"noreferrer",className:"text-[11px] text-accent underline-offset-2 hover:underline",children:[l.statusInstallDocs," →"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.statusRunHint}),e.jsx(oe,{label:t.runHint.label,cmd:t.runHint.cmd,copy:l,onCopy:i})]})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx(je,{index:2,label:l.stepModels,done:t.detected&&t.models.length>0}),t.detected?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3",children:[e.jsx("div",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsInstalledHeader(t.models.length)}),t.models.length===0?e.jsx("div",{className:"text-[12px] text-fg-5",children:l.modelsInstalledEmpty}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(A=>e.jsx(Je,{name:A.id,sizeBytes:A.sizeBytes},A.id))})]}),j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-fg-5",children:l.modelsRecommendedHeader}),e.jsx("div",{className:"space-y-1.5",children:j.map(A=>e.jsx(Xe,{entry:A,backend:t,totalRamGb:s,copy:l,locale:d,onCopy:i},A.id))})]})]}):e.jsx("div",{className:"rounded-md border border-edge bg-panel-alt px-3.5 py-3 text-[12px] text-fg-5",children:l.modelsBackendOffline})]})]}),e.jsx("div",{className:"mt-6 border-t border-edge pt-4",children:e.jsx(ce,{primary:{label:l.closeBtn,onClick:w}})})]})}function tt({snapshot:n,onConnected:t}){const a=$(h=>h.locale),s=$(h=>h.host),o=$(h=>h.toast),l=r.useMemo(()=>Ge(a),[a]),d=Ce(),w=n??d,{backends:u,catalog:i,currentOs:g,loading:f,error:j,refresh:p}=w,[C,E]=r.useState(null),A=r.useMemo(()=>u.find(h=>h.id===C)??null,[u,C]),L=r.useRef("");r.useEffect(()=>{const h=u.map(B=>B.existingProviderId||"").join(",");h!==L.current&&(L.current=h,t&&u.some(B=>B.existingProviderId)&&t())},[u,t]);const M=r.useCallback(async()=>{const h=await p();return t&&h.addedProviderIds.length>0&&await t(),h},[p,t]),x=r.useCallback(h=>{navigator.clipboard?.writeText(h),o(l.copied)},[l.copied,o]),N=s?.totalMem?s.totalMem/1024**3:null,R=s?`${s.cpuModel||s.arch} · ${We(s.totalMem)} RAM`:l.hostUnknown,y=u.length>0?u:[{id:"ollama",label:"Ollama",detected:!1,baseURL:"http://127.0.0.1:11434",openAIBaseURL:"http://127.0.0.1:11434/v1",models:[],existingProviderId:null,homepage:"https://ollama.com/",install:{},runHint:{cmd:"ollama serve"},pullCommandTemplate:"ollama pull ${model}",supportedOnThisOs:!0},{id:"mlx",label:"mlx-lm",detected:!1,baseURL:"http://127.0.0.1:8080",openAIBaseURL:"http://127.0.0.1:8080/v1",models:[],existingProviderId:null,homepage:"https://github.com/ml-explore/mlx-lm",install:{},runHint:{cmd:"mlx_lm.server --port 8080"},pullCommandTemplate:"mlx_lm.server --model ${model} --port 8080",supportedOnThisOs:!0}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[12px] text-fg-5",children:[e.jsx("span",{className:"font-semibold uppercase tracking-[0.14em] text-fg-5",children:l.hostLabel}),e.jsx("span",{className:"mx-2 text-fg-6",children:"·"}),e.jsx("span",{className:"text-fg-3",children:R})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>{M()},disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3"})," ",l.refreshing]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"↻"})," ",l.refresh]})})]}),e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:l.sectionLabel}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:y.map(h=>e.jsx(Qe,{backend:h,copy:l,locale:a,onClick:()=>E(h.id)},h.id))})]}),j&&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:j}),e.jsx(et,{open:C!==null,backend:A,catalog:i,totalRamGb:N,currentOs:g,copy:l,locale:a,onClose:()=>E(null),onRefresh:M,onCopy:x})]})}function nt(n){return!n||!Number.isFinite(n)?null:n>=1e6?`${Math.round(n/1e5)/10}M ctx`:n>=1e3?`${Math.round(n/1e3)}K ctx`:`${n} ctx`}function ye(n){const t=(()=>{try{return new URL(n.baseURL)}catch{return null}})(),a=t?.host.toLowerCase()??"",s=t?.port??"";return(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="11434"?"ollama":(a.startsWith("127.0.0.1")||a.startsWith("localhost"))&&s==="8080"?"mlx":a.includes("openrouter")?"openrouter":a.includes("anthropic")?"anthropic":a.includes("deepseek")?"deepseek":a.includes("googleapis")||a.includes("vertex")?"google":a.includes("openai.com")?"openai":a.includes("dashscope")||a.includes("qwen")||a.includes("aliyun")?"qwen":a.includes("volces")||a.includes("volcengine")||a.includes("doubao")?"doubao":a.includes("bigmodel")||a.includes("zhipu")||a.includes("z.ai")?"glm":a.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function at(n){return n==="zh-CN"?{sectionTitle:"我的模型",sectionHint:"把你常用的模型登记成一条条快捷方式,自由起别名。这是一份纯粹的选择列表——智能体会从这里挑模型,但谁选了什么不会反向显示在这里。",addLabel:"添加模型",empty:"还没有登记任何模型",emptyHint:'先在下方"模型供应商"里接入一个供应商,再点上方"添加模型"把常用的几个固定下来。',addModalTitle:"添加模型",editModalTitle:"编辑模型",fieldName:"显示名",fieldNameHint:"智能体卡片和 IM 选择菜单里会看到的名称;留空则直接用模型 ID。",fieldProvider:"供应商",fieldProviderEmpty:'没有可用的供应商;请先在下方"模型供应商"里接入一个。',fieldProviderLockedHint:'想换别的供应商?关闭这个窗口,先到下方"模型供应商"里接入。',fieldModelId:"模型",fieldModelIdHint:"从供应商 /v1/models 拉到的真实模型列表中挑选。",fieldModelIdLoading:"正在拉取该供应商的模型列表…",fieldModelIdEmpty:"该供应商没有返回模型列表(或还未校验),可手动输入模型 ID。",fieldModelIdToggleManual:"改为手动输入",fieldModelIdToggleList:"从列表选择",fieldModelIdSearchPlaceholder:"搜索模型",fieldModelIdSearchEmpty:"没有匹配的模型",fieldModelIdCurrentLabel:"当前",fieldEffort:"推理强度",effortDefault:"(沿用默认)",cancel:"取消",save:"保存",saving:"保存中",remove:"删除",removeConfirm:"删除这个模型条目?已经选择它的智能体会自动回退到官方认证。",via:"经由"}:{sectionTitle:"My Models",sectionHint:"Register the models you actually use as named shortcuts. A pure selection list — agents pick from here, but who picks what does not bubble back into this view.",addLabel:"Add model",empty:"No models registered yet",emptyHint:"Connect a provider below first, then come back here to pin the few you actually use.",addModalTitle:"Add Model",editModalTitle:"Edit Model",fieldName:"Display name",fieldNameHint:"Shown in agent cards and the IM model picker. Leave empty to use the model id as-is.",fieldProvider:"Provider",fieldProviderEmpty:'No providers configured yet; add one in "Model Providers" below first.',fieldProviderLockedHint:'Want a different provider? Close this dialog and connect one in "Model Providers" below.',fieldModelId:"Model",fieldModelIdHint:"Picked from the provider's live /v1/models list.",fieldModelIdLoading:"Loading the provider's model list…",fieldModelIdEmpty:"This provider returned no model list (or has not been validated yet). Enter a model ID manually.",fieldModelIdToggleManual:"Enter manually",fieldModelIdToggleList:"Pick from list",fieldModelIdSearchPlaceholder:"Search models",fieldModelIdSearchEmpty:"No matching models",fieldModelIdCurrentLabel:"Current",fieldEffort:"Reasoning effort",effortDefault:"(default)",cancel:"Cancel",save:"Save",saving:"Saving",remove:"Remove",removeConfirm:"Remove this model entry? Agents that picked it will fall back to native auth.",via:"via"}}async function Ee(n,t,a){return(await fetch(t,{method:n,headers:{"Content-Type":"application/json"},body:a?JSON.stringify(a):void 0})).json()}const lt=["","low","medium","high","xhigh","max"];function st({open:n,copy:t,providers:a,initial:s,existing:o,onClose:l,onSaved:d,onRemove:w}){const[u,i]=r.useState(s),[g,f]=r.useState(!1),[j,p]=r.useState(null),[C,E]=r.useState(()=>new Map),[A,L]=r.useState(!1),[M,x]=r.useState(null),[N,R]=r.useState(!1);r.useEffect(()=>{n&&(i(s),p(null),R(!1),E(new Map))},[n,s]),r.useEffect(()=>{if(!n)return;const m=u.providerId;if(!m||C.has(m))return;let b=!1;return L(!0),x(null),(async()=>{try{const v=await(await fetch(`/api/models/providers/${m}/models`)).json();if(b)return;const S=v.modelInfos&&v.modelInfos.length>0?v.modelInfos:(v.models||[]).map(P=>({id:P}));E(P=>{const D=new Map(P);return D.set(m,S),D}),!v.ok&&v.error&&x(v.error)}catch(c){b||x(c?.message||String(c))}finally{b||L(!1)}})(),()=>{b=!0}},[n,u.providerId,C]);const y=!!o,h=C.get(u.providerId)??null,B=r.useCallback(async()=>{p(null),f(!0);try{const m={name:u.name.trim()||void 0,providerId:u.providerId,modelId:u.modelId.trim(),effort:u.effort||null},b=y&&o?`/api/models/profiles/${o.id}`:"/api/models/profiles",v=await Ee(y?"PATCH":"POST",b,m);if(!v.ok){p(v.error||"Failed to save");return}d(),l()}catch(m){p(m?.message||String(m))}finally{f(!1)}},[u,y,o,d,l]),z=!g&&!!u.providerId&&u.modelId.trim().length>0;return e.jsxs(ee,{open:n,onClose:l,children:[e.jsx(te,{title:y?t.editModalTitle:t.addModalTitle,description:t.sectionHint,onClose:l}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(H,{children:t.fieldProvider}),a.length===0?e.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-700",children:t.fieldProviderEmpty}):(()=>{const m=y||a.length<=1,b=a.find(c=>c.id===u.providerId)??a[0];return m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-10 w-full items-center gap-2.5 rounded-md border border-edge bg-panel-alt px-3",children:[e.jsx(Y,{brand:ye(b),size:20}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-fg-2",children:b.name}),e.jsx("div",{className:"truncate font-mono text-[10.5px] leading-tight text-fg-5",children:b.baseURL})]})]}),!y&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldProviderLockedHint})]}):e.jsx(q,{value:u.providerId,options:a.map(c=>({value:c.id,label:`${c.name} · ${c.baseURL}`})),onChange:c=>i(v=>({...v,providerId:c}))})})()]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-baseline justify-between gap-2",children:[e.jsx(H,{className:"mb-0",children:t.fieldModelId}),h&&h.length>0&&e.jsx("button",{type:"button",onClick:()=>R(m=>!m),className:"text-[11px] text-fg-5 transition hover:text-fg-3",children:N?t.fieldModelIdToggleList:t.fieldModelIdToggleManual})]}),A&&e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-md border border-edge bg-panel-alt px-3 text-[12px] text-fg-5",children:[e.jsx(G,{}),t.fieldModelIdLoading]}),!A&&!N&&h&&h.length>0&&(()=>{const b=[...!h.some(c=>c.id===u.modelId)&&u.modelId?[{value:u.modelId,label:u.modelId,description:t.fieldModelIdCurrentLabel}]:[],...h.map(c=>({value:c.id,label:c.id,description:c.name&&c.name.toLowerCase()!==c.id.toLowerCase()?c.name:void 0,meta:c.contextLength?nt(c.contextLength):void 0}))];return e.jsx(we,{value:u.modelId,options:b,onChange:c=>i(v=>({...v,modelId:c})),searchPlaceholder:t.fieldModelIdSearchPlaceholder,noMatchesText:t.fieldModelIdSearchEmpty,currentLabel:t.fieldModelIdCurrentLabel})})(),!A&&(N||!h||h.length===0)&&e.jsxs(e.Fragment,{children:[e.jsx(K,{value:u.modelId,onChange:m=>i(b=>({...b,modelId:m.target.value})),placeholder:"anthropic/claude-sonnet-4"}),(!h||h.length===0)&&!M&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldModelIdEmpty})]}),M&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-amber-700",children:M}),!N&&h&&h.length>0&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldModelIdHint})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldName}),e.jsx(K,{value:u.name,onChange:m=>i(b=>({...b,name:m.target.value})),placeholder:u.modelId||"anthropic/claude-sonnet-4"}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-fg-5",children:t.fieldNameHint})]}),e.jsxs("div",{children:[e.jsx(H,{children:t.fieldEffort}),e.jsx(q,{value:u.effort,options:lt.map(m=>({value:m,label:m||t.effortDefault})),onChange:m=>i(b=>({...b,effort:m}))})]}),j&&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:j})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-2 border-t border-edge pt-4",children:[e.jsx("div",{children:y&&w&&e.jsx("button",{type:"button",onClick:()=>{w()},className:"text-[12px] text-fg-5 transition hover:text-[var(--th-err)]",children:t.remove})}),e.jsx(ce,{primary:{label:g?t.saving:t.save,onClick:B,disabled:!z},secondary:{label:t.cancel,onClick:l}})]})]})}function it({profile:n,provider:t,copy:a,onPick:s}){const o=t?ye(t):"custom";return e.jsxs("button",{type:"button",onClick:s,className:"group relative flex h-[120px] flex-col rounded-lg border border-edge bg-panel-alt px-4 py-3.5 text-left transition-all duration-200 hover:-translate-y-0.5 hover:border-edge-strong hover:bg-panel hover:shadow-[0_4px_16px_rgba(15,23,42,0.06)]",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-2",children:[e.jsx(Y,{brand:o,size:28}),n.effort&&e.jsx(O,{variant:"muted",children:n.effort})]}),e.jsxs("div",{className:"mt-auto min-w-0",children:[e.jsx("div",{className:"truncate text-[14px] font-semibold tracking-tight text-fg",children:n.name}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] leading-relaxed text-fg-4",children:n.modelId}),e.jsxs("div",{className:"mt-1 truncate text-[11.5px] text-fg-5",children:[a.via," ",t?.name??"?"]})]})]})}function rt({onClick:n,label:t}){return e.jsxs("button",{type:"button",onClick:n,className:"flex h-[120px] flex-col items-center justify-center rounded-lg border border-dashed border-edge bg-panel-alt text-fg-4 transition hover:border-edge-strong hover:bg-panel hover:text-fg-2",children:[e.jsx("div",{className:"text-2xl leading-none",children:"+"}),e.jsx("div",{className:"mt-1 text-[12.5px] font-medium tracking-tight",children:t})]})}function dt({snapshot:n}){const{providers:t,profiles:a,reload:s}=n,o=$(p=>p.locale),l=r.useMemo(()=>at(o),[o]),[d,w]=r.useState(null),u=r.useMemo(()=>new Map(t.map(p=>[p.id,p])),[t]),i=r.useCallback(async p=>{confirm(l.removeConfirm)&&(await Ee("DELETE",`/api/models/profiles/${p.id}`),await s())},[l,s]),g=r.useMemo(()=>({name:"",providerId:t[0]?.id??"",modelId:"",effort:""}),[t]),f=r.useMemo(()=>{if(!d||d.kind!=="edit")return null;const p=d.profile;return{name:p.name,providerId:p.providerId,modelId:p.modelId,effort:p.effort||""}},[d]),j=a.length===0;return e.jsxs("div",{className:"space-y-2",children:[j&&e.jsxs("div",{className:"rounded-lg border border-dashed border-edge bg-panel-alt px-4 py-6 text-center",children:[e.jsx("div",{className:"text-[13.5px] font-semibold text-fg-2",children:l.empty}),e.jsx("div",{className:"mx-auto mt-1 max-w-md text-[12px] leading-relaxed text-fg-5",children:l.emptyHint}),t.length>0&&e.jsx("div",{className:"mt-3",children:e.jsx(_,{variant:"primary",size:"sm",onClick:()=>w({kind:"add"}),children:l.addLabel})})]}),!j&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[a.map(p=>e.jsx(it,{profile:p,provider:u.get(p.providerId)??null,copy:l,onPick:()=>w({kind:"edit",profile:p})},p.id)),t.length>0&&e.jsx(rt,{label:l.addLabel,onClick:()=>w({kind:"add"})})]}),d&&e.jsx(st,{open:!0,copy:l,providers:t,initial:d.kind==="edit"?f:g,existing:d.kind==="edit"?d.profile:null,onClose:()=>w(null),onSaved:s,onRemove:d.kind==="edit"?async()=>{await i(d.profile),w(null)}:void 0})]})}const ot=["claude","codex","gemini","hermes"];function ct(n){return n==="hermes"}function ut(n){const t=(n||"").toLowerCase().trim();return t==="openrouter"?"openrouter":t==="anthropic"?"anthropic":t==="openai"?"openai":t==="google"||t==="gemini"?"google":t==="deepseek"?"deepseek":t==="qwen"||t==="dashscope"?"qwen":t==="doubao"||t==="volces"||t==="volcengine"?"doubao":t==="glm"||t==="zhipu"||t==="bigmodel"?"glm":t==="minimax"?"minimax":"custom"}function mt(n){const t=(()=>{try{return new URL(n.baseURL).host.toLowerCase()}catch{return""}})();return t.includes("openrouter")?"openrouter":t.includes("anthropic")?"anthropic":t.includes("deepseek")?"deepseek":t.includes("googleapis")||t.includes("vertex")?"google":t.includes("openai.com")?"openai":t.includes("dashscope")||t.includes("qwen")||t.includes("aliyun")?"qwen":t.includes("volces")||t.includes("volcengine")||t.includes("doubao")?"doubao":t.includes("bigmodel")||t.includes("zhipu")||t.includes("z.ai")?"glm":t.includes("minimax")?"minimax":n.kind==="anthropic"?"anthropic":n.kind==="google"?"google":n.kind==="openai"?"openai":"custom"}function Ne(n,t){const a=n.bindings[t];if(!a)return null;const s=n.profiles.find(l=>l.id===a);if(!s)return null;const o=n.providers.find(l=>l.id===s.providerId);return o?{profileId:s.id,providerId:o.id,providerName:o.name,providerBrand:mt(o),modelId:s.modelId,effort:s.effort||null}:null}function ft(n){return n==="zh-CN"?{defaultsTitle:"新会话默认值",defaultsHint:"决定新建对话默认走哪个智能体。具体模型与推理强度由该智能体卡片下的「供应商 / 模型 / 推理强度」决定。",defaultsEditTitle:"修改默认智能体",defaultsEditHint:"选择新建对话默认走哪个智能体。",defaultsSaved:"默认智能体已更新",editDefaults:"修改默认",agentsTitle:"可用智能体",defaultAgent:"默认智能体",installLabel:"安装状态",versionLabel:"版本",defaultBadge:"默认",installed:"已安装",notInstalled:"未安装",notInstalledHint:"安装该智能体的本地 CLI 后即可在此配置供应商与模型。",noModel:"未设置",noVersion:"版本未知",loadFailed:"无法加载智能体状态",updateAvailable:"有新版本",updateSkipped:"自动更新已跳过",updateFailed:"自动更新失败",update:"升级",updating:"升级中…",checkUpdate:"检查更新",checking:"检查中…",upToDate:"已是最新",install:"安装",installing:"安装中…",profilesHint:"把你常用的模型登记成一条条快捷方式,自由起别名。这是一份纯粹的选择列表——智能体(包括 Hermes)会从这里挑模型,但选了谁不会反向显示在这里。",profilesTitle:"我的模型",modelsTitle:"模型供应商",modelsHint:'接入 BYOK 供应商;接入后可在上方"我的模型"里挑选具体模型并固定下来。',localTitle:"本地模型",localHint:"在本机检测 Ollama / mlx-lm 并按内存推荐合适的开源模型;接入后会作为一个供应商出现在智能体卡片中。",rowProvider:"供应商",rowModel:"模型",rowEffort:"推理强度",providerNative:"官方(CLI 内置认证)",providerNativeFromAgent:"智能体自身配置",effortDefault:"默认",modelLoading:"正在拉取模型列表…",modelEmpty:"该供应商未返回模型列表,请使用自定义输入。",modelCustomToggle:"改为自定义输入",modelListToggle:"从列表选择",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"搜索模型",modelSearchEmpty:"没有匹配的模型",modelCurrentLabel:"当前",modelGroupNative:"官方",modelGroupProfiles:"我的模型",modelPickerEmpty:"没有可选模型",modelPickerEmptyHint:'该智能体的官方模型列表为空,且你还没有登记任何"我的模型"。',saveChanges:"保存",saving:"保存中…",saved:"已保存",configError:"保存失败",externalNativeNote:t=>`Hermes 当前从 ${t||"~/.hermes/config.yaml"} 读取这些值;切换为某个 BYOK 供应商可由 pikiclaw 接管。`,configure:"配置",configModalTitle:t=>`配置 ${t}`,rowSummaryNative:"官方认证",rowSummaryNoModel:"未选模型",rowSummaryNoEffort:"默认强度"}:{defaultsTitle:"New Session Defaults",defaultsHint:"Pick which agent new sessions use by default. Provider / Model / Effort live on each agent card below.",defaultsEditTitle:"Change Default Agent",defaultsEditHint:"Which agent should new sessions use by default?",defaultsSaved:"Default agent updated",editDefaults:"Change default",agentsTitle:"Available Agents",defaultAgent:"Default Agent",installLabel:"Install",versionLabel:"Version",defaultBadge:"Default",installed:"Installed",notInstalled:"Not installed",notInstalledHint:"Install the local CLI for this agent to configure its provider and model.",noModel:"Not set",noVersion:"Version unavailable",loadFailed:"Failed to load agent status",updateAvailable:"Update available",updateSkipped:"Auto-update skipped",updateFailed:"Auto-update failed",update:"Update",updating:"Updating…",checkUpdate:"Check update",checking:"Checking…",upToDate:"Up to date",install:"Install",installing:"Installing…",profilesTitle:"My Models",profilesHint:"Register the models you actually use as named shortcuts. A pure selection list — agents (including Hermes) pick from here, but who picks what does not bubble back into this view.",modelsTitle:"Model Providers",modelsHint:'Connect BYOK providers; pin specific models above in "My Models".',localTitle:"Local Models",localHint:"Detect Ollama / mlx-lm on this machine and surface coding models that fit your RAM. Connected backends show up as a provider on the agent cards.",rowProvider:"Provider",rowModel:"Model",rowEffort:"Effort",providerNative:"Native (CLI auth)",providerNativeFromAgent:"agent's own config",effortDefault:"default",modelLoading:"Loading model list…",modelEmpty:"Provider returned no model list — use custom input.",modelCustomToggle:"Use custom input",modelListToggle:"Pick from list",modelCustomPlaceholder:"anthropic/claude-sonnet-4",modelSearchPlaceholder:"Search models",modelSearchEmpty:"No matching models",modelCurrentLabel:"Current",modelGroupNative:"Native",modelGroupProfiles:"My Models",modelPickerEmpty:"No models available",modelPickerEmptyHint:'This agent has no native model list, and no "My Models" entries are registered.',saveChanges:"Save",saving:"Saving…",saved:"Saved",configError:"Save failed",externalNativeNote:t=>`Hermes reads these values from ${t||"~/.hermes/config.yaml"}; pick a BYOK provider to let pikiclaw take over.`,configure:"Configure",configModalTitle:t=>`Configure ${t}`,rowSummaryNative:"Native auth",rowSummaryNoModel:"No model",rowSummaryNoEffort:"Default effort"}}function pt(n,t){const a=n.filter(o=>o.installed);return(a.length?a:n).map(o=>({value:o.agent,label:`${Q(o.agent).label} · ${o.installed?o.version||t.installed:t.notInstalled}`}))}function ke(n,t){n({defaultAgent:t.defaultAgent,agents:t.agents})}function ht(n,t,a){if(a)return{kind:"profile",modelId:a.modelId,profileId:a.profileId,effort:a.effort||""};const s=t?.nativeConfig||null;return{kind:"native",modelId:s?.model||t?.selectedModel||"",profileId:null,effort:s?.effort||t?.selectedEffort||""}}function xt(n,t){return n.kind===t.kind&&(n.profileId||"")===(t.profileId||"")&&n.modelId.trim()===t.modelId.trim()&&(n.effort||"")===(t.effort||"")}function gt(n){return n.kind==="profile"&&n.profileId?`p:${n.profileId}`:`n:${n.modelId}`}function vt(n){return n.startsWith("n:")?{kind:"native",modelId:n.slice(2)}:n.startsWith("p:")?{kind:"profile",profileId:n.slice(2)}:null}function bt({agentId:n,agentStatus:t,boundInfo:a,copy:s,layer:o,toast:l,onSaved:d,onCancel:w,t:u}){const i=ct(n),g=t.nativeConfig||null,f=r.useMemo(()=>ht(n,t,a),[n,t,a]),[j,p]=r.useState(f),[C,E]=r.useState(!1),[A,L]=r.useState(null);r.useEffect(()=>{p(f),L(null)},[f]);const x=j.kind==="native"&&i,N=r.useMemo(()=>{const b=he[n]||he.claude;return[{value:"",label:s.effortDefault},...b.map(c=>({value:c,label:c}))]},[n,s.effortDefault]),R=r.useMemo(()=>{const b=[];if(!i)for(const v of t.models){const S=v.alias?.toLowerCase().replace(/[\s_-]/g,""),P=v.id.toLowerCase().replace(/[\s_-]/g,""),D=v.alias&&S!==P;b.push({value:`n:${v.id}`,label:v.id,description:D?v.alias:void 0,group:s.modelGroupNative})}const c=new Set(Be[n]||[]);for(const v of o.profiles){const S=o.providers.find(Z=>Z.id===v.providerId);if(!S||!c.has(S.kind))continue;const P=S.name,U=v.name.trim().toLowerCase()!==v.modelId.trim().toLowerCase()?`${P} · ${v.modelId}`:P;b.push({value:`p:${v.id}`,label:v.name,description:U,group:s.modelGroupProfiles})}return b},[n,t.models,o.profiles,o.providers,s.modelGroupNative,s.modelGroupProfiles,i]),y=gt(j),h=r.useCallback(b=>{const c=vt(b);if(c)if(c.kind==="native")p(v=>({...v,kind:"native",modelId:c.modelId,profileId:null,effort:v.kind==="profile"?t.nativeSelectedEffort||t.nativeConfig?.effort||"":v.effort}));else{const v=o.profiles.find(S=>S.id===c.profileId);p(S=>({...S,kind:"profile",profileId:c.profileId,modelId:v?.modelId||S.modelId,effort:v?.effort||S.effort}))}},[o.profiles,t.nativeSelectedEffort,t.nativeConfig]),B=!xt(j,f),z=!C&&B&&(x||!!j.modelId.trim()||j.kind==="profile"),m=r.useCallback(async()=>{L(null),E(!0);try{const b=j.effort||null;if(j.kind==="native"){if(o.bindings[n]&&await o.setActiveProfile(n,null),!i){const c={agent:n},v=j.modelId.trim();if(v&&v!==(t.nativeSelectedModel||"")&&(c.model=v),b!==(t.nativeSelectedEffort||null)&&(c.effort=b),Object.keys(c).length>1){const S=await V.updateRuntimeAgent(c);if(!S.ok)throw new Error(S.error||"Failed to update agent")}}}else{if(!j.profileId)throw new Error("No profile selected");if(await o.setActiveProfile(n,j.profileId),b!==(t.selectedEffort||null)){const c=await V.updateRuntimeAgent({agent:n,effort:b});if(!c.ok)throw new Error(c.error||"Failed to update agent")}}await Promise.resolve(d()),l(s.saved)}catch(b){const c=b?.message||String(b);L(c),l(`${s.configError}: ${c}`,!1)}finally{E(!1)}},[n,t,s,j,i,o,d,l]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{children:[e.jsx(H,{className:"!mb-1 text-[11px]",children:s.rowModel}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"truncate font-mono",children:g?.model||s.noModel})}):R.length===0?e.jsxs("div",{className:"rounded-md border border-edge bg-panel-alt px-3 py-3",children:[e.jsx("div",{className:"text-[12px] font-medium text-fg-3",children:s.modelPickerEmpty}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-fg-5",children:s.modelPickerEmptyHint})]}):e.jsx(we,{value:y,options:R,onChange:h,placeholder:"—",searchPlaceholder:s.modelSearchPlaceholder,noMatchesText:s.modelSearchEmpty,currentLabel:s.modelCurrentLabel})]}),e.jsxs("div",{children:[e.jsx(H,{className:"!mb-1 text-[11px]",children:s.rowEffort}),x?e.jsx("div",{className:"flex h-9 items-center rounded-md border border-control-border bg-control px-3 text-[13px] text-fg-3",children:e.jsx("span",{className:"font-mono",children:g?.effort||s.effortDefault})}):e.jsx(q,{value:j.effort,options:N,onChange:b=>p(c=>({...c,effort:b}))})]})]}),x&&e.jsx("div",{className:"text-[11px] leading-relaxed text-fg-5",children:s.externalNativeNote(g?.configPath||"")}),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.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:w,disabled:C,children:u("modal.cancel")}),e.jsxs(_,{variant:"primary",size:"sm",disabled:!z,onClick:()=>{m()},children:[C&&e.jsx(G,{className:"h-3 w-3"}),C?s.saving:s.saveChanges]})]})]})}function jt(n,t,a){if(t)return{providerBrand:t.providerBrand,providerLabel:t.providerName,modelText:t.modelId||a.rowSummaryNoModel,effortText:t.effort||a.rowSummaryNoEffort};const s=n.nativeConfig||null,o=s?.provider||null;return{providerBrand:ut(o),providerLabel:a.rowSummaryNative,modelText:n.nativeSelectedModel||s?.model||n.selectedModel||a.rowSummaryNoModel,effortText:n.nativeSelectedEffort||s?.effort||n.selectedEffort||a.rowSummaryNoEffort}}function Nt({agent:n,copy:t,t:a,installing:s,onInstall:o,updatingAgent:l,checkingAgent:d,onUpdate:w,onCheckUpdate:u,onEdit:i,loading:g=!1,boundInfo:f}){const j=Q(n.agent),p=j.advantageKey?a(j.advantageKey):"",C=n.installed?jt(n,f,t):null;return e.jsxs("div",{className:"glass rounded-md border border-edge px-3.5 py-2.5 shadow-[0_1px_0_rgba(255,255,255,0.02),0_4px_12px_rgba(15,23,42,0.05)]",title:p||void 0,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-edge bg-panel-alt",children:e.jsx(Y,{brand:n.agent,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[14px] font-semibold tracking-tight text-fg",children:j.label}),n.isDefault&&e.jsx(O,{variant:"accent",children:t.defaultBadge}),g?e.jsxs(O,{variant:"muted",children:[e.jsx(G,{className:"h-3 w-3"})," ",a("status.loading")]}):n.installed?e.jsx(O,{variant:"ok",children:t.installed}):e.jsx(O,{variant:"muted",children:t.notInstalled}),n.installed&&n.updateAvailable&&e.jsx(O,{variant:"warn",children:t.updateAvailable}),n.installed&&n.version&&e.jsxs("span",{className:"text-[11px] font-mono text-fg-5",children:["v",n.version]}),n.latestVersion&&n.updateAvailable&&e.jsxs("span",{className:"text-[11px] text-amber-400",children:["→ ",n.latestVersion]})]}),C?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Y,{brand:C.providerBrand,size:11}),e.jsx("span",{className:"text-fg-3",children:C.providerLabel})]}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-mono text-fg-3",children:C.modelText}),e.jsx("span",{className:"text-fg-6","aria-hidden":"true",children:"·"}),e.jsx("span",{children:C.effortText})]}):p?e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-fg-5",children:p}):null]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[g&&e.jsx("div",{className:"inline-flex h-7 items-center gap-2 px-2 text-[11px] text-fg-5",children:e.jsx(G,{className:"h-3 w-3"})}),!g&&!n.installed&&e.jsx(_,{variant:"primary",size:"sm",disabled:s,onClick:()=>o(n),children:s?t.installing:t.install}),!g&&n.installed&&n.updateAvailable&&e.jsx(_,{variant:"outline",size:"sm",disabled:l,onClick:()=>w(n),children:l?t.updating:t.update}),!g&&n.installed&&!n.updateAvailable&&e.jsx(_,{variant:"ghost",size:"icon",disabled:d,onClick:()=>u(n),title:t.checkUpdate,"aria-label":t.checkUpdate,className:"h-7 w-7",children:d?e.jsx(G,{className:"h-3 w-3"}):e.jsx("span",{"aria-hidden":"true",children:"↻"})}),!g&&n.installed&&e.jsx(_,{variant:"outline",size:"sm",onClick:()=>i(n),children:t.configure})]})]}),!g&&n.installed&&n.updateAvailable&&n.updateStatus==="skipped"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-warn-text)"},children:[t.updateSkipped,": ",n.updateDetail]}),!g&&n.installed&&n.updateStatus==="failed"&&n.updateDetail&&e.jsxs("div",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--th-badge-err-text)"},children:[t.updateFailed,": ",n.updateDetail]})]})}function At(){const n=$(k=>k.locale),t=$(k=>k.toast),a=$(k=>k.agentStatus),s=$(k=>k.setAgentStatus),o=$(k=>k.refreshAgentStatus),l=r.useMemo(()=>De(n),[n]),d=r.useMemo(()=>ft(n),[n]),w=Me(),u=Ce(),[i,g]=r.useState(a?{defaultAgent:a.defaultAgent,agents:a.agents}:null),[f,j]=r.useState(!a),[p,C]=r.useState(null),[E,A]=r.useState(!1),[L,M]=r.useState(null),[x,N]=r.useState(!1),[R,y]=r.useState("codex"),[h,B]=r.useState(null),[z,m]=r.useState(null),[b,c]=r.useState(null),v=r.useRef(!!a);r.useEffect(()=>{a&&(ke(g,a),v.current||(v.current=!0,j(!1)))},[a]);const S=r.useCallback(k=>{ke(g,k),s(k)},[s]),P=r.useCallback(async()=>{v.current||j(!0);try{const k=await V.getAgentStatus();return S(k),C(null),v.current=!0,k}catch(k){const I=k instanceof Error?k.message:d.loadFailed;return C(I),v.current||t(I,!1),null}finally{j(!1)}},[S,d.loadFailed,t]);r.useEffect(()=>{a?o():P()},[]);const D=r.useMemo(()=>{const k=i?.agents||[],I=new Map(k.map(T=>[T.agent,T]));return ot.map(T=>{const pe=I.get(T);if(pe)return pe;const He=Q(T);return{agent:T,label:He.label,installed:!1,version:void 0,installCommand:void 0,selectedModel:null,selectedEffort:null,isDefault:i?.defaultAgent===T,models:[],usage:null}})},[i]),U=i?.defaultAgent||"codex",Z=D.find(k=>k.agent===U)||null,ue=D.filter(k=>k.installed).length>0,Se=pt(D,d),me=r.useCallback(async k=>{A(!0);try{const I=await V.updateRuntimeAgent(k);if(!I.ok)throw new Error(I.error||l("config.applyFailed"));return S(I),I}catch(I){const T=I instanceof Error?I.message:l("config.applyFailed");return t(T,!1),P(),null}finally{A(!1)}},[S,P,l,t]);r.useEffect(()=>{x&&y(U)},[U,x]);const Ae=r.useCallback(async()=>{if(R===U){N(!1);return}await me({defaultAgent:R})&&(t(d.defaultsSaved),N(!1))},[d.defaultsSaved,U,R,t,me]),Le=r.useCallback(async k=>{if(!L){M(k.agent);try{const I=await V.installAgent(k.agent);if(!I.ok)throw new Error(I.error||l("config.agentInstallFailed"));S(I),t(l("config.agentInstalled"))}catch(I){const T=I instanceof Error?I.message:l("config.agentInstallFailed");t(T,!1),P()}finally{M(I=>I===k.agent?null:I)}}},[S,L,P,l,t]),Re=r.useCallback(async k=>{if(!h){B(k.agent);try{const I=await V.updateAgent(k.agent);if(!I.ok)throw new Error(I.error||l("config.agentInstallFailed"));S(I),t(d.upToDate)}catch(I){const T=I instanceof Error?I.message:d.updateFailed;t(T,!1),P()}finally{B(I=>I===k.agent?null:I)}}},[S,d.updateFailed,d.upToDate,P,l,t,h]),Pe=r.useCallback(async k=>{if(!z){m(k.agent);try{const I=await V.checkAgentUpdate(k.agent);if(!I.ok)throw new Error(I.error||d.loadFailed);S(I)}catch(I){const T=I instanceof Error?I.message:d.loadFailed;t(T,!1),P()}finally{m(I=>I===k.agent?null:I)}}},[S,z,d.loadFailed,P,t]),ne=f&&!i,Te=ne?l("status.loading"):Z?Q(Z.agent).label:d.notInstalled;ne?l("status.loading"):Z?.installed?d.installed:d.notInstalled;const fe=r.useCallback(async()=>{await w.reload(),await P()},[w,P]),W=b?D.find(k=>k.agent===b)??null:null,ae=W?Q(W.agent):null;return e.jsxs("div",{className:"animate-in space-y-4",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-fg-5",children:d.agentsTitle}),ne?e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-5",children:[e.jsx(G,{className:"h-3 w-3"}),e.jsx("span",{children:d.defaultAgent})]}):e.jsxs("button",{type:"button",onClick:()=>N(!0),disabled:E||!ue,title:d.editDefaults,className:"group inline-flex items-center gap-1.5 rounded-full border border-edge bg-panel-alt px-3 py-1 text-[12px] transition hover:border-edge-strong hover:bg-panel disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"text-fg-5 group-hover:text-fg-4",children:d.defaultAgent}),e.jsx(Y,{brand:U,size:14}),e.jsx("span",{className:"font-semibold text-fg-2",children:Te}),e.jsx("svg",{className:"text-fg-6 transition group-hover:text-fg-3",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-2",children:D.map(k=>e.jsx(Nt,{agent:k,copy:d,t:l,installing:L===k.agent,loading:ne,onInstall:Le,updatingAgent:h===k.agent,checkingAgent:z===k.agent,onUpdate:Re,onCheckUpdate:Pe,onEdit:I=>c(I.agent),boundInfo:Ne(w,k.agent)},k.agent))})]}),p&&e.jsx(Ue,{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:p}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>{P()},children:l("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.profilesTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.profilesHint})]})}),e.jsx(dt,{snapshot:w})]}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.modelsTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.modelsHint})]})}),e.jsx(Ke,{snapshot:w,localBackends:u.backends})]}),e.jsxs("section",{className:"space-y-3 pt-4",children:[e.jsx("div",{className:"flex items-baseline justify-between border-t border-edge pt-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight text-fg",children:d.localTitle}),e.jsx("div",{className:"mt-0.5 text-[13px] leading-relaxed text-fg-4",children:d.localHint})]})}),e.jsx(tt,{snapshot:u,onConnected:fe})]}),e.jsx(ee,{open:!!W,onClose:()=>c(null),wide:!0,children:W&&ae&&e.jsxs(e.Fragment,{children:[e.jsx(te,{title:d.configModalTitle(ae.label),description:ae.advantageKey?l(ae.advantageKey):void 0,onClose:()=>c(null)}),e.jsx(bt,{agentId:W.agent,agentStatus:W,boundInfo:Ne(w,W.agent),copy:d,layer:w,toast:t,t:l,onSaved:async()=>{await fe(),c(null)},onCancel:()=>c(null)})]})}),e.jsxs(ee,{open:x,onClose:()=>N(!1),children:[e.jsx(te,{title:d.defaultsEditTitle,description:d.defaultsEditHint,onClose:()=>N(!1)}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(H,{children:d.defaultAgent}),e.jsx(q,{value:R,options:Se,onChange:k=>y(k),disabled:E||!ue,placeholder:d.notInstalled})]})}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(_,{variant:"ghost",onClick:()=>N(!1),children:l("modal.cancel")}),e.jsx(_,{variant:"primary",disabled:E||R===U,onClick:()=>{Ae()},children:l(E?"config.validating":"modal.save")})]})]})]})}export{At as AgentTab,At as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./react-vendor-DTcmqLiz.js";import{c as g}from"./index-DEXOVIim.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",m="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20fill='%23fff'%20d='M32%2030h36c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H56l-14%2012%204-12h-14c-8%200-14-6-14-14V44c0-8%206-14%2014-14Z'/%3e%3cpath%20fill='%23fff'%20opacity='.55'%20d='M56%2054h32c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H80l-14%2012%204-12h-14c-8%200-14-6-14-14V68c0-8%206-14%2014-14Z'/%3e%3ccircle%20cx='44'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='60'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='72'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3ccircle%20cx='86'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3c/svg%3e",v="/assets/playwright-BldPFZgC.ico",C="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",L="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",B="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",y="/assets/hermes-BAarh-tH.png",u="/assets/openrouter-CsJ_bD5Q.ico",D="/assets/anthropic-BAdojD7P.ico",E="/assets/deepseek-BeYNZEk0.ico",F="/assets/qwen-xykkX0_y.png",b="/assets/doubao-DloFDuFR.png",z="data:image/png;base64,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",J="/assets/minimax-PuEGTfrF.ico",k="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='currentColor'%20aria-label='OpenAI'%3e%3cpath%20d='M22.282%209.821a5.985%205.985%200%200%200-.516-4.91%206.046%206.046%200%200%200-6.51-2.9A6.065%206.065%200%200%200%204.981%204.18a5.985%205.985%200%200%200-3.998%202.9%206.046%206.046%200%200%200%20.743%207.097%205.98%205.98%200%200%200%20.51%204.911%206.051%206.051%200%200%200%206.515%202.9A5.985%205.985%200%200%200%2013.26%2024a6.056%206.056%200%200%200%205.772-4.206%205.99%205.99%200%200%200%203.997-2.9%206.056%206.056%200%200%200-.747-7.073zM13.26%2022.43a4.476%204.476%200%200%201-2.876-1.04l.141-.081%204.779-2.758a.795.795%200%200%200%20.392-.681v-6.737l2.02%201.168a.071.071%200%200%201%20.038.052v5.583a4.504%204.504%200%200%201-4.494%204.494zM3.6%2018.304a4.47%204.47%200%200%201-.535-3.014l.142.085%204.783%202.759a.771.771%200%200%200%20.78%200l5.843-3.369v2.332a.08.08%200%200%201-.033.062L9.74%2019.95a4.5%204.5%200%200%201-6.14-1.646zM2.34%207.896a4.485%204.485%200%200%201%202.366-1.973V11.6a.766.766%200%200%200%20.388.677l5.815%203.355-2.02%201.168a.076.076%200%200%201-.071%200l-4.83-2.786A4.504%204.504%200%200%201%202.34%207.872zm16.597%203.855l-5.833-3.387L15.119%207.2a.076.076%200%200%201%20.071%200l4.83%202.791a4.494%204.494%200%200%201-.676%208.105v-5.678a.79.79%200%200%200-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776%200%200%200-.785%200L9.409%209.23V6.897a.066.066%200%200%201%20.028-.061l4.83-2.787a4.5%204.5%200%200%201%206.68%204.66zm-12.64%204.135l-2.02-1.164a.08.08%200%200%201-.038-.057V6.075a4.5%204.5%200%200%201%207.375-3.453l-.142.08L8.704%205.46a.795.795%200%200%200-.393.681zm1.097-2.365l2.602-1.5%202.607%201.5v3l-2.597%201.5-2.607-1.5z'/%3e%3c/svg%3e",I="/assets/ollama-Bt9O-2K_.png",Q="/assets/mlx-DhWwjtMw.png",P={claude:a,codex:h,gemini:r,telegram:A,feishu:n,weixin:w,slack:x,discord:d,dingtalk:f,wecom:m,playwright:v,vscode:C,cursor:L,windsurf:p,finder:B,hermes:y,openrouter:u,anthropic:D,deepseek:E,google:r,qwen:F,doubao:b,glm:z,minimax:J,openai:k,ollama:I,mlx:Q},R={custom:{letter:"+",color:"#94a3b8",bg:"rgba(148,163,184,0.12)"}};function Z({brand:t,size:e=18,className:l}){const i=P[t];if(i)return s.jsx("img",{src:i,alt:"","aria-hidden":"true",draggable:!1,className:g("shrink-0 object-contain select-none",l),style:{width:e,height:e}});const c=R[t];if(!c)return null;const o=c.letter.length>1;return s.jsx("span",{"aria-hidden":"true",className:g("inline-flex shrink-0 items-center justify-center rounded-md font-semibold tracking-tight select-none",l),style:{width:e,height:e,background:c.bg,color:c.color,fontSize:Math.round(e*(o?.42:.55)),lineHeight:1,letterSpacing:o?"-0.02em":"normal"},children:c.letter})}export{Z as B};
|
|
1
|
+
import{j as s}from"./react-vendor-DTcmqLiz.js";import{c as g}from"./index-6-_orDYi.js";const a="data:image/png;base64,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",h="/assets/codex-DYadqqp0.png",n="/assets/feishu-C4OMrjCW.ico",r="/assets/gemini-BYkEpiWr.svg",A="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3clinearGradient%20x1='50%25'%20y1='0%25'%20x2='50%25'%20y2='100%25'%20id='linearGradient-1'%3e%3cstop%20stop-color='%2338AEEB'%20offset='0%25'%3e%3c/stop%3e%3cstop%20stop-color='%23279AD1'%20offset='100%25'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='Artboard'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20id='Oval'%20fill='url(%23linearGradient-1)'%20cx='8'%20cy='8'%20r='8'%3e%3c/circle%3e%3cpath%20d='M3.17026167,7.83635602%20C5.78750201,6.74265999%207.53273882,6.02162863%208.40597211,5.67326193%20C10.8992306,4.67860423%2011.2454541,4.53439191%2011.5831299,4.52864956%20C11.6573986,4.52743168%2011.8385417,4.55776042%2011.9798438,4.67645833%20C12.1211458,4.79515625%2012.1635786,4.87206678%2012.1755371,4.93908691%20C12.1874957,5.00610705%2012.1862759,5.21456762%2012.1744385,5.3338623%20C12.0393279,6.69547283%2011.5259342,9.83829771%2011.2285121,11.3633248%20C11.1026617,12.008621%2010.8548582,12.2249854%2010.6149558,12.2461596%20C10.0935924,12.2921758%209.69769267,11.9156852%209.19272668,11.5981993%20C8.40255458,11.1013965%208.13911734,10.9180161%207.3721185,10.4332283%20C6.48571864,9.87297217%206.85080034,9.6784879%207.35595703,9.17524981%20C7.48815894,9.04355001%209.67825076,7.04590073%209.71077046,6.86250183%20C9.7391276,6.70257812%209.7494847,6.68189389%209.67664063,6.60973958%20C9.60379655,6.53758527%209.51674192,6.54658941%209.46083149,6.55876051%20C9.38158015,6.57601267%208.17521836,7.33962686%205.84174612,8.84960308%20C5.48344358,9.08558775%205.15890428,9.20056741%204.86812819,9.19454205%20C4.54757089,9.18789957%203.93094724,9.02070014%203.47255094,8.87778221%20C2.91030922,8.70248755%202.46345069,8.609808%202.50236203,8.31210343%20C2.52262946,8.15704047%202.74526267,7.998458%203.17026167,7.83635602%20Z'%20id='Path-3'%20fill='%23FFFFFF'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",w="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20d='M42%2033c-16.569%200-30%2011.64-30%2026%200%208.084%204.283%2015.306%2011.008%2020.073L18%2095l20.832-8.102A37.33%2037.33%200%200%200%2042%2087c16.569%200%2030-11.64%2030-26S58.569%2033%2042%2033Z'%20fill='%23fff'/%3e%3cpath%20d='M85%2048c-13.807%200-25%209.402-25%2021%200%2011.598%2011.193%2021%2025%2021%202.545%200%205-.319%207.29-.91L109%2095l-4.772-12.27C109.078%2079.05%20112%2074.232%20112%2069c0-11.598-12.193-21-27-21Z'%20fill='%23fff'%20opacity='.95'/%3e%3ccircle%20cx='33'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='50'%20cy='56'%20r='4.5'%20fill='%2307C160'/%3e%3ccircle%20cx='77'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='92'%20cy='66'%20r='4'%20fill='%2307C160'/%3e%3c/svg%3e",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",m="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='28'%20fill='%2307C160'/%3e%3cpath%20fill='%23fff'%20d='M32%2030h36c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H56l-14%2012%204-12h-14c-8%200-14-6-14-14V44c0-8%206-14%2014-14Z'/%3e%3cpath%20fill='%23fff'%20opacity='.55'%20d='M56%2054h32c8%200%2014%206%2014%2014v18c0%208-6%2014-14%2014H80l-14%2012%204-12h-14c-8%200-14-6-14-14V68c0-8%206-14%2014-14Z'/%3e%3ccircle%20cx='44'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='60'%20cy='52'%20r='4'%20fill='%2307C160'/%3e%3ccircle%20cx='72'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3ccircle%20cx='86'%20cy='80'%20r='3.5'%20fill='%23fff'/%3e%3c/svg%3e",v="/assets/playwright-BldPFZgC.ico",C="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M23.15%202.587L18.21.21a1.494%201.494%200%200%200-1.705.29l-9.46%208.63-4.12-3.128a.999.999%200%200%200-1.276.057L.327%207.261A1%201%200%200%200%20.326%208.74L3.899%2012%20.326%2015.26a1%201%200%200%200%20.001%201.479L1.65%2017.94a.999.999%200%200%200%201.276.057l4.12-3.128%209.46%208.63a1.492%201.492%200%200%200%201.704.29l4.942-2.377A1.5%201.5%200%200%200%2024%2020.06V3.939a1.5%201.5%200%200%200-.85-1.352zm-5.146%2014.861L10.826%2012l7.178-5.448v10.896z'%20fill='%23007ACC'/%3e%3c/svg%3e",L="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%2319191C'/%3e%3cpath%20d='M7%205l10%207-4.5%201.5L15.5%2019l-2.2.8-3-5.5L7%2017z'%20fill='%23fff'/%3e%3c/svg%3e",p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%230BA48A'/%3e%3cpath%20d='M8%2018l2-12h2.5l-1.2%205h4.2L10%2018H8zm3.5-3.5l3-7.5'%20fill='%23fff'%20fill-rule='evenodd'/%3e%3c/svg%3e",B="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3crect%20width='24'%20height='24'%20rx='5.5'%20fill='%234A90D9'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='12'%20rx='1.5'%20fill='%236DB3F2'/%3e%3crect%20x='5'%20y='5'%20width='14'%20height='3.5'%20rx='1.5'%20fill='%233D7ABF'/%3e%3ccircle%20cx='8.5'%20cy='6.8'%20r='.8'%20fill='%23FF5F57'/%3e%3ccircle%20cx='11'%20cy='6.8'%20r='.8'%20fill='%23FEBC2E'/%3e%3ccircle%20cx='13.5'%20cy='6.8'%20r='.8'%20fill='%2328C840'/%3e%3crect%20x='7'%20y='10.5'%20width='10'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.7'/%3e%3crect%20x='7'%20y='13'%20width='7'%20height='1'%20rx='.5'%20fill='%23fff'%20opacity='.5'/%3e%3c/svg%3e",y="/assets/hermes-BAarh-tH.png",u="/assets/openrouter-CsJ_bD5Q.ico",D="/assets/anthropic-BAdojD7P.ico",E="/assets/deepseek-BeYNZEk0.ico",F="/assets/qwen-xykkX0_y.png",b="/assets/doubao-DloFDuFR.png",z="data:image/png;base64,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",J="/assets/minimax-PuEGTfrF.ico",k="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='currentColor'%20aria-label='OpenAI'%3e%3cpath%20d='M22.282%209.821a5.985%205.985%200%200%200-.516-4.91%206.046%206.046%200%200%200-6.51-2.9A6.065%206.065%200%200%200%204.981%204.18a5.985%205.985%200%200%200-3.998%202.9%206.046%206.046%200%200%200%20.743%207.097%205.98%205.98%200%200%200%20.51%204.911%206.051%206.051%200%200%200%206.515%202.9A5.985%205.985%200%200%200%2013.26%2024a6.056%206.056%200%200%200%205.772-4.206%205.99%205.99%200%200%200%203.997-2.9%206.056%206.056%200%200%200-.747-7.073zM13.26%2022.43a4.476%204.476%200%200%201-2.876-1.04l.141-.081%204.779-2.758a.795.795%200%200%200%20.392-.681v-6.737l2.02%201.168a.071.071%200%200%201%20.038.052v5.583a4.504%204.504%200%200%201-4.494%204.494zM3.6%2018.304a4.47%204.47%200%200%201-.535-3.014l.142.085%204.783%202.759a.771.771%200%200%200%20.78%200l5.843-3.369v2.332a.08.08%200%200%201-.033.062L9.74%2019.95a4.5%204.5%200%200%201-6.14-1.646zM2.34%207.896a4.485%204.485%200%200%201%202.366-1.973V11.6a.766.766%200%200%200%20.388.677l5.815%203.355-2.02%201.168a.076.076%200%200%201-.071%200l-4.83-2.786A4.504%204.504%200%200%201%202.34%207.872zm16.597%203.855l-5.833-3.387L15.119%207.2a.076.076%200%200%201%20.071%200l4.83%202.791a4.494%204.494%200%200%201-.676%208.105v-5.678a.79.79%200%200%200-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776%200%200%200-.785%200L9.409%209.23V6.897a.066.066%200%200%201%20.028-.061l4.83-2.787a4.5%204.5%200%200%201%206.68%204.66zm-12.64%204.135l-2.02-1.164a.08.08%200%200%201-.038-.057V6.075a4.5%204.5%200%200%201%207.375-3.453l-.142.08L8.704%205.46a.795.795%200%200%200-.393.681zm1.097-2.365l2.602-1.5%202.607%201.5v3l-2.597%201.5-2.607-1.5z'/%3e%3c/svg%3e",I="/assets/ollama-Bt9O-2K_.png",Q="/assets/mlx-DhWwjtMw.png",P={claude:a,codex:h,gemini:r,telegram:A,feishu:n,weixin:w,slack:x,discord:d,dingtalk:f,wecom:m,playwright:v,vscode:C,cursor:L,windsurf:p,finder:B,hermes:y,openrouter:u,anthropic:D,deepseek:E,google:r,qwen:F,doubao:b,glm:z,minimax:J,openai:k,ollama:I,mlx:Q},R={custom:{letter:"+",color:"#94a3b8",bg:"rgba(148,163,184,0.12)"}};function Z({brand:t,size:e=18,className:l}){const i=P[t];if(i)return s.jsx("img",{src:i,alt:"","aria-hidden":"true",draggable:!1,className:g("shrink-0 object-contain select-none",l),style:{width:e,height:e}});const c=R[t];if(!c)return null;const o=c.letter.length>1;return s.jsx("span",{"aria-hidden":"true",className:g("inline-flex shrink-0 items-center justify-center rounded-md font-semibold tracking-tight select-none",l),style:{width:e,height:e,background:c.bg,color:c.color,fontSize:Math.round(e*(o?.42:.55)),lineHeight:1,letterSpacing:o?"-0.02em":"normal"},children:c.letter})}export{Z as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-
|
|
1
|
+
import{r,j as e}from"./react-vendor-DTcmqLiz.js";import{a as I,k as P,S as z}from"./index-6-_orDYi.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};
|