@kingsoftcloud/ksadk-web 0.3.17 → 0.3.19

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 (204) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-DYzXIPnl.js → ArtifactsPanel-cjsDWTLW.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-Dpa-tOmG.js → CodeBlock-DTtT6SBI.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-D8kBE9sl.js → MathMessageMarkdown-Dap7DsE1.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock-BYOoZB-_.js → MermaidBlock-C2QkLej8.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-CAeXHeo6.js → NativeTerminalPanel-CeLWBCnF.js} +1 -1
  9. package/dist-ksadk/assets/{OfficialA2uiRenderer-yPb3s23n.js → OfficialA2uiRenderer-BshRBsxZ.js} +1 -1
  10. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-DdVxMn2L.js → abnfDiagram-VCTEODGH-RvCk4kKS.js} +1 -1
  11. package/dist-ksadk/assets/{arc-DsOMYRTm.js → arc-R-NvbHBi.js} +1 -1
  12. package/dist-ksadk/assets/architecture-7GRP2DOG-BgT_ltgS.js +1 -0
  13. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-BCfzi23_.js → architectureDiagram-5GKGNRK7-CWyeEVzn.js} +1 -1
  14. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-gC-Gc2Xv.js → blockDiagram-NRAW4CY4-CHbhUWj9.js} +1 -1
  15. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BAHemGZa.js → c4Diagram-UCG6FXSJ-BJAftB45.js} +1 -1
  16. package/dist-ksadk/assets/channel-CO8jKUdU.js +1 -0
  17. package/dist-ksadk/assets/chunk-2Q5K7J3B-BQ7ktM_H.js +1 -0
  18. package/dist-ksadk/assets/{chunk-5VM5RSS4-Cthhs8Yv.js → chunk-5VM5RSS4-BHufOSfh.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-F27PBJKO-BPV04XpW.js → chunk-F27PBJKO-BNPW42o9.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-G27WJ6UU-Cl1n0gHd.js → chunk-G27WJ6UU-D_eOFZiC.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-JWPE2WC7-DqkIh_LK.js → chunk-JWPE2WC7-DEVN_PSR.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-LCL6LL3I-DZhAKY7Z.js → chunk-LCL6LL3I-DjGV_Lnh.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-POPQ4Y6H-BGuhTofV.js → chunk-POPQ4Y6H-C2i8ZB07.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-RHFEMEQ7-DhrRHdJ6.js → chunk-RHFEMEQ7-DMk7_iWC.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-SVP7TREG-CIdm5TIa.js → chunk-SVP7TREG-wHQkXddN.js} +1 -1
  26. package/dist-ksadk/assets/{chunk-XXDRQBXY-CNIlGK4v.js → chunk-XXDRQBXY-gvpc9yiQ.js} +1 -1
  27. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-HRhUD6oW.js +1 -0
  28. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-HRhUD6oW.js +1 -0
  29. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-BjauSFl3.js → cose-bilkent-JH36ORCC-BF-zBbK8.js} +1 -1
  30. package/dist-ksadk/assets/cynefin-OW5HDTMX-DlLbgFtT.js +1 -0
  31. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-DPszkr1j.js → cynefinDiagram-5FMLGOSQ-0_hg7nkA.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-3AP2YEHR-Ds2xBGA0.js → dagre-3AP2YEHR-uSuKjV2i.js} +1 -1
  33. package/dist-ksadk/assets/{dagre-Dr0YPDPm.js → dagre-BCQPdEAN.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-S7CK7UJ4-BOQfgaW5.js → diagram-S7CK7UJ4-ay17NfAC.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-UQ7AKVKN-DMMyB2sa.js → diagram-UQ7AKVKN-CaUhPrNE.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VSXAHHWV-DZR1nzPa.js → diagram-VSXAHHWV-upF8B0NL.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-VX7I27RA-DzAwLHuI.js → diagram-VX7I27RA-B4t46LEt.js} +1 -1
  38. package/dist-ksadk/assets/{diagram-Z3DM3KII-D98d_Dgt.js → diagram-Z3DM3KII-BeHjswE7.js} +1 -1
  39. package/dist-ksadk/assets/{dist-A55dc8b7.js → dist-58qYwY0M.js} +1 -1
  40. package/dist-ksadk/assets/{dist-By8HbjFH.js → dist-AF7gi0D5.js} +1 -1
  41. package/dist-ksadk/assets/{dist-HuJDn2Nr.js → dist-B0PMHWqd.js} +1 -1
  42. package/dist-ksadk/assets/{dist-U51Rn7ZW.js → dist-B0s4RUpo.js} +1 -1
  43. package/dist-ksadk/assets/{dist-glVlUB_d.js → dist-BGzoFqM2.js} +1 -1
  44. package/dist-ksadk/assets/{dist-BHIb3Gvv.js → dist-BLCD6xMk.js} +1 -1
  45. package/dist-ksadk/assets/{dist-BIR7kFKG.js → dist-Be3VXZq8.js} +1 -1
  46. package/dist-ksadk/assets/{dist-CpHO1CY1.js → dist-Bt0YWq2H.js} +1 -1
  47. package/dist-ksadk/assets/{dist-BEzIxZLq.js → dist-Bt4Xk1Ro.js} +1 -1
  48. package/dist-ksadk/assets/{dist-D9GtQnvz.js → dist-Bx4az-XW.js} +1 -1
  49. package/dist-ksadk/assets/{dist-DHiOUJJ-.js → dist-C577ALLK.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DxBl1V2_.js → dist-CIZ7o8ol.js} +1 -1
  51. package/dist-ksadk/assets/{dist-CxzBVC3N.js → dist-COzkztpc.js} +1 -1
  52. package/dist-ksadk/assets/{dist-CN8MSPvo.js → dist-CW5ZHS5y.js} +1 -1
  53. package/dist-ksadk/assets/{dist-Du5KbDTg.js → dist-CdhMAiGd.js} +1 -1
  54. package/dist-ksadk/assets/{dist-MMIlBueM.js → dist-DIeaHG12.js} +1 -1
  55. package/dist-ksadk/assets/{dist-BpZXLW0T.js → dist-DfFlb9ip.js} +1 -1
  56. package/dist-ksadk/assets/{dist-C1uAMNTH.js → dist-DvOmTQAV.js} +1 -1
  57. package/dist-ksadk/assets/{dist-VLWgeZIu.js → dist-Dze75pZq.js} +1 -1
  58. package/dist-ksadk/assets/{dist-E1uwqlZY.js → dist-h0bOCJVW.js} +1 -1
  59. package/dist-ksadk/assets/{dist-q8rONmMl.js → dist-mkEF0-z9.js} +1 -1
  60. package/dist-ksadk/assets/{dist-X8Mgnqit.js → dist-uAoeCAZ2.js} +1 -1
  61. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-X4mBLaw3.js → ebnfDiagram-PWID7BFC-CZKqGdhK.js} +1 -1
  62. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-ClybQoOy.js → erDiagram-SSCWMZ5O-CfQ9oOg4.js} +1 -1
  63. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BgSxiUqa.js +1 -0
  64. package/dist-ksadk/assets/flowDiagram-A5DVABFB-Dcg0DKL0.js +1 -0
  65. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-Dc_fWiA_.js → ganttDiagram-EL5Y4UJY-CWdRcbsA.js} +1 -1
  66. package/dist-ksadk/assets/gitGraph-4MIJSDKK-DiYbIL_1.js +1 -0
  67. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-0eEV_CEC.js → gitGraphDiagram-WWUBYQGX-S2TxceQ8.js} +1 -1
  68. package/dist-ksadk/assets/index-CK5of5EC.js +1135 -0
  69. package/dist-ksadk/assets/index-ofLgkIsP.css +2 -0
  70. package/dist-ksadk/assets/info-A6RAGUB7-CIUhUhPM.js +1 -0
  71. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-mZoyw4Xh.js → infoDiagram-RXCK75RN-7M0hPUvw.js} +1 -1
  72. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-CO8OkxgJ.js → ishikawaDiagram-5VMMS53U-DApt_KC9.js} +1 -1
  73. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-Ci8GpXLK.js → journeyDiagram-EYS64GPL-03NWnwcI.js} +1 -1
  74. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-lgD5AYON.js → kanban-definition-3QL26DDD-CWrM-ciB.js} +1 -1
  75. package/dist-ksadk/assets/{katex-Chn0O-XC.js → katex-CVJEnrQQ.js} +1 -1
  76. package/dist-ksadk/assets/{linear-ffygyi0f.js → linear-CuvdttYn.js} +1 -1
  77. package/dist-ksadk/assets/{mermaid-parser.core-CGPz1_57.js → mermaid-parser.core-CyiGaINC.js} +2 -2
  78. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-DRaJyZGQ.js → mindmap-definition-FBJOCRG2-Cx8x9zok.js} +1 -1
  79. package/dist-ksadk/assets/packet-AYTQ26CC-CVt8vTzN.js +1 -0
  80. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-BbQ2QDD3.js → pegDiagram-XKGWAZYB-BvMeLOBU.js} +1 -1
  81. package/dist-ksadk/assets/pie-WAS4IAKB-BmY8d_KC.js +1 -0
  82. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-BcB_c4Ka.js → pieDiagram-E7YTZNPT-BTEiUEUk.js} +1 -1
  83. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-CK3csxHk.js → quadrantDiagram-AXDQQJYC-CEMfGgSc.js} +1 -1
  84. package/dist-ksadk/assets/radar-RG4KPBEZ-D-vxRTHO.js +1 -0
  85. package/dist-ksadk/assets/railroad-74A4TZTK-hDbxS9Gl.js +1 -0
  86. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-6j4dsPir.js +1 -0
  87. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-f3r0amOv.js +1 -0
  88. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DpGM5wUK.js +1 -0
  89. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-D1YLglVU.js → railroadDiagram-O6MQD6OU-DjL0Ielv.js} +1 -1
  90. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-VeyqOcw3.js → requirementDiagram-EFPCY7ZU-Da11svpD.js} +1 -1
  91. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-uskDVCah.js → sankeyDiagram-P5KCCOFB-DtKGEnlF.js} +1 -1
  92. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-CmoPC4aR.js → sequenceDiagram-WJ2MYXX4-CR6Ct1Vm.js} +1 -1
  93. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DzV4X5WN.js → sizeCapture-X5ZJPWSS-DaQE2An6.js} +1 -1
  94. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-BJehrZbH.js → stateDiagram-HBIQ2CUA-Ct2KGWos.js} +1 -1
  95. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-IHXiAplS.js +1 -0
  96. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-Bn4tEi27.js → swimlanes-XN3QIQJK-BpIOaZ-N.js} +1 -1
  97. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-ByC69bCd.js +8 -0
  98. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-bSkaKxqF.js → timeline-definition-24CTP7MA-CdwbtpKP.js} +1 -1
  99. package/dist-ksadk/assets/treeView-Q6P3EWNA-Bm72pNZV.js +1 -0
  100. package/dist-ksadk/assets/treemap-WGGIJYW6-Dpgkdt4o.js +1 -0
  101. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-ClO6s5iT.js → vennDiagram-4TSXK5OY-Dr_5LEwY.js} +1 -1
  102. package/dist-ksadk/assets/wardley-WFR3VGLG-C9w6FZRL.js +1 -0
  103. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-CcaYar33.js → wardleyDiagram-VM6X3IG4-DYojPjE8.js} +1 -1
  104. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-DdiPl8uB.js → xychartDiagram-S5SC5T6Z-DV3dpSiv.js} +1 -1
  105. package/dist-ksadk/index.html +2 -2
  106. package/dist-lib/App.d.ts.map +1 -1
  107. package/dist-lib/{AttachmentPreview-DHvWB_a-.js → AttachmentPreview-COS-HmHj.js} +121 -121
  108. package/dist-lib/{ConnectedComposer-CuN3EUnU.js → ConnectedComposer-CB_YmxRQ.js} +246 -246
  109. package/dist-lib/{ConnectedMessageList-CT-MJJkJ.js → ConnectedMessageList-CJgvv-Hi.js} +379 -294
  110. package/dist-lib/{WorkspacePanelContainer-Jg9bUmLJ.js → WorkspacePanelContainer-DU6mKsi5.js} +5 -5
  111. package/dist-lib/{a2ui-DridcTyF.js → a2ui-e0gsVo7e.js} +336 -527
  112. package/dist-lib/api/client.d.ts +2 -1
  113. package/dist-lib/api/client.d.ts.map +1 -1
  114. package/dist-lib/api/messages.d.ts +38 -0
  115. package/dist-lib/api/messages.d.ts.map +1 -1
  116. package/dist-lib/{capabilities-lJRDfRg9.js → capabilities-CHy70QGW.js} +5 -2
  117. package/dist-lib/capabilities.js +1 -1
  118. package/dist-lib/chat-composer.js +2 -2
  119. package/dist-lib/chat-timeline.js +5 -5
  120. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  121. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  122. package/dist-lib/components/chat/DeferredHistoryContent.d.ts +6 -0
  123. package/dist-lib/components/chat/DeferredHistoryContent.d.ts.map +1 -0
  124. package/dist-lib/components/chat/ProcessingBlocksView.d.ts +1 -8
  125. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
  126. package/dist-lib/components/chat/submitted-interaction-history.d.ts.map +1 -1
  127. package/dist-lib/components/chat/types.d.ts +11 -0
  128. package/dist-lib/components/chat/types.d.ts.map +1 -1
  129. package/dist-lib/components.js +14 -14
  130. package/dist-lib/conversation.js +2 -2
  131. package/dist-lib/core/api/facade.d.ts +2 -14
  132. package/dist-lib/core/api/facade.d.ts.map +1 -1
  133. package/dist-lib/core/api/types.d.ts +1 -24
  134. package/dist-lib/core/api/types.d.ts.map +1 -1
  135. package/dist-lib/core/run/blocks.d.ts +4 -2
  136. package/dist-lib/core/run/blocks.d.ts.map +1 -1
  137. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  138. package/dist-lib/core/run/engine.d.ts +5 -1
  139. package/dist-lib/core/run/engine.d.ts.map +1 -1
  140. package/dist-lib/core/run/types.d.ts +13 -0
  141. package/dist-lib/core/run/types.d.ts.map +1 -1
  142. package/dist-lib/core/stream/types.d.ts +7 -0
  143. package/dist-lib/core/stream/types.d.ts.map +1 -1
  144. package/dist-lib/{feedback-CaSZOBD2.js → feedback-nyK8zFEK.js} +1 -1
  145. package/dist-lib/hooks/useAgentChat.d.ts +1 -1
  146. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  147. package/dist-lib/hooks/useInteractions.d.ts +1 -1
  148. package/dist-lib/hooks/useInteractions.d.ts.map +1 -1
  149. package/dist-lib/hooks/useRunAgent.d.ts +1 -0
  150. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  151. package/dist-lib/hooks/useSessionLifecycle.d.ts +3 -1
  152. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  153. package/dist-lib/hooks.js +120 -119
  154. package/dist-lib/{permission-2NpSBuq3.js → permission-B9NRAmxP.js} +1 -1
  155. package/dist-lib/{persisted-session-history-D_1AtH5H.js → persisted-session-history-C8S6Tl-E.js} +482 -380
  156. package/dist-lib/runtime.js +178 -176
  157. package/dist-lib/{session-events-6PXUoAkP.js → session-events-BMRjrPq2.js} +542 -292
  158. package/dist-lib/stores/session.d.ts +4 -0
  159. package/dist-lib/stores/session.d.ts.map +1 -1
  160. package/dist-lib/styles.css +1 -1
  161. package/dist-lib/{useSessionLifecycle-daQg0sqQ.js → useSessionLifecycle-DPwSsODU.js} +1874 -1096
  162. package/dist-lib/utils/capabilities.d.ts +1 -0
  163. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  164. package/dist-lib/utils/history-content.d.ts +16 -0
  165. package/dist-lib/utils/history-content.d.ts.map +1 -0
  166. package/dist-lib/utils/history-tool-facts.d.ts.map +1 -1
  167. package/dist-lib/utils/persisted-session-history.d.ts +1 -1
  168. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  169. package/dist-lib/utils/responses-stream.d.ts +3 -1
  170. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  171. package/dist-lib/utils/run-progress.d.ts.map +1 -1
  172. package/dist-lib/utils/session-event-history.d.ts +13 -0
  173. package/dist-lib/utils/session-event-history.d.ts.map +1 -1
  174. package/dist-lib/utils/session-events.d.ts +4 -1
  175. package/dist-lib/utils/session-events.d.ts.map +1 -1
  176. package/dist-lib/utils/session-items.d.ts +36 -0
  177. package/dist-lib/utils/session-items.d.ts.map +1 -0
  178. package/dist-lib/utils/transcript-order.d.ts +2 -1
  179. package/dist-lib/utils/transcript-order.d.ts.map +1 -1
  180. package/package.json +1 -1
  181. package/dist-ksadk/assets/architecture-7GRP2DOG-Ds1NB530.js +0 -1
  182. package/dist-ksadk/assets/channel-B4PiWfnA.js +0 -1
  183. package/dist-ksadk/assets/chunk-2Q5K7J3B-CI2tn5IS.js +0 -1
  184. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-BMQzydMm.js +0 -1
  185. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-BMQzydMm.js +0 -1
  186. package/dist-ksadk/assets/cynefin-OW5HDTMX-DcGwq_cA.js +0 -1
  187. package/dist-ksadk/assets/eventmodeling-NTZA5JFV--IdqCKdV.js +0 -1
  188. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BsidNZBX.js +0 -1
  189. package/dist-ksadk/assets/gitGraph-4MIJSDKK-BTqI4bBo.js +0 -1
  190. package/dist-ksadk/assets/index-B0DeBpyZ.js +0 -1132
  191. package/dist-ksadk/assets/index-DEVfafsU.css +0 -2
  192. package/dist-ksadk/assets/info-A6RAGUB7-CXZCoW0H.js +0 -1
  193. package/dist-ksadk/assets/packet-AYTQ26CC-DoZlIRtk.js +0 -1
  194. package/dist-ksadk/assets/pie-WAS4IAKB-Dl-IyMT_.js +0 -1
  195. package/dist-ksadk/assets/radar-RG4KPBEZ-Bp8MemxX.js +0 -1
  196. package/dist-ksadk/assets/railroad-74A4TZTK-BmKyKako.js +0 -1
  197. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-DhFitwOH.js +0 -1
  198. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-TB8LQz8q.js +0 -1
  199. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-B3J1Rtq9.js +0 -1
  200. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-DkujIgVj.js +0 -1
  201. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-Blb1TQ9Q.js +0 -8
  202. package/dist-ksadk/assets/treeView-Q6P3EWNA-C5Ez-6L4.js +0 -1
  203. package/dist-ksadk/assets/treemap-WGGIJYW6-WdNvoGQV.js +0 -1
  204. package/dist-ksadk/assets/wardley-WFR3VGLG-DCCceTuX.js +0 -1
