@kingsoftcloud/ksadk-web 0.3.7 → 0.3.9

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 +6 -0
  2. package/RELEASE_PROVENANCE.json +2 -2
  3. package/dist-ksadk/assets/{ArtifactsPanel-CGbWlMNh.js → ArtifactsPanel-BPpNPGID.js} +1 -1
  4. package/dist-ksadk/assets/{CodeBlock-b4C7upmO.js → CodeBlock-Ds5vf0vb.js} +10 -7
  5. package/dist-ksadk/assets/MathMessageMarkdown-DiObfQyu.js +8 -0
  6. package/dist-ksadk/assets/{MermaidBlock-BEBN4Ksz.js → MermaidBlock-D7rbvY87.js} +9 -9
  7. package/dist-ksadk/assets/{NativeTerminalPanel-zvL-WpAn.js → NativeTerminalPanel-DU4dms0x.js} +1 -1
  8. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-BYafW7Za.js → abnfDiagram-VCTEODGH-CPEZNrp6.js} +1 -1
  9. package/dist-ksadk/assets/{arc-bTohInsS.js → arc-SmcBsmpk.js} +1 -1
  10. package/dist-ksadk/assets/architecture-7GRP2DOG-BB6Hc16V.js +1 -0
  11. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-Ch5Lbzsi.js → architectureDiagram-5GKGNRK7-DczwkdRf.js} +1 -1
  12. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-kqF4MDOG.js → blockDiagram-NRAW4CY4-DOH-lQsK.js} +1 -1
  13. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-8uSRIODv.js → c4Diagram-UCG6FXSJ-DDqa-d5a.js} +1 -1
  14. package/dist-ksadk/assets/channel-D_LgMO6N.js +1 -0
  15. package/dist-ksadk/assets/chunk-2Q5K7J3B-CzuaVSxD.js +1 -0
  16. package/dist-ksadk/assets/{chunk-5VM5RSS4-DkhehZDr.js → chunk-5VM5RSS4-BRbyQMbk.js} +1 -1
  17. package/dist-ksadk/assets/{chunk-F27PBJKO-BdXhtPe9.js → chunk-F27PBJKO-DC03vp6H.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-G27WJ6UU-DPTpvpwi.js → chunk-G27WJ6UU-DsFJlOsn.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-JWPE2WC7-Pqoh38el.js → chunk-JWPE2WC7-B03qL1Z_.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-LCL6LL3I-DeU00qC-.js → chunk-LCL6LL3I-BbKJcRob.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-POPQ4Y6H-CzxScFkr.js → chunk-POPQ4Y6H-B7_CA3-V.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-RHFEMEQ7-DpqMx-ux.js → chunk-RHFEMEQ7-CEWTfYzF.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-SVP7TREG-C6t0SypQ.js → chunk-SVP7TREG-C9e3delk.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-XXDRQBXY-DVaeafZk.js → chunk-XXDRQBXY-_Ym5ccEC.js} +1 -1
  25. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-CZOWJyrI.js +1 -0
  26. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-CZOWJyrI.js +1 -0
  27. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-Bf9D3tzJ.js → cose-bilkent-JH36ORCC-B6yMcByQ.js} +1 -1
  28. package/dist-ksadk/assets/cynefin-OW5HDTMX-BBxC9wl_.js +1 -0
  29. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-B9cY3iTz.js → cynefinDiagram-5FMLGOSQ-B1MVQxq-.js} +1 -1
  30. package/dist-ksadk/assets/{dagre-3AP2YEHR-CSwlx3CB.js → dagre-3AP2YEHR-LeImiTSm.js} +1 -1
  31. package/dist-ksadk/assets/{dagre-UBpgon5q.js → dagre-BUWpUaQH.js} +1 -1
  32. package/dist-ksadk/assets/{diagram-S7CK7UJ4-C9akhN9a.js → diagram-S7CK7UJ4-gvIKXdfF.js} +1 -1
  33. package/dist-ksadk/assets/{diagram-UQ7AKVKN-CgedhTPI.js → diagram-UQ7AKVKN-Bns2BbiH.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-VSXAHHWV-Cjucz5BY.js → diagram-VSXAHHWV-OKsO2R1h.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-VX7I27RA-Dd4Vleyn.js → diagram-VX7I27RA-pY0oKM38.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-Z3DM3KII-CZ2jGtYW.js → diagram-Z3DM3KII-DohYTiXC.js} +1 -1
  37. package/dist-ksadk/assets/{dist-DFD6Qa6T.js → dist-8PQ_BKzp.js} +1 -1
  38. package/dist-ksadk/assets/{dist-BIr4DSRq.js → dist-BDJ_cEqg.js} +1 -1
  39. package/dist-ksadk/assets/{dist-ClYUxfeK.js → dist-BDZE5o1x.js} +1 -1
  40. package/dist-ksadk/assets/{dist-BnaTiyzN.js → dist-BFo1orBG.js} +1 -1
  41. package/dist-ksadk/assets/{dist-Bj730Ib4.js → dist-BHnyxINi.js} +1 -1
  42. package/dist-ksadk/assets/{dist-BgV_owcB.js → dist-BbwSdGXT.js} +1 -1
  43. package/dist-ksadk/assets/{dist-QfkEHOlb.js → dist-BoW8KUVe.js} +1 -1
  44. package/dist-ksadk/assets/{dist-D_ctSS2i.js → dist-CBw6QiWi.js} +1 -1
  45. package/dist-ksadk/assets/{dist-CB9iJrvg.js → dist-CNlBI6JB.js} +1 -1
  46. package/dist-ksadk/assets/{dist-C1NMAY5a.js → dist-CO7NxVj-.js} +1 -1
  47. package/dist-ksadk/assets/{dist-CFzsn6BG.js → dist-CR1wd2ZP.js} +1 -1
  48. package/dist-ksadk/assets/{dist-B3FR1SKK.js → dist-CfKVhXlF.js} +1 -1
  49. package/dist-ksadk/assets/{dist-DvFK7p5S.js → dist-CuGt0QN2.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DiixqL0J.js → dist-DDzde0u0.js} +1 -1
  51. package/dist-ksadk/assets/{dist-DVCOWtha.js → dist-DP49CguF.js} +1 -1
  52. package/dist-ksadk/assets/dist-DTS11lPz.js +1 -0
  53. package/dist-ksadk/assets/{dist-Cf125P_m.js → dist-DUGnYv3Z.js} +1 -1
  54. package/dist-ksadk/assets/{dist-fBO2v5Kt.js → dist-DkIfde63.js} +1 -1
  55. package/dist-ksadk/assets/{dist-btbmmX5O.js → dist-JhK8apkX.js} +1 -1
  56. package/dist-ksadk/assets/{dist-DoVSwoDb.js → dist-XjCOh1mQ.js} +1 -1
  57. package/dist-ksadk/assets/{dist-ufY3F5p6.js → dist-axtMuC4Y.js} +2 -2
  58. package/dist-ksadk/assets/{dist-C5_ZAZsG.js → dist-vn-doe7c.js} +1 -1
  59. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-Ci8NqqZu.js → ebnfDiagram-PWID7BFC-BzjnujnW.js} +1 -1
  60. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CCIOhLZG.js → erDiagram-SSCWMZ5O-DdvSgpsK.js} +1 -1
  61. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-Cp_KL3nY.js +1 -0
  62. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BPxElJOb.js +1 -0
  63. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-Cp_r9Hb6.js → ganttDiagram-EL5Y4UJY-lcb8scO2.js} +1 -1
  64. package/dist-ksadk/assets/gitGraph-4MIJSDKK-B8DHF0b5.js +1 -0
  65. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-Dlhc8Wr8.js → gitGraphDiagram-WWUBYQGX-Cixie9K7.js} +1 -1
  66. package/dist-ksadk/assets/index-BumyuS0D.css +2 -0
  67. package/dist-ksadk/assets/index-DzVlSFGc.js +244 -0
  68. package/dist-ksadk/assets/info-A6RAGUB7-BDfMAVbQ.js +1 -0
  69. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-CO0rRTRA.js → infoDiagram-RXCK75RN-CN3pHWLc.js} +1 -1
  70. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-CHiaedSS.js → ishikawaDiagram-5VMMS53U-C-Rld8v2.js} +1 -1
  71. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-CHcCIB09.js → journeyDiagram-EYS64GPL-BTrUK9qG.js} +1 -1
  72. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CJ_ebBZf.js → kanban-definition-3QL26DDD-CRf-REL4.js} +1 -1
  73. package/dist-ksadk/assets/{katex-B4weu383.js → katex-DBkN_1i8.js} +1 -1
  74. package/dist-ksadk/assets/{linear-V-MgYHW1.js → linear-DR0IfN-Q.js} +1 -1
  75. package/dist-ksadk/assets/{mermaid-parser.core-CBijEX_c.js → mermaid-parser.core-Ej-7BR0m.js} +2 -2
  76. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-Bc-pQvpp.js → mindmap-definition-FBJOCRG2-BWL7ORVc.js} +1 -1
  77. package/dist-ksadk/assets/packet-AYTQ26CC-27mP8Due.js +1 -0
  78. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-D7genGLl.js → pegDiagram-XKGWAZYB-CCTfQJ1W.js} +1 -1
  79. package/dist-ksadk/assets/pie-WAS4IAKB-BZriQtXm.js +1 -0
  80. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-Bxj32zwD.js → pieDiagram-E7YTZNPT-BSOm4bnO.js} +1 -1
  81. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-BURv2mGh.js → quadrantDiagram-AXDQQJYC-BaQFiqoK.js} +1 -1
  82. package/dist-ksadk/assets/radar-RG4KPBEZ-DjxXwLPU.js +1 -0
  83. package/dist-ksadk/assets/railroad-74A4TZTK-C0dLiJCE.js +1 -0
  84. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CtFZAnrB.js +1 -0
  85. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BlqaBE1g.js +1 -0
  86. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-xZlOtuT5.js +1 -0
  87. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-CCsh3avW.js → railroadDiagram-O6MQD6OU-BzcGgAQa.js} +1 -1
  88. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-_FRRBKEd.js → requirementDiagram-EFPCY7ZU-BSW8FM0T.js} +1 -1
  89. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-C-gr2o9M.js → sankeyDiagram-P5KCCOFB-BtTDOHfw.js} +1 -1
  90. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-D97NmfKg.js → sequenceDiagram-WJ2MYXX4-jXhWZPC6.js} +1 -1
  91. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DjrPC5FX.js → sizeCapture-X5ZJPWSS-Bi3ddJUw.js} +1 -1
  92. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DzMNg1hh.js → stateDiagram-HBIQ2CUA-BJZaCT2J.js} +1 -1
  93. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-De0kAogJ.js +1 -0
  94. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-Cssf_CsU.js → swimlanes-XN3QIQJK-DnZwc2fl.js} +1 -1
  95. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DY_Zfiw4.js +8 -0
  96. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-BWTHzyS1.js → timeline-definition-24CTP7MA-BrunPeYF.js} +1 -1
  97. package/dist-ksadk/assets/treeView-Q6P3EWNA-Dn_GVxQ_.js +1 -0
  98. package/dist-ksadk/assets/treemap-WGGIJYW6-DMRNlrYS.js +1 -0
  99. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-BSKgJsmR.js → vennDiagram-4TSXK5OY-DGczjqRq.js} +1 -1
  100. package/dist-ksadk/assets/wardley-WFR3VGLG-B8DGIkoz.js +1 -0
  101. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-eflHNoaZ.js → wardleyDiagram-VM6X3IG4-B31kHkto.js} +1 -1
  102. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-eYqrQ-v4.js → xychartDiagram-S5SC5T6Z-CFGAbZRL.js} +1 -1
  103. package/dist-ksadk/index.html +2 -2
  104. package/dist-lib/{ArtifactsPanel-rz8e8OIc.js → ArtifactsPanel-DByDntRi.js} +1 -1
  105. package/dist-lib/{AttachmentPreview-CBpwnWxP.js → AttachmentPreview-tjd7Ufsh.js} +133 -292
  106. package/dist-lib/CodeBlock-DMIf4h33.js +213 -0
  107. package/dist-lib/{ConnectedComposer-DQ-yODJ-.js → ConnectedComposer-Cz5HKWFx.js} +322 -286
  108. package/dist-lib/{ConnectedMessageList-DfSvxYLL.js → ConnectedMessageList-CR6VIuLb.js} +476 -631
  109. package/dist-lib/ExecutionTree-v3HexvPo.js +277 -0
  110. package/dist-lib/FilePreviewModal-Cg8FoEGt.js +133 -0
  111. package/dist-lib/InteractionSchemaForm-BNoW5wzt.js +157 -0
  112. package/dist-lib/{MathMessageMarkdown-CBcDrAw-.js → MathMessageMarkdown-CfKpa9jm.js} +33 -33
  113. package/dist-lib/{MenuChip-So0XESNz.js → MenuChip-CT8v3QtQ.js} +1 -1
  114. package/dist-lib/MermaidBlock-H_0qzQDf.js +42 -0
  115. package/dist-lib/MessageMarkdown-D5yqDJ95.js +418 -0
  116. package/dist-lib/{NativeTerminalPanel-D2J75bIU.js → NativeTerminalPanel-beSt6mii.js} +1 -1
  117. package/dist-lib/{WorkspacePanelContainer-Q8Tt_oXe.js → WorkspacePanelContainer-jXNATcO4.js} +16 -16
  118. package/dist-lib/{a2ui-BVAet3qy.js → a2ui-BEQoW34n.js} +69 -70
  119. package/dist-lib/chat-composer.js +4 -4
  120. package/dist-lib/chat-timeline.js +4 -3
  121. package/dist-lib/clipboard-MB6Ru6h6.js +20 -0
  122. package/dist-lib/components/MessageMarkdown.d.ts.map +1 -1
  123. package/dist-lib/components/chat/ChatComposer.d.ts +4 -2
  124. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  125. package/dist-lib/components/chat/ChatMessageList.d.ts +8 -1
  126. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  127. package/dist-lib/components/chat/ConnectedComposer.d.ts +9 -1
  128. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  129. package/dist-lib/components/chat/ConnectedMessageList.d.ts +5 -1
  130. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  131. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
  132. package/dist-lib/components/chat/types.d.ts +8 -0
  133. package/dist-lib/components/chat/types.d.ts.map +1 -1
  134. package/dist-lib/components/markdown/CodeBlock.d.ts.map +1 -1
  135. package/dist-lib/components/markdown/MathMessageMarkdown.d.ts.map +1 -1
  136. package/dist-lib/components/markdown/MermaidBlock.d.ts.map +1 -1
  137. package/dist-lib/components/teams/CreateGroupDialog.d.ts +21 -0
  138. package/dist-lib/components/teams/CreateGroupDialog.d.ts.map +1 -0
  139. package/dist-lib/components/teams/ExecutionTree.d.ts +24 -0
  140. package/dist-lib/components/teams/ExecutionTree.d.ts.map +1 -0
  141. package/dist-lib/components/teams/InteractionMessage.d.ts +4 -0
  142. package/dist-lib/components/teams/InteractionMessage.d.ts.map +1 -0
  143. package/dist-lib/components/teams/TeamReconciliation.d.ts +9 -0
  144. package/dist-lib/components/teams/TeamReconciliation.d.ts.map +1 -0
  145. package/dist-lib/components/teams/TeamWorkspace.d.ts +110 -0
  146. package/dist-lib/components/teams/TeamWorkspace.d.ts.map +1 -0
  147. package/dist-lib/components/workspace/FilePreviewModal.d.ts +21 -0
  148. package/dist-lib/components/workspace/FilePreviewModal.d.ts.map +1 -0
  149. package/dist-lib/components.js +34 -32
  150. package/dist-lib/conversation.js +198 -5
  151. package/dist-lib/core/conversation/history-search.d.ts +33 -0
  152. package/dist-lib/core/conversation/history-search.d.ts.map +1 -0
  153. package/dist-lib/core/conversation/hosted.d.ts +1 -1
  154. package/dist-lib/core/conversation/hosted.d.ts.map +1 -1
  155. package/dist-lib/core/conversation/index.d.ts +1 -0
  156. package/dist-lib/core/conversation/index.d.ts.map +1 -1
  157. package/dist-lib/core/conversation/presentation.d.ts.map +1 -1
  158. package/dist-lib/core/conversation/projection-store.d.ts +25 -0
  159. package/dist-lib/core/conversation/projection-store.d.ts.map +1 -0
  160. package/dist-lib/core/conversation/session-facade.d.ts +136 -0
  161. package/dist-lib/core/conversation/session-facade.d.ts.map +1 -0
  162. package/dist-lib/core/conversation/studio-controller.d.ts +143 -0
  163. package/dist-lib/core/conversation/studio-controller.d.ts.map +1 -0
  164. package/dist-lib/core/conversation/types.d.ts +8 -0
  165. package/dist-lib/core/conversation/types.d.ts.map +1 -1
  166. package/dist-lib/core/run/blocks.d.ts +2 -0
  167. package/dist-lib/core/run/blocks.d.ts.map +1 -1
  168. package/dist-lib/core/run/dispatcher.d.ts +4 -1
  169. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  170. package/dist-lib/core/run/engine.d.ts +22 -6
  171. package/dist-lib/core/run/engine.d.ts.map +1 -1
  172. package/dist-lib/core/run/index.d.ts +1 -1
  173. package/dist-lib/core/run/index.d.ts.map +1 -1
  174. package/dist-lib/core/run/types.d.ts +8 -3
  175. package/dist-lib/core/run/types.d.ts.map +1 -1
  176. package/dist-lib/core/teams/client.d.ts +106 -0
  177. package/dist-lib/core/teams/client.d.ts.map +1 -0
  178. package/dist-lib/core/teams/contracts.d.ts +827 -0
  179. package/dist-lib/core/teams/contracts.d.ts.map +1 -0
  180. package/dist-lib/core/teams/grouping.d.ts +5 -0
  181. package/dist-lib/core/teams/grouping.d.ts.map +1 -0
  182. package/dist-lib/core/teams/observer.d.ts +52 -0
  183. package/dist-lib/core/teams/observer.d.ts.map +1 -0
  184. package/dist-lib/core/teams/presentation.d.ts +17 -0
  185. package/dist-lib/core/teams/presentation.d.ts.map +1 -0
  186. package/dist-lib/core/teams/reducer.d.ts +13 -0
  187. package/dist-lib/core/teams/reducer.d.ts.map +1 -0
  188. package/dist-lib/core/teams/types.d.ts +362 -0
  189. package/dist-lib/core/teams/types.d.ts.map +1 -0
  190. package/dist-lib/{feedback-D256P415.js → feedback-CuC5jRi_.js} +88 -84
  191. package/dist-lib/file-preview.js +3 -0
  192. package/dist-lib/history-search-CBd9v7MY.js +58 -0
  193. package/dist-lib/hooks/useAgentChat.d.ts +22 -1
  194. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  195. package/dist-lib/hooks/useRunAgent.d.ts +9 -4
  196. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  197. package/dist-lib/hooks/useSessionLifecycle.d.ts +13 -2
  198. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  199. package/dist-lib/hooks/useTeamChat.d.ts +17 -0
  200. package/dist-lib/hooks/useTeamChat.d.ts.map +1 -0
  201. package/dist-lib/hooks.js +240 -140
  202. package/dist-lib/{permission--lxoX90f.js → permission-CcMWqN8Y.js} +1 -1
  203. package/dist-lib/{persisted-session-history-Bb3ScKrL.js → persisted-session-history-ClsfDfGs.js} +365 -604
  204. package/dist-lib/presentation-yYw7xK60.js +53 -0
  205. package/dist-lib/public/components.d.ts +3 -0
  206. package/dist-lib/public/components.d.ts.map +1 -1
  207. package/dist-lib/public/conversation.d.ts +8 -0
  208. package/dist-lib/public/conversation.d.ts.map +1 -1
  209. package/dist-lib/public/file-preview.d.ts +4 -0
  210. package/dist-lib/public/file-preview.d.ts.map +1 -0
  211. package/dist-lib/public/runtime.d.ts +1 -1
  212. package/dist-lib/public/runtime.d.ts.map +1 -1
  213. package/dist-lib/public/team-components.d.ts +4 -0
  214. package/dist-lib/public/team-components.d.ts.map +1 -0
  215. package/dist-lib/public/team-execution.d.ts +3 -0
  216. package/dist-lib/public/team-execution.d.ts.map +1 -0
  217. package/dist-lib/public/teams.d.ts +8 -0
  218. package/dist-lib/public/teams.d.ts.map +1 -0
  219. package/dist-lib/reducer-BP8YVv-Q.js +270 -0
  220. package/dist-lib/reducer-gQmR9Qb9.js +424 -0
  221. package/dist-lib/runtime.js +35 -34
  222. package/dist-lib/stores/streaming.d.ts +3 -1
  223. package/dist-lib/stores/streaming.d.ts.map +1 -1
  224. package/dist-lib/studio-controller-jBKN9hmp.js +422 -0
  225. package/dist-lib/styles.css +1 -1
  226. package/dist-lib/team-components.js +2033 -0
  227. package/dist-lib/team-execution.js +2 -0
  228. package/dist-lib/teams.css +429 -0
  229. package/dist-lib/teams.js +357 -0
  230. package/dist-lib/types/agent-control.d.ts.map +1 -1
  231. package/dist-lib/types/capabilities.d.ts +6 -0
  232. package/dist-lib/types/capabilities.d.ts.map +1 -1
  233. package/dist-lib/{useSessionLifecycle-DQCw8YmE.js → useSessionLifecycle-DQXKeBm9.js} +1221 -1025
  234. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  235. package/dist-lib/utils/session-events.d.ts.map +1 -1
  236. package/dist-lib/utils/workspace-file-paths.d.ts +14 -0
  237. package/dist-lib/utils/workspace-file-paths.d.ts.map +1 -0
  238. package/dist-lib/utils/workspace-file-preview-bus.d.ts +4 -0
  239. package/dist-lib/utils/workspace-file-preview-bus.d.ts.map +1 -0
  240. package/dist-lib/utils-CX-Pz5p6.js +8 -0
  241. package/package.json +24 -3
  242. package/schemas/teams-v1-execution-snapshot.schema.json +197 -0
  243. package/schemas/teams-v1-group-event.schema.json +53 -0
  244. package/schemas/teams-v1-group-snapshot.schema.json +1464 -0
  245. package/schemas/teams-v1-interaction-ref.schema.json +64 -0
  246. package/dist-ksadk/assets/MathMessageMarkdown-DbdW5A4_.js +0 -8
  247. package/dist-ksadk/assets/architecture-7GRP2DOG-BW5UtSnx.js +0 -1
  248. package/dist-ksadk/assets/channel-CF5Up3hQ.js +0 -1
  249. package/dist-ksadk/assets/chunk-2Q5K7J3B-KkXX47WI.js +0 -1
  250. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-Cz81acRQ.js +0 -1
  251. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-Cz81acRQ.js +0 -1
  252. package/dist-ksadk/assets/cynefin-OW5HDTMX-DVWs8a2t.js +0 -1
  253. package/dist-ksadk/assets/dist-B2_CVgKv.js +0 -1
  254. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-CQqR2hg3.js +0 -1
  255. package/dist-ksadk/assets/flowDiagram-A5DVABFB-DDRRbGPm.js +0 -1
  256. package/dist-ksadk/assets/gitGraph-4MIJSDKK-fgWEf7UD.js +0 -1
  257. package/dist-ksadk/assets/index-DcTML1Up.css +0 -2
  258. package/dist-ksadk/assets/index-Dh2XHqPK.js +0 -244
  259. package/dist-ksadk/assets/info-A6RAGUB7-BUecLTdt.js +0 -1
  260. package/dist-ksadk/assets/packet-AYTQ26CC-BeW-btFv.js +0 -1
  261. package/dist-ksadk/assets/pie-WAS4IAKB-X0xh4SaT.js +0 -1
  262. package/dist-ksadk/assets/radar-RG4KPBEZ-DzRMSqjd.js +0 -1
  263. package/dist-ksadk/assets/railroad-74A4TZTK-Cc44icX-.js +0 -1
  264. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-D6S4BdV-.js +0 -1
  265. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-vD3aVE2o.js +0 -1
  266. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-CYbW_b4T.js +0 -1
  267. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BIcjKFhF.js +0 -1
  268. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-tq3K3Ybl.js +0 -8
  269. package/dist-ksadk/assets/treeView-Q6P3EWNA-DBXt3GdU.js +0 -1
  270. package/dist-ksadk/assets/treemap-WGGIJYW6-DrCy4E_l.js +0 -1
  271. package/dist-ksadk/assets/wardley-WFR3VGLG-CefhOliM.js +0 -1
  272. package/dist-lib/CodeBlock-DCUUY0PL.js +0 -113
  273. package/dist-lib/MermaidBlock-DBFTztfQ.js +0 -35
