@kingsoftcloud/ksadk-web 0.3.6 → 0.3.8

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 (220) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/RELEASE_PROVENANCE.json +2 -2
  3. package/dist-ksadk/assets/{ArtifactsPanel-Ci-uVB1V.js → ArtifactsPanel-CbUDzOQO.js} +1 -1
  4. package/dist-ksadk/assets/{CodeBlock-Bs7KdIr5.js → CodeBlock-BwoN4XSB.js} +3 -3
  5. package/dist-ksadk/assets/{MathMessageMarkdown-C4aqRWHc.js → MathMessageMarkdown-CE8kmnzT.js} +4 -4
  6. package/dist-ksadk/assets/{MermaidBlock-SfTSCYPD.js → MermaidBlock-E2c6OIM3.js} +6 -6
  7. package/dist-ksadk/assets/{NativeTerminalPanel-D4469o8R.js → NativeTerminalPanel-DPLNV-9q.js} +1 -1
  8. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-DrkbRVUB.js → abnfDiagram-VCTEODGH-BOEVF10j.js} +1 -1
  9. package/dist-ksadk/assets/{arc--N-SlvcB.js → arc-D8m73GUU.js} +1 -1
  10. package/dist-ksadk/assets/architecture-7GRP2DOG-rCXFSJus.js +1 -0
  11. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-CVY40LaN.js → architectureDiagram-5GKGNRK7-CZB47JMF.js} +1 -1
  12. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-ByT8Mf2K.js → blockDiagram-NRAW4CY4-Cv2NU94T.js} +1 -1
  13. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-CD872g0K.js → c4Diagram-UCG6FXSJ-opDgjD87.js} +1 -1
  14. package/dist-ksadk/assets/channel-hnxAcHmY.js +1 -0
  15. package/dist-ksadk/assets/chunk-2Q5K7J3B-CULEGhLm.js +1 -0
  16. package/dist-ksadk/assets/{chunk-5VM5RSS4-DHt45oYW.js → chunk-5VM5RSS4-Ck1iwW_G.js} +1 -1
  17. package/dist-ksadk/assets/{chunk-F27PBJKO-DaF_3kAI.js → chunk-F27PBJKO-B8zFIVuU.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-G27WJ6UU-BA8YNT5P.js → chunk-G27WJ6UU-CjEsmMNX.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-JWPE2WC7-zNpvDS81.js → chunk-JWPE2WC7-CUCDIyfQ.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-LCL6LL3I-CEggtrMX.js → chunk-LCL6LL3I-DnfLBbwZ.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-POPQ4Y6H-Cc1cWxmR.js → chunk-POPQ4Y6H-1y0OEgko.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-RHFEMEQ7-D62WfyW_.js → chunk-RHFEMEQ7-BXaPo939.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-SVP7TREG-D2mcy9Rw.js → chunk-SVP7TREG-3RCiOG-8.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-XXDRQBXY-Dx1kmIl_.js → chunk-XXDRQBXY-Bpt5C4kv.js} +1 -1
  25. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-ChOM9CGx.js +1 -0
  26. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-ChOM9CGx.js +1 -0
  27. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-B5niRPCY.js → cose-bilkent-JH36ORCC-CltU2Iio.js} +1 -1
  28. package/dist-ksadk/assets/cynefin-OW5HDTMX-s8NJ5Tm_.js +1 -0
  29. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-DFfJ9u8F.js → cynefinDiagram-5FMLGOSQ-Bnah0vhH.js} +1 -1
  30. package/dist-ksadk/assets/{dagre-3AP2YEHR-BrPUj5we.js → dagre-3AP2YEHR-BQng1ROC.js} +1 -1
  31. package/dist-ksadk/assets/{dagre-J9T9lGqd.js → dagre-CoKqxJD2.js} +1 -1
  32. package/dist-ksadk/assets/{diagram-S7CK7UJ4-dw09FBMD.js → diagram-S7CK7UJ4-BXDuD2zO.js} +1 -1
  33. package/dist-ksadk/assets/{diagram-UQ7AKVKN-BqkIPows.js → diagram-UQ7AKVKN-DIfNFAeg.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-VSXAHHWV-iO4XlpWi.js → diagram-VSXAHHWV-DKAwDqkb.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-VX7I27RA-DRMax9wk.js → diagram-VX7I27RA-qFFDltev.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-Z3DM3KII-_JoXBxpU.js → diagram-Z3DM3KII-zMIfhqzQ.js} +1 -1
  37. package/dist-ksadk/assets/{dist-CTRKDU8K.js → dist-1s_bzCxO.js} +1 -1
  38. package/dist-ksadk/assets/{dist-DLGYftqv.js → dist-2cBTzdEm.js} +1 -1
  39. package/dist-ksadk/assets/{dist-C5xBbsOZ.js → dist-4ml45Gmg.js} +1 -1
  40. package/dist-ksadk/assets/{dist-C6T-wP4s.js → dist-ASt3FSxr.js} +1 -1
  41. package/dist-ksadk/assets/{dist-D-7_sx4d.js → dist-B29N3_Ie.js} +1 -1
  42. package/dist-ksadk/assets/{dist-BuVggBmt.js → dist-BEABF8oE.js} +1 -1
  43. package/dist-ksadk/assets/{dist-DTeQCULT.js → dist-BGIxM2Vg.js} +1 -1
  44. package/dist-ksadk/assets/{dist-CYNfiHL_.js → dist-BH4O3hsm.js} +1 -1
  45. package/dist-ksadk/assets/{dist-Dys6qb_l.js → dist-Blo8ntwU.js} +1 -1
  46. package/dist-ksadk/assets/{dist-BZBDMLXX.js → dist-Bzxnd_qQ.js} +1 -1
  47. package/dist-ksadk/assets/{dist-B8Xx9Bcu.js → dist-C60M2KmF.js} +1 -1
  48. package/dist-ksadk/assets/{dist-B5ACVHAD.js → dist-C965y3AU.js} +1 -1
  49. package/dist-ksadk/assets/{dist-DiUlU2X0.js → dist-CPy8MMAV.js} +1 -1
  50. package/dist-ksadk/assets/{dist-DHWEsppc.js → dist-CU5pKkyk.js} +1 -1
  51. package/dist-ksadk/assets/{dist-BcWjNWFB.js → dist-Coj7US2k.js} +1 -1
  52. package/dist-ksadk/assets/{dist-BD6pm3IK.js → dist-DCeG0nKY.js} +1 -1
  53. package/dist-ksadk/assets/{dist-BcF5XYGL.js → dist-DI-Jbiqn.js} +1 -1
  54. package/dist-ksadk/assets/{dist-DaJnfr3_.js → dist-DzXJwPG5.js} +1 -1
  55. package/dist-ksadk/assets/{dist-Dguio8Hw.js → dist-GOJu-1O3.js} +1 -1
  56. package/dist-ksadk/assets/{dist-CHgoCvLH.js → dist-Ha8Q7H83.js} +1 -1
  57. package/dist-ksadk/assets/{dist-EFwlyh-J.js → dist-RXjVy4Wc.js} +1 -1
  58. package/dist-ksadk/assets/{dist-D0V4p2BH.js → dist-YZwAStAT.js} +1 -1
  59. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-BVLszyE1.js → ebnfDiagram-PWID7BFC-Y-b0ShII.js} +1 -1
  60. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-NK9zebDC.js → erDiagram-SSCWMZ5O-CGX9tK2T.js} +1 -1
  61. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DSV5ve2-.js +1 -0
  62. package/dist-ksadk/assets/flowDiagram-A5DVABFB-B3rM8szx.js +1 -0
  63. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-B-NR6rAS.js → ganttDiagram-EL5Y4UJY-R7T0Mwkt.js} +1 -1
  64. package/dist-ksadk/assets/gitGraph-4MIJSDKK-B4xZV0AQ.js +1 -0
  65. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DntUECol.js → gitGraphDiagram-WWUBYQGX-gzn4XbP8.js} +1 -1
  66. package/dist-ksadk/assets/index-CYNEAutW.css +2 -0
  67. package/dist-ksadk/assets/index-obJvgClV.js +244 -0
  68. package/dist-ksadk/assets/info-A6RAGUB7-iLxaj0HG.js +1 -0
  69. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-lraP-4to.js → infoDiagram-RXCK75RN-DrE_0Ol8.js} +1 -1
  70. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-BFUXP6G0.js → ishikawaDiagram-5VMMS53U-CYEgalv4.js} +1 -1
  71. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DvJkYxSd.js → journeyDiagram-EYS64GPL-Bu-fPVb1.js} +1 -1
  72. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-Bx42a2kj.js → kanban-definition-3QL26DDD-CUFLrae5.js} +1 -1
  73. package/dist-ksadk/assets/{katex-T3OysX4v.js → katex-CXN0YSjg.js} +1 -1
  74. package/dist-ksadk/assets/{linear-BX4Gctf_.js → linear-BSbK6DWk.js} +1 -1
  75. package/dist-ksadk/assets/{mermaid-parser.core-B-Njf-Rf.js → mermaid-parser.core-D7K14JJL.js} +2 -2
  76. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-DO4XhxDO.js → mindmap-definition-FBJOCRG2-VVy1xsSW.js} +1 -1
  77. package/dist-ksadk/assets/packet-AYTQ26CC-Cn-vZ0Ty.js +1 -0
  78. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-Bhi4hvvi.js → pegDiagram-XKGWAZYB-BSK45EeA.js} +1 -1
  79. package/dist-ksadk/assets/pie-WAS4IAKB-DFyCNLMM.js +1 -0
  80. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-3cwlvdGv.js → pieDiagram-E7YTZNPT-D7CnjFEg.js} +1 -1
  81. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-BqCZQkDk.js → quadrantDiagram-AXDQQJYC-D2XhCNms.js} +1 -1
  82. package/dist-ksadk/assets/radar-RG4KPBEZ-DOHzZ4f2.js +1 -0
  83. package/dist-ksadk/assets/railroad-74A4TZTK-3tTa8qz5.js +1 -0
  84. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BCeMbyzT.js +1 -0
  85. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CBtr8GVh.js +1 -0
  86. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-CL9v6-uA.js +1 -0
  87. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-D6Z9xo29.js → railroadDiagram-O6MQD6OU-CRzXwklx.js} +1 -1
  88. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-0eqBRCt3.js → requirementDiagram-EFPCY7ZU-Cc9PcBiM.js} +1 -1
  89. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-BrJ43vZ_.js → sankeyDiagram-P5KCCOFB-C96FB-uX.js} +1 -1
  90. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-C-A3Z3yp.js → sequenceDiagram-WJ2MYXX4-CKOJAXyc.js} +1 -1
  91. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-BR1hzV_F.js → sizeCapture-X5ZJPWSS-D9YhRNJt.js} +1 -1
  92. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-BfHY88Bq.js → stateDiagram-HBIQ2CUA-BS0ROr-u.js} +1 -1
  93. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-jtOYkJhr.js +1 -0
  94. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-D_jtIJEW.js → swimlanes-XN3QIQJK-DShW7VAE.js} +1 -1
  95. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-fHwNs_3X.js +8 -0
  96. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-CZGn87oV.js → timeline-definition-24CTP7MA-DSeFMeHD.js} +1 -1
  97. package/dist-ksadk/assets/treeView-Q6P3EWNA-BkRpaj3X.js +1 -0
  98. package/dist-ksadk/assets/treemap-WGGIJYW6-BUpY1xKR.js +1 -0
  99. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-CAtuK-e_.js → vennDiagram-4TSXK5OY-CZEKlEip.js} +1 -1
  100. package/dist-ksadk/assets/wardley-WFR3VGLG-CJDNWytu.js +1 -0
  101. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-BWJCCvTJ.js → wardleyDiagram-VM6X3IG4-DTOzWBuZ.js} +1 -1
  102. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-BqG5_bw9.js → xychartDiagram-S5SC5T6Z-RbQFiLqZ.js} +1 -1
  103. package/dist-ksadk/index.html +2 -2
  104. package/dist-lib/App.d.ts +3 -1
  105. package/dist-lib/App.d.ts.map +1 -1
  106. package/dist-lib/{ArtifactsPanel-BX-TQaOJ.js → ArtifactsPanel-DByDntRi.js} +1 -1
  107. package/dist-lib/{AttachmentPreview-D8BjnDTd.js → AttachmentPreview-BKMo_SaP.js} +133 -292
  108. package/dist-lib/{CodeBlock-CGejCh33.js → CodeBlock-CgGEMQi-.js} +2 -2
  109. package/dist-lib/{ConnectedComposer-BgTxuTfq.js → ConnectedComposer-B5icGTSY.js} +274 -281
  110. package/dist-lib/{ConnectedMessageList-B-y-w-dq.js → ConnectedMessageList-C01x96Jz.js} +449 -719
  111. package/dist-lib/ExecutionTree-v3HexvPo.js +277 -0
  112. package/dist-lib/InteractionSchemaForm-BNoW5wzt.js +157 -0
  113. package/dist-lib/{MathMessageMarkdown-DzxSRCoH.js → MathMessageMarkdown--DoGNUu-.js} +2 -2
  114. package/dist-lib/{MenuChip-BXivncgX.js → MenuChip-CT8v3QtQ.js} +1 -1
  115. package/dist-lib/MessageMarkdown-C0NKq4TZ.js +255 -0
  116. package/dist-lib/{NativeTerminalPanel-DyPvD5ij.js → NativeTerminalPanel-beSt6mii.js} +1 -1
  117. package/dist-lib/{WorkspacePanelContainer-IBpAs0Ft.js → WorkspacePanelContainer-BKdoP1vC.js} +685 -662
  118. package/dist-lib/{a2ui-TSXmGrT-.js → a2ui-C7sqee_K.js} +25 -12
  119. package/dist-lib/chat-composer.js +4 -4
  120. package/dist-lib/chat-timeline.js +4 -3
  121. package/dist-lib/clipboard-MB6Ru6h6.js +20 -0
  122. package/dist-lib/components/AgentAuthorizationBoundary.d.ts +16 -0
  123. package/dist-lib/components/AgentAuthorizationBoundary.d.ts.map +1 -0
  124. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  125. package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
  126. package/dist-lib/components/chat/ContextUsageIndicator.d.ts.map +1 -1
  127. package/dist-lib/components/teams/CreateGroupDialog.d.ts +16 -0
  128. package/dist-lib/components/teams/CreateGroupDialog.d.ts.map +1 -0
  129. package/dist-lib/components/teams/ExecutionTree.d.ts +24 -0
  130. package/dist-lib/components/teams/ExecutionTree.d.ts.map +1 -0
  131. package/dist-lib/components/teams/InteractionMessage.d.ts +4 -0
  132. package/dist-lib/components/teams/InteractionMessage.d.ts.map +1 -0
  133. package/dist-lib/components/teams/TeamWorkspace.d.ts +100 -0
  134. package/dist-lib/components/teams/TeamWorkspace.d.ts.map +1 -0
  135. package/dist-lib/components.js +33 -32
  136. package/dist-lib/conversation.js +3 -2
  137. package/dist-lib/core/teams/client.d.ts +91 -0
  138. package/dist-lib/core/teams/client.d.ts.map +1 -0
  139. package/dist-lib/core/teams/contracts.d.ts +639 -0
  140. package/dist-lib/core/teams/contracts.d.ts.map +1 -0
  141. package/dist-lib/core/teams/observer.d.ts +52 -0
  142. package/dist-lib/core/teams/observer.d.ts.map +1 -0
  143. package/dist-lib/core/teams/presentation.d.ts +17 -0
  144. package/dist-lib/core/teams/presentation.d.ts.map +1 -0
  145. package/dist-lib/core/teams/reducer.d.ts +13 -0
  146. package/dist-lib/core/teams/reducer.d.ts.map +1 -0
  147. package/dist-lib/core/teams/types.d.ts +293 -0
  148. package/dist-lib/core/teams/types.d.ts.map +1 -0
  149. package/dist-lib/{feedback-D256P415.js → feedback-CuC5jRi_.js} +88 -84
  150. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  151. package/dist-lib/hooks/useBootstrap.d.ts +1 -1
  152. package/dist-lib/hooks/useBootstrap.d.ts.map +1 -1
  153. package/dist-lib/hooks/useInteractions.d.ts +1 -0
  154. package/dist-lib/hooks/useInteractions.d.ts.map +1 -1
  155. package/dist-lib/hooks/useSessionLifecycle.d.ts +2 -0
  156. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  157. package/dist-lib/hooks/useTeamChat.d.ts +17 -0
  158. package/dist-lib/hooks/useTeamChat.d.ts.map +1 -0
  159. package/dist-lib/hooks.js +112 -110
  160. package/dist-lib/permission-Cu2xehB-.js +25 -0
  161. package/dist-lib/{persisted-session-history-Bb3ScKrL.js → persisted-session-history-CJAtRhxZ.js} +371 -636
  162. package/dist-lib/presentation-yYw7xK60.js +53 -0
  163. package/dist-lib/public/components.d.ts +2 -0
  164. package/dist-lib/public/components.d.ts.map +1 -1
  165. package/dist-lib/public/runtime.d.ts +2 -0
  166. package/dist-lib/public/runtime.d.ts.map +1 -1
  167. package/dist-lib/public/team-components.d.ts +4 -0
  168. package/dist-lib/public/team-components.d.ts.map +1 -0
  169. package/dist-lib/public/team-execution.d.ts +3 -0
  170. package/dist-lib/public/team-execution.d.ts.map +1 -0
  171. package/dist-lib/public/teams.d.ts +8 -0
  172. package/dist-lib/public/teams.d.ts.map +1 -0
  173. package/dist-lib/reducer-B-uAlhi2.js +372 -0
  174. package/dist-lib/reducer-BP8YVv-Q.js +270 -0
  175. package/dist-lib/runtime.js +223 -196
  176. package/dist-lib/stores/permission.d.ts +1 -0
  177. package/dist-lib/stores/permission.d.ts.map +1 -1
  178. package/dist-lib/stores/session.d.ts +1 -0
  179. package/dist-lib/stores/session.d.ts.map +1 -1
  180. package/dist-lib/styles.css +1 -1
  181. package/dist-lib/team-components.js +1366 -0
  182. package/dist-lib/team-execution.js +2 -0
  183. package/dist-lib/teams.css +316 -0
  184. package/dist-lib/teams.js +338 -0
  185. package/dist-lib/{useSessionLifecycle-DuzkfGgL.js → useSessionLifecycle-DN68JYHx.js} +601 -574
  186. package/dist-lib/utils/authorization-cache.d.ts +15 -0
  187. package/dist-lib/utils/authorization-cache.d.ts.map +1 -0
  188. package/dist-lib/utils/session.d.ts +1 -1
  189. package/dist-lib/utils/session.d.ts.map +1 -1
  190. package/dist-lib/utils-CX-Pz5p6.js +8 -0
  191. package/package.json +17 -3
  192. package/schemas/teams-v1-execution-snapshot.schema.json +197 -0
  193. package/schemas/teams-v1-group-event.schema.json +53 -0
  194. package/schemas/teams-v1-group-snapshot.schema.json +1016 -0
  195. package/schemas/teams-v1-interaction-ref.schema.json +64 -0
  196. package/dist-ksadk/assets/architecture-7GRP2DOG-BqHCyWeg.js +0 -1
  197. package/dist-ksadk/assets/channel-Coa1sp6C.js +0 -1
  198. package/dist-ksadk/assets/chunk-2Q5K7J3B-DsFmVSN9.js +0 -1
  199. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-CYwIXL9J.js +0 -1
  200. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-CYwIXL9J.js +0 -1
  201. package/dist-ksadk/assets/cynefin-OW5HDTMX-Bnax5hCk.js +0 -1
  202. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BKRpMRZl.js +0 -1
  203. package/dist-ksadk/assets/flowDiagram-A5DVABFB-BGRwyiok.js +0 -1
  204. package/dist-ksadk/assets/gitGraph-4MIJSDKK-BceyfApi.js +0 -1
  205. package/dist-ksadk/assets/index-CaZ1dIkb.js +0 -244
  206. package/dist-ksadk/assets/index-OxfmJAbi.css +0 -2
  207. package/dist-ksadk/assets/info-A6RAGUB7-DgE9TXs9.js +0 -1
  208. package/dist-ksadk/assets/packet-AYTQ26CC-DQZbTYdS.js +0 -1
  209. package/dist-ksadk/assets/pie-WAS4IAKB-ChP3z5PO.js +0 -1
  210. package/dist-ksadk/assets/radar-RG4KPBEZ-BswBIyb7.js +0 -1
  211. package/dist-ksadk/assets/railroad-74A4TZTK-C4qYmztZ.js +0 -1
  212. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CUxXRHeB.js +0 -1
  213. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CHvnaoXp.js +0 -1
  214. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-x9Vt3w1A.js +0 -1
  215. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BLRHkxVu.js +0 -1
  216. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-D6sWlh4I.js +0 -8
  217. package/dist-ksadk/assets/treeView-Q6P3EWNA-DEdJV9Ig.js +0 -1
  218. package/dist-ksadk/assets/treemap-WGGIJYW6-Bte4RVdK.js +0 -1
  219. package/dist-ksadk/assets/wardley-WFR3VGLG-DiVBK1MJ.js +0 -1
  220. package/dist-lib/permission-BWkTcIzC.js +0 -24
