agent-tower 0.5.3-beta.5 → 0.5.3-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +13 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/cli.js +26 -3
  5. package/dist/cli.js.map +1 -1
  6. package/dist/executors/__tests__/base.executor.test.js +83 -8
  7. package/dist/executors/__tests__/base.executor.test.js.map +1 -1
  8. package/dist/executors/__tests__/claude-code.executor.test.d.ts +2 -0
  9. package/dist/executors/__tests__/claude-code.executor.test.d.ts.map +1 -0
  10. package/dist/executors/__tests__/claude-code.executor.test.js +72 -0
  11. package/dist/executors/__tests__/claude-code.executor.test.js.map +1 -0
  12. package/dist/executors/__tests__/providers-availability.test.d.ts +2 -0
  13. package/dist/executors/__tests__/providers-availability.test.d.ts.map +1 -0
  14. package/dist/executors/__tests__/providers-availability.test.js +92 -0
  15. package/dist/executors/__tests__/providers-availability.test.js.map +1 -0
  16. package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts +2 -0
  17. package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts.map +1 -0
  18. package/dist/executors/__tests__/stdin-prompt.executors.test.js +177 -0
  19. package/dist/executors/__tests__/stdin-prompt.executors.test.js.map +1 -0
  20. package/dist/executors/base.executor.d.ts.map +1 -1
  21. package/dist/executors/base.executor.js +131 -33
  22. package/dist/executors/base.executor.js.map +1 -1
  23. package/dist/executors/claude-code.executor.d.ts.map +1 -1
  24. package/dist/executors/claude-code.executor.js +22 -52
  25. package/dist/executors/claude-code.executor.js.map +1 -1
  26. package/dist/executors/codex.executor.js +4 -4
  27. package/dist/executors/codex.executor.js.map +1 -1
  28. package/dist/executors/cursor-agent.executor.d.ts.map +1 -1
  29. package/dist/executors/cursor-agent.executor.js +4 -6
  30. package/dist/executors/cursor-agent.executor.js.map +1 -1
  31. package/dist/executors/gemini-cli.executor.d.ts.map +1 -1
  32. package/dist/executors/gemini-cli.executor.js +9 -8
  33. package/dist/executors/gemini-cli.executor.js.map +1 -1
  34. package/dist/executors/image-utils.d.ts.map +1 -1
  35. package/dist/executors/image-utils.js +4 -22
  36. package/dist/executors/image-utils.js.map +1 -1
  37. package/dist/index.js +37 -2
  38. package/dist/index.js.map +1 -1
  39. package/dist/pipeline/agent-pipeline.d.ts.map +1 -1
  40. package/dist/pipeline/agent-pipeline.js +27 -2
  41. package/dist/pipeline/agent-pipeline.js.map +1 -1
  42. package/dist/routes/__tests__/filesystem.test.js +5 -2
  43. package/dist/routes/__tests__/filesystem.test.js.map +1 -1
  44. package/dist/routes/__tests__/git.test.d.ts +2 -0
  45. package/dist/routes/__tests__/git.test.d.ts.map +1 -0
  46. package/dist/routes/__tests__/git.test.js +47 -0
  47. package/dist/routes/__tests__/git.test.js.map +1 -0
  48. package/dist/routes/__tests__/workspaces.test.d.ts +2 -0
  49. package/dist/routes/__tests__/workspaces.test.d.ts.map +1 -0
  50. package/dist/routes/__tests__/workspaces.test.js +85 -0
  51. package/dist/routes/__tests__/workspaces.test.js.map +1 -0
  52. package/dist/routes/filesystem.d.ts.map +1 -1
  53. package/dist/routes/filesystem.js +4 -3
  54. package/dist/routes/filesystem.js.map +1 -1
  55. package/dist/routes/git.d.ts.map +1 -1
  56. package/dist/routes/git.js +32 -0
  57. package/dist/routes/git.js.map +1 -1
  58. package/dist/services/__tests__/conversation.service.test.js +63 -0
  59. package/dist/services/__tests__/conversation.service.test.js.map +1 -1
  60. package/dist/services/__tests__/project.service.test.js +56 -0
  61. package/dist/services/__tests__/project.service.test.js.map +1 -1
  62. package/dist/services/__tests__/task.service.test.js +49 -0
  63. package/dist/services/__tests__/task.service.test.js.map +1 -1
  64. package/dist/services/__tests__/team-reconciler.service.test.js +15 -9
  65. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  66. package/dist/services/__tests__/team-run.service.test.js +27 -3
  67. package/dist/services/__tests__/team-run.service.test.js.map +1 -1
  68. package/dist/services/__tests__/workspace.service.test.js +49 -1
  69. package/dist/services/__tests__/workspace.service.test.js.map +1 -1
  70. package/dist/services/conversation.service.d.ts.map +1 -1
  71. package/dist/services/conversation.service.js +17 -1
  72. package/dist/services/conversation.service.js.map +1 -1
  73. package/dist/services/project-guards.d.ts +4 -0
  74. package/dist/services/project-guards.d.ts.map +1 -1
  75. package/dist/services/project-guards.js +10 -0
  76. package/dist/services/project-guards.js.map +1 -1
  77. package/dist/services/project.service.d.ts +6 -1
  78. package/dist/services/project.service.d.ts.map +1 -1
  79. package/dist/services/project.service.js +31 -29
  80. package/dist/services/project.service.js.map +1 -1
  81. package/dist/services/session-manager.d.ts +9 -8
  82. package/dist/services/session-manager.d.ts.map +1 -1
  83. package/dist/services/session-manager.js +129 -16
  84. package/dist/services/session-manager.js.map +1 -1
  85. package/dist/services/task.service.d.ts +154 -5
  86. package/dist/services/task.service.d.ts.map +1 -1
  87. package/dist/services/task.service.js +54 -9
  88. package/dist/services/task.service.js.map +1 -1
  89. package/dist/services/team-run.service.d.ts.map +1 -1
  90. package/dist/services/team-run.service.js +11 -2
  91. package/dist/services/team-run.service.js.map +1 -1
  92. package/dist/services/terminal-manager.d.ts.map +1 -1
  93. package/dist/services/terminal-manager.js +39 -7
  94. package/dist/services/terminal-manager.js.map +1 -1
  95. package/dist/services/workspace.service.d.ts +7 -7
  96. package/dist/services/workspace.service.d.ts.map +1 -1
  97. package/dist/services/workspace.service.js +9 -1
  98. package/dist/services/workspace.service.js.map +1 -1
  99. package/dist/utils/error-log.d.ts +20 -0
  100. package/dist/utils/error-log.d.ts.map +1 -0
  101. package/dist/utils/error-log.js +176 -0
  102. package/dist/utils/error-log.js.map +1 -0
  103. package/dist/utils/error-log.test.d.ts +2 -0
  104. package/dist/utils/error-log.test.d.ts.map +1 -0
  105. package/dist/utils/error-log.test.js +233 -0
  106. package/dist/utils/error-log.test.js.map +1 -0
  107. package/dist/utils/prisma-cli-env.d.ts +3 -0
  108. package/dist/utils/prisma-cli-env.d.ts.map +1 -0
  109. package/dist/utils/prisma-cli-env.js +15 -0
  110. package/dist/utils/prisma-cli-env.js.map +1 -0
  111. package/dist/utils/prisma-cli-env.test.d.ts +2 -0
  112. package/dist/utils/prisma-cli-env.test.d.ts.map +1 -0
  113. package/dist/utils/prisma-cli-env.test.js +34 -0
  114. package/dist/utils/prisma-cli-env.test.js.map +1 -0
  115. package/dist/utils/process-launch.d.ts +4 -0
  116. package/dist/utils/process-launch.d.ts.map +1 -1
  117. package/dist/utils/process-launch.js +99 -15
  118. package/dist/utils/process-launch.js.map +1 -1
  119. package/dist/utils/process-launch.test.js +120 -3
  120. package/dist/utils/process-launch.test.js.map +1 -1
  121. package/dist/web/assets/{AgentDemoPage-DC61uZJ_.js → AgentDemoPage-C3_t3lf0.js} +1 -1
  122. package/dist/web/assets/{AgentLogo-CGrwilQJ.js → AgentLogo-BiGSdOLM.js} +1 -1
  123. package/dist/web/assets/ConversationPage-D3BaVRNK.js +3 -0
  124. package/dist/web/assets/CreateTaskInput-C6ZA8Cnu.js +2 -0
  125. package/dist/web/assets/{DemoPage-BDUjXkK3.js → DemoPage-BGdrlCk3.js} +1 -1
  126. package/dist/web/assets/{GeneralSettingsPage-DuYC1Vhv.js → GeneralSettingsPage-DRP9x8ha.js} +1 -1
  127. package/dist/web/assets/{Icons-BqZeUyTx.js → Icons-U8HyAFg8.js} +1 -1
  128. package/dist/web/assets/{LoadingPreviewPage-DPA8HxNr.js → LoadingPreviewPage-BR3n6lWz.js} +1 -1
  129. package/dist/web/assets/{McpSettingsPage-BO_Fd_mA.js → McpSettingsPage-BQ4HNeR-.js} +1 -1
  130. package/dist/web/assets/{MemberAvatar-BesdHRgJ.js → MemberAvatar-BjHhs0Hs.js} +1 -1
  131. package/dist/web/assets/{NotificationSettingsPage-F5HPtn9-.js → NotificationSettingsPage-nAYf_v-C.js} +1 -1
  132. package/dist/web/assets/{ProfileSettingsPage-DweTPF_t.js → ProfileSettingsPage-CvVvZlDS.js} +1 -1
  133. package/dist/web/assets/{ProjectKanbanPage-G5OQeJvU.css → ProjectKanbanPage-DcpNTP1B.css} +1 -1
  134. package/dist/web/assets/ProjectKanbanPage-DpWuiq4x.js +89 -0
  135. package/dist/web/assets/ProjectSettingsPage-B1V5vUQk.js +2 -0
  136. package/dist/web/assets/{ProviderSettingsPage-Cio0LIzm.js → ProviderSettingsPage-CXq-sGzZ.js} +1 -1
  137. package/dist/web/assets/{SettingsMasterDetail-BnqVBe7H.js → SettingsMasterDetail-BOKbstXF.js} +1 -1
  138. package/dist/web/assets/TeamSettingsPage-DFx7ZKTf.js +1 -0
  139. package/dist/web/assets/{arc-CYddG-Kz.js → arc-D4qG1SmX.js} +1 -1
  140. package/dist/web/assets/{architectureDiagram-3BPJPVTR-B3RXX4-J.js → architectureDiagram-3BPJPVTR-C1KQ-nPu.js} +1 -1
  141. package/dist/web/assets/{arrow-left-CufhOEz9.js → arrow-left-DKU68PPE.js} +1 -1
  142. package/dist/web/assets/{blockDiagram-GPEHLZMM-a7Dr_zcs.js → blockDiagram-GPEHLZMM-CHBz_0R-.js} +1 -1
  143. package/dist/web/assets/{c4Diagram-AAUBKEIU-BLwSao_g.js → c4Diagram-AAUBKEIU-spmGspVf.js} +1 -1
  144. package/dist/web/assets/channel-BzXNFc3j.js +1 -0
  145. package/dist/web/assets/check-ugjfD3Li.js +1 -0
  146. package/dist/web/assets/{chevron-down-BQyZkT4A.js → chevron-down-Bqq-PI_B.js} +1 -1
  147. package/dist/web/assets/{chevron-right-94xg9kiO.js → chevron-right-K0xCrJxO.js} +1 -1
  148. package/dist/web/assets/{chevron-up-BZM-aGAU.js → chevron-up-Rnt9gnA4.js} +1 -1
  149. package/dist/web/assets/{chunk-2J33WTMH-CV8jFvSt.js → chunk-2J33WTMH-BoBYuHA8.js} +1 -1
  150. package/dist/web/assets/{chunk-4BX2VUAB-DXquqZ4n.js → chunk-4BX2VUAB-Bmb_y0KF.js} +1 -1
  151. package/dist/web/assets/{chunk-55IACEB6-BowEEH_6.js → chunk-55IACEB6-B_KS5xlb.js} +1 -1
  152. package/dist/web/assets/{chunk-727SXJPM-Cbn9G9U_.js → chunk-727SXJPM-DI9KppWM.js} +1 -1
  153. package/dist/web/assets/{chunk-AQP2D5EJ-C-0K23VQ.js → chunk-AQP2D5EJ-C3F0DJdJ.js} +1 -1
  154. package/dist/web/assets/{chunk-FMBD7UC4-BJv0I_Lt.js → chunk-FMBD7UC4-C6-Jfc2f.js} +1 -1
  155. package/dist/web/assets/{chunk-ND2GUHAM-DJBjsrJO.js → chunk-ND2GUHAM-Crt5iCMS.js} +1 -1
  156. package/dist/web/assets/{chunk-QZHKN3VN-CBw_GG0t.js → chunk-QZHKN3VN-CSYfO5_E.js} +1 -1
  157. package/dist/web/assets/{circle-alert-lbce0dXY.js → circle-alert-BA6H1Efg.js} +1 -1
  158. package/dist/web/assets/classDiagram-4FO5ZUOK-DWVhCasm.js +1 -0
  159. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DWVhCasm.js +1 -0
  160. package/dist/web/assets/{code-block-OCS4YCEC-CRG-xCnX.js → code-block-OCS4YCEC-BNCfYHwe.js} +1 -1
  161. package/dist/web/assets/{confirm-dialog-Cnw_rxtM.js → confirm-dialog-xFGalfma.js} +1 -1
  162. package/dist/web/assets/{cose-bilkent-S5V4N54A-DCNqQrFt.js → cose-bilkent-S5V4N54A-CsfM-xa6.js} +1 -1
  163. package/dist/web/assets/{dagre-BM42HDAG-oecZRFap.js → dagre-BM42HDAG-a0_McFXq.js} +1 -1
  164. package/dist/web/assets/{diagram-2AECGRRQ-BXx6WNMi.js → diagram-2AECGRRQ-Dc-ZrrCl.js} +1 -1
  165. package/dist/web/assets/{diagram-5GNKFQAL-Bu66xpEW.js → diagram-5GNKFQAL-CVTae_wQ.js} +1 -1
  166. package/dist/web/assets/{diagram-KO2AKTUF-ZGMyoO90.js → diagram-KO2AKTUF-DkfB2YqP.js} +1 -1
  167. package/dist/web/assets/{diagram-LMA3HP47-riQUwPgu.js → diagram-LMA3HP47-k45WlYTa.js} +1 -1
  168. package/dist/web/assets/{diagram-OG6HWLK6-H_PHYJoy.js → diagram-OG6HWLK6-D6oP9231.js} +1 -1
  169. package/dist/web/assets/{erDiagram-TEJ5UH35-ePGpWuWD.js → erDiagram-TEJ5UH35-DCsStITe.js} +1 -1
  170. package/dist/web/assets/{flowDiagram-I6XJVG4X-BZUDzSVZ.js → flowDiagram-I6XJVG4X-BpnMpo54.js} +1 -1
  171. package/dist/web/assets/{folder-Ca5RFac7.js → folder-aqzIYw0B.js} +1 -1
  172. package/dist/web/assets/folder-picker-CFznZBP-.js +1 -0
  173. package/dist/web/assets/{ganttDiagram-6RSMTGT7-D2UOmWEL.js → ganttDiagram-6RSMTGT7-CzoF4UuV.js} +1 -1
  174. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DEzWWRW3.js → gitGraphDiagram-PVQCEYII-AlRFGn3n.js} +1 -1
  175. package/dist/web/assets/index-BMsh00ht.js +120 -0
  176. package/dist/web/assets/{index-JK3A62-g.js → index-BvCxcy2E.js} +4 -4
  177. package/dist/web/assets/index-CMlcurFO.css +1 -0
  178. package/dist/web/assets/{infoDiagram-5YYISTIA-BNClnI_5.js → infoDiagram-5YYISTIA-DYmUMa5y.js} +1 -1
  179. package/dist/web/assets/{input-7UYarzFy.js → input-BOQDrqKN.js} +1 -1
  180. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-B1aSs8GW.js → ishikawaDiagram-YF4QCWOH-BbR4k44d.js} +1 -1
  181. package/dist/web/assets/{journeyDiagram-JHISSGLW-DlXxUTcw.js → journeyDiagram-JHISSGLW-B3BgsbGr.js} +1 -1
  182. package/dist/web/assets/{kanban-definition-UN3LZRKU-Ctkuw8kN.js → kanban-definition-UN3LZRKU-CAw6dg5S.js} +1 -1
  183. package/dist/web/assets/{layers-C89p38EX.js → layers-CHCOcaOD.js} +1 -1
  184. package/dist/web/assets/{linear--QsFiowO.js → linear-DuhwDM_T.js} +1 -1
  185. package/dist/web/assets/{loader-circle-DolxjVmY.js → loader-circle-ZTtR7VFf.js} +1 -1
  186. package/dist/web/assets/{mermaid-NOHMQCX5-CW_FGpKP.js → mermaid-NOHMQCX5-BfcG134x.js} +3 -3
  187. package/dist/web/assets/{message-square-KV4Azzxs.js → message-square-8nr39Elw.js} +1 -1
  188. package/dist/web/assets/{mindmap-definition-RKZ34NQL-Dm6rZMiM.js → mindmap-definition-RKZ34NQL-Dn4_OJVF.js} +1 -1
  189. package/dist/web/assets/{modal-PZSR91HW.js → modal-Ct5Hq4HV.js} +1 -1
  190. package/dist/web/assets/{pencil-9lMJOuw2.js → pencil-CHhoqtja.js} +1 -1
  191. package/dist/web/assets/{pieDiagram-4H26LBE5-DbQPjRBP.js → pieDiagram-4H26LBE5-BazLj2iZ.js} +1 -1
  192. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DeRrMc4Y.js → quadrantDiagram-W4KKPZXB-By8b3yLK.js} +1 -1
  193. package/dist/web/assets/{requirementDiagram-4Y6WPE33-aajAoXSH.js → requirementDiagram-4Y6WPE33-Y8tQe-HW.js} +1 -1
  194. package/dist/web/assets/{rotate-ccw-D7tnDKF_.js → rotate-ccw-DacB7Wa2.js} +1 -1
  195. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-DWsta0ns.js → sankeyDiagram-5OEKKPKP-CsWPn5i_.js} +1 -1
  196. package/dist/web/assets/select-BAGWw5mB.js +1 -0
  197. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BGBP9NTB.js → sequenceDiagram-3UESZ5HK-CRYTLL5B.js} +1 -1
  198. package/dist/web/assets/{stateDiagram-AJRCARHV-Dl0Q7uMb.js → stateDiagram-AJRCARHV-CRAWuvD-.js} +1 -1
  199. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DLPzRpsU.js +1 -0
  200. package/dist/web/assets/{switch-BhqMnTiu.js → switch-DEDPfm5p.js} +1 -1
  201. package/dist/web/assets/{terminal-BR0PXV2W.js → terminal-D9ZyN65O.js} +1 -1
  202. package/dist/web/assets/{textarea-eWIZ3eZW.js → textarea-Bwf5qeVw.js} +1 -1
  203. package/dist/web/assets/{timeline-definition-PNZ67QCA-DuDIvs1s.js → timeline-definition-PNZ67QCA-CNyG_LiR.js} +1 -1
  204. package/dist/web/assets/{trash-2-C7F85sIB.js → trash-2-CAJaQyy-.js} +1 -1
  205. package/dist/web/assets/{upload-CQTsuurY.js → upload-CvRhSiH5.js} +1 -1
  206. package/dist/web/assets/{use-profiles-Btexu_oH.js → use-profiles-CXwrOP0r.js} +1 -1
  207. package/dist/web/assets/{use-providers-BEPU5ALg.js → use-providers-cM1M1P2G.js} +1 -1
  208. package/dist/web/assets/{useNormalizedLogs-CvCCSYxy.js → useNormalizedLogs-Bpa12fkI.js} +1 -1
  209. package/dist/web/assets/{vennDiagram-CIIHVFJN-BDyKeyr8.js → vennDiagram-CIIHVFJN-Ccs0W2eH.js} +1 -1
  210. package/dist/web/assets/{wardley-L42UT6IY-DAOA5Zsv.js → wardley-L42UT6IY-DZ98ClK4.js} +1 -1
  211. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CCmLvkBT.js → wardleyDiagram-YWT4CUSO-CFZaMuWx.js} +1 -1
  212. package/dist/web/assets/{xychartDiagram-2RQKCTM6-EsyeKzfj.js → xychartDiagram-2RQKCTM6-DupmVBai.js} +1 -1
  213. package/dist/web/index.html +2 -2
  214. package/node_modules/@agent-tower/shared/dist/types.d.ts +4 -0
  215. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  216. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  217. package/package.json +1 -1
  218. package/dist/web/assets/ConversationPage-DvD_lYUj.js +0 -3
  219. package/dist/web/assets/CreateTaskInput-CstzayW9.js +0 -2
  220. package/dist/web/assets/ProjectKanbanPage-taUI2xm6.js +0 -89
  221. package/dist/web/assets/ProjectSettingsPage-BfTQwRb7.js +0 -2
  222. package/dist/web/assets/TeamSettingsPage-CHoLj7rL.js +0 -1
  223. package/dist/web/assets/channel-BTbcDemz.js +0 -1
  224. package/dist/web/assets/check-C5Ba8Rby.js +0 -1
  225. package/dist/web/assets/classDiagram-4FO5ZUOK-D4Noh8IG.js +0 -1
  226. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-D4Noh8IG.js +0 -1
  227. package/dist/web/assets/folder-picker-CZIjxGNQ.js +0 -1
  228. package/dist/web/assets/index-17XUvLGe.css +0 -1
  229. package/dist/web/assets/index-M-QRACZK.js +0 -120
  230. package/dist/web/assets/select-CTiftuHJ.js +0 -1
  231. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BEhmiwth.js +0 -1
