agent-tower 0.5.2-beta.3 → 0.5.2-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +13 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/git/git-cli.d.ts +5 -3
  5. package/dist/git/git-cli.d.ts.map +1 -1
  6. package/dist/git/git-cli.js +3 -1
  7. package/dist/git/git-cli.js.map +1 -1
  8. package/dist/git/worktree.manager.js +1 -1
  9. package/dist/git/worktree.manager.js.map +1 -1
  10. package/dist/git/worktree.manager.test.js +69 -0
  11. package/dist/git/worktree.manager.test.js.map +1 -1
  12. package/dist/mcp/http-client.d.ts +1 -0
  13. package/dist/mcp/http-client.d.ts.map +1 -1
  14. package/dist/mcp/http-client.js +3 -0
  15. package/dist/mcp/http-client.js.map +1 -1
  16. package/dist/mcp/server.d.ts.map +1 -1
  17. package/dist/mcp/server.js +27 -2
  18. package/dist/mcp/server.js.map +1 -1
  19. package/dist/routes/team-runs.d.ts.map +1 -1
  20. package/dist/routes/team-runs.js +9 -0
  21. package/dist/routes/team-runs.js.map +1 -1
  22. package/dist/services/__tests__/team-reconciler.service.test.js +120 -0
  23. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  24. package/dist/services/__tests__/team-run.service.test.js +30 -0
  25. package/dist/services/__tests__/team-run.service.test.js.map +1 -1
  26. package/dist/services/__tests__/workspace-git-watcher.service.test.js +139 -0
  27. package/dist/services/__tests__/workspace-git-watcher.service.test.js.map +1 -1
  28. package/dist/services/team-run.service.d.ts +1 -0
  29. package/dist/services/team-run.service.d.ts.map +1 -1
  30. package/dist/services/team-run.service.js +40 -8
  31. package/dist/services/team-run.service.js.map +1 -1
  32. package/dist/services/workspace-git-watcher.service.d.ts +9 -4
  33. package/dist/services/workspace-git-watcher.service.d.ts.map +1 -1
  34. package/dist/services/workspace-git-watcher.service.js +44 -58
  35. package/dist/services/workspace-git-watcher.service.js.map +1 -1
  36. package/dist/socket/index.d.ts.map +1 -1
  37. package/dist/socket/index.js +12 -0
  38. package/dist/socket/index.js.map +1 -1
  39. package/dist/web/assets/{AgentDemoPage-DRtgA1-w.js → AgentDemoPage-BIMA7LtG.js} +1 -1
  40. package/dist/web/assets/{DemoPage-8g4kqlV1.js → DemoPage-Ck0jATn9.js} +1 -1
  41. package/dist/web/assets/{GeneralSettingsPage-b2dViAif.js → GeneralSettingsPage-C5KUTpFg.js} +1 -1
  42. package/dist/web/assets/{MemberAvatar-BuaKw8fE.js → MemberAvatar-CKkPlE4w.js} +1 -1
  43. package/dist/web/assets/{NotificationSettingsPage-DCtnFBrk.js → NotificationSettingsPage-Dl2nJ6Kj.js} +1 -1
  44. package/dist/web/assets/{ProfileSettingsPage-Hplbudpu.js → ProfileSettingsPage-D_YQBJqm.js} +1 -1
  45. package/dist/web/assets/ProjectKanbanPage-D2_609qP.js +89 -0
  46. package/dist/web/assets/{ProjectSettingsPage-CnG-6FVF.js → ProjectSettingsPage-DpewUnnG.js} +1 -1
  47. package/dist/web/assets/{ProviderSettingsPage-B-u7Av-v.js → ProviderSettingsPage-BbruFhJJ.js} +1 -1
  48. package/dist/web/assets/{SettingsMasterDetail-C7L4KTOf.js → SettingsMasterDetail-zGxTmEVL.js} +1 -1
  49. package/dist/web/assets/{TeamSettingsPage-DCsq_ojZ.js → TeamSettingsPage-B3dBegBu.js} +1 -1
  50. package/dist/web/assets/{arrow-left-BSle2OYV.js → arrow-left-DTTqavaj.js} +1 -1
  51. package/dist/web/assets/check-N8co_7vS.js +1 -0
  52. package/dist/web/assets/{chevron-down-Dj8_pYCl.js → chevron-down-CXD7aP1s.js} +1 -1
  53. package/dist/web/assets/{chevron-right-BUCnUjsN.js → chevron-right-DSp9sZpx.js} +1 -1
  54. package/dist/web/assets/{chevron-up-BhzmceCN.js → chevron-up-DAXQrjEz.js} +1 -1
  55. package/dist/web/assets/{code-block-OCS4YCEC-C9ZDvx5q.js → code-block-OCS4YCEC-Cwwrn6vr.js} +1 -1
  56. package/dist/web/assets/{confirm-dialog-NY6uLJRk.js → confirm-dialog-DnHo_qsz.js} +1 -1
  57. package/dist/web/assets/{folder-picker-B5loyQsl.js → folder-picker-TUuS8jPV.js} +1 -1
  58. package/dist/web/assets/index-JZcaQb4r.css +1 -0
  59. package/dist/web/assets/{index-DSFOeuuj.js → index-X6FFd4Oy.js} +8 -8
  60. package/dist/web/assets/{input-D67geHKZ.js → input-CWSScfQB.js} +1 -1
  61. package/dist/web/assets/{layers-Dl9LLqoY.js → layers-DMovMRW4.js} +1 -1
  62. package/dist/web/assets/{loader-circle-CP1oxYjb.js → loader-circle-CvnvXNY6.js} +1 -1
  63. package/dist/web/assets/{mermaid-NOHMQCX5-C-bBE9vu.js → mermaid-NOHMQCX5-CmO9pIR-.js} +3 -3
  64. package/dist/web/assets/{message-square-Bwt_cqko.js → message-square-tazyMedo.js} +1 -1
  65. package/dist/web/assets/{modal-0iwqEf_V.js → modal-D9LZcnXe.js} +1 -1
  66. package/dist/web/assets/{pencil-CAgGPSMf.js → pencil-Cfcl8xtO.js} +1 -1
  67. package/dist/web/assets/{rotate-ccw-CnfGwAnp.js → rotate-ccw-BCxAIasK.js} +1 -1
  68. package/dist/web/assets/{select-C0X1iRxk.js → select-wCJbdjbF.js} +1 -1
  69. package/dist/web/assets/{switch-D_KOTssd.js → switch-BpVaaZIq.js} +1 -1
  70. package/dist/web/assets/{textarea-DS-Evqsv.js → textarea-CqAqQ-DJ.js} +1 -1
  71. package/dist/web/assets/{upload-CTsJ3wDk.js → upload-Doc6mqhw.js} +1 -1
  72. package/dist/web/assets/{use-profiles-CzdxiQuG.js → use-profiles-CLbwBXdL.js} +1 -1
  73. package/dist/web/assets/{use-providers-BdxKwaE3.js → use-providers-C8Rfahov.js} +1 -1
  74. package/dist/web/index.html +2 -2
  75. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +1 -0
  76. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  77. package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
  78. package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
  79. package/package.json +1 -1
  80. package/dist/web/assets/ProjectKanbanPage-UJVkISeV.js +0 -89
  81. package/dist/web/assets/check-COf1UbPe.js +0 -1
  82. package/dist/web/assets/index-3iFMFw1l.css +0 -1
