@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
@@ -1,22 +1,23 @@
1
- import { i as e } from "./capabilities-lJRDfRg9.js";
2
- import { n as t, t as n } from "./json-value-DnHp0582.js";
3
- import { createContext as r, useContext as i } from "react";
4
- import { create as a } from "zustand";
5
- import { jsx as o } from "react/jsx-runtime";
6
- import s from "ajv/dist/2020.js";
7
- import c from "ajv-formats";
8
- import { Catalog as l, MessageProcessor as u, createFunctionImplementation as d } from "@a2ui/web_core/v0_9";
9
- import { canonicalize as f } from "json-canonicalize";
10
- import { sha256 as ee } from "@noble/hashes/sha2.js";
11
- import { bytesToHex as te } from "@noble/hashes/utils.js";
12
- import ne from "ajv";
13
- import re from "ajv/dist/2019.js";
14
- import ie from "ajv-draft-04";
1
+ import { a as e, s as t } from "./capabilities-CHy70QGW.js";
2
+ import { S as n, b as r, f as i, s as a, y as o } from "./session-events-DvFsVXpD.js";
3
+ import { createContext as s, useContext as c } from "react";
4
+ import { create as l } from "zustand";
5
+ import { jsx as u } from "react/jsx-runtime";
6
+ import { z as d } from "zod";
7
+ import f from "ajv";
8
+ import p from "ajv/dist/2019.js";
9
+ import m from "ajv/dist/2020.js";
10
+ import h from "ajv-draft-04";
11
+ import g from "ajv-formats";
12
+ import { canonicalize as ee } from "json-canonicalize";
13
+ import { sha256 as te } from "@noble/hashes/sha2.js";
14
+ import { bytesToHex as ne } from "@noble/hashes/utils.js";
15
+ import { Catalog as _, MessageProcessor as re, createFunctionImplementation as ie } from "@a2ui/web_core/v0_9";
15
16
  //#region src/stores/ui.ts