@@ -1,198 +1,7 @@
1
1
  import { n as e } from "./tool-display-DTiRdghE.js";
2
- //#region src/core/conversation/errors.ts
3
- var t = class extends Error {
4
- code;
5
- status;
6
- capability;
7
- runId;
8
- cursor;
9
- cause;
10
- constructor(e, t, n = {}) {
11
- super(t), this.name = "ConversationClientError", this.code = e, this.status = n.status, this.capability = n.capability, this.runId = n.runId, this.cursor = n.cursor, this.cause = n.cause;
12
- }
13
- }, n = "conversation.ksadk.io/v1", r = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/, i = new Set([
14
- "native",
15
- "translated",
16
- "degraded",
17
- "unavailable"
18
- ]), a = new Set([
19
- "user_message",
20
- "assistant_text",
21
- "reasoning",
22
- "tool_call",
23
- "approval",
24
- "progress",
25
- "plan",
26
- "goal",
27
- "artifact",
28
- "a2ui",
29
- "error",
30
- "unknown"
31
- ]), o = new Set([
32
- "append",
33
- "replace",
34
- "completed"
35
- ]), s = new Set([
36
- "pending",
37
- "streaming",
38
- "completed",
39
- "failed"
40
- ]), c = new Set([
41
- "public",
42
- "internal",
43
- "hidden"
44
- ]), l = new Set([
45
- "apiVersion",
46
- "kind",
47
- "inputId",
48
- "sessionId",
49
- "idempotencyKey",
50
- "parts",
51
- "modelRef",
52
- "reasoning",
53
- "extensions"
54
- ]), u = new Set(["kind", "text"]), d = new Set([
55
- "kind",
56
- "attachmentRef",
57
- "mediaType",
58
- "name"
59
- ]), f = "ksadk.approval", p = "ksadk.collaboration", m = "ksadk.goal";
60
- function h(e) {
61
- return typeof e == "object" && e && !Array.isArray(e) ? e : null;
62
- }
63
- function g(e, t) {
64
- return typeof e == "string" && e.length > 0 && e.length <= t;
65
- }
66
- function _(e, t, n = !1) {
67
- return e == null || typeof e == "string" && e.length <= t && (n || e.length > 0);
68
- }
69
- function v(e, t) {
70
- return Object.keys(e).every((e) => t.has(e));
71
- }
72
- function y(e) {
73
- let t = h(e);
74
- return !t || typeof t.kind != "string" ? null : t.kind === "text" ? !v(t, u) || !g(t.text, 131072) ? null : {
75
- kind: "text",
76
- text: t.text
77
- } : t.kind === "attachment" ? !v(t, d) || !g(t.attachmentRef, 2048) || !g(t.mediaType, 256) || !_(t.name, 1024, !0) ? null : {
78
- kind: "attachment",
79
- attachmentRef: t.attachmentRef,
80
- mediaType: t.mediaType,
81
- ...t.name === void 0 ? {} : { name: t.name }
82
- } : null;
83
- }
84
- function b(e) {
85
- if (e === void 0) return {};
86
- let t = h(e);
87
- if (!t || Object.keys(t).some((e) => !r.test(e) || !e.includes("."))) return null;
88
- let n = t[f], i = t[p], a = t[m];
89
- return n !== void 0 && ![
90
- "ask",
91
- "risk",
92
- "full"
93
- ].includes(String(n)) || i !== void 0 && !["default", "plan"].includes(String(i)) || a !== void 0 && !g(a, 4096) ? null : { ...t };
94
- }
95
- function ee(e) {
96
- let t = h(e);
97
- if (!t || !v(t, l) || t.apiVersion !== n || t.kind !== "ConversationInput" || !g(t.inputId, 256) || !g(t.sessionId, 256) || !g(t.idempotencyKey, 512) || !Array.isArray(t.parts) || t.parts.length === 0 || !_(t.modelRef, 256) || !_(t.reasoning, 64)) return null;
98
- let r = t.parts.map(y), i = b(t.extensions);
99
- return r.some((e) => e === null) || i === null ? null : {
100
- apiVersion: n,
101
- kind: "ConversationInput",
102
- inputId: t.inputId,
103
- sessionId: t.sessionId,
104
- idempotencyKey: t.idempotencyKey,
105
- parts: r,
106
- ...t.modelRef === void 0 ? {} : { modelRef: t.modelRef },
107
- ...t.reasoning === void 0 ? {} : { reasoning: t.reasoning },
108
- ...t.extensions === void 0 ? {} : { extensions: i }
109
- };
110
- }
111
- function te(e) {
112
- let r = ee({
113
- ...e,
114
- apiVersion: e.apiVersion || n,
115
- kind: e.kind || "ConversationInput"
116
- });
117
- if (!r) throw new t("conversation_contract_mismatch", "Conversation input does not match conversation.ksadk.io/v1.");
118
- return r;
119
- }
120
- function ne(e) {
121
- let t = e.parts.map((e) => e.kind === "text" ? "text" : e.mediaType.toLowerCase().startsWith("image/") ? "attachment.image" : "attachment.file");
122
- e.modelRef && t.push("model.select"), e.reasoning && t.push("reasoning.effort");
123
- for (let n of Object.keys(e.extensions || {})) n === f ? t.push("approval") : n === p ? e.extensions?.[n] === "plan" && t.push("plan") : n === m ? t.push("goal") : t.push(n);
124
- return [...new Set(t)];
125
- }
126
- function re(e, n) {
127
- if (e.sessionId !== n.sessionId) throw new t("conversation_session_mismatch", "Conversation input session does not match the active surface.");
128
- for (let r of ne(n)) if (!ce(e, r)) throw new t("conversation_input_unsupported", "Conversation input is not declared by the active surface.", { capability: r });
129
- return n;
130
- }
131
- function ie(e) {
132
- let t = h(e);
133
- return !t || !g(t.name, 128) || !r.test(t.name) || !i.has(t.mode) || !_(t.reason, 512, !0) || (t.mode === "degraded" || t.mode === "unavailable") && !g(t.reason, 512) ? null : {
134
- name: t.name,
135
- mode: t.mode,
136
- ...t.reason === void 0 ? {} : { reason: t.reason }
137
- };
138
- }
139
- function ae(e) {
140
- if (e === void 0) return [];
141
- if (!Array.isArray(e)) return null;
142
- let t = e.map(ie);
143
- if (t.some((e) => e === null)) return null;
144
- let n = t;
145
- return new Set(n.map((e) => e.name)).size === n.length ? n : null;
146
- }
147
- function oe(e) {
148
- let t = h(e);
149
- if (!t || t.apiVersion !== n || t.kind !== "ConversationSurface" || !g(t.surfaceId, 256) || !g(t.sessionId, 256) || !g(t.providerRef, 256)) return null;
150
- let r = ae(t.inputs), i = ae(t.outputs);
151
- return !r || !i ? null : {
152
- apiVersion: n,
153
- kind: "ConversationSurface",
154
- surfaceId: t.surfaceId,
155
- sessionId: t.sessionId,
156
- providerRef: t.providerRef,
157
- inputs: r,
158
- outputs: i
159
- };
160
- }
161
- function se(e) {
162
- let t = h(e);
163
- if (!t || t.apiVersion !== n || t.kindVersion !== 1 || !g(t.itemId, 512) || !_(t.parentItemId, 512) || !Array.isArray(t.sourceEventIds) || t.sourceEventIds.length === 0 || t.sourceEventIds.some((e) => typeof e != "string" || e.length === 0) || new Set(t.sourceEventIds).size !== t.sourceEventIds.length || !g(t.sessionId, 256) || !g(t.runId, 256) || !g(t.kind, 128) || !o.has(t.operation) || !s.has(t.lifecycle) || t.visibility !== void 0 && !c.has(t.visibility) || !g(t.payloadSchemaRef, 256) || !_(t.capabilityRef, 256, !0)) return null;
164
- let r = t.operation, i = t.lifecycle;
165
- if (r === "completed" && i !== "completed" && i !== "failed") return null;
166
- let l = t.payload === void 0 ? {} : h(t.payload), u = t.nativeRef === void 0 ? {} : h(t.nativeRef);
167
- if (!l || !u) return null;
168
- let d = String(t.kind || "unknown"), f = a.has(d) ? d : "unknown";
169
- return {
170
- apiVersion: n,
171
- kindVersion: 1,
172
- itemId: t.itemId,
173
- ...t.parentItemId === void 0 ? {} : { parentItemId: t.parentItemId },
174
- sourceEventIds: [...t.sourceEventIds],
175
- sessionId: t.sessionId,
176
- runId: t.runId,
177
- kind: f,
178
- operation: r,
179
- lifecycle: i,
180
- visibility: f === "unknown" && d !== "unknown" ? "hidden" : t.visibility || "public",
181
- payloadSchemaRef: t.payloadSchemaRef,
182
- payload: f === "unknown" && d !== "unknown" ? {
183
- originalKind: d,
184
- summary: "This content type is not supported by the current renderer."
185
- } : { ...l },
186
- ...t.capabilityRef === void 0 ? {} : { capabilityRef: t.capabilityRef },
187
- nativeRef: { ...u }
188
- };
189
- }
190
- function ce(e, ...t) {
191
- return e.inputs.some((e) => t.includes(e.name) && (e.mode === "native" || e.mode === "translated"));
192
- }
193
- //#endregion
2
+ import { c as t, o as n, s as r, t as i, u as a } from "./reducer-BP8YVv-Q.js";
194
3
  //#region src/core/conversation/presentation.ts