@@ -1 +1 @@
1
- import{h as H,u as Q,r as n,m as b,j as e,B as y,L as X,H as Y}from"./index-DSFOeuuj.js";import{u as Z,a as ee,b as L,c as te,d as se,e as ne,T as re,P as ae,A as le,G as ie,S as oe}from"./mermaid-NOHMQCX5-C-bBE9vu.js";import{d as ce}from"./use-profiles-CzdxiQuG.js";import{C as de}from"./chevron-up-BhzmceCN.js";import{C as xe}from"./chevron-down-Dj8_pYCl.js";import"./log-adapter-CtvxzS4j.js";import"./chevron-right-BUCnUjsN.js";import"./check-COf1UbPe.js";const me=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ue=H("hash",me);const pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],he=H("send",pe),ge=!0;function Ae(){const{t:s}=Q(),[w,U]=n.useState([]),[i,S]=n.useState(""),[x,A]=n.useState("DEFAULT"),[o,k]=n.useState(""),[a,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),C=n.useRef(null),$=n.useRef(null),u=n.useRef(null),{data:p}=ce(i),F=p?Object.keys(p):["DEFAULT"],V=t=>{S(t),A("DEFAULT")},_=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),B=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:G,agentSessionId:I,attach:z,clearLogs:P}=Z({sessionId:a||"",onExit:_,onError:B}),{todos:R}=ee(G);n.useEffect(()=>{b.get("/demo/agents").then(t=>{U(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const M=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},O=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});ge&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),D(r.sessionId),c("running")}catch(r){console.error("Start failed:",r),c("error")}},T=async()=>{if(!a||!m.trim())return;const t=m.trim();j("");try{await b.post(`/demo/${a}/message`,{message:t})}catch(r){console.error("Send failed:",r)}},K=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},q=()=>{D(null),c("idle"),k(""),j(""),P()},J=l==="running",d=a!==null,W=w.find(t=>t.type===i);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:d?o.slice(0,50)+(o.length>50?"...":""):s("新会话")})]}),e.jsxs("div",{className:"flex items-center",children:[l==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),l==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),l==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),l==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),l==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),d&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${g?"":"truncate"}`,onClick:()=>E(!g),children:o}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(de,{size:14}):e.jsx(xe,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:W?.name||i||s("未选择")})]}),x!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:x})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:s("连接")}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${h?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(h?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(y,{variant:"outline",size:"sm",onClick:q,className:"ml-auto",children:s("新会话")}),e.jsxs(X,{to:"/settings/profiles",className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(Y,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:$,className:"flex-1 overflow-y-auto px-8 py-6",children:d?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:s("等待 Agent 响应...")}):e.jsx(ne,{ref:C,logs:v,scrollElementRef:$})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("选择 Agent")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:i===t.type?"default":"outline",disabled:!t.available,onClick:()=>V(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:F.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:O,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(re,{todos:R})}),d&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:u,value:m,onChange:M,rows:3,placeholder:s("发送消息给 Agent..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ae,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(le,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(ue,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(ie,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[J&&e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(oe,{size:12,fill:"currentColor"}),e.jsx("span",{children:s("停止")})]}),e.jsxs("button",{onClick:T,disabled:!m.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${m.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:s("发送")}),e.jsx(he,{size:14})]})]})]})]})})]})}export{Ae as AgentDemoPage};
1
+ import{h as H,u as Q,r as n,m as b,j as e,B as y,L as X,H as Y}from"./index-X6FFd4Oy.js";import{u as Z,a as ee,b as L,c as te,d as se,e as ne,T as re,P as ae,A as le,G as ie,S as oe}from"./mermaid-NOHMQCX5-CmO9pIR-.js";import{d as ce}from"./use-profiles-CLbwBXdL.js";import{C as de}from"./chevron-up-DAXQrjEz.js";import{C as xe}from"./chevron-down-CXD7aP1s.js";import"./log-adapter-CtvxzS4j.js";import"./chevron-right-DSp9sZpx.js";import"./check-N8co_7vS.js";const me=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ue=H("hash",me);const pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],he=H("send",pe),ge=!0;function Ae(){const{t:s}=Q(),[w,U]=n.useState([]),[i,S]=n.useState(""),[x,A]=n.useState("DEFAULT"),[o,k]=n.useState(""),[a,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),C=n.useRef(null),$=n.useRef(null),u=n.useRef(null),{data:p}=ce(i),F=p?Object.keys(p):["DEFAULT"],V=t=>{S(t),A("DEFAULT")},_=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),B=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:G,agentSessionId:I,attach:z,clearLogs:P}=Z({sessionId:a||"",onExit:_,onError:B}),{todos:R}=ee(G);n.useEffect(()=>{b.get("/demo/agents").then(t=>{U(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const M=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},O=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});ge&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),D(r.sessionId),c("running")}catch(r){console.error("Start failed:",r),c("error")}},T=async()=>{if(!a||!m.trim())return;const t=m.trim();j("");try{await b.post(`/demo/${a}/message`,{message:t})}catch(r){console.error("Send failed:",r)}},K=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},q=()=>{D(null),c("idle"),k(""),j(""),P()},J=l==="running",d=a!==null,W=w.find(t=>t.type===i);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:d?o.slice(0,50)+(o.length>50?"...":""):s("新会话")})]}),e.jsxs("div",{className:"flex items-center",children:[l==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),l==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),l==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),l==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),l==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),d&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${g?"":"truncate"}`,onClick:()=>E(!g),children:o}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(de,{size:14}):e.jsx(xe,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:W?.name||i||s("未选择")})]}),x!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:x})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:s("连接")}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${h?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(h?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(y,{variant:"outline",size:"sm",onClick:q,className:"ml-auto",children:s("新会话")}),e.jsxs(X,{to:"/settings/profiles",className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(Y,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:$,className:"flex-1 overflow-y-auto px-8 py-6",children:d?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:s("等待 Agent 响应...")}):e.jsx(ne,{ref:C,logs:v,scrollElementRef:$})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("选择 Agent")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:i===t.type?"default":"outline",disabled:!t.available,onClick:()=>V(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:F.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:O,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(re,{todos:R})}),d&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:u,value:m,onChange:M,rows:3,placeholder:s("发送消息给 Agent..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ae,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(le,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(ue,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(ie,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[J&&e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(oe,{size:12,fill:"currentColor"}),e.jsx("span",{children:s("停止")})]}),e.jsxs("button",{onClick:T,disabled:!m.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${m.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:s("发送")}),e.jsx(he,{size:14})]})]})]})]})})]})}export{Ae as AgentDemoPage};
@@ -1,4 +1,4 @@
1
- import{r as a,E as j,F as E,G as T,j as t,g as M,u as U,m as I,B as O}from"./index-DSFOeuuj.js";function P(s){const{sessionId:c,onOutput:k,onExit:x,onError:b}=s,[p,g]=a.useState(()=>j.isConnected()),[l,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},C=r=>{r.sessionId===c&&m.current.onOutput?.(r.data)},w=r=>{r.sessionId===c&&(d(!1),m.current.onExit?.(r.exitCode))},S=r=>{r.sessionId===c&&m.current.onError?.(r.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,C),n.on(E.SESSION_EXIT,w),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,C),n.off(E.SESSION_EXIT,w),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:l,attach:i,detach:y,sendInput:N,resize:h}}function $({className:s,...c}){return t.jsx("div",{"data-slot":"card",className:M("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",s),...c})}function B(){const{t:s}=U(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[l,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
1
+ import{r as a,E as j,F as E,G as T,j as t,g as M,u as U,m as I,B as O}from"./index-X6FFd4Oy.js";function P(s){const{sessionId:c,onOutput:k,onExit:x,onError:b}=s,[p,g]=a.useState(()=>j.isConnected()),[l,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},C=r=>{r.sessionId===c&&m.current.onOutput?.(r.data)},w=r=>{r.sessionId===c&&(d(!1),m.current.onExit?.(r.exitCode))},S=r=>{r.sessionId===c&&m.current.onError?.(r.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,C),n.on(E.SESSION_EXIT,w),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,C),n.off(E.SESSION_EXIT,w),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:l,attach:i,detach:y,sendInput:N,resize:h}}function $({className:s,...c}){return t.jsx("div",{"data-slot":"card",className:M("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",s),...c})}function B(){const{t:s}=U(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[l,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
2
2
  [进程退出,退出码: ${e}]`,timestamp:new Date}]),d(null)},[]),w=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
3
3
  [错误: ${e}]`,timestamp:new Date}])},[]),{isConnected:S,isAttached:r,attach:D}=P({sessionId:l||"",onOutput:v,onExit:C,onError:w});a.useEffect(()=>{I.get("/demo/agents").then(e=>{k(e.agents);const o=e.agents.find(f=>f.available);o&&b(o.type)})},[]),a.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[m]),a.useEffect(()=>{l&&S&&!r&&D()},[l,S,r,D]);const R=async()=>{if(!(!x||!p.trim())){N(!0),i([{role:"user",content:p,timestamp:new Date}]);try{const e=await I.post("/demo/start",{agentType:x,prompt:p.trim()});d(e.sessionId),g("")}catch(e){i(o=>[...o,{role:"agent",content:s("启动失败: {message}",{message:e instanceof Error?e.message:s("未知错误")}),timestamp:new Date}])}finally{N(!1)}}},A=async()=>{if(!l||!h.trim())return;const e=h.trim();i(o=>[...o,{role:"user",content:e,timestamp:new Date}]),n("");try{await I.post(`/demo/${l}/message`,{message:e})}catch(o){i(f=>[...f,{role:"agent",content:s("发送失败: {message}",{message:o instanceof Error?o.message:s("未知错误")}),timestamp:new Date}])}},_=async()=>{if(l)try{await I.post(`/demo/${l}/stop`),i(e=>[...e,{role:"agent",content:`
4
4
  [${s("会话已停止")}]`,timestamp:new Date}]),d(null)}catch(e){console.error("Stop failed:",e)}};return t.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[t.jsx("h1",{className:"text-2xl font-bold",children:s("Agent 交互演示")}),!l&&t.jsxs($,{className:"p-4",children:[t.jsx("h2",{className:"text-lg font-semibold mb-3",children:s("选择 Agent")}),t.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:c.map(e=>t.jsxs(O,{variant:x===e.type?"default":"outline",disabled:!e.available,onClick:()=>b(e.type),children:[e.name,e.available&&e.version&&` (${e.version})`,!e.available&&s(" (不可用)")]},e.type))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&R(),placeholder:s("输入你的问题或任务..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:R,disabled:y||!x||!p.trim(),children:s(y?"启动中...":"开始")})]})]}),t.jsxs($,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex justify-between items-center mb-3",children:[t.jsx("h2",{className:"text-lg font-semibold",children:s("对话")}),l&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-500",children:s(S?r?"已连接":"连接中...":"未连接")}),t.jsx(O,{variant:"outline",size:"sm",onClick:_,children:s("停止")})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?t.jsx("div",{className:"text-gray-400 text-center py-8",children:s("选择 Agent 并输入问题开始对话")}):m.map((e,o)=>t.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[t.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?s("你"):"Agent"}),t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),t.jsx("div",{ref:u})]}),l&&t.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[t.jsx("input",{type:"text",value:h,onChange:e=>n(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&A(),placeholder:s("发送后续消息..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:A,disabled:!h.trim(),children:s("发送")})]})]})]})}export{B as DemoPage};
