@kingsoftcloud/ksadk-web 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +31 -0
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-10GPXIJ6.js → ArtifactsPanel-9RUQms_7.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-BXk1l-G1.js → CodeBlock-iq6mFygx.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-D9uB55Oh.js → MathMessageMarkdown-DSd_MMwp.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock--OEYoXIJ.js → MermaidBlock-B1tXyzN9.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-DrEe1syq.js → NativeTerminalPanel-BTTm24gh.js} +1 -1
  9. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-eeTFJLvo.js → abnfDiagram-VCTEODGH-CrPuGQ-J.js} +1 -1
  10. package/dist-ksadk/assets/{arc-S3ZNbIAd.js → arc-LSpozW7f.js} +1 -1
  11. package/dist-ksadk/assets/architecture-7GRP2DOG-DlLqIl7c.js +1 -0
  12. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-CRjgEJDX.js → architectureDiagram-5GKGNRK7-BiBddfc6.js} +1 -1
  13. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-C7bsBoNH.js → blockDiagram-NRAW4CY4-Cfpt59CA.js} +1 -1
  14. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BX3c33Ob.js → c4Diagram-UCG6FXSJ-TtkMYecK.js} +1 -1
  15. package/dist-ksadk/assets/channel-cg7jYcXF.js +1 -0
  16. package/dist-ksadk/assets/chunk-2Q5K7J3B-C4iMKTWb.js +1 -0
  17. package/dist-ksadk/assets/{chunk-5VM5RSS4-bZ7ws-8m.js → chunk-5VM5RSS4-QNTrS1KC.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-F27PBJKO-D2r0pvhY.js → chunk-F27PBJKO-CHsVsbjO.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-G27WJ6UU-CZwF3oUP.js → chunk-G27WJ6UU-BiyNaPce.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-JWPE2WC7-DigFYCML.js → chunk-JWPE2WC7-EjVrwIfj.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-LCL6LL3I-CnorGV5q.js → chunk-LCL6LL3I-BCXNTVwQ.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-POPQ4Y6H-CexntQA-.js → chunk-POPQ4Y6H-BNP6opFp.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-RHFEMEQ7-CHTC7UxA.js → chunk-RHFEMEQ7-CroPk1q-.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-SVP7TREG-BC1EWt_-.js → chunk-SVP7TREG-8eF2thNo.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-XXDRQBXY-BTG24xN0.js → chunk-XXDRQBXY-CfKEfSWB.js} +1 -1
  26. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-RtbaG_Dz.js +1 -0
  27. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-RtbaG_Dz.js +1 -0
  28. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-CkonRdAS.js → cose-bilkent-JH36ORCC-NYLLr4y3.js} +1 -1
  29. package/dist-ksadk/assets/cynefin-OW5HDTMX-BRs0UJ32.js +1 -0
  30. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-DEOCBe15.js → cynefinDiagram-5FMLGOSQ-1t2bjASn.js} +1 -1
  31. package/dist-ksadk/assets/{dagre-3AP2YEHR-DBThPuLa.js → dagre-3AP2YEHR-CyCcpGXQ.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-ClTPrTht.js → dagre-DIBkWWe5.js} +1 -1
  33. package/dist-ksadk/assets/{diagram-S7CK7UJ4-DsZHrnpJ.js → diagram-S7CK7UJ4-Qnyx09fY.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-UQ7AKVKN-BJR4nhVr.js → diagram-UQ7AKVKN-BBuBi2BK.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-VSXAHHWV-xzcERX0a.js → diagram-VSXAHHWV-Cu2pi7DX.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VX7I27RA-tn2xM1xu.js → diagram-VX7I27RA-D1hy0wPv.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-Z3DM3KII-BZPGBkw5.js → diagram-Z3DM3KII-DG_ukeOg.js} +1 -1
  38. package/dist-ksadk/assets/{dist-B1oWRmrH.js → dist-32Woo6w8.js} +1 -1
  39. package/dist-ksadk/assets/{dist-Btyo4vX4.js → dist-39frJg8c.js} +1 -1
  40. package/dist-ksadk/assets/{dist-DjhwGUgZ.js → dist-7mNpnBIq.js} +1 -1
  41. package/dist-ksadk/assets/{dist-C71CsujO.js → dist-BDYKkv8k.js} +1 -1
  42. package/dist-ksadk/assets/{dist-4zN1_tq5.js → dist-BRFE6wml.js} +1 -1
  43. package/dist-ksadk/assets/{dist-DdRBIceA.js → dist-Bami3Hbn.js} +1 -1
  44. package/dist-ksadk/assets/{dist-u8tVH5Ak.js → dist-BbqgJcRm.js} +1 -1
  45. package/dist-ksadk/assets/{dist-CXpH_Rdd.js → dist-Bo0uuYGj.js} +1 -1
  46. package/dist-ksadk/assets/{dist-BI1qQH4n.js → dist-BoDw8sHC.js} +1 -1
  47. package/dist-ksadk/assets/{dist-DJmCPRVB.js → dist-Bzd96FWg.js} +1 -1
  48. package/dist-ksadk/assets/{dist-BJLUwH6W.js → dist-C6YcRSBB.js} +1 -1
  49. package/dist-ksadk/assets/{dist-Cq4OL6nO.js → dist-C8E2u2Gy.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DyqV4fL4.js → dist-CgpyS7Tw.js} +1 -1
  51. package/dist-ksadk/assets/{dist-D1V3f1B4.js → dist-CsdC51-G.js} +1 -1
  52. package/dist-ksadk/assets/{dist-8VWI-2bZ.js → dist-D0t-jg0i.js} +1 -1
  53. package/dist-ksadk/assets/{dist-DQAB0qn_.js → dist-D2l4f5Dh.js} +1 -1
  54. package/dist-ksadk/assets/{dist-DfGFrb0v.js → dist-Dbb1c9iJ.js} +1 -1
  55. package/dist-ksadk/assets/{dist-B-46q3Hk.js → dist-_RQDZ9v3.js} +1 -1
  56. package/dist-ksadk/assets/{dist-Bbwqa8TG.js → dist-dLCAHoLT.js} +1 -1
  57. package/dist-ksadk/assets/{dist-B0gdk4rl.js → dist-mo17RERT.js} +1 -1
  58. package/dist-ksadk/assets/{dist-M67Hwu0n.js → dist-snMJ4dAH.js} +1 -1
  59. package/dist-ksadk/assets/{dist-DUwKa_l6.js → dist-vM3yu1Iv.js} +1 -1
  60. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-DVfMsLge.js → ebnfDiagram-PWID7BFC-DuBo2W05.js} +1 -1
  61. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CWEZSYaw.js → erDiagram-SSCWMZ5O-ZJrJetMD.js} +1 -1
  62. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DCJzsswd.js +1 -0
  63. package/dist-ksadk/assets/flowDiagram-A5DVABFB-485rByL2.js +1 -0
  64. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-TWIxoyYL.js → ganttDiagram-EL5Y4UJY-Bwk2yIEM.js} +1 -1
  65. package/dist-ksadk/assets/gitGraph-4MIJSDKK-C5VB4yJL.js +1 -0
  66. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DDh2hd2S.js → gitGraphDiagram-WWUBYQGX-DWYLIagz.js} +1 -1
  67. package/dist-ksadk/assets/index-Cp5NEP4y.css +2 -0
  68. package/dist-ksadk/assets/index-j3aFdsSv.js +244 -0
  69. package/dist-ksadk/assets/info-A6RAGUB7-tqDdMmNT.js +1 -0
  70. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-CgoyWiDR.js → infoDiagram-RXCK75RN-DMPen5_h.js} +1 -1
  71. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-CyRIu_om.js → ishikawaDiagram-5VMMS53U-DsPNKFIz.js} +1 -1
  72. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DN5JXHzN.js → journeyDiagram-EYS64GPL-BNbTP-8a.js} +1 -1
  73. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CNP3ui66.js → kanban-definition-3QL26DDD-BKR6Itkv.js} +1 -1
  74. package/dist-ksadk/assets/{katex-DWEzQy1d.js → katex-B0oLa8CR.js} +1 -1
  75. package/dist-ksadk/assets/{linear-C-qHp7d2.js → linear-B3_la4oE.js} +1 -1
  76. package/dist-ksadk/assets/{mermaid-parser.core-Cl-K943T.js → mermaid-parser.core-B6PQSAV-.js} +2 -2
  77. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-D5DB5mYm.js → mindmap-definition-FBJOCRG2-By8qFxGO.js} +1 -1
  78. package/dist-ksadk/assets/packet-AYTQ26CC-BxA-7Hkq.js +1 -0
  79. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-BQVc9ia_.js → pegDiagram-XKGWAZYB-K1kvFBKC.js} +1 -1
  80. package/dist-ksadk/assets/pie-WAS4IAKB-3Tmx9EyU.js +1 -0
  81. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-B6UCAvtY.js → pieDiagram-E7YTZNPT-5XFtDn56.js} +1 -1
  82. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-mIr2d3eb.js → quadrantDiagram-AXDQQJYC-DQwy74C1.js} +1 -1
  83. package/dist-ksadk/assets/radar-RG4KPBEZ-D_bZK5Bu.js +1 -0
  84. package/dist-ksadk/assets/railroad-74A4TZTK-COy6RdCd.js +1 -0
  85. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CrdA8h6r.js +1 -0
  86. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BnDti7-r.js +1 -0
  87. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DmYdbc7f.js +1 -0
  88. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-Dt3FFDmK.js → railroadDiagram-O6MQD6OU-cozhldnA.js} +1 -1
  89. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-Cz_vQtgF.js → requirementDiagram-EFPCY7ZU-CElPZjXR.js} +1 -1
  90. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-wlO1TsH5.js → sankeyDiagram-P5KCCOFB-y_USXv4y.js} +1 -1
  91. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-CHRbElYq.js → sequenceDiagram-WJ2MYXX4-BJbQk7Za.js} +1 -1
  92. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DXX54iyO.js → sizeCapture-X5ZJPWSS-DAaf435S.js} +1 -1
  93. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-Dp_lw9II.js → stateDiagram-HBIQ2CUA-BiLbLu1I.js} +1 -1
  94. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5rxHhPTD.js +1 -0
  95. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-D8O5UlLG.js → swimlanes-XN3QIQJK-DxhmU8aj.js} +1 -1
  96. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-B3Po2rui.js +8 -0
  97. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-8mfKcxvG.js → timeline-definition-24CTP7MA-D18EWv7u.js} +1 -1
  98. package/dist-ksadk/assets/treeView-Q6P3EWNA-6G5wA0pE.js +1 -0
  99. package/dist-ksadk/assets/treemap-WGGIJYW6-BE9GnPbg.js +1 -0
  100. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-EnNl0DE7.js → vennDiagram-4TSXK5OY-rUBCuIGM.js} +1 -1
  101. package/dist-ksadk/assets/wardley-WFR3VGLG-BYh81kWC.js +1 -0
  102. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DBu5fbYr.js → wardleyDiagram-VM6X3IG4-CDZQ5sZK.js} +1 -1
  103. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-BSVXs4IY.js → xychartDiagram-S5SC5T6Z-CH_HdHYk.js} +1 -1
  104. package/dist-ksadk/index.html +2 -2
  105. package/dist-lib/App.d.ts.map +1 -1
  106. package/dist-lib/{ArtifactsPanel-D36BykpN.js → ArtifactsPanel-BX-TQaOJ.js} +18 -17
  107. package/dist-lib/AttachmentPreview-D8BjnDTd.js +694 -0
  108. package/dist-lib/{CodeBlock-BlEkUJ8C.js → CodeBlock-D3-ZCOb_.js} +44 -41
  109. package/dist-lib/ConnectedComposer-BgTxuTfq.js +743 -0
  110. package/dist-lib/ConnectedMessageList-BwRiSswQ.js +1504 -0
  111. package/dist-lib/{MathMessageMarkdown-CcnPvEgd.js → MathMessageMarkdown-DwgeFqKs.js} +32 -31
  112. package/dist-lib/MenuChip-BXivncgX.js +43 -0
  113. package/dist-lib/{MermaidBlock-BFNE1NN8.js → MermaidBlock-DBFTztfQ.js} +15 -13
  114. package/dist-lib/{NativeTerminalPanel-Dix1UX_z.js → NativeTerminalPanel-DyPvD5ij.js} +166 -172
  115. package/dist-lib/WorkspacePanelContainer-C-na8Ns1.js +1617 -0
  116. package/dist-lib/a2ui-TSXmGrT-.js +486 -0
  117. package/dist-lib/api/client.d.ts +48 -14
  118. package/dist-lib/api/client.d.ts.map +1 -1
  119. package/dist-lib/{capabilities-njdklP3r.js → capabilities-CXle1R-K.js} +60 -30
  120. package/dist-lib/capabilities.js +1 -1
  121. package/dist-lib/chat-composer.js +4 -0
  122. package/dist-lib/chat-timeline.js +3 -0
  123. package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
  124. package/dist-lib/components/chat/ChatComposer.d.ts +4 -3
  125. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  126. package/dist-lib/components/chat/ChatMessageList.d.ts +7 -4
  127. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  128. package/dist-lib/components/chat/ConnectedComposer.d.ts +4 -3
  129. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  130. package/dist-lib/components/chat/ConnectedMessageList.d.ts +6 -3
  131. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  132. package/dist-lib/components/chat/ContextUsageIndicator.d.ts +4 -8
  133. package/dist-lib/components/chat/ContextUsageIndicator.d.ts.map +1 -1
  134. package/dist-lib/components/chat/ExecutionModeMenu.d.ts.map +1 -1
  135. package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts +1 -1
  136. package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts.map +1 -1
  137. package/dist-lib/components/chat/InteractionSchemaForm.d.ts.map +1 -1
  138. package/dist-lib/components/chat/InteractionTray.d.ts +4 -4
  139. package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -1
  140. package/dist-lib/components/chat/MenuChip.d.ts +19 -0
  141. package/dist-lib/components/chat/MenuChip.d.ts.map +1 -0
  142. package/dist-lib/components/chat/ModelSettingsMenu.d.ts.map +1 -1
  143. package/dist-lib/components/chat/PermissionMenu.d.ts.map +1 -1
  144. package/dist-lib/components/chat/ProcessingBlocksView.d.ts +3 -3
  145. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
  146. package/dist-lib/components/chat/schema-fields.d.ts +4 -1
  147. package/dist-lib/components/chat/schema-fields.d.ts.map +1 -1
  148. package/dist-lib/components/chat/types.d.ts +4 -1
  149. package/dist-lib/components/chat/types.d.ts.map +1 -1
  150. package/dist-lib/components.js +38 -30
  151. package/dist-lib/conversation.js +1 -1
  152. package/dist-lib/core/api/facade.d.ts +70 -13
  153. package/dist-lib/core/api/facade.d.ts.map +1 -1
  154. package/dist-lib/core/api/types.d.ts +4 -1
  155. package/dist-lib/core/api/types.d.ts.map +1 -1
  156. package/dist-lib/core/conversation/hosted.d.ts.map +1 -1
  157. package/dist-lib/core/conversation/index.d.ts +1 -1
  158. package/dist-lib/core/conversation/index.d.ts.map +1 -1
  159. package/dist-lib/core/interaction/adapters/normalize.d.ts +2 -2
  160. package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -1
  161. package/dist-lib/core/interaction/adapters/responses.d.ts.map +1 -1
  162. package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -1
  163. package/dist-lib/core/interaction/client.d.ts.map +1 -1
  164. package/dist-lib/core/interaction/index.d.ts +8 -0
  165. package/dist-lib/core/interaction/index.d.ts.map +1 -1
  166. package/dist-lib/core/interaction/store.d.ts +0 -0
  167. package/dist-lib/core/interaction/store.d.ts.map +1 -1
  168. package/dist-lib/core/run/a2ui.d.ts +2 -0
  169. package/dist-lib/core/run/a2ui.d.ts.map +1 -1
  170. package/dist-lib/core/run/blocks.d.ts +1 -0
  171. package/dist-lib/core/run/blocks.d.ts.map +1 -1
  172. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  173. package/dist-lib/core/run/engine.d.ts.map +1 -1
  174. package/dist-lib/core/run/types.d.ts +3 -1
  175. package/dist-lib/core/run/types.d.ts.map +1 -1
  176. package/dist-lib/core/stream/kernel-events.d.ts +3 -0
  177. package/dist-lib/core/stream/kernel-events.d.ts.map +1 -1
  178. package/dist-lib/core/stream/types.d.ts +7 -0
  179. package/dist-lib/core/stream/types.d.ts.map +1 -1
  180. package/dist-lib/feedback-D256P415.js +239 -0
  181. package/dist-lib/hooks/useAgentChat.d.ts +95 -0
  182. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -0
  183. package/dist-lib/hooks/useBootstrap.d.ts +3 -2
  184. package/dist-lib/hooks/useBootstrap.d.ts.map +1 -1
  185. package/dist-lib/hooks/useRunAgent.d.ts +7 -0
  186. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  187. package/dist-lib/hooks/useSessionLifecycle.d.ts +2 -0
  188. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  189. package/dist-lib/hooks.js +167 -0
  190. package/dist-lib/permission-BWkTcIzC.js +24 -0
  191. package/dist-lib/{persisted-session-history-C0N8TrMb.js → persisted-session-history-Bb3ScKrL.js} +463 -266
  192. package/dist-lib/public/chat-composer.d.ts +15 -0
  193. package/dist-lib/public/chat-composer.d.ts.map +1 -0
  194. package/dist-lib/public/chat-timeline.d.ts +12 -0
  195. package/dist-lib/public/chat-timeline.d.ts.map +1 -0
  196. package/dist-lib/public/components.d.ts +23 -0
  197. package/dist-lib/public/components.d.ts.map +1 -1
  198. package/dist-lib/public/hooks.d.ts +3 -0
  199. package/dist-lib/public/hooks.d.ts.map +1 -0
  200. package/dist-lib/public/runtime.d.ts +2 -0
  201. package/dist-lib/public/runtime.d.ts.map +1 -1
  202. package/dist-lib/public/styles.d.ts +1 -1
  203. package/dist-lib/rolldown-runtime-Dy4uBu1J.js +11 -0
  204. package/dist-lib/{tool-display-C4tPXce0.js → runtime-items-q6tMjfGU.js} +0 -0
  205. package/dist-lib/runtime.js +277 -4987
  206. package/dist-lib/sandbox-BTRIKAO6.js +92 -0
  207. package/dist-lib/stores/model.d.ts +1 -0
  208. package/dist-lib/stores/model.d.ts.map +1 -1
  209. package/dist-lib/styles.css +1 -1
  210. package/dist-lib/tool-display-DTiRdghE.js +64 -0
  211. package/dist-lib/types/capabilities.d.ts +1 -0
  212. package/dist-lib/types/capabilities.d.ts.map +1 -1
  213. package/dist-lib/useSessionLifecycle-DuzkfGgL.js +4233 -0
  214. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  215. package/dist-lib/utils/chat-message-grouping.d.ts +4 -0
  216. package/dist-lib/utils/chat-message-grouping.d.ts.map +1 -0
  217. package/dist-lib/utils/chat-scroll.d.ts +14 -0
  218. package/dist-lib/utils/chat-scroll.d.ts.map +1 -0
  219. package/dist-lib/utils/context.d.ts +12 -7
  220. package/dist-lib/utils/context.d.ts.map +1 -1
  221. package/dist-lib/utils/messages.d.ts.map +1 -1
  222. package/dist-lib/utils/persisted-session-history.d.ts +2 -0
  223. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  224. package/dist-lib/utils/responses-stream.d.ts +2 -0
  225. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  226. package/dist-lib/utils/session-events.d.ts.map +1 -1
  227. package/dist-lib/utils/session.d.ts +1 -0
  228. package/dist-lib/utils/session.d.ts.map +1 -1
  229. package/dist-lib/utils/workspace.d.ts +1 -1
  230. package/package.json +13 -1
  231. package/dist-ksadk/assets/architecture-7GRP2DOG-Dk9nRQ6-.js +0 -1
  232. package/dist-ksadk/assets/channel-s354Yo6o.js +0 -1
  233. package/dist-ksadk/assets/chunk-2Q5K7J3B-CDpPpKR5.js +0 -1
  234. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-Dd0nucl9.js +0 -1
  235. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-Dd0nucl9.js +0 -1
  236. package/dist-ksadk/assets/cynefin-OW5HDTMX-BBlT4uMf.js +0 -1
  237. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-Dr5okd8V.js +0 -1
  238. package/dist-ksadk/assets/flowDiagram-A5DVABFB-VEO-cVcO.js +0 -1
  239. package/dist-ksadk/assets/gitGraph-4MIJSDKK-CKiKY9Cf.js +0 -1
  240. package/dist-ksadk/assets/index-B2k_urY8.js +0 -241
  241. package/dist-ksadk/assets/index-ILPt6IWF.css +0 -2
  242. package/dist-ksadk/assets/info-A6RAGUB7-ubA4Nm_p.js +0 -1
  243. package/dist-ksadk/assets/packet-AYTQ26CC-C7R3NUlK.js +0 -1
  244. package/dist-ksadk/assets/pie-WAS4IAKB-BIT6qjr3.js +0 -1
  245. package/dist-ksadk/assets/radar-RG4KPBEZ-l5noef9X.js +0 -1
  246. package/dist-ksadk/assets/railroad-74A4TZTK-Baea6ZvM.js +0 -1
  247. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-OKn8zZnU.js +0 -1
  248. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-DdKAKC4l.js +0 -1
  249. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-Bds8udlG.js +0 -1
  250. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5b-8o2iS.js +0 -1
  251. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-uf6WPRA4.js +0 -8
  252. package/dist-ksadk/assets/treeView-Q6P3EWNA-CK5CSrSO.js +0 -1
  253. package/dist-ksadk/assets/treemap-WGGIJYW6-Ch2BKgAM.js +0 -1
  254. package/dist-ksadk/assets/wardley-WFR3VGLG-YW3Q0ml_.js +0 -1
  255. package/dist-lib/WorkspacePanelContainer-Cr1BwR1P.js +0 -4397
  256. package/dist-lib/api/bootstrap.d.ts +0 -2
  257. package/dist-lib/api/bootstrap.d.ts.map +0 -1
  258. package/dist-lib/api/checkpoints.d.ts +0 -38
  259. package/dist-lib/api/checkpoints.d.ts.map +0 -1
  260. package/dist-lib/api/events.d.ts +0 -20
  261. package/dist-lib/api/events.d.ts.map +0 -1
  262. package/dist-lib/api/messages.d.ts +0 -73
  263. package/dist-lib/api/messages.d.ts.map +0 -1
  264. package/dist-lib/api/model.d.ts +0 -2
  265. package/dist-lib/api/model.d.ts.map +0 -1
  266. package/dist-lib/api/run.d.ts +0 -36
  267. package/dist-lib/api/run.d.ts.map +0 -1
  268. package/dist-lib/api/session.d.ts +0 -61
  269. package/dist-lib/api/session.d.ts.map +0 -1
  270. package/dist-lib/api/upload.d.ts +0 -12
  271. package/dist-lib/api/upload.d.ts.map +0 -1
  272. package/dist-lib/api/workspace.d.ts +0 -8
  273. package/dist-lib/api/workspace.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as e } from "./tool-display-C4tPXce0.js";
