@kingsoftcloud/ksadk-web 0.3.19 → 0.3.21

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 (190) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-cjsDWTLW.js → ArtifactsPanel-BTenzy1K.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-DTtT6SBI.js → CodeBlock-CWxI359u.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-Dap7DsE1.js → MathMessageMarkdown-B15VlKfr.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock-C2QkLej8.js → MermaidBlock-CF2HMJlR.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-CeLWBCnF.js → NativeTerminalPanel-BxxcxRm3.js} +1 -1
  9. package/dist-ksadk/assets/{OfficialA2uiRenderer-BshRBsxZ.js → OfficialA2uiRenderer-CV3Q-e0k.js} +1 -1
  10. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-RvCk4kKS.js → abnfDiagram-VCTEODGH-C17mm8XX.js} +1 -1
  11. package/dist-ksadk/assets/{arc-R-NvbHBi.js → arc-CCLBsX1i.js} +1 -1
  12. package/dist-ksadk/assets/architecture-7GRP2DOG-BY2RHa5r.js +1 -0
  13. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-CWyeEVzn.js → architectureDiagram-5GKGNRK7-3pYSVy-d.js} +1 -1
  14. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-CHbhUWj9.js → blockDiagram-NRAW4CY4-CsOB-WCp.js} +1 -1
  15. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BJAftB45.js → c4Diagram-UCG6FXSJ-CU7GynG6.js} +1 -1
  16. package/dist-ksadk/assets/channel-DwzgTDPP.js +1 -0
  17. package/dist-ksadk/assets/chunk-2Q5K7J3B-N0kjk6xb.js +1 -0
  18. package/dist-ksadk/assets/{chunk-5VM5RSS4-BHufOSfh.js → chunk-5VM5RSS4-Cq3ikYM6.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-F27PBJKO-BNPW42o9.js → chunk-F27PBJKO-6qvmutbT.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-G27WJ6UU-D_eOFZiC.js → chunk-G27WJ6UU-BPmeKaDK.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-JWPE2WC7-DEVN_PSR.js → chunk-JWPE2WC7-zKI5bjIE.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-LCL6LL3I-DjGV_Lnh.js → chunk-LCL6LL3I-DZu2N18T.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-POPQ4Y6H-C2i8ZB07.js → chunk-POPQ4Y6H-BGNgCFIF.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-RHFEMEQ7-DMk7_iWC.js → chunk-RHFEMEQ7-G_H04lee.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-SVP7TREG-wHQkXddN.js → chunk-SVP7TREG-BFQPbitJ.js} +1 -1
  26. package/dist-ksadk/assets/{chunk-XXDRQBXY-gvpc9yiQ.js → chunk-XXDRQBXY-BbCZlhsd.js} +1 -1
  27. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-tbe25yqD.js +1 -0
  28. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-tbe25yqD.js +1 -0
  29. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-BF-zBbK8.js → cose-bilkent-JH36ORCC-C4DjCklV.js} +1 -1
  30. package/dist-ksadk/assets/cynefin-OW5HDTMX-CSDfrArA.js +1 -0
  31. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-0_hg7nkA.js → cynefinDiagram-5FMLGOSQ-CT5ZGJWR.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-3AP2YEHR-uSuKjV2i.js → dagre-3AP2YEHR-DpvhjWtg.js} +1 -1
  33. package/dist-ksadk/assets/{dagre-BCQPdEAN.js → dagre-DXyfwLa_.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-S7CK7UJ4-ay17NfAC.js → diagram-S7CK7UJ4-BFXOsPnj.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-UQ7AKVKN-CaUhPrNE.js → diagram-UQ7AKVKN-DjknKAEr.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VSXAHHWV-upF8B0NL.js → diagram-VSXAHHWV-BB85Ss9s.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-VX7I27RA-B4t46LEt.js → diagram-VX7I27RA-BXi257cj.js} +1 -1
  38. package/dist-ksadk/assets/{diagram-Z3DM3KII-BeHjswE7.js → diagram-Z3DM3KII-DpUD78cp.js} +1 -1
  39. package/dist-ksadk/assets/{dist-DIeaHG12.js → dist-B06powmG.js} +1 -1
  40. package/dist-ksadk/assets/{dist-Bt4Xk1Ro.js → dist-BNv0PyLr.js} +1 -1
  41. package/dist-ksadk/assets/{dist-B0PMHWqd.js → dist-BRZbKA2x.js} +1 -1
  42. package/dist-ksadk/assets/{dist-B0s4RUpo.js → dist-BYwMHGkY.js} +1 -1
  43. package/dist-ksadk/assets/{dist-CIZ7o8ol.js → dist-BZW9mKsK.js} +1 -1
  44. package/dist-ksadk/assets/{dist-COzkztpc.js → dist-BeVI-Kxd.js} +1 -1
  45. package/dist-ksadk/assets/{dist-uAoeCAZ2.js → dist-Bq9DY1Dv.js} +1 -1
  46. package/dist-ksadk/assets/{dist-CW5ZHS5y.js → dist-Bzd2QgV8.js} +1 -1
  47. package/dist-ksadk/assets/{dist-h0bOCJVW.js → dist-CMFDdLf4.js} +1 -1
  48. package/dist-ksadk/assets/{dist-58qYwY0M.js → dist-CV9d3y2j.js} +1 -1
  49. package/dist-ksadk/assets/{dist-Be3VXZq8.js → dist-CXVLGraS.js} +1 -1
  50. package/dist-ksadk/assets/{dist-Bt0YWq2H.js → dist-CczefzvC.js} +1 -1
  51. package/dist-ksadk/assets/{dist-C577ALLK.js → dist-Cj2Auk2b.js} +1 -1
  52. package/dist-ksadk/assets/{dist-DfFlb9ip.js → dist-CnQbOxbh.js} +1 -1
  53. package/dist-ksadk/assets/{dist-Dze75pZq.js → dist-DBGrMizf.js} +1 -1
  54. package/dist-ksadk/assets/{dist-DvOmTQAV.js → dist-DavYaJ9Q.js} +1 -1
  55. package/dist-ksadk/assets/{dist-BGzoFqM2.js → dist-Dycz9kOr.js} +1 -1
  56. package/dist-ksadk/assets/{dist-BLCD6xMk.js → dist-R5ApucPA.js} +1 -1
  57. package/dist-ksadk/assets/{dist-AF7gi0D5.js → dist-TZoM3zbE.js} +1 -1
  58. package/dist-ksadk/assets/{dist-CdhMAiGd.js → dist-WrvDVf9t.js} +1 -1
  59. package/dist-ksadk/assets/{dist-mkEF0-z9.js → dist-Z1yWL6bl.js} +1 -1
  60. package/dist-ksadk/assets/{dist-Bx4az-XW.js → dist-r1VjfiSE.js} +1 -1
  61. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-CZKqGdhK.js → ebnfDiagram-PWID7BFC-lDIRqB5V.js} +1 -1
  62. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CfQ9oOg4.js → erDiagram-SSCWMZ5O-BiSx4WXZ.js} +1 -1
  63. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-CA5gOEzT.js +1 -0
  64. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BEQAxSrx.js +1 -0
  65. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-CWdRcbsA.js → ganttDiagram-EL5Y4UJY-B2XMRclR.js} +1 -1
  66. package/dist-ksadk/assets/gitGraph-4MIJSDKK-DhOY6HCO.js +1 -0
  67. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-S2TxceQ8.js → gitGraphDiagram-WWUBYQGX-B0Im0UQT.js} +1 -1
  68. package/dist-ksadk/assets/index-B9UP7He9.css +2 -0
  69. package/dist-ksadk/assets/index-DybHfQCT.js +1135 -0
  70. package/dist-ksadk/assets/info-A6RAGUB7-Dp4VkXgu.js +1 -0
  71. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-7M0hPUvw.js → infoDiagram-RXCK75RN-CoIIy7xO.js} +1 -1
  72. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-DApt_KC9.js → ishikawaDiagram-5VMMS53U-CdOil3Ww.js} +1 -1
  73. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-03NWnwcI.js → journeyDiagram-EYS64GPL-ag6kSf5d.js} +1 -1
  74. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CWrM-ciB.js → kanban-definition-3QL26DDD-CmIFaKQY.js} +1 -1
  75. package/dist-ksadk/assets/{katex-CVJEnrQQ.js → katex-DxefP4aZ.js} +1 -1
  76. package/dist-ksadk/assets/{linear-CuvdttYn.js → linear-DwipGcVt.js} +1 -1
  77. package/dist-ksadk/assets/{mermaid-parser.core-CyiGaINC.js → mermaid-parser.core-vshe0mzD.js} +2 -2
  78. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-Cx8x9zok.js → mindmap-definition-FBJOCRG2-Dw-6--QW.js} +1 -1
  79. package/dist-ksadk/assets/packet-AYTQ26CC-CeRM6FyX.js +1 -0
  80. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-BvMeLOBU.js → pegDiagram-XKGWAZYB-DFNebRUp.js} +1 -1
  81. package/dist-ksadk/assets/pie-WAS4IAKB-Djp6ckL7.js +1 -0
  82. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-BTEiUEUk.js → pieDiagram-E7YTZNPT-CHxeRYAb.js} +1 -1
  83. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-CEMfGgSc.js → quadrantDiagram-AXDQQJYC-B5EZIUvT.js} +1 -1
  84. package/dist-ksadk/assets/radar-RG4KPBEZ-D2dsze9F.js +1 -0
  85. package/dist-ksadk/assets/railroad-74A4TZTK-DBwQwqS4.js +1 -0
  86. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-DkPaTgaM.js +1 -0
  87. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CGj2E-SZ.js +1 -0
  88. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DGXLjDY5.js +1 -0
  89. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-DjL0Ielv.js → railroadDiagram-O6MQD6OU-D3sGYWAm.js} +1 -1
  90. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-Da11svpD.js → requirementDiagram-EFPCY7ZU-C-MRJ006.js} +1 -1
  91. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-DtKGEnlF.js → sankeyDiagram-P5KCCOFB-C5Qc8Tw5.js} +1 -1
  92. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-CR6Ct1Vm.js → sequenceDiagram-WJ2MYXX4-Cwt6RdFu.js} +1 -1
  93. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DaQE2An6.js → sizeCapture-X5ZJPWSS-DffXmYT6.js} +1 -1
  94. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-Ct2KGWos.js → stateDiagram-HBIQ2CUA-CsWi85pm.js} +1 -1
  95. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-DP_nPml6.js +1 -0
  96. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-BpIOaZ-N.js → swimlanes-XN3QIQJK-BFT0NQ46.js} +1 -1
  97. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DOvIyrQA.js +8 -0
  98. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-CdwbtpKP.js → timeline-definition-24CTP7MA-DXYCmjmW.js} +1 -1
  99. package/dist-ksadk/assets/treeView-Q6P3EWNA-Drao7JLN.js +1 -0
  100. package/dist-ksadk/assets/treemap-WGGIJYW6-CdCZ9GK9.js +1 -0
  101. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-Dr_5LEwY.js → vennDiagram-4TSXK5OY-D7CAii6e.js} +1 -1
  102. package/dist-ksadk/assets/wardley-WFR3VGLG-BaPyAVbq.js +1 -0
  103. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DYojPjE8.js → wardleyDiagram-VM6X3IG4-cQzt4L9O.js} +1 -1
  104. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-DV3dpSiv.js → xychartDiagram-S5SC5T6Z-DazvdMTB.js} +1 -1
  105. package/dist-ksadk/index.html +2 -2
  106. package/dist-lib/App.d.ts.map +1 -1
  107. package/dist-lib/{AttachmentPreview-COS-HmHj.js → AttachmentPreview-DPxeFYm-.js} +2 -2
  108. package/dist-lib/{ConnectedComposer-CB_YmxRQ.js → ConnectedComposer-CVMfDdns.js} +3 -3
  109. package/dist-lib/{ConnectedMessageList-CJgvv-Hi.js → ConnectedMessageList-BnRqhlEn.js} +924 -611
  110. package/dist-lib/{WorkspacePanelContainer-DU6mKsi5.js → WorkspacePanelContainer-3h8wgDJj.js} +2 -2
  111. package/dist-lib/{a2ui-e0gsVo7e.js → a2ui-DmynyrCk.js} +1 -1
  112. package/dist-lib/api/client.d.ts +1 -0
  113. package/dist-lib/api/client.d.ts.map +1 -1
  114. package/dist-lib/api/messages.d.ts +2 -0
  115. package/dist-lib/api/messages.d.ts.map +1 -1
  116. package/dist-lib/chat-composer.js +2 -2
  117. package/dist-lib/chat-timeline.js +3 -3
  118. package/dist-lib/components/chat/ChatMessageList.d.ts +5 -1
  119. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  120. package/dist-lib/components/chat/ConnectedMessageList.d.ts +2 -1
  121. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  122. package/dist-lib/components/chat/HistoryAnchoredRows.d.ts +44 -0
  123. package/dist-lib/components/chat/HistoryAnchoredRows.d.ts.map +1 -0
  124. package/dist-lib/components/chat/history-reading-anchor.d.ts +16 -0
  125. package/dist-lib/components/chat/history-reading-anchor.d.ts.map +1 -0
  126. package/dist-lib/components/chat/types.d.ts +1 -0
  127. package/dist-lib/components/chat/types.d.ts.map +1 -1
  128. package/dist-lib/components.js +5 -5
  129. package/dist-lib/conversation.js +1 -1
  130. package/dist-lib/core/api/facade.d.ts +3 -3
  131. package/dist-lib/core/api/facade.d.ts.map +1 -1
  132. package/dist-lib/core/api/types.d.ts +3 -0
  133. package/dist-lib/core/api/types.d.ts.map +1 -1
  134. package/dist-lib/core/conversation/hosted.d.ts +1 -1
  135. package/dist-lib/core/conversation/hosted.d.ts.map +1 -1
  136. package/dist-lib/core/run/agui.d.ts +3 -2
  137. package/dist-lib/core/run/agui.d.ts.map +1 -1
  138. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  139. package/dist-lib/core/run/engine.d.ts +1 -0
  140. package/dist-lib/core/run/engine.d.ts.map +1 -1
  141. package/dist-lib/core/run/types.d.ts +4 -0
  142. package/dist-lib/core/run/types.d.ts.map +1 -1
  143. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  144. package/dist-lib/hooks/useRunAgent.d.ts +2 -1
  145. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  146. package/dist-lib/hooks/useSessionLifecycle.d.ts +3 -1
  147. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  148. package/dist-lib/hooks.js +42 -41
  149. package/dist-lib/{permission-B9NRAmxP.js → permission-B60mkAsy.js} +1 -1
  150. package/dist-lib/{persisted-session-history-C8S6Tl-E.js → persisted-session-history-B9O1vWtS.js} +212 -203
  151. package/dist-lib/runtime.js +112 -110
  152. package/dist-lib/{session-events-BMRjrPq2.js → session-events-COiszsgX.js} +1 -0
  153. package/dist-lib/{feedback-nyK8zFEK.js → session-message-history-DC89pksC.js} +10 -2
  154. package/dist-lib/styles.css +1 -1
  155. package/dist-lib/{useSessionLifecycle-DPwSsODU.js → useSessionLifecycle-DeX2s_iU.js} +1377 -1115
  156. package/dist-lib/utils/message-virtualization.d.ts +24 -2
  157. package/dist-lib/utils/message-virtualization.d.ts.map +1 -1
  158. package/dist-lib/utils/session-event-history.d.ts +1 -1
  159. package/dist-lib/utils/session-event-history.d.ts.map +1 -1
  160. package/dist-lib/utils/session-events.d.ts.map +1 -1
  161. package/dist-lib/utils/session-items.d.ts.map +1 -1
  162. package/dist-lib/utils/session-message-history.d.ts +2 -0
  163. package/dist-lib/utils/session-message-history.d.ts.map +1 -1
  164. package/dist-lib/utils/transcript-order.d.ts +1 -1
  165. package/dist-lib/utils/transcript-order.d.ts.map +1 -1
  166. package/package.json +1 -1
  167. package/dist-ksadk/assets/architecture-7GRP2DOG-BgT_ltgS.js +0 -1
  168. package/dist-ksadk/assets/channel-CO8jKUdU.js +0 -1
  169. package/dist-ksadk/assets/chunk-2Q5K7J3B-BQ7ktM_H.js +0 -1
  170. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-HRhUD6oW.js +0 -1
  171. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-HRhUD6oW.js +0 -1
  172. package/dist-ksadk/assets/cynefin-OW5HDTMX-DlLbgFtT.js +0 -1
  173. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BgSxiUqa.js +0 -1
  174. package/dist-ksadk/assets/flowDiagram-A5DVABFB-Dcg0DKL0.js +0 -1
  175. package/dist-ksadk/assets/gitGraph-4MIJSDKK-DiYbIL_1.js +0 -1
  176. package/dist-ksadk/assets/index-CK5of5EC.js +0 -1135
  177. package/dist-ksadk/assets/index-ofLgkIsP.css +0 -2
  178. package/dist-ksadk/assets/info-A6RAGUB7-CIUhUhPM.js +0 -1
  179. package/dist-ksadk/assets/packet-AYTQ26CC-CVt8vTzN.js +0 -1
  180. package/dist-ksadk/assets/pie-WAS4IAKB-BmY8d_KC.js +0 -1
  181. package/dist-ksadk/assets/radar-RG4KPBEZ-D-vxRTHO.js +0 -1
  182. package/dist-ksadk/assets/railroad-74A4TZTK-hDbxS9Gl.js +0 -1
  183. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-6j4dsPir.js +0 -1
  184. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-f3r0amOv.js +0 -1
  185. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DpGM5wUK.js +0 -1
  186. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-IHXiAplS.js +0 -1
  187. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-ByC69bCd.js +0 -8
  188. package/dist-ksadk/assets/treeView-Q6P3EWNA-Bm72pNZV.js +0 -1
  189. package/dist-ksadk/assets/treemap-WGGIJYW6-Dpgkdt4o.js +0 -1
  190. package/dist-ksadk/assets/wardley-WFR3VGLG-C9w6FZRL.js +0 -1