@@ -1,7 +1,7 @@
1
- import { f as e, n as t, p as n, r } from "./session-events-6PXUoAkP.js";
2
- import { d as i, i as a, l as o, o as s, p as c, t as l, u } from "./reducer-mbYiX0wz.js";
1
+ import { S as e, b as t, f as n, n as r, r as i } from "./session-events-BMRjrPq2.js";
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
- var d = [
4
+ var f = [
5
5
  "authorization",
6
6
  "credential",
7
7
  "password",
@@ -19,14 +19,14 @@ var d = [
19
19
  "stack",
20
20
  "exception"
21
21
  ];
22
- function f(e) {
23
- return e.normalize("NFKC").toLowerCase().replace(/[^a-z0-9]/g, "");
24
- }
25
22
  function p(e) {
26
- let t = f(e);
27
- return d.some((e) => t.includes(e));
23
+ return e.normalize("NFKC").toLowerCase().replace(/[^a-z0-9]/g, "");
28
24
  }
29
25
  function m(e) {
26
+ let t = p(e);
27
+ return f.some((e) => t.includes(e));
28
+ }
29
+ function h(e) {
30
30
  let t = e.split(".");
31
31
  if (t.length > 4 || t.some((e) => e.length === 0)) return null;
32
32
  let n = t.map((e) => {
@@ -39,10 +39,10 @@ function m(e) {
39
39
  let r = n, i = 2 ** (8 * (5 - r.length));
40
40
  return r.slice(0, -1).some((e) => e > 255) || r.at(-1) >= i ? null : r.slice(0, -1).reduce((e, t, n) => e + t * 2 ** (8 * (3 - n)), r.at(-1));
41
41
  }
42
- function h(e) {
42
+ function g(e) {
43
43
  return e >>> 24 == 0 || e >>> 24 == 10 || e >>> 24 == 127 || e >>> 16 == 43518 || e >>> 16 == 49320 || e >>> 20 == 2753;
44
44
  }
45
- function g(e) {
45
+ function _(e) {
46
46
  let t;
47
47
  try {
48
48
  t = decodeURIComponent(e).toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
@@ -50,44 +50,44 @@ function g(e) {
50
50
  return !0;
51
51
  }
52
52
  if (t === "localhost" || t.endsWith(".localhost") || t.endsWith(".local") || t.endsWith(".internal")) return !0;
53
- let n = t.match(/^::ffff:(\d+(?:\.\d+){0,3})$/)?.[1], r = t.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i), i = r ? Number.parseInt(r[1], 16) * 65536 + Number.parseInt(r[2], 16) : m(n || t);
54
- if (i !== null) return h(i);
53
+ let n = t.match(/^::ffff:(\d+(?:\.\d+){0,3})$/)?.[1], r = t.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i), i = r ? Number.parseInt(r[1], 16) * 65536 + Number.parseInt(r[2], 16) : h(n || t);
54
+ if (i !== null) return g(i);
55
55
  let a = Number.parseInt(t.split(":", 1)[0], 16);
56
56
  return t === "::" || t === "::1" || Number.isInteger(a) && (a & 65024) == 64512 || Number.isInteger(a) && (a & 65472) == 65152;
57
57
  }
58
- function _(e) {
58
+ function v(e) {
59
59
  return (e.match(/https?:\/\/\[[^\]]+\](?::\d+)?[^\s<>{}"']*|https?:\/\/[^\s<>{}"'[\]()]+/gi) || []).some((e) => {
60
60
  let t = e.replace(/[.,;:!?]+$/, "").replace(/\\/g, "/");
61
61
  try {
62
62
  let e = new URL(t);
63
- return !!(e.username || e.password) || g(e.hostname);
63
+ return !!(e.username || e.password) || _(e.hostname);
64
64
  } catch {
65
65
  return !0;
66
66
  }
67
67
  });
68
68
  }
69
- function v(e, t = 0) {
70
- return b(e, t, 8192);
69
+ function y(e, t = 0) {
70
+ return x(e, t, 8192);
71
71
  }
72
- function y(e, t, n) {
73
- return b(e, 0, [
72
+ function b(e, t, n) {
73
+ return x(e, 0, [
74
74
  "langgraph",
75
75
  "adk",
76
76
  "codex"
77
77
  ].includes(String(t)) && !String(n || "").toLowerCase().includes("a2a") ? Infinity : 8192);
78
78
  }
79
- function b(e, t, n) {
80
- return t > 8 ? "[truncated]" : typeof e == "string" ? /bearer\s+\S+|traceback|(?:token|authorization|api[_ .-]?key|access[_ .-]?token|refresh[_ .-]?token|secretaccesskey|accesstoken|refreshtoken|cookie|password|secret)\s*["']?\s*[=:]/i.test(e) || _(e) ? "[redacted]" : e.length > n ? `${e.slice(0, n)}[truncated]` : e : Array.isArray(e) ? e.slice(0, 128).map((e) => b(e, t + 1, n)) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).slice(0, 128).filter(([e]) => !p(e)).map(([e, r]) => [e, b(r, t + 1, n)])) : e;
79
+ function x(e, t, n) {
80
+ return t > 8 ? "[truncated]" : typeof e == "string" ? /bearer\s+\S+|traceback|(?:token|authorization|api[_ .-]?key|access[_ .-]?token|refresh[_ .-]?token|secretaccesskey|accesstoken|refreshtoken|cookie|password|secret)\s*["']?\s*[=:]/i.test(e) || v(e) ? "[redacted]" : e.length > n ? `${e.slice(0, n)}[truncated]` : e : Array.isArray(e) ? e.slice(0, 128).map((e) => x(e, t + 1, n)) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).slice(0, 128).filter(([e]) => !m(e)).map(([e, r]) => [e, x(r, t + 1, n)])) : e;
81
81
  }
82
82
  //#endregion
83
83
  //#region src/core/conversation/runtime-ingress.ts
84
- var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e, t, n) => JSON.stringify([
84
+ var S = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, C = (e, t, n) => JSON.stringify([
85
85
  e,
86
86
  t,
87
87
  n
88
- ]), C = class {
89
- runtime = new n();
90
- flatChildren = new l();
88
+ ]), w = class {
89
+ runtime = new e();
90
+ flatChildren = new u();
91
91
  seen = /* @__PURE__ */ new Set();
92
92
  parents = /* @__PURE__ */ new Map();
93
93
  descriptorItemIds = /* @__PURE__ */ new Map();
@@ -97,11 +97,11 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
97
97
  sessionId;
98
98
  conversation;
99
99
  profile;
100
- constructor(e, t = new l(), n = "flat-v1") {
100
+ constructor(e, t = new u(), n = "flat-v1") {
101
101
  this.sessionId = e, this.conversation = t, this.profile = n;
102
102
  }
103
103
  identity(e, t, n, r = !1) {
104
- return this.profile === "agent-block-v1" || r ? S(e, t, n) : n;
104
+ return this.profile === "agent-block-v1" || r ? C(e, t, n) : n;
105
105
  }
106
106
  snapshot() {
107
107
  let e = this.conversation.snapshot();
@@ -119,13 +119,13 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
119
119
  if (!t || !n || !r) throw Error("RuntimeEvent identity missing");
120
120
  if (this.runId && this.runId !== t) throw Error("RuntimeEvent run identity changed");
121
121
  if (this.seen.has(r)) return null;
122
- let a = String(e.parent_scope_id ?? this.descriptors.get(n)?.parent_scope_id ?? this.parents.get(n) ?? ""), o = x(e.source), c = [
122
+ let a = String(e.parent_scope_id ?? this.descriptors.get(n)?.parent_scope_id ?? this.parents.get(n) ?? ""), o = S(e.source), s = [
123
123
  "adk",
124
124
  "langgraph",
125
125
  "codex"
126
126
  ].includes(String(o.framework)) && !this.descriptors.has(n);
127
- if (c && a && i === "run.progress") return null;
128
- if (i.startsWith("run.") && (a || !c && this.rootScope && n !== this.rootScope)) throw Error("Child scope cannot transition root run");
127
+ if (s && a && i === "run.progress") return null;
128
+ if (i.startsWith("run.") && (a || !s && this.rootScope && n !== this.rootScope)) throw Error("Child scope cannot transition root run");
129
129
  if (this.parents.has(n) && this.parents.get(n) !== a) throw Error("Scope parent changed");
130
130
  let l = String(e.item_id || ""), u = this.identity(t, n, l || r, !!a), d = Object.fromEntries(Object.entries({
131
131
  framework: o.framework,
@@ -152,7 +152,7 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
152
152
  payloadSchemaRef: "conversation.item.progress/v1",
153
153
  payload: {},
154
154
  nativeRef: d
155
- }, p = x(x(e.source).metadata), m = p.conversation_visibility ?? p.visibility;
155
+ }, p = S(S(e.source).metadata), m = p.conversation_visibility ?? p.visibility;
156
156
  if ([
157
157
  "public",
158
158
  "internal",
@@ -167,35 +167,35 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
167
167
  "run.failed",
168
168
  "run.canceled",
169
169
  "run.cancelled"
170
- ].includes(i) && (f.kind = "error", f.payloadSchemaRef = "conversation.item.error/v1", f.payload.error = x(e.error).message || e.reason || ""), f.lifecycle = ["run.completed", "run.interrupted"].includes(i) ? "completed" : [
170
+ ].includes(i) && (f.kind = "error", f.payloadSchemaRef = "conversation.item.error/v1", f.payload.error = S(e.error).message || e.reason || ""), f.lifecycle = ["run.completed", "run.interrupted"].includes(i) ? "completed" : [
171
171
  "run.failed",
172
172
  "run.canceled",
173
173
  "run.cancelled"
174
174
  ].includes(i) ? "failed" : "streaming";
175
175
  else {
176
176
  if (!l) throw Error("RuntimeEvent item identity missing");
177
- let d = x(e.snapshot || e.initial), p = i === "item.updated" ? [x(e.update)] : Array.isArray(d.parts) ? d.parts : [], h = p.map((e) => {
178
- let t = x(e);
177
+ let d = S(e.snapshot || e.initial), p = i === "item.updated" ? [S(e.update)] : Array.isArray(d.parts) ? d.parts : [], h = p.map((e) => {
178
+ let t = S(e);
179
179
  return {
180
180
  partId: String(t.part_id || "part"),
181
181
  contentType: String(t.content_type || "data"),
182
182
  ...typeof t.text == "string" ? { text: t.text } : {},
183
183
  value: t
184
184
  };
185
- }), g = p.map((e) => x(x(e).data)).find((e) => e.schema === "execution.scope/v1");
186
- if (a && !g && !c) {
185
+ }), g = p.map((e) => S(S(e).data)).find((e) => e.schema === "execution.scope/v1");
186
+ if (a && !g && !s) {
187
187
  let e = this.descriptorItemIds.get(n);
188
188
  if (!e) throw Error("Child content requires its scope descriptor first");
189
189
  f.parentItemId = e;
190
190
  }
191
191
  if (g) {
192
192
  if (this.descriptorItemIds.has(n) && this.descriptorItemIds.get(n) !== u) throw Error("Scope descriptor item identity changed");
193
- let e = x(g.trigger_ref);
193
+ let e = S(g.trigger_ref);
194
194
  if (g.scope_id !== n || g.parent_scope_id !== a || e.scope_id !== a || !e.item_id || !e.call_id || !a) throw Error("Invalid scope descriptor locator");
195
195
  let t = this.runtime.snapshot().items.find((t) => t.scopeId === e.scope_id && t.itemId === e.item_id);
196
- if (t && !t.parts.some((t) => x(t.value).call_id === e.call_id)) throw Error("Scope trigger call mismatch");
196
+ if (t && !t.parts.some((t) => S(t.value).call_id === e.call_id)) throw Error("Scope trigger call mismatch");
197
197
  let r = this.descriptors.get(n);
198
- s({
198
+ c({
199
199
  ...f,
200
200
  kind: "agent",
201
201
  payloadSchemaRef: "conversation.item.agent/v1",
@@ -207,15 +207,15 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
207
207
  } : void 0), this.descriptors.set(n, g), this.descriptorItemIds.set(n, u);
208
208
  }
209
209
  for (let e of this.descriptors.values()) {
210
- let t = x(e.trigger_ref);
211
- if (t.scope_id === n && t.item_id === l && h.length && !h.some((e) => x(e.value).call_id === t.call_id)) throw Error("Scope trigger call mismatch");
210
+ let t = S(e.trigger_ref);
211
+ if (t.scope_id === n && t.item_id === l && h.length && !h.some((e) => S(e.value).call_id === t.call_id)) throw Error("Scope trigger call mismatch");
212
212
  }
213
213
  let _ = this.runtime.snapshot().items.find((e) => e.scopeId === n && e.itemId === l);
214
- if (a && !c && _ && _.status !== "open") {
214
+ if (a && !s && _ && _.status !== "open") {
215
215
  if (i === "item.updated" || i === "item.started") throw Error("Remote item cannot reopen");
216
216
  if (Array.isArray(d.parts) && JSON.stringify(_.parts) !== JSON.stringify(h)) throw Error("Remote terminal content conflict");
217
217
  }
218
- let b = {
218
+ let v = {
219
219
  type: i.replaceAll(".", "_"),
220
220
  runId: t,
221
221
  scopeId: n,
@@ -231,52 +231,52 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
231
231
  op: e.op || "replace"
232
232
  } : {}
233
233
  };
234
- this.runtime.apply(b);
235
- let S = this.runtime.snapshot().items.find((e) => e.scopeId === n && e.itemId === l);
236
- if (!S || a && S.itemKind === "status" && S.status === "open" && !S.parts.length) return null;
234
+ this.runtime.apply(v);
235
+ let x = this.runtime.snapshot().items.find((e) => e.scopeId === n && e.itemId === l);
236
+ if (!x || a && x.itemKind === "status" && x.status === "open" && !x.parts.length) return null;
237
237
  if (a && [
238
238
  "artifact",
239
239
  "tool_call",
240
240
  "tool_result"
241
- ].includes(S.itemKind) && !S.parts.length) return this.runId = t, this.parents.set(n, a), this.seen.add(r), null;
242
- let C = S.parts.map((e) => x(e.value)), w = C.map((e) => x(e.data)).find((e) => e.schema === "execution.scope/v1");
243
- if (f.lifecycle = S.status === "open" ? i === "item.started" ? "pending" : "streaming" : S.status, f.operation = ["completed", "failed"].includes(f.lifecycle) ? "completed" : i === "item.started" ? "append" : "replace", w) f.operation = ["completed", "failed"].includes(f.lifecycle) ? "completed" : "replace", f.kind = "agent", f.payloadSchemaRef = "conversation.item.agent/v1", f.payload = w, f.parentItemId = this.identity(t, String(x(w.trigger_ref).scope_id), String(x(w.trigger_ref).item_id), !!this.parents.get(String(x(w.trigger_ref).scope_id))), f.capabilityRef = "agent.block";
244
- else if (S.itemKind === "tool_call" || S.itemKind === "tool_result") {
241
+ ].includes(x.itemKind) && !x.parts.length) return this.runId = t, this.parents.set(n, a), this.seen.add(r), null;
242
+ let C = x.parts.map((e) => S(e.value)), w = C.map((e) => S(e.data)).find((e) => e.schema === "execution.scope/v1");
243
+ if (f.lifecycle = x.status === "open" ? i === "item.started" ? "pending" : "streaming" : x.status, f.operation = ["completed", "failed"].includes(f.lifecycle) ? "completed" : i === "item.started" ? "append" : "replace", w) f.operation = ["completed", "failed"].includes(f.lifecycle) ? "completed" : "replace", f.kind = "agent", f.payloadSchemaRef = "conversation.item.agent/v1", f.payload = w, f.parentItemId = this.identity(t, String(S(w.trigger_ref).scope_id), String(S(w.trigger_ref).item_id), !!this.parents.get(String(S(w.trigger_ref).scope_id))), f.capabilityRef = "agent.block";
244
+ else if (x.itemKind === "tool_call" || x.itemKind === "tool_result") {
245
245
  let e = C.find((e) => e.content_type === "tool_call"), t = C.find((e) => e.content_type === "tool_result");
246
246
  f.kind = "tool_call", f.capabilityRef = "tool.inspect", f.payloadSchemaRef = "conversation.item.tool-call/v1", f.payload = {
247
247
  ...e ? {
248
248
  callId: e.call_id,
249
249
  tool: e.name,
250
- args: v(e.arguments)
250
+ args: y(e.arguments)
251
251
  } : {},
252
252
  ...t ? {
253
253
  callId: t.call_id,
254
- output: y(t.result, o.framework, o.protocol),
254
+ output: b(t.result, o.framework, o.protocol),
255
255
  isError: t.is_error
256
256
  } : {},
257
- executionStatus: S.status === "failed" ? "failed" : t && S.status !== "open" ? t.is_error ? "failed" : "completed" : S.itemKind === "tool_result" ? "unknown" : "running",
258
- sourceKind: S.itemKind
257
+ executionStatus: x.status === "failed" ? "failed" : t && x.status !== "open" ? t.is_error ? "failed" : "completed" : x.itemKind === "tool_result" ? "unknown" : "running",
258
+ sourceKind: x.itemKind
259
259
  };
260
- } else if (S.itemKind === "data" && o.protocol === "a2ui") {
260
+ } else if (x.itemKind === "data" && o.protocol === "a2ui") {
261
261
  let e = C.find((e) => e.content_type === "data")?.data;
262
262
  f.kind = "a2ui", f.payloadSchemaRef = "conversation.item.a2ui/v1", f.payload = {
263
- surfaceId: String(x(o.metadata).surface_id || ""),
264
- ...typeof x(o.metadata).interaction_id == "string" ? { interactionId: x(o.metadata).interaction_id } : {},
263
+ surfaceId: String(S(o.metadata).surface_id || ""),
264
+ ...typeof S(o.metadata).interaction_id == "string" ? { interactionId: S(o.metadata).interaction_id } : {},
265
265
  data: Array.isArray(e) ? e : []
266
266
  };
267
- } else if (S.itemKind === "message" || S.itemKind === "reasoning" || S.itemKind === "artifact" && S.parts.length > 0 && S.parts.every((e) => e.contentType === "text")) {
268
- f.kind = S.itemKind === "reasoning" ? "reasoning" : x(x(e.source).metadata).native_item_kind === "userMessage" ? "user_message" : "assistant_text", f.payloadSchemaRef = `conversation.item.${f.kind}/v1`, f.payload = { text: S.parts.map((e) => e.text || "").join("") };
269
- let t = x(o.metadata);
270
- f.kind === "reasoning" && (t.public_summary === !0 || t.provider_reasoning === !0) && (f.payload.presentationSource = t.public_summary === !0 ? "public_summary" : "provider_reasoning"), i === "item.updated" && e.op === "append" && (f.operation = "append", f.payload.text = x(e.update).text || "");
271
- } else if (S.itemKind === "artifact") {
267
+ } else if (x.itemKind === "message" || x.itemKind === "reasoning" || x.itemKind === "artifact" && x.parts.length > 0 && x.parts.every((e) => e.contentType === "text")) {
268
+ f.kind = x.itemKind === "reasoning" ? "reasoning" : S(S(e.source).metadata).native_item_kind === "userMessage" ? "user_message" : "assistant_text", f.payloadSchemaRef = `conversation.item.${f.kind}/v1`, f.payload = { text: x.parts.map((e) => e.text || "").join("") };
269
+ let t = S(o.metadata);
270
+ f.kind === "reasoning" && (t.public_summary === !0 || t.provider_reasoning === !0) && (f.payload.presentationSource = t.public_summary === !0 ? "public_summary" : "provider_reasoning"), i === "item.updated" && e.op === "append" && (f.operation = "append", f.payload.text = S(e.update).text || "");
271
+ } else if (x.itemKind === "artifact") {
272
272
  let e = C.find((e) => e.content_type === "artifact") || {};
273
273
  f.kind = "artifact", f.payloadSchemaRef = "conversation.item.artifact/v1", f.payload = {
274
274
  name: e.name,
275
275
  mimeType: e.mime_type,
276
276
  uri: e.uri
277
277
  };
278
- } else if (S.status === "failed") {
279
- let t = x(e.error);
278
+ } else if (x.status === "failed") {
279
+ let t = S(e.error);
280
280
  f.kind = "error", f.payloadSchemaRef = "conversation.item.error/v1", f.payload = { error: String(t.message || t.code || "Remote call failed") };
281
281
  } else f.visibility = m === "public" ? "public" : "hidden", f.kind = "unknown", f.payloadSchemaRef = "conversation.item.unknown/v1", f.payload = { summary: "Unsupported runtime content" };
282
282
  }
@@ -285,11 +285,11 @@ var x = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {}, S = (e,
285
285
  };
286
286
  //#endregion
287
287
  //#region src/core/a2ui/history.ts
288
- function w(e, t) {
288
+ function T(e, t) {
289
289
  let n = e.map((e) => JSON.stringify(e)), r = t.map((e) => JSON.stringify(e));
290
290
  return n.every((e, t) => r[t] === e) ? t : r.every((e, t) => n[t] === e) ? e : [...e, ...t];
291
291
  }
292
- function T(e, t, n) {
292
+ function E(e, t, n) {
293
293
  let r = {
294
294
  ...t.runId || e?.runId ? { runId: t.runId || e?.runId } : {},
295
295
  ...t.interactionId || e?.interactionId ? { interactionId: t.interactionId || e?.interactionId } : {},
@@ -301,7 +301,7 @@ function T(e, t, n) {
301
301
  } : {
302
302
  ...t,
303
303
  ...r,
304
- messages: e ? w(e.messages, t.messages) : t.messages,
304
+ messages: e ? T(e.messages, t.messages) : t.messages,
305
305
  ...n || e?.batchIds || t.batchIds ? { batchIds: [...new Set([
306
306
  ...e?.batchIds || [],
307
307
  ...t.batchIds || [],
@@ -318,21 +318,21 @@ function ee(e, t) {
318
318
  let i = e.activity.runId || e.message.runId || e.message.invocationId, a = t.activity.runId || t.message.runId || t.message.invocationId;
319
319
  return i && a ? i === a : (e.activity.originMessageId || e.message.id) === (t.activity.originMessageId || t.message.id);
320
320
  }
321
- function E(e, t) {
321
+ 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 D(e) {
325
+ function te(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) => {
329
- let i = t.get(r.surfaceId) || [], a = E(i, {
329
+ let i = t.get(r.surfaceId) || [], a = D(i, {
330
330
  message: e,
331
331
  activity: r
332
332
  });
333
333
  if (a) {
334
334
  let t = a.activity;
335
- n = !0, t.messages = w(t.messages, r.messages), t.interactionId = r.interactionId || t.interactionId, t.runId ||= r.runId || e.runId || e.invocationId, t.batchIds = [...new Set([...t.batchIds || [], ...r.batchIds || []])];
335
+ n = !0, t.messages = T(t.messages, r.messages), t.interactionId = r.interactionId || t.interactionId, t.runId ||= r.runId || e.runId || e.invocationId, t.batchIds = [...new Set([...t.batchIds || [], ...r.batchIds || []])];
336
336
  return;
337
337
  }
338
338
  let o = r.runId || e.runId || e.invocationId, s = {
@@ -357,7 +357,7 @@ function D(e) {
357
357
  }
358
358
  //#endregion
359
359
  //#region src/core/conversation/presentation.ts
360
- var te = {
360
+ var ne = {
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 te = {
368
368
  a2ui: "conversation.item.a2ui/v1",
369
369
  error: "conversation.item.error/v1"
370
370
  };
371
- function ne(e) {
371
+ function re(e) {
372
372
  return e.lifecycle === "completed" || e.lifecycle === "failed";
373
373
  }
374
- var re = new Set([
374
+ var ie = new Set([
375
375
  "aborted",
376
376
  "canceled",
377
377
  "cancelled",
@@ -380,16 +380,16 @@ var re = new Set([
380
380
  "interrupted"
381
381
  ]);
382
382
  function O(e) {
383
- if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !ne(e)) return;
383
+ if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !re(e)) return;
384
384
  let t = typeof e.payload.status == "string" ? e.payload.status.toLowerCase() : "";
385
385
  if (t === "completed") return "completed";
386
- if (re.has(t)) return "failed";
386
+ if (ie.has(t)) return "failed";
387
387
  }
388
- function ie(e) {
389
- let t = te[e.kind];
388
+ function ae(e) {
389
+ let t = ne[e.kind];
390
390
  return t === void 0 || t === e.payloadSchemaRef;
391
391
  }
392
- function ae(e) {
392
+ function oe(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 ae(e) {
398
398
  return null;
399
399
  }
400
400
  }
401
- function oe(e) {
401
+ function se(e) {
402
402
  return {
403
403
  id: e.itemId,
404
404
  parentId: e.parentItemId || null,
@@ -408,8 +408,8 @@ function oe(e) {
408
408
  lifecycle: e.lifecycle
409
409
  };
410
410
  }
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);
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);
413
413
  return {
414
414
  artifactId: t,
415
415
  itemId: e.itemId,
@@ -446,8 +446,8 @@ function A(e, t) {
446
446
  }
447
447
  return `item:${e.itemId}`;
448
448
  }
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: w(e.payload.data, t.payload.data) } : {};
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) } : {};
451
451
  return {
452
452
  ...e,
453
453
  ...t,
@@ -473,7 +473,7 @@ function ce(e, t) {
473
473
  } : {}
474
474
  };
475
475
  }
476
- function le(e) {
476
+ function ue(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
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;
@@ -498,7 +498,7 @@ function le(e) {
498
498
  runId: c.runId
499
499
  },
500
500
  activity: d
501
- } : null, p = r.get(u) || [], m = f ? E(p, f) : void 0, h = f ? m?.index : n.get(u);
501
+ } : null, p = r.get(u) || [], m = f ? D(p, f) : void 0, h = f ? m?.index : n.get(u);
502
502
  if (h === void 0) {
503
503
  f ? r.set(u, [...p, {
504
504
  ...f,
@@ -514,7 +514,7 @@ function le(e) {
514
514
  let g = t[h];
515
515
  t[h] = {
516
516
  key: g.key,
517
- item: ce(g.item, c),
517
+ item: le(g.item, c),
518
518
  sourceItemIds: [...new Set([...g.sourceItemIds, c.itemId])]
519
519
  };
520
520
  }
@@ -529,29 +529,29 @@ function le(e) {
529
529
  }
530
530
  } : t);
531
531
  }
532
- function j(e, t) {
532
+ function de(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 ue(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) => j(t, e).map((e) => e.itemId))), a = e.filter((e) => !r(e) && !i.has(e.itemId));
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));
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
- }), le(a).map((t) => {
541
+ }), ue(a).map((t) => {
542
542
  if (t.item.kind !== "agent") return t;
543
- let n = le(e.filter((e) => r(e) === t.item && !i.has(e.itemId)));
543
+ let n = ue(e.filter((e) => r(e) === t.item && !i.has(e.itemId)));
544
544
  return {
545
545
  ...t,
546
- sourceItemIds: [...new Set([...j(t.item, e).map((e) => e.itemId), ...t.sourceItemIds])],
546
+ sourceItemIds: [...new Set([...de(t.item, e).map((e) => e.itemId), ...t.sourceItemIds])],
547
547
  children: n
548
548
  };
549
549
  });
550
550
  }
551
- function de(e, t = {}) {
551
+ function j(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) => j(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) => 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;
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 de(e, t = {}) {
567
567
  }
568
568
  n = a.filter((e) => e.kind !== "assistant_text" || !!i);
569
569
  }
570
- let r = n.filter(ie), i = n.filter((e) => !ie(e)), a = new Set([
570
+ let r = n.filter(ae), i = n.filter((e) => !ae(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(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) => O(e) !== void 0);
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);
575
575
  return {
576
- timeline: ue(r.filter((e) => e.kind !== "progress")),
576
+ timeline: fe(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 de(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(se),
584
+ artifacts: r.filter((e) => e.kind === "artifact").map(ce),
585
585
  fallbacks: [...l.map((e) => ({
586
586
  id: e.itemId,
587
587
  title: "Unsupported content",
@@ -604,12 +604,12 @@ function N(e) {
604
604
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
605
605
  }
606
606
  function P(e) {
607
- if (e?.aborted) throw new c("conversation_aborted", "Conversation request was aborted.");
607
+ if (e?.aborted) throw new l("conversation_aborted", "Conversation request was aborted.");
608
608
  }
609
- function fe(e, t) {
609
+ function pe(e, t) {
610
610
  return t?.aborted === !0 || e instanceof Error && e.name === "AbortError";
611
611
  }
612
- function pe(e) {
612
+ function me(e) {
613
613
  let t = e.trim().replace(/\/+$/, "");
614
614
  if (!t) return "";
615
615
  if (!t.includes("://")) return t.startsWith("/") ? t : `/${t}`;
@@ -618,36 +618,36 @@ function pe(e) {
618
618
  if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password) throw Error("unsafe URL");
619
619
  return e.toString().replace(/\/$/, "");
620
620
  } catch (e) {
621
- throw new c("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
621
+ throw new l("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
622
622
  }
623
623
  }
624
- function me(e) {
624
+ function he(e) {
625
625
  return Math.min(200 * 2 ** Math.max(0, e - 1), 2e3);
626
626
  }
627
- function he(e) {
627
+ function ge(e) {
628
628
  return new Promise((t) => {
629
629
  setTimeout(t, e);
630
630
  });
631
631
  }
632
- async function ge(e, t, n) {
632
+ async function _e(e, t, n) {
633
633
  if (P(n), !n) {
634
634
  await e(t);
635
635
  return;
636
636
  }
637
637
  await new Promise((r, i) => {
638
- let a = () => i(new c("conversation_aborted", "Conversation request was aborted."));
638
+ let a = () => i(new l("conversation_aborted", "Conversation request was aborted."));
639
639
  n.addEventListener("abort", a, { once: !0 }), e(t).then(r, i).finally(() => {
640
640
  n.removeEventListener("abort", a);
641
641
  });
642
642
  });
643
643
  }
644
- function _e(e, t, n, r, i) {
644
+ function F(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: de(a, { profile: r })
650
+ presentation: j(a, { profile: r })
651
651
  };
652
652
  }
653
653
  function ve(e, t) {
@@ -657,7 +657,7 @@ function ve(e, t) {
657
657
  if (!e || e.startsWith(":")) continue;
658
658
  let i = e.indexOf(":"), a = i < 0 ? e : e.slice(0, i), o = i < 0 ? "" : e.slice(i + 1), s = o.startsWith(" ") ? o.slice(1) : o;
659
659
  if (a === "id") {
660
- if (!/^\d+$/.test(s) || !Number.isSafeInteger(Number(s))) throw new c("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
660
+ if (!/^\d+$/.test(s) || !Number.isSafeInteger(Number(s))) throw new l("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
661
661
  n = Number(s);
662
662
  } else a === "data" && r.push(s);
663
663
  }
@@ -668,31 +668,31 @@ function ve(e, t) {
668
668
  try {
669
669
  a = JSON.parse(i);
670
670
  } catch (e) {
671
- throw new c("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
671
+ throw new l("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
672
672
  }
673
- let s = N(a), l = N(s?.runtimeEvent) || N(s?.runtime_event) || (s?.schema_version === 2 ? s : null);
674
- if (!s || s.conversationItem === void 0 && !l) {
673
+ let o = N(a), c = N(o?.runtimeEvent) || N(o?.runtime_event) || (o?.schema_version === 2 ? o : null);
674
+ if (!o || o.conversationItem === void 0 && !c) {
675
675
  n !== void 0 && (t.cursor = Math.max(t.cursor, n));
676
676
  return;
677
677
  }
678
- if (n === void 0) throw new c("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
679
- let u = s.conversationItem === void 0 ? "runtime" : "native";
678
+ if (n === void 0) throw new l("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
679
+ let u = o.conversationItem === void 0 ? "runtime" : "native";
680
680
  if (t.lane && t.lane !== u) {
681
681
  t.cursor = Math.max(t.cursor, n);
682
682
  return;
683
683
  }
684
684
  let d;
685
685
  try {
686
- d = u === "native" ? o(s.conversationItem) : t.runtime.apply(l);
686
+ d = u === "native" ? s(o.conversationItem) : t.runtime.apply(c);
687
687
  } catch (e) {
688
- throw new c("conversation_contract_mismatch", "Runtime conversation identity or lifecycle invariant failed.", { cause: e });
688
+ throw new l("conversation_contract_mismatch", "Runtime conversation identity or lifecycle invariant failed.", { cause: e });
689
689
  }
690
690
  if (u === "runtime" && !d) {
691
691
  t.cursor = Math.max(t.cursor, n);
692
692
  return;
693
693
  }
694
- if (!d) throw new c("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
695
- if (t.runId && t.runId !== d.runId) throw new c("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
694
+ if (!d) throw new l("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
695
+ if (t.runId && t.runId !== d.runId) throw new l("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
696
696
  runId: t.runId,
697
697
  cursor: t.cursor
698
698
  });
@@ -701,12 +701,12 @@ function ve(e, t) {
701
701
  try {
702
702
  f = u === "runtime" ? !0 : t.reducer.apply(d);
703
703
  } catch (e) {
704
- throw new c("conversation_contract_mismatch", "Conversation identity or lifecycle invariant failed.", { cause: e });
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?.(_e(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?.(F(t.reducer, t.cursor, t.runId, t.profile, t.lane === "runtime" ? t.runtime : void 0));
707
707
  }
708
708
  async function ye(e, t) {
709
- if (!e.body) throw new c("conversation_stream_error", "Conversation response has no event stream body.");
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 {
712
712
  for (;;) {
@@ -722,7 +722,7 @@ async function ye(e, t) {
722
722
  }
723
723
  i += r.decode(), i.trim() && ve(i, t);
724
724
  } catch (e) {
725
- throw e instanceof c ? e : (fe(e, t.options.signal) && P(t.options.signal), new c("conversation_stream_error", "Conversation event stream was interrupted.", {
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,
727
727
  runId: t.runId || void 0,
728
728
  cursor: t.cursor
@@ -743,13 +743,13 @@ var xe = class {
743
743
  sleep;
744
744
  retryDelayMs;
745
745
  constructor(e = {}) {
746
- if (!Number.isInteger(e.maxReconnects ?? M) || (e.maxReconnects ?? M) < 0 || (e.maxReconnects ?? M) > 32) throw new c("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
747
- this.fetcher = e.fetch, this.rendererCatalog = e.rendererCatalog, this.ingressLane = e.ingressLane, this.baseUrl = pe(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? M, this.sleep = e.sleep || he, this.retryDelayMs = e.retryDelayMs || me;
746
+ if (!Number.isInteger(e.maxReconnects ?? M) || (e.maxReconnects ?? M) < 0 || (e.maxReconnects ?? M) > 32) throw new l("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
747
+ this.fetcher = e.fetch, this.rendererCatalog = e.rendererCatalog, this.ingressLane = e.ingressLane, this.baseUrl = me(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? M, this.sleep = e.sleep || ge, this.retryDelayMs = e.retryDelayMs || he;
748
748
  }
749
749
  fetch() {
750
750
  if (this.fetcher) return this.fetcher;
751
751
  if (typeof globalThis.fetch == "function") return globalThis.fetch.bind(globalThis);
752
- throw new c("conversation_http_error", "No fetch implementation is available for the conversation client.");
752
+ throw new l("conversation_http_error", "No fetch implementation is available for the conversation client.");
753
753
  }
754
754
  url(e) {
755
755
  return `${this.baseUrl}${e}`;
@@ -759,24 +759,24 @@ var xe = class {
759
759
  try {
760
760
  return await this.fetch()(e, t);
761
761
  } catch (e) {
762
- throw e instanceof c ? e : (fe(e, n) && P(n), new c(r, "Conversation network request failed.", { cause: e }));
762
+ throw e instanceof l ? e : (pe(e, n) && P(n), new l(r, "Conversation network request failed.", { cause: e }));
763
763
  }
764
764
  }
765
765
  assertOk(e) {
766
- if (!e.ok) throw new c("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
766
+ if (!e.ok) throw new l("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
767
767
  }
768
768
  async getSurface(e, t, n = {}) {
769
- if (!e || !t) throw new c("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
769
+ if (!e || !t) throw new l("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
770
770
  let r = n.signal ? { signal: n.signal } : void 0, i = await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(t)}`), r, n.signal, "conversation_http_error");
771
771
  this.assertOk(i);
772
772
  let a;
773
773
  try {
774
774
  a = await i.json();
775
775
  } catch (e) {
776
- throw new c("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
776
+ throw new l("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
777
777
  }
778
- let o = N(a), s = u(o?.surface);
779
- if (!o || typeof o.buildId != "string" || !o.buildId || !s) throw new c("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
778
+ let o = N(a), s = d(o?.surface);
779
+ if (!o || typeof o.buildId != "string" || !o.buildId || !s) throw new l("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
780
780
  return {
781
781
  buildId: o.buildId,
782
782
  surface: s
@@ -784,23 +784,23 @@ var xe = class {
784
784
  }
785
785
  async streamTurn(e) {
786
786
  P(e.signal);
787
- let t = a(e.bootstrap.surface, this.rendererCatalog), n = {
787
+ let t = o(e.bootstrap.surface, this.rendererCatalog), n = {
788
788
  ...e.input,
789
789
  ...t === "agent-block-v1" || e.input.extensions?.["ksadk.presentation"] ? { extensions: {
790
790
  ...e.input.extensions,
791
791
  "ksadk.presentation": { profile: t }
792
792
  } } : {}
793
793
  };
794
- i(e.bootstrap.surface, n);
795
- let r = e.bootstrap.surface.outputs.find((e) => e.name === "agent.block"), o = r?.mode === "native" ? "native" : r?.mode === "translated" ? "runtime" : void 0;
796
- if (o && this.ingressLane && o !== this.ingressLane) throw new c("conversation_contract_mismatch", "Configured ingress lane disagrees with the conversation surface.");
797
- let s = o || this.ingressLane || "native", u = new l(), d = {
794
+ a(e.bootstrap.surface, n);
795
+ let r = e.bootstrap.surface.outputs.find((e) => e.name === "agent.block"), i = r?.mode === "native" ? "native" : r?.mode === "translated" ? "runtime" : void 0;
796
+ if (i && this.ingressLane && i !== this.ingressLane) throw new l("conversation_contract_mismatch", "Configured ingress lane disagrees with the conversation surface.");
797
+ let s = i || this.ingressLane || "native", c = new u(), d = {
798
798
  profile: t,
799
799
  lane: s,
800
- runtime: new C(n.sessionId, u, t),
800
+ runtime: new w(n.sessionId, c, t),
801
801
  cursor: 0,
802
802
  runId: "",
803
- reducer: u,
803
+ reducer: c,
804
804
  options: e
805
805
  }, f = {
806
806
  method: "POST",
@@ -815,13 +815,13 @@ var xe = class {
815
815
  try {
816
816
  await ye(p, d);
817
817
  } catch (e) {
818
- if (!(e instanceof c) || e.code !== "conversation_stream_error" || !d.runId) throw e;
818
+ if (!(e instanceof l) || e.code !== "conversation_stream_error" || !d.runId) throw e;
819
819
  }
820
- let m = _e(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0);
820
+ let m = F(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0);
821
821
  if (be(m)) return m;
822
- if (!d.runId) throw new c("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: d.cursor });
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
- await ge(this.sleep, this.retryDelayMs(t), e.signal), P(e.signal);
824
+ await _e(this.sleep, this.retryDelayMs(t), e.signal), P(e.signal);
825
825
  let n;
826
826
  try {
827
827
  n = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(d.runId)}/events?after=${d.cursor}${d.profile === "agent-block-v1" ? "&presentationProfile=agent-block-v1" : ""}`), {
@@ -830,12 +830,12 @@ var xe = class {
830
830
  ...e.signal ? { signal: e.signal } : {}
831
831
  }, e.signal), this.assertOk(n), await ye(n, d);
832
832
  } catch (e) {
833
- if (e instanceof c && e.code === "conversation_aborted" || e instanceof c && e.code === "conversation_contract_mismatch" || e instanceof c && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
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 = _e(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0), be(m)) return m;
836
+ if (m = F(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0), be(m)) return m;
837
837
  }
838
- throw new c("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
838
+ throw new l("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
839
839
  runId: d.runId,
840
840
  cursor: d.cursor
841
841
  });
@@ -874,7 +874,7 @@ var we = Ce([{
874
874
  }]);
875
875
  //#endregion
876
876
  //#region src/utils/history-tool-facts.ts
877
- function F(e, t) {
877
+ function I(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 F(e, t) {
882
882
  status: n(e.status) && !n(t.status) ? e.status : t.status
883
883
  };
884
884
  }
885
- function I(e) {
885
+ function L(e) {
886
886
  let t = e.map((e) => ({
887
887
  ...e,
888
888
  tools: e.tools ? { ...e.tools } : void 0
@@ -907,13 +907,13 @@ function I(e) {
907
907
  let r = e.message.tools[e.key], i = n ? {
908
908
  ...t,
909
909
  ...r,
910
- ...F(t, r)
910
+ ...I(t, r)
911
911
  } : {
912
912
  ...r,
913
913
  ...t,
914
- ...F(r, t)
914
+ ...I(r, t)
915
915
  };
916
- e.message.tools[e.key] = i, e.message.blocks = e.message.blocks?.map((e) => e.type === "tool" && e.extra?.callId === t.callId ? {
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,
918
918
  args: i.args,
919
919
  output: i.output,
@@ -946,22 +946,38 @@ function I(e) {
946
946
  }
947
947
  o(h, l), s(e, t, l.callId), c = !0;
948
948
  }
949
- return c ? t : e;
949
+ return c ? t.filter((e) => e.itemId || ![
950
+ "tool_result",
951
+ "stage_tool_result",
952
+ "tool_call",
953
+ "stage_tool_call"
954
+ ].includes(e.eventType || "") || e.content || e.reasoning || e.blocks?.length || e.attachments?.length || Object.keys(e.tools || {}).length) : e;
950
955
  }
951
956
  //#endregion
952
957
  //#region src/utils/transcript-order.ts
953
- var L = (e) => e.runId || e.invocationId;
954
- function R(e) {
958
+ var R = (e) => e.runId || e.invocationId;
959
+ function Te(e, t) {
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);
964
+ return r < 0 ? e : [
965
+ ...e.slice(0, r),
966
+ t,
967
+ ...e.slice(r)
968
+ ];
969
+ }
970
+ function z(e) {
955
971
  let t = /* @__PURE__ */ new Map();
956
972
  for (let n of e) {
957
- let e = L(n), r = n.historyOrder?.group;
973
+ let e = R(n), r = n.historyOrder?.group;
958
974
  e && r !== void 0 && t.set(e, Math.min(r, t.get(e) ?? r));
959
975
  }
960
976
  let n = e.map((e, n) => ({
961
977
  message: e,
962
978
  index: n,
963
979
  seq: e.historyOrder?.seq,
964
- group: e.historyOrder?.group ?? t.get(L(e) || "") ?? e.historyOrder?.seq,
980
+ group: e.historyOrder?.group ?? t.get(R(e) || "") ?? e.historyOrder?.seq,
965
981
  part: e.historyOrder?.index || 0
966
982
  })), r, i = n.map(() => void 0);
967
983
  for (let e = n.length - 1; e >= 0; e--) i[e] = r, n[e].group !== void 0 && (r = n[e].group);
@@ -976,54 +992,54 @@ function R(e) {
976
992
  side: 0
977
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);
978
994
  }
979
- function Te(e, t) {
995
+ function Ee(e, t) {
980
996
  if (!t) return !0;
981
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];
982
998
  return Object.keys(e).some(n) || Object.keys(t).some(n);
983
999
  }
984
- function Ee(e, t, n) {
985
- let r = new Map(t.map((e) => [e.id, e])), i = n.filter((e) => r.has(e.id) && r.get(e.id)?.feedback !== e.feedback), a = new Map(i.map((e) => [e.id, e.feedback])), o = (e) => JSON.stringify([L(e), e.responseId]), s = new Map(i.filter((e) => e.responseId).map((e) => [o(e), e.feedback])), c = (e) => e.map((e) => {
986
- if (a.has(e.id)) return {
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 {
987
1003
  ...e,
988
- feedback: a.get(e.id)
1004
+ feedback: o.get(e.id)
989
1005
  };
990
- let t = o(e);
991
- return e.responseId && s.has(t) ? {
1006
+ let t = s(e);
1007
+ return e.responseId && c.has(t) ? {
992
1008
  ...e,
993
- feedback: s.get(t)
1009
+ feedback: c.get(t)
994
1010
  } : e;
995
- }), l = n.filter((e) => Te(e, r.get(e.id)));
996
- if (!l.length) return D(I(c(e)));
997
- let u = new Set(l.map(L).filter(Boolean)), d = new Set(l.map((e) => e.id)), f = n.filter((e) => u.has(L(e)) || d.has(e.id)), p = e;
998
- for (let t of u) {
999
- let n = f.filter((e) => L(e) === t), r = e.filter((e) => L(e) === t), i = p.findIndex((e) => L(e) === t), a = n.some((e) => e.role === "user") ? [] : r.filter((e) => e.role === "user");
1000
- p = p.filter((e) => L(e) !== t);
1001
- let o = i < 0 ? p.length : Math.min(i, p.length);
1002
- p.splice(o, 0, ...a, ...n.map((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) => ({
1003
1019
  ...e,
1004
- historyOrder: e.historyOrder || r.find((t) => t.id === e.id)?.historyOrder
1020
+ historyOrder: e.historyOrder || a.find((t) => t.id === e.id)?.historyOrder
1005
1021
  })));
1006
1022
  }
1007
- for (let e of f.filter((e) => !L(e))) {
1008
- let t = p.findIndex((t) => t.id === e.id);
1023
+ for (let e of p.filter((e) => !R(e))) {
1024
+ let t = m.findIndex((t) => t.id === e.id);
1009
1025
  if (t < 0) {
1010
- let t = n.indexOf(e), r = n.slice(t + 1).find((e) => p.some((t) => t.id === e.id)), i = n.slice(0, t).findLast((e) => p.some((t) => t.id === e.id)), a = r ? p.findIndex((e) => e.id === r.id) : i ? p.findIndex((e) => e.id === i.id) + 1 : p.length;
1011
- p = [
1012
- ...p.slice(0, a),
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),
1013
1029
  e,
1014
- ...p.slice(a)
1030
+ ...m.slice(a)
1015
1031
  ];
1016
- } else p = p.map((n, r) => r === t ? {
1032
+ } else m = m.map((n, r) => r === t ? {
1017
1033
  ...e,
1018
1034
  historyOrder: e.historyOrder || n.historyOrder
1019
1035
  } : n);
1020
1036
  }
1021
- return D(I(c(R(p))));
1037
+ return te(L(l(z(m))));
1022
1038
  }
1023
1039
  //#endregion
1024
1040
  //#region src/core/conversation/hosted.ts
1025
- var De = "conversation_item_v1";
1026
- function z(e) {
1041
+ var Oe = "conversation_item_v1";
1042
+ function ke(e) {
1027
1043
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
1028
1044
  }
1029
1045
  function B(e) {
@@ -1042,17 +1058,17 @@ function H(e) {
1042
1058
  return {
1043
1059
  id: `conversation:${e.runId}:${e.itemId}`,
1044
1060
  timestamp: 0,
1045
- eventType: De,
1061
+ eventType: Oe,
1046
1062
  eventId: e.sourceEventIds.at(-1),
1047
1063
  runId: e.runId,
1048
1064
  itemId: e.itemId,
1049
1065
  status: e.lifecycle === "failed" ? "failed" : e.lifecycle === "completed" ? "completed" : "running"
1050
1066
  };
1051
1067
  }
1052
- function Oe(e) {
1068
+ function Ae(e) {
1053
1069
  return e.lifecycle === "failed" ? "error" : e.lifecycle === "completed" ? "done" : "streaming";
1054
1070
  }
1055
- function ke(e) {
1071
+ function je(e) {
1056
1072
  let t = typeof e.payload.text == "string" ? e.payload.text : "";
1057
1073
  if (e.kind === "user_message") return {
1058
1074
  ...H(e),
@@ -1064,13 +1080,13 @@ function ke(e) {
1064
1080
  id: `conversation-block:${e.itemId}`,
1065
1081
  type: "thinking",
1066
1082
  content: t,
1067
- status: Oe(e),
1083
+ status: Ae(e),
1068
1084
  ...e.payload.presentationSource === "public_summary" || e.payload.presentationSource === "provider_reasoning" ? { source: e.payload.presentationSource } : {}
1069
1085
  } : {
1070
1086
  id: `conversation-block:${e.itemId}`,
1071
1087
  type: "text",
1072
1088
  content: t,
1073
- status: Oe(e)
1089
+ status: Ae(e)
1074
1090
  };
1075
1091
  return {
1076
1092
  ...H(e),
@@ -1080,8 +1096,8 @@ function ke(e) {
1080
1096
  blocks: [n]
1081
1097
  };
1082
1098
  }
1083
- function Ae(e, t = !1) {
1084
- let n = B(e.payload.tool) || (e.payload.sourceKind === "tool_result" ? "Tool result" : "Tool"), r = B(e.payload.callId), i = V(v(e.payload.args)), a = Object.prototype.hasOwnProperty.call(e.payload, "output") ? V(y(e.payload.output, e.nativeRef.framework, e.nativeRef.protocol)) : void 0, o = {
1099
+ function Me(e, t = !1) {
1100
+ 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 = {
1085
1101
  failed: "error",
1086
1102
  completed: "completed",
1087
1103
  running: "running",
@@ -1109,48 +1125,48 @@ function Ae(e, t = !1) {
1109
1125
  } }
1110
1126
  };
1111
1127
  }
1112
- function je(e) {
1128
+ function Ne(e) {
1113
1129
  return e === "structured_input" ? "structured_input" : e === "plan_review" ? "plan_review" : e === "custom" ? "custom" : "approval";
1114
1130
  }
1115
- function Me(t) {
1116
- let n = B(t.payload.interactionId), r = t.payload.revision;
1131
+ function Pe(e) {
1132
+ let n = B(e.payload.interactionId), r = e.payload.revision;
1117
1133
  if (!n || !Number.isInteger(r) || Number(r) < 1) return null;
1118
- let i = V(t.payload.detail), a = B(t.payload.prompt) || i, o = je(t.payload.interactionKind), s = t.lifecycle === "completed", c = {};
1119
- if (s && Object.hasOwn(t.payload, "response")) try {
1120
- c = { response: e(t.payload.response) };
1134
+ let i = V(e.payload.detail), a = B(e.payload.prompt) || i, o = Ne(e.payload.interactionKind), s = e.lifecycle === "completed", c = {};
1135
+ if (s && Object.hasOwn(e.payload, "response")) try {
1136
+ c = { response: t(e.payload.response) };
1121
1137
  } catch {}
1122
1138
  return {
1123
1139
  interactionId: n,
1124
- sessionId: t.sessionId,
1125
- runId: t.runId,
1140
+ sessionId: e.sessionId,
1141
+ runId: e.runId,
1126
1142
  kind: o,
1127
- title: B(t.payload.title) || (o === "approval" ? `审批:${B(t.payload.kind) || "操作"}` : "需要补充信息"),
1143
+ title: B(e.payload.title) || (o === "approval" ? `审批:${B(e.payload.kind) || "操作"}` : "需要补充信息"),
1128
1144
  message: a || "运行需要人工确认。",
1129
- requestSchema: z(t.payload.inputSchema),
1145
+ requestSchema: ke(e.payload.inputSchema),
1130
1146
  presentation: null,
1131
1147
  status: s ? "resolved" : "pending",
1132
1148
  revision: Number(r),
1133
- createdAt: B(t.payload.createdAt) || "",
1134
- expiresAt: B(t.payload.expiresAt),
1135
- resolvedAt: s ? B(t.payload.resolvedAt) : null,
1136
- actor: s ? B(t.payload.actor) : null,
1149
+ createdAt: B(e.payload.createdAt) || "",
1150
+ expiresAt: B(e.payload.expiresAt),
1151
+ resolvedAt: s ? B(e.payload.resolvedAt) : null,
1152
+ actor: s ? B(e.payload.actor) : null,
1137
1153
  outcome: s && [
1138
1154
  "approved",
1139
1155
  "rejected",
1140
1156
  "submitted",
1141
1157
  "cancelled",
1142
1158
  "expired"
1143
- ].includes(String(t.payload.outcome || "")) ? t.payload.outcome : null,
1144
- responseSummary: s ? B(t.payload.responseSummary) : null,
1159
+ ].includes(String(e.payload.outcome || "")) ? e.payload.outcome : null,
1160
+ responseSummary: s ? B(e.payload.responseSummary) : null,
1145
1161
  ...c,
1146
1162
  source: "interaction_v1",
1147
1163
  extensions: {
1148
- conversation_item_id: t.itemId,
1149
- ...B(t.payload.callId) ? { call_id: B(t.payload.callId) } : {}
1164
+ conversation_item_id: e.itemId,
1165
+ ...B(e.payload.callId) ? { call_id: B(e.payload.callId) } : {}
1150
1166
  }
1151
1167
  };
1152
1168
  }
1153
- function Ne(e, t) {
1169
+ function Fe(e, t) {
1154
1170
  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 = {
1155
1171
  approvalRequestId: t.interactionId,
1156
1172
  approvalStatus: i,
@@ -1178,24 +1194,24 @@ function Ne(e, t) {
1178
1194
  } }
1179
1195
  };
1180
1196
  }
1181
- function Pe(e) {
1197
+ function Ie(e) {
1182
1198
  for (let t of [
1183
1199
  "createSurface",
1184
1200
  "updateComponents",
1185
1201
  "updateDataModel",
1186
1202
  "deleteSurface"
1187
1203
  ]) {
1188
- let n = B(z(e[t])?.surfaceId);
1204
+ let n = B(ke(e[t])?.surfaceId);
1189
1205
  if (n) return n;
1190
1206
  }
1191
1207
  return null;
1192
1208
  }
1193
- function Fe(e) {
1209
+ function Le(e) {
1194
1210
  let t = Array.isArray(e.payload.data) ? e.payload.data : Array.isArray(e.payload.operations) ? e.payload.operations : null;
1195
1211
  if (!t) return null;
1196
- let n = t.map(z);
1212
+ let n = t.map(ke);
1197
1213
  if (n.some((e) => e === null)) return null;
1198
- let r = n, i = B(e.payload.surfaceId) || r.map(Pe).find((e) => e !== null) || null;
1214
+ let r = n, i = B(e.payload.surfaceId) || r.map(Ie).find((e) => e !== null) || null;
1199
1215
  return i ? {
1200
1216
  ...H(e),
1201
1217
  role: "a2ui",
@@ -1215,10 +1231,10 @@ function U(e, t, n, r = !1) {
1215
1231
  status: r ? "failed" : H(e).status
1216
1232
  };
1217
1233
  }
1218
- function Ie(e) {
1234
+ function Re(e) {
1219
1235
  for (let { item: t } of [...e].reverse()) {
1220
1236
  if (t.visibility !== "public" || t.kind !== "assistant_text" || t.payloadSchemaRef !== "conversation.item.assistant_text/v1" || typeof t.payload.text != "string") continue;
1221
- let e = v(t.payload.text);
1237
+ let e = y(t.payload.text);
1222
1238
  if (typeof e != "string" || e === "[redacted]") continue;
1223
1239
  let n = e.replace(/\s+/g, " ").trim();
1224
1240
  if (!n) continue;
@@ -1249,27 +1265,27 @@ function W(e) {
1249
1265
  agentBlock: {
1250
1266
  item: f,
1251
1267
  messages: n.messages,
1252
- summary: Ie(d.children || [])
1268
+ summary: Re(d.children || [])
1253
1269
  },
1254
1270
  status: f.payload.status === "cancelled" ? "cancelled" : H(f).status
1255
1271
  }), u.push(...n.interactions);
1256
1272
  continue;
1257
1273
  }
1258
1274
  if (n.has(f.itemId)) {
1259
- l.push(ke(f));
1275
+ l.push(je(f));
1260
1276
  continue;
1261
1277
  }
1262
1278
  if (r.has(f.itemId)) {
1263
- l.push(Ae(f, !!t.terminalStatus && f.runId === e.runId));
1279
+ l.push(Me(f, !!t.terminalStatus && f.runId === e.runId));
1264
1280
  continue;
1265
1281
  }
1266
1282
  if (i.has(f.itemId) || a.has(f.itemId)) {
1267
- let e = Me(f);
1268
- e ? (u.push(e), l.push(Ne(f, e))) : l.push(U(f, "Interaction unavailable", "The server did not provide a durable interaction revision; this card is read-only."));
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."));
1269
1285
  continue;
1270
1286
  }
1271
1287
  if (o.has(f.itemId)) {
1272
- let e = Fe(f);
1288
+ let e = Le(f);
1273
1289
  l.push(e || U(f, "Unsupported content", "A2UI payload is not a valid passive operation list."));
1274
1290
  continue;
1275
1291
  }
@@ -1317,7 +1333,7 @@ function W(e) {
1317
1333
  interactions: u
1318
1334
  };
1319
1335
  }
1320
- function Le(e, t, n) {
1336
+ function ze(e, t, n) {
1321
1337
  let r = W(t).messages;
1322
1338
  if (!r.length) return e;
1323
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") ? [{
@@ -1334,9 +1350,9 @@ function Le(e, t, n) {
1334
1350
  }
1335
1351
  //#endregion
1336
1352
  //#region src/core/run/blocks.ts
1337
- var Re = 0;
1353
+ var Be = 0;
1338
1354
  function G(e) {
1339
- return Re += 1, `${e}-${Re}`;
1355
+ return Be += 1, `${e}-${Be}`;
1340
1356
  }
1341
1357
  function K(e) {
1342
1358
  return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
@@ -1344,19 +1360,31 @@ function K(e) {
1344
1360
  status: "done"
1345
1361
  } : e);
1346
1362
  }
1347
- function ze(e, t) {
1348
- let n = [...e ?? []], r = n[n.length - 1];
1349
- return r?.type === "thinking" && r.status === "streaming" ? (n[n.length - 1] = {
1350
- ...r,
1351
- content: r.content + t
1352
- }, n) : [...n, {
1363
+ function Ve(e, t, n) {
1364
+ let r = [...e ?? []], i = r[r.length - 1];
1365
+ return i?.type === "thinking" && i.status === "streaming" && i.itemId === n ? (r[r.length - 1] = {
1366
+ ...i,
1367
+ content: i.content + t
1368
+ }, r) : [...K(r), {
1353
1369
  id: G("thinking"),
1354
1370
  type: "thinking",
1355
1371
  content: t,
1356
- status: "streaming"
1372
+ status: "streaming",
1373
+ ...n && { itemId: n }
1357
1374
  }];
1358
1375
  }
1359
- function Be(e, t) {
1376
+ function He(e, t, n) {
1377
+ let r = (e) => e.type === "thinking" && e.itemId === t, i = e.findLastIndex(r), a = 0;
1378
+ return e.flatMap((e, t) => {
1379
+ if (!r(e)) return [e];
1380
+ let o = t === i ? n.length : a + e.content.length, s = n.slice(a, o);
1381
+ return a = o, s ? [{
1382
+ ...e,
1383
+ content: s
1384
+ }] : [];
1385
+ });
1386
+ }
1387
+ function Ue(e, t) {
1360
1388
  let n = [...K(e ?? [])], r = n[n.length - 1];
1361
1389
  return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
1362
1390
  ...r,
@@ -1368,17 +1396,11 @@ function Be(e, t) {
1368
1396
  status: "streaming"
1369
1397
  }];
1370
1398
  }
1371
- function Ve(e, t) {
1399
+ function We(e, t) {
1372
1400
  let n = e ?? [], r = n.filter((e) => e.type === "text").map((e) => e.content).join("");
1373
1401
  if (r === t) return n;
1374
- let i = n.flatMap((e, t) => e.type === "text" ? [t] : []);
1375
- if (!i.length) return [...n, {
1376
- id: G("text"),
1377
- type: "text",
1378
- content: t,
1379
- status: "streaming"
1380
- }];
1381
- let a = 0;
1402
+ if (t.startsWith(r) && n.at(-1)?.type !== "text") return Ue(n, t.slice(r.length));
1403
+ let i = n.flatMap((e, t) => e.type === "text" ? [t] : []), a = 0;
1382
1404
  for (; a < r.length && a < t.length && r[a] === t[a];) a++;
1383
1405
  let o = 0;
1384
1406
  for (; o < r.length - a && o < t.length - a && r[r.length - o - 1] === t[t.length - o - 1];) o++;
@@ -1397,25 +1419,29 @@ function Ve(e, t) {
1397
1419
  };
1398
1420
  });
1399
1421
  }
1400
- function He(e, t) {
1401
- let n = K(e ?? []);
1402
- if (n.filter((e) => e.type === "text").map((e) => e.content).join("") === t) return n.map((e) => e.type === "text" && e.status === "streaming" ? {
1422
+ function Ge(e, t) {
1423
+ let n = K(e ?? []), r = n.flatMap((e) => e.type === "text" ? [e.content] : []).join(""), i = n.at(-1), a = n;
1424
+ if (t !== r && i?.type !== "text") {
1425
+ let e = t.startsWith(r) ? t.slice(r.length) : t;
1426
+ e && (a = [...n, {
1427
+ id: G("text"),
1428
+ type: "text",
1429
+ content: e,
1430
+ status: "done"
1431
+ }]);
1432
+ } else if (i?.type === "text" && t !== r && t !== i.content) {
1433
+ let e = r.slice(0, r.length - i.content.length), o = t.startsWith(e) ? t.slice(e.length) : t;
1434
+ a = [...n.slice(0, -1), {
1435
+ ...i,
1436
+ content: o
1437
+ }];
1438
+ }
1439
+ return a.map((e) => e.type === "text" && e.status === "streaming" ? {
1403
1440
  ...e,
1404
1441
  status: "done"
1405
1442
  } : e);
1406
- let r = [...n], i = r.map((e) => e.type).lastIndexOf("text");
1407
- return i >= 0 && r[i].type === "text" ? (r[i] = {
1408
- ...r[i],
1409
- content: t,
1410
- status: "done"
1411
- }, r) : [...r, {
1412
- id: G("text"),
1413
- type: "text",
1414
- content: t,
1415
- status: "done"
1416
- }];
1417
1443
  }
1418
- function Ue(e, t) {
1444
+ function Ke(e, t) {
1419
1445
  if (!t) return [...e ?? []];
1420
1446
  let n = [...e ?? []], r = n[n.length - 1];
1421
1447
  if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
@@ -1425,19 +1451,22 @@ function Ue(e, t) {
1425
1451
  content: i
1426
1452
  }, n) : (n.pop(), n);
1427
1453
  }
1428
- function We(e, t, n) {
1429
- let r = [...K(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
1430
- if (i >= 0 && r[i].type === "tool") {
1431
- 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);
1432
- if (t && !a && !o) return r;
1433
- let s = n.extra ?? e.extra;
1434
- return r[i] = {
1454
+ function qe(e, t, n) {
1455
+ let r = [...e ?? []], i = n.extra?.callId, a = i ? r.findIndex((e) => e.type === "tool" && e.extra?.callId === i && e.toolName === t) : -1;
1456
+ 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
+ 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);
1458
+ if (t && !i && !o) return r;
1459
+ let s = n.extra ? {
1460
+ ...e.extra,
1461
+ ...n.extra
1462
+ } : e.extra;
1463
+ return r[a] = {
1435
1464
  ...e,
1436
1465
  ...n,
1437
1466
  extra: s
1438
1467
  }, r;
1439
1468
  }
1440
- return [...r, {
1469
+ return [...K(r), {
1441
1470
  id: G("tool"),
1442
1471
  type: "tool",
1443
1472
  toolName: t,
@@ -1447,10 +1476,10 @@ function We(e, t, n) {
1447
1476
  extra: n.extra
1448
1477
  }];
1449
1478
  }
1450
- function Ge(e) {
1479
+ function Je(e) {
1451
1480
  return K(e ?? []);
1452
1481
  }
1453
- function Ke(e) {
1482
+ function Ye(e) {
1454
1483
  let t = [];
1455
1484
  if (e.reasoning && e.reasoning.trim() && t.push({
1456
1485
  id: G("thinking"),
@@ -1479,14 +1508,14 @@ function Ke(e) {
1479
1508
  }
1480
1509
  //#endregion
1481
1510
  //#region src/core/stream/kernel-events.ts
1482
- var qe = {
1511
+ var Xe = {
1483
1512
  "run.started": "in_progress",
1484
1513
  "run.progress": "in_progress",
1485
1514
  "run.completed": "completed",
1486
1515
  "run.failed": "failed",
1487
1516
  "run.canceled": "cancelled",
1488
1517
  "run.interrupted": "interrupted"
1489
- }, Je = new Set([
1518
+ }, Ze = new Set([
1490
1519
  "completed",
1491
1520
  "failed",
1492
1521
  "cancelled",
@@ -1495,7 +1524,7 @@ var qe = {
1495
1524
  function q(e) {
1496
1525
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
1497
1526
  }
1498
- function Ye(e) {
1527
+ function Qe(e) {
1499
1528
  let t = q(e.source), n = t ? q(t.metadata) : null;
1500
1529
  return String(n?.native_item_kind || "");
1501
1530
  }
@@ -1505,7 +1534,7 @@ function J(e, t) {
1505
1534
  let r = n?.parts;
1506
1535
  return Array.isArray(r) ? r : t === "update" ? [n] : [];
1507
1536
  }
1508
- function Xe(e) {
1537
+ function $e(e) {
1509
1538
  let t = q(e);
1510
1539
  if (!t) return "";
1511
1540
  if (typeof t.text == "string") return t.text;
@@ -1523,9 +1552,9 @@ function Xe(e) {
1523
1552
  return "";
1524
1553
  }
1525
1554
  function Y(e) {
1526
- return e.map(Xe).join("");
1555
+ return e.map($e).join("");
1527
1556
  }
1528
- function Ze(e) {
1557
+ function et(e) {
1529
1558
  return e.some((e) => q(q(e)?.data)?.type === "userMessage");
1530
1559
  }
1531
1560
  function X(e) {
@@ -1535,18 +1564,18 @@ function X(e) {
1535
1564
  }
1536
1565
  return Y(e) || null;
1537
1566
  }
1538
- function Qe(e) {
1567
+ function tt(e) {
1539
1568
  let t = q(e);
1540
1569
  return t ? q(t.data) || t : null;
1541
1570
  }
1542
- function $e(e) {
1543
- let t = Qe(e);
1571
+ function nt(e) {
1572
+ let t = tt(e);
1544
1573
  return String(t?.content_type || t?.type || "").trim().toLowerCase();
1545
1574
  }
1546
- function et(e) {
1575
+ function rt(e) {
1547
1576
  for (let t of e) {
1548
- let e = Qe(t);
1549
- if (!e || $e(t) !== "tool_call") continue;
1577
+ let e = tt(t);
1578
+ if (!e || nt(t) !== "tool_call") continue;
1550
1579
  let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
1551
1580
  if (!(!n && !r)) return {
1552
1581
  callId: n,
@@ -1556,10 +1585,10 @@ function et(e) {
1556
1585
  }
1557
1586
  return null;
1558
1587
  }
1559
- function tt(e) {
1588
+ function it(e) {
1560
1589
  for (let t of e) {
1561
- let e = Qe(t);
1562
- if (!e || $e(t) !== "tool_result") continue;
1590
+ let e = tt(t);
1591
+ if (!e || nt(t) !== "tool_result") continue;
1563
1592
  let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
1564
1593
  return {
1565
1594
  callId: n,
@@ -1581,7 +1610,7 @@ function Z(e, t, n, r) {
1581
1610
  ...i && i !== a ? { SourceItemId: i } : {}
1582
1611
  } };
1583
1612
  }
1584
- var nt = class {
1613
+ var at = class {
1585
1614
  textByPart = /* @__PURE__ */ new Map();
1586
1615
  toolNameByCallId = /* @__PURE__ */ new Map();
1587
1616
  toolCallByItemId = /* @__PURE__ */ new Map();
@@ -1613,7 +1642,7 @@ var nt = class {
1613
1642
  };
1614
1643
  if (r === "control.run_transition") {
1615
1644
  let t = String(e.state || "").toLowerCase();
1616
- if (Je.has(t)) return {
1645
+ if (Ze.has(t)) return {
1617
1646
  ...a(),
1618
1647
  EventType: "run_status",
1619
1648
  Content: { status: t }
@@ -1624,17 +1653,17 @@ var nt = class {
1624
1653
  if (n !== "runtime") return null;
1625
1654
  let o = q(q(e.source)?.metadata), s = o?.conversation_visibility ?? o?.visibility;
1626
1655
  if (r.startsWith("item.") && ["internal", "hidden"].includes(String(s))) return null;
1627
- let c = qe[r];
1656
+ let c = Xe[r];
1628
1657
  if (c) return {
1629
1658
  ...a(),
1630
1659
  EventType: "run_status",
1631
1660
  Content: { status: c }
1632
1661
  };
1633
- let l = Ye(e);
1662
+ let l = Qe(e);
1634
1663
  if (r === "item.started") {
1635
1664
  let t = J(e, "initial");
1636
1665
  if (e.item_kind === "tool_call") {
1637
- let n = et(t);
1666
+ let n = rt(t);
1638
1667
  if (!n) return null;
1639
1668
  let r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
1640
1669
  return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
@@ -1652,7 +1681,7 @@ var nt = class {
1652
1681
  }
1653
1682
  };
1654
1683
  }
1655
- return e.item_kind === "tool_result" || l === "userMessage" || Ze(t) || l === "reasoning" || e.item_kind === "reasoning" ? null : l === "agentMessage" || !l && e.item_kind === "message" ? {
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" ? {
1656
1685
  ...a(),
1657
1686
  EventType: "assistant_stream_snapshot",
1658
1687
  Content: { parts: [{ text: "" }] },
@@ -1672,7 +1701,7 @@ var nt = class {
1672
1701
  if (r === "item.updated") {
1673
1702
  let n = J(e, "update");
1674
1703
  if (e.item_kind === "tool_call") {
1675
- let t = tt(n);
1704
+ let t = it(n);
1676
1705
  if (!t) return null;
1677
1706
  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;
1678
1707
  return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
@@ -1717,7 +1746,7 @@ var nt = class {
1717
1746
  if (r === "item.completed") {
1718
1747
  let n = J(e, "snapshot");
1719
1748
  if (e.item_kind === "tool_call") {
1720
- let t = et(n), r = tt(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";
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";
1721
1750
  if (s && this.toolNameByCallId.set(s, c), r) {
1722
1751
  let t = r.isError ? { error: r.result } : r.result;
1723
1752
  return {
@@ -1745,7 +1774,7 @@ var nt = class {
1745
1774
  };
1746
1775
  }
1747
1776
  if (e.item_kind === "tool_result") {
1748
- let t = tt(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);
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);
1749
1778
  return {
1750
1779
  ...a(),
1751
1780
  EventType: "tool_result",
@@ -1758,7 +1787,7 @@ var nt = class {
1758
1787
  }
1759
1788
  };
1760
1789
  }
1761
- if (l === "userMessage" || Ze(n)) return {
1790
+ if (l === "userMessage" || et(n)) return {
1762
1791
  ...a(),
1763
1792
  EventType: "user_message",
1764
1793
  Content: { parts: [{ text: Y(n) }] }
@@ -1823,7 +1852,7 @@ var nt = class {
1823
1852
  return null;
1824
1853
  }
1825
1854
  };
1826
- async function rt(e) {
1855
+ async function ot(e) {
1827
1856
  let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
1828
1857
  try {
1829
1858
  for (;;) {
@@ -1833,8 +1862,8 @@ async function rt(e) {
1833
1862
  break;
1834
1863
  }
1835
1864
  if (r.trimStart().startsWith("{")) {
1836
- if (it(r)) {
1837
- i = at(r);
1865
+ if (st(r)) {
1866
+ i = ct(r);
1838
1867
  break;
1839
1868
  }
1840
1869
  } else if (o(r)) break;
@@ -1870,7 +1899,7 @@ async function rt(e) {
1870
1899
  stream: c
1871
1900
  };
1872
1901
  }
1873
- function it(e) {
1902
+ function st(e) {
1874
1903
  let t = e.trim();
1875
1904
  if (!t.endsWith("}")) return !1;
1876
1905
  let n = 0, r = !1, i = !1;
@@ -1887,7 +1916,7 @@ function it(e) {
1887
1916
  }
1888
1917
  return n === 0;
1889
1918
  }
1890
- function at(e) {
1919
+ function ct(e) {
1891
1920
  try {
1892
1921
  let t = q(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1893
1922
  if (!n) return null;
@@ -1913,8 +1942,8 @@ function at(e) {
1913
1942
  function Q(e) {
1914
1943
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
1915
1944
  }
1916
- function ot(e) {
1917
- let t = e.map(ct), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t, n) => JSON.stringify([
1945
+ function lt(e) {
1946
+ let t = e.map(ft), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t, n) => JSON.stringify([
1918
1947
  e,
1919
1948
  t,
1920
1949
  n
@@ -1942,7 +1971,7 @@ function ot(e) {
1942
1971
  } : e;
1943
1972
  });
1944
1973
  }
1945
- function st(e) {
1974
+ function ut(e) {
1946
1975
  if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
1947
1976
  if (typeof e == "string" && e.trim()) {
1948
1977
  let t = Number(e.trim());
@@ -1951,7 +1980,78 @@ function st(e) {
1951
1980
  let t = Date.parse(String(e || ""));
1952
1981
  return Number.isFinite(t) ? t : Date.now();
1953
1982
  }
1954
- function ct(e) {
1983
+ function dt(e, t, r, i, a) {
1984
+ let o = /* @__PURE__ */ new Set(), s = (e, t) => JSON.stringify([e, t]), c = /* @__PURE__ */ new Set();
1985
+ for (let e of t) {
1986
+ let t = n(e, i);
1987
+ t?.kind === "approval" && t.outcome === "rejected" && t.runId && (o.add(t.runId), c.add(s(t.runId, t.interactionId)));
1988
+ }
1989
+ let l = /* @__PURE__ */ new Map();
1990
+ for (let e of r) {
1991
+ if (e?.item_kind !== "data" || e.event_type !== "item.completed" || typeof e.run_id != "string" || typeof e.scope_id != "string" || Q(e.source)?.framework !== "langgraph") continue;
1992
+ let t = Q(e.snapshot)?.parts;
1993
+ if (Array.isArray(t)) for (let n of t) {
1994
+ let t = Q(Q(Q(n)?.data)?.["HumanInTheLoopMiddleware.after_model"]);
1995
+ if (Array.isArray(t?.messages)) for (let n of t.messages.map(Q)) {
1996
+ if (n?.type !== "tool" || n.status !== "error" || typeof n.tool_call_id != "string") continue;
1997
+ o.add(e.run_id);
1998
+ let t = s(e.run_id, n.tool_call_id), r = l.get(t) ?? /* @__PURE__ */ new Set();
1999
+ r.add(e.scope_id), l.set(t, r);
2000
+ }
2001
+ }
2002
+ }
2003
+ if (!o.size) return e;
2004
+ let u = /* @__PURE__ */ new Set();
2005
+ for (let t of e) {
2006
+ let e = t.invocationId || t.runId;
2007
+ if (!(!t.scopeId || !e || !o.has(e))) for (let n of Object.values(t.tools || {})) n.callId && u.add(s(e, n.callId));
2008
+ }
2009
+ let d = (e) => {
2010
+ if (e.agentBlock) return {
2011
+ ...e,
2012
+ agentBlock: {
2013
+ ...e.agentBlock,
2014
+ messages: e.agentBlock.messages.map(d)
2015
+ }
2016
+ };
2017
+ let t = e.invocationId || e.runId;
2018
+ if (!t || !o.has(t) || e.role !== "model") return e;
2019
+ let n = (n, r, i) => {
2020
+ if (![
2021
+ "running",
2022
+ "paused",
2023
+ "unknown"
2024
+ ].includes(i)) return;
2025
+ let o = typeof n == "string" ? s(t, n) : "", d = l.get(o);
2026
+ if (typeof r == "string" && c.has(s(t, r)) || d && (e.scopeId ? d.has(e.scopeId) : d.size === 1 && !u.has(o))) return {
2027
+ status: "completed",
2028
+ approvalStatus: "rejected"
2029
+ };
2030
+ if (i !== "unknown" && a.has(t)) return { status: "unknown" };
2031
+ };
2032
+ return {
2033
+ ...e,
2034
+ tools: e.tools && Object.fromEntries(Object.entries(e.tools).map(([e, t]) => [e, {
2035
+ ...t,
2036
+ ...n(t.callId, t.approvalRequestId, t.status)
2037
+ }])),
2038
+ blocks: e.blocks?.map((e) => {
2039
+ if (e.type !== "tool") return e;
2040
+ let t = n(e.extra?.callId, e.extra?.approvalRequestId, e.status);
2041
+ return t ? {
2042
+ ...e,
2043
+ status: t.status,
2044
+ extra: {
2045
+ ...e.extra,
2046
+ ...t.approvalStatus ? { approvalStatus: t.approvalStatus } : {}
2047
+ }
2048
+ } : e;
2049
+ })
2050
+ };
2051
+ };
2052
+ return e.map(d);
2053
+ }
2054
+ function ft(e) {
1955
2055
  let t = Q(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
1956
2056
  if (t && String(t.event_type || "")) return {
1957
2057
  ...t,
@@ -1971,58 +2071,58 @@ function ct(e) {
1971
2071
  timestamp: e.Timestamp || n.timestamp || r.timestamp
1972
2072
  };
1973
2073
  }
1974
- function lt(e, n, r) {
2074
+ function pt(e, t, n) {
1975
2075
  let i = /* @__PURE__ */ new Map();
1976
- for (let e of n) {
1977
- if (e.EventType !== "run_status" || ct(e)) continue;
2076
+ for (let e of t) {
2077
+ if (e.EventType !== "run_status" || ft(e)) continue;
1978
2078
  let t = String(e.InvocationId || e.Metadata?.run_id || "").trim();
1979
- t && !r.has(t) && i.set(t, e);
2079
+ t && !n.has(t) && i.set(t, e);
1980
2080
  }
1981
2081
  let a = e;
1982
- for (let [e, n] of i) {
1983
- let r = t({
1984
- ...n,
1985
- EventId: n.EventId || `legacy-terminal:${e}:${n.SeqId || 0}`,
1986
- Timestamp: st(n.Timestamp)
2082
+ for (let [e, t] of i) {
2083
+ let n = r({
2084
+ ...t,
2085
+ EventId: t.EventId || `legacy-terminal:${e}:${t.SeqId || 0}`,
2086
+ Timestamp: ut(t.Timestamp)
1987
2087
  });
1988
- if (!r) continue;
2088
+ if (!n) continue;
1989
2089
  let i = (t) => (t.invocationId || t.runId) === e;
1990
2090
  a = a.filter((e) => !(i(e) && e.role === "system" && e.eventType === "run_status")).map((e) => {
1991
2091
  if (!i(e) || e.role !== "model") return e;
1992
- let t = (e) => e === "running" || e === "paused", n = "运行已结束,未记录此工具的最终结果。";
2092
+ let t = (e) => e === "running" || e === "paused", r = "运行已结束,未记录此工具的最终结果。";
1993
2093
  return {
1994
2094
  ...e,
1995
- tools: e.tools && Object.fromEntries(Object.entries(e.tools).map(([e, r]) => [e, t(r.status) ? {
1996
- ...r,
2095
+ tools: e.tools && Object.fromEntries(Object.entries(e.tools).map(([e, n]) => [e, t(n.status) ? {
2096
+ ...n,
1997
2097
  status: "unknown",
1998
- summary: r.summary || n
1999
- } : r])),
2098
+ summary: n.summary || r
2099
+ } : n])),
2000
2100
  blocks: e.blocks?.map((e) => e.type === "thinking" && e.status === "streaming" ? {
2001
2101
  ...e,
2002
2102
  status: "done"
2003
2103
  } : e.type !== "tool" || !t(e.status) ? e : {
2004
2104
  ...e,
2005
2105
  status: "unknown",
2006
- summary: e.summary || n,
2106
+ summary: e.summary || r,
2007
2107
  extra: {
2008
2108
  ...e.extra,
2009
2109
  persistedToolStatus: e.status,
2010
- terminalRunStatus: r.status
2110
+ terminalRunStatus: n.status
2011
2111
  }
2012
2112
  })
2013
2113
  };
2014
2114
  }), a.push({
2015
- ...r,
2115
+ ...n,
2016
2116
  invocationId: e,
2017
- eventId: n.EventId
2117
+ eventId: t.EventId
2018
2118
  });
2019
2119
  }
2020
- return a === e ? e : R(a);
2120
+ return a === e ? e : z(a);
2021
2121
  }
2022
2122
  function $(e) {
2023
2123
  return e.role === "model" ? {
2024
2124
  ...e,
2025
- blocks: e.blocks?.length ? e.blocks : Ke({
2125
+ blocks: e.blocks?.length ? e.blocks : Ye({
2026
2126
  content: e.content,
2027
2127
  reasoning: e.reasoning,
2028
2128
  reasoningSource: e.reasoningSource,
@@ -2030,7 +2130,7 @@ function $(e) {
2030
2130
  })
2031
2131
  } : e;
2032
2132
  }
2033
- function ut(e, t) {
2133
+ function mt(e, t) {
2034
2134
  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 ? {
2035
2135
  ...e,
2036
2136
  ...n,
@@ -2043,7 +2143,7 @@ function ut(e, t) {
2043
2143
  } : e));
2044
2144
  return n && !r ? [n, ...s] : s;
2045
2145
  }
2046
- function dt(e, t) {
2146
+ function ht(e, t) {
2047
2147
  let n = t.filter((e) => e.role === "model"), r = n.flatMap((e) => Object.values(e.tools || {}).map((t) => ({
2048
2148
  tool: t,
2049
2149
  scope: e.scopeId
@@ -2058,7 +2158,7 @@ function dt(e, t) {
2058
2158
  return [t, r ? {
2059
2159
  ...n,
2060
2160
  ...r,
2061
- ...F(n, r),
2161
+ ...I(n, r),
2062
2162
  name: n.name
2063
2163
  } : n];
2064
2164
  })), n = e === s ? a : [];
@@ -2071,9 +2171,9 @@ function dt(e, t) {
2071
2171
  let n = t.extra?.callId, r = typeof n == "string" ? i(n, e.scopeId) : void 0;
2072
2172
  return r ? {
2073
2173
  ...t,
2074
- ...F(t, r)
2174
+ ...I(t, r)
2075
2175
  } : t;
2076
- }), c = Ke({ 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;
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;
2077
2177
  return $({
2078
2178
  ...e,
2079
2179
  ...e === s ? { reasoning: e.reasoning || o || void 0 } : {},
@@ -2086,21 +2186,21 @@ function dt(e, t) {
2086
2186
  });
2087
2187
  });
2088
2188
  }
2089
- function ft(e) {
2189
+ function gt(e) {
2090
2190
  return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
2091
2191
  }
2092
- var pt = new Set([
2192
+ var _t = new Set([
2093
2193
  "approval.resolved",
2094
2194
  "interaction.resolved",
2095
2195
  "interaction.cancelled",
2096
2196
  "interaction.canceled",
2097
2197
  "a2ui.action"
2098
2198
  ]);
2099
- function mt(e) {
2199
+ function vt(e) {
2100
2200
  let t = /* @__PURE__ */ new Set();
2101
2201
  for (let n of e) {
2102
2202
  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();
2103
- if (!pt.has(a)) continue;
2203
+ if (!_t.has(a)) continue;
2104
2204
  let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
2105
2205
  if (![
2106
2206
  "cancel",
@@ -2112,64 +2212,66 @@ function mt(e) {
2112
2212
  }
2113
2213
  return t;
2114
2214
  }
2115
- function ht(e, t, n, i = "flat-v1") {
2116
- e = I(e);
2117
- let a = new nt(n), o = [], s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = [...t || []].filter((e) => {
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) => {
2118
2218
  let t = e.Content, r = Q(t?.session_event || t?.sessionEvent), i = Q(t?.runtime_event || t?.runtimeEvent);
2119
2219
  return [
2120
2220
  e.SessionId,
2121
2221
  r?.session_id,
2122
2222
  i?.session_id
2123
2223
  ].every((e) => !e || e === n);
2124
- }).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), d = Number(u[0]?.SeqId || 0) <= 1, f = ot(u);
2125
- for (let [e, t] of u.entries()) {
2126
- let n = f[e];
2224
+ }).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), f = Number(a ?? d[0]?.SeqId ?? 0) <= 1, p = lt(d);
2225
+ for (let [e, t] of d.entries()) {
2226
+ let n = p[e];
2127
2227
  if (!n) continue;
2128
2228
  let r = String(n.run_id || "").trim();
2129
2229
  if (r) {
2130
- s.add(r), !n.parent_scope_id && [
2230
+ c.add(r), !n.parent_scope_id && [
2131
2231
  "run.completed",
2132
2232
  "run.failed",
2133
2233
  "run.cancelled",
2134
2234
  "run.canceled"
2135
- ].includes(String(n.event_type)) && c.add(r);
2235
+ ].includes(String(n.event_type)) && l.add(r);
2136
2236
  let e = Q(Q(n.source)?.metadata), t = String(n.event_type || "") === "run.started", i = e?.native_item_kind === "userMessage";
2137
- (d || t || i) && l.add(r);
2237
+ (f || t || i) && u.add(r);
2138
2238
  }
2139
- let i = a.translate(n);
2140
- i && o.push({
2239
+ let i = o.translate(n);
2240
+ i && s.push({
2141
2241
  ...i,
2142
2242
  SeqId: Number(t.SeqId || i.SeqId || 0),
2143
- Timestamp: st(t.Timestamp || i.Timestamp)
2243
+ Timestamp: ut(t.Timestamp || i.Timestamp)
2144
2244
  });
2145
2245
  }
2146
- let p = r(o).filter((e) => e.invocationId && s.has(e.invocationId)), m = /* @__PURE__ */ new Map();
2246
+ let m = i(s).filter((e) => e.invocationId && c.has(e.invocationId)), h = /* @__PURE__ */ new Map();
2147
2247
  for (let t of e) {
2148
2248
  let e = String(t.invocationId || "");
2149
- e && m.set(e, [...m.get(e) || [], t]);
2249
+ if (!e) continue;
2250
+ let n = h.get(e);
2251
+ n ? n.push(t) : h.set(e, [t]);
2150
2252
  }
2151
- let h = new Set([...ft(p)].filter((e) => l.has(e))), g = /* @__PURE__ */ new Map();
2152
- for (let e of f) {
2253
+ let g = new Set([...gt(m)].filter((e) => u.has(e))), _ = /* @__PURE__ */ new Map();
2254
+ for (let e of p) {
2153
2255
  if (e?.schema_version !== 2 || !e.run_id) continue;
2154
- let t = String(e.run_id), n = g.get(t) || [];
2155
- n.push(e), g.set(t, n);
2256
+ let t = String(e.run_id), n = _.get(t) || [];
2257
+ n.push(e), _.set(t, n);
2156
2258
  }
2157
- let _ = (e) => [
2259
+ let v = (e) => [
2158
2260
  Q(e.initial),
2159
2261
  Q(e.snapshot),
2160
2262
  Q(e.update)
2161
- ].some((e) => Q(e?.data)?.schema === "execution.scope/v1" || Array.isArray(e?.parts) && e.parts.some((e) => Q(Q(e)?.data)?.schema === "execution.scope/v1")), v = new Set([...g].filter(([, e]) => e.some(_)).map(([e]) => e)), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
2162
- for (let [e, t] of g) {
2163
- if (!v.has(e) && !h.has(e) && !t.some((e) => ["item.failed", "run.failed"].includes(String(e.event_type)))) continue;
2164
- let r = t.some((e) => e.event_type === "run.started" && !e.parent_scope_id), a = /* @__PURE__ */ new Set(), o = t.every((e) => {
2263
+ ].some((e) => Q(e?.data)?.schema === "execution.scope/v1" || Array.isArray(e?.parts) && e.parts.some((e) => Q(Q(e)?.data)?.schema === "execution.scope/v1")), y = new Set([..._].filter(([, e]) => e.some(v)).map(([e]) => e)), b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
2264
+ for (let [e, t] of _) {
2265
+ if (!y.has(e) && !g.has(e) && !t.some((e) => ["item.failed", "run.failed"].includes(String(e.event_type)))) continue;
2266
+ let i = t.some((e) => e.event_type === "run.started" && !e.parent_scope_id), a = /* @__PURE__ */ new Set(), o = t.every((e) => {
2165
2267
  let t = JSON.stringify([e.scope_id, e.item_id]);
2166
- return e.event_type === "item.started" && a.add(t), !_(e) || a.has(t);
2268
+ return e.event_type === "item.started" && a.add(t), !v(e) || a.has(t);
2167
2269
  });
2168
- if (!(!r || !o)) try {
2169
- let r = new C(n, void 0, i);
2170
- t.forEach((e) => r.apply(e));
2171
- let a = r.snapshot(), o = de(a, { profile: i }), s = st(t[0].timestamp);
2172
- y.set(e, W({
2270
+ if (!(!i || !o)) try {
2271
+ let i = new w(n, void 0, r);
2272
+ t.forEach((e) => i.apply(e));
2273
+ let a = i.snapshot(), o = j(a, { profile: r }), s = ut(t[0].timestamp);
2274
+ b.set(e, W({
2173
2275
  state: a,
2174
2276
  presentation: o,
2175
2277
  runId: e,
@@ -2187,36 +2289,36 @@ function ht(e, t, n, i = "flat-v1") {
2187
2289
  };
2188
2290
  }));
2189
2291
  } catch (t) {
2190
- b.add(e), console.warn(`[SessionHistory] strict replay skipped for run ${e}:`, t instanceof Error ? t.message : "invalid runtime history");
2292
+ x.add(e), console.warn(`[SessionHistory] strict replay skipped for run ${e}:`, t instanceof Error ? t.message : "invalid runtime history");
2191
2293
  }
2192
2294
  }
2193
- for (let e of new Set([...v, ...b])) y.has(e) || h.delete(e);
2194
- let x = mt(u), S = [...h].flatMap((e) => ut(p.filter((t) => t.invocationId === e), m.get(e) || [])), w = /* @__PURE__ */ new Map(), T = [];
2195
- for (let [e, t] of m) {
2196
- if (h.has(e) || !s.has(e)) continue;
2197
- let n = p.filter((t) => t.invocationId === e), r = t.some((e) => e.role === "model" && String(e.content || "").trim());
2198
- w.set(e, r ? dt(t, n) : t), r || T.push(...n.map($));
2199
- }
2200
- for (let e of s) h.has(e) || m.has(e) || T.push(...p.filter((t) => t.invocationId === e).map($));
2201
- let ee = new Map([...w.values()].flat().map((e) => [e.id, e])), E = R([
2202
- ...e.filter((e) => !(e.role === "model" && e.invocationId && x.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !h.has(e.invocationId))).map((e) => ee.get(e.id) || e),
2203
- ...S,
2204
- ...T
2295
+ 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 = [];
2297
+ for (let [e, t] of h) {
2298
+ if (g.has(e) || !c.has(e)) continue;
2299
+ 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($));
2301
+ }
2302
+ for (let e of c) g.has(e) || h.has(e) || E.push(...m.filter((t) => t.invocationId === e).map($));
2303
+ let ee = new Map([...T.values()].flat().map((e) => [e.id, e])), D = z([
2304
+ ...e.filter((e) => !(e.role === "model" && e.invocationId && S.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !g.has(e.invocationId))).map((e) => ee.get(e.id) || e),
2305
+ ...C,
2306
+ ...E
2205
2307
  ]);
2206
- for (let [e, t] of y) {
2308
+ for (let [e, t] of b) {
2207
2309
  if (!t.length) continue;
2208
- let n = (t) => t.invocationId === e || t.runId === e, r = E.findIndex(n), i = E.filter(n), a = i.find((e) => e.role === "user"), o = v.has(e) ? a && !t.some((e) => e.role === "user") ? [a, ...t] : t : ut(t, i), s = E.filter((e) => !n(e)), c = r < 0 ? s.length : r;
2209
- E = [
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;
2311
+ D = [
2210
2312
  ...s.slice(0, c),
2211
2313
  ...o,
2212
2314
  ...s.slice(c)
2213
- ], h.add(e);
2315
+ ], g.add(e);
2214
2316
  }
2215
2317
  return {
2216
- messages: I(R(lt(E, u, c))),
2217
- canonicalRunIds: [...h],
2218
- translatedEvents: o
2318
+ messages: dt(L(z(pt(D, d, l))), d, p, n, l),
2319
+ canonicalRunIds: [...g],
2320
+ translatedEvents: s
2219
2321
  };
2220
2322
  }
2221
2323
  //#endregion
2222
- export { T as C, E as S, S as T, we as _, Be as a, de as b, He as c, Ue as d, We as f, I as g, Ee as h, rt as i, Ge as l, W as m, ht as n, ze as o, Le as p, nt as r, Ke as s, ct as t, Ve as u, Ce as v, C as w, D as x, xe as y };
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 };