agent-tower 0.7.2-beta.4 → 0.7.2-beta.6

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 (173) hide show
  1. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +12 -8
  2. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
  3. package/dist/runtime/cli-driver.js +15 -9
  4. package/dist/runtime/cli-driver.js.map +1 -1
  5. package/dist/services/__tests__/session-manager.lifecycle.test.js +69 -0
  6. package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
  7. package/dist/services/__tests__/session-manager.team-run.test.js +3 -1
  8. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  9. package/dist/services/__tests__/terminal-manager.test.js +70 -0
  10. package/dist/services/__tests__/terminal-manager.test.js.map +1 -1
  11. package/dist/services/session-manager.d.ts.map +1 -1
  12. package/dist/services/session-manager.js +2 -2
  13. package/dist/services/session-manager.js.map +1 -1
  14. package/dist/services/terminal-manager.d.ts.map +1 -1
  15. package/dist/services/terminal-manager.js +9 -4
  16. package/dist/services/terminal-manager.js.map +1 -1
  17. package/dist/web/assets/AgentDemoPage-D0LQRcXm.js +1 -0
  18. package/dist/web/assets/{AgentEnvironmentSettingsPage-DQjnDr-h.js → AgentEnvironmentSettingsPage-BnWVgvNe.js} +1 -1
  19. package/dist/web/assets/{AgentLogo-I2etsqym.js → AgentLogo-BDyW3ihb.js} +1 -1
  20. package/dist/web/assets/BranchSelect-Dmp5hq0i.js +1 -0
  21. package/dist/web/assets/BrandLogo-YGT4Vlw5.js +1 -0
  22. package/dist/web/assets/{ConversationPage-jEYUuSPT.js → ConversationPage-BhapUYGe.js} +2 -2
  23. package/dist/web/assets/CreateTaskInput-GLF3Oyc1.js +1 -0
  24. package/dist/web/assets/{DemoPage-BkkueMuL.js → DemoPage-BwX2SvcN.js} +1 -1
  25. package/dist/web/assets/{DesignSystemPage-oM16R2Ta.js → DesignSystemPage-j-1-1JtQ.js} +4 -4
  26. package/dist/web/assets/EditableTaskTitle-mHT39coo.js +70 -0
  27. package/dist/web/assets/{ExecutionPermissionSelector-BX5Xx8ta.js → ExecutionPermissionSelector-DeeNd4Kh.js} +1 -1
  28. package/dist/web/assets/{GeneralSettingsPage-B0jFlgDl.js → GeneralSettingsPage-BBe3EXcj.js} +1 -1
  29. package/dist/web/assets/{LoadingPreviewPage-BxjpxLLP.js → LoadingPreviewPage-BxEFnEQh.js} +1 -1
  30. package/dist/web/assets/{McpSettingsPage-BErvd619.js → McpSettingsPage-DDA8yUxu.js} +1 -1
  31. package/dist/web/assets/{MemberAvatar-TVtoxQe8.js → MemberAvatar-CCRbS97s.js} +1 -1
  32. package/dist/web/assets/MobileTaskDetail-BOIFPybn.js +5 -0
  33. package/dist/web/assets/{NotificationSettingsPage-BETMBdj1.js → NotificationSettingsPage-B2kUnE8w.js} +1 -1
  34. package/dist/web/assets/{ProfileSettingsPage-C03ZAft-.js → ProfileSettingsPage-DPZpUoFd.js} +1 -1
  35. package/dist/web/assets/ProjectKanbanPage-DQnwUBFg.js +12 -0
  36. package/dist/web/assets/ProjectSettingsPage-CcXAOYb7.js +2 -0
  37. package/dist/web/assets/{ProviderSettingsPage-CeNQPd74.js → ProviderSettingsPage-BAIRvcAS.js} +2 -2
  38. package/dist/web/assets/{SettingsMasterDetail-B_SI2h_k.js → SettingsMasterDetail-BuxwsR9R.js} +1 -1
  39. package/dist/web/assets/TaskDetail-B3pOSx3f.js +3 -0
  40. package/dist/web/assets/TeamSettingsPage-DoWmzvKu.js +1 -0
  41. package/dist/web/assets/{agent-meta-DOylIs2N.js → agent-meta-MzuGtqxl.js} +1 -1
  42. package/dist/web/assets/arc-Bm_QIbJA.js +1 -0
  43. package/dist/web/assets/{architectureDiagram-3BPJPVTR-DWO_DRgk.js → architectureDiagram-3BPJPVTR-B5EIiXuX.js} +1 -1
  44. package/dist/web/assets/arrow-down-BVePf1ZM.js +1 -0
  45. package/dist/web/assets/{at-sign-BFf8Sz8T.js → at-sign-BE17rU5b.js} +1 -1
  46. package/dist/web/assets/{blockDiagram-GPEHLZMM-CJPYhE52.js → blockDiagram-GPEHLZMM-GFwnvSLM.js} +1 -1
  47. package/dist/web/assets/{c4Diagram-AAUBKEIU-Cx5IvcjB.js → c4Diagram-AAUBKEIU-iJfLTxEa.js} +1 -1
  48. package/dist/web/assets/channel-CYYV7_Oi.js +1 -0
  49. package/dist/web/assets/check-qs0S_9rB.js +1 -0
  50. package/dist/web/assets/{chevron-down-C6Ta4vyM.js → chevron-down-BaQEBzp3.js} +1 -1
  51. package/dist/web/assets/{chevron-up-BwJT7iif.js → chevron-up-D0y6skqr.js} +1 -1
  52. package/dist/web/assets/{chunk-2J33WTMH-D9cBNYgd.js → chunk-2J33WTMH-CDxRPp-8.js} +1 -1
  53. package/dist/web/assets/{chunk-4BX2VUAB-BY8TNt6E.js → chunk-4BX2VUAB-mzPbgyiz.js} +1 -1
  54. package/dist/web/assets/{chunk-55IACEB6-pT-HP-28.js → chunk-55IACEB6-KNAJbQyw.js} +1 -1
  55. package/dist/web/assets/{chunk-727SXJPM-hy95xDLb.js → chunk-727SXJPM-BqGfqkDK.js} +2 -2
  56. package/dist/web/assets/{chunk-AQP2D5EJ-DlUN-icr.js → chunk-AQP2D5EJ-D27ue-H0.js} +1 -1
  57. package/dist/web/assets/{chunk-FMBD7UC4-Dg2iMKZR.js → chunk-FMBD7UC4-DRza-3q8.js} +1 -1
  58. package/dist/web/assets/{chunk-ND2GUHAM-DMzFIsJ-.js → chunk-ND2GUHAM-CUgkviLu.js} +1 -1
  59. package/dist/web/assets/{chunk-QZHKN3VN-C6CgmKuM.js → chunk-QZHKN3VN-BAlOJwZb.js} +1 -1
  60. package/dist/web/assets/{circle-alert-Dm2Pl-rU.js → circle-alert-Cbvy2cMo.js} +1 -1
  61. package/dist/web/assets/classDiagram-4FO5ZUOK-Cl-3ikxt.js +1 -0
  62. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Cl-3ikxt.js +1 -0
  63. package/dist/web/assets/code-block-OCS4YCEC-CO23R1Os.js +2 -0
  64. package/dist/web/assets/{confirm-dialog-DRpyE_qU.js → confirm-dialog-BrgNTypL.js} +1 -1
  65. package/dist/web/assets/{copy-r0aUdsl8.js → copy-DejkmIHZ.js} +1 -1
  66. package/dist/web/assets/{cose-bilkent-S5V4N54A-D-fvmvw-.js → cose-bilkent-S5V4N54A-8TBY7BP_.js} +1 -1
  67. package/dist/web/assets/cssMode-hzDRnxMx.js +1 -0
  68. package/dist/web/assets/{dagre-BM42HDAG-H0bYI1f3.js → dagre-BM42HDAG-CkMzDiim.js} +1 -1
  69. package/dist/web/assets/{diagram-2AECGRRQ-DI568fLp.js → diagram-2AECGRRQ-CAOQJ2N1.js} +1 -1
  70. package/dist/web/assets/{diagram-5GNKFQAL-BLcaBzw2.js → diagram-5GNKFQAL-DKhE0hiI.js} +1 -1
  71. package/dist/web/assets/{diagram-KO2AKTUF-aL1cvl23.js → diagram-KO2AKTUF-DBdkXSpa.js} +1 -1
  72. package/dist/web/assets/{diagram-LMA3HP47-DbOutAfH.js → diagram-LMA3HP47-DRi2t32c.js} +1 -1
  73. package/dist/web/assets/{diagram-OG6HWLK6-D_cWftAX.js → diagram-OG6HWLK6-DtP92tI1.js} +1 -1
  74. package/dist/web/assets/{erDiagram-TEJ5UH35-DRe5V8Dx.js → erDiagram-TEJ5UH35-DWFKXtst.js} +1 -1
  75. package/dist/web/assets/{flowDiagram-I6XJVG4X-B5-vg_Nh.js → flowDiagram-I6XJVG4X-LDE0h4ri.js} +1 -1
  76. package/dist/web/assets/{freemarker2-CXlYb2yX.js → freemarker2-CLksOOZX.js} +2 -2
  77. package/dist/web/assets/{ganttDiagram-6RSMTGT7-B3iBFICN.js → ganttDiagram-6RSMTGT7-DD2RfdyV.js} +1 -1
  78. package/dist/web/assets/gauge-CPlvCZUV.js +1 -0
  79. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CZ9zsKVw.js → gitGraphDiagram-PVQCEYII-DkKrR8ex.js} +1 -1
  80. package/dist/web/assets/{globe-JXfw4MCF.js → globe-CD4g63c9.js} +1 -1
  81. package/dist/web/assets/handlebars-C1M9t0Lo.js +1 -0
  82. package/dist/web/assets/html-DKVKQovh.js +1 -0
  83. package/dist/web/assets/htmlMode-BSWjg5ir.js +1 -0
  84. package/dist/web/assets/index-BnqdwOEH.css +1 -0
  85. package/dist/web/assets/{index-CWbMMO6g.js → index-CMJV-mgF.js} +3 -3
  86. package/dist/web/assets/{index-CWEbo6pZ.js → index-D_QVcsLn.js} +5 -5
  87. package/dist/web/assets/{infoDiagram-5YYISTIA-DQU_sN8x.js → infoDiagram-5YYISTIA-BdPA9Xfi.js} +1 -1
  88. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BVGrNzJa.js → ishikawaDiagram-YF4QCWOH-220u4uiv.js} +1 -1
  89. package/dist/web/assets/javascript-WwrMY2Bg.js +1 -0
  90. package/dist/web/assets/{journeyDiagram-JHISSGLW-DU4Md1Tq.js → journeyDiagram-JHISSGLW-BvE0Y3tZ.js} +1 -1
  91. package/dist/web/assets/{jsonMode-BMSvHUHa.js → jsonMode-Dz0hnnvg.js} +2 -2
  92. package/dist/web/assets/{kanban-definition-UN3LZRKU-DDPgCucq.js → kanban-definition-UN3LZRKU-Q0JH1P6D.js} +1 -1
  93. package/dist/web/assets/{key-round-BHVp7u3Z.js → key-round-DZm1FLLr.js} +1 -1
  94. package/dist/web/assets/{layers-2tjjhM75.js → layers-Dda7MM7a.js} +1 -1
  95. package/dist/web/assets/{linear-D8yLBTVY.js → linear-Dr6SfnSn.js} +1 -1
  96. package/dist/web/assets/{link-CnunXc7X.js → link-BUeSP3T7.js} +1 -1
  97. package/dist/web/assets/liquid-CzGEh0ls.js +1 -0
  98. package/dist/web/assets/{lspLanguageFeatures-BiYvrSP0.js → lspLanguageFeatures-Bbp4PWlJ.js} +1 -1
  99. package/dist/web/assets/mdx-y6S3OMMk.js +1 -0
  100. package/dist/web/assets/{mermaid-NOHMQCX5-9-DTTfp6.js → mermaid-NOHMQCX5-C72362la.js} +60 -61
  101. package/dist/web/assets/{message-square-QM0c6Dcv.js → message-square-CFriSt4D.js} +1 -1
  102. package/dist/web/assets/{mindmap-definition-RKZ34NQL-CCAuuWFZ.js → mindmap-definition-RKZ34NQL-bvDaNfKs.js} +1 -1
  103. package/dist/web/assets/{modal-BRoNvfhw.js → modal-DeigO7aN.js} +1 -1
  104. package/dist/web/assets/{monaco-CrBn9oMJ.js → monaco-BuDK9Fat.js} +3 -3
  105. package/dist/web/assets/{paperclip-CC7nHUQ7.js → paperclip-BOSklTt7.js} +1 -1
  106. package/dist/web/assets/{pencil-DIY0Hu5t.js → pencil-BRQ9W_a-.js} +1 -1
  107. package/dist/web/assets/{pieDiagram-4H26LBE5-CXy_N5QX.js → pieDiagram-4H26LBE5-BQCca9Cq.js} +2 -2
  108. package/dist/web/assets/{play-CIZVXiwM.js → play-Mxkwq69n.js} +1 -1
  109. package/dist/web/assets/python-CMnGKsU9.js +1 -0
  110. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Dt44QsS8.js → quadrantDiagram-W4KKPZXB-BEM2U7Cd.js} +1 -1
  111. package/dist/web/assets/razor-mLurbGgY.js +1 -0
  112. package/dist/web/assets/{requirementDiagram-4Y6WPE33-BL8D7Np0.js → requirementDiagram-4Y6WPE33-CcmFIALZ.js} +1 -1
  113. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-I5nefO3A.js → sankeyDiagram-5OEKKPKP-D9Nrfbqk.js} +1 -1
  114. package/dist/web/assets/{select-BmjoUfrV.js → select-DKS02St6.js} +1 -1
  115. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-lbPrhX8g.js → sequenceDiagram-3UESZ5HK-5udQDi0x.js} +1 -1
  116. package/dist/web/assets/{server-BNBdQGor.js → server-DJaSJ9m1.js} +1 -1
  117. package/dist/web/assets/{stateDiagram-AJRCARHV-Bw3qtv2M.js → stateDiagram-AJRCARHV-D-cF1NGV.js} +1 -1
  118. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-a4ugQnZs.js +1 -0
  119. package/dist/web/assets/status-styles-sQm4KLdp.js +1 -0
  120. package/dist/web/assets/{switch-CEUHI4gI.js → switch-7LWQ_sEx.js} +1 -1
  121. package/dist/web/assets/task-CDYaC_No.js +42 -0
  122. package/dist/web/assets/task-priority-acVgTiil.js +1 -0
  123. package/dist/web/assets/{textarea-CD82lB0Z.js → textarea-Ft9KMoEI.js} +1 -1
  124. package/dist/web/assets/{timeline-definition-PNZ67QCA-Cfg_kgoa.js → timeline-definition-PNZ67QCA-DXS236a-.js} +1 -1
  125. package/dist/web/assets/{trash-2-BF_3L-qk.js → trash-2-Bc-URu8c.js} +1 -1
  126. package/dist/web/assets/{tsMode-DAHSkTAr.js → tsMode-Vr3bndW1.js} +4 -4
  127. package/dist/web/assets/typescript-BfjoaUSn.js +1 -0
  128. package/dist/web/assets/{upload-B2AMXrU-.js → upload-C9Z4jLtv.js} +1 -1
  129. package/dist/web/assets/use-attachments-EypT-7PI.js +2 -0
  130. package/dist/web/assets/{use-profiles-CQ-jIuiI.js → use-profiles-nMPGwy3v.js} +1 -1
  131. package/dist/web/assets/{use-projects-BYUZwQ-q.js → use-projects-DI27nNwl.js} +1 -1
  132. package/dist/web/assets/{use-providers-DdV9gbj1.js → use-providers-DB9ghBPq.js} +1 -1
  133. package/dist/web/assets/use-workspaces-d4n9m9cX.js +1 -0
  134. package/dist/web/assets/{useNormalizedLogs-DdFsf-Z1.js → useNormalizedLogs-DRoPbP0w.js} +1 -1
  135. package/dist/web/assets/useTokenUsage-4qTDa8SY.js +1 -0
  136. package/dist/web/assets/{vennDiagram-CIIHVFJN-CdEP03CK.js → vennDiagram-CIIHVFJN-BzyNrP06.js} +1 -1
  137. package/dist/web/assets/{wardley-L42UT6IY-q_Enplrs.js → wardley-L42UT6IY-BQ4SyU9_.js} +1 -1
  138. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DlL6fsid.js → wardleyDiagram-YWT4CUSO-CcCqmB58.js} +1 -1
  139. package/dist/web/assets/xml-BGVoPR0b.js +1 -0
  140. package/dist/web/assets/{xychartDiagram-2RQKCTM6-B2OGqVKA.js → xychartDiagram-2RQKCTM6-RWm1MtQk.js} +1 -1
  141. package/dist/web/assets/yaml-eFhNavrs.js +1 -0
  142. package/dist/web/index.html +2 -2
  143. package/package.json +1 -1
  144. package/dist/web/assets/AgentDemoPage-Svq9Baa7.js +0 -1
  145. package/dist/web/assets/BranchSelect-Eb5UGWWX.js +0 -1
  146. package/dist/web/assets/BrandLogo-BjC1hcgv.js +0 -1
  147. package/dist/web/assets/CreateTaskInput-B_cRDkVq.js +0 -1
  148. package/dist/web/assets/ProjectKanbanPage-DsPxwoVf.js +0 -86
  149. package/dist/web/assets/ProjectSettingsPage-BwNM6VWs.js +0 -2
  150. package/dist/web/assets/TeamSettingsPage-BfgtMl_n.js +0 -1
  151. package/dist/web/assets/arc-BlZww3MO.js +0 -1
  152. package/dist/web/assets/channel-D9sA6Wxp.js +0 -1
  153. package/dist/web/assets/check-Cm7Vstpm.js +0 -1
  154. package/dist/web/assets/classDiagram-4FO5ZUOK-2e2YVo9r.js +0 -1
  155. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-2e2YVo9r.js +0 -1
  156. package/dist/web/assets/code-block-OCS4YCEC-DizntuP_.js +0 -2
  157. package/dist/web/assets/cssMode-DVorIr82.js +0 -1
  158. package/dist/web/assets/handlebars-BL0prPVZ.js +0 -1
  159. package/dist/web/assets/html-DJWeRkWe.js +0 -1
  160. package/dist/web/assets/htmlMode-D_fekqg9.js +0 -1
  161. package/dist/web/assets/index-uXglTJ2_.css +0 -1
  162. package/dist/web/assets/javascript-CDfuzdfe.js +0 -1
  163. package/dist/web/assets/liquid-DHrNpv6c.js +0 -1
  164. package/dist/web/assets/mdx-CIEpgUOV.js +0 -1
  165. package/dist/web/assets/python-BIs0pClJ.js +0 -1
  166. package/dist/web/assets/razor-JCx8NEwU.js +0 -1
  167. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Xbc4HxDQ.js +0 -1
  168. package/dist/web/assets/task-kalEmHDc.js +0 -42
  169. package/dist/web/assets/task-priority-wLXAgVZZ.js +0 -1
  170. package/dist/web/assets/typescript-CptiLWGr.js +0 -1
  171. package/dist/web/assets/xml-DbPqkgZW.js +0 -1
  172. package/dist/web/assets/yaml-Deyq6Z5-.js +0 -1
  173. /package/dist/web/assets/{ProjectKanbanPage-DcpNTP1B.css → EditableTaskTitle-DcpNTP1B.css} +0 -0
