@jiangxiaosheng/digital-agent-platform 1.0.4 → 1.0.5
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/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +63 -59
- package/.next/app-path-routes-manifest.json +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_1bmmeh3 +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/1.pack +0 -0
- package/.next/cache/webpack/client-production/5.pack +0 -0
- package/.next/cache/webpack/client-production/7.pack +0 -0
- package/.next/cache/webpack/client-production/8.pack +0 -0
- package/.next/cache/webpack/client-production/9.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/edge-server-production/1.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/1.pack +0 -0
- package/.next/cache/webpack/server-production/3.pack +0 -0
- package/.next/cache/webpack/server-production/4.pack +0 -0
- package/.next/cache/webpack/server-production/5.pack +0 -0
- package/.next/cache/webpack/server-production/6.pack +0 -0
- package/.next/cache/webpack/server-production/7.pack +0 -0
- package/.next/cache/webpack/server-production/8.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/server/app/[locale]/agents/[id]/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/agents/[id]/edit/page.js +1 -1
- package/.next/server/app/[locale]/agents/[id]/edit/page.js.nft.json +1 -1
- package/.next/server/app/[locale]/agents/[id]/edit/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/agents/new/page.js +1 -1
- package/.next/server/app/[locale]/agents/new/page.js.nft.json +1 -1
- package/.next/server/app/[locale]/agents/new/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/agents/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/knowledge/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[locale]/settings/page.js +1 -1
- package/.next/server/app/[locale]/settings/page.js.nft.json +1 -1
- package/.next/server/app/[locale]/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth-config/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/bash-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/chat/[agentId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env-vars/[key]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env-vars/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env-vars/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/file-serve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/knowledge/[id]/documents/[docId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/knowledge/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/knowledge/[id]/upload/route.js +1 -1
- package/.next/server/app/api/knowledge/[id]/upload/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/knowledge/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[agentId]/[sessionId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[agentId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/voice-provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace-files/route_client-reference-manifest.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +12 -12
- package/.next/server/chunks/1354.js +1 -0
- package/.next/server/chunks/7420.js +1 -0
- package/.next/server/chunks/7555.js +1 -0
- package/.next/server/chunks/9576.js +1 -0
- package/.next/server/middleware-manifest.json +4 -4
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/static/chunks/3763-85d191447a96df85.js +1 -0
- package/.next/static/chunks/5822-2ca912318cc34b52.js +1 -0
- package/.next/static/chunks/5964-cdb47df650c9e359.js +1 -0
- package/.next/static/chunks/6009-1f2b513c3fe454c1.js +1 -0
- package/.next/static/chunks/app/[locale]/agents/[id]/edit/{page-8d0cc73c7aff7774.js → page-74a70d27b56ead9b.js} +1 -1
- package/.next/static/chunks/app/[locale]/agents/new/{page-aeaa197c0ccfd2f9.js → page-11833508212d4d80.js} +1 -1
- package/.next/static/chunks/app/[locale]/knowledge/{page-7b4b6aa0a07d7da3.js → page-4928374e08e30a81.js} +1 -1
- package/.next/static/chunks/app/[locale]/settings/page-472b2cd8df49bf94.js +1 -0
- package/.next/trace +4 -4
- package/package.json +1 -1
- package/src/app/[locale]/settings/page.tsx +3 -3
- package/src/components/agents/model-selector.tsx +6 -0
- package/.next/server/chunks/1285.js +0 -1
- package/.next/server/chunks/2112.js +0 -1
- package/.next/server/chunks/4125.js +0 -1
- package/.next/static/chunks/2733-714d0e6cd51477c7.js +0 -1
- package/.next/static/chunks/3923-e04a628626d77a16.js +0 -1
- package/.next/static/chunks/6742-ad22486f7c4c8592.js +0 -1
- package/.next/static/chunks/app/[locale]/settings/page-71d67c3b9f712584.js +0 -1
- /package/.next/static/{0f9LzcIDG_ySmdh1lmd-C → rUwWYP4-J64RRKJv93Ihp}/_buildManifest.js +0 -0
- /package/.next/static/{0f9LzcIDG_ySmdh1lmd-C → rUwWYP4-J64RRKJv93Ihp}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2455],{3821:(e,s,a)=>{Promise.resolve().then(a.bind(a,9789))},5765:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(7401).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},4505:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(7401).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},3473:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(7401).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},1773:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(7401).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},5686:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(7401).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},9789:(e,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>O});var t=a(5155),r=a(2115),l=a(7266),n=a(7113),i=a(6046),d=a(4505),c=a(8867),o=a(7401);let m=(0,o.A)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var x=a(3473),h=a(1719),u=a(6967),p=a(5686);let v=(0,o.A)("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),g=(0,o.A)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),j=(0,o.A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var y=a(1773),b=a(6609),N=a(3312),f=a(3900),k=a(8986),w=a(488),C=a(2884),S=a(7528),A=a(5121),E=a(1567),T=a(853),K=a(5765);let I=(0,o.A)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);var M=a(6754),z=a(1344);function B(e){let{enabledSkills:s,onChange:a}=e,[l,n]=(0,r.useState)([]),[i,c]=(0,r.useState)(!1),[o,m]=(0,r.useState)(!1),h=(0,r.useCallback)(()=>{c(!0),fetch("/api/skills").then(e=>e.json()).then(n).finally(()=>c(!1))},[]);(0,r.useEffect)(()=>{h()},[h]);let u=async e=>{await fetch("/api/skills/".concat(encodeURIComponent(e)),{method:"DELETE"}),n(s=>s.filter(s=>s.name!==e)),a&&s&&a(s.filter(s=>s!==e))};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"text-sm text-muted-foreground",children:["已安装 ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:l.length})," 个 Skill"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(N.$,{variant:"ghost",size:"sm",onClick:h,disabled:i,className:"gap-1.5 h-8",children:[(0,t.jsx)(y.A,{className:(0,E.cn)("h-3.5 w-3.5",i&&"animate-spin")}),"刷新"]}),(0,t.jsxs)(N.$,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-1.5 h-8",children:[(0,t.jsx)(x.A,{className:"h-3.5 w-3.5"}),"安装 Skill"]})]})]}),i?(0,t.jsxs)("div",{className:"flex items-center justify-center py-10 text-muted-foreground text-sm",children:[(0,t.jsx)(d.A,{className:"h-4 w-4 animate-spin mr-2"}),"加载中…"]}):0===l.length?(0,t.jsxs)("div",{className:"rounded-xl border border-dashed p-10 text-center text-sm text-muted-foreground",children:[(0,t.jsx)("p",{className:"mb-2",children:"还没有安装任何 Skill"}),(0,t.jsxs)(N.$,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-1.5",children:[(0,t.jsx)(x.A,{className:"h-3.5 w-3.5"}),"安装第一个 Skill"]})]}):(0,t.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,t.jsxs)("div",{className:"group flex items-start gap-3 rounded-xl border p-3.5 hover:bg-secondary/20 transition-colors",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"font-mono text-sm font-medium",children:e.name}),e.hasSetup&&(0,t.jsx)(A.E,{variant:"outline",className:"text-[10px] h-4 px-1.5 font-normal",children:"含 Setup"})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.description||"暂无描述"}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/60 mt-0.5 font-mono truncate",children:e.filePath})]}),(0,t.jsx)("button",{type:"button",onClick:()=>u(e.name),title:"卸载",className:"opacity-0 group-hover:opacity-100 p-1.5 rounded-lg text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-all shrink-0",children:(0,t.jsx)(p.A,{className:"h-4 w-4"})})]},e.name))}),(0,t.jsx)(P,{open:o,onClose:()=>m(!1),onInstalled:h,installed:l})]})}function P(e){let{open:s,onClose:a,onInstalled:l,installed:n}=e,i=new Set(n.map(e=>e.name)),[o,m]=(0,r.useState)("search"),[x,h]=(0,r.useState)(""),[u,p]=(0,r.useState)([]),[v,g]=(0,r.useState)(!1),[y,b]=(0,r.useState)(""),[w,S]=(0,r.useState)(null),[B,P]=(0,r.useState)({}),[J,L]=(0,r.useState)(""),[O,D]=(0,r.useState)(""),[$,V]=(0,r.useState)(""),[U,_]=(0,r.useState)("idle"),[q,R]=(0,r.useState)(""),F=(0,r.useRef)(null),H=(0,r.useCallback)(async e=>{if(!e.trim()){p([]);return}g(!0),b("");try{var s,a;let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim(),limit:30})}),r=await t.json();if(!t.ok)throw Error(null!==(s=r.error)&&void 0!==s?s:"HTTP ".concat(t.status));p(null!==(a=r.results)&&void 0!==a?a:[])}catch(e){b(String(e)),p([])}finally{g(!1)}},[]);(0,r.useEffect)(()=>{if("search"===o)return F.current&&clearTimeout(F.current),F.current=setTimeout(()=>H(x),400),()=>{F.current&&clearTimeout(F.current)}},[x,o,H]);let X=async e=>{S(e);try{var s;let a=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:e})}),t=await a.json();if(!a.ok||!t.success)throw Error(null!==(s=t.error)&&void 0!==s?s:"安装失败");P(s=>({...s,[e]:"ok"})),l()}catch(s){P(s=>({...s,[e]:"err"})),console.error(s)}finally{S(null)}},W=async()=>{_("loading"),R("");try{var e;let s="url"===o?{url:J.trim()}:{content:O.trim(),name:$.trim()},t=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await t.json();if(!t.ok)throw Error(null!==(e=r.error)&&void 0!==e?e:"安装失败");_("ok"),l(),setTimeout(()=>{a(),G()},1200)}catch(e){_("err"),R(String(e))}},G=()=>{h(""),p([]),b(""),L(""),D(""),V(""),_("idle"),R(""),P({})};return(0,t.jsx)(z.lG,{open:s,onOpenChange:e=>{e||(a(),G())},children:(0,t.jsxs)(z.Cf,{className:"max-w-xl max-h-[85vh] flex flex-col",children:[(0,t.jsx)(z.c7,{children:(0,t.jsx)(z.L3,{children:"安装 Skill"})}),(0,t.jsxs)(C.tU,{value:o,onValueChange:e=>m(e),className:"flex-1 flex flex-col min-h-0",children:[(0,t.jsxs)(C.j7,{className:"shrink-0",children:[(0,t.jsx)(C.Xi,{value:"search",children:"\uD83D\uDD0D 社区搜索"}),(0,t.jsx)(C.Xi,{value:"url",children:"\uD83D\uDD17 URL 安装"}),(0,t.jsx)(C.Xi,{value:"paste",children:"\uD83D\uDCCB 粘贴内容"})]}),(0,t.jsxs)(C.av,{value:"search",className:"flex-1 flex flex-col min-h-0 space-y-3 mt-3",children:[(0,t.jsxs)("div",{className:"relative shrink-0",children:[(0,t.jsx)(T.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,t.jsx)(f.p,{value:x,onChange:e=>h(e.target.value),placeholder:"搜索社区 Skills,例如:web search、pdf、code review…",className:"pl-9",autoFocus:!0})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-1.5 pr-1",children:[v&&(0,t.jsxs)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:[(0,t.jsx)(d.A,{className:"h-4 w-4 animate-spin mr-2"}),"搜索中…"]}),!v&&y&&(0,t.jsx)("div",{className:"py-8 text-center text-sm text-destructive",children:y}),!v&&!y&&x&&0===u.length&&(0,t.jsxs)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:["未找到「",x,"」相关 Skill"]}),!v&&!y&&!x&&(0,t.jsxs)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:["输入关键词搜索 ",(0,t.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"skills.sh"})," 社区 Skills"]}),u.map(e=>{let s=B[e.package],a=w===e.package,r=i.has(e.name);return(0,t.jsxs)("div",{className:(0,E.cn)("flex items-start gap-3 rounded-xl border p-3 transition-colors",r?"bg-[#57BE6B]/5 border-[#57BE6B]/30":"hover:bg-secondary/30"),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"font-mono text-sm font-medium",children:e.name}),r&&(0,t.jsx)(A.E,{className:"text-[10px] h-4 px-1.5 bg-[#57BE6B]/15 text-[#57BE6B] border-0 font-normal",children:"已安装"}),e.installs>0&&(0,t.jsxs)("span",{className:"text-[10px] text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["↓ ",e.installsDisplay]})]}),(0,t.jsx)("p",{className:"text-[11px] font-mono text-muted-foreground/70 mt-0.5",children:e.package}),(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-blue-500 hover:underline flex items-center gap-0.5 mt-0.5 w-fit",children:[(0,t.jsx)(K.A,{className:"h-2.5 w-2.5"}),"查看详情"]})]}),r?(0,t.jsxs)("div",{className:"flex items-center gap-1 h-7 px-2 text-xs text-[#57BE6B] shrink-0",children:[(0,t.jsx)(c.A,{className:"h-3.5 w-3.5"}),"已安装"]}):(0,t.jsx)(N.$,{size:"sm",variant:"ok"===s?"ghost":"outline",className:(0,E.cn)("h-7 text-xs shrink-0 gap-1 min-w-[56px]","ok"===s&&"text-green-600 dark:text-green-400"),disabled:a||"ok"===s,onClick:()=>X(e.package),children:a?(0,t.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):"ok"===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.A,{className:"h-3 w-3"}),"已装"]}):"err"===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j,{className:"h-3 w-3 text-destructive"}),"失败"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I,{className:"h-3 w-3"}),"安装"]})})]},e.package)})]})]}),(0,t.jsxs)(C.av,{value:"url",className:"space-y-3 mt-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground",children:"SKILL.md 的原始 URL"}),(0,t.jsx)(f.p,{value:J,onChange:e=>L(e.target.value),placeholder:"https://raw.githubusercontent.com/user/repo/main/skill/SKILL.md",className:"font-mono text-sm"}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"支持 GitHub raw 链接或任意可访问的 markdown 地址"})]}),"ok"===U&&(0,t.jsxs)("p",{className:"text-sm text-green-600 flex items-center gap-1",children:[(0,t.jsx)(c.A,{className:"h-4 w-4"}),"安装成功!"]}),"err"===U&&(0,t.jsxs)("p",{className:"text-sm text-destructive flex items-center gap-1",children:[(0,t.jsx)(j,{className:"h-4 w-4"}),q]}),(0,t.jsxs)(z.Es,{children:[(0,t.jsx)(N.$,{variant:"outline",onClick:()=>{a(),G()},children:"取消"}),(0,t.jsxs)(N.$,{onClick:W,disabled:"loading"===U||!J.trim(),children:["loading"===U&&(0,t.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}),"安装"]})]})]}),(0,t.jsxs)(C.av,{value:"paste",className:"space-y-3 mt-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground",children:"Skill 名称(slug)"}),(0,t.jsx)(f.p,{value:$,onChange:e=>V(e.target.value),placeholder:"my-skill",className:"font-mono text-sm"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground",children:"SKILL.md 内容"}),(0,t.jsx)(M.T,{value:O,onChange:e=>D(e.target.value),placeholder:"---\nname: my-skill\ndescription: 描述这个 skill 的用途\n---\n\n# My Skill\n\n...",rows:8,className:"font-mono text-xs"})]}),"ok"===U&&(0,t.jsxs)("p",{className:"text-sm text-green-600 flex items-center gap-1",children:[(0,t.jsx)(c.A,{className:"h-4 w-4"}),"安装成功!"]}),"err"===U&&(0,t.jsxs)("p",{className:"text-sm text-destructive flex items-center gap-1",children:[(0,t.jsx)(j,{className:"h-4 w-4"}),q]}),(0,t.jsxs)(z.Es,{children:[(0,t.jsx)(N.$,{variant:"outline",onClick:()=>{a(),G()},children:"取消"}),(0,t.jsxs)(N.$,{onClick:W,disabled:"loading"===U||!O.trim(),children:["loading"===U&&(0,t.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}),"安装"]})]})]})]})]})})}var J=a(2935);let L=[{value:"anthropic-messages",label:"Anthropic Messages"},{value:"openai-responses",label:"OpenAI Responses"},{value:"openai-completions",label:"OpenAI Completions (Legacy)"},{value:"google-generative-ai",label:"Google Generative AI"},{value:"bedrock-converse-stream",label:"AWS Bedrock Converse"}];function O(){var e,s,a,o,h,u,p,v;let g=(0,l.useTranslations)("settings"),j=(0,l.useTranslations)("common"),{theme:y,setTheme:b}=(0,n.D)(),w=(0,l.useLocale)(),A=(0,i.useRouter)(),E=(0,i.usePathname)(),[T,K]=(0,r.useState)({}),[I,M]=(0,r.useState)({providers:{}}),[z,P]=(0,r.useState)({currentProvider:"openai",providers:{}}),[L,O]=(0,r.useState)("idle");(0,r.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{var s,a;K(null!==(s=e.auth)&&void 0!==s?s:{}),M(null!==(a=e.modelsConfig)&&void 0!==a?a:{providers:{}})}),fetch("/api/voice-provider").then(e=>e.json()).then(e=>{P(e)})},[]);let $=(0,r.useCallback)(async()=>{O("saving"),await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({auth:T,modelsConfig:I})}),await fetch("/api/voice-provider",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),O("saved"),setTimeout(()=>O("idle"),2500),await fetch("/api/models"),(0,J.Pi)()},[T,I,z]);return(0,t.jsxs)("div",{className:"p-6 max-w-3xl mx-auto",children:[(0,t.jsxs)("div",{className:"mb-6 flex items-center justify-between p-4 rounded-xl bg-white dark:bg-slate-800/50 backdrop-blur-sm border border-gray-200 dark:border-slate-700/50 neo-card",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold text-gray-900 dark:bg-gradient-to-r dark:from-cyan-400 dark:to-blue-400 dark:bg-clip-text dark:text-transparent",children:g("title")}),(0,t.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-400 mt-1",children:g("subtitle")})]}),(0,t.jsxs)(N.$,{onClick:$,disabled:"saving"===L,className:"neo-button gap-2 bg-gradient-to-r from-blue-500 to-indigo-500 dark:from-cyan-600 dark:to-blue-600 hover:from-blue-600 hover:to-indigo-600 dark:hover:from-cyan-500 dark:hover:to-blue-500 text-white border-0 shadow-lg hover:shadow-blue-500/30 dark:hover:shadow-cyan-500/50 transition-all duration-200 hover:scale-105",children:["saving"===L?(0,t.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):"saved"===L?(0,t.jsx)(c.A,{className:"h-4 w-4"}):(0,t.jsx)(m,{className:"h-4 w-4"}),"saving"===L?"保存中…":"saved"===L?"已保存":j("save")]})]}),(0,t.jsxs)(C.tU,{defaultValue:"providers",children:[(0,t.jsxs)(C.j7,{className:"mb-6 neo-card bg-gray-50 dark:bg-slate-800/50 backdrop-blur-sm border border-gray-200 dark:border-slate-700/50 p-1",children:[(0,t.jsx)(C.Xi,{value:"providers",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"内置提供商"}),(0,t.jsx)(C.Xi,{value:"custom",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"自定义提供商"}),(0,t.jsx)(C.Xi,{value:"voice",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"语音供应商"}),(0,t.jsx)(C.Xi,{value:"envvars",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"环境变量"}),(0,t.jsx)(C.Xi,{value:"skills",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"Skills 管理"}),(0,t.jsx)(C.Xi,{value:"appearance",className:"data-[state=active]:neo-card-inset data-[state=active]:bg-blue-100 data-[state=active]:text-blue-700 dark:data-[state=active]:bg-gradient-to-r dark:data-[state=active]:from-cyan-600 dark:data-[state=active]:to-blue-600 dark:data-[state=active]:text-white hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-all duration-200",children:"外观 & 语言"})]}),(0,t.jsx)(C.av,{value:"providers",className:"space-y-4",children:(0,t.jsx)(_,{apiKeys:T,onKeysChange:K,onSave:$})}),(0,t.jsxs)(C.av,{value:"custom",className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{children:(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["添加兼容 OpenAI / Anthropic API 的自定义提供商。配置存储在"," ",(0,t.jsx)("code",{className:"font-mono text-xs bg-secondary px-1 rounded",children:"~/.pi/agent/models.json"}),"。"]})}),(0,t.jsxs)(N.$,{variant:"outline",size:"sm",className:"neo-button hover:scale-105 transition-transform",onClick:()=>{let e="custom-provider-".concat(Date.now());M(s=>({providers:{...s.providers,[e]:{baseUrl:"",api:"openai-completions",apiKey:"",models:[]}}}))},children:[(0,t.jsx)(x.A,{className:"mr-2 h-4 w-4"}),"添加提供商"]})]}),0===Object.keys(I.providers).length?(0,t.jsx)("div",{className:"rounded-lg border border-dashed p-8 text-center text-muted-foreground text-sm",children:"暂无自定义提供商。点击「添加提供商」创建一个。"}):(0,t.jsx)("div",{className:"space-y-4",children:Object.entries(I.providers).map(e=>{let[s,a]=e;return(0,t.jsx)(D,{name:s,provider:a,onChange:e=>M(a=>({providers:{...a.providers,[s]:e}})),onRename:e=>{e!==s&&e&&M(a=>{let{[s]:t,...r}=a.providers;return{providers:{...r,[e]:t}}})},onDelete:()=>M(e=>{let{[s]:a,...t}=e.providers;return{providers:t}})},s)})})]}),(0,t.jsxs)(C.av,{value:"voice",className:"space-y-4",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["选择一个语音供应商并配置API密钥,全局生效。配置存储在"," ",(0,t.jsx)("code",{className:"font-mono text-xs bg-secondary px-1 rounded",children:"~/.pi/agent/voice-provider.json"}),"。"]})}),(0,t.jsxs)("div",{className:"neo-card p-4 bg-white dark:bg-slate-800/50 rounded-xl",children:[(0,t.jsx)(k.J,{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 block",children:"当前语音供应商"}),(0,t.jsxs)(S.l6,{value:z.currentProvider,onValueChange:e=>P(s=>({...s,currentProvider:e})),children:[(0,t.jsx)(S.bq,{className:"neo-card-inset",children:(0,t.jsx)(S.yv,{})}),(0,t.jsxs)(S.gC,{children:[(0,t.jsx)(S.eb,{value:"openai",children:"OpenAI TTS"}),(0,t.jsx)(S.eb,{value:"aliyun",children:"阿里云语音合成"}),(0,t.jsx)(S.eb,{value:"tencent",children:"腾讯云TTS"}),(0,t.jsx)(S.eb,{value:"baidu",children:"百度语音合成"})]})]})]}),"openai"===z.currentProvider&&(0,t.jsxs)("div",{className:"neo-card p-4 bg-white dark:bg-slate-800/50 rounded-xl space-y-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"OpenAI TTS 配置"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"API Key"}),(0,t.jsx)(f.p,{type:"password",placeholder:"sk-...",value:(null===(e=z.providers.openai)||void 0===e?void 0:e.apiKey)||"",onChange:e=>P(s=>({...s,providers:{...s.providers,openai:{...s.providers.openai,apiKey:e.target.value}}}))})]})]}),"aliyun"===z.currentProvider&&(0,t.jsxs)("div",{className:"neo-card p-4 bg-white dark:bg-slate-800/50 rounded-xl space-y-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"阿里云配置"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"AppKey"}),(0,t.jsx)(f.p,{placeholder:"...",value:(null===(s=z.providers.aliyun)||void 0===s?void 0:s.appKey)||"",onChange:e=>P(s=>{var a,t;return{...s,providers:{...s.providers,aliyun:{...s.providers.aliyun,appKey:e.target.value,accessKeyId:(null===(a=s.providers.aliyun)||void 0===a?void 0:a.accessKeyId)||"",accessKeySecret:(null===(t=s.providers.aliyun)||void 0===t?void 0:t.accessKeySecret)||""}}}})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"Access Key ID"}),(0,t.jsx)(f.p,{type:"password",placeholder:"...",value:(null===(a=z.providers.aliyun)||void 0===a?void 0:a.accessKeyId)||"",onChange:e=>P(s=>{var a,t;return{...s,providers:{...s.providers,aliyun:{...s.providers.aliyun,appKey:(null===(a=s.providers.aliyun)||void 0===a?void 0:a.appKey)||"",accessKeyId:e.target.value,accessKeySecret:(null===(t=s.providers.aliyun)||void 0===t?void 0:t.accessKeySecret)||""}}}})})]}),(0,t.jsxs)("div",{className:"space-y-2 col-span-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"Access Key Secret"}),(0,t.jsx)(f.p,{type:"password",placeholder:"...",value:(null===(o=z.providers.aliyun)||void 0===o?void 0:o.accessKeySecret)||"",onChange:e=>P(s=>{var a,t;return{...s,providers:{...s.providers,aliyun:{...s.providers.aliyun,appKey:(null===(a=s.providers.aliyun)||void 0===a?void 0:a.appKey)||"",accessKeyId:(null===(t=s.providers.aliyun)||void 0===t?void 0:t.accessKeyId)||"",accessKeySecret:e.target.value}}}})})]})]})]}),"tencent"===z.currentProvider&&(0,t.jsxs)("div",{className:"neo-card p-4 bg-white dark:bg-slate-800/50 rounded-xl space-y-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"腾讯云配置"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"Secret ID"}),(0,t.jsx)(f.p,{type:"password",placeholder:"AKID...",value:(null===(h=z.providers.tencent)||void 0===h?void 0:h.secretId)||"",onChange:e=>P(s=>{var a;return{...s,providers:{...s.providers,tencent:{...s.providers.tencent,secretId:e.target.value,secretKey:(null===(a=s.providers.tencent)||void 0===a?void 0:a.secretKey)||""}}}})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"Secret Key"}),(0,t.jsx)(f.p,{type:"password",placeholder:"...",value:(null===(u=z.providers.tencent)||void 0===u?void 0:u.secretKey)||"",onChange:e=>P(s=>{var a;return{...s,providers:{...s.providers,tencent:{...s.providers.tencent,secretId:(null===(a=s.providers.tencent)||void 0===a?void 0:a.secretId)||"",secretKey:e.target.value}}}})})]})]})]}),"baidu"===z.currentProvider&&(0,t.jsxs)("div",{className:"neo-card p-4 bg-white dark:bg-slate-800/50 rounded-xl space-y-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"百度配置"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"API Key"}),(0,t.jsx)(f.p,{type:"password",placeholder:"...",value:(null===(p=z.providers.baidu)||void 0===p?void 0:p.apiKey)||"",onChange:e=>P(s=>{var a;return{...s,providers:{...s.providers,baidu:{...s.providers.baidu,apiKey:e.target.value,secretKey:(null===(a=s.providers.baidu)||void 0===a?void 0:a.secretKey)||""}}}})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(k.J,{className:"text-xs",children:"Secret Key"}),(0,t.jsx)(f.p,{type:"password",placeholder:"...",value:(null===(v=z.providers.baidu)||void 0===v?void 0:v.secretKey)||"",onChange:e=>P(s=>{var a;return{...s,providers:{...s.providers,baidu:{...s.providers.baidu,apiKey:(null===(a=s.providers.baidu)||void 0===a?void 0:a.apiKey)||"",secretKey:e.target.value}}}})})]})]})]})]}),(0,t.jsx)(C.av,{value:"envvars",children:(0,t.jsx)(V,{})}),(0,t.jsxs)(C.av,{value:"skills",className:"space-y-2",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["安装、卸载 Skills。Skills 存储在"," ",(0,t.jsx)("code",{className:"font-mono text-xs bg-secondary px-1 rounded",children:"~/.pi/agent/skills/"}),", 对所有数字人共享。在数字人配置中可按需启用/禁用。"]})}),(0,t.jsx)(B,{})]}),(0,t.jsxs)(C.av,{value:"appearance",className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{children:g("theme")}),(0,t.jsxs)(S.l6,{value:y,onValueChange:b,children:[(0,t.jsx)(S.bq,{className:"w-48",children:(0,t.jsx)(S.yv,{})}),(0,t.jsxs)(S.gC,{children:[(0,t.jsx)(S.eb,{value:"light",children:g("themeLight")}),(0,t.jsx)(S.eb,{value:"dark",children:g("themeDark")}),(0,t.jsx)(S.eb,{value:"system",children:g("themeSystem")})]})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{children:g("language")}),(0,t.jsxs)(S.l6,{value:w,onValueChange:e=>{A.push(E.replace(/^\/(zh|en)/,"/".concat(e)))},children:[(0,t.jsx)(S.bq,{className:"w-48",children:(0,t.jsx)(S.yv,{})}),(0,t.jsxs)(S.gC,{children:[(0,t.jsx)(S.eb,{value:"zh",children:"中文"}),(0,t.jsx)(S.eb,{value:"en",children:"English"})]})]})]})]})]})]})}function D(e){var s,a,l,n,i,d,o,m;let{name:y,provider:b,onChange:w,onRename:C,onDelete:T}=e,[K,I]=(0,r.useState)(!0),[M,z]=(0,r.useState)(y),[B,P]=(0,r.useState)(!1),[J,O]=(0,r.useState)({phase:"idle"}),D=(e,s)=>w({...b,[e]:s}),V=async e=>{O({phase:"testing"});try{let s=await fetch("/api/models-config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:y,provider:b,model:e})}),a=await s.json();a.ok?O({phase:"success",latencyMs:a.latencyMs,responseText:a.responseText}):O({phase:"error",message:a.error,latencyMs:a.latencyMs})}catch(e){O({phase:"error",message:String(e)})}},U=(e,s,a)=>{var t;let r=[...null!==(t=b.models)&&void 0!==t?t:[]];r[e]={...r[e],[s]:a},D("models",r)},_=e=>{var s;let a=[...null!==(s=b.models)&&void 0!==s?s:[]];a.splice(e,1),D("models",a)};return(0,t.jsxs)("div",{className:"rounded-xl border bg-card overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 cursor-pointer hover:bg-secondary/30 transition-colors",onClick:()=>I(!K),children:[K?(0,t.jsx)(h.A,{className:"h-4 w-4 text-muted-foreground"}):(0,t.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-sm font-medium flex-1 truncate",children:y}),(0,t.jsx)(A.E,{variant:"outline",className:"text-xs",children:null!==(a=b.api)&&void 0!==a?a:"—"}),(0,t.jsxs)(A.E,{variant:"secondary",className:"text-xs",children:[null!==(l=null===(s=b.models)||void 0===s?void 0:s.length)&&void 0!==l?l:0," models"]}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),T()},className:"ml-1 text-muted-foreground hover:text-destructive transition-colors",children:(0,t.jsx)(p.A,{className:"h-4 w-4"})})]}),K&&(0,t.jsxs)("div",{className:"px-4 pb-4 space-y-4 border-t",children:[(0,t.jsxs)("div",{className:"pt-4 space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"提供商名称(唯一标识)"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(f.p,{value:M,onChange:e=>z(e.target.value),className:"font-mono text-sm",placeholder:"my-custom-provider"}),M!==y&&M.trim()&&(0,t.jsx)(N.$,{size:"sm",onClick:()=>C(M.trim()),children:"重命名"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Base URL"}),(0,t.jsx)(f.p,{value:null!==(n=b.baseUrl)&&void 0!==n?n:"",onChange:e=>D("baseUrl",e.target.value||void 0),placeholder:"https://api.example.com/v1",className:"font-mono text-sm"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"API 协议"}),(0,t.jsxs)(S.l6,{value:null!==(i=b.api)&&void 0!==i?i:"openai-completions",onValueChange:e=>D("api",e),children:[(0,t.jsx)(S.bq,{children:(0,t.jsx)(S.yv,{})}),(0,t.jsx)(S.gC,{children:L.map(e=>(0,t.jsx)(S.eb,{value:e.value,children:e.label},e.value))})]})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"API Key"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(f.p,{type:B?"text":"password",value:null!==(d=b.apiKey)&&void 0!==d?d:"",onChange:e=>D("apiKey",e.target.value||void 0),placeholder:"ENV_VAR_NAME, !shell-command, 或直接填写密钥",className:"pr-10 font-mono text-sm"}),(0,t.jsx)("button",{type:"button",onClick:()=>P(!B),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:B?(0,t.jsx)(v,{className:"h-4 w-4"}):(0,t.jsx)(g,{className:"h-4 w-4"})})]}),(0,t.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["前缀 ",(0,t.jsx)("code",{className:"font-mono",children:"!"})," 运行 Shell 命令,或填写环境变量名(自动读取)"]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"模型列表"}),(0,t.jsxs)(N.$,{variant:"ghost",size:"sm",onClick:()=>{var e;D("models",[...null!==(e=b.models)&&void 0!==e?e:[],{id:"",name:"",contextWindow:128e3,maxTokens:4096,input:["text","image"],reasoning:!1,cost:{input:0,output:0}}])},className:"h-7 text-xs",children:[(0,t.jsx)(x.A,{className:"mr-1 h-3 w-3"}),"添加模型"]})]}),0===(null!==(o=b.models)&&void 0!==o?o:[]).length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded-lg",children:"暂无模型,点击「添加模型」"}):(0,t.jsx)("div",{className:"space-y-3",children:(null!==(m=b.models)&&void 0!==m?m:[]).map((e,s)=>(0,t.jsx)($,{model:e,onUpdate:(e,a)=>U(s,e,a),onDelete:()=>_(s),onTest:()=>V(e),testState:J},s))})]}),"idle"!==J.phase&&"testing"!==J.phase&&(0,t.jsxs)("div",{className:(0,E.cn)("flex items-start gap-2 rounded-lg px-3 py-2 text-sm","success"===J.phase?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"),children:["success"===J.phase?(0,t.jsx)(c.A,{className:"h-4 w-4 mt-0.5 shrink-0"}):(0,t.jsx)(j,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,t.jsx)("div",{children:"success"===J.phase?"连接成功 (".concat(J.latencyMs,"ms)").concat(J.responseText?' — "'.concat(J.responseText,'"'):""):"连接失败: ".concat(J.message).concat(J.latencyMs?" (".concat(J.latencyMs,"ms)"):"")}),(0,t.jsx)("button",{onClick:()=>O({phase:"idle"}),className:"ml-auto text-current opacity-50 hover:opacity-100",children:(0,t.jsx)(j,{className:"h-3 w-3"})})]})]})]})}function $(e){var s,a,r,l,n,i,c,o;let{model:m,onUpdate:x,onDelete:h,onTest:u,testState:v}=e,g="testing"===v.phase;return(0,t.jsxs)("div",{className:"rounded-lg border bg-secondary/20 p-3 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 grid grid-cols-2 gap-2",children:[(0,t.jsx)(f.p,{value:m.id,onChange:e=>x("id",e.target.value),placeholder:"model-id(如 gpt-4o)",className:"font-mono text-xs h-8"}),(0,t.jsx)(f.p,{value:null!==(r=m.name)&&void 0!==r?r:"",onChange:e=>x("name",e.target.value||void 0),placeholder:"显示名称(可选)",className:"text-xs h-8"})]}),(0,t.jsxs)(N.$,{variant:"ghost",size:"sm",onClick:u,disabled:!m.id||g,className:"h-8 text-xs shrink-0 gap-1",title:"测试连接",children:[g?(0,t.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):(0,t.jsx)(y.A,{className:"h-3 w-3"}),"测试"]}),(0,t.jsx)("button",{type:"button",onClick:h,className:"text-muted-foreground hover:text-destructive transition-colors",children:(0,t.jsx)(p.A,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(k.J,{className:"text-[10px] text-muted-foreground",children:"Context Window"}),(0,t.jsx)(f.p,{type:"number",value:null!==(l=m.contextWindow)&&void 0!==l?l:128e3,onChange:e=>x("contextWindow",Number(e.target.value)),className:"text-xs h-7 mt-0.5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(k.J,{className:"text-[10px] text-muted-foreground",children:"Max Output Tokens"}),(0,t.jsx)(f.p,{type:"number",value:null!==(n=m.maxTokens)&&void 0!==n?n:4096,onChange:e=>x("maxTokens",Number(e.target.value)),className:"text-xs h-7 mt-0.5"})]}),(0,t.jsx)("div",{className:"flex flex-col justify-end",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 h-7",children:[(0,t.jsx)(w.d,{id:"reasoning-".concat(m.id),checked:null!==(i=m.reasoning)&&void 0!==i&&i,onCheckedChange:e=>x("reasoning",e),className:"scale-75"}),(0,t.jsx)(k.J,{htmlFor:"reasoning-".concat(m.id),className:"text-[11px] cursor-pointer",children:"支持 Thinking"})]})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(k.J,{className:"text-[10px] text-muted-foreground",children:"输入价格 ($/1M tokens)"}),(0,t.jsx)(f.p,{type:"number",step:"0.01",value:null!==(c=null===(s=m.cost)||void 0===s?void 0:s.input)&&void 0!==c?c:0,onChange:e=>x("cost",{...m.cost,input:Number(e.target.value)}),className:"text-xs h-7 mt-0.5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(k.J,{className:"text-[10px] text-muted-foreground",children:"输出价格 ($/1M tokens)"}),(0,t.jsx)(f.p,{type:"number",step:"0.01",value:null!==(o=null===(a=m.cost)||void 0===a?void 0:a.output)&&void 0!==o?o:0,onChange:e=>x("cost",{...m.cost,output:Number(e.target.value)}),className:"text-xs h-7 mt-0.5"})]})]})]})}function V(){var e;let[s,a]=(0,r.useState)({}),[l,n]=(0,r.useState)(!0),[i,o]=(0,r.useState)(""),[m,h]=(0,r.useState)(""),[u,v]=(0,r.useState)(null),[g,k]=(0,r.useState)(""),[w,C]=(0,r.useState)(""),[S,A]=(0,r.useState)(null),[T,K]=(0,r.useState)(null),[I,M]=(0,r.useState)(!1),[z,B]=(0,r.useState)({}),P=(0,r.useCallback)(()=>{n(!0),fetch("/api/env-vars",{cache:"no-store"}).then(e=>e.json()).then(e=>{a(e),n(!1)}).catch(()=>n(!1))},[]);(0,r.useEffect)(()=>{P()},[P]);let J=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;if(C(""),!e.trim()){C("变量名不能为空");return}let a=await fetch("/api/env-vars",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e.trim(),value:s})}),t=await a.json();if(!a.ok){var r;C(null!==(r=t.error)&&void 0!==r?r:"保存失败");return}e===i&&(o(""),h("")),A(e.trim()),setTimeout(()=>A(null),2500),P(),K(null)},L=async e=>{await fetch("/api/env-vars/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:g})}),v(null),A(e),setTimeout(()=>A(null),2500),P()},O=async e=>{await fetch("/api/env-vars/".concat(encodeURIComponent(e)),{method:"DELETE"}),P(),K(null)},D=async()=>{M(!0),K(await fetch("/api/env-vars/scan").then(e=>e.json())),B({}),M(!1)},$=async e=>{var s;await J(e,null!==(s=z[e])&&void 0!==s?s:""),B(s=>{let a={...s};return delete a[e],a}),setTimeout(D,300)},V=Object.entries(s).sort((e,s)=>{let[a]=e,[t]=s;return a.localeCompare(t)}),U=null!==(e=null==T?void 0:T.summary.filter(e=>!e.stored))&&void 0!==e?e:[];return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-zinc-200 dark:border-zinc-700 bg-zinc-50 dark:bg-zinc-800/50 p-4",children:[(0,t.jsx)(b.A,{className:"h-5 w-5 text-zinc-500 shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"全局环境变量"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:["存于 ",(0,t.jsx)("code",{className:"font-mono bg-zinc-100 dark:bg-zinc-800 px-1 rounded",children:"~/.digital-agents/env.json"}),", Bash 工具执行时自动注入。"]})]}),(0,t.jsxs)(N.$,{size:"sm",variant:"outline",onClick:D,disabled:I,className:"gap-1.5 shrink-0",children:[I?(0,t.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(y.A,{className:"h-3.5 w-3.5"}),"扫描 Skill 变量"]})]}),T&&(0,t.jsxs)("div",{className:"rounded-xl border overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b bg-secondary/30",children:[(0,t.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Skill 引用的环境变量"}),(0,t.jsx)("button",{type:"button",onClick:()=>K(null),className:"text-muted-foreground hover:text-foreground text-xs",children:"关闭"})]}),(0,t.jsx)("div",{className:"p-3 space-y-2",children:0===T.summary.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"未发现 Skill 引用的环境变量"}):T.summary.map(e=>{var s;return(0,t.jsxs)("div",{className:(0,E.cn)("flex items-center gap-2 rounded-lg border px-3 py-2.5 transition-all",e.stored?"border-[#57BE6B]/40 bg-[#57BE6B]/8 dark:bg-[#57BE6B]/10":"border-amber-300 dark:border-amber-700 bg-amber-50/50 dark:bg-amber-900/10"),children:[e.stored?(0,t.jsx)(c.A,{className:"h-4 w-4 text-[#57BE6B] shrink-0"}):(0,t.jsx)("span",{className:"h-4 w-4 rounded-full border-2 border-amber-400 shrink-0 flex items-center justify-center",children:(0,t.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("code",{className:"text-xs font-mono font-semibold",children:e.name}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["引用于:",e.skills.join("、")]})]}),e.stored?(0,t.jsx)("span",{className:"text-[10px] text-[#57BE6B] shrink-0",children:"已配置"}):(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(f.p,{value:null!==(s=z[e.name])&&void 0!==s?s:"",onChange:s=>B(a=>({...a,[e.name]:s.target.value})),onKeyDown:s=>"Enter"===s.key&&$(e.name),placeholder:"输入值...",className:"h-7 w-36 text-xs font-mono"}),(0,t.jsxs)(N.$,{size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:()=>$(e.name),children:[(0,t.jsx)(x.A,{className:"h-3 w-3"}),"添加"]})]})]},e.name)})}),U.length>0&&(0,t.jsx)("div",{className:"px-4 py-2.5 border-t bg-amber-50/30 dark:bg-amber-900/10",children:(0,t.jsxs)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["⚠️ ",U.length," 个变量尚未配置 — 相关 Skill 执行时可能报错"]})})]}),(0,t.jsxs)("div",{className:"rounded-xl border p-4 space-y-3",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"手动添加变量"}),(0,t.jsxs)("div",{className:"flex gap-2 items-start",children:[(0,t.jsx)(f.p,{value:i,onChange:e=>{o(e.target.value),C("")},onKeyDown:e=>"Enter"===e.key&&J(),placeholder:"VARIABLE_NAME",className:"font-mono text-sm flex-1"}),(0,t.jsx)("span",{className:"text-muted-foreground pt-2 text-sm shrink-0",children:"="}),(0,t.jsx)(f.p,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&J(),placeholder:"value",className:"font-mono text-sm flex-1"}),(0,t.jsxs)(N.$,{size:"sm",onClick:()=>J(),className:"gap-1.5 shrink-0",children:[(0,t.jsx)(x.A,{className:"h-3.5 w-3.5"}),"添加"]})]}),w&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:w})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["已配置 (",V.length,")"]}),V.length>0&&(0,t.jsx)("button",{type:"button",onClick:async()=>{confirm("确认清空所有环境变量?")&&(await fetch("/api/env-vars",{method:"DELETE"}),P(),K(null))},className:"text-xs text-destructive hover:underline",children:"清空全部"})]}),l?(0,t.jsxs)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:[(0,t.jsx)(d.A,{className:"h-4 w-4 animate-spin mr-2"}),"加载中…"]}):0===V.length?(0,t.jsx)("div",{className:"rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground",children:"暂无环境变量。点击「扫描 Skill 变量」自动发现 Skill 所需的变量名,或手动添加。"}):V.map(e=>{let[s,a]=e;return(0,t.jsxs)("div",{className:(0,E.cn)("group flex items-center gap-2 rounded-lg border px-3 py-2.5 transition-all",S===s?"border-[#57BE6B]/60 bg-[#57BE6B]/10":"border-border hover:border-zinc-300 dark:hover:border-zinc-600"),children:[(0,t.jsx)("code",{className:"text-xs font-mono font-semibold shrink-0 min-w-[140px] truncate",children:s}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs shrink-0",children:"="}),u===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.p,{value:g,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&L(s),"Escape"===e.key&&v(null)},className:"h-7 text-xs font-mono flex-1",autoFocus:!0}),(0,t.jsx)(N.$,{size:"sm",variant:"ghost",className:"h-7 px-2 text-[#57BE6B]",onClick:()=>L(s),children:(0,t.jsx)(c.A,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(N.$,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>v(null),children:(0,t.jsx)(j,{className:"h-3.5 w-3.5"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground flex-1 truncate cursor-pointer hover:text-foreground",onClick:()=>{v(s),k(a)},title:a||"(空)",children:a||(0,t.jsx)("em",{className:"opacity-40 not-italic",children:"(空)"})}),S===s&&(0,t.jsx)("span",{className:"text-[10px] text-[#57BE6B] shrink-0",children:"已保存"}),(0,t.jsx)("button",{type:"button",className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground transition-all",onClick:()=>{v(s),k(a)},title:"编辑",children:(0,t.jsx)(y.A,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all",onClick:()=>O(s),title:"删除",children:(0,t.jsx)(p.A,{className:"h-3.5 w-3.5"})})]})]},s)})]})]})}let U={anthropic:{name:"Anthropic",placeholder:"sk-ant-api03-...",color:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800"},openai:{name:"OpenAI",placeholder:"sk-proj-...",color:"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800"},google:{name:"Google AI",placeholder:"AIzaSy...",color:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800"},groq:{name:"Groq",placeholder:"gsk_...",color:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800"},deepseek:{name:"DeepSeek",placeholder:"sk-...",color:"bg-cyan-50 dark:bg-cyan-900/20 border-cyan-200 dark:border-cyan-800"},xai:{name:"xAI (Grok)",placeholder:"xai-...",color:"bg-zinc-50 dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700"},mistral:{name:"Mistral",placeholder:"...",color:"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800"}};function _(e){var s,a;let{apiKeys:l,onKeysChange:n,onSave:i}=e,[o,m]=(0,r.useState)(""),[h,u]=(0,r.useState)(""),[v,g]=(0,r.useState)({phase:"idle"}),[b,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(null),[A,T]=(0,r.useState)(""),K=Object.entries(l).filter(e=>{let[,s]=e;return s&&""!==s.trim()}),I=Object.entries(U).filter(e=>{let[s]=e;return!l[s]}),M=async(e,s)=>{g({phase:"testing"});try{var a;let t=await fetch("/api/auth-config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,key:s})}),r=await t.json();r.ok?g({phase:"ok",ms:r.latencyMs}):g({phase:"err",msg:null!==(a=r.error)&&void 0!==a?a:"HTTP ".concat(r.status)})}catch(e){g({phase:"err",msg:String(e)})}},z=async()=>{o&&h.trim()&&await M(o,h.trim())},B=async()=>{n({...l,[o]:h.trim()}),await i(),m(""),u(""),g({phase:"idle"}),w(!1)},P=async e=>{n({...l,[e]:""}),await i()},J=async e=>{n({...l,[e]:A.trim()}),await i(),S(null),T("")};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"LLM 提供商"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:["密钥存储于 ",(0,t.jsx)("code",{className:"font-mono bg-secondary px-1 rounded",children:"~/.pi/agent/auth.json"})]})]}),!b&&(0,t.jsxs)(N.$,{variant:"outline",size:"sm",onClick:()=>w(!0),className:"gap-1.5",disabled:0===I.length,children:[(0,t.jsx)(x.A,{className:"h-3.5 w-3.5"}),"添加提供商"]})]}),0===K.length&&!b&&(0,t.jsx)("div",{className:"rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground",children:"还没有配置任何 LLM 提供商。点击「添加提供商」开始配置。"}),(0,t.jsx)("div",{className:"space-y-2",children:K.map(e=>{var s,a,r;let[l,n]=e,i=U[l],d=C===l;return(0,t.jsxs)("div",{className:(0,E.cn)("group flex items-center gap-3 rounded-xl border p-3.5 transition-all",null!==(s=null==i?void 0:i.color)&&void 0!==s?s:""),children:[(0,t.jsxs)("div",{className:"w-28 shrink-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:null!==(a=null==i?void 0:i.name)&&void 0!==a?a:l}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono",children:l})]}),d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.p,{type:"password",value:A,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J(l),"Escape"===e.key&&S(null)},placeholder:null!==(r=null==i?void 0:i.placeholder)&&void 0!==r?r:"API Key",className:"flex-1 font-mono text-xs h-8",autoFocus:!0}),(0,t.jsxs)(N.$,{size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:()=>J(l),children:[(0,t.jsx)(c.A,{className:"h-3 w-3"}),"保存"]}),(0,t.jsx)(N.$,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>S(null),children:(0,t.jsx)(j,{className:"h-3.5 w-3.5"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex-1 font-mono text-xs text-muted-foreground",children:n.startsWith("***")?n:"••••••••"+n.slice(-4)}),(0,t.jsxs)("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,t.jsx)(N.$,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>{S(l),T(n.startsWith("***")?"":n)},children:"编辑"}),(0,t.jsx)(N.$,{size:"sm",variant:"ghost",className:"h-7 px-2 text-destructive hover:text-destructive",onClick:()=>P(l),children:(0,t.jsx)(p.A,{className:"h-3.5 w-3.5"})})]})]})]},l)})}),b&&(0,t.jsxs)("div",{className:"rounded-xl border-2 border-dashed border-[#57BE6B]/50 p-4 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"text-sm font-semibold",children:"添加提供商"}),(0,t.jsx)("button",{type:"button",onClick:()=>{w(!1),g({phase:"idle"}),u(""),m("")},className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)(j,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground",children:"提供商"}),(0,t.jsxs)("select",{value:o,onChange:e=>{m(e.target.value),g({phase:"idle"})},className:"w-full h-9 rounded-md border border-input bg-white dark:bg-zinc-800 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring",children:[(0,t.jsx)("option",{value:"",children:"选择提供商…"}),I.map(e=>{let[s,a]=e;return(0,t.jsx)("option",{value:s,children:a.name},s)})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(k.J,{className:"text-xs text-muted-foreground",children:"API Key"}),(0,t.jsx)(f.p,{type:"password",value:h,onChange:e=>{u(e.target.value),g({phase:"idle"})},onKeyDown:e=>"Enter"===e.key&&z(),placeholder:o?null!==(a=null===(s=U[o])||void 0===s?void 0:s.placeholder)&&void 0!==a?a:"API Key":"先选择提供商",className:"font-mono text-sm",disabled:!o})]})]}),"idle"!==v.phase&&(0,t.jsxs)("div",{className:(0,E.cn)("flex items-center gap-2 rounded-lg px-3 py-2 text-sm","testing"===v.phase?"bg-secondary":"ok"===v.phase?"bg-[#57BE6B]/10 text-[#57BE6B]":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"),children:["testing"===v.phase&&(0,t.jsx)(d.A,{className:"h-4 w-4 animate-spin"}),"ok"===v.phase&&(0,t.jsx)(c.A,{className:"h-4 w-4"}),"err"===v.phase&&(0,t.jsx)(j,{className:"h-4 w-4"}),(0,t.jsxs)("span",{children:["testing"===v.phase&&"测试连通性中…","ok"===v.phase&&"连接成功 (".concat(v.ms,"ms) — 点击「确认添加」保存"),"err"===v.phase&&"连接失败: ".concat(v.msg)]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(N.$,{variant:"outline",className:"flex-1 gap-1.5",disabled:!o||!h.trim()||"testing"===v.phase,onClick:z,children:["testing"===v.phase?(0,t.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(y.A,{className:"h-3.5 w-3.5"}),"测试连通性"]}),"ok"===v.phase&&(0,t.jsxs)(N.$,{className:"flex-1 gap-1.5 bg-[#57BE6B] hover:bg-[#4aaa5d]",onClick:B,children:[(0,t.jsx)(c.A,{className:"h-3.5 w-3.5"}),"确认添加"]})]})]})]})}},7113:(e,s,a)=>{"use strict";a.d(s,{D:()=>o,N:()=>m});var t=a(2115),r=(e,s,a,t,r,l,n,i)=>{let d=document.documentElement,c=["light","dark"];function o(s){(Array.isArray(e)?e:[e]).forEach(e=>{let a="class"===e,t=a&&l?r.map(e=>l[e]||e):r;a?(d.classList.remove(...t),d.classList.add(l&&l[s]?l[s]:s)):d.setAttribute(e,s)}),i&&c.includes(s)&&(d.style.colorScheme=s)}if(t)o(t);else try{let e=localStorage.getItem(s)||a,t=n&&"system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e;o(t)}catch(e){}},l=["light","dark"],n="(prefers-color-scheme: dark)",i="undefined"==typeof window,d=t.createContext(void 0),c={setTheme:e=>{},themes:[]},o=()=>{var e;return null!=(e=t.useContext(d))?e:c},m=e=>t.useContext(d)?t.createElement(t.Fragment,null,e.children):t.createElement(h,{...e}),x=["light","dark"],h=e=>{let{forcedTheme:s,disableTransitionOnChange:a=!1,enableSystem:r=!0,enableColorScheme:i=!0,storageKey:c="theme",themes:o=x,defaultTheme:m=r?"system":"light",attribute:h="data-theme",value:j,children:y,nonce:b,scriptProps:N}=e,[f,k]=t.useState(()=>p(c,m)),[w,C]=t.useState(()=>"system"===f?g():f),S=j?Object.values(j):o,A=t.useCallback(e=>{let s=e;if(!s)return;"system"===e&&r&&(s=g());let t=j?j[s]:s,n=a?v(b):null,d=document.documentElement,c=e=>{"class"===e?(d.classList.remove(...S),t&&d.classList.add(t)):e.startsWith("data-")&&(t?d.setAttribute(e,t):d.removeAttribute(e))};if(Array.isArray(h)?h.forEach(c):c(h),i){let e=l.includes(m)?m:null,a=l.includes(s)?s:e;d.style.colorScheme=a}null==n||n()},[b]),E=t.useCallback(e=>{let s="function"==typeof e?e(f):e;k(s);try{localStorage.setItem(c,s)}catch(e){}},[f]),T=t.useCallback(e=>{C(g(e)),"system"===f&&r&&!s&&A("system")},[f,s]);t.useEffect(()=>{let e=window.matchMedia(n);return e.addListener(T),T(e),()=>e.removeListener(T)},[T]),t.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?k(e.newValue):E(m))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[E]),t.useEffect(()=>{A(null!=s?s:f)},[s,f]);let K=t.useMemo(()=>({theme:f,setTheme:E,forcedTheme:s,resolvedTheme:"system"===f?w:f,themes:r?[...o,"system"]:o,systemTheme:r?w:void 0}),[f,E,s,w,r,o]);return t.createElement(d.Provider,{value:K},t.createElement(u,{forcedTheme:s,storageKey:c,attribute:h,enableSystem:r,enableColorScheme:i,defaultTheme:m,value:j,themes:o,nonce:b,scriptProps:N}),y)},u=t.memo(e=>{let{forcedTheme:s,storageKey:a,attribute:l,enableSystem:n,enableColorScheme:i,defaultTheme:d,value:c,themes:o,nonce:m,scriptProps:x}=e,h=JSON.stringify([l,a,d,s,o,c,n,i]).slice(1,-1);return t.createElement("script",{...x,suppressHydrationWarning:!0,nonce:"undefined"==typeof window?m:"",dangerouslySetInnerHTML:{__html:"(".concat(r.toString(),")(").concat(h,")")}})}),p=(e,s)=>{let a;if(!i){try{a=localStorage.getItem(e)||void 0}catch(e){}return a||s}},v=e=>{let s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(s),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(s)},1)}},g=e=>(e||(e=window.matchMedia(n)),e.matches?"dark":"light")}},e=>{var s=s=>e(e.s=s);e.O(0,[8313,1868,3259,5964,5822,8441,1517,7358],()=>s(3821)),_N_E=e.O()}]);
|