@kingsoftcloud/ksadk-web 0.3.18 → 0.3.20
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.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-Cdr5C_vM.js → ArtifactsPanel-xJrZLoUS.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-BWRafud9.js → CodeBlock-BTA9jlFc.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-CFKeJIvy.js → MathMessageMarkdown-D8CLDYjs.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-BneAGUOd.js → MermaidBlock-3yYZbQx6.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-BHI85zDO.js → NativeTerminalPanel-D4Ndrv99.js} +1 -1
- package/dist-ksadk/assets/{OfficialA2uiRenderer-BOmT36lJ.js → OfficialA2uiRenderer-B8MknRNx.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-DQvlOsBI.js → abnfDiagram-VCTEODGH-F1iqB6Wc.js} +1 -1
- package/dist-ksadk/assets/{arc-CGx0e4pN.js → arc-flL4n_cG.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-CVbS66_3.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-WyybcNKX.js → architectureDiagram-5GKGNRK7-BwmlMIkR.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-C9Cx_GVs.js → blockDiagram-NRAW4CY4-C_BWAm_x.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-Bh7X3bGr.js → c4Diagram-UCG6FXSJ-82fRziw1.js} +1 -1
- package/dist-ksadk/assets/channel-BRWZD-yc.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-WPKdx1wk.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-cP9XupZj.js → chunk-5VM5RSS4-C1Ojz8Pw.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-Bm77fvR9.js → chunk-F27PBJKO-BBOOiT8C.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-DDKNPesQ.js → chunk-G27WJ6UU-BhhwsUX3.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-BqiUDB7s.js → chunk-JWPE2WC7-iEW3AJI-.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-C528mMZy.js → chunk-LCL6LL3I-DIuXy-81.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-CzZ9g_Uf.js → chunk-POPQ4Y6H-ykIsvKaZ.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-CXj4tUZ-.js → chunk-RHFEMEQ7-CNMnEM31.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-BHyd85pS.js → chunk-SVP7TREG-C1xb4D9y.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-Qe29PHGe.js → chunk-XXDRQBXY-np-DgwXJ.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-B9FzdGp4.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-B9FzdGp4.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-maRKgeec.js → cose-bilkent-JH36ORCC-BTnDFOg9.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-BdJIG45e.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-CoD0bEvn.js → cynefinDiagram-5FMLGOSQ-BhCQoeu0.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-BkpgQqyW.js → dagre-3AP2YEHR-QU3SAyBp.js} +1 -1
- package/dist-ksadk/assets/{dagre-BUaTFrYa.js → dagre-CcBuTmO1.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-25HdTbjE.js → diagram-S7CK7UJ4-pUqMF-N_.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-KO-WqOIg.js → diagram-UQ7AKVKN-CsBd6UK1.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-B360BkDQ.js → diagram-VSXAHHWV-z067B8w9.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-COr1Oqsg.js → diagram-VX7I27RA-Bq2OSM3W.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-CgaKrIwB.js → diagram-Z3DM3KII-CGcOnXgQ.js} +1 -1
- package/dist-ksadk/assets/{dist-CwnkOyDn.js → dist-29mR2j1z.js} +1 -1
- package/dist-ksadk/assets/{dist-C9BTMVwS.js → dist-B7wGQtoN.js} +1 -1
- package/dist-ksadk/assets/{dist-_0Xgu_07.js → dist-B82Nq4cr.js} +1 -1
- package/dist-ksadk/assets/{dist-DKG0OYnk.js → dist-BBhjV2zk.js} +1 -1
- package/dist-ksadk/assets/{dist-Brbrdmff.js → dist-BCeJUhFK.js} +1 -1
- package/dist-ksadk/assets/{dist-DgJ57sRe.js → dist-BFwycVyB.js} +1 -1
- package/dist-ksadk/assets/{dist-CxIl4t92.js → dist-BgNv7i6A.js} +1 -1
- package/dist-ksadk/assets/{dist-BoRn8a_t.js → dist-BzzV3E1A.js} +1 -1
- package/dist-ksadk/assets/{dist-CR61WJFC.js → dist-CDVF37r5.js} +1 -1
- package/dist-ksadk/assets/{dist-Bsuusoi0.js → dist-CldkDS2P.js} +1 -1
- package/dist-ksadk/assets/{dist-CBo9AHUv.js → dist-CtBVJsc4.js} +1 -1
- package/dist-ksadk/assets/{dist--HftQyp9.js → dist-D2pftL-p.js} +1 -1
- package/dist-ksadk/assets/{dist-DmWw0IXB.js → dist-D4i4A-9H.js} +1 -1
- package/dist-ksadk/assets/{dist-DzdXSBJb.js → dist-DAvQipED.js} +1 -1
- package/dist-ksadk/assets/{dist-B3Jp5r1e.js → dist-DClJp8Fu.js} +1 -1
- package/dist-ksadk/assets/{dist-DXOlCAay.js → dist-DLBTehW7.js} +1 -1
- package/dist-ksadk/assets/{dist-By-MVndb.js → dist-DaTlP0PP.js} +1 -1
- package/dist-ksadk/assets/{dist-BQ116UdZ.js → dist-DkIK9AMC.js} +1 -1
- package/dist-ksadk/assets/{dist-HHvdjADB.js → dist-DoI7sPXP.js} +1 -1
- package/dist-ksadk/assets/{dist-BEbS8Bag.js → dist-DoiIiZp1.js} +1 -1
- package/dist-ksadk/assets/{dist-DSw5Ju6-.js → dist-Hq4SADW4.js} +1 -1
- package/dist-ksadk/assets/{dist-Bxcu8Ca0.js → dist-uTNKHquK.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-DogDP2db.js → ebnfDiagram-PWID7BFC-B3R_tmjW.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CeBDnUjR.js → erDiagram-SSCWMZ5O-J2nOSrdM.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DYpyM1Bl.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BTndHsf4.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-oIQL3MCp.js → ganttDiagram-EL5Y4UJY-C8RKSSnW.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-K0gsLZ8v.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js → gitGraphDiagram-WWUBYQGX--TydsWqh.js} +1 -1
- package/dist-ksadk/assets/index-B9UP7He9.css +2 -0
- package/dist-ksadk/assets/index-BkjYckSc.js +1135 -0
- package/dist-ksadk/assets/info-A6RAGUB7-rivQEqA4.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-yQRC41Ya.js → infoDiagram-RXCK75RN-D6sVWyle.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-BCu4HiwL.js → ishikawaDiagram-5VMMS53U-DrclE7fd.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-JaqmO73K.js → journeyDiagram-EYS64GPL-BRfZiBbu.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-DQo4X8NO.js → kanban-definition-3QL26DDD-CNybbrEd.js} +1 -1
- package/dist-ksadk/assets/{katex-t_DWylQw.js → katex-DBOw26LR.js} +1 -1
- package/dist-ksadk/assets/{linear-DWdnI35B.js → linear-44nYnHX-.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-BHrT2Pfe.js → mermaid-parser.core-C_kQii2V.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-PBVAhZYV.js → mindmap-definition-FBJOCRG2-BVRrbrEZ.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BWH3_z2P.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-CU_cLfow.js → pegDiagram-XKGWAZYB-DegSzNRD.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-YFDBqoLw.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-B1h0-_pW.js → pieDiagram-E7YTZNPT-CxdzAjVe.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-DEMoGo5a.js → quadrantDiagram-AXDQQJYC-CCoPOep-.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-Dyl_dza9.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-BP48ZU0l.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BLZ-Uq2U.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-EZUa4Mwx.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-HrWsR5Xv.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-BTAob2wg.js → railroadDiagram-O6MQD6OU-c0A7TkkT.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js → requirementDiagram-EFPCY7ZU-P6gr0KYk.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-DeaTWkur.js → sankeyDiagram-P5KCCOFB-DC4nZ3Da.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-gFQYrsOd.js → sequenceDiagram-WJ2MYXX4-CZtmOwJw.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-pGQzddMB.js → sizeCapture-X5ZJPWSS-Co1bu09k.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DmpYOZt1.js → stateDiagram-HBIQ2CUA-BQVjMByH.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BdDvoPqK.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-BfuSAsrr.js → swimlanes-XN3QIQJK-hlr6yX7f.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-CVQOLHam.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-CgJwrrxf.js → timeline-definition-24CTP7MA-CvlFQUAe.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-B5KEc2LE.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-Ctt8lBKu.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-CBSAgXDd.js → vennDiagram-4TSXK5OY-TSlD8LZX.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-DVbqgmoi.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-013TZ2JZ.js → wardleyDiagram-VM6X3IG4-COY6_ZHj.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-u6Frp8xp.js → xychartDiagram-S5SC5T6Z-DbaIT_9a.js} +1 -1
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/{AttachmentPreview-Dhc6ulFv.js → AttachmentPreview-DPxeFYm-.js} +76 -76
- package/dist-lib/{ConnectedComposer-Cc6bqJmu.js → ConnectedComposer-CVMfDdns.js} +47 -47
- package/dist-lib/ConnectedMessageList-BnRqhlEn.js +2016 -0
- package/dist-lib/{WorkspacePanelContainer-_PuvSz_J.js → WorkspacePanelContainer-3h8wgDJj.js} +16 -16
- package/dist-lib/{a2ui-DihCxdtQ.js → a2ui-DmynyrCk.js} +31 -31
- package/dist-lib/api/client.d.ts +3 -1
- package/dist-lib/api/client.d.ts.map +1 -1
- package/dist-lib/api/messages.d.ts +40 -0
- package/dist-lib/api/messages.d.ts.map +1 -1
- package/dist-lib/chat-composer.js +2 -2
- package/dist-lib/chat-timeline.js +5 -5
- package/dist-lib/components/chat/ChatMessageList.d.ts +5 -1
- package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/ConnectedMessageList.d.ts +2 -1
- package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/DeferredHistoryContent.d.ts +6 -0
- package/dist-lib/components/chat/DeferredHistoryContent.d.ts.map +1 -0
- package/dist-lib/components/chat/HistoryAnchoredRows.d.ts +44 -0
- package/dist-lib/components/chat/HistoryAnchoredRows.d.ts.map +1 -0
- package/dist-lib/components/chat/ProcessingBlocksView.d.ts +0 -7
- package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
- package/dist-lib/components/chat/history-reading-anchor.d.ts +16 -0
- package/dist-lib/components/chat/history-reading-anchor.d.ts.map +1 -0
- package/dist-lib/components/chat/types.d.ts +12 -0
- package/dist-lib/components/chat/types.d.ts.map +1 -1
- package/dist-lib/components.js +7 -7
- package/dist-lib/conversation.js +2 -2
- package/dist-lib/core/api/facade.d.ts +3 -17
- package/dist-lib/core/api/facade.d.ts.map +1 -1
- package/dist-lib/core/api/types.d.ts +2 -24
- package/dist-lib/core/api/types.d.ts.map +1 -1
- package/dist-lib/core/conversation/hosted.d.ts +1 -1
- package/dist-lib/core/conversation/hosted.d.ts.map +1 -1
- package/dist-lib/core/run/agui.d.ts +3 -2
- package/dist-lib/core/run/agui.d.ts.map +1 -1
- package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
- package/dist-lib/core/run/engine.d.ts +6 -1
- package/dist-lib/core/run/engine.d.ts.map +1 -1
- package/dist-lib/core/run/types.d.ts +5 -0
- package/dist-lib/core/run/types.d.ts.map +1 -1
- package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
- package/dist-lib/hooks/useRunAgent.d.ts +3 -1
- package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts +5 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
- package/dist-lib/hooks.js +119 -117
- package/dist-lib/{permission-DGyt7wBj.js → permission-B60mkAsy.js} +1 -1
- package/dist-lib/{persisted-session-history-Bh_6zSKC.js → persisted-session-history-B9O1vWtS.js} +364 -337
- package/dist-lib/runtime.js +208 -205
- package/dist-lib/{session-events-DvFsVXpD.js → session-events-COiszsgX.js} +233 -220
- package/dist-lib/{feedback-BBJKMdF2.js → session-message-history-DC89pksC.js} +10 -2
- package/dist-lib/stores/session.d.ts +4 -0
- package/dist-lib/stores/session.d.ts.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/{useSessionLifecycle-u7i_h_io.js → useSessionLifecycle-B0RRKS9m.js} +1950 -1019
- package/dist-lib/utils/history-content.d.ts +16 -0
- package/dist-lib/utils/history-content.d.ts.map +1 -0
- package/dist-lib/utils/history-tool-facts.d.ts.map +1 -1
- package/dist-lib/utils/message-virtualization.d.ts +24 -2
- package/dist-lib/utils/message-virtualization.d.ts.map +1 -1
- package/dist-lib/utils/persisted-session-history.d.ts +1 -1
- package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
- package/dist-lib/utils/session-event-history.d.ts +3 -1
- package/dist-lib/utils/session-event-history.d.ts.map +1 -1
- package/dist-lib/utils/session-events.d.ts +4 -1
- package/dist-lib/utils/session-events.d.ts.map +1 -1
- package/dist-lib/utils/session-items.d.ts +36 -0
- package/dist-lib/utils/session-items.d.ts.map +1 -0
- package/dist-lib/utils/session-message-history.d.ts +2 -0
- package/dist-lib/utils/session-message-history.d.ts.map +1 -1
- package/dist-lib/utils/transcript-order.d.ts +2 -1
- package/dist-lib/utils/transcript-order.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-CFWjFkDL.js +0 -1
- package/dist-ksadk/assets/channel-D6Dp_l74.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-CwmjhFYK.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-CBZRVuc4.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-BUWSkncI.js +0 -1
- package/dist-ksadk/assets/index-4g1ndaxW.js +0 -1132
- package/dist-ksadk/assets/index-DEVfafsU.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-CzJ_YrOs.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-CXoos6fx.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-CjF9NoIt.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-BQGWs9nw.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-B6znvLUK.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-DtMdDH8N.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-VoU8QtLZ.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-YWSRB0Zm.js +0 -1
- package/dist-lib/ConnectedMessageList-Bdd-qjs-.js +0 -1621
package/dist-lib/{persisted-session-history-Bh_6zSKC.js → persisted-session-history-B9O1vWtS.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as e, b as t, f as n, n as r, r as i } from "./session-events-
|
|
1
|
+
import { S as e, b as t, f as n, n as r, r as i } from "./session-events-COiszsgX.js";
|
|
2
2
|
import { d as a, i as o, l as s, o as c, p as l, t as u, u as d } from "./reducer-mbYiX0wz.js";
|
|
3
3
|
//#region src/core/conversation/safe-tool-value.ts
|
|
4
4
|
var f = [
|
|
@@ -289,7 +289,7 @@ function T(e, t) {
|
|
|
289
289
|
let n = e.map((e) => JSON.stringify(e)), r = t.map((e) => JSON.stringify(e));
|
|
290
290
|
return n.every((e, t) => r[t] === e) ? t : r.every((e, t) => n[t] === e) ? e : [...e, ...t];
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function E(e, t, n) {
|
|
293
293
|
let r = {
|
|
294
294
|
...t.runId || e?.runId ? { runId: t.runId || e?.runId } : {},
|
|
295
295
|
...t.interactionId || e?.interactionId ? { interactionId: t.interactionId || e?.interactionId } : {},
|
|
@@ -311,22 +311,22 @@ function ee(e, t, n) {
|
|
|
311
311
|
}
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/core/a2ui/transcript.ts
|
|
314
|
-
function
|
|
314
|
+
function ee(e, t) {
|
|
315
315
|
if (e.activity.surfaceId !== t.activity.surfaceId) return !1;
|
|
316
316
|
let n = e.activity.interactionId, r = t.activity.interactionId;
|
|
317
317
|
if (n && r) return n === r;
|
|
318
318
|
let i = e.activity.runId || e.message.runId || e.message.invocationId, a = t.activity.runId || t.message.runId || t.message.invocationId;
|
|
319
319
|
return i && a ? i === a : (e.activity.originMessageId || e.message.id) === (t.activity.originMessageId || t.message.id);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
322
|
-
let n = e.filter((e) =>
|
|
321
|
+
function D(e, t) {
|
|
322
|
+
let n = e.filter((e) => ee(e, t));
|
|
323
323
|
return n.length === 1 ? n[0] : void 0;
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function O(e) {
|
|
326
326
|
if (!e.some((e) => e.aguiActivity || e.aguiActivities?.length)) return e;
|
|
327
327
|
let t = /* @__PURE__ */ new Map(), n = !1, r = e.map((e) => {
|
|
328
328
|
let r = (r) => {
|
|
329
|
-
let i = t.get(r.surfaceId) || [], a =
|
|
329
|
+
let i = t.get(r.surfaceId) || [], a = D(i, {
|
|
330
330
|
message: e,
|
|
331
331
|
activity: r
|
|
332
332
|
});
|
|
@@ -357,7 +357,7 @@ function ne(e) {
|
|
|
357
357
|
}
|
|
358
358
|
//#endregion
|
|
359
359
|
//#region src/core/conversation/presentation.ts
|
|
360
|
-
var
|
|
360
|
+
var te = {
|
|
361
361
|
user_message: "conversation.item.user_message/v1",
|
|
362
362
|
assistant_text: "conversation.item.assistant_text/v1",
|
|
363
363
|
reasoning: "conversation.item.reasoning/v1",
|
|
@@ -368,10 +368,10 @@ var re = {
|
|
|
368
368
|
a2ui: "conversation.item.a2ui/v1",
|
|
369
369
|
error: "conversation.item.error/v1"
|
|
370
370
|
};
|
|
371
|
-
function
|
|
371
|
+
function ne(e) {
|
|
372
372
|
return e.lifecycle === "completed" || e.lifecycle === "failed";
|
|
373
373
|
}
|
|
374
|
-
var
|
|
374
|
+
var re = new Set([
|
|
375
375
|
"aborted",
|
|
376
376
|
"canceled",
|
|
377
377
|
"cancelled",
|
|
@@ -379,17 +379,17 @@ var ae = new Set([
|
|
|
379
379
|
"incomplete",
|
|
380
380
|
"interrupted"
|
|
381
381
|
]);
|
|
382
|
-
function
|
|
383
|
-
if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !
|
|
382
|
+
function k(e) {
|
|
383
|
+
if (e.parentItemId || e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || e.kind !== "progress" && e.kind !== "error" || !ne(e)) return;
|
|
384
384
|
let t = typeof e.payload.status == "string" ? e.payload.status.toLowerCase() : "";
|
|
385
385
|
if (t === "completed") return "completed";
|
|
386
|
-
if (
|
|
386
|
+
if (re.has(t)) return "failed";
|
|
387
387
|
}
|
|
388
|
-
function
|
|
389
|
-
let t =
|
|
388
|
+
function ie(e) {
|
|
389
|
+
let t = te[e.kind];
|
|
390
390
|
return t === void 0 || t === e.payloadSchemaRef;
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function ae(e) {
|
|
393
393
|
if (typeof e != "string" || e.length === 0) return null;
|
|
394
394
|
try {
|
|
395
395
|
let t = new URL(e);
|
|
@@ -398,7 +398,7 @@ function se(e) {
|
|
|
398
398
|
return null;
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function oe(e) {
|
|
402
402
|
return {
|
|
403
403
|
id: e.itemId,
|
|
404
404
|
parentId: e.parentItemId || null,
|
|
@@ -408,8 +408,8 @@ function ce(e) {
|
|
|
408
408
|
lifecycle: e.lifecycle
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
let t = typeof e.payload.artifactId == "string" && e.payload.artifactId ? e.payload.artifactId : e.itemId, n = e.payload.sizeBytes ?? e.payload.size, r = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : null, i =
|
|
411
|
+
function se(e) {
|
|
412
|
+
let t = typeof e.payload.artifactId == "string" && e.payload.artifactId ? e.payload.artifactId : e.itemId, n = e.payload.sizeBytes ?? e.payload.size, r = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : null, i = ae(e.payload.uri);
|
|
413
413
|
return {
|
|
414
414
|
artifactId: t,
|
|
415
415
|
itemId: e.itemId,
|
|
@@ -423,13 +423,13 @@ function le(e) {
|
|
|
423
423
|
uri: i
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function A(e, t) {
|
|
427
427
|
let n = e.payload[t];
|
|
428
428
|
return typeof n == "string" && n ? n : null;
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function j(e, t) {
|
|
431
431
|
if (e.kind === "tool_call") {
|
|
432
|
-
let n =
|
|
432
|
+
let n = A(e, "callId");
|
|
433
433
|
if (n) return `tool:${JSON.stringify([
|
|
434
434
|
e.runId,
|
|
435
435
|
t ?? (e.nativeRef.scopeId || e.nativeRef.scope_id || ""),
|
|
@@ -437,17 +437,17 @@ function k(e, t) {
|
|
|
437
437
|
])}`;
|
|
438
438
|
}
|
|
439
439
|
if (e.kind === "approval") {
|
|
440
|
-
let t =
|
|
440
|
+
let t = A(e, "interactionId");
|
|
441
441
|
if (t) return `approval:${t}`;
|
|
442
442
|
}
|
|
443
443
|
if (e.kind === "a2ui") {
|
|
444
|
-
let t =
|
|
444
|
+
let t = A(e, "surfaceId");
|
|
445
445
|
if (t) return `a2ui:${JSON.stringify([e.runId, t])}`;
|
|
446
446
|
}
|
|
447
447
|
return `item:${e.itemId}`;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
let n =
|
|
449
|
+
function ce(e, t) {
|
|
450
|
+
let n = ne(e) && !ne(t), r = e.kind === "a2ui" && t.kind === "a2ui" && Array.isArray(e.payload.data) && Array.isArray(t.payload.data) ? { data: T(e.payload.data, t.payload.data) } : {};
|
|
451
451
|
return {
|
|
452
452
|
...e,
|
|
453
453
|
...t,
|
|
@@ -473,32 +473,32 @@ function ue(e, t) {
|
|
|
473
473
|
} : {}
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function le(e) {
|
|
477
477
|
let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
478
478
|
let t = e.nativeRef.parentScopeId;
|
|
479
|
-
return e.nativeRef.framework === "langgraph" && e.kind === "tool_call" && e.payload.sourceKind === "tool_result" && e.payload.callId && typeof t == "string" ?
|
|
479
|
+
return e.nativeRef.framework === "langgraph" && e.kind === "tool_call" && e.payload.sourceKind === "tool_result" && e.payload.callId && typeof t == "string" ? j(e, t) : void 0;
|
|
480
480
|
};
|
|
481
481
|
for (let t of e) {
|
|
482
482
|
if (t.nativeRef.framework === "langgraph" && t.payload.sourceKind === "tool_call") {
|
|
483
|
-
let e =
|
|
483
|
+
let e = j(t);
|
|
484
484
|
i.set(e, (i.get(e) ?? 0) + 1);
|
|
485
485
|
}
|
|
486
|
-
t.kind === "tool_call" && t.payload.sourceKind === "tool_result" && a.add(
|
|
486
|
+
t.kind === "tool_call" && t.payload.sourceKind === "tool_result" && a.add(j(t));
|
|
487
487
|
let e = s(t);
|
|
488
488
|
e && o.set(e, (o.get(e) ?? 0) + 1);
|
|
489
489
|
}
|
|
490
490
|
for (let c of e) {
|
|
491
|
-
let e =
|
|
492
|
-
surfaceId:
|
|
491
|
+
let e = j(c), l = s(c), u = l && !i.has(e) && !a.has(l) && i.get(l) === 1 && o.get(l) === 1 ? l : e, d = c.kind === "a2ui" ? {
|
|
492
|
+
surfaceId: A(c, "surfaceId") || "",
|
|
493
493
|
messages: [],
|
|
494
|
-
...
|
|
494
|
+
...A(c, "interactionId") ? { interactionId: A(c, "interactionId") } : {}
|
|
495
495
|
} : null, f = d ? {
|
|
496
496
|
message: {
|
|
497
497
|
id: c.itemId,
|
|
498
498
|
runId: c.runId
|
|
499
499
|
},
|
|
500
500
|
activity: d
|
|
501
|
-
} : null, p = r.get(u) || [], m = f ?
|
|
501
|
+
} : null, p = r.get(u) || [], m = f ? D(p, f) : void 0, h = f ? m?.index : n.get(u);
|
|
502
502
|
if (h === void 0) {
|
|
503
503
|
f ? r.set(u, [...p, {
|
|
504
504
|
...f,
|
|
@@ -514,7 +514,7 @@ function de(e) {
|
|
|
514
514
|
let g = t[h];
|
|
515
515
|
t[h] = {
|
|
516
516
|
key: g.key,
|
|
517
|
-
item:
|
|
517
|
+
item: ce(g.item, c),
|
|
518
518
|
sourceItemIds: [...new Set([...g.sourceItemIds, c.itemId])]
|
|
519
519
|
};
|
|
520
520
|
}
|
|
@@ -529,29 +529,29 @@ function de(e) {
|
|
|
529
529
|
}
|
|
530
530
|
} : t);
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function ue(e, t) {
|
|
533
533
|
let n = e.payload.trigger_ref;
|
|
534
534
|
return n ? t.filter((t) => t.kind === "tool_call" && t.runId === e.runId && (t.nativeRef.scopeId || t.nativeRef.scope_id) === n.scope_id && (t.payload.callId === n.call_id || t.itemId === e.parentItemId)) : [];
|
|
535
535
|
}
|
|
536
|
-
function
|
|
537
|
-
let t = e.filter((e) => e.kind === "agent"), n = (e) => String(e.nativeRef.scopeId || e.nativeRef.scope_id || ""), r = (e) => t.find((t) => t.runId === e.runId && t.itemId !== e.itemId && (e.parentItemId === t.itemId || (e.kind === "agent" ? e.payload.parent_scope_id === t.payload.scope_id : n(e) && n(e) === String(t.payload.scope_id)))), i = new Set(t.flatMap((t) =>
|
|
536
|
+
function de(e) {
|
|
537
|
+
let t = e.filter((e) => e.kind === "agent"), n = (e) => String(e.nativeRef.scopeId || e.nativeRef.scope_id || ""), r = (e) => t.find((t) => t.runId === e.runId && t.itemId !== e.itemId && (e.parentItemId === t.itemId || (e.kind === "agent" ? e.payload.parent_scope_id === t.payload.scope_id : n(e) && n(e) === String(t.payload.scope_id)))), i = new Set(t.flatMap((t) => ue(t, e).map((e) => e.itemId))), a = e.filter((e) => !r(e) && !i.has(e.itemId));
|
|
538
538
|
return a.sort((t, n) => {
|
|
539
539
|
let r = (t) => t.kind === "agent" && t.parentItemId && e.some((e) => e.itemId === t.parentItemId) ? e.findIndex((e) => e.itemId === t.parentItemId) : e.indexOf(t);
|
|
540
540
|
return r(t) - r(n);
|
|
541
|
-
}),
|
|
541
|
+
}), le(a).map((t) => {
|
|
542
542
|
if (t.item.kind !== "agent") return t;
|
|
543
|
-
let n =
|
|
543
|
+
let n = le(e.filter((e) => r(e) === t.item && !i.has(e.itemId)));
|
|
544
544
|
return {
|
|
545
545
|
...t,
|
|
546
|
-
sourceItemIds: [...new Set([...
|
|
546
|
+
sourceItemIds: [...new Set([...ue(t.item, e).map((e) => e.itemId), ...t.sourceItemIds])],
|
|
547
547
|
children: n
|
|
548
548
|
};
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
|
-
function
|
|
551
|
+
function fe(e, t = {}) {
|
|
552
552
|
let n = e.items.filter((e) => e.visibility === "public" || t.includeInternal === !0 && e.visibility === "internal");
|
|
553
553
|
if (t.profile === "flat-v1" && n.some((e) => e.kind === "agent")) {
|
|
554
|
-
let e = n.filter((e) => e.kind === "agent"), t = new Set(e.flatMap((e) =>
|
|
554
|
+
let e = n.filter((e) => e.kind === "agent"), t = new Set(e.flatMap((e) => ue(e, n).map((e) => e.itemId))), r = (t) => e.some((e) => e.runId === t.runId && (t.parentItemId === e.itemId || typeof e.payload.scope_id == "string" && e.payload.scope_id.length > 0 && e.payload.scope_id === (t.nativeRef.scopeId || t.nativeRef.scope_id))), i = n.find((e) => k(e)), a = n.filter((e) => e.kind !== "agent" && (e.kind === "error" || !r(e) && !t.has(e.itemId))), o = i?.payload.outputRefs || i?.payload.output_refs;
|
|
555
555
|
Array.isArray(o) && o.length && (a = a.filter((e) => e.kind !== "assistant_text" || o.some((t) => e.nativeRef.scopeId === t.scope_id && e.nativeRef.runtimeItemId === t.item_id)));
|
|
556
556
|
let s = a.filter((e) => e.kind === "assistant_text");
|
|
557
557
|
if (i && !s.some((e) => e.payload.text) && Array.isArray(o)) {
|
|
@@ -567,13 +567,13 @@ function me(e, t = {}) {
|
|
|
567
567
|
}
|
|
568
568
|
n = a.filter((e) => e.kind !== "assistant_text" || !!i);
|
|
569
569
|
}
|
|
570
|
-
let r = n.filter(
|
|
570
|
+
let r = n.filter(ie), i = n.filter((e) => !ie(e)), a = new Set([
|
|
571
571
|
"user_message",
|
|
572
572
|
"assistant_text",
|
|
573
573
|
"reasoning"
|
|
574
|
-
]), o = r.filter((e) => a.has(e.kind)).map(
|
|
574
|
+
]), o = r.filter((e) => a.has(e.kind)).map(oe), s = (e) => e.nativeRef.parentScopeId || e.nativeRef.parent_scope_id || r.some((t) => t.kind === "agent" && (e.parentItemId === t.itemId || t.runId === e.runId && t.payload.scope_id === (e.nativeRef.scopeId || e.nativeRef.scope_id))), c = (e) => r.filter((t) => t.kind === e && !s(t)).map((e) => typeof e.payload.text == "string" ? e.payload.text : "").join(""), l = [...r.filter((e) => e.kind === "unknown"), ...i], u = r.filter((e) => e.kind === "error"), d = [...r].reverse().find((e) => k(e) !== void 0);
|
|
575
575
|
return {
|
|
576
|
-
timeline:
|
|
576
|
+
timeline: de(r.filter((e) => e.kind !== "progress")),
|
|
577
577
|
output: c("assistant_text"),
|
|
578
578
|
reasoning: c("reasoning"),
|
|
579
579
|
textItems: o,
|
|
@@ -581,7 +581,7 @@ function me(e, t = {}) {
|
|
|
581
581
|
approvalItems: r.filter((e) => e.kind === "approval"),
|
|
582
582
|
structuredInputItems: r.filter((e) => e.kind === "progress" && e.payloadSchemaRef === "conversation.item.structured-input/v1"),
|
|
583
583
|
a2uiItems: r.filter((e) => e.kind === "a2ui"),
|
|
584
|
-
artifacts: r.filter((e) => e.kind === "artifact").map(
|
|
584
|
+
artifacts: r.filter((e) => e.kind === "artifact").map(se),
|
|
585
585
|
fallbacks: [...l.map((e) => ({
|
|
586
586
|
id: e.itemId,
|
|
587
587
|
title: "Unsupported content",
|
|
@@ -594,22 +594,22 @@ function me(e, t = {}) {
|
|
|
594
594
|
failed: !0
|
|
595
595
|
}))],
|
|
596
596
|
runId: n.at(-1)?.runId || "",
|
|
597
|
-
terminalStatus: d ?
|
|
597
|
+
terminalStatus: d ? k(d) : void 0
|
|
598
598
|
};
|
|
599
599
|
}
|
|
600
600
|
//#endregion
|
|
601
601
|
//#region src/core/conversation/client.ts
|
|
602
|
-
var
|
|
603
|
-
function
|
|
602
|
+
var M = 8;
|
|
603
|
+
function N(e) {
|
|
604
604
|
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function P(e) {
|
|
607
607
|
if (e?.aborted) throw new l("conversation_aborted", "Conversation request was aborted.");
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function pe(e, t) {
|
|
610
610
|
return t?.aborted === !0 || e instanceof Error && e.name === "AbortError";
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function me(e) {
|
|
613
613
|
let t = e.trim().replace(/\/+$/, "");
|
|
614
614
|
if (!t) return "";
|
|
615
615
|
if (!t.includes("://")) return t.startsWith("/") ? t : `/${t}`;
|
|
@@ -621,16 +621,16 @@ function ge(e) {
|
|
|
621
621
|
throw new l("conversation_contract_mismatch", "Conversation base URL must be an HTTP(S) URL without embedded credentials.", { cause: e });
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function he(e) {
|
|
625
625
|
return Math.min(200 * 2 ** Math.max(0, e - 1), 2e3);
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function ge(e) {
|
|
628
628
|
return new Promise((t) => {
|
|
629
629
|
setTimeout(t, e);
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
|
-
async function
|
|
633
|
-
if (
|
|
632
|
+
async function _e(e, t, n) {
|
|
633
|
+
if (P(n), !n) {
|
|
634
634
|
await e(t);
|
|
635
635
|
return;
|
|
636
636
|
}
|
|
@@ -641,16 +641,16 @@ async function ye(e, t, n) {
|
|
|
641
641
|
});
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function ve(e, t, n, r, i) {
|
|
645
645
|
let a = i ? i.snapshot() : e.snapshot();
|
|
646
646
|
return {
|
|
647
647
|
cursor: t,
|
|
648
648
|
runId: n,
|
|
649
649
|
state: a,
|
|
650
|
-
presentation:
|
|
650
|
+
presentation: fe(a, { profile: r })
|
|
651
651
|
};
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function ye(e, t) {
|
|
654
654
|
let n, r = [];
|
|
655
655
|
for (let t of e.split(/\r?\n/)) {
|
|
656
656
|
let e = t.endsWith("\r") ? t.slice(0, -1) : t;
|
|
@@ -670,7 +670,7 @@ function be(e, t) {
|
|
|
670
670
|
} catch (e) {
|
|
671
671
|
throw new l("conversation_contract_mismatch", "Conversation stream contains invalid JSON.", { cause: e });
|
|
672
672
|
}
|
|
673
|
-
let o =
|
|
673
|
+
let o = N(a), c = N(o?.runtimeEvent) || N(o?.runtime_event) || (o?.schema_version === 2 ? o : null);
|
|
674
674
|
if (!o || o.conversationItem === void 0 && !c) {
|
|
675
675
|
n !== void 0 && (t.cursor = Math.max(t.cursor, n));
|
|
676
676
|
return;
|
|
@@ -703,26 +703,26 @@ function be(e, t) {
|
|
|
703
703
|
} catch (e) {
|
|
704
704
|
throw new l("conversation_contract_mismatch", "Conversation identity or lifecycle invariant failed.", { cause: e });
|
|
705
705
|
}
|
|
706
|
-
t.cursor = Math.max(t.cursor, n), f && !(t.profile === "flat-v1" && d.nativeRef.parentScopeId) && t.options.onItem?.(d), t.options.onUpdate?.(
|
|
706
|
+
t.cursor = Math.max(t.cursor, n), f && !(t.profile === "flat-v1" && d.nativeRef.parentScopeId) && t.options.onItem?.(d), t.options.onUpdate?.(ve(t.reducer, t.cursor, t.runId, t.profile, t.lane === "runtime" ? t.runtime : void 0));
|
|
707
707
|
}
|
|
708
|
-
async function
|
|
708
|
+
async function be(e, t) {
|
|
709
709
|
if (!e.body) throw new l("conversation_stream_error", "Conversation response has no event stream body.");
|
|
710
710
|
let n = e.body.getReader(), r = new TextDecoder(), i = "";
|
|
711
711
|
try {
|
|
712
712
|
for (;;) {
|
|
713
|
-
|
|
713
|
+
P(t.options.signal);
|
|
714
714
|
let { value: e, done: a } = await n.read();
|
|
715
715
|
if (a) break;
|
|
716
716
|
i += r.decode(e, { stream: !0 });
|
|
717
717
|
let o = /\r?\n\r?\n/.exec(i);
|
|
718
718
|
for (; o?.index !== void 0;) {
|
|
719
719
|
let e = o.index, n = o[0].length;
|
|
720
|
-
|
|
720
|
+
ye(i.slice(0, e), t), i = i.slice(e + n), o = /\r?\n\r?\n/.exec(i);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
i += r.decode(), i.trim() &&
|
|
723
|
+
i += r.decode(), i.trim() && ye(i, t);
|
|
724
724
|
} catch (e) {
|
|
725
|
-
throw e instanceof l ? e : (
|
|
725
|
+
throw e instanceof l ? e : (pe(e, t.options.signal) && P(t.options.signal), new l("conversation_stream_error", "Conversation event stream was interrupted.", {
|
|
726
726
|
cause: e,
|
|
727
727
|
runId: t.runId || void 0,
|
|
728
728
|
cursor: t.cursor
|
|
@@ -731,10 +731,10 @@ async function xe(e, t) {
|
|
|
731
731
|
n.releaseLock();
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
function
|
|
735
|
-
return e.state.items.some((e) =>
|
|
734
|
+
function xe(e) {
|
|
735
|
+
return e.state.items.some((e) => k(e) !== void 0);
|
|
736
736
|
}
|
|
737
|
-
var
|
|
737
|
+
var Se = class {
|
|
738
738
|
fetcher;
|
|
739
739
|
ingressLane;
|
|
740
740
|
rendererCatalog;
|
|
@@ -743,8 +743,8 @@ var Ce = class {
|
|
|
743
743
|
sleep;
|
|
744
744
|
retryDelayMs;
|
|
745
745
|
constructor(e = {}) {
|
|
746
|
-
if (!Number.isInteger(e.maxReconnects ??
|
|
747
|
-
this.fetcher = e.fetch, this.rendererCatalog = e.rendererCatalog, this.ingressLane = e.ingressLane, this.baseUrl =
|
|
746
|
+
if (!Number.isInteger(e.maxReconnects ?? M) || (e.maxReconnects ?? M) < 0 || (e.maxReconnects ?? M) > 32) throw new l("conversation_contract_mismatch", "Conversation reconnect limit must be an integer from 0 to 32.");
|
|
747
|
+
this.fetcher = e.fetch, this.rendererCatalog = e.rendererCatalog, this.ingressLane = e.ingressLane, this.baseUrl = me(e.baseUrl || ""), this.maxReconnects = e.maxReconnects ?? M, this.sleep = e.sleep || ge, this.retryDelayMs = e.retryDelayMs || he;
|
|
748
748
|
}
|
|
749
749
|
fetch() {
|
|
750
750
|
if (this.fetcher) return this.fetcher;
|
|
@@ -755,11 +755,11 @@ var Ce = class {
|
|
|
755
755
|
return `${this.baseUrl}${e}`;
|
|
756
756
|
}
|
|
757
757
|
async request(e, t, n, r = "conversation_stream_error") {
|
|
758
|
-
|
|
758
|
+
P(n);
|
|
759
759
|
try {
|
|
760
760
|
return await this.fetch()(e, t);
|
|
761
761
|
} catch (e) {
|
|
762
|
-
throw e instanceof l ? e : (
|
|
762
|
+
throw e instanceof l ? e : (pe(e, n) && P(n), new l(r, "Conversation network request failed.", { cause: e }));
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
765
|
assertOk(e) {
|
|
@@ -775,7 +775,7 @@ var Ce = class {
|
|
|
775
775
|
} catch (e) {
|
|
776
776
|
throw new l("conversation_contract_mismatch", "Conversation surface response is not valid JSON.", { cause: e });
|
|
777
777
|
}
|
|
778
|
-
let o =
|
|
778
|
+
let o = N(a), s = d(o?.surface);
|
|
779
779
|
if (!o || typeof o.buildId != "string" || !o.buildId || !s) throw new l("conversation_contract_mismatch", "Conversation surface response does not match conversation.ksadk.io/v1.");
|
|
780
780
|
return {
|
|
781
781
|
buildId: o.buildId,
|
|
@@ -783,7 +783,7 @@ var Ce = class {
|
|
|
783
783
|
};
|
|
784
784
|
}
|
|
785
785
|
async streamTurn(e) {
|
|
786
|
-
|
|
786
|
+
P(e.signal);
|
|
787
787
|
let t = o(e.bootstrap.surface, this.rendererCatalog), n = {
|
|
788
788
|
...e.input,
|
|
789
789
|
...t === "agent-block-v1" || e.input.extensions?.["ksadk.presentation"] ? { extensions: {
|
|
@@ -813,27 +813,27 @@ var Ce = class {
|
|
|
813
813
|
}, p = await this.request(this.url(`/api/v1/builds/${encodeURIComponent(e.bootstrap.buildId)}/conversation:stream`), f, e.signal);
|
|
814
814
|
this.assertOk(p);
|
|
815
815
|
try {
|
|
816
|
-
await
|
|
816
|
+
await be(p, d);
|
|
817
817
|
} catch (e) {
|
|
818
818
|
if (!(e instanceof l) || e.code !== "conversation_stream_error" || !d.runId) throw e;
|
|
819
819
|
}
|
|
820
|
-
let m =
|
|
821
|
-
if (
|
|
820
|
+
let m = ve(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0);
|
|
821
|
+
if (xe(m)) return m;
|
|
822
822
|
if (!d.runId) throw new l("conversation_run_identity_missing", "The stream ended before a canonical item supplied its run identity.", { cursor: d.cursor });
|
|
823
823
|
for (let t = 1; t <= this.maxReconnects; t += 1) {
|
|
824
|
-
await
|
|
824
|
+
await _e(this.sleep, this.retryDelayMs(t), e.signal), P(e.signal);
|
|
825
825
|
let n;
|
|
826
826
|
try {
|
|
827
827
|
n = await this.request(this.url(`/api/v1/runs/${encodeURIComponent(d.runId)}/events?after=${d.cursor}${d.profile === "agent-block-v1" ? "&presentationProfile=agent-block-v1" : ""}`), {
|
|
828
828
|
method: "GET",
|
|
829
829
|
headers: { "Last-Event-ID": String(d.cursor) },
|
|
830
830
|
...e.signal ? { signal: e.signal } : {}
|
|
831
|
-
}, e.signal), this.assertOk(n), await
|
|
831
|
+
}, e.signal), this.assertOk(n), await be(n, d);
|
|
832
832
|
} catch (e) {
|
|
833
833
|
if (e instanceof l && e.code === "conversation_aborted" || e instanceof l && e.code === "conversation_contract_mismatch" || e instanceof l && e.code === "conversation_http_error" && e.status !== void 0 && e.status < 500) throw e;
|
|
834
834
|
continue;
|
|
835
835
|
}
|
|
836
|
-
if (m =
|
|
836
|
+
if (m = ve(d.reducer, d.cursor, d.runId, d.profile, d.lane === "runtime" ? d.runtime : void 0), xe(m)) return m;
|
|
837
837
|
}
|
|
838
838
|
throw new l("conversation_reconnect_exhausted", "Conversation replay stopped after the configured reconnect limit.", {
|
|
839
839
|
runId: d.runId,
|
|
@@ -843,13 +843,13 @@ var Ce = class {
|
|
|
843
843
|
};
|
|
844
844
|
//#endregion
|
|
845
845
|
//#region src/core/conversation/renderer-registry.ts
|
|
846
|
-
function
|
|
846
|
+
function Ce(e, t) {
|
|
847
847
|
if (!e.trim()) throw Error(`trusted conversation renderer ${t} must not be empty`);
|
|
848
848
|
}
|
|
849
|
-
function
|
|
849
|
+
function we(e) {
|
|
850
850
|
let t = /* @__PURE__ */ new Map();
|
|
851
851
|
for (let n of e) {
|
|
852
|
-
if (
|
|
852
|
+
if (Ce(n.id, "id"), Ce(n.schemaRef, "schemaRef"), !n.kinds.length) throw Error("trusted conversation renderer kinds must not be empty");
|
|
853
853
|
if (t.has(n.schemaRef)) throw Error(`duplicate trusted conversation renderer schemaRef: ${n.schemaRef}`);
|
|
854
854
|
t.set(n.schemaRef, Object.freeze({
|
|
855
855
|
...n,
|
|
@@ -867,14 +867,14 @@ function Te(e) {
|
|
|
867
867
|
}
|
|
868
868
|
});
|
|
869
869
|
}
|
|
870
|
-
var
|
|
870
|
+
var Te = we([{
|
|
871
871
|
id: "ksadk.agent-block",
|
|
872
872
|
schemaRef: "conversation.item.agent/v1",
|
|
873
873
|
kinds: ["agent"]
|
|
874
874
|
}]);
|
|
875
875
|
//#endregion
|
|
876
876
|
//#region src/utils/history-tool-facts.ts
|
|
877
|
-
function
|
|
877
|
+
function F(e, t) {
|
|
878
878
|
let n = (e) => e === "completed" || e === "error", r = t.output === void 0 ? e.output : t.output;
|
|
879
879
|
return {
|
|
880
880
|
args: t.args || e.args,
|
|
@@ -882,7 +882,7 @@ function P(e, t) {
|
|
|
882
882
|
status: n(e.status) && !n(t.status) ? e.status : t.status
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
|
-
function
|
|
885
|
+
function I(e) {
|
|
886
886
|
let t = e.map((e) => ({
|
|
887
887
|
...e,
|
|
888
888
|
tools: e.tools ? { ...e.tools } : void 0
|
|
@@ -907,13 +907,13 @@ function F(e) {
|
|
|
907
907
|
let r = e.message.tools[e.key], i = n ? {
|
|
908
908
|
...t,
|
|
909
909
|
...r,
|
|
910
|
-
...
|
|
910
|
+
...F(t, r)
|
|
911
911
|
} : {
|
|
912
912
|
...r,
|
|
913
913
|
...t,
|
|
914
|
-
...
|
|
914
|
+
...F(r, t)
|
|
915
915
|
};
|
|
916
|
-
e.message.tools[e.key] = i, e.message.blocks = e.message.blocks?.map((e) => e.type === "tool" && e.extra?.callId === t.callId ? {
|
|
916
|
+
t.deferredOutput && (i.status = t.status), i.name === "tool" && (i.name = r.name === "tool" ? t.name : r.name), e.message.tools[e.key] = i, e.message.blocks = e.message.blocks?.map((e) => e.type === "tool" && e.extra?.callId === t.callId ? {
|
|
917
917
|
...e,
|
|
918
918
|
args: i.args,
|
|
919
919
|
output: i.output,
|
|
@@ -946,22 +946,38 @@ function F(e) {
|
|
|
946
946
|
}
|
|
947
947
|
o(h, l), s(e, t, l.callId), c = !0;
|
|
948
948
|
}
|
|
949
|
-
return c ? t
|
|
949
|
+
return c ? t.filter((e) => e.itemId || ![
|
|
950
|
+
"tool_result",
|
|
951
|
+
"stage_tool_result",
|
|
952
|
+
"tool_call",
|
|
953
|
+
"stage_tool_call"
|
|
954
|
+
].includes(e.eventType || "") || e.content || e.reasoning || e.blocks?.length || e.attachments?.length || Object.keys(e.tools || {}).length) : e;
|
|
950
955
|
}
|
|
951
956
|
//#endregion
|
|
952
957
|
//#region src/utils/transcript-order.ts
|
|
953
|
-
var
|
|
954
|
-
function
|
|
958
|
+
var L = (e) => e.runId || e.invocationId, R = (e) => e.role === "user" && e.eventType === "optimistic_user_message";
|
|
959
|
+
function Ee(e, t) {
|
|
960
|
+
if (!t) return e;
|
|
961
|
+
let n = L(t);
|
|
962
|
+
if (!n || e.some((e) => e.role === "user" && L(e) === n)) return e;
|
|
963
|
+
let r = e.findIndex((e) => L(e) === n);
|
|
964
|
+
return r < 0 ? e : [
|
|
965
|
+
...e.slice(0, r),
|
|
966
|
+
t,
|
|
967
|
+
...e.slice(r)
|
|
968
|
+
];
|
|
969
|
+
}
|
|
970
|
+
function z(e) {
|
|
955
971
|
let t = /* @__PURE__ */ new Map();
|
|
956
972
|
for (let n of e) {
|
|
957
|
-
let e =
|
|
973
|
+
let e = L(n), r = n.historyOrder?.group;
|
|
958
974
|
e && r !== void 0 && t.set(e, Math.min(r, t.get(e) ?? r));
|
|
959
975
|
}
|
|
960
976
|
let n = e.map((e, n) => ({
|
|
961
977
|
message: e,
|
|
962
978
|
index: n,
|
|
963
979
|
seq: e.historyOrder?.seq,
|
|
964
|
-
group: e.historyOrder?.group ?? t.get(
|
|
980
|
+
group: e.historyOrder?.group ?? t.get(L(e) || "") ?? e.historyOrder?.seq,
|
|
965
981
|
part: e.historyOrder?.index || 0
|
|
966
982
|
})), r, i = n.map(() => void 0);
|
|
967
983
|
for (let e = n.length - 1; e >= 0; e--) i[e] = r, n[e].group !== void 0 && (r = n[e].group);
|
|
@@ -981,55 +997,64 @@ function De(e, t) {
|
|
|
981
997
|
let n = (n) => n === "feedback" ? !1 : n === "historyOrder" ? e.historyOrder?.seq !== t.historyOrder?.seq || e.historyOrder?.index !== t.historyOrder?.index || e.historyOrder?.group !== t.historyOrder?.group : e[n] !== t[n];
|
|
982
998
|
return Object.keys(e).some(n) || Object.keys(t).some(n);
|
|
983
999
|
}
|
|
984
|
-
function Oe(e, t, n) {
|
|
985
|
-
let
|
|
986
|
-
|
|
1000
|
+
function Oe(e, t, n, r = !1) {
|
|
1001
|
+
let i = e.filter((e) => e.role === "user" && !R(e)), a = new Set(i.map(L).filter(Boolean)), o = new Set(i.map((e) => e.commandId).filter(Boolean)), s = n.filter((e) => !R(e) || !a.has(L(e)) && !o.has(e.commandId)), c = s.filter((t) => R(t) && !e.some((e) => e.id === t.id));
|
|
1002
|
+
if (c.length) {
|
|
1003
|
+
e = [...e];
|
|
1004
|
+
for (let t of c) {
|
|
1005
|
+
let n = L(t), r = n ? e.findIndex((e) => L(e) === n) : -1;
|
|
1006
|
+
r < 0 ? e.push(t) : e.splice(r, 0, t);
|
|
1007
|
+
}
|
|
1008
|
+
e = z(e);
|
|
1009
|
+
}
|
|
1010
|
+
let l = new Map(t.map((e) => [e.id, e])), u = s.filter((e) => l.has(e.id) && l.get(e.id)?.feedback !== e.feedback), d = new Map(u.map((e) => [e.id, e.feedback])), f = (e) => JSON.stringify([L(e), e.responseId]), p = new Map(u.filter((e) => e.responseId).map((e) => [f(e), e.feedback])), m = (e) => e.map((e) => {
|
|
1011
|
+
if (d.has(e.id)) return {
|
|
987
1012
|
...e,
|
|
988
|
-
feedback:
|
|
1013
|
+
feedback: d.get(e.id)
|
|
989
1014
|
};
|
|
990
|
-
let t =
|
|
991
|
-
return e.responseId &&
|
|
1015
|
+
let t = f(e);
|
|
1016
|
+
return e.responseId && p.has(t) ? {
|
|
992
1017
|
...e,
|
|
993
|
-
feedback:
|
|
1018
|
+
feedback: p.get(t)
|
|
994
1019
|
} : e;
|
|
995
|
-
}),
|
|
996
|
-
if (!
|
|
997
|
-
let
|
|
998
|
-
for (let t of
|
|
999
|
-
let n =
|
|
1000
|
-
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1020
|
+
}), h = s.filter((e) => De(e, l.get(e.id)));
|
|
1021
|
+
if (!h.length) return O(I(m(e)));
|
|
1022
|
+
let g = new Set(h.map(L).filter(Boolean)), _ = new Set(h.map((e) => e.id)), v = s.filter((e) => g.has(L(e)) || _.has(e.id)), y = e;
|
|
1023
|
+
for (let t of g) {
|
|
1024
|
+
let n = v.filter((e) => L(e) === t), i = e.filter((e) => L(e) === t), a = y.findIndex((e) => L(e) === t), o = new Set(n.map((e) => e.id)), s = r ? i.filter((e) => !o.has(e.id) && !l.has(e.id)) : n.some((e) => e.role === "user") ? [] : i.filter((e) => e.role === "user");
|
|
1025
|
+
y = y.filter((e) => L(e) !== t);
|
|
1026
|
+
let c = a < 0 ? y.length : Math.min(a, y.length);
|
|
1027
|
+
y.splice(c, 0, ...s, ...n.map((e) => ({
|
|
1003
1028
|
...e,
|
|
1004
|
-
historyOrder: e.historyOrder ||
|
|
1029
|
+
historyOrder: e.historyOrder || i.find((t) => t.id === e.id)?.historyOrder
|
|
1005
1030
|
})));
|
|
1006
1031
|
}
|
|
1007
|
-
for (let e of
|
|
1008
|
-
let t =
|
|
1032
|
+
for (let e of v.filter((e) => !L(e))) {
|
|
1033
|
+
let t = y.findIndex((t) => t.id === e.id);
|
|
1009
1034
|
if (t < 0) {
|
|
1010
|
-
let t =
|
|
1011
|
-
|
|
1012
|
-
...
|
|
1035
|
+
let t = s.indexOf(e), n = s.slice(t + 1).find((e) => y.some((t) => t.id === e.id)), r = s.slice(0, t).findLast((e) => y.some((t) => t.id === e.id)), i = n ? y.findIndex((e) => e.id === n.id) : r ? y.findIndex((e) => e.id === r.id) + 1 : y.length;
|
|
1036
|
+
y = [
|
|
1037
|
+
...y.slice(0, i),
|
|
1013
1038
|
e,
|
|
1014
|
-
...
|
|
1039
|
+
...y.slice(i)
|
|
1015
1040
|
];
|
|
1016
|
-
} else
|
|
1041
|
+
} else y = y.map((n, r) => r === t ? {
|
|
1017
1042
|
...e,
|
|
1018
1043
|
historyOrder: e.historyOrder || n.historyOrder
|
|
1019
1044
|
} : n);
|
|
1020
1045
|
}
|
|
1021
|
-
return
|
|
1046
|
+
return O(I(m(z(y))));
|
|
1022
1047
|
}
|
|
1023
1048
|
//#endregion
|
|
1024
1049
|
//#region src/core/conversation/hosted.ts
|
|
1025
1050
|
var ke = "conversation_item_v1";
|
|
1026
|
-
function
|
|
1051
|
+
function Ae(e) {
|
|
1027
1052
|
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
1028
1053
|
}
|
|
1029
|
-
function
|
|
1054
|
+
function B(e) {
|
|
1030
1055
|
return typeof e == "string" && e.trim() ? e : null;
|
|
1031
1056
|
}
|
|
1032
|
-
function
|
|
1057
|
+
function V(e) {
|
|
1033
1058
|
if (typeof e == "string") return e;
|
|
1034
1059
|
if (e == null) return "";
|
|
1035
1060
|
try {
|
|
@@ -1038,7 +1063,7 @@ function B(e) {
|
|
|
1038
1063
|
return String(e);
|
|
1039
1064
|
}
|
|
1040
1065
|
}
|
|
1041
|
-
function
|
|
1066
|
+
function H(e) {
|
|
1042
1067
|
return {
|
|
1043
1068
|
id: `conversation:${e.runId}:${e.itemId}`,
|
|
1044
1069
|
timestamp: 0,
|
|
@@ -1049,13 +1074,13 @@ function V(e) {
|
|
|
1049
1074
|
status: e.lifecycle === "failed" ? "failed" : e.lifecycle === "completed" ? "completed" : "running"
|
|
1050
1075
|
};
|
|
1051
1076
|
}
|
|
1052
|
-
function
|
|
1077
|
+
function je(e) {
|
|
1053
1078
|
return e.lifecycle === "failed" ? "error" : e.lifecycle === "completed" ? "done" : "streaming";
|
|
1054
1079
|
}
|
|
1055
|
-
function
|
|
1080
|
+
function Me(e) {
|
|
1056
1081
|
let t = typeof e.payload.text == "string" ? e.payload.text : "";
|
|
1057
1082
|
if (e.kind === "user_message") return {
|
|
1058
|
-
...
|
|
1083
|
+
...H(e),
|
|
1059
1084
|
role: "user",
|
|
1060
1085
|
content: t,
|
|
1061
1086
|
eventType: "user_message"
|
|
@@ -1064,31 +1089,31 @@ function je(e) {
|
|
|
1064
1089
|
id: `conversation-block:${e.itemId}`,
|
|
1065
1090
|
type: "thinking",
|
|
1066
1091
|
content: t,
|
|
1067
|
-
status:
|
|
1092
|
+
status: je(e),
|
|
1068
1093
|
...e.payload.presentationSource === "public_summary" || e.payload.presentationSource === "provider_reasoning" ? { source: e.payload.presentationSource } : {}
|
|
1069
1094
|
} : {
|
|
1070
1095
|
id: `conversation-block:${e.itemId}`,
|
|
1071
1096
|
type: "text",
|
|
1072
1097
|
content: t,
|
|
1073
|
-
status:
|
|
1098
|
+
status: je(e)
|
|
1074
1099
|
};
|
|
1075
1100
|
return {
|
|
1076
|
-
...
|
|
1101
|
+
...H(e),
|
|
1077
1102
|
role: "model",
|
|
1078
1103
|
content: e.kind === "assistant_text" ? t : "",
|
|
1079
1104
|
reasoning: e.kind === "reasoning" ? t : void 0,
|
|
1080
1105
|
blocks: [n]
|
|
1081
1106
|
};
|
|
1082
1107
|
}
|
|
1083
|
-
function
|
|
1084
|
-
let n =
|
|
1108
|
+
function Ne(e, t = !1) {
|
|
1109
|
+
let n = B(e.payload.tool) || (e.payload.sourceKind === "tool_result" ? "Tool result" : "Tool"), r = B(e.payload.callId), i = V(y(e.payload.args)), a = Object.prototype.hasOwnProperty.call(e.payload, "output") ? V(b(e.payload.output, e.nativeRef.framework, e.nativeRef.protocol)) : void 0, o = {
|
|
1085
1110
|
failed: "error",
|
|
1086
1111
|
completed: "completed",
|
|
1087
1112
|
running: "running",
|
|
1088
1113
|
unknown: "unknown"
|
|
1089
1114
|
}, s = e.payload.executionStatus, c = typeof s == "string" && Object.hasOwn(o, s) ? o[s] : e.lifecycle === "failed" || e.payload.isError === !0 ? "error" : e.lifecycle === "completed" ? "completed" : "running", l = t && c === "running" ? "unknown" : c;
|
|
1090
1115
|
return {
|
|
1091
|
-
...
|
|
1116
|
+
...H(e),
|
|
1092
1117
|
role: "model",
|
|
1093
1118
|
content: "",
|
|
1094
1119
|
blocks: [{
|
|
@@ -1109,13 +1134,13 @@ function Me(e, t = !1) {
|
|
|
1109
1134
|
} }
|
|
1110
1135
|
};
|
|
1111
1136
|
}
|
|
1112
|
-
function
|
|
1137
|
+
function Pe(e) {
|
|
1113
1138
|
return e === "structured_input" ? "structured_input" : e === "plan_review" ? "plan_review" : e === "custom" ? "custom" : "approval";
|
|
1114
1139
|
}
|
|
1115
|
-
function
|
|
1116
|
-
let n =
|
|
1140
|
+
function Fe(e) {
|
|
1141
|
+
let n = B(e.payload.interactionId), r = e.payload.revision;
|
|
1117
1142
|
if (!n || !Number.isInteger(r) || Number(r) < 1) return null;
|
|
1118
|
-
let i =
|
|
1143
|
+
let i = V(e.payload.detail), a = B(e.payload.prompt) || i, o = Pe(e.payload.interactionKind), s = e.lifecycle === "completed", c = {};
|
|
1119
1144
|
if (s && Object.hasOwn(e.payload, "response")) try {
|
|
1120
1145
|
c = { response: t(e.payload.response) };
|
|
1121
1146
|
} catch {}
|
|
@@ -1124,16 +1149,16 @@ function Pe(e) {
|
|
|
1124
1149
|
sessionId: e.sessionId,
|
|
1125
1150
|
runId: e.runId,
|
|
1126
1151
|
kind: o,
|
|
1127
|
-
title:
|
|
1152
|
+
title: B(e.payload.title) || (o === "approval" ? `审批:${B(e.payload.kind) || "操作"}` : "需要补充信息"),
|
|
1128
1153
|
message: a || "运行需要人工确认。",
|
|
1129
|
-
requestSchema:
|
|
1154
|
+
requestSchema: Ae(e.payload.inputSchema),
|
|
1130
1155
|
presentation: null,
|
|
1131
1156
|
status: s ? "resolved" : "pending",
|
|
1132
1157
|
revision: Number(r),
|
|
1133
|
-
createdAt:
|
|
1134
|
-
expiresAt:
|
|
1135
|
-
resolvedAt: s ?
|
|
1136
|
-
actor: s ?
|
|
1158
|
+
createdAt: B(e.payload.createdAt) || "",
|
|
1159
|
+
expiresAt: B(e.payload.expiresAt),
|
|
1160
|
+
resolvedAt: s ? B(e.payload.resolvedAt) : null,
|
|
1161
|
+
actor: s ? B(e.payload.actor) : null,
|
|
1137
1162
|
outcome: s && [
|
|
1138
1163
|
"approved",
|
|
1139
1164
|
"rejected",
|
|
@@ -1141,23 +1166,23 @@ function Pe(e) {
|
|
|
1141
1166
|
"cancelled",
|
|
1142
1167
|
"expired"
|
|
1143
1168
|
].includes(String(e.payload.outcome || "")) ? e.payload.outcome : null,
|
|
1144
|
-
responseSummary: s ?
|
|
1169
|
+
responseSummary: s ? B(e.payload.responseSummary) : null,
|
|
1145
1170
|
...c,
|
|
1146
1171
|
source: "interaction_v1",
|
|
1147
1172
|
extensions: {
|
|
1148
1173
|
conversation_item_id: e.itemId,
|
|
1149
|
-
...
|
|
1174
|
+
...B(e.payload.callId) ? { call_id: B(e.payload.callId) } : {}
|
|
1150
1175
|
}
|
|
1151
1176
|
};
|
|
1152
1177
|
}
|
|
1153
|
-
function
|
|
1154
|
-
let n =
|
|
1178
|
+
function Ie(e, t) {
|
|
1179
|
+
let n = B(e.payload.kind) || "approval", r = V(e.payload.detail), i = t.status === "resolved" ? t.outcome === "rejected" ? "rejected" : t.outcome === "cancelled" || t.outcome === "expired" ? "cancelled" : "approved" : "pending", a = t.status === "pending" ? "paused" : "completed", o = {
|
|
1155
1180
|
approvalRequestId: t.interactionId,
|
|
1156
1181
|
approvalStatus: i,
|
|
1157
1182
|
approvalMessage: t.message
|
|
1158
1183
|
};
|
|
1159
1184
|
return {
|
|
1160
|
-
...
|
|
1185
|
+
...H(e),
|
|
1161
1186
|
role: "model",
|
|
1162
1187
|
content: "",
|
|
1163
1188
|
blocks: [{
|
|
@@ -1178,26 +1203,26 @@ function Fe(e, t) {
|
|
|
1178
1203
|
} }
|
|
1179
1204
|
};
|
|
1180
1205
|
}
|
|
1181
|
-
function
|
|
1206
|
+
function Le(e) {
|
|
1182
1207
|
for (let t of [
|
|
1183
1208
|
"createSurface",
|
|
1184
1209
|
"updateComponents",
|
|
1185
1210
|
"updateDataModel",
|
|
1186
1211
|
"deleteSurface"
|
|
1187
1212
|
]) {
|
|
1188
|
-
let n =
|
|
1213
|
+
let n = B(Ae(e[t])?.surfaceId);
|
|
1189
1214
|
if (n) return n;
|
|
1190
1215
|
}
|
|
1191
1216
|
return null;
|
|
1192
1217
|
}
|
|
1193
|
-
function
|
|
1218
|
+
function Re(e) {
|
|
1194
1219
|
let t = Array.isArray(e.payload.data) ? e.payload.data : Array.isArray(e.payload.operations) ? e.payload.operations : null;
|
|
1195
1220
|
if (!t) return null;
|
|
1196
|
-
let n = t.map(
|
|
1221
|
+
let n = t.map(Ae);
|
|
1197
1222
|
if (n.some((e) => e === null)) return null;
|
|
1198
|
-
let r = n, i =
|
|
1223
|
+
let r = n, i = B(e.payload.surfaceId) || r.map(Le).find((e) => e !== null) || null;
|
|
1199
1224
|
return i ? {
|
|
1200
|
-
...
|
|
1225
|
+
...H(e),
|
|
1201
1226
|
role: "a2ui",
|
|
1202
1227
|
content: "",
|
|
1203
1228
|
aguiActivity: {
|
|
@@ -1207,15 +1232,15 @@ function Le(e) {
|
|
|
1207
1232
|
}
|
|
1208
1233
|
} : null;
|
|
1209
1234
|
}
|
|
1210
|
-
function
|
|
1235
|
+
function U(e, t, n, r = !1) {
|
|
1211
1236
|
return {
|
|
1212
|
-
...
|
|
1237
|
+
...H(e),
|
|
1213
1238
|
role: "system",
|
|
1214
1239
|
content: n ? `${t}: ${n}` : t,
|
|
1215
|
-
status: r ? "failed" :
|
|
1240
|
+
status: r ? "failed" : H(e).status
|
|
1216
1241
|
};
|
|
1217
1242
|
}
|
|
1218
|
-
function
|
|
1243
|
+
function ze(e) {
|
|
1219
1244
|
for (let { item: t } of [...e].reverse()) {
|
|
1220
1245
|
if (t.visibility !== "public" || t.kind !== "assistant_text" || t.payloadSchemaRef !== "conversation.item.assistant_text/v1" || typeof t.payload.text != "string") continue;
|
|
1221
1246
|
let e = y(t.payload.text);
|
|
@@ -1226,16 +1251,16 @@ function Re(e) {
|
|
|
1226
1251
|
return r.length > 160 ? `${r.slice(0, 160).join("")}…` : n;
|
|
1227
1252
|
}
|
|
1228
1253
|
}
|
|
1229
|
-
function
|
|
1254
|
+
function W(e) {
|
|
1230
1255
|
let t = e.presentation, n = new Map(t.textItems.map((e) => [e.id, e])), r = new Set(t.toolItems.map((e) => e.itemId)), i = new Set(t.approvalItems.map((e) => e.itemId)), a = new Set(t.structuredInputItems.map((e) => e.itemId)), o = new Set(t.a2uiItems.map((e) => e.itemId)), s = new Map(t.artifacts.map((e) => [e.id, e])), c = new Map(t.fallbacks.map((e) => [e.id, e])), l = [], u = [];
|
|
1231
1256
|
for (let d of t.timeline) {
|
|
1232
1257
|
let { item: f } = d;
|
|
1233
1258
|
if (f.kind === "agent") {
|
|
1234
1259
|
if (!d.children) {
|
|
1235
|
-
l.push(
|
|
1260
|
+
l.push(U(f, "Remote agent", String(f.payload.status || "submitted")));
|
|
1236
1261
|
continue;
|
|
1237
1262
|
}
|
|
1238
|
-
let n =
|
|
1263
|
+
let n = W({
|
|
1239
1264
|
...e,
|
|
1240
1265
|
presentation: {
|
|
1241
1266
|
...t,
|
|
@@ -1243,40 +1268,40 @@ function U(e) {
|
|
|
1243
1268
|
}
|
|
1244
1269
|
});
|
|
1245
1270
|
l.push({
|
|
1246
|
-
...
|
|
1271
|
+
...H(f),
|
|
1247
1272
|
role: "model",
|
|
1248
1273
|
content: "",
|
|
1249
1274
|
agentBlock: {
|
|
1250
1275
|
item: f,
|
|
1251
1276
|
messages: n.messages,
|
|
1252
|
-
summary:
|
|
1277
|
+
summary: ze(d.children || [])
|
|
1253
1278
|
},
|
|
1254
|
-
status: f.payload.status === "cancelled" ? "cancelled" :
|
|
1279
|
+
status: f.payload.status === "cancelled" ? "cancelled" : H(f).status
|
|
1255
1280
|
}), u.push(...n.interactions);
|
|
1256
1281
|
continue;
|
|
1257
1282
|
}
|
|
1258
1283
|
if (n.has(f.itemId)) {
|
|
1259
|
-
l.push(
|
|
1284
|
+
l.push(Me(f));
|
|
1260
1285
|
continue;
|
|
1261
1286
|
}
|
|
1262
1287
|
if (r.has(f.itemId)) {
|
|
1263
|
-
l.push(
|
|
1288
|
+
l.push(Ne(f, !!t.terminalStatus && f.runId === e.runId));
|
|
1264
1289
|
continue;
|
|
1265
1290
|
}
|
|
1266
1291
|
if (i.has(f.itemId) || a.has(f.itemId)) {
|
|
1267
|
-
let e =
|
|
1268
|
-
e ? (u.push(e), l.push(
|
|
1292
|
+
let e = Fe(f);
|
|
1293
|
+
e ? (u.push(e), l.push(Ie(f, e))) : l.push(U(f, "Interaction unavailable", "The server did not provide a durable interaction revision; this card is read-only."));
|
|
1269
1294
|
continue;
|
|
1270
1295
|
}
|
|
1271
1296
|
if (o.has(f.itemId)) {
|
|
1272
|
-
let e =
|
|
1273
|
-
l.push(e ||
|
|
1297
|
+
let e = Re(f);
|
|
1298
|
+
l.push(e || U(f, "Unsupported content", "A2UI payload is not a valid passive operation list."));
|
|
1274
1299
|
continue;
|
|
1275
1300
|
}
|
|
1276
1301
|
let p = s.get(f.itemId);
|
|
1277
1302
|
if (p) {
|
|
1278
1303
|
l.push(p.status === "pending" ? {
|
|
1279
|
-
...
|
|
1304
|
+
...H(f),
|
|
1280
1305
|
role: "model",
|
|
1281
1306
|
content: p.name,
|
|
1282
1307
|
attachments: [{
|
|
@@ -1290,7 +1315,7 @@ function U(e) {
|
|
|
1290
1315
|
status: "pending"
|
|
1291
1316
|
}]
|
|
1292
1317
|
} : p.status === "ready" && p.uri ? {
|
|
1293
|
-
...
|
|
1318
|
+
...H(f),
|
|
1294
1319
|
role: "model",
|
|
1295
1320
|
content: p.name,
|
|
1296
1321
|
attachments: [{
|
|
@@ -1303,13 +1328,13 @@ function U(e) {
|
|
|
1303
1328
|
sizeBytes: p.sizeBytes,
|
|
1304
1329
|
status: p.status
|
|
1305
1330
|
}]
|
|
1306
|
-
} :
|
|
1331
|
+
} : U(f, "Artifact unavailable", p.status === "failed" ? "The artifact failed to generate or its URI is not a safe HTTP(S) link." : "The artifact URI is not a safe HTTP(S) link."));
|
|
1307
1332
|
continue;
|
|
1308
1333
|
}
|
|
1309
1334
|
let m = c.get(f.itemId);
|
|
1310
1335
|
if (m) {
|
|
1311
1336
|
if (f.kind === "error" && ["cancelled", "canceled"].includes(String(f.payload.status || "").toLowerCase())) continue;
|
|
1312
|
-
l.push(
|
|
1337
|
+
l.push(U(f, m.title, m.detail, m.failed));
|
|
1313
1338
|
}
|
|
1314
1339
|
}
|
|
1315
1340
|
return {
|
|
@@ -1317,47 +1342,47 @@ function U(e) {
|
|
|
1317
1342
|
interactions: u
|
|
1318
1343
|
};
|
|
1319
1344
|
}
|
|
1320
|
-
function
|
|
1321
|
-
let
|
|
1322
|
-
if (!
|
|
1323
|
-
let
|
|
1324
|
-
...
|
|
1345
|
+
function Be(e, t, n, r) {
|
|
1346
|
+
let i = W(t).messages;
|
|
1347
|
+
if (!i.length) return e;
|
|
1348
|
+
let a = e.filter((e) => e.eventType !== "optimistic_assistant_placeholder"), o = (e) => e.runId === t.runId || e.invocationId === t.runId || r !== void 0 && (e.runId === r || e.invocationId === r), s = a.findIndex(o), c = n ? a.findIndex((e) => e.id === n) : s < 0 ? a.findLastIndex((e) => e.role === "user" && e.eventType === "optimistic_user_message") : a.findIndex((e) => e.role === "user" && o(e)), l = a[c], u = a.filter((e, t) => t !== c && !o(e)), d = [c, s].filter((e) => e >= 0), f = d.length ? Math.min(...d) : u.length, p = l && !i.some((e) => e.role === "user") ? [{
|
|
1349
|
+
...l,
|
|
1325
1350
|
invocationId: t.runId,
|
|
1326
1351
|
eventType: void 0
|
|
1327
1352
|
}] : [];
|
|
1328
1353
|
return [
|
|
1329
|
-
...
|
|
1330
|
-
...
|
|
1331
|
-
...
|
|
1332
|
-
...
|
|
1354
|
+
...u.slice(0, f),
|
|
1355
|
+
...p,
|
|
1356
|
+
...i,
|
|
1357
|
+
...u.slice(f)
|
|
1333
1358
|
];
|
|
1334
1359
|
}
|
|
1335
1360
|
//#endregion
|
|
1336
1361
|
//#region src/core/run/blocks.ts
|
|
1337
|
-
var
|
|
1338
|
-
function W(e) {
|
|
1339
|
-
return Be += 1, `${e}-${Be}`;
|
|
1340
|
-
}
|
|
1362
|
+
var Ve = 0;
|
|
1341
1363
|
function G(e) {
|
|
1364
|
+
return Ve += 1, `${e}-${Ve}`;
|
|
1365
|
+
}
|
|
1366
|
+
function K(e) {
|
|
1342
1367
|
return e.map((e) => e.type === "thinking" && e.status === "streaming" ? {
|
|
1343
1368
|
...e,
|
|
1344
1369
|
status: "done"
|
|
1345
1370
|
} : e);
|
|
1346
1371
|
}
|
|
1347
|
-
function
|
|
1372
|
+
function He(e, t, n) {
|
|
1348
1373
|
let r = [...e ?? []], i = r[r.length - 1];
|
|
1349
1374
|
return i?.type === "thinking" && i.status === "streaming" && i.itemId === n ? (r[r.length - 1] = {
|
|
1350
1375
|
...i,
|
|
1351
1376
|
content: i.content + t
|
|
1352
|
-
}, r) : [...
|
|
1353
|
-
id:
|
|
1377
|
+
}, r) : [...K(r), {
|
|
1378
|
+
id: G("thinking"),
|
|
1354
1379
|
type: "thinking",
|
|
1355
1380
|
content: t,
|
|
1356
1381
|
status: "streaming",
|
|
1357
1382
|
...n && { itemId: n }
|
|
1358
1383
|
}];
|
|
1359
1384
|
}
|
|
1360
|
-
function
|
|
1385
|
+
function Ue(e, t, n) {
|
|
1361
1386
|
let r = (e) => e.type === "thinking" && e.itemId === t, i = e.findLastIndex(r), a = 0;
|
|
1362
1387
|
return e.flatMap((e, t) => {
|
|
1363
1388
|
if (!r(e)) return [e];
|
|
@@ -1368,22 +1393,22 @@ function He(e, t, n) {
|
|
|
1368
1393
|
}] : [];
|
|
1369
1394
|
});
|
|
1370
1395
|
}
|
|
1371
|
-
function
|
|
1372
|
-
let n = [...
|
|
1396
|
+
function We(e, t) {
|
|
1397
|
+
let n = [...K(e ?? [])], r = n[n.length - 1];
|
|
1373
1398
|
return r?.type === "text" && r.status === "streaming" ? (n[n.length - 1] = {
|
|
1374
1399
|
...r,
|
|
1375
1400
|
content: r.content + t
|
|
1376
1401
|
}, n) : [...n, {
|
|
1377
|
-
id:
|
|
1402
|
+
id: G("text"),
|
|
1378
1403
|
type: "text",
|
|
1379
1404
|
content: t,
|
|
1380
1405
|
status: "streaming"
|
|
1381
1406
|
}];
|
|
1382
1407
|
}
|
|
1383
|
-
function
|
|
1408
|
+
function Ge(e, t) {
|
|
1384
1409
|
let n = e ?? [], r = n.filter((e) => e.type === "text").map((e) => e.content).join("");
|
|
1385
1410
|
if (r === t) return n;
|
|
1386
|
-
if (t.startsWith(r) && n.at(-1)?.type !== "text") return
|
|
1411
|
+
if (t.startsWith(r) && n.at(-1)?.type !== "text") return We(n, t.slice(r.length));
|
|
1387
1412
|
let i = n.flatMap((e, t) => e.type === "text" ? [t] : []), a = 0;
|
|
1388
1413
|
for (; a < r.length && a < t.length && r[a] === t[a];) a++;
|
|
1389
1414
|
let o = 0;
|
|
@@ -1403,12 +1428,12 @@ function We(e, t) {
|
|
|
1403
1428
|
};
|
|
1404
1429
|
});
|
|
1405
1430
|
}
|
|
1406
|
-
function
|
|
1407
|
-
let n =
|
|
1431
|
+
function Ke(e, t) {
|
|
1432
|
+
let n = K(e ?? []), r = n.flatMap((e) => e.type === "text" ? [e.content] : []).join(""), i = n.at(-1), a = n;
|
|
1408
1433
|
if (t !== r && i?.type !== "text") {
|
|
1409
1434
|
let e = t.startsWith(r) ? t.slice(r.length) : t;
|
|
1410
1435
|
e && (a = [...n, {
|
|
1411
|
-
id:
|
|
1436
|
+
id: G("text"),
|
|
1412
1437
|
type: "text",
|
|
1413
1438
|
content: e,
|
|
1414
1439
|
status: "done"
|
|
@@ -1425,7 +1450,7 @@ function Ge(e, t) {
|
|
|
1425
1450
|
status: "done"
|
|
1426
1451
|
} : e);
|
|
1427
1452
|
}
|
|
1428
|
-
function
|
|
1453
|
+
function qe(e, t) {
|
|
1429
1454
|
if (!t) return [...e ?? []];
|
|
1430
1455
|
let n = [...e ?? []], r = n[n.length - 1];
|
|
1431
1456
|
if (r?.type !== "thinking" || !r.content.endsWith(t)) return n;
|
|
@@ -1435,7 +1460,7 @@ function Ke(e, t) {
|
|
|
1435
1460
|
content: i
|
|
1436
1461
|
}, n) : (n.pop(), n);
|
|
1437
1462
|
}
|
|
1438
|
-
function
|
|
1463
|
+
function Je(e, t, n) {
|
|
1439
1464
|
let r = [...e ?? []], i = n.extra?.callId, a = i ? r.findIndex((e) => e.type === "tool" && e.extra?.callId === i && e.toolName === t) : -1;
|
|
1440
1465
|
if (a < 0 && (a = r.findLastIndex((e) => e.type === "tool" && e.toolName === t && (!i || !e.extra?.callId && (e.status === "running" || e.status === "paused")))), a >= 0 && r[a].type === "tool") {
|
|
1441
1466
|
let e = r[a], t = e.status === "error" || e.status === "completed", i = n.output !== void 0, o = n.extra && (n.extra.approvalRequestId || n.extra.approvalStatus);
|
|
@@ -1450,8 +1475,8 @@ function qe(e, t, n) {
|
|
|
1450
1475
|
extra: s
|
|
1451
1476
|
}, r;
|
|
1452
1477
|
}
|
|
1453
|
-
return [...
|
|
1454
|
-
id:
|
|
1478
|
+
return [...K(r), {
|
|
1479
|
+
id: G("tool"),
|
|
1455
1480
|
type: "tool",
|
|
1456
1481
|
toolName: t,
|
|
1457
1482
|
args: n.args ?? "",
|
|
@@ -1460,19 +1485,19 @@ function qe(e, t, n) {
|
|
|
1460
1485
|
extra: n.extra
|
|
1461
1486
|
}];
|
|
1462
1487
|
}
|
|
1463
|
-
function Je(e) {
|
|
1464
|
-
return G(e ?? []);
|
|
1465
|
-
}
|
|
1466
1488
|
function Ye(e) {
|
|
1489
|
+
return K(e ?? []);
|
|
1490
|
+
}
|
|
1491
|
+
function Xe(e) {
|
|
1467
1492
|
let t = [];
|
|
1468
1493
|
if (e.reasoning && e.reasoning.trim() && t.push({
|
|
1469
|
-
id:
|
|
1494
|
+
id: G("thinking"),
|
|
1470
1495
|
type: "thinking",
|
|
1471
1496
|
content: e.reasoning,
|
|
1472
1497
|
status: "done",
|
|
1473
1498
|
...e.reasoningSource ? { source: e.reasoningSource } : {}
|
|
1474
1499
|
}), e.tools) for (let n of Object.values(e.tools)) t.push({
|
|
1475
|
-
id:
|
|
1500
|
+
id: G("tool"),
|
|
1476
1501
|
type: "tool",
|
|
1477
1502
|
toolName: n.name,
|
|
1478
1503
|
args: n.args ?? "",
|
|
@@ -1484,7 +1509,7 @@ function Ye(e) {
|
|
|
1484
1509
|
} } : {}
|
|
1485
1510
|
});
|
|
1486
1511
|
return e.content && e.content.trim() && t.push({
|
|
1487
|
-
id:
|
|
1512
|
+
id: G("text"),
|
|
1488
1513
|
type: "text",
|
|
1489
1514
|
content: e.content,
|
|
1490
1515
|
status: "done"
|
|
@@ -1492,40 +1517,40 @@ function Ye(e) {
|
|
|
1492
1517
|
}
|
|
1493
1518
|
//#endregion
|
|
1494
1519
|
//#region src/core/stream/kernel-events.ts
|
|
1495
|
-
var
|
|
1520
|
+
var Ze = {
|
|
1496
1521
|
"run.started": "in_progress",
|
|
1497
1522
|
"run.progress": "in_progress",
|
|
1498
1523
|
"run.completed": "completed",
|
|
1499
1524
|
"run.failed": "failed",
|
|
1500
1525
|
"run.canceled": "cancelled",
|
|
1501
1526
|
"run.interrupted": "interrupted"
|
|
1502
|
-
},
|
|
1527
|
+
}, Qe = new Set([
|
|
1503
1528
|
"completed",
|
|
1504
1529
|
"failed",
|
|
1505
1530
|
"cancelled",
|
|
1506
1531
|
"canceled"
|
|
1507
1532
|
]);
|
|
1508
|
-
function
|
|
1533
|
+
function q(e) {
|
|
1509
1534
|
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
1510
1535
|
}
|
|
1511
|
-
function
|
|
1512
|
-
let t =
|
|
1536
|
+
function $e(e) {
|
|
1537
|
+
let t = q(e.source), n = t ? q(t.metadata) : null;
|
|
1513
1538
|
return String(n?.native_item_kind || "");
|
|
1514
1539
|
}
|
|
1515
|
-
function
|
|
1516
|
-
let n =
|
|
1540
|
+
function J(e, t) {
|
|
1541
|
+
let n = q(e[t]);
|
|
1517
1542
|
if (!n) return [];
|
|
1518
1543
|
let r = n?.parts;
|
|
1519
1544
|
return Array.isArray(r) ? r : t === "update" ? [n] : [];
|
|
1520
1545
|
}
|
|
1521
|
-
function
|
|
1522
|
-
let t =
|
|
1546
|
+
function et(e) {
|
|
1547
|
+
let t = q(e);
|
|
1523
1548
|
if (!t) return "";
|
|
1524
1549
|
if (typeof t.text == "string") return t.text;
|
|
1525
|
-
let n =
|
|
1550
|
+
let n = q(t.data);
|
|
1526
1551
|
if (n) {
|
|
1527
1552
|
let e = n.content;
|
|
1528
|
-
if (Array.isArray(e)) return e.map((e) => String(
|
|
1553
|
+
if (Array.isArray(e)) return e.map((e) => String(q(e)?.text || "")).join("");
|
|
1529
1554
|
for (let e of [
|
|
1530
1555
|
"text",
|
|
1531
1556
|
"output",
|
|
@@ -1535,31 +1560,31 @@ function $e(e) {
|
|
|
1535
1560
|
}
|
|
1536
1561
|
return "";
|
|
1537
1562
|
}
|
|
1538
|
-
function
|
|
1539
|
-
return e.map(
|
|
1563
|
+
function Y(e) {
|
|
1564
|
+
return e.map(et).join("");
|
|
1540
1565
|
}
|
|
1541
|
-
function
|
|
1542
|
-
return e.some((e) =>
|
|
1566
|
+
function tt(e) {
|
|
1567
|
+
return e.some((e) => q(q(e)?.data)?.type === "userMessage");
|
|
1543
1568
|
}
|
|
1544
|
-
function
|
|
1569
|
+
function X(e) {
|
|
1545
1570
|
if (e.length === 1) {
|
|
1546
|
-
let t =
|
|
1571
|
+
let t = q(q(e[0])?.data);
|
|
1547
1572
|
if (t) return t;
|
|
1548
1573
|
}
|
|
1549
|
-
return
|
|
1574
|
+
return Y(e) || null;
|
|
1550
1575
|
}
|
|
1551
|
-
function
|
|
1552
|
-
let t =
|
|
1553
|
-
return t ?
|
|
1576
|
+
function nt(e) {
|
|
1577
|
+
let t = q(e);
|
|
1578
|
+
return t ? q(t.data) || t : null;
|
|
1554
1579
|
}
|
|
1555
|
-
function
|
|
1556
|
-
let t =
|
|
1580
|
+
function rt(e) {
|
|
1581
|
+
let t = nt(e);
|
|
1557
1582
|
return String(t?.content_type || t?.type || "").trim().toLowerCase();
|
|
1558
1583
|
}
|
|
1559
|
-
function
|
|
1584
|
+
function it(e) {
|
|
1560
1585
|
for (let t of e) {
|
|
1561
|
-
let e =
|
|
1562
|
-
if (!e ||
|
|
1586
|
+
let e = nt(t);
|
|
1587
|
+
if (!e || rt(t) !== "tool_call") continue;
|
|
1563
1588
|
let n = String(e.call_id || "").trim(), r = String(e.name || e.tool_name || "").trim();
|
|
1564
1589
|
if (!(!n && !r)) return {
|
|
1565
1590
|
callId: n,
|
|
@@ -1569,10 +1594,10 @@ function nt(e) {
|
|
|
1569
1594
|
}
|
|
1570
1595
|
return null;
|
|
1571
1596
|
}
|
|
1572
|
-
function
|
|
1597
|
+
function at(e) {
|
|
1573
1598
|
for (let t of e) {
|
|
1574
|
-
let e =
|
|
1575
|
-
if (!e ||
|
|
1599
|
+
let e = nt(t);
|
|
1600
|
+
if (!e || rt(t) !== "tool_result") continue;
|
|
1576
1601
|
let n = String(e.call_id || e.tool_call_id || "").trim(), r = e.is_error === !0 || e.error != null;
|
|
1577
1602
|
return {
|
|
1578
1603
|
callId: n,
|
|
@@ -1594,7 +1619,7 @@ function Z(e, t, n, r) {
|
|
|
1594
1619
|
...i && i !== a ? { SourceItemId: i } : {}
|
|
1595
1620
|
} };
|
|
1596
1621
|
}
|
|
1597
|
-
var
|
|
1622
|
+
var ot = class {
|
|
1598
1623
|
textByPart = /* @__PURE__ */ new Map();
|
|
1599
1624
|
toolNameByCallId = /* @__PURE__ */ new Map();
|
|
1600
1625
|
toolCallByItemId = /* @__PURE__ */ new Map();
|
|
@@ -1604,7 +1629,7 @@ var it = class {
|
|
|
1604
1629
|
this.sessionId = e;
|
|
1605
1630
|
}
|
|
1606
1631
|
translate(e) {
|
|
1607
|
-
if (!
|
|
1632
|
+
if (!q(e)) return null;
|
|
1608
1633
|
let t = Number(e.seq);
|
|
1609
1634
|
if (!Number.isFinite(t) || t <= 0) return null;
|
|
1610
1635
|
let n = String(e.family || ""), r = String(e.event_type || ""), i = String(e.run_id || ""), a = () => ({
|
|
@@ -1626,7 +1651,7 @@ var it = class {
|
|
|
1626
1651
|
};
|
|
1627
1652
|
if (r === "control.run_transition") {
|
|
1628
1653
|
let t = String(e.state || "").toLowerCase();
|
|
1629
|
-
if (
|
|
1654
|
+
if (Qe.has(t)) return {
|
|
1630
1655
|
...a(),
|
|
1631
1656
|
EventType: "run_status",
|
|
1632
1657
|
Content: { status: t }
|
|
@@ -1635,19 +1660,19 @@ var it = class {
|
|
|
1635
1660
|
return null;
|
|
1636
1661
|
}
|
|
1637
1662
|
if (n !== "runtime") return null;
|
|
1638
|
-
let o =
|
|
1663
|
+
let o = q(q(e.source)?.metadata), s = o?.conversation_visibility ?? o?.visibility;
|
|
1639
1664
|
if (r.startsWith("item.") && ["internal", "hidden"].includes(String(s))) return null;
|
|
1640
|
-
let c =
|
|
1665
|
+
let c = Ze[r];
|
|
1641
1666
|
if (c) return {
|
|
1642
1667
|
...a(),
|
|
1643
1668
|
EventType: "run_status",
|
|
1644
1669
|
Content: { status: c }
|
|
1645
1670
|
};
|
|
1646
|
-
let l =
|
|
1671
|
+
let l = $e(e);
|
|
1647
1672
|
if (r === "item.started") {
|
|
1648
|
-
let t =
|
|
1673
|
+
let t = J(e, "initial");
|
|
1649
1674
|
if (e.item_kind === "tool_call") {
|
|
1650
|
-
let n =
|
|
1675
|
+
let n = it(t);
|
|
1651
1676
|
if (!n) return null;
|
|
1652
1677
|
let r = n?.callId || String(e.item_id || ""), o = n?.name || "tool";
|
|
1653
1678
|
return r && this.toolNameByCallId.set(r, o), e.item_id && this.toolCallByItemId.set(String(e.item_id), {
|
|
@@ -1661,11 +1686,11 @@ var it = class {
|
|
|
1661
1686
|
call_id: r,
|
|
1662
1687
|
tool_name: o,
|
|
1663
1688
|
run_id: i,
|
|
1664
|
-
tool_args: n?.arguments ??
|
|
1689
|
+
tool_args: n?.arguments ?? X(t)
|
|
1665
1690
|
}
|
|
1666
1691
|
};
|
|
1667
1692
|
}
|
|
1668
|
-
return e.item_kind === "tool_result" || l === "userMessage" ||
|
|
1693
|
+
return e.item_kind === "tool_result" || l === "userMessage" || tt(t) || l === "reasoning" || e.item_kind === "reasoning" ? null : l === "agentMessage" || !l && e.item_kind === "message" ? {
|
|
1669
1694
|
...a(),
|
|
1670
1695
|
EventType: "assistant_stream_snapshot",
|
|
1671
1696
|
Content: { parts: [{ text: "" }] },
|
|
@@ -1678,14 +1703,14 @@ var it = class {
|
|
|
1678
1703
|
call_id: String(e.item_id || ""),
|
|
1679
1704
|
tool_name: l,
|
|
1680
1705
|
run_id: i,
|
|
1681
|
-
tool_args:
|
|
1706
|
+
tool_args: X(t)
|
|
1682
1707
|
}
|
|
1683
1708
|
} : null;
|
|
1684
1709
|
}
|
|
1685
1710
|
if (r === "item.updated") {
|
|
1686
|
-
let n =
|
|
1711
|
+
let n = J(e, "update");
|
|
1687
1712
|
if (e.item_kind === "tool_call") {
|
|
1688
|
-
let t =
|
|
1713
|
+
let t = at(n);
|
|
1689
1714
|
if (!t) return null;
|
|
1690
1715
|
let r = this.toolCallByItemId.get(String(e.item_id || "")), o = t.callId || r?.callId || String(e.item_id || ""), s = r?.name || this.toolNameByCallId.get(o) || "tool", c = t.isError ? { error: t.result } : t.result;
|
|
1691
1716
|
return e.item_id && this.toolResultByItemId.set(String(e.item_id), c), {
|
|
@@ -1700,7 +1725,7 @@ var it = class {
|
|
|
1700
1725
|
}
|
|
1701
1726
|
};
|
|
1702
1727
|
}
|
|
1703
|
-
let r =
|
|
1728
|
+
let r = q(n[0]), o = String(r?.part_id || e.item_id || t), s = String(e.op || "replace"), c = Y(n), u = this.textByPart.get(o) || "", d = s === "append" ? u + c : c;
|
|
1704
1729
|
return this.textByPart.set(o, d), l === "agentMessage" || !l && e.item_kind === "message" ? {
|
|
1705
1730
|
...a(),
|
|
1706
1731
|
EventType: "assistant_stream_snapshot",
|
|
@@ -1714,7 +1739,7 @@ var it = class {
|
|
|
1714
1739
|
} : null;
|
|
1715
1740
|
}
|
|
1716
1741
|
if (r === "item.snapshot_replaced") {
|
|
1717
|
-
let n =
|
|
1742
|
+
let n = J(e, "snapshot"), r = String(q(n[0])?.part_id || e.item_id || t), i = Y(n);
|
|
1718
1743
|
return this.textByPart.set(r, i), l === "agentMessage" || !l && e.item_kind === "message" ? {
|
|
1719
1744
|
...a(),
|
|
1720
1745
|
EventType: "assistant_stream_snapshot",
|
|
@@ -1728,9 +1753,9 @@ var it = class {
|
|
|
1728
1753
|
} : null;
|
|
1729
1754
|
}
|
|
1730
1755
|
if (r === "item.completed") {
|
|
1731
|
-
let n =
|
|
1756
|
+
let n = J(e, "snapshot");
|
|
1732
1757
|
if (e.item_kind === "tool_call") {
|
|
1733
|
-
let t =
|
|
1758
|
+
let t = it(n), r = at(n), o = this.toolCallByItemId.get(String(e.item_id || "")), s = r?.callId || t?.callId || o?.callId || String(e.item_id || ""), c = t?.name || o?.name || this.toolNameByCallId.get(s) || "tool";
|
|
1734
1759
|
if (s && this.toolNameByCallId.set(s, c), r) {
|
|
1735
1760
|
let t = r.isError ? { error: r.result } : r.result;
|
|
1736
1761
|
return {
|
|
@@ -1753,12 +1778,12 @@ var it = class {
|
|
|
1753
1778
|
call_id: s,
|
|
1754
1779
|
tool_name: c,
|
|
1755
1780
|
run_id: i,
|
|
1756
|
-
tool_args: t?.arguments ??
|
|
1781
|
+
tool_args: t?.arguments ?? X(n)
|
|
1757
1782
|
}
|
|
1758
1783
|
};
|
|
1759
1784
|
}
|
|
1760
1785
|
if (e.item_kind === "tool_result") {
|
|
1761
|
-
let t =
|
|
1786
|
+
let t = at(n), r = t?.callId || String(e.item_id || ""), o = this.toolNameByCallId.get(r) || l || "tool", s = t?.isError ? { error: t.result } : t?.result ?? X(n);
|
|
1762
1787
|
return {
|
|
1763
1788
|
...a(),
|
|
1764
1789
|
EventType: "tool_result",
|
|
@@ -1771,13 +1796,13 @@ var it = class {
|
|
|
1771
1796
|
}
|
|
1772
1797
|
};
|
|
1773
1798
|
}
|
|
1774
|
-
if (l === "userMessage" ||
|
|
1799
|
+
if (l === "userMessage" || tt(n)) return {
|
|
1775
1800
|
...a(),
|
|
1776
1801
|
EventType: "user_message",
|
|
1777
|
-
Content: { parts: [{ text:
|
|
1802
|
+
Content: { parts: [{ text: Y(n) }] }
|
|
1778
1803
|
};
|
|
1779
1804
|
if (l === "agentMessage" || !l && e.item_kind === "message") {
|
|
1780
|
-
let r =
|
|
1805
|
+
let r = Y(n), i = String(q(n[0])?.part_id || e.item_id || t);
|
|
1781
1806
|
return this.textByPart.set(i, r), {
|
|
1782
1807
|
...a(),
|
|
1783
1808
|
EventType: "assistant_message",
|
|
@@ -1786,11 +1811,11 @@ var it = class {
|
|
|
1786
1811
|
};
|
|
1787
1812
|
}
|
|
1788
1813
|
if (l === "reasoning" || e.item_kind === "reasoning") {
|
|
1789
|
-
let r = String(
|
|
1814
|
+
let r = String(q(n[0])?.part_id || e.item_id || t);
|
|
1790
1815
|
return {
|
|
1791
1816
|
...a(),
|
|
1792
1817
|
EventType: "reasoning",
|
|
1793
|
-
Content: { parts: [{ text:
|
|
1818
|
+
Content: { parts: [{ text: Y(n) }] },
|
|
1794
1819
|
Metadata: Z(e, "completed", r)
|
|
1795
1820
|
};
|
|
1796
1821
|
}
|
|
@@ -1802,7 +1827,7 @@ var it = class {
|
|
|
1802
1827
|
call_id: String(e.item_id || ""),
|
|
1803
1828
|
tool_name: l,
|
|
1804
1829
|
run_id: i,
|
|
1805
|
-
tool_output:
|
|
1830
|
+
tool_output: X(n)
|
|
1806
1831
|
}
|
|
1807
1832
|
} : null;
|
|
1808
1833
|
}
|
|
@@ -1817,7 +1842,7 @@ var it = class {
|
|
|
1817
1842
|
call_id: n,
|
|
1818
1843
|
tool_name: r,
|
|
1819
1844
|
run_id: i,
|
|
1820
|
-
tool_output: o ?? { error:
|
|
1845
|
+
tool_output: o ?? { error: q(e.error) || e.error || "item failed" }
|
|
1821
1846
|
}
|
|
1822
1847
|
};
|
|
1823
1848
|
}
|
|
@@ -1829,14 +1854,14 @@ var it = class {
|
|
|
1829
1854
|
call_id: String(e.item_id || ""),
|
|
1830
1855
|
tool_name: l,
|
|
1831
1856
|
run_id: i,
|
|
1832
|
-
tool_output: { error:
|
|
1857
|
+
tool_output: { error: q(e.error) || e.error || "item failed" }
|
|
1833
1858
|
}
|
|
1834
1859
|
} : null;
|
|
1835
1860
|
}
|
|
1836
1861
|
return null;
|
|
1837
1862
|
}
|
|
1838
1863
|
};
|
|
1839
|
-
async function
|
|
1864
|
+
async function st(e) {
|
|
1840
1865
|
let t = e.getReader(), n = new TextDecoder(), r = "", i = null, a = !1, o = (e) => e.includes("data:") || e.includes("event:") || e.includes(":");
|
|
1841
1866
|
try {
|
|
1842
1867
|
for (;;) {
|
|
@@ -1846,8 +1871,8 @@ async function at(e) {
|
|
|
1846
1871
|
break;
|
|
1847
1872
|
}
|
|
1848
1873
|
if (r.trimStart().startsWith("{")) {
|
|
1849
|
-
if (
|
|
1850
|
-
i =
|
|
1874
|
+
if (ct(r)) {
|
|
1875
|
+
i = lt(r);
|
|
1851
1876
|
break;
|
|
1852
1877
|
}
|
|
1853
1878
|
} else if (o(r)) break;
|
|
@@ -1883,7 +1908,7 @@ async function at(e) {
|
|
|
1883
1908
|
stream: c
|
|
1884
1909
|
};
|
|
1885
1910
|
}
|
|
1886
|
-
function
|
|
1911
|
+
function ct(e) {
|
|
1887
1912
|
let t = e.trim();
|
|
1888
1913
|
if (!t.endsWith("}")) return !1;
|
|
1889
1914
|
let n = 0, r = !1, i = !1;
|
|
@@ -1900,11 +1925,11 @@ function ot(e) {
|
|
|
1900
1925
|
}
|
|
1901
1926
|
return n === 0;
|
|
1902
1927
|
}
|
|
1903
|
-
function
|
|
1928
|
+
function lt(e) {
|
|
1904
1929
|
try {
|
|
1905
|
-
let t =
|
|
1930
|
+
let t = q(JSON.parse(e).Data), n = String(t?.ReceiptStatus || "");
|
|
1906
1931
|
if (!n) return null;
|
|
1907
|
-
let r =
|
|
1932
|
+
let r = q(t?.Error);
|
|
1908
1933
|
return {
|
|
1909
1934
|
status: n,
|
|
1910
1935
|
presentationProfile: t?.PresentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1",
|
|
@@ -1926,8 +1951,8 @@ function st(e) {
|
|
|
1926
1951
|
function Q(e) {
|
|
1927
1952
|
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
1928
1953
|
}
|
|
1929
|
-
function
|
|
1930
|
-
let t = e.map(
|
|
1954
|
+
function ut(e) {
|
|
1955
|
+
let t = e.map(pt), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = (e, t, n) => JSON.stringify([
|
|
1931
1956
|
e,
|
|
1932
1957
|
t,
|
|
1933
1958
|
n
|
|
@@ -1955,7 +1980,7 @@ function ct(e) {
|
|
|
1955
1980
|
} : e;
|
|
1956
1981
|
});
|
|
1957
1982
|
}
|
|
1958
|
-
function
|
|
1983
|
+
function dt(e) {
|
|
1959
1984
|
if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
|
|
1960
1985
|
if (typeof e == "string" && e.trim()) {
|
|
1961
1986
|
let t = Number(e.trim());
|
|
@@ -1964,7 +1989,7 @@ function lt(e) {
|
|
|
1964
1989
|
let t = Date.parse(String(e || ""));
|
|
1965
1990
|
return Number.isFinite(t) ? t : Date.now();
|
|
1966
1991
|
}
|
|
1967
|
-
function
|
|
1992
|
+
function ft(e, t, r, i, a) {
|
|
1968
1993
|
let o = /* @__PURE__ */ new Set(), s = (e, t) => JSON.stringify([e, t]), c = /* @__PURE__ */ new Set();
|
|
1969
1994
|
for (let e of t) {
|
|
1970
1995
|
let t = n(e, i);
|
|
@@ -2035,7 +2060,7 @@ function ut(e, t, r, i, a) {
|
|
|
2035
2060
|
};
|
|
2036
2061
|
return e.map(d);
|
|
2037
2062
|
}
|
|
2038
|
-
function
|
|
2063
|
+
function pt(e) {
|
|
2039
2064
|
let t = Q(e?.Content?.runtime_event || e?.Content?.runtimeEvent);
|
|
2040
2065
|
if (t && String(t.event_type || "")) return {
|
|
2041
2066
|
...t,
|
|
@@ -2055,10 +2080,10 @@ function dt(e) {
|
|
|
2055
2080
|
timestamp: e.Timestamp || n.timestamp || r.timestamp
|
|
2056
2081
|
};
|
|
2057
2082
|
}
|
|
2058
|
-
function
|
|
2083
|
+
function mt(e, t, n) {
|
|
2059
2084
|
let i = /* @__PURE__ */ new Map();
|
|
2060
2085
|
for (let e of t) {
|
|
2061
|
-
if (e.EventType !== "run_status" ||
|
|
2086
|
+
if (e.EventType !== "run_status" || pt(e)) continue;
|
|
2062
2087
|
let t = String(e.InvocationId || e.Metadata?.run_id || "").trim();
|
|
2063
2088
|
t && !n.has(t) && i.set(t, e);
|
|
2064
2089
|
}
|
|
@@ -2067,7 +2092,7 @@ function ft(e, t, n) {
|
|
|
2067
2092
|
let n = r({
|
|
2068
2093
|
...t,
|
|
2069
2094
|
EventId: t.EventId || `legacy-terminal:${e}:${t.SeqId || 0}`,
|
|
2070
|
-
Timestamp:
|
|
2095
|
+
Timestamp: dt(t.Timestamp)
|
|
2071
2096
|
});
|
|
2072
2097
|
if (!n) continue;
|
|
2073
2098
|
let i = (t) => (t.invocationId || t.runId) === e;
|
|
@@ -2101,12 +2126,12 @@ function ft(e, t, n) {
|
|
|
2101
2126
|
eventId: t.EventId
|
|
2102
2127
|
});
|
|
2103
2128
|
}
|
|
2104
|
-
return a === e ? e :
|
|
2129
|
+
return a === e ? e : z(a);
|
|
2105
2130
|
}
|
|
2106
2131
|
function $(e) {
|
|
2107
2132
|
return e.role === "model" ? {
|
|
2108
2133
|
...e,
|
|
2109
|
-
blocks: e.blocks?.length ? e.blocks :
|
|
2134
|
+
blocks: e.blocks?.length ? e.blocks : Xe({
|
|
2110
2135
|
content: e.content,
|
|
2111
2136
|
reasoning: e.reasoning,
|
|
2112
2137
|
reasoningSource: e.reasoningSource,
|
|
@@ -2114,7 +2139,7 @@ function $(e) {
|
|
|
2114
2139
|
})
|
|
2115
2140
|
} : e;
|
|
2116
2141
|
}
|
|
2117
|
-
function
|
|
2142
|
+
function ht(e, t) {
|
|
2118
2143
|
let n = t.find((e) => e.role === "user"), r = e.some((e) => e.role === "user"), i = t.filter((e) => e.role === "model"), a = e.filter((e) => e.role === "model").at(-1), o = i.at(-1), s = e.map((e) => e.role === "user" && n ? {
|
|
2119
2144
|
...e,
|
|
2120
2145
|
...n,
|
|
@@ -2127,7 +2152,7 @@ function pt(e, t) {
|
|
|
2127
2152
|
} : e));
|
|
2128
2153
|
return n && !r ? [n, ...s] : s;
|
|
2129
2154
|
}
|
|
2130
|
-
function
|
|
2155
|
+
function gt(e, t) {
|
|
2131
2156
|
let n = t.filter((e) => e.role === "model"), r = n.flatMap((e) => Object.values(e.tools || {}).map((t) => ({
|
|
2132
2157
|
tool: t,
|
|
2133
2158
|
scope: e.scopeId
|
|
@@ -2142,7 +2167,7 @@ function mt(e, t) {
|
|
|
2142
2167
|
return [t, r ? {
|
|
2143
2168
|
...n,
|
|
2144
2169
|
...r,
|
|
2145
|
-
...
|
|
2170
|
+
...F(n, r),
|
|
2146
2171
|
name: n.name
|
|
2147
2172
|
} : n];
|
|
2148
2173
|
})), n = e === s ? a : [];
|
|
@@ -2155,9 +2180,9 @@ function mt(e, t) {
|
|
|
2155
2180
|
let n = t.extra?.callId, r = typeof n == "string" ? i(n, e.scopeId) : void 0;
|
|
2156
2181
|
return r ? {
|
|
2157
2182
|
...t,
|
|
2158
|
-
...
|
|
2183
|
+
...F(t, r)
|
|
2159
2184
|
} : t;
|
|
2160
|
-
}), c =
|
|
2185
|
+
}), c = Xe({ tools: Object.fromEntries(n.map(({ tool: e, scope: t }) => [JSON.stringify([t || "", e.callId || e.name]), e])) }), l = r?.findIndex((e) => e.type === "text") ?? -1;
|
|
2161
2186
|
return $({
|
|
2162
2187
|
...e,
|
|
2163
2188
|
...e === s ? { reasoning: e.reasoning || o || void 0 } : {},
|
|
@@ -2170,21 +2195,21 @@ function mt(e, t) {
|
|
|
2170
2195
|
});
|
|
2171
2196
|
});
|
|
2172
2197
|
}
|
|
2173
|
-
function
|
|
2198
|
+
function _t(e) {
|
|
2174
2199
|
return new Set(e.filter((e) => e.role === "model" && e.eventType === "assistant_message" && !!String(e.content || "").trim() && !!e.invocationId).map((e) => String(e.invocationId)));
|
|
2175
2200
|
}
|
|
2176
|
-
var
|
|
2201
|
+
var vt = new Set([
|
|
2177
2202
|
"approval.resolved",
|
|
2178
2203
|
"interaction.resolved",
|
|
2179
2204
|
"interaction.cancelled",
|
|
2180
2205
|
"interaction.canceled",
|
|
2181
2206
|
"a2ui.action"
|
|
2182
2207
|
]);
|
|
2183
|
-
function
|
|
2208
|
+
function yt(e) {
|
|
2184
2209
|
let t = /* @__PURE__ */ new Set();
|
|
2185
2210
|
for (let n of e) {
|
|
2186
2211
|
let e = Q(n.Content) || {}, r = Q(e.runtime_event || e.runtimeEvent) || {}, i = Q(e.payload) || Q(r.payload) || {}, a = String(n.EventType || e.event_type || e.eventType || r.event_type || "").toLowerCase();
|
|
2187
|
-
if (!
|
|
2212
|
+
if (!vt.has(a)) continue;
|
|
2188
2213
|
let o = String(e.outcome || e.action || e.name || e.status || i.outcome || i.action || i.name || i.status || "").toLowerCase();
|
|
2189
2214
|
if (![
|
|
2190
2215
|
"cancel",
|
|
@@ -2196,64 +2221,66 @@ function _t(e) {
|
|
|
2196
2221
|
}
|
|
2197
2222
|
return t;
|
|
2198
2223
|
}
|
|
2199
|
-
function
|
|
2200
|
-
e =
|
|
2201
|
-
let
|
|
2224
|
+
function bt(e, t, n, r = "flat-v1", a) {
|
|
2225
|
+
e = I(e);
|
|
2226
|
+
let o = new ot(n), s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = [...t || []].filter((e) => {
|
|
2202
2227
|
let t = e.Content, r = Q(t?.session_event || t?.sessionEvent), i = Q(t?.runtime_event || t?.runtimeEvent);
|
|
2203
2228
|
return [
|
|
2204
2229
|
e.SessionId,
|
|
2205
2230
|
r?.session_id,
|
|
2206
2231
|
i?.session_id
|
|
2207
2232
|
].every((e) => !e || e === n);
|
|
2208
|
-
}).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)),
|
|
2209
|
-
for (let [e, t] of
|
|
2210
|
-
let n =
|
|
2233
|
+
}).sort((e, t) => Number(e.SeqId || 0) - Number(t.SeqId || 0)), f = Number(a ?? d[0]?.SeqId ?? 0) <= 1, p = ut(d);
|
|
2234
|
+
for (let [e, t] of d.entries()) {
|
|
2235
|
+
let n = p[e];
|
|
2211
2236
|
if (!n) continue;
|
|
2212
2237
|
let r = String(n.run_id || "").trim();
|
|
2213
2238
|
if (r) {
|
|
2214
|
-
|
|
2239
|
+
c.add(r), !n.parent_scope_id && [
|
|
2215
2240
|
"run.completed",
|
|
2216
2241
|
"run.failed",
|
|
2217
2242
|
"run.cancelled",
|
|
2218
2243
|
"run.canceled"
|
|
2219
|
-
].includes(String(n.event_type)) &&
|
|
2244
|
+
].includes(String(n.event_type)) && l.add(r);
|
|
2220
2245
|
let e = Q(Q(n.source)?.metadata), t = String(n.event_type || "") === "run.started", i = e?.native_item_kind === "userMessage";
|
|
2221
|
-
(
|
|
2246
|
+
(f || t || i) && u.add(r);
|
|
2222
2247
|
}
|
|
2223
|
-
let i =
|
|
2224
|
-
i &&
|
|
2248
|
+
let i = o.translate(n);
|
|
2249
|
+
i && s.push({
|
|
2225
2250
|
...i,
|
|
2226
2251
|
SeqId: Number(t.SeqId || i.SeqId || 0),
|
|
2227
|
-
Timestamp:
|
|
2252
|
+
Timestamp: dt(t.Timestamp || i.Timestamp)
|
|
2228
2253
|
});
|
|
2229
2254
|
}
|
|
2230
|
-
let
|
|
2255
|
+
let m = i(s).filter((e) => e.invocationId && c.has(e.invocationId)), h = /* @__PURE__ */ new Map();
|
|
2231
2256
|
for (let t of e) {
|
|
2232
2257
|
let e = String(t.invocationId || "");
|
|
2233
|
-
|
|
2258
|
+
if (!e) continue;
|
|
2259
|
+
let n = h.get(e);
|
|
2260
|
+
n ? n.push(t) : h.set(e, [t]);
|
|
2234
2261
|
}
|
|
2235
|
-
let
|
|
2236
|
-
for (let e of
|
|
2262
|
+
let g = new Set([..._t(m)].filter((e) => u.has(e))), _ = /* @__PURE__ */ new Map();
|
|
2263
|
+
for (let e of p) {
|
|
2237
2264
|
if (e?.schema_version !== 2 || !e.run_id) continue;
|
|
2238
|
-
let t = String(e.run_id), n =
|
|
2239
|
-
n.push(e),
|
|
2265
|
+
let t = String(e.run_id), n = _.get(t) || [];
|
|
2266
|
+
n.push(e), _.set(t, n);
|
|
2240
2267
|
}
|
|
2241
|
-
let
|
|
2268
|
+
let v = (e) => [
|
|
2242
2269
|
Q(e.initial),
|
|
2243
2270
|
Q(e.snapshot),
|
|
2244
2271
|
Q(e.update)
|
|
2245
|
-
].some((e) => Q(e?.data)?.schema === "execution.scope/v1" || Array.isArray(e?.parts) && e.parts.some((e) => Q(Q(e)?.data)?.schema === "execution.scope/v1")),
|
|
2246
|
-
for (let [e, t] of
|
|
2247
|
-
if (!
|
|
2272
|
+
].some((e) => Q(e?.data)?.schema === "execution.scope/v1" || Array.isArray(e?.parts) && e.parts.some((e) => Q(Q(e)?.data)?.schema === "execution.scope/v1")), y = new Set([..._].filter(([, e]) => e.some(v)).map(([e]) => e)), b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
|
|
2273
|
+
for (let [e, t] of _) {
|
|
2274
|
+
if (!y.has(e) && !g.has(e) && !t.some((e) => ["item.failed", "run.failed"].includes(String(e.event_type)))) continue;
|
|
2248
2275
|
let i = t.some((e) => e.event_type === "run.started" && !e.parent_scope_id), a = /* @__PURE__ */ new Set(), o = t.every((e) => {
|
|
2249
2276
|
let t = JSON.stringify([e.scope_id, e.item_id]);
|
|
2250
|
-
return e.event_type === "item.started" && a.add(t), !
|
|
2277
|
+
return e.event_type === "item.started" && a.add(t), !v(e) || a.has(t);
|
|
2251
2278
|
});
|
|
2252
2279
|
if (!(!i || !o)) try {
|
|
2253
2280
|
let i = new w(n, void 0, r);
|
|
2254
2281
|
t.forEach((e) => i.apply(e));
|
|
2255
|
-
let a = i.snapshot(), o =
|
|
2256
|
-
|
|
2282
|
+
let a = i.snapshot(), o = fe(a, { profile: r }), s = dt(t[0].timestamp);
|
|
2283
|
+
b.set(e, W({
|
|
2257
2284
|
state: a,
|
|
2258
2285
|
presentation: o,
|
|
2259
2286
|
runId: e,
|
|
@@ -2271,36 +2298,36 @@ function vt(e, t, n, r = "flat-v1") {
|
|
|
2271
2298
|
};
|
|
2272
2299
|
}));
|
|
2273
2300
|
} catch (t) {
|
|
2274
|
-
|
|
2301
|
+
x.add(e), console.warn(`[SessionHistory] strict replay skipped for run ${e}:`, t instanceof Error ? t.message : "invalid runtime history");
|
|
2275
2302
|
}
|
|
2276
2303
|
}
|
|
2277
|
-
for (let e of new Set([...
|
|
2278
|
-
let
|
|
2279
|
-
for (let [e, t] of
|
|
2280
|
-
if (
|
|
2281
|
-
let n =
|
|
2282
|
-
|
|
2283
|
-
}
|
|
2284
|
-
for (let e of
|
|
2285
|
-
let ee = new Map([...
|
|
2286
|
-
...e.filter((e) => !(e.role === "model" && e.invocationId &&
|
|
2287
|
-
...
|
|
2288
|
-
...
|
|
2304
|
+
for (let e of new Set([...y, ...x])) b.has(e) || g.delete(e);
|
|
2305
|
+
let S = yt(d), C = [...g].flatMap((e) => ht(m.filter((t) => t.invocationId === e), h.get(e) || [])), T = /* @__PURE__ */ new Map(), E = [];
|
|
2306
|
+
for (let [e, t] of h) {
|
|
2307
|
+
if (g.has(e) || !c.has(e)) continue;
|
|
2308
|
+
let n = m.filter((t) => t.invocationId === e), r = t.some((e) => e.role === "model" && String(e.content || "").trim());
|
|
2309
|
+
T.set(e, r ? gt(t, n) : t), r || E.push(...n.map($));
|
|
2310
|
+
}
|
|
2311
|
+
for (let e of c) g.has(e) || h.has(e) || E.push(...m.filter((t) => t.invocationId === e).map($));
|
|
2312
|
+
let ee = new Map([...T.values()].flat().map((e) => [e.id, e])), D = z([
|
|
2313
|
+
...e.filter((e) => !(e.role === "model" && e.invocationId && S.has(e.invocationId)) && (e.role === "a2ui" || !e.invocationId || !g.has(e.invocationId))).map((e) => ee.get(e.id) || e),
|
|
2314
|
+
...C,
|
|
2315
|
+
...E
|
|
2289
2316
|
]);
|
|
2290
|
-
for (let [e, t] of
|
|
2317
|
+
for (let [e, t] of b) {
|
|
2291
2318
|
if (!t.length) continue;
|
|
2292
|
-
let n = (t) => t.invocationId === e || t.runId === e, r =
|
|
2293
|
-
|
|
2319
|
+
let n = (t) => t.invocationId === e || t.runId === e, r = D.findIndex(n), i = D.filter(n), a = i.find((e) => e.role === "user"), o = y.has(e) ? a && !t.some((e) => e.role === "user") ? [a, ...t] : t : ht(t, i), s = D.filter((e) => !n(e)), c = r < 0 ? s.length : r;
|
|
2320
|
+
D = [
|
|
2294
2321
|
...s.slice(0, c),
|
|
2295
2322
|
...o,
|
|
2296
2323
|
...s.slice(c)
|
|
2297
|
-
],
|
|
2324
|
+
], g.add(e);
|
|
2298
2325
|
}
|
|
2299
2326
|
return {
|
|
2300
|
-
messages:
|
|
2301
|
-
canonicalRunIds: [...
|
|
2302
|
-
translatedEvents:
|
|
2327
|
+
messages: ft(I(z(mt(D, d, l))), d, p, n, l),
|
|
2328
|
+
canonicalRunIds: [...g],
|
|
2329
|
+
translatedEvents: s
|
|
2303
2330
|
};
|
|
2304
2331
|
}
|
|
2305
2332
|
//#endregion
|
|
2306
|
-
export {
|
|
2333
|
+
export { fe as C, w as D, E, C as O, Se as S, D as T, z as _, We as a, Te as b, Ke as c, Ue as d, qe as f, Oe as g, W as h, st as i, Ye as l, Be as m, bt as n, He as o, Je as p, ot as r, Xe as s, pt as t, Ge as u, Ee as v, O as w, we as x, I as y };
|