agent-tower 0.5.3-beta.8 → 0.5.3-beta.9
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/dist/web/assets/{AgentDemoPage-gztcIidI.js → AgentDemoPage-DMLw4xpg.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-CPNttAOj.js → AgentEnvironmentSettingsPage-NgRdouLu.js} +1 -1
- package/dist/web/assets/{AgentLogo-Bqjt1u2k.js → AgentLogo-ThhvSi7G.js} +1 -1
- package/dist/web/assets/{ConversationPage-DdfPLaBU.js → ConversationPage-B1ZcyF_h.js} +1 -1
- package/dist/web/assets/{CreateTaskInput-DQSvlvL0.js → CreateTaskInput-Cb3aRHr3.js} +1 -1
- package/dist/web/assets/{DemoPage-BHRQrxxs.js → DemoPage-CN2OBKzu.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-c6tWGPk7.js → GeneralSettingsPage-CE7P3t_v.js} +1 -1
- package/dist/web/assets/{Icons-hnXjnfjL.js → Icons-DIZBOtuC.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-D_TI4PEx.js → LoadingPreviewPage-CRBcypeY.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-D6b7ZWOS.js → McpSettingsPage-gp1XDMUd.js} +1 -1
- package/dist/web/assets/{MemberAvatar-DKsedKpu.js → MemberAvatar-Y_pJlw-N.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-Cv91U2pg.js → NotificationSettingsPage-BhZeHEef.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-K_eadHzF.js → ProfileSettingsPage-D_y3ePFs.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-Cw4kAimX.js → ProjectKanbanPage-CBfocvKp.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-Vw4sQoAf.js → ProjectSettingsPage-V38j8T61.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-DeNiqchP.js → ProviderSettingsPage-D-1Fyh5B.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-BusgjyV7.js → SettingsMasterDetail-CZfVaFo2.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-DIQuN3Y5.js → TeamSettingsPage-DysTmOGE.js} +1 -1
- package/dist/web/assets/{arc-cT4PVtdQ.js → arc-CgLBAHTH.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-DYwJxluW.js → architectureDiagram-3BPJPVTR-CP9eQfdk.js} +1 -1
- package/dist/web/assets/{arrow-left-DWeEJsaX.js → arrow-left-y1LwO7sB.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CaXsST1G.js → blockDiagram-GPEHLZMM-BURZnUwn.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DKqAyb1m.js → c4Diagram-AAUBKEIU-Dzgp3z3S.js} +1 -1
- package/dist/web/assets/channel-CWEYGfCJ.js +1 -0
- package/dist/web/assets/check-D2WWIhwV.js +1 -0
- package/dist/web/assets/{chevron-down-o4IZE_P6.js → chevron-down--B7iZqBL.js} +1 -1
- package/dist/web/assets/{chevron-right-DSyyoNau.js → chevron-right-7PShDIwg.js} +1 -1
- package/dist/web/assets/{chevron-up-BsLA8Xot.js → chevron-up-3n_vHdrD.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DoC7k16y.js → chunk-2J33WTMH-CIpasa01.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-CMKi8GO_.js → chunk-4BX2VUAB-DeSe2m1y.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Lyg5IKqI.js → chunk-55IACEB6-BkJ6ogdn.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-ColYow00.js → chunk-727SXJPM-Bkbv-knP.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-CoT-4pKg.js → chunk-AQP2D5EJ-BG9wGFIo.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-DVIaL62f.js → chunk-FMBD7UC4-Cvl_2za9.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-BNuafnYz.js → chunk-ND2GUHAM-B_zdzkWX.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-mqqlxbRp.js → chunk-QZHKN3VN-Ch6dvKNw.js} +1 -1
- package/dist/web/assets/{circle-alert-FqsC_oWX.js → circle-alert-W13JkYj3.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CcU8zfK8.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CcU8zfK8.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-BHWPqjt4.js → code-block-OCS4YCEC-CYhJ9OPu.js} +1 -1
- package/dist/web/assets/{confirm-dialog-BRqwAzwk.js → confirm-dialog-BAqfLDT8.js} +1 -1
- package/dist/web/assets/{copy-r1RvUhIY.js → copy-bJ2sut_L.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-Dx6hZ-zB.js → cose-bilkent-S5V4N54A-DWlnxyfH.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-jCqcQJ4A.js → dagre-BM42HDAG-Bt3QI02a.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-BFaFAwAW.js → diagram-2AECGRRQ-EaJBYSnS.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-D0VOgGBN.js → diagram-5GNKFQAL-BGyRb-_h.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-OkBj16PX.js → diagram-KO2AKTUF-CZhDTMfm.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-Ca28pfZT.js → diagram-LMA3HP47-Be8BAxmL.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-BdQf7KOI.js → diagram-OG6HWLK6-DEdQ7Cml.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-Bf80VYE6.js → erDiagram-TEJ5UH35-CG9SNlbz.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-BZWZqm_C.js → flowDiagram-I6XJVG4X-BUpx5PVX.js} +1 -1
- package/dist/web/assets/{folder-picker-ROPpPW7C.js → folder-picker-DFB9_pv4.js} +1 -1
- package/dist/web/assets/{folder-C-l50KQ-.js → folder-u7fKAtz_.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CWf25QDV.js → ganttDiagram-6RSMTGT7-D7vRxMpE.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-9cyYoW83.js → gitGraphDiagram-PVQCEYII-3lhH-RcD.js} +1 -1
- package/dist/web/assets/{index-3VWij2vw.js → index-7nw4fV42.js} +3 -3
- package/dist/web/assets/{index-Cask0_DN.js → index-CGMjRoF7.js} +4 -4
- package/dist/web/assets/index-YCjjSSLC.css +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-DWSuhoXN.js → infoDiagram-5YYISTIA-C5SNbJpO.js} +1 -1
- package/dist/web/assets/{input-Dyl1onpD.js → input-CKwRYuUJ.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BfxkZcbP.js → ishikawaDiagram-YF4QCWOH-Ca7tX9_0.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-keJyzDNt.js → journeyDiagram-JHISSGLW-B2oo6nxY.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-wo8SY3VQ.js → kanban-definition-UN3LZRKU-D1CzIzX9.js} +1 -1
- package/dist/web/assets/{layers-CT4P8Wt_.js → layers-BbLzQqyy.js} +1 -1
- package/dist/web/assets/{linear-DXmYF97H.js → linear-BWowtcGw.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DjJdrIaK.js → mermaid-NOHMQCX5-B42ziicV.js} +3 -3
- package/dist/web/assets/{message-square-B0uoScMB.js → message-square-Bd_m34OX.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-BR1VqGMr.js → mindmap-definition-RKZ34NQL-CYbO6QCk.js} +1 -1
- package/dist/web/assets/{modal-CN741Elc.js → modal-CxOKWOjZ.js} +1 -1
- package/dist/web/assets/{pencil-B05Eh9uE.js → pencil-h5kxwbcu.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-DmIVi6kN.js → pieDiagram-4H26LBE5-DXQghKRy.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Bh1fx3P_.js → quadrantDiagram-W4KKPZXB-C6lAMMQB.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BheNLVEb.js → requirementDiagram-4Y6WPE33-Di9Le7Wy.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CWuQByUh.js → sankeyDiagram-5OEKKPKP-BGpnptvR.js} +1 -1
- package/dist/web/assets/{select-B2NVUyiF.js → select-DFuN9DX8.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-Blll85Hd.js → sequenceDiagram-3UESZ5HK-DjfkfaQL.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-C31npQBQ.js → stateDiagram-AJRCARHV-DsELotm9.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CudtEyHd.js +1 -0
- package/dist/web/assets/{switch-BiB7Kgpg.js → switch-gL7lBFj6.js} +1 -1
- package/dist/web/assets/{textarea-Du_ydNYw.js → textarea-Lr4GZaYW.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BXjt2YG8.js → timeline-definition-PNZ67QCA-Cq1BWC0T.js} +1 -1
- package/dist/web/assets/{trash-2-CWVsy23V.js → trash-2-B7GFt5Wl.js} +1 -1
- package/dist/web/assets/{upload-C-wK_vWU.js → upload-L8hpDFoO.js} +1 -1
- package/dist/web/assets/{use-profiles-DwPVupVL.js → use-profiles-zIsoigD8.js} +1 -1
- package/dist/web/assets/{use-providers-C-PIoFvi.js → use-providers-erJ2iHLz.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-CGOi3cNq.js → useNormalizedLogs-CXAn7xj_.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-DKpjIApG.js → vennDiagram-CIIHVFJN-DdOfNtRo.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-DvryVGdS.js → wardley-L42UT6IY-BeKcEIgK.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CtUF9zNr.js → wardleyDiagram-YWT4CUSO-DPKOxABd.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-Qx4Q-1Xq.js → xychartDiagram-2RQKCTM6-olIy_aaY.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
- package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
- package/package.json +1 -1
- package/dist/web/assets/channel--M3xJN0e.js +0 -1
- package/dist/web/assets/check-CjNklwnC.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BkKX675E.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BkKX675E.js +0 -1
- package/dist/web/assets/index-C4wUDrio.css +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BXcVcTJl.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as H,u as X,O as Y,r as n,m as b,j as e,B as y,P as Z,Q as ee,U as te}from"./index-3VWij2vw.js";import{u as se,a as ne,T as re,P as ae}from"./useNormalizedLogs-CGOi3cNq.js";import{b as le}from"./mermaid-NOHMQCX5-DjJdrIaK.js";import{I as L,a as ie,b as oe,A as ce,G as de}from"./Icons-hnXjnfjL.js";import{d as xe}from"./use-profiles-DwPVupVL.js";import{C as me}from"./chevron-up-BsLA8Xot.js";import{C as ue}from"./chevron-down-o4IZE_P6.js";import"./check-CjNklwnC.js";import"./chevron-right-DSyyoNau.js";const pe=[["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"}]],he=H("hash",pe);const ge=[["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"}]],fe=H("send",ge),be=!0;function Ee(){const{t:s}=X(),{preserveDesktopSearch:U}=Y(),[w,F]=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}=xe(i),V=p?Object.keys(p):["DEFAULT"],_=t=>{S(t),A("DEFAULT")},B=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),G=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:M,agentSessionId:I,attach:z,clearLogs:P}=se({sessionId:a||"",onExit:B,onError:G}),{todos:R}=ne(M);n.useEffect(()=>{b.get("/demo/agents").then(t=>{F(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 O=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`}},K=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});be&&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)}},q=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},J=()=>{D(null),c("idle"),k(""),j(""),P()},Q=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(ie,{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(oe,{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(me,{size:14}):e.jsx(ue,{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:J,className:"ml-auto",children:s("新会话")}),e.jsxs(Z,{to:U("/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(ee,{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(le,{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:()=>_(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:V.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:K,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:O,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(ce,{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(he,{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(de,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Q&&e.jsxs("button",{onClick:q,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(te,{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(fe,{size:14})]})]})]})]})})]})}export{Ee as AgentDemoPage};
|
|
1
|
+
import{g as H,u as X,O as Y,r as n,m as b,j as e,B as y,P as Z,Q as ee,U as te}from"./index-7nw4fV42.js";import{u as se,a as ne,T as re,P as ae}from"./useNormalizedLogs-CXAn7xj_.js";import{b as le}from"./mermaid-NOHMQCX5-B42ziicV.js";import{I as L,a as ie,b as oe,A as ce,G as de}from"./Icons-DIZBOtuC.js";import{d as xe}from"./use-profiles-zIsoigD8.js";import{C as me}from"./chevron-up-3n_vHdrD.js";import{C as ue}from"./chevron-down--B7iZqBL.js";import"./check-D2WWIhwV.js";import"./chevron-right-7PShDIwg.js";const pe=[["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"}]],he=H("hash",pe);const ge=[["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"}]],fe=H("send",ge),be=!0;function Ee(){const{t:s}=X(),{preserveDesktopSearch:U}=Y(),[w,F]=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}=xe(i),V=p?Object.keys(p):["DEFAULT"],_=t=>{S(t),A("DEFAULT")},B=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),G=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:M,agentSessionId:I,attach:z,clearLogs:P}=se({sessionId:a||"",onExit:B,onError:G}),{todos:R}=ne(M);n.useEffect(()=>{b.get("/demo/agents").then(t=>{F(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 O=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`}},K=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});be&&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)}},q=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},J=()=>{D(null),c("idle"),k(""),j(""),P()},Q=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(ie,{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(oe,{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(me,{size:14}):e.jsx(ue,{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:J,className:"ml-auto",children:s("新会话")}),e.jsxs(Z,{to:U("/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(ee,{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(le,{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:()=>_(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:V.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:K,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:O,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(ce,{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(he,{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(de,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Q&&e.jsxs("button",{onClick:q,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(te,{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(fe,{size:14})]})]})]})]})})]})}export{Ee as AgentDemoPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,j as n,S as s,d as i,A as r}from"./index-
|
|
1
|
+
import{u as e,j as n,S as s,d as i,A as r}from"./index-7nw4fV42.js";function g(){const{t}=e();return n.jsxs(s,{children:[n.jsx(i,{title:t("Agent 环境"),description:t("检测并安装本机 Agent CLI。安装前会展示官方来源、风险和校验摘要。")}),n.jsx(r,{})]})}export{g as AgentEnvironmentSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as s,C as u,h as o}from"./index-
|
|
1
|
+
import{r as a,j as s,C as u,h as o}from"./index-7nw4fV42.js";import{g as f}from"./mermaid-NOHMQCX5-B42ziicV.js";function d({agentType:n,className:t,fallbackClassName:i}){const e=f(n),[c,r]=a.useState(!1);return a.useEffect(()=>{r(!1)},[e?.logoSrc]),!e||c?s.jsx(u,{"aria-hidden":"true",className:o("shrink-0 text-muted-foreground",t,i)}):s.jsx("img",{src:e.logoSrc,alt:"","aria-hidden":"true",className:o("shrink-0 object-contain",t),draggable:!1,onError:()=>r(!0)})}export{d as A};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{g as Ee,u as ie,r,j as e,U as Ae,h as y,i as je,k as Z,l as le,q as h,m as B,a2 as Te,O as Le,a3 as Pe,K as Me,M as be,Q as Re,a4 as qe,a5 as ae}from"./index-
|
|
1
|
+
import{g as Ee,u as ie,r,j as e,U as Ae,h as y,i as je,k as Z,l as le,q as h,m as B,a2 as Te,O as Le,a3 as Pe,K as Me,M as be,Q as Re,a4 as qe,a5 as ae}from"./index-7nw4fV42.js";import{u as Oe,b as ze,A as Fe,S as w}from"./mermaid-NOHMQCX5-B42ziicV.js";import{u as Ke,a as Qe,T as Ue,P as Be}from"./useNormalizedLogs-CXAn7xj_.js";import{u as _e,a as $e,A as Ge,P as He,T as Ve,b as We,B as Je,c as Ye,S as Xe,d as we,C as Ze}from"./CreateTaskInput-Cb3aRHr3.js";import{u as et}from"./use-providers-erJ2iHLz.js";import{M as pe}from"./message-square-Bd_m34OX.js";import{A as tt}from"./arrow-left-y1LwO7sB.js";import{T as st}from"./trash-2-B7GFt5Wl.js";import"./chevron-right-7PShDIwg.js";import"./chevron-down--B7iZqBL.js";import"./check-D2WWIhwV.js";import"./AgentLogo-ThhvSi7G.js";import"./MemberAvatar-Y_pJlw-N.js";import"./folder-u7fKAtz_.js";const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],rt=Ee("layout-list",nt);function at(t){return t===w.RUNNING||t===w.PENDING}function ot({sessionId:t,sessionStatus:n,agentType:o,providerId:f,providers:S,initialTokenUsage:j,onProviderChange:m,onSend:p,onStop:x,onExit:C,isSending:N=!1,isStopping:I=!1,canStop:O,className:T}){const{t:a}=ie(),[d,_]=r.useState(""),[z,$]=r.useState(f??""),[G,F]=r.useState(!1),[K,k]=r.useState(null),H=r.useRef(null),ee=r.useRef(null),ce=r.useRef(null),L=r.useRef(!1),{scrollRef:de,contentRef:ue,isAtBottom:V,scrollToBottom:P}=_e({initial:"instant",resize:"smooth"}),{isConnected:W,isLoadingSnapshot:i,logs:D,entries:me,attach:E}=Ke({sessionId:t,sessionStatus:n,onExit:C}),{todos:J}=Qe(me),Q=$e(D,j),{files:fe,addFiles:g,removeFile:te,clear:se,buildMarkdownLinks:Y,getDoneAttachments:ne,hasFiles:A,isUploading:M}=Oe(),R=at(n),X=O??R;r.useEffect(()=>{$(f??"")},[f]),r.useEffect(()=>{t&&W&&E()},[t,W,E]);const xe=r.useCallback(c=>{$(c),m?.(c)},[m]),re=r.useCallback(()=>{H.current&&(H.current.style.height="60px")},[]),he=r.useCallback(c=>{_(c.target.value);const v=c.target;v.style.height="auto",v.style.height=`${Math.max(60,Math.min(v.scrollHeight,300))}px`},[]),s=r.useCallback(async()=>{if(!d.trim()&&!A||L.current||N||M)return;L.current=!0;const c=Y(),v=ne().map(q=>q.id),U=[d.trim(),c].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`);_(""),se(),re(),k(null);try{await p({message:U,providerId:z||void 0,attachmentIds:v}),await E(),requestAnimationFrame(()=>P("smooth"))}catch(q){k(q instanceof Error?q.message:a("Send failed. Please try again.")),_(U)}finally{L.current=!1}},[d,A,N,M,Y,ne,se,re,p,z,E,P,a]),l=r.useCallback(async()=>{!X||I||await x()},[X,I,x]),u=r.useCallback(c=>{const v=c.target.files;v&&v.length>0&&g(Array.from(v)),c.target.value=""},[g]),b=r.useCallback(c=>{const v=c.clipboardData.items,U=[];for(const q of v)if(q.kind==="file"){const ge=q.getAsFile();ge&&U.push(ge)}U.length>0&&(c.preventDefault(),g(U))},[g]),Se=r.useCallback(c=>{c.preventDefault(),F(!0)},[]),Ie=r.useCallback(c=>{c.preventDefault(),F(!1)},[]),De=r.useCallback(c=>{c.preventDefault(),F(!1);const v=c.dataTransfer.files;v.length>0&&g(Array.from(v))},[g]);return e.jsxs("div",{className:y("relative flex min-h-0 flex-1 flex-col bg-background",T),children:[e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:de,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pb-4 pt-6",children:e.jsx("div",{ref:ue,className:"mx-auto w-full min-w-0 max-w-4xl",children:i?e.jsxs("div",{className:"flex items-center justify-center gap-3 py-12 text-muted-foreground/70",children:[e.jsxs("svg",{className:"h-5 w-5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:a("Loading logs...")})]}):D.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground/70",children:a(R?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(ze,{logs:D})})}),!V&&e.jsxs("button",{type:"button",onClick:()=>P(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-muted-foreground shadow-md backdrop-blur-sm transition-all hover:bg-background hover:text-foreground","aria-label":a("Scroll to bottom"),children:[e.jsx(Ge,{size:14}),e.jsx("span",{children:a("Back to bottom")})]})]}),J.length>0&&e.jsx("div",{className:"shrink-0 border-t border-border/60 bg-background px-6 pb-1 pt-2",children:e.jsx("div",{className:"mx-auto max-w-4xl",children:e.jsx(Ue,{todos:J})})}),e.jsx("div",{className:"z-10 w-full shrink-0 border-t border-transparent bg-background p-6 pb-6 pt-2",onDragOver:Se,onDragLeave:Ie,onDrop:De,children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[K?e.jsx("div",{className:"mb-2 text-sm text-destructive",children:K}):null,e.jsxs("div",{ref:ce,className:y("relative rounded-xl border bg-background transition-colors duration-200 hover:border-ring/40 focus-within:border-ring/60",G?"border-info bg-info/5":"border-border"),children:[e.jsx(Fe,{files:fe,onRemove:te}),e.jsx("textarea",{ref:H,value:d,onChange:he,onPaste:b,onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.repeat&&!c.nativeEvent.isComposing&&c.nativeEvent.keyCode!==229&&(c.preventDefault(),s())},rows:1,placeholder:a(G?"Drop files here...":t&&!R?"Continue conversation...":"Message Agent..."),className:"w-full resize-none border-none bg-transparent px-4 pb-2 pt-4 text-sm leading-relaxed text-foreground placeholder-muted-foreground/70 focus:outline-none",style:{minHeight:"60px",maxHeight:"300px"}}),e.jsx("input",{ref:ee,type:"file",multiple:!0,className:"hidden",onChange:u}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("button",{type:"button",onClick:()=>ee.current?.click(),disabled:M,className:"rounded-lg p-2 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",title:a("Upload file"),children:e.jsx(Be,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{providers:S,currentProviderId:z,agentType:o,onSelect:xe}),e.jsx(Ve,{usage:Q}),X&&R&&!d.trim()&&!A?e.jsx("button",{type:"button",onClick:l,disabled:I,className:"rounded-lg bg-destructive p-2 text-white transition-all duration-200 hover:bg-destructive/90 disabled:opacity-50",title:a("Stop"),children:e.jsx(Ae,{size:14})}):e.jsx("button",{type:"button",onClick:s,disabled:!d.trim()&&!A||M||N,className:y("rounded-lg p-2 transition-all duration-200",(d.trim()||A)&&!M&&!N?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-transparent text-muted-foreground/50"),title:a("Send"),children:e.jsx(We,{size:18})})]})]})]})]})})]})}function it(t=50){return je({queryKey:h.conversations.list({limit:t}),queryFn:()=>B.get("/conversations",{params:{limit:String(t)}})})}function lt(t){return je({queryKey:h.conversations.detail(t??""),queryFn:()=>B.get(`/conversations/${t}`),enabled:!!t})}function ct(){const t=Z();return le({mutationFn:n=>B.post("/conversations",n),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function dt(){const t=Z();return le({mutationFn:({id:n,...o})=>B.post(`/conversations/${n}/message`,o),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function ut(){const t=Z();return le({mutationFn:n=>B.post(`/conversations/${n}/stop`),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function mt(){const t=Z();return le({mutationFn:n=>B.delete(`/conversations/${n}`),onSuccess:(n,o)=>{t.removeQueries({queryKey:h.conversations.detail(o)}),t.invalidateQueries({queryKey:h.conversations.all})}})}const ft=3e4,Ce="agent-tower:conversation-read-times";function xt(){try{const t=window.localStorage.getItem(Ce);if(!t)return{};const n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).map(([o,f])=>[o,typeof f=="number"?f:Number(f)]).filter(o=>Number.isFinite(o[1])))}catch{return{}}}function ve(t){try{window.localStorage.setItem(Ce,JSON.stringify(t))}catch{}}function ye(t){const n=t.lastActiveAt??t.updatedAt??t.createdAt;if(!n)return 0;const o=new Date(n).getTime();return Number.isFinite(o)?o:0}function ht(t=ft){const[,n]=r.useState(0);r.useEffect(()=>{const o=setInterval(()=>n(f=>f+1),t);return()=>clearInterval(o)},[t])}function oe(t){return t===w.RUNNING||t===w.PENDING}function ke(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const o=Math.max(0,Math.floor((Date.now()-n.getTime())/1e3));return o<60?ae("{count}s ago",{count:o}):o<3600?ae("{count}m ago",{count:Math.floor(o/60)}):o<86400?ae("{count}h ago",{count:Math.floor(o/3600)}):ae("{count}d ago",{count:Math.floor(o/86400)})}function pt(t,n){switch(t){case w.RUNNING:return n("Running");case w.PENDING:return n("Starting");case w.COMPLETED:return n("Completed");case w.FAILED:return n("Failed");case w.CANCELLED:return n("Stopped");default:return t}}function Ne({className:t,pulseClassName:n}){return e.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[e.jsx("span",{className:y("absolute inline-flex h-full w-full animate-ping rounded-full",n)}),e.jsx("span",{className:y("relative inline-flex h-2 w-2 rounded-full",t)})]})}function gt({status:t,unread:n}){return oe(t)?e.jsx(Ne,{className:"bg-success",pulseClassName:"bg-success/70"}):n?e.jsx(Ne,{className:"bg-warning",pulseClassName:"bg-warning/70"}):null}function bt({conversation:t,selected:n,onSelect:o,onDelete:f,disabled:S,unread:j}){const{t:m}=ie(),p=ke(t.lastActiveAt??t.createdAt),x=oe(t.status)||j;return e.jsxs("div",{className:y("group ml-4 mr-2 flex items-center rounded-md transition-colors",n?"bg-accent":"hover:bg-accent/50"),children:[e.jsxs("button",{type:"button",onClick:o,title:t.title,className:"flex min-w-0 flex-1 animate-task-enter items-center gap-2.5 rounded-md px-2 py-2 text-left text-sm",children:[e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(pe,{size:14,className:"text-muted-foreground"})}),e.jsx("span",{className:y("min-w-0 flex-1 truncate",n?"font-medium text-foreground":"text-foreground/90"),children:t.title}),x?e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(gt,{status:t.status,unread:j})}):e.jsx("span",{className:"flex w-14 shrink-0 items-center justify-end text-[11px] tabular-nums text-muted-foreground/50",children:e.jsx("span",{className:"truncate group-hover:hidden",children:p})})]}),e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),f()},disabled:S,className:"mr-1 hidden shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-background hover:text-destructive disabled:opacity-50 group-hover:flex",title:m("Delete"),children:e.jsx(st,{size:14})})]})}function vt({isOpen:t,conversations:n,onClose:o,onSelectConversation:f}){const{t:S}=ie(),[j,m]=r.useState(""),[p,x]=r.useState(0),C=r.useRef(null);r.useEffect(()=>{t&&(m(""),x(0))},[t]);const N=r.useMemo(()=>{const a=j.trim().toLowerCase();return a?n.filter(d=>d.title.toLowerCase().includes(a)).slice(0,50):n.slice(0,12)},[n,j]);r.useEffect(()=>{x(0)},[j]),r.useEffect(()=>{C.current?.children[p]?.scrollIntoView({block:"nearest"})},[p]);const I=r.useCallback(a=>{f(a),o()},[o,f]),O=r.useCallback(a=>{if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="ArrowDown"){a.preventDefault(),x(d=>Math.min(d+1,N.length-1));return}if(a.key==="ArrowUp"){a.preventDefault(),x(d=>Math.max(d-1,0));return}if(a.key==="Enter"&&!a.nativeEvent.isComposing){a.preventDefault();const d=N[p];d&&I(d)}},[p,I,o,N]);if(!t)return null;const T=j.trim().length>0;return e.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:o}),e.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-border bg-popover shadow-lg animate-in fade-in zoom-in-95 duration-100",children:[e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border/60 px-4",children:[e.jsx(we,{size:15,className:"shrink-0 text-muted-foreground/70"}),e.jsx("input",{value:j,onChange:a=>m(a.target.value),onKeyDown:O,placeholder:S("Search conversations..."),"aria-label":S("Search conversations..."),autoFocus:!0,className:"flex-1 border-none bg-transparent py-3 text-sm text-foreground placeholder-muted-foreground/60 focus:outline-none"})]}),N.length>0?e.jsxs(e.Fragment,{children:[T?null:e.jsx("div",{className:"px-4 pb-1 pt-2.5 text-[11px] font-medium text-muted-foreground/70",children:S("Recent conversations")}),e.jsx("div",{ref:C,className:"max-h-[46vh] overflow-y-auto pb-1.5 pt-0.5 scrollbar-app-thin",children:N.map((a,d)=>e.jsxs("button",{type:"button",onClick:()=>I(a),onMouseEnter:()=>x(d),className:y("flex w-full items-center gap-2.5 px-4 py-2 text-left transition-colors",d===p&&"bg-accent"),children:[e.jsx(pe,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground/90",title:a.title,children:a.title}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/60",children:ke(a.lastActiveAt??a.createdAt)})]},a.id))})]}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:S("No matching conversations")})]})]})}function Mt(){const{t}=ie();ht();const n=Te(),{usesIntegratedTitlebar:o,desktopPlatform:f,hasMacTrafficLights:S}=Le(),j=o&&f==="win32",{conversationId:m}=Pe(),p=Z(),[x,C]=r.useState(""),[N,I]=r.useState("idle"),[O,T]=r.useState(null),[a,d]=r.useState(!1),[_,z]=r.useState(!1),[$,G]=r.useState(xt),[F,K]=r.useState(()=>new Set),{data:k=[],isLoading:H}=it(),{data:ee,isLoading:ce}=lt(m),{data:L=[],isLoading:de}=et(),ue=ct(),V=dt(),P=ut(),W=mt(),i=ee??k.find(s=>s.id===m)??null,D=r.useMemo(()=>L.filter(({availability:s})=>s.type!=="NOT_FOUND"),[L]),me=D.map(({provider:s})=>({id:s.id,name:s.name,agentType:s.agentType,available:!0})),E=!!m,J=E||a,Q=r.useCallback(s=>{p.invalidateQueries({queryKey:h.conversations.all}),s&&p.invalidateQueries({queryKey:h.conversations.detail(s)})},[p]),fe=r.useCallback(()=>{Q(m)},[m,Q]),g=r.useCallback(s=>{if(K(u=>{if(!u.has(s.id))return u;const b=new Set(u);return b.delete(s.id),b}),s.status!==w.COMPLETED)return;const l=Math.max(Date.now(),ye(s));G(u=>{if(u[s.id]&&u[s.id]>=l)return u;const b={...u,[s.id]:l};return ve(b),b})},[]),te=r.useCallback(s=>{K(l=>{if(l.has(s))return l;const u=new Set(l);return u.add(s),u})},[]),se=r.useCallback(s=>{K(l=>{if(!l.has(s))return l;const u=new Set(l);return u.delete(s),u}),G(l=>{if(!(s in l))return l;const u={...l};return delete u[s],ve(u),u})},[]),Y=r.useMemo(()=>{const s=new Map;for(const l of k)s.set(l.sessionId,l);return i&&s.set(i.sessionId,i),s},[i,k]),ne=r.useCallback(s=>s.status!==w.COMPLETED?!1:F.has(s.id)?!0:ye(s)>($[s.id]??0),[$,F]);r.useEffect(()=>{!x&&D.length>0&&C(D[0].provider.id)},[D,x]),r.useEffect(()=>{i?.providerId&&C(i.providerId)},[i?.providerId]),r.useEffect(()=>{m&&d(!1)},[m]),r.useEffect(()=>{i&&g(i)},[i,g]),r.useEffect(()=>{const s=Me.connect(),l=u=>{const b=Y.get(u.sessionId);if(b){if(Q(b.id),u.status!==w.COMPLETED){g(b);return}if(b.id===m){g(b);return}te(b.id)}};return s.on(be.SESSION_COMPLETED,l),()=>{s.off(be.SESSION_COMPLETED,l)}},[m,Y,Q,g,te]);const A=()=>{T(null),d(!0),n("/conversations")},M=()=>{d(!1),n("/conversations")},R=r.useCallback(s=>{g(s),d(!1),n(`/conversations/${s.id}`)},[g,n]),X=async s=>{if(!(!s.providerId||!s.title.trim()||N!=="idle")){I("starting-session"),T(null);try{const l=await ue.mutateAsync({prompt:s.title.trim(),providerId:s.providerId,attachmentIds:s.attachmentIds});C(s.providerId),d(!1),n(`/conversations/${l.id}`)}catch(l){T(l instanceof Error?l.message:t("Failed to start. Please try again."))}finally{I("idle")}}},xe=async s=>{!i||!s.message.trim()||V.isPending||await V.mutateAsync({id:i.id,message:s.message,providerId:s.providerId||x||void 0,attachmentIds:s.attachmentIds})},re=async()=>{!i||!oe(i.status)||P.isPending||await P.mutateAsync(i.id)},he=async s=>{window.confirm(t("Delete this conversation?"))&&(await W.mutateAsync(s),se(s),m===s&&(d(!1),n("/conversations")))};return e.jsxs("div",{className:"flex h-dvh flex-col overflow-hidden bg-sidebar text-sm text-foreground",children:[e.jsxs("header",{className:y("flex h-12 shrink-0 items-center justify-between bg-sidebar px-4",o&&"app-region-drag",j&&"pr-[150px]"),children:[e.jsxs("div",{className:y("flex min-w-0 items-center gap-2",S&&"pl-[72px]"),children:[e.jsx(Je,{}),e.jsx(Ye,{}),e.jsx("span",{className:"mx-1.5 select-none text-muted-foreground/40",children:"/"}),e.jsx("span",{className:"truncate text-sm font-medium text-foreground/90",children:t("Conversation")})]}),e.jsx("button",{type:"button",onClick:()=>qe.getState().openSettings(),className:y("rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground",o&&"app-region-no-drag"),title:t("Settings"),children:e.jsx(Re,{size:16})})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("aside",{className:y("h-full w-full shrink-0 flex-col bg-sidebar md:flex md:w-[320px]",J?"hidden md:flex":"flex"),children:[e.jsxs("div",{className:"shrink-0 px-2 pb-1 pt-2",children:[e.jsxs("button",{type:"button",onClick:A,className:y("flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm transition-colors",a?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"),title:t("New Conversation"),children:[e.jsx(Xe,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("New Conversation")})]}),e.jsxs("button",{type:"button",onClick:()=>n("/"),className:"flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent/50",title:t("Tasks"),children:[e.jsx(rt,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Tasks")})]}),e.jsxs("button",{type:"button",onClick:()=>z(!0),className:"flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent/50",title:t("Search"),children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Search")})]})]}),e.jsx("div",{className:"relative min-h-0 flex-1 overflow-y-auto scrollbar-app-thin pb-4 pt-3",children:H?e.jsx("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:t("Loading...")}):k.length===0?e.jsxs("div",{className:"flex h-full select-none flex-col items-center justify-center px-6 text-center",children:[e.jsx(pe,{size:36,className:"mb-3 text-muted-foreground/40",strokeWidth:1.5}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:t("No conversations")}),e.jsx("button",{type:"button",onClick:A,className:"rounded-md bg-brand px-3.5 py-1.5 text-xs font-medium text-brand-foreground transition-colors hover:bg-brand/90",children:t("New Conversation")})]}):e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex w-full items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"flex-1 text-left",children:t("History")}),e.jsx("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/50",children:k.length})]}),e.jsx("div",{className:"mt-0.5 flex min-h-[40px] flex-col rounded-md",children:k.map(s=>e.jsx(bt,{conversation:s,selected:s.id===m,disabled:W.isPending,unread:s.id!==m&&ne(s),onSelect:()=>R(s),onDelete:()=>he(s.id)},s.id))})]})}),e.jsx("div",{className:"flex items-center justify-between border-t border-border/60 px-4 py-3 text-xs text-muted-foreground/70",children:e.jsxs("span",{children:[t("Conversations")," · ",k.length]})})]}),e.jsxs("main",{className:y("min-w-0 flex-1 flex-col bg-background md:mb-2 md:mr-2 md:overflow-hidden md:rounded-xl md:border md:border-border/50",J?"flex":"hidden md:flex"),children:[e.jsx("header",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border/60 px-4 md:px-5",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[E||a?e.jsx("button",{type:"button",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground md:hidden",onClick:M,title:t("Back"),children:e.jsx(tt,{size:17})}):null,e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold",children:i?.title??t("New Conversation")}),i?e.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[pt(i.status,t),i.directoryName?` · ${i.directoryName}`:""]}):null]})]})}),!i&&E?e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-4 text-sm text-muted-foreground",children:t(ce?"Loading...":"Conversation not found")}):i?e.jsx(ot,{sessionId:i.sessionId,sessionStatus:i.status,agentType:i.agentType,providerId:x||i.providerId,providers:L,initialTokenUsage:i.tokenUsage,onProviderChange:C,onSend:xe,onStop:re,onExit:fe,isSending:V.isPending,isStopping:P.isPending,canStop:oe(i.status)}):e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 pb-[10vh] md:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[e.jsx("h1",{className:"mb-8 max-w-full break-words text-center text-3xl leading-tight tracking-tight text-foreground",children:t("需要我帮你做点什么?")}),e.jsx(Ze,{variant:"conversation",projects:[],providers:me,isProvidersLoading:de,defaultProviderId:x,createStep:N,placeholder:"Ask a question...",submitLabel:"Start",pendingLabel:"Starting...",submitTitle:"Start",onSubmit:async({title:s,providerId:l,attachmentIds:u})=>{await X({title:s,providerId:l,attachmentIds:u})}}),O?e.jsx("div",{className:"mt-3 rounded-lg border border-destructive/15 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:O}):null]})})]})]}),e.jsx(vt,{isOpen:_,conversations:k,onClose:()=>z(!1),onSelectConversation:R})]})}export{Mt as ConversationPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as q,j as e,u as ce,r as n,aa as Re,O as Ye,x as Ge,y as Ve,$ as le,P as Ae,h as b,X as Xe,ab as Ze,ac as Je,ad as Qe}from"./index-3VWij2vw.js";import{W as L,u as et,A as tt}from"./mermaid-NOHMQCX5-DjJdrIaK.js";import{A as se}from"./AgentLogo-Bqjt1u2k.js";import{C as re}from"./chevron-down-o4IZE_P6.js";import{C as X}from"./check-CjNklwnC.js";import{M as ze}from"./MemberAvatar-DKsedKpu.js";import{u as st}from"./use-providers-C-PIoFvi.js";import{P as rt}from"./trash-2-CWVsy23V.js";import{P as nt}from"./useNormalizedLogs-CGOi3cNq.js";import{F as ot}from"./folder-C-l50KQ-.js";const at=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ot=q("arrow-down",at);const it=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],lt=q("arrow-up",it);const ct=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],dt=q("gauge",ct);const ut=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],mt=q("git-branch",ut);const ft=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pt=q("search",ft);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pt=q("shield",xt);const gt=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ft=q("square-pen",gt);const ht=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bt=q("zap",ht);function be({content:a,children:c,className:d="",side:l="top"}){const j=l==="bottom"?"top-full mt-2":"bottom-full mb-2",v=l==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative inline-block ${d}`,children:[c,e.jsxs("div",{className:`invisible absolute ${j} left-1/2 -translate-x-1/2 max-w-[260px] px-3 py-2 bg-neutral-900 text-white text-xs leading-relaxed rounded-lg opacity-0 group-hover/tooltip:visible group-hover/tooltip:opacity-100 group-focus-within/tooltip:visible group-focus-within/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-normal z-[100] shadow-lg`,children:[a,e.jsx("div",{className:`absolute ${v} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ie(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toString()}function vt(a){return a>=.9?"text-red-500":a>=.7?"text-amber-500":"text-neutral-400"}function Bt({usage:a,tooltipSide:c="top"}){const{t:d}=ce();if(!a)return null;const l=a.modelContextWindow,j=l?a.totalTokens/l:0,v=l?Math.min(Math.round(j*100),100):null,u=l?vt(j):"text-neutral-400",y=l?e.jsx("span",{children:d("上下文: {used} / {max} tokens",{used:ie(a.totalTokens),max:ie(l)})}):e.jsx("span",{children:d("已使用: {used} tokens",{used:ie(a.totalTokens)})});return e.jsx(be,{content:y,side:c,children:e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[e.jsx(dt,{size:14,className:u}),e.jsxs("span",{className:`tabular-nums ${u}`,children:[ie(a.totalTokens),v!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",v,"%"]})]})]})})}const Nt={damping:.7,stiffness:.05,mass:1.25},jt=70,yt=1e3/60,kt=350;let de=!1;globalThis.document?.addEventListener("mousedown",()=>{de=!0});globalThis.document?.addEventListener("mouseup",()=>{de=!1});globalThis.document?.addEventListener("click",()=>{de=!1});const $t=(a={})=>{const[c,d]=n.useState(!1),[l,j]=n.useState(a.initial!==!1),[v,u]=n.useState(!1),y=n.useRef(null);y.current=a;const f=n.useCallback(()=>{if(!de)return!1;const o=window.getSelection();if(!o||!o.rangeCount)return!1;const m=o.getRangeAt(0);return m.commonAncestorContainer.contains(g.current)||g.current?.contains(m.commonAncestorContainer)},[]),N=n.useCallback(o=>{t.isAtBottom=o,j(o)},[]),x=n.useCallback(o=>{t.escapedFromLock=o,d(o)},[]),t=n.useMemo(()=>{let o;return{escapedFromLock:c,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(m){g.current&&(g.current.scrollTop=m,t.ignoreScrollToTop=g.current.scrollTop)},get targetScrollTop(){return!g.current||!F.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!F.current)return 0;const{targetScrollTop:m}=this;if(!a.targetScrollTop)return m;if(o?.targetScrollTop===m)return o.calculatedScrollTop;const p=Math.max(Math.min(a.targetScrollTop(m,{scrollElement:g.current,contentElement:F.current}),m),0);return o={targetScrollTop:m,calculatedScrollTop:p},requestAnimationFrame(()=>{o=void 0}),p},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=jt}}},[]),P=n.useCallback((o={})=>{typeof o=="string"&&(o={animation:o}),o.preserveScrollPosition||N(!0);const m=Date.now()+(Number(o.wait)||0),p=he(y.current,o.animation),{ignoreEscapes:w=!1}=o;let R,A=t.calculatedTargetScrollTop;o.duration instanceof Promise?o.duration.finally(()=>{R=Date.now()}):R=m+(o.duration??0);const M=async()=>{const H=new Promise(requestAnimationFrame).then(()=>{if(!t.isAtBottom)return t.animation=void 0,!1;const{scrollTop:z}=t,Y=performance.now(),U=(Y-(t.lastTick??Y))/yt;if(t.animation||(t.animation={behavior:p,promise:H,ignoreEscapes:w}),t.animation.behavior===p&&(t.lastTick=Y),f()||m>Date.now())return M();if(z<Math.min(A,t.calculatedTargetScrollTop)){if(t.animation?.behavior===p){if(p==="instant")return t.scrollTop=t.calculatedTargetScrollTop,M();t.velocity=(p.damping*t.velocity+p.stiffness*t.scrollDifference)/p.mass,t.accumulated+=t.velocity*U,t.scrollTop+=t.accumulated,t.scrollTop!==z&&(t.accumulated=0)}return M()}return R>Date.now()?(A=t.calculatedTargetScrollTop,M()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?P({animation:he(y.current,y.current.resize),ignoreEscapes:w,duration:Math.max(0,R-Date.now())||void 0}):t.isAtBottom)});return H.then(z=>(requestAnimationFrame(()=>{t.animation||(t.lastTick=void 0,t.velocity=0)}),z))};return o.wait!==!0&&(t.animation=void 0),t.animation?.behavior===p?t.animation.promise:M()},[N,f,t]),i=n.useCallback(()=>{x(!0),N(!1)},[x,N]),O=n.useCallback(({target:o})=>{if(o!==g.current)return;const{scrollTop:m,ignoreScrollToTop:p}=t;let{lastScrollTop:w=m}=t;t.lastScrollTop=m,t.ignoreScrollToTop=void 0,p&&p>m&&(w=p),u(t.isNearBottom),setTimeout(()=>{if(t.resizeDifference||m===p)return;if(f()){x(!0),N(!1);return}const R=m>w,A=m<w;if(t.animation?.ignoreEscapes){t.scrollTop=w;return}A&&(x(!0),N(!1)),R&&x(!1),!t.escapedFromLock&&t.isNearBottom&&N(!0)},1)},[x,N,f,t]),K=n.useCallback(({target:o,deltaY:m})=>{let p=o;for(;!["scroll","auto"].includes(getComputedStyle(p).overflow);){if(!p.parentElement)return;p=p.parentElement}p===g.current&&m<0&&g.current.scrollHeight>g.current.clientHeight&&!t.animation?.ignoreEscapes&&(x(!0),N(!1))},[x,N,t]),g=Ie(o=>{g.current?.removeEventListener("scroll",O),g.current?.removeEventListener("wheel",K),o?.addEventListener("scroll",O,{passive:!0}),o?.addEventListener("wheel",K,{passive:!0})},[]),F=Ie(o=>{if(t.resizeObserver?.disconnect(),!o)return;let m;t.resizeObserver=new ResizeObserver(([p])=>{const{height:w}=p.contentRect,R=w-(m??w);if(t.resizeDifference=R,t.scrollTop>t.targetScrollTop&&(t.scrollTop=t.targetScrollTop),u(t.isNearBottom),R>=0){const A=he(y.current,m?y.current.resize:y.current.initial);P({animation:A,wait:!0,preserveScrollPosition:!0,duration:A==="instant"?void 0:kt})}else t.isNearBottom&&(x(!1),N(!0));m=w,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===R&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(o)},[]);return{contentRef:F,scrollRef:g,scrollToBottom:P,stopScroll:i,isAtBottom:l||v,isNearBottom:v,escapedFromLock:c,state:t}};function Ie(a,c){const d=n.useCallback(l=>(d.current=l,a(l)),c);return d}const ge=new Map;function he(...a){const c={...Nt};let d=!1;for(const j of a){if(j==="instant"){d=!0;continue}typeof j=="object"&&(d=!1,c.damping=j.damping??c.damping,c.stiffness=j.stiffness??c.stiffness,c.mass=j.mass??c.mass)}const l=JSON.stringify(c);return ge.has(l)||ge.set(l,Object.freeze(c)),d?"instant":ge.get(l)}function Ut({providers:a,currentProviderId:c,agentType:d,onSelect:l}){const{t:j}=ce(),[v,u]=n.useState(!1),y=n.useRef(null),f=a.filter(x=>String(x.provider.agentType)===d),N=a.find(x=>x.provider.id===c);return n.useEffect(()=>{function x(t){y.current&&!y.current.contains(t.target)&&u(!1)}if(v)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[v]),f.length<=1?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d})]}):e.jsxs("div",{className:"relative",ref:y,children:[e.jsxs("button",{onClick:()=>u(!v),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${N?.provider.name??d} (click to change)`,children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d}),e.jsx(re,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:j("切换渠道")}),f.map(x=>e.jsxs("button",{onClick:()=>{l(x.provider.id),u(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${x.provider.id===c?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(se,{agentType:x.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:x.provider.name}),x.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:j("(默认)")})]}),x.provider.id===c&&e.jsx(X,{size:14,className:"shrink-0"})]},x.provider.id))]})]})}function Wt(a,c){return n.useMemo(()=>{for(let d=a.length-1;d>=0;d--){const l=a[d];if(l.tokenUsage&&typeof l.tokenUsage.totalTokens=="number"&&l.tokenUsage.totalTokens>0)return{totalTokens:l.tokenUsage.totalTokens,modelContextWindow:l.tokenUsage.modelContextWindow}}return c??null},[a,c])}function Le(a,c,d,l){if(d.filter(u=>u===l).length<=1)return a;const v=d.slice(0,c+1).filter(u=>u===l).length;return`${a} #${v}`}function wt(a){return Object.values(a).filter(Boolean).length}function Tt({mode:a,setMode:c,selectedTemplateId:d,setSelectedTemplateId:l,selectedMemberPresetIds:j,setSelectedMemberPresetIds:v,disabled:u=!1,compact:y=!1}){const{t:f}=ce(),{preserveDesktopSearch:N}=Ye(),[x,t]=n.useState(!1),{data:P}=st(),{data:i,isError:O,isFetching:K,isLoading:g,refetch:F}=Ge(),{data:o,isError:m,isFetching:p,isLoading:w,refetch:R}=Ve(),A=n.useMemo(()=>new Map((P??[]).map(({provider:r,availability:h})=>[r.id,r.name+(h.type==="NOT_FOUND"?f(" (不可用)"):"")])),[P,f]),M=n.useMemo(()=>new Map((i??[]).map(r=>[r.id,r])),[i]),H=n.useMemo(()=>new Map((o??[]).map(r=>[r.id,r])),[o]),z=n.useMemo(()=>j.map(r=>M.get(r)).filter(r=>!!r),[M,j]);n.useEffect(()=>{i!==void 0&&v(r=>{const h=r.filter(T=>M.has(T));return h.length===r.length&&h.every((T,_)=>T===r[_])?r:h})},[i,M,v]),n.useEffect(()=>{o!==void 0&&l(r=>!r||H.has(r)?r:null)},[l,H,o]);const Y=r=>{u||l(h=>h===r?null:r)},U=r=>{u||v(h=>[...h,r])},ue=r=>{u||v(h=>h.filter((T,_)=>_!==r))},ne=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:f("团队模板")}),m?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{R()},disabled:u||p,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):w?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(o??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有团队模板"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:b("space-y-1.5",y&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(o??[]).map(r=>{const h=r.id===d,T=r.members?.length??0,_=r.members?.map(B=>B.memberPresetId)??[],W=r.members?.slice(0,3).map((B,me)=>Le(B.memberPreset?.name??B.memberPresetId,me,_,B.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>Y(r.id),disabled:u,className:b("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",h?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:b("text-xs truncate",h?"font-medium text-foreground":"text-foreground"),children:r.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[T,f("人")]})]}),W&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:W})]}),h&&e.jsx(X,{size:13,className:"shrink-0 text-foreground"})]})},r.id)})})]}),Z=z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map((r,h)=>{const T=Le(r.name,h,j,r.id);return e.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded-md border border-border/60 bg-background text-[10px] text-foreground",children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:T}),e.jsx("button",{type:"button",onClick:()=>ue(h),disabled:u,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Xe,{size:9})})]},`${r.id}-${h}`)})}),G=O?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{F()},disabled:u||K,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(i??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有成员预设"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(i??[]).map(r=>{const h=j.filter(W=>W===r.id).length,T=A.get(r.providerId)??r.providerId,_=wt(r.capabilities);return e.jsxs("button",{type:"button",onClick:()=>U(r.id),disabled:u,className:b("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",u&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:r.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[T," · ",_,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",h]}),e.jsx(rt,{size:12,className:"text-muted-foreground"})]})]},r.id)})}),J=z.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-primary text-[10px] font-semibold text-primary-foreground px-1.5",children:z.length}),V=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:f("执行模式")}),e.jsxs("div",{className:"inline-flex items-center h-7 rounded-md border border-border/70 bg-background p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&c("AUTO"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(bt,{size:11}),f("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!u&&c("CONFIRM"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(pt,{size:11}),f("确认模式")]})]})]});return y?e.jsxs("div",{className:"space-y-3",children:[V,ne,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&t(r=>!r),disabled:u,"aria-expanded":x,className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(re,{size:12,className:b("transition-transform",x?"":"-rotate-90")}),f("追加独立成员"),J]}),x&&e.jsxs("div",{className:"mt-2",children:[Z,G]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[V,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[ne,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:f("追加成员")}),J]}),Z,G]})]})]})}function qt({className:a="h-7 w-7"}){return e.jsx("img",{src:Ze,alt:"Agent Tower",className:`block shrink-0 object-contain ${a}`})}function Kt({className:a=""}){return e.jsx("span",{className:`font-semibold text-foreground tracking-tight text-base ${a}`,children:"Agent Tower"})}const Ct={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Ht({variant:a="task",projects:c,providers:d,isProvidersLoading:l,onSubmit:j,defaultProjectId:v="",defaultProviderId:u="",onProjectChange:y,createStep:f,placeholder:N,submitLabel:x,pendingLabel:t,submitTitle:P}){const{t:i}=ce(),[O,K]=n.useState(""),[g,F]=n.useState(v),[o,m]=n.useState(u),[p,w]=n.useState("SOLO"),[R,A]=n.useState(L.WORKTREE),[M,H]=n.useState("AUTO"),[z,Y]=n.useState(null),[U,ue]=n.useState([]),[ne,Z]=n.useState(!1),[G,J]=n.useState(!1),[V,r]=n.useState(!1),[h,T]=n.useState(!1),_=n.useRef(null),W=n.useRef(null),B=n.useRef(null),me=n.useRef(null),ve=n.useRef(null),{files:Ne,addFiles:Q,removeFile:De,clear:je,buildMarkdownLinks:ye,getDoneAttachments:ke,isUploading:oe}=et(),C=a==="conversation",k=a==="task"||a==="conversation",_e=x??i(C?"开始":"创建");n.useEffect(()=>{F(v),y?.(v)},[v,y]),n.useEffect(()=>{m(u)},[u]),n.useEffect(()=>{if(!G)return;const s=S=>{_.current&&!_.current.contains(S.target)&&J(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[G]),n.useEffect(()=>{if(!V)return;const s=S=>{W.current&&!W.current.contains(S.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[V]),n.useEffect(()=>{if(!h)return;const s=S=>{B.current&&!B.current.contains(S.target)&&T(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[h]);const ae=n.useMemo(()=>c.find(s=>s.id===g),[c,g]),fe=n.useMemo(()=>d.find(s=>s.id===o),[d,o]),Oe=ae?.isGitRepo!==!1,D=!C&&!Oe,I=D?"SOLO":p,$=D?L.MAIN_DIRECTORY:R,Pe=$===L.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),we=i("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),Fe=i("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),Te=i("初始化 Git 后可使用工作树模式。"),E=f!=="idle",Ce=!!z||U.length>0,ee=!E&&!oe&&O.trim().length>0&&(C?!!o:!!g&&(I==="SOLO"?!!o:Ce));n.useEffect(()=>{D&&(w("SOLO"),A(L.MAIN_DIRECTORY),Z(!1),T(!1))},[D]);const xe=n.useCallback(async()=>{if(!ee)return;const s=k?ye():"",S=k?ke().map(te=>te.id):[];try{await j({title:O.trim(),description:"",projectId:C?"":g,providerId:o,mode:C?"SOLO":I,workspaceMode:!C&&I==="SOLO"?$:L.WORKTREE,teamRunMode:C?"AUTO":M,teamTemplateId:C||D?null:z,memberPresetIds:C||D?[]:U,attachmentLinks:s,attachmentIds:S}),K(""),k&&je()}catch{}},[ee,k,ye,ke,j,O,C,g,o,I,$,M,D,z,U,je]),Be=n.useCallback(s=>{s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),xe())},[xe]),$e=n.useCallback(s=>{const S=s.target.files;S&&S.length>0&&Q(Array.from(S)),s.target.value=""},[Q]),Ue=n.useCallback(s=>{F(s),y?.(s),J(!1)},[y]),We=n.useCallback(s=>{if(!k)return;const S=s.clipboardData.items,te=[];for(const Me of S)if(Me.kind==="file"){const Ee=Me.getAsFile();Ee&&te.push(Ee)}te.length>0&&(s.preventDefault(),Q(te))},[Q,k]),[Se,pe]=n.useState(!1),qe=n.useCallback(s=>{k&&(s.preventDefault(),pe(!0))},[k]),Ke=n.useCallback(s=>{k&&(s.preventDefault(),pe(!1))},[k]),He=n.useCallback(s=>{if(!k)return;s.preventDefault(),pe(!1);const S=s.dataTransfer.files;S.length>0&&Q(Array.from(S))},[Q,k]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:b("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Se?"border-info bg-info/5":"border-border",E&&"opacity-80"),onDragOver:k?qe:void 0,onDragLeave:k?Ke:void 0,onDrop:k?He:void 0,children:[k&&Ne.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(tt,{files:Ne,onRemove:De})}),e.jsx("textarea",{ref:me,value:O,onChange:s=>K(s.target.value),onKeyDown:Be,onPaste:k?We:void 0,placeholder:i(N||"Describe your task..."),disabled:E,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-[15px] text-foreground placeholder:text-muted-foreground/80 leading-relaxed",style:{minHeight:"76px",maxHeight:"220px",fieldSizing:"content"}}),k&&Se&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-center py-3 border border-dashed border-info/40 rounded-lg text-xs font-medium text-info",children:i("Drop files here")})}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:k?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>ve.current?.click(),disabled:E||oe,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:e.jsx(nt,{size:18})}),e.jsx("input",{ref:ve,type:"file",multiple:!0,onChange:$e,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[k&&oe&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i("Uploading...")]}),E&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i(t??Ct[f])]}),!C&&!E&&!oe&&I==="TEAM"&&!Ce&&O.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:i("请选择团队模板或追加成员")}),ee&&e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[11px] text-muted-foreground/80 select-none",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-border bg-muted/60 text-[10px] font-medium text-muted-foreground leading-none",children:"⏎"}),_e]}),e.jsx("button",{type:"button",onClick:xe,disabled:!ee,className:b("flex items-center justify-center size-8 rounded-lg transition-all duration-200",ee?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:i(P||"Create & Start"),children:e.jsx(lt,{size:16,strokeWidth:2.5})})]})]})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!C&&e.jsxs("div",{className:"relative",ref:_,children:[e.jsxs("button",{type:"button",onClick:()=>{E||J(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",ae?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(ot,{size:14,className:"shrink-0",style:{color:ae?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:ae?.name??i("Project")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",G&&"rotate-180")})]}),G&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:c.map(s=>e.jsxs("button",{type:"button",onClick:()=>Ue(s.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:s.color??"var(--muted-foreground)"}}),e.jsx("span",{className:b("truncate flex-1",s.id===g?"text-foreground font-medium":"text-muted-foreground"),children:s.name}),e.jsx(X,{size:14,className:b("ml-2 shrink-0 text-foreground",s.id===g?"opacity-100":"opacity-0")})]},s.id))})]}),(C||I==="SOLO")&&e.jsxs("div",{className:"relative",ref:W,children:[e.jsxs("button",{type:"button",onClick:()=>{E||r(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",fe?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(se,{agentType:fe?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:fe?.name??i(l?"Loading...":"Agent")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",V&&"rotate-180")})]}),V&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:d.map(s=>e.jsxs("button",{type:"button",disabled:!s.available,onClick:()=>{m(s.id),r(!1)},className:b("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!s.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(X,{size:14,className:b("mr-2 shrink-0 text-foreground",s.id===o?"opacity-100":"opacity-0")}),e.jsx(se,{agentType:s.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:b("min-w-0 truncate",s.id===o?"text-foreground font-medium":"text-muted-foreground"),children:[s.name,s.available?"":i(" (unavailable)")]})]},s.id))})]}),!C&&I==="SOLO"&&e.jsxs("div",{className:"relative",ref:B,children:[e.jsxs("button",{type:"button",onClick:()=>{E||T(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(mt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:Pe}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",h&&"rotate-180")})]}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[D?e.jsx(be,{side:"bottom",className:"block w-full",content:Te,children:e.jsx("div",{tabIndex:0,"aria-label":Te,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(X,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]})})}):e.jsxs("button",{type:"button",onClick:()=>{A(L.WORKTREE),T(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]}),e.jsxs("button",{type:"button",onClick:()=>{A(L.MAIN_DIRECTORY),T(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:i("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]})]})]}),!C&&e.jsx(be,{side:"bottom",className:"ml-auto",content:D?i("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):$===L.MAIN_DIRECTORY?i("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):i("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":I==="TEAM",onClick:()=>{E||D||(p==="TEAM"?(w("SOLO"),Z(!1)):(w("TEAM"),T(!1),A(L.WORKTREE),Z(!0)))},disabled:E||D,className:b("flex items-center gap-2 h-7 pl-2 pr-2 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",I==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":i("启用团队模式"),children:[e.jsx(Je,{size:14,className:I==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:i("团队模式")}),(D||$===L.MAIN_DIRECTORY)&&I!=="TEAM"?e.jsx(Qe,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:b("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",I==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:b("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",I==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),!C&&I==="TEAM"&&ne&&e.jsx("div",{className:"mt-2.5 rounded-xl border border-border/60 bg-muted/40 p-3 animate-[fadeInUp_0.25s_cubic-bezier(0.16,1,0.3,1)]",children:e.jsx(Tt,{mode:M,setMode:H,selectedTemplateId:z,setSelectedTemplateId:Y,selectedMemberPresetIds:U,setSelectedMemberPresetIds:ue,disabled:E,compact:!0})})]})}export{Ot as A,qt as B,Ht as C,mt as G,Ut as P,Ft as S,Bt as T,bt as Z,Wt as a,lt as b,Kt as c,Pt as d,be as e,Tt as f,pt as g,$t as u};
|
|
1
|
+
import{g as q,j as e,u as ce,r as n,aa as Re,O as Ye,x as Ge,y as Ve,$ as le,P as Ae,h as b,X as Xe,ab as Ze,ac as Je,ad as Qe}from"./index-7nw4fV42.js";import{W as L,u as et,A as tt}from"./mermaid-NOHMQCX5-B42ziicV.js";import{A as se}from"./AgentLogo-ThhvSi7G.js";import{C as re}from"./chevron-down--B7iZqBL.js";import{C as X}from"./check-D2WWIhwV.js";import{M as ze}from"./MemberAvatar-Y_pJlw-N.js";import{u as st}from"./use-providers-erJ2iHLz.js";import{P as rt}from"./trash-2-B7GFt5Wl.js";import{P as nt}from"./useNormalizedLogs-CXAn7xj_.js";import{F as ot}from"./folder-u7fKAtz_.js";const at=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ot=q("arrow-down",at);const it=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],lt=q("arrow-up",it);const ct=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],dt=q("gauge",ct);const ut=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],mt=q("git-branch",ut);const ft=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pt=q("search",ft);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pt=q("shield",xt);const gt=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ft=q("square-pen",gt);const ht=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bt=q("zap",ht);function be({content:a,children:c,className:d="",side:l="top"}){const j=l==="bottom"?"top-full mt-2":"bottom-full mb-2",v=l==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative inline-block ${d}`,children:[c,e.jsxs("div",{className:`invisible absolute ${j} left-1/2 -translate-x-1/2 max-w-[260px] px-3 py-2 bg-neutral-900 text-white text-xs leading-relaxed rounded-lg opacity-0 group-hover/tooltip:visible group-hover/tooltip:opacity-100 group-focus-within/tooltip:visible group-focus-within/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-normal z-[100] shadow-lg`,children:[a,e.jsx("div",{className:`absolute ${v} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ie(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toString()}function vt(a){return a>=.9?"text-red-500":a>=.7?"text-amber-500":"text-neutral-400"}function Bt({usage:a,tooltipSide:c="top"}){const{t:d}=ce();if(!a)return null;const l=a.modelContextWindow,j=l?a.totalTokens/l:0,v=l?Math.min(Math.round(j*100),100):null,u=l?vt(j):"text-neutral-400",y=l?e.jsx("span",{children:d("上下文: {used} / {max} tokens",{used:ie(a.totalTokens),max:ie(l)})}):e.jsx("span",{children:d("已使用: {used} tokens",{used:ie(a.totalTokens)})});return e.jsx(be,{content:y,side:c,children:e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[e.jsx(dt,{size:14,className:u}),e.jsxs("span",{className:`tabular-nums ${u}`,children:[ie(a.totalTokens),v!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",v,"%"]})]})]})})}const Nt={damping:.7,stiffness:.05,mass:1.25},jt=70,yt=1e3/60,kt=350;let de=!1;globalThis.document?.addEventListener("mousedown",()=>{de=!0});globalThis.document?.addEventListener("mouseup",()=>{de=!1});globalThis.document?.addEventListener("click",()=>{de=!1});const $t=(a={})=>{const[c,d]=n.useState(!1),[l,j]=n.useState(a.initial!==!1),[v,u]=n.useState(!1),y=n.useRef(null);y.current=a;const f=n.useCallback(()=>{if(!de)return!1;const o=window.getSelection();if(!o||!o.rangeCount)return!1;const m=o.getRangeAt(0);return m.commonAncestorContainer.contains(g.current)||g.current?.contains(m.commonAncestorContainer)},[]),N=n.useCallback(o=>{t.isAtBottom=o,j(o)},[]),x=n.useCallback(o=>{t.escapedFromLock=o,d(o)},[]),t=n.useMemo(()=>{let o;return{escapedFromLock:c,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(m){g.current&&(g.current.scrollTop=m,t.ignoreScrollToTop=g.current.scrollTop)},get targetScrollTop(){return!g.current||!F.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!F.current)return 0;const{targetScrollTop:m}=this;if(!a.targetScrollTop)return m;if(o?.targetScrollTop===m)return o.calculatedScrollTop;const p=Math.max(Math.min(a.targetScrollTop(m,{scrollElement:g.current,contentElement:F.current}),m),0);return o={targetScrollTop:m,calculatedScrollTop:p},requestAnimationFrame(()=>{o=void 0}),p},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=jt}}},[]),P=n.useCallback((o={})=>{typeof o=="string"&&(o={animation:o}),o.preserveScrollPosition||N(!0);const m=Date.now()+(Number(o.wait)||0),p=he(y.current,o.animation),{ignoreEscapes:w=!1}=o;let R,A=t.calculatedTargetScrollTop;o.duration instanceof Promise?o.duration.finally(()=>{R=Date.now()}):R=m+(o.duration??0);const M=async()=>{const H=new Promise(requestAnimationFrame).then(()=>{if(!t.isAtBottom)return t.animation=void 0,!1;const{scrollTop:z}=t,Y=performance.now(),U=(Y-(t.lastTick??Y))/yt;if(t.animation||(t.animation={behavior:p,promise:H,ignoreEscapes:w}),t.animation.behavior===p&&(t.lastTick=Y),f()||m>Date.now())return M();if(z<Math.min(A,t.calculatedTargetScrollTop)){if(t.animation?.behavior===p){if(p==="instant")return t.scrollTop=t.calculatedTargetScrollTop,M();t.velocity=(p.damping*t.velocity+p.stiffness*t.scrollDifference)/p.mass,t.accumulated+=t.velocity*U,t.scrollTop+=t.accumulated,t.scrollTop!==z&&(t.accumulated=0)}return M()}return R>Date.now()?(A=t.calculatedTargetScrollTop,M()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?P({animation:he(y.current,y.current.resize),ignoreEscapes:w,duration:Math.max(0,R-Date.now())||void 0}):t.isAtBottom)});return H.then(z=>(requestAnimationFrame(()=>{t.animation||(t.lastTick=void 0,t.velocity=0)}),z))};return o.wait!==!0&&(t.animation=void 0),t.animation?.behavior===p?t.animation.promise:M()},[N,f,t]),i=n.useCallback(()=>{x(!0),N(!1)},[x,N]),O=n.useCallback(({target:o})=>{if(o!==g.current)return;const{scrollTop:m,ignoreScrollToTop:p}=t;let{lastScrollTop:w=m}=t;t.lastScrollTop=m,t.ignoreScrollToTop=void 0,p&&p>m&&(w=p),u(t.isNearBottom),setTimeout(()=>{if(t.resizeDifference||m===p)return;if(f()){x(!0),N(!1);return}const R=m>w,A=m<w;if(t.animation?.ignoreEscapes){t.scrollTop=w;return}A&&(x(!0),N(!1)),R&&x(!1),!t.escapedFromLock&&t.isNearBottom&&N(!0)},1)},[x,N,f,t]),K=n.useCallback(({target:o,deltaY:m})=>{let p=o;for(;!["scroll","auto"].includes(getComputedStyle(p).overflow);){if(!p.parentElement)return;p=p.parentElement}p===g.current&&m<0&&g.current.scrollHeight>g.current.clientHeight&&!t.animation?.ignoreEscapes&&(x(!0),N(!1))},[x,N,t]),g=Ie(o=>{g.current?.removeEventListener("scroll",O),g.current?.removeEventListener("wheel",K),o?.addEventListener("scroll",O,{passive:!0}),o?.addEventListener("wheel",K,{passive:!0})},[]),F=Ie(o=>{if(t.resizeObserver?.disconnect(),!o)return;let m;t.resizeObserver=new ResizeObserver(([p])=>{const{height:w}=p.contentRect,R=w-(m??w);if(t.resizeDifference=R,t.scrollTop>t.targetScrollTop&&(t.scrollTop=t.targetScrollTop),u(t.isNearBottom),R>=0){const A=he(y.current,m?y.current.resize:y.current.initial);P({animation:A,wait:!0,preserveScrollPosition:!0,duration:A==="instant"?void 0:kt})}else t.isNearBottom&&(x(!1),N(!0));m=w,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===R&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(o)},[]);return{contentRef:F,scrollRef:g,scrollToBottom:P,stopScroll:i,isAtBottom:l||v,isNearBottom:v,escapedFromLock:c,state:t}};function Ie(a,c){const d=n.useCallback(l=>(d.current=l,a(l)),c);return d}const ge=new Map;function he(...a){const c={...Nt};let d=!1;for(const j of a){if(j==="instant"){d=!0;continue}typeof j=="object"&&(d=!1,c.damping=j.damping??c.damping,c.stiffness=j.stiffness??c.stiffness,c.mass=j.mass??c.mass)}const l=JSON.stringify(c);return ge.has(l)||ge.set(l,Object.freeze(c)),d?"instant":ge.get(l)}function Ut({providers:a,currentProviderId:c,agentType:d,onSelect:l}){const{t:j}=ce(),[v,u]=n.useState(!1),y=n.useRef(null),f=a.filter(x=>String(x.provider.agentType)===d),N=a.find(x=>x.provider.id===c);return n.useEffect(()=>{function x(t){y.current&&!y.current.contains(t.target)&&u(!1)}if(v)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[v]),f.length<=1?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d})]}):e.jsxs("div",{className:"relative",ref:y,children:[e.jsxs("button",{onClick:()=>u(!v),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${N?.provider.name??d} (click to change)`,children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d}),e.jsx(re,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:j("切换渠道")}),f.map(x=>e.jsxs("button",{onClick:()=>{l(x.provider.id),u(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${x.provider.id===c?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(se,{agentType:x.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:x.provider.name}),x.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:j("(默认)")})]}),x.provider.id===c&&e.jsx(X,{size:14,className:"shrink-0"})]},x.provider.id))]})]})}function Wt(a,c){return n.useMemo(()=>{for(let d=a.length-1;d>=0;d--){const l=a[d];if(l.tokenUsage&&typeof l.tokenUsage.totalTokens=="number"&&l.tokenUsage.totalTokens>0)return{totalTokens:l.tokenUsage.totalTokens,modelContextWindow:l.tokenUsage.modelContextWindow}}return c??null},[a,c])}function Le(a,c,d,l){if(d.filter(u=>u===l).length<=1)return a;const v=d.slice(0,c+1).filter(u=>u===l).length;return`${a} #${v}`}function wt(a){return Object.values(a).filter(Boolean).length}function Tt({mode:a,setMode:c,selectedTemplateId:d,setSelectedTemplateId:l,selectedMemberPresetIds:j,setSelectedMemberPresetIds:v,disabled:u=!1,compact:y=!1}){const{t:f}=ce(),{preserveDesktopSearch:N}=Ye(),[x,t]=n.useState(!1),{data:P}=st(),{data:i,isError:O,isFetching:K,isLoading:g,refetch:F}=Ge(),{data:o,isError:m,isFetching:p,isLoading:w,refetch:R}=Ve(),A=n.useMemo(()=>new Map((P??[]).map(({provider:r,availability:h})=>[r.id,r.name+(h.type==="NOT_FOUND"?f(" (不可用)"):"")])),[P,f]),M=n.useMemo(()=>new Map((i??[]).map(r=>[r.id,r])),[i]),H=n.useMemo(()=>new Map((o??[]).map(r=>[r.id,r])),[o]),z=n.useMemo(()=>j.map(r=>M.get(r)).filter(r=>!!r),[M,j]);n.useEffect(()=>{i!==void 0&&v(r=>{const h=r.filter(T=>M.has(T));return h.length===r.length&&h.every((T,_)=>T===r[_])?r:h})},[i,M,v]),n.useEffect(()=>{o!==void 0&&l(r=>!r||H.has(r)?r:null)},[l,H,o]);const Y=r=>{u||l(h=>h===r?null:r)},U=r=>{u||v(h=>[...h,r])},ue=r=>{u||v(h=>h.filter((T,_)=>_!==r))},ne=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:f("团队模板")}),m?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{R()},disabled:u||p,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):w?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(o??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有团队模板"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:b("space-y-1.5",y&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(o??[]).map(r=>{const h=r.id===d,T=r.members?.length??0,_=r.members?.map(B=>B.memberPresetId)??[],W=r.members?.slice(0,3).map((B,me)=>Le(B.memberPreset?.name??B.memberPresetId,me,_,B.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>Y(r.id),disabled:u,className:b("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",h?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:b("text-xs truncate",h?"font-medium text-foreground":"text-foreground"),children:r.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[T,f("人")]})]}),W&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:W})]}),h&&e.jsx(X,{size:13,className:"shrink-0 text-foreground"})]})},r.id)})})]}),Z=z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map((r,h)=>{const T=Le(r.name,h,j,r.id);return e.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded-md border border-border/60 bg-background text-[10px] text-foreground",children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:T}),e.jsx("button",{type:"button",onClick:()=>ue(h),disabled:u,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Xe,{size:9})})]},`${r.id}-${h}`)})}),G=O?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{F()},disabled:u||K,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(i??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有成员预设"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(i??[]).map(r=>{const h=j.filter(W=>W===r.id).length,T=A.get(r.providerId)??r.providerId,_=wt(r.capabilities);return e.jsxs("button",{type:"button",onClick:()=>U(r.id),disabled:u,className:b("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",u&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:r.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[T," · ",_,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",h]}),e.jsx(rt,{size:12,className:"text-muted-foreground"})]})]},r.id)})}),J=z.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-primary text-[10px] font-semibold text-primary-foreground px-1.5",children:z.length}),V=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:f("执行模式")}),e.jsxs("div",{className:"inline-flex items-center h-7 rounded-md border border-border/70 bg-background p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&c("AUTO"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(bt,{size:11}),f("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!u&&c("CONFIRM"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(pt,{size:11}),f("确认模式")]})]})]});return y?e.jsxs("div",{className:"space-y-3",children:[V,ne,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&t(r=>!r),disabled:u,"aria-expanded":x,className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(re,{size:12,className:b("transition-transform",x?"":"-rotate-90")}),f("追加独立成员"),J]}),x&&e.jsxs("div",{className:"mt-2",children:[Z,G]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[V,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[ne,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:f("追加成员")}),J]}),Z,G]})]})]})}function qt({className:a="h-7 w-7"}){return e.jsx("img",{src:Ze,alt:"Agent Tower",className:`block shrink-0 object-contain ${a}`})}function Kt({className:a=""}){return e.jsx("span",{className:`font-semibold text-foreground tracking-tight text-base ${a}`,children:"Agent Tower"})}const Ct={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Ht({variant:a="task",projects:c,providers:d,isProvidersLoading:l,onSubmit:j,defaultProjectId:v="",defaultProviderId:u="",onProjectChange:y,createStep:f,placeholder:N,submitLabel:x,pendingLabel:t,submitTitle:P}){const{t:i}=ce(),[O,K]=n.useState(""),[g,F]=n.useState(v),[o,m]=n.useState(u),[p,w]=n.useState("SOLO"),[R,A]=n.useState(L.WORKTREE),[M,H]=n.useState("AUTO"),[z,Y]=n.useState(null),[U,ue]=n.useState([]),[ne,Z]=n.useState(!1),[G,J]=n.useState(!1),[V,r]=n.useState(!1),[h,T]=n.useState(!1),_=n.useRef(null),W=n.useRef(null),B=n.useRef(null),me=n.useRef(null),ve=n.useRef(null),{files:Ne,addFiles:Q,removeFile:De,clear:je,buildMarkdownLinks:ye,getDoneAttachments:ke,isUploading:oe}=et(),C=a==="conversation",k=a==="task"||a==="conversation",_e=x??i(C?"开始":"创建");n.useEffect(()=>{F(v),y?.(v)},[v,y]),n.useEffect(()=>{m(u)},[u]),n.useEffect(()=>{if(!G)return;const s=S=>{_.current&&!_.current.contains(S.target)&&J(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[G]),n.useEffect(()=>{if(!V)return;const s=S=>{W.current&&!W.current.contains(S.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[V]),n.useEffect(()=>{if(!h)return;const s=S=>{B.current&&!B.current.contains(S.target)&&T(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[h]);const ae=n.useMemo(()=>c.find(s=>s.id===g),[c,g]),fe=n.useMemo(()=>d.find(s=>s.id===o),[d,o]),Oe=ae?.isGitRepo!==!1,D=!C&&!Oe,I=D?"SOLO":p,$=D?L.MAIN_DIRECTORY:R,Pe=$===L.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),we=i("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),Fe=i("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),Te=i("初始化 Git 后可使用工作树模式。"),E=f!=="idle",Ce=!!z||U.length>0,ee=!E&&!oe&&O.trim().length>0&&(C?!!o:!!g&&(I==="SOLO"?!!o:Ce));n.useEffect(()=>{D&&(w("SOLO"),A(L.MAIN_DIRECTORY),Z(!1),T(!1))},[D]);const xe=n.useCallback(async()=>{if(!ee)return;const s=k?ye():"",S=k?ke().map(te=>te.id):[];try{await j({title:O.trim(),description:"",projectId:C?"":g,providerId:o,mode:C?"SOLO":I,workspaceMode:!C&&I==="SOLO"?$:L.WORKTREE,teamRunMode:C?"AUTO":M,teamTemplateId:C||D?null:z,memberPresetIds:C||D?[]:U,attachmentLinks:s,attachmentIds:S}),K(""),k&&je()}catch{}},[ee,k,ye,ke,j,O,C,g,o,I,$,M,D,z,U,je]),Be=n.useCallback(s=>{s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),xe())},[xe]),$e=n.useCallback(s=>{const S=s.target.files;S&&S.length>0&&Q(Array.from(S)),s.target.value=""},[Q]),Ue=n.useCallback(s=>{F(s),y?.(s),J(!1)},[y]),We=n.useCallback(s=>{if(!k)return;const S=s.clipboardData.items,te=[];for(const Me of S)if(Me.kind==="file"){const Ee=Me.getAsFile();Ee&&te.push(Ee)}te.length>0&&(s.preventDefault(),Q(te))},[Q,k]),[Se,pe]=n.useState(!1),qe=n.useCallback(s=>{k&&(s.preventDefault(),pe(!0))},[k]),Ke=n.useCallback(s=>{k&&(s.preventDefault(),pe(!1))},[k]),He=n.useCallback(s=>{if(!k)return;s.preventDefault(),pe(!1);const S=s.dataTransfer.files;S.length>0&&Q(Array.from(S))},[Q,k]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:b("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Se?"border-info bg-info/5":"border-border",E&&"opacity-80"),onDragOver:k?qe:void 0,onDragLeave:k?Ke:void 0,onDrop:k?He:void 0,children:[k&&Ne.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(tt,{files:Ne,onRemove:De})}),e.jsx("textarea",{ref:me,value:O,onChange:s=>K(s.target.value),onKeyDown:Be,onPaste:k?We:void 0,placeholder:i(N||"Describe your task..."),disabled:E,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-[15px] text-foreground placeholder:text-muted-foreground/80 leading-relaxed",style:{minHeight:"76px",maxHeight:"220px",fieldSizing:"content"}}),k&&Se&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-center py-3 border border-dashed border-info/40 rounded-lg text-xs font-medium text-info",children:i("Drop files here")})}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:k?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>ve.current?.click(),disabled:E||oe,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:e.jsx(nt,{size:18})}),e.jsx("input",{ref:ve,type:"file",multiple:!0,onChange:$e,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[k&&oe&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i("Uploading...")]}),E&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i(t??Ct[f])]}),!C&&!E&&!oe&&I==="TEAM"&&!Ce&&O.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:i("请选择团队模板或追加成员")}),ee&&e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[11px] text-muted-foreground/80 select-none",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-border bg-muted/60 text-[10px] font-medium text-muted-foreground leading-none",children:"⏎"}),_e]}),e.jsx("button",{type:"button",onClick:xe,disabled:!ee,className:b("flex items-center justify-center size-8 rounded-lg transition-all duration-200",ee?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:i(P||"Create & Start"),children:e.jsx(lt,{size:16,strokeWidth:2.5})})]})]})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!C&&e.jsxs("div",{className:"relative",ref:_,children:[e.jsxs("button",{type:"button",onClick:()=>{E||J(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",ae?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(ot,{size:14,className:"shrink-0",style:{color:ae?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:ae?.name??i("Project")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",G&&"rotate-180")})]}),G&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:c.map(s=>e.jsxs("button",{type:"button",onClick:()=>Ue(s.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:s.color??"var(--muted-foreground)"}}),e.jsx("span",{className:b("truncate flex-1",s.id===g?"text-foreground font-medium":"text-muted-foreground"),children:s.name}),e.jsx(X,{size:14,className:b("ml-2 shrink-0 text-foreground",s.id===g?"opacity-100":"opacity-0")})]},s.id))})]}),(C||I==="SOLO")&&e.jsxs("div",{className:"relative",ref:W,children:[e.jsxs("button",{type:"button",onClick:()=>{E||r(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",fe?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(se,{agentType:fe?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:fe?.name??i(l?"Loading...":"Agent")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",V&&"rotate-180")})]}),V&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:d.map(s=>e.jsxs("button",{type:"button",disabled:!s.available,onClick:()=>{m(s.id),r(!1)},className:b("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!s.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(X,{size:14,className:b("mr-2 shrink-0 text-foreground",s.id===o?"opacity-100":"opacity-0")}),e.jsx(se,{agentType:s.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:b("min-w-0 truncate",s.id===o?"text-foreground font-medium":"text-muted-foreground"),children:[s.name,s.available?"":i(" (unavailable)")]})]},s.id))})]}),!C&&I==="SOLO"&&e.jsxs("div",{className:"relative",ref:B,children:[e.jsxs("button",{type:"button",onClick:()=>{E||T(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(mt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:Pe}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",h&&"rotate-180")})]}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[D?e.jsx(be,{side:"bottom",className:"block w-full",content:Te,children:e.jsx("div",{tabIndex:0,"aria-label":Te,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(X,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]})})}):e.jsxs("button",{type:"button",onClick:()=>{A(L.WORKTREE),T(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]}),e.jsxs("button",{type:"button",onClick:()=>{A(L.MAIN_DIRECTORY),T(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:i("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]})]})]}),!C&&e.jsx(be,{side:"bottom",className:"ml-auto",content:D?i("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):$===L.MAIN_DIRECTORY?i("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):i("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":I==="TEAM",onClick:()=>{E||D||(p==="TEAM"?(w("SOLO"),Z(!1)):(w("TEAM"),T(!1),A(L.WORKTREE),Z(!0)))},disabled:E||D,className:b("flex items-center gap-2 h-7 pl-2 pr-2 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",I==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":i("启用团队模式"),children:[e.jsx(Je,{size:14,className:I==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:i("团队模式")}),(D||$===L.MAIN_DIRECTORY)&&I!=="TEAM"?e.jsx(Qe,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:b("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",I==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:b("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",I==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),!C&&I==="TEAM"&&ne&&e.jsx("div",{className:"mt-2.5 rounded-xl border border-border/60 bg-muted/40 p-3 animate-[fadeInUp_0.25s_cubic-bezier(0.16,1,0.3,1)]",children:e.jsx(Tt,{mode:M,setMode:H,selectedTemplateId:z,setSelectedTemplateId:Y,selectedMemberPresetIds:U,setSelectedMemberPresetIds:ue,disabled:E,compact:!0})})]})}export{Ot as A,qt as B,Ht as C,mt as G,Ut as P,Ft as S,Bt as T,bt as Z,Wt as a,lt as b,Kt as c,Pt as d,be as e,Tt as f,pt as g,$t as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as a,K as j,M as E,N as T,j as s,h as _,u as P,m as I,B as O}from"./index-
|
|
1
|
+
import{r as a,K as j,M as E,N as T,j as s,h as _,u as P,m as I,B as O}from"./index-7nw4fV42.js";function U(t){const{sessionId:c,onOutput:k,onExit:x,onError:b}=t,[p,g]=a.useState(()=>j.isConnected()),[r,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)},w=l=>{l.sessionId===c&&m.current.onOutput?.(l.data)},C=l=>{l.sessionId===c&&(d(!1),m.current.onExit?.(l.exitCode))},S=l=>{l.sessionId===c&&m.current.onError?.(l.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,w),n.on(E.SESSION_EXIT,C),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,w),n.off(E.SESSION_EXIT,C),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:r,attach:i,detach:y,sendInput:N,resize:h}}function $({className:t,...c}){return s.jsx("div",{"data-slot":"card",className:_("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...c})}function z(){const{t}=P(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[r,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}]})},[]),w=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
2
2
|
[${t("Process exited with code {code}",{code:e})}]`,timestamp:new Date}]),d(null)},[t]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
3
3
|
[${t("Error: {message}",{message:e})}]`,timestamp:new Date}])},[t]),{isConnected:S,isAttached:l,attach:D}=U({sessionId:r||"",onOutput:v,onExit:w,onError:C});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(()=>{r&&S&&!l&&D()},[r,S,l,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:t("启动失败: {message}",{message:e instanceof Error?e.message:t("未知错误")}),timestamp:new Date}])}finally{N(!1)}}},A=async()=>{if(!r||!h.trim())return;const e=h.trim();i(o=>[...o,{role:"user",content:e,timestamp:new Date}]),n("");try{await I.post(`/demo/${r}/message`,{message:e})}catch(o){i(f=>[...f,{role:"agent",content:t("发送失败: {message}",{message:o instanceof Error?o.message:t("未知错误")}),timestamp:new Date}])}},M=async()=>{if(r)try{await I.post(`/demo/${r}/stop`),i(e=>[...e,{role:"agent",content:`
|
|
4
4
|
[${t("会话已停止")}]`,timestamp:new Date}]),d(null)}catch(e){console.error("Stop failed:",e)}};return s.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:t("Agent 交互演示")}),!r&&s.jsxs($,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold mb-3",children:t("选择 Agent")}),s.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:c.map(e=>s.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&&t(" (不可用)")]},e.type))}),s.jsxs("div",{className:"flex gap-2",children:[s.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:t("输入你的问题或任务..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(O,{onClick:R,disabled:y||!x||!p.trim(),children:t(y?"启动中...":"开始")})]})]}),s.jsxs($,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:t("对话")}),r&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-500",children:t(S?l?"已连接":"连接中...":"未连接")}),s.jsx(O,{variant:"outline",size:"sm",onClick:M,children:t("停止")})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?s.jsx("div",{className:"text-gray-400 text-center py-8",children:t("选择 Agent 并输入问题开始对话")}):m.map((e,o)=>s.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[s.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?t("你"):"Agent"}),s.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),s.jsx("div",{ref:u})]}),r&&s.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[s.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:t("发送后续消息..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(O,{onClick:A,disabled:!h.trim(),children:t("发送")})]})]})]})}export{z 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-
|
|
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-7nw4fV42.js";import{S as v}from"./select-DFuN9DX8.js";import{T as O}from"./textarea-Lr4GZaYW.js";import{u as k}from"./use-providers-erJ2iHLz.js";import"./chevron-down--B7iZqBL.js";import"./check-D2WWIhwV.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{g as t,j as o}from"./index-
|
|
1
|
+
import{g as t,j as o}from"./index-7nw4fV42.js";const r=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],c=t("at-sign",r);const s=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],i=t("globe",s),l=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M8 1a7 7 0 0 0 0 14V1z",fill:"currentColor"})]}),h=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),o.jsx("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"})]}),x=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})}),d=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M13.5 4.5L6.5 11.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),w=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M5.5 5.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});export{c as A,i as G,h as I,d as a,x as b,w as c,l as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as f,r as o,L as u,j as e,R as h,X as b}from"./index-
|
|
1
|
+
import{u as f,r as o,L as u,j as e,R as h,X as b}from"./index-7nw4fV42.js";function p(){const{t:s}=f(),[a,c]=o.useState(null),x=o.useRef(null),d=o.useRef(null),i=o.useRef(null),t=a?u.find(r=>r.id===a):null,l=o.useCallback(()=>{c(null)},[]);return o.useEffect(()=>{if(!t){i.current?.focus(),i.current=null;return}d.current?.focus();const r=n=>{if(n.key==="Escape"){n.preventDefault(),l();return}n.key==="Tab"&&(n.preventDefault(),d.current?.focus())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,l]),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("style",{children:h}),e.jsx("header",{className:"border-b border-border px-6 py-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Loading Animation Preview"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("10 个首屏加载动画候选 · 颜色遵循 Agent Tower 设计规范 · 点击卡片查看全屏效果")})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8",inert:t?!0:void 0,"aria-hidden":t?!0:void 0,children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map((r,n)=>{const m=r.component;return e.jsxs("button",{onClick:g=>{i.current=g.currentTarget,c(r.id)},className:"group relative flex flex-col bg-card border border-border rounded-lg p-5 text-left transition-shadow hover:shadow-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",children:[e.jsxs("span",{className:"absolute top-3 right-3 text-[11px] font-semibold text-muted-foreground/60 tabular-nums",children:["#",n+1]}),e.jsx("div",{className:"flex items-center justify-center h-28 mb-4",children:e.jsx(m,{})}),e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:s(r.description)})]},r.id)})}),e.jsxs("div",{className:"mt-10 p-5 border border-border rounded-lg bg-muted/30",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground mb-2",children:s("设计推荐")}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1.5 leading-relaxed",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("首选:Charcoal Breathe (#10)")})," — ",s("品牌感最强,Charcoal 色块+Tower 图标呼吸,用户对产品的第一印象即品牌本身。")]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("备选A:Tower Pulse (#1)")})," — ",s("品牌图标直接出现,脉冲节奏稳定,不浮夸,适合工作台场景。")]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("备选B:Terminal Cursor (#4)")})," — ",s("终端光标闪烁,贴合 Agent/终端协作的核心场景,开发者亲切感强。")]})]})]})]}),t&&e.jsxs("div",{ref:x,className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:r=>{r.target===r.currentTarget&&l()},role:"dialog","aria-modal":"true","aria-label":s("全屏预览:{name}",{name:t.name}),children:[e.jsx("button",{ref:d,onClick:l,className:"absolute top-4 right-4 p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":s("关闭预览"),children:e.jsx(b,{size:20})}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"scale-[2] origin-center",children:e.jsx(t.component,{})}),e.jsxs("div",{className:"text-center mt-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm",children:s(t.description)})]}),e.jsx("span",{className:"text-xs text-muted-foreground/60 mt-2",children:s("按 Esc 或点击关闭按钮退出")})]})]})]})}export{p as LoadingPreviewPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as x,i as m,q as o,m as u,u as p,r as g,t as n,j as e,S as a,$ as f,B as i,a1 as h}from"./index-
|
|
1
|
+
import{g as x,i as m,q as o,m as u,u as p,r as g,t as n,j as e,S as a,$ as f,B as i,a1 as h}from"./index-7nw4fV42.js";import{C as j}from"./copy-bJ2sut_L.js";import{C as b}from"./check-D2WWIhwV.js";const y=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],N=x("server",y);function C(){return m({queryKey:o.system.mcpConfig,queryFn:()=>u.get("/system/mcp-config")})}function v({mode:s,label:t}){const r=s==="desktop-packaged";return e.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-1 text-[11px] font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:t})}function z(){const{t:s}=p(),{data:t,isLoading:r,isError:l,refetch:d}=C(),c=g.useCallback(async()=>{if(t?.configJson)try{await navigator.clipboard.writeText(t.configJson),n.success(s("MCP 配置已复制"))}catch{n.error(s("复制 MCP 配置失败"))}},[t?.configJson,s]);return r?e.jsx(a,{children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-neutral-500"})})}):l||!t?e.jsxs(a,{children:[e.jsx("h2",{className:"mb-1 text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("div",{className:"mt-5 rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:s("MCP 配置加载失败")}),e.jsx(i,{className:"mt-4",size:"sm",variant:"outline",onClick:()=>{d()},children:s("重试")})]}):e.jsxs(a,{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-neutral-500",children:s("复制下面的 JSON 到支持 MCP 的客户端配置中。桌面打包版使用 App 内置 runtime,不需要全局安装 agent-tower。")})]}),e.jsxs(i,{size:"sm",onClick:c,children:[e.jsx(j,{size:14}),s("复制配置")]})]}),e.jsxs("div",{className:"space-y-3 border-b border-neutral-100 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{mode:t.runtimeMode,label:t.runtimeMode==="desktop-packaged"?s("桌面打包 runtime"):s("工作区 runtime")}),e.jsx("span",{className:"text-[12px] text-neutral-400",children:t.serverName})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(h,{size:12}),"Command"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.command})]}),e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(N,{size:12}),"Entry"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.args[0]??""})]})]})]}),e.jsxs("div",{className:"pt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:"mcpServers JSON"}),t.runtimeMode==="desktop-packaged"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600",children:[e.jsx(b,{size:12}),s("无需全局 CLI")]})]}),e.jsx("textarea",{readOnly:!0,value:t.configJson,rows:14,className:"w-full resize-y rounded-lg border border-neutral-200 bg-neutral-950 px-3 py-3 font-mono text-[12px] leading-relaxed text-neutral-100 outline-none"}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-neutral-400",children:s("当前版本只生成通用 MCP 配置,不会自动修改 Claude、Codex 或其他第三方客户端配置文件。")})]})]})}export{z as McpSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as n,h as o}from"./index-
|
|
1
|
+
import{r as i,j as n,h as o}from"./index-7nw4fV42.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{g 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,Z as B,d as W,e as j,_ as z,B as L,$ as M,a0 as A,f as K,W as Q}from"./index-
|
|
1
|
+
import{g 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,Z as B,d as W,e as j,_ as z,B as L,$ as M,a0 as A,f as K,W as Q}from"./index-7nw4fV42.js";import{S as _}from"./select-DFuN9DX8.js";import{I as d}from"./input-CKwRYuUJ.js";import{S as O}from"./switch-gL7lBFj6.js";import{M as D}from"./message-square-Bd_m34OX.js";import{C as H}from"./circle-alert-W13JkYj3.js";import"./chevron-down--B7iZqBL.js";import"./check-D2WWIhwV.js";const Z=[["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"}]],$=P("link",Z);function G(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function J(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function V(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function oe(){const{t}=R(),{data:i,isLoading:y}=G(),l=J(),n=V(),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(W,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:z,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(O,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:D,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(_,{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(L,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(M,{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(A,{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($,{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(K,{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(Q,{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,h as P}from"./index-
|
|
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,h as P}from"./index-7nw4fV42.js";import{u as U,a as _,b as z,c as B}from"./use-profiles-zIsoigD8.js";import{M as F}from"./modal-CxOKWOjZ.js";import{C as G}from"./confirm-dialog-BAqfLDT8.js";import{I as $}from"./input-CKwRYuUJ.js";import{T as R}from"./textarea-Lr4GZaYW.js";import{L as H}from"./layers-BbLzQqyy.js";import{C as q}from"./chevron-down--B7iZqBL.js";import{P as K,T as Q}from"./trash-2-B7GFt5Wl.js";import{P as W}from"./pencil-h5kxwbcu.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(K,{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(Q,{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 ce(){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:H,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($,{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(R,{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(G,{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{ce as ProfileSettingsPage};
|