agent-tower 0.5.2 → 0.5.3-beta.0

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 (162) hide show
  1. package/dist/cli.js +14 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/executors/__tests__/base.executor.test.js +12 -0
  4. package/dist/executors/__tests__/base.executor.test.js.map +1 -1
  5. package/dist/executors/execution-env.d.ts +1 -1
  6. package/dist/executors/execution-env.d.ts.map +1 -1
  7. package/dist/executors/execution-env.js +4 -0
  8. package/dist/executors/execution-env.js.map +1 -1
  9. package/dist/routes/conversations.d.ts +3 -0
  10. package/dist/routes/conversations.d.ts.map +1 -0
  11. package/dist/routes/conversations.js +102 -0
  12. package/dist/routes/conversations.js.map +1 -0
  13. package/dist/routes/index.d.ts.map +1 -1
  14. package/dist/routes/index.js +3 -0
  15. package/dist/routes/index.js.map +1 -1
  16. package/dist/routes/sessions.d.ts.map +1 -1
  17. package/dist/routes/sessions.js +37 -21
  18. package/dist/routes/sessions.js.map +1 -1
  19. package/dist/services/__tests__/conversation.service.test.d.ts +2 -0
  20. package/dist/services/__tests__/conversation.service.test.d.ts.map +1 -0
  21. package/dist/services/__tests__/conversation.service.test.js +102 -0
  22. package/dist/services/__tests__/conversation.service.test.js.map +1 -0
  23. package/dist/services/commit-message.service.d.ts.map +1 -1
  24. package/dist/services/commit-message.service.js +4 -0
  25. package/dist/services/commit-message.service.js.map +1 -1
  26. package/dist/services/conversation.service.d.ts +26 -0
  27. package/dist/services/conversation.service.d.ts.map +1 -0
  28. package/dist/services/conversation.service.js +224 -0
  29. package/dist/services/conversation.service.js.map +1 -0
  30. package/dist/services/session-manager.d.ts +69 -13
  31. package/dist/services/session-manager.d.ts.map +1 -1
  32. package/dist/services/session-manager.js +107 -42
  33. package/dist/services/session-manager.js.map +1 -1
  34. package/dist/services/task.service.d.ts +2 -2
  35. package/dist/services/terminal-manager.d.ts.map +1 -1
  36. package/dist/services/terminal-manager.js +2 -0
  37. package/dist/services/terminal-manager.js.map +1 -1
  38. package/dist/services/workspace.service.d.ts +9 -7
  39. package/dist/services/workspace.service.d.ts.map +1 -1
  40. package/dist/types/index.d.ts +4 -0
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/dist/types/index.js +6 -0
  43. package/dist/types/index.js.map +1 -1
  44. package/dist/web/assets/AgentDemoPage-CUgqAjq9.js +1 -0
  45. package/dist/web/assets/ConversationPage-Cyiw8Hra.js +3 -0
  46. package/dist/web/assets/CreateTaskInput-BILlpv9b.js +2 -0
  47. package/dist/web/assets/{DemoPage-Xc4QRNUj.js → DemoPage-SywVXjL0.js} +1 -1
  48. package/dist/web/assets/{GeneralSettingsPage-DWKl6BHA.js → GeneralSettingsPage-CTymytF6.js} +1 -1
  49. package/dist/web/assets/Icons-DmLVnVdg.js +1 -0
  50. package/dist/web/assets/{McpSettingsPage-BHEMUq7Z.js → McpSettingsPage-DyolUN8C.js} +1 -1
  51. package/dist/web/assets/{MemberAvatar-b_WKLu8w.js → MemberAvatar-u6jTOiDY.js} +1 -1
  52. package/dist/web/assets/NotificationSettingsPage-BBop2Bu4.js +1 -0
  53. package/dist/web/assets/ProfileSettingsPage-Bw-eI0cF.js +3 -0
  54. package/dist/web/assets/ProjectKanbanPage-BFf2FZVz.js +89 -0
  55. package/dist/web/assets/ProjectSettingsPage-BJ4sOhMl.js +2 -0
  56. package/dist/web/assets/{ProviderSettingsPage-DQ_IDUUZ.js → ProviderSettingsPage-BlLaN0i2.js} +19 -19
  57. package/dist/web/assets/{SettingsMasterDetail-Cx9Ylq9N.js → SettingsMasterDetail-CdimTj5n.js} +1 -1
  58. package/dist/web/assets/TeamSettingsPage-CqQTc5AI.js +1 -0
  59. package/dist/web/assets/{arc-D31VhUJX.js → arc-Ddp5hhH6.js} +1 -1
  60. package/dist/web/assets/{architectureDiagram-3BPJPVTR-Ak9jpJ8q.js → architectureDiagram-3BPJPVTR-CpK7WDLU.js} +1 -1
  61. package/dist/web/assets/{arrow-left-DcUokonk.js → arrow-left-B6KMicbE.js} +1 -1
  62. package/dist/web/assets/{blockDiagram-GPEHLZMM-DEDpa_4t.js → blockDiagram-GPEHLZMM-6_0hov2h.js} +1 -1
  63. package/dist/web/assets/{c4Diagram-AAUBKEIU-BgS3ci_x.js → c4Diagram-AAUBKEIU-Br6Tzu3R.js} +1 -1
  64. package/dist/web/assets/channel-Bg_GO2e9.js +1 -0
  65. package/dist/web/assets/check-D9lM__p8.js +1 -0
  66. package/dist/web/assets/{chevron-down-DuDzRplH.js → chevron-down-Cur5jANy.js} +1 -1
  67. package/dist/web/assets/{chevron-right-BezhysME.js → chevron-right-R3KVa8oQ.js} +1 -1
  68. package/dist/web/assets/{chevron-up-DtQ85g91.js → chevron-up-DcLdFanO.js} +1 -1
  69. package/dist/web/assets/{chunk-2J33WTMH-BnpAjP2E.js → chunk-2J33WTMH-D8zyttB-.js} +1 -1
  70. package/dist/web/assets/{chunk-4BX2VUAB-DNUdFpBR.js → chunk-4BX2VUAB-Cqi9xJ8M.js} +1 -1
  71. package/dist/web/assets/{chunk-55IACEB6-CTj6ihx_.js → chunk-55IACEB6-Dxjaitf1.js} +1 -1
  72. package/dist/web/assets/{chunk-727SXJPM-yKiHVB7X.js → chunk-727SXJPM-CAn8Y9XB.js} +1 -1
  73. package/dist/web/assets/{chunk-AQP2D5EJ-njbMVjqc.js → chunk-AQP2D5EJ-B4sECH9U.js} +1 -1
  74. package/dist/web/assets/{chunk-FMBD7UC4-h0jEUL75.js → chunk-FMBD7UC4-Ckd3e1dg.js} +1 -1
  75. package/dist/web/assets/{chunk-ND2GUHAM-DjMFJZNr.js → chunk-ND2GUHAM-h5WBT7BK.js} +1 -1
  76. package/dist/web/assets/{chunk-QZHKN3VN-odAhWIp4.js → chunk-QZHKN3VN-Cdzk46MK.js} +1 -1
  77. package/dist/web/assets/{circle-alert-IhLKVEi9.js → circle-alert-OKyZ9U2p.js} +1 -1
  78. package/dist/web/assets/classDiagram-4FO5ZUOK-BeJctdRx.js +1 -0
  79. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BeJctdRx.js +1 -0
  80. package/dist/web/assets/{code-block-OCS4YCEC-4ofbxqu2.js → code-block-OCS4YCEC-VMJOsrkF.js} +1 -1
  81. package/dist/web/assets/{confirm-dialog-Amksh2QM.js → confirm-dialog-BAnxa2C9.js} +1 -1
  82. package/dist/web/assets/{cose-bilkent-S5V4N54A-Ds62_zKQ.js → cose-bilkent-S5V4N54A-CbFey2pd.js} +1 -1
  83. package/dist/web/assets/{dagre-BM42HDAG-De9CyhMh.js → dagre-BM42HDAG-Bd2eIyf3.js} +1 -1
  84. package/dist/web/assets/{diagram-2AECGRRQ-Db7DRtzA.js → diagram-2AECGRRQ-CXONvVnW.js} +1 -1
  85. package/dist/web/assets/{diagram-5GNKFQAL-DXeGI1-M.js → diagram-5GNKFQAL-B2E90mVs.js} +1 -1
  86. package/dist/web/assets/{diagram-KO2AKTUF-Llle6qEC.js → diagram-KO2AKTUF-ByaC99pb.js} +1 -1
  87. package/dist/web/assets/{diagram-LMA3HP47-BcK1LGRh.js → diagram-LMA3HP47-DwVBF2fn.js} +1 -1
  88. package/dist/web/assets/{diagram-OG6HWLK6-0_sJ3YRD.js → diagram-OG6HWLK6-FWRddceo.js} +1 -1
  89. package/dist/web/assets/{erDiagram-TEJ5UH35-BjT0k23c.js → erDiagram-TEJ5UH35-ye6i3SGj.js} +1 -1
  90. package/dist/web/assets/{flowDiagram-I6XJVG4X-kaKS6P_m.js → flowDiagram-I6XJVG4X-B6l7qTcg.js} +1 -1
  91. package/dist/web/assets/folder-B0m3OL2U.js +1 -0
  92. package/dist/web/assets/folder-picker-D5XrSfLA.js +1 -0
  93. package/dist/web/assets/{ganttDiagram-6RSMTGT7-CW8IoCY6.js → ganttDiagram-6RSMTGT7-BCCqDrep.js} +1 -1
  94. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-C5-QVJMh.js → gitGraphDiagram-PVQCEYII-Ca4ANaSw.js} +1 -1
  95. package/dist/web/assets/index-C4twOgZR.css +1 -0
  96. package/dist/web/assets/{index-Du7RXa9t.js → index-C9hQg1KT.js} +4 -4
  97. package/dist/web/assets/{index-Bd5HU-dB.js → index-DbO4YyUv.js} +6 -6
  98. package/dist/web/assets/{infoDiagram-5YYISTIA-CG7QnPme.js → infoDiagram-5YYISTIA-D1V1Tezr.js} +1 -1
  99. package/dist/web/assets/{input-BxcpVmsb.js → input-Dqnd4oTj.js} +1 -1
  100. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DitLiYai.js → ishikawaDiagram-YF4QCWOH-DnGiJn9p.js} +1 -1
  101. package/dist/web/assets/{journeyDiagram-JHISSGLW-EKXFhiai.js → journeyDiagram-JHISSGLW-QFxbLfhN.js} +1 -1
  102. package/dist/web/assets/{kanban-definition-UN3LZRKU-Ckbr1P9R.js → kanban-definition-UN3LZRKU-BA2nBc7B.js} +1 -1
  103. package/dist/web/assets/{layers-Dqjek9Kd.js → layers-CfFYGUtI.js} +1 -1
  104. package/dist/web/assets/{linear-HA2k3O-l.js → linear-DpASQZmA.js} +1 -1
  105. package/dist/web/assets/{loader-circle-B4v8mirO.js → loader-circle-B5Lfi46Y.js} +1 -1
  106. package/dist/web/assets/log-adapter-CjgRCCYG.js +1 -0
  107. package/dist/web/assets/{mermaid-NOHMQCX5-C2N-Y-YP.js → mermaid-NOHMQCX5-7FmPQynq.js} +60 -60
  108. package/dist/web/assets/{message-square-B-2bz9LU.js → message-square-CEefL0sf.js} +1 -1
  109. package/dist/web/assets/{mindmap-definition-RKZ34NQL-ByCTUtXz.js → mindmap-definition-RKZ34NQL-C7QuD-ms.js} +1 -1
  110. package/dist/web/assets/modal-CAB_bs-c.js +1 -0
  111. package/dist/web/assets/{pencil-DzjmtIoi.js → pencil-B__GQn9r.js} +1 -1
  112. package/dist/web/assets/{pieDiagram-4H26LBE5-DeQnXQoJ.js → pieDiagram-4H26LBE5-Bf5diCKb.js} +1 -1
  113. package/dist/web/assets/{quadrantDiagram-W4KKPZXB--ocdxSbH.js → quadrantDiagram-W4KKPZXB-BMbcPnH3.js} +1 -1
  114. package/dist/web/assets/{requirementDiagram-4Y6WPE33-CJq21gDX.js → requirementDiagram-4Y6WPE33-CUPvJXMk.js} +1 -1
  115. package/dist/web/assets/{rotate-ccw-BhUVdZv6.js → rotate-ccw-5d-eMwsw.js} +1 -1
  116. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-U373GNMv.js → sankeyDiagram-5OEKKPKP-C77g6vmK.js} +1 -1
  117. package/dist/web/assets/{select-CCf5nwYs.js → select-BJfNuuIV.js} +1 -1
  118. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BuH8el8s.js → sequenceDiagram-3UESZ5HK-xGOV8CdQ.js} +1 -1
  119. package/dist/web/assets/{stateDiagram-AJRCARHV-CqZ_L1ch.js → stateDiagram-AJRCARHV-Bc0piegy.js} +1 -1
  120. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CiRT9t6d.js +1 -0
  121. package/dist/web/assets/{switch-DsjSr4nv.js → switch-bLlDOWNp.js} +1 -1
  122. package/dist/web/assets/{terminal-JXRig8oL.js → terminal-Bh2qSv0U.js} +1 -1
  123. package/dist/web/assets/{textarea-BzeEPT1A.js → textarea-BcVRpxhF.js} +1 -1
  124. package/dist/web/assets/{timeline-definition-PNZ67QCA-BIrIbCOG.js → timeline-definition-PNZ67QCA-CcACRt_V.js} +1 -1
  125. package/dist/web/assets/trash-2-8Pu6lwnW.js +1 -0
  126. package/dist/web/assets/{upload-BwkqnAVE.js → upload-DNwyW_bv.js} +1 -1
  127. package/dist/web/assets/{use-profiles-DcyUHq0p.js → use-profiles-BIqkQu69.js} +1 -1
  128. package/dist/web/assets/{use-providers-BWgjPVX8.js → use-providers-BOyY0DcV.js} +1 -1
  129. package/dist/web/assets/{vennDiagram-CIIHVFJN-Dmk1mluX.js → vennDiagram-CIIHVFJN-BC9RHBQ5.js} +1 -1
  130. package/dist/web/assets/{wardley-L42UT6IY-CEY4M7Op.js → wardley-L42UT6IY-BgPj73Dc.js} +1 -1
  131. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CiK-Q213.js → wardleyDiagram-YWT4CUSO-PbfDUndy.js} +1 -1
  132. package/dist/web/assets/{xychartDiagram-2RQKCTM6-C5rj3Hpu.js → xychartDiagram-2RQKCTM6-D87KYJUM.js} +1 -1
  133. package/dist/web/index.html +2 -2
  134. package/node_modules/@agent-tower/shared/dist/types.d.ts +41 -1
  135. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  136. package/node_modules/@agent-tower/shared/dist/types.js +8 -0
  137. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  138. package/node_modules/@prisma/client/.prisma/client/edge.js +21 -6
  139. package/node_modules/@prisma/client/.prisma/client/index-browser.js +14 -0
  140. package/node_modules/@prisma/client/.prisma/client/index.d.ts +1789 -211
  141. package/node_modules/@prisma/client/.prisma/client/index.js +21 -6
  142. package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
  143. package/node_modules/@prisma/client/.prisma/client/schema.prisma +34 -14
  144. package/node_modules/@prisma/client/.prisma/client/wasm.js +14 -0
  145. package/package.json +1 -1
  146. package/prisma/migrations/20260618000000_add_conversations/migration.sql +79 -0
  147. package/prisma/schema.prisma +22 -2
  148. package/dist/web/assets/AgentDemoPage-DAdN5g19.js +0 -1
  149. package/dist/web/assets/NotificationSettingsPage-C2KeYegv.js +0 -1
  150. package/dist/web/assets/ProfileSettingsPage-CVOCVwVK.js +0 -3
  151. package/dist/web/assets/ProjectKanbanPage-J_5GxZQ7.js +0 -90
  152. package/dist/web/assets/ProjectSettingsPage-CP3V8oAJ.js +0 -2
  153. package/dist/web/assets/TeamSettingsPage-BHE2x82g.js +0 -1
  154. package/dist/web/assets/channel-BLjA9Brq.js +0 -1
  155. package/dist/web/assets/check-DyTLNLlk.js +0 -1
  156. package/dist/web/assets/classDiagram-4FO5ZUOK-DHqakOiv.js +0 -1
  157. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DHqakOiv.js +0 -1
  158. package/dist/web/assets/folder-picker-CbAfVBHD.js +0 -1
  159. package/dist/web/assets/index-LbQD7FZK.css +0 -1
  160. package/dist/web/assets/log-adapter-CtvxzS4j.js +0 -1
  161. package/dist/web/assets/modal-C6m1dmin.js +0 -1
  162. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DkD_6IX-.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,yCAA2B,CAAA;IAC3B,qCAAuB,CAAA;IACvB,2BAAa,CAAA;IACb,qCAAuB,CAAA;AACzB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;IACvB,4CAAyB,CAAA;AAC3B,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,WAAW;AACX,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,kDAAiC,CAAA;AACnC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,UAAU;AACV,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,sCAAyB,CAAA;IACzB,0CAA6B,CAAA;IAC7B,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED,OAAO;AACP,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;IACjB,wCAAuB,CAAA;AACzB,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;AAED,OAAO;AACP,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,eAAe;IACf,+BAAa,CAAA;IACb,2BAA2B;IAC3B,2CAAyB,CAAA;AAC3B,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,yCAA2B,CAAA;IAC3B,qCAAuB,CAAA;IACvB,2BAAa,CAAA;IACb,qCAAuB,CAAA;AACzB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;IACvB,4CAAyB,CAAA;AAC3B,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,WAAW;AACX,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,kDAAiC,CAAA;AACnC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,UAAU;AACV,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,sCAAyB,CAAA;IACzB,0CAA6B,CAAA;IAC7B,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED,OAAO;AACP,MAAM,CAAN,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;IACjB,wCAAuB,CAAA;AACzB,CAAC,EANW,aAAa,KAAb,aAAa,QAMxB;AAED,OAAO;AACP,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,eAAe;IACf,+BAAa,CAAA;IACb,2BAA2B;IAC3B,2CAAyB,CAAA;AAC3B,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,UAAU;AACV,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
