@kingsoftcloud/ksadk-web 0.2.18 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist-ksadk/assets/{ArtifactsPanel-C0meuOdi.js → ArtifactsPanel-Cjnqt-8W.js} +1 -1
  3. package/dist-ksadk/assets/CodeBlock-BqyqZfuB.js +9 -0
  4. package/dist-ksadk/assets/MathMessageMarkdown-BpH7jiFM.js +8 -0
  5. package/dist-ksadk/assets/MermaidBlock-DWuxETaJ.js +303 -0
  6. package/dist-ksadk/assets/NativeTerminalPanel-MDTopWMO.js +1 -0
  7. package/dist-ksadk/assets/{arc-bj2rZnP5.js → arc-CFKwSk_B.js} +1 -1
  8. package/dist-ksadk/assets/architecture-7EHR7CIX-CynqOWjZ.js +1 -0
  9. package/dist-ksadk/assets/{architectureDiagram-3BPJPVTR-2u1ltDIj.js → architectureDiagram-3BPJPVTR-Dej8jX8c.js} +1 -1
  10. package/dist-ksadk/assets/{blockDiagram-GPEHLZMM-D6fvdK20.js → blockDiagram-GPEHLZMM-1F64jqvy.js} +1 -1
  11. package/dist-ksadk/assets/{c4Diagram-AAUBKEIU-BK82L5n5.js → c4Diagram-AAUBKEIU-9q7AUAKb.js} +1 -1
  12. package/dist-ksadk/assets/channel-iUGv2N24.js +1 -0
  13. package/dist-ksadk/assets/{chunk-2J33WTMH-DLVdkeyQ.js → chunk-2J33WTMH-6qgwJm7Q.js} +1 -1
  14. package/dist-ksadk/assets/{chunk-4BX2VUAB-BbwsYcbW.js → chunk-4BX2VUAB-CsWIQRhc.js} +1 -1
  15. package/dist-ksadk/assets/{chunk-55IACEB6-DOairxzw.js → chunk-55IACEB6-BK8paA20.js} +1 -1
  16. package/dist-ksadk/assets/{chunk-727SXJPM-hCO487gs.js → chunk-727SXJPM-B-JEhy7h.js} +1 -1
  17. package/dist-ksadk/assets/{chunk-AQP2D5EJ-XU8vDOuG.js → chunk-AQP2D5EJ-DYBvMHAa.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-FMBD7UC4-PrapyfMu.js → chunk-FMBD7UC4-BGhvzDYt.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-ND2GUHAM-CboKhTZ3.js → chunk-ND2GUHAM-D98vPd-E.js} +1 -1
  20. package/dist-ksadk/assets/chunk-QZHKN3VN-YQIEXeF6.js +1 -0
  21. package/dist-ksadk/assets/classDiagram-4FO5ZUOK-CDAUuoXK.js +1 -0
  22. package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-CDAUuoXK.js +1 -0
  23. package/dist-ksadk/assets/{cose-bilkent-S5V4N54A-_N8bJ-EU.js → cose-bilkent-S5V4N54A-CX3yotHq.js} +1 -1
  24. package/dist-ksadk/assets/{dagre-BM42HDAG-FoDlo5J2.js → dagre-BM42HDAG-C7TguAWo.js} +1 -1
  25. package/dist-ksadk/assets/{diagram-2AECGRRQ-BBp6ebBw.js → diagram-2AECGRRQ-Dd17_kws.js} +1 -1
  26. package/dist-ksadk/assets/{diagram-5GNKFQAL-CqOvG1PR.js → diagram-5GNKFQAL-DVIClIil.js} +1 -1
  27. package/dist-ksadk/assets/{diagram-KO2AKTUF-O9T3t6ba.js → diagram-KO2AKTUF-Df_3gYQa.js} +1 -1
  28. package/dist-ksadk/assets/{diagram-LMA3HP47-CGG8ekBO.js → diagram-LMA3HP47-BhLk6ZtA.js} +1 -1
  29. package/dist-ksadk/assets/{diagram-OG6HWLK6-4BmH1EEg.js → diagram-OG6HWLK6-D4GNGvuu.js} +1 -1
  30. package/dist-ksadk/assets/{dist-CiZHB6ZW.js → dist-6CVKuTAe.js} +1 -1
  31. package/dist-ksadk/assets/{dist-BMKM66B4.js → dist-BUHRxvDG.js} +1 -1
  32. package/dist-ksadk/assets/{dist-CZ6C3x8B.js → dist-BZ9n9AjO.js} +1 -1
  33. package/dist-ksadk/assets/{dist-DbaH3p5h.js → dist-BibcG1V9.js} +1 -1
  34. package/dist-ksadk/assets/{dist-BVzcWa6D.js → dist-Bs-jQcRX.js} +1 -1
  35. package/dist-ksadk/assets/{dist-D99wf6_X.js → dist-C2xjE7cO.js} +1 -1
  36. package/dist-ksadk/assets/{dist-DLMjL01k.js → dist-C7-3jInC.js} +1 -1
  37. package/dist-ksadk/assets/{dist-DI-oVAXw.js → dist-C99THtIA.js} +1 -1
  38. package/dist-ksadk/assets/{dist-BkJjNih3.js → dist-CGcp2ex8.js} +1 -1
  39. package/dist-ksadk/assets/{dist-D5JGcxBx.js → dist-CVQRZjPu.js} +1 -1
  40. package/dist-ksadk/assets/{dist-CWiTDN_V.js → dist-Cf23NY4L.js} +1 -1
  41. package/dist-ksadk/assets/{dist-DLeM1OCK.js → dist-CgF3fj15.js} +1 -1
  42. package/dist-ksadk/assets/{dist-BmuTWcm7.js → dist-Cwt7koer.js} +1 -1
  43. package/dist-ksadk/assets/{dist-C2DKRFVK.js → dist-D82mtD2s.js} +1 -1
  44. package/dist-ksadk/assets/{dist-B67uF2uK.js → dist-DF06ORQo.js} +1 -1
  45. package/dist-ksadk/assets/{dist-Cwhk4lwI.js → dist-DHn6nBzr.js} +1 -1
  46. package/dist-ksadk/assets/{dist-S4klkK5W.js → dist-Djgl2wVZ.js} +1 -1
  47. package/dist-ksadk/assets/{dist-DCpZrjaK.js → dist-DlzCRy0S.js} +1 -1
  48. package/dist-ksadk/assets/{dist-Cp1_jKwf.js → dist-DqNnNFrw.js} +1 -1
  49. package/dist-ksadk/assets/{dist-6kSZvCZh.js → dist-DyvYLMW9.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DM0rEQPk.js → dist-eoW6tZXA.js} +1 -1
  51. package/dist-ksadk/assets/{dist-Bk1l05Ni.js → dist-ivOya1LD.js} +1 -1
  52. package/dist-ksadk/assets/{erDiagram-TEJ5UH35-oJhaci7S.js → erDiagram-TEJ5UH35-CnfRcY2M.js} +1 -1
  53. package/dist-ksadk/assets/eventmodeling-FCH6USID-ChYO-ijM.js +1 -0
  54. package/dist-ksadk/assets/{flowDiagram-I6XJVG4X-DtTmUan-.js → flowDiagram-I6XJVG4X-DGaJjGNJ.js} +1 -1
  55. package/dist-ksadk/assets/{ganttDiagram-6RSMTGT7-BSsb_eij.js → ganttDiagram-6RSMTGT7-DpCoB2g9.js} +1 -1
  56. package/dist-ksadk/assets/gitGraph-WXDBUCRP-BN_0Fk-j.js +1 -0
  57. package/dist-ksadk/assets/{gitGraphDiagram-PVQCEYII-BR5s6Pws.js → gitGraphDiagram-PVQCEYII-9IKVFBVT.js} +1 -1
  58. package/dist-ksadk/assets/index-QSwCHuB8.js +177 -0
  59. package/dist-ksadk/assets/index-jOPmTOZH.css +2 -0
  60. package/dist-ksadk/assets/info-J43DQDTF-Cp6o3vId.js +1 -0
  61. package/dist-ksadk/assets/{infoDiagram-5YYISTIA-DYPc5cvh.js → infoDiagram-5YYISTIA-CYIIsb8y.js} +1 -1
  62. package/dist-ksadk/assets/{ishikawaDiagram-YF4QCWOH-MoBdALDg.js → ishikawaDiagram-YF4QCWOH-DLOHGvWw.js} +1 -1
  63. package/dist-ksadk/assets/{journeyDiagram-JHISSGLW-DgLiQT8l.js → journeyDiagram-JHISSGLW-BIzKeejT.js} +1 -1
  64. package/dist-ksadk/assets/{kanban-definition-UN3LZRKU-CsFx112F.js → kanban-definition-UN3LZRKU-BWHoFSw2.js} +1 -1
  65. package/dist-ksadk/assets/{katex-DRsiwpM2.js → katex-DATssjp1.js} +1 -1
  66. package/dist-ksadk/assets/{linear-TNRQ5Orv.js → linear-CvMBw9cA.js} +1 -1
  67. package/dist-ksadk/assets/{mermaid-parser.core-D2eMVOgo.js → mermaid-parser.core-mGAcEwcq.js} +2 -2
  68. package/dist-ksadk/assets/{mindmap-definition-RKZ34NQL-BtByYFhL.js → mindmap-definition-RKZ34NQL-CSAQxEAe.js} +1 -1
  69. package/dist-ksadk/assets/packet-YPE3B663-wQzct3cT.js +1 -0
  70. package/dist-ksadk/assets/pie-LRSECV5Y-BgTQiv-9.js +1 -0
  71. package/dist-ksadk/assets/{pieDiagram-4H26LBE5-DPnuCB8c.js → pieDiagram-4H26LBE5-By-ra07M.js} +1 -1
  72. package/dist-ksadk/assets/{quadrantDiagram-W4KKPZXB-miFpCPv4.js → quadrantDiagram-W4KKPZXB-CxIR4JXI.js} +1 -1
  73. package/dist-ksadk/assets/radar-GUYGQ44K-BIq5fXsn.js +1 -0
  74. package/dist-ksadk/assets/{requirementDiagram-4Y6WPE33-mjB_yYkW.js → requirementDiagram-4Y6WPE33-DpW90iu3.js} +1 -1
  75. package/dist-ksadk/assets/{sankeyDiagram-5OEKKPKP-D7hSlZZZ.js → sankeyDiagram-5OEKKPKP-DpGa6EAV.js} +1 -1
  76. package/dist-ksadk/assets/{sequenceDiagram-3UESZ5HK-D9Cx6hC3.js → sequenceDiagram-3UESZ5HK-NTKNGGe5.js} +1 -1
  77. package/dist-ksadk/assets/{stateDiagram-AJRCARHV-D_zrg47o.js → stateDiagram-AJRCARHV-DGpd9yFG.js} +1 -1
  78. package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-B3o579IQ.js +1 -0
  79. package/dist-ksadk/assets/{timeline-definition-PNZ67QCA-CwSec0Wa.js → timeline-definition-PNZ67QCA-jqoYs3jQ.js} +1 -1
  80. package/dist-ksadk/assets/treeView-BLDUP644-Dqi-E0EM.js +1 -0
  81. package/dist-ksadk/assets/treemap-LRROVOQU-ClQP9CJ9.js +1 -0
  82. package/dist-ksadk/assets/{vennDiagram-CIIHVFJN-agCVobiF.js → vennDiagram-CIIHVFJN-l3Z7-wbP.js} +1 -1
  83. package/dist-ksadk/assets/wardley-L42UT6IY-8XLvnNIs.js +1 -0
  84. package/dist-ksadk/assets/{wardleyDiagram-YWT4CUSO-TmrlhWNt.js → wardleyDiagram-YWT4CUSO-BR54GPmr.js} +1 -1
  85. package/dist-ksadk/assets/{xychartDiagram-2RQKCTM6-DV71V-ah.js → xychartDiagram-2RQKCTM6-SkiH8GsK.js} +1 -1
  86. package/dist-ksadk/index.html +2 -2
  87. package/dist-lib/App.d.ts.map +1 -1
  88. package/dist-lib/{ArtifactsPanel-DCn5q1OB.js → ArtifactsPanel-BAfHt4bC.js} +4 -4
  89. package/dist-lib/CodeBlock-Cbl6cxYC.js +110 -0
  90. package/dist-lib/{MathMessageMarkdown-DQPFplDT.js → MathMessageMarkdown-DbMSeHQa.js} +15 -10
  91. package/dist-lib/{NativeTerminalPanel-CjyPyYC4.js → NativeTerminalPanel-BTPHqbvY.js} +1 -1
  92. package/dist-lib/WorkspacePanelContainer-Iy0LhhgG.js +3782 -0
  93. package/dist-lib/api/errors.d.ts +2 -0
  94. package/dist-lib/api/errors.d.ts.map +1 -0
  95. package/dist-lib/api/messages.d.ts +22 -0
  96. package/dist-lib/api/messages.d.ts.map +1 -1
  97. package/dist-lib/capabilities-CxHZ869f.js +133 -0
  98. package/dist-lib/capabilities.js +1 -1
  99. package/dist-lib/components/MessageMarkdown.d.ts.map +1 -1
  100. package/dist-lib/components/chat/A2UIActivityMessage.d.ts +7 -0
  101. package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -0
  102. package/dist-lib/components/chat/ChatComposer.d.ts +4 -1
  103. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  104. package/dist-lib/components/chat/ChatHeader.d.ts.map +1 -1
  105. package/dist-lib/components/chat/ChatMessageList.d.ts +8 -1
  106. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  107. package/dist-lib/components/chat/ChatSidebar.d.ts.map +1 -1
  108. package/dist-lib/components/chat/ConnectedComposer.d.ts +4 -1
  109. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  110. package/dist-lib/components/chat/ConnectedMessageList.d.ts +8 -2
  111. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  112. package/dist-lib/components/chat/ContextUsageIndicator.d.ts +13 -0
  113. package/dist-lib/components/chat/ContextUsageIndicator.d.ts.map +1 -0
  114. package/dist-lib/components/chat/MenuChip.d.ts +19 -0
  115. package/dist-lib/components/chat/MenuChip.d.ts.map +1 -0
  116. package/dist-lib/components/chat/PermissionMenu.d.ts +7 -0
  117. package/dist-lib/components/chat/PermissionMenu.d.ts.map +1 -0
  118. package/dist-lib/components/chat/ProcessingBlocksView.d.ts +24 -0
  119. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -0
  120. package/dist-lib/components/chat/StatusBanner.d.ts +13 -0
  121. package/dist-lib/components/chat/StatusBanner.d.ts.map +1 -0
  122. package/dist-lib/components/chat/types.d.ts +28 -1
  123. package/dist-lib/components/chat/types.d.ts.map +1 -1
  124. package/dist-lib/components/markdown/CodeBlock.d.ts.map +1 -1
  125. package/dist-lib/components/markdown/MathMessageMarkdown.d.ts.map +1 -1
  126. package/dist-lib/components.js +3 -3
  127. package/dist-lib/core/api/facade.d.ts +3 -1
  128. package/dist-lib/core/api/facade.d.ts.map +1 -1
  129. package/dist-lib/core/api/types.d.ts +2 -1
  130. package/dist-lib/core/api/types.d.ts.map +1 -1
  131. package/dist-lib/core/run/a2ui.d.ts +13 -0
  132. package/dist-lib/core/run/a2ui.d.ts.map +1 -0
  133. package/dist-lib/core/run/agui.d.ts +35 -0
  134. package/dist-lib/core/run/agui.d.ts.map +1 -0
  135. package/dist-lib/core/run/blocks.d.ts +65 -0
  136. package/dist-lib/core/run/blocks.d.ts.map +1 -0
  137. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  138. package/dist-lib/core/run/engine.d.ts +10 -0
  139. package/dist-lib/core/run/engine.d.ts.map +1 -1
  140. package/dist-lib/core/run/types.d.ts +60 -0
  141. package/dist-lib/core/run/types.d.ts.map +1 -1
  142. package/dist-lib/core/stream/responses-protocol.d.ts.map +1 -1
  143. package/dist-lib/core/stream/types.d.ts +29 -0
  144. package/dist-lib/core/stream/types.d.ts.map +1 -1
  145. package/dist-lib/hooks/useFeedback.d.ts.map +1 -1
  146. package/dist-lib/hooks/useRunAgent.d.ts +8 -0
  147. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  148. package/dist-lib/hooks/useSessionLifecycle.d.ts +1 -1
  149. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  150. package/dist-lib/runtime.js +2187 -1302
  151. package/dist-lib/stores/permission.d.ts +11 -0
  152. package/dist-lib/stores/permission.d.ts.map +1 -0
  153. package/dist-lib/stores/session.d.ts +10 -13
  154. package/dist-lib/stores/session.d.ts.map +1 -1
  155. package/dist-lib/stores/streaming.d.ts +17 -0
  156. package/dist-lib/stores/streaming.d.ts.map +1 -1
  157. package/dist-lib/styles.css +2 -1
  158. package/dist-lib/types/api.d.ts +12 -0
  159. package/dist-lib/types/api.d.ts.map +1 -1
  160. package/dist-lib/types/capabilities.d.ts +9 -1
  161. package/dist-lib/types/capabilities.d.ts.map +1 -1
  162. package/dist-lib/types/session-events.d.ts +11 -0
  163. package/dist-lib/types/session-events.d.ts.map +1 -1
  164. package/dist-lib/utils/capabilities.d.ts +1 -0
  165. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  166. package/dist-lib/utils/markdown.d.ts +1 -0
  167. package/dist-lib/utils/markdown.d.ts.map +1 -1
  168. package/dist-lib/utils/messages.d.ts.map +1 -1
  169. package/dist-lib/utils/parse-unified-diff.d.ts +15 -0
  170. package/dist-lib/utils/parse-unified-diff.d.ts.map +1 -0
  171. package/dist-lib/utils/recovered-run.d.ts +4 -0
  172. package/dist-lib/utils/recovered-run.d.ts.map +1 -0
  173. package/dist-lib/utils/responses-stream.d.ts +1 -1
  174. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  175. package/dist-lib/utils/session-events.d.ts +1 -0
  176. package/dist-lib/utils/session-events.d.ts.map +1 -1
  177. package/dist-lib/utils/session-message-history.d.ts +7 -0
  178. package/dist-lib/utils/session-message-history.d.ts.map +1 -0
  179. package/dist-lib/utils/workspace.d.ts +1 -1
  180. package/package.json +12 -3
  181. package/dist-ksadk/assets/CodeBlock-BbI4HPtJ.js +0 -9
  182. package/dist-ksadk/assets/MathMessageMarkdown-DMLQYoLp.js +0 -8
  183. package/dist-ksadk/assets/MermaidBlock-DCR8WZ17.js +0 -303
  184. package/dist-ksadk/assets/NativeTerminalPanel-CKUvWhUz.js +0 -1
  185. package/dist-ksadk/assets/architecture-7EHR7CIX-Cr6Xz1_c.js +0 -1
  186. package/dist-ksadk/assets/channel-BSSOwFIb.js +0 -1
  187. package/dist-ksadk/assets/chunk-QZHKN3VN-XXpdiwUL.js +0 -1
  188. package/dist-ksadk/assets/classDiagram-4FO5ZUOK-C5HvGiyK.js +0 -1
  189. package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-C5HvGiyK.js +0 -1
  190. package/dist-ksadk/assets/eventmodeling-FCH6USID-CIgwHJLL.js +0 -1
  191. package/dist-ksadk/assets/gitGraph-WXDBUCRP-BVAJ7uo0.js +0 -1
  192. package/dist-ksadk/assets/index-BH7-pC0B.js +0 -165
  193. package/dist-ksadk/assets/index-DAURbCsP.css +0 -1
  194. package/dist-ksadk/assets/info-J43DQDTF-MT80V4ge.js +0 -1
  195. package/dist-ksadk/assets/packet-YPE3B663-BLKhbXZB.js +0 -1
  196. package/dist-ksadk/assets/pie-LRSECV5Y-DFOikjSY.js +0 -1
  197. package/dist-ksadk/assets/radar-GUYGQ44K-095b1Ikw.js +0 -1
  198. package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-J9kCb0nC.js +0 -1
  199. package/dist-ksadk/assets/treeView-BLDUP644-yinfJEY6.js +0 -1
  200. package/dist-ksadk/assets/treemap-LRROVOQU-DosUqN1Q.js +0 -1
  201. package/dist-ksadk/assets/wardley-L42UT6IY-Bvp7-5uH.js +0 -1
  202. package/dist-lib/CodeBlock-BGJr6bCf.js +0 -94
  203. package/dist-lib/WorkspacePanelContainer-fvYVV4lp.js +0 -2912
  204. package/dist-lib/capabilities-CiyyeRQ9.js +0 -78
  205. package/dist-lib/utils/session-event-history.d.ts +0 -28
  206. package/dist-lib/utils/session-event-history.d.ts.map +0 -1