@@ -1,198 +1,7 @@
1
1
  import { n as e } from "./tool-display-DTiRdghE.js";
2
- //#region src/core/conversation/errors.ts
3
- var t = class extends Error {
4
- code;
5
- status;
6
- capability;
7
- runId;
8
- cursor;
9
- cause;
10
- constructor(e, t, n = {}) {
11
- super(t), this.name = "ConversationClientError", this.code = e, this.status = n.status, this.capability = n.capability, this.runId = n.runId, this.cursor = n.cursor, this.cause = n.cause;
12
- }
13
- }, n = "conversation.ksadk.io/v1", r = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/, i = new Set([
14
- "native",
15
- "translated",
16
- "degraded",
17
- "unavailable"
18
- ]), a = new Set([
19
- "user_message",
20
- "assistant_text",
21
- "reasoning",
22
- "tool_call",
23
- "approval",
24
- "progress",
25
- "plan",
26
- "goal",
27
- "artifact",
28
- "a2ui",
29
- "error",
30
- "unknown"
31
- ]), o = new Set([
32
- "append",
33
- "replace",
34
- "completed"
35
- ]), s = new Set([
36
- "pending",
37
- "streaming",
38
- "completed",
39
- "failed"
40
- ]), c = new Set([
41
- "public",
42
- "internal",
43
- "hidden"
44
- ]), l = new Set([
45
- "apiVersion",
46
- "kind",
47
- "inputId",
48
- "sessionId",
49
- "idempotencyKey",
50
- "parts",
51
- "modelRef",
52
- "reasoning",
53
- "extensions"
54
- ]), u = new Set(["kind", "text"]), d = new Set([
55
- "kind",
56
- "attachmentRef",
57
- "mediaType",
58
- "name"
59
- ]), f = "ksadk.approval", p = "ksadk.collaboration", m = "ksadk.goal";
60
- function h(e) {
61
- return typeof e == "object" && e && !Array.isArray(e) ? e : null;
62
- }
63
- function g(e, t) {
64
- return typeof e == "string" && e.length > 0 && e.length <= t;
65
- }
66
- function _(e, t, n = !1) {
67
- return e == null || typeof e == "string" && e.length <= t && (n || e.length > 0);
68
- }
69
- function v(e, t) {
70
- return Object.keys(e).every((e) => t.has(e));
71
- }
72
- function y(e) {
73
- let t = h(e);
74
- return !t || typeof t.kind != "string" ? null : t.kind === "text" ? !v(t, u) || !g(t.text, 131072) ? null : {
75
- kind: "text",
76
- text: t.text
77
- } : t.kind === "attachment" ? !v(t, d) || !g(t.attachmentRef, 2048) || !g(t.mediaType, 256) || !_(t.name, 1024, !0) ? null : {
78
- kind: "attachment",
79
- attachmentRef: t.attachmentRef,
80
- mediaType: t.mediaType,
81
- ...t.name === void 0 ? {} : { name: t.name }
82
- } : null;
83
- }
84
- function b(e) {
85
- if (e === void 0) return {};
86
- let t = h(e);
87
- if (!t || Object.keys(t).some((e) => !r.test(e) || !e.includes("."))) return null;
88
- let n = t[f], i = t[p], a = t[m];
89
- return n !== void 0 && ![
90
- "ask",
91
- "risk",
92
- "full"
93
- ].includes(String(n)) || i !== void 0 && !["default", "plan"].includes(String(i)) || a !== void 0 && !g(a, 4096) ? null : { ...t };
94
- }
95
- function ee(e) {
96
- let t = h(e);
97
- if (!t || !v(t, l) || t.apiVersion !== n || t.kind !== "ConversationInput" || !g(t.inputId, 256) || !g(t.sessionId, 256) || !g(t.idempotencyKey, 512) || !Array.isArray(t.parts) || t.parts.length === 0 || !_(t.modelRef, 256) || !_(t.reasoning, 64)) return null;
98
- let r = t.parts.map(y), i = b(t.extensions);
99
- return r.some((e) => e === null) || i === null ? null : {
100
- apiVersion: n,
101
- kind: "ConversationInput",
102
- inputId: t.inputId,
103
- sessionId: t.sessionId,
104
- idempotencyKey: t.idempotencyKey,
105
- parts: r,
106
- ...t.modelRef === void 0 ? {} : { modelRef: t.modelRef },
107
- ...t.reasoning === void 0 ? {} : { reasoning: t.reasoning },
108
- ...t.extensions === void 0 ? {} : { extensions: i }
109
- };
110
- }
111
- function te(e) {
112
- let r = ee({
113
- ...e,
114
- apiVersion: e.apiVersion || n,
115
- kind: e.kind || "ConversationInput"
116
- });
117
- if (!r) throw new t("conversation_contract_mismatch", "Conversation input does not match conversation.ksadk.io/v1.");
118
- return r;
119
- }
120
- function ne(e) {
121
- let t = e.parts.map((e) => e.kind === "text" ? "text" : e.mediaType.toLowerCase().startsWith("image/") ? "attachment.image" : "attachment.file");
122
- e.modelRef && t.push("model.select"), e.reasoning && t.push("reasoning.effort");
123
- for (let n of Object.keys(e.extensions || {})) n === f ? t.push("approval") : n === p ? e.extensions?.[n] === "plan" && t.push("plan") : n === m ? t.push("goal") : t.push(n);
124
- return [...new Set(t)];
125
- }
126
- function re(e, n) {
127
- if (e.sessionId !== n.sessionId) throw new t("conversation_session_mismatch", "Conversation input session does not match the active surface.");
128
- for (let r of ne(n)) if (!ce(e, r)) throw new t("conversation_input_unsupported", "Conversation input is not declared by the active surface.", { capability: r });
129
- return n;
130
- }
131
- function ie(e) {
132
- let t = h(e);
133
- return !t || !g(t.name, 128) || !r.test(t.name) || !i.has(t.mode) || !_(t.reason, 512, !0) || (t.mode === "degraded" || t.mode === "unavailable") && !g(t.reason, 512) ? null : {
134
- name: t.name,
135
- mode: t.mode,
136
- ...t.reason === void 0 ? {} : { reason: t.reason }
137
- };
138
- }
139
- function ae(e) {
140
- if (e === void 0) return [];
141
- if (!Array.isArray(e)) return null;
142
- let t = e.map(ie);
143
- if (t.some((e) => e === null)) return null;
144
- let n = t;
145
- return new Set(n.map((e) => e.name)).size === n.length ? n : null;
146
- }
147
- function oe(e) {
148
- let t = h(e);
149
- if (!t || t.apiVersion !== n || t.kind !== "ConversationSurface" || !g(t.surfaceId, 256) || !g(t.sessionId, 256) || !g(t.providerRef, 256)) return null;
150
- let r = ae(t.inputs), i = ae(t.outputs);
151
- return !r || !i ? null : {
152
- apiVersion: n,
153
- kind: "ConversationSurface",
154
- surfaceId: t.surfaceId,
155
- sessionId: t.sessionId,
156
- providerRef: t.providerRef,
157
- inputs: r,
158
- outputs: i
159
- };
160
- }
161
- function se(e) {
162
- let t = h(e);
163
- if (!t || t.apiVersion !== n || t.kindVersion !== 1 || !g(t.itemId, 512) || !_(t.parentItemId, 512) || !Array.isArray(t.sourceEventIds) || t.sourceEventIds.length === 0 || t.sourceEventIds.some((e) => typeof e != "string" || e.length === 0) || new Set(t.sourceEventIds).size !== t.sourceEventIds.length || !g(t.sessionId, 256) || !g(t.runId, 256) || !g(t.kind, 128) || !o.has(t.operation) || !s.has(t.lifecycle) || t.visibility !== void 0 && !c.has(t.visibility) || !g(t.payloadSchemaRef, 256) || !_(t.capabilityRef, 256, !0)) return null;
164
- let r = t.operation, i = t.lifecycle;
165
- if (r === "completed" && i !== "completed" && i !== "failed") return null;
166
- let l = t.payload === void 0 ? {} : h(t.payload), u = t.nativeRef === void 0 ? {} : h(t.nativeRef);
167
- if (!l || !u) return null;
168
- let d = String(t.kind || "unknown"), f = a.has(d) ? d : "unknown";
169
- return {
170
- apiVersion: n,
171
- kindVersion: 1,
172
- itemId: t.itemId,
173
- ...t.parentItemId === void 0 ? {} : { parentItemId: t.parentItemId },
174
- sourceEventIds: [...t.sourceEventIds],
175
- sessionId: t.sessionId,
176
- runId: t.runId,
177
- kind: f,
178
- operation: r,
179
- lifecycle: i,
180
- visibility: f === "unknown" && d !== "unknown" ? "hidden" : t.visibility || "public",
181
- payloadSchemaRef: t.payloadSchemaRef,
182
- payload: f === "unknown" && d !== "unknown" ? {
183
- originalKind: d,
184
- summary: "This content type is not supported by the current renderer."
185
- } : { ...l },
186
- ...t.capabilityRef === void 0 ? {} : { capabilityRef: t.capabilityRef },
187
- nativeRef: { ...u }
188
- };
189
- }
190
- function ce(e, ...t) {
191
- return e.inputs.some((e) => t.includes(e.name) && (e.mode === "native" || e.mode === "translated"));
192
- }
193
- //#endregion
2
+ import { c as t, o as n, s as r, t as i, u as a } from "./reducer-BP8YVv-Q.js";
194
3
  //#region src/core/conversation/presentation.ts