@@ -1,4 +1,4 @@
1
- import { S as e, b as t, f as n, n as r, r as i } from "./session-events-BMRjrPq2.js";
1
+ import { S as e, b as t, f as n, n as r, r as i } from "./session-events-COiszsgX.js";
2
2
  import { d as a, i as o, l as s, o as c, p as l, t as u, u as d } from "./reducer-mbYiX0wz.js";
3
3
  //#region src/core/conversation/safe-tool-value.ts
4
4
  var f = [
@@ -322,7 +322,7 @@ function D(e, t) {
322
322
  let n = e.filter((e) => ee(e, t));
323
323
  return n.length === 1 ? n[0] : void 0;
324
324
  }
325
- function te(e) {
325
+ function O(e) {
326
326
  if (!e.some((e) => e.aguiActivity || e.aguiActivities?.length)) return e;
327
327
  let t = /* @__PURE__ */ new Map(), n = !1, r = e.map((e) => {
328
328
  let r = (r) => {
@@ -357,7 +357,7 @@ function te(e) {
357
357
  }
358
358
  //#endregion
359
359
  //#region src/core/conversation/presentation.ts
360
- var ne = {
360
+ var te = {
361
361
  user_message: "conversation.item.user_message/v1",
362
362
  assistant_text: "conversation.item.assistant_text/v1",
363
363
  reasoning: "conversation.item.reasoning/v1",
@@ -368,10 +368,10 @@ var ne = {
368
368
  a2ui: "conversation.item.a2ui/v1",
369
369
  error: "conversation.item.error/v1"
370
370
  };
371
- function re(e) {
371
+ function ne(e) {
372
372
  return e.lifecycle === "completed" || e.lifecycle === "failed";
373
373
  }
374
- var ie = new Set([
374
+ var re = new Set([
375
375
  "aborted",
376
376
  "canceled",
377
377
  "cancelled",
@@ -379,17 +379,17 @@ var ie = new Set([
379
379
  "incomplete",
380
380
  "interrupted"
381
381
  ]);
382
- function O(e) {
383
- if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !re(e)) return;
382
+ function k(e) {
383
+ if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !ne(e)) return;
384
384
  let t = typeof e.payload.status == "string" ? e.payload.status.toLowerCase() : "";
385
385
  if (t === "completed") return "completed";
386
- if (ie.has(t)) return "failed";
386
+ if (re.has(t)) return "failed";
387
387
  }
388
- function ae(e) {
389
- let t = ne[e.kind];
388
+ function ie(e) {
389
+ let t = te[e.kind];
390
390
  return t === void 0 || t === e.payloadSchemaRef;
391
391
  }
392
- function oe(e) {
392
+ function ae(e) {
393
393
  if (typeof e != "string" || e.length === 0) return null;
394
394
  try {
395
395
  let t = new URL(e);
@@ -398,7 +398,7 @@ function oe(e) {
398
398
  return null;
399
399
  }
400
400
  }
401
- function se(e) {
401
+ function oe(e) {
402
402
  return {
403
403
  id: e.itemId,
404
404
  parentId: e.parentItemId || null,
@@ -408,8 +408,8 @@ function se(e) {
408
408
  lifecycle: e.lifecycle
409
409
  };
410
410
  }
411
- function ce(e) {
412
- 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 = oe(e.payload.uri);
411
+ function se(e) {
412
+ 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 = ae(e.payload.uri);
413
413
  return {
414
414
  artifactId: t,
415
415
  itemId: e.itemId,
@@ -423,13 +423,13 @@ function ce(e) {
423
423
  uri: i
424
424
  };
425
425
  }
426
- function k(e, t) {
426
+ function A(e, t) {
427
427
  let n = e.payload[t];
428
428
  return typeof n == "string" && n ? n : null;
429
429
  }
430
- function A(e, t) {
430
+ function j(e, t) {
431
431
  if (e.kind === "tool_call") {
432
- let n = k(e, "callId");
432
+ let n = A(e, "callId");
433
433
  if (n) return `tool:${JSON.stringify([
434
434
  e.runId,
435
435
  t ?? (e.nativeRef.scopeId || e.nativeRef.scope_id || ""),
@@ -437,17 +437,17 @@ function A(e, t) {
437
437
  ])}`;
438
438
  }
439
439
  if (e.kind === "approval") {
440
- let t = k(e, "interactionId");
440
+ let t = A(e, "interactionId");
441
441
  if (t) return `approval:${t}`;
442
442
  }
443
443
  if (e.kind === "a2ui") {
444
- let t = k(e, "surfaceId");
444
+ let t = A(e, "surfaceId");
445
445
  if (t) return `a2ui:${JSON.stringify([e.runId, t])}`;
446
446
  }
447
447
  return `item:${e.itemId}`;
448
448
  }
449
- function le(e, t) {
450
- let n = re(e) && !re(t), r = e.kind === "a2ui" && t.kind === "a2ui" && Array.isArray(e.payload.data) && Array.isArray(t.payload.data) ? { data: T(e.payload.data, t.payload.data) } : {};
449
+ function ce(e, t) {
450
+ let n = ne(e) && !ne(t), r = e.kind === "a2ui" && t.kind === "a2ui" && Array.isArray(e.payload.data) && Array.isArray(t.payload.data) ? { data: T(e.payload.data, t.payload.data) } : {};
451
451
  return {
452
452
  ...e,
453
453
  ...t,
@@ -473,25 +473,25 @@ function le(e, t) {
473
473
  } : {}
474
474
  };
475
475
  }
476
- function ue(e) {
476
+ function le(e) {
477
477
  let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), s = (e) => {
478
478
  let t = e.nativeRef.parentScopeId;
479
- return e.nativeRef.framework === "langgraph" && e.kind === "tool_call" && e.payload.sourceKind === "tool_result" && e.payload.callId && typeof t == "string" ? A(e, t) : void 0;
479
+ return e.nativeRef.framework === "langgraph" && e.kind === "tool_call" && e.payload.sourceKind === "tool_result" && e.payload.callId && typeof t == "string" ? j(e, t) : void 0;
480
480
  };
481
481
  for (let t of e) {
482
482
  if (t.nativeRef.framework === "langgraph" && t.payload.sourceKind === "tool_call") {
483
- let e = A(t);
483
+ let e = j(t);
484
484
  i.set(e, (i.get(e) ?? 0) + 1);
485
485
  }
486
- t.kind === "tool_call" && t.payload.sourceKind === "tool_result" && a.add(A(t));
486
+ t.kind === "tool_call" && t.payload.sourceKind === "tool_result" && a.add(j(t));
487
487
  let e = s(t);
488
488
  e && o.set(e, (o.get(e) ?? 0) + 1);
489
489
  }
490
490
  for (let c of e) {
491
- let e = A(c), l = s(c), u = l && !i.has(e) && !a.has(l) && i.get(l) === 1 && o.get(l) === 1 ? l : e, d = c.kind === "a2ui" ? {
492
- surfaceId: k(c, "surfaceId") || "",
491
+ let e = j(c), l = s(c), u = l && !i.has(e) && !a.has(l) && i.get(l) === 1 && o.get(l) === 1 ? l : e, d = c.kind === "a2ui" ? {
492
+ surfaceId: A(c, "surfaceId") || "",
493
493
  messages: [],
494
- ...k(c, "interactionId") ? { interactionId: k(c, "interactionId") } : {}
494
+ ...A(c, "interactionId") ? { interactionId: A(c, "interactionId") } : {}
495
495
  } : null, f = d ? {
496
496
  message: {
497
497
  id: c.itemId,
@@ -514,7 +514,7 @@ function ue(e) {
514
514
  let g = t[h];
515
515
  t[h] = {
516
516
  key: g.key,
517
- item: le(g.item, c),
517
+ item: ce(g.item, c),
518
518
  sourceItemIds: [...new Set([...g.sourceItemIds, c.itemId])]
519
519
  };
520
520
  }
@@ -529,29 +529,29 @@ function ue(e) {
529
529
  }
530
530
  } : t);
531
531
  }
532
- function de(e, t) {
532
+ function ue(e, t) {
533
533
  let n = e.payload.trigger_ref;
534
534
  return n ? t.filter((t) => t.kind === "tool_call" && t.runId === e.runId && (t.nativeRef.scopeId || t.nativeRef.scope_id) === n.scope_id && (t.payload.callId === n.call_id || t.itemId === e.parentItemId)) : [];
535
535
  }
536
- function fe(e) {
537
- let t = e.filter((e) => e.kind === "agent"), n = (e) => String(e.nativeRef.scopeId || e.nativeRef.scope_id || ""), r = (e) => t.find((t) => t.runId === e.runId && t.itemId !== e.itemId && (e.parentItemId === t.itemId || (e.kind === "agent" ? e.payload.parent_scope_id === t.payload.scope_id : n(e) && n(e) === String(t.payload.scope_id)))), i = new Set(t.flatMap((t) => de(t, e).map((e) => e.itemId))), a = e.filter((e) => !r(e) && !i.has(e.itemId));
536
+ function de(e) {
537
+ let t = e.filter((e) => e.kind === "agent"), n = (e) => String(e.nativeRef.scopeId || e.nativeRef.scope_id || ""), r = (e) => t.find((t) => t.runId === e.runId && t.itemId !== e.itemId && (e.parentItemId === t.itemId || (e.kind === "agent" ? e.payload.parent_scope_id === t.payload.scope_id : n(e) && n(e) === String(t.payload.scope_id)))), i = new Set(t.flatMap((t) => ue(t, e).map((e) => e.itemId))), a = e.filter((e) => !r(e) && !i.has(e.itemId));
538
538
  return a.sort((t, n) => {
539
539
  let r = (t) => t.kind === "agent" && t.parentItemId && e.some((e) => e.itemId === t.parentItemId) ? e.findIndex((e) => e.itemId === t.parentItemId) : e.indexOf(t);
540
540
  return r(t) - r(n);
541
- }), ue(a).map((t) => {
541
+ }), le(a).map((t) => {
542
542
  if (t.item.kind !== "agent") return t;
543
- let n = ue(e.filter((e) => r(e) === t.item && !i.has(e.itemId)));
543
+ let n = le(e.filter((e) => r(e) === t.item && !i.has(e.itemId)));
544
544
  return {
545
545
  ...t,
546
- sourceItemIds: [...new Set([...de(t.item, e).map((e) => e.itemId), ...t.sourceItemIds])],
546
+ sourceItemIds: [...new Set([...ue(t.item, e).map((e) => e.itemId), ...t.sourceItemIds])],
547
547
  children: n
548
548
  };
549
549
  });
550
550
  }
551
- function j(e, t = {}) {
551
+ function fe(e, t = {}) {
552
552
  let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal");
553
553
  if (t.profile === "flat-v1" && n.some((e) => e.kind === "agent")) {
554
- let e = n.filter((e) => e.kind === "agent"), t = new Set(e.flatMap((e) => de(e, n).map((e) => e.itemId))), r = (t) => e.some((e) => e.runId === t.runId && (t.parentItemId === e.itemId || typeof e.payload.scope_id == "string" && e.payload.scope_id.length > 0 && e.payload.scope_id === (t.nativeRef.scopeId || t.nativeRef.scope_id))), i = n.find((e) => O(e)), a = n.filter((e) => e.kind !== "agent" && (e.kind === "error" || !r(e) && !t.has(e.itemId))), o = i?.payload.outputRefs || i?.payload.output_refs;
554
+ let e = n.filter((e) => e.kind === "agent"), t = new Set(e.flatMap((e) => ue(e, n).map((e) => e.itemId))), r = (t) => e.some((e) => e.runId === t.runId && (t.parentItemId === e.itemId || typeof e.payload.scope_id == "string" && e.payload.scope_id.length > 0 && e.payload.scope_id === (t.nativeRef.scopeId || t.nativeRef.scope_id))), i = n.find((e) => k(e)), a = n.filter((e) => e.kind !== "agent" && (e.kind === "error" || !r(e) && !t.has(e.itemId))), o = i?.payload.outputRefs || i?.payload.output_refs;
555
555
  Array.isArray(o) && o.length && (a = a.filter((e) => e.kind !== "assistant_text" || o.some((t) => e.nativeRef.scopeId === t.scope_id && e.nativeRef.runtimeItemId === t.item_id)));
556
556
  let s = a.filter((e) => e.kind === "assistant_text");
557
557
  if (i && !s.some((e) => e.payload.text) && Array.isArray(o)) {
@@ -567,13 +567,13 @@ function j(e, t = {}) {
567
567
  }
568
568
  n = a.filter((e) => e.kind !== "assistant_text" || !!i);
569
569
  }
570
- let r = n.filter(ae), i = n.filter((e) => !ae(e)), a = new Set([
570
+ let r = n.filter(ie), i = n.filter((e) => !ie(e)), a = new Set([
571
571
  "user_message",
572
572
  "assistant_text",
573
573
  "reasoning"
574
- ]), o = r.filter((e) => a.has(e.kind)).map(se), s = (e) => e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || r.some((t) => t.kind === "agent" && (e.parentItemId === t.itemId || t.runId === e.runId && t.payload.scope_id === (e.nativeRef.scopeId || e.nativeRef.scope_id))), c = (e) => r.filter((t) => t.kind === e && !s(t)).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), l = [...r.filter((e) => e.kind === "unknown"), ...i], u = r.filter((e) => e.kind === "error"), d = [...r].reverse().find((e) => O(e) !== void 0);
574
+ ]), o = r.filter((e) => a.has(e.kind)).map(oe), s = (e) => e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || r.some((t) => t.kind === "agent" && (e.parentItemId === t.itemId || t.runId === e.runId && t.payload.scope_id === (e.nativeRef.scopeId || e.nativeRef.scope_id))), c = (e) => r.filter((t) => t.kind === e && !s(t)).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), l = [...r.filter((e) => e.kind === "unknown"), ...i], u = r.filter((e) => e.kind === "error"), d = [...r].reverse().find((e) => k(e) !== void 0);
575
575
  return {
576
- timeline: fe(r.filter((e) => e.kind !== "progress")),
576
+ timeline: de(r.filter((e) => e.kind !== "progress")),
577
577
  output: c("assistant_text"),
578
578
  reasoning: c("reasoning"),
579
579
  textItems: o,
@@ -581,7 +581,7 @@ function j(e, t = {}) {
581
581
  approvalItems: r.filter((e) => e.kind === "approval"),
582
582
  structuredInputItems: r.filter((e) => e.kind === "progress" && e.payloadSchemaRef === "conversation.item.structured-input/v1"),
583
583
  a2uiItems: r.filter((e) => e.kind === "a2ui"),
584
- artifacts: r.filter((e) => e.kind === "artifact").map(ce),
584
+ artifacts: r.filter((e) => e.kind === "artifact").map(se),
585
585
  fallbacks: [...l.map((e) => ({
586
586
  id: e.itemId,
587
587
  title: "Unsupported content",
@@ -594,7 +594,7 @@ function j(e, t = {}) {
594
594
  failed: !0
595
595
  }))],
596
596
  runId: n.at(-1)?.runId || "",
597
- terminalStatus: d ? O(d) : void 0
597
+ terminalStatus: d ? k(d) : void 0
598
598
  };
599
599
  }
600
600
  //#endregion
@@ -641,16 +641,16 @@ async function _e(e, t, n) {
641
641
  });
642
642
  });
643
643
  }
644
- function F(e, t, n, r, i) {
644
+ function ve(e, t, n, r, i) {
645
645
  let a = i ? i.snapshot() : e.snapshot();
646
646
  return {
647
647
  cursor: t,
648
648
  runId: n,
649
649
  state: a,
650
- presentation: j(a, { profile: r })
650
+ presentation: fe(a, { profile: r })
651
651
  };
652
652
  }
653
- function ve(e, t) {
653
+ function ye(e, t) {
654
654
  let n, r = [];
655
655
  for (let t of e.split(/\r?\n/)) {
656
656
  let e = t.endsWith("\r") ? t.slice(0, -1) : t;
@@ -703,9 +703,9 @@ function ve(e, t) {
703
703
  } catch (e) {
704
704
  throw new l("conversation_contract_mismatch", "Conversation identity or lifecycle invariant failed.", { cause: e });
705
705
  }
706
- t.cursor = Math.max(t.cursor, n), f && !(t.profile === "flat-v1" && d.nativeRef.parentScopeId) && t.options.onItem?.(d), t.options.onUpdate?.(F(t.reducer, t.cursor, t.runId, t.profile, t.lane === "runtime" ? t.runtime : void 0));
706
+ t.cursor = Math.max(t.cursor, n), f && !(t.profile === "flat-v1" && d.nativeRef.parentScopeId) && t.options.onItem?.(d), t.options.onUpdate?.(ve(t.reducer, t.cursor, t.runId, t.profile, t.lane === "runtime" ? t.runtime : void 0));
707
707
  }
708
- async function ye(e, t) {
708
+ async function be(e, t) {
709
709
  if (!e.body) throw new l("conversation_stream_error", "Conversation response has no event stream body.");
710
710
  let n = e.body.getReader(), r = new TextDecoder(), i = "";
711
711
  try {
@@ -717,10 +717,10 @@ async function ye(e, t) {
717
717
  let o = /\r?\n\r?\n/.exec(i);
718
718
  for (; o?.index !== void 0;) {
719
719
  let e = o.index, n = o[0].length;
720
- ve(i.slice(0, e), t), i = i.slice(e + n), o = /\r?\n\r?\n/.exec(i);
720
+ ye(i.slice(0, e), t), i = i.slice(e + n), o = /\r?\n\r?\n/.exec(i);
721
721
  }
722
722
  }
723
- i += r.decode(), i.trim() && ve(i, t);
723
+ i += r.decode(), i.trim() && ye(i, t);
724
724
  } catch (e) {
725
725
  throw e instanceof l ? e : (pe(e, t.options.signal) && P(t.options.signal), new l("conversation_stream_error", "Conversation event stream was interrupted.", {
726
726
  cause: e,
@@ -731,10 +731,10 @@ async function ye(e, t) {
731
731
  n.releaseLock();
732
732
  }
733
733
  }
734
- function be(e) {
735
- return e.state.items.some((e) => O(e) !== void 0);
734
+ function xe(e) {
735
+ return e.state.items.some((e) => k(e) !== void 0);
736
736
  }
737
- var xe = class {
737
+ var Se = class {
738
738
  fetcher;
739
739
  ingressLane;
740
740
  rendererCatalog;
@@ -813,12 +813,12 @@ var xe = class {
813
813
  }, p = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), f, e.signal);
814
814
  this.assertOk(p);
815
815
  try {
816
- await ye(p, d);
816
+ await be(p, d);
817
817
  } catch (e) {
818
818
  if (!(e instanceof l) || e.code !== "conversation_stream_error" || !d.runId) throw e;
819
819
  }
820
- let m = F(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0);
821
- if (be(m)) return m;
820
+ let m = ve(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0);
821
+ if (xe(m)) return m;
822
822
  if (!d.runId) throw new l("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: d.cursor });
823
823
  for (let t = 1; t <= this.maxReconnects; t += 1) {
824
824
  await _e(this.sleep, this.retryDelayMs(t), e.signal), P(e.signal);
@@ -828,12 +828,12 @@ var xe = class {
828
828
  method: "GET",
829
829
  headers: { "Last-Event-ID": String(d.cursor) },
830
830
  ...e.signal ? { signal: e.signal } : {}
831
- }, e.signal), this.assertOk(n), await ye(n, d);
831
+ }, e.signal), this.assertOk(n), await be(n, d);
832
832
  } catch (e) {
833
833
  if (e instanceof l && e.code === "conversation_aborted" || e instanceof l && e.code === "conversation_contract_mismatch" || e instanceof l && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
834
834
  continue;
835
835
  }
836
- if (m = F(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0), be(m)) return m;
836
+ if (m = ve(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0), xe(m)) return m;
837
837
  }
838
838
  throw new l("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
839
839
  runId: d.runId,
@@ -843,13 +843,13 @@ var xe = class {
843
843
  };
844
844
  //#endregion
845
845
  //#region src/core/conversation/renderer-registry.ts
846
- function Se(e, t) {
846
+ function Ce(e, t) {
847
847
  if (!e.trim()) throw Error(`trusted conversation renderer ${t} must not be empty`);
848
848
  }
849
- function Ce(e) {
849
+ function we(e) {
850
850
  let t = /* @__PURE__ */ new Map();
851
851
  for (let n of e) {
852
- if (Se(n.id, "id"), Se(n.schemaRef, "schemaRef"), !n.kinds.length) throw Error("trusted conversation renderer kinds must not be empty");
852
+ if (Ce(n.id, "id"), Ce(n.schemaRef, "schemaRef"), !n.kinds.length) throw Error("trusted conversation renderer kinds must not be empty");
853
853
  if (t.has(n.schemaRef)) throw Error(`duplicate trusted conversation renderer schemaRef: ${n.schemaRef}`);
854
854
  t.set(n.schemaRef, Object.freeze({
855
855
  ...n,
@@ -867,14 +867,14 @@ function Ce(e) {
867
867
  }
868
868
  });
869
869
  }
870
- var we = Ce([{
870
+ var Te = we([{
871
871
  id: "ksadk.agent-block",
872
872
  schemaRef: "conversation.item.agent/v1",
873
873
  kinds: ["agent"]
874
874
  }]);
875
875
  //#endregion
876
876
  //#region src/utils/history-tool-facts.ts
877
- function I(e, t) {
877
+ function F(e, t) {
878
878
  let n = (e) => e === "completed" || e === "error", r = t.output === void 0 ? e.output : t.output;
879
879
  return {
880
880
  args: t.args || e.args,
@@ -882,7 +882,7 @@ function I(e, t) {
882
882
  status: n(e.status) && !n(t.status) ? e.status : t.status
883
883
  };
884
884
  }
885
- function L(e) {
885
+ function I(e) {
886
886
  let t = e.map((e) => ({
887
887
  ...e,
888
888
  tools: e.tools ? { ...e.tools } : void 0
@@ -907,11 +907,11 @@ function L(e) {
907
907
  let r = e.message.tools[e.key], i = n ? {
908
908
  ...t,
909
909
  ...r,
910
- ...I(t, r)
910
+ ...F(t, r)
911
911
  } : {
912
912
  ...r,
913
913
  ...t,
914
- ...I(r, t)
914
+ ...F(r, t)
915
915
  };
916
916
  t.deferredOutput && (i.status = t.status), i.name === "tool" && (i.name = r.name === "tool" ? t.name : r.name), e.message.tools[e.key] = i, e.message.blocks = e.message.blocks?.map((e) => e.type === "tool" && e.extra?.callId === t.callId ? {
917
917
  ...e,
@@ -955,12 +955,12 @@ function L(e) {
955
955
  }
956
956
  //#endregion
957
957
  //#region src/utils/transcript-order.ts
958
- var R = (e) => e.runId || e.invocationId;
959
- function Te(e, t) {
958
+ var L = (e) => e.runId || e.invocationId, R = (e) => e.role === "user" && e.eventType === "optimistic_user_message";
959
+ function Ee(e, t) {
960
960
  if (!t) return e;
961
- let n = R(t);
962
- if (!n || e.some((e) => e.role === "user" && R(e) === n)) return e;
963
- let r = e.findIndex((e) => R(e) === n);
961
+ let n = L(t);
962
+ if (!n || e.some((e) => e.role === "user" && L(e) === n)) return e;
963
+ let r = e.findIndex((e) => L(e) === n);
964
964
  return r < 0 ? e : [
965
965
  ...e.slice(0, r),
966
966
  t,
@@ -970,14 +970,14 @@ function Te(e, t) {
970
970
  function z(e) {
971
971
  let t = /* @__PURE__ */ new Map();
972
972
  for (let n of e) {
973
- let e = R(n), r = n.historyOrder?.group;
973
+ let e = L(n), r = n.historyOrder?.group;
974
974
  e && r !== void 0 && t.set(e, Math.min(r, t.get(e) ?? r));
975
975
  }
976
976
  let n = e.map((e, n) => ({
977
977
  message: e,
978
978
  index: n,
979
979
  seq: e.historyOrder?.seq,
980
- group: e.historyOrder?.group ?? t.get(R(e) || "") ?? e.historyOrder?.seq,
980
+ group: e.historyOrder?.group ?? t.get(L(e) || "") ?? e.historyOrder?.seq,
981
981
  part: e.historyOrder?.index || 0
982
982
  })), r, i = n.map(() => void 0);
983
983
  for (let e = n.length - 1; e >= 0; e--) i[e] = r, n[e].group !== void 0 && (r = n[e].group);
@@ -992,54 +992,63 @@ function z(e) {
992
992
  side: 0
993
993
  })).sort((e, t) => e.anchor - t.anchor || e.side - t.side || (e.side === 0 ? (e.seq ?? e.anchor) - (t.seq ?? t.anchor) : 0) || (e.side === 0 ? e.part - t.part : 0) || e.index - t.index).map((e) => e.message);
994
994
  }
995
- function Ee(e, t) {
995
+ function De(e, t) {
996
996
  if (!t) return !0;
997
997
  let n = (n) => n === "feedback" ? !1 : n === "historyOrder" ? e.historyOrder?.seq !== t.historyOrder?.seq || e.historyOrder?.index !== t.historyOrder?.index || e.historyOrder?.group !== t.historyOrder?.group : e[n] !== t[n];
998
998
  return Object.keys(e).some(n) || Object.keys(t).some(n);
999
999
  }
1000
- function De(e, t, n, r = !1) {
1001
- let i = new Map(t.map((e) => [e.id, e])), a = n.filter((e) => i.has(e.id) && i.get(e.id)?.feedback !== e.feedback), o = new Map(a.map((e) => [e.id, e.feedback])), s = (e) => JSON.stringify([R(e), e.responseId]), c = new Map(a.filter((e) => e.responseId).map((e) => [s(e), e.feedback])), l = (e) => e.map((e) => {
1002
- if (o.has(e.id)) return {
1000
+ function Oe(e, t, n, r = !1) {
1001
+ let i = e.filter((e) => e.role === "user" && !R(e)), a = new Set(i.map(L).filter(Boolean)), o = new Set(i.map((e) => e.commandId).filter(Boolean)), s = n.filter((e) => !R(e) || !a.has(L(e)) && !o.has(e.commandId)), c = s.filter((t) => R(t) && !e.some((e) => e.id === t.id));
1002
+ if (c.length) {
1003
+ e = [...e];
1004
+ for (let t of c) {
1005
+ let n = L(t), r = n ? e.findIndex((e) => L(e) === n) : -1;
1006
+ r < 0 ? e.push(t) : e.splice(r, 0, t);
1007
+ }
1008
+ e = z(e);
1009
+ }
1010
+ let l = new Map(t.map((e) => [e.id, e])), u = s.filter((e) => l.has(e.id) && l.get(e.id)?.feedback !== e.feedback), d = new Map(u.map((e) => [e.id, e.feedback])), f = (e) => JSON.stringify([L(e), e.responseId]), p = new Map(u.filter((e) => e.responseId).map((e) => [f(e), e.feedback])), m = (e) => e.map((e) => {
1011
+ if (d.has(e.id)) return {
1003
1012
  ...e,
1004
- feedback: o.get(e.id)
1013
+ feedback: d.get(e.id)
1005
1014
  };
1006
- let t = s(e);
1007
- return e.responseId && c.has(t) ? {
1015
+ let t = f(e);
1016
+ return e.responseId && p.has(t) ? {
1008
1017
  ...e,
1009
- feedback: c.get(t)
1018
+ feedback: p.get(t)
1010
1019
  } : e;
1011
- }), u = n.filter((e) => Ee(e, i.get(e.id)));
1012
- if (!u.length) return te(L(l(e)));
1013
- let d = new Set(u.map(R).filter(Boolean)), f = new Set(u.map((e) => e.id)), p = n.filter((e) => d.has(R(e)) || f.has(e.id)), m = e;
1014
- for (let t of d) {
1015
- let n = p.filter((e) => R(e) === t), a = e.filter((e) => R(e) === t), o = m.findIndex((e) => R(e) === t), s = new Set(n.map((e) => e.id)), c = r ? a.filter((e) => !s.has(e.id) && !i.has(e.id)) : n.some((e) => e.role === "user") ? [] : a.filter((e) => e.role === "user");
1016
- m = m.filter((e) => R(e) !== t);
1017
- let l = o < 0 ? m.length : Math.min(o, m.length);
1018
- m.splice(l, 0, ...c, ...n.map((e) => ({
1020
+ }), h = s.filter((e) => De(e, l.get(e.id)));
1021
+ if (!h.length) return O(I(m(e)));
1022
+ let g = new Set(h.map(L).filter(Boolean)), _ = new Set(h.map((e) => e.id)), v = s.filter((e) => g.has(L(e)) || _.has(e.id)), y = e;
1023
+ for (let t of g) {
1024
+ let n = v.filter((e) => L(e) === t), i = e.filter((e) => L(e) === t), a = y.findIndex((e) => L(e) === t), o = new Set(n.map((e) => e.id)), s = r ? i.filter((e) => !o.has(e.id) && !l.has(e.id)) : n.some((e) => e.role === "user") ? [] : i.filter((e) => e.role === "user");
1025
+ y = y.filter((e) => L(e) !== t);
1026
+ let c = a < 0 ? y.length : Math.min(a, y.length);
1027
+ y.splice(c, 0, ...s, ...n.map((e) => ({
1019
1028
  ...e,
1020
- historyOrder: e.historyOrder || a.find((t) => t.id === e.id)?.historyOrder
1029
+ historyOrder: e.historyOrder || i.find((t) => t.id === e.id)?.historyOrder
1021
1030
  })));
1022
1031
  }
1023
- for (let e of p.filter((e) => !R(e))) {
1024
- let t = m.findIndex((t) => t.id === e.id);
1032
+ for (let e of v.filter((e) => !L(e))) {
1033
+ let t = y.findIndex((t) => t.id === e.id);
1025
1034
  if (t < 0) {
1026
- let t = n.indexOf(e), r = n.slice(t + 1).find((e) => m.some((t) => t.id === e.id)), i = n.slice(0, t).findLast((e) => m.some((t) => t.id === e.id)), a = r ? m.findIndex((e) => e.id === r.id) : i ? m.findIndex((e) => e.id === i.id) + 1 : m.length;
1027
- m = [
1028
- ...m.slice(0, a),
1035
+ let t = s.indexOf(e), n = s.slice(t + 1).find((e) => y.some((t) => t.id === e.id)), r = s.slice(0, t).findLast((e) => y.some((t) => t.id === e.id)), i = n ? y.findIndex((e) => e.id === n.id) : r ? y.findIndex((e) => e.id === r.id) + 1 : y.length;
1036
+ y = [
1037
+ ...y.slice(0, i),
1029
1038
  e,
1030
- ...m.slice(a)
1039
+ ...y.slice(i)
1031
1040
  ];
1032
- } else m = m.map((n, r) => r === t ? {
1041
+ } else y = y.map((n, r) => r === t ? {
1033
1042
  ...e,
1034
1043
  historyOrder: e.historyOrder || n.historyOrder
1035
1044
  } : n);
1036
1045
  }
1037
- return te(L(l(z(m))));
1046
+ return O(I(m(z(y))));
1038
1047
  }
1039
1048
  //#endregion
1040
1049
  //#region src/core/conversation/hosted.ts
1041
- var Oe = "conversation_item_v1";
1042
- function ke(e) {
1050
+ var ke = "conversation_item_v1";
1051
+ function Ae(e) {
1043
1052
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
1044
1053
  }
1045
1054
  function B(e) {
@@ -1058,17 +1067,17 @@ function H(e) {
1058
1067
  return {
1059
1068
  id: `conversation:${e.runId}:${e.itemId}`,
1060
1069
  timestamp: 0,
1061
- eventType: Oe,
1070
+ eventType: ke,
1062
1071
  eventId: e.sourceEventIds.at(-1),
1063
1072
  runId: e.runId,
1064
1073
  itemId: e.itemId,
1065
1074
  status: e.lifecycle === "failed" ? "failed" : e.lifecycle === "completed" ? "completed" : "running"
1066
1075
  };
1067
1076
  }
1068
- function Ae(e) {
1077
+ function je(e) {
1069
1078
  return e.lifecycle === "failed" ? "error" : e.lifecycle === "completed" ? "done" : "streaming";
1070
1079
  }
1071
- function je(e) {
1080
+ function Me(e) {
1072
1081
  let t = typeof e.payload.text == "string" ? e.payload.text : "";
1073
1082
  if (e.kind === "user_message") return {
1074
1083
  ...H(e),
@@ -1080,13 +1089,13 @@ function je(e) {
1080
1089
  id: `conversation-block:${e.itemId}`,
1081
1090
  type: "thinking",
1082
1091
  content: t,
1083
- status: Ae(e),
1092
+ status: je(e),
1084
1093
  ...e.payload.presentationSource === "public_summary" || e.payload.presentationSource === "provider_reasoning" ? { source: e.payload.presentationSource } : {}
1085
1094
  } : {
1086
1095
  id: `conversation-block:${e.itemId}`,
1087
1096
  type: "text",
1088
1097
  content: t,
1089
- status: Ae(e)
1098
+ status: je(e)
1090
1099
  };
1091
1100
  return {
1092
1101
  ...H(e),
@@ -1096,7 +1105,7 @@ function je(e) {
1096
1105
  blocks: [n]
1097
1106
  };
1098
1107
  }
1099
- function Me(e, t = !1) {
1108
+ function Ne(e, t = !1) {
1100
1109
  let n = B(e.payload.tool) || (e.payload.sourceKind === "tool_result" ? "Tool result" : "Tool"), r = B(e.payload.callId), i = V(y(e.payload.args)), a = Object.prototype.hasOwnProperty.call(e.payload, "output") ? V(b(e.payload.output, e.nativeRef.framework, e.nativeRef.protocol)) : void 0, o = {
1101
1110
  failed: "error",
1102
1111
  completed: "completed",
@@ -1125,13 +1134,13 @@ function Me(e, t = !1) {
1125
1134
  } }
1126
1135
  };
1127
1136
  }
1128
- function Ne(e) {
1137
+ function Pe(e) {
1129
1138
  return e === "structured_input" ? "structured_input" : e === "plan_review" ? "plan_review" : e === "custom" ? "custom" : "approval";
1130
1139
  }
1131
- function Pe(e) {
1140
+ function Fe(e) {
1132
1141
  let n = B(e.payload.interactionId), r = e.payload.revision;
1133
1142
  if (!n || !Number.isInteger(r) || Number(r) < 1) return null;
1134
- let i = V(e.payload.detail), a = B(e.payload.prompt) || i, o = Ne(e.payload.interactionKind), s = e.lifecycle === "completed", c = {};
1143
+ let i = V(e.payload.detail), a = B(e.payload.prompt) || i, o = Pe(e.payload.interactionKind), s = e.lifecycle === "completed", c = {};
1135
1144
  if (s && Object.hasOwn(e.payload, "response")) try {
1136
1145
  c = { response: t(e.payload.response) };
1137
1146
  } catch {}
@@ -1142,7 +1151,7 @@ function Pe(e) {
1142
1151
  kind: o,
1143
1152
  title: B(e.payload.title) || (o === "approval" ? `审批:${B(e.payload.kind) || "操作"}` : "需要补充信息"),
1144
1153
  message: a || "运行需要人工确认。",
1145
- requestSchema: ke(e.payload.inputSchema),
1154
+ requestSchema: Ae(e.payload.inputSchema),
1146
1155
  presentation: null,
1147
1156
  status: s ? "resolved" : "pending",
1148
1157
  revision: Number(r),
@@ -1166,7 +1175,7 @@ function Pe(e) {
1166
1175
  }
1167
1176
  };
1168
1177
  }
1169
- function Fe(e, t) {
1178
+ function Ie(e, t) {
1170
1179
  let n = B(e.payload.kind) || "approval", r = V(e.payload.detail), i = t.status === "resolved" ? t.outcome === "rejected" ? "rejected" : t.outcome === "cancelled" || t.outcome === "expired" ? "cancelled" : "approved" : "pending", a = t.status === "pending" ? "paused" : "completed", o = {
1171
1180
  approvalRequestId: t.interactionId,
1172
1181
  approvalStatus: i,
@@ -1194,24 +1203,24 @@ function Fe(e, t) {
1194
1203
  } }
1195
1204
  };
1196
1205
  }
1197
- function Ie(e) {
1206
+ function Le(e) {
1198
1207
  for (let t of [
1199
1208
  "createSurface",
1200
1209
  "updateComponents",
1201
1210
  "updateDataModel",
1202
1211
  "deleteSurface"
1203
1212
  ]) {
1204
- let n = B(ke(e[t])?.surfaceId);
1213
+ let n = B(Ae(e[t])?.surfaceId);
1205
1214
  if (n) return n;
1206
1215
  }
1207
1216
  return null;
1208
1217
  }
1209
- function Le(e) {
1218
+ function Re(e) {
1210
1219
  let t = Array.isArray(e.payload.data) ? e.payload.data : Array.isArray(e.payload.operations) ? e.payload.operations : null;
1211
1220
  if (!t) return null;
1212
- let n = t.map(ke);
1221
+ let n = t.map(Ae);
1213
1222
  if (n.some((e) => e === null)) return null;
1214
- let r = n, i = B(e.payload.surfaceId) || r.map(Ie).find((e) => e !== null) || null;
1223
+ let r = n, i = B(e.payload.surfaceId) || r.map(Le).find((e) => e !== null) || null;
1215
1224
  return i ? {
1216
1225
  ...H(e),
1217
1226
  role: "a2ui",
@@ -1231,7 +1240,7 @@ function U(e, t, n, r = !1) {
1231
1240
  status: r ? "failed" : H(e).status
1232
1241
  };
1233
1242
  }
1234
- function Re(e) {
1243
+ function ze(e) {
1235
1244
  for (let { item: t } of [...e].reverse()) {
1236
1245
  if (t.visibility !== "public" || t.kind !== "assistant_text" || t.payloadSchemaRef !== "conversation.item.assistant_text/v1" || typeof t.payload.text != "string") continue;
1237
1246
  let e = y(t.payload.text);
@@ -1265,27 +1274,27 @@ function W(e) {
1265
1274
  agentBlock: {
1266
1275
  item: f,
1267
1276
  messages: n.messages,
1268
- summary: Re(d.children || [])
1277
+ summary: ze(d.children || [])
1269
1278
  },
1270
1279
  status: f.payload.status === "cancelled" ? "cancelled" : H(f).status
1271
1280
  }), u.push(...n.interactions);
1272
1281
  continue;
1273
1282
  }
1274
1283
  if (n.has(f.itemId)) {
1275
- l.push(je(f));
1284
+ l.push(Me(f));
1276
1285
  continue;
1277
1286
  }
1278
1287
  if (r.has(f.itemId)) {
1279
- l.push(Me(f, !!t.terminalStatus && f.runId === e.runId));
1288
+ l.push(Ne(f, !!t.terminalStatus && f.runId === e.runId));
1280
1289
  continue;
1281
1290
  }
1282
1291
  if (i.has(f.itemId) || a.has(f.itemId)) {
1283
- let e = Pe(f);
1284
- e ? (u.push(e), l.push(Fe(f, e))) : l.push(U(f, "Interaction unavailable", "The server did not provide a durable interaction revision; this card is read-only."));
1292
+ let e = Fe(f);
1293
+ e ? (u.push(e), l.push(Ie(f, e))) : l.push(U(f, "Interaction unavailable", "The server did not provide a durable interaction revision; this card is read-only."));
1285
1294
  continue;
1286
1295
  }
1287
1296
  if (o.has(f.itemId)) {
1288
- let e = Le(f);
1297
+ let e = Re(f);
1289
1298
  l.push(e || U(f, "Unsupported content", "A2UI payload is not a valid passive operation list."));
1290
1299
  continue;
1291
1300
  }
@@ -1333,26 +1342,26 @@ function W(e) {
1333
1342
  interactions: u
1334
1343
  };
1335
1344
  }
1336
- function ze(e, t, n) {
1337
- let r = W(t).messages;
1338
- if (!r.length) return e;
1339
- let i = e.filter((e) => e.eventType !== "optimistic_assistant_placeholder"), a = (e) => e.runId === t.runId || e.invocationId === t.runId, o = i.findIndex(a), s = n ? i.findIndex((e) => e.id === n) : o < 0 ? i.findLastIndex((e) => e.role === "user" && e.eventType === "optimistic_user_message") : i.findIndex((e) => e.role === "user" && a(e)), c = i[s], l = i.filter((e, t) => t !== s && !a(e)), u = [s, o].filter((e) => e >= 0), d = u.length ? Math.min(...u) : l.length, f = c && !r.some((e) => e.role === "user") ? [{
1340
- ...c,
1345
+ function Be(e, t, n, r) {
1346
+ let i = W(t).messages;
1347
+ if (!i.length) return e;
1348
+ let a = e.filter((e) => e.eventType !== "optimistic_assistant_placeholder"), o = (e) => e.runId === t.runId || e.invocationId === t.runId || r !== void 0 && (e.runId === r || e.invocationId === r), s = a.findIndex(o), c = n ? a.findIndex((e) => e.id === n) : s < 0 ? a.findLastIndex((e) => e.role === "user" && e.eventType === "optimistic_user_message") : a.findIndex((e) => e.role === "user" && o(e)), l = a[c], u = a.filter((e, t) => t !== c && !o(e)), d = [c, s].filter((e) => e >= 0), f = d.length ? Math.min(...d) : u.length, p = l && !i.some((e) => e.role === "user") ? [{
1349
+ ...l,
1341
1350
  invocationId: t.runId,
1342
1351
  eventType: void 0
1343
1352
  }] : [];
1344
1353
  return [
1345
- ...l.slice(0, d),
1346
- ...f,
1347
- ...r,
1348
- ...l.slice(d)
1354
+ ...u.slice(0, f),
1355
+ ...p,
1356
+ ...i,
1357
+ ...u.slice(f)
1349
1358
  ];
1350
1359
  }
1351
1360
  //#endregion
1352
1361
  //#region src/core/run/blocks.ts
1353
- var Be = 0;
1362
+ var Ve = 0;
1354
1363
  function G(e) {
1355
- return Be += 1, `${e}-${Be}`;
1364
+ return Ve += 1, `${e}-${Ve}`;
1356
1365
  }
1357
1366
  function K(e) {
1358
1367
  return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
@@ -1360,7 +1369,7 @@ function K(e) {
1360
1369
  status: "done"
1361
1370
  } : e);
1362
1371
  }
1363
- function Ve(e, t, n) {
1372
+ function He(e, t, n) {
1364
1373
  let r = [...e ?? []], i = r[r.length - 1];
1365
1374
  return i?.type === "thinking" && i.status === "streaming" && i.itemId === n ? (r[r.length - 1] = {
1366
1375
  ...i,
@@ -1373,7 +1382,7 @@ function Ve(e, t, n) {
1373
1382
  ...n && { itemId: n }
1374
1383
  }];
1375
1384
  }
1376
- function He(e, t, n) {
1385
+ function Ue(e, t, n) {
1377
1386
  let r = (e) => e.type === "thinking" && e.itemId === t, i = e.findLastIndex(r), a = 0;
1378
1387
  return e.flatMap((e, t) => {
1379
1388
  if (!r(e)) return [e];
@@ -1384,7 +1393,7 @@ function He(e, t, n) {
1384
1393
  }] : [];
1385
1394
  });
1386
1395
  }
1387
- function Ue(e, t) {
1396
+ function We(e, t) {
1388
1397
  let n = [...K(e ?? [])], r = n[n.length - 1];
1389
1398
  return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
1390
1399
  ...r,
@@ -1396,10 +1405,10 @@ function Ue(e, t) {
1396
1405
  status: "streaming"
1397
1406
  }];
1398
1407
  }
1399
- function We(e, t) {
1408
+ function Ge(e, t) {
1400
1409
  let n = e ?? [], r = n.filter((e) => e.type === "text").map((e) => e.content).join("");
1401
1410
  if (r === t) return n;
1402
- if (t.startsWith(r) && n.at(-1)?.type !== "text") return Ue(n, t.slice(r.length));
1411
+ if (t.startsWith(r) && n.at(-1)?.type !== "text") return We(n, t.slice(r.length));
1403
1412
  let i = n.flatMap((e, t) => e.type === "text" ? [t] : []), a = 0;
1404
1413
  for (; a < r.length && a < t.length && r[a] === t[a];) a++;
1405
1414
  let o = 0;
@@ -1419,7 +1428,7 @@ function We(e, t) {
1419
1428
  };
1420
1429
  });
1421
1430
  }
1422
- function Ge(e, t) {
1431
+ function Ke(e, t) {
1423
1432
  let n = K(e ?? []), r = n.flatMap((e) => e.type === "text" ? [e.content] : []).join(""), i = n.at(-1), a = n;
1424
1433
  if (t !== r && i?.type !== "text") {
1425
1434
  let e = t.startsWith(r) ? t.slice(r.length) : t;
@@ -1441,7 +1450,7 @@ function Ge(e, t) {
1441
1450
  status: "done"
1442
1451
  } : e);
1443
1452
  }
1444
- function Ke(e, t) {
1453
+ function qe(e, t) {
1445
1454
  if (!t) return [...e ?? []];
1446
1455
  let n = [...e ?? []], r = n[n.length - 1];
1447
1456
  if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
@@ -1451,7 +1460,7 @@ function Ke(e, t) {
1451
1460
  content: i
1452
1461
  }, n) : (n.pop(), n);
1453
1462
  }
1454
- function qe(e, t, n) {
1463
+ function Je(e, t, n) {
1455
1464
  let r = [...e ?? []], i = n.extra?.callId, a = i ? r.findIndex((e) => e.type === "tool" && e.extra?.callId === i && e.toolName === t) : -1;
1456
1465
  if (a < 0 && (a = r.findLastIndex((e) => e.type === "tool" && e.toolName === t && (!i || !e.extra?.callId && (e.status === "running" || e.status === "paused")))), a >= 0 && r[a].type === "tool") {
1457
1466
  let e = r[a], t = e.status === "error" || e.status === "completed", i = n.output !== void 0, o = n.extra && (n.extra.approvalRequestId || n.extra.approvalStatus);
@@ -1476,10 +1485,10 @@ function qe(e, t, n) {
1476
1485
  extra: n.extra
1477
1486
  }];
1478
1487
  }
1479
- function Je(e) {
1488
+ function Ye(e) {
1480
1489
  return K(e ?? []);
1481
1490
  }
1482
- function Ye(e) {
1491
+ function Xe(e) {
1483
1492
  let t = [];
1484
1493
  if (e.reasoning && e.reasoning.trim() && t.push({
1485
1494
  id: G("thinking"),
@@ -1508,14 +1517,14 @@ function Ye(e) {
1508
1517
  }
1509
1518
  //#endregion
1510
1519
  //#region src/core/stream/kernel-events.ts
1511
- var Xe = {
1520
+ var Ze = {
1512
1521
  "run.started": "in_progress",
1513
1522
  "run.progress": "in_progress",
1514
1523
  "run.completed": "completed",
1515
1524
  "run.failed": "failed",
1516
1525
  "run.canceled": "cancelled",
1517
1526
  "run.interrupted": "interrupted"
1518
- }, Ze = new Set([
1527
+ }, Qe = new Set([
1519
1528
  "completed",
1520
1529
  "failed",
1521
1530
  "cancelled",
@@ -1524,7 +1533,7 @@ var Xe = {
1524
1533
  function q(e) {
1525
1534
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
1526
1535
  }
1527
- function Qe(e) {
1536
+ function $e(e) {
1528
1537
  let t = q(e.source), n = t ? q(t.metadata) : null;
1529
1538
  return String(n?.native_item_kind || "");
1530
1539
  }
@@ -1534,7 +1543,7 @@ function J(e, t) {
1534
1543
  let r = n?.parts;
1535
1544
  return Array.isArray(r) ? r : t === "update" ? [n] : [];
1536
1545
  }
1537
- function $e(e) {
1546
+ function et(e) {
1538
1547
  let t = q(e);
1539
1548
  if (!t) return "";
1540
1549
  if (typeof t.text == "string") return t.text;
@@ -1552,9 +1561,9 @@ function $e(e) {
1552
1561
  return "";
1553
1562
  }
1554
1563
  function Y(e) {
1555
- return e.map($e).join("");
1564
+ return e.map(et).join("");
1556
1565
  }
1557
- function et(e) {
1566
+ function tt(e) {
1558
1567
  return e.some((e) => q(q(e)?.data)?.type === "userMessage");
1559
1568
  }
1560
1569
  function X(e) {
@@ -1564,18 +1573,18 @@ function X(e) {
1564
1573
  }
1565
1574
  return Y(e) || null;
1566
1575
  }
1567
- function tt(e) {
1576
+ function nt(e) {
1568
1577
  let t = q(e);
1569
1578
  return t ? q(t.data) || t : null;
1570
1579
  }
1571
- function nt(e) {
1572
- let t = tt(e);
1580
+ function rt(e) {
1581
+ let t = nt(e);
1573
1582
  return String(t?.content_type || t?.type || "").trim().toLowerCase();
1574
1583
  }
1575
- function rt(e) {
1584
+ function it(e) {
1576
1585
  for (let t of e) {
1577
- let e = tt(t);
1578
- if (!e || nt(t) !== "tool_call") continue;
1586
+ let e = nt(t);
1587
+ if (!e || rt(t) !== "tool_call") continue;
1579
1588
  let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
1580
1589
  if (!(!n && !r)) return {
1581
1590
  callId: n,
@@ -1585,10 +1594,10 @@ function rt(e) {
1585
1594
  }
1586
1595
  return null;
1587
1596
  }
1588
- function it(e) {
1597
+ function at(e) {
1589
1598
  for (let t of e) {
1590
- let e = tt(t);
1591
- if (!e || nt(t) !== "tool_result") continue;
1599
+ let e = nt(t);
1600
+ if (!e || rt(t) !== "tool_result") continue;
1592
1601
  let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
1593
1602
  return {
1594
1603
  callId: n,
@@ -1610,7 +1619,7 @@ function Z(e, t, n, r) {
1610
1619
  ...i && i !== a ? { SourceItemId: i } : {}
1611
1620
  } };
1612
1621
  }
1613
- var at = class {
1622
+ var ot = class {
1614
1623
  textByPart = /* @__PURE__ */ new Map();
1615
1624
  toolNameByCallId = /* @__PURE__ */ new Map();
1616
1625
  toolCallByItemId = /* @__PURE__ */ new Map();
@@ -1642,7 +1651,7 @@ var at = class {
1642
1651
  };
1643
1652
  if (r === "control.run_transition") {
1644
1653
  let t = String(e.state || "").toLowerCase();
1645
- if (Ze.has(t)) return {
1654
+ if (Qe.has(t)) return {
1646
1655
  ...a(),
1647
1656
  EventType: "run_status",
1648
1657
  Content: { status: t }
@@ -1653,17 +1662,17 @@ var at = class {
1653
1662
  if (n !== "runtime") return null;
1654
1663
  let o = q(q(e.source)?.metadata), s = o?.conversation_visibility ?? o?.visibility;
1655
1664
  if (r.startsWith("item.") && ["internal", "hidden"].includes(String(s))) return null;
1656
- let c = Xe[r];
1665
+ let c = Ze[r];
1657
1666
  if (c) return {
1658
1667
  ...a(),
1659
1668
  EventType: "run_status",
1660
1669
  Content: { status: c }
1661
1670
  };
1662
- let l = Qe(e);
1671
+ let l = $e(e);
1663
1672
  if (r === "item.started") {
1664
1673
  let t = J(e, "initial");
1665
1674
  if (e.item_kind === "tool_call") {
1666
- let n = rt(t);
1675
+ let n = it(t);
1667
1676
  if (!n) return null;
1668
1677
  let r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
1669
1678
  return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
@@ -1681,7 +1690,7 @@ var at = class {
1681
1690
  }
1682
1691
  };
1683
1692
  }
1684
- return e.item_kind === "tool_result" || l === "userMessage" || et(t) || l === "reasoning" || e.item_kind === "reasoning" ? null : l === "agentMessage" || !l && e.item_kind === "message" ? {
1693
+ return e.item_kind === "tool_result" || l === "userMessage" || tt(t) || l === "reasoning" || e.item_kind === "reasoning" ? null : l === "agentMessage" || !l && e.item_kind === "message" ? {
1685
1694
  ...a(),
1686
1695
  EventType: "assistant_stream_snapshot",
1687
1696
  Content: { parts: [{ text: "" }] },
@@ -1701,7 +1710,7 @@ var at = class {
1701
1710
  if (r === "item.updated") {
1702
1711
  let n = J(e, "update");
1703
1712
  if (e.item_kind === "tool_call") {
1704
- let t = it(n);
1713
+ let t = at(n);
1705
1714
  if (!t) return null;
1706
1715
  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;
1707
1716
  return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
@@ -1746,7 +1755,7 @@ var at = class {
1746
1755
  if (r === "item.completed") {
1747
1756
  let n = J(e, "snapshot");
1748
1757
  if (e.item_kind === "tool_call") {
1749
- let t = rt(n), r = it(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";
1758
+ let t = it(n), r = at(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";
1750
1759
  if (s && this.toolNameByCallId.set(s, c), r) {
1751
1760
  let t = r.isError ? { error: r.result } : r.result;
1752
1761
  return {
@@ -1774,7 +1783,7 @@ var at = class {
1774
1783
  };
1775
1784
  }
1776
1785
  if (e.item_kind === "tool_result") {
1777
- let t = it(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || l || "tool", s = t?.isError ? { error: t.result } : t?.result ?? X(n);
1786
+ let t = at(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || l || "tool", s = t?.isError ? { error: t.result } : t?.result ?? X(n);
1778
1787
  return {
1779
1788
  ...a(),
1780
1789
  EventType: "tool_result",
@@ -1787,7 +1796,7 @@ var at = class {
1787
1796
  }
1788
1797
  };
1789
1798
  }
1790
- if (l === "userMessage" || et(n)) return {
1799
+ if (l === "userMessage" || tt(n)) return {
1791
1800
  ...a(),
1792
1801
  EventType: "user_message",
1793
1802
  Content: { parts: [{ text: Y(n) }] }
@@ -1852,7 +1861,7 @@ var at = class {
1852
1861
  return null;
1853
1862
  }
1854
1863
  };
1855
- async function ot(e) {
1864
+ async function st(e) {
1856
1865
  let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
1857
1866
  try {
1858
1867
  for (;;) {
@@ -1862,8 +1871,8 @@ async function ot(e) {
1862
1871
  break;
1863
1872
  }
1864
1873
  if (r.trimStart().startsWith("{")) {
1865
- if (st(r)) {
1866
- i = ct(r);
1874
+ if (ct(r)) {
1875
+ i = lt(r);
1867
1876
  break;
1868
1877
  }
1869
1878
  } else if (o(r)) break;
@@ -1899,7 +1908,7 @@ async function ot(e) {
1899
1908
  stream: c
1900
1909
  };
1901
1910
  }
1902
- function st(e) {
1911
+ function ct(e) {
1903
1912
  let t = e.trim();
1904
1913
  if (!t.endsWith("}")) return !1;
1905
1914
  let n = 0, r = !1, i = !1;
@@ -1916,7 +1925,7 @@ function st(e) {
1916
1925
  }
1917
1926
  return n === 0;
1918
1927
  }
1919
- function ct(e) {
1928
+ function lt(e) {
1920
1929
  try {
1921
1930
  let t = q(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1922
1931
  if (!n) return null;
@@ -1942,8 +1951,8 @@ function ct(e) {
1942
1951
  function Q(e) {
1943
1952
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
1944
1953
  }
1945
- function lt(e) {
1946
- let t = e.map(ft), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t, n) => JSON.stringify([
1954
+ function ut(e) {
1955
+ let t = e.map(pt), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t, n) => JSON.stringify([
1947
1956
  e,
1948
1957
  t,
1949
1958
  n
@@ -1971,7 +1980,7 @@ function lt(e) {
1971
1980
  } : e;
1972
1981
  });
1973
1982
  }
1974
- function ut(e) {
1983
+ function dt(e) {
1975
1984
  if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
1976
1985
  if (typeof e == "string" && e.trim()) {
1977
1986
  let t = Number(e.trim());
@@ -1980,7 +1989,7 @@ function ut(e) {
1980
1989
  let t = Date.parse(String(e || ""));
1981
1990
  return Number.isFinite(t) ? t : Date.now();
1982
1991
  }
1983
- function dt(e, t, r, i, a) {
1992
+ function ft(e, t, r, i, a) {
1984
1993
  let o = /* @__PURE__ */ new Set(), s = (e, t) => JSON.stringify([e, t]), c = /* @__PURE__ */ new Set();
1985
1994
  for (let e of t) {
1986
1995
  let t = n(e, i);
@@ -2051,7 +2060,7 @@ function dt(e, t, r, i, a) {
2051
2060
  };
2052
2061
  return e.map(d);
2053
2062
  }
2054
- function ft(e) {
2063
+ function pt(e) {
2055
2064
  let t = Q(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
2056
2065
  if (t && String(t.event_type || "")) return {
2057
2066
  ...t,
@@ -2071,10 +2080,10 @@ function ft(e) {
2071
2080
  timestamp: e.Timestamp || n.timestamp || r.timestamp
2072
2081
  };
2073
2082
  }
2074
- function pt(e, t, n) {
2083
+ function mt(e, t, n) {
2075
2084
  let i = /* @__PURE__ */ new Map();
2076
2085
  for (let e of t) {
2077
- if (e.EventType !== "run_status" || ft(e)) continue;
2086
+ if (e.EventType !== "run_status" || pt(e)) continue;
2078
2087
  let t = String(e.InvocationId || e.Metadata?.run_id || "").trim();
2079
2088
  t && !n.has(t) && i.set(t, e);
2080
2089
  }
@@ -2083,7 +2092,7 @@ function pt(e, t, n) {
2083
2092
  let n = r({
2084
2093
  ...t,
2085
2094
  EventId: t.EventId || `legacy-terminal:${e}:${t.SeqId || 0}`,
2086
- Timestamp: ut(t.Timestamp)
2095
+ Timestamp: dt(t.Timestamp)
2087
2096
  });
2088
2097
  if (!n) continue;
2089
2098
  let i = (t) => (t.invocationId || t.runId) === e;
@@ -2122,7 +2131,7 @@ function pt(e, t, n) {
2122
2131
  function $(e) {
2123
2132
  return e.role === "model" ? {
2124
2133
  ...e,
2125
- blocks: e.blocks?.length ? e.blocks : Ye({
2134
+ blocks: e.blocks?.length ? e.blocks : Xe({
2126
2135
  content: e.content,
2127
2136
  reasoning: e.reasoning,
2128
2137
  reasoningSource: e.reasoningSource,
@@ -2130,7 +2139,7 @@ function $(e) {
2130
2139
  })
2131
2140
  } : e;
2132
2141
  }
2133
- function mt(e, t) {
2142
+ function ht(e, t) {
2134
2143
  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 ? {
2135
2144
  ...e,
2136
2145
  ...n,
@@ -2143,7 +2152,7 @@ function mt(e, t) {
2143
2152
  } : e));
2144
2153
  return n && !r ? [n, ...s] : s;
2145
2154
  }
2146
- function ht(e, t) {
2155
+ function gt(e, t) {
2147
2156
  let n = t.filter((e) => e.role === "model"), r = n.flatMap((e) => Object.values(e.tools || {}).map((t) => ({
2148
2157
  tool: t,
2149
2158
  scope: e.scopeId
@@ -2158,7 +2167,7 @@ function ht(e, t) {
2158
2167
  return [t, r ? {
2159
2168
  ...n,
2160
2169
  ...r,
2161
- ...I(n, r),
2170
+ ...F(n, r),
2162
2171
  name: n.name
2163
2172
  } : n];
2164
2173
  })), n = e === s ? a : [];
@@ -2171,9 +2180,9 @@ function ht(e, t) {
2171
2180
  let n = t.extra?.callId, r = typeof n == "string" ? i(n, e.scopeId) : void 0;
2172
2181
  return r ? {
2173
2182
  ...t,
2174
- ...I(t, r)
2183
+ ...F(t, r)
2175
2184
  } : t;
2176
- }), c = Ye({ tools: Object.fromEntries(n.map(({ tool: e, scope: t }) => [JSON.stringify([t || "", e.callId || e.name]), e])) }), l = r?.findIndex((e) => e.type === "text") ?? -1;
2185
+ }), c = Xe({ tools: Object.fromEntries(n.map(({ tool: e, scope: t }) => [JSON.stringify([t || "", e.callId || e.name]), e])) }), l = r?.findIndex((e) => e.type === "text") ?? -1;
2177
2186
  return $({
2178
2187
  ...e,
2179
2188
  ...e === s ? { reasoning: e.reasoning || o || void 0 } : {},
@@ -2186,21 +2195,21 @@ function ht(e, t) {
2186
2195
  });
2187
2196
  });
2188
2197
  }
2189
- function gt(e) {
2198
+ function _t(e) {
2190
2199
  return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
2191
2200
  }
2192
- var _t = new Set([
2201
+ var vt = new Set([
2193
2202
  "approval.resolved",
2194
2203
  "interaction.resolved",
2195
2204
  "interaction.cancelled",
2196
2205
  "interaction.canceled",
2197
2206
  "a2ui.action"
2198
2207
  ]);
2199
- function vt(e) {
2208
+ function yt(e) {
2200
2209
  let t = /* @__PURE__ */ new Set();
2201
2210
  for (let n of e) {
2202
2211
  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();
2203
- if (!_t.has(a)) continue;
2212
+ if (!vt.has(a)) continue;
2204
2213
  let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
2205
2214
  if (![
2206
2215
  "cancel",
@@ -2212,16 +2221,16 @@ function vt(e) {
2212
2221
  }
2213
2222
  return t;
2214
2223
  }
2215
- function yt(e, t, n, r = "flat-v1", a) {
2216
- e = L(e);
2217
- let o = new at(n), s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = [...t || []].filter((e) => {
2224
+ function bt(e, t, n, r = "flat-v1", a) {
2225
+ e = I(e);
2226
+ let o = new ot(n), s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = [...t || []].filter((e) => {
2218
2227
  let t = e.Content, r = Q(t?.session_event || t?.sessionEvent), i = Q(t?.runtime_event || t?.runtimeEvent);
2219
2228
  return [
2220
2229
  e.SessionId,
2221
2230
  r?.session_id,
2222
2231
  i?.session_id
2223
2232
  ].every((e) => !e || e === n);
2224
- }).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), f = Number(a ?? d[0]?.SeqId ?? 0) <= 1, p = lt(d);
2233
+ }).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), f = Number(a ?? d[0]?.SeqId ?? 0) <= 1, p = ut(d);
2225
2234
  for (let [e, t] of d.entries()) {
2226
2235
  let n = p[e];
2227
2236
  if (!n) continue;
@@ -2240,7 +2249,7 @@ function yt(e, t, n, r = "flat-v1", a) {
2240
2249
  i && s.push({
2241
2250
  ...i,
2242
2251
  SeqId: Number(t.SeqId || i.SeqId || 0),
2243
- Timestamp: ut(t.Timestamp || i.Timestamp)
2252
+ Timestamp: dt(t.Timestamp || i.Timestamp)
2244
2253
  });
2245
2254
  }
2246
2255
  let m = i(s).filter((e) => e.invocationId && c.has(e.invocationId)), h = /* @__PURE__ */ new Map();
@@ -2250,7 +2259,7 @@ function yt(e, t, n, r = "flat-v1", a) {
2250
2259
  let n = h.get(e);
2251
2260
  n ? n.push(t) : h.set(e, [t]);
2252
2261
  }
2253
- let g = new Set([...gt(m)].filter((e) => u.has(e))), _ = /* @__PURE__ */ new Map();
2262
+ let g = new Set([..._t(m)].filter((e) => u.has(e))), _ = /* @__PURE__ */ new Map();
2254
2263
  for (let e of p) {
2255
2264
  if (e?.schema_version !== 2 || !e.run_id) continue;
2256
2265
  let t = String(e.run_id), n = _.get(t) || [];
@@ -2270,7 +2279,7 @@ function yt(e, t, n, r = "flat-v1", a) {
2270
2279
  if (!(!i || !o)) try {
2271
2280
  let i = new w(n, void 0, r);
2272
2281
  t.forEach((e) => i.apply(e));
2273
- let a = i.snapshot(), o = j(a, { profile: r }), s = ut(t[0].timestamp);
2282
+ let a = i.snapshot(), o = fe(a, { profile: r }), s = dt(t[0].timestamp);
2274
2283
  b.set(e, W({
2275
2284
  state: a,
2276
2285
  presentation: o,
@@ -2293,11 +2302,11 @@ function yt(e, t, n, r = "flat-v1", a) {
2293
2302
  }
2294
2303
  }
2295
2304
  for (let e of new Set([...y, ...x])) b.has(e) || g.delete(e);
2296
- let S = vt(d), C = [...g].flatMap((e) => mt(m.filter((t) => t.invocationId === e), h.get(e) || [])), T = /* @__PURE__ */ new Map(), E = [];
2305
+ let S = yt(d), C = [...g].flatMap((e) => ht(m.filter((t) => t.invocationId === e), h.get(e) || [])), T = /* @__PURE__ */ new Map(), E = [];
2297
2306
  for (let [e, t] of h) {
2298
2307
  if (g.has(e) || !c.has(e)) continue;
2299
2308
  let n = m.filter((t) => t.invocationId === e), r = t.some((e) => e.role === "model" && String(e.content || "").trim());
2300
- T.set(e, r ? ht(t, n) : t), r || E.push(...n.map($));
2309
+ T.set(e, r ? gt(t, n) : t), r || E.push(...n.map($));
2301
2310
  }
2302
2311
  for (let e of c) g.has(e) || h.has(e) || E.push(...m.filter((t) => t.invocationId === e).map($));
2303
2312
  let ee = new Map([...T.values()].flat().map((e) => [e.id, e])), D = z([
@@ -2307,7 +2316,7 @@ function yt(e, t, n, r = "flat-v1", a) {
2307
2316
  ]);
2308
2317
  for (let [e, t] of b) {
2309
2318
  if (!t.length) continue;
2310
- let n = (t) => t.invocationId === e || t.runId === e, r = D.findIndex(n), i = D.filter(n), a = i.find((e) => e.role === "user"), o = y.has(e) ? a && !t.some((e) => e.role === "user") ? [a, ...t] : t : mt(t, i), s = D.filter((e) => !n(e)), c = r < 0 ? s.length : r;
2319
+ let n = (t) => t.invocationId === e || t.runId === e, r = D.findIndex(n), i = D.filter(n), a = i.find((e) => e.role === "user"), o = y.has(e) ? a && !t.some((e) => e.role === "user") ? [a, ...t] : t : ht(t, i), s = D.filter((e) => !n(e)), c = r < 0 ? s.length : r;
2311
2320
  D = [
2312
2321
  ...s.slice(0, c),
2313
2322
  ...o,
@@ -2315,10 +2324,10 @@ function yt(e, t, n, r = "flat-v1", a) {
2315
2324
  ], g.add(e);
2316
2325
  }
2317
2326
  return {
2318
- messages: dt(L(z(pt(D, d, l))), d, p, n, l),
2327
+ messages: ft(I(z(mt(D, d, l))), d, p, n, l),
2319
2328
  canonicalRunIds: [...g],
2320
2329
  translatedEvents: s
2321
2330
  };
2322
2331
  }
2323
2332
  //#endregion
2324
- export { j as C, w as D, E, C as O, xe as S, D as T, z as _, Ue as a, we as b, Ge as c, He as d, Ke as f, De as g, W as h, ot as i, Je as l, ze as m, yt as n, Ve as o, qe as p, at as r, Ye as s, ft as t, We as u, Te as v, te as w, Ce as x, L as y };
2333
+ export { fe as C, w as D, E, C as O, Se as S, D as T, z as _, We as a, Te as b, Ke as c, Ue as d, qe as f, Oe as g, W as h, st as i, Ye as l, Be as m, bt as n, He as o, Je as p, ot as r, Xe as s, pt as t, Ge as u, Ee as v, O as w, we as x, I as y };