@kingsoftcloud/ksadk-web 0.3.15 → 0.3.17

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 (225) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -2
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-ND1ni01O.js → ArtifactsPanel-DYzXIPnl.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-Bm987IV9.js → CodeBlock-Dpa-tOmG.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-m289SxEv.js → MathMessageMarkdown-D8kBE9sl.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock-Draq-3W4.js → MermaidBlock-BYOoZB-_.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-BPKj9OEV.js → NativeTerminalPanel-CAeXHeo6.js} +1 -1
  9. package/dist-ksadk/assets/{OfficialA2uiRenderer-Buvy4tjx.js → OfficialA2uiRenderer-yPb3s23n.js} +1 -1
  10. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-DSkvfGF3.js → abnfDiagram-VCTEODGH-DdVxMn2L.js} +1 -1
  11. package/dist-ksadk/assets/{arc-D2OD6TRH.js → arc-DsOMYRTm.js} +1 -1
  12. package/dist-ksadk/assets/architecture-7GRP2DOG-Ds1NB530.js +1 -0
  13. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-BAGaNeP_.js → architectureDiagram-5GKGNRK7-BCfzi23_.js} +1 -1
  14. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-CE77-fsa.js → blockDiagram-NRAW4CY4-gC-Gc2Xv.js} +1 -1
  15. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-QM8LLt8e.js → c4Diagram-UCG6FXSJ-BAHemGZa.js} +1 -1
  16. package/dist-ksadk/assets/channel-B4PiWfnA.js +1 -0
  17. package/dist-ksadk/assets/chunk-2Q5K7J3B-CI2tn5IS.js +1 -0
  18. package/dist-ksadk/assets/{chunk-5VM5RSS4-NBYbb28t.js → chunk-5VM5RSS4-Cthhs8Yv.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-F27PBJKO-xaO4b0PR.js → chunk-F27PBJKO-BPV04XpW.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-G27WJ6UU-Bi73NhBu.js → chunk-G27WJ6UU-Cl1n0gHd.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-JWPE2WC7-CngFBp9d.js → chunk-JWPE2WC7-DqkIh_LK.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-LCL6LL3I-BsunO5Rx.js → chunk-LCL6LL3I-DZhAKY7Z.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-POPQ4Y6H-ImP4Ew8y.js → chunk-POPQ4Y6H-BGuhTofV.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-RHFEMEQ7-CdQmbok4.js → chunk-RHFEMEQ7-DhrRHdJ6.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-SVP7TREG-ExibL7Ea.js → chunk-SVP7TREG-CIdm5TIa.js} +1 -1
  26. package/dist-ksadk/assets/{chunk-XXDRQBXY-Bz850mDu.js → chunk-XXDRQBXY-CNIlGK4v.js} +1 -1
  27. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-BMQzydMm.js +1 -0
  28. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-BMQzydMm.js +1 -0
  29. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-C0xUJvyH.js → cose-bilkent-JH36ORCC-BjauSFl3.js} +1 -1
  30. package/dist-ksadk/assets/cynefin-OW5HDTMX-DcGwq_cA.js +1 -0
  31. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-DV2coA_s.js → cynefinDiagram-5FMLGOSQ-DPszkr1j.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-3AP2YEHR-jEooZQ_X.js → dagre-3AP2YEHR-Ds2xBGA0.js} +1 -1
  33. package/dist-ksadk/assets/{dagre-ljD7-f9M.js → dagre-Dr0YPDPm.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-S7CK7UJ4-B5BoTuaY.js → diagram-S7CK7UJ4-BOQfgaW5.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-UQ7AKVKN-Cvxn92tK.js → diagram-UQ7AKVKN-DMMyB2sa.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VSXAHHWV-CI86Na4n.js → diagram-VSXAHHWV-DZR1nzPa.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-VX7I27RA-CeZud7ml.js → diagram-VX7I27RA-DzAwLHuI.js} +1 -1
  38. package/dist-ksadk/assets/{diagram-Z3DM3KII-GeJxYdqI.js → diagram-Z3DM3KII-D98d_Dgt.js} +1 -1
  39. package/dist-ksadk/assets/{dist-CJuVeKiz.js → dist-A55dc8b7.js} +1 -1
  40. package/dist-ksadk/assets/{dist-BtermLVk.js → dist-BEzIxZLq.js} +1 -1
  41. package/dist-ksadk/assets/{dist-BxicrSj5.js → dist-BHIb3Gvv.js} +1 -1
  42. package/dist-ksadk/assets/{dist-Dk6TLega.js → dist-BIR7kFKG.js} +1 -1
  43. package/dist-ksadk/assets/{dist-Dig9D26k.js → dist-BpZXLW0T.js} +1 -1
  44. package/dist-ksadk/assets/{dist-lHe3BnLM.js → dist-By8HbjFH.js} +1 -1
  45. package/dist-ksadk/assets/{dist-ubZkVDhc.js → dist-C1uAMNTH.js} +1 -1
  46. package/dist-ksadk/assets/{dist-C7H9f-JT.js → dist-CN8MSPvo.js} +1 -1
  47. package/dist-ksadk/assets/{dist-eYoWaedR.js → dist-CpHO1CY1.js} +1 -1
  48. package/dist-ksadk/assets/{dist-BcNp5ouu.js → dist-CxzBVC3N.js} +1 -1
  49. package/dist-ksadk/assets/{dist-D2IRjZmI.js → dist-D9GtQnvz.js} +1 -1
  50. package/dist-ksadk/assets/{dist-CmWGM_T9.js → dist-DHiOUJJ-.js} +1 -1
  51. package/dist-ksadk/assets/{dist-Cgh3LKbI.js → dist-Du5KbDTg.js} +1 -1
  52. package/dist-ksadk/assets/{dist-CXo9VOuF.js → dist-DxBl1V2_.js} +1 -1
  53. package/dist-ksadk/assets/{dist-BiarszCa.js → dist-E1uwqlZY.js} +1 -1
  54. package/dist-ksadk/assets/{dist-BOBeN4EW.js → dist-HuJDn2Nr.js} +1 -1
  55. package/dist-ksadk/assets/{dist-BgCDfLfr.js → dist-MMIlBueM.js} +1 -1
  56. package/dist-ksadk/assets/{dist-IuOndGF_.js → dist-U51Rn7ZW.js} +1 -1
  57. package/dist-ksadk/assets/{dist-nOyq5Gq7.js → dist-VLWgeZIu.js} +1 -1
  58. package/dist-ksadk/assets/{dist-XaciJNLw.js → dist-X8Mgnqit.js} +1 -1
  59. package/dist-ksadk/assets/{dist-B_y4v6Vh.js → dist-glVlUB_d.js} +1 -1
  60. package/dist-ksadk/assets/{dist-CWaqQiTL.js → dist-q8rONmMl.js} +1 -1
  61. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-CVnEnD_Y.js → ebnfDiagram-PWID7BFC-X4mBLaw3.js} +1 -1
  62. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-gaG6xmRn.js → erDiagram-SSCWMZ5O-ClybQoOy.js} +1 -1
  63. package/dist-ksadk/assets/eventmodeling-NTZA5JFV--IdqCKdV.js +1 -0
  64. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BsidNZBX.js +1 -0
  65. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-Yov_MdHm.js → ganttDiagram-EL5Y4UJY-Dc_fWiA_.js} +1 -1
  66. package/dist-ksadk/assets/gitGraph-4MIJSDKK-BTqI4bBo.js +1 -0
  67. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-pCt6JiWp.js → gitGraphDiagram-WWUBYQGX-0eEV_CEC.js} +1 -1
  68. package/dist-ksadk/assets/index-B0DeBpyZ.js +1132 -0
  69. package/dist-ksadk/assets/index-DEVfafsU.css +2 -0
  70. package/dist-ksadk/assets/info-A6RAGUB7-CXZCoW0H.js +1 -0
  71. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-Df7QB9IZ.js → infoDiagram-RXCK75RN-mZoyw4Xh.js} +1 -1
  72. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-BxZM8H3E.js → ishikawaDiagram-5VMMS53U-CO8OkxgJ.js} +1 -1
  73. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DXJc7vNQ.js → journeyDiagram-EYS64GPL-Ci8GpXLK.js} +1 -1
  74. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-uGr_y_n5.js → kanban-definition-3QL26DDD-lgD5AYON.js} +1 -1
  75. package/dist-ksadk/assets/{katex-C34HoTrL.js → katex-Chn0O-XC.js} +1 -1
  76. package/dist-ksadk/assets/{linear-C7-Mijzq.js → linear-ffygyi0f.js} +1 -1
  77. package/dist-ksadk/assets/{mermaid-parser.core-DH4-hsMU.js → mermaid-parser.core-CGPz1_57.js} +2 -2
  78. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-5UJYSEer.js → mindmap-definition-FBJOCRG2-DRaJyZGQ.js} +1 -1
  79. package/dist-ksadk/assets/packet-AYTQ26CC-DoZlIRtk.js +1 -0
  80. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-BPdl55Nd.js → pegDiagram-XKGWAZYB-BbQ2QDD3.js} +1 -1
  81. package/dist-ksadk/assets/pie-WAS4IAKB-Dl-IyMT_.js +1 -0
  82. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-cDC3mpF_.js → pieDiagram-E7YTZNPT-BcB_c4Ka.js} +1 -1
  83. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-7jhGjy86.js → quadrantDiagram-AXDQQJYC-CK3csxHk.js} +1 -1
  84. package/dist-ksadk/assets/radar-RG4KPBEZ-Bp8MemxX.js +1 -0
  85. package/dist-ksadk/assets/railroad-74A4TZTK-BmKyKako.js +1 -0
  86. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-DhFitwOH.js +1 -0
  87. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-TB8LQz8q.js +1 -0
  88. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-B3J1Rtq9.js +1 -0
  89. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-DdTXYjCz.js → railroadDiagram-O6MQD6OU-D1YLglVU.js} +1 -1
  90. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-BxH5im9j.js → requirementDiagram-EFPCY7ZU-VeyqOcw3.js} +1 -1
  91. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-BrTs-PhV.js → sankeyDiagram-P5KCCOFB-uskDVCah.js} +1 -1
  92. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-B-GvSk9Z.js → sequenceDiagram-WJ2MYXX4-CmoPC4aR.js} +1 -1
  93. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-CxP3dmNT.js → sizeCapture-X5ZJPWSS-DzV4X5WN.js} +1 -1
  94. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-CIw-mH34.js → stateDiagram-HBIQ2CUA-BJehrZbH.js} +1 -1
  95. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-DkujIgVj.js +1 -0
  96. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-YZIWfS0x.js → swimlanes-XN3QIQJK-Bn4tEi27.js} +1 -1
  97. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-Blb1TQ9Q.js +8 -0
  98. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-CJ63qwLI.js → timeline-definition-24CTP7MA-bSkaKxqF.js} +1 -1
  99. package/dist-ksadk/assets/treeView-Q6P3EWNA-C5Ez-6L4.js +1 -0
  100. package/dist-ksadk/assets/treemap-WGGIJYW6-WdNvoGQV.js +1 -0
  101. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-DimJA1nS.js → vennDiagram-4TSXK5OY-ClO6s5iT.js} +1 -1
  102. package/dist-ksadk/assets/wardley-WFR3VGLG-DCCceTuX.js +1 -0
  103. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-Wf93ZvjN.js → wardleyDiagram-VM6X3IG4-CcaYar33.js} +1 -1
  104. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-B2A1aC7t.js → xychartDiagram-S5SC5T6Z-DdiPl8uB.js} +1 -1
  105. package/dist-ksadk/index.html +2 -2
  106. package/dist-lib/App.d.ts.map +1 -1
  107. package/dist-lib/AttachmentPreview-DHvWB_a-.js +1956 -0
  108. package/dist-lib/ConnectedComposer-CuN3EUnU.js +872 -0
  109. package/dist-lib/{ConnectedMessageList-Dhudkynn.js → ConnectedMessageList-CT-MJJkJ.js} +444 -442
  110. package/dist-lib/{WorkspacePanelContainer-CA59c9AQ.js → WorkspacePanelContainer-Jg9bUmLJ.js} +321 -321
  111. package/dist-lib/{a2ui-D2QH7eTV.js → a2ui-DridcTyF.js} +1717 -447
  112. package/dist-lib/{capabilities-DAeBY-WO.js → capabilities-lJRDfRg9.js} +46 -33
  113. package/dist-lib/capabilities.js +1 -1
  114. package/dist-lib/chat-composer.js +2 -2
  115. package/dist-lib/chat-timeline.js +3 -3
  116. package/dist-lib/components/chat/A2UIActivityMessage.d.ts +1 -0
  117. package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
  118. package/dist-lib/components/chat/ChatComposer.d.ts +4 -2
  119. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  120. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  121. package/dist-lib/components/chat/ConnectedComposer.d.ts +4 -2
  122. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  123. package/dist-lib/components/chat/ExecutionPermissionMenu.d.ts +11 -0
  124. package/dist-lib/components/chat/ExecutionPermissionMenu.d.ts.map +1 -0
  125. package/dist-lib/components/chat/InteractionA2uiSurface.d.ts +6 -1
  126. package/dist-lib/components/chat/InteractionA2uiSurface.d.ts.map +1 -1
  127. package/dist-lib/components/chat/InteractionTray.d.ts +3 -1
  128. package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -1
  129. package/dist-lib/components/chat/JsonSchemaInputForm.d.ts.map +1 -1
  130. package/dist-lib/components/chat/McpAuthorizationCard.d.ts +8 -0
  131. package/dist-lib/components/chat/McpAuthorizationCard.d.ts.map +1 -0
  132. package/dist-lib/components/chat/permission-menu-visibility.d.ts +7 -0
  133. package/dist-lib/components/chat/permission-menu-visibility.d.ts.map +1 -0
  134. package/dist-lib/components/ui/button.d.ts +12 -0
  135. package/dist-lib/components/ui/button.d.ts.map +1 -0
  136. package/dist-lib/components.js +13 -13
  137. package/dist-lib/conversation.js +2 -2
  138. package/dist-lib/core/api/facade.d.ts +1 -0
  139. package/dist-lib/core/api/facade.d.ts.map +1 -1
  140. package/dist-lib/core/api/types.d.ts +1 -0
  141. package/dist-lib/core/api/types.d.ts.map +1 -1
  142. package/dist-lib/core/conversation/presentation.d.ts.map +1 -1
  143. package/dist-lib/core/conversation/runtime-ingress.d.ts.map +1 -1
  144. package/dist-lib/core/interaction/a2ui-approval.d.ts +20 -0
  145. package/dist-lib/core/interaction/a2ui-approval.d.ts.map +1 -0
  146. package/dist-lib/core/interaction/adapters/agui.d.ts.map +1 -1
  147. package/dist-lib/core/interaction/adapters/normalize.d.ts +2 -0
  148. package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -1
  149. package/dist-lib/core/interaction/adapters/responses.d.ts +14 -0
  150. package/dist-lib/core/interaction/adapters/responses.d.ts.map +1 -1
  151. package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -1
  152. package/dist-lib/core/interaction/client.d.ts.map +1 -1
  153. package/dist-lib/core/interaction/index.d.ts +16 -2
  154. package/dist-lib/core/interaction/index.d.ts.map +1 -1
  155. package/dist-lib/core/interaction/legacy-a2ui.d.ts +5 -0
  156. package/dist-lib/core/interaction/legacy-a2ui.d.ts.map +1 -0
  157. package/dist-lib/core/interaction/pending.d.ts +4 -0
  158. package/dist-lib/core/interaction/pending.d.ts.map +1 -0
  159. package/dist-lib/core/mcp-authorization/contract.d.ts +5 -0
  160. package/dist-lib/core/mcp-authorization/contract.d.ts.map +1 -0
  161. package/dist-lib/core/mcp-authorization/normalize.d.ts +4 -0
  162. package/dist-lib/core/mcp-authorization/normalize.d.ts.map +1 -0
  163. package/dist-lib/core/mcp-authorization/recovery.d.ts +5 -0
  164. package/dist-lib/core/mcp-authorization/recovery.d.ts.map +1 -0
  165. package/dist-lib/core/mcp-authorization/types.d.ts +20 -0
  166. package/dist-lib/core/mcp-authorization/types.d.ts.map +1 -0
  167. package/dist-lib/core/run/agui.d.ts.map +1 -1
  168. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  169. package/dist-lib/core/run/engine.d.ts.map +1 -1
  170. package/dist-lib/core/run/types.d.ts +13 -0
  171. package/dist-lib/core/run/types.d.ts.map +1 -1
  172. package/dist-lib/core/stream/types.d.ts +11 -0
  173. package/dist-lib/core/stream/types.d.ts.map +1 -1
  174. package/dist-lib/core/teams/cloudContracts.d.ts +15 -15
  175. package/dist-lib/{feedback-DRgW061h.js → feedback-CaSZOBD2.js} +12 -22
  176. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  177. package/dist-lib/hooks/useInteractions.d.ts +1 -0
  178. package/dist-lib/hooks/useInteractions.d.ts.map +1 -1
  179. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  180. package/dist-lib/hooks.js +58 -57
  181. package/dist-lib/{permission-CHy_uZD0.js → permission-2NpSBuq3.js} +1 -1
  182. package/dist-lib/{persisted-session-history-KtoKbLRA.js → persisted-session-history-D_1AtH5H.js} +536 -1457
  183. package/dist-lib/runtime.js +279 -276
  184. package/dist-lib/session-events-6PXUoAkP.js +1225 -0
  185. package/dist-lib/stores/bootstrap.d.ts.map +1 -1
  186. package/dist-lib/stores/execution-permission.d.ts +21 -0
  187. package/dist-lib/stores/execution-permission.d.ts.map +1 -0
  188. package/dist-lib/styles.css +1 -1
  189. package/dist-lib/types/capabilities.d.ts +14 -0
  190. package/dist-lib/types/capabilities.d.ts.map +1 -1
  191. package/dist-lib/{useSessionLifecycle-DNG3Yks2.js → useSessionLifecycle-daQg0sqQ.js} +1032 -1946
  192. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  193. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  194. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  195. package/dist-lib/utils/run-progress.d.ts.map +1 -1
  196. package/dist-lib/utils/workspace.d.ts +1 -1
  197. package/package.json +1 -1
  198. package/dist-ksadk/assets/architecture-7GRP2DOG-vaJx2f97.js +0 -1
  199. package/dist-ksadk/assets/channel-qoLBikeO.js +0 -1
  200. package/dist-ksadk/assets/chunk-2Q5K7J3B-OLdkjA_5.js +0 -1
  201. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-DqbkClnv.js +0 -1
  202. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-DqbkClnv.js +0 -1
  203. package/dist-ksadk/assets/cynefin-OW5HDTMX-BnPp48kV.js +0 -1
  204. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BHS_Svvs.js +0 -1
  205. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BkQ0O0Ft.js +0 -1
  206. package/dist-ksadk/assets/gitGraph-4MIJSDKK-CSW-TIsw.js +0 -1
  207. package/dist-ksadk/assets/index-DMqhW2cV.css +0 -2
  208. package/dist-ksadk/assets/index-DcQSCIw4.js +0 -1132
  209. package/dist-ksadk/assets/info-A6RAGUB7-2r962Zht.js +0 -1
  210. package/dist-ksadk/assets/packet-AYTQ26CC-C8AN0vyj.js +0 -1
  211. package/dist-ksadk/assets/pie-WAS4IAKB-D8iGFt9t.js +0 -1
  212. package/dist-ksadk/assets/radar-RG4KPBEZ-BFDLv34s.js +0 -1
  213. package/dist-ksadk/assets/railroad-74A4TZTK-BCF2fZR0.js +0 -1
  214. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-Ban_fK3c.js +0 -1
  215. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-DKxLpd8o.js +0 -1
  216. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-n_o0pjRU.js +0 -1
  217. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-CFLSAbtQ.js +0 -1
  218. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-CNHXQSl-.js +0 -8
  219. package/dist-ksadk/assets/treeView-Q6P3EWNA-B1wKifn0.js +0 -1
  220. package/dist-ksadk/assets/treemap-WGGIJYW6-DECztlF0.js +0 -1
  221. package/dist-ksadk/assets/wardley-WFR3VGLG-BSQgLjrP.js +0 -1
  222. package/dist-lib/AttachmentPreview-CPRjbiqd.js +0 -1545
  223. package/dist-lib/ConnectedComposer-CKnKpokV.js +0 -781
  224. package/dist-lib/json-value-DnHp0582.js +0 -186
  225. package/dist-lib/tool-display-DTiRdghE.js +0 -64