@@ -0,0 +1,3782 @@
1
+ import { ArrowDown as e, ArrowUp as t, Bot as n, Check as r, ChevronDown as i, Code as a, Copy as o, Download as s, ExternalLink as c, Eye as l, FileCode2 as u, FileDiff as d, FileText as f, FolderOpen as p, Globe2 as m, Hand as h, Image as g, Loader2 as _, LoaderCircle as v, Maximize2 as y, MessageSquarePlus as b, MessageSquareText as x, Minimize2 as S, MoreHorizontal as C, Package as w, PanelLeft as ee, PanelLeftClose as T, Paperclip as E, Pin as D, PinOff as te, RefreshCcw as O, RefreshCw as ne, Save as re, Search as ie, ShieldAlert as ae, ShieldCheck as k, Sparkles as A, Square as oe, StopCircle as j, TerminalSquare as M, ThumbsDown as N, ThumbsUp as P, Trash2 as se, Upload as ce, WifiOff as le, Wrench as ue, X as de, XCircle as F, ZapOff as fe } from "lucide-react";
2
+ import { clsx as pe } from "clsx";
3
+ import { twMerge as I } from "tailwind-merge";
4
+ import { create as L } from "zustand";
5
+ import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
6
+ import * as V from "react";
7
+ import me, { Suspense as H, lazy as he, useCallback as U, useEffect as W, useId as ge, useLayoutEffect as G, useMemo as _e, useRef as K, useState as q } from "react";
8
+ import * as J from "@radix-ui/react-dialog";
9
+ import { cva as ve } from "class-variance-authority";
10
+ import ye from "react-markdown";
11
+ import be from "remark-gfm";
12
+ import xe from "remark-breaks";
13
+ import { A2UIProvider as Se, A2UIRenderer as Ce, A2UI_SCHEMA_CONTEXT_DESCRIPTION as we, basicCatalog as Te, buildCatalogContextValue as Ee, useA2UI as De } from "@copilotkit/a2ui-renderer";
14
+ import { EditorView as Oe, crosshairCursor as ke, drawSelection as Ae, dropCursor as je, highlightActiveLine as Me, highlightActiveLineGutter as Ne, keymap as Pe, lineNumbers as Fe, rectangularSelection as Ie } from "@codemirror/view";
15
+ import { Compartment as Le, EditorState as Re } from "@codemirror/state";
16
+ import { defaultKeymap as ze, history as Be, historyKeymap as Ve, indentWithTab as He } from "@codemirror/commands";
17
+ import { LanguageDescription as Ue, bracketMatching as We, defaultHighlightStyle as Ge, foldGutter as Ke, foldKeymap as qe, indentOnInput as Je, syntaxHighlighting as Ye } from "@codemirror/language";
18
+ import { oneDark as Xe } from "@codemirror/theme-one-dark";
19
+ import { highlightSelectionMatches as Ze, searchKeymap as Qe } from "@codemirror/search";
20
+ import { autocompletion as $e, closeBrackets as et, closeBracketsKeymap as tt, completionKeymap as nt } from "@codemirror/autocomplete";
21
+ import { languages as rt } from "@codemirror/language-data";
22
+ //#region src/lib/utils.ts
23
+ function Y(...e) {
24
+ return I(pe(e));
25
+ }
26
+ //#endregion
27
+ //#region src/stores/model.ts
28
+ function it(e, t) {
29
+ let n = /* @__PURE__ */ new Map();
30
+ for (let t of e) t?.id && n.set(t.id, t);
31
+ for (let e of t) e?.id && n.set(e.id, {
32
+ ...n.get(e.id) || {},
33
+ ...e
34
+ });
35
+ return Array.from(n.values()).sort((e, t) => e.id.localeCompare(t.id));
36
+ }
37
+ var at = L()((e) => ({
38
+ availableModels: [],
39
+ selectedModel: "",
40
+ modelSource: "",
41
+ modelCatalogLoaded: !1,
42
+ thinkingMode: "auto",
43
+ upsertModels: (t) => e((e) => ({ availableModels: it(e.availableModels, t) })),
44
+ setSelectedModel: (t) => e({ selectedModel: t }),
45
+ setModelSource: (t) => e({ modelSource: t }),
46
+ setModelCatalogLoaded: (t) => e({ modelCatalogLoaded: t }),
47
+ setThinkingMode: (t) => e({ thinkingMode: t })
48
+ })), ot = new Set([
49
+ "auto",
50
+ "enabled",
51
+ "disabled"
52
+ ]);
53
+ function st(e) {
54
+ let t = String(e || "").trim().toLowerCase();
55
+ return ot.has(t) ? t : "auto";
56
+ }
57
+ function ct(e) {
58
+ let t = st(e);
59
+ if (t === "disabled") return { thinking: { type: "disabled" } };
60
+ if (t === "enabled") return { thinking: { type: "enabled" } };
61
+ }
62
+ //#endregion
63
+ //#region src/components/chat/ContextUsageIndicator.tsx
64
+ function lt({ indicator: e }) {
65
+ let t = Math.max(0, Math.min(100, e.percent ?? 0));
66
+ return /* @__PURE__ */ B("div", {
67
+ className: "group relative flex h-8 w-8 items-center justify-center",
68
+ children: [/* @__PURE__ */ z("div", {
69
+ className: Y("flex h-4 w-4 items-center justify-center rounded-full", e.phase === "warning" || e.phase === "compressing" || t >= 85 ? "text-red-500" : "text-[#a5abb2]"),
70
+ title: e.label,
71
+ children: /* @__PURE__ */ z("div", {
72
+ className: "flex h-3 w-3 items-center justify-center rounded-full",
73
+ style: { background: `conic-gradient(currentColor ${t * 3.6}deg, #edf0f2 0deg)` },
74
+ children: /* @__PURE__ */ z("span", { className: "h-2 w-2 rounded-full bg-background" })
75
+ })
76
+ }), /* @__PURE__ */ B("div", {
77
+ className: "pointer-events-auto absolute bottom-[calc(100%+0.75rem)] left-1/2 z-30 hidden w-max -translate-x-1/2 rounded-2xl border border-border/70 bg-background px-4 py-3 text-center text-sm leading-5 text-foreground shadow-[0_14px_42px_rgba(15,23,42,0.16)] group-hover:block dark:shadow-[0_14px_42px_rgba(0,0,0,0.4)]",
78
+ children: [
79
+ /* @__PURE__ */ z("div", {
80
+ className: "mb-1 whitespace-nowrap font-light text-text-secondary",
81
+ children: "估算上下文"
82
+ }),
83
+ /* @__PURE__ */ B("div", {
84
+ className: "whitespace-nowrap font-light",
85
+ children: [t, "% 已使用"]
86
+ }),
87
+ /* @__PURE__ */ z("div", {
88
+ className: "whitespace-nowrap font-light text-text-muted",
89
+ children: e.usedTokens && e.contextWindowTokens ? `${ut(e.usedTokens)} / ${ut(e.contextWindowTokens)}` : e.label
90
+ })
91
+ ]
92
+ })]
93
+ });
94
+ }
95
+ function ut(e) {
96
+ return e >= 1e6 ? `${(e / 1e6).toFixed(1)}m` : e >= 1e3 ? `${(e / 1e3).toFixed(0)}k` : String(e);
97
+ }
98
+ //#endregion
99
+ //#region src/components/chat/MenuChip.tsx
100
+ function dt({ label: e, options: t, value: n, onChange: r, title: a }) {
101
+ let [o, s] = q(!1), c = K(null);
102
+ return W(() => {
103
+ if (!o) return;
104
+ let e = (e) => {
105
+ c.current && !c.current.contains(e.target) && s(!1);
106
+ };
107
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
108
+ }, [o]), /* @__PURE__ */ B("div", {
109
+ ref: c,
110
+ className: "relative",
111
+ children: [/* @__PURE__ */ B("button", {
112
+ type: "button",
113
+ onClick: () => s((e) => !e),
114
+ title: a,
115
+ className: "flex h-8 max-w-[12rem] items-center gap-1 overflow-hidden rounded-full px-2 text-sm font-normal leading-[18px] text-text-primary hover:bg-muted",
116
+ children: [/* @__PURE__ */ z("span", {
117
+ className: "min-w-0 flex-1 truncate text-center",
118
+ children: e
119
+ }), /* @__PURE__ */ z(i, { className: Y("h-4 w-4 shrink-0 text-text-secondary transition-transform", o && "rotate-180") })]
120
+ }), o ? /* @__PURE__ */ z("div", {
121
+ className: "absolute bottom-[calc(100%+0.5rem)] left-0 z-30 max-h-[min(50vh,20rem)] min-w-[10rem] max-w-[16rem] overflow-y-auto rounded-xl border border-border bg-popover p-1.5 text-sm shadow-[0_10px_28px_rgba(0,0,0,0.18)]",
122
+ children: t.map((e) => /* @__PURE__ */ z("button", {
123
+ type: "button",
124
+ onClick: () => {
125
+ r(e.value), s(!1);
126
+ },
127
+ className: Y("flex w-full items-center rounded-lg px-2.5 py-1.5 text-left leading-5 transition-colors", e.value === n ? "bg-muted text-text-primary" : "text-text-secondary hover:bg-muted hover:text-text-primary"),
128
+ children: /* @__PURE__ */ z("span", {
129
+ className: "min-w-0 flex-1 truncate",
130
+ children: e.label
131
+ })
132
+ }, e.value))
133
+ }) : null]
134
+ });
135
+ }
136
+ //#endregion
137
+ //#region src/stores/permission.ts
138
+ var ft = "ksadk.web.permission-mode";
139
+ function pt() {
140
+ try {
141
+ let e = globalThis.localStorage?.getItem(ft);
142
+ return e === "ask" || e === "full" || e === "risk" ? e : "risk";
143
+ } catch {
144
+ return "risk";
145
+ }
146
+ }
147
+ function mt(e) {
148
+ try {
149
+ globalThis.localStorage?.setItem(ft, e);
150
+ } catch {}
151
+ }
152
+ var ht = L()((e) => ({
153
+ permissionMode: pt(),
154
+ setPermissionMode: (t) => {
155
+ mt(t), e({ permissionMode: t });
156
+ }
157
+ })), gt = [
158
+ {
159
+ value: "ask",
160
+ label: "请求批准",
161
+ description: "有副作用的操作执行前先确认",
162
+ icon: h
163
+ },
164
+ {
165
+ value: "risk",
166
+ label: "风险操作需确认",
167
+ description: "只对命令、写入和外部副作用确认",
168
+ icon: k
169
+ },
170
+ {
171
+ value: "full",
172
+ label: "完全访问",
173
+ description: "本次会话不再为默认规则弹出确认",
174
+ icon: ae
175
+ }
176
+ ], _t = {
177
+ ask: "请求批准",
178
+ risk: "风险确认",
179
+ full: "完全访问"
180
+ };
181
+ function vt({ approvalPolicy: e }) {
182
+ let [t, n] = q(!1), a = K(null), o = ht((e) => e.permissionMode), s = ht((e) => e.setPermissionMode), c = gt.filter((t) => !e || e.Modes.includes(t.value));
183
+ return W(() => {
184
+ c.some((e) => e.value === o) || s(e?.DefaultMode || c[0]?.value || "risk");
185
+ }, [
186
+ e?.DefaultMode,
187
+ o,
188
+ s,
189
+ c
190
+ ]), W(() => {
191
+ if (!t) return;
192
+ let e = (e) => {
193
+ a.current && !a.current.contains(e.target) && n(!1);
194
+ }, r = (e) => {
195
+ e.key === "Escape" && n(!1);
196
+ };
197
+ return document.addEventListener("mousedown", e), document.addEventListener("keydown", r), () => {
198
+ document.removeEventListener("mousedown", e), document.removeEventListener("keydown", r);
199
+ };
200
+ }, [t]), /* @__PURE__ */ B("div", {
201
+ ref: a,
202
+ className: "relative",
203
+ children: [/* @__PURE__ */ B("button", {
204
+ type: "button",
205
+ onClick: () => n((e) => !e),
206
+ className: "flex h-8 items-center gap-1 rounded-full px-2 text-[13px] text-text-secondary transition hover:bg-muted hover:text-text-primary",
207
+ "aria-expanded": t,
208
+ "aria-haspopup": "menu",
209
+ title: "设置本次会话的工具审批规则",
210
+ children: [
211
+ /* @__PURE__ */ z(k, { className: "h-3.5 w-3.5" }),
212
+ /* @__PURE__ */ z("span", { children: _t[o] }),
213
+ /* @__PURE__ */ z(i, { className: Y("h-3.5 w-3.5 transition-transform", t && "rotate-180") })
214
+ ]
215
+ }), t ? /* @__PURE__ */ B("div", {
216
+ role: "menu",
217
+ "aria-label": "工具权限",
218
+ className: "absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[19rem] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_12px_30px_rgba(15,23,42,0.14)]",
219
+ children: [/* @__PURE__ */ z("div", {
220
+ className: "px-2.5 pb-1.5 pt-1 text-[11px] text-text-muted",
221
+ children: "本次会话的默认审批规则"
222
+ }), c.map((e) => {
223
+ let t = e.icon, i = e.value === o;
224
+ return /* @__PURE__ */ B("button", {
225
+ type: "button",
226
+ role: "menuitemradio",
227
+ "aria-checked": i,
228
+ onClick: () => {
229
+ s(e.value), n(!1);
230
+ },
231
+ className: Y("flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-left transition-colors", i ? "bg-primary/[0.08]" : "hover:bg-muted/75"),
232
+ children: [
233
+ /* @__PURE__ */ z(t, { className: Y("h-[17px] w-[17px] shrink-0", i ? "text-primary" : "text-text-muted") }),
234
+ /* @__PURE__ */ B("span", {
235
+ className: "min-w-0 flex-1",
236
+ children: [/* @__PURE__ */ z("span", {
237
+ className: Y("block text-[13px] font-medium leading-5", i ? "text-text-primary" : "text-text-secondary"),
238
+ children: e.label
239
+ }), /* @__PURE__ */ z("span", {
240
+ className: "block text-[11px] leading-4 text-text-muted",
241
+ children: e.description
242
+ })]
243
+ }),
244
+ i ? /* @__PURE__ */ z(r, {
245
+ className: "h-4 w-4 shrink-0 text-primary",
246
+ "aria-hidden": "true"
247
+ }) : null
248
+ ]
249
+ }, e.value);
250
+ })]
251
+ }) : null]
252
+ });
253
+ }
254
+ //#endregion
255
+ //#region src/components/chat/ChatComposer.tsx
256
+ function yt({ attachments: e, composerContextIndicator: n, composerMaxHeight: r, fileInputRef: i, input: a, isMobile: o, isStreaming: s, approvalEnabled: c = !1, approvalPolicy: l, queuedDrafts: u, onAppendAttachments: d, onInputChange: f, onPaste: p, onRemoveAttachment: m, onStopGeneration: h, onCancelRemote: g, onSubmit: _, textareaRef: v }) {
257
+ let y = o ? "发送消息..." : "发送消息…", b = g ? "保留恢复点并结束本次执行" : "停止生成", x = at((e) => e.availableModels), S = at((e) => e.selectedModel), C = at((e) => e.thinkingMode), w = at((e) => e.setSelectedModel), ee = at((e) => e.setThinkingMode), T = x.find((e) => e.id === S)?.display_name || S || "", D = (e) => e === "enabled" ? "开启思考" : e === "disabled" ? "关闭思考" : "思考自动", te = (e) => e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
258
+ return /* @__PURE__ */ z("div", {
259
+ className: "relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3",
260
+ children: /* @__PURE__ */ B("div", {
261
+ className: "mx-auto w-full max-w-[64rem]",
262
+ children: [u.length > 0 ? /* @__PURE__ */ B("div", {
263
+ className: "mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",
264
+ children: [/* @__PURE__ */ B("div", {
265
+ className: "mb-1.5 flex items-center justify-between gap-2",
266
+ children: [/* @__PURE__ */ B("span", {
267
+ className: "font-semibold",
268
+ children: ["发送队列 · ", u.length]
269
+ }), /* @__PURE__ */ z("span", {
270
+ className: "text-amber-700/75 dark:text-amber-200/75",
271
+ children: "当前回复完成后依次发送"
272
+ })]
273
+ }), /* @__PURE__ */ B("div", {
274
+ className: "flex flex-col gap-1",
275
+ children: [u.slice(0, 3).map((e, t) => {
276
+ let n = e.text.trim() || (e.attachments.length > 0 ? "仅附件消息" : "空消息");
277
+ return /* @__PURE__ */ B("div", {
278
+ className: "flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5",
279
+ children: [
280
+ /* @__PURE__ */ z("span", {
281
+ className: "flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100",
282
+ children: t + 1
283
+ }),
284
+ /* @__PURE__ */ z("span", {
285
+ className: "min-w-0 flex-1 truncate text-text-secondary",
286
+ children: n
287
+ }),
288
+ e.attachments.length > 0 ? /* @__PURE__ */ B("span", {
289
+ className: "flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100",
290
+ children: [e.attachments.length, " 附件"]
291
+ }) : null
292
+ ]
293
+ }, `${t}-${n}-${e.attachments.length}`);
294
+ }), u.length > 3 ? /* @__PURE__ */ B("div", {
295
+ className: "px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80",
296
+ children: [
297
+ "还有 ",
298
+ u.length - 3,
299
+ " 条等待发送"
300
+ ]
301
+ }) : null]
302
+ })]
303
+ }) : null, /* @__PURE__ */ z("div", {
304
+ className: "relative rounded-[26px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_3px_7.5px_rgba(0,0,0,0.04),0_0_20px_rgba(0,0,0,0.05)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_3px_7.5px_rgba(0,0,0,0.2)]",
305
+ children: /* @__PURE__ */ z("div", {
306
+ className: "flex items-center gap-3",
307
+ children: /* @__PURE__ */ B("form", {
308
+ onSubmit: (t) => {
309
+ if (t.preventDefault(), s) {
310
+ g ? g() : h();
311
+ return;
312
+ }
313
+ let n = a.trim();
314
+ !n && e.length === 0 || _(n, e);
315
+ },
316
+ onDragOver: (e) => {
317
+ e.preventDefault(), e.stopPropagation();
318
+ },
319
+ onDrop: (e) => {
320
+ e.preventDefault(), e.stopPropagation(), e.dataTransfer.files && e.dataTransfer.files.length > 0 && d(Array.from(e.dataTransfer.files));
321
+ },
322
+ className: "relative flex min-h-[76px] min-w-0 flex-1 flex-col rounded-[26px] border border-border/45 bg-background px-4 pb-1.5 pt-2 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15",
323
+ children: [
324
+ e.length > 0 ? /* @__PURE__ */ z("div", {
325
+ className: "mb-1.5 flex flex-wrap gap-2",
326
+ children: e.map((e, t) => /* @__PURE__ */ B("div", {
327
+ className: Y("group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs", o ? "max-w-full" : "max-w-[14rem]"),
328
+ children: [
329
+ /* @__PURE__ */ z("span", {
330
+ className: "flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted",
331
+ children: /* @__PURE__ */ z(E, { className: "h-3.5 w-3.5" })
332
+ }),
333
+ /* @__PURE__ */ B("span", {
334
+ className: "min-w-0 flex-1",
335
+ children: [/* @__PURE__ */ z("span", {
336
+ className: "block truncate font-medium text-text-primary",
337
+ children: e.name
338
+ }), /* @__PURE__ */ z("span", {
339
+ className: "block text-[10px] text-text-muted",
340
+ children: te(e.size)
341
+ })]
342
+ }),
343
+ /* @__PURE__ */ z("button", {
344
+ type: "button",
345
+ onClick: () => m(t),
346
+ className: "absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500",
347
+ "aria-label": `移除附件 ${e.name}`,
348
+ children: /* @__PURE__ */ z("span", {
349
+ className: "text-[11px] leading-none",
350
+ children: "×"
351
+ })
352
+ })
353
+ ]
354
+ }, `${e.name}-${e.size}-${t}`))
355
+ }) : null,
356
+ /* @__PURE__ */ z("textarea", {
357
+ ref: v,
358
+ rows: 1,
359
+ value: a,
360
+ onChange: f,
361
+ onKeyDown: (e) => {
362
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), e.currentTarget.form?.requestSubmit());
363
+ },
364
+ onPaste: p,
365
+ placeholder: y,
366
+ className: Y("custom-scrollbar max-h-[112px] min-h-[48px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-0 pt-1 text-[14px] leading-6 text-text-primary outline-none placeholder:text-text-muted/55", o ? "text-[16px]" : "text-[14px]"),
367
+ style: {
368
+ maxHeight: `${r}px`,
369
+ overflowY: "auto"
370
+ }
371
+ }),
372
+ /* @__PURE__ */ B("div", {
373
+ className: "mt-auto flex min-h-8 items-center justify-between gap-2 pt-1",
374
+ children: [/* @__PURE__ */ B("div", {
375
+ className: "flex items-center gap-2",
376
+ children: [
377
+ /* @__PURE__ */ B("label", {
378
+ className: "flex h-8 w-8 items-center justify-center rounded-full text-text-muted transition hover:bg-muted hover:text-text-secondary",
379
+ title: "上传附件",
380
+ children: [/* @__PURE__ */ z("input", {
381
+ ref: i,
382
+ type: "file",
383
+ multiple: !0,
384
+ className: "hidden",
385
+ onChange: (e) => {
386
+ e.target.files && e.target.files.length > 0 && (d(Array.from(e.target.files)), e.target.value = "");
387
+ }
388
+ }), /* @__PURE__ */ z(E, { className: "h-[18px] w-[18px]" })]
389
+ }),
390
+ c ? /* @__PURE__ */ z(vt, { approvalPolicy: l }) : null,
391
+ x.length > 0 ? /* @__PURE__ */ z(dt, {
392
+ label: T || S,
393
+ title: T || S,
394
+ value: S,
395
+ onChange: (e) => w(e),
396
+ options: x.map((e) => ({
397
+ value: e.id,
398
+ label: e.display_name || e.id
399
+ }))
400
+ }) : null,
401
+ /* @__PURE__ */ z(dt, {
402
+ label: D(C),
403
+ title: "控制模型 thinking/reasoning 参数",
404
+ value: C,
405
+ onChange: (e) => ee(st(e)),
406
+ options: [
407
+ {
408
+ value: "auto",
409
+ label: "思考自动"
410
+ },
411
+ {
412
+ value: "enabled",
413
+ label: "开启思考"
414
+ },
415
+ {
416
+ value: "disabled",
417
+ label: "关闭思考"
418
+ }
419
+ ]
420
+ })
421
+ ]
422
+ }), /* @__PURE__ */ B("div", {
423
+ className: "flex items-center gap-1.5",
424
+ children: [n ? /* @__PURE__ */ z(lt, { indicator: n }) : null, /* @__PURE__ */ z("button", {
425
+ type: "submit",
426
+ disabled: !s && !a.trim() && e.length === 0,
427
+ className: Y("flex h-8 w-8 items-center justify-center rounded-full transition-all", s || a.trim() || e.length > 0 ? "bg-[#1f1f1f] text-white hover:opacity-80" : "bg-muted text-text-muted/45"),
428
+ title: s ? b : "发送消息",
429
+ children: s ? /* @__PURE__ */ z(oe, { className: "h-3.5 w-3.5 fill-current" }) : /* @__PURE__ */ z(t, { className: "h-[18px] w-[18px]" })
430
+ })]
431
+ })]
432
+ })
433
+ ]
434
+ })
435
+ })
436
+ })]
437
+ })
438
+ });
439
+ }
440
+ //#endregion
441
+ //#region src/components/ui/sheet.tsx
442
+ var bt = J.Root, xt = J.Portal, St = V.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ z(J.Overlay, {
443
+ className: Y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", e),
444
+ ...t,
445
+ ref: n
446
+ }));
447
+ St.displayName = J.Overlay.displayName;
448
+ var Ct = ve("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", {
449
+ variants: { side: {
450
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
451
+ bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
452
+ left: "inset-y-0 left-0 h-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
453
+ right: "inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right"
454
+ } },
455
+ defaultVariants: { side: "right" }
456
+ }), wt = V.forwardRef(({ side: e = "right", className: t, children: n, showOverlay: r = !0, showCloseButton: i = !0, ...a }, o) => /* @__PURE__ */ B(xt, { children: [r ? /* @__PURE__ */ z(St, {}) : null, /* @__PURE__ */ B(J.Content, {
457
+ ref: o,
458
+ className: Y(Ct({ side: e }), t),
459
+ ...a,
460
+ children: [n, i ? /* @__PURE__ */ B(J.Close, {
461
+ className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",
462
+ children: [/* @__PURE__ */ z(de, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", {
463
+ className: "sr-only",
464
+ children: "Close"
465
+ })]
466
+ }) : null]
467
+ })] }));
468
+ wt.displayName = J.Content.displayName;
469
+ var Tt = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
470
+ className: Y("flex flex-col space-y-2 text-center sm:text-left", e),
471
+ ...t
472
+ });
473
+ Tt.displayName = "SheetHeader";
474
+ var Et = ({ className: e, ...t }) => /* @__PURE__ */ z("div", {
475
+ className: Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", e),
476
+ ...t
477
+ });
478
+ Et.displayName = "SheetFooter";
479
+ var Dt = V.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ z(J.Title, {
480
+ ref: n,
481
+ className: Y("text-lg font-semibold text-foreground", e),
482
+ ...t
483
+ }));
484
+ Dt.displayName = J.Title.displayName;
485
+ var Ot = V.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ z(J.Description, {
486
+ ref: n,
487
+ className: Y("text-sm text-muted-foreground", e),
488
+ ...t
489
+ }));
490
+ Ot.displayName = J.Description.displayName;
491
+ //#endregion
492
+ //#region src/components/chat/ChatHeader.tsx
493
+ var kt = he(() => import("./NativeTerminalPanel-BTPHqbvY.js").then((e) => e.n).then((e) => ({ default: e.NativeTerminalPanel })));
494
+ function At({ availableModels: e, selectedModel: t, onSelectModel: n, selectedModelLabel: r, modelCatalogLoaded: i, modelSource: a, thinkingEnabled: o, thinkingMode: s, onSelectThinkingMode: c, compact: l = !1 }) {
495
+ let u = Y("rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300", l ? "w-full" : "max-w-[13rem]"), d = e.length > 1 ? /* @__PURE__ */ z("select", {
496
+ value: t,
497
+ onChange: (e) => n(e.target.value),
498
+ className: u,
499
+ children: e.map((e) => /* @__PURE__ */ z("option", {
500
+ value: e.id,
501
+ children: e.display_name || e.id
502
+ }, e.id))
503
+ }) : r ? /* @__PURE__ */ z("span", {
504
+ className: Y(u, "inline-flex max-w-full items-center", l ? "justify-start" : ""),
505
+ title: a || r,
506
+ children: /* @__PURE__ */ z("span", {
507
+ className: "truncate",
508
+ children: r
509
+ })
510
+ }) : /* @__PURE__ */ z("span", {
511
+ className: "text-sm text-slate-400",
512
+ children: i ? "未配置模型" : "Loading models..."
513
+ }), f = o ? /* @__PURE__ */ B("select", {
514
+ value: s,
515
+ onChange: (e) => c(e.target.value),
516
+ className: Y(u, l ? "" : "max-w-[9rem]"),
517
+ title: "控制模型 thinking/reasoning 参数",
518
+ children: [
519
+ /* @__PURE__ */ z("option", {
520
+ value: "auto",
521
+ children: "思考自动"
522
+ }),
523
+ /* @__PURE__ */ z("option", {
524
+ value: "enabled",
525
+ children: "开启思考"
526
+ }),
527
+ /* @__PURE__ */ z("option", {
528
+ value: "disabled",
529
+ children: "关闭思考"
530
+ })
531
+ ]
532
+ }) : null;
533
+ return /* @__PURE__ */ B("div", {
534
+ className: Y("flex min-w-0 gap-2", l ? "w-full flex-col" : "items-center"),
535
+ children: [d, f]
536
+ });
537
+ }
538
+ function jt({ agentName: e, currentSessionId: t, isMobile: n, sidebarOpen: r, mobileSidebarOpen: i, onToggleSidebar: a, availableModels: o, selectedModel: s, onSelectModel: l, selectedModelLabel: u, modelCatalogLoaded: d, modelSource: f, thinkingEnabled: m, thinkingMode: h, onSelectThinkingMode: g, mobileActionsOpen: _, onMobileActionsOpenChange: v, workspaceEnabled: y, onOpenWorkspace: b, nativeManagementLink: x, nativeTerminal: S, nativeLauncherMode: w = !1 }) {
539
+ let [E, D] = q(!1), te = !!S?.Enabled, O = z(n ? i ? T : ee : r ? T : ee, { className: "h-5 w-5" });
540
+ return /* @__PURE__ */ B(R, { children: [
541
+ /* @__PURE__ */ B("header", {
542
+ className: Y("flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4", n ? "pt-[calc(var(--safe-area-top)+0.5rem)]" : "h-12"),
543
+ children: [/* @__PURE__ */ B("div", {
544
+ className: "flex min-w-0 items-center gap-2",
545
+ children: [w ? null : /* @__PURE__ */ z("button", {
546
+ type: "button",
547
+ onClick: a,
548
+ className: "rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800",
549
+ "aria-label": n ? "打开历史记录" : "切换侧边栏",
550
+ children: O
551
+ }), /* @__PURE__ */ B("div", {
552
+ className: "min-w-0",
553
+ children: [/* @__PURE__ */ z("div", {
554
+ className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base",
555
+ children: e
556
+ }), /* @__PURE__ */ z("div", {
557
+ className: "text-[11px] text-slate-400 dark:text-slate-500",
558
+ children: w ? "原生运行时入口" : "智能体"
559
+ })]
560
+ })]
561
+ }), n ? /* @__PURE__ */ z("button", {
562
+ type: "button",
563
+ onClick: () => v(!0),
564
+ className: "rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800",
565
+ "aria-label": "打开会话操作",
566
+ children: /* @__PURE__ */ z(C, { className: "h-5 w-5" })
567
+ }) : /* @__PURE__ */ B("div", {
568
+ className: "flex min-w-0 items-center gap-2",
569
+ children: [
570
+ x ? /* @__PURE__ */ B("a", {
571
+ href: x.href,
572
+ target: "_blank",
573
+ rel: "noreferrer",
574
+ title: x.title,
575
+ className: "inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700",
576
+ children: [/* @__PURE__ */ z(c, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", { children: x.label })]
577
+ }) : null,
578
+ y ? /* @__PURE__ */ B("button", {
579
+ type: "button",
580
+ onClick: b,
581
+ className: "inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700",
582
+ children: [/* @__PURE__ */ z(p, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", { children: "Workspace" })]
583
+ }) : null,
584
+ te ? /* @__PURE__ */ B("button", {
585
+ type: "button",
586
+ onClick: () => D(!0),
587
+ className: "inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200",
588
+ children: [/* @__PURE__ */ z(M, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", { children: "TUI" })]
589
+ }) : null,
590
+ !w && n ? /* @__PURE__ */ z(At, {
591
+ availableModels: o,
592
+ selectedModel: s,
593
+ onSelectModel: l,
594
+ selectedModelLabel: u,
595
+ modelCatalogLoaded: d,
596
+ modelSource: f,
597
+ thinkingEnabled: m,
598
+ thinkingMode: h,
599
+ onSelectThinkingMode: g,
600
+ compact: !0
601
+ }) : null,
602
+ !w && t ? /* @__PURE__ */ B("span", {
603
+ className: "rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800",
604
+ children: ["ID: ", t.slice(0, 8)]
605
+ }) : null
606
+ ]
607
+ })]
608
+ }),
609
+ n ? /* @__PURE__ */ z(bt, {
610
+ open: _,
611
+ onOpenChange: v,
612
+ children: /* @__PURE__ */ B(wt, {
613
+ side: "bottom",
614
+ className: "rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900",
615
+ children: [/* @__PURE__ */ B(Tt, {
616
+ className: "text-left",
617
+ children: [/* @__PURE__ */ z(Dt, { children: "会话设置" }), /* @__PURE__ */ z(Ot, {
618
+ className: "sr-only",
619
+ children: "调整当前会话的模型和 Workspace 操作。"
620
+ })]
621
+ }), /* @__PURE__ */ B("div", {
622
+ className: "mt-6 flex flex-col gap-4",
623
+ children: [
624
+ y ? /* @__PURE__ */ B("button", {
625
+ type: "button",
626
+ onClick: () => {
627
+ v(!1), b();
628
+ },
629
+ className: "inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700",
630
+ children: [/* @__PURE__ */ z(p, { className: "h-4 w-4" }), "工作区文件"]
631
+ }) : null,
632
+ te ? /* @__PURE__ */ B("button", {
633
+ type: "button",
634
+ onClick: () => {
635
+ v(!1), D(!0);
636
+ },
637
+ className: "inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200",
638
+ children: [/* @__PURE__ */ z(M, { className: "h-4 w-4" }), "原生 TUI"]
639
+ }) : null,
640
+ x ? /* @__PURE__ */ B("a", {
641
+ href: x.href,
642
+ target: "_blank",
643
+ rel: "noreferrer",
644
+ title: x.title,
645
+ onClick: () => v(!1),
646
+ className: "inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700",
647
+ children: [/* @__PURE__ */ z(c, { className: "h-4 w-4" }), x.label]
648
+ }) : null,
649
+ w ? /* @__PURE__ */ z("div", {
650
+ className: "rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",
651
+ children: "当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。"
652
+ }) : /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ B("div", {
653
+ className: "space-y-2",
654
+ children: [/* @__PURE__ */ z("div", {
655
+ className: "text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500",
656
+ children: "模型"
657
+ }), /* @__PURE__ */ z(At, {
658
+ availableModels: o,
659
+ selectedModel: s,
660
+ onSelectModel: l,
661
+ selectedModelLabel: u,
662
+ modelCatalogLoaded: d,
663
+ modelSource: f,
664
+ thinkingEnabled: m,
665
+ thinkingMode: h,
666
+ onSelectThinkingMode: g,
667
+ compact: !0
668
+ })]
669
+ }), /* @__PURE__ */ B("div", {
670
+ className: "space-y-2",
671
+ children: [/* @__PURE__ */ z("div", {
672
+ className: "text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500",
673
+ children: "当前会话"
674
+ }), /* @__PURE__ */ z("div", {
675
+ className: "rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",
676
+ children: t ? /* @__PURE__ */ z("span", {
677
+ className: "break-all font-mono",
678
+ children: t
679
+ }) : "新对话尚未创建会话 ID"
680
+ })]
681
+ })] })
682
+ ]
683
+ })]
684
+ })
685
+ }) : null,
686
+ S && E ? /* @__PURE__ */ z(H, {
687
+ fallback: null,
688
+ children: /* @__PURE__ */ z(kt, {
689
+ capability: S,
690
+ open: E,
691
+ sessionId: t,
692
+ onClose: () => D(!1)
693
+ })
694
+ }) : null
695
+ ] });
696
+ }
697
+ //#endregion
698
+ //#region src/utils/markdown.js
699
+ function Mt(e) {
700
+ return e.replace(/<think>([\s\S]*?)(?:<\/think>|$)/gi, (e, t) => `\n> 💭 **思考过程**\n>\n${String(t || "").trim().split("\n").filter(Boolean).map((e) => `> ${e}`).join("\n")}\n\n`);
701
+ }
702
+ function Nt(e) {
703
+ return /^\s*\|(?:\s*[:\-]+\s*\|){2,}\s*$/.test(e);
704
+ }
705
+ function X(e) {
706
+ let t = e.trim();
707
+ return t.startsWith("|") ? t.split("|").length >= 4 : !1;
708
+ }
709
+ function Pt(e) {
710
+ let t = e.trim();
711
+ return t.startsWith("|") ? t.replace(/^\|/, "").replace(/\|\s*$/, "").split("|").map((e) => e.trim()) : [];
712
+ }
713
+ function Ft(e, t = "") {
714
+ return `${t}| ${e.join(" | ")} |`;
715
+ }
716
+ function It(e) {
717
+ let t = e.split("\n"), n = [], r = 0;
718
+ for (; r < t.length;) {
719
+ let e = t[r];
720
+ if (X(e) && r + 1 < t.length && Nt(t[r + 1])) {
721
+ let i = e.match(/^(\s*)/)?.[1] || "", a = Pt(e), o = Pt(t[r + 1]), s = [], c = r + 2, l = Math.max(a.length, o.length);
722
+ for (; c < t.length && X(t[c]);) {
723
+ let e = Pt(t[c]);
724
+ l = Math.max(l, e.length), s.push(e), c += 1;
725
+ }
726
+ let u = (e) => {
727
+ let t = [...e];
728
+ for (; t.length < l;) t.push("");
729
+ return t;
730
+ };
731
+ n.push(Ft(u(a), i)), n.push(Ft(((e) => {
732
+ let t = [...e];
733
+ for (; t.length < l;) t.push("---");
734
+ return t;
735
+ })(o), i));
736
+ for (let e of s) n.push(Ft(u(e), i));
737
+ r = c;
738
+ } else n.push(e), r += 1;
739
+ }
740
+ return n.join("\n");
741
+ }
742
+ function Lt(e) {
743
+ return Nt(e) || /\|\|/.test(e) || /\|(?:\s*[:\-]+\s*\|){2,}/.test(e) && /\|(?:[^|\n]*\|){2,}/.test(e);
744
+ }
745
+ function Rt(e) {
746
+ return Lt(e) ? e.replace(/\|\s*\|/g, "|\n|").split("\n").map((e) => e.trimEnd()).filter((e) => e.trim().length > 0) : [e];
747
+ }
748
+ function zt(e) {
749
+ return X(e) ? e.replace(/\|\s*(?:\*{1,2}|_{1,2})\s*$/u, "|") : e;
750
+ }
751
+ function Bt(e) {
752
+ let t = e.trim();
753
+ return X(t) ? t.split("|").slice(1, -1).length : 0;
754
+ }
755
+ function Vt(e) {
756
+ let t = e.match(/^(\s*)/)?.[1] || "", n = Bt(e);
757
+ return n < 2 ? "" : `${t}| ${Array.from({ length: n }, () => "---").join(" | ")} |`;
758
+ }
759
+ function Ht(e) {
760
+ let t = [];
761
+ for (let n of e.split("\n")) {
762
+ if (/^\s*\|\s*$/.test(n)) continue;
763
+ let e = n.match(/^(\s*)\|\s*([^|]+)$/);
764
+ if (e) {
765
+ t.push(`${e[1]}${e[2].trim()}`);
766
+ continue;
767
+ }
768
+ t.push(...Rt(n).map(zt));
769
+ }
770
+ let n = [];
771
+ for (let e = 0; e < t.length; e += 1) {
772
+ let r = t[e];
773
+ r.trim().length === 0 && X(n[n.length - 1] || "") && Nt(t[e + 1] || "") || n.push(r);
774
+ }
775
+ let r = [];
776
+ for (let e = 0; e < n.length; e += 1) {
777
+ let t = n[e], i = n[e + 1] || "";
778
+ if (r.push(t), X(t) && X(i) && !Nt(i) && Bt(t) === Bt(i)) {
779
+ let i = X(n[e - 1] || ""), a = t.match(/^(\s*)/)?.[1] || "";
780
+ if (!i && a.length === 0) {
781
+ let e = Vt(t);
782
+ e && r.push(e);
783
+ }
784
+ }
785
+ }
786
+ let i = [];
787
+ for (let e = 0; e < r.length; e += 1) {
788
+ let t = r[e], n = r[e + 1] || "", a = i[i.length - 1] || "", o = X(t) && (a.trim().length === 0 || !X(a)), s = X(t) && (n.trim().length === 0 || !X(n)), c = t.match(/^(\s*)/)?.[1] || "";
789
+ o && c.length === 0 && a.trim().length > 0 && i.push(""), i.push(t), s && c.length === 0 && n.trim().length > 0 && i.push("");
790
+ }
791
+ return i.join("\n");
792
+ }
793
+ function Ut(e) {
794
+ let t = e.replace(/^[\u200B-\u200D\uFEFF]+/u, ""), n = t.match(/^([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([##]{1,6})([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(\S.*)?$/u);
795
+ if (!n) return t;
796
+ let [, r, i, , a = ""] = n, o = r.replace(/[^\t ]/gu, " "), s = i.replace(/#/gu, "#");
797
+ return a ? `${o}${s} ${a}` : `${o}${s}`;
798
+ }
799
+ function Wt(e) {
800
+ let t = e;
801
+ return t = t.split("\n").map((e) => Ut(e)).join("\n"), t = t.replace(/^[ \t]+(#{1,6}\s*)/gm, "$1"), t = t.replace(/([^\n#])\s*(#{1,6}\s*[^\s|])/g, "$1\n\n$2"), t = t.replace(/^(#{1,6}\s*[^\n]+)\n(?!\n)/gm, "$1\n\n"), t = t.replace(/^(#{1,6}[^\n|]+?)\s*(\|)/gm, "$1\n$2"), t = t.replace(/([。;;::])\s*(\d+\.\s*)/g, "$1\n$2"), t = t.replace(/([^\n\s])(\d+\.\s+)/g, "$1\n$2"), t = t.replace(/([。;;::\.])\s*-(?!-)\s*/g, "$1\n- "), t = t.replace(/([^\n\s-])-\s+/g, "$1\n- "), t = t.replace(/^-(?!-)(\S)/gm, "- $1"), t = Ht(t), t = t.replace(/\n{3,}/g, "\n\n"), t.trim();
802
+ }
803
+ function Gt(e) {
804
+ return e.map((t, n) => {
805
+ if (n % 2 == 1) return t;
806
+ let r = Wt(t), i = n > 0, a = n < e.length - 1;
807
+ return r ? (i && !r.startsWith("\n") && (r = `\n${r}`), a && !r.endsWith("\n") && (r = `${r}\n`), r) : i && a ? "\n\n" : i || a ? "\n" : r;
808
+ });
809
+ }
810
+ function Kt(e) {
811
+ if (!e) return e;
812
+ let t = String(e).replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
813
+ return t = Mt(t), t = It(t), (t.match(/```/g) || []).length % 2 == 1 && (t = `${t}\n\`\`\``), Gt(t.split("```")).join("```").trim();
814
+ }
815
+ //#endregion
816
+ //#region src/components/MessageMarkdown.tsx
817
+ var qt = me.lazy(() => import("./CodeBlock-Cbl6cxYC.js").then((e) => ({ default: e.CodeBlock }))), Jt = me.lazy(() => import("./MermaidBlock-BFNE1NN8.js").then((e) => ({ default: e.MermaidBlock }))), Yt = me.lazy(() => import("./MathMessageMarkdown-DbMSeHQa.js").then((e) => ({ default: e.MathMessageMarkdown })));
818
+ function Xt(e) {
819
+ return /\$[^$]+\$|\$\$[^$]+\$\$/.test(e);
820
+ }
821
+ var Zt = {
822
+ h1({ children: e }) {
823
+ return /* @__PURE__ */ z("h1", {
824
+ className: "mb-3.5 mt-5 text-[17px] font-semibold text-foreground",
825
+ children: e
826
+ });
827
+ },
828
+ h2({ children: e }) {
829
+ return /* @__PURE__ */ z("h2", {
830
+ className: "mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground",
831
+ children: e
832
+ });
833
+ },
834
+ h3({ children: e }) {
835
+ return /* @__PURE__ */ z("h3", {
836
+ className: "mb-2 mt-3.5 text-[14px] font-semibold text-foreground",
837
+ children: e
838
+ });
839
+ },
840
+ p({ children: e }) {
841
+ return /* @__PURE__ */ z("p", {
842
+ className: "mb-2.5 min-w-0 break-words leading-[1.65] text-foreground",
843
+ children: e
844
+ });
845
+ },
846
+ ul({ children: e }) {
847
+ return /* @__PURE__ */ z("ul", {
848
+ className: "mb-3 list-disc space-y-1.5 pl-5 text-foreground",
849
+ children: e
850
+ });
851
+ },
852
+ ol({ children: e }) {
853
+ return /* @__PURE__ */ z("ol", {
854
+ className: "mb-3 list-decimal space-y-1.5 pl-8 text-foreground",
855
+ children: e
856
+ });
857
+ },
858
+ li({ children: e }) {
859
+ return /* @__PURE__ */ z("li", {
860
+ className: "min-w-0 break-words pl-1 leading-6 text-foreground",
861
+ children: e
862
+ });
863
+ },
864
+ strong({ children: e }) {
865
+ return /* @__PURE__ */ z("strong", {
866
+ className: "font-semibold text-foreground",
867
+ children: e
868
+ });
869
+ },
870
+ blockquote({ children: e }) {
871
+ return /* @__PURE__ */ z("blockquote", {
872
+ className: "mb-3 border-l-2 border-border pl-4 text-text-secondary",
873
+ children: e
874
+ });
875
+ },
876
+ code({ className: e, children: t, ...n }) {
877
+ let r = /language-(\w+)/.exec(e || ""), i = String(t ?? "");
878
+ if (!r && !i.includes("\n")) return /* @__PURE__ */ z("code", {
879
+ className: "rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[13.5px] text-text-primary before:content-none after:content-none",
880
+ ...n,
881
+ children: t
882
+ });
883
+ let a = r ? r[1] : "";
884
+ return a === "mermaid" ? /* @__PURE__ */ z(H, {
885
+ fallback: /* @__PURE__ */ z("div", { className: "h-32 animate-pulse rounded bg-muted" }),
886
+ children: /* @__PURE__ */ z(Jt, { chart: i })
887
+ }) : /* @__PURE__ */ z(H, {
888
+ fallback: /* @__PURE__ */ z("pre", {
889
+ className: "p-4 text-sm",
890
+ children: i
891
+ }),
892
+ children: /* @__PURE__ */ z(qt, {
893
+ language: a,
894
+ value: i
895
+ })
896
+ });
897
+ },
898
+ table({ children: e, ...t }) {
899
+ return /* @__PURE__ */ z("div", {
900
+ className: "mb-3 max-w-full overflow-x-auto",
901
+ children: /* @__PURE__ */ z("table", {
902
+ className: "w-full min-w-max border-collapse text-sm text-foreground",
903
+ ...t,
904
+ children: e
905
+ })
906
+ });
907
+ },
908
+ th({ children: e, ...t }) {
909
+ return /* @__PURE__ */ z("th", {
910
+ className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
911
+ ...t,
912
+ children: e
913
+ });
914
+ },
915
+ td({ children: e, ...t }) {
916
+ return /* @__PURE__ */ z("td", {
917
+ className: "border-b border-border px-3 py-2 text-text-secondary",
918
+ ...t,
919
+ children: e
920
+ });
921
+ },
922
+ a({ children: e, href: t, ...n }) {
923
+ return /* @__PURE__ */ z("a", {
924
+ href: t,
925
+ className: "text-primary hover:underline",
926
+ target: "_blank",
927
+ rel: "noopener noreferrer",
928
+ ...n,
929
+ children: e
930
+ });
931
+ }
932
+ }, Qt = me.memo(({ content: e }) => {
933
+ let t = Kt(e);
934
+ return /* @__PURE__ */ z("div", {
935
+ className: "max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
936
+ children: /* @__PURE__ */ z(ye, {
937
+ remarkPlugins: [be, xe],
938
+ components: Zt,
939
+ children: t
940
+ })
941
+ });
942
+ }), Z = me.memo(({ content: e }) => Xt(e) ? /* @__PURE__ */ z(H, {
943
+ fallback: /* @__PURE__ */ z(Qt, { content: e }),
944
+ children: /* @__PURE__ */ z(Yt, { content: e })
945
+ }) : /* @__PURE__ */ z(Qt, { content: e })), $t = /^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;
946
+ function en(e) {
947
+ let t = [], n = /* @__PURE__ */ new Map(), r = null;
948
+ for (let i of e.split("\n")) {
949
+ let e = i.match($t);
950
+ if (e) {
951
+ let a = e[2], o = n.get(a);
952
+ if (o) {
953
+ o.lines.push(i), r = o;
954
+ continue;
955
+ }
956
+ r = {
957
+ oldPath: e[1],
958
+ path: a,
959
+ lines: [i]
960
+ }, n.set(a, r), t.push(r);
961
+ continue;
962
+ }
963
+ r?.lines.push(i);
964
+ }
965
+ return t;
966
+ }
967
+ function tn(e) {
968
+ let t = 0, n = 0;
969
+ for (let r of e.lines) r.startsWith("+") && !r.startsWith("+++") ? t += 1 : r.startsWith("-") && !r.startsWith("---") && (n += 1);
970
+ return {
971
+ added: t,
972
+ removed: n
973
+ };
974
+ }
975
+ function nn(e) {
976
+ return /^diff --git /m.test(e);
977
+ }
978
+ //#endregion
979
+ //#region src/components/chat/ProcessingBlocksView.tsx
980
+ function rn({ summary: e, children: t, defaultOpen: n = !1, streaming: r = !1 }) {
981
+ let [a, o] = q(n);
982
+ return /* @__PURE__ */ B("div", {
983
+ className: "mb-1.5",
984
+ children: [/* @__PURE__ */ B("button", {
985
+ type: "button",
986
+ onClick: () => o((e) => !e),
987
+ className: "flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] text-slate-500 transition-colors hover:bg-slate-100/70 dark:text-slate-400 dark:hover:bg-slate-800/40",
988
+ children: [r ? /* @__PURE__ */ z(v, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }) : /* @__PURE__ */ z(i, { className: Y("h-3.5 w-3.5 text-slate-400 transition-transform", a && "rotate-90") }), /* @__PURE__ */ z("span", {
989
+ className: "min-w-0 flex-1 truncate",
990
+ children: e
991
+ })]
992
+ }), a && /* @__PURE__ */ z("div", {
993
+ className: "mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60",
994
+ children: t
995
+ })]
996
+ });
997
+ }
998
+ function an({ block: e }) {
999
+ let [t, n] = q(!1), r = e.status === "streaming", a = e.content.length, o = `${e.id}-thinking-detail`;
1000
+ return /* @__PURE__ */ B("div", {
1001
+ className: "mb-1.5 min-w-0",
1002
+ children: [/* @__PURE__ */ B("button", {
1003
+ type: "button",
1004
+ "aria-expanded": t,
1005
+ "aria-controls": o,
1006
+ onClick: () => n((e) => !e),
1007
+ className: "flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] leading-5 text-slate-400 transition-colors hover:bg-slate-100/70 hover:text-slate-500 dark:text-slate-500 dark:hover:bg-slate-800/40 dark:hover:text-slate-400",
1008
+ children: [
1009
+ /* @__PURE__ */ z(A, { className: Y("h-3.5 w-3.5 shrink-0", r && "animate-pulse motion-reduce:animate-none") }),
1010
+ /* @__PURE__ */ z("span", {
1011
+ className: "min-w-0 truncate",
1012
+ children: r ? "思考中" : "已思考"
1013
+ }),
1014
+ !r && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("span", {
1015
+ className: "text-slate-300 dark:text-slate-600",
1016
+ children: "·"
1017
+ }), /* @__PURE__ */ B("span", {
1018
+ className: "font-mono text-xs text-slate-400 dark:text-slate-500",
1019
+ children: [a, " 字"]
1020
+ })] }),
1021
+ /* @__PURE__ */ z(i, { className: Y("h-3.5 w-3.5 shrink-0 transition-transform", t && "rotate-180") })
1022
+ ]
1023
+ }), t && e.content && /* @__PURE__ */ z("div", {
1024
+ id: o,
1025
+ className: "custom-scrollbar mt-1.5 max-h-[min(46vh,28rem)] overflow-y-auto border-l border-slate-200/80 pl-3.5 text-[12px] leading-5 text-slate-500 dark:border-slate-700/60 dark:text-slate-400 [&_h1]:!mb-2 [&_h1]:!mt-3 [&_h1]:!text-[13px] [&_h2]:!mb-1.5 [&_h2]:!mt-3 [&_h2]:!text-[12px] [&_h3]:!mb-1 [&_h3]:!mt-2.5 [&_h3]:!text-[12px] [&_li]:!text-[12px] [&_li]:!leading-5 [&_p]:!my-1.5 [&_p]:!text-[12px] [&_p]:!leading-5 [&_p]:!text-slate-500 dark:[&_p]:!text-slate-400 [&_pre]:!my-1.5",
1026
+ children: /* @__PURE__ */ z(Z, { content: e.content })
1027
+ })]
1028
+ });
1029
+ }
1030
+ function on({ block: e, tool: t, isStreaming: n, onRespondToApproval: r, onRespondToAguiApproval: i }) {
1031
+ let a = t?.status ?? e.status, o = t?.args ?? e.args, s = t?.output ?? e.output, c = e.extra || {}, l = c.approvalStatus || t?.approvalStatus, u = c.approvalRequestId || t?.approvalRequestId, d = c.approvalMessage || t?.approvalMessage, f = c.approvalProtocol || t?.approvalProtocol, p = c.previousResponseId || t?.previousResponseId, m = a === "running", h = a === "error", g = a === "paused", _ = h ? "执行失败" : l === "pending" ? "等待确认" : l === "rejected" ? "已拒绝" : m ? l === "approved" ? "已授权 · 执行中" : "正在运行" : l === "approved" ? "已授权" : g ? "已暂停" : "已完成", v = h ? "text-rose-500 dark:text-rose-400" : g ? "text-amber-500 dark:text-amber-400" : m ? "text-slate-500 dark:text-slate-400" : "text-slate-400 dark:text-slate-500";
1032
+ return /* @__PURE__ */ z(rn, {
1033
+ streaming: m && !o,
1034
+ defaultOpen: l === "pending" || g,
1035
+ summary: /* @__PURE__ */ B("span", {
1036
+ className: "flex items-center gap-1.5",
1037
+ children: [
1038
+ /* @__PURE__ */ z(ue, { className: Y("h-3.5 w-3.5 shrink-0", v) }),
1039
+ /* @__PURE__ */ z("span", {
1040
+ className: v,
1041
+ children: _
1042
+ }),
1043
+ /* @__PURE__ */ z("span", {
1044
+ className: "truncate font-medium text-slate-600 dark:text-slate-300",
1045
+ children: e.toolName
1046
+ }),
1047
+ m && o && /* @__PURE__ */ z("span", {
1048
+ className: "ml-0.5 animate-pulse text-slate-400",
1049
+ children: "…"
1050
+ })
1051
+ ]
1052
+ }),
1053
+ children: /* @__PURE__ */ B("div", {
1054
+ className: "flex flex-col gap-2.5 py-1 text-[13px]",
1055
+ children: [
1056
+ u && l === "pending" && /* @__PURE__ */ B("section", {
1057
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-slate-200/90 bg-white/70 px-2.5 py-2 font-sans text-[12px] text-slate-600 shadow-[0_1px_2px_rgba(15,23,42,0.03)] dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300",
1058
+ children: [/* @__PURE__ */ B("div", {
1059
+ className: "flex min-w-0 flex-1 items-center gap-2",
1060
+ children: [
1061
+ /* @__PURE__ */ z("span", {
1062
+ className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400",
1063
+ "aria-hidden": "true"
1064
+ }),
1065
+ /* @__PURE__ */ z("span", {
1066
+ className: "shrink-0 font-medium text-slate-700 dark:text-slate-200",
1067
+ children: "需要确认"
1068
+ }),
1069
+ /* @__PURE__ */ z("span", {
1070
+ className: "min-w-0 truncate text-slate-500 dark:text-slate-400",
1071
+ children: d || "允许后将执行此工具调用。"
1072
+ })
1073
+ ]
1074
+ }), /* @__PURE__ */ B("div", {
1075
+ className: "flex shrink-0 items-center gap-1.5",
1076
+ children: [/* @__PURE__ */ z("button", {
1077
+ type: "button",
1078
+ disabled: n,
1079
+ onClick: () => f === "ag-ui" ? i?.({
1080
+ interruptId: u || "",
1081
+ approve: !0
1082
+ }) : r?.({
1083
+ approvalRequestId: u || "",
1084
+ approve: !0,
1085
+ previousResponseId: p
1086
+ }),
1087
+ className: "inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-55",
1088
+ children: "允许执行"
1089
+ }), /* @__PURE__ */ z("button", {
1090
+ type: "button",
1091
+ disabled: n,
1092
+ onClick: () => f === "ag-ui" ? i?.({
1093
+ interruptId: u || "",
1094
+ approve: !1
1095
+ }) : r?.({
1096
+ approvalRequestId: u || "",
1097
+ approve: !1,
1098
+ previousResponseId: p
1099
+ }),
1100
+ className: "inline-flex h-7 items-center rounded-md px-2 text-[12px] font-medium text-slate-500 transition hover:bg-slate-100 hover:text-rose-600 disabled:opacity-55 dark:text-slate-400 dark:hover:bg-slate-800",
1101
+ children: "拒绝"
1102
+ })]
1103
+ })]
1104
+ }),
1105
+ u && l && l !== "pending" && /* @__PURE__ */ B("div", {
1106
+ className: "flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400",
1107
+ children: [
1108
+ /* @__PURE__ */ z("span", { children: l === "approved" ? "已授权" : "已拒绝" }),
1109
+ l === "approved" && m ? /* @__PURE__ */ z("span", { children: "· 工具执行中" }) : null,
1110
+ l === "approved" && h ? /* @__PURE__ */ z("span", { children: "· 工具执行失败" }) : null
1111
+ ]
1112
+ }),
1113
+ o ? /* @__PURE__ */ z(dn, {
1114
+ label: "入参",
1115
+ value: o,
1116
+ tone: "input"
1117
+ }) : null,
1118
+ s ? sn(e.toolName, s, h) : null
1119
+ ]
1120
+ })
1121
+ });
1122
+ }
1123
+ function sn(e, t, n) {
1124
+ if (nn(t)) return /* @__PURE__ */ z(cn, { output: t });
1125
+ let r = e.toLowerCase();
1126
+ if (r.includes("web_search") || r.includes("search")) {
1127
+ let e = ln(t);
1128
+ if (e.length > 0) return /* @__PURE__ */ z(un, { sources: e });
1129
+ }
1130
+ return /* @__PURE__ */ z(dn, {
1131
+ label: "输出",
1132
+ value: t,
1133
+ tone: n ? "error" : "output"
1134
+ });
1135
+ }
1136
+ function cn({ output: e }) {
1137
+ let t = en(e), [n, r] = q(!1), i = n ? t : t.slice(0, 3);
1138
+ return /* @__PURE__ */ B("div", {
1139
+ className: "my-2 overflow-hidden rounded-xl border border-border bg-background",
1140
+ children: [
1141
+ /* @__PURE__ */ B("div", {
1142
+ className: "flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-medium text-text-secondary",
1143
+ children: [/* @__PURE__ */ z(d, { className: "h-3.5 w-3.5 text-primary" }), /* @__PURE__ */ B("span", { children: [
1144
+ "改动 ",
1145
+ t.length,
1146
+ " 个文件"
1147
+ ] })]
1148
+ }),
1149
+ /* @__PURE__ */ z("div", {
1150
+ className: "flex flex-col",
1151
+ children: i.map((e) => {
1152
+ let { added: t, removed: n } = tn(e);
1153
+ return /* @__PURE__ */ B("div", {
1154
+ className: "group/file-change-row flex min-w-0 items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-muted",
1155
+ children: [/* @__PURE__ */ z("span", {
1156
+ className: "min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary",
1157
+ children: e.path
1158
+ }), /* @__PURE__ */ B("span", {
1159
+ className: "flex-shrink-0 text-[11px] font-mono",
1160
+ children: [
1161
+ /* @__PURE__ */ B("span", {
1162
+ className: "text-emerald-600",
1163
+ children: ["+", t]
1164
+ }),
1165
+ " ",
1166
+ /* @__PURE__ */ B("span", {
1167
+ className: "text-rose-500",
1168
+ children: ["−", n]
1169
+ })
1170
+ ]
1171
+ })]
1172
+ }, e.path);
1173
+ })
1174
+ }),
1175
+ t.length > 3 ? /* @__PURE__ */ z("button", {
1176
+ type: "button",
1177
+ onClick: () => r((e) => !e),
1178
+ className: "flex w-full items-center justify-center gap-1 border-t border-border py-1.5 text-xs text-text-muted transition hover:bg-muted hover:text-text-primary",
1179
+ children: n ? "收起" : `展开剩余 ${t.length - 3} 个文件`
1180
+ }) : null
1181
+ ]
1182
+ });
1183
+ }
1184
+ function ln(e) {
1185
+ try {
1186
+ let t = JSON.parse(e), n = Array.isArray(t) ? t : t?.results ?? t?.sources ?? [];
1187
+ return Array.isArray(n) ? n.map((e) => {
1188
+ let t = e, n = String(t?.url ?? t?.link ?? t?.href ?? ""), r = String(t?.title ?? t?.name ?? n);
1189
+ return n ? {
1190
+ url: n,
1191
+ title: r
1192
+ } : null;
1193
+ }).filter((e) => e !== null) : [];
1194
+ } catch {
1195
+ return [];
1196
+ }
1197
+ }
1198
+ function un({ sources: e }) {
1199
+ return /* @__PURE__ */ z("div", {
1200
+ className: "mt-2 flex min-w-0",
1201
+ children: /* @__PURE__ */ B("span", {
1202
+ className: "group/web-search-sources relative inline-flex min-w-0",
1203
+ children: [/* @__PURE__ */ B("button", {
1204
+ type: "button",
1205
+ className: "inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md border border-border bg-surface px-2 text-xs text-text-secondary transition-colors hover:bg-muted hover:text-text-primary",
1206
+ children: [/* @__PURE__ */ z(m, {
1207
+ className: "h-3.5 w-3.5 shrink-0",
1208
+ strokeWidth: 1.7
1209
+ }), /* @__PURE__ */ B("span", { children: ["来源 · ", e.length] })]
1210
+ }), /* @__PURE__ */ z("span", {
1211
+ className: "absolute bottom-full left-0 z-30 hidden max-w-[calc(100vw-3rem)] pb-1 group-hover/web-search-sources:block",
1212
+ children: /* @__PURE__ */ z("span", {
1213
+ className: "block w-[min(26rem,calc(100vw-3rem))] rounded-xl border border-border bg-popover p-2 text-left text-text-primary shadow-2xl",
1214
+ children: /* @__PURE__ */ z("span", {
1215
+ className: "flex min-w-0 flex-col gap-1",
1216
+ children: e.map((e, t) => /* @__PURE__ */ B("a", {
1217
+ href: e.url,
1218
+ target: "_blank",
1219
+ rel: "noopener noreferrer",
1220
+ className: "flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-sm leading-5 text-text-secondary transition-colors hover:bg-muted hover:text-text-primary",
1221
+ children: [/* @__PURE__ */ z(m, {
1222
+ className: "h-3.5 w-3.5 shrink-0",
1223
+ strokeWidth: 1.7
1224
+ }), /* @__PURE__ */ z("span", {
1225
+ className: "min-w-0 flex-1 truncate",
1226
+ children: e.title
1227
+ })]
1228
+ }, `${e.url}-${t}`))
1229
+ })
1230
+ })
1231
+ })]
1232
+ })
1233
+ });
1234
+ }
1235
+ function dn({ label: e, tone: t, value: n }) {
1236
+ return /* @__PURE__ */ B("div", { children: [/* @__PURE__ */ z("div", {
1237
+ className: "mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400",
1238
+ children: e
1239
+ }), /* @__PURE__ */ z("pre", {
1240
+ className: Y("custom-scrollbar max-h-60 overflow-auto rounded-lg px-3 py-2 text-[12.5px] leading-relaxed whitespace-pre-wrap break-all", t === "error" ? "bg-rose-50/60 text-rose-700 dark:bg-rose-950/20 dark:text-rose-200" : t === "output" ? "bg-emerald-50/40 text-emerald-800 dark:bg-emerald-950/20 dark:text-emerald-200" : "bg-slate-50 text-slate-700 dark:bg-slate-900/40 dark:text-slate-200"),
1241
+ children: n
1242
+ })] });
1243
+ }
1244
+ function fn({ block: e }) {
1245
+ return e.content ? /* @__PURE__ */ z("div", {
1246
+ className: "w-full break-words py-0.5 text-[14px] leading-[1.65]",
1247
+ children: /* @__PURE__ */ z(Z, { content: e.content })
1248
+ }) : null;
1249
+ }
1250
+ function pn({ message: e, isStreaming: t, onRespondToApproval: n, onRespondToAguiApproval: r }) {
1251
+ return /* @__PURE__ */ z("div", {
1252
+ className: "mb-3 min-w-0",
1253
+ children: (e.blocks ?? []).map((i) => i.type === "thinking" ? /* @__PURE__ */ z(an, { block: i }, i.id) : i.type === "tool" ? /* @__PURE__ */ z(on, {
1254
+ block: i,
1255
+ tool: e.tools?.[i.toolName],
1256
+ isStreaming: t,
1257
+ onRespondToApproval: n,
1258
+ onRespondToAguiApproval: r
1259
+ }, i.id) : /* @__PURE__ */ z(fn, { block: i }, i.id))
1260
+ });
1261
+ }
1262
+ //#endregion
1263
+ //#region src/stores/streaming.ts
1264
+ var mn = (e) => Object.keys(e).length > 0, hn = (e, t) => {
1265
+ let n = { ...e };
1266
+ return delete n[t], n;
1267
+ }, gn = L()((e, t) => ({
1268
+ isStreaming: !1,
1269
+ currentRunId: "",
1270
+ stopRequested: !1,
1271
+ activity: null,
1272
+ sessionActivities: {},
1273
+ sessionStreaming: {},
1274
+ banner: null,
1275
+ lastSeqId: 0,
1276
+ activeInvocationId: "",
1277
+ setStreaming: (t) => e({ isStreaming: t }),
1278
+ setBanner: (t) => e({ banner: t ? {
1279
+ ...t,
1280
+ createdAt: Date.now()
1281
+ } : null }),
1282
+ setLastSeqId: (t) => e({ lastSeqId: t }),
1283
+ setActiveInvocationId: (t) => e({ activeInvocationId: t }),
1284
+ setSessionStreaming: (t, n) => e((e) => {
1285
+ let r = String(t || "");
1286
+ if (!r) return { isStreaming: n };
1287
+ let i = hn(e.sessionStreaming, r), a = n ? {
1288
+ ...i,
1289
+ [r]: !0
1290
+ } : i;
1291
+ return {
1292
+ sessionStreaming: a,
1293
+ isStreaming: mn(a)
1294
+ };
1295
+ }),
1296
+ isSessionStreaming: (e) => {
1297
+ let n = String(e || "");
1298
+ return !!(n && t().sessionStreaming[n]);
1299
+ },
1300
+ getSessionActivity: (e) => {
1301
+ let n = String(e || "");
1302
+ return n && t().sessionActivities[n] || null;
1303
+ },
1304
+ setCurrentRunId: (t) => e({ currentRunId: t }),
1305
+ requestStop: () => e({ stopRequested: !0 }),
1306
+ beginActivity: (t) => e({
1307
+ stopRequested: !1,
1308
+ activity: {
1309
+ runId: t.runId,
1310
+ source: t.source || "run",
1311
+ status: t.status || "running",
1312
+ phase: t.phase,
1313
+ detail: t.detail,
1314
+ startedAt: Date.now(),
1315
+ lastEventAt: Date.now(),
1316
+ eventCount: 0
1317
+ }
1318
+ }),
1319
+ updateActivity: (t) => e((e) => {
1320
+ let n = String(t.sessionId || ""), r = n ? e.sessionActivities[n] : e.activity, i = r ? {
1321
+ ...r,
1322
+ source: t.source || r.source,
1323
+ status: t.status || r.status,
1324
+ phase: t.phase || r.phase,
1325
+ detail: t.detail === void 0 ? r.detail : t.detail,
1326
+ lastEventAt: Date.now(),
1327
+ eventCount: r.eventCount + (t.countEvent === !1 ? 0 : 1)
1328
+ } : {
1329
+ source: t.source || "run",
1330
+ status: t.status || "running",
1331
+ phase: t.phase || "正在运行",
1332
+ detail: t.detail,
1333
+ startedAt: Date.now(),
1334
+ lastEventAt: Date.now(),
1335
+ eventCount: t.countEvent === !1 ? 0 : 1
1336
+ };
1337
+ return n ? {
1338
+ isStreaming: mn(e.sessionStreaming),
1339
+ sessionActivities: {
1340
+ ...e.sessionActivities,
1341
+ [n]: i
1342
+ },
1343
+ activity: i
1344
+ } : { activity: i };
1345
+ }),
1346
+ stopActivity: (t) => e((e) => ({
1347
+ isStreaming: !1,
1348
+ stopRequested: !0,
1349
+ activity: e.activity ? {
1350
+ ...e.activity,
1351
+ status: "stopped",
1352
+ phase: "已断开输出流",
1353
+ detail: t || "前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。",
1354
+ lastEventAt: Date.now()
1355
+ } : null
1356
+ })),
1357
+ stopSessionActivity: (t, n) => e((e) => {
1358
+ let r = String(t || "");
1359
+ if (!r) return {};
1360
+ let i = e.sessionActivities[r];
1361
+ if (!i) return {};
1362
+ let a = {
1363
+ ...i,
1364
+ status: "stopped",
1365
+ phase: "已断开输出流",
1366
+ detail: n || "前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。",
1367
+ lastEventAt: Date.now()
1368
+ }, o = {
1369
+ ...e.sessionActivities,
1370
+ [r]: a
1371
+ }, s = hn(e.sessionStreaming, r);
1372
+ return {
1373
+ isStreaming: mn(s),
1374
+ activity: a,
1375
+ sessionActivities: o,
1376
+ sessionStreaming: s
1377
+ };
1378
+ }),
1379
+ clearActivity: () => e({ activity: null }),
1380
+ clearSessionActivity: (t) => e((e) => {
1381
+ let n = String(t || "");
1382
+ if (!n) return {};
1383
+ let { [n]: r, ...i } = e.sessionActivities, a = hn(e.sessionStreaming, n);
1384
+ return {
1385
+ sessionActivities: i,
1386
+ sessionStreaming: a,
1387
+ isStreaming: mn(a),
1388
+ activity: e.activity === r ? null : e.activity
1389
+ };
1390
+ }),
1391
+ resetRun: () => e({
1392
+ isStreaming: !1,
1393
+ currentRunId: "",
1394
+ stopRequested: !1,
1395
+ activity: null,
1396
+ sessionActivities: {},
1397
+ sessionStreaming: {},
1398
+ lastSeqId: 0,
1399
+ activeInvocationId: ""
1400
+ })
1401
+ }));
1402
+ //#endregion
1403
+ //#region src/components/chat/StatusBanner.tsx
1404
+ function _n({ onRetry: e }) {
1405
+ let t = gn((e) => e.banner);
1406
+ if (!t) return null;
1407
+ let n = t.kind === "rate_limited" ? /* @__PURE__ */ z(vn, {
1408
+ message: t.message,
1409
+ retryAfterSec: t.retryAfterSec
1410
+ }, t.createdAt || `${t.sessionId || ""}:${t.retryAfterSec || 0}`) : null, r = {
1411
+ rate_limited: {
1412
+ icon: /* @__PURE__ */ z(fe, { className: "h-4 w-4 text-amber-500" }),
1413
+ bg: "border-amber-200/70 bg-amber-50/70 dark:border-amber-900/40 dark:bg-amber-950/20",
1414
+ text: "text-amber-700 dark:text-amber-200",
1415
+ label: n
1416
+ },
1417
+ network: {
1418
+ icon: /* @__PURE__ */ z(v, { className: "h-4 w-4 animate-spin text-text-secondary" }),
1419
+ bg: "border-border/70 bg-muted/60",
1420
+ text: "text-text-secondary",
1421
+ label: t.message || "网络异常,正在重连…"
1422
+ },
1423
+ error: {
1424
+ icon: /* @__PURE__ */ z(le, { className: "h-4 w-4 text-rose-500" }),
1425
+ bg: "border-rose-200/70 bg-rose-50/70 dark:border-rose-900/40 dark:bg-rose-950/20",
1426
+ text: "text-rose-600 dark:text-rose-300",
1427
+ label: t.message || "运行失败,请重试"
1428
+ }
1429
+ }[t.kind];
1430
+ return /* @__PURE__ */ B("div", {
1431
+ className: Y("mx-auto mb-3 flex w-full max-w-3xl items-center gap-2.5 rounded-xl border px-3.5 py-2.5 text-sm shadow-sm", r.bg, r.text),
1432
+ role: "status",
1433
+ children: [
1434
+ r.icon,
1435
+ /* @__PURE__ */ z("span", {
1436
+ className: "min-w-0 flex-1 truncate",
1437
+ children: r.label
1438
+ }),
1439
+ t.kind === "error" && e ? /* @__PURE__ */ B("button", {
1440
+ type: "button",
1441
+ onClick: e,
1442
+ className: "flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium text-rose-600 transition hover:bg-rose-100 dark:text-rose-300 dark:hover:bg-rose-950/40",
1443
+ children: [/* @__PURE__ */ z(ne, { className: "h-3 w-3" }), "重试"]
1444
+ }) : null
1445
+ ]
1446
+ });
1447
+ }
1448
+ function vn({ message: e, retryAfterSec: t }) {
1449
+ let [n, r] = q(t || 0);
1450
+ return W(() => {
1451
+ if (!t) return;
1452
+ let e = setInterval(() => {
1453
+ r((e) => e > 0 ? e - 1 : 0);
1454
+ }, 1e3);
1455
+ return () => clearInterval(e);
1456
+ }, [t]), n > 0 ? `${e}(${n}s 后可重试)` : e;
1457
+ }
1458
+ //#endregion
1459
+ //#region src/utils/feedback.js
1460
+ function Q(e) {
1461
+ return String(e || "").trim();
1462
+ }
1463
+ function yn(e) {
1464
+ let t = Q(e).toLowerCase();
1465
+ return t === "up" || t === "down" ? t : "";
1466
+ }
1467
+ function bn(e) {
1468
+ if (!e || typeof e != "object") return null;
1469
+ let t = yn(e.Rating || e.rating);
1470
+ return t ? {
1471
+ agentId: Q(e.AgentId || e.agentId),
1472
+ sessionId: Q(e.SessionId || e.sessionId),
1473
+ responseId: Q(e.ResponseId || e.responseId),
1474
+ eventId: Q(e.EventId || e.eventId),
1475
+ rating: t,
1476
+ comment: String(e.Comment ?? e.comment ?? ""),
1477
+ traceId: Q(e.TraceId || e.traceId),
1478
+ rootSpanId: Q(e.RootSpanId || e.rootSpanId),
1479
+ updatedAt: Q(e.UpdatedAt || e.updatedAt)
1480
+ } : null;
1481
+ }
1482
+ function xn(e, t, n) {
1483
+ return !!(e?.role === "model" && Q(e.responseId) && Q(e.eventId) && !(t && n));
1484
+ }
1485
+ function Sn({ agentId: e, sessionId: t, message: n }) {
1486
+ let r = Q(n?.responseId);
1487
+ if (!r) throw Error("Message missing response id");
1488
+ return {
1489
+ AgentId: Q(e),
1490
+ SessionId: Q(t),
1491
+ ResponseId: r
1492
+ };
1493
+ }
1494
+ function Cn({ agentId: e, sessionId: t, message: n, rating: r, comment: i = "" }) {
1495
+ let a = yn(r);
1496
+ if (!a) throw Error("Feedback rating must be up or down");
1497
+ let o = {
1498
+ ...Sn({
1499
+ agentId: e,
1500
+ sessionId: t,
1501
+ message: n
1502
+ }),
1503
+ EventId: Q(n?.eventId),
1504
+ Rating: a,
1505
+ Comment: String(i || ""),
1506
+ TraceId: Q(n?.traceId),
1507
+ RootSpanId: Q(n?.rootSpanId)
1508
+ };
1509
+ if (!o.EventId) throw Error("Message missing event id");
1510
+ return o;
1511
+ }
1512
+ function wn(e, { messageId: t, rating: n, comment: r = "" }) {
1513
+ let i = e.find((e) => e.id === t), a = i?.feedback ? { ...i.feedback } : null, o = yn(n);
1514
+ return {
1515
+ nextMessages: e.map((e) => e.id === t ? {
1516
+ ...e,
1517
+ feedback: {
1518
+ ...e.feedback || {},
1519
+ responseId: Q(e.responseId),
1520
+ eventId: Q(e.eventId),
1521
+ rating: o,
1522
+ comment: String(r || ""),
1523
+ pending: !0,
1524
+ error: ""
1525
+ }
1526
+ } : e),
1527
+ previousFeedback: a
1528
+ };
1529
+ }
1530
+ function Tn(e, { messageId: t, feedback: n }) {
1531
+ let r = bn(n) || n;
1532
+ return e.map((e) => e.id === t ? {
1533
+ ...e,
1534
+ feedback: r ? {
1535
+ ...r,
1536
+ pending: !1,
1537
+ error: ""
1538
+ } : void 0
1539
+ } : e);
1540
+ }
1541
+ function En(e, { messageId: t, previousFeedback: n }) {
1542
+ return e.map((e) => {
1543
+ if (e.id !== t) return e;
1544
+ if (!n) {
1545
+ let { feedback: t, ...n } = e;
1546
+ return n;
1547
+ }
1548
+ return {
1549
+ ...e,
1550
+ feedback: n
1551
+ };
1552
+ });
1553
+ }
1554
+ function Dn(e, { messageId: t }) {
1555
+ return e.map((e) => {
1556
+ if (e.id !== t) return e;
1557
+ let { feedback: n, ...r } = e;
1558
+ return r;
1559
+ });
1560
+ }
1561
+ //#endregion
1562
+ //#region src/utils/tool-display.js
1563
+ function On(e) {
1564
+ return String(e || "").replace(/\\u([0-9a-fA-F]{4})/g, (e, t) => String.fromCharCode(Number.parseInt(t, 16)));
1565
+ }
1566
+ function kn(e) {
1567
+ let t = String(e || "").trim();
1568
+ for (let e = 0; e < 3; e += 1) {
1569
+ if (!t) return t;
1570
+ let e = t[0], n = t[t.length - 1];
1571
+ if (!(e === "{" && n === "}" || e === "[" && n === "]" || e === "\"" && n === "\"")) return t.replace(/\\n/g, "\n").replace(/\\"/g, "\"");
1572
+ try {
1573
+ let e = JSON.parse(t);
1574
+ if (typeof e != "string") return An(e);
1575
+ t = e.trim();
1576
+ } catch {
1577
+ return On(t).replace(/\\n/g, "\n").replace(/\\"/g, "\"");
1578
+ }
1579
+ }
1580
+ return t;
1581
+ }
1582
+ function An(e) {
1583
+ return typeof e == "string" ? kn(e) : Array.isArray(e) ? e.map((e) => An(e)) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, An(t)]));
1584
+ }
1585
+ function jn(e) {
1586
+ return typeof e == "string" ? kn(e) : An(e);
1587
+ }
1588
+ function Mn(e) {
1589
+ return e === !1 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "false" : !1;
1590
+ }
1591
+ function Nn(e) {
1592
+ return e === !0 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "true" : !1;
1593
+ }
1594
+ function Pn(e) {
1595
+ return e == null || e === !1 ? !1 : typeof e == "string" ? e.trim().length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
1596
+ }
1597
+ function Fn(e) {
1598
+ return String(e?.status || "").trim().toLowerCase() === "accepted_not_extracted";
1599
+ }
1600
+ function In(e, t = 0) {
1601
+ if (!e || t > 4) return !1;
1602
+ if (typeof e == "string") {
1603
+ let n = kn(e);
1604
+ return n !== e && In(n, t + 1);
1605
+ }
1606
+ if (Array.isArray(e)) return e.some((e) => In(e, t + 1));
1607
+ if (typeof e != "object" || Fn(e)) return !1;
1608
+ if (Mn(e.ok) || Mn(e.success)) return !0;
1609
+ let n = Nn(e.ok) || Nn(e.success), r = String(e.status || "").trim().toLowerCase();
1610
+ return !n && [
1611
+ "error",
1612
+ "failed",
1613
+ "failure"
1614
+ ].includes(r) || !n && (Pn(e.error_type) || Pn(e.error_message) || Pn(e.error)) ? !0 : Object.values(e).some((e) => In(e, t + 1));
1615
+ }
1616
+ function Ln(e) {
1617
+ return e == null || e === "" ? !1 : In(jn(e));
1618
+ }
1619
+ function Rn(e) {
1620
+ if (e == null || e === "") return "";
1621
+ let t = jn(e);
1622
+ return typeof t == "string" ? t : JSON.stringify(t, null, 2);
1623
+ }
1624
+ //#endregion
1625
+ //#region src/utils/clipboard.js
1626
+ async function zn(e, t = globalThis) {
1627
+ let n = String(e ?? ""), r = t?.navigator;
1628
+ if (r?.clipboard?.writeText) try {
1629
+ return await r.clipboard.writeText(n), !0;
1630
+ } catch {}
1631
+ let i = t?.document, a = i?.body;
1632
+ if (!i?.createElement || !a?.appendChild || !a?.removeChild) return !1;
1633
+ let o = i.createElement("textarea");
1634
+ o.value = n, o.setAttribute?.("readonly", ""), o.style && (o.style.position = "fixed", o.style.top = "0", o.style.left = "-9999px", o.style.opacity = "0", o.style.pointerEvents = "none");
1635
+ let s = i.activeElement;
1636
+ a.appendChild(o), o.focus?.(), o.select?.(), o.setSelectionRange?.(0, n.length);
1637
+ try {
1638
+ return typeof i.execCommand == "function" ? !!i.execCommand("copy") : !1;
1639
+ } finally {
1640
+ a.removeChild(o), s?.focus?.();
1641
+ }
1642
+ }
1643
+ //#endregion
1644
+ //#region src/utils/session-helpers.ts
1645
+ function Bn(e) {
1646
+ return String(e.Title || "").trim() || String(e.FirstPrompt || "").trim() || String(e.LastPrompt || "").trim() || String(e.Summary || "").trim() || "新对话";
1647
+ }
1648
+ //#endregion
1649
+ //#region src/utils/message-virtualization.js
1650
+ function Vn(e, t, n) {
1651
+ return Math.max(t, Math.min(n, e));
1652
+ }
1653
+ function Hn({ items: e = [], scrollTop: t = 0, viewportHeight: n = 0, overscan: r = 4, defaultItemHeight: i = 120, measuredHeights: a = /* @__PURE__ */ new Map(), getItemKey: o = (e, t) => e?.id || String(t) } = {}) {
1654
+ let s = Math.max(0, Number(n) || 0), c = Math.max(0, Number(t) || 0), l = Math.max(0, Number(r) || 0), u = Math.max(1, Number(i) || 120);
1655
+ if (!e.length) return {
1656
+ startIndex: 0,
1657
+ endIndex: 0,
1658
+ offsetTop: 0,
1659
+ totalHeight: 0,
1660
+ visibleItems: []
1661
+ };
1662
+ let d = e.map((e, t) => {
1663
+ let n = o(e, t), r = Number(a.get(n));
1664
+ return Number.isFinite(r) && r > 0 ? r : u;
1665
+ }), f = Array(e.length), p = 0;
1666
+ for (let t = 0; t < e.length; t += 1) f[t] = p, p += d[t];
1667
+ let m = p, h = c + s, g = 0;
1668
+ for (; g < e.length && f[g] + d[g] <= c;) g += 1;
1669
+ let _ = g;
1670
+ for (; _ < e.length && f[_] < h;) _ += 1;
1671
+ return g = Vn(g - l, 0, e.length), _ = Vn(Math.max(g + 1, _ + l), 0, e.length), {
1672
+ startIndex: g,
1673
+ endIndex: _,
1674
+ offsetTop: f[g] || 0,
1675
+ totalHeight: m,
1676
+ visibleItems: e.slice(g, _).map((e, t) => {
1677
+ let n = g + t;
1678
+ return {
1679
+ index: n,
1680
+ item: e,
1681
+ top: f[n] || 0,
1682
+ height: d[n] || u
1683
+ };
1684
+ })
1685
+ };
1686
+ }
1687
+ //#endregion
1688
+ //#region src/core/run/a2ui.ts
1689
+ var Un = Te, Wn = {
1690
+ description: we,
1691
+ value: Ee(Un)
1692
+ };
1693
+ function Gn(e) {
1694
+ return e.map((e) => {
1695
+ let t = e.updateComponents;
1696
+ if (!t || typeof t != "object" || Array.isArray(t)) return e;
1697
+ let n = t.components;
1698
+ if (!Array.isArray(n)) return e;
1699
+ let r = n.filter((e) => !!(e && typeof e == "object" && !Array.isArray(e)));
1700
+ if (r.some((e) => e.id === "root")) return e;
1701
+ let i = r.filter((e) => typeof e.id == "string" && e.id.endsWith("-root"));
1702
+ if (i.length !== 1) return e;
1703
+ let a = i[0];
1704
+ return {
1705
+ ...e,
1706
+ updateComponents: {
1707
+ ...t,
1708
+ components: n.map((e) => e === a ? {
1709
+ ...a,
1710
+ id: "root"
1711
+ } : e)
1712
+ }
1713
+ };
1714
+ });
1715
+ }
1716
+ //#endregion
1717
+ //#region src/components/chat/A2UIActivityMessage.tsx
1718
+ function Kn({ surfaceId: e, messages: t }) {
1719
+ let { processMessages: n } = De();
1720
+ return W(() => {
1721
+ n(t);
1722
+ }, [t, n]), /* @__PURE__ */ z(Ce, {
1723
+ surfaceId: e,
1724
+ className: "w-full",
1725
+ fallback: /* @__PURE__ */ z("div", {
1726
+ className: "text-sm text-slate-500 dark:text-slate-400",
1727
+ children: "界面内容暂不可用"
1728
+ }),
1729
+ loadingFallback: /* @__PURE__ */ z("div", {
1730
+ className: "text-sm text-slate-500 dark:text-slate-400",
1731
+ children: "正在加载界面"
1732
+ })
1733
+ });
1734
+ }
1735
+ function qn({ surfaceId: e, messages: t, onAction: n }) {
1736
+ return /* @__PURE__ */ z("div", {
1737
+ className: "mb-3 w-full overflow-hidden rounded-lg border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-700 dark:bg-slate-900",
1738
+ children: /* @__PURE__ */ z(Se, {
1739
+ catalog: Un,
1740
+ onAction: n,
1741
+ children: /* @__PURE__ */ z(Kn, {
1742
+ surfaceId: e,
1743
+ messages: t
1744
+ })
1745
+ })
1746
+ });
1747
+ }
1748
+ //#endregion
1749
+ //#region src/components/chat/ChatMessageList.tsx
1750
+ var Jn = 140, Yn = 4;
1751
+ function Xn(e) {
1752
+ let t = String(e || "").trim().toLowerCase();
1753
+ return t === "elevated" ? "高风险" : t === "always" ? "始终确认" : t === "confirm" ? "需确认" : e || "";
1754
+ }
1755
+ function Zn(e) {
1756
+ return String(e || "").trim().toLowerCase() === "elevated" ? "border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200" : "border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-200";
1757
+ }
1758
+ function Qn({ messageId: e, top: t, onMeasure: n, children: r }) {
1759
+ let i = K(null);
1760
+ return G(() => {
1761
+ let r = i.current;
1762
+ if (!r) return;
1763
+ let a = () => n(e, r.offsetHeight, t);
1764
+ if (a(), typeof ResizeObserver > "u") return;
1765
+ let o = new ResizeObserver(a);
1766
+ return o.observe(r), () => o.disconnect();
1767
+ }, [
1768
+ e,
1769
+ n,
1770
+ t
1771
+ ]), /* @__PURE__ */ z("div", {
1772
+ ref: i,
1773
+ style: {
1774
+ position: "absolute",
1775
+ top: t,
1776
+ left: 0,
1777
+ right: 0
1778
+ },
1779
+ children: r
1780
+ });
1781
+ }
1782
+ function $n(e) {
1783
+ let t = Math.max(0, Math.floor(e / 1e3)), n = Math.floor(t / 60), r = t % 60;
1784
+ return n <= 0 ? `${r}s` : `${n}m ${String(r).padStart(2, "0")}s`;
1785
+ }
1786
+ function er(e) {
1787
+ return e < 1e3 ? "刚刚" : e < 6e4 ? `${Math.floor(e / 1e3)} 秒前` : `${Math.floor(e / 6e4)} 分钟前`;
1788
+ }
1789
+ function tr(e) {
1790
+ return !Number.isFinite(e) || !e || e <= 0 ? "" : e >= 1e6 ? `${(e / 1e6).toFixed(e >= 1e7 ? 0 : 1)}M` : e >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e5 ? 0 : 1)}K` : String(Math.round(e));
1791
+ }
1792
+ function nr({ contextIndicator: e }) {
1793
+ let t = e?.usedTokens, n = e?.contextWindowTokens, r = tr(t), i = tr(n);
1794
+ if (!r) return null;
1795
+ let a = [r, i].filter(Boolean).join("/");
1796
+ return /* @__PURE__ */ B("span", {
1797
+ className: "token-count-pulse hidden text-slate-400 dark:text-slate-500 sm:inline",
1798
+ title: e?.label || `估算 token ${a}`,
1799
+ children: ["估算 token ", a]
1800
+ }, r);
1801
+ }
1802
+ function rr({ activity: e, contextIndicator: t, onStopGeneration: n, onCancelRemote: i }) {
1803
+ let [a, o] = q(() => Date.now());
1804
+ W(() => {
1805
+ let e = window.setInterval(() => o(Date.now()), 1e3);
1806
+ return () => window.clearInterval(e);
1807
+ }, []);
1808
+ let s = e.status === "connecting" || e.status === "running" || e.status === "waiting", c = a - e.lastEventAt < 2e4;
1809
+ return /* @__PURE__ */ B("div", {
1810
+ className: "inline-flex max-w-full items-center gap-2 rounded-full border border-slate-200/70 bg-white/90 px-2.5 py-1 text-[11px] leading-4 text-slate-500 shadow-sm shadow-slate-900/5 backdrop-blur dark:border-slate-700/60 dark:bg-slate-900/90 dark:text-slate-400",
1811
+ children: [
1812
+ e.status === "failed" ? /* @__PURE__ */ z(j, { className: "h-3 w-3 text-rose-500" }) : e.status === "completed" ? /* @__PURE__ */ z(r, { className: "h-3 w-3 text-emerald-500" }) : e.status === "stopped" ? /* @__PURE__ */ z(k, { className: "h-3 w-3 text-amber-500" }) : /* @__PURE__ */ z(O, { className: "h-3 w-3 animate-spin text-slate-400" }),
1813
+ /* @__PURE__ */ z("span", {
1814
+ className: "max-w-[16rem] truncate text-slate-600 dark:text-slate-300",
1815
+ title: e.detail || e.phase,
1816
+ children: e.phase
1817
+ }),
1818
+ /* @__PURE__ */ B("span", { children: [
1819
+ e.source === "restore" ? "恢复" : "运行",
1820
+ " ",
1821
+ $n(a - e.startedAt)
1822
+ ] }),
1823
+ s ? /* @__PURE__ */ z("span", {
1824
+ className: Y("inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full", c ? "bg-emerald-400" : "bg-slate-300 dark:bg-slate-600"),
1825
+ title: c ? "连接存活" : "连接超时"
1826
+ }) : null,
1827
+ /* @__PURE__ */ B("span", {
1828
+ className: "text-slate-400 dark:text-slate-500",
1829
+ children: [e.eventCount, " ev"]
1830
+ }),
1831
+ /* @__PURE__ */ z("span", {
1832
+ className: "hidden text-slate-400 dark:text-slate-500 sm:inline",
1833
+ children: er(a - e.lastEventAt)
1834
+ }),
1835
+ /* @__PURE__ */ z(nr, { contextIndicator: t }),
1836
+ s && (n || i) ? /* @__PURE__ */ B("div", {
1837
+ className: "flex flex-shrink-0 gap-1",
1838
+ children: [n ? /* @__PURE__ */ B("button", {
1839
+ type: "button",
1840
+ onClick: n,
1841
+ className: "flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-slate-100 hover:text-slate-700 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-200",
1842
+ children: [/* @__PURE__ */ z(j, { className: "h-3 w-3" }), "停止"]
1843
+ }) : null, i ? /* @__PURE__ */ B("button", {
1844
+ type: "button",
1845
+ "aria-label": "取消运行并保留恢复点",
1846
+ title: "取消运行并保留最近 checkpoint",
1847
+ onClick: i,
1848
+ className: "flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-rose-50 hover:text-rose-600 dark:text-slate-500 dark:hover:bg-rose-950/30 dark:hover:text-rose-300",
1849
+ children: [/* @__PURE__ */ z(F, { className: "h-3 w-3" }), "取消"]
1850
+ }) : null]
1851
+ }) : null
1852
+ ]
1853
+ });
1854
+ }
1855
+ function ir({ agentName: e }) {
1856
+ return /* @__PURE__ */ B("div", {
1857
+ className: "flex flex-col items-center justify-center min-h-[50vh] px-4",
1858
+ children: [
1859
+ /* @__PURE__ */ z("div", {
1860
+ className: "mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600\n flex items-center justify-center shadow-lg shadow-blue-500/20",
1861
+ children: /* @__PURE__ */ z(n, { className: "h-8 w-8 text-white" })
1862
+ }),
1863
+ /* @__PURE__ */ z("h2", {
1864
+ className: "text-xl font-semibold text-slate-900 dark:text-slate-50",
1865
+ children: "有什么我可以帮您的吗?"
1866
+ }),
1867
+ /* @__PURE__ */ B("p", {
1868
+ className: "mt-2 text-sm text-slate-500",
1869
+ children: [
1870
+ "我是 ",
1871
+ e,
1872
+ ",由 Ksyun AgentEngine 驱动"
1873
+ ]
1874
+ })
1875
+ ]
1876
+ });
1877
+ }
1878
+ function ar() {
1879
+ return /* @__PURE__ */ B("div", {
1880
+ className: "mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8",
1881
+ "aria-label": "正在加载会话历史",
1882
+ children: [
1883
+ /* @__PURE__ */ z("div", { className: "h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800" }),
1884
+ /* @__PURE__ */ z("div", { className: "h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" }),
1885
+ /* @__PURE__ */ z("div", { className: "ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" }),
1886
+ /* @__PURE__ */ z("div", { className: "h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" })
1887
+ ]
1888
+ });
1889
+ }
1890
+ function or({ attachments: e, isMobile: t, onOpenAttachmentPreview: n }) {
1891
+ return /* @__PURE__ */ z("div", {
1892
+ className: "mb-3 flex flex-wrap gap-3",
1893
+ children: e.map((e, r) => e.type.startsWith("image/") ? e.url ? /* @__PURE__ */ z("button", {
1894
+ type: "button",
1895
+ onClick: () => n(e),
1896
+ className: Y("group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700", t ? "w-full max-w-full" : "max-w-[200px]"),
1897
+ children: /* @__PURE__ */ z("img", {
1898
+ src: e.url,
1899
+ alt: e.name,
1900
+ className: Y("object-cover transition group-hover:scale-[1.02]", t ? "max-h-[16rem] w-full max-w-full" : "max-h-[200px] max-w-[200px]")
1901
+ })
1902
+ }, `${e.name}-${r}`) : /* @__PURE__ */ z("div", {
1903
+ className: Y("flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400", t ? "h-28 w-full" : "h-[120px] w-[200px]"),
1904
+ children: e.name
1905
+ }, `${e.name}-${r}`) : /* @__PURE__ */ B("div", {
1906
+ className: Y("flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800", t ? "w-full max-w-full" : "w-max max-w-full"),
1907
+ children: [/* @__PURE__ */ z(E, { className: "h-4 w-4 flex-shrink-0 text-blue-500" }), e.url ? /* @__PURE__ */ z("a", {
1908
+ href: e.url,
1909
+ target: "_blank",
1910
+ rel: "noreferrer",
1911
+ className: "truncate text-sm text-slate-700 hover:underline dark:text-slate-300",
1912
+ title: e.name,
1913
+ children: e.name
1914
+ }) : /* @__PURE__ */ z("span", {
1915
+ className: "truncate text-sm text-slate-700 dark:text-slate-300",
1916
+ title: e.name,
1917
+ children: e.name
1918
+ })]
1919
+ }, `${e.name}-${r}`))
1920
+ });
1921
+ }
1922
+ function sr({ message: e }) {
1923
+ return /* @__PURE__ */ z("div", {
1924
+ className: "w-full px-0 py-2 sm:px-4",
1925
+ children: /* @__PURE__ */ B("div", {
1926
+ className: "mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",
1927
+ children: [
1928
+ /* @__PURE__ */ B("div", {
1929
+ className: "flex items-center gap-2 font-medium",
1930
+ children: [e.status === "running" ? /* @__PURE__ */ z(O, { className: "h-4 w-4 animate-spin text-amber-600 dark:text-amber-300" }) : e.status === "failed" ? /* @__PURE__ */ z(j, { className: "h-4 w-4 text-rose-600 dark:text-rose-400" }) : /* @__PURE__ */ z(r, { className: "h-4 w-4 text-emerald-600 dark:text-emerald-400" }), /* @__PURE__ */ z("span", { children: e.content })]
1931
+ }),
1932
+ e.compactedUntilSeqId ? /* @__PURE__ */ B("div", {
1933
+ className: "mt-1 text-xs text-amber-700/80 dark:text-amber-200/80",
1934
+ children: ["已折叠到会话事件 #", e.compactedUntilSeqId]
1935
+ }) : null,
1936
+ e.summary ? /* @__PURE__ */ B("details", {
1937
+ className: "mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40",
1938
+ children: [/* @__PURE__ */ z("summary", {
1939
+ className: "cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200",
1940
+ children: "查看压缩摘要"
1941
+ }), /* @__PURE__ */ z("div", {
1942
+ className: "mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200",
1943
+ children: /* @__PURE__ */ z(Z, { content: e.summary })
1944
+ })]
1945
+ }) : null
1946
+ ]
1947
+ })
1948
+ });
1949
+ }
1950
+ function cr({ label: e, tone: t, value: n }) {
1951
+ let [i, a] = q("idle"), s = Rn(n);
1952
+ W(() => {
1953
+ if (i === "idle") return;
1954
+ let e = window.setTimeout(() => a("idle"), 1600);
1955
+ return () => window.clearTimeout(e);
1956
+ }, [i]);
1957
+ let c = async () => {
1958
+ a(await zn(s) ? "copied" : "failed");
1959
+ };
1960
+ return /* @__PURE__ */ B("div", { children: [/* @__PURE__ */ B("div", {
1961
+ className: "mb-1 flex items-center justify-between gap-2",
1962
+ children: [/* @__PURE__ */ z("div", {
1963
+ className: Y("text-xs font-semibold uppercase", t === "input" ? "text-blue-500" : t === "error" ? "text-rose-500" : "text-emerald-500"),
1964
+ children: e
1965
+ }), /* @__PURE__ */ B("button", {
1966
+ type: "button",
1967
+ onClick: () => {
1968
+ c();
1969
+ },
1970
+ className: "inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100",
1971
+ children: [i === "copied" ? /* @__PURE__ */ z(r, { className: "h-3.5 w-3.5 text-emerald-500" }) : /* @__PURE__ */ z(o, { className: "h-3.5 w-3.5" }), i === "copied" ? "已复制" : i === "failed" ? "复制失败" : "复制"]
1972
+ })]
1973
+ }), /* @__PURE__ */ z("div", {
1974
+ className: "custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]",
1975
+ children: s
1976
+ })] });
1977
+ }
1978
+ function lr({ isLastMessage: e, isStreaming: t, message: n, onDeleteFeedback: r, onSubmitFeedback: i }) {
1979
+ let [a, s] = q(!1), [c, l] = q(n.feedback?.comment || ""), u = xn(n, t, e), d = !!n.feedback?.pending, f = n.feedback?.rating, p = async () => {
1980
+ let e = n.content || "";
1981
+ e && zn(e);
1982
+ };
1983
+ return u ? /* @__PURE__ */ B("div", {
1984
+ className: "mt-2 flex flex-col gap-2 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100",
1985
+ children: [
1986
+ /* @__PURE__ */ B("div", {
1987
+ className: "flex flex-wrap items-center gap-1.5 text-xs text-text-muted",
1988
+ children: [
1989
+ /* @__PURE__ */ z("button", {
1990
+ type: "button",
1991
+ onClick: () => {
1992
+ p();
1993
+ },
1994
+ className: "inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary",
1995
+ title: "复制",
1996
+ children: /* @__PURE__ */ z(o, { className: "h-3.5 w-3.5" })
1997
+ }),
1998
+ /* @__PURE__ */ z("span", {
1999
+ className: "text-text-muted/60",
2000
+ children: "·"
2001
+ }),
2002
+ /* @__PURE__ */ z("span", {
2003
+ className: "font-medium",
2004
+ children: "本次回复有帮助吗?"
2005
+ }),
2006
+ /* @__PURE__ */ B("button", {
2007
+ type: "button",
2008
+ disabled: d,
2009
+ onClick: () => i({
2010
+ message: n,
2011
+ rating: "up",
2012
+ comment: ""
2013
+ }),
2014
+ className: Y("inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60", f === "up" ? "border-primary/30 bg-primary/10 text-primary" : "border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary"),
2015
+ children: [/* @__PURE__ */ z(P, { className: "h-3.5 w-3.5" }), "有帮助"]
2016
+ }),
2017
+ /* @__PURE__ */ B("button", {
2018
+ type: "button",
2019
+ disabled: d,
2020
+ onClick: () => {
2021
+ l(n.feedback?.comment || ""), s((e) => !e);
2022
+ },
2023
+ className: Y("inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60", f === "down" ? "border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300" : "border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600"),
2024
+ children: [/* @__PURE__ */ z(N, { className: "h-3.5 w-3.5" }), "需改进"]
2025
+ }),
2026
+ n.feedback ? /* @__PURE__ */ B("button", {
2027
+ type: "button",
2028
+ disabled: d,
2029
+ onClick: () => r(n),
2030
+ className: "inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200",
2031
+ children: [/* @__PURE__ */ z(se, { className: "h-3.5 w-3.5" }), "删除反馈"]
2032
+ }) : null,
2033
+ d ? /* @__PURE__ */ z("span", {
2034
+ className: "text-slate-400",
2035
+ children: "提交中…"
2036
+ }) : null
2037
+ ]
2038
+ }),
2039
+ a ? /* @__PURE__ */ B("div", {
2040
+ className: "max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20",
2041
+ children: [/* @__PURE__ */ z("textarea", {
2042
+ value: c,
2043
+ onChange: (e) => l(e.target.value),
2044
+ placeholder: "可以补充哪里不准确、缺失或不符合预期。",
2045
+ className: "min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950"
2046
+ }), /* @__PURE__ */ B("div", {
2047
+ className: "mt-2 flex flex-wrap justify-end gap-2",
2048
+ children: [/* @__PURE__ */ z("button", {
2049
+ type: "button",
2050
+ onClick: () => s(!1),
2051
+ className: "rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100",
2052
+ children: "取消"
2053
+ }), /* @__PURE__ */ z("button", {
2054
+ type: "button",
2055
+ disabled: d,
2056
+ onClick: () => {
2057
+ i({
2058
+ message: n,
2059
+ rating: "down",
2060
+ comment: c
2061
+ }), s(!1);
2062
+ },
2063
+ className: "rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60",
2064
+ children: "提交点踩"
2065
+ })]
2066
+ })]
2067
+ }) : f === "down" && n.feedback?.comment ? /* @__PURE__ */ B("div", {
2068
+ className: "max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200",
2069
+ children: ["反馈:", n.feedback.comment]
2070
+ }) : null,
2071
+ n.feedback?.error ? /* @__PURE__ */ z("div", {
2072
+ className: "text-xs text-rose-600 dark:text-rose-300",
2073
+ children: n.feedback.error
2074
+ }) : null
2075
+ ]
2076
+ }) : null;
2077
+ }
2078
+ function ur({ agentName: e, isMobile: t, isStreaming: a, isLastMessage: o, message: s, onDeleteFeedback: c, onOpenAttachmentPreview: l, onRespondToApproval: u, onRespondToAguiApproval: d, onSubmitFeedback: f, onSubmitAguiAction: p }) {
2079
+ return s.role === "user" ? /* @__PURE__ */ z("div", {
2080
+ className: "mb-3 flex justify-end",
2081
+ children: /* @__PURE__ */ B("div", {
2082
+ className: "max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground",
2083
+ children: [s.attachments?.length ? /* @__PURE__ */ z(or, {
2084
+ attachments: s.attachments,
2085
+ isMobile: t,
2086
+ onOpenAttachmentPreview: l
2087
+ }) : null, s.content]
2088
+ })
2089
+ }) : s.role === "a2ui" && s.aguiActivity ? /* @__PURE__ */ z(qn, {
2090
+ surfaceId: s.aguiActivity.surfaceId,
2091
+ messages: s.aguiActivity.messages,
2092
+ onAction: p
2093
+ }) : /* @__PURE__ */ B("div", {
2094
+ className: "group mx-auto mb-3 w-full max-w-3xl px-6",
2095
+ children: [
2096
+ /* @__PURE__ */ B("div", {
2097
+ className: "mb-1.5 flex items-center gap-2 text-xs text-text-muted",
2098
+ children: [/* @__PURE__ */ z(n, { className: "w-3.5 h-3.5" }), /* @__PURE__ */ z("span", { children: e })]
2099
+ }),
2100
+ s.attachments?.length ? /* @__PURE__ */ z(or, {
2101
+ attachments: s.attachments,
2102
+ isMobile: t,
2103
+ onOpenAttachmentPreview: l
2104
+ }) : null,
2105
+ s.blocks?.length ? /* @__PURE__ */ z(pn, {
2106
+ message: s,
2107
+ isStreaming: a,
2108
+ onRespondToApproval: u,
2109
+ onRespondToAguiApproval: d
2110
+ }) : /* @__PURE__ */ B(R, { children: [
2111
+ s.reasoning ? /* @__PURE__ */ B("details", {
2112
+ className: "group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30",
2113
+ children: [/* @__PURE__ */ B("summary", {
2114
+ className: "flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden",
2115
+ children: [/* @__PURE__ */ B("div", {
2116
+ className: "flex min-w-0 items-center gap-2",
2117
+ children: [
2118
+ a && o && !s.content ? /* @__PURE__ */ z(O, { className: "h-4 w-4 animate-spin text-slate-500" }) : /* @__PURE__ */ z(r, { className: "h-4 w-4 text-slate-400" }),
2119
+ /* @__PURE__ */ z("span", {
2120
+ className: "truncate",
2121
+ children: "思考过程"
2122
+ }),
2123
+ /* @__PURE__ */ z("span", {
2124
+ className: "rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300",
2125
+ children: a && o && !s.content ? "生成中" : "已完成"
2126
+ })
2127
+ ]
2128
+ }), /* @__PURE__ */ z(i, { className: "h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180" })]
2129
+ }), /* @__PURE__ */ z("div", {
2130
+ className: "border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20",
2131
+ children: /* @__PURE__ */ z("div", {
2132
+ className: "custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2",
2133
+ children: /* @__PURE__ */ z(Z, { content: s.reasoning })
2134
+ })
2135
+ })]
2136
+ }) : null,
2137
+ s.tools ? Object.values(s.tools).map((e, t) => /* @__PURE__ */ B("details", {
2138
+ open: e.approvalStatus === "pending" || e.status === "paused" ? !0 : void 0,
2139
+ className: Y("group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors", e.status === "paused" ? "border-amber-200/80 bg-amber-50/25 text-slate-700 dark:border-amber-900/60 dark:bg-amber-950/10 dark:text-slate-200" : e.status === "error" ? "border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200" : "border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300"),
2140
+ children: [/* @__PURE__ */ z("summary", {
2141
+ className: "flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium",
2142
+ children: /* @__PURE__ */ B("div", {
2143
+ className: "flex items-center gap-2",
2144
+ children: [e.status === "running" ? /* @__PURE__ */ z(O, { className: "h-4 w-4 animate-spin text-slate-500" }) : e.status === "paused" ? /* @__PURE__ */ z(k, { className: "h-4 w-4 text-amber-500" }) : e.status === "error" ? /* @__PURE__ */ z(F, { className: "h-4 w-4 text-rose-500" }) : /* @__PURE__ */ z(r, { className: "h-4 w-4 text-slate-400" }), /* @__PURE__ */ B("span", { children: [e.approvalStatus === "pending" ? "等待审批:" : e.approvalStatus === "approved" ? "已批准:" : e.approvalStatus === "rejected" ? "已拒绝:" : e.status === "error" ? "工具调用失败:" : "工具调用:", e.name] })]
2145
+ })
2146
+ }), /* @__PURE__ */ B("div", {
2147
+ className: Y("flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed", e.status === "paused" ? "border-amber-200/70 dark:border-amber-900/60" : e.status === "error" ? "border-rose-200/70 dark:border-rose-900/60" : "border-slate-200/70 dark:border-slate-800"),
2148
+ children: [
2149
+ e.approvalRequestId ? /* @__PURE__ */ B("div", {
2150
+ className: "font-sans text-sm text-slate-700 dark:text-slate-200",
2151
+ children: [
2152
+ /* @__PURE__ */ z("div", {
2153
+ className: "font-medium",
2154
+ children: e.approvalStatus === "approved" ? "已批准该工具调用。" : e.approvalStatus === "rejected" ? "已拒绝该工具调用。" : e.approvalMessage || "该工具调用需要人工确认后继续。"
2155
+ }),
2156
+ e.approvalLevel ? /* @__PURE__ */ B("div", {
2157
+ className: Y("mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium", Zn(e.approvalLevel)),
2158
+ children: ["审批级别:", Xn(e.approvalLevel)]
2159
+ }) : null,
2160
+ e.serverLabel ? /* @__PURE__ */ B("div", {
2161
+ className: "mt-1 text-xs text-amber-700/80 dark:text-amber-200/80",
2162
+ children: ["MCP Server: ", e.serverLabel]
2163
+ }) : null,
2164
+ e.approvalStatus === "pending" ? /* @__PURE__ */ B("div", {
2165
+ className: "mt-3 flex flex-wrap gap-2",
2166
+ children: [/* @__PURE__ */ B("button", {
2167
+ type: "button",
2168
+ disabled: a || e.approvalStatus !== "pending",
2169
+ onClick: () => e.approvalProtocol === "ag-ui" ? d?.({
2170
+ interruptId: e.approvalRequestId || "",
2171
+ approve: !0
2172
+ }) : u({
2173
+ approvalRequestId: e.approvalRequestId || "",
2174
+ approve: !0,
2175
+ previousResponseId: e.previousResponseId
2176
+ }),
2177
+ className: "inline-flex min-h-8 items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55",
2178
+ children: [/* @__PURE__ */ z(r, { className: "h-3.5 w-3.5" }), "批准并继续"]
2179
+ }), /* @__PURE__ */ B("button", {
2180
+ type: "button",
2181
+ disabled: a || e.approvalStatus !== "pending",
2182
+ onClick: () => e.approvalProtocol === "ag-ui" ? d?.({
2183
+ interruptId: e.approvalRequestId || "",
2184
+ approve: !1
2185
+ }) : u({
2186
+ approvalRequestId: e.approvalRequestId || "",
2187
+ approve: !1,
2188
+ previousResponseId: e.previousResponseId
2189
+ }),
2190
+ className: "inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300",
2191
+ children: [/* @__PURE__ */ z(F, { className: "h-3.5 w-3.5" }), "拒绝"]
2192
+ })]
2193
+ }) : /* @__PURE__ */ B("div", {
2194
+ className: "mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400",
2195
+ children: [e.approvalStatus === "approved" ? /* @__PURE__ */ z(r, { className: "h-3.5 w-3.5 text-emerald-500" }) : /* @__PURE__ */ z(F, { className: "h-3.5 w-3.5 text-rose-500" }), e.approvalStatus === "approved" ? "已批准" : "已拒绝"]
2196
+ })
2197
+ ]
2198
+ }) : null,
2199
+ e.args ? /* @__PURE__ */ z(cr, {
2200
+ label: "入参 (Args)",
2201
+ tone: "input",
2202
+ value: e.args
2203
+ }) : null,
2204
+ e.output ? /* @__PURE__ */ z(cr, {
2205
+ label: "输出 (Output)",
2206
+ tone: e.status === "error" ? "error" : "output",
2207
+ value: e.output
2208
+ }) : null
2209
+ ]
2210
+ })]
2211
+ }, `${e.name}-${t}`)) : null,
2212
+ /* @__PURE__ */ z("div", {
2213
+ className: "w-full break-words",
2214
+ children: s.content ? /* @__PURE__ */ z(Z, { content: s.content }) : a && o && !s.reasoning && !s.tools ? /* @__PURE__ */ z("span", { className: "ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm" }) : null
2215
+ })
2216
+ ] }),
2217
+ s.aguiActivities?.map((e) => /* @__PURE__ */ z(qn, {
2218
+ surfaceId: e.surfaceId,
2219
+ messages: e.messages,
2220
+ onAction: p
2221
+ }, e.surfaceId)),
2222
+ /* @__PURE__ */ z(lr, {
2223
+ isLastMessage: o,
2224
+ isStreaming: a,
2225
+ message: s,
2226
+ onDeleteFeedback: c,
2227
+ onSubmitFeedback: f
2228
+ })
2229
+ ]
2230
+ });
2231
+ }
2232
+ function dr({ agentName: t, isMobile: n, isStreaming: r, activity: i, contextIndicator: a, messages: o, isLoadingInitialHistory: s = !1, onDeleteFeedback: c, onOpenAttachmentPreview: l, onRespondToApproval: u, onRespondToAguiApproval: d, onSubmitFeedback: f, onSubmitAguiAction: p, onStopGeneration: m, onCancelRemote: h, checkpoints: g = [], onResumeCheckpoint: _, scrollRef: v }) {
2233
+ let [y, b] = q(0), [x, S] = q(0), [C, w] = q(/* @__PURE__ */ new Map()), ee = K(C);
2234
+ G(() => {
2235
+ let e = v.current;
2236
+ if (!e) return;
2237
+ let t = () => {
2238
+ b(e.scrollTop), S(e.clientHeight);
2239
+ };
2240
+ if (t(), typeof ResizeObserver > "u") return;
2241
+ let n = new ResizeObserver(() => t());
2242
+ return n.observe(e), () => n.disconnect();
2243
+ }, [v]);
2244
+ let T = _e(() => Hn({
2245
+ items: o,
2246
+ scrollTop: y,
2247
+ viewportHeight: x,
2248
+ overscan: Yn,
2249
+ defaultItemHeight: Jn,
2250
+ measuredHeights: C,
2251
+ getItemKey: (e, t) => e?.id || String(t)
2252
+ }), [
2253
+ C,
2254
+ o,
2255
+ y,
2256
+ x
2257
+ ]), E = T.visibleItems, D = U((e, t, n) => {
2258
+ if (!e || !Number.isFinite(t) || t <= 0) return;
2259
+ let r = ee.current, i = r.get(e) ?? Jn;
2260
+ if (i === t) return;
2261
+ let a = new Map(r);
2262
+ a.set(e, t), ee.current = a, w(a);
2263
+ let o = v.current;
2264
+ o && n < o.scrollTop && (o.scrollTop += t - i, b(o.scrollTop));
2265
+ }, [v]);
2266
+ return /* @__PURE__ */ B("div", {
2267
+ ref: v,
2268
+ onScroll: (e) => b(e.currentTarget.scrollTop),
2269
+ className: Y("custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth", n ? "px-3 py-3" : "px-4 py-5"),
2270
+ children: [
2271
+ /* @__PURE__ */ z("div", {
2272
+ className: Y("mx-auto flex w-full max-w-[64rem] flex-col", i ? "pb-10 sm:pb-10" : "pb-6 sm:pb-8"),
2273
+ children: o.length === 0 && s ? /* @__PURE__ */ z(ar, {}) : o.length === 0 ? /* @__PURE__ */ z(ir, { agentName: t }) : /* @__PURE__ */ z("div", {
2274
+ style: { height: T.totalHeight },
2275
+ className: "relative",
2276
+ children: E.map((e) => /* @__PURE__ */ z(Qn, {
2277
+ messageId: e.item.id || String(e.index),
2278
+ top: e.top,
2279
+ onMeasure: D,
2280
+ children: e.item.role === "system" ? /* @__PURE__ */ z(sr, { message: e.item }) : /* @__PURE__ */ z(ur, {
2281
+ agentName: t,
2282
+ isMobile: n,
2283
+ isStreaming: r,
2284
+ isLastMessage: e.index === o.length - 1,
2285
+ message: e.item,
2286
+ onDeleteFeedback: c,
2287
+ onOpenAttachmentPreview: l,
2288
+ onRespondToApproval: u,
2289
+ onRespondToAguiApproval: d,
2290
+ onSubmitFeedback: f,
2291
+ onSubmitAguiAction: p
2292
+ })
2293
+ }, e.item.id || e.index))
2294
+ })
2295
+ }),
2296
+ /* @__PURE__ */ z(_n, {}),
2297
+ y > 320 ? /* @__PURE__ */ z("button", {
2298
+ type: "button",
2299
+ onClick: () => {
2300
+ let e = v.current;
2301
+ e && e.scrollTo({
2302
+ top: e.scrollHeight,
2303
+ behavior: "smooth"
2304
+ });
2305
+ },
2306
+ className: "sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary",
2307
+ title: "回到底部",
2308
+ children: /* @__PURE__ */ z(e, { className: "h-4 w-4" })
2309
+ }) : null,
2310
+ i ? /* @__PURE__ */ z("div", {
2311
+ className: "sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end",
2312
+ children: /* @__PURE__ */ z(rr, {
2313
+ activity: i,
2314
+ contextIndicator: a,
2315
+ onStopGeneration: m,
2316
+ onCancelRemote: h
2317
+ })
2318
+ }) : null
2319
+ ]
2320
+ });
2321
+ }
2322
+ //#endregion
2323
+ //#region src/utils/session-list.js
2324
+ var fr = new Set([
2325
+ "in_progress",
2326
+ "running",
2327
+ "queued",
2328
+ "pending"
2329
+ ]), pr = 300 * 1e3;
2330
+ function mr(e) {
2331
+ let t = e?.UpdatedAt ?? e?.updated_at;
2332
+ if (typeof t == "string") {
2333
+ let e = Date.parse(t);
2334
+ return Number.isNaN(e) ? 0 : e;
2335
+ }
2336
+ return typeof t == "number" && Number.isFinite(t) ? t > 1e11 ? t : t * 1e3 : 0;
2337
+ }
2338
+ function hr(e) {
2339
+ return String(e || "").trim().toLowerCase();
2340
+ }
2341
+ function gr(e) {
2342
+ if (!e) return "";
2343
+ let t = typeof e == "number" ? new Date(e > 1e11 ? e : e * 1e3) : new Date(e);
2344
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleString("zh-CN", {
2345
+ timeZone: "Asia/Shanghai",
2346
+ month: "short",
2347
+ day: "numeric",
2348
+ hour: "2-digit",
2349
+ minute: "2-digit",
2350
+ hour12: !1
2351
+ });
2352
+ }
2353
+ function _r(e) {
2354
+ return [
2355
+ e?.Title,
2356
+ e?.Summary,
2357
+ e?.FirstPrompt,
2358
+ e?.LastPrompt,
2359
+ e?.SessionId,
2360
+ e?.Model?.display_name,
2361
+ e?.Model?.id
2362
+ ].map(hr).join(" ");
2363
+ }
2364
+ function vr(e, t = {}) {
2365
+ if (!fr.has(hr(e?.ActiveRunStatus))) return !1;
2366
+ let n = mr(e);
2367
+ if (!n) return !0;
2368
+ let r = Number.isFinite(Number(t.now)) ? Number(t.now) : Date.now(), i = Number.isFinite(Number(t.activeStaleAfterMs)) ? Number(t.activeStaleAfterMs) : pr;
2369
+ return r - n <= i;
2370
+ }
2371
+ function yr(e = [], t = "", n = {}) {
2372
+ let r = hr(t), i = new Set(Array.isArray(n.pinnedSessionIds) ? n.pinnedSessionIds : []);
2373
+ return (Array.isArray(e) ? e : []).filter((e) => e?.SessionId).filter((e) => !r || _r(e).includes(r)).slice().sort((e, t) => {
2374
+ let r = +!!i.has(e.SessionId), a = +!!i.has(t.SessionId);
2375
+ if (r !== a) return a - r;
2376
+ let o = +!!vr(e, n), s = +!!vr(t, n);
2377
+ return o === s ? mr(t) - mr(e) : s - o;
2378
+ });
2379
+ }
2380
+ function br(e, t = {}) {
2381
+ let n = vr(e, t);
2382
+ return {
2383
+ running: n,
2384
+ label: n ? "" : gr(e?.UpdatedAt ?? e?.updated_at)
2385
+ };
2386
+ }
2387
+ //#endregion
2388
+ //#region src/components/chat/ChatSidebar.tsx
2389
+ function xr({ sessions: e, currentSessionId: t, onCreateNewSession: n, onSelectSession: r, onDeleteSession: i, onTogglePinSession: a, onLoadMoreSessions: o, sessionTitle: s, pinnedSessionIds: c = [], hasMoreSessions: l = !1, isLoadingSessions: u = !1, className: d }) {
2390
+ let [f, p] = q(""), m = _e(() => yr(e, f, { pinnedSessionIds: c }), [
2391
+ e,
2392
+ c,
2393
+ f
2394
+ ]), h = _e(() => new Set(c), [c]);
2395
+ return /* @__PURE__ */ B("div", {
2396
+ className: Y("flex h-full min-h-0 flex-col bg-sidebar", d),
2397
+ children: [
2398
+ /* @__PURE__ */ B("div", {
2399
+ className: "flex flex-shrink-0 flex-col gap-2 border-b border-black/[0.06] px-3 py-3 dark:border-white/[0.08]",
2400
+ children: [/* @__PURE__ */ B("button", {
2401
+ type: "button",
2402
+ onClick: n,
2403
+ className: "flex h-[34px] w-full items-center justify-between rounded-[10px] px-2.5 text-sm font-medium text-sidebar-text-secondary transition-colors hover:bg-sidebar-hover hover:text-sidebar-text",
2404
+ children: [/* @__PURE__ */ B("span", {
2405
+ className: "flex items-center gap-1.5",
2406
+ children: [/* @__PURE__ */ z(b, { className: "h-4 w-4" }), /* @__PURE__ */ z("span", { children: "新对话" })]
2407
+ }), /* @__PURE__ */ z("span", {
2408
+ className: "rounded border border-black/[0.08] px-1.5 py-0.5 text-[11px] text-sidebar-text-muted dark:border-white/[0.1]",
2409
+ children: "⌘ N"
2410
+ })]
2411
+ }), /* @__PURE__ */ B("label", {
2412
+ className: "flex h-9 items-center gap-2 rounded-[10px] border border-black/[0.06] bg-background px-2.5 text-xs text-sidebar-text-muted focus-within:border-primary/40 dark:border-white/[0.08]",
2413
+ children: [/* @__PURE__ */ z(ie, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ z("input", {
2414
+ value: f,
2415
+ onChange: (e) => p(e.target.value),
2416
+ className: "min-w-0 flex-1 bg-transparent text-sm text-sidebar-text outline-none placeholder:text-sidebar-text-muted",
2417
+ placeholder: "搜索会话、模型或摘要"
2418
+ })]
2419
+ })]
2420
+ }),
2421
+ /* @__PURE__ */ B("div", {
2422
+ className: "min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-2 custom-scrollbar",
2423
+ onScroll: (e) => {
2424
+ if (!o || u || !l || f.trim()) return;
2425
+ let t = e.currentTarget;
2426
+ t.scrollHeight - t.scrollTop - t.clientHeight < 200 && o();
2427
+ },
2428
+ children: [/* @__PURE__ */ B("div", {
2429
+ className: "px-2.5 py-2 text-xs font-medium text-sidebar-text-muted opacity-75",
2430
+ children: ["历史记录", f.trim() ? ` · ${m.length}` : ""]
2431
+ }), /* @__PURE__ */ B("div", {
2432
+ className: "flex flex-col gap-0.5",
2433
+ children: [m.length > 0 ? m.map((e) => {
2434
+ let n = br(e), o = h.has(e.SessionId), c = t === e.SessionId;
2435
+ return /* @__PURE__ */ B("div", {
2436
+ role: "button",
2437
+ tabIndex: 0,
2438
+ "aria-current": c ? "page" : void 0,
2439
+ onClick: () => r(e.SessionId),
2440
+ onKeyDown: (t) => {
2441
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), r(e.SessionId));
2442
+ },
2443
+ className: Y("group relative flex h-[30px] items-center gap-1 rounded-[10px] border-l-2 border-transparent px-2 text-sm leading-5 transition-colors", c ? "border-l-2 border-primary bg-primary/10 font-medium text-sidebar-text" : n.running ? "cursor-pointer bg-primary/8 text-sidebar-text" : "cursor-pointer text-sidebar-text-secondary hover:bg-sidebar-hover hover:text-sidebar-text"),
2444
+ children: [
2445
+ n.running ? /* @__PURE__ */ z("span", {
2446
+ className: "absolute left-0 top-1/2 h-3.5 w-0.5 -translate-y-1/2 rounded-full bg-primary",
2447
+ "aria-hidden": "true"
2448
+ }) : null,
2449
+ /* @__PURE__ */ z("div", {
2450
+ className: "min-w-0 flex-1 truncate text-[13px]",
2451
+ children: s(e)
2452
+ }),
2453
+ n.running ? /* @__PURE__ */ z(v, { className: "h-3.5 w-3.5 flex-shrink-0 animate-spin text-primary" }) : n.label ? /* @__PURE__ */ z("span", {
2454
+ className: "flex-shrink-0 text-[11px] leading-none text-sidebar-text-muted group-hover:hidden",
2455
+ children: n.label
2456
+ }) : null,
2457
+ /* @__PURE__ */ B("div", {
2458
+ className: "pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100",
2459
+ children: [/* @__PURE__ */ z("button", {
2460
+ type: "button",
2461
+ onClick: (t) => a(e.SessionId, t),
2462
+ className: Y("flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-sidebar-text", o && "text-primary opacity-100"),
2463
+ title: o ? "取消置顶" : "置顶会话",
2464
+ "aria-label": o ? "取消置顶会话" : "置顶会话",
2465
+ children: z(o ? te : D, { className: "h-3.5 w-3.5" })
2466
+ }), /* @__PURE__ */ z("button", {
2467
+ type: "button",
2468
+ onClick: (t) => i(e.SessionId, t),
2469
+ className: "flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-rose-500",
2470
+ title: "删除会话",
2471
+ children: /* @__PURE__ */ z(se, { className: "h-3.5 w-3.5" })
2472
+ })]
2473
+ })
2474
+ ]
2475
+ }, e.SessionId);
2476
+ }) : /* @__PURE__ */ z("div", {
2477
+ className: "rounded-xl border border-dashed border-black/[0.08] px-3 py-8 text-center text-xs text-sidebar-text-muted dark:border-white/[0.1]",
2478
+ children: "没有匹配的会话"
2479
+ }), u ? /* @__PURE__ */ B("div", {
2480
+ className: "flex items-center justify-center gap-2 px-3 py-3 text-xs text-sidebar-text-muted",
2481
+ children: [/* @__PURE__ */ z(v, { className: "h-3.5 w-3.5 animate-spin" }), /* @__PURE__ */ z("span", { children: "加载中" })]
2482
+ }) : null]
2483
+ })]
2484
+ }),
2485
+ /* @__PURE__ */ B("div", {
2486
+ className: "border-t border-black/[0.06] px-4 py-3 text-center dark:border-white/[0.08]",
2487
+ children: [
2488
+ /* @__PURE__ */ z("div", {
2489
+ className: "text-[10px] font-medium tracking-[0.14em] text-sidebar-text-muted",
2490
+ children: "POWERED BY"
2491
+ }),
2492
+ /* @__PURE__ */ z("div", {
2493
+ className: "mt-1 bg-gradient-to-r from-blue-600 to-indigo-500 bg-clip-text text-xs font-bold text-transparent dark:from-blue-400 dark:to-indigo-300",
2494
+ children: "Ksyun AgentEngine"
2495
+ }),
2496
+ /* @__PURE__ */ z("div", {
2497
+ className: "mx-auto mt-2 max-w-[13rem] text-[10px] leading-4 text-sidebar-text-muted",
2498
+ children: "Agent 可能产生不准确的信息,请独立验证。"
2499
+ })
2500
+ ]
2501
+ })
2502
+ ]
2503
+ });
2504
+ }
2505
+ //#endregion
2506
+ //#region src/components/native/NativeRuntimeLauncher.tsx
2507
+ var Sr = he(() => import("./NativeTerminalPanel-BTPHqbvY.js").then((e) => e.n).then((e) => ({ default: e.NativeTerminalPanel })));
2508
+ function Cr({ productLabel: e = "原生运行时", nativeManagementLink: t, nativeTerminal: n, workspaceEnabled: r, onOpenWorkspace: i }) {
2509
+ let a = !!n?.Enabled, [o, s] = q(!1);
2510
+ return /* @__PURE__ */ B("section", {
2511
+ className: "flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8",
2512
+ children: [/* @__PURE__ */ z("div", {
2513
+ className: "mx-auto flex w-full max-w-5xl flex-col justify-center",
2514
+ children: /* @__PURE__ */ B("div", {
2515
+ className: "overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30",
2516
+ children: [/* @__PURE__ */ B("div", {
2517
+ className: "border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8",
2518
+ children: [
2519
+ /* @__PURE__ */ B("div", {
2520
+ className: "inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300",
2521
+ children: [
2522
+ /* @__PURE__ */ z(k, { className: "h-3.5 w-3.5" }),
2523
+ e,
2524
+ " native runtime"
2525
+ ]
2526
+ }),
2527
+ /* @__PURE__ */ z("h1", {
2528
+ className: "mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl",
2529
+ children: "对话请使用原生管理台"
2530
+ }),
2531
+ /* @__PURE__ */ z("p", {
2532
+ className: "mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base",
2533
+ children: "当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。"
2534
+ })
2535
+ ]
2536
+ }), /* @__PURE__ */ B("div", {
2537
+ className: "grid gap-4 p-6 md:grid-cols-3 sm:p-8",
2538
+ children: [
2539
+ /* @__PURE__ */ B("div", {
2540
+ className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
2541
+ children: [
2542
+ /* @__PURE__ */ z("div", {
2543
+ className: "flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950",
2544
+ children: /* @__PURE__ */ z(x, { className: "h-5 w-5" })
2545
+ }),
2546
+ /* @__PURE__ */ z("h2", {
2547
+ className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
2548
+ children: "原生管理台"
2549
+ }),
2550
+ /* @__PURE__ */ z("p", {
2551
+ className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
2552
+ children: "使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。"
2553
+ }),
2554
+ t ? /* @__PURE__ */ B("a", {
2555
+ href: t.href,
2556
+ target: "_blank",
2557
+ rel: "noreferrer",
2558
+ title: t.title,
2559
+ className: "mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white",
2560
+ children: [
2561
+ /* @__PURE__ */ z(c, { className: "h-4 w-4" }),
2562
+ "打开",
2563
+ t.label
2564
+ ]
2565
+ }) : /* @__PURE__ */ z("div", {
2566
+ className: "mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200",
2567
+ children: "当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。"
2568
+ })
2569
+ ]
2570
+ }),
2571
+ /* @__PURE__ */ B("div", {
2572
+ className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
2573
+ children: [
2574
+ /* @__PURE__ */ z("div", {
2575
+ className: "flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300",
2576
+ children: /* @__PURE__ */ z(p, { className: "h-5 w-5" })
2577
+ }),
2578
+ /* @__PURE__ */ z("h2", {
2579
+ className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
2580
+ children: "Workspace 文件管理"
2581
+ }),
2582
+ /* @__PURE__ */ z("p", {
2583
+ className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
2584
+ children: "文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。"
2585
+ }),
2586
+ r ? /* @__PURE__ */ B("button", {
2587
+ type: "button",
2588
+ onClick: i,
2589
+ className: "mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700",
2590
+ children: [/* @__PURE__ */ z(p, { className: "h-4 w-4" }), "打开 Workspace"]
2591
+ }) : /* @__PURE__ */ z("div", {
2592
+ className: "mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400",
2593
+ children: "当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。"
2594
+ })
2595
+ ]
2596
+ }),
2597
+ /* @__PURE__ */ B("div", {
2598
+ className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
2599
+ children: [
2600
+ /* @__PURE__ */ z("div", {
2601
+ className: "flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",
2602
+ children: /* @__PURE__ */ z(M, { className: "h-5 w-5" })
2603
+ }),
2604
+ /* @__PURE__ */ z("h2", {
2605
+ className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
2606
+ children: "原生 TUI"
2607
+ }),
2608
+ /* @__PURE__ */ z("p", {
2609
+ className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
2610
+ children: "如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。"
2611
+ }),
2612
+ a ? /* @__PURE__ */ B("button", {
2613
+ type: "button",
2614
+ onClick: () => s(!0),
2615
+ className: "mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200",
2616
+ children: [/* @__PURE__ */ z(M, { className: "h-4 w-4" }), "打开 TUI"]
2617
+ }) : /* @__PURE__ */ z("div", {
2618
+ className: "mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400",
2619
+ children: "当前运行时未声明可用的浏览器 TUI 能力。"
2620
+ })
2621
+ ]
2622
+ })
2623
+ ]
2624
+ })]
2625
+ })
2626
+ }), n && o ? /* @__PURE__ */ z(H, {
2627
+ fallback: null,
2628
+ children: /* @__PURE__ */ z(Sr, {
2629
+ capability: n,
2630
+ open: o,
2631
+ onClose: () => s(!1)
2632
+ })
2633
+ }) : null]
2634
+ });
2635
+ }
2636
+ //#endregion
2637
+ //#region src/stores/ui.ts
2638
+ function wr(e, t) {
2639
+ return typeof t == "function" ? t(e) : t;
2640
+ }
2641
+ var Tr = L()((e) => ({
2642
+ sidebarOpen: !0,
2643
+ mobileSidebarOpen: !1,
2644
+ mobileActionsOpen: !1,
2645
+ workspacePanelOpen: !1,
2646
+ workspacePanelWidth: 820,
2647
+ workspacePanelFullscreen: !1,
2648
+ input: "",
2649
+ attachments: [],
2650
+ previewAttachment: null,
2651
+ previewImageSize: null,
2652
+ queuedDrafts: [],
2653
+ toasts: [],
2654
+ toggleSidebar: () => e((e) => ({ sidebarOpen: !e.sidebarOpen })),
2655
+ setSidebarOpen: (t) => e({ sidebarOpen: t }),
2656
+ toggleMobileSidebar: () => e((e) => ({ mobileSidebarOpen: !e.mobileSidebarOpen })),
2657
+ setMobileSidebarOpen: (t) => e({ mobileSidebarOpen: t }),
2658
+ toggleMobileActions: () => e((e) => ({ mobileActionsOpen: !e.mobileActionsOpen })),
2659
+ setMobileActionsOpen: (t) => e({ mobileActionsOpen: t }),
2660
+ setWorkspacePanelOpen: (t) => e({ workspacePanelOpen: t }),
2661
+ setWorkspacePanelWidth: (t) => e({ workspacePanelWidth: t }),
2662
+ setWorkspacePanelFullscreen: (t) => e({ workspacePanelFullscreen: t }),
2663
+ setInput: (t) => e({ input: t }),
2664
+ setAttachments: (t) => e((e) => ({ attachments: wr(e.attachments, t) })),
2665
+ setPreviewAttachment: (t) => e({ previewAttachment: t }),
2666
+ setPreviewImageSize: (t) => e({ previewImageSize: t }),
2667
+ setQueuedDrafts: (t) => e((e) => ({ queuedDrafts: wr(e.queuedDrafts, t) })),
2668
+ pushToast: (t, n = "info") => e((e) => ({ toasts: [...e.toasts, {
2669
+ id: String(Date.now() + Math.random()),
2670
+ message: t,
2671
+ variant: n,
2672
+ createdAt: Date.now()
2673
+ }] })),
2674
+ dismissToast: (t) => e((e) => ({ toasts: e.toasts.filter((e) => e.id !== t) }))
2675
+ }));
2676
+ //#endregion
2677
+ //#region src/components/workspace/FileEditor.tsx
2678
+ function Er(e) {
2679
+ let t = String(e || "").split("/").pop() || "", n = t.lastIndexOf(".");
2680
+ return n >= 0 ? t.slice(n) : "";
2681
+ }
2682
+ function Dr(e) {
2683
+ return Ue.matchFilename(rt, `file${e}`);
2684
+ }
2685
+ function Or({ content: e, path: t, readOnly: n = !1, onSave: r, onDirtyChange: i, onContentChange: a, getContentRef: o }) {
2686
+ let s = K(null), c = K(null), l = K(new Le()), u = K(new Le()), d = K(new Le()), f = K(!1), p = K(r), m = K(i), h = K(a);
2687
+ W(() => {
2688
+ p.current = r, m.current = i, h.current = a;
2689
+ }, [
2690
+ r,
2691
+ i,
2692
+ a
2693
+ ]);
2694
+ let g = U((e) => {
2695
+ f.current !== e && (f.current = e, m.current?.(e));
2696
+ }, []);
2697
+ return W(() => {
2698
+ if (!s.current) return;
2699
+ let r = document.documentElement.classList.contains("dark"), i = Pe.of([{
2700
+ key: "Mod-s",
2701
+ run: (e) => {
2702
+ let t = e.state.doc.toString();
2703
+ return p.current?.(t), g(!1), !0;
2704
+ },
2705
+ preventDefault: !0
2706
+ }]), a = new Oe({
2707
+ state: Re.create({
2708
+ doc: e,
2709
+ extensions: [
2710
+ Fe(),
2711
+ Ne(),
2712
+ Be(),
2713
+ Ke(),
2714
+ Ae(),
2715
+ je(),
2716
+ Re.allowMultipleSelections.of(!0),
2717
+ Je(),
2718
+ Ye(Ge, { fallback: !0 }),
2719
+ We(),
2720
+ et(),
2721
+ $e(),
2722
+ Ie(),
2723
+ ke(),
2724
+ Me(),
2725
+ Ze(),
2726
+ Pe.of([
2727
+ ...tt,
2728
+ ...ze,
2729
+ ...Qe,
2730
+ ...Ve,
2731
+ ...qe,
2732
+ ...nt,
2733
+ He
2734
+ ]),
2735
+ i,
2736
+ Oe.updateListener.of((e) => {
2737
+ e.docChanged && (g(!0), h.current?.(e.state.doc.toString()));
2738
+ }),
2739
+ d.current.of(Re.readOnly.of(n)),
2740
+ l.current.of([]),
2741
+ u.current.of(r ? Xe : []),
2742
+ Oe.theme({
2743
+ "&": { height: "100%" },
2744
+ ".cm-scroller": { overflow: "auto" }
2745
+ })
2746
+ ]
2747
+ }),
2748
+ parent: s.current
2749
+ });
2750
+ c.current = a, o && (o.current = () => a.state.doc.toString());
2751
+ let f = Dr(Er(t));
2752
+ return f && f.load().then((e) => {
2753
+ c.current && c.current.dispatch({ effects: l.current.reconfigure(e) });
2754
+ }).catch(() => {}), () => {
2755
+ a.destroy(), c.current = null, o && (o.current = null);
2756
+ };
2757
+ }, []), W(() => {
2758
+ let t = c.current;
2759
+ if (!t) return;
2760
+ let n = t.state.doc.toString();
2761
+ n !== e && (t.dispatch({ changes: {
2762
+ from: 0,
2763
+ to: n.length,
2764
+ insert: e
2765
+ } }), g(!1));
2766
+ }, [e, g]), W(() => {
2767
+ let e = c.current;
2768
+ if (!e) return;
2769
+ let n = Dr(Er(t));
2770
+ n ? n.load().then((e) => {
2771
+ c.current && c.current.dispatch({ effects: l.current.reconfigure(e) });
2772
+ }).catch(() => {}) : e.dispatch({ effects: l.current.reconfigure([]) });
2773
+ }, [t]), W(() => {
2774
+ let e = c.current;
2775
+ e && e.dispatch({ effects: d.current.reconfigure(Re.readOnly.of(n)) });
2776
+ }, [n]), W(() => {
2777
+ let e = new MutationObserver(() => {
2778
+ let e = c.current;
2779
+ if (!e) return;
2780
+ let t = document.documentElement.classList.contains("dark");
2781
+ e.dispatch({ effects: u.current.reconfigure(t ? Xe : []) });
2782
+ });
2783
+ return e.observe(document.documentElement, {
2784
+ attributes: !0,
2785
+ attributeFilter: ["class"]
2786
+ }), () => e.disconnect();
2787
+ }, []), /* @__PURE__ */ z("div", {
2788
+ ref: s,
2789
+ className: "h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto"
2790
+ });
2791
+ }
2792
+ //#endregion
2793
+ //#region src/components/workspace/FilePreview.tsx
2794
+ function kr({ content: e, objectUrl: t, kind: n, filename: r, path: i }) {
2795
+ return n === "markdown" ? /* @__PURE__ */ z(Z, { content: e || "" }) : n === "image" && t ? /* @__PURE__ */ z("div", {
2796
+ className: "flex items-center justify-center p-4",
2797
+ children: /* @__PURE__ */ z("img", {
2798
+ src: t,
2799
+ alt: r,
2800
+ className: "max-h-[70vh] max-w-full rounded object-contain"
2801
+ })
2802
+ }) : n === "pdf" && t ? /* @__PURE__ */ z("iframe", {
2803
+ src: t,
2804
+ title: r,
2805
+ className: "h-full w-full border-0"
2806
+ }) : (n === "text" || n === "code") && e !== null ? /* @__PURE__ */ z(Or, {
2807
+ content: e,
2808
+ path: i || r,
2809
+ readOnly: !0,
2810
+ onSave: () => {},
2811
+ onDirtyChange: () => {},
2812
+ getContentRef: { current: () => e || "" }
2813
+ }) : /* @__PURE__ */ z("div", {
2814
+ className: "flex h-full items-center justify-center px-6 text-center",
2815
+ children: /* @__PURE__ */ z("div", {
2816
+ className: "w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400",
2817
+ children: "该文件类型暂不支持在线预览,请直接下载查看。"
2818
+ })
2819
+ });
2820
+ }
2821
+ //#endregion
2822
+ //#region src/utils/sandbox.ts
2823
+ function Ar(e) {
2824
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2825
+ }
2826
+ function jr(e) {
2827
+ let t = e.endsWith("/") ? e : `${e}/`;
2828
+ if (typeof window > "u") return "'self'";
2829
+ try {
2830
+ return new URL(t, window.location.origin).toString();
2831
+ } catch {
2832
+ return "'self'";
2833
+ }
2834
+ }
2835
+ function Mr(...e) {
2836
+ return Array.from(new Set(e.filter((e) => !!e))).join(" ");
2837
+ }
2838
+ function Nr(e) {
2839
+ let t = e ? jr(e) : void 0, n = Mr("'unsafe-inline'", "'unsafe-eval'", "'self'", "https:", t), r = Mr("'self'", "https:", t);
2840
+ return [
2841
+ "default-src 'none'",
2842
+ `script-src ${n}`,
2843
+ `style-src 'unsafe-inline' data: ${r}`,
2844
+ `img-src data: blob: ${r}`,
2845
+ `font-src data: ${r}`,
2846
+ `media-src data: blob: ${r}`,
2847
+ "worker-src blob:",
2848
+ "connect-src 'none'",
2849
+ "form-action 'none'",
2850
+ "base-uri 'self'"
2851
+ ].join("; ");
2852
+ }
2853
+ function Pr(e) {
2854
+ try {
2855
+ let t = new URL(e, window.location.href);
2856
+ return [
2857
+ "http:",
2858
+ "https:",
2859
+ "mailto:"
2860
+ ].includes(t.protocol);
2861
+ } catch {
2862
+ return !1;
2863
+ }
2864
+ }
2865
+ function Fr(e, t = {}) {
2866
+ let { channelId: n, basePath: r } = typeof t == "string" ? { channelId: t } : t, i = Nr(r), a = `<script>
2867
+ function ksadkScrollToHash(rawHref) {
2868
+ if (!rawHref || rawHref === '#') return;
2869
+ var rawId = rawHref.slice(1);
2870
+ var id = rawId;
2871
+ try {
2872
+ id = decodeURIComponent(rawId);
2873
+ } catch (_) {}
2874
+ var target = document.getElementById(id) || document.getElementsByName(id)[0];
2875
+ if (target) {
2876
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
2877
+ }
2878
+ }
2879
+ document.addEventListener('click', function(event) {
2880
+ var target = event.target && event.target.closest ? event.target.closest('a') : null;
2881
+ if (!target) return;
2882
+ var rawHref = target.getAttribute('href') || '';
2883
+ if (rawHref.charAt(0) === '#') {
2884
+ event.preventDefault();
2885
+ ksadkScrollToHash(rawHref);
2886
+ return;
2887
+ }
2888
+ if (target.href) {
2889
+ event.preventDefault();
2890
+ window.parent.postMessage({
2891
+ type: 'ksadk:linkClick',
2892
+ channelId: ${JSON.stringify(n || "")},
2893
+ href: target.href,
2894
+ target: target.target || '_self'
2895
+ }, '*');
2896
+ }
2897
+ }, true);
2898
+ <\/script>`, o = `${`<meta http-equiv="Content-Security-Policy" content="${Ar(i)}">`}${r ? `<base href="${Ar(r)}">` : ""}${a}`;
2899
+ return /<head[^>]*>/i.test(e) ? e.replace(/<head[^>]*>/i, `$&${o}`) : `${o}${e}`;
2900
+ }
2901
+ function Ir(e, t) {
2902
+ let n = K(null);
2903
+ W(() => (n.current = (n) => {
2904
+ if (n.source !== e.current?.contentWindow || n.data?.type !== "ksadk:linkClick" || t && n.data?.channelId !== t) return;
2905
+ let r = n.data?.href;
2906
+ typeof r == "string" && r && Pr(r) && window.open(r, "_blank", "noopener,noreferrer");
2907
+ }, window.addEventListener("message", n.current), () => {
2908
+ n.current && window.removeEventListener("message", n.current);
2909
+ }), [e, t]);
2910
+ }
2911
+ var Lr = "/_ksadk/workspace/v1/files", Rr = new Set([
2912
+ ".md",
2913
+ ".markdown",
2914
+ ".mdx"
2915
+ ]), zr = new Set([".pdf"]), Br = new Set([
2916
+ ".png",
2917
+ ".jpg",
2918
+ ".jpeg",
2919
+ ".gif",
2920
+ ".webp",
2921
+ ".svg",
2922
+ ".bmp",
2923
+ ".ico"
2924
+ ]), Vr = new Set(/* @__PURE__ */ ".txt,.log,.json,.yaml,.yml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.sh,.sql,.csv,.tsv,.toml,.ini,.env,.lock,.conf,.c,.cc,.cpp,.go,.java,.rs".split(",")), Hr = new Set([
2925
+ "application/json",
2926
+ "application/ld+json",
2927
+ "application/xml",
2928
+ "application/javascript",
2929
+ "application/x-javascript",
2930
+ "application/typescript",
2931
+ "application/x-sh",
2932
+ "application/x-yaml",
2933
+ "application/yaml",
2934
+ "text/csv",
2935
+ "text/tab-separated-values"
2936
+ ]);
2937
+ function $(e) {
2938
+ let t = String(e || "").trim().replace(/\\/g, "/");
2939
+ if (!t || t === "/") return ".";
2940
+ let n = [];
2941
+ for (let e of t.split("/")) {
2942
+ let t = e.trim();
2943
+ if (!(!t || t === ".")) {
2944
+ if (t === "..") {
2945
+ n.length > 0 && n.pop();
2946
+ continue;
2947
+ }
2948
+ n.push(t);
2949
+ }
2950
+ }
2951
+ return n.length > 0 ? n.join("/") : ".";
2952
+ }
2953
+ function Ur(e) {
2954
+ let t = $(e);
2955
+ return t === "." ? "" : t.split("/").filter(Boolean).map((e) => encodeURIComponent(e)).join("/");
2956
+ }
2957
+ function Wr(e) {
2958
+ let t = Ur(e);
2959
+ return t ? `${Lr}/${t}` : Lr;
2960
+ }
2961
+ function Gr(e) {
2962
+ let t = $(e);
2963
+ if (t === "." || !t.includes("/")) return `${Lr}/`;
2964
+ let n = Ur(t.substring(0, t.lastIndexOf("/")));
2965
+ return n ? `${Lr}/${n}/` : `${Lr}/`;
2966
+ }
2967
+ function Kr(e) {
2968
+ return $(e) === ".";
2969
+ }
2970
+ function qr(e) {
2971
+ let t = $(e);
2972
+ return t === "." ? "/" : `/${t}`;
2973
+ }
2974
+ function Jr(e) {
2975
+ let t = String(e || "").split("/").pop() || "", n = t.lastIndexOf(".");
2976
+ return n >= 0 ? t.slice(n).toLowerCase() : "";
2977
+ }
2978
+ function Yr(e) {
2979
+ return String(e || "").split(";")[0].trim().toLowerCase();
2980
+ }
2981
+ var Xr = new Set([".html", ".htm"]);
2982
+ function Zr({ path: e, mimeType: t }) {
2983
+ let n = Jr(e), r = Yr(t);
2984
+ return r === "text/html" || Xr.has(n) ? "html" : r === "text/markdown" || Rr.has(n) ? "markdown" : r === "application/pdf" || zr.has(n) ? "pdf" : r.startsWith("image/") || Br.has(n) ? "image" : r.startsWith("text/") || Hr.has(r) || Vr.has(n) ? "text" : "unsupported";
2985
+ }
2986
+ var Qr = new Set([
2987
+ ".txt",
2988
+ ".log",
2989
+ ".csv",
2990
+ ".tsv",
2991
+ ".env",
2992
+ ".ini",
2993
+ ".conf",
2994
+ ".lock"
2995
+ ]);
2996
+ function $r({ path: e, mimeType: t }) {
2997
+ let n = Jr(e), r = Yr(t);
2998
+ return Xr.has(n) || r === "text/html" ? "html" : r === "text/markdown" || Rr.has(n) ? "markdown" : r === "application/pdf" || zr.has(n) || r.startsWith("image/") || Br.has(n) ? null : Qr.has(n) || r === "text/plain" ? "text" : r.startsWith("text/") || Hr.has(r) || Vr.has(n) ? "code" : null;
2999
+ }
3000
+ function ei({ isMobile: e }) {
3001
+ return e ? {
3002
+ renderMode: "sheet",
3003
+ modal: !0,
3004
+ showOverlay: !0,
3005
+ preventOutsideClose: !1,
3006
+ side: "bottom"
3007
+ } : {
3008
+ renderMode: "inline",
3009
+ modal: !1,
3010
+ showOverlay: !1,
3011
+ preventOutsideClose: !0,
3012
+ side: "right"
3013
+ };
3014
+ }
3015
+ function ti() {
3016
+ let e = 0;
3017
+ return {
3018
+ next(t) {
3019
+ return e += 1, {
3020
+ path: t,
3021
+ version: e
3022
+ };
3023
+ },
3024
+ invalidate() {
3025
+ e += 1;
3026
+ },
3027
+ isCurrent(t) {
3028
+ return !!t && t.version === e;
3029
+ }
3030
+ };
3031
+ }
3032
+ function ni({ workspaceFiles: e, accessMode: t }) {
3033
+ if (!e?.Enabled) return !1;
3034
+ let n = String(t || "").trim().toLowerCase();
3035
+ return n === "owner" || n === "private";
3036
+ }
3037
+ //#endregion
3038
+ //#region src/components/workspace/HtmlPreview.tsx
3039
+ function ri({ content: e, path: t, onSave: n, onDirtyChange: r, getContentRef: i, isMobile: o }) {
3040
+ let s = K(null), u = ge(), [d, f] = q("preview"), p = Gr(t), m = Wr(t), h = U(() => Fr(e, {
3041
+ basePath: p,
3042
+ channelId: u
3043
+ }), [
3044
+ e,
3045
+ p,
3046
+ u
3047
+ ]), [g, _] = q(h());
3048
+ W(() => {
3049
+ let e = setTimeout(() => {
3050
+ _(h());
3051
+ }, 300);
3052
+ return () => clearTimeout(e);
3053
+ }, [h]), Ir(s, u);
3054
+ let v = U(() => {
3055
+ let e = new Blob([g], { type: "text/html;charset=utf-8" }), t = URL.createObjectURL(e), n = window.open(t, "_blank", "noopener,noreferrer");
3056
+ window.setTimeout(() => URL.revokeObjectURL(t), 3e4), n || window.open(m, "_blank", "noopener,noreferrer");
3057
+ }, [m, g]);
3058
+ return o ? /* @__PURE__ */ B("div", {
3059
+ className: "flex h-full flex-col",
3060
+ children: [/* @__PURE__ */ B("div", {
3061
+ className: "flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700",
3062
+ children: [/* @__PURE__ */ B("button", {
3063
+ onClick: () => f("editor"),
3064
+ className: Y("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", d === "editor" ? "bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100" : "text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800"),
3065
+ children: [/* @__PURE__ */ z(a, { className: "h-3.5 w-3.5" }), "编辑"]
3066
+ }), /* @__PURE__ */ B("button", {
3067
+ onClick: () => f("preview"),
3068
+ className: Y("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", d === "preview" ? "bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100" : "text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800"),
3069
+ children: [/* @__PURE__ */ z(l, { className: "h-3.5 w-3.5" }), "预览"]
3070
+ })]
3071
+ }), d === "editor" ? /* @__PURE__ */ z(Or, {
3072
+ content: e,
3073
+ path: t,
3074
+ onSave: n,
3075
+ onDirtyChange: r,
3076
+ getContentRef: i
3077
+ }) : /* @__PURE__ */ z("iframe", {
3078
+ ref: s,
3079
+ srcDoc: g,
3080
+ sandbox: "allow-scripts allow-downloads allow-same-origin",
3081
+ title: "HTML 预览",
3082
+ className: "h-full w-full border-0 bg-white"
3083
+ })]
3084
+ }) : d === "editor" ? /* @__PURE__ */ B("div", {
3085
+ className: "relative flex h-full flex-col",
3086
+ children: [/* @__PURE__ */ z(Or, {
3087
+ content: e,
3088
+ path: t,
3089
+ onSave: n,
3090
+ onDirtyChange: r,
3091
+ getContentRef: i
3092
+ }), /* @__PURE__ */ B("button", {
3093
+ onClick: () => f("preview"),
3094
+ className: "absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700",
3095
+ children: [/* @__PURE__ */ z(l, { className: "h-3.5 w-3.5" }), "预览"]
3096
+ })]
3097
+ }) : /* @__PURE__ */ B("div", {
3098
+ className: "relative flex h-full flex-col",
3099
+ children: [/* @__PURE__ */ z("iframe", {
3100
+ ref: s,
3101
+ srcDoc: g,
3102
+ sandbox: "allow-scripts allow-downloads allow-same-origin",
3103
+ title: "HTML 预览",
3104
+ className: "h-full w-full border-0 bg-white"
3105
+ }), /* @__PURE__ */ B("div", {
3106
+ className: "absolute right-3 top-3 z-10 flex gap-1.5",
3107
+ children: [/* @__PURE__ */ B("button", {
3108
+ onClick: v,
3109
+ className: "inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700",
3110
+ title: "在新窗口中打开当前预览",
3111
+ children: [/* @__PURE__ */ z(c, { className: "h-3.5 w-3.5" }), "新窗口"]
3112
+ }), /* @__PURE__ */ B("button", {
3113
+ onClick: () => f("editor"),
3114
+ className: "inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700",
3115
+ children: [/* @__PURE__ */ z(a, { className: "h-3.5 w-3.5" }), "编辑"]
3116
+ })]
3117
+ })]
3118
+ });
3119
+ }
3120
+ //#endregion
3121
+ //#region src/components/workspace/MarkdownPreview.tsx
3122
+ function ii(e) {
3123
+ e.current && clearTimeout(e.current);
3124
+ }
3125
+ function ai({ content: e, path: t, onSave: n, onDirtyChange: r, getContentRef: i, isMobile: o }) {
3126
+ let [s, c] = q("editor"), [u, d] = q(e), f = K(null);
3127
+ return W(() => (ii(f), f.current = setTimeout(() => d(e), 300), () => ii(f)), [e]), o ? /* @__PURE__ */ B("div", {
3128
+ className: "flex h-full flex-col",
3129
+ children: [/* @__PURE__ */ B("div", {
3130
+ className: "flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30",
3131
+ children: [/* @__PURE__ */ B("button", {
3132
+ onClick: () => c("editor"),
3133
+ className: Y("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", s === "editor" ? "bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100" : "text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800"),
3134
+ children: [/* @__PURE__ */ z(a, { className: "h-3.5 w-3.5" }), "编辑"]
3135
+ }), /* @__PURE__ */ B("button", {
3136
+ onClick: () => c("preview"),
3137
+ className: Y("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", s === "preview" ? "bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100" : "text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800"),
3138
+ children: [/* @__PURE__ */ z(l, { className: "h-3.5 w-3.5" }), "预览"]
3139
+ })]
3140
+ }), s === "editor" ? /* @__PURE__ */ z(Or, {
3141
+ content: e,
3142
+ path: t,
3143
+ onSave: n,
3144
+ onDirtyChange: r,
3145
+ getContentRef: i
3146
+ }) : /* @__PURE__ */ z("div", {
3147
+ className: "flex-1 overflow-auto p-4",
3148
+ children: /* @__PURE__ */ z(Z, { content: u })
3149
+ })]
3150
+ }) : s === "editor" ? /* @__PURE__ */ B("div", {
3151
+ className: "relative flex h-full flex-col",
3152
+ children: [/* @__PURE__ */ z(Or, {
3153
+ content: e,
3154
+ path: t,
3155
+ onSave: n,
3156
+ onDirtyChange: r,
3157
+ getContentRef: i
3158
+ }), /* @__PURE__ */ B("button", {
3159
+ onClick: () => c("preview"),
3160
+ className: "absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700",
3161
+ children: [/* @__PURE__ */ z(l, { className: "h-3.5 w-3.5" }), "预览"]
3162
+ })]
3163
+ }) : /* @__PURE__ */ B("div", {
3164
+ className: "relative flex h-full flex-col",
3165
+ children: [/* @__PURE__ */ z("div", {
3166
+ className: "flex-1 overflow-auto p-4",
3167
+ children: /* @__PURE__ */ z(Z, { content: u })
3168
+ }), /* @__PURE__ */ B("button", {
3169
+ onClick: () => c("editor"),
3170
+ className: "absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700",
3171
+ children: [/* @__PURE__ */ z(a, { className: "h-3.5 w-3.5" }), "编辑"]
3172
+ })]
3173
+ });
3174
+ }
3175
+ //#endregion
3176
+ //#region src/components/workspace/WorkspacePanel.tsx
3177
+ var oi = "/agentengine/api/v1/GetWorkspaceFileContent", si = 4e3;
3178
+ function ci(e) {
3179
+ let t = $(e);
3180
+ if (!t || t === ".") return ".";
3181
+ let n = t.split("/").filter(Boolean);
3182
+ return n.length <= 1 ? "." : n.slice(0, -1).join("/");
3183
+ }
3184
+ function li(e) {
3185
+ if (!e) return "";
3186
+ let t = Date.parse(e);
3187
+ return Number.isNaN(t) ? e : new Date(t).toLocaleString();
3188
+ }
3189
+ function ui(e) {
3190
+ let t = Number(e);
3191
+ return !Number.isFinite(t) || t <= 0 ? "0 B" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(1)} GB`;
3192
+ }
3193
+ var di = [
3194
+ {
3195
+ label: "Markdown",
3196
+ detail: ".md .markdown .mdx"
3197
+ },
3198
+ {
3199
+ label: "代码/文本",
3200
+ detail: ".py .js .ts .tsx .json .yaml .log .txt"
3201
+ },
3202
+ {
3203
+ label: "图片",
3204
+ detail: "PNG JPG GIF WebP SVG"
3205
+ },
3206
+ {
3207
+ label: "PDF",
3208
+ detail: ".pdf"
3209
+ },
3210
+ {
3211
+ label: "表格文本",
3212
+ detail: "CSV TSV"
3213
+ }
3214
+ ];
3215
+ function fi(e) {
3216
+ return Wr(e);
3217
+ }
3218
+ function pi({ label: e, showSupportedTypes: t = !1 }) {
3219
+ return /* @__PURE__ */ z("div", {
3220
+ className: "flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center",
3221
+ children: /* @__PURE__ */ B("div", {
3222
+ className: "w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400",
3223
+ children: [/* @__PURE__ */ z("div", { children: e }), t ? /* @__PURE__ */ B("div", {
3224
+ className: "mt-4 text-left",
3225
+ children: [
3226
+ /* @__PURE__ */ z("div", {
3227
+ className: "text-xs font-semibold uppercase tracking-[0.12em] text-slate-400",
3228
+ children: "支持在线预览"
3229
+ }),
3230
+ /* @__PURE__ */ z("div", {
3231
+ className: "mt-2 grid gap-2",
3232
+ children: di.map((e) => /* @__PURE__ */ B("div", {
3233
+ className: "rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950",
3234
+ children: [/* @__PURE__ */ z("div", {
3235
+ className: "text-sm font-medium text-slate-700 dark:text-slate-200",
3236
+ children: e.label
3237
+ }), /* @__PURE__ */ z("div", {
3238
+ className: "mt-0.5 font-mono text-[11px] text-slate-400",
3239
+ children: e.detail
3240
+ })]
3241
+ }, e.label))
3242
+ }),
3243
+ /* @__PURE__ */ z("div", {
3244
+ className: "mt-3 text-xs leading-5 text-slate-400",
3245
+ children: "Word、Excel、PPT 当前不支持在线预览,可下载后查看。"
3246
+ })
3247
+ ]
3248
+ }) : null]
3249
+ })
3250
+ });
3251
+ }
3252
+ function mi({ agentId: e, capability: n, open: r, onClose: i, isFullscreen: a = !1, onToggleFullscreen: o, isMobile: c = !1, api: l }) {
3253
+ let d = K(null), m = K(null), [h, v] = q(!1), [b, x] = q("."), [C, ee] = q([]), [T, E] = q(!1), [D, te] = q(!1), [O, ie] = q(!1), [ae, k] = q(""), [A, oe] = q(null), [j, M] = q(null), [N, P] = q(!1), [le, ue] = q(!1), F = K(null), fe = K(null), pe = K("selection"), I = K(ti()), L = _e(() => C.find((e) => e.Path === A) ?? null, [C, A]), R = _e(() => L ? $r({
3254
+ path: L.Path,
3255
+ mimeType: L.MimeType
3256
+ }) : null, [L]), V = U(() => N ? window.confirm("当前文件有未保存的更改,确定要离开吗?") : !0, [N]), me = n.ContentPath || oi, H = n.RootLabel || "Workspace", he = H ? `${H.charAt(0).toUpperCase()}${H.slice(1)}` : "Workspace", ge = qr(b), G = U(() => {
3257
+ m.current &&= (URL.revokeObjectURL(m.current), null);
3258
+ }, []);
3259
+ W(() => () => G(), [G]);
3260
+ let J = U(async (t, n = {}) => {
3261
+ let r = !!n.background;
3262
+ r ? te(!0) : E(!0), r || k("");
3263
+ try {
3264
+ let n = await l.listWorkspaceFiles(e, t, !1), i = $(String(n?.Path || t || ".")), a = Array.isArray(n?.Entries) ? n.Entries : [];
3265
+ x(i), ee(a), pe.current = r ? "background-refresh" : "selection", oe((e) => {
3266
+ if (e) {
3267
+ let t = a.find((t) => t.Path === e);
3268
+ if (t && t.Type === "file") return e;
3269
+ }
3270
+ return a.find((e) => e.Type === "file")?.Path ?? null;
3271
+ });
3272
+ } catch (e) {
3273
+ console.error("Failed to load workspace entries:", e), r || k(e instanceof Error ? e.message : String(e));
3274
+ } finally {
3275
+ r ? te(!1) : E(!1);
3276
+ }
3277
+ }, [e, l]);
3278
+ W(() => {
3279
+ !r || h || (v(!0), J("."));
3280
+ }, [
3281
+ h,
3282
+ J,
3283
+ r
3284
+ ]), W(() => {
3285
+ if (!r || N || !h) return;
3286
+ let e = window.setInterval(() => {
3287
+ J(b, { background: !0 });
3288
+ }, si);
3289
+ return () => window.clearInterval(e);
3290
+ }, [
3291
+ b,
3292
+ N,
3293
+ h,
3294
+ J,
3295
+ r
3296
+ ]);
3297
+ let ve = U(async (t) => {
3298
+ let n = I.current.next(t.Path), r = Zr({
3299
+ path: t.Path,
3300
+ mimeType: t.MimeType
3301
+ });
3302
+ if (fe.current = t.Path, r === "unsupported") {
3303
+ G(), M({
3304
+ path: t.Path,
3305
+ kind: r,
3306
+ status: "ready",
3307
+ mimeType: t.MimeType ?? void 0
3308
+ });
3309
+ return;
3310
+ }
3311
+ G(), M({
3312
+ path: t.Path,
3313
+ kind: r,
3314
+ status: "loading",
3315
+ mimeType: t.MimeType ?? void 0
3316
+ });
3317
+ try {
3318
+ let r = await l.getWorkspaceFileContent(e, t.Path, { asText: !1 });
3319
+ if (!I.current.isCurrent(n)) return;
3320
+ if (r instanceof Blob) {
3321
+ let e = t.MimeType || "", i = Zr({
3322
+ path: t.Path,
3323
+ mimeType: e
3324
+ });
3325
+ if (i === "image" || i === "pdf") {
3326
+ let n = URL.createObjectURL(r);
3327
+ m.current = n, M({
3328
+ path: t.Path,
3329
+ kind: i,
3330
+ status: "ready",
3331
+ mimeType: e,
3332
+ objectUrl: n
3333
+ });
3334
+ return;
3335
+ }
3336
+ let a = await r.text();
3337
+ if (!I.current.isCurrent(n)) return;
3338
+ let o = Zr({
3339
+ path: t.Path,
3340
+ mimeType: e
3341
+ });
3342
+ M({
3343
+ path: t.Path,
3344
+ kind: o,
3345
+ status: "ready",
3346
+ mimeType: e,
3347
+ content: a
3348
+ });
3349
+ } else {
3350
+ let e = t.MimeType || "", n = Zr({
3351
+ path: t.Path,
3352
+ mimeType: e
3353
+ });
3354
+ M({
3355
+ path: t.Path,
3356
+ kind: n,
3357
+ status: "ready",
3358
+ mimeType: e,
3359
+ content: r
3360
+ });
3361
+ }
3362
+ } catch (e) {
3363
+ if (!I.current.isCurrent(n)) return;
3364
+ console.error("Failed to preview workspace file:", e), M({
3365
+ path: t.Path,
3366
+ kind: r,
3367
+ status: "error",
3368
+ mimeType: t.MimeType ?? void 0,
3369
+ error: e instanceof Error ? e.message : String(e)
3370
+ });
3371
+ }
3372
+ }, [
3373
+ e,
3374
+ l,
3375
+ G
3376
+ ]);
3377
+ W(() => {
3378
+ if (!L || L.Type !== "file") {
3379
+ G(), M(null), P(!1), fe.current = null;
3380
+ return;
3381
+ }
3382
+ if (pe.current === "background-refresh" && fe.current === L.Path) {
3383
+ pe.current = "selection";
3384
+ return;
3385
+ }
3386
+ pe.current = "selection", ve(L);
3387
+ }, [
3388
+ G,
3389
+ ve,
3390
+ L
3391
+ ]);
3392
+ let ye = async (t) => {
3393
+ if (!(!t || t.length === 0)) {
3394
+ ie(!0), k("");
3395
+ try {
3396
+ for (let r of Array.from(t)) {
3397
+ if (r.size > n.MaxUploadBytes) throw Error(`文件 ${r.name} 超过上传上限`);
3398
+ let t = Kr(b) ? r.name : `${b}/${r.name}`, i = new FormData();
3399
+ i.append("file", r), i.append("AgentId", e), i.append("Path", t), await l.addWorkspaceFile(i);
3400
+ }
3401
+ await J(b);
3402
+ } catch (e) {
3403
+ console.error("Failed to upload workspace files:", e), k(e instanceof Error ? e.message : String(e));
3404
+ } finally {
3405
+ d.current && (d.current.value = ""), ie(!1);
3406
+ }
3407
+ }
3408
+ }, be = async (t) => {
3409
+ if (!n.SupportsDelete) return;
3410
+ let r = $(t.Path);
3411
+ if (window.confirm(`删除 ${r} ?`)) {
3412
+ k("");
3413
+ try {
3414
+ await l.deleteWorkspaceFile(e, r), A && $(A) === r && (oe(null), P(!1)), await J(t.Type === "directory" && ($(b) === r || $(b).startsWith(`${r}/`)) ? ci(r) : b);
3415
+ } catch (e) {
3416
+ console.error("Failed to delete workspace file:", e), k(e instanceof Error ? e.message : String(e));
3417
+ }
3418
+ }
3419
+ }, xe = () => !L || L.Type !== "file" ? /* @__PURE__ */ z(pi, {
3420
+ label: "从左侧选择文件后在这里查看内容预览。",
3421
+ showSupportedTypes: !0
3422
+ }) : !j || j.path !== L.Path || j.status === "loading" ? /* @__PURE__ */ z("div", {
3423
+ className: "flex h-full min-h-[16rem] items-center justify-center",
3424
+ children: /* @__PURE__ */ B("div", {
3425
+ className: "inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400",
3426
+ children: [/* @__PURE__ */ z(_, { className: "h-4 w-4 animate-spin" }), "正在加载预览..."]
3427
+ })
3428
+ }) : j.status === "error" ? /* @__PURE__ */ z(pi, { label: j.error || "文件预览加载失败。" }) : j.kind === "markdown" ? /* @__PURE__ */ z(ai, {
3429
+ content: j.content || "",
3430
+ path: L.Path,
3431
+ onSave: Se,
3432
+ onDirtyChange: P,
3433
+ getContentRef: F,
3434
+ isMobile: c
3435
+ }) : j.kind === "image" && j.objectUrl ? /* @__PURE__ */ z(kr, {
3436
+ content: null,
3437
+ objectUrl: j.objectUrl,
3438
+ kind: "image",
3439
+ filename: L.Name,
3440
+ mimeType: j.mimeType || ""
3441
+ }) : j.kind === "pdf" && j.objectUrl ? /* @__PURE__ */ z(kr, {
3442
+ content: null,
3443
+ objectUrl: j.objectUrl,
3444
+ kind: "pdf",
3445
+ filename: L.Name,
3446
+ mimeType: j.mimeType || ""
3447
+ }) : j.kind === "html" ? /* @__PURE__ */ z(ri, {
3448
+ content: j.content || "",
3449
+ path: L.Path,
3450
+ onSave: Se,
3451
+ onDirtyChange: P,
3452
+ getContentRef: F,
3453
+ isMobile: c,
3454
+ agentId: e,
3455
+ contentPath: me
3456
+ }) : j.kind === "text" || j.kind === "code" ? /* @__PURE__ */ z(Or, {
3457
+ content: j.content || "",
3458
+ path: L.Path,
3459
+ onSave: Se,
3460
+ onDirtyChange: P,
3461
+ getContentRef: F
3462
+ }) : /* @__PURE__ */ z(kr, {
3463
+ content: null,
3464
+ kind: "unsupported",
3465
+ filename: L.Name,
3466
+ mimeType: j.mimeType || ""
3467
+ }), Se = async (t) => {
3468
+ if (L) {
3469
+ ue(!0), k("");
3470
+ try {
3471
+ let n = new Blob([t], { type: L.MimeType || "text/plain" }), r = new FormData();
3472
+ r.append("file", n, L.Name), r.append("AgentId", e), r.append("Path", L.Path), await l.addWorkspaceFile(r), I.current.invalidate(), P(!1), M((e) => e && e.path === L.Path ? {
3473
+ ...e,
3474
+ content: t
3475
+ } : e), fe.current = L.Path, await J(b, { background: !0 });
3476
+ } catch (e) {
3477
+ console.error("Failed to save workspace file:", e), k(e instanceof Error ? e.message : String(e));
3478
+ } finally {
3479
+ ue(!1);
3480
+ }
3481
+ }
3482
+ }, Ce = L?.Type === "file" && j?.path === L.Path && j.status === "ready" && (j.kind === "text" || j.kind === "code" || j.kind === "html" || j.kind === "markdown"), we = L?.Type === "file" && j?.path === L.Path && j.status === "ready" && j.kind === "pdf";
3483
+ return /* @__PURE__ */ B("div", {
3484
+ className: "flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200",
3485
+ children: [/* @__PURE__ */ B("div", {
3486
+ className: "flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40",
3487
+ children: [/* @__PURE__ */ B("div", {
3488
+ className: "flex min-w-0 flex-1 items-center gap-3",
3489
+ children: [
3490
+ /* @__PURE__ */ z("div", {
3491
+ className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100",
3492
+ children: he
3493
+ }),
3494
+ /* @__PURE__ */ z("div", { className: "hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block" }),
3495
+ /* @__PURE__ */ B("div", {
3496
+ className: "flex min-w-0 items-center gap-2",
3497
+ children: [/* @__PURE__ */ z("span", {
3498
+ className: "flex-shrink-0 text-xs text-slate-400",
3499
+ children: "当前目录"
3500
+ }), /* @__PURE__ */ z("div", {
3501
+ className: "custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300",
3502
+ title: `${ge},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,
3503
+ children: ge
3504
+ })]
3505
+ }),
3506
+ /* @__PURE__ */ z("div", {
3507
+ className: "hidden truncate text-[11px] text-slate-400 xl:block",
3508
+ children: "工作区内相对路径,不是宿主机绝对路径。"
3509
+ })
3510
+ ]
3511
+ }), /* @__PURE__ */ B("div", {
3512
+ className: "flex flex-shrink-0 items-center gap-1.5",
3513
+ children: [
3514
+ /* @__PURE__ */ z("input", {
3515
+ ref: d,
3516
+ type: "file",
3517
+ multiple: !0,
3518
+ className: "hidden",
3519
+ onChange: (e) => void ye(e.target.files)
3520
+ }),
3521
+ /* @__PURE__ */ B("button", {
3522
+ type: "button",
3523
+ onClick: () => d.current?.click(),
3524
+ disabled: O,
3525
+ className: "inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900",
3526
+ title: `上传文件,上限 ${Math.floor(n.MaxUploadBytes / (1024 * 1024))}MB`,
3527
+ children: [/* @__PURE__ */ z(ce, { className: "h-3.5 w-3.5" }), O ? "上传中" : "上传"]
3528
+ }),
3529
+ /* @__PURE__ */ B("button", {
3530
+ type: "button",
3531
+ onClick: () => {
3532
+ let e = new URLSearchParams({ Path: b }).toString();
3533
+ window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`, "_blank", "noopener,noreferrer");
3534
+ },
3535
+ className: "inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900",
3536
+ title: "导出当前目录为 ZIP",
3537
+ children: [/* @__PURE__ */ z(w, { className: "h-3.5 w-3.5" }), "导出"]
3538
+ }),
3539
+ o ? /* @__PURE__ */ z("button", {
3540
+ type: "button",
3541
+ onClick: o,
3542
+ className: "rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100",
3543
+ "aria-label": a ? "退出全屏" : "全屏查看 Workspace",
3544
+ title: a ? "退出全屏" : "全屏查看",
3545
+ children: z(a ? S : y, { className: "h-4 w-4" })
3546
+ }) : null,
3547
+ i ? /* @__PURE__ */ z("button", {
3548
+ type: "button",
3549
+ onClick: () => {
3550
+ V() && i?.();
3551
+ },
3552
+ className: "rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100",
3553
+ "aria-label": "关闭 Workspace",
3554
+ title: "关闭",
3555
+ children: /* @__PURE__ */ z(de, { className: "h-4 w-4" })
3556
+ }) : null
3557
+ ]
3558
+ })]
3559
+ }), /* @__PURE__ */ B("div", {
3560
+ className: "flex min-h-0 flex-1 flex-col md:flex-row",
3561
+ children: [/* @__PURE__ */ B("div", {
3562
+ className: "flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r",
3563
+ children: [/* @__PURE__ */ B("div", {
3564
+ className: "flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40",
3565
+ children: [/* @__PURE__ */ B("div", {
3566
+ className: "flex items-center justify-between gap-2",
3567
+ children: [/* @__PURE__ */ B("div", {
3568
+ className: "min-w-0",
3569
+ children: [/* @__PURE__ */ z("div", {
3570
+ className: "text-xs font-medium text-slate-900 dark:text-slate-100",
3571
+ children: "文件"
3572
+ }), /* @__PURE__ */ B("div", {
3573
+ className: "flex items-center gap-1 text-[11px] text-slate-400",
3574
+ children: [/* @__PURE__ */ B("span", { children: [C.length, " 项"] }), D ? /* @__PURE__ */ z(ne, {
3575
+ className: "h-3 w-3 animate-spin",
3576
+ "aria-label": "正在同步 Workspace 目录"
3577
+ }) : null]
3578
+ })]
3579
+ }), /* @__PURE__ */ B("div", {
3580
+ className: "flex items-center gap-1",
3581
+ children: [/* @__PURE__ */ z("button", {
3582
+ type: "button",
3583
+ onClick: () => {
3584
+ V() && J(ci(b));
3585
+ },
3586
+ disabled: T || Kr(b),
3587
+ className: "rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900",
3588
+ title: "返回上级目录",
3589
+ children: /* @__PURE__ */ z(t, { className: "h-4 w-4" })
3590
+ }), /* @__PURE__ */ z("button", {
3591
+ type: "button",
3592
+ onClick: () => {
3593
+ V() && J(b);
3594
+ },
3595
+ disabled: T,
3596
+ className: "rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900",
3597
+ title: "刷新目录",
3598
+ children: /* @__PURE__ */ z(ne, { className: `h-4 w-4 ${T ? "animate-spin" : ""}` })
3599
+ })]
3600
+ })]
3601
+ }), ae ? /* @__PURE__ */ z("div", {
3602
+ className: "mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300",
3603
+ children: ae
3604
+ }) : null]
3605
+ }), /* @__PURE__ */ z("div", {
3606
+ className: "custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2",
3607
+ children: !h && !r ? /* @__PURE__ */ z("div", {
3608
+ className: "px-3 py-4 text-sm text-slate-400",
3609
+ children: "打开面板后加载 workspace 文件。"
3610
+ }) : T ? /* @__PURE__ */ z("div", {
3611
+ className: "px-3 py-4 text-sm text-slate-400",
3612
+ children: "正在加载目录..."
3613
+ }) : C.length === 0 ? /* @__PURE__ */ z("div", {
3614
+ className: "px-3 py-4 text-sm text-slate-400",
3615
+ children: "当前目录为空。"
3616
+ }) : /* @__PURE__ */ z("div", {
3617
+ className: "space-y-0.5",
3618
+ children: C.map((e) => {
3619
+ let t = Zr({
3620
+ path: e.Path,
3621
+ mimeType: e.MimeType
3622
+ }), r = A === e.Path, i = e.Type === "file" ? fi(e.Path) : "";
3623
+ return /* @__PURE__ */ B("div", {
3624
+ title: e.Path,
3625
+ className: Y("group flex items-center gap-1 rounded-lg px-1.5 py-1 transition", r ? "bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50" : "text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900"),
3626
+ children: [/* @__PURE__ */ B("button", {
3627
+ type: "button",
3628
+ onClick: () => {
3629
+ if (e.Type === "directory") {
3630
+ J(e.Path);
3631
+ return;
3632
+ }
3633
+ A !== e.Path && !V() || oe(e.Path);
3634
+ },
3635
+ className: "flex min-w-0 flex-1 items-center gap-2 text-left",
3636
+ children: [/* @__PURE__ */ z("div", {
3637
+ className: Y("flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md", r ? "text-slate-900 dark:text-slate-50" : "text-slate-400 dark:text-slate-500"),
3638
+ children: e.Type === "directory" ? /* @__PURE__ */ z(p, { className: "h-3.5 w-3.5" }) : z(t === "image" ? g : t === "markdown" || t === "text" || t === "html" ? u : f, { className: "h-3.5 w-3.5" })
3639
+ }), /* @__PURE__ */ B("div", {
3640
+ className: "min-w-0 flex-1",
3641
+ children: [/* @__PURE__ */ z("div", {
3642
+ className: "truncate text-[13px] leading-5",
3643
+ children: e.Name
3644
+ }), /* @__PURE__ */ z("div", {
3645
+ className: Y("truncate text-[11px] leading-4", r ? "text-slate-500 dark:text-slate-400" : "text-slate-400"),
3646
+ children: e.Type === "directory" ? "目录" : ui(e.SizeBytes)
3647
+ })]
3648
+ })]
3649
+ }), /* @__PURE__ */ B("div", {
3650
+ className: "flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100",
3651
+ children: [e.Type === "file" ? /* @__PURE__ */ z("a", {
3652
+ href: i,
3653
+ download: e.Name,
3654
+ className: Y("rounded-md p-1.5 transition", r ? "hover:bg-white dark:hover:bg-slate-700" : "hover:bg-slate-100 dark:hover:bg-slate-800"),
3655
+ title: "下载",
3656
+ children: /* @__PURE__ */ z(s, { className: "h-3.5 w-3.5" })
3657
+ }) : null, n.SupportsDelete ? /* @__PURE__ */ z("button", {
3658
+ type: "button",
3659
+ onClick: () => void be(e),
3660
+ className: Y("rounded-md p-1.5 transition", r ? "hover:bg-white dark:hover:bg-slate-700" : "hover:bg-slate-100 dark:hover:bg-slate-800"),
3661
+ title: "删除",
3662
+ children: /* @__PURE__ */ z(se, { className: "h-3.5 w-3.5" })
3663
+ }) : null]
3664
+ })]
3665
+ }, e.Path);
3666
+ })
3667
+ })
3668
+ })]
3669
+ }), /* @__PURE__ */ B("div", {
3670
+ className: "flex min-h-0 min-w-0 flex-1 flex-col",
3671
+ children: [/* @__PURE__ */ z("div", {
3672
+ className: "flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40",
3673
+ children: L ? /* @__PURE__ */ B("div", {
3674
+ className: "flex w-full items-start justify-between gap-3",
3675
+ children: [/* @__PURE__ */ B("div", {
3676
+ className: "min-w-0",
3677
+ children: [
3678
+ /* @__PURE__ */ z("div", {
3679
+ className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100",
3680
+ children: L.Name
3681
+ }),
3682
+ /* @__PURE__ */ z("div", {
3683
+ className: "mt-0.5 break-all font-mono text-[11px] text-slate-400",
3684
+ children: L.Path
3685
+ }),
3686
+ /* @__PURE__ */ B("div", {
3687
+ className: "mt-1 text-[11px] text-slate-400",
3688
+ children: [
3689
+ ui(L.SizeBytes),
3690
+ L.MimeType ? ` · ${L.MimeType}` : "",
3691
+ L.ModifiedAt ? ` · ${li(L.ModifiedAt)}` : ""
3692
+ ]
3693
+ })
3694
+ ]
3695
+ }), R === "text" || R === "code" || R === "html" || R === "markdown" ? /* @__PURE__ */ B("button", {
3696
+ type: "button",
3697
+ onClick: () => {
3698
+ let e = F.current;
3699
+ e && Se(e());
3700
+ },
3701
+ disabled: !N || le,
3702
+ className: Y("inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition", N && !le ? "bg-blue-600 text-white hover:bg-blue-700" : "text-slate-400 dark:text-slate-500 cursor-not-allowed"),
3703
+ children: [/* @__PURE__ */ z(re, { className: "h-3.5 w-3.5" }), le ? "保存中" : N ? "保存" : "已保存"]
3704
+ }) : null]
3705
+ }) : /* @__PURE__ */ B("div", {
3706
+ className: "w-full",
3707
+ children: [/* @__PURE__ */ z("div", {
3708
+ className: "text-sm font-semibold text-slate-900 dark:text-slate-100",
3709
+ children: "文件预览"
3710
+ }), /* @__PURE__ */ z("div", {
3711
+ className: "mt-0.5 text-xs text-slate-500 dark:text-slate-400",
3712
+ children: "选择左侧文件后可在此查看内容。"
3713
+ })]
3714
+ })
3715
+ }), /* @__PURE__ */ z("div", {
3716
+ className: Y("custom-scrollbar min-h-0 flex-1", we || Ce ? "overflow-hidden p-0" : "overflow-y-auto px-4 py-4"),
3717
+ children: xe()
3718
+ })]
3719
+ })]
3720
+ })]
3721
+ });
3722
+ }
3723
+ //#endregion
3724
+ //#region src/components/workspace/WorkspacePanelContainer.tsx
3725
+ function hi({ agentId: e, capability: t, workspacePanelOpen: n, workspacePanelWidth: r, workspacePanelFullscreen: i, isMobile: a, workspaceEnabled: o, workspaceFiles: s, workspacePanelPresentation: c, closeWorkspacePanel: l, handleWorkspacePanelResizeStart: u, api: d }) {
3726
+ let f = c.renderMode === "inline", p = c.renderMode === "sheet";
3727
+ return !o || !s ? null : /* @__PURE__ */ B(R, { children: [f ? /* @__PURE__ */ B(R, { children: [n && !i ? /* @__PURE__ */ z("div", {
3728
+ role: "separator",
3729
+ "aria-label": "调整 Workspace 宽度",
3730
+ "aria-orientation": "vertical",
3731
+ onPointerDown: u,
3732
+ className: "hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block"
3733
+ }) : null, /* @__PURE__ */ z("aside", {
3734
+ style: n && !i ? { width: `${r}px` } : void 0,
3735
+ className: Y(i ? "fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950" : "hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex", n ? "border-l border-slate-200/30 dark:border-slate-800/40" : "w-0 border-l border-transparent"),
3736
+ children: n ? /* @__PURE__ */ z(mi, {
3737
+ agentId: e,
3738
+ capability: t,
3739
+ open: n,
3740
+ onClose: l,
3741
+ isFullscreen: i,
3742
+ onToggleFullscreen: () => Tr.getState().setWorkspacePanelFullscreen(!i),
3743
+ isMobile: a,
3744
+ api: d
3745
+ }) : null
3746
+ })] }) : null, p ? /* @__PURE__ */ z(bt, {
3747
+ open: n,
3748
+ onOpenChange: (e) => {
3749
+ e || Tr.getState().setWorkspacePanelFullscreen(!1), Tr.getState().setWorkspacePanelOpen(e);
3750
+ },
3751
+ modal: c.modal,
3752
+ children: /* @__PURE__ */ B(wt, {
3753
+ side: c.side,
3754
+ showOverlay: c.showOverlay,
3755
+ onInteractOutside: (e) => {
3756
+ c.preventOutsideClose && e.preventDefault();
3757
+ },
3758
+ showCloseButton: !1,
3759
+ className: Y("border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950", a ? "h-[70vh] rounded-t-[1.75rem]" : "h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl"),
3760
+ children: [
3761
+ /* @__PURE__ */ z(Dt, {
3762
+ className: "sr-only",
3763
+ children: "Workspace 文件"
3764
+ }),
3765
+ /* @__PURE__ */ z(Ot, {
3766
+ className: "sr-only",
3767
+ children: "浏览、上传和预览 Workspace 文件。"
3768
+ }),
3769
+ /* @__PURE__ */ z(mi, {
3770
+ agentId: e,
3771
+ capability: t,
3772
+ open: n,
3773
+ onClose: l,
3774
+ isMobile: a,
3775
+ api: d
3776
+ })
3777
+ ]
3778
+ })
3779
+ }) : null] });
3780
+ }
3781
+ //#endregion
3782
+ export { Dt as A, gn as C, bt as D, jt as E, at as F, Y as I, ht as M, ct as N, wt as O, st as P, xn as S, Kt as T, Cn as _, Ir as a, bn as b, xr as c, Gn as d, Bn as f, Sn as g, wn as h, Fr as i, yt as j, Ot as k, dr as l, Ln as m, ni as n, Tr as o, zn as p, ei as r, Cr as s, hi as t, Wn as u, Dn as v, Z as w, En as x, Tn as y };