@@ -0,0 +1 @@
1
+ import{h as H,u as Q,r as n,m as b,j as e,B as y,L as X,K as Y}from"./index-DbO4YyUv.js";import{u as Z,a as ee,b as te,T as se,P as ne,S as re}from"./mermaid-NOHMQCX5-7FmPQynq.js";import"./log-adapter-CjgRCCYG.js";import{I as L,a as ae,b as le,A as ie,G as oe}from"./Icons-DmLVnVdg.js";import{d as ce}from"./use-profiles-BIqkQu69.js";import{C as de}from"./chevron-up-DcLdFanO.js";import{C as xe}from"./chevron-down-Cur5jANy.js";import"./chevron-right-R3KVa8oQ.js";import"./check-D9lM__p8.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"],V=t=>{S(t),A("DEFAULT")},_=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),B=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:G,agentSessionId:I,attach:z,clearLogs:P}=Z({sessionId:a||"",onExit:_,onError:B}),{todos:R}=ee(G);n.useEffect(()=>{b.get("/demo/agents").then(t=>{U(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const M=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},K=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});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)}},O=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(te,{ref:C,logs:v,scrollElementRef:$})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("选择 Agent")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:i===t.type?"default":"outline",disabled:!t.available,onClick:()=>V(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:F.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:K,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(se,{todos:R})}),d&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:u,value:m,onChange:M,rows:3,placeholder:s("发送消息给 Agent..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ne,{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:O,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(re,{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};
@@ -0,0 +1,3 @@
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 U,Q as Ae,R as Te,H as Le,I as he,K as Pe,T as Me,U as oe}from"./index-DbO4YyUv.js";import{S as w}from"./log-adapter-CjgRCCYG.js";import{u as Re,a as qe,b as ze,T as Oe,P as Fe,S as Ke}from"./mermaid-NOHMQCX5-7FmPQynq.js";import{u as Qe,a as Ue,b as Be,A as _e,c as $e,P as Ge,T as He,d as Ve,B as We,e as Je,S as Ye,f as ye,C as Xe}from"./CreateTaskInput-BILlpv9b.js";import{u as Ze}from"./use-providers-BOyY0DcV.js";import{M as me}from"./message-square-CEefL0sf.js";import{A as et}from"./arrow-left-B6KMicbE.js";import{T as tt}from"./trash-2-8Pu6lwnW.js";import"./chevron-right-R3KVa8oQ.js";import"./chevron-down-Cur5jANy.js";import"./check-D9lM__p8.js";import"./loader-circle-B5Lfi46Y.js";import"./MemberAvatar-u6jTOiDY.js";import"./folder-B0m3OL2U.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),T=r.useRef(!1),{scrollRef:ee,contentRef:i,isAtBottom:O,scrollToBottom:H}=Qe({initial:"instant",resize:"smooth"}),{isConnected:F,isLoadingSnapshot:te,logs:D,entries:de,attach:j}=Re({sessionId:t,sessionStatus:n,onExit:I}),{todos:V}=qe(de),ue=Ue(D,f),{files:se,addFiles:E,removeFile:ne,clear:re,buildMarkdownLinks:W,getDoneAttachments:ae,hasFiles:L,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()&&!L||T.current||p||P)return;T.current=!0;const c=W(),v=ae().map(M=>M.id),Q=[u.trim(),c].filter(Boolean).join(`
2
+
3
+ `);q(""),re(),d(),z(null);try{await y({message:Q,providerId:A||void 0,attachmentIds:v}),await j(),requestAnimationFrame(()=>H("smooth"))}catch(M){z(M instanceof Error?M.message:o("Send failed. Please try again.")),q(Q)}finally{T.current=!1}},[u,L,p,P,W,ae,re,d,y,A,j,H,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,Q=[];for(const M of v)if(M.kind==="file"){const xe=M.getAsFile();xe&&Q.push(xe)}Q.length>0&&(c.preventDefault(),E(Q))},[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(ze,{logs:D})})}),!O&&e.jsxs("button",{type:"button",onClick:()=>H(),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")})]})]}),V.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:V})})}),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(He,{usage:ue}),s&&K&&!u.trim()&&!L?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()&&!L||P||p,className:k("rounded-lg p-2 transition-all duration-200",(u.trim()||L)&&!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(Ve,{size:18})})]})]})]})]})})]})}function ot(t=50){return ve({queryKey:x.conversations.list({limit:t}),queryFn:()=>U.get("/conversations",{params:{limit:String(t)}})})}function it(t){return ve({queryKey:x.conversations.detail(t??""),queryFn:()=>U.get(`/conversations/${t}`),enabled:!!t})}function lt(){const t=J();return ce({mutationFn:n=>U.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})=>U.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=>U.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=>U.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 Pt(){const{t}=le();xt();const n=Ae(),{conversationId:a}=Te(),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(),T=dt(),ee=ut(),i=_??C.find(s=>s.id===a)??null,O=r.useMemo(()=>z.filter(({availability:s})=>s.type!=="NOT_FOUND"),[z]),H=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})},[]),V=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=Le.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}V(b.id)}};return s.on(he.SESSION_COMPLETED,l),()=>{s.off(he.SESSION_COMPLETED,l)}},[a,se,D,j,V]);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")}}},L=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)||T.isPending||await T.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:L,onStop:P,onExit:de,isSending:G.isPending,isStopping:T.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("New Conversation")}),e.jsx(Xe,{variant:"conversation",projects:[],providers:H,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{Pt as ConversationPage};
@@ -0,0 +1,2 @@
1
+ import{h as P,r,j as e,u as ae,Y as ye,Z as ke,X as Me,i as $e,m as Be,s as Ue,v as We,L as we,g as v,_ as qe}from"./index-DbO4YyUv.js";import{C as Q}from"./chevron-down-Cur5jANy.js";import{C as V}from"./check-D9lM__p8.js";import{W as F}from"./log-adapter-CjgRCCYG.js";import{L as ee}from"./loader-circle-B5Lfi46Y.js";import{M as Te}from"./MemberAvatar-u6jTOiDY.js";import{u as Ke}from"./use-providers-BOyY0DcV.js";import{P as He}from"./trash-2-8Pu6lwnW.js";import{P as Ye}from"./mermaid-NOHMQCX5-7FmPQynq.js";import{F as Ve}from"./folder-B0m3OL2U.js";const Ge=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ut=P("arrow-down",Ge);const Xe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ze=P("arrow-up",Xe);const Je=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Qe=P("bot",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=P("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=P("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=P("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=P("image",ot);const lt=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Wt=P("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=P("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=P("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=P("zap",mt);const xt={damping:.7,stiffness:.05,mass:1.25},pt=70,ht=1e3/60,gt=350;let oe=!1;globalThis.document?.addEventListener("mousedown",()=>{oe=!0});globalThis.document?.addEventListener("mouseup",()=>{oe=!1});globalThis.document?.addEventListener("click",()=>{oe=!1});const Kt=(s={})=>{const[o,l]=r.useState(!1),[c,h]=r.useState(s.initial!==!1),[b,f]=r.useState(!1),k=r.useRef(null);k.current=s;const x=r.useCallback(()=>{if(!oe)return!1;const i=window.getSelection();if(!i||!i.rangeCount)return!1;const p=i.getRangeAt(0);return p.commonAncestorContainer.contains(m.current)||m.current?.contains(p.commonAncestorContainer)},[]),j=r.useCallback(i=>{t.isAtBottom=i,h(i)},[]),g=r.useCallback(i=>{t.escapedFromLock=i,l(i)},[]),t=r.useMemo(()=>{let i;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||!R.current?0:m.current.scrollHeight-1-m.current.clientHeight},get calculatedTargetScrollTop(){if(!m.current||!R.current)return 0;const{targetScrollTop:p}=this;if(!s.targetScrollTop)return p;if(i?.targetScrollTop===p)return i.calculatedScrollTop;const d=Math.max(Math.min(s.targetScrollTop(p,{scrollElement:m.current,contentElement:R.current}),p),0);return i={targetScrollTop:p,calculatedScrollTop:d},requestAnimationFrame(()=>{i=void 0}),d},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=pt}}},[]),N=r.useCallback((i={})=>{typeof i=="string"&&(i={animation:i}),i.preserveScrollPosition||j(!0);const p=Date.now()+(Number(i.wait)||0),d=ue(k.current,i.animation),{ignoreEscapes:M=!1}=i;let w,E=t.calculatedTargetScrollTop;i.duration instanceof Promise?i.duration.finally(()=>{w=Date.now()}):w=p+(i.duration??0);const L=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 L();if(O<Math.min(E,t.calculatedTargetScrollTop)){if(t.animation?.behavior===d){if(d==="instant")return t.scrollTop=t.calculatedTargetScrollTop,L();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 L()}return w>Date.now()?(E=t.calculatedTargetScrollTop,L()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?N({animation:ue(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 i.wait!==!0&&(t.animation=void 0),t.animation?.behavior===d?t.animation.promise:L()},[j,x,t]),u=r.useCallback(()=>{g(!0),j(!1)},[g,j]),C=r.useCallback(({target:i})=>{if(i!==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()){g(!0),j(!1);return}const w=p>M,E=p<M;if(t.animation?.ignoreEscapes){t.scrollTop=M;return}E&&(g(!0),j(!1)),w&&g(!1),!t.escapedFromLock&&t.isNearBottom&&j(!0)},1)},[g,j,x,t]),S=r.useCallback(({target:i,deltaY:p})=>{let d=i;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&&(g(!0),j(!1))},[g,j,t]),m=Ce(i=>{m.current?.removeEventListener("scroll",C),m.current?.removeEventListener("wheel",S),i?.addEventListener("scroll",C,{passive:!0}),i?.addEventListener("wheel",S,{passive:!0})},[]),R=Ce(i=>{if(t.resizeObserver?.disconnect(),!i)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=ue(k.current,p?k.current.resize:k.current.initial);N({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:gt})}else t.isNearBottom&&(g(!1),j(!0));p=M,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===w&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(i)},[]);return{contentRef:R,scrollRef:m,scrollToBottom:N,stopScroll:u,isAtBottom:c||b,isNearBottom:b,escapedFromLock:o,state:t}};function Ce(s,o){const l=r.useCallback(c=>(l.current=c,s(c)),o);return l}const de=new Map;function ue(...s){const o={...xt};let l=!1;for(const h of s){if(h==="instant"){l=!0;continue}typeof h=="object"&&(l=!1,o.damping=h.damping??o.damping,o.stiffness=h.stiffness??o.stiffness,o.mass=h.mass??o.mass)}const c=JSON.stringify(o);return de.has(c)||de.set(c,Object.freeze(o)),l?"instant":de.get(c)}function bt({content:s,children:o,className:l="",side:c="top"}){const h=c==="bottom"?"top-full mt-2":"bottom-full mb-2",b=c==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative ${l}`,children:[o,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 vt(s){return s>=.9?"text-red-500":s>=.7?"text-amber-500":"text-neutral-400"}function Ht({usage:s,tooltipSide:o="top"}){const{t:l}=ae();if(!s)return null;const c=s.modelContextWindow,h=c?s.totalTokens/c:0,b=c?Math.min(Math.round(h*100),100):null,f=c?vt(h):"text-neutral-400",k=c?e.jsx("span",{children:l("上下文: {used} / {max} tokens",{used:ne(s.totalTokens),max:ne(c)})}):e.jsx("span",{children:l("已使用: {used} tokens",{used:ne(s.totalTokens)})});return e.jsx(bt,{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(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,"%"]})]})]})})}function Yt({providers:s,currentProviderId:o,agentType:l,onSelect:c}){const{t:h}=ae(),[b,f]=r.useState(!1),k=r.useRef(null),x=s.filter(g=>String(g.provider.agentType)===l),j=s.find(g=>g.provider.id===o);return r.useEffect(()=>{function g(t){k.current&&!k.current.contains(t.target)&&f(!1)}if(b)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[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(ye,{size:14,className:"shrink-0"}),e.jsx("span",{children:j?.provider.name?ke(j.provider.name,12):l})]}):e.jsxs("div",{className:"relative",ref:k,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: ${j?.provider.name??l} (click to change)`,children:[e.jsx(ye,{size:14,className:"shrink-0"}),e.jsx("span",{children:j?.provider.name?ke(j.provider.name,12):l}),e.jsx(Q,{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(g=>e.jsxs("button",{onClick:()=>{c(g.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 ${g.provider.id===o?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate max-w-[120px]",children:g.provider.name}),g.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:h("(默认)")})]}),g.provider.id===o&&e.jsx(V,{size:14,className:"shrink-0"})]},g.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: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(l=>e.jsx(kt,{item:l,onRemove:o},l.tempId))})}function kt({item:s,onRemove:o}){const l=s.file.type.startsWith("image/"),c=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] ${c?"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(ee,{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}),c?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:()=>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 wt="/api";async function Tt(s){const o=new FormData;o.append("file",s);const l=await fetch(`${wt}/attachments/upload`,{method:"POST",body:o});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||`Upload failed (${l.status})`)}return l.json()}let Ct=0;function St(){const[s,o]=r.useState([]),l=r.useRef(s);l.current=s;const c=r.useCallback(async t=>{const N=t.map(u=>({tempId:`tmp-${++Ct}`,file:u,progress:0,status:"uploading"}));o(u=>[...u,...N]),await Promise.allSettled(N.map(async u=>{try{const C=await Tt(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))}}))},[]),h=r.useCallback(()=>l.current.filter(t=>t.status==="done"&&t.attachment).map(t=>t.attachment),[]),b=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=h();return t.length===0?"":t.map(N=>`${N.mimeType.startsWith("image/")?"!":""}[${N.originalName}](${N.storagePath})`).join(`
2
+ `)},[h]),j=s.length>0,g=s.some(t=>t.status==="uploading");return{files:s,addFiles:c,removeFile:b,clear:f,restoreFiles:k,buildMarkdownLinks:x,getDoneAttachments:h,hasFiles:j,isUploading:g}}function Vt(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 l=s.length-1;l>=0;l--){const c=s[l];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,l,c){if(l.filter(f=>f===c).length<=1)return s;const b=l.slice(0,o+1).filter(f=>f===c).length;return`${s} #${b}`}function Mt(s){return Object.values(s).filter(Boolean).length}function Et({mode:s,setMode:o,selectedTemplateId:l,setSelectedTemplateId:c,selectedMemberPresetIds:h,setSelectedMemberPresetIds:b,disabled:f=!1,compact:k=!1}){const{t:x}=ae(),[j,g]=r.useState(!1),{data:t}=Ke(),{data:N,isError:u,isFetching:C,isLoading:S,refetch:m}=Ue(),{data:R,isError:i,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]),L=r.useMemo(()=>new Map((R??[]).map(a=>[a.id,a])),[R]),$=r.useMemo(()=>h.map(a=>E.get(a)).filter(a=>!!a),[E,h]);r.useEffect(()=>{N!==void 0&&b(a=>{const y=a.filter(_=>E.has(_));return y.length===a.length&&y.every((_,D)=>_===a[D])?a:y})},[N,E,b]),r.useEffect(()=>{R!==void 0&&c(a=>!a||L.has(a)?a:null)},[c,L,R]);const O=a=>{f||c(y=>y===a?null:a)},q=a=>{f||b(y=>[...y,a])},U=a=>{f||b(y=>y.filter((_,D)=>D!==a))},te=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:x("团队模板")}),i?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(ee,{size:12,className:"animate-spin"}),x("加载中...")]}):(R??[]).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:v("space-y-1.5",k&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(R??[]).map(a=>{const y=a.id===l,_=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:v("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:v("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:[_,x("人")]})]}),W&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:W})]}),y&&e.jsx(V,{size:13,className:"shrink-0 text-foreground"})]})},a.id)})})]}),se=$.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.map((a,y)=>{const _=Se(a.name,y,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(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:_}),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}`)})}),G=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(ee,{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=h.filter(W=>W===a.id).length,_=w.get(a.providerId)??a.providerId,D=Mt(a.capabilities);return e.jsxs("button",{type:"button",onClick:()=>q(a.id),disabled:f,className:v("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:[_," · ",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(He,{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:v("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&&o("CONFIRM"),disabled:f,className:v("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 k?e.jsxs("div",{className:"space-y-3",children:[H,te,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&g(a=>!a),disabled:f,"aria-expanded":j,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(Q,{size:12,className:v("transition-transform",j?"":"-rotate-90")}),x("追加独立成员"),K]}),j&&e.jsxs("div",{className:"mt-2",children:[se,G]})]})]}):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:[te,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]}),se,G]})]})]})}const At="/assets/agent-tower-logo-COx9gy77.png";function Xt({className:s="h-7 w-7"}){return e.jsx("img",{src:At,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 It={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:o,providers:l,isProvidersLoading:c,onSubmit:h,defaultProjectId:b="",defaultProviderId:f="",onProjectChange:k,createStep:x,placeholder:j,submitLabel:g,pendingLabel:t,submitTitle:N}){const{t:u}=ae(),[C,S]=r.useState(""),[m,R]=r.useState(b),[i,p]=r.useState(f),[d,M]=r.useState("SOLO"),[w,E]=r.useState(F.WORKTREE),[L,$]=r.useState("AUTO"),[O,q]=r.useState(null),[U,te]=r.useState([]),[se,G]=r.useState(!1),[K,H]=r.useState(!1),[a,y]=r.useState(!1),[_,D]=r.useState(!1),W=r.useRef(null),B=r.useRef(null),X=r.useRef(null),Ee=r.useRef(null),me=r.useRef(null),{files:fe,addFiles:Y,removeFile:Ae,clear:xe,buildMarkdownLinks:pe,getDoneAttachments:he,isUploading:re}=St(),A=s==="conversation",T=s==="task"||s==="conversation",Ie=g??u(A?"开始":"创建");r.useEffect(()=>{R(b),k?.(b)},[b,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(!_)return;const n=I=>{X.current&&!X.current.contains(I.target)&&D(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[_]);const ie=r.useMemo(()=>o.find(n=>n.id===m),[o,m]),ge=r.useMemo(()=>l.find(n=>n.id===i),[l,i]),_e=w===F.MAIN_DIRECTORY?u("本地模式"):u("工作树模式"),z=x!=="idle",be=!!O||U.length>0,Z=!z&&!re&&C.trim().length>0&&(A?!!i:!!m&&(d==="SOLO"?!!i:be)),le=r.useCallback(async()=>{if(!Z)return;const n=T?pe():"",I=T?he().map(J=>J.id):[];try{await h({title:C.trim(),description:"",projectId:A?"":m,providerId:i,mode:A?"SOLO":d,workspaceMode:!A&&d==="SOLO"?w:F.WORKTREE,teamRunMode:A?"AUTO":L,teamTemplateId:A?null:O,memberPresetIds:A?[]:U,attachmentLinks:n,attachmentIds:I}),S(""),T&&xe()}catch{}},[Z,T,pe,he,h,C,A,m,i,d,w,L,O,U,xe]),ze=r.useCallback(n=>{n.key==="Enter"&&!n.shiftKey&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),le())},[le]),Re=r.useCallback(n=>{const I=n.target.files;I&&I.length>0&&Y(Array.from(I)),n.target.value=""},[Y]),Le=r.useCallback(n=>{R(n),k?.(n),H(!1)},[k]),De=r.useCallback(n=>{if(!T)return;const I=n.clipboardData.items,J=[];for(const je of I)if(je.kind==="file"){const Ne=je.getAsFile();Ne&&J.push(Ne)}J.length>0&&(n.preventDefault(),Y(J))},[Y,T]),[ve,ce]=r.useState(!1),Oe=r.useCallback(n=>{T&&(n.preventDefault(),ce(!0))},[T]),Fe=r.useCallback(n=>{T&&(n.preventDefault(),ce(!1))},[T]),Pe=r.useCallback(n=>{if(!T)return;n.preventDefault(),ce(!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:v("relative bg-background rounded-xl border transition-all duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.04)]","hover:border-foreground/15 hover:shadow-[0_2px_6px_rgba(0,0,0,0.05)]","focus-within:border-foreground/25 focus-within:shadow-[0_2px_8px_rgba(0,0,0,0.06)]",ve?"border-info/40 bg-info/5 ring-2 ring-info/15":"border-border",z&&"opacity-80"),onDragOver:T?Oe:void 0,onDragLeave:T?Fe:void 0,onDrop:T?Pe:void 0,children:[T&&fe.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(yt,{files:fe,onRemove:Ae})}),e.jsx("textarea",{ref:Ee,value:C,onChange:n=>S(n.target.value),onKeyDown:ze,onPaste:T?De:void 0,placeholder:u(j||"Describe your task..."),disabled:z,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&&ve&&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:()=>me.current?.click(),disabled:z||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:u("Attach files"),children:e.jsx(Ye,{size:18})}),e.jsx("input",{ref:me,type:"file",multiple:!0,onChange:Re,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(ee,{size:14,className:"animate-spin"}),u("Uploading...")]}),z&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ee,{size:14,className:"animate-spin"}),u(t??It[x])]}),!A&&!z&&!re&&d==="TEAM"&&!be&&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:le,disabled:!Z,className:v("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(Ze,{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:()=>{z||H(n=>!n)},disabled:z,className:v("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",ie?"text-foreground":"text-muted-foreground"),children:[e.jsx(Ve,{size:14,className:"shrink-0",style:{color:ie?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:ie?.name??u("Project")}),e.jsx(Q,{size:12,className:v("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:()=>Le(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:v("truncate flex-1",n.id===m?"text-foreground font-medium":"text-muted-foreground"),children:n.name}),e.jsx(V,{size:14,className:v("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:()=>{z||y(n=>!n)},disabled:z,className:v("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",ge?"text-foreground":"text-muted-foreground"),children:[e.jsx(Qe,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[120px] truncate",children:ge?.name??u(c?"Loading...":"Agent")}),e.jsx(Q,{size:12,className:v("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:l.map(n=>e.jsxs("button",{type:"button",disabled:!n.available,onClick:()=>{p(n.id),y(!1)},className:v("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:v("mr-2 shrink-0 text-foreground",n.id===i?"opacity-100":"opacity-0")}),e.jsxs("span",{className:v("truncate",n.id===i?"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:()=>{z||D(n=>!n)},disabled:z,className:v("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"),children:[e.jsx(at,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:_e}),e.jsx(Q,{size:12,className:v("text-muted-foreground transition-transform",_&&"rotate-180")})]}),_&&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(V,{size:14,className:v("mr-2 shrink-0 text-foreground",w===F.WORKTREE?"opacity-100":"opacity-0")}),e.jsx("span",{className:v("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(V,{size:14,className:v("mr-2 shrink-0 text-foreground",w===F.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsx("span",{className:v("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:()=>{z||(d==="TEAM"?(M("SOLO"),G(!1)):(M("TEAM"),D(!1),E(F.WORKTREE),G(!0)))},disabled:z,className:v("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":"text-muted-foreground"),title:u("启用团队模式"),children:[e.jsx(qe,{size:14,className:d==="TEAM"?"text-foreground":"text-muted-foreground"}),e.jsx("span",{children:u("团队模式")}),e.jsx("span",{className:v("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:v("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"&&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:L,setMode:$,selectedTemplateId:O,setSelectedTemplateId:q,selectedMemberPresetIds:U,setSelectedMemberPresetIds:te,disabled:z,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,Ht as T,ft as Z,Gt as a,St as b,yt as c,Ze as d,Zt as e,Wt as f,Vt as g,Et as h,dt as i,Kt as u};
@@ -1,4 +1,4 @@
1
- import{r as a,E as j,F as E,G as T,j as t,g as M,u as U,m as I,B as O}from"./index-Bd5HU-dB.js";function P(s){const{sessionId:c,onOutput:k,onExit:x,onError:b}=s,[p,g]=a.useState(()=>j.isConnected()),[l,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},C=r=>{r.sessionId===c&&m.current.onOutput?.(r.data)},w=r=>{r.sessionId===c&&(d(!1),m.current.onExit?.(r.exitCode))},S=r=>{r.sessionId===c&&m.current.onError?.(r.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,C),n.on(E.SESSION_EXIT,w),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,C),n.off(E.SESSION_EXIT,w),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:l,attach:i,detach:y,sendInput:N,resize:h}}function $({className:s,...c}){return t.jsx("div",{"data-slot":"card",className:M("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",s),...c})}function B(){const{t:s}=U(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[l,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
1
+ import{r as a,H as j,I as E,J as T,j as t,g as M,u as U,m as I,B as O}from"./index-DbO4YyUv.js";function P(s){const{sessionId:c,onOutput:k,onExit:x,onError:b}=s,[p,g]=a.useState(()=>j.isConnected()),[l,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},C=r=>{r.sessionId===c&&m.current.onOutput?.(r.data)},w=r=>{r.sessionId===c&&(d(!1),m.current.onExit?.(r.exitCode))},S=r=>{r.sessionId===c&&m.current.onError?.(r.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,C),n.on(E.SESSION_EXIT,w),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,C),n.off(E.SESSION_EXIT,w),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:l,attach:i,detach:y,sendInput:N,resize:h}}function $({className:s,...c}){return t.jsx("div",{"data-slot":"card",className:M("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",s),...c})}function B(){const{t:s}=U(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[l,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
2
2
  [进程退出,退出码: ${e}]`,timestamp:new Date}]),d(null)},[]),w=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
3
3
  [错误: ${e}]`,timestamp:new Date}])},[]),{isConnected:S,isAttached:r,attach:D}=P({sessionId:l||"",onOutput:v,onExit:C,onError:w});a.useEffect(()=>{I.get("/demo/agents").then(e=>{k(e.agents);const o=e.agents.find(f=>f.available);o&&b(o.type)})},[]),a.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[m]),a.useEffect(()=>{l&&S&&!r&&D()},[l,S,r,D]);const R=async()=>{if(!(!x||!p.trim())){N(!0),i([{role:"user",content:p,timestamp:new Date}]);try{const e=await I.post("/demo/start",{agentType:x,prompt:p.trim()});d(e.sessionId),g("")}catch(e){i(o=>[...o,{role:"agent",content:s("启动失败: {message}",{message:e instanceof Error?e.message:s("未知错误")}),timestamp:new Date}])}finally{N(!1)}}},A=async()=>{if(!l||!h.trim())return;const e=h.trim();i(o=>[...o,{role:"user",content:e,timestamp:new Date}]),n("");try{await I.post(`/demo/${l}/message`,{message:e})}catch(o){i(f=>[...f,{role:"agent",content:s("发送失败: {message}",{message:o instanceof Error?o.message:s("未知错误")}),timestamp:new Date}])}},_=async()=>{if(l)try{await I.post(`/demo/${l}/stop`),i(e=>[...e,{role:"agent",content:`
4
4
  [${s("会话已停止")}]`,timestamp:new Date}]),d(null)}catch(e){console.error("Stop failed:",e)}};return t.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[t.jsx("h1",{className:"text-2xl font-bold",children:s("Agent 交互演示")}),!l&&t.jsxs($,{className:"p-4",children:[t.jsx("h2",{className:"text-lg font-semibold mb-3",children:s("选择 Agent")}),t.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:c.map(e=>t.jsxs(O,{variant:x===e.type?"default":"outline",disabled:!e.available,onClick:()=>b(e.type),children:[e.name,e.available&&e.version&&` (${e.version})`,!e.available&&s(" (不可用)")]},e.type))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&R(),placeholder:s("输入你的问题或任务..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:R,disabled:y||!x||!p.trim(),children:s(y?"启动中...":"开始")})]})]}),t.jsxs($,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex justify-between items-center mb-3",children:[t.jsx("h2",{className:"text-lg font-semibold",children:s("对话")}),l&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-500",children:s(S?r?"已连接":"连接中...":"未连接")}),t.jsx(O,{variant:"outline",size:"sm",onClick:_,children:s("停止")})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?t.jsx("div",{className:"text-gray-400 text-center py-8",children:s("选择 Agent 并输入问题开始对话")}):m.map((e,o)=>t.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[t.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?s("你"):"Agent"}),t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),t.jsx("div",{ref:u})]}),l&&t.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[t.jsx("input",{type:"text",value:h,onChange:e=>n(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&A(),placeholder:s("发送后续消息..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),t.jsx(O,{onClick:A,disabled:!h.trim(),children:s("发送")})]})]})]})}export{B as DemoPage};