1
+ import { n as e } from "./tool-display-DTiRdghE.js";
2
2
  //#region src/core/conversation/errors.ts
3
3
  var t = class extends Error {
4
4
  code;
@@ -351,10 +351,10 @@ function ye() {
351
351
  appliedSources: []
352
352
  };
353
353
  }
354
- function w(e) {
354
+ function be(e) {
355
355
  return e.lifecycle === "completed" || e.lifecycle === "failed";
356
356
  }
357
- function be(e, t) {
357
+ function xe(e, t) {
358
358
  let n = {
359
359
  ...e,
360
360
  ...t
@@ -363,12 +363,12 @@ function be(e, t) {
363
363
  for (let r of ["data", "operations"]) Array.isArray(e[r]) && Array.isArray(t[r]) && (n[r] = [...e[r], ...t[r]]);
364
364
  return n;
365
365
  }
366
- function T(e, t) {
366
+ function Se(e, t) {
367
367
  let n = t.sourceEventIds.map((e) => JSON.stringify([t.itemId, e])), r = new Set(e.appliedSources);
368
368
  if (n.every((e) => r.has(e))) return e;
369
369
  n.forEach((e) => r.add(e));
370
370
  let i = e.items.findIndex((e) => e.itemId === t.itemId), a = i >= 0 ? e.items[i] : void 0;
371
- if (a && w(a) && !w(t)) return {
371
+ if (a && be(a) && !be(t)) return {
372
372
  ...e,
373
373
  appliedSources: [...r]
374
374
  };
@@ -378,7 +378,7 @@ function T(e, t) {
378
378
  let e = [...new Set([...a.sourceEventIds, ...t.sourceEventIds])];
379
379
  a.kind === t.kind ? t.operation === "append" ? o[i] = {
380
380
  ...t,
381
- payload: be(a.payload, t.payload),
381
+ payload: xe(a.payload, t.payload),
382
382
  sourceEventIds: e
383
383
  } : o[i] = {
384
384
  ...t,
@@ -397,10 +397,10 @@ function T(e, t) {
397
397
  appliedSources: [...r]
398
398
  };
399
399
  }
400
- var xe = class {
400
+ var Ce = class {
401
401
  state = ye();
402
402
  apply(e) {
403
- let t = T(this.state, e);
403
+ let t = Se(this.state, e);
404
404
  if (t === this.state) return !1;
405
405
  let n = t.items !== this.state.items;
406
406
  return this.state = t, n;
@@ -419,17 +419,17 @@ var xe = class {
419
419
  appliedSources: [...this.state.appliedSources]
420
420
  };
421
421
  }
422
- }, E = 8;
423
- function Se(e) {
422
+ }, w = 8;
423
+ function T(e) {
424
424
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
425
425
  }
426
- function D(e) {
426
+ function E(e) {
427
427
  if (e?.aborted) throw new t("conversation_aborted", "Conversation request was aborted.");
428
428
  }
429
- function Ce(e, t) {
429
+ function we(e, t) {
430
430
  return t?.aborted === !0 || e instanceof Error && e.name === "AbortError";
431
431
  }
432
- function we(e) {
432
+ function Te(e) {
433
433
  let n = e.trim().replace(/\/+$/, "");
434
434
  if (!n) return "";
435
435
  if (!n.includes("://")) return n.startsWith("/") ? n : `/${n}`;
@@ -441,16 +441,16 @@ function we(e) {
441
441
  throw new t("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
442
442
  }
443
443
  }
444
- function Te(e) {
444
+ function Ee(e) {
445
445
  return Math.min(200 * 2 ** Math.max(0, e - 1), 2e3);
446
446
  }
447
- function Ee(e) {
447
+ function De(e) {
448
448
  return new Promise((t) => {
449
449
  setTimeout(t, e);
450
450
  });
451
451
  }
452
- async function De(e, n, r) {
453
- if (D(r), !r) {
452
+ async function Oe(e, n, r) {
453
+ if (E(r), !r) {
454
454
  await e(n);
455
455
  return;
456
456
  }
@@ -461,7 +461,7 @@ async function De(e, n, r) {
461
461
  });
462
462
  });
463
463
  }
464
- function O(e, t, n) {
464
+ function D(e, t, n) {
465
465
  let r = e.snapshot();
466
466
  return {
467
467
  cursor: t,
@@ -470,7 +470,7 @@ function O(e, t, n) {
470
470
  presentation: ve(r)
471
471
  };
472
472
  }
473
- function Oe(e, n) {
473
+ function ke(e, n) {
474
474
  let r, i = [];
475
475
  for (let n of e.split(/\r?\n/)) {
476
476
  let e = n.endsWith("\r") ? n.slice(0, -1) : n;
@@ -490,7 +490,7 @@ function Oe(e, n) {
490
490
  } catch (e) {
491
491
  throw new t("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
492
492
  }
493
- let s = Se(o);
493
+ let s = T(o);
494
494
  if (!s || s.conversationItem === void 0) {
495
495
  r !== void 0 && (n.cursor = Math.max(n.cursor, r));
496
496
  return;
@@ -504,26 +504,26 @@ function Oe(e, n) {
504
504
  });
505
505
  n.runId = c.runId;
506
506
  let l = n.reducer.apply(c);
507
- n.cursor = Math.max(n.cursor, r), l && n.options.onItem?.(c), n.options.onUpdate?.(O(n.reducer, n.cursor, n.runId));
507
+ n.cursor = Math.max(n.cursor, r), l && n.options.onItem?.(c), n.options.onUpdate?.(D(n.reducer, n.cursor, n.runId));
508
508
  }
509
- async function ke(e, n) {
509
+ async function Ae(e, n) {
510
510
  if (!e.body) throw new t("conversation_stream_error", "Conversation response has no event stream body.");
511
511
  let r = e.body.getReader(), i = new TextDecoder(), a = "";
512
512
  try {
513
513
  for (;;) {
514
- D(n.options.signal);
514
+ E(n.options.signal);
515
515
  let { value: e, done: t } = await r.read();
516
516
  if (t) break;
517
517
  a += i.decode(e, { stream: !0 });
518
518
  let o = /\r?\n\r?\n/.exec(a);
519
519
  for (; o?.index !== void 0;) {
520
520
  let e = o.index, t = o[0].length;
521
- Oe(a.slice(0, e), n), a = a.slice(e + t), o = /\r?\n\r?\n/.exec(a);
521
+ ke(a.slice(0, e), n), a = a.slice(e + t), o = /\r?\n\r?\n/.exec(a);
522
522
  }
523
523
  }
524
- a += i.decode(), a.trim() && Oe(a, n);
524
+ a += i.decode(), a.trim() && ke(a, n);
525
525
  } catch (e) {
526
- throw e instanceof t ? e : (Ce(e, n.options.signal) && D(n.options.signal), new t("conversation_stream_error", "Conversation event stream was interrupted.", {
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.", {
527
527
  cause: e,
528
528
  runId: n.runId || void 0,
529
529
  cursor: n.cursor
@@ -532,18 +532,18 @@ async function ke(e, n) {
532
532
  r.releaseLock();
533
533
  }
534
534
  }
535
- function Ae(e) {
535
+ function je(e) {
536
536
  return e.state.items.some((e) => S(e) !== void 0);
537
537
  }
538
- var je = class {
538
+ var Me = class {
539
539
  fetcher;
540
540
  baseUrl;
541
541
  maxReconnects;
542
542
  sleep;
543
543
  retryDelayMs;
544
544
  constructor(e = {}) {
545
- if (!Number.isInteger(e.maxReconnects ?? E) || (e.maxReconnects ?? E) < 0 || (e.maxReconnects ?? E) > 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 = we(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? E, this.sleep = e.sleep || Ee, this.retryDelayMs = e.retryDelayMs || Te;
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;
547
547
  }
548
548
  fetch() {
549
549
  if (this.fetcher) return this.fetcher;
@@ -554,11 +554,11 @@ var je = class {
554
554
  return `${this.baseUrl}${e}`;
555
555
  }
556
556
  async request(e, n, r, i = "conversation_stream_error") {
557
- D(r);
557
+ E(r);
558
558
  try {
559
559
  return await this.fetch()(e, n);
560
560
  } catch (e) {
561
- throw e instanceof t ? e : (Ce(e, r) && D(r), new t(i, "Conversation network request failed.", { cause: e }));
561
+ throw e instanceof t ? e : (we(e, r) && E(r), new t(i, "Conversation network request failed.", { cause: e }));
562
562
  }
563
563
  }
564
564
  assertOk(e) {
@@ -574,7 +574,7 @@ var je = class {
574
574
  } catch (e) {
575
575
  throw new t("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
576
576
  }
577
- let s = Se(o), c = oe(s?.surface);
577
+ let s = T(o), c = oe(s?.surface);
578
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.");
579
579
  return {
580
580
  buildId: s.buildId,
@@ -582,11 +582,11 @@ var je = class {
582
582
  };
583
583
  }
584
584
  async streamTurn(e) {
585
- D(e.signal), re(e.bootstrap.surface, e.input);
585
+ E(e.signal), re(e.bootstrap.surface, e.input);
586
586
  let n = {
587
587
  cursor: 0,
588
588
  runId: "",
589
- reducer: new xe(),
589
+ reducer: new Ce(),
590
590
  options: e
591
591
  }, r = {
592
592
  method: "POST",
@@ -599,69 +599,69 @@ var je = class {
599
599
  }, i = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), r, e.signal);
600
600
  this.assertOk(i);
601
601
  try {
602
- await ke(i, n);
602
+ await Ae(i, n);
603
603
  } catch (e) {
604
604
  if (!(e instanceof t) || e.code !== "conversation_stream_error" || !n.runId) throw e;
605
605
  }
606
- let a = O(n.reducer, n.cursor, n.runId);
607
- if (Ae(a)) return a;
606
+ let a = D(n.reducer, n.cursor, n.runId);
607
+ if (je(a)) return a;
608
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
609
  for (let r = 1; r <= this.maxReconnects; r += 1) {
610
- await De(this.sleep, this.retryDelayMs(r), e.signal), D(e.signal);
610
+ await Oe(this.sleep, this.retryDelayMs(r), e.signal), E(e.signal);
611
611
  let i;
612
612
  try {
613
613
  i = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(n.runId)}/events?after=${n.cursor}`), {
614
614
  method: "GET",
615
615
  headers: { "Last-Event-ID": String(n.cursor) },
616
616
  ...e.signal ? { signal: e.signal } : {}
617
- }, e.signal), this.assertOk(i), await ke(i, n);
617
+ }, e.signal), this.assertOk(i), await Ae(i, n);
618
618
  } catch (e) {
619
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;
620
620
  continue;
621
621
  }
622
- if (a = O(n.reducer, n.cursor, n.runId), Ae(a)) return a;
622
+ if (a = D(n.reducer, n.cursor, n.runId), je(a)) return a;
623
623
  }
624
624
  throw new t("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
625
625
  runId: n.runId,
626
626
  cursor: n.cursor
627
627
  });
628
628
  }
629
- }, Me = 0;
630
- function k(e) {
631
- return Me += 1, `${e}-${Me}`;
629
+ }, Ne = 0;
630
+ function O(e) {
631
+ return Ne += 1, `${e}-${Ne}`;
632
632
  }
633
- function A(e) {
633
+ function k(e) {
634
634
  return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
635
635
  ...e,
636
636
  status: "done"
637
637
  } : e);
638
638
  }
639
- function Ne(e, t) {
639
+ function Pe(e, t) {
640
640
  let n = [...e ?? []], r = n[n.length - 1];
641
641
  return r?.type === "thinking" && r.status === "streaming" ? (n[n.length - 1] = {
642
642
  ...r,
643
643
  content: r.content + t
644
644
  }, n) : [...n, {
645
- id: k("thinking"),
645
+ id: O("thinking"),
646
646
  type: "thinking",
647
647
  content: t,
648
648
  status: "streaming"
649
649
  }];
650
650
  }
651
- function Pe(e, t) {
652
- let n = [...A(e ?? [])], r = n[n.length - 1];
651
+ function Fe(e, t) {
652
+ let n = [...k(e ?? [])], r = n[n.length - 1];
653
653
  return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
654
654
  ...r,
655
655
  content: r.content + t
656
656
  }, n) : [...n, {
657
- id: k("text"),
657
+ id: O("text"),
658
658
  type: "text",
659
659
  content: t,
660
660
  status: "streaming"
661
661
  }];
662
662
  }
663
- function Fe(e, t) {
664
- let n = A(e ?? []);
663
+ function Ie(e, t) {
664
+ let n = k(e ?? []);
665
665
  if (n.filter((e) => e.type === "text").map((e) => e.content).join("") === t) return n.map((e) => e.type === "text" && e.status === "streaming" ? {
666
666
  ...e,
667
667
  status: "done"
@@ -672,13 +672,13 @@ function Fe(e, t) {
672
672
  content: t,
673
673
  status: "done"
674
674
  }, r) : [...r, {
675
- id: k("text"),
675
+ id: O("text"),
676
676
  type: "text",
677
677
  content: t,
678
678
  status: "done"
679
679
  }];
680
680
  }
681
- function Ie(e, t) {
681
+ function Le(e, t) {
682
682
  if (!t) return [...e ?? []];
683
683
  let n = [...e ?? []], r = n[n.length - 1];
684
684
  if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
@@ -688,8 +688,8 @@ function Ie(e, t) {
688
688
  content: i
689
689
  }, n) : (n.pop(), n);
690
690
  }
691
- function Le(e, t, n) {
692
- let r = [...A(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
691
+ function Re(e, t, n) {
692
+ let r = [...k(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
693
693
  if (i >= 0 && r[i].type === "tool") {
694
694
  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
695
  if (t && !a && !o) return r;
@@ -701,7 +701,7 @@ function Le(e, t, n) {
701
701
  }, r;
702
702
  }
703
703
  return [...r, {
704
- id: k("tool"),
704
+ id: O("tool"),
705
705
  type: "tool",
706
706
  toolName: t,
707
707
  args: n.args ?? "",
@@ -710,26 +710,27 @@ function Le(e, t, n) {
710
710
  extra: n.extra
711
711
  }];
712
712
  }
713
- function Re(e) {
714
- return A(e ?? []);
715
- }
716
713
  function ze(e) {
714
+ return k(e ?? []);
715
+ }
716
+ function Be(e) {
717
717
  let t = [];
718
718
  if (e.reasoning && e.reasoning.trim() && t.push({
719
- id: k("thinking"),
719
+ id: O("thinking"),
720
720
  type: "thinking",
721
721
  content: e.reasoning,
722
722
  status: "done"
723
723
  }), e.tools) for (let n of Object.values(e.tools)) t.push({
724
- id: k("tool"),
724
+ id: O("tool"),
725
725
  type: "tool",
726
726
  toolName: n.name,
727
727
  args: n.args ?? "",
728
728
  output: n.output,
729
- status: n.status ?? "completed"
729
+ status: n.status ?? "completed",
730
+ ...n.callId ? { extra: { callId: n.callId } } : {}
730
731
  });
731
732
  return e.content && e.content.trim() && t.push({
732
- id: k("text"),
733
+ id: O("text"),
733
734
  type: "text",
734
735
  content: e.content,
735
736
  status: "done"
@@ -737,40 +738,40 @@ function ze(e) {
737
738
  }
738
739
  //#endregion
739
740
  //#region src/core/stream/kernel-events.ts
740
- var Be = {
741
+ var Ve = {
741
742
  "run.started": "in_progress",
742
743
  "run.progress": "in_progress",
743
744
  "run.completed": "completed",
744
745
  "run.failed": "failed",
745
746
  "run.canceled": "cancelled",
746
747
  "run.interrupted": "interrupted"
747
- }, Ve = new Set([
748
+ }, He = new Set([
748
749
  "completed",
749
750
  "failed",
750
751
  "cancelled",
751
752
  "canceled"
752
753
  ]);
753
- function j(e) {
754
+ function A(e) {
754
755
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
755
756
  }
756
- function He(e) {
757
- let t = j(e.source), n = t ? j(t.metadata) : null;
757
+ function Ue(e) {
758
+ let t = A(e.source), n = t ? A(t.metadata) : null;
758
759
  return String(n?.native_item_kind || "");
759
760
  }
760
- function M(e, t) {
761
- let n = j(e[t]);
761
+ function j(e, t) {
762
+ let n = A(e[t]);
762
763
  if (!n) return [];
763
764
  let r = n?.parts;
764
765
  return Array.isArray(r) ? r : t === "update" ? [n] : [];
765
766
  }
766
- function Ue(e) {
767
- let t = j(e);
767
+ function We(e) {
768
+ let t = A(e);
768
769
  if (!t) return "";
769
770
  if (typeof t.text == "string") return t.text;
770
- let n = j(t.data);
771
+ let n = A(t.data);
771
772
  if (n) {
772
773
  let e = n.content;
773
- if (Array.isArray(e)) return e.map((e) => String(j(e)?.text || "")).join("");
774
+ if (Array.isArray(e)) return e.map((e) => String(A(e)?.text || "")).join("");
774
775
  for (let e of [
775
776
  "text",
776
777
  "output",
@@ -780,37 +781,76 @@ function Ue(e) {
780
781
  }
781
782
  return "";
782
783
  }
784
+ function M(e) {
785
+ return e.map(We).join("");
786
+ }
787
+ function Ge(e) {
788
+ return e.some((e) => A(A(e)?.data)?.type === "userMessage");
789
+ }
783
790
  function N(e) {
784
- return e.map(Ue).join("");
791
+ if (e.length === 1) {
792
+ let t = A(A(e[0])?.data);
793
+ if (t) return t;
794
+ }
795
+ return M(e) || null;
785
796
  }
786
797
  function P(e) {
787
- return e.some((e) => j(j(e)?.data)?.type === "userMessage");
798
+ let t = A(e);
799
+ return t ? A(t.data) || t : null;
788
800
  }
789
801
  function F(e) {
790
- if (e.length === 1) {
791
- let t = j(j(e[0])?.data);
792
- if (t) return t;
802
+ let t = P(e);
803
+ return String(t?.content_type || t?.type || "").trim().toLowerCase();
804
+ }
805
+ function I(e) {
806
+ for (let t of e) {
807
+ let e = P(t);
808
+ if (!e || F(t) !== "tool_call") continue;
809
+ let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
810
+ if (!(!n && !r)) return {
811
+ callId: n,
812
+ name: r,
813
+ arguments: e.arguments ?? e.args ?? {}
814
+ };
793
815
  }
794
- return N(e) || null;
816
+ return null;
795
817
  }
796
- function I(e, t, n) {
818
+ function L(e) {
819
+ for (let t of e) {
820
+ let e = P(t);
821
+ if (!e || F(t) !== "tool_result") continue;
822
+ let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
823
+ return {
824
+ callId: n,
825
+ result: e.result ?? e.output ?? e.error ?? null,
826
+ isError: r
827
+ };
828
+ }
829
+ return null;
830
+ }
831
+ function R(e, t, n, r) {
832
+ let i = String(e.item_id || ""), a = String(r || i);
797
833
  return { RuntimeItem: {
798
834
  RunId: String(e.run_id || ""),
799
835
  ScopeId: String(e.scope_id || e.run_id || ""),
800
- ItemId: String(e.item_id || ""),
836
+ ItemId: a,
801
837
  ...n ? { PartId: n } : {},
802
838
  Operation: t,
803
- SourceEventId: String(e.event_id || "")
839
+ SourceEventId: String(e.event_id || ""),
840
+ ...i && i !== a ? { SourceItemId: i } : {}
804
841
  } };
805
842
  }
806
- var L = class {
843
+ var Ke = class {
807
844
  textByPart = /* @__PURE__ */ new Map();
845
+ toolNameByCallId = /* @__PURE__ */ new Map();
846
+ toolCallByItemId = /* @__PURE__ */ new Map();
847
+ toolResultByItemId = /* @__PURE__ */ new Map();
808
848
  sessionId;
809
849
  constructor(e) {
810
850
  this.sessionId = e;
811
851
  }
812
852
  translate(e) {
813
- if (!j(e)) return null;
853
+ if (!A(e)) return null;
814
854
  let t = Number(e.seq);
815
855
  if (!Number.isFinite(t) || t <= 0) return null;
816
856
  let n = String(e.family || ""), r = String(e.event_type || ""), i = String(e.run_id || ""), a = () => ({
@@ -827,7 +867,7 @@ var L = class {
827
867
  if (n === "control") {
828
868
  if (r === "control.run_transition") {
829
869
  let t = String(e.state || "").toLowerCase();
830
- if (Ve.has(t)) return {
870
+ if (He.has(t)) return {
831
871
  ...a(),
832
872
  EventType: "run_status",
833
873
  Content: { status: t }
@@ -836,111 +876,204 @@ var L = class {
836
876
  return null;
837
877
  }
838
878
  if (n !== "runtime") return null;
839
- let o = Be[r];
879
+ let o = Ve[r];
840
880
  if (o) return {
841
881
  ...a(),
842
882
  EventType: "run_status",
843
883
  Content: { status: o }
844
884
  };
845
- let s = He(e);
885
+ let s = Ue(e);
846
886
  if (r === "item.started") {
847
- let t = M(e, "initial");
848
- return s === "userMessage" || P(t) || s === "reasoning" || e.item_kind === "reasoning" ? null : s === "agentMessage" || !s && e.item_kind === "message" ? {
887
+ let t = j(e, "initial");
888
+ if (e.item_kind === "tool_call") {
889
+ let n = I(t), r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
890
+ return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
891
+ callId: r,
892
+ name: o
893
+ }), {
894
+ ...a(),
895
+ EventType: "tool_call",
896
+ Metadata: {
897
+ ...R(e, "replace", void 0, r),
898
+ call_id: r,
899
+ tool_name: o,
900
+ run_id: i,
901
+ tool_args: n?.arguments ?? N(t)
902
+ }
903
+ };
904
+ }
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" ? {
849
906
  ...a(),
850
907
  EventType: "assistant_stream_snapshot",
851
908
  Content: { parts: [{ text: "" }] },
852
- Metadata: I(e, "replace")
909
+ Metadata: R(e, "replace")
853
910
  } : s && s !== "notification" ? {
854
911
  ...a(),
855
912
  EventType: "tool_call",
856
913
  Metadata: {
857
- ...I(e, "replace"),
914
+ ...R(e, "replace"),
858
915
  call_id: String(e.item_id || ""),
859
916
  tool_name: s,
860
917
  run_id: i,
861
- tool_args: F(t)
918
+ tool_args: N(t)
862
919
  }
863
920
  } : null;
864
921
  }
865
922
  if (r === "item.updated") {
866
- let n = M(e, "update"), r = j(n[0]), i = String(r?.part_id || e.item_id || t), o = String(e.op || "replace"), c = N(n), l = this.textByPart.get(i) || "", u = o === "append" ? l + c : c;
867
- return this.textByPart.set(i, u), s === "agentMessage" || !s && e.item_kind === "message" ? {
923
+ let n = j(e, "update");
924
+ if (e.item_kind === "tool_call") {
925
+ let t = L(n);
926
+ if (!t) return null;
927
+ 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
+ return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
929
+ ...a(),
930
+ EventType: "tool_result",
931
+ Metadata: {
932
+ ...R(e, "completed", void 0, o),
933
+ call_id: o,
934
+ tool_name: s,
935
+ run_id: i,
936
+ tool_output: c
937
+ }
938
+ };
939
+ }
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;
941
+ return this.textByPart.set(o, d), s === "agentMessage" || !s && e.item_kind === "message" ? {
868
942
  ...a(),
869
943
  EventType: "assistant_stream_snapshot",
870
- Content: { parts: [{ text: u }] },
871
- Metadata: I(e, "replace", i)
944
+ Content: { parts: [{ text: d }] },
945
+ Metadata: R(e, "replace", o)
872
946
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
873
947
  ...a(),
874
948
  EventType: "reasoning",
875
- Content: { parts: [{ text: c }] },
876
- Metadata: I(e, o === "append" ? "append" : "replace", i)
949
+ Content: { parts: [{ text: l }] },
950
+ Metadata: R(e, c === "append" ? "append" : "replace", o)
877
951
  } : null;
878
952
  }
879
953
  if (r === "item.snapshot_replaced") {
880
- let n = M(e, "snapshot"), r = String(j(n[0])?.part_id || e.item_id || t), i = N(n);
954
+ let n = j(e, "snapshot"), r = String(A(n[0])?.part_id || e.item_id || t), i = M(n);
881
955
  return this.textByPart.set(r, i), s === "agentMessage" || !s && e.item_kind === "message" ? {
882
956
  ...a(),
883
957
  EventType: "assistant_stream_snapshot",
884
958
  Content: { parts: [{ text: i }] },
885
- Metadata: I(e, "replace", r)
959
+ Metadata: R(e, "replace", r)
886
960
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
887
961
  ...a(),
888
962
  EventType: "reasoning",
889
963
  Content: { parts: [{ text: i }] },
890
- Metadata: I(e, "replace", r)
964
+ Metadata: R(e, "replace", r)
891
965
  } : null;
892
966
  }
893
967
  if (r === "item.completed") {
894
- let n = M(e, "snapshot");
895
- if (s === "userMessage" || P(n)) return {
968
+ let n = j(e, "snapshot");
969
+ 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";
971
+ if (s && this.toolNameByCallId.set(s, c), r) {
972
+ let t = r.isError ? { error: r.result } : r.result;
973
+ return {
974
+ ...a(),
975
+ EventType: "tool_result",
976
+ Metadata: {
977
+ ...R(e, "completed", void 0, s),
978
+ call_id: s,
979
+ tool_name: c,
980
+ run_id: i,
981
+ tool_output: t
982
+ }
983
+ };
984
+ }
985
+ return {
986
+ ...a(),
987
+ EventType: "tool_call",
988
+ Metadata: {
989
+ ...R(e, "replace", void 0, s),
990
+ call_id: s,
991
+ tool_name: c,
992
+ run_id: i,
993
+ tool_args: t?.arguments ?? N(n)
994
+ }
995
+ };
996
+ }
997
+ 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);
999
+ return {
1000
+ ...a(),
1001
+ EventType: "tool_result",
1002
+ Metadata: {
1003
+ ...R(e, "completed", void 0, r),
1004
+ call_id: r,
1005
+ tool_name: o,
1006
+ run_id: i,
1007
+ tool_output: c
1008
+ }
1009
+ };
1010
+ }
1011
+ if (s === "userMessage" || Ge(n)) return {
896
1012
  ...a(),
897
1013
  EventType: "user_message",
898
- Content: { parts: [{ text: N(n) }] }
1014
+ Content: { parts: [{ text: M(n) }] }
899
1015
  };
900
1016
  if (s === "agentMessage" || !s && e.item_kind === "message") {
901
- let r = N(n), i = String(j(n[0])?.part_id || e.item_id || t);
1017
+ let r = M(n), i = String(A(n[0])?.part_id || e.item_id || t);
902
1018
  return this.textByPart.set(i, r), {
903
1019
  ...a(),
904
1020
  EventType: "assistant_message",
905
1021
  Content: { parts: [{ text: r }] },
906
- Metadata: I(e, "completed", i)
1022
+ Metadata: R(e, "completed", i)
907
1023
  };
908
1024
  }
909
1025
  if (s === "reasoning" || e.item_kind === "reasoning") {
910
- let r = String(j(n[0])?.part_id || e.item_id || t);
1026
+ let r = String(A(n[0])?.part_id || e.item_id || t);
911
1027
  return {
912
1028
  ...a(),
913
1029
  EventType: "reasoning",
914
- Content: { parts: [{ text: N(n) }] },
915
- Metadata: I(e, "completed", r)
1030
+ Content: { parts: [{ text: M(n) }] },
1031
+ Metadata: R(e, "completed", r)
916
1032
  };
917
1033
  }
918
1034
  return s && s !== "notification" ? {
919
1035
  ...a(),
920
1036
  EventType: "tool_result",
921
1037
  Metadata: {
922
- ...I(e, "completed"),
1038
+ ...R(e, "completed"),
923
1039
  call_id: String(e.item_id || ""),
924
1040
  tool_name: s,
925
1041
  run_id: i,
926
- tool_output: F(n)
1042
+ tool_output: N(n)
927
1043
  }
928
1044
  } : null;
929
1045
  }
930
- return r === "item.failed" && s && s !== "notification" && s !== "agentMessage" && s !== "reasoning" ? {
931
- ...a(),
932
- EventType: "tool_result",
933
- Metadata: {
934
- ...I(e, "completed"),
935
- call_id: String(e.item_id || ""),
936
- tool_name: s,
937
- run_id: i,
938
- tool_output: { error: j(e.error) || e.error || "item failed" }
1046
+ if (r === "item.failed") {
1047
+ if (e.item_kind === "tool_call") {
1048
+ let t = this.toolCallByItemId.get(String(e.item_id || "")), n = t?.callId || String(e.item_id || ""), r = t?.name || this.toolNameByCallId.get(n) || "tool", o = this.toolResultByItemId.get(String(e.item_id || ""));
1049
+ return {
1050
+ ...a(),
1051
+ EventType: "tool_result",
1052
+ Metadata: {
1053
+ ...R(e, "completed", void 0, n),
1054
+ call_id: n,
1055
+ tool_name: r,
1056
+ run_id: i,
1057
+ tool_output: o ?? { error: A(e.error) || e.error || "item failed" }
1058
+ }
1059
+ };
939
1060
  }
940
- } : null;
1061
+ return s && s !== "notification" && s !== "agentMessage" && s !== "reasoning" ? {
1062
+ ...a(),
1063
+ EventType: "tool_result",
1064
+ Metadata: {
1065
+ ...R(e, "completed"),
1066
+ call_id: String(e.item_id || ""),
1067
+ tool_name: s,
1068
+ run_id: i,
1069
+ tool_output: { error: A(e.error) || e.error || "item failed" }
1070
+ }
1071
+ } : null;
1072
+ }
1073
+ return null;
941
1074
  }
942
1075
  };
943
- async function We(e) {
1076
+ async function qe(e) {
944
1077
  let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
945
1078
  try {
946
1079
  for (;;) {
@@ -950,8 +1083,8 @@ async function We(e) {
950
1083
  break;
951
1084
  }
952
1085
  if (r.trimStart().startsWith("{")) {
953
- if (Ge(r)) {
954
- i = Ke(r);
1086
+ if (Je(r)) {
1087
+ i = Ye(r);
955
1088
  break;
956
1089
  }
957
1090
  } else if (o(r)) break;
@@ -985,7 +1118,7 @@ async function We(e) {
985
1118
  stream: c
986
1119
  };
987
1120
  }
988
- function Ge(e) {
1121
+ function Je(e) {
989
1122
  let t = e.trim();
990
1123
  if (!t.endsWith("}")) return !1;
991
1124
  let n = 0, r = !1, i = !1;
@@ -1002,11 +1135,11 @@ function Ge(e) {
1002
1135
  }
1003
1136
  return n === 0;
1004
1137
  }
1005
- function Ke(e) {
1138
+ function Ye(e) {
1006
1139
  try {
1007
- let t = j(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1140
+ let t = A(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1008
1141
  if (!n) return null;
1009
- let r = j(t?.Error);
1142
+ let r = A(t?.Error);
1010
1143
  return {
1011
1144
  status: n,
1012
1145
  messageId: t?.MessageId ?? null,
@@ -1023,15 +1156,17 @@ function Ke(e) {
1023
1156
  }
1024
1157
  //#endregion
1025
1158
  //#region src/utils/responses-stream.js
1026
- function R() {
1159
+ function Xe() {
1027
1160
  return {
1028
1161
  toolNames: /* @__PURE__ */ new Map(),
1029
1162
  toolArguments: /* @__PURE__ */ new Map(),
1030
1163
  callIds: /* @__PURE__ */ new Map(),
1031
- currentResponseId: ""
1164
+ currentResponseId: "",
1165
+ sawTextDelta: !1,
1166
+ sawReasoningDelta: !1
1032
1167
  };
1033
1168
  }
1034
- function qe(e) {
1169
+ function Ze(e) {
1035
1170
  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 : "";
1036
1171
  }
1037
1172
  function z(e) {
@@ -1039,15 +1174,15 @@ function z(e) {
1039
1174
  }
1040
1175
  function B(...e) {
1041
1176
  for (let t of e) {
1042
- let e = qe(t);
1177
+ let e = Ze(t);
1043
1178
  if (e) return e;
1044
1179
  }
1045
1180
  return "";
1046
1181
  }
1047
- function Je(e, t) {
1182
+ function Qe(e, t) {
1048
1183
  return String(e?.id || e?.item_id || e?.call_id || t?.item_id || t?.call_id || t?.output_index || "");
1049
1184
  }
1050
- function Ye(e, t, n, r, i) {
1185
+ function $e(e, t, n, r, i) {
1051
1186
  t && (e.toolNames.set(t, r), e.toolArguments.set(t, i));
1052
1187
  let a = String(n?.call_id || "");
1053
1188
  a && (e.callIds.set(a, t || r), e.toolNames.set(a, r), e.toolArguments.set(a, i));
@@ -1058,10 +1193,10 @@ function V(e, t, n, r = "tool") {
1058
1193
  }
1059
1194
  function H(e) {
1060
1195
  if (!e || typeof e != "object") return "";
1061
- let t = qe(e.content);
1196
+ let t = Ze(e.content);
1062
1197
  return B(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
1063
1198
  }
1064
- function Xe(e) {
1199
+ function et(e) {
1065
1200
  let t = e?.response && typeof e.response == "object" ? e.response : e, n = B(t?.output_text, t?.text);
1066
1201
  if (n) return n;
1067
1202
  let r = Array.isArray(t?.output) ? t.output : [];
@@ -1071,11 +1206,11 @@ function Xe(e) {
1071
1206
  }
1072
1207
  return "";
1073
1208
  }
1074
- function Ze(e) {
1209
+ function tt(e) {
1075
1210
  let t = e?.response && typeof e.response == "object" ? e.response : e;
1076
1211
  return Array.isArray(t?.output) ? t.output : [];
1077
1212
  }
1078
- function Qe(e) {
1213
+ function nt(e) {
1079
1214
  let t = e;
1080
1215
  if (typeof t == "string") try {
1081
1216
  t = JSON.parse(t);
@@ -1088,10 +1223,10 @@ function Qe(e) {
1088
1223
  } : t;
1089
1224
  }
1090
1225
  function U({ data: e, state: t, status: n }) {
1091
- let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Je(r, e);
1226
+ let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Qe(r, e);
1092
1227
  if (i === "function_call") {
1093
1228
  let e = V(t, a, r), i = z(r.arguments ?? r.args ?? r.input);
1094
- return Ye(t, a, r, e, i), [{
1229
+ return $e(t, a, r, e, i), [{
1095
1230
  type: "tool_upsert",
1096
1231
  name: e,
1097
1232
  args: i,
@@ -1104,7 +1239,7 @@ function U({ data: e, state: t, status: n }) {
1104
1239
  output: z(r.output ?? r.result ?? r.content)
1105
1240
  }];
1106
1241
  if (i === "mcp_approval_request") {
1107
- let n = String(r.name || "approval"), i = z(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || "");
1242
+ let n = String(r.name || "approval"), i = z(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || ""), o = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
1108
1243
  return [{
1109
1244
  type: "tool_upsert",
1110
1245
  name: n,
@@ -1117,6 +1252,7 @@ function U({ data: e, state: t, status: n }) {
1117
1252
  type: "approval_request",
1118
1253
  approvalRequestId: a,
1119
1254
  previousResponseId: String(e?.response_id || t.currentResponseId || ""),
1255
+ ...o ? { runId: o } : {},
1120
1256
  name: n,
1121
1257
  args: i
1122
1258
  }];
@@ -1137,7 +1273,7 @@ function U({ data: e, state: t, status: n }) {
1137
1273
  }
1138
1274
  return [];
1139
1275
  }
1140
- function $e({ eventName: e, data: t, state: n }) {
1276
+ function rt({ eventName: e, data: t, state: n }) {
1141
1277
  let r = String(t?.type || e || "").trim(), i = String(t?.id || t?.response?.id || t?.response_id || "");
1142
1278
  if (i.startsWith("resp_") && (n.currentResponseId = i), r === "response.tool_call") return [{
1143
1279
  type: "tool_upsert",
@@ -1180,14 +1316,14 @@ function $e({ eventName: e, data: t, state: n }) {
1180
1316
  }
1181
1317
  if (r === "response.reasoning.delta" || r === "response.reasoning_text.delta" || r === "response.reasoning_summary.delta" || r === "response.reasoning_summary_text.delta") {
1182
1318
  let e = B(t?.delta, t?.text);
1183
- return e ? [{
1319
+ return e && (n.sawReasoningDelta = !0), e ? [{
1184
1320
  type: "reasoning_delta",
1185
1321
  text: e
1186
1322
  }] : [];
1187
1323
  }
1188
1324
  if (r === "response.output_text.delta") {
1189
1325
  let e = B(t?.delta, t?.text);
1190
- return e ? [{
1326
+ return e && (n.sawTextDelta = !0), e ? [{
1191
1327
  type: "text_delta",
1192
1328
  text: e
1193
1329
  }] : [];
@@ -1200,27 +1336,27 @@ function $e({ eventName: e, data: t, state: n }) {
1200
1336
  }] : [];
1201
1337
  }
1202
1338
  if (r === "response.content_part.delta") {
1203
- let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), n = B(t?.delta?.text, t?.delta, t?.text);
1204
- return n ? e.includes("reasoning") ? [{
1339
+ let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), r = B(t?.delta?.text, t?.delta, t?.text);
1340
+ return r ? e.includes("reasoning") ? (n.sawReasoningDelta = !0, [{
1205
1341
  type: "reasoning_delta",
1206
- text: n
1207
- }] : [{
1342
+ text: r
1343
+ }]) : (n.sawTextDelta = !0, [{
1208
1344
  type: "text_delta",
1209
- text: n
1210
- }] : [];
1345
+ text: r
1346
+ }]) : [];
1211
1347
  }
1212
1348
  if (r === "response.completed") {
1213
- let e = Xe(t), r = Ze(t).flatMap((e) => U({
1349
+ let e = et(t), r = tt(t).flatMap((e) => U({
1214
1350
  data: {
1215
1351
  ...t,
1216
1352
  item: e
1217
1353
  },
1218
1354
  state: n,
1219
1355
  status: "completed"
1220
- })), i = r.some((e) => e.type === "text_final");
1356
+ })).filter((e) => !(n.sawTextDelta && e.type === "text_final") && !(n.sawReasoningDelta && e.type === "reasoning_delta")), i = r.some((e) => e.type === "text_final");
1221
1357
  return [
1222
1358
  ...r,
1223
- ...e && !i ? [{
1359
+ ...e && !n.sawTextDelta && !i ? [{
1224
1360
  type: "text_final",
1225
1361
  text: e
1226
1362
  }] : [],
@@ -1246,20 +1382,21 @@ function $e({ eventName: e, data: t, state: n }) {
1246
1382
  status: "cancelled"
1247
1383
  }];
1248
1384
  if (r === "response.approval_request" || r === "response.ksadk.approval_request") {
1249
- let e = Qe(t?.interrupt_info), r = String(e.approval_request_id || e.id || ""), i = String(t?.response_id || n.currentResponseId || ""), a = e.approval_requests && typeof e.approval_requests == "object" ? e.approval_requests : e, o = Array.isArray(a.action_requests) ? a.action_requests : [];
1250
- if (o.length > 0) {
1251
- let e = o.map((e) => ({
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 : [];
1386
+ if (s.length > 0) {
1387
+ let e = s.map((e) => ({
1252
1388
  type: "tool_upsert",
1253
1389
  name: String(e?.name || "tool"),
1254
1390
  args: JSON.stringify(e?.args ?? {}),
1255
1391
  status: "paused",
1256
1392
  approvalRequestId: r,
1257
1393
  previousResponseId: i
1258
- })), t = o[0] || {};
1394
+ })), t = s[0] || {};
1259
1395
  return [...e, {
1260
1396
  type: "approval_request",
1261
1397
  approvalRequestId: r,
1262
1398
  previousResponseId: i,
1399
+ ...a ? { runId: a } : {},
1263
1400
  name: String(t?.name || "人工确认"),
1264
1401
  args: JSON.stringify(t?.args ?? {})
1265
1402
  }];
@@ -1267,7 +1404,17 @@ function $e({ eventName: e, data: t, state: n }) {
1267
1404
  return [{
1268
1405
  type: "approval_request",
1269
1406
  approvalRequestId: r,
1270
- previousResponseId: i
1407
+ previousResponseId: i,
1408
+ ...a ? { runId: a } : {}
1409
+ }];
1410
+ }
1411
+ if (r === "response.approval_resolved" || r === "response.ksadk.approval_resolved") {
1412
+ let e = String(t?.decision || t?.outcome || "").toLowerCase(), n = e === "reject" || e === "rejected" || e === "denied" ? "rejected" : e === "cancel" || e === "cancelled" || e === "canceled" ? "cancelled" : "approved";
1413
+ return [{
1414
+ type: "approval_resolved",
1415
+ approvalRequestId: String(t?.approval_request_id || t?.approvalRequestId || t?.approval_id || t?.approvalId || ""),
1416
+ decision: n,
1417
+ revision: Number(t?.revision || 2)
1271
1418
  }];
1272
1419
  }
1273
1420
  if (new Set([
@@ -1323,7 +1470,7 @@ function $e({ eventName: e, data: t, state: n }) {
1323
1470
  }
1324
1471
  //#endregion
1325
1472
  //#region src/utils/session-events.js
1326
- var et = new Set([
1473
+ var it = new Set([
1327
1474
  "completed",
1328
1475
  "failed",
1329
1476
  "error",
@@ -1349,11 +1496,11 @@ function K(e) {
1349
1496
  let t = e?.Content?.payload;
1350
1497
  return t && typeof t == "object" ? t : {};
1351
1498
  }
1352
- function tt(e, t) {
1499
+ function at(e, t) {
1353
1500
  let n = String(e || ""), r = String(t || "");
1354
1501
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1355
1502
  }
1356
- function nt(e) {
1503
+ function ot(e) {
1357
1504
  let t = String(e?.EventType || ""), n = K(e);
1358
1505
  return G[t] ? {
1359
1506
  ...e,
@@ -1397,7 +1544,7 @@ function nt(e) {
1397
1544
  }
1398
1545
  } : e;
1399
1546
  }
1400
- function rt(e) {
1547
+ function st(e) {
1401
1548
  let t = [], n = /* @__PURE__ */ new Map();
1402
1549
  for (let r of Array.isArray(e) ? e : []) {
1403
1550
  let e = String(r?.EventType || "");
@@ -1407,11 +1554,11 @@ function rt(e) {
1407
1554
  let t = n.get(e);
1408
1555
  n.set(e, {
1409
1556
  event: r,
1410
- text: tt(t?.text, K(r).text)
1557
+ text: at(t?.text, K(r).text)
1411
1558
  });
1412
1559
  continue;
1413
1560
  }
1414
- t.push(nt(r));
1561
+ t.push(ot(r));
1415
1562
  }
1416
1563
  for (let { event: e, text: r } of n.values()) t.push({
1417
1564
  ...e,
@@ -1425,10 +1572,12 @@ function rt(e) {
1425
1572
  stream_snapshot: !0
1426
1573
  }
1427
1574
  });
1428
- return t.sort((e, t) => Z(e) - Z(t));
1575
+ return t.sort((e, t) => Q(e) - Q(t));
1429
1576
  }
1430
- function it(e) {
1431
- let t = String(e?.EventType || "").trim(), n = K(e);
1577
+ function ct(e) {
1578
+ let t = String(e?.EventType || "").trim();
1579
+ if (t !== "run_status" && !t.startsWith("run.")) return "";
1580
+ let n = K(e);
1432
1581
  return String(e?.Content?.status || n.status || G[t] || "").trim().toLowerCase();
1433
1582
  }
1434
1583
  function q(e) {
@@ -1438,10 +1587,10 @@ function J(e) {
1438
1587
  let t = String(e || "").trim();
1439
1588
  return t ? `/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}` : "";
1440
1589
  }
1441
- function at(e) {
1590
+ function lt(e) {
1442
1591
  return String(e || "").match(/^data:([^;,]+)/)?.[1] || "";
1443
1592
  }
1444
- function ot(e, t) {
1593
+ function ut(e, t) {
1445
1594
  let n = String(e || "").trim(), r = String(t || "").trim();
1446
1595
  return !n || !r || n === r ? !0 : n.endsWith("/*") ? r.startsWith(n.slice(0, -1)) : r.endsWith("/*") ? n.startsWith(r.slice(0, -1)) : !1;
1447
1596
  }
@@ -1486,7 +1635,7 @@ function Y(e) {
1486
1635
  t && i({
1487
1636
  name: e.filename || e.displayName || e.display_name || "uploaded_image",
1488
1637
  url: t,
1489
- type: e.mime_type || e.mimeType || at(t) || "image/*"
1638
+ type: e.mime_type || e.mimeType || lt(t) || "image/*"
1490
1639
  });
1491
1640
  continue;
1492
1641
  }
@@ -1508,7 +1657,7 @@ function Y(e) {
1508
1657
  type: e.mime_type || "application/octet-stream",
1509
1658
  fileUri: t
1510
1659
  };
1511
- !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && ot(e.type, n.type) && (e.url || e.fileUri)) || i(n);
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);
1512
1661
  }
1513
1662
  let o = Array.from(r.values());
1514
1663
  return {
@@ -1516,10 +1665,10 @@ function Y(e) {
1516
1665
  attachments: o.length > 0 ? o : void 0
1517
1666
  };
1518
1667
  }
1519
- function st(t) {
1668
+ function dt(t) {
1520
1669
  let n = t?.Metadata?.responses_output;
1521
1670
  if (!Array.isArray(n)) return {};
1522
- let r = R(), i = $e({
1671
+ let r = Xe(), i = rt({
1523
1672
  eventName: "response.completed",
1524
1673
  data: { response: {
1525
1674
  id: String(t.Metadata?.response_id || ""),
@@ -1563,10 +1712,10 @@ function st(t) {
1563
1712
  ...Object.keys(o).length > 0 ? { tools: o } : {}
1564
1713
  };
1565
1714
  }
1566
- function ct(e, t, n) {
1715
+ function ft(e, t, n) {
1567
1716
  return t === "running" ? e === "prompt_too_long" ? "检测到上下文过长,正在自动压缩历史后重试" : "正在自动压缩上下文" : n ? e === "prompt_too_long" ? "上下文过长,系统已自动压缩历史并重试" : "系统已自动压缩较早的对话上下文" : t === "failed" ? "自动压缩上下文未完成" : e === "prompt_too_long" ? "已完成上下文压缩,并继续当前回复" : "已完成上下文压缩";
1568
1717
  }
1569
- function lt(e, t) {
1718
+ function pt(e, t) {
1570
1719
  return t?.itemId ? [
1571
1720
  "runtime-item",
1572
1721
  t.runId || e,
@@ -1587,7 +1736,7 @@ function X(e) {
1587
1736
  n.ItemId
1588
1737
  ].join("\0") : t;
1589
1738
  }
1590
- function ut(e) {
1739
+ function mt(e) {
1591
1740
  let t = e?.Metadata?.RuntimeItem;
1592
1741
  return t?.ItemId ? {
1593
1742
  id: `runtime:${t.RunId || e.InvocationId || "run"}:${t.ScopeId || e.InvocationId || "scope"}:${t.ItemId}`,
@@ -1597,10 +1746,10 @@ function ut(e) {
1597
1746
  partId: t.PartId ? String(t.PartId) : void 0
1598
1747
  } : null;
1599
1748
  }
1600
- function dt(e) {
1749
+ function ht(e) {
1601
1750
  return e?.Metadata?.responses_mirror === !0 || String(e?.Metadata?.responses_mirror || "").trim().toLowerCase() === "true";
1602
1751
  }
1603
- function ft(e) {
1752
+ function Z(e) {
1604
1753
  if (e?.EventType !== "user_message") return "";
1605
1754
  let t = Y(e), n = (t.attachments || []).map((e) => [
1606
1755
  e.name || "",
@@ -1610,16 +1759,16 @@ function ft(e) {
1610
1759
  ].join("")).sort().join("");
1611
1760
  return [String(t.text || "").trim(), n].join("\0");
1612
1761
  }
1613
- function pt(e) {
1762
+ function gt(e) {
1614
1763
  return e?.EventType === "assistant_stream_snapshot";
1615
1764
  }
1616
- function Z(e) {
1765
+ function Q(e) {
1617
1766
  let t = Number(e?.SeqId || 0);
1618
1767
  if (Number.isFinite(t) && t > 0) return t;
1619
1768
  let n = Number(e?.Timestamp || 0);
1620
1769
  return Number.isFinite(n) ? n : 0;
1621
1770
  }
1622
- function mt(e) {
1771
+ function _t(e) {
1623
1772
  if (typeof e == "string") return e;
1624
1773
  if (e == null) return "";
1625
1774
  try {
@@ -1628,35 +1777,36 @@ function mt(e) {
1628
1777
  return String(e);
1629
1778
  }
1630
1779
  }
1631
- function ht(t) {
1780
+ function vt(t) {
1632
1781
  let n = String(t?.EventType || "");
1633
1782
  if (!W.has(n)) return null;
1634
- let r = String(t.Metadata?.tool_name || t.Metadata?.name || t.Metadata?.function_name || q(t.Content?.parts) || "tool").trim() || "tool", i = {
1783
+ 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 = {
1635
1784
  name: r,
1785
+ ...i ? { callId: i } : {},
1636
1786
  args: "",
1637
1787
  status: "running"
1638
- }, a = n === "tool_result" || n === "stage_tool_result" ? (() => {
1639
- let n = mt(t.Metadata?.tool_output ?? t.Metadata?.output ?? t.Metadata?.result ?? q(t.Content?.parts));
1788
+ }, 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));
1640
1790
  return {
1641
- ...i,
1791
+ ...a,
1642
1792
  output: n,
1643
1793
  status: e(n) ? "error" : "completed"
1644
1794
  };
1645
1795
  })() : {
1646
- ...i,
1647
- args: mt(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1648
- }, o = ut(t);
1796
+ ...a,
1797
+ args: _t(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1798
+ }, s = mt(t);
1649
1799
  return {
1650
- id: o?.id || t.EventId || String(Date.now() + Math.random()),
1800
+ id: s?.id || t.EventId || String(Date.now() + Math.random()),
1651
1801
  role: "model",
1652
1802
  content: "",
1653
1803
  timestamp: t.Timestamp || Date.now(),
1654
1804
  eventType: n,
1655
- ...o || {},
1656
- tools: { [r]: a }
1805
+ ...s || {},
1806
+ tools: { [r]: o }
1657
1807
  };
1658
1808
  }
1659
- function gt(e = {}, t = {}) {
1809
+ function yt(e = {}, t = {}) {
1660
1810
  let n = { ...e || {} };
1661
1811
  for (let [e, r] of Object.entries(t || {})) n[e] = {
1662
1812
  ...n[e] || {},
@@ -1666,8 +1816,8 @@ function gt(e = {}, t = {}) {
1666
1816
  };
1667
1817
  return n;
1668
1818
  }
1669
- function _t(e = {}, t = "") {
1670
- let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : et.has(n) ? "error" : "";
1819
+ function bt(e = {}, t = "") {
1820
+ let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : it.has(n) ? "error" : "";
1671
1821
  if (!r) return e;
1672
1822
  let i = !1, a = {};
1673
1823
  for (let [t, n] of Object.entries(e || {})) n?.status === "running" ? (i = !0, a[t] = {
@@ -1676,11 +1826,11 @@ function _t(e = {}, t = "") {
1676
1826
  }) : a[t] = n;
1677
1827
  return i ? a : e;
1678
1828
  }
1679
- function vt(e, t) {
1829
+ function xt(e, t) {
1680
1830
  return {
1681
1831
  ...e,
1682
- reasoning: yt(e.reasoning, t.reasoning),
1683
- tools: gt(e.tools, t.tools),
1832
+ reasoning: St(e.reasoning, t.reasoning),
1833
+ tools: yt(e.tools, t.tools),
1684
1834
  eventId: t.eventId || e.eventId,
1685
1835
  responseId: t.responseId || e.responseId,
1686
1836
  traceId: t.traceId || e.traceId,
@@ -1689,11 +1839,11 @@ function vt(e, t) {
1689
1839
  id: t.responseId || t.reasoning || t.tools ? t.id : e.id
1690
1840
  };
1691
1841
  }
1692
- function yt(e = "", t = "") {
1842
+ function St(e = "", t = "") {
1693
1843
  let n = String(e || ""), r = String(t || "");
1694
1844
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1695
1845
  }
1696
- function bt(e) {
1846
+ function Ct(e) {
1697
1847
  return {
1698
1848
  id: e.id,
1699
1849
  role: "system",
@@ -1704,11 +1854,11 @@ function bt(e) {
1704
1854
  summary: e.summary,
1705
1855
  historical: e.historical,
1706
1856
  timestamp: e.timestamp,
1707
- content: ct(e.trigger, e.status, e.historical)
1857
+ content: ft(e.trigger, e.status, e.historical)
1708
1858
  };
1709
1859
  }
1710
- function xt(e) {
1711
- let t = e?.EventType || "", n = ut(e);
1860
+ function wt(e) {
1861
+ let t = e?.EventType || "", n = mt(e);
1712
1862
  if (t === "run_status") return e.Content?.status === "failed" ? {
1713
1863
  id: e.EventId || String(Date.now() + Math.random()),
1714
1864
  role: "system",
@@ -1726,7 +1876,7 @@ function xt(e) {
1726
1876
  } : null;
1727
1877
  if (t === "context_checkpoint") {
1728
1878
  let t = Y(e);
1729
- return bt({
1879
+ return Ct({
1730
1880
  id: e.EventId || String(Date.now() + Math.random()),
1731
1881
  timestamp: e.Timestamp || Date.now(),
1732
1882
  status: "completed",
@@ -1748,9 +1898,9 @@ function xt(e) {
1748
1898
  ...n || {}
1749
1899
  } : null;
1750
1900
  }
1751
- if (W.has(t)) return ht(e);
1901
+ if (W.has(t)) return vt(e);
1752
1902
  if (t !== "user_message" && t !== "assistant_message" && t !== "assistant_stream_snapshot") return null;
1753
- let r = Y(e), i = t === "assistant_message" ? st(e) : {};
1903
+ let r = Y(e), i = t === "assistant_message" ? dt(e) : {};
1754
1904
  if (!r.text && !r.attachments?.length && !i.reasoning && !i.tools) return null;
1755
1905
  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();
1756
1906
  return {
@@ -1768,8 +1918,8 @@ function xt(e) {
1768
1918
  ...i
1769
1919
  };
1770
1920
  }
1771
- function Q(e = []) {
1772
- 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 = rt(e), c = [];
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 = [];
1773
1923
  for (let e of s) {
1774
1924
  let t = String(e?.EventId || "").trim();
1775
1925
  if (t) {
@@ -1780,30 +1930,30 @@ function Q(e = []) {
1780
1930
  }
1781
1931
  let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
1782
1932
  for (let e of c) {
1783
- if (e?.EventType !== "user_message" || dt(e)) {
1933
+ if (e?.EventType !== "user_message" || ht(e)) {
1784
1934
  if (e?.EventType === "assistant_message") {
1785
1935
  let t = X(e);
1786
1936
  t && u.add(t);
1787
1937
  }
1788
- if (pt(e)) {
1938
+ if (gt(e)) {
1789
1939
  let t = X(e);
1790
1940
  if (t) {
1791
1941
  let n = d.get(t);
1792
- (!n || Z(e) >= Z(n)) && d.set(t, e);
1942
+ (!n || Q(e) >= Q(n)) && d.set(t, e);
1793
1943
  }
1794
1944
  }
1795
1945
  continue;
1796
1946
  }
1797
- let t = ft(e);
1947
+ let t = Z(e);
1798
1948
  t && l.add(t);
1799
1949
  }
1800
1950
  let f = c.filter((e) => {
1801
- if (pt(e)) {
1951
+ if (gt(e)) {
1802
1952
  let t = X(e);
1803
1953
  return t ? u.has(t) ? !1 : d.get(t) === e : !0;
1804
1954
  }
1805
- if (e?.EventType !== "user_message" || !dt(e)) return !0;
1806
- let t = ft(e);
1955
+ if (e?.EventType !== "user_message" || !ht(e)) return !0;
1956
+ let t = Z(e);
1807
1957
  return !t || !l.has(t);
1808
1958
  });
1809
1959
  for (let e of f) {
@@ -1821,26 +1971,26 @@ function Q(e = []) {
1821
1971
  let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = /* @__PURE__ */ new Map(), v = (e) => {
1822
1972
  let t = e?.itemId ? `${e.runId || e.invocationId || ""}\u0000${e.scopeId || e.invocationId || ""}\u0000${e.itemId}` : "", n = t ? h.get(t) : void 0;
1823
1973
  if (n !== void 0) {
1824
- p[n] = vt(p[n], e);
1974
+ p[n] = xt(p[n], e);
1825
1975
  return;
1826
1976
  }
1827
1977
  let r = String(e?.responseId || "").trim(), i = r ? m.get(r) : void 0;
1828
1978
  if (i !== void 0) {
1829
- p[i] = vt(p[i], e);
1979
+ p[i] = xt(p[i], e);
1830
1980
  return;
1831
1981
  }
1832
1982
  r && m.set(r, p.length), t && h.set(t, p.length), p.push(e);
1833
1983
  }, y = () => {
1834
1984
  g &&= (v(g), null);
1835
- }, b = (e) => {
1836
- let n = String(e || "").trim();
1837
- if (!n) return {};
1838
- let r = _.get(n);
1839
- return r ? (_.delete(n), { tools: _t(r.tools, t.get(n)) }) : {};
1985
+ }, b = (e, n = "") => {
1986
+ let r = String(e || "").trim();
1987
+ if (!r) return {};
1988
+ let i = _.get(r);
1989
+ return i ? (_.delete(r), { tools: bt(i.tools, t.get(r) || n) }) : {};
1840
1990
  };
1841
1991
  for (let e of f) {
1842
1992
  if (e.EventType === "run_status") continue;
1843
- let t = xt(e);
1993
+ let t = wt(e);
1844
1994
  if (!t) continue;
1845
1995
  let n = String(e.InvocationId || "").trim();
1846
1996
  if (n && (t.invocationId = n), W.has(t.eventType)) {
@@ -1863,7 +2013,7 @@ function Q(e = []) {
1863
2013
  invocationId: n
1864
2014
  },
1865
2015
  timestamp: Math.max(Number(r?.timestamp || 0), Number(t.timestamp || 0)),
1866
- tools: gt(r?.tools, t.tools)
2016
+ tools: yt(r?.tools, t.tools)
1867
2017
  });
1868
2018
  continue;
1869
2019
  }
@@ -1881,24 +2031,24 @@ function Q(e = []) {
1881
2031
  }
1882
2032
  let r = t.eventType === "assistant_message" || t.eventType === "assistant_stream_snapshot";
1883
2033
  if (r && g) {
1884
- let n = String(e.InvocationId || "").trim(), r = lt(n, t);
2034
+ let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1885
2035
  if (t.eventType === "assistant_message" && n && a.has(r)) {
1886
2036
  g = null;
1887
2037
  continue;
1888
2038
  }
1889
2039
  t.eventType === "assistant_message" && n && a.add(r), v({
1890
2040
  ...t,
1891
- ...b(n),
1892
- reasoning: yt(g.reasoning, t.reasoning)
2041
+ ...b(n, t.eventType === "assistant_message" ? "completed" : ""),
2042
+ reasoning: St(g.reasoning, t.reasoning)
1893
2043
  }), g = null;
1894
2044
  continue;
1895
2045
  }
1896
2046
  if (y(), r) {
1897
- let n = String(e.InvocationId || "").trim(), r = lt(n, t);
2047
+ let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1898
2048
  if (t.eventType === "assistant_message" && n && a.has(r)) continue;
1899
2049
  t.eventType === "assistant_message" && n && a.add(r), v({
1900
2050
  ...t,
1901
- ...b(n)
2051
+ ...b(n, t.eventType === "assistant_message" ? "completed" : "")
1902
2052
  });
1903
2053
  continue;
1904
2054
  }
@@ -1907,7 +2057,7 @@ function Q(e = []) {
1907
2057
  y();
1908
2058
  for (let [e, n] of _.entries()) v({
1909
2059
  ...n,
1910
- tools: _t(n.tools, t.get(e))
2060
+ tools: bt(n.tools, t.get(e))
1911
2061
  });
1912
2062
  for (let [e, a] of t.entries()) {
1913
2063
  if (a !== "in_progress" || r.has(e) || !i.has(e)) continue;
@@ -1923,7 +2073,7 @@ function Q(e = []) {
1923
2073
  }
1924
2074
  return p;
1925
2075
  }
1926
- function St(e = [], t = []) {
2076
+ function Et(e = [], t = []) {
1927
2077
  let n = [], r = /* @__PURE__ */ new Set();
1928
2078
  for (let i of [...Array.isArray(e) ? e : [], ...Array.isArray(t) ? t : []]) {
1929
2079
  let e = String(i?.EventId || "").trim();
@@ -1938,34 +2088,38 @@ function St(e = [], t = []) {
1938
2088
  return Number.isFinite(n) && Number.isFinite(r) && n !== r ? n - r : Number(e?.Timestamp || 0) - Number(t?.Timestamp || 0);
1939
2089
  });
1940
2090
  }
1941
- function Ct(e = []) {
2091
+ function Dt(e = []) {
1942
2092
  return (Array.isArray(e) ? e : []).reduce((e, t) => {
1943
2093
  let n = Number(t.SeqId || 0);
1944
2094
  return Number.isFinite(n) ? Math.max(e, n) : e;
1945
2095
  }, 0);
1946
2096
  }
1947
- function wt(e) {
1948
- return et.has(it(e));
2097
+ function Ot(e) {
2098
+ return it.has(ct(e));
1949
2099
  }
1950
2100
  //#endregion
1951
2101
  //#region src/utils/persisted-session-history.ts
1952
2102
  function $(e) {
1953
2103
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
1954
2104
  }
1955
- function Tt(e) {
2105
+ function kt(e) {
1956
2106
  if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
2107
+ if (typeof e == "string" && e.trim()) {
2108
+ let t = Number(e.trim());
2109
+ if (Number.isFinite(t)) return t > 0 && t < 1e11 ? t * 1e3 : t;
2110
+ }
1957
2111
  let t = Date.parse(String(e || ""));
1958
2112
  return Number.isFinite(t) ? t : Date.now();
1959
2113
  }
1960
- function Et(e) {
1961
- let t = $(e?.Content?.runtime_event);
2114
+ function At(e) {
2115
+ let t = $(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
1962
2116
  if (t && String(t.event_type || "")) return {
1963
2117
  ...t,
1964
2118
  family: "runtime",
1965
2119
  seq: Number(e.SeqId || t.seq || 0),
1966
2120
  timestamp: e.Timestamp || t.timestamp
1967
2121
  };
1968
- let n = $(e?.Content?.session_event);
2122
+ let n = $(e?.Content?.session_event || e?.Content?.sessionEvent);
1969
2123
  if (!n || String(n.family || "") !== "runtime") return null;
1970
2124
  let r = $(n.payload);
1971
2125
  return !r || !String(r.event_type || n.event_type || "") ? null : {
@@ -1977,57 +2131,100 @@ function Et(e) {
1977
2131
  timestamp: e.Timestamp || n.timestamp || r.timestamp
1978
2132
  };
1979
2133
  }
1980
- function Dt(e) {
2134
+ function jt(e) {
1981
2135
  return e.role === "model" ? {
1982
2136
  ...e,
1983
- blocks: ze({
2137
+ blocks: e.blocks?.length ? e.blocks : Be({
1984
2138
  content: e.content,
1985
2139
  reasoning: e.reasoning,
1986
2140
  tools: e.tools
1987
2141
  })
1988
2142
  } : e;
1989
2143
  }
1990
- function Ot(e, t) {
1991
- let n = t.find((e) => e.role === "user"), r = t.filter((e) => e.role === "model"), i = e.filter((e) => e.role === "model").at(-1), a = r.at(-1);
1992
- return e.map((e) => e.role === "user" && n ? {
2144
+ function Mt(e, t) {
2145
+ 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 ? {
1993
2146
  ...e,
1994
2147
  ...n,
1995
2148
  invocationId: e.invocationId || n.invocationId
1996
- } : Dt(e === i && a ? {
2149
+ } : jt(e === a && o ? {
1997
2150
  ...e,
1998
- responseId: a.responseId || e.responseId,
1999
- traceId: a.traceId || e.traceId,
2000
- rootSpanId: a.rootSpanId || e.rootSpanId
2151
+ responseId: o.responseId || e.responseId,
2152
+ traceId: o.traceId || e.traceId,
2153
+ rootSpanId: o.rootSpanId || e.rootSpanId
2001
2154
  } : e));
2155
+ return n && !r ? [n, ...s] : s;
2002
2156
  }
2003
- function kt(e) {
2157
+ function Nt(e, t) {
2158
+ let n = t.filter((e) => e.role === "model"), r = n.reduce((e, t) => ({
2159
+ ...e,
2160
+ ...t.tools || {}
2161
+ }), {}), 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({
2163
+ ...e,
2164
+ reasoning: e.reasoning || i || void 0,
2165
+ tools: Object.keys(r).length > 0 ? {
2166
+ ...e.tools || {},
2167
+ ...r
2168
+ } : e.tools
2169
+ }) : e);
2170
+ }
2171
+ function Pt(e) {
2004
2172
  return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
2005
2173
  }
2006
- function At(e, t, n) {
2007
- let r = new L(n), i = [], a = /* @__PURE__ */ new Set(), o = [...t || []].sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0));
2008
- for (let e of o) {
2009
- let t = Et(e);
2174
+ var Ft = new Set([
2175
+ "approval.resolved",
2176
+ "interaction.resolved",
2177
+ "interaction.cancelled",
2178
+ "interaction.canceled",
2179
+ "a2ui.action"
2180
+ ]);
2181
+ function It(e) {
2182
+ let t = /* @__PURE__ */ new Set();
2183
+ 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;
2186
+ let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
2187
+ if (![
2188
+ "cancel",
2189
+ "cancelled",
2190
+ "canceled"
2191
+ ].includes(o)) continue;
2192
+ let s = String(n.InvocationId || e.runId || e.run_id || i.runId || i.run_id || r.run_id || "").trim();
2193
+ s && t.add(s);
2194
+ }
2195
+ return t;
2196
+ }
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;
2199
+ for (let e of s) {
2200
+ let t = At(e);
2010
2201
  if (!t) continue;
2011
2202
  let n = String(t.run_id || "").trim();
2012
- n && a.add(n);
2013
- let o = r.translate(t);
2014
- o && i.push({
2015
- ...o,
2016
- SeqId: Number(e.SeqId || o.SeqId || 0),
2017
- Timestamp: Tt(e.Timestamp || o.Timestamp)
2203
+ if (n) {
2204
+ a.add(n);
2205
+ let e = $($(t.source)?.metadata), r = String(t.event_type || "") === "run.started", i = e?.native_item_kind === "userMessage";
2206
+ (c || r || i) && o.add(n);
2207
+ }
2208
+ let s = r.translate(t);
2209
+ s && i.push({
2210
+ ...s,
2211
+ SeqId: Number(e.SeqId || s.SeqId || 0),
2212
+ Timestamp: kt(e.Timestamp || s.Timestamp)
2018
2213
  });
2019
2214
  }
2020
- let s = Q(i).filter((e) => e.invocationId && a.has(e.invocationId)), c = /* @__PURE__ */ new Map();
2215
+ let l = Tt(i).filter((e) => e.invocationId && a.has(e.invocationId)), u = /* @__PURE__ */ new Map();
2021
2216
  for (let t of e) {
2022
2217
  let e = String(t.invocationId || "");
2023
- e && c.set(e, [...c.get(e) || [], t]);
2218
+ e && u.set(e, [...u.get(e) || [], t]);
2024
2219
  }
2025
- let l = kt(s), u = [...l].flatMap((e) => Ot(s.filter((t) => t.invocationId === e), c.get(e) || []));
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]));
2026
2223
  return {
2027
- messages: [...e.filter((e) => e.role === "a2ui" || !e.invocationId || !l.has(e.invocationId)), ...u].sort((e, t) => Number(e.timestamp || 0) - Number(t.timestamp || 0)),
2028
- canonicalRunIds: [...l],
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)),
2225
+ canonicalRunIds: [...d],
2029
2226
  translatedEvents: i
2030
2227
  };
2031
2228
  }
2032
2229
  //#endregion
2033
- export { ce as A, T as C, se as D, ee as E, oe as O, ye as S, te as T, Re as _, wt as a, je as b, it as c, L as d, We as f, Fe as g, ze as h, Q as i, t as j, re as k, R as l, Ne as m, At as n, Ct as o, Pe as p, bt as r, St as s, Et as t, $e as u, Ie as v, ve as w, xe as x, Le as y };
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 };