@kingsoftcloud/ksadk-web 0.3.16 → 0.3.18

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 (230) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/RELEASE_PROVENANCE.json +2 -2
  4. package/dist-ksadk/assets/{ArtifactsPanel-BuQ9Y_JK.js → ArtifactsPanel-Cdr5C_vM.js} +1 -1
  5. package/dist-ksadk/assets/{CodeBlock-ClmrpVUK.js → CodeBlock-BWRafud9.js} +1 -1
  6. package/dist-ksadk/assets/{MathMessageMarkdown-DYg6qEqQ.js → MathMessageMarkdown-CFKeJIvy.js} +1 -1
  7. package/dist-ksadk/assets/{MermaidBlock-B8QsBFET.js → MermaidBlock-BneAGUOd.js} +6 -6
  8. package/dist-ksadk/assets/{NativeTerminalPanel-Dkm61i5S.js → NativeTerminalPanel-BHI85zDO.js} +1 -1
  9. package/dist-ksadk/assets/{OfficialA2uiRenderer-SMVbkx2W.js → OfficialA2uiRenderer-BOmT36lJ.js} +1 -1
  10. package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-CQ5-2gHs.js → abnfDiagram-VCTEODGH-DQvlOsBI.js} +1 -1
  11. package/dist-ksadk/assets/{arc-CHdgzwmb.js → arc-CGx0e4pN.js} +1 -1
  12. package/dist-ksadk/assets/architecture-7GRP2DOG-CFWjFkDL.js +1 -0
  13. package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-MnCOPhnl.js → architectureDiagram-5GKGNRK7-WyybcNKX.js} +1 -1
  14. package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-DZ61ECd8.js → blockDiagram-NRAW4CY4-C9Cx_GVs.js} +1 -1
  15. package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-D9FYHHhU.js → c4Diagram-UCG6FXSJ-Bh7X3bGr.js} +1 -1
  16. package/dist-ksadk/assets/channel-D6Dp_l74.js +1 -0
  17. package/dist-ksadk/assets/chunk-2Q5K7J3B-CwmjhFYK.js +1 -0
  18. package/dist-ksadk/assets/{chunk-5VM5RSS4-AIv2klim.js → chunk-5VM5RSS4-cP9XupZj.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-F27PBJKO-D_sWJ7f-.js → chunk-F27PBJKO-Bm77fvR9.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-G27WJ6UU-DQzToglM.js → chunk-G27WJ6UU-DDKNPesQ.js} +1 -1
  21. package/dist-ksadk/assets/{chunk-JWPE2WC7-lOgv6BXZ.js → chunk-JWPE2WC7-BqiUDB7s.js} +1 -1
  22. package/dist-ksadk/assets/{chunk-LCL6LL3I-Cbx6jBtE.js → chunk-LCL6LL3I-C528mMZy.js} +1 -1
  23. package/dist-ksadk/assets/{chunk-POPQ4Y6H-DNJ22Jtx.js → chunk-POPQ4Y6H-CzZ9g_Uf.js} +1 -1
  24. package/dist-ksadk/assets/{chunk-RHFEMEQ7-BhICgqzs.js → chunk-RHFEMEQ7-CXj4tUZ-.js} +1 -1
  25. package/dist-ksadk/assets/{chunk-SVP7TREG-r-bF-HGi.js → chunk-SVP7TREG-BHyd85pS.js} +1 -1
  26. package/dist-ksadk/assets/{chunk-XXDRQBXY-OjeFK9EX.js → chunk-XXDRQBXY-Qe29PHGe.js} +1 -1
  27. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +1 -0
  28. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +1 -0
  29. package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-LkMJR5TN.js → cose-bilkent-JH36ORCC-maRKgeec.js} +1 -1
  30. package/dist-ksadk/assets/cynefin-OW5HDTMX-CBZRVuc4.js +1 -0
  31. package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-B6wd-M91.js → cynefinDiagram-5FMLGOSQ-CoD0bEvn.js} +1 -1
  32. package/dist-ksadk/assets/{dagre-3AP2YEHR-Yo8czwSH.js → dagre-3AP2YEHR-BkpgQqyW.js} +1 -1
  33. package/dist-ksadk/assets/{dagre-IpjZOTvn.js → dagre-BUaTFrYa.js} +1 -1
  34. package/dist-ksadk/assets/{diagram-S7CK7UJ4-CAkqzyfj.js → diagram-S7CK7UJ4-25HdTbjE.js} +1 -1
  35. package/dist-ksadk/assets/{diagram-UQ7AKVKN-JyEZmDlh.js → diagram-UQ7AKVKN-KO-WqOIg.js} +1 -1
  36. package/dist-ksadk/assets/{diagram-VSXAHHWV-DGBXNEif.js → diagram-VSXAHHWV-B360BkDQ.js} +1 -1
  37. package/dist-ksadk/assets/{diagram-VX7I27RA-KljR5Glh.js → diagram-VX7I27RA-COr1Oqsg.js} +1 -1
  38. package/dist-ksadk/assets/{diagram-Z3DM3KII-8FQ2FrUP.js → diagram-Z3DM3KII-CgaKrIwB.js} +1 -1
  39. package/dist-ksadk/assets/{dist-AnEuKlWI.js → dist--HftQyp9.js} +1 -1
  40. package/dist-ksadk/assets/{dist-BmrsRv90.js → dist-B3Jp5r1e.js} +1 -1
  41. package/dist-ksadk/assets/{dist-Bls_5FN6.js → dist-BEbS8Bag.js} +1 -1
  42. package/dist-ksadk/assets/{dist-DRAbZJl6.js → dist-BQ116UdZ.js} +1 -1
  43. package/dist-ksadk/assets/{dist-BRaujO8W.js → dist-BoRn8a_t.js} +1 -1
  44. package/dist-ksadk/assets/{dist-CAnMW8ay.js → dist-Brbrdmff.js} +1 -1
  45. package/dist-ksadk/assets/{dist-Cs1lGsiM.js → dist-Bsuusoi0.js} +1 -1
  46. package/dist-ksadk/assets/{dist-BUvPmCJJ.js → dist-Bxcu8Ca0.js} +1 -1
  47. package/dist-ksadk/assets/{dist-CSguAs4w.js → dist-By-MVndb.js} +1 -1
  48. package/dist-ksadk/assets/{dist-Bo4bAcyo.js → dist-C9BTMVwS.js} +1 -1
  49. package/dist-ksadk/assets/{dist-dxCMjEJX.js → dist-CBo9AHUv.js} +1 -1
  50. package/dist-ksadk/assets/{dist-CTkYhw0e.js → dist-CR61WJFC.js} +1 -1
  51. package/dist-ksadk/assets/{dist-Bnqrfpu2.js → dist-CwnkOyDn.js} +1 -1
  52. package/dist-ksadk/assets/{dist-BblTQEdU.js → dist-CxIl4t92.js} +1 -1
  53. package/dist-ksadk/assets/{dist-87AsLuzD.js → dist-DKG0OYnk.js} +1 -1
  54. package/dist-ksadk/assets/{dist-Cj5PFf9x.js → dist-DSw5Ju6-.js} +1 -1
  55. package/dist-ksadk/assets/{dist-Ps_8XMpQ.js → dist-DXOlCAay.js} +1 -1
  56. package/dist-ksadk/assets/{dist-C-4NaB6S.js → dist-DgJ57sRe.js} +1 -1
  57. package/dist-ksadk/assets/{dist-DWRPGuTp.js → dist-DmWw0IXB.js} +1 -1
  58. package/dist-ksadk/assets/{dist-DrFtl2Jz.js → dist-DzdXSBJb.js} +1 -1
  59. package/dist-ksadk/assets/{dist-DQSR5gJm.js → dist-HHvdjADB.js} +1 -1
  60. package/dist-ksadk/assets/{dist-DW_Mhac3.js → dist-_0Xgu_07.js} +1 -1
  61. package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-BDy_T6BJ.js → ebnfDiagram-PWID7BFC-DogDP2db.js} +1 -1
  62. package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-Cb9mxU2v.js → erDiagram-SSCWMZ5O-CeBDnUjR.js} +1 -1
  63. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +1 -0
  64. package/dist-ksadk/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +1 -0
  65. package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-CI-NY47s.js → ganttDiagram-EL5Y4UJY-oIQL3MCp.js} +1 -1
  66. package/dist-ksadk/assets/gitGraph-4MIJSDKK-BUWSkncI.js +1 -0
  67. package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DZBPuEz2.js → gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js} +1 -1
  68. package/dist-ksadk/assets/index-4g1ndaxW.js +1132 -0
  69. package/dist-ksadk/assets/index-DEVfafsU.css +2 -0
  70. package/dist-ksadk/assets/info-A6RAGUB7-CzJ_YrOs.js +1 -0
  71. package/dist-ksadk/assets/{infoDiagram-RXCK75RN-BGVB1ufk.js → infoDiagram-RXCK75RN-yQRC41Ya.js} +1 -1
  72. package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-C-pPrser.js → ishikawaDiagram-5VMMS53U-BCu4HiwL.js} +1 -1
  73. package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-mqH7Ax1g.js → journeyDiagram-EYS64GPL-JaqmO73K.js} +1 -1
  74. package/dist-ksadk/assets/{kanban-definition-3QL26DDD-D1g0NfmY.js → kanban-definition-3QL26DDD-DQo4X8NO.js} +1 -1
  75. package/dist-ksadk/assets/{katex-DBFpex0b.js → katex-t_DWylQw.js} +1 -1
  76. package/dist-ksadk/assets/{linear-H9vrIL3e.js → linear-DWdnI35B.js} +1 -1
  77. package/dist-ksadk/assets/{mermaid-parser.core-CTwOsmSy.js → mermaid-parser.core-BHrT2Pfe.js} +2 -2
  78. package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-P24ajxwA.js → mindmap-definition-FBJOCRG2-PBVAhZYV.js} +1 -1
  79. package/dist-ksadk/assets/packet-AYTQ26CC-CXoos6fx.js +1 -0
  80. package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-CIAjyVaA.js → pegDiagram-XKGWAZYB-CU_cLfow.js} +1 -1
  81. package/dist-ksadk/assets/pie-WAS4IAKB-CjF9NoIt.js +1 -0
  82. package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-Cpg76g41.js → pieDiagram-E7YTZNPT-B1h0-_pW.js} +1 -1
  83. package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-COa_uah3.js → quadrantDiagram-AXDQQJYC-DEMoGo5a.js} +1 -1
  84. package/dist-ksadk/assets/radar-RG4KPBEZ-BQGWs9nw.js +1 -0
  85. package/dist-ksadk/assets/railroad-74A4TZTK-B6znvLUK.js +1 -0
  86. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +1 -0
  87. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +1 -0
  88. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +1 -0
  89. package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-CDiUen7V.js → railroadDiagram-O6MQD6OU-BTAob2wg.js} +1 -1
  90. package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-4tmvHR-z.js → requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js} +1 -1
  91. package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-cmOQFKfb.js → sankeyDiagram-P5KCCOFB-DeaTWkur.js} +1 -1
  92. package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-C87BVo37.js → sequenceDiagram-WJ2MYXX4-gFQYrsOd.js} +1 -1
  93. package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-BD2400H2.js → sizeCapture-X5ZJPWSS-pGQzddMB.js} +1 -1
  94. package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DaxlblQk.js → stateDiagram-HBIQ2CUA-DmpYOZt1.js} +1 -1
  95. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +1 -0
  96. package/dist-ksadk/assets/{swimlanes-XN3QIQJK-M7GAwJZ9.js → swimlanes-XN3QIQJK-BfuSAsrr.js} +1 -1
  97. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +8 -0
  98. package/dist-ksadk/assets/{timeline-definition-24CTP7MA-Cq_BUN6-.js → timeline-definition-24CTP7MA-CgJwrrxf.js} +1 -1
  99. package/dist-ksadk/assets/treeView-Q6P3EWNA-DtMdDH8N.js +1 -0
  100. package/dist-ksadk/assets/treemap-WGGIJYW6-VoU8QtLZ.js +1 -0
  101. package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-BTAMWn-b.js → vennDiagram-4TSXK5OY-CBSAgXDd.js} +1 -1
  102. package/dist-ksadk/assets/wardley-WFR3VGLG-YWSRB0Zm.js +1 -0
  103. package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-Dnvpr9wl.js → wardleyDiagram-VM6X3IG4-013TZ2JZ.js} +1 -1
  104. package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-D838CKvY.js → xychartDiagram-S5SC5T6Z-u6Frp8xp.js} +1 -1
  105. package/dist-ksadk/index.html +2 -2
  106. package/dist-lib/App.d.ts.map +1 -1
  107. package/dist-lib/AttachmentPreview-Dhc6ulFv.js +1956 -0
  108. package/dist-lib/{ConnectedComposer-B2lm1bBF.js → ConnectedComposer-Cc6bqJmu.js} +354 -351
  109. package/dist-lib/{ConnectedMessageList-BumlD3Zk.js → ConnectedMessageList-Bdd-qjs-.js} +427 -422
  110. package/dist-lib/{WorkspacePanelContainer-CcI-iqlE.js → WorkspacePanelContainer-_PuvSz_J.js} +319 -319
  111. package/dist-lib/{a2ui-CWVTKJ6O.js → a2ui-DihCxdtQ.js} +1467 -410
  112. package/dist-lib/{capabilities-lJRDfRg9.js → capabilities-CHy70QGW.js} +5 -2
  113. package/dist-lib/capabilities.js +1 -1
  114. package/dist-lib/chat-composer.js +2 -2
  115. package/dist-lib/chat-timeline.js +3 -3
  116. package/dist-lib/components/chat/A2UIActivityMessage.d.ts +1 -0
  117. package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
  118. package/dist-lib/components/chat/ChatComposer.d.ts +2 -1
  119. package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
  120. package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
  121. package/dist-lib/components/chat/ConnectedComposer.d.ts +2 -1
  122. package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
  123. package/dist-lib/components/chat/ExecutionPermissionMenu.d.ts.map +1 -1
  124. package/dist-lib/components/chat/InteractionA2uiSurface.d.ts +6 -1
  125. package/dist-lib/components/chat/InteractionA2uiSurface.d.ts.map +1 -1
  126. package/dist-lib/components/chat/InteractionTray.d.ts +3 -1
  127. package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -1
  128. package/dist-lib/components/chat/JsonSchemaInputForm.d.ts.map +1 -1
  129. package/dist-lib/components/chat/McpAuthorizationCard.d.ts +8 -0
  130. package/dist-lib/components/chat/McpAuthorizationCard.d.ts.map +1 -0
  131. package/dist-lib/components/chat/ProcessingBlocksView.d.ts +1 -1
  132. package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
  133. package/dist-lib/components/chat/submitted-interaction-history.d.ts.map +1 -1
  134. package/dist-lib/components/ui/button.d.ts +12 -0
  135. package/dist-lib/components/ui/button.d.ts.map +1 -0
  136. package/dist-lib/components.js +5 -5
  137. package/dist-lib/conversation.js +2 -2
  138. package/dist-lib/core/api/facade.d.ts +1 -0
  139. package/dist-lib/core/api/facade.d.ts.map +1 -1
  140. package/dist-lib/core/api/types.d.ts +1 -0
  141. package/dist-lib/core/api/types.d.ts.map +1 -1
  142. package/dist-lib/core/conversation/presentation.d.ts.map +1 -1
  143. package/dist-lib/core/conversation/runtime-ingress.d.ts.map +1 -1
  144. package/dist-lib/core/interaction/a2ui-approval.d.ts +20 -0
  145. package/dist-lib/core/interaction/a2ui-approval.d.ts.map +1 -0
  146. package/dist-lib/core/interaction/adapters/agui.d.ts.map +1 -1
  147. package/dist-lib/core/interaction/adapters/normalize.d.ts +2 -0
  148. package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -1
  149. package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -1
  150. package/dist-lib/core/interaction/client.d.ts.map +1 -1
  151. package/dist-lib/core/interaction/legacy-a2ui.d.ts +5 -0
  152. package/dist-lib/core/interaction/legacy-a2ui.d.ts.map +1 -0
  153. package/dist-lib/core/interaction/pending.d.ts +4 -0
  154. package/dist-lib/core/interaction/pending.d.ts.map +1 -0
  155. package/dist-lib/core/mcp-authorization/contract.d.ts +5 -0
  156. package/dist-lib/core/mcp-authorization/contract.d.ts.map +1 -0
  157. package/dist-lib/core/mcp-authorization/normalize.d.ts +4 -0
  158. package/dist-lib/core/mcp-authorization/normalize.d.ts.map +1 -0
  159. package/dist-lib/core/mcp-authorization/recovery.d.ts +5 -0
  160. package/dist-lib/core/mcp-authorization/recovery.d.ts.map +1 -0
  161. package/dist-lib/core/mcp-authorization/types.d.ts +20 -0
  162. package/dist-lib/core/mcp-authorization/types.d.ts.map +1 -0
  163. package/dist-lib/core/run/agui.d.ts.map +1 -1
  164. package/dist-lib/core/run/blocks.d.ts +4 -2
  165. package/dist-lib/core/run/blocks.d.ts.map +1 -1
  166. package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
  167. package/dist-lib/core/run/engine.d.ts.map +1 -1
  168. package/dist-lib/core/run/types.d.ts +12 -0
  169. package/dist-lib/core/run/types.d.ts.map +1 -1
  170. package/dist-lib/core/stream/types.d.ts +7 -0
  171. package/dist-lib/core/stream/types.d.ts.map +1 -1
  172. package/dist-lib/core/teams/cloudContracts.d.ts +15 -15
  173. package/dist-lib/{feedback-CuC5jRi_.js → feedback-BBJKMdF2.js} +98 -86
  174. package/dist-lib/hooks/useAgentChat.d.ts +1 -1
  175. package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
  176. package/dist-lib/hooks/useInteractions.d.ts +2 -1
  177. package/dist-lib/hooks/useInteractions.d.ts.map +1 -1
  178. package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
  179. package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
  180. package/dist-lib/hooks.js +19 -18
  181. package/dist-lib/permission-DGyt7wBj.js +25 -0
  182. package/dist-lib/{persisted-session-history-Mg7yqvHj.js → persisted-session-history-Bh_6zSKC.js} +626 -1479
  183. package/dist-lib/runtime.js +258 -255
  184. package/dist-lib/session-events-DvFsVXpD.js +1463 -0
  185. package/dist-lib/stores/bootstrap.d.ts.map +1 -1
  186. package/dist-lib/stores/execution-permission.d.ts +2 -0
  187. package/dist-lib/stores/execution-permission.d.ts.map +1 -1
  188. package/dist-lib/styles.css +1 -1
  189. package/dist-lib/types/capabilities.d.ts +4 -0
  190. package/dist-lib/types/capabilities.d.ts.map +1 -1
  191. package/dist-lib/{useSessionLifecycle-BsS84-O4.js → useSessionLifecycle-u7i_h_io.js} +1018 -1987
  192. package/dist-lib/utils/capabilities.d.ts +1 -0
  193. package/dist-lib/utils/capabilities.d.ts.map +1 -1
  194. package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
  195. package/dist-lib/utils/responses-stream.d.ts +3 -1
  196. package/dist-lib/utils/responses-stream.d.ts.map +1 -1
  197. package/dist-lib/utils/run-progress.d.ts.map +1 -1
  198. package/dist-lib/utils/session-event-history.d.ts +11 -0
  199. package/dist-lib/utils/session-event-history.d.ts.map +1 -1
  200. package/dist-lib/utils/session-events.d.ts.map +1 -1
  201. package/dist-lib/utils/workspace.d.ts +1 -1
  202. package/package.json +1 -1
  203. package/dist-ksadk/assets/architecture-7GRP2DOG-B_LhRes-.js +0 -1
  204. package/dist-ksadk/assets/channel-Bq55bwo_.js +0 -1
  205. package/dist-ksadk/assets/chunk-2Q5K7J3B-Dace2ujW.js +0 -1
  206. package/dist-ksadk/assets/classDiagram-DTDB5LWJ-l9qDDu33.js +0 -1
  207. package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-l9qDDu33.js +0 -1
  208. package/dist-ksadk/assets/cynefin-OW5HDTMX-jtPBpAp-.js +0 -1
  209. package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DMz2Fvu-.js +0 -1
  210. package/dist-ksadk/assets/flowDiagram-A5DVABFB-clcQL_nf.js +0 -1
  211. package/dist-ksadk/assets/gitGraph-4MIJSDKK-DDQIXIFD.js +0 -1
  212. package/dist-ksadk/assets/index-4lKAP0g-.js +0 -1132
  213. package/dist-ksadk/assets/index-DMqhW2cV.css +0 -2
  214. package/dist-ksadk/assets/info-A6RAGUB7-CnWfuiwa.js +0 -1
  215. package/dist-ksadk/assets/packet-AYTQ26CC-C1REqCW5.js +0 -1
  216. package/dist-ksadk/assets/pie-WAS4IAKB-CzQ5iT3d.js +0 -1
  217. package/dist-ksadk/assets/radar-RG4KPBEZ-d5WzegFP.js +0 -1
  218. package/dist-ksadk/assets/railroad-74A4TZTK-fRIdWxzy.js +0 -1
  219. package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-7joOoyeT.js +0 -1
  220. package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BAgBPuog.js +0 -1
  221. package/dist-ksadk/assets/railroad-peg-WCYAUIDC-Bq9jPeDZ.js +0 -1
  222. package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BAnVAqLb.js +0 -1
  223. package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DzYhp6ae.js +0 -8
  224. package/dist-ksadk/assets/treeView-Q6P3EWNA-Kl6y61te.js +0 -1
  225. package/dist-ksadk/assets/treemap-WGGIJYW6-Bt1G2wC0.js +0 -1
  226. package/dist-ksadk/assets/wardley-WFR3VGLG-CNYQTyja.js +0 -1
  227. package/dist-lib/AttachmentPreview-DkgZ9Upi.js +0 -1545
  228. package/dist-lib/execution-permission-UqLwHTJS.js +0 -89
  229. package/dist-lib/json-value-DnHp0582.js +0 -186
  230. package/dist-lib/tool-display-DTiRdghE.js +0 -64
