@kingsoftcloud/ksadk-web 0.3.19 → 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 +6 -0
- package/README.md +2 -2
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-cjsDWTLW.js → ArtifactsPanel-xJrZLoUS.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-DTtT6SBI.js → CodeBlock-BTA9jlFc.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-Dap7DsE1.js → MathMessageMarkdown-D8CLDYjs.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-C2QkLej8.js → MermaidBlock-3yYZbQx6.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-CeLWBCnF.js → NativeTerminalPanel-D4Ndrv99.js} +1 -1
- package/dist-ksadk/assets/{OfficialA2uiRenderer-BshRBsxZ.js → OfficialA2uiRenderer-B8MknRNx.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-RvCk4kKS.js → abnfDiagram-VCTEODGH-F1iqB6Wc.js} +1 -1
- package/dist-ksadk/assets/{arc-R-NvbHBi.js → arc-flL4n_cG.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-CVbS66_3.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-CWyeEVzn.js → architectureDiagram-5GKGNRK7-BwmlMIkR.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-CHbhUWj9.js → blockDiagram-NRAW4CY4-C_BWAm_x.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BJAftB45.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-BHufOSfh.js → chunk-5VM5RSS4-C1Ojz8Pw.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-BNPW42o9.js → chunk-F27PBJKO-BBOOiT8C.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-D_eOFZiC.js → chunk-G27WJ6UU-BhhwsUX3.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-DEVN_PSR.js → chunk-JWPE2WC7-iEW3AJI-.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-DjGV_Lnh.js → chunk-LCL6LL3I-DIuXy-81.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-C2i8ZB07.js → chunk-POPQ4Y6H-ykIsvKaZ.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-DMk7_iWC.js → chunk-RHFEMEQ7-CNMnEM31.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-wHQkXddN.js → chunk-SVP7TREG-C1xb4D9y.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-gvpc9yiQ.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-BF-zBbK8.js → cose-bilkent-JH36ORCC-BTnDFOg9.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-BdJIG45e.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-0_hg7nkA.js → cynefinDiagram-5FMLGOSQ-BhCQoeu0.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-uSuKjV2i.js → dagre-3AP2YEHR-QU3SAyBp.js} +1 -1
- package/dist-ksadk/assets/{dagre-BCQPdEAN.js → dagre-CcBuTmO1.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-ay17NfAC.js → diagram-S7CK7UJ4-pUqMF-N_.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-CaUhPrNE.js → diagram-UQ7AKVKN-CsBd6UK1.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-upF8B0NL.js → diagram-VSXAHHWV-z067B8w9.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-B4t46LEt.js → diagram-VX7I27RA-Bq2OSM3W.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-BeHjswE7.js → diagram-Z3DM3KII-CGcOnXgQ.js} +1 -1
- package/dist-ksadk/assets/{dist-Bt4Xk1Ro.js → dist-29mR2j1z.js} +1 -1
- package/dist-ksadk/assets/{dist-CdhMAiGd.js → dist-B7wGQtoN.js} +1 -1
- package/dist-ksadk/assets/{dist-BGzoFqM2.js → dist-B82Nq4cr.js} +1 -1
- package/dist-ksadk/assets/{dist-58qYwY0M.js → dist-BBhjV2zk.js} +1 -1
- package/dist-ksadk/assets/{dist-C577ALLK.js → dist-BCeJUhFK.js} +1 -1
- package/dist-ksadk/assets/{dist-B0PMHWqd.js → dist-BFwycVyB.js} +1 -1
- package/dist-ksadk/assets/{dist-uAoeCAZ2.js → dist-BgNv7i6A.js} +1 -1
- package/dist-ksadk/assets/{dist-Dze75pZq.js → dist-BzzV3E1A.js} +1 -1
- package/dist-ksadk/assets/{dist-CIZ7o8ol.js → dist-CDVF37r5.js} +1 -1
- package/dist-ksadk/assets/{dist-AF7gi0D5.js → dist-CldkDS2P.js} +1 -1
- package/dist-ksadk/assets/{dist-DvOmTQAV.js → dist-CtBVJsc4.js} +1 -1
- package/dist-ksadk/assets/{dist-mkEF0-z9.js → dist-D2pftL-p.js} +1 -1
- package/dist-ksadk/assets/{dist-Be3VXZq8.js → dist-D4i4A-9H.js} +1 -1
- package/dist-ksadk/assets/{dist-BLCD6xMk.js → dist-DAvQipED.js} +1 -1
- package/dist-ksadk/assets/{dist-Bt0YWq2H.js → dist-DClJp8Fu.js} +1 -1
- package/dist-ksadk/assets/{dist-B0s4RUpo.js → dist-DLBTehW7.js} +1 -1
- package/dist-ksadk/assets/{dist-CW5ZHS5y.js → dist-DaTlP0PP.js} +1 -1
- package/dist-ksadk/assets/{dist-Bx4az-XW.js → dist-DkIK9AMC.js} +1 -1
- package/dist-ksadk/assets/{dist-DIeaHG12.js → dist-DoI7sPXP.js} +1 -1
- package/dist-ksadk/assets/{dist-COzkztpc.js → dist-DoiIiZp1.js} +1 -1
- package/dist-ksadk/assets/{dist-DfFlb9ip.js → dist-Hq4SADW4.js} +1 -1
- package/dist-ksadk/assets/{dist-h0bOCJVW.js → dist-uTNKHquK.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-CZKqGdhK.js → ebnfDiagram-PWID7BFC-B3R_tmjW.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CfQ9oOg4.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-CWdRcbsA.js → ganttDiagram-EL5Y4UJY-C8RKSSnW.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-K0gsLZ8v.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-S2TxceQ8.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-7M0hPUvw.js → infoDiagram-RXCK75RN-D6sVWyle.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-DApt_KC9.js → ishikawaDiagram-5VMMS53U-DrclE7fd.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-03NWnwcI.js → journeyDiagram-EYS64GPL-BRfZiBbu.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CWrM-ciB.js → kanban-definition-3QL26DDD-CNybbrEd.js} +1 -1
- package/dist-ksadk/assets/{katex-CVJEnrQQ.js → katex-DBOw26LR.js} +1 -1
- package/dist-ksadk/assets/{linear-CuvdttYn.js → linear-44nYnHX-.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-CyiGaINC.js → mermaid-parser.core-C_kQii2V.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-Cx8x9zok.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-BvMeLOBU.js → pegDiagram-XKGWAZYB-DegSzNRD.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-YFDBqoLw.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-BTEiUEUk.js → pieDiagram-E7YTZNPT-CxdzAjVe.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-CEMfGgSc.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-DjL0Ielv.js → railroadDiagram-O6MQD6OU-c0A7TkkT.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-Da11svpD.js → requirementDiagram-EFPCY7ZU-P6gr0KYk.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-DtKGEnlF.js → sankeyDiagram-P5KCCOFB-DC4nZ3Da.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-CR6Ct1Vm.js → sequenceDiagram-WJ2MYXX4-CZtmOwJw.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DaQE2An6.js → sizeCapture-X5ZJPWSS-Co1bu09k.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-Ct2KGWos.js → stateDiagram-HBIQ2CUA-BQVjMByH.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BdDvoPqK.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-BpIOaZ-N.js → swimlanes-XN3QIQJK-hlr6yX7f.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-CVQOLHam.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-CdwbtpKP.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-Dr_5LEwY.js → vennDiagram-4TSXK5OY-TSlD8LZX.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-DVbqgmoi.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DYojPjE8.js → wardleyDiagram-VM6X3IG4-COY6_ZHj.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-DV3dpSiv.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-COS-HmHj.js → AttachmentPreview-DPxeFYm-.js} +2 -2
- package/dist-lib/{ConnectedComposer-CB_YmxRQ.js → ConnectedComposer-CVMfDdns.js} +3 -3
- package/dist-lib/{ConnectedMessageList-CJgvv-Hi.js → ConnectedMessageList-BnRqhlEn.js} +924 -611
- package/dist-lib/{WorkspacePanelContainer-DU6mKsi5.js → WorkspacePanelContainer-3h8wgDJj.js} +2 -2
- package/dist-lib/{a2ui-e0gsVo7e.js → a2ui-DmynyrCk.js} +1 -1
- package/dist-lib/api/client.d.ts +1 -0
- package/dist-lib/api/client.d.ts.map +1 -1
- package/dist-lib/api/messages.d.ts +2 -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 +3 -3
- 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/HistoryAnchoredRows.d.ts +44 -0
- package/dist-lib/components/chat/HistoryAnchoredRows.d.ts.map +1 -0
- 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 +1 -0
- package/dist-lib/components/chat/types.d.ts.map +1 -1
- package/dist-lib/components.js +5 -5
- package/dist-lib/conversation.js +1 -1
- package/dist-lib/core/api/facade.d.ts +1 -3
- package/dist-lib/core/api/facade.d.ts.map +1 -1
- package/dist-lib/core/api/types.d.ts +1 -0
- 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 +1 -0
- package/dist-lib/core/run/engine.d.ts.map +1 -1
- package/dist-lib/core/run/types.d.ts +4 -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 +2 -1
- package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts +2 -0
- package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
- package/dist-lib/hooks.js +42 -41
- package/dist-lib/{permission-B9NRAmxP.js → permission-B60mkAsy.js} +1 -1
- package/dist-lib/{persisted-session-history-C8S6Tl-E.js → persisted-session-history-B9O1vWtS.js} +212 -203
- package/dist-lib/runtime.js +112 -110
- package/dist-lib/{session-events-BMRjrPq2.js → session-events-COiszsgX.js} +1 -0
- package/dist-lib/{feedback-nyK8zFEK.js → session-message-history-DC89pksC.js} +10 -2
- package/dist-lib/styles.css +1 -1
- package/dist-lib/{useSessionLifecycle-DPwSsODU.js → useSessionLifecycle-B0RRKS9m.js} +1042 -845
- 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/session-event-history.d.ts +1 -1
- package/dist-lib/utils/session-event-history.d.ts.map +1 -1
- package/dist-lib/utils/session-events.d.ts.map +1 -1
- package/dist-lib/utils/session-items.d.ts.map +1 -1
- 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 +1 -1
- package/dist-lib/utils/transcript-order.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-BgT_ltgS.js +0 -1
- package/dist-ksadk/assets/channel-CO8jKUdU.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-BQ7ktM_H.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-HRhUD6oW.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-HRhUD6oW.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-DlLbgFtT.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BgSxiUqa.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-Dcg0DKL0.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-DiYbIL_1.js +0 -1
- package/dist-ksadk/assets/index-CK5of5EC.js +0 -1135
- package/dist-ksadk/assets/index-ofLgkIsP.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-CIUhUhPM.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-CVt8vTzN.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-BmY8d_KC.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-D-vxRTHO.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-hDbxS9Gl.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-6j4dsPir.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-f3r0amOv.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DpGM5wUK.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-IHXiAplS.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-ByC69bCd.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-Bm72pNZV.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-Dpgkdt4o.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-C9w6FZRL.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as e, i as t, o as n, t as r } from "./capabilities-CHy70QGW.js";
|
|
2
|
-
import { E as i, I as a, J as o, K as s, L as c, M as l, N as u, O as d, V as f, W as p, X as m, Y as h, Z as g, a as _, b as v, c as y, d as b, f as x, k as S, l as ee, o as C, p as w, q as T, r as E, s as D, t as O, u as
|
|
3
|
-
import { C as A, a as j, d as M, f as N, i as
|
|
4
|
-
import { a as V, c as
|
|
5
|
-
import { a as
|
|
6
|
-
import { C as he, D as ge, E as _e, S as ve, T as ye, _ as be, a as xe, b as Se, c as Ce, d as we, f as Te, g as Ee, h as De, i as Oe, l as ke, m as Ae, n as je, o as Me, p as Ne, r as Pe, s as Fe, t as Ie, u as Le, v as Re, w as ze, y as Be } from "./persisted-session-history-
|
|
7
|
-
import { useCallback as
|
|
2
|
+
import { E as i, I as a, J as o, K as s, L as c, M as l, N as u, O as d, V as f, W as p, X as m, Y as h, Z as g, a as _, b as v, c as y, d as b, f as x, k as S, l as ee, o as C, p as w, q as T, r as E, s as D, t as O, u as k, v as te } from "./a2ui-DmynyrCk.js";
|
|
3
|
+
import { C as A, a as j, d as M, f as N, i as P, l as F, o as I, p as L, r as R, s as ne, t as z, u as re, x as B } from "./session-events-COiszsgX.js";
|
|
4
|
+
import { a as V, c as H, d as U, f as W, i as ie, l as ae, n as oe, o as G, p as K, r as se, s as ce, u as le } from "./session-message-history-DC89pksC.js";
|
|
5
|
+
import { a as ue, d as de, f as fe, p as pe, s as me } from "./reducer-mbYiX0wz.js";
|
|
6
|
+
import { C as he, D as ge, E as _e, S as ve, T as ye, _ as be, a as xe, b as Se, c as Ce, d as we, f as Te, g as Ee, h as De, i as Oe, l as ke, m as Ae, n as je, o as Me, p as Ne, r as Pe, s as Fe, t as Ie, u as Le, v as Re, w as ze, y as Be } from "./persisted-session-history-B9O1vWtS.js";
|
|
7
|
+
import { useCallback as q, useEffect as J, useMemo as Ve, useRef as Y, useState as He } from "react";
|
|
8
8
|
import { HttpAgent as Ue, buildResumeArray as We } from "@ag-ui/client";
|
|
9
9
|
//#region src/api/client.ts
|
|
10
|
-
var
|
|
10
|
+
var X = class extends Error {
|
|
11
11
|
code;
|
|
12
12
|
detail;
|
|
13
13
|
retryAfterMs;
|
|
@@ -17,7 +17,7 @@ var Y = class extends Error {
|
|
|
17
17
|
Number.isFinite(t) && (this.retryAfterMs = Math.max(0, t));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, Z = class extends Error {
|
|
21
21
|
constructor(e = "请求已取消") {
|
|
22
22
|
super(e), this.name = "CancelledError";
|
|
23
23
|
}
|
|
@@ -28,19 +28,19 @@ async function Ke(e) {
|
|
|
28
28
|
n = t ? JSON.parse(t) : {};
|
|
29
29
|
} catch {
|
|
30
30
|
let n = e.headers.get("content-type")?.toLowerCase() || "";
|
|
31
|
-
if ((e.status === 401 || e.status === 403) && (n.includes("text/html") || t.trimStart().startsWith("<"))) throw new
|
|
31
|
+
if ((e.status === 401 || e.status === 403) && (n.includes("text/html") || t.trimStart().startsWith("<"))) throw new X(e.status, "访问会话已失效,请从 Dashboard 或 Studio 的云端会话重新打开 Agent。");
|
|
32
32
|
if (!e.ok) {
|
|
33
33
|
let n = t.trim();
|
|
34
|
-
throw new
|
|
34
|
+
throw new X(e.status, n && n.length <= 256 && !n.startsWith("<") ? n : e.statusText || `HTTP ${e.status}`, t, e.headers.get("retry-after"));
|
|
35
35
|
}
|
|
36
|
-
throw new
|
|
36
|
+
throw new X(-2, "响应格式异常");
|
|
37
37
|
}
|
|
38
|
-
if (!e.ok) throw new
|
|
39
|
-
if (n?.Code !== void 0 && n.Code !== 0) throw new
|
|
38
|
+
if (!e.ok) throw new X(e.status, n?.Message || `HTTP ${e.status}`, n, e.headers.get("retry-after"));
|
|
39
|
+
if (n?.Code !== void 0 && n.Code !== 0) throw new X(n.Code, n.Message || "请求失败", n, e.headers.get("retry-after"));
|
|
40
40
|
return n.Data;
|
|
41
41
|
}
|
|
42
42
|
function qe(e) {
|
|
43
|
-
throw e instanceof DOMException && e.name === "AbortError" ? new
|
|
43
|
+
throw e instanceof DOMException && e.name === "AbortError" ? new Z() : e;
|
|
44
44
|
}
|
|
45
45
|
var Je = class {
|
|
46
46
|
fetcher;
|
|
@@ -96,11 +96,11 @@ var Je = class {
|
|
|
96
96
|
} catch (e) {
|
|
97
97
|
throw qe(e);
|
|
98
98
|
}
|
|
99
|
-
if (!o.ok) throw new
|
|
99
|
+
if (!o.ok) throw new X(o.status, `资源获取失败: ${o.statusText}`);
|
|
100
100
|
try {
|
|
101
101
|
return n?.asText ? await o.text() : await o.blob();
|
|
102
102
|
} catch {
|
|
103
|
-
throw new
|
|
103
|
+
throw new X(-3, "文件读取失败");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
async streamAction(e, t, n) {
|
|
@@ -118,9 +118,10 @@ var Je = class {
|
|
|
118
118
|
} catch (e) {
|
|
119
119
|
throw qe(e);
|
|
120
120
|
}
|
|
121
|
-
if (!r.ok) throw await Ke(r), new
|
|
122
|
-
if ((r.headers.get("content-type")?.toLowerCase() || "").includes("application/json") && await Ke(r.clone()), !r.body) throw new
|
|
123
|
-
|
|
121
|
+
if (!r.ok) throw await Ke(r), new X(r.status, `流式请求失败: ${r.statusText}`);
|
|
122
|
+
if ((r.headers.get("content-type")?.toLowerCase() || "").includes("application/json") && await Ke(r.clone()), !r.body) throw new X(-1, "无法获取响应流");
|
|
123
|
+
let i = r.headers.get("x-agentengine-command-id");
|
|
124
|
+
return i && n?.onCommandAdmitted?.(i), r.body;
|
|
124
125
|
}
|
|
125
126
|
async streamGetAction(e, t, n) {
|
|
126
127
|
let r = this.agentId && !t.AgentId ? {
|
|
@@ -135,14 +136,34 @@ var Je = class {
|
|
|
135
136
|
} catch (e) {
|
|
136
137
|
throw qe(e);
|
|
137
138
|
}
|
|
138
|
-
if (!o.ok || o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
139
|
-
if (!o.body) throw new
|
|
139
|
+
if (!o.ok || o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new X(502, "流式订阅未返回事件流", await Ke(o));
|
|
140
|
+
if (!o.body) throw new X(-1, "无法获取响应流");
|
|
140
141
|
return o.body;
|
|
141
142
|
}
|
|
142
|
-
}, Ye = new Je(), Xe = (e, t, n) => Ye.streamAction(e, t, n), Ze = (e, t, n) => Ye.streamGetAction(e, t, n);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
}, Ye = new Je(), Xe = (e, t, n) => Ye.streamAction(e, t, n), Ze = (e, t, n) => Ye.streamGetAction(e, t, n), Qe = 50, $e = 2500;
|
|
144
|
+
async function et(e, t) {
|
|
145
|
+
let { itemCursor: n, contentSeqId: r, limit: i, signal: a } = e ?? {};
|
|
146
|
+
if (!n || r !== void 0 || !i || i <= Qe) return t(i, a);
|
|
147
|
+
a?.throwIfAborted();
|
|
148
|
+
let o = new AbortController(), s = () => o.abort(a?.reason);
|
|
149
|
+
a?.addEventListener("abort", s, { once: !0 });
|
|
150
|
+
let c = Symbol("slow-history-page"), l;
|
|
151
|
+
try {
|
|
152
|
+
let e = t(i, o.signal), n = await Promise.race([e, new Promise((e) => {
|
|
153
|
+
l = setTimeout(() => e(c), $e);
|
|
154
|
+
})]);
|
|
155
|
+
if (n !== c) return n;
|
|
156
|
+
o.signal.throwIfAborted();
|
|
157
|
+
try {
|
|
158
|
+
return await Promise.any([e, t(Qe, o.signal)]);
|
|
159
|
+
} catch (e) {
|
|
160
|
+
throw e instanceof AggregateError ? e.errors[0] : e;
|
|
161
|
+
}
|
|
162
|
+
} finally {
|
|
163
|
+
clearTimeout(l), o.abort(), a?.removeEventListener("abort", s);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function tt(e) {
|
|
146
167
|
return {
|
|
147
168
|
HistoryView: e.HistoryView,
|
|
148
169
|
Items: e.Items,
|
|
@@ -167,7 +188,7 @@ function Qe(e) {
|
|
|
167
188
|
}
|
|
168
189
|
//#endregion
|
|
169
190
|
//#region src/core/api/facade.ts
|
|
170
|
-
var
|
|
191
|
+
var nt = class {
|
|
171
192
|
client;
|
|
172
193
|
constructor(e = {}) {
|
|
173
194
|
this.client = new Je(e);
|
|
@@ -235,7 +256,7 @@ var $e = class {
|
|
|
235
256
|
};
|
|
236
257
|
}
|
|
237
258
|
async listSessionMessages(e, t) {
|
|
238
|
-
return
|
|
259
|
+
return tt(await et(t, (n, r) => this.client.postJsonAction("ListSessionMessages", {
|
|
239
260
|
AgentId: t?.agentId,
|
|
240
261
|
SessionId: e,
|
|
241
262
|
HistoryView: t?.historyView,
|
|
@@ -248,11 +269,11 @@ var $e = class {
|
|
|
248
269
|
CursorSource: t?.cursorSource,
|
|
249
270
|
HistoryEpoch: t?.historyEpoch,
|
|
250
271
|
SnapshotSeqId: t?.snapshotSeqId,
|
|
251
|
-
Limit:
|
|
272
|
+
Limit: n,
|
|
252
273
|
IncludeReasoning: t?.includeReasoning,
|
|
253
274
|
IncludeToolEvents: t?.includeToolEvents,
|
|
254
275
|
IncludeAttachments: t?.includeAttachments
|
|
255
|
-
},
|
|
276
|
+
}, { signal: r })));
|
|
256
277
|
}
|
|
257
278
|
async listSessionCheckpoints(e, t) {
|
|
258
279
|
return this.client.postJsonAction("ListSessionCheckpoints", {
|
|
@@ -368,34 +389,34 @@ var $e = class {
|
|
|
368
389
|
async uploadFile(e, t) {
|
|
369
390
|
return this.client.postFormAction("UploadFile", e, t);
|
|
370
391
|
}
|
|
371
|
-
},
|
|
372
|
-
function
|
|
392
|
+
}, rt = "ksadk:webui:selected-session:";
|
|
393
|
+
function it(e) {
|
|
373
394
|
return String(e || "").trim() || "default-agent";
|
|
374
395
|
}
|
|
375
|
-
function
|
|
396
|
+
function at(e) {
|
|
376
397
|
if (e && typeof e.getItem == "function") return e;
|
|
377
398
|
try {
|
|
378
399
|
if (typeof window < "u" && window.localStorage) return window.localStorage;
|
|
379
400
|
} catch {}
|
|
380
401
|
return null;
|
|
381
402
|
}
|
|
382
|
-
function
|
|
383
|
-
return o.key(`${
|
|
403
|
+
function ot(e) {
|
|
404
|
+
return o.key(`${rt}${it(e)}`);
|
|
384
405
|
}
|
|
385
|
-
function
|
|
386
|
-
let n =
|
|
406
|
+
function st(e, t) {
|
|
407
|
+
let n = at(t);
|
|
387
408
|
if (!n) return null;
|
|
388
409
|
try {
|
|
389
|
-
return String(n.getItem(
|
|
410
|
+
return String(n.getItem(ot(e)) || "").trim() || null;
|
|
390
411
|
} catch {
|
|
391
412
|
return null;
|
|
392
413
|
}
|
|
393
414
|
}
|
|
394
|
-
function
|
|
415
|
+
function ct(e, t, n) {
|
|
395
416
|
if (!o.writable) return;
|
|
396
|
-
let r =
|
|
417
|
+
let r = at(n);
|
|
397
418
|
if (!r) return;
|
|
398
|
-
let i =
|
|
419
|
+
let i = ot(e), a = String(t || "").trim();
|
|
399
420
|
try {
|
|
400
421
|
if (a) {
|
|
401
422
|
r.setItem(i, a);
|
|
@@ -404,7 +425,7 @@ function at(e, t, n) {
|
|
|
404
425
|
r.removeItem(i);
|
|
405
426
|
} catch {}
|
|
406
427
|
}
|
|
407
|
-
function
|
|
428
|
+
function lt(e, t) {
|
|
408
429
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
409
430
|
let n = String(t || "").trim();
|
|
410
431
|
if (n && e.some((e) => String(e?.SessionId || "").trim() === n)) return n;
|
|
@@ -414,7 +435,7 @@ function ot(e, t) {
|
|
|
414
435
|
}
|
|
415
436
|
return null;
|
|
416
437
|
}
|
|
417
|
-
function
|
|
438
|
+
function ut(e, t, n) {
|
|
418
439
|
let r = Array.isArray(e) ? e : [], i = Array.isArray(t) ? t : [], a = n instanceof Set ? n : new Set(Array.isArray(n) ? n : []);
|
|
419
440
|
if (a.size === 0) return r;
|
|
420
441
|
let o = new Set(r.map((e) => String(e?.SessionId || "").trim()).filter(Boolean)), s = i.filter((e) => {
|
|
@@ -425,16 +446,16 @@ function st(e, t, n) {
|
|
|
425
446
|
}
|
|
426
447
|
//#endregion
|
|
427
448
|
//#region src/hooks/useBootstrap.ts
|
|
428
|
-
function
|
|
429
|
-
return e instanceof
|
|
449
|
+
function dt(e) {
|
|
450
|
+
return e instanceof X && (e.code === 401 || e.code === 403) ? "auth-required" : "error";
|
|
430
451
|
}
|
|
431
|
-
function
|
|
452
|
+
function ft(e) {
|
|
432
453
|
if (!Array.isArray(e)) return ["responses", "chat_completions"];
|
|
433
454
|
let t = e.filter((e) => e === "responses" || e === "chat_completions");
|
|
434
455
|
return t.length > 0 ? t : ["responses", "chat_completions"];
|
|
435
456
|
}
|
|
436
|
-
var
|
|
437
|
-
async function
|
|
457
|
+
var pt = new nt();
|
|
458
|
+
async function mt(e, t = pt) {
|
|
438
459
|
try {
|
|
439
460
|
let n = await t.listAgentModels(e), r = n?.Models;
|
|
440
461
|
Array.isArray(r) && h.getState().upsertModels(r);
|
|
@@ -446,8 +467,8 @@ async function dt(e, t = ut) {
|
|
|
446
467
|
h.getState().setModelCatalogLoaded(!0);
|
|
447
468
|
}
|
|
448
469
|
}
|
|
449
|
-
function
|
|
450
|
-
|
|
470
|
+
function ht(t, n, i = pt, a) {
|
|
471
|
+
J(() => {
|
|
451
472
|
let o = new AbortController();
|
|
452
473
|
return (async () => {
|
|
453
474
|
c.getState().setStatus("loading");
|
|
@@ -462,15 +483,15 @@ function ft(t, n, i = ut, a) {
|
|
|
462
483
|
let f = String(u?.Framework || "").trim().toLowerCase();
|
|
463
484
|
c.getState().setAgentFramework(f);
|
|
464
485
|
let p = e(s);
|
|
465
|
-
c.getState().setCapabilities(p), c.getState().setApiFormats(
|
|
486
|
+
c.getState().setCapabilities(p), c.getState().setApiFormats(ft(p.HostedChat.ApiFormats)), c.getState().setAccessMode(String(l?.AccessMode || "Owner"));
|
|
466
487
|
let m = p.WorkspaceFiles && l?.WorkspaceFiles ? l.WorkspaceFiles : null;
|
|
467
|
-
c.getState().setWorkspaceFiles(m), m || g.getState().setWorkspacePanelOpen(!1), r(p) && t.fetchSessions(d,
|
|
488
|
+
c.getState().setWorkspaceFiles(m), m || g.getState().setWorkspacePanelOpen(!1), r(p) && t.fetchSessions(d, st(d));
|
|
468
489
|
let _ = l?.Model;
|
|
469
|
-
_?.id && (h.getState().setSelectedModel(_.id), h.getState().upsertModels([_]), h.getState().setModelSource(_.source || "")),
|
|
490
|
+
_?.id && (h.getState().setSelectedModel(_.id), h.getState().upsertModels([_]), h.getState().setModelSource(_.source || "")), mt(d, i), c.getState().setStatus("ready");
|
|
470
491
|
} catch (e) {
|
|
471
492
|
if (o.signal.aborted) return;
|
|
472
493
|
console.error("Failed to fetch bootstrap:", e);
|
|
473
|
-
let t =
|
|
494
|
+
let t = dt(e);
|
|
474
495
|
c.getState().setStatus(t, t === "auth-required" ? "当前访问链接未授权或已过期。" : "无法加载 Agent 配置,请稍后重试。");
|
|
475
496
|
}
|
|
476
497
|
})(), () => o.abort();
|
|
@@ -482,14 +503,14 @@ function ft(t, n, i = ut, a) {
|
|
|
482
503
|
}
|
|
483
504
|
//#endregion
|
|
484
505
|
//#region src/hooks/useFeedback.ts
|
|
485
|
-
function
|
|
506
|
+
function gt(e) {
|
|
486
507
|
let { agentId: t, currentSessionId: n, isStreaming: r, api: i, submitDraft: a } = e;
|
|
487
508
|
return {
|
|
488
|
-
submitResponseFeedback:
|
|
509
|
+
submitResponseFeedback: q(async (e) => {
|
|
489
510
|
if (!n) return;
|
|
490
511
|
let r = null;
|
|
491
|
-
|
|
492
|
-
let n =
|
|
512
|
+
K.getState().patchMessages((t) => {
|
|
513
|
+
let n = se(t, {
|
|
493
514
|
messageId: e.message.id,
|
|
494
515
|
rating: e.rating,
|
|
495
516
|
comment: e.comment || ""
|
|
@@ -497,19 +518,19 @@ function pt(e) {
|
|
|
497
518
|
return r = n.previousFeedback, n.nextMessages;
|
|
498
519
|
});
|
|
499
520
|
try {
|
|
500
|
-
let r =
|
|
521
|
+
let r = H((await i.upsertResponseFeedback(V({
|
|
501
522
|
agentId: t,
|
|
502
523
|
sessionId: n,
|
|
503
524
|
message: e.message,
|
|
504
525
|
rating: e.rating,
|
|
505
526
|
comment: e.comment || ""
|
|
506
527
|
})))?.Feedback);
|
|
507
|
-
r &&
|
|
528
|
+
r && K.getState().patchMessages((t) => ce(t, {
|
|
508
529
|
messageId: e.message.id,
|
|
509
530
|
feedback: r
|
|
510
531
|
}));
|
|
511
532
|
} catch (t) {
|
|
512
|
-
console.error("Failed to submit response feedback:", t),
|
|
533
|
+
console.error("Failed to submit response feedback:", t), K.getState().patchMessages((t) => ae(t, {
|
|
513
534
|
messageId: e.message.id,
|
|
514
535
|
previousFeedback: r
|
|
515
536
|
}));
|
|
@@ -519,18 +540,18 @@ function pt(e) {
|
|
|
519
540
|
n,
|
|
520
541
|
i
|
|
521
542
|
]),
|
|
522
|
-
deleteResponseFeedback:
|
|
543
|
+
deleteResponseFeedback: q(async (e) => {
|
|
523
544
|
if (!n) return;
|
|
524
545
|
let r = e.feedback ? { ...e.feedback } : null;
|
|
525
|
-
|
|
546
|
+
K.getState().patchMessages((t) => G(t, { messageId: e.id }));
|
|
526
547
|
try {
|
|
527
|
-
await i.deleteResponseFeedback(
|
|
548
|
+
await i.deleteResponseFeedback(ie({
|
|
528
549
|
agentId: t,
|
|
529
550
|
sessionId: n,
|
|
530
551
|
message: e
|
|
531
552
|
}));
|
|
532
553
|
} catch (t) {
|
|
533
|
-
console.error("Failed to delete response feedback:", t),
|
|
554
|
+
console.error("Failed to delete response feedback:", t), K.getState().patchMessages((t) => ae(t, {
|
|
534
555
|
messageId: e.id,
|
|
535
556
|
previousFeedback: r
|
|
536
557
|
}));
|
|
@@ -540,11 +561,11 @@ function pt(e) {
|
|
|
540
561
|
n,
|
|
541
562
|
i
|
|
542
563
|
]),
|
|
543
|
-
respondToApproval:
|
|
564
|
+
respondToApproval: q(async (e) => !e.approvalRequestId || r || !await a("", [], [{
|
|
544
565
|
type: "mcp_approval_response",
|
|
545
566
|
approval_request_id: e.approvalRequestId,
|
|
546
567
|
approve: e.approve
|
|
547
|
-
}], e.previousResponseId) ? !1 : (s.getState().currentSessionId === n &&
|
|
568
|
+
}], e.previousResponseId) ? !1 : (s.getState().currentSessionId === n && K.getState().patchMessages((t) => t.map((t) => {
|
|
548
569
|
let n = e.approve ? "approved" : "rejected", r = (t) => e.approve && t === "paused" ? "running" : e.approve ? t : "completed";
|
|
549
570
|
return {
|
|
550
571
|
...t,
|
|
@@ -571,7 +592,7 @@ function pt(e) {
|
|
|
571
592
|
}
|
|
572
593
|
//#endregion
|
|
573
594
|
//#region src/core/mcp-authorization/recovery.ts
|
|
574
|
-
function
|
|
595
|
+
function _t(e, t, n, r) {
|
|
575
596
|
let i = /* @__PURE__ */ new Map(), a = !1;
|
|
576
597
|
function o(e) {
|
|
577
598
|
clearTimeout(i.get(e)), i.delete(e);
|
|
@@ -588,7 +609,7 @@ function mt(e, t, n, r) {
|
|
|
588
609
|
try {
|
|
589
610
|
let o = await n("GetMcpAuthorizationWait", l, void 0, t);
|
|
590
611
|
if (a || !i.has(l)) return;
|
|
591
|
-
let s =
|
|
612
|
+
let s = L(o, t, c), u = e.get(t, l);
|
|
592
613
|
s?.interactionId === l && u && s.revision > u.revision && (e.upsert(s), (s.status === "resolved" || s.status === "cancelled" || s.status === "expired") && r(t));
|
|
593
614
|
} catch {}
|
|
594
615
|
!a && i.has(l) && i.set(l, setTimeout(u, 3e3));
|
|
@@ -606,7 +627,7 @@ function mt(e, t, n, r) {
|
|
|
606
627
|
}
|
|
607
628
|
//#endregion
|
|
608
629
|
//#region src/hooks/useInteractions.ts
|
|
609
|
-
function
|
|
630
|
+
function vt(e) {
|
|
610
631
|
let t = _(), [n] = He(() => new i({
|
|
611
632
|
agentId: e.agentId,
|
|
612
633
|
store: w,
|
|
@@ -618,11 +639,11 @@ function ht(e) {
|
|
|
618
639
|
legacyResponsesApproval: e.legacyResponsesApproval,
|
|
619
640
|
legacyAguiResume: e.legacyAguiResume
|
|
620
641
|
}));
|
|
621
|
-
|
|
642
|
+
J(() => {
|
|
622
643
|
n.setInteractionV1Enabled(e.interactionV1Enabled);
|
|
623
644
|
}, [n, e.interactionV1Enabled]);
|
|
624
645
|
let [r, a] = He(0);
|
|
625
|
-
|
|
646
|
+
J(() => w.subscribe(() => a((e) => e + 1)), []);
|
|
626
647
|
let o = c((e) => e.accessMode === "Share"), s = Ve(() => {
|
|
627
648
|
if (!e.currentSessionId) return [];
|
|
628
649
|
let t = w.listAll(e.currentSessionId);
|
|
@@ -632,16 +653,16 @@ function ht(e) {
|
|
|
632
653
|
e.currentSessionId,
|
|
633
654
|
o
|
|
634
655
|
]), l = Ve(() => s.filter(U), [s]), { currentSessionId: u, interactionV1Enabled: d, onAcceptedInteraction: f } = e, p = o ? void 0 : e.api.mcpAuthorization, m = e.reloadHistory;
|
|
635
|
-
|
|
636
|
-
if (u && p) return
|
|
656
|
+
J(() => {
|
|
657
|
+
if (u && p) return _t(w, u, p, m);
|
|
637
658
|
}, [
|
|
638
659
|
e.agentId,
|
|
639
660
|
u,
|
|
640
661
|
p,
|
|
641
662
|
m
|
|
642
663
|
]);
|
|
643
|
-
let h =
|
|
644
|
-
return
|
|
664
|
+
let h = Y(/* @__PURE__ */ new Set());
|
|
665
|
+
return J(() => {
|
|
645
666
|
for (let e of s) {
|
|
646
667
|
let t = e.extensions.mcpAuthorization;
|
|
647
668
|
if (!t || ![
|
|
@@ -658,7 +679,7 @@ function ht(e) {
|
|
|
658
679
|
client: n,
|
|
659
680
|
pending: l,
|
|
660
681
|
records: s,
|
|
661
|
-
respond:
|
|
682
|
+
respond: q((e) => {
|
|
662
683
|
let t = u ? w.get(u, e.interactionId) : null;
|
|
663
684
|
return u ? n.respond({
|
|
664
685
|
...e,
|
|
@@ -673,43 +694,43 @@ function ht(e) {
|
|
|
673
694
|
localCatalog: t
|
|
674
695
|
};
|
|
675
696
|
}
|
|
676
|
-
var
|
|
677
|
-
function
|
|
697
|
+
var yt = .28;
|
|
698
|
+
function bt(e, t = 768) {
|
|
678
699
|
return Number(e) <= t;
|
|
679
700
|
}
|
|
680
|
-
function
|
|
701
|
+
function xt({ isMobile: e, desktopSidebarOpen: t, mobileSidebarOpen: n }) {
|
|
681
702
|
return {
|
|
682
703
|
desktopSidebarVisible: !e && !!t,
|
|
683
704
|
mobileDrawerVisible: !!(e && n)
|
|
684
705
|
};
|
|
685
706
|
}
|
|
686
|
-
function
|
|
707
|
+
function St({ isMobile: e, viewportHeight: t, desktopMaxHeight: n = 160 }) {
|
|
687
708
|
if (!e) return n;
|
|
688
709
|
let r = Number(t);
|
|
689
710
|
if (!Number.isFinite(r) || r <= 0) return n;
|
|
690
|
-
let i = Math.floor(r *
|
|
711
|
+
let i = Math.floor(r * yt);
|
|
691
712
|
return Math.max(120, Math.min(n, i));
|
|
692
713
|
}
|
|
693
714
|
//#endregion
|
|
694
715
|
//#region src/hooks/useResponsiveViewport.ts
|
|
695
|
-
function
|
|
716
|
+
function Ct() {
|
|
696
717
|
return typeof window > "u" ? 900 : Math.round(window.visualViewport?.height || window.innerHeight || 900);
|
|
697
718
|
}
|
|
698
|
-
function
|
|
719
|
+
function wt() {
|
|
699
720
|
return typeof window > "u" ? {
|
|
700
721
|
isMobile: !1,
|
|
701
722
|
viewportHeight: 900
|
|
702
723
|
} : {
|
|
703
|
-
isMobile:
|
|
704
|
-
viewportHeight:
|
|
724
|
+
isMobile: bt(window.innerWidth, 768),
|
|
725
|
+
viewportHeight: Ct()
|
|
705
726
|
};
|
|
706
727
|
}
|
|
707
|
-
function
|
|
708
|
-
let [e, t] = He(() =>
|
|
709
|
-
return
|
|
728
|
+
function Tt() {
|
|
729
|
+
let [e, t] = He(() => wt());
|
|
730
|
+
return J(() => {
|
|
710
731
|
if (typeof window > "u") return;
|
|
711
732
|
let e = window.matchMedia("(max-width: 768px)"), n = () => {
|
|
712
|
-
t(
|
|
733
|
+
t(wt());
|
|
713
734
|
};
|
|
714
735
|
n();
|
|
715
736
|
let r = typeof e.addEventListener == "function" ? (e.addEventListener("change", n), () => e.removeEventListener("change", n)) : (e.addListener(n), () => e.removeListener(n));
|
|
@@ -720,10 +741,10 @@ function St() {
|
|
|
720
741
|
}
|
|
721
742
|
//#endregion
|
|
722
743
|
//#region src/core/stream/responses-protocol.ts
|
|
723
|
-
var
|
|
744
|
+
var Et = class {
|
|
724
745
|
id = "responses";
|
|
725
746
|
createState() {
|
|
726
|
-
return
|
|
747
|
+
return re();
|
|
727
748
|
}
|
|
728
749
|
parseItemOperations(e, t, n) {
|
|
729
750
|
return A(e.eventName, e.data, t, n);
|
|
@@ -767,23 +788,23 @@ var Ct = class {
|
|
|
767
788
|
};
|
|
768
789
|
//#endregion
|
|
769
790
|
//#region src/utils/stream-parsing.ts
|
|
770
|
-
function
|
|
791
|
+
function Dt(e) {
|
|
771
792
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e && typeof e == "object" && "text" in e && typeof e.text == "string" ? e.text : "").join("") : "";
|
|
772
793
|
}
|
|
773
|
-
function
|
|
794
|
+
function Ot(e) {
|
|
774
795
|
return e && typeof e == "object" ? e : {};
|
|
775
796
|
}
|
|
776
|
-
function
|
|
777
|
-
let t =
|
|
797
|
+
function kt(e) {
|
|
798
|
+
let t = Ot(e).choices, n = Ot(Array.isArray(t) ? t[0] : null), r = Ot(n.delta), i = Ot(n.message);
|
|
778
799
|
return {
|
|
779
|
-
content:
|
|
780
|
-
reasoning:
|
|
781
|
-
finalText:
|
|
800
|
+
content: Dt(r.content),
|
|
801
|
+
reasoning: Dt(r.reasoning_content),
|
|
802
|
+
finalText: Dt(i.content)
|
|
782
803
|
};
|
|
783
804
|
}
|
|
784
805
|
//#endregion
|
|
785
806
|
//#region src/core/stream/chat-completions-protocol.ts
|
|
786
|
-
var
|
|
807
|
+
var At = class {
|
|
787
808
|
id = "chat_completions";
|
|
788
809
|
createState() {
|
|
789
810
|
return {};
|
|
@@ -791,7 +812,7 @@ var Dt = class {
|
|
|
791
812
|
parse(e) {
|
|
792
813
|
let t = e.data;
|
|
793
814
|
if (typeof t != "object" || !t) return [];
|
|
794
|
-
let n =
|
|
815
|
+
let n = kt(t), r = [];
|
|
795
816
|
return n.reasoning && r.push({
|
|
796
817
|
type: "reasoning_delta",
|
|
797
818
|
text: n.reasoning
|
|
@@ -803,14 +824,14 @@ var Dt = class {
|
|
|
803
824
|
text: n.finalText
|
|
804
825
|
}), r;
|
|
805
826
|
}
|
|
806
|
-
},
|
|
807
|
-
|
|
808
|
-
function
|
|
809
|
-
return
|
|
827
|
+
}, jt = /* @__PURE__ */ new Map();
|
|
828
|
+
jt.set("responses", new Et()), jt.set("chat_completions", new At());
|
|
829
|
+
function Mt(e) {
|
|
830
|
+
return jt.get(e) || jt.get("responses");
|
|
810
831
|
}
|
|
811
832
|
//#endregion
|
|
812
833
|
//#region src/utils/stream-control.js
|
|
813
|
-
function
|
|
834
|
+
function Nt(e = []) {
|
|
814
835
|
return e.some((e) => {
|
|
815
836
|
if (e?.type !== "terminal") return !1;
|
|
816
837
|
let t = String(e.status || "").toLowerCase();
|
|
@@ -819,7 +840,7 @@ function At(e = []) {
|
|
|
819
840
|
}
|
|
820
841
|
//#endregion
|
|
821
842
|
//#region src/core/transport/sse-parser.ts
|
|
822
|
-
function
|
|
843
|
+
function Pt(e) {
|
|
823
844
|
let t = [], n = e.trim();
|
|
824
845
|
if (!n) return t;
|
|
825
846
|
let r = n.split("\n");
|
|
@@ -849,7 +870,7 @@ function jt(e) {
|
|
|
849
870
|
}
|
|
850
871
|
return t;
|
|
851
872
|
}
|
|
852
|
-
function
|
|
873
|
+
function Ft(e) {
|
|
853
874
|
let t = e.split("\n\n");
|
|
854
875
|
return {
|
|
855
876
|
chunks: t,
|
|
@@ -858,49 +879,49 @@ function Mt(e) {
|
|
|
858
879
|
}
|
|
859
880
|
//#endregion
|
|
860
881
|
//#region src/utils/error.ts
|
|
861
|
-
function
|
|
882
|
+
function It(e) {
|
|
862
883
|
return e instanceof Error ? e.message : String(e);
|
|
863
884
|
}
|
|
864
885
|
//#endregion
|
|
865
886
|
//#region src/utils/model-options.js
|
|
866
|
-
var
|
|
887
|
+
var Lt = new Set([
|
|
867
888
|
"auto",
|
|
868
889
|
"enabled",
|
|
869
890
|
"disabled"
|
|
870
891
|
]);
|
|
871
|
-
function
|
|
892
|
+
function Rt(e) {
|
|
872
893
|
let t = String(e || "").trim().toLowerCase();
|
|
873
|
-
return
|
|
894
|
+
return Lt.has(t) ? t : "auto";
|
|
874
895
|
}
|
|
875
|
-
function
|
|
876
|
-
let t =
|
|
896
|
+
function zt(e) {
|
|
897
|
+
let t = Rt(e);
|
|
877
898
|
if (t === "disabled") return { thinking: { type: "disabled" } };
|
|
878
899
|
if (t === "enabled") return { thinking: { type: "enabled" } };
|
|
879
900
|
}
|
|
880
|
-
var
|
|
881
|
-
function
|
|
901
|
+
var Bt = 1280;
|
|
902
|
+
function Vt(e) {
|
|
882
903
|
let { apiFormats: t } = e;
|
|
883
904
|
return t.includes("responses") ? "responses" : t.includes("chat_completions") ? "chat_completions" : "responses";
|
|
884
905
|
}
|
|
885
|
-
function
|
|
886
|
-
let r = Math.min(
|
|
906
|
+
function Ht(e, t, n) {
|
|
907
|
+
let r = Math.min(Bt, Math.max(420, t - n - 360));
|
|
887
908
|
return Math.min(Math.max(e, 420), r);
|
|
888
909
|
}
|
|
889
910
|
//#endregion
|
|
890
911
|
//#region src/core/run/agui.ts
|
|
891
|
-
function
|
|
912
|
+
function Ut(e) {
|
|
892
913
|
return String(e.type || "").toUpperCase();
|
|
893
914
|
}
|
|
894
|
-
function
|
|
915
|
+
function Wt(e, t) {
|
|
895
916
|
return String(e.messageId || t);
|
|
896
917
|
}
|
|
897
|
-
function
|
|
918
|
+
function Gt(e, t) {
|
|
898
919
|
return String(e.runId || t);
|
|
899
920
|
}
|
|
900
|
-
function
|
|
921
|
+
function Kt(e) {
|
|
901
922
|
return e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
902
923
|
}
|
|
903
|
-
function
|
|
924
|
+
function qt(e) {
|
|
904
925
|
if (Array.isArray(e)) return E(e.filter((e) => !!(e && typeof e == "object")));
|
|
905
926
|
if (e && typeof e == "object") {
|
|
906
927
|
let t = e.a2ui_operations;
|
|
@@ -908,10 +929,10 @@ function Wt(e) {
|
|
|
908
929
|
}
|
|
909
930
|
return [];
|
|
910
931
|
}
|
|
911
|
-
function
|
|
932
|
+
function Jt(e) {
|
|
912
933
|
return e == null || e === "" ? "" : typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
913
934
|
}
|
|
914
|
-
var
|
|
935
|
+
var Yt = class {
|
|
915
936
|
agent;
|
|
916
937
|
onEvent;
|
|
917
938
|
tools = /* @__PURE__ */ new Map();
|
|
@@ -920,6 +941,7 @@ var Kt = class {
|
|
|
920
941
|
activeRunId = "";
|
|
921
942
|
logicalRunId = "";
|
|
922
943
|
executionEpoch = 0;
|
|
944
|
+
onAdmission;
|
|
923
945
|
threadId;
|
|
924
946
|
forwardedProps;
|
|
925
947
|
catalogRegistry;
|
|
@@ -928,10 +950,13 @@ var Kt = class {
|
|
|
928
950
|
url: e.url,
|
|
929
951
|
agentId: e.agentId,
|
|
930
952
|
threadId: e.threadId,
|
|
931
|
-
fetch:
|
|
932
|
-
|
|
953
|
+
fetch: async (t, n) => {
|
|
954
|
+
let r = this.onAdmission, i = await (e.fetch ?? globalThis.fetch)(t, n), a = i.headers.get("X-AgentEngine-AGUI-Command-Id");
|
|
955
|
+
return i.ok && r && r === this.onAdmission && a && r(a), i;
|
|
956
|
+
}
|
|
957
|
+
}), this.onEvent = e.onEvent, this.threadId = e.threadId, this.forwardedProps = e.forwardedProps || {}, this.catalogRegistry = e.a2uiCatalogRegistry || te;
|
|
933
958
|
}
|
|
934
|
-
configure(e, t =
|
|
959
|
+
configure(e, t = te) {
|
|
935
960
|
this.forwardedProps = e, this.catalogRegistry = t;
|
|
936
961
|
}
|
|
937
962
|
reconcileInteractions(e) {
|
|
@@ -942,15 +967,20 @@ var Kt = class {
|
|
|
942
967
|
r.length ? this.pendingByRun.set(e, r) : this.pendingByRun.delete(e);
|
|
943
968
|
}
|
|
944
969
|
}
|
|
945
|
-
async run(e, t, n) {
|
|
946
|
-
|
|
970
|
+
async run(e, t, n, r) {
|
|
971
|
+
this.activeRunId = t, this.logicalRunId = t, this.agent.addMessage({
|
|
947
972
|
id: `${t}:user`,
|
|
948
973
|
role: "user",
|
|
949
974
|
content: e
|
|
950
|
-
}), this.
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
975
|
+
}), this.onAdmission = r;
|
|
976
|
+
try {
|
|
977
|
+
return await this.execute({
|
|
978
|
+
runId: t,
|
|
979
|
+
abortController: this.controllerFor(n)
|
|
980
|
+
});
|
|
981
|
+
} finally {
|
|
982
|
+
this.onAdmission === r && (this.onAdmission = void 0);
|
|
983
|
+
}
|
|
954
984
|
}
|
|
955
985
|
async resume(e, t) {
|
|
956
986
|
if (t.status === "resolved" && t.payload === null) throw Error("AG-UI 1.0 根 null 答案须通过 Interaction/v1 提交。");
|
|
@@ -980,22 +1010,22 @@ var Kt = class {
|
|
|
980
1010
|
let t = ++this.executionEpoch, n = this.logicalRunId || e.runId, r = !0, i = /* @__PURE__ */ new Set(), a = (n) => {
|
|
981
1011
|
if (!r || t !== this.executionEpoch || this.activeRunId !== e.runId || e.abortController?.signal.aborted) return null;
|
|
982
1012
|
let a = n;
|
|
983
|
-
if (
|
|
984
|
-
let o =
|
|
1013
|
+
if (Ut(n) !== "CUSTOM" || a.name !== "ksadk.text_message_snapshot") return null;
|
|
1014
|
+
let o = Kt(a.value);
|
|
985
1015
|
return o.version === 1 && o.threadId === this.threadId && o.runId === e.runId && typeof o.messageId == "string" && i.has(o.messageId) && typeof o.content == "string" ? {
|
|
986
1016
|
messageId: o.messageId,
|
|
987
1017
|
content: o.content
|
|
988
1018
|
} : null;
|
|
989
1019
|
}, o = "completed", s = !1, c = {
|
|
990
1020
|
onEvent: ({ event: t, messages: r }) => {
|
|
991
|
-
|
|
1021
|
+
Ut(t) === "TEXT_MESSAGE_START" && i.add(Wt(t, `${e.runId}:assistant`));
|
|
992
1022
|
let c = a(t);
|
|
993
1023
|
if (c && r.some((e) => e.id === c.messageId && e.role === "assistant") && this.onEvent({
|
|
994
1024
|
type: "text_replace",
|
|
995
1025
|
messageId: c.messageId,
|
|
996
1026
|
text: c.content,
|
|
997
1027
|
sessionId: this.threadId
|
|
998
|
-
}),
|
|
1028
|
+
}), Ut(t) === "RUN_FINISHED" && (s = !0), Ut(t) === "RUN_ERROR" && t.code === "INPUT_RESPONSE_INVALID") for (let t of e.resume || []) this.onEvent({
|
|
999
1029
|
type: "interaction_submit_rejected",
|
|
1000
1030
|
interactionId: t.interruptId,
|
|
1001
1031
|
message: "答案未通过 Runtime 校验,请修改后重新提交。"
|
|
@@ -1033,13 +1063,13 @@ var Kt = class {
|
|
|
1033
1063
|
}
|
|
1034
1064
|
let u = this.pendingByRun.get(e.runId) || this.agent.pendingInterrupts.slice();
|
|
1035
1065
|
return u.length > 0 && (this.pendingByRun.set(e.runId, u), o !== "failed" && (o = "interrupted")), {
|
|
1036
|
-
status: s ? o : "
|
|
1066
|
+
status: s || o === "failed" ? o : "incomplete",
|
|
1037
1067
|
result: l,
|
|
1038
1068
|
pendingInterruptIds: u.map((e) => e.id)
|
|
1039
1069
|
};
|
|
1040
1070
|
}
|
|
1041
1071
|
project(e, t, n = !1, r = t) {
|
|
1042
|
-
let i =
|
|
1072
|
+
let i = Ut(e), a = Gt(e, t), o = Wt(e, `${a}:assistant`), s = e, c = [];
|
|
1043
1073
|
if (i === "RUN_STARTED") c.push({
|
|
1044
1074
|
type: "activity",
|
|
1045
1075
|
phase: "AG-UI 运行已创建",
|
|
@@ -1071,9 +1101,15 @@ var Kt = class {
|
|
|
1071
1101
|
this.tools.set(e, {
|
|
1072
1102
|
name: String(s.toolCallName || "tool"),
|
|
1073
1103
|
args: ""
|
|
1074
|
-
})
|
|
1104
|
+
});
|
|
1105
|
+
let t = this.runMessageIds.get(a) || `${a}:assistant`;
|
|
1106
|
+
c.push({
|
|
1107
|
+
type: "assistant_message_created",
|
|
1108
|
+
messageId: t,
|
|
1109
|
+
invocationId: r
|
|
1110
|
+
}, {
|
|
1075
1111
|
type: "tool_upsert",
|
|
1076
|
-
messageId:
|
|
1112
|
+
messageId: t,
|
|
1077
1113
|
name: String(s.toolCallName || "tool"),
|
|
1078
1114
|
args: "",
|
|
1079
1115
|
status: "running"
|
|
@@ -1102,7 +1138,7 @@ var Kt = class {
|
|
|
1102
1138
|
output: String(s.content || "")
|
|
1103
1139
|
});
|
|
1104
1140
|
} else if (i === "CUSTOM" && s.name === "ksadk.session_event") {
|
|
1105
|
-
let e =
|
|
1141
|
+
let e = Kt(s.value), t = e.family === "control" && ["mcp.authorization.requested", "mcp.authorization.updated"].includes(String(e.event_type));
|
|
1106
1142
|
(e.family === "interaction" || t) && e.family_version === 1 && e.session_id === this.threadId && typeof e.event_type == "string" && Number.isSafeInteger(e.seq) && c.push({
|
|
1107
1143
|
type: "stream_event",
|
|
1108
1144
|
sessionId: e.session_id,
|
|
@@ -1116,7 +1152,7 @@ var Kt = class {
|
|
|
1116
1152
|
}
|
|
1117
1153
|
});
|
|
1118
1154
|
} else if (i === "ACTIVITY_SNAPSHOT") {
|
|
1119
|
-
let e = s.content, t =
|
|
1155
|
+
let e = s.content, t = Kt(e), n = String(t.surfaceId || t.surface_id || s.messageId || "default");
|
|
1120
1156
|
c.push({
|
|
1121
1157
|
type: "agui_activity",
|
|
1122
1158
|
runId: r,
|
|
@@ -1124,17 +1160,17 @@ var Kt = class {
|
|
|
1124
1160
|
...typeof t.interactionId == "string" ? { interactionId: t.interactionId } : {},
|
|
1125
1161
|
messageId: this.runMessageIds.get(a) || o,
|
|
1126
1162
|
surfaceId: n,
|
|
1127
|
-
messages:
|
|
1163
|
+
messages: qt(t.content ?? e)
|
|
1128
1164
|
});
|
|
1129
1165
|
} else if (i === "RUN_FINISHED") {
|
|
1130
|
-
let e =
|
|
1166
|
+
let e = Kt(s.outcome);
|
|
1131
1167
|
if (String(e.type || "").toLowerCase() === "interrupt") {
|
|
1132
1168
|
let t = Array.isArray(e.interrupts) ? e.interrupts : [];
|
|
1133
1169
|
this.pendingByRun.set(a, t);
|
|
1134
1170
|
for (let e of t) {
|
|
1135
|
-
let t =
|
|
1171
|
+
let t = Kt(e.metadata);
|
|
1136
1172
|
if (t.interaction_v1 === !0) continue;
|
|
1137
|
-
let n = e.toolCallId ? this.tools.get(e.toolCallId) : void 0, r = String(t.tool_name || t.toolName || n?.name || e.reason || "人工确认"), i =
|
|
1173
|
+
let n = e.toolCallId ? this.tools.get(e.toolCallId) : void 0, r = String(t.tool_name || t.toolName || n?.name || e.reason || "人工确认"), i = Jt(t.arguments ?? t.tool_args ?? t.args ?? n?.args);
|
|
1138
1174
|
c.push({
|
|
1139
1175
|
type: "approval_requested",
|
|
1140
1176
|
messageId: this.runMessageIds.get(a) || `${a}:assistant`,
|
|
@@ -1169,7 +1205,7 @@ var Kt = class {
|
|
|
1169
1205
|
};
|
|
1170
1206
|
return { events: c };
|
|
1171
1207
|
}
|
|
1172
|
-
},
|
|
1208
|
+
}, Xt = new Set([
|
|
1173
1209
|
"completed",
|
|
1174
1210
|
"failed",
|
|
1175
1211
|
"error",
|
|
@@ -1178,7 +1214,7 @@ var Kt = class {
|
|
|
1178
1214
|
"aborted",
|
|
1179
1215
|
"interrupted",
|
|
1180
1216
|
"resume_failed"
|
|
1181
|
-
]),
|
|
1217
|
+
]), Zt = [
|
|
1182
1218
|
0,
|
|
1183
1219
|
500,
|
|
1184
1220
|
1e3,
|
|
@@ -1186,7 +1222,7 @@ var Kt = class {
|
|
|
1186
1222
|
4e3,
|
|
1187
1223
|
8e3
|
|
1188
1224
|
];
|
|
1189
|
-
function
|
|
1225
|
+
function Qt(e, t) {
|
|
1190
1226
|
return !e || t.aborted ? Promise.resolve() : new Promise((n) => {
|
|
1191
1227
|
let r = () => {
|
|
1192
1228
|
clearTimeout(i), t.removeEventListener("abort", r), n();
|
|
@@ -1194,7 +1230,7 @@ function Yt(e, t) {
|
|
|
1194
1230
|
t.addEventListener("abort", r, { once: !0 });
|
|
1195
1231
|
});
|
|
1196
1232
|
}
|
|
1197
|
-
function
|
|
1233
|
+
function $t(e) {
|
|
1198
1234
|
if (typeof window > "u" || window.navigator.onLine !== !1 || e.aborted) return Promise.resolve();
|
|
1199
1235
|
let t = window;
|
|
1200
1236
|
return new Promise((n) => {
|
|
@@ -1204,12 +1240,12 @@ function Xt(e) {
|
|
|
1204
1240
|
t.addEventListener("online", r, { once: !0 }), e.addEventListener("abort", r, { once: !0 });
|
|
1205
1241
|
});
|
|
1206
1242
|
}
|
|
1207
|
-
function
|
|
1243
|
+
function en(e) {
|
|
1208
1244
|
if (e.Content?.runtime_event?.parent_scope_id) return null;
|
|
1209
|
-
let t =
|
|
1210
|
-
return
|
|
1245
|
+
let t = ne(e);
|
|
1246
|
+
return Xt.has(t) ? t : null;
|
|
1211
1247
|
}
|
|
1212
|
-
function
|
|
1248
|
+
function tn(e, t) {
|
|
1213
1249
|
let n = String(t?.type || e || "").trim();
|
|
1214
1250
|
if (n === "response.created") return {
|
|
1215
1251
|
phase: "运行已创建",
|
|
@@ -1255,11 +1291,11 @@ function Qt(e, t) {
|
|
|
1255
1291
|
status: "failed"
|
|
1256
1292
|
} : null;
|
|
1257
1293
|
}
|
|
1258
|
-
function
|
|
1294
|
+
function nn() {
|
|
1259
1295
|
let e = globalThis.crypto;
|
|
1260
1296
|
return e && typeof e.randomUUID == "function" ? `run_${e.randomUUID()}` : `run_${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
1261
1297
|
}
|
|
1262
|
-
var
|
|
1298
|
+
var rn = {
|
|
1263
1299
|
idle: [
|
|
1264
1300
|
"creating-session",
|
|
1265
1301
|
"uploading-files",
|
|
@@ -1298,7 +1334,7 @@ var en = {
|
|
|
1298
1334
|
],
|
|
1299
1335
|
error: ["connecting", "idle"],
|
|
1300
1336
|
cancelled: ["idle"]
|
|
1301
|
-
},
|
|
1337
|
+
}, an = class {
|
|
1302
1338
|
_stage = "idle";
|
|
1303
1339
|
listeners = /* @__PURE__ */ new Set();
|
|
1304
1340
|
abortController = null;
|
|
@@ -1444,10 +1480,10 @@ var en = {
|
|
|
1444
1480
|
for (let e of this.listeners) e(t);
|
|
1445
1481
|
}
|
|
1446
1482
|
getAguiClient(e) {
|
|
1447
|
-
let t = this.config.hostedChatTransport;
|
|
1483
|
+
let t = this.config.aguiResumeTransport || this.config.hostedChatTransport;
|
|
1448
1484
|
if (t?.Protocol !== "ag-ui" || !t.Endpoint) return null;
|
|
1449
1485
|
if (!this.aguiClient || this.aguiThreadSessionId !== e) {
|
|
1450
|
-
let n = new
|
|
1486
|
+
let n = new Yt({
|
|
1451
1487
|
url: t.Endpoint,
|
|
1452
1488
|
agentId: this.config.agentId,
|
|
1453
1489
|
threadId: e,
|
|
@@ -1460,13 +1496,13 @@ var en = {
|
|
|
1460
1496
|
return this.aguiClient.reconcileInteractions(w.listAll(e)), this.aguiClient.configure({
|
|
1461
1497
|
model: this.config.selectedModel || void 0,
|
|
1462
1498
|
modelMetadata: this.config.selectedModelMetadata || void 0,
|
|
1463
|
-
modelOptions:
|
|
1499
|
+
modelOptions: zt(Rt(this.config.thinkingMode)),
|
|
1464
1500
|
toolApprovalMode: this.config.permissionMode || "risk"
|
|
1465
1501
|
}, this.config.a2uiCatalogRegistry), this.aguiClient;
|
|
1466
1502
|
}
|
|
1467
1503
|
setStage(e) {
|
|
1468
1504
|
if (this._stage === e) return;
|
|
1469
|
-
let t =
|
|
1505
|
+
let t = rn[this._stage];
|
|
1470
1506
|
t && !t.includes(e) && console.warn(`[RunEngine] Invalid transition: ${this._stage} → ${e}`), this._stage = e, e === "idle" && this.pendingConfig && (this.config = this.pendingConfig, this.pendingConfig = null), this.emit({
|
|
1471
1507
|
type: "stage_changed",
|
|
1472
1508
|
stage: e
|
|
@@ -1495,7 +1531,7 @@ var en = {
|
|
|
1495
1531
|
try {
|
|
1496
1532
|
if (r ||= await this.createSession(e), !r) throw Error("运行时未返回会话身份,请确认创建结果后重试。");
|
|
1497
1533
|
this.activeSessionId = r;
|
|
1498
|
-
let s =
|
|
1534
|
+
let s = nn();
|
|
1499
1535
|
this.publishInvocation(s), e.onInvocationCreated?.(s), this.recordCursor(0);
|
|
1500
1536
|
let c = n ? null : await this.getConversationBootstrap(r);
|
|
1501
1537
|
if (c && this.config.conversationClient) {
|
|
@@ -1553,10 +1589,10 @@ var en = {
|
|
|
1553
1589
|
status: "connecting",
|
|
1554
1590
|
countEvent: !1
|
|
1555
1591
|
});
|
|
1556
|
-
let u = n ? "responses" :
|
|
1592
|
+
let u = n ? "responses" : Vt({
|
|
1557
1593
|
agentFramework: this.config.agentFramework,
|
|
1558
1594
|
apiFormats: this.config.apiFormats
|
|
1559
|
-
}), d =
|
|
1595
|
+
}), d = Mt(u), f = d.createState(), p = this.config.hostedChatTransport, m = !n && !e.executionMode && e.attachments.length === 0 && p?.Protocol === "ag-ui" ? this.getAguiClient(r) : null;
|
|
1560
1596
|
if (m && p) {
|
|
1561
1597
|
this.setStage("streaming"), this.emit({
|
|
1562
1598
|
type: "activity",
|
|
@@ -1564,12 +1600,42 @@ var en = {
|
|
|
1564
1600
|
status: "waiting",
|
|
1565
1601
|
countEvent: !1
|
|
1566
1602
|
});
|
|
1567
|
-
let
|
|
1568
|
-
|
|
1603
|
+
let n, o = this.abortController?.signal, c;
|
|
1604
|
+
try {
|
|
1605
|
+
c = (await m.run(e.text, s, o, (t) => {
|
|
1606
|
+
n = t, e.onCommandAdmitted?.(t), i(!0);
|
|
1607
|
+
})).status;
|
|
1608
|
+
} catch (e) {
|
|
1609
|
+
if (!n || o?.aborted || !this.config.kernelCommandEventsEnabled) throw e;
|
|
1610
|
+
c = "incomplete";
|
|
1611
|
+
}
|
|
1612
|
+
if (this.operationEpoch !== t) return;
|
|
1613
|
+
if (c === "incomplete" && n && this.config.kernelCommandEventsEnabled) {
|
|
1614
|
+
this.setStage("recovering"), this.emit({
|
|
1615
|
+
type: "activity",
|
|
1616
|
+
phase: "网络异常,尝试重连",
|
|
1617
|
+
status: "waiting",
|
|
1618
|
+
countEvent: !1
|
|
1619
|
+
}), this.recordCursor(0);
|
|
1620
|
+
let i = await this.consumeKernelRunEvents(r, {
|
|
1621
|
+
commandId: n,
|
|
1622
|
+
status: "accepted"
|
|
1623
|
+
}, e.onInvocationCreated, "flat-v1", {
|
|
1624
|
+
invocationId: s,
|
|
1625
|
+
optimisticMessageId: e.optimisticMessageId
|
|
1626
|
+
});
|
|
1627
|
+
if (this.operationEpoch !== t) return;
|
|
1628
|
+
if (i.awaitingInput || i.outcomeUnknown) {
|
|
1629
|
+
a = i.awaitingInput ? "awaiting-input" : "unknown";
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
c = i.terminalStatus, c && c !== "cancelled" && this.invocationId && e.onRecovered?.(r, this.invocationId);
|
|
1633
|
+
}
|
|
1634
|
+
if (c === "interrupted" || c === "cancelled" || c === "canceled") {
|
|
1569
1635
|
a = "cancelled", this.setStage("completing"), this.emit({ type: "stream_ended" });
|
|
1570
1636
|
return;
|
|
1571
1637
|
}
|
|
1572
|
-
if (
|
|
1638
|
+
if (c !== "completed") {
|
|
1573
1639
|
a = "failed", this.setStage("error"), this.emit({
|
|
1574
1640
|
type: "activity",
|
|
1575
1641
|
phase: "AG-UI 运行失败",
|
|
@@ -1586,7 +1652,10 @@ var en = {
|
|
|
1586
1652
|
}), this.emit({ type: "stream_ended" });
|
|
1587
1653
|
return;
|
|
1588
1654
|
}
|
|
1589
|
-
let h = this.buildRequestBody(r, u, n, e, l, s), g = this.config.kernelSessionEventsEnabled && this.config.presentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1", _ = await this.api.runAgent(h, {
|
|
1655
|
+
let h = this.buildRequestBody(r, u, n, e, l, s), g = this.config.kernelSessionEventsEnabled && this.config.presentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1", _ = await this.api.runAgent(h, {
|
|
1656
|
+
signal: this.abortController?.signal,
|
|
1657
|
+
onCommandAdmitted: e.onCommandAdmitted
|
|
1658
|
+
});
|
|
1590
1659
|
if (this.operationEpoch !== t || this.abortController?.signal.aborted) {
|
|
1591
1660
|
i(!1), await _.cancel();
|
|
1592
1661
|
return;
|
|
@@ -1604,7 +1673,7 @@ var en = {
|
|
|
1604
1673
|
}
|
|
1605
1674
|
this.config.kernelSessionEventsEnabled && i(!y.receipt || y.receipt.status === "accepted" || y.receipt.status === "duplicate");
|
|
1606
1675
|
let b;
|
|
1607
|
-
if (
|
|
1676
|
+
if (y.receipt ? (y.receipt.commandId && e.onCommandAdmitted?.(y.receipt.commandId), b = await this.consumeKernelRunEvents(r, y.receipt, e.onInvocationCreated, g)) : b = await this.consumeStream(y.stream, d, f, v, s), this.operationEpoch !== t) return;
|
|
1608
1677
|
if (b.awaitingInput) {
|
|
1609
1678
|
a = "awaiting-input", this.setStage("completing"), this.emit({
|
|
1610
1679
|
type: "activity",
|
|
@@ -1650,7 +1719,7 @@ var en = {
|
|
|
1650
1719
|
}), this.emit({ type: "stream_ended" });
|
|
1651
1720
|
} catch (n) {
|
|
1652
1721
|
if (this.operationEpoch !== t) return;
|
|
1653
|
-
if (this.failCompaction(), this.abortController?.signal.aborted || n instanceof
|
|
1722
|
+
if (this.failCompaction(), this.abortController?.signal.aborted || n instanceof Z || n instanceof DOMException && n.name === "AbortError" || n instanceof pe && n.code === "conversation_aborted") a = "cancelled";
|
|
1654
1723
|
else {
|
|
1655
1724
|
let t = n instanceof TypeError;
|
|
1656
1725
|
if (a = t ? "unknown" : "failed", console.error("[RunEngine] start() error:", n), t) {
|
|
@@ -1675,7 +1744,7 @@ var en = {
|
|
|
1675
1744
|
type: "error",
|
|
1676
1745
|
error: n instanceof Error ? n : Error(String(n))
|
|
1677
1746
|
});
|
|
1678
|
-
} else n instanceof
|
|
1747
|
+
} else n instanceof X && n.code === 429 ? (this.setStage("error"), this.emit({
|
|
1679
1748
|
type: "rate_limited",
|
|
1680
1749
|
message: n.message || "请求过于频繁,请稍后重试",
|
|
1681
1750
|
sessionId: r
|
|
@@ -1724,22 +1793,22 @@ var en = {
|
|
|
1724
1793
|
});
|
|
1725
1794
|
let i = null;
|
|
1726
1795
|
try {
|
|
1727
|
-
let n = e.reconnect ?
|
|
1796
|
+
let n = e.reconnect ? Zt : [0], a = e.afterSeqId, o = !0;
|
|
1728
1797
|
for (let s of n) {
|
|
1729
|
-
if (await
|
|
1798
|
+
if (await Qt(s, t.signal), e.reconnect && await $t(t.signal), !r() || t.signal.aborted) return "cancelled";
|
|
1730
1799
|
try {
|
|
1731
1800
|
if (o) try {
|
|
1732
1801
|
i = await this.readRecoveredRunEvents(e, a, t.signal, r, (e) => {
|
|
1733
1802
|
a = Math.max(a, e);
|
|
1734
1803
|
});
|
|
1735
1804
|
} catch (t) {
|
|
1736
|
-
if (!e.reconnect || !(t instanceof
|
|
1805
|
+
if (!e.reconnect || !(t instanceof X) || t.code !== 404) throw t;
|
|
1737
1806
|
o = !1;
|
|
1738
1807
|
}
|
|
1739
1808
|
if (!i && e.reconnect && r() && !t.signal.aborted && (i = await this.readRecoveredRunStatus(e, t.signal)), i) break;
|
|
1740
1809
|
} catch (n) {
|
|
1741
|
-
if (!r() || t.signal.aborted || n instanceof
|
|
1742
|
-
let i = n instanceof TypeError || n instanceof
|
|
1810
|
+
if (!r() || t.signal.aborted || n instanceof Z) return "cancelled";
|
|
1811
|
+
let i = n instanceof TypeError || n instanceof X && (n.code >= 500 || n.code === 408 || n.code === 429);
|
|
1743
1812
|
if (!e.reconnect || !i) throw n;
|
|
1744
1813
|
this.emit({
|
|
1745
1814
|
type: "activity",
|
|
@@ -1808,9 +1877,9 @@ var en = {
|
|
|
1808
1877
|
let { value: u, done: d } = await s.read();
|
|
1809
1878
|
if (d || !r() || n.aborted) break;
|
|
1810
1879
|
l += c.decode(u, { stream: !0 });
|
|
1811
|
-
let { chunks: f, remainder: p } =
|
|
1880
|
+
let { chunks: f, remainder: p } = Ft(l);
|
|
1812
1881
|
l = p;
|
|
1813
|
-
for (let s of f) for (let { data: c } of
|
|
1882
|
+
for (let s of f) for (let { data: c } of Pt(s)) {
|
|
1814
1883
|
if (!r() || n.aborted) return null;
|
|
1815
1884
|
if (!c || typeof c != "object") continue;
|
|
1816
1885
|
let s = c;
|
|
@@ -1820,7 +1889,7 @@ var en = {
|
|
|
1820
1889
|
event: s,
|
|
1821
1890
|
sessionId: a
|
|
1822
1891
|
}), s.SeqId && (t = s.SeqId, i(t));
|
|
1823
|
-
let l =
|
|
1892
|
+
let l = en(s);
|
|
1824
1893
|
if (l) return l;
|
|
1825
1894
|
}
|
|
1826
1895
|
}
|
|
@@ -1831,7 +1900,7 @@ var en = {
|
|
|
1831
1900
|
}
|
|
1832
1901
|
async readRecoveredRunStatus({ sessionId: e, invocationId: t }, n) {
|
|
1833
1902
|
let r = await this.api.getSession(e, { signal: n }), i = String(r.ActiveRunStatus || "").trim().toLowerCase();
|
|
1834
|
-
if (r.SessionId === e && r.ActiveInvocationId === t &&
|
|
1903
|
+
if (r.SessionId === e && r.ActiveInvocationId === t && Xt.has(i)) return i;
|
|
1835
1904
|
if (n.aborted) return null;
|
|
1836
1905
|
let a = await this.api.listSessionEvents(e, {
|
|
1837
1906
|
eventTypes: [
|
|
@@ -1844,7 +1913,7 @@ var en = {
|
|
|
1844
1913
|
signal: n
|
|
1845
1914
|
});
|
|
1846
1915
|
for (let n of a.Events) if (n.SessionId === e && n.InvocationId === t) {
|
|
1847
|
-
let e =
|
|
1916
|
+
let e = en(n);
|
|
1848
1917
|
if (e) return e;
|
|
1849
1918
|
}
|
|
1850
1919
|
return null;
|
|
@@ -1853,7 +1922,7 @@ var en = {
|
|
|
1853
1922
|
if (this._stage !== "idle") return !1;
|
|
1854
1923
|
let t = ++this.operationEpoch;
|
|
1855
1924
|
this.abortController = new AbortController(), this.activeSessionId = e.sessionId;
|
|
1856
|
-
let n =
|
|
1925
|
+
let n = nn();
|
|
1857
1926
|
return this.publishInvocation(n), (async () => {
|
|
1858
1927
|
let r = "unknown";
|
|
1859
1928
|
try {
|
|
@@ -1887,7 +1956,7 @@ var en = {
|
|
|
1887
1956
|
checkpointId: e.checkpointId,
|
|
1888
1957
|
resumeAttemptId: e.resumeAttemptId,
|
|
1889
1958
|
invocationId: n
|
|
1890
|
-
}, { signal: this.abortController?.signal }), i =
|
|
1959
|
+
}, { signal: this.abortController?.signal }), i = Mt("responses"), a = i.createState();
|
|
1891
1960
|
this.setStage("streaming"), this.emit({
|
|
1892
1961
|
type: "activity",
|
|
1893
1962
|
source: "restore",
|
|
@@ -1951,7 +2020,7 @@ var en = {
|
|
|
1951
2020
|
if (!n) return !1;
|
|
1952
2021
|
let r = ++this.operationEpoch;
|
|
1953
2022
|
this.activeSessionId = t;
|
|
1954
|
-
let i =
|
|
2023
|
+
let i = nn();
|
|
1955
2024
|
return this.publishInvocation(i), this.setStage("connecting"), this.emit({
|
|
1956
2025
|
type: "activity",
|
|
1957
2026
|
phase: "提交人工确认",
|
|
@@ -2020,7 +2089,7 @@ var en = {
|
|
|
2020
2089
|
try {
|
|
2021
2090
|
return await t.getSurface(this.config.agentId, e, { signal: this.abortController?.signal });
|
|
2022
2091
|
} catch (e) {
|
|
2023
|
-
if (e instanceof
|
|
2092
|
+
if (e instanceof pe && e.code === "conversation_http_error" && e.status === 404) return null;
|
|
2024
2093
|
throw e;
|
|
2025
2094
|
}
|
|
2026
2095
|
}
|
|
@@ -2032,39 +2101,39 @@ var en = {
|
|
|
2032
2101
|
});
|
|
2033
2102
|
for (let t of r.attachments) {
|
|
2034
2103
|
let n = t.type.startsWith("image/") ? "attachment.image" : "attachment.file";
|
|
2035
|
-
if (!
|
|
2104
|
+
if (!fe(e.surface, n)) throw new pe("conversation_input_unsupported", "Conversation attachment is not declared by the active surface.", { capability: n });
|
|
2036
2105
|
}
|
|
2037
2106
|
r.attachments.length > 0 && i.push(...await this.uploadCanonicalAttachments(r.attachments));
|
|
2038
|
-
let o =
|
|
2107
|
+
let o = Rt(this.config.thinkingMode), s = me({
|
|
2039
2108
|
inputId: `input:${n}`,
|
|
2040
2109
|
sessionId: t,
|
|
2041
2110
|
idempotencyKey: `conversation:${n}`,
|
|
2042
2111
|
parts: i,
|
|
2043
|
-
...this.config.selectedModel &&
|
|
2044
|
-
...o !== "auto" &&
|
|
2112
|
+
...this.config.selectedModel && fe(e.surface, "model.select") ? { modelRef: this.config.selectedModel } : {},
|
|
2113
|
+
...o !== "auto" && fe(e.surface, "reasoning.effort") ? { reasoning: o } : {},
|
|
2045
2114
|
extensions: {
|
|
2046
|
-
...this.config.permissionMode &&
|
|
2115
|
+
...this.config.permissionMode && fe(e.surface, "approval") ? { "ksadk.approval": this.config.permissionMode } : {},
|
|
2047
2116
|
...r.executionMode === "plan" ? { "ksadk.collaboration": "plan" } : {},
|
|
2048
2117
|
...r.executionMode === "goal" && a ? { "ksadk.goal": a } : {}
|
|
2049
2118
|
}
|
|
2050
2119
|
});
|
|
2051
|
-
return
|
|
2120
|
+
return de(e.surface, s);
|
|
2052
2121
|
}
|
|
2053
2122
|
async uploadCanonicalAttachments(e) {
|
|
2054
2123
|
this.setStage("uploading-files");
|
|
2055
2124
|
let t = [];
|
|
2056
2125
|
for (let n of e) {
|
|
2057
|
-
if (n.size > 100 * 1024 * 1024) throw new
|
|
2126
|
+
if (n.size > 100 * 1024 * 1024) throw new pe("conversation_input_unsupported", "Conversation attachment exceeds the Hosted UI upload limit.", { capability: n.type.startsWith("image/") ? "attachment.image" : "attachment.file" });
|
|
2058
2127
|
let e = new FormData();
|
|
2059
2128
|
e.append("file", n), e.append("AgentId", this.config.agentId);
|
|
2060
2129
|
let r;
|
|
2061
2130
|
try {
|
|
2062
2131
|
r = await this.api.uploadFile(e, { signal: this.abortController?.signal });
|
|
2063
2132
|
} catch (e) {
|
|
2064
|
-
throw new
|
|
2133
|
+
throw new pe("conversation_http_error", "Conversation attachment upload failed.", { cause: e });
|
|
2065
2134
|
}
|
|
2066
2135
|
let i = r?.FileData?.fileUri;
|
|
2067
|
-
if (!i) throw new
|
|
2136
|
+
if (!i) throw new pe("conversation_contract_mismatch", "Conversation attachment upload did not return an attachment reference.");
|
|
2068
2137
|
t.push({
|
|
2069
2138
|
kind: "attachment",
|
|
2070
2139
|
attachmentRef: i,
|
|
@@ -2095,7 +2164,7 @@ var en = {
|
|
|
2095
2164
|
} catch (e) {
|
|
2096
2165
|
this.emit({
|
|
2097
2166
|
type: "system_message",
|
|
2098
|
-
content: `【系统提示】图片 ${t.name} 读取失败,原因: ${
|
|
2167
|
+
content: `【系统提示】图片 ${t.name} 读取失败,原因: ${It(e)}`
|
|
2099
2168
|
});
|
|
2100
2169
|
}
|
|
2101
2170
|
continue;
|
|
@@ -2112,7 +2181,7 @@ var en = {
|
|
|
2112
2181
|
} catch (e) {
|
|
2113
2182
|
this.emit({
|
|
2114
2183
|
type: "system_message",
|
|
2115
|
-
content: `【系统提示】文件 ${t.name} 上传失败,原因: ${
|
|
2184
|
+
content: `【系统提示】文件 ${t.name} 上传失败,原因: ${It(e)}`
|
|
2116
2185
|
});
|
|
2117
2186
|
}
|
|
2118
2187
|
}
|
|
@@ -2124,43 +2193,43 @@ var en = {
|
|
|
2124
2193
|
return `data:${e.type || "application/octet-stream"};base64,${btoa(n)}`;
|
|
2125
2194
|
}
|
|
2126
2195
|
buildRequestBody(e, n, r, i, a, o) {
|
|
2127
|
-
let s = this.buildExecutionMetadata(i), c = this.config.hostedChatTransport?.Runtime === "dsh" ? this.config.dshApprovalMode : this.config.permissionMode || "risk",
|
|
2128
|
-
this.config.kernelSessionEventsEnabled && this.config.presentationProfile === "agent-block-v1" && (
|
|
2129
|
-
let
|
|
2130
|
-
|
|
2131
|
-
let
|
|
2196
|
+
let s = this.buildExecutionMetadata(i), c = this.config.agentFramework.trim().toLowerCase(), l = this.config.hostedChatTransport?.Runtime === "dsh" ? this.config.dshApprovalMode : this.config.permissionMode || "risk", u = {};
|
|
2197
|
+
this.config.kernelSessionEventsEnabled && this.config.presentationProfile === "agent-block-v1" && (u["ksadk.presentation"] = { profile: "agent-block-v1" });
|
|
2198
|
+
let d = this.config.mcpAuthorization;
|
|
2199
|
+
c === "langgraph" && d?.schema === B.schema && d.digest === B.digest && (u["mcp.authorization"] = B);
|
|
2200
|
+
let m = {
|
|
2132
2201
|
AgentId: this.config.agentId,
|
|
2133
2202
|
SessionId: e,
|
|
2134
2203
|
InvocationId: o,
|
|
2135
2204
|
Stream: !0,
|
|
2136
2205
|
...t(this.config.hostedChatTransport) ? { ContinueOnDisconnect: !0 } : {},
|
|
2137
2206
|
...this.config.kernelSessionEventsEnabled ? { Background: !0 } : {},
|
|
2138
|
-
...Object.keys(
|
|
2207
|
+
...Object.keys(u).length ? { Extensions: u } : {},
|
|
2139
2208
|
ApiFormat: n,
|
|
2140
2209
|
Model: this.config.selectedModel || void 0,
|
|
2141
|
-
ModelMetadata: this.config.selectedModelMetadata
|
|
2142
|
-
ModelOptions:
|
|
2210
|
+
...c !== "ksxc" && this.config.selectedModelMetadata ? { ModelMetadata: this.config.selectedModelMetadata } : {},
|
|
2211
|
+
ModelOptions: zt(Rt(this.config.thinkingMode)),
|
|
2143
2212
|
Metadata: { agentengine: {
|
|
2144
|
-
...
|
|
2213
|
+
...l ? { tool_approval_mode: l } : {},
|
|
2145
2214
|
...f(p.getState().modeFor(this.config.agentId)),
|
|
2146
2215
|
...s
|
|
2147
2216
|
} }
|
|
2148
2217
|
};
|
|
2149
|
-
if (r)
|
|
2218
|
+
if (r) m.ResponsesInput = i.responsesInput, m.PreviousResponseId = i.previousResponseId;
|
|
2150
2219
|
else {
|
|
2151
2220
|
let e = [{
|
|
2152
2221
|
type: "input_text",
|
|
2153
2222
|
text: i.text.trim()
|
|
2154
2223
|
}];
|
|
2155
|
-
e.push(...a), n === "responses" && (
|
|
2224
|
+
e.push(...a), n === "responses" && (m.ResponsesInput = [{
|
|
2156
2225
|
role: "user",
|
|
2157
2226
|
content: e
|
|
2158
|
-
}]),
|
|
2227
|
+
}]), m.Messages = [{
|
|
2159
2228
|
role: "user",
|
|
2160
2229
|
content: e
|
|
2161
2230
|
}];
|
|
2162
2231
|
}
|
|
2163
|
-
return
|
|
2232
|
+
return m;
|
|
2164
2233
|
}
|
|
2165
2234
|
buildExecutionMetadata(e) {
|
|
2166
2235
|
let t = e.executionMode;
|
|
@@ -2177,7 +2246,7 @@ var en = {
|
|
|
2177
2246
|
}
|
|
2178
2247
|
return {};
|
|
2179
2248
|
}
|
|
2180
|
-
async consumeKernelRunEvents(e, t, n, r = "flat-v1") {
|
|
2249
|
+
async consumeKernelRunEvents(e, t, n, r = "flat-v1", i) {
|
|
2181
2250
|
if (t.status === "rejected" || t.status === "unsupported") return this.setStage("error"), this.emit({
|
|
2182
2251
|
type: "error",
|
|
2183
2252
|
error: Error(t.error?.message || `运行提交被拒绝(${t.status})`)
|
|
@@ -2195,45 +2264,47 @@ var en = {
|
|
|
2195
2264
|
status: "running",
|
|
2196
2265
|
countEvent: !1
|
|
2197
2266
|
});
|
|
2198
|
-
let
|
|
2199
|
-
if (this.config.kernelCommandEventsEnabled && !
|
|
2267
|
+
let a = new Pe(e), o = r === "agent-block-v1" && t.presentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1", s = new ge(e, void 0, o), c = this.config.kernelCommandEventsEnabled && t.commandId || void 0;
|
|
2268
|
+
if (this.config.kernelCommandEventsEnabled && !c) return this.emit({
|
|
2200
2269
|
type: "error",
|
|
2201
2270
|
error: /* @__PURE__ */ Error("运行回执缺少命令身份,无法安全订阅本轮输出。")
|
|
2202
2271
|
}), { terminalStatus: "failed" };
|
|
2203
|
-
let
|
|
2204
|
-
|
|
2205
|
-
let
|
|
2206
|
-
for (;
|
|
2272
|
+
let l = !!c || !t.commandId, u = t.runId || "";
|
|
2273
|
+
u && (this.publishInvocation(u), n?.(u));
|
|
2274
|
+
let d, f = 0, p = !1, m = /* @__PURE__ */ new Set();
|
|
2275
|
+
for (; d === void 0 && f < 6;) {
|
|
2207
2276
|
let r;
|
|
2208
2277
|
try {
|
|
2209
|
-
let
|
|
2210
|
-
|
|
2211
|
-
|
|
2278
|
+
let h = this.abortController?.signal;
|
|
2279
|
+
if (h && i && await $t(h), h?.aborted) return { terminalStatus: "cancelled" };
|
|
2280
|
+
let g = this.lastSeqId, _ = await this.api.subscribeSessionEvents(e, g, {
|
|
2281
|
+
signal: h,
|
|
2282
|
+
...c ? { commandId: c } : {}
|
|
2212
2283
|
});
|
|
2213
|
-
|
|
2214
|
-
let
|
|
2215
|
-
for (;
|
|
2216
|
-
let { value:
|
|
2217
|
-
if (
|
|
2218
|
-
|
|
2219
|
-
let
|
|
2220
|
-
|
|
2221
|
-
for (let r of
|
|
2222
|
-
|
|
2284
|
+
f = 0, r = _.getReader();
|
|
2285
|
+
let v = new TextDecoder(), y = "";
|
|
2286
|
+
for (; d === void 0;) {
|
|
2287
|
+
let { value: c, done: f } = await r.read();
|
|
2288
|
+
if (f) break;
|
|
2289
|
+
y += v.decode(c, { stream: !0 });
|
|
2290
|
+
let h = Ft(y);
|
|
2291
|
+
y = h.remainder;
|
|
2292
|
+
for (let r of h.chunks) if (r.trim()) for (let c of Pt(r)) {
|
|
2293
|
+
p && (c.eventName === "__ping__" || c.data && typeof c.data == "object") && (p = !1, this.emit({
|
|
2223
2294
|
type: "activity",
|
|
2224
2295
|
phase: "正在处理",
|
|
2225
2296
|
status: "running",
|
|
2226
2297
|
countEvent: !1
|
|
2227
2298
|
}));
|
|
2228
|
-
let r =
|
|
2299
|
+
let r = c.data;
|
|
2229
2300
|
if (!r || typeof r != "object") continue;
|
|
2230
|
-
let
|
|
2231
|
-
if (Number.isFinite(
|
|
2232
|
-
|
|
2301
|
+
let f = Number(r.seq);
|
|
2302
|
+
if (Number.isFinite(f) && f > 0 && this.recordCursor(f), !l) {
|
|
2303
|
+
l = r.event_type === "control.command_accepted" && r.command_id === t.commandId;
|
|
2233
2304
|
continue;
|
|
2234
2305
|
}
|
|
2235
|
-
let
|
|
2236
|
-
if (!
|
|
2306
|
+
let h = String(r.run_id || "");
|
|
2307
|
+
if (!u && h && (u = h, this.publishInvocation(u), n?.(u)), h && u !== h) continue;
|
|
2237
2308
|
if (String(r.event_type).startsWith("mcp.authorization.")) {
|
|
2238
2309
|
let e = r.payload ?? r, t = String(e.wait_id || "");
|
|
2239
2310
|
t && [
|
|
@@ -2241,41 +2312,46 @@ var en = {
|
|
|
2241
2312
|
"cancelled",
|
|
2242
2313
|
"expired",
|
|
2243
2314
|
"failed"
|
|
2244
|
-
].includes(String(e.status)) ?
|
|
2315
|
+
].includes(String(e.status)) ? m.delete(t) : t && m.add(t);
|
|
2245
2316
|
}
|
|
2246
|
-
if (r.family === "interaction" && typeof r.interaction_id == "string" && (r.event_type === "interaction.requested" ?
|
|
2317
|
+
if (r.family === "interaction" && typeof r.interaction_id == "string" && (r.event_type === "interaction.requested" ? m.add(r.interaction_id) : [
|
|
2247
2318
|
"interaction.resolved",
|
|
2248
2319
|
"interaction.cancelled",
|
|
2249
2320
|
"interaction.expired"
|
|
2250
|
-
].includes(String(r.event_type)) &&
|
|
2251
|
-
let t =
|
|
2321
|
+
].includes(String(r.event_type)) && m.delete(r.interaction_id)), r.schema_version === 2 && r.family === "runtime" && s.apply(r)) {
|
|
2322
|
+
let t = s.snapshot();
|
|
2252
2323
|
this.emit({
|
|
2253
2324
|
type: "conversation_snapshot",
|
|
2254
2325
|
sessionId: e,
|
|
2255
2326
|
result: {
|
|
2256
2327
|
state: t,
|
|
2257
|
-
presentation: he(t, { profile:
|
|
2258
|
-
runId:
|
|
2328
|
+
presentation: he(t, { profile: o }),
|
|
2329
|
+
runId: u,
|
|
2259
2330
|
cursor: this.lastSeqId
|
|
2260
|
-
}
|
|
2331
|
+
},
|
|
2332
|
+
replacesInvocationId: i?.invocationId,
|
|
2333
|
+
optimisticMessageId: i?.optimisticMessageId
|
|
2261
2334
|
});
|
|
2262
2335
|
}
|
|
2263
|
-
let
|
|
2264
|
-
if (
|
|
2336
|
+
let g = a.translate(r);
|
|
2337
|
+
if (g && (this.emit({
|
|
2265
2338
|
type: "stream_event",
|
|
2266
|
-
event:
|
|
2339
|
+
event: g,
|
|
2267
2340
|
sessionId: e
|
|
2268
|
-
}),
|
|
2269
|
-
let e = String(
|
|
2270
|
-
e !== "interrupted" &&
|
|
2341
|
+
}), g.EventType === "run_status")) {
|
|
2342
|
+
let e = String(g.Content?.status || "").toLowerCase();
|
|
2343
|
+
e !== "interrupted" && Xt.has(e) && (d = e);
|
|
2271
2344
|
}
|
|
2272
2345
|
}
|
|
2273
2346
|
}
|
|
2274
|
-
|
|
2347
|
+
if (d === void 0) {
|
|
2348
|
+
if (i && m.size) return { awaitingInput: !0 };
|
|
2349
|
+
await new Promise((e) => setTimeout(e, 3e3));
|
|
2350
|
+
}
|
|
2275
2351
|
} catch (e) {
|
|
2276
|
-
if (e instanceof
|
|
2277
|
-
if (
|
|
2278
|
-
if (
|
|
2352
|
+
if (e instanceof Z || this.abortController?.signal.aborted || e instanceof DOMException && e.name === "AbortError") return { terminalStatus: "cancelled" };
|
|
2353
|
+
if (c && e instanceof X && e.code === 409 && e.detail?.Data?.ReasonCode === "KERNEL_COMMAND_PENDING") {
|
|
2354
|
+
if (p = !0, this.emit({
|
|
2279
2355
|
type: "activity",
|
|
2280
2356
|
phase: "运行已入队,等待执行",
|
|
2281
2357
|
status: "waiting",
|
|
@@ -2283,22 +2359,22 @@ var en = {
|
|
|
2283
2359
|
}), await new Promise((e) => setTimeout(e, 1e3)), this.abortController?.signal.aborted) return { terminalStatus: "cancelled" };
|
|
2284
2360
|
continue;
|
|
2285
2361
|
}
|
|
2286
|
-
if (e instanceof
|
|
2362
|
+
if (e instanceof X && e.code >= 400 && e.code < 500 && e.code !== 429) return this.emit({
|
|
2287
2363
|
type: "error",
|
|
2288
2364
|
error: e
|
|
2289
2365
|
}), { terminalStatus: "failed" };
|
|
2290
|
-
if (
|
|
2291
|
-
|
|
2366
|
+
if (f += 1, f >= 6) break;
|
|
2367
|
+
p = !0, this.emit({
|
|
2292
2368
|
type: "activity",
|
|
2293
2369
|
phase: "网络异常,尝试重连",
|
|
2294
2370
|
status: "waiting",
|
|
2295
2371
|
countEvent: !1
|
|
2296
|
-
}), await new Promise((e) => setTimeout(e, 800 *
|
|
2372
|
+
}), await new Promise((e) => setTimeout(e, 800 * f));
|
|
2297
2373
|
} finally {
|
|
2298
2374
|
await r?.cancel().catch(() => {});
|
|
2299
2375
|
}
|
|
2300
2376
|
}
|
|
2301
|
-
return
|
|
2377
|
+
return d === void 0 ? m.size ? { awaitingInput: !0 } : { outcomeUnknown: !0 } : { terminalStatus: d };
|
|
2302
2378
|
}
|
|
2303
2379
|
async consumeStream(e, t, n, r, i) {
|
|
2304
2380
|
let a = e.getReader(), o = new TextDecoder(), s = "", c = !1, l = 0, u, d = /* @__PURE__ */ new Set(), f = () => ({
|
|
@@ -2313,32 +2389,32 @@ var en = {
|
|
|
2313
2389
|
messageId: r,
|
|
2314
2390
|
invocationId: i
|
|
2315
2391
|
})), s += o.decode(e, { stream: !0 });
|
|
2316
|
-
let { chunks: m, remainder: h } =
|
|
2392
|
+
let { chunks: m, remainder: h } = Ft(s);
|
|
2317
2393
|
s = h;
|
|
2318
2394
|
for (let e of m) {
|
|
2319
2395
|
if (!e.trim()) continue;
|
|
2320
2396
|
if (this.isCompactionChunk(e)) {
|
|
2321
|
-
let t =
|
|
2397
|
+
let t = Pt(e);
|
|
2322
2398
|
for (let e of t) e.eventName.startsWith("response.compaction") && this.upsertCompactionMessage({
|
|
2323
2399
|
...e.data,
|
|
2324
2400
|
phase: e.eventName.split(".").pop()
|
|
2325
2401
|
});
|
|
2326
2402
|
continue;
|
|
2327
2403
|
}
|
|
2328
|
-
let i =
|
|
2404
|
+
let i = Pt(e), o = !1;
|
|
2329
2405
|
for (let e of i) {
|
|
2330
2406
|
if (e.eventName === "__done__") {
|
|
2331
2407
|
o = !0;
|
|
2332
2408
|
continue;
|
|
2333
2409
|
}
|
|
2334
|
-
let i =
|
|
2410
|
+
let i = tn(e.eventName, e.data);
|
|
2335
2411
|
i && !(d.size > 0 && (e.eventName === "response.incomplete" || e.data?.type === "response.incomplete")) && this.emit({
|
|
2336
2412
|
type: "activity",
|
|
2337
2413
|
...i
|
|
2338
2414
|
});
|
|
2339
2415
|
let a = t.parse(e, n);
|
|
2340
2416
|
for (let e of a) e.type === "approval_request" && d.add(e.approvalRequestId), e.type === "canonical_interaction" && d.add(e.interactionId), e.type === "approval_resolved" && d.delete(e.approvalRequestId), this.dispatchAction(e, r), e.type === "terminal" && (u = e.status);
|
|
2341
|
-
if (
|
|
2417
|
+
if (Nt(a)) {
|
|
2342
2418
|
o = !0;
|
|
2343
2419
|
let e = a.find((e) => e.type === "terminal");
|
|
2344
2420
|
u = e && "status" in e ? String(e.status || "") : void 0;
|
|
@@ -2509,8 +2585,8 @@ var en = {
|
|
|
2509
2585
|
};
|
|
2510
2586
|
//#endregion
|
|
2511
2587
|
//#region src/utils/recovered-run.ts
|
|
2512
|
-
function
|
|
2513
|
-
let r = e.filter((e) => e.role === "model" && e.invocationId === n), i =
|
|
2588
|
+
function on(e, t, n) {
|
|
2589
|
+
let r = e.filter((e) => e.role === "model" && e.invocationId === n), i = R(t).filter((e) => e.role === "model"), a = i.map((e) => ({
|
|
2514
2590
|
...e,
|
|
2515
2591
|
id: !e.itemId && i.length === 1 ? r[0]?.id || `${n}:assistant` : e.id,
|
|
2516
2592
|
invocationId: n,
|
|
@@ -2531,25 +2607,25 @@ function nn(e, t, n) {
|
|
|
2531
2607
|
}
|
|
2532
2608
|
//#endregion
|
|
2533
2609
|
//#region src/core/run/dispatcher.ts
|
|
2534
|
-
var
|
|
2535
|
-
function
|
|
2610
|
+
var sn = "连接断开或生成出错,请重试";
|
|
2611
|
+
function cn(e, t, n) {
|
|
2536
2612
|
let r = e.tools?.[t];
|
|
2537
2613
|
return r?.callId ? n ? r.callId === n ? t : n : Object.entries(e.tools ?? {}).findLast(([, e]) => e.name === t)?.[0] ?? t : t;
|
|
2538
2614
|
}
|
|
2539
|
-
function
|
|
2615
|
+
function ln(e) {
|
|
2540
2616
|
let t = String(e.message || "").trim();
|
|
2541
|
-
return /runtime agent kernel is not ready/i.test(t) ? "云端运行时尚未就绪,请检查部署状态后重试" : !t || /failed to fetch|networkerror/i.test(t) ?
|
|
2617
|
+
return /runtime agent kernel is not ready/i.test(t) ? "云端运行时尚未就绪,请检查部署状态后重试" : !t || /failed to fetch|networkerror/i.test(t) ? sn : t.length <= 240 ? t : sn;
|
|
2542
2618
|
}
|
|
2543
|
-
var
|
|
2619
|
+
var un = new Set(["completed"]), dn = new Set([
|
|
2544
2620
|
"failed",
|
|
2545
2621
|
"error",
|
|
2546
2622
|
"cancelled",
|
|
2547
2623
|
"canceled",
|
|
2548
2624
|
"aborted",
|
|
2549
2625
|
"incomplete"
|
|
2550
|
-
]),
|
|
2551
|
-
function
|
|
2552
|
-
|
|
2626
|
+
]), fn = /* @__PURE__ */ new Map();
|
|
2627
|
+
function pn(e, t) {
|
|
2628
|
+
K.getState().patchMessages((n) => {
|
|
2553
2629
|
if (n.some((t) => t.id === e)) return t ? n.map((n) => n.id === e ? {
|
|
2554
2630
|
...n,
|
|
2555
2631
|
invocationId: t
|
|
@@ -2574,12 +2650,12 @@ function un(e, t) {
|
|
|
2574
2650
|
}];
|
|
2575
2651
|
});
|
|
2576
2652
|
}
|
|
2577
|
-
function
|
|
2653
|
+
function mn(e) {
|
|
2578
2654
|
return e.filter((e) => e.eventType !== "optimistic_assistant_placeholder");
|
|
2579
2655
|
}
|
|
2580
|
-
function
|
|
2581
|
-
let t = String(e || "").trim().toLowerCase(), n =
|
|
2582
|
-
n &&
|
|
2656
|
+
function hn(e) {
|
|
2657
|
+
let t = String(e || "").trim().toLowerCase(), n = un.has(t) ? "completed" : dn.has(t) ? "error" : null;
|
|
2658
|
+
n && K.getState().patchMessages((e) => e.map((e) => {
|
|
2583
2659
|
if (!e.tools) return e;
|
|
2584
2660
|
let t = !1, r = Object.fromEntries(Object.entries(e.tools).map(([e, r]) => r.status === "running" ? (t = !0, [e, {
|
|
2585
2661
|
...r,
|
|
@@ -2591,7 +2667,7 @@ function fn(e) {
|
|
|
2591
2667
|
} : e;
|
|
2592
2668
|
}));
|
|
2593
2669
|
}
|
|
2594
|
-
function
|
|
2670
|
+
function gn(e, t) {
|
|
2595
2671
|
!e.sessionId && t?.draftId && (e = {
|
|
2596
2672
|
...e,
|
|
2597
2673
|
sessionId: t.draftId
|
|
@@ -2610,7 +2686,7 @@ function pn(e, t) {
|
|
|
2610
2686
|
"stream_event",
|
|
2611
2687
|
"conversation_snapshot"
|
|
2612
2688
|
].includes(e.type)) return;
|
|
2613
|
-
let r =
|
|
2689
|
+
let r = K.getState(), i = (e) => {
|
|
2614
2690
|
e && m.getState().updateActivity({ sessionId: e });
|
|
2615
2691
|
};
|
|
2616
2692
|
switch (e.type) {
|
|
@@ -2634,10 +2710,10 @@ function pn(e, t) {
|
|
|
2634
2710
|
}]);
|
|
2635
2711
|
break;
|
|
2636
2712
|
case "assistant_message_created":
|
|
2637
|
-
|
|
2713
|
+
pn(e.messageId, e.invocationId);
|
|
2638
2714
|
break;
|
|
2639
2715
|
case "text_delta":
|
|
2640
|
-
|
|
2716
|
+
pn(e.messageId), i(e.sessionId), r.patchMessages((t) => t.map((t) => t.id === e.messageId ? {
|
|
2641
2717
|
...t,
|
|
2642
2718
|
content: t.content + e.delta,
|
|
2643
2719
|
blocks: xe(t.blocks, e.delta)
|
|
@@ -2652,7 +2728,7 @@ function pn(e, t) {
|
|
|
2652
2728
|
} : t)), i(e.sessionId);
|
|
2653
2729
|
break;
|
|
2654
2730
|
case "text_final":
|
|
2655
|
-
|
|
2731
|
+
pn(e.messageId), i(e.sessionId), r.patchMessages((t) => t.map((t) => t.id === e.messageId ? (() => {
|
|
2656
2732
|
let n = !!(e.text && !t.content && t.reasoning?.endsWith(e.text)), r = n ? t.reasoning.slice(0, -e.text.length) : t.reasoning, i = n ? Te(t.blocks, e.text) : t.blocks;
|
|
2657
2733
|
return {
|
|
2658
2734
|
...t,
|
|
@@ -2663,7 +2739,7 @@ function pn(e, t) {
|
|
|
2663
2739
|
})() : t));
|
|
2664
2740
|
break;
|
|
2665
2741
|
case "reasoning_delta":
|
|
2666
|
-
|
|
2742
|
+
pn(e.messageId), i(e.sessionId), r.patchMessages((t) => t.map((t) => t.id === e.messageId ? {
|
|
2667
2743
|
...t,
|
|
2668
2744
|
reasoning: (t.reasoning || "") + e.delta,
|
|
2669
2745
|
blocks: Me(t.blocks, e.delta, e.itemId)
|
|
@@ -2681,9 +2757,9 @@ function pn(e, t) {
|
|
|
2681
2757
|
}));
|
|
2682
2758
|
break;
|
|
2683
2759
|
case "tool_upsert":
|
|
2684
|
-
|
|
2760
|
+
pn(e.messageId), i(e.sessionId), r.patchMessages((t) => t.map((t) => {
|
|
2685
2761
|
if (t.id !== e.messageId) return t;
|
|
2686
|
-
let n =
|
|
2762
|
+
let n = cn(t, e.name, e.callId), r = t.tools?.[n], i = e.callId ? {
|
|
2687
2763
|
...e.extra,
|
|
2688
2764
|
callId: e.callId
|
|
2689
2765
|
} : e.extra, a = r?.approvalStatus === "approved" || r?.approvalStatus === "rejected" || r?.approvalStatus === "cancelled", o = e.status, s = r?.approvalStatus === "rejected" || r?.approvalStatus === "cancelled" ? "completed" : r?.status === "error" && o !== "error" ? "error" : o;
|
|
@@ -2712,9 +2788,9 @@ function pn(e, t) {
|
|
|
2712
2788
|
}));
|
|
2713
2789
|
break;
|
|
2714
2790
|
case "tool_result":
|
|
2715
|
-
|
|
2791
|
+
pn(e.messageId), i(e.sessionId), r.patchMessages((t) => t.map((t) => {
|
|
2716
2792
|
if (t.id !== e.messageId) return t;
|
|
2717
|
-
let n =
|
|
2793
|
+
let n = F(e.output) ? "error" : "completed", r = cn(t, e.name, e.callId);
|
|
2718
2794
|
return {
|
|
2719
2795
|
...t,
|
|
2720
2796
|
blocks: Ne(t.blocks, e.name, {
|
|
@@ -2750,7 +2826,7 @@ function pn(e, t) {
|
|
|
2750
2826
|
previousResponseId: e.previousResponseId,
|
|
2751
2827
|
sessionId: e.sessionId
|
|
2752
2828
|
}), n) break;
|
|
2753
|
-
|
|
2829
|
+
pn(e.messageId), r.patchMessages((t) => t.map((t) => {
|
|
2754
2830
|
if (t.id !== e.messageId) return t;
|
|
2755
2831
|
let n = t.tools?.[e.approvalRequestId], r = n?.approvalStatus === "approved" || n?.approvalStatus === "rejected" || n?.approvalStatus === "cancelled", i = {
|
|
2756
2832
|
approvalRequestId: e.approvalRequestId,
|
|
@@ -2784,7 +2860,7 @@ function pn(e, t) {
|
|
|
2784
2860
|
y(e);
|
|
2785
2861
|
break;
|
|
2786
2862
|
case "question_requested":
|
|
2787
|
-
|
|
2863
|
+
k({
|
|
2788
2864
|
questionId: e.questionId,
|
|
2789
2865
|
questions: e.questions,
|
|
2790
2866
|
runId: e.runId,
|
|
@@ -2845,7 +2921,7 @@ function pn(e, t) {
|
|
|
2845
2921
|
}]);
|
|
2846
2922
|
break;
|
|
2847
2923
|
case "compaction": {
|
|
2848
|
-
let t = `compaction-${Date.now()}`, n = e.phase === "start" ? "running" : e.phase === "failed" ? "failed" : "completed", i =
|
|
2924
|
+
let t = `compaction-${Date.now()}`, n = e.phase === "start" ? "running" : e.phase === "failed" ? "failed" : "completed", i = z({
|
|
2849
2925
|
id: t,
|
|
2850
2926
|
timestamp: Date.now(),
|
|
2851
2927
|
status: n,
|
|
@@ -2862,7 +2938,7 @@ function pn(e, t) {
|
|
|
2862
2938
|
e.stage === "streaming" || e.stage === "connecting" ? m.getState().setSessionStreaming(e.sessionId, !0) : (e.stage === "completing" || e.stage === "error" || e.stage === "cancelled") && m.getState().setSessionStreaming(e.sessionId, !1);
|
|
2863
2939
|
break;
|
|
2864
2940
|
case "stream_ended":
|
|
2865
|
-
m.getState().setSessionStreaming(e.sessionId, !1), n ||
|
|
2941
|
+
m.getState().setSessionStreaming(e.sessionId, !1), n || K.getState().patchMessages((t) => mn(t).map((t) => !(!e.runId || t.runId === e.runId || t.invocationId === e.runId) || t.role !== "model" || !t.blocks?.some((e) => e.status === "streaming") ? t : {
|
|
2866
2942
|
...t,
|
|
2867
2943
|
blocks: ke(t.blocks.map((e) => e.type === "text" && e.status === "streaming" ? {
|
|
2868
2944
|
...e,
|
|
@@ -2874,7 +2950,7 @@ function pn(e, t) {
|
|
|
2874
2950
|
}, 2400);
|
|
2875
2951
|
break;
|
|
2876
2952
|
case "error": {
|
|
2877
|
-
let t =
|
|
2953
|
+
let t = ln(e.error);
|
|
2878
2954
|
m.getState().setSessionStreaming(e.sessionId, !1), m.getState().updateActivity({
|
|
2879
2955
|
sessionId: e.sessionId,
|
|
2880
2956
|
visible: !n,
|
|
@@ -2886,7 +2962,7 @@ function pn(e, t) {
|
|
|
2886
2962
|
kind: "error",
|
|
2887
2963
|
message: t,
|
|
2888
2964
|
sessionId: e.sessionId
|
|
2889
|
-
}), r.patchMessages((e) => [...
|
|
2965
|
+
}), r.patchMessages((e) => [...mn(e), {
|
|
2890
2966
|
id: String(Date.now()),
|
|
2891
2967
|
role: "model",
|
|
2892
2968
|
content: `运行失败:${t}`,
|
|
@@ -2906,10 +2982,10 @@ function pn(e, t) {
|
|
|
2906
2982
|
message: e.message || "请求过于频繁,请稍后重试",
|
|
2907
2983
|
retryAfterSec: e.retryAfterSec,
|
|
2908
2984
|
sessionId: e.sessionId
|
|
2909
|
-
}), r.patchMessages(
|
|
2985
|
+
}), r.patchMessages(mn));
|
|
2910
2986
|
break;
|
|
2911
2987
|
case "terminal":
|
|
2912
|
-
e.sessionId && String(e.status || "").trim().toLowerCase() !== "incomplete" && w.markSessionTerminal(e.sessionId), n ||
|
|
2988
|
+
e.sessionId && String(e.status || "").trim().toLowerCase() !== "incomplete" && w.markSessionTerminal(e.sessionId), n || hn(e.status);
|
|
2913
2989
|
break;
|
|
2914
2990
|
case "stream_event": {
|
|
2915
2991
|
let t = e.sessionId || e.event.SessionId;
|
|
@@ -2921,12 +2997,12 @@ function pn(e, t) {
|
|
|
2921
2997
|
});
|
|
2922
2998
|
let i = String(e.event.InvocationId || "").trim();
|
|
2923
2999
|
if (!n && t && i) {
|
|
2924
|
-
let n = `${t}:${i}`, r =
|
|
2925
|
-
|
|
3000
|
+
let n = `${t}:${i}`, r = I(fn.get(n) || [], [e.event]);
|
|
3001
|
+
fn.set(n, r), K.getState().patchMessages((e) => e.some((e) => e.eventType === "conversation_item_v1" && e.runId === i) ? e : on(e, r, i)), P(e.event) && fn.delete(n);
|
|
2926
3002
|
}
|
|
2927
3003
|
e.event.EventType === "run_checkpoint" && t && W.getState().upsertSessionCheckpoint(t, e.event);
|
|
2928
3004
|
{
|
|
2929
|
-
let r =
|
|
3005
|
+
let r = ne(e.event);
|
|
2930
3006
|
r === "completed" ? m.getState().updateActivity({
|
|
2931
3007
|
sessionId: t,
|
|
2932
3008
|
visible: !n,
|
|
@@ -2953,12 +3029,12 @@ function pn(e, t) {
|
|
|
2953
3029
|
let t = De(e.result);
|
|
2954
3030
|
for (let e of t.interactions) w.upsert(e);
|
|
2955
3031
|
if (n) break;
|
|
2956
|
-
r.patchMessages((t) => Ae(t, e.result, e.optimisticMessageId)), i(e.sessionId);
|
|
3032
|
+
r.patchMessages((t) => Ae(t, e.result, e.optimisticMessageId, e.replacesInvocationId)), i(e.sessionId);
|
|
2957
3033
|
break;
|
|
2958
3034
|
}
|
|
2959
3035
|
case "a2ui_surface_begin": {
|
|
2960
3036
|
let t = `a2ui-${e.surfaceId}`;
|
|
2961
|
-
|
|
3037
|
+
K.getState().patchMessages((n) => [...n.filter((e) => e.id !== t), {
|
|
2962
3038
|
id: t,
|
|
2963
3039
|
role: "a2ui",
|
|
2964
3040
|
content: "",
|
|
@@ -2972,7 +3048,7 @@ function pn(e, t) {
|
|
|
2972
3048
|
}
|
|
2973
3049
|
case "a2ui_surface_update": {
|
|
2974
3050
|
let t = `a2ui-${e.surfaceId}`;
|
|
2975
|
-
|
|
3051
|
+
K.getState().patchMessages((n) => n.map((n) => n.id === t && n.a2ui ? {
|
|
2976
3052
|
...n,
|
|
2977
3053
|
a2ui: {
|
|
2978
3054
|
...n.a2ui,
|
|
@@ -2983,7 +3059,7 @@ function pn(e, t) {
|
|
|
2983
3059
|
}
|
|
2984
3060
|
case "a2ui_surface_end": {
|
|
2985
3061
|
let t = `a2ui-${e.surfaceId}`;
|
|
2986
|
-
|
|
3062
|
+
K.getState().patchMessages((e) => e.map((e) => e.id === t && e.a2ui ? {
|
|
2987
3063
|
...e,
|
|
2988
3064
|
a2ui: {
|
|
2989
3065
|
...e.a2ui,
|
|
@@ -2994,7 +3070,7 @@ function pn(e, t) {
|
|
|
2994
3070
|
}
|
|
2995
3071
|
case "a2ui_interaction": {
|
|
2996
3072
|
let t = `a2ui-${e.surfaceId}`;
|
|
2997
|
-
|
|
3073
|
+
K.getState().patchMessages((n) => n.map((n) => n.id === t && n.a2ui ? {
|
|
2998
3074
|
...n,
|
|
2999
3075
|
a2ui: {
|
|
3000
3076
|
...n.a2ui,
|
|
@@ -3008,7 +3084,7 @@ function pn(e, t) {
|
|
|
3008
3084
|
break;
|
|
3009
3085
|
}
|
|
3010
3086
|
case "agui_activity":
|
|
3011
|
-
|
|
3087
|
+
K.getState().patchMessages((t) => {
|
|
3012
3088
|
let n = t.find((t) => t.id === e.messageId), r = e.runId || n?.runId || n?.invocationId, i = `agui-a2ui-${JSON.stringify([
|
|
3013
3089
|
r || e.messageId,
|
|
3014
3090
|
e.interactionId || "",
|
|
@@ -3056,41 +3132,42 @@ function pn(e, t) {
|
|
|
3056
3132
|
break;
|
|
3057
3133
|
}
|
|
3058
3134
|
}
|
|
3059
|
-
function
|
|
3060
|
-
|
|
3135
|
+
function _n() {
|
|
3136
|
+
fn.clear();
|
|
3061
3137
|
}
|
|
3062
3138
|
//#endregion
|
|
3063
3139
|
//#region src/hooks/useRunAgent.ts
|
|
3064
|
-
var
|
|
3065
|
-
function
|
|
3140
|
+
var vn = 64;
|
|
3141
|
+
function yn(e, t, n) {
|
|
3066
3142
|
if (t.sessionId = n, t.conversationId) return;
|
|
3067
3143
|
let r = JSON.stringify([t.agentId, n]);
|
|
3068
3144
|
e.set(r, t), t.key !== r && e.get(t.key) === t && e.delete(t.key), t.key = r;
|
|
3069
3145
|
}
|
|
3070
|
-
function
|
|
3071
|
-
let t = _(), r =
|
|
3146
|
+
function bn(e) {
|
|
3147
|
+
let t = _(), r = Y(/* @__PURE__ */ new Map()), i = Y(/* @__PURE__ */ new Set()), a = q((e) => i.current.has(e), []), o = q((e) => {
|
|
3072
3148
|
let t = r.current;
|
|
3073
|
-
if (!(t.size <=
|
|
3074
|
-
if (t.size <=
|
|
3149
|
+
if (!(t.size <= vn)) for (let [n, r] of t) {
|
|
3150
|
+
if (t.size <= vn) break;
|
|
3075
3151
|
n === e || r.engine.stage !== "idle" || r.queue.length > 0 || r.isVisible() || t.delete(n);
|
|
3076
3152
|
}
|
|
3077
|
-
}, []), l = Ve(() => new ve({ rendererCatalog: Se }), []), u = e.conversationClient === void 0 ? e.uiCapabilities.ConversationSurface == null ? null : l : e.conversationClient, { agentId: d, apiFormats: f, agentFramework: p, selectedModel: h, selectedModelMetadata: v, thinkingMode: y, permissionMode: b, currentSessionIdRef: x, conversationIdRef: S, queuedDraftRef: ee, onRunSettled: C,
|
|
3153
|
+
}, []), l = Ve(() => new ve({ rendererCatalog: Se }), []), u = e.conversationClient === void 0 ? e.uiCapabilities.ConversationSurface == null ? null : l : e.conversationClient, { agentId: d, apiFormats: f, agentFramework: p, selectedModel: h, selectedModelMetadata: v, thinkingMode: y, permissionMode: b, currentSessionIdRef: x, conversationIdRef: S, queuedDraftRef: ee, onRunSettled: C, onUserInputBound: w, onRunRecovered: T, onSessionCreated: E, waitForPendingSessionCreation: D, uiCapabilities: O, outbox: k } = e, te = c((e) => e.status === "ready" && e.agentId === d && e.accessMode !== "Share" ? e.capabilities.McpAuthorization : void 0), A = Ve(() => ({
|
|
3078
3154
|
a2uiCatalogRegistry: t,
|
|
3079
3155
|
agentId: d,
|
|
3080
3156
|
apiFormats: f,
|
|
3081
3157
|
agentFramework: p,
|
|
3082
3158
|
selectedModel: h,
|
|
3083
3159
|
selectedModelMetadata: v,
|
|
3084
|
-
thinkingMode:
|
|
3160
|
+
thinkingMode: O.Thinking ? y : "auto",
|
|
3085
3161
|
permissionMode: b,
|
|
3086
3162
|
mcpAuthorization: te,
|
|
3087
|
-
dshApprovalMode:
|
|
3088
|
-
runtimeCapabilityMatrix:
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3163
|
+
dshApprovalMode: O.Approval && O.ApprovalPolicy?.RuntimeOverride ? O.ApprovalPolicy.DefaultMode : void 0,
|
|
3164
|
+
runtimeCapabilityMatrix: O.RuntimeCapabilityMatrix,
|
|
3165
|
+
aguiResumeTransport: O.HostedChat?.Transports?.find((e) => e.Protocol === "ag-ui"),
|
|
3166
|
+
hostedChatTransport: n(O, { requireResumableRun: !!(O.RunLifecycle?.Enabled && O.RunLifecycle.Resume) }),
|
|
3167
|
+
checkpointResumePreviewEnabled: !!O.RunLifecycle?.CheckpointResumePreview,
|
|
3168
|
+
kernelSessionEventsEnabled: O.KernelSessionEvents === !0 || O.KernelSessionEventsByCommand === !0,
|
|
3169
|
+
kernelCommandEventsEnabled: O.KernelSessionEventsByCommand === !0,
|
|
3170
|
+
presentationProfile: ue(O.ConversationSurface, Se),
|
|
3094
3171
|
conversationClient: u || void 0
|
|
3095
3172
|
}), [
|
|
3096
3173
|
d,
|
|
@@ -3100,15 +3177,15 @@ function _n(e) {
|
|
|
3100
3177
|
v,
|
|
3101
3178
|
y,
|
|
3102
3179
|
b,
|
|
3103
|
-
|
|
3180
|
+
O,
|
|
3104
3181
|
te,
|
|
3105
3182
|
u,
|
|
3106
3183
|
t
|
|
3107
|
-
]),
|
|
3184
|
+
]), j = q((t = x.current) => {
|
|
3108
3185
|
let n = e.conversationIdRef?.current, i = JSON.stringify([d, n || t || "new-session"]), a = r.current.get(i);
|
|
3109
3186
|
if (!a) {
|
|
3110
3187
|
o(i);
|
|
3111
|
-
let s = () => e.agentIdRef.current === d && (e.conversationIdRef ? e.conversationIdRef.current === n : x.current === a.sessionId), c = new
|
|
3188
|
+
let s = () => e.agentIdRef.current === d && (e.conversationIdRef ? e.conversationIdRef.current === n : x.current === a.sessionId), c = new an(e.api, {
|
|
3112
3189
|
isVisible: s,
|
|
3113
3190
|
draftId: n
|
|
3114
3191
|
});
|
|
@@ -3120,7 +3197,7 @@ function _n(e) {
|
|
|
3120
3197
|
engine: c,
|
|
3121
3198
|
queue: [],
|
|
3122
3199
|
isVisible: s
|
|
3123
|
-
}, c.subscribe((e) =>
|
|
3200
|
+
}, c.subscribe((e) => gn(e, {
|
|
3124
3201
|
visible: s(),
|
|
3125
3202
|
draftId: n
|
|
3126
3203
|
})), r.current.set(i, a);
|
|
@@ -3133,31 +3210,31 @@ function _n(e) {
|
|
|
3133
3210
|
e.conversationIdRef,
|
|
3134
3211
|
x,
|
|
3135
3212
|
o
|
|
3136
|
-
]),
|
|
3137
|
-
let t =
|
|
3138
|
-
return t.engine.stage === "idle" && t.engine.updateConfig(
|
|
3139
|
-
}, [
|
|
3213
|
+
]), M = q((e) => {
|
|
3214
|
+
let t = j(e);
|
|
3215
|
+
return t.engine.stage === "idle" && t.engine.updateConfig(A), t.engine;
|
|
3216
|
+
}, [A, j]), N = q((e) => {
|
|
3140
3217
|
if (!e.isVisible()) return;
|
|
3141
3218
|
let t = e.queue.map((e) => e.draft);
|
|
3142
3219
|
ee.current = t, g.getState().setQueuedDrafts(t);
|
|
3143
|
-
}, [ee]),
|
|
3220
|
+
}, [ee]), P = q((e) => {
|
|
3144
3221
|
let t = e.queue[0];
|
|
3145
|
-
!t || e.engine.stage !== "idle" || (e.queue.shift(),
|
|
3146
|
-
t.launch() || (e.queue.unshift(t),
|
|
3222
|
+
!t || e.engine.stage !== "idle" || (e.queue.shift(), N(e), queueMicrotask(() => {
|
|
3223
|
+
t.launch() || (e.queue.unshift(t), N(e));
|
|
3147
3224
|
}));
|
|
3148
|
-
}, [
|
|
3149
|
-
|
|
3225
|
+
}, [N]);
|
|
3226
|
+
J(() => {
|
|
3150
3227
|
let t = JSON.stringify([d, e.conversationId || S?.current || e.currentSessionId || "new-session"]), n = r.current.get(t);
|
|
3151
|
-
n ?
|
|
3228
|
+
n ? N(n) : (ee.current = [], g.getState().setQueuedDrafts([]));
|
|
3152
3229
|
}, [
|
|
3153
3230
|
d,
|
|
3154
3231
|
e.currentSessionId,
|
|
3155
3232
|
e.conversationId,
|
|
3156
3233
|
S,
|
|
3157
|
-
|
|
3234
|
+
N,
|
|
3158
3235
|
ee
|
|
3159
3236
|
]);
|
|
3160
|
-
let
|
|
3237
|
+
let F = q((e) => {
|
|
3161
3238
|
let t = e.text.trim(), n = e.attachments.map((e) => ({
|
|
3162
3239
|
name: e.name,
|
|
3163
3240
|
url: URL.createObjectURL(e),
|
|
@@ -3165,7 +3242,7 @@ function _n(e) {
|
|
|
3165
3242
|
}));
|
|
3166
3243
|
if (!t && n.length === 0) return;
|
|
3167
3244
|
let r = `optimistic-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3168
|
-
return
|
|
3245
|
+
return K.getState().patchMessages((e) => [...e, {
|
|
3169
3246
|
id: r,
|
|
3170
3247
|
role: "user",
|
|
3171
3248
|
content: t,
|
|
@@ -3173,9 +3250,9 @@ function _n(e) {
|
|
|
3173
3250
|
eventType: "optimistic_user_message",
|
|
3174
3251
|
attachments: n.length ? n : void 0
|
|
3175
3252
|
}]), r;
|
|
3176
|
-
}, []),
|
|
3253
|
+
}, []), I = q((e) => {
|
|
3177
3254
|
let t = `optimistic-assistant-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3178
|
-
return
|
|
3255
|
+
return K.getState().patchMessages((n) => {
|
|
3179
3256
|
let r = n.findIndex((t) => t.id === e), i = r < 0 ? n.length : r + 1;
|
|
3180
3257
|
return [
|
|
3181
3258
|
...n.slice(0, i),
|
|
@@ -3190,129 +3267,135 @@ function _n(e) {
|
|
|
3190
3267
|
...n.slice(i)
|
|
3191
3268
|
];
|
|
3192
3269
|
}), t;
|
|
3193
|
-
}, []),
|
|
3194
|
-
if (
|
|
3195
|
-
let
|
|
3196
|
-
|
|
3197
|
-
let
|
|
3198
|
-
text:
|
|
3199
|
-
attachments: [...
|
|
3200
|
-
responsesInput:
|
|
3201
|
-
previousResponseId:
|
|
3202
|
-
executionMode:
|
|
3203
|
-
optimisticMessageId:
|
|
3204
|
-
text:
|
|
3205
|
-
attachments:
|
|
3270
|
+
}, []), L = q(async (t, n, a, o, c, l) => {
|
|
3271
|
+
if (l && i.current.has(l)) return !1;
|
|
3272
|
+
let u = j();
|
|
3273
|
+
N(u);
|
|
3274
|
+
let d = {
|
|
3275
|
+
text: t,
|
|
3276
|
+
attachments: [...n],
|
|
3277
|
+
responsesInput: a,
|
|
3278
|
+
previousResponseId: o,
|
|
3279
|
+
executionMode: c,
|
|
3280
|
+
optimisticMessageId: F({
|
|
3281
|
+
text: t,
|
|
3282
|
+
attachments: n
|
|
3206
3283
|
})
|
|
3207
|
-
},
|
|
3208
|
-
requestId:
|
|
3209
|
-
conversationId:
|
|
3210
|
-
agentId:
|
|
3211
|
-
text:
|
|
3212
|
-
attachments:
|
|
3284
|
+
}, f = a === void 0 && u.conversationId && k ? k : void 0, p = u.conversationId && f ? f.enqueue({
|
|
3285
|
+
requestId: l,
|
|
3286
|
+
conversationId: u.conversationId,
|
|
3287
|
+
agentId: u.agentId,
|
|
3288
|
+
text: t,
|
|
3289
|
+
attachments: n.map((e) => ({
|
|
3213
3290
|
name: e.name,
|
|
3214
3291
|
type: e.type,
|
|
3215
3292
|
size: e.size
|
|
3216
3293
|
})),
|
|
3217
|
-
executionMode:
|
|
3294
|
+
executionMode: c
|
|
3218
3295
|
}) : void 0;
|
|
3219
|
-
|
|
3220
|
-
let
|
|
3296
|
+
p && f && (i.current.add(p.requestId), f.setRuntimeAttachments(p.requestId, n));
|
|
3297
|
+
let h;
|
|
3221
3298
|
try {
|
|
3222
|
-
|
|
3299
|
+
h = await D?.();
|
|
3223
3300
|
} catch (e) {
|
|
3224
|
-
throw
|
|
3301
|
+
throw p && f && (i.current.delete(p.requestId), f.update(p.requestId, {
|
|
3225
3302
|
status: "unknown",
|
|
3226
3303
|
error: "创建会话的结果待确认。"
|
|
3227
3304
|
})), e;
|
|
3228
3305
|
}
|
|
3229
|
-
!
|
|
3230
|
-
let
|
|
3231
|
-
|
|
3232
|
-
}),
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
...
|
|
3237
|
-
|
|
3306
|
+
!u.sessionId && h && yn(r.current, u, h);
|
|
3307
|
+
let _, v = a === void 0 ? null : new Promise((e) => {
|
|
3308
|
+
_ = e;
|
|
3309
|
+
}), y = (t) => {
|
|
3310
|
+
let n = d.optimisticMessageId;
|
|
3311
|
+
n && (u.sessionId && e.agentIdRef.current === u.agentId && w?.(u.sessionId, n, t), u.isVisible() && K.getState().patchMessages((e) => e.map((e) => e.id === n ? {
|
|
3312
|
+
...e,
|
|
3313
|
+
...t
|
|
3314
|
+
} : e)));
|
|
3315
|
+
}, b = () => {
|
|
3316
|
+
if (u.engine.stage !== "idle") return !1;
|
|
3317
|
+
u.engine.updateConfig(A), p && f && f.markSending(p.requestId), u.isVisible() && (g.getState().setMobileActionsOpen(!1), I(d.optimisticMessageId)), m.getState().setSessionStreaming(u.sessionId || u.conversationId, !0);
|
|
3318
|
+
let e = u.engine.start({
|
|
3319
|
+
...d,
|
|
3320
|
+
sessionId: u.sessionId,
|
|
3238
3321
|
onInvocationCreated: (e) => {
|
|
3239
|
-
|
|
3240
|
-
...t,
|
|
3241
|
-
invocationId: e
|
|
3242
|
-
} : t));
|
|
3322
|
+
p && f && f.update(p.requestId, { invocationId: e }), y({ invocationId: e });
|
|
3243
3323
|
},
|
|
3324
|
+
onCommandAdmitted: (e) => y({ commandId: e }),
|
|
3244
3325
|
onSessionCreated: (e) => {
|
|
3245
|
-
let t =
|
|
3246
|
-
|
|
3326
|
+
let t = u.isVisible(), n = u.sessionId || u.conversationId;
|
|
3327
|
+
yn(r.current, u, e), p && f && f.update(p.requestId, { nativeSessionId: e }), m.getState().setSessionStreaming(e, !0), n !== e && m.getState().setSessionStreaming(n, !1), E?.(e, u.conversationId, u.agentId), !E && t && (s.getState().upsertSessions([{
|
|
3247
3328
|
SessionId: e,
|
|
3248
3329
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3249
|
-
}]), x.current = e, s.getState().setCurrentSessionId(e)), t &&
|
|
3330
|
+
}]), x.current = e, s.getState().setCurrentSessionId(e)), t && ct(u.agentId, e);
|
|
3250
3331
|
},
|
|
3251
3332
|
onSessionUpsert: () => {},
|
|
3252
|
-
onDispatchResult:
|
|
3333
|
+
onDispatchResult: _,
|
|
3253
3334
|
onRecovered: (e, t) => {
|
|
3254
|
-
|
|
3335
|
+
u.isVisible() && u.sessionId === e && T?.(e, t);
|
|
3255
3336
|
},
|
|
3256
3337
|
onSettled: (e, t = "unknown") => {
|
|
3257
|
-
|
|
3338
|
+
p && i.current.delete(p.requestId), p && f && f.update(p.requestId, { status: t === "completed" || t === "awaiting-input" ? "completed" : t === "cancelled" ? "cancelled" : t === "failed" ? "failed" : "unknown" }), C?.(e, u.agentId, t), t === "completed" && P(u);
|
|
3258
3339
|
}
|
|
3259
3340
|
});
|
|
3260
|
-
return e || m.getState().setSessionStreaming(
|
|
3261
|
-
},
|
|
3262
|
-
return !
|
|
3263
|
-
draft:
|
|
3264
|
-
launch:
|
|
3265
|
-
}),
|
|
3341
|
+
return e || m.getState().setSessionStreaming(u.sessionId || u.conversationId, !1), e;
|
|
3342
|
+
}, S = b();
|
|
3343
|
+
return !S && a === void 0 ? (u.queue.push({
|
|
3344
|
+
draft: d,
|
|
3345
|
+
launch: b
|
|
3346
|
+
}), N(u), !0) : v ? (S || _?.(!1), v) : S;
|
|
3266
3347
|
}, [
|
|
3348
|
+
I,
|
|
3349
|
+
F,
|
|
3350
|
+
A,
|
|
3351
|
+
e.agentIdRef,
|
|
3352
|
+
x,
|
|
3267
3353
|
P,
|
|
3268
|
-
|
|
3354
|
+
j,
|
|
3355
|
+
T,
|
|
3356
|
+
C,
|
|
3357
|
+
E,
|
|
3358
|
+
w,
|
|
3269
3359
|
k,
|
|
3270
|
-
x,
|
|
3271
3360
|
N,
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
]), I = K(() => {
|
|
3280
|
-
j(x.current).stop();
|
|
3281
|
-
}, [x, j]), L = K(() => {
|
|
3282
|
-
j(x.current).disconnect();
|
|
3283
|
-
}, [x, j]), R = K((e) => {
|
|
3284
|
-
let t = A(e.sessionId), n = j(e.sessionId);
|
|
3361
|
+
D
|
|
3362
|
+
]), R = q(() => {
|
|
3363
|
+
M(x.current).stop();
|
|
3364
|
+
}, [x, M]), ne = q(() => {
|
|
3365
|
+
M(x.current).disconnect();
|
|
3366
|
+
}, [x, M]), z = q((e) => {
|
|
3367
|
+
let t = j(e.sessionId), n = M(e.sessionId);
|
|
3285
3368
|
if (n.stage !== "idle") return !1;
|
|
3286
|
-
|
|
3369
|
+
_n(), g.getState().setMobileActionsOpen(!1), m.getState().setSessionStreaming(e.sessionId, !0);
|
|
3287
3370
|
let r = n.resumeCheckpoint({
|
|
3288
3371
|
...e,
|
|
3289
3372
|
onSettled: (e, n) => {
|
|
3290
|
-
C?.(e, t.agentId, n), n === "completed" &&
|
|
3373
|
+
C?.(e, t.agentId, n), n === "completed" && P(t);
|
|
3291
3374
|
}
|
|
3292
3375
|
});
|
|
3293
3376
|
return r || m.getState().setSessionStreaming(e.sessionId, !1), r;
|
|
3294
3377
|
}, [
|
|
3295
|
-
|
|
3378
|
+
P,
|
|
3379
|
+
M,
|
|
3296
3380
|
j,
|
|
3297
|
-
A,
|
|
3298
3381
|
C
|
|
3299
|
-
]), re =
|
|
3300
|
-
|
|
3382
|
+
]), re = q(() => {
|
|
3383
|
+
_n();
|
|
3301
3384
|
}, []);
|
|
3302
3385
|
return {
|
|
3303
|
-
submitDraft:
|
|
3386
|
+
submitDraft: L,
|
|
3304
3387
|
isOutboxRequestActive: a,
|
|
3305
|
-
stopGeneration:
|
|
3306
|
-
disconnectRun:
|
|
3307
|
-
resumeCheckpoint:
|
|
3308
|
-
submitAguiAction:
|
|
3388
|
+
stopGeneration: R,
|
|
3389
|
+
disconnectRun: ne,
|
|
3390
|
+
resumeCheckpoint: z,
|
|
3391
|
+
submitAguiAction: q((e) => {
|
|
3309
3392
|
let t = e.userAction;
|
|
3310
3393
|
if (!t) return !1;
|
|
3311
3394
|
let n = t.context || {}, r = String(n.interruptId || n.interrupt_id || "");
|
|
3312
3395
|
if (!r) return !1;
|
|
3313
3396
|
let i = x.current;
|
|
3314
3397
|
if (!i) return !1;
|
|
3315
|
-
let a =
|
|
3398
|
+
let a = j(i), o = M(i), s = n.status === "cancelled" ? "cancelled" : "resolved", c = Object.prototype.hasOwnProperty.call(n, "payload") ? n.payload : {
|
|
3316
3399
|
action: t.name,
|
|
3317
3400
|
sourceComponentId: t.sourceComponentId,
|
|
3318
3401
|
context: n
|
|
@@ -3323,21 +3406,21 @@ function _n(e) {
|
|
|
3323
3406
|
status: s,
|
|
3324
3407
|
payload: c,
|
|
3325
3408
|
onSettled: (e) => {
|
|
3326
|
-
C?.(e, a.agentId),
|
|
3409
|
+
C?.(e, a.agentId), P(a);
|
|
3327
3410
|
}
|
|
3328
3411
|
});
|
|
3329
3412
|
}, [
|
|
3330
3413
|
x,
|
|
3331
|
-
|
|
3414
|
+
P,
|
|
3415
|
+
M,
|
|
3332
3416
|
j,
|
|
3333
|
-
A,
|
|
3334
3417
|
C
|
|
3335
3418
|
]),
|
|
3336
|
-
respondToAguiApproval:
|
|
3419
|
+
respondToAguiApproval: q((e) => {
|
|
3337
3420
|
if (!e.interruptId) return !1;
|
|
3338
3421
|
let t = x.current;
|
|
3339
3422
|
if (!t) return !1;
|
|
3340
|
-
let n =
|
|
3423
|
+
let n = j(t), r = M(t);
|
|
3341
3424
|
if (r.stage !== "idle") return !1;
|
|
3342
3425
|
m.getState().setSessionStreaming(t, !0);
|
|
3343
3426
|
let i = r.resumeAguiInterrupt({
|
|
@@ -3346,15 +3429,15 @@ function _n(e) {
|
|
|
3346
3429
|
status: e.status || "resolved",
|
|
3347
3430
|
payload: Object.hasOwn(e, "payload") ? e.payload : { decision: e.approve ? "approve" : "reject" },
|
|
3348
3431
|
onSettled: (e) => {
|
|
3349
|
-
C?.(e, n.agentId),
|
|
3432
|
+
C?.(e, n.agentId), P(n);
|
|
3350
3433
|
}
|
|
3351
3434
|
});
|
|
3352
3435
|
return i || m.getState().setSessionStreaming(t, !1), i;
|
|
3353
3436
|
}, [
|
|
3354
3437
|
x,
|
|
3355
|
-
|
|
3438
|
+
P,
|
|
3439
|
+
M,
|
|
3356
3440
|
j,
|
|
3357
|
-
A,
|
|
3358
3441
|
C
|
|
3359
3442
|
]),
|
|
3360
3443
|
resetCompaction: re
|
|
@@ -3362,18 +3445,18 @@ function _n(e) {
|
|
|
3362
3445
|
}
|
|
3363
3446
|
//#endregion
|
|
3364
3447
|
//#region src/utils/history-preparation.ts
|
|
3365
|
-
function
|
|
3366
|
-
return e instanceof
|
|
3448
|
+
function xn(e) {
|
|
3449
|
+
return e instanceof X && e.code === 503 && e.detail?.ReasonCode === "HISTORY_PREPARING";
|
|
3367
3450
|
}
|
|
3368
|
-
async function
|
|
3451
|
+
async function Sn(e, t) {
|
|
3369
3452
|
let n = Date.now();
|
|
3370
3453
|
for (let r = 0;; r += 1) {
|
|
3371
|
-
if (!t.isCurrent() || t.signal?.aborted) throw new
|
|
3454
|
+
if (!t.isCurrent() || t.signal?.aborted) throw new Z();
|
|
3372
3455
|
try {
|
|
3373
3456
|
return await e();
|
|
3374
3457
|
} catch (e) {
|
|
3375
|
-
if (!
|
|
3376
|
-
if (!t.isCurrent() || t.signal?.aborted) throw new
|
|
3458
|
+
if (!xn(e) || r >= 60 || Date.now() - n >= 3e5) throw e;
|
|
3459
|
+
if (!t.isCurrent() || t.signal?.aborted) throw new Z();
|
|
3377
3460
|
t.onPreparing?.(), await new Promise((e) => {
|
|
3378
3461
|
let i = () => {
|
|
3379
3462
|
clearTimeout(a), t.signal?.removeEventListener("abort", i), e();
|
|
@@ -3385,7 +3468,7 @@ async function yn(e, t) {
|
|
|
3385
3468
|
}
|
|
3386
3469
|
//#endregion
|
|
3387
3470
|
//#region src/utils/kernel-run-history.ts
|
|
3388
|
-
async function
|
|
3471
|
+
async function Cn(e, t, n, r, i, a) {
|
|
3389
3472
|
let o = r.Events;
|
|
3390
3473
|
if (o.some((e) => e.EventType === "run.started" && e.InvocationId === n)) return o;
|
|
3391
3474
|
let s = {
|
|
@@ -3427,13 +3510,13 @@ async function bn(e, t, n, r, i, a) {
|
|
|
3427
3510
|
c(r);
|
|
3428
3511
|
let i = r.Events;
|
|
3429
3512
|
if (!i.length || i.some((e) => !Number.isSafeInteger(e.SeqId) || Number(e.SeqId) >= n || Number(e.SeqId) < l)) throw Error("Kernel run history cursor did not advance");
|
|
3430
|
-
o =
|
|
3513
|
+
o = I(o, i);
|
|
3431
3514
|
}
|
|
3432
3515
|
return o;
|
|
3433
3516
|
}
|
|
3434
3517
|
//#endregion
|
|
3435
3518
|
//#region src/utils/interaction-history.ts
|
|
3436
|
-
var
|
|
3519
|
+
var wn = [
|
|
3437
3520
|
"mcp.authorization.requested",
|
|
3438
3521
|
"mcp.authorization.updated",
|
|
3439
3522
|
"interaction.requested",
|
|
@@ -3451,8 +3534,8 @@ var xn = [
|
|
|
3451
3534
|
"interaction.expired",
|
|
3452
3535
|
"approval.resolved",
|
|
3453
3536
|
"a2ui.action"
|
|
3454
|
-
],
|
|
3455
|
-
async function
|
|
3537
|
+
], Tn = 32, En = 2;
|
|
3538
|
+
async function Dn(e, t, n, r, i, a) {
|
|
3456
3539
|
let o = /* @__PURE__ */ new Set(), s = Infinity, c = (e) => {
|
|
3457
3540
|
for (let t of e) {
|
|
3458
3541
|
t.agentBlock && c(t.agentBlock.messages);
|
|
@@ -3482,10 +3565,10 @@ async function wn(e, t, n, r, i, a) {
|
|
|
3482
3565
|
incomplete: !1
|
|
3483
3566
|
};
|
|
3484
3567
|
let d = [], f = Number(r.SnapshotSeqId) + 1;
|
|
3485
|
-
for (let n = 0; n <
|
|
3568
|
+
for (let n = 0; n < En && i() && !a?.aborted; n += 1) {
|
|
3486
3569
|
let n = await e.listSessionEvents(t, {
|
|
3487
|
-
eventTypes:
|
|
3488
|
-
limit:
|
|
3570
|
+
eventTypes: wn,
|
|
3571
|
+
limit: Tn,
|
|
3489
3572
|
afterSeqId: s,
|
|
3490
3573
|
beforeSeqId: f,
|
|
3491
3574
|
cursorSource: r.CursorSource,
|
|
@@ -3515,7 +3598,7 @@ async function wn(e, t, n, r, i, a) {
|
|
|
3515
3598
|
}
|
|
3516
3599
|
//#endregion
|
|
3517
3600
|
//#region src/utils/messages.js
|
|
3518
|
-
var
|
|
3601
|
+
var On = {
|
|
3519
3602
|
running: "running",
|
|
3520
3603
|
completed: "completed",
|
|
3521
3604
|
failed: "error",
|
|
@@ -3526,7 +3609,7 @@ var Tn = {
|
|
|
3526
3609
|
rejected: "completed",
|
|
3527
3610
|
cancelled: "completed",
|
|
3528
3611
|
expired: "completed"
|
|
3529
|
-
},
|
|
3612
|
+
}, kn = {
|
|
3530
3613
|
pending: "pending",
|
|
3531
3614
|
paused: "pending",
|
|
3532
3615
|
approved: "approved",
|
|
@@ -3535,7 +3618,7 @@ var Tn = {
|
|
|
3535
3618
|
cancelled: "cancelled",
|
|
3536
3619
|
expired: "cancelled"
|
|
3537
3620
|
};
|
|
3538
|
-
function
|
|
3621
|
+
function An(e) {
|
|
3539
3622
|
if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
|
|
3540
3623
|
if (typeof e == "string") {
|
|
3541
3624
|
let t = Number(e.trim());
|
|
@@ -3545,7 +3628,7 @@ function Dn(e) {
|
|
|
3545
3628
|
}
|
|
3546
3629
|
return Date.now();
|
|
3547
3630
|
}
|
|
3548
|
-
function
|
|
3631
|
+
function jn(e) {
|
|
3549
3632
|
if (typeof e == "string") return e;
|
|
3550
3633
|
if (e && typeof e == "object") {
|
|
3551
3634
|
if (typeof e.text == "string") return e.text;
|
|
@@ -3553,23 +3636,23 @@ function On(e) {
|
|
|
3553
3636
|
}
|
|
3554
3637
|
return "";
|
|
3555
3638
|
}
|
|
3556
|
-
function
|
|
3639
|
+
function Mn(e) {
|
|
3557
3640
|
let t = {}, n = /* @__PURE__ */ new Map();
|
|
3558
3641
|
for (let t of e ?? []) t?.Name && n.set(t.Name, (n.get(t.Name) || 0) + 1);
|
|
3559
3642
|
for (let r of e ?? []) {
|
|
3560
3643
|
if (!r?.Name) continue;
|
|
3561
|
-
let e =
|
|
3644
|
+
let e = On[String(r.Status ?? "completed").toLowerCase()] ?? "completed", i = {
|
|
3562
3645
|
name: r.Name,
|
|
3563
3646
|
args: r.Args === void 0 ? "" : typeof r.Args == "string" ? r.Args : JSON.stringify(r.Args),
|
|
3564
3647
|
status: e
|
|
3565
3648
|
};
|
|
3566
|
-
r.Result !== void 0 && (i.output = typeof r.Result == "string" ? r.Result : JSON.stringify(r.Result)), r.ApprovalRequestId && (i.approvalRequestId = r.ApprovalRequestId, i.approvalStatus =
|
|
3649
|
+
r.Result !== void 0 && (i.output = typeof r.Result == "string" ? r.Result : JSON.stringify(r.Result)), r.ApprovalRequestId && (i.approvalRequestId = r.ApprovalRequestId, i.approvalStatus = kn[String(r.ApprovalStatus ?? r.Status ?? "paused").toLowerCase()], i.approvalProtocol = String(r.Protocol ?? "").toLowerCase() === "ag-ui" ? "ag-ui" : "responses", r.ApprovalMessage && (i.approvalMessage = String(r.ApprovalMessage)), r.ApprovalLevel && (i.approvalLevel = String(r.ApprovalLevel))), r.ToolCallId && (i.callId = r.ToolCallId, i.previousResponseId = r.ToolCallId);
|
|
3567
3650
|
let a = n.get(r.Name) > 1 && (r.ToolCallId || r.ApprovalRequestId) || r.Name;
|
|
3568
3651
|
t[a] = i;
|
|
3569
3652
|
}
|
|
3570
3653
|
return t;
|
|
3571
3654
|
}
|
|
3572
|
-
function
|
|
3655
|
+
function Nn(e) {
|
|
3573
3656
|
if (Array.isArray(e)) return e.map((e) => ({
|
|
3574
3657
|
name: e.name || "",
|
|
3575
3658
|
url: e.url || "",
|
|
@@ -3577,10 +3660,10 @@ function An(e) {
|
|
|
3577
3660
|
fileUri: e.file_uri
|
|
3578
3661
|
}));
|
|
3579
3662
|
}
|
|
3580
|
-
function
|
|
3663
|
+
function Pn(e) {
|
|
3581
3664
|
return e == null ? "" : typeof e == "string" ? e : JSON.stringify(e);
|
|
3582
3665
|
}
|
|
3583
|
-
function
|
|
3666
|
+
function Fn(e) {
|
|
3584
3667
|
if (!(!Array.isArray(e) || !e.length)) return e.flatMap((e, t) => {
|
|
3585
3668
|
let n = String(e?.Type || "").toLowerCase(), r = e?.SeqId ?? t;
|
|
3586
3669
|
if (n === "thinking" || n === "text") {
|
|
@@ -3593,13 +3676,13 @@ function Mn(e) {
|
|
|
3593
3676
|
}] : [];
|
|
3594
3677
|
}
|
|
3595
3678
|
if (n !== "tool") return [];
|
|
3596
|
-
let i =
|
|
3679
|
+
let i = On[String(e?.Status || "completed").toLowerCase()] ?? "completed";
|
|
3597
3680
|
return [{
|
|
3598
3681
|
id: `history-tool-${r}`,
|
|
3599
3682
|
type: "tool",
|
|
3600
3683
|
toolName: String(e?.Name || "tool"),
|
|
3601
|
-
args:
|
|
3602
|
-
...e?.Result === void 0 ? {} : { output:
|
|
3684
|
+
args: Pn(e?.Args),
|
|
3685
|
+
...e?.Result === void 0 ? {} : { output: Pn(e.Result) },
|
|
3603
3686
|
status: i,
|
|
3604
3687
|
...e?.ToolCallId ? { extra: {
|
|
3605
3688
|
callId: String(e.ToolCallId),
|
|
@@ -3608,12 +3691,12 @@ function Mn(e) {
|
|
|
3608
3691
|
}];
|
|
3609
3692
|
});
|
|
3610
3693
|
}
|
|
3611
|
-
function
|
|
3612
|
-
let t = e.Role === "assistant" ? "model" : e.Role || "user", n = e.ToolEvents?.length ?
|
|
3694
|
+
function In(e) {
|
|
3695
|
+
let t = e.Role === "assistant" ? "model" : e.Role || "user", n = e.ToolEvents?.length ? Mn(e.ToolEvents) : void 0, r = Nn(e.Attachments), i = Fn(e.Blocks), a = e.Reasoning?.length ? e.Reasoning.map((e) => e.text).join("") : void 0, o = {
|
|
3613
3696
|
id: e.MessageId || `msg-${e.SeqId ?? Math.random().toString(36).slice(2)}`,
|
|
3614
3697
|
role: t,
|
|
3615
|
-
content:
|
|
3616
|
-
timestamp:
|
|
3698
|
+
content: jn(e.Content),
|
|
3699
|
+
timestamp: An(e.Timestamp),
|
|
3617
3700
|
...Number.isSafeInteger(e.SeqId) && e.SeqId > 0 ? { historyOrder: {
|
|
3618
3701
|
seq: e.SeqId,
|
|
3619
3702
|
...Number.isSafeInteger(e.StartSeqId) && e.StartSeqId > 0 ? { group: e.StartSeqId } : {}
|
|
@@ -3629,7 +3712,7 @@ function Nn(e) {
|
|
|
3629
3712
|
content: o.content
|
|
3630
3713
|
})), e.MessageId && (o.eventId = e.MessageId), e.InvocationId && (o.invocationId = e.InvocationId), e.ScopeId && (o.scopeId = e.ScopeId), e.ResponseId && (o.responseId = e.ResponseId), e.TraceId && (o.traceId = e.TraceId), e.RootSpanId && (o.rootSpanId = e.RootSpanId), o;
|
|
3631
3714
|
}
|
|
3632
|
-
function
|
|
3715
|
+
function Ln(e) {
|
|
3633
3716
|
return Array.isArray(e.Activities) ? e.Activities.flatMap((t, n) => {
|
|
3634
3717
|
let r = String(t?.SurfaceId || "");
|
|
3635
3718
|
if (!r) return [];
|
|
@@ -3643,7 +3726,7 @@ function Pn(e) {
|
|
|
3643
3726
|
id: o && o !== String(e.MessageId || "") ? o : `${o || e.MessageId || e.SeqId || "message"}:a2ui:${r}:${n}`,
|
|
3644
3727
|
role: "a2ui",
|
|
3645
3728
|
content: "",
|
|
3646
|
-
timestamp:
|
|
3729
|
+
timestamp: An(e.Timestamp),
|
|
3647
3730
|
...e.InvocationId ? { invocationId: String(e.InvocationId) } : {},
|
|
3648
3731
|
...Number.isSafeInteger(e.SeqId) && e.SeqId > 0 ? { historyOrder: {
|
|
3649
3732
|
seq: e.SeqId,
|
|
@@ -3658,12 +3741,12 @@ function Pn(e) {
|
|
|
3658
3741
|
}];
|
|
3659
3742
|
}) : [];
|
|
3660
3743
|
}
|
|
3661
|
-
function
|
|
3662
|
-
return ze(Be(e.map(
|
|
3744
|
+
function Rn(e) {
|
|
3745
|
+
return ze(Be(e.map(In)).flatMap((t, n) => [t, ...Ln(e[n])]));
|
|
3663
3746
|
}
|
|
3664
3747
|
//#endregion
|
|
3665
3748
|
//#region src/utils/history-content.ts
|
|
3666
|
-
function
|
|
3749
|
+
function zn(e, t) {
|
|
3667
3750
|
return t.throwIfAborted(), new Promise((n, r) => {
|
|
3668
3751
|
let i = () => {
|
|
3669
3752
|
clearTimeout(a), r(t.reason);
|
|
@@ -3673,7 +3756,7 @@ function In(e, t) {
|
|
|
3673
3756
|
t.addEventListener("abort", i, { once: !0 });
|
|
3674
3757
|
});
|
|
3675
3758
|
}
|
|
3676
|
-
async function
|
|
3759
|
+
async function Bn(e, t, n, r, i, a = {}, o) {
|
|
3677
3760
|
let s = JSON.stringify([
|
|
3678
3761
|
t,
|
|
3679
3762
|
r.HistoryEpoch,
|
|
@@ -3706,14 +3789,14 @@ async function Ln(e, t, n, r, i, a = {}, o) {
|
|
|
3706
3789
|
signal: i
|
|
3707
3790
|
});
|
|
3708
3791
|
} catch (e) {
|
|
3709
|
-
if (e instanceof
|
|
3792
|
+
if (e instanceof X && e.code === 429 && s < 3) {
|
|
3710
3793
|
let t = e.retryAfterMs ?? 500 * 2 ** s;
|
|
3711
3794
|
if (t <= 8e3) {
|
|
3712
|
-
s++, await
|
|
3795
|
+
s++, await zn(t, i);
|
|
3713
3796
|
continue;
|
|
3714
3797
|
}
|
|
3715
3798
|
}
|
|
3716
|
-
throw e instanceof
|
|
3799
|
+
throw e instanceof X && [
|
|
3717
3800
|
400,
|
|
3718
3801
|
401,
|
|
3719
3802
|
403,
|
|
@@ -3734,7 +3817,7 @@ async function Ln(e, t, n, r, i, a = {}, o) {
|
|
|
3734
3817
|
}
|
|
3735
3818
|
//#endregion
|
|
3736
3819
|
//#region src/utils/session-items.ts
|
|
3737
|
-
function
|
|
3820
|
+
function Vn(e, t, n) {
|
|
3738
3821
|
if (e.HistoryView !== "items-v1" || !Array.isArray(e.Items) || !e.HistoryEpoch || !Number.isSafeInteger(e.SnapshotSeqId) || e.HasMore !== !!e.NextItemCursor || e.HasMore && (!e.Items.length || e.NextItemCursor === n)) throw Error("会话条目分页响应无效,请重新打开会话。");
|
|
3739
3822
|
let r = 0;
|
|
3740
3823
|
for (let n of e.Items) {
|
|
@@ -3743,21 +3826,21 @@ function Rn(e, t, n) {
|
|
|
3743
3826
|
}
|
|
3744
3827
|
return e.Items;
|
|
3745
3828
|
}
|
|
3746
|
-
async function
|
|
3747
|
-
let o = await
|
|
3829
|
+
async function Hn(e, t, n, r, i, a) {
|
|
3830
|
+
let o = await Bn(e, t, n, r, i, a);
|
|
3748
3831
|
if (!Array.isArray(o) || o.length !== 2 || !o[0] || typeof o[0] != "object") throw Error("历史正文格式无效。");
|
|
3749
3832
|
return {
|
|
3750
3833
|
Content: o[0],
|
|
3751
3834
|
Metadata: o[1]
|
|
3752
3835
|
};
|
|
3753
3836
|
}
|
|
3754
|
-
function
|
|
3837
|
+
function Un(e) {
|
|
3755
3838
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
3756
3839
|
for (let r of e) {
|
|
3757
3840
|
if (Ie(r)) continue;
|
|
3758
3841
|
let e = r.Content, i = e?.parts?.map((e) => e.text || "").join("") || e?.text || e?.payload?.text || "", a = r.InvocationId || r.EventId, o = r.EventType;
|
|
3759
3842
|
if (o === "run.started" && r.Metadata?.ksadk_runtime_event && e?.payload?.source === "ag-ui") {
|
|
3760
|
-
let n =
|
|
3843
|
+
let n = qn(e.payload.input);
|
|
3761
3844
|
n && t.push({
|
|
3762
3845
|
...r,
|
|
3763
3846
|
EventId: "input:" + r.EventId,
|
|
@@ -3800,16 +3883,16 @@ function Bn(e) {
|
|
|
3800
3883
|
});
|
|
3801
3884
|
return t;
|
|
3802
3885
|
}
|
|
3803
|
-
function
|
|
3886
|
+
function Q(e) {
|
|
3804
3887
|
return e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
3805
3888
|
}
|
|
3806
|
-
function
|
|
3889
|
+
function Wn(e) {
|
|
3807
3890
|
let t = /* @__PURE__ */ new Map();
|
|
3808
3891
|
for (let n of e) {
|
|
3809
3892
|
if (n.EventType !== "approval_response") continue;
|
|
3810
|
-
let e =
|
|
3893
|
+
let e = Q(n.Metadata?.resume_input), r = e.approval_request_id || e.interrupt_id || e.id;
|
|
3811
3894
|
if (!r) continue;
|
|
3812
|
-
let i =
|
|
3895
|
+
let i = Q(e.value).decisions, a = Array.isArray(i) && Q(i[0]).type, o = [
|
|
3813
3896
|
"cancelled",
|
|
3814
3897
|
"expired",
|
|
3815
3898
|
"submitted"
|
|
@@ -3817,8 +3900,8 @@ function Vn(e) {
|
|
|
3817
3900
|
t.set(String(r), o === "submitted" ? "completed" : o);
|
|
3818
3901
|
}
|
|
3819
3902
|
return e.filter((e) => e.EventType === "approval_request").map((e) => {
|
|
3820
|
-
let n =
|
|
3821
|
-
return
|
|
3903
|
+
let n = Q(e.Metadata?.interrupt_info), r = Array.isArray(n.action_requests) ? Q(n.action_requests[0]) : {}, i = String(n.approval_request_id || n.id || "");
|
|
3904
|
+
return In({
|
|
3822
3905
|
MessageId: e.EventId,
|
|
3823
3906
|
Role: "assistant",
|
|
3824
3907
|
SeqId: e.SeqId,
|
|
@@ -3836,12 +3919,12 @@ function Vn(e) {
|
|
|
3836
3919
|
});
|
|
3837
3920
|
});
|
|
3838
3921
|
}
|
|
3839
|
-
function
|
|
3922
|
+
function Gn(e) {
|
|
3840
3923
|
let t = [];
|
|
3841
3924
|
function n(e) {
|
|
3842
|
-
let r =
|
|
3925
|
+
let r = Q(e), i = String(r.id || r.component_id || ""), a = String(r.component || r.type || "");
|
|
3843
3926
|
if (!i || !a) return "";
|
|
3844
|
-
let o =
|
|
3927
|
+
let o = Q(r.props), s = Array.isArray(r.children) ? r.children.map(n).filter(Boolean) : [];
|
|
3845
3928
|
return t.push({
|
|
3846
3929
|
id: i,
|
|
3847
3930
|
component: a,
|
|
@@ -3851,12 +3934,12 @@ function Hn(e) {
|
|
|
3851
3934
|
}
|
|
3852
3935
|
return Array.isArray(e) && e.forEach(n), t;
|
|
3853
3936
|
}
|
|
3854
|
-
function
|
|
3855
|
-
return
|
|
3937
|
+
function Kn(e) {
|
|
3938
|
+
return Rn(e.flatMap((e) => {
|
|
3856
3939
|
if (!e.EventType?.startsWith("a2ui.surface.")) return [];
|
|
3857
|
-
let t =
|
|
3940
|
+
let t = Q(e.Content), n = Object.keys(Q(t.payload)).length ? Q(t.payload) : t, r = String(n.surfaceId || n.surface_id || "");
|
|
3858
3941
|
if (!r) return [];
|
|
3859
|
-
let i = n.operations || n.a2ui_operations, a = n.surface ?
|
|
3942
|
+
let i = n.operations || n.a2ui_operations, a = n.surface ? Q(n.surface) : n, o = Gn(a.components), s = a.data_model ?? a.dataModel, c = Array.isArray(i) ? i : e.EventType === "a2ui.surface.end" ? [{
|
|
3860
3943
|
version: "v0.9",
|
|
3861
3944
|
deleteSurface: { surfaceId: r }
|
|
3862
3945
|
}] : [
|
|
@@ -3899,13 +3982,13 @@ function Un(e) {
|
|
|
3899
3982
|
}] : [];
|
|
3900
3983
|
})).filter((e) => e.role === "a2ui");
|
|
3901
3984
|
}
|
|
3902
|
-
function
|
|
3985
|
+
function qn(e) {
|
|
3903
3986
|
if (typeof e == "string") return e;
|
|
3904
|
-
if (Array.isArray(e)) return e.map(
|
|
3905
|
-
let t =
|
|
3906
|
-
return n === void 0 ? "" :
|
|
3987
|
+
if (Array.isArray(e)) return e.map(qn).join("");
|
|
3988
|
+
let t = Q(e), n = t.text ?? t.content ?? t.parts;
|
|
3989
|
+
return n === void 0 ? "" : qn(n);
|
|
3907
3990
|
}
|
|
3908
|
-
var
|
|
3991
|
+
var Jn = new Set([
|
|
3909
3992
|
"user_message",
|
|
3910
3993
|
"assistant_message",
|
|
3911
3994
|
"assistant_stream_snapshot",
|
|
@@ -3932,9 +4015,9 @@ var Wn = new Set([
|
|
|
3932
4015
|
"run.failed",
|
|
3933
4016
|
"run.canceled"
|
|
3934
4017
|
]);
|
|
3935
|
-
function
|
|
4018
|
+
function Yn(e, t, n, r, i, a) {
|
|
3936
4019
|
let o = async (i, a) => {
|
|
3937
|
-
let o = await
|
|
4020
|
+
let o = await Hn(t, n, e.SeqId, r, i, a), s = Q(o.Content?.session_event), c = s.family === "workflow" && Q(Q(s.payload).legacy_history_event);
|
|
3938
4021
|
return c && c.EventType ? {
|
|
3939
4022
|
...c,
|
|
3940
4023
|
SessionId: n,
|
|
@@ -3958,11 +4041,11 @@ function Gn(e, t, n, r, i, a) {
|
|
|
3958
4041
|
}, l = e.ToolRef;
|
|
3959
4042
|
if (l?.CallId && (l.Kind === "call" || l.Kind === "result")) {
|
|
3960
4043
|
let e = l.Kind === "result", t = async (t, r) => {
|
|
3961
|
-
let i = await o(t, r), a = Ie(i), s = a && new Pe(n).translate(a), c =
|
|
4044
|
+
let i = await o(t, r), a = Ie(i), s = a && new Pe(n).translate(a), c = R(s ? [{
|
|
3962
4045
|
...s,
|
|
3963
4046
|
Timestamp: i.Timestamp,
|
|
3964
4047
|
SeqId: i.SeqId
|
|
3965
|
-
}] :
|
|
4048
|
+
}] : Un([i]), { preserveDistinctEvents: !0 }).flatMap((e) => Object.values(e.tools || {})).find((e) => e.callId === l.CallId), u = e ? c?.output : c?.args;
|
|
3966
4049
|
if (u === void 0) throw Error("历史工具正文与调用标识不一致。");
|
|
3967
4050
|
return u;
|
|
3968
4051
|
}, r = l.ScopeId;
|
|
@@ -3997,7 +4080,7 @@ function Gn(e, t, n, r, i, a) {
|
|
|
3997
4080
|
content: e.EventType,
|
|
3998
4081
|
readHistoryContent: async (e, t) => {
|
|
3999
4082
|
let r = await o(e, t);
|
|
4000
|
-
return je(
|
|
4083
|
+
return je(R(Un([r])), [r], n, i).messages.flatMap((e) => [
|
|
4001
4084
|
e.content,
|
|
4002
4085
|
e.reasoning,
|
|
4003
4086
|
...Object.values(e.tools || {}).map((e) => JSON.stringify(e, null, 2))
|
|
@@ -4005,21 +4088,25 @@ function Gn(e, t, n, r, i, a) {
|
|
|
4005
4088
|
}
|
|
4006
4089
|
};
|
|
4007
4090
|
}
|
|
4008
|
-
function
|
|
4091
|
+
function Xn(e, t, n, r, i, a) {
|
|
4009
4092
|
let o = e.filter((e) => !e.ContentRef).map((e) => e.Event), s = new Set(e.filter((e) => {
|
|
4010
4093
|
if (!e.InputCommandId || e.InboxInput) return !1;
|
|
4011
|
-
let t = Ie(e.Event), n =
|
|
4012
|
-
return e.EventType === "user_message" || t?.event_type === "item.completed" && (n.native_item_kind === "userMessage" || Array.isArray(r) && r.some((e) =>
|
|
4094
|
+
let t = Ie(e.Event), n = Q(Q(t?.source).metadata), r = Q(t?.snapshot).parts;
|
|
4095
|
+
return e.EventType === "user_message" || t?.event_type === "item.completed" && (n.native_item_kind === "userMessage" || Array.isArray(r) && r.some((e) => Q(Q(e).data).type === "userMessage"));
|
|
4013
4096
|
}).map((e) => e.InputCommandId).filter(Boolean)), c = e.filter((e) => e.InboxInput && !s.has(e.InboxInput.CommandId)), l = c.flatMap((e) => e.InboxInput?.Text === void 0 ? [] : [{
|
|
4014
4097
|
...e.Event,
|
|
4015
4098
|
EventId: "inbox:" + e.InboxInput.CommandId,
|
|
4016
4099
|
EventType: "user_message",
|
|
4017
|
-
Content: { parts: [{ text: e.InboxInput.Text }] }
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
],
|
|
4100
|
+
Content: { parts: [{ text: e.InboxInput.Text }] },
|
|
4101
|
+
Metadata: {
|
|
4102
|
+
...e.Event.Metadata,
|
|
4103
|
+
runtime_metadata: { command_id: e.InboxInput.CommandId }
|
|
4104
|
+
}
|
|
4105
|
+
}]), u = Un([...o, ...l].sort((e, t) => Number(e.SeqId) - Number(t.SeqId))), d = je([
|
|
4106
|
+
...R(u, { preserveDistinctEvents: !0 }),
|
|
4107
|
+
...Wn(u),
|
|
4108
|
+
...Kn(u)
|
|
4109
|
+
], o, n, i, a), f = e.filter((e) => e.ContentRef).map((e) => Yn(e, t, n, r, i, d.messages));
|
|
4023
4110
|
for (let e of c) {
|
|
4024
4111
|
let i = e.InboxInput;
|
|
4025
4112
|
i.ContentRef && f.push({
|
|
@@ -4037,12 +4124,13 @@ function Kn(e, t, n, r, i, a) {
|
|
|
4037
4124
|
"inbox"
|
|
4038
4125
|
]),
|
|
4039
4126
|
invocationId: e.InvocationId,
|
|
4040
|
-
|
|
4127
|
+
commandId: i.CommandId,
|
|
4128
|
+
readHistoryContent: async (i, a) => qn(await Bn(t, n, e.SeqId, r, i, a, "inbox"))
|
|
4041
4129
|
});
|
|
4042
4130
|
}
|
|
4043
4131
|
let p = /* @__PURE__ */ new Map();
|
|
4044
4132
|
for (let e of u) {
|
|
4045
|
-
if (!e.EventType ||
|
|
4133
|
+
if (!e.EventType || Jn.has(e.EventType) || e.Content?.session_event) continue;
|
|
4046
4134
|
let t = e.InvocationId || "", n = p.get(t);
|
|
4047
4135
|
n ? n.push(e) : p.set(t, [e]);
|
|
4048
4136
|
}
|
|
@@ -4054,7 +4142,7 @@ function Kn(e, t, n, r, i, a) {
|
|
|
4054
4142
|
historyOrder: { seq: t[0].SeqId },
|
|
4055
4143
|
invocationId: e,
|
|
4056
4144
|
readHistoryContent: async () => t.map((e) => {
|
|
4057
|
-
let t = e.EventType === "progress" ?
|
|
4145
|
+
let t = e.EventType === "progress" ? qn(e.Content?.parts) : "";
|
|
4058
4146
|
return [
|
|
4059
4147
|
e.SeqId,
|
|
4060
4148
|
e.EventType,
|
|
@@ -4067,7 +4155,7 @@ function Kn(e, t, n, r, i, a) {
|
|
|
4067
4155
|
messages: f.length ? Be(be([...d.messages, ...f])) : d.messages
|
|
4068
4156
|
};
|
|
4069
4157
|
}
|
|
4070
|
-
function
|
|
4158
|
+
function Zn(e) {
|
|
4071
4159
|
if (!e.InvocationId || e.InvocationId !== e.Event.InvocationId || e.ContentRef || e.InboxInput || e.InputCommandId || ![
|
|
4072
4160
|
"assistant_stream_delta",
|
|
4073
4161
|
"text.delta",
|
|
@@ -4076,21 +4164,21 @@ function qn(e) {
|
|
|
4076
4164
|
let t = e.Event.Content;
|
|
4077
4165
|
return t?.parts?.map((e) => e.text || "").join("") || t?.text || t?.payload?.text || "";
|
|
4078
4166
|
}
|
|
4079
|
-
var
|
|
4167
|
+
var Qn = new Set([
|
|
4080
4168
|
"user_message",
|
|
4081
4169
|
"assistant_message",
|
|
4082
4170
|
"tool_call",
|
|
4083
4171
|
"tool_result"
|
|
4084
4172
|
]);
|
|
4085
|
-
function
|
|
4173
|
+
function $n(e) {
|
|
4086
4174
|
let t = e.Event;
|
|
4087
|
-
return
|
|
4175
|
+
return Qn.has(e.EventType) && e.EventType === t.EventType && !!(t.EventId?.trim() && e.InvocationId && e.InvocationId === t.InvocationId?.trim()) && Number.isSafeInteger(e.SeqId) && e.SeqId > 0 && e.SeqId === t.SeqId && !e.ContentRef && !e.InboxInput && !e.InputCommandId && !t.Metadata?.RuntimeItem && !t.Metadata?.responses_mirror && Object.keys(t.Content || {}).every((e) => [
|
|
4088
4176
|
"role",
|
|
4089
4177
|
"parts",
|
|
4090
4178
|
"text"
|
|
4091
4179
|
].includes(e));
|
|
4092
4180
|
}
|
|
4093
|
-
function
|
|
4181
|
+
function er(e, t) {
|
|
4094
4182
|
if (!t || t >= e.length || e[t - 1].SeqId >= e[t].SeqId) return e.length;
|
|
4095
4183
|
let n = new Set(e.slice(0, t).map((e) => e.InvocationId)), r = t;
|
|
4096
4184
|
for (; r < e.length && n.has(e[r].InvocationId);) r++;
|
|
@@ -4098,9 +4186,9 @@ function Xn(e, t) {
|
|
|
4098
4186
|
for (let t = r; t < e.length; t++) if (n.has(e[t].InvocationId) || i.has(e[t].Event.EventId.trim())) return e.length;
|
|
4099
4187
|
return r;
|
|
4100
4188
|
}
|
|
4101
|
-
function
|
|
4189
|
+
function tr(e, t, n, r, i, a) {
|
|
4102
4190
|
let o = new Map(a?.progress), s = /* @__PURE__ */ new Map(), c = [], l = (e) => {
|
|
4103
|
-
let t = c.at(-1), n =
|
|
4191
|
+
let t = c.at(-1), n = Zn(e), r = t && n !== void 0 && t.InvocationId === e.InvocationId ? Zn(t) : void 0;
|
|
4104
4192
|
r === void 0 ? c.push(e) : c[c.length - 1] = {
|
|
4105
4193
|
...e,
|
|
4106
4194
|
Event: {
|
|
@@ -4121,17 +4209,17 @@ function Zn(e, t, n, r, i, a) {
|
|
|
4121
4209
|
newer: n
|
|
4122
4210
|
});
|
|
4123
4211
|
}
|
|
4124
|
-
let u = (a?.hasOnlyPlainChatItems ?? !0) && c.every((e, t) =>
|
|
4212
|
+
let u = (a?.hasOnlyPlainChatItems ?? !0) && c.every((e, t) => $n(e) && (!t || c[t - 1].SeqId < e.SeqId)), d = c.length, f = a?.semanticItems || [], p = f, m = a?.semantic, h = e[0]?.SeqId ?? a?.firstSeq;
|
|
4125
4213
|
if (c.length || !m || h === 1 && a?.firstSeq !== 1) {
|
|
4126
4214
|
f.length && l(f[0]), p = c.concat(f.slice(1));
|
|
4127
|
-
let e = u && a ?
|
|
4215
|
+
let e = u && a ? er(p, d) : p.length;
|
|
4128
4216
|
if (a && e < p.length) {
|
|
4129
|
-
let o =
|
|
4217
|
+
let o = Xn(p.slice(0, e), t, n, r, i, h), s = p[e].SeqId, c = a.semantic.messages.filter((e) => e.historyOrder.seq >= s);
|
|
4130
4218
|
m = {
|
|
4131
4219
|
...o,
|
|
4132
4220
|
messages: o.messages.concat(c)
|
|
4133
4221
|
};
|
|
4134
|
-
} else m =
|
|
4222
|
+
} else m = Xn(p, t, n, r, i, h);
|
|
4135
4223
|
}
|
|
4136
4224
|
let g = [];
|
|
4137
4225
|
for (let [e, t] of o) {
|
|
@@ -4146,7 +4234,7 @@ function Zn(e, t, n, r, i, a) {
|
|
|
4146
4234
|
readHistoryContent: async () => {
|
|
4147
4235
|
let e = [];
|
|
4148
4236
|
for (let n = t; n; n = n.newer) for (let t of n.events) {
|
|
4149
|
-
let n =
|
|
4237
|
+
let n = qn(t.Content?.parts) || qn(t.Content) || qn(t.Content?.payload);
|
|
4150
4238
|
e.push([
|
|
4151
4239
|
t.SeqId,
|
|
4152
4240
|
t.EventType,
|
|
@@ -4167,7 +4255,7 @@ function Zn(e, t, n, r, i, a) {
|
|
|
4167
4255
|
messages: g.length ? be([...m.messages, ...g]) : m.messages
|
|
4168
4256
|
};
|
|
4169
4257
|
}
|
|
4170
|
-
async function
|
|
4258
|
+
async function nr(e, t, n, r, i, a) {
|
|
4171
4259
|
let o, s = n, c;
|
|
4172
4260
|
do {
|
|
4173
4261
|
i.throwIfAborted();
|
|
@@ -4181,11 +4269,11 @@ async function Qn(e, t, n, r, i, a) {
|
|
|
4181
4269
|
});
|
|
4182
4270
|
if (l.HistoryEpoch !== r || c !== void 0 && l.SnapshotSeqId !== c) throw Error("接续历史来源已变化。");
|
|
4183
4271
|
c = l.SnapshotSeqId;
|
|
4184
|
-
for (let n of
|
|
4272
|
+
for (let n of Vn(l, t, o)) {
|
|
4185
4273
|
if (n.SeqId <= s) throw Error("接续历史条目未前进。");
|
|
4186
4274
|
let r = n.ContentRef ? {
|
|
4187
4275
|
...n.Event,
|
|
4188
|
-
...await
|
|
4276
|
+
...await Hn(e, t, n.SeqId, l, i)
|
|
4189
4277
|
} : n.Event;
|
|
4190
4278
|
i.throwIfAborted(), a(r), s = n.SeqId;
|
|
4191
4279
|
}
|
|
@@ -4195,23 +4283,23 @@ async function Qn(e, t, n, r, i, a) {
|
|
|
4195
4283
|
}
|
|
4196
4284
|
//#endregion
|
|
4197
4285
|
//#region src/utils/session-event-history.ts
|
|
4198
|
-
async function
|
|
4286
|
+
async function rr(e, t, n, r, i, a = !1) {
|
|
4199
4287
|
if (n.CursorSource !== "runtime") return;
|
|
4200
|
-
let
|
|
4201
|
-
if (
|
|
4202
|
-
let
|
|
4288
|
+
let o = r?.events.filter((e) => e.EventType === "run_status").sort((e, t) => Number(t.SeqId) - Number(e.SeqId))[0];
|
|
4289
|
+
if (o || r && !r.hasMore && r.loadedCount >= r.total) return o;
|
|
4290
|
+
let s = n.HistoryEpochSource === "server-event-anchor", c = await e.listSessionEvents(t, {
|
|
4203
4291
|
eventTypes: ["run_status"],
|
|
4204
4292
|
limit: 1,
|
|
4205
4293
|
cursorSource: n.CursorSource,
|
|
4206
|
-
...
|
|
4294
|
+
...s ? { beforeSeqId: (n.SnapshotSeqId ?? 0) + 1 } : a ? {} : {
|
|
4207
4295
|
historyEpoch: n.HistoryEpoch,
|
|
4208
4296
|
snapshotSeqId: n.SnapshotSeqId
|
|
4209
4297
|
},
|
|
4210
4298
|
signal: i
|
|
4211
4299
|
});
|
|
4212
|
-
if (
|
|
4213
|
-
let r =
|
|
4214
|
-
if (
|
|
4300
|
+
if (s) {
|
|
4301
|
+
let r = c.Events[0]?.SeqId;
|
|
4302
|
+
if (c.CursorSource !== "runtime" || !r || !n.SnapshotSeqId || r > n.SnapshotSeqId) return;
|
|
4215
4303
|
let a = await e.listSessionMessages(t, {
|
|
4216
4304
|
historyView: "items-v1",
|
|
4217
4305
|
afterSeqId: r - 1,
|
|
@@ -4222,18 +4310,21 @@ async function $n(e, t, n, r, i) {
|
|
|
4222
4310
|
}), o = a.Items?.[0]?.Event;
|
|
4223
4311
|
return a.HistoryView === "items-v1" && a.CursorSource === n.CursorSource && a.HistoryEpoch === n.HistoryEpoch && a.SnapshotSeqId === n.SnapshotSeqId && o?.SessionId === t && o.SeqId === r && o.EventType === "run_status" ? o : void 0;
|
|
4224
4312
|
}
|
|
4225
|
-
if (
|
|
4313
|
+
if (c.CursorSource === n.CursorSource && c.HistoryEpoch === n.HistoryEpoch && (a ? typeof c.SnapshotSeqId == "number" && c.SnapshotSeqId >= (n.SnapshotSeqId ?? 0) : c.SnapshotSeqId === n.SnapshotSeqId)) {
|
|
4314
|
+
let e = c.Events[0];
|
|
4315
|
+
if (e?.EventType === "run_status" && (e.SessionId === t || !a && !e.SessionId)) return e;
|
|
4316
|
+
}
|
|
4226
4317
|
}
|
|
4227
|
-
var
|
|
4318
|
+
var ir = class extends Error {
|
|
4228
4319
|
seq;
|
|
4229
4320
|
constructor(e) {
|
|
4230
4321
|
super(`Session event seq ${e} was received twice with conflicting content`), this.name = "SessionEventConflictError", this.seq = e;
|
|
4231
4322
|
}
|
|
4232
4323
|
};
|
|
4233
|
-
function
|
|
4234
|
-
return Array.isArray(e) ? `[${e.map(
|
|
4324
|
+
function ar(e) {
|
|
4325
|
+
return Array.isArray(e) ? `[${e.map(ar).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${JSON.stringify(e)}:${ar(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
|
|
4235
4326
|
}
|
|
4236
|
-
var
|
|
4327
|
+
var or = new Set(["runtime"]), sr = class {
|
|
4237
4328
|
eventsBySeq = /* @__PURE__ */ new Map();
|
|
4238
4329
|
lastSeqValue = 0;
|
|
4239
4330
|
accept(e) {
|
|
@@ -4241,7 +4332,7 @@ var nr = new Set(["runtime"]), rr = class {
|
|
|
4241
4332
|
if (!t.ok) throw t.error;
|
|
4242
4333
|
let n = t.value, r = this.eventsBySeq.get(n.seq);
|
|
4243
4334
|
if (r) {
|
|
4244
|
-
if (
|
|
4335
|
+
if (ar(r) !== ar(n)) throw new ir(n.seq);
|
|
4245
4336
|
return;
|
|
4246
4337
|
}
|
|
4247
4338
|
this.eventsBySeq.set(n.seq, n), this.lastSeqValue = Math.max(this.lastSeqValue, n.seq);
|
|
@@ -4253,41 +4344,79 @@ var nr = new Set(["runtime"]), rr = class {
|
|
|
4253
4344
|
return this.lastSeqValue;
|
|
4254
4345
|
}
|
|
4255
4346
|
displayableEvents() {
|
|
4256
|
-
return [...this.eventsBySeq.values()].filter((e) =>
|
|
4347
|
+
return [...this.eventsBySeq.values()].filter((e) => or.has(e.family)).sort((e, t) => e.seq - t.seq);
|
|
4257
4348
|
}
|
|
4258
4349
|
};
|
|
4259
|
-
function
|
|
4260
|
-
return new
|
|
4350
|
+
function cr() {
|
|
4351
|
+
return new sr();
|
|
4261
4352
|
}
|
|
4262
4353
|
//#endregion
|
|
4263
4354
|
//#region src/hooks/useSessionLifecycle.ts
|
|
4264
|
-
var
|
|
4265
|
-
function
|
|
4355
|
+
var lr = 500, ur = 30, dr = 50, fr = 100, pr = 200, mr = 3, hr = 64, gr = 8, _r = 128, vr = 1800 * 1e3;
|
|
4356
|
+
function yr(e, t) {
|
|
4266
4357
|
return !(e.CursorSource !== t.CursorSource || e.HistoryEpoch !== t.HistoryEpoch || e.SnapshotSeqId !== void 0 && t.SnapshotSeqId !== void 0 && e.SnapshotSeqId !== t.SnapshotSeqId || !e.CursorSource && (e.CursorCompatibleWithRuntime === !1 || t.CursorCompatibleWithRuntime === !1));
|
|
4267
4358
|
}
|
|
4268
|
-
function
|
|
4359
|
+
function br(e) {
|
|
4269
4360
|
return {
|
|
4270
4361
|
CursorSource: e.cursorSource,
|
|
4271
4362
|
HistoryEpoch: e.historyEpoch,
|
|
4272
4363
|
SnapshotSeqId: e.snapshotSeqId
|
|
4273
4364
|
};
|
|
4274
4365
|
}
|
|
4275
|
-
function
|
|
4276
|
-
if (!(e instanceof
|
|
4366
|
+
function xr(e) {
|
|
4367
|
+
if (!(e instanceof X) || !e.detail || typeof e.detail != "object") return;
|
|
4277
4368
|
let t = e.detail;
|
|
4278
4369
|
return typeof t.ReasonCode == "string" ? t.ReasonCode : void 0;
|
|
4279
4370
|
}
|
|
4280
|
-
function
|
|
4281
|
-
return e instanceof
|
|
4371
|
+
function Sr(e) {
|
|
4372
|
+
return e instanceof X && e.code === 409 && xr(e) === "HISTORY_RELOAD_REQUIRED";
|
|
4282
4373
|
}
|
|
4283
|
-
function
|
|
4284
|
-
return new
|
|
4374
|
+
function Cr() {
|
|
4375
|
+
return new X(409, "历史来源已变化", {
|
|
4285
4376
|
Code: 409,
|
|
4286
4377
|
ReasonCode: "HISTORY_RELOAD_REQUIRED",
|
|
4287
4378
|
Data: null
|
|
4288
4379
|
});
|
|
4289
4380
|
}
|
|
4290
|
-
function
|
|
4381
|
+
function wr(e, t) {
|
|
4382
|
+
return {
|
|
4383
|
+
signal: t,
|
|
4384
|
+
historyView: e.historyView ?? (e.cursorSource === "runtime" && e.historyEpoch && e.snapshotSeqId !== void 0 ? "items-v1" : void 0),
|
|
4385
|
+
itemCursor: e.nextItemCursor ?? void 0,
|
|
4386
|
+
beforeSeqId: e.nextCursor ?? void 0,
|
|
4387
|
+
cursorSource: e.cursorSource,
|
|
4388
|
+
historyEpoch: e.historyEpoch,
|
|
4389
|
+
snapshotSeqId: e.snapshotSeqId,
|
|
4390
|
+
limit: e.historyView === "items-v1" ? pr : dr,
|
|
4391
|
+
includeReasoning: !0,
|
|
4392
|
+
includeToolEvents: !0,
|
|
4393
|
+
includeAttachments: !0
|
|
4394
|
+
};
|
|
4395
|
+
}
|
|
4396
|
+
async function Tr(e, t, n, r, i, a, o) {
|
|
4397
|
+
let s = new Set(r.messages.map((e) => e.id)), c = n.itemCursor, l = o, u = r.firstSeq, d = r, f = [], p = new Set([c]);
|
|
4398
|
+
for (let r = 1;; r++) {
|
|
4399
|
+
if (!yr({
|
|
4400
|
+
CursorSource: n.cursorSource,
|
|
4401
|
+
HistoryEpoch: n.historyEpoch,
|
|
4402
|
+
SnapshotSeqId: n.snapshotSeqId
|
|
4403
|
+
}, l) || l.HistoryView !== "items-v1") throw Cr();
|
|
4404
|
+
let o = Vn(l, t, c);
|
|
4405
|
+
if (o.length && u != null && o.at(-1).SeqId >= u) throw Cr();
|
|
4406
|
+
if (u = o[0]?.SeqId ?? u, f = o.concat(f), d = tr(o, e, t, l, i, d), !l.HasMore || r >= mr || d.messages.some((e) => e.role !== "system" && !s.has(e.id))) return {
|
|
4407
|
+
page: l,
|
|
4408
|
+
items: f,
|
|
4409
|
+
projection: d
|
|
4410
|
+
};
|
|
4411
|
+
if (c = l.NextItemCursor, p.has(c)) throw Cr();
|
|
4412
|
+
p.add(c), l = await a({
|
|
4413
|
+
...n,
|
|
4414
|
+
itemCursor: c,
|
|
4415
|
+
beforeSeqId: void 0
|
|
4416
|
+
});
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
function Er(e) {
|
|
4291
4420
|
return {
|
|
4292
4421
|
historyView: e.HistoryView,
|
|
4293
4422
|
nextItemCursor: e.NextItemCursor,
|
|
@@ -4305,37 +4434,37 @@ function _r(e) {
|
|
|
4305
4434
|
preparing: !1
|
|
4306
4435
|
};
|
|
4307
4436
|
}
|
|
4308
|
-
function $(e, t, n, r, i =
|
|
4437
|
+
function $(e, t, n, r, i = _r) {
|
|
4309
4438
|
for (e.delete(t), e.set(t, n); e.size > i;) {
|
|
4310
4439
|
let t = [...e.keys()].find((e) => e !== r);
|
|
4311
4440
|
if (!t) break;
|
|
4312
4441
|
e.delete(t);
|
|
4313
4442
|
}
|
|
4314
4443
|
}
|
|
4315
|
-
function
|
|
4444
|
+
function Dr(e) {
|
|
4316
4445
|
return new Promise((t) => {
|
|
4317
4446
|
if (e.aborted) {
|
|
4318
4447
|
t();
|
|
4319
4448
|
return;
|
|
4320
4449
|
}
|
|
4321
|
-
let n = globalThis.setTimeout(t,
|
|
4450
|
+
let n = globalThis.setTimeout(t, lr);
|
|
4322
4451
|
e.addEventListener("abort", () => {
|
|
4323
4452
|
globalThis.clearTimeout(n), t();
|
|
4324
4453
|
}, { once: !0 });
|
|
4325
4454
|
});
|
|
4326
4455
|
}
|
|
4327
|
-
var
|
|
4456
|
+
var Or = new Set([
|
|
4328
4457
|
"in_progress",
|
|
4329
4458
|
"running",
|
|
4330
4459
|
"resuming",
|
|
4331
4460
|
"starting"
|
|
4332
4461
|
]);
|
|
4333
|
-
function
|
|
4462
|
+
function kr(e) {
|
|
4334
4463
|
let t = e.ActiveRunUpdatedAt || e.UpdatedAt, n = typeof t == "number" ? t > 1e11 ? t : t * 1e3 : Date.parse(String(t || ""));
|
|
4335
|
-
return Number.isFinite(n) && n <= Date.now() +
|
|
4464
|
+
return Number.isFinite(n) && n <= Date.now() + vr && Date.now() - n <= vr;
|
|
4336
4465
|
}
|
|
4337
|
-
function
|
|
4338
|
-
let t =
|
|
4466
|
+
function Ar(e) {
|
|
4467
|
+
let t = ne(e);
|
|
4339
4468
|
return t ? t === "completed" ? {
|
|
4340
4469
|
status: "completed",
|
|
4341
4470
|
phase: "后台长任务已完成"
|
|
@@ -4353,11 +4482,15 @@ function xr(e) {
|
|
|
4353
4482
|
phase: "后台长任务恢复失败"
|
|
4354
4483
|
} : null : null;
|
|
4355
4484
|
}
|
|
4356
|
-
function
|
|
4357
|
-
let { agentId: r, api: i, isMobile: a, resetCompaction: o, uiCapabilities: l, disconnectRun: u, restoreSession: d = !0 } = e, f =
|
|
4485
|
+
function jr(e) {
|
|
4486
|
+
let { agentId: r, api: i, isMobile: a, resetCompaction: o, uiCapabilities: l, disconnectRun: u, restoreSession: d = !0 } = e, f = Y(e.currentSessionId), p = Y(e.agentId), h = Y(l);
|
|
4358
4487
|
h.current = l;
|
|
4359
|
-
let _ =
|
|
4360
|
-
|
|
4488
|
+
let _ = Y(null), v = Y(0), y = Y(null), b = Y(null), S = Y(/* @__PURE__ */ new Map()), C = Y(null);
|
|
4489
|
+
J(() => () => {
|
|
4490
|
+
C.current?.sessionId === e.currentSessionId && (C.current?.controller.abort(), C.current = null);
|
|
4491
|
+
}, [e.currentSessionId, i]);
|
|
4492
|
+
let w = Y(/* @__PURE__ */ new Map()), E = Y(/* @__PURE__ */ new Map()), D = Y(/* @__PURE__ */ new Map()), O = Y(/* @__PURE__ */ new Map()), k = Y(/* @__PURE__ */ new Map()), te = Y(/* @__PURE__ */ new Map()), A = Y(/* @__PURE__ */ new Map()), M = Y(/* @__PURE__ */ new Map()), N = Y(null), F = Y(null), L = Y(null), R = Y(null), z = Y(null), re = q(async (e, t, n) => {
|
|
4493
|
+
let r = n.filter((e) => le(e, !1, !1));
|
|
4361
4494
|
if (!r.length) return;
|
|
4362
4495
|
let a = await Promise.all(r.map(async (n) => {
|
|
4363
4496
|
try {
|
|
@@ -4366,7 +4499,7 @@ function Sr(e) {
|
|
|
4366
4499
|
SessionId: t,
|
|
4367
4500
|
ResponseId: n.responseId,
|
|
4368
4501
|
EventId: n.eventId
|
|
4369
|
-
}), a = r?.Feedback ?
|
|
4502
|
+
}), a = r?.Feedback ? H(r.Feedback) : null;
|
|
4370
4503
|
return a ? {
|
|
4371
4504
|
messageId: n.id,
|
|
4372
4505
|
feedback: a
|
|
@@ -4377,15 +4510,15 @@ function Sr(e) {
|
|
|
4377
4510
|
}));
|
|
4378
4511
|
if (f.current !== t) return;
|
|
4379
4512
|
let o = new Map(a.filter((e) => !!e).map((e) => [e.messageId, e.feedback]));
|
|
4380
|
-
o.size &&
|
|
4513
|
+
o.size && K.getState().patchMessages((e) => e.map((e) => o.has(e.id) ? {
|
|
4381
4514
|
...e,
|
|
4382
4515
|
feedback: o.get(e.id)
|
|
4383
4516
|
} : e));
|
|
4384
|
-
}, [i]),
|
|
4517
|
+
}, [i]), B = q(async (e) => {
|
|
4385
4518
|
_.current?.abort();
|
|
4386
4519
|
let t = new AbortController();
|
|
4387
4520
|
_.current = t;
|
|
4388
|
-
let n = !1, r = !1, a = !1, o = c.getState(), l = o.agentId === p.current ? o.capabilities : h.current, u = l.KernelSessionEventsByCommand === !0, d =
|
|
4521
|
+
let n = !1, r = !1, a = !1, o = c.getState(), l = o.agentId === p.current ? o.capabilities : h.current, u = l.KernelSessionEventsByCommand === !0, d = ue(l.ConversationSurface, Se), g = new ge(e.sessionId, void 0, d), v = u ? 0 : e.afterSeqId, y = () => _.current === t && f.current === e.sessionId, b = cr(), x = !1, S = (t) => {
|
|
4389
4522
|
if (t.InvocationId && t.InvocationId !== e.invocationId) return;
|
|
4390
4523
|
let i = t.seq;
|
|
4391
4524
|
typeof i == "number" && b.accept(t);
|
|
@@ -4400,7 +4533,7 @@ function Sr(e) {
|
|
|
4400
4533
|
let o = t.Content?.runtime_event;
|
|
4401
4534
|
if (u && o?.schema_version === 2 && o.run_id === e.invocationId && g.apply(o)) {
|
|
4402
4535
|
let t = g.snapshot();
|
|
4403
|
-
|
|
4536
|
+
gn({
|
|
4404
4537
|
type: "conversation_snapshot",
|
|
4405
4538
|
sessionId: e.sessionId,
|
|
4406
4539
|
result: {
|
|
@@ -4411,13 +4544,13 @@ function Sr(e) {
|
|
|
4411
4544
|
}
|
|
4412
4545
|
});
|
|
4413
4546
|
}
|
|
4414
|
-
if (
|
|
4547
|
+
if (gn({
|
|
4415
4548
|
type: "stream_event",
|
|
4416
4549
|
sessionId: e.sessionId,
|
|
4417
4550
|
event: t
|
|
4418
|
-
}),
|
|
4551
|
+
}), P(t)) {
|
|
4419
4552
|
r = !0, n = !0;
|
|
4420
|
-
let i =
|
|
4553
|
+
let i = Ar(t);
|
|
4421
4554
|
i && m.getState().updateActivity({
|
|
4422
4555
|
sessionId: e.sessionId,
|
|
4423
4556
|
status: i.status,
|
|
@@ -4440,7 +4573,7 @@ function Sr(e) {
|
|
|
4440
4573
|
}); !r && y();) {
|
|
4441
4574
|
try {
|
|
4442
4575
|
let a = s.getState().messageHistory[e.sessionId];
|
|
4443
|
-
if (x && a?.historyView === "items-v1" && a.historyEpoch && (v = await
|
|
4576
|
+
if (x && a?.historyView === "items-v1" && a.historyEpoch && (v = await nr(i, e.sessionId, v, a.historyEpoch, t.signal, (e) => {
|
|
4444
4577
|
y() && S(e);
|
|
4445
4578
|
}), r || !y())) break;
|
|
4446
4579
|
x = !0;
|
|
@@ -4458,10 +4591,10 @@ function Sr(e) {
|
|
|
4458
4591
|
let { value: t, done: i } = await c.read();
|
|
4459
4592
|
if (i) break;
|
|
4460
4593
|
u += l.decode(t, { stream: !0 });
|
|
4461
|
-
let a =
|
|
4594
|
+
let a = Ft(u);
|
|
4462
4595
|
u = a.remainder;
|
|
4463
4596
|
for (let t of a.chunks) if (t.trim()) {
|
|
4464
|
-
for (let i of
|
|
4597
|
+
for (let i of Pt(t)) {
|
|
4465
4598
|
if (i.eventName === "__ping__") {
|
|
4466
4599
|
m.getState().updateActivity({
|
|
4467
4600
|
sessionId: e.sessionId,
|
|
@@ -4484,13 +4617,13 @@ function Sr(e) {
|
|
|
4484
4617
|
}
|
|
4485
4618
|
r && c.cancel().catch(() => {});
|
|
4486
4619
|
} catch (i) {
|
|
4487
|
-
if (i instanceof DOMException && i.name === "AbortError" || i instanceof
|
|
4620
|
+
if (i instanceof DOMException && i.name === "AbortError" || i instanceof Z || t.signal.aborted) {
|
|
4488
4621
|
r = !0, a = !0, y() && m.getState().stopSessionActivity(e.sessionId, "恢复事件订阅已取消。");
|
|
4489
4622
|
break;
|
|
4490
4623
|
}
|
|
4491
4624
|
if (!y()) break;
|
|
4492
|
-
if (i instanceof
|
|
4493
|
-
r = !0, n =
|
|
4625
|
+
if (i instanceof X && i.code >= 400 && i.code < 500 && i.code !== 408 && i.code !== 429) {
|
|
4626
|
+
r = !0, n = Sr(i), gn({
|
|
4494
4627
|
type: "error",
|
|
4495
4628
|
sessionId: e.sessionId,
|
|
4496
4629
|
error: i
|
|
@@ -4505,9 +4638,9 @@ function Sr(e) {
|
|
|
4505
4638
|
countEvent: !1
|
|
4506
4639
|
});
|
|
4507
4640
|
}
|
|
4508
|
-
!r && y() && await
|
|
4641
|
+
!r && y() && await Dr(t.signal);
|
|
4509
4642
|
}
|
|
4510
|
-
r && !a && y() &&
|
|
4643
|
+
r && !a && y() && gn({
|
|
4511
4644
|
type: "stream_ended",
|
|
4512
4645
|
sessionId: e.sessionId
|
|
4513
4646
|
});
|
|
@@ -4515,10 +4648,10 @@ function Sr(e) {
|
|
|
4515
4648
|
e instanceof DOMException && e.name === "AbortError" || console.error("Failed to subscribe run events:", e);
|
|
4516
4649
|
} finally {
|
|
4517
4650
|
let r = _.current === t;
|
|
4518
|
-
r && (_.current = null), r && f.current === e.sessionId && (m.getState().setCurrentRunId(""), m.getState().setActiveInvocationId(""), n &&
|
|
4651
|
+
r && (_.current = null), r && f.current === e.sessionId && (m.getState().setCurrentRunId(""), m.getState().setActiveInvocationId(""), n && R.current?.(e.sessionId), z.current?.(p.current, e.sessionId));
|
|
4519
4652
|
}
|
|
4520
|
-
}, [i]),
|
|
4521
|
-
if (!h.current.RunLifecycle.Enabled || !e.runId || p.current !== r || f.current !== e.sessionId || _.current || (
|
|
4653
|
+
}, [i]), V = q((e) => {
|
|
4654
|
+
if (!h.current.RunLifecycle.Enabled || !e.runId || p.current !== r || f.current !== e.sessionId || _.current || (A.current.get(e.sessionId)?.events || []).some((t) => {
|
|
4522
4655
|
let n = t.Content?.runtime_event;
|
|
4523
4656
|
return t.InvocationId === e.runId && !n?.parent_scope_id && [
|
|
4524
4657
|
"completed",
|
|
@@ -4527,49 +4660,66 @@ function Sr(e) {
|
|
|
4527
4660
|
"cancelled",
|
|
4528
4661
|
"canceled",
|
|
4529
4662
|
"aborted"
|
|
4530
|
-
].includes(
|
|
4663
|
+
].includes(ne(t));
|
|
4531
4664
|
})) return;
|
|
4532
4665
|
let t = m.getState().getSessionActivity(e.sessionId);
|
|
4533
4666
|
m.getState().isSessionStreaming(e.sessionId) && t?.source === "run" && [
|
|
4534
4667
|
"connecting",
|
|
4535
4668
|
"running",
|
|
4536
4669
|
"waiting"
|
|
4537
|
-
].includes(t.status) && (e.extensions?.mcpAuthorization || h.current.KernelSessionEventsByCommand === !0 && t.runId === e.runId) ||
|
|
4670
|
+
].includes(t.status) && (e.extensions?.mcpAuthorization || h.current.KernelSessionEventsByCommand === !0 && t.runId === e.runId) || B({
|
|
4538
4671
|
sessionId: e.sessionId,
|
|
4539
4672
|
invocationId: e.runId,
|
|
4540
|
-
afterSeqId: j(
|
|
4673
|
+
afterSeqId: j(A.current.get(e.sessionId)?.events || [])
|
|
4541
4674
|
});
|
|
4542
|
-
}, [r,
|
|
4675
|
+
}, [r, B]), U = q(async (e, r = !1, u, d) => {
|
|
4543
4676
|
if (u?.aborted) return;
|
|
4544
|
-
|
|
4545
|
-
let S = c.getState(), T = S.agentId === p.current ? S.capabilities : h.current,
|
|
4546
|
-
|
|
4547
|
-
let
|
|
4548
|
-
|
|
4549
|
-
let F =
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
s.getState().
|
|
4555
|
-
let
|
|
4556
|
-
|
|
4677
|
+
L.current = null;
|
|
4678
|
+
let S = c.getState(), T = S.agentId === p.current ? S.capabilities : h.current, M = ue(T.ConversationSurface, Se);
|
|
4679
|
+
k.current.set(e, M);
|
|
4680
|
+
let N = f.current;
|
|
4681
|
+
C.current?.controller.abort(), C.current = null;
|
|
4682
|
+
let F = ++v.current;
|
|
4683
|
+
y.current = F, b.current = null;
|
|
4684
|
+
let I = (e, t) => {
|
|
4685
|
+
$(O.current, e, t, f.current, gr);
|
|
4686
|
+
}, z = O.current.get(e), V = D.current.get(e);
|
|
4687
|
+
N && N !== e && (I(N, K.getState().messages), K.getState().setMessages(z || []), s.getState().clearSessionMessageHistory(e), W.getState().setSessionCheckpoints(e, []), W.getState().setSessionToolReceipts(e, []), m.getState().setCurrentRunId(""), m.getState().clearActivity()), f.current = e;
|
|
4688
|
+
let H = () => f.current === e && v.current === F && !u?.aborted;
|
|
4689
|
+
s.getState().setCurrentSessionId(e), s.getState().setSessionInitialMessageHistoryLoading(e, !z);
|
|
4690
|
+
let U = m.getState();
|
|
4691
|
+
U.isSessionStreaming(e) && U.updateActivity({
|
|
4557
4692
|
sessionId: e,
|
|
4558
4693
|
phase: "正在同步任务进展",
|
|
4559
4694
|
countEvent: !1
|
|
4560
4695
|
}), o();
|
|
4561
|
-
let
|
|
4562
|
-
_.current?.abort()
|
|
4696
|
+
let ie = K.getState().messages;
|
|
4697
|
+
_.current?.abort();
|
|
4698
|
+
let ae = T.RunLifecycle.Enabled && T.RunLifecycle.Resume, oe = t(n(T)), G = (t) => {
|
|
4699
|
+
if (!H() || !t.ActiveInvocationId) return;
|
|
4700
|
+
let n = m.getState();
|
|
4701
|
+
if (n.getSessionActivity(e)?.runId !== t.ActiveInvocationId) return;
|
|
4702
|
+
let r = Ar({
|
|
4703
|
+
EventType: "run_status",
|
|
4704
|
+
Content: { status: t.ActiveRunStatus }
|
|
4705
|
+
});
|
|
4706
|
+
r && (n.setSessionStreaming(e, !1), n.updateActivity({
|
|
4707
|
+
sessionId: e,
|
|
4708
|
+
...r,
|
|
4709
|
+
countEvent: !1
|
|
4710
|
+
}));
|
|
4711
|
+
};
|
|
4712
|
+
a && g.getState().setMobileSidebarOpen(!1);
|
|
4563
4713
|
try {
|
|
4564
|
-
let
|
|
4714
|
+
let t = {
|
|
4565
4715
|
historyView: "items-v1",
|
|
4566
|
-
limit:
|
|
4716
|
+
limit: fr,
|
|
4567
4717
|
includeReasoning: !0,
|
|
4568
4718
|
includeToolEvents: !0,
|
|
4569
4719
|
includeAttachments: !0,
|
|
4570
4720
|
signal: u
|
|
4571
|
-
},
|
|
4572
|
-
isCurrent:
|
|
4721
|
+
}, n = await Sn(() => i.listSessionMessages(e, t), {
|
|
4722
|
+
isCurrent: H,
|
|
4573
4723
|
signal: u,
|
|
4574
4724
|
onPreparing: () => {
|
|
4575
4725
|
let t = s.getState().messageHistory[e];
|
|
@@ -4579,144 +4729,160 @@ function Sr(e) {
|
|
|
4579
4729
|
hasMore: t?.hasMore ?? !1,
|
|
4580
4730
|
preparing: !0,
|
|
4581
4731
|
error: void 0
|
|
4582
|
-
}), s.getState().setSessionInitialMessageHistoryLoading(e, !
|
|
4732
|
+
}), s.getState().setSessionInitialMessageHistoryLoading(e, !z);
|
|
4583
4733
|
}
|
|
4584
4734
|
});
|
|
4585
|
-
if (!
|
|
4586
|
-
let
|
|
4735
|
+
if (!H()) return;
|
|
4736
|
+
let r = oe && n.CursorSource === "runtime" && !!n.HistoryEpoch && n.HistoryEpochSource !== "server-event-anchor", a = oe || ae ? (async () => {
|
|
4737
|
+
let t = ae ? await i.getSession(e) : {};
|
|
4738
|
+
if (G(t), r && H()) {
|
|
4739
|
+
let r = await rr(i, e, n, void 0, u, !0);
|
|
4740
|
+
r && (t = {
|
|
4741
|
+
ActiveInvocationId: r.InvocationId,
|
|
4742
|
+
ActiveRunStatus: ne(r)
|
|
4743
|
+
}, G(t));
|
|
4744
|
+
}
|
|
4745
|
+
return t;
|
|
4746
|
+
})().then((e) => ({ session: e }), (e) => ({ error: e })) : void 0, o = n.HistoryView === "items-v1" ? Vn(n, e) : void 0, h = o && tr(o, i, e, n, M), g = Rn(n.Messages);
|
|
4587
4747
|
$(te.current, e, g, f.current);
|
|
4588
|
-
let _ = Re(h?.messages ?? g,
|
|
4589
|
-
if (!
|
|
4590
|
-
let t = Ee(_,
|
|
4591
|
-
|
|
4748
|
+
let _ = Re(h?.messages ?? g, V), v = 0, S = h?.canonicalRunIds ?? [];
|
|
4749
|
+
if (!z) {
|
|
4750
|
+
let t = Ee(_, ie, K.getState().messages);
|
|
4751
|
+
K.getState().setMessages(t), ie = _, I(e, t);
|
|
4592
4752
|
}
|
|
4593
4753
|
if (s.getState().setSessionMessageHistory(e, {
|
|
4594
|
-
nextCursor:
|
|
4595
|
-
hasMore:
|
|
4596
|
-
...
|
|
4754
|
+
nextCursor: n.NextCursor,
|
|
4755
|
+
hasMore: n.HasMore,
|
|
4756
|
+
...Er(n)
|
|
4597
4757
|
}), s.getState().setSessionInitialMessageHistoryLoading(e, !1), o) {
|
|
4598
4758
|
let t = o.filter((e) => !e.ContentRef).map((e) => e.Event);
|
|
4599
|
-
$(
|
|
4759
|
+
$(A.current, e, {
|
|
4600
4760
|
itemProjection: h,
|
|
4601
4761
|
events: t,
|
|
4602
|
-
hasMore:
|
|
4762
|
+
hasMore: n.HasMore,
|
|
4603
4763
|
loadedCount: o.length,
|
|
4604
4764
|
total: o.length,
|
|
4605
|
-
cursorSource:
|
|
4606
|
-
historyEpoch:
|
|
4607
|
-
snapshotSeqId:
|
|
4765
|
+
cursorSource: n.CursorSource,
|
|
4766
|
+
historyEpoch: n.HistoryEpoch,
|
|
4767
|
+
snapshotSeqId: n.SnapshotSeqId
|
|
4608
4768
|
}, f.current);
|
|
4609
4769
|
for (let n of t) x(n, e);
|
|
4610
4770
|
} else try {
|
|
4611
4771
|
let t = await i.listSessionEvents(e, {
|
|
4612
4772
|
offset: 0,
|
|
4613
|
-
limit:
|
|
4773
|
+
limit: hr,
|
|
4614
4774
|
signal: u,
|
|
4615
|
-
historyEpoch:
|
|
4616
|
-
snapshotSeqId:
|
|
4775
|
+
historyEpoch: n.CursorSource === "runtime" ? n.HistoryEpoch : void 0,
|
|
4776
|
+
snapshotSeqId: n.CursorSource === "runtime" ? n.SnapshotSeqId : void 0
|
|
4617
4777
|
});
|
|
4618
|
-
if (!
|
|
4619
|
-
let
|
|
4620
|
-
if (
|
|
4778
|
+
if (!H()) return;
|
|
4779
|
+
let r = yr(n, t), a = t.Events, o = [...g].reverse().find((e) => e.invocationId && Object.values(e.tools || {}).some((e) => e.name === "call_a2a_agent"))?.invocationId;
|
|
4780
|
+
if (r && T.KernelSessionEventsByCommand === !0 && t.CursorSource === "runtime" && o && (a = await Cn(i, e, o, t, H, u), !H())) return;
|
|
4621
4781
|
let c = {
|
|
4622
|
-
events:
|
|
4623
|
-
loadedCount:
|
|
4624
|
-
total:
|
|
4625
|
-
cursorSource:
|
|
4626
|
-
historyEpoch:
|
|
4627
|
-
snapshotSeqId:
|
|
4782
|
+
events: r ? a : [],
|
|
4783
|
+
loadedCount: r ? a.length : 0,
|
|
4784
|
+
total: r ? Math.max(0, Number(t.Total ?? t.Events?.length ?? 0) || 0) : 0,
|
|
4785
|
+
cursorSource: r ? t.CursorSource : void 0,
|
|
4786
|
+
historyEpoch: r ? t.HistoryEpoch : void 0,
|
|
4787
|
+
snapshotSeqId: r ? t.SnapshotSeqId : void 0
|
|
4628
4788
|
};
|
|
4629
|
-
if ($(
|
|
4630
|
-
nextCursor:
|
|
4631
|
-
hasMore: !!(
|
|
4789
|
+
if ($(A.current, e, c, f.current), s.getState().setSessionMessageHistory(e, {
|
|
4790
|
+
nextCursor: n.NextCursor,
|
|
4791
|
+
hasMore: !!(n.HasMore || c.loadedCount < c.total)
|
|
4632
4792
|
}), c.events.length > 0) {
|
|
4633
4793
|
v = j(c.events);
|
|
4634
4794
|
for (let t of c.events) x(t, e);
|
|
4635
|
-
let t = je(g, c.events, e,
|
|
4636
|
-
S = t.canonicalRunIds, _ = Re(t.messages,
|
|
4795
|
+
let t = je(g, c.events, e, M);
|
|
4796
|
+
S = t.canonicalRunIds, _ = Re(t.messages, V);
|
|
4637
4797
|
}
|
|
4638
|
-
if (
|
|
4639
|
-
let
|
|
4640
|
-
if (!
|
|
4641
|
-
for (let t of
|
|
4642
|
-
|
|
4643
|
-
generation:
|
|
4798
|
+
if (r) {
|
|
4799
|
+
let r = await Dn(i, e, g, t, H, u);
|
|
4800
|
+
if (!H()) return;
|
|
4801
|
+
for (let t of r.events) x(t, e);
|
|
4802
|
+
r.incomplete && (b.current = {
|
|
4803
|
+
generation: F,
|
|
4644
4804
|
message: "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。"
|
|
4645
4805
|
}, s.getState().setSessionMessageHistory(e, {
|
|
4646
4806
|
...s.getState().messageHistory[e],
|
|
4647
|
-
nextCursor:
|
|
4648
|
-
hasMore: !!(
|
|
4807
|
+
nextCursor: n.NextCursor,
|
|
4808
|
+
hasMore: !!(n.HasMore || c.loadedCount < c.total),
|
|
4649
4809
|
error: "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。"
|
|
4650
4810
|
}));
|
|
4651
4811
|
}
|
|
4652
4812
|
} catch (e) {
|
|
4653
|
-
if (
|
|
4654
|
-
|
|
4655
|
-
generation:
|
|
4813
|
+
if (Sr(e)) throw e;
|
|
4814
|
+
H() && (b.current = {
|
|
4815
|
+
generation: F,
|
|
4656
4816
|
message: "完整事件历史读取失败,请刷新会话后重新查找。当前结果只包含已读取的正文。"
|
|
4657
4817
|
}), console.warn("[SessionLifecycle] canonical history replay failed:", e);
|
|
4658
4818
|
}
|
|
4659
|
-
if (!
|
|
4660
|
-
ee(_, e), $(
|
|
4661
|
-
let
|
|
4662
|
-
D.RunLifecycle.Enabled && D.RunLifecycle.Checkpoints ? (i.listSessionCheckpoints({
|
|
4819
|
+
if (!H()) return;
|
|
4820
|
+
ee(_, e), $(w.current, e, new Set(S), f.current), $(E.current, e, _, f.current), _ = Ee(_, ie, K.getState().messages), K.getState().setMessages(_), I(e, _), y.current = null, re(p.current, e, _);
|
|
4821
|
+
let C = Math.max(n.LatestSeqId || 0, v), D = c.getState().capabilities || l;
|
|
4822
|
+
if (D.RunLifecycle.Enabled && D.RunLifecycle.Checkpoints ? (i.listSessionCheckpoints({
|
|
4663
4823
|
agentId: p.current,
|
|
4664
4824
|
sessionId: e
|
|
4665
4825
|
}).then((t) => {
|
|
4666
|
-
|
|
4826
|
+
H() && W.getState().setSessionCheckpoints(e, t.Checkpoints || []);
|
|
4667
4827
|
}).catch((t) => {
|
|
4668
|
-
|
|
4828
|
+
H() && (console.warn("[SessionLifecycle] checkpoint load failed:", t), W.getState().setSessionCheckpoints(e, []));
|
|
4669
4829
|
}), i.listToolReceipts({
|
|
4670
4830
|
agentId: p.current,
|
|
4671
4831
|
sessionId: e
|
|
4672
4832
|
}).then((t) => {
|
|
4673
|
-
|
|
4833
|
+
H() && W.getState().setSessionToolReceipts(e, t.ToolReceipts || []);
|
|
4674
4834
|
}).catch((t) => {
|
|
4675
|
-
|
|
4676
|
-
})) : W.getState().clearSessionCheckpoints(e)
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
let
|
|
4680
|
-
if (
|
|
4681
|
-
let
|
|
4682
|
-
r && (
|
|
4835
|
+
H() && (console.warn("[SessionLifecycle] tool receipt load failed:", t), W.getState().setSessionToolReceipts(e, []));
|
|
4836
|
+
})) : W.getState().clearSessionCheckpoints(e), a) try {
|
|
4837
|
+
let t = await a;
|
|
4838
|
+
if ("error" in t) throw t.error;
|
|
4839
|
+
let o = t.session;
|
|
4840
|
+
if (oe && !r && !o.ActiveInvocationId && H()) {
|
|
4841
|
+
let t = A.current.get(e), r = await rr(i, e, n, t && yr(n, br(t)) ? t : void 0, u);
|
|
4842
|
+
r && (o = {
|
|
4683
4843
|
ActiveInvocationId: r.InvocationId,
|
|
4684
|
-
ActiveRunStatus:
|
|
4844
|
+
ActiveRunStatus: ne(r)
|
|
4685
4845
|
});
|
|
4686
4846
|
}
|
|
4687
|
-
if (!
|
|
4688
|
-
let
|
|
4689
|
-
if (
|
|
4690
|
-
let
|
|
4847
|
+
if (!H()) return;
|
|
4848
|
+
let s = String(o.ActiveRunStatus || "").toLowerCase();
|
|
4849
|
+
if (o.ActiveInvocationId && (Or.has(s) || s === "" && kr(o)) && o.ActiveInvocationId !== d) {
|
|
4850
|
+
let t = m.getState(), n = t.getSessionActivity(e), r = t.isSessionStreaming(e);
|
|
4851
|
+
if (n?.runId && (n.runId === o.ActiveInvocationId ? [
|
|
4852
|
+
"completed",
|
|
4853
|
+
"failed",
|
|
4854
|
+
"stopped"
|
|
4855
|
+
].includes(n.status) : r && n.source === "run")) return;
|
|
4856
|
+
let i = (T.KernelSessionEventsByCommand === !0 || oe) && r && n?.source === "run" && n.runId === o.ActiveInvocationId && [
|
|
4691
4857
|
"connecting",
|
|
4692
4858
|
"running",
|
|
4693
4859
|
"waiting"
|
|
4694
4860
|
].includes(n.status);
|
|
4695
|
-
|
|
4861
|
+
i && m.getState().updateActivity({
|
|
4696
4862
|
sessionId: e,
|
|
4697
4863
|
phase: "正在处理",
|
|
4698
4864
|
countEvent: !1
|
|
4699
|
-
}),
|
|
4865
|
+
}), i || B({
|
|
4700
4866
|
sessionId: e,
|
|
4701
|
-
invocationId:
|
|
4702
|
-
afterSeqId:
|
|
4867
|
+
invocationId: o.ActiveInvocationId,
|
|
4868
|
+
afterSeqId: C
|
|
4703
4869
|
});
|
|
4704
4870
|
} else {
|
|
4705
|
-
let
|
|
4871
|
+
let t = m.getState(), n = t.getSessionActivity(e), r = o.ActiveInvocationId && n?.runId === o.ActiveInvocationId ? Ar({
|
|
4706
4872
|
EventType: "run_status",
|
|
4707
|
-
Content: { status:
|
|
4708
|
-
}) : null,
|
|
4873
|
+
Content: { status: s }
|
|
4874
|
+
}) : null, i = n?.runId ? [...A.current.get(e)?.events || []].reverse().find((e) => {
|
|
4709
4875
|
let t = e.Content?.runtime_event;
|
|
4710
|
-
return e.InvocationId ===
|
|
4711
|
-
}) : void 0,
|
|
4712
|
-
|
|
4876
|
+
return e.InvocationId === n.runId && !t?.parent_scope_id && P(e);
|
|
4877
|
+
}) : void 0, a = r || i && Ar(i);
|
|
4878
|
+
a && (t.setSessionStreaming(e, !1), t.updateActivity({
|
|
4713
4879
|
sessionId: e,
|
|
4714
|
-
...
|
|
4880
|
+
...a,
|
|
4715
4881
|
countEvent: !1
|
|
4716
4882
|
}));
|
|
4717
4883
|
}
|
|
4718
4884
|
} catch (t) {
|
|
4719
|
-
if (console.warn("[SessionLifecycle] getSession for reconnect failed:", t),
|
|
4885
|
+
if (console.warn("[SessionLifecycle] getSession for reconnect failed:", t), H()) {
|
|
4720
4886
|
let t = m.getState();
|
|
4721
4887
|
t.isSessionStreaming(e) && t.getSessionActivity(e)?.phase === "正在同步任务进展" && t.updateActivity({
|
|
4722
4888
|
sessionId: e,
|
|
@@ -4726,7 +4892,7 @@ function Sr(e) {
|
|
|
4726
4892
|
}
|
|
4727
4893
|
}
|
|
4728
4894
|
} catch (t) {
|
|
4729
|
-
if (
|
|
4895
|
+
if (Sr(t) && !r && H()) {
|
|
4730
4896
|
s.getState().setSessionMessageHistory(e, {
|
|
4731
4897
|
nextItemCursor: null,
|
|
4732
4898
|
historyView: void 0,
|
|
@@ -4741,14 +4907,14 @@ function Sr(e) {
|
|
|
4741
4907
|
cursorCompatibleWithRuntime: void 0,
|
|
4742
4908
|
sessionContractVersion: void 0
|
|
4743
4909
|
}), queueMicrotask(() => {
|
|
4744
|
-
|
|
4910
|
+
H() && R.current?.(e, !0);
|
|
4745
4911
|
});
|
|
4746
4912
|
return;
|
|
4747
4913
|
}
|
|
4748
|
-
if (
|
|
4749
|
-
let n = r ? "历史来源已变化,重新加载失败。原有消息已保留,请手动刷新会话。" :
|
|
4914
|
+
if (H() && !(t instanceof Z)) {
|
|
4915
|
+
let n = r ? "历史来源已变化,重新加载失败。原有消息已保留,请手动刷新会话。" : xn(t) ? "历史仍在准备,请稍后重试。" : "会话历史读取失败,请重试。已有消息已保留。";
|
|
4750
4916
|
b.current = {
|
|
4751
|
-
generation:
|
|
4917
|
+
generation: F,
|
|
4752
4918
|
message: n
|
|
4753
4919
|
};
|
|
4754
4920
|
let i = s.getState().messageHistory[e];
|
|
@@ -4769,22 +4935,28 @@ function Sr(e) {
|
|
|
4769
4935
|
retryOlderPage: !1
|
|
4770
4936
|
}), r && g.getState().pushToast(n, "error");
|
|
4771
4937
|
}
|
|
4772
|
-
t instanceof
|
|
4938
|
+
t instanceof Z || console.error("Failed to load session messages:", t);
|
|
4773
4939
|
} finally {
|
|
4774
|
-
y.current ===
|
|
4940
|
+
y.current === F && (y.current = null), H() && s.getState().setSessionInitialMessageHistoryLoading(e, !1);
|
|
4775
4941
|
}
|
|
4776
4942
|
}, [
|
|
4777
4943
|
i,
|
|
4778
4944
|
a,
|
|
4779
4945
|
re,
|
|
4780
4946
|
o,
|
|
4781
|
-
|
|
4947
|
+
B,
|
|
4782
4948
|
l
|
|
4783
|
-
]),
|
|
4949
|
+
]), ie = q((e, t) => {
|
|
4784
4950
|
if (f.current !== e) return;
|
|
4785
|
-
let n =
|
|
4786
|
-
n && $(
|
|
4787
|
-
}, [
|
|
4951
|
+
let n = K.getState().messages.find((e) => e.role === "user" && (e.runId || e.invocationId) === t);
|
|
4952
|
+
n && $(D.current, e, n, e), U(e, !1, void 0, t);
|
|
4953
|
+
}, [U]), ae = q((e, t, n) => {
|
|
4954
|
+
let r = O.current, i = r.get(e);
|
|
4955
|
+
i?.some((e) => e.id === t) && r.set(e, i.map((e) => e.id === t ? {
|
|
4956
|
+
...e,
|
|
4957
|
+
...n
|
|
4958
|
+
} : e));
|
|
4959
|
+
}, []), G = q(async (e = "default-agent", t = null) => {
|
|
4788
4960
|
let n = s.getState();
|
|
4789
4961
|
n.sessionsAgentId && n.sessionsAgentId !== e && n.resetSessionPagination(e);
|
|
4790
4962
|
let r = s.getState().sessionsGeneration, a = () => c.getState().agentId === e && s.getState().sessionsGeneration === r;
|
|
@@ -4792,58 +4964,58 @@ function Sr(e) {
|
|
|
4792
4964
|
s.getState().setLoadingSessions(!0);
|
|
4793
4965
|
let n = await i.listSessions(e, {
|
|
4794
4966
|
page: 1,
|
|
4795
|
-
pageSize:
|
|
4967
|
+
pageSize: ur
|
|
4796
4968
|
});
|
|
4797
4969
|
if (!a()) return;
|
|
4798
4970
|
let r = n.Sessions || [];
|
|
4799
|
-
for (let e of r)
|
|
4800
|
-
let o = new Set(Array.from(
|
|
4971
|
+
for (let e of r) M.current.delete(e.SessionId);
|
|
4972
|
+
let o = new Set(Array.from(M.current.entries()).filter(([, t]) => t === e).map(([e]) => e)), c = ut(r, s.getState().sessions, o);
|
|
4801
4973
|
if (s.getState().upsertSessions(c, {
|
|
4802
4974
|
agentId: e,
|
|
4803
4975
|
total: Number(n.Total ?? n.Sessions?.length ?? 0),
|
|
4804
4976
|
page: Number(n.Page ?? 1),
|
|
4805
|
-
pageSize: Number(n.PageSize ??
|
|
4977
|
+
pageSize: Number(n.PageSize ?? ur),
|
|
4806
4978
|
replace: !0
|
|
4807
|
-
}),
|
|
4808
|
-
let l = s.getState().sessions, u = f.current, p = u || (d ?
|
|
4809
|
-
p && p !== u &&
|
|
4979
|
+
}), F.current || L.current === e) return;
|
|
4980
|
+
let l = s.getState().sessions, u = f.current, p = u || (d ? lt(l, t || st(e)) : null);
|
|
4981
|
+
p && p !== u && U(p);
|
|
4810
4982
|
} catch (e) {
|
|
4811
|
-
if (e instanceof
|
|
4983
|
+
if (e instanceof Z) return;
|
|
4812
4984
|
console.error("Failed to fetch sessions:", e);
|
|
4813
4985
|
} finally {
|
|
4814
4986
|
a() && s.getState().setLoadingSessions(!1);
|
|
4815
4987
|
}
|
|
4816
4988
|
}, [
|
|
4817
4989
|
i,
|
|
4818
|
-
|
|
4990
|
+
U,
|
|
4819
4991
|
d
|
|
4820
|
-
]),
|
|
4821
|
-
d && t && !f.current && !
|
|
4822
|
-
let n =
|
|
4823
|
-
if (d && !f.current &&
|
|
4992
|
+
]), se = q((e, t) => {
|
|
4993
|
+
d && t && !f.current && !F.current && L.current !== e && (p.current = e, U(t));
|
|
4994
|
+
let n = G(e, t);
|
|
4995
|
+
if (d && !f.current && L.current !== e) {
|
|
4824
4996
|
let e = {
|
|
4825
4997
|
ready: n,
|
|
4826
4998
|
cancelled: !1
|
|
4827
4999
|
};
|
|
4828
|
-
|
|
4829
|
-
|
|
5000
|
+
N.current = e, n.finally(() => {
|
|
5001
|
+
N.current === e && (N.current = null);
|
|
4830
5002
|
});
|
|
4831
5003
|
}
|
|
4832
5004
|
return n;
|
|
4833
5005
|
}, [
|
|
5006
|
+
G,
|
|
4834
5007
|
U,
|
|
4835
|
-
V,
|
|
4836
5008
|
d
|
|
4837
|
-
]), ce =
|
|
5009
|
+
]), ce = q((...e) => (N.current && (N.current.cancelled = !0), U(...e)), [U]), de = q(async () => {
|
|
4838
5010
|
let e = s.getState();
|
|
4839
5011
|
if (e.isLoadingSessions || !e.hasMoreSessions) return;
|
|
4840
5012
|
let t = T({
|
|
4841
5013
|
total: e.sessionsTotal,
|
|
4842
|
-
pageSize: e.sessionsPageSize ||
|
|
5014
|
+
pageSize: e.sessionsPageSize || ur,
|
|
4843
5015
|
loadedPages: e.loadedPages
|
|
4844
5016
|
});
|
|
4845
5017
|
if (!t) return;
|
|
4846
|
-
let n = e.sessionsPageSize ||
|
|
5018
|
+
let n = e.sessionsPageSize || ur, r = e.sessionsAgentId || p.current || "default-agent", a = () => c.getState().agentId === r && s.getState().sessionsGeneration === e.sessionsGeneration;
|
|
4847
5019
|
try {
|
|
4848
5020
|
s.getState().setLoadingSessions(!0);
|
|
4849
5021
|
let o = await i.listSessions(r, {
|
|
@@ -4858,74 +5030,95 @@ function Sr(e) {
|
|
|
4858
5030
|
pageSize: Number(o.PageSize ?? n)
|
|
4859
5031
|
});
|
|
4860
5032
|
} catch (e) {
|
|
4861
|
-
if (e instanceof
|
|
5033
|
+
if (e instanceof Z) return;
|
|
4862
5034
|
console.error("Failed to load more sessions:", e);
|
|
4863
5035
|
} finally {
|
|
4864
5036
|
a() && s.getState().setLoadingSessions(!1);
|
|
4865
5037
|
}
|
|
4866
5038
|
}, [i]);
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
}, [
|
|
4870
|
-
|
|
4871
|
-
}, [
|
|
4872
|
-
let
|
|
4873
|
-
if (
|
|
5039
|
+
J(() => {
|
|
5040
|
+
R.current = U;
|
|
5041
|
+
}, [U]), J(() => {
|
|
5042
|
+
z.current = G;
|
|
5043
|
+
}, [G]);
|
|
5044
|
+
let fe = q((e, t = !1) => {
|
|
5045
|
+
if (L.current = null, t && f.current === e) {
|
|
4874
5046
|
s.getState().upsertSessions([{
|
|
4875
5047
|
SessionId: e,
|
|
4876
5048
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4877
5049
|
}]);
|
|
4878
5050
|
return;
|
|
4879
5051
|
}
|
|
4880
|
-
v.current += 1, _.current?.abort(),
|
|
5052
|
+
v.current += 1, _.current?.abort(), M.current.set(e, p.current), s.getState().upsertSessions([{
|
|
4881
5053
|
SessionId: e,
|
|
4882
5054
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4883
|
-
}]), f.current = e, s.getState().setCurrentSessionId(e), t || (
|
|
4884
|
-
}, [a]),
|
|
4885
|
-
|
|
4886
|
-
}, [a]),
|
|
4887
|
-
if (
|
|
4888
|
-
await
|
|
5055
|
+
}]), f.current = e, s.getState().setCurrentSessionId(e), t || (K.getState().setMessages([]), m.getState().setCurrentRunId(""), m.getState().clearActivity()), s.getState().clearSessionMessageHistory(e), W.getState().setSessionCheckpoints(e, []), W.getState().setSessionToolReceipts(e, []), a && (g.getState().setMobileSidebarOpen(!1), g.getState().setMobileActionsOpen(!1));
|
|
5056
|
+
}, [a]), pe = q(() => {
|
|
5057
|
+
N.current && (N.current.cancelled = !0), ct(p.current, null), L.current = p.current, v.current += 1, _.current?.abort(), f.current = null, s.getState().setCurrentSessionId(null), K.getState().setMessages([]), m.getState().setCurrentRunId(""), m.getState().clearActivity(), a && g.getState().setMobileSidebarOpen(!1);
|
|
5058
|
+
}, [a]), me = q(async () => {
|
|
5059
|
+
if (F.current) {
|
|
5060
|
+
await F.current;
|
|
4889
5061
|
return;
|
|
4890
5062
|
}
|
|
4891
|
-
|
|
5063
|
+
N.current && (N.current.cancelled = !0), ct(r, null), v.current += 1, _.current?.abort(), f.current = null, s.getState().setCurrentSessionId(null), K.getState().setMessages([]);
|
|
4892
5064
|
let e = i.createSession(r).then((e) => {
|
|
4893
5065
|
let t = e.SessionId || null;
|
|
4894
|
-
return t && c.getState().agentId === r &&
|
|
4895
|
-
}).catch((e) => (e instanceof
|
|
4896
|
-
|
|
5066
|
+
return t && c.getState().agentId === r && fe(t, K.getState().messages.some((e) => e.eventType === "optimistic_user_message" || e.eventType === "optimistic_assistant_placeholder")), t;
|
|
5067
|
+
}).catch((e) => (e instanceof Z || console.error("Failed to create session:", e), null));
|
|
5068
|
+
F.current = e;
|
|
4897
5069
|
try {
|
|
4898
5070
|
await e;
|
|
4899
5071
|
} finally {
|
|
4900
|
-
|
|
5072
|
+
F.current === e && (F.current = null);
|
|
4901
5073
|
}
|
|
4902
5074
|
}, [
|
|
4903
|
-
|
|
5075
|
+
fe,
|
|
4904
5076
|
r,
|
|
4905
5077
|
i
|
|
4906
|
-
]),
|
|
4907
|
-
let e =
|
|
5078
|
+
]), _e = q(async () => {
|
|
5079
|
+
let e = F.current;
|
|
4908
5080
|
if (e) return await e;
|
|
4909
|
-
let t =
|
|
4910
|
-
if (!f.current && t && !t.cancelled && (await t.ready, t.cancelled)) throw new
|
|
5081
|
+
let t = N.current;
|
|
5082
|
+
if (!f.current && t && !t.cancelled && (await t.ready, t.cancelled)) throw new Z();
|
|
4911
5083
|
return f.current;
|
|
4912
|
-
}, []),
|
|
5084
|
+
}, []), ve = q(async (e) => {
|
|
4913
5085
|
try {
|
|
4914
5086
|
let t = await i.deleteSession(e);
|
|
4915
|
-
return c.getState().agentId === r ? t.Deleted === !1 ? (g.getState().pushToast("会话暂未删除,云端运行时仍在同步,请稍后重试。", "error"),
|
|
5087
|
+
return c.getState().agentId === r ? t.Deleted === !1 ? (g.getState().pushToast("会话暂未删除,云端运行时仍在同步,请稍后重试。", "error"), G(r, f.current ?? void 0), !1) : (s.getState().removeSession(e), s.getState().clearSessionMessageHistory(e), O.current.delete(e), te.current.delete(e), k.current.delete(e), A.current.delete(e), w.current.delete(e), E.current.delete(e), D.current.delete(e), M.current.delete(e), f.current === e && (ct(r, null), v.current += 1, _.current?.abort(), u?.(), f.current = null, K.getState().setMessages([]), W.getState().clearSessionCheckpoints(e), s.getState().setCurrentSessionId(null), m.getState().setCurrentRunId(""), m.getState().clearActivity(), G(r)), !0) : t.Deleted !== !1;
|
|
4916
5088
|
} catch (e) {
|
|
4917
|
-
return e instanceof
|
|
5089
|
+
return e instanceof Z ? !1 : (console.error("Failed to delete session", e), g.getState().pushToast("删除会话失败,请稍后重试。", "error"), !1);
|
|
4918
5090
|
}
|
|
4919
5091
|
}, [
|
|
4920
5092
|
r,
|
|
4921
5093
|
i,
|
|
4922
5094
|
u,
|
|
4923
|
-
|
|
4924
|
-
]),
|
|
5095
|
+
G
|
|
5096
|
+
]), ye = q((e) => {
|
|
5097
|
+
let t = s.getState().messageHistory[e], n = A.current.get(e)?.itemProjection, r = oe(t);
|
|
5098
|
+
if (f.current !== e || !t || r === null || t.isLoadingInitial || t.isLoadingOlder || t.historyView === "items-v1" && !n) return;
|
|
5099
|
+
let a = v.current, o = C.current;
|
|
5100
|
+
if (o?.sessionId === e && o.generation === a && o.cursor === r && o.projection === n) return;
|
|
5101
|
+
o?.controller.abort();
|
|
5102
|
+
let c = new AbortController(), l = wr(t, c.signal), u = k.current.get(e) || "flat-v1", d = (t) => (c.signal.throwIfAborted(), i.listSessionMessages(e, t));
|
|
5103
|
+
C.current = {
|
|
5104
|
+
sessionId: e,
|
|
5105
|
+
generation: a,
|
|
5106
|
+
cursor: r,
|
|
5107
|
+
projection: n,
|
|
5108
|
+
controller: c,
|
|
5109
|
+
result: d(l).then(async (t) => {
|
|
5110
|
+
let r = n && l.itemCursor ? await Tr(i, e, l, n, u, d, t) : null;
|
|
5111
|
+
return {
|
|
5112
|
+
page: r?.page ?? t,
|
|
5113
|
+
batch: r
|
|
5114
|
+
};
|
|
5115
|
+
}).catch(() => null)
|
|
5116
|
+
};
|
|
5117
|
+
}, [i]), xe = q(async (e, t) => {
|
|
4925
5118
|
t?.throwIfAborted();
|
|
4926
|
-
let n = s.getState().messageHistory[e], r =
|
|
5119
|
+
let n = s.getState().messageHistory[e], r = A.current.get(e), a = !!(n?.hasMore && (n.nextCursor !== null || n.nextItemCursor)), o = !!(r && r.loadedCount < r.total);
|
|
4927
5120
|
if (!n || n.isLoadingOlder || !a && !o) return;
|
|
4928
|
-
let c = v.current, l =
|
|
5121
|
+
let c = v.current, l = E.current.get(e) || K.getState().messages, u = Symbol(e);
|
|
4929
5122
|
S.current.set(e, u);
|
|
4930
5123
|
let d = () => f.current === e && v.current === c && S.current.get(e) === u && !t?.aborted, m = {
|
|
4931
5124
|
isCurrent: d,
|
|
@@ -4941,132 +5134,134 @@ function Sr(e) {
|
|
|
4941
5134
|
};
|
|
4942
5135
|
try {
|
|
4943
5136
|
s.getState().setSessionMessageHistoryLoading(e, !0);
|
|
4944
|
-
let
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
includeAttachments: !0
|
|
4956
|
-
}), m) : Promise.resolve(null), o && r ? yn(() => i.listSessionEvents(e, {
|
|
5137
|
+
let h = wr(n, t), g = (t) => Sn(() => i.listSessionMessages(e, t), m), [_, y] = await Promise.allSettled([a ? (async () => {
|
|
5138
|
+
let n = C.current;
|
|
5139
|
+
if (!t && n?.sessionId === e && n.generation === c && n.cursor === (h.itemCursor ?? h.beforeSeqId) && n.projection === r?.itemProjection) {
|
|
5140
|
+
let e = await n.result;
|
|
5141
|
+
if (C.current === n && (C.current = null), e) return e;
|
|
5142
|
+
}
|
|
5143
|
+
return {
|
|
5144
|
+
page: await g(h),
|
|
5145
|
+
batch: null
|
|
5146
|
+
};
|
|
5147
|
+
})() : Promise.resolve(null), o && r ? Sn(() => i.listSessionEvents(e, {
|
|
4957
5148
|
signal: t,
|
|
4958
5149
|
offset: r.loadedCount,
|
|
4959
|
-
limit:
|
|
5150
|
+
limit: hr,
|
|
4960
5151
|
cursorSource: r.cursorSource,
|
|
4961
5152
|
historyEpoch: r.historyEpoch,
|
|
4962
5153
|
snapshotSeqId: r.snapshotSeqId
|
|
4963
5154
|
}), m) : Promise.resolve(null)]);
|
|
4964
5155
|
if (t?.throwIfAborted(), f.current !== e || v.current !== c || S.current.get(e) !== u) return;
|
|
4965
|
-
let
|
|
5156
|
+
let T = y.status === "rejected" && y.reason instanceof X && [
|
|
4966
5157
|
429,
|
|
4967
5158
|
502,
|
|
4968
5159
|
503,
|
|
4969
5160
|
504
|
|
4970
|
-
].includes(
|
|
4971
|
-
if (
|
|
4972
|
-
if (
|
|
4973
|
-
let
|
|
4974
|
-
if (
|
|
5161
|
+
].includes(y.reason.code);
|
|
5162
|
+
if (y.status === "rejected" && !T) throw y.reason;
|
|
5163
|
+
if (_.status === "rejected") throw _.reason;
|
|
5164
|
+
let j = _.value?.page ?? null, M = y.status === "fulfilled" ? y.value : null, N = T ? "消息正文已加载,部分事件详情暂时读取失败,请重试加载更早记录。" : void 0;
|
|
5165
|
+
if (j && !yr({
|
|
4975
5166
|
CursorSource: n.cursorSource,
|
|
4976
5167
|
HistoryEpoch: n.historyEpoch,
|
|
4977
5168
|
SnapshotSeqId: n.snapshotSeqId,
|
|
4978
5169
|
CursorCompatibleWithRuntime: n.cursorCompatibleWithRuntime
|
|
4979
|
-
},
|
|
5170
|
+
}, j) || M && r && !yr(br(r), M) || (N ? b.current = {
|
|
4980
5171
|
generation: c,
|
|
4981
|
-
message:
|
|
4982
|
-
} :
|
|
4983
|
-
let
|
|
4984
|
-
if (
|
|
4985
|
-
let
|
|
4986
|
-
if (!
|
|
4987
|
-
let
|
|
5172
|
+
message: N
|
|
5173
|
+
} : M && (b.current = null), n.historyView === "items-v1" && j?.HistoryView !== "items-v1")) throw Cr();
|
|
5174
|
+
let F, L;
|
|
5175
|
+
if (j?.HistoryView === "items-v1") {
|
|
5176
|
+
let a = r?.itemProjection, o = k.current.get(e) || "flat-v1", s = _.value?.batch ?? (!t && a && h.itemCursor ? await Tr(i, e, h, a, o, g, j) : null);
|
|
5177
|
+
if (!d()) return;
|
|
5178
|
+
let c = s?.page ?? j;
|
|
5179
|
+
j = c;
|
|
5180
|
+
let u = s?.items ?? Vn(c, e, n.nextItemCursor), f = a?.firstSeq ?? n.nextCursor;
|
|
5181
|
+
if (!a && (n.historyView === "items-v1" || n.cursorSource !== "runtime" || !n.historyEpoch || n.snapshotSeqId !== c.SnapshotSeqId || f == null) || u.length && f != null && u.at(-1).SeqId >= f) throw Cr();
|
|
5182
|
+
let p = a ? r?.legacySuffix : {
|
|
4988
5183
|
messages: l,
|
|
4989
|
-
boundary:
|
|
4990
|
-
canonicalRunIds: [...
|
|
4991
|
-
},
|
|
4992
|
-
if (
|
|
4993
|
-
let e =
|
|
5184
|
+
boundary: f,
|
|
5185
|
+
canonicalRunIds: [...w.current.get(e) || []]
|
|
5186
|
+
}, m = s?.projection ?? tr(u, i, e, c, o, a);
|
|
5187
|
+
if (F = m, p) {
|
|
5188
|
+
let e = p.messages.filter((e) => {
|
|
4994
5189
|
let t = e.historyOrder?.seq;
|
|
4995
|
-
return t == null || t >=
|
|
5190
|
+
return t == null || t >= p.boundary || c.HasMore && m.firstSeq != null && t < m.firstSeq;
|
|
4996
5191
|
}), t = new Set(e.map((e) => e.id));
|
|
4997
|
-
|
|
4998
|
-
messages: be([...
|
|
4999
|
-
canonicalRunIds: [...new Set([...
|
|
5192
|
+
F = {
|
|
5193
|
+
messages: be([...m.messages.filter((e) => !t.has(e.id)), ...e]),
|
|
5194
|
+
canonicalRunIds: [...new Set([...m.canonicalRunIds, ...p.canonicalRunIds])]
|
|
5000
5195
|
};
|
|
5001
5196
|
}
|
|
5002
|
-
let
|
|
5003
|
-
|
|
5004
|
-
itemProjection:
|
|
5005
|
-
legacySuffix:
|
|
5006
|
-
hasMore:
|
|
5007
|
-
events: [...
|
|
5008
|
-
loadedCount:
|
|
5009
|
-
total:
|
|
5010
|
-
historyEpoch:
|
|
5011
|
-
snapshotSeqId:
|
|
5012
|
-
cursorSource:
|
|
5197
|
+
let v = u.filter((e) => !e.ContentRef).map((e) => e.Event), y = (a ? r.loadedCount : 0) + u.length;
|
|
5198
|
+
L = {
|
|
5199
|
+
itemProjection: m,
|
|
5200
|
+
legacySuffix: p,
|
|
5201
|
+
hasMore: c.HasMore,
|
|
5202
|
+
events: [...v.filter((e) => e.EventType === "run_status" || P(e)), ...r?.events || []],
|
|
5203
|
+
loadedCount: y,
|
|
5204
|
+
total: y,
|
|
5205
|
+
historyEpoch: c.HistoryEpoch,
|
|
5206
|
+
snapshotSeqId: c.SnapshotSeqId,
|
|
5207
|
+
cursorSource: c.CursorSource
|
|
5013
5208
|
};
|
|
5014
|
-
for (let t of
|
|
5015
|
-
b.current = null,
|
|
5209
|
+
for (let t of v) x(t, e);
|
|
5210
|
+
b.current = null, N = void 0;
|
|
5016
5211
|
}
|
|
5017
|
-
let
|
|
5018
|
-
$(te.current, e,
|
|
5019
|
-
let
|
|
5020
|
-
if (
|
|
5021
|
-
else if (
|
|
5022
|
-
let t =
|
|
5023
|
-
|
|
5024
|
-
events:
|
|
5025
|
-
loadedCount:
|
|
5026
|
-
total:
|
|
5027
|
-
cursorSource:
|
|
5028
|
-
historyEpoch:
|
|
5029
|
-
snapshotSeqId:
|
|
5212
|
+
let R = j ? Rn(j.Messages) : [], ne = new Set(R.map((e) => e.id)), z = [...R, ...(te.current.get(e) || []).filter((e) => !ne.has(e.id))];
|
|
5213
|
+
$(te.current, e, z, f.current);
|
|
5214
|
+
let B = r?.events || [], V = r?.loadedCount || 0, H = r?.total || 0;
|
|
5215
|
+
if (L) V = H = L.loadedCount;
|
|
5216
|
+
else if (M) {
|
|
5217
|
+
let t = M.Events || [];
|
|
5218
|
+
B = I(t, B), H = Math.max(H, Number(M.Total ?? 0) || 0), V = t.length > 0 ? Math.min(H, V + t.length) : H, $(A.current, e, {
|
|
5219
|
+
events: B,
|
|
5220
|
+
loadedCount: V,
|
|
5221
|
+
total: H,
|
|
5222
|
+
cursorSource: M.CursorSource ?? r?.cursorSource,
|
|
5223
|
+
historyEpoch: M.HistoryEpoch ?? r?.historyEpoch,
|
|
5224
|
+
snapshotSeqId: M.SnapshotSeqId ?? r?.snapshotSeqId
|
|
5030
5225
|
}, f.current);
|
|
5031
5226
|
for (let n of t) x(n, e);
|
|
5032
5227
|
}
|
|
5033
|
-
if (
|
|
5034
|
-
let n = await
|
|
5035
|
-
Events:
|
|
5228
|
+
if (R.length && r) {
|
|
5229
|
+
let n = await Dn(i, e, R, {
|
|
5230
|
+
Events: B,
|
|
5036
5231
|
CursorSource: r.cursorSource,
|
|
5037
5232
|
HistoryEpoch: r.historyEpoch,
|
|
5038
5233
|
SnapshotSeqId: r.snapshotSeqId
|
|
5039
5234
|
}, d, t);
|
|
5040
5235
|
if (!d()) return;
|
|
5041
5236
|
for (let t of n.events) x(t, e);
|
|
5042
|
-
n.incomplete && (
|
|
5237
|
+
n.incomplete && (N = "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。", b.current = {
|
|
5043
5238
|
generation: c,
|
|
5044
|
-
message:
|
|
5239
|
+
message: N
|
|
5045
5240
|
});
|
|
5046
5241
|
}
|
|
5047
|
-
let
|
|
5048
|
-
|
|
5049
|
-
let ie = Ee(
|
|
5050
|
-
$(
|
|
5051
|
-
nextCursor:
|
|
5052
|
-
hasMore: !!(
|
|
5053
|
-
...
|
|
5054
|
-
...
|
|
5055
|
-
dataSource:
|
|
5056
|
-
degraded:
|
|
5057
|
-
cursorSource:
|
|
5058
|
-
cursorCompatibleWithRuntime:
|
|
5059
|
-
sessionContractVersion:
|
|
5060
|
-
historyEpoch:
|
|
5061
|
-
persistenceDegraded:
|
|
5062
|
-
snapshotSeqId:
|
|
5242
|
+
let U = F ?? je(z, B, e, k.current.get(e) || "flat-v1"), W = Re(U.messages, D.current.get(e));
|
|
5243
|
+
L && $(A.current, e, L, f.current), ee(W, e), $(E.current, e, W, f.current);
|
|
5244
|
+
let ie = Ee(W, l, K.getState().messages, !!F);
|
|
5245
|
+
$(w.current, e, new Set(U.canonicalRunIds), f.current), K.getState().setMessages(ie), $(O.current, e, ie, f.current, gr), s.getState().setSessionMessageHistory(e, {
|
|
5246
|
+
nextCursor: j ? j.NextCursor : n.nextCursor,
|
|
5247
|
+
hasMore: !!(j && j.HasMore || V < H),
|
|
5248
|
+
...j ? Er(j) : {},
|
|
5249
|
+
...j ? {
|
|
5250
|
+
dataSource: j.DataSource ?? n.dataSource,
|
|
5251
|
+
degraded: j.Degraded ?? n.degraded,
|
|
5252
|
+
cursorSource: j.CursorSource ?? n.cursorSource,
|
|
5253
|
+
cursorCompatibleWithRuntime: j.CursorCompatibleWithRuntime ?? n.cursorCompatibleWithRuntime,
|
|
5254
|
+
sessionContractVersion: j.SessionContractVersion ?? n.sessionContractVersion,
|
|
5255
|
+
historyEpoch: j.HistoryEpoch ?? n.historyEpoch,
|
|
5256
|
+
persistenceDegraded: j.PersistenceDegraded ?? n.persistenceDegraded,
|
|
5257
|
+
snapshotSeqId: j.SnapshotSeqId ?? n.snapshotSeqId
|
|
5063
5258
|
} : {},
|
|
5064
5259
|
preparing: !1,
|
|
5065
|
-
error:
|
|
5066
|
-
retryOlderPage: !!
|
|
5067
|
-
}), re(p.current, e,
|
|
5260
|
+
error: N,
|
|
5261
|
+
retryOlderPage: !!N
|
|
5262
|
+
}), re(p.current, e, R);
|
|
5068
5263
|
} catch (r) {
|
|
5069
|
-
if (
|
|
5264
|
+
if (Sr(r) && f.current === e && v.current === c && S.current.get(e) === u && !t?.aborted) {
|
|
5070
5265
|
s.getState().setSessionMessageHistory(e, {
|
|
5071
5266
|
nextCursor: null,
|
|
5072
5267
|
nextItemCursor: null,
|
|
@@ -5082,16 +5277,16 @@ function Sr(e) {
|
|
|
5082
5277
|
sessionContractVersion: void 0,
|
|
5083
5278
|
persistenceDegraded: void 0,
|
|
5084
5279
|
error: void 0
|
|
5085
|
-
}), await
|
|
5280
|
+
}), await U(e, !0, t);
|
|
5086
5281
|
return;
|
|
5087
5282
|
}
|
|
5088
|
-
if (d() && !(r instanceof
|
|
5283
|
+
if (d() && !(r instanceof Z) && s.getState().setSessionMessageHistory(e, {
|
|
5089
5284
|
...n,
|
|
5090
5285
|
preparing: !1,
|
|
5091
5286
|
retryOlderPage: !0,
|
|
5092
5287
|
error: r instanceof Error ? r.message : "历史加载失败,请重试"
|
|
5093
5288
|
}), t) throw r;
|
|
5094
|
-
r instanceof
|
|
5289
|
+
r instanceof Z || console.error("Failed to load older session messages:", r);
|
|
5095
5290
|
} finally {
|
|
5096
5291
|
if (S.current.get(e) === u) if (S.current.delete(e), v.current === c) {
|
|
5097
5292
|
let t = s.getState().messageHistory[e];
|
|
@@ -5107,40 +5302,42 @@ function Sr(e) {
|
|
|
5107
5302
|
}, [
|
|
5108
5303
|
i,
|
|
5109
5304
|
re,
|
|
5110
|
-
|
|
5305
|
+
U
|
|
5111
5306
|
]);
|
|
5112
5307
|
return {
|
|
5113
|
-
historySearchSnapshot:
|
|
5114
|
-
let e = f.current || "", t = s.getState().messageHistory[e], n =
|
|
5308
|
+
historySearchSnapshot: q(() => {
|
|
5309
|
+
let e = f.current || "", t = s.getState().messageHistory[e], n = A.current.get(e);
|
|
5115
5310
|
return {
|
|
5116
5311
|
owner: JSON.stringify([
|
|
5117
5312
|
p.current,
|
|
5118
5313
|
e,
|
|
5119
5314
|
v.current
|
|
5120
5315
|
]),
|
|
5121
|
-
messages:
|
|
5316
|
+
messages: K.getState().messages,
|
|
5122
5317
|
hasMore: !!t?.hasMore,
|
|
5123
5318
|
loading: !!(y.current === v.current || s.getState().isLoadingSessions || t?.isLoadingInitial || t?.isLoadingOlder),
|
|
5124
5319
|
checkpoint: `${t?.nextItemCursor ?? t?.nextCursor}:${n?.loadedCount}`,
|
|
5125
5320
|
error: b.current?.generation === v.current ? b.current.message : void 0
|
|
5126
5321
|
};
|
|
5127
5322
|
}, []),
|
|
5128
|
-
followAcceptedInteraction:
|
|
5129
|
-
fetchSessions:
|
|
5130
|
-
fetchInitialSessions:
|
|
5131
|
-
loadMoreSessions:
|
|
5323
|
+
followAcceptedInteraction: V,
|
|
5324
|
+
fetchSessions: G,
|
|
5325
|
+
fetchInitialSessions: se,
|
|
5326
|
+
loadMoreSessions: de,
|
|
5132
5327
|
loadSession: ce,
|
|
5133
|
-
recoverSessionRun:
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5328
|
+
recoverSessionRun: ie,
|
|
5329
|
+
bindCachedUserInput: ae,
|
|
5330
|
+
loadOlderSessionMessages: xe,
|
|
5331
|
+
prefetchOlderSessionMessages: ye,
|
|
5332
|
+
createNewSession: me,
|
|
5333
|
+
startNewConversation: pe,
|
|
5334
|
+
adoptCreatedSession: fe,
|
|
5335
|
+
waitForPendingSessionCreation: _e,
|
|
5336
|
+
deleteSession: ve,
|
|
5140
5337
|
currentSessionIdRef: f,
|
|
5141
5338
|
agentIdRef: p,
|
|
5142
5339
|
runSubscriptionAbortRef: _
|
|
5143
5340
|
};
|
|
5144
5341
|
}
|
|
5145
5342
|
//#endregion
|
|
5146
|
-
export { Ze as S,
|
|
5343
|
+
export { Ze as S, ht as _, bn as a, Je as b, Rt as c, Mt as d, Tt as f, gt as g, vt as h, cr as i, Pt as l, xt as m, ir as n, an as o, St as p, sr as r, Ht as s, jr as t, Ft as u, ct as v, Xe as x, nt as y };
|