195
- var le = {
4
+ var o = {
196
5
  user_message: "conversation.item.user_message/v1",
197
6
  assistant_text: "conversation.item.assistant_text/v1",
198
7
  reasoning: "conversation.item.reasoning/v1",
@@ -202,10 +11,10 @@ var le = {
202
11
  a2ui: "conversation.item.a2ui/v1",
203
12
  error: "conversation.item.error/v1"
204
13
  };
205
- function x(e) {
14
+ function s(e) {
206
15
  return e.lifecycle === "completed" || e.lifecycle === "failed";
207
16
  }
208
- var ue = new Set([
17
+ var c = new Set([
209
18
  "aborted",
210
19
  "canceled",
211
20
  "cancelled",
@@ -213,17 +22,17 @@ var ue = new Set([
213
22
  "incomplete",
214
23
  "interrupted"
215
24
  ]);
216
- function S(e) {
217
- if (e.kind !== "progress" && e.kind !== "error" || !x(e)) return;
25
+ function l(e) {
26
+ if (e.kind !== "progress" && e.kind !== "error" || !s(e)) return;
218
27
  let t = typeof e.payload.status == "string" ? e.payload.status.toLowerCase() : "";
219
28
  if (t === "completed") return "completed";
220
- if (ue.has(t)) return "failed";
29
+ if (c.has(t)) return "failed";
221
30
  }
222
- function de(e) {
223
- let t = le[e.kind];
31
+ function u(e) {
32
+ let t = o[e.kind];
224
33
  return t === void 0 || t === e.payloadSchemaRef;
225
34
  }
226
- function fe(e) {
35
+ function d(e) {
227
36
  if (typeof e != "string" || e.length === 0) return null;
228
37
  try {
229
38
  let t = new URL(e);
@@ -232,7 +41,7 @@ function fe(e) {
232
41
  return null;
233
42
  }
234
43
  }
235
- function pe(e) {
44
+ function f(e) {
236
45
  return {
237
46
  id: e.itemId,
238
47
  parentId: e.parentItemId || null,
@@ -242,35 +51,42 @@ function pe(e) {
242
51
  lifecycle: e.lifecycle
243
52
  };
244
53
  }
245
- function me(e) {
54
+ function p(e) {
55
+ let t = typeof e.payload.artifactId == "string" && e.payload.artifactId ? e.payload.artifactId : e.itemId, n = e.payload.sizeBytes ?? e.payload.size, r = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : null, i = d(e.payload.uri);
246
56
  return {
57
+ artifactId: t,
58
+ itemId: e.itemId,
59
+ runId: e.runId,
60
+ sourceEventIds: [...e.sourceEventIds],
247
61
  id: e.itemId,
248
62
  name: typeof e.payload.name == "string" && e.payload.name ? e.payload.name : "Artifact",
249
63
  mimeType: typeof e.payload.mimeType == "string" && e.payload.mimeType ? e.payload.mimeType : "application/octet-stream",
250
- uri: fe(e.payload.uri)
64
+ sizeBytes: r,
65
+ status: e.lifecycle === "failed" ? "failed" : e.lifecycle === "completed" ? i ? "ready" : "failed" : "pending",
66
+ uri: i
251
67
  };
252
68
  }
253
- function C(e, t) {
69
+ function m(e, t) {
254
70
  let n = e.payload[t];
255
71
  return typeof n == "string" && n ? n : null;
256
72
  }
257
- function he(e) {
73
+ function h(e) {
258
74
  if (e.kind === "tool_call") {
259
- let t = C(e, "callId");
75
+ let t = m(e, "callId");
260
76
  if (t) return `tool:${t}`;
261
77
  }
262
78
  if (e.kind === "approval") {
263
- let t = C(e, "interactionId");
79
+ let t = m(e, "interactionId");
264
80
  if (t) return `approval:${t}`;
265
81
  }
266
82
  if (e.kind === "a2ui") {
267
- let t = C(e, "surfaceId");
83
+ let t = m(e, "surfaceId");
268
84
  if (t) return `a2ui:${t}`;
269
85
  }
270
86
  return `item:${e.itemId}`;
271
87
  }
272
- function ge(e, t) {
273
- let n = x(e) && !x(t);
88
+ function g(e, t) {
89
+ let n = s(e) && !s(t);
274
90
  return {
275
91
  ...e,
276
92
  ...t,
@@ -291,10 +107,10 @@ function ge(e, t) {
291
107
  } : {}
292
108
  };
293
109
  }
294
- function _e(e) {
110
+ function _(e) {
295
111
  let t = [], n = /* @__PURE__ */ new Map();
296
112
  for (let r of e) {
297
- let e = he(r), i = n.get(e);
113
+ let e = h(r), i = n.get(e);
298
114
  if (i === void 0) {
299
115
  n.set(e, t.length), t.push({
300
116
  key: e,
@@ -306,20 +122,20 @@ function _e(e) {
306
122
  let a = t[i];
307
123
  t[i] = {
308
124
  key: e,
309
- item: ge(a.item, r),
125
+ item: g(a.item, r),
310
126
  sourceItemIds: [...new Set([...a.sourceItemIds, r.itemId])]
311
127
  };
312
128
  }
313
129
  return t;
314
130
  }
315
- function ve(e, t = {}) {
316
- let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal"), r = n.filter(de), i = n.filter((e) => !de(e)), a = new Set([
131
+ function v(e, t = {}) {
132
+ let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal"), r = n.filter(u), i = n.filter((e) => !u(e)), a = new Set([
317
133
  "user_message",
318
134
  "assistant_text",
319
135
  "reasoning"
320
- ]), o = r.filter((e) => a.has(e.kind)).map(pe), s = (e) => r.filter((t) => t.kind === e).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), c = [...r.filter((e) => e.kind === "unknown"), ...i], l = r.filter((e) => e.kind === "error"), u = [...r].reverse().find((e) => S(e) !== void 0);
136
+ ]), o = r.filter((e) => a.has(e.kind)).map(f), s = (e) => r.filter((t) => t.kind === e).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), c = [...r.filter((e) => e.kind === "unknown"), ...i], d = r.filter((e) => e.kind === "error"), m = [...r].reverse().find((e) => l(e) !== void 0);
321
137
  return {
322
- timeline: _e(r.filter((e) => e.kind !== "progress")),
138
+ timeline: _(r.filter((e) => e.kind !== "progress")),
323
139
  output: s("assistant_text"),
324
140
  reasoning: s("reasoning"),
325
141
  textItems: o,
@@ -327,266 +143,192 @@ function ve(e, t = {}) {
327
143
  approvalItems: r.filter((e) => e.kind === "approval"),
328
144
  structuredInputItems: r.filter((e) => e.kind === "progress" && e.payloadSchemaRef === "conversation.item.structured-input/v1"),
329
145
  a2uiItems: r.filter((e) => e.kind === "a2ui"),
330
- artifacts: r.filter((e) => e.kind === "artifact").map(me),
146
+ artifacts: r.filter((e) => e.kind === "artifact").map(p),
331
147
  fallbacks: [...c.map((e) => ({
332
148
  id: e.itemId,
333
149
  title: "Unsupported content",
334
150
  detail: String(e.payload.summary || e.payload.originalKind || e.payloadSchemaRef),
335
151
  failed: e.lifecycle === "failed"
336
- })), ...l.map((e) => ({
152
+ })), ...d.map((e) => ({
337
153
  id: e.itemId,
338
154
  title: "Run failed",
339
155
  detail: String(e.payload.error || "The agent run failed."),
340
156
  failed: !0
341
157
  }))],
342
158
  runId: n.at(-1)?.runId || "",
343
- terminalStatus: u ? S(u) : void 0
159
+ terminalStatus: m ? l(m) : void 0
344
160
  };
345
161
  }
346
162
  //#endregion
347
- //#region src/core/conversation/reducer.ts
348
- function ye() {
349
- return {
350
- items: [],
351
- appliedSources: []
352
- };
353
- }
354
- function be(e) {
355
- return e.lifecycle === "completed" || e.lifecycle === "failed";
356
- }
357
- function xe(e, t) {
358
- let n = {
359
- ...e,
360
- ...t
361
- };
362
- typeof e.text == "string" && typeof t.text == "string" && (n.text = e.text + t.text);
363
- for (let r of ["data", "operations"]) Array.isArray(e[r]) && Array.isArray(t[r]) && (n[r] = [...e[r], ...t[r]]);
364
- return n;
365
- }
366
- function Se(e, t) {
367
- let n = t.sourceEventIds.map((e) => JSON.stringify([t.itemId, e])), r = new Set(e.appliedSources);
368
- if (n.every((e) => r.has(e))) return e;
369
- n.forEach((e) => r.add(e));
370
- let i = e.items.findIndex((e) => e.itemId === t.itemId), a = i >= 0 ? e.items[i] : void 0;
371
- if (a && be(a) && !be(t)) return {
372
- ...e,
373
- appliedSources: [...r]
374
- };
375
- let o = [...e.items];
376
- if (!a) o.push(t);
377
- else {
378
- let e = [...new Set([...a.sourceEventIds, ...t.sourceEventIds])];
379
- a.kind === t.kind ? t.operation === "append" ? o[i] = {
380
- ...t,
381
- payload: xe(a.payload, t.payload),
382
- sourceEventIds: e
383
- } : o[i] = {
384
- ...t,
385
- sourceEventIds: e
386
- } : o[i] = {
387
- ...t,
388
- kind: "unknown",
389
- operation: "replace",
390
- payloadSchemaRef: "conversation.item.unknown/v1",
391
- payload: { summary: "The content type changed for the same item and was safely degraded." },
392
- sourceEventIds: e
393
- };
394
- }
395
- return {
396
- items: o,
397
- appliedSources: [...r]
398
- };
399
- }
400
- var Ce = class {
401
- state = ye();
402
- apply(e) {
403
- let t = Se(this.state, e);
404
- if (t === this.state) return !1;
405
- let n = t.items !== this.state.items;
406
- return this.state = t, n;
407
- }
408
- applyAll(e) {
409
- for (let t of e) this.apply(t);
410
- }
411
- snapshot() {
412
- return {
413
- items: this.state.items.map((e) => ({
414
- ...e,
415
- sourceEventIds: [...e.sourceEventIds],
416
- payload: { ...e.payload },
417
- nativeRef: { ...e.nativeRef }
418
- })),
419
- appliedSources: [...this.state.appliedSources]
420
- };
421
- }
422
- }, w = 8;
423
- function T(e) {
163
+ //#region src/core/conversation/client.ts
164
+ var y = 8;
165
+ function b(e) {
424
166
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
425
167
  }
426
- function E(e) {
427
- if (e?.aborted) throw new t("conversation_aborted", "Conversation request was aborted.");
168
+ function x(e) {
169
+ if (e?.aborted) throw new a("conversation_aborted", "Conversation request was aborted.");
428
170
  }
429
- function we(e, t) {
171
+ function ee(e, t) {
430
172
  return t?.aborted === !0 || e instanceof Error && e.name === "AbortError";
431
173
  }
432
- function Te(e) {
433
- let n = e.trim().replace(/\/+$/, "");
434
- if (!n) return "";
435
- if (!n.includes("://")) return n.startsWith("/") ? n : `/${n}`;
174
+ function te(e) {
175
+ let t = e.trim().replace(/\/+$/, "");
176
+ if (!t) return "";
177
+ if (!t.includes("://")) return t.startsWith("/") ? t : `/${t}`;
436
178
  try {
437
- let e = new URL(n);
179
+ let e = new URL(t);
438
180
  if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password) throw Error("unsafe URL");
439
181
  return e.toString().replace(/\/$/, "");
440
182
  } catch (e) {
441
- throw new t("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
183
+ throw new a("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
442
184
  }
443
185
  }
444
- function Ee(e) {
186
+ function ne(e) {
445
187
  return Math.min(200 * 2 ** Math.max(0, e - 1), 2e3);
446
188
  }
447
- function De(e) {
189
+ function re(e) {
448
190
  return new Promise((t) => {
449
191
  setTimeout(t, e);
450
192
  });
451
193
  }
452
- async function Oe(e, n, r) {
453
- if (E(r), !r) {
454
- await e(n);
194
+ async function ie(e, t, n) {
195
+ if (x(n), !n) {
196
+ await e(t);
455
197
  return;
456
198
  }
457
- await new Promise((i, a) => {
458
- let o = () => a(new t("conversation_aborted", "Conversation request was aborted."));
459
- r.addEventListener("abort", o, { once: !0 }), e(n).then(i, a).finally(() => {
460
- r.removeEventListener("abort", o);
199
+ await new Promise((r, i) => {
200
+ let o = () => i(new a("conversation_aborted", "Conversation request was aborted."));
201
+ n.addEventListener("abort", o, { once: !0 }), e(t).then(r, i).finally(() => {
202
+ n.removeEventListener("abort", o);
461
203
  });
462
204
  });
463
205
  }
464
- function D(e, t, n) {
206
+ function S(e, t, n) {
465
207
  let r = e.snapshot();
466
208
  return {
467
209
  cursor: t,
468
210
  runId: n,
469
211
  state: r,
470
- presentation: ve(r)
212
+ presentation: v(r)
471
213
  };
472
214
  }
473
- function ke(e, n) {
215
+ function C(e, t) {
474
216
  let r, i = [];
475
- for (let n of e.split(/\r?\n/)) {
476
- let e = n.endsWith("\r") ? n.slice(0, -1) : n;
217
+ for (let t of e.split(/\r?\n/)) {
218
+ let e = t.endsWith("\r") ? t.slice(0, -1) : t;
477
219
  if (!e || e.startsWith(":")) continue;
478
- let a = e.indexOf(":"), o = a < 0 ? e : e.slice(0, a), s = a < 0 ? "" : e.slice(a + 1), c = s.startsWith(" ") ? s.slice(1) : s;
220
+ let n = e.indexOf(":"), o = n < 0 ? e : e.slice(0, n), s = n < 0 ? "" : e.slice(n + 1), c = s.startsWith(" ") ? s.slice(1) : s;
479
221
  if (o === "id") {
480
- if (!/^\d+$/.test(c) || !Number.isSafeInteger(Number(c))) throw new t("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
222
+ if (!/^\d+$/.test(c) || !Number.isSafeInteger(Number(c))) throw new a("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
481
223
  r = Number(c);
482
224
  } else o === "data" && i.push(c);
483
225
  }
484
226
  if (i.length === 0) return;
485
- let a = i.join("\n");
486
- if (!a || a === "[DONE]") return;
487
- let o;
227
+ let o = i.join("\n");
228
+ if (!o || o === "[DONE]") return;
229
+ let s;
488
230
  try {
489
- o = JSON.parse(a);
231
+ s = JSON.parse(o);
490
232
  } catch (e) {
491
- throw new t("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
233
+ throw new a("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
492
234
  }
493
- let s = T(o);
494
- if (!s || s.conversationItem === void 0) {
495
- r !== void 0 && (n.cursor = Math.max(n.cursor, r));
235
+ let c = b(s);
236
+ if (!c || c.conversationItem === void 0) {
237
+ r !== void 0 && (t.cursor = Math.max(t.cursor, r));
496
238
  return;
497
239
  }
498
- if (r === void 0) throw new t("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
499
- let c = se(s.conversationItem);
500
- if (!c) throw new t("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
501
- if (n.runId && n.runId !== c.runId) throw new t("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
502
- runId: n.runId,
503
- cursor: n.cursor
240
+ if (r === void 0) throw new a("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
241
+ let l = n(c.conversationItem);
242
+ if (!l) throw new a("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
243
+ if (t.runId && t.runId !== l.runId) throw new a("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
244
+ runId: t.runId,
245
+ cursor: t.cursor
504
246
  });
505
- n.runId = c.runId;
506
- let l = n.reducer.apply(c);
507
- n.cursor = Math.max(n.cursor, r), l && n.options.onItem?.(c), n.options.onUpdate?.(D(n.reducer, n.cursor, n.runId));
247
+ t.runId = l.runId;
248
+ let u = t.reducer.apply(l);
249
+ t.cursor = Math.max(t.cursor, r), u && t.options.onItem?.(l), t.options.onUpdate?.(S(t.reducer, t.cursor, t.runId));
508
250
  }
509
- async function Ae(e, n) {
510
- if (!e.body) throw new t("conversation_stream_error", "Conversation response has no event stream body.");
511
- let r = e.body.getReader(), i = new TextDecoder(), a = "";
251
+ async function w(e, t) {
252
+ if (!e.body) throw new a("conversation_stream_error", "Conversation response has no event stream body.");
253
+ let n = e.body.getReader(), r = new TextDecoder(), i = "";
512
254
  try {
513
255
  for (;;) {
514
- E(n.options.signal);
515
- let { value: e, done: t } = await r.read();
516
- if (t) break;
517
- a += i.decode(e, { stream: !0 });
518
- let o = /\r?\n\r?\n/.exec(a);
256
+ x(t.options.signal);
257
+ let { value: e, done: a } = await n.read();
258
+ if (a) break;
259
+ i += r.decode(e, { stream: !0 });
260
+ let o = /\r?\n\r?\n/.exec(i);
519
261
  for (; o?.index !== void 0;) {
520
- let e = o.index, t = o[0].length;
521
- ke(a.slice(0, e), n), a = a.slice(e + t), o = /\r?\n\r?\n/.exec(a);
262
+ let e = o.index, n = o[0].length;
263
+ C(i.slice(0, e), t), i = i.slice(e + n), o = /\r?\n\r?\n/.exec(i);
522
264
  }
523
265
  }
524
- a += i.decode(), a.trim() && ke(a, n);
266
+ i += r.decode(), i.trim() && C(i, t);
525
267
  } catch (e) {
526
- throw e instanceof t ? e : (we(e, n.options.signal) && E(n.options.signal), new t("conversation_stream_error", "Conversation event stream was interrupted.", {
268
+ throw e instanceof a ? e : (ee(e, t.options.signal) && x(t.options.signal), new a("conversation_stream_error", "Conversation event stream was interrupted.", {
527
269
  cause: e,
528
- runId: n.runId || void 0,
529
- cursor: n.cursor
270
+ runId: t.runId || void 0,
271
+ cursor: t.cursor
530
272
  }));
531
273
  } finally {
532
- r.releaseLock();
274
+ n.releaseLock();
533
275
  }
534
276
  }
535
- function je(e) {
536
- return e.state.items.some((e) => S(e) !== void 0);
277
+ function T(e) {
278
+ return e.state.items.some((e) => l(e) !== void 0);
537
279
  }
538
- var Me = class {
280
+ var ae = class {
539
281
  fetcher;
540
282
  baseUrl;
541
283
  maxReconnects;
542
284
  sleep;
543
285
  retryDelayMs;
544
286
  constructor(e = {}) {
545
- if (!Number.isInteger(e.maxReconnects ?? w) || (e.maxReconnects ?? w) < 0 || (e.maxReconnects ?? w) > 32) throw new t("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
546
- this.fetcher = e.fetch, this.baseUrl = Te(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? w, this.sleep = e.sleep || De, this.retryDelayMs = e.retryDelayMs || Ee;
287
+ if (!Number.isInteger(e.maxReconnects ?? y) || (e.maxReconnects ?? y) < 0 || (e.maxReconnects ?? y) > 32) throw new a("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
288
+ this.fetcher = e.fetch, this.baseUrl = te(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? y, this.sleep = e.sleep || re, this.retryDelayMs = e.retryDelayMs || ne;
547
289
  }
548
290
  fetch() {
549
291
  if (this.fetcher) return this.fetcher;
550
292
  if (typeof globalThis.fetch == "function") return globalThis.fetch.bind(globalThis);
551
- throw new t("conversation_http_error", "No fetch implementation is available for the conversation client.");
293
+ throw new a("conversation_http_error", "No fetch implementation is available for the conversation client.");
552
294
  }
553
295
  url(e) {
554
296
  return `${this.baseUrl}${e}`;
555
297
  }
556
- async request(e, n, r, i = "conversation_stream_error") {
557
- E(r);
298
+ async request(e, t, n, r = "conversation_stream_error") {
299
+ x(n);
558
300
  try {
559
- return await this.fetch()(e, n);
301
+ return await this.fetch()(e, t);
560
302
  } catch (e) {
561
- throw e instanceof t ? e : (we(e, r) && E(r), new t(i, "Conversation network request failed.", { cause: e }));
303
+ throw e instanceof a ? e : (ee(e, n) && x(n), new a(r, "Conversation network request failed.", { cause: e }));
562
304
  }
563
305
  }
564
306
  assertOk(e) {
565
- if (!e.ok) throw new t("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
307
+ if (!e.ok) throw new a("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
566
308
  }
567
- async getSurface(e, n, r = {}) {
568
- if (!e || !n) throw new t("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
569
- let i = r.signal ? { signal: r.signal } : void 0, a = await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(n)}`), i, r.signal, "conversation_http_error");
570
- this.assertOk(a);
571
- let o;
309
+ async getSurface(e, t, n = {}) {
310
+ if (!e || !t) throw new a("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
311
+ let i = n.signal ? { signal: n.signal } : void 0, o = await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(t)}`), i, n.signal, "conversation_http_error");
312
+ this.assertOk(o);
313
+ let s;
572
314
  try {
573
- o = await a.json();
315
+ s = await o.json();
574
316
  } catch (e) {
575
- throw new t("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
317
+ throw new a("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
576
318
  }
577
- let s = T(o), c = oe(s?.surface);
578
- if (!s || typeof s.buildId != "string" || !s.buildId || !c) throw new t("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
319
+ let c = b(s), l = r(c?.surface);
320
+ if (!c || typeof c.buildId != "string" || !c.buildId || !l) throw new a("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
579
321
  return {
580
- buildId: s.buildId,
581
- surface: c
322
+ buildId: c.buildId,
323
+ surface: l
582
324
  };
583
325
  }
584
326
  async streamTurn(e) {
585
- E(e.signal), re(e.bootstrap.surface, e.input);
327
+ x(e.signal), t(e.bootstrap.surface, e.input);
586
328
  let n = {
587
329
  cursor: 0,
588
330
  runId: "",
589
- reducer: new Ce(),
331
+ reducer: new i(),
590
332
  options: e
591
333
  }, r = {
592
334
  method: "POST",
@@ -596,72 +338,72 @@ var Me = class {
596
338
  },
597
339
  body: JSON.stringify({ input: e.input }),
598
340
  ...e.signal ? { signal: e.signal } : {}
599
- }, i = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), r, e.signal);
600
- this.assertOk(i);
341
+ }, o = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), r, e.signal);
342
+ this.assertOk(o);
601
343
  try {
602
- await Ae(i, n);
344
+ await w(o, n);
603
345
  } catch (e) {
604
- if (!(e instanceof t) || e.code !== "conversation_stream_error" || !n.runId) throw e;
346
+ if (!(e instanceof a) || e.code !== "conversation_stream_error" || !n.runId) throw e;
605
347
  }
606
- let a = D(n.reducer, n.cursor, n.runId);
607
- if (je(a)) return a;
608
- if (!n.runId) throw new t("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: n.cursor });
609
- for (let r = 1; r <= this.maxReconnects; r += 1) {
610
- await Oe(this.sleep, this.retryDelayMs(r), e.signal), E(e.signal);
611
- let i;
348
+ let s = S(n.reducer, n.cursor, n.runId);
349
+ if (T(s)) return s;
350
+ if (!n.runId) throw new a("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: n.cursor });
351
+ for (let t = 1; t <= this.maxReconnects; t += 1) {
352
+ await ie(this.sleep, this.retryDelayMs(t), e.signal), x(e.signal);
353
+ let r;
612
354
  try {
613
- i = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(n.runId)}/events?after=${n.cursor}`), {
355
+ r = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(n.runId)}/events?after=${n.cursor}`), {
614
356
  method: "GET",
615
357
  headers: { "Last-Event-ID": String(n.cursor) },
616
358
  ...e.signal ? { signal: e.signal } : {}
617
- }, e.signal), this.assertOk(i), await Ae(i, n);
359
+ }, e.signal), this.assertOk(r), await w(r, n);
618
360
  } catch (e) {
619
- if (e instanceof t && e.code === "conversation_aborted" || e instanceof t && e.code === "conversation_contract_mismatch" || e instanceof t && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
361
+ if (e instanceof a && e.code === "conversation_aborted" || e instanceof a && e.code === "conversation_contract_mismatch" || e instanceof a && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
620
362
  continue;
621
363
  }
622
- if (a = D(n.reducer, n.cursor, n.runId), je(a)) return a;
364
+ if (s = S(n.reducer, n.cursor, n.runId), T(s)) return s;
623
365
  }
624
- throw new t("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
366
+ throw new a("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
625
367
  runId: n.runId,
626
368
  cursor: n.cursor
627
369
  });
628
370
  }
629
- }, Ne = 0;
630
- function O(e) {
631
- return Ne += 1, `${e}-${Ne}`;
371
+ }, oe = 0;
372
+ function E(e) {
373
+ return oe += 1, `${e}-${oe}`;
632
374
  }
633
- function k(e) {
375
+ function D(e) {
634
376
  return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
635
377
  ...e,
636
378
  status: "done"
637
379
  } : e);
638
380
  }
639
- function Pe(e, t) {
381
+ function se(e, t) {
640
382
  let n = [...e ?? []], r = n[n.length - 1];
641
383
  return r?.type === "thinking" && r.status === "streaming" ? (n[n.length - 1] = {
642
384
  ...r,
643
385
  content: r.content + t
644
386
  }, n) : [...n, {
645
- id: O("thinking"),
387
+ id: E("thinking"),
646
388
  type: "thinking",
647
389
  content: t,
648
390
  status: "streaming"
649
391
  }];
650
392
  }
651
- function Fe(e, t) {
652
- let n = [...k(e ?? [])], r = n[n.length - 1];
393
+ function ce(e, t) {
394
+ let n = [...D(e ?? [])], r = n[n.length - 1];
653
395
  return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
654
396
  ...r,
655
397
  content: r.content + t
656
398
  }, n) : [...n, {
657
- id: O("text"),
399
+ id: E("text"),
658
400
  type: "text",
659
401
  content: t,
660
402
  status: "streaming"
661
403
  }];
662
404
  }
663
- function Ie(e, t) {
664
- let n = k(e ?? []);
405
+ function le(e, t) {
406
+ let n = D(e ?? []);
665
407
  if (n.filter((e) => e.type === "text").map((e) => e.content).join("") === t) return n.map((e) => e.type === "text" && e.status === "streaming" ? {
666
408
  ...e,
667
409
  status: "done"
@@ -672,13 +414,13 @@ function Ie(e, t) {
672
414
  content: t,
673
415
  status: "done"
674
416
  }, r) : [...r, {
675
- id: O("text"),
417
+ id: E("text"),
676
418
  type: "text",
677
419
  content: t,
678
420
  status: "done"
679
421
  }];
680
422
  }
681
- function Le(e, t) {
423
+ function ue(e, t) {
682
424
  if (!t) return [...e ?? []];
683
425
  let n = [...e ?? []], r = n[n.length - 1];
684
426
  if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
@@ -688,8 +430,8 @@ function Le(e, t) {
688
430
  content: i
689
431
  }, n) : (n.pop(), n);
690
432
  }
691
- function Re(e, t, n) {
692
- let r = [...k(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
433
+ function de(e, t, n) {
434
+ let r = [...D(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
693
435
  if (i >= 0 && r[i].type === "tool") {
694
436
  let e = r[i], t = e.status === "error" || e.status === "completed", a = n.output !== void 0, o = n.extra && (n.extra.approvalRequestId || n.extra.approvalStatus);
695
437
  if (t && !a && !o) return r;
@@ -701,7 +443,7 @@ function Re(e, t, n) {
701
443
  }, r;
702
444
  }
703
445
  return [...r, {
704
- id: O("tool"),
446
+ id: E("tool"),
705
447
  type: "tool",
706
448
  toolName: t,
707
449
  args: n.args ?? "",
@@ -710,18 +452,18 @@ function Re(e, t, n) {
710
452
  extra: n.extra
711
453
  }];
712
454
  }
713
- function ze(e) {
714
- return k(e ?? []);
455
+ function fe(e) {
456
+ return D(e ?? []);
715
457
  }
716
- function Be(e) {
458
+ function pe(e) {
717
459
  let t = [];
718
460
  if (e.reasoning && e.reasoning.trim() && t.push({
719
- id: O("thinking"),
461
+ id: E("thinking"),
720
462
  type: "thinking",
721
463
  content: e.reasoning,
722
464
  status: "done"
723
465
  }), e.tools) for (let n of Object.values(e.tools)) t.push({
724
- id: O("tool"),
466
+ id: E("tool"),
725
467
  type: "tool",
726
468
  toolName: n.name,
727
469
  args: n.args ?? "",
@@ -730,7 +472,7 @@ function Be(e) {
730
472
  ...n.callId ? { extra: { callId: n.callId } } : {}
731
473
  });
732
474
  return e.content && e.content.trim() && t.push({
733
- id: O("text"),
475
+ id: E("text"),
734
476
  type: "text",
735
477
  content: e.content,
736
478
  status: "done"
@@ -738,40 +480,40 @@ function Be(e) {
738
480
  }
739
481
  //#endregion
740
482
  //#region src/core/stream/kernel-events.ts
741
- var Ve = {
483
+ var me = {
742
484
  "run.started": "in_progress",
743
485
  "run.progress": "in_progress",
744
486
  "run.completed": "completed",
745
487
  "run.failed": "failed",
746
488
  "run.canceled": "cancelled",
747
489
  "run.interrupted": "interrupted"
748
- }, He = new Set([
490
+ }, he = new Set([
749
491
  "completed",
750
492
  "failed",
751
493
  "cancelled",
752
494
  "canceled"
753
495
  ]);
754
- function A(e) {
496
+ function O(e) {
755
497
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
756
498
  }
757
- function Ue(e) {
758
- let t = A(e.source), n = t ? A(t.metadata) : null;
499
+ function ge(e) {
500
+ let t = O(e.source), n = t ? O(t.metadata) : null;
759
501
  return String(n?.native_item_kind || "");
760
502
  }
761
- function j(e, t) {
762
- let n = A(e[t]);
503
+ function k(e, t) {
504
+ let n = O(e[t]);
763
505
  if (!n) return [];
764
506
  let r = n?.parts;
765
507
  return Array.isArray(r) ? r : t === "update" ? [n] : [];
766
508
  }
767
- function We(e) {
768
- let t = A(e);
509
+ function _e(e) {
510
+ let t = O(e);
769
511
  if (!t) return "";
770
512
  if (typeof t.text == "string") return t.text;
771
- let n = A(t.data);
513
+ let n = O(t.data);
772
514
  if (n) {
773
515
  let e = n.content;
774
- if (Array.isArray(e)) return e.map((e) => String(A(e)?.text || "")).join("");
516
+ if (Array.isArray(e)) return e.map((e) => String(O(e)?.text || "")).join("");
775
517
  for (let e of [
776
518
  "text",
777
519
  "output",
@@ -781,31 +523,31 @@ function We(e) {
781
523
  }
782
524
  return "";
783
525
  }
784
- function M(e) {
785
- return e.map(We).join("");
526
+ function A(e) {
527
+ return e.map(_e).join("");
786
528
  }
787
- function Ge(e) {
788
- return e.some((e) => A(A(e)?.data)?.type === "userMessage");
529
+ function j(e) {
530
+ return e.some((e) => O(O(e)?.data)?.type === "userMessage");
789
531
  }
790
- function N(e) {
532
+ function M(e) {
791
533
  if (e.length === 1) {
792
- let t = A(A(e[0])?.data);
534
+ let t = O(O(e[0])?.data);
793
535
  if (t) return t;
794
536
  }
795
- return M(e) || null;
537
+ return A(e) || null;
796
538
  }
797
- function P(e) {
798
- let t = A(e);
799
- return t ? A(t.data) || t : null;
539
+ function N(e) {
540
+ let t = O(e);
541
+ return t ? O(t.data) || t : null;
800
542
  }
801
- function F(e) {
802
- let t = P(e);
543
+ function P(e) {
544
+ let t = N(e);
803
545
  return String(t?.content_type || t?.type || "").trim().toLowerCase();
804
546
  }
805
- function I(e) {
547
+ function F(e) {
806
548
  for (let t of e) {
807
- let e = P(t);
808
- if (!e || F(t) !== "tool_call") continue;
549
+ let e = N(t);
550
+ if (!e || P(t) !== "tool_call") continue;
809
551
  let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
810
552
  if (!(!n && !r)) return {
811
553
  callId: n,
@@ -815,10 +557,10 @@ function I(e) {
815
557
  }
816
558
  return null;
817
559
  }
818
- function L(e) {
560
+ function I(e) {
819
561
  for (let t of e) {
820
- let e = P(t);
821
- if (!e || F(t) !== "tool_result") continue;
562
+ let e = N(t);
563
+ if (!e || P(t) !== "tool_result") continue;
822
564
  let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
823
565
  return {
824
566
  callId: n,
@@ -828,7 +570,7 @@ function L(e) {
828
570
  }
829
571
  return null;
830
572
  }
831
- function R(e, t, n, r) {
573
+ function L(e, t, n, r) {
832
574
  let i = String(e.item_id || ""), a = String(r || i);
833
575
  return { RuntimeItem: {
834
576
  RunId: String(e.run_id || ""),
@@ -840,7 +582,7 @@ function R(e, t, n, r) {
840
582
  ...i && i !== a ? { SourceItemId: i } : {}
841
583
  } };
842
584
  }
843
- var Ke = class {
585
+ var ve = class {
844
586
  textByPart = /* @__PURE__ */ new Map();
845
587
  toolNameByCallId = /* @__PURE__ */ new Map();
846
588
  toolCallByItemId = /* @__PURE__ */ new Map();
@@ -850,7 +592,7 @@ var Ke = class {
850
592
  this.sessionId = e;
851
593
  }
852
594
  translate(e) {
853
- if (!A(e)) return null;
595
+ if (!O(e)) return null;
854
596
  let t = Number(e.seq);
855
597
  if (!Number.isFinite(t) || t <= 0) return null;
856
598
  let n = String(e.family || ""), r = String(e.event_type || ""), i = String(e.run_id || ""), a = () => ({
@@ -867,7 +609,7 @@ var Ke = class {
867
609
  if (n === "control") {
868
610
  if (r === "control.run_transition") {
869
611
  let t = String(e.state || "").toLowerCase();
870
- if (He.has(t)) return {
612
+ if (he.has(t)) return {
871
613
  ...a(),
872
614
  EventType: "run_status",
873
615
  Content: { status: t }
@@ -876,17 +618,17 @@ var Ke = class {
876
618
  return null;
877
619
  }
878
620
  if (n !== "runtime") return null;
879
- let o = Ve[r];
621
+ let o = me[r];
880
622
  if (o) return {
881
623
  ...a(),
882
624
  EventType: "run_status",
883
625
  Content: { status: o }
884
626
  };
885
- let s = Ue(e);
627
+ let s = ge(e);
886
628
  if (r === "item.started") {
887
- let t = j(e, "initial");
629
+ let t = k(e, "initial");
888
630
  if (e.item_kind === "tool_call") {
889
- let n = I(t), r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
631
+ let n = F(t), r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
890
632
  return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
891
633
  callId: r,
892
634
  name: o
@@ -894,42 +636,42 @@ var Ke = class {
894
636
  ...a(),
895
637
  EventType: "tool_call",
896
638
  Metadata: {
897
- ...R(e, "replace", void 0, r),
639
+ ...L(e, "replace", void 0, r),
898
640
  call_id: r,
899
641
  tool_name: o,
900
642
  run_id: i,
901
- tool_args: n?.arguments ?? N(t)
643
+ tool_args: n?.arguments ?? M(t)
902
644
  }
903
645
  };
904
646
  }
905
- return e.item_kind === "tool_result" || s === "userMessage" || Ge(t) || s === "reasoning" || e.item_kind === "reasoning" ? null : s === "agentMessage" || !s && e.item_kind === "message" ? {
647
+ return e.item_kind === "tool_result" || s === "userMessage" || j(t) || s === "reasoning" || e.item_kind === "reasoning" ? null : s === "agentMessage" || !s && e.item_kind === "message" ? {
906
648
  ...a(),
907
649
  EventType: "assistant_stream_snapshot",
908
650
  Content: { parts: [{ text: "" }] },
909
- Metadata: R(e, "replace")
651
+ Metadata: L(e, "replace")
910
652
  } : s && s !== "notification" ? {
911
653
  ...a(),
912
654
  EventType: "tool_call",
913
655
  Metadata: {
914
- ...R(e, "replace"),
656
+ ...L(e, "replace"),
915
657
  call_id: String(e.item_id || ""),
916
658
  tool_name: s,
917
659
  run_id: i,
918
- tool_args: N(t)
660
+ tool_args: M(t)
919
661
  }
920
662
  } : null;
921
663
  }
922
664
  if (r === "item.updated") {
923
- let n = j(e, "update");
665
+ let n = k(e, "update");
924
666
  if (e.item_kind === "tool_call") {
925
- let t = L(n);
667
+ let t = I(n);
926
668
  if (!t) return null;
927
669
  let r = this.toolCallByItemId.get(String(e.item_id || "")), o = t.callId || r?.callId || String(e.item_id || ""), s = r?.name || this.toolNameByCallId.get(o) || "tool", c = t.isError ? { error: t.result } : t.result;
928
670
  return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
929
671
  ...a(),
930
672
  EventType: "tool_result",
931
673
  Metadata: {
932
- ...R(e, "completed", void 0, o),
674
+ ...L(e, "completed", void 0, o),
933
675
  call_id: o,
934
676
  tool_name: s,
935
677
  run_id: i,
@@ -937,44 +679,44 @@ var Ke = class {
937
679
  }
938
680
  };
939
681
  }
940
- let r = A(n[0]), o = String(r?.part_id || e.item_id || t), c = String(e.op || "replace"), l = M(n), u = this.textByPart.get(o) || "", d = c === "append" ? u + l : l;
682
+ let r = O(n[0]), o = String(r?.part_id || e.item_id || t), c = String(e.op || "replace"), l = A(n), u = this.textByPart.get(o) || "", d = c === "append" ? u + l : l;
941
683
  return this.textByPart.set(o, d), s === "agentMessage" || !s && e.item_kind === "message" ? {
942
684
  ...a(),
943
685
  EventType: "assistant_stream_snapshot",
944
686
  Content: { parts: [{ text: d }] },
945
- Metadata: R(e, "replace", o)
687
+ Metadata: L(e, "replace", o)
946
688
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
947
689
  ...a(),
948
690
  EventType: "reasoning",
949
691
  Content: { parts: [{ text: l }] },
950
- Metadata: R(e, c === "append" ? "append" : "replace", o)
692
+ Metadata: L(e, c === "append" ? "append" : "replace", o)
951
693
  } : null;
952
694
  }
953
695
  if (r === "item.snapshot_replaced") {
954
- let n = j(e, "snapshot"), r = String(A(n[0])?.part_id || e.item_id || t), i = M(n);
696
+ let n = k(e, "snapshot"), r = String(O(n[0])?.part_id || e.item_id || t), i = A(n);
955
697
  return this.textByPart.set(r, i), s === "agentMessage" || !s && e.item_kind === "message" ? {
956
698
  ...a(),
957
699
  EventType: "assistant_stream_snapshot",
958
700
  Content: { parts: [{ text: i }] },
959
- Metadata: R(e, "replace", r)
701
+ Metadata: L(e, "replace", r)
960
702
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
961
703
  ...a(),
962
704
  EventType: "reasoning",
963
705
  Content: { parts: [{ text: i }] },
964
- Metadata: R(e, "replace", r)
706
+ Metadata: L(e, "replace", r)
965
707
  } : null;
966
708
  }
967
709
  if (r === "item.completed") {
968
- let n = j(e, "snapshot");
710
+ let n = k(e, "snapshot");
969
711
  if (e.item_kind === "tool_call") {
970
- let t = I(n), r = L(n), o = this.toolCallByItemId.get(String(e.item_id || "")), s = r?.callId || t?.callId || o?.callId || String(e.item_id || ""), c = t?.name || o?.name || this.toolNameByCallId.get(s) || "tool";
712
+ let t = F(n), r = I(n), o = this.toolCallByItemId.get(String(e.item_id || "")), s = r?.callId || t?.callId || o?.callId || String(e.item_id || ""), c = t?.name || o?.name || this.toolNameByCallId.get(s) || "tool";
971
713
  if (s && this.toolNameByCallId.set(s, c), r) {
972
714
  let t = r.isError ? { error: r.result } : r.result;
973
715
  return {
974
716
  ...a(),
975
717
  EventType: "tool_result",
976
718
  Metadata: {
977
- ...R(e, "completed", void 0, s),
719
+ ...L(e, "completed", void 0, s),
978
720
  call_id: s,
979
721
  tool_name: c,
980
722
  run_id: i,
@@ -986,21 +728,21 @@ var Ke = class {
986
728
  ...a(),
987
729
  EventType: "tool_call",
988
730
  Metadata: {
989
- ...R(e, "replace", void 0, s),
731
+ ...L(e, "replace", void 0, s),
990
732
  call_id: s,
991
733
  tool_name: c,
992
734
  run_id: i,
993
- tool_args: t?.arguments ?? N(n)
735
+ tool_args: t?.arguments ?? M(n)
994
736
  }
995
737
  };
996
738
  }
997
739
  if (e.item_kind === "tool_result") {
998
- let t = L(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || s || "tool", c = t?.isError ? { error: t.result } : t?.result ?? N(n);
740
+ let t = I(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || s || "tool", c = t?.isError ? { error: t.result } : t?.result ?? M(n);
999
741
  return {
1000
742
  ...a(),
1001
743
  EventType: "tool_result",
1002
744
  Metadata: {
1003
- ...R(e, "completed", void 0, r),
745
+ ...L(e, "completed", void 0, r),
1004
746
  call_id: r,
1005
747
  tool_name: o,
1006
748
  run_id: i,
@@ -1008,38 +750,38 @@ var Ke = class {
1008
750
  }
1009
751
  };
1010
752
  }
1011
- if (s === "userMessage" || Ge(n)) return {
753
+ if (s === "userMessage" || j(n)) return {
1012
754
  ...a(),
1013
755
  EventType: "user_message",
1014
- Content: { parts: [{ text: M(n) }] }
756
+ Content: { parts: [{ text: A(n) }] }
1015
757
  };
1016
758
  if (s === "agentMessage" || !s && e.item_kind === "message") {
1017
- let r = M(n), i = String(A(n[0])?.part_id || e.item_id || t);
759
+ let r = A(n), i = String(O(n[0])?.part_id || e.item_id || t);
1018
760
  return this.textByPart.set(i, r), {
1019
761
  ...a(),
1020
762
  EventType: "assistant_message",
1021
763
  Content: { parts: [{ text: r }] },
1022
- Metadata: R(e, "completed", i)
764
+ Metadata: L(e, "completed", i)
1023
765
  };
1024
766
  }
1025
767
  if (s === "reasoning" || e.item_kind === "reasoning") {
1026
- let r = String(A(n[0])?.part_id || e.item_id || t);
768
+ let r = String(O(n[0])?.part_id || e.item_id || t);
1027
769
  return {
1028
770
  ...a(),
1029
771
  EventType: "reasoning",
1030
- Content: { parts: [{ text: M(n) }] },
1031
- Metadata: R(e, "completed", r)
772
+ Content: { parts: [{ text: A(n) }] },
773
+ Metadata: L(e, "completed", r)
1032
774
  };
1033
775
  }
1034
776
  return s && s !== "notification" ? {
1035
777
  ...a(),
1036
778
  EventType: "tool_result",
1037
779
  Metadata: {
1038
- ...R(e, "completed"),
780
+ ...L(e, "completed"),
1039
781
  call_id: String(e.item_id || ""),
1040
782
  tool_name: s,
1041
783
  run_id: i,
1042
- tool_output: N(n)
784
+ tool_output: M(n)
1043
785
  }
1044
786
  } : null;
1045
787
  }
@@ -1050,11 +792,11 @@ var Ke = class {
1050
792
  ...a(),
1051
793
  EventType: "tool_result",
1052
794
  Metadata: {
1053
- ...R(e, "completed", void 0, n),
795
+ ...L(e, "completed", void 0, n),
1054
796
  call_id: n,
1055
797
  tool_name: r,
1056
798
  run_id: i,
1057
- tool_output: o ?? { error: A(e.error) || e.error || "item failed" }
799
+ tool_output: o ?? { error: O(e.error) || e.error || "item failed" }
1058
800
  }
1059
801
  };
1060
802
  }
@@ -1062,18 +804,18 @@ var Ke = class {
1062
804
  ...a(),
1063
805
  EventType: "tool_result",
1064
806
  Metadata: {
1065
- ...R(e, "completed"),
807
+ ...L(e, "completed"),
1066
808
  call_id: String(e.item_id || ""),
1067
809
  tool_name: s,
1068
810
  run_id: i,
1069
- tool_output: { error: A(e.error) || e.error || "item failed" }
811
+ tool_output: { error: O(e.error) || e.error || "item failed" }
1070
812
  }
1071
813
  } : null;
1072
814
  }
1073
815
  return null;
1074
816
  }
1075
817
  };
1076
- async function qe(e) {
818
+ async function ye(e) {
1077
819
  let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
1078
820
  try {
1079
821
  for (;;) {
@@ -1083,13 +825,15 @@ async function qe(e) {
1083
825
  break;
1084
826
  }
1085
827
  if (r.trimStart().startsWith("{")) {
1086
- if (Je(r)) {
1087
- i = Ye(r);
828
+ if (be(r)) {
829
+ i = xe(r);
1088
830
  break;
1089
831
  }
1090
832
  } else if (o(r)) break;
1091
833
  }
1092
- } catch {}
834
+ } catch (e) {
835
+ throw t.releaseLock(), e;
836
+ }
1093
837
  let s = new TextEncoder().encode(r), c = new ReadableStream({
1094
838
  start(e) {
1095
839
  if (s.length > 0 && e.enqueue(s), a || i) {
@@ -1102,15 +846,15 @@ async function qe(e) {
1102
846
  return;
1103
847
  }
1104
848
  return n();
1105
- }).catch(() => {
849
+ }).catch((t) => {
1106
850
  try {
1107
- e.close();
851
+ e.error(t);
1108
852
  } catch {}
1109
853
  });
1110
854
  n();
1111
855
  },
1112
856
  cancel() {
1113
- t.cancel();
857
+ t.cancel().catch(() => {});
1114
858
  }
1115
859
  });
1116
860
  return {
@@ -1118,7 +862,7 @@ async function qe(e) {
1118
862
  stream: c
1119
863
  };
1120
864
  }
1121
- function Je(e) {
865
+ function be(e) {
1122
866
  let t = e.trim();
1123
867
  if (!t.endsWith("}")) return !1;
1124
868
  let n = 0, r = !1, i = !1;
@@ -1135,11 +879,11 @@ function Je(e) {
1135
879
  }
1136
880
  return n === 0;
1137
881
  }
1138
- function Ye(e) {
882
+ function xe(e) {
1139
883
  try {
1140
- let t = A(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
884
+ let t = O(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1141
885
  if (!n) return null;
1142
- let r = A(t?.Error);
886
+ let r = O(t?.Error);
1143
887
  return {
1144
888
  status: n,
1145
889
  messageId: t?.MessageId ?? null,
@@ -1156,7 +900,7 @@ function Ye(e) {
1156
900
  }
1157
901
  //#endregion
1158
902
  //#region src/utils/responses-stream.js
1159
- function Xe() {
903
+ function R() {
1160
904
  return {
1161
905
  toolNames: /* @__PURE__ */ new Map(),
1162
906
  toolArguments: /* @__PURE__ */ new Map(),
@@ -1166,7 +910,7 @@ function Xe() {
1166
910
  sawReasoningDelta: !1
1167
911
  };
1168
912
  }
1169
- function Ze(e) {
913
+ function Se(e) {
1170
914
  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 : "";
1171
915
  }
1172
916
  function z(e) {
@@ -1174,15 +918,15 @@ function z(e) {
1174
918
  }
1175
919
  function B(...e) {
1176
920
  for (let t of e) {
1177
- let e = Ze(t);
921
+ let e = Se(t);
1178
922
  if (e) return e;
1179
923
  }
1180
924
  return "";
1181
925
  }
1182
- function Qe(e, t) {
926
+ function Ce(e, t) {
1183
927
  return String(e?.id || e?.item_id || e?.call_id || t?.item_id || t?.call_id || t?.output_index || "");
1184
928
  }
1185
- function $e(e, t, n, r, i) {
929
+ function we(e, t, n, r, i) {
1186
930
  t && (e.toolNames.set(t, r), e.toolArguments.set(t, i));
1187
931
  let a = String(n?.call_id || "");
1188
932
  a && (e.callIds.set(a, t || r), e.toolNames.set(a, r), e.toolArguments.set(a, i));
@@ -1193,10 +937,10 @@ function V(e, t, n, r = "tool") {
1193
937
  }
1194
938
  function H(e) {
1195
939
  if (!e || typeof e != "object") return "";
1196
- let t = Ze(e.content);
940
+ let t = Se(e.content);
1197
941
  return B(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
1198
942
  }
1199
- function et(e) {
943
+ function Te(e) {
1200
944
  let t = e?.response && typeof e.response == "object" ? e.response : e, n = B(t?.output_text, t?.text);
1201
945
  if (n) return n;
1202
946
  let r = Array.isArray(t?.output) ? t.output : [];
@@ -1206,11 +950,11 @@ function et(e) {
1206
950
  }
1207
951
  return "";
1208
952
  }
1209
- function tt(e) {
953
+ function Ee(e) {
1210
954
  let t = e?.response && typeof e.response == "object" ? e.response : e;
1211
955
  return Array.isArray(t?.output) ? t.output : [];
1212
956
  }
1213
- function nt(e) {
957
+ function De(e) {
1214
958
  let t = e;
1215
959
  if (typeof t == "string") try {
1216
960
  t = JSON.parse(t);
@@ -1223,10 +967,10 @@ function nt(e) {
1223
967
  } : t;
1224
968
  }
1225
969
  function U({ data: e, state: t, status: n }) {
1226
- let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Qe(r, e);
970
+ let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Ce(r, e);
1227
971
  if (i === "function_call") {
1228
972
  let e = V(t, a, r), i = z(r.arguments ?? r.args ?? r.input);
1229
- return $e(t, a, r, e, i), [{
973
+ return we(t, a, r, e, i), [{
1230
974
  type: "tool_upsert",
1231
975
  name: e,
1232
976
  args: i,
@@ -1273,7 +1017,7 @@ function U({ data: e, state: t, status: n }) {
1273
1017
  }
1274
1018
  return [];
1275
1019
  }
1276
- function rt({ eventName: e, data: t, state: n }) {
1020
+ function Oe({ eventName: e, data: t, state: n }) {
1277
1021
  let r = String(t?.type || e || "").trim(), i = String(t?.id || t?.response?.id || t?.response_id || "");
1278
1022
  if (i.startsWith("resp_") && (n.currentResponseId = i), r === "response.tool_call") return [{
1279
1023
  type: "tool_upsert",
@@ -1346,7 +1090,7 @@ function rt({ eventName: e, data: t, state: n }) {
1346
1090
  }]) : [];
1347
1091
  }
1348
1092
  if (r === "response.completed") {
1349
- let e = et(t), r = tt(t).flatMap((e) => U({
1093
+ let e = Te(t), r = Ee(t).flatMap((e) => U({
1350
1094
  data: {
1351
1095
  ...t,
1352
1096
  item: e
@@ -1382,7 +1126,7 @@ function rt({ eventName: e, data: t, state: n }) {
1382
1126
  status: "cancelled"
1383
1127
  }];
1384
1128
  if (r === "response.approval_request" || r === "response.ksadk.approval_request") {
1385
- let e = nt(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 : [];
1129
+ let e = De(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 : [];
1386
1130
  if (s.length > 0) {
1387
1131
  let e = s.map((e) => ({
1388
1132
  type: "tool_upsert",
@@ -1470,7 +1214,7 @@ function rt({ eventName: e, data: t, state: n }) {
1470
1214
  }
1471
1215
  //#endregion
1472
1216
  //#region src/utils/session-events.js
1473
- var it = new Set([
1217
+ var ke = new Set([
1474
1218
  "completed",
1475
1219
  "failed",
1476
1220
  "error",
@@ -1496,11 +1240,11 @@ function K(e) {
1496
1240
  let t = e?.Content?.payload;
1497
1241
  return t && typeof t == "object" ? t : {};
1498
1242
  }
1499
- function at(e, t) {
1243
+ function Ae(e, t) {
1500
1244
  let n = String(e || ""), r = String(t || "");
1501
1245
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1502
1246
  }
1503
- function ot(e) {
1247
+ function je(e) {
1504
1248
  let t = String(e?.EventType || ""), n = K(e);
1505
1249
  return G[t] ? {
1506
1250
  ...e,
@@ -1544,21 +1288,21 @@ function ot(e) {
1544
1288
  }
1545
1289
  } : e;
1546
1290
  }
1547
- function st(e) {
1291
+ function Me(e) {
1548
1292
  let t = [], n = /* @__PURE__ */ new Map();
1549
1293
  for (let r of Array.isArray(e) ? e : []) {
1550
1294
  let e = String(r?.EventType || "");
1551
- if (e === "text.delta" || e === "text.completed") {
1295
+ if (e === "text.delta" || e === "text.completed" || e === "message.delta") {
1552
1296
  let e = String(r?.InvocationId || "").trim();
1553
1297
  if (!e) continue;
1554
1298
  let t = n.get(e);
1555
1299
  n.set(e, {
1556
1300
  event: r,
1557
- text: at(t?.text, K(r).text)
1301
+ text: Ae(t?.text, K(r).text || r?.Content?.text)
1558
1302
  });
1559
1303
  continue;
1560
1304
  }
1561
- t.push(ot(r));
1305
+ t.push(je(r));
1562
1306
  }
1563
1307
  for (let { event: e, text: r } of n.values()) t.push({
1564
1308
  ...e,
@@ -1572,9 +1316,17 @@ function st(e) {
1572
1316
  stream_snapshot: !0
1573
1317
  }
1574
1318
  });
1575
- return t.sort((e, t) => Q(e) - Q(t));
1319
+ for (let n of Array.isArray(e) ? e : []) String(n?.EventType || "") === "message.completed" && t.push({
1320
+ ...n,
1321
+ EventType: "assistant_message",
1322
+ Content: {
1323
+ role: "model",
1324
+ parts: [{ text: String(K(n).text || n?.Content?.text || "") }]
1325
+ }
1326
+ });
1327
+ return t.sort((e, t) => Z(e) - Z(t));
1576
1328
  }
1577
- function ct(e) {
1329
+ function Ne(e) {
1578
1330
  let t = String(e?.EventType || "").trim();
1579
1331
  if (t !== "run_status" && !t.startsWith("run.")) return "";
1580
1332
  let n = K(e);
@@ -1587,10 +1339,10 @@ function J(e) {
1587
1339
  let t = String(e || "").trim();
1588
1340
  return t ? `/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}` : "";
1589
1341
  }
1590
- function lt(e) {
1342
+ function Pe(e) {
1591
1343
  return String(e || "").match(/^data:([^;,]+)/)?.[1] || "";
1592
1344
  }
1593
- function ut(e, t) {
1345
+ function Fe(e, t) {
1594
1346
  let n = String(e || "").trim(), r = String(t || "").trim();
1595
1347
  return !n || !r || n === r ? !0 : n.endsWith("/*") ? r.startsWith(n.slice(0, -1)) : r.endsWith("/*") ? n.startsWith(r.slice(0, -1)) : !1;
1596
1348
  }
@@ -1635,7 +1387,7 @@ function Y(e) {
1635
1387
  t && i({
1636
1388
  name: e.filename || e.displayName || e.display_name || "uploaded_image",
1637
1389
  url: t,
1638
- type: e.mime_type || e.mimeType || lt(t) || "image/*"
1390
+ type: e.mime_type || e.mimeType || Pe(t) || "image/*"
1639
1391
  });
1640
1392
  continue;
1641
1393
  }
@@ -1657,7 +1409,7 @@ function Y(e) {
1657
1409
  type: e.mime_type || "application/octet-stream",
1658
1410
  fileUri: t
1659
1411
  };
1660
- !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && ut(e.type, n.type) && (e.url || e.fileUri)) || i(n);
1412
+ !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && Fe(e.type, n.type) && (e.url || e.fileUri)) || i(n);
1661
1413
  }
1662
1414
  let o = Array.from(r.values());
1663
1415
  return {
@@ -1665,10 +1417,10 @@ function Y(e) {
1665
1417
  attachments: o.length > 0 ? o : void 0
1666
1418
  };
1667
1419
  }
1668
- function dt(t) {
1420
+ function Ie(t) {
1669
1421
  let n = t?.Metadata?.responses_output;
1670
1422
  if (!Array.isArray(n)) return {};
1671
- let r = Xe(), i = rt({
1423
+ let r = R(), i = Oe({
1672
1424
  eventName: "response.completed",
1673
1425
  data: { response: {
1674
1426
  id: String(t.Metadata?.response_id || ""),
@@ -1712,10 +1464,10 @@ function dt(t) {
1712
1464
  ...Object.keys(o).length > 0 ? { tools: o } : {}
1713
1465
  };
1714
1466
  }
1715
- function ft(e, t, n) {
1467
+ function Le(e, t, n) {
1716
1468
  return t === "running" ? e === "prompt_too_long" ? "检测到上下文过长,正在自动压缩历史后重试" : "正在自动压缩上下文" : n ? e === "prompt_too_long" ? "上下文过长,系统已自动压缩历史并重试" : "系统已自动压缩较早的对话上下文" : t === "failed" ? "自动压缩上下文未完成" : e === "prompt_too_long" ? "已完成上下文压缩,并继续当前回复" : "已完成上下文压缩";
1717
1469
  }
1718
- function pt(e, t) {
1470
+ function Re(e, t) {
1719
1471
  return t?.itemId ? [
1720
1472
  "runtime-item",
1721
1473
  t.runId || e,
@@ -1736,7 +1488,7 @@ function X(e) {
1736
1488
  n.ItemId
1737
1489
  ].join("\0") : t;
1738
1490
  }
1739
- function mt(e) {
1491
+ function ze(e) {
1740
1492
  let t = e?.Metadata?.RuntimeItem;
1741
1493
  return t?.ItemId ? {
1742
1494
  id: `runtime:${t.RunId || e.InvocationId || "run"}:${t.ScopeId || e.InvocationId || "scope"}:${t.ItemId}`,
@@ -1746,10 +1498,10 @@ function mt(e) {
1746
1498
  partId: t.PartId ? String(t.PartId) : void 0
1747
1499
  } : null;
1748
1500
  }
1749
- function ht(e) {
1501
+ function Be(e) {
1750
1502
  return e?.Metadata?.responses_mirror === !0 || String(e?.Metadata?.responses_mirror || "").trim().toLowerCase() === "true";
1751
1503
  }
1752
- function Z(e) {
1504
+ function Ve(e) {
1753
1505
  if (e?.EventType !== "user_message") return "";
1754
1506
  let t = Y(e), n = (t.attachments || []).map((e) => [
1755
1507
  e.name || "",
@@ -1759,16 +1511,16 @@ function Z(e) {
1759
1511
  ].join("")).sort().join("");
1760
1512
  return [String(t.text || "").trim(), n].join("\0");
1761
1513
  }
1762
- function gt(e) {
1514
+ function He(e) {
1763
1515
  return e?.EventType === "assistant_stream_snapshot";
1764
1516
  }
1765
- function Q(e) {
1517
+ function Z(e) {
1766
1518
  let t = Number(e?.SeqId || 0);
1767
1519
  if (Number.isFinite(t) && t > 0) return t;
1768
1520
  let n = Number(e?.Timestamp || 0);
1769
1521
  return Number.isFinite(n) ? n : 0;
1770
1522
  }
1771
- function _t(e) {
1523
+ function Ue(e) {
1772
1524
  if (typeof e == "string") return e;
1773
1525
  if (e == null) return "";
1774
1526
  try {
@@ -1777,7 +1529,7 @@ function _t(e) {
1777
1529
  return String(e);
1778
1530
  }
1779
1531
  }
1780
- function vt(t) {
1532
+ function We(t) {
1781
1533
  let n = String(t?.EventType || "");
1782
1534
  if (!W.has(n)) return null;
1783
1535
  let r = String(t.Metadata?.tool_name || t.Metadata?.name || t.Metadata?.function_name || q(t.Content?.parts) || "tool").trim() || "tool", i = String(t.Metadata?.call_id || t.Metadata?.callId || t.Metadata?.RuntimeItem?.ToolCallId || "").trim(), a = {
@@ -1786,7 +1538,7 @@ function vt(t) {
1786
1538
  args: "",
1787
1539
  status: "running"
1788
1540
  }, o = n === "tool_result" || n === "stage_tool_result" ? (() => {
1789
- let n = _t(t.Metadata?.tool_output ?? t.Metadata?.output ?? t.Metadata?.result ?? q(t.Content?.parts));
1541
+ let n = Ue(t.Metadata?.tool_output ?? t.Metadata?.output ?? t.Metadata?.result ?? q(t.Content?.parts));
1790
1542
  return {
1791
1543
  ...a,
1792
1544
  output: n,
@@ -1794,8 +1546,8 @@ function vt(t) {
1794
1546
  };
1795
1547
  })() : {
1796
1548
  ...a,
1797
- args: _t(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1798
- }, s = mt(t);
1549
+ args: Ue(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1550
+ }, s = ze(t);
1799
1551
  return {
1800
1552
  id: s?.id || t.EventId || String(Date.now() + Math.random()),
1801
1553
  role: "model",
@@ -1806,7 +1558,7 @@ function vt(t) {
1806
1558
  tools: { [r]: o }
1807
1559
  };
1808
1560
  }
1809
- function yt(e = {}, t = {}) {
1561
+ function Ge(e = {}, t = {}) {
1810
1562
  let n = { ...e || {} };
1811
1563
  for (let [e, r] of Object.entries(t || {})) n[e] = {
1812
1564
  ...n[e] || {},
@@ -1816,8 +1568,8 @@ function yt(e = {}, t = {}) {
1816
1568
  };
1817
1569
  return n;
1818
1570
  }
1819
- function bt(e = {}, t = "") {
1820
- let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : it.has(n) ? "error" : "";
1571
+ function Ke(e = {}, t = "") {
1572
+ let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : ke.has(n) ? "error" : "";
1821
1573
  if (!r) return e;
1822
1574
  let i = !1, a = {};
1823
1575
  for (let [t, n] of Object.entries(e || {})) n?.status === "running" ? (i = !0, a[t] = {
@@ -1826,11 +1578,11 @@ function bt(e = {}, t = "") {
1826
1578
  }) : a[t] = n;
1827
1579
  return i ? a : e;
1828
1580
  }
1829
- function xt(e, t) {
1581
+ function qe(e, t) {
1830
1582
  return {
1831
1583
  ...e,
1832
- reasoning: St(e.reasoning, t.reasoning),
1833
- tools: yt(e.tools, t.tools),
1584
+ reasoning: Je(e.reasoning, t.reasoning),
1585
+ tools: Ge(e.tools, t.tools),
1834
1586
  eventId: t.eventId || e.eventId,
1835
1587
  responseId: t.responseId || e.responseId,
1836
1588
  traceId: t.traceId || e.traceId,
@@ -1839,11 +1591,11 @@ function xt(e, t) {
1839
1591
  id: t.responseId || t.reasoning || t.tools ? t.id : e.id
1840
1592
  };
1841
1593
  }
1842
- function St(e = "", t = "") {
1594
+ function Je(e = "", t = "") {
1843
1595
  let n = String(e || ""), r = String(t || "");
1844
1596
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1845
1597
  }
1846
- function Ct(e) {
1598
+ function Ye(e) {
1847
1599
  return {
1848
1600
  id: e.id,
1849
1601
  role: "system",
@@ -1854,11 +1606,11 @@ function Ct(e) {
1854
1606
  summary: e.summary,
1855
1607
  historical: e.historical,
1856
1608
  timestamp: e.timestamp,
1857
- content: ft(e.trigger, e.status, e.historical)
1609
+ content: Le(e.trigger, e.status, e.historical)
1858
1610
  };
1859
1611
  }
1860
- function wt(e) {
1861
- let t = e?.EventType || "", n = mt(e);
1612
+ function Xe(e) {
1613
+ let t = e?.EventType || "", n = ze(e);
1862
1614
  if (t === "run_status") return e.Content?.status === "failed" ? {
1863
1615
  id: e.EventId || String(Date.now() + Math.random()),
1864
1616
  role: "system",
@@ -1876,7 +1628,7 @@ function wt(e) {
1876
1628
  } : null;
1877
1629
  if (t === "context_checkpoint") {
1878
1630
  let t = Y(e);
1879
- return Ct({
1631
+ return Ye({
1880
1632
  id: e.EventId || String(Date.now() + Math.random()),
1881
1633
  timestamp: e.Timestamp || Date.now(),
1882
1634
  status: "completed",
@@ -1898,9 +1650,9 @@ function wt(e) {
1898
1650
  ...n || {}
1899
1651
  } : null;
1900
1652
  }
1901
- if (W.has(t)) return vt(e);
1653
+ if (W.has(t)) return We(e);
1902
1654
  if (t !== "user_message" && t !== "assistant_message" && t !== "assistant_stream_snapshot") return null;
1903
- let r = Y(e), i = t === "assistant_message" ? dt(e) : {};
1655
+ let r = Y(e), i = t === "assistant_message" ? Ie(e) : {};
1904
1656
  if (!r.text && !r.attachments?.length && !i.reasoning && !i.tools) return null;
1905
1657
  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();
1906
1658
  return {
@@ -1918,8 +1670,8 @@ function wt(e) {
1918
1670
  ...i
1919
1671
  };
1920
1672
  }
1921
- function Tt(e = []) {
1922
- 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 = st(e), c = [];
1673
+ function Ze(e = []) {
1674
+ 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 = Me(e), c = [];
1923
1675
  for (let e of s) {
1924
1676
  let t = String(e?.EventId || "").trim();
1925
1677
  if (t) {
@@ -1930,30 +1682,30 @@ function Tt(e = []) {
1930
1682
  }
1931
1683
  let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
1932
1684
  for (let e of c) {
1933
- if (e?.EventType !== "user_message" || ht(e)) {
1685
+ if (e?.EventType !== "user_message" || Be(e)) {
1934
1686
  if (e?.EventType === "assistant_message") {
1935
1687
  let t = X(e);
1936
1688
  t && u.add(t);
1937
1689
  }
1938
- if (gt(e)) {
1690
+ if (He(e)) {
1939
1691
  let t = X(e);
1940
1692
  if (t) {
1941
1693
  let n = d.get(t);
1942
- (!n || Q(e) >= Q(n)) && d.set(t, e);
1694
+ (!n || Z(e) >= Z(n)) && d.set(t, e);
1943
1695
  }
1944
1696
  }
1945
1697
  continue;
1946
1698
  }
1947
- let t = Z(e);
1699
+ let t = Ve(e);
1948
1700
  t && l.add(t);
1949
1701
  }
1950
1702
  let f = c.filter((e) => {
1951
- if (gt(e)) {
1703
+ if (He(e)) {
1952
1704
  let t = X(e);
1953
1705
  return t ? u.has(t) ? !1 : d.get(t) === e : !0;
1954
1706
  }
1955
- if (e?.EventType !== "user_message" || !ht(e)) return !0;
1956
- let t = Z(e);
1707
+ if (e?.EventType !== "user_message" || !Be(e)) return !0;
1708
+ let t = Ve(e);
1957
1709
  return !t || !l.has(t);
1958
1710
  });
1959
1711
  for (let e of f) {
@@ -1971,12 +1723,12 @@ function Tt(e = []) {
1971
1723
  let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = /* @__PURE__ */ new Map(), v = (e) => {
1972
1724
  let t = e?.itemId ? `${e.runId || e.invocationId || ""}\u0000${e.scopeId || e.invocationId || ""}\u0000${e.itemId}` : "", n = t ? h.get(t) : void 0;
1973
1725
  if (n !== void 0) {
1974
- p[n] = xt(p[n], e);
1726
+ p[n] = qe(p[n], e);
1975
1727
  return;
1976
1728
  }
1977
1729
  let r = String(e?.responseId || "").trim(), i = r ? m.get(r) : void 0;
1978
1730
  if (i !== void 0) {
1979
- p[i] = xt(p[i], e);
1731
+ p[i] = qe(p[i], e);
1980
1732
  return;
1981
1733
  }
1982
1734
  r && m.set(r, p.length), t && h.set(t, p.length), p.push(e);
@@ -1986,11 +1738,11 @@ function Tt(e = []) {
1986
1738
  let r = String(e || "").trim();
1987
1739
  if (!r) return {};
1988
1740
  let i = _.get(r);
1989
- return i ? (_.delete(r), { tools: bt(i.tools, t.get(r) || n) }) : {};
1741
+ return i ? (_.delete(r), { tools: Ke(i.tools, t.get(r) || n) }) : {};
1990
1742
  };
1991
1743
  for (let e of f) {
1992
1744
  if (e.EventType === "run_status") continue;
1993
- let t = wt(e);
1745
+ let t = Xe(e);
1994
1746
  if (!t) continue;
1995
1747
  let n = String(e.InvocationId || "").trim();
1996
1748
  if (n && (t.invocationId = n), W.has(t.eventType)) {
@@ -2013,7 +1765,7 @@ function Tt(e = []) {
2013
1765
  invocationId: n
2014
1766
  },
2015
1767
  timestamp: Math.max(Number(r?.timestamp || 0), Number(t.timestamp || 0)),
2016
- tools: yt(r?.tools, t.tools)
1768
+ tools: Ge(r?.tools, t.tools)
2017
1769
  });
2018
1770
  continue;
2019
1771
  }
@@ -2031,7 +1783,7 @@ function Tt(e = []) {
2031
1783
  }
2032
1784
  let r = t.eventType === "assistant_message" || t.eventType === "assistant_stream_snapshot";
2033
1785
  if (r && g) {
2034
- let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1786
+ let n = String(e.InvocationId || "").trim(), r = Re(n, t);
2035
1787
  if (t.eventType === "assistant_message" && n && a.has(r)) {
2036
1788
  g = null;
2037
1789
  continue;
@@ -2039,12 +1791,12 @@ function Tt(e = []) {
2039
1791
  t.eventType === "assistant_message" && n && a.add(r), v({
2040
1792
  ...t,
2041
1793
  ...b(n, t.eventType === "assistant_message" ? "completed" : ""),
2042
- reasoning: St(g.reasoning, t.reasoning)
1794
+ reasoning: Je(g.reasoning, t.reasoning)
2043
1795
  }), g = null;
2044
1796
  continue;
2045
1797
  }
2046
1798
  if (y(), r) {
2047
- let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1799
+ let n = String(e.InvocationId || "").trim(), r = Re(n, t);
2048
1800
  if (t.eventType === "assistant_message" && n && a.has(r)) continue;
2049
1801
  t.eventType === "assistant_message" && n && a.add(r), v({
2050
1802
  ...t,
@@ -2057,7 +1809,7 @@ function Tt(e = []) {
2057
1809
  y();
2058
1810
  for (let [e, n] of _.entries()) v({
2059
1811
  ...n,
2060
- tools: bt(n.tools, t.get(e))
1812
+ tools: Ke(n.tools, t.get(e))
2061
1813
  });
2062
1814
  for (let [e, a] of t.entries()) {
2063
1815
  if (a !== "in_progress" || r.has(e) || !i.has(e)) continue;
@@ -2073,7 +1825,7 @@ function Tt(e = []) {
2073
1825
  }
2074
1826
  return p;
2075
1827
  }
2076
- function Et(e = [], t = []) {
1828
+ function Qe(e = [], t = []) {
2077
1829
  let n = [], r = /* @__PURE__ */ new Set();
2078
1830
  for (let i of [...Array.isArray(e) ? e : [], ...Array.isArray(t) ? t : []]) {
2079
1831
  let e = String(i?.EventId || "").trim();
@@ -2088,21 +1840,21 @@ function Et(e = [], t = []) {
2088
1840
  return Number.isFinite(n) && Number.isFinite(r) && n !== r ? n - r : Number(e?.Timestamp || 0) - Number(t?.Timestamp || 0);
2089
1841
  });
2090
1842
  }
2091
- function Dt(e = []) {
1843
+ function $e(e = []) {
2092
1844
  return (Array.isArray(e) ? e : []).reduce((e, t) => {
2093
1845
  let n = Number(t.SeqId || 0);
2094
1846
  return Number.isFinite(n) ? Math.max(e, n) : e;
2095
1847
  }, 0);
2096
1848
  }
2097
- function Ot(e) {
2098
- return it.has(ct(e));
1849
+ function et(e) {
1850
+ return ke.has(Ne(e));
2099
1851
  }
2100
1852
  //#endregion
2101
1853
  //#region src/utils/persisted-session-history.ts
2102
- function $(e) {
1854
+ function Q(e) {
2103
1855
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
2104
1856
  }
2105
- function kt(e) {
1857
+ function tt(e) {
2106
1858
  if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
2107
1859
  if (typeof e == "string" && e.trim()) {
2108
1860
  let t = Number(e.trim());
@@ -2111,17 +1863,17 @@ function kt(e) {
2111
1863
  let t = Date.parse(String(e || ""));
2112
1864
  return Number.isFinite(t) ? t : Date.now();
2113
1865
  }
2114
- function At(e) {
2115
- let t = $(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
1866
+ function nt(e) {
1867
+ let t = Q(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
2116
1868
  if (t && String(t.event_type || "")) return {
2117
1869
  ...t,
2118
1870
  family: "runtime",
2119
1871
  seq: Number(e.SeqId || t.seq || 0),
2120
1872
  timestamp: e.Timestamp || t.timestamp
2121
1873
  };
2122
- let n = $(e?.Content?.session_event || e?.Content?.sessionEvent);
1874
+ let n = Q(e?.Content?.session_event || e?.Content?.sessionEvent);
2123
1875
  if (!n || String(n.family || "") !== "runtime") return null;
2124
- let r = $(n.payload);
1876
+ let r = Q(n.payload);
2125
1877
  return !r || !String(r.event_type || n.event_type || "") ? null : {
2126
1878
  ...r,
2127
1879
  family: "runtime",
@@ -2131,22 +1883,22 @@ function At(e) {
2131
1883
  timestamp: e.Timestamp || n.timestamp || r.timestamp
2132
1884
  };
2133
1885
  }
2134
- function jt(e) {
1886
+ function $(e) {
2135
1887
  return e.role === "model" ? {
2136
1888
  ...e,
2137
- blocks: e.blocks?.length ? e.blocks : Be({
1889
+ blocks: e.blocks?.length ? e.blocks : pe({
2138
1890
  content: e.content,
2139
1891
  reasoning: e.reasoning,
2140
1892
  tools: e.tools
2141
1893
  })
2142
1894
  } : e;
2143
1895
  }
2144
- function Mt(e, t) {
1896
+ function rt(e, t) {
2145
1897
  let n = t.find((e) => e.role === "user"), r = e.some((e) => e.role === "user"), i = t.filter((e) => e.role === "model"), a = e.filter((e) => e.role === "model").at(-1), o = i.at(-1), s = e.map((e) => e.role === "user" && n ? {
2146
1898
  ...e,
2147
1899
  ...n,
2148
1900
  invocationId: e.invocationId || n.invocationId
2149
- } : jt(e === a && o ? {
1901
+ } : $(e === a && o ? {
2150
1902
  ...e,
2151
1903
  responseId: o.responseId || e.responseId,
2152
1904
  traceId: o.traceId || e.traceId,
@@ -2154,12 +1906,12 @@ function Mt(e, t) {
2154
1906
  } : e));
2155
1907
  return n && !r ? [n, ...s] : s;
2156
1908
  }
2157
- function Nt(e, t) {
1909
+ function it(e, t) {
2158
1910
  let n = t.filter((e) => e.role === "model"), r = n.reduce((e, t) => ({
2159
1911
  ...e,
2160
1912
  ...t.tools || {}
2161
1913
  }), {}), i = n.map((e) => String(e.reasoning || "").trim()).filter(Boolean).join("\n\n"), a = [...e].reverse().find((e) => e.role === "model");
2162
- return !a || Object.keys(r).length === 0 && !i ? e : e.map((e) => e === a ? jt({
1914
+ return !a || Object.keys(r).length === 0 && !i ? e : e.map((e) => e === a ? $({
2163
1915
  ...e,
2164
1916
  reasoning: e.reasoning || i || void 0,
2165
1917
  tools: Object.keys(r).length > 0 ? {
@@ -2168,21 +1920,21 @@ function Nt(e, t) {
2168
1920
  } : e.tools
2169
1921
  }) : e);
2170
1922
  }
2171
- function Pt(e) {
1923
+ function at(e) {
2172
1924
  return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
2173
1925
  }
2174
- var Ft = new Set([
1926
+ var ot = new Set([
2175
1927
  "approval.resolved",
2176
1928
  "interaction.resolved",
2177
1929
  "interaction.cancelled",
2178
1930
  "interaction.canceled",
2179
1931
  "a2ui.action"
2180
1932
  ]);
2181
- function It(e) {
1933
+ function st(e) {
2182
1934
  let t = /* @__PURE__ */ new Set();
2183
1935
  for (let n of e) {
2184
- let e = $(n.Content) || {}, r = $(e.runtime_event || e.runtimeEvent) || {}, i = $(e.payload) || $(r.payload) || {}, a = String(n.EventType || e.event_type || e.eventType || r.event_type || "").toLowerCase();
2185
- if (!Ft.has(a)) continue;
1936
+ let e = Q(n.Content) || {}, r = Q(e.runtime_event || e.runtimeEvent) || {}, i = Q(e.payload) || Q(r.payload) || {}, a = String(n.EventType || e.event_type || e.eventType || r.event_type || "").toLowerCase();
1937
+ if (!ot.has(a)) continue;
2186
1938
  let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
2187
1939
  if (![
2188
1940
  "cancel",
@@ -2194,37 +1946,46 @@ function It(e) {
2194
1946
  }
2195
1947
  return t;
2196
1948
  }
2197
- function Lt(e, t, n) {
2198
- let r = new Ke(n), i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = [...t || []].sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), c = Number(s[0]?.SeqId || 0) <= 1;
1949
+ function ct(e, t, n) {
1950
+ let r = new ve(n), i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = [...t || []].sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), c = Number(s[0]?.SeqId || 0) <= 1;
2199
1951
  for (let e of s) {
2200
- let t = At(e);
1952
+ let t = nt(e);
2201
1953
  if (!t) continue;
2202
1954
  let n = String(t.run_id || "").trim();
2203
1955
  if (n) {
2204
1956
  a.add(n);
2205
- let e = $($(t.source)?.metadata), r = String(t.event_type || "") === "run.started", i = e?.native_item_kind === "userMessage";
1957
+ let e = Q(Q(t.source)?.metadata), r = String(t.event_type || "") === "run.started", i = e?.native_item_kind === "userMessage";
2206
1958
  (c || r || i) && o.add(n);
2207
1959
  }
2208
1960
  let s = r.translate(t);
2209
1961
  s && i.push({
2210
1962
  ...s,
2211
1963
  SeqId: Number(e.SeqId || s.SeqId || 0),
2212
- Timestamp: kt(e.Timestamp || s.Timestamp)
1964
+ Timestamp: tt(e.Timestamp || s.Timestamp)
2213
1965
  });
2214
1966
  }
2215
- let l = Tt(i).filter((e) => e.invocationId && a.has(e.invocationId)), u = /* @__PURE__ */ new Map();
1967
+ let l = Ze(i).filter((e) => e.invocationId && a.has(e.invocationId)), u = /* @__PURE__ */ new Map();
2216
1968
  for (let t of e) {
2217
1969
  let e = String(t.invocationId || "");
2218
1970
  e && u.set(e, [...u.get(e) || [], t]);
2219
1971
  }
2220
- let d = new Set([...Pt(l)].filter((e) => o.has(e))), f = It(s), p = [...d].flatMap((e) => Mt(l.filter((t) => t.invocationId === e), u.get(e) || [])), m = /* @__PURE__ */ new Map();
2221
- for (let [e, t] of u) d.has(e) || !a.has(e) || m.set(e, Nt(t, l.filter((t) => t.invocationId === e)));
2222
- let h = new Map([...m.values()].flat().map((e) => [e.id, e]));
1972
+ let d = new Set([...at(l)].filter((e) => o.has(e))), f = st(s), p = [...d].flatMap((e) => rt(l.filter((t) => t.invocationId === e), u.get(e) || [])), m = /* @__PURE__ */ new Map(), h = [];
1973
+ for (let [e, t] of u) {
1974
+ if (d.has(e) || !a.has(e)) continue;
1975
+ let n = l.filter((t) => t.invocationId === e);
1976
+ m.set(e, it(t, n)), t.some((e) => e.role === "model" && String(e.content || "").trim()) || h.push(...n.map($));
1977
+ }
1978
+ for (let e of a) d.has(e) || u.has(e) || h.push(...l.filter((t) => t.invocationId === e).map($));
1979
+ let g = new Map([...m.values()].flat().map((e) => [e.id, e]));
2223
1980
  return {
2224
- messages: [...e.filter((e) => !(e.role === "model" && e.invocationId && f.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !d.has(e.invocationId))).map((e) => h.get(e.id) || e), ...p].sort((e, t) => Number(e.timestamp || 0) - Number(t.timestamp || 0)),
1981
+ messages: [
1982
+ ...e.filter((e) => !(e.role === "model" && e.invocationId && f.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !d.has(e.invocationId))).map((e) => g.get(e.id) || e),
1983
+ ...p,
1984
+ ...h
1985
+ ].sort((e, t) => Number(e.timestamp || 0) - Number(t.timestamp || 0)),
2225
1986
  canonicalRunIds: [...d],
2226
1987
  translatedEvents: i
2227
1988
  };
2228
1989
  }
2229
1990
  //#endregion
2230
- export { ce as A, Se as C, se as D, ee as E, oe as O, ye as S, te as T, ze as _, Ot as a, Me as b, ct as c, Ke as d, qe as f, Ie as g, Be as h, Tt as i, t as j, re as k, Xe as l, Pe as m, Lt as n, Dt as o, Fe as p, Ct as r, Et as s, At as t, rt as u, Le as v, ve as w, Ce as x, Re as y };
1991
+ export { fe as _, et as a, ae as b, Ne as c, ve as d, ye as f, le as g, pe as h, Ze as i, R as l, se as m, ct as n, $e as o, ce as p, Ye as r, Qe as s, nt as t, Oe as u, ue as v, v as x, de as y };