@@ -0,0 +1,1463 @@
1
+ //#region src/core/stream/runtime-items.ts
2
+ function e(e, t) {
3
+ return `${e}\u0000${t}`;
4
+ }
5
+ function t(e) {
6
+ return { ...e };
7
+ }
8
+ var n = class {
9
+ runId = null;
10
+ status = null;
11
+ items = /* @__PURE__ */ new Map();
12
+ seenEventIds = /* @__PURE__ */ new Set();
13
+ apply(e) {
14
+ if (e.eventId) {
15
+ if (this.seenEventIds.has(e.eventId)) return;
16
+ this.seenEventIds.add(e.eventId);
17
+ }
18
+ switch (e.type) {
19
+ case "run_started":
20
+ this.runId = e.runId, this.status = "running";
21
+ return;
22
+ case "run_interrupted":
23
+ this.status = "interrupted";
24
+ return;
25
+ case "run_completed":
26
+ this.status = "completed";
27
+ return;
28
+ case "run_failed":
29
+ this.status = "failed";
30
+ return;
31
+ case "run_canceled":
32
+ this.status = "canceled";
33
+ return;
34
+ case "item_started":
35
+ this.startItem(e);
36
+ return;
37
+ case "item_updated":
38
+ this.updateItem(e);
39
+ return;
40
+ case "item_snapshot_replaced":
41
+ this.replaceSnapshot(e);
42
+ return;
43
+ case "item_completed":
44
+ case "item_failed":
45
+ this.closeItem(e);
46
+ return;
47
+ }
48
+ }
49
+ applyAll(e) {
50
+ for (let t of e) this.apply(t);
51
+ }
52
+ snapshot() {
53
+ return {
54
+ runId: this.runId,
55
+ status: this.status,
56
+ items: Array.from(this.items.values()).map((e) => ({
57
+ ...e,
58
+ parts: e.parts.map(t)
59
+ }))
60
+ };
61
+ }
62
+ ensureItem(t) {
63
+ this.runId === null && (this.runId = t.runId);
64
+ let n = e(t.scopeId, t.itemId), r = this.items.get(n);
65
+ return r || (r = {
66
+ runId: t.runId,
67
+ scopeId: t.scopeId,
68
+ itemId: t.itemId,
69
+ itemKind: t.itemKind || "message",
70
+ status: "open",
71
+ parts: []
72
+ }, this.items.set(n, r)), r;
73
+ }
74
+ startItem(n) {
75
+ let r = e(n.scopeId, n.itemId), i = this.items.get(r);
76
+ if (i) {
77
+ n.phase !== void 0 && (i.phase = n.phase);
78
+ return;
79
+ }
80
+ let a = this.ensureItem(n);
81
+ a.phase = n.phase, n.initialParts && (a.parts = n.initialParts.map(t));
82
+ }
83
+ updateItem(e) {
84
+ let n = this.ensureItem(e), r = n.parts.findIndex((t) => t.partId === e.partId);
85
+ if (r < 0) {
86
+ n.parts.push(t(e.part));
87
+ return;
88
+ }
89
+ let i = n.parts[r];
90
+ if (e.op === "replace") {
91
+ n.parts[r] = t(e.part);
92
+ return;
93
+ }
94
+ n.parts[r] = {
95
+ ...i,
96
+ text: `${i.text || ""}${e.part.text || ""}`
97
+ };
98
+ }
99
+ replaceSnapshot(e) {
100
+ let n = this.ensureItem(e);
101
+ n.parts = e.parts.map(t);
102
+ }
103
+ closeItem(e) {
104
+ let n = this.ensureItem(e);
105
+ e.parts && (n.parts = e.parts.map(t)), n.status = e.type === "item_completed" ? "completed" : "failed";
106
+ }
107
+ };
108
+ function r(e, t) {
109
+ return {
110
+ partId: e,
111
+ contentType: "text",
112
+ text: t
113
+ };
114
+ }
115
+ var i = "text-0";
116
+ function a(e, t) {
117
+ return String(e?.id || e?.item_id || t?.item_id || t?.output_index || "");
118
+ }
119
+ function o(e) {
120
+ let t = e?.content;
121
+ return Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : String(e?.text || "")).join("") : String(e?.output_text || e?.text || "");
122
+ }
123
+ function s(e, t, n, s) {
124
+ let c = String(t?.type || e || "").trim(), l = t?.id ? String(t.id) : void 0, u = t?.item || t?.output_item || {}, d = a(u, t), f = String(u?.type || ""), p = f.includes("reasoning") ? "reasoning" : "message";
125
+ if (c === "response.output_item.added") return !d || f !== "message" && !f.includes("reasoning") ? [] : [{
126
+ type: "item_started",
127
+ runId: n,
128
+ scopeId: s,
129
+ itemId: d,
130
+ itemKind: p,
131
+ phase: "final_answer",
132
+ eventId: l
133
+ }];
134
+ if (c === "response.output_text.delta" || c === "response.content_part.delta") {
135
+ if (!d) return [];
136
+ let e = String(t?.delta || t?.text || "");
137
+ return e ? [{
138
+ type: "item_updated",
139
+ runId: n,
140
+ scopeId: s,
141
+ itemId: d,
142
+ itemKind: p,
143
+ partId: i,
144
+ op: t?.replace === !0 ? "replace" : "append",
145
+ part: r(i, e),
146
+ eventId: l
147
+ }] : [];
148
+ }
149
+ return c === "response.output_item.done" || c === "response.output_text.done" ? d ? [{
150
+ type: "item_completed",
151
+ runId: n,
152
+ scopeId: s,
153
+ itemId: d,
154
+ itemKind: p,
155
+ parts: [r(i, o(u) || String(t?.text || ""))],
156
+ eventId: l
157
+ }] : [] : c === "response.completed" ? [{
158
+ type: "run_completed",
159
+ runId: n,
160
+ scopeId: s,
161
+ eventId: l
162
+ }] : [];
163
+ }
164
+ //#endregion
165
+ //#region src/core/mcp-authorization/contract.ts
166
+ var c = {
167
+ schema: "mcp.authorization/v1",
168
+ digest: "b9bc3b0c286a3b21b8a5dfee00ad83eaa28aa72e418140502c58fc2e0eced938"
169
+ };
170
+ //#endregion
171
+ //#region src/types/json-value.ts
172
+ function l(e) {
173
+ let t = /* @__PURE__ */ new Set(), n = [{ value: e }];
174
+ for (; n.length;) {
175
+ let e = n.pop(), r = e.value;
176
+ if (e.leave) {
177
+ t.delete(r);
178
+ continue;
179
+ }
180
+ if (!(r === null || typeof r == "string" || typeof r == "boolean") && !(typeof r == "number" && Number.isFinite(r))) {
181
+ if (typeof r != "object" || t.has(r) || !Array.isArray(r) && ![Object.prototype, null].includes(Object.getPrototypeOf(r)) || Object.getOwnPropertySymbols(r).length) throw TypeError("答案必须是合法 JSON 值。");
182
+ if (t.add(r), n.push({
183
+ value: r,
184
+ leave: !0
185
+ }), Array.isArray(r)) for (let e = 0; e < r.length; e += 1) n.push({ value: r[e] });
186
+ else for (let e of Object.values(r)) n.push({ value: e });
187
+ }
188
+ }
189
+ return e;
190
+ }
191
+ //#endregion
192
+ //#region src/core/interaction/adapters/normalize.ts
193
+ var u = new Set([
194
+ "approval",
195
+ "structured_input",
196
+ "plan_review",
197
+ "custom"
198
+ ]), d = new Set([
199
+ "pending",
200
+ "resolving",
201
+ "failed",
202
+ "resolved",
203
+ "cancelled",
204
+ "expired"
205
+ ]), f = new Set([
206
+ "approved",
207
+ "rejected",
208
+ "submitted",
209
+ "cancelled",
210
+ "expired"
211
+ ]);
212
+ function p(e) {
213
+ return typeof e == "object" && e && !Array.isArray(e) ? e : null;
214
+ }
215
+ function m(e) {
216
+ return typeof e == "string" && e.length > 0 ? e : null;
217
+ }
218
+ var h = "人工确认", g = "本次运行需要人工处理后才能继续。", _ = "补充信息", v = "请填写后提交,Agent 将继续当前任务。";
219
+ function y(e) {
220
+ let t = String(e.kind || "approval"), n = String(e.status || "pending"), r = String(e.outcome || ""), i = p(e.presentation), a = i ? p(i.a2ui) : null, o;
221
+ if (n === "resolved" && Object.hasOwn(e, "response")) try {
222
+ o = { response: l(e.response) };
223
+ } catch {}
224
+ return {
225
+ interactionId: e.interactionId,
226
+ sessionId: e.sessionId,
227
+ runId: m(e.runId),
228
+ kind: u.has(t) ? t : "custom",
229
+ title: typeof e.title == "string" && e.title ? e.title : t === "structured_input" ? _ : h,
230
+ message: typeof e.message == "string" && e.message ? e.message : t === "structured_input" ? v : g,
231
+ requestSchema: p(e.requestSchema),
232
+ presentation: a ? { a2ui: {
233
+ wireVersion: String(a.wire_version ?? a.wireVersion ?? ""),
234
+ catalogDigest: String(a.catalog_digest ?? a.catalogDigest ?? ""),
235
+ messages: Array.isArray(a.messages) ? a.messages.filter((e) => typeof e == "object") : []
236
+ } } : null,
237
+ status: d.has(n) ? n : "pending",
238
+ revision: Number.isFinite(Number(e.revision)) && Number(e.revision) > 0 ? Number(e.revision) : 1,
239
+ createdAt: m(e.createdAt) || (/* @__PURE__ */ new Date()).toISOString(),
240
+ expiresAt: m(e.expiresAt),
241
+ resolvedAt: m(e.resolvedAt),
242
+ actor: m(e.actor),
243
+ outcome: f.has(r) ? r : null,
244
+ responseSummary: m(e.responseSummary),
245
+ ...o,
246
+ source: e.source,
247
+ extensions: e.extensions || {}
248
+ };
249
+ }
250
+ //#endregion
251
+ //#region src/core/mcp-authorization/normalize.ts
252
+ function b(e) {
253
+ if (!e || typeof e != "object") return !1;
254
+ let t = e;
255
+ return t.schema === c.schema && typeof t.wait_id == "string" && t.wait_id.length > 0 && typeof t.run_id == "string" && t.run_id.length > 0 && typeof t.revision == "number" && Number.isSafeInteger(t.revision) && t.revision >= 0;
256
+ }
257
+ function x(e) {
258
+ return Array.isArray(e) && e.every((e) => typeof e == "string");
259
+ }
260
+ function S(e) {
261
+ return b(e) && typeof e.capability_digest == "string" && typeof e.config_id == "string" && typeof e.status == "string" && typeof e.deadline == "number" && Number.isFinite(e.deadline) && typeof e.requires_resume == "boolean" && (e.display_name === void 0 || typeof e.display_name == "string") && (e.error == null || typeof e.error == "string") && x(e.scopes) && x(e.allowed_actions);
262
+ }
263
+ function C(e, t, n) {
264
+ if (!b(e) || n && e.run_id !== n) return null;
265
+ let r = S(e) && e.capability_digest === c.digest ? e : {
266
+ schema: e.schema,
267
+ wait_id: e.wait_id,
268
+ run_id: e.run_id,
269
+ revision: e.revision,
270
+ status: "unsupported"
271
+ };
272
+ return y({
273
+ interactionId: r.wait_id,
274
+ sessionId: t,
275
+ runId: r.run_id,
276
+ kind: "custom",
277
+ title: "MCP 服务授权",
278
+ message: "授权完成后将继续当前任务。",
279
+ revision: r.revision,
280
+ source: "interaction_v1",
281
+ status: r.status === "resumed" ? "resolved" : [
282
+ "cancelled",
283
+ "expired",
284
+ "failed"
285
+ ].includes(r.status) ? r.status : "pending",
286
+ extensions: { mcpAuthorization: r }
287
+ });
288
+ }
289
+ //#endregion
290
+ //#region src/core/interaction/adapters/session-events.ts
291
+ var ee = new Set([
292
+ "interaction.requested",
293
+ "interaction_requested",
294
+ "ksadk.interaction/v1.requested",
295
+ "InteractionRequested",
296
+ "approval.requested",
297
+ "a2ui.interaction"
298
+ ]), te = new Set([
299
+ "interaction.resolved",
300
+ "interaction_resolved",
301
+ "ksadk.interaction/v1.resolved",
302
+ "InteractionResolved",
303
+ "interaction.cancelled",
304
+ "interaction.cancel",
305
+ "interaction.expired",
306
+ "approval.resolved",
307
+ "a2ui.action"
308
+ ]);
309
+ function w(e) {
310
+ return typeof e == "object" && e && !Array.isArray(e) ? e : null;
311
+ }
312
+ function ne(e, t) {
313
+ let n = w(e);
314
+ if (!n) return null;
315
+ let r = w(n.Content ?? n.content), i = w(r?.session_event ?? r?.sessionEvent), a = w(n.payload), o = i ?? (a?.family === "interaction" ? a : null) ?? (n.family === "interaction" ? n : null), s = i ?? (String(a?.event_type || "").startsWith("mcp.authorization.") ? a : null) ?? (String(r?.event_type || "").startsWith("mcp.authorization.") ? r : n);
316
+ if (s && String(s?.event_type || s?.EventType || "").startsWith("mcp.authorization.")) return C(s.payload ?? s, String(s.session_id || n.SessionId || t || ""), String(s.run_id || n.InvocationId || ""));
317
+ if (o && o.family !== "interaction") return null;
318
+ let c = o ?? n, l = String(c.event_type || c.EventType || "").trim();
319
+ if (!l) return null;
320
+ let u = w(c.payload ?? c.Content) ?? (o || {}), d = w(u.interaction) || w(u.Interaction) || w(u.interaction_request) || u, f = String(d.interaction_id || d.interactionId || d.InteractionId || d.approval_id || d.approvalId || u.interaction_id || u.interactionId || u.InteractionId || u.approval_id || u.approvalId || "");
321
+ if (!f) return null;
322
+ let p = String(c.session_id || c.SessionId || d.session_id || d.sessionId || t || "");
323
+ if (!p) return null;
324
+ if (ee.has(l)) {
325
+ let e = w(d.request) || {}, t = w(d.presentation ?? e.presentation), n = {
326
+ ...w(d.extensions) || {},
327
+ ...d.detail === void 0 ? {} : { detail: d.detail },
328
+ ...(d.call_id ?? d.callId) === void 0 ? {} : { call_id: d.call_id ?? d.callId }
329
+ };
330
+ return y({
331
+ interactionId: f,
332
+ sessionId: p,
333
+ runId: d.run_id ?? d.runId ?? c.run_id ?? c.InvocationId,
334
+ kind: l === "approval.requested" ? "approval" : d.kind === "form" ? "structured_input" : d.kind ?? e.kind ?? "approval",
335
+ title: d.title ?? t?.title,
336
+ message: d.message ?? d.description ?? w(d.detail)?.command ?? t?.description,
337
+ requestSchema: d.request_schema ?? d.requestSchema ?? d.input_schema ?? d.inputSchema ?? d.RequestSchema ?? e.request_schema,
338
+ presentation: t,
339
+ status: "pending",
340
+ revision: d.revision ?? 1,
341
+ createdAt: d.created_at ?? d.createdAt ?? c.timestamp ?? c.Timestamp,
342
+ expiresAt: d.expires_at ?? e.expires_at,
343
+ source: "interaction_v1",
344
+ extensions: n
345
+ });
346
+ }
347
+ if (te.has(l)) {
348
+ let e = {
349
+ ...w(d.extensions) || {},
350
+ ...d.detail === void 0 ? {} : { detail: d.detail },
351
+ ...(d.call_id ?? d.callId) === void 0 ? {} : { call_id: d.call_id ?? d.callId }
352
+ }, t = l === "interaction.cancelled" || l === "interaction.cancel" ? "cancelled" : l === "interaction.expired" ? "expired" : "resolved", n = String(u.outcome ?? d.outcome ?? d.status ?? "").toLowerCase(), r = String(u.action ?? d.action ?? u.name ?? d.name ?? "").toLowerCase(), i = n;
353
+ i ||= r === "approve" ? "approved" : r === "reject" ? "rejected" : r === "submit" ? "submitted" : r === "cancel" || t === "cancelled" ? "cancelled" : t === "expired" ? "expired" : "submitted";
354
+ let a = t === "resolved" ? "resolved" : t;
355
+ return y({
356
+ interactionId: f,
357
+ sessionId: p,
358
+ runId: d.run_id ?? d.runId ?? c.run_id ?? c.InvocationId,
359
+ kind: d.kind,
360
+ title: d.title,
361
+ message: d.message,
362
+ requestSchema: d.request_schema,
363
+ presentation: d.presentation,
364
+ status: a,
365
+ revision: d.revision,
366
+ createdAt: d.created_at ?? c.timestamp,
367
+ expiresAt: d.expires_at,
368
+ resolvedAt: u.resolved_at ?? u.resolvedAt ?? d.resolved_at ?? d.resolvedAt ?? c.timestamp ?? c.Timestamp,
369
+ actor: u.actor ?? d.actor ?? c.actor_ref,
370
+ outcome: i,
371
+ responseSummary: u.response_summary ?? d.response_summary ?? (r ? `${r}` : void 0),
372
+ ...Object.hasOwn(d, "response") ? { response: d.response } : Object.hasOwn(u, "response") ? { response: u.response } : !o && ["a2ui.action", "interaction.resolved"].includes(l) && Object.hasOwn(d, "data") ? { response: d.data } : {},
373
+ source: "interaction_v1",
374
+ extensions: e
375
+ });
376
+ }
377
+ return null;
378
+ }
379
+ //#endregion
380
+ //#region src/utils/responses-stream.js
381
+ function T() {
382
+ return {
383
+ toolNames: /* @__PURE__ */ new Map(),
384
+ toolArguments: /* @__PURE__ */ new Map(),
385
+ callIds: /* @__PURE__ */ new Map(),
386
+ currentResponseId: "",
387
+ sawTextDelta: !1,
388
+ messageTextByItem: /* @__PURE__ */ new Map(),
389
+ reasoningByItem: /* @__PURE__ */ new Map(),
390
+ reasoningByIndex: /* @__PURE__ */ new Map()
391
+ };
392
+ }
393
+ function E(e) {
394
+ 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 : "";
395
+ }
396
+ function D(e) {
397
+ return e == null ? "" : typeof e == "string" ? e : typeof e == "object" ? JSON.stringify(e, null, 2) : String(e);
398
+ }
399
+ function O(...e) {
400
+ for (let t of e) {
401
+ let e = E(t);
402
+ if (e) return e;
403
+ }
404
+ return "";
405
+ }
406
+ function k(e, t) {
407
+ return String(e?.id || e?.item_id || e?.call_id || t?.item_id || t?.call_id || (t?.output_index ?? ""));
408
+ }
409
+ function re(e, t, n, r, i) {
410
+ t && (e.toolNames.set(t, r), e.toolArguments.set(t, i));
411
+ let a = String(n?.call_id || "");
412
+ a && (e.callIds.set(t, a), e.callIds.set(a, a), e.toolNames.set(a, r), e.toolArguments.set(a, i));
413
+ }
414
+ function A(e, t, n, r, i) {
415
+ let a = i ? r : (e.messageTextByItem.get(t) || "") + r;
416
+ t && e.messageTextByItem.set(t, a), Number.isInteger(n) && e.messageTextByItem.set(n, a);
417
+ }
418
+ function j(e, t, n, r = "tool") {
419
+ let i = String(n?.call_id || "");
420
+ return String(n?.name || n?.tool_name || (t ? e.toolNames.get(t) : "") || (i ? e.toolNames.get(i) : "") || r);
421
+ }
422
+ function M(e) {
423
+ if (!e || typeof e != "object") return "";
424
+ let t = E(e.content);
425
+ return O(e.output_text, e.text, e.summary_text, e.summary, e.delta, t);
426
+ }
427
+ function ie(e) {
428
+ let t = e?.response && typeof e.response == "object" ? e.response : e, n = O(t?.output_text, t?.text);
429
+ if (n) return n;
430
+ let r = Array.isArray(t?.output) ? t.output : [];
431
+ for (let e of r) {
432
+ if (e?.type !== "message") continue;
433
+ let t = M(e);
434
+ if (t) return t;
435
+ }
436
+ return "";
437
+ }
438
+ function ae(e) {
439
+ let t = e?.response && typeof e.response == "object" ? e.response : e;
440
+ return Array.isArray(t?.output) ? t.output : [];
441
+ }
442
+ function oe(e) {
443
+ let t = e;
444
+ if (typeof t == "string") try {
445
+ t = JSON.parse(t);
446
+ } catch {
447
+ return {};
448
+ }
449
+ return Array.isArray(t) && (t = t[0] || {}), !t || typeof t != "object" ? {} : t.value && typeof t.value == "object" && !Array.isArray(t.value) ? {
450
+ ...t.value,
451
+ approval_request_id: t.value.approval_request_id || t.value.id || t.id
452
+ } : t;
453
+ }
454
+ function N(e, t, n, r, i = !1) {
455
+ if (!n) return [];
456
+ let a = e.reasoningByItem.get(t) ?? (i ? e.reasoningByIndex.get(r) : void 0) ?? {
457
+ itemId: t,
458
+ text: ""
459
+ }, o = a.text;
460
+ if (a.text = i ? n : o + n, e.reasoningByItem.set(t, a), Number.isInteger(r) && e.reasoningByIndex.set(r, a), i && o) {
461
+ if (n === o) return [];
462
+ if (a.itemId) return [{
463
+ type: "reasoning_snapshot",
464
+ itemId: a.itemId,
465
+ text: n
466
+ }];
467
+ }
468
+ return [{
469
+ type: "reasoning_delta",
470
+ text: i && n.startsWith(o) ? n.slice(o.length) : n,
471
+ ...a.itemId && { itemId: a.itemId }
472
+ }];
473
+ }
474
+ function P({ data: e, state: t, status: n }) {
475
+ let r = e?.item || e?.output_item || e || {}, i = String(r.type || "").trim(), a = k(r, e);
476
+ if (i === "function_call") {
477
+ let e = j(t, a, r), i = D(r.arguments ?? r.args ?? r.input);
478
+ re(t, a, r, e, i);
479
+ let o = t.callIds.get(a);
480
+ return [{
481
+ type: "tool_upsert",
482
+ name: e,
483
+ args: i,
484
+ status: n,
485
+ ...o && { callId: o }
486
+ }];
487
+ }
488
+ if (i === "function_call_output") return [{
489
+ type: "tool_result",
490
+ name: j(t, a, r),
491
+ ...r.call_id && { callId: r.call_id },
492
+ output: D(r.output ?? r.result ?? r.content)
493
+ }];
494
+ if (i === "mcp_user_question") {
495
+ let n = String(r.id || r.question_id || ""), i = Array.isArray(r.questions) ? r.questions : [], a = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
496
+ return [{
497
+ type: "question_request",
498
+ questionId: n,
499
+ questions: i,
500
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
501
+ ...a ? { runId: a } : {}
502
+ }];
503
+ }
504
+ if (i === "mcp_approval_request") {
505
+ let n = String(r.name || "approval"), i = D(r.arguments ?? r.args), a = String(r.id || r.approval_request_id || ""), o = String(r.run_id || r.runId || e?.run_id || e?.runId || "");
506
+ return [{
507
+ type: "tool_upsert",
508
+ name: n,
509
+ args: i,
510
+ status: "paused",
511
+ approvalRequestId: a,
512
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
513
+ serverLabel: String(r.server_label || "")
514
+ }, {
515
+ type: "approval_request",
516
+ approvalRequestId: a,
517
+ previousResponseId: String(e?.response_id || t.currentResponseId || ""),
518
+ ...o ? { runId: o } : {},
519
+ name: n,
520
+ args: i
521
+ }];
522
+ }
523
+ if (i === "reasoning" || i === "reasoning_summary" || i === "reasoning_summary_text") return N(t, a, M(r), e?.output_index, !0);
524
+ if (i === "message") {
525
+ let i = M(r);
526
+ return i && A(t, a, e?.output_index, i, !0), i ? [{
527
+ type: n === "completed" ? "text_final" : "text_delta",
528
+ text: i
529
+ }] : [];
530
+ }
531
+ return [];
532
+ }
533
+ function se({ eventName: e, data: t, state: n }) {
534
+ let r = String(t?.type || e || "").trim(), i = String(t?.id || t?.response?.id || t?.response_id || "");
535
+ if (i.startsWith("resp_") && (n.currentResponseId = i), r === "response.tool_call") {
536
+ let e = String(t?.name || t?.tool_name || "tool"), r = D(t?.args ?? t?.arguments), i = t?.call_id;
537
+ return i && re(n, i, t, e, r), [{
538
+ type: "tool_upsert",
539
+ name: e,
540
+ args: r,
541
+ status: "running",
542
+ ...i && { callId: i }
543
+ }];
544
+ }
545
+ if (r === "response.tool_result" || r === "response.ksadk.tool_result") {
546
+ let e = String(t?.name || t?.tool_name || "tool"), r = t?.call_id || n.callIds.get(t?.run_id);
547
+ return [{
548
+ type: "tool_result",
549
+ name: e,
550
+ output: D(t?.output ?? t?.result),
551
+ ...r && { callId: r }
552
+ }];
553
+ }
554
+ if (r === "response.output_item.added") return P({
555
+ data: t,
556
+ state: n,
557
+ status: "running"
558
+ });
559
+ if (r === "response.output_item.done") return P({
560
+ data: t,
561
+ state: n,
562
+ status: "completed"
563
+ });
564
+ if (r === "response.function_call_arguments.delta") {
565
+ let e = String(t?.item_id || t?.call_id || ""), r = j(n, e, t), i = `${n.toolArguments.get(e) || ""}${String(t?.delta || "")}`;
566
+ n.toolArguments.set(e, i);
567
+ let a = n.callIds.get(e);
568
+ return [{
569
+ type: "tool_upsert",
570
+ name: r,
571
+ args: i,
572
+ status: "running",
573
+ ...a && { callId: a }
574
+ }];
575
+ }
576
+ if (r === "response.function_call_arguments.done") {
577
+ let e = String(t?.item_id || t?.call_id || ""), r = j(n, e, t), i = D(t?.arguments ?? n.toolArguments.get(e));
578
+ n.toolArguments.set(e, i);
579
+ let a = n.callIds.get(e);
580
+ return [{
581
+ type: "tool_upsert",
582
+ name: r,
583
+ args: i,
584
+ status: "running",
585
+ ...a && { callId: a }
586
+ }];
587
+ }
588
+ if (r === "response.reasoning.delta" || r === "response.reasoning_text.delta" || r === "response.reasoning_summary.delta" || r === "response.reasoning_summary_text.delta") {
589
+ let e = O(t?.delta, t?.text);
590
+ return N(n, k(null, t), e, t?.output_index);
591
+ }
592
+ if (r === "response.output_text.delta") {
593
+ if (t?.replace === !0 && (typeof t.delta == "string" || typeof t.text == "string")) {
594
+ n.sawTextDelta = !0;
595
+ let e = typeof t.delta == "string" ? t.delta : t.text;
596
+ return A(n, k(null, t), t.output_index, e, !0), [{
597
+ type: "text_replace",
598
+ text: e
599
+ }];
600
+ }
601
+ let e = O(t?.delta, t?.text);
602
+ return e && (n.sawTextDelta = !0, A(n, k(null, t), t?.output_index, e, !1)), e ? [{
603
+ type: "text_delta",
604
+ text: e
605
+ }] : [];
606
+ }
607
+ if (r === "response.output_text.done") {
608
+ let e = O(t?.text, t?.delta);
609
+ return e && A(n, k(null, t), t?.output_index, e, !0), e ? [{
610
+ type: "text_final",
611
+ text: e
612
+ }] : [];
613
+ }
614
+ if (r === "response.content_part.delta") {
615
+ let e = String(t?.part?.type || t?.delta?.type || t?.content_type || ""), r = O(t?.delta?.text, t?.delta, t?.text);
616
+ return r ? e.includes("reasoning") ? N(n, k(null, t), r, t?.output_index) : (n.sawTextDelta = !0, A(n, k(null, t), t?.output_index, r, !1), [{
617
+ type: "text_delta",
618
+ text: r
619
+ }]) : [];
620
+ }
621
+ if (r === "response.completed") {
622
+ let e = ie(t), r = ae(t).flatMap((e, r) => {
623
+ if (n.sawTextDelta && e?.type === "message") {
624
+ let t = k(e, {}), i = M(e);
625
+ if (!t || !n.messageTextByItem.size || n.messageTextByItem.get(t) === i || n.messageTextByItem.get(r) === i) return [];
626
+ }
627
+ return P({
628
+ data: {
629
+ ...t,
630
+ output_index: r,
631
+ item: e
632
+ },
633
+ state: n,
634
+ status: "completed"
635
+ });
636
+ }), i = r.some((e) => e.type === "text_final");
637
+ return [
638
+ ...r,
639
+ ...e && !n.sawTextDelta && !i ? [{
640
+ type: "text_final",
641
+ text: e
642
+ }] : [],
643
+ {
644
+ type: "terminal",
645
+ status: "completed"
646
+ }
647
+ ];
648
+ }
649
+ if (r === "response.failed") return [{
650
+ type: "failed",
651
+ message: t?.error?.message || "Agent 运行失败"
652
+ }, {
653
+ type: "terminal",
654
+ status: "failed"
655
+ }];
656
+ if (r === "response.incomplete") return [{ type: "incomplete" }, {
657
+ type: "terminal",
658
+ status: "incomplete"
659
+ }];
660
+ if (r === "response.cancelled") return [{
661
+ type: "terminal",
662
+ status: "cancelled"
663
+ }];
664
+ if (r === "response.approval_request" || r === "response.ksadk.approval_request") {
665
+ let e = oe(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 : [];
666
+ if (s.length > 0) {
667
+ let e = s.map((e) => ({
668
+ type: "tool_upsert",
669
+ name: String(e?.name || "tool"),
670
+ args: JSON.stringify(e?.args ?? {}),
671
+ status: "paused",
672
+ approvalRequestId: r,
673
+ previousResponseId: i
674
+ })), t = s[0] || {};
675
+ return [...e, {
676
+ type: "approval_request",
677
+ approvalRequestId: r,
678
+ previousResponseId: i,
679
+ ...a ? { runId: a } : {},
680
+ name: String(t?.name || "人工确认"),
681
+ args: JSON.stringify(t?.args ?? {})
682
+ }];
683
+ }
684
+ return [{
685
+ type: "approval_request",
686
+ approvalRequestId: r,
687
+ previousResponseId: i,
688
+ ...a ? { runId: a } : {}
689
+ }];
690
+ }
691
+ if (r === "response.question_resolved" || r === "response.ksadk.question_resolved") return [{
692
+ type: "question_resolved",
693
+ questionId: String(t?.question_id || t?.questionId || ""),
694
+ answers: t?.answers && typeof t.answers == "object" ? t.answers : {},
695
+ revision: Number(t?.revision || 2)
696
+ }];
697
+ if (r === "response.approval_resolved" || r === "response.ksadk.approval_resolved") {
698
+ let e = String(t?.decision || t?.outcome || "").toLowerCase(), n = e === "reject" || e === "rejected" || e === "denied" ? "rejected" : e === "cancel" || e === "cancelled" || e === "canceled" ? "cancelled" : "approved";
699
+ return [{
700
+ type: "approval_resolved",
701
+ approvalRequestId: String(t?.approval_request_id || t?.approvalRequestId || t?.approval_id || t?.approvalId || ""),
702
+ decision: n,
703
+ revision: Number(t?.revision || 2)
704
+ }];
705
+ }
706
+ if (new Set([
707
+ "response.ksadk.a2ui_surface_begin",
708
+ "a2ui.surface.begin",
709
+ "response.a2ui.createSurface",
710
+ "a2ui.createSurface",
711
+ "createSurface"
712
+ ]).has(r)) {
713
+ let e = t?.surface && typeof t.surface == "object" ? t.surface : {};
714
+ return [{
715
+ type: "a2ui_surface_begin",
716
+ surfaceId: String(t?.surface_id || t?.surfaceId || e.surface_id || e.surfaceId || ""),
717
+ surface: e
718
+ }];
719
+ }
720
+ if (new Set([
721
+ "response.ksadk.a2ui_surface_update",
722
+ "a2ui.surface.update",
723
+ "response.a2ui.updateComponents",
724
+ "a2ui.updateComponents",
725
+ "updateComponents"
726
+ ]).has(r)) {
727
+ let e = t?.surface && typeof t.surface == "object" ? t.surface : {};
728
+ return [{
729
+ type: "a2ui_surface_update",
730
+ surfaceId: String(t?.surface_id || t?.surfaceId || e.surface_id || e.surfaceId || ""),
731
+ surface: e
732
+ }];
733
+ }
734
+ if (new Set([
735
+ "response.ksadk.a2ui_surface_end",
736
+ "a2ui.surface.end",
737
+ "response.a2ui.deleteSurface",
738
+ "a2ui.deleteSurface",
739
+ "deleteSurface"
740
+ ]).has(r)) return [{
741
+ type: "a2ui_surface_end",
742
+ surfaceId: String(t?.surface_id || t?.surfaceId || "")
743
+ }];
744
+ if (new Set(["response.ksadk.a2ui_interaction", "a2ui.interaction"]).has(r)) return [{
745
+ type: "a2ui_interaction",
746
+ surfaceId: String(t?.surface_id || t?.surfaceId || ""),
747
+ interactionId: String(t?.interaction_id || t?.interactionId || ""),
748
+ kind: String(t?.kind || "input"),
749
+ inputSchema: t?.input_schema && typeof t.input_schema == "object" ? t.input_schema : {}
750
+ }];
751
+ let a = t?.content?.parts?.[0]?.text;
752
+ return a && !t?.actions?.finishReason ? [{
753
+ type: "text_delta",
754
+ text: String(a)
755
+ }] : [];
756
+ }
757
+ //#endregion
758
+ //#region src/utils/tool-display.js
759
+ function ce(e) {
760
+ return String(e || "").replace(/\\u([0-9a-fA-F]{4})/g, (e, t) => String.fromCharCode(Number.parseInt(t, 16)));
761
+ }
762
+ function F(e) {
763
+ let t = String(e || "").trim();
764
+ for (let e = 0; e < 3; e += 1) {
765
+ if (!t) return t;
766
+ let e = t[0], n = t[t.length - 1];
767
+ if (!(e === "{" && n === "}" || e === "[" && n === "]" || e === "\"" && n === "\"")) return t.replace(/\\n/g, "\n").replace(/\\"/g, "\"");
768
+ try {
769
+ let e = JSON.parse(t);
770
+ if (typeof e != "string") return I(e);
771
+ t = e.trim();
772
+ } catch {
773
+ return ce(t).replace(/\\n/g, "\n").replace(/\\"/g, "\"");
774
+ }
775
+ }
776
+ return t;
777
+ }
778
+ function I(e) {
779
+ return typeof e == "string" ? F(e) : Array.isArray(e) ? e.map((e) => I(e)) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, I(t)]));
780
+ }
781
+ function L(e) {
782
+ return typeof e == "string" ? F(e) : I(e);
783
+ }
784
+ function R(e) {
785
+ return e === !1 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "false" : !1;
786
+ }
787
+ function z(e) {
788
+ return e === !0 ? !0 : typeof e == "string" ? e.trim().toLowerCase() === "true" : !1;
789
+ }
790
+ function B(e) {
791
+ return e == null || e === !1 ? !1 : typeof e == "string" ? e.trim().length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
792
+ }
793
+ function le(e) {
794
+ return String(e?.status || "").trim().toLowerCase() === "accepted_not_extracted";
795
+ }
796
+ function V(e, t = 0) {
797
+ if (!e || t > 4) return !1;
798
+ if (typeof e == "string") {
799
+ let n = F(e);
800
+ return n !== e && V(n, t + 1);
801
+ }
802
+ if (Array.isArray(e)) return e.some((e) => V(e, t + 1));
803
+ if (typeof e != "object" || le(e)) return !1;
804
+ if (R(e.ok) || R(e.success)) return !0;
805
+ let n = z(e.ok) || z(e.success), r = String(e.status || "").trim().toLowerCase();
806
+ return !n && [
807
+ "error",
808
+ "failed",
809
+ "failure"
810
+ ].includes(r) || !n && (B(e.error_type) || B(e.error_message) || B(e.error)) ? !0 : Object.values(e).some((e) => V(e, t + 1));
811
+ }
812
+ function H(e) {
813
+ return e == null || e === "" ? !1 : V(L(e));
814
+ }
815
+ function ue(e) {
816
+ if (e == null || e === "") return "";
817
+ let t = L(e);
818
+ return typeof t == "string" ? t : JSON.stringify(t, null, 2);
819
+ }
820
+ //#endregion
821
+ //#region src/utils/session-events.js
822
+ var U = new Set([
823
+ "completed",
824
+ "failed",
825
+ "error",
826
+ "cancelled",
827
+ "canceled",
828
+ "aborted",
829
+ "interrupted",
830
+ "resume_failed"
831
+ ]), W = new Set([
832
+ "tool_call",
833
+ "tool_result",
834
+ "stage_tool_call",
835
+ "stage_tool_result"
836
+ ]), G = {
837
+ "run.started": "in_progress",
838
+ "run.progress": "in_progress",
839
+ "run.interrupted": "interrupted",
840
+ "run.completed": "completed",
841
+ "run.failed": "failed",
842
+ "run.canceled": "cancelled"
843
+ };
844
+ function K(e) {
845
+ let t = e?.Content?.payload;
846
+ return t && typeof t == "object" ? t : {};
847
+ }
848
+ function de(e, t) {
849
+ let n = String(e || ""), r = String(t || "");
850
+ return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
851
+ }
852
+ function fe(e) {
853
+ let t = String(e?.EventType || ""), n = K(e);
854
+ return G[t] ? {
855
+ ...e,
856
+ EventType: "run_status",
857
+ Content: {
858
+ status: String(n.status || G[t]),
859
+ ...n.detail ? { detail: String(n.detail) } : {}
860
+ }
861
+ } : t === "reasoning.delta" || t === "reasoning.completed" ? {
862
+ ...e,
863
+ EventType: "reasoning",
864
+ Content: {
865
+ role: "model",
866
+ parts: [{ text: String(n.text || "") }]
867
+ }
868
+ } : t === "tool.call.begin" ? {
869
+ ...e,
870
+ EventType: "tool_call",
871
+ Metadata: {
872
+ ...e.Metadata || {},
873
+ tool_name: n.name,
874
+ tool_args: n.args,
875
+ tool_call_id: n.call_id
876
+ },
877
+ Content: {
878
+ role: "model",
879
+ parts: []
880
+ }
881
+ } : t === "tool.call.end" ? {
882
+ ...e,
883
+ EventType: "tool_result",
884
+ Metadata: {
885
+ ...e.Metadata || {},
886
+ tool_name: n.name,
887
+ tool_output: n.error || n.result,
888
+ tool_call_id: n.call_id
889
+ },
890
+ Content: {
891
+ role: "model",
892
+ parts: []
893
+ }
894
+ } : e;
895
+ }
896
+ function pe(e) {
897
+ let t = [], n = /* @__PURE__ */ new Map();
898
+ for (let r of Array.isArray(e) ? e : []) {
899
+ let e = String(r?.EventType || "");
900
+ if (e === "text.delta" || e === "text.completed" || e === "message.delta") {
901
+ let e = String(r?.InvocationId || "").trim();
902
+ if (!e) continue;
903
+ let t = n.get(e);
904
+ n.set(e, {
905
+ event: r,
906
+ text: de(t?.text, K(r).text || r?.Content?.text)
907
+ });
908
+ continue;
909
+ }
910
+ t.push(fe(r));
911
+ }
912
+ for (let { event: e, text: r } of n.values()) t.push({
913
+ ...e,
914
+ EventType: "assistant_stream_snapshot",
915
+ Content: {
916
+ role: "model",
917
+ parts: [{ text: r }]
918
+ },
919
+ Metadata: {
920
+ ...e.Metadata || {},
921
+ stream_snapshot: !0
922
+ }
923
+ });
924
+ for (let n of Array.isArray(e) ? e : []) String(n?.EventType || "") === "message.completed" && t.push({
925
+ ...n,
926
+ EventType: "assistant_message",
927
+ Content: {
928
+ role: "model",
929
+ parts: [{ text: String(K(n).text || n?.Content?.text || "") }]
930
+ }
931
+ });
932
+ return t.sort((e, t) => $(e) - $(t));
933
+ }
934
+ function q(e) {
935
+ let t = String(e?.EventType || "").trim();
936
+ if (t !== "run_status" && !t.startsWith("run.")) return "";
937
+ let n = K(e);
938
+ return String(e?.Content?.status || n.status || t === "run_status" && e?.Metadata?.status || G[t] || "").trim().toLowerCase();
939
+ }
940
+ function J(e) {
941
+ 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("") : "";
942
+ }
943
+ function Y(e) {
944
+ let t = String(e || "").trim();
945
+ return t ? `/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}` : "";
946
+ }
947
+ function me(e) {
948
+ return String(e || "").match(/^data:([^;,]+)/)?.[1] || "";
949
+ }
950
+ function he(e, t) {
951
+ let n = String(e || "").trim(), r = String(t || "").trim();
952
+ return !n || !r || n === r ? !0 : n.endsWith("/*") ? r.startsWith(n.slice(0, -1)) : r.endsWith("/*") ? n.startsWith(r.slice(0, -1)) : !1;
953
+ }
954
+ function X(e) {
955
+ let t = e?.Content?.parts || [], n = [], r = /* @__PURE__ */ new Map(), i = (e) => {
956
+ let t = `${e.fileUri || e.url || e.name}|${e.type}`;
957
+ r.has(t) || r.set(t, e);
958
+ };
959
+ for (let e of t) {
960
+ if (e?.type === "input_text" || e?.text) {
961
+ n.push(e.text || "");
962
+ continue;
963
+ }
964
+ if (e?.type === "input_file" && e.inlineData) {
965
+ i({
966
+ name: e.inlineData.displayName || "attachment",
967
+ url: `data:${e.inlineData.mimeType || "application/octet-stream"};base64,${e.inlineData.data}`,
968
+ type: e.inlineData.mimeType || "application/octet-stream"
969
+ });
970
+ continue;
971
+ }
972
+ if (e?.type === "input_file" && typeof e.file_data == "string" && e.file_data) {
973
+ i({
974
+ name: e.filename || e.displayName || e.display_name || "attachment",
975
+ url: `data:${e.mime_type || e.mimeType || "application/octet-stream"};base64,${e.file_data}`,
976
+ type: e.mime_type || e.mimeType || "application/octet-stream"
977
+ });
978
+ continue;
979
+ }
980
+ if (e?.type === "input_file" && typeof e.file_url == "string" && e.file_url.trim()) {
981
+ let t = e.file_url.trim();
982
+ i({
983
+ name: e.filename || e.displayName || e.display_name || "attachment",
984
+ url: Y(t),
985
+ type: e.mime_type || e.mimeType || "application/octet-stream",
986
+ fileUri: t
987
+ });
988
+ continue;
989
+ }
990
+ if (e?.type === "input_image" || e?.type === "image_url") {
991
+ let t = typeof e.image_url == "string" ? e.image_url : e.image_url?.url;
992
+ t && i({
993
+ name: e.filename || e.displayName || e.display_name || "uploaded_image",
994
+ url: t,
995
+ type: e.mime_type || e.mimeType || me(t) || "image/*"
996
+ });
997
+ continue;
998
+ }
999
+ if (e?.type === "input_file" && e.fileData) {
1000
+ let t = String(e.fileData.fileUri || "").trim();
1001
+ i({
1002
+ name: e.fileData.displayName || "attachment",
1003
+ url: Y(t),
1004
+ type: e.fileData.mimeType || "application/octet-stream",
1005
+ fileUri: t
1006
+ });
1007
+ }
1008
+ }
1009
+ let a = Array.isArray(e?.Metadata?.attachments) ? e.Metadata.attachments : [];
1010
+ for (let e of a) {
1011
+ let t = String(e.file_uri || "").trim(), n = {
1012
+ name: e.display_name || "attachment",
1013
+ url: Y(t),
1014
+ type: e.mime_type || "application/octet-stream",
1015
+ fileUri: t
1016
+ };
1017
+ !n.url && !n.fileUri && Array.from(r.values()).some((e) => e.name === n.name && he(e.type, n.type) && (e.url || e.fileUri)) || i(n);
1018
+ }
1019
+ let o = Array.from(r.values());
1020
+ return {
1021
+ text: n.join(""),
1022
+ attachments: o.length > 0 ? o : void 0
1023
+ };
1024
+ }
1025
+ function ge(e) {
1026
+ let t = e?.Metadata?.responses_output;
1027
+ if (!Array.isArray(t)) return {};
1028
+ let n = T(), r = se({
1029
+ eventName: "response.completed",
1030
+ data: { response: {
1031
+ id: String(e.Metadata?.response_id || ""),
1032
+ output: t
1033
+ } },
1034
+ state: n
1035
+ }), i = "", a = {};
1036
+ for (let e of r) {
1037
+ if (e.type === "reasoning_delta") {
1038
+ i += e.text;
1039
+ continue;
1040
+ }
1041
+ if (e.type === "tool_upsert") {
1042
+ a[e.name] = {
1043
+ ...a[e.name] || {
1044
+ name: e.name,
1045
+ args: ""
1046
+ },
1047
+ name: e.name,
1048
+ args: e.args,
1049
+ status: e.status,
1050
+ ...e.approvalRequestId ? { approvalRequestId: e.approvalRequestId } : {},
1051
+ ...e.previousResponseId ? { previousResponseId: e.previousResponseId } : {},
1052
+ ...e.serverLabel ? { serverLabel: e.serverLabel } : {},
1053
+ ...e.approvalRequestId ? { approvalStatus: "pending" } : {}
1054
+ };
1055
+ continue;
1056
+ }
1057
+ e.type === "tool_result" && (a[e.name] = {
1058
+ ...a[e.name] || {
1059
+ name: e.name,
1060
+ args: ""
1061
+ },
1062
+ name: e.name,
1063
+ output: e.output,
1064
+ status: H(e.output) ? "error" : "completed"
1065
+ });
1066
+ }
1067
+ return {
1068
+ ...i ? { reasoning: i } : {},
1069
+ ...Object.keys(a).length > 0 ? { tools: a } : {}
1070
+ };
1071
+ }
1072
+ function _e(e, t, n) {
1073
+ return t === "running" ? e === "prompt_too_long" ? "检测到上下文过长,正在自动压缩历史后重试" : "正在自动压缩上下文" : n ? e === "prompt_too_long" ? "上下文过长,系统已自动压缩历史并重试" : "系统已自动压缩较早的对话上下文" : t === "failed" ? "自动压缩上下文未完成" : e === "prompt_too_long" ? "已完成上下文压缩,并继续当前回复" : "已完成上下文压缩";
1074
+ }
1075
+ function Z(e, t) {
1076
+ return t?.itemId ? [
1077
+ "runtime-item",
1078
+ t.runId || e,
1079
+ t.scopeId || e,
1080
+ t.itemId
1081
+ ].join("\0") : [
1082
+ e,
1083
+ t.content || "",
1084
+ t.reasoning || ""
1085
+ ].join("\0");
1086
+ }
1087
+ function Q(e) {
1088
+ let t = String(e?.InvocationId || "").trim(), n = e?.Metadata?.RuntimeItem;
1089
+ return n?.ItemId ? [
1090
+ "runtime-item",
1091
+ n.RunId || t,
1092
+ n.ScopeId || t,
1093
+ n.ItemId
1094
+ ].join("\0") : t;
1095
+ }
1096
+ function ve(e) {
1097
+ let t = e?.Metadata?.RuntimeItem;
1098
+ return t?.ItemId ? {
1099
+ id: `runtime:${t.RunId || e.InvocationId || "run"}:${t.ScopeId || e.InvocationId || "scope"}:${t.ItemId}`,
1100
+ runId: String(t.RunId || e.InvocationId || ""),
1101
+ scopeId: String(t.ScopeId || e.InvocationId || ""),
1102
+ itemId: String(t.ItemId),
1103
+ partId: t.PartId ? String(t.PartId) : void 0
1104
+ } : null;
1105
+ }
1106
+ function ye(e) {
1107
+ return e?.Metadata?.responses_mirror === !0 || String(e?.Metadata?.responses_mirror || "").trim().toLowerCase() === "true";
1108
+ }
1109
+ function be(e) {
1110
+ if (e?.EventType !== "user_message") return "";
1111
+ let t = X(e), n = (t.attachments || []).map((e) => [
1112
+ e.name || "",
1113
+ e.fileUri || "",
1114
+ e.url || "",
1115
+ e.type || ""
1116
+ ].join("")).sort().join("");
1117
+ return [String(t.text || "").trim(), n].join("\0");
1118
+ }
1119
+ function xe(e) {
1120
+ return e?.EventType === "assistant_stream_snapshot";
1121
+ }
1122
+ function $(e) {
1123
+ let t = Number(e?.SeqId || 0);
1124
+ if (Number.isFinite(t) && t > 0) return t;
1125
+ let n = Number(e?.Timestamp || 0);
1126
+ return Number.isFinite(n) ? n : 0;
1127
+ }
1128
+ function Se(e) {
1129
+ if (typeof e == "string") return e;
1130
+ if (e == null) return "";
1131
+ try {
1132
+ return JSON.stringify(e, null, 2);
1133
+ } catch {
1134
+ return String(e);
1135
+ }
1136
+ }
1137
+ function Ce(e) {
1138
+ let t = String(e?.EventType || "");
1139
+ if (!W.has(t)) return null;
1140
+ let n = String(e.Metadata?.tool_name || e.Metadata?.name || e.Metadata?.function_name || J(e.Content?.parts) || "tool").trim() || "tool", r = String(e.Metadata?.call_id || e.Metadata?.callId || e.Metadata?.RuntimeItem?.ToolCallId || "").trim(), i = {
1141
+ name: n,
1142
+ ...r ? { callId: r } : {},
1143
+ args: "",
1144
+ status: "running"
1145
+ }, a = t === "tool_result" || t === "stage_tool_result" ? (() => {
1146
+ let t = Se(e.Metadata?.tool_output ?? e.Metadata?.output ?? e.Metadata?.result ?? J(e.Content?.parts));
1147
+ return {
1148
+ ...i,
1149
+ output: t,
1150
+ status: H(t) ? "error" : "completed"
1151
+ };
1152
+ })() : {
1153
+ ...i,
1154
+ args: Se(e.Metadata?.tool_args ?? e.Metadata?.arguments ?? e.Metadata?.args ?? {})
1155
+ }, o = ve(e);
1156
+ return {
1157
+ id: o?.id || e.EventId || String(Date.now() + Math.random()),
1158
+ role: "model",
1159
+ content: "",
1160
+ timestamp: e.Timestamp || Date.now(),
1161
+ eventType: t,
1162
+ ...o || {},
1163
+ tools: { [n]: a }
1164
+ };
1165
+ }
1166
+ function we(e = {}, t = {}) {
1167
+ let n = { ...e || {} };
1168
+ for (let [e, r] of Object.entries(t || {})) n[e] = {
1169
+ ...n[e] || {},
1170
+ ...r || {},
1171
+ name: e,
1172
+ args: r?.args || n[e]?.args || ""
1173
+ };
1174
+ return n;
1175
+ }
1176
+ function Te(e = {}, t = "") {
1177
+ let n = String(t || "").trim().toLowerCase(), r = n === "completed" ? "completed" : U.has(n) ? "error" : "";
1178
+ if (!r) return e;
1179
+ let i = !1, a = {};
1180
+ for (let [t, n] of Object.entries(e || {})) n?.status === "running" ? (i = !0, a[t] = {
1181
+ ...n,
1182
+ status: r
1183
+ }) : a[t] = n;
1184
+ return i ? a : e;
1185
+ }
1186
+ function Ee(e, t) {
1187
+ return {
1188
+ ...e,
1189
+ reasoning: De(e.reasoning, t.reasoning),
1190
+ tools: we(e.tools, t.tools),
1191
+ eventId: t.eventId || e.eventId,
1192
+ responseId: t.responseId || e.responseId,
1193
+ traceId: t.traceId || e.traceId,
1194
+ rootSpanId: t.rootSpanId || e.rootSpanId,
1195
+ timestamp: Math.max(Number(e.timestamp || 0), Number(t.timestamp || 0)) || t.timestamp || e.timestamp,
1196
+ id: t.responseId || t.reasoning || t.tools ? t.id : e.id
1197
+ };
1198
+ }
1199
+ function De(e = "", t = "") {
1200
+ let n = String(e || ""), r = String(t || "");
1201
+ return n ? !r || n.endsWith(r) ? n : r.startsWith(n) ? r : `${n}${r}` : r;
1202
+ }
1203
+ function Oe(e) {
1204
+ return {
1205
+ id: e.id,
1206
+ role: "system",
1207
+ eventType: "context_checkpoint",
1208
+ status: e.status,
1209
+ trigger: e.trigger,
1210
+ compactedUntilSeqId: e.compactedUntilSeqId,
1211
+ summary: e.summary,
1212
+ historical: e.historical,
1213
+ timestamp: e.timestamp,
1214
+ content: _e(e.trigger, e.status, e.historical)
1215
+ };
1216
+ }
1217
+ function ke(e) {
1218
+ let t = Ae(e);
1219
+ return t && Number.isSafeInteger(e.SeqId) && e.SeqId > 0 && (t.historyOrder = { seq: e.SeqId }), t;
1220
+ }
1221
+ function Ae(e) {
1222
+ let t = e?.EventType || "", n = ve(e);
1223
+ if (t === "run_status") return e.Content?.status === "failed" ? {
1224
+ id: e.EventId || String(Date.now() + Math.random()),
1225
+ role: "system",
1226
+ content: e.Content?.detail || "本轮运行失败。",
1227
+ eventType: t,
1228
+ status: "failed",
1229
+ timestamp: e.Timestamp || Date.now()
1230
+ } : e.Content?.status === "cancelled" ? {
1231
+ id: e.EventId || String(Date.now() + Math.random()),
1232
+ role: "system",
1233
+ content: e.Content?.detail || "本轮输出已停止。",
1234
+ eventType: t,
1235
+ status: "cancelled",
1236
+ timestamp: e.Timestamp || Date.now()
1237
+ } : null;
1238
+ if (t === "context_checkpoint") {
1239
+ let t = X(e);
1240
+ return Oe({
1241
+ id: e.EventId || String(Date.now() + Math.random()),
1242
+ timestamp: e.Timestamp || Date.now(),
1243
+ status: "completed",
1244
+ trigger: String(e.Metadata?.trigger || "auto"),
1245
+ compactedUntilSeqId: Number(e.Metadata?.compacted_until_seq_id || 0) || void 0,
1246
+ summary: t.text || void 0,
1247
+ historical: !0
1248
+ });
1249
+ }
1250
+ if (t === "reasoning") {
1251
+ let r = X(e).text || J(e.Metadata?.reasoning);
1252
+ return r ? {
1253
+ id: n?.id || e.EventId || String(Date.now() + Math.random()),
1254
+ role: "model",
1255
+ content: "",
1256
+ reasoning: r,
1257
+ ...e.Metadata?.presentation_source === "public_summary" ? { reasoningSource: "public_summary" } : e.Metadata?.presentation_source === "provider_reasoning" ? { reasoningSource: "provider_reasoning" } : {},
1258
+ timestamp: e.Timestamp || Date.now(),
1259
+ eventType: t,
1260
+ ...n || {}
1261
+ } : null;
1262
+ }
1263
+ if (W.has(t)) return Ce(e);
1264
+ if (t !== "user_message" && t !== "assistant_message" && t !== "assistant_stream_snapshot") return null;
1265
+ let r = X(e), i = t === "assistant_message" ? ge(e) : {};
1266
+ if (!r.text && !r.attachments?.length && !i.reasoning && !i.tools) return null;
1267
+ 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();
1268
+ return {
1269
+ id: n?.id || e.EventId || String(Date.now() + Math.random()),
1270
+ role: t === "user_message" ? "user" : "model",
1271
+ content: r.text,
1272
+ timestamp: e.Timestamp || Date.now(),
1273
+ eventType: t,
1274
+ eventId: e.EventId || void 0,
1275
+ responseId: a || void 0,
1276
+ traceId: o || void 0,
1277
+ rootSpanId: s || void 0,
1278
+ attachments: r.attachments,
1279
+ ...n || {},
1280
+ ...i
1281
+ };
1282
+ }
1283
+ function je(e = []) {
1284
+ 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 = pe(e), c = [];
1285
+ for (let e of s) {
1286
+ let t = String(e?.EventId || "").trim();
1287
+ if (t) {
1288
+ if (o.has(t)) continue;
1289
+ o.add(t);
1290
+ }
1291
+ c.push(e);
1292
+ }
1293
+ let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
1294
+ for (let e of c) {
1295
+ if (e?.EventType !== "user_message" || ye(e)) {
1296
+ if (e?.EventType === "assistant_message") {
1297
+ let t = Q(e);
1298
+ t && u.add(t);
1299
+ }
1300
+ if (xe(e)) {
1301
+ let t = Q(e);
1302
+ if (t) {
1303
+ let n = d.get(t);
1304
+ (!n || $(e) >= $(n)) && d.set(t, e);
1305
+ }
1306
+ }
1307
+ continue;
1308
+ }
1309
+ let t = be(e);
1310
+ t && l.add(t);
1311
+ }
1312
+ let f = c.filter((e) => {
1313
+ if (xe(e)) {
1314
+ let t = Q(e);
1315
+ return t ? u.has(t) ? !1 : d.get(t) === e : !0;
1316
+ }
1317
+ if (e?.EventType !== "user_message" || !ye(e)) return !0;
1318
+ let t = be(e);
1319
+ return !t || !l.has(t);
1320
+ });
1321
+ for (let e of f) {
1322
+ let a = String(e.InvocationId || "").trim();
1323
+ a && e.EventType === "user_message" && i.add(a), a && [
1324
+ "assistant_message",
1325
+ "assistant_stream_snapshot",
1326
+ "reasoning",
1327
+ "tool_call",
1328
+ "tool_result",
1329
+ "stage_tool_call",
1330
+ "stage_tool_result"
1331
+ ].includes(String(e.EventType || "")) && r.add(a), e.EventType === "run_status" && a && (t.set(a, String(e.Content?.status || "").trim()), n.set(a, e));
1332
+ }
1333
+ let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = /* @__PURE__ */ new Map(), v = (e) => {
1334
+ let t = e?.itemId ? `${e.runId || e.invocationId || ""}\u0000${e.scopeId || e.invocationId || ""}\u0000${e.itemId}` : "", n = t ? h.get(t) : void 0;
1335
+ if (n !== void 0) {
1336
+ p[n] = Ee(p[n], e);
1337
+ return;
1338
+ }
1339
+ let r = String(e?.responseId || "").trim(), i = r ? m.get(r) : void 0;
1340
+ if (i !== void 0) {
1341
+ p[i] = Ee(p[i], e);
1342
+ return;
1343
+ }
1344
+ r && m.set(r, p.length), t && h.set(t, p.length), p.push(e);
1345
+ }, y = () => {
1346
+ g &&= (v(g), null);
1347
+ }, b = (e, n = "") => {
1348
+ let r = String(e || "").trim();
1349
+ if (!r) return {};
1350
+ let i = _.get(r);
1351
+ return i ? (_.delete(r), { tools: Te(i.tools, t.get(r) || n) }) : {};
1352
+ };
1353
+ for (let e of f) {
1354
+ if (e.EventType === "run_status") continue;
1355
+ let t = ke(e);
1356
+ if (!t) continue;
1357
+ let n = String(e.InvocationId || "").trim();
1358
+ if (n && (t.invocationId = n), W.has(t.eventType)) {
1359
+ let n = String(e.InvocationId || "").trim();
1360
+ if (t.itemId) {
1361
+ y(), v(t);
1362
+ continue;
1363
+ }
1364
+ if (!n) {
1365
+ y(), v(t);
1366
+ continue;
1367
+ }
1368
+ let r = _.get(n);
1369
+ _.set(n, {
1370
+ ...r || {
1371
+ id: t.id,
1372
+ role: "model",
1373
+ content: "",
1374
+ timestamp: t.timestamp,
1375
+ invocationId: n
1376
+ },
1377
+ timestamp: Math.max(Number(r?.timestamp || 0), Number(t.timestamp || 0)),
1378
+ tools: we(r?.tools, t.tools)
1379
+ });
1380
+ continue;
1381
+ }
1382
+ if (t.eventType === "reasoning") {
1383
+ let n = String(e.InvocationId || "").trim(), r = String(e.Metadata?.RuntimeItem?.Operation || "").toLowerCase(), i = !!(t.itemId && g?.itemId === t.itemId && g?.runId === t.runId && g?.scopeId === t.scopeId), a = !!(!t.itemId && !g?.itemId && n && g?.invocationId === n);
1384
+ if (g && (i || a)) {
1385
+ g.reasoning = r === "replace" || r === "completed" ? t.reasoning : `${g.reasoning || ""}${t.reasoning || ""}`, g.timestamp = t.timestamp;
1386
+ continue;
1387
+ }
1388
+ y(), g = {
1389
+ ...t,
1390
+ ...n ? { invocationId: n } : {}
1391
+ };
1392
+ continue;
1393
+ }
1394
+ let r = t.eventType === "assistant_message" || t.eventType === "assistant_stream_snapshot";
1395
+ if (r && g) {
1396
+ let n = String(e.InvocationId || "").trim(), r = Z(n, t);
1397
+ if (t.eventType === "assistant_message" && n && a.has(r)) {
1398
+ g = null;
1399
+ continue;
1400
+ }
1401
+ t.eventType === "assistant_message" && n && a.add(r), v({
1402
+ ...t,
1403
+ ...b(n, t.eventType === "assistant_message" ? "completed" : ""),
1404
+ reasoning: De(g.reasoning, t.reasoning)
1405
+ }), g = null;
1406
+ continue;
1407
+ }
1408
+ if (y(), r) {
1409
+ let n = String(e.InvocationId || "").trim(), r = Z(n, t);
1410
+ if (t.eventType === "assistant_message" && n && a.has(r)) continue;
1411
+ t.eventType === "assistant_message" && n && a.add(r), v({
1412
+ ...t,
1413
+ ...b(n, t.eventType === "assistant_message" ? "completed" : "")
1414
+ });
1415
+ continue;
1416
+ }
1417
+ v(t);
1418
+ }
1419
+ y();
1420
+ for (let [e, n] of _.entries()) v({
1421
+ ...n,
1422
+ tools: Te(n.tools, t.get(e))
1423
+ });
1424
+ for (let [e, a] of t.entries()) {
1425
+ if (a !== "in_progress" || r.has(e) || !i.has(e)) continue;
1426
+ let t = n.get(e) || {};
1427
+ v({
1428
+ id: `run-placeholder-${e}`,
1429
+ role: "model",
1430
+ content: "",
1431
+ status: "running",
1432
+ eventType: "run_status",
1433
+ timestamp: t.Timestamp || Date.now()
1434
+ });
1435
+ }
1436
+ return p;
1437
+ }
1438
+ function Me(e = [], t = []) {
1439
+ let n = [], r = /* @__PURE__ */ new Set();
1440
+ for (let i of [...Array.isArray(e) ? e : [], ...Array.isArray(t) ? t : []]) {
1441
+ let e = String(i?.EventId || "").trim();
1442
+ if (e) {
1443
+ if (r.has(e)) continue;
1444
+ r.add(e);
1445
+ }
1446
+ n.push(i);
1447
+ }
1448
+ return n.sort((e, t) => {
1449
+ let n = Number(e?.SeqId || 0), r = Number(t?.SeqId || 0);
1450
+ return Number.isFinite(n) && Number.isFinite(r) && n !== r ? n - r : Number(e?.Timestamp || 0) - Number(t?.Timestamp || 0);
1451
+ });
1452
+ }
1453
+ function Ne(e = []) {
1454
+ return (Array.isArray(e) ? e : []).reduce((e, t) => {
1455
+ let n = Number(t.SeqId || 0);
1456
+ return Number.isFinite(n) ? Math.max(e, n) : e;
1457
+ }, 0);
1458
+ }
1459
+ function Pe(e) {
1460
+ return U.has(q(e));
1461
+ }
1462
+ //#endregion
1463
+ export { s as C, n as S, g as _, Ne as a, l as b, ue as c, se as d, ne as f, _ as g, v as h, Pe as i, H as l, S as m, ke as n, Me as o, C as p, je as r, q as s, Oe as t, T as u, h as v, c as x, y };