agent-tower 0.5.3-beta.3 → 0.5.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/AgentDemoPage-DC61uZJ_.js +1 -0
- package/dist/web/assets/{AgentLogo-DQId6FqS.js → AgentLogo-CGrwilQJ.js} +1 -1
- package/dist/web/assets/ConversationPage-DvD_lYUj.js +3 -0
- package/dist/web/assets/CreateTaskInput-CstzayW9.js +2 -0
- package/dist/web/assets/DemoPage-BDUjXkK3.js +4 -0
- package/dist/web/assets/{GeneralSettingsPage-CFc1CWWl.js → GeneralSettingsPage-DuYC1Vhv.js} +1 -1
- package/dist/web/assets/{Icons-EVcY239B.js → Icons-BqZeUyTx.js} +1 -1
- package/dist/web/assets/LoadingPreviewPage-DPA8HxNr.js +1 -0
- package/dist/web/assets/{McpSettingsPage-BujDKp8T.js → McpSettingsPage-BO_Fd_mA.js} +1 -1
- package/dist/web/assets/{MemberAvatar-Bvlu6rk3.js → MemberAvatar-BesdHRgJ.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-Dsn-5Uft.js → NotificationSettingsPage-F5HPtn9-.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-CuhQBP_t.js → ProfileSettingsPage-DweTPF_t.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DiEo6BK_.js → ProjectKanbanPage-taUI2xm6.js} +32 -32
- package/dist/web/assets/{ProjectSettingsPage-Cj46vZYF.js → ProjectSettingsPage-BfTQwRb7.js} +2 -2
- package/dist/web/assets/ProviderSettingsPage-Cio0LIzm.js +86 -0
- package/dist/web/assets/{SettingsMasterDetail-_vE8P7ke.js → SettingsMasterDetail-BnqVBe7H.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-CC_QgVbE.js → TeamSettingsPage-CHoLj7rL.js} +1 -1
- package/dist/web/assets/{arc-DWusz5nt.js → arc-CYddG-Kz.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BzUiKOFe.js → architectureDiagram-3BPJPVTR-B3RXX4-J.js} +1 -1
- package/dist/web/assets/{arrow-left-C_pxdzZL.js → arrow-left-CufhOEz9.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-BGx2sLYW.js → blockDiagram-GPEHLZMM-a7Dr_zcs.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BCihVD7R.js → c4Diagram-AAUBKEIU-BLwSao_g.js} +1 -1
- package/dist/web/assets/channel-BTbcDemz.js +1 -0
- package/dist/web/assets/check-C5Ba8Rby.js +1 -0
- package/dist/web/assets/{chevron-down-DuZqUX3d.js → chevron-down-BQyZkT4A.js} +1 -1
- package/dist/web/assets/{chevron-right-BTjA7BSq.js → chevron-right-94xg9kiO.js} +1 -1
- package/dist/web/assets/{chevron-up-BeZXjQ4W.js → chevron-up-BZM-aGAU.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-BVhYZ0vK.js → chunk-2J33WTMH-CV8jFvSt.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-amtolJb4.js → chunk-4BX2VUAB-DXquqZ4n.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Bi5q9Evi.js → chunk-55IACEB6-BowEEH_6.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-Bb_qV3PR.js → chunk-727SXJPM-Cbn9G9U_.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-BhFBU2pH.js → chunk-AQP2D5EJ-C-0K23VQ.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-CbBz10YF.js → chunk-FMBD7UC4-BJv0I_Lt.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-B930BNNl.js → chunk-ND2GUHAM-DJBjsrJO.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-YlRfC0oD.js → chunk-QZHKN3VN-CBw_GG0t.js} +1 -1
- package/dist/web/assets/{circle-alert-DCm2E91k.js → circle-alert-lbce0dXY.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-D4Noh8IG.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-D4Noh8IG.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-ImXQka3_.js → code-block-OCS4YCEC-CRG-xCnX.js} +1 -1
- package/dist/web/assets/{confirm-dialog-Cc27tq8j.js → confirm-dialog-Cnw_rxtM.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-Di3PzbLp.js → cose-bilkent-S5V4N54A-DCNqQrFt.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-DD7qiU9m.js → dagre-BM42HDAG-oecZRFap.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-Bgr-CjRi.js → diagram-2AECGRRQ-BXx6WNMi.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-CvRORhH2.js → diagram-5GNKFQAL-Bu66xpEW.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-CkVyLyvM.js → diagram-KO2AKTUF-ZGMyoO90.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-B-CPQQuU.js → diagram-LMA3HP47-riQUwPgu.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-DXow9CgH.js → diagram-OG6HWLK6-H_PHYJoy.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-BPLJJwjL.js → erDiagram-TEJ5UH35-ePGpWuWD.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-ggyugmK6.js → flowDiagram-I6XJVG4X-BZUDzSVZ.js} +1 -1
- package/dist/web/assets/{folder-B35uD7uF.js → folder-Ca5RFac7.js} +1 -1
- package/dist/web/assets/{folder-picker-DFxfUtH5.js → folder-picker-CZIjxGNQ.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-317n6mcW.js → ganttDiagram-6RSMTGT7-D2UOmWEL.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DTUyiJew.js → gitGraphDiagram-PVQCEYII-DEzWWRW3.js} +1 -1
- package/dist/web/assets/index-17XUvLGe.css +1 -0
- package/dist/web/assets/{index-BwKL3rKp.js → index-JK3A62-g.js} +4 -4
- package/dist/web/assets/index-M-QRACZK.js +120 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-1GXYdkvW.js → infoDiagram-5YYISTIA-BNClnI_5.js} +1 -1
- package/dist/web/assets/{input-6lLP89Y3.js → input-7UYarzFy.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DSGxwLxL.js → ishikawaDiagram-YF4QCWOH-B1aSs8GW.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-Bk9wMzSo.js → journeyDiagram-JHISSGLW-DlXxUTcw.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BW3QAONh.js → kanban-definition-UN3LZRKU-Ctkuw8kN.js} +1 -1
- package/dist/web/assets/{layers-CDcLPjE5.js → layers-C89p38EX.js} +1 -1
- package/dist/web/assets/{linear-DTyT0tZy.js → linear--QsFiowO.js} +1 -1
- package/dist/web/assets/{loader-circle-DDrZegLO.js → loader-circle-DolxjVmY.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-CeIvIbfU.js → mermaid-NOHMQCX5-CW_FGpKP.js} +3 -3
- package/dist/web/assets/{message-square-CunpcgQi.js → message-square-KV4Azzxs.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CMuh1LCP.js → mindmap-definition-RKZ34NQL-Dm6rZMiM.js} +1 -1
- package/dist/web/assets/{modal-D8uSzIAd.js → modal-PZSR91HW.js} +1 -1
- package/dist/web/assets/{pencil-BTaYfjKo.js → pencil-9lMJOuw2.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-8PB3-bCK.js → pieDiagram-4H26LBE5-DbQPjRBP.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Dpf14KEr.js → quadrantDiagram-W4KKPZXB-DeRrMc4Y.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-ClTLx63o.js → requirementDiagram-4Y6WPE33-aajAoXSH.js} +1 -1
- package/dist/web/assets/{rotate-ccw-bVmcWqcA.js → rotate-ccw-D7tnDKF_.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-ChlGi0jn.js → sankeyDiagram-5OEKKPKP-DWsta0ns.js} +1 -1
- package/dist/web/assets/{select-tNVeGe-v.js → select-CTiftuHJ.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-6tJ810tk.js → sequenceDiagram-3UESZ5HK-BGBP9NTB.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Cc5dwA5r.js → stateDiagram-AJRCARHV-Dl0Q7uMb.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BEhmiwth.js +1 -0
- package/dist/web/assets/{switch-7jE2n-KP.js → switch-BhqMnTiu.js} +1 -1
- package/dist/web/assets/{terminal-D5iU4zAj.js → terminal-BR0PXV2W.js} +1 -1
- package/dist/web/assets/{textarea-DVa2Yvj4.js → textarea-eWIZ3eZW.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-q32Hcn4m.js → timeline-definition-PNZ67QCA-DuDIvs1s.js} +1 -1
- package/dist/web/assets/{trash-2-z7TLHqpU.js → trash-2-C7F85sIB.js} +1 -1
- package/dist/web/assets/{upload-DeI535ZH.js → upload-CQTsuurY.js} +1 -1
- package/dist/web/assets/{use-profiles-BS_Mkp5d.js → use-profiles-Btexu_oH.js} +1 -1
- package/dist/web/assets/{use-providers-CWfLQ--R.js → use-providers-BEPU5ALg.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-DW37m6Ji.js → useNormalizedLogs-CvCCSYxy.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-VxBXMI4P.js → vennDiagram-CIIHVFJN-BDyKeyr8.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-BvNOQGfh.js → wardley-L42UT6IY-DAOA5Zsv.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DMTZkLB4.js → wardleyDiagram-YWT4CUSO-CCmLvkBT.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-BaJ2kymJ.js → xychartDiagram-2RQKCTM6-EsyeKzfj.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@prisma/client/.prisma/client/edge.js +3 -4
- package/node_modules/@prisma/client/.prisma/client/index.js +3 -4
- package/node_modules/@prisma/client/default.d.ts +1 -1
- package/node_modules/@prisma/client/default.js +1 -1
- package/node_modules/@prisma/client/edge.d.ts +1 -1
- package/node_modules/@prisma/client/edge.js +1 -1
- package/node_modules/@prisma/client/index-browser.js +1 -1
- package/node_modules/@prisma/client/index.d.ts +1 -1
- package/node_modules/@prisma/client/index.js +1 -1
- package/node_modules/@prisma/client/package.json +0 -2
- package/node_modules/@prisma/client/react-native.d.ts +1 -1
- package/node_modules/@prisma/client/react-native.js +1 -1
- package/node_modules/@prisma/client/sql.d.ts +1 -1
- package/node_modules/@prisma/client/sql.js +1 -1
- package/node_modules/@prisma/client/sql.mjs +1 -1
- package/node_modules/@prisma/client/wasm.d.ts +1 -1
- package/node_modules/@prisma/client/wasm.js +1 -1
- package/package.json +1 -2
- package/dist/web/assets/AgentDemoPage-Cc1sKLmE.js +0 -1
- package/dist/web/assets/ConversationPage-BXDIbwTR.js +0 -3
- package/dist/web/assets/CreateTaskInput-CDynnXvO.js +0 -2
- package/dist/web/assets/DemoPage-BeL28u5_.js +0 -4
- package/dist/web/assets/LoadingPreviewPage-CRwEvHz_.js +0 -1
- package/dist/web/assets/ProviderSettingsPage-G7pPagR6.js +0 -54
- package/dist/web/assets/channel-BBvaRDfe.js +0 -1
- package/dist/web/assets/check-C7Na6M49.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-XuAtffBc.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-XuAtffBc.js +0 -1
- package/dist/web/assets/index-DgO-2xBV.css +0 -1
- package/dist/web/assets/index-OY1TIdAK.js +0 -120
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-EVHRu9u3.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-tower",
|
|
3
|
-
"version": "0.5.3-beta.
|
|
3
|
+
"version": "0.5.3-beta.4",
|
|
4
4
|
"description": "AI Agent Task Management Dashboard",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"dist/",
|
|
22
22
|
"prisma/",
|
|
23
23
|
"scripts/",
|
|
24
|
-
"node_modules/.prisma/",
|
|
25
24
|
"node_modules/@agent-tower/",
|
|
26
25
|
"node_modules/@prisma/",
|
|
27
26
|
"node_modules/@shitiandmw/",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as H,u as Q,r as n,m as b,j as e,B as y,M as X,N as Y}from"./index-OY1TIdAK.js";import{u as Z,a as ee,T as te,P as se,S as ne}from"./useNormalizedLogs-DW37m6Ji.js";import{b as re}from"./mermaid-NOHMQCX5-CeIvIbfU.js";import{I as L,a as ae,b as le,A as ie,G as oe}from"./Icons-EVcY239B.js";import{d as ce}from"./use-profiles-BS_Mkp5d.js";import{C as de}from"./chevron-up-BeZXjQ4W.js";import{C as xe}from"./chevron-down-DuZqUX3d.js";import"./check-C7Na6M49.js";import"./chevron-right-BTjA7BSq.js";const me=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ue=H("hash",me);const pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],he=H("send",pe),ge=!0;function ke(){const{t:s}=Q(),[w,U]=n.useState([]),[i,S]=n.useState(""),[x,A]=n.useState("DEFAULT"),[o,k]=n.useState(""),[a,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),C=n.useRef(null),$=n.useRef(null),u=n.useRef(null),{data:p}=ce(i),F=p?Object.keys(p):["DEFAULT"],M=t=>{S(t),A("DEFAULT")},V=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),_=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:B,agentSessionId:I,attach:z,clearLogs:P}=Z({sessionId:a||"",onExit:V,onError:_}),{todos:R}=ee(B);n.useEffect(()=>{b.get("/demo/agents").then(t=>{U(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const G=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},O=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});ge&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),D(r.sessionId),c("running")}catch(r){console.error("Start failed:",r),c("error")}},T=async()=>{if(!a||!m.trim())return;const t=m.trim();j("");try{await b.post(`/demo/${a}/message`,{message:t})}catch(r){console.error("Send failed:",r)}},K=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},q=()=>{D(null),c("idle"),k(""),j(""),P()},J=l==="running",d=a!==null,W=w.find(t=>t.type===i);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:d?o.slice(0,50)+(o.length>50?"...":""):s("新会话")})]}),e.jsxs("div",{className:"flex items-center",children:[l==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),l==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(ae,{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(le,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),l==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),l==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),d&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${g?"":"truncate"}`,onClick:()=>E(!g),children:o}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(de,{size:14}):e.jsx(xe,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:W?.name||i||s("未选择")})]}),x!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:x})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:s("连接")}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${h?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(h?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(y,{variant:"outline",size:"sm",onClick:q,className:"ml-auto",children:s("新会话")}),e.jsxs(X,{to:"/settings/profiles",className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(Y,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:$,className:"flex-1 overflow-y-auto px-8 py-6",children:d?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:s("等待 Agent 响应...")}):e.jsx(re,{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:()=>M(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:F.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:O,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(te,{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:G,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(se,{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(ie,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(ue,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(oe,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[J&&e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(ne,{size:12,fill:"currentColor"}),e.jsx("span",{children:s("停止")})]}),e.jsxs("button",{onClick:T,disabled:!m.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${m.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:s("发送")}),e.jsx(he,{size:14})]})]})]})]})})]})}export{ke as AgentDemoPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{h as Ee,u as le,r,j as e,g as k,i as ve,k as J,l as ce,q as x,m as Q,U as Ae,V as Le,I as Te,J as he,N as Pe,W as Me,Y as oe}from"./index-OY1TIdAK.js";import{b as Re,S as w}from"./mermaid-NOHMQCX5-CeIvIbfU.js";import{u as qe,a as ze,T as Oe,P as Fe,S as Ke}from"./useNormalizedLogs-DW37m6Ji.js";import{u as Ue,a as Qe,b as Be,A as _e,c as $e,P as Ge,T as Ve,d as He,B as We,e as Je,S as Ye,f as ye,C as Xe}from"./CreateTaskInput-CDynnXvO.js";import{u as Ze}from"./use-providers-CWfLQ--R.js";import{M as me}from"./message-square-CunpcgQi.js";import{A as et}from"./arrow-left-C_pxdzZL.js";import{T as tt}from"./trash-2-z7TLHqpU.js";import"./chevron-right-BTjA7BSq.js";import"./chevron-down-DuZqUX3d.js";import"./check-C7Na6M49.js";import"./AgentLogo-DQId6FqS.js";import"./loader-circle-DDrZegLO.js";import"./MemberAvatar-Bvlu6rk3.js";import"./folder-B35uD7uF.js";const st=[["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"}]],nt=Ee("layout-list",st);function rt(t){return t===w.RUNNING||t===w.PENDING}function at({sessionId:t,sessionStatus:n,agentType:a,providerId:m,providers:h,initialTokenUsage:f,onProviderChange:S,onSend:y,onStop:N,onExit:I,isSending:p=!1,isStopping:g=!1,canStop:B,className:R}){const{t:o}=le(),[u,q]=r.useState(""),[A,C]=r.useState(m??""),[Y,_]=r.useState(!1),[X,z]=r.useState(null),$=r.useRef(null),Z=r.useRef(null),G=r.useRef(null),L=r.useRef(!1),{scrollRef:ee,contentRef:i,isAtBottom:O,scrollToBottom:V}=Ue({initial:"instant",resize:"smooth"}),{isConnected:F,isLoadingSnapshot:te,logs:D,entries:de,attach:j}=qe({sessionId:t,sessionStatus:n,onExit:I}),{todos:H}=ze(de),ue=Qe(D,f),{files:se,addFiles:E,removeFile:ne,clear:re,buildMarkdownLinks:W,getDoneAttachments:ae,hasFiles:T,isUploading:P}=Be(),K=rt(n),s=B??K;r.useEffect(()=>{C(m??"")},[m]),r.useEffect(()=>{t&&F&&j()},[t,F,j]);const l=r.useCallback(c=>{C(c),S?.(c)},[S]),d=r.useCallback(()=>{$.current&&($.current.style.height="60px")},[]),b=r.useCallback(c=>{q(c.target.value);const v=c.target;v.style.height="auto",v.style.height=`${Math.max(60,Math.min(v.scrollHeight,300))}px`},[]),fe=r.useCallback(async()=>{if(!u.trim()&&!T||L.current||p||P)return;L.current=!0;const c=W(),v=ae().map(M=>M.id),U=[u.trim(),c].filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`);q(""),re(),d(),z(null);try{await y({message:U,providerId:A||void 0,attachmentIds:v}),await j(),requestAnimationFrame(()=>V("smooth"))}catch(M){z(M instanceof Error?M.message:o("Send failed. Please try again.")),q(U)}finally{L.current=!1}},[u,T,p,P,W,ae,re,d,y,A,j,V,o]),we=r.useCallback(async()=>{!s||g||await N()},[s,g,N]),Ce=r.useCallback(c=>{const v=c.target.files;v&&v.length>0&&E(Array.from(v)),c.target.value=""},[E]),ke=r.useCallback(c=>{const v=c.clipboardData.items,U=[];for(const M of v)if(M.kind==="file"){const xe=M.getAsFile();xe&&U.push(xe)}U.length>0&&(c.preventDefault(),E(U))},[E]),Se=r.useCallback(c=>{c.preventDefault(),_(!0)},[]),Ie=r.useCallback(c=>{c.preventDefault(),_(!1)},[]),De=r.useCallback(c=>{c.preventDefault(),_(!1);const v=c.dataTransfer.files;v.length>0&&E(Array.from(v))},[E]);return e.jsxs("div",{className:k("relative flex min-h-0 flex-1 flex-col bg-background",R),children:[e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:ee,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pb-4 pt-6",children:e.jsx("div",{ref:i,className:"mx-auto w-full min-w-0 max-w-4xl",children:te?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:o("Loading logs...")})]}):D.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground/70",children:o(K?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(Re,{logs:D})})}),!O&&e.jsxs("button",{type:"button",onClick:()=>V(),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":o("Scroll to bottom"),children:[e.jsx(_e,{size:14}),e.jsx("span",{children:o("Back to bottom")})]})]}),H.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(Oe,{todos:H})})}),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:[X?e.jsx("div",{className:"mb-2 text-sm text-destructive",children:X}):null,e.jsxs("div",{ref:G,className:k("relative rounded-xl border bg-background transition-colors duration-200 hover:border-ring/40 focus-within:border-ring/60",Y?"border-info bg-info/5":"border-border"),children:[e.jsx($e,{files:se,onRemove:ne}),e.jsx("textarea",{ref:$,value:u,onChange:b,onPaste:ke,onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.repeat&&!c.nativeEvent.isComposing&&c.nativeEvent.keyCode!==229&&(c.preventDefault(),fe())},rows:1,placeholder:o(Y?"Drop files here...":t&&!K?"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:Z,type:"file",multiple:!0,className:"hidden",onChange:Ce}),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:()=>Z.current?.click(),disabled:P,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:o("Upload file"),children:e.jsx(Fe,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{providers:h,currentProviderId:A,agentType:a,onSelect:l}),e.jsx(Ve,{usage:ue}),s&&K&&!u.trim()&&!T?e.jsx("button",{type:"button",onClick:we,disabled:g,className:"rounded-lg bg-destructive p-2 text-white transition-all duration-200 hover:bg-destructive/90 disabled:opacity-50",title:o("Stop"),children:e.jsx(Ke,{size:14})}):e.jsx("button",{type:"button",onClick:fe,disabled:!u.trim()&&!T||P||p,className:k("rounded-lg p-2 transition-all duration-200",(u.trim()||T)&&!P&&!p?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-transparent text-muted-foreground/50"),title:o("Send"),children:e.jsx(He,{size:18})})]})]})]})]})})]})}function ot(t=50){return ve({queryKey:x.conversations.list({limit:t}),queryFn:()=>Q.get("/conversations",{params:{limit:String(t)}})})}function it(t){return ve({queryKey:x.conversations.detail(t??""),queryFn:()=>Q.get(`/conversations/${t}`),enabled:!!t})}function lt(){const t=J();return ce({mutationFn:n=>Q.post("/conversations",n),onSuccess:n=>{t.setQueryData(x.conversations.detail(n.id),n),t.invalidateQueries({queryKey:x.conversations.all}),t.invalidateQueries({queryKey:x.sessions.detail(n.sessionId)})}})}function ct(){const t=J();return ce({mutationFn:({id:n,...a})=>Q.post(`/conversations/${n}/message`,a),onSuccess:n=>{t.setQueryData(x.conversations.detail(n.id),n),t.invalidateQueries({queryKey:x.conversations.all}),t.invalidateQueries({queryKey:x.sessions.detail(n.sessionId)})}})}function dt(){const t=J();return ce({mutationFn:n=>Q.post(`/conversations/${n}/stop`),onSuccess:n=>{t.setQueryData(x.conversations.detail(n.id),n),t.invalidateQueries({queryKey:x.conversations.all}),t.invalidateQueries({queryKey:x.sessions.detail(n.sessionId)})}})}function ut(){const t=J();return ce({mutationFn:n=>Q.delete(`/conversations/${n}`),onSuccess:(n,a)=>{t.removeQueries({queryKey:x.conversations.detail(a)}),t.invalidateQueries({queryKey:x.conversations.all})}})}const mt=3e4,Ne="agent-tower:conversation-read-times";function ft(){try{const t=window.localStorage.getItem(Ne);if(!t)return{};const n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).map(([a,m])=>[a,typeof m=="number"?m:Number(m)]).filter(a=>Number.isFinite(a[1])))}catch{return{}}}function pe(t){try{window.localStorage.setItem(Ne,JSON.stringify(t))}catch{}}function ge(t){const n=t.lastActiveAt??t.updatedAt??t.createdAt;if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}function xt(t=mt){const[,n]=r.useState(0);r.useEffect(()=>{const a=setInterval(()=>n(m=>m+1),t);return()=>clearInterval(a)},[t])}function ie(t){return t===w.RUNNING||t===w.PENDING}function je(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const a=Math.max(0,Math.floor((Date.now()-n.getTime())/1e3));return a<60?oe("{count}s ago",{count:a}):a<3600?oe("{count}m ago",{count:Math.floor(a/60)}):a<86400?oe("{count}h ago",{count:Math.floor(a/3600)}):oe("{count}d ago",{count:Math.floor(a/86400)})}function ht(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 be({className:t,pulseClassName:n}){return e.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[e.jsx("span",{className:k("absolute inline-flex h-full w-full animate-ping rounded-full",n)}),e.jsx("span",{className:k("relative inline-flex h-2 w-2 rounded-full",t)})]})}function pt({status:t,unread:n}){return ie(t)?e.jsx(be,{className:"bg-success",pulseClassName:"bg-success/70"}):n?e.jsx(be,{className:"bg-warning",pulseClassName:"bg-warning/70"}):null}function gt({conversation:t,selected:n,onSelect:a,onDelete:m,disabled:h,unread:f}){const{t:S}=le(),y=je(t.lastActiveAt??t.createdAt),N=ie(t.status)||f;return e.jsxs("div",{className:k("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:a,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(me,{size:14,className:"text-muted-foreground"})}),e.jsx("span",{className:k("min-w-0 flex-1 truncate",n?"font-medium text-foreground":"text-foreground/90"),children:t.title}),N?e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(pt,{status:t.status,unread:f})}):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:y})})]}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),m()},disabled:h,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:S("Delete"),children:e.jsx(tt,{size:14})})]})}function bt({isOpen:t,conversations:n,onClose:a,onSelectConversation:m}){const{t:h}=le(),[f,S]=r.useState(""),[y,N]=r.useState(0),I=r.useRef(null);r.useEffect(()=>{t&&(S(""),N(0))},[t]);const p=r.useMemo(()=>{const o=f.trim().toLowerCase();return o?n.filter(u=>u.title.toLowerCase().includes(o)).slice(0,50):n.slice(0,12)},[n,f]);r.useEffect(()=>{N(0)},[f]),r.useEffect(()=>{I.current?.children[y]?.scrollIntoView({block:"nearest"})},[y]);const g=r.useCallback(o=>{m(o),a()},[a,m]),B=r.useCallback(o=>{if(o.key==="Escape"){o.preventDefault(),a();return}if(o.key==="ArrowDown"){o.preventDefault(),N(u=>Math.min(u+1,p.length-1));return}if(o.key==="ArrowUp"){o.preventDefault(),N(u=>Math.max(u-1,0));return}if(o.key==="Enter"&&!o.nativeEvent.isComposing){o.preventDefault();const u=p[y];u&&g(u)}},[y,g,a,p]);if(!t)return null;const R=f.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:a}),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(ye,{size:15,className:"shrink-0 text-muted-foreground/70"}),e.jsx("input",{value:f,onChange:o=>S(o.target.value),onKeyDown:B,placeholder:h("Search conversations..."),"aria-label":h("Search conversations..."),autoFocus:!0,className:"flex-1 border-none bg-transparent py-3 text-sm text-foreground placeholder-muted-foreground/60 focus:outline-none"})]}),p.length>0?e.jsxs(e.Fragment,{children:[R?null:e.jsx("div",{className:"px-4 pb-1 pt-2.5 text-[11px] font-medium text-muted-foreground/70",children:h("Recent conversations")}),e.jsx("div",{ref:I,className:"max-h-[46vh] overflow-y-auto pb-1.5 pt-0.5 scrollbar-app-thin",children:p.map((o,u)=>e.jsxs("button",{type:"button",onClick:()=>g(o),onMouseEnter:()=>N(u),className:k("flex w-full items-center gap-2.5 px-4 py-2 text-left transition-colors",u===y&&"bg-accent"),children:[e.jsx(me,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground/90",title:o.title,children:o.title}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/60",children:je(o.lastActiveAt??o.createdAt)})]},o.id))})]}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:h("No matching conversations")})]})]})}function Mt(){const{t}=le();xt();const n=Ae(),{conversationId:a}=Le(),m=J(),[h,f]=r.useState(""),[S,y]=r.useState("idle"),[N,I]=r.useState(null),[p,g]=r.useState(!1),[B,R]=r.useState(!1),[o,u]=r.useState(ft),[q,A]=r.useState(()=>new Set),{data:C=[],isLoading:Y}=ot(),{data:_,isLoading:X}=it(a),{data:z=[],isLoading:$}=Ze(),Z=lt(),G=ct(),L=dt(),ee=ut(),i=_??C.find(s=>s.id===a)??null,O=r.useMemo(()=>z.filter(({availability:s})=>s.type!=="NOT_FOUND"),[z]),V=O.map(({provider:s})=>({id:s.id,name:s.name,available:!0})),F=!!a,te=F||p,D=r.useCallback(s=>{m.invalidateQueries({queryKey:x.conversations.all}),s&&m.invalidateQueries({queryKey:x.conversations.detail(s)})},[m]),de=r.useCallback(()=>{D(a)},[a,D]),j=r.useCallback(s=>{if(A(d=>{if(!d.has(s.id))return d;const b=new Set(d);return b.delete(s.id),b}),s.status!==w.COMPLETED)return;const l=Math.max(Date.now(),ge(s));u(d=>{if(d[s.id]&&d[s.id]>=l)return d;const b={...d,[s.id]:l};return pe(b),b})},[]),H=r.useCallback(s=>{A(l=>{if(l.has(s))return l;const d=new Set(l);return d.add(s),d})},[]),ue=r.useCallback(s=>{A(l=>{if(!l.has(s))return l;const d=new Set(l);return d.delete(s),d}),u(l=>{if(!(s in l))return l;const d={...l};return delete d[s],pe(d),d})},[]),se=r.useMemo(()=>{const s=new Map;for(const l of C)s.set(l.sessionId,l);return i&&s.set(i.sessionId,i),s},[i,C]),E=r.useCallback(s=>s.status!==w.COMPLETED?!1:q.has(s.id)?!0:ge(s)>(o[s.id]??0),[o,q]);r.useEffect(()=>{!h&&O.length>0&&f(O[0].provider.id)},[O,h]),r.useEffect(()=>{i?.providerId&&f(i.providerId)},[i?.providerId]),r.useEffect(()=>{a&&g(!1)},[a]),r.useEffect(()=>{i&&j(i)},[i,j]),r.useEffect(()=>{const s=Te.connect(),l=d=>{const b=se.get(d.sessionId);if(b){if(D(b.id),d.status!==w.COMPLETED){j(b);return}if(b.id===a){j(b);return}H(b.id)}};return s.on(he.SESSION_COMPLETED,l),()=>{s.off(he.SESSION_COMPLETED,l)}},[a,se,D,j,H]);const ne=()=>{I(null),g(!0),n("/conversations")},re=()=>{g(!1),n("/conversations")},W=r.useCallback(s=>{j(s),g(!1),n(`/conversations/${s.id}`)},[j,n]),ae=async s=>{if(!(!s.providerId||!s.title.trim()||S!=="idle")){y("starting-session"),I(null);try{const l=await Z.mutateAsync({prompt:s.title.trim(),providerId:s.providerId,attachmentIds:s.attachmentIds});f(s.providerId),g(!1),n(`/conversations/${l.id}`)}catch(l){I(l instanceof Error?l.message:t("Failed to start. Please try again."))}finally{y("idle")}}},T=async s=>{!i||!s.message.trim()||G.isPending||await G.mutateAsync({id:i.id,message:s.message,providerId:s.providerId||h||void 0,attachmentIds:s.attachmentIds})},P=async()=>{!i||!ie(i.status)||L.isPending||await L.mutateAsync(i.id)},K=async s=>{window.confirm(t("Delete this conversation?"))&&(await ee.mutateAsync(s),ue(s),a===s&&(g(!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:"flex h-12 shrink-0 items-center justify-between bg-sidebar px-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(We,{}),e.jsx(Je,{}),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:()=>Me.getState().openSettings(),className:"rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground",title:t("Settings"),children:e.jsx(Pe,{size:16})})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("aside",{className:k("h-full w-full shrink-0 flex-col bg-sidebar md:flex md:w-[320px]",te?"hidden md:flex":"flex"),children:[e.jsxs("div",{className:"shrink-0 px-2 pb-1 pt-2",children:[e.jsxs("button",{type:"button",onClick:ne,className:k("flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm transition-colors",p?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"),title:t("New Conversation"),children:[e.jsx(Ye,{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(nt,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Tasks")})]}),e.jsxs("button",{type:"button",onClick:()=>R(!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(ye,{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:Y?e.jsx("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:t("Loading...")}):C.length===0?e.jsxs("div",{className:"flex h-full select-none flex-col items-center justify-center px-6 text-center",children:[e.jsx(me,{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:ne,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:C.length})]}),e.jsx("div",{className:"mt-0.5 flex min-h-[40px] flex-col rounded-md",children:C.map(s=>e.jsx(gt,{conversation:s,selected:s.id===a,disabled:ee.isPending,unread:s.id!==a&&E(s),onSelect:()=>W(s),onDelete:()=>K(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")," · ",C.length]})})]}),e.jsxs("main",{className:k("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",te?"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:[F||p?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:re,title:t("Back"),children:e.jsx(et,{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:[ht(i.status,t),i.directoryName?` · ${i.directoryName}`:""]}):null]})]})}),!i&&F?e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-4 text-sm text-muted-foreground",children:t(X?"Loading...":"Conversation not found")}):i?e.jsx(at,{sessionId:i.sessionId,sessionStatus:i.status,agentType:i.agentType,providerId:h||i.providerId,providers:z,initialTokenUsage:i.tokenUsage,onProviderChange:f,onSend:T,onStop:P,onExit:de,isSending:G.isPending,isStopping:L.isPending,canStop:ie(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(Xe,{variant:"conversation",projects:[],providers:V,isProvidersLoading:$,defaultProviderId:h,createStep:S,placeholder:"Ask a question...",submitLabel:"Start",pendingLabel:"Starting...",submitTitle:"Start",onSubmit:async({title:s,providerId:l,attachmentIds:d})=>{await ae({title:s,providerId:l,attachmentIds:d})}}),N?e.jsx("div",{className:"mt-3 rounded-lg border border-destructive/15 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:N}):null]})})]})]}),e.jsx(bt,{isOpen:B,conversations:C,onClose:()=>R(!1),onSelectConversation:W})]})}export{Mt as ConversationPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{h as P,j as e,u as oe,r,$ as ke,X as Me,i as $e,m as Be,s as Ue,v as We,M as we,g as j,a0 as qe,a1 as Ke}from"./index-OY1TIdAK.js";import{W as F}from"./mermaid-NOHMQCX5-CeIvIbfU.js";import{A as Q}from"./AgentLogo-DQId6FqS.js";import{C as ee}from"./chevron-down-DuZqUX3d.js";import{C as G}from"./check-C7Na6M49.js";import{L as te}from"./loader-circle-DDrZegLO.js";import{M as Te}from"./MemberAvatar-Bvlu6rk3.js";import{u as He}from"./use-providers-CWfLQ--R.js";import{P as Ye}from"./trash-2-z7TLHqpU.js";import{P as Ge}from"./useNormalizedLogs-DW37m6Ji.js";import{F as Ve}from"./folder-B35uD7uF.js";const Xe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Bt=P("arrow-down",Xe);const Ze=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Je=P("arrow-up",Ze);const Qe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],et=P("file-text",Qe);const tt=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],st=P("gauge",tt);const rt=[["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"}]],nt=P("git-branch",rt);const at=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ot=P("image",at);const it=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ut=P("search",it);const lt=[["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"}]],ct=P("shield",lt);const dt=[["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"}]],Wt=P("square-pen",dt);const ut=[["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"}]],mt=P("zap",ut);function ft({content:s,children:o,className:i="",side:c="top"}){const g=c==="bottom"?"top-full mt-2":"bottom-full mb-2",v=c==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative ${i}`,children:[o,e.jsxs("div",{className:`absolute ${g} left-1/2 -translate-x-1/2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[100] shadow-lg`,children:[s,e.jsx("div",{className:`absolute ${v} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ae(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function xt(s){return s>=.9?"text-red-500":s>=.7?"text-amber-500":"text-neutral-400"}function qt({usage:s,tooltipSide:o="top"}){const{t:i}=oe();if(!s)return null;const c=s.modelContextWindow,g=c?s.totalTokens/c:0,v=c?Math.min(Math.round(g*100),100):null,f=c?xt(g):"text-neutral-400",k=c?e.jsx("span",{children:i("上下文: {used} / {max} tokens",{used:ae(s.totalTokens),max:ae(c)})}):e.jsx("span",{children:i("已使用: {used} tokens",{used:ae(s.totalTokens)})});return e.jsx(ft,{content:k,side:o,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(st,{size:14,className:f}),e.jsxs("span",{className:`tabular-nums ${f}`,children:[ae(s.totalTokens),v!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",v,"%"]})]})]})})}const pt={damping:.7,stiffness:.05,mass:1.25},gt=70,ht=1e3/60,bt=350;let ie=!1;globalThis.document?.addEventListener("mousedown",()=>{ie=!0});globalThis.document?.addEventListener("mouseup",()=>{ie=!1});globalThis.document?.addEventListener("click",()=>{ie=!1});const Kt=(s={})=>{const[o,i]=r.useState(!1),[c,g]=r.useState(s.initial!==!1),[v,f]=r.useState(!1),k=r.useRef(null);k.current=s;const x=r.useCallback(()=>{if(!ie)return!1;const l=window.getSelection();if(!l||!l.rangeCount)return!1;const p=l.getRangeAt(0);return p.commonAncestorContainer.contains(m.current)||m.current?.contains(p.commonAncestorContainer)},[]),b=r.useCallback(l=>{t.isAtBottom=l,g(l)},[]),h=r.useCallback(l=>{t.escapedFromLock=l,i(l)},[]),t=r.useMemo(()=>{let l;return{escapedFromLock:o,isAtBottom:c,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return m.current?.scrollTop??0},set scrollTop(p){m.current&&(m.current.scrollTop=p,t.ignoreScrollToTop=m.current.scrollTop)},get targetScrollTop(){return!m.current||!L.current?0:m.current.scrollHeight-1-m.current.clientHeight},get calculatedTargetScrollTop(){if(!m.current||!L.current)return 0;const{targetScrollTop:p}=this;if(!s.targetScrollTop)return p;if(l?.targetScrollTop===p)return l.calculatedScrollTop;const d=Math.max(Math.min(s.targetScrollTop(p,{scrollElement:m.current,contentElement:L.current}),p),0);return l={targetScrollTop:p,calculatedScrollTop:d},requestAnimationFrame(()=>{l=void 0}),d},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=gt}}},[]),N=r.useCallback((l={})=>{typeof l=="string"&&(l={animation:l}),l.preserveScrollPosition||b(!0);const p=Date.now()+(Number(l.wait)||0),d=fe(k.current,l.animation),{ignoreEscapes:M=!1}=l;let w,E=t.calculatedTargetScrollTop;l.duration instanceof Promise?l.duration.finally(()=>{w=Date.now()}):w=p+(l.duration??0);const _=async()=>{const $=new Promise(requestAnimationFrame).then(()=>{if(!t.isAtBottom)return t.animation=void 0,!1;const{scrollTop:O}=t,q=performance.now(),U=(q-(t.lastTick??q))/ht;if(t.animation||(t.animation={behavior:d,promise:$,ignoreEscapes:M}),t.animation.behavior===d&&(t.lastTick=q),x()||p>Date.now())return _();if(O<Math.min(E,t.calculatedTargetScrollTop)){if(t.animation?.behavior===d){if(d==="instant")return t.scrollTop=t.calculatedTargetScrollTop,_();t.velocity=(d.damping*t.velocity+d.stiffness*t.scrollDifference)/d.mass,t.accumulated+=t.velocity*U,t.scrollTop+=t.accumulated,t.scrollTop!==O&&(t.accumulated=0)}return _()}return w>Date.now()?(E=t.calculatedTargetScrollTop,_()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?N({animation:fe(k.current,k.current.resize),ignoreEscapes:M,duration:Math.max(0,w-Date.now())||void 0}):t.isAtBottom)});return $.then(O=>(requestAnimationFrame(()=>{t.animation||(t.lastTick=void 0,t.velocity=0)}),O))};return l.wait!==!0&&(t.animation=void 0),t.animation?.behavior===d?t.animation.promise:_()},[b,x,t]),u=r.useCallback(()=>{h(!0),b(!1)},[h,b]),C=r.useCallback(({target:l})=>{if(l!==m.current)return;const{scrollTop:p,ignoreScrollToTop:d}=t;let{lastScrollTop:M=p}=t;t.lastScrollTop=p,t.ignoreScrollToTop=void 0,d&&d>p&&(M=d),f(t.isNearBottom),setTimeout(()=>{if(t.resizeDifference||p===d)return;if(x()){h(!0),b(!1);return}const w=p>M,E=p<M;if(t.animation?.ignoreEscapes){t.scrollTop=M;return}E&&(h(!0),b(!1)),w&&h(!1),!t.escapedFromLock&&t.isNearBottom&&b(!0)},1)},[h,b,x,t]),S=r.useCallback(({target:l,deltaY:p})=>{let d=l;for(;!["scroll","auto"].includes(getComputedStyle(d).overflow);){if(!d.parentElement)return;d=d.parentElement}d===m.current&&p<0&&m.current.scrollHeight>m.current.clientHeight&&!t.animation?.ignoreEscapes&&(h(!0),b(!1))},[h,b,t]),m=Ce(l=>{m.current?.removeEventListener("scroll",C),m.current?.removeEventListener("wheel",S),l?.addEventListener("scroll",C,{passive:!0}),l?.addEventListener("wheel",S,{passive:!0})},[]),L=Ce(l=>{if(t.resizeObserver?.disconnect(),!l)return;let p;t.resizeObserver=new ResizeObserver(([d])=>{const{height:M}=d.contentRect,w=M-(p??M);if(t.resizeDifference=w,t.scrollTop>t.targetScrollTop&&(t.scrollTop=t.targetScrollTop),f(t.isNearBottom),w>=0){const E=fe(k.current,p?k.current.resize:k.current.initial);N({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:bt})}else t.isNearBottom&&(h(!1),b(!0));p=M,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===w&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(l)},[]);return{contentRef:L,scrollRef:m,scrollToBottom:N,stopScroll:u,isAtBottom:c||v,isNearBottom:v,escapedFromLock:o,state:t}};function Ce(s,o){const i=r.useCallback(c=>(i.current=c,s(c)),o);return i}const me=new Map;function fe(...s){const o={...pt};let i=!1;for(const g of s){if(g==="instant"){i=!0;continue}typeof g=="object"&&(i=!1,o.damping=g.damping??o.damping,o.stiffness=g.stiffness??o.stiffness,o.mass=g.mass??o.mass)}const c=JSON.stringify(o);return me.has(c)||me.set(c,Object.freeze(o)),i?"instant":me.get(c)}function Ht({providers:s,currentProviderId:o,agentType:i,onSelect:c}){const{t:g}=oe(),[v,f]=r.useState(!1),k=r.useRef(null),x=s.filter(h=>String(h.provider.agentType)===i),b=s.find(h=>h.provider.id===o);return r.useEffect(()=>{function h(t){k.current&&!k.current.contains(t.target)&&f(!1)}if(v)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[v]),x.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(Q,{agentType:b?.provider.agentType??i,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:b?.provider.name?ke(b.provider.name,12):i})]}):e.jsxs("div",{className:"relative",ref:k,children:[e.jsxs("button",{onClick:()=>f(!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: ${b?.provider.name??i} (click to change)`,children:[e.jsx(Q,{agentType:b?.provider.agentType??i,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:b?.provider.name?ke(b.provider.name,12):i}),e.jsx(ee,{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:g("切换渠道")}),x.map(h=>e.jsxs("button",{onClick:()=>{c(h.provider.id),f(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${h.provider.id===o?"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(Q,{agentType:h.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:h.provider.name}),h.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:g("(默认)")})]}),h.provider.id===o&&e.jsx(G,{size:14,className:"shrink-0"})]},h.provider.id))]})]})}const vt="/api";function jt(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}function Nt({files:s,onRemove:o}){return s.length===0?null:e.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:s.map(i=>e.jsx(yt,{item:i,onRemove:o},i.tempId))})}function yt({item:s,onRemove:o}){const i=s.file.type.startsWith("image/"),c=s.status==="error",g=s.status==="uploading";return e.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${c?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[i&&s.status==="done"&&s.attachment?e.jsx("img",{src:`${vt}${s.attachment.url}`,alt:s.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("span",{className:"flex-shrink-0",children:g?e.jsx(te,{size:16,className:"animate-spin text-neutral-400"}):i?e.jsx(ot,{size:16,className:"text-neutral-400"}):e.jsx(et,{size:16,className:"text-neutral-400"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:s.file.name}),c?e.jsx("div",{className:"truncate text-red-500",children:s.error}):e.jsx("div",{className:"text-neutral-400",children:jt(s.file.size)})]}),e.jsx("button",{onClick:()=>o(s.tempId),className:"absolute -top-1.5 -right-1.5 hidden group-hover:flex items-center justify-center w-5 h-5 rounded-full bg-neutral-700 text-white hover:bg-neutral-900 transition-colors",children:e.jsx(Me,{size:10})})]})}const kt="/api";async function wt(s){const o=new FormData;o.append("file",s);const i=await fetch(`${kt}/attachments/upload`,{method:"POST",body:o});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.error||`Upload failed (${i.status})`)}return i.json()}let Tt=0;function Ct(){const[s,o]=r.useState([]),i=r.useRef(s);i.current=s;const c=r.useCallback(async t=>{const N=t.map(u=>({tempId:`tmp-${++Tt}`,file:u,progress:0,status:"uploading"}));o(u=>[...u,...N]),await Promise.allSettled(N.map(async u=>{try{const C=await wt(u.file);o(S=>S.map(m=>m.tempId===u.tempId?{...m,status:"done",progress:100,attachment:C}:m))}catch(C){o(S=>S.map(m=>m.tempId===u.tempId?{...m,status:"error",error:C instanceof Error?C.message:"Upload failed"}:m))}}))},[]),g=r.useCallback(()=>i.current.filter(t=>t.status==="done"&&t.attachment).map(t=>t.attachment),[]),v=r.useCallback(t=>{o(N=>N.filter(u=>u.tempId!==t))},[]),f=r.useCallback(()=>{o([])},[]),k=r.useCallback(t=>{t.length!==0&&o(N=>{const u=new Set(N.map(S=>S.attachment?.id??S.tempId)),C=t.filter(S=>{const m=S.attachment?.id??S.tempId;return u.has(m)?!1:(u.add(m),!0)});return C.length>0?[...N,...C]:N})},[]),x=r.useCallback(()=>{const t=g();return t.length===0?"":t.map(N=>`${N.mimeType.startsWith("image/")?"!":""}[${N.originalName}](${N.storagePath})`).join(`
|
|
2
|
-
`)},[g]),b=s.length>0,h=s.some(t=>t.status==="uploading");return{files:s,addFiles:c,removeFile:v,clear:f,restoreFiles:k,buildMarkdownLinks:x,getDoneAttachments:g,hasFiles:b,isUploading:h}}function Yt(s){const o=r.useMemo(()=>Array.from(new Set(s.filter(Boolean))),[s]);return $e({queryKey:["attachments","metadata",o],queryFn:()=>Be.get("/attachments/metadata",{params:{ids:o.join(",")}}),enabled:o.length>0,staleTime:300*1e3})}function Gt(s,o){return r.useMemo(()=>{for(let i=s.length-1;i>=0;i--){const c=s[i];if(c.tokenUsage&&typeof c.tokenUsage.totalTokens=="number"&&c.tokenUsage.totalTokens>0)return{totalTokens:c.tokenUsage.totalTokens,modelContextWindow:c.tokenUsage.modelContextWindow}}return o??null},[s,o])}function Se(s,o,i,c){if(i.filter(f=>f===c).length<=1)return s;const v=i.slice(0,o+1).filter(f=>f===c).length;return`${s} #${v}`}function St(s){return Object.values(s).filter(Boolean).length}function Mt({mode:s,setMode:o,selectedTemplateId:i,setSelectedTemplateId:c,selectedMemberPresetIds:g,setSelectedMemberPresetIds:v,disabled:f=!1,compact:k=!1}){const{t:x}=oe(),[b,h]=r.useState(!1),{data:t}=He(),{data:N,isError:u,isFetching:C,isLoading:S,refetch:m}=Ue(),{data:L,isError:l,isFetching:p,isLoading:d,refetch:M}=We(),w=r.useMemo(()=>new Map((t??[]).map(({provider:a,availability:y})=>[a.id,a.name+(y.type==="NOT_FOUND"?x(" (不可用)"):"")])),[t,x]),E=r.useMemo(()=>new Map((N??[]).map(a=>[a.id,a])),[N]),_=r.useMemo(()=>new Map((L??[]).map(a=>[a.id,a])),[L]),$=r.useMemo(()=>g.map(a=>E.get(a)).filter(a=>!!a),[E,g]);r.useEffect(()=>{N!==void 0&&v(a=>{const y=a.filter(z=>E.has(z));return y.length===a.length&&y.every((z,D)=>z===a[D])?a:y})},[N,E,v]),r.useEffect(()=>{L!==void 0&&c(a=>!a||_.has(a)?a:null)},[c,_,L]);const O=a=>{f||c(y=>y===a?null:a)},q=a=>{f||v(y=>[...y,a])},U=a=>{f||v(y=>y.filter((z,D)=>D!==a))},se=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:x("团队模板")}),l?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{M()},disabled:f||p,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):d?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(te,{size:12,className:"animate-spin"}),x("加载中...")]}):(L??[]).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:[x("当前没有团队模板"),e.jsx(we,{to:"/settings/team",className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:j("space-y-1.5",k&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(L??[]).map(a=>{const y=a.id===i,z=a.members?.length??0,D=a.members?.map(B=>B.memberPresetId)??[],W=a.members?.slice(0,3).map((B,X)=>Se(B.memberPreset?.name??B.memberPresetId,X,D,B.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>O(a.id),disabled:f,className:j("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",y?"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:j("text-xs truncate",y?"font-medium text-foreground":"text-foreground"),children:a.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[z,x("人")]})]}),W&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:W})]}),y&&e.jsx(G,{size:13,className:"shrink-0 text-foreground"})]})},a.id)})})]}),re=$.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.map((a,y)=>{const z=Se(a.name,y,g,a.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(Te,{name:a.name,avatar:a.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:z}),e.jsx("button",{type:"button",onClick:()=>U(y),disabled:f,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Me,{size:9})})]},`${a.id}-${y}`)})}),V=u?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{m()},disabled:f||C,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):S?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(te,{size:12,className:"animate-spin"}),x("加载中...")]}):(N??[]).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:[x("当前没有成员预设"),e.jsx(we,{to:"/settings/team",className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(N??[]).map(a=>{const y=g.filter(W=>W===a.id).length,z=w.get(a.providerId)??a.providerId,D=St(a.capabilities);return e.jsxs("button",{type:"button",onClick:()=>q(a.id),disabled:f,className:j("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",f&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(Te,{name:a.name,avatar:a.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:a.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[z," · ",D,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[y>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",y]}),e.jsx(Ye,{size:12,className:"text-muted-foreground"})]})]},a.id)})}),K=$.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:$.length}),H=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:x("执行模式")}),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:()=>!f&&o("AUTO"),disabled:f,className:j("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",s==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(mt,{size:11}),x("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!f&&o("CONFIRM"),disabled:f,className:j("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",s==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ct,{size:11}),x("确认模式")]})]})]});return k?e.jsxs("div",{className:"space-y-3",children:[H,se,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&h(a=>!a),disabled:f,"aria-expanded":b,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(ee,{size:12,className:j("transition-transform",b?"":"-rotate-90")}),x("追加独立成员"),K]}),b&&e.jsxs("div",{className:"mt-2",children:[re,V]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[H,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[se,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:x("追加成员")}),K]}),re,V]})]})]})}function Vt({className:s="h-7 w-7"}){return e.jsx("img",{src:qe,alt:"Agent Tower",className:`block shrink-0 object-contain ${s}`})}function Xt({className:s=""}){return e.jsx("span",{className:`font-semibold text-foreground tracking-tight text-base ${s}`,children:"Agent Tower"})}const Et={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Zt({variant:s="task",projects:o,providers:i,isProvidersLoading:c,onSubmit:g,defaultProjectId:v="",defaultProviderId:f="",onProjectChange:k,createStep:x,placeholder:b,submitLabel:h,pendingLabel:t,submitTitle:N}){const{t:u}=oe(),[C,S]=r.useState(""),[m,L]=r.useState(v),[l,p]=r.useState(f),[d,M]=r.useState("SOLO"),[w,E]=r.useState(F.WORKTREE),[_,$]=r.useState("AUTO"),[O,q]=r.useState(null),[U,se]=r.useState([]),[re,V]=r.useState(!1),[K,H]=r.useState(!1),[a,y]=r.useState(!1),[z,D]=r.useState(!1),W=r.useRef(null),B=r.useRef(null),X=r.useRef(null),Ee=r.useRef(null),xe=r.useRef(null),{files:pe,addFiles:Y,removeFile:Ae,clear:ge,buildMarkdownLinks:he,getDoneAttachments:be,isUploading:ne}=Ct(),A=s==="conversation",T=s==="task"||s==="conversation",Ie=h??u(A?"开始":"创建");r.useEffect(()=>{L(v),k?.(v)},[v,k]),r.useEffect(()=>{p(f)},[f]),r.useEffect(()=>{if(!K)return;const n=I=>{W.current&&!W.current.contains(I.target)&&H(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[K]),r.useEffect(()=>{if(!a)return;const n=I=>{B.current&&!B.current.contains(I.target)&&y(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[a]),r.useEffect(()=>{if(!z)return;const n=I=>{X.current&&!X.current.contains(I.target)&&D(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[z]);const le=r.useMemo(()=>o.find(n=>n.id===m),[o,m]),ce=r.useMemo(()=>i.find(n=>n.id===l),[i,l]),ze=w===F.MAIN_DIRECTORY?u("本地模式"):u("工作树模式"),R=x!=="idle",ve=!!O||U.length>0,Z=!R&&!ne&&C.trim().length>0&&(A?!!l:!!m&&(d==="SOLO"?!!l:ve)),de=r.useCallback(async()=>{if(!Z)return;const n=T?he():"",I=T?be().map(J=>J.id):[];try{await g({title:C.trim(),description:"",projectId:A?"":m,providerId:l,mode:A?"SOLO":d,workspaceMode:!A&&d==="SOLO"?w:F.WORKTREE,teamRunMode:A?"AUTO":_,teamTemplateId:A?null:O,memberPresetIds:A?[]:U,attachmentLinks:n,attachmentIds:I}),S(""),T&&ge()}catch{}},[Z,T,he,be,g,C,A,m,l,d,w,_,O,U,ge]),Re=r.useCallback(n=>{n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),de())},[de]),Le=r.useCallback(n=>{const I=n.target.files;I&&I.length>0&&Y(Array.from(I)),n.target.value=""},[Y]),_e=r.useCallback(n=>{L(n),k?.(n),H(!1)},[k]),De=r.useCallback(n=>{if(!T)return;const I=n.clipboardData.items,J=[];for(const Ne of I)if(Ne.kind==="file"){const ye=Ne.getAsFile();ye&&J.push(ye)}J.length>0&&(n.preventDefault(),Y(J))},[Y,T]),[je,ue]=r.useState(!1),Oe=r.useCallback(n=>{T&&(n.preventDefault(),ue(!0))},[T]),Fe=r.useCallback(n=>{T&&(n.preventDefault(),ue(!1))},[T]),Pe=r.useCallback(n=>{if(!T)return;n.preventDefault(),ue(!1);const I=n.dataTransfer.files;I.length>0&&Y(Array.from(I))},[Y,T]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:j("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",je?"border-info bg-info/5":"border-border",R&&"opacity-80"),onDragOver:T?Oe:void 0,onDragLeave:T?Fe:void 0,onDrop:T?Pe:void 0,children:[T&&pe.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(Nt,{files:pe,onRemove:Ae})}),e.jsx("textarea",{ref:Ee,value:C,onChange:n=>S(n.target.value),onKeyDown:Re,onPaste:T?De:void 0,placeholder:u(b||"Describe your task..."),disabled:R,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"}}),T&&je&&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:u("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:T?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>xe.current?.click(),disabled:R||ne,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:u("Attach files"),children:e.jsx(Ge,{size:18})}),e.jsx("input",{ref:xe,type:"file",multiple:!0,onChange:Le,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[T&&ne&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(te,{size:14,className:"animate-spin"}),u("Uploading...")]}),R&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(te,{size:14,className:"animate-spin"}),u(t??Et[x])]}),!A&&!R&&!ne&&d==="TEAM"&&!ve&&C.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:u("请选择团队模板或追加成员")}),Z&&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:"⏎"}),Ie]}),e.jsx("button",{type:"button",onClick:de,disabled:!Z,className:j("flex items-center justify-center size-8 rounded-lg transition-all duration-200",Z?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:u(N||"Create & Start"),children:e.jsx(Je,{size:16,strokeWidth:2.5})})]})]})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!A&&e.jsxs("div",{className:"relative",ref:W,children:[e.jsxs("button",{type:"button",onClick:()=>{R||H(n=>!n)},disabled:R,className:j("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",le?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Ve,{size:14,className:"shrink-0",style:{color:le?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:le?.name??u("Project")}),e.jsx(ee,{size:12,className:j("text-muted-foreground transition-transform",K&&"rotate-180")})]}),K&&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:o.map(n=>e.jsxs("button",{type:"button",onClick:()=>_e(n.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:n.color??"var(--muted-foreground)"}}),e.jsx("span",{className:j("truncate flex-1",n.id===m?"text-foreground font-medium":"text-muted-foreground"),children:n.name}),e.jsx(G,{size:14,className:j("ml-2 shrink-0 text-foreground",n.id===m?"opacity-100":"opacity-0")})]},n.id))})]}),(A||d==="SOLO")&&e.jsxs("div",{className:"relative",ref:B,children:[e.jsxs("button",{type:"button",onClick:()=>{R||y(n=>!n)},disabled:R,className:j("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",ce?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Q,{agentType:ce?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:ce?.name??u(c?"Loading...":"Agent")}),e.jsx(ee,{size:12,className:j("text-muted-foreground transition-transform",a&&"rotate-180")})]}),a&&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:i.map(n=>e.jsxs("button",{type:"button",disabled:!n.available,onClick:()=>{p(n.id),y(!1)},className:j("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!n.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(G,{size:14,className:j("mr-2 shrink-0 text-foreground",n.id===l?"opacity-100":"opacity-0")}),e.jsx(Q,{agentType:n.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:j("min-w-0 truncate",n.id===l?"text-foreground font-medium":"text-muted-foreground"),children:[n.name,n.available?"":u(" (unavailable)")]})]},n.id))})]}),!A&&d==="SOLO"&&e.jsxs("div",{className:"relative",ref:X,children:[e.jsxs("button",{type:"button",onClick:()=>{R||D(n=>!n)},disabled:R,className:j("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(nt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:ze}),e.jsx(ee,{size:12,className:j("text-muted-foreground transition-transform",z&&"rotate-180")})]}),z&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-44 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[e.jsxs("button",{type:"button",onClick:()=>{E(F.WORKTREE),D(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(G,{size:14,className:j("mr-2 shrink-0 text-foreground",w===F.WORKTREE?"opacity-100":"opacity-0")}),e.jsx("span",{className:j("truncate",w===F.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:u("工作树模式")})]}),e.jsxs("button",{type:"button",onClick:()=>{E(F.MAIN_DIRECTORY),D(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(G,{size:14,className:j("mr-2 shrink-0 text-foreground",w===F.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsx("span",{className:j("truncate",w===F.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:u("本地模式")})]})]})]}),!A&&e.jsxs("button",{type:"button",role:"switch","aria-checked":d==="TEAM",onClick:()=>{R||(d==="TEAM"?(M("SOLO"),V(!1)):(M("TEAM"),D(!1),E(F.WORKTREE),V(!0)))},disabled:R,className:j("ml-auto 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",d==="TEAM"?"text-foreground/80":"text-muted-foreground"),title:u("启用团队模式"),children:[e.jsx(Ke,{size:14,className:d==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:u("团队模式")}),e.jsx("span",{className:j("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",d==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:j("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",d==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})]}),!A&&d==="SOLO"&&w===F.MAIN_DIRECTORY&&e.jsx("div",{className:"mt-2.5",children:e.jsx("div",{className:"rounded-lg border border-warning/25 bg-warning/8 px-3 py-2 text-xs leading-relaxed text-warning/90",children:u("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),!A&&d==="TEAM"&&re&&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(Mt,{mode:_,setMode:$,selectedTemplateId:O,setSelectedTemplateId:q,selectedMemberPresetIds:U,setSelectedMemberPresetIds:se,disabled:R,compact:!0})})]})}export{Bt as A,Vt as B,Zt as C,et as F,nt as G,ot as I,Ht as P,Wt as S,qt as T,mt as Z,Gt as a,Ct as b,Nt as c,Je as d,Xt as e,Ut as f,Yt as g,Mt as h,ct as i,Kt as u};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as a,I as j,J as E,K as T,j as t,g as M,u as U,m as I,B as O}from"./index-OY1TIdAK.js";function P(s){const{sessionId:c,onOutput:k,onExit:x,onError:b}=s,[p,g]=a.useState(()=>j.isConnected()),[l,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},C=r=>{r.sessionId===c&&m.current.onOutput?.(r.data)},w=r=>{r.sessionId===c&&(d(!1),m.current.onExit?.(r.exitCode))},S=r=>{r.sessionId===c&&m.current.onError?.(r.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,C),n.on(E.SESSION_EXIT,w),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,C),n.off(E.SESSION_EXIT,w),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:l,attach:i,detach:y,sendInput:N,resize:h}}function $({className:s,...c}){return t.jsx("div",{"data-slot":"card",className:M("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",s),...c})}function z(){const{t:s}=U(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[l,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
2
|
-
[进程退出,退出码: ${e}]`,timestamp:new Date}]),d(null)},[]),w=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
3
|
-
[错误: ${e}]`,timestamp:new Date}])},[]),{isConnected:S,isAttached:r,attach:D}=P({sessionId:l||"",onOutput:v,onExit:C,onError:w});a.useEffect(()=>{I.get("/demo/agents").then(e=>{k(e.agents);const o=e.agents.find(f=>f.available);o&&b(o.type)})},[]),a.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[m]),a.useEffect(()=>{l&&S&&!r&&D()},[l,S,r,D]);const R=async()=>{if(!(!x||!p.trim())){N(!0),i([{role:"user",content:p,timestamp:new Date}]);try{const e=await I.post("/demo/start",{agentType:x,prompt:p.trim()});d(e.sessionId),g("")}catch(e){i(o=>[...o,{role:"agent",content:s("启动失败: {message}",{message:e instanceof Error?e.message:s("未知错误")}),timestamp:new Date}])}finally{N(!1)}}},A=async()=>{if(!l||!h.trim())return;const e=h.trim();i(o=>[...o,{role:"user",content:e,timestamp:new Date}]),n("");try{await I.post(`/demo/${l}/message`,{message:e})}catch(o){i(f=>[...f,{role:"agent",content:s("发送失败: {message}",{message:o instanceof Error?o.message:s("未知错误")}),timestamp:new Date}])}},_=async()=>{if(l)try{await I.post(`/demo/${l}/stop`),i(e=>[...e,{role:"agent",content:`
|
|
4
|
-
[${s("会话已停止")}]`,timestamp:new Date}]),d(null)}catch(e){console.error("Stop failed:",e)}};return t.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[t.jsx("h1",{className:"text-2xl font-bold",children:s("Agent 交互演示")}),!l&&t.jsxs($,{className:"p-4",children:[t.jsx("h2",{className:"text-lg font-semibold mb-3",children:s("选择 Agent")}),t.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:c.map(e=>t.jsxs(O,{variant:x===e.type?"default":"outline",disabled:!e.available,onClick:()=>b(e.type),children:[e.name,e.available&&e.version&&` (${e.version})`,!e.available&&s(" (不可用)")]},e.type))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&R(),placeholder:s("输入你的问题或任务..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:R,disabled:y||!x||!p.trim(),children:s(y?"启动中...":"开始")})]})]}),t.jsxs($,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex justify-between items-center mb-3",children:[t.jsx("h2",{className:"text-lg font-semibold",children:s("对话")}),l&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-500",children:s(S?r?"已连接":"连接中...":"未连接")}),t.jsx(O,{variant:"outline",size:"sm",onClick:_,children:s("停止")})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?t.jsx("div",{className:"text-gray-400 text-center py-8",children:s("选择 Agent 并输入问题开始对话")}):m.map((e,o)=>t.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[t.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?s("你"):"Agent"}),t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),t.jsx("div",{ref:u})]}),l&&t.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[t.jsx("input",{type:"text",value:h,onChange:e=>n(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&A(),placeholder:s("发送后续消息..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:A,disabled:!h.trim(),children:s("发送")})]})]})]})}export{z as DemoPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,L as c,j as e,R as g,X as f}from"./index-OY1TIdAK.js";function b(){const[i,a]=n.useState(null),u=n.useRef(null),l=n.useRef(null),d=n.useRef(null),r=i?c.find(s=>s.id===i):null,o=n.useCallback(()=>{a(null)},[]);return n.useEffect(()=>{if(!r){d.current?.focus(),d.current=null;return}l.current?.focus();const s=t=>{if(t.key==="Escape"){t.preventDefault(),o();return}t.key==="Tab"&&(t.preventDefault(),l.current?.focus())};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[r,o]),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("style",{children:g}),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:"10 个首屏加载动画候选 · 颜色遵循 Agent Tower 设计规范 · 点击卡片查看全屏效果"})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8",inert:r?!0:void 0,"aria-hidden":r?!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:c.map((s,t)=>{const x=s.component;return e.jsxs("button",{onClick:m=>{d.current=m.currentTarget,a(s.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:["#",t+1]}),e.jsx("div",{className:"flex items-center justify-center h-28 mb-4",children:e.jsx(x,{})}),e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:s.description})]},s.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:"设计推荐"}),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:"首选:Charcoal Breathe (#10)"})," — 品牌感最强,Charcoal 色块+Tower 图标呼吸,用户对产品的第一印象即品牌本身。"]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"备选A:Tower Pulse (#1)"})," — 品牌图标直接出现,脉冲节奏稳定, 不浮夸,适合工作台场景。"]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:"备选B:Terminal Cursor (#4)"})," — 终端光标闪烁,贴合 Agent/终端协作的核心场景,开发者亲切感强。"]})]})]})]}),r&&e.jsxs("div",{ref:u,className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:s=>{s.target===s.currentTarget&&o()},role:"dialog","aria-modal":"true","aria-label":`全屏预览:${r.name}`,children:[e.jsx("button",{ref:l,onClick:o,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":"关闭预览",children:e.jsx(f,{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(r.component,{})}),e.jsxs("div",{className:"text-center mt-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:r.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm",children:r.description})]}),e.jsx("span",{className:"text-xs text-muted-foreground/60 mt-2",children:"按 Esc 或点击关闭按钮退出"})]})]})]})}export{b as LoadingPreviewPage};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import{h as Ce,i as Ee,q as ke,m as Pe,u as I,r as v,j as n,g as S,S as ne,O as Oe,d as Te,B as N,n as Ie,C as Se,t as P,f as X,Y as se}from"./index-OY1TIdAK.js";import{u as _e,a as Ae,b as De,c as Le,d as Re,e as ze,f as Fe}from"./use-providers-CWfLQ--R.js";import{C as Me}from"./confirm-dialog-Cc27tq8j.js";import{I as U}from"./input-6lLP89Y3.js";import{M as J,T as Ue}from"./modal-D8uSzIAd.js";import{S as ae}from"./select-tNVeGe-v.js";import{C as Be,S as Ge}from"./switch-7jE2n-KP.js";import{T as oe}from"./textarea-DVa2Yvj4.js";import{f as z,A as w}from"./mermaid-NOHMQCX5-CeIvIbfU.js";import{A as F}from"./AgentLogo-DQId6FqS.js";import{C as ce}from"./chevron-down-DuZqUX3d.js";import{S as Ke}from"./SettingsMasterDetail-_vE8P7ke.js";import{U as Xe,C as Ve}from"./upload-DeI535ZH.js";import{P as $,T as de}from"./trash-2-z7TLHqpU.js";import{P as Ze}from"./pencil-BTaYfjKo.js";import{R as $e}from"./rotate-ccw-bVmcWqcA.js";import"./check-C7Na6M49.js";import"./chevron-right-BTjA7BSq.js";import"./arrow-left-C_pxdzZL.js";const qe=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],He=Ce("download",qe);function Je(e,t){let l=e.slice(0,t).split(/\r\n|\n|\r/g);return[l.length,l.pop().length+1]}function Ye(e,t,l){let a=e.split(/\r\n|\n|\r/g),r="",i=(Math.log10(t+1)|0)+1;for(let s=t-1;s<=t+1;s++){let o=a[s-1];o&&(r+=s.toString().padEnd(i," "),r+=": ",r+=o,r+=`
|
|
2
|
-
`,s===t&&(r+=" ".repeat(i+l+2),r+=`^
|
|
3
|
-
`))}return r}class p extends Error{line;column;codeblock;constructor(t,l){const[a,r]=Je(l.toml,l.ptr),i=Ye(l.toml,a,r);super(`Invalid TOML document: ${t}
|
|
4
|
-
|
|
5
|
-
${i}`,l),this.line=a,this.column=r,this.codeblock=i}}function We(e,t){let l=0;for(;e[t-++l]==="\\";);return--l&&l%2}function q(e,t=0,l=e.length){let a=e.indexOf(`
|
|
6
|
-
`,t);return e[a-1]==="\r"&&a--,a<=l?a:-1}function B(e,t){for(let l=t;l<e.length;l++){let a=e[l];if(a===`
|
|
7
|
-
`)return l;if(a==="\r"&&e[l+1]===`
|
|
8
|
-
`)return l+1;if(a<" "&&a!==" "||a==="")throw new p("control characters are not allowed in comments",{toml:e,ptr:t})}return e.length}function T(e,t,l,a){let r;for(;(r=e[t])===" "||r===" "||!l&&(r===`
|
|
9
|
-
`||r==="\r"&&e[t+1]===`
|
|
10
|
-
`);)t++;return a||r!=="#"?t:T(e,B(e,t),l)}function Qe(e,t,l,a,r=!1){if(!a)return t=q(e,t),t<0?e.length:t;for(let i=t;i<e.length;i++){let s=e[i];if(s==="#")i=q(e,i);else{if(s===l)return i+1;if(s===a||r&&(s===`
|
|
11
|
-
`||s==="\r"&&e[i+1]===`
|
|
12
|
-
`))return i}}throw new p("cannot find end of structure",{toml:e,ptr:t})}function ue(e,t){let l=e[t],a=l===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):l;t+=a.length-1;do t=e.indexOf(a,++t);while(t>-1&&l!=="'"&&We(e,t));return t>-1&&(t+=a.length,a.length>1&&(e[t]===l&&t++,e[t]===l&&t++)),t}let et=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class A extends Date{#t=!1;#n=!1;#e=null;constructor(t){let l=!0,a=!0,r="Z";if(typeof t=="string"){let i=t.match(et);i?(i[1]||(l=!1,t=`0000-01-01T${t}`),a=!!i[2],a&&t[10]===" "&&(t=t.replace(" ","T")),i[2]&&+i[2]>23?t="":(r=i[3]||null,t=t.toUpperCase(),!r&&a&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#t=l,this.#n=a,this.#e=r)}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let l=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return l=this.#e[0]==="-"?l:-l,new Date(this.getTime()-l*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,l="Z"){let a=new A(t);return a.#e=l,a}static wrapAsLocalDateTime(t){let l=new A(t);return l.#e=null,l}static wrapAsLocalDate(t){let l=new A(t);return l.#n=!1,l.#e=null,l}static wrapAsLocalTime(t){let l=new A(t);return l.#t=!1,l.#e=null,l}}let tt=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,nt=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,st=/^[+-]?0[0-9_]/,rt=/^[0-9a-f]{2,8}$/i,re={b:"\b",t:" ",n:`
|
|
13
|
-
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function me(e,t=0,l=e.length){let a=e[t]==="'",r=e[t++]===e[t]&&e[t]===e[t+1];r&&(l-=2,e[t+=2]==="\r"&&t++,e[t]===`
|
|
14
|
-
`&&t++);let i=0,s,o="",d=t;for(;t<l-1;){let c=e[t++];if(c===`
|
|
15
|
-
`||c==="\r"&&e[t]===`
|
|
16
|
-
`){if(!r)throw new p("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(c<" "&&c!==" "||c==="")throw new p("control characters are not allowed in strings",{toml:e,ptr:t-1});if(s){if(s=!1,c==="x"||c==="u"||c==="U"){let f=e.slice(t,t+=c==="x"?2:c==="u"?4:8);if(!rt.test(f))throw new p("invalid unicode escape",{toml:e,ptr:i});try{o+=String.fromCodePoint(parseInt(f,16))}catch{throw new p("invalid unicode escape",{toml:e,ptr:i})}}else if(r&&(c===`
|
|
17
|
-
`||c===" "||c===" "||c==="\r")){if(t=T(e,t-1,!0),e[t]!==`
|
|
18
|
-
`&&e[t]!=="\r")throw new p("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:i});t=T(e,t)}else if(c in re)o+=re[c];else throw new p("unrecognized escape sequence",{toml:e,ptr:i});d=t}else!a&&c==="\\"&&(i=t-1,s=!0,o+=e.slice(d,i))}return o+e.slice(d,l-1)}function it(e,t,l,a){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return a?0n:0;let r=tt.test(e);if(r||nt.test(e)){if(st.test(e))throw new p("leading zeroes are not allowed",{toml:t,ptr:l});e=e.replace(/_/g,"");let s=+e;if(isNaN(s))throw new p("invalid number",{toml:t,ptr:l});if(r){if((r=!Number.isSafeInteger(s))&&!a)throw new p("integer value cannot be represented losslessly",{toml:t,ptr:l});(r||a===!0)&&(s=BigInt(e))}return s}const i=new A(e);if(!i.isValid())throw new p("invalid value",{toml:t,ptr:l});return i}function lt(e,t,l){let a=e.slice(t,l),r=a.indexOf("#");return r>-1&&(B(e,r),a=a.slice(0,r)),[a.trimEnd(),r]}function Y(e,t,l,a,r){if(a===0)throw new p("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let i=e[t];if(i==="["||i==="{"){let[d,c]=i==="["?ct(e,t,a,r):ot(e,t,a,r);if(l){if(c=T(e,c),e[c]===",")c++;else if(e[c]!==l)throw new p("expected comma or end of structure",{toml:e,ptr:c})}return[d,c]}let s;if(i==='"'||i==="'"){s=ue(e,t);let d=me(e,t,s);if(l){if(s=T(e,s),e[s]&&e[s]!==","&&e[s]!==l&&e[s]!==`
|
|
19
|
-
`&&e[s]!=="\r")throw new p("unexpected character encountered",{toml:e,ptr:s});s+=+(e[s]===",")}return[d,s]}s=Qe(e,t,",",l);let o=lt(e,t,s-+(e[s-1]===","));if(!o[0])throw new p("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return l&&o[1]>-1&&(s=T(e,t+o[1]),s+=+(e[s]===",")),[it(o[0],e,t,r),s]}let at=/^[a-zA-Z0-9-_]+[ \t]*$/;function H(e,t,l="="){let a=t-1,r=[],i=e.indexOf(l,t);if(i<0)throw new p("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let s=e[t=++a];if(s!==" "&&s!==" ")if(s==='"'||s==="'"){if(s===e[t+1]&&s===e[t+2])throw new p("multiline strings are not allowed in keys",{toml:e,ptr:t});let o=ue(e,t);if(o<0)throw new p("unfinished string encountered",{toml:e,ptr:t});a=e.indexOf(".",o);let d=e.slice(o,a<0||a>i?i:a),c=q(d);if(c>-1)throw new p("newlines are not allowed in keys",{toml:e,ptr:t+a+c});if(d.trimStart())throw new p("found extra tokens after the string part",{toml:e,ptr:o});if(i<o&&(i=e.indexOf(l,o),i<0))throw new p("incomplete key-value: cannot find end of key",{toml:e,ptr:t});r.push(me(e,t,o))}else{a=e.indexOf(".",t);let o=e.slice(t,a<0||a>i?i:a);if(!at.test(o))throw new p("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});r.push(o.trimEnd())}}while(a+1&&a<i);return[r,T(e,i+1,!0,!0)]}function ot(e,t,l,a){let r={},i=new Set,s;for(t++;(s=e[t++])!=="}"&&s;){if(s===",")throw new p("expected value, found comma",{toml:e,ptr:t-1});if(s==="#")t=B(e,t);else if(s!==" "&&s!==" "&&s!==`
|
|
20
|
-
`&&s!=="\r"){let o,d=r,c=!1,[f,y]=H(e,t-1);for(let x=0;x<f.length;x++){if(x&&(d=c?d[o]:d[o]={}),o=f[x],(c=Object.hasOwn(d,o))&&(typeof d[o]!="object"||i.has(d[o])))throw new p("trying to redefine an already defined value",{toml:e,ptr:t});!c&&o==="__proto__"&&Object.defineProperty(d,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new p("trying to redefine an already defined value",{toml:e,ptr:t});let[g,m]=Y(e,y,"}",l-1,a);i.add(g),d[o]=g,t=m}}if(!s)throw new p("unfinished table encountered",{toml:e,ptr:t});return[r,t]}function ct(e,t,l,a){let r=[],i;for(t++;(i=e[t++])!=="]"&&i;){if(i===",")throw new p("expected value, found comma",{toml:e,ptr:t-1});if(i==="#")t=B(e,t);else if(i!==" "&&i!==" "&&i!==`
|
|
21
|
-
`&&i!=="\r"){let s=Y(e,t-1,"]",l-1,a);r.push(s[0]),t=s[1]}}if(!i)throw new p("unfinished array encountered",{toml:e,ptr:t});return[r,t]}function ie(e,t,l,a){let r=t,i=l,s,o=!1,d;for(let c=0;c<e.length;c++){if(c){if(r=o?r[s]:r[s]={},i=(d=i[s]).c,a===0&&(d.t===1||d.t===2))return null;if(d.t===2){let f=r.length-1;r=r[f],i=i[f].c}}if(s=e[c],(o=Object.hasOwn(r,s))&&i[s]?.t===0&&i[s]?.d)return null;o||(s==="__proto__"&&(Object.defineProperty(r,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(i,s,{enumerable:!0,configurable:!0,writable:!0})),i[s]={t:c<e.length-1&&a===2?3:a,d:!1,i:0,c:{}})}if(d=i[s],d.t!==a&&!(a===1&&d.t===3)||(a===2&&(d.d||(d.d=!0,r[s]=[]),r[s].push(r={}),d.c[d.i++]=d={t:1,d:!1,i:0,c:{}}),d.d))return null;if(d.d=!0,a===1)r=o?r[s]:r[s]={};else if(a===0&&o)return null;return[s,r,d.c]}function dt(e,{maxDepth:t=1e3,integersAsBigInt:l}={}){let a={},r={},i=a,s=r;for(let o=T(e,0);o<e.length;){if(e[o]==="["){let d=e[++o]==="[",c=H(e,o+=+d,"]");if(d){if(e[c[1]-1]!=="]")throw new p("expected end of table declaration",{toml:e,ptr:c[1]-1});c[1]++}let f=ie(c[0],a,r,d?2:1);if(!f)throw new p("trying to redefine an already defined table or value",{toml:e,ptr:o});s=f[2],i=f[1],o=c[1]}else{let d=H(e,o),c=ie(d[0],i,s,0);if(!c)throw new p("trying to redefine an already defined table or value",{toml:e,ptr:o});let f=Y(e,d[1],void 0,t,l);c[1][c[0]]=f[0],o=f[1]}if(o=T(e,o,!0),e[o]&&e[o]!==`
|
|
22
|
-
`&&e[o]!=="\r")throw new p("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:o});o=T(e,o)}return a}function ut(){return Ee({queryKey:ke.system.cursorAgentModels,queryFn:()=>Pe.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function mt({value:e,onChange:t}){const{t:l}=I(),{data:a,isLoading:r,isError:i}=ut(),s=a?.models??[],[o,d]=v.useState(!1),[c,f]=v.useState(""),y=v.useMemo(()=>{const g=c.trim().toLowerCase();return g?s.filter(m=>m.id.toLowerCase().includes(g)||m.label.toLowerCase().includes(g)):s},[s,c]);return n.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[n.jsx("input",{type:"text",value:e,onChange:g=>{const m=g.target.value;t(m===""?void 0:m)},placeholder:l("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 font-mono"}),n.jsxs("button",{type:"button",onClick:()=>d(g=>!g),disabled:r,className:"flex items-center gap-1 text-xs text-neutral-600 hover:text-neutral-900 disabled:opacity-50 w-fit",children:[n.jsx(ce,{size:14,className:S("transition-transform",o&&"rotate-180")}),r?l("正在加载 cursor-agent 模型列表…"):o?l("收起列表"):l("从本机 cursor-agent 选择({count} 个)",{count:s.length})]}),o&&!r&&n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-white shadow-sm overflow-hidden",children:[n.jsx("input",{type:"text",value:c,onChange:g=>f(g.target.value),placeholder:l("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-neutral-100 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-neutral-300"}),n.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[n.jsx("button",{type:"button",onClick:()=>{t(void 0),d(!1),f("")},className:S("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50",e?"text-neutral-700":"bg-neutral-50 font-medium"),children:l("默认 (auto)")}),y.map(g=>n.jsxs("button",{type:"button",onClick:()=>{t(g.id),d(!1),f("")},className:S("w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 border-t border-neutral-100",e===g.id?"bg-blue-50/80":""),children:[n.jsx("div",{className:"font-mono text-xs text-neutral-900 break-all",children:g.id}),n.jsx("div",{className:"text-xs text-neutral-500 mt-0.5 break-words",children:g.label})]},g.id)),y.length===0&&n.jsx("div",{className:"px-3 py-4 text-xs text-neutral-400 text-center",children:l("无匹配项")})]})]}),(i||a?.error)&&n.jsxs("p",{className:"text-xs text-amber-700",children:[l("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:a?.error??l("请求失败")}),n.jsx("code",{className:"mx-0.5 bg-neutral-100 px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),l("查看 ID。")]})]})}const M={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},W={[w.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"claude-sonnet-4-20250514"},{key:"effort",label:"推理强度",type:"select",options:[{value:"",label:"默认"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"XHigh"},{value:"max",label:"Max"}]},M],[w.GEMINI_CLI]:[{key:"yolo",label:"跳过权限确认",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"gemini-2.5-pro"},M],[w.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},{key:"model",label:"模型",type:"cursor_model"},M],[w.CODEX]:[{key:"dangerouslyBypassApprovalsAndSandbox",label:"跳过所有确认和沙盒",type:"switch"},{key:"model",label:"模型",type:"input",placeholder:"o3"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},M]};function le(){return{}}function Q(e,t){return{...t}}const xt=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),ft=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
23
|
-
# 参考: https://developers.openai.com/codex/config-sample
|
|
24
|
-
|
|
25
|
-
# ─── 模型与推理 ─────────────────────────────────────────────
|
|
26
|
-
# model_reasoning_effort = "medium" # minimal | low | medium | high | xhigh
|
|
27
|
-
# model_reasoning_summary = "auto" # auto | concise | detailed | none
|
|
28
|
-
# model_verbosity = "medium" # low | medium | high
|
|
29
|
-
# service_tier = "flex" # fast | flex
|
|
30
|
-
|
|
31
|
-
# ─── 自定义 Model Provider ──────────────────────────────────
|
|
32
|
-
# model_provider = "azure"
|
|
33
|
-
#
|
|
34
|
-
# [model_providers.azure]
|
|
35
|
-
# name = "Azure OpenAI"
|
|
36
|
-
# base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
|
|
37
|
-
# env_key = "AZURE_OPENAI_API_KEY"
|
|
38
|
-
# env_key_instructions = "Set AZURE_OPENAI_API_KEY in Provider env"
|
|
39
|
-
# wire_api = "responses"
|
|
40
|
-
# query_params = { api-version = "2025-04-01-preview" }
|
|
41
|
-
|
|
42
|
-
# ─── OpenAI 数据驻留 ────────────────────────────────────────
|
|
43
|
-
# [model_providers.openai-us]
|
|
44
|
-
# name = "OpenAI US"
|
|
45
|
-
# base_url = "https://us.api.openai.com/v1"
|
|
46
|
-
# wire_api = "responses"
|
|
47
|
-
# requires_openai_auth = true
|
|
48
|
-
|
|
49
|
-
# ─── 本地 OSS (Ollama) ──────────────────────────────────────
|
|
50
|
-
# [model_providers.ollama]
|
|
51
|
-
# name = "Ollama"
|
|
52
|
-
# base_url = "http://localhost:11434/v1"
|
|
53
|
-
# wire_api = "responses"
|
|
54
|
-
`;function V(e){return e===w.CLAUDE_CODE?xt:e===w.CODEX?ft:""}function pt(e){return e===w.CLAUDE_CODE||e===w.CODEX}const gt=Object.values(W).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),ht=Object.values(W).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function bt(e,t){return typeof t=="boolean"?t?se("是"):se("否"):typeof t=="string"&&t?ht[e]?.[t]??t:String(t)}function _(e,t){return e instanceof Error?e.message:t}function vt(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function jt(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),a=URL.createObjectURL(l),r=document.createElement("a");r.href=a,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)}function yt(e){switch(e){case"CREATE":return{label:"新增",className:"bg-success/10 text-success"};case"OVERWRITE":return{label:"覆盖",className:"bg-warning/10 text-warning"};case"SKIP":return{label:"跳过",className:"bg-muted text-muted-foreground"}}}function wt({type:e}){const t=e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND";return n.jsx("span",{className:S("inline-block h-2 w-2 rounded-full shrink-0",t?"bg-success":"bg-border"),title:t?"Available":"Unavailable",children:n.jsx("span",{className:"sr-only",children:t?"Available":"Unavailable"})})}function Nt({type:e}){const{t}=I();return e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND"?n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success",children:[n.jsx(Be,{size:11,"aria-hidden":"true"}),t("可用")]}):n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground",children:[n.jsx(Ve,{size:11,"aria-hidden":"true"}),t("不可用")]})}function Z({title:e,defaultOpen:t=!1,children:l}){const[a,r]=v.useState(t);return n.jsxs("div",{className:"rounded-lg border border-border",children:[n.jsxs("button",{type:"button",onClick:()=>r(i=>!i),"aria-expanded":a,className:"w-full flex items-center justify-between rounded-lg px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset",children:[e,n.jsx(ce,{size:14,"aria-hidden":"true",className:S("text-muted-foreground transition-transform motion-reduce:transition-none",a&&"rotate-180")})]}),a&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function Ct({agentType:e,config:t,onChange:l}){const{t:a}=I(),r=W[e]??[];if(r.length===0)return n.jsx("p",{className:"text-xs text-muted-foreground",children:a("该类型暂无运行配置")});const i=(s,o)=>{l({...t,[s]:o})};return n.jsx("div",{className:"space-y-3",children:r.map(s=>s.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"mb-1 block text-sm text-foreground",children:a(s.label)}),n.jsx(oe,{value:t[s.key]??"",onChange:o=>i(s.key,o.target.value||void 0),placeholder:s.placeholder?a(s.placeholder):void 0,rows:s.rows??3,className:"py-1.5"})]},s.key):s.type==="cursor_model"?n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[n.jsx("label",{className:"w-32 shrink-0 text-sm text-foreground sm:pt-2",children:a(s.label)}),n.jsx(mt,{value:t[s.key]??"",onChange:o=>i(s.key,o)})]},s.key):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"w-32 shrink-0 text-sm text-foreground",children:a(s.label)}),s.type==="switch"&&n.jsx(Ge,{checked:!!t[s.key],onCheckedChange:o=>i(s.key,o),"aria-label":a(s.label)}),s.type==="input"&&n.jsx(U,{value:t[s.key]??"",onChange:o=>i(s.key,o.target.value||void 0),placeholder:s.placeholder?a(s.placeholder):void 0,className:"flex-1 py-1.5"}),s.type==="select"&&s.options&&n.jsx(ae,{value:t[s.key]??"",onChange:o=>i(s.key,o||void 0),options:s.options,placeholder:a("选择...")})]},s.key))})}function Et({isOpen:e,onClose:t,initialData:l,onSave:a}){const{t:r}=I(),[i,s]=v.useState(l??{name:"",agentType:w.CLAUDE_CODE,config:le(),settings:"",env:[],isDefault:!1}),[o,d]=v.useState("");v.useEffect(()=>{if(!l&&!i.settings){const m=V(i.agentType);m&&s(x=>({...x,settings:m}))}},[]);const c=m=>{s(x=>({...x,agentType:m,config:le(),settings:V(m)}))},f=()=>{d("");const m=Q(i.agentType,i.config),x={};for(const[O,k]of Object.entries(m))k!==void 0&&k!==""&&(x[O]=k);const j=i.settings.trim();if(j){if(i.agentType===w.CODEX)try{dt(j)}catch(O){d(r("TOML 语法错误: {message}",{message:O instanceof Error?O.message:String(O)}));return}else if(i.agentType===w.CLAUDE_CODE)try{JSON.parse(j)}catch{d(r("JSON 语法错误"));return}}const b={};for(const{key:O,value:k}of i.env){const D=O.trim();D&&(b[D]=k)}const E=!!l,G={name:i.name,agentType:i.agentType,config:x,settings:E?j||"":j||void 0,env:E||Object.keys(b).length>0?b:void 0,isDefault:i.isDefault};a(G)};if(!e)return null;const y=pt(i.agentType),g=i.agentType===w.CODEX;return n.jsx(J,{isOpen:e,onClose:t,title:r(l?"编辑 Provider":"新建 Provider"),className:"max-w-2xl",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("label",{htmlFor:"provider-name",className:"mb-1 block text-xs font-medium text-foreground",children:r("名称")}),n.jsx(U,{id:"provider-name",value:i.name,onChange:m=>s(x=>({...x,name:m.target.value})),placeholder:r("例如: Claude Code (官方)")})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:r("Agent 类型")}),n.jsx(ae,{value:i.agentType,onChange:m=>c(m),options:Object.values(w).map(m=>({value:m,label:z(m),icon:n.jsx(F,{agentType:m,className:"size-4"})})),placeholder:r("选择 Agent 类型")})]}),l&&n.jsxs("div",{children:[n.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:r("Agent 类型")}),n.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-neutral-200 bg-muted/30 px-3 text-sm text-muted-foreground",children:[n.jsx(F,{agentType:i.agentType,className:"size-4"}),n.jsx("span",{className:"min-w-0 truncate",children:z(i.agentType)})]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:i.isDefault,onChange:m=>s(x=>({...x,isDefault:m.target.checked})),className:"h-4 w-4 rounded border-border accent-primary"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-foreground",children:r("设为该类型的默认 Provider")})]}),n.jsx(Z,{title:r("运行配置"),defaultOpen:!0,children:n.jsx(Ct,{agentType:i.agentType,config:i.config,onChange:m=>s(x=>({...x,config:m}))})}),n.jsxs(Z,{title:r("环境变量"),defaultOpen:i.env.length>0,children:[n.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:[r("注入到 Agent 进程的环境变量。Codex 的")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"env_key"})," ",r("指定的是变量名,实际值需在此处设置。")]}),n.jsxs("div",{className:"space-y-2",children:[i.env.map((m,x)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx(U,{value:m.key,onChange:j=>{const b=[...i.env];b[x]={...b[x],key:j.target.value},s(E=>({...E,env:b}))},placeholder:r("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 py-1.5 font-mono"}),n.jsx(U,{value:m.value,onChange:j=>{const b=[...i.env];b[x]={...b[x],value:j.target.value},s(E=>({...E,env:b}))},placeholder:r("值"),className:"flex-1 py-1.5 font-mono"}),n.jsx("button",{type:"button",onClick:()=>{const j=i.env.filter((b,E)=>E!==x);s(b=>({...b,env:j}))},"aria-label":r("删除"),className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:n.jsx(de,{size:14})})]},x)),n.jsxs(N,{variant:"outline",size:"sm",onClick:()=>s(m=>({...m,env:[...m.env,{key:"",value:""}]})),children:[n.jsx($,{size:12,className:"mr-1"}),r("添加变量")]})]})]}),y&&n.jsxs(Z,{title:r(g?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)"),children:[n.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:g?n.jsxs(n.Fragment,{children:[r("直接填写 Codex")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"config.toml"})," ",r("格式的配置片段,通过")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"-c"})," ",r("参数注入。不会修改你的")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"~/.codex/config.toml"})," ",r("文件。")]}):n.jsxs(n.Fragment,{children:[r("对应 Claude Code 的")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"~/.claude/settings.json"}),",",r("通过")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"--settings"})," ",r("参数注入。在")," ",n.jsx("code",{className:"rounded bg-muted px-1",children:"env"})," ",r("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),n.jsx(oe,{value:i.settings,onChange:m=>{s(x=>({...x,settings:m.target.value})),d("")},rows:10,className:"font-mono",placeholder:V(i.agentType),"aria-invalid":!!o}),o&&n.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:o})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(N,{variant:"outline",onClick:t,children:r("取消")}),n.jsx(N,{onClick:f,disabled:!i.name.trim(),children:r("保存")})]})]})})}function kt({isOpen:e,onClose:t,onConfirm:l,acknowledged:a,onAcknowledgedChange:r,isLoading:i}){const{t:s}=I();return n.jsx(J,{isOpen:e,onClose:t,title:s("导出 Provider 备份"),className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(N,{variant:"outline",onClick:t,disabled:i,children:s("取消")}),n.jsx(N,{onClick:l,disabled:!a||i,children:s(i?"导出中...":"导出备份")})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-warning/30 bg-warning/10 px-4 py-3 text-sm text-foreground",children:[n.jsx(Ue,{size:15,className:"mt-0.5 shrink-0 text-warning","aria-hidden":"true"}),n.jsx("span",{children:s("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")})]}),n.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[n.jsx("p",{children:s("这个功能用于备份和迁移,不用于分享配置。")}),n.jsx("p",{children:s("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),n.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border px-4 py-3 text-sm text-foreground",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:o=>r(o.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),n.jsx("span",{children:s("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function Pt({isOpen:e,onClose:t,preview:l,backup:a,onConfirm:r,isLoading:i}){const{t:s}=I();if(!l||!a)return null;const o=l.summary.create+l.summary.overwrite,d=[...l.items].sort((c,f)=>{const y={CREATE:0,OVERWRITE:1,SKIP:2};return y[c.action]-y[f.action]});return n.jsx(J,{isOpen:e,onClose:t,title:s("导入 Provider 备份"),className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(N,{variant:"outline",onClick:t,disabled:i,children:s("取消")}),n.jsx(N,{onClick:r,disabled:o===0||i,children:i?s("导入中..."):s("确认导入 {count} 项",{count:o})})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3 text-sm text-muted-foreground",children:[n.jsx("div",{children:s("导出时间:{value}",{value:new Date(a.exportedAt).toLocaleString()})}),n.jsx("div",{children:s("模式:完整备份(含敏感信息)")}),n.jsx("div",{children:s("文件内 Provider 数量:{count}",{count:a.providers.length})})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsxs("div",{className:"rounded-lg border border-success/25 bg-success/10 px-4 py-3",children:[n.jsx("div",{className:"text-xs font-medium text-success",children:s("新增")}),n.jsx("div",{className:"text-lg font-semibold text-foreground",children:l.summary.create})]}),n.jsxs("div",{className:"rounded-lg border border-warning/25 bg-warning/10 px-4 py-3",children:[n.jsx("div",{className:"text-xs font-medium text-warning",children:s("覆盖")}),n.jsx("div",{className:"text-lg font-semibold text-foreground",children:l.summary.overwrite})]}),n.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s("跳过")}),n.jsx("div",{className:"text-lg font-semibold text-foreground",children:l.summary.skip})]})]}),n.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:d.map(c=>{const f=yt(c.action);return n.jsxs("div",{className:"rounded-lg border border-border px-4 py-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"truncate text-sm font-medium text-foreground",children:c.incoming.name}),n.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-[11px] font-medium ${f.className}`,children:s(f.label)})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx(F,{agentType:c.incoming.agentType,className:"size-3.5"}),n.jsx("span",{className:"min-w-0 truncate",children:z(c.incoming.agentType)})," · ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:c.incoming.id})]})]})}),c.action==="OVERWRITE"&&c.existing&&n.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("将覆盖当前已有的 Provider:{name}",{name:c.existing.name})}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前同 ID Provider 配置一致,本次不会重复写入。")}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前不存在同 ID Provider,将直接新增。")})]},c.incoming.id)})})]})})}function Ot({item:e,onEdit:t,onDelete:l}){const{t:a}=I(),r=e.provider,i=e.availability,s=Q(r.agentType,r.config),o=Object.entries(s).filter(([c])=>c!=="cmd"),d=Object.keys(r.env||{});return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx("h3",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:r.name}),n.jsx(Nt,{type:i.type})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[n.jsx(F,{agentType:r.agentType,className:"size-3.5"}),n.jsx("span",{className:"truncate",children:z(r.agentType)})]}),r.isDefault&&n.jsx("span",{className:"rounded-full bg-primary/[0.06] px-2 py-0.5 text-[11px] font-medium text-primary",children:a("默认")}),r.builtIn&&n.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground",children:a("内置")})]})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsxs(N,{size:"sm",variant:"outline",onClick:t,children:[n.jsx(Ze,{size:13}),a("编辑")]}),n.jsxs(N,{size:"sm",variant:r.builtIn?"outline":"destructive",onClick:l,disabled:r.deletable===!1,children:[r.builtIn?n.jsx($e,{size:13}):n.jsx(de,{size:13}),r.builtIn?a("恢复默认"):a("删除")]})]})]}),o.length>0&&n.jsxs("div",{children:[n.jsx(X,{className:"mb-3",children:a("运行配置")}),n.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:o.map(([c,f])=>n.jsxs("div",{className:"flex items-center gap-4 bg-background px-4 py-2.5",children:[n.jsx("span",{className:"w-32 shrink-0 text-[13px] text-muted-foreground",children:a(gt[c]??c)}),n.jsx("span",{className:"font-mono text-[13px] text-foreground",children:bt(c,f)})]},c))})]}),d.length>0&&n.jsxs("div",{children:[n.jsx(X,{className:"mb-3",children:a("环境变量")}),n.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:d.map(c=>n.jsxs("div",{className:"flex items-center gap-4 bg-background px-4 py-2.5",children:[n.jsx("span",{className:"font-mono text-[13px] text-foreground",children:c}),n.jsx("span",{className:"text-[13px] text-muted-foreground","aria-label":"hidden",children:"•••••"})]},c))})]}),r.settings?.trim()&&n.jsxs("div",{children:[n.jsx(X,{className:"mb-3",children:a("CLI 配置")}),n.jsx("div",{className:"rounded-lg border border-border bg-muted/40 p-4",children:n.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:r.settings})})]}),o.length===0&&d.length===0&&!r.settings?.trim()&&n.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:a('该 Provider 未配置额外参数。点击"编辑"添加运行配置、环境变量或 CLI 配置。')})]})}function qt(){const{t:e}=I(),{data:t,isLoading:l}=_e(),a=Ae(),r=De(),i=Le(),s=Re(),o=ze(),d=Fe(),c=v.useRef(null),[f,y]=v.useState(null),[g,m]=v.useState(null),[x,j]=v.useState(null),[b,E]=v.useState(!1),[G,O]=v.useState(!1),[k,D]=v.useState(null),[xe,K]=v.useState(!1),L=t??[];v.useEffect(()=>{!f&&L.length>0&&y(L[0].provider.id)},[L,f]);const fe=u=>{a.mutate(u,{onSuccess:()=>m(null),onError:h=>P.error(_(h,e("创建 Provider 失败")))})},pe=(u,h)=>{r.mutate({id:u,data:h},{onSuccess:()=>m(null),onError:C=>P.error(_(C,e("更新 Provider 失败")))})},ge=u=>{if(!(u.deletable??!u.builtIn)){P.error(e("系统内置 Provider 不可删除"));return}j({id:u.id,name:u.name,builtIn:u.builtIn})},he=()=>{x&&i.mutate(x.id,{onSuccess:()=>{P.success(x.builtIn?e("已恢复默认 Provider 配置"):e("Provider 已删除")),f===x.id&&y(null),j(null),K(!1)},onError:u=>P.error(_(u,e("删除 Provider 失败")))})},ee=()=>{E(!1),O(!1)},te=()=>D(null),be=()=>{s.mutate(void 0,{onSuccess:u=>{jt(vt(u.exportedAt),u),P.success(e("Provider 备份已导出")),ee()},onError:u=>P.error(_(u,e("导出 Provider 备份失败")))})},ve=()=>{c.current&&(c.current.value="",c.current.click())},je=async u=>{const h=u.target.files?.[0];if(u.target.value="",!h)return;let C;try{C=JSON.parse(await h.text())}catch{P.error(e("备份文件不是有效的 JSON"));return}o.mutate(C,{onSuccess:R=>D({backup:C,preview:R}),onError:R=>P.error(_(R,e("导入预览失败")))})},ye=()=>{k&&d.mutate(k.backup,{onSuccess:u=>{const h=u.summary.create+u.summary.overwrite;P.success(h===0?e("导入完成,当前配置无需变更"):e("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:u.summary.create,overwrite:u.summary.overwrite,skip:u.summary.skip})),te()},onError:u=>P.error(_(u,e("导入 Provider 备份失败")))})},we=u=>{const h=u.provider,C=h.env?Object.entries(h.env).map(([R,Ne])=>({key:R,value:Ne})):[];m({id:h.id,data:{name:h.name,agentType:h.agentType,config:Q(h.agentType,h.config),settings:h.settings??"",env:C,isDefault:h.isDefault}})};return l?n.jsx(ne,{className:"max-w-5xl",children:n.jsx(Oe,{})}):n.jsxs(ne,{className:"max-w-5xl",children:[n.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:je}),n.jsx(Te,{title:e("Agent 配置"),actions:n.jsxs(n.Fragment,{children:[n.jsxs(N,{variant:"outline",size:"sm",onClick:ve,disabled:o.isPending||d.isPending,children:[n.jsx(Xe,{size:13}),e("导入")]}),n.jsxs(N,{variant:"outline",size:"sm",onClick:()=>E(!0),disabled:s.isPending,children:[n.jsx(He,{size:13}),e("导出")]}),n.jsxs(N,{size:"sm",onClick:()=>m({}),children:[n.jsx($,{size:13,className:"mr-1"}),e("新建")]})]})}),L.length===0?n.jsx(Ie,{icon:Se,message:e("暂无 Agent 配置"),action:n.jsxs(N,{size:"sm",onClick:()=>m({}),children:[n.jsx($,{size:13,className:"mr-1"}),e("新建配置")]})}):n.jsx(Ke,{items:L,selectedId:f,onSelectItem:u=>{y(u),K(!0)},getItemId:u=>u.provider.id,mobileShowDetail:xe,onMobileBack:()=>K(!1),renderListItem:(u,h)=>{const C=u.provider;return n.jsxs(n.Fragment,{children:[n.jsx(wt,{type:u.availability.type}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate text-[13px] font-medium",children:C.name}),n.jsxs("div",{className:S("flex min-w-0 items-center gap-1.5 text-[11px]",h?"text-primary-foreground/60":"text-muted-foreground"),children:[n.jsx(F,{agentType:C.agentType,className:"size-3.5",fallbackClassName:h?"text-primary-foreground/70":"text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate",children:z(C.agentType)})]})]}),C.isDefault&&n.jsx("span",{className:S("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",h?"bg-white/20 text-primary-foreground":"bg-primary/[0.06] text-primary"),children:e("默认")})]})},renderDetail:u=>u?n.jsx("div",{className:"p-5",children:n.jsx(Ot,{item:u,onEdit:()=>we(u),onDelete:()=>ge(u.provider)})}):n.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:e("选择一个 Provider 查看详情")})}),g&&n.jsx(Et,{isOpen:!0,onClose:()=>m(null),initialData:g.data,onSave:u=>{g.id?pe(g.id,u):fe(u)}}),n.jsx(Me,{isOpen:x!==null,onClose:()=>{i.isPending||j(null)},onConfirm:he,title:x?.builtIn?e("恢复默认 Provider"):e("删除 Provider"),description:x?.builtIn?e('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:x?.name}):e('确定删除 "{name}"?此操作不可撤销。',{name:x?.name}),confirmText:x?.builtIn?e("恢复默认"):e("删除"),cancelText:e("取消"),variant:"danger",isLoading:i.isPending}),n.jsx(kt,{isOpen:b,onClose:ee,onConfirm:be,acknowledged:G,onAcknowledgedChange:O,isLoading:s.isPending}),n.jsx(Pt,{isOpen:!!k,onClose:te,preview:k?.preview??null,backup:k?.backup??null,onConfirm:ye,isLoading:d.isPending})]})}export{qt as ProviderSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{V as a,W as n}from"./index-BwKL3rKp.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as c}from"./index-OY1TIdAK.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-Bb_qV3PR.js";import{_ as i}from"./index-BwKL3rKp.js";import"./chunk-FMBD7UC4-CbBz10YF.js";import"./chunk-ND2GUHAM-B930BNNl.js";import"./chunk-55IACEB6-Bi5q9Evi.js";import"./chunk-2J33WTMH-BVhYZ0vK.js";import"./index-OY1TIdAK.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-Bb_qV3PR.js";import{_ as i}from"./index-BwKL3rKp.js";import"./chunk-FMBD7UC4-CbBz10YF.js";import"./chunk-ND2GUHAM-B930BNNl.js";import"./chunk-55IACEB6-Bi5q9Evi.js";import"./chunk-2J33WTMH-BVhYZ0vK.js";import"./index-OY1TIdAK.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|