16
- function p(e, t) {
17
+ function ae(e, t) {
17
18
  return typeof t == "function" ? t(e) : t;
18
19
  }
19
- var ae = a()((e) => ({
20
+ var oe = l()((e) => ({
20
21
  sidebarOpen: !0,
21
22
  mobileSidebarOpen: !1,
22
23
  mobileActionsOpen: !1,
@@ -39,10 +40,10 @@ var ae = a()((e) => ({
39
40
  setWorkspacePanelWidth: (t) => e({ workspacePanelWidth: t }),
40
41
  setWorkspacePanelFullscreen: (t) => e({ workspacePanelFullscreen: t }),
41
42
  setInput: (t) => e({ input: t }),
42
- setAttachments: (t) => e((e) => ({ attachments: p(e.attachments, t) })),
43
+ setAttachments: (t) => e((e) => ({ attachments: ae(e.attachments, t) })),
43
44
  setPreviewAttachment: (t) => e({ previewAttachment: t }),
44
45
  setPreviewImageSize: (t) => e({ previewImageSize: t }),
45
- setQueuedDrafts: (t) => e((e) => ({ queuedDrafts: p(e.queuedDrafts, t) })),
46
+ setQueuedDrafts: (t) => e((e) => ({ queuedDrafts: ae(e.queuedDrafts, t) })),
46
47
  pushToast: (t, n = "info") => e((e) => ({ toasts: [...e.toasts, {
47
48
  id: String(Date.now() + Math.random()),
48
49
  message: t,
@@ -50,14 +51,14 @@ var ae = a()((e) => ({
50
51
  createdAt: Date.now()
51
52
  }] })),
52
53
  dismissToast: (t) => e((e) => ({ toasts: e.toasts.filter((e) => e.id !== t) }))
53
- })), m = (e) => Object.keys(e).length > 0, h = {
54
+ })), v = (e) => Object.keys(e).length > 0, se = {
54
55
  runId: null,
55
56
  status: null,
56
57
  items: []
57
- }, g = new t(), _ = (e, t) => {
58
+ }, y = new n(), b = (e, t) => {
58
59
  let n = { ...e };
59
60
  return delete n[t], n;
60
- }, oe = a()((e, n) => ({
61
+ }, ce = l()((e, t) => ({
61
62
  isStreaming: !1,
62
63
  currentRunId: "",
63
64
  stopRequested: !1,
@@ -67,7 +68,7 @@ var ae = a()((e) => ({
67
68
  banner: null,
68
69
  lastSeqId: 0,
69
70
  activeInvocationId: "",
70
- runtimeItems: h,
71
+ runtimeItems: se,
71
72
  setStreaming: (t) => e({ isStreaming: t }),
72
73
  setBanner: (t) => e({ banner: t ? {
73
74
  ...t,
@@ -76,22 +77,22 @@ var ae = a()((e) => ({
76
77
  setLastSeqId: (t) => e({ lastSeqId: t }),
77
78
  setActiveInvocationId: (t) => e({ activeInvocationId: t }),
78
79
  setSessionStreaming: (t, n) => e((e) => {
79
- let r = String(t || ""), i = _(e.sessionStreaming, r), a = n ? {
80
+ let r = String(t || ""), i = b(e.sessionStreaming, r), a = n ? {
80
81
  ...i,
81
82
  [r]: !0
82
83
  } : i;
83
84
  return {
84
85
  sessionStreaming: a,
85
- isStreaming: m(a)
86
+ isStreaming: v(a)
86
87
  };
87
88
  }),
88
89
  isSessionStreaming: (e) => {
89
- let t = String(e || "");
90
- return !!n().sessionStreaming[t];
90
+ let n = String(e || "");
91
+ return !!t().sessionStreaming[n];
91
92
  },
92
93
  getSessionActivity: (e) => {
93
- let t = String(e || "");
94
- return t && n().sessionActivities[t] || null;
94
+ let n = String(e || "");
95
+ return n && t().sessionActivities[n] || null;
95
96
  },
96
97
  setCurrentRunId: (t) => e({ currentRunId: t }),
97
98
  requestStop: () => e({ stopRequested: !0 }),
@@ -129,7 +130,7 @@ var ae = a()((e) => ({
129
130
  eventCount: t.countEvent === !1 ? 0 : 1
130
131
  };
131
132
  return n ? {
132
- isStreaming: m(e.sessionStreaming),
133
+ isStreaming: v(e.sessionStreaming),
133
134
  sessionActivities: {
134
135
  ...e.sessionActivities,
135
136
  [n]: i
@@ -162,9 +163,9 @@ var ae = a()((e) => ({
162
163
  }, s = {
163
164
  ...e.sessionActivities,
164
165
  [i]: o
165
- }, c = _(e.sessionStreaming, i);
166
+ }, c = b(e.sessionStreaming, i);
166
167
  return {
167
- isStreaming: m(c),
168
+ isStreaming: v(c),
168
169
  ...r ? {
169
170
  activity: o,
170
171
  stopRequested: !0
@@ -177,19 +178,19 @@ var ae = a()((e) => ({
177
178
  clearSessionActivity: (t) => e((e) => {
178
179
  let n = String(t || "");
179
180
  if (!n) return {};
180
- let { [n]: r, ...i } = e.sessionActivities, a = _(e.sessionStreaming, n);
181
+ let { [n]: r, ...i } = e.sessionActivities, a = b(e.sessionStreaming, n);
181
182
  return {
182
183
  sessionActivities: i,
183
184
  sessionStreaming: a,
184
- isStreaming: m(a),
185
+ isStreaming: v(a),
185
186
  activity: e.activity === r ? null : e.activity
186
187
  };
187
188
  }),
188
189
  applyRuntimeItemOperations: (t) => {
189
- g.applyAll(t), e({ runtimeItems: g.snapshot() });
190
+ y.applyAll(t), e({ runtimeItems: y.snapshot() });
190
191
  },
191
192
  resetRun: () => {
192
- g = new t(), e({
193
+ y = new n(), e({
193
194
  isStreaming: !1,
194
195
  currentRunId: "",
195
196
  stopRequested: !1,
@@ -198,13 +199,13 @@ var ae = a()((e) => ({
198
199
  sessionStreaming: {},
199
200
  lastSeqId: 0,
200
201
  activeInvocationId: "",
201
- runtimeItems: h
202
+ runtimeItems: se
202
203
  });
203
204
  }
204
205
  }));
205
206
  //#endregion
206
207
  //#region src/stores/model.ts
207
- function se(e, t) {
208
+ function le(e, t) {
208
209
  let n = /* @__PURE__ */ new Map();
209
210
  for (let t of e) t?.id && n.set(t.id, t);
210
211
  for (let e of t) e?.id && n.set(e.id, {
@@ -213,13 +214,13 @@ function se(e, t) {
213
214
  });
214
215
  return Array.from(n.values()).sort((e, t) => e.id.localeCompare(t.id));
215
216
  }
216
- var v = a()((e) => ({
217
+ var ue = l()((e) => ({
217
218
  availableModels: [],
218
219
  selectedModel: "",
219
220
  modelSource: "",
220
221
  modelCatalogLoaded: !1,
221
222
  thinkingMode: "auto",
222
- upsertModels: (t) => e((e) => ({ availableModels: se(e.availableModels, t) })),
223
+ upsertModels: (t) => e((e) => ({ availableModels: le(e.availableModels, t) })),
223
224
  setSelectedModel: (t) => e({ selectedModel: t }),
224
225
  setModelSource: (t) => e({ modelSource: t }),
225
226
  setModelCatalogLoaded: (t) => e({ modelCatalogLoaded: t }),
@@ -230,7 +231,7 @@ var v = a()((e) => ({
230
231
  modelSource: "",
231
232
  modelCatalogLoaded: !1
232
233
  })
233
- })), y = new class {
234
+ })), x = new class {
234
235
  initialized = !1;
235
236
  scope;
236
237
  blocked = !1;
@@ -250,7 +251,7 @@ var v = a()((e) => ({
250
251
  }();
251
252
  //#endregion
252
253
  //#region src/utils/session-pagination.js
253
- function b(e = /* @__PURE__ */ new Set(), t = []) {
254
+ function S(e = /* @__PURE__ */ new Set(), t = []) {
254
255
  let n = new Set(e);
255
256
  for (let e of t) {
256
257
  let t = Number(e);
@@ -258,17 +259,17 @@ function b(e = /* @__PURE__ */ new Set(), t = []) {
258
259
  }
259
260
  return new Set(Array.from(n).sort((e, t) => e - t));
260
261
  }
261
- function x({ sessionsLength: e = 0, total: t = 0, page: n = 0, pageSize: r = 30, loadedPages: i = /* @__PURE__ */ new Set() } = {}) {
262
+ function de({ sessionsLength: e = 0, total: t = 0, page: n = 0, pageSize: r = 30, loadedPages: i = /* @__PURE__ */ new Set() } = {}) {
262
263
  let a = Math.max(0, Number(t) || 0), o = Math.max(0, Number(e) || 0);
263
264
  return {
264
265
  total: a,
265
266
  page: Math.max(0, Number(n) || 0),
266
267
  pageSize: Math.max(1, Number(r) || 30),
267
- loadedPages: b(i),
268
+ loadedPages: S(i),
268
269
  hasMore: o < a
269
270
  };
270
271
  }
271
- function ce({ total: e = 0, pageSize: t = 30, loadedPages: n = /* @__PURE__ */ new Set() } = {}) {
272
+ function fe({ total: e = 0, pageSize: t = 30, loadedPages: n = /* @__PURE__ */ new Set() } = {}) {
272
273
  let r = Math.max(0, Number(e) || 0), i = Math.max(1, Number(t) || 30);
273
274
  if (r <= 0) return null;
274
275
  let a = Math.ceil(r / i);
@@ -277,7 +278,7 @@ function ce({ total: e = 0, pageSize: t = 30, loadedPages: n = /* @__PURE__ */ n
277
278
  }
278
279
  //#endregion
279
280
  //#region src/stores/session.ts
280
- function S(e) {
281
+ function pe(e) {
281
282
  let t = e.UpdatedAt;
282
283
  if (typeof t == "string") {
283
284
  let e = Date.parse(t);
@@ -285,37 +286,37 @@ function S(e) {
285
286
  }
286
287
  return typeof t == "number" && Number.isFinite(t) ? t > 1e11 ? t : t * 1e3 : 0;
287
288
  }
288
- var C = "ksadk.pinnedSessionIds";
289
- function w() {
289
+ var me = "ksadk.pinnedSessionIds";
290
+ function he() {
290
291
  try {
291
- let e = globalThis.localStorage?.getItem(y.key(C)), t = e ? JSON.parse(e) : [];
292
+ let e = globalThis.localStorage?.getItem(x.key(me)), t = e ? JSON.parse(e) : [];
292
293
  return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
293
294
  } catch {
294
295
  return [];
295
296
  }
296
297
  }
297
- function le(e) {
298
- if (y.writable) try {
299
- globalThis.localStorage?.setItem(y.key(C), JSON.stringify(e));
298
+ function ge(e) {
299
+ if (x.writable) try {
300
+ globalThis.localStorage?.setItem(x.key(me), JSON.stringify(e));
300
301
  } catch {}
301
302
  }
302
- function T(e, t) {
303
+ function C(e, t) {
303
304
  let n = new Set(t);
304
305
  return e.slice().sort((e, t) => {
305
306
  let r = +!!n.has(e.SessionId), i = +!!n.has(t.SessionId);
306
- return r === i ? S(t) - S(e) : i - r;
307
+ return r === i ? pe(t) - pe(e) : i - r;
307
308
  });
308
309
  }
309
- function ue(e, t, n) {
310
+ function _e(e, t, n) {
310
311
  let r = /* @__PURE__ */ new Map();
311
312
  for (let t of e) t?.SessionId && r.set(t.SessionId, t);
312
313
  for (let e of t) e?.SessionId && r.set(e.SessionId, {
313
314
  ...r.get(e.SessionId) || {},
314
315
  ...e
315
316
  });
316
- return T(Array.from(r.values()), n);
317
+ return C(Array.from(r.values()), n);
317
318
  }
318
- var de = a()((e) => ({
319
+ var ve = l()((e) => ({
319
320
  sessions: [],
320
321
  currentSessionId: null,
321
322
  sessionsAgentId: "",
@@ -326,12 +327,12 @@ var de = a()((e) => ({
326
327
  loadedPages: /* @__PURE__ */ new Set(),
327
328
  hasMoreSessions: !1,
328
329
  isLoadingSessions: !0,
329
- pinnedSessionIds: w(),
330
+ pinnedSessionIds: he(),
330
331
  messageHistory: {},
331
- setSessions: (t) => e((e) => ({ sessions: T(t, e.pinnedSessionIds) })),
332
+ setSessions: (t) => e((e) => ({ sessions: C(t, e.pinnedSessionIds) })),
332
333
  setCurrentSessionId: (t) => e({ currentSessionId: t }),
333
334
  upsertSessions: (t, n) => e((e) => {
334
- let r = ue(n?.replace ? [] : e.sessions, t, e.pinnedSessionIds), i = n?.page ?? e.sessionsPage, a = n?.pageSize ?? e.sessionsPageSize, o = n?.total ?? Math.max(e.sessionsTotal, r.length), s = n?.replace ? b(/* @__PURE__ */ new Set(), [i]) : b(e.loadedPages, [i]), c = x({
335
+ let r = _e(n?.replace ? [] : e.sessions, t, e.pinnedSessionIds), i = n?.page ?? e.sessionsPage, a = n?.pageSize ?? e.sessionsPageSize, o = n?.total ?? Math.max(e.sessionsTotal, r.length), s = n?.replace ? S(/* @__PURE__ */ new Set(), [i]) : S(e.loadedPages, [i]), c = de({
335
336
  sessionsLength: r.length,
336
337
  total: o,
337
338
  page: i,
@@ -353,7 +354,7 @@ var de = a()((e) => ({
353
354
  return {
354
355
  sessions: n,
355
356
  sessionsTotal: r,
356
- hasMoreSessions: x({
357
+ hasMoreSessions: de({
357
358
  sessionsLength: n.length,
358
359
  total: r,
359
360
  page: e.sessionsPage,
@@ -378,9 +379,9 @@ var de = a()((e) => ({
378
379
  let n = new Set(e.pinnedSessionIds);
379
380
  n.has(t) ? n.delete(t) : n.add(t);
380
381
  let r = Array.from(n);
381
- return le(r), {
382
+ return ge(r), {
382
383
  pinnedSessionIds: r,
383
- sessions: T(e.sessions, r)
384
+ sessions: C(e.sessions, r)
384
385
  };
385
386
  }),
386
387
  setSessionMessageHistory: (t, n) => e((e) => ({ messageHistory: {
@@ -422,7 +423,91 @@ var de = a()((e) => ({
422
423
  let n = { ...e.messageHistory };
423
424
  return delete n[t], { messageHistory: n };
424
425
  })
425
- })), fe = a()((t) => ({
426
+ })), ye = "ksadk.web.execution-permission", be = [
427
+ "read-only",
428
+ "workspace-write",
429
+ "danger-full-access"
430
+ ], xe = {
431
+ "read-only": "只读",
432
+ "workspace-write": "工作区可写",
433
+ "danger-full-access": "完全访问"
434
+ }, Se = {
435
+ "read-only": "只读",
436
+ "workspace-write": "工作区可写",
437
+ "danger-full-access": "完全访问"
438
+ }, Ce = {
439
+ "read-only": "只读文件与命令",
440
+ "workspace-write": "可修改工作区文件",
441
+ "danger-full-access": "不再限制文件与命令"
442
+ };
443
+ function w(e) {
444
+ if (!e || !Array.isArray(e.Modes)) return [];
445
+ let t = e.Modes.filter((e) => be.includes(e));
446
+ return [...new Set(t)];
447
+ }
448
+ function we(e, t) {
449
+ let n = w(e);
450
+ if (n.length === 0) return;
451
+ if (t && n.includes(t)) return t;
452
+ let r = e?.DefaultMode;
453
+ return r && n.includes(r) ? r : n[0];
454
+ }
455
+ function Te(e) {
456
+ return e && be.includes(e) ? { permission_mode: e } : {};
457
+ }
458
+ function T(e) {
459
+ return x.key(`${ye}.${e}`);
460
+ }
461
+ function Ee(e) {
462
+ try {
463
+ return globalThis.localStorage?.getItem(T(e)) ?? null;
464
+ } catch {
465
+ return null;
466
+ }
467
+ }
468
+ function De(e, t) {
469
+ if (x.writable) try {
470
+ t ? globalThis.localStorage?.setItem(T(e), t) : globalThis.localStorage?.removeItem(T(e));
471
+ } catch {}
472
+ }
473
+ var Oe = l()((e, t) => ({
474
+ byAgent: {},
475
+ policies: {},
476
+ scopes: {},
477
+ configure: (n, r) => {
478
+ if (!n || x.blocked) return;
479
+ let i = T(n), a = Ee(n), o = t().scopes[n] === i ? t().byAgent[n] : void 0, s = {
480
+ Modes: w(r),
481
+ DefaultMode: r?.DefaultMode
482
+ }, c = we(s, o ?? a);
483
+ c !== a && De(n, c ?? null), e((e) => ({
484
+ byAgent: {
485
+ ...e.byAgent,
486
+ [n]: c
487
+ },
488
+ policies: {
489
+ ...e.policies,
490
+ [n]: s
491
+ },
492
+ scopes: {
493
+ ...e.scopes,
494
+ [n]: i
495
+ }
496
+ }));
497
+ },
498
+ select: (n, r) => {
499
+ !n || x.blocked || t().scopes[n] !== T(n) || !w(t().policies[n]).includes(r) || (De(n, r), e((e) => ({ byAgent: {
500
+ ...e.byAgent,
501
+ [n]: r
502
+ } })));
503
+ },
504
+ modeFor: (e) => {
505
+ let n = t();
506
+ if (x.blocked || n.scopes[e] !== T(e)) return;
507
+ let r = n.byAgent[e];
508
+ return r && w(n.policies[e]).includes(r) ? r : void 0;
509
+ }
510
+ })), ke = l()((t, n) => ({
426
511
  agentId: "default-agent",
427
512
  agentName: "Agent",
428
513
  agentFramework: "",
@@ -435,7 +520,9 @@ var de = a()((e) => ({
435
520
  setAgentId: (e) => t({ agentId: e }),
436
521
  setAgentName: (e) => t({ agentName: e }),
437
522
  setAgentFramework: (e) => t({ agentFramework: e }),
438
- setCapabilities: (e) => t({ capabilities: e }),
523
+ setCapabilities: (e) => {
524
+ Oe.getState().configure(n().agentId, e.ExecutionPolicy), t({ capabilities: e });
525
+ },
439
526
  setApiFormats: (e) => t({ apiFormats: e }),
440
527
  setAccessMode: (e) => t({ accessMode: e }),
441
528
  setWorkspaceFiles: (e) => t({ workspaceFiles: e }),
@@ -443,7 +530,1065 @@ var de = a()((e) => ({
443
530
  status: e,
444
531
  errorMessage: n
445
532
  })
446
- })), E = {
533
+ })), Ae = new Set([
534
+ "resolved",
535
+ "cancelled",
536
+ "expired"
537
+ ]);
538
+ function E(e) {
539
+ return Ae.has(e);
540
+ }
541
+ function je(e, t) {
542
+ return `interaction:${e}:revision-${t}`;
543
+ }
544
+ function Me(e, t) {
545
+ if (typeof t != "object" || !t || Array.isArray(t)) return e === "cancel" ? "已取消" : "已提交";
546
+ let n = t.approved;
547
+ if (typeof n == "boolean") return n ? "已同意" : "已拒绝";
548
+ let r = Object.keys(t);
549
+ return r.length === 0 ? e === "approve" ? "已同意" : e === "reject" ? "已拒绝" : e === "cancel" ? "已取消" : "已提交" : `${e}(${r.slice(0, 3).map((e) => {
550
+ let n = t[e];
551
+ return `${e}=${typeof n == "string" ? n.length > 24 ? `${n.slice(0, 24)}…` : n : typeof n == "object" && n ? "[object]" : String(n)}`;
552
+ }).join(", ")})`;
553
+ }
554
+ //#endregion
555
+ //#region src/core/interaction/store.ts
556
+ var D = class {
557
+ records = /* @__PURE__ */ new Map();
558
+ terminalRuns = /* @__PURE__ */ new Set();
559
+ rejectedCommands = /* @__PURE__ */ new Map();
560
+ listeners = /* @__PURE__ */ new Set();
561
+ key(e, t) {
562
+ return `${e}\u0000${t}`;
563
+ }
564
+ runKey(e, t) {
565
+ return `${e}\u0000${t}`;
566
+ }
567
+ subscribe(e) {
568
+ return this.listeners.add(e), () => {
569
+ this.listeners.delete(e);
570
+ };
571
+ }
572
+ emit(e) {
573
+ for (let t of this.listeners) t(e);
574
+ }
575
+ get(e, t) {
576
+ return this.records.get(this.key(e, t)) || null;
577
+ }
578
+ listPending(e) {
579
+ return this.listAll(e).filter((e) => e.status === "pending");
580
+ }
581
+ listAll(e) {
582
+ return this.all().filter((t) => t.sessionId === e);
583
+ }
584
+ all() {
585
+ return [...this.records.values()].sort((e, t) => String(e.createdAt).localeCompare(String(t.createdAt)));
586
+ }
587
+ upsert(e) {
588
+ let t = this.get(e.sessionId, e.interactionId);
589
+ e.runId && !E(e.status) && !E(t?.status ?? "pending") && this.terminalRuns.has(this.runKey(e.sessionId, e.runId)) && (e = {
590
+ ...e,
591
+ status: "expired",
592
+ outcome: "expired",
593
+ resolvedAt: e.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
594
+ responseSummary: e.responseSummary ?? "运行已结束"
595
+ });
596
+ let n, r;
597
+ return t ? E(t.status) && !E(e.status) ? (n = {
598
+ ...t,
599
+ title: ["人工确认", "补充信息"].includes(t.title) ? e.title : t.title,
600
+ message: ["本次运行需要人工处理后才能继续。", "请填写后提交,Agent 将继续当前任务。"].includes(t.message) ? e.message : t.message,
601
+ kind: t.kind === "approval" && !t.requestSchema ? e.kind : t.kind,
602
+ requestSchema: t.requestSchema ?? e.requestSchema,
603
+ presentation: t.presentation ?? e.presentation
604
+ }, r = {
605
+ type: "interaction_updated",
606
+ interaction: n
607
+ }) : e.revision < t.revision || e.revision === t.revision && E(t.status) && !E(e.status) || t.status === "failed" && t.extensions.rejected_command_id && e.revision === t.revision && !E(e.status) || t.status === "resolving" && !E(e.status) ? (n = t, r = {
608
+ type: "interaction_updated",
609
+ interaction: n
610
+ }) : E(e.status) ? (n = {
611
+ ...t,
612
+ ...e,
613
+ title: t.title || e.title,
614
+ kind: t.kind || e.kind,
615
+ message: t.message || e.message,
616
+ runId: e.runId ?? t.runId,
617
+ requestSchema: t.requestSchema ?? e.requestSchema,
618
+ presentation: t.presentation ?? e.presentation,
619
+ actor: e.actor ?? t.actor,
620
+ outcome: e.outcome ?? t.outcome,
621
+ resolvedAt: e.resolvedAt ?? t.resolvedAt,
622
+ responseSummary: e.responseSummary ?? t.responseSummary,
623
+ ...Object.hasOwn(t, "response") ? { response: t.response } : {}
624
+ }, r = {
625
+ type: "interaction_resolved",
626
+ interaction: n
627
+ }) : (n = {
628
+ ...t,
629
+ ...e
630
+ }, r = {
631
+ type: "interaction_updated",
632
+ interaction: n
633
+ }) : (n = e, r = {
634
+ type: "interaction_requested",
635
+ interaction: n
636
+ }), this.records.set(this.key(n.sessionId, n.interactionId), n), this.emit(r), r;
637
+ }
638
+ markResolving(e, t) {
639
+ let n = this.get(e, t);
640
+ if (!n || !["pending", "failed"].includes(n.status)) return;
641
+ let r = { ...n.extensions };
642
+ delete r.submit_error, delete r.submit_command_id, this.records.set(this.key(e, t), {
643
+ ...n,
644
+ status: "resolving",
645
+ extensions: r
646
+ }), this.emit({
647
+ type: "interaction_updated",
648
+ interaction: this.get(e, t)
649
+ });
650
+ }
651
+ resolveLocally(e, t, n) {
652
+ let r = this.get(e, t);
653
+ if (!r) return;
654
+ let i = {
655
+ ...r,
656
+ ...n,
657
+ resolvedAt: n.resolvedAt ?? r.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
658
+ revision: n.revision ?? r.revision
659
+ };
660
+ this.records.set(this.key(e, t), i), this.emit({
661
+ type: "interaction_resolved",
662
+ interaction: i
663
+ });
664
+ }
665
+ recordCommand(e, t, n) {
666
+ let r = this.get(e, t);
667
+ if (!r || !n || E(r.status)) return;
668
+ this.records.set(this.key(e, t), {
669
+ ...r,
670
+ extensions: {
671
+ ...r.extensions,
672
+ submit_command_id: n
673
+ }
674
+ });
675
+ let i = this.rejectedCommands.get(this.key(e, n));
676
+ i && this.rejectCommand(e, n, i);
677
+ }
678
+ rejectCommand(e, t, n) {
679
+ if (!(!e || !t)) {
680
+ this.rejectedCommands.set(this.key(e, t), n);
681
+ for (let r of this.listAll(e)) {
682
+ if (r.extensions.submit_command_id !== t) continue;
683
+ this.markFailed(e, r.interactionId, {
684
+ code: n,
685
+ message: `提交未执行(${n}),请重试`,
686
+ retryable: !0
687
+ });
688
+ let i = this.get(e, r.interactionId);
689
+ i?.status === "failed" && this.records.set(this.key(e, r.interactionId), {
690
+ ...i,
691
+ extensions: {
692
+ ...i.extensions,
693
+ rejected_command_id: t
694
+ }
695
+ });
696
+ }
697
+ }
698
+ }
699
+ recordIdempotencyKey(e, t, n) {
700
+ let r = this.get(e, t);
701
+ if (!r) return;
702
+ let i = {
703
+ ...r,
704
+ extensions: {
705
+ ...r.extensions,
706
+ idempotency_key: n
707
+ }
708
+ };
709
+ this.records.set(this.key(e, t), i), this.emit({
710
+ type: "interaction_updated",
711
+ interaction: i
712
+ });
713
+ }
714
+ markFailed(e, t, n) {
715
+ let r = this.get(e, t);
716
+ if (!r || E(r.status)) return;
717
+ let i = {
718
+ ...r,
719
+ status: "failed",
720
+ extensions: {
721
+ ...r.extensions,
722
+ submit_error: n
723
+ }
724
+ };
725
+ this.records.set(this.key(e, t), i), this.emit({
726
+ type: "interaction_updated",
727
+ interaction: i
728
+ });
729
+ }
730
+ revertToPending(e, t) {
731
+ let n = this.get(e, t);
732
+ if (!n || n.status !== "resolving") return;
733
+ let r = {
734
+ ...n,
735
+ status: "pending"
736
+ };
737
+ this.records.set(this.key(e, t), r), this.emit({
738
+ type: "interaction_updated",
739
+ interaction: r
740
+ });
741
+ }
742
+ markRunTerminal(e, t) {
743
+ if (!(!e || !t)) {
744
+ this.terminalRuns.add(this.runKey(e, t));
745
+ for (let n of this.listAll(e)) {
746
+ if (n.runId !== t || E(n.status)) continue;
747
+ let r = {
748
+ ...n,
749
+ status: "expired",
750
+ outcome: "expired",
751
+ resolvedAt: n.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
752
+ responseSummary: n.responseSummary ?? "运行已结束"
753
+ };
754
+ this.records.set(this.key(e, n.interactionId), r), this.emit({
755
+ type: "interaction_resolved",
756
+ interaction: r
757
+ });
758
+ }
759
+ }
760
+ }
761
+ markSessionTerminal(e) {
762
+ if (!e) return;
763
+ let t = new Set(this.listAll(e).filter((e) => !E(e.status)).map((e) => e.runId).filter((e) => !!e));
764
+ for (let n of t) this.markRunTerminal(e, n);
765
+ for (let t of this.listAll(e)) {
766
+ if (t.runId || E(t.status)) continue;
767
+ let n = {
768
+ ...t,
769
+ status: "expired",
770
+ outcome: "expired",
771
+ resolvedAt: t.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
772
+ responseSummary: t.responseSummary ?? "运行已结束"
773
+ };
774
+ this.records.set(this.key(e, t.interactionId), n), this.emit({
775
+ type: "interaction_resolved",
776
+ interaction: n
777
+ });
778
+ }
779
+ }
780
+ remove(e, t) {
781
+ let n = this.key(e, t);
782
+ this.records.has(n) && (this.records.delete(n), this.emit({
783
+ type: "interaction_removed",
784
+ interactionId: t
785
+ }));
786
+ }
787
+ clearSession(e) {
788
+ for (let t of this.listAll(e)) this.remove(e, t.interactionId);
789
+ let t = `${e}\u0000`;
790
+ for (let e of this.rejectedCommands.keys()) e.startsWith(t) && this.rejectedCommands.delete(e);
791
+ for (let e of this.terminalRuns) e.startsWith(t) && this.terminalRuns.delete(e);
792
+ }
793
+ }, O = class extends Error {
794
+ constructor(e) {
795
+ super(e), this.name = "ContractMismatchError";
796
+ }
797
+ }, Ne = new Set([
798
+ "schema_version",
799
+ "command_id",
800
+ "status",
801
+ "message_id",
802
+ "run_id",
803
+ "accepted_seq",
804
+ "error"
805
+ ]), Pe = d.object({
806
+ code: d.string().min(1),
807
+ message: d.string(),
808
+ retryable: d.boolean(),
809
+ details: d.record(d.string(), d.unknown()).optional()
810
+ });
811
+ function Fe(e) {
812
+ if (typeof e != "object" || !e || Array.isArray(e)) return k(e);
813
+ let t = e;
814
+ if ("schema_version" in t || !("SchemaVersion" in t)) return k(e);
815
+ let n = {
816
+ SchemaVersion: "schema_version",
817
+ CommandId: "command_id",
818
+ Status: "status",
819
+ MessageId: "message_id",
820
+ RunId: "run_id",
821
+ AcceptedSeq: "accepted_seq",
822
+ Error: "error"
823
+ };
824
+ return k(Object.fromEntries(Object.entries(t).map(([e, t]) => [n[e] ?? e, t])));
825
+ }
826
+ function k(e) {
827
+ let t = d.object({
828
+ schema_version: d.literal(1),
829
+ command_id: d.string().min(1),
830
+ status: d.enum([
831
+ "accepted",
832
+ "duplicate",
833
+ "rejected",
834
+ "unsupported",
835
+ "queue_full",
836
+ "persistence_uncertain"
837
+ ]),
838
+ message_id: d.string().min(1).nullable().optional(),
839
+ run_id: d.string().min(1).nullable().optional(),
840
+ accepted_seq: d.number().int().min(0).nullable().optional(),
841
+ error: Pe.nullable().optional()
842
+ }).passthrough().safeParse(e);
843
+ if (!t.success) throw new O(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);
844
+ let n = t.data;
845
+ if ((n.status === "rejected" || n.status === "unsupported" || n.status === "queue_full" || n.status === "persistence_uncertain") && !n.error) throw new O(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);
846
+ let r = {};
847
+ for (let [e, t] of Object.entries(n)) Ne.has(e) || (r[e] = t);
848
+ let i = n.error ? {
849
+ ...n.error,
850
+ extensions: {}
851
+ } : null;
852
+ return {
853
+ schema_version: 1,
854
+ command_id: n.command_id,
855
+ status: n.status,
856
+ message_id: n.message_id ?? null,
857
+ run_id: n.run_id ?? null,
858
+ accepted_seq: n.accepted_seq ?? null,
859
+ error: i,
860
+ extensions: r
861
+ };
862
+ }
863
+ function Ie(e) {
864
+ try {
865
+ return t(e);
866
+ } catch (e) {
867
+ throw new O(`RuntimeCapabilityMatrix/v1 mismatch: ${e instanceof Error ? e.message : String(e)}`);
868
+ }
869
+ }
870
+ var Le = new Set([
871
+ "schema_version",
872
+ "event_id",
873
+ "session_id",
874
+ "seq",
875
+ "timestamp",
876
+ "family",
877
+ "family_version",
878
+ "event_type",
879
+ "payload",
880
+ "run_id",
881
+ "causation_id",
882
+ "correlation_id",
883
+ "actor_ref"
884
+ ]), Re = new Map([["control", 1], ["runtime", 2]]), ze = {
885
+ schema_version: ["schemaVersion", "SchemaVersion"],
886
+ event_id: ["eventId", "EventId"],
887
+ session_id: ["sessionId", "SessionId"],
888
+ seq: [
889
+ "seqId",
890
+ "SeqId",
891
+ "Seq"
892
+ ],
893
+ timestamp: ["Timestamp"],
894
+ family: ["Family"],
895
+ family_version: ["familyVersion", "FamilyVersion"],
896
+ event_type: ["eventType", "EventType"],
897
+ payload: ["Payload"],
898
+ run_id: ["runId", "RunId"],
899
+ causation_id: ["causationId", "CausationId"],
900
+ correlation_id: ["correlationId", "CorrelationId"],
901
+ actor_ref: ["actorRef", "ActorRef"]
902
+ };
903
+ function Be(e) {
904
+ if (!e || typeof e != "object" || Array.isArray(e)) return e;
905
+ let t = e, n = { ...t };
906
+ for (let [e, r] of Object.entries(ze)) {
907
+ if (n[e] === void 0) {
908
+ let i = r.find((e) => t[e] !== void 0);
909
+ i && (n[e] = t[i]);
910
+ }
911
+ for (let e of r) delete n[e];
912
+ }
913
+ return n;
914
+ }
915
+ var Ve = d.object({
916
+ schema_version: d.literal(1),
917
+ event_id: d.string().min(1),
918
+ session_id: d.string().min(1),
919
+ seq: d.number().int().min(0),
920
+ timestamp: d.string().min(1),
921
+ family: d.string().min(1),
922
+ family_version: d.number().int().min(1),
923
+ event_type: d.string().min(1),
924
+ payload: d.record(d.string(), d.unknown()),
925
+ run_id: d.string().min(1).nullable().optional(),
926
+ causation_id: d.string().min(1).nullable().optional(),
927
+ correlation_id: d.string().min(1).nullable().optional(),
928
+ actor_ref: d.string().min(1).nullable().optional()
929
+ }).passthrough();
930
+ function He(e) {
931
+ let t = Ve.safeParse(Be(e));
932
+ if (!t.success) return {
933
+ ok: !1,
934
+ error: new O(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)
935
+ };
936
+ let n = t.data, r = Re.get(n.family);
937
+ if (r !== void 0 && n.family_version !== r) return {
938
+ ok: !1,
939
+ error: new O(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)
940
+ };
941
+ let i = {};
942
+ for (let [e, t] of Object.entries(n)) Le.has(e) || (i[e] = t);
943
+ return {
944
+ ok: !0,
945
+ value: {
946
+ schema_version: 1,
947
+ event_id: n.event_id,
948
+ session_id: n.session_id,
949
+ seq: n.seq,
950
+ timestamp: n.timestamp,
951
+ family: n.family,
952
+ family_version: n.family_version,
953
+ event_type: n.event_type,
954
+ payload: n.payload,
955
+ run_id: n.run_id ?? null,
956
+ causation_id: n.causation_id ?? null,
957
+ correlation_id: n.correlation_id ?? null,
958
+ actor_ref: n.actor_ref ?? null,
959
+ extensions: i
960
+ }
961
+ };
962
+ }
963
+ function Ue(e) {
964
+ let t = d.object({
965
+ schema_version: d.literal(1),
966
+ agent_instance_id: d.string().min(1),
967
+ instance_state: d.enum([
968
+ "ready",
969
+ "degraded",
970
+ "unavailable"
971
+ ]),
972
+ session_id: d.string().min(1).nullable().optional(),
973
+ active_run_id: d.string().min(1).nullable().optional(),
974
+ active_run_state: d.enum([
975
+ "pending",
976
+ "running",
977
+ "paused",
978
+ "waiting"
979
+ ]).nullable().optional(),
980
+ inbox_depth: d.number().int().min(0),
981
+ activation_id: d.string().min(1).nullable().optional(),
982
+ lease_expires_at: d.string().min(1).nullable().optional(),
983
+ capability: d.unknown()
984
+ }).passthrough().safeParse(e);
985
+ if (!t.success) throw new O(`AgentStatusSnapshot/v1 mismatch: ${t.error.message}`);
986
+ let n = t.data, r = {};
987
+ for (let e of Object.keys(n)) [
988
+ "schema_version",
989
+ "agent_instance_id",
990
+ "instance_state",
991
+ "session_id",
992
+ "active_run_id",
993
+ "active_run_state",
994
+ "inbox_depth",
995
+ "activation_id",
996
+ "lease_expires_at",
997
+ "capability"
998
+ ].includes(e) || (r[e] = n[e]);
999
+ return {
1000
+ schema_version: 1,
1001
+ agent_instance_id: n.agent_instance_id,
1002
+ instance_state: n.instance_state,
1003
+ session_id: n.session_id ?? null,
1004
+ active_run_id: n.active_run_id ?? null,
1005
+ active_run_state: n.active_run_state ?? null,
1006
+ inbox_depth: n.inbox_depth,
1007
+ activation_id: n.activation_id ?? null,
1008
+ lease_expires_at: n.lease_expires_at ?? null,
1009
+ capability: Ie(n.capability),
1010
+ extensions: r
1011
+ };
1012
+ }
1013
+ var We = {
1014
+ $schema: "http://json-schema.org/draft-06/schema#",
1015
+ $id: "http://json-schema.org/draft-06/schema#",
1016
+ title: "Core schema meta-schema",
1017
+ definitions: {
1018
+ schemaArray: {
1019
+ type: "array",
1020
+ minItems: 1,
1021
+ items: { $ref: "#" }
1022
+ },
1023
+ nonNegativeInteger: {
1024
+ type: "integer",
1025
+ minimum: 0
1026
+ },
1027
+ nonNegativeIntegerDefault0: { allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] },
1028
+ simpleTypes: { enum: [
1029
+ "array",
1030
+ "boolean",
1031
+ "integer",
1032
+ "null",
1033
+ "number",
1034
+ "object",
1035
+ "string"
1036
+ ] },
1037
+ stringArray: {
1038
+ type: "array",
1039
+ items: { type: "string" },
1040
+ uniqueItems: !0,
1041
+ default: []
1042
+ }
1043
+ },
1044
+ type: ["object", "boolean"],
1045
+ properties: {
1046
+ $id: {
1047
+ type: "string",
1048
+ format: "uri-reference"
1049
+ },
1050
+ $schema: {
1051
+ type: "string",
1052
+ format: "uri"
1053
+ },
1054
+ $ref: {
1055
+ type: "string",
1056
+ format: "uri-reference"
1057
+ },
1058
+ title: { type: "string" },
1059
+ description: { type: "string" },
1060
+ default: {},
1061
+ examples: {
1062
+ type: "array",
1063
+ items: {}
1064
+ },
1065
+ multipleOf: {
1066
+ type: "number",
1067
+ exclusiveMinimum: 0
1068
+ },
1069
+ maximum: { type: "number" },
1070
+ exclusiveMaximum: { type: "number" },
1071
+ minimum: { type: "number" },
1072
+ exclusiveMinimum: { type: "number" },
1073
+ maxLength: { $ref: "#/definitions/nonNegativeInteger" },
1074
+ minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1075
+ pattern: {
1076
+ type: "string",
1077
+ format: "regex"
1078
+ },
1079
+ additionalItems: { $ref: "#" },
1080
+ items: {
1081
+ anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }],
1082
+ default: {}
1083
+ },
1084
+ maxItems: { $ref: "#/definitions/nonNegativeInteger" },
1085
+ minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1086
+ uniqueItems: {
1087
+ type: "boolean",
1088
+ default: !1
1089
+ },
1090
+ contains: { $ref: "#" },
1091
+ maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
1092
+ minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1093
+ required: { $ref: "#/definitions/stringArray" },
1094
+ additionalProperties: { $ref: "#" },
1095
+ definitions: {
1096
+ type: "object",
1097
+ additionalProperties: { $ref: "#" },
1098
+ default: {}
1099
+ },
1100
+ properties: {
1101
+ type: "object",
1102
+ additionalProperties: { $ref: "#" },
1103
+ default: {}
1104
+ },
1105
+ patternProperties: {
1106
+ type: "object",
1107
+ additionalProperties: { $ref: "#" },
1108
+ default: {}
1109
+ },
1110
+ dependencies: {
1111
+ type: "object",
1112
+ additionalProperties: { anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] }
1113
+ },
1114
+ propertyNames: { $ref: "#" },
1115
+ const: {},
1116
+ enum: {
1117
+ type: "array",
1118
+ minItems: 1,
1119
+ uniqueItems: !0
1120
+ },
1121
+ type: { anyOf: [{ $ref: "#/definitions/simpleTypes" }, {
1122
+ type: "array",
1123
+ items: { $ref: "#/definitions/simpleTypes" },
1124
+ minItems: 1,
1125
+ uniqueItems: !0
1126
+ }] },
1127
+ format: { type: "string" },
1128
+ allOf: { $ref: "#/definitions/schemaArray" },
1129
+ anyOf: { $ref: "#/definitions/schemaArray" },
1130
+ oneOf: { $ref: "#/definitions/schemaArray" },
1131
+ not: { $ref: "#" }
1132
+ },
1133
+ default: {}
1134
+ }, A = /* @__PURE__ */ new Map();
1135
+ function j(e) {
1136
+ r(e);
1137
+ let t = JSON.stringify(e), n = A.get(t);
1138
+ if (n) return n;
1139
+ let i = String(e.$schema || "https://json-schema.org/draft/2020-12/schema"), a = {
1140
+ strict: !1,
1141
+ allErrors: !0,
1142
+ coerceTypes: !1,
1143
+ useDefaults: !1,
1144
+ removeAdditional: !1,
1145
+ ownProperties: !0,
1146
+ logger: !1
1147
+ }, o = /draft-04/.test(i) ? new h(a) : /draft-0[67]/.test(i) ? new f(a) : /2019-09/.test(i) ? new p(a) : /2020-12/.test(i) ? new m(a) : null;
1148
+ if (!o) throw TypeError("Unsupported JSON Schema dialect");
1149
+ /draft-06/.test(i) && o.addMetaSchema(We), g(o);
1150
+ let s = o.compile(e);
1151
+ if ("$async" in s && s.$async) throw TypeError("Async schemas are not supported");
1152
+ A.size >= 128 && A.delete(A.keys().next().value);
1153
+ let c = typeof e.$id == "string" ? e.$id.replace(/#$/, "") : typeof e.id == "string" ? e.id.replace(/#$/, "") : "", l = {
1154
+ root: s,
1155
+ at: (e, t) => !!(e === "" ? s : o.getSchema(`${c}#${e}`))?.(t)
1156
+ };
1157
+ return A.set(t, l), l;
1158
+ }
1159
+ function Ge(e) {
1160
+ return j(e).at;
1161
+ }
1162
+ function Ke(e, t) {
1163
+ try {
1164
+ r(t);
1165
+ let n = j(e).root, i = n(t);
1166
+ return {
1167
+ valid: !!i,
1168
+ issues: i ? [] : (n.errors || []).slice(0, 10).map((e) => `${e.instancePath || "/"}:不符合 ${e.keyword} 约束`)
1169
+ };
1170
+ } catch {
1171
+ return {
1172
+ valid: !1,
1173
+ issues: ["输入或表单约束不是受支持的 JSON。"]
1174
+ };
1175
+ }
1176
+ }
1177
+ //#endregion
1178
+ //#region src/core/interaction/form-values.ts
1179
+ var M = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, qe = (e, t) => Object.hasOwn(e, t) ? e[t] : void 0, Je = (e) => e.replace(/~/g, "~0").replace(/\//g, "~1"), Ye = /^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u;
1180
+ function Xe(e) {
1181
+ let [t, n = "0"] = e.toLowerCase().split("e"), [r, i = ""] = t.replace(/^-/, "").split("."), a = (r + i).replace(/^0+/, "").replace(/0+$/, "");
1182
+ if (!a) return "0";
1183
+ let o = (r + i).length - (r + i).replace(/0+$/, "").length;
1184
+ return `${e.startsWith("-") ? "-" : ""}${a}e${Number(n) - i.length + o}`;
1185
+ }
1186
+ function Ze(e, t) {
1187
+ if (typeof e != "string") return e;
1188
+ if (t.includes("boolean") && (e === "true" || e === "false")) return e === "true";
1189
+ if (!t.some((e) => e === "number" || e === "integer") || e.length > 1024 || !Ye.test(e)) return e;
1190
+ let n = Number(e);
1191
+ return !Number.isFinite(n) || Xe(e) !== Xe(JSON.stringify(n)) || !t.includes("number") && !Number.isSafeInteger(n) ? e : n === 0 ? 0 : n;
1192
+ }
1193
+ function Qe(e, t) {
1194
+ let n = r(t), i = Ge(e), a = 0, o = (e, t) => {
1195
+ try {
1196
+ return i(e, t);
1197
+ } catch {
1198
+ return !1;
1199
+ }
1200
+ }, s = (t) => {
1201
+ if (typeof t != "string" || !t.startsWith("#")) return;
1202
+ let n;
1203
+ try {
1204
+ n = decodeURIComponent(t.slice(1));
1205
+ } catch {
1206
+ return;
1207
+ }
1208
+ if (n !== "" && !n.startsWith("/")) return;
1209
+ let r = e;
1210
+ for (let e of n === "" ? [] : n.slice(1).split("/")) {
1211
+ let t = e.replace(/~1/g, "/").replace(/~0/g, "~");
1212
+ r = Array.isArray(r) ? r[Number(t)] : M(r) ? qe(r, t) : void 0;
1213
+ }
1214
+ return {
1215
+ node: r,
1216
+ path: n
1217
+ };
1218
+ }, c = (e, t, n, r = 0) => {
1219
+ let i = M(e);
1220
+ if (++a > 8192 || r > 48 || !i || o(t, n)) return n;
1221
+ let l = n, u = s(i.$ref);
1222
+ u && (n = c(u.node, u.path, n, r + 1)), Array.isArray(i.allOf) && i.allOf.forEach((e, i) => {
1223
+ n = c(e, `${t}/allOf/${i}`, n, r + 1);
1224
+ });
1225
+ let d = Array.isArray(i.oneOf) ? "oneOf" : "anyOf", f = i[d];
1226
+ if (Array.isArray(f)) {
1227
+ let e = f.map((e, i) => c(e, `${t}/${d}/${i}`, n, r + 1)).filter((e) => o(t, e)), i = new Map(e.map((e) => [JSON.stringify(e), e]));
1228
+ return i.size === 1 ? [...i.values()][0] : l;
1229
+ }
1230
+ if (Array.isArray(n)) {
1231
+ let e = Array.isArray(i.items), a = e ? i.items : Array.isArray(i.prefixItems) ? i.prefixItems : [], o = e ? i.additionalItems : i.items;
1232
+ return n.map((n, i) => c(i < a.length ? a[i] : o, i < a.length ? `${t}/${e ? "items" : "prefixItems"}/${i}` : `${t}/${e ? "additionalItems" : "items"}`, n, r + 1));
1233
+ }
1234
+ let p = M(n);
1235
+ if (p) {
1236
+ let e = {}, n = M(i.properties) || {}, a = M(i.patternProperties) || {};
1237
+ for (let [o, s] of Object.entries(p)) {
1238
+ let l = s, u = !1;
1239
+ Object.hasOwn(n, o) && (l = c(n[o], `${t}/properties/${Je(o)}`, l, r + 1), u = !0);
1240
+ for (let [e, n] of Object.entries(a)) new RegExp(e, "u").test(o) && (l = c(n, `${t}/patternProperties/${Je(e)}`, l, r + 1), u = !0);
1241
+ !u && M(i.additionalProperties) && (l = c(i.additionalProperties, `${t}/additionalProperties`, l, r + 1)), Object.defineProperty(e, o, {
1242
+ value: l,
1243
+ enumerable: !0,
1244
+ configurable: !0,
1245
+ writable: !0
1246
+ });
1247
+ }
1248
+ return e;
1249
+ }
1250
+ return Ze(n, Array.isArray(i.type) ? i.type : [i.type]);
1251
+ }, l = c(e, "", n), u = Ke(e, l);
1252
+ if (!u.valid) throw TypeError(u.issues.join(";"));
1253
+ return l;
1254
+ }
1255
+ //#endregion
1256
+ //#region src/core/interaction/client.ts
1257
+ var $e = {
1258
+ approve: "approved",
1259
+ reject: "rejected",
1260
+ submit: "submitted",
1261
+ cancel: "cancelled"
1262
+ };
1263
+ function N(e, t) {
1264
+ return {
1265
+ schema_version: 1,
1266
+ command_id: `local-${t}`,
1267
+ status: e,
1268
+ message_id: null,
1269
+ run_id: null,
1270
+ accepted_seq: null,
1271
+ error: null,
1272
+ extensions: {}
1273
+ };
1274
+ }
1275
+ var et = class {
1276
+ store;
1277
+ deps;
1278
+ inFlight = /* @__PURE__ */ new Map();
1279
+ constructor(e) {
1280
+ this.deps = e, this.store = e.store || new D();
1281
+ }
1282
+ listPending(e) {
1283
+ return this.store.listPending(e);
1284
+ }
1285
+ setInteractionV1Enabled(e) {
1286
+ this.deps.interactionV1Enabled = e;
1287
+ }
1288
+ subscribe(e) {
1289
+ return this.store.subscribe(e);
1290
+ }
1291
+ ingest(e) {
1292
+ this.store.upsert(e);
1293
+ }
1294
+ ingestHistory(e) {
1295
+ for (let t of e) this.store.upsert(t);
1296
+ for (let [e] of this.inFlight) {
1297
+ let t = this.store.all().find((t) => this.recordKey(t) === e);
1298
+ t && t.status !== "pending" && t.status !== "resolving" && this.inFlight.delete(e);
1299
+ }
1300
+ }
1301
+ recordKey(e) {
1302
+ return JSON.stringify([e.sessionId, e.interactionId]);
1303
+ }
1304
+ findByInteractionId(e, t) {
1305
+ if (t) return this.store.get(t, e);
1306
+ let n = this.store.all().filter((t) => t.interactionId === e);
1307
+ return n.length === 1 ? n[0] : null;
1308
+ }
1309
+ async respond(e) {
1310
+ let t = this.findByInteractionId(e.interactionId, e.sessionId);
1311
+ if (!t) return N("rejected", e.interactionId);
1312
+ if (t.status === "resolved" || t.status === "cancelled" || t.status === "expired" || t.status === "resolving") return N("duplicate", e.interactionId);
1313
+ let n = this.deps.interactionV1Enabled || t.source === "interaction_v1";
1314
+ if (!n && t.source === "responses" && (t.kind !== "approval" || ![
1315
+ "approve",
1316
+ "reject",
1317
+ "cancel"
1318
+ ].includes(e.action))) {
1319
+ let n = {
1320
+ code: "input_transport_unsupported",
1321
+ message: "当前运行时不支持提交此提问,请升级运行时后重试。",
1322
+ retryable: !1,
1323
+ extensions: {}
1324
+ };
1325
+ return this.store.markFailed(t.sessionId, e.interactionId, n), {
1326
+ ...N("unsupported", e.interactionId),
1327
+ error: n
1328
+ };
1329
+ }
1330
+ try {
1331
+ r(e.response);
1332
+ } catch {
1333
+ return this.store.markFailed(t.sessionId, e.interactionId, {
1334
+ code: "input_response_invalid",
1335
+ message: "答案必须是合法 JSON 值。",
1336
+ retryable: !0
1337
+ }), N("rejected", e.interactionId);
1338
+ }
1339
+ if (t.kind === "structured_input" && e.action === "submit" && t.requestSchema) try {
1340
+ e = {
1341
+ ...e,
1342
+ response: Qe(t.requestSchema, e.response)
1343
+ };
1344
+ } catch (n) {
1345
+ return this.store.markFailed(t.sessionId, e.interactionId, {
1346
+ code: "input_response_invalid",
1347
+ message: n instanceof Error ? n.message : "答案不符合表单约束。",
1348
+ retryable: !0
1349
+ }), N("rejected", e.interactionId);
1350
+ }
1351
+ if (t.source === "agui" && !this.deps.interactionV1Enabled && e.action !== "cancel" && e.response === null) return this.store.markFailed(t.sessionId, e.interactionId, {
1352
+ code: "input_transport_unsupported",
1353
+ message: "当前 AG-UI 传输不能提交根 null,请使用 Interaction/v1。",
1354
+ retryable: !1
1355
+ }), N("rejected", e.interactionId);
1356
+ let i = e.idempotencyKey || je(e.interactionId, e.expectedRevision), a = t.extensions.rejected_command_id, o = a ? `${i}:retry-${a}` : i, s = this.recordKey(t), c = this.inFlight.get(s);
1357
+ if (c) return N(c === o ? "duplicate" : "rejected", e.interactionId);
1358
+ this.inFlight.set(s, o), this.store.markResolving(t.sessionId, e.interactionId);
1359
+ try {
1360
+ if (!n && t.source === "responses" && this.deps.legacyResponsesApproval) {
1361
+ let n = t.extensions.previous_response_id;
1362
+ return await this.deps.legacyResponsesApproval(e.interactionId, e.action === "approve", ...typeof n == "string" && n ? [n] : []) === !1 ? (this.store.markFailed(t.sessionId, e.interactionId, {
1363
+ code: "interaction_not_dispatched",
1364
+ message: "交互尚未提交,请稍后重试。",
1365
+ retryable: !0
1366
+ }), N("rejected", e.interactionId)) : (this.resolveLocal(t, e, o), N("accepted", e.interactionId));
1367
+ }
1368
+ if (!n && t.source === "agui" && this.deps.legacyAguiResume) return this.deps.legacyAguiResume(String(t.extensions.interrupt_id || e.interactionId), e.action === "cancel" ? "cancelled" : "resolved", e.response) ? (this.store.recordIdempotencyKey(t.sessionId, e.interactionId, o), N("accepted", e.interactionId)) : (this.store.revertToPending(t.sessionId, e.interactionId), N("rejected", e.interactionId));
1369
+ let r = k(await this.deps.submitInteraction({
1370
+ AgentId: this.deps.agentId,
1371
+ SessionId: t.sessionId,
1372
+ RunId: t.runId || "",
1373
+ InteractionId: e.interactionId,
1374
+ ExpectedRevision: e.expectedRevision,
1375
+ Action: e.action,
1376
+ Response: e.response,
1377
+ IdempotencyKey: o
1378
+ }));
1379
+ return r.status === "accepted" || r.status === "duplicate" ? (this.store.recordCommand(t.sessionId, e.interactionId, r.command_id), this.store.recordIdempotencyKey(t.sessionId, e.interactionId, o)) : r.status === "queue_full" ? this.store.revertToPending(t.sessionId, e.interactionId) : this.store.markFailed(t.sessionId, e.interactionId, {
1380
+ code: r.error?.code ?? String(r.status),
1381
+ message: r.error?.message ?? `提交未通过(${r.status})`,
1382
+ retryable: r.error?.retryable ?? !1
1383
+ }), r;
1384
+ } catch (n) {
1385
+ let r = n instanceof Error ? n.message : String(n || "交互提交失败");
1386
+ throw this.store.markFailed(t.sessionId, e.interactionId, {
1387
+ code: "interaction_submit_failed",
1388
+ message: r,
1389
+ retryable: !0
1390
+ }), n;
1391
+ } finally {
1392
+ this.inFlight.delete(s);
1393
+ }
1394
+ }
1395
+ resolveLocal(e, t, n) {
1396
+ let r = this.store.get(e.sessionId, t.interactionId);
1397
+ if (!r || E(r.status)) return;
1398
+ let i = t.action === "cancel" ? "cancelled" : "resolved";
1399
+ this.store.resolveLocally(e.sessionId, t.interactionId, {
1400
+ status: i,
1401
+ outcome: $e[t.action],
1402
+ actor: "user",
1403
+ responseSummary: e.kind === "structured_input" ? t.action === "cancel" ? "已取消" : "已提交" : Me(t.action, t.response),
1404
+ revision: t.expectedRevision
1405
+ });
1406
+ let a = this.store.get(e.sessionId, t.interactionId);
1407
+ a && this.store.upsert({
1408
+ ...a,
1409
+ extensions: {
1410
+ ...a.extensions,
1411
+ idempotency_key: n
1412
+ }
1413
+ });
1414
+ }
1415
+ }, P = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, F = class extends Error {};
1416
+ function tt() {
1417
+ let e = 8192;
1418
+ return () => {
1419
+ if (--e < 0) throw new F();
1420
+ };
1421
+ }
1422
+ function nt(e, t, n) {
1423
+ if (e === "#") return t;
1424
+ if (typeof e != "string" || !e.startsWith("#/")) throw new F();
1425
+ try {
1426
+ let r = t;
1427
+ for (let t of decodeURIComponent(e.slice(2)).split("/")) {
1428
+ n();
1429
+ let e = P(r) ?? (Array.isArray(r) ? r : void 0), i = t.replace(/~1/g, "/").replace(/~0/g, "~");
1430
+ if (!e || !Object.hasOwn(e, i)) throw new F();
1431
+ r = e[i];
1432
+ }
1433
+ return r;
1434
+ } catch {
1435
+ throw new F();
1436
+ }
1437
+ }
1438
+ function I(e, t, n) {
1439
+ let r = /* @__PURE__ */ new Set(), i = [...e];
1440
+ for (; i.length;) {
1441
+ n();
1442
+ let e = i.pop();
1443
+ if (typeof e == "boolean") continue;
1444
+ let a = P(e);
1445
+ if (!a) throw new F();
1446
+ if (!r.has(a)) {
1447
+ if (r.add(a), a !== t && Object.hasOwn(a, "$id") || Object.hasOwn(a, "$dynamicRef") || Object.hasOwn(a, "$recursiveRef")) throw new F();
1448
+ Object.hasOwn(a, "$ref") && i.push(nt(a.$ref, t, n));
1449
+ for (let e of [
1450
+ "allOf",
1451
+ "anyOf",
1452
+ "oneOf"
1453
+ ]) {
1454
+ let t = a[e];
1455
+ if (t !== void 0 && !Array.isArray(t)) throw new F();
1456
+ Array.isArray(t) && i.push(...t);
1457
+ }
1458
+ for (let e of [
1459
+ "if",
1460
+ "then",
1461
+ "else"
1462
+ ]) Object.hasOwn(a, e) && i.push(a[e]);
1463
+ for (let e of [P(a.dependentSchemas), P(a.dependencies)]) for (let t of Object.values(e || {})) (P(t) || typeof t == "boolean") && i.push(t);
1464
+ }
1465
+ }
1466
+ return [...r];
1467
+ }
1468
+ var L = (e) => e.writeOnly === !0 || e.format === "password" || e["x-sensitive"] === !0 || e["x-codex-is-secret"] === !0;
1469
+ function rt(e, t = e) {
1470
+ try {
1471
+ return I([e], t, tt()).some(L);
1472
+ } catch {
1473
+ return !0;
1474
+ }
1475
+ }
1476
+ function R(e, t) {
1477
+ let n = tt();
1478
+ function i(t, r, a) {
1479
+ if (n(), a > 48) throw new F();
1480
+ let o = I(t, e, n);
1481
+ return o.some(L) ? null : Array.isArray(r) ? r.map((e, t) => {
1482
+ let n = [];
1483
+ for (let e of o) {
1484
+ let r = Array.isArray(e.prefixItems) ? e.prefixItems : void 0, i = Array.isArray(e.items) ? e.items : void 0;
1485
+ n.push(r && t < r.length ? r[t] : i ? t < i.length ? i[t] : e.additionalItems ?? {} : e.items ?? {});
1486
+ for (let t of ["contains", "unevaluatedItems"]) Object.hasOwn(e, t) && n.push(e[t]);
1487
+ }
1488
+ return i(n, e, a + 1);
1489
+ }) : typeof r != "object" || !r ? r : Object.fromEntries(Object.entries(r).map(([e, t]) => {
1490
+ let n = [];
1491
+ for (let t of o) {
1492
+ let r = P(t.properties), i = !!(r && Object.hasOwn(r, e));
1493
+ i && n.push(r[e]);
1494
+ for (let [r, a] of Object.entries(P(t.patternProperties) || {})) new RegExp(r).test(e) && (i = !0, n.push(a));
1495
+ !i && Object.hasOwn(t, "additionalProperties") && n.push(t.additionalProperties), Object.hasOwn(t, "unevaluatedProperties") && n.push(t.unevaluatedProperties);
1496
+ }
1497
+ return [e, i(n, t, a + 1)];
1498
+ }));
1499
+ }
1500
+ try {
1501
+ return r(t), i([e], t, 0);
1502
+ } catch {
1503
+ return null;
1504
+ }
1505
+ }
1506
+ function it(e) {
1507
+ if (!(e.kind !== "structured_input" || e.status !== "resolved" || e.outcome !== "submitted" || !e.requestSchema || !Object.hasOwn(e, "response"))) try {
1508
+ return { value: R(e.requestSchema, r(e.response)) };
1509
+ } catch {
1510
+ return;
1511
+ }
1512
+ }
1513
+ //#endregion
1514
+ //#region src/core/interaction/adapters/responses.ts
1515
+ function z(e) {
1516
+ return !e.approvalRequestId || !e.sessionId ? null : o({
1517
+ interactionId: e.approvalRequestId,
1518
+ sessionId: e.sessionId,
1519
+ runId: e.runId ?? null,
1520
+ kind: "approval",
1521
+ title: e.name ? `审批:${e.name}` : "人工确认",
1522
+ message: e.message || "本次运行需要人工审批后才能继续。",
1523
+ requestSchema: e.requestSchema ?? null,
1524
+ status: "pending",
1525
+ revision: 1,
1526
+ source: "responses",
1527
+ extensions: {
1528
+ ...e.previousResponseId ? { previous_response_id: e.previousResponseId } : {},
1529
+ ...e.approvalLevel ? { approval_level: e.approvalLevel } : {},
1530
+ ...e.args ? { arguments: e.args } : {}
1531
+ }
1532
+ });
1533
+ }
1534
+ function at(e) {
1535
+ let t = {}, n = [];
1536
+ for (let r of e) {
1537
+ let e = r && typeof r == "object" ? r : {}, i = String(e.id || e.question_id || e.name || `question_${n.length + 1}`), a = Array.isArray(e.options) ? e.options.map((e) => typeof e == "string" ? e : String(e?.id ?? e?.value ?? e?.label ?? "")).filter(Boolean) : [];
1538
+ t[i] = {
1539
+ type: "string",
1540
+ title: String(e.question || e.label || e.title || i),
1541
+ ...a.length ? { enum: a } : {}
1542
+ }, n.push(i);
1543
+ }
1544
+ return {
1545
+ type: "object",
1546
+ properties: t,
1547
+ required: n,
1548
+ additionalProperties: !1
1549
+ };
1550
+ }
1551
+ function ot(e) {
1552
+ if (!e.questionId || !e.sessionId) return null;
1553
+ let t = Array.isArray(e.questions) ? e.questions : [];
1554
+ return o({
1555
+ interactionId: e.questionId,
1556
+ sessionId: e.sessionId,
1557
+ runId: e.runId ?? null,
1558
+ kind: "structured_input",
1559
+ title: "询问",
1560
+ message: "Agent 需要你的选择后才能继续。",
1561
+ requestSchema: at(t),
1562
+ status: "pending",
1563
+ revision: 1,
1564
+ source: "responses",
1565
+ extensions: { questions: t }
1566
+ });
1567
+ }
1568
+ //#endregion
1569
+ //#region src/core/interaction/adapters/agui.ts
1570
+ function B(e) {
1571
+ if (!e.interruptId || !e.sessionId) return null;
1572
+ let t = e.requestSchema != null;
1573
+ return o({
1574
+ interactionId: e.interruptId,
1575
+ sessionId: e.sessionId,
1576
+ runId: e.runId ?? null,
1577
+ kind: t ? "structured_input" : "approval",
1578
+ title: e.name ? `${t ? "补充信息" : "确认"}:${e.name}` : t ? "补充信息" : "人工确认",
1579
+ message: e.message || (t ? "请填写后提交,Agent 将继续当前任务。" : "本次运行需要人工确认后才能继续。"),
1580
+ requestSchema: e.requestSchema ?? null,
1581
+ status: "pending",
1582
+ revision: 1,
1583
+ source: "agui",
1584
+ extensions: {
1585
+ interrupt_id: e.interruptId,
1586
+ ...e.toolCallId ? { tool_call_id: e.toolCallId } : {},
1587
+ ...e.reason ? { reason: e.reason } : {}
1588
+ }
1589
+ });
1590
+ }
1591
+ var V = {
447
1592
  $schema: "https://json-schema.org/draft/2020-12/schema",
448
1593
  $id: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json",
449
1594
  title: "A2UI Basic Catalog",
@@ -519,7 +1664,7 @@ var de = a()((e) => ({
519
1664
  { $ref: "#/functions/not" }
520
1665
  ] }
521
1666
  }
522
- }, D = {
1667
+ }, st = {
523
1668
  $schema: "https://json-schema.org/draft/2020-12/schema",
524
1669
  $id: "https://a2ui.org/specification/v0_9/common_types.json",
525
1670
  title: "A2UI Common Types",
@@ -712,7 +1857,7 @@ var de = a()((e) => ({
712
1857
  }]
713
1858
  }
714
1859
  }
715
- }, O = {
1860
+ }, ct = {
716
1861
  schema_version: 1,
717
1862
  profile: "official-0.9.1",
718
1863
  wire_versions: ["v0.9", "v0.9.1"],
@@ -790,7 +1935,7 @@ var de = a()((e) => ({
790
1935
  ],
791
1936
  source: "ksadk.a2ui.models.BASIC_CATALOG; project compatibility asset"
792
1937
  }]
793
- }, k = {
1938
+ }, H = {
794
1939
  $schema: "https://json-schema.org/draft/2020-12/schema",
795
1940
  $id: "a2ui.org/catalogs/basic/v1.0",
796
1941
  catalogId: "a2ui.org/catalogs/basic/v1.0",
@@ -960,24 +2105,24 @@ var de = a()((e) => ({
960
2105
  }
961
2106
  },
962
2107
  functions: {}
963
- }, A = E, j = O, M = k;
964
- function N(e) {
965
- return te(ee(new TextEncoder().encode(f(n(e)))));
2108
+ }, U = V, W = ct, G = H;
2109
+ function K(e) {
2110
+ return ne(te(new TextEncoder().encode(ee(r(e)))));
966
2111
  }
967
- var P = new s({
2112
+ var q = new m({
968
2113
  strict: !1,
969
2114
  allErrors: !0,
970
2115
  logger: !1
971
2116
  });
972
- c(P), P.addSchema(D), P.addSchema(E), P.addSchema(k);
973
- for (let e of Object.keys(O.schema_resolution_aliases)) P.addSchema({
974
- ...E,
2117
+ g(q), q.addSchema(st), q.addSchema(V), q.addSchema(H);
2118
+ for (let e of Object.keys(ct.schema_resolution_aliases)) q.addSchema({
2119
+ ...V,
975
2120
  $id: e
976
2121
  });
977
- new Map(Object.keys(E.components).map((e) => [e, P.getSchema(`${E.$id}#/components/${e}`)])), new Map(Object.keys(k.components).map((e) => [e, P.getSchema(`${k.$id}#/components/${e}`)]));
2122
+ new Map(Object.keys(V.components).map((e) => [e, q.getSchema(`${V.$id}#/components/${e}`)])), new Map(Object.keys(H.components).map((e) => [e, q.getSchema(`${H.$id}#/components/${e}`)]));
978
2123
  //#endregion
979
2124
  //#region src/core/a2ui/linking.ts
980
- var pe = new Set([
2125
+ var lt = new Set([
981
2126
  "components",
982
2127
  "functions",
983
2128
  "$defs",
@@ -985,7 +2130,7 @@ var pe = new Set([
985
2130
  "properties",
986
2131
  "patternProperties",
987
2132
  "dependentSchemas"
988
- ]), me = new Set([
2133
+ ]), ut = new Set([
989
2134
  "theme",
990
2135
  "items",
991
2136
  "additionalProperties",
@@ -999,13 +2144,13 @@ var pe = new Set([
999
2144
  "unevaluatedProperties",
1000
2145
  "unevaluatedItems",
1001
2146
  "contentSchema"
1002
- ]), he = new Set([
2147
+ ]), dt = new Set([
1003
2148
  "allOf",
1004
2149
  "anyOf",
1005
2150
  "oneOf",
1006
2151
  "prefixItems"
1007
- ]), F = "https://a2ui.org/specification/v0_9/common_types.json";
1008
- function I(e, t) {
2152
+ ]), ft = "https://a2ui.org/specification/v0_9/common_types.json";
2153
+ function pt(e, t) {
1009
2154
  let n = String(e.$id || e.catalogId), r = /* @__PURE__ */ new Set(), i = (e, t) => t.startsWith("#") ? e.split("#")[0] + t : /^[a-z][a-z0-9+.-]*:/i.test(t) ? t : new URL(t, e).href, a = (e, o, s = !1) => {
1010
2155
  if (!e || typeof e != "object" || Array.isArray(e)) return structuredClone(e);
1011
2156
  let c = e, l = typeof c.$id == "string" && c.$id !== o ? i(o, c.$id) : o, u = structuredClone(c);
@@ -1015,7 +2160,7 @@ function I(e, t) {
1015
2160
  let d = i(l, o), f = t(d);
1016
2161
  if (f === void 0) throw Error("A2UI 目录包含未提供的离线 Schema 引用。");
1017
2162
  if (d.split("#")[0] === n) u[e] = "#" + (d.split("#")[1] || "");
1018
- else if (d.split("#")[0] !== F) {
2163
+ else if (d.split("#")[0] !== ft) {
1019
2164
  if (r.has(d)) throw Error("循环的外部 A2UI Schema 资产无法完成链接。");
1020
2165
  r.add(d);
1021
2166
  let t;
@@ -1028,32 +2173,32 @@ function I(e, t) {
1028
2173
  return Object.keys(n).length ? { allOf: [t, a(n, l, s)] } : t;
1029
2174
  }
1030
2175
  }
1031
- for (let [e, t] of Object.entries(c)) pe.has(e) && t && typeof t == "object" && !Array.isArray(t) ? u[e] = Object.fromEntries(Object.entries(t).map(([e, t]) => [e, a(t, l, s)])) : me.has(e) && (typeof t == "object" || typeof t == "boolean") ? u[e] = a(t, l, s) : he.has(e) && Array.isArray(t) && (u[e] = t.map((e) => a(e, l, s)));
2176
+ for (let [e, t] of Object.entries(c)) lt.has(e) && t && typeof t == "object" && !Array.isArray(t) ? u[e] = Object.fromEntries(Object.entries(t).map(([e, t]) => [e, a(t, l, s)])) : ut.has(e) && (typeof t == "object" || typeof t == "boolean") ? u[e] = a(t, l, s) : dt.has(e) && Array.isArray(t) && (u[e] = t.map((e) => a(e, l, s)));
1032
2177
  return s && (delete u.$id, delete u.$schema, delete u.$anchor), u;
1033
2178
  };
1034
2179
  return a(e, n);
1035
2180
  }
1036
2181
  //#endregion
1037
2182
  //#region src/core/a2ui/registry.ts
1038
- var L = [{
1039
- schema: A,
2183
+ var mt = [{
2184
+ schema: U,
1040
2185
  loadRenderer: async () => (await import("@a2ui/web_core/v0_9/basic_catalog")).basicCatalog
1041
2186
  }, {
1042
- schema: M,
1043
- loadRenderer: async () => new l(M.catalogId, "0.9", [...l.fromSchema(M, "0.9").components.values()], [])
1044
- }], R = class {
2187
+ schema: G,
2188
+ loadRenderer: async () => new _(G.catalogId, "0.9", [..._.fromSchema(G, "0.9").components.values()], [])
2189
+ }], J = class {
1045
2190
  defaultCatalogId;
1046
2191
  entries = /* @__PURE__ */ new Map();
1047
2192
  validators = /* @__PURE__ */ new Map();
1048
2193
  loaders = /* @__PURE__ */ new Map();
1049
2194
  processorSchemas = /* @__PURE__ */ new Map();
1050
- constructor(e = [], t = j.catalog_id) {
1051
- for (let t of [...L, ...e]) {
2195
+ constructor(e = [], t = W.catalog_id) {
2196
+ for (let t of [...mt, ...e]) {
1052
2197
  let e = structuredClone(t.schema), n = e.catalogId;
1053
2198
  if (typeof n != "string" || !n.trim() || !e.components || typeof e.components != "object") throw Error("A2UI 目录缺少身份或组件 Schema。");
1054
- let r = N(e), i = this.entries.get(n);
2199
+ let r = K(e), i = this.entries.get(n);
1055
2200
  if (i) {
1056
- if (i.digest !== r || i.loadRenderer !== t.loadRenderer || i.historyAdapter !== t.historyAdapter || N(i.resources) !== N(t.resources || []) || N(i.inputComponents) !== N(t.inputComponents || [])) throw Error("A2UI 目录身份存在冲突。");
2201
+ if (i.digest !== r || i.loadRenderer !== t.loadRenderer || i.historyAdapter !== t.historyAdapter || K(i.resources) !== K(t.resources || []) || K(i.inputComponents) !== K(t.inputComponents || [])) throw Error("A2UI 目录身份存在冲突。");
1057
2202
  continue;
1058
2203
  }
1059
2204
  let a = structuredClone(t.resources || []);
@@ -1065,31 +2210,31 @@ var L = [{
1065
2210
  inputComponents: Object.freeze([...t.inputComponents || []])
1066
2211
  }));
1067
2212
  }
1068
- let n = new s({
2213
+ let n = new m({
1069
2214
  strict: !1,
1070
2215
  allErrors: !0,
1071
2216
  logger: !1
1072
2217
  });
1073
- c(n);
2218
+ g(n);
1074
2219
  let r = /* @__PURE__ */ new Map(), i = (e) => {
1075
2220
  let t = e.$id ?? e.catalogId;
1076
2221
  if (typeof t != "string" || !t) throw Error("离线 A2UI Schema 缺少 $id。");
1077
- if (r.has(t) && N(r.get(t)) !== N(e)) throw Error("离线 A2UI Schema 身份存在冲突。");
2222
+ if (r.has(t) && K(r.get(t)) !== K(e)) throw Error("离线 A2UI Schema 身份存在冲突。");
1078
2223
  r.set(t, e);
1079
2224
  };
1080
- i(D);
2225
+ i(st);
1081
2226
  for (let e of this.entries.values()) {
1082
2227
  i(e.schema);
1083
2228
  for (let t of e.resources || []) i(t);
1084
2229
  }
1085
- for (let e of Object.keys(j.schema_resolution_aliases)) i({
1086
- ...A,
2230
+ for (let e of Object.keys(W.schema_resolution_aliases)) i({
2231
+ ...U,
1087
2232
  $id: e
1088
2233
  });
1089
2234
  for (let [e, t] of r) n.addSchema(t, e);
1090
2235
  for (let [e, t] of this.entries) {
1091
2236
  let r = String(t.schema.$id || e);
1092
- this.validators.set(e, new Map(Object.keys(t.schema.components).map((e) => [e, n.getSchema(`${r}#/components/${e}`)]))), this.processorSchemas.set(e, I(t.schema, (e) => n.getSchema(e)?.schema));
2237
+ this.validators.set(e, new Map(Object.keys(t.schema.components).map((e) => [e, n.getSchema(`${r}#/components/${e}`)]))), this.processorSchemas.set(e, pt(t.schema, (e) => n.getSchema(e)?.schema));
1093
2238
  }
1094
2239
  if (!this.entries.has(t)) throw Error("默认 A2UI 目录未注册。");
1095
2240
  this.defaultCatalogId = t;
@@ -1119,9 +2264,9 @@ var L = [{
1119
2264
  }
1120
2265
  validateMessages(e) {
1121
2266
  if (!e.length || e.length > 4096 || new TextEncoder().encode(JSON.stringify(e)).length > 1048576) throw Error("A2UI 消息无效或超过展示预算。");
1122
- let t = new u([...this.processorSchemas.values()].map((e) => {
1123
- let t = l.fromSchema(e, "0.9");
1124
- return new l(t.id, t.protocolVersion, [...t.components.values()], [...t.functions.values()].map((e) => d(e, () => {
2267
+ let t = new re([...this.processorSchemas.values()].map((e) => {
2268
+ let t = _.fromSchema(e, "0.9");
2269
+ return new _(t.id, t.protocolVersion, [...t.components.values()], [...t.functions.values()].map((e) => ie(e, () => {
1125
2270
  throw Error("校验过程不能执行 A2UI 函数。");
1126
2271
  })), t.themeSchema, t.instructions);
1127
2272
  }), void 0, {
@@ -1178,37 +2323,25 @@ var L = [{
1178
2323
  }));
1179
2324
  }
1180
2325
  };
1181
- function z(e = [], t = {}) {
1182
- return new R(e, t.defaultCatalogId);
1183
- }
1184
- var B = z(), V = r(B);
1185
- function ge({ registry: e, children: t }) {
1186
- return /* @__PURE__ */ o(V.Provider, {
1187
- value: e,
1188
- children: t
1189
- });
2326
+ function ht(e = [], t = {}) {
2327
+ return new J(e, t.defaultCatalogId);
1190
2328
  }
1191
- function _e() {
1192
- return i(V);
2329
+ var Y = ht(), gt = "0.9.1";
2330
+ function _t(e) {
2331
+ return K(e);
1193
2332
  }
1194
- //#endregion
1195
- //#region src/core/interaction/a2ui-validate.ts
1196
- var ve = "0.9.1";
1197
- function ye(e) {
1198
- return N(e);
1199
- }
1200
- function H(e, t = B) {
1201
- if (!e) return U(null);
1202
- if (e.wireVersion !== "0.9.1" || !e.messages || e.messages.length === 0) return U(e);
2333
+ function vt(e, t = Y) {
2334
+ if (!e) return X(null);
2335
+ if (e.wireVersion !== "0.9.1" || !e.messages || e.messages.length === 0) return X(e);
1203
2336
  try {
1204
- let n = t instanceof R ? t : B, r = new Set(e.messages.flatMap((e) => {
2337
+ let n = t instanceof J ? t : Y, r = new Set(e.messages.flatMap((e) => {
1205
2338
  let t = e.createSurface;
1206
2339
  return t?.catalogId ? [t.catalogId] : [];
1207
2340
  }));
1208
2341
  if (r.size !== 1) return "json-schema-form";
1209
2342
  let i = n.get([...r][0]);
1210
2343
  if (!i) return "json-schema-form";
1211
- let a = t instanceof R ? i.digest : ye(t), o = [...r][0] === M.catalogId && e.catalogDigest === j.catalog_digest;
2344
+ let a = t instanceof J ? i.digest : _t(t), o = [...r][0] === G.catalogId && e.catalogDigest === W.catalog_digest;
1212
2345
  if (!e.catalogDigest || e.catalogDigest !== a && !o) return "json-schema-form";
1213
2346
  n.validateMessages(e.messages).dispose();
1214
2347
  } catch {
@@ -1216,320 +2349,244 @@ function H(e, t = B) {
1216
2349
  }
1217
2350
  return "a2ui";
1218
2351
  }
1219
- function U(e) {
1220
- return e && be(e) ? "json-schema-form" : "basic-controls";
2352
+ function X(e) {
2353
+ return e && yt(e) ? "json-schema-form" : "basic-controls";
1221
2354
  }
1222
- function be(e) {
2355
+ function yt(e) {
1223
2356
  return e.messages.some((e) => {
1224
2357
  let t = e.inputSchema ?? e.input_schema ?? e.schema;
1225
2358
  return typeof t == "object" && !!t;
1226
2359
  });
1227
2360
  }
1228
- function xe(e, t = B) {
2361
+ function bt(e, t = Y) {
1229
2362
  let n = e.kind === "approval" ? e.presentation?.a2ui : null;
1230
- return n && H(n, t) === "a2ui" ? n : null;
2363
+ return n && vt(n, t) === "a2ui" ? n : null;
1231
2364
  }
1232
2365
  //#endregion
1233
- //#region src/core/interaction/types.ts
1234
- var Se = new Set([
1235
- "resolved",
1236
- "cancelled",
1237
- "expired"
1238
- ]);
1239
- function Ce(e) {
1240
- return Se.has(e);
1241
- }
1242
- function we(e, t) {
1243
- return `interaction:${e}:revision-${t}`;
1244
- }
1245
- function Te(e, t) {
1246
- if (typeof t != "object" || !t || Array.isArray(t)) return e === "cancel" ? "已取消" : "已提交";
1247
- let n = t.approved;
1248
- if (typeof n == "boolean") return n ? "已同意" : "已拒绝";
1249
- let r = Object.keys(t);
1250
- return r.length === 0 ? e === "approve" ? "已同意" : e === "reject" ? "已拒绝" : e === "cancel" ? "已取消" : "已提交" : `${e}(${r.slice(0, 3).map((e) => {
1251
- let n = t[e];
1252
- return `${e}=${typeof n == "string" ? n.length > 24 ? `${n.slice(0, 24)}…` : n : typeof n == "object" && n ? "[object]" : String(n)}`;
1253
- }).join(", ")})`;
1254
- }
1255
- var Ee = {
1256
- $schema: "http://json-schema.org/draft-06/schema#",
1257
- $id: "http://json-schema.org/draft-06/schema#",
1258
- title: "Core schema meta-schema",
1259
- definitions: {
1260
- schemaArray: {
1261
- type: "array",
1262
- minItems: 1,
1263
- items: { $ref: "#" }
1264
- },
1265
- nonNegativeInteger: {
1266
- type: "integer",
1267
- minimum: 0
1268
- },
1269
- nonNegativeIntegerDefault0: { allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] },
1270
- simpleTypes: { enum: [
1271
- "array",
1272
- "boolean",
1273
- "integer",
1274
- "null",
1275
- "number",
1276
- "object",
1277
- "string"
1278
- ] },
1279
- stringArray: {
1280
- type: "array",
1281
- items: { type: "string" },
1282
- uniqueItems: !0,
1283
- default: []
2366
+ //#region src/core/interaction/legacy-history.ts
2367
+ var Z = (e) => typeof e == "string" && e ? e : void 0;
2368
+ function xt(e, t, n) {
2369
+ for (let r of n) {
2370
+ if (r.agentBlock && xt(e, t, r.agentBlock.messages), r.eventType === "conversation_item_v1") continue;
2371
+ let n = Object.values(r.tools || {}), i = [...n];
2372
+ for (let e of r.blocks || []) {
2373
+ if (e.type !== "tool" || !Z(e.extra?.approvalRequestId)) continue;
2374
+ let t = e.extra || {}, r = n.find((e) => e.approvalRequestId === t.approvalRequestId);
2375
+ i.push({
2376
+ ...r,
2377
+ name: e.toolName,
2378
+ args: e.args,
2379
+ status: e.status,
2380
+ approvalRequestId: Z(t.approvalRequestId),
2381
+ approvalStatus: Z(t.approvalStatus) || r?.approvalStatus,
2382
+ approvalProtocol: Z(t.approvalProtocol) || r?.approvalProtocol,
2383
+ approvalMessage: Z(t.approvalMessage) || r?.approvalMessage,
2384
+ previousResponseId: Z(t.previousResponseId) || r?.previousResponseId
2385
+ });
1284
2386
  }
1285
- },
1286
- type: ["object", "boolean"],
1287
- properties: {
1288
- $id: {
1289
- type: "string",
1290
- format: "uri-reference"
1291
- },
1292
- $schema: {
1293
- type: "string",
1294
- format: "uri"
1295
- },
1296
- $ref: {
1297
- type: "string",
1298
- format: "uri-reference"
1299
- },
1300
- title: { type: "string" },
1301
- description: { type: "string" },
1302
- default: {},
1303
- examples: {
1304
- type: "array",
1305
- items: {}
1306
- },
1307
- multipleOf: {
1308
- type: "number",
1309
- exclusiveMinimum: 0
1310
- },
1311
- maximum: { type: "number" },
1312
- exclusiveMaximum: { type: "number" },
1313
- minimum: { type: "number" },
1314
- exclusiveMinimum: { type: "number" },
1315
- maxLength: { $ref: "#/definitions/nonNegativeInteger" },
1316
- minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1317
- pattern: {
1318
- type: "string",
1319
- format: "regex"
1320
- },
1321
- additionalItems: { $ref: "#" },
1322
- items: {
1323
- anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }],
1324
- default: {}
1325
- },
1326
- maxItems: { $ref: "#/definitions/nonNegativeInteger" },
1327
- minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1328
- uniqueItems: {
1329
- type: "boolean",
1330
- default: !1
1331
- },
1332
- contains: { $ref: "#" },
1333
- maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
1334
- minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
1335
- required: { $ref: "#/definitions/stringArray" },
1336
- additionalProperties: { $ref: "#" },
1337
- definitions: {
1338
- type: "object",
1339
- additionalProperties: { $ref: "#" },
1340
- default: {}
1341
- },
1342
- properties: {
1343
- type: "object",
1344
- additionalProperties: { $ref: "#" },
1345
- default: {}
1346
- },
1347
- patternProperties: {
1348
- type: "object",
1349
- additionalProperties: { $ref: "#" },
1350
- default: {}
1351
- },
1352
- dependencies: {
1353
- type: "object",
1354
- additionalProperties: { anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] }
1355
- },
1356
- propertyNames: { $ref: "#" },
1357
- const: {},
1358
- enum: {
1359
- type: "array",
1360
- minItems: 1,
1361
- uniqueItems: !0
1362
- },
1363
- type: { anyOf: [{ $ref: "#/definitions/simpleTypes" }, {
1364
- type: "array",
1365
- items: { $ref: "#/definitions/simpleTypes" },
1366
- minItems: 1,
1367
- uniqueItems: !0
1368
- }] },
1369
- format: { type: "string" },
1370
- allOf: { $ref: "#/definitions/schemaArray" },
1371
- anyOf: { $ref: "#/definitions/schemaArray" },
1372
- oneOf: { $ref: "#/definitions/schemaArray" },
1373
- not: { $ref: "#" }
1374
- },
1375
- default: {}
1376
- }, W = /* @__PURE__ */ new Map();
1377
- function G(e) {
1378
- n(e);
1379
- let t = JSON.stringify(e), r = W.get(t);
1380
- if (r) return r;
1381
- let i = String(e.$schema || "https://json-schema.org/draft/2020-12/schema"), a = {
1382
- strict: !1,
1383
- allErrors: !0,
1384
- coerceTypes: !1,
1385
- useDefaults: !1,
1386
- removeAdditional: !1,
1387
- ownProperties: !0,
1388
- logger: !1
1389
- }, o = /draft-04/.test(i) ? new ie(a) : /draft-0[67]/.test(i) ? new ne(a) : /2019-09/.test(i) ? new re(a) : /2020-12/.test(i) ? new s(a) : null;
1390
- if (!o) throw TypeError("Unsupported JSON Schema dialect");
1391
- /draft-06/.test(i) && o.addMetaSchema(Ee), c(o);
1392
- let l = o.compile(e);
1393
- if ("$async" in l && l.$async) throw TypeError("Async schemas are not supported");
1394
- W.size >= 128 && W.delete(W.keys().next().value);
1395
- let u = typeof e.$id == "string" ? e.$id.replace(/#$/, "") : typeof e.id == "string" ? e.id.replace(/#$/, "") : "", d = {
1396
- root: l,
1397
- at: (e, t) => !!(e === "" ? l : o.getSchema(`${u}#${e}`))?.(t)
1398
- };
1399
- return W.set(t, d), d;
2387
+ for (let n of i) {
2388
+ let i = n.approvalRequestId, a = n.approvalProtocol, o = n.approvalStatus || (n.status === "paused" ? "pending" : void 0);
2389
+ if (!i || !o || ![
2390
+ "pending",
2391
+ "approved",
2392
+ "rejected",
2393
+ "cancelled"
2394
+ ].includes(o) || a !== "responses" && a !== "ag-ui") continue;
2395
+ let s = e.get(t, i);
2396
+ if (s && (s.source === "interaction_v1" || E(s.status))) continue;
2397
+ let c = {
2398
+ sessionId: t,
2399
+ runId: r.runId || r.invocationId,
2400
+ name: n.name,
2401
+ message: n.approvalMessage,
2402
+ args: n.args,
2403
+ previousResponseId: n.previousResponseId || r.responseId
2404
+ }, l = a === "ag-ui" ? B({
2405
+ ...c,
2406
+ interruptId: i,
2407
+ toolCallId: n.callId
2408
+ }) : z({
2409
+ ...c,
2410
+ approvalRequestId: i
2411
+ });
2412
+ l && (l.revision = s?.revision || l.revision, l.createdAt = s?.createdAt || l.createdAt, l.runId = s?.runId || l.runId, l.extensions = {
2413
+ ...l.extensions,
2414
+ ...s?.extensions
2415
+ }, o !== "pending" && (l.status = o === "cancelled" ? "cancelled" : "resolved", l.outcome = o), e.upsert(l));
2416
+ }
2417
+ }
1400
2418
  }
1401
- function De(e) {
1402
- return G(e).at;
2419
+ //#endregion
2420
+ //#region src/core/interaction/adapters/legacy-runtime-events.ts
2421
+ function Q(e) {
2422
+ return e && typeof e == "object" && !Array.isArray(e) ? e : null;
1403
2423
  }
1404
- function Oe(e, t) {
1405
- try {
1406
- n(t);
1407
- let r = G(e).root, i = r(t);
1408
- return {
1409
- valid: !!i,
1410
- issues: i ? [] : (r.errors || []).slice(0, 10).map((e) => `${e.instancePath || "/"}:不符合 ${e.keyword} 约束`)
1411
- };
1412
- } catch {
1413
- return {
1414
- valid: !1,
1415
- issues: ["输入或表单约束不是受支持的 JSON。"]
1416
- };
2424
+ function St(e, t) {
2425
+ let n = Q(e), r = Q(Q(n?.Content)?.runtime_event);
2426
+ if (!r || r.schema_version !== 2 || r.interaction_kind !== "approval") return null;
2427
+ let i = Q(r.source);
2428
+ if (![
2429
+ "langgraph",
2430
+ "langchain",
2431
+ "deepagents"
2432
+ ].includes(String(i?.framework))) return null;
2433
+ let a = String(n?.SessionId || t || ""), o = typeof r.interaction_id == "string" ? r.interaction_id : "";
2434
+ if (!a || !o) return null;
2435
+ let s = Q(r.request), c = Q(s?.detail), l = Q(r.response), u = r.event_type === "interaction.requested", d = r.event_type === "interaction.resolved";
2436
+ if (u && (s?.request_type !== "approval" || c?.approval_request_id !== o) || !u && (!d || l?.response_type !== "approval")) return null;
2437
+ let f = Q((Array.isArray(c?.action_requests) ? c.action_requests : [])[0]), p = c?.arguments ?? f?.args, m = Q(i?.metadata), h = z({
2438
+ approvalRequestId: o,
2439
+ sessionId: a,
2440
+ runId: String(r.run_id || n?.InvocationId || "") || void 0,
2441
+ name: String(c?.tool_name || f?.name || "") || void 0,
2442
+ message: typeof c?.description == "string" ? c.description : void 0,
2443
+ args: p === void 0 ? void 0 : typeof p == "string" ? p : JSON.stringify(p),
2444
+ previousResponseId: typeof m?.response_id == "string" ? m.response_id : void 0
2445
+ });
2446
+ if (!h) return null;
2447
+ if (h.createdAt = String(r.timestamp ?? n?.Timestamp ?? h.createdAt), d) {
2448
+ let e = l?.decision;
2449
+ if (e !== "approved" && e !== "rejected" && e !== "canceled") return null;
2450
+ h.status = e === "canceled" ? "cancelled" : "resolved", h.outcome = e === "canceled" ? "cancelled" : e, h.resolvedAt = h.createdAt;
1417
2451
  }
2452
+ return h;
1418
2453
  }
1419
2454
  //#endregion
1420
- //#region src/core/interaction/response-snapshot.ts
1421
- var K = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, q = class extends Error {};
1422
- function J() {
1423
- let e = 8192;
1424
- return () => {
1425
- if (--e < 0) throw new q();
1426
- };
2455
+ //#region src/core/interaction/index.ts
2456
+ var Ct = new Set([
2457
+ "completed",
2458
+ "failed",
2459
+ "error",
2460
+ "cancelled",
2461
+ "canceled",
2462
+ "aborted",
2463
+ "resume_failed"
2464
+ ]), $ = new D();
2465
+ function wt(e, t) {
2466
+ xt($, t, e);
1427
2467
  }
1428
- function ke(e, t, n) {
1429
- if (e === "#") return t;
1430
- if (typeof e != "string" || !e.startsWith("#/")) throw new q();
1431
- try {
1432
- let r = t;
1433
- for (let t of decodeURIComponent(e.slice(2)).split("/")) {
1434
- n();
1435
- let e = K(r) ?? (Array.isArray(r) ? r : void 0), i = t.replace(/~1/g, "/").replace(/~0/g, "~");
1436
- if (!e || !Object.hasOwn(e, i)) throw new q();
1437
- r = e[i];
1438
- }
1439
- return r;
1440
- } catch {
1441
- throw new q();
2468
+ function Tt(e, t) {
2469
+ let n = i(e, t) ?? St(e, t);
2470
+ n && $.upsert(n);
2471
+ let r = typeof e == "object" && e ? e : null;
2472
+ if (r?.EventType === "control.command_rejected") {
2473
+ let e = r.Content;
2474
+ $.rejectCommand(String(r.SessionId || t || ""), String(e?.command_id || ""), String(e?.reason || "command_rejected"));
1442
2475
  }
2476
+ let o = r ? a(r) : null;
2477
+ if (o !== null && Ct.has(o)) {
2478
+ let e = typeof r?.Content == "object" && r.Content !== null ? r.Content : {}, n = typeof e.payload == "object" && e.payload !== null ? e.payload : {}, i = String(r?.SessionId || r?.session_id || t || ""), a = String(r?.InvocationId || r?.run_id || n.run_id || n.runId || "");
2479
+ $.markRunTerminal(i, a);
2480
+ }
2481
+ return n;
1443
2482
  }
1444
- function Y(e, t, n) {
1445
- let r = /* @__PURE__ */ new Set(), i = [...e];
1446
- for (; i.length;) {
1447
- n();
1448
- let e = i.pop();
1449
- if (typeof e == "boolean") continue;
1450
- let a = K(e);
1451
- if (!a) throw new q();
1452
- if (!r.has(a)) {
1453
- if (r.add(a), a !== t && Object.hasOwn(a, "$id") || Object.hasOwn(a, "$dynamicRef") || Object.hasOwn(a, "$recursiveRef")) throw new q();
1454
- Object.hasOwn(a, "$ref") && i.push(ke(a.$ref, t, n));
1455
- for (let e of [
1456
- "allOf",
1457
- "anyOf",
1458
- "oneOf"
1459
- ]) {
1460
- let t = a[e];
1461
- if (t !== void 0 && !Array.isArray(t)) throw new q();
1462
- Array.isArray(t) && i.push(...t);
1463
- }
1464
- for (let e of [
1465
- "if",
1466
- "then",
1467
- "else"
1468
- ]) Object.hasOwn(a, e) && i.push(a[e]);
1469
- for (let e of [K(a.dependentSchemas), K(a.dependencies)]) for (let t of Object.values(e || {})) (K(t) || typeof t == "boolean") && i.push(t);
2483
+ function Et(e) {
2484
+ let t = e.sessionId || "";
2485
+ if (!t || !e.approvalRequestId) return null;
2486
+ let n = e.protocol === "ag-ui" ? B({
2487
+ interruptId: e.approvalRequestId,
2488
+ sessionId: t,
2489
+ runId: e.runId,
2490
+ name: e.name,
2491
+ message: e.message,
2492
+ reason: e.approvalLevel,
2493
+ requestSchema: e.requestSchema
2494
+ }) : z({
2495
+ approvalRequestId: e.approvalRequestId,
2496
+ sessionId: t,
2497
+ runId: e.runId,
2498
+ name: e.name,
2499
+ message: e.message,
2500
+ args: e.args,
2501
+ approvalLevel: e.approvalLevel,
2502
+ previousResponseId: e.previousResponseId
2503
+ });
2504
+ return n && $.upsert(n), n;
2505
+ }
2506
+ function Dt(e) {
2507
+ let t = e.sessionId || "";
2508
+ if (!t || !e.questionId) return null;
2509
+ let n = ot({
2510
+ questionId: e.questionId,
2511
+ sessionId: t,
2512
+ runId: e.runId,
2513
+ questions: e.questions
2514
+ });
2515
+ return n && $.upsert(n), n;
2516
+ }
2517
+ function Ot(e) {
2518
+ let t = e.sessionId || "";
2519
+ if (!t || !e.questionId) return null;
2520
+ let n = $.get(t, e.questionId);
2521
+ if (!n) return null;
2522
+ let r = e.answers && typeof e.answers == "object" ? e.answers : {};
2523
+ return $.upsert({
2524
+ ...n,
2525
+ status: "resolved",
2526
+ revision: e.revision ?? n.revision + 1,
2527
+ resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
2528
+ outcome: "submitted",
2529
+ responseSummary: JSON.stringify(r).slice(0, 200),
2530
+ extensions: {
2531
+ ...n.extensions,
2532
+ answers: r
1470
2533
  }
1471
- }
1472
- return [...r];
2534
+ }), $.get(t, e.questionId);
1473
2535
  }
1474
- var X = (e) => e.writeOnly === !0 || e.format === "password" || e["x-sensitive"] === !0 || e["x-codex-is-secret"] === !0;
1475
- function Z(e, t = e) {
1476
- try {
1477
- return Y([e], t, J()).some(X);
1478
- } catch {
1479
- return !0;
1480
- }
2536
+ function kt(e) {
2537
+ let t = e.sessionId || "";
2538
+ if (!t || !e.approvalRequestId) return null;
2539
+ let n = $.get(t, e.approvalRequestId);
2540
+ return n?.source === "agui" && n.kind === "structured_input" ? E(n.status) ? n : ($.resolveLocally(t, n.interactionId, {
2541
+ status: e.decision === "cancelled" ? "cancelled" : "resolved",
2542
+ outcome: e.decision === "cancelled" ? "cancelled" : "submitted",
2543
+ revision: e.revision || 2,
2544
+ actor: "user"
2545
+ }), $.get(t, n.interactionId)) : Tt({
2546
+ EventType: "approval.resolved",
2547
+ Content: {
2548
+ approvalId: e.approvalRequestId,
2549
+ revision: e.revision || 2,
2550
+ outcome: e.decision,
2551
+ actor: "user",
2552
+ resolvedAt: (/* @__PURE__ */ new Date()).toISOString()
2553
+ }
2554
+ }, t);
1481
2555
  }
1482
- function Q(e, t) {
1483
- let r = J();
1484
- function i(t, n, a) {
1485
- if (r(), a > 48) throw new q();
1486
- let o = Y(t, e, r);
1487
- return o.some(X) ? null : Array.isArray(n) ? n.map((e, t) => {
1488
- let n = [];
1489
- for (let e of o) {
1490
- let r = Array.isArray(e.prefixItems) ? e.prefixItems : void 0, i = Array.isArray(e.items) ? e.items : void 0;
1491
- n.push(r && t < r.length ? r[t] : i ? t < i.length ? i[t] : e.additionalItems ?? {} : e.items ?? {});
1492
- for (let t of ["contains", "unevaluatedItems"]) Object.hasOwn(e, t) && n.push(e[t]);
1493
- }
1494
- return i(n, e, a + 1);
1495
- }) : typeof n != "object" || !n ? n : Object.fromEntries(Object.entries(n).map(([e, t]) => {
1496
- let n = [];
1497
- for (let t of o) {
1498
- let r = K(t.properties), i = !!(r && Object.hasOwn(r, e));
1499
- i && n.push(r[e]);
1500
- for (let [r, a] of Object.entries(K(t.patternProperties) || {})) new RegExp(r).test(e) && (i = !0, n.push(a));
1501
- !i && Object.hasOwn(t, "additionalProperties") && n.push(t.additionalProperties), Object.hasOwn(t, "unevaluatedProperties") && n.push(t.unevaluatedProperties);
1502
- }
1503
- return [e, i(n, t, a + 1)];
1504
- }));
1505
- }
1506
- try {
1507
- return n(t), i([e], t, 0);
1508
- } catch {
1509
- return null;
1510
- }
2556
+ function At(e) {
2557
+ let t = $.get(e.sessionId || "", e.interactionId);
2558
+ !t || t.source !== "agui" || E(t.status) || $.markFailed(t.sessionId, t.interactionId, {
2559
+ code: "input_response_invalid",
2560
+ message: e.message,
2561
+ retryable: !0
2562
+ });
1511
2563
  }
1512
- function Ae(e) {
1513
- if (!(e.kind !== "structured_input" || e.status !== "resolved" || e.outcome !== "submitted" || !e.requestSchema || !Object.hasOwn(e, "response"))) try {
1514
- return { value: Q(e.requestSchema, n(e.response)) };
1515
- } catch {
1516
- return;
1517
- }
2564
+ //#endregion
2565
+ //#region src/core/a2ui/provider.tsx
2566
+ var jt = s(Y);
2567
+ function Mt({ registry: e, children: t }) {
2568
+ return /* @__PURE__ */ u(jt.Provider, {
2569
+ value: e,
2570
+ children: t
2571
+ });
2572
+ }
2573
+ function Nt() {
2574
+ return c(jt);
1518
2575
  }
1519
2576
  //#endregion
1520
2577
  //#region src/core/run/a2ui.ts
1521
- var $ = {
2578
+ var Pt = {
1522
2579
  description: "A2UI Component Schema — available components for generating UI surfaces. Use these component names and properties when creating A2UI operations.",
1523
2580
  value: JSON.stringify({
1524
- ...A,
1525
- ksadkManifest: j
2581
+ ...U,
2582
+ ksadkManifest: W
1526
2583
  })
1527
2584
  };
1528
- function je(e = B) {
1529
- if (e === B) return $;
2585
+ function Ft(e = Y) {
2586
+ if (e === Y) return Pt;
1530
2587
  let t = e.get(e.defaultCatalogId);
1531
2588
  return {
1532
- description: $.description,
2589
+ description: Pt.description,
1533
2590
  value: JSON.stringify({
1534
2591
  ...t.schema,
1535
2592
  ksadkResources: t.resources,
@@ -1541,7 +2598,7 @@ function je(e = B) {
1541
2598
  })
1542
2599
  };
1543
2600
  }
1544
- function Me(e) {
2601
+ function It(e) {
1545
2602
  return e.map((e) => {
1546
2603
  let t = e.updateComponents;
1547
2604
  if (!t || typeof t != "object" || Array.isArray(t)) return e;
@@ -1564,7 +2621,7 @@ function Me(e) {
1564
2621
  };
1565
2622
  });
1566
2623
  }
1567
- function Ne(e) {
2624
+ function Lt(e) {
1568
2625
  for (let t of e) {
1569
2626
  let e = t.updateComponents?.components;
1570
2627
  if (!Array.isArray(e) || !e.some((e) => e.component === "Form" && e.id === "form")) continue;
@@ -1574,4 +2631,4 @@ function Ne(e) {
1574
2631
  return null;
1575
2632
  }
1576
2633
  //#endregion
1577
- export { ce as C, ae as D, oe as E, de as S, v as T, z as _, Q as a, fe as b, Oe as c, Te as d, ve as f, _e as g, ge as h, Z as i, we as l, xe as m, Ne as n, Ae as o, H as p, Me as r, De as s, je as t, Ce as u, B as v, y as w, w as x, M as y };
2634
+ export { Ie as A, Te as B, R as C, O as D, Ke as E, E as F, ve as G, we as H, ke as I, ue as J, fe as K, Ce as L, He as M, D as N, Fe as O, je as P, xe as R, rt as S, et as T, Oe as U, w as V, he as W, oe as X, ce as Y, ht as _, Nt as a, B as b, At as c, Ot as d, Tt as f, bt as g, vt as h, Mt as i, k as j, Ue as k, wt as l, gt as m, Lt as n, Et as o, $ as p, x as q, It as r, kt as s, Ft as t, Dt as u, Y as v, it as w, z as x, G as y, Se as z };