@@ -1 +1 @@
1
- import{u as y,a as _,b as A,c as E,r as i,t as m,j as s,S as T,d as I,e as p,f as M,B as g}from"./index-DSFOeuuj.js";import{S as v}from"./select-C0X1iRxk.js";import{T as O}from"./textarea-DS-Evqsv.js";import{u as k}from"./use-providers-BdxKwaE3.js";import"./chevron-down-Dj8_pYCl.js";import"./check-COf1UbPe.js";const L=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],l="__follow_task__";function F(){const{locale:x,setLocale:S,t:e}=y(),{data:r}=_(),{data:f}=k(),{data:o}=A(),a=E(),[h,u]=i.useState(l),[c,d]=i.useState(""),[j,n]=i.useState(!1);i.useEffect(()=>{!r||!o||(u(r.commitMessageProviderId||l),d(r.commitMessagePrompt||o.prompt),n(!1))},[r,o]);const P=[{value:l,label:e("跟随任务")},...(f??[]).filter(t=>t.availability.type!=="NOT_FOUND").map(t=>({value:t.provider.id,label:t.provider.name}))],b=i.useCallback(t=>{u(t);const N=t===l?null:t;a.mutate({commitMessageProviderId:N},{onError:()=>m.error(e("保存失败"))})},[a,e]),C=i.useCallback(()=>{const t=c.trim()||null;a.mutate({commitMessagePrompt:t},{onSuccess:()=>{n(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[c,a,e]);return s.jsxs(T,{children:[s.jsx(I,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(p,{label:e("显示语言"),description:e("界面语言会保存到本地数据库,重启后继续生效。"),align:"center",children:s.jsx(v,{value:x,onChange:t=>S(t),options:L})})}),s.jsx(M,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(p,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(v,{value:h,onChange:b,options:P})}),s.jsx(p,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(O,{value:c,onChange:t=>{d(t.target.value),n(!0)},rows:5,className:"font-mono resize-y"}),j&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{d(r?.commitMessagePrompt||o?.prompt||""),n(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:C,disabled:a.isPending,children:a.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{F as GeneralSettingsPage};
1
+ import{u as y,a as _,b as A,c as E,r as i,t as m,j as s,S as T,d as I,e as p,f as M,B as g}from"./index-X6FFd4Oy.js";import{S as v}from"./select-wCJbdjbF.js";import{T as O}from"./textarea-CqAqQ-DJ.js";import{u as k}from"./use-providers-C8Rfahov.js";import"./chevron-down-CXD7aP1s.js";import"./check-N8co_7vS.js";const L=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],l="__follow_task__";function F(){const{locale:x,setLocale:S,t:e}=y(),{data:r}=_(),{data:f}=k(),{data:o}=A(),a=E(),[h,u]=i.useState(l),[c,d]=i.useState(""),[j,n]=i.useState(!1);i.useEffect(()=>{!r||!o||(u(r.commitMessageProviderId||l),d(r.commitMessagePrompt||o.prompt),n(!1))},[r,o]);const P=[{value:l,label:e("跟随任务")},...(f??[]).filter(t=>t.availability.type!=="NOT_FOUND").map(t=>({value:t.provider.id,label:t.provider.name}))],b=i.useCallback(t=>{u(t);const N=t===l?null:t;a.mutate({commitMessageProviderId:N},{onError:()=>m.error(e("保存失败"))})},[a,e]),C=i.useCallback(()=>{const t=c.trim()||null;a.mutate({commitMessagePrompt:t},{onSuccess:()=>{n(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[c,a,e]);return s.jsxs(T,{children:[s.jsx(I,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(p,{label:e("显示语言"),description:e("界面语言会保存到本地数据库,重启后继续生效。"),align:"center",children:s.jsx(v,{value:x,onChange:t=>S(t),options:L})})}),s.jsx(M,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(p,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(v,{value:h,onChange:b,options:P})}),s.jsx(p,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(O,{value:c,onChange:t=>{d(t.target.value),n(!0)},rows:5,className:"font-mono resize-y"}),j&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{d(r?.commitMessagePrompt||o?.prompt||""),n(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:C,disabled:a.isPending,children:a.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{F as GeneralSettingsPage};
@@ -1 +1 @@
1
- import{r as i,j as n,g as o}from"./index-DSFOeuuj.js";function d(r){const t=r.trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);return e.length>=2?`${e[0][0]??""}${e[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function a(r){const t=r.trim();return/^#([0-9a-f]{3,8})$/i.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)}function l(r){const t=r.trim();return t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:image/")||t.startsWith("blob:")}function h(r,t){const e=r?.trim()??"";return!e||a(e)||l(e)?d(t):e.length<=2?e.toUpperCase():e.slice(0,2).toUpperCase()}function p(r){const t=r?.trim()??"";if(!(!t||!a(t)))return{backgroundColor:t,color:"#ffffff"}}function g({name:r,avatar:t,className:e}){const[u,c]=i.useState(null),s=t?.trim()??"",f=!!s&&l(s)&&u!==s,m=i.useMemo(()=>h(s,r),[r,s]);return f?n.jsx("img",{src:s,alt:r,loading:"lazy",onError:()=>c(s),className:o("h-7 w-7 shrink-0 rounded-full border border-neutral-200 bg-white object-cover",e)}):n.jsx("div",{className:o("flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-neutral-100 text-[10px] font-semibold text-neutral-600",e),style:p(s),"aria-label":r,children:m})}export{g as M};
1
+ import{r as i,j as n,g as o}from"./index-X6FFd4Oy.js";function d(r){const t=r.trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);return e.length>=2?`${e[0][0]??""}${e[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function a(r){const t=r.trim();return/^#([0-9a-f]{3,8})$/i.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)}function l(r){const t=r.trim();return t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:image/")||t.startsWith("blob:")}function h(r,t){const e=r?.trim()??"";return!e||a(e)||l(e)?d(t):e.length<=2?e.toUpperCase():e.slice(0,2).toUpperCase()}function p(r){const t=r?.trim()??"";if(!(!t||!a(t)))return{backgroundColor:t,color:"#ffffff"}}function g({name:r,avatar:t,className:e}){const[u,c]=i.useState(null),s=t?.trim()??"",f=!!s&&l(s)&&u!==s,m=i.useMemo(()=>h(s,r),[r,s]);return f?n.jsx("img",{src:s,alt:r,loading:"lazy",onError:()=>c(s),className:o("h-7 w-7 shrink-0 rounded-full border border-neutral-200 bg-white object-cover",e)}):n.jsx("div",{className:o("flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-neutral-100 text-[10px] font-semibold text-neutral-600",e),style:p(s),"aria-label":r,children:m})}export{g as M};
@@ -1 +1 @@
1
- import{h as P,i as q,k as E,l as k,q as v,m as h,u as R,r as o,j as e,S as g,K as B,d as L,e as j,M,B as W,f as z,J as A}from"./index-DSFOeuuj.js";import{S as K}from"./select-C0X1iRxk.js";import{I as d}from"./input-D67geHKZ.js";import{S as Q,C as O}from"./switch-D_KOTssd.js";import{M as _}from"./message-square-Bwt_cqko.js";import{L as D,C as H}from"./loader-circle-CP1oxYjb.js";import"./chevron-down-Dj8_pYCl.js";import"./check-COf1UbPe.js";const J=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],G=P("link",J);function V(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function X(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function Y(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function oe(){const{t}=R(),{data:i,isLoading:y}=V(),l=X(),n=Y(),N=[{value:"none",label:t("关闭")},{value:"feishu",label:t("飞书 Webhook")}],[a,x]=o.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[m,p]=o.useState(!1),[f,r]=o.useState("idle"),u=o.useRef(void 0);if(o.useEffect(()=>{i&&!m&&x({webhookUrl:i.feishuWebhookUrl??"",baseUrl:i.thirdPartyBaseUrl??"",titleTemplate:i.taskInReviewTitleTemplate??"",bodyTemplate:i.taskInReviewBodyTemplate??""})},[i,m]),o.useEffect(()=>(n.isSuccess?(r("success"),u.current=setTimeout(()=>r("idle"),3e3)):n.isError&&(r("error"),u.current=setTimeout(()=>r("idle"),5e3)),()=>clearTimeout(u.current)),[n.isSuccess,n.isError]),y)return e.jsx(g,{children:e.jsx(B,{rows:3})});const T=i?.osNotificationEnabled??!0,b=i?.thirdPartyChannel??"none",c=(s,I)=>{x(F=>({...F,[s]:I})),p(!0)},S=s=>{l.mutate({osNotificationEnabled:s})},C=s=>{l.mutate({thirdPartyChannel:s})},U=()=>{l.mutate({feishuWebhookUrl:a.webhookUrl.trim()||null,thirdPartyBaseUrl:a.baseUrl.trim()||null,taskInReviewTitleTemplate:a.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:a.bodyTemplate.trim()||t('✅ "{taskTitle}" 已完成,等待审查')},{onSuccess:()=>p(!1)})},w=()=>{a.webhookUrl.trim()&&n.mutate({channel:"feishu",webhookUrl:a.webhookUrl.trim(),baseUrl:a.baseUrl.trim()||void 0})};return e.jsxs(g,{children:[e.jsx(L,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:M,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(Q,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:_,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(K,{value:b,onChange:s=>C(s),options:N})}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4 sm:pl-11",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-webhook-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Webhook URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"feishu-webhook-url",value:a.webhookUrl,onChange:s=>c("webhookUrl",s.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"min-w-0 flex-1 font-mono"}),e.jsxs(W,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(D,{size:12,className:"mr-1 animate-spin motion-reduce:animate-none"}),t("测试")]})]}),f==="success"&&e.jsxs("div",{role:"status",className:"mt-2 flex items-center gap-1.5 text-xs text-success",children:[e.jsx(O,{size:12,"aria-hidden":"true"}),t("测试消息发送成功")]}),f==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 flex items-center gap-1.5 text-xs text-destructive",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),t("发送失败,请检查 Webhook 地址")]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-base-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(G,{size:11,"aria-hidden":"true"}),t("跳转地址")]})}),e.jsx(d,{id:"feishu-base-url",value:a.baseUrl,onChange:s=>c("baseUrl",s.target.value),placeholder:"http://localhost:5173",className:"font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t('通知卡片中的"查看任务"按钮跳转地址前缀')})]})]})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(z,{children:t("通知模板")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("支持变量: {taskTitle}, {taskId}, {projectId}, {projectName}, {status}",{taskTitle:"{taskTitle}",taskId:"{taskId}",projectId:"{projectId}",projectName:"{projectName}",status:"{status}"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-title-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("标题")}),e.jsx(d,{id:"notification-title-template",value:a.titleTemplate,onChange:s=>c("titleTemplate",s.target.value),placeholder:"Agent Tower"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-body-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("内容")}),e.jsx(d,{id:"notification-body-template",value:a.bodyTemplate,onChange:s=>c("bodyTemplate",s.target.value),placeholder:t('✅ "{taskTitle}" 已完成,等待审查')})]})]})]})]}),m&&e.jsx(A,{saving:l.isPending,onSave:U})]})}export{oe as NotificationSettingsPage};
1
+ import{h as P,i as q,k as E,l as k,q as v,m as h,u as R,r as o,j as e,S as g,K as B,d as L,e as j,M,B as W,f as z,J as A}from"./index-X6FFd4Oy.js";import{S as K}from"./select-wCJbdjbF.js";import{I as d}from"./input-CWSScfQB.js";import{S as Q,C as O}from"./switch-BpVaaZIq.js";import{M as _}from"./message-square-tazyMedo.js";import{L as D,C as H}from"./loader-circle-CvnvXNY6.js";import"./chevron-down-CXD7aP1s.js";import"./check-N8co_7vS.js";const J=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],G=P("link",J);function V(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function X(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function Y(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function oe(){const{t}=R(),{data:i,isLoading:y}=V(),l=X(),n=Y(),N=[{value:"none",label:t("关闭")},{value:"feishu",label:t("飞书 Webhook")}],[a,x]=o.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[m,p]=o.useState(!1),[f,r]=o.useState("idle"),u=o.useRef(void 0);if(o.useEffect(()=>{i&&!m&&x({webhookUrl:i.feishuWebhookUrl??"",baseUrl:i.thirdPartyBaseUrl??"",titleTemplate:i.taskInReviewTitleTemplate??"",bodyTemplate:i.taskInReviewBodyTemplate??""})},[i,m]),o.useEffect(()=>(n.isSuccess?(r("success"),u.current=setTimeout(()=>r("idle"),3e3)):n.isError&&(r("error"),u.current=setTimeout(()=>r("idle"),5e3)),()=>clearTimeout(u.current)),[n.isSuccess,n.isError]),y)return e.jsx(g,{children:e.jsx(B,{rows:3})});const T=i?.osNotificationEnabled??!0,b=i?.thirdPartyChannel??"none",c=(s,I)=>{x(F=>({...F,[s]:I})),p(!0)},S=s=>{l.mutate({osNotificationEnabled:s})},C=s=>{l.mutate({thirdPartyChannel:s})},U=()=>{l.mutate({feishuWebhookUrl:a.webhookUrl.trim()||null,thirdPartyBaseUrl:a.baseUrl.trim()||null,taskInReviewTitleTemplate:a.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:a.bodyTemplate.trim()||t('✅ "{taskTitle}" 已完成,等待审查')},{onSuccess:()=>p(!1)})},w=()=>{a.webhookUrl.trim()&&n.mutate({channel:"feishu",webhookUrl:a.webhookUrl.trim(),baseUrl:a.baseUrl.trim()||void 0})};return e.jsxs(g,{children:[e.jsx(L,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:M,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(Q,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:_,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(K,{value:b,onChange:s=>C(s),options:N})}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4 sm:pl-11",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-webhook-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Webhook URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"feishu-webhook-url",value:a.webhookUrl,onChange:s=>c("webhookUrl",s.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"min-w-0 flex-1 font-mono"}),e.jsxs(W,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(D,{size:12,className:"mr-1 animate-spin motion-reduce:animate-none"}),t("测试")]})]}),f==="success"&&e.jsxs("div",{role:"status",className:"mt-2 flex items-center gap-1.5 text-xs text-success",children:[e.jsx(O,{size:12,"aria-hidden":"true"}),t("测试消息发送成功")]}),f==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 flex items-center gap-1.5 text-xs text-destructive",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),t("发送失败,请检查 Webhook 地址")]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-base-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(G,{size:11,"aria-hidden":"true"}),t("跳转地址")]})}),e.jsx(d,{id:"feishu-base-url",value:a.baseUrl,onChange:s=>c("baseUrl",s.target.value),placeholder:"http://localhost:5173",className:"font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t('通知卡片中的"查看任务"按钮跳转地址前缀')})]})]})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(z,{children:t("通知模板")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("支持变量: {taskTitle}, {taskId}, {projectId}, {projectName}, {status}",{taskTitle:"{taskTitle}",taskId:"{taskId}",projectId:"{projectId}",projectName:"{projectName}",status:"{status}"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-title-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("标题")}),e.jsx(d,{id:"notification-title-template",value:a.titleTemplate,onChange:s=>c("titleTemplate",s.target.value),placeholder:"Agent Tower"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-body-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("内容")}),e.jsx(d,{id:"notification-body-template",value:a.bodyTemplate,onChange:s=>c("bodyTemplate",s.target.value),placeholder:t('✅ "{taskTitle}" 已完成,等待审查')})]})]})]})]}),m&&e.jsx(A,{saving:l.isPending,onSave:U})]})}export{oe as NotificationSettingsPage};
@@ -1,3 +1,3 @@
1
- import{u as T,r as g,j as e,S,d as J,n as M,o as w,B as E,p,g as P}from"./index-DSFOeuuj.js";import{u as U,a as _,b as z,c as B}from"./use-profiles-CzdxiQuG.js";import{M as F,P as G,T as $}from"./modal-0iwqEf_V.js";import{C as R}from"./confirm-dialog-NY6uLJRk.js";import{I as H}from"./input-D67geHKZ.js";import{T as q}from"./textarea-DS-Evqsv.js";import{L as K}from"./layers-Dl9LLqoY.js";import{C as Q}from"./chevron-down-Dj8_pYCl.js";import{P as W}from"./pencil-CAgGPSMf.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(Q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(G,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx($,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=U(),{data:c}=_(),h=z(),j=B(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
1
+ import{u as T,r as g,j as e,S,d as J,n as M,o as w,B as E,p,g as P}from"./index-X6FFd4Oy.js";import{u as U,a as _,b as z,c as B}from"./use-profiles-CLbwBXdL.js";import{M as F,P as G,T as $}from"./modal-D9LZcnXe.js";import{C as R}from"./confirm-dialog-DnHo_qsz.js";import{I as H}from"./input-CWSScfQB.js";import{T as q}from"./textarea-CqAqQ-DJ.js";import{L as K}from"./layers-DMovMRW4.js";import{C as Q}from"./chevron-down-CXD7aP1s.js";import{P as W}from"./pencil-Cfcl8xtO.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(Q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(G,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx($,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=U(),{data:c}=_(),h=z(),j=B(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
2
2
 
3
3
  }`),v("")},D=()=>{if(!(!n||!i.trim()))try{const s=JSON.parse(b);v(""),h.mutate({agentType:n.agentType,variant:i.trim().toUpperCase(),config:s},{onSuccess:()=>r(null)})}catch{v(t("JSON 格式错误"))}},L=(s,l)=>{N({agentType:s,variant:l})},A=()=>{o&&j.mutate({agentType:o.agentType,variant:o.variant},{onSettled:()=>N(null)})},I=(s,l)=>!!c?.executors[s]?.[l];if(m)return e.jsx(S,{children:e.jsx(Z,{})});const C=a?.executors??{};return e.jsxs(S,{children:[e.jsx(J,{title:t("Profile 配置"),description:t("管理 Agent 执行器的配置变体。每个变体定义一组运行参数。"),className:"mb-4"}),e.jsx("div",{className:"space-y-3",children:Object.entries(C).map(([s,l])=>e.jsx(Y,{agentType:s,variants:l,isBuiltIn:d=>I(s,d),onEdit:(d,V)=>k(s,d,V),onNew:()=>O(s),onDelete:d=>L(s,d)},s))}),Object.keys(C).length===0&&e.jsx(M,{icon:K,message:t("暂无 Profile 配置")}),e.jsx(F,{isOpen:!!n,onClose:()=>r(null),title:n?.isNew?t("新增 Variant — {agentType}",{agentType:y[n.agentType]??n.agentType}):t("编辑 {variant}",{variant:n?.variant??""}),action:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outline",onClick:()=>r(null),children:t("取消")}),e.jsx(E,{onClick:D,disabled:h.isPending,children:h.isPending?t("保存中..."):t("保存")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{label:t("Variant 名称"),htmlFor:"profile-variant-name",children:e.jsx(H,{id:"profile-variant-name",value:i,onChange:s=>x(s.target.value),disabled:!n?.isNew,placeholder:t("例如: CUSTOM"),className:"font-mono"})}),e.jsxs(w,{label:t("配置 (JSON)"),htmlFor:"profile-variant-json",children:[e.jsx(q,{id:"profile-variant-json",value:b,onChange:s=>{u(s.target.value),v("")},rows:6,className:"resize-none font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:f})]})]})}),e.jsx(R,{isOpen:o!==null,onClose:()=>{j.isPending||N(null)},onConfirm:A,title:t("删除 Profile Variant"),description:o?t('确定删除 "{name}"?此操作不可撤销。',{name:`${y[o.agentType]??o.agentType} / ${o.variant}`}):"",confirmText:t("删除"),cancelText:t("取消"),variant:"danger",isLoading:j.isPending})]})}export{de as ProfileSettingsPage};