@kingsoftcloud/ksadk-web 0.3.4 → 0.3.5

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 (273) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +31 -0
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-10GPXIJ6.js → ArtifactsPanel-9RUQms_7.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-BXk1l-G1.js → CodeBlock-iq6mFygx.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-D9uB55Oh.js → MathMessageMarkdown-DSd_MMwp.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock--OEYoXIJ.js → MermaidBlock-B1tXyzN9.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-DrEe1syq.js → NativeTerminalPanel-BTTm24gh.js} +1 -1
  9. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-eeTFJLvo.js → abnfDiagram-VCTEODGH-CrPuGQ-J.js} +1 -1
  10. package/dist-ksadk/assets/{arc-S3ZNbIAd.js → arc-LSpozW7f.js} +1 -1
  11. package/dist-ksadk/assets/architecture-7GRP2DOG-DlLqIl7c.js +1 -0
  12. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-CRjgEJDX.js → architectureDiagram-5GKGNRK7-BiBddfc6.js} +1 -1
  13. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-C7bsBoNH.js → blockDiagram-NRAW4CY4-Cfpt59CA.js} +1 -1
  14. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BX3c33Ob.js → c4Diagram-UCG6FXSJ-TtkMYecK.js} +1 -1
  15. package/dist-ksadk/assets/channel-cg7jYcXF.js +1 -0
  16. package/dist-ksadk/assets/chunk-2Q5K7J3B-C4iMKTWb.js +1 -0
  17. package/dist-ksadk/assets/{chunk-5VM5RSS4-bZ7ws-8m.js → chunk-5VM5RSS4-QNTrS1KC.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-F27PBJKO-D2r0pvhY.js → chunk-F27PBJKO-CHsVsbjO.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-G27WJ6UU-CZwF3oUP.js → chunk-G27WJ6UU-BiyNaPce.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-JWPE2WC7-DigFYCML.js → chunk-JWPE2WC7-EjVrwIfj.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-LCL6LL3I-CnorGV5q.js → chunk-LCL6LL3I-BCXNTVwQ.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-POPQ4Y6H-CexntQA-.js → chunk-POPQ4Y6H-BNP6opFp.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-RHFEMEQ7-CHTC7UxA.js → chunk-RHFEMEQ7-CroPk1q-.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-SVP7TREG-BC1EWt_-.js → chunk-SVP7TREG-8eF2thNo.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-XXDRQBXY-BTG24xN0.js → chunk-XXDRQBXY-CfKEfSWB.js} +1 -1
  26. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-RtbaG_Dz.js +1 -0
  27. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-RtbaG_Dz.js +1 -0
  28. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-CkonRdAS.js → cose-bilkent-JH36ORCC-NYLLr4y3.js} +1 -1
  29. package/dist-ksadk/assets/cynefin-OW5HDTMX-BRs0UJ32.js +1 -0
  30. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-DEOCBe15.js → cynefinDiagram-5FMLGOSQ-1t2bjASn.js} +1 -1
  31. package/dist-ksadk/assets/{dagre-3AP2YEHR-DBThPuLa.js → dagre-3AP2YEHR-CyCcpGXQ.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-ClTPrTht.js → dagre-DIBkWWe5.js} +1 -1
  33. package/dist-ksadk/assets/{diagram-S7CK7UJ4-DsZHrnpJ.js → diagram-S7CK7UJ4-Qnyx09fY.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-UQ7AKVKN-BJR4nhVr.js → diagram-UQ7AKVKN-BBuBi2BK.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-VSXAHHWV-xzcERX0a.js → diagram-VSXAHHWV-Cu2pi7DX.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VX7I27RA-tn2xM1xu.js → diagram-VX7I27RA-D1hy0wPv.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-Z3DM3KII-BZPGBkw5.js → diagram-Z3DM3KII-DG_ukeOg.js} +1 -1
  38. package/dist-ksadk/assets/{dist-B1oWRmrH.js → dist-32Woo6w8.js} +1 -1
  39. package/dist-ksadk/assets/{dist-Btyo4vX4.js → dist-39frJg8c.js} +1 -1
  40. package/dist-ksadk/assets/{dist-DjhwGUgZ.js → dist-7mNpnBIq.js} +1 -1
  41. package/dist-ksadk/assets/{dist-C71CsujO.js → dist-BDYKkv8k.js} +1 -1
  42. package/dist-ksadk/assets/{dist-4zN1_tq5.js → dist-BRFE6wml.js} +1 -1
  43. package/dist-ksadk/assets/{dist-DdRBIceA.js → dist-Bami3Hbn.js} +1 -1
  44. package/dist-ksadk/assets/{dist-u8tVH5Ak.js → dist-BbqgJcRm.js} +1 -1
  45. package/dist-ksadk/assets/{dist-CXpH_Rdd.js → dist-Bo0uuYGj.js} +1 -1
  46. package/dist-ksadk/assets/{dist-BI1qQH4n.js → dist-BoDw8sHC.js} +1 -1
  47. package/dist-ksadk/assets/{dist-DJmCPRVB.js → dist-Bzd96FWg.js} +1 -1
  48. package/dist-ksadk/assets/{dist-BJLUwH6W.js → dist-C6YcRSBB.js} +1 -1
  49. package/dist-ksadk/assets/{dist-Cq4OL6nO.js → dist-C8E2u2Gy.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DyqV4fL4.js → dist-CgpyS7Tw.js} +1 -1
  51. package/dist-ksadk/assets/{dist-D1V3f1B4.js → dist-CsdC51-G.js} +1 -1
  52. package/dist-ksadk/assets/{dist-8VWI-2bZ.js → dist-D0t-jg0i.js} +1 -1
  53. package/dist-ksadk/assets/{dist-DQAB0qn_.js → dist-D2l4f5Dh.js} +1 -1
  54. package/dist-ksadk/assets/{dist-DfGFrb0v.js → dist-Dbb1c9iJ.js} +1 -1
  55. package/dist-ksadk/assets/{dist-B-46q3Hk.js → dist-_RQDZ9v3.js} +1 -1
  56. package/dist-ksadk/assets/{dist-Bbwqa8TG.js → dist-dLCAHoLT.js} +1 -1
  57. package/dist-ksadk/assets/{dist-B0gdk4rl.js → dist-mo17RERT.js} +1 -1
  58. package/dist-ksadk/assets/{dist-M67Hwu0n.js → dist-snMJ4dAH.js} +1 -1
  59. package/dist-ksadk/assets/{dist-DUwKa_l6.js → dist-vM3yu1Iv.js} +1 -1
  60. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-DVfMsLge.js → ebnfDiagram-PWID7BFC-DuBo2W05.js} +1 -1
  61. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CWEZSYaw.js → erDiagram-SSCWMZ5O-ZJrJetMD.js} +1 -1
  62. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DCJzsswd.js +1 -0
  63. package/dist-ksadk/assets/flowDiagram-A5DVABFB-485rByL2.js +1 -0
  64. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-TWIxoyYL.js → ganttDiagram-EL5Y4UJY-Bwk2yIEM.js} +1 -1
  65. package/dist-ksadk/assets/gitGraph-4MIJSDKK-C5VB4yJL.js +1 -0
  66. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DDh2hd2S.js → gitGraphDiagram-WWUBYQGX-DWYLIagz.js} +1 -1
  67. package/dist-ksadk/assets/index-Cp5NEP4y.css +2 -0
  68. package/dist-ksadk/assets/index-j3aFdsSv.js +244 -0
  69. package/dist-ksadk/assets/info-A6RAGUB7-tqDdMmNT.js +1 -0
  70. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-CgoyWiDR.js → infoDiagram-RXCK75RN-DMPen5_h.js} +1 -1
  71. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-CyRIu_om.js → ishikawaDiagram-5VMMS53U-DsPNKFIz.js} +1 -1
  72. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DN5JXHzN.js → journeyDiagram-EYS64GPL-BNbTP-8a.js} +1 -1
  73. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CNP3ui66.js → kanban-definition-3QL26DDD-BKR6Itkv.js} +1 -1
  74. package/dist-ksadk/assets/{katex-DWEzQy1d.js → katex-B0oLa8CR.js} +1 -1
  75. package/dist-ksadk/assets/{linear-C-qHp7d2.js → linear-B3_la4oE.js} +1 -1
  76. package/dist-ksadk/assets/{mermaid-parser.core-Cl-K943T.js → mermaid-parser.core-B6PQSAV-.js} +2 -2
  77. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-D5DB5mYm.js → mindmap-definition-FBJOCRG2-By8qFxGO.js} +1 -1
  78. package/dist-ksadk/assets/packet-AYTQ26CC-BxA-7Hkq.js +1 -0
  79. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-BQVc9ia_.js → pegDiagram-XKGWAZYB-K1kvFBKC.js} +1 -1
  80. package/dist-ksadk/assets/pie-WAS4IAKB-3Tmx9EyU.js +1 -0
  81. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-B6UCAvtY.js → pieDiagram-E7YTZNPT-5XFtDn56.js} +1 -1
  82. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-mIr2d3eb.js → quadrantDiagram-AXDQQJYC-DQwy74C1.js} +1 -1
  83. package/dist-ksadk/assets/radar-RG4KPBEZ-D_bZK5Bu.js +1 -0
  84. package/dist-ksadk/assets/railroad-74A4TZTK-COy6RdCd.js +1 -0
  85. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CrdA8h6r.js +1 -0
  86. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BnDti7-r.js +1 -0
  87. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DmYdbc7f.js +1 -0
  88. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-Dt3FFDmK.js → railroadDiagram-O6MQD6OU-cozhldnA.js} +1 -1
  89. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-Cz_vQtgF.js → requirementDiagram-EFPCY7ZU-CElPZjXR.js} +1 -1
  90. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-wlO1TsH5.js → sankeyDiagram-P5KCCOFB-y_USXv4y.js} +1 -1
  91. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-CHRbElYq.js → sequenceDiagram-WJ2MYXX4-BJbQk7Za.js} +1 -1
  92. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DXX54iyO.js → sizeCapture-X5ZJPWSS-DAaf435S.js} +1 -1
  93. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-Dp_lw9II.js → stateDiagram-HBIQ2CUA-BiLbLu1I.js} +1 -1
  94. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5rxHhPTD.js +1 -0
  95. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-D8O5UlLG.js → swimlanes-XN3QIQJK-DxhmU8aj.js} +1 -1
  96. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-B3Po2rui.js +8 -0
  97. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-8mfKcxvG.js → timeline-definition-24CTP7MA-D18EWv7u.js} +1 -1
  98. package/dist-ksadk/assets/treeView-Q6P3EWNA-6G5wA0pE.js +1 -0
  99. package/dist-ksadk/assets/treemap-WGGIJYW6-BE9GnPbg.js +1 -0
  100. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-EnNl0DE7.js → vennDiagram-4TSXK5OY-rUBCuIGM.js} +1 -1
  101. package/dist-ksadk/assets/wardley-WFR3VGLG-BYh81kWC.js +1 -0
  102. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DBu5fbYr.js → wardleyDiagram-VM6X3IG4-CDZQ5sZK.js} +1 -1
  103. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-BSVXs4IY.js → xychartDiagram-S5SC5T6Z-CH_HdHYk.js} +1 -1
  104. package/dist-ksadk/index.html +2 -2
  105. package/dist-lib/App.d.ts.map +1 -1
  106. package/dist-lib/{ArtifactsPanel-D36BykpN.js → ArtifactsPanel-BX-TQaOJ.js} +18 -17
  107. package/dist-lib/AttachmentPreview-D8BjnDTd.js +694 -0
  108. package/dist-lib/{CodeBlock-BlEkUJ8C.js → CodeBlock-D3-ZCOb_.js} +44 -41
  109. package/dist-lib/ConnectedComposer-BgTxuTfq.js +743 -0
  110. package/dist-lib/ConnectedMessageList-BwRiSswQ.js +1504 -0
  111. package/dist-lib/{MathMessageMarkdown-CcnPvEgd.js → MathMessageMarkdown-DwgeFqKs.js} +32 -31
  112. package/dist-lib/MenuChip-BXivncgX.js +43 -0
  113. package/dist-lib/{MermaidBlock-BFNE1NN8.js → MermaidBlock-DBFTztfQ.js} +15 -13
  114. package/dist-lib/{NativeTerminalPanel-Dix1UX_z.js → NativeTerminalPanel-DyPvD5ij.js} +166 -172
  115. package/dist-lib/WorkspacePanelContainer-C-na8Ns1.js +1617 -0
  116. package/dist-lib/a2ui-TSXmGrT-.js +486 -0
  117. package/dist-lib/api/client.d.ts +48 -14
  118. package/dist-lib/api/client.d.ts.map +1 -1
  119. package/dist-lib/{capabilities-njdklP3r.js → capabilities-CXle1R-K.js} +60 -30
  120. package/dist-lib/capabilities.js +1 -1
  121. package/dist-lib/chat-composer.js +4 -0
  122. package/dist-lib/chat-timeline.js +3 -0
  123. package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
  124. package/dist-lib/components/chat/ChatComposer.d.ts +4 -3
  125. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  126. package/dist-lib/components/chat/ChatMessageList.d.ts +7 -4
  127. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  128. package/dist-lib/components/chat/ConnectedComposer.d.ts +4 -3
  129. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  130. package/dist-lib/components/chat/ConnectedMessageList.d.ts +6 -3
  131. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  132. package/dist-lib/components/chat/ContextUsageIndicator.d.ts +4 -8
  133. package/dist-lib/components/chat/ContextUsageIndicator.d.ts.map +1 -1
  134. package/dist-lib/components/chat/ExecutionModeMenu.d.ts.map +1 -1
  135. package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts +1 -1
  136. package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts.map +1 -1
  137. package/dist-lib/components/chat/InteractionSchemaForm.d.ts.map +1 -1
  138. package/dist-lib/components/chat/InteractionTray.d.ts +4 -4
  139. package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -1
  140. package/dist-lib/components/chat/MenuChip.d.ts +19 -0
  141. package/dist-lib/components/chat/MenuChip.d.ts.map +1 -0
  142. package/dist-lib/components/chat/ModelSettingsMenu.d.ts.map +1 -1
  143. package/dist-lib/components/chat/PermissionMenu.d.ts.map +1 -1
  144. package/dist-lib/components/chat/ProcessingBlocksView.d.ts +3 -3
  145. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
  146. package/dist-lib/components/chat/schema-fields.d.ts +4 -1
  147. package/dist-lib/components/chat/schema-fields.d.ts.map +1 -1
  148. package/dist-lib/components/chat/types.d.ts +4 -1
  149. package/dist-lib/components/chat/types.d.ts.map +1 -1
  150. package/dist-lib/components.js +38 -30
  151. package/dist-lib/conversation.js +1 -1
  152. package/dist-lib/core/api/facade.d.ts +70 -13
  153. package/dist-lib/core/api/facade.d.ts.map +1 -1
  154. package/dist-lib/core/api/types.d.ts +4 -1
  155. package/dist-lib/core/api/types.d.ts.map +1 -1
  156. package/dist-lib/core/conversation/hosted.d.ts.map +1 -1
  157. package/dist-lib/core/conversation/index.d.ts +1 -1
  158. package/dist-lib/core/conversation/index.d.ts.map +1 -1
  159. package/dist-lib/core/interaction/adapters/normalize.d.ts +2 -2
  160. package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -1
  161. package/dist-lib/core/interaction/adapters/responses.d.ts.map +1 -1
  162. package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -1
  163. package/dist-lib/core/interaction/client.d.ts.map +1 -1
  164. package/dist-lib/core/interaction/index.d.ts +8 -0
  165. package/dist-lib/core/interaction/index.d.ts.map +1 -1
  166. package/dist-lib/core/interaction/store.d.ts +0 -0
  167. package/dist-lib/core/interaction/store.d.ts.map +1 -1
  168. package/dist-lib/core/run/a2ui.d.ts +2 -0
  169. package/dist-lib/core/run/a2ui.d.ts.map +1 -1
  170. package/dist-lib/core/run/blocks.d.ts +1 -0
  171. package/dist-lib/core/run/blocks.d.ts.map +1 -1
  172. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  173. package/dist-lib/core/run/engine.d.ts.map +1 -1
  174. package/dist-lib/core/run/types.d.ts +3 -1
  175. package/dist-lib/core/run/types.d.ts.map +1 -1
  176. package/dist-lib/core/stream/kernel-events.d.ts +3 -0
  177. package/dist-lib/core/stream/kernel-events.d.ts.map +1 -1
  178. package/dist-lib/core/stream/types.d.ts +7 -0
  179. package/dist-lib/core/stream/types.d.ts.map +1 -1
  180. package/dist-lib/feedback-D256P415.js +239 -0
  181. package/dist-lib/hooks/useAgentChat.d.ts +95 -0
  182. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -0
  183. package/dist-lib/hooks/useBootstrap.d.ts +3 -2
  184. package/dist-lib/hooks/useBootstrap.d.ts.map +1 -1
  185. package/dist-lib/hooks/useRunAgent.d.ts +7 -0
  186. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  187. package/dist-lib/hooks/useSessionLifecycle.d.ts +2 -0
  188. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  189. package/dist-lib/hooks.js +167 -0
  190. package/dist-lib/permission-BWkTcIzC.js +24 -0
  191. package/dist-lib/{persisted-session-history-C0N8TrMb.js → persisted-session-history-Bb3ScKrL.js} +463 -266
  192. package/dist-lib/public/chat-composer.d.ts +15 -0
  193. package/dist-lib/public/chat-composer.d.ts.map +1 -0
  194. package/dist-lib/public/chat-timeline.d.ts +12 -0
  195. package/dist-lib/public/chat-timeline.d.ts.map +1 -0
  196. package/dist-lib/public/components.d.ts +23 -0
  197. package/dist-lib/public/components.d.ts.map +1 -1
  198. package/dist-lib/public/hooks.d.ts +3 -0
  199. package/dist-lib/public/hooks.d.ts.map +1 -0
  200. package/dist-lib/public/runtime.d.ts +2 -0
  201. package/dist-lib/public/runtime.d.ts.map +1 -1
  202. package/dist-lib/public/styles.d.ts +1 -1
  203. package/dist-lib/rolldown-runtime-Dy4uBu1J.js +11 -0
  204. package/dist-lib/{tool-display-C4tPXce0.js → runtime-items-q6tMjfGU.js} +0 -0
  205. package/dist-lib/runtime.js +277 -4987
  206. package/dist-lib/sandbox-BTRIKAO6.js +92 -0
  207. package/dist-lib/stores/model.d.ts +1 -0
  208. package/dist-lib/stores/model.d.ts.map +1 -1
  209. package/dist-lib/styles.css +1 -1
  210. package/dist-lib/tool-display-DTiRdghE.js +64 -0
  211. package/dist-lib/types/capabilities.d.ts +1 -0
  212. package/dist-lib/types/capabilities.d.ts.map +1 -1
  213. package/dist-lib/useSessionLifecycle-DuzkfGgL.js +4233 -0
  214. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  215. package/dist-lib/utils/chat-message-grouping.d.ts +4 -0
  216. package/dist-lib/utils/chat-message-grouping.d.ts.map +1 -0
  217. package/dist-lib/utils/chat-scroll.d.ts +14 -0
  218. package/dist-lib/utils/chat-scroll.d.ts.map +1 -0
  219. package/dist-lib/utils/context.d.ts +12 -7
  220. package/dist-lib/utils/context.d.ts.map +1 -1
  221. package/dist-lib/utils/messages.d.ts.map +1 -1
  222. package/dist-lib/utils/persisted-session-history.d.ts +2 -0
  223. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  224. package/dist-lib/utils/responses-stream.d.ts +2 -0
  225. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  226. package/dist-lib/utils/session-events.d.ts.map +1 -1
  227. package/dist-lib/utils/session.d.ts +1 -0
  228. package/dist-lib/utils/session.d.ts.map +1 -1
  229. package/dist-lib/utils/workspace.d.ts +1 -1
  230. package/package.json +13 -1
  231. package/dist-ksadk/assets/architecture-7GRP2DOG-Dk9nRQ6-.js +0 -1
  232. package/dist-ksadk/assets/channel-s354Yo6o.js +0 -1
  233. package/dist-ksadk/assets/chunk-2Q5K7J3B-CDpPpKR5.js +0 -1
  234. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-Dd0nucl9.js +0 -1
  235. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-Dd0nucl9.js +0 -1
  236. package/dist-ksadk/assets/cynefin-OW5HDTMX-BBlT4uMf.js +0 -1
  237. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-Dr5okd8V.js +0 -1
  238. package/dist-ksadk/assets/flowDiagram-A5DVABFB-VEO-cVcO.js +0 -1
  239. package/dist-ksadk/assets/gitGraph-4MIJSDKK-CKiKY9Cf.js +0 -1
  240. package/dist-ksadk/assets/index-B2k_urY8.js +0 -241
  241. package/dist-ksadk/assets/index-ILPt6IWF.css +0 -2
  242. package/dist-ksadk/assets/info-A6RAGUB7-ubA4Nm_p.js +0 -1
  243. package/dist-ksadk/assets/packet-AYTQ26CC-C7R3NUlK.js +0 -1
  244. package/dist-ksadk/assets/pie-WAS4IAKB-BIT6qjr3.js +0 -1
  245. package/dist-ksadk/assets/radar-RG4KPBEZ-l5noef9X.js +0 -1
  246. package/dist-ksadk/assets/railroad-74A4TZTK-Baea6ZvM.js +0 -1
  247. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-OKn8zZnU.js +0 -1
  248. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-DdKAKC4l.js +0 -1
  249. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-Bds8udlG.js +0 -1
  250. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5b-8o2iS.js +0 -1
  251. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-uf6WPRA4.js +0 -8
  252. package/dist-ksadk/assets/treeView-Q6P3EWNA-CK5CSrSO.js +0 -1
  253. package/dist-ksadk/assets/treemap-WGGIJYW6-Ch2BKgAM.js +0 -1
  254. package/dist-ksadk/assets/wardley-WFR3VGLG-YW3Q0ml_.js +0 -1
  255. package/dist-lib/WorkspacePanelContainer-Cr1BwR1P.js +0 -4397
  256. package/dist-lib/api/bootstrap.d.ts +0 -2
  257. package/dist-lib/api/bootstrap.d.ts.map +0 -1
  258. package/dist-lib/api/checkpoints.d.ts +0 -38
  259. package/dist-lib/api/checkpoints.d.ts.map +0 -1
  260. package/dist-lib/api/events.d.ts +0 -20
  261. package/dist-lib/api/events.d.ts.map +0 -1
  262. package/dist-lib/api/messages.d.ts +0 -73
  263. package/dist-lib/api/messages.d.ts.map +0 -1
  264. package/dist-lib/api/model.d.ts +0 -2
  265. package/dist-lib/api/model.d.ts.map +0 -1
  266. package/dist-lib/api/run.d.ts +0 -36
  267. package/dist-lib/api/run.d.ts.map +0 -1
  268. package/dist-lib/api/session.d.ts +0 -61
  269. package/dist-lib/api/session.d.ts.map +0 -1
  270. package/dist-lib/api/upload.d.ts +0 -12
  271. package/dist-lib/api/upload.d.ts.map +0 -1
  272. package/dist-lib/api/workspace.d.ts +0 -8
  273. package/dist-lib/api/workspace.d.ts.map +0 -1