@@ -1,3 +0,0 @@
1
- import{h as Ee,u as le,r,j as e,g as b,i as ve,k as Z,l as ce,q as h,m as _,V as Ae,M as Te,W as Le,I as Pe,J as he,O as Me,Y as Re,Z as oe}from"./index-M-QRACZK.js";import{b as qe,S as w}from"./mermaid-NOHMQCX5-CW_FGpKP.js";import{u as Oe,a as ze,T as Fe,P as Ke,S as Qe}from"./useNormalizedLogs-CvCCSYxy.js";import{u as Ue,a as Be,b as _e,A as $e,c as Ge,P as Ve,T as He,d as We,B as Je,e as Ye,S as Ze,f as ye,C as Xe}from"./CreateTaskInput-CstzayW9.js";import{u as et}from"./use-providers-BEPU5ALg.js";import{M as fe}from"./message-square-KV4Azzxs.js";import{A as tt}from"./arrow-left-CufhOEz9.js";import{T as st}from"./trash-2-C7F85sIB.js";import"./chevron-right-94xg9kiO.js";import"./chevron-down-BQyZkT4A.js";import"./check-C5Ba8Rby.js";import"./AgentLogo-CGrwilQJ.js";import"./loader-circle-DolxjVmY.js";import"./MemberAvatar-BesdHRgJ.js";import"./folder-Ca5RFac7.js";const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],rt=Ee("layout-list",nt);function at(t){return t===w.RUNNING||t===w.PENDING}function ot({sessionId:t,sessionStatus:n,agentType:o,providerId:c,providers:N,initialTokenUsage:f,onProviderChange:j,onSend:v,onStop:y,onExit:D,isSending:p=!1,isStopping:C=!1,canStop:S,className:$}){const{t:a}=le(),[m,q]=r.useState(""),[O,z]=r.useState(c??""),[k,G]=r.useState(!1),[X,ee]=r.useState(null),T=r.useRef(null),te=r.useRef(null),de=r.useRef(null),L=r.useRef(!1),{scrollRef:V,contentRef:se,isAtBottom:l,scrollToBottom:A}=Ue({initial:"instant",resize:"smooth"}),{isConnected:ne,isLoadingSnapshot:H,logs:F,entries:K,attach:Q}=Oe({sessionId:t,sessionStatus:n,onExit:D}),{todos:I}=ze(K),re=Be(F,f),{files:ue,addFiles:E,removeFile:me,clear:W,buildMarkdownLinks:ae,getDoneAttachments:J,hasFiles:P,isUploading:M}=_e(),U=at(n),Y=S??U;r.useEffect(()=>{z(c??"")},[c]),r.useEffect(()=>{t&&ne&&Q()},[t,ne,Q]);const s=r.useCallback(d=>{z(d),j?.(d)},[j]),i=r.useCallback(()=>{T.current&&(T.current.style.height="60px")},[]),u=r.useCallback(d=>{q(d.target.value);const g=d.target;g.style.height="auto",g.style.height=`${Math.max(60,Math.min(g.scrollHeight,300))}px`},[]),x=r.useCallback(async()=>{if(!m.trim()&&!P||L.current||p||M)return;L.current=!0;const d=ae(),g=J().map(R=>R.id),B=[m.trim(),d].filter(Boolean).join(`
2
-
3
- `);q(""),W(),i(),ee(null);try{await v({message:B,providerId:O||void 0,attachmentIds:g}),await Q(),requestAnimationFrame(()=>A("smooth"))}catch(R){ee(R instanceof Error?R.message:a("Send failed. Please try again.")),q(B)}finally{L.current=!1}},[m,P,p,M,ae,J,W,i,v,O,Q,A,a]),we=r.useCallback(async()=>{!Y||C||await y()},[Y,C,y]),Ce=r.useCallback(d=>{const g=d.target.files;g&&g.length>0&&E(Array.from(g)),d.target.value=""},[E]),ke=r.useCallback(d=>{const g=d.clipboardData.items,B=[];for(const R of g)if(R.kind==="file"){const xe=R.getAsFile();xe&&B.push(xe)}B.length>0&&(d.preventDefault(),E(B))},[E]),Se=r.useCallback(d=>{d.preventDefault(),G(!0)},[]),Ie=r.useCallback(d=>{d.preventDefault(),G(!1)},[]),De=r.useCallback(d=>{d.preventDefault(),G(!1);const g=d.dataTransfer.files;g.length>0&&E(Array.from(g))},[E]);return e.jsxs("div",{className:b("relative flex min-h-0 flex-1 flex-col bg-background",$),children:[e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:V,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pb-4 pt-6",children:e.jsx("div",{ref:se,className:"mx-auto w-full min-w-0 max-w-4xl",children:H?e.jsxs("div",{className:"flex items-center justify-center gap-3 py-12 text-muted-foreground/70",children:[e.jsxs("svg",{className:"h-5 w-5 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:a("Loading logs...")})]}):F.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground/70",children:a(U?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(qe,{logs:F})})}),!l&&e.jsxs("button",{type:"button",onClick:()=>A(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-muted-foreground shadow-md backdrop-blur-sm transition-all hover:bg-background hover:text-foreground","aria-label":a("Scroll to bottom"),children:[e.jsx($e,{size:14}),e.jsx("span",{children:a("Back to bottom")})]})]}),I.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(Fe,{todos:I})})}),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:de,className:b("relative rounded-xl border bg-background transition-colors duration-200 hover:border-ring/40 focus-within:border-ring/60",k?"border-info bg-info/5":"border-border"),children:[e.jsx(Ge,{files:ue,onRemove:me}),e.jsx("textarea",{ref:T,value:m,onChange:u,onPaste:ke,onKeyDown:d=>{d.key==="Enter"&&!d.shiftKey&&!d.repeat&&!d.nativeEvent.isComposing&&d.nativeEvent.keyCode!==229&&(d.preventDefault(),x())},rows:1,placeholder:a(k?"Drop files here...":t&&!U?"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:te,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:()=>te.current?.click(),disabled:M,className:"rounded-lg p-2 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",title:a("Upload file"),children:e.jsx(Ke,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{providers:N,currentProviderId:O,agentType:o,onSelect:s}),e.jsx(He,{usage:re}),Y&&U&&!m.trim()&&!P?e.jsx("button",{type:"button",onClick:we,disabled:C,className:"rounded-lg bg-destructive p-2 text-white transition-all duration-200 hover:bg-destructive/90 disabled:opacity-50",title:a("Stop"),children:e.jsx(Qe,{size:14})}):e.jsx("button",{type:"button",onClick:x,disabled:!m.trim()&&!P||M||p,className:b("rounded-lg p-2 transition-all duration-200",(m.trim()||P)&&!M&&!p?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-transparent text-muted-foreground/50"),title:a("Send"),children:e.jsx(We,{size:18})})]})]})]})]})})]})}function it(t=50){return ve({queryKey:h.conversations.list({limit:t}),queryFn:()=>_.get("/conversations",{params:{limit:String(t)}})})}function lt(t){return ve({queryKey:h.conversations.detail(t??""),queryFn:()=>_.get(`/conversations/${t}`),enabled:!!t})}function ct(){const t=Z();return ce({mutationFn:n=>_.post("/conversations",n),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function dt(){const t=Z();return ce({mutationFn:({id:n,...o})=>_.post(`/conversations/${n}/message`,o),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function ut(){const t=Z();return ce({mutationFn:n=>_.post(`/conversations/${n}/stop`),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function mt(){const t=Z();return ce({mutationFn:n=>_.delete(`/conversations/${n}`),onSuccess:(n,o)=>{t.removeQueries({queryKey:h.conversations.detail(o)}),t.invalidateQueries({queryKey:h.conversations.all})}})}const ft=3e4,Ne="agent-tower:conversation-read-times";function xt(){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(([o,c])=>[o,typeof c=="number"?c:Number(c)]).filter(o=>Number.isFinite(o[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 o=new Date(n).getTime();return Number.isFinite(o)?o:0}function ht(t=ft){const[,n]=r.useState(0);r.useEffect(()=>{const o=setInterval(()=>n(c=>c+1),t);return()=>clearInterval(o)},[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 o=Math.max(0,Math.floor((Date.now()-n.getTime())/1e3));return o<60?oe("{count}s ago",{count:o}):o<3600?oe("{count}m ago",{count:Math.floor(o/60)}):o<86400?oe("{count}h ago",{count:Math.floor(o/3600)}):oe("{count}d ago",{count:Math.floor(o/86400)})}function pt(t,n){switch(t){case w.RUNNING:return n("Running");case w.PENDING:return n("Starting");case w.COMPLETED:return n("Completed");case w.FAILED:return n("Failed");case w.CANCELLED:return n("Stopped");default:return t}}function be({className:t,pulseClassName:n}){return e.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[e.jsx("span",{className:b("absolute inline-flex h-full w-full animate-ping rounded-full",n)}),e.jsx("span",{className:b("relative inline-flex h-2 w-2 rounded-full",t)})]})}function gt({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 bt({conversation:t,selected:n,onSelect:o,onDelete:c,disabled:N,unread:f}){const{t:j}=le(),v=je(t.lastActiveAt??t.createdAt),y=ie(t.status)||f;return e.jsxs("div",{className:b("group ml-4 mr-2 flex items-center rounded-md transition-colors",n?"bg-accent":"hover:bg-accent/50"),children:[e.jsxs("button",{type:"button",onClick:o,title:t.title,className:"flex min-w-0 flex-1 animate-task-enter items-center gap-2.5 rounded-md px-2 py-2 text-left text-sm",children:[e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(fe,{size:14,className:"text-muted-foreground"})}),e.jsx("span",{className:b("min-w-0 flex-1 truncate",n?"font-medium text-foreground":"text-foreground/90"),children:t.title}),y?e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(gt,{status:t.status,unread: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:v})})]}),e.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),c()},disabled:N,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:j("Delete"),children:e.jsx(st,{size:14})})]})}function vt({isOpen:t,conversations:n,onClose:o,onSelectConversation:c}){const{t:N}=le(),[f,j]=r.useState(""),[v,y]=r.useState(0),D=r.useRef(null);r.useEffect(()=>{t&&(j(""),y(0))},[t]);const p=r.useMemo(()=>{const a=f.trim().toLowerCase();return a?n.filter(m=>m.title.toLowerCase().includes(a)).slice(0,50):n.slice(0,12)},[n,f]);r.useEffect(()=>{y(0)},[f]),r.useEffect(()=>{D.current?.children[v]?.scrollIntoView({block:"nearest"})},[v]);const C=r.useCallback(a=>{c(a),o()},[o,c]),S=r.useCallback(a=>{if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="ArrowDown"){a.preventDefault(),y(m=>Math.min(m+1,p.length-1));return}if(a.key==="ArrowUp"){a.preventDefault(),y(m=>Math.max(m-1,0));return}if(a.key==="Enter"&&!a.nativeEvent.isComposing){a.preventDefault();const m=p[v];m&&C(m)}},[v,C,o,p]);if(!t)return null;const $=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:o}),e.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-border bg-popover shadow-lg animate-in fade-in zoom-in-95 duration-100",children:[e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border/60 px-4",children:[e.jsx(ye,{size:15,className:"shrink-0 text-muted-foreground/70"}),e.jsx("input",{value:f,onChange:a=>j(a.target.value),onKeyDown:S,placeholder:N("Search conversations..."),"aria-label":N("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:[$?null:e.jsx("div",{className:"px-4 pb-1 pt-2.5 text-[11px] font-medium text-muted-foreground/70",children:N("Recent conversations")}),e.jsx("div",{ref:D,className:"max-h-[46vh] overflow-y-auto pb-1.5 pt-0.5 scrollbar-app-thin",children:p.map((a,m)=>e.jsxs("button",{type:"button",onClick:()=>C(a),onMouseEnter:()=>y(m),className:b("flex w-full items-center gap-2.5 px-4 py-2 text-left transition-colors",m===v&&"bg-accent"),children:[e.jsx(fe,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground/90",title:a.title,children:a.title}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/60",children:je(a.lastActiveAt??a.createdAt)})]},a.id))})]}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:N("No matching conversations")})]})]})}function Rt(){const{t}=le();ht();const n=Ae(),{usesIntegratedTitlebar:o}=Te(),{conversationId:c}=Le(),N=Z(),[f,j]=r.useState(""),[v,y]=r.useState("idle"),[D,p]=r.useState(null),[C,S]=r.useState(!1),[$,a]=r.useState(!1),[m,q]=r.useState(xt),[O,z]=r.useState(()=>new Set),{data:k=[],isLoading:G}=it(),{data:X,isLoading:ee}=lt(c),{data:T=[],isLoading:te}=et(),de=ct(),L=dt(),V=ut(),se=mt(),l=X??k.find(s=>s.id===c)??null,A=r.useMemo(()=>T.filter(({availability:s})=>s.type!=="NOT_FOUND"),[T]),ne=A.map(({provider:s})=>({id:s.id,name:s.name,agentType:s.agentType,available:!0})),H=!!c,F=H||C,K=r.useCallback(s=>{N.invalidateQueries({queryKey:h.conversations.all}),s&&N.invalidateQueries({queryKey:h.conversations.detail(s)})},[N]),Q=r.useCallback(()=>{K(c)},[c,K]),I=r.useCallback(s=>{if(z(u=>{if(!u.has(s.id))return u;const x=new Set(u);return x.delete(s.id),x}),s.status!==w.COMPLETED)return;const i=Math.max(Date.now(),ge(s));q(u=>{if(u[s.id]&&u[s.id]>=i)return u;const x={...u,[s.id]:i};return pe(x),x})},[]),re=r.useCallback(s=>{z(i=>{if(i.has(s))return i;const u=new Set(i);return u.add(s),u})},[]),ue=r.useCallback(s=>{z(i=>{if(!i.has(s))return i;const u=new Set(i);return u.delete(s),u}),q(i=>{if(!(s in i))return i;const u={...i};return delete u[s],pe(u),u})},[]),E=r.useMemo(()=>{const s=new Map;for(const i of k)s.set(i.sessionId,i);return l&&s.set(l.sessionId,l),s},[l,k]),me=r.useCallback(s=>s.status!==w.COMPLETED?!1:O.has(s.id)?!0:ge(s)>(m[s.id]??0),[m,O]);r.useEffect(()=>{!f&&A.length>0&&j(A[0].provider.id)},[A,f]),r.useEffect(()=>{l?.providerId&&j(l.providerId)},[l?.providerId]),r.useEffect(()=>{c&&S(!1)},[c]),r.useEffect(()=>{l&&I(l)},[l,I]),r.useEffect(()=>{const s=Pe.connect(),i=u=>{const x=E.get(u.sessionId);if(x){if(K(x.id),u.status!==w.COMPLETED){I(x);return}if(x.id===c){I(x);return}re(x.id)}};return s.on(he.SESSION_COMPLETED,i),()=>{s.off(he.SESSION_COMPLETED,i)}},[c,E,K,I,re]);const W=()=>{p(null),S(!0),n("/conversations")},ae=()=>{S(!1),n("/conversations")},J=r.useCallback(s=>{I(s),S(!1),n(`/conversations/${s.id}`)},[I,n]),P=async s=>{if(!(!s.providerId||!s.title.trim()||v!=="idle")){y("starting-session"),p(null);try{const i=await de.mutateAsync({prompt:s.title.trim(),providerId:s.providerId,attachmentIds:s.attachmentIds});j(s.providerId),S(!1),n(`/conversations/${i.id}`)}catch(i){p(i instanceof Error?i.message:t("Failed to start. Please try again."))}finally{y("idle")}}},M=async s=>{!l||!s.message.trim()||L.isPending||await L.mutateAsync({id:l.id,message:s.message,providerId:s.providerId||f||void 0,attachmentIds:s.attachmentIds})},U=async()=>{!l||!ie(l.status)||V.isPending||await V.mutateAsync(l.id)},Y=async s=>{window.confirm(t("Delete this conversation?"))&&(await se.mutateAsync(s),ue(s),c===s&&(S(!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:b("flex h-12 shrink-0 items-center justify-between bg-sidebar px-4",o&&"app-region-drag"),children:[e.jsxs("div",{className:b("flex min-w-0 items-center gap-2",o&&"pl-[72px]"),children:[e.jsx(Je,{}),e.jsx(Ye,{}),e.jsx("span",{className:"mx-1.5 select-none text-muted-foreground/40",children:"/"}),e.jsx("span",{className:"truncate text-sm font-medium text-foreground/90",children:t("Conversation")})]}),e.jsx("button",{type:"button",onClick:()=>Re.getState().openSettings(),className:b("rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground",o&&"app-region-no-drag"),title:t("Settings"),children:e.jsx(Me,{size:16})})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("aside",{className:b("h-full w-full shrink-0 flex-col bg-sidebar md:flex md:w-[320px]",F?"hidden md:flex":"flex"),children:[e.jsxs("div",{className:"shrink-0 px-2 pb-1 pt-2",children:[e.jsxs("button",{type:"button",onClick:W,className:b("flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm transition-colors",C?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"),title:t("New Conversation"),children:[e.jsx(Ze,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("New Conversation")})]}),e.jsxs("button",{type:"button",onClick:()=>n("/"),className:"flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent/50",title:t("Tasks"),children:[e.jsx(rt,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Tasks")})]}),e.jsxs("button",{type:"button",onClick:()=>a(!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:G?e.jsx("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:t("Loading...")}):k.length===0?e.jsxs("div",{className:"flex h-full select-none flex-col items-center justify-center px-6 text-center",children:[e.jsx(fe,{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:W,className:"rounded-md bg-brand px-3.5 py-1.5 text-xs font-medium text-brand-foreground transition-colors hover:bg-brand/90",children:t("New Conversation")})]}):e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex w-full items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"flex-1 text-left",children:t("History")}),e.jsx("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/50",children:k.length})]}),e.jsx("div",{className:"mt-0.5 flex min-h-[40px] flex-col rounded-md",children:k.map(s=>e.jsx(bt,{conversation:s,selected:s.id===c,disabled:se.isPending,unread:s.id!==c&&me(s),onSelect:()=>J(s),onDelete:()=>Y(s.id)},s.id))})]})}),e.jsx("div",{className:"flex items-center justify-between border-t border-border/60 px-4 py-3 text-xs text-muted-foreground/70",children:e.jsxs("span",{children:[t("Conversations")," · ",k.length]})})]}),e.jsxs("main",{className:b("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",F?"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:[H||C?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:ae,title:t("Back"),children:e.jsx(tt,{size:17})}):null,e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold",children:l?.title??t("New Conversation")}),l?e.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[pt(l.status,t),l.directoryName?` · ${l.directoryName}`:""]}):null]})]})}),!l&&H?e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-4 text-sm text-muted-foreground",children:t(ee?"Loading...":"Conversation not found")}):l?e.jsx(ot,{sessionId:l.sessionId,sessionStatus:l.status,agentType:l.agentType,providerId:f||l.providerId,providers:T,initialTokenUsage:l.tokenUsage,onProviderChange:j,onSend:M,onStop:U,onExit:Q,isSending:L.isPending,isStopping:V.isPending,canStop:ie(l.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:ne,isProvidersLoading:te,defaultProviderId:f,createStep:v,placeholder:"Ask a question...",submitLabel:"Start",pendingLabel:"Starting...",submitTitle:"Start",onSubmit:async({title:s,providerId:i,attachmentIds:u})=>{await P({title:s,providerId:i,attachmentIds:u})}}),D?e.jsx("div",{className:"mt-3 rounded-lg border border-destructive/15 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:D}):null]})})]})]}),e.jsx(vt,{isOpen:$,conversations:k,onClose:()=>a(!1),onSelectConversation:J})]})}export{Rt as ConversationPage};
@@ -1,2 +0,0 @@
1
- import{h as F,j as e,u as ae,r,a0 as we,X as Ee,i as $e,m as Be,M as Ue,s as We,v as qe,N as Te,g as N,a1 as Ke,a2 as He}from"./index-M-QRACZK.js";import{W as O}from"./mermaid-NOHMQCX5-CW_FGpKP.js";import{A as Q}from"./AgentLogo-CGrwilQJ.js";import{C as ee}from"./chevron-down-BQyZkT4A.js";import{C as V}from"./check-C5Ba8Rby.js";import{L as te}from"./loader-circle-DolxjVmY.js";import{M as Ce}from"./MemberAvatar-BesdHRgJ.js";import{u as Ye}from"./use-providers-BEPU5ALg.js";import{P as Ge}from"./trash-2-C7F85sIB.js";import{P as Ve}from"./useNormalizedLogs-CvCCSYxy.js";import{F as Xe}from"./folder-Ca5RFac7.js";const Ze=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ut=F("arrow-down",Ze);const Je=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Qe=F("arrow-up",Je);const et=[["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"}]],tt=F("file-text",et);const st=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],rt=F("gauge",st);const nt=[["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"}]],at=F("git-branch",nt);const ot=[["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"}]],it=F("image",ot);const lt=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Wt=F("search",lt);const ct=[["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"}]],dt=F("shield",ct);const ut=[["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"}]],qt=F("square-pen",ut);const mt=[["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"}]],ft=F("zap",mt);function xt({content:s,children:i,className:l="",side:d="top"}){const h=d==="bottom"?"top-full mt-2":"bottom-full mb-2",b=d==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative ${l}`,children:[i,e.jsxs("div",{className:`absolute ${h} 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 ${b} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ne(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function pt(s){return s>=.9?"text-red-500":s>=.7?"text-amber-500":"text-neutral-400"}function Kt({usage:s,tooltipSide:i="top"}){const{t:l}=ae();if(!s)return null;const d=s.modelContextWindow,h=d?s.totalTokens/d:0,b=d?Math.min(Math.round(h*100),100):null,f=d?pt(h):"text-neutral-400",y=d?e.jsx("span",{children:l("上下文: {used} / {max} tokens",{used:ne(s.totalTokens),max:ne(d)})}):e.jsx("span",{children:l("已使用: {used} tokens",{used:ne(s.totalTokens)})});return e.jsx(xt,{content:y,side:i,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(rt,{size:14,className:f}),e.jsxs("span",{className:`tabular-nums ${f}`,children:[ne(s.totalTokens),b!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",b,"%"]})]})]})})}const gt={damping:.7,stiffness:.05,mass:1.25},ht=70,bt=1e3/60,vt=350;let oe=!1;globalThis.document?.addEventListener("mousedown",()=>{oe=!0});globalThis.document?.addEventListener("mouseup",()=>{oe=!1});globalThis.document?.addEventListener("click",()=>{oe=!1});const Ht=(s={})=>{const[i,l]=r.useState(!1),[d,h]=r.useState(s.initial!==!1),[b,f]=r.useState(!1),y=r.useRef(null);y.current=s;const x=r.useCallback(()=>{if(!oe)return!1;const o=window.getSelection();if(!o||!o.rangeCount)return!1;const g=o.getRangeAt(0);return g.commonAncestorContainer.contains(m.current)||m.current?.contains(g.commonAncestorContainer)},[]),v=r.useCallback(o=>{t.isAtBottom=o,h(o)},[]),p=r.useCallback(o=>{t.escapedFromLock=o,l(o)},[]),t=r.useMemo(()=>{let o;return{escapedFromLock:i,isAtBottom:d,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return m.current?.scrollTop??0},set scrollTop(g){m.current&&(m.current.scrollTop=g,t.ignoreScrollToTop=m.current.scrollTop)},get targetScrollTop(){return!m.current||!P.current?0:m.current.scrollHeight-1-m.current.clientHeight},get calculatedTargetScrollTop(){if(!m.current||!P.current)return 0;const{targetScrollTop:g}=this;if(!s.targetScrollTop)return g;if(o?.targetScrollTop===g)return o.calculatedScrollTop;const u=Math.max(Math.min(s.targetScrollTop(g,{scrollElement:m.current,contentElement:P.current}),g),0);return o={targetScrollTop:g,calculatedScrollTop:u},requestAnimationFrame(()=>{o=void 0}),u},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ht}}},[]),k=r.useCallback((o={})=>{typeof o=="string"&&(o={animation:o}),o.preserveScrollPosition||v(!0);const g=Date.now()+(Number(o.wait)||0),u=xe(y.current,o.animation),{ignoreEscapes:M=!1}=o;let w,_=t.calculatedTargetScrollTop;o.duration instanceof Promise?o.duration.finally(()=>{w=Date.now()}):w=g+(o.duration??0);const z=async()=>{const W=new Promise(requestAnimationFrame).then(()=>{if(!t.isAtBottom)return t.animation=void 0,!1;const{scrollTop:L}=t,q=performance.now(),B=(q-(t.lastTick??q))/bt;if(t.animation||(t.animation={behavior:u,promise:W,ignoreEscapes:M}),t.animation.behavior===u&&(t.lastTick=q),x()||g>Date.now())return z();if(L<Math.min(_,t.calculatedTargetScrollTop)){if(t.animation?.behavior===u){if(u==="instant")return t.scrollTop=t.calculatedTargetScrollTop,z();t.velocity=(u.damping*t.velocity+u.stiffness*t.scrollDifference)/u.mass,t.accumulated+=t.velocity*B,t.scrollTop+=t.accumulated,t.scrollTop!==L&&(t.accumulated=0)}return z()}return w>Date.now()?(_=t.calculatedTargetScrollTop,z()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?k({animation:xe(y.current,y.current.resize),ignoreEscapes:M,duration:Math.max(0,w-Date.now())||void 0}):t.isAtBottom)});return W.then(L=>(requestAnimationFrame(()=>{t.animation||(t.lastTick=void 0,t.velocity=0)}),L))};return o.wait!==!0&&(t.animation=void 0),t.animation?.behavior===u?t.animation.promise:z()},[v,x,t]),c=r.useCallback(()=>{p(!0),v(!1)},[p,v]),C=r.useCallback(({target:o})=>{if(o!==m.current)return;const{scrollTop:g,ignoreScrollToTop:u}=t;let{lastScrollTop:M=g}=t;t.lastScrollTop=g,t.ignoreScrollToTop=void 0,u&&u>g&&(M=u),f(t.isNearBottom),setTimeout(()=>{if(t.resizeDifference||g===u)return;if(x()){p(!0),v(!1);return}const w=g>M,_=g<M;if(t.animation?.ignoreEscapes){t.scrollTop=M;return}_&&(p(!0),v(!1)),w&&p(!1),!t.escapedFromLock&&t.isNearBottom&&v(!0)},1)},[p,v,x,t]),S=r.useCallback(({target:o,deltaY:g})=>{let u=o;for(;!["scroll","auto"].includes(getComputedStyle(u).overflow);){if(!u.parentElement)return;u=u.parentElement}u===m.current&&g<0&&m.current.scrollHeight>m.current.clientHeight&&!t.animation?.ignoreEscapes&&(p(!0),v(!1))},[p,v,t]),m=Se(o=>{m.current?.removeEventListener("scroll",C),m.current?.removeEventListener("wheel",S),o?.addEventListener("scroll",C,{passive:!0}),o?.addEventListener("wheel",S,{passive:!0})},[]),P=Se(o=>{if(t.resizeObserver?.disconnect(),!o)return;let g;t.resizeObserver=new ResizeObserver(([u])=>{const{height:M}=u.contentRect,w=M-(g??M);if(t.resizeDifference=w,t.scrollTop>t.targetScrollTop&&(t.scrollTop=t.targetScrollTop),f(t.isNearBottom),w>=0){const _=xe(y.current,g?y.current.resize:y.current.initial);k({animation:_,wait:!0,preserveScrollPosition:!0,duration:_==="instant"?void 0:vt})}else t.isNearBottom&&(p(!1),v(!0));g=M,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===w&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(o)},[]);return{contentRef:P,scrollRef:m,scrollToBottom:k,stopScroll:c,isAtBottom:d||b,isNearBottom:b,escapedFromLock:i,state:t}};function Se(s,i){const l=r.useCallback(d=>(l.current=d,s(d)),i);return l}const fe=new Map;function xe(...s){const i={...gt};let l=!1;for(const h of s){if(h==="instant"){l=!0;continue}typeof h=="object"&&(l=!1,i.damping=h.damping??i.damping,i.stiffness=h.stiffness??i.stiffness,i.mass=h.mass??i.mass)}const d=JSON.stringify(i);return fe.has(d)||fe.set(d,Object.freeze(i)),l?"instant":fe.get(d)}function Yt({providers:s,currentProviderId:i,agentType:l,onSelect:d}){const{t:h}=ae(),[b,f]=r.useState(!1),y=r.useRef(null),x=s.filter(p=>String(p.provider.agentType)===l),v=s.find(p=>p.provider.id===i);return r.useEffect(()=>{function p(t){y.current&&!y.current.contains(t.target)&&f(!1)}if(b)return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[b]),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:v?.provider.agentType??l,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:v?.provider.name?we(v.provider.name,12):l})]}):e.jsxs("div",{className:"relative",ref:y,children:[e.jsxs("button",{onClick:()=>f(!b),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: ${v?.provider.name??l} (click to change)`,children:[e.jsx(Q,{agentType:v?.provider.agentType??l,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:v?.provider.name?we(v.provider.name,12):l}),e.jsx(ee,{size:12,className:`shrink-0 transition-transform ${b?"rotate-180":""}`})]}),b&&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:h("切换渠道")}),x.map(p=>e.jsxs("button",{onClick:()=>{d(p.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 ${p.provider.id===i?"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:p.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:p.provider.name}),p.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:h("(默认)")})]}),p.provider.id===i&&e.jsx(V,{size:14,className:"shrink-0"})]},p.provider.id))]})]})}const jt="/api";function Nt(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}function yt({files:s,onRemove:i}){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(l=>e.jsx(kt,{item:l,onRemove:i},l.tempId))})}function kt({item:s,onRemove:i}){const l=s.file.type.startsWith("image/"),d=s.status==="error",h=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] ${d?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[l&&s.status==="done"&&s.attachment?e.jsx("img",{src:`${jt}${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:h?e.jsx(te,{size:16,className:"animate-spin text-neutral-400"}):l?e.jsx(it,{size:16,className:"text-neutral-400"}):e.jsx(tt,{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}),d?e.jsx("div",{className:"truncate text-red-500",children:s.error}):e.jsx("div",{className:"text-neutral-400",children:Nt(s.file.size)})]}),e.jsx("button",{onClick:()=>i(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(Ee,{size:10})})]})}const wt="/api";async function Tt(s){const i=new FormData;i.append("file",s);const l=await fetch(`${wt}/attachments/upload`,{method:"POST",body:i});if(!l.ok){const d=await l.json().catch(()=>({}));throw new Error(d.error||`Upload failed (${l.status})`)}return l.json()}let Ct=0;function St(){const[s,i]=r.useState([]),l=r.useRef(s);l.current=s;const d=r.useCallback(async t=>{const k=t.map(c=>({tempId:`tmp-${++Ct}`,file:c,progress:0,status:"uploading"}));i(c=>[...c,...k]),await Promise.allSettled(k.map(async c=>{try{const C=await Tt(c.file);i(S=>S.map(m=>m.tempId===c.tempId?{...m,status:"done",progress:100,attachment:C}:m))}catch(C){i(S=>S.map(m=>m.tempId===c.tempId?{...m,status:"error",error:C instanceof Error?C.message:"Upload failed"}:m))}}))},[]),h=r.useCallback(()=>l.current.filter(t=>t.status==="done"&&t.attachment).map(t=>t.attachment),[]),b=r.useCallback(t=>{i(k=>k.filter(c=>c.tempId!==t))},[]),f=r.useCallback(()=>{i([])},[]),y=r.useCallback(t=>{t.length!==0&&i(k=>{const c=new Set(k.map(S=>S.attachment?.id??S.tempId)),C=t.filter(S=>{const m=S.attachment?.id??S.tempId;return c.has(m)?!1:(c.add(m),!0)});return C.length>0?[...k,...C]:k})},[]),x=r.useCallback(()=>{const t=h();return t.length===0?"":t.map(k=>`${k.mimeType.startsWith("image/")?"!":""}[${k.originalName}](${k.storagePath})`).join(`
2
- `)},[h]),v=s.length>0,p=s.some(t=>t.status==="uploading");return{files:s,addFiles:d,removeFile:b,clear:f,restoreFiles:y,buildMarkdownLinks:x,getDoneAttachments:h,hasFiles:v,isUploading:p}}function Gt(s){const i=r.useMemo(()=>Array.from(new Set(s.filter(Boolean))),[s]);return $e({queryKey:["attachments","metadata",i],queryFn:()=>Be.get("/attachments/metadata",{params:{ids:i.join(",")}}),enabled:i.length>0,staleTime:300*1e3})}function Vt(s,i){return r.useMemo(()=>{for(let l=s.length-1;l>=0;l--){const d=s[l];if(d.tokenUsage&&typeof d.tokenUsage.totalTokens=="number"&&d.tokenUsage.totalTokens>0)return{totalTokens:d.tokenUsage.totalTokens,modelContextWindow:d.tokenUsage.modelContextWindow}}return i??null},[s,i])}function Me(s,i,l,d){if(l.filter(f=>f===d).length<=1)return s;const b=l.slice(0,i+1).filter(f=>f===d).length;return`${s} #${b}`}function Mt(s){return Object.values(s).filter(Boolean).length}function Et({mode:s,setMode:i,selectedTemplateId:l,setSelectedTemplateId:d,selectedMemberPresetIds:h,setSelectedMemberPresetIds:b,disabled:f=!1,compact:y=!1}){const{t:x}=ae(),{preserveDesktopSearch:v}=Ue(),[p,t]=r.useState(!1),{data:k}=Ye(),{data:c,isError:C,isFetching:S,isLoading:m,refetch:P}=We(),{data:o,isError:g,isFetching:u,isLoading:M,refetch:w}=qe(),_=r.useMemo(()=>new Map((k??[]).map(({provider:a,availability:j})=>[a.id,a.name+(j.type==="NOT_FOUND"?x(" (不可用)"):"")])),[k,x]),z=r.useMemo(()=>new Map((c??[]).map(a=>[a.id,a])),[c]),W=r.useMemo(()=>new Map((o??[]).map(a=>[a.id,a])),[o]),L=r.useMemo(()=>h.map(a=>z.get(a)).filter(a=>!!a),[z,h]);r.useEffect(()=>{c!==void 0&&b(a=>{const j=a.filter(E=>z.has(E));return j.length===a.length&&j.every((E,D)=>E===a[D])?a:j})},[c,z,b]),r.useEffect(()=>{o!==void 0&&d(a=>!a||W.has(a)?a:null)},[d,W,o]);const q=a=>{f||d(j=>j===a?null:a)},B=a=>{f||b(j=>[...j,a])},ie=a=>{f||b(j=>j.filter((E,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("团队模板")}),g?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:()=>{w()},disabled:f||u,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):M?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("加载中...")]}):(o??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[x("当前没有团队模板"),e.jsx(Te,{to:v("/settings/team"),className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:N("space-y-1.5",y&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(o??[]).map(a=>{const j=a.id===l,E=a.members?.length??0,D=a.members?.map($=>$.memberPresetId)??[],U=a.members?.slice(0,3).map(($,le)=>Me($.memberPreset?.name??$.memberPresetId,le,D,$.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>q(a.id),disabled:f,className:N("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",j?"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:N("text-xs truncate",j?"font-medium text-foreground":"text-foreground"),children:a.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[E,x("人")]})]}),U&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:U})]}),j&&e.jsx(V,{size:13,className:"shrink-0 text-foreground"})]})},a.id)})})]}),X=L.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:L.map((a,j)=>{const E=Me(a.name,j,h,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(Ce,{name:a.name,avatar:a.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:E}),e.jsx("button",{type:"button",onClick:()=>ie(j),disabled:f,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Ee,{size:9})})]},`${a.id}-${j}`)})}),K=C?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:()=>{P()},disabled:f||S,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):m?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("加载中...")]}):(c??[]).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(Te,{to:v("/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:(c??[]).map(a=>{const j=h.filter(U=>U===a.id).length,E=_.get(a.providerId)??a.providerId,D=Mt(a.capabilities);return e.jsxs("button",{type:"button",onClick:()=>B(a.id),disabled:f,className:N("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(Ce,{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:[E," · ",D,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[j>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",j]}),e.jsx(Ge,{size:12,className:"text-muted-foreground"})]})]},a.id)})}),Y=L.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:L.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&&i("AUTO"),disabled:f,className:N("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(ft,{size:11}),x("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!f&&i("CONFIRM"),disabled:f,className:N("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(dt,{size:11}),x("确认模式")]})]})]});return y?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&&t(a=>!a),disabled:f,"aria-expanded":p,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:N("transition-transform",p?"":"-rotate-90")}),x("追加独立成员"),Y]}),p&&e.jsxs("div",{className:"mt-2",children:[X,K]})]})]}):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("追加成员")}),Y]}),X,K]})]})]})}function Xt({className:s="h-7 w-7"}){return e.jsx("img",{src:Ke,alt:"Agent Tower",className:`block shrink-0 object-contain ${s}`})}function Zt({className:s=""}){return e.jsx("span",{className:`font-semibold text-foreground tracking-tight text-base ${s}`,children:"Agent Tower"})}const At={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Jt({variant:s="task",projects:i,providers:l,isProvidersLoading:d,onSubmit:h,defaultProjectId:b="",defaultProviderId:f="",onProjectChange:y,createStep:x,placeholder:v,submitLabel:p,pendingLabel:t,submitTitle:k}){const{t:c}=ae(),[C,S]=r.useState(""),[m,P]=r.useState(b),[o,g]=r.useState(f),[u,M]=r.useState("SOLO"),[w,_]=r.useState(O.WORKTREE),[z,W]=r.useState("AUTO"),[L,q]=r.useState(null),[B,ie]=r.useState([]),[se,X]=r.useState(!1),[K,Y]=r.useState(!1),[H,a]=r.useState(!1),[j,E]=r.useState(!1),D=r.useRef(null),U=r.useRef(null),$=r.useRef(null),le=r.useRef(null),pe=r.useRef(null),{files:ge,addFiles:G,removeFile:Ae,clear:he,buildMarkdownLinks:be,getDoneAttachments:ve,isUploading:re}=St(),A=s==="conversation",T=s==="task"||s==="conversation",Ie=p??c(A?"开始":"创建");r.useEffect(()=>{P(b),y?.(b)},[b,y]),r.useEffect(()=>{g(f)},[f]),r.useEffect(()=>{if(!K)return;const n=I=>{D.current&&!D.current.contains(I.target)&&Y(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[K]),r.useEffect(()=>{if(!H)return;const n=I=>{U.current&&!U.current.contains(I.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[H]),r.useEffect(()=>{if(!j)return;const n=I=>{$.current&&!$.current.contains(I.target)&&E(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[j]);const ce=r.useMemo(()=>i.find(n=>n.id===m),[i,m]),de=r.useMemo(()=>l.find(n=>n.id===o),[l,o]),ze=w===O.MAIN_DIRECTORY?c("本地模式"):c("工作树模式"),R=x!=="idle",je=!!L||B.length>0,Z=!R&&!re&&C.trim().length>0&&(A?!!o:!!m&&(u==="SOLO"?!!o:je)),ue=r.useCallback(async()=>{if(!Z)return;const n=T?be():"",I=T?ve().map(J=>J.id):[];try{await h({title:C.trim(),description:"",projectId:A?"":m,providerId:o,mode:A?"SOLO":u,workspaceMode:!A&&u==="SOLO"?w:O.WORKTREE,teamRunMode:A?"AUTO":z,teamTemplateId:A?null:L,memberPresetIds:A?[]:B,attachmentLinks:n,attachmentIds:I}),S(""),T&&he()}catch{}},[Z,T,be,ve,h,C,A,m,o,u,w,z,L,B,he]),Re=r.useCallback(n=>{n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),ue())},[ue]),Le=r.useCallback(n=>{const I=n.target.files;I&&I.length>0&&G(Array.from(I)),n.target.value=""},[G]),_e=r.useCallback(n=>{P(n),y?.(n),Y(!1)},[y]),De=r.useCallback(n=>{if(!T)return;const I=n.clipboardData.items,J=[];for(const ye of I)if(ye.kind==="file"){const ke=ye.getAsFile();ke&&J.push(ke)}J.length>0&&(n.preventDefault(),G(J))},[G,T]),[Ne,me]=r.useState(!1),Oe=r.useCallback(n=>{T&&(n.preventDefault(),me(!0))},[T]),Fe=r.useCallback(n=>{T&&(n.preventDefault(),me(!1))},[T]),Pe=r.useCallback(n=>{if(!T)return;n.preventDefault(),me(!1);const I=n.dataTransfer.files;I.length>0&&G(Array.from(I))},[G,T]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:N("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",Ne?"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&&ge.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(yt,{files:ge,onRemove:Ae})}),e.jsx("textarea",{ref:le,value:C,onChange:n=>S(n.target.value),onKeyDown:Re,onPaste:T?De:void 0,placeholder:c(v||"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&&Ne&&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:c("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:()=>pe.current?.click(),disabled:R||re,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:c("Attach files"),children:e.jsx(Ve,{size:18})}),e.jsx("input",{ref:pe,type:"file",multiple:!0,onChange:Le,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[T&&re&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(te,{size:14,className:"animate-spin"}),c("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"}),c(t??At[x])]}),!A&&!R&&!re&&u==="TEAM"&&!je&&C.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:c("请选择团队模板或追加成员")}),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:ue,disabled:!Z,className:N("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:c(k||"Create & Start"),children:e.jsx(Qe,{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:D,children:[e.jsxs("button",{type:"button",onClick:()=>{R||Y(n=>!n)},disabled:R,className:N("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(Xe,{size:14,className:"shrink-0",style:{color:ce?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:ce?.name??c("Project")}),e.jsx(ee,{size:12,className:N("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:i.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:N("truncate flex-1",n.id===m?"text-foreground font-medium":"text-muted-foreground"),children:n.name}),e.jsx(V,{size:14,className:N("ml-2 shrink-0 text-foreground",n.id===m?"opacity-100":"opacity-0")})]},n.id))})]}),(A||u==="SOLO")&&e.jsxs("div",{className:"relative",ref:U,children:[e.jsxs("button",{type:"button",onClick:()=>{R||a(n=>!n)},disabled:R,className:N("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",de?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Q,{agentType:de?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:de?.name??c(d?"Loading...":"Agent")}),e.jsx(ee,{size:12,className:N("text-muted-foreground transition-transform",H&&"rotate-180")})]}),H&&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:l.map(n=>e.jsxs("button",{type:"button",disabled:!n.available,onClick:()=>{g(n.id),a(!1)},className:N("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(V,{size:14,className:N("mr-2 shrink-0 text-foreground",n.id===o?"opacity-100":"opacity-0")}),e.jsx(Q,{agentType:n.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:N("min-w-0 truncate",n.id===o?"text-foreground font-medium":"text-muted-foreground"),children:[n.name,n.available?"":c(" (unavailable)")]})]},n.id))})]}),!A&&u==="SOLO"&&e.jsxs("div",{className:"relative",ref:$,children:[e.jsxs("button",{type:"button",onClick:()=>{R||E(n=>!n)},disabled:R,className:N("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(at,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:ze}),e.jsx(ee,{size:12,className:N("text-muted-foreground transition-transform",j&&"rotate-180")})]}),j&&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:()=>{_(O.WORKTREE),E(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(V,{size:14,className:N("mr-2 shrink-0 text-foreground",w===O.WORKTREE?"opacity-100":"opacity-0")}),e.jsx("span",{className:N("truncate",w===O.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:c("工作树模式")})]}),e.jsxs("button",{type:"button",onClick:()=>{_(O.MAIN_DIRECTORY),E(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(V,{size:14,className:N("mr-2 shrink-0 text-foreground",w===O.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsx("span",{className:N("truncate",w===O.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:c("本地模式")})]})]})]}),!A&&e.jsxs("button",{type:"button",role:"switch","aria-checked":u==="TEAM",onClick:()=>{R||(u==="TEAM"?(M("SOLO"),X(!1)):(M("TEAM"),E(!1),_(O.WORKTREE),X(!0)))},disabled:R,className:N("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",u==="TEAM"?"text-foreground/80":"text-muted-foreground"),title:c("启用团队模式"),children:[e.jsx(He,{size:14,className:u==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:c("团队模式")}),e.jsx("span",{className:N("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",u==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:N("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",u==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})]}),!A&&u==="SOLO"&&w===O.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:c("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),!A&&u==="TEAM"&&se&&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(Et,{mode:z,setMode:W,selectedTemplateId:L,setSelectedTemplateId:q,selectedMemberPresetIds:B,setSelectedMemberPresetIds:ie,disabled:R,compact:!0})})]})}export{Ut as A,Xt as B,Jt as C,tt as F,at as G,it as I,Yt as P,qt as S,Kt as T,ft as Z,Vt as a,St as b,yt as c,Qe as d,Zt as e,Wt as f,Gt as g,Et as h,dt as i,Ht as u};