@kingsoftcloud/ksadk-web 0.3.16 → 0.3.17
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-BuQ9Y_JK.js → ArtifactsPanel-DYzXIPnl.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-ClmrpVUK.js → CodeBlock-Dpa-tOmG.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-DYg6qEqQ.js → MathMessageMarkdown-D8kBE9sl.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-B8QsBFET.js → MermaidBlock-BYOoZB-_.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-Dkm61i5S.js → NativeTerminalPanel-CAeXHeo6.js} +1 -1
- package/dist-ksadk/assets/{OfficialA2uiRenderer-SMVbkx2W.js → OfficialA2uiRenderer-yPb3s23n.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-CQ5-2gHs.js → abnfDiagram-VCTEODGH-DdVxMn2L.js} +1 -1
- package/dist-ksadk/assets/{arc-CHdgzwmb.js → arc-DsOMYRTm.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-Ds1NB530.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-MnCOPhnl.js → architectureDiagram-5GKGNRK7-BCfzi23_.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-DZ61ECd8.js → blockDiagram-NRAW4CY4-gC-Gc2Xv.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-D9FYHHhU.js → c4Diagram-UCG6FXSJ-BAHemGZa.js} +1 -1
- package/dist-ksadk/assets/channel-B4PiWfnA.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-CI2tn5IS.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-AIv2klim.js → chunk-5VM5RSS4-Cthhs8Yv.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-D_sWJ7f-.js → chunk-F27PBJKO-BPV04XpW.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-DQzToglM.js → chunk-G27WJ6UU-Cl1n0gHd.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-lOgv6BXZ.js → chunk-JWPE2WC7-DqkIh_LK.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-Cbx6jBtE.js → chunk-LCL6LL3I-DZhAKY7Z.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-DNJ22Jtx.js → chunk-POPQ4Y6H-BGuhTofV.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-BhICgqzs.js → chunk-RHFEMEQ7-DhrRHdJ6.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-r-bF-HGi.js → chunk-SVP7TREG-CIdm5TIa.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-OjeFK9EX.js → chunk-XXDRQBXY-CNIlGK4v.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-BMQzydMm.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-BMQzydMm.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-LkMJR5TN.js → cose-bilkent-JH36ORCC-BjauSFl3.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-DcGwq_cA.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-B6wd-M91.js → cynefinDiagram-5FMLGOSQ-DPszkr1j.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-Yo8czwSH.js → dagre-3AP2YEHR-Ds2xBGA0.js} +1 -1
- package/dist-ksadk/assets/{dagre-IpjZOTvn.js → dagre-Dr0YPDPm.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-CAkqzyfj.js → diagram-S7CK7UJ4-BOQfgaW5.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-JyEZmDlh.js → diagram-UQ7AKVKN-DMMyB2sa.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-DGBXNEif.js → diagram-VSXAHHWV-DZR1nzPa.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-KljR5Glh.js → diagram-VX7I27RA-DzAwLHuI.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-8FQ2FrUP.js → diagram-Z3DM3KII-D98d_Dgt.js} +1 -1
- package/dist-ksadk/assets/{dist-87AsLuzD.js → dist-A55dc8b7.js} +1 -1
- package/dist-ksadk/assets/{dist-Bnqrfpu2.js → dist-BEzIxZLq.js} +1 -1
- package/dist-ksadk/assets/{dist-DrFtl2Jz.js → dist-BHIb3Gvv.js} +1 -1
- package/dist-ksadk/assets/{dist-DWRPGuTp.js → dist-BIR7kFKG.js} +1 -1
- package/dist-ksadk/assets/{dist-Cj5PFf9x.js → dist-BpZXLW0T.js} +1 -1
- package/dist-ksadk/assets/{dist-Cs1lGsiM.js → dist-By8HbjFH.js} +1 -1
- package/dist-ksadk/assets/{dist-dxCMjEJX.js → dist-C1uAMNTH.js} +1 -1
- package/dist-ksadk/assets/{dist-CSguAs4w.js → dist-CN8MSPvo.js} +1 -1
- package/dist-ksadk/assets/{dist-BmrsRv90.js → dist-CpHO1CY1.js} +1 -1
- package/dist-ksadk/assets/{dist-Bls_5FN6.js → dist-CxzBVC3N.js} +1 -1
- package/dist-ksadk/assets/{dist-DRAbZJl6.js → dist-D9GtQnvz.js} +1 -1
- package/dist-ksadk/assets/{dist-CAnMW8ay.js → dist-DHiOUJJ-.js} +1 -1
- package/dist-ksadk/assets/{dist-Bo4bAcyo.js → dist-Du5KbDTg.js} +1 -1
- package/dist-ksadk/assets/{dist-CTkYhw0e.js → dist-DxBl1V2_.js} +1 -1
- package/dist-ksadk/assets/{dist-BUvPmCJJ.js → dist-E1uwqlZY.js} +1 -1
- package/dist-ksadk/assets/{dist-C-4NaB6S.js → dist-HuJDn2Nr.js} +1 -1
- package/dist-ksadk/assets/{dist-DQSR5gJm.js → dist-MMIlBueM.js} +1 -1
- package/dist-ksadk/assets/{dist-Ps_8XMpQ.js → dist-U51Rn7ZW.js} +1 -1
- package/dist-ksadk/assets/{dist-BRaujO8W.js → dist-VLWgeZIu.js} +1 -1
- package/dist-ksadk/assets/{dist-BblTQEdU.js → dist-X8Mgnqit.js} +1 -1
- package/dist-ksadk/assets/{dist-DW_Mhac3.js → dist-glVlUB_d.js} +1 -1
- package/dist-ksadk/assets/{dist-AnEuKlWI.js → dist-q8rONmMl.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-BDy_T6BJ.js → ebnfDiagram-PWID7BFC-X4mBLaw3.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-Cb9mxU2v.js → erDiagram-SSCWMZ5O-ClybQoOy.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV--IdqCKdV.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BsidNZBX.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-CI-NY47s.js → ganttDiagram-EL5Y4UJY-Dc_fWiA_.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-BTqI4bBo.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DZBPuEz2.js → gitGraphDiagram-WWUBYQGX-0eEV_CEC.js} +1 -1
- package/dist-ksadk/assets/index-B0DeBpyZ.js +1132 -0
- package/dist-ksadk/assets/index-DEVfafsU.css +2 -0
- package/dist-ksadk/assets/info-A6RAGUB7-CXZCoW0H.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-BGVB1ufk.js → infoDiagram-RXCK75RN-mZoyw4Xh.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-C-pPrser.js → ishikawaDiagram-5VMMS53U-CO8OkxgJ.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-mqH7Ax1g.js → journeyDiagram-EYS64GPL-Ci8GpXLK.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-D1g0NfmY.js → kanban-definition-3QL26DDD-lgD5AYON.js} +1 -1
- package/dist-ksadk/assets/{katex-DBFpex0b.js → katex-Chn0O-XC.js} +1 -1
- package/dist-ksadk/assets/{linear-H9vrIL3e.js → linear-ffygyi0f.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-CTwOsmSy.js → mermaid-parser.core-CGPz1_57.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-P24ajxwA.js → mindmap-definition-FBJOCRG2-DRaJyZGQ.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-DoZlIRtk.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-CIAjyVaA.js → pegDiagram-XKGWAZYB-BbQ2QDD3.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-Dl-IyMT_.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-Cpg76g41.js → pieDiagram-E7YTZNPT-BcB_c4Ka.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-COa_uah3.js → quadrantDiagram-AXDQQJYC-CK3csxHk.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-Bp8MemxX.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-BmKyKako.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-DhFitwOH.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-TB8LQz8q.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-B3J1Rtq9.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-CDiUen7V.js → railroadDiagram-O6MQD6OU-D1YLglVU.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-4tmvHR-z.js → requirementDiagram-EFPCY7ZU-VeyqOcw3.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-cmOQFKfb.js → sankeyDiagram-P5KCCOFB-uskDVCah.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-C87BVo37.js → sequenceDiagram-WJ2MYXX4-CmoPC4aR.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-BD2400H2.js → sizeCapture-X5ZJPWSS-DzV4X5WN.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DaxlblQk.js → stateDiagram-HBIQ2CUA-BJehrZbH.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-DkujIgVj.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-M7GAwJZ9.js → swimlanes-XN3QIQJK-Bn4tEi27.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-Blb1TQ9Q.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-Cq_BUN6-.js → timeline-definition-24CTP7MA-bSkaKxqF.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-C5Ez-6L4.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-WdNvoGQV.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-BTAMWn-b.js → vennDiagram-4TSXK5OY-ClO6s5iT.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-DCCceTuX.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-Dnvpr9wl.js → wardleyDiagram-VM6X3IG4-CcaYar33.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-D838CKvY.js → xychartDiagram-S5SC5T6Z-DdiPl8uB.js} +1 -1
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/AttachmentPreview-DHvWB_a-.js +1956 -0
- package/dist-lib/{ConnectedComposer-B2lm1bBF.js → ConnectedComposer-CuN3EUnU.js} +220 -217
- package/dist-lib/{ConnectedMessageList-BumlD3Zk.js → ConnectedMessageList-CT-MJJkJ.js} +419 -417
- package/dist-lib/{WorkspacePanelContainer-CcI-iqlE.js → WorkspacePanelContainer-Jg9bUmLJ.js} +324 -324
- package/dist-lib/{a2ui-CWVTKJ6O.js → a2ui-DridcTyF.js} +1656 -408
- package/dist-lib/chat-composer.js +2 -2
- package/dist-lib/chat-timeline.js +3 -3
- package/dist-lib/components/chat/A2UIActivityMessage.d.ts +1 -0
- package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
- package/dist-lib/components/chat/ChatComposer.d.ts +2 -1
- package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
- package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/ConnectedComposer.d.ts +2 -1
- package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
- package/dist-lib/components/chat/ExecutionPermissionMenu.d.ts.map +1 -1
- package/dist-lib/components/chat/InteractionA2uiSurface.d.ts +6 -1
- package/dist-lib/components/chat/InteractionA2uiSurface.d.ts.map +1 -1
- package/dist-lib/components/chat/InteractionTray.d.ts +3 -1
- package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -1
- package/dist-lib/components/chat/JsonSchemaInputForm.d.ts.map +1 -1
- package/dist-lib/components/chat/McpAuthorizationCard.d.ts +8 -0
- package/dist-lib/components/chat/McpAuthorizationCard.d.ts.map +1 -0
- package/dist-lib/components/ui/button.d.ts +12 -0
- package/dist-lib/components/ui/button.d.ts.map +1 -0
- package/dist-lib/components.js +13 -13
- package/dist-lib/conversation.js +2 -2
- package/dist-lib/core/api/facade.d.ts +1 -0
- 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/presentation.d.ts.map +1 -1
- package/dist-lib/core/conversation/runtime-ingress.d.ts.map +1 -1
- package/dist-lib/core/interaction/a2ui-approval.d.ts +20 -0
- package/dist-lib/core/interaction/a2ui-approval.d.ts.map +1 -0
- package/dist-lib/core/interaction/adapters/agui.d.ts.map +1 -1
- package/dist-lib/core/interaction/adapters/normalize.d.ts +2 -0
- package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -1
- package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -1
- package/dist-lib/core/interaction/client.d.ts.map +1 -1
- package/dist-lib/core/interaction/legacy-a2ui.d.ts +5 -0
- package/dist-lib/core/interaction/legacy-a2ui.d.ts.map +1 -0
- package/dist-lib/core/interaction/pending.d.ts +4 -0
- package/dist-lib/core/interaction/pending.d.ts.map +1 -0
- package/dist-lib/core/mcp-authorization/contract.d.ts +5 -0
- package/dist-lib/core/mcp-authorization/contract.d.ts.map +1 -0
- package/dist-lib/core/mcp-authorization/normalize.d.ts +4 -0
- package/dist-lib/core/mcp-authorization/normalize.d.ts.map +1 -0
- package/dist-lib/core/mcp-authorization/recovery.d.ts +5 -0
- package/dist-lib/core/mcp-authorization/recovery.d.ts.map +1 -0
- package/dist-lib/core/mcp-authorization/types.d.ts +20 -0
- package/dist-lib/core/mcp-authorization/types.d.ts.map +1 -0
- package/dist-lib/core/run/agui.d.ts.map +1 -1
- package/dist-lib/core/run/engine.d.ts.map +1 -1
- package/dist-lib/core/teams/cloudContracts.d.ts +15 -15
- package/dist-lib/{feedback-CuC5jRi_.js → feedback-CaSZOBD2.js} +98 -86
- package/dist-lib/hooks/useAgentChat.d.ts.map +1 -1
- package/dist-lib/hooks/useInteractions.d.ts +1 -0
- package/dist-lib/hooks/useInteractions.d.ts.map +1 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
- package/dist-lib/hooks.js +19 -18
- package/dist-lib/permission-2NpSBuq3.js +25 -0
- package/dist-lib/{persisted-session-history-Mg7yqvHj.js → persisted-session-history-D_1AtH5H.js} +536 -1473
- package/dist-lib/runtime.js +272 -270
- package/dist-lib/session-events-6PXUoAkP.js +1225 -0
- package/dist-lib/stores/bootstrap.d.ts.map +1 -1
- package/dist-lib/stores/execution-permission.d.ts +2 -0
- package/dist-lib/stores/execution-permission.d.ts.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/types/capabilities.d.ts +4 -0
- package/dist-lib/types/capabilities.d.ts.map +1 -1
- package/dist-lib/{useSessionLifecycle-BsS84-O4.js → useSessionLifecycle-daQg0sqQ.js} +961 -1974
- package/dist-lib/utils/persisted-session-history.d.ts.map +1 -1
- package/dist-lib/utils/run-progress.d.ts.map +1 -1
- package/dist-lib/utils/workspace.d.ts +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-B_LhRes-.js +0 -1
- package/dist-ksadk/assets/channel-Bq55bwo_.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-Dace2ujW.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-l9qDDu33.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-l9qDDu33.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-jtPBpAp-.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DMz2Fvu-.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-clcQL_nf.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-DDQIXIFD.js +0 -1
- package/dist-ksadk/assets/index-4lKAP0g-.js +0 -1132
- package/dist-ksadk/assets/index-DMqhW2cV.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-CnWfuiwa.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-C1REqCW5.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-CzQ5iT3d.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-d5WzegFP.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-fRIdWxzy.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-7joOoyeT.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BAgBPuog.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-Bq9jPeDZ.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BAnVAqLb.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DzYhp6ae.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-Kl6y61te.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-Bt1G2wC0.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-CNYQTyja.js +0 -1
- package/dist-lib/AttachmentPreview-DkgZ9Upi.js +0 -1545
- package/dist-lib/execution-permission-UqLwHTJS.js +0 -89
- package/dist-lib/json-value-DnHp0582.js +0 -186
- package/dist-lib/tool-display-DTiRdghE.js +0 -64
|
@@ -1,52 +1,49 @@
|
|
|
1
|
-
import { a as e, i as t,
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import { i as
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useCallback as H, useEffect as U, useMemo as Oe, useRef as W, useState as ke } from "react";
|
|
10
|
-
import { z as G } from "zod";
|
|
11
|
-
import { HttpAgent as Ae, buildResumeArray as je } from "@ag-ui/client";
|
|
1
|
+
import { a as e, i as t, t as n } from "./capabilities-lJRDfRg9.js";
|
|
2
|
+
import { $ as r, B as i, E as a, I as o, L as s, M as c, N as l, O as u, Q as d, S as f, W as p, X as m, Y as h, Z as g, a as _, c as v, d as y, et as b, f as x, k as S, l as C, o as w, p as T, q as E, r as D, s as O, t as k, u as A, v as j, z as M } from "./a2ui-DridcTyF.js";
|
|
3
|
+
import { a as ee, d as N, i as P, l as F, m as I, o as L, r as R, s as z, t as B, u as V } from "./session-events-6PXUoAkP.js";
|
|
4
|
+
import { a as H, c as te, d as U, i as ne, l as re, n as ie, o as ae, r as oe, s as se, t as ce, u as W } from "./feedback-CaSZOBD2.js";
|
|
5
|
+
import { a as le, d as ue, f as de, p as G, s as fe } from "./reducer-mbYiX0wz.js";
|
|
6
|
+
import { C as pe, S as me, _ as he, a as ge, b as _e, c as ve, d as ye, f as be, g as xe, h as Se, i as Ce, l as we, m as Te, n as Ee, o as De, p as Oe, r as ke, s as Ae, u as je, w as Me, x as Ne, y as Pe } from "./persisted-session-history-D_1AtH5H.js";
|
|
7
|
+
import { useCallback as K, useEffect as q, useMemo as Fe, useRef as J, useState as Ie } from "react";
|
|
8
|
+
import { HttpAgent as Le, buildResumeArray as Re } from "@ag-ui/client";
|
|
12
9
|
//#region src/api/client.ts
|
|
13
|
-
var
|
|
10
|
+
var Y = class extends Error {
|
|
14
11
|
code;
|
|
15
12
|
detail;
|
|
16
13
|
constructor(e, t, n) {
|
|
17
14
|
super(t), this.name = "ApiError", this.code = e, this.detail = n;
|
|
18
15
|
}
|
|
19
|
-
},
|
|
16
|
+
}, X = class extends Error {
|
|
20
17
|
constructor(e = "请求已取消") {
|
|
21
18
|
super(e), this.name = "CancelledError";
|
|
22
19
|
}
|
|
23
|
-
},
|
|
24
|
-
async function
|
|
20
|
+
}, ze = "/agentengine/api/v1";
|
|
21
|
+
async function Be(e) {
|
|
25
22
|
let t = await e.text(), n = {};
|
|
26
23
|
try {
|
|
27
24
|
n = t ? JSON.parse(t) : {};
|
|
28
25
|
} catch {
|
|
29
26
|
let n = e.headers.get("content-type")?.toLowerCase() || "";
|
|
30
|
-
if ((e.status === 401 || e.status === 403) && (n.includes("text/html") || t.trimStart().startsWith("<"))) throw new
|
|
27
|
+
if ((e.status === 401 || e.status === 403) && (n.includes("text/html") || t.trimStart().startsWith("<"))) throw new Y(e.status, "访问会话已失效,请从 Dashboard 或 Studio 的云端会话重新打开 Agent。");
|
|
31
28
|
if (!e.ok) {
|
|
32
29
|
let n = t.trim();
|
|
33
|
-
throw new
|
|
30
|
+
throw new Y(e.status, n && n.length <= 256 && !n.startsWith("<") ? n : e.statusText || `HTTP ${e.status}`, t);
|
|
34
31
|
}
|
|
35
|
-
throw new
|
|
32
|
+
throw new Y(-2, "响应格式异常");
|
|
36
33
|
}
|
|
37
|
-
if (!e.ok) throw new
|
|
38
|
-
if (n?.Code !== void 0 && n.Code !== 0) throw new
|
|
34
|
+
if (!e.ok) throw new Y(e.status, n?.Message || `HTTP ${e.status}`, n);
|
|
35
|
+
if (n?.Code !== void 0 && n.Code !== 0) throw new Y(n.Code, n.Message || "请求失败", n);
|
|
39
36
|
return n.Data;
|
|
40
37
|
}
|
|
41
|
-
function
|
|
42
|
-
throw e instanceof DOMException && e.name === "AbortError" ? new
|
|
38
|
+
function Ve(e) {
|
|
39
|
+
throw e instanceof DOMException && e.name === "AbortError" ? new X() : e;
|
|
43
40
|
}
|
|
44
|
-
var
|
|
41
|
+
var He = class {
|
|
45
42
|
fetcher;
|
|
46
43
|
baseUrl;
|
|
47
44
|
agentId;
|
|
48
45
|
constructor(e = {}) {
|
|
49
|
-
this.fetcher = e.fetch || ((e, t) => globalThis.fetch(e, t)), this.baseUrl = String(e.baseUrl ||
|
|
46
|
+
this.fetcher = e.fetch || ((e, t) => globalThis.fetch(e, t)), this.baseUrl = String(e.baseUrl || ze).replace(/\/+$/, ""), this.agentId = String(e.agentId || "").trim();
|
|
50
47
|
}
|
|
51
48
|
actionUrl(e) {
|
|
52
49
|
return `${this.baseUrl}/${e}`;
|
|
@@ -67,9 +64,9 @@ var Fe = class {
|
|
|
67
64
|
signal: n?.signal
|
|
68
65
|
});
|
|
69
66
|
} catch (e) {
|
|
70
|
-
throw
|
|
67
|
+
throw Ve(e);
|
|
71
68
|
}
|
|
72
|
-
return
|
|
69
|
+
return Be(r);
|
|
73
70
|
}
|
|
74
71
|
async postFormAction(e, t, n) {
|
|
75
72
|
let r;
|
|
@@ -81,9 +78,9 @@ var Fe = class {
|
|
|
81
78
|
signal: n?.signal
|
|
82
79
|
});
|
|
83
80
|
} catch (e) {
|
|
84
|
-
throw
|
|
81
|
+
throw Ve(e);
|
|
85
82
|
}
|
|
86
|
-
return
|
|
83
|
+
return Be(r);
|
|
87
84
|
}
|
|
88
85
|
async getResource(e, t, n) {
|
|
89
86
|
let r = this.agentId && !t.AgentId ? {
|
|
@@ -93,13 +90,13 @@ var Fe = class {
|
|
|
93
90
|
try {
|
|
94
91
|
o = await this.fetcher(a, { signal: n?.signal });
|
|
95
92
|
} catch (e) {
|
|
96
|
-
throw
|
|
93
|
+
throw Ve(e);
|
|
97
94
|
}
|
|
98
|
-
if (!o.ok) throw new
|
|
95
|
+
if (!o.ok) throw new Y(o.status, `资源获取失败: ${o.statusText}`);
|
|
99
96
|
try {
|
|
100
97
|
return n?.asText ? await o.text() : await o.blob();
|
|
101
98
|
} catch {
|
|
102
|
-
throw new
|
|
99
|
+
throw new Y(-3, "文件读取失败");
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
102
|
async streamAction(e, t, n) {
|
|
@@ -115,10 +112,10 @@ var Fe = class {
|
|
|
115
112
|
signal: n?.signal
|
|
116
113
|
});
|
|
117
114
|
} catch (e) {
|
|
118
|
-
throw
|
|
115
|
+
throw Ve(e);
|
|
119
116
|
}
|
|
120
|
-
if (!r.ok) throw await
|
|
121
|
-
if ((r.headers.get("content-type")?.toLowerCase() || "").includes("application/json") && await
|
|
117
|
+
if (!r.ok) throw await Be(r), new Y(r.status, `流式请求失败: ${r.statusText}`);
|
|
118
|
+
if ((r.headers.get("content-type")?.toLowerCase() || "").includes("application/json") && await Be(r.clone()), !r.body) throw new Y(-1, "无法获取响应流");
|
|
122
119
|
return r.body;
|
|
123
120
|
}
|
|
124
121
|
async streamGetAction(e, t, n) {
|
|
@@ -132,235 +129,16 @@ var Fe = class {
|
|
|
132
129
|
signal: n?.signal
|
|
133
130
|
});
|
|
134
131
|
} catch (e) {
|
|
135
|
-
throw
|
|
132
|
+
throw Ve(e);
|
|
136
133
|
}
|
|
137
|
-
if (!o.ok || o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
138
|
-
if (!o.body) throw new
|
|
134
|
+
if (!o.ok || o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new Y(502, "流式订阅未返回事件流", await Be(o));
|
|
135
|
+
if (!o.body) throw new Y(-1, "无法获取响应流");
|
|
139
136
|
return o.body;
|
|
140
137
|
}
|
|
141
|
-
},
|
|
142
|
-
constructor(e) {
|
|
143
|
-
super(e), this.name = "ContractMismatchError";
|
|
144
|
-
}
|
|
145
|
-
}, ze = new Set([
|
|
146
|
-
"schema_version",
|
|
147
|
-
"command_id",
|
|
148
|
-
"status",
|
|
149
|
-
"message_id",
|
|
150
|
-
"run_id",
|
|
151
|
-
"accepted_seq",
|
|
152
|
-
"error"
|
|
153
|
-
]), Be = G.object({
|
|
154
|
-
code: G.string().min(1),
|
|
155
|
-
message: G.string(),
|
|
156
|
-
retryable: G.boolean(),
|
|
157
|
-
details: G.record(G.string(), G.unknown()).optional()
|
|
158
|
-
});
|
|
159
|
-
function Ve(e) {
|
|
160
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return He(e);
|
|
161
|
-
let t = e;
|
|
162
|
-
if ("schema_version" in t || !("SchemaVersion" in t)) return He(e);
|
|
163
|
-
let n = {
|
|
164
|
-
SchemaVersion: "schema_version",
|
|
165
|
-
CommandId: "command_id",
|
|
166
|
-
Status: "status",
|
|
167
|
-
MessageId: "message_id",
|
|
168
|
-
RunId: "run_id",
|
|
169
|
-
AcceptedSeq: "accepted_seq",
|
|
170
|
-
Error: "error"
|
|
171
|
-
};
|
|
172
|
-
return He(Object.fromEntries(Object.entries(t).map(([e, t]) => [n[e] ?? e, t])));
|
|
173
|
-
}
|
|
174
|
-
function He(e) {
|
|
175
|
-
let t = G.object({
|
|
176
|
-
schema_version: G.literal(1),
|
|
177
|
-
command_id: G.string().min(1),
|
|
178
|
-
status: G.enum([
|
|
179
|
-
"accepted",
|
|
180
|
-
"duplicate",
|
|
181
|
-
"rejected",
|
|
182
|
-
"unsupported",
|
|
183
|
-
"queue_full",
|
|
184
|
-
"persistence_uncertain"
|
|
185
|
-
]),
|
|
186
|
-
message_id: G.string().min(1).nullable().optional(),
|
|
187
|
-
run_id: G.string().min(1).nullable().optional(),
|
|
188
|
-
accepted_seq: G.number().int().min(0).nullable().optional(),
|
|
189
|
-
error: Be.nullable().optional()
|
|
190
|
-
}).passthrough().safeParse(e);
|
|
191
|
-
if (!t.success) throw new J(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);
|
|
192
|
-
let n = t.data;
|
|
193
|
-
if ((n.status === "rejected" || n.status === "unsupported" || n.status === "queue_full" || n.status === "persistence_uncertain") && !n.error) throw new J(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);
|
|
194
|
-
let r = {};
|
|
195
|
-
for (let [e, t] of Object.entries(n)) ze.has(e) || (r[e] = t);
|
|
196
|
-
let i = n.error ? {
|
|
197
|
-
...n.error,
|
|
198
|
-
extensions: {}
|
|
199
|
-
} : null;
|
|
200
|
-
return {
|
|
201
|
-
schema_version: 1,
|
|
202
|
-
command_id: n.command_id,
|
|
203
|
-
status: n.status,
|
|
204
|
-
message_id: n.message_id ?? null,
|
|
205
|
-
run_id: n.run_id ?? null,
|
|
206
|
-
accepted_seq: n.accepted_seq ?? null,
|
|
207
|
-
error: i,
|
|
208
|
-
extensions: r
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function Ue(e) {
|
|
212
|
-
try {
|
|
213
|
-
return n(e);
|
|
214
|
-
} catch (e) {
|
|
215
|
-
throw new J(`RuntimeCapabilityMatrix/v1 mismatch: ${e instanceof Error ? e.message : String(e)}`);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
var We = new Set([
|
|
219
|
-
"schema_version",
|
|
220
|
-
"event_id",
|
|
221
|
-
"session_id",
|
|
222
|
-
"seq",
|
|
223
|
-
"timestamp",
|
|
224
|
-
"family",
|
|
225
|
-
"family_version",
|
|
226
|
-
"event_type",
|
|
227
|
-
"payload",
|
|
228
|
-
"run_id",
|
|
229
|
-
"causation_id",
|
|
230
|
-
"correlation_id",
|
|
231
|
-
"actor_ref"
|
|
232
|
-
]), Ge = new Map([["control", 1], ["runtime", 2]]), Ke = {
|
|
233
|
-
schema_version: ["schemaVersion", "SchemaVersion"],
|
|
234
|
-
event_id: ["eventId", "EventId"],
|
|
235
|
-
session_id: ["sessionId", "SessionId"],
|
|
236
|
-
seq: [
|
|
237
|
-
"seqId",
|
|
238
|
-
"SeqId",
|
|
239
|
-
"Seq"
|
|
240
|
-
],
|
|
241
|
-
timestamp: ["Timestamp"],
|
|
242
|
-
family: ["Family"],
|
|
243
|
-
family_version: ["familyVersion", "FamilyVersion"],
|
|
244
|
-
event_type: ["eventType", "EventType"],
|
|
245
|
-
payload: ["Payload"],
|
|
246
|
-
run_id: ["runId", "RunId"],
|
|
247
|
-
causation_id: ["causationId", "CausationId"],
|
|
248
|
-
correlation_id: ["correlationId", "CorrelationId"],
|
|
249
|
-
actor_ref: ["actorRef", "ActorRef"]
|
|
250
|
-
};
|
|
251
|
-
function qe(e) {
|
|
252
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
253
|
-
let t = e, n = { ...t };
|
|
254
|
-
for (let [e, r] of Object.entries(Ke)) {
|
|
255
|
-
if (n[e] === void 0) {
|
|
256
|
-
let i = r.find((e) => t[e] !== void 0);
|
|
257
|
-
i && (n[e] = t[i]);
|
|
258
|
-
}
|
|
259
|
-
for (let e of r) delete n[e];
|
|
260
|
-
}
|
|
261
|
-
return n;
|
|
262
|
-
}
|
|
263
|
-
var Je = G.object({
|
|
264
|
-
schema_version: G.literal(1),
|
|
265
|
-
event_id: G.string().min(1),
|
|
266
|
-
session_id: G.string().min(1),
|
|
267
|
-
seq: G.number().int().min(0),
|
|
268
|
-
timestamp: G.string().min(1),
|
|
269
|
-
family: G.string().min(1),
|
|
270
|
-
family_version: G.number().int().min(1),
|
|
271
|
-
event_type: G.string().min(1),
|
|
272
|
-
payload: G.record(G.string(), G.unknown()),
|
|
273
|
-
run_id: G.string().min(1).nullable().optional(),
|
|
274
|
-
causation_id: G.string().min(1).nullable().optional(),
|
|
275
|
-
correlation_id: G.string().min(1).nullable().optional(),
|
|
276
|
-
actor_ref: G.string().min(1).nullable().optional()
|
|
277
|
-
}).passthrough();
|
|
278
|
-
function Ye(e) {
|
|
279
|
-
let t = Je.safeParse(qe(e));
|
|
280
|
-
if (!t.success) return {
|
|
281
|
-
ok: !1,
|
|
282
|
-
error: new J(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)
|
|
283
|
-
};
|
|
284
|
-
let n = t.data, r = Ge.get(n.family);
|
|
285
|
-
if (r !== void 0 && n.family_version !== r) return {
|
|
286
|
-
ok: !1,
|
|
287
|
-
error: new J(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)
|
|
288
|
-
};
|
|
289
|
-
let i = {};
|
|
290
|
-
for (let [e, t] of Object.entries(n)) We.has(e) || (i[e] = t);
|
|
291
|
-
return {
|
|
292
|
-
ok: !0,
|
|
293
|
-
value: {
|
|
294
|
-
schema_version: 1,
|
|
295
|
-
event_id: n.event_id,
|
|
296
|
-
session_id: n.session_id,
|
|
297
|
-
seq: n.seq,
|
|
298
|
-
timestamp: n.timestamp,
|
|
299
|
-
family: n.family,
|
|
300
|
-
family_version: n.family_version,
|
|
301
|
-
event_type: n.event_type,
|
|
302
|
-
payload: n.payload,
|
|
303
|
-
run_id: n.run_id ?? null,
|
|
304
|
-
causation_id: n.causation_id ?? null,
|
|
305
|
-
correlation_id: n.correlation_id ?? null,
|
|
306
|
-
actor_ref: n.actor_ref ?? null,
|
|
307
|
-
extensions: i
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function Xe(e) {
|
|
312
|
-
let t = G.object({
|
|
313
|
-
schema_version: G.literal(1),
|
|
314
|
-
agent_instance_id: G.string().min(1),
|
|
315
|
-
instance_state: G.enum([
|
|
316
|
-
"ready",
|
|
317
|
-
"degraded",
|
|
318
|
-
"unavailable"
|
|
319
|
-
]),
|
|
320
|
-
session_id: G.string().min(1).nullable().optional(),
|
|
321
|
-
active_run_id: G.string().min(1).nullable().optional(),
|
|
322
|
-
active_run_state: G.enum([
|
|
323
|
-
"pending",
|
|
324
|
-
"running",
|
|
325
|
-
"paused",
|
|
326
|
-
"waiting"
|
|
327
|
-
]).nullable().optional(),
|
|
328
|
-
inbox_depth: G.number().int().min(0),
|
|
329
|
-
activation_id: G.string().min(1).nullable().optional(),
|
|
330
|
-
lease_expires_at: G.string().min(1).nullable().optional(),
|
|
331
|
-
capability: G.unknown()
|
|
332
|
-
}).passthrough().safeParse(e);
|
|
333
|
-
if (!t.success) throw new J(`AgentStatusSnapshot/v1 mismatch: ${t.error.message}`);
|
|
334
|
-
let n = t.data, r = {};
|
|
335
|
-
for (let e of Object.keys(n)) [
|
|
336
|
-
"schema_version",
|
|
337
|
-
"agent_instance_id",
|
|
338
|
-
"instance_state",
|
|
339
|
-
"session_id",
|
|
340
|
-
"active_run_id",
|
|
341
|
-
"active_run_state",
|
|
342
|
-
"inbox_depth",
|
|
343
|
-
"activation_id",
|
|
344
|
-
"lease_expires_at",
|
|
345
|
-
"capability"
|
|
346
|
-
].includes(e) || (r[e] = n[e]);
|
|
347
|
-
return {
|
|
348
|
-
schema_version: 1,
|
|
349
|
-
agent_instance_id: n.agent_instance_id,
|
|
350
|
-
instance_state: n.instance_state,
|
|
351
|
-
session_id: n.session_id ?? null,
|
|
352
|
-
active_run_id: n.active_run_id ?? null,
|
|
353
|
-
active_run_state: n.active_run_state ?? null,
|
|
354
|
-
inbox_depth: n.inbox_depth,
|
|
355
|
-
activation_id: n.activation_id ?? null,
|
|
356
|
-
lease_expires_at: n.lease_expires_at ?? null,
|
|
357
|
-
capability: Ue(n.capability),
|
|
358
|
-
extensions: r
|
|
359
|
-
};
|
|
360
|
-
}
|
|
138
|
+
}, Ue = new He(), We = (e, t, n) => Ue.streamAction(e, t, n), Ge = (e, t, n) => Ue.streamGetAction(e, t, n);
|
|
361
139
|
//#endregion
|
|
362
140
|
//#region src/api/messages.ts
|
|
363
|
-
function
|
|
141
|
+
function Ke(e) {
|
|
364
142
|
return {
|
|
365
143
|
Messages: e.Messages ?? [],
|
|
366
144
|
LatestSeqId: Number.isFinite(Number(e.LatestSeqId)) ? Number(e.LatestSeqId) : 0,
|
|
@@ -378,11 +156,16 @@ function Ze(e) {
|
|
|
378
156
|
}
|
|
379
157
|
//#endregion
|
|
380
158
|
//#region src/core/api/facade.ts
|
|
381
|
-
var
|
|
159
|
+
var qe = class {
|
|
382
160
|
client;
|
|
383
161
|
constructor(e = {}) {
|
|
384
|
-
this.client = new
|
|
162
|
+
this.client = new He(e);
|
|
385
163
|
}
|
|
164
|
+
mcpAuthorization = async (e, t, n, r) => this.client.postJsonAction(e, {
|
|
165
|
+
WaitId: t,
|
|
166
|
+
...r ? { SessionId: r } : {},
|
|
167
|
+
...n ? { ExpectedRevision: n } : {}
|
|
168
|
+
});
|
|
386
169
|
async compactSession(e, t) {
|
|
387
170
|
return this.client.postJsonAction("CompactSession", {
|
|
388
171
|
AgentId: e,
|
|
@@ -441,7 +224,7 @@ var Qe = class {
|
|
|
441
224
|
};
|
|
442
225
|
}
|
|
443
226
|
async listSessionMessages(e, t) {
|
|
444
|
-
return
|
|
227
|
+
return Ke(await this.client.postJsonAction("ListSessionMessages", {
|
|
445
228
|
AgentId: t?.agentId,
|
|
446
229
|
SessionId: e,
|
|
447
230
|
AfterSeqId: t?.afterSeqId,
|
|
@@ -479,7 +262,13 @@ var Qe = class {
|
|
|
479
262
|
}, t);
|
|
480
263
|
}
|
|
481
264
|
async runAgent(e, t) {
|
|
482
|
-
return this.client.streamAction("RunAgent",
|
|
265
|
+
return this.client.streamAction("RunAgent", {
|
|
266
|
+
...e,
|
|
267
|
+
Extensions: {
|
|
268
|
+
...e.Extensions,
|
|
269
|
+
"mcp.authorization": M
|
|
270
|
+
}
|
|
271
|
+
}, t);
|
|
483
272
|
}
|
|
484
273
|
async resumeRun(e, t) {
|
|
485
274
|
return this.client.streamAction("ResumeRun", {
|
|
@@ -500,14 +289,14 @@ var Qe = class {
|
|
|
500
289
|
}, t);
|
|
501
290
|
}
|
|
502
291
|
async submitControl(e, t) {
|
|
503
|
-
return
|
|
292
|
+
return S(await this.client.postJsonAction("SubmitAgentControl", {
|
|
504
293
|
CommandType: e.command_type,
|
|
505
294
|
IdempotencyKey: e.idempotency_key,
|
|
506
295
|
Payload: e.payload
|
|
507
296
|
}, t));
|
|
508
297
|
}
|
|
509
298
|
async submitInteraction(e, t) {
|
|
510
|
-
return
|
|
299
|
+
return S(await this.client.postJsonAction("SubmitInteraction", { ...e }, t));
|
|
511
300
|
}
|
|
512
301
|
async getAgentStatus(e) {
|
|
513
302
|
return this.client.postJsonAction("GetAgentStatus", {}, e);
|
|
@@ -569,34 +358,34 @@ var Qe = class {
|
|
|
569
358
|
async uploadFile(e, t) {
|
|
570
359
|
return this.client.postFormAction("UploadFile", e, t);
|
|
571
360
|
}
|
|
572
|
-
},
|
|
573
|
-
function
|
|
361
|
+
}, Je = "ksadk:webui:selected-session:";
|
|
362
|
+
function Ye(e) {
|
|
574
363
|
return String(e || "").trim() || "default-agent";
|
|
575
364
|
}
|
|
576
|
-
function
|
|
365
|
+
function Xe(e) {
|
|
577
366
|
if (e && typeof e.getItem == "function") return e;
|
|
578
367
|
try {
|
|
579
368
|
if (typeof window < "u" && window.localStorage) return window.localStorage;
|
|
580
369
|
} catch {}
|
|
581
370
|
return null;
|
|
582
371
|
}
|
|
583
|
-
function
|
|
584
|
-
return
|
|
372
|
+
function Ze(e) {
|
|
373
|
+
return g.key(`${Je}${Ye(e)}`);
|
|
585
374
|
}
|
|
586
|
-
function
|
|
587
|
-
let n =
|
|
375
|
+
function Qe(e, t) {
|
|
376
|
+
let n = Xe(t);
|
|
588
377
|
if (!n) return null;
|
|
589
378
|
try {
|
|
590
|
-
return String(n.getItem(
|
|
379
|
+
return String(n.getItem(Ze(e)) || "").trim() || null;
|
|
591
380
|
} catch {
|
|
592
381
|
return null;
|
|
593
382
|
}
|
|
594
383
|
}
|
|
595
|
-
function
|
|
596
|
-
if (!
|
|
597
|
-
let r =
|
|
384
|
+
function $e(e, t, n) {
|
|
385
|
+
if (!g.writable) return;
|
|
386
|
+
let r = Xe(n);
|
|
598
387
|
if (!r) return;
|
|
599
|
-
let i =
|
|
388
|
+
let i = Ze(e), a = String(t || "").trim();
|
|
600
389
|
try {
|
|
601
390
|
if (a) {
|
|
602
391
|
r.setItem(i, a);
|
|
@@ -605,7 +394,7 @@ function it(e, t, n) {
|
|
|
605
394
|
r.removeItem(i);
|
|
606
395
|
} catch {}
|
|
607
396
|
}
|
|
608
|
-
function
|
|
397
|
+
function et(e, t) {
|
|
609
398
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
610
399
|
let n = String(t || "").trim();
|
|
611
400
|
if (n && e.some((e) => String(e?.SessionId || "").trim() === n)) return n;
|
|
@@ -615,7 +404,7 @@ function at(e, t) {
|
|
|
615
404
|
}
|
|
616
405
|
return null;
|
|
617
406
|
}
|
|
618
|
-
function
|
|
407
|
+
function tt(e, t, n) {
|
|
619
408
|
let r = Array.isArray(e) ? e : [], i = Array.isArray(t) ? t : [], a = n instanceof Set ? n : new Set(Array.isArray(n) ? n : []);
|
|
620
409
|
if (a.size === 0) return r;
|
|
621
410
|
let o = new Set(r.map((e) => String(e?.SessionId || "").trim()).filter(Boolean)), s = i.filter((e) => {
|
|
@@ -626,71 +415,71 @@ function ot(e, t, n) {
|
|
|
626
415
|
}
|
|
627
416
|
//#endregion
|
|
628
417
|
//#region src/hooks/useBootstrap.ts
|
|
629
|
-
function
|
|
630
|
-
return e instanceof
|
|
418
|
+
function nt(e) {
|
|
419
|
+
return e instanceof Y && (e.code === 401 || e.code === 403) ? "auth-required" : "error";
|
|
631
420
|
}
|
|
632
|
-
function
|
|
421
|
+
function rt(e) {
|
|
633
422
|
if (!Array.isArray(e)) return ["responses", "chat_completions"];
|
|
634
423
|
let t = e.filter((e) => e === "responses" || e === "chat_completions");
|
|
635
424
|
return t.length > 0 ? t : ["responses", "chat_completions"];
|
|
636
425
|
}
|
|
637
|
-
var
|
|
638
|
-
async function
|
|
426
|
+
var it = new qe();
|
|
427
|
+
async function at(e, t = it) {
|
|
639
428
|
try {
|
|
640
429
|
let n = await t.listAgentModels(e), r = n?.Models;
|
|
641
|
-
Array.isArray(r) &&
|
|
430
|
+
Array.isArray(r) && d.getState().upsertModels(r);
|
|
642
431
|
let i = n;
|
|
643
|
-
i?.Current && !
|
|
432
|
+
i?.Current && !d.getState().selectedModel && d.getState().setSelectedModel(String(i.Current)), i?.Source && d.getState().setModelSource(String(i.Source));
|
|
644
433
|
} catch (e) {
|
|
645
434
|
console.error("Failed to fetch models:", e);
|
|
646
435
|
} finally {
|
|
647
|
-
|
|
436
|
+
d.getState().setModelCatalogLoaded(!0);
|
|
648
437
|
}
|
|
649
438
|
}
|
|
650
|
-
function
|
|
651
|
-
|
|
439
|
+
function ot(e, r, a = it, o) {
|
|
440
|
+
q(() => {
|
|
652
441
|
let s = new AbortController();
|
|
653
442
|
return (async () => {
|
|
654
|
-
|
|
443
|
+
i.getState().setStatus("loading");
|
|
655
444
|
try {
|
|
656
|
-
let
|
|
445
|
+
let c = o ?? await a.getAgentUiBootstrap(r, { signal: s.signal });
|
|
657
446
|
if (s.signal.aborted) return;
|
|
658
|
-
let
|
|
659
|
-
if (
|
|
660
|
-
let e = String(
|
|
661
|
-
|
|
447
|
+
let l = c, u = l?.Agent, f = String(u?.AgentId || "default-agent");
|
|
448
|
+
if (i.getState().setAgentId(f), u?.Name) {
|
|
449
|
+
let e = String(u.Name);
|
|
450
|
+
i.getState().setAgentName(e), document.title = e;
|
|
662
451
|
}
|
|
663
|
-
let
|
|
664
|
-
|
|
665
|
-
let
|
|
666
|
-
|
|
667
|
-
let
|
|
668
|
-
|
|
669
|
-
let
|
|
670
|
-
|
|
452
|
+
let p = String(u?.Framework || "").trim().toLowerCase();
|
|
453
|
+
i.getState().setAgentFramework(p);
|
|
454
|
+
let m = t(c);
|
|
455
|
+
i.getState().setCapabilities(m), i.getState().setApiFormats(rt(m.HostedChat.ApiFormats)), i.getState().setAccessMode(String(l?.AccessMode || "Owner"));
|
|
456
|
+
let h = m.WorkspaceFiles && l?.WorkspaceFiles ? l.WorkspaceFiles : null;
|
|
457
|
+
i.getState().setWorkspaceFiles(h), h || b.getState().setWorkspacePanelOpen(!1), n(m) && e.fetchSessions(f, Qe(f));
|
|
458
|
+
let g = l?.Model;
|
|
459
|
+
g?.id && (d.getState().setSelectedModel(g.id), d.getState().upsertModels([g]), d.getState().setModelSource(g.source || "")), at(f, a), i.getState().setStatus("ready");
|
|
671
460
|
} catch (e) {
|
|
672
461
|
if (s.signal.aborted) return;
|
|
673
462
|
console.error("Failed to fetch bootstrap:", e);
|
|
674
|
-
let t =
|
|
675
|
-
|
|
463
|
+
let t = nt(e);
|
|
464
|
+
i.getState().setStatus(t, t === "auth-required" ? "当前访问链接未授权或已过期。" : "无法加载 Agent 配置,请稍后重试。");
|
|
676
465
|
}
|
|
677
466
|
})(), () => s.abort();
|
|
678
467
|
}, [
|
|
679
|
-
|
|
680
|
-
|
|
468
|
+
a,
|
|
469
|
+
r,
|
|
681
470
|
o
|
|
682
471
|
]);
|
|
683
472
|
}
|
|
684
473
|
//#endregion
|
|
685
474
|
//#region src/hooks/useFeedback.ts
|
|
686
|
-
function
|
|
475
|
+
function st(e) {
|
|
687
476
|
let { agentId: t, currentSessionId: n, isStreaming: r, api: i, submitDraft: a } = e;
|
|
688
477
|
return {
|
|
689
|
-
submitResponseFeedback:
|
|
478
|
+
submitResponseFeedback: K(async (e) => {
|
|
690
479
|
if (!n) return;
|
|
691
480
|
let r = null;
|
|
692
|
-
|
|
693
|
-
let n =
|
|
481
|
+
U.getState().patchMessages((t) => {
|
|
482
|
+
let n = ce(t, {
|
|
694
483
|
messageId: e.message.id,
|
|
695
484
|
rating: e.rating,
|
|
696
485
|
comment: e.comment || ""
|
|
@@ -698,19 +487,19 @@ function ft(e) {
|
|
|
698
487
|
return r = n.previousFeedback, n.nextMessages;
|
|
699
488
|
});
|
|
700
489
|
try {
|
|
701
|
-
let r =
|
|
490
|
+
let r = ae((await i.upsertResponseFeedback(oe({
|
|
702
491
|
agentId: t,
|
|
703
492
|
sessionId: n,
|
|
704
493
|
message: e.message,
|
|
705
494
|
rating: e.rating,
|
|
706
495
|
comment: e.comment || ""
|
|
707
496
|
})))?.Feedback);
|
|
708
|
-
r &&
|
|
497
|
+
r && U.getState().patchMessages((t) => H(t, {
|
|
709
498
|
messageId: e.message.id,
|
|
710
499
|
feedback: r
|
|
711
500
|
}));
|
|
712
501
|
} catch (t) {
|
|
713
|
-
console.error("Failed to submit response feedback:", t),
|
|
502
|
+
console.error("Failed to submit response feedback:", t), U.getState().patchMessages((t) => se(t, {
|
|
714
503
|
messageId: e.message.id,
|
|
715
504
|
previousFeedback: r
|
|
716
505
|
}));
|
|
@@ -720,18 +509,18 @@ function ft(e) {
|
|
|
720
509
|
n,
|
|
721
510
|
i
|
|
722
511
|
]),
|
|
723
|
-
deleteResponseFeedback:
|
|
512
|
+
deleteResponseFeedback: K(async (e) => {
|
|
724
513
|
if (!n) return;
|
|
725
514
|
let r = e.feedback ? { ...e.feedback } : null;
|
|
726
|
-
|
|
515
|
+
U.getState().patchMessages((t) => ne(t, { messageId: e.id }));
|
|
727
516
|
try {
|
|
728
|
-
await i.deleteResponseFeedback(
|
|
517
|
+
await i.deleteResponseFeedback(ie({
|
|
729
518
|
agentId: t,
|
|
730
519
|
sessionId: n,
|
|
731
520
|
message: e
|
|
732
521
|
}));
|
|
733
522
|
} catch (t) {
|
|
734
|
-
console.error("Failed to delete response feedback:", t),
|
|
523
|
+
console.error("Failed to delete response feedback:", t), U.getState().patchMessages((t) => se(t, {
|
|
735
524
|
messageId: e.id,
|
|
736
525
|
previousFeedback: r
|
|
737
526
|
}));
|
|
@@ -741,11 +530,11 @@ function ft(e) {
|
|
|
741
530
|
n,
|
|
742
531
|
i
|
|
743
532
|
]),
|
|
744
|
-
respondToApproval:
|
|
533
|
+
respondToApproval: K(async (e) => !e.approvalRequestId || r || !await a("", [], [{
|
|
745
534
|
type: "mcp_approval_response",
|
|
746
535
|
approval_request_id: e.approvalRequestId,
|
|
747
536
|
approve: e.approve
|
|
748
|
-
}], e.previousResponseId) ? !1 : (
|
|
537
|
+
}], e.previousResponseId) ? !1 : (h.getState().currentSessionId === n && U.getState().patchMessages((t) => t.map((t) => {
|
|
749
538
|
let n = e.approve ? "approved" : "rejected", r = (t) => e.approve && t === "paused" ? "running" : e.approve ? t : "completed";
|
|
750
539
|
return {
|
|
751
540
|
...t,
|
|
@@ -771,891 +560,46 @@ function ft(e) {
|
|
|
771
560
|
};
|
|
772
561
|
}
|
|
773
562
|
//#endregion
|
|
774
|
-
//#region src/core/
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
"cancelled",
|
|
786
|
-
"expired"
|
|
787
|
-
]), ht = new Set([
|
|
788
|
-
"approved",
|
|
789
|
-
"rejected",
|
|
790
|
-
"submitted",
|
|
791
|
-
"cancelled",
|
|
792
|
-
"expired"
|
|
793
|
-
]);
|
|
794
|
-
function gt(e) {
|
|
795
|
-
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
796
|
-
}
|
|
797
|
-
function _t(e) {
|
|
798
|
-
return typeof e == "string" && e.length > 0 ? e : null;
|
|
799
|
-
}
|
|
800
|
-
var vt = "人工确认", yt = "本次运行需要人工处理后才能继续。";
|
|
801
|
-
function bt(e) {
|
|
802
|
-
let t = String(e.kind || "approval"), n = String(e.status || "pending"), r = String(e.outcome || ""), i = gt(e.presentation), a = i ? gt(i.a2ui) : null, o;
|
|
803
|
-
if (n === "resolved" && Object.hasOwn(e, "response")) try {
|
|
804
|
-
o = { response: x(e.response) };
|
|
805
|
-
} catch {}
|
|
806
|
-
return {
|
|
807
|
-
interactionId: e.interactionId,
|
|
808
|
-
sessionId: e.sessionId,
|
|
809
|
-
runId: _t(e.runId),
|
|
810
|
-
kind: pt.has(t) ? t : "custom",
|
|
811
|
-
title: typeof e.title == "string" && e.title ? e.title : vt,
|
|
812
|
-
message: typeof e.message == "string" && e.message ? e.message : yt,
|
|
813
|
-
requestSchema: gt(e.requestSchema),
|
|
814
|
-
presentation: a ? { a2ui: {
|
|
815
|
-
wireVersion: String(a.wire_version ?? a.wireVersion ?? ""),
|
|
816
|
-
catalogDigest: String(a.catalog_digest ?? a.catalogDigest ?? ""),
|
|
817
|
-
messages: Array.isArray(a.messages) ? a.messages.filter((e) => typeof e == "object") : []
|
|
818
|
-
} } : null,
|
|
819
|
-
status: mt.has(n) ? n : "pending",
|
|
820
|
-
revision: Number.isFinite(Number(e.revision)) && Number(e.revision) > 0 ? Number(e.revision) : 1,
|
|
821
|
-
createdAt: _t(e.createdAt) || (/* @__PURE__ */ new Date()).toISOString(),
|
|
822
|
-
expiresAt: _t(e.expiresAt),
|
|
823
|
-
resolvedAt: _t(e.resolvedAt),
|
|
824
|
-
actor: _t(e.actor),
|
|
825
|
-
outcome: ht.has(r) ? r : null,
|
|
826
|
-
responseSummary: _t(e.responseSummary),
|
|
827
|
-
...o,
|
|
828
|
-
source: e.source,
|
|
829
|
-
extensions: e.extensions || {}
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
//#endregion
|
|
833
|
-
//#region src/core/interaction/store.ts
|
|
834
|
-
var xt = class {
|
|
835
|
-
records = /* @__PURE__ */ new Map();
|
|
836
|
-
terminalRuns = /* @__PURE__ */ new Set();
|
|
837
|
-
rejectedCommands = /* @__PURE__ */ new Map();
|
|
838
|
-
listeners = /* @__PURE__ */ new Set();
|
|
839
|
-
key(e, t) {
|
|
840
|
-
return `${e}\u0000${t}`;
|
|
841
|
-
}
|
|
842
|
-
runKey(e, t) {
|
|
843
|
-
return `${e}\u0000${t}`;
|
|
844
|
-
}
|
|
845
|
-
subscribe(e) {
|
|
846
|
-
return this.listeners.add(e), () => {
|
|
847
|
-
this.listeners.delete(e);
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
emit(e) {
|
|
851
|
-
for (let t of this.listeners) t(e);
|
|
852
|
-
}
|
|
853
|
-
get(e, t) {
|
|
854
|
-
return this.records.get(this.key(e, t)) || null;
|
|
855
|
-
}
|
|
856
|
-
listPending(e) {
|
|
857
|
-
return this.listAll(e).filter((e) => e.status === "pending");
|
|
858
|
-
}
|
|
859
|
-
listAll(e) {
|
|
860
|
-
return this.all().filter((t) => t.sessionId === e);
|
|
861
|
-
}
|
|
862
|
-
all() {
|
|
863
|
-
return [...this.records.values()].sort((e, t) => String(e.createdAt).localeCompare(String(t.createdAt)));
|
|
864
|
-
}
|
|
865
|
-
upsert(e) {
|
|
866
|
-
let t = this.get(e.sessionId, e.interactionId);
|
|
867
|
-
e.runId && !_(e.status) && !_(t?.status ?? "pending") && this.terminalRuns.has(this.runKey(e.sessionId, e.runId)) && (e = {
|
|
868
|
-
...e,
|
|
869
|
-
status: "expired",
|
|
870
|
-
outcome: "expired",
|
|
871
|
-
resolvedAt: e.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
872
|
-
responseSummary: e.responseSummary ?? "运行已结束"
|
|
873
|
-
});
|
|
874
|
-
let n, r;
|
|
875
|
-
return t ? _(t.status) && !_(e.status) ? (n = {
|
|
876
|
-
...t,
|
|
877
|
-
title: t.title === "人工确认" ? e.title : t.title,
|
|
878
|
-
message: t.message === "本次运行需要人工处理后才能继续。" ? e.message : t.message,
|
|
879
|
-
kind: t.kind === "approval" && !t.requestSchema ? e.kind : t.kind,
|
|
880
|
-
requestSchema: t.requestSchema ?? e.requestSchema,
|
|
881
|
-
presentation: t.presentation ?? e.presentation
|
|
882
|
-
}, r = {
|
|
883
|
-
type: "interaction_updated",
|
|
884
|
-
interaction: n
|
|
885
|
-
}) : e.revision < t.revision || e.revision === t.revision && _(t.status) && !_(e.status) || t.status === "failed" && t.extensions.rejected_command_id && e.revision === t.revision && !_(e.status) || t.status === "resolving" && !_(e.status) ? (n = t, r = {
|
|
886
|
-
type: "interaction_updated",
|
|
887
|
-
interaction: n
|
|
888
|
-
}) : _(e.status) ? (n = {
|
|
889
|
-
...t,
|
|
890
|
-
...e,
|
|
891
|
-
title: t.title || e.title,
|
|
892
|
-
kind: t.kind || e.kind,
|
|
893
|
-
message: t.message || e.message,
|
|
894
|
-
runId: e.runId ?? t.runId,
|
|
895
|
-
requestSchema: t.requestSchema ?? e.requestSchema,
|
|
896
|
-
presentation: t.presentation ?? e.presentation,
|
|
897
|
-
actor: e.actor ?? t.actor,
|
|
898
|
-
outcome: e.outcome ?? t.outcome,
|
|
899
|
-
resolvedAt: e.resolvedAt ?? t.resolvedAt,
|
|
900
|
-
responseSummary: e.responseSummary ?? t.responseSummary,
|
|
901
|
-
...Object.hasOwn(t, "response") ? { response: t.response } : {}
|
|
902
|
-
}, r = {
|
|
903
|
-
type: "interaction_resolved",
|
|
904
|
-
interaction: n
|
|
905
|
-
}) : (n = {
|
|
906
|
-
...t,
|
|
907
|
-
...e
|
|
908
|
-
}, r = {
|
|
909
|
-
type: "interaction_updated",
|
|
910
|
-
interaction: n
|
|
911
|
-
}) : (n = e, r = {
|
|
912
|
-
type: "interaction_requested",
|
|
913
|
-
interaction: n
|
|
914
|
-
}), this.records.set(this.key(n.sessionId, n.interactionId), n), this.emit(r), r;
|
|
915
|
-
}
|
|
916
|
-
markResolving(e, t) {
|
|
917
|
-
let n = this.get(e, t);
|
|
918
|
-
if (!n || !["pending", "failed"].includes(n.status)) return;
|
|
919
|
-
let r = { ...n.extensions };
|
|
920
|
-
delete r.submit_error, delete r.submit_command_id, this.records.set(this.key(e, t), {
|
|
921
|
-
...n,
|
|
922
|
-
status: "resolving",
|
|
923
|
-
extensions: r
|
|
924
|
-
}), this.emit({
|
|
925
|
-
type: "interaction_updated",
|
|
926
|
-
interaction: this.get(e, t)
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
resolveLocally(e, t, n) {
|
|
930
|
-
let r = this.get(e, t);
|
|
931
|
-
if (!r) return;
|
|
932
|
-
let i = {
|
|
933
|
-
...r,
|
|
934
|
-
...n,
|
|
935
|
-
resolvedAt: n.resolvedAt ?? r.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
936
|
-
revision: n.revision ?? r.revision
|
|
937
|
-
};
|
|
938
|
-
this.records.set(this.key(e, t), i), this.emit({
|
|
939
|
-
type: "interaction_resolved",
|
|
940
|
-
interaction: i
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
recordCommand(e, t, n) {
|
|
944
|
-
let r = this.get(e, t);
|
|
945
|
-
if (!r || !n || _(r.status)) return;
|
|
946
|
-
this.records.set(this.key(e, t), {
|
|
947
|
-
...r,
|
|
948
|
-
extensions: {
|
|
949
|
-
...r.extensions,
|
|
950
|
-
submit_command_id: n
|
|
951
|
-
}
|
|
952
|
-
});
|
|
953
|
-
let i = this.rejectedCommands.get(this.key(e, n));
|
|
954
|
-
i && this.rejectCommand(e, n, i);
|
|
955
|
-
}
|
|
956
|
-
rejectCommand(e, t, n) {
|
|
957
|
-
if (!(!e || !t)) {
|
|
958
|
-
this.rejectedCommands.set(this.key(e, t), n);
|
|
959
|
-
for (let r of this.listAll(e)) {
|
|
960
|
-
if (r.extensions.submit_command_id !== t) continue;
|
|
961
|
-
this.markFailed(e, r.interactionId, {
|
|
962
|
-
code: n,
|
|
963
|
-
message: `提交未执行(${n}),请重试`,
|
|
964
|
-
retryable: !0
|
|
965
|
-
});
|
|
966
|
-
let i = this.get(e, r.interactionId);
|
|
967
|
-
i?.status === "failed" && this.records.set(this.key(e, r.interactionId), {
|
|
968
|
-
...i,
|
|
969
|
-
extensions: {
|
|
970
|
-
...i.extensions,
|
|
971
|
-
rejected_command_id: t
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
recordIdempotencyKey(e, t, n) {
|
|
978
|
-
let r = this.get(e, t);
|
|
979
|
-
if (!r) return;
|
|
980
|
-
let i = {
|
|
981
|
-
...r,
|
|
982
|
-
extensions: {
|
|
983
|
-
...r.extensions,
|
|
984
|
-
idempotency_key: n
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
this.records.set(this.key(e, t), i), this.emit({
|
|
988
|
-
type: "interaction_updated",
|
|
989
|
-
interaction: i
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
markFailed(e, t, n) {
|
|
993
|
-
let r = this.get(e, t);
|
|
994
|
-
if (!r || _(r.status)) return;
|
|
995
|
-
let i = {
|
|
996
|
-
...r,
|
|
997
|
-
status: "failed",
|
|
998
|
-
extensions: {
|
|
999
|
-
...r.extensions,
|
|
1000
|
-
submit_error: n
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
this.records.set(this.key(e, t), i), this.emit({
|
|
1004
|
-
type: "interaction_updated",
|
|
1005
|
-
interaction: i
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
revertToPending(e, t) {
|
|
1009
|
-
let n = this.get(e, t);
|
|
1010
|
-
if (!n || n.status !== "resolving") return;
|
|
1011
|
-
let r = {
|
|
1012
|
-
...n,
|
|
1013
|
-
status: "pending"
|
|
1014
|
-
};
|
|
1015
|
-
this.records.set(this.key(e, t), r), this.emit({
|
|
1016
|
-
type: "interaction_updated",
|
|
1017
|
-
interaction: r
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
markRunTerminal(e, t) {
|
|
1021
|
-
if (!(!e || !t)) {
|
|
1022
|
-
this.terminalRuns.add(this.runKey(e, t));
|
|
1023
|
-
for (let n of this.listAll(e)) {
|
|
1024
|
-
if (n.runId !== t || _(n.status)) continue;
|
|
1025
|
-
let r = {
|
|
1026
|
-
...n,
|
|
1027
|
-
status: "expired",
|
|
1028
|
-
outcome: "expired",
|
|
1029
|
-
resolvedAt: n.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1030
|
-
responseSummary: n.responseSummary ?? "运行已结束"
|
|
1031
|
-
};
|
|
1032
|
-
this.records.set(this.key(e, n.interactionId), r), this.emit({
|
|
1033
|
-
type: "interaction_resolved",
|
|
1034
|
-
interaction: r
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
markSessionTerminal(e) {
|
|
1040
|
-
if (!e) return;
|
|
1041
|
-
let t = new Set(this.listAll(e).filter((e) => !_(e.status)).map((e) => e.runId).filter((e) => !!e));
|
|
1042
|
-
for (let n of t) this.markRunTerminal(e, n);
|
|
1043
|
-
for (let t of this.listAll(e)) {
|
|
1044
|
-
if (t.runId || _(t.status)) continue;
|
|
1045
|
-
let n = {
|
|
1046
|
-
...t,
|
|
1047
|
-
status: "expired",
|
|
1048
|
-
outcome: "expired",
|
|
1049
|
-
resolvedAt: t.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1050
|
-
responseSummary: t.responseSummary ?? "运行已结束"
|
|
1051
|
-
};
|
|
1052
|
-
this.records.set(this.key(e, t.interactionId), n), this.emit({
|
|
1053
|
-
type: "interaction_resolved",
|
|
1054
|
-
interaction: n
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
remove(e, t) {
|
|
1059
|
-
let n = this.key(e, t);
|
|
1060
|
-
this.records.has(n) && (this.records.delete(n), this.emit({
|
|
1061
|
-
type: "interaction_removed",
|
|
1062
|
-
interactionId: t
|
|
1063
|
-
}));
|
|
1064
|
-
}
|
|
1065
|
-
clearSession(e) {
|
|
1066
|
-
for (let t of this.listAll(e)) this.remove(e, t.interactionId);
|
|
1067
|
-
let t = `${e}\u0000`;
|
|
1068
|
-
for (let e of this.rejectedCommands.keys()) e.startsWith(t) && this.rejectedCommands.delete(e);
|
|
1069
|
-
for (let e of this.terminalRuns) e.startsWith(t) && this.terminalRuns.delete(e);
|
|
1070
|
-
}
|
|
1071
|
-
}, St = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, Ct = (e, t) => Object.hasOwn(e, t) ? e[t] : void 0, wt = (e) => e.replace(/~/g, "~0").replace(/\//g, "~1"), Tt = /^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u;
|
|
1072
|
-
function Et(e) {
|
|
1073
|
-
let [t, n = "0"] = e.toLowerCase().split("e"), [r, i = ""] = t.replace(/^-/, "").split("."), a = (r + i).replace(/^0+/, "").replace(/0+$/, "");
|
|
1074
|
-
if (!a) return "0";
|
|
1075
|
-
let o = (r + i).length - (r + i).replace(/0+$/, "").length;
|
|
1076
|
-
return `${e.startsWith("-") ? "-" : ""}${a}e${Number(n) - i.length + o}`;
|
|
1077
|
-
}
|
|
1078
|
-
function Dt(e, t) {
|
|
1079
|
-
if (typeof e != "string") return e;
|
|
1080
|
-
if (t.includes("boolean") && (e === "true" || e === "false")) return e === "true";
|
|
1081
|
-
if (!t.some((e) => e === "number" || e === "integer") || e.length > 1024 || !Tt.test(e)) return e;
|
|
1082
|
-
let n = Number(e);
|
|
1083
|
-
return !Number.isFinite(n) || Et(e) !== Et(JSON.stringify(n)) || !t.includes("number") && !Number.isSafeInteger(n) ? e : n === 0 ? 0 : n;
|
|
1084
|
-
}
|
|
1085
|
-
function Ot(e, t) {
|
|
1086
|
-
let n = x(t), r = h(e), i = 0, a = (e, t) => {
|
|
1087
|
-
try {
|
|
1088
|
-
return r(e, t);
|
|
1089
|
-
} catch {
|
|
1090
|
-
return !1;
|
|
1091
|
-
}
|
|
1092
|
-
}, o = (t) => {
|
|
1093
|
-
if (typeof t != "string" || !t.startsWith("#")) return;
|
|
1094
|
-
let n;
|
|
1095
|
-
try {
|
|
1096
|
-
n = decodeURIComponent(t.slice(1));
|
|
1097
|
-
} catch {
|
|
563
|
+
//#region src/core/mcp-authorization/recovery.ts
|
|
564
|
+
function ct(e, t, n, r) {
|
|
565
|
+
let i = /* @__PURE__ */ new Map(), a = !1;
|
|
566
|
+
function o(e) {
|
|
567
|
+
clearTimeout(i.get(e)), i.delete(e);
|
|
568
|
+
}
|
|
569
|
+
function c(c) {
|
|
570
|
+
if (c.sessionId !== t || !c.runId) return;
|
|
571
|
+
let l = c.runId, u = c.interactionId;
|
|
572
|
+
if (c.status !== "pending" || re(c)) {
|
|
573
|
+
o(u);
|
|
1098
574
|
return;
|
|
1099
575
|
}
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
};
|
|
1110
|
-
}, s = (e, t, n, r = 0) => {
|
|
1111
|
-
let c = St(e);
|
|
1112
|
-
if (++i > 8192 || r > 48 || !c || a(t, n)) return n;
|
|
1113
|
-
let l = n, u = o(c.$ref);
|
|
1114
|
-
u && (n = s(u.node, u.path, n, r + 1)), Array.isArray(c.allOf) && c.allOf.forEach((e, i) => {
|
|
1115
|
-
n = s(e, `${t}/allOf/${i}`, n, r + 1);
|
|
1116
|
-
});
|
|
1117
|
-
let d = Array.isArray(c.oneOf) ? "oneOf" : "anyOf", f = c[d];
|
|
1118
|
-
if (Array.isArray(f)) {
|
|
1119
|
-
let e = f.map((e, i) => s(e, `${t}/${d}/${i}`, n, r + 1)).filter((e) => a(t, e)), i = new Map(e.map((e) => [JSON.stringify(e), e]));
|
|
1120
|
-
return i.size === 1 ? [...i.values()][0] : l;
|
|
1121
|
-
}
|
|
1122
|
-
if (Array.isArray(n)) {
|
|
1123
|
-
let e = Array.isArray(c.items), i = e ? c.items : Array.isArray(c.prefixItems) ? c.prefixItems : [], a = e ? c.additionalItems : c.items;
|
|
1124
|
-
return n.map((n, o) => s(o < i.length ? i[o] : a, o < i.length ? `${t}/${e ? "items" : "prefixItems"}/${o}` : `${t}/${e ? "additionalItems" : "items"}`, n, r + 1));
|
|
1125
|
-
}
|
|
1126
|
-
let p = St(n);
|
|
1127
|
-
if (p) {
|
|
1128
|
-
let e = {}, n = St(c.properties) || {}, i = St(c.patternProperties) || {};
|
|
1129
|
-
for (let [a, o] of Object.entries(p)) {
|
|
1130
|
-
let l = o, u = !1;
|
|
1131
|
-
Object.hasOwn(n, a) && (l = s(n[a], `${t}/properties/${wt(a)}`, l, r + 1), u = !0);
|
|
1132
|
-
for (let [e, n] of Object.entries(i)) new RegExp(e, "u").test(a) && (l = s(n, `${t}/patternProperties/${wt(e)}`, l, r + 1), u = !0);
|
|
1133
|
-
!u && St(c.additionalProperties) && (l = s(c.additionalProperties, `${t}/additionalProperties`, l, r + 1)), Object.defineProperty(e, a, {
|
|
1134
|
-
value: l,
|
|
1135
|
-
enumerable: !0,
|
|
1136
|
-
configurable: !0,
|
|
1137
|
-
writable: !0
|
|
1138
|
-
});
|
|
1139
|
-
}
|
|
1140
|
-
return e;
|
|
1141
|
-
}
|
|
1142
|
-
return Dt(n, Array.isArray(c.type) ? c.type : [c.type]);
|
|
1143
|
-
}, c = s(e, "", n), l = u(e, c);
|
|
1144
|
-
if (!l.valid) throw TypeError(l.issues.join(";"));
|
|
1145
|
-
return c;
|
|
1146
|
-
}
|
|
1147
|
-
//#endregion
|
|
1148
|
-
//#region src/core/interaction/client.ts
|
|
1149
|
-
var kt = {
|
|
1150
|
-
approve: "approved",
|
|
1151
|
-
reject: "rejected",
|
|
1152
|
-
submit: "submitted",
|
|
1153
|
-
cancel: "cancelled"
|
|
1154
|
-
};
|
|
1155
|
-
function Y(e, t) {
|
|
1156
|
-
return {
|
|
1157
|
-
schema_version: 1,
|
|
1158
|
-
command_id: `local-${t}`,
|
|
1159
|
-
status: e,
|
|
1160
|
-
message_id: null,
|
|
1161
|
-
run_id: null,
|
|
1162
|
-
accepted_seq: null,
|
|
1163
|
-
error: null,
|
|
1164
|
-
extensions: {}
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
|
-
var At = class {
|
|
1168
|
-
store;
|
|
1169
|
-
deps;
|
|
1170
|
-
inFlight = /* @__PURE__ */ new Map();
|
|
1171
|
-
constructor(e) {
|
|
1172
|
-
this.deps = e, this.store = e.store || new xt();
|
|
1173
|
-
}
|
|
1174
|
-
listPending(e) {
|
|
1175
|
-
return this.store.listPending(e);
|
|
1176
|
-
}
|
|
1177
|
-
setInteractionV1Enabled(e) {
|
|
1178
|
-
this.deps.interactionV1Enabled = e;
|
|
1179
|
-
}
|
|
1180
|
-
subscribe(e) {
|
|
1181
|
-
return this.store.subscribe(e);
|
|
1182
|
-
}
|
|
1183
|
-
ingest(e) {
|
|
1184
|
-
this.store.upsert(e);
|
|
1185
|
-
}
|
|
1186
|
-
ingestHistory(e) {
|
|
1187
|
-
for (let t of e) this.store.upsert(t);
|
|
1188
|
-
for (let [e] of this.inFlight) {
|
|
1189
|
-
let t = this.store.all().find((t) => this.recordKey(t) === e);
|
|
1190
|
-
t && t.status !== "pending" && t.status !== "resolving" && this.inFlight.delete(e);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
recordKey(e) {
|
|
1194
|
-
return JSON.stringify([e.sessionId, e.interactionId]);
|
|
1195
|
-
}
|
|
1196
|
-
findByInteractionId(e, t) {
|
|
1197
|
-
if (t) return this.store.get(t, e);
|
|
1198
|
-
let n = this.store.all().filter((t) => t.interactionId === e);
|
|
1199
|
-
return n.length === 1 ? n[0] : null;
|
|
1200
|
-
}
|
|
1201
|
-
async respond(e) {
|
|
1202
|
-
let t = this.findByInteractionId(e.interactionId, e.sessionId);
|
|
1203
|
-
if (!t) return Y("rejected", e.interactionId);
|
|
1204
|
-
if (t.status === "resolved" || t.status === "cancelled" || t.status === "expired" || t.status === "resolving") return Y("duplicate", e.interactionId);
|
|
1205
|
-
try {
|
|
1206
|
-
x(e.response);
|
|
1207
|
-
} catch {
|
|
1208
|
-
return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1209
|
-
code: "input_response_invalid",
|
|
1210
|
-
message: "答案必须是合法 JSON 值。",
|
|
1211
|
-
retryable: !0
|
|
1212
|
-
}), Y("rejected", e.interactionId);
|
|
1213
|
-
}
|
|
1214
|
-
if (t.kind === "structured_input" && e.action === "submit" && t.requestSchema) try {
|
|
1215
|
-
e = {
|
|
1216
|
-
...e,
|
|
1217
|
-
response: Ot(t.requestSchema, e.response)
|
|
1218
|
-
};
|
|
1219
|
-
} catch (n) {
|
|
1220
|
-
return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1221
|
-
code: "input_response_invalid",
|
|
1222
|
-
message: n instanceof Error ? n.message : "答案不符合表单约束。",
|
|
1223
|
-
retryable: !0
|
|
1224
|
-
}), Y("rejected", e.interactionId);
|
|
1225
|
-
}
|
|
1226
|
-
if (t.source === "agui" && !this.deps.interactionV1Enabled && e.action !== "cancel" && e.response === null) return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1227
|
-
code: "input_transport_unsupported",
|
|
1228
|
-
message: "当前 AG-UI 传输不能提交根 null,请使用 Interaction/v1。",
|
|
1229
|
-
retryable: !1
|
|
1230
|
-
}), Y("rejected", e.interactionId);
|
|
1231
|
-
let n = e.idempotencyKey || p(e.interactionId, e.expectedRevision), r = t.extensions.rejected_command_id, i = r ? `${n}:retry-${r}` : n, a = this.recordKey(t), o = this.inFlight.get(a);
|
|
1232
|
-
if (o) return Y(o === i ? "duplicate" : "rejected", e.interactionId);
|
|
1233
|
-
this.inFlight.set(a, i), this.store.markResolving(t.sessionId, e.interactionId);
|
|
1234
|
-
let s = this.deps.interactionV1Enabled || t.source === "interaction_v1";
|
|
1235
|
-
try {
|
|
1236
|
-
if (!s && t.source === "responses" && this.deps.legacyResponsesApproval) {
|
|
1237
|
-
let n = t.extensions.previous_response_id;
|
|
1238
|
-
return await this.deps.legacyResponsesApproval(e.interactionId, e.action === "approve", ...typeof n == "string" && n ? [n] : []) === !1 ? (this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1239
|
-
code: "interaction_not_dispatched",
|
|
1240
|
-
message: "交互尚未提交,请稍后重试。",
|
|
1241
|
-
retryable: !0
|
|
1242
|
-
}), Y("rejected", e.interactionId)) : (this.resolveLocal(t, e, i), Y("accepted", e.interactionId));
|
|
1243
|
-
}
|
|
1244
|
-
if (!s && t.source === "agui" && this.deps.legacyAguiResume) return this.deps.legacyAguiResume(String(t.extensions.interrupt_id || e.interactionId), e.action === "cancel" ? "cancelled" : "resolved", e.response) ? (this.store.recordIdempotencyKey(t.sessionId, e.interactionId, i), Y("accepted", e.interactionId)) : (this.store.revertToPending(t.sessionId, e.interactionId), Y("rejected", e.interactionId));
|
|
1245
|
-
let n = He(await this.deps.submitInteraction({
|
|
1246
|
-
AgentId: this.deps.agentId,
|
|
1247
|
-
SessionId: t.sessionId,
|
|
1248
|
-
RunId: t.runId || "",
|
|
1249
|
-
InteractionId: e.interactionId,
|
|
1250
|
-
ExpectedRevision: e.expectedRevision,
|
|
1251
|
-
Action: e.action,
|
|
1252
|
-
Response: e.response,
|
|
1253
|
-
IdempotencyKey: i
|
|
1254
|
-
}));
|
|
1255
|
-
return n.status === "accepted" || n.status === "duplicate" ? (this.store.recordCommand(t.sessionId, e.interactionId, n.command_id), this.store.recordIdempotencyKey(t.sessionId, e.interactionId, i)) : n.status === "queue_full" ? this.store.revertToPending(t.sessionId, e.interactionId) : this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1256
|
-
code: n.error?.code ?? String(n.status),
|
|
1257
|
-
message: n.error?.message ?? `提交未通过(${n.status})`,
|
|
1258
|
-
retryable: n.error?.retryable ?? !1
|
|
1259
|
-
}), n;
|
|
1260
|
-
} catch (n) {
|
|
1261
|
-
let r = n instanceof Error ? n.message : String(n || "交互提交失败");
|
|
1262
|
-
throw this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1263
|
-
code: "interaction_submit_failed",
|
|
1264
|
-
message: r,
|
|
1265
|
-
retryable: !0
|
|
1266
|
-
}), n;
|
|
1267
|
-
} finally {
|
|
1268
|
-
this.inFlight.delete(a);
|
|
576
|
+
if (i.has(u)) return;
|
|
577
|
+
async function d() {
|
|
578
|
+
try {
|
|
579
|
+
let o = await n("GetMcpAuthorizationWait", u, void 0, t);
|
|
580
|
+
if (a || !i.has(u)) return;
|
|
581
|
+
let c = s(o, t, l), d = e.get(t, u);
|
|
582
|
+
c?.interactionId === u && d && c.revision > d.revision && (e.upsert(c), (c.status === "resolved" || c.status === "cancelled" || c.status === "expired") && r(t));
|
|
583
|
+
} catch {}
|
|
584
|
+
!a && i.has(u) && i.set(u, setTimeout(d, 3e3));
|
|
1269
585
|
}
|
|
586
|
+
i.set(u, setTimeout(d, 3e3));
|
|
1270
587
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
let i = t.action === "cancel" ? "cancelled" : "resolved";
|
|
1275
|
-
this.store.resolveLocally(e.sessionId, t.interactionId, {
|
|
1276
|
-
status: i,
|
|
1277
|
-
outcome: kt[t.action],
|
|
1278
|
-
actor: "user",
|
|
1279
|
-
responseSummary: e.kind === "structured_input" ? t.action === "cancel" ? "已取消" : "已提交" : d(t.action, t.response),
|
|
1280
|
-
revision: t.expectedRevision
|
|
1281
|
-
});
|
|
1282
|
-
let a = this.store.get(e.sessionId, t.interactionId);
|
|
1283
|
-
a && this.store.upsert({
|
|
1284
|
-
...a,
|
|
1285
|
-
extensions: {
|
|
1286
|
-
...a.extensions,
|
|
1287
|
-
idempotency_key: n
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
}, jt = new Set([
|
|
1292
|
-
"interaction.requested",
|
|
1293
|
-
"interaction_requested",
|
|
1294
|
-
"ksadk.interaction/v1.requested",
|
|
1295
|
-
"InteractionRequested",
|
|
1296
|
-
"approval.requested",
|
|
1297
|
-
"a2ui.interaction"
|
|
1298
|
-
]), Mt = new Set([
|
|
1299
|
-
"interaction.resolved",
|
|
1300
|
-
"interaction_resolved",
|
|
1301
|
-
"ksadk.interaction/v1.resolved",
|
|
1302
|
-
"InteractionResolved",
|
|
1303
|
-
"interaction.cancelled",
|
|
1304
|
-
"interaction.cancel",
|
|
1305
|
-
"interaction.expired",
|
|
1306
|
-
"approval.resolved",
|
|
1307
|
-
"a2ui.action"
|
|
1308
|
-
]);
|
|
1309
|
-
function X(e) {
|
|
1310
|
-
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
1311
|
-
}
|
|
1312
|
-
function Nt(e, t) {
|
|
1313
|
-
let n = X(e);
|
|
1314
|
-
if (!n) return null;
|
|
1315
|
-
let r = X(n.Content ?? n.content), i = X(r?.session_event ?? r?.sessionEvent), a = X(n.payload), o = i ?? (a?.family === "interaction" ? a : null) ?? (n.family === "interaction" ? n : null);
|
|
1316
|
-
if (o && o.family !== "interaction") return null;
|
|
1317
|
-
let s = o ?? n, c = String(s.event_type || s.EventType || "").trim();
|
|
1318
|
-
if (!c) return null;
|
|
1319
|
-
let l = X(s.payload ?? s.Content) ?? (o || {}), u = X(l.interaction) || X(l.Interaction) || X(l.interaction_request) || l, d = String(u.interaction_id || u.interactionId || u.InteractionId || u.approval_id || u.approvalId || l.interaction_id || l.interactionId || l.InteractionId || l.approval_id || l.approvalId || "");
|
|
1320
|
-
if (!d) return null;
|
|
1321
|
-
let f = String(s.session_id || s.SessionId || u.session_id || u.sessionId || t || "");
|
|
1322
|
-
if (!f) return null;
|
|
1323
|
-
if (jt.has(c)) {
|
|
1324
|
-
let e = X(u.request) || {}, t = X(u.presentation ?? e.presentation), n = {
|
|
1325
|
-
...X(u.extensions) || {},
|
|
1326
|
-
...u.detail === void 0 ? {} : { detail: u.detail },
|
|
1327
|
-
...(u.call_id ?? u.callId) === void 0 ? {} : { call_id: u.call_id ?? u.callId }
|
|
1328
|
-
};
|
|
1329
|
-
return bt({
|
|
1330
|
-
interactionId: d,
|
|
1331
|
-
sessionId: f,
|
|
1332
|
-
runId: u.run_id ?? u.runId ?? s.run_id ?? s.InvocationId,
|
|
1333
|
-
kind: c === "approval.requested" ? "approval" : u.kind === "form" ? "structured_input" : u.kind ?? e.kind ?? "approval",
|
|
1334
|
-
title: u.title ?? t?.title,
|
|
1335
|
-
message: u.message ?? u.description ?? X(u.detail)?.command ?? t?.description,
|
|
1336
|
-
requestSchema: u.request_schema ?? u.requestSchema ?? u.input_schema ?? u.inputSchema ?? u.RequestSchema ?? e.request_schema,
|
|
1337
|
-
presentation: t,
|
|
1338
|
-
status: "pending",
|
|
1339
|
-
revision: u.revision ?? 1,
|
|
1340
|
-
createdAt: u.created_at ?? u.createdAt ?? s.timestamp ?? s.Timestamp,
|
|
1341
|
-
expiresAt: u.expires_at ?? e.expires_at,
|
|
1342
|
-
source: "interaction_v1",
|
|
1343
|
-
extensions: n
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
if (Mt.has(c)) {
|
|
1347
|
-
let e = {
|
|
1348
|
-
...X(u.extensions) || {},
|
|
1349
|
-
...u.detail === void 0 ? {} : { detail: u.detail },
|
|
1350
|
-
...(u.call_id ?? u.callId) === void 0 ? {} : { call_id: u.call_id ?? u.callId }
|
|
1351
|
-
}, t = c === "interaction.cancelled" || c === "interaction.cancel" ? "cancelled" : c === "interaction.expired" ? "expired" : "resolved", n = String(l.outcome ?? u.outcome ?? u.status ?? "").toLowerCase(), r = String(l.action ?? u.action ?? l.name ?? u.name ?? "").toLowerCase(), i = n;
|
|
1352
|
-
i ||= r === "approve" ? "approved" : r === "reject" ? "rejected" : r === "submit" ? "submitted" : r === "cancel" || t === "cancelled" ? "cancelled" : t === "expired" ? "expired" : "submitted";
|
|
1353
|
-
let a = t === "resolved" ? "resolved" : t;
|
|
1354
|
-
return bt({
|
|
1355
|
-
interactionId: d,
|
|
1356
|
-
sessionId: f,
|
|
1357
|
-
runId: u.run_id ?? u.runId ?? s.run_id ?? s.InvocationId,
|
|
1358
|
-
kind: u.kind,
|
|
1359
|
-
title: u.title,
|
|
1360
|
-
message: u.message,
|
|
1361
|
-
requestSchema: u.request_schema,
|
|
1362
|
-
presentation: u.presentation,
|
|
1363
|
-
status: a,
|
|
1364
|
-
revision: u.revision,
|
|
1365
|
-
createdAt: u.created_at ?? s.timestamp,
|
|
1366
|
-
expiresAt: u.expires_at,
|
|
1367
|
-
resolvedAt: l.resolved_at ?? l.resolvedAt ?? u.resolved_at ?? u.resolvedAt ?? s.timestamp ?? s.Timestamp,
|
|
1368
|
-
actor: l.actor ?? u.actor ?? s.actor_ref,
|
|
1369
|
-
outcome: i,
|
|
1370
|
-
responseSummary: l.response_summary ?? u.response_summary ?? (r ? `${r}` : void 0),
|
|
1371
|
-
...Object.hasOwn(u, "response") ? { response: u.response } : Object.hasOwn(l, "response") ? { response: l.response } : !o && ["a2ui.action", "interaction.resolved"].includes(c) && Object.hasOwn(u, "data") ? { response: u.data } : {},
|
|
1372
|
-
source: "interaction_v1",
|
|
1373
|
-
extensions: e
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
return null;
|
|
1377
|
-
}
|
|
1378
|
-
//#endregion
|
|
1379
|
-
//#region src/core/interaction/adapters/responses.ts
|
|
1380
|
-
function Pt(e) {
|
|
1381
|
-
return !e.approvalRequestId || !e.sessionId ? null : bt({
|
|
1382
|
-
interactionId: e.approvalRequestId,
|
|
1383
|
-
sessionId: e.sessionId,
|
|
1384
|
-
runId: e.runId ?? null,
|
|
1385
|
-
kind: "approval",
|
|
1386
|
-
title: e.name ? `审批:${e.name}` : "人工确认",
|
|
1387
|
-
message: e.message || "本次运行需要人工审批后才能继续。",
|
|
1388
|
-
requestSchema: e.requestSchema ?? null,
|
|
1389
|
-
status: "pending",
|
|
1390
|
-
revision: 1,
|
|
1391
|
-
source: "responses",
|
|
1392
|
-
extensions: {
|
|
1393
|
-
...e.previousResponseId ? { previous_response_id: e.previousResponseId } : {},
|
|
1394
|
-
...e.approvalLevel ? { approval_level: e.approvalLevel } : {},
|
|
1395
|
-
...e.args ? { arguments: e.args } : {}
|
|
1396
|
-
}
|
|
588
|
+
e.listAll(t).forEach(c);
|
|
589
|
+
let l = e.subscribe((e) => {
|
|
590
|
+
e.type === "interaction_removed" ? o(e.interactionId) : c(e.interaction);
|
|
1397
591
|
});
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
for (let r of e) {
|
|
1402
|
-
let e = r && typeof r == "object" ? r : {}, i = String(e.id || e.question_id || e.name || `question_${n.length + 1}`), a = Array.isArray(e.options) ? e.options.map((e) => typeof e == "string" ? e : String(e?.id ?? e?.value ?? e?.label ?? "")).filter(Boolean) : [];
|
|
1403
|
-
t[i] = {
|
|
1404
|
-
type: "string",
|
|
1405
|
-
title: String(e.question || e.label || e.title || i),
|
|
1406
|
-
...a.length ? { enum: a } : {}
|
|
1407
|
-
}, n.push(i);
|
|
1408
|
-
}
|
|
1409
|
-
return {
|
|
1410
|
-
type: "object",
|
|
1411
|
-
properties: t,
|
|
1412
|
-
required: n,
|
|
1413
|
-
additionalProperties: !1
|
|
592
|
+
return () => {
|
|
593
|
+
a = !0, l();
|
|
594
|
+
for (let e of i.keys()) o(e);
|
|
1414
595
|
};
|
|
1415
596
|
}
|
|
1416
|
-
function It(e) {
|
|
1417
|
-
if (!e.questionId || !e.sessionId) return null;
|
|
1418
|
-
let t = Array.isArray(e.questions) ? e.questions : [];
|
|
1419
|
-
return bt({
|
|
1420
|
-
interactionId: e.questionId,
|
|
1421
|
-
sessionId: e.sessionId,
|
|
1422
|
-
runId: e.runId ?? null,
|
|
1423
|
-
kind: "structured_input",
|
|
1424
|
-
title: "询问",
|
|
1425
|
-
message: "Agent 需要你的选择后才能继续。",
|
|
1426
|
-
requestSchema: Ft(t),
|
|
1427
|
-
status: "pending",
|
|
1428
|
-
revision: 1,
|
|
1429
|
-
source: "responses",
|
|
1430
|
-
extensions: { questions: t }
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
//#endregion
|
|
1434
|
-
//#region src/core/interaction/adapters/agui.ts
|
|
1435
|
-
function Lt(e) {
|
|
1436
|
-
return !e.interruptId || !e.sessionId ? null : bt({
|
|
1437
|
-
interactionId: e.interruptId,
|
|
1438
|
-
sessionId: e.sessionId,
|
|
1439
|
-
runId: e.runId ?? null,
|
|
1440
|
-
kind: e.requestSchema ? "structured_input" : "approval",
|
|
1441
|
-
title: e.name ? `确认:${e.name}` : "人工确认",
|
|
1442
|
-
message: e.message || "本次运行需要人工确认后才能继续。",
|
|
1443
|
-
requestSchema: e.requestSchema ?? null,
|
|
1444
|
-
status: "pending",
|
|
1445
|
-
revision: 1,
|
|
1446
|
-
source: "agui",
|
|
1447
|
-
extensions: {
|
|
1448
|
-
interrupt_id: e.interruptId,
|
|
1449
|
-
...e.toolCallId ? { tool_call_id: e.toolCallId } : {},
|
|
1450
|
-
...e.reason ? { reason: e.reason } : {}
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
//#endregion
|
|
1455
|
-
//#region src/core/interaction/legacy-history.ts
|
|
1456
|
-
var Rt = (e) => typeof e == "string" && e ? e : void 0;
|
|
1457
|
-
function zt(e, t, n) {
|
|
1458
|
-
for (let r of n) {
|
|
1459
|
-
if (r.agentBlock && zt(e, t, r.agentBlock.messages), r.eventType === "conversation_item_v1") continue;
|
|
1460
|
-
let n = Object.values(r.tools || {}), i = [...n];
|
|
1461
|
-
for (let e of r.blocks || []) {
|
|
1462
|
-
if (e.type !== "tool" || !Rt(e.extra?.approvalRequestId)) continue;
|
|
1463
|
-
let t = e.extra || {}, r = n.find((e) => e.approvalRequestId === t.approvalRequestId);
|
|
1464
|
-
i.push({
|
|
1465
|
-
...r,
|
|
1466
|
-
name: e.toolName,
|
|
1467
|
-
args: e.args,
|
|
1468
|
-
status: e.status,
|
|
1469
|
-
approvalRequestId: Rt(t.approvalRequestId),
|
|
1470
|
-
approvalStatus: Rt(t.approvalStatus) || r?.approvalStatus,
|
|
1471
|
-
approvalProtocol: Rt(t.approvalProtocol) || r?.approvalProtocol,
|
|
1472
|
-
approvalMessage: Rt(t.approvalMessage) || r?.approvalMessage,
|
|
1473
|
-
previousResponseId: Rt(t.previousResponseId) || r?.previousResponseId
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
for (let n of i) {
|
|
1477
|
-
let i = n.approvalRequestId, a = n.approvalProtocol, o = n.approvalStatus || (n.status === "paused" ? "pending" : void 0);
|
|
1478
|
-
if (!i || !o || ![
|
|
1479
|
-
"pending",
|
|
1480
|
-
"approved",
|
|
1481
|
-
"rejected",
|
|
1482
|
-
"cancelled"
|
|
1483
|
-
].includes(o) || a !== "responses" && a !== "ag-ui") continue;
|
|
1484
|
-
let s = e.get(t, i);
|
|
1485
|
-
if (s && (s.source === "interaction_v1" || _(s.status))) continue;
|
|
1486
|
-
let c = {
|
|
1487
|
-
sessionId: t,
|
|
1488
|
-
runId: r.runId || r.invocationId,
|
|
1489
|
-
name: n.name,
|
|
1490
|
-
message: n.approvalMessage,
|
|
1491
|
-
args: n.args,
|
|
1492
|
-
previousResponseId: n.previousResponseId || r.responseId
|
|
1493
|
-
}, l = a === "ag-ui" ? Lt({
|
|
1494
|
-
...c,
|
|
1495
|
-
interruptId: i,
|
|
1496
|
-
toolCallId: n.callId
|
|
1497
|
-
}) : Pt({
|
|
1498
|
-
...c,
|
|
1499
|
-
approvalRequestId: i
|
|
1500
|
-
});
|
|
1501
|
-
l && (l.revision = s?.revision || l.revision, l.createdAt = s?.createdAt || l.createdAt, l.runId = s?.runId || l.runId, l.extensions = {
|
|
1502
|
-
...l.extensions,
|
|
1503
|
-
...s?.extensions
|
|
1504
|
-
}, o !== "pending" && (l.status = o === "cancelled" ? "cancelled" : "resolved", l.outcome = o), e.upsert(l));
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
//#endregion
|
|
1509
|
-
//#region src/core/interaction/adapters/legacy-runtime-events.ts
|
|
1510
|
-
function Z(e) {
|
|
1511
|
-
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
1512
|
-
}
|
|
1513
|
-
function Bt(e, t) {
|
|
1514
|
-
let n = Z(e), r = Z(Z(n?.Content)?.runtime_event);
|
|
1515
|
-
if (!r || r.schema_version !== 2 || r.interaction_kind !== "approval") return null;
|
|
1516
|
-
let i = Z(r.source);
|
|
1517
|
-
if (![
|
|
1518
|
-
"langgraph",
|
|
1519
|
-
"langchain",
|
|
1520
|
-
"deepagents"
|
|
1521
|
-
].includes(String(i?.framework))) return null;
|
|
1522
|
-
let a = String(n?.SessionId || t || ""), o = typeof r.interaction_id == "string" ? r.interaction_id : "";
|
|
1523
|
-
if (!a || !o) return null;
|
|
1524
|
-
let s = Z(r.request), c = Z(s?.detail), l = Z(r.response), u = r.event_type === "interaction.requested", d = r.event_type === "interaction.resolved";
|
|
1525
|
-
if (u && (s?.request_type !== "approval" || c?.approval_request_id !== o) || !u && (!d || l?.response_type !== "approval")) return null;
|
|
1526
|
-
let f = Z((Array.isArray(c?.action_requests) ? c.action_requests : [])[0]), p = c?.arguments ?? f?.args, m = Z(i?.metadata), h = Pt({
|
|
1527
|
-
approvalRequestId: o,
|
|
1528
|
-
sessionId: a,
|
|
1529
|
-
runId: String(r.run_id || n?.InvocationId || "") || void 0,
|
|
1530
|
-
name: String(c?.tool_name || f?.name || "") || void 0,
|
|
1531
|
-
message: typeof c?.description == "string" ? c.description : void 0,
|
|
1532
|
-
args: p === void 0 ? void 0 : typeof p == "string" ? p : JSON.stringify(p),
|
|
1533
|
-
previousResponseId: typeof m?.response_id == "string" ? m.response_id : void 0
|
|
1534
|
-
});
|
|
1535
|
-
if (!h) return null;
|
|
1536
|
-
if (h.createdAt = String(r.timestamp ?? n?.Timestamp ?? h.createdAt), d) {
|
|
1537
|
-
let e = l?.decision;
|
|
1538
|
-
if (e !== "approved" && e !== "rejected" && e !== "canceled") return null;
|
|
1539
|
-
h.status = e === "canceled" ? "cancelled" : "resolved", h.outcome = e === "canceled" ? "cancelled" : e, h.resolvedAt = h.createdAt;
|
|
1540
|
-
}
|
|
1541
|
-
return h;
|
|
1542
|
-
}
|
|
1543
|
-
//#endregion
|
|
1544
|
-
//#region src/core/interaction/index.ts
|
|
1545
|
-
var Vt = new Set([
|
|
1546
|
-
"completed",
|
|
1547
|
-
"failed",
|
|
1548
|
-
"error",
|
|
1549
|
-
"cancelled",
|
|
1550
|
-
"canceled",
|
|
1551
|
-
"aborted",
|
|
1552
|
-
"resume_failed"
|
|
1553
|
-
]), Q = new xt();
|
|
1554
|
-
function Ht(e, t) {
|
|
1555
|
-
zt(Q, t, e);
|
|
1556
|
-
}
|
|
1557
|
-
function Ut(e, t) {
|
|
1558
|
-
let n = Nt(e, t) ?? Bt(e, t);
|
|
1559
|
-
n && Q.upsert(n);
|
|
1560
|
-
let r = typeof e == "object" && e ? e : null;
|
|
1561
|
-
if (r?.EventType === "control.command_rejected") {
|
|
1562
|
-
let e = r.Content;
|
|
1563
|
-
Q.rejectCommand(String(r.SessionId || t || ""), String(e?.command_id || ""), String(e?.reason || "command_rejected"));
|
|
1564
|
-
}
|
|
1565
|
-
let i = r ? ce(r) : null;
|
|
1566
|
-
if (i !== null && Vt.has(i)) {
|
|
1567
|
-
let e = typeof r?.Content == "object" && r.Content !== null ? r.Content : {}, n = typeof e.payload == "object" && e.payload !== null ? e.payload : {}, i = String(r?.SessionId || r?.session_id || t || ""), a = String(r?.InvocationId || r?.run_id || n.run_id || n.runId || "");
|
|
1568
|
-
Q.markRunTerminal(i, a);
|
|
1569
|
-
}
|
|
1570
|
-
return n;
|
|
1571
|
-
}
|
|
1572
|
-
function Wt(e) {
|
|
1573
|
-
let t = e.sessionId || "";
|
|
1574
|
-
if (!t || !e.approvalRequestId) return null;
|
|
1575
|
-
let n = e.protocol === "ag-ui" ? Lt({
|
|
1576
|
-
interruptId: e.approvalRequestId,
|
|
1577
|
-
sessionId: t,
|
|
1578
|
-
runId: e.runId,
|
|
1579
|
-
name: e.name,
|
|
1580
|
-
message: e.message,
|
|
1581
|
-
reason: e.approvalLevel,
|
|
1582
|
-
requestSchema: e.requestSchema
|
|
1583
|
-
}) : Pt({
|
|
1584
|
-
approvalRequestId: e.approvalRequestId,
|
|
1585
|
-
sessionId: t,
|
|
1586
|
-
runId: e.runId,
|
|
1587
|
-
name: e.name,
|
|
1588
|
-
message: e.message,
|
|
1589
|
-
args: e.args,
|
|
1590
|
-
approvalLevel: e.approvalLevel,
|
|
1591
|
-
previousResponseId: e.previousResponseId
|
|
1592
|
-
});
|
|
1593
|
-
return n && Q.upsert(n), n;
|
|
1594
|
-
}
|
|
1595
|
-
function Gt(e) {
|
|
1596
|
-
let t = e.sessionId || "";
|
|
1597
|
-
if (!t || !e.questionId) return null;
|
|
1598
|
-
let n = It({
|
|
1599
|
-
questionId: e.questionId,
|
|
1600
|
-
sessionId: t,
|
|
1601
|
-
runId: e.runId,
|
|
1602
|
-
questions: e.questions
|
|
1603
|
-
});
|
|
1604
|
-
return n && Q.upsert(n), n;
|
|
1605
|
-
}
|
|
1606
|
-
function Kt(e) {
|
|
1607
|
-
let t = e.sessionId || "";
|
|
1608
|
-
if (!t || !e.questionId) return null;
|
|
1609
|
-
let n = Q.get(t, e.questionId);
|
|
1610
|
-
if (!n) return null;
|
|
1611
|
-
let r = e.answers && typeof e.answers == "object" ? e.answers : {};
|
|
1612
|
-
return Q.upsert({
|
|
1613
|
-
...n,
|
|
1614
|
-
status: "resolved",
|
|
1615
|
-
revision: e.revision ?? n.revision + 1,
|
|
1616
|
-
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1617
|
-
outcome: "submitted",
|
|
1618
|
-
responseSummary: JSON.stringify(r).slice(0, 200),
|
|
1619
|
-
extensions: {
|
|
1620
|
-
...n.extensions,
|
|
1621
|
-
answers: r
|
|
1622
|
-
}
|
|
1623
|
-
}), Q.get(t, e.questionId);
|
|
1624
|
-
}
|
|
1625
|
-
function qt(e) {
|
|
1626
|
-
let t = e.sessionId || "";
|
|
1627
|
-
if (!t || !e.approvalRequestId) return null;
|
|
1628
|
-
let n = Q.get(t, e.approvalRequestId);
|
|
1629
|
-
return n?.source === "agui" && n.kind === "structured_input" ? _(n.status) ? n : (Q.resolveLocally(t, n.interactionId, {
|
|
1630
|
-
status: e.decision === "cancelled" ? "cancelled" : "resolved",
|
|
1631
|
-
outcome: e.decision === "cancelled" ? "cancelled" : "submitted",
|
|
1632
|
-
revision: e.revision || 2,
|
|
1633
|
-
actor: "user"
|
|
1634
|
-
}), Q.get(t, n.interactionId)) : Ut({
|
|
1635
|
-
EventType: "approval.resolved",
|
|
1636
|
-
Content: {
|
|
1637
|
-
approvalId: e.approvalRequestId,
|
|
1638
|
-
revision: e.revision || 2,
|
|
1639
|
-
outcome: e.decision,
|
|
1640
|
-
actor: "user",
|
|
1641
|
-
resolvedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1642
|
-
}
|
|
1643
|
-
}, t);
|
|
1644
|
-
}
|
|
1645
|
-
function Jt(e) {
|
|
1646
|
-
let t = Q.get(e.sessionId || "", e.interactionId);
|
|
1647
|
-
!t || t.source !== "agui" || _(t.status) || Q.markFailed(t.sessionId, t.interactionId, {
|
|
1648
|
-
code: "input_response_invalid",
|
|
1649
|
-
message: e.message,
|
|
1650
|
-
retryable: !0
|
|
1651
|
-
});
|
|
1652
|
-
}
|
|
1653
597
|
//#endregion
|
|
1654
598
|
//#region src/hooks/useInteractions.ts
|
|
1655
|
-
function
|
|
1656
|
-
let t =
|
|
599
|
+
function lt(e) {
|
|
600
|
+
let t = _(), [n] = Ie(() => new a({
|
|
1657
601
|
agentId: e.agentId,
|
|
1658
|
-
store:
|
|
602
|
+
store: T,
|
|
1659
603
|
submitInteraction: (t) => e.api.submitInteraction({
|
|
1660
604
|
...t,
|
|
1661
605
|
AgentId: e.getAgentId?.() ?? t.AgentId
|
|
@@ -1664,68 +608,90 @@ function Yt(e) {
|
|
|
1664
608
|
legacyResponsesApproval: e.legacyResponsesApproval,
|
|
1665
609
|
legacyAguiResume: e.legacyAguiResume
|
|
1666
610
|
}));
|
|
1667
|
-
|
|
611
|
+
q(() => {
|
|
1668
612
|
n.setInteractionV1Enabled(e.interactionV1Enabled);
|
|
1669
613
|
}, [n, e.interactionV1Enabled]);
|
|
1670
|
-
let [r, i] =
|
|
1671
|
-
|
|
1672
|
-
let
|
|
1673
|
-
|
|
614
|
+
let [r, i] = Ie(0);
|
|
615
|
+
q(() => T.subscribe(() => i((e) => e + 1)), []);
|
|
616
|
+
let o = Fe(() => e.currentSessionId ? T.listAll(e.currentSessionId).filter(re) : [], [r, e.currentSessionId]), s = Fe(() => e.currentSessionId ? T.listAll(e.currentSessionId) : [], [r, e.currentSessionId]), { currentSessionId: c, interactionV1Enabled: l, onAcceptedInteraction: u } = e, d = e.api.mcpAuthorization, f = e.reloadHistory;
|
|
617
|
+
q(() => {
|
|
618
|
+
if (c && d) return ct(T, c, d, f);
|
|
619
|
+
}, [
|
|
620
|
+
e.agentId,
|
|
621
|
+
c,
|
|
622
|
+
d,
|
|
623
|
+
f
|
|
624
|
+
]);
|
|
625
|
+
let p = J(/* @__PURE__ */ new Set());
|
|
626
|
+
return q(() => {
|
|
627
|
+
for (let e of s) {
|
|
628
|
+
let t = e.extensions.mcpAuthorization;
|
|
629
|
+
if (!t || ![
|
|
630
|
+
"credential_ready",
|
|
631
|
+
"connecting",
|
|
632
|
+
"resumed",
|
|
633
|
+
"cancelled",
|
|
634
|
+
"expired"
|
|
635
|
+
].includes(t.status || "")) continue;
|
|
636
|
+
let n = `${e.sessionId}:${e.interactionId}:${t.status}`;
|
|
637
|
+
p.current.has(n) || (p.current.add(n), u?.(e));
|
|
638
|
+
}
|
|
639
|
+
}, [s, u]), {
|
|
1674
640
|
client: n,
|
|
1675
|
-
pending:
|
|
1676
|
-
records:
|
|
1677
|
-
respond:
|
|
1678
|
-
let t =
|
|
1679
|
-
return
|
|
641
|
+
pending: o,
|
|
642
|
+
records: s,
|
|
643
|
+
respond: K((e) => {
|
|
644
|
+
let t = c ? T.get(c, e.interactionId) : null;
|
|
645
|
+
return c ? n.respond({
|
|
1680
646
|
...e,
|
|
1681
|
-
sessionId:
|
|
1682
|
-
}).then((e) => (t && (
|
|
647
|
+
sessionId: c
|
|
648
|
+
}).then((e) => (t && (l || t.source === "interaction_v1") && (e.status === "accepted" || e.status === "duplicate") && u?.(t), e)) : Promise.reject(/* @__PURE__ */ Error("请先选择会话。"));
|
|
1683
649
|
}, [
|
|
1684
650
|
n,
|
|
1685
|
-
s,
|
|
1686
651
|
c,
|
|
1687
|
-
l
|
|
652
|
+
l,
|
|
653
|
+
u
|
|
1688
654
|
]),
|
|
1689
655
|
localCatalog: t
|
|
1690
656
|
};
|
|
1691
657
|
}
|
|
1692
|
-
var
|
|
1693
|
-
function
|
|
658
|
+
var ut = .28;
|
|
659
|
+
function dt(e, t = 768) {
|
|
1694
660
|
return Number(e) <= t;
|
|
1695
661
|
}
|
|
1696
|
-
function
|
|
662
|
+
function ft({ isMobile: e, desktopSidebarOpen: t, mobileSidebarOpen: n }) {
|
|
1697
663
|
return {
|
|
1698
664
|
desktopSidebarVisible: !e && !!t,
|
|
1699
665
|
mobileDrawerVisible: !!(e && n)
|
|
1700
666
|
};
|
|
1701
667
|
}
|
|
1702
|
-
function
|
|
668
|
+
function pt({ isMobile: e, viewportHeight: t, desktopMaxHeight: n = 160 }) {
|
|
1703
669
|
if (!e) return n;
|
|
1704
670
|
let r = Number(t);
|
|
1705
671
|
if (!Number.isFinite(r) || r <= 0) return n;
|
|
1706
|
-
let i = Math.floor(r *
|
|
672
|
+
let i = Math.floor(r * ut);
|
|
1707
673
|
return Math.max(120, Math.min(n, i));
|
|
1708
674
|
}
|
|
1709
675
|
//#endregion
|
|
1710
676
|
//#region src/hooks/useResponsiveViewport.ts
|
|
1711
|
-
function
|
|
677
|
+
function mt() {
|
|
1712
678
|
return typeof window > "u" ? 900 : Math.round(window.visualViewport?.height || window.innerHeight || 900);
|
|
1713
679
|
}
|
|
1714
|
-
function
|
|
680
|
+
function ht() {
|
|
1715
681
|
return typeof window > "u" ? {
|
|
1716
682
|
isMobile: !1,
|
|
1717
683
|
viewportHeight: 900
|
|
1718
684
|
} : {
|
|
1719
|
-
isMobile:
|
|
1720
|
-
viewportHeight:
|
|
685
|
+
isMobile: dt(window.innerWidth, 768),
|
|
686
|
+
viewportHeight: mt()
|
|
1721
687
|
};
|
|
1722
688
|
}
|
|
1723
|
-
function
|
|
1724
|
-
let [e, t] =
|
|
1725
|
-
return
|
|
689
|
+
function gt() {
|
|
690
|
+
let [e, t] = Ie(() => ht());
|
|
691
|
+
return q(() => {
|
|
1726
692
|
if (typeof window > "u") return;
|
|
1727
693
|
let e = window.matchMedia("(max-width: 768px)"), n = () => {
|
|
1728
|
-
t(
|
|
694
|
+
t(ht());
|
|
1729
695
|
};
|
|
1730
696
|
n();
|
|
1731
697
|
let r = typeof e.addEventListener == "function" ? (e.addEventListener("change", n), () => e.removeEventListener("change", n)) : (e.addListener(n), () => e.removeListener(n));
|
|
@@ -1736,23 +702,23 @@ function nn() {
|
|
|
1736
702
|
}
|
|
1737
703
|
//#endregion
|
|
1738
704
|
//#region src/core/stream/responses-protocol.ts
|
|
1739
|
-
var
|
|
705
|
+
var _t = class {
|
|
1740
706
|
id = "responses";
|
|
1741
707
|
createState() {
|
|
1742
|
-
return
|
|
708
|
+
return V();
|
|
1743
709
|
}
|
|
1744
710
|
parseItemOperations(e, t, n) {
|
|
1745
|
-
return
|
|
711
|
+
return I(e.eventName, e.data, t, n);
|
|
1746
712
|
}
|
|
1747
713
|
parse(e, t) {
|
|
1748
714
|
let n = e.data;
|
|
1749
|
-
if (e.eventName === "interaction.requested" && n
|
|
1750
|
-
let
|
|
1751
|
-
if (
|
|
715
|
+
if (n && (e.eventName === "interaction.requested" && n.family === "interaction" || e.eventName?.startsWith("mcp.authorization."))) {
|
|
716
|
+
let t = n.payload, r = String(t?.interaction_id || t?.wait_id || "");
|
|
717
|
+
if (r && n.session_id && n.run_id) return [{
|
|
1752
718
|
type: "canonical_interaction",
|
|
1753
|
-
interactionId:
|
|
719
|
+
interactionId: r,
|
|
1754
720
|
event: {
|
|
1755
|
-
EventType:
|
|
721
|
+
EventType: e.eventName,
|
|
1756
722
|
SessionId: String(n.session_id),
|
|
1757
723
|
InvocationId: String(n.run_id),
|
|
1758
724
|
SeqId: Number(n.seq || 0),
|
|
@@ -1760,7 +726,7 @@ var rn = class {
|
|
|
1760
726
|
}
|
|
1761
727
|
}];
|
|
1762
728
|
}
|
|
1763
|
-
return
|
|
729
|
+
return N({
|
|
1764
730
|
eventName: e.eventName,
|
|
1765
731
|
data: e.data,
|
|
1766
732
|
state: t
|
|
@@ -1783,23 +749,23 @@ var rn = class {
|
|
|
1783
749
|
};
|
|
1784
750
|
//#endregion
|
|
1785
751
|
//#region src/utils/stream-parsing.ts
|
|
1786
|
-
function
|
|
752
|
+
function vt(e) {
|
|
1787
753
|
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("") : "";
|
|
1788
754
|
}
|
|
1789
|
-
function
|
|
755
|
+
function yt(e) {
|
|
1790
756
|
return e && typeof e == "object" ? e : {};
|
|
1791
757
|
}
|
|
1792
|
-
function
|
|
1793
|
-
let t =
|
|
758
|
+
function bt(e) {
|
|
759
|
+
let t = yt(e).choices, n = yt(Array.isArray(t) ? t[0] : null), r = yt(n.delta), i = yt(n.message);
|
|
1794
760
|
return {
|
|
1795
|
-
content:
|
|
1796
|
-
reasoning:
|
|
1797
|
-
finalText:
|
|
761
|
+
content: vt(r.content),
|
|
762
|
+
reasoning: vt(r.reasoning_content),
|
|
763
|
+
finalText: vt(i.content)
|
|
1798
764
|
};
|
|
1799
765
|
}
|
|
1800
766
|
//#endregion
|
|
1801
767
|
//#region src/core/stream/chat-completions-protocol.ts
|
|
1802
|
-
var
|
|
768
|
+
var xt = class {
|
|
1803
769
|
id = "chat_completions";
|
|
1804
770
|
createState() {
|
|
1805
771
|
return {};
|
|
@@ -1807,7 +773,7 @@ var cn = class {
|
|
|
1807
773
|
parse(e) {
|
|
1808
774
|
let t = e.data;
|
|
1809
775
|
if (typeof t != "object" || !t) return [];
|
|
1810
|
-
let n =
|
|
776
|
+
let n = bt(t), r = [];
|
|
1811
777
|
return n.reasoning && r.push({
|
|
1812
778
|
type: "reasoning_delta",
|
|
1813
779
|
text: n.reasoning
|
|
@@ -1819,14 +785,14 @@ var cn = class {
|
|
|
1819
785
|
text: n.finalText
|
|
1820
786
|
}), r;
|
|
1821
787
|
}
|
|
1822
|
-
},
|
|
1823
|
-
|
|
1824
|
-
function
|
|
1825
|
-
return
|
|
788
|
+
}, St = /* @__PURE__ */ new Map();
|
|
789
|
+
St.set("responses", new _t()), St.set("chat_completions", new xt());
|
|
790
|
+
function Ct(e) {
|
|
791
|
+
return St.get(e) || St.get("responses");
|
|
1826
792
|
}
|
|
1827
793
|
//#endregion
|
|
1828
794
|
//#region src/utils/stream-control.js
|
|
1829
|
-
function
|
|
795
|
+
function wt(e = []) {
|
|
1830
796
|
return e.some((e) => {
|
|
1831
797
|
if (e?.type !== "terminal") return !1;
|
|
1832
798
|
let t = String(e.status || "").toLowerCase();
|
|
@@ -1835,7 +801,7 @@ function dn(e = []) {
|
|
|
1835
801
|
}
|
|
1836
802
|
//#endregion
|
|
1837
803
|
//#region src/core/transport/sse-parser.ts
|
|
1838
|
-
function
|
|
804
|
+
function Tt(e) {
|
|
1839
805
|
let t = [], n = e.trim();
|
|
1840
806
|
if (!n) return t;
|
|
1841
807
|
let r = n.split("\n");
|
|
@@ -1865,7 +831,7 @@ function fn(e) {
|
|
|
1865
831
|
}
|
|
1866
832
|
return t;
|
|
1867
833
|
}
|
|
1868
|
-
function
|
|
834
|
+
function Et(e) {
|
|
1869
835
|
let t = e.split("\n\n");
|
|
1870
836
|
return {
|
|
1871
837
|
chunks: t,
|
|
@@ -1874,60 +840,60 @@ function pn(e) {
|
|
|
1874
840
|
}
|
|
1875
841
|
//#endregion
|
|
1876
842
|
//#region src/utils/error.ts
|
|
1877
|
-
function
|
|
843
|
+
function Dt(e) {
|
|
1878
844
|
return e instanceof Error ? e.message : String(e);
|
|
1879
845
|
}
|
|
1880
846
|
//#endregion
|
|
1881
847
|
//#region src/utils/model-options.js
|
|
1882
|
-
var
|
|
848
|
+
var Ot = new Set([
|
|
1883
849
|
"auto",
|
|
1884
850
|
"enabled",
|
|
1885
851
|
"disabled"
|
|
1886
852
|
]);
|
|
1887
|
-
function
|
|
853
|
+
function kt(e) {
|
|
1888
854
|
let t = String(e || "").trim().toLowerCase();
|
|
1889
|
-
return
|
|
855
|
+
return Ot.has(t) ? t : "auto";
|
|
1890
856
|
}
|
|
1891
|
-
function
|
|
1892
|
-
let t =
|
|
857
|
+
function At(e) {
|
|
858
|
+
let t = kt(e);
|
|
1893
859
|
if (t === "disabled") return { thinking: { type: "disabled" } };
|
|
1894
860
|
if (t === "enabled") return { thinking: { type: "enabled" } };
|
|
1895
861
|
}
|
|
1896
|
-
var
|
|
1897
|
-
function
|
|
862
|
+
var jt = 1280;
|
|
863
|
+
function Mt(e) {
|
|
1898
864
|
let { apiFormats: t } = e;
|
|
1899
865
|
return t.includes("responses") ? "responses" : t.includes("chat_completions") ? "chat_completions" : "responses";
|
|
1900
866
|
}
|
|
1901
|
-
function
|
|
1902
|
-
let r = Math.min(
|
|
867
|
+
function Nt(e, t, n) {
|
|
868
|
+
let r = Math.min(jt, Math.max(420, t - n - 360));
|
|
1903
869
|
return Math.min(Math.max(e, 420), r);
|
|
1904
870
|
}
|
|
1905
871
|
//#endregion
|
|
1906
872
|
//#region src/core/run/agui.ts
|
|
1907
|
-
function
|
|
873
|
+
function Pt(e) {
|
|
1908
874
|
return String(e.type || "").toUpperCase();
|
|
1909
875
|
}
|
|
1910
|
-
function
|
|
876
|
+
function Ft(e, t) {
|
|
1911
877
|
return String(e.messageId || t);
|
|
1912
878
|
}
|
|
1913
|
-
function
|
|
879
|
+
function It(e, t) {
|
|
1914
880
|
return String(e.runId || t);
|
|
1915
881
|
}
|
|
1916
|
-
function
|
|
882
|
+
function Lt(e) {
|
|
1917
883
|
return e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
1918
884
|
}
|
|
1919
|
-
function
|
|
1920
|
-
if (Array.isArray(e)) return
|
|
885
|
+
function Rt(e) {
|
|
886
|
+
if (Array.isArray(e)) return D(e.filter((e) => !!(e && typeof e == "object")));
|
|
1921
887
|
if (e && typeof e == "object") {
|
|
1922
888
|
let t = e.a2ui_operations;
|
|
1923
|
-
return Array.isArray(t) ?
|
|
889
|
+
return Array.isArray(t) ? D(t.filter((e) => !!(e && typeof e == "object"))) : [e];
|
|
1924
890
|
}
|
|
1925
891
|
return [];
|
|
1926
892
|
}
|
|
1927
|
-
function
|
|
893
|
+
function zt(e) {
|
|
1928
894
|
return e == null || e === "" ? "" : typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
1929
895
|
}
|
|
1930
|
-
var
|
|
896
|
+
var Bt = class {
|
|
1931
897
|
agent;
|
|
1932
898
|
onEvent;
|
|
1933
899
|
tools = /* @__PURE__ */ new Map();
|
|
@@ -1940,18 +906,18 @@ var Dn = class {
|
|
|
1940
906
|
forwardedProps;
|
|
1941
907
|
catalogRegistry;
|
|
1942
908
|
constructor(e) {
|
|
1943
|
-
this.agent = new
|
|
909
|
+
this.agent = new Le({
|
|
1944
910
|
url: e.url,
|
|
1945
911
|
agentId: e.agentId,
|
|
1946
912
|
threadId: e.threadId,
|
|
1947
913
|
fetch: e.fetch
|
|
1948
|
-
}), this.onEvent = e.onEvent, this.threadId = e.threadId, this.forwardedProps = e.forwardedProps || {}, this.catalogRegistry = e.a2uiCatalogRegistry ||
|
|
914
|
+
}), this.onEvent = e.onEvent, this.threadId = e.threadId, this.forwardedProps = e.forwardedProps || {}, this.catalogRegistry = e.a2uiCatalogRegistry || j;
|
|
1949
915
|
}
|
|
1950
|
-
configure(e, t =
|
|
916
|
+
configure(e, t = j) {
|
|
1951
917
|
this.forwardedProps = e, this.catalogRegistry = t;
|
|
1952
918
|
}
|
|
1953
919
|
reconcileInteractions(e) {
|
|
1954
|
-
let t = (t) => !e.some((e) => t.metadata?.interaction_v1 === !0 && e.source === "interaction_v1" && e.sessionId === this.threadId && e.interactionId === t.id && e.runId === t.metadata.run_id && e.revision >= Number(t.metadata.revision || 1) &&
|
|
920
|
+
let t = (t) => !e.some((e) => t.metadata?.interaction_v1 === !0 && e.source === "interaction_v1" && e.sessionId === this.threadId && e.interactionId === t.id && e.runId === t.metadata.run_id && e.revision >= Number(t.metadata.revision || 1) && o(e.status));
|
|
1955
921
|
this.agent.pendingInterrupts = this.agent.pendingInterrupts.filter(t);
|
|
1956
922
|
for (let [e, n] of this.pendingByRun) {
|
|
1957
923
|
let r = n.filter(t);
|
|
@@ -1973,7 +939,7 @@ var Dn = class {
|
|
|
1973
939
|
let n = this.agent.pendingInterrupts.length > 0 ? this.agent.pendingInterrupts : this.pendingByRun.get(this.activeRunId) || [], r = n.length > 0 ? n.filter((e) => e.id === t.interruptId) : [{
|
|
1974
940
|
id: t.interruptId,
|
|
1975
941
|
reason: "approval"
|
|
1976
|
-
}], i =
|
|
942
|
+
}], i = Re(r, { [t.interruptId]: t.status === "resolved" ? {
|
|
1977
943
|
status: "resolved",
|
|
1978
944
|
payload: t.payload
|
|
1979
945
|
} : { status: "cancelled" } });
|
|
@@ -1996,22 +962,22 @@ var Dn = class {
|
|
|
1996
962
|
let t = ++this.executionEpoch, n = this.logicalRunId || e.runId, r = !0, i = /* @__PURE__ */ new Set(), a = (n) => {
|
|
1997
963
|
if (!r || t !== this.executionEpoch || this.activeRunId !== e.runId || e.abortController?.signal.aborted) return null;
|
|
1998
964
|
let a = n;
|
|
1999
|
-
if (
|
|
2000
|
-
let o =
|
|
965
|
+
if (Pt(n) !== "CUSTOM" || a.name !== "ksadk.text_message_snapshot") return null;
|
|
966
|
+
let o = Lt(a.value);
|
|
2001
967
|
return o.version === 1 && o.threadId === this.threadId && o.runId === e.runId && typeof o.messageId == "string" && i.has(o.messageId) && typeof o.content == "string" ? {
|
|
2002
968
|
messageId: o.messageId,
|
|
2003
969
|
content: o.content
|
|
2004
970
|
} : null;
|
|
2005
971
|
}, o = "completed", s = !1, c = {
|
|
2006
972
|
onEvent: ({ event: t, messages: r }) => {
|
|
2007
|
-
|
|
973
|
+
Pt(t) === "TEXT_MESSAGE_START" && i.add(Ft(t, `${e.runId}:assistant`));
|
|
2008
974
|
let c = a(t);
|
|
2009
975
|
if (c && r.some((e) => e.id === c.messageId && e.role === "assistant") && this.onEvent({
|
|
2010
976
|
type: "text_replace",
|
|
2011
977
|
messageId: c.messageId,
|
|
2012
978
|
text: c.content,
|
|
2013
979
|
sessionId: this.threadId
|
|
2014
|
-
}),
|
|
980
|
+
}), Pt(t) === "RUN_FINISHED" && (s = !0), Pt(t) === "RUN_ERROR" && t.code === "INPUT_RESPONSE_INVALID") for (let t of e.resume || []) this.onEvent({
|
|
2015
981
|
type: "interaction_submit_rejected",
|
|
2016
982
|
interactionId: t.interruptId,
|
|
2017
983
|
message: "答案未通过 Runtime 校验,请修改后重新提交。"
|
|
@@ -2036,7 +1002,7 @@ var Dn = class {
|
|
|
2036
1002
|
try {
|
|
2037
1003
|
l = await this.agent.runAgent({
|
|
2038
1004
|
runId: e.runId,
|
|
2039
|
-
context: [
|
|
1005
|
+
context: [k(this.catalogRegistry)],
|
|
2040
1006
|
forwardedProps: {
|
|
2041
1007
|
...this.forwardedProps,
|
|
2042
1008
|
injectA2UITool: !0
|
|
@@ -2055,7 +1021,7 @@ var Dn = class {
|
|
|
2055
1021
|
};
|
|
2056
1022
|
}
|
|
2057
1023
|
project(e, t, n = !1, r = t) {
|
|
2058
|
-
let i =
|
|
1024
|
+
let i = Pt(e), a = It(e, t), o = Ft(e, `${a}:assistant`), s = e, c = [];
|
|
2059
1025
|
if (i === "RUN_STARTED") c.push({
|
|
2060
1026
|
type: "activity",
|
|
2061
1027
|
phase: "AG-UI 运行已创建",
|
|
@@ -2118,8 +1084,8 @@ var Dn = class {
|
|
|
2118
1084
|
output: String(s.content || "")
|
|
2119
1085
|
});
|
|
2120
1086
|
} else if (i === "CUSTOM" && s.name === "ksadk.session_event") {
|
|
2121
|
-
let e =
|
|
2122
|
-
e.family === "interaction" && e.family_version === 1 && e.session_id === this.threadId && typeof e.event_type == "string" && Number.isSafeInteger(e.seq) && c.push({
|
|
1087
|
+
let e = Lt(s.value), t = e.family === "control" && ["mcp.authorization.requested", "mcp.authorization.updated"].includes(String(e.event_type));
|
|
1088
|
+
(e.family === "interaction" || t) && e.family_version === 1 && e.session_id === this.threadId && typeof e.event_type == "string" && Number.isSafeInteger(e.seq) && c.push({
|
|
2123
1089
|
type: "stream_event",
|
|
2124
1090
|
sessionId: e.session_id,
|
|
2125
1091
|
event: {
|
|
@@ -2132,7 +1098,7 @@ var Dn = class {
|
|
|
2132
1098
|
}
|
|
2133
1099
|
});
|
|
2134
1100
|
} else if (i === "ACTIVITY_SNAPSHOT") {
|
|
2135
|
-
let e = s.content, t =
|
|
1101
|
+
let e = s.content, t = Lt(e), n = String(t.surfaceId || t.surface_id || s.messageId || "default");
|
|
2136
1102
|
c.push({
|
|
2137
1103
|
type: "agui_activity",
|
|
2138
1104
|
runId: r,
|
|
@@ -2140,17 +1106,17 @@ var Dn = class {
|
|
|
2140
1106
|
...typeof t.interactionId == "string" ? { interactionId: t.interactionId } : {},
|
|
2141
1107
|
messageId: this.runMessageIds.get(a) || o,
|
|
2142
1108
|
surfaceId: n,
|
|
2143
|
-
messages:
|
|
1109
|
+
messages: Rt(t.content ?? e)
|
|
2144
1110
|
});
|
|
2145
1111
|
} else if (i === "RUN_FINISHED") {
|
|
2146
|
-
let e =
|
|
1112
|
+
let e = Lt(s.outcome);
|
|
2147
1113
|
if (String(e.type || "").toLowerCase() === "interrupt") {
|
|
2148
1114
|
let t = Array.isArray(e.interrupts) ? e.interrupts : [];
|
|
2149
1115
|
this.pendingByRun.set(a, t);
|
|
2150
1116
|
for (let e of t) {
|
|
2151
|
-
let t =
|
|
1117
|
+
let t = Lt(e.metadata);
|
|
2152
1118
|
if (t.interaction_v1 === !0) continue;
|
|
2153
|
-
let n = e.toolCallId ? this.tools.get(e.toolCallId) : void 0, r = String(t.tool_name || t.toolName || n?.name || e.reason || "人工确认"), i =
|
|
1119
|
+
let n = e.toolCallId ? this.tools.get(e.toolCallId) : void 0, r = String(t.tool_name || t.toolName || n?.name || e.reason || "人工确认"), i = zt(t.arguments ?? t.tool_args ?? t.args ?? n?.args);
|
|
2154
1120
|
c.push({
|
|
2155
1121
|
type: "approval_requested",
|
|
2156
1122
|
messageId: this.runMessageIds.get(a) || `${a}:assistant`,
|
|
@@ -2185,7 +1151,7 @@ var Dn = class {
|
|
|
2185
1151
|
};
|
|
2186
1152
|
return { events: c };
|
|
2187
1153
|
}
|
|
2188
|
-
},
|
|
1154
|
+
}, Vt = new Set([
|
|
2189
1155
|
"completed",
|
|
2190
1156
|
"failed",
|
|
2191
1157
|
"error",
|
|
@@ -2195,12 +1161,12 @@ var Dn = class {
|
|
|
2195
1161
|
"interrupted",
|
|
2196
1162
|
"resume_failed"
|
|
2197
1163
|
]);
|
|
2198
|
-
function
|
|
1164
|
+
function Ht(e) {
|
|
2199
1165
|
if (e.EventType !== "run_status") return null;
|
|
2200
1166
|
let t = String(e.Content?.status || "").trim().toLowerCase();
|
|
2201
|
-
return
|
|
1167
|
+
return Vt.has(t) ? t : null;
|
|
2202
1168
|
}
|
|
2203
|
-
function
|
|
1169
|
+
function Ut(e, t) {
|
|
2204
1170
|
let n = String(t?.type || e || "").trim();
|
|
2205
1171
|
if (n === "response.created") return {
|
|
2206
1172
|
phase: "运行已创建",
|
|
@@ -2246,11 +1212,11 @@ function An(e, t) {
|
|
|
2246
1212
|
status: "failed"
|
|
2247
1213
|
} : null;
|
|
2248
1214
|
}
|
|
2249
|
-
function
|
|
1215
|
+
function Wt() {
|
|
2250
1216
|
let e = globalThis.crypto;
|
|
2251
1217
|
return e && typeof e.randomUUID == "function" ? `run_${e.randomUUID()}` : `run_${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
2252
1218
|
}
|
|
2253
|
-
var
|
|
1219
|
+
var Gt = {
|
|
2254
1220
|
idle: [
|
|
2255
1221
|
"creating-session",
|
|
2256
1222
|
"uploading-files",
|
|
@@ -2288,7 +1254,7 @@ var Mn = {
|
|
|
2288
1254
|
],
|
|
2289
1255
|
error: ["connecting", "idle"],
|
|
2290
1256
|
cancelled: ["idle"]
|
|
2291
|
-
},
|
|
1257
|
+
}, Kt = class {
|
|
2292
1258
|
_stage = "idle";
|
|
2293
1259
|
listeners = /* @__PURE__ */ new Set();
|
|
2294
1260
|
abortController = null;
|
|
@@ -2321,18 +1287,18 @@ var Mn = {
|
|
|
2321
1287
|
return this.activeSessionId || this.projection.draftId || null;
|
|
2322
1288
|
}
|
|
2323
1289
|
publishInvocation(e) {
|
|
2324
|
-
this.invocationId = e, e &&
|
|
1290
|
+
this.invocationId = e, e && r.getState().updateActivity({
|
|
2325
1291
|
sessionId: this.streamingKey,
|
|
2326
1292
|
runId: e,
|
|
2327
1293
|
countEvent: !1,
|
|
2328
1294
|
visible: this.projection.isVisible?.()
|
|
2329
|
-
}), this.projection.isVisible?.() !== !1 && (
|
|
1295
|
+
}), this.projection.isVisible?.() !== !1 && (r.getState().setCurrentRunId(e), r.getState().setActiveInvocationId(e));
|
|
2330
1296
|
}
|
|
2331
1297
|
recordCursor(e) {
|
|
2332
|
-
this.lastSeqId = e === 0 ? 0 : Math.max(this.lastSeqId, e), this.projection.isVisible?.() !== !1 &&
|
|
1298
|
+
this.lastSeqId = e === 0 ? 0 : Math.max(this.lastSeqId, e), this.projection.isVisible?.() !== !1 && r.getState().setLastSeqId(this.lastSeqId);
|
|
2333
1299
|
}
|
|
2334
1300
|
stopActivity(e) {
|
|
2335
|
-
let t =
|
|
1301
|
+
let t = r.getState(), n = this.projection.isVisible?.() !== !1;
|
|
2336
1302
|
this.streamingKey ? t.stopSessionActivity(this.streamingKey, e, n) : n && t.stopActivity(e);
|
|
2337
1303
|
}
|
|
2338
1304
|
get stage() {
|
|
@@ -2345,9 +1311,9 @@ var Mn = {
|
|
|
2345
1311
|
this.lastControlCommand = e;
|
|
2346
1312
|
let t;
|
|
2347
1313
|
try {
|
|
2348
|
-
t =
|
|
1314
|
+
t = c(await this.api.submitControl(e));
|
|
2349
1315
|
} catch (e) {
|
|
2350
|
-
if (e instanceof
|
|
1316
|
+
if (e instanceof u) return this.controlStateValue = {
|
|
2351
1317
|
phase: "contract_mismatch",
|
|
2352
1318
|
error: null,
|
|
2353
1319
|
receipt: null
|
|
@@ -2437,7 +1403,7 @@ var Mn = {
|
|
|
2437
1403
|
let t = this.config.hostedChatTransport;
|
|
2438
1404
|
if (t?.Protocol !== "ag-ui" || !t.Endpoint) return null;
|
|
2439
1405
|
if (!this.aguiClient || this.aguiThreadSessionId !== e) {
|
|
2440
|
-
let n = new
|
|
1406
|
+
let n = new Bt({
|
|
2441
1407
|
url: t.Endpoint,
|
|
2442
1408
|
agentId: this.config.agentId,
|
|
2443
1409
|
threadId: e,
|
|
@@ -2447,16 +1413,16 @@ var Mn = {
|
|
|
2447
1413
|
});
|
|
2448
1414
|
this.aguiClient = n, this.aguiThreadSessionId = e;
|
|
2449
1415
|
}
|
|
2450
|
-
return this.aguiClient.reconcileInteractions(
|
|
1416
|
+
return this.aguiClient.reconcileInteractions(T.listAll(e)), this.aguiClient.configure({
|
|
2451
1417
|
model: this.config.selectedModel || void 0,
|
|
2452
1418
|
modelMetadata: this.config.selectedModelMetadata || void 0,
|
|
2453
|
-
modelOptions:
|
|
1419
|
+
modelOptions: At(kt(this.config.thinkingMode)),
|
|
2454
1420
|
toolApprovalMode: this.config.permissionMode || "risk"
|
|
2455
1421
|
}, this.config.a2uiCatalogRegistry), this.aguiClient;
|
|
2456
1422
|
}
|
|
2457
1423
|
setStage(e) {
|
|
2458
1424
|
if (this._stage === e) return;
|
|
2459
|
-
let t =
|
|
1425
|
+
let t = Gt[this._stage];
|
|
2460
1426
|
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({
|
|
2461
1427
|
type: "stage_changed",
|
|
2462
1428
|
stage: e
|
|
@@ -2477,19 +1443,19 @@ var Mn = {
|
|
|
2477
1443
|
phase: this.activeSessionId ? "连接运行时" : "创建会话",
|
|
2478
1444
|
countEvent: !1
|
|
2479
1445
|
});
|
|
2480
|
-
let n = e.responsesInput !== void 0,
|
|
2481
|
-
|
|
1446
|
+
let n = e.responsesInput !== void 0, i = !1, a = (t) => {
|
|
1447
|
+
i || (i = !0, e.onDispatchResult?.(t));
|
|
2482
1448
|
};
|
|
2483
1449
|
return (async () => {
|
|
2484
|
-
let
|
|
1450
|
+
let i = e.sessionId || null, o = "unknown";
|
|
2485
1451
|
try {
|
|
2486
|
-
if (
|
|
2487
|
-
this.activeSessionId =
|
|
2488
|
-
let
|
|
2489
|
-
this.publishInvocation(
|
|
2490
|
-
let s = n ? null : await this.getConversationBootstrap(
|
|
1452
|
+
if (i ||= await this.createSession(e), !i) throw Error("运行时未返回会话身份,请确认创建结果后重试。");
|
|
1453
|
+
this.activeSessionId = i;
|
|
1454
|
+
let r = Wt();
|
|
1455
|
+
this.publishInvocation(r), e.onInvocationCreated?.(r), this.recordCursor(0);
|
|
1456
|
+
let s = n ? null : await this.getConversationBootstrap(i);
|
|
2491
1457
|
if (s && this.config.conversationClient) {
|
|
2492
|
-
let n = await this.buildCanonicalConversationInput(s,
|
|
1458
|
+
let n = await this.buildCanonicalConversationInput(s, i, r, e);
|
|
2493
1459
|
this.setStage("connecting"), this.emit({
|
|
2494
1460
|
type: "activity",
|
|
2495
1461
|
phase: "连接会话运行时",
|
|
@@ -2501,7 +1467,7 @@ var Mn = {
|
|
|
2501
1467
|
status: "waiting",
|
|
2502
1468
|
countEvent: !1
|
|
2503
1469
|
});
|
|
2504
|
-
let
|
|
1470
|
+
let a = await this.config.conversationClient.streamTurn({
|
|
2505
1471
|
bootstrap: s,
|
|
2506
1472
|
input: n,
|
|
2507
1473
|
signal: this.abortController?.signal,
|
|
@@ -2509,14 +1475,14 @@ var Mn = {
|
|
|
2509
1475
|
t.runId && (this.publishInvocation(t.runId), e.onInvocationCreated?.(t.runId)), this.emit({
|
|
2510
1476
|
type: "conversation_snapshot",
|
|
2511
1477
|
result: t,
|
|
2512
|
-
sessionId:
|
|
1478
|
+
sessionId: i,
|
|
2513
1479
|
optimisticMessageId: e.optimisticMessageId
|
|
2514
1480
|
});
|
|
2515
1481
|
}
|
|
2516
1482
|
});
|
|
2517
1483
|
if (this.operationEpoch !== t) return;
|
|
2518
|
-
if (
|
|
2519
|
-
|
|
1484
|
+
if (a.presentation.terminalStatus === "failed") {
|
|
1485
|
+
o = "failed", this.setStage("error"), this.emit({
|
|
2520
1486
|
type: "activity",
|
|
2521
1487
|
phase: "运行失败",
|
|
2522
1488
|
status: "failed",
|
|
@@ -2524,15 +1490,15 @@ var Mn = {
|
|
|
2524
1490
|
});
|
|
2525
1491
|
return;
|
|
2526
1492
|
}
|
|
2527
|
-
this.setStage("completing"),
|
|
1493
|
+
this.setStage("completing"), o = "completed", this.emit({
|
|
2528
1494
|
type: "activity",
|
|
2529
1495
|
phase: "运行完成",
|
|
2530
1496
|
status: "completed",
|
|
2531
1497
|
countEvent: !1
|
|
2532
1498
|
}), this.emit({
|
|
2533
1499
|
type: "stream_ended",
|
|
2534
|
-
sessionId:
|
|
2535
|
-
runId:
|
|
1500
|
+
sessionId: i,
|
|
1501
|
+
runId: a.runId
|
|
2536
1502
|
});
|
|
2537
1503
|
return;
|
|
2538
1504
|
}
|
|
@@ -2543,10 +1509,10 @@ var Mn = {
|
|
|
2543
1509
|
status: "connecting",
|
|
2544
1510
|
countEvent: !1
|
|
2545
1511
|
});
|
|
2546
|
-
let l = n ? "responses" :
|
|
1512
|
+
let l = n ? "responses" : Mt({
|
|
2547
1513
|
agentFramework: this.config.agentFramework,
|
|
2548
1514
|
apiFormats: this.config.apiFormats
|
|
2549
|
-
}), u =
|
|
1515
|
+
}), u = Ct(l), d = u.createState(), f = this.config.hostedChatTransport, p = !n && !e.executionMode && e.attachments.length === 0 && f?.Protocol === "ag-ui" ? this.getAguiClient(i) : null;
|
|
2550
1516
|
if (p && f) {
|
|
2551
1517
|
this.setStage("streaming"), this.emit({
|
|
2552
1518
|
type: "activity",
|
|
@@ -2554,13 +1520,13 @@ var Mn = {
|
|
|
2554
1520
|
status: "waiting",
|
|
2555
1521
|
countEvent: !1
|
|
2556
1522
|
});
|
|
2557
|
-
let t = await p.run(e.text,
|
|
1523
|
+
let t = await p.run(e.text, r, this.abortController?.signal);
|
|
2558
1524
|
if (t.status === "interrupted") {
|
|
2559
|
-
|
|
1525
|
+
o = "cancelled", this.setStage("completing"), this.emit({ type: "stream_ended" });
|
|
2560
1526
|
return;
|
|
2561
1527
|
}
|
|
2562
1528
|
if (t.status !== "completed") {
|
|
2563
|
-
|
|
1529
|
+
o = "failed", this.setStage("error"), this.emit({
|
|
2564
1530
|
type: "activity",
|
|
2565
1531
|
phase: "AG-UI 运行失败",
|
|
2566
1532
|
status: "failed",
|
|
@@ -2568,7 +1534,7 @@ var Mn = {
|
|
|
2568
1534
|
});
|
|
2569
1535
|
return;
|
|
2570
1536
|
}
|
|
2571
|
-
this.setStage("completing"),
|
|
1537
|
+
this.setStage("completing"), o = "completed", this.emit({
|
|
2572
1538
|
type: "activity",
|
|
2573
1539
|
phase: "运行完成",
|
|
2574
1540
|
status: "completed",
|
|
@@ -2576,27 +1542,27 @@ var Mn = {
|
|
|
2576
1542
|
}), this.emit({ type: "stream_ended" });
|
|
2577
1543
|
return;
|
|
2578
1544
|
}
|
|
2579
|
-
let m = this.buildRequestBody(
|
|
1545
|
+
let m = this.buildRequestBody(i, l, n, e, c, r), h = this.config.kernelSessionEventsEnabled && this.config.presentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1", g = await this.api.runAgent(m, { signal: this.abortController?.signal });
|
|
2580
1546
|
if (this.operationEpoch !== t || this.abortController?.signal.aborted) {
|
|
2581
|
-
|
|
1547
|
+
a(!1), await g.cancel();
|
|
2582
1548
|
return;
|
|
2583
1549
|
}
|
|
2584
|
-
this.config.kernelSessionEventsEnabled ||
|
|
1550
|
+
this.config.kernelSessionEventsEnabled || a(!0), this.setStage("streaming"), this.emit({
|
|
2585
1551
|
type: "activity",
|
|
2586
1552
|
phase: "等待首个输出",
|
|
2587
1553
|
status: "waiting",
|
|
2588
1554
|
countEvent: !1
|
|
2589
1555
|
});
|
|
2590
|
-
let _ = `msg-${Date.now()}`, v = await
|
|
1556
|
+
let _ = `msg-${Date.now()}`, v = await Ce(g);
|
|
2591
1557
|
if (this.operationEpoch !== t || this.abortController?.signal.aborted) {
|
|
2592
|
-
|
|
1558
|
+
a(!1), await v.stream.cancel();
|
|
2593
1559
|
return;
|
|
2594
1560
|
}
|
|
2595
|
-
this.config.kernelSessionEventsEnabled &&
|
|
1561
|
+
this.config.kernelSessionEventsEnabled && a(!v.receipt || v.receipt.status === "accepted" || v.receipt.status === "duplicate");
|
|
2596
1562
|
let y;
|
|
2597
|
-
if (y = v.receipt ? await this.consumeKernelRunEvents(
|
|
1563
|
+
if (y = v.receipt ? await this.consumeKernelRunEvents(i, v.receipt, e.onInvocationCreated, h) : await this.consumeStream(v.stream, u, d, _, r), this.operationEpoch !== t) return;
|
|
2598
1564
|
if (y.awaitingInput) {
|
|
2599
|
-
|
|
1565
|
+
o = "awaiting-input", this.setStage("completing"), this.emit({
|
|
2600
1566
|
type: "activity",
|
|
2601
1567
|
phase: "等待人工确认",
|
|
2602
1568
|
status: "waiting",
|
|
@@ -2605,7 +1571,7 @@ var Mn = {
|
|
|
2605
1571
|
return;
|
|
2606
1572
|
}
|
|
2607
1573
|
if (y.outcomeUnknown) {
|
|
2608
|
-
|
|
1574
|
+
o = "unknown", this.setStage("recovering"), this.emit({
|
|
2609
1575
|
type: "activity",
|
|
2610
1576
|
phase: "运行状态待确认",
|
|
2611
1577
|
status: "waiting",
|
|
@@ -2615,7 +1581,7 @@ var Mn = {
|
|
|
2615
1581
|
return;
|
|
2616
1582
|
}
|
|
2617
1583
|
if (y.terminalStatus === "cancelled") {
|
|
2618
|
-
|
|
1584
|
+
o = "cancelled", this.setStage("stopping"), this.stopActivity("运行时已取消本次执行。"), this.emit({
|
|
2619
1585
|
type: "activity",
|
|
2620
1586
|
phase: "运行已取消",
|
|
2621
1587
|
status: "stopped",
|
|
@@ -2624,7 +1590,7 @@ var Mn = {
|
|
|
2624
1590
|
return;
|
|
2625
1591
|
}
|
|
2626
1592
|
if (y.terminalStatus && y.terminalStatus !== "completed") {
|
|
2627
|
-
|
|
1593
|
+
o = "failed", this.setStage("error"), this.emit({
|
|
2628
1594
|
type: "activity",
|
|
2629
1595
|
phase: y.terminalStatus === "incomplete" ? "运行中断" : "运行失败",
|
|
2630
1596
|
status: "failed",
|
|
@@ -2632,17 +1598,17 @@ var Mn = {
|
|
|
2632
1598
|
});
|
|
2633
1599
|
return;
|
|
2634
1600
|
}
|
|
2635
|
-
this.setStage("completing"),
|
|
1601
|
+
this.setStage("completing"), o = "completed", this.emit({
|
|
2636
1602
|
type: "activity",
|
|
2637
1603
|
phase: "运行完成",
|
|
2638
1604
|
status: "completed",
|
|
2639
1605
|
countEvent: !1
|
|
2640
1606
|
}), this.emit({ type: "stream_ended" });
|
|
2641
1607
|
} catch (e) {
|
|
2642
|
-
if (this.failCompaction(), e instanceof DOMException && e.name === "AbortError" || e instanceof
|
|
1608
|
+
if (this.failCompaction(), e instanceof DOMException && e.name === "AbortError" || e instanceof G && e.code === "conversation_aborted") o = "cancelled";
|
|
2643
1609
|
else {
|
|
2644
1610
|
let t = e instanceof TypeError;
|
|
2645
|
-
if (
|
|
1611
|
+
if (o = t ? "unknown" : "failed", console.error("[RunEngine] start() error:", e), t) {
|
|
2646
1612
|
this.setStage("recovering"), this.emit({
|
|
2647
1613
|
type: "activity",
|
|
2648
1614
|
phase: "网络异常,尝试重连",
|
|
@@ -2664,17 +1630,17 @@ var Mn = {
|
|
|
2664
1630
|
type: "error",
|
|
2665
1631
|
error: e instanceof Error ? e : Error(String(e))
|
|
2666
1632
|
});
|
|
2667
|
-
} else e instanceof
|
|
1633
|
+
} else e instanceof Y && e.code === 429 ? (this.setStage("error"), this.emit({
|
|
2668
1634
|
type: "rate_limited",
|
|
2669
1635
|
message: e.message || "请求过于频繁,请稍后重试",
|
|
2670
|
-
sessionId:
|
|
1636
|
+
sessionId: i
|
|
2671
1637
|
})) : (this.setStage("error"), this.emit({
|
|
2672
1638
|
type: "error",
|
|
2673
1639
|
error: e instanceof Error ? e : Error(String(e))
|
|
2674
1640
|
}));
|
|
2675
1641
|
}
|
|
2676
1642
|
} finally {
|
|
2677
|
-
|
|
1643
|
+
a(!1), this.operationEpoch === t && (r.getState().setSessionStreaming(this.streamingKey, !1), this.setStage("idle"), this.activeCompactionId = null, this.activeSessionId = null, e.onSettled?.(i, o));
|
|
2678
1644
|
}
|
|
2679
1645
|
})(), !0;
|
|
2680
1646
|
}
|
|
@@ -2690,7 +1656,7 @@ var Mn = {
|
|
|
2690
1656
|
});
|
|
2691
1657
|
}
|
|
2692
1658
|
disconnect() {
|
|
2693
|
-
this._stage !== "idle" && (this.operationEpoch += 1, this.abortController?.abort(), this.aguiClient?.abort(),
|
|
1659
|
+
this._stage !== "idle" && (this.operationEpoch += 1, this.abortController?.abort(), this.aguiClient?.abort(), r.getState().setSessionStreaming(this.streamingKey, !1), this.projection.isVisible?.() !== !1 && r.getState().clearActivity(), this._stage = "idle", this.activeCompactionId = null, this.activeSessionId = null);
|
|
2694
1660
|
}
|
|
2695
1661
|
async cancelRemote(e) {
|
|
2696
1662
|
try {
|
|
@@ -2725,11 +1691,11 @@ var Mn = {
|
|
|
2725
1691
|
let { value: e, done: n } = await r.read();
|
|
2726
1692
|
if (n) break;
|
|
2727
1693
|
a += i.decode(e, { stream: !0 });
|
|
2728
|
-
let { chunks: o, remainder: s } =
|
|
1694
|
+
let { chunks: o, remainder: s } = Et(a);
|
|
2729
1695
|
a = s;
|
|
2730
1696
|
for (let e of o) {
|
|
2731
1697
|
if (!e.trim()) continue;
|
|
2732
|
-
let n =
|
|
1698
|
+
let n = Tt(e);
|
|
2733
1699
|
for (let e of n) e.eventName === "__done__" || e.eventName === "__ping__" || (this.emit({
|
|
2734
1700
|
type: "activity",
|
|
2735
1701
|
phase: "收到恢复事件",
|
|
@@ -2737,7 +1703,7 @@ var Mn = {
|
|
|
2737
1703
|
}), this.emit({
|
|
2738
1704
|
type: "stream_event",
|
|
2739
1705
|
event: e.data
|
|
2740
|
-
}), t =
|
|
1706
|
+
}), t = Ht(e.data) || t);
|
|
2741
1707
|
}
|
|
2742
1708
|
}
|
|
2743
1709
|
this.setStage("completing"), t === "cancelled" || t === "canceled" || t === "aborted" ? this.emit({
|
|
@@ -2775,16 +1741,16 @@ var Mn = {
|
|
|
2775
1741
|
} catch (e) {
|
|
2776
1742
|
e instanceof DOMException && e.name === "AbortError" || console.error("Failed to subscribe to run events:", e);
|
|
2777
1743
|
} finally {
|
|
2778
|
-
|
|
1744
|
+
r.getState().setSessionStreaming(e.sessionId, !1), this.publishInvocation(""), this.setStage("idle"), this.activeSessionId = null;
|
|
2779
1745
|
}
|
|
2780
1746
|
}
|
|
2781
1747
|
resumeCheckpoint(e) {
|
|
2782
1748
|
if (this._stage !== "idle") return !1;
|
|
2783
1749
|
let t = ++this.operationEpoch;
|
|
2784
1750
|
this.abortController = new AbortController(), this.activeSessionId = e.sessionId;
|
|
2785
|
-
let n =
|
|
1751
|
+
let n = Wt();
|
|
2786
1752
|
return this.publishInvocation(n), (async () => {
|
|
2787
|
-
let
|
|
1753
|
+
let i = "unknown";
|
|
2788
1754
|
try {
|
|
2789
1755
|
if (this.setStage("connecting"), this.emit({
|
|
2790
1756
|
type: "activity",
|
|
@@ -2816,7 +1782,7 @@ var Mn = {
|
|
|
2816
1782
|
checkpointId: e.checkpointId,
|
|
2817
1783
|
resumeAttemptId: e.resumeAttemptId,
|
|
2818
1784
|
invocationId: n
|
|
2819
|
-
}, { signal: this.abortController?.signal }),
|
|
1785
|
+
}, { signal: this.abortController?.signal }), r = Ct("responses"), a = r.createState();
|
|
2820
1786
|
this.setStage("streaming"), this.emit({
|
|
2821
1787
|
type: "activity",
|
|
2822
1788
|
source: "restore",
|
|
@@ -2824,9 +1790,9 @@ var Mn = {
|
|
|
2824
1790
|
status: "waiting",
|
|
2825
1791
|
countEvent: !1
|
|
2826
1792
|
});
|
|
2827
|
-
let o = `msg-${Date.now()}`, s = await this.consumeStream(t,
|
|
1793
|
+
let o = `msg-${Date.now()}`, s = await this.consumeStream(t, r, a, o, n);
|
|
2828
1794
|
if (s.awaitingInput) {
|
|
2829
|
-
|
|
1795
|
+
i = "awaiting-input", this.setStage("completing"), this.emit({
|
|
2830
1796
|
type: "activity",
|
|
2831
1797
|
source: "restore",
|
|
2832
1798
|
phase: "等待人工确认",
|
|
@@ -2837,7 +1803,7 @@ var Mn = {
|
|
|
2837
1803
|
}
|
|
2838
1804
|
if (s.terminalStatus && s.terminalStatus !== "completed") {
|
|
2839
1805
|
if (s.terminalStatus === "cancelled") {
|
|
2840
|
-
|
|
1806
|
+
i = "cancelled", this.setStage("stopping"), this.stopActivity("运行时已取消本次恢复。"), this.emit({
|
|
2841
1807
|
type: "activity",
|
|
2842
1808
|
source: "restore",
|
|
2843
1809
|
phase: "恢复已取消",
|
|
@@ -2846,7 +1812,7 @@ var Mn = {
|
|
|
2846
1812
|
}), this.setStage("cancelled");
|
|
2847
1813
|
return;
|
|
2848
1814
|
}
|
|
2849
|
-
this.setStage("error"),
|
|
1815
|
+
this.setStage("error"), i = "failed", this.emit({
|
|
2850
1816
|
type: "activity",
|
|
2851
1817
|
source: "restore",
|
|
2852
1818
|
phase: s.terminalStatus === "incomplete" ? "恢复中断" : "恢复失败",
|
|
@@ -2855,7 +1821,7 @@ var Mn = {
|
|
|
2855
1821
|
});
|
|
2856
1822
|
return;
|
|
2857
1823
|
}
|
|
2858
|
-
this.setStage("completing"),
|
|
1824
|
+
this.setStage("completing"), i = "completed", this.emit({
|
|
2859
1825
|
type: "activity",
|
|
2860
1826
|
source: "restore",
|
|
2861
1827
|
phase: "恢复完成",
|
|
@@ -2863,12 +1829,12 @@ var Mn = {
|
|
|
2863
1829
|
countEvent: !1
|
|
2864
1830
|
}), this.emit({ type: "stream_ended" });
|
|
2865
1831
|
} catch (e) {
|
|
2866
|
-
e instanceof DOMException && e.name === "AbortError" ?
|
|
1832
|
+
e instanceof DOMException && e.name === "AbortError" ? i = "cancelled" : (i = "failed", console.error("[RunEngine] resumeCheckpoint() error:", e), this.setStage("error"), this.emit({
|
|
2867
1833
|
type: "error",
|
|
2868
1834
|
error: e instanceof Error ? e : Error(String(e))
|
|
2869
1835
|
}));
|
|
2870
1836
|
} finally {
|
|
2871
|
-
this.operationEpoch === t && (
|
|
1837
|
+
this.operationEpoch === t && (r.getState().setSessionStreaming(e.sessionId, !1), this.publishInvocation(""), this.setStage("idle"), this.activeSessionId = null, e.onSettled?.(e.sessionId, i));
|
|
2872
1838
|
}
|
|
2873
1839
|
})(), !0;
|
|
2874
1840
|
}
|
|
@@ -2880,7 +1846,7 @@ var Mn = {
|
|
|
2880
1846
|
if (!n) return !1;
|
|
2881
1847
|
let r = ++this.operationEpoch;
|
|
2882
1848
|
this.activeSessionId = t;
|
|
2883
|
-
let i =
|
|
1849
|
+
let i = Wt();
|
|
2884
1850
|
return this.publishInvocation(i), this.setStage("connecting"), this.emit({
|
|
2885
1851
|
type: "activity",
|
|
2886
1852
|
phase: "提交人工确认",
|
|
@@ -2892,7 +1858,7 @@ var Mn = {
|
|
|
2892
1858
|
this.setStage("streaming");
|
|
2893
1859
|
let r = await n.resume(i, {
|
|
2894
1860
|
interruptId: e.interruptId,
|
|
2895
|
-
logicalRunId:
|
|
1861
|
+
logicalRunId: T.get(t, e.interruptId)?.runId || void 0,
|
|
2896
1862
|
status: e.status,
|
|
2897
1863
|
payload: e.payload
|
|
2898
1864
|
}), o = e.payload && typeof e.payload == "object" ? e.payload : {}, s = String(o.decision || o.type || "").toLowerCase(), c = r.pendingInterruptIds?.includes(e.interruptId);
|
|
@@ -2949,7 +1915,7 @@ var Mn = {
|
|
|
2949
1915
|
try {
|
|
2950
1916
|
return await t.getSurface(this.config.agentId, e, { signal: this.abortController?.signal });
|
|
2951
1917
|
} catch (e) {
|
|
2952
|
-
if (e instanceof
|
|
1918
|
+
if (e instanceof G && e.code === "conversation_http_error" && e.status === 404) return null;
|
|
2953
1919
|
throw e;
|
|
2954
1920
|
}
|
|
2955
1921
|
}
|
|
@@ -2961,39 +1927,39 @@ var Mn = {
|
|
|
2961
1927
|
});
|
|
2962
1928
|
for (let t of r.attachments) {
|
|
2963
1929
|
let n = t.type.startsWith("image/") ? "attachment.image" : "attachment.file";
|
|
2964
|
-
if (!
|
|
1930
|
+
if (!de(e.surface, n)) throw new G("conversation_input_unsupported", "Conversation attachment is not declared by the active surface.", { capability: n });
|
|
2965
1931
|
}
|
|
2966
1932
|
r.attachments.length > 0 && i.push(...await this.uploadCanonicalAttachments(r.attachments));
|
|
2967
|
-
let o =
|
|
1933
|
+
let o = kt(this.config.thinkingMode), s = fe({
|
|
2968
1934
|
inputId: `input:${n}`,
|
|
2969
1935
|
sessionId: t,
|
|
2970
1936
|
idempotencyKey: `conversation:${n}`,
|
|
2971
1937
|
parts: i,
|
|
2972
|
-
...this.config.selectedModel &&
|
|
2973
|
-
...o !== "auto" &&
|
|
1938
|
+
...this.config.selectedModel && de(e.surface, "model.select") ? { modelRef: this.config.selectedModel } : {},
|
|
1939
|
+
...o !== "auto" && de(e.surface, "reasoning.effort") ? { reasoning: o } : {},
|
|
2974
1940
|
extensions: {
|
|
2975
|
-
...this.config.permissionMode &&
|
|
1941
|
+
...this.config.permissionMode && de(e.surface, "approval") ? { "ksadk.approval": this.config.permissionMode } : {},
|
|
2976
1942
|
...r.executionMode === "plan" ? { "ksadk.collaboration": "plan" } : {},
|
|
2977
1943
|
...r.executionMode === "goal" && a ? { "ksadk.goal": a } : {}
|
|
2978
1944
|
}
|
|
2979
1945
|
});
|
|
2980
|
-
return
|
|
1946
|
+
return ue(e.surface, s);
|
|
2981
1947
|
}
|
|
2982
1948
|
async uploadCanonicalAttachments(e) {
|
|
2983
1949
|
this.setStage("uploading-files");
|
|
2984
1950
|
let t = [];
|
|
2985
1951
|
for (let n of e) {
|
|
2986
|
-
if (n.size > 100 * 1024 * 1024) throw new
|
|
1952
|
+
if (n.size > 100 * 1024 * 1024) throw new G("conversation_input_unsupported", "Conversation attachment exceeds the Hosted UI upload limit.", { capability: n.type.startsWith("image/") ? "attachment.image" : "attachment.file" });
|
|
2987
1953
|
let e = new FormData();
|
|
2988
1954
|
e.append("file", n), e.append("AgentId", this.config.agentId);
|
|
2989
1955
|
let r;
|
|
2990
1956
|
try {
|
|
2991
1957
|
r = await this.api.uploadFile(e, { signal: this.abortController?.signal });
|
|
2992
1958
|
} catch (e) {
|
|
2993
|
-
throw new
|
|
1959
|
+
throw new G("conversation_http_error", "Conversation attachment upload failed.", { cause: e });
|
|
2994
1960
|
}
|
|
2995
1961
|
let i = r?.FileData?.fileUri;
|
|
2996
|
-
if (!i) throw new
|
|
1962
|
+
if (!i) throw new G("conversation_contract_mismatch", "Conversation attachment upload did not return an attachment reference.");
|
|
2997
1963
|
t.push({
|
|
2998
1964
|
kind: "attachment",
|
|
2999
1965
|
attachmentRef: i,
|
|
@@ -3024,7 +1990,7 @@ var Mn = {
|
|
|
3024
1990
|
} catch (e) {
|
|
3025
1991
|
this.emit({
|
|
3026
1992
|
type: "system_message",
|
|
3027
|
-
content: `【系统提示】图片 ${t.name} 读取失败,原因: ${
|
|
1993
|
+
content: `【系统提示】图片 ${t.name} 读取失败,原因: ${Dt(e)}`
|
|
3028
1994
|
});
|
|
3029
1995
|
}
|
|
3030
1996
|
continue;
|
|
@@ -3041,7 +2007,7 @@ var Mn = {
|
|
|
3041
2007
|
} catch (e) {
|
|
3042
2008
|
this.emit({
|
|
3043
2009
|
type: "system_message",
|
|
3044
|
-
content: `【系统提示】文件 ${t.name} 上传失败,原因: ${
|
|
2010
|
+
content: `【系统提示】文件 ${t.name} 上传失败,原因: ${Dt(e)}`
|
|
3045
2011
|
});
|
|
3046
2012
|
}
|
|
3047
2013
|
}
|
|
@@ -3063,10 +2029,10 @@ var Mn = {
|
|
|
3063
2029
|
ApiFormat: t,
|
|
3064
2030
|
Model: this.config.selectedModel || void 0,
|
|
3065
2031
|
ModelMetadata: this.config.selectedModelMetadata || void 0,
|
|
3066
|
-
ModelOptions:
|
|
2032
|
+
ModelOptions: At(kt(this.config.thinkingMode)),
|
|
3067
2033
|
Metadata: { agentengine: {
|
|
3068
2034
|
tool_approval_mode: this.config.permissionMode || "risk",
|
|
3069
|
-
...
|
|
2035
|
+
...p(E.getState().modeFor(this.config.agentId)),
|
|
3070
2036
|
...o
|
|
3071
2037
|
} }
|
|
3072
2038
|
};
|
|
@@ -3119,7 +2085,7 @@ var Mn = {
|
|
|
3119
2085
|
status: "running",
|
|
3120
2086
|
countEvent: !1
|
|
3121
2087
|
});
|
|
3122
|
-
let i = new
|
|
2088
|
+
let i = new ke(e), a = r === "agent-block-v1" && t.presentationProfile === "agent-block-v1" ? "agent-block-v1" : "flat-v1", o = new Me(e, void 0, a), s = this.config.kernelCommandEventsEnabled && t.commandId || void 0;
|
|
3123
2089
|
if (this.config.kernelCommandEventsEnabled && !s) return this.emit({
|
|
3124
2090
|
type: "error",
|
|
3125
2091
|
error: /* @__PURE__ */ Error("运行回执缺少命令身份,无法安全订阅本轮输出。")
|
|
@@ -3140,9 +2106,9 @@ var Mn = {
|
|
|
3140
2106
|
let { value: s, done: d } = await r.read();
|
|
3141
2107
|
if (d) break;
|
|
3142
2108
|
_ += g.decode(s, { stream: !0 });
|
|
3143
|
-
let m =
|
|
2109
|
+
let m = Et(_);
|
|
3144
2110
|
_ = m.remainder;
|
|
3145
|
-
for (let r of m.chunks) if (r.trim()) for (let s of
|
|
2111
|
+
for (let r of m.chunks) if (r.trim()) for (let s of Tt(r)) {
|
|
3146
2112
|
f && (s.eventName === "__ping__" || s.data && typeof s.data == "object") && (f = !1, this.emit({
|
|
3147
2113
|
type: "activity",
|
|
3148
2114
|
phase: "正在处理",
|
|
@@ -3158,6 +2124,15 @@ var Mn = {
|
|
|
3158
2124
|
}
|
|
3159
2125
|
let m = String(r.run_id || "");
|
|
3160
2126
|
if (!l && m && (l = m, this.publishInvocation(l), n?.(l)), m && l !== m) continue;
|
|
2127
|
+
if (String(r.event_type).startsWith("mcp.authorization.")) {
|
|
2128
|
+
let e = r.payload ?? r, t = String(e.wait_id || "");
|
|
2129
|
+
t && [
|
|
2130
|
+
"resumed",
|
|
2131
|
+
"cancelled",
|
|
2132
|
+
"expired",
|
|
2133
|
+
"failed"
|
|
2134
|
+
].includes(String(e.status)) ? p.delete(t) : t && p.add(t);
|
|
2135
|
+
}
|
|
3161
2136
|
if (r.family === "interaction" && typeof r.interaction_id == "string" && (r.event_type === "interaction.requested" ? p.add(r.interaction_id) : [
|
|
3162
2137
|
"interaction.resolved",
|
|
3163
2138
|
"interaction.cancelled",
|
|
@@ -3169,7 +2144,7 @@ var Mn = {
|
|
|
3169
2144
|
sessionId: e,
|
|
3170
2145
|
result: {
|
|
3171
2146
|
state: t,
|
|
3172
|
-
presentation:
|
|
2147
|
+
presentation: _e(t, { profile: a }),
|
|
3173
2148
|
runId: l,
|
|
3174
2149
|
cursor: this.lastSeqId
|
|
3175
2150
|
}
|
|
@@ -3182,14 +2157,14 @@ var Mn = {
|
|
|
3182
2157
|
sessionId: e
|
|
3183
2158
|
}), h.EventType === "run_status")) {
|
|
3184
2159
|
let e = String(h.Content?.status || "").toLowerCase();
|
|
3185
|
-
e !== "interrupted" &&
|
|
2160
|
+
e !== "interrupted" && Vt.has(e) && (u = e);
|
|
3186
2161
|
}
|
|
3187
2162
|
}
|
|
3188
2163
|
}
|
|
3189
2164
|
u === void 0 && await new Promise((e) => setTimeout(e, 3e3));
|
|
3190
2165
|
} catch (e) {
|
|
3191
|
-
if (e instanceof
|
|
3192
|
-
if (s && e instanceof
|
|
2166
|
+
if (e instanceof X || this.abortController?.signal.aborted || e instanceof DOMException && e.name === "AbortError") return { terminalStatus: "cancelled" };
|
|
2167
|
+
if (s && e instanceof Y && e.code === 409 && e.detail?.Data?.ReasonCode === "KERNEL_COMMAND_PENDING") {
|
|
3193
2168
|
if (f = !0, this.emit({
|
|
3194
2169
|
type: "activity",
|
|
3195
2170
|
phase: "运行已入队,等待执行",
|
|
@@ -3198,7 +2173,7 @@ var Mn = {
|
|
|
3198
2173
|
}), await new Promise((e) => setTimeout(e, 1e3)), this.abortController?.signal.aborted) return { terminalStatus: "cancelled" };
|
|
3199
2174
|
continue;
|
|
3200
2175
|
}
|
|
3201
|
-
if (e instanceof
|
|
2176
|
+
if (e instanceof Y && e.code >= 400 && e.code < 500 && e.code !== 429) return this.emit({
|
|
3202
2177
|
type: "error",
|
|
3203
2178
|
error: e
|
|
3204
2179
|
}), { terminalStatus: "failed" };
|
|
@@ -3228,32 +2203,32 @@ var Mn = {
|
|
|
3228
2203
|
messageId: r,
|
|
3229
2204
|
invocationId: i
|
|
3230
2205
|
})), s += o.decode(e, { stream: !0 });
|
|
3231
|
-
let { chunks: m, remainder: h } =
|
|
2206
|
+
let { chunks: m, remainder: h } = Et(s);
|
|
3232
2207
|
s = h;
|
|
3233
2208
|
for (let e of m) {
|
|
3234
2209
|
if (!e.trim()) continue;
|
|
3235
2210
|
if (this.isCompactionChunk(e)) {
|
|
3236
|
-
let t =
|
|
2211
|
+
let t = Tt(e);
|
|
3237
2212
|
for (let e of t) e.eventName.startsWith("response.compaction") && this.upsertCompactionMessage({
|
|
3238
2213
|
...e.data,
|
|
3239
2214
|
phase: e.eventName.split(".").pop()
|
|
3240
2215
|
});
|
|
3241
2216
|
continue;
|
|
3242
2217
|
}
|
|
3243
|
-
let i =
|
|
2218
|
+
let i = Tt(e), o = !1;
|
|
3244
2219
|
for (let e of i) {
|
|
3245
2220
|
if (e.eventName === "__done__") {
|
|
3246
2221
|
o = !0;
|
|
3247
2222
|
continue;
|
|
3248
2223
|
}
|
|
3249
|
-
let i =
|
|
2224
|
+
let i = Ut(e.eventName, e.data);
|
|
3250
2225
|
i && !(d.size > 0 && (e.eventName === "response.incomplete" || e.data?.type === "response.incomplete")) && this.emit({
|
|
3251
2226
|
type: "activity",
|
|
3252
2227
|
...i
|
|
3253
2228
|
});
|
|
3254
2229
|
let a = t.parse(e, n);
|
|
3255
2230
|
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);
|
|
3256
|
-
if (
|
|
2231
|
+
if (wt(a)) {
|
|
3257
2232
|
o = !0;
|
|
3258
2233
|
let e = a.find((e) => e.type === "terminal");
|
|
3259
2234
|
u = e && "status" in e ? String(e.status || "") : void 0;
|
|
@@ -3433,12 +2408,12 @@ var Mn = {
|
|
|
3433
2408
|
};
|
|
3434
2409
|
//#endregion
|
|
3435
2410
|
//#region src/utils/recovered-run.ts
|
|
3436
|
-
function
|
|
3437
|
-
let r = e.filter((e) => e.role === "model" && e.invocationId === n), i =
|
|
2411
|
+
function qt(e, t, n) {
|
|
2412
|
+
let r = e.filter((e) => e.role === "model" && e.invocationId === n), i = R(t).filter((e) => e.role === "model"), a = i.map((e) => ({
|
|
3438
2413
|
...e,
|
|
3439
2414
|
id: !e.itemId && i.length === 1 ? r[0]?.id || `${n}:assistant` : e.id,
|
|
3440
2415
|
invocationId: n,
|
|
3441
|
-
blocks:
|
|
2416
|
+
blocks: Ae({
|
|
3442
2417
|
content: e.content,
|
|
3443
2418
|
reasoning: e.reasoning,
|
|
3444
2419
|
reasoningSource: e.reasoningSource,
|
|
@@ -3455,21 +2430,21 @@ function Pn(e, t, n) {
|
|
|
3455
2430
|
}
|
|
3456
2431
|
//#endregion
|
|
3457
2432
|
//#region src/core/run/dispatcher.ts
|
|
3458
|
-
var
|
|
3459
|
-
function
|
|
2433
|
+
var Jt = "连接断开或生成出错,请重试";
|
|
2434
|
+
function Yt(e) {
|
|
3460
2435
|
let t = String(e.message || "").trim();
|
|
3461
|
-
return /runtime agent kernel is not ready/i.test(t) ? "云端运行时尚未就绪,请检查部署状态后重试" : !t || /failed to fetch|networkerror/i.test(t) ?
|
|
2436
|
+
return /runtime agent kernel is not ready/i.test(t) ? "云端运行时尚未就绪,请检查部署状态后重试" : !t || /failed to fetch|networkerror/i.test(t) ? Jt : t.length <= 240 ? t : Jt;
|
|
3462
2437
|
}
|
|
3463
|
-
var
|
|
2438
|
+
var Xt = new Set(["completed"]), Zt = new Set([
|
|
3464
2439
|
"failed",
|
|
3465
2440
|
"error",
|
|
3466
2441
|
"cancelled",
|
|
3467
2442
|
"canceled",
|
|
3468
2443
|
"aborted",
|
|
3469
2444
|
"incomplete"
|
|
3470
|
-
]),
|
|
3471
|
-
function
|
|
3472
|
-
|
|
2445
|
+
]), Qt = /* @__PURE__ */ new Map();
|
|
2446
|
+
function Z(e, t) {
|
|
2447
|
+
U.getState().patchMessages((n) => {
|
|
3473
2448
|
if (n.some((t) => t.id === e)) return t ? n.map((n) => n.id === e ? {
|
|
3474
2449
|
...n,
|
|
3475
2450
|
invocationId: t
|
|
@@ -3494,12 +2469,12 @@ function Bn(e, t) {
|
|
|
3494
2469
|
}];
|
|
3495
2470
|
});
|
|
3496
2471
|
}
|
|
3497
|
-
function
|
|
2472
|
+
function $t(e) {
|
|
3498
2473
|
return e.filter((e) => e.eventType !== "optimistic_assistant_placeholder");
|
|
3499
2474
|
}
|
|
3500
|
-
function
|
|
3501
|
-
let t = String(e || "").trim().toLowerCase(), n =
|
|
3502
|
-
n &&
|
|
2475
|
+
function en(e) {
|
|
2476
|
+
let t = String(e || "").trim().toLowerCase(), n = Xt.has(t) ? "completed" : Zt.has(t) ? "error" : null;
|
|
2477
|
+
n && U.getState().patchMessages((e) => e.map((e) => {
|
|
3503
2478
|
if (!e.tools) return e;
|
|
3504
2479
|
let t = !1, r = Object.fromEntries(Object.entries(e.tools).map(([e, r]) => r.status === "running" ? (t = !0, [e, {
|
|
3505
2480
|
...r,
|
|
@@ -3511,12 +2486,12 @@ function Hn(e) {
|
|
|
3511
2486
|
} : e;
|
|
3512
2487
|
}));
|
|
3513
2488
|
}
|
|
3514
|
-
function
|
|
2489
|
+
function Q(e, t) {
|
|
3515
2490
|
!e.sessionId && t?.draftId && (e = {
|
|
3516
2491
|
...e,
|
|
3517
2492
|
sessionId: t.draftId
|
|
3518
2493
|
});
|
|
3519
|
-
let n = t ? !t.visible : !!(e.sessionId &&
|
|
2494
|
+
let n = t ? !t.visible : !!(e.sessionId && h.getState().currentSessionId !== e.sessionId);
|
|
3520
2495
|
if (n && ![
|
|
3521
2496
|
"activity",
|
|
3522
2497
|
"stage_changed",
|
|
@@ -3530,12 +2505,12 @@ function Un(e, t) {
|
|
|
3530
2505
|
"stream_event",
|
|
3531
2506
|
"conversation_snapshot"
|
|
3532
2507
|
].includes(e.type)) return;
|
|
3533
|
-
let
|
|
3534
|
-
e &&
|
|
2508
|
+
let i = U.getState(), a = (e) => {
|
|
2509
|
+
e && r.getState().updateActivity({ sessionId: e });
|
|
3535
2510
|
};
|
|
3536
2511
|
switch (e.type) {
|
|
3537
2512
|
case "activity":
|
|
3538
|
-
|
|
2513
|
+
r.getState().updateActivity({
|
|
3539
2514
|
sessionId: e.sessionId,
|
|
3540
2515
|
visible: !n,
|
|
3541
2516
|
source: e.source,
|
|
@@ -3546,7 +2521,7 @@ function Un(e, t) {
|
|
|
3546
2521
|
});
|
|
3547
2522
|
break;
|
|
3548
2523
|
case "user_message_added":
|
|
3549
|
-
|
|
2524
|
+
r.getState().setBanner(null), i.patchMessages((t) => [...t, {
|
|
3550
2525
|
id: e.messageId,
|
|
3551
2526
|
role: "user",
|
|
3552
2527
|
content: "",
|
|
@@ -3554,48 +2529,48 @@ function Un(e, t) {
|
|
|
3554
2529
|
}]);
|
|
3555
2530
|
break;
|
|
3556
2531
|
case "assistant_message_created":
|
|
3557
|
-
|
|
2532
|
+
Z(e.messageId, e.invocationId);
|
|
3558
2533
|
break;
|
|
3559
2534
|
case "text_delta":
|
|
3560
|
-
|
|
2535
|
+
Z(e.messageId), a(e.sessionId), i.patchMessages((t) => t.map((t) => t.id === e.messageId ? {
|
|
3561
2536
|
...t,
|
|
3562
2537
|
content: t.content + e.delta,
|
|
3563
|
-
blocks:
|
|
2538
|
+
blocks: ge(t.blocks, e.delta)
|
|
3564
2539
|
} : t));
|
|
3565
2540
|
break;
|
|
3566
2541
|
case "text_replace":
|
|
3567
|
-
if (e.sessionId &&
|
|
3568
|
-
|
|
2542
|
+
if (e.sessionId && h.getState().currentSessionId && e.sessionId !== h.getState().currentSessionId && e.sessionId !== t?.draftId) break;
|
|
2543
|
+
i.patchMessages((t) => t.map((t) => t.id === e.messageId && t.role === "model" ? {
|
|
3569
2544
|
...t,
|
|
3570
2545
|
content: e.text,
|
|
3571
|
-
blocks:
|
|
3572
|
-
} : t)),
|
|
2546
|
+
blocks: je(t.blocks, e.text)
|
|
2547
|
+
} : t)), a(e.sessionId);
|
|
3573
2548
|
break;
|
|
3574
2549
|
case "text_final":
|
|
3575
|
-
|
|
3576
|
-
let n = !!(e.text && !t.content && t.reasoning?.endsWith(e.text)), r = n ? t.reasoning.slice(0, -e.text.length) : t.reasoning, i = n ?
|
|
2550
|
+
Z(e.messageId), a(e.sessionId), i.patchMessages((t) => t.map((t) => t.id === e.messageId ? (() => {
|
|
2551
|
+
let n = !!(e.text && !t.content && t.reasoning?.endsWith(e.text)), r = n ? t.reasoning.slice(0, -e.text.length) : t.reasoning, i = n ? ye(t.blocks, e.text) : t.blocks;
|
|
3577
2552
|
return {
|
|
3578
2553
|
...t,
|
|
3579
2554
|
reasoning: r,
|
|
3580
2555
|
content: e.text,
|
|
3581
|
-
blocks:
|
|
2556
|
+
blocks: ve(i, e.text)
|
|
3582
2557
|
};
|
|
3583
2558
|
})() : t));
|
|
3584
2559
|
break;
|
|
3585
2560
|
case "reasoning_delta":
|
|
3586
|
-
|
|
2561
|
+
Z(e.messageId), a(e.sessionId), i.patchMessages((t) => t.map((t) => t.id === e.messageId ? {
|
|
3587
2562
|
...t,
|
|
3588
2563
|
reasoning: (t.reasoning || "") + e.delta,
|
|
3589
|
-
blocks:
|
|
2564
|
+
blocks: De(t.blocks, e.delta)
|
|
3590
2565
|
} : t));
|
|
3591
2566
|
break;
|
|
3592
2567
|
case "tool_upsert":
|
|
3593
|
-
|
|
2568
|
+
Z(e.messageId), a(e.sessionId), i.patchMessages((t) => t.map((t) => {
|
|
3594
2569
|
if (t.id !== e.messageId) return t;
|
|
3595
2570
|
let n = t.tools?.[e.name], r = n?.approvalStatus === "approved" || n?.approvalStatus === "rejected" || n?.approvalStatus === "cancelled", i = e.status, a = n?.approvalStatus === "rejected" || n?.approvalStatus === "cancelled" ? "completed" : n?.status === "error" && i !== "error" ? "error" : i;
|
|
3596
2571
|
return {
|
|
3597
2572
|
...t,
|
|
3598
|
-
blocks:
|
|
2573
|
+
blocks: be(t.blocks, e.name, {
|
|
3599
2574
|
args: e.args,
|
|
3600
2575
|
status: a,
|
|
3601
2576
|
extra: e.extra
|
|
@@ -3618,12 +2593,12 @@ function Un(e, t) {
|
|
|
3618
2593
|
}));
|
|
3619
2594
|
break;
|
|
3620
2595
|
case "tool_result":
|
|
3621
|
-
|
|
2596
|
+
Z(e.messageId), a(e.sessionId), i.patchMessages((t) => t.map((t) => {
|
|
3622
2597
|
if (t.id !== e.messageId) return t;
|
|
3623
|
-
let n =
|
|
2598
|
+
let n = F(e.output) ? "error" : "completed";
|
|
3624
2599
|
return {
|
|
3625
2600
|
...t,
|
|
3626
|
-
blocks:
|
|
2601
|
+
blocks: be(t.blocks, e.name, {
|
|
3627
2602
|
output: e.output,
|
|
3628
2603
|
status: n
|
|
3629
2604
|
}),
|
|
@@ -3642,7 +2617,7 @@ function Un(e, t) {
|
|
|
3642
2617
|
}));
|
|
3643
2618
|
break;
|
|
3644
2619
|
case "approval_requested":
|
|
3645
|
-
if (
|
|
2620
|
+
if (w({
|
|
3646
2621
|
approvalRequestId: e.approvalRequestId,
|
|
3647
2622
|
protocol: e.protocol,
|
|
3648
2623
|
requestSchema: e.requestSchema,
|
|
@@ -3654,7 +2629,7 @@ function Un(e, t) {
|
|
|
3654
2629
|
previousResponseId: e.previousResponseId,
|
|
3655
2630
|
sessionId: e.sessionId
|
|
3656
2631
|
}), n) break;
|
|
3657
|
-
|
|
2632
|
+
Z(e.messageId), i.patchMessages((t) => t.map((t) => {
|
|
3658
2633
|
if (t.id !== e.messageId) return t;
|
|
3659
2634
|
let n = t.tools?.[e.approvalRequestId], r = n?.approvalStatus === "approved" || n?.approvalStatus === "rejected" || n?.approvalStatus === "cancelled", i = {
|
|
3660
2635
|
approvalRequestId: e.approvalRequestId,
|
|
@@ -3666,7 +2641,7 @@ function Un(e, t) {
|
|
|
3666
2641
|
}, a = r ? n.status : "paused";
|
|
3667
2642
|
return {
|
|
3668
2643
|
...t,
|
|
3669
|
-
blocks:
|
|
2644
|
+
blocks: be(t.blocks, e.name, {
|
|
3670
2645
|
args: e.args,
|
|
3671
2646
|
status: a,
|
|
3672
2647
|
extra: i
|
|
@@ -3685,10 +2660,10 @@ function Un(e, t) {
|
|
|
3685
2660
|
}));
|
|
3686
2661
|
break;
|
|
3687
2662
|
case "interaction_submit_rejected":
|
|
3688
|
-
|
|
2663
|
+
v(e);
|
|
3689
2664
|
break;
|
|
3690
2665
|
case "question_requested":
|
|
3691
|
-
|
|
2666
|
+
A({
|
|
3692
2667
|
questionId: e.questionId,
|
|
3693
2668
|
questions: e.questions,
|
|
3694
2669
|
runId: e.runId,
|
|
@@ -3696,7 +2671,7 @@ function Un(e, t) {
|
|
|
3696
2671
|
});
|
|
3697
2672
|
break;
|
|
3698
2673
|
case "question_resolved":
|
|
3699
|
-
|
|
2674
|
+
y({
|
|
3700
2675
|
questionId: e.questionId,
|
|
3701
2676
|
answers: e.answers,
|
|
3702
2677
|
revision: e.revision,
|
|
@@ -3704,13 +2679,13 @@ function Un(e, t) {
|
|
|
3704
2679
|
});
|
|
3705
2680
|
break;
|
|
3706
2681
|
case "approval_resolved":
|
|
3707
|
-
if (
|
|
2682
|
+
if (O({
|
|
3708
2683
|
approvalRequestId: e.approvalRequestId,
|
|
3709
2684
|
decision: e.decision,
|
|
3710
2685
|
revision: e.revision,
|
|
3711
2686
|
sessionId: e.sessionId
|
|
3712
2687
|
}), n) break;
|
|
3713
|
-
|
|
2688
|
+
i.patchMessages((t) => t.map((t) => {
|
|
3714
2689
|
if (!t.tools) return t;
|
|
3715
2690
|
let n = !1, r = Object.fromEntries(Object.entries(t.tools).map(([t, r]) => {
|
|
3716
2691
|
if (r.approvalRequestId !== e.approvalRequestId) return [t, r];
|
|
@@ -3741,7 +2716,7 @@ function Un(e, t) {
|
|
|
3741
2716
|
}));
|
|
3742
2717
|
break;
|
|
3743
2718
|
case "system_message":
|
|
3744
|
-
|
|
2719
|
+
i.patchMessages((t) => [...t, {
|
|
3745
2720
|
id: String(Date.now() + Math.random()),
|
|
3746
2721
|
role: "system",
|
|
3747
2722
|
content: e.content,
|
|
@@ -3749,48 +2724,48 @@ function Un(e, t) {
|
|
|
3749
2724
|
}]);
|
|
3750
2725
|
break;
|
|
3751
2726
|
case "compaction": {
|
|
3752
|
-
let t = `compaction-${Date.now()}`, n = e.phase === "start" ? "running" : e.phase === "failed" ? "failed" : "completed",
|
|
2727
|
+
let t = `compaction-${Date.now()}`, n = e.phase === "start" ? "running" : e.phase === "failed" ? "failed" : "completed", r = B({
|
|
3753
2728
|
id: t,
|
|
3754
2729
|
timestamp: Date.now(),
|
|
3755
2730
|
status: n,
|
|
3756
2731
|
trigger: e.trigger,
|
|
3757
2732
|
compactedUntilSeqId: e.compactedUntilSeqId
|
|
3758
2733
|
});
|
|
3759
|
-
|
|
2734
|
+
i.patchMessages((e) => e.findIndex((e) => e.id === t) < 0 ? [...e, r] : e.map((e) => e.id === t ? {
|
|
3760
2735
|
...e,
|
|
3761
|
-
...
|
|
2736
|
+
...r
|
|
3762
2737
|
} : e));
|
|
3763
2738
|
break;
|
|
3764
2739
|
}
|
|
3765
2740
|
case "stage_changed":
|
|
3766
|
-
e.stage === "streaming" || e.stage === "connecting" ?
|
|
2741
|
+
e.stage === "streaming" || e.stage === "connecting" ? r.getState().setSessionStreaming(e.sessionId, !0) : (e.stage === "completing" || e.stage === "error" || e.stage === "cancelled") && r.getState().setSessionStreaming(e.sessionId, !1);
|
|
3767
2742
|
break;
|
|
3768
2743
|
case "stream_ended":
|
|
3769
|
-
|
|
2744
|
+
r.getState().setSessionStreaming(e.sessionId, !1), n || U.getState().patchMessages((t) => $t(t).map((t) => !(!e.runId || t.runId === e.runId || t.invocationId === e.runId) || t.role !== "model" || !t.blocks?.some((e) => e.status === "streaming") ? t : {
|
|
3770
2745
|
...t,
|
|
3771
|
-
blocks:
|
|
2746
|
+
blocks: we(t.blocks.map((e) => e.type === "text" && e.status === "streaming" ? {
|
|
3772
2747
|
...e,
|
|
3773
2748
|
status: "done"
|
|
3774
2749
|
} : e))
|
|
3775
2750
|
})), globalThis.setTimeout(() => {
|
|
3776
|
-
let t =
|
|
2751
|
+
let t = r.getState();
|
|
3777
2752
|
t.getSessionActivity(e.sessionId)?.status === "completed" && t.clearSessionActivity(e.sessionId);
|
|
3778
2753
|
}, 2400);
|
|
3779
2754
|
break;
|
|
3780
2755
|
case "error": {
|
|
3781
|
-
let t =
|
|
3782
|
-
|
|
2756
|
+
let t = Yt(e.error);
|
|
2757
|
+
r.getState().setSessionStreaming(e.sessionId, !1), r.getState().updateActivity({
|
|
3783
2758
|
sessionId: e.sessionId,
|
|
3784
2759
|
visible: !n,
|
|
3785
2760
|
status: "failed",
|
|
3786
2761
|
phase: "运行失败",
|
|
3787
2762
|
detail: t,
|
|
3788
2763
|
countEvent: !1
|
|
3789
|
-
}), n || (
|
|
2764
|
+
}), n || (r.getState().setBanner({
|
|
3790
2765
|
kind: "error",
|
|
3791
2766
|
message: t,
|
|
3792
2767
|
sessionId: e.sessionId
|
|
3793
|
-
}),
|
|
2768
|
+
}), i.patchMessages((e) => [...$t(e), {
|
|
3794
2769
|
id: String(Date.now()),
|
|
3795
2770
|
role: "model",
|
|
3796
2771
|
content: `运行失败:${t}`,
|
|
@@ -3799,51 +2774,51 @@ function Un(e, t) {
|
|
|
3799
2774
|
break;
|
|
3800
2775
|
}
|
|
3801
2776
|
case "rate_limited":
|
|
3802
|
-
|
|
2777
|
+
r.getState().setSessionStreaming(e.sessionId, !1), r.getState().updateActivity({
|
|
3803
2778
|
sessionId: e.sessionId,
|
|
3804
2779
|
visible: !n,
|
|
3805
2780
|
status: "failed",
|
|
3806
2781
|
phase: "请求被限流",
|
|
3807
2782
|
countEvent: !1
|
|
3808
|
-
}), n || (
|
|
2783
|
+
}), n || (r.getState().setBanner({
|
|
3809
2784
|
kind: "rate_limited",
|
|
3810
2785
|
message: e.message || "请求过于频繁,请稍后重试",
|
|
3811
2786
|
retryAfterSec: e.retryAfterSec,
|
|
3812
2787
|
sessionId: e.sessionId
|
|
3813
|
-
}),
|
|
2788
|
+
}), i.patchMessages($t));
|
|
3814
2789
|
break;
|
|
3815
2790
|
case "terminal":
|
|
3816
|
-
e.sessionId && String(e.status || "").trim().toLowerCase() !== "incomplete" &&
|
|
2791
|
+
e.sessionId && String(e.status || "").trim().toLowerCase() !== "incomplete" && T.markSessionTerminal(e.sessionId), n || en(e.status);
|
|
3817
2792
|
break;
|
|
3818
2793
|
case "stream_event": {
|
|
3819
2794
|
let t = e.sessionId || e.event.SessionId;
|
|
3820
|
-
|
|
3821
|
-
let
|
|
3822
|
-
!n && typeof
|
|
2795
|
+
x(e.event, t || void 0);
|
|
2796
|
+
let i = e.event.SeqId;
|
|
2797
|
+
!n && typeof i == "number" && i > 0 && r.getState().setLastSeqId(i), t && r.getState().updateActivity({
|
|
3823
2798
|
sessionId: t,
|
|
3824
2799
|
visible: !n
|
|
3825
2800
|
});
|
|
3826
|
-
let
|
|
3827
|
-
if (!n && t &&
|
|
3828
|
-
let n = `${t}:${
|
|
3829
|
-
|
|
2801
|
+
let a = String(e.event.InvocationId || "").trim();
|
|
2802
|
+
if (!n && t && a) {
|
|
2803
|
+
let n = `${t}:${a}`, r = L(Qt.get(n) || [], [e.event]);
|
|
2804
|
+
Qt.set(n, r), U.getState().patchMessages((e) => e.some((e) => e.eventType === "conversation_item_v1" && e.runId === a) ? e : qt(e, r, a)), P(e.event) && Qt.delete(n);
|
|
3830
2805
|
}
|
|
3831
|
-
e.event.EventType === "run_checkpoint" && t &&
|
|
2806
|
+
e.event.EventType === "run_checkpoint" && t && W.getState().upsertSessionCheckpoint(t, e.event);
|
|
3832
2807
|
{
|
|
3833
|
-
let
|
|
3834
|
-
|
|
2808
|
+
let i = z(e.event);
|
|
2809
|
+
i === "completed" ? r.getState().updateActivity({
|
|
3835
2810
|
sessionId: t,
|
|
3836
2811
|
visible: !n,
|
|
3837
2812
|
status: "completed",
|
|
3838
2813
|
phase: "后台长任务已完成",
|
|
3839
2814
|
countEvent: !1
|
|
3840
|
-
}) :
|
|
2815
|
+
}) : i === "cancelled" || i === "canceled" || i === "aborted" ? r.getState().updateActivity({
|
|
3841
2816
|
sessionId: t,
|
|
3842
2817
|
visible: !n,
|
|
3843
2818
|
status: "stopped",
|
|
3844
2819
|
phase: "后台长任务已取消",
|
|
3845
2820
|
countEvent: !1
|
|
3846
|
-
}) : (
|
|
2821
|
+
}) : (i === "failed" || i === "error") && r.getState().updateActivity({
|
|
3847
2822
|
sessionId: t,
|
|
3848
2823
|
visible: !n,
|
|
3849
2824
|
status: "failed",
|
|
@@ -3854,15 +2829,15 @@ function Un(e, t) {
|
|
|
3854
2829
|
break;
|
|
3855
2830
|
}
|
|
3856
2831
|
case "conversation_snapshot": {
|
|
3857
|
-
let t =
|
|
3858
|
-
for (let e of t.interactions)
|
|
2832
|
+
let t = Te(e.result);
|
|
2833
|
+
for (let e of t.interactions) T.upsert(e);
|
|
3859
2834
|
if (n) break;
|
|
3860
|
-
|
|
2835
|
+
i.patchMessages((t) => Oe(t, e.result, e.optimisticMessageId)), a(e.sessionId);
|
|
3861
2836
|
break;
|
|
3862
2837
|
}
|
|
3863
2838
|
case "a2ui_surface_begin": {
|
|
3864
2839
|
let t = `a2ui-${e.surfaceId}`;
|
|
3865
|
-
|
|
2840
|
+
U.getState().patchMessages((n) => [...n.filter((e) => e.id !== t), {
|
|
3866
2841
|
id: t,
|
|
3867
2842
|
role: "a2ui",
|
|
3868
2843
|
content: "",
|
|
@@ -3876,7 +2851,7 @@ function Un(e, t) {
|
|
|
3876
2851
|
}
|
|
3877
2852
|
case "a2ui_surface_update": {
|
|
3878
2853
|
let t = `a2ui-${e.surfaceId}`;
|
|
3879
|
-
|
|
2854
|
+
U.getState().patchMessages((n) => n.map((n) => n.id === t && n.a2ui ? {
|
|
3880
2855
|
...n,
|
|
3881
2856
|
a2ui: {
|
|
3882
2857
|
...n.a2ui,
|
|
@@ -3887,7 +2862,7 @@ function Un(e, t) {
|
|
|
3887
2862
|
}
|
|
3888
2863
|
case "a2ui_surface_end": {
|
|
3889
2864
|
let t = `a2ui-${e.surfaceId}`;
|
|
3890
|
-
|
|
2865
|
+
U.getState().patchMessages((e) => e.map((e) => e.id === t && e.a2ui ? {
|
|
3891
2866
|
...e,
|
|
3892
2867
|
a2ui: {
|
|
3893
2868
|
...e.a2ui,
|
|
@@ -3898,7 +2873,7 @@ function Un(e, t) {
|
|
|
3898
2873
|
}
|
|
3899
2874
|
case "a2ui_interaction": {
|
|
3900
2875
|
let t = `a2ui-${e.surfaceId}`;
|
|
3901
|
-
|
|
2876
|
+
U.getState().patchMessages((n) => n.map((n) => n.id === t && n.a2ui ? {
|
|
3902
2877
|
...n,
|
|
3903
2878
|
a2ui: {
|
|
3904
2879
|
...n.a2ui,
|
|
@@ -3912,7 +2887,7 @@ function Un(e, t) {
|
|
|
3912
2887
|
break;
|
|
3913
2888
|
}
|
|
3914
2889
|
case "agui_activity":
|
|
3915
|
-
|
|
2890
|
+
U.getState().patchMessages((t) => {
|
|
3916
2891
|
let n = t.find((t) => t.id === e.messageId), r = e.runId || n?.runId || n?.invocationId, i = `agui-a2ui-${JSON.stringify([
|
|
3917
2892
|
r || e.messageId,
|
|
3918
2893
|
e.interactionId || "",
|
|
@@ -3923,7 +2898,7 @@ function Un(e, t) {
|
|
|
3923
2898
|
originMessageId: e.messageId,
|
|
3924
2899
|
...r ? { runId: r } : {},
|
|
3925
2900
|
...e.interactionId ? { interactionId: e.interactionId } : {}
|
|
3926
|
-
}, o =
|
|
2901
|
+
}, o = me(t.flatMap((e) => [...e.aguiActivity ? [{
|
|
3927
2902
|
message: e,
|
|
3928
2903
|
activity: e.aguiActivity
|
|
3929
2904
|
}] : [], ...(e.aguiActivities || []).map((t) => ({
|
|
@@ -3935,12 +2910,12 @@ function Un(e, t) {
|
|
|
3935
2910
|
});
|
|
3936
2911
|
if (o) return t.map((t) => t === o.message ? {
|
|
3937
2912
|
...t,
|
|
3938
|
-
...t.aguiActivity === o.activity ? { aguiActivity:
|
|
2913
|
+
...t.aguiActivity === o.activity ? { aguiActivity: pe(o.activity, a, e.batchId) } : { aguiActivities: t.aguiActivities?.map((t) => t === o.activity ? pe(t, a, e.batchId) : t) }
|
|
3939
2914
|
} : t);
|
|
3940
2915
|
let s = !1, c = t.map((t) => {
|
|
3941
2916
|
if (t.id !== e.messageId) return t;
|
|
3942
2917
|
s = !0;
|
|
3943
|
-
let n = [...t.aguiActivities || [],
|
|
2918
|
+
let n = [...t.aguiActivities || [], pe(void 0, a, e.batchId)];
|
|
3944
2919
|
return {
|
|
3945
2920
|
...t,
|
|
3946
2921
|
aguiActivities: n
|
|
@@ -3953,112 +2928,112 @@ function Un(e, t) {
|
|
|
3953
2928
|
content: "",
|
|
3954
2929
|
timestamp: l?.timestamp || Date.now(),
|
|
3955
2930
|
...r ? { invocationId: r } : {},
|
|
3956
|
-
aguiActivity:
|
|
2931
|
+
aguiActivity: pe(l?.aguiActivity, a, e.batchId)
|
|
3957
2932
|
};
|
|
3958
2933
|
return l ? t.map((e) => e.id === i ? u : e) : [...t, u];
|
|
3959
2934
|
});
|
|
3960
2935
|
break;
|
|
3961
2936
|
}
|
|
3962
2937
|
}
|
|
3963
|
-
function
|
|
3964
|
-
|
|
2938
|
+
function tn() {
|
|
2939
|
+
Qt.clear();
|
|
3965
2940
|
}
|
|
3966
2941
|
//#endregion
|
|
3967
2942
|
//#region src/hooks/useRunAgent.ts
|
|
3968
|
-
var
|
|
3969
|
-
function
|
|
2943
|
+
var nn = 64;
|
|
2944
|
+
function rn(e, t, n) {
|
|
3970
2945
|
if (t.sessionId = n, t.conversationId) return;
|
|
3971
2946
|
let r = JSON.stringify([t.agentId, n]);
|
|
3972
2947
|
e.set(r, t), t.key !== r && e.get(t.key) === t && e.delete(t.key), t.key = r;
|
|
3973
2948
|
}
|
|
3974
|
-
function
|
|
3975
|
-
let n =
|
|
3976
|
-
let t =
|
|
3977
|
-
if (!(t.size <=
|
|
3978
|
-
if (t.size <=
|
|
2949
|
+
function an(t) {
|
|
2950
|
+
let n = _(), i = J(/* @__PURE__ */ new Map()), a = J(/* @__PURE__ */ new Set()), o = K((e) => a.current.has(e), []), s = K((e) => {
|
|
2951
|
+
let t = i.current;
|
|
2952
|
+
if (!(t.size <= nn)) for (let [n, r] of t) {
|
|
2953
|
+
if (t.size <= nn) break;
|
|
3979
2954
|
n === e || r.engine.stage !== "idle" || r.queue.length > 0 || r.isVisible() || t.delete(n);
|
|
3980
2955
|
}
|
|
3981
|
-
}, []),
|
|
2956
|
+
}, []), c = Fe(() => new Pe({ rendererCatalog: he }), []), l = t.conversationClient === void 0 ? t.uiCapabilities.ConversationSurface == null ? null : c : t.conversationClient, { agentId: u, apiFormats: d, agentFramework: f, selectedModel: p, selectedModelMetadata: m, thinkingMode: g, permissionMode: v, currentSessionIdRef: y, conversationIdRef: x, queuedDraftRef: S, onRunSettled: C, onSessionCreated: w, waitForPendingSessionCreation: T, uiCapabilities: E, outbox: D } = t, O = Fe(() => ({
|
|
3982
2957
|
a2uiCatalogRegistry: n,
|
|
3983
|
-
agentId:
|
|
3984
|
-
apiFormats:
|
|
3985
|
-
agentFramework:
|
|
3986
|
-
selectedModel:
|
|
3987
|
-
selectedModelMetadata:
|
|
3988
|
-
thinkingMode: E.Thinking ?
|
|
3989
|
-
permissionMode:
|
|
2958
|
+
agentId: u,
|
|
2959
|
+
apiFormats: d,
|
|
2960
|
+
agentFramework: f,
|
|
2961
|
+
selectedModel: p,
|
|
2962
|
+
selectedModelMetadata: m,
|
|
2963
|
+
thinkingMode: E.Thinking ? g : "auto",
|
|
2964
|
+
permissionMode: v,
|
|
3990
2965
|
runtimeCapabilityMatrix: E.RuntimeCapabilityMatrix,
|
|
3991
2966
|
hostedChatTransport: e(E, { requireResumableRun: !!(E.RunLifecycle?.Enabled && E.RunLifecycle.Resume) }),
|
|
3992
2967
|
checkpointResumePreviewEnabled: !!E.RunLifecycle?.CheckpointResumePreview,
|
|
3993
2968
|
kernelSessionEventsEnabled: E.KernelSessionEvents === !0 || E.KernelSessionEventsByCommand === !0,
|
|
3994
2969
|
kernelCommandEventsEnabled: E.KernelSessionEventsByCommand === !0,
|
|
3995
|
-
presentationProfile:
|
|
3996
|
-
conversationClient:
|
|
2970
|
+
presentationProfile: le(E.ConversationSurface, he),
|
|
2971
|
+
conversationClient: l || void 0
|
|
3997
2972
|
}), [
|
|
2973
|
+
u,
|
|
2974
|
+
d,
|
|
2975
|
+
f,
|
|
3998
2976
|
p,
|
|
3999
2977
|
m,
|
|
4000
|
-
h,
|
|
4001
2978
|
g,
|
|
4002
|
-
_,
|
|
4003
2979
|
v,
|
|
4004
|
-
y,
|
|
4005
2980
|
E,
|
|
4006
|
-
|
|
2981
|
+
l,
|
|
4007
2982
|
n
|
|
4008
|
-
]), k =
|
|
4009
|
-
let n = t.conversationIdRef?.current,
|
|
2983
|
+
]), k = K((e = y.current) => {
|
|
2984
|
+
let n = t.conversationIdRef?.current, r = JSON.stringify([u, n || e || "new-session"]), a = i.current.get(r);
|
|
4010
2985
|
if (!a) {
|
|
4011
|
-
|
|
4012
|
-
let o = () => t.agentIdRef.current ===
|
|
2986
|
+
s(r);
|
|
2987
|
+
let o = () => t.agentIdRef.current === u && (t.conversationIdRef ? t.conversationIdRef.current === n : y.current === a.sessionId), c = new Kt(t.api, {
|
|
4013
2988
|
isVisible: o,
|
|
4014
2989
|
draftId: n
|
|
4015
2990
|
});
|
|
4016
2991
|
a = {
|
|
4017
|
-
key:
|
|
4018
|
-
agentId:
|
|
2992
|
+
key: r,
|
|
2993
|
+
agentId: u,
|
|
4019
2994
|
conversationId: n,
|
|
4020
2995
|
sessionId: e || null,
|
|
4021
|
-
engine:
|
|
2996
|
+
engine: c,
|
|
4022
2997
|
queue: [],
|
|
4023
2998
|
isVisible: o
|
|
4024
|
-
},
|
|
2999
|
+
}, c.subscribe((e) => Q(e, {
|
|
4025
3000
|
visible: o(),
|
|
4026
3001
|
draftId: n
|
|
4027
|
-
})),
|
|
3002
|
+
})), i.current.set(r, a);
|
|
4028
3003
|
}
|
|
4029
3004
|
return a;
|
|
4030
3005
|
}, [
|
|
4031
|
-
|
|
3006
|
+
u,
|
|
4032
3007
|
t.agentIdRef,
|
|
4033
3008
|
t.api,
|
|
4034
3009
|
t.conversationIdRef,
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
]), A =
|
|
3010
|
+
y,
|
|
3011
|
+
s
|
|
3012
|
+
]), A = K((e) => {
|
|
4038
3013
|
let t = k(e);
|
|
4039
3014
|
return t.engine.stage === "idle" && t.engine.updateConfig(O), t.engine;
|
|
4040
|
-
}, [O, k]), j =
|
|
3015
|
+
}, [O, k]), j = K((e) => {
|
|
4041
3016
|
if (!e.isVisible()) return;
|
|
4042
3017
|
let t = e.queue.map((e) => e.draft);
|
|
4043
|
-
S.current = t,
|
|
4044
|
-
}, [S]), M =
|
|
3018
|
+
S.current = t, b.getState().setQueuedDrafts(t);
|
|
3019
|
+
}, [S]), M = K((e) => {
|
|
4045
3020
|
let t = e.queue[0];
|
|
4046
3021
|
!t || e.engine.stage !== "idle" || (e.queue.shift(), j(e), queueMicrotask(() => {
|
|
4047
3022
|
t.launch() || (e.queue.unshift(t), j(e));
|
|
4048
3023
|
}));
|
|
4049
3024
|
}, [j]);
|
|
4050
|
-
|
|
4051
|
-
let e = JSON.stringify([
|
|
4052
|
-
n ? j(n) : (S.current = [],
|
|
3025
|
+
q(() => {
|
|
3026
|
+
let e = JSON.stringify([u, t.conversationId || x?.current || t.currentSessionId || "new-session"]), n = i.current.get(e);
|
|
3027
|
+
n ? j(n) : (S.current = [], b.getState().setQueuedDrafts([]));
|
|
4053
3028
|
}, [
|
|
4054
|
-
|
|
3029
|
+
u,
|
|
4055
3030
|
t.currentSessionId,
|
|
4056
3031
|
t.conversationId,
|
|
4057
3032
|
x,
|
|
4058
3033
|
j,
|
|
4059
3034
|
S
|
|
4060
3035
|
]);
|
|
4061
|
-
let
|
|
3036
|
+
let ee = K((e) => {
|
|
4062
3037
|
let t = e.text.trim(), n = e.attachments.map((e) => ({
|
|
4063
3038
|
name: e.name,
|
|
4064
3039
|
url: URL.createObjectURL(e),
|
|
@@ -4066,7 +3041,7 @@ function qn(t) {
|
|
|
4066
3041
|
}));
|
|
4067
3042
|
if (!t && n.length === 0) return;
|
|
4068
3043
|
let r = `optimistic-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
4069
|
-
return
|
|
3044
|
+
return U.getState().patchMessages((e) => [...e, {
|
|
4070
3045
|
id: r,
|
|
4071
3046
|
role: "user",
|
|
4072
3047
|
content: t,
|
|
@@ -4074,9 +3049,9 @@ function qn(t) {
|
|
|
4074
3049
|
eventType: "optimistic_user_message",
|
|
4075
3050
|
attachments: n.length ? n : void 0
|
|
4076
3051
|
}]), r;
|
|
4077
|
-
}, []),
|
|
3052
|
+
}, []), N = K((e) => {
|
|
4078
3053
|
let t = `optimistic-assistant-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
4079
|
-
return
|
|
3054
|
+
return U.getState().patchMessages((n) => {
|
|
4080
3055
|
let r = n.findIndex((t) => t.id === e), i = r < 0 ? n.length : r + 1;
|
|
4081
3056
|
return [
|
|
4082
3057
|
...n.slice(0, i),
|
|
@@ -4091,81 +3066,81 @@ function qn(t) {
|
|
|
4091
3066
|
...n.slice(i)
|
|
4092
3067
|
];
|
|
4093
3068
|
}), t;
|
|
4094
|
-
}, []),
|
|
4095
|
-
if (
|
|
4096
|
-
let
|
|
4097
|
-
j(
|
|
4098
|
-
let
|
|
3069
|
+
}, []), P = K(async (e, t, n, o, s, c) => {
|
|
3070
|
+
if (c && a.current.has(c)) return !1;
|
|
3071
|
+
let l = k();
|
|
3072
|
+
j(l);
|
|
3073
|
+
let u = {
|
|
4099
3074
|
text: e,
|
|
4100
3075
|
attachments: [...t],
|
|
4101
3076
|
responsesInput: n,
|
|
4102
|
-
previousResponseId:
|
|
4103
|
-
executionMode:
|
|
4104
|
-
optimisticMessageId:
|
|
3077
|
+
previousResponseId: o,
|
|
3078
|
+
executionMode: s,
|
|
3079
|
+
optimisticMessageId: ee({
|
|
4105
3080
|
text: e,
|
|
4106
3081
|
attachments: t
|
|
4107
3082
|
})
|
|
4108
|
-
},
|
|
4109
|
-
requestId:
|
|
4110
|
-
conversationId:
|
|
4111
|
-
agentId:
|
|
3083
|
+
}, d = n === void 0 && l.conversationId && D ? D : void 0, f = l.conversationId && d ? d.enqueue({
|
|
3084
|
+
requestId: c,
|
|
3085
|
+
conversationId: l.conversationId,
|
|
3086
|
+
agentId: l.agentId,
|
|
4112
3087
|
text: e,
|
|
4113
3088
|
attachments: t.map((e) => ({
|
|
4114
3089
|
name: e.name,
|
|
4115
3090
|
type: e.type,
|
|
4116
3091
|
size: e.size
|
|
4117
3092
|
})),
|
|
4118
|
-
executionMode:
|
|
3093
|
+
executionMode: s
|
|
4119
3094
|
}) : void 0;
|
|
4120
|
-
|
|
4121
|
-
let
|
|
3095
|
+
f && d && (a.current.add(f.requestId), d.setRuntimeAttachments(f.requestId, t));
|
|
3096
|
+
let p;
|
|
4122
3097
|
try {
|
|
4123
|
-
|
|
3098
|
+
p = await T?.();
|
|
4124
3099
|
} catch (e) {
|
|
4125
|
-
throw
|
|
3100
|
+
throw f && d && (a.current.delete(f.requestId), d.update(f.requestId, {
|
|
4126
3101
|
status: "unknown",
|
|
4127
3102
|
error: "创建会话的结果待确认。"
|
|
4128
3103
|
})), e;
|
|
4129
3104
|
}
|
|
4130
|
-
!
|
|
4131
|
-
let
|
|
4132
|
-
|
|
4133
|
-
}),
|
|
4134
|
-
if (
|
|
4135
|
-
|
|
4136
|
-
let e =
|
|
4137
|
-
...
|
|
4138
|
-
sessionId:
|
|
3105
|
+
!l.sessionId && p && rn(i.current, l, p);
|
|
3106
|
+
let m, g = n === void 0 ? null : new Promise((e) => {
|
|
3107
|
+
m = e;
|
|
3108
|
+
}), _ = () => {
|
|
3109
|
+
if (l.engine.stage !== "idle") return !1;
|
|
3110
|
+
l.engine.updateConfig(O), f && d && d.markSending(f.requestId), l.isVisible() && (b.getState().setMobileActionsOpen(!1), N(u.optimisticMessageId)), r.getState().setSessionStreaming(l.sessionId || l.conversationId, !0);
|
|
3111
|
+
let e = l.engine.start({
|
|
3112
|
+
...u,
|
|
3113
|
+
sessionId: l.sessionId,
|
|
4139
3114
|
onInvocationCreated: (e) => {
|
|
4140
|
-
|
|
3115
|
+
f && d && d.update(f.requestId, { invocationId: e }), l.isVisible() && U.getState().patchMessages((t) => t.map((t) => t.id === u.optimisticMessageId ? {
|
|
4141
3116
|
...t,
|
|
4142
3117
|
invocationId: e
|
|
4143
3118
|
} : t));
|
|
4144
3119
|
},
|
|
4145
3120
|
onSessionCreated: (e) => {
|
|
4146
|
-
let t =
|
|
4147
|
-
|
|
3121
|
+
let t = l.isVisible(), n = l.sessionId || l.conversationId;
|
|
3122
|
+
rn(i.current, l, e), f && d && d.update(f.requestId, { nativeSessionId: e }), r.getState().setSessionStreaming(e, !0), n !== e && r.getState().setSessionStreaming(n, !1), w?.(e, l.conversationId, l.agentId), !w && t && (h.getState().upsertSessions([{
|
|
4148
3123
|
SessionId: e,
|
|
4149
3124
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4150
|
-
}]),
|
|
3125
|
+
}]), y.current = e, h.getState().setCurrentSessionId(e)), t && $e(l.agentId, e);
|
|
4151
3126
|
},
|
|
4152
3127
|
onSessionUpsert: () => {},
|
|
4153
|
-
onDispatchResult:
|
|
3128
|
+
onDispatchResult: m,
|
|
4154
3129
|
onSettled: (e, t = "unknown") => {
|
|
4155
|
-
|
|
3130
|
+
f && a.current.delete(f.requestId), f && d && d.update(f.requestId, { status: t === "completed" || t === "awaiting-input" ? "completed" : t === "cancelled" ? "cancelled" : t === "failed" ? "failed" : "unknown" }), C?.(e, l.agentId, t), t === "completed" && M(l);
|
|
4156
3131
|
}
|
|
4157
3132
|
});
|
|
4158
|
-
return e ||
|
|
4159
|
-
},
|
|
4160
|
-
return !
|
|
4161
|
-
draft:
|
|
4162
|
-
launch:
|
|
4163
|
-
}), j(
|
|
3133
|
+
return e || r.getState().setSessionStreaming(l.sessionId || l.conversationId, !1), e;
|
|
3134
|
+
}, v = _();
|
|
3135
|
+
return !v && n === void 0 ? (l.queue.push({
|
|
3136
|
+
draft: u,
|
|
3137
|
+
launch: _
|
|
3138
|
+
}), j(l), !0) : g ? (v || m?.(!1), g) : v;
|
|
4164
3139
|
}, [
|
|
4165
|
-
|
|
4166
|
-
|
|
3140
|
+
N,
|
|
3141
|
+
ee,
|
|
4167
3142
|
O,
|
|
4168
|
-
|
|
3143
|
+
y,
|
|
4169
3144
|
M,
|
|
4170
3145
|
k,
|
|
4171
3146
|
C,
|
|
@@ -4173,41 +3148,41 @@ function qn(t) {
|
|
|
4173
3148
|
D,
|
|
4174
3149
|
j,
|
|
4175
3150
|
T
|
|
4176
|
-
]),
|
|
4177
|
-
A(
|
|
4178
|
-
}, [
|
|
4179
|
-
A(
|
|
4180
|
-
}, [
|
|
3151
|
+
]), F = K(() => {
|
|
3152
|
+
A(y.current).stop();
|
|
3153
|
+
}, [y, A]), I = K(() => {
|
|
3154
|
+
A(y.current).disconnect();
|
|
3155
|
+
}, [y, A]), L = K((e) => {
|
|
4181
3156
|
let t = k(e.sessionId), n = A(e.sessionId);
|
|
4182
3157
|
if (n.stage !== "idle") return !1;
|
|
4183
|
-
|
|
4184
|
-
let
|
|
3158
|
+
tn(), b.getState().setMobileActionsOpen(!1), r.getState().setSessionStreaming(e.sessionId, !0);
|
|
3159
|
+
let i = n.resumeCheckpoint({
|
|
4185
3160
|
...e,
|
|
4186
3161
|
onSettled: (e, n) => {
|
|
4187
3162
|
C?.(e, t.agentId, n), n === "completed" && M(t);
|
|
4188
3163
|
}
|
|
4189
3164
|
});
|
|
4190
|
-
return
|
|
3165
|
+
return i || r.getState().setSessionStreaming(e.sessionId, !1), i;
|
|
4191
3166
|
}, [
|
|
4192
3167
|
M,
|
|
4193
3168
|
A,
|
|
4194
3169
|
k,
|
|
4195
3170
|
C
|
|
4196
|
-
]),
|
|
4197
|
-
|
|
3171
|
+
]), R = K(() => {
|
|
3172
|
+
tn();
|
|
4198
3173
|
}, []);
|
|
4199
3174
|
return {
|
|
4200
|
-
submitDraft:
|
|
4201
|
-
isOutboxRequestActive:
|
|
4202
|
-
stopGeneration:
|
|
4203
|
-
disconnectRun:
|
|
4204
|
-
resumeCheckpoint:
|
|
4205
|
-
submitAguiAction:
|
|
3175
|
+
submitDraft: P,
|
|
3176
|
+
isOutboxRequestActive: o,
|
|
3177
|
+
stopGeneration: F,
|
|
3178
|
+
disconnectRun: I,
|
|
3179
|
+
resumeCheckpoint: L,
|
|
3180
|
+
submitAguiAction: K((e) => {
|
|
4206
3181
|
let t = e.userAction;
|
|
4207
3182
|
if (!t) return !1;
|
|
4208
3183
|
let n = t.context || {}, r = String(n.interruptId || n.interrupt_id || "");
|
|
4209
3184
|
if (!r) return !1;
|
|
4210
|
-
let i =
|
|
3185
|
+
let i = y.current;
|
|
4211
3186
|
if (!i) return !1;
|
|
4212
3187
|
let a = k(i), o = A(i), s = n.status === "cancelled" ? "cancelled" : "resolved", c = Object.prototype.hasOwnProperty.call(n, "payload") ? n.payload : {
|
|
4213
3188
|
action: t.name,
|
|
@@ -4224,20 +3199,20 @@ function qn(t) {
|
|
|
4224
3199
|
}
|
|
4225
3200
|
});
|
|
4226
3201
|
}, [
|
|
4227
|
-
|
|
3202
|
+
y,
|
|
4228
3203
|
M,
|
|
4229
3204
|
A,
|
|
4230
3205
|
k,
|
|
4231
3206
|
C
|
|
4232
3207
|
]),
|
|
4233
|
-
respondToAguiApproval:
|
|
3208
|
+
respondToAguiApproval: K((e) => {
|
|
4234
3209
|
if (!e.interruptId) return !1;
|
|
4235
|
-
let t =
|
|
3210
|
+
let t = y.current;
|
|
4236
3211
|
if (!t) return !1;
|
|
4237
|
-
let n = k(t),
|
|
4238
|
-
if (
|
|
4239
|
-
|
|
4240
|
-
let
|
|
3212
|
+
let n = k(t), i = A(t);
|
|
3213
|
+
if (i.stage !== "idle") return !1;
|
|
3214
|
+
r.getState().setSessionStreaming(t, !0);
|
|
3215
|
+
let a = i.resumeAguiInterrupt({
|
|
4241
3216
|
sessionId: t,
|
|
4242
3217
|
interruptId: e.interruptId,
|
|
4243
3218
|
status: e.status || "resolved",
|
|
@@ -4246,31 +3221,31 @@ function qn(t) {
|
|
|
4246
3221
|
C?.(e, n.agentId), M(n);
|
|
4247
3222
|
}
|
|
4248
3223
|
});
|
|
4249
|
-
return
|
|
3224
|
+
return a || r.getState().setSessionStreaming(t, !1), a;
|
|
4250
3225
|
}, [
|
|
4251
|
-
|
|
3226
|
+
y,
|
|
4252
3227
|
M,
|
|
4253
3228
|
A,
|
|
4254
3229
|
k,
|
|
4255
3230
|
C
|
|
4256
3231
|
]),
|
|
4257
|
-
resetCompaction:
|
|
3232
|
+
resetCompaction: R
|
|
4258
3233
|
};
|
|
4259
3234
|
}
|
|
4260
3235
|
//#endregion
|
|
4261
3236
|
//#region src/utils/history-preparation.ts
|
|
4262
|
-
function
|
|
4263
|
-
return e instanceof
|
|
3237
|
+
function on(e) {
|
|
3238
|
+
return e instanceof Y && e.code === 503 && e.detail?.ReasonCode === "HISTORY_PREPARING";
|
|
4264
3239
|
}
|
|
4265
|
-
async function
|
|
3240
|
+
async function sn(e, t) {
|
|
4266
3241
|
let n = Date.now();
|
|
4267
3242
|
for (let r = 0;; r += 1) {
|
|
4268
|
-
if (!t.isCurrent() || t.signal?.aborted) throw new
|
|
3243
|
+
if (!t.isCurrent() || t.signal?.aborted) throw new X();
|
|
4269
3244
|
try {
|
|
4270
3245
|
return await e();
|
|
4271
3246
|
} catch (e) {
|
|
4272
|
-
if (!
|
|
4273
|
-
if (!t.isCurrent() || t.signal?.aborted) throw new
|
|
3247
|
+
if (!on(e) || r >= 60 || Date.now() - n >= 3e5) throw e;
|
|
3248
|
+
if (!t.isCurrent() || t.signal?.aborted) throw new X();
|
|
4274
3249
|
t.onPreparing?.(), await new Promise((e) => {
|
|
4275
3250
|
let i = () => {
|
|
4276
3251
|
clearTimeout(a), t.signal?.removeEventListener("abort", i), e();
|
|
@@ -4282,7 +3257,7 @@ async function Yn(e, t) {
|
|
|
4282
3257
|
}
|
|
4283
3258
|
//#endregion
|
|
4284
3259
|
//#region src/utils/kernel-run-history.ts
|
|
4285
|
-
async function
|
|
3260
|
+
async function cn(e, t, n, r, i, a) {
|
|
4286
3261
|
let o = r.Events;
|
|
4287
3262
|
if (o.some((e) => e.EventType === "run.started" && e.InvocationId === n)) return o;
|
|
4288
3263
|
let s = {
|
|
@@ -4324,13 +3299,15 @@ async function Xn(e, t, n, r, i, a) {
|
|
|
4324
3299
|
c(r);
|
|
4325
3300
|
let i = r.Events;
|
|
4326
3301
|
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");
|
|
4327
|
-
o =
|
|
3302
|
+
o = L(o, i);
|
|
4328
3303
|
}
|
|
4329
3304
|
return o;
|
|
4330
3305
|
}
|
|
4331
3306
|
//#endregion
|
|
4332
3307
|
//#region src/utils/interaction-history.ts
|
|
4333
|
-
var
|
|
3308
|
+
var ln = [
|
|
3309
|
+
"mcp.authorization.requested",
|
|
3310
|
+
"mcp.authorization.updated",
|
|
4334
3311
|
"interaction.requested",
|
|
4335
3312
|
"interaction_requested",
|
|
4336
3313
|
"ksadk.interaction/v1.requested",
|
|
@@ -4346,8 +3323,8 @@ var Zn = [
|
|
|
4346
3323
|
"interaction.expired",
|
|
4347
3324
|
"approval.resolved",
|
|
4348
3325
|
"a2ui.action"
|
|
4349
|
-
],
|
|
4350
|
-
async function
|
|
3326
|
+
], un = 32, dn = 2;
|
|
3327
|
+
async function fn(e, t, n, r, i, a) {
|
|
4351
3328
|
let o = /* @__PURE__ */ new Set(), s = Infinity, c = (e) => {
|
|
4352
3329
|
for (let t of e) {
|
|
4353
3330
|
t.agentBlock && c(t.agentBlock.messages);
|
|
@@ -4369,20 +3346,20 @@ async function er(e, t, n, r, i, a) {
|
|
|
4369
3346
|
incomplete: !1
|
|
4370
3347
|
};
|
|
4371
3348
|
let l = /* @__PURE__ */ new Set(), u = (e) => {
|
|
4372
|
-
let n =
|
|
3349
|
+
let n = f(e, t);
|
|
4373
3350
|
return !n || !o.has(n.interactionId) ? !1 : (n.status === "pending" && l.add(n.interactionId), !0);
|
|
4374
3351
|
};
|
|
4375
3352
|
if (r.Events.forEach(u), [...o].every((e) => l.has(e))) return {
|
|
4376
3353
|
events: [],
|
|
4377
3354
|
incomplete: !1
|
|
4378
3355
|
};
|
|
4379
|
-
let d = [],
|
|
4380
|
-
for (let n = 0; n <
|
|
3356
|
+
let d = [], p = Number(r.SnapshotSeqId) + 1;
|
|
3357
|
+
for (let n = 0; n < dn && i() && !a?.aborted; n += 1) {
|
|
4381
3358
|
let n = await e.listSessionEvents(t, {
|
|
4382
|
-
eventTypes:
|
|
4383
|
-
limit:
|
|
3359
|
+
eventTypes: ln,
|
|
3360
|
+
limit: un,
|
|
4384
3361
|
afterSeqId: s,
|
|
4385
|
-
beforeSeqId:
|
|
3362
|
+
beforeSeqId: p,
|
|
4386
3363
|
cursorSource: r.CursorSource,
|
|
4387
3364
|
historyEpoch: r.HistoryEpoch,
|
|
4388
3365
|
snapshotSeqId: r.SnapshotSeqId,
|
|
@@ -4399,9 +3376,9 @@ async function er(e, t, n, r, i, a) {
|
|
|
4399
3376
|
events: d,
|
|
4400
3377
|
incomplete: [...o].some((e) => !l.has(e))
|
|
4401
3378
|
};
|
|
4402
|
-
let
|
|
4403
|
-
if (!Number.isSafeInteger(
|
|
4404
|
-
|
|
3379
|
+
let f = Math.min(...c.map((e) => Number(e.SeqId)));
|
|
3380
|
+
if (!Number.isSafeInteger(f) || f <= s || f >= p) throw Error("Interaction history cursor did not advance");
|
|
3381
|
+
p = f;
|
|
4405
3382
|
}
|
|
4406
3383
|
return {
|
|
4407
3384
|
events: d,
|
|
@@ -4410,7 +3387,7 @@ async function er(e, t, n, r, i, a) {
|
|
|
4410
3387
|
}
|
|
4411
3388
|
//#endregion
|
|
4412
3389
|
//#region src/utils/messages.js
|
|
4413
|
-
var
|
|
3390
|
+
var pn = {
|
|
4414
3391
|
running: "running",
|
|
4415
3392
|
completed: "completed",
|
|
4416
3393
|
failed: "error",
|
|
@@ -4421,7 +3398,7 @@ var tr = {
|
|
|
4421
3398
|
rejected: "completed",
|
|
4422
3399
|
cancelled: "completed",
|
|
4423
3400
|
expired: "completed"
|
|
4424
|
-
},
|
|
3401
|
+
}, mn = {
|
|
4425
3402
|
pending: "pending",
|
|
4426
3403
|
paused: "pending",
|
|
4427
3404
|
approved: "approved",
|
|
@@ -4430,7 +3407,7 @@ var tr = {
|
|
|
4430
3407
|
cancelled: "cancelled",
|
|
4431
3408
|
expired: "cancelled"
|
|
4432
3409
|
};
|
|
4433
|
-
function
|
|
3410
|
+
function hn(e) {
|
|
4434
3411
|
if (typeof e == "number" && Number.isFinite(e)) return e > 0 && e < 1e11 ? e * 1e3 : e;
|
|
4435
3412
|
if (typeof e == "string") {
|
|
4436
3413
|
let t = Number(e.trim());
|
|
@@ -4440,7 +3417,7 @@ function rr(e) {
|
|
|
4440
3417
|
}
|
|
4441
3418
|
return Date.now();
|
|
4442
3419
|
}
|
|
4443
|
-
function
|
|
3420
|
+
function gn(e) {
|
|
4444
3421
|
if (typeof e == "string") return e;
|
|
4445
3422
|
if (e && typeof e == "object") {
|
|
4446
3423
|
if (typeof e.text == "string") return e.text;
|
|
@@ -4448,23 +3425,23 @@ function ir(e) {
|
|
|
4448
3425
|
}
|
|
4449
3426
|
return "";
|
|
4450
3427
|
}
|
|
4451
|
-
function
|
|
3428
|
+
function _n(e) {
|
|
4452
3429
|
let t = {}, n = /* @__PURE__ */ new Map();
|
|
4453
3430
|
for (let t of e ?? []) t?.Name && n.set(t.Name, (n.get(t.Name) || 0) + 1);
|
|
4454
3431
|
for (let r of e ?? []) {
|
|
4455
3432
|
if (!r?.Name) continue;
|
|
4456
|
-
let e =
|
|
3433
|
+
let e = pn[String(r.Status ?? "completed").toLowerCase()] ?? "completed", i = {
|
|
4457
3434
|
name: r.Name,
|
|
4458
3435
|
args: r.Args === void 0 ? "" : typeof r.Args == "string" ? r.Args : JSON.stringify(r.Args),
|
|
4459
3436
|
status: e
|
|
4460
3437
|
};
|
|
4461
|
-
r.Result !== void 0 && (i.output = typeof r.Result == "string" ? r.Result : JSON.stringify(r.Result)), r.ApprovalRequestId && (i.approvalRequestId = r.ApprovalRequestId, i.approvalStatus =
|
|
3438
|
+
r.Result !== void 0 && (i.output = typeof r.Result == "string" ? r.Result : JSON.stringify(r.Result)), r.ApprovalRequestId && (i.approvalRequestId = r.ApprovalRequestId, i.approvalStatus = mn[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);
|
|
4462
3439
|
let a = n.get(r.Name) > 1 && (r.ToolCallId || r.ApprovalRequestId) || r.Name;
|
|
4463
3440
|
t[a] = i;
|
|
4464
3441
|
}
|
|
4465
3442
|
return t;
|
|
4466
3443
|
}
|
|
4467
|
-
function
|
|
3444
|
+
function vn(e) {
|
|
4468
3445
|
if (Array.isArray(e)) return e.map((e) => ({
|
|
4469
3446
|
name: e.name || "",
|
|
4470
3447
|
url: e.url || "",
|
|
@@ -4472,10 +3449,10 @@ function or(e) {
|
|
|
4472
3449
|
fileUri: e.file_uri
|
|
4473
3450
|
}));
|
|
4474
3451
|
}
|
|
4475
|
-
function
|
|
3452
|
+
function yn(e) {
|
|
4476
3453
|
return e == null ? "" : typeof e == "string" ? e : JSON.stringify(e);
|
|
4477
3454
|
}
|
|
4478
|
-
function
|
|
3455
|
+
function bn(e) {
|
|
4479
3456
|
if (!(!Array.isArray(e) || !e.length)) return e.flatMap((e, t) => {
|
|
4480
3457
|
let n = String(e?.Type || "").toLowerCase(), r = e?.SeqId ?? t;
|
|
4481
3458
|
if (n === "thinking" || n === "text") {
|
|
@@ -4488,13 +3465,13 @@ function cr(e) {
|
|
|
4488
3465
|
}] : [];
|
|
4489
3466
|
}
|
|
4490
3467
|
if (n !== "tool") return [];
|
|
4491
|
-
let i =
|
|
3468
|
+
let i = pn[String(e?.Status || "completed").toLowerCase()] ?? "completed";
|
|
4492
3469
|
return [{
|
|
4493
3470
|
id: `history-tool-${r}`,
|
|
4494
3471
|
type: "tool",
|
|
4495
3472
|
toolName: String(e?.Name || "tool"),
|
|
4496
|
-
args:
|
|
4497
|
-
...e?.Result === void 0 ? {} : { output:
|
|
3473
|
+
args: yn(e?.Args),
|
|
3474
|
+
...e?.Result === void 0 ? {} : { output: yn(e.Result) },
|
|
4498
3475
|
status: i,
|
|
4499
3476
|
...e?.ToolCallId ? { extra: {
|
|
4500
3477
|
callId: String(e.ToolCallId),
|
|
@@ -4503,12 +3480,12 @@ function cr(e) {
|
|
|
4503
3480
|
}];
|
|
4504
3481
|
});
|
|
4505
3482
|
}
|
|
4506
|
-
function
|
|
4507
|
-
let t = e.Role === "assistant" ? "model" : e.Role || "user", n = e.ToolEvents?.length ?
|
|
3483
|
+
function xn(e) {
|
|
3484
|
+
let t = e.Role === "assistant" ? "model" : e.Role || "user", n = e.ToolEvents?.length ? _n(e.ToolEvents) : void 0, r = vn(e.Attachments), i = bn(e.Blocks), a = e.Reasoning?.length ? e.Reasoning.map((e) => e.text).join("") : void 0, o = {
|
|
4508
3485
|
id: e.MessageId || `msg-${e.SeqId ?? Math.random().toString(36).slice(2)}`,
|
|
4509
3486
|
role: t,
|
|
4510
|
-
content:
|
|
4511
|
-
timestamp:
|
|
3487
|
+
content: gn(e.Content),
|
|
3488
|
+
timestamp: hn(e.Timestamp),
|
|
4512
3489
|
...Number.isSafeInteger(e.SeqId) && e.SeqId > 0 ? { historyOrder: {
|
|
4513
3490
|
seq: e.SeqId,
|
|
4514
3491
|
...Number.isSafeInteger(e.StartSeqId) && e.StartSeqId > 0 ? { group: e.StartSeqId } : {}
|
|
@@ -4518,13 +3495,13 @@ function lr(e) {
|
|
|
4518
3495
|
tools: n,
|
|
4519
3496
|
attachments: r
|
|
4520
3497
|
};
|
|
4521
|
-
return t === "model" && (o.blocks = i ??
|
|
3498
|
+
return t === "model" && (o.blocks = i ?? Ae({
|
|
4522
3499
|
reasoning: a,
|
|
4523
3500
|
tools: n,
|
|
4524
3501
|
content: o.content
|
|
4525
3502
|
})), 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;
|
|
4526
3503
|
}
|
|
4527
|
-
function
|
|
3504
|
+
function Sn(e) {
|
|
4528
3505
|
return Array.isArray(e.Activities) ? e.Activities.flatMap((t, n) => {
|
|
4529
3506
|
let r = String(t?.SurfaceId || "");
|
|
4530
3507
|
if (!r) return [];
|
|
@@ -4538,7 +3515,7 @@ function ur(e) {
|
|
|
4538
3515
|
id: o && o !== String(e.MessageId || "") ? o : `${o || e.MessageId || e.SeqId || "message"}:a2ui:${r}:${n}`,
|
|
4539
3516
|
role: "a2ui",
|
|
4540
3517
|
content: "",
|
|
4541
|
-
timestamp:
|
|
3518
|
+
timestamp: hn(e.Timestamp),
|
|
4542
3519
|
...e.InvocationId ? { invocationId: String(e.InvocationId) } : {},
|
|
4543
3520
|
...Number.isSafeInteger(e.SeqId) && e.SeqId > 0 ? { historyOrder: {
|
|
4544
3521
|
seq: e.SeqId,
|
|
@@ -4547,35 +3524,35 @@ function ur(e) {
|
|
|
4547
3524
|
} } : {},
|
|
4548
3525
|
aguiActivity: {
|
|
4549
3526
|
surfaceId: r,
|
|
4550
|
-
messages:
|
|
3527
|
+
messages: D(a),
|
|
4551
3528
|
...typeof i?.interactionId == "string" ? { interactionId: i.interactionId } : {}
|
|
4552
3529
|
}
|
|
4553
3530
|
}];
|
|
4554
3531
|
}) : [];
|
|
4555
3532
|
}
|
|
4556
|
-
function
|
|
4557
|
-
return
|
|
3533
|
+
function Cn(e) {
|
|
3534
|
+
return Ne(xe(e.map(xn)).flatMap((t, n) => [t, ...Sn(e[n])]));
|
|
4558
3535
|
}
|
|
4559
3536
|
//#endregion
|
|
4560
3537
|
//#region src/utils/session-event-history.ts
|
|
4561
|
-
var
|
|
3538
|
+
var wn = class extends Error {
|
|
4562
3539
|
seq;
|
|
4563
3540
|
constructor(e) {
|
|
4564
3541
|
super(`Session event seq ${e} was received twice with conflicting content`), this.name = "SessionEventConflictError", this.seq = e;
|
|
4565
3542
|
}
|
|
4566
3543
|
};
|
|
4567
|
-
function
|
|
4568
|
-
return Array.isArray(e) ? `[${e.map(
|
|
3544
|
+
function Tn(e) {
|
|
3545
|
+
return Array.isArray(e) ? `[${e.map(Tn).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)}:${Tn(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
|
|
4569
3546
|
}
|
|
4570
|
-
var
|
|
3547
|
+
var En = new Set(["runtime"]), Dn = class {
|
|
4571
3548
|
eventsBySeq = /* @__PURE__ */ new Map();
|
|
4572
3549
|
lastSeqValue = 0;
|
|
4573
3550
|
accept(e) {
|
|
4574
|
-
let t =
|
|
3551
|
+
let t = l(e);
|
|
4575
3552
|
if (!t.ok) throw t.error;
|
|
4576
3553
|
let n = t.value, r = this.eventsBySeq.get(n.seq);
|
|
4577
3554
|
if (r) {
|
|
4578
|
-
if (
|
|
3555
|
+
if (Tn(r) !== Tn(n)) throw new wn(n.seq);
|
|
4579
3556
|
return;
|
|
4580
3557
|
}
|
|
4581
3558
|
this.eventsBySeq.set(n.seq, n), this.lastSeqValue = Math.max(this.lastSeqValue, n.seq);
|
|
@@ -4587,41 +3564,41 @@ var mr = new Set(["runtime"]), hr = class {
|
|
|
4587
3564
|
return this.lastSeqValue;
|
|
4588
3565
|
}
|
|
4589
3566
|
displayableEvents() {
|
|
4590
|
-
return [...this.eventsBySeq.values()].filter((e) =>
|
|
3567
|
+
return [...this.eventsBySeq.values()].filter((e) => En.has(e.family)).sort((e, t) => e.seq - t.seq);
|
|
4591
3568
|
}
|
|
4592
3569
|
};
|
|
4593
|
-
function
|
|
4594
|
-
return new
|
|
3570
|
+
function On() {
|
|
3571
|
+
return new Dn();
|
|
4595
3572
|
}
|
|
4596
3573
|
//#endregion
|
|
4597
3574
|
//#region src/hooks/useSessionLifecycle.ts
|
|
4598
|
-
var
|
|
4599
|
-
function
|
|
3575
|
+
var kn = 500, An = 30, jn = 50, Mn = 64, Nn = 8, Pn = 128, Fn = 1800 * 1e3;
|
|
3576
|
+
function In(e, t) {
|
|
4600
3577
|
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));
|
|
4601
3578
|
}
|
|
4602
|
-
function
|
|
3579
|
+
function Ln(e) {
|
|
4603
3580
|
return {
|
|
4604
3581
|
CursorSource: e.cursorSource,
|
|
4605
3582
|
HistoryEpoch: e.historyEpoch,
|
|
4606
3583
|
SnapshotSeqId: e.snapshotSeqId
|
|
4607
3584
|
};
|
|
4608
3585
|
}
|
|
4609
|
-
function
|
|
4610
|
-
if (!(e instanceof
|
|
3586
|
+
function Rn(e) {
|
|
3587
|
+
if (!(e instanceof Y) || !e.detail || typeof e.detail != "object") return;
|
|
4611
3588
|
let t = e.detail;
|
|
4612
3589
|
return typeof t.ReasonCode == "string" ? t.ReasonCode : void 0;
|
|
4613
3590
|
}
|
|
4614
|
-
function
|
|
4615
|
-
return e instanceof
|
|
3591
|
+
function zn(e) {
|
|
3592
|
+
return e instanceof Y && e.code === 409 && Rn(e) === "HISTORY_RELOAD_REQUIRED";
|
|
4616
3593
|
}
|
|
4617
|
-
function
|
|
4618
|
-
return new
|
|
3594
|
+
function Bn() {
|
|
3595
|
+
return new Y(409, "历史来源已变化", {
|
|
4619
3596
|
Code: 409,
|
|
4620
3597
|
ReasonCode: "HISTORY_RELOAD_REQUIRED",
|
|
4621
3598
|
Data: null
|
|
4622
3599
|
});
|
|
4623
3600
|
}
|
|
4624
|
-
function
|
|
3601
|
+
function Vn(e) {
|
|
4625
3602
|
return {
|
|
4626
3603
|
dataSource: e.DataSource,
|
|
4627
3604
|
degraded: e.Degraded,
|
|
@@ -4635,37 +3612,37 @@ function kr(e) {
|
|
|
4635
3612
|
preparing: !1
|
|
4636
3613
|
};
|
|
4637
3614
|
}
|
|
4638
|
-
function $(e, t, n, r, i =
|
|
3615
|
+
function $(e, t, n, r, i = Pn) {
|
|
4639
3616
|
for (e.delete(t), e.set(t, n); e.size > i;) {
|
|
4640
3617
|
let t = [...e.keys()].find((e) => e !== r);
|
|
4641
3618
|
if (!t) break;
|
|
4642
3619
|
e.delete(t);
|
|
4643
3620
|
}
|
|
4644
3621
|
}
|
|
4645
|
-
function
|
|
3622
|
+
function Hn(e) {
|
|
4646
3623
|
return new Promise((t) => {
|
|
4647
3624
|
if (e.aborted) {
|
|
4648
3625
|
t();
|
|
4649
3626
|
return;
|
|
4650
3627
|
}
|
|
4651
|
-
let n = globalThis.setTimeout(t,
|
|
3628
|
+
let n = globalThis.setTimeout(t, kn);
|
|
4652
3629
|
e.addEventListener("abort", () => {
|
|
4653
3630
|
globalThis.clearTimeout(n), t();
|
|
4654
3631
|
}, { once: !0 });
|
|
4655
3632
|
});
|
|
4656
3633
|
}
|
|
4657
|
-
var
|
|
3634
|
+
var Un = new Set([
|
|
4658
3635
|
"in_progress",
|
|
4659
3636
|
"running",
|
|
4660
3637
|
"resuming",
|
|
4661
3638
|
"starting"
|
|
4662
3639
|
]);
|
|
4663
|
-
function
|
|
3640
|
+
function Wn(e) {
|
|
4664
3641
|
let t = e.ActiveRunUpdatedAt || e.UpdatedAt, n = typeof t == "number" ? t > 1e11 ? t : t * 1e3 : Date.parse(String(t || ""));
|
|
4665
|
-
return Number.isFinite(n) && n <= Date.now() +
|
|
3642
|
+
return Number.isFinite(n) && n <= Date.now() + Fn && Date.now() - n <= Fn;
|
|
4666
3643
|
}
|
|
4667
|
-
function
|
|
4668
|
-
let t =
|
|
3644
|
+
function Gn(e) {
|
|
3645
|
+
let t = z(e);
|
|
4669
3646
|
return t ? t === "completed" ? {
|
|
4670
3647
|
status: "completed",
|
|
4671
3648
|
phase: "后台长任务已完成"
|
|
@@ -4683,11 +3660,11 @@ function Nr(e) {
|
|
|
4683
3660
|
phase: "后台长任务恢复失败"
|
|
4684
3661
|
} : null : null;
|
|
4685
3662
|
}
|
|
4686
|
-
function
|
|
4687
|
-
let { agentId: t, api: n, isMobile:
|
|
4688
|
-
|
|
4689
|
-
let
|
|
4690
|
-
let i = r.filter((e) =>
|
|
3663
|
+
function Kn(e) {
|
|
3664
|
+
let { agentId: t, api: n, isMobile: a, resetCompaction: o, uiCapabilities: s, disconnectRun: c, restoreSession: l = !0 } = e, u = J(e.currentSessionId), d = J(e.agentId), f = J(s);
|
|
3665
|
+
f.current = s;
|
|
3666
|
+
let p = J(null), g = J(On()), _ = J(0), v = J(null), y = J(null), S = J(/* @__PURE__ */ new Map()), w = J(/* @__PURE__ */ new Map()), T = J(/* @__PURE__ */ new Map()), E = J(/* @__PURE__ */ new Map()), D = J(/* @__PURE__ */ new Map()), O = J(/* @__PURE__ */ new Map()), k = J(/* @__PURE__ */ new Map()), A = J(/* @__PURE__ */ new Map()), j = J(null), M = J(null), N = J(null), F = J(null), I = K(async (e, t, r) => {
|
|
3667
|
+
let i = r.filter((e) => te(e, !1, !1));
|
|
4691
3668
|
if (!i.length) return;
|
|
4692
3669
|
let a = await Promise.all(i.map(async (r) => {
|
|
4693
3670
|
try {
|
|
@@ -4696,7 +3673,7 @@ function Pr(e) {
|
|
|
4696
3673
|
SessionId: t,
|
|
4697
3674
|
ResponseId: r.responseId,
|
|
4698
3675
|
EventId: r.eventId
|
|
4699
|
-
}), a = i?.Feedback ?
|
|
3676
|
+
}), a = i?.Feedback ? ae(i.Feedback) : null;
|
|
4700
3677
|
return a ? {
|
|
4701
3678
|
messageId: r.id,
|
|
4702
3679
|
feedback: a
|
|
@@ -4705,19 +3682,19 @@ function Pr(e) {
|
|
|
4705
3682
|
return console.error("Failed to load response feedback:", e), null;
|
|
4706
3683
|
}
|
|
4707
3684
|
}));
|
|
4708
|
-
if (
|
|
3685
|
+
if (u.current !== t) return;
|
|
4709
3686
|
let o = new Map(a.filter((e) => !!e).map((e) => [e.messageId, e.feedback]));
|
|
4710
|
-
o.size &&
|
|
3687
|
+
o.size && U.getState().patchMessages((e) => e.map((e) => o.has(e.id) ? {
|
|
4711
3688
|
...e,
|
|
4712
3689
|
feedback: o.get(e.id)
|
|
4713
3690
|
} : e));
|
|
4714
|
-
}, [n]),
|
|
4715
|
-
|
|
3691
|
+
}, [n]), R = K(async (e) => {
|
|
3692
|
+
p.current?.abort();
|
|
4716
3693
|
let t = new AbortController();
|
|
4717
|
-
|
|
4718
|
-
let
|
|
3694
|
+
p.current = t;
|
|
3695
|
+
let a = !1, o = !1, s = !1, c = i.getState(), l = c.agentId === d.current ? c.capabilities : f.current, m = l.KernelSessionEventsByCommand === !0, h = le(l.ConversationSurface, he), _ = new Me(e.sessionId, void 0, h), v = m ? 0 : e.afterSeqId, y = () => p.current === t && u.current === e.sessionId;
|
|
4719
3696
|
try {
|
|
4720
|
-
for (
|
|
3697
|
+
for (r.getState().setCurrentRunId(e.invocationId), r.getState().setActiveInvocationId(e.invocationId), r.getState().setSessionStreaming(e.sessionId, !0), r.getState().updateActivity({
|
|
4721
3698
|
sessionId: e.sessionId,
|
|
4722
3699
|
runId: e.invocationId,
|
|
4723
3700
|
source: "restore",
|
|
@@ -4725,9 +3702,9 @@ function Pr(e) {
|
|
|
4725
3702
|
phase: "正在同步任务进展",
|
|
4726
3703
|
detail: e.invocationId,
|
|
4727
3704
|
countEvent: !1
|
|
4728
|
-
}); !
|
|
3705
|
+
}); !o && y();) {
|
|
4729
3706
|
try {
|
|
4730
|
-
let
|
|
3707
|
+
let i = await n.subscribeRunEvents({
|
|
4731
3708
|
sessionId: e.sessionId,
|
|
4732
3709
|
invocationId: e.invocationId,
|
|
4733
3710
|
afterSeqId: v
|
|
@@ -4736,17 +3713,17 @@ function Pr(e) {
|
|
|
4736
3713
|
t.abort();
|
|
4737
3714
|
return;
|
|
4738
3715
|
}
|
|
4739
|
-
let s =
|
|
4740
|
-
for (; !
|
|
3716
|
+
let s = i.getReader(), c = new TextDecoder(), l = "";
|
|
3717
|
+
for (; !o && y();) {
|
|
4741
3718
|
let { value: t, done: n } = await s.read();
|
|
4742
3719
|
if (n) break;
|
|
4743
3720
|
l += c.decode(t, { stream: !0 });
|
|
4744
|
-
let
|
|
4745
|
-
l =
|
|
4746
|
-
for (let t of
|
|
4747
|
-
for (let n of
|
|
3721
|
+
let i = Et(l);
|
|
3722
|
+
l = i.remainder;
|
|
3723
|
+
for (let t of i.chunks) if (t.trim()) {
|
|
3724
|
+
for (let n of Tt(t)) {
|
|
4748
3725
|
if (n.eventName === "__ping__") {
|
|
4749
|
-
|
|
3726
|
+
r.getState().updateActivity({
|
|
4750
3727
|
sessionId: e.sessionId,
|
|
4751
3728
|
status: "running",
|
|
4752
3729
|
phase: "正在处理",
|
|
@@ -4755,31 +3732,31 @@ function Pr(e) {
|
|
|
4755
3732
|
continue;
|
|
4756
3733
|
}
|
|
4757
3734
|
if (n.eventName === "__done__") {
|
|
4758
|
-
|
|
3735
|
+
o = !0, a = !0;
|
|
4759
3736
|
break;
|
|
4760
3737
|
}
|
|
4761
3738
|
if (!n.data || typeof n.data != "object") continue;
|
|
4762
3739
|
let t = n.data;
|
|
4763
3740
|
if (!y()) break;
|
|
4764
3741
|
if (t.InvocationId && t.InvocationId !== e.invocationId) continue;
|
|
4765
|
-
if (
|
|
3742
|
+
if (r.getState().updateActivity({
|
|
4766
3743
|
sessionId: e.sessionId,
|
|
4767
3744
|
status: "running",
|
|
4768
3745
|
phase: "正在处理",
|
|
4769
3746
|
countEvent: !1
|
|
4770
3747
|
}), typeof t.seq == "number") {
|
|
4771
3748
|
try {
|
|
4772
|
-
|
|
3749
|
+
g.current.accept(t);
|
|
4773
3750
|
} catch (e) {
|
|
4774
3751
|
console.error("[SessionLifecycle] session event cursor conflict:", e);
|
|
4775
3752
|
}
|
|
4776
|
-
v = Math.max(v,
|
|
3753
|
+
v = Math.max(v, g.current.reconnectAfterSeq()), Q({
|
|
4777
3754
|
type: "stream_event",
|
|
4778
3755
|
sessionId: e.sessionId,
|
|
4779
3756
|
event: t
|
|
4780
|
-
}),
|
|
4781
|
-
let n =
|
|
4782
|
-
n &&
|
|
3757
|
+
}), o ||= P(t), a ||= o;
|
|
3758
|
+
let n = Gn(t);
|
|
3759
|
+
n && r.getState().updateActivity({
|
|
4783
3760
|
sessionId: e.sessionId,
|
|
4784
3761
|
status: n.status,
|
|
4785
3762
|
phase: n.phase,
|
|
@@ -4788,55 +3765,55 @@ function Pr(e) {
|
|
|
4788
3765
|
});
|
|
4789
3766
|
continue;
|
|
4790
3767
|
}
|
|
4791
|
-
let
|
|
4792
|
-
Number.isFinite(
|
|
3768
|
+
let i = Number(t.SeqId || 0);
|
|
3769
|
+
Number.isFinite(i) && (v = Math.max(v, i));
|
|
4793
3770
|
let s = t.Content?.runtime_event;
|
|
4794
|
-
if (
|
|
4795
|
-
let t =
|
|
4796
|
-
|
|
3771
|
+
if (m && s?.schema_version === 2 && s.run_id === e.invocationId && _.apply(s)) {
|
|
3772
|
+
let t = _.snapshot();
|
|
3773
|
+
Q({
|
|
4797
3774
|
type: "conversation_snapshot",
|
|
4798
3775
|
sessionId: e.sessionId,
|
|
4799
3776
|
result: {
|
|
4800
3777
|
state: t,
|
|
4801
|
-
presentation:
|
|
3778
|
+
presentation: _e(t, { profile: h }),
|
|
4802
3779
|
runId: e.invocationId,
|
|
4803
3780
|
cursor: v
|
|
4804
3781
|
}
|
|
4805
3782
|
});
|
|
4806
3783
|
}
|
|
4807
|
-
|
|
3784
|
+
Q({
|
|
4808
3785
|
type: "stream_event",
|
|
4809
3786
|
sessionId: e.sessionId,
|
|
4810
3787
|
event: t
|
|
4811
|
-
}),
|
|
4812
|
-
let c =
|
|
4813
|
-
if (c &&
|
|
3788
|
+
}), o ||= P(t), a ||= o;
|
|
3789
|
+
let c = Gn(t);
|
|
3790
|
+
if (c && r.getState().updateActivity({
|
|
4814
3791
|
sessionId: e.sessionId,
|
|
4815
3792
|
status: c.status,
|
|
4816
3793
|
phase: c.phase,
|
|
4817
3794
|
detail: e.invocationId,
|
|
4818
3795
|
countEvent: !1
|
|
4819
|
-
}),
|
|
3796
|
+
}), o) break;
|
|
4820
3797
|
}
|
|
4821
|
-
if (
|
|
3798
|
+
if (o) break;
|
|
4822
3799
|
}
|
|
4823
3800
|
}
|
|
4824
|
-
|
|
3801
|
+
o && s.cancel().catch(() => {});
|
|
4825
3802
|
} catch (n) {
|
|
4826
|
-
if (n instanceof DOMException && n.name === "AbortError" || n instanceof
|
|
4827
|
-
|
|
3803
|
+
if (n instanceof DOMException && n.name === "AbortError" || n instanceof X || t.signal.aborted) {
|
|
3804
|
+
o = !0, s = !0, y() && r.getState().stopSessionActivity(e.sessionId, "恢复事件订阅已取消。");
|
|
4828
3805
|
break;
|
|
4829
3806
|
}
|
|
4830
3807
|
if (!y()) break;
|
|
4831
|
-
if (n instanceof
|
|
4832
|
-
|
|
3808
|
+
if (n instanceof Y && n.code >= 400 && n.code < 500 && n.code !== 408 && n.code !== 429) {
|
|
3809
|
+
o = !0, a = !1, Q({
|
|
4833
3810
|
type: "error",
|
|
4834
3811
|
sessionId: e.sessionId,
|
|
4835
3812
|
error: n
|
|
4836
3813
|
});
|
|
4837
3814
|
break;
|
|
4838
3815
|
}
|
|
4839
|
-
console.warn("Run event subscription disconnected; retrying:", n),
|
|
3816
|
+
console.warn("Run event subscription disconnected; retrying:", n), r.getState().updateActivity({
|
|
4840
3817
|
sessionId: e.sessionId,
|
|
4841
3818
|
status: "waiting",
|
|
4842
3819
|
phase: "恢复连接中",
|
|
@@ -4844,178 +3821,188 @@ function Pr(e) {
|
|
|
4844
3821
|
countEvent: !1
|
|
4845
3822
|
});
|
|
4846
3823
|
}
|
|
4847
|
-
!
|
|
3824
|
+
!o && y() && await Hn(t.signal);
|
|
4848
3825
|
}
|
|
4849
|
-
|
|
3826
|
+
o && !s && y() && Q({
|
|
4850
3827
|
type: "stream_ended",
|
|
4851
3828
|
sessionId: e.sessionId
|
|
4852
3829
|
});
|
|
4853
3830
|
} catch (e) {
|
|
4854
3831
|
e instanceof DOMException && e.name === "AbortError" || console.error("Failed to subscribe run events:", e);
|
|
4855
3832
|
} finally {
|
|
4856
|
-
let n =
|
|
4857
|
-
n && (
|
|
3833
|
+
let n = p.current === t;
|
|
3834
|
+
n && (p.current = null), n && u.current === e.sessionId && (r.getState().setCurrentRunId(""), r.getState().setActiveInvocationId(""), a && N.current?.(e.sessionId), F.current?.(d.current, e.sessionId));
|
|
4858
3835
|
}
|
|
4859
|
-
}, [n]),
|
|
4860
|
-
if (!
|
|
4861
|
-
|
|
4862
|
-
|
|
3836
|
+
}, [n]), B = K((e) => {
|
|
3837
|
+
if (!f.current.RunLifecycle.Enabled || !e.runId || d.current !== t || u.current !== e.sessionId || p.current || (k.current.get(e.sessionId)?.events || []).some((t) => {
|
|
3838
|
+
let n = t.Content?.runtime_event;
|
|
3839
|
+
return t.InvocationId === e.runId && !n?.parent_scope_id && [
|
|
3840
|
+
"completed",
|
|
3841
|
+
"failed",
|
|
3842
|
+
"error",
|
|
3843
|
+
"cancelled",
|
|
3844
|
+
"canceled",
|
|
3845
|
+
"aborted"
|
|
3846
|
+
].includes(z(t));
|
|
3847
|
+
})) return;
|
|
3848
|
+
let n = r.getState().getSessionActivity(e.sessionId);
|
|
3849
|
+
r.getState().isSessionStreaming(e.sessionId) && n?.source === "run" && [
|
|
4863
3850
|
"connecting",
|
|
4864
3851
|
"running",
|
|
4865
3852
|
"waiting"
|
|
4866
|
-
].includes(n.status) ||
|
|
3853
|
+
].includes(n.status) && (e.extensions?.mcpAuthorization || f.current.KernelSessionEventsByCommand === !0 && n.runId === e.runId) || R({
|
|
4867
3854
|
sessionId: e.sessionId,
|
|
4868
3855
|
invocationId: e.runId,
|
|
4869
|
-
afterSeqId:
|
|
3856
|
+
afterSeqId: ee(k.current.get(e.sessionId)?.events || [])
|
|
4870
3857
|
});
|
|
4871
|
-
}, [t,
|
|
4872
|
-
if (
|
|
4873
|
-
|
|
4874
|
-
let
|
|
4875
|
-
|
|
4876
|
-
let
|
|
4877
|
-
|
|
4878
|
-
let
|
|
4879
|
-
$(
|
|
4880
|
-
},
|
|
4881
|
-
|
|
4882
|
-
let
|
|
4883
|
-
|
|
4884
|
-
let
|
|
4885
|
-
|
|
3858
|
+
}, [t, R]), V = K(async (e, t = !1, c) => {
|
|
3859
|
+
if (c?.aborted) return;
|
|
3860
|
+
M.current = null;
|
|
3861
|
+
let l = i.getState(), m = l.agentId === d.current ? l.capabilities : f.current, g = le(m.ConversationSurface, he);
|
|
3862
|
+
D.current.set(e, g);
|
|
3863
|
+
let S = u.current, A = ++_.current;
|
|
3864
|
+
v.current = A, y.current = null;
|
|
3865
|
+
let j = (e, t) => {
|
|
3866
|
+
$(E.current, e, t, u.current, Nn);
|
|
3867
|
+
}, F = E.current.get(e);
|
|
3868
|
+
S && S !== e && (j(S, U.getState().messages), U.getState().setMessages(F || []), h.getState().clearSessionMessageHistory(e), W.getState().setSessionCheckpoints(e, []), W.getState().setSessionToolReceipts(e, []), r.getState().setCurrentRunId(""), r.getState().clearActivity()), u.current = e;
|
|
3869
|
+
let L = () => u.current === e && _.current === A && !c?.aborted;
|
|
3870
|
+
h.getState().setCurrentSessionId(e), h.getState().setSessionInitialMessageHistoryLoading(e, !F);
|
|
3871
|
+
let z = r.getState();
|
|
3872
|
+
z.isSessionStreaming(e) && z.updateActivity({
|
|
4886
3873
|
sessionId: e,
|
|
4887
3874
|
phase: "正在同步任务进展",
|
|
4888
3875
|
countEvent: !1
|
|
4889
|
-
}),
|
|
4890
|
-
let
|
|
4891
|
-
|
|
3876
|
+
}), o();
|
|
3877
|
+
let B = U.getState().messages;
|
|
3878
|
+
p.current?.abort(), a && b.getState().setMobileSidebarOpen(!1);
|
|
4892
3879
|
try {
|
|
4893
3880
|
let t = {
|
|
4894
|
-
limit:
|
|
3881
|
+
limit: jn,
|
|
4895
3882
|
includeReasoning: !0,
|
|
4896
3883
|
includeToolEvents: !0,
|
|
4897
3884
|
includeAttachments: !0,
|
|
4898
|
-
signal:
|
|
4899
|
-
},
|
|
4900
|
-
isCurrent:
|
|
4901
|
-
signal:
|
|
3885
|
+
signal: c
|
|
3886
|
+
}, a = await sn(() => n.listSessionMessages(e, t), {
|
|
3887
|
+
isCurrent: L,
|
|
3888
|
+
signal: c,
|
|
4902
3889
|
onPreparing: () => {
|
|
4903
|
-
let t =
|
|
4904
|
-
|
|
3890
|
+
let t = h.getState().messageHistory[e];
|
|
3891
|
+
h.getState().setSessionMessageHistory(e, {
|
|
4905
3892
|
...t,
|
|
4906
3893
|
nextCursor: t?.nextCursor ?? null,
|
|
4907
3894
|
hasMore: t?.hasMore ?? !1,
|
|
4908
3895
|
preparing: !0,
|
|
4909
3896
|
error: void 0
|
|
4910
|
-
}),
|
|
3897
|
+
}), h.getState().setSessionInitialMessageHistoryLoading(e, !F);
|
|
4911
3898
|
}
|
|
4912
3899
|
});
|
|
4913
|
-
if (!
|
|
4914
|
-
let
|
|
4915
|
-
$(O.current, e,
|
|
4916
|
-
let
|
|
4917
|
-
if (!
|
|
4918
|
-
let t =
|
|
4919
|
-
|
|
3900
|
+
if (!L()) return;
|
|
3901
|
+
let o = Cn(a.Messages);
|
|
3902
|
+
$(O.current, e, o, u.current);
|
|
3903
|
+
let l = o, f = 0, p = [];
|
|
3904
|
+
if (!F) {
|
|
3905
|
+
let t = Se(o, B, U.getState().messages);
|
|
3906
|
+
U.getState().setMessages(t), B = o, j(e, t);
|
|
4920
3907
|
}
|
|
4921
|
-
|
|
4922
|
-
nextCursor:
|
|
4923
|
-
hasMore:
|
|
4924
|
-
...
|
|
4925
|
-
}),
|
|
3908
|
+
h.getState().setSessionMessageHistory(e, {
|
|
3909
|
+
nextCursor: a.NextCursor,
|
|
3910
|
+
hasMore: a.HasMore,
|
|
3911
|
+
...Vn(a)
|
|
3912
|
+
}), h.getState().setSessionInitialMessageHistoryLoading(e, !1);
|
|
4926
3913
|
try {
|
|
4927
3914
|
let t = await n.listSessionEvents(e, {
|
|
4928
3915
|
offset: 0,
|
|
4929
|
-
limit:
|
|
4930
|
-
signal:
|
|
4931
|
-
historyEpoch:
|
|
4932
|
-
snapshotSeqId:
|
|
3916
|
+
limit: Mn,
|
|
3917
|
+
signal: c,
|
|
3918
|
+
historyEpoch: a.CursorSource === "runtime" ? a.HistoryEpoch : void 0,
|
|
3919
|
+
snapshotSeqId: a.CursorSource === "runtime" ? a.SnapshotSeqId : void 0
|
|
4933
3920
|
});
|
|
4934
|
-
if (!
|
|
4935
|
-
let
|
|
4936
|
-
if (
|
|
4937
|
-
let
|
|
4938
|
-
events:
|
|
4939
|
-
loadedCount:
|
|
4940
|
-
total:
|
|
4941
|
-
cursorSource:
|
|
4942
|
-
historyEpoch:
|
|
4943
|
-
snapshotSeqId:
|
|
3921
|
+
if (!L()) return;
|
|
3922
|
+
let r = In(a, t), i = t.Events, s = [...o].reverse().find((e) => e.invocationId && Object.values(e.tools || {}).some((e) => e.name === "call_a2a_agent"))?.invocationId;
|
|
3923
|
+
if (r && m.KernelSessionEventsByCommand === !0 && t.CursorSource === "runtime" && s && (i = await cn(n, e, s, t, L, c), !L())) return;
|
|
3924
|
+
let d = {
|
|
3925
|
+
events: r ? i : [],
|
|
3926
|
+
loadedCount: r ? i.length : 0,
|
|
3927
|
+
total: r ? Math.max(0, Number(t.Total ?? t.Events?.length ?? 0) || 0) : 0,
|
|
3928
|
+
cursorSource: r ? t.CursorSource : void 0,
|
|
3929
|
+
historyEpoch: r ? t.HistoryEpoch : void 0,
|
|
3930
|
+
snapshotSeqId: r ? t.SnapshotSeqId : void 0
|
|
4944
3931
|
};
|
|
4945
|
-
if ($(
|
|
4946
|
-
nextCursor:
|
|
4947
|
-
hasMore: !!(
|
|
4948
|
-
}),
|
|
4949
|
-
|
|
4950
|
-
for (let t of
|
|
4951
|
-
let t =
|
|
4952
|
-
|
|
3932
|
+
if ($(k.current, e, d, u.current), h.getState().setSessionMessageHistory(e, {
|
|
3933
|
+
nextCursor: a.NextCursor,
|
|
3934
|
+
hasMore: !!(a.HasMore || d.loadedCount < d.total)
|
|
3935
|
+
}), d.events.length > 0) {
|
|
3936
|
+
f = ee(d.events);
|
|
3937
|
+
for (let t of d.events) x(t, e);
|
|
3938
|
+
let t = Ee(o, d.events, e, g);
|
|
3939
|
+
p = t.canonicalRunIds, l = t.messages;
|
|
4953
3940
|
}
|
|
4954
|
-
if (
|
|
4955
|
-
let
|
|
4956
|
-
if (!
|
|
4957
|
-
for (let t of
|
|
4958
|
-
|
|
4959
|
-
generation:
|
|
3941
|
+
if (r) {
|
|
3942
|
+
let r = await fn(n, e, o, t, L, c);
|
|
3943
|
+
if (!L()) return;
|
|
3944
|
+
for (let t of r.events) x(t, e);
|
|
3945
|
+
r.incomplete && (y.current = {
|
|
3946
|
+
generation: A,
|
|
4960
3947
|
message: "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。"
|
|
4961
|
-
},
|
|
4962
|
-
...
|
|
4963
|
-
nextCursor:
|
|
4964
|
-
hasMore: !!(
|
|
3948
|
+
}, h.getState().setSessionMessageHistory(e, {
|
|
3949
|
+
...h.getState().messageHistory[e],
|
|
3950
|
+
nextCursor: a.NextCursor,
|
|
3951
|
+
hasMore: !!(a.HasMore || d.loadedCount < d.total),
|
|
4965
3952
|
error: "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。"
|
|
4966
3953
|
}));
|
|
4967
3954
|
}
|
|
4968
3955
|
} catch (e) {
|
|
4969
|
-
if (
|
|
4970
|
-
|
|
4971
|
-
generation:
|
|
3956
|
+
if (zn(e)) throw e;
|
|
3957
|
+
L() && (y.current = {
|
|
3958
|
+
generation: A,
|
|
4972
3959
|
message: "完整事件历史读取失败,请刷新会话后重新查找。当前结果只包含已读取的正文。"
|
|
4973
3960
|
}), console.warn("[SessionLifecycle] canonical history replay failed:", e);
|
|
4974
3961
|
}
|
|
4975
|
-
if (!
|
|
4976
|
-
|
|
4977
|
-
let
|
|
4978
|
-
if (
|
|
4979
|
-
agentId:
|
|
3962
|
+
if (!L()) return;
|
|
3963
|
+
C(l, e), $(w.current, e, new Set(p), u.current), $(T.current, e, l, u.current), l = Se(l, B, U.getState().messages), U.getState().setMessages(l), j(e, l), v.current = null, I(d.current, e, l);
|
|
3964
|
+
let _ = Math.max(a.LatestSeqId || 0, f), b = i.getState().capabilities || s;
|
|
3965
|
+
if (b.RunLifecycle.Enabled && b.RunLifecycle.Checkpoints ? (n.listSessionCheckpoints({
|
|
3966
|
+
agentId: d.current,
|
|
4980
3967
|
sessionId: e
|
|
4981
3968
|
}).then((t) => {
|
|
4982
|
-
|
|
3969
|
+
L() && W.getState().setSessionCheckpoints(e, t.Checkpoints || []);
|
|
4983
3970
|
}).catch((t) => {
|
|
4984
|
-
|
|
3971
|
+
L() && (console.warn("[SessionLifecycle] checkpoint load failed:", t), W.getState().setSessionCheckpoints(e, []));
|
|
4985
3972
|
}), n.listToolReceipts({
|
|
4986
|
-
agentId:
|
|
3973
|
+
agentId: d.current,
|
|
4987
3974
|
sessionId: e
|
|
4988
3975
|
}).then((t) => {
|
|
4989
|
-
|
|
3976
|
+
L() && W.getState().setSessionToolReceipts(e, t.ToolReceipts || []);
|
|
4990
3977
|
}).catch((t) => {
|
|
4991
|
-
|
|
4992
|
-
})) :
|
|
3978
|
+
L() && (console.warn("[SessionLifecycle] tool receipt load failed:", t), W.getState().setSessionToolReceipts(e, []));
|
|
3979
|
+
})) : W.getState().clearSessionCheckpoints(e), b.RunLifecycle.Enabled && b.RunLifecycle.Resume) try {
|
|
4993
3980
|
let t = await n.getSession(e);
|
|
4994
|
-
if (!
|
|
4995
|
-
let
|
|
4996
|
-
if (t.ActiveInvocationId && (
|
|
4997
|
-
let n =
|
|
3981
|
+
if (!L()) return;
|
|
3982
|
+
let i = String(t.ActiveRunStatus || "").toLowerCase();
|
|
3983
|
+
if (t.ActiveInvocationId && (Un.has(i) || i === "" && Wn(t))) {
|
|
3984
|
+
let n = r.getState().getSessionActivity(e), i = m.KernelSessionEventsByCommand === !0 && r.getState().isSessionStreaming(e) && n?.source === "run" && n.runId === t.ActiveInvocationId && [
|
|
4998
3985
|
"connecting",
|
|
4999
3986
|
"running",
|
|
5000
3987
|
"waiting"
|
|
5001
3988
|
].includes(n.status);
|
|
5002
|
-
|
|
3989
|
+
i && r.getState().updateActivity({
|
|
5003
3990
|
sessionId: e,
|
|
5004
3991
|
phase: "正在处理",
|
|
5005
3992
|
countEvent: !1
|
|
5006
|
-
}),
|
|
3993
|
+
}), i || R({
|
|
5007
3994
|
sessionId: e,
|
|
5008
3995
|
invocationId: t.ActiveInvocationId,
|
|
5009
|
-
afterSeqId:
|
|
3996
|
+
afterSeqId: _
|
|
5010
3997
|
});
|
|
5011
3998
|
} else {
|
|
5012
|
-
let n =
|
|
3999
|
+
let n = r.getState(), a = n.getSessionActivity(e), o = t.ActiveInvocationId && a?.runId === t.ActiveInvocationId ? Gn({
|
|
5013
4000
|
EventType: "run_status",
|
|
5014
|
-
Content: { status:
|
|
5015
|
-
}) : null, s =
|
|
4001
|
+
Content: { status: i }
|
|
4002
|
+
}) : null, s = a?.runId ? [...k.current.get(e)?.events || []].reverse().find((e) => {
|
|
5016
4003
|
let t = e.Content?.runtime_event;
|
|
5017
|
-
return e.InvocationId ===
|
|
5018
|
-
}) : void 0, c =
|
|
4004
|
+
return e.InvocationId === a.runId && !t?.parent_scope_id && P(e);
|
|
4005
|
+
}) : void 0, c = o || s && Gn(s);
|
|
5019
4006
|
c && (n.setSessionStreaming(e, !1), n.updateActivity({
|
|
5020
4007
|
sessionId: e,
|
|
5021
4008
|
...c,
|
|
@@ -5023,8 +4010,8 @@ function Pr(e) {
|
|
|
5023
4010
|
}));
|
|
5024
4011
|
}
|
|
5025
4012
|
} catch (t) {
|
|
5026
|
-
if (console.warn("[SessionLifecycle] getSession for reconnect failed:", t),
|
|
5027
|
-
let t =
|
|
4013
|
+
if (console.warn("[SessionLifecycle] getSession for reconnect failed:", t), L()) {
|
|
4014
|
+
let t = r.getState();
|
|
5028
4015
|
t.isSessionStreaming(e) && t.getSessionActivity(e)?.phase === "正在同步任务进展" && t.updateActivity({
|
|
5029
4016
|
sessionId: e,
|
|
5030
4017
|
phase: "正在确认任务状态",
|
|
@@ -5033,8 +4020,8 @@ function Pr(e) {
|
|
|
5033
4020
|
}
|
|
5034
4021
|
}
|
|
5035
4022
|
} catch (n) {
|
|
5036
|
-
if (
|
|
5037
|
-
|
|
4023
|
+
if (zn(n) && !t && L()) {
|
|
4024
|
+
h.getState().setSessionMessageHistory(e, {
|
|
5038
4025
|
nextCursor: null,
|
|
5039
4026
|
hasMore: !1,
|
|
5040
4027
|
cursorSource: void 0,
|
|
@@ -5045,18 +4032,18 @@ function Pr(e) {
|
|
|
5045
4032
|
cursorCompatibleWithRuntime: void 0,
|
|
5046
4033
|
sessionContractVersion: void 0
|
|
5047
4034
|
}), queueMicrotask(() => {
|
|
5048
|
-
|
|
4035
|
+
L() && N.current?.(e, !0);
|
|
5049
4036
|
});
|
|
5050
4037
|
return;
|
|
5051
4038
|
}
|
|
5052
|
-
if (
|
|
5053
|
-
let r = t ? "历史来源已变化,重新加载失败。原有消息已保留,请手动刷新会话。" :
|
|
5054
|
-
|
|
5055
|
-
generation:
|
|
4039
|
+
if (L() && !(n instanceof X)) {
|
|
4040
|
+
let r = t ? "历史来源已变化,重新加载失败。原有消息已保留,请手动刷新会话。" : on(n) ? "历史仍在准备,请稍后重试。" : "会话历史读取失败,请重试。已有消息已保留。";
|
|
4041
|
+
y.current = {
|
|
4042
|
+
generation: A,
|
|
5056
4043
|
message: r
|
|
5057
4044
|
};
|
|
5058
|
-
let i =
|
|
5059
|
-
|
|
4045
|
+
let i = h.getState().messageHistory[e];
|
|
4046
|
+
h.getState().setSessionMessageHistory(e, {
|
|
5060
4047
|
...i,
|
|
5061
4048
|
nextCursor: i?.nextCursor ?? null,
|
|
5062
4049
|
hasMore: i?.hasMore ?? !1,
|
|
@@ -5069,147 +4056,147 @@ function Pr(e) {
|
|
|
5069
4056
|
} : {},
|
|
5070
4057
|
preparing: !1,
|
|
5071
4058
|
error: r
|
|
5072
|
-
}), t &&
|
|
4059
|
+
}), t && b.getState().pushToast(r, "error");
|
|
5073
4060
|
}
|
|
5074
|
-
n instanceof
|
|
4061
|
+
n instanceof X || console.error("Failed to load session messages:", n);
|
|
5075
4062
|
} finally {
|
|
5076
|
-
|
|
4063
|
+
v.current === A && (v.current = null), L() && h.getState().setSessionInitialMessageHistoryLoading(e, !1);
|
|
5077
4064
|
}
|
|
5078
4065
|
}, [
|
|
5079
4066
|
n,
|
|
5080
|
-
|
|
4067
|
+
a,
|
|
4068
|
+
I,
|
|
4069
|
+
o,
|
|
5081
4070
|
R,
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
]), V = H(async (e = "default-agent", t = null) => {
|
|
5086
|
-
let r = s.getState();
|
|
4071
|
+
s
|
|
4072
|
+
]), H = K(async (e = "default-agent", t = null) => {
|
|
4073
|
+
let r = h.getState();
|
|
5087
4074
|
r.sessionsAgentId && r.sessionsAgentId !== e && r.resetSessionPagination(e);
|
|
5088
|
-
let
|
|
4075
|
+
let a = h.getState().sessionsGeneration, o = () => i.getState().agentId === e && h.getState().sessionsGeneration === a;
|
|
5089
4076
|
try {
|
|
5090
|
-
|
|
4077
|
+
h.getState().setLoadingSessions(!0);
|
|
5091
4078
|
let r = await n.listSessions(e, {
|
|
5092
4079
|
page: 1,
|
|
5093
|
-
pageSize:
|
|
4080
|
+
pageSize: An
|
|
5094
4081
|
});
|
|
5095
|
-
if (!
|
|
4082
|
+
if (!o()) return;
|
|
5096
4083
|
let i = r.Sessions || [];
|
|
5097
|
-
for (let e of i)
|
|
5098
|
-
let
|
|
5099
|
-
if (
|
|
4084
|
+
for (let e of i) A.current.delete(e.SessionId);
|
|
4085
|
+
let a = new Set(Array.from(A.current.entries()).filter(([, t]) => t === e).map(([e]) => e)), s = tt(i, h.getState().sessions, a);
|
|
4086
|
+
if (h.getState().upsertSessions(s, {
|
|
5100
4087
|
agentId: e,
|
|
5101
4088
|
total: Number(r.Total ?? r.Sessions?.length ?? 0),
|
|
5102
4089
|
page: Number(r.Page ?? 1),
|
|
5103
|
-
pageSize: Number(r.PageSize ??
|
|
4090
|
+
pageSize: Number(r.PageSize ?? An),
|
|
5104
4091
|
replace: !0
|
|
5105
|
-
}),
|
|
5106
|
-
let
|
|
5107
|
-
|
|
4092
|
+
}), j.current || M.current === e) return;
|
|
4093
|
+
let c = h.getState().sessions, d = u.current, f = d || (l ? et(c, t || Qe(e)) : null);
|
|
4094
|
+
f && f !== d && V(f);
|
|
5108
4095
|
} catch (e) {
|
|
5109
|
-
if (e instanceof
|
|
4096
|
+
if (e instanceof X) return;
|
|
5110
4097
|
console.error("Failed to fetch sessions:", e);
|
|
5111
4098
|
} finally {
|
|
5112
|
-
|
|
4099
|
+
o() && h.getState().setLoadingSessions(!1);
|
|
5113
4100
|
}
|
|
5114
4101
|
}, [
|
|
5115
4102
|
n,
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
]),
|
|
5119
|
-
let e =
|
|
4103
|
+
V,
|
|
4104
|
+
l
|
|
4105
|
+
]), ne = K(async () => {
|
|
4106
|
+
let e = h.getState();
|
|
5120
4107
|
if (e.isLoadingSessions || !e.hasMoreSessions) return;
|
|
5121
|
-
let t =
|
|
4108
|
+
let t = m({
|
|
5122
4109
|
total: e.sessionsTotal,
|
|
5123
|
-
pageSize: e.sessionsPageSize ||
|
|
4110
|
+
pageSize: e.sessionsPageSize || An,
|
|
5124
4111
|
loadedPages: e.loadedPages
|
|
5125
4112
|
});
|
|
5126
4113
|
if (!t) return;
|
|
5127
|
-
let r = e.sessionsPageSize ||
|
|
4114
|
+
let r = e.sessionsPageSize || An, a = e.sessionsAgentId || d.current || "default-agent", o = () => i.getState().agentId === a && h.getState().sessionsGeneration === e.sessionsGeneration;
|
|
5128
4115
|
try {
|
|
5129
|
-
|
|
4116
|
+
h.getState().setLoadingSessions(!0);
|
|
5130
4117
|
let i = await n.listSessions(a, {
|
|
5131
4118
|
page: t,
|
|
5132
4119
|
pageSize: r
|
|
5133
4120
|
});
|
|
5134
4121
|
if (!o()) return;
|
|
5135
|
-
|
|
4122
|
+
h.getState().upsertSessions(i.Sessions || [], {
|
|
5136
4123
|
agentId: a,
|
|
5137
4124
|
total: Number(i.Total ?? e.sessionsTotal),
|
|
5138
4125
|
page: Number(i.Page ?? t),
|
|
5139
4126
|
pageSize: Number(i.PageSize ?? r)
|
|
5140
4127
|
});
|
|
5141
4128
|
} catch (e) {
|
|
5142
|
-
if (e instanceof
|
|
4129
|
+
if (e instanceof X) return;
|
|
5143
4130
|
console.error("Failed to load more sessions:", e);
|
|
5144
4131
|
} finally {
|
|
5145
|
-
o() &&
|
|
4132
|
+
o() && h.getState().setLoadingSessions(!1);
|
|
5146
4133
|
}
|
|
5147
4134
|
}, [n]);
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
}, [
|
|
5151
|
-
|
|
5152
|
-
}, [
|
|
5153
|
-
let
|
|
5154
|
-
if (
|
|
5155
|
-
|
|
4135
|
+
q(() => {
|
|
4136
|
+
N.current = V;
|
|
4137
|
+
}, [V]), q(() => {
|
|
4138
|
+
F.current = H;
|
|
4139
|
+
}, [H]);
|
|
4140
|
+
let re = K((e, t = !1) => {
|
|
4141
|
+
if (M.current = null, t && u.current === e) {
|
|
4142
|
+
h.getState().upsertSessions([{
|
|
5156
4143
|
SessionId: e,
|
|
5157
4144
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5158
4145
|
}]);
|
|
5159
4146
|
return;
|
|
5160
4147
|
}
|
|
5161
|
-
|
|
4148
|
+
_.current += 1, p.current?.abort(), A.current.set(e, d.current), h.getState().upsertSessions([{
|
|
5162
4149
|
SessionId: e,
|
|
5163
4150
|
UpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5164
|
-
}]),
|
|
5165
|
-
}, [
|
|
5166
|
-
|
|
5167
|
-
}, [
|
|
5168
|
-
if (
|
|
5169
|
-
await
|
|
4151
|
+
}]), u.current = e, h.getState().setCurrentSessionId(e), t || (U.getState().setMessages([]), r.getState().setCurrentRunId(""), r.getState().clearActivity()), h.getState().clearSessionMessageHistory(e), W.getState().setSessionCheckpoints(e, []), W.getState().setSessionToolReceipts(e, []), a && (b.getState().setMobileSidebarOpen(!1), b.getState().setMobileActionsOpen(!1));
|
|
4152
|
+
}, [a]), ie = K(() => {
|
|
4153
|
+
M.current = d.current, _.current += 1, p.current?.abort(), u.current = null, h.getState().setCurrentSessionId(null), U.getState().setMessages([]), r.getState().setCurrentRunId(""), r.getState().clearActivity(), a && b.getState().setMobileSidebarOpen(!1);
|
|
4154
|
+
}, [a]), oe = K(async () => {
|
|
4155
|
+
if (j.current) {
|
|
4156
|
+
await j.current;
|
|
5170
4157
|
return;
|
|
5171
4158
|
}
|
|
5172
|
-
|
|
4159
|
+
_.current += 1, p.current?.abort(), u.current = null, h.getState().setCurrentSessionId(null), U.getState().setMessages([]);
|
|
5173
4160
|
let e = n.createSession(t).then((e) => {
|
|
5174
4161
|
let n = e.SessionId || null;
|
|
5175
|
-
return n &&
|
|
5176
|
-
}).catch((e) => (e instanceof
|
|
5177
|
-
|
|
4162
|
+
return n && i.getState().agentId === t && re(n, U.getState().messages.some((e) => e.eventType === "optimistic_user_message" || e.eventType === "optimistic_assistant_placeholder")), n;
|
|
4163
|
+
}).catch((e) => (e instanceof X || console.error("Failed to create session:", e), null));
|
|
4164
|
+
j.current = e;
|
|
5178
4165
|
try {
|
|
5179
4166
|
await e;
|
|
5180
4167
|
} finally {
|
|
5181
|
-
|
|
4168
|
+
j.current === e && (j.current = null);
|
|
5182
4169
|
}
|
|
5183
4170
|
}, [
|
|
5184
|
-
|
|
4171
|
+
re,
|
|
5185
4172
|
t,
|
|
5186
4173
|
n
|
|
5187
|
-
]),
|
|
5188
|
-
let e =
|
|
5189
|
-
return e ? await e :
|
|
5190
|
-
}, []),
|
|
4174
|
+
]), se = K(async () => {
|
|
4175
|
+
let e = j.current;
|
|
4176
|
+
return e ? await e : u.current;
|
|
4177
|
+
}, []), ce = K(async (e) => {
|
|
5191
4178
|
try {
|
|
5192
|
-
let
|
|
5193
|
-
return
|
|
4179
|
+
let a = await n.deleteSession(e);
|
|
4180
|
+
return i.getState().agentId === t ? a.Deleted === !1 ? (b.getState().pushToast("会话暂未删除,云端运行时仍在同步,请稍后重试。", "error"), H(t, u.current ?? void 0), !1) : (h.getState().removeSession(e), h.getState().clearSessionMessageHistory(e), E.current.delete(e), O.current.delete(e), D.current.delete(e), k.current.delete(e), w.current.delete(e), T.current.delete(e), A.current.delete(e), u.current === e && (_.current += 1, p.current?.abort(), c?.(), u.current = null, U.getState().setMessages([]), W.getState().clearSessionCheckpoints(e), h.getState().setCurrentSessionId(null), r.getState().setCurrentRunId(""), r.getState().clearActivity(), H(t)), !0) : a.Deleted !== !1;
|
|
5194
4181
|
} catch (e) {
|
|
5195
|
-
return e instanceof
|
|
4182
|
+
return e instanceof X ? !1 : (console.error("Failed to delete session", e), b.getState().pushToast("删除会话失败,请稍后重试。", "error"), !1);
|
|
5196
4183
|
}
|
|
5197
4184
|
}, [
|
|
5198
4185
|
t,
|
|
5199
4186
|
n,
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
]),
|
|
4187
|
+
c,
|
|
4188
|
+
H
|
|
4189
|
+
]), ue = K(async (e, t) => {
|
|
5203
4190
|
t?.throwIfAborted();
|
|
5204
|
-
let r =
|
|
4191
|
+
let r = h.getState().messageHistory[e], i = k.current.get(e), a = !!(r?.hasMore && r.nextCursor !== null), o = !!(i && i.loadedCount < i.total);
|
|
5205
4192
|
if (!r || r.isLoadingOlder || !a && !o) return;
|
|
5206
|
-
let
|
|
5207
|
-
|
|
5208
|
-
let
|
|
5209
|
-
isCurrent:
|
|
4193
|
+
let s = _.current, c = T.current.get(e) || U.getState().messages, l = Symbol(e);
|
|
4194
|
+
S.current.set(e, l);
|
|
4195
|
+
let f = () => u.current === e && _.current === s && S.current.get(e) === l && !t?.aborted, p = {
|
|
4196
|
+
isCurrent: f,
|
|
5210
4197
|
signal: t,
|
|
5211
4198
|
onPreparing: () => {
|
|
5212
|
-
|
|
4199
|
+
h.getState().setSessionMessageHistory(e, {
|
|
5213
4200
|
...r,
|
|
5214
4201
|
preparing: !0,
|
|
5215
4202
|
error: void 0,
|
|
@@ -5218,97 +4205,97 @@ function Pr(e) {
|
|
|
5218
4205
|
}
|
|
5219
4206
|
};
|
|
5220
4207
|
try {
|
|
5221
|
-
|
|
5222
|
-
let [
|
|
4208
|
+
h.getState().setSessionMessageHistoryLoading(e, !0);
|
|
4209
|
+
let [m, g] = await Promise.allSettled([a ? sn(() => n.listSessionMessages(e, {
|
|
5223
4210
|
signal: t,
|
|
5224
4211
|
beforeSeqId: r.nextCursor ?? void 0,
|
|
5225
4212
|
cursorSource: r.cursorSource,
|
|
5226
4213
|
historyEpoch: r.historyEpoch,
|
|
5227
4214
|
snapshotSeqId: r.snapshotSeqId,
|
|
5228
|
-
limit:
|
|
4215
|
+
limit: jn,
|
|
5229
4216
|
includeReasoning: !0,
|
|
5230
4217
|
includeToolEvents: !0,
|
|
5231
4218
|
includeAttachments: !0
|
|
5232
|
-
}),
|
|
4219
|
+
}), p) : Promise.resolve(null), o && i ? sn(() => n.listSessionEvents(e, {
|
|
5233
4220
|
signal: t,
|
|
5234
4221
|
offset: i.loadedCount,
|
|
5235
|
-
limit:
|
|
4222
|
+
limit: Mn,
|
|
5236
4223
|
cursorSource: i.cursorSource,
|
|
5237
4224
|
historyEpoch: i.historyEpoch,
|
|
5238
4225
|
snapshotSeqId: i.snapshotSeqId
|
|
5239
|
-
}),
|
|
5240
|
-
if (t?.throwIfAborted(),
|
|
5241
|
-
let
|
|
4226
|
+
}), p) : Promise.resolve(null)]);
|
|
4227
|
+
if (t?.throwIfAborted(), u.current !== e || _.current !== s || S.current.get(e) !== l) return;
|
|
4228
|
+
let v = g.status === "rejected" && g.reason instanceof Y && [
|
|
5242
4229
|
429,
|
|
5243
4230
|
502,
|
|
5244
4231
|
503,
|
|
5245
4232
|
504
|
|
5246
4233
|
].includes(g.reason.code);
|
|
5247
|
-
if (g.status === "rejected" && !
|
|
5248
|
-
if (
|
|
5249
|
-
let
|
|
5250
|
-
if (
|
|
4234
|
+
if (g.status === "rejected" && !v) throw g.reason;
|
|
4235
|
+
if (m.status === "rejected") throw m.reason;
|
|
4236
|
+
let b = m.value, A = g.status === "fulfilled" ? g.value : null, j = v ? "消息正文已加载,部分事件详情暂时读取失败,请重试加载更早记录。" : void 0;
|
|
4237
|
+
if (b && !In({
|
|
5251
4238
|
CursorSource: r.cursorSource,
|
|
5252
4239
|
HistoryEpoch: r.historyEpoch,
|
|
5253
4240
|
SnapshotSeqId: r.snapshotSeqId,
|
|
5254
4241
|
CursorCompatibleWithRuntime: r.cursorCompatibleWithRuntime
|
|
5255
|
-
},
|
|
5256
|
-
|
|
5257
|
-
generation:
|
|
5258
|
-
message:
|
|
5259
|
-
} :
|
|
5260
|
-
let
|
|
5261
|
-
$(O.current, e,
|
|
5262
|
-
let P = i?.events || [], F = i?.loadedCount || 0,
|
|
5263
|
-
if (
|
|
5264
|
-
let t =
|
|
5265
|
-
P =
|
|
4242
|
+
}, b) || A && i && !In(Ln(i), A)) throw Bn();
|
|
4243
|
+
j ? y.current = {
|
|
4244
|
+
generation: s,
|
|
4245
|
+
message: j
|
|
4246
|
+
} : A && (y.current = null);
|
|
4247
|
+
let M = b ? Cn(b.Messages) : [], ee = new Set(M.map((e) => e.id)), N = [...M, ...(O.current.get(e) || []).filter((e) => !ee.has(e.id))];
|
|
4248
|
+
$(O.current, e, N, u.current);
|
|
4249
|
+
let P = i?.events || [], F = i?.loadedCount || 0, R = i?.total || 0;
|
|
4250
|
+
if (A) {
|
|
4251
|
+
let t = A.Events || [];
|
|
4252
|
+
P = L(t, P), R = Math.max(R, Number(A.Total ?? 0) || 0), F = t.length > 0 ? Math.min(R, F + t.length) : R, $(k.current, e, {
|
|
5266
4253
|
events: P,
|
|
5267
4254
|
loadedCount: F,
|
|
5268
|
-
total:
|
|
5269
|
-
cursorSource:
|
|
5270
|
-
historyEpoch:
|
|
5271
|
-
snapshotSeqId:
|
|
5272
|
-
},
|
|
5273
|
-
for (let n of t)
|
|
4255
|
+
total: R,
|
|
4256
|
+
cursorSource: A.CursorSource ?? i?.cursorSource,
|
|
4257
|
+
historyEpoch: A.HistoryEpoch ?? i?.historyEpoch,
|
|
4258
|
+
snapshotSeqId: A.SnapshotSeqId ?? i?.snapshotSeqId
|
|
4259
|
+
}, u.current);
|
|
4260
|
+
for (let n of t) x(n, e);
|
|
5274
4261
|
}
|
|
5275
|
-
if (
|
|
5276
|
-
let r = await
|
|
4262
|
+
if (M.length && i) {
|
|
4263
|
+
let r = await fn(n, e, M, {
|
|
5277
4264
|
Events: P,
|
|
5278
4265
|
CursorSource: i.cursorSource,
|
|
5279
4266
|
HistoryEpoch: i.historyEpoch,
|
|
5280
4267
|
SnapshotSeqId: i.snapshotSeqId
|
|
5281
|
-
},
|
|
5282
|
-
if (!
|
|
5283
|
-
for (let t of r.events)
|
|
5284
|
-
r.incomplete && (
|
|
5285
|
-
generation:
|
|
5286
|
-
message:
|
|
4268
|
+
}, f, t);
|
|
4269
|
+
if (!f()) return;
|
|
4270
|
+
for (let t of r.events) x(t, e);
|
|
4271
|
+
r.incomplete && (j = "部分交互历史尚未恢复完整,旧卡片保持只读。请加载较早消息后重试。", y.current = {
|
|
4272
|
+
generation: s,
|
|
4273
|
+
message: j
|
|
5287
4274
|
});
|
|
5288
4275
|
}
|
|
5289
|
-
let
|
|
5290
|
-
|
|
5291
|
-
let
|
|
5292
|
-
$(
|
|
5293
|
-
nextCursor:
|
|
5294
|
-
hasMore: !!(
|
|
5295
|
-
...
|
|
5296
|
-
...
|
|
5297
|
-
dataSource:
|
|
5298
|
-
degraded:
|
|
5299
|
-
cursorSource:
|
|
5300
|
-
cursorCompatibleWithRuntime:
|
|
5301
|
-
sessionContractVersion:
|
|
5302
|
-
historyEpoch:
|
|
5303
|
-
persistenceDegraded:
|
|
5304
|
-
snapshotSeqId:
|
|
4276
|
+
let z = Ee(N, P, e, D.current.get(e) || "flat-v1");
|
|
4277
|
+
C(z.messages, e), $(T.current, e, z.messages, u.current);
|
|
4278
|
+
let B = Se(z.messages, c, U.getState().messages);
|
|
4279
|
+
$(w.current, e, new Set(z.canonicalRunIds), u.current), U.getState().setMessages(B), $(E.current, e, B, u.current, Nn), h.getState().setSessionMessageHistory(e, {
|
|
4280
|
+
nextCursor: b ? b.NextCursor : r.nextCursor,
|
|
4281
|
+
hasMore: !!(b && b.HasMore || F < R),
|
|
4282
|
+
...b ? Vn(b) : {},
|
|
4283
|
+
...b ? {
|
|
4284
|
+
dataSource: b.DataSource ?? r.dataSource,
|
|
4285
|
+
degraded: b.Degraded ?? r.degraded,
|
|
4286
|
+
cursorSource: b.CursorSource ?? r.cursorSource,
|
|
4287
|
+
cursorCompatibleWithRuntime: b.CursorCompatibleWithRuntime ?? r.cursorCompatibleWithRuntime,
|
|
4288
|
+
sessionContractVersion: b.SessionContractVersion ?? r.sessionContractVersion,
|
|
4289
|
+
historyEpoch: b.HistoryEpoch ?? r.historyEpoch,
|
|
4290
|
+
persistenceDegraded: b.PersistenceDegraded ?? r.persistenceDegraded,
|
|
4291
|
+
snapshotSeqId: b.SnapshotSeqId ?? r.snapshotSeqId
|
|
5305
4292
|
} : {},
|
|
5306
4293
|
preparing: !1,
|
|
5307
|
-
error:
|
|
5308
|
-
}),
|
|
4294
|
+
error: j
|
|
4295
|
+
}), I(d.current, e, M);
|
|
5309
4296
|
} catch (n) {
|
|
5310
|
-
if (
|
|
5311
|
-
|
|
4297
|
+
if (zn(n) && u.current === e && _.current === s && S.current.get(e) === l && !t?.aborted) {
|
|
4298
|
+
h.getState().setSessionMessageHistory(e, {
|
|
5312
4299
|
nextCursor: null,
|
|
5313
4300
|
hasMore: !1,
|
|
5314
4301
|
cursorSource: void 0,
|
|
@@ -5320,62 +4307,62 @@ function Pr(e) {
|
|
|
5320
4307
|
sessionContractVersion: void 0,
|
|
5321
4308
|
persistenceDegraded: void 0,
|
|
5322
4309
|
error: void 0
|
|
5323
|
-
}), await
|
|
4310
|
+
}), await V(e, !0, t);
|
|
5324
4311
|
return;
|
|
5325
4312
|
}
|
|
5326
|
-
if (
|
|
4313
|
+
if (f() && !(n instanceof X) && h.getState().setSessionMessageHistory(e, {
|
|
5327
4314
|
...r,
|
|
5328
4315
|
preparing: !1,
|
|
5329
4316
|
error: n instanceof Error ? n.message : "历史加载失败,请重试"
|
|
5330
4317
|
}), t) throw n;
|
|
5331
|
-
n instanceof
|
|
4318
|
+
n instanceof X || console.error("Failed to load older session messages:", n);
|
|
5332
4319
|
} finally {
|
|
5333
|
-
if (
|
|
5334
|
-
let t =
|
|
5335
|
-
|
|
4320
|
+
if (S.current.get(e) === l) if (S.current.delete(e), _.current === s) {
|
|
4321
|
+
let t = h.getState().messageHistory[e];
|
|
4322
|
+
h.getState().setSessionMessageHistory(e, {
|
|
5336
4323
|
...t,
|
|
5337
4324
|
nextCursor: t?.nextCursor ?? null,
|
|
5338
4325
|
hasMore: t?.hasMore ?? !1,
|
|
5339
4326
|
preparing: !1,
|
|
5340
4327
|
isLoadingOlder: !1
|
|
5341
4328
|
});
|
|
5342
|
-
} else
|
|
4329
|
+
} else h.getState().setSessionMessageHistoryLoading(e, !1);
|
|
5343
4330
|
}
|
|
5344
4331
|
}, [
|
|
5345
4332
|
n,
|
|
5346
|
-
|
|
5347
|
-
|
|
4333
|
+
I,
|
|
4334
|
+
V
|
|
5348
4335
|
]);
|
|
5349
4336
|
return {
|
|
5350
|
-
historySearchSnapshot:
|
|
5351
|
-
let e =
|
|
4337
|
+
historySearchSnapshot: K(() => {
|
|
4338
|
+
let e = u.current || "", t = h.getState().messageHistory[e], n = k.current.get(e);
|
|
5352
4339
|
return {
|
|
5353
4340
|
owner: JSON.stringify([
|
|
5354
|
-
|
|
4341
|
+
d.current,
|
|
5355
4342
|
e,
|
|
5356
|
-
|
|
4343
|
+
_.current
|
|
5357
4344
|
]),
|
|
5358
|
-
messages:
|
|
4345
|
+
messages: U.getState().messages,
|
|
5359
4346
|
hasMore: !!t?.hasMore,
|
|
5360
|
-
loading: !!(
|
|
4347
|
+
loading: !!(v.current === _.current || h.getState().isLoadingSessions || t?.isLoadingInitial || t?.isLoadingOlder),
|
|
5361
4348
|
checkpoint: `${t?.nextCursor}:${n?.loadedCount}`,
|
|
5362
|
-
error:
|
|
4349
|
+
error: y.current?.generation === _.current ? y.current.message : void 0
|
|
5363
4350
|
};
|
|
5364
4351
|
}, []),
|
|
5365
|
-
followAcceptedInteraction:
|
|
5366
|
-
fetchSessions:
|
|
5367
|
-
loadMoreSessions:
|
|
5368
|
-
loadSession:
|
|
5369
|
-
loadOlderSessionMessages:
|
|
5370
|
-
createNewSession:
|
|
5371
|
-
startNewConversation:
|
|
5372
|
-
adoptCreatedSession:
|
|
5373
|
-
waitForPendingSessionCreation:
|
|
5374
|
-
deleteSession:
|
|
5375
|
-
currentSessionIdRef:
|
|
5376
|
-
agentIdRef:
|
|
5377
|
-
runSubscriptionAbortRef:
|
|
4352
|
+
followAcceptedInteraction: B,
|
|
4353
|
+
fetchSessions: H,
|
|
4354
|
+
loadMoreSessions: ne,
|
|
4355
|
+
loadSession: V,
|
|
4356
|
+
loadOlderSessionMessages: ue,
|
|
4357
|
+
createNewSession: oe,
|
|
4358
|
+
startNewConversation: ie,
|
|
4359
|
+
adoptCreatedSession: re,
|
|
4360
|
+
waitForPendingSessionCreation: se,
|
|
4361
|
+
deleteSession: ce,
|
|
4362
|
+
currentSessionIdRef: u,
|
|
4363
|
+
agentIdRef: d,
|
|
4364
|
+
runSubscriptionAbortRef: p
|
|
5378
4365
|
};
|
|
5379
4366
|
}
|
|
5380
4367
|
//#endregion
|
|
5381
|
-
export {
|
|
4368
|
+
export { Ge as S, ot as _, an as a, He as b, kt as c, Ct as d, gt as f, st as g, lt as h, On as i, Tt as l, ft as m, wn as n, Kt as o, pt as p, Dn as r, Nt as s, Kn as t, Et as u, $e as v, We as x, qe as y };
|