@@ -0,0 +1,1225 @@
1
+ //#region src/core/stream/runtime-items.ts
2
+ function e(e, t) {
3
+ return `${e}\u0000${t}`;
4
+ }
5
+ function t(e) {
6
+ return { ...e };
7
+ }
8
+ var n = class {
9
+ runId = null;
10
+ status = null;
11
+ items = /* @__PURE__ */ new Map();
12
+ seenEventIds = /* @__PURE__ */ new Set();
13
+ apply(e) {
14
+ if (e.eventId) {
15
+ if (this.seenEventIds.has(e.eventId)) return;
16
+ this.seenEventIds.add(e.eventId);
17
+ }
18
+ switch (e.type) {
19
+ case "run_started":
20
+ this.runId = e.runId, this.status = "running";
21
+ return;
22
+ case "run_interrupted":
23
+ this.status = "interrupted";
24
+ return;
25
+ case "run_completed":
26
+ this.status = "completed";
27
+ return;
28
+ case "run_failed":
29
+ this.status = "failed";
30
+ return;
31
+ case "run_canceled":
32
+ this.status = "canceled";
33
+ return;
34
+ case "item_started":
35
+ this.startItem(e);
36
+ return;
37
+ case "item_updated":
38
+ this.updateItem(e);
39
+ return;
40
+ case "item_snapshot_replaced":
41
+ this.replaceSnapshot(e);
42
+ return;
43
+ case "item_completed":
44
+ case "item_failed":
45
+ this.closeItem(e);
46
+ return;
47
+ }
48
+ }
49
+ applyAll(e) {
50
+ for (let t of e) this.apply(t);
51
+ }
52
+ snapshot() {
53
+ return {
54
+ runId: this.runId,
55
+ status: this.status,
56
+ items: Array.from(this.items.values()).map((e) => ({
57
+ ...e,
58
+ parts: e.parts.map(t)
59
+ }))
60
+ };
61
+ }
62
+ ensureItem(t) {
63
+ this.runId === null && (this.runId = t.runId);
64
+ let n = e(t.scopeId, t.itemId), r = this.items.get(n);
65
+ return r || (r = {
66
+ runId: t.runId,
67
+ scopeId: t.scopeId,
68
+ itemId: t.itemId,
69
+ itemKind: t.itemKind || "message",
70
+ status: "open",
71
+ parts: []
72
+ }, this.items.set(n, r)), r;
73
+ }
74
+ startItem(n) {
75
+ let r = e(n.scopeId, n.itemId), i = this.items.get(r);
76
+ if (i) {
77
+ n.phase !== void 0 && (i.phase = n.phase);
78
+ return;
79
+ }
80
+ let a = this.ensureItem(n);
81
+ a.phase = n.phase, n.initialParts && (a.parts = n.initialParts.map(t));
82
+ }
83
+ updateItem(e) {
84
+ let n = this.ensureItem(e), r = n.parts.findIndex((t) => t.partId === e.partId);
85
+ if (r < 0) {
86
+ n.parts.push(t(e.part));
87
+ return;
88
+ }
89
+ let i = n.parts[r];
90
+ if (e.op === "replace") {
91
+ n.parts[r] = t(e.part);
92
+ return;
93
+ }
94
+ n.parts[r] = {
95
+ ...i,
96
+ text: `${i.text || ""}${e.part.text || ""}`
97
+ };
98
+ }
99
+ replaceSnapshot(e) {
100
+ let n = this.ensureItem(e);
101
+ n.parts = e.parts.map(t);
102
+ }
103
+ closeItem(e) {
104
+ let n = this.ensureItem(e);
105
+ e.parts && (n.parts = e.parts.map(t)), n.status = e.type === "item_completed" ? "completed" : "failed";
106
+ }
107
+ };
108
+ function r(e, t) {
109
+ return {
110
+ partId: e,
111
+ contentType: "text",
112
+ text: t
113
+ };
114
+ }
115
+ var i = "text-0";
116
+ function a(e, t) {
117
+ return String(e?.id || e?.item_id || t?.item_id || t?.output_index || "");
118
+ }
119
+ function o(e) {
120
+ let t = e?.content;
121
+ return Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : String(e?.text || "")).join("") : String(e?.output_text || e?.text || "");
122
+ }
123
+ function s(e, t, n, s) {
124
+ let c = String(t?.type || e || "").trim(), l = t?.id ? String(t.id) : void 0, u = t?.item || t?.output_item || {}, d = a(u, t), f = String(u?.type || ""), p = f.includes("reasoning") ? "reasoning" : "message";
125
+ if (c === "response.output_item.added") return !d || f !== "message" && !f.includes("reasoning") ? [] : [{
126
+ type: "item_started",
127
+ runId: n,
128
+ scopeId: s,
129
+ itemId: d,
130
+ itemKind: p,
131
+ phase: "final_answer",
132
+ eventId: l
133
+ }];
134
+ if (c === "response.output_text.delta" || c === "response.content_part.delta") {
135
+ if (!d) return [];
136
+ let e = String(t?.delta || t?.text || "");
137
+ return e ? [{
138
+ type: "item_updated",
139
+ runId: n,
140
+ scopeId: s,
141
+ itemId: d,
142
+ itemKind: p,
143
+ partId: i,
144
+ op: t?.replace === !0 ? "replace" : "append",
145
+ part: r(i, e),
146
+ eventId: l
147
+ }] : [];
148
+ }
149
+ return c === "response.output_item.done" || c === "response.output_text.done" ? d ? [{
150
+ type: "item_completed",
151
+ runId: n,
152
+ scopeId: s,
153
+ itemId: d,
154
+ itemKind: p,
155
+ parts: [r(i, o(u) || String(t?.text || ""))],
156
+ eventId: l
157
+ }] : [] : c === "response.completed" ? [{
158
+ type: "run_completed",
159
+ runId: n,
160
+ scopeId: s,
161
+ eventId: l
162
+ }] : [];
163
+ }
164
+ //#endregion
165
+ //#region src/types/json-value.ts
166
+ function c(e) {
167
+ let t = /* @__PURE__ */ new Set(), n = [{ value: e }];
168
+ for (; n.length;) {
169
+ let e = n.pop(), r = e.value;
170
+ if (e.leave) {
171
+ t.delete(r);
172
+ continue;
173
+ }
174
+ if (!(r === null || typeof r == "string" || typeof r == "boolean") && !(typeof r == "number" && Number.isFinite(r))) {
175
+ if (typeof r != "object" || t.has(r) || !Array.isArray(r) && ![Object.prototype, null].includes(Object.getPrototypeOf(r)) || Object.getOwnPropertySymbols(r).length) throw TypeError("答案必须是合法 JSON 值。");
176
+ if (t.add(r), n.push({
177
+ value: r,
178
+ leave: !0
179
+ }), Array.isArray(r)) for (let e = 0; e < r.length; e += 1) n.push({ value: r[e] });
180
+ else for (let e of Object.values(r)) n.push({ value: e });
181
+ }
182
+ }
183
+ return e;
184
+ }
185
+ //#endregion
186
+ //#region src/utils/responses-stream.js
187
+ function l() {
188
+ return {
189
+ toolNames: /* @__PURE__ */ new Map(),
190
+ toolArguments: /* @__PURE__ */ new Map(),
191
+ callIds: /* @__PURE__ */ new Map(),
192
+ currentResponseId: "",
193
+ sawTextDelta: !1,
194
+ sawReasoningDelta: !1
195
+ };
196
+ }
197
+ function u(e) {
198
+ return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e && typeof e == "object" && typeof e.text == "string" ? e.text : "").join("") : e && typeof e == "object" && typeof e.text == "string" ? e.text : "";
199
+ }
200
+ function d(e) {
201
+ return e == null ? "" : typeof e == "string" ? e : typeof e == "object" ? JSON.stringify(e, null, 2) : String(e);
202
+ }
203
+ function f(...e) {
204
+ for (let t of e) {
205
+ let e = u(t);
206
+ if (e) return e;
207
+ }
208
+ return "";
209
+ }
210
+ function p(e, t) {
211
+ return String(e?.id || e?.item_id || e?.call_id || t?.item_id || t?.call_id || t?.output_index || "");
212
+ }
213
+ function m(e, t, n, r, i) {
214
+ t && (e.toolNames.set(t, r), e.toolArguments.set(t, i));
215
+ let a = String(n?.call_id || "");
216
+ a && (e.callIds.set(a, t || r), e.toolNames.set(a, r), e.toolArguments.set(a, i));
217
+ }
218
+ function h(e, t, n, r = "tool") {
219
+ let i = String(n?.call_id || "");
220
+ return String(n?.name || n?.tool_name || (t ? e.toolNames.get(t) : "") || (i ? e.toolNames.get(i) : "") || r);
221
+ }
222
+ function g(e) {
223
+ if (!e || typeof e != "object") return "";
224
+ let t = u(e.content);
225
+ return f(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
226
+ }
227
+ function _(e) {
228
+ let t = e?.response && typeof e.response == "object" ? e.response : e, n = f(t?.output_text, t?.text);
229
+ if (n) return n;
230
+ let r = Array.isArray(t?.output) ? t.output : [];
231
+ for (let e of r) {
232
+ let t = g(e);
233
+ if (t) return t;
234
+ }
235
+ return "";
236
+ }
237
+ function v(e) {
238
+ let t = e?.response && typeof e.response == "object" ? e.response : e;
239
+ return Array.isArray(t?.output) ? t.output : [];
240
+ }
241
+ function y(e) {
242
+ let t = e;
243
+ if (typeof t == "string") try {
244
+ t = JSON.parse(t);
245
+ } catch {
246
+ return {};
247
+ }
248
+ return Array.isArray(t) && (t = t[0] || {}), !t || typeof t != "object" ? {} : t.value && typeof t.value == "object" && !Array.isArray(t.value) ? {
249
+ ...t.value,
250
+ approval_request_id: t.value.approval_request_id || t.value.id || t.id
251
+ } : t;
252
+ }
253
+ function b({ data: e, state: t, status: n }) {
254
+ let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = p(r, e);
255
+ if (i === "function_call") {
256
+ let e = h(t, a, r), i = d(r.arguments ?? r.args ?? r.input);
257
+ return m(t, a, r, e, i), [{
258
+ type: "tool_upsert",
259
+ name: e,
260
+ args: i,
261
+ status: n
262
+ }];
263
+ }
264
+ if (i === "function_call_output") return [{
265
+ type: "tool_result",
266
+ name: h(t, a, r),
267
+ output: d(r.output ?? r.result ?? r.content)
268
+ }];
269
+ if (i === "mcp_user_question") {
270
+ let n = String(r.id || r.question_id || ""), i = Array.isArray(r.questions) ? r.questions : [], a = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
271
+ return [{
272
+ type: "question_request",
273
+ questionId: n,
274
+ questions: i,
275
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
276
+ ...a ? { runId: a } : {}
277
+ }];
278
+ }
279
+ if (i === "mcp_approval_request") {
280
+ let n = String(r.name || "approval"), i = d(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || ""), o = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
281
+ return [{
282
+ type: "tool_upsert",
283
+ name: n,
284
+ args: i,
285
+ status: "paused",
286
+ approvalRequestId: a,
287
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
288
+ serverLabel: String(r.server_label || "")
289
+ }, {
290
+ type: "approval_request",
291
+ approvalRequestId: a,
292
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
293
+ ...o ? { runId: o } : {},
294
+ name: n,
295
+ args: i
296
+ }];
297
+ }
298
+ if (i === "reasoning" || i === "reasoning_summary" || i === "reasoning_summary_text") {
299
+ let e = g(r);
300
+ return e ? [{
301
+ type: "reasoning_delta",
302
+ text: e
303
+ }] : [];
304
+ }
305
+ if (i === "message") {
306
+ let e = g(r);
307
+ return e ? [{
308
+ type: n === "completed" ? "text_final" : "text_delta",
309
+ text: e
310
+ }] : [];
311
+ }
312
+ return [];
313
+ }
314
+ function x({ eventName: e, data: t, state: n }) {
315
+ let r = String(t?.type || e || "").trim(), i = String(t?.id || t?.response?.id || t?.response_id || "");
316
+ if (i.startsWith("resp_") && (n.currentResponseId = i), r === "response.tool_call") return [{
317
+ type: "tool_upsert",
318
+ name: String(t?.name || t?.tool_name || "tool"),
319
+ args: d(t?.args ?? t?.arguments),
320
+ status: "running"
321
+ }];
322
+ if (r === "response.tool_result" || r === "response.ksadk.tool_result") return [{
323
+ type: "tool_result",
324
+ name: String(t?.name || t?.tool_name || "tool"),
325
+ output: d(t?.output ?? t?.result)
326
+ }];
327
+ if (r === "response.output_item.added") return b({
328
+ data: t,
329
+ state: n,
330
+ status: "running"
331
+ });
332
+ if (r === "response.output_item.done") return b({
333
+ data: t,
334
+ state: n,
335
+ status: "completed"
336
+ });
337
+ if (r === "response.function_call_arguments.delta") {
338
+ let e = String(t?.item_id || t?.call_id || ""), r = h(n, e, t), i = `${n.toolArguments.get(e) || ""}${String(t?.delta || "")}`;
339
+ return n.toolArguments.set(e, i), [{
340
+ type: "tool_upsert",
341
+ name: r,
342
+ args: i,
343
+ status: "running"
344
+ }];
345
+ }
346
+ if (r === "response.function_call_arguments.done") {
347
+ let e = String(t?.item_id || t?.call_id || ""), r = h(n, e, t), i = d(t?.arguments ?? n.toolArguments.get(e));
348
+ return n.toolArguments.set(e, i), [{
349
+ type: "tool_upsert",
350
+ name: r,
351
+ args: i,
352
+ status: "running"
353
+ }];
354
+ }
355
+ if (r === "response.reasoning.delta" || r === "response.reasoning_text.delta" || r === "response.reasoning_summary.delta" || r === "response.reasoning_summary_text.delta") {
356
+ let e = f(t?.delta, t?.text);
357
+ return e && (n.sawReasoningDelta = !0), e ? [{
358
+ type: "reasoning_delta",
359
+ text: e
360
+ }] : [];
361
+ }
362
+ if (r === "response.output_text.delta") {
363
+ if (t?.replace === !0 && (typeof t.delta == "string" || typeof t.text == "string")) return n.sawTextDelta = !0, [{
364
+ type: "text_replace",
365
+ text: typeof t.delta == "string" ? t.delta : t.text
366
+ }];
367
+ let e = f(t?.delta, t?.text);
368
+ return e && (n.sawTextDelta = !0), e ? [{
369
+ type: "text_delta",
370
+ text: e
371
+ }] : [];
372
+ }
373
+ if (r === "response.output_text.done") {
374
+ let e = f(t?.text, t?.delta);
375
+ return e ? [{
376
+ type: "text_final",
377
+ text: e
378
+ }] : [];
379
+ }
380
+ if (r === "response.content_part.delta") {
381
+ let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), r = f(t?.delta?.text, t?.delta, t?.text);
382
+ return r ? e.includes("reasoning") ? (n.sawReasoningDelta = !0, [{
383
+ type: "reasoning_delta",
384
+ text: r
385
+ }]) : (n.sawTextDelta = !0, [{
386
+ type: "text_delta",
387
+ text: r
388
+ }]) : [];
389
+ }
390
+ if (r === "response.completed") {
391
+ let e = _(t), r = v(t).flatMap((e) => b({
392
+ data: {
393
+ ...t,
394
+ item: e
395
+ },
396
+ state: n,
397
+ status: "completed"
398
+ })).filter((e) => !(n.sawTextDelta && e.type === "text_final") && !(n.sawReasoningDelta && e.type === "reasoning_delta")), i = r.some((e) => e.type === "text_final");
399
+ return [
400
+ ...r,
401
+ ...e && !n.sawTextDelta && !i ? [{
402
+ type: "text_final",
403
+ text: e
404
+ }] : [],
405
+ {
406
+ type: "terminal",
407
+ status: "completed"
408
+ }
409
+ ];
410
+ }
411
+ if (r === "response.failed") return [{
412
+ type: "failed",
413
+ message: t?.error?.message || "Agent 运行失败"
414
+ }, {
415
+ type: "terminal",
416
+ status: "failed"
417
+ }];
418
+ if (r === "response.incomplete") return [{ type: "incomplete" }, {
419
+ type: "terminal",
420
+ status: "incomplete"
421
+ }];
422
+ if (r === "response.cancelled") return [{
423
+ type: "terminal",
424
+ status: "cancelled"
425
+ }];
426
+ if (r === "response.approval_request" || r === "response.ksadk.approval_request") {
427
+ let e = y(t?.interrupt_info), r = String(e.approval_request_id || e.id || ""), i = String(t?.response_id || n.currentResponseId || ""), a = String(t?.run_id || t?.runId || ""), o = e.approval_requests && typeof e.approval_requests == "object" ? e.approval_requests : e, s = Array.isArray(o.action_requests) ? o.action_requests : [];
428
+ if (s.length > 0) {
429
+ let e = s.map((e) => ({
430
+ type: "tool_upsert",
431
+ name: String(e?.name || "tool"),
432
+ args: JSON.stringify(e?.args ?? {}),
433
+ status: "paused",
434
+ approvalRequestId: r,
435
+ previousResponseId: i
436
+ })), t = s[0] || {};
437
+ return [...e, {
438
+ type: "approval_request",
439
+ approvalRequestId: r,
440
+ previousResponseId: i,
441
+ ...a ? { runId: a } : {},
442
+ name: String(t?.name || "人工确认"),
443
+ args: JSON.stringify(t?.args ?? {})
444
+ }];
445
+ }
446
+ return [{
447
+ type: "approval_request",
448
+ approvalRequestId: r,
449
+ previousResponseId: i,
450
+ ...a ? { runId: a } : {}
451
+ }];
452
+ }
453
+ if (r === "response.question_resolved" || r === "response.ksadk.question_resolved") return [{
454
+ type: "question_resolved",
455
+ questionId: String(t?.question_id || t?.questionId || ""),
456
+ answers: t?.answers && typeof t.answers == "object" ? t.answers : {},
457
+ revision: Number(t?.revision || 2)
458
+ }];
459
+ if (r === "response.approval_resolved" || r === "response.ksadk.approval_resolved") {
460
+ let e = String(t?.decision || t?.outcome || "").toLowerCase(), n = e === "reject" || e === "rejected" || e === "denied" ? "rejected" : e === "cancel" || e === "cancelled" || e === "canceled" ? "cancelled" : "approved";
461
+ return [{
462
+ type: "approval_resolved",
463
+ approvalRequestId: String(t?.approval_request_id || t?.approvalRequestId || t?.approval_id || t?.approvalId || ""),
464
+ decision: n,
465
+ revision: Number(t?.revision || 2)
466
+ }];
467
+ }
468
+ if (new Set([
469
+ "response.ksadk.a2ui_surface_begin",
470
+ "a2ui.surface.begin",
471
+ "response.a2ui.createSurface",
472
+ "a2ui.createSurface",
473
+ "createSurface"
474
+ ]).has(r)) {
475
+ let e = t?.surface && typeof t.surface == "object" ? t.surface : {};
476
+ return [{
477
+ type: "a2ui_surface_begin",
478
+ surfaceId: String(t?.surface_id || t?.surfaceId || e.surface_id || e.surfaceId || ""),
479
+ surface: e
480
+ }];
481
+ }
482
+ if (new Set([
483
+ "response.ksadk.a2ui_surface_update",
484
+ "a2ui.surface.update",
485
+ "response.a2ui.updateComponents",
486
+ "a2ui.updateComponents",
487
+ "updateComponents"
488
+ ]).has(r)) {
489
+ let e = t?.surface && typeof t.surface == "object" ? t.surface : {};
490
+ return [{
491
+ type: "a2ui_surface_update",
492
+ surfaceId: String(t?.surface_id || t?.surfaceId || e.surface_id || e.surfaceId || ""),
493
+ surface: e
494
+ }];
495
+ }
496
+ if (new Set([
497
+ "response.ksadk.a2ui_surface_end",
498
+ "a2ui.surface.end",
499
+ "response.a2ui.deleteSurface",
500
+ "a2ui.deleteSurface",
501
+ "deleteSurface"
502
+ ]).has(r)) return [{
503
+ type: "a2ui_surface_end",
504
+ surfaceId: String(t?.surface_id || t?.surfaceId || "")
505
+ }];
506
+ if (new Set(["response.ksadk.a2ui_interaction", "a2ui.interaction"]).has(r)) return [{
507
+ type: "a2ui_interaction",
508
+ surfaceId: String(t?.surface_id || t?.surfaceId || ""),
509
+ interactionId: String(t?.interaction_id || t?.interactionId || ""),
510
+ kind: String(t?.kind || "input"),
511
+ inputSchema: t?.input_schema && typeof t.input_schema == "object" ? t.input_schema : {}
512
+ }];
513
+ let a = t?.content?.parts?.[0]?.text;
514
+ return a && !t?.actions?.finishReason ? [{
515
+ type: "text_delta",
516
+ text: String(a)
517
+ }] : [];
518
+ }
519
+ //#endregion
520
+ //#region src/utils/tool-display.js
521
+ function ee(e) {
522
+ return String(e || "").replace(/\\u([0-9a-fA-F]{4})/g, (e, t) => String.fromCharCode(Number.parseInt(t, 16)));
523
+ }
524
+ function S(e) {
525
+ let t = String(e || "").trim();
526
+ for (let e = 0; e < 3; e += 1) {
527
+ if (!t) return t;
528
+ let e = t[0], n = t[t.length - 1];
529
+ if (!(e === "{" && n === "}" || e === "[" && n === "]" || e === "\"" && n === "\"")) return t.replace(/\\n/g, "\n").replace(/\\"/g, "\"");
530
+ try {
531
+ let e = JSON.parse(t);
532
+ if (typeof e != "string") return C(e);
533
+ t = e.trim();
534
+ } catch {
535
+ return ee(t).replace(/\\n/g, "\n").replace(/\\"/g, "\"");
536
+ }
537
+ }
538
+ return t;
539
+ }
540
+ function C(e) {
541
+ return typeof e == "string" ? S(e) : Array.isArray(e) ? e.map((e) => C(e)) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, C(t)]));
542
+ }
543
+ function w(e) {
544
+ return typeof e == "string" ? S(e) : C(e);
545
+ }
546
+ function T(e) {
547
+ return e === !1 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "false" : !1;
548
+ }
549
+ function E(e) {
550
+ return e === !0 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "true" : !1;
551
+ }
552
+ function D(e) {
553
+ return e == null || e === !1 ? !1 : typeof e == "string" ? e.trim().length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
554
+ }
555
+ function te(e) {
556
+ return String(e?.status || "").trim().toLowerCase() === "accepted_not_extracted";
557
+ }
558
+ function O(e, t = 0) {
559
+ if (!e || t > 4) return !1;
560
+ if (typeof e == "string") {
561
+ let n = S(e);
562
+ return n !== e && O(n, t + 1);
563
+ }
564
+ if (Array.isArray(e)) return e.some((e) => O(e, t + 1));
565
+ if (typeof e != "object" || te(e)) return !1;
566
+ if (T(e.ok) || T(e.success)) return !0;
567
+ let n = E(e.ok) || E(e.success), r = String(e.status || "").trim().toLowerCase();
568
+ return !n && [
569
+ "error",
570
+ "failed",
571
+ "failure"
572
+ ].includes(r) || !n && (D(e.error_type) || D(e.error_message) || D(e.error)) ? !0 : Object.values(e).some((e) => O(e, t + 1));
573
+ }
574
+ function k(e) {
575
+ return e == null || e === "" ? !1 : O(w(e));
576
+ }
577
+ function ne(e) {
578
+ if (e == null || e === "") return "";
579
+ let t = w(e);
580
+ return typeof t == "string" ? t : JSON.stringify(t, null, 2);
581
+ }
582
+ //#endregion
583
+ //#region src/utils/session-events.js
584
+ var A = new Set([
585
+ "completed",
586
+ "failed",
587
+ "error",
588
+ "cancelled",
589
+ "canceled",
590
+ "aborted",
591
+ "interrupted",
592
+ "resume_failed"
593
+ ]), j = new Set([
594
+ "tool_call",
595
+ "tool_result",
596
+ "stage_tool_call",
597
+ "stage_tool_result"
598
+ ]), M = {
599
+ "run.started": "in_progress",
600
+ "run.progress": "in_progress",
601
+ "run.interrupted": "interrupted",
602
+ "run.completed": "completed",
603
+ "run.failed": "failed",
604
+ "run.canceled": "cancelled"
605
+ };
606
+ function N(e) {
607
+ let t = e?.Content?.payload;
608
+ return t && typeof t == "object" ? t : {};
609
+ }
610
+ function re(e, t) {
611
+ let n = String(e || ""), r = String(t || "");
612
+ return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
613
+ }
614
+ function ie(e) {
615
+ let t = String(e?.EventType || ""), n = N(e);
616
+ return M[t] ? {
617
+ ...e,
618
+ EventType: "run_status",
619
+ Content: {
620
+ status: String(n.status || M[t]),
621
+ ...n.detail ? { detail: String(n.detail) } : {}
622
+ }
623
+ } : t === "reasoning.delta" || t === "reasoning.completed" ? {
624
+ ...e,
625
+ EventType: "reasoning",
626
+ Content: {
627
+ role: "model",
628
+ parts: [{ text: String(n.text || "") }]
629
+ }
630
+ } : t === "tool.call.begin" ? {
631
+ ...e,
632
+ EventType: "tool_call",
633
+ Metadata: {
634
+ ...e.Metadata || {},
635
+ tool_name: n.name,
636
+ tool_args: n.args,
637
+ tool_call_id: n.call_id
638
+ },
639
+ Content: {
640
+ role: "model",
641
+ parts: []
642
+ }
643
+ } : t === "tool.call.end" ? {
644
+ ...e,
645
+ EventType: "tool_result",
646
+ Metadata: {
647
+ ...e.Metadata || {},
648
+ tool_name: n.name,
649
+ tool_output: n.error || n.result,
650
+ tool_call_id: n.call_id
651
+ },
652
+ Content: {
653
+ role: "model",
654
+ parts: []
655
+ }
656
+ } : e;
657
+ }
658
+ function ae(e) {
659
+ let t = [], n = /* @__PURE__ */ new Map();
660
+ for (let r of Array.isArray(e) ? e : []) {
661
+ let e = String(r?.EventType || "");
662
+ if (e === "text.delta" || e === "text.completed" || e === "message.delta") {
663
+ let e = String(r?.InvocationId || "").trim();
664
+ if (!e) continue;
665
+ let t = n.get(e);
666
+ n.set(e, {
667
+ event: r,
668
+ text: re(t?.text, N(r).text || r?.Content?.text)
669
+ });
670
+ continue;
671
+ }
672
+ t.push(ie(r));
673
+ }
674
+ for (let { event: e, text: r } of n.values()) t.push({
675
+ ...e,
676
+ EventType: "assistant_stream_snapshot",
677
+ Content: {
678
+ role: "model",
679
+ parts: [{ text: r }]
680
+ },
681
+ Metadata: {
682
+ ...e.Metadata || {},
683
+ stream_snapshot: !0
684
+ }
685
+ });
686
+ for (let n of Array.isArray(e) ? e : []) String(n?.EventType || "") === "message.completed" && t.push({
687
+ ...n,
688
+ EventType: "assistant_message",
689
+ Content: {
690
+ role: "model",
691
+ parts: [{ text: String(N(n).text || n?.Content?.text || "") }]
692
+ }
693
+ });
694
+ return t.sort((e, t) => G(e) - G(t));
695
+ }
696
+ function P(e) {
697
+ let t = String(e?.EventType || "").trim();
698
+ if (t !== "run_status" && !t.startsWith("run.")) return "";
699
+ let n = N(e);
700
+ return String(e?.Content?.status || n.status || M[t] || "").trim().toLowerCase();
701
+ }
702
+ function F(e) {
703
+ return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e && typeof e == "object" && typeof e.text == "string" ? e.text : "").join("") : "";
704
+ }
705
+ function I(e) {
706
+ let t = String(e || "").trim();
707
+ return t ? `/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}` : "";
708
+ }
709
+ function L(e) {
710
+ return String(e || "").match(/^data:([^;,]+)/)?.[1] || "";
711
+ }
712
+ function oe(e, t) {
713
+ let n = String(e || "").trim(), r = String(t || "").trim();
714
+ return !n || !r || n === r ? !0 : n.endsWith("/*") ? r.startsWith(n.slice(0, -1)) : r.endsWith("/*") ? n.startsWith(r.slice(0, -1)) : !1;
715
+ }
716
+ function R(e) {
717
+ let t = e?.Content?.parts || [], n = [], r = /* @__PURE__ */ new Map(), i = (e) => {
718
+ let t = `${e.fileUri || e.url || e.name}|${e.type}`;
719
+ r.has(t) || r.set(t, e);
720
+ };
721
+ for (let e of t) {
722
+ if (e?.type === "input_text" || e?.text) {
723
+ n.push(e.text || "");
724
+ continue;
725
+ }
726
+ if (e?.type === "input_file" && e.inlineData) {
727
+ i({
728
+ name: e.inlineData.displayName || "attachment",
729
+ url: `data:${e.inlineData.mimeType || "application/octet-stream"};base64,${e.inlineData.data}`,
730
+ type: e.inlineData.mimeType || "application/octet-stream"
731
+ });
732
+ continue;
733
+ }
734
+ if (e?.type === "input_file" && typeof e.file_data == "string" && e.file_data) {
735
+ i({
736
+ name: e.filename || e.displayName || e.display_name || "attachment",
737
+ url: `data:${e.mime_type || e.mimeType || "application/octet-stream"};base64,${e.file_data}`,
738
+ type: e.mime_type || e.mimeType || "application/octet-stream"
739
+ });
740
+ continue;
741
+ }
742
+ if (e?.type === "input_file" && typeof e.file_url == "string" && e.file_url.trim()) {
743
+ let t = e.file_url.trim();
744
+ i({
745
+ name: e.filename || e.displayName || e.display_name || "attachment",
746
+ url: I(t),
747
+ type: e.mime_type || e.mimeType || "application/octet-stream",
748
+ fileUri: t
749
+ });
750
+ continue;
751
+ }
752
+ if (e?.type === "input_image" || e?.type === "image_url") {
753
+ let t = typeof e.image_url == "string" ? e.image_url : e.image_url?.url;
754
+ t && i({
755
+ name: e.filename || e.displayName || e.display_name || "uploaded_image",
756
+ url: t,
757
+ type: e.mime_type || e.mimeType || L(t) || "image/*"
758
+ });
759
+ continue;
760
+ }
761
+ if (e?.type === "input_file" && e.fileData) {
762
+ let t = String(e.fileData.fileUri || "").trim();
763
+ i({
764
+ name: e.fileData.displayName || "attachment",
765
+ url: I(t),
766
+ type: e.fileData.mimeType || "application/octet-stream",
767
+ fileUri: t
768
+ });
769
+ }
770
+ }
771
+ let a = Array.isArray(e?.Metadata?.attachments) ? e.Metadata.attachments : [];
772
+ for (let e of a) {
773
+ let t = String(e.file_uri || "").trim(), n = {
774
+ name: e.display_name || "attachment",
775
+ url: I(t),
776
+ type: e.mime_type || "application/octet-stream",
777
+ fileUri: t
778
+ };
779
+ !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && oe(e.type, n.type) && (e.url || e.fileUri)) || i(n);
780
+ }
781
+ let o = Array.from(r.values());
782
+ return {
783
+ text: n.join(""),
784
+ attachments: o.length > 0 ? o : void 0
785
+ };
786
+ }
787
+ function se(e) {
788
+ let t = e?.Metadata?.responses_output;
789
+ if (!Array.isArray(t)) return {};
790
+ let n = l(), r = x({
791
+ eventName: "response.completed",
792
+ data: { response: {
793
+ id: String(e.Metadata?.response_id || ""),
794
+ output: t
795
+ } },
796
+ state: n
797
+ }), i = "", a = {};
798
+ for (let e of r) {
799
+ if (e.type === "reasoning_delta") {
800
+ i += e.text;
801
+ continue;
802
+ }
803
+ if (e.type === "tool_upsert") {
804
+ a[e.name] = {
805
+ ...a[e.name] || {
806
+ name: e.name,
807
+ args: ""
808
+ },
809
+ name: e.name,
810
+ args: e.args,
811
+ status: e.status,
812
+ ...e.approvalRequestId ? { approvalRequestId: e.approvalRequestId } : {},
813
+ ...e.previousResponseId ? { previousResponseId: e.previousResponseId } : {},
814
+ ...e.serverLabel ? { serverLabel: e.serverLabel } : {},
815
+ ...e.approvalRequestId ? { approvalStatus: "pending" } : {}
816
+ };
817
+ continue;
818
+ }
819
+ e.type === "tool_result" && (a[e.name] = {
820
+ ...a[e.name] || {
821
+ name: e.name,
822
+ args: ""
823
+ },
824
+ name: e.name,
825
+ output: e.output,
826
+ status: k(e.output) ? "error" : "completed"
827
+ });
828
+ }
829
+ return {
830
+ ...i ? { reasoning: i } : {},
831
+ ...Object.keys(a).length > 0 ? { tools: a } : {}
832
+ };
833
+ }
834
+ function ce(e, t, n) {
835
+ return t === "running" ? e === "prompt_too_long" ? "检测到上下文过长,正在自动压缩历史后重试" : "正在自动压缩上下文" : n ? e === "prompt_too_long" ? "上下文过长,系统已自动压缩历史并重试" : "系统已自动压缩较早的对话上下文" : t === "failed" ? "自动压缩上下文未完成" : e === "prompt_too_long" ? "已完成上下文压缩,并继续当前回复" : "已完成上下文压缩";
836
+ }
837
+ function z(e, t) {
838
+ return t?.itemId ? [
839
+ "runtime-item",
840
+ t.runId || e,
841
+ t.scopeId || e,
842
+ t.itemId
843
+ ].join("\0") : [
844
+ e,
845
+ t.content || "",
846
+ t.reasoning || ""
847
+ ].join("\0");
848
+ }
849
+ function B(e) {
850
+ let t = String(e?.InvocationId || "").trim(), n = e?.Metadata?.RuntimeItem;
851
+ return n?.ItemId ? [
852
+ "runtime-item",
853
+ n.RunId || t,
854
+ n.ScopeId || t,
855
+ n.ItemId
856
+ ].join("\0") : t;
857
+ }
858
+ function V(e) {
859
+ let t = e?.Metadata?.RuntimeItem;
860
+ return t?.ItemId ? {
861
+ id: `runtime:${t.RunId || e.InvocationId || "run"}:${t.ScopeId || e.InvocationId || "scope"}:${t.ItemId}`,
862
+ runId: String(t.RunId || e.InvocationId || ""),
863
+ scopeId: String(t.ScopeId || e.InvocationId || ""),
864
+ itemId: String(t.ItemId),
865
+ partId: t.PartId ? String(t.PartId) : void 0
866
+ } : null;
867
+ }
868
+ function H(e) {
869
+ return e?.Metadata?.responses_mirror === !0 || String(e?.Metadata?.responses_mirror || "").trim().toLowerCase() === "true";
870
+ }
871
+ function U(e) {
872
+ if (e?.EventType !== "user_message") return "";
873
+ let t = R(e), n = (t.attachments || []).map((e) => [
874
+ e.name || "",
875
+ e.fileUri || "",
876
+ e.url || "",
877
+ e.type || ""
878
+ ].join("")).sort().join("");
879
+ return [String(t.text || "").trim(), n].join("\0");
880
+ }
881
+ function W(e) {
882
+ return e?.EventType === "assistant_stream_snapshot";
883
+ }
884
+ function G(e) {
885
+ let t = Number(e?.SeqId || 0);
886
+ if (Number.isFinite(t) && t > 0) return t;
887
+ let n = Number(e?.Timestamp || 0);
888
+ return Number.isFinite(n) ? n : 0;
889
+ }
890
+ function K(e) {
891
+ if (typeof e == "string") return e;
892
+ if (e == null) return "";
893
+ try {
894
+ return JSON.stringify(e, null, 2);
895
+ } catch {
896
+ return String(e);
897
+ }
898
+ }
899
+ function le(e) {
900
+ let t = String(e?.EventType || "");
901
+ if (!j.has(t)) return null;
902
+ let n = String(e.Metadata?.tool_name || e.Metadata?.name || e.Metadata?.function_name || F(e.Content?.parts) || "tool").trim() || "tool", r = String(e.Metadata?.call_id || e.Metadata?.callId || e.Metadata?.RuntimeItem?.ToolCallId || "").trim(), i = {
903
+ name: n,
904
+ ...r ? { callId: r } : {},
905
+ args: "",
906
+ status: "running"
907
+ }, a = t === "tool_result" || t === "stage_tool_result" ? (() => {
908
+ let t = K(e.Metadata?.tool_output ?? e.Metadata?.output ?? e.Metadata?.result ?? F(e.Content?.parts));
909
+ return {
910
+ ...i,
911
+ output: t,
912
+ status: k(t) ? "error" : "completed"
913
+ };
914
+ })() : {
915
+ ...i,
916
+ args: K(e.Metadata?.tool_args ?? e.Metadata?.arguments ?? e.Metadata?.args ?? {})
917
+ }, o = V(e);
918
+ return {
919
+ id: o?.id || e.EventId || String(Date.now() + Math.random()),
920
+ role: "model",
921
+ content: "",
922
+ timestamp: e.Timestamp || Date.now(),
923
+ eventType: t,
924
+ ...o || {},
925
+ tools: { [n]: a }
926
+ };
927
+ }
928
+ function q(e = {}, t = {}) {
929
+ let n = { ...e || {} };
930
+ for (let [e, r] of Object.entries(t || {})) n[e] = {
931
+ ...n[e] || {},
932
+ ...r || {},
933
+ name: e,
934
+ args: r?.args || n[e]?.args || ""
935
+ };
936
+ return n;
937
+ }
938
+ function J(e = {}, t = "") {
939
+ let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : A.has(n) ? "error" : "";
940
+ if (!r) return e;
941
+ let i = !1, a = {};
942
+ for (let [t, n] of Object.entries(e || {})) n?.status === "running" ? (i = !0, a[t] = {
943
+ ...n,
944
+ status: r
945
+ }) : a[t] = n;
946
+ return i ? a : e;
947
+ }
948
+ function Y(e, t) {
949
+ return {
950
+ ...e,
951
+ reasoning: X(e.reasoning, t.reasoning),
952
+ tools: q(e.tools, t.tools),
953
+ eventId: t.eventId || e.eventId,
954
+ responseId: t.responseId || e.responseId,
955
+ traceId: t.traceId || e.traceId,
956
+ rootSpanId: t.rootSpanId || e.rootSpanId,
957
+ timestamp: Math.max(Number(e.timestamp || 0), Number(t.timestamp || 0)) || t.timestamp || e.timestamp,
958
+ id: t.responseId || t.reasoning || t.tools ? t.id : e.id
959
+ };
960
+ }
961
+ function X(e = "", t = "") {
962
+ let n = String(e || ""), r = String(t || "");
963
+ return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
964
+ }
965
+ function Z(e) {
966
+ return {
967
+ id: e.id,
968
+ role: "system",
969
+ eventType: "context_checkpoint",
970
+ status: e.status,
971
+ trigger: e.trigger,
972
+ compactedUntilSeqId: e.compactedUntilSeqId,
973
+ summary: e.summary,
974
+ historical: e.historical,
975
+ timestamp: e.timestamp,
976
+ content: ce(e.trigger, e.status, e.historical)
977
+ };
978
+ }
979
+ function Q(e) {
980
+ let t = $(e);
981
+ return t && Number.isSafeInteger(e.SeqId) && e.SeqId > 0 && (t.historyOrder = { seq: e.SeqId }), t;
982
+ }
983
+ function $(e) {
984
+ let t = e?.EventType || "", n = V(e);
985
+ if (t === "run_status") return e.Content?.status === "failed" ? {
986
+ id: e.EventId || String(Date.now() + Math.random()),
987
+ role: "system",
988
+ content: e.Content?.detail || "本轮运行失败。",
989
+ eventType: t,
990
+ status: "failed",
991
+ timestamp: e.Timestamp || Date.now()
992
+ } : e.Content?.status === "cancelled" ? {
993
+ id: e.EventId || String(Date.now() + Math.random()),
994
+ role: "system",
995
+ content: e.Content?.detail || "本轮输出已停止。",
996
+ eventType: t,
997
+ status: "cancelled",
998
+ timestamp: e.Timestamp || Date.now()
999
+ } : null;
1000
+ if (t === "context_checkpoint") {
1001
+ let t = R(e);
1002
+ return Z({
1003
+ id: e.EventId || String(Date.now() + Math.random()),
1004
+ timestamp: e.Timestamp || Date.now(),
1005
+ status: "completed",
1006
+ trigger: String(e.Metadata?.trigger || "auto"),
1007
+ compactedUntilSeqId: Number(e.Metadata?.compacted_until_seq_id || 0) || void 0,
1008
+ summary: t.text || void 0,
1009
+ historical: !0
1010
+ });
1011
+ }
1012
+ if (t === "reasoning") {
1013
+ let r = R(e).text || F(e.Metadata?.reasoning);
1014
+ return r ? {
1015
+ id: n?.id || e.EventId || String(Date.now() + Math.random()),
1016
+ role: "model",
1017
+ content: "",
1018
+ reasoning: r,
1019
+ ...e.Metadata?.presentation_source === "public_summary" ? { reasoningSource: "public_summary" } : e.Metadata?.presentation_source === "provider_reasoning" ? { reasoningSource: "provider_reasoning" } : {},
1020
+ timestamp: e.Timestamp || Date.now(),
1021
+ eventType: t,
1022
+ ...n || {}
1023
+ } : null;
1024
+ }
1025
+ if (j.has(t)) return le(e);
1026
+ if (t !== "user_message" && t !== "assistant_message" && t !== "assistant_stream_snapshot") return null;
1027
+ let r = R(e), i = t === "assistant_message" ? se(e) : {};
1028
+ if (!r.text && !r.attachments?.length && !i.reasoning && !i.tools) return null;
1029
+ let a = String(e.Metadata?.response_id || e.Metadata?.ResponseId || "").trim(), o = String(e.Metadata?.trace_id || e.Metadata?.TraceId || "").trim(), s = String(e.Metadata?.root_span_id || e.Metadata?.rootSpanId || e.Metadata?.RootSpanId || "").trim();
1030
+ return {
1031
+ id: n?.id || e.EventId || String(Date.now() + Math.random()),
1032
+ role: t === "user_message" ? "user" : "model",
1033
+ content: r.text,
1034
+ timestamp: e.Timestamp || Date.now(),
1035
+ eventType: t,
1036
+ eventId: e.EventId || void 0,
1037
+ responseId: a || void 0,
1038
+ traceId: o || void 0,
1039
+ rootSpanId: s || void 0,
1040
+ attachments: r.attachments,
1041
+ ...n || {},
1042
+ ...i
1043
+ };
1044
+ }
1045
+ function ue(e = []) {
1046
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = ae(e), c = [];
1047
+ for (let e of s) {
1048
+ let t = String(e?.EventId || "").trim();
1049
+ if (t) {
1050
+ if (o.has(t)) continue;
1051
+ o.add(t);
1052
+ }
1053
+ c.push(e);
1054
+ }
1055
+ let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
1056
+ for (let e of c) {
1057
+ if (e?.EventType !== "user_message" || H(e)) {
1058
+ if (e?.EventType === "assistant_message") {
1059
+ let t = B(e);
1060
+ t && u.add(t);
1061
+ }
1062
+ if (W(e)) {
1063
+ let t = B(e);
1064
+ if (t) {
1065
+ let n = d.get(t);
1066
+ (!n || G(e) >= G(n)) && d.set(t, e);
1067
+ }
1068
+ }
1069
+ continue;
1070
+ }
1071
+ let t = U(e);
1072
+ t && l.add(t);
1073
+ }
1074
+ let f = c.filter((e) => {
1075
+ if (W(e)) {
1076
+ let t = B(e);
1077
+ return t ? u.has(t) ? !1 : d.get(t) === e : !0;
1078
+ }
1079
+ if (e?.EventType !== "user_message" || !H(e)) return !0;
1080
+ let t = U(e);
1081
+ return !t || !l.has(t);
1082
+ });
1083
+ for (let e of f) {
1084
+ let a = String(e.InvocationId || "").trim();
1085
+ a && e.EventType === "user_message" && i.add(a), a && [
1086
+ "assistant_message",
1087
+ "assistant_stream_snapshot",
1088
+ "reasoning",
1089
+ "tool_call",
1090
+ "tool_result",
1091
+ "stage_tool_call",
1092
+ "stage_tool_result"
1093
+ ].includes(String(e.EventType || "")) && r.add(a), e.EventType === "run_status" && a && (t.set(a, String(e.Content?.status || "").trim()), n.set(a, e));
1094
+ }
1095
+ let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = /* @__PURE__ */ new Map(), v = (e) => {
1096
+ let t = e?.itemId ? `${e.runId || e.invocationId || ""}\u0000${e.scopeId || e.invocationId || ""}\u0000${e.itemId}` : "", n = t ? h.get(t) : void 0;
1097
+ if (n !== void 0) {
1098
+ p[n] = Y(p[n], e);
1099
+ return;
1100
+ }
1101
+ let r = String(e?.responseId || "").trim(), i = r ? m.get(r) : void 0;
1102
+ if (i !== void 0) {
1103
+ p[i] = Y(p[i], e);
1104
+ return;
1105
+ }
1106
+ r && m.set(r, p.length), t && h.set(t, p.length), p.push(e);
1107
+ }, y = () => {
1108
+ g &&= (v(g), null);
1109
+ }, b = (e, n = "") => {
1110
+ let r = String(e || "").trim();
1111
+ if (!r) return {};
1112
+ let i = _.get(r);
1113
+ return i ? (_.delete(r), { tools: J(i.tools, t.get(r) || n) }) : {};
1114
+ };
1115
+ for (let e of f) {
1116
+ if (e.EventType === "run_status") continue;
1117
+ let t = Q(e);
1118
+ if (!t) continue;
1119
+ let n = String(e.InvocationId || "").trim();
1120
+ if (n && (t.invocationId = n), j.has(t.eventType)) {
1121
+ let n = String(e.InvocationId || "").trim();
1122
+ if (t.itemId) {
1123
+ y(), v(t);
1124
+ continue;
1125
+ }
1126
+ if (!n) {
1127
+ y(), v(t);
1128
+ continue;
1129
+ }
1130
+ let r = _.get(n);
1131
+ _.set(n, {
1132
+ ...r || {
1133
+ id: t.id,
1134
+ role: "model",
1135
+ content: "",
1136
+ timestamp: t.timestamp,
1137
+ invocationId: n
1138
+ },
1139
+ timestamp: Math.max(Number(r?.timestamp || 0), Number(t.timestamp || 0)),
1140
+ tools: q(r?.tools, t.tools)
1141
+ });
1142
+ continue;
1143
+ }
1144
+ if (t.eventType === "reasoning") {
1145
+ let n = String(e.InvocationId || "").trim(), r = String(e.Metadata?.RuntimeItem?.Operation || "").toLowerCase(), i = !!(t.itemId && g?.itemId === t.itemId && g?.runId === t.runId && g?.scopeId === t.scopeId), a = !!(!t.itemId && !g?.itemId && n && g?.invocationId === n);
1146
+ if (g && (i || a)) {
1147
+ g.reasoning = r === "replace" || r === "completed" ? t.reasoning : `${g.reasoning || ""}${t.reasoning || ""}`, g.timestamp = t.timestamp;
1148
+ continue;
1149
+ }
1150
+ y(), g = {
1151
+ ...t,
1152
+ ...n ? { invocationId: n } : {}
1153
+ };
1154
+ continue;
1155
+ }
1156
+ let r = t.eventType === "assistant_message" || t.eventType === "assistant_stream_snapshot";
1157
+ if (r && g) {
1158
+ let n = String(e.InvocationId || "").trim(), r = z(n, t);
1159
+ if (t.eventType === "assistant_message" && n && a.has(r)) {
1160
+ g = null;
1161
+ continue;
1162
+ }
1163
+ t.eventType === "assistant_message" && n && a.add(r), v({
1164
+ ...t,
1165
+ ...b(n, t.eventType === "assistant_message" ? "completed" : ""),
1166
+ reasoning: X(g.reasoning, t.reasoning)
1167
+ }), g = null;
1168
+ continue;
1169
+ }
1170
+ if (y(), r) {
1171
+ let n = String(e.InvocationId || "").trim(), r = z(n, t);
1172
+ if (t.eventType === "assistant_message" && n && a.has(r)) continue;
1173
+ t.eventType === "assistant_message" && n && a.add(r), v({
1174
+ ...t,
1175
+ ...b(n, t.eventType === "assistant_message" ? "completed" : "")
1176
+ });
1177
+ continue;
1178
+ }
1179
+ v(t);
1180
+ }
1181
+ y();
1182
+ for (let [e, n] of _.entries()) v({
1183
+ ...n,
1184
+ tools: J(n.tools, t.get(e))
1185
+ });
1186
+ for (let [e, a] of t.entries()) {
1187
+ if (a !== "in_progress" || r.has(e) || !i.has(e)) continue;
1188
+ let t = n.get(e) || {};
1189
+ v({
1190
+ id: `run-placeholder-${e}`,
1191
+ role: "model",
1192
+ content: "",
1193
+ status: "running",
1194
+ eventType: "run_status",
1195
+ timestamp: t.Timestamp || Date.now()
1196
+ });
1197
+ }
1198
+ return p;
1199
+ }
1200
+ function de(e = [], t = []) {
1201
+ let n = [], r = /* @__PURE__ */ new Set();
1202
+ for (let i of [...Array.isArray(e) ? e : [], ...Array.isArray(t) ? t : []]) {
1203
+ let e = String(i?.EventId || "").trim();
1204
+ if (e) {
1205
+ if (r.has(e)) continue;
1206
+ r.add(e);
1207
+ }
1208
+ n.push(i);
1209
+ }
1210
+ return n.sort((e, t) => {
1211
+ let n = Number(e?.SeqId || 0), r = Number(t?.SeqId || 0);
1212
+ return Number.isFinite(n) && Number.isFinite(r) && n !== r ? n - r : Number(e?.Timestamp || 0) - Number(t?.Timestamp || 0);
1213
+ });
1214
+ }
1215
+ function fe(e = []) {
1216
+ return (Array.isArray(e) ? e : []).reduce((e, t) => {
1217
+ let n = Number(t.SeqId || 0);
1218
+ return Number.isFinite(n) ? Math.max(e, n) : e;
1219
+ }, 0);
1220
+ }
1221
+ function pe(e) {
1222
+ return A.has(P(e));
1223
+ }
1224
+ //#endregion
1225
+ export { fe as a, ne as c, x as d, c as f, pe as i, k as l, s as m, Q as n, de as o, n as p, ue as r, P as s, Z as t, l as u };