@@ -1 +1 @@
1
- import{u as y,a as _,b as A,c as E,r as i,t as m,j as s,S as T,d as I,e as p,f as M,B as g}from"./index-Bd5HU-dB.js";import{S as v}from"./select-CCf5nwYs.js";import{T as O}from"./textarea-BzeEPT1A.js";import{u as k}from"./use-providers-BWgjPVX8.js";import"./chevron-down-DuDzRplH.js";import"./check-DyTLNLlk.js";const L=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],l="__follow_task__";function F(){const{locale:x,setLocale:S,t:e}=y(),{data:r}=_(),{data:f}=k(),{data:o}=A(),a=E(),[h,u]=i.useState(l),[c,d]=i.useState(""),[j,n]=i.useState(!1);i.useEffect(()=>{!r||!o||(u(r.commitMessageProviderId||l),d(r.commitMessagePrompt||o.prompt),n(!1))},[r,o]);const P=[{value:l,label:e("跟随任务")},...(f??[]).filter(t=>t.availability.type!=="NOT_FOUND").map(t=>({value:t.provider.id,label:t.provider.name}))],b=i.useCallback(t=>{u(t);const N=t===l?null:t;a.mutate({commitMessageProviderId:N},{onError:()=>m.error(e("保存失败"))})},[a,e]),C=i.useCallback(()=>{const t=c.trim()||null;a.mutate({commitMessagePrompt:t},{onSuccess:()=>{n(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[c,a,e]);return s.jsxs(T,{children:[s.jsx(I,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(p,{label:e("显示语言"),description:e("界面语言会保存到本地数据库,重启后继续生效。"),align:"center",children:s.jsx(v,{value:x,onChange:t=>S(t),options:L})})}),s.jsx(M,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(p,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(v,{value:h,onChange:b,options:P})}),s.jsx(p,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(O,{value:c,onChange:t=>{d(t.target.value),n(!0)},rows:5,className:"font-mono resize-y"}),j&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{d(r?.commitMessagePrompt||o?.prompt||""),n(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:C,disabled:a.isPending,children:a.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{F as GeneralSettingsPage};
1
+ import{u as y,a as _,b as A,c as E,r as i,t as m,j as s,S as T,d as I,e as p,f as M,B as g}from"./index-DbO4YyUv.js";import{S as v}from"./select-BJfNuuIV.js";import{T as O}from"./textarea-BcVRpxhF.js";import{u as k}from"./use-providers-BOyY0DcV.js";import"./chevron-down-Cur5jANy.js";import"./check-D9lM__p8.js";const L=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],l="__follow_task__";function F(){const{locale:x,setLocale:S,t:e}=y(),{data:r}=_(),{data:f}=k(),{data:o}=A(),a=E(),[h,u]=i.useState(l),[c,d]=i.useState(""),[j,n]=i.useState(!1);i.useEffect(()=>{!r||!o||(u(r.commitMessageProviderId||l),d(r.commitMessagePrompt||o.prompt),n(!1))},[r,o]);const P=[{value:l,label:e("跟随任务")},...(f??[]).filter(t=>t.availability.type!=="NOT_FOUND").map(t=>({value:t.provider.id,label:t.provider.name}))],b=i.useCallback(t=>{u(t);const N=t===l?null:t;a.mutate({commitMessageProviderId:N},{onError:()=>m.error(e("保存失败"))})},[a,e]),C=i.useCallback(()=>{const t=c.trim()||null;a.mutate({commitMessagePrompt:t},{onSuccess:()=>{n(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[c,a,e]);return s.jsxs(T,{children:[s.jsx(I,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(p,{label:e("显示语言"),description:e("界面语言会保存到本地数据库,重启后继续生效。"),align:"center",children:s.jsx(v,{value:x,onChange:t=>S(t),options:L})})}),s.jsx(M,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(p,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(v,{value:h,onChange:b,options:P})}),s.jsx(p,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(O,{value:c,onChange:t=>{d(t.target.value),n(!0)},rows:5,className:"font-mono resize-y"}),j&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{d(r?.commitMessagePrompt||o?.prompt||""),n(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:C,disabled:a.isPending,children:a.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{F as GeneralSettingsPage};
@@ -0,0 +1 @@
1
+ import{h as t,j as o}from"./index-DbO4YyUv.js";const r=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],c=t("at-sign",r);const s=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],i=t("globe",s),l=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M8 1a7 7 0 0 0 0 14V1z",fill:"currentColor"})]}),h=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),o.jsx("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"})]}),x=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})}),d=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M13.5 4.5L6.5 11.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),w=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M5.5 5.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});export{c as A,i as G,h as I,d as a,x as b,w as c,l as d};
@@ -1 +1 @@
1
- import{h as x,i as m,q as o,m as u,u as p,r as g,t as n,j as e,S as a,B as i}from"./index-Bd5HU-dB.js";import{L as f}from"./loader-circle-B4v8mirO.js";import{C as h,T as j}from"./terminal-JXRig8oL.js";import{C as b}from"./check-DyTLNLlk.js";const y=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],N=x("server",y);function C(){return m({queryKey:o.system.mcpConfig,queryFn:()=>u.get("/system/mcp-config")})}function v({mode:s,label:t}){const r=s==="desktop-packaged";return e.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-1 text-[11px] font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:t})}function P(){const{t:s}=p(),{data:t,isLoading:r,isError:l,refetch:d}=C(),c=g.useCallback(async()=>{if(t?.configJson)try{await navigator.clipboard.writeText(t.configJson),n.success(s("MCP 配置已复制"))}catch{n.error(s("复制 MCP 配置失败"))}},[t?.configJson,s]);return r?e.jsx(a,{children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-neutral-500"})})}):l||!t?e.jsxs(a,{children:[e.jsx("h2",{className:"mb-1 text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("div",{className:"mt-5 rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:s("MCP 配置加载失败")}),e.jsx(i,{className:"mt-4",size:"sm",variant:"outline",onClick:()=>{d()},children:s("重试")})]}):e.jsxs(a,{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-neutral-500",children:s("复制下面的 JSON 到支持 MCP 的客户端配置中。桌面打包版使用 App 内置 runtime,不需要全局安装 agent-tower。")})]}),e.jsxs(i,{size:"sm",onClick:c,children:[e.jsx(h,{size:14}),s("复制配置")]})]}),e.jsxs("div",{className:"space-y-3 border-b border-neutral-100 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{mode:t.runtimeMode,label:t.runtimeMode==="desktop-packaged"?s("桌面打包 runtime"):s("工作区 runtime")}),e.jsx("span",{className:"text-[12px] text-neutral-400",children:t.serverName})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(j,{size:12}),"Command"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.command})]}),e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(N,{size:12}),"Entry"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.args[0]??""})]})]})]}),e.jsxs("div",{className:"pt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:"mcpServers JSON"}),t.runtimeMode==="desktop-packaged"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600",children:[e.jsx(b,{size:12}),s("无需全局 CLI")]})]}),e.jsx("textarea",{readOnly:!0,value:t.configJson,rows:14,className:"w-full resize-y rounded-lg border border-neutral-200 bg-neutral-950 px-3 py-3 font-mono text-[12px] leading-relaxed text-neutral-100 outline-none"}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-neutral-400",children:s("当前版本只生成通用 MCP 配置,不会自动修改 Claude、Codex 或其他第三方客户端配置文件。")})]})]})}export{P as McpSettingsPage};
1
+ import{h as x,i as m,q as o,m as u,u as p,r as g,t as n,j as e,S as a,B as i}from"./index-DbO4YyUv.js";import{L as f}from"./loader-circle-B5Lfi46Y.js";import{C as h,T as j}from"./terminal-Bh2qSv0U.js";import{C as b}from"./check-D9lM__p8.js";const y=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],N=x("server",y);function C(){return m({queryKey:o.system.mcpConfig,queryFn:()=>u.get("/system/mcp-config")})}function v({mode:s,label:t}){const r=s==="desktop-packaged";return e.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-1 text-[11px] font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:t})}function P(){const{t:s}=p(),{data:t,isLoading:r,isError:l,refetch:d}=C(),c=g.useCallback(async()=>{if(t?.configJson)try{await navigator.clipboard.writeText(t.configJson),n.success(s("MCP 配置已复制"))}catch{n.error(s("复制 MCP 配置失败"))}},[t?.configJson,s]);return r?e.jsx(a,{children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-neutral-500"})})}):l||!t?e.jsxs(a,{children:[e.jsx("h2",{className:"mb-1 text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("div",{className:"mt-5 rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:s("MCP 配置加载失败")}),e.jsx(i,{className:"mt-4",size:"sm",variant:"outline",onClick:()=>{d()},children:s("重试")})]}):e.jsxs(a,{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-neutral-500",children:s("复制下面的 JSON 到支持 MCP 的客户端配置中。桌面打包版使用 App 内置 runtime,不需要全局安装 agent-tower。")})]}),e.jsxs(i,{size:"sm",onClick:c,children:[e.jsx(h,{size:14}),s("复制配置")]})]}),e.jsxs("div",{className:"space-y-3 border-b border-neutral-100 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{mode:t.runtimeMode,label:t.runtimeMode==="desktop-packaged"?s("桌面打包 runtime"):s("工作区 runtime")}),e.jsx("span",{className:"text-[12px] text-neutral-400",children:t.serverName})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(j,{size:12}),"Command"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.command})]}),e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(N,{size:12}),"Entry"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.args[0]??""})]})]})]}),e.jsxs("div",{className:"pt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:"mcpServers JSON"}),t.runtimeMode==="desktop-packaged"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600",children:[e.jsx(b,{size:12}),s("无需全局 CLI")]})]}),e.jsx("textarea",{readOnly:!0,value:t.configJson,rows:14,className:"w-full resize-y rounded-lg border border-neutral-200 bg-neutral-950 px-3 py-3 font-mono text-[12px] leading-relaxed text-neutral-100 outline-none"}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-neutral-400",children:s("当前版本只生成通用 MCP 配置,不会自动修改 Claude、Codex 或其他第三方客户端配置文件。")})]})]})}export{P as McpSettingsPage};
@@ -1 +1 @@
1
- import{r as i,j as n,g as o}from"./index-Bd5HU-dB.js";function d(r){const t=r.trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);return e.length>=2?`${e[0][0]??""}${e[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function a(r){const t=r.trim();return/^#([0-9a-f]{3,8})$/i.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)}function l(r){const t=r.trim();return t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:image/")||t.startsWith("blob:")}function h(r,t){const e=r?.trim()??"";return!e||a(e)||l(e)?d(t):e.length<=2?e.toUpperCase():e.slice(0,2).toUpperCase()}function p(r){const t=r?.trim()??"";if(!(!t||!a(t)))return{backgroundColor:t,color:"#ffffff"}}function g({name:r,avatar:t,className:e}){const[u,c]=i.useState(null),s=t?.trim()??"",f=!!s&&l(s)&&u!==s,m=i.useMemo(()=>h(s,r),[r,s]);return f?n.jsx("img",{src:s,alt:r,loading:"lazy",onError:()=>c(s),className:o("h-7 w-7 shrink-0 rounded-full border border-neutral-200 bg-white object-cover",e)}):n.jsx("div",{className:o("flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-neutral-100 text-[10px] font-semibold text-neutral-600",e),style:p(s),"aria-label":r,children:m})}export{g as M};
1
+ import{r as i,j as n,g as o}from"./index-DbO4YyUv.js";function d(r){const t=r.trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);return e.length>=2?`${e[0][0]??""}${e[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function a(r){const t=r.trim();return/^#([0-9a-f]{3,8})$/i.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)}function l(r){const t=r.trim();return t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:image/")||t.startsWith("blob:")}function h(r,t){const e=r?.trim()??"";return!e||a(e)||l(e)?d(t):e.length<=2?e.toUpperCase():e.slice(0,2).toUpperCase()}function p(r){const t=r?.trim()??"";if(!(!t||!a(t)))return{backgroundColor:t,color:"#ffffff"}}function g({name:r,avatar:t,className:e}){const[u,c]=i.useState(null),s=t?.trim()??"",f=!!s&&l(s)&&u!==s,m=i.useMemo(()=>h(s,r),[r,s]);return f?n.jsx("img",{src:s,alt:r,loading:"lazy",onError:()=>c(s),className:o("h-7 w-7 shrink-0 rounded-full border border-neutral-200 bg-white object-cover",e)}):n.jsx("div",{className:o("flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-neutral-100 text-[10px] font-semibold text-neutral-600",e),style:p(s),"aria-label":r,children:m})}export{g as M};
@@ -0,0 +1 @@
1
+ import{h as F,i as q,k as E,l as k,q as v,m as h,u as R,r as o,j as e,S as g,O as B,d as L,e as j,P as W,B as z,f as M,N as A}from"./index-DbO4YyUv.js";import{S as K}from"./select-BJfNuuIV.js";import{I as d}from"./input-Dqnd4oTj.js";import{S as O,C as Q}from"./switch-bLlDOWNp.js";import{M as _}from"./message-square-CEefL0sf.js";import{L as D}from"./loader-circle-B5Lfi46Y.js";import{C as H}from"./circle-alert-OKyZ9U2p.js";import"./chevron-down-Cur5jANy.js";import"./check-D9lM__p8.js";const G=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],J=F("link",G);function V(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function X(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function Y(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function le(){const{t}=R(),{data:i,isLoading:N}=V(),l=X(),n=Y(),y=[{value:"none",label:t("关闭")},{value:"feishu",label:t("飞书 Webhook")}],[a,p]=o.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[m,x]=o.useState(!1),[f,r]=o.useState("idle"),u=o.useRef(void 0);if(o.useEffect(()=>{i&&!m&&p({webhookUrl:i.feishuWebhookUrl??"",baseUrl:i.thirdPartyBaseUrl??"",titleTemplate:i.taskInReviewTitleTemplate??"",bodyTemplate:i.taskInReviewBodyTemplate??""})},[i,m]),o.useEffect(()=>(n.isSuccess?(r("success"),u.current=setTimeout(()=>r("idle"),3e3)):n.isError&&(r("error"),u.current=setTimeout(()=>r("idle"),5e3)),()=>clearTimeout(u.current)),[n.isSuccess,n.isError]),N)return e.jsx(g,{children:e.jsx(B,{rows:3})});const T=i?.osNotificationEnabled??!0,b=i?.thirdPartyChannel??"none",c=(s,I)=>{p(P=>({...P,[s]:I})),x(!0)},S=s=>{l.mutate({osNotificationEnabled:s})},C=s=>{l.mutate({thirdPartyChannel:s})},U=()=>{l.mutate({feishuWebhookUrl:a.webhookUrl.trim()||null,thirdPartyBaseUrl:a.baseUrl.trim()||null,taskInReviewTitleTemplate:a.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:a.bodyTemplate.trim()||t('✅ "{taskTitle}" 已完成,等待审查')},{onSuccess:()=>x(!1)})},w=()=>{a.webhookUrl.trim()&&n.mutate({channel:"feishu",webhookUrl:a.webhookUrl.trim(),baseUrl:a.baseUrl.trim()||void 0})};return e.jsxs(g,{children:[e.jsx(L,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:W,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(O,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:_,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(K,{value:b,onChange:s=>C(s),options:y})}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4 sm:pl-11",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-webhook-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Webhook URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"feishu-webhook-url",value:a.webhookUrl,onChange:s=>c("webhookUrl",s.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"min-w-0 flex-1 font-mono"}),e.jsxs(z,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(D,{size:12,className:"mr-1 animate-spin motion-reduce:animate-none"}),t("测试")]})]}),f==="success"&&e.jsxs("div",{role:"status",className:"mt-2 flex items-center gap-1.5 text-xs text-success",children:[e.jsx(Q,{size:12,"aria-hidden":"true"}),t("测试消息发送成功")]}),f==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 flex items-center gap-1.5 text-xs text-destructive",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),t("发送失败,请检查 Webhook 地址")]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-base-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:11,"aria-hidden":"true"}),t("跳转地址")]})}),e.jsx(d,{id:"feishu-base-url",value:a.baseUrl,onChange:s=>c("baseUrl",s.target.value),placeholder:"http://localhost:5173",className:"font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t('通知卡片中的"查看任务"按钮跳转地址前缀')})]})]})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(M,{children:t("通知模板")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("支持变量: {taskTitle}, {taskId}, {projectId}, {projectName}, {status}",{taskTitle:"{taskTitle}",taskId:"{taskId}",projectId:"{projectId}",projectName:"{projectName}",status:"{status}"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-title-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("标题")}),e.jsx(d,{id:"notification-title-template",value:a.titleTemplate,onChange:s=>c("titleTemplate",s.target.value),placeholder:"Agent Tower"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-body-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("内容")}),e.jsx(d,{id:"notification-body-template",value:a.bodyTemplate,onChange:s=>c("bodyTemplate",s.target.value),placeholder:t('✅ "{taskTitle}" 已完成,等待审查')})]})]})]})]}),m&&e.jsx(A,{saving:l.isPending,onSave:U})]})}export{le as NotificationSettingsPage};
@@ -0,0 +1,3 @@
1
+ import{u as T,r as g,j as e,S,d as J,n as M,o as w,B as E,p,g as P}from"./index-DbO4YyUv.js";import{u as U,a as _,b as z,c as B}from"./use-profiles-BIqkQu69.js";import{M as F}from"./modal-CAB_bs-c.js";import{C as G}from"./confirm-dialog-BAnxa2C9.js";import{I as $}from"./input-Dqnd4oTj.js";import{T as R}from"./textarea-BcVRpxhF.js";import{L as H}from"./layers-CfFYGUtI.js";import{C as q}from"./chevron-down-Cur5jANy.js";import{P as K,T as Q}from"./trash-2-8Pu6lwnW.js";import{P as W}from"./pencil-B__GQn9r.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(K,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx(Q,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function ce(){const{t}=T(),{data:a,isLoading:m}=U(),{data:c}=_(),h=z(),j=B(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
2
+
3
+ }`),v("")},D=()=>{if(!(!n||!i.trim()))try{const s=JSON.parse(b);v(""),h.mutate({agentType:n.agentType,variant:i.trim().toUpperCase(),config:s},{onSuccess:()=>r(null)})}catch{v(t("JSON 格式错误"))}},L=(s,l)=>{N({agentType:s,variant:l})},A=()=>{o&&j.mutate({agentType:o.agentType,variant:o.variant},{onSettled:()=>N(null)})},I=(s,l)=>!!c?.executors[s]?.[l];if(m)return e.jsx(S,{children:e.jsx(Z,{})});const C=a?.executors??{};return e.jsxs(S,{children:[e.jsx(J,{title:t("Profile 配置"),description:t("管理 Agent 执行器的配置变体。每个变体定义一组运行参数。"),className:"mb-4"}),e.jsx("div",{className:"space-y-3",children:Object.entries(C).map(([s,l])=>e.jsx(Y,{agentType:s,variants:l,isBuiltIn:d=>I(s,d),onEdit:(d,V)=>k(s,d,V),onNew:()=>O(s),onDelete:d=>L(s,d)},s))}),Object.keys(C).length===0&&e.jsx(M,{icon:H,message:t("暂无 Profile 配置")}),e.jsx(F,{isOpen:!!n,onClose:()=>r(null),title:n?.isNew?t("新增 Variant — {agentType}",{agentType:y[n.agentType]??n.agentType}):t("编辑 {variant}",{variant:n?.variant??""}),action:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outline",onClick:()=>r(null),children:t("取消")}),e.jsx(E,{onClick:D,disabled:h.isPending,children:h.isPending?t("保存中..."):t("保存")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{label:t("Variant 名称"),htmlFor:"profile-variant-name",children:e.jsx($,{id:"profile-variant-name",value:i,onChange:s=>x(s.target.value),disabled:!n?.isNew,placeholder:t("例如: CUSTOM"),className:"font-mono"})}),e.jsxs(w,{label:t("配置 (JSON)"),htmlFor:"profile-variant-json",children:[e.jsx(R,{id:"profile-variant-json",value:b,onChange:s=>{u(s.target.value),v("")},rows:6,className:"resize-none font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:f})]})]})}),e.jsx(G,{isOpen:o!==null,onClose:()=>{j.isPending||N(null)},onConfirm:A,title:t("删除 Profile Variant"),description:o?t('确定删除 "{name}"?此操作不可撤销。',{name:`${y[o.agentType]??o.agentType} / ${o.variant}`}):"",confirmText:t("删除"),cancelText:t("取消"),variant:"danger",isLoading:j.isPending})]})}export{ce as ProfileSettingsPage};