@@ -1 +0,0 @@
1
- import{c as H,j as e,u as te,a3 as se,r as n,p as b,B as N,a8 as ne,a5 as re,a1 as ae}from"./index-CWbMMO6g.js";import{u as le,a as oe,L as ie,T as ce}from"./useNormalizedLogs-DdFsf-Z1.js";import{a as de}from"./mermaid-NOHMQCX5-9-DTTfp6.js";import"./agent-meta-DOylIs2N.js";import{d as xe}from"./use-profiles-CQ-jIuiI.js";import{C as me}from"./chevron-up-BwJT7iif.js";import{C as ue}from"./chevron-down-C6Ta4vyM.js";import{P as he}from"./paperclip-CC7nHUQ7.js";import{A as pe}from"./at-sign-BFf8Sz8T.js";import{G as ge}from"./globe-JXfw4MCF.js";import"./check-Cm7Vstpm.js";const fe=[["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"}]],be=H("hash",fe);const je=[["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"}]],ve=H("send",je),B=({className:s})=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:s,xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),e.jsx("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"})]}),ye=({className:s})=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:s,xmlns:"http://www.w3.org/2000/svg",children:e.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})}),Ne=({className:s})=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:s,xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M13.5 4.5L6.5 11.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),we=!0;function Re(){const{t:s}=te(),{preserveDesktopSearch:U}=se(),[w,V]=n.useState([]),[o,S]=n.useState(""),[x,k]=n.useState("DEFAULT"),[i,A]=n.useState(""),[a,C]=n.useState(null),[F,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),$=n.useRef(null),I=n.useRef(null),u=n.useRef(null),{data:h}=xe(o),M=h?Object.keys(h):["DEFAULT"],_=t=>{S(t),k("DEFAULT")},G=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),O=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:p,isAttached:f,isOutputActive:W,lastExitAt:K,logs:v,entries:q,agentSessionId:L,attach:z,clearLogs:P}=le({sessionId:a||"",sessionStartedAt:F,onExit:G,onError:O}),{todos:R}=oe(q);n.useEffect(()=>{b.get("/demo/agents").then(t=>{V(t.agents);const r=t.agents.find(y=>y.available);r&&S(r.type)})},[]),n.useEffect(()=>{$.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${p} isAttached=${f}`),a&&p&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,p,f,z]);const J=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const y=Math.min(u.current.scrollHeight,210);u.current.style.height=`${y}px`}},Q=async()=>{if(!o||!i.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:o,prompt:i.trim(),variant:x});we&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),C(r.sessionId),D(t),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)}},X=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},Y=()=>{C(null),D(null),c("idle"),A(""),j(""),P()},Z=l==="running",d=a!==null,ee=w.find(t=>t.type===o);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?i.slice(0,50)+(i.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(B,{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(Ne,{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(ye,{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(B,{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:i}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(me,{size:14}):e.jsx(ue,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:ee?.name||o||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})]}),L&&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:[L.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 ${p?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(p?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(N,{variant:"outline",size:"sm",onClick:Y,className:"ml-auto",children:s("新会话")}),e.jsxs(ne,{to:U("/settings/profiles"),className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(re,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:I,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(ie,{children:e.jsx(de,{ref:$,logs:v,isOutputActive:W,lastExitAt:K,scrollElementRef:I})})}):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(N,{variant:o===t.type?"default":"outline",disabled:!t.available,onClick:()=>_(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:M.map(t=>e.jsx("button",{onClick:()=>k(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))}),h&&h[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(h[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:i,onChange:t=>A(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(N,{onClick:Q,disabled:l==="starting"||!o||!i.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(ce,{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:J,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(he,{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(pe,{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(be,{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(ge,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Z&&e.jsxs("button",{onClick:X,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(ae,{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(ve,{size:14})]})]})]})]})})]})}export{Re as AgentDemoPage};
@@ -1 +0,0 @@
1
- import{u as H,r as l,p as d,j as t,l as b,ac as L,V as $,m as T,ad as Z,n as N,o as q,q as o}from"./index-CWbMMO6g.js";import{F as B,G as J}from"./task-priority-wLXAgVZZ.js";import{C as U}from"./agent-meta-DOylIs2N.js";import{C as W}from"./circle-alert-Dm2Pl-rU.js";import{C as P}from"./check-Cm7Vstpm.js";import{P as X,b as ee,B as te,c as se,S as re,M as ae,d as ne,e as ie}from"./task-kalEmHDc.js";import{C as le}from"./chevron-down-C6Ta4vyM.js";function oe(e,a="git"){return a==="directory"||e.isGitRepo?"select-and-browse":"browse"}function we({value:e,onChange:a,validationMode:n="git",placeholder:c}){const{t:j}=H(),[x,A]=l.useState(""),[F,h]=l.useState([]),[k,G]=l.useState(""),[v,Q]=l.useState("/"),[f,K]=l.useState([]),[S,y]=l.useState(!1),[g,C]=l.useState(null),[R,E]=l.useState(e),[D,m]=l.useState(null),[s,w]=l.useState(!1),V=l.useRef(!1);l.useEffect(()=>{E(e)},[e]);const u=l.useCallback(async r=>{y(!0),C(null);try{const i={};r&&(i.path=r);const p=await d.get("/filesystem/browse",{params:i});A(p.current),G(p.parent),Q(p.sep||"/"),h(p.dirs),p.drives&&K(p.drives)}catch(i){C(i instanceof Error?i.message:"Failed to browse directory")}finally{y(!1)}},[]);l.useEffect(()=>{V.current||(V.current=!0,u())},[u]);const I=l.useCallback(async r=>{if(E(r),n==="directory"){a(r),m(null);return}w(!0),m(null);try{const i=await d.get("/filesystem/validate",{params:{path:r}});i.valid&&i.isGitRepo!==!1?(a(r),m(null)):m(i.error??"Not a Git repository")}catch(i){m(i instanceof Error?i.message:"Validation failed")}finally{w(!1)}},[a,n]),M=l.useCallback(r=>{oe(r,n)==="select-and-browse"?(I(r.path),u(r.path)):(u(r.path),m(null))},[I,u,n]),z=v==="\\",_=l.useMemo(()=>x?x.split(/[\\/]/).filter(Boolean):[],[x]),O=l.useCallback(r=>{const i=_.slice(0,r+1);let p;z?(p=i.join("\\"),i.length===1&&/^[A-Za-z]:$/.test(i[0])&&(p+="\\")):p="/"+i.join("/"),u(p),m(null)},[_,u,z]),Y=l.useCallback(r=>{if(r.key==="Enter"&&!r.nativeEvent.isComposing&&r.nativeEvent.keyCode!==229){r.preventDefault();const i=R.trim();i&&(u(i),I(i))}},[R,u,I]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:"text",value:R,onChange:r=>E(r.target.value),onKeyDown:Y,placeholder:c??"e.g., /Users/me/projects/my-repo",className:b("w-full px-3 py-2 border rounded-lg text-sm font-mono focus:outline-none transition-colors pr-8",e?"border-emerald-300 bg-emerald-50/50 focus:border-emerald-400":"border-neutral-200 focus:border-neutral-400")}),e&&(n==="git"?t.jsx(L,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500"}):t.jsx(B,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500"}))]}),t.jsx("p",{className:"text-xs text-neutral-400",children:j(n==="git"?"Browse and select a Git repository, or type a path and press Enter":"Browse and select a directory, or type a path and press Enter")}),f.length>0&&t.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:f.map(r=>t.jsx("button",{onClick:()=>{u(r),m(null)},className:b("px-2 py-0.5 rounded text-xs font-mono transition-colors border",x.toUpperCase().startsWith(r.toUpperCase())?"bg-neutral-900 text-white border-neutral-900":"border-neutral-200 text-neutral-600 hover:bg-neutral-100"),children:r.replace("\\","")},r))}),t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-neutral-500 overflow-x-auto pb-1 scrollbar-none",children:[!z&&t.jsx("button",{onClick:()=>u("/"),className:"hover:text-neutral-900 transition-colors flex-shrink-0 px-1 py-0.5 rounded hover:bg-neutral-100",children:"/"}),_.map((r,i)=>t.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[(z?i>0:!0)&&t.jsx(U,{size:10,className:"text-neutral-300"}),t.jsx("button",{onClick:()=>O(i),className:b("px-1 py-0.5 rounded transition-colors truncate max-w-[120px]",i===_.length-1?"font-medium text-neutral-900":"hover:text-neutral-900 hover:bg-neutral-100"),children:r})]},i))]}),t.jsx("div",{className:"border border-neutral-200 rounded-lg overflow-hidden",children:t.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:S?t.jsxs("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:[t.jsx($,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:"Loading..."})]}):g?t.jsxs("div",{className:"flex items-center justify-center py-8 text-red-500 gap-2",children:[t.jsx(W,{size:14}),t.jsx("span",{className:"text-xs",children:g})]}):F.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8 text-neutral-400",children:[t.jsx("span",{className:"text-xs",children:"No subdirectories"}),n==="directory"&&x&&t.jsxs("button",{type:"button",onClick:()=>I(x),className:b("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",x===e?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-neutral-200 bg-white text-neutral-700 hover:bg-neutral-50"),children:[t.jsx(P,{size:13}),t.jsx("span",{children:j("Select Current")})]})]}):t.jsxs("ul",{className:"divide-y divide-neutral-100",children:[x!==k&&t.jsx("li",{children:t.jsxs("button",{onClick:()=>u(k),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-neutral-50 transition-colors group",children:[t.jsx(B,{size:14,className:"text-neutral-400 flex-shrink-0"}),t.jsx("span",{className:"text-xs text-neutral-500 group-hover:text-neutral-700",children:".."})]})}),F.map(r=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>M(r),className:b("w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors group",r.path===e?"bg-emerald-50":"hover:bg-neutral-50"),children:[r.isGitRepo?t.jsx(L,{size:14,className:"text-emerald-500 flex-shrink-0"}):t.jsx(B,{size:14,className:"text-neutral-400 flex-shrink-0"}),t.jsx("span",{className:b("text-xs truncate",r.path===e?"font-medium text-emerald-700":"text-neutral-700 group-hover:text-neutral-900"),children:r.name}),r.isGitRepo&&t.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] font-medium bg-emerald-100 text-emerald-600 px-1.5 py-0.5 rounded",children:"Git"}),!r.isGitRepo&&n!=="directory"&&t.jsx(U,{size:12,className:"ml-auto text-neutral-300 group-hover:text-neutral-400 flex-shrink-0"}),!r.isGitRepo&&n==="directory"&&t.jsx(P,{size:12,className:b("ml-auto flex-shrink-0",r.path===e?"text-emerald-500":"text-neutral-300 group-hover:text-neutral-400")})]})},r.path))]})})}),s&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-400",children:[t.jsx($,{size:12,className:"animate-spin"}),t.jsx("span",{children:"Validating..."})]}),D&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:[t.jsx(W,{size:12}),t.jsx("span",{children:D})]})]})}const ce=1500,ue=2e3,de=5e3;function je(e,a){return e&&a?.workingDir===e&&a.tab==="changes"?ce:!1}function pe(e,a){return e&&a?.workspaceId===e&&a.tab==="changes"?ue:!1}function ke(e,a){return e&&a?.workingDir===e&&a.tab==="history"?de:!1}function ve(e){return T({queryKey:o.workspaces.projectBranches(e),queryFn:()=>d.get(`/projects/${e}/workspace-branches`),enabled:!!e,staleTime:0})}function Ne(){const e=q();return N({mutationFn:({id:a,...n})=>d.patch(`/workspaces/${a}/base-branch`,n),onSettled:async()=>{await Promise.all([e.invalidateQueries({queryKey:o.workspaces.all}),e.invalidateQueries({queryKey:o.tasks.all}),e.invalidateQueries({queryKey:o.git.all})])}})}function Se(e){return T({queryKey:o.workspaces.list(e),queryFn:()=>d.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Ce(e){const a=q();return N({mutationFn:n=>d.post(`/tasks/${e}/workspaces`,n),onSuccess:()=>{a.invalidateQueries({queryKey:o.workspaces.list(e)}),a.invalidateQueries({queryKey:o.tasks.all})}})}function Ee(){const e=q();return N({mutationFn:({id:a,commitMessage:n,stopActiveServices:c})=>d.post(`/workspaces/${a}/merge`,{commitMessage:n,stopActiveServices:c}),onSuccess:()=>{e.invalidateQueries({queryKey:o.workspaces.all}),e.invalidateQueries({queryKey:o.tasks.all}),e.invalidateQueries({queryKey:o.git.all}),e.invalidateQueries({queryKey:o.workspaceServices.all})},onError:()=>{e.invalidateQueries({queryKey:o.git.all}),e.invalidateQueries({queryKey:o.workspaceServices.all})}})}function qe(){const e=q();return N({mutationFn:a=>d.post(`/workspaces/${a}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:o.workspaces.all}),e.invalidateQueries({queryKey:o.tasks.all})}})}function Ke(){return N({mutationFn:({workspaceId:e,editorType:a})=>d.post(`/workspaces/${e}/open-editor`,{editorType:a})})}function Re(e,a={}){const n=Z(j=>j.visibleContext),c=pe(e,n);return T({queryKey:o.workspaces.gitStatus(e),queryFn:()=>d.get(`/workspaces/${e}/git-status`),enabled:!!e&&(a.enabled??!0),refetchInterval:c,refetchIntervalInBackground:!1,refetchOnWindowFocus:c?"always":!1,refetchOnReconnect:c?"always":!1})}function De(){const e=q();return N({mutationFn:a=>d.post(`/workspaces/${a}/rebase`),onSuccess:(a,n)=>{e.invalidateQueries({queryKey:o.workspaces.gitStatus(n)}),e.invalidateQueries({queryKey:o.git.all})},onError:(a,n)=>{e.invalidateQueries({queryKey:o.workspaces.gitStatus(n)}),e.invalidateQueries({queryKey:o.git.all})}})}function Ie(){const e=q();return N({mutationFn:a=>d.post(`/workspaces/${a}/abort-operation`),onSuccess:(a,n)=>{e.invalidateQueries({queryKey:o.workspaces.gitStatus(n)}),e.invalidateQueries({queryKey:o.git.all})}})}function Fe({id:e,label:a,value:n,branches:c,disabled:j,isRefreshing:x,onChange:A,onOpen:F}){const{t:h}=H(),k=l.useId(),G=l.useRef(null),[v,Q]=l.useState(!1),[f,K]=l.useState(""),[S,y]=l.useState(0),g=c.filter(s=>s.toLowerCase().includes(f.trim().toLowerCase())),C=g[S],R=c.includes(n),E=s=>{Q(s),s&&(K(""),y(Math.max(0,c.indexOf(n))),F())},D=s=>{A(s),Q(!1)};l.useEffect(()=>{v&&G.current?.querySelector("[data-highlighted]")?.scrollIntoView?.({block:"nearest"})},[v,S,f]);const m=s=>{s.nativeEvent.isComposing||(s.key==="ArrowDown"||s.key==="ArrowUp"?(s.preventDefault(),y(w=>Math.max(0,Math.min(g.length-1,w+(s.key==="ArrowDown"?1:-1))))):!f&&(s.key==="Home"||s.key==="End")?(s.preventDefault(),y(s.key==="Home"?0:Math.max(0,g.length-1))):s.key==="Enter"&&C&&(s.preventDefault(),D(C)))};return t.jsxs(X,{open:v,onOpenChange:E,children:[t.jsx(ee,{asChild:!0,children:t.jsxs(te,{id:e,"aria-label":a,"aria-haspopup":"listbox",disabled:j,size:"lg",title:n,className:"w-full min-w-0 justify-between border border-input px-3 font-normal shadow-none ring-0 hover:border-ring/50 hover:bg-background focus-visible:border-ring focus-visible:ring-0 data-[state=open]:border-ring",onKeyDown:s=>{!v&&(s.key==="ArrowDown"||s.key==="ArrowUp")&&(s.preventDefault(),E(!0))},children:[t.jsx(J,{className:"size-3.5 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-left",children:[n,!R&&` (${h("Unavailable")})`]}),t.jsx(le,{className:b("size-3.5 text-muted-foreground transition-transform",v&&"rotate-180")})]})}),t.jsxs(se,{"aria-label":a,className:"z-[70] flex max-h-[min(24rem,var(--radix-popover-content-available-height))] w-(--radix-popover-trigger-width) max-w-[calc(100vw-1rem)] flex-col overflow-hidden p-1",onKeyDown:s=>{s.key==="Escape"&&s.stopPropagation()},onEscapeKeyDown:s=>{s.stopPropagation(),f&&(s.preventDefault(),K(""),y(0))},children:[t.jsx("div",{className:"shrink-0 p-1",children:t.jsx(re,{"aria-label":h("Search branches"),placeholder:h("Search branches"),role:"combobox","aria-expanded":!0,"aria-autocomplete":"list","aria-controls":k,"aria-activedescendant":C?`${k}-${S}`:void 0,value:f,onValueChange:s=>{K(s),y(0)},onKeyDown:m})}),t.jsxs("div",{ref:G,id:k,role:"listbox","aria-label":a,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[g.map((s,w)=>t.jsxs("button",{id:`${k}-${w}`,type:"button",role:"option","aria-selected":s===n,"data-highlighted":w===S?"":void 0,tabIndex:-1,title:s,onPointerMove:()=>y(w),onClick:()=>D(s),className:b(ie,ne,s===n&&"font-medium text-foreground"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:s}),s===n&&t.jsx("span",{className:ae,children:t.jsx(P,{className:"size-3.5"})})]},s)),g.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:h("No matching branches")})]}),t.jsxs("div",{role:"status",className:"flex shrink-0 items-center gap-1.5 border-t border-border/60 px-2 pt-2 pb-1 text-[11px] tabular-nums text-muted-foreground",children:[x&&t.jsx($,{className:"size-3 animate-spin","aria-label":h("Refreshing branches")}),f.trim()?h("{shown} of {total} local branches",{shown:g.length,total:c.length}):h("{count} local branches",{count:c.length})]})]})]})}export{Fe as B,we as F,Se as a,Ne as b,Re as c,De as d,Ee as e,Ie as f,je as g,ke as h,Ce as i,Ke as j,qe as k,ve as u};
@@ -1 +0,0 @@
1
- import{c as a,j as o}from"./index-CWbMMO6g.js";const t=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],r=a("gauge",t);const n=[["path",{d:"M5 12h14",key:"1ays0h"}]],u=a("minus",n);const s=[["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"}]],h=a("square-pen",s),c="/assets/agent-tower-lockup-DPAcheCt.png";function i({className:e="h-6 w-auto max-[359px]:h-[22px]"}){return o.jsx("img",{src:c,alt:"Agent Tower",className:`block shrink-0 select-none object-contain ${e}`})}export{i as B,r as G,u as M,h as S};
@@ -1 +0,0 @@
1
- import{c as de,o as ve,n as ke,q as D,p as me,t as kt,a7 as Ct,m as ot,r as a,_ as St,$ as ie,u as ue,j as e,V as be,l as w,ai as Xe,a3 as Tt,E as Et,F as Mt,a8 as Ze,X as It,D as Rt,aj as At,ak as Lt}from"./index-CWbMMO6g.js";import{S as Je,R as ce,A as Ne,W as O,T as et}from"./agent-meta-DOylIs2N.js";import{T as Pe,u as Ot,A as Pt}from"./mermaid-NOHMQCX5-9-DTTfp6.js";import{G as _t,M as Dt}from"./BrandLogo-BjC1hcgv.js";import{g as zt,a as $t,l as _e}from"./ExecutionPermissionSelector-BX5Xx8ta.js";import{A as ge}from"./AgentLogo-I2etsqym.js";import{C as le}from"./chevron-down-C6Ta4vyM.js";import{C as ee}from"./check-Cm7Vstpm.js";import{d as Ft}from"./use-projects-BYUZwQ-q.js";import{M as tt}from"./MemberAvatar-TVtoxQe8.js";import{u as qt}from"./use-providers-DdV9gbj1.js";import{P as Gt}from"./trash-2-BF_3L-qk.js";import{g as at,T as Ut,a as Wt,F as Bt,G as Kt}from"./task-priority-wLXAgVZZ.js";import{P as Ht}from"./paperclip-CC7nHUQ7.js";const Qt=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Vt=de("chevrons-down",Qt);const Yt=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Xt=de("chevrons-up",Yt);const Zt=[["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"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Jt=de("shield-alert",Zt);const es=[["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"}]],ts=de("shield",es);const ss=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]],ns=de("signal-high",ss);const rs=[["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"}]],os=de("zap",rs);function it(t){const s=ve(),r=ot({queryKey:D.sessions.runtime(t),queryFn:()=>me.get(`/sessions/${t}/runtime`),enabled:!!t});return a.useEffect(()=>{if(!t)return;const o=St.connect(),c=g=>{g.sessionId===t&&s.invalidateQueries({queryKey:D.sessions.runtime(t)})},l=g=>{g.sessionId===t&&s.setQueryData(D.sessions.runtime(t),g.state)},f=()=>{s.invalidateQueries({queryKey:D.sessions.runtime(t)})};return o.on(ie.SESSION_PERMISSION_REQUESTED,c),o.on(ie.SESSION_PERMISSION_INVALIDATED,c),o.on(ie.SESSION_RUNTIME_STATE_CHANGED,l),o.on("connect",f),()=>{o.off(ie.SESSION_PERMISSION_REQUESTED,c),o.off(ie.SESSION_PERMISSION_INVALIDATED,c),o.off(ie.SESSION_RUNTIME_STATE_CHANGED,l),o.off("connect",f)}},[t,s]),r}function as(t){return t==="RUNNING"||t==="AWAITING_PERMISSION"||t==="CANCELLING"}function is(t){return t===Je.RUNNING||t===Je.PENDING}function Xs(t,s){const{data:r}=it(t);return{runtimeState:r,isActive:is(s)||as(r?.turnState),isCancelling:r?.turnState==="CANCELLING"}}function cs(){const t=ve();return ke({mutationFn:({sessionId:s,requestId:r,optionId:o})=>me.post(`/sessions/${s}/permissions/${r}/resolve`,{optionId:o}),onSettled:(s,r,o)=>{t.invalidateQueries({queryKey:D.sessions.runtime(o.sessionId)})}})}function Zs(){const t=ve();return ke({mutationFn:s=>me.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{t.invalidateQueries({queryKey:D.sessions.detail(r)}),t.invalidateQueries({queryKey:D.tasks.all})}})}const ls=45e3;function Js(){const t=ve();return ke({mutationFn:async s=>{try{return await me.post(`/sessions/${s}/stop`,void 0,{signal:AbortSignal.timeout(ls)})}catch(r){throw r instanceof DOMException&&r.name==="TimeoutError"?new Error("Stop request timed out before the server answered. The session may still be stopping; refresh the status and retry."):r}},onError:s=>{kt.error(Ct("Failed to stop session. Refreshing status; check it and try again."),{description:s instanceof Error?s.message:void 0})},onSettled:(s,r,o)=>{t.setQueryData(D.sessions.runtime(o),c=>c?.turnState==="CANCELLING"?{...c,turnState:"IDLE"}:c),Promise.allSettled([t.invalidateQueries({queryKey:D.sessions.detail(o)}),t.invalidateQueries({queryKey:D.sessions.runtime(o)}),t.invalidateQueries({queryKey:D.workspaces.all}),t.invalidateQueries({queryKey:D.tasks.all})])}})}function en(){const t=ve();return ke({mutationFn:({id:s,message:r,providerId:o})=>me.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{t.invalidateQueries({queryKey:D.workspaces.all}),t.invalidateQueries({queryKey:D.tasks.all})}})}function tn({sessionId:t,compact:s=!1}){const{t:r}=ue(),{data:o}=it(t),c=cs(),l=o?.pendingPermissions[0],f=l?.requestId,g=c.reset;return a.useEffect(()=>{g()},[f,g]),l?e.jsx("div",{className:w("mb-2 border-l-2 border-warning bg-warning/5 px-3 py-2.5",s&&"px-2.5 py-2"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(Jt,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:r("Permission required")}),e.jsx("div",{className:"mt-0.5 break-words text-xs text-muted-foreground",children:l.toolSummary||l.toolName||r("The agent needs approval to continue.")}),l.actionDetails?e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all text-xs",children:l.actionDetails}):null,e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:l.options.map(p=>e.jsxs("button",{type:"button",disabled:c.isPending,onClick:()=>c.mutate({sessionId:t,requestId:l.requestId,optionId:p.optionId}),className:w("inline-flex min-h-8 items-center gap-1.5 border px-3 text-xs font-medium transition-colors disabled:opacity-50",p.kind.startsWith("reject")?"border-destructive/30 text-destructive hover:bg-destructive/10":"border-border bg-background text-foreground hover:bg-muted"),children:[c.isPending&&c.variables?.requestId===l.requestId&&c.variables.optionId===p.optionId?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):null,r(p.name)]},p.optionId))}),c.error?e.jsx("div",{className:"mt-1.5 text-xs text-destructive",role:"alert",children:c.error.message}):null]})]})}):null}function we(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function ds(t){return t>=.9?"text-red-500":t>=.7?"text-amber-500":"text-neutral-400"}function sn({usage:t,tooltipSide:s="top"}){const{t:r}=ue();if(!t)return null;const o=t.modelContextWindow,c=o?t.totalTokens/o:0,l=o?Math.min(Math.round(c*100),100):null,f=o?ds(c):"text-neutral-400",g=o?e.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:we(t.totalTokens),max:we(o)})}):e.jsx("span",{children:r("已使用: {used} tokens",{used:we(t.totalTokens)})});return e.jsx(Pe,{content:g,side:s,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(_t,{size:14,className:f}),e.jsxs("span",{className:`tabular-nums ${f}`,children:[we(t.totalTokens),l!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",l,"%"]})]})]})})}const ms={damping:.7,stiffness:.05,mass:1.25},us=70,ps=1e3/60,fs=350;let Ce=!1;globalThis.document?.addEventListener("mousedown",()=>{Ce=!0});globalThis.document?.addEventListener("mouseup",()=>{Ce=!1});globalThis.document?.addEventListener("click",()=>{Ce=!1});const nn=(t={})=>{const[s,r]=a.useState(!1),[o,c]=a.useState(t.initial!==!1),[l,f]=a.useState(!1),g=a.useRef(null);g.current=t;const p=a.useCallback(()=>{if(!Ce)return!1;const h=window.getSelection();if(!h||!h.rangeCount)return!1;const v=h.getRangeAt(0);return v.commonAncestorContainer.contains(x.current)||x.current?.contains(v.commonAncestorContainer)},[]),b=a.useCallback(h=>{n.isAtBottom=h,c(h)},[]),N=a.useCallback(h=>{n.escapedFromLock=h,r(h)},[]),n=a.useMemo(()=>{let h;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(v){x.current&&(x.current.scrollTop=v,n.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){return!x.current||!R.current?0:x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!R.current)return 0;const{targetScrollTop:v}=this;if(!t.targetScrollTop)return v;if(h?.targetScrollTop===v)return h.calculatedScrollTop;const y=Math.max(Math.min(t.targetScrollTop(v,{scrollElement:x.current,contentElement:R.current}),v),0);return h={targetScrollTop:v,calculatedScrollTop:y},requestAnimationFrame(()=>{h=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=us}}},[]),k=a.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||b(!0);const v=Date.now()+(Number(h.wait)||0),y=Oe(g.current,h.animation),{ignoreEscapes:I=!1}=h;let S,z=n.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{S=Date.now()}):S=v+(h.duration??0);const T=async()=>{const q=new Promise(requestAnimationFrame).then(()=>{if(!n.isAtBottom)return n.animation=void 0,!1;const{scrollTop:$}=n,W=performance.now(),te=(W-(n.lastTick??W))/ps;if(n.animation||(n.animation={behavior:y,promise:q,ignoreEscapes:I}),n.animation.behavior===y&&(n.lastTick=W),p()||v>Date.now())return T();if($<Math.min(z,n.calculatedTargetScrollTop)){if(n.animation?.behavior===y){if(y==="instant")return n.scrollTop=n.calculatedTargetScrollTop,T();n.velocity=(y.damping*n.velocity+y.stiffness*n.scrollDifference)/y.mass,n.accumulated+=n.velocity*te,n.scrollTop+=n.accumulated,n.scrollTop!==$&&(n.accumulated=0)}return T()}return S>Date.now()?(z=n.calculatedTargetScrollTop,T()):(n.animation=void 0,n.scrollTop<n.calculatedTargetScrollTop?k({animation:Oe(g.current,g.current.resize),ignoreEscapes:I,duration:Math.max(0,S-Date.now())||void 0}):n.isAtBottom)});return q.then($=>(requestAnimationFrame(()=>{n.animation||(n.lastTick=void 0,n.velocity=0)}),$))};return h.wait!==!0&&(n.animation=void 0),n.animation?.behavior===y?n.animation.promise:T()},[b,p,n]),d=a.useCallback(()=>{N(!0),b(!1)},[N,b]),u=a.useCallback(({target:h})=>{if(h!==x.current)return;const{scrollTop:v,ignoreScrollToTop:y}=n;let{lastScrollTop:I=v}=n;n.lastScrollTop=v,n.ignoreScrollToTop=void 0,y&&y>v&&(I=y),f(n.isNearBottom),setTimeout(()=>{if(n.resizeDifference||v===y)return;if(p()){N(!0),b(!1);return}const S=v>I,z=v<I;if(n.animation?.ignoreEscapes){n.scrollTop=I;return}z&&(N(!0),b(!1)),S&&N(!1),!n.escapedFromLock&&n.isNearBottom&&b(!0)},1)},[N,b,p,n]),C=a.useCallback(({target:h,deltaY:v})=>{let y=h;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===x.current&&v<0&&x.current.scrollHeight>x.current.clientHeight&&!n.animation?.ignoreEscapes&&(N(!0),b(!1))},[N,b,n]),x=st(h=>{x.current?.removeEventListener("scroll",u),x.current?.removeEventListener("wheel",C),h?.addEventListener("scroll",u,{passive:!0}),h?.addEventListener("wheel",C,{passive:!0})},[]),R=st(h=>{if(n.resizeObserver?.disconnect(),!h)return;let v;n.resizeObserver=new ResizeObserver(([y])=>{const{height:I}=y.contentRect,S=I-(v??I);if(n.resizeDifference=S,n.scrollTop>n.targetScrollTop&&(n.scrollTop=n.targetScrollTop),f(n.isNearBottom),S>=0){const z=Oe(g.current,v?g.current.resize:g.current.initial);k({animation:z,wait:!0,preserveScrollPosition:!0,duration:z==="instant"?void 0:fs})}else n.isNearBottom&&(N(!1),b(!0));v=I,requestAnimationFrame(()=>{setTimeout(()=>{n.resizeDifference===S&&(n.resizeDifference=0)},1)})}),n.resizeObserver?.observe(h)},[]);return{contentRef:R,scrollRef:x,scrollToBottom:k,stopScroll:d,isAtBottom:o||l,isNearBottom:l,escapedFromLock:s,state:n}};function st(t,s){const r=a.useCallback(o=>(r.current=o,t(o)),s);return r}const Le=new Map;function Oe(...t){const s={...ms};let r=!1;for(const c of t){if(c==="instant"){r=!0;continue}typeof c=="object"&&(r=!1,s.damping=c.damping??s.damping,s.stiffness=c.stiffness??s.stiffness,s.mass=c.mass??s.mass)}const o=JSON.stringify(s);return Le.has(o)||Le.set(o,Object.freeze(s)),r?"instant":Le.get(o)}function rn({providers:t,currentProviderId:s,agentType:r,runtimeType:o,onSelect:c}){const{t:l}=ue(),[f,g]=a.useState(!1),p=a.useRef(null),b=o===ce.ACP?ce.ACP:ce.CLI,N=t.filter(u=>String(u.provider.agentType)===r&&(u.provider.runtimeType===ce.ACP?ce.ACP:ce.CLI)===b),n=t.find(u=>u.provider.id===s),k=zt(t,s),d=k?e.jsx("span",{role:"alert",className:"block break-words text-[11px] leading-snug text-destructive",children:l(k)}):null;return a.useEffect(()=>{function u(C){p.current&&!p.current.contains(C.target)&&g(!1)}if(f)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[f]),N.length===0||N.length===1&&N[0].provider.id===s?e.jsxs("div",{className:"min-w-[112px] max-w-[min(46vw,240px)] px-2 py-1.5 text-xs text-neutral-400 select-none cursor-default",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ge,{agentType:n?.provider.agentType??r,className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?Xe(n.provider.name,12):r})]}),d]}):e.jsxs("div",{className:"relative min-w-[112px] max-w-[min(46vw,240px)]",ref:p,children:[e.jsxs("button",{type:"button",onClick:()=>g(!f),className:"flex max-w-full items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${n?.provider.name??r} (click to change)`,children:[e.jsx(ge,{agentType:n?.provider.agentType??r,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?Xe(n.provider.name,12):r}),e.jsx(le,{size:12,className:`shrink-0 transition-transform ${f?"rotate-180":""}`})]}),d?e.jsx("div",{className:"px-2",children:d}):null,f&&e.jsxs("div",{className:"absolute bottom-full right-0 z-50 mb-1 max-h-[min(60vh,320px)] min-w-[160px] max-w-[min(80vw,320px)] overflow-y-auto rounded-lg border border-neutral-200 bg-white py-1 shadow-lg",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:l("切换渠道")}),N.map(u=>{const C=$t(u),x=u.provider.executionPermission?l("Required permission: {mode}",{mode:l(_e[u.provider.executionPermission])}):void 0;return e.jsx("div",{tabIndex:C?0:void 0,role:C?"group":void 0,"aria-label":C?[u.provider.name,x,l(C)].filter(Boolean).join(": "):void 0,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:e.jsxs("button",{type:"button",disabled:!!C,onClick:()=>{c(u.provider.id),g(!1)},className:`disabled:cursor-not-allowed w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${u.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ge,{agentType:u.provider.agentType,className:"size-4"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate max-w-[200px]",children:u.provider.name}),u.provider.executionPermission?e.jsx("span",{className:"block text-xs",children:l(_e[u.provider.executionPermission])}):null,C?e.jsx("span",{className:"block max-w-[240px] break-words text-xs",children:l(C)}):null]}),u.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:l("(默认)")})]}),u.provider.id===s&&e.jsx(ee,{size:14,className:"shrink-0"})]})},u.provider.id)})]})]})}function on(t,s){return a.useMemo(()=>{for(let r=t.length-1;r>=0;r--){const o=t[r];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[t,s])}function nt({iconName:t,className:s}){switch(t){case"chevrons-up":return e.jsx(Xt,{className:s,"aria-hidden":"true"});case"signal-high":return e.jsx(ns,{className:s,"aria-hidden":"true"});case"chevrons-down":return e.jsx(Vt,{className:s,"aria-hidden":"true"});default:return e.jsx(Dt,{className:s,"aria-hidden":"true"})}}function an({priority:t,className:s}){const r=at(t);return e.jsx("span",{className:w("inline-flex shrink-0 items-center rounded px-1.5 py-0.5 text-[10px] font-semibold leading-none",r.className,s),title:`${r.code} · ${r.label}`,children:r.code})}function xs({value:t,onChange:s,disabled:r=!1,compact:o=!1}){const{t:c}=ue(),[l,f]=a.useState(!1),g=a.useRef(null),p=at(t);return a.useEffect(()=>{if(!l)return;const b=N=>{g.current&&!g.current.contains(N.target)&&f(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),e.jsxs("div",{className:"relative",ref:g,children:[e.jsxs("button",{type:"button",disabled:r||!s,onClick:()=>f(b=>!b),"aria-haspopup":"listbox","aria-expanded":l,"aria-label":c("Task priority"),className:w("inline-flex items-center gap-1.5 rounded-md text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-50",o?"px-1.5 py-1":"px-2 py-1.5",p.className),children:[e.jsx(nt,{iconName:p.iconName,className:"size-3.5"}),e.jsx("span",{children:c(p.label)}),s?e.jsx(le,{className:w("size-3 transition-transform",l&&"rotate-180"),"aria-hidden":"true"}):null]}),l&&e.jsx("div",{className:"absolute right-0 top-full z-50 mt-1.5 w-36 rounded-lg border border-border bg-popover p-1 shadow-lg",role:"listbox","aria-label":c("Task priority"),children:Ut.map(b=>{const N=b.value===p.value;return e.jsxs("button",{type:"button",role:"option","aria-selected":N,onClick:()=>{s?.(b.value),f(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-xs text-foreground/80 transition-colors hover:bg-accent",children:[e.jsx("span",{className:w("inline-flex size-5 items-center justify-center rounded",b.className),children:e.jsx(nt,{iconName:b.iconName,className:"size-3.5"})}),e.jsxs("span",{className:"flex-1",children:[b.code," · ",c(b.label)]}),N?e.jsx(ee,{className:"size-3.5 text-foreground","aria-hidden":"true"}):null]},b.value)})})]})}function rt(t,s,r,o){if(r.filter(f=>f===o).length<=1)return t;const l=r.slice(0,s+1).filter(f=>f===o).length;return`${t} #${l}`}function hs(t){return Object.values(t).filter(Boolean).length}function gs({mode:t,setMode:s,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:c,setSelectedMemberPresetIds:l,disabled:f=!1,compact:g=!1}){const{t:p}=ue(),{preserveDesktopSearch:b}=Tt(),[N,n]=a.useState(!1),{data:k}=qt(),{data:d,isError:u,isFetching:C,isLoading:x,refetch:R}=Et(),{data:h,isError:v,isFetching:y,isLoading:I,refetch:S}=Mt(),z=a.useMemo(()=>new Map((k??[]).map(({provider:m,availability:j})=>[m.id,m.name+(j.type==="NOT_FOUND"?p(" (不可用)"):"")])),[k,p]),T=a.useMemo(()=>new Map((d??[]).map(m=>[m.id,m])),[d]),q=a.useMemo(()=>new Map((h??[]).map(m=>[m.id,m])),[h]),$=a.useMemo(()=>c.map(m=>T.get(m)).filter(m=>!!m),[T,c]);a.useEffect(()=>{d!==void 0&&l(m=>{const j=m.filter(P=>T.has(P));return j.length===m.length&&j.every((P,U)=>P===m[U])?m:j})},[d,T,l]),a.useEffect(()=>{h!==void 0&&o(m=>!m||q.has(m)?m:null)},[o,q,h]);const W=m=>{f||o(j=>j===m?null:m)},te=m=>{f||l(j=>[...j,m])},Q=m=>{f||l(j=>j.filter((P,U)=>U!==m))},se=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:p("团队模板")}),v?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:p("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{S()},disabled:f||y,className:"ml-2 underline hover:no-underline",children:p("重试")})]}):I?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(be,{size:12,className:"animate-spin"}),p("加载中...")]}):(h??[]).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:[p("当前没有团队模板"),e.jsx(Ze,{to:b("/settings/team"),className:"ml-1.5 text-info hover:underline",children:p("去创建")})]}):e.jsx("div",{className:w("space-y-1.5",g&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(h??[]).map(m=>{const j=m.id===r,P=m.members?.length??0,U=m.members?.map(Y=>Y.memberPresetId)??[],V=m.members?.slice(0,3).map((Y,oe)=>rt(Y.memberPreset?.name??Y.memberPresetId,oe,U,Y.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>W(m.id),disabled:f,className:w("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",j?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:w("text-xs truncate",j?"font-medium text-foreground":"text-foreground"),children:m.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[P,p("人")]})]}),V&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:V})]}),j&&e.jsx(ee,{size:13,className:"shrink-0 text-foreground"})]})},m.id)})})]}),B=$.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.map((m,j)=>{const P=rt(m.name,j,c,m.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(tt,{name:m.name,avatar:m.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:P}),e.jsx("button",{type:"button",onClick:()=>Q(j),disabled:f,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(It,{size:9})})]},`${m.id}-${j}`)})}),re=u?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:p("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{R()},disabled:f||C,className:"ml-2 underline hover:no-underline",children:p("重试")})]}):x?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(be,{size:12,className:"animate-spin"}),p("加载中...")]}):(d??[]).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:[p("当前没有成员预设"),e.jsx(Ze,{to:b("/settings/team"),className:"ml-1.5 text-info hover:underline",children:p("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(d??[]).map(m=>{const j=c.filter(V=>V===m.id).length,P=z.get(m.providerId)??m.providerId,U=hs(m.capabilities);return e.jsxs("button",{type:"button",onClick:()=>te(m.id),disabled:f,className:w("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(tt,{name:m.name,avatar:m.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:m.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[P," · ",U,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[j>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",j]}),e.jsx(Gt,{size:12,className:"text-muted-foreground"})]})]},m.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}),pe=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:p("执行模式")}),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&&s("AUTO"),disabled:f,className:w("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(os,{size:11}),p("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!f&&s("CONFIRM"),disabled:f,className:w("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ts,{size:11}),p("确认模式")]})]})]});return g?e.jsxs("div",{className:"space-y-3",children:[pe,se,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&n(m=>!m),disabled:f,"aria-expanded":N,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(le,{size:12,className:w("transition-transform",N?"":"-rotate-90")}),p("追加独立成员"),K]}),N&&e.jsxs("div",{className:"mt-2",children:[B,re]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[pe,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[se,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:p("追加成员")}),K]}),B,re]})]})]})}function bs({commands:t,selectedIndex:s,query:r,hasCatalog:o,title:c="Slash Commands",queryPrefix:l="/",emptyCatalogMessage:f="No slash commands catalog for this agent yet.",emptyQueryMessage:g,insertionHint:p="Enter / Tab to insert",compact:b=!1,onSelect:N}){const n=b?"px-1.5 pb-1.5":"px-2 pb-2",k=b?"px-2 py-1.5":"px-2.5 py-2",d=b?"max-h-36":"max-h-48";return e.jsxs("div",{className:b?"pt-1.5":"pt-2",children:[e.jsxs("div",{className:`mb-1 flex items-center justify-between ${b?"px-2 pt-0.5":"px-3 pt-1"}`,children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:c}),e.jsx("span",{className:"text-[10px] text-neutral-400",children:p})]}),t.length===0?e.jsx("div",{className:`${b?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?g??`No matches for ${l}${r}`:f}):e.jsx("div",{className:`${n} ${d} overflow-y-auto`,children:t.map((u,C)=>e.jsxs("button",{type:"button",onMouseDown:x=>x.preventDefault(),onClick:()=>N(u),className:`w-full rounded-lg border text-left transition-colors ${C===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${k}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:u.command}),u.kind&&u.kind!=="builtin"?e.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:u.scope?`${u.scope} ${u.kind}`:u.kind}):null]}),e.jsx("div",{className:`${b?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:u.description})]},u.command))})]})}const J=12,je=8;function vs({open:t,anchorRef:s,commands:r,selectedIndex:o,query:c,hasCatalog:l,title:f,queryPrefix:g,emptyCatalogMessage:p,emptyQueryMessage:b,insertionHint:N,compact:n=!1,onSelect:k}){const d=a.useRef(null),[u,C]=a.useState(null);return a.useLayoutEffect(()=>{if(!t){C(null);return}const x=s.current;if(!x)return;let R=0;const h=()=>{const I=s.current;if(!I)return;const S=I.getBoundingClientRect(),z=window.innerWidth,T=window.innerHeight,q=n?260:320,$=n?z-J*2:560,W=Math.min(Math.max(S.width,q),Math.max(q,$)),te=Math.min(Math.max(J,S.left),Math.max(J,z-J-W)),Q=T-S.bottom-je-J,se=S.top-je-J,B=d.current?.offsetHeight??(n?220:280),re=n?240:320,K=Q<180&&se>Q,m=Math.max(120,Math.min(re,K?se:Q)),j=K?Math.max(J,S.top-je-Math.min(B,m)):Math.min(T-J-Math.min(B,m),S.bottom+je);C({top:j,left:te,width:W,maxHeight:m})},v=()=>{cancelAnimationFrame(R),R=requestAnimationFrame(h)};v();const y=new ResizeObserver(v);return y.observe(x),d.current&&y.observe(d.current),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),window.visualViewport?.addEventListener("resize",v),window.visualViewport?.addEventListener("scroll",v),()=>{cancelAnimationFrame(R),y.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),window.visualViewport?.removeEventListener("resize",v),window.visualViewport?.removeEventListener("scroll",v)}},[s,r.length,n,t,c,o]),!t||!u||typeof document>"u"?null:Rt.createPortal(e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:e.jsx("div",{ref:d,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:u.top,left:u.left,width:u.width,maxHeight:u.maxHeight},children:e.jsx(bs,{commands:r,selectedIndex:o,query:c,hasCatalog:l,title:f,queryPrefix:g,emptyCatalogMessage:p,emptyQueryMessage:b,insertionHint:N,compact:n,onSelect:k})})}),document.body)}function ys({agentType:t,workingDir:s}){return ot({queryKey:D.system.slashCommandCatalog(t,s),queryFn:async()=>(await me.get("/system/slash-command-catalog",{params:{agentType:String(t),...s?{workingDir:s}:{}}})).commands,enabled:!!t,staleTime:3e4})}function Ns(t,s){const r=new Set,o=[];for(const c of[...t,...s]){const l=c.command.trim().toLowerCase();!l||r.has(l)||(r.add(l),o.push(c.kind?c:{...c,kind:"builtin"}))}return o}function Se(t){return t.trim().toLowerCase().replace(/^[/$]/,"")}function ws(t){return Se(t.command)}function js(t,s){if(!s)return 1e3;const r=ws(t),o=t.aliases?.map(Se)??[],c=[r,...o];let l=0;for(const g of c)g===s?l=Math.max(l,500):g.startsWith(s)?l=Math.max(l,400-(g.length-s.length)):g.includes(s)&&(l=Math.max(l,250-g.indexOf(s)));return l>0?l:`${r} ${o.join(" ")} ${t.description}`.toLowerCase().includes(s)?100:0}function cn(t){const s=/(^|[\s])\$([^\s]*)$/.exec(t);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:Se(s[2]),replaceStart:r}}function ks(t,s){const r=Se(s);return r?t.map((o,c)=>({command:o,index:c,score:js(o,r)})).filter(o=>o.score>0).sort((o,c)=>c.score-o.score||o.index-c.index||o.command.command.localeCompare(c.command.command)).map(o=>o.command):t.slice()}const Cs=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],Ss=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],Ts=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],Es=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],Ms={[Ne.CODEX]:Cs,[Ne.CLAUDE_CODE]:Ss,[Ne.GEMINI_CLI]:Ts,[Ne.CURSOR_AGENT]:Es};function ct(t){return t.trim().toLowerCase().replace(/^\//,"")}function Is(t){return t?(Ms[t]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function Rs(t){const s=t.match(/^\s*\/([^\s]*)$/);return s?ct(s[1]):null}function As(t,s){return ks(t,ct(s))}function Ls(t){const s=t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229,r=t.key==="Tab"&&!t.shiftKey;return s||r}function Os({agentType:t,workingDir:s,input:r,setInput:o,textareaRef:c,minHeight:l,maxHeight:f}){const[g,p]=a.useState(0),{data:b=[]}=ys({agentType:t,workingDir:s}),N=a.useMemo(()=>Ns(Is(t),b),[t,b]),n=a.useMemo(()=>Rs(r),[r]),k=a.useMemo(()=>n===null?[]:As(N,n),[N,n]),d=a.useCallback(()=>{const x=c.current;x&&(x.style.height="auto",x.style.height=`${Math.max(l,Math.min(x.scrollHeight,f))}px`)},[f,l,c]);a.useEffect(()=>{p(0)},[t,n]),a.useEffect(()=>{g<k.length||p(0)},[k.length,g]);const u=a.useCallback(x=>{const h=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${x.command} `;o(h),requestAnimationFrame(()=>{const v=c.current;v&&(d(),v.focus(),v.setSelectionRange(h.length,h.length))})},[r,d,o,c]),C=a.useCallback(x=>n===null||k.length===0?!1:x.key==="ArrowDown"?(x.preventDefault(),p(R=>(R+1)%k.length),!0):x.key==="ArrowUp"?(x.preventDefault(),p(R=>(R-1+k.length)%k.length),!0):Ls(x)?(x.preventDefault(),u(k[g]??k[0]),!0):!1,[u,k,n,g]);return{allCommands:N,query:n,filteredCommands:k,selectedIndex:g,setSelectedIndex:p,applyCommand:u,handleKeyDown:C}}const Ps={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function ln({variant:t="task",projects:s,providers:r,isProvidersLoading:o,onSubmit:c,defaultProjectId:l="",defaultProviderId:f="",onProjectChange:g,createStep:p,placeholder:b,submitLabel:N,pendingLabel:n,submitTitle:k}){const{t:d}=ue(),[u,C]=a.useState(""),[x,R]=a.useState(l),[h,v]=a.useState(f),y=h||f,[I,S]=a.useState("SOLO"),[z,T]=a.useState(O.WORKTREE),[q,$]=a.useState(et.NORMAL),[W,te]=a.useState({}),[Q,se]=a.useState("AUTO"),[B,re]=a.useState(null),[K,pe]=a.useState([]),[m,j]=a.useState(!1),[P,U]=a.useState(!1),[V,Y]=a.useState(!1),[oe,ne]=a.useState(!1),Te=a.useRef(null),Ee=a.useRef(null),Me=a.useRef(null),De=a.useRef(null),ze=a.useRef(null),$e=a.useRef(null),{files:Fe,addFiles:ae,removeFile:lt,clear:qe,buildMarkdownLinks:Ge,getDoneAttachments:Ue,isUploading:ye}=Ot(),fe=Ft(),E=t==="conversation",M=t==="task"||t==="conversation",dt=N??d(E?"开始":"创建");a.useEffect(()=>{R(l),g?.(l)},[l,g]),a.useEffect(()=>{if(!P)return;const i=A=>{Te.current&&!Te.current.contains(A.target)&&U(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[P]),a.useEffect(()=>{if(!V)return;const i=A=>{Ee.current&&!Ee.current.contains(A.target)&&Y(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[V]),a.useEffect(()=>{if(!oe)return;const i=A=>{Me.current&&!Me.current.contains(A.target)&&ne(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[oe]);const G=a.useMemo(()=>s.find(i=>i.id===x),[s,x]),H=a.useMemo(()=>r.find(i=>i.id===y),[r,y]),Ie=x?W[x]:void 0,mt=(Ie?.isGitRepo??G?.isGitRepo)!==!1,ut=(Ie?.worktreeReady??G?.worktreeReady)!==!1,F=!E&&!(mt&&ut),_=F?"SOLO":I,X=F?O.MAIN_DIRECTORY:z,pt=X===O.MAIN_DIRECTORY?d("本地模式"):d("工作树模式"),We=d("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),ft=d("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),xt=Ie?.reason??G?.reason,Be=d(xt==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"初始化 Git 后可使用工作树模式。"),Ke=E||_==="SOLO"?H?.agentType:null,Z=Os({agentType:Ke,workingDir:E?void 0:G?.repoPath,input:u,setInput:C,textareaRef:ze,minHeight:76,maxHeight:220}),L=p!=="idle",He=!!B||K.length>0,xe=!L&&!ye&&u.trim().length>0&&(E?H?.available===!0:!!x&&(_==="SOLO"?H?.available===!0:He));a.useEffect(()=>{F&&(S("SOLO"),T(O.MAIN_DIRECTORY),j(!1),ne(!1))},[F]),a.useEffect(()=>{F||E||T(O.WORKTREE)},[E,F,G?.id]);const ht=a.useCallback(async()=>{if(!G||fe.isPending)return;const i=await fe.mutateAsync({id:G.id});te(A=>({...A,[G.id]:i})),i.worktreeReady&&(S("SOLO"),T(O.WORKTREE),ne(!1))},[fe,G]),Re=a.useCallback(async()=>{if(!xe)return;const i=M?Ge():"",A=M?Ue().map(he=>he.id):[];try{await c({title:u.trim(),description:"",projectId:E?"":x,providerId:y,mode:E?"SOLO":_,workspaceMode:!E&&_==="SOLO"?X:O.WORKTREE,teamRunMode:E?"AUTO":Q,teamTemplateId:E||F?null:B,memberPresetIds:E||F?[]:K,attachmentLinks:i,attachmentIds:A,priority:q}),C(""),$(et.NORMAL),M&&qe()}catch{}},[xe,M,Ge,Ue,c,u,E,x,y,_,X,Q,F,B,K,qe,q]),gt=a.useCallback(i=>{Z.handleKeyDown(i)||i.key==="Enter"&&!i.shiftKey&&!i.nativeEvent.isComposing&&i.nativeEvent.keyCode!==229&&(i.preventDefault(),Re())},[Re,Z]),bt=a.useCallback(i=>{const A=i.target.files;A&&A.length>0&&ae(Array.from(A)),i.target.value=""},[ae]),vt=a.useCallback(i=>{R(i),g?.(i),U(!1)},[g]),yt=a.useCallback(i=>{if(!M)return;const A=i.clipboardData.items,he=[];for(const Ve of A)if(Ve.kind==="file"){const Ye=Ve.getAsFile();Ye&&he.push(Ye)}he.length>0&&(i.preventDefault(),ae(he))},[ae,M]),[Qe,Ae]=a.useState(!1),Nt=a.useCallback(i=>{M&&(i.preventDefault(),Ae(!0))},[M]),wt=a.useCallback(i=>{M&&(i.preventDefault(),Ae(!1))},[M]),jt=a.useCallback(i=>{if(!M)return;i.preventDefault(),Ae(!1);const A=i.dataTransfer.files;A.length>0&&ae(Array.from(A))},[ae,M]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{ref:De,className:w("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Qe?"border-info bg-info/5":"border-border",L&&"opacity-80"),onDragOver:M?Nt:void 0,onDragLeave:M?wt:void 0,onDrop:M?jt:void 0,children:[M&&Fe.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(Pt,{files:Fe,onRemove:lt})}),e.jsx("textarea",{ref:ze,value:u,onChange:i=>C(i.target.value),onKeyDown:gt,onPaste:M?yt:void 0,placeholder:d(b||"Describe your task..."),disabled:L,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"}}),M&&Qe&&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:d("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:M?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>$e.current?.click(),disabled:L||ye,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:d("Attach files"),children:e.jsx(Ht,{size:18})}),e.jsx("input",{ref:$e,type:"file",multiple:!0,onChange:bt,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&ye&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(be,{size:14,className:"animate-spin"}),d("Uploading...")]}),L&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(be,{size:14,className:"animate-spin"}),d(n??Ps[p])]}),!E&&!L&&!ye&&_==="TEAM"&&!He&&u.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:d("请选择团队模板或追加成员")}),xe&&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:"⏎"}),dt]}),e.jsx("button",{type:"button",onClick:Re,disabled:!xe,className:w("flex items-center justify-center size-8 rounded-lg transition-all duration-200",xe?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:d(k||"Create & Start"),children:e.jsx(Wt,{size:16,strokeWidth:2.5})})]})]})]}),e.jsx(vs,{open:!!Ke&&Z.query!==null,anchorRef:De,commands:Z.filteredCommands,selectedIndex:Z.selectedIndex,query:Z.query??"",hasCatalog:Z.allCommands.length>0,compact:!0,onSelect:Z.applyCommand}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!E&&e.jsxs("div",{className:"relative",ref:Te,children:[e.jsxs("button",{type:"button",onClick:()=>{L||U(i=>!i)},disabled:L,className:w("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",G?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Bt,{size:14,className:"shrink-0",style:{color:G?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:G?.name??d("Project")}),e.jsx(le,{size:12,className:w("text-muted-foreground transition-transform",P&&"rotate-180")})]}),P&&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:s.map(i=>e.jsxs("button",{type:"button",onClick:()=>vt(i.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:i.color??"var(--muted-foreground)"}}),e.jsx("span",{className:w("truncate flex-1",i.id===x?"text-foreground font-medium":"text-muted-foreground"),children:i.name}),e.jsx(ee,{size:14,className:w("ml-2 shrink-0 text-foreground",i.id===x?"opacity-100":"opacity-0")})]},i.id))})]}),(E||_==="SOLO")&&e.jsxs("div",{className:"relative",ref:Ee,children:[e.jsxs("button",{type:"button",onClick:()=>{L||Y(i=>!i)},disabled:L,className:w("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",H?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(ge,{agentType:H?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:H?.name??d(o?"Loading...":"Agent")}),e.jsx(le,{size:12,className:w("text-muted-foreground transition-transform",V&&"rotate-180")})]}),V&&e.jsx("div",{className:"absolute top-full left-0 z-50 mt-1.5 max-h-[min(60vh,320px)] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-lg border border-border bg-popover py-1 shadow-[0_4px_12px_rgba(0,0,0,0.06)] sm:w-80",children:r.map(i=>e.jsx("div",{tabIndex:i.available?void 0:0,role:i.available?void 0:"group","aria-label":i.available?void 0:`${i.name}: ${d(i.reason||"Agent executable is unavailable.")}`,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:e.jsxs("button",{type:"button",disabled:!i.available,onClick:()=>{v(i.id),Y(!1)},className:w("flex w-full items-start px-3 py-2 text-left text-xs transition-colors hover:bg-accent",!i.available&&"cursor-not-allowed"),children:[e.jsx(ee,{size:14,className:w("mr-2 mt-0.5 shrink-0 text-foreground",i.id===y?"opacity-100":"opacity-0")}),e.jsx(ge,{agentType:i.agentType,className:"mr-2 mt-0.5 size-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:w("block break-words",i.id===y?"font-medium text-foreground":"text-muted-foreground"),children:[i.name,i.available?"":d(" (unavailable)")]}),i.permissionMode?e.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:d("Required permission: {mode}",{mode:d(_e[i.permissionMode])})}):null,i.reason?e.jsx("span",{className:"mt-0.5 block break-words text-[11px] leading-snug text-destructive",children:d(i.reason)}):null]})]})},i.id))})]}),!E&&_==="SOLO"&&e.jsxs("div",{className:"relative",ref:Me,children:[e.jsxs("button",{type:"button",onClick:()=>{L||ne(i=>!i)},disabled:L,className:w("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(Kt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:pt}),e.jsx(le,{size:12,className:w("text-muted-foreground transition-transform",oe&&"rotate-180")})]}),oe&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[F?e.jsx(Pe,{side:"bottom",className:"block w-full",content:Be,children:e.jsxs("div",{tabIndex:0,"aria-label":Be,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(ee,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:d("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:We})]})]}),e.jsx("button",{type:"button",onClick:ht,disabled:fe.isPending,className:"flex w-full items-center px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:fe.isPending?d("检测中..."):d("重新检测 Git 状态")})]})}):e.jsxs("button",{type:"button",onClick:()=>{T(O.WORKTREE),ne(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(ee,{size:14,className:w("mr-2 mt-0.5 shrink-0 text-foreground",X===O.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:w("block truncate",X===O.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:d("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:We})]})]}),e.jsxs("button",{type:"button",onClick:()=>{T(O.MAIN_DIRECTORY),ne(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(ee,{size:14,className:w("mr-2 mt-0.5 shrink-0 text-foreground",X===O.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:w("block truncate",X===O.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:d("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:ft})]})]})]})]}),!E&&e.jsx(xs,{value:q,compact:!0,disabled:L,onChange:$}),!E&&e.jsx(Pe,{side:"bottom",className:"ml-auto",content:F?d("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):X===O.MAIN_DIRECTORY?d("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):d("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":_==="TEAM",onClick:()=>{L||F||(I==="TEAM"?(S("SOLO"),j(!1)):(S("TEAM"),ne(!1),T(O.WORKTREE),j(!0)))},disabled:L||F,className:w("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",_==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":d("启用团队模式"),children:[e.jsx(At,{size:14,className:_==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:d("团队模式")}),(F||X===O.MAIN_DIRECTORY)&&_!=="TEAM"?e.jsx(Lt,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:w("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",_==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:w("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",_==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),H&&!H.available?e.jsx("p",{role:"alert",className:"mt-2 break-words px-2 text-xs leading-snug text-destructive",children:H.reason?d(H.reason):d("Agent executable is unavailable.")}):null,!E&&_==="TEAM"&&m&&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(gs,{mode:Q,setMode:se,selectedTemplateId:B,setSelectedTemplateId:re,selectedMemberPresetIds:K,setSelectedMemberPresetIds:pe,disabled:L,compact:!0})})]})}export{ln as C,rn as P,tn as R,vs as S,sn as T,os as Z,on as a,Xs as b,an as c,Zs as d,gs as e,en as f,cn as g,ks as h,Os as i,Js as j,xs as k,ts as l,nn as u};