@@ -1,4397 +0,0 @@
1
- import { r as e, t } from "./tool-display-C4tPXce0.js";
2
- import { ArrowDown as n, ArrowUp as r, Bot as i, Check as a, ChevronDown as o, ChevronLeft as s, ChevronRight as c, Code as l, Copy as u, Download as d, ExternalLink as f, Eye as p, FileCode2 as m, FileDiff as h, FileText as g, FolderOpen as _, Globe2 as v, Hand as y, Image as b, ListTodo as x, Loader2 as S, LoaderCircle as C, Maximize2 as w, MessageSquarePlus as T, MessageSquareText as E, Minimize2 as ee, MoreHorizontal as te, Package as ne, PanelLeft as re, PanelLeftClose as ie, Paperclip as ae, Pin as D, PinOff as O, Plus as oe, RefreshCcw as k, RefreshCw as se, Save as ce, Search as A, ShieldAlert as j, ShieldCheck as M, Sparkles as le, Square as ue, StopCircle as N, Target as de, TerminalSquare as P, ThumbsDown as fe, ThumbsUp as F, Trash2 as pe, Upload as me, WifiOff as he, Wrench as ge, X as _e, XCircle as ve, ZapOff as ye } from "lucide-react";
3
- import { clsx as be } from "clsx";
4
- import { twMerge as xe } from "tailwind-merge";
5
- import { create as I } from "zustand";
6
- import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
7
- import * as B from "react";
8
- import V, { Suspense as H, lazy as Se, useCallback as U, useEffect as W, useId as Ce, useLayoutEffect as we, useMemo as Te, useRef as G, useState as K } from "react";
9
- import * as q from "@radix-ui/react-dialog";
10
- import { cva as Ee } from "class-variance-authority";
11
- import De from "react-markdown";
12
- import Oe from "remark-gfm";
13
- import ke from "remark-breaks";
14
- import { A2UIProvider as Ae, A2UIRenderer as je, A2UI_SCHEMA_CONTEXT_DESCRIPTION as Me, basicCatalog as Ne, buildCatalogContextValue as Pe, useA2UI as Fe } from "@copilotkit/a2ui-renderer";
15
- import { EditorView as Ie, crosshairCursor as Le, drawSelection as Re, dropCursor as ze, highlightActiveLine as Be, highlightActiveLineGutter as Ve, keymap as He, lineNumbers as Ue, rectangularSelection as We } from "@codemirror/view";
16
- import { Compartment as Ge, EditorState as Ke } from "@codemirror/state";
17
- import { defaultKeymap as qe, history as Je, historyKeymap as Ye, indentWithTab as Xe } from "@codemirror/commands";
18
- import { LanguageDescription as Ze, bracketMatching as Qe, defaultHighlightStyle as $e, foldGutter as et, foldKeymap as tt, indentOnInput as nt, syntaxHighlighting as rt } from "@codemirror/language";
19
- import { oneDark as it } from "@codemirror/theme-one-dark";
20
- import { highlightSelectionMatches as at, searchKeymap as ot } from "@codemirror/search";
21
- import { autocompletion as st, closeBrackets as ct, closeBracketsKeymap as lt, completionKeymap as ut } from "@codemirror/autocomplete";
22
- import { languages as dt } from "@codemirror/language-data";
23
- //#region src/lib/utils.ts
24
- function J(...e) {
25
- return xe(be(e));
26
- }
27
- //#endregion
28
- //#region src/stores/model.ts
29
- function ft(e, t) {
30
- let n = /* @__PURE__ */ new Map();
31
- for (let t of e) t?.id && n.set(t.id, t);
32
- for (let e of t) e?.id && n.set(e.id, {
33
- ...n.get(e.id) || {},
34
- ...e
35
- });
36
- return Array.from(n.values()).sort((e, t) => e.id.localeCompare(t.id));
37
- }
38
- var pt = I()((e) => ({
39
- availableModels: [],
40
- selectedModel: "",
41
- modelSource: "",
42
- modelCatalogLoaded: !1,
43
- thinkingMode: "auto",
44
- upsertModels: (t) => e((e) => ({ availableModels: ft(e.availableModels, t) })),
45
- setSelectedModel: (t) => e({ selectedModel: t }),
46
- setModelSource: (t) => e({ modelSource: t }),
47
- setModelCatalogLoaded: (t) => e({ modelCatalogLoaded: t }),
48
- setThinkingMode: (t) => e({ thinkingMode: t })
49
- }));
50
- //#endregion
51
- //#region src/components/chat/ContextUsageIndicator.tsx
52
- function mt({ indicator: e }) {
53
- let t = Math.max(0, Math.min(100, e.percent ?? 0));
54
- return /* @__PURE__ */ z("div", {
55
- className: "group relative flex h-8 w-8 items-center justify-center",
56
- children: [/* @__PURE__ */ R("div", {
57
- className: J("flex h-4 w-4 items-center justify-center rounded-full", e.phase === "warning" || e.phase === "compressing" || t >= 85 ? "text-red-500" : "text-[#a5abb2]"),
58
- title: e.label,
59
- children: /* @__PURE__ */ R("div", {
60
- className: "flex h-3 w-3 items-center justify-center rounded-full",
61
- style: { background: `conic-gradient(currentColor ${t * 3.6}deg, #edf0f2 0deg)` },
62
- children: /* @__PURE__ */ R("span", { className: "h-2 w-2 rounded-full bg-background" })
63
- })
64
- }), /* @__PURE__ */ z("div", {
65
- 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)]",
66
- children: [
67
- /* @__PURE__ */ R("div", {
68
- className: "mb-1 whitespace-nowrap font-light text-text-secondary",
69
- children: "估算上下文"
70
- }),
71
- /* @__PURE__ */ z("div", {
72
- className: "whitespace-nowrap font-light",
73
- children: [t, "% 已使用"]
74
- }),
75
- /* @__PURE__ */ R("div", {
76
- className: "whitespace-nowrap font-light text-text-muted",
77
- children: e.usedTokens && e.contextWindowTokens ? `${ht(e.usedTokens)} / ${ht(e.contextWindowTokens)}` : e.label
78
- })
79
- ]
80
- })]
81
- });
82
- }
83
- function ht(e) {
84
- return e >= 1e6 ? `${(e / 1e6).toFixed(1)}m` : e >= 1e3 ? `${(e / 1e3).toFixed(0)}k` : String(e);
85
- }
86
- //#endregion
87
- //#region src/components/chat/ExecutionModeMenu.tsx
88
- var gt = [{
89
- value: "plan",
90
- label: "计划模式",
91
- description: "先分析并形成可执行计划",
92
- icon: x
93
- }, {
94
- value: "goal",
95
- label: "设定目标",
96
- description: "朝可验证的停止条件持续推进",
97
- icon: de
98
- }], _t = {
99
- plan: "计划模式",
100
- goal: "目标"
101
- };
102
- function vt({ attachmentsEnabled: e, mode: t, support: n, onSelectMode: r, onUpload: i }) {
103
- let [s, c] = K(!1), l = G(null), u = gt.filter((e) => n[e.value]);
104
- return W(() => {
105
- if (!s) return;
106
- let e = (e) => {
107
- l.current && !l.current.contains(e.target) && c(!1);
108
- }, t = (e) => {
109
- e.key === "Escape" && c(!1);
110
- };
111
- return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
112
- document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
113
- };
114
- }, [s]), !e && u.length === 0 ? null : /* @__PURE__ */ z("div", {
115
- ref: l,
116
- className: "relative flex min-w-0 items-center gap-1",
117
- children: [
118
- /* @__PURE__ */ R("button", {
119
- type: "button",
120
- onClick: () => c((e) => !e),
121
- className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25",
122
- "aria-expanded": s,
123
- "aria-haspopup": "menu",
124
- "aria-label": "添加附件或选择执行模式",
125
- title: "添加附件或选择执行模式",
126
- children: /* @__PURE__ */ R(oe, { className: "h-[19px] w-[19px]" })
127
- }),
128
- t ? /* @__PURE__ */ z("button", {
129
- type: "button",
130
- onClick: () => c((e) => !e),
131
- className: J("flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition", t === "goal" ? "bg-amber-50 text-amber-700 hover:bg-amber-100 dark:bg-amber-950/40 dark:text-amber-300" : "text-text-secondary hover:bg-muted hover:text-text-primary"),
132
- "aria-label": `当前执行模式:${_t[t]}`,
133
- children: [/* @__PURE__ */ R("span", {
134
- className: "truncate",
135
- children: _t[t]
136
- }), /* @__PURE__ */ R(o, { className: "h-3.5 w-3.5 shrink-0" })]
137
- }) : null,
138
- s ? /* @__PURE__ */ z("div", {
139
- role: "menu",
140
- "aria-label": "附件与执行模式",
141
- className: "absolute bottom-[calc(100%+0.65rem)] left-0 z-40 w-[min(19rem,calc(100vw-2rem))] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.16)]",
142
- children: [
143
- e ? /* @__PURE__ */ z("button", {
144
- type: "button",
145
- role: "menuitem",
146
- onClick: () => {
147
- i(), c(!1);
148
- },
149
- className: "flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2.5 text-left transition hover:bg-muted/70",
150
- children: [/* @__PURE__ */ R(me, { className: "h-4 w-4 shrink-0 text-text-muted" }), /* @__PURE__ */ z("span", { children: [/* @__PURE__ */ R("span", {
151
- className: "block text-[13px] font-medium text-text-primary",
152
- children: "上传附件"
153
- }), /* @__PURE__ */ R("span", {
154
- className: "block text-[11px] text-text-muted",
155
- children: "添加文件或图片到当前消息"
156
- })] })]
157
- }) : null,
158
- e && u.length > 0 ? /* @__PURE__ */ R("div", { className: "my-1 h-px bg-border/70" }) : null,
159
- u.map((e) => {
160
- let n = e.icon, i = t === e.value;
161
- return /* @__PURE__ */ z("button", {
162
- type: "button",
163
- role: "menuitemradio",
164
- "aria-checked": i,
165
- onClick: () => {
166
- r(e.value), c(!1);
167
- },
168
- className: J("flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2.5 text-left transition", i ? "bg-muted" : "hover:bg-muted/70"),
169
- children: [
170
- /* @__PURE__ */ R(n, { className: "h-4 w-4 shrink-0 text-text-muted" }),
171
- /* @__PURE__ */ z("span", {
172
- className: "min-w-0 flex-1",
173
- children: [/* @__PURE__ */ R("span", {
174
- className: "block text-[13px] font-medium text-text-primary",
175
- children: e.label
176
- }), /* @__PURE__ */ R("span", {
177
- className: "block text-[11px] text-text-muted",
178
- children: e.description
179
- })]
180
- }),
181
- i ? /* @__PURE__ */ R(a, { className: "h-4 w-4 shrink-0 text-text-primary" }) : null
182
- ]
183
- }, e.value);
184
- })
185
- ]
186
- }) : null
187
- ]
188
- });
189
- }
190
- //#endregion
191
- //#region src/components/chat/ModelSettingsMenu.tsx
192
- var yt = [
193
- {
194
- value: "auto",
195
- label: "自动",
196
- description: "使用模型或 Agent 的默认设置"
197
- },
198
- {
199
- value: "enabled",
200
- label: "开启",
201
- description: "请求模型输出推理过程"
202
- },
203
- {
204
- value: "disabled",
205
- label: "关闭",
206
- description: "不额外请求模型推理"
207
- }
208
- ], bt = {
209
- auto: "自动",
210
- enabled: "开启",
211
- disabled: "关闭"
212
- };
213
- function xt({ availableModels: e, selectedModel: t, thinkingEnabled: n, thinkingMode: r, onSelectModel: i, onSelectThinkingMode: s }) {
214
- let [l, u] = K(!1), [d, f] = K("model"), p = G(null), m = e.find((e) => e.id === t)?.display_name || t || "选择模型", h = n ? d : "model";
215
- return W(() => {
216
- if (!l) return;
217
- let e = (e) => {
218
- p.current && !p.current.contains(e.target) && u(!1);
219
- }, t = (e) => {
220
- e.key === "Escape" && u(!1);
221
- };
222
- return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
223
- document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
224
- };
225
- }, [l]), /* @__PURE__ */ z("div", {
226
- ref: p,
227
- className: "relative",
228
- children: [/* @__PURE__ */ z("button", {
229
- type: "button",
230
- onClick: () => u((e) => !e),
231
- className: "flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl bg-muted/80 px-3 text-[13px] text-text-primary transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25",
232
- "aria-expanded": l,
233
- "aria-haspopup": "menu",
234
- "aria-label": n ? `模型 ${m},推理 ${bt[r]}` : `模型 ${m}`,
235
- title: n ? "选择模型与推理设置" : "选择模型",
236
- children: [
237
- /* @__PURE__ */ R("span", {
238
- className: "min-w-0 truncate",
239
- children: m
240
- }),
241
- n ? /* @__PURE__ */ R("span", {
242
- className: "shrink-0 text-text-muted",
243
- children: bt[r]
244
- }) : null,
245
- /* @__PURE__ */ R(o, { className: J("h-3.5 w-3.5 shrink-0 text-text-muted transition-transform", l && "rotate-180") })
246
- ]
247
- }), l ? /* @__PURE__ */ z("div", {
248
- className: "absolute bottom-[calc(100%+0.65rem)] right-0 z-40 flex items-end gap-2 sm:flex-row-reverse",
249
- children: [/* @__PURE__ */ z("div", {
250
- role: "menu",
251
- "aria-label": h === "model" ? "选择模型" : "选择推理设置",
252
- className: "max-h-[min(54vh,22rem)] w-[min(18rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.16)]",
253
- children: [
254
- n ? /* @__PURE__ */ z("div", {
255
- className: "mb-1 grid grid-cols-2 gap-1 sm:hidden",
256
- children: [/* @__PURE__ */ R("button", {
257
- type: "button",
258
- onClick: () => f("model"),
259
- className: J("rounded-lg px-2 py-1.5 text-xs", h === "model" ? "bg-muted text-text-primary" : "text-text-muted"),
260
- children: "模型"
261
- }), /* @__PURE__ */ R("button", {
262
- type: "button",
263
- onClick: () => f("reasoning"),
264
- className: J("rounded-lg px-2 py-1.5 text-xs", h === "reasoning" ? "bg-muted text-text-primary" : "text-text-muted"),
265
- children: "推理"
266
- })]
267
- }) : null,
268
- /* @__PURE__ */ R("div", {
269
- className: "px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted",
270
- children: h === "model" ? "模型" : "推理设置"
271
- }),
272
- h === "model" ? e.map((e) => {
273
- let n = e.id === t;
274
- return /* @__PURE__ */ z("button", {
275
- type: "button",
276
- role: "menuitemradio",
277
- "aria-checked": n,
278
- onClick: () => {
279
- i(e.id), u(!1);
280
- },
281
- className: J("flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors", n ? "bg-muted text-text-primary" : "text-text-secondary hover:bg-muted/70 hover:text-text-primary"),
282
- children: [/* @__PURE__ */ R("span", {
283
- className: "min-w-0 flex-1 truncate",
284
- children: e.display_name || e.id
285
- }), n ? /* @__PURE__ */ R(a, {
286
- className: "h-4 w-4 shrink-0",
287
- "aria-hidden": "true"
288
- }) : null]
289
- }, e.id);
290
- }) : yt.map((e) => {
291
- let t = e.value === r;
292
- return /* @__PURE__ */ z("button", {
293
- type: "button",
294
- role: "menuitemradio",
295
- "aria-checked": t,
296
- onClick: () => {
297
- s(e.value), u(!1);
298
- },
299
- className: J("flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left transition-colors", t ? "bg-muted" : "hover:bg-muted/70"),
300
- children: [/* @__PURE__ */ z("span", {
301
- className: "min-w-0 flex-1",
302
- children: [/* @__PURE__ */ R("span", {
303
- className: "block text-[13px] font-medium text-text-primary",
304
- children: e.label
305
- }), /* @__PURE__ */ R("span", {
306
- className: "block text-[11px] leading-4 text-text-muted",
307
- children: e.description
308
- })]
309
- }), t ? /* @__PURE__ */ R(a, {
310
- className: "h-4 w-4 shrink-0 text-text-primary",
311
- "aria-hidden": "true"
312
- }) : null]
313
- }, e.value);
314
- })
315
- ]
316
- }), /* @__PURE__ */ z("div", {
317
- className: "hidden w-[16rem] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.13)] sm:block",
318
- children: [/* @__PURE__ */ z("button", {
319
- type: "button",
320
- onClick: () => f("model"),
321
- className: J("flex w-full items-center gap-2 rounded-xl px-2.5 py-2.5 text-left text-[13px] transition-colors", h === "model" ? "bg-muted text-text-primary" : "text-text-secondary hover:bg-muted/70"),
322
- children: [
323
- /* @__PURE__ */ R("span", {
324
- className: "font-medium",
325
- children: "模型"
326
- }),
327
- /* @__PURE__ */ R("span", {
328
- className: "min-w-0 flex-1 truncate text-right text-text-muted",
329
- children: m
330
- }),
331
- /* @__PURE__ */ R(c, { className: "h-4 w-4 shrink-0 text-text-muted" })
332
- ]
333
- }), n ? /* @__PURE__ */ z("button", {
334
- type: "button",
335
- onClick: () => f("reasoning"),
336
- className: J("flex w-full items-center gap-2 rounded-xl px-2.5 py-2.5 text-left text-[13px] transition-colors", h === "reasoning" ? "bg-muted text-text-primary" : "text-text-secondary hover:bg-muted/70"),
337
- children: [
338
- /* @__PURE__ */ R("span", {
339
- className: "font-medium",
340
- children: "推理"
341
- }),
342
- /* @__PURE__ */ R("span", {
343
- className: "min-w-0 flex-1 truncate text-right text-text-muted",
344
- children: bt[r]
345
- }),
346
- /* @__PURE__ */ R(c, { className: "h-4 w-4 shrink-0 text-text-muted" })
347
- ]
348
- }) : null]
349
- })]
350
- }) : null]
351
- });
352
- }
353
- //#endregion
354
- //#region src/stores/permission.ts
355
- var St = "ksadk.web.permission-mode";
356
- function Ct() {
357
- try {
358
- let e = globalThis.localStorage?.getItem(St);
359
- return e === "ask" || e === "full" || e === "risk" ? e : "risk";
360
- } catch {
361
- return "risk";
362
- }
363
- }
364
- function wt(e) {
365
- try {
366
- globalThis.localStorage?.setItem(St, e);
367
- } catch {}
368
- }
369
- var Tt = I()((e) => ({
370
- permissionMode: Ct(),
371
- setPermissionMode: (t) => {
372
- wt(t), e({ permissionMode: t });
373
- }
374
- })), Et = [
375
- {
376
- value: "ask",
377
- label: "请求批准",
378
- description: "有副作用的操作执行前先确认",
379
- icon: y
380
- },
381
- {
382
- value: "risk",
383
- label: "风险操作需确认",
384
- description: "只对命令、写入和外部副作用确认",
385
- icon: M
386
- },
387
- {
388
- value: "full",
389
- label: "完全访问",
390
- description: "本次会话不再为默认规则弹出确认",
391
- icon: j
392
- }
393
- ], Dt = {
394
- ask: "请求批准",
395
- risk: "风险确认",
396
- full: "完全访问"
397
- };
398
- function Ot({ approvalPolicy: e }) {
399
- let [t, n] = K(!1), r = G(null), i = Tt((e) => e.permissionMode), s = Tt((e) => e.setPermissionMode), c = i === "ask" ? y : i === "full" ? j : M, l = Te(() => Et.filter((t) => !e || e.Modes.includes(t.value)), [e]);
400
- return W(() => {
401
- l.some((e) => e.value === i) || s(e?.DefaultMode || l[0]?.value || "risk");
402
- }, [
403
- e?.DefaultMode,
404
- i,
405
- s,
406
- l
407
- ]), W(() => {
408
- if (!t) return;
409
- let e = (e) => {
410
- r.current && !r.current.contains(e.target) && n(!1);
411
- }, i = (e) => {
412
- e.key === "Escape" && n(!1);
413
- };
414
- return document.addEventListener("mousedown", e), document.addEventListener("keydown", i), () => {
415
- document.removeEventListener("mousedown", e), document.removeEventListener("keydown", i);
416
- };
417
- }, [t]), /* @__PURE__ */ z("div", {
418
- ref: r,
419
- className: "relative",
420
- children: [/* @__PURE__ */ z("button", {
421
- type: "button",
422
- onClick: () => n((e) => !e),
423
- className: J("flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25", i === "full" ? "text-amber-600 dark:text-amber-400" : "text-text-secondary hover:text-text-primary"),
424
- "aria-expanded": t,
425
- "aria-haspopup": "menu",
426
- title: "设置本次会话的工具审批规则",
427
- children: [
428
- /* @__PURE__ */ R(c, { className: "h-3.5 w-3.5" }),
429
- /* @__PURE__ */ R("span", { children: Dt[i] }),
430
- /* @__PURE__ */ R(o, { className: J("h-3.5 w-3.5 transition-transform", t && "rotate-180") })
431
- ]
432
- }), t ? /* @__PURE__ */ z("div", {
433
- role: "menu",
434
- "aria-label": "工具权限",
435
- 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)]",
436
- children: [/* @__PURE__ */ R("div", {
437
- className: "px-2.5 pb-1.5 pt-1 text-[11px] text-text-muted",
438
- children: "本次会话的默认审批规则"
439
- }), l.map((e) => {
440
- let t = e.icon, r = e.value === i;
441
- return /* @__PURE__ */ z("button", {
442
- type: "button",
443
- role: "menuitemradio",
444
- "aria-checked": r,
445
- onClick: () => {
446
- s(e.value), n(!1);
447
- },
448
- className: J("flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-left transition-colors", r ? "bg-primary/[0.08]" : "hover:bg-muted/75"),
449
- children: [
450
- /* @__PURE__ */ R(t, { className: J("h-[17px] w-[17px] shrink-0", r ? "text-primary" : "text-text-muted") }),
451
- /* @__PURE__ */ z("span", {
452
- className: "min-w-0 flex-1",
453
- children: [/* @__PURE__ */ R("span", {
454
- className: J("block text-[13px] font-medium leading-5", r ? "text-text-primary" : "text-text-secondary"),
455
- children: e.label
456
- }), /* @__PURE__ */ R("span", {
457
- className: "block text-[11px] leading-4 text-text-muted",
458
- children: e.description
459
- })]
460
- }),
461
- r ? /* @__PURE__ */ R(a, {
462
- className: "h-4 w-4 shrink-0 text-primary",
463
- "aria-hidden": "true"
464
- }) : null
465
- ]
466
- }, e.value);
467
- })]
468
- }) : null]
469
- });
470
- }
471
- //#endregion
472
- //#region src/components/chat/ChatComposer.tsx
473
- function kt({ attachments: e, composerContextIndicator: t, composerMaxHeight: n, fileInputRef: i, input: a, isMobile: o, isStreaming: s, attachmentsEnabled: c = !0, approvalEnabled: l = !1, approvalPolicy: u, thinkingEnabled: d = !1, executionMode: f, executionModeSupport: p, queuedDrafts: m, onAppendAttachments: h, onInputChange: g, onSelectExecutionMode: _, onPaste: v, onRemoveAttachment: y, onStopGeneration: b, onCancelRemote: x, onSubmit: S, textareaRef: C }) {
474
- let w = f === "goal" ? "描述需要持续完成的目标…" : f === "plan" ? "描述需要先规划的任务…" : o ? "发送消息..." : "发送消息…", T = x ? "保留恢复点并结束本次执行" : "停止生成", E = f === "goal" ? !!a.trim() : !!(a.trim() || e.length > 0), ee = pt((e) => e.availableModels), te = pt((e) => e.selectedModel), ne = pt((e) => e.thinkingMode), re = pt((e) => e.setSelectedModel), ie = pt((e) => e.setThinkingMode), D = (e) => e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
475
- return /* @__PURE__ */ R("div", {
476
- className: "relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3",
477
- children: /* @__PURE__ */ z("div", {
478
- className: "mx-auto w-full max-w-[64rem]",
479
- children: [m.length > 0 ? /* @__PURE__ */ z("div", {
480
- 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",
481
- children: [/* @__PURE__ */ z("div", {
482
- className: "mb-1.5 flex items-center justify-between gap-2",
483
- children: [/* @__PURE__ */ z("span", {
484
- className: "font-semibold",
485
- children: ["发送队列 · ", m.length]
486
- }), /* @__PURE__ */ R("span", {
487
- className: "text-amber-700/75 dark:text-amber-200/75",
488
- children: "当前回复完成后依次发送"
489
- })]
490
- }), /* @__PURE__ */ z("div", {
491
- className: "flex flex-col gap-1",
492
- children: [m.slice(0, 3).map((e, t) => {
493
- let n = e.text.trim() || (e.attachments.length > 0 ? "仅附件消息" : "空消息");
494
- return /* @__PURE__ */ z("div", {
495
- className: "flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5",
496
- children: [
497
- /* @__PURE__ */ R("span", {
498
- 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",
499
- children: t + 1
500
- }),
501
- /* @__PURE__ */ R("span", {
502
- className: "min-w-0 flex-1 truncate text-text-secondary",
503
- children: n
504
- }),
505
- e.attachments.length > 0 ? /* @__PURE__ */ z("span", {
506
- 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",
507
- children: [e.attachments.length, " 附件"]
508
- }) : null
509
- ]
510
- }, `${t}-${n}-${e.attachments.length}`);
511
- }), m.length > 3 ? /* @__PURE__ */ z("div", {
512
- className: "px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80",
513
- children: [
514
- "还有 ",
515
- m.length - 3,
516
- " 条等待发送"
517
- ]
518
- }) : null]
519
- })]
520
- }) : null, /* @__PURE__ */ R("div", {
521
- className: "relative rounded-[28px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]",
522
- children: /* @__PURE__ */ R("div", {
523
- className: "flex items-center gap-3",
524
- children: /* @__PURE__ */ z("form", {
525
- onSubmit: (t) => {
526
- if (t.preventDefault(), s) {
527
- x ? x() : b();
528
- return;
529
- }
530
- let n = a.trim();
531
- E && S(n, e);
532
- },
533
- onDragOver: (e) => {
534
- e.preventDefault(), e.stopPropagation();
535
- },
536
- onDrop: (e) => {
537
- e.preventDefault(), e.stopPropagation(), c && e.dataTransfer.files && e.dataTransfer.files.length > 0 && h(Array.from(e.dataTransfer.files));
538
- },
539
- className: "relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[28px] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5",
540
- children: [
541
- e.length > 0 ? /* @__PURE__ */ R("div", {
542
- className: "mb-1.5 flex flex-wrap gap-2",
543
- children: e.map((e, t) => /* @__PURE__ */ z("div", {
544
- className: J("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]"),
545
- children: [
546
- /* @__PURE__ */ R("span", {
547
- className: "flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted",
548
- children: /* @__PURE__ */ R(ae, { className: "h-3.5 w-3.5" })
549
- }),
550
- /* @__PURE__ */ z("span", {
551
- className: "min-w-0 flex-1",
552
- children: [/* @__PURE__ */ R("span", {
553
- className: "block truncate font-medium text-text-primary",
554
- children: e.name
555
- }), /* @__PURE__ */ R("span", {
556
- className: "block text-[10px] text-text-muted",
557
- children: D(e.size)
558
- })]
559
- }),
560
- /* @__PURE__ */ R("button", {
561
- type: "button",
562
- onClick: () => y(t),
563
- 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",
564
- "aria-label": `移除附件 ${e.name}`,
565
- children: /* @__PURE__ */ R("span", {
566
- className: "text-[11px] leading-none",
567
- children: "×"
568
- })
569
- })
570
- ]
571
- }, `${e.name}-${e.size}-${t}`))
572
- }) : null,
573
- /* @__PURE__ */ R("textarea", {
574
- ref: C,
575
- rows: 1,
576
- value: a,
577
- onChange: g,
578
- onKeyDown: (e) => {
579
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), e.currentTarget.form?.requestSubmit());
580
- },
581
- onPaste: v,
582
- placeholder: w,
583
- className: J("custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60", o ? "text-[16px]" : "text-[14px]"),
584
- style: {
585
- maxHeight: `${n}px`,
586
- overflowY: "auto"
587
- }
588
- }),
589
- /* @__PURE__ */ z("div", {
590
- className: "mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5",
591
- children: [/* @__PURE__ */ z("div", {
592
- className: "flex min-w-0 items-center gap-1.5",
593
- children: [
594
- /* @__PURE__ */ R("input", {
595
- ref: i,
596
- type: "file",
597
- multiple: !0,
598
- className: "hidden",
599
- onChange: (e) => {
600
- e.target.files && e.target.files.length > 0 && (h(Array.from(e.target.files)), e.target.value = "");
601
- }
602
- }),
603
- /* @__PURE__ */ R(vt, {
604
- attachmentsEnabled: c,
605
- mode: f,
606
- support: p,
607
- onSelectMode: _,
608
- onUpload: () => i.current?.click()
609
- }),
610
- l ? /* @__PURE__ */ R(Ot, { approvalPolicy: u }) : null
611
- ]
612
- }), /* @__PURE__ */ z("div", {
613
- className: "flex min-w-0 items-center gap-1.5",
614
- children: [
615
- t ? /* @__PURE__ */ R(mt, { indicator: t }) : null,
616
- ee.length > 0 ? /* @__PURE__ */ R(xt, {
617
- availableModels: ee,
618
- selectedModel: te,
619
- thinkingEnabled: d,
620
- thinkingMode: ne,
621
- onSelectModel: re,
622
- onSelectThinkingMode: ie
623
- }) : null,
624
- /* @__PURE__ */ R("button", {
625
- type: "submit",
626
- disabled: !s && !E,
627
- className: J("flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30", s || E ? "bg-[#1f1f1f] text-white hover:opacity-80" : "bg-muted text-text-muted/45"),
628
- title: s ? T : "发送消息",
629
- children: s ? /* @__PURE__ */ R(ue, { className: "h-3.5 w-3.5 fill-current" }) : /* @__PURE__ */ R(r, { className: "h-[18px] w-[18px]" })
630
- })
631
- ]
632
- })]
633
- })
634
- ]
635
- })
636
- })
637
- })]
638
- })
639
- });
640
- }
641
- //#endregion
642
- //#region src/components/ui/sheet.tsx
643
- var At = q.Root, jt = q.Portal, Mt = B.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ R(q.Overlay, {
644
- className: J("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),
645
- ...t,
646
- ref: n
647
- }));
648
- Mt.displayName = q.Overlay.displayName;
649
- var Nt = Ee("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", {
650
- variants: { side: {
651
- top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
652
- bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
653
- left: "inset-y-0 left-0 h-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
654
- right: "inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right"
655
- } },
656
- defaultVariants: { side: "right" }
657
- }), Pt = B.forwardRef(({ side: e = "right", className: t, children: n, showOverlay: r = !0, showCloseButton: i = !0, ...a }, o) => /* @__PURE__ */ z(jt, { children: [r ? /* @__PURE__ */ R(Mt, {}) : null, /* @__PURE__ */ z(q.Content, {
658
- ref: o,
659
- className: J(Nt({ side: e }), t),
660
- ...a,
661
- children: [n, i ? /* @__PURE__ */ z(q.Close, {
662
- 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",
663
- children: [/* @__PURE__ */ R(_e, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", {
664
- className: "sr-only",
665
- children: "Close"
666
- })]
667
- }) : null]
668
- })] }));
669
- Pt.displayName = q.Content.displayName;
670
- var Ft = ({ className: e, ...t }) => /* @__PURE__ */ R("div", {
671
- className: J("flex flex-col space-y-2 text-center sm:text-left", e),
672
- ...t
673
- });
674
- Ft.displayName = "SheetHeader";
675
- var It = ({ className: e, ...t }) => /* @__PURE__ */ R("div", {
676
- className: J("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", e),
677
- ...t
678
- });
679
- It.displayName = "SheetFooter";
680
- var Lt = B.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ R(q.Title, {
681
- ref: n,
682
- className: J("text-lg font-semibold text-foreground", e),
683
- ...t
684
- }));
685
- Lt.displayName = q.Title.displayName;
686
- var Rt = B.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ R(q.Description, {
687
- ref: n,
688
- className: J("text-sm text-muted-foreground", e),
689
- ...t
690
- }));
691
- Rt.displayName = q.Description.displayName;
692
- //#endregion
693
- //#region src/components/chat/ChatHeader.tsx
694
- var zt = Se(() => import("./NativeTerminalPanel-Dix1UX_z.js").then((e) => e.n).then((e) => ({ default: e.NativeTerminalPanel })));
695
- function Bt({ availableModels: e, selectedModel: t, onSelectModel: n, selectedModelLabel: r, modelCatalogLoaded: i, modelSource: a, thinkingEnabled: o, thinkingMode: s, onSelectThinkingMode: c, compact: l = !1 }) {
696
- let u = J("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__ */ R("select", {
697
- value: t,
698
- onChange: (e) => n(e.target.value),
699
- className: u,
700
- children: e.map((e) => /* @__PURE__ */ R("option", {
701
- value: e.id,
702
- children: e.display_name || e.id
703
- }, e.id))
704
- }) : r ? /* @__PURE__ */ R("span", {
705
- className: J(u, "inline-flex max-w-full items-center", l ? "justify-start" : ""),
706
- title: a || r,
707
- children: /* @__PURE__ */ R("span", {
708
- className: "truncate",
709
- children: r
710
- })
711
- }) : /* @__PURE__ */ R("span", {
712
- className: "text-sm text-slate-400",
713
- children: i ? "未配置模型" : "Loading models..."
714
- }), f = o ? /* @__PURE__ */ z("select", {
715
- value: s,
716
- onChange: (e) => c(e.target.value),
717
- className: J(u, l ? "" : "max-w-[9rem]"),
718
- title: "控制模型 thinking/reasoning 参数",
719
- children: [
720
- /* @__PURE__ */ R("option", {
721
- value: "auto",
722
- children: "思考自动"
723
- }),
724
- /* @__PURE__ */ R("option", {
725
- value: "enabled",
726
- children: "开启思考"
727
- }),
728
- /* @__PURE__ */ R("option", {
729
- value: "disabled",
730
- children: "关闭思考"
731
- })
732
- ]
733
- }) : null;
734
- return /* @__PURE__ */ z("div", {
735
- className: J("flex min-w-0 gap-2", l ? "w-full flex-col" : "items-center"),
736
- children: [d, f]
737
- });
738
- }
739
- function Vt({ agentName: e, currentSessionId: t, isMobile: n, sidebarOpen: r, mobileSidebarOpen: i, onToggleSidebar: a, availableModels: o, selectedModel: s, onSelectModel: c, selectedModelLabel: l, modelCatalogLoaded: u, modelSource: d, thinkingEnabled: p, thinkingMode: m, onSelectThinkingMode: h, mobileActionsOpen: g, onMobileActionsOpenChange: v, workspaceEnabled: y, onOpenWorkspace: b, nativeManagementLink: x, nativeTerminal: S, nativeLauncherMode: C = !1 }) {
740
- let [w, T] = K(!1), E = !!S?.Enabled, ee = R(n ? i ? ie : re : r ? ie : re, { className: "h-5 w-5" });
741
- return /* @__PURE__ */ z(L, { children: [
742
- /* @__PURE__ */ z("header", {
743
- className: J("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"),
744
- children: [/* @__PURE__ */ z("div", {
745
- className: "flex min-w-0 items-center gap-2",
746
- children: [C ? null : /* @__PURE__ */ R("button", {
747
- type: "button",
748
- onClick: a,
749
- className: "rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800",
750
- "aria-label": n ? "打开历史记录" : "切换侧边栏",
751
- children: ee
752
- }), /* @__PURE__ */ z("div", {
753
- className: "min-w-0",
754
- children: [/* @__PURE__ */ R("div", {
755
- className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base",
756
- children: e
757
- }), /* @__PURE__ */ R("div", {
758
- className: "text-[11px] text-slate-400 dark:text-slate-500",
759
- children: C ? "原生运行时入口" : "智能体"
760
- })]
761
- })]
762
- }), n ? /* @__PURE__ */ R("button", {
763
- type: "button",
764
- onClick: () => v(!0),
765
- className: "rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800",
766
- "aria-label": "打开会话操作",
767
- children: /* @__PURE__ */ R(te, { className: "h-5 w-5" })
768
- }) : /* @__PURE__ */ z("div", {
769
- className: "flex min-w-0 items-center gap-2",
770
- children: [
771
- x ? /* @__PURE__ */ z("a", {
772
- href: x.href,
773
- target: "_blank",
774
- rel: "noreferrer",
775
- title: x.title,
776
- 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",
777
- children: [/* @__PURE__ */ R(f, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: x.label })]
778
- }) : null,
779
- y ? /* @__PURE__ */ z("button", {
780
- type: "button",
781
- onClick: b,
782
- 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",
783
- children: [/* @__PURE__ */ R(_, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: "Workspace" })]
784
- }) : null,
785
- E ? /* @__PURE__ */ z("button", {
786
- type: "button",
787
- onClick: () => T(!0),
788
- 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",
789
- children: [/* @__PURE__ */ R(P, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: "TUI" })]
790
- }) : null,
791
- !C && n ? /* @__PURE__ */ R(Bt, {
792
- availableModels: o,
793
- selectedModel: s,
794
- onSelectModel: c,
795
- selectedModelLabel: l,
796
- modelCatalogLoaded: u,
797
- modelSource: d,
798
- thinkingEnabled: p,
799
- thinkingMode: m,
800
- onSelectThinkingMode: h,
801
- compact: !0
802
- }) : null,
803
- !C && t ? /* @__PURE__ */ z("span", {
804
- className: "rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800",
805
- children: ["ID: ", t.slice(0, 8)]
806
- }) : null
807
- ]
808
- })]
809
- }),
810
- n ? /* @__PURE__ */ R(At, {
811
- open: g,
812
- onOpenChange: v,
813
- children: /* @__PURE__ */ z(Pt, {
814
- side: "bottom",
815
- 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",
816
- children: [/* @__PURE__ */ z(Ft, {
817
- className: "text-left",
818
- children: [/* @__PURE__ */ R(Lt, { children: "会话设置" }), /* @__PURE__ */ R(Rt, {
819
- className: "sr-only",
820
- children: "调整当前会话的模型和 Workspace 操作。"
821
- })]
822
- }), /* @__PURE__ */ z("div", {
823
- className: "mt-6 flex flex-col gap-4",
824
- children: [
825
- y ? /* @__PURE__ */ z("button", {
826
- type: "button",
827
- onClick: () => {
828
- v(!1), b();
829
- },
830
- 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",
831
- children: [/* @__PURE__ */ R(_, { className: "h-4 w-4" }), "工作区文件"]
832
- }) : null,
833
- E ? /* @__PURE__ */ z("button", {
834
- type: "button",
835
- onClick: () => {
836
- v(!1), T(!0);
837
- },
838
- 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",
839
- children: [/* @__PURE__ */ R(P, { className: "h-4 w-4" }), "原生 TUI"]
840
- }) : null,
841
- x ? /* @__PURE__ */ z("a", {
842
- href: x.href,
843
- target: "_blank",
844
- rel: "noreferrer",
845
- title: x.title,
846
- onClick: () => v(!1),
847
- 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",
848
- children: [/* @__PURE__ */ R(f, { className: "h-4 w-4" }), x.label]
849
- }) : null,
850
- C ? /* @__PURE__ */ R("div", {
851
- 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",
852
- children: "当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。"
853
- }) : /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
854
- className: "space-y-2",
855
- children: [/* @__PURE__ */ R("div", {
856
- className: "text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500",
857
- children: "模型"
858
- }), /* @__PURE__ */ R(Bt, {
859
- availableModels: o,
860
- selectedModel: s,
861
- onSelectModel: c,
862
- selectedModelLabel: l,
863
- modelCatalogLoaded: u,
864
- modelSource: d,
865
- thinkingEnabled: p,
866
- thinkingMode: m,
867
- onSelectThinkingMode: h,
868
- compact: !0
869
- })]
870
- }), /* @__PURE__ */ z("div", {
871
- className: "space-y-2",
872
- children: [/* @__PURE__ */ R("div", {
873
- className: "text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500",
874
- children: "当前会话"
875
- }), /* @__PURE__ */ R("div", {
876
- 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",
877
- children: t ? /* @__PURE__ */ R("span", {
878
- className: "break-all font-mono",
879
- children: t
880
- }) : "新对话尚未创建会话 ID"
881
- })]
882
- })] })
883
- ]
884
- })]
885
- })
886
- }) : null,
887
- S && w ? /* @__PURE__ */ R(H, {
888
- fallback: null,
889
- children: /* @__PURE__ */ R(zt, {
890
- capability: S,
891
- open: w,
892
- sessionId: t,
893
- onClose: () => T(!1)
894
- })
895
- }) : null
896
- ] });
897
- }
898
- //#endregion
899
- //#region src/utils/markdown.js
900
- function Ht(e) {
901
- 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`);
902
- }
903
- function Ut(e) {
904
- return /^\s*\|(?:\s*[:\-]+\s*\|){2,}\s*$/.test(e);
905
- }
906
- function Y(e) {
907
- let t = e.trim();
908
- return t.startsWith("|") ? t.split("|").length >= 4 : !1;
909
- }
910
- function Wt(e) {
911
- let t = e.trim();
912
- return t.startsWith("|") ? t.replace(/^\|/, "").replace(/\|\s*$/, "").split("|").map((e) => e.trim()) : [];
913
- }
914
- function Gt(e, t = "") {
915
- return `${t}| ${e.join(" | ")} |`;
916
- }
917
- function Kt(e) {
918
- let t = e.split("\n"), n = [], r = 0;
919
- for (; r < t.length;) {
920
- let e = t[r];
921
- if (Y(e) && r + 1 < t.length && Ut(t[r + 1])) {
922
- let i = e.match(/^(\s*)/)?.[1] || "", a = Wt(e), o = Wt(t[r + 1]), s = [], c = r + 2, l = Math.max(a.length, o.length);
923
- for (; c < t.length && Y(t[c]);) {
924
- let e = Wt(t[c]);
925
- l = Math.max(l, e.length), s.push(e), c += 1;
926
- }
927
- let u = (e) => {
928
- let t = [...e];
929
- for (; t.length < l;) t.push("");
930
- return t;
931
- };
932
- n.push(Gt(u(a), i)), n.push(Gt(((e) => {
933
- let t = [...e];
934
- for (; t.length < l;) t.push("---");
935
- return t;
936
- })(o), i));
937
- for (let e of s) n.push(Gt(u(e), i));
938
- r = c;
939
- } else n.push(e), r += 1;
940
- }
941
- return n.join("\n");
942
- }
943
- function qt(e) {
944
- return Ut(e) || /\|\|/.test(e) || /\|(?:\s*[:\-]+\s*\|){2,}/.test(e) && /\|(?:[^|\n]*\|){2,}/.test(e);
945
- }
946
- function Jt(e) {
947
- return qt(e) ? e.replace(/\|\s*\|/g, "|\n|").split("\n").map((e) => e.trimEnd()).filter((e) => e.trim().length > 0) : [e];
948
- }
949
- function Yt(e) {
950
- return Y(e) ? e.replace(/\|\s*(?:\*{1,2}|_{1,2})\s*$/u, "|") : e;
951
- }
952
- function Xt(e) {
953
- let t = e.trim();
954
- return Y(t) ? t.split("|").slice(1, -1).length : 0;
955
- }
956
- function Zt(e) {
957
- let t = e.match(/^(\s*)/)?.[1] || "", n = Xt(e);
958
- return n < 2 ? "" : `${t}| ${Array.from({ length: n }, () => "---").join(" | ")} |`;
959
- }
960
- function Qt(e) {
961
- let t = [];
962
- for (let n of e.split("\n")) {
963
- if (/^\s*\|\s*$/.test(n)) continue;
964
- let e = n.match(/^(\s*)\|\s*([^|]+)$/);
965
- if (e) {
966
- t.push(`${e[1]}${e[2].trim()}`);
967
- continue;
968
- }
969
- t.push(...Jt(n).map(Yt));
970
- }
971
- let n = [];
972
- for (let e = 0; e < t.length; e += 1) {
973
- let r = t[e];
974
- r.trim().length === 0 && Y(n[n.length - 1] || "") && Ut(t[e + 1] || "") || n.push(r);
975
- }
976
- let r = [];
977
- for (let e = 0; e < n.length; e += 1) {
978
- let t = n[e], i = n[e + 1] || "";
979
- if (r.push(t), Y(t) && Y(i) && !Ut(i) && Xt(t) === Xt(i)) {
980
- let i = Y(n[e - 1] || ""), a = t.match(/^(\s*)/)?.[1] || "";
981
- if (!i && a.length === 0) {
982
- let e = Zt(t);
983
- e && r.push(e);
984
- }
985
- }
986
- }
987
- let i = [];
988
- for (let e = 0; e < r.length; e += 1) {
989
- let t = r[e], n = r[e + 1] || "", a = i[i.length - 1] || "", o = Y(t) && (a.trim().length === 0 || !Y(a)), s = Y(t) && (n.trim().length === 0 || !Y(n)), c = t.match(/^(\s*)/)?.[1] || "";
990
- o && c.length === 0 && a.trim().length > 0 && i.push(""), i.push(t), s && c.length === 0 && n.trim().length > 0 && i.push("");
991
- }
992
- return i.join("\n");
993
- }
994
- function $t(e) {
995
- 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);
996
- if (!n) return t;
997
- let [, r, i, , a = ""] = n, o = r.replace(/[^\t ]/gu, " "), s = i.replace(/#/gu, "#");
998
- return a ? `${o}${s} ${a}` : `${o}${s}`;
999
- }
1000
- function en(e) {
1001
- let t = e;
1002
- return t = t.split("\n").map((e) => $t(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 = Qt(t), t = t.replace(/\n{3,}/g, "\n\n"), t.trim();
1003
- }
1004
- function tn(e) {
1005
- return e.map((t, n) => {
1006
- if (n % 2 == 1) return t;
1007
- let r = en(t), i = n > 0, a = n < e.length - 1;
1008
- 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;
1009
- });
1010
- }
1011
- function nn(e) {
1012
- if (!e) return e;
1013
- let t = String(e).replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
1014
- return t = Ht(t), t = Kt(t), (t.match(/```/g) || []).length % 2 == 1 && (t = `${t}\n\`\`\``), tn(t.split("```")).join("```").trim();
1015
- }
1016
- //#endregion
1017
- //#region src/components/MessageMarkdown.tsx
1018
- var rn = V.lazy(() => import("./CodeBlock-BlEkUJ8C.js").then((e) => ({ default: e.CodeBlock }))), an = V.lazy(() => import("./MermaidBlock-BFNE1NN8.js").then((e) => ({ default: e.MermaidBlock }))), on = V.lazy(() => import("./MathMessageMarkdown-CcnPvEgd.js").then((e) => ({ default: e.MathMessageMarkdown })));
1019
- function sn(e) {
1020
- return /\$[^$]+\$|\$\$[^$]+\$\$/.test(e);
1021
- }
1022
- var cn = {
1023
- h1({ children: e }) {
1024
- return /* @__PURE__ */ R("h1", {
1025
- className: "mb-3.5 mt-5 text-[17px] font-semibold text-foreground",
1026
- children: e
1027
- });
1028
- },
1029
- h2({ children: e }) {
1030
- return /* @__PURE__ */ R("h2", {
1031
- className: "mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground",
1032
- children: e
1033
- });
1034
- },
1035
- h3({ children: e }) {
1036
- return /* @__PURE__ */ R("h3", {
1037
- className: "mb-2 mt-3.5 text-[14px] font-semibold text-foreground",
1038
- children: e
1039
- });
1040
- },
1041
- p({ children: e }) {
1042
- return /* @__PURE__ */ R("p", {
1043
- className: "mb-2.5 min-w-0 break-words leading-[1.65] text-foreground",
1044
- children: e
1045
- });
1046
- },
1047
- ul({ children: e }) {
1048
- return /* @__PURE__ */ R("ul", {
1049
- className: "mb-3 list-disc space-y-1.5 pl-5 text-foreground",
1050
- children: e
1051
- });
1052
- },
1053
- ol({ children: e }) {
1054
- return /* @__PURE__ */ R("ol", {
1055
- className: "mb-3 list-decimal space-y-1.5 pl-8 text-foreground",
1056
- children: e
1057
- });
1058
- },
1059
- li({ children: e }) {
1060
- return /* @__PURE__ */ R("li", {
1061
- className: "min-w-0 break-words pl-1 leading-6 text-foreground",
1062
- children: e
1063
- });
1064
- },
1065
- strong({ children: e }) {
1066
- return /* @__PURE__ */ R("strong", {
1067
- className: "font-semibold text-foreground",
1068
- children: e
1069
- });
1070
- },
1071
- blockquote({ children: e }) {
1072
- return /* @__PURE__ */ R("blockquote", {
1073
- className: "mb-3 border-l-2 border-border pl-4 text-text-secondary",
1074
- children: e
1075
- });
1076
- },
1077
- code({ className: e, children: t, ...n }) {
1078
- let r = /language-(\w+)/.exec(e || ""), i = String(t ?? "");
1079
- if (!r && !i.includes("\n")) return /* @__PURE__ */ R("code", {
1080
- 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",
1081
- ...n,
1082
- children: t
1083
- });
1084
- let a = r ? r[1] : "";
1085
- return a === "mermaid" ? /* @__PURE__ */ R(H, {
1086
- fallback: /* @__PURE__ */ R("div", { className: "h-32 animate-pulse rounded bg-muted" }),
1087
- children: /* @__PURE__ */ R(an, { chart: i })
1088
- }) : /* @__PURE__ */ R(H, {
1089
- fallback: /* @__PURE__ */ R("pre", {
1090
- className: "p-4 text-sm",
1091
- children: i
1092
- }),
1093
- children: /* @__PURE__ */ R(rn, {
1094
- language: a,
1095
- value: i
1096
- })
1097
- });
1098
- },
1099
- table({ children: e, ...t }) {
1100
- return /* @__PURE__ */ R("div", {
1101
- className: "mb-3 max-w-full overflow-x-auto",
1102
- children: /* @__PURE__ */ R("table", {
1103
- className: "w-full min-w-max border-collapse text-sm text-foreground",
1104
- ...t,
1105
- children: e
1106
- })
1107
- });
1108
- },
1109
- th({ children: e, ...t }) {
1110
- return /* @__PURE__ */ R("th", {
1111
- className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
1112
- ...t,
1113
- children: e
1114
- });
1115
- },
1116
- td({ children: e, ...t }) {
1117
- return /* @__PURE__ */ R("td", {
1118
- className: "border-b border-border px-3 py-2 text-text-secondary",
1119
- ...t,
1120
- children: e
1121
- });
1122
- },
1123
- a({ children: e, href: t, ...n }) {
1124
- return /* @__PURE__ */ R("a", {
1125
- href: t,
1126
- className: "text-primary hover:underline",
1127
- target: "_blank",
1128
- rel: "noopener noreferrer",
1129
- ...n,
1130
- children: e
1131
- });
1132
- }
1133
- }, ln = V.memo(({ content: e }) => {
1134
- let t = nn(e);
1135
- return /* @__PURE__ */ R("div", {
1136
- className: "max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
1137
- children: /* @__PURE__ */ R(De, {
1138
- remarkPlugins: [Oe, ke],
1139
- components: cn,
1140
- children: t
1141
- })
1142
- });
1143
- }), X = V.memo(({ content: e }) => sn(e) ? /* @__PURE__ */ R(H, {
1144
- fallback: /* @__PURE__ */ R(ln, { content: e }),
1145
- children: /* @__PURE__ */ R(on, { content: e })
1146
- }) : /* @__PURE__ */ R(ln, { content: e })), un = /^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;
1147
- function dn(e) {
1148
- let t = [], n = /* @__PURE__ */ new Map(), r = null;
1149
- for (let i of e.split("\n")) {
1150
- let e = i.match(un);
1151
- if (e) {
1152
- let a = e[2], o = n.get(a);
1153
- if (o) {
1154
- o.lines.push(i), r = o;
1155
- continue;
1156
- }
1157
- r = {
1158
- oldPath: e[1],
1159
- path: a,
1160
- lines: [i]
1161
- }, n.set(a, r), t.push(r);
1162
- continue;
1163
- }
1164
- r?.lines.push(i);
1165
- }
1166
- return t;
1167
- }
1168
- function fn(e) {
1169
- let t = 0, n = 0;
1170
- for (let r of e.lines) r.startsWith("+") && !r.startsWith("+++") ? t += 1 : r.startsWith("-") && !r.startsWith("---") && (n += 1);
1171
- return {
1172
- added: t,
1173
- removed: n
1174
- };
1175
- }
1176
- function pn(e) {
1177
- return /^diff --git /m.test(e);
1178
- }
1179
- //#endregion
1180
- //#region src/core/interaction/a2ui-validate.ts
1181
- var mn = "0.9.1";
1182
- function hn(e) {
1183
- let t = typeof e == "object" && e ? e.components : null, n = Array.isArray(t) ? t : [], r = [];
1184
- for (let e of n) typeof e == "object" && e && typeof e.id == "string" && r.push(e.id);
1185
- return r.sort();
1186
- }
1187
- function gn(e) {
1188
- let t = hn(e).join("|"), n = 2166136261, r = 16777619;
1189
- for (let e = 0; e < t.length; e += 1) {
1190
- let i = t.charCodeAt(e);
1191
- n = (n ^ i) >>> 0, n = Math.imul(n, 16777619) >>> 0, r = r + Math.imul(i + e, 2246822507) >>> 0;
1192
- }
1193
- return `fnv1a-${n.toString(16)}-${r.toString(16)}`;
1194
- }
1195
- function _n(e, t) {
1196
- if (!e) return vn(null);
1197
- if (e.wireVersion !== "0.9.1" || !e.messages || e.messages.length === 0) return vn(e);
1198
- if (e.catalogDigest) {
1199
- let n = gn(t);
1200
- if (e.catalogDigest !== n) return "json-schema-form";
1201
- }
1202
- return "a2ui";
1203
- }
1204
- function vn(e) {
1205
- return e && yn(e) ? "json-schema-form" : "basic-controls";
1206
- }
1207
- function yn(e) {
1208
- return e.messages.some((e) => {
1209
- let t = e.inputSchema ?? e.input_schema ?? e.schema;
1210
- return typeof t == "object" && !!t;
1211
- });
1212
- }
1213
- //#endregion
1214
- //#region src/core/interaction/types.ts
1215
- var bn = new Set([
1216
- "resolved",
1217
- "cancelled",
1218
- "expired"
1219
- ]);
1220
- function xn(e) {
1221
- return bn.has(e);
1222
- }
1223
- function Sn(e, t) {
1224
- return `interaction:${e}:revision-${t}`;
1225
- }
1226
- function Cn(e, t) {
1227
- let n = t.approved;
1228
- if (typeof n == "boolean") return n ? "已同意" : "已拒绝";
1229
- let r = Object.keys(t);
1230
- return r.length === 0 ? e === "approve" ? "已同意" : e === "reject" ? "已拒绝" : e === "cancel" ? "已取消" : "已提交" : `${e}(${r.slice(0, 3).map((e) => {
1231
- let n = t[e];
1232
- return `${e}=${typeof n == "string" ? n.length > 24 ? `${n.slice(0, 24)}…` : n : typeof n == "object" && n ? "[object]" : String(n)}`;
1233
- }).join(", ")})`;
1234
- }
1235
- //#endregion
1236
- //#region src/components/chat/schema-fields.ts
1237
- function wn(e) {
1238
- return typeof e == "object" && e && !Array.isArray(e) ? e : null;
1239
- }
1240
- function Tn(e) {
1241
- let t = wn(e.properties) || {}, n = Array.isArray(e.required) ? new Set(e.required.map(String)) : /* @__PURE__ */ new Set(), r = [];
1242
- for (let [e, i] of Object.entries(t)) {
1243
- let t = wn(i), a = String(t?.type || "").toLowerCase(), o = a === "string" || a === "number" || a === "boolean" ? a : "unknown";
1244
- r.push({
1245
- name: e,
1246
- title: typeof t?.title == "string" ? t.title : void 0,
1247
- type: o,
1248
- required: n.has(e),
1249
- enumValues: Array.isArray(t?.enum) ? t.enum : void 0
1250
- });
1251
- }
1252
- return r;
1253
- }
1254
- //#endregion
1255
- //#region src/components/chat/InteractionSchemaForm.tsx
1256
- function En({ schema: e, values: t, onChange: n, disabled: r, onSubmit: i, onCancel: a }) {
1257
- return /* @__PURE__ */ z("div", {
1258
- className: "mt-3",
1259
- "data-testid": "interaction-schema-form",
1260
- children: [Tn(e).map((e) => /* @__PURE__ */ z("label", {
1261
- className: "mb-2 block text-xs text-slate-600 dark:text-slate-300",
1262
- children: [/* @__PURE__ */ z("span", {
1263
- className: "mb-1 block font-medium",
1264
- children: [e.title || e.name, e.required ? /* @__PURE__ */ R("span", {
1265
- className: "ml-0.5 text-rose-500",
1266
- children: "*"
1267
- }) : null]
1268
- }), e.enumValues && e.enumValues.length > 0 ? /* @__PURE__ */ z("select", {
1269
- "data-testid": `interaction-field-${e.name}`,
1270
- disabled: r,
1271
- value: String(t[e.name] ?? ""),
1272
- onChange: (r) => n({
1273
- ...t,
1274
- [e.name]: r.target.value
1275
- }),
1276
- className: "w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950",
1277
- children: [/* @__PURE__ */ R("option", {
1278
- value: "",
1279
- children: "请选择…"
1280
- }), e.enumValues.map((e) => /* @__PURE__ */ R("option", {
1281
- value: String(e),
1282
- children: String(e)
1283
- }, String(e)))]
1284
- }) : e.type === "boolean" ? /* @__PURE__ */ R("input", {
1285
- type: "checkbox",
1286
- "data-testid": `interaction-field-${e.name}`,
1287
- disabled: r,
1288
- checked: !!t[e.name],
1289
- onChange: (r) => n({
1290
- ...t,
1291
- [e.name]: r.target.checked
1292
- }),
1293
- className: "h-4 w-4"
1294
- }) : e.type === "number" ? /* @__PURE__ */ R("input", {
1295
- type: "number",
1296
- "data-testid": `interaction-field-${e.name}`,
1297
- disabled: r,
1298
- value: t[e.name] === void 0 ? "" : String(t[e.name]),
1299
- onChange: (r) => n({
1300
- ...t,
1301
- [e.name]: r.target.value === "" ? void 0 : Number(r.target.value)
1302
- }),
1303
- className: "w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950"
1304
- }) : /* @__PURE__ */ R("input", {
1305
- type: "text",
1306
- "data-testid": `interaction-field-${e.name}`,
1307
- disabled: r,
1308
- value: String(t[e.name] ?? ""),
1309
- onChange: (r) => n({
1310
- ...t,
1311
- [e.name]: r.target.value
1312
- }),
1313
- className: "w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950"
1314
- })]
1315
- }, e.name)), /* @__PURE__ */ z("div", {
1316
- className: "mt-2 flex flex-wrap gap-2",
1317
- children: [/* @__PURE__ */ R("button", {
1318
- type: "button",
1319
- "data-testid": "interaction-submit",
1320
- disabled: r,
1321
- onClick: i,
1322
- className: "inline-flex min-h-8 items-center rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55",
1323
- children: "提交"
1324
- }), /* @__PURE__ */ R("button", {
1325
- type: "button",
1326
- "data-testid": "interaction-form-cancel",
1327
- disabled: r,
1328
- onClick: a,
1329
- className: "inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400",
1330
- children: "取消本次确认"
1331
- })]
1332
- })]
1333
- });
1334
- }
1335
- //#endregion
1336
- //#region src/core/run/a2ui.ts
1337
- var Dn = Ne, On = {
1338
- description: Me,
1339
- value: Pe(Dn)
1340
- };
1341
- function kn(e) {
1342
- return e.map((e) => {
1343
- let t = e.updateComponents;
1344
- if (!t || typeof t != "object" || Array.isArray(t)) return e;
1345
- let n = t.components;
1346
- if (!Array.isArray(n)) return e;
1347
- let r = n.filter((e) => !!(e && typeof e == "object" && !Array.isArray(e)));
1348
- if (r.some((e) => e.id === "root")) return e;
1349
- let i = r.filter((e) => typeof e.id == "string" && e.id.endsWith("-root"));
1350
- if (i.length !== 1) return e;
1351
- let a = i[0];
1352
- return {
1353
- ...e,
1354
- updateComponents: {
1355
- ...t,
1356
- components: n.map((e) => e === a ? {
1357
- ...a,
1358
- id: "root"
1359
- } : e)
1360
- }
1361
- };
1362
- });
1363
- }
1364
- //#endregion
1365
- //#region src/components/chat/A2UIActivityMessage.tsx
1366
- function An({ surfaceId: e, serializedMessages: t }) {
1367
- let { processMessages: n } = Fe();
1368
- return W(() => {
1369
- n(JSON.parse(t));
1370
- }, [t, n]), /* @__PURE__ */ R(je, {
1371
- surfaceId: e,
1372
- className: "w-full",
1373
- fallback: /* @__PURE__ */ R("div", {
1374
- className: "text-sm text-slate-500 dark:text-slate-400",
1375
- children: "界面内容暂不可用"
1376
- }),
1377
- loadingFallback: /* @__PURE__ */ R("div", {
1378
- className: "text-sm text-slate-500 dark:text-slate-400",
1379
- children: "正在加载界面"
1380
- })
1381
- });
1382
- }
1383
- function jn({ surfaceId: e, messages: t, onAction: n }) {
1384
- let r = JSON.stringify(t);
1385
- return /* @__PURE__ */ R("div", {
1386
- 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",
1387
- children: /* @__PURE__ */ R(Ae, {
1388
- catalog: Dn,
1389
- onAction: n,
1390
- children: /* @__PURE__ */ R(An, {
1391
- surfaceId: e,
1392
- serializedMessages: r
1393
- })
1394
- }, `${e}:${r}`)
1395
- });
1396
- }
1397
- //#endregion
1398
- //#region src/components/chat/InteractionA2uiSurface.tsx
1399
- function Mn({ a2ui: e, disabled: t, onSubmit: n, onCancel: r }) {
1400
- return /* @__PURE__ */ z("div", {
1401
- className: "mt-3",
1402
- "data-testid": "interaction-a2ui-surface",
1403
- children: [/* @__PURE__ */ R(jn, {
1404
- surfaceId: `interaction-${e.wireVersion}`,
1405
- messages: e.messages,
1406
- onAction: t ? void 0 : (e) => {
1407
- let t = e.userAction?.context || {};
1408
- n(typeof t.payload == "object" && t.payload !== null ? t.payload : { ...t });
1409
- }
1410
- }), t ? null : /* @__PURE__ */ R("button", {
1411
- type: "button",
1412
- "data-testid": "interaction-a2ui-cancel",
1413
- onClick: r,
1414
- className: "mt-1 inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline dark:text-slate-400",
1415
- children: "取消本次确认"
1416
- })]
1417
- });
1418
- }
1419
- //#endregion
1420
- //#region src/components/chat/InteractionTray.tsx
1421
- function Nn(e) {
1422
- for (let t of e?.messages || []) {
1423
- let e = t.inputSchema ?? t.input_schema ?? t.schema;
1424
- if (typeof e == "object" && e) return e;
1425
- }
1426
- return null;
1427
- }
1428
- function Pn(e) {
1429
- if (!e.expiresAt) return !1;
1430
- let t = Date.parse(e.expiresAt);
1431
- return Number.isFinite(t) && t <= Date.now();
1432
- }
1433
- function Fn(e) {
1434
- let t = e.extensions.submit_error;
1435
- return typeof t == "object" && t && "code" in t && "message" in t ? {
1436
- code: String(t.code),
1437
- message: String(t.message),
1438
- retryable: !!t.retryable
1439
- } : null;
1440
- }
1441
- var In = {
1442
- approved: "已同意",
1443
- rejected: "已拒绝",
1444
- submitted: "已提交",
1445
- cancelled: "已取消",
1446
- expired: "已过期"
1447
- };
1448
- function Ln({ interactions: e, activeIndex: t, onSelectIndex: n, onRespond: r, localCatalog: i }) {
1449
- let [o, l] = K(""), [u, d] = K({}), f = e[Math.min(t, Math.max(e.length - 1, 0))];
1450
- if (!f) return null;
1451
- let p = Pn(f), m = Fn(f), h = p || f.status === "resolving", g = _n(f.presentation?.a2ui, i), _ = f.requestSchema ?? Nn(f.presentation?.a2ui) ?? null, v = g === "a2ui" ? "a2ui" : g === "json-schema-form" && _ || f.requestSchema && !f.presentation ? "json-schema-form" : "basic-controls", y = v === "json-schema-form" && _ || f.requestSchema, b = (e, t) => {
1452
- h || r({
1453
- interactionId: f.interactionId,
1454
- expectedRevision: f.revision,
1455
- action: e,
1456
- response: t,
1457
- idempotencyKey: Sn(f.interactionId, f.revision)
1458
- });
1459
- };
1460
- return /* @__PURE__ */ R("div", {
1461
- "data-testid": "interaction-tray",
1462
- "data-interaction-status": f.status,
1463
- "data-interaction-count": e.length,
1464
- className: "mx-auto mb-2 w-full max-w-3xl px-6",
1465
- children: /* @__PURE__ */ z("div", {
1466
- className: "rounded-xl border border-amber-300/80 bg-amber-50/80 p-3 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30",
1467
- children: [
1468
- /* @__PURE__ */ z("div", {
1469
- className: "flex items-center justify-between gap-2",
1470
- children: [/* @__PURE__ */ z("div", {
1471
- className: "flex items-center gap-2 text-sm font-medium text-amber-900 dark:text-amber-200",
1472
- children: [/* @__PURE__ */ R("span", {
1473
- "data-testid": "interaction-tray-title",
1474
- children: f.title
1475
- }), e.length > 1 ? /* @__PURE__ */ z("span", {
1476
- "data-testid": "interaction-tray-count",
1477
- className: "rounded-full border border-amber-400/60 px-1.5 py-0.5 text-xs",
1478
- children: [
1479
- t + 1,
1480
- "/",
1481
- e.length
1482
- ]
1483
- }) : null]
1484
- }), e.length > 1 ? /* @__PURE__ */ z("div", {
1485
- className: "flex items-center gap-1",
1486
- children: [/* @__PURE__ */ R("button", {
1487
- type: "button",
1488
- "data-testid": "interaction-tray-prev",
1489
- disabled: t <= 0,
1490
- onClick: () => n(Math.max(t - 1, 0)),
1491
- className: "rounded border border-amber-400/60 p-1 text-amber-900 disabled:opacity-40 dark:text-amber-200",
1492
- "aria-label": "上一条待确认",
1493
- children: /* @__PURE__ */ R(s, { className: "h-3.5 w-3.5" })
1494
- }), /* @__PURE__ */ R("button", {
1495
- type: "button",
1496
- "data-testid": "interaction-tray-next",
1497
- disabled: t >= e.length - 1,
1498
- onClick: () => n(Math.min(t + 1, e.length - 1)),
1499
- className: "rounded border border-amber-400/60 p-1 text-amber-900 disabled:opacity-40 dark:text-amber-200",
1500
- "aria-label": "下一条待确认",
1501
- children: /* @__PURE__ */ R(c, { className: "h-3.5 w-3.5" })
1502
- })]
1503
- }) : null]
1504
- }),
1505
- /* @__PURE__ */ R("p", {
1506
- className: "mt-2 text-sm text-slate-700 dark:text-slate-200",
1507
- "data-testid": "interaction-tray-message",
1508
- children: f.message
1509
- }),
1510
- p ? /* @__PURE__ */ z("p", {
1511
- className: "mt-2 text-xs font-medium text-rose-600 dark:text-rose-400",
1512
- "data-testid": "interaction-tray-expired",
1513
- children: [
1514
- "该确认已过期(",
1515
- In.expired,
1516
- "),等待运行时继续处理。"
1517
- ]
1518
- }) : null,
1519
- m ? /* @__PURE__ */ z("p", {
1520
- className: "mt-2 text-xs font-medium text-rose-600 dark:text-rose-400",
1521
- "data-testid": "interaction-tray-error",
1522
- children: [
1523
- "提交失败(",
1524
- m.code,
1525
- "):",
1526
- m.message,
1527
- m.retryable ? ",可重试。" : ""
1528
- ]
1529
- }) : null,
1530
- v === "a2ui" && f.presentation?.a2ui ? /* @__PURE__ */ R(Mn, {
1531
- a2ui: f.presentation.a2ui,
1532
- disabled: h,
1533
- onSubmit: (e) => b("submit", e),
1534
- onCancel: () => b("cancel", {})
1535
- }) : v === "json-schema-form" && y ? /* @__PURE__ */ R(En, {
1536
- schema: y,
1537
- values: u,
1538
- onChange: d,
1539
- disabled: h,
1540
- onSubmit: () => b("submit", u),
1541
- onCancel: () => b("cancel", {})
1542
- }) : /* @__PURE__ */ z("div", {
1543
- className: "mt-3",
1544
- "data-testid": "interaction-tray-basic",
1545
- children: [/* @__PURE__ */ R("input", {
1546
- type: "text",
1547
- value: o,
1548
- onChange: (e) => l(e.target.value),
1549
- placeholder: "备注(可选)",
1550
- disabled: h,
1551
- "data-testid": "interaction-tray-comment",
1552
- className: "mb-2 w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950"
1553
- }), /* @__PURE__ */ z("div", {
1554
- className: "flex flex-wrap gap-2",
1555
- children: [
1556
- /* @__PURE__ */ z("button", {
1557
- type: "button",
1558
- "data-testid": "interaction-approve",
1559
- disabled: h,
1560
- onClick: () => b("approve", {
1561
- decision: "approve",
1562
- ...o ? { comment: o } : {}
1563
- }),
1564
- 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",
1565
- children: [/* @__PURE__ */ R(a, { className: "h-3.5 w-3.5" }), "批准并继续"]
1566
- }),
1567
- /* @__PURE__ */ z("button", {
1568
- type: "button",
1569
- "data-testid": "interaction-reject",
1570
- disabled: h,
1571
- onClick: () => b("reject", {
1572
- decision: "reject",
1573
- ...o ? { comment: o } : {}
1574
- }),
1575
- 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",
1576
- children: [/* @__PURE__ */ R(ve, { className: "h-3.5 w-3.5" }), "拒绝"]
1577
- }),
1578
- /* @__PURE__ */ R("button", {
1579
- type: "button",
1580
- "data-testid": "interaction-cancel",
1581
- disabled: h,
1582
- onClick: () => b("cancel", {}),
1583
- className: "inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400",
1584
- children: "取消本次确认"
1585
- })
1586
- ]
1587
- })]
1588
- }),
1589
- f.status === "resolving" ? /* @__PURE__ */ R("p", {
1590
- className: "mt-2 text-xs text-amber-700 dark:text-amber-300",
1591
- children: "正在提交,请稍候…"
1592
- }) : null
1593
- ]
1594
- })
1595
- });
1596
- }
1597
- function Rn({ outcome: e }) {
1598
- return /* @__PURE__ */ R("span", {
1599
- className: J("rounded border px-1.5 py-0.5 text-xs font-medium", e === "approved" ? "border-emerald-300 text-emerald-700 dark:border-emerald-900 dark:text-emerald-300" : e === "rejected" ? "border-rose-300 text-rose-700 dark:border-rose-900 dark:text-rose-300" : "border-slate-300 text-slate-600 dark:border-slate-700 dark:text-slate-300"),
1600
- children: In[e] || e
1601
- });
1602
- }
1603
- //#endregion
1604
- //#region src/components/chat/InteractionHistoryAnchor.tsx
1605
- function zn(e) {
1606
- if (!e) return "";
1607
- let t = Date.parse(e);
1608
- return Number.isFinite(t) ? new Date(t).toLocaleString() : e;
1609
- }
1610
- function Bn(e) {
1611
- let t = e?.properties;
1612
- return typeof t != "object" || !t ? [] : Object.keys(t);
1613
- }
1614
- function Vn({ interaction: e }) {
1615
- let t = e.status === "resolved" || e.status === "cancelled" || e.status === "expired", n = Bn(e.requestSchema);
1616
- return /* @__PURE__ */ z("div", {
1617
- "data-testid": "interaction-history-anchor",
1618
- "data-interaction-id": e.interactionId,
1619
- "data-interaction-status": e.status,
1620
- className: "mt-2 rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600 dark:border-slate-800 dark:bg-slate-900/60 dark:text-slate-300",
1621
- children: [/* @__PURE__ */ z("div", {
1622
- className: "flex flex-wrap items-center gap-2",
1623
- children: [/* @__PURE__ */ R("span", {
1624
- className: "font-medium text-slate-700 dark:text-slate-200",
1625
- children: e.title
1626
- }), /* @__PURE__ */ R(Rn, { outcome: e.outcome || e.status })]
1627
- }), t ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
1628
- className: "mt-1 leading-relaxed",
1629
- children: [
1630
- e.actor ? /* @__PURE__ */ z("span", { children: [
1631
- "操作人:",
1632
- e.actor,
1633
- " · "
1634
- ] }) : null,
1635
- e.resolvedAt ? /* @__PURE__ */ z("span", { children: [
1636
- "决定时间:",
1637
- zn(e.resolvedAt),
1638
- " · "
1639
- ] }) : null,
1640
- /* @__PURE__ */ R("span", {
1641
- "data-testid": "interaction-history-response-summary",
1642
- children: e.responseSummary || "响应内容已脱敏"
1643
- })
1644
- ]
1645
- }), /* @__PURE__ */ z("details", {
1646
- "data-testid": "interaction-history-detail",
1647
- className: "mt-1",
1648
- children: [/* @__PURE__ */ R("summary", {
1649
- className: "cursor-pointer select-none text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200",
1650
- children: "查看确认快照"
1651
- }), /* @__PURE__ */ z("div", {
1652
- "data-testid": "interaction-history-snapshot",
1653
- className: "mt-1 rounded border border-slate-200 bg-white px-2 py-1.5 leading-relaxed dark:border-slate-800 dark:bg-slate-950",
1654
- children: [
1655
- /* @__PURE__ */ z("div", { children: ["操作者:", /* @__PURE__ */ R("span", {
1656
- "data-testid": "interaction-history-actor-ref",
1657
- children: e.actor || "—"
1658
- })] }),
1659
- /* @__PURE__ */ z("div", { children: ["决定时间:", zn(e.resolvedAt) || "—"] }),
1660
- /* @__PURE__ */ z("div", { children: ["关键参数:", n.length > 0 ? /* @__PURE__ */ R("span", {
1661
- "data-testid": "interaction-history-schema-keys",
1662
- children: n.join("、")
1663
- }) : /* @__PURE__ */ R("span", { children: "无结构化参数" })] })
1664
- ]
1665
- })]
1666
- })] }) : /* @__PURE__ */ z("div", {
1667
- className: "mt-1",
1668
- children: ["状态:", e.status === "pending" ? "待处理(见输入区确认面板)" : "处理中…"]
1669
- })]
1670
- });
1671
- }
1672
- //#endregion
1673
- //#region src/components/chat/ProcessingBlocksView.tsx
1674
- function Hn({ summary: e, children: t, defaultOpen: n = !1, streaming: r = !1 }) {
1675
- let [i, a] = K(n);
1676
- return /* @__PURE__ */ z("div", {
1677
- className: "mb-1.5",
1678
- children: [/* @__PURE__ */ z("button", {
1679
- type: "button",
1680
- onClick: () => a((e) => !e),
1681
- 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",
1682
- children: [r ? /* @__PURE__ */ R(C, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }) : /* @__PURE__ */ R(o, { className: J("h-3.5 w-3.5 text-slate-400 transition-transform", i && "rotate-90") }), /* @__PURE__ */ R("span", {
1683
- className: "min-w-0 flex-1 truncate",
1684
- children: e
1685
- })]
1686
- }), i && /* @__PURE__ */ R("div", {
1687
- className: "mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60",
1688
- children: t
1689
- })]
1690
- });
1691
- }
1692
- function Un({ block: e }) {
1693
- let [t, n] = K(!1), r = e.status === "streaming", i = e.content.length, a = `${e.id}-thinking-detail`;
1694
- return /* @__PURE__ */ z("div", {
1695
- className: "mb-1.5 min-w-0",
1696
- children: [/* @__PURE__ */ z("button", {
1697
- type: "button",
1698
- "aria-expanded": t,
1699
- "aria-controls": a,
1700
- onClick: () => n((e) => !e),
1701
- 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",
1702
- children: [
1703
- !r && /* @__PURE__ */ R(le, { className: "h-3.5 w-3.5 shrink-0" }),
1704
- /* @__PURE__ */ R("span", {
1705
- className: J("min-w-0 truncate", r && "waiting-thinking-text"),
1706
- "data-testid": r ? "thinking-indicator" : void 0,
1707
- role: r ? "status" : void 0,
1708
- children: r ? "正在思考…" : "已思考"
1709
- }),
1710
- !r && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
1711
- className: "text-slate-300 dark:text-slate-600",
1712
- children: "·"
1713
- }), /* @__PURE__ */ z("span", {
1714
- className: "font-mono text-xs text-slate-400 dark:text-slate-500",
1715
- children: [i, " 字"]
1716
- })] }),
1717
- /* @__PURE__ */ R(o, { className: J("h-3.5 w-3.5 shrink-0 transition-transform", t && "rotate-180") })
1718
- ]
1719
- }), t && e.content && /* @__PURE__ */ R("div", {
1720
- id: a,
1721
- 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",
1722
- children: /* @__PURE__ */ R(X, { content: e.content })
1723
- })]
1724
- });
1725
- }
1726
- function Wn({ block: e, tool: t, isStreaming: n, interactionRecord: r, onRespondToApproval: i, onRespondToAguiApproval: a }) {
1727
- let o = t?.status ?? e.status, s = t?.args ?? e.args, c = t?.output ?? e.output, l = e.extra || {}, u = l.approvalStatus || t?.approvalStatus, d = l.approvalRequestId || t?.approvalRequestId, f = l.approvalMessage || t?.approvalMessage, p = l.approvalProtocol || t?.approvalProtocol, m = l.previousResponseId || t?.previousResponseId, h = o === "running", g = o === "error", _ = o === "paused", v = g ? "执行失败" : u === "pending" ? "等待确认" : u === "rejected" ? "已拒绝" : h ? u === "approved" ? "已授权 · 执行中" : "正在运行" : u === "approved" ? "已授权" : _ ? "已暂停" : "已完成", y = g ? "text-rose-500 dark:text-rose-400" : _ ? "text-amber-500 dark:text-amber-400" : h ? "text-slate-500 dark:text-slate-400" : "text-slate-400 dark:text-slate-500";
1728
- return /* @__PURE__ */ R(Hn, {
1729
- streaming: h && !s,
1730
- defaultOpen: u === "pending" || _,
1731
- summary: /* @__PURE__ */ z("span", {
1732
- className: "flex items-center gap-1.5",
1733
- children: [
1734
- /* @__PURE__ */ R(ge, { className: J("h-3.5 w-3.5 shrink-0", y) }),
1735
- /* @__PURE__ */ R("span", {
1736
- className: y,
1737
- children: v
1738
- }),
1739
- /* @__PURE__ */ R("span", {
1740
- className: "truncate font-medium text-slate-600 dark:text-slate-300",
1741
- children: e.toolName
1742
- }),
1743
- h && s && /* @__PURE__ */ R("span", {
1744
- className: "ml-0.5 animate-pulse text-slate-400",
1745
- children: "…"
1746
- })
1747
- ]
1748
- }),
1749
- children: /* @__PURE__ */ z("div", {
1750
- className: "flex flex-col gap-2.5 py-1 text-[13px]",
1751
- children: [
1752
- d && u === "pending" && !r && /* @__PURE__ */ z("section", {
1753
- 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",
1754
- children: [/* @__PURE__ */ z("div", {
1755
- className: "flex min-w-0 flex-1 items-center gap-2",
1756
- children: [
1757
- /* @__PURE__ */ R("span", {
1758
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400",
1759
- "aria-hidden": "true"
1760
- }),
1761
- /* @__PURE__ */ R("span", {
1762
- className: "shrink-0 font-medium text-slate-700 dark:text-slate-200",
1763
- children: "需要确认"
1764
- }),
1765
- /* @__PURE__ */ R("span", {
1766
- className: "min-w-0 truncate text-slate-500 dark:text-slate-400",
1767
- children: f || "允许后将执行此工具调用。"
1768
- })
1769
- ]
1770
- }), /* @__PURE__ */ z("div", {
1771
- className: "flex shrink-0 items-center gap-1.5",
1772
- children: [/* @__PURE__ */ R("button", {
1773
- type: "button",
1774
- disabled: n,
1775
- onClick: () => p === "ag-ui" ? a?.({
1776
- interruptId: d || "",
1777
- approve: !0
1778
- }) : i?.({
1779
- approvalRequestId: d || "",
1780
- approve: !0,
1781
- previousResponseId: m
1782
- }),
1783
- 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",
1784
- children: "允许执行"
1785
- }), /* @__PURE__ */ R("button", {
1786
- type: "button",
1787
- disabled: n,
1788
- onClick: () => p === "ag-ui" ? a?.({
1789
- interruptId: d || "",
1790
- approve: !1
1791
- }) : i?.({
1792
- approvalRequestId: d || "",
1793
- approve: !1,
1794
- previousResponseId: m
1795
- }),
1796
- 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",
1797
- children: "拒绝"
1798
- })]
1799
- })]
1800
- }),
1801
- d && u === "pending" && r ? /* @__PURE__ */ z("div", {
1802
- className: "flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400",
1803
- children: [/* @__PURE__ */ R("span", {
1804
- className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400",
1805
- "aria-hidden": "true"
1806
- }), "请在输入区确认面板中操作。"]
1807
- }) : null,
1808
- d && u && u !== "pending" && /* @__PURE__ */ z("div", {
1809
- className: "flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400",
1810
- children: [
1811
- /* @__PURE__ */ R("span", { children: u === "approved" ? "已授权" : "已拒绝" }),
1812
- u === "approved" && h ? /* @__PURE__ */ R("span", { children: "· 工具执行中" }) : null,
1813
- u === "approved" && g ? /* @__PURE__ */ R("span", { children: "· 工具执行失败" }) : null
1814
- ]
1815
- }),
1816
- s ? /* @__PURE__ */ R(Yn, {
1817
- label: "入参",
1818
- value: s,
1819
- tone: "input"
1820
- }) : null,
1821
- c ? Gn(e.toolName, c, g) : null
1822
- ]
1823
- })
1824
- });
1825
- }
1826
- function Gn(e, t, n) {
1827
- if (pn(t)) return /* @__PURE__ */ R(Kn, { output: t });
1828
- let r = e.toLowerCase();
1829
- if (r.includes("web_search") || r.includes("search")) {
1830
- let e = qn(t);
1831
- if (e.length > 0) return /* @__PURE__ */ R(Jn, { sources: e });
1832
- }
1833
- return /* @__PURE__ */ R(Yn, {
1834
- label: "输出",
1835
- value: t,
1836
- tone: n ? "error" : "output"
1837
- });
1838
- }
1839
- function Kn({ output: e }) {
1840
- let t = dn(e), [n, r] = K(!1), i = n ? t : t.slice(0, 3);
1841
- return /* @__PURE__ */ z("div", {
1842
- className: "my-2 overflow-hidden rounded-xl border border-border bg-background",
1843
- children: [
1844
- /* @__PURE__ */ z("div", {
1845
- className: "flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-medium text-text-secondary",
1846
- children: [/* @__PURE__ */ R(h, { className: "h-3.5 w-3.5 text-primary" }), /* @__PURE__ */ z("span", { children: [
1847
- "改动 ",
1848
- t.length,
1849
- " 个文件"
1850
- ] })]
1851
- }),
1852
- /* @__PURE__ */ R("div", {
1853
- className: "flex flex-col",
1854
- children: i.map((e) => {
1855
- let { added: t, removed: n } = fn(e);
1856
- return /* @__PURE__ */ z("div", {
1857
- className: "group/file-change-row flex min-w-0 items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-muted",
1858
- children: [/* @__PURE__ */ R("span", {
1859
- className: "min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary",
1860
- children: e.path
1861
- }), /* @__PURE__ */ z("span", {
1862
- className: "flex-shrink-0 text-[11px] font-mono",
1863
- children: [
1864
- /* @__PURE__ */ z("span", {
1865
- className: "text-emerald-600",
1866
- children: ["+", t]
1867
- }),
1868
- " ",
1869
- /* @__PURE__ */ z("span", {
1870
- className: "text-rose-500",
1871
- children: ["−", n]
1872
- })
1873
- ]
1874
- })]
1875
- }, e.path);
1876
- })
1877
- }),
1878
- t.length > 3 ? /* @__PURE__ */ R("button", {
1879
- type: "button",
1880
- onClick: () => r((e) => !e),
1881
- 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",
1882
- children: n ? "收起" : `展开剩余 ${t.length - 3} 个文件`
1883
- }) : null
1884
- ]
1885
- });
1886
- }
1887
- function qn(e) {
1888
- try {
1889
- let t = JSON.parse(e), n = Array.isArray(t) ? t : t?.results ?? t?.sources ?? [];
1890
- return Array.isArray(n) ? n.map((e) => {
1891
- let t = e, n = String(t?.url ?? t?.link ?? t?.href ?? ""), r = String(t?.title ?? t?.name ?? n);
1892
- return n ? {
1893
- url: n,
1894
- title: r
1895
- } : null;
1896
- }).filter((e) => e !== null) : [];
1897
- } catch {
1898
- return [];
1899
- }
1900
- }
1901
- function Jn({ sources: e }) {
1902
- return /* @__PURE__ */ R("div", {
1903
- className: "mt-2 flex min-w-0",
1904
- children: /* @__PURE__ */ z("span", {
1905
- className: "group/web-search-sources relative inline-flex min-w-0",
1906
- children: [/* @__PURE__ */ z("button", {
1907
- type: "button",
1908
- 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",
1909
- children: [/* @__PURE__ */ R(v, {
1910
- className: "h-3.5 w-3.5 shrink-0",
1911
- strokeWidth: 1.7
1912
- }), /* @__PURE__ */ z("span", { children: ["来源 · ", e.length] })]
1913
- }), /* @__PURE__ */ R("span", {
1914
- className: "absolute bottom-full left-0 z-30 hidden max-w-[calc(100vw-3rem)] pb-1 group-hover/web-search-sources:block",
1915
- children: /* @__PURE__ */ R("span", {
1916
- className: "block w-[min(26rem,calc(100vw-3rem))] rounded-xl border border-border bg-popover p-2 text-left text-text-primary shadow-2xl",
1917
- children: /* @__PURE__ */ R("span", {
1918
- className: "flex min-w-0 flex-col gap-1",
1919
- children: e.map((e, t) => /* @__PURE__ */ z("a", {
1920
- href: e.url,
1921
- target: "_blank",
1922
- rel: "noopener noreferrer",
1923
- 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",
1924
- children: [/* @__PURE__ */ R(v, {
1925
- className: "h-3.5 w-3.5 shrink-0",
1926
- strokeWidth: 1.7
1927
- }), /* @__PURE__ */ R("span", {
1928
- className: "min-w-0 flex-1 truncate",
1929
- children: e.title
1930
- })]
1931
- }, `${e.url}-${t}`))
1932
- })
1933
- })
1934
- })]
1935
- })
1936
- });
1937
- }
1938
- function Yn({ label: e, tone: t, value: n }) {
1939
- return /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("div", {
1940
- className: "mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400",
1941
- children: e
1942
- }), /* @__PURE__ */ R("pre", {
1943
- className: J("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"),
1944
- children: n
1945
- })] });
1946
- }
1947
- function Xn({ block: e }) {
1948
- return e.content ? /* @__PURE__ */ R("div", {
1949
- className: "w-full break-words py-0.5 text-[14px] leading-[1.65]",
1950
- children: /* @__PURE__ */ R(X, { content: e.content })
1951
- }) : null;
1952
- }
1953
- function Zn({ message: e, isStreaming: t, onRespondToApproval: n, onRespondToAguiApproval: r, interactionRecords: i }) {
1954
- return /* @__PURE__ */ R("div", {
1955
- className: "mb-3 min-w-0",
1956
- children: (e.blocks ?? []).map((a) => {
1957
- if (a.type === "thinking") return /* @__PURE__ */ R(Un, { block: a }, a.id);
1958
- if (a.type === "tool") {
1959
- let o = a.extra || {}, s = String(o.approvalRequestId || e.tools?.[a.toolName]?.approvalRequestId || ""), c = s ? i?.find((e) => e.interactionId === s) : void 0;
1960
- return /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R(Wn, {
1961
- block: a,
1962
- tool: e.tools?.[a.toolName],
1963
- isStreaming: t,
1964
- interactionRecord: c,
1965
- onRespondToApproval: n,
1966
- onRespondToAguiApproval: r
1967
- }), c ? /* @__PURE__ */ R(Vn, { interaction: c }) : null] }, a.id);
1968
- }
1969
- return /* @__PURE__ */ R(Xn, { block: a }, a.id);
1970
- })
1971
- });
1972
- }
1973
- //#endregion
1974
- //#region src/stores/streaming.ts
1975
- var Qn = (e) => Object.keys(e).length > 0, $n = {
1976
- runId: null,
1977
- status: null,
1978
- items: []
1979
- }, er = new e(), tr = (e, t) => {
1980
- let n = { ...e };
1981
- return delete n[t], n;
1982
- }, nr = I()((t, n) => ({
1983
- isStreaming: !1,
1984
- currentRunId: "",
1985
- stopRequested: !1,
1986
- activity: null,
1987
- sessionActivities: {},
1988
- sessionStreaming: {},
1989
- banner: null,
1990
- lastSeqId: 0,
1991
- activeInvocationId: "",
1992
- runtimeItems: $n,
1993
- setStreaming: (e) => t({ isStreaming: e }),
1994
- setBanner: (e) => t({ banner: e ? {
1995
- ...e,
1996
- createdAt: Date.now()
1997
- } : null }),
1998
- setLastSeqId: (e) => t({ lastSeqId: e }),
1999
- setActiveInvocationId: (e) => t({ activeInvocationId: e }),
2000
- setSessionStreaming: (e, n) => t((t) => {
2001
- let r = String(e || "");
2002
- if (!r) return { isStreaming: n };
2003
- let i = tr(t.sessionStreaming, r), a = n ? {
2004
- ...i,
2005
- [r]: !0
2006
- } : i;
2007
- return {
2008
- sessionStreaming: a,
2009
- isStreaming: Qn(a)
2010
- };
2011
- }),
2012
- isSessionStreaming: (e) => {
2013
- let t = String(e || "");
2014
- return !!(t && n().sessionStreaming[t]);
2015
- },
2016
- getSessionActivity: (e) => {
2017
- let t = String(e || "");
2018
- return t && n().sessionActivities[t] || null;
2019
- },
2020
- setCurrentRunId: (e) => t({ currentRunId: e }),
2021
- requestStop: () => t({ stopRequested: !0 }),
2022
- beginActivity: (e) => t({
2023
- stopRequested: !1,
2024
- activity: {
2025
- runId: e.runId,
2026
- source: e.source || "run",
2027
- status: e.status || "running",
2028
- phase: e.phase,
2029
- detail: e.detail,
2030
- startedAt: Date.now(),
2031
- lastEventAt: Date.now(),
2032
- eventCount: 0
2033
- }
2034
- }),
2035
- updateActivity: (e) => t((t) => {
2036
- let n = String(e.sessionId || ""), r = n ? t.sessionActivities[n] : t.activity, i = r ? {
2037
- ...r,
2038
- source: e.source || r.source,
2039
- status: e.status || r.status,
2040
- phase: e.phase || r.phase,
2041
- detail: e.detail === void 0 ? r.detail : e.detail,
2042
- lastEventAt: Date.now(),
2043
- eventCount: r.eventCount + (e.countEvent === !1 ? 0 : 1)
2044
- } : {
2045
- source: e.source || "run",
2046
- status: e.status || "running",
2047
- phase: e.phase || "正在运行",
2048
- detail: e.detail,
2049
- startedAt: Date.now(),
2050
- lastEventAt: Date.now(),
2051
- eventCount: e.countEvent === !1 ? 0 : 1
2052
- };
2053
- return n ? {
2054
- isStreaming: Qn(t.sessionStreaming),
2055
- sessionActivities: {
2056
- ...t.sessionActivities,
2057
- [n]: i
2058
- },
2059
- activity: i
2060
- } : { activity: i };
2061
- }),
2062
- stopActivity: (e) => t((t) => ({
2063
- isStreaming: !1,
2064
- stopRequested: !0,
2065
- activity: t.activity ? {
2066
- ...t.activity,
2067
- status: "stopped",
2068
- phase: "已断开输出流",
2069
- detail: e || "前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。",
2070
- lastEventAt: Date.now()
2071
- } : null
2072
- })),
2073
- stopSessionActivity: (e, n) => t((t) => {
2074
- let r = String(e || "");
2075
- if (!r) return {};
2076
- let i = t.sessionActivities[r];
2077
- if (!i) return {};
2078
- let a = {
2079
- ...i,
2080
- status: "stopped",
2081
- phase: "已断开输出流",
2082
- detail: n || "前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。",
2083
- lastEventAt: Date.now()
2084
- }, o = {
2085
- ...t.sessionActivities,
2086
- [r]: a
2087
- }, s = tr(t.sessionStreaming, r);
2088
- return {
2089
- isStreaming: Qn(s),
2090
- activity: a,
2091
- sessionActivities: o,
2092
- sessionStreaming: s
2093
- };
2094
- }),
2095
- clearActivity: () => t({ activity: null }),
2096
- clearSessionActivity: (e) => t((t) => {
2097
- let n = String(e || "");
2098
- if (!n) return {};
2099
- let { [n]: r, ...i } = t.sessionActivities, a = tr(t.sessionStreaming, n);
2100
- return {
2101
- sessionActivities: i,
2102
- sessionStreaming: a,
2103
- isStreaming: Qn(a),
2104
- activity: t.activity === r ? null : t.activity
2105
- };
2106
- }),
2107
- applyRuntimeItemOperations: (e) => {
2108
- er.applyAll(e), t({ runtimeItems: er.snapshot() });
2109
- },
2110
- resetRun: () => {
2111
- er = new e(), t({
2112
- isStreaming: !1,
2113
- currentRunId: "",
2114
- stopRequested: !1,
2115
- activity: null,
2116
- sessionActivities: {},
2117
- sessionStreaming: {},
2118
- lastSeqId: 0,
2119
- activeInvocationId: "",
2120
- runtimeItems: $n
2121
- });
2122
- }
2123
- }));
2124
- //#endregion
2125
- //#region src/components/chat/StatusBanner.tsx
2126
- function rr({ onRetry: e }) {
2127
- let t = nr((e) => e.banner);
2128
- if (!t) return null;
2129
- let n = t.kind === "rate_limited" ? /* @__PURE__ */ R(ir, {
2130
- message: t.message,
2131
- retryAfterSec: t.retryAfterSec
2132
- }, t.createdAt || `${t.sessionId || ""}:${t.retryAfterSec || 0}`) : null, r = {
2133
- rate_limited: {
2134
- icon: /* @__PURE__ */ R(ye, { className: "h-4 w-4 text-amber-500" }),
2135
- bg: "border-amber-200/70 bg-amber-50/70 dark:border-amber-900/40 dark:bg-amber-950/20",
2136
- text: "text-amber-700 dark:text-amber-200",
2137
- label: n
2138
- },
2139
- network: {
2140
- icon: /* @__PURE__ */ R(C, { className: "h-4 w-4 animate-spin text-text-secondary" }),
2141
- bg: "border-border/70 bg-muted/60",
2142
- text: "text-text-secondary",
2143
- label: t.message || "网络异常,正在重连…"
2144
- },
2145
- error: {
2146
- icon: /* @__PURE__ */ R(he, { className: "h-4 w-4 text-rose-500" }),
2147
- bg: "border-rose-200/70 bg-rose-50/70 dark:border-rose-900/40 dark:bg-rose-950/20",
2148
- text: "text-rose-600 dark:text-rose-300",
2149
- label: t.message || "运行失败,请重试"
2150
- }
2151
- }[t.kind];
2152
- return /* @__PURE__ */ z("div", {
2153
- className: J("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),
2154
- role: "status",
2155
- children: [
2156
- r.icon,
2157
- /* @__PURE__ */ R("span", {
2158
- className: "min-w-0 flex-1 truncate",
2159
- children: r.label
2160
- }),
2161
- t.kind === "error" && e ? /* @__PURE__ */ z("button", {
2162
- type: "button",
2163
- onClick: e,
2164
- 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",
2165
- children: [/* @__PURE__ */ R(se, { className: "h-3 w-3" }), "重试"]
2166
- }) : null
2167
- ]
2168
- });
2169
- }
2170
- function ir({ message: e, retryAfterSec: t }) {
2171
- let [n, r] = K(t || 0);
2172
- return W(() => {
2173
- if (!t) return;
2174
- let e = setInterval(() => {
2175
- r((e) => e > 0 ? e - 1 : 0);
2176
- }, 1e3);
2177
- return () => clearInterval(e);
2178
- }, [t]), n > 0 ? `${e}(${n}s 后可重试)` : e;
2179
- }
2180
- //#endregion
2181
- //#region src/utils/feedback.js
2182
- function Z(e) {
2183
- return String(e || "").trim();
2184
- }
2185
- function ar(e) {
2186
- let t = Z(e).toLowerCase();
2187
- return t === "up" || t === "down" ? t : "";
2188
- }
2189
- function or(e) {
2190
- if (!e || typeof e != "object") return null;
2191
- let t = ar(e.Rating || e.rating);
2192
- return t ? {
2193
- agentId: Z(e.AgentId || e.agentId),
2194
- sessionId: Z(e.SessionId || e.sessionId),
2195
- responseId: Z(e.ResponseId || e.responseId),
2196
- eventId: Z(e.EventId || e.eventId),
2197
- rating: t,
2198
- comment: String(e.Comment ?? e.comment ?? ""),
2199
- traceId: Z(e.TraceId || e.traceId),
2200
- rootSpanId: Z(e.RootSpanId || e.rootSpanId),
2201
- updatedAt: Z(e.UpdatedAt || e.updatedAt)
2202
- } : null;
2203
- }
2204
- function sr(e, t, n) {
2205
- return !!(e?.role === "model" && Z(e.responseId) && !(t && n));
2206
- }
2207
- function cr({ agentId: e, sessionId: t, message: n }) {
2208
- let r = Z(n?.responseId);
2209
- if (!r) throw Error("Message missing response id");
2210
- return {
2211
- AgentId: Z(e),
2212
- SessionId: Z(t),
2213
- ResponseId: r
2214
- };
2215
- }
2216
- function lr({ agentId: e, sessionId: t, message: n, rating: r, comment: i = "" }) {
2217
- let a = ar(r);
2218
- if (!a) throw Error("Feedback rating must be up or down");
2219
- return {
2220
- ...cr({
2221
- agentId: e,
2222
- sessionId: t,
2223
- message: n
2224
- }),
2225
- Rating: a,
2226
- Comment: String(i || ""),
2227
- TraceId: Z(n?.traceId),
2228
- RootSpanId: Z(n?.rootSpanId)
2229
- };
2230
- }
2231
- function ur(e, { messageId: t, rating: n, comment: r = "" }) {
2232
- let i = e.find((e) => e.id === t), a = i?.feedback ? { ...i.feedback } : null, o = ar(n);
2233
- return {
2234
- nextMessages: e.map((e) => e.id === t ? {
2235
- ...e,
2236
- feedback: {
2237
- ...e.feedback || {},
2238
- responseId: Z(e.responseId),
2239
- eventId: Z(e.eventId),
2240
- rating: o,
2241
- comment: String(r || ""),
2242
- pending: !0,
2243
- error: ""
2244
- }
2245
- } : e),
2246
- previousFeedback: a
2247
- };
2248
- }
2249
- function dr(e, { messageId: t, feedback: n }) {
2250
- let r = or(n) || n;
2251
- return e.map((e) => e.id === t ? {
2252
- ...e,
2253
- feedback: r ? {
2254
- ...r,
2255
- pending: !1,
2256
- error: ""
2257
- } : void 0
2258
- } : e);
2259
- }
2260
- function fr(e, { messageId: t, previousFeedback: n }) {
2261
- return e.map((e) => {
2262
- if (e.id !== t) return e;
2263
- if (!n) {
2264
- let { feedback: t, ...n } = e;
2265
- return n;
2266
- }
2267
- return {
2268
- ...e,
2269
- feedback: n
2270
- };
2271
- });
2272
- }
2273
- function pr(e, { messageId: t }) {
2274
- return e.map((e) => {
2275
- if (e.id !== t) return e;
2276
- let { feedback: n, ...r } = e;
2277
- return r;
2278
- });
2279
- }
2280
- //#endregion
2281
- //#region src/utils/clipboard.js
2282
- async function mr(e, t = globalThis) {
2283
- let n = String(e ?? ""), r = t?.navigator;
2284
- if (r?.clipboard?.writeText) try {
2285
- return await r.clipboard.writeText(n), !0;
2286
- } catch {}
2287
- let i = t?.document, a = i?.body;
2288
- if (!i?.createElement || !a?.appendChild || !a?.removeChild) return !1;
2289
- let o = i.createElement("textarea");
2290
- 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");
2291
- let s = i.activeElement;
2292
- a.appendChild(o), o.focus?.(), o.select?.(), o.setSelectionRange?.(0, n.length);
2293
- try {
2294
- return typeof i.execCommand == "function" ? !!i.execCommand("copy") : !1;
2295
- } finally {
2296
- a.removeChild(o), s?.focus?.();
2297
- }
2298
- }
2299
- //#endregion
2300
- //#region src/utils/session-helpers.ts
2301
- function hr(e) {
2302
- return String(e.Title || "").trim() || String(e.FirstPrompt || "").trim() || String(e.LastPrompt || "").trim() || String(e.Summary || "").trim() || "新对话";
2303
- }
2304
- //#endregion
2305
- //#region src/utils/message-virtualization.js
2306
- function gr(e, t, n) {
2307
- return Math.max(t, Math.min(n, e));
2308
- }
2309
- function _r({ 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) } = {}) {
2310
- 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);
2311
- if (!e.length) return {
2312
- startIndex: 0,
2313
- endIndex: 0,
2314
- offsetTop: 0,
2315
- totalHeight: 0,
2316
- visibleItems: []
2317
- };
2318
- let d = e.map((e, t) => {
2319
- let n = o(e, t), r = Number(a.get(n));
2320
- return Number.isFinite(r) && r > 0 ? r : u;
2321
- }), f = Array(e.length), p = 0;
2322
- for (let t = 0; t < e.length; t += 1) f[t] = p, p += d[t];
2323
- let m = p, h = c + s, g = 0;
2324
- for (; g < e.length && f[g] + d[g] <= c;) g += 1;
2325
- let _ = g;
2326
- for (; _ < e.length && f[_] < h;) _ += 1;
2327
- return g = gr(g - l, 0, e.length), _ = gr(Math.max(g + 1, _ + l), 0, e.length), {
2328
- startIndex: g,
2329
- endIndex: _,
2330
- offsetTop: f[g] || 0,
2331
- totalHeight: m,
2332
- visibleItems: e.slice(g, _).map((e, t) => {
2333
- let n = g + t;
2334
- return {
2335
- index: n,
2336
- item: e,
2337
- top: f[n] || 0,
2338
- height: d[n] || u
2339
- };
2340
- })
2341
- };
2342
- }
2343
- //#endregion
2344
- //#region src/components/chat/ChatMessageList.tsx
2345
- var vr = 140, yr = 4;
2346
- function br(e) {
2347
- let t = String(e || "").trim().toLowerCase();
2348
- return t === "elevated" ? "高风险" : t === "always" ? "始终确认" : t === "confirm" ? "需确认" : e || "";
2349
- }
2350
- function xr(e) {
2351
- 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";
2352
- }
2353
- function Sr({ messageId: e, top: t, onMeasure: n, children: r }) {
2354
- let i = G(null);
2355
- return we(() => {
2356
- let r = i.current;
2357
- if (!r) return;
2358
- let a = () => n(e, r.offsetHeight, t);
2359
- if (a(), typeof ResizeObserver > "u") return;
2360
- let o = new ResizeObserver(a);
2361
- return o.observe(r), () => o.disconnect();
2362
- }, [
2363
- e,
2364
- n,
2365
- t
2366
- ]), /* @__PURE__ */ R("div", {
2367
- ref: i,
2368
- style: {
2369
- position: "absolute",
2370
- top: t,
2371
- left: 0,
2372
- right: 0
2373
- },
2374
- children: r
2375
- });
2376
- }
2377
- function Cr(e) {
2378
- let t = Math.max(0, Math.floor(e / 1e3)), n = Math.floor(t / 60), r = t % 60;
2379
- return n <= 0 ? `${r}s` : `${n}m ${String(r).padStart(2, "0")}s`;
2380
- }
2381
- function wr(e) {
2382
- return e < 1e3 ? "刚刚" : e < 6e4 ? `${Math.floor(e / 1e3)} 秒前` : `${Math.floor(e / 6e4)} 分钟前`;
2383
- }
2384
- function Tr(e) {
2385
- 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));
2386
- }
2387
- function Er({ contextIndicator: e }) {
2388
- let t = e?.usedTokens, n = e?.contextWindowTokens, r = Tr(t), i = Tr(n);
2389
- if (!r) return null;
2390
- let a = [r, i].filter(Boolean).join("/");
2391
- return /* @__PURE__ */ z("span", {
2392
- className: "token-count-pulse hidden text-slate-400 dark:text-slate-500 sm:inline",
2393
- title: e?.label || `估算 token ${a}`,
2394
- children: ["估算 token ", a]
2395
- }, r);
2396
- }
2397
- function Dr({ activity: e, contextIndicator: t, onStopGeneration: n, onCancelRemote: r }) {
2398
- let [i, o] = K(() => Date.now());
2399
- W(() => {
2400
- let e = window.setInterval(() => o(Date.now()), 1e3);
2401
- return () => window.clearInterval(e);
2402
- }, []);
2403
- let s = e.status === "connecting" || e.status === "running" || e.status === "waiting", c = i - e.lastEventAt < 2e4;
2404
- return /* @__PURE__ */ z("div", {
2405
- 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",
2406
- children: [
2407
- e.status === "failed" ? /* @__PURE__ */ R(N, { className: "h-3 w-3 text-rose-500" }) : e.status === "completed" ? /* @__PURE__ */ R(a, { className: "h-3 w-3 text-emerald-500" }) : e.status === "stopped" ? /* @__PURE__ */ R(M, { className: "h-3 w-3 text-amber-500" }) : /* @__PURE__ */ R(k, { className: "h-3 w-3 animate-spin text-slate-400" }),
2408
- /* @__PURE__ */ R("span", {
2409
- className: "max-w-[16rem] truncate text-slate-600 dark:text-slate-300",
2410
- title: e.detail || e.phase,
2411
- children: e.phase
2412
- }),
2413
- /* @__PURE__ */ z("span", { children: [
2414
- e.source === "restore" ? "恢复" : "运行",
2415
- " ",
2416
- Cr(i - e.startedAt)
2417
- ] }),
2418
- s ? /* @__PURE__ */ R("span", {
2419
- className: J("inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full", c ? "bg-emerald-400" : "bg-slate-300 dark:bg-slate-600"),
2420
- title: c ? "连接存活" : "连接超时"
2421
- }) : null,
2422
- /* @__PURE__ */ z("span", {
2423
- className: "text-slate-400 dark:text-slate-500",
2424
- children: [e.eventCount, " ev"]
2425
- }),
2426
- /* @__PURE__ */ R("span", {
2427
- className: "hidden text-slate-400 dark:text-slate-500 sm:inline",
2428
- children: wr(i - e.lastEventAt)
2429
- }),
2430
- /* @__PURE__ */ R(Er, { contextIndicator: t }),
2431
- s && (n || r) ? /* @__PURE__ */ z("div", {
2432
- className: "flex flex-shrink-0 gap-1",
2433
- children: [n ? /* @__PURE__ */ z("button", {
2434
- type: "button",
2435
- onClick: n,
2436
- 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",
2437
- children: [/* @__PURE__ */ R(N, { className: "h-3 w-3" }), "停止"]
2438
- }) : null, r ? /* @__PURE__ */ z("button", {
2439
- type: "button",
2440
- "aria-label": "取消运行并保留恢复点",
2441
- title: "取消运行并保留最近 checkpoint",
2442
- onClick: r,
2443
- 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",
2444
- children: [/* @__PURE__ */ R(ve, { className: "h-3 w-3" }), "取消"]
2445
- }) : null]
2446
- }) : null
2447
- ]
2448
- });
2449
- }
2450
- function Or({ agentName: e }) {
2451
- return /* @__PURE__ */ z("div", {
2452
- className: "flex flex-col items-center justify-center min-h-[50vh] px-4",
2453
- children: [
2454
- /* @__PURE__ */ R("div", {
2455
- 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",
2456
- children: /* @__PURE__ */ R(i, { className: "h-8 w-8 text-white" })
2457
- }),
2458
- /* @__PURE__ */ R("h2", {
2459
- className: "text-xl font-semibold text-slate-900 dark:text-slate-50",
2460
- children: "有什么我可以帮您的吗?"
2461
- }),
2462
- /* @__PURE__ */ z("p", {
2463
- className: "mt-2 text-sm text-slate-500",
2464
- children: [
2465
- "我是 ",
2466
- e,
2467
- ",由 Ksyun AgentEngine 驱动"
2468
- ]
2469
- })
2470
- ]
2471
- });
2472
- }
2473
- function kr() {
2474
- return /* @__PURE__ */ z("div", {
2475
- className: "mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8",
2476
- "aria-label": "正在加载会话历史",
2477
- children: [
2478
- /* @__PURE__ */ R("div", { className: "h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800" }),
2479
- /* @__PURE__ */ R("div", { className: "h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" }),
2480
- /* @__PURE__ */ R("div", { className: "ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" }),
2481
- /* @__PURE__ */ R("div", { className: "h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900" })
2482
- ]
2483
- });
2484
- }
2485
- function Ar({ attachments: e, isMobile: t, onOpenAttachmentPreview: n }) {
2486
- return /* @__PURE__ */ R("div", {
2487
- className: "mb-3 flex flex-wrap gap-3",
2488
- children: e.map((e, r) => e.type.startsWith("image/") ? e.url ? /* @__PURE__ */ R("button", {
2489
- type: "button",
2490
- onClick: () => n(e),
2491
- className: J("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]"),
2492
- children: /* @__PURE__ */ R("img", {
2493
- src: e.url,
2494
- alt: e.name,
2495
- className: J("object-cover transition group-hover:scale-[1.02]", t ? "max-h-[16rem] w-full max-w-full" : "max-h-[200px] max-w-[200px]")
2496
- })
2497
- }, `${e.name}-${r}`) : /* @__PURE__ */ R("div", {
2498
- className: J("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]"),
2499
- children: e.name
2500
- }, `${e.name}-${r}`) : /* @__PURE__ */ z("div", {
2501
- className: J("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"),
2502
- children: [/* @__PURE__ */ R(ae, { className: "h-4 w-4 flex-shrink-0 text-blue-500" }), e.url ? /* @__PURE__ */ R("a", {
2503
- href: e.url,
2504
- target: "_blank",
2505
- rel: "noreferrer",
2506
- className: "truncate text-sm text-slate-700 hover:underline dark:text-slate-300",
2507
- title: e.name,
2508
- children: e.name
2509
- }) : /* @__PURE__ */ R("span", {
2510
- className: "truncate text-sm text-slate-700 dark:text-slate-300",
2511
- title: e.name,
2512
- children: e.name
2513
- })]
2514
- }, `${e.name}-${r}`))
2515
- });
2516
- }
2517
- function jr({ message: e }) {
2518
- return /* @__PURE__ */ R("div", {
2519
- className: "w-full px-0 py-2 sm:px-4",
2520
- children: /* @__PURE__ */ z("div", {
2521
- 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",
2522
- children: [
2523
- /* @__PURE__ */ z("div", {
2524
- className: "flex items-center gap-2 font-medium",
2525
- children: [e.status === "running" ? /* @__PURE__ */ R(k, { className: "h-4 w-4 animate-spin text-amber-600 dark:text-amber-300" }) : e.status === "failed" ? /* @__PURE__ */ R(N, { className: "h-4 w-4 text-rose-600 dark:text-rose-400" }) : /* @__PURE__ */ R(a, { className: "h-4 w-4 text-emerald-600 dark:text-emerald-400" }), /* @__PURE__ */ R("span", { children: e.content })]
2526
- }),
2527
- e.compactedUntilSeqId ? /* @__PURE__ */ z("div", {
2528
- className: "mt-1 text-xs text-amber-700/80 dark:text-amber-200/80",
2529
- children: ["已折叠到会话事件 #", e.compactedUntilSeqId]
2530
- }) : null,
2531
- e.summary ? /* @__PURE__ */ z("details", {
2532
- 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",
2533
- children: [/* @__PURE__ */ R("summary", {
2534
- className: "cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200",
2535
- children: "查看压缩摘要"
2536
- }), /* @__PURE__ */ R("div", {
2537
- className: "mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200",
2538
- children: /* @__PURE__ */ R(X, { content: e.summary })
2539
- })]
2540
- }) : null
2541
- ]
2542
- })
2543
- });
2544
- }
2545
- function Mr({ label: e, tone: n, value: r }) {
2546
- let [i, o] = K("idle"), s = t(r);
2547
- W(() => {
2548
- if (i === "idle") return;
2549
- let e = window.setTimeout(() => o("idle"), 1600);
2550
- return () => window.clearTimeout(e);
2551
- }, [i]);
2552
- let c = async () => {
2553
- o(await mr(s) ? "copied" : "failed");
2554
- };
2555
- return /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ z("div", {
2556
- className: "mb-1 flex items-center justify-between gap-2",
2557
- children: [/* @__PURE__ */ R("div", {
2558
- className: J("text-xs font-semibold uppercase", n === "input" ? "text-blue-500" : n === "error" ? "text-rose-500" : "text-emerald-500"),
2559
- children: e
2560
- }), /* @__PURE__ */ z("button", {
2561
- type: "button",
2562
- onClick: () => {
2563
- c();
2564
- },
2565
- 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",
2566
- children: [i === "copied" ? /* @__PURE__ */ R(a, { className: "h-3.5 w-3.5 text-emerald-500" }) : /* @__PURE__ */ R(u, { className: "h-3.5 w-3.5" }), i === "copied" ? "已复制" : i === "failed" ? "复制失败" : "复制"]
2567
- })]
2568
- }), /* @__PURE__ */ R("div", {
2569
- 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]",
2570
- children: s
2571
- })] });
2572
- }
2573
- function Nr({ isLastMessage: e, isStreaming: t, message: n, onDeleteFeedback: r, onSubmitFeedback: i, alwaysVisible: a = !1 }) {
2574
- let [o, s] = K(!1), [c, l] = K(n.feedback?.comment || ""), d = sr(n, t, e), f = !!n.feedback?.pending, p = n.feedback?.rating, m = async () => {
2575
- let e = n.content || "";
2576
- e && mr(e);
2577
- };
2578
- return d ? /* @__PURE__ */ z("div", {
2579
- className: J("mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100", a ? "opacity-100" : "opacity-0 group-hover:opacity-100"),
2580
- children: [
2581
- /* @__PURE__ */ z("div", {
2582
- className: "flex flex-wrap items-center gap-1.5 text-xs text-text-muted",
2583
- children: [
2584
- /* @__PURE__ */ R("button", {
2585
- type: "button",
2586
- onClick: () => {
2587
- m();
2588
- },
2589
- 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",
2590
- title: "复制",
2591
- children: /* @__PURE__ */ R(u, { className: "h-3.5 w-3.5" })
2592
- }),
2593
- /* @__PURE__ */ R("span", {
2594
- className: "text-text-muted/60",
2595
- children: "·"
2596
- }),
2597
- /* @__PURE__ */ R("span", {
2598
- className: "font-medium",
2599
- children: "本次回复有帮助吗?"
2600
- }),
2601
- /* @__PURE__ */ z("button", {
2602
- type: "button",
2603
- disabled: f,
2604
- onClick: () => i({
2605
- message: n,
2606
- rating: "up",
2607
- comment: ""
2608
- }),
2609
- className: J("inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60", p === "up" ? "border-primary/30 bg-primary/10 text-primary" : "border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary"),
2610
- children: [/* @__PURE__ */ R(F, { className: "h-3.5 w-3.5" }), "有帮助"]
2611
- }),
2612
- /* @__PURE__ */ z("button", {
2613
- type: "button",
2614
- disabled: f,
2615
- onClick: () => {
2616
- l(n.feedback?.comment || ""), s((e) => !e);
2617
- },
2618
- className: J("inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60", p === "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"),
2619
- children: [/* @__PURE__ */ R(fe, { className: "h-3.5 w-3.5" }), "需改进"]
2620
- }),
2621
- n.feedback ? /* @__PURE__ */ z("button", {
2622
- type: "button",
2623
- disabled: f,
2624
- onClick: () => r(n),
2625
- 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",
2626
- children: [/* @__PURE__ */ R(pe, { className: "h-3.5 w-3.5" }), "删除反馈"]
2627
- }) : null,
2628
- f ? /* @__PURE__ */ R("span", {
2629
- className: "text-slate-400",
2630
- children: "提交中…"
2631
- }) : null
2632
- ]
2633
- }),
2634
- o ? /* @__PURE__ */ z("div", {
2635
- 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",
2636
- children: [/* @__PURE__ */ R("textarea", {
2637
- value: c,
2638
- onChange: (e) => l(e.target.value),
2639
- placeholder: "可以补充哪里不准确、缺失或不符合预期。",
2640
- 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"
2641
- }), /* @__PURE__ */ z("div", {
2642
- className: "mt-2 flex flex-wrap justify-end gap-2",
2643
- children: [/* @__PURE__ */ R("button", {
2644
- type: "button",
2645
- onClick: () => s(!1),
2646
- 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",
2647
- children: "取消"
2648
- }), /* @__PURE__ */ R("button", {
2649
- type: "button",
2650
- disabled: f,
2651
- onClick: () => {
2652
- i({
2653
- message: n,
2654
- rating: "down",
2655
- comment: c
2656
- }), s(!1);
2657
- },
2658
- 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",
2659
- children: "提交点踩"
2660
- })]
2661
- })]
2662
- }) : p === "down" && n.feedback?.comment ? /* @__PURE__ */ z("div", {
2663
- 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",
2664
- children: ["反馈:", n.feedback.comment]
2665
- }) : null,
2666
- n.feedback?.error ? /* @__PURE__ */ R("div", {
2667
- className: "text-xs text-rose-600 dark:text-rose-300",
2668
- children: n.feedback.error
2669
- }) : null
2670
- ]
2671
- }) : null;
2672
- }
2673
- function Pr({ agentName: e, isMobile: t, isStreaming: n, isLastMessage: r, message: s, onDeleteFeedback: c, onOpenAttachmentPreview: l, onRespondToApproval: u, onRespondToAguiApproval: d, onSubmitFeedback: f, onSubmitAguiAction: p, interactionRecords: m }) {
2674
- if (s.role === "user") return /* @__PURE__ */ R("div", {
2675
- className: "mb-3 flex justify-end",
2676
- children: /* @__PURE__ */ z("div", {
2677
- className: "max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground",
2678
- children: [s.attachments?.length ? /* @__PURE__ */ R(Ar, {
2679
- attachments: s.attachments,
2680
- isMobile: t,
2681
- onOpenAttachmentPreview: l
2682
- }) : null, s.content]
2683
- })
2684
- });
2685
- if (s.role === "a2ui" && s.aguiActivity) return /* @__PURE__ */ R(jn, {
2686
- surfaceId: s.aguiActivity.surfaceId,
2687
- messages: s.aguiActivity.messages,
2688
- onAction: p
2689
- });
2690
- let h = n && r && !s.content;
2691
- return /* @__PURE__ */ z("div", {
2692
- className: "group mx-auto mb-3 w-full max-w-3xl px-6",
2693
- children: [
2694
- /* @__PURE__ */ z("div", {
2695
- className: "mb-1.5 flex items-center gap-2 text-xs text-text-muted",
2696
- children: [/* @__PURE__ */ R(i, { className: "w-3.5 h-3.5" }), /* @__PURE__ */ R("span", { children: e })]
2697
- }),
2698
- s.attachments?.length ? /* @__PURE__ */ R(Ar, {
2699
- attachments: s.attachments,
2700
- isMobile: t,
2701
- onOpenAttachmentPreview: l
2702
- }) : null,
2703
- s.blocks?.length ? /* @__PURE__ */ R(Zn, {
2704
- message: s,
2705
- isStreaming: n,
2706
- onRespondToApproval: u,
2707
- interactionRecords: m,
2708
- onRespondToAguiApproval: d
2709
- }) : /* @__PURE__ */ z(L, { children: [
2710
- s.reasoning ? /* @__PURE__ */ z("details", {
2711
- 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",
2712
- children: [/* @__PURE__ */ z("summary", {
2713
- className: "flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden",
2714
- children: [/* @__PURE__ */ z("div", {
2715
- className: "flex min-w-0 items-center gap-2",
2716
- children: [
2717
- h ? null : /* @__PURE__ */ R(a, { className: "h-4 w-4 text-slate-400" }),
2718
- /* @__PURE__ */ R("span", {
2719
- className: J("truncate", h && "waiting-thinking-text"),
2720
- "data-testid": h ? "legacy-thinking-indicator" : void 0,
2721
- role: h ? "status" : void 0,
2722
- children: h ? "正在思考…" : "思考过程"
2723
- }),
2724
- h ? null : /* @__PURE__ */ R("span", {
2725
- 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",
2726
- children: "已完成"
2727
- })
2728
- ]
2729
- }), /* @__PURE__ */ R(o, { className: "h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180" })]
2730
- }), /* @__PURE__ */ R("div", {
2731
- className: "border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20",
2732
- children: /* @__PURE__ */ R("div", {
2733
- 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",
2734
- children: /* @__PURE__ */ R(X, { content: s.reasoning })
2735
- })
2736
- })]
2737
- }) : null,
2738
- s.tools ? Object.values(s.tools).map((e, t) => /* @__PURE__ */ z("details", {
2739
- open: e.approvalStatus === "pending" || e.status === "paused" ? !0 : void 0,
2740
- className: J("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"),
2741
- children: [/* @__PURE__ */ R("summary", {
2742
- className: "flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium",
2743
- children: /* @__PURE__ */ z("div", {
2744
- className: "flex items-center gap-2",
2745
- children: [e.status === "running" ? /* @__PURE__ */ R(k, { className: "h-4 w-4 animate-spin text-slate-500" }) : e.status === "paused" ? /* @__PURE__ */ R(M, { className: "h-4 w-4 text-amber-500" }) : e.status === "error" ? /* @__PURE__ */ R(ve, { className: "h-4 w-4 text-rose-500" }) : /* @__PURE__ */ R(a, { className: "h-4 w-4 text-slate-400" }), /* @__PURE__ */ z("span", { children: [e.approvalStatus === "pending" ? "等待审批:" : e.approvalStatus === "approved" ? "已批准:" : e.approvalStatus === "rejected" ? "已拒绝:" : e.status === "error" ? "工具调用失败:" : "工具调用:", e.name] })]
2746
- })
2747
- }), /* @__PURE__ */ z("div", {
2748
- className: J("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"),
2749
- children: [
2750
- e.approvalRequestId ? /* @__PURE__ */ z("div", {
2751
- className: "font-sans text-sm text-slate-700 dark:text-slate-200",
2752
- children: [
2753
- /* @__PURE__ */ R("div", {
2754
- className: "font-medium",
2755
- children: e.approvalStatus === "approved" ? "已批准该工具调用。" : e.approvalStatus === "rejected" ? "已拒绝该工具调用。" : e.approvalMessage || "该工具调用需要人工确认后继续。"
2756
- }),
2757
- e.approvalLevel ? /* @__PURE__ */ z("div", {
2758
- className: J("mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium", xr(e.approvalLevel)),
2759
- children: ["审批级别:", br(e.approvalLevel)]
2760
- }) : null,
2761
- e.serverLabel ? /* @__PURE__ */ z("div", {
2762
- className: "mt-1 text-xs text-amber-700/80 dark:text-amber-200/80",
2763
- children: ["MCP Server: ", e.serverLabel]
2764
- }) : null,
2765
- e.approvalStatus === "pending" ? /* @__PURE__ */ z("div", {
2766
- className: "mt-3 flex flex-wrap gap-2",
2767
- children: [/* @__PURE__ */ z("button", {
2768
- type: "button",
2769
- disabled: n || e.approvalStatus !== "pending",
2770
- onClick: () => e.approvalProtocol === "ag-ui" ? d?.({
2771
- interruptId: e.approvalRequestId || "",
2772
- approve: !0
2773
- }) : u({
2774
- approvalRequestId: e.approvalRequestId || "",
2775
- approve: !0,
2776
- previousResponseId: e.previousResponseId
2777
- }),
2778
- 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",
2779
- children: [/* @__PURE__ */ R(a, { className: "h-3.5 w-3.5" }), "批准并继续"]
2780
- }), /* @__PURE__ */ z("button", {
2781
- type: "button",
2782
- disabled: n || e.approvalStatus !== "pending",
2783
- onClick: () => e.approvalProtocol === "ag-ui" ? d?.({
2784
- interruptId: e.approvalRequestId || "",
2785
- approve: !1
2786
- }) : u({
2787
- approvalRequestId: e.approvalRequestId || "",
2788
- approve: !1,
2789
- previousResponseId: e.previousResponseId
2790
- }),
2791
- 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",
2792
- children: [/* @__PURE__ */ R(ve, { className: "h-3.5 w-3.5" }), "拒绝"]
2793
- })]
2794
- }) : /* @__PURE__ */ z("div", {
2795
- className: "mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400",
2796
- children: [e.approvalStatus === "approved" ? /* @__PURE__ */ R(a, { className: "h-3.5 w-3.5 text-emerald-500" }) : /* @__PURE__ */ R(ve, { className: "h-3.5 w-3.5 text-rose-500" }), e.approvalStatus === "approved" ? "已批准" : "已拒绝"]
2797
- })
2798
- ]
2799
- }) : null,
2800
- e.args ? /* @__PURE__ */ R(Mr, {
2801
- label: "入参 (Args)",
2802
- tone: "input",
2803
- value: e.args
2804
- }) : null,
2805
- e.output ? /* @__PURE__ */ R(Mr, {
2806
- label: "输出 (Output)",
2807
- tone: e.status === "error" ? "error" : "output",
2808
- value: e.output
2809
- }) : null
2810
- ]
2811
- })]
2812
- }, `${e.name}-${t}`)) : null,
2813
- s.tools ? Object.values(s.tools).filter((e) => m?.some((t) => t.interactionId === e.approvalRequestId)).map((e) => /* @__PURE__ */ R(Vn, { interaction: m.find((t) => t.interactionId === e.approvalRequestId) }, `anchor-${e.approvalRequestId}`)) : null,
2814
- /* @__PURE__ */ R("div", {
2815
- className: "w-full break-words",
2816
- children: s.content ? /* @__PURE__ */ R(X, { content: s.content }) : n && r && !s.reasoning && !s.tools ? /* @__PURE__ */ R("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
2817
- })
2818
- ] }),
2819
- s.aguiActivities?.map((e) => /* @__PURE__ */ R(jn, {
2820
- surfaceId: e.surfaceId,
2821
- messages: e.messages,
2822
- onAction: p
2823
- }, e.surfaceId)),
2824
- /* @__PURE__ */ R(Nr, {
2825
- isLastMessage: r,
2826
- isStreaming: n,
2827
- message: s,
2828
- onDeleteFeedback: c,
2829
- onSubmitFeedback: f
2830
- })
2831
- ]
2832
- });
2833
- }
2834
- function Fr({ agentName: e, isMobile: t, 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: _, interactionRecords: v, scrollRef: y }) {
2835
- let [b, x] = K(0), [S, C] = K(0), [w, T] = K(/* @__PURE__ */ new Map()), E = G(w);
2836
- we(() => {
2837
- let e = y.current;
2838
- if (!e) return;
2839
- let t = () => {
2840
- x(e.scrollTop), C(e.clientHeight);
2841
- };
2842
- if (t(), typeof ResizeObserver > "u") return;
2843
- let n = new ResizeObserver(() => t());
2844
- return n.observe(e), () => n.disconnect();
2845
- }, [y]);
2846
- let ee = Te(() => _r({
2847
- items: o,
2848
- scrollTop: b,
2849
- viewportHeight: S,
2850
- overscan: yr,
2851
- defaultItemHeight: vr,
2852
- measuredHeights: w,
2853
- getItemKey: (e, t) => e?.id || String(t)
2854
- }), [
2855
- w,
2856
- o,
2857
- b,
2858
- S
2859
- ]), te = ee.visibleItems, ne = U((e, t, n) => {
2860
- if (!e || !Number.isFinite(t) || t <= 0) return;
2861
- let r = E.current, i = r.get(e) ?? vr;
2862
- if (i === t) return;
2863
- let a = new Map(r);
2864
- a.set(e, t), E.current = a, T(a);
2865
- let o = y.current;
2866
- o && n < o.scrollTop && (o.scrollTop += t - i, x(o.scrollTop));
2867
- }, [y]);
2868
- return /* @__PURE__ */ z("div", {
2869
- ref: y,
2870
- onScroll: (e) => x(e.currentTarget.scrollTop),
2871
- className: J("custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth", t ? "px-3 py-3" : "px-4 py-5"),
2872
- children: [
2873
- /* @__PURE__ */ R("div", {
2874
- className: J("mx-auto flex w-full max-w-[64rem] flex-col", i ? "pb-10 sm:pb-10" : "pb-6 sm:pb-8"),
2875
- children: o.length === 0 && s ? /* @__PURE__ */ R(kr, {}) : o.length === 0 ? /* @__PURE__ */ R(Or, { agentName: e }) : /* @__PURE__ */ R("div", {
2876
- style: { height: ee.totalHeight },
2877
- className: "relative",
2878
- children: te.map((n) => /* @__PURE__ */ R(Sr, {
2879
- messageId: n.item.id || String(n.index),
2880
- top: n.top,
2881
- onMeasure: ne,
2882
- children: n.item.role === "system" ? /* @__PURE__ */ R(jr, { message: n.item }) : /* @__PURE__ */ R(Pr, {
2883
- agentName: e,
2884
- isMobile: t,
2885
- isStreaming: r,
2886
- isLastMessage: n.index === o.length - 1,
2887
- message: n.item,
2888
- onDeleteFeedback: c,
2889
- onOpenAttachmentPreview: l,
2890
- onRespondToApproval: u,
2891
- interactionRecords: v,
2892
- onRespondToAguiApproval: d,
2893
- onSubmitFeedback: f,
2894
- onSubmitAguiAction: p
2895
- })
2896
- }, n.item.id || n.index))
2897
- })
2898
- }),
2899
- /* @__PURE__ */ R(rr, {}),
2900
- b > 320 ? /* @__PURE__ */ R("button", {
2901
- type: "button",
2902
- onClick: () => {
2903
- let e = y.current;
2904
- e && e.scrollTo({
2905
- top: e.scrollHeight,
2906
- behavior: "smooth"
2907
- });
2908
- },
2909
- 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",
2910
- title: "回到底部",
2911
- children: /* @__PURE__ */ R(n, { className: "h-4 w-4" })
2912
- }) : null,
2913
- i ? /* @__PURE__ */ R("div", {
2914
- className: "sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end",
2915
- children: /* @__PURE__ */ R(Dr, {
2916
- activity: i,
2917
- contextIndicator: a,
2918
- onStopGeneration: m,
2919
- onCancelRemote: h
2920
- })
2921
- }) : null
2922
- ]
2923
- });
2924
- }
2925
- //#endregion
2926
- //#region src/utils/session-list.js
2927
- var Ir = new Set([
2928
- "in_progress",
2929
- "running",
2930
- "resuming",
2931
- "starting",
2932
- "streaming",
2933
- "queued",
2934
- "pending",
2935
- "accepted"
2936
- ]), Lr = new Set([
2937
- "failed",
2938
- "error",
2939
- "resume_failed",
2940
- "interrupted",
2941
- "cancelled",
2942
- "canceled",
2943
- "aborted",
2944
- "expired"
2945
- ]), Rr = 300 * 1e3;
2946
- function zr(e) {
2947
- let t = e?.UpdatedAt ?? e?.updated_at;
2948
- if (typeof t == "string") {
2949
- let e = Date.parse(t);
2950
- return Number.isNaN(e) ? 0 : e;
2951
- }
2952
- return typeof t == "number" && Number.isFinite(t) ? t > 1e11 ? t : t * 1e3 : 0;
2953
- }
2954
- function Br(e) {
2955
- return String(e || "").trim().toLowerCase();
2956
- }
2957
- function Vr(e) {
2958
- if (!e) return "";
2959
- let t = typeof e == "number" ? new Date(e > 1e11 ? e : e * 1e3) : new Date(e);
2960
- return Number.isNaN(t.getTime()) ? "" : t.toLocaleString("zh-CN", {
2961
- timeZone: "Asia/Shanghai",
2962
- month: "short",
2963
- day: "numeric",
2964
- hour: "2-digit",
2965
- minute: "2-digit",
2966
- hour12: !1
2967
- });
2968
- }
2969
- function Hr(e) {
2970
- return [
2971
- e?.Title,
2972
- e?.Summary,
2973
- e?.FirstPrompt,
2974
- e?.LastPrompt,
2975
- e?.SessionId,
2976
- e?.Model?.display_name,
2977
- e?.Model?.id
2978
- ].map(Br).join(" ");
2979
- }
2980
- function Ur(e, t = {}) {
2981
- if (!Ir.has(Br(e?.ActiveRunStatus))) return !1;
2982
- let n = zr(e);
2983
- if (!n) return !0;
2984
- let r = Number.isFinite(Number(t.now)) ? Number(t.now) : Date.now(), i = Number.isFinite(Number(t.activeStaleAfterMs)) ? Number(t.activeStaleAfterMs) : Rr;
2985
- return r - n <= i;
2986
- }
2987
- function Wr(e = [], t = "", n = {}) {
2988
- let r = Br(t), i = new Set(Array.isArray(n.pinnedSessionIds) ? n.pinnedSessionIds : []);
2989
- return (Array.isArray(e) ? e : []).filter((e) => e?.SessionId).filter((e) => !r || Hr(e).includes(r)).slice().sort((e, t) => {
2990
- let r = +!!i.has(e.SessionId), a = +!!i.has(t.SessionId);
2991
- if (r !== a) return a - r;
2992
- let o = +!!Ur(e, n), s = +!!Ur(t, n);
2993
- return o === s ? zr(t) - zr(e) : s - o;
2994
- });
2995
- }
2996
- function Gr(e, t = {}) {
2997
- let n = Ur(e, t), r = Lr.has(Br(e?.ActiveRunStatus));
2998
- return {
2999
- running: n,
3000
- failed: r,
3001
- label: n || r ? "" : Vr(e?.UpdatedAt ?? e?.updated_at)
3002
- };
3003
- }
3004
- //#endregion
3005
- //#region src/components/chat/ChatSidebar.tsx
3006
- function Kr({ 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 }) {
3007
- let [f, p] = K(""), m = Te(() => Wr(e, f, { pinnedSessionIds: c }), [
3008
- e,
3009
- c,
3010
- f
3011
- ]), h = Te(() => new Set(c), [c]);
3012
- return /* @__PURE__ */ z("div", {
3013
- className: J("flex h-full min-h-0 flex-col bg-sidebar", d),
3014
- children: [
3015
- /* @__PURE__ */ z("div", {
3016
- className: "flex flex-shrink-0 flex-col gap-2 border-b border-black/[0.06] px-3 py-3 dark:border-white/[0.08]",
3017
- children: [/* @__PURE__ */ z("button", {
3018
- type: "button",
3019
- onClick: n,
3020
- 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",
3021
- children: [/* @__PURE__ */ z("span", {
3022
- className: "flex items-center gap-1.5",
3023
- children: [/* @__PURE__ */ R(T, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: "新对话" })]
3024
- }), /* @__PURE__ */ R("span", {
3025
- className: "rounded border border-black/[0.08] px-1.5 py-0.5 text-[11px] text-sidebar-text-muted dark:border-white/[0.1]",
3026
- children: "⌘ N"
3027
- })]
3028
- }), /* @__PURE__ */ z("label", {
3029
- 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]",
3030
- children: [/* @__PURE__ */ R(A, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ R("input", {
3031
- value: f,
3032
- onChange: (e) => p(e.target.value),
3033
- className: "min-w-0 flex-1 bg-transparent text-sm text-sidebar-text outline-none placeholder:text-sidebar-text-muted",
3034
- placeholder: "搜索会话、模型或摘要"
3035
- })]
3036
- })]
3037
- }),
3038
- /* @__PURE__ */ z("div", {
3039
- className: "min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-2 custom-scrollbar",
3040
- onScroll: (e) => {
3041
- if (!o || u || !l || f.trim()) return;
3042
- let t = e.currentTarget;
3043
- t.scrollHeight - t.scrollTop - t.clientHeight < 200 && o();
3044
- },
3045
- children: [/* @__PURE__ */ z("div", {
3046
- className: "px-2.5 py-2 text-xs font-medium text-sidebar-text-muted opacity-75",
3047
- children: ["历史记录", f.trim() ? ` · ${m.length}` : ""]
3048
- }), /* @__PURE__ */ z("div", {
3049
- className: "flex flex-col gap-0.5",
3050
- children: [m.length > 0 ? m.map((e) => {
3051
- let n = Gr(e), o = h.has(e.SessionId), c = t === e.SessionId;
3052
- return /* @__PURE__ */ z("div", {
3053
- className: J("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/[0.035] text-sidebar-text" : "cursor-pointer text-sidebar-text-secondary hover:bg-sidebar-hover hover:text-sidebar-text"),
3054
- children: [/* @__PURE__ */ z("button", {
3055
- type: "button",
3056
- "aria-current": c ? "page" : void 0,
3057
- className: "flex min-w-0 flex-1 items-center gap-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-primary/60",
3058
- onClick: () => r(e.SessionId),
3059
- children: [/* @__PURE__ */ R("span", {
3060
- className: "min-w-0 flex-1 truncate text-[13px]",
3061
- children: s(e)
3062
- }), n.running ? /* @__PURE__ */ R("span", {
3063
- "aria-label": "运行中",
3064
- className: "h-1.5 w-1.5 flex-shrink-0 animate-spin rounded-full border border-primary border-t-transparent"
3065
- }) : n.failed ? /* @__PURE__ */ R("span", {
3066
- "aria-label": "运行失败",
3067
- title: "运行失败",
3068
- className: "h-1.5 w-1.5 flex-shrink-0 rounded-full bg-rose-500/75"
3069
- }) : n.label ? /* @__PURE__ */ R("span", {
3070
- className: "flex-shrink-0 text-[11px] leading-none text-sidebar-text-muted group-hover:hidden",
3071
- children: n.label
3072
- }) : null]
3073
- }), /* @__PURE__ */ z("div", {
3074
- className: "absolute right-1 top-1/2 flex -translate-y-1/2 items-center justify-end gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
3075
- children: [/* @__PURE__ */ R("button", {
3076
- type: "button",
3077
- onClick: (t) => a(e.SessionId, t),
3078
- className: J("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"),
3079
- title: o ? "取消置顶" : "置顶会话",
3080
- "aria-label": o ? "取消置顶会话" : "置顶会话",
3081
- children: R(o ? O : D, { className: "h-3.5 w-3.5" })
3082
- }), /* @__PURE__ */ R("button", {
3083
- type: "button",
3084
- onClick: (t) => i(e.SessionId, t),
3085
- className: "flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-rose-500",
3086
- title: "删除会话",
3087
- children: /* @__PURE__ */ R(pe, { className: "h-3.5 w-3.5" })
3088
- })]
3089
- })]
3090
- }, e.SessionId);
3091
- }) : /* @__PURE__ */ R("div", {
3092
- 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]",
3093
- children: "没有匹配的会话"
3094
- }), u ? /* @__PURE__ */ z("div", {
3095
- className: "flex items-center justify-center gap-2 px-3 py-3 text-xs text-sidebar-text-muted",
3096
- children: [/* @__PURE__ */ R(C, { className: "h-3.5 w-3.5 animate-spin" }), /* @__PURE__ */ R("span", { children: "加载中" })]
3097
- }) : null]
3098
- })]
3099
- }),
3100
- /* @__PURE__ */ z("div", {
3101
- className: "border-t border-black/[0.06] px-4 py-3 text-center dark:border-white/[0.08]",
3102
- children: [
3103
- /* @__PURE__ */ R("div", {
3104
- className: "text-[10px] font-medium tracking-[0.14em] text-sidebar-text-muted",
3105
- children: "POWERED BY"
3106
- }),
3107
- /* @__PURE__ */ R("div", {
3108
- 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",
3109
- children: "Ksyun AgentEngine"
3110
- }),
3111
- /* @__PURE__ */ R("div", {
3112
- className: "mx-auto mt-2 max-w-[13rem] text-[10px] leading-4 text-sidebar-text-muted",
3113
- children: "Agent 可能产生不准确的信息,请独立验证。"
3114
- })
3115
- ]
3116
- })
3117
- ]
3118
- });
3119
- }
3120
- //#endregion
3121
- //#region src/components/native/NativeRuntimeLauncher.tsx
3122
- var qr = Se(() => import("./NativeTerminalPanel-Dix1UX_z.js").then((e) => e.n).then((e) => ({ default: e.NativeTerminalPanel })));
3123
- function Jr({ productLabel: e = "原生运行时", nativeManagementLink: t, nativeTerminal: n, workspaceEnabled: r, onOpenWorkspace: i }) {
3124
- let a = !!n?.Enabled, [o, s] = K(!1);
3125
- return /* @__PURE__ */ z("section", {
3126
- 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",
3127
- children: [/* @__PURE__ */ R("div", {
3128
- className: "mx-auto flex w-full max-w-5xl flex-col justify-center",
3129
- children: /* @__PURE__ */ z("div", {
3130
- 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",
3131
- children: [/* @__PURE__ */ z("div", {
3132
- 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",
3133
- children: [
3134
- /* @__PURE__ */ z("div", {
3135
- 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",
3136
- children: [
3137
- /* @__PURE__ */ R(M, { className: "h-3.5 w-3.5" }),
3138
- e,
3139
- " native runtime"
3140
- ]
3141
- }),
3142
- /* @__PURE__ */ R("h1", {
3143
- className: "mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl",
3144
- children: "对话请使用原生管理台"
3145
- }),
3146
- /* @__PURE__ */ R("p", {
3147
- className: "mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base",
3148
- children: "当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。"
3149
- })
3150
- ]
3151
- }), /* @__PURE__ */ z("div", {
3152
- className: "grid gap-4 p-6 md:grid-cols-3 sm:p-8",
3153
- children: [
3154
- /* @__PURE__ */ z("div", {
3155
- className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
3156
- children: [
3157
- /* @__PURE__ */ R("div", {
3158
- 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",
3159
- children: /* @__PURE__ */ R(E, { className: "h-5 w-5" })
3160
- }),
3161
- /* @__PURE__ */ R("h2", {
3162
- className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
3163
- children: "原生管理台"
3164
- }),
3165
- /* @__PURE__ */ R("p", {
3166
- className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
3167
- children: "使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。"
3168
- }),
3169
- t ? /* @__PURE__ */ z("a", {
3170
- href: t.href,
3171
- target: "_blank",
3172
- rel: "noreferrer",
3173
- title: t.title,
3174
- 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",
3175
- children: [
3176
- /* @__PURE__ */ R(f, { className: "h-4 w-4" }),
3177
- "打开",
3178
- t.label
3179
- ]
3180
- }) : /* @__PURE__ */ R("div", {
3181
- 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",
3182
- children: "当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。"
3183
- })
3184
- ]
3185
- }),
3186
- /* @__PURE__ */ z("div", {
3187
- className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
3188
- children: [
3189
- /* @__PURE__ */ R("div", {
3190
- 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",
3191
- children: /* @__PURE__ */ R(_, { className: "h-5 w-5" })
3192
- }),
3193
- /* @__PURE__ */ R("h2", {
3194
- className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
3195
- children: "Workspace 文件管理"
3196
- }),
3197
- /* @__PURE__ */ R("p", {
3198
- className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
3199
- children: "文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。"
3200
- }),
3201
- r ? /* @__PURE__ */ z("button", {
3202
- type: "button",
3203
- onClick: i,
3204
- 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",
3205
- children: [/* @__PURE__ */ R(_, { className: "h-4 w-4" }), "打开 Workspace"]
3206
- }) : /* @__PURE__ */ R("div", {
3207
- 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",
3208
- children: "当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。"
3209
- })
3210
- ]
3211
- }),
3212
- /* @__PURE__ */ z("div", {
3213
- className: "rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
3214
- children: [
3215
- /* @__PURE__ */ R("div", {
3216
- 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",
3217
- children: /* @__PURE__ */ R(P, { className: "h-5 w-5" })
3218
- }),
3219
- /* @__PURE__ */ R("h2", {
3220
- className: "mt-4 text-base font-semibold text-slate-950 dark:text-slate-50",
3221
- children: "原生 TUI"
3222
- }),
3223
- /* @__PURE__ */ R("p", {
3224
- className: "mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300",
3225
- children: "如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。"
3226
- }),
3227
- a ? /* @__PURE__ */ z("button", {
3228
- type: "button",
3229
- onClick: () => s(!0),
3230
- 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",
3231
- children: [/* @__PURE__ */ R(P, { className: "h-4 w-4" }), "打开 TUI"]
3232
- }) : /* @__PURE__ */ R("div", {
3233
- 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",
3234
- children: "当前运行时未声明可用的浏览器 TUI 能力。"
3235
- })
3236
- ]
3237
- })
3238
- ]
3239
- })]
3240
- })
3241
- }), n && o ? /* @__PURE__ */ R(H, {
3242
- fallback: null,
3243
- children: /* @__PURE__ */ R(qr, {
3244
- capability: n,
3245
- open: o,
3246
- onClose: () => s(!1)
3247
- })
3248
- }) : null]
3249
- });
3250
- }
3251
- //#endregion
3252
- //#region src/stores/ui.ts
3253
- function Yr(e, t) {
3254
- return typeof t == "function" ? t(e) : t;
3255
- }
3256
- var Xr = I()((e) => ({
3257
- sidebarOpen: !0,
3258
- mobileSidebarOpen: !1,
3259
- mobileActionsOpen: !1,
3260
- workspacePanelOpen: !1,
3261
- workspacePanelWidth: 820,
3262
- workspacePanelFullscreen: !1,
3263
- input: "",
3264
- attachments: [],
3265
- previewAttachment: null,
3266
- previewImageSize: null,
3267
- queuedDrafts: [],
3268
- toasts: [],
3269
- toggleSidebar: () => e((e) => ({ sidebarOpen: !e.sidebarOpen })),
3270
- setSidebarOpen: (t) => e({ sidebarOpen: t }),
3271
- toggleMobileSidebar: () => e((e) => ({ mobileSidebarOpen: !e.mobileSidebarOpen })),
3272
- setMobileSidebarOpen: (t) => e({ mobileSidebarOpen: t }),
3273
- toggleMobileActions: () => e((e) => ({ mobileActionsOpen: !e.mobileActionsOpen })),
3274
- setMobileActionsOpen: (t) => e({ mobileActionsOpen: t }),
3275
- setWorkspacePanelOpen: (t) => e({ workspacePanelOpen: t }),
3276
- setWorkspacePanelWidth: (t) => e({ workspacePanelWidth: t }),
3277
- setWorkspacePanelFullscreen: (t) => e({ workspacePanelFullscreen: t }),
3278
- setInput: (t) => e({ input: t }),
3279
- setAttachments: (t) => e((e) => ({ attachments: Yr(e.attachments, t) })),
3280
- setPreviewAttachment: (t) => e({ previewAttachment: t }),
3281
- setPreviewImageSize: (t) => e({ previewImageSize: t }),
3282
- setQueuedDrafts: (t) => e((e) => ({ queuedDrafts: Yr(e.queuedDrafts, t) })),
3283
- pushToast: (t, n = "info") => e((e) => ({ toasts: [...e.toasts, {
3284
- id: String(Date.now() + Math.random()),
3285
- message: t,
3286
- variant: n,
3287
- createdAt: Date.now()
3288
- }] })),
3289
- dismissToast: (t) => e((e) => ({ toasts: e.toasts.filter((e) => e.id !== t) }))
3290
- }));
3291
- //#endregion
3292
- //#region src/components/workspace/FileEditor.tsx
3293
- function Zr(e) {
3294
- let t = String(e || "").split("/").pop() || "", n = t.lastIndexOf(".");
3295
- return n >= 0 ? t.slice(n) : "";
3296
- }
3297
- function Qr(e) {
3298
- return Ze.matchFilename(dt, `file${e}`);
3299
- }
3300
- function Q({ content: e, path: t, readOnly: n = !1, onSave: r, onDirtyChange: i, onContentChange: a, getContentRef: o }) {
3301
- let s = G(null), c = G(null), l = G(new Ge()), u = G(new Ge()), d = G(new Ge()), f = G(!1), p = G(r), m = G(i), h = G(a);
3302
- W(() => {
3303
- p.current = r, m.current = i, h.current = a;
3304
- }, [
3305
- r,
3306
- i,
3307
- a
3308
- ]);
3309
- let g = U((e) => {
3310
- f.current !== e && (f.current = e, m.current?.(e));
3311
- }, []);
3312
- return W(() => {
3313
- if (!s.current) return;
3314
- let r = document.documentElement.classList.contains("dark"), i = He.of([{
3315
- key: "Mod-s",
3316
- run: (e) => {
3317
- let t = e.state.doc.toString();
3318
- return p.current?.(t), g(!1), !0;
3319
- },
3320
- preventDefault: !0
3321
- }]), a = new Ie({
3322
- state: Ke.create({
3323
- doc: e,
3324
- extensions: [
3325
- Ue(),
3326
- Ve(),
3327
- Je(),
3328
- et(),
3329
- Re(),
3330
- ze(),
3331
- Ke.allowMultipleSelections.of(!0),
3332
- nt(),
3333
- rt($e, { fallback: !0 }),
3334
- Qe(),
3335
- ct(),
3336
- st(),
3337
- We(),
3338
- Le(),
3339
- Be(),
3340
- at(),
3341
- He.of([
3342
- ...lt,
3343
- ...qe,
3344
- ...ot,
3345
- ...Ye,
3346
- ...tt,
3347
- ...ut,
3348
- Xe
3349
- ]),
3350
- i,
3351
- Ie.updateListener.of((e) => {
3352
- e.docChanged && (g(!0), h.current?.(e.state.doc.toString()));
3353
- }),
3354
- d.current.of(Ke.readOnly.of(n)),
3355
- l.current.of([]),
3356
- u.current.of(r ? it : []),
3357
- Ie.theme({
3358
- "&": { height: "100%" },
3359
- ".cm-scroller": { overflow: "auto" }
3360
- })
3361
- ]
3362
- }),
3363
- parent: s.current
3364
- });
3365
- c.current = a, o && (o.current = () => a.state.doc.toString());
3366
- let f = Qr(Zr(t));
3367
- return f && f.load().then((e) => {
3368
- c.current && c.current.dispatch({ effects: l.current.reconfigure(e) });
3369
- }).catch(() => {}), () => {
3370
- a.destroy(), c.current = null, o && (o.current = null);
3371
- };
3372
- }, []), W(() => {
3373
- let t = c.current;
3374
- if (!t) return;
3375
- let n = t.state.doc.toString();
3376
- n !== e && (t.dispatch({ changes: {
3377
- from: 0,
3378
- to: n.length,
3379
- insert: e
3380
- } }), g(!1));
3381
- }, [e, g]), W(() => {
3382
- let e = c.current;
3383
- if (!e) return;
3384
- let n = Qr(Zr(t));
3385
- n ? n.load().then((e) => {
3386
- c.current && c.current.dispatch({ effects: l.current.reconfigure(e) });
3387
- }).catch(() => {}) : e.dispatch({ effects: l.current.reconfigure([]) });
3388
- }, [t]), W(() => {
3389
- let e = c.current;
3390
- e && e.dispatch({ effects: d.current.reconfigure(Ke.readOnly.of(n)) });
3391
- }, [n]), W(() => {
3392
- let e = new MutationObserver(() => {
3393
- let e = c.current;
3394
- if (!e) return;
3395
- let t = document.documentElement.classList.contains("dark");
3396
- e.dispatch({ effects: u.current.reconfigure(t ? it : []) });
3397
- });
3398
- return e.observe(document.documentElement, {
3399
- attributes: !0,
3400
- attributeFilter: ["class"]
3401
- }), () => e.disconnect();
3402
- }, []), /* @__PURE__ */ R("div", {
3403
- ref: s,
3404
- className: "h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto"
3405
- });
3406
- }
3407
- //#endregion
3408
- //#region src/components/workspace/FilePreview.tsx
3409
- function $r({ content: e, objectUrl: t, kind: n, filename: r, path: i }) {
3410
- return n === "markdown" ? /* @__PURE__ */ R(X, { content: e || "" }) : n === "image" && t ? /* @__PURE__ */ R("div", {
3411
- className: "flex items-center justify-center p-4",
3412
- children: /* @__PURE__ */ R("img", {
3413
- src: t,
3414
- alt: r,
3415
- className: "max-h-[70vh] max-w-full rounded object-contain"
3416
- })
3417
- }) : n === "pdf" && t ? /* @__PURE__ */ R("iframe", {
3418
- src: t,
3419
- title: r,
3420
- className: "h-full w-full border-0"
3421
- }) : (n === "text" || n === "code") && e !== null ? /* @__PURE__ */ R(Q, {
3422
- content: e,
3423
- path: i || r,
3424
- readOnly: !0,
3425
- onSave: () => {},
3426
- onDirtyChange: () => {},
3427
- getContentRef: { current: () => e || "" }
3428
- }) : /* @__PURE__ */ R("div", {
3429
- className: "flex h-full items-center justify-center px-6 text-center",
3430
- children: /* @__PURE__ */ R("div", {
3431
- 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",
3432
- children: "该文件类型暂不支持在线预览,请直接下载查看。"
3433
- })
3434
- });
3435
- }
3436
- //#endregion
3437
- //#region src/utils/sandbox.ts
3438
- function ei(e) {
3439
- return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3440
- }
3441
- function ti(e) {
3442
- let t = e.endsWith("/") ? e : `${e}/`;
3443
- if (typeof window > "u") return "'self'";
3444
- try {
3445
- return new URL(t, window.location.origin).toString();
3446
- } catch {
3447
- return "'self'";
3448
- }
3449
- }
3450
- function ni(...e) {
3451
- return Array.from(new Set(e.filter((e) => !!e))).join(" ");
3452
- }
3453
- function ri(e) {
3454
- let t = e ? ti(e) : void 0, n = ni("'unsafe-inline'", "'unsafe-eval'", "'self'", "https:", t), r = ni("'self'", "https:", t);
3455
- return [
3456
- "default-src 'none'",
3457
- `script-src ${n}`,
3458
- `style-src 'unsafe-inline' data: ${r}`,
3459
- `img-src data: blob: ${r}`,
3460
- `font-src data: ${r}`,
3461
- `media-src data: blob: ${r}`,
3462
- "worker-src blob:",
3463
- "connect-src 'none'",
3464
- "form-action 'none'",
3465
- "base-uri 'self'"
3466
- ].join("; ");
3467
- }
3468
- function ii(e) {
3469
- try {
3470
- let t = new URL(e, window.location.href);
3471
- return [
3472
- "http:",
3473
- "https:",
3474
- "mailto:"
3475
- ].includes(t.protocol);
3476
- } catch {
3477
- return !1;
3478
- }
3479
- }
3480
- function ai(e, t = {}) {
3481
- let { channelId: n, basePath: r } = typeof t == "string" ? { channelId: t } : t, i = ri(r), a = `<script>
3482
- function ksadkScrollToHash(rawHref) {
3483
- if (!rawHref || rawHref === '#') return;
3484
- var rawId = rawHref.slice(1);
3485
- var id = rawId;
3486
- try {
3487
- id = decodeURIComponent(rawId);
3488
- } catch (_) {}
3489
- var target = document.getElementById(id) || document.getElementsByName(id)[0];
3490
- if (target) {
3491
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
3492
- }
3493
- }
3494
- document.addEventListener('click', function(event) {
3495
- var target = event.target && event.target.closest ? event.target.closest('a') : null;
3496
- if (!target) return;
3497
- var rawHref = target.getAttribute('href') || '';
3498
- if (rawHref.charAt(0) === '#') {
3499
- event.preventDefault();
3500
- ksadkScrollToHash(rawHref);
3501
- return;
3502
- }
3503
- if (target.href) {
3504
- event.preventDefault();
3505
- window.parent.postMessage({
3506
- type: 'ksadk:linkClick',
3507
- channelId: ${JSON.stringify(n || "")},
3508
- href: target.href,
3509
- target: target.target || '_self'
3510
- }, '*');
3511
- }
3512
- }, true);
3513
- <\/script>`, o = `${`<meta http-equiv="Content-Security-Policy" content="${ei(i)}">`}${r ? `<base href="${ei(r)}">` : ""}${a}`;
3514
- return /<head[^>]*>/i.test(e) ? e.replace(/<head[^>]*>/i, `$&${o}`) : `${o}${e}`;
3515
- }
3516
- function oi(e, t) {
3517
- let n = G(null);
3518
- W(() => (n.current = (n) => {
3519
- if (n.source !== e.current?.contentWindow || n.data?.type !== "ksadk:linkClick" || t && n.data?.channelId !== t) return;
3520
- let r = n.data?.href;
3521
- typeof r == "string" && r && ii(r) && window.open(r, "_blank", "noopener,noreferrer");
3522
- }, window.addEventListener("message", n.current), () => {
3523
- n.current && window.removeEventListener("message", n.current);
3524
- }), [e, t]);
3525
- }
3526
- var si = "/_ksadk/workspace/v1/files", ci = new Set([
3527
- ".md",
3528
- ".markdown",
3529
- ".mdx"
3530
- ]), li = new Set([".pdf"]), ui = new Set([
3531
- ".png",
3532
- ".jpg",
3533
- ".jpeg",
3534
- ".gif",
3535
- ".webp",
3536
- ".svg",
3537
- ".bmp",
3538
- ".ico"
3539
- ]), di = 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(",")), fi = new Set([
3540
- "application/json",
3541
- "application/ld+json",
3542
- "application/xml",
3543
- "application/javascript",
3544
- "application/x-javascript",
3545
- "application/typescript",
3546
- "application/x-sh",
3547
- "application/x-yaml",
3548
- "application/yaml",
3549
- "text/csv",
3550
- "text/tab-separated-values"
3551
- ]);
3552
- function $(e) {
3553
- let t = String(e || "").trim().replace(/\\/g, "/");
3554
- if (!t || t === "/") return ".";
3555
- let n = [];
3556
- for (let e of t.split("/")) {
3557
- let t = e.trim();
3558
- if (!(!t || t === ".")) {
3559
- if (t === "..") {
3560
- n.length > 0 && n.pop();
3561
- continue;
3562
- }
3563
- n.push(t);
3564
- }
3565
- }
3566
- return n.length > 0 ? n.join("/") : ".";
3567
- }
3568
- function pi(e) {
3569
- let t = $(e);
3570
- return t === "." ? "" : t.split("/").filter(Boolean).map((e) => encodeURIComponent(e)).join("/");
3571
- }
3572
- function mi(e) {
3573
- let t = pi(e);
3574
- return t ? `${si}/${t}` : si;
3575
- }
3576
- function hi(e) {
3577
- let t = $(e);
3578
- if (t === "." || !t.includes("/")) return `${si}/`;
3579
- let n = pi(t.substring(0, t.lastIndexOf("/")));
3580
- return n ? `${si}/${n}/` : `${si}/`;
3581
- }
3582
- function gi(e) {
3583
- return $(e) === ".";
3584
- }
3585
- function _i(e) {
3586
- let t = $(e);
3587
- return t === "." ? "/" : `/${t}`;
3588
- }
3589
- function vi(e) {
3590
- let t = String(e || "").split("/").pop() || "", n = t.lastIndexOf(".");
3591
- return n >= 0 ? t.slice(n).toLowerCase() : "";
3592
- }
3593
- function yi(e) {
3594
- return String(e || "").split(";")[0].trim().toLowerCase();
3595
- }
3596
- var bi = new Set([".html", ".htm"]);
3597
- function xi({ path: e, mimeType: t }) {
3598
- let n = vi(e), r = yi(t);
3599
- return r === "text/html" || bi.has(n) ? "html" : r === "text/markdown" || ci.has(n) ? "markdown" : r === "application/pdf" || li.has(n) ? "pdf" : r.startsWith("image/") || ui.has(n) ? "image" : r.startsWith("text/") || fi.has(r) || di.has(n) ? "text" : "unsupported";
3600
- }
3601
- var Si = new Set([
3602
- ".txt",
3603
- ".log",
3604
- ".csv",
3605
- ".tsv",
3606
- ".env",
3607
- ".ini",
3608
- ".conf",
3609
- ".lock"
3610
- ]);
3611
- function Ci({ path: e, mimeType: t }) {
3612
- let n = vi(e), r = yi(t);
3613
- return bi.has(n) || r === "text/html" ? "html" : r === "text/markdown" || ci.has(n) ? "markdown" : r === "application/pdf" || li.has(n) || r.startsWith("image/") || ui.has(n) ? null : Si.has(n) || r === "text/plain" ? "text" : r.startsWith("text/") || fi.has(r) || di.has(n) ? "code" : null;
3614
- }
3615
- function wi({ isMobile: e }) {
3616
- return e ? {
3617
- renderMode: "sheet",
3618
- modal: !0,
3619
- showOverlay: !0,
3620
- preventOutsideClose: !1,
3621
- side: "bottom"
3622
- } : {
3623
- renderMode: "inline",
3624
- modal: !1,
3625
- showOverlay: !1,
3626
- preventOutsideClose: !0,
3627
- side: "right"
3628
- };
3629
- }
3630
- function Ti() {
3631
- let e = 0;
3632
- return {
3633
- next(t) {
3634
- return e += 1, {
3635
- path: t,
3636
- version: e
3637
- };
3638
- },
3639
- invalidate() {
3640
- e += 1;
3641
- },
3642
- isCurrent(t) {
3643
- return !!t && t.version === e;
3644
- }
3645
- };
3646
- }
3647
- function Ei({ workspaceFiles: e, accessMode: t }) {
3648
- if (!e?.Enabled) return !1;
3649
- let n = String(t || "").trim().toLowerCase();
3650
- return n === "owner" || n === "private";
3651
- }
3652
- //#endregion
3653
- //#region src/components/workspace/HtmlPreview.tsx
3654
- function Di({ content: e, path: t, onSave: n, onDirtyChange: r, getContentRef: i, isMobile: a }) {
3655
- let o = G(null), s = Ce(), [c, u] = K("preview"), d = hi(t), m = mi(t), h = U(() => ai(e, {
3656
- basePath: d,
3657
- channelId: s
3658
- }), [
3659
- e,
3660
- d,
3661
- s
3662
- ]), [g, _] = K(h());
3663
- W(() => {
3664
- let e = setTimeout(() => {
3665
- _(h());
3666
- }, 300);
3667
- return () => clearTimeout(e);
3668
- }, [h]), oi(o, s);
3669
- let v = U(() => {
3670
- let e = new Blob([g], { type: "text/html;charset=utf-8" }), t = URL.createObjectURL(e), n = window.open(t, "_blank", "noopener,noreferrer");
3671
- window.setTimeout(() => URL.revokeObjectURL(t), 3e4), n || window.open(m, "_blank", "noopener,noreferrer");
3672
- }, [m, g]);
3673
- return a ? /* @__PURE__ */ z("div", {
3674
- className: "flex h-full flex-col",
3675
- children: [/* @__PURE__ */ z("div", {
3676
- className: "flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700",
3677
- children: [/* @__PURE__ */ z("button", {
3678
- onClick: () => u("editor"),
3679
- className: J("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", c === "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"),
3680
- children: [/* @__PURE__ */ R(l, { className: "h-3.5 w-3.5" }), "编辑"]
3681
- }), /* @__PURE__ */ z("button", {
3682
- onClick: () => u("preview"),
3683
- className: J("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", c === "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"),
3684
- children: [/* @__PURE__ */ R(p, { className: "h-3.5 w-3.5" }), "预览"]
3685
- })]
3686
- }), c === "editor" ? /* @__PURE__ */ R(Q, {
3687
- content: e,
3688
- path: t,
3689
- onSave: n,
3690
- onDirtyChange: r,
3691
- getContentRef: i
3692
- }) : /* @__PURE__ */ R("iframe", {
3693
- ref: o,
3694
- srcDoc: g,
3695
- sandbox: "allow-scripts allow-downloads allow-same-origin",
3696
- title: "HTML 预览",
3697
- className: "h-full w-full border-0 bg-white"
3698
- })]
3699
- }) : c === "editor" ? /* @__PURE__ */ z("div", {
3700
- className: "relative flex h-full flex-col",
3701
- children: [/* @__PURE__ */ R(Q, {
3702
- content: e,
3703
- path: t,
3704
- onSave: n,
3705
- onDirtyChange: r,
3706
- getContentRef: i
3707
- }), /* @__PURE__ */ z("button", {
3708
- onClick: () => u("preview"),
3709
- 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",
3710
- children: [/* @__PURE__ */ R(p, { className: "h-3.5 w-3.5" }), "预览"]
3711
- })]
3712
- }) : /* @__PURE__ */ z("div", {
3713
- className: "relative flex h-full flex-col",
3714
- children: [/* @__PURE__ */ R("iframe", {
3715
- ref: o,
3716
- srcDoc: g,
3717
- sandbox: "allow-scripts allow-downloads allow-same-origin",
3718
- title: "HTML 预览",
3719
- className: "h-full w-full border-0 bg-white"
3720
- }), /* @__PURE__ */ z("div", {
3721
- className: "absolute right-3 top-3 z-10 flex gap-1.5",
3722
- children: [/* @__PURE__ */ z("button", {
3723
- onClick: v,
3724
- 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",
3725
- title: "在新窗口中打开当前预览",
3726
- children: [/* @__PURE__ */ R(f, { className: "h-3.5 w-3.5" }), "新窗口"]
3727
- }), /* @__PURE__ */ z("button", {
3728
- onClick: () => u("editor"),
3729
- 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",
3730
- children: [/* @__PURE__ */ R(l, { className: "h-3.5 w-3.5" }), "编辑"]
3731
- })]
3732
- })]
3733
- });
3734
- }
3735
- //#endregion
3736
- //#region src/components/workspace/MarkdownPreview.tsx
3737
- function Oi(e) {
3738
- e.current && clearTimeout(e.current);
3739
- }
3740
- function ki({ content: e, path: t, onSave: n, onDirtyChange: r, getContentRef: i, isMobile: a }) {
3741
- let [o, s] = K("editor"), [c, u] = K(e), d = G(null);
3742
- return W(() => (Oi(d), d.current = setTimeout(() => u(e), 300), () => Oi(d)), [e]), a ? /* @__PURE__ */ z("div", {
3743
- className: "flex h-full flex-col",
3744
- children: [/* @__PURE__ */ z("div", {
3745
- className: "flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30",
3746
- children: [/* @__PURE__ */ z("button", {
3747
- onClick: () => s("editor"),
3748
- className: J("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", o === "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"),
3749
- children: [/* @__PURE__ */ R(l, { className: "h-3.5 w-3.5" }), "编辑"]
3750
- }), /* @__PURE__ */ z("button", {
3751
- onClick: () => s("preview"),
3752
- className: J("flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors", o === "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"),
3753
- children: [/* @__PURE__ */ R(p, { className: "h-3.5 w-3.5" }), "预览"]
3754
- })]
3755
- }), o === "editor" ? /* @__PURE__ */ R(Q, {
3756
- content: e,
3757
- path: t,
3758
- onSave: n,
3759
- onDirtyChange: r,
3760
- getContentRef: i
3761
- }) : /* @__PURE__ */ R("div", {
3762
- className: "flex-1 overflow-auto p-4",
3763
- children: /* @__PURE__ */ R(X, { content: c })
3764
- })]
3765
- }) : o === "editor" ? /* @__PURE__ */ z("div", {
3766
- className: "relative flex h-full flex-col",
3767
- children: [/* @__PURE__ */ R(Q, {
3768
- content: e,
3769
- path: t,
3770
- onSave: n,
3771
- onDirtyChange: r,
3772
- getContentRef: i
3773
- }), /* @__PURE__ */ z("button", {
3774
- onClick: () => s("preview"),
3775
- 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",
3776
- children: [/* @__PURE__ */ R(p, { className: "h-3.5 w-3.5" }), "预览"]
3777
- })]
3778
- }) : /* @__PURE__ */ z("div", {
3779
- className: "relative flex h-full flex-col",
3780
- children: [/* @__PURE__ */ R("div", {
3781
- className: "flex-1 overflow-auto p-4",
3782
- children: /* @__PURE__ */ R(X, { content: c })
3783
- }), /* @__PURE__ */ z("button", {
3784
- onClick: () => s("editor"),
3785
- 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",
3786
- children: [/* @__PURE__ */ R(l, { className: "h-3.5 w-3.5" }), "编辑"]
3787
- })]
3788
- });
3789
- }
3790
- //#endregion
3791
- //#region src/components/workspace/WorkspacePanel.tsx
3792
- var Ai = "/agentengine/api/v1/GetWorkspaceFileContent", ji = 4e3;
3793
- function Mi(e) {
3794
- let t = $(e);
3795
- if (!t || t === ".") return ".";
3796
- let n = t.split("/").filter(Boolean);
3797
- return n.length <= 1 ? "." : n.slice(0, -1).join("/");
3798
- }
3799
- function Ni(e) {
3800
- if (!e) return "";
3801
- let t = Date.parse(e);
3802
- return Number.isNaN(t) ? e : new Date(t).toLocaleString();
3803
- }
3804
- function Pi(e) {
3805
- let t = Number(e);
3806
- 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`;
3807
- }
3808
- var Fi = [
3809
- {
3810
- label: "Markdown",
3811
- detail: ".md .markdown .mdx"
3812
- },
3813
- {
3814
- label: "代码/文本",
3815
- detail: ".py .js .ts .tsx .json .yaml .log .txt"
3816
- },
3817
- {
3818
- label: "图片",
3819
- detail: "PNG JPG GIF WebP SVG"
3820
- },
3821
- {
3822
- label: "PDF",
3823
- detail: ".pdf"
3824
- },
3825
- {
3826
- label: "表格文本",
3827
- detail: "CSV TSV"
3828
- }
3829
- ];
3830
- function Ii(e) {
3831
- return mi(e);
3832
- }
3833
- function Li({ label: e, showSupportedTypes: t = !1 }) {
3834
- return /* @__PURE__ */ R("div", {
3835
- className: "flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center",
3836
- children: /* @__PURE__ */ z("div", {
3837
- 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",
3838
- children: [/* @__PURE__ */ R("div", { children: e }), t ? /* @__PURE__ */ z("div", {
3839
- className: "mt-4 text-left",
3840
- children: [
3841
- /* @__PURE__ */ R("div", {
3842
- className: "text-xs font-semibold uppercase tracking-[0.12em] text-slate-400",
3843
- children: "支持在线预览"
3844
- }),
3845
- /* @__PURE__ */ R("div", {
3846
- className: "mt-2 grid gap-2",
3847
- children: Fi.map((e) => /* @__PURE__ */ z("div", {
3848
- className: "rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950",
3849
- children: [/* @__PURE__ */ R("div", {
3850
- className: "text-sm font-medium text-slate-700 dark:text-slate-200",
3851
- children: e.label
3852
- }), /* @__PURE__ */ R("div", {
3853
- className: "mt-0.5 font-mono text-[11px] text-slate-400",
3854
- children: e.detail
3855
- })]
3856
- }, e.label))
3857
- }),
3858
- /* @__PURE__ */ R("div", {
3859
- className: "mt-3 text-xs leading-5 text-slate-400",
3860
- children: "Word、Excel、PPT 当前不支持在线预览,可下载后查看。"
3861
- })
3862
- ]
3863
- }) : null]
3864
- })
3865
- });
3866
- }
3867
- function Ri({ agentId: e, capability: t, open: n, onClose: i, isFullscreen: a = !1, onToggleFullscreen: o, isMobile: s = !1, api: c }) {
3868
- let l = G(null), u = G(null), [f, p] = K(!1), [h, v] = K("."), [y, x] = K([]), [C, T] = K(!1), [E, te] = K(!1), [re, ie] = K(!1), [ae, D] = K(""), [O, oe] = K(null), [k, A] = K(null), [j, M] = K(!1), [le, ue] = K(!1), N = G(null), de = G(null), P = G("selection"), fe = G(Ti()), F = Te(() => y.find((e) => e.Path === O) ?? null, [y, O]), he = Te(() => F ? Ci({
3869
- path: F.Path,
3870
- mimeType: F.MimeType
3871
- }) : null, [F]), ge = U(() => j ? window.confirm("当前文件有未保存的更改,确定要离开吗?") : !0, [j]), ve = t.ContentPath || Ai, ye = t.RootLabel || "Workspace", be = ye ? `${ye.charAt(0).toUpperCase()}${ye.slice(1)}` : "Workspace", xe = _i(h), I = U(() => {
3872
- u.current &&= (URL.revokeObjectURL(u.current), null);
3873
- }, []);
3874
- W(() => () => I(), [I]);
3875
- let L = U(async (t, n = {}) => {
3876
- let r = !!n.background;
3877
- r ? te(!0) : T(!0), r || D("");
3878
- try {
3879
- let n = await c.listWorkspaceFiles(e, t, !1), i = $(String(n?.Path || t || ".")), a = Array.isArray(n?.Entries) ? n.Entries : [];
3880
- v(i), x(a), P.current = r ? "background-refresh" : "selection", oe((e) => {
3881
- if (e) {
3882
- let t = a.find((t) => t.Path === e);
3883
- if (t && t.Type === "file") return e;
3884
- }
3885
- return a.find((e) => e.Type === "file")?.Path ?? null;
3886
- });
3887
- } catch (e) {
3888
- console.error("Failed to load workspace entries:", e), r || D(e instanceof Error ? e.message : String(e));
3889
- } finally {
3890
- r ? te(!1) : T(!1);
3891
- }
3892
- }, [e, c]);
3893
- W(() => {
3894
- !n || f || (p(!0), L("."));
3895
- }, [
3896
- f,
3897
- L,
3898
- n
3899
- ]), W(() => {
3900
- if (!n || j || !f) return;
3901
- let e = window.setInterval(() => {
3902
- L(h, { background: !0 });
3903
- }, ji);
3904
- return () => window.clearInterval(e);
3905
- }, [
3906
- h,
3907
- j,
3908
- f,
3909
- L,
3910
- n
3911
- ]);
3912
- let B = U(async (t) => {
3913
- let n = fe.current.next(t.Path), r = xi({
3914
- path: t.Path,
3915
- mimeType: t.MimeType
3916
- });
3917
- if (de.current = t.Path, r === "unsupported") {
3918
- I(), A({
3919
- path: t.Path,
3920
- kind: r,
3921
- status: "ready",
3922
- mimeType: t.MimeType ?? void 0
3923
- });
3924
- return;
3925
- }
3926
- I(), A({
3927
- path: t.Path,
3928
- kind: r,
3929
- status: "loading",
3930
- mimeType: t.MimeType ?? void 0
3931
- });
3932
- try {
3933
- let r = await c.getWorkspaceFileContent(e, t.Path, { asText: !1 });
3934
- if (!fe.current.isCurrent(n)) return;
3935
- if (r instanceof Blob) {
3936
- let e = t.MimeType || "", i = xi({
3937
- path: t.Path,
3938
- mimeType: e
3939
- });
3940
- if (i === "image" || i === "pdf") {
3941
- let n = URL.createObjectURL(r);
3942
- u.current = n, A({
3943
- path: t.Path,
3944
- kind: i,
3945
- status: "ready",
3946
- mimeType: e,
3947
- objectUrl: n
3948
- });
3949
- return;
3950
- }
3951
- let a = await r.text();
3952
- if (!fe.current.isCurrent(n)) return;
3953
- let o = xi({
3954
- path: t.Path,
3955
- mimeType: e
3956
- });
3957
- A({
3958
- path: t.Path,
3959
- kind: o,
3960
- status: "ready",
3961
- mimeType: e,
3962
- content: a
3963
- });
3964
- } else {
3965
- let e = t.MimeType || "", n = xi({
3966
- path: t.Path,
3967
- mimeType: e
3968
- });
3969
- A({
3970
- path: t.Path,
3971
- kind: n,
3972
- status: "ready",
3973
- mimeType: e,
3974
- content: r
3975
- });
3976
- }
3977
- } catch (e) {
3978
- if (!fe.current.isCurrent(n)) return;
3979
- console.error("Failed to preview workspace file:", e), A({
3980
- path: t.Path,
3981
- kind: r,
3982
- status: "error",
3983
- mimeType: t.MimeType ?? void 0,
3984
- error: e instanceof Error ? e.message : String(e)
3985
- });
3986
- }
3987
- }, [
3988
- e,
3989
- c,
3990
- I
3991
- ]);
3992
- W(() => {
3993
- if (!F || F.Type !== "file") {
3994
- I(), A(null), M(!1), de.current = null;
3995
- return;
3996
- }
3997
- if (P.current === "background-refresh" && de.current === F.Path) {
3998
- P.current = "selection";
3999
- return;
4000
- }
4001
- P.current = "selection", B(F);
4002
- }, [
4003
- I,
4004
- B,
4005
- F
4006
- ]);
4007
- let V = async (n) => {
4008
- if (!(!n || n.length === 0)) {
4009
- ie(!0), D("");
4010
- try {
4011
- for (let r of Array.from(n)) {
4012
- if (r.size > t.MaxUploadBytes) throw Error(`文件 ${r.name} 超过上传上限`);
4013
- let n = gi(h) ? r.name : `${h}/${r.name}`, i = new FormData();
4014
- i.append("file", r), i.append("AgentId", e), i.append("Path", n), await c.addWorkspaceFile(i);
4015
- }
4016
- await L(h);
4017
- } catch (e) {
4018
- console.error("Failed to upload workspace files:", e), D(e instanceof Error ? e.message : String(e));
4019
- } finally {
4020
- l.current && (l.current.value = ""), ie(!1);
4021
- }
4022
- }
4023
- }, H = async (n) => {
4024
- if (!t.SupportsDelete) return;
4025
- let r = $(n.Path);
4026
- if (window.confirm(`删除 ${r} ?`)) {
4027
- D("");
4028
- try {
4029
- await c.deleteWorkspaceFile(e, r), O && $(O) === r && (oe(null), M(!1)), await L(n.Type === "directory" && ($(h) === r || $(h).startsWith(`${r}/`)) ? Mi(r) : h);
4030
- } catch (e) {
4031
- console.error("Failed to delete workspace file:", e), D(e instanceof Error ? e.message : String(e));
4032
- }
4033
- }
4034
- }, Se = () => !F || F.Type !== "file" ? /* @__PURE__ */ R(Li, {
4035
- label: "从左侧选择文件后在这里查看内容预览。",
4036
- showSupportedTypes: !0
4037
- }) : !k || k.path !== F.Path || k.status === "loading" ? /* @__PURE__ */ R("div", {
4038
- className: "flex h-full min-h-[16rem] items-center justify-center",
4039
- children: /* @__PURE__ */ z("div", {
4040
- 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",
4041
- children: [/* @__PURE__ */ R(S, { className: "h-4 w-4 animate-spin" }), "正在加载预览..."]
4042
- })
4043
- }) : k.status === "error" ? /* @__PURE__ */ R(Li, { label: k.error || "文件预览加载失败。" }) : k.kind === "markdown" ? /* @__PURE__ */ R(ki, {
4044
- content: k.content || "",
4045
- path: F.Path,
4046
- onSave: Ce,
4047
- onDirtyChange: M,
4048
- getContentRef: N,
4049
- isMobile: s
4050
- }) : k.kind === "image" && k.objectUrl ? /* @__PURE__ */ R($r, {
4051
- content: null,
4052
- objectUrl: k.objectUrl,
4053
- kind: "image",
4054
- filename: F.Name,
4055
- mimeType: k.mimeType || ""
4056
- }) : k.kind === "pdf" && k.objectUrl ? /* @__PURE__ */ R($r, {
4057
- content: null,
4058
- objectUrl: k.objectUrl,
4059
- kind: "pdf",
4060
- filename: F.Name,
4061
- mimeType: k.mimeType || ""
4062
- }) : k.kind === "html" ? /* @__PURE__ */ R(Di, {
4063
- content: k.content || "",
4064
- path: F.Path,
4065
- onSave: Ce,
4066
- onDirtyChange: M,
4067
- getContentRef: N,
4068
- isMobile: s,
4069
- agentId: e,
4070
- contentPath: ve
4071
- }) : k.kind === "text" || k.kind === "code" ? /* @__PURE__ */ R(Q, {
4072
- content: k.content || "",
4073
- path: F.Path,
4074
- onSave: Ce,
4075
- onDirtyChange: M,
4076
- getContentRef: N
4077
- }) : /* @__PURE__ */ R($r, {
4078
- content: null,
4079
- kind: "unsupported",
4080
- filename: F.Name,
4081
- mimeType: k.mimeType || ""
4082
- }), Ce = async (t) => {
4083
- if (F) {
4084
- ue(!0), D("");
4085
- try {
4086
- let n = new Blob([t], { type: F.MimeType || "text/plain" }), r = new FormData();
4087
- r.append("file", n, F.Name), r.append("AgentId", e), r.append("Path", F.Path), await c.addWorkspaceFile(r), fe.current.invalidate(), M(!1), A((e) => e && e.path === F.Path ? {
4088
- ...e,
4089
- content: t
4090
- } : e), de.current = F.Path, await L(h, { background: !0 });
4091
- } catch (e) {
4092
- console.error("Failed to save workspace file:", e), D(e instanceof Error ? e.message : String(e));
4093
- } finally {
4094
- ue(!1);
4095
- }
4096
- }
4097
- }, we = F?.Type === "file" && k?.path === F.Path && k.status === "ready" && (k.kind === "text" || k.kind === "code" || k.kind === "html" || k.kind === "markdown"), q = F?.Type === "file" && k?.path === F.Path && k.status === "ready" && k.kind === "pdf";
4098
- return /* @__PURE__ */ z("div", {
4099
- 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",
4100
- children: [/* @__PURE__ */ z("div", {
4101
- className: "flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40",
4102
- children: [/* @__PURE__ */ z("div", {
4103
- className: "flex min-w-0 flex-1 items-center gap-3",
4104
- children: [
4105
- /* @__PURE__ */ R("div", {
4106
- className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100",
4107
- children: be
4108
- }),
4109
- /* @__PURE__ */ R("div", { className: "hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block" }),
4110
- /* @__PURE__ */ z("div", {
4111
- className: "flex min-w-0 items-center gap-2",
4112
- children: [/* @__PURE__ */ R("span", {
4113
- className: "flex-shrink-0 text-xs text-slate-400",
4114
- children: "当前目录"
4115
- }), /* @__PURE__ */ R("div", {
4116
- 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",
4117
- title: `${xe},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,
4118
- children: xe
4119
- })]
4120
- }),
4121
- /* @__PURE__ */ R("div", {
4122
- className: "hidden truncate text-[11px] text-slate-400 xl:block",
4123
- children: "工作区内相对路径,不是宿主机绝对路径。"
4124
- })
4125
- ]
4126
- }), /* @__PURE__ */ z("div", {
4127
- className: "flex flex-shrink-0 items-center gap-1.5",
4128
- children: [
4129
- /* @__PURE__ */ R("input", {
4130
- ref: l,
4131
- type: "file",
4132
- multiple: !0,
4133
- className: "hidden",
4134
- onChange: (e) => void V(e.target.files)
4135
- }),
4136
- /* @__PURE__ */ z("button", {
4137
- type: "button",
4138
- onClick: () => l.current?.click(),
4139
- disabled: re,
4140
- 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",
4141
- title: `上传文件,上限 ${Math.floor(t.MaxUploadBytes / (1024 * 1024))}MB`,
4142
- children: [/* @__PURE__ */ R(me, { className: "h-3.5 w-3.5" }), re ? "上传中" : "上传"]
4143
- }),
4144
- /* @__PURE__ */ z("button", {
4145
- type: "button",
4146
- onClick: () => {
4147
- let e = new URLSearchParams({ Path: h }).toString();
4148
- window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`, "_blank", "noopener,noreferrer");
4149
- },
4150
- 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",
4151
- title: "导出当前目录为 ZIP",
4152
- children: [/* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" }), "导出"]
4153
- }),
4154
- o ? /* @__PURE__ */ R("button", {
4155
- type: "button",
4156
- onClick: o,
4157
- 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",
4158
- "aria-label": a ? "退出全屏" : "全屏查看 Workspace",
4159
- title: a ? "退出全屏" : "全屏查看",
4160
- children: R(a ? ee : w, { className: "h-4 w-4" })
4161
- }) : null,
4162
- i ? /* @__PURE__ */ R("button", {
4163
- type: "button",
4164
- onClick: () => {
4165
- ge() && i?.();
4166
- },
4167
- 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",
4168
- "aria-label": "关闭 Workspace",
4169
- title: "关闭",
4170
- children: /* @__PURE__ */ R(_e, { className: "h-4 w-4" })
4171
- }) : null
4172
- ]
4173
- })]
4174
- }), /* @__PURE__ */ z("div", {
4175
- className: "flex min-h-0 flex-1 flex-col md:flex-row",
4176
- children: [/* @__PURE__ */ z("div", {
4177
- 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",
4178
- children: [/* @__PURE__ */ z("div", {
4179
- className: "flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40",
4180
- children: [/* @__PURE__ */ z("div", {
4181
- className: "flex items-center justify-between gap-2",
4182
- children: [/* @__PURE__ */ z("div", {
4183
- className: "min-w-0",
4184
- children: [/* @__PURE__ */ R("div", {
4185
- className: "text-xs font-medium text-slate-900 dark:text-slate-100",
4186
- children: "文件"
4187
- }), /* @__PURE__ */ z("div", {
4188
- className: "flex items-center gap-1 text-[11px] text-slate-400",
4189
- children: [/* @__PURE__ */ z("span", { children: [y.length, " 项"] }), E ? /* @__PURE__ */ R(se, {
4190
- className: "h-3 w-3 animate-spin",
4191
- "aria-label": "正在同步 Workspace 目录"
4192
- }) : null]
4193
- })]
4194
- }), /* @__PURE__ */ z("div", {
4195
- className: "flex items-center gap-1",
4196
- children: [/* @__PURE__ */ R("button", {
4197
- type: "button",
4198
- onClick: () => {
4199
- ge() && L(Mi(h));
4200
- },
4201
- disabled: C || gi(h),
4202
- 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",
4203
- title: "返回上级目录",
4204
- children: /* @__PURE__ */ R(r, { className: "h-4 w-4" })
4205
- }), /* @__PURE__ */ R("button", {
4206
- type: "button",
4207
- onClick: () => {
4208
- ge() && L(h);
4209
- },
4210
- disabled: C,
4211
- 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",
4212
- title: "刷新目录",
4213
- children: /* @__PURE__ */ R(se, { className: `h-4 w-4 ${C ? "animate-spin" : ""}` })
4214
- })]
4215
- })]
4216
- }), ae ? /* @__PURE__ */ R("div", {
4217
- 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",
4218
- children: ae
4219
- }) : null]
4220
- }), /* @__PURE__ */ R("div", {
4221
- className: "custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2",
4222
- children: !f && !n ? /* @__PURE__ */ R("div", {
4223
- className: "px-3 py-4 text-sm text-slate-400",
4224
- children: "打开面板后加载 workspace 文件。"
4225
- }) : C ? /* @__PURE__ */ R("div", {
4226
- className: "px-3 py-4 text-sm text-slate-400",
4227
- children: "正在加载目录..."
4228
- }) : y.length === 0 ? /* @__PURE__ */ R("div", {
4229
- className: "px-3 py-4 text-sm text-slate-400",
4230
- children: "当前目录为空。"
4231
- }) : /* @__PURE__ */ R("div", {
4232
- className: "space-y-0.5",
4233
- children: y.map((e) => {
4234
- let n = xi({
4235
- path: e.Path,
4236
- mimeType: e.MimeType
4237
- }), r = O === e.Path, i = e.Type === "file" ? Ii(e.Path) : "";
4238
- return /* @__PURE__ */ z("div", {
4239
- title: e.Path,
4240
- className: J("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"),
4241
- children: [/* @__PURE__ */ z("button", {
4242
- type: "button",
4243
- onClick: () => {
4244
- if (e.Type === "directory") {
4245
- L(e.Path);
4246
- return;
4247
- }
4248
- O !== e.Path && !ge() || oe(e.Path);
4249
- },
4250
- className: "flex min-w-0 flex-1 items-center gap-2 text-left",
4251
- children: [/* @__PURE__ */ R("div", {
4252
- className: J("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"),
4253
- children: e.Type === "directory" ? /* @__PURE__ */ R(_, { className: "h-3.5 w-3.5" }) : R(n === "image" ? b : n === "markdown" || n === "text" || n === "html" ? m : g, { className: "h-3.5 w-3.5" })
4254
- }), /* @__PURE__ */ z("div", {
4255
- className: "min-w-0 flex-1",
4256
- children: [/* @__PURE__ */ R("div", {
4257
- className: "truncate text-[13px] leading-5",
4258
- children: e.Name
4259
- }), /* @__PURE__ */ R("div", {
4260
- className: J("truncate text-[11px] leading-4", r ? "text-slate-500 dark:text-slate-400" : "text-slate-400"),
4261
- children: e.Type === "directory" ? "目录" : Pi(e.SizeBytes)
4262
- })]
4263
- })]
4264
- }), /* @__PURE__ */ z("div", {
4265
- className: "flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100",
4266
- children: [e.Type === "file" ? /* @__PURE__ */ R("a", {
4267
- href: i,
4268
- download: e.Name,
4269
- className: J("rounded-md p-1.5 transition", r ? "hover:bg-white dark:hover:bg-slate-700" : "hover:bg-slate-100 dark:hover:bg-slate-800"),
4270
- title: "下载",
4271
- children: /* @__PURE__ */ R(d, { className: "h-3.5 w-3.5" })
4272
- }) : null, t.SupportsDelete ? /* @__PURE__ */ R("button", {
4273
- type: "button",
4274
- onClick: () => void H(e),
4275
- className: J("rounded-md p-1.5 transition", r ? "hover:bg-white dark:hover:bg-slate-700" : "hover:bg-slate-100 dark:hover:bg-slate-800"),
4276
- title: "删除",
4277
- children: /* @__PURE__ */ R(pe, { className: "h-3.5 w-3.5" })
4278
- }) : null]
4279
- })]
4280
- }, e.Path);
4281
- })
4282
- })
4283
- })]
4284
- }), /* @__PURE__ */ z("div", {
4285
- className: "flex min-h-0 min-w-0 flex-1 flex-col",
4286
- children: [/* @__PURE__ */ R("div", {
4287
- className: "flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40",
4288
- children: F ? /* @__PURE__ */ z("div", {
4289
- className: "flex w-full items-start justify-between gap-3",
4290
- children: [/* @__PURE__ */ z("div", {
4291
- className: "min-w-0",
4292
- children: [
4293
- /* @__PURE__ */ R("div", {
4294
- className: "truncate text-sm font-semibold text-slate-900 dark:text-slate-100",
4295
- children: F.Name
4296
- }),
4297
- /* @__PURE__ */ R("div", {
4298
- className: "mt-0.5 break-all font-mono text-[11px] text-slate-400",
4299
- children: F.Path
4300
- }),
4301
- /* @__PURE__ */ z("div", {
4302
- className: "mt-1 text-[11px] text-slate-400",
4303
- children: [
4304
- Pi(F.SizeBytes),
4305
- F.MimeType ? ` · ${F.MimeType}` : "",
4306
- F.ModifiedAt ? ` · ${Ni(F.ModifiedAt)}` : ""
4307
- ]
4308
- })
4309
- ]
4310
- }), he === "text" || he === "code" || he === "html" || he === "markdown" ? /* @__PURE__ */ z("button", {
4311
- type: "button",
4312
- onClick: () => {
4313
- let e = N.current;
4314
- e && Ce(e());
4315
- },
4316
- disabled: !j || le,
4317
- className: J("inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition", j && !le ? "bg-blue-600 text-white hover:bg-blue-700" : "text-slate-400 dark:text-slate-500 cursor-not-allowed"),
4318
- children: [/* @__PURE__ */ R(ce, { className: "h-3.5 w-3.5" }), le ? "保存中" : j ? "保存" : "已保存"]
4319
- }) : null]
4320
- }) : /* @__PURE__ */ z("div", {
4321
- className: "w-full",
4322
- children: [/* @__PURE__ */ R("div", {
4323
- className: "text-sm font-semibold text-slate-900 dark:text-slate-100",
4324
- children: "文件预览"
4325
- }), /* @__PURE__ */ R("div", {
4326
- className: "mt-0.5 text-xs text-slate-500 dark:text-slate-400",
4327
- children: "选择左侧文件后可在此查看内容。"
4328
- })]
4329
- })
4330
- }), /* @__PURE__ */ R("div", {
4331
- className: J("custom-scrollbar min-h-0 flex-1", q || we ? "overflow-hidden p-0" : "overflow-y-auto px-4 py-4"),
4332
- children: Se()
4333
- })]
4334
- })]
4335
- })]
4336
- });
4337
- }
4338
- //#endregion
4339
- //#region src/components/workspace/WorkspacePanelContainer.tsx
4340
- function zi({ agentId: e, capability: t, workspacePanelOpen: n, workspacePanelWidth: r, workspacePanelFullscreen: i, isMobile: a, workspaceEnabled: o, workspaceFiles: s, workspacePanelPresentation: c, closeWorkspacePanel: l, handleWorkspacePanelResizeStart: u, api: d }) {
4341
- let f = c.renderMode === "inline", p = c.renderMode === "sheet";
4342
- return !o || !s ? null : /* @__PURE__ */ z(L, { children: [f ? /* @__PURE__ */ z(L, { children: [n && !i ? /* @__PURE__ */ R("div", {
4343
- role: "separator",
4344
- "aria-label": "调整 Workspace 宽度",
4345
- "aria-orientation": "vertical",
4346
- onPointerDown: u,
4347
- 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"
4348
- }) : null, /* @__PURE__ */ R("aside", {
4349
- style: n && !i ? { width: `${r}px` } : void 0,
4350
- className: J(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"),
4351
- children: n ? /* @__PURE__ */ R(Ri, {
4352
- agentId: e,
4353
- capability: t,
4354
- open: n,
4355
- onClose: l,
4356
- isFullscreen: i,
4357
- onToggleFullscreen: () => Xr.getState().setWorkspacePanelFullscreen(!i),
4358
- isMobile: a,
4359
- api: d
4360
- }) : null
4361
- })] }) : null, p ? /* @__PURE__ */ R(At, {
4362
- open: n,
4363
- onOpenChange: (e) => {
4364
- e || Xr.getState().setWorkspacePanelFullscreen(!1), Xr.getState().setWorkspacePanelOpen(e);
4365
- },
4366
- modal: c.modal,
4367
- children: /* @__PURE__ */ z(Pt, {
4368
- side: c.side,
4369
- showOverlay: c.showOverlay,
4370
- onInteractOutside: (e) => {
4371
- c.preventOutsideClose && e.preventDefault();
4372
- },
4373
- showCloseButton: !1,
4374
- className: J("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"),
4375
- children: [
4376
- /* @__PURE__ */ R(Lt, {
4377
- className: "sr-only",
4378
- children: "Workspace 文件"
4379
- }),
4380
- /* @__PURE__ */ R(Rt, {
4381
- className: "sr-only",
4382
- children: "浏览、上传和预览 Workspace 文件。"
4383
- }),
4384
- /* @__PURE__ */ R(Ri, {
4385
- agentId: e,
4386
- capability: t,
4387
- open: n,
4388
- onClose: l,
4389
- isMobile: a,
4390
- api: d
4391
- })
4392
- ]
4393
- })
4394
- }) : null] });
4395
- }
4396
- //#endregion
4397
- export { X as A, J as B, Dn as C, Cn as D, xn as E, Rt as F, Lt as I, kt as L, Vt as M, At as N, mn as O, Pt as P, Tt as R, On as S, Sn as T, or as _, oi as a, nr as b, Kr as c, mr as d, ur as f, dr as g, pr as h, ai as i, nn as j, _n as k, Fr as l, lr as m, Ei as n, Xr as o, cr as p, wi as r, Jr as s, zi as t, hr as u, fr as v, kn as w, Ln as x, sr as y, pt as z };