195
- var le = {
4
+ var o = {
196
5
  user_message: "conversation.item.user_message/v1",
197
6
  assistant_text: "conversation.item.assistant_text/v1",
198
7
  reasoning: "conversation.item.reasoning/v1",
@@ -202,10 +11,10 @@ var le = {
202
11
  a2ui: "conversation.item.a2ui/v1",
203
12
  error: "conversation.item.error/v1"
204
13
  };
205
- function x(e) {
14
+ function s(e) {
206
15
  return e.lifecycle === "completed" || e.lifecycle === "failed";
207
16
  }
208
- var ue = new Set([
17
+ var c = new Set([
209
18
  "aborted",
210
19
  "canceled",
211
20
  "cancelled",
@@ -213,17 +22,17 @@ var ue = new Set([
213
22
  "incomplete",
214
23
  "interrupted"
215
24
  ]);
216
- function S(e) {
217
- if (e.kind !== "progress" && e.kind !== "error" || !x(e)) return;
25
+ function l(e) {
26
+ if (e.kind !== "progress" && e.kind !== "error" || !s(e)) return;
218
27
  let t = typeof e.payload.status == "string" ? e.payload.status.toLowerCase() : "";
219
28
  if (t === "completed") return "completed";
220
- if (ue.has(t)) return "failed";
29
+ if (c.has(t)) return "failed";
221
30
  }
222
- function de(e) {
223
- let t = le[e.kind];
31
+ function u(e) {
32
+ let t = o[e.kind];
224
33
  return t === void 0 || t === e.payloadSchemaRef;
225
34
  }
226
- function fe(e) {
35
+ function d(e) {
227
36
  if (typeof e != "string" || e.length === 0) return null;
228
37
  try {
229
38
  let t = new URL(e);
@@ -232,7 +41,7 @@ function fe(e) {
232
41
  return null;
233
42
  }
234
43
  }
235
- function pe(e) {
44
+ function f(e) {
236
45
  return {
237
46
  id: e.itemId,
238
47
  parentId: e.parentItemId || null,
@@ -242,35 +51,35 @@ function pe(e) {
242
51
  lifecycle: e.lifecycle
243
52
  };
244
53
  }
245
- function me(e) {
54
+ function p(e) {
246
55
  return {
247
56
  id: e.itemId,
248
57
  name: typeof e.payload.name == "string" && e.payload.name ? e.payload.name : "Artifact",
249
58
  mimeType: typeof e.payload.mimeType == "string" && e.payload.mimeType ? e.payload.mimeType : "application/octet-stream",
250
- uri: fe(e.payload.uri)
59
+ uri: d(e.payload.uri)
251
60
  };
252
61
  }
253
- function C(e, t) {
62
+ function m(e, t) {
254
63
  let n = e.payload[t];
255
64
  return typeof n == "string" && n ? n : null;
256
65
  }
257
- function he(e) {
66
+ function h(e) {
258
67
  if (e.kind === "tool_call") {
259
- let t = C(e, "callId");
68
+ let t = m(e, "callId");
260
69
  if (t) return `tool:${t}`;
261
70
  }
262
71
  if (e.kind === "approval") {
263
- let t = C(e, "interactionId");
72
+ let t = m(e, "interactionId");
264
73
  if (t) return `approval:${t}`;
265
74
  }
266
75
  if (e.kind === "a2ui") {
267
- let t = C(e, "surfaceId");
76
+ let t = m(e, "surfaceId");
268
77
  if (t) return `a2ui:${t}`;
269
78
  }
270
79
  return `item:${e.itemId}`;
271
80
  }
272
- function ge(e, t) {
273
- let n = x(e) && !x(t);
81
+ function g(e, t) {
82
+ let n = s(e) && !s(t);
274
83
  return {
275
84
  ...e,
276
85
  ...t,
@@ -291,10 +100,10 @@ function ge(e, t) {
291
100
  } : {}
292
101
  };
293
102
  }
294
- function _e(e) {
103
+ function _(e) {
295
104
  let t = [], n = /* @__PURE__ */ new Map();
296
105
  for (let r of e) {
297
- let e = he(r), i = n.get(e);
106
+ let e = h(r), i = n.get(e);
298
107
  if (i === void 0) {
299
108
  n.set(e, t.length), t.push({
300
109
  key: e,
@@ -306,20 +115,20 @@ function _e(e) {
306
115
  let a = t[i];
307
116
  t[i] = {
308
117
  key: e,
309
- item: ge(a.item, r),
118
+ item: g(a.item, r),
310
119
  sourceItemIds: [...new Set([...a.sourceItemIds, r.itemId])]
311
120
  };
312
121
  }
313
122
  return t;
314
123
  }
315
- function ve(e, t = {}) {
316
- let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal"), r = n.filter(de), i = n.filter((e) => !de(e)), a = new Set([
124
+ function v(e, t = {}) {
125
+ let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal"), r = n.filter(u), i = n.filter((e) => !u(e)), a = new Set([
317
126
  "user_message",
318
127
  "assistant_text",
319
128
  "reasoning"
320
- ]), o = r.filter((e) => a.has(e.kind)).map(pe), s = (e) => r.filter((t) => t.kind === e).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), c = [...r.filter((e) => e.kind === "unknown"), ...i], l = r.filter((e) => e.kind === "error"), u = [...r].reverse().find((e) => S(e) !== void 0);
129
+ ]), o = r.filter((e) => a.has(e.kind)).map(f), s = (e) => r.filter((t) => t.kind === e).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), c = [...r.filter((e) => e.kind === "unknown"), ...i], d = r.filter((e) => e.kind === "error"), m = [...r].reverse().find((e) => l(e) !== void 0);
321
130
  return {
322
- timeline: _e(r.filter((e) => e.kind !== "progress")),
131
+ timeline: _(r.filter((e) => e.kind !== "progress")),
323
132
  output: s("assistant_text"),
324
133
  reasoning: s("reasoning"),
325
134
  textItems: o,
@@ -327,266 +136,192 @@ function ve(e, t = {}) {
327
136
  approvalItems: r.filter((e) => e.kind === "approval"),
328
137
  structuredInputItems: r.filter((e) => e.kind === "progress" && e.payloadSchemaRef === "conversation.item.structured-input/v1"),
329
138
  a2uiItems: r.filter((e) => e.kind === "a2ui"),
330
- artifacts: r.filter((e) => e.kind === "artifact").map(me),
139
+ artifacts: r.filter((e) => e.kind === "artifact").map(p),
331
140
  fallbacks: [...c.map((e) => ({
332
141
  id: e.itemId,
333
142
  title: "Unsupported content",
334
143
  detail: String(e.payload.summary || e.payload.originalKind || e.payloadSchemaRef),
335
144
  failed: e.lifecycle === "failed"
336
- })), ...l.map((e) => ({
145
+ })), ...d.map((e) => ({
337
146
  id: e.itemId,
338
147
  title: "Run failed",
339
148
  detail: String(e.payload.error || "The agent run failed."),
340
149
  failed: !0
341
150
  }))],
342
151
  runId: n.at(-1)?.runId || "",
343
- terminalStatus: u ? S(u) : void 0
152
+ terminalStatus: m ? l(m) : void 0
344
153
  };
345
154
  }
346
155
  //#endregion
347
- //#region src/core/conversation/reducer.ts
348
- function ye() {
349
- return {
350
- items: [],
351
- appliedSources: []
352
- };
353
- }
354
- function be(e) {
355
- return e.lifecycle === "completed" || e.lifecycle === "failed";
356
- }
357
- function xe(e, t) {
358
- let n = {
359
- ...e,
360
- ...t
361
- };
362
- typeof e.text == "string" && typeof t.text == "string" && (n.text = e.text + t.text);
363
- for (let r of ["data", "operations"]) Array.isArray(e[r]) && Array.isArray(t[r]) && (n[r] = [...e[r], ...t[r]]);
364
- return n;
365
- }
366
- function Se(e, t) {
367
- let n = t.sourceEventIds.map((e) => JSON.stringify([t.itemId, e])), r = new Set(e.appliedSources);
368
- if (n.every((e) => r.has(e))) return e;
369
- n.forEach((e) => r.add(e));
370
- let i = e.items.findIndex((e) => e.itemId === t.itemId), a = i >= 0 ? e.items[i] : void 0;
371
- if (a && be(a) && !be(t)) return {
372
- ...e,
373
- appliedSources: [...r]
374
- };
375
- let o = [...e.items];
376
- if (!a) o.push(t);
377
- else {
378
- let e = [...new Set([...a.sourceEventIds, ...t.sourceEventIds])];
379
- a.kind === t.kind ? t.operation === "append" ? o[i] = {
380
- ...t,
381
- payload: xe(a.payload, t.payload),
382
- sourceEventIds: e
383
- } : o[i] = {
384
- ...t,
385
- sourceEventIds: e
386
- } : o[i] = {
387
- ...t,
388
- kind: "unknown",
389
- operation: "replace",
390
- payloadSchemaRef: "conversation.item.unknown/v1",
391
- payload: { summary: "The content type changed for the same item and was safely degraded." },
392
- sourceEventIds: e
393
- };
394
- }
395
- return {
396
- items: o,
397
- appliedSources: [...r]
398
- };
399
- }
400
- var Ce = class {
401
- state = ye();
402
- apply(e) {
403
- let t = Se(this.state, e);
404
- if (t === this.state) return !1;
405
- let n = t.items !== this.state.items;
406
- return this.state = t, n;
407
- }
408
- applyAll(e) {
409
- for (let t of e) this.apply(t);
410
- }
411
- snapshot() {
412
- return {
413
- items: this.state.items.map((e) => ({
414
- ...e,
415
- sourceEventIds: [...e.sourceEventIds],
416
- payload: { ...e.payload },
417
- nativeRef: { ...e.nativeRef }
418
- })),
419
- appliedSources: [...this.state.appliedSources]
420
- };
421
- }
422
- }, w = 8;
423
- function T(e) {
156
+ //#region src/core/conversation/client.ts
157
+ var y = 8;
158
+ function b(e) {
424
159
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
425
160
  }
426
- function E(e) {
427
- if (e?.aborted) throw new t("conversation_aborted", "Conversation request was aborted.");
161
+ function x(e) {
162
+ if (e?.aborted) throw new a("conversation_aborted", "Conversation request was aborted.");
428
163
  }
429
- function we(e, t) {
164
+ function S(e, t) {
430
165
  return t?.aborted === !0 || e instanceof Error && e.name === "AbortError";
431
166
  }
432
- function Te(e) {
433
- let n = e.trim().replace(/\/+$/, "");
434
- if (!n) return "";
435
- if (!n.includes("://")) return n.startsWith("/") ? n : `/${n}`;
167
+ function ee(e) {
168
+ let t = e.trim().replace(/\/+$/, "");
169
+ if (!t) return "";
170
+ if (!t.includes("://")) return t.startsWith("/") ? t : `/${t}`;
436
171
  try {
437
- let e = new URL(n);
172
+ let e = new URL(t);
438
173
  if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password) throw Error("unsafe URL");
439
174
  return e.toString().replace(/\/$/, "");
440
175
  } catch (e) {
441
- throw new t("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
176
+ throw new a("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
442
177
  }
443
178
  }
444
- function Ee(e) {
179
+ function te(e) {
445
180
  return Math.min(200 * 2 ** Math.max(0, e - 1), 2e3);
446
181
  }
447
- function De(e) {
182
+ function ne(e) {
448
183
  return new Promise((t) => {
449
184
  setTimeout(t, e);
450
185
  });
451
186
  }
452
- async function Oe(e, n, r) {
453
- if (E(r), !r) {
454
- await e(n);
187
+ async function re(e, t, n) {
188
+ if (x(n), !n) {
189
+ await e(t);
455
190
  return;
456
191
  }
457
- await new Promise((i, a) => {
458
- let o = () => a(new t("conversation_aborted", "Conversation request was aborted."));
459
- r.addEventListener("abort", o, { once: !0 }), e(n).then(i, a).finally(() => {
460
- r.removeEventListener("abort", o);
192
+ await new Promise((r, i) => {
193
+ let o = () => i(new a("conversation_aborted", "Conversation request was aborted."));
194
+ n.addEventListener("abort", o, { once: !0 }), e(t).then(r, i).finally(() => {
195
+ n.removeEventListener("abort", o);
461
196
  });
462
197
  });
463
198
  }
464
- function D(e, t, n) {
199
+ function C(e, t, n) {
465
200
  let r = e.snapshot();
466
201
  return {
467
202
  cursor: t,
468
203
  runId: n,
469
204
  state: r,
470
- presentation: ve(r)
205
+ presentation: v(r)
471
206
  };
472
207
  }
473
- function ke(e, n) {
208
+ function w(e, t) {
474
209
  let r, i = [];
475
- for (let n of e.split(/\r?\n/)) {
476
- let e = n.endsWith("\r") ? n.slice(0, -1) : n;
210
+ for (let t of e.split(/\r?\n/)) {
211
+ let e = t.endsWith("\r") ? t.slice(0, -1) : t;
477
212
  if (!e || e.startsWith(":")) continue;
478
- let a = e.indexOf(":"), o = a < 0 ? e : e.slice(0, a), s = a < 0 ? "" : e.slice(a + 1), c = s.startsWith(" ") ? s.slice(1) : s;
213
+ let n = e.indexOf(":"), o = n < 0 ? e : e.slice(0, n), s = n < 0 ? "" : e.slice(n + 1), c = s.startsWith(" ") ? s.slice(1) : s;
479
214
  if (o === "id") {
480
- if (!/^\d+$/.test(c) || !Number.isSafeInteger(Number(c))) throw new t("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
215
+ if (!/^\d+$/.test(c) || !Number.isSafeInteger(Number(c))) throw new a("conversation_stream_error", "Conversation stream contains an invalid replay cursor.");
481
216
  r = Number(c);
482
217
  } else o === "data" && i.push(c);
483
218
  }
484
219
  if (i.length === 0) return;
485
- let a = i.join("\n");
486
- if (!a || a === "[DONE]") return;
487
- let o;
220
+ let o = i.join("\n");
221
+ if (!o || o === "[DONE]") return;
222
+ let s;
488
223
  try {
489
- o = JSON.parse(a);
224
+ s = JSON.parse(o);
490
225
  } catch (e) {
491
- throw new t("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
226
+ throw new a("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
492
227
  }
493
- let s = T(o);
494
- if (!s || s.conversationItem === void 0) {
495
- r !== void 0 && (n.cursor = Math.max(n.cursor, r));
228
+ let c = b(s);
229
+ if (!c || c.conversationItem === void 0) {
230
+ r !== void 0 && (t.cursor = Math.max(t.cursor, r));
496
231
  return;
497
232
  }
498
- if (r === void 0) throw new t("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
499
- let c = se(s.conversationItem);
500
- if (!c) throw new t("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
501
- if (n.runId && n.runId !== c.runId) throw new t("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
502
- runId: n.runId,
503
- cursor: n.cursor
233
+ if (r === void 0) throw new a("conversation_stream_error", "Canonical conversation items require an SSE replay cursor.");
234
+ let l = n(c.conversationItem);
235
+ if (!l) throw new a("conversation_contract_mismatch", "Conversation stream item does not match conversation.ksadk.io/v1.");
236
+ if (t.runId && t.runId !== l.runId) throw new a("conversation_contract_mismatch", "Conversation stream changed canonical run identity.", {
237
+ runId: t.runId,
238
+ cursor: t.cursor
504
239
  });
505
- n.runId = c.runId;
506
- let l = n.reducer.apply(c);
507
- n.cursor = Math.max(n.cursor, r), l && n.options.onItem?.(c), n.options.onUpdate?.(D(n.reducer, n.cursor, n.runId));
240
+ t.runId = l.runId;
241
+ let u = t.reducer.apply(l);
242
+ t.cursor = Math.max(t.cursor, r), u && t.options.onItem?.(l), t.options.onUpdate?.(C(t.reducer, t.cursor, t.runId));
508
243
  }
509
- async function Ae(e, n) {
510
- if (!e.body) throw new t("conversation_stream_error", "Conversation response has no event stream body.");
511
- let r = e.body.getReader(), i = new TextDecoder(), a = "";
244
+ async function ie(e, t) {
245
+ if (!e.body) throw new a("conversation_stream_error", "Conversation response has no event stream body.");
246
+ let n = e.body.getReader(), r = new TextDecoder(), i = "";
512
247
  try {
513
248
  for (;;) {
514
- E(n.options.signal);
515
- let { value: e, done: t } = await r.read();
516
- if (t) break;
517
- a += i.decode(e, { stream: !0 });
518
- let o = /\r?\n\r?\n/.exec(a);
249
+ x(t.options.signal);
250
+ let { value: e, done: a } = await n.read();
251
+ if (a) break;
252
+ i += r.decode(e, { stream: !0 });
253
+ let o = /\r?\n\r?\n/.exec(i);
519
254
  for (; o?.index !== void 0;) {
520
- let e = o.index, t = o[0].length;
521
- ke(a.slice(0, e), n), a = a.slice(e + t), o = /\r?\n\r?\n/.exec(a);
255
+ let e = o.index, n = o[0].length;
256
+ w(i.slice(0, e), t), i = i.slice(e + n), o = /\r?\n\r?\n/.exec(i);
522
257
  }
523
258
  }
524
- a += i.decode(), a.trim() && ke(a, n);
259
+ i += r.decode(), i.trim() && w(i, t);
525
260
  } catch (e) {
526
- throw e instanceof t ? e : (we(e, n.options.signal) && E(n.options.signal), new t("conversation_stream_error", "Conversation event stream was interrupted.", {
261
+ throw e instanceof a ? e : (S(e, t.options.signal) && x(t.options.signal), new a("conversation_stream_error", "Conversation event stream was interrupted.", {
527
262
  cause: e,
528
- runId: n.runId || void 0,
529
- cursor: n.cursor
263
+ runId: t.runId || void 0,
264
+ cursor: t.cursor
530
265
  }));
531
266
  } finally {
532
- r.releaseLock();
267
+ n.releaseLock();
533
268
  }
534
269
  }
535
- function je(e) {
536
- return e.state.items.some((e) => S(e) !== void 0);
270
+ function T(e) {
271
+ return e.state.items.some((e) => l(e) !== void 0);
537
272
  }
538
- var Me = class {
273
+ var ae = class {
539
274
  fetcher;
540
275
  baseUrl;
541
276
  maxReconnects;
542
277
  sleep;
543
278
  retryDelayMs;
544
279
  constructor(e = {}) {
545
- if (!Number.isInteger(e.maxReconnects ?? w) || (e.maxReconnects ?? w) < 0 || (e.maxReconnects ?? w) > 32) throw new t("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
546
- this.fetcher = e.fetch, this.baseUrl = Te(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? w, this.sleep = e.sleep || De, this.retryDelayMs = e.retryDelayMs || Ee;
280
+ if (!Number.isInteger(e.maxReconnects ?? y) || (e.maxReconnects ?? y) < 0 || (e.maxReconnects ?? y) > 32) throw new a("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
281
+ this.fetcher = e.fetch, this.baseUrl = ee(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? y, this.sleep = e.sleep || ne, this.retryDelayMs = e.retryDelayMs || te;
547
282
  }
548
283
  fetch() {
549
284
  if (this.fetcher) return this.fetcher;
550
285
  if (typeof globalThis.fetch == "function") return globalThis.fetch.bind(globalThis);
551
- throw new t("conversation_http_error", "No fetch implementation is available for the conversation client.");
286
+ throw new a("conversation_http_error", "No fetch implementation is available for the conversation client.");
552
287
  }
553
288
  url(e) {
554
289
  return `${this.baseUrl}${e}`;
555
290
  }
556
- async request(e, n, r, i = "conversation_stream_error") {
557
- E(r);
291
+ async request(e, t, n, r = "conversation_stream_error") {
292
+ x(n);
558
293
  try {
559
- return await this.fetch()(e, n);
294
+ return await this.fetch()(e, t);
560
295
  } catch (e) {
561
- throw e instanceof t ? e : (we(e, r) && E(r), new t(i, "Conversation network request failed.", { cause: e }));
296
+ throw e instanceof a ? e : (S(e, n) && x(n), new a(r, "Conversation network request failed.", { cause: e }));
562
297
  }
563
298
  }
564
299
  assertOk(e) {
565
- if (!e.ok) throw new t("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
300
+ if (!e.ok) throw new a("conversation_http_error", `Conversation endpoint returned HTTP ${e.status}.`, { status: e.status });
566
301
  }
567
- async getSurface(e, n, r = {}) {
568
- if (!e || !n) throw new t("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
569
- let i = r.signal ? { signal: r.signal } : void 0, a = await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(n)}`), i, r.signal, "conversation_http_error");
570
- this.assertOk(a);
571
- let o;
302
+ async getSurface(e, t, n = {}) {
303
+ if (!e || !t) throw new a("conversation_contract_mismatch", "Agent and session identities are required to get a conversation surface.");
304
+ let i = n.signal ? { signal: n.signal } : void 0, o = await this.request(this.url(`/api/v1/agents/${encodeURIComponent(e)}/conversation-surface?sessionId=${encodeURIComponent(t)}`), i, n.signal, "conversation_http_error");
305
+ this.assertOk(o);
306
+ let s;
572
307
  try {
573
- o = await a.json();
308
+ s = await o.json();
574
309
  } catch (e) {
575
- throw new t("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
310
+ throw new a("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
576
311
  }
577
- let s = T(o), c = oe(s?.surface);
578
- if (!s || typeof s.buildId != "string" || !s.buildId || !c) throw new t("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
312
+ let c = b(s), l = r(c?.surface);
313
+ if (!c || typeof c.buildId != "string" || !c.buildId || !l) throw new a("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
579
314
  return {
580
- buildId: s.buildId,
581
- surface: c
315
+ buildId: c.buildId,
316
+ surface: l
582
317
  };
583
318
  }
584
319
  async streamTurn(e) {
585
- E(e.signal), re(e.bootstrap.surface, e.input);
320
+ x(e.signal), t(e.bootstrap.surface, e.input);
586
321
  let n = {
587
322
  cursor: 0,
588
323
  runId: "",
589
- reducer: new Ce(),
324
+ reducer: new i(),
590
325
  options: e
591
326
  }, r = {
592
327
  method: "POST",
@@ -596,72 +331,72 @@ var Me = class {
596
331
  },
597
332
  body: JSON.stringify({ input: e.input }),
598
333
  ...e.signal ? { signal: e.signal } : {}
599
- }, i = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), r, e.signal);
600
- this.assertOk(i);
334
+ }, o = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), r, e.signal);
335
+ this.assertOk(o);
601
336
  try {
602
- await Ae(i, n);
337
+ await ie(o, n);
603
338
  } catch (e) {
604
- if (!(e instanceof t) || e.code !== "conversation_stream_error" || !n.runId) throw e;
339
+ if (!(e instanceof a) || e.code !== "conversation_stream_error" || !n.runId) throw e;
605
340
  }
606
- let a = D(n.reducer, n.cursor, n.runId);
607
- if (je(a)) return a;
608
- if (!n.runId) throw new t("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: n.cursor });
609
- for (let r = 1; r <= this.maxReconnects; r += 1) {
610
- await Oe(this.sleep, this.retryDelayMs(r), e.signal), E(e.signal);
611
- let i;
341
+ let s = C(n.reducer, n.cursor, n.runId);
342
+ if (T(s)) return s;
343
+ if (!n.runId) throw new a("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: n.cursor });
344
+ for (let t = 1; t <= this.maxReconnects; t += 1) {
345
+ await re(this.sleep, this.retryDelayMs(t), e.signal), x(e.signal);
346
+ let r;
612
347
  try {
613
- i = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(n.runId)}/events?after=${n.cursor}`), {
348
+ r = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(n.runId)}/events?after=${n.cursor}`), {
614
349
  method: "GET",
615
350
  headers: { "Last-Event-ID": String(n.cursor) },
616
351
  ...e.signal ? { signal: e.signal } : {}
617
- }, e.signal), this.assertOk(i), await Ae(i, n);
352
+ }, e.signal), this.assertOk(r), await ie(r, n);
618
353
  } catch (e) {
619
- if (e instanceof t && e.code === "conversation_aborted" || e instanceof t && e.code === "conversation_contract_mismatch" || e instanceof t && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
354
+ if (e instanceof a && e.code === "conversation_aborted" || e instanceof a && e.code === "conversation_contract_mismatch" || e instanceof a && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
620
355
  continue;
621
356
  }
622
- if (a = D(n.reducer, n.cursor, n.runId), je(a)) return a;
357
+ if (s = C(n.reducer, n.cursor, n.runId), T(s)) return s;
623
358
  }
624
- throw new t("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
359
+ throw new a("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
625
360
  runId: n.runId,
626
361
  cursor: n.cursor
627
362
  });
628
363
  }
629
- }, Ne = 0;
630
- function O(e) {
631
- return Ne += 1, `${e}-${Ne}`;
364
+ }, oe = 0;
365
+ function E(e) {
366
+ return oe += 1, `${e}-${oe}`;
632
367
  }
633
- function k(e) {
368
+ function D(e) {
634
369
  return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
635
370
  ...e,
636
371
  status: "done"
637
372
  } : e);
638
373
  }
639
- function Pe(e, t) {
374
+ function se(e, t) {
640
375
  let n = [...e ?? []], r = n[n.length - 1];
641
376
  return r?.type === "thinking" && r.status === "streaming" ? (n[n.length - 1] = {
642
377
  ...r,
643
378
  content: r.content + t
644
379
  }, n) : [...n, {
645
- id: O("thinking"),
380
+ id: E("thinking"),
646
381
  type: "thinking",
647
382
  content: t,
648
383
  status: "streaming"
649
384
  }];
650
385
  }
651
- function Fe(e, t) {
652
- let n = [...k(e ?? [])], r = n[n.length - 1];
386
+ function ce(e, t) {
387
+ let n = [...D(e ?? [])], r = n[n.length - 1];
653
388
  return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
654
389
  ...r,
655
390
  content: r.content + t
656
391
  }, n) : [...n, {
657
- id: O("text"),
392
+ id: E("text"),
658
393
  type: "text",
659
394
  content: t,
660
395
  status: "streaming"
661
396
  }];
662
397
  }
663
- function Ie(e, t) {
664
- let n = k(e ?? []);
398
+ function le(e, t) {
399
+ let n = D(e ?? []);
665
400
  if (n.filter((e) => e.type === "text").map((e) => e.content).join("") === t) return n.map((e) => e.type === "text" && e.status === "streaming" ? {
666
401
  ...e,
667
402
  status: "done"
@@ -672,13 +407,13 @@ function Ie(e, t) {
672
407
  content: t,
673
408
  status: "done"
674
409
  }, r) : [...r, {
675
- id: O("text"),
410
+ id: E("text"),
676
411
  type: "text",
677
412
  content: t,
678
413
  status: "done"
679
414
  }];
680
415
  }
681
- function Le(e, t) {
416
+ function ue(e, t) {
682
417
  if (!t) return [...e ?? []];
683
418
  let n = [...e ?? []], r = n[n.length - 1];
684
419
  if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
@@ -688,8 +423,8 @@ function Le(e, t) {
688
423
  content: i
689
424
  }, n) : (n.pop(), n);
690
425
  }
691
- function Re(e, t, n) {
692
- let r = [...k(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
426
+ function de(e, t, n) {
427
+ let r = [...D(e ?? [])], i = r.findIndex((e) => e.type === "tool" && e.toolName === t);
693
428
  if (i >= 0 && r[i].type === "tool") {
694
429
  let e = r[i], t = e.status === "error" || e.status === "completed", a = n.output !== void 0, o = n.extra && (n.extra.approvalRequestId || n.extra.approvalStatus);
695
430
  if (t && !a && !o) return r;
@@ -701,7 +436,7 @@ function Re(e, t, n) {
701
436
  }, r;
702
437
  }
703
438
  return [...r, {
704
- id: O("tool"),
439
+ id: E("tool"),
705
440
  type: "tool",
706
441
  toolName: t,
707
442
  args: n.args ?? "",
@@ -710,18 +445,18 @@ function Re(e, t, n) {
710
445
  extra: n.extra
711
446
  }];
712
447
  }
713
- function ze(e) {
714
- return k(e ?? []);
448
+ function fe(e) {
449
+ return D(e ?? []);
715
450
  }
716
- function Be(e) {
451
+ function pe(e) {
717
452
  let t = [];
718
453
  if (e.reasoning && e.reasoning.trim() && t.push({
719
- id: O("thinking"),
454
+ id: E("thinking"),
720
455
  type: "thinking",
721
456
  content: e.reasoning,
722
457
  status: "done"
723
458
  }), e.tools) for (let n of Object.values(e.tools)) t.push({
724
- id: O("tool"),
459
+ id: E("tool"),
725
460
  type: "tool",
726
461
  toolName: n.name,
727
462
  args: n.args ?? "",
@@ -730,7 +465,7 @@ function Be(e) {
730
465
  ...n.callId ? { extra: { callId: n.callId } } : {}
731
466
  });
732
467
  return e.content && e.content.trim() && t.push({
733
- id: O("text"),
468
+ id: E("text"),
734
469
  type: "text",
735
470
  content: e.content,
736
471
  status: "done"
@@ -738,40 +473,40 @@ function Be(e) {
738
473
  }
739
474
  //#endregion
740
475
  //#region src/core/stream/kernel-events.ts
741
- var Ve = {
476
+ var me = {
742
477
  "run.started": "in_progress",
743
478
  "run.progress": "in_progress",
744
479
  "run.completed": "completed",
745
480
  "run.failed": "failed",
746
481
  "run.canceled": "cancelled",
747
482
  "run.interrupted": "interrupted"
748
- }, He = new Set([
483
+ }, he = new Set([
749
484
  "completed",
750
485
  "failed",
751
486
  "cancelled",
752
487
  "canceled"
753
488
  ]);
754
- function A(e) {
489
+ function O(e) {
755
490
  return typeof e == "object" && e && !Array.isArray(e) ? e : null;
756
491
  }
757
- function Ue(e) {
758
- let t = A(e.source), n = t ? A(t.metadata) : null;
492
+ function ge(e) {
493
+ let t = O(e.source), n = t ? O(t.metadata) : null;
759
494
  return String(n?.native_item_kind || "");
760
495
  }
761
- function j(e, t) {
762
- let n = A(e[t]);
496
+ function k(e, t) {
497
+ let n = O(e[t]);
763
498
  if (!n) return [];
764
499
  let r = n?.parts;
765
500
  return Array.isArray(r) ? r : t === "update" ? [n] : [];
766
501
  }
767
- function We(e) {
768
- let t = A(e);
502
+ function _e(e) {
503
+ let t = O(e);
769
504
  if (!t) return "";
770
505
  if (typeof t.text == "string") return t.text;
771
- let n = A(t.data);
506
+ let n = O(t.data);
772
507
  if (n) {
773
508
  let e = n.content;
774
- if (Array.isArray(e)) return e.map((e) => String(A(e)?.text || "")).join("");
509
+ if (Array.isArray(e)) return e.map((e) => String(O(e)?.text || "")).join("");
775
510
  for (let e of [
776
511
  "text",
777
512
  "output",
@@ -781,31 +516,31 @@ function We(e) {
781
516
  }
782
517
  return "";
783
518
  }
784
- function M(e) {
785
- return e.map(We).join("");
519
+ function A(e) {
520
+ return e.map(_e).join("");
786
521
  }
787
- function Ge(e) {
788
- return e.some((e) => A(A(e)?.data)?.type === "userMessage");
522
+ function j(e) {
523
+ return e.some((e) => O(O(e)?.data)?.type === "userMessage");
789
524
  }
790
- function N(e) {
525
+ function M(e) {
791
526
  if (e.length === 1) {
792
- let t = A(A(e[0])?.data);
527
+ let t = O(O(e[0])?.data);
793
528
  if (t) return t;
794
529
  }
795
- return M(e) || null;
530
+ return A(e) || null;
796
531
  }
797
- function P(e) {
798
- let t = A(e);
799
- return t ? A(t.data) || t : null;
532
+ function N(e) {
533
+ let t = O(e);
534
+ return t ? O(t.data) || t : null;
800
535
  }
801
- function F(e) {
802
- let t = P(e);
536
+ function P(e) {
537
+ let t = N(e);
803
538
  return String(t?.content_type || t?.type || "").trim().toLowerCase();
804
539
  }
805
- function I(e) {
540
+ function F(e) {
806
541
  for (let t of e) {
807
- let e = P(t);
808
- if (!e || F(t) !== "tool_call") continue;
542
+ let e = N(t);
543
+ if (!e || P(t) !== "tool_call") continue;
809
544
  let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
810
545
  if (!(!n && !r)) return {
811
546
  callId: n,
@@ -815,10 +550,10 @@ function I(e) {
815
550
  }
816
551
  return null;
817
552
  }
818
- function L(e) {
553
+ function I(e) {
819
554
  for (let t of e) {
820
- let e = P(t);
821
- if (!e || F(t) !== "tool_result") continue;
555
+ let e = N(t);
556
+ if (!e || P(t) !== "tool_result") continue;
822
557
  let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
823
558
  return {
824
559
  callId: n,
@@ -828,7 +563,7 @@ function L(e) {
828
563
  }
829
564
  return null;
830
565
  }
831
- function R(e, t, n, r) {
566
+ function L(e, t, n, r) {
832
567
  let i = String(e.item_id || ""), a = String(r || i);
833
568
  return { RuntimeItem: {
834
569
  RunId: String(e.run_id || ""),
@@ -840,7 +575,7 @@ function R(e, t, n, r) {
840
575
  ...i && i !== a ? { SourceItemId: i } : {}
841
576
  } };
842
577
  }
843
- var Ke = class {
578
+ var R = class {
844
579
  textByPart = /* @__PURE__ */ new Map();
845
580
  toolNameByCallId = /* @__PURE__ */ new Map();
846
581
  toolCallByItemId = /* @__PURE__ */ new Map();
@@ -850,7 +585,7 @@ var Ke = class {
850
585
  this.sessionId = e;
851
586
  }
852
587
  translate(e) {
853
- if (!A(e)) return null;
588
+ if (!O(e)) return null;
854
589
  let t = Number(e.seq);
855
590
  if (!Number.isFinite(t) || t <= 0) return null;
856
591
  let n = String(e.family || ""), r = String(e.event_type || ""), i = String(e.run_id || ""), a = () => ({
@@ -867,7 +602,7 @@ var Ke = class {
867
602
  if (n === "control") {
868
603
  if (r === "control.run_transition") {
869
604
  let t = String(e.state || "").toLowerCase();
870
- if (He.has(t)) return {
605
+ if (he.has(t)) return {
871
606
  ...a(),
872
607
  EventType: "run_status",
873
608
  Content: { status: t }
@@ -876,17 +611,17 @@ var Ke = class {
876
611
  return null;
877
612
  }
878
613
  if (n !== "runtime") return null;
879
- let o = Ve[r];
614
+ let o = me[r];
880
615
  if (o) return {
881
616
  ...a(),
882
617
  EventType: "run_status",
883
618
  Content: { status: o }
884
619
  };
885
- let s = Ue(e);
620
+ let s = ge(e);
886
621
  if (r === "item.started") {
887
- let t = j(e, "initial");
622
+ let t = k(e, "initial");
888
623
  if (e.item_kind === "tool_call") {
889
- let n = I(t), r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
624
+ let n = F(t), r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
890
625
  return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
891
626
  callId: r,
892
627
  name: o
@@ -894,42 +629,42 @@ var Ke = class {
894
629
  ...a(),
895
630
  EventType: "tool_call",
896
631
  Metadata: {
897
- ...R(e, "replace", void 0, r),
632
+ ...L(e, "replace", void 0, r),
898
633
  call_id: r,
899
634
  tool_name: o,
900
635
  run_id: i,
901
- tool_args: n?.arguments ?? N(t)
636
+ tool_args: n?.arguments ?? M(t)
902
637
  }
903
638
  };
904
639
  }
905
- return e.item_kind === "tool_result" || s === "userMessage" || Ge(t) || s === "reasoning" || e.item_kind === "reasoning" ? null : s === "agentMessage" || !s && e.item_kind === "message" ? {
640
+ return e.item_kind === "tool_result" || s === "userMessage" || j(t) || s === "reasoning" || e.item_kind === "reasoning" ? null : s === "agentMessage" || !s && e.item_kind === "message" ? {
906
641
  ...a(),
907
642
  EventType: "assistant_stream_snapshot",
908
643
  Content: { parts: [{ text: "" }] },
909
- Metadata: R(e, "replace")
644
+ Metadata: L(e, "replace")
910
645
  } : s && s !== "notification" ? {
911
646
  ...a(),
912
647
  EventType: "tool_call",
913
648
  Metadata: {
914
- ...R(e, "replace"),
649
+ ...L(e, "replace"),
915
650
  call_id: String(e.item_id || ""),
916
651
  tool_name: s,
917
652
  run_id: i,
918
- tool_args: N(t)
653
+ tool_args: M(t)
919
654
  }
920
655
  } : null;
921
656
  }
922
657
  if (r === "item.updated") {
923
- let n = j(e, "update");
658
+ let n = k(e, "update");
924
659
  if (e.item_kind === "tool_call") {
925
- let t = L(n);
660
+ let t = I(n);
926
661
  if (!t) return null;
927
662
  let r = this.toolCallByItemId.get(String(e.item_id || "")), o = t.callId || r?.callId || String(e.item_id || ""), s = r?.name || this.toolNameByCallId.get(o) || "tool", c = t.isError ? { error: t.result } : t.result;
928
663
  return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
929
664
  ...a(),
930
665
  EventType: "tool_result",
931
666
  Metadata: {
932
- ...R(e, "completed", void 0, o),
667
+ ...L(e, "completed", void 0, o),
933
668
  call_id: o,
934
669
  tool_name: s,
935
670
  run_id: i,
@@ -937,44 +672,44 @@ var Ke = class {
937
672
  }
938
673
  };
939
674
  }
940
- let r = A(n[0]), o = String(r?.part_id || e.item_id || t), c = String(e.op || "replace"), l = M(n), u = this.textByPart.get(o) || "", d = c === "append" ? u + l : l;
675
+ let r = O(n[0]), o = String(r?.part_id || e.item_id || t), c = String(e.op || "replace"), l = A(n), u = this.textByPart.get(o) || "", d = c === "append" ? u + l : l;
941
676
  return this.textByPart.set(o, d), s === "agentMessage" || !s && e.item_kind === "message" ? {
942
677
  ...a(),
943
678
  EventType: "assistant_stream_snapshot",
944
679
  Content: { parts: [{ text: d }] },
945
- Metadata: R(e, "replace", o)
680
+ Metadata: L(e, "replace", o)
946
681
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
947
682
  ...a(),
948
683
  EventType: "reasoning",
949
684
  Content: { parts: [{ text: l }] },
950
- Metadata: R(e, c === "append" ? "append" : "replace", o)
685
+ Metadata: L(e, c === "append" ? "append" : "replace", o)
951
686
  } : null;
952
687
  }
953
688
  if (r === "item.snapshot_replaced") {
954
- let n = j(e, "snapshot"), r = String(A(n[0])?.part_id || e.item_id || t), i = M(n);
689
+ let n = k(e, "snapshot"), r = String(O(n[0])?.part_id || e.item_id || t), i = A(n);
955
690
  return this.textByPart.set(r, i), s === "agentMessage" || !s && e.item_kind === "message" ? {
956
691
  ...a(),
957
692
  EventType: "assistant_stream_snapshot",
958
693
  Content: { parts: [{ text: i }] },
959
- Metadata: R(e, "replace", r)
694
+ Metadata: L(e, "replace", r)
960
695
  } : s === "reasoning" || e.item_kind === "reasoning" ? {
961
696
  ...a(),
962
697
  EventType: "reasoning",
963
698
  Content: { parts: [{ text: i }] },
964
- Metadata: R(e, "replace", r)
699
+ Metadata: L(e, "replace", r)
965
700
  } : null;
966
701
  }
967
702
  if (r === "item.completed") {
968
- let n = j(e, "snapshot");
703
+ let n = k(e, "snapshot");
969
704
  if (e.item_kind === "tool_call") {
970
- let t = I(n), r = L(n), o = this.toolCallByItemId.get(String(e.item_id || "")), s = r?.callId || t?.callId || o?.callId || String(e.item_id || ""), c = t?.name || o?.name || this.toolNameByCallId.get(s) || "tool";
705
+ let t = F(n), r = I(n), o = this.toolCallByItemId.get(String(e.item_id || "")), s = r?.callId || t?.callId || o?.callId || String(e.item_id || ""), c = t?.name || o?.name || this.toolNameByCallId.get(s) || "tool";
971
706
  if (s && this.toolNameByCallId.set(s, c), r) {
972
707
  let t = r.isError ? { error: r.result } : r.result;
973
708
  return {
974
709
  ...a(),
975
710
  EventType: "tool_result",
976
711
  Metadata: {
977
- ...R(e, "completed", void 0, s),
712
+ ...L(e, "completed", void 0, s),
978
713
  call_id: s,
979
714
  tool_name: c,
980
715
  run_id: i,
@@ -986,21 +721,21 @@ var Ke = class {
986
721
  ...a(),
987
722
  EventType: "tool_call",
988
723
  Metadata: {
989
- ...R(e, "replace", void 0, s),
724
+ ...L(e, "replace", void 0, s),
990
725
  call_id: s,
991
726
  tool_name: c,
992
727
  run_id: i,
993
- tool_args: t?.arguments ?? N(n)
728
+ tool_args: t?.arguments ?? M(n)
994
729
  }
995
730
  };
996
731
  }
997
732
  if (e.item_kind === "tool_result") {
998
- let t = L(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || s || "tool", c = t?.isError ? { error: t.result } : t?.result ?? N(n);
733
+ let t = I(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || s || "tool", c = t?.isError ? { error: t.result } : t?.result ?? M(n);
999
734
  return {
1000
735
  ...a(),
1001
736
  EventType: "tool_result",
1002
737
  Metadata: {
1003
- ...R(e, "completed", void 0, r),
738
+ ...L(e, "completed", void 0, r),
1004
739
  call_id: r,
1005
740
  tool_name: o,
1006
741
  run_id: i,
@@ -1008,38 +743,38 @@ var Ke = class {
1008
743
  }
1009
744
  };
1010
745
  }
1011
- if (s === "userMessage" || Ge(n)) return {
746
+ if (s === "userMessage" || j(n)) return {
1012
747
  ...a(),
1013
748
  EventType: "user_message",
1014
- Content: { parts: [{ text: M(n) }] }
749
+ Content: { parts: [{ text: A(n) }] }
1015
750
  };
1016
751
  if (s === "agentMessage" || !s && e.item_kind === "message") {
1017
- let r = M(n), i = String(A(n[0])?.part_id || e.item_id || t);
752
+ let r = A(n), i = String(O(n[0])?.part_id || e.item_id || t);
1018
753
  return this.textByPart.set(i, r), {
1019
754
  ...a(),
1020
755
  EventType: "assistant_message",
1021
756
  Content: { parts: [{ text: r }] },
1022
- Metadata: R(e, "completed", i)
757
+ Metadata: L(e, "completed", i)
1023
758
  };
1024
759
  }
1025
760
  if (s === "reasoning" || e.item_kind === "reasoning") {
1026
- let r = String(A(n[0])?.part_id || e.item_id || t);
761
+ let r = String(O(n[0])?.part_id || e.item_id || t);
1027
762
  return {
1028
763
  ...a(),
1029
764
  EventType: "reasoning",
1030
- Content: { parts: [{ text: M(n) }] },
1031
- Metadata: R(e, "completed", r)
765
+ Content: { parts: [{ text: A(n) }] },
766
+ Metadata: L(e, "completed", r)
1032
767
  };
1033
768
  }
1034
769
  return s && s !== "notification" ? {
1035
770
  ...a(),
1036
771
  EventType: "tool_result",
1037
772
  Metadata: {
1038
- ...R(e, "completed"),
773
+ ...L(e, "completed"),
1039
774
  call_id: String(e.item_id || ""),
1040
775
  tool_name: s,
1041
776
  run_id: i,
1042
- tool_output: N(n)
777
+ tool_output: M(n)
1043
778
  }
1044
779
  } : null;
1045
780
  }
@@ -1050,11 +785,11 @@ var Ke = class {
1050
785
  ...a(),
1051
786
  EventType: "tool_result",
1052
787
  Metadata: {
1053
- ...R(e, "completed", void 0, n),
788
+ ...L(e, "completed", void 0, n),
1054
789
  call_id: n,
1055
790
  tool_name: r,
1056
791
  run_id: i,
1057
- tool_output: o ?? { error: A(e.error) || e.error || "item failed" }
792
+ tool_output: o ?? { error: O(e.error) || e.error || "item failed" }
1058
793
  }
1059
794
  };
1060
795
  }
@@ -1062,18 +797,18 @@ var Ke = class {
1062
797
  ...a(),
1063
798
  EventType: "tool_result",
1064
799
  Metadata: {
1065
- ...R(e, "completed"),
800
+ ...L(e, "completed"),
1066
801
  call_id: String(e.item_id || ""),
1067
802
  tool_name: s,
1068
803
  run_id: i,
1069
- tool_output: { error: A(e.error) || e.error || "item failed" }
804
+ tool_output: { error: O(e.error) || e.error || "item failed" }
1070
805
  }
1071
806
  } : null;
1072
807
  }
1073
808
  return null;
1074
809
  }
1075
810
  };
1076
- async function qe(e) {
811
+ async function ve(e) {
1077
812
  let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
1078
813
  try {
1079
814
  for (;;) {
@@ -1083,8 +818,8 @@ async function qe(e) {
1083
818
  break;
1084
819
  }
1085
820
  if (r.trimStart().startsWith("{")) {
1086
- if (Je(r)) {
1087
- i = Ye(r);
821
+ if (ye(r)) {
822
+ i = be(r);
1088
823
  break;
1089
824
  }
1090
825
  } else if (o(r)) break;
@@ -1118,7 +853,7 @@ async function qe(e) {
1118
853
  stream: c
1119
854
  };
1120
855
  }
1121
- function Je(e) {
856
+ function ye(e) {
1122
857
  let t = e.trim();
1123
858
  if (!t.endsWith("}")) return !1;
1124
859
  let n = 0, r = !1, i = !1;
@@ -1135,11 +870,11 @@ function Je(e) {
1135
870
  }
1136
871
  return n === 0;
1137
872
  }
1138
- function Ye(e) {
873
+ function be(e) {
1139
874
  try {
1140
- let t = A(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
875
+ let t = O(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
1141
876
  if (!n) return null;
1142
- let r = A(t?.Error);
877
+ let r = O(t?.Error);
1143
878
  return {
1144
879
  status: n,
1145
880
  messageId: t?.MessageId ?? null,
@@ -1156,7 +891,7 @@ function Ye(e) {
1156
891
  }
1157
892
  //#endregion
1158
893
  //#region src/utils/responses-stream.js
1159
- function Xe() {
894
+ function z() {
1160
895
  return {
1161
896
  toolNames: /* @__PURE__ */ new Map(),
1162
897
  toolArguments: /* @__PURE__ */ new Map(),
@@ -1166,51 +901,51 @@ function Xe() {
1166
901
  sawReasoningDelta: !1
1167
902
  };
1168
903
  }
1169
- function Ze(e) {
904
+ function xe(e) {
1170
905
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e && typeof e == "object" && typeof e.text == "string" ? e.text : "").join("") : e && typeof e == "object" && typeof e.text == "string" ? e.text : "";
1171
906
  }
1172
- function z(e) {
907
+ function B(e) {
1173
908
  return e == null ? "" : typeof e == "string" ? e : typeof e == "object" ? JSON.stringify(e, null, 2) : String(e);
1174
909
  }
1175
- function B(...e) {
910
+ function V(...e) {
1176
911
  for (let t of e) {
1177
- let e = Ze(t);
912
+ let e = xe(t);
1178
913
  if (e) return e;
1179
914
  }
1180
915
  return "";
1181
916
  }
1182
- function Qe(e, t) {
917
+ function Se(e, t) {
1183
918
  return String(e?.id || e?.item_id || e?.call_id || t?.item_id || t?.call_id || t?.output_index || "");
1184
919
  }
1185
- function $e(e, t, n, r, i) {
920
+ function Ce(e, t, n, r, i) {
1186
921
  t && (e.toolNames.set(t, r), e.toolArguments.set(t, i));
1187
922
  let a = String(n?.call_id || "");
1188
923
  a && (e.callIds.set(a, t || r), e.toolNames.set(a, r), e.toolArguments.set(a, i));
1189
924
  }
1190
- function V(e, t, n, r = "tool") {
925
+ function H(e, t, n, r = "tool") {
1191
926
  let i = String(n?.call_id || "");
1192
927
  return String(n?.name || n?.tool_name || (t ? e.toolNames.get(t) : "") || (i ? e.toolNames.get(i) : "") || r);
1193
928
  }
1194
- function H(e) {
929
+ function U(e) {
1195
930
  if (!e || typeof e != "object") return "";
1196
- let t = Ze(e.content);
1197
- return B(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
931
+ let t = xe(e.content);
932
+ return V(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
1198
933
  }
1199
- function et(e) {
1200
- let t = e?.response && typeof e.response == "object" ? e.response : e, n = B(t?.output_text, t?.text);
934
+ function we(e) {
935
+ let t = e?.response && typeof e.response == "object" ? e.response : e, n = V(t?.output_text, t?.text);
1201
936
  if (n) return n;
1202
937
  let r = Array.isArray(t?.output) ? t.output : [];
1203
938
  for (let e of r) {
1204
- let t = H(e);
939
+ let t = U(e);
1205
940
  if (t) return t;
1206
941
  }
1207
942
  return "";
1208
943
  }
1209
- function tt(e) {
944
+ function Te(e) {
1210
945
  let t = e?.response && typeof e.response == "object" ? e.response : e;
1211
946
  return Array.isArray(t?.output) ? t.output : [];
1212
947
  }
1213
- function nt(e) {
948
+ function Ee(e) {
1214
949
  let t = e;
1215
950
  if (typeof t == "string") try {
1216
951
  t = JSON.parse(t);
@@ -1222,11 +957,11 @@ function nt(e) {
1222
957
  approval_request_id: t.value.approval_request_id || t.value.id || t.id
1223
958
  } : t;
1224
959
  }
1225
- function U({ data: e, state: t, status: n }) {
1226
- let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Qe(r, e);
960
+ function W({ data: e, state: t, status: n }) {
961
+ let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = Se(r, e);
1227
962
  if (i === "function_call") {
1228
- let e = V(t, a, r), i = z(r.arguments ?? r.args ?? r.input);
1229
- return $e(t, a, r, e, i), [{
963
+ let e = H(t, a, r), i = B(r.arguments ?? r.args ?? r.input);
964
+ return Ce(t, a, r, e, i), [{
1230
965
  type: "tool_upsert",
1231
966
  name: e,
1232
967
  args: i,
@@ -1235,11 +970,11 @@ function U({ data: e, state: t, status: n }) {
1235
970
  }
1236
971
  if (i === "function_call_output") return [{
1237
972
  type: "tool_result",
1238
- name: V(t, a, r),
1239
- output: z(r.output ?? r.result ?? r.content)
973
+ name: H(t, a, r),
974
+ output: B(r.output ?? r.result ?? r.content)
1240
975
  }];
1241
976
  if (i === "mcp_approval_request") {
1242
- let n = String(r.name || "approval"), i = z(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || ""), o = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
977
+ let n = String(r.name || "approval"), i = B(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || ""), o = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
1243
978
  return [{
1244
979
  type: "tool_upsert",
1245
980
  name: n,
@@ -1258,14 +993,14 @@ function U({ data: e, state: t, status: n }) {
1258
993
  }];
1259
994
  }
1260
995
  if (i === "reasoning" || i === "reasoning_summary" || i === "reasoning_summary_text") {
1261
- let e = H(r);
996
+ let e = U(r);
1262
997
  return e ? [{
1263
998
  type: "reasoning_delta",
1264
999
  text: e
1265
1000
  }] : [];
1266
1001
  }
1267
1002
  if (i === "message") {
1268
- let e = H(r);
1003
+ let e = U(r);
1269
1004
  return e ? [{
1270
1005
  type: n === "completed" ? "text_final" : "text_delta",
1271
1006
  text: e
@@ -1273,31 +1008,31 @@ function U({ data: e, state: t, status: n }) {
1273
1008
  }
1274
1009
  return [];
1275
1010
  }
1276
- function rt({ eventName: e, data: t, state: n }) {
1011
+ function De({ eventName: e, data: t, state: n }) {
1277
1012
  let r = String(t?.type || e || "").trim(), i = String(t?.id || t?.response?.id || t?.response_id || "");
1278
1013
  if (i.startsWith("resp_") && (n.currentResponseId = i), r === "response.tool_call") return [{
1279
1014
  type: "tool_upsert",
1280
1015
  name: String(t?.name || t?.tool_name || "tool"),
1281
- args: z(t?.args ?? t?.arguments),
1016
+ args: B(t?.args ?? t?.arguments),
1282
1017
  status: "running"
1283
1018
  }];
1284
1019
  if (r === "response.tool_result" || r === "response.ksadk.tool_result") return [{
1285
1020
  type: "tool_result",
1286
1021
  name: String(t?.name || t?.tool_name || "tool"),
1287
- output: z(t?.output ?? t?.result)
1022
+ output: B(t?.output ?? t?.result)
1288
1023
  }];
1289
- if (r === "response.output_item.added") return U({
1024
+ if (r === "response.output_item.added") return W({
1290
1025
  data: t,
1291
1026
  state: n,
1292
1027
  status: "running"
1293
1028
  });
1294
- if (r === "response.output_item.done") return U({
1029
+ if (r === "response.output_item.done") return W({
1295
1030
  data: t,
1296
1031
  state: n,
1297
1032
  status: "completed"
1298
1033
  });
1299
1034
  if (r === "response.function_call_arguments.delta") {
1300
- let e = String(t?.item_id || t?.call_id || ""), r = V(n, e, t), i = `${n.toolArguments.get(e) || ""}${String(t?.delta || "")}`;
1035
+ let e = String(t?.item_id || t?.call_id || ""), r = H(n, e, t), i = `${n.toolArguments.get(e) || ""}${String(t?.delta || "")}`;
1301
1036
  return n.toolArguments.set(e, i), [{
1302
1037
  type: "tool_upsert",
1303
1038
  name: r,
@@ -1306,7 +1041,7 @@ function rt({ eventName: e, data: t, state: n }) {
1306
1041
  }];
1307
1042
  }
1308
1043
  if (r === "response.function_call_arguments.done") {
1309
- let e = String(t?.item_id || t?.call_id || ""), r = V(n, e, t), i = z(t?.arguments ?? n.toolArguments.get(e));
1044
+ let e = String(t?.item_id || t?.call_id || ""), r = H(n, e, t), i = B(t?.arguments ?? n.toolArguments.get(e));
1310
1045
  return n.toolArguments.set(e, i), [{
1311
1046
  type: "tool_upsert",
1312
1047
  name: r,
@@ -1315,28 +1050,28 @@ function rt({ eventName: e, data: t, state: n }) {
1315
1050
  }];
1316
1051
  }
1317
1052
  if (r === "response.reasoning.delta" || r === "response.reasoning_text.delta" || r === "response.reasoning_summary.delta" || r === "response.reasoning_summary_text.delta") {
1318
- let e = B(t?.delta, t?.text);
1053
+ let e = V(t?.delta, t?.text);
1319
1054
  return e && (n.sawReasoningDelta = !0), e ? [{
1320
1055
  type: "reasoning_delta",
1321
1056
  text: e
1322
1057
  }] : [];
1323
1058
  }
1324
1059
  if (r === "response.output_text.delta") {
1325
- let e = B(t?.delta, t?.text);
1060
+ let e = V(t?.delta, t?.text);
1326
1061
  return e && (n.sawTextDelta = !0), e ? [{
1327
1062
  type: "text_delta",
1328
1063
  text: e
1329
1064
  }] : [];
1330
1065
  }
1331
1066
  if (r === "response.output_text.done") {
1332
- let e = B(t?.text, t?.delta);
1067
+ let e = V(t?.text, t?.delta);
1333
1068
  return e ? [{
1334
1069
  type: "text_final",
1335
1070
  text: e
1336
1071
  }] : [];
1337
1072
  }
1338
1073
  if (r === "response.content_part.delta") {
1339
- let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), r = B(t?.delta?.text, t?.delta, t?.text);
1074
+ let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), r = V(t?.delta?.text, t?.delta, t?.text);
1340
1075
  return r ? e.includes("reasoning") ? (n.sawReasoningDelta = !0, [{
1341
1076
  type: "reasoning_delta",
1342
1077
  text: r
@@ -1346,7 +1081,7 @@ function rt({ eventName: e, data: t, state: n }) {
1346
1081
  }]) : [];
1347
1082
  }
1348
1083
  if (r === "response.completed") {
1349
- let e = et(t), r = tt(t).flatMap((e) => U({
1084
+ let e = we(t), r = Te(t).flatMap((e) => W({
1350
1085
  data: {
1351
1086
  ...t,
1352
1087
  item: e
@@ -1382,7 +1117,7 @@ function rt({ eventName: e, data: t, state: n }) {
1382
1117
  status: "cancelled"
1383
1118
  }];
1384
1119
  if (r === "response.approval_request" || r === "response.ksadk.approval_request") {
1385
- let e = nt(t?.interrupt_info), r = String(e.approval_request_id || e.id || ""), i = String(t?.response_id || n.currentResponseId || ""), a = String(t?.run_id || t?.runId || ""), o = e.approval_requests && typeof e.approval_requests == "object" ? e.approval_requests : e, s = Array.isArray(o.action_requests) ? o.action_requests : [];
1120
+ let e = Ee(t?.interrupt_info), r = String(e.approval_request_id || e.id || ""), i = String(t?.response_id || n.currentResponseId || ""), a = String(t?.run_id || t?.runId || ""), o = e.approval_requests && typeof e.approval_requests == "object" ? e.approval_requests : e, s = Array.isArray(o.action_requests) ? o.action_requests : [];
1386
1121
  if (s.length > 0) {
1387
1122
  let e = s.map((e) => ({
1388
1123
  type: "tool_upsert",
@@ -1470,7 +1205,7 @@ function rt({ eventName: e, data: t, state: n }) {
1470
1205
  }
1471
1206
  //#endregion
1472
1207
  //#region src/utils/session-events.js
1473
- var it = new Set([
1208
+ var Oe = new Set([
1474
1209
  "completed",
1475
1210
  "failed",
1476
1211
  "error",
@@ -1479,12 +1214,12 @@ var it = new Set([
1479
1214
  "aborted",
1480
1215
  "interrupted",
1481
1216
  "resume_failed"
1482
- ]), W = new Set([
1217
+ ]), G = new Set([
1483
1218
  "tool_call",
1484
1219
  "tool_result",
1485
1220
  "stage_tool_call",
1486
1221
  "stage_tool_result"
1487
- ]), G = {
1222
+ ]), K = {
1488
1223
  "run.started": "in_progress",
1489
1224
  "run.progress": "in_progress",
1490
1225
  "run.interrupted": "interrupted",
@@ -1492,21 +1227,21 @@ var it = new Set([
1492
1227
  "run.failed": "failed",
1493
1228
  "run.canceled": "cancelled"
1494
1229
  };
1495
- function K(e) {
1230
+ function q(e) {
1496
1231
  let t = e?.Content?.payload;
1497
1232
  return t && typeof t == "object" ? t : {};
1498
1233
  }
1499
- function at(e, t) {
1234
+ function ke(e, t) {
1500
1235
  let n = String(e || ""), r = String(t || "");
1501
1236
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1502
1237
  }
1503
- function ot(e) {
1504
- let t = String(e?.EventType || ""), n = K(e);
1505
- return G[t] ? {
1238
+ function Ae(e) {
1239
+ let t = String(e?.EventType || ""), n = q(e);
1240
+ return K[t] ? {
1506
1241
  ...e,
1507
1242
  EventType: "run_status",
1508
1243
  Content: {
1509
- status: String(n.status || G[t]),
1244
+ status: String(n.status || K[t]),
1510
1245
  ...n.detail ? { detail: String(n.detail) } : {}
1511
1246
  }
1512
1247
  } : t === "reasoning.delta" || t === "reasoning.completed" ? {
@@ -1544,7 +1279,7 @@ function ot(e) {
1544
1279
  }
1545
1280
  } : e;
1546
1281
  }
1547
- function st(e) {
1282
+ function je(e) {
1548
1283
  let t = [], n = /* @__PURE__ */ new Map();
1549
1284
  for (let r of Array.isArray(e) ? e : []) {
1550
1285
  let e = String(r?.EventType || "");
@@ -1554,11 +1289,11 @@ function st(e) {
1554
1289
  let t = n.get(e);
1555
1290
  n.set(e, {
1556
1291
  event: r,
1557
- text: at(t?.text, K(r).text)
1292
+ text: ke(t?.text, q(r).text)
1558
1293
  });
1559
1294
  continue;
1560
1295
  }
1561
- t.push(ot(r));
1296
+ t.push(Ae(r));
1562
1297
  }
1563
1298
  for (let { event: e, text: r } of n.values()) t.push({
1564
1299
  ...e,
@@ -1574,27 +1309,27 @@ function st(e) {
1574
1309
  });
1575
1310
  return t.sort((e, t) => Q(e) - Q(t));
1576
1311
  }
1577
- function ct(e) {
1312
+ function Me(e) {
1578
1313
  let t = String(e?.EventType || "").trim();
1579
1314
  if (t !== "run_status" && !t.startsWith("run.")) return "";
1580
- let n = K(e);
1581
- return String(e?.Content?.status || n.status || G[t] || "").trim().toLowerCase();
1315
+ let n = q(e);
1316
+ return String(e?.Content?.status || n.status || K[t] || "").trim().toLowerCase();
1582
1317
  }
1583
- function q(e) {
1318
+ function J(e) {
1584
1319
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e && typeof e == "object" && typeof e.text == "string" ? e.text : "").join("") : "";
1585
1320
  }
1586
- function J(e) {
1321
+ function Y(e) {
1587
1322
  let t = String(e || "").trim();
1588
1323
  return t ? `/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}` : "";
1589
1324
  }
1590
- function lt(e) {
1325
+ function Ne(e) {
1591
1326
  return String(e || "").match(/^data:([^;,]+)/)?.[1] || "";
1592
1327
  }
1593
- function ut(e, t) {
1328
+ function Pe(e, t) {
1594
1329
  let n = String(e || "").trim(), r = String(t || "").trim();
1595
1330
  return !n || !r || n === r ? !0 : n.endsWith("/*") ? r.startsWith(n.slice(0, -1)) : r.endsWith("/*") ? n.startsWith(r.slice(0, -1)) : !1;
1596
1331
  }
1597
- function Y(e) {
1332
+ function X(e) {
1598
1333
  let t = e?.Content?.parts || [], n = [], r = /* @__PURE__ */ new Map(), i = (e) => {
1599
1334
  let t = `${e.fileUri || e.url || e.name}|${e.type}`;
1600
1335
  r.has(t) || r.set(t, e);
@@ -1624,7 +1359,7 @@ function Y(e) {
1624
1359
  let t = e.file_url.trim();
1625
1360
  i({
1626
1361
  name: e.filename || e.displayName || e.display_name || "attachment",
1627
- url: J(t),
1362
+ url: Y(t),
1628
1363
  type: e.mime_type || e.mimeType || "application/octet-stream",
1629
1364
  fileUri: t
1630
1365
  });
@@ -1635,7 +1370,7 @@ function Y(e) {
1635
1370
  t && i({
1636
1371
  name: e.filename || e.displayName || e.display_name || "uploaded_image",
1637
1372
  url: t,
1638
- type: e.mime_type || e.mimeType || lt(t) || "image/*"
1373
+ type: e.mime_type || e.mimeType || Ne(t) || "image/*"
1639
1374
  });
1640
1375
  continue;
1641
1376
  }
@@ -1643,7 +1378,7 @@ function Y(e) {
1643
1378
  let t = String(e.fileData.fileUri || "").trim();
1644
1379
  i({
1645
1380
  name: e.fileData.displayName || "attachment",
1646
- url: J(t),
1381
+ url: Y(t),
1647
1382
  type: e.fileData.mimeType || "application/octet-stream",
1648
1383
  fileUri: t
1649
1384
  });
@@ -1653,11 +1388,11 @@ function Y(e) {
1653
1388
  for (let e of a) {
1654
1389
  let t = String(e.file_uri || "").trim(), n = {
1655
1390
  name: e.display_name || "attachment",
1656
- url: J(t),
1391
+ url: Y(t),
1657
1392
  type: e.mime_type || "application/octet-stream",
1658
1393
  fileUri: t
1659
1394
  };
1660
- !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && ut(e.type, n.type) && (e.url || e.fileUri)) || i(n);
1395
+ !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && Pe(e.type, n.type) && (e.url || e.fileUri)) || i(n);
1661
1396
  }
1662
1397
  let o = Array.from(r.values());
1663
1398
  return {
@@ -1665,10 +1400,10 @@ function Y(e) {
1665
1400
  attachments: o.length > 0 ? o : void 0
1666
1401
  };
1667
1402
  }
1668
- function dt(t) {
1403
+ function Fe(t) {
1669
1404
  let n = t?.Metadata?.responses_output;
1670
1405
  if (!Array.isArray(n)) return {};
1671
- let r = Xe(), i = rt({
1406
+ let r = z(), i = De({
1672
1407
  eventName: "response.completed",
1673
1408
  data: { response: {
1674
1409
  id: String(t.Metadata?.response_id || ""),
@@ -1712,10 +1447,10 @@ function dt(t) {
1712
1447
  ...Object.keys(o).length > 0 ? { tools: o } : {}
1713
1448
  };
1714
1449
  }
1715
- function ft(e, t, n) {
1450
+ function Ie(e, t, n) {
1716
1451
  return t === "running" ? e === "prompt_too_long" ? "检测到上下文过长,正在自动压缩历史后重试" : "正在自动压缩上下文" : n ? e === "prompt_too_long" ? "上下文过长,系统已自动压缩历史并重试" : "系统已自动压缩较早的对话上下文" : t === "failed" ? "自动压缩上下文未完成" : e === "prompt_too_long" ? "已完成上下文压缩,并继续当前回复" : "已完成上下文压缩";
1717
1452
  }
1718
- function pt(e, t) {
1453
+ function Le(e, t) {
1719
1454
  return t?.itemId ? [
1720
1455
  "runtime-item",
1721
1456
  t.runId || e,
@@ -1727,7 +1462,7 @@ function pt(e, t) {
1727
1462
  t.reasoning || ""
1728
1463
  ].join("\0");
1729
1464
  }
1730
- function X(e) {
1465
+ function Z(e) {
1731
1466
  let t = String(e?.InvocationId || "").trim(), n = e?.Metadata?.RuntimeItem;
1732
1467
  return n?.ItemId ? [
1733
1468
  "runtime-item",
@@ -1736,7 +1471,7 @@ function X(e) {
1736
1471
  n.ItemId
1737
1472
  ].join("\0") : t;
1738
1473
  }
1739
- function mt(e) {
1474
+ function Re(e) {
1740
1475
  let t = e?.Metadata?.RuntimeItem;
1741
1476
  return t?.ItemId ? {
1742
1477
  id: `runtime:${t.RunId || e.InvocationId || "run"}:${t.ScopeId || e.InvocationId || "scope"}:${t.ItemId}`,
@@ -1746,12 +1481,12 @@ function mt(e) {
1746
1481
  partId: t.PartId ? String(t.PartId) : void 0
1747
1482
  } : null;
1748
1483
  }
1749
- function ht(e) {
1484
+ function ze(e) {
1750
1485
  return e?.Metadata?.responses_mirror === !0 || String(e?.Metadata?.responses_mirror || "").trim().toLowerCase() === "true";
1751
1486
  }
1752
- function Z(e) {
1487
+ function Be(e) {
1753
1488
  if (e?.EventType !== "user_message") return "";
1754
- let t = Y(e), n = (t.attachments || []).map((e) => [
1489
+ let t = X(e), n = (t.attachments || []).map((e) => [
1755
1490
  e.name || "",
1756
1491
  e.fileUri || "",
1757
1492
  e.url || "",
@@ -1759,7 +1494,7 @@ function Z(e) {
1759
1494
  ].join("")).sort().join("");
1760
1495
  return [String(t.text || "").trim(), n].join("\0");
1761
1496
  }
1762
- function gt(e) {
1497
+ function Ve(e) {
1763
1498
  return e?.EventType === "assistant_stream_snapshot";
1764
1499
  }
1765
1500
  function Q(e) {
@@ -1768,7 +1503,7 @@ function Q(e) {
1768
1503
  let n = Number(e?.Timestamp || 0);
1769
1504
  return Number.isFinite(n) ? n : 0;
1770
1505
  }
1771
- function _t(e) {
1506
+ function He(e) {
1772
1507
  if (typeof e == "string") return e;
1773
1508
  if (e == null) return "";
1774
1509
  try {
@@ -1777,16 +1512,16 @@ function _t(e) {
1777
1512
  return String(e);
1778
1513
  }
1779
1514
  }
1780
- function vt(t) {
1515
+ function Ue(t) {
1781
1516
  let n = String(t?.EventType || "");
1782
- if (!W.has(n)) return null;
1783
- let r = String(t.Metadata?.tool_name || t.Metadata?.name || t.Metadata?.function_name || q(t.Content?.parts) || "tool").trim() || "tool", i = String(t.Metadata?.call_id || t.Metadata?.callId || t.Metadata?.RuntimeItem?.ToolCallId || "").trim(), a = {
1517
+ if (!G.has(n)) return null;
1518
+ let r = String(t.Metadata?.tool_name || t.Metadata?.name || t.Metadata?.function_name || J(t.Content?.parts) || "tool").trim() || "tool", i = String(t.Metadata?.call_id || t.Metadata?.callId || t.Metadata?.RuntimeItem?.ToolCallId || "").trim(), a = {
1784
1519
  name: r,
1785
1520
  ...i ? { callId: i } : {},
1786
1521
  args: "",
1787
1522
  status: "running"
1788
1523
  }, o = n === "tool_result" || n === "stage_tool_result" ? (() => {
1789
- let n = _t(t.Metadata?.tool_output ?? t.Metadata?.output ?? t.Metadata?.result ?? q(t.Content?.parts));
1524
+ let n = He(t.Metadata?.tool_output ?? t.Metadata?.output ?? t.Metadata?.result ?? J(t.Content?.parts));
1790
1525
  return {
1791
1526
  ...a,
1792
1527
  output: n,
@@ -1794,8 +1529,8 @@ function vt(t) {
1794
1529
  };
1795
1530
  })() : {
1796
1531
  ...a,
1797
- args: _t(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1798
- }, s = mt(t);
1532
+ args: He(t.Metadata?.tool_args ?? t.Metadata?.arguments ?? t.Metadata?.args ?? {})
1533
+ }, s = Re(t);
1799
1534
  return {
1800
1535
  id: s?.id || t.EventId || String(Date.now() + Math.random()),
1801
1536
  role: "model",
@@ -1806,7 +1541,7 @@ function vt(t) {
1806
1541
  tools: { [r]: o }
1807
1542
  };
1808
1543
  }
1809
- function yt(e = {}, t = {}) {
1544
+ function We(e = {}, t = {}) {
1810
1545
  let n = { ...e || {} };
1811
1546
  for (let [e, r] of Object.entries(t || {})) n[e] = {
1812
1547
  ...n[e] || {},
@@ -1816,8 +1551,8 @@ function yt(e = {}, t = {}) {
1816
1551
  };
1817
1552
  return n;
1818
1553
  }
1819
- function bt(e = {}, t = "") {
1820
- let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : it.has(n) ? "error" : "";
1554
+ function Ge(e = {}, t = "") {
1555
+ let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : Oe.has(n) ? "error" : "";
1821
1556
  if (!r) return e;
1822
1557
  let i = !1, a = {};
1823
1558
  for (let [t, n] of Object.entries(e || {})) n?.status === "running" ? (i = !0, a[t] = {
@@ -1826,11 +1561,11 @@ function bt(e = {}, t = "") {
1826
1561
  }) : a[t] = n;
1827
1562
  return i ? a : e;
1828
1563
  }
1829
- function xt(e, t) {
1564
+ function Ke(e, t) {
1830
1565
  return {
1831
1566
  ...e,
1832
- reasoning: St(e.reasoning, t.reasoning),
1833
- tools: yt(e.tools, t.tools),
1567
+ reasoning: qe(e.reasoning, t.reasoning),
1568
+ tools: We(e.tools, t.tools),
1834
1569
  eventId: t.eventId || e.eventId,
1835
1570
  responseId: t.responseId || e.responseId,
1836
1571
  traceId: t.traceId || e.traceId,
@@ -1839,11 +1574,11 @@ function xt(e, t) {
1839
1574
  id: t.responseId || t.reasoning || t.tools ? t.id : e.id
1840
1575
  };
1841
1576
  }
1842
- function St(e = "", t = "") {
1577
+ function qe(e = "", t = "") {
1843
1578
  let n = String(e || ""), r = String(t || "");
1844
1579
  return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1845
1580
  }
1846
- function Ct(e) {
1581
+ function Je(e) {
1847
1582
  return {
1848
1583
  id: e.id,
1849
1584
  role: "system",
@@ -1854,11 +1589,11 @@ function Ct(e) {
1854
1589
  summary: e.summary,
1855
1590
  historical: e.historical,
1856
1591
  timestamp: e.timestamp,
1857
- content: ft(e.trigger, e.status, e.historical)
1592
+ content: Ie(e.trigger, e.status, e.historical)
1858
1593
  };
1859
1594
  }
1860
- function wt(e) {
1861
- let t = e?.EventType || "", n = mt(e);
1595
+ function Ye(e) {
1596
+ let t = e?.EventType || "", n = Re(e);
1862
1597
  if (t === "run_status") return e.Content?.status === "failed" ? {
1863
1598
  id: e.EventId || String(Date.now() + Math.random()),
1864
1599
  role: "system",
@@ -1875,8 +1610,8 @@ function wt(e) {
1875
1610
  timestamp: e.Timestamp || Date.now()
1876
1611
  } : null;
1877
1612
  if (t === "context_checkpoint") {
1878
- let t = Y(e);
1879
- return Ct({
1613
+ let t = X(e);
1614
+ return Je({
1880
1615
  id: e.EventId || String(Date.now() + Math.random()),
1881
1616
  timestamp: e.Timestamp || Date.now(),
1882
1617
  status: "completed",
@@ -1887,7 +1622,7 @@ function wt(e) {
1887
1622
  });
1888
1623
  }
1889
1624
  if (t === "reasoning") {
1890
- let r = Y(e).text || q(e.Metadata?.reasoning);
1625
+ let r = X(e).text || J(e.Metadata?.reasoning);
1891
1626
  return r ? {
1892
1627
  id: n?.id || e.EventId || String(Date.now() + Math.random()),
1893
1628
  role: "model",
@@ -1898,9 +1633,9 @@ function wt(e) {
1898
1633
  ...n || {}
1899
1634
  } : null;
1900
1635
  }
1901
- if (W.has(t)) return vt(e);
1636
+ if (G.has(t)) return Ue(e);
1902
1637
  if (t !== "user_message" && t !== "assistant_message" && t !== "assistant_stream_snapshot") return null;
1903
- let r = Y(e), i = t === "assistant_message" ? dt(e) : {};
1638
+ let r = X(e), i = t === "assistant_message" ? Fe(e) : {};
1904
1639
  if (!r.text && !r.attachments?.length && !i.reasoning && !i.tools) return null;
1905
1640
  let a = String(e.Metadata?.response_id || e.Metadata?.ResponseId || "").trim(), o = String(e.Metadata?.trace_id || e.Metadata?.TraceId || "").trim(), s = String(e.Metadata?.root_span_id || e.Metadata?.rootSpanId || e.Metadata?.RootSpanId || "").trim();
1906
1641
  return {
@@ -1918,8 +1653,8 @@ function wt(e) {
1918
1653
  ...i
1919
1654
  };
1920
1655
  }
1921
- function Tt(e = []) {
1922
- let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = st(e), c = [];
1656
+ function Xe(e = []) {
1657
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = je(e), c = [];
1923
1658
  for (let e of s) {
1924
1659
  let t = String(e?.EventId || "").trim();
1925
1660
  if (t) {
@@ -1930,13 +1665,13 @@ function Tt(e = []) {
1930
1665
  }
1931
1666
  let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
1932
1667
  for (let e of c) {
1933
- if (e?.EventType !== "user_message" || ht(e)) {
1668
+ if (e?.EventType !== "user_message" || ze(e)) {
1934
1669
  if (e?.EventType === "assistant_message") {
1935
- let t = X(e);
1670
+ let t = Z(e);
1936
1671
  t && u.add(t);
1937
1672
  }
1938
- if (gt(e)) {
1939
- let t = X(e);
1673
+ if (Ve(e)) {
1674
+ let t = Z(e);
1940
1675
  if (t) {
1941
1676
  let n = d.get(t);
1942
1677
  (!n || Q(e) >= Q(n)) && d.set(t, e);
@@ -1944,16 +1679,16 @@ function Tt(e = []) {
1944
1679
  }
1945
1680
  continue;
1946
1681
  }
1947
- let t = Z(e);
1682
+ let t = Be(e);
1948
1683
  t && l.add(t);
1949
1684
  }
1950
1685
  let f = c.filter((e) => {
1951
- if (gt(e)) {
1952
- let t = X(e);
1686
+ if (Ve(e)) {
1687
+ let t = Z(e);
1953
1688
  return t ? u.has(t) ? !1 : d.get(t) === e : !0;
1954
1689
  }
1955
- if (e?.EventType !== "user_message" || !ht(e)) return !0;
1956
- let t = Z(e);
1690
+ if (e?.EventType !== "user_message" || !ze(e)) return !0;
1691
+ let t = Be(e);
1957
1692
  return !t || !l.has(t);
1958
1693
  });
1959
1694
  for (let e of f) {
@@ -1971,12 +1706,12 @@ function Tt(e = []) {
1971
1706
  let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = /* @__PURE__ */ new Map(), v = (e) => {
1972
1707
  let t = e?.itemId ? `${e.runId || e.invocationId || ""}\u0000${e.scopeId || e.invocationId || ""}\u0000${e.itemId}` : "", n = t ? h.get(t) : void 0;
1973
1708
  if (n !== void 0) {
1974
- p[n] = xt(p[n], e);
1709
+ p[n] = Ke(p[n], e);
1975
1710
  return;
1976
1711
  }
1977
1712
  let r = String(e?.responseId || "").trim(), i = r ? m.get(r) : void 0;
1978
1713
  if (i !== void 0) {
1979
- p[i] = xt(p[i], e);
1714
+ p[i] = Ke(p[i], e);
1980
1715
  return;
1981
1716
  }
1982
1717
  r && m.set(r, p.length), t && h.set(t, p.length), p.push(e);
@@ -1986,14 +1721,14 @@ function Tt(e = []) {
1986
1721
  let r = String(e || "").trim();
1987
1722
  if (!r) return {};
1988
1723
  let i = _.get(r);
1989
- return i ? (_.delete(r), { tools: bt(i.tools, t.get(r) || n) }) : {};
1724
+ return i ? (_.delete(r), { tools: Ge(i.tools, t.get(r) || n) }) : {};
1990
1725
  };
1991
1726
  for (let e of f) {
1992
1727
  if (e.EventType === "run_status") continue;
1993
- let t = wt(e);
1728
+ let t = Ye(e);
1994
1729
  if (!t) continue;
1995
1730
  let n = String(e.InvocationId || "").trim();
1996
- if (n && (t.invocationId = n), W.has(t.eventType)) {
1731
+ if (n && (t.invocationId = n), G.has(t.eventType)) {
1997
1732
  let n = String(e.InvocationId || "").trim();
1998
1733
  if (t.itemId) {
1999
1734
  y(), v(t);
@@ -2013,7 +1748,7 @@ function Tt(e = []) {
2013
1748
  invocationId: n
2014
1749
  },
2015
1750
  timestamp: Math.max(Number(r?.timestamp || 0), Number(t.timestamp || 0)),
2016
- tools: yt(r?.tools, t.tools)
1751
+ tools: We(r?.tools, t.tools)
2017
1752
  });
2018
1753
  continue;
2019
1754
  }
@@ -2031,7 +1766,7 @@ function Tt(e = []) {
2031
1766
  }
2032
1767
  let r = t.eventType === "assistant_message" || t.eventType === "assistant_stream_snapshot";
2033
1768
  if (r && g) {
2034
- let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1769
+ let n = String(e.InvocationId || "").trim(), r = Le(n, t);
2035
1770
  if (t.eventType === "assistant_message" && n && a.has(r)) {
2036
1771
  g = null;
2037
1772
  continue;
@@ -2039,12 +1774,12 @@ function Tt(e = []) {
2039
1774
  t.eventType === "assistant_message" && n && a.add(r), v({
2040
1775
  ...t,
2041
1776
  ...b(n, t.eventType === "assistant_message" ? "completed" : ""),
2042
- reasoning: St(g.reasoning, t.reasoning)
1777
+ reasoning: qe(g.reasoning, t.reasoning)
2043
1778
  }), g = null;
2044
1779
  continue;
2045
1780
  }
2046
1781
  if (y(), r) {
2047
- let n = String(e.InvocationId || "").trim(), r = pt(n, t);
1782
+ let n = String(e.InvocationId || "").trim(), r = Le(n, t);
2048
1783
  if (t.eventType === "assistant_message" && n && a.has(r)) continue;
2049
1784
  t.eventType === "assistant_message" && n && a.add(r), v({
2050
1785
  ...t,
@@ -2057,7 +1792,7 @@ function Tt(e = []) {
2057
1792
  y();
2058
1793
  for (let [e, n] of _.entries()) v({
2059
1794
  ...n,
2060
- tools: bt(n.tools, t.get(e))
1795
+ tools: Ge(n.tools, t.get(e))
2061
1796
  });
2062
1797
  for (let [e, a] of t.entries()) {
2063
1798
  if (a !== "in_progress" || r.has(e) || !i.has(e)) continue;
@@ -2073,7 +1808,7 @@ function Tt(e = []) {
2073
1808
  }
2074
1809
  return p;
2075
1810
  }
2076
- function Et(e = [], t = []) {
1811
+ function Ze(e = [], t = []) {
2077
1812
  let n = [], r = /* @__PURE__ */ new Set();
2078
1813
  for (let i of [...Array.isArray(e) ? e : [], ...Array.isArray(t) ? t : []]) {
2079
1814
  let e = String(i?.EventId || "").trim();
@@ -2088,21 +1823,21 @@ function Et(e = [], t = []) {
2088
1823
  return Number.isFinite(n) && Number.isFinite(r) && n !== r ? n - r : Number(e?.Timestamp || 0) - Number(t?.Timestamp || 0);
2089
1824
  });
2090
1825
  }
2091
- function Dt(e = []) {
1826
+ function Qe(e = []) {
2092
1827
  return (Array.isArray(e) ? e : []).reduce((e, t) => {
2093
1828
  let n = Number(t.SeqId || 0);
2094
1829
  return Number.isFinite(n) ? Math.max(e, n) : e;
2095
1830
  }, 0);
2096
1831
  }
2097
- function Ot(e) {
2098
- return it.has(ct(e));
1832
+ function $e(e) {
1833
+ return Oe.has(Me(e));
2099
1834
  }
2100
1835
  //#endregion
2101
1836
  //#region src/utils/persisted-session-history.ts
2102
1837
  function $(e) {
2103
1838
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
2104
1839
  }
2105
- function kt(e) {
1840
+ function et(e) {
2106
1841
  if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
2107
1842
  if (typeof e == "string" && e.trim()) {
2108
1843
  let t = Number(e.trim());
@@ -2111,7 +1846,7 @@ function kt(e) {
2111
1846
  let t = Date.parse(String(e || ""));
2112
1847
  return Number.isFinite(t) ? t : Date.now();
2113
1848
  }
2114
- function At(e) {
1849
+ function tt(e) {
2115
1850
  let t = $(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
2116
1851
  if (t && String(t.event_type || "")) return {
2117
1852
  ...t,
@@ -2131,22 +1866,22 @@ function At(e) {
2131
1866
  timestamp: e.Timestamp || n.timestamp || r.timestamp
2132
1867
  };
2133
1868
  }
2134
- function jt(e) {
1869
+ function nt(e) {
2135
1870
  return e.role === "model" ? {
2136
1871
  ...e,
2137
- blocks: e.blocks?.length ? e.blocks : Be({
1872
+ blocks: e.blocks?.length ? e.blocks : pe({
2138
1873
  content: e.content,
2139
1874
  reasoning: e.reasoning,
2140
1875
  tools: e.tools
2141
1876
  })
2142
1877
  } : e;
2143
1878
  }
2144
- function Mt(e, t) {
1879
+ function rt(e, t) {
2145
1880
  let n = t.find((e) => e.role === "user"), r = e.some((e) => e.role === "user"), i = t.filter((e) => e.role === "model"), a = e.filter((e) => e.role === "model").at(-1), o = i.at(-1), s = e.map((e) => e.role === "user" && n ? {
2146
1881
  ...e,
2147
1882
  ...n,
2148
1883
  invocationId: e.invocationId || n.invocationId
2149
- } : jt(e === a && o ? {
1884
+ } : nt(e === a && o ? {
2150
1885
  ...e,
2151
1886
  responseId: o.responseId || e.responseId,
2152
1887
  traceId: o.traceId || e.traceId,
@@ -2154,12 +1889,12 @@ function Mt(e, t) {
2154
1889
  } : e));
2155
1890
  return n && !r ? [n, ...s] : s;
2156
1891
  }
2157
- function Nt(e, t) {
1892
+ function it(e, t) {
2158
1893
  let n = t.filter((e) => e.role === "model"), r = n.reduce((e, t) => ({
2159
1894
  ...e,
2160
1895
  ...t.tools || {}
2161
1896
  }), {}), i = n.map((e) => String(e.reasoning || "").trim()).filter(Boolean).join("\n\n"), a = [...e].reverse().find((e) => e.role === "model");
2162
- return !a || Object.keys(r).length === 0 && !i ? e : e.map((e) => e === a ? jt({
1897
+ return !a || Object.keys(r).length === 0 && !i ? e : e.map((e) => e === a ? nt({
2163
1898
  ...e,
2164
1899
  reasoning: e.reasoning || i || void 0,
2165
1900
  tools: Object.keys(r).length > 0 ? {
@@ -2168,21 +1903,21 @@ function Nt(e, t) {
2168
1903
  } : e.tools
2169
1904
  }) : e);
2170
1905
  }
2171
- function Pt(e) {
1906
+ function at(e) {
2172
1907
  return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
2173
1908
  }
2174
- var Ft = new Set([
1909
+ var ot = new Set([
2175
1910
  "approval.resolved",
2176
1911
  "interaction.resolved",
2177
1912
  "interaction.cancelled",
2178
1913
  "interaction.canceled",
2179
1914
  "a2ui.action"
2180
1915
  ]);
2181
- function It(e) {
1916
+ function st(e) {
2182
1917
  let t = /* @__PURE__ */ new Set();
2183
1918
  for (let n of e) {
2184
1919
  let e = $(n.Content) || {}, r = $(e.runtime_event || e.runtimeEvent) || {}, i = $(e.payload) || $(r.payload) || {}, a = String(n.EventType || e.event_type || e.eventType || r.event_type || "").toLowerCase();
2185
- if (!Ft.has(a)) continue;
1920
+ if (!ot.has(a)) continue;
2186
1921
  let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
2187
1922
  if (![
2188
1923
  "cancel",
@@ -2194,10 +1929,10 @@ function It(e) {
2194
1929
  }
2195
1930
  return t;
2196
1931
  }
2197
- function Lt(e, t, n) {
2198
- let r = new Ke(n), i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = [...t || []].sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), c = Number(s[0]?.SeqId || 0) <= 1;
1932
+ function ct(e, t, n) {
1933
+ let r = new R(n), i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = [...t || []].sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), c = Number(s[0]?.SeqId || 0) <= 1;
2199
1934
  for (let e of s) {
2200
- let t = At(e);
1935
+ let t = tt(e);
2201
1936
  if (!t) continue;
2202
1937
  let n = String(t.run_id || "").trim();
2203
1938
  if (n) {
@@ -2209,16 +1944,16 @@ function Lt(e, t, n) {
2209
1944
  s && i.push({
2210
1945
  ...s,
2211
1946
  SeqId: Number(e.SeqId || s.SeqId || 0),
2212
- Timestamp: kt(e.Timestamp || s.Timestamp)
1947
+ Timestamp: et(e.Timestamp || s.Timestamp)
2213
1948
  });
2214
1949
  }
2215
- let l = Tt(i).filter((e) => e.invocationId && a.has(e.invocationId)), u = /* @__PURE__ */ new Map();
1950
+ let l = Xe(i).filter((e) => e.invocationId && a.has(e.invocationId)), u = /* @__PURE__ */ new Map();
2216
1951
  for (let t of e) {
2217
1952
  let e = String(t.invocationId || "");
2218
1953
  e && u.set(e, [...u.get(e) || [], t]);
2219
1954
  }
2220
- let d = new Set([...Pt(l)].filter((e) => o.has(e))), f = It(s), p = [...d].flatMap((e) => Mt(l.filter((t) => t.invocationId === e), u.get(e) || [])), m = /* @__PURE__ */ new Map();
2221
- for (let [e, t] of u) d.has(e) || !a.has(e) || m.set(e, Nt(t, l.filter((t) => t.invocationId === e)));
1955
+ let d = new Set([...at(l)].filter((e) => o.has(e))), f = st(s), p = [...d].flatMap((e) => rt(l.filter((t) => t.invocationId === e), u.get(e) || [])), m = /* @__PURE__ */ new Map();
1956
+ for (let [e, t] of u) d.has(e) || !a.has(e) || m.set(e, it(t, l.filter((t) => t.invocationId === e)));
2222
1957
  let h = new Map([...m.values()].flat().map((e) => [e.id, e]));
2223
1958
  return {
2224
1959
  messages: [...e.filter((e) => !(e.role === "model" && e.invocationId && f.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !d.has(e.invocationId))).map((e) => h.get(e.id) || e), ...p].sort((e, t) => Number(e.timestamp || 0) - Number(t.timestamp || 0)),
@@ -2227,4 +1962,4 @@ function Lt(e, t, n) {
2227
1962
  };
2228
1963
  }
2229
1964
  //#endregion
2230
- export { ce as A, Se as C, se as D, ee as E, oe as O, ye as S, te as T, ze as _, Ot as a, Me as b, ct as c, Ke as d, qe as f, Ie as g, Be as h, Tt as i, t as j, re as k, Xe as l, Pe as m, Lt as n, Dt as o, Fe as p, Ct as r, Et as s, At as t, rt as u, Le as v, ve as w, Ce as x, Re as y };
1965
+ export { fe as _, $e as a, ae as b, Me as c, R as d, ve as f, le as g, pe as h, Xe as i, z as l, se as m, ct as n, Qe as o, ce as p, Je as r, Ze as s, tt as t, De as u, ue as v, v as x, de as y };