@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,22 +1,23 @@
|
|
|
1
|
-
import { i as e } from "./capabilities-lJRDfRg9.js";
|
|
2
|
-
import { n as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { create as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { i as e, o as t } from "./capabilities-lJRDfRg9.js";
|
|
2
|
+
import { f as n, p as r, s as i } from "./session-events-6PXUoAkP.js";
|
|
3
|
+
import { createContext as a, useContext as o } from "react";
|
|
4
|
+
import { create as s } from "zustand";
|
|
5
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
6
|
+
import { z as l } from "zod";
|
|
7
|
+
import u from "ajv";
|
|
8
|
+
import d from "ajv/dist/2019.js";
|
|
9
|
+
import f from "ajv/dist/2020.js";
|
|
10
|
+
import p from "ajv-draft-04";
|
|
11
|
+
import m from "ajv-formats";
|
|
12
|
+
import { canonicalize as h } from "json-canonicalize";
|
|
10
13
|
import { sha256 as ee } from "@noble/hashes/sha2.js";
|
|
11
14
|
import { bytesToHex as te } from "@noble/hashes/utils.js";
|
|
12
|
-
import ne from "
|
|
13
|
-
import re from "ajv/dist/2019.js";
|
|
14
|
-
import ie from "ajv-draft-04";
|
|
15
|
+
import { Catalog as g, MessageProcessor as ne, createFunctionImplementation as re } from "@a2ui/web_core/v0_9";
|
|
15
16
|
//#region src/stores/ui.ts
|
|
16
|
-
function
|
|
17
|
+
function ie(e, t) {
|
|
17
18
|
return typeof t == "function" ? t(e) : t;
|
|
18
19
|
}
|
|
19
|
-
var ae =
|
|
20
|
+
var ae = s()((e) => ({
|
|
20
21
|
sidebarOpen: !0,
|
|
21
22
|
mobileSidebarOpen: !1,
|
|
22
23
|
mobileActionsOpen: !1,
|
|
@@ -39,10 +40,10 @@ var ae = a()((e) => ({
|
|
|
39
40
|
setWorkspacePanelWidth: (t) => e({ workspacePanelWidth: t }),
|
|
40
41
|
setWorkspacePanelFullscreen: (t) => e({ workspacePanelFullscreen: t }),
|
|
41
42
|
setInput: (t) => e({ input: t }),
|
|
42
|
-
setAttachments: (t) => e((e) => ({ attachments:
|
|
43
|
+
setAttachments: (t) => e((e) => ({ attachments: ie(e.attachments, t) })),
|
|
43
44
|
setPreviewAttachment: (t) => e({ previewAttachment: t }),
|
|
44
45
|
setPreviewImageSize: (t) => e({ previewImageSize: t }),
|
|
45
|
-
setQueuedDrafts: (t) => e((e) => ({ queuedDrafts:
|
|
46
|
+
setQueuedDrafts: (t) => e((e) => ({ queuedDrafts: ie(e.queuedDrafts, t) })),
|
|
46
47
|
pushToast: (t, n = "info") => e((e) => ({ toasts: [...e.toasts, {
|
|
47
48
|
id: String(Date.now() + Math.random()),
|
|
48
49
|
message: t,
|
|
@@ -50,14 +51,14 @@ var ae = a()((e) => ({
|
|
|
50
51
|
createdAt: Date.now()
|
|
51
52
|
}] })),
|
|
52
53
|
dismissToast: (t) => e((e) => ({ toasts: e.toasts.filter((e) => e.id !== t) }))
|
|
53
|
-
})),
|
|
54
|
+
})), _ = (e) => Object.keys(e).length > 0, oe = {
|
|
54
55
|
runId: null,
|
|
55
56
|
status: null,
|
|
56
57
|
items: []
|
|
57
|
-
},
|
|
58
|
+
}, v = new r(), y = (e, t) => {
|
|
58
59
|
let n = { ...e };
|
|
59
60
|
return delete n[t], n;
|
|
60
|
-
},
|
|
61
|
+
}, se = s()((e, t) => ({
|
|
61
62
|
isStreaming: !1,
|
|
62
63
|
currentRunId: "",
|
|
63
64
|
stopRequested: !1,
|
|
@@ -67,7 +68,7 @@ var ae = a()((e) => ({
|
|
|
67
68
|
banner: null,
|
|
68
69
|
lastSeqId: 0,
|
|
69
70
|
activeInvocationId: "",
|
|
70
|
-
runtimeItems:
|
|
71
|
+
runtimeItems: oe,
|
|
71
72
|
setStreaming: (t) => e({ isStreaming: t }),
|
|
72
73
|
setBanner: (t) => e({ banner: t ? {
|
|
73
74
|
...t,
|
|
@@ -76,22 +77,22 @@ var ae = a()((e) => ({
|
|
|
76
77
|
setLastSeqId: (t) => e({ lastSeqId: t }),
|
|
77
78
|
setActiveInvocationId: (t) => e({ activeInvocationId: t }),
|
|
78
79
|
setSessionStreaming: (t, n) => e((e) => {
|
|
79
|
-
let r = String(t || ""), i =
|
|
80
|
+
let r = String(t || ""), i = y(e.sessionStreaming, r), a = n ? {
|
|
80
81
|
...i,
|
|
81
82
|
[r]: !0
|
|
82
83
|
} : i;
|
|
83
84
|
return {
|
|
84
85
|
sessionStreaming: a,
|
|
85
|
-
isStreaming:
|
|
86
|
+
isStreaming: _(a)
|
|
86
87
|
};
|
|
87
88
|
}),
|
|
88
89
|
isSessionStreaming: (e) => {
|
|
89
|
-
let
|
|
90
|
-
return !!
|
|
90
|
+
let n = String(e || "");
|
|
91
|
+
return !!t().sessionStreaming[n];
|
|
91
92
|
},
|
|
92
93
|
getSessionActivity: (e) => {
|
|
93
|
-
let
|
|
94
|
-
return
|
|
94
|
+
let n = String(e || "");
|
|
95
|
+
return n && t().sessionActivities[n] || null;
|
|
95
96
|
},
|
|
96
97
|
setCurrentRunId: (t) => e({ currentRunId: t }),
|
|
97
98
|
requestStop: () => e({ stopRequested: !0 }),
|
|
@@ -129,7 +130,7 @@ var ae = a()((e) => ({
|
|
|
129
130
|
eventCount: t.countEvent === !1 ? 0 : 1
|
|
130
131
|
};
|
|
131
132
|
return n ? {
|
|
132
|
-
isStreaming:
|
|
133
|
+
isStreaming: _(e.sessionStreaming),
|
|
133
134
|
sessionActivities: {
|
|
134
135
|
...e.sessionActivities,
|
|
135
136
|
[n]: i
|
|
@@ -162,9 +163,9 @@ var ae = a()((e) => ({
|
|
|
162
163
|
}, s = {
|
|
163
164
|
...e.sessionActivities,
|
|
164
165
|
[i]: o
|
|
165
|
-
}, c =
|
|
166
|
+
}, c = y(e.sessionStreaming, i);
|
|
166
167
|
return {
|
|
167
|
-
isStreaming:
|
|
168
|
+
isStreaming: _(c),
|
|
168
169
|
...r ? {
|
|
169
170
|
activity: o,
|
|
170
171
|
stopRequested: !0
|
|
@@ -177,19 +178,19 @@ var ae = a()((e) => ({
|
|
|
177
178
|
clearSessionActivity: (t) => e((e) => {
|
|
178
179
|
let n = String(t || "");
|
|
179
180
|
if (!n) return {};
|
|
180
|
-
let { [n]: r, ...i } = e.sessionActivities, a =
|
|
181
|
+
let { [n]: r, ...i } = e.sessionActivities, a = y(e.sessionStreaming, n);
|
|
181
182
|
return {
|
|
182
183
|
sessionActivities: i,
|
|
183
184
|
sessionStreaming: a,
|
|
184
|
-
isStreaming:
|
|
185
|
+
isStreaming: _(a),
|
|
185
186
|
activity: e.activity === r ? null : e.activity
|
|
186
187
|
};
|
|
187
188
|
}),
|
|
188
189
|
applyRuntimeItemOperations: (t) => {
|
|
189
|
-
|
|
190
|
+
v.applyAll(t), e({ runtimeItems: v.snapshot() });
|
|
190
191
|
},
|
|
191
192
|
resetRun: () => {
|
|
192
|
-
|
|
193
|
+
v = new r(), e({
|
|
193
194
|
isStreaming: !1,
|
|
194
195
|
currentRunId: "",
|
|
195
196
|
stopRequested: !1,
|
|
@@ -198,13 +199,13 @@ var ae = a()((e) => ({
|
|
|
198
199
|
sessionStreaming: {},
|
|
199
200
|
lastSeqId: 0,
|
|
200
201
|
activeInvocationId: "",
|
|
201
|
-
runtimeItems:
|
|
202
|
+
runtimeItems: oe
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
}));
|
|
205
206
|
//#endregion
|
|
206
207
|
//#region src/stores/model.ts
|
|
207
|
-
function
|
|
208
|
+
function ce(e, t) {
|
|
208
209
|
let n = /* @__PURE__ */ new Map();
|
|
209
210
|
for (let t of e) t?.id && n.set(t.id, t);
|
|
210
211
|
for (let e of t) e?.id && n.set(e.id, {
|
|
@@ -213,13 +214,13 @@ function se(e, t) {
|
|
|
213
214
|
});
|
|
214
215
|
return Array.from(n.values()).sort((e, t) => e.id.localeCompare(t.id));
|
|
215
216
|
}
|
|
216
|
-
var
|
|
217
|
+
var le = s()((e) => ({
|
|
217
218
|
availableModels: [],
|
|
218
219
|
selectedModel: "",
|
|
219
220
|
modelSource: "",
|
|
220
221
|
modelCatalogLoaded: !1,
|
|
221
222
|
thinkingMode: "auto",
|
|
222
|
-
upsertModels: (t) => e((e) => ({ availableModels:
|
|
223
|
+
upsertModels: (t) => e((e) => ({ availableModels: ce(e.availableModels, t) })),
|
|
223
224
|
setSelectedModel: (t) => e({ selectedModel: t }),
|
|
224
225
|
setModelSource: (t) => e({ modelSource: t }),
|
|
225
226
|
setModelCatalogLoaded: (t) => e({ modelCatalogLoaded: t }),
|
|
@@ -230,7 +231,7 @@ var v = a()((e) => ({
|
|
|
230
231
|
modelSource: "",
|
|
231
232
|
modelCatalogLoaded: !1
|
|
232
233
|
})
|
|
233
|
-
})),
|
|
234
|
+
})), b = new class {
|
|
234
235
|
initialized = !1;
|
|
235
236
|
scope;
|
|
236
237
|
blocked = !1;
|
|
@@ -250,7 +251,7 @@ var v = a()((e) => ({
|
|
|
250
251
|
}();
|
|
251
252
|
//#endregion
|
|
252
253
|
//#region src/utils/session-pagination.js
|
|
253
|
-
function
|
|
254
|
+
function x(e = /* @__PURE__ */ new Set(), t = []) {
|
|
254
255
|
let n = new Set(e);
|
|
255
256
|
for (let e of t) {
|
|
256
257
|
let t = Number(e);
|
|
@@ -258,17 +259,17 @@ function b(e = /* @__PURE__ */ new Set(), t = []) {
|
|
|
258
259
|
}
|
|
259
260
|
return new Set(Array.from(n).sort((e, t) => e - t));
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
+
function ue({ sessionsLength: e = 0, total: t = 0, page: n = 0, pageSize: r = 30, loadedPages: i = /* @__PURE__ */ new Set() } = {}) {
|
|
262
263
|
let a = Math.max(0, Number(t) || 0), o = Math.max(0, Number(e) || 0);
|
|
263
264
|
return {
|
|
264
265
|
total: a,
|
|
265
266
|
page: Math.max(0, Number(n) || 0),
|
|
266
267
|
pageSize: Math.max(1, Number(r) || 30),
|
|
267
|
-
loadedPages:
|
|
268
|
+
loadedPages: x(i),
|
|
268
269
|
hasMore: o < a
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
+
function de({ total: e = 0, pageSize: t = 30, loadedPages: n = /* @__PURE__ */ new Set() } = {}) {
|
|
272
273
|
let r = Math.max(0, Number(e) || 0), i = Math.max(1, Number(t) || 30);
|
|
273
274
|
if (r <= 0) return null;
|
|
274
275
|
let a = Math.ceil(r / i);
|
|
@@ -277,7 +278,7 @@ function ce({ total: e = 0, pageSize: t = 30, loadedPages: n = /* @__PURE__ */ n
|
|
|
277
278
|
}
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region src/stores/session.ts
|
|
280
|
-
function
|
|
281
|
+
function fe(e) {
|
|
281
282
|
let t = e.UpdatedAt;
|
|
282
283
|
if (typeof t == "string") {
|
|
283
284
|
let e = Date.parse(t);
|
|
@@ -285,37 +286,37 @@ function S(e) {
|
|
|
285
286
|
}
|
|
286
287
|
return typeof t == "number" && Number.isFinite(t) ? t > 1e11 ? t : t * 1e3 : 0;
|
|
287
288
|
}
|
|
288
|
-
var
|
|
289
|
-
function
|
|
289
|
+
var pe = "ksadk.pinnedSessionIds";
|
|
290
|
+
function me() {
|
|
290
291
|
try {
|
|
291
|
-
let e = globalThis.localStorage?.getItem(
|
|
292
|
+
let e = globalThis.localStorage?.getItem(b.key(pe)), t = e ? JSON.parse(e) : [];
|
|
292
293
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
293
294
|
} catch {
|
|
294
295
|
return [];
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
|
-
function
|
|
298
|
-
if (
|
|
299
|
-
globalThis.localStorage?.setItem(
|
|
298
|
+
function he(e) {
|
|
299
|
+
if (b.writable) try {
|
|
300
|
+
globalThis.localStorage?.setItem(b.key(pe), JSON.stringify(e));
|
|
300
301
|
} catch {}
|
|
301
302
|
}
|
|
302
|
-
function
|
|
303
|
+
function S(e, t) {
|
|
303
304
|
let n = new Set(t);
|
|
304
305
|
return e.slice().sort((e, t) => {
|
|
305
306
|
let r = +!!n.has(e.SessionId), i = +!!n.has(t.SessionId);
|
|
306
|
-
return r === i ?
|
|
307
|
+
return r === i ? fe(t) - fe(e) : i - r;
|
|
307
308
|
});
|
|
308
309
|
}
|
|
309
|
-
function
|
|
310
|
+
function ge(e, t, n) {
|
|
310
311
|
let r = /* @__PURE__ */ new Map();
|
|
311
312
|
for (let t of e) t?.SessionId && r.set(t.SessionId, t);
|
|
312
313
|
for (let e of t) e?.SessionId && r.set(e.SessionId, {
|
|
313
314
|
...r.get(e.SessionId) || {},
|
|
314
315
|
...e
|
|
315
316
|
});
|
|
316
|
-
return
|
|
317
|
+
return S(Array.from(r.values()), n);
|
|
317
318
|
}
|
|
318
|
-
var
|
|
319
|
+
var _e = s()((e) => ({
|
|
319
320
|
sessions: [],
|
|
320
321
|
currentSessionId: null,
|
|
321
322
|
sessionsAgentId: "",
|
|
@@ -326,12 +327,12 @@ var de = a()((e) => ({
|
|
|
326
327
|
loadedPages: /* @__PURE__ */ new Set(),
|
|
327
328
|
hasMoreSessions: !1,
|
|
328
329
|
isLoadingSessions: !0,
|
|
329
|
-
pinnedSessionIds:
|
|
330
|
+
pinnedSessionIds: me(),
|
|
330
331
|
messageHistory: {},
|
|
331
|
-
setSessions: (t) => e((e) => ({ sessions:
|
|
332
|
+
setSessions: (t) => e((e) => ({ sessions: S(t, e.pinnedSessionIds) })),
|
|
332
333
|
setCurrentSessionId: (t) => e({ currentSessionId: t }),
|
|
333
334
|
upsertSessions: (t, n) => e((e) => {
|
|
334
|
-
let r =
|
|
335
|
+
let r = ge(n?.replace ? [] : e.sessions, t, e.pinnedSessionIds), i = n?.page ?? e.sessionsPage, a = n?.pageSize ?? e.sessionsPageSize, o = n?.total ?? Math.max(e.sessionsTotal, r.length), s = n?.replace ? x(/* @__PURE__ */ new Set(), [i]) : x(e.loadedPages, [i]), c = ue({
|
|
335
336
|
sessionsLength: r.length,
|
|
336
337
|
total: o,
|
|
337
338
|
page: i,
|
|
@@ -353,7 +354,7 @@ var de = a()((e) => ({
|
|
|
353
354
|
return {
|
|
354
355
|
sessions: n,
|
|
355
356
|
sessionsTotal: r,
|
|
356
|
-
hasMoreSessions:
|
|
357
|
+
hasMoreSessions: ue({
|
|
357
358
|
sessionsLength: n.length,
|
|
358
359
|
total: r,
|
|
359
360
|
page: e.sessionsPage,
|
|
@@ -378,9 +379,9 @@ var de = a()((e) => ({
|
|
|
378
379
|
let n = new Set(e.pinnedSessionIds);
|
|
379
380
|
n.has(t) ? n.delete(t) : n.add(t);
|
|
380
381
|
let r = Array.from(n);
|
|
381
|
-
return
|
|
382
|
+
return he(r), {
|
|
382
383
|
pinnedSessionIds: r,
|
|
383
|
-
sessions:
|
|
384
|
+
sessions: S(e.sessions, r)
|
|
384
385
|
};
|
|
385
386
|
}),
|
|
386
387
|
setSessionMessageHistory: (t, n) => e((e) => ({ messageHistory: {
|
|
@@ -422,7 +423,91 @@ var de = a()((e) => ({
|
|
|
422
423
|
let n = { ...e.messageHistory };
|
|
423
424
|
return delete n[t], { messageHistory: n };
|
|
424
425
|
})
|
|
425
|
-
})),
|
|
426
|
+
})), ve = "ksadk.web.execution-permission", ye = [
|
|
427
|
+
"read-only",
|
|
428
|
+
"workspace-write",
|
|
429
|
+
"danger-full-access"
|
|
430
|
+
], be = {
|
|
431
|
+
"read-only": "只读",
|
|
432
|
+
"workspace-write": "工作区可写",
|
|
433
|
+
"danger-full-access": "完全访问"
|
|
434
|
+
}, xe = {
|
|
435
|
+
"read-only": "只读",
|
|
436
|
+
"workspace-write": "工作区可写",
|
|
437
|
+
"danger-full-access": "完全访问"
|
|
438
|
+
}, Se = {
|
|
439
|
+
"read-only": "只读文件与命令",
|
|
440
|
+
"workspace-write": "可修改工作区文件",
|
|
441
|
+
"danger-full-access": "不再限制文件与命令"
|
|
442
|
+
};
|
|
443
|
+
function C(e) {
|
|
444
|
+
if (!e || !Array.isArray(e.Modes)) return [];
|
|
445
|
+
let t = e.Modes.filter((e) => ye.includes(e));
|
|
446
|
+
return [...new Set(t)];
|
|
447
|
+
}
|
|
448
|
+
function Ce(e, t) {
|
|
449
|
+
let n = C(e);
|
|
450
|
+
if (n.length === 0) return;
|
|
451
|
+
if (t && n.includes(t)) return t;
|
|
452
|
+
let r = e?.DefaultMode;
|
|
453
|
+
return r && n.includes(r) ? r : n[0];
|
|
454
|
+
}
|
|
455
|
+
function we(e) {
|
|
456
|
+
return e && ye.includes(e) ? { permission_mode: e } : {};
|
|
457
|
+
}
|
|
458
|
+
function w(e) {
|
|
459
|
+
return b.key(`${ve}.${e}`);
|
|
460
|
+
}
|
|
461
|
+
function Te(e) {
|
|
462
|
+
try {
|
|
463
|
+
return globalThis.localStorage?.getItem(w(e)) ?? null;
|
|
464
|
+
} catch {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
function Ee(e, t) {
|
|
469
|
+
if (b.writable) try {
|
|
470
|
+
t ? globalThis.localStorage?.setItem(w(e), t) : globalThis.localStorage?.removeItem(w(e));
|
|
471
|
+
} catch {}
|
|
472
|
+
}
|
|
473
|
+
var De = s()((e, t) => ({
|
|
474
|
+
byAgent: {},
|
|
475
|
+
policies: {},
|
|
476
|
+
scopes: {},
|
|
477
|
+
configure: (n, r) => {
|
|
478
|
+
if (!n || b.blocked) return;
|
|
479
|
+
let i = w(n), a = Te(n), o = t().scopes[n] === i ? t().byAgent[n] : void 0, s = {
|
|
480
|
+
Modes: C(r),
|
|
481
|
+
DefaultMode: r?.DefaultMode
|
|
482
|
+
}, c = Ce(s, o ?? a);
|
|
483
|
+
c !== a && Ee(n, c ?? null), e((e) => ({
|
|
484
|
+
byAgent: {
|
|
485
|
+
...e.byAgent,
|
|
486
|
+
[n]: c
|
|
487
|
+
},
|
|
488
|
+
policies: {
|
|
489
|
+
...e.policies,
|
|
490
|
+
[n]: s
|
|
491
|
+
},
|
|
492
|
+
scopes: {
|
|
493
|
+
...e.scopes,
|
|
494
|
+
[n]: i
|
|
495
|
+
}
|
|
496
|
+
}));
|
|
497
|
+
},
|
|
498
|
+
select: (n, r) => {
|
|
499
|
+
!n || b.blocked || t().scopes[n] !== w(n) || !C(t().policies[n]).includes(r) || (Ee(n, r), e((e) => ({ byAgent: {
|
|
500
|
+
...e.byAgent,
|
|
501
|
+
[n]: r
|
|
502
|
+
} })));
|
|
503
|
+
},
|
|
504
|
+
modeFor: (e) => {
|
|
505
|
+
let n = t();
|
|
506
|
+
if (b.blocked || n.scopes[e] !== w(e)) return;
|
|
507
|
+
let r = n.byAgent[e];
|
|
508
|
+
return r && C(n.policies[e]).includes(r) ? r : void 0;
|
|
509
|
+
}
|
|
510
|
+
})), Oe = s()((t, n) => ({
|
|
426
511
|
agentId: "default-agent",
|
|
427
512
|
agentName: "Agent",
|
|
428
513
|
agentFramework: "",
|
|
@@ -435,7 +520,9 @@ var de = a()((e) => ({
|
|
|
435
520
|
setAgentId: (e) => t({ agentId: e }),
|
|
436
521
|
setAgentName: (e) => t({ agentName: e }),
|
|
437
522
|
setAgentFramework: (e) => t({ agentFramework: e }),
|
|
438
|
-
setCapabilities: (e) =>
|
|
523
|
+
setCapabilities: (e) => {
|
|
524
|
+
De.getState().configure(n().agentId, e.ExecutionPolicy), t({ capabilities: e });
|
|
525
|
+
},
|
|
439
526
|
setApiFormats: (e) => t({ apiFormats: e }),
|
|
440
527
|
setAccessMode: (e) => t({ accessMode: e }),
|
|
441
528
|
setWorkspaceFiles: (e) => t({ workspaceFiles: e }),
|
|
@@ -443,7 +530,1256 @@ var de = a()((e) => ({
|
|
|
443
530
|
status: e,
|
|
444
531
|
errorMessage: n
|
|
445
532
|
})
|
|
446
|
-
})),
|
|
533
|
+
})), T = {
|
|
534
|
+
schema: "mcp.authorization/v1",
|
|
535
|
+
digest: "b9bc3b0c286a3b21b8a5dfee00ad83eaa28aa72e418140502c58fc2e0eced938"
|
|
536
|
+
}, ke = new Set([
|
|
537
|
+
"approval",
|
|
538
|
+
"structured_input",
|
|
539
|
+
"plan_review",
|
|
540
|
+
"custom"
|
|
541
|
+
]), Ae = new Set([
|
|
542
|
+
"pending",
|
|
543
|
+
"resolving",
|
|
544
|
+
"failed",
|
|
545
|
+
"resolved",
|
|
546
|
+
"cancelled",
|
|
547
|
+
"expired"
|
|
548
|
+
]), je = new Set([
|
|
549
|
+
"approved",
|
|
550
|
+
"rejected",
|
|
551
|
+
"submitted",
|
|
552
|
+
"cancelled",
|
|
553
|
+
"expired"
|
|
554
|
+
]);
|
|
555
|
+
function E(e) {
|
|
556
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
557
|
+
}
|
|
558
|
+
function D(e) {
|
|
559
|
+
return typeof e == "string" && e.length > 0 ? e : null;
|
|
560
|
+
}
|
|
561
|
+
var Me = "人工确认", Ne = "本次运行需要人工处理后才能继续。", Pe = "补充信息", Fe = "请填写后提交,Agent 将继续当前任务。";
|
|
562
|
+
function O(e) {
|
|
563
|
+
let t = String(e.kind || "approval"), r = String(e.status || "pending"), i = String(e.outcome || ""), a = E(e.presentation), o = a ? E(a.a2ui) : null, s;
|
|
564
|
+
if (r === "resolved" && Object.hasOwn(e, "response")) try {
|
|
565
|
+
s = { response: n(e.response) };
|
|
566
|
+
} catch {}
|
|
567
|
+
return {
|
|
568
|
+
interactionId: e.interactionId,
|
|
569
|
+
sessionId: e.sessionId,
|
|
570
|
+
runId: D(e.runId),
|
|
571
|
+
kind: ke.has(t) ? t : "custom",
|
|
572
|
+
title: typeof e.title == "string" && e.title ? e.title : t === "structured_input" ? Pe : Me,
|
|
573
|
+
message: typeof e.message == "string" && e.message ? e.message : t === "structured_input" ? Fe : Ne,
|
|
574
|
+
requestSchema: E(e.requestSchema),
|
|
575
|
+
presentation: o ? { a2ui: {
|
|
576
|
+
wireVersion: String(o.wire_version ?? o.wireVersion ?? ""),
|
|
577
|
+
catalogDigest: String(o.catalog_digest ?? o.catalogDigest ?? ""),
|
|
578
|
+
messages: Array.isArray(o.messages) ? o.messages.filter((e) => typeof e == "object") : []
|
|
579
|
+
} } : null,
|
|
580
|
+
status: Ae.has(r) ? r : "pending",
|
|
581
|
+
revision: Number.isFinite(Number(e.revision)) && Number(e.revision) > 0 ? Number(e.revision) : 1,
|
|
582
|
+
createdAt: D(e.createdAt) || (/* @__PURE__ */ new Date()).toISOString(),
|
|
583
|
+
expiresAt: D(e.expiresAt),
|
|
584
|
+
resolvedAt: D(e.resolvedAt),
|
|
585
|
+
actor: D(e.actor),
|
|
586
|
+
outcome: je.has(i) ? i : null,
|
|
587
|
+
responseSummary: D(e.responseSummary),
|
|
588
|
+
...s,
|
|
589
|
+
source: e.source,
|
|
590
|
+
extensions: e.extensions || {}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/core/mcp-authorization/normalize.ts
|
|
595
|
+
function Ie(e) {
|
|
596
|
+
if (!e || typeof e != "object") return !1;
|
|
597
|
+
let t = e;
|
|
598
|
+
return t.schema === T.schema && typeof t.wait_id == "string" && t.wait_id.length > 0 && typeof t.run_id == "string" && t.run_id.length > 0 && typeof t.revision == "number" && Number.isSafeInteger(t.revision) && t.revision >= 0;
|
|
599
|
+
}
|
|
600
|
+
function Le(e) {
|
|
601
|
+
return Array.isArray(e) && e.every((e) => typeof e == "string");
|
|
602
|
+
}
|
|
603
|
+
function Re(e) {
|
|
604
|
+
return Ie(e) && typeof e.capability_digest == "string" && typeof e.config_id == "string" && typeof e.status == "string" && typeof e.deadline == "number" && Number.isFinite(e.deadline) && typeof e.requires_resume == "boolean" && (e.display_name === void 0 || typeof e.display_name == "string") && (e.error == null || typeof e.error == "string") && Le(e.scopes) && Le(e.allowed_actions);
|
|
605
|
+
}
|
|
606
|
+
function ze(e, t, n) {
|
|
607
|
+
if (!Ie(e) || n && e.run_id !== n) return null;
|
|
608
|
+
let r = Re(e) && e.capability_digest === T.digest ? e : {
|
|
609
|
+
schema: e.schema,
|
|
610
|
+
wait_id: e.wait_id,
|
|
611
|
+
run_id: e.run_id,
|
|
612
|
+
revision: e.revision,
|
|
613
|
+
status: "unsupported"
|
|
614
|
+
};
|
|
615
|
+
return O({
|
|
616
|
+
interactionId: r.wait_id,
|
|
617
|
+
sessionId: t,
|
|
618
|
+
runId: r.run_id,
|
|
619
|
+
kind: "custom",
|
|
620
|
+
title: "MCP 服务授权",
|
|
621
|
+
message: "授权完成后将继续当前任务。",
|
|
622
|
+
revision: r.revision,
|
|
623
|
+
source: "interaction_v1",
|
|
624
|
+
status: r.status === "resumed" ? "resolved" : [
|
|
625
|
+
"cancelled",
|
|
626
|
+
"expired",
|
|
627
|
+
"failed"
|
|
628
|
+
].includes(r.status) ? r.status : "pending",
|
|
629
|
+
extensions: { mcpAuthorization: r }
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/core/interaction/types.ts
|
|
634
|
+
var Be = new Set([
|
|
635
|
+
"resolved",
|
|
636
|
+
"cancelled",
|
|
637
|
+
"expired"
|
|
638
|
+
]);
|
|
639
|
+
function k(e) {
|
|
640
|
+
return Be.has(e);
|
|
641
|
+
}
|
|
642
|
+
function Ve(e, t) {
|
|
643
|
+
return `interaction:${e}:revision-${t}`;
|
|
644
|
+
}
|
|
645
|
+
function He(e, t) {
|
|
646
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return e === "cancel" ? "已取消" : "已提交";
|
|
647
|
+
let n = t.approved;
|
|
648
|
+
if (typeof n == "boolean") return n ? "已同意" : "已拒绝";
|
|
649
|
+
let r = Object.keys(t);
|
|
650
|
+
return r.length === 0 ? e === "approve" ? "已同意" : e === "reject" ? "已拒绝" : e === "cancel" ? "已取消" : "已提交" : `${e}(${r.slice(0, 3).map((e) => {
|
|
651
|
+
let n = t[e];
|
|
652
|
+
return `${e}=${typeof n == "string" ? n.length > 24 ? `${n.slice(0, 24)}…` : n : typeof n == "object" && n ? "[object]" : String(n)}`;
|
|
653
|
+
}).join(", ")})`;
|
|
654
|
+
}
|
|
655
|
+
//#endregion
|
|
656
|
+
//#region src/core/interaction/store.ts
|
|
657
|
+
var A = class {
|
|
658
|
+
records = /* @__PURE__ */ new Map();
|
|
659
|
+
terminalRuns = /* @__PURE__ */ new Set();
|
|
660
|
+
rejectedCommands = /* @__PURE__ */ new Map();
|
|
661
|
+
listeners = /* @__PURE__ */ new Set();
|
|
662
|
+
key(e, t) {
|
|
663
|
+
return `${e}\u0000${t}`;
|
|
664
|
+
}
|
|
665
|
+
runKey(e, t) {
|
|
666
|
+
return `${e}\u0000${t}`;
|
|
667
|
+
}
|
|
668
|
+
subscribe(e) {
|
|
669
|
+
return this.listeners.add(e), () => {
|
|
670
|
+
this.listeners.delete(e);
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
emit(e) {
|
|
674
|
+
for (let t of this.listeners) t(e);
|
|
675
|
+
}
|
|
676
|
+
get(e, t) {
|
|
677
|
+
return this.records.get(this.key(e, t)) || null;
|
|
678
|
+
}
|
|
679
|
+
listPending(e) {
|
|
680
|
+
return this.listAll(e).filter((e) => e.status === "pending");
|
|
681
|
+
}
|
|
682
|
+
listAll(e) {
|
|
683
|
+
return this.all().filter((t) => t.sessionId === e);
|
|
684
|
+
}
|
|
685
|
+
all() {
|
|
686
|
+
return [...this.records.values()].sort((e, t) => String(e.createdAt).localeCompare(String(t.createdAt)));
|
|
687
|
+
}
|
|
688
|
+
upsert(e) {
|
|
689
|
+
let t = this.get(e.sessionId, e.interactionId);
|
|
690
|
+
e.runId && !k(e.status) && !k(t?.status ?? "pending") && this.terminalRuns.has(this.runKey(e.sessionId, e.runId)) && (e = {
|
|
691
|
+
...e,
|
|
692
|
+
status: "expired",
|
|
693
|
+
outcome: "expired",
|
|
694
|
+
resolvedAt: e.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
695
|
+
responseSummary: e.responseSummary ?? "运行已结束"
|
|
696
|
+
});
|
|
697
|
+
let n, r;
|
|
698
|
+
return t ? k(t.status) && !k(e.status) ? (n = {
|
|
699
|
+
...t,
|
|
700
|
+
title: ["人工确认", "补充信息"].includes(t.title) ? e.title : t.title,
|
|
701
|
+
message: ["本次运行需要人工处理后才能继续。", "请填写后提交,Agent 将继续当前任务。"].includes(t.message) ? e.message : t.message,
|
|
702
|
+
kind: t.kind === "approval" && !t.requestSchema ? e.kind : t.kind,
|
|
703
|
+
requestSchema: t.requestSchema ?? e.requestSchema,
|
|
704
|
+
presentation: t.presentation ?? e.presentation
|
|
705
|
+
}, r = {
|
|
706
|
+
type: "interaction_updated",
|
|
707
|
+
interaction: n
|
|
708
|
+
}) : e.revision < t.revision || e.revision === t.revision && k(t.status) && !k(e.status) || t.status === "failed" && t.extensions.rejected_command_id && e.revision === t.revision && !k(e.status) || t.status === "resolving" && !k(e.status) ? (n = t, r = {
|
|
709
|
+
type: "interaction_updated",
|
|
710
|
+
interaction: n
|
|
711
|
+
}) : k(e.status) ? (n = {
|
|
712
|
+
...t,
|
|
713
|
+
...e,
|
|
714
|
+
title: t.title || e.title,
|
|
715
|
+
kind: t.kind || e.kind,
|
|
716
|
+
message: t.message || e.message,
|
|
717
|
+
runId: e.runId ?? t.runId,
|
|
718
|
+
requestSchema: t.requestSchema ?? e.requestSchema,
|
|
719
|
+
presentation: t.presentation ?? e.presentation,
|
|
720
|
+
actor: e.actor ?? t.actor,
|
|
721
|
+
outcome: e.outcome ?? t.outcome,
|
|
722
|
+
resolvedAt: e.resolvedAt ?? t.resolvedAt,
|
|
723
|
+
responseSummary: e.responseSummary ?? t.responseSummary,
|
|
724
|
+
...Object.hasOwn(t, "response") ? { response: t.response } : {}
|
|
725
|
+
}, r = {
|
|
726
|
+
type: "interaction_resolved",
|
|
727
|
+
interaction: n
|
|
728
|
+
}) : (n = {
|
|
729
|
+
...t,
|
|
730
|
+
...e
|
|
731
|
+
}, r = {
|
|
732
|
+
type: "interaction_updated",
|
|
733
|
+
interaction: n
|
|
734
|
+
}) : (n = e, r = {
|
|
735
|
+
type: "interaction_requested",
|
|
736
|
+
interaction: n
|
|
737
|
+
}), this.records.set(this.key(n.sessionId, n.interactionId), n), this.emit(r), r;
|
|
738
|
+
}
|
|
739
|
+
markResolving(e, t) {
|
|
740
|
+
let n = this.get(e, t);
|
|
741
|
+
if (!n || !["pending", "failed"].includes(n.status)) return;
|
|
742
|
+
let r = { ...n.extensions };
|
|
743
|
+
delete r.submit_error, delete r.submit_command_id, this.records.set(this.key(e, t), {
|
|
744
|
+
...n,
|
|
745
|
+
status: "resolving",
|
|
746
|
+
extensions: r
|
|
747
|
+
}), this.emit({
|
|
748
|
+
type: "interaction_updated",
|
|
749
|
+
interaction: this.get(e, t)
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
resolveLocally(e, t, n) {
|
|
753
|
+
let r = this.get(e, t);
|
|
754
|
+
if (!r) return;
|
|
755
|
+
let i = {
|
|
756
|
+
...r,
|
|
757
|
+
...n,
|
|
758
|
+
resolvedAt: n.resolvedAt ?? r.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
759
|
+
revision: n.revision ?? r.revision
|
|
760
|
+
};
|
|
761
|
+
this.records.set(this.key(e, t), i), this.emit({
|
|
762
|
+
type: "interaction_resolved",
|
|
763
|
+
interaction: i
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
recordCommand(e, t, n) {
|
|
767
|
+
let r = this.get(e, t);
|
|
768
|
+
if (!r || !n || k(r.status)) return;
|
|
769
|
+
this.records.set(this.key(e, t), {
|
|
770
|
+
...r,
|
|
771
|
+
extensions: {
|
|
772
|
+
...r.extensions,
|
|
773
|
+
submit_command_id: n
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
let i = this.rejectedCommands.get(this.key(e, n));
|
|
777
|
+
i && this.rejectCommand(e, n, i);
|
|
778
|
+
}
|
|
779
|
+
rejectCommand(e, t, n) {
|
|
780
|
+
if (!(!e || !t)) {
|
|
781
|
+
this.rejectedCommands.set(this.key(e, t), n);
|
|
782
|
+
for (let r of this.listAll(e)) {
|
|
783
|
+
if (r.extensions.submit_command_id !== t) continue;
|
|
784
|
+
this.markFailed(e, r.interactionId, {
|
|
785
|
+
code: n,
|
|
786
|
+
message: `提交未执行(${n}),请重试`,
|
|
787
|
+
retryable: !0
|
|
788
|
+
});
|
|
789
|
+
let i = this.get(e, r.interactionId);
|
|
790
|
+
i?.status === "failed" && this.records.set(this.key(e, r.interactionId), {
|
|
791
|
+
...i,
|
|
792
|
+
extensions: {
|
|
793
|
+
...i.extensions,
|
|
794
|
+
rejected_command_id: t
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
recordIdempotencyKey(e, t, n) {
|
|
801
|
+
let r = this.get(e, t);
|
|
802
|
+
if (!r) return;
|
|
803
|
+
let i = {
|
|
804
|
+
...r,
|
|
805
|
+
extensions: {
|
|
806
|
+
...r.extensions,
|
|
807
|
+
idempotency_key: n
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
this.records.set(this.key(e, t), i), this.emit({
|
|
811
|
+
type: "interaction_updated",
|
|
812
|
+
interaction: i
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
markFailed(e, t, n) {
|
|
816
|
+
let r = this.get(e, t);
|
|
817
|
+
if (!r || k(r.status)) return;
|
|
818
|
+
let i = {
|
|
819
|
+
...r,
|
|
820
|
+
status: "failed",
|
|
821
|
+
extensions: {
|
|
822
|
+
...r.extensions,
|
|
823
|
+
submit_error: n
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
this.records.set(this.key(e, t), i), this.emit({
|
|
827
|
+
type: "interaction_updated",
|
|
828
|
+
interaction: i
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
revertToPending(e, t) {
|
|
832
|
+
let n = this.get(e, t);
|
|
833
|
+
if (!n || n.status !== "resolving") return;
|
|
834
|
+
let r = {
|
|
835
|
+
...n,
|
|
836
|
+
status: "pending"
|
|
837
|
+
};
|
|
838
|
+
this.records.set(this.key(e, t), r), this.emit({
|
|
839
|
+
type: "interaction_updated",
|
|
840
|
+
interaction: r
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
markRunTerminal(e, t) {
|
|
844
|
+
if (!(!e || !t)) {
|
|
845
|
+
this.terminalRuns.add(this.runKey(e, t));
|
|
846
|
+
for (let n of this.listAll(e)) {
|
|
847
|
+
if (n.runId !== t || k(n.status)) continue;
|
|
848
|
+
let r = {
|
|
849
|
+
...n,
|
|
850
|
+
status: "expired",
|
|
851
|
+
outcome: "expired",
|
|
852
|
+
resolvedAt: n.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
853
|
+
responseSummary: n.responseSummary ?? "运行已结束"
|
|
854
|
+
};
|
|
855
|
+
this.records.set(this.key(e, n.interactionId), r), this.emit({
|
|
856
|
+
type: "interaction_resolved",
|
|
857
|
+
interaction: r
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
markSessionTerminal(e) {
|
|
863
|
+
if (!e) return;
|
|
864
|
+
let t = new Set(this.listAll(e).filter((e) => !k(e.status)).map((e) => e.runId).filter((e) => !!e));
|
|
865
|
+
for (let n of t) this.markRunTerminal(e, n);
|
|
866
|
+
for (let t of this.listAll(e)) {
|
|
867
|
+
if (t.runId || k(t.status)) continue;
|
|
868
|
+
let n = {
|
|
869
|
+
...t,
|
|
870
|
+
status: "expired",
|
|
871
|
+
outcome: "expired",
|
|
872
|
+
resolvedAt: t.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
873
|
+
responseSummary: t.responseSummary ?? "运行已结束"
|
|
874
|
+
};
|
|
875
|
+
this.records.set(this.key(e, t.interactionId), n), this.emit({
|
|
876
|
+
type: "interaction_resolved",
|
|
877
|
+
interaction: n
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
remove(e, t) {
|
|
882
|
+
let n = this.key(e, t);
|
|
883
|
+
this.records.has(n) && (this.records.delete(n), this.emit({
|
|
884
|
+
type: "interaction_removed",
|
|
885
|
+
interactionId: t
|
|
886
|
+
}));
|
|
887
|
+
}
|
|
888
|
+
clearSession(e) {
|
|
889
|
+
for (let t of this.listAll(e)) this.remove(e, t.interactionId);
|
|
890
|
+
let t = `${e}\u0000`;
|
|
891
|
+
for (let e of this.rejectedCommands.keys()) e.startsWith(t) && this.rejectedCommands.delete(e);
|
|
892
|
+
for (let e of this.terminalRuns) e.startsWith(t) && this.terminalRuns.delete(e);
|
|
893
|
+
}
|
|
894
|
+
}, j = class extends Error {
|
|
895
|
+
constructor(e) {
|
|
896
|
+
super(e), this.name = "ContractMismatchError";
|
|
897
|
+
}
|
|
898
|
+
}, Ue = new Set([
|
|
899
|
+
"schema_version",
|
|
900
|
+
"command_id",
|
|
901
|
+
"status",
|
|
902
|
+
"message_id",
|
|
903
|
+
"run_id",
|
|
904
|
+
"accepted_seq",
|
|
905
|
+
"error"
|
|
906
|
+
]), We = l.object({
|
|
907
|
+
code: l.string().min(1),
|
|
908
|
+
message: l.string(),
|
|
909
|
+
retryable: l.boolean(),
|
|
910
|
+
details: l.record(l.string(), l.unknown()).optional()
|
|
911
|
+
});
|
|
912
|
+
function Ge(e) {
|
|
913
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return M(e);
|
|
914
|
+
let t = e;
|
|
915
|
+
if ("schema_version" in t || !("SchemaVersion" in t)) return M(e);
|
|
916
|
+
let n = {
|
|
917
|
+
SchemaVersion: "schema_version",
|
|
918
|
+
CommandId: "command_id",
|
|
919
|
+
Status: "status",
|
|
920
|
+
MessageId: "message_id",
|
|
921
|
+
RunId: "run_id",
|
|
922
|
+
AcceptedSeq: "accepted_seq",
|
|
923
|
+
Error: "error"
|
|
924
|
+
};
|
|
925
|
+
return M(Object.fromEntries(Object.entries(t).map(([e, t]) => [n[e] ?? e, t])));
|
|
926
|
+
}
|
|
927
|
+
function M(e) {
|
|
928
|
+
let t = l.object({
|
|
929
|
+
schema_version: l.literal(1),
|
|
930
|
+
command_id: l.string().min(1),
|
|
931
|
+
status: l.enum([
|
|
932
|
+
"accepted",
|
|
933
|
+
"duplicate",
|
|
934
|
+
"rejected",
|
|
935
|
+
"unsupported",
|
|
936
|
+
"queue_full",
|
|
937
|
+
"persistence_uncertain"
|
|
938
|
+
]),
|
|
939
|
+
message_id: l.string().min(1).nullable().optional(),
|
|
940
|
+
run_id: l.string().min(1).nullable().optional(),
|
|
941
|
+
accepted_seq: l.number().int().min(0).nullable().optional(),
|
|
942
|
+
error: We.nullable().optional()
|
|
943
|
+
}).passthrough().safeParse(e);
|
|
944
|
+
if (!t.success) throw new j(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);
|
|
945
|
+
let n = t.data;
|
|
946
|
+
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`);
|
|
947
|
+
let r = {};
|
|
948
|
+
for (let [e, t] of Object.entries(n)) Ue.has(e) || (r[e] = t);
|
|
949
|
+
let i = n.error ? {
|
|
950
|
+
...n.error,
|
|
951
|
+
extensions: {}
|
|
952
|
+
} : null;
|
|
953
|
+
return {
|
|
954
|
+
schema_version: 1,
|
|
955
|
+
command_id: n.command_id,
|
|
956
|
+
status: n.status,
|
|
957
|
+
message_id: n.message_id ?? null,
|
|
958
|
+
run_id: n.run_id ?? null,
|
|
959
|
+
accepted_seq: n.accepted_seq ?? null,
|
|
960
|
+
error: i,
|
|
961
|
+
extensions: r
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function Ke(e) {
|
|
965
|
+
try {
|
|
966
|
+
return t(e);
|
|
967
|
+
} catch (e) {
|
|
968
|
+
throw new j(`RuntimeCapabilityMatrix/v1 mismatch: ${e instanceof Error ? e.message : String(e)}`);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
var qe = new Set([
|
|
972
|
+
"schema_version",
|
|
973
|
+
"event_id",
|
|
974
|
+
"session_id",
|
|
975
|
+
"seq",
|
|
976
|
+
"timestamp",
|
|
977
|
+
"family",
|
|
978
|
+
"family_version",
|
|
979
|
+
"event_type",
|
|
980
|
+
"payload",
|
|
981
|
+
"run_id",
|
|
982
|
+
"causation_id",
|
|
983
|
+
"correlation_id",
|
|
984
|
+
"actor_ref"
|
|
985
|
+
]), Je = new Map([["control", 1], ["runtime", 2]]), Ye = {
|
|
986
|
+
schema_version: ["schemaVersion", "SchemaVersion"],
|
|
987
|
+
event_id: ["eventId", "EventId"],
|
|
988
|
+
session_id: ["sessionId", "SessionId"],
|
|
989
|
+
seq: [
|
|
990
|
+
"seqId",
|
|
991
|
+
"SeqId",
|
|
992
|
+
"Seq"
|
|
993
|
+
],
|
|
994
|
+
timestamp: ["Timestamp"],
|
|
995
|
+
family: ["Family"],
|
|
996
|
+
family_version: ["familyVersion", "FamilyVersion"],
|
|
997
|
+
event_type: ["eventType", "EventType"],
|
|
998
|
+
payload: ["Payload"],
|
|
999
|
+
run_id: ["runId", "RunId"],
|
|
1000
|
+
causation_id: ["causationId", "CausationId"],
|
|
1001
|
+
correlation_id: ["correlationId", "CorrelationId"],
|
|
1002
|
+
actor_ref: ["actorRef", "ActorRef"]
|
|
1003
|
+
};
|
|
1004
|
+
function Xe(e) {
|
|
1005
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
1006
|
+
let t = e, n = { ...t };
|
|
1007
|
+
for (let [e, r] of Object.entries(Ye)) {
|
|
1008
|
+
if (n[e] === void 0) {
|
|
1009
|
+
let i = r.find((e) => t[e] !== void 0);
|
|
1010
|
+
i && (n[e] = t[i]);
|
|
1011
|
+
}
|
|
1012
|
+
for (let e of r) delete n[e];
|
|
1013
|
+
}
|
|
1014
|
+
return n;
|
|
1015
|
+
}
|
|
1016
|
+
var Ze = l.object({
|
|
1017
|
+
schema_version: l.literal(1),
|
|
1018
|
+
event_id: l.string().min(1),
|
|
1019
|
+
session_id: l.string().min(1),
|
|
1020
|
+
seq: l.number().int().min(0),
|
|
1021
|
+
timestamp: l.string().min(1),
|
|
1022
|
+
family: l.string().min(1),
|
|
1023
|
+
family_version: l.number().int().min(1),
|
|
1024
|
+
event_type: l.string().min(1),
|
|
1025
|
+
payload: l.record(l.string(), l.unknown()),
|
|
1026
|
+
run_id: l.string().min(1).nullable().optional(),
|
|
1027
|
+
causation_id: l.string().min(1).nullable().optional(),
|
|
1028
|
+
correlation_id: l.string().min(1).nullable().optional(),
|
|
1029
|
+
actor_ref: l.string().min(1).nullable().optional()
|
|
1030
|
+
}).passthrough();
|
|
1031
|
+
function Qe(e) {
|
|
1032
|
+
let t = Ze.safeParse(Xe(e));
|
|
1033
|
+
if (!t.success) return {
|
|
1034
|
+
ok: !1,
|
|
1035
|
+
error: new j(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)
|
|
1036
|
+
};
|
|
1037
|
+
let n = t.data, r = Je.get(n.family);
|
|
1038
|
+
if (r !== void 0 && n.family_version !== r) return {
|
|
1039
|
+
ok: !1,
|
|
1040
|
+
error: new j(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)
|
|
1041
|
+
};
|
|
1042
|
+
let i = {};
|
|
1043
|
+
for (let [e, t] of Object.entries(n)) qe.has(e) || (i[e] = t);
|
|
1044
|
+
return {
|
|
1045
|
+
ok: !0,
|
|
1046
|
+
value: {
|
|
1047
|
+
schema_version: 1,
|
|
1048
|
+
event_id: n.event_id,
|
|
1049
|
+
session_id: n.session_id,
|
|
1050
|
+
seq: n.seq,
|
|
1051
|
+
timestamp: n.timestamp,
|
|
1052
|
+
family: n.family,
|
|
1053
|
+
family_version: n.family_version,
|
|
1054
|
+
event_type: n.event_type,
|
|
1055
|
+
payload: n.payload,
|
|
1056
|
+
run_id: n.run_id ?? null,
|
|
1057
|
+
causation_id: n.causation_id ?? null,
|
|
1058
|
+
correlation_id: n.correlation_id ?? null,
|
|
1059
|
+
actor_ref: n.actor_ref ?? null,
|
|
1060
|
+
extensions: i
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
function $e(e) {
|
|
1065
|
+
let t = l.object({
|
|
1066
|
+
schema_version: l.literal(1),
|
|
1067
|
+
agent_instance_id: l.string().min(1),
|
|
1068
|
+
instance_state: l.enum([
|
|
1069
|
+
"ready",
|
|
1070
|
+
"degraded",
|
|
1071
|
+
"unavailable"
|
|
1072
|
+
]),
|
|
1073
|
+
session_id: l.string().min(1).nullable().optional(),
|
|
1074
|
+
active_run_id: l.string().min(1).nullable().optional(),
|
|
1075
|
+
active_run_state: l.enum([
|
|
1076
|
+
"pending",
|
|
1077
|
+
"running",
|
|
1078
|
+
"paused",
|
|
1079
|
+
"waiting"
|
|
1080
|
+
]).nullable().optional(),
|
|
1081
|
+
inbox_depth: l.number().int().min(0),
|
|
1082
|
+
activation_id: l.string().min(1).nullable().optional(),
|
|
1083
|
+
lease_expires_at: l.string().min(1).nullable().optional(),
|
|
1084
|
+
capability: l.unknown()
|
|
1085
|
+
}).passthrough().safeParse(e);
|
|
1086
|
+
if (!t.success) throw new j(`AgentStatusSnapshot/v1 mismatch: ${t.error.message}`);
|
|
1087
|
+
let n = t.data, r = {};
|
|
1088
|
+
for (let e of Object.keys(n)) [
|
|
1089
|
+
"schema_version",
|
|
1090
|
+
"agent_instance_id",
|
|
1091
|
+
"instance_state",
|
|
1092
|
+
"session_id",
|
|
1093
|
+
"active_run_id",
|
|
1094
|
+
"active_run_state",
|
|
1095
|
+
"inbox_depth",
|
|
1096
|
+
"activation_id",
|
|
1097
|
+
"lease_expires_at",
|
|
1098
|
+
"capability"
|
|
1099
|
+
].includes(e) || (r[e] = n[e]);
|
|
1100
|
+
return {
|
|
1101
|
+
schema_version: 1,
|
|
1102
|
+
agent_instance_id: n.agent_instance_id,
|
|
1103
|
+
instance_state: n.instance_state,
|
|
1104
|
+
session_id: n.session_id ?? null,
|
|
1105
|
+
active_run_id: n.active_run_id ?? null,
|
|
1106
|
+
active_run_state: n.active_run_state ?? null,
|
|
1107
|
+
inbox_depth: n.inbox_depth,
|
|
1108
|
+
activation_id: n.activation_id ?? null,
|
|
1109
|
+
lease_expires_at: n.lease_expires_at ?? null,
|
|
1110
|
+
capability: Ke(n.capability),
|
|
1111
|
+
extensions: r
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
var et = {
|
|
1115
|
+
$schema: "http://json-schema.org/draft-06/schema#",
|
|
1116
|
+
$id: "http://json-schema.org/draft-06/schema#",
|
|
1117
|
+
title: "Core schema meta-schema",
|
|
1118
|
+
definitions: {
|
|
1119
|
+
schemaArray: {
|
|
1120
|
+
type: "array",
|
|
1121
|
+
minItems: 1,
|
|
1122
|
+
items: { $ref: "#" }
|
|
1123
|
+
},
|
|
1124
|
+
nonNegativeInteger: {
|
|
1125
|
+
type: "integer",
|
|
1126
|
+
minimum: 0
|
|
1127
|
+
},
|
|
1128
|
+
nonNegativeIntegerDefault0: { allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] },
|
|
1129
|
+
simpleTypes: { enum: [
|
|
1130
|
+
"array",
|
|
1131
|
+
"boolean",
|
|
1132
|
+
"integer",
|
|
1133
|
+
"null",
|
|
1134
|
+
"number",
|
|
1135
|
+
"object",
|
|
1136
|
+
"string"
|
|
1137
|
+
] },
|
|
1138
|
+
stringArray: {
|
|
1139
|
+
type: "array",
|
|
1140
|
+
items: { type: "string" },
|
|
1141
|
+
uniqueItems: !0,
|
|
1142
|
+
default: []
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
type: ["object", "boolean"],
|
|
1146
|
+
properties: {
|
|
1147
|
+
$id: {
|
|
1148
|
+
type: "string",
|
|
1149
|
+
format: "uri-reference"
|
|
1150
|
+
},
|
|
1151
|
+
$schema: {
|
|
1152
|
+
type: "string",
|
|
1153
|
+
format: "uri"
|
|
1154
|
+
},
|
|
1155
|
+
$ref: {
|
|
1156
|
+
type: "string",
|
|
1157
|
+
format: "uri-reference"
|
|
1158
|
+
},
|
|
1159
|
+
title: { type: "string" },
|
|
1160
|
+
description: { type: "string" },
|
|
1161
|
+
default: {},
|
|
1162
|
+
examples: {
|
|
1163
|
+
type: "array",
|
|
1164
|
+
items: {}
|
|
1165
|
+
},
|
|
1166
|
+
multipleOf: {
|
|
1167
|
+
type: "number",
|
|
1168
|
+
exclusiveMinimum: 0
|
|
1169
|
+
},
|
|
1170
|
+
maximum: { type: "number" },
|
|
1171
|
+
exclusiveMaximum: { type: "number" },
|
|
1172
|
+
minimum: { type: "number" },
|
|
1173
|
+
exclusiveMinimum: { type: "number" },
|
|
1174
|
+
maxLength: { $ref: "#/definitions/nonNegativeInteger" },
|
|
1175
|
+
minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1176
|
+
pattern: {
|
|
1177
|
+
type: "string",
|
|
1178
|
+
format: "regex"
|
|
1179
|
+
},
|
|
1180
|
+
additionalItems: { $ref: "#" },
|
|
1181
|
+
items: {
|
|
1182
|
+
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }],
|
|
1183
|
+
default: {}
|
|
1184
|
+
},
|
|
1185
|
+
maxItems: { $ref: "#/definitions/nonNegativeInteger" },
|
|
1186
|
+
minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1187
|
+
uniqueItems: {
|
|
1188
|
+
type: "boolean",
|
|
1189
|
+
default: !1
|
|
1190
|
+
},
|
|
1191
|
+
contains: { $ref: "#" },
|
|
1192
|
+
maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
|
|
1193
|
+
minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1194
|
+
required: { $ref: "#/definitions/stringArray" },
|
|
1195
|
+
additionalProperties: { $ref: "#" },
|
|
1196
|
+
definitions: {
|
|
1197
|
+
type: "object",
|
|
1198
|
+
additionalProperties: { $ref: "#" },
|
|
1199
|
+
default: {}
|
|
1200
|
+
},
|
|
1201
|
+
properties: {
|
|
1202
|
+
type: "object",
|
|
1203
|
+
additionalProperties: { $ref: "#" },
|
|
1204
|
+
default: {}
|
|
1205
|
+
},
|
|
1206
|
+
patternProperties: {
|
|
1207
|
+
type: "object",
|
|
1208
|
+
additionalProperties: { $ref: "#" },
|
|
1209
|
+
default: {}
|
|
1210
|
+
},
|
|
1211
|
+
dependencies: {
|
|
1212
|
+
type: "object",
|
|
1213
|
+
additionalProperties: { anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] }
|
|
1214
|
+
},
|
|
1215
|
+
propertyNames: { $ref: "#" },
|
|
1216
|
+
const: {},
|
|
1217
|
+
enum: {
|
|
1218
|
+
type: "array",
|
|
1219
|
+
minItems: 1,
|
|
1220
|
+
uniqueItems: !0
|
|
1221
|
+
},
|
|
1222
|
+
type: { anyOf: [{ $ref: "#/definitions/simpleTypes" }, {
|
|
1223
|
+
type: "array",
|
|
1224
|
+
items: { $ref: "#/definitions/simpleTypes" },
|
|
1225
|
+
minItems: 1,
|
|
1226
|
+
uniqueItems: !0
|
|
1227
|
+
}] },
|
|
1228
|
+
format: { type: "string" },
|
|
1229
|
+
allOf: { $ref: "#/definitions/schemaArray" },
|
|
1230
|
+
anyOf: { $ref: "#/definitions/schemaArray" },
|
|
1231
|
+
oneOf: { $ref: "#/definitions/schemaArray" },
|
|
1232
|
+
not: { $ref: "#" }
|
|
1233
|
+
},
|
|
1234
|
+
default: {}
|
|
1235
|
+
}, N = /* @__PURE__ */ new Map();
|
|
1236
|
+
function tt(e) {
|
|
1237
|
+
n(e);
|
|
1238
|
+
let t = JSON.stringify(e), r = N.get(t);
|
|
1239
|
+
if (r) return r;
|
|
1240
|
+
let i = String(e.$schema || "https://json-schema.org/draft/2020-12/schema"), a = {
|
|
1241
|
+
strict: !1,
|
|
1242
|
+
allErrors: !0,
|
|
1243
|
+
coerceTypes: !1,
|
|
1244
|
+
useDefaults: !1,
|
|
1245
|
+
removeAdditional: !1,
|
|
1246
|
+
ownProperties: !0,
|
|
1247
|
+
logger: !1
|
|
1248
|
+
}, o = /draft-04/.test(i) ? new p(a) : /draft-0[67]/.test(i) ? new u(a) : /2019-09/.test(i) ? new d(a) : /2020-12/.test(i) ? new f(a) : null;
|
|
1249
|
+
if (!o) throw TypeError("Unsupported JSON Schema dialect");
|
|
1250
|
+
/draft-06/.test(i) && o.addMetaSchema(et), m(o);
|
|
1251
|
+
let s = o.compile(e);
|
|
1252
|
+
if ("$async" in s && s.$async) throw TypeError("Async schemas are not supported");
|
|
1253
|
+
N.size >= 128 && N.delete(N.keys().next().value);
|
|
1254
|
+
let c = typeof e.$id == "string" ? e.$id.replace(/#$/, "") : typeof e.id == "string" ? e.id.replace(/#$/, "") : "", l = {
|
|
1255
|
+
root: s,
|
|
1256
|
+
at: (e, t) => !!(e === "" ? s : o.getSchema(`${c}#${e}`))?.(t)
|
|
1257
|
+
};
|
|
1258
|
+
return N.set(t, l), l;
|
|
1259
|
+
}
|
|
1260
|
+
function nt(e) {
|
|
1261
|
+
return tt(e).at;
|
|
1262
|
+
}
|
|
1263
|
+
function rt(e, t) {
|
|
1264
|
+
try {
|
|
1265
|
+
n(t);
|
|
1266
|
+
let r = tt(e).root, i = r(t);
|
|
1267
|
+
return {
|
|
1268
|
+
valid: !!i,
|
|
1269
|
+
issues: i ? [] : (r.errors || []).slice(0, 10).map((e) => `${e.instancePath || "/"}:不符合 ${e.keyword} 约束`)
|
|
1270
|
+
};
|
|
1271
|
+
} catch {
|
|
1272
|
+
return {
|
|
1273
|
+
valid: !1,
|
|
1274
|
+
issues: ["输入或表单约束不是受支持的 JSON。"]
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
//#endregion
|
|
1279
|
+
//#region src/core/interaction/form-values.ts
|
|
1280
|
+
var P = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, it = (e, t) => Object.hasOwn(e, t) ? e[t] : void 0, at = (e) => e.replace(/~/g, "~0").replace(/\//g, "~1"), ot = /^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u;
|
|
1281
|
+
function st(e) {
|
|
1282
|
+
let [t, n = "0"] = e.toLowerCase().split("e"), [r, i = ""] = t.replace(/^-/, "").split("."), a = (r + i).replace(/^0+/, "").replace(/0+$/, "");
|
|
1283
|
+
if (!a) return "0";
|
|
1284
|
+
let o = (r + i).length - (r + i).replace(/0+$/, "").length;
|
|
1285
|
+
return `${e.startsWith("-") ? "-" : ""}${a}e${Number(n) - i.length + o}`;
|
|
1286
|
+
}
|
|
1287
|
+
function ct(e, t) {
|
|
1288
|
+
if (typeof e != "string") return e;
|
|
1289
|
+
if (t.includes("boolean") && (e === "true" || e === "false")) return e === "true";
|
|
1290
|
+
if (!t.some((e) => e === "number" || e === "integer") || e.length > 1024 || !ot.test(e)) return e;
|
|
1291
|
+
let n = Number(e);
|
|
1292
|
+
return !Number.isFinite(n) || st(e) !== st(JSON.stringify(n)) || !t.includes("number") && !Number.isSafeInteger(n) ? e : n === 0 ? 0 : n;
|
|
1293
|
+
}
|
|
1294
|
+
function lt(e, t) {
|
|
1295
|
+
let r = n(t), i = nt(e), a = 0, o = (e, t) => {
|
|
1296
|
+
try {
|
|
1297
|
+
return i(e, t);
|
|
1298
|
+
} catch {
|
|
1299
|
+
return !1;
|
|
1300
|
+
}
|
|
1301
|
+
}, s = (t) => {
|
|
1302
|
+
if (typeof t != "string" || !t.startsWith("#")) return;
|
|
1303
|
+
let n;
|
|
1304
|
+
try {
|
|
1305
|
+
n = decodeURIComponent(t.slice(1));
|
|
1306
|
+
} catch {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
if (n !== "" && !n.startsWith("/")) return;
|
|
1310
|
+
let r = e;
|
|
1311
|
+
for (let e of n === "" ? [] : n.slice(1).split("/")) {
|
|
1312
|
+
let t = e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1313
|
+
r = Array.isArray(r) ? r[Number(t)] : P(r) ? it(r, t) : void 0;
|
|
1314
|
+
}
|
|
1315
|
+
return {
|
|
1316
|
+
node: r,
|
|
1317
|
+
path: n
|
|
1318
|
+
};
|
|
1319
|
+
}, c = (e, t, n, r = 0) => {
|
|
1320
|
+
let i = P(e);
|
|
1321
|
+
if (++a > 8192 || r > 48 || !i || o(t, n)) return n;
|
|
1322
|
+
let l = n, u = s(i.$ref);
|
|
1323
|
+
u && (n = c(u.node, u.path, n, r + 1)), Array.isArray(i.allOf) && i.allOf.forEach((e, i) => {
|
|
1324
|
+
n = c(e, `${t}/allOf/${i}`, n, r + 1);
|
|
1325
|
+
});
|
|
1326
|
+
let d = Array.isArray(i.oneOf) ? "oneOf" : "anyOf", f = i[d];
|
|
1327
|
+
if (Array.isArray(f)) {
|
|
1328
|
+
let e = f.map((e, i) => c(e, `${t}/${d}/${i}`, n, r + 1)).filter((e) => o(t, e)), i = new Map(e.map((e) => [JSON.stringify(e), e]));
|
|
1329
|
+
return i.size === 1 ? [...i.values()][0] : l;
|
|
1330
|
+
}
|
|
1331
|
+
if (Array.isArray(n)) {
|
|
1332
|
+
let e = Array.isArray(i.items), a = e ? i.items : Array.isArray(i.prefixItems) ? i.prefixItems : [], o = e ? i.additionalItems : i.items;
|
|
1333
|
+
return n.map((n, i) => c(i < a.length ? a[i] : o, i < a.length ? `${t}/${e ? "items" : "prefixItems"}/${i}` : `${t}/${e ? "additionalItems" : "items"}`, n, r + 1));
|
|
1334
|
+
}
|
|
1335
|
+
let p = P(n);
|
|
1336
|
+
if (p) {
|
|
1337
|
+
let e = {}, n = P(i.properties) || {}, a = P(i.patternProperties) || {};
|
|
1338
|
+
for (let [o, s] of Object.entries(p)) {
|
|
1339
|
+
let l = s, u = !1;
|
|
1340
|
+
Object.hasOwn(n, o) && (l = c(n[o], `${t}/properties/${at(o)}`, l, r + 1), u = !0);
|
|
1341
|
+
for (let [e, n] of Object.entries(a)) new RegExp(e, "u").test(o) && (l = c(n, `${t}/patternProperties/${at(e)}`, l, r + 1), u = !0);
|
|
1342
|
+
!u && P(i.additionalProperties) && (l = c(i.additionalProperties, `${t}/additionalProperties`, l, r + 1)), Object.defineProperty(e, o, {
|
|
1343
|
+
value: l,
|
|
1344
|
+
enumerable: !0,
|
|
1345
|
+
configurable: !0,
|
|
1346
|
+
writable: !0
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
return e;
|
|
1350
|
+
}
|
|
1351
|
+
return ct(n, Array.isArray(i.type) ? i.type : [i.type]);
|
|
1352
|
+
}, l = c(e, "", r), u = rt(e, l);
|
|
1353
|
+
if (!u.valid) throw TypeError(u.issues.join(";"));
|
|
1354
|
+
return l;
|
|
1355
|
+
}
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region src/core/interaction/client.ts
|
|
1358
|
+
var ut = {
|
|
1359
|
+
approve: "approved",
|
|
1360
|
+
reject: "rejected",
|
|
1361
|
+
submit: "submitted",
|
|
1362
|
+
cancel: "cancelled"
|
|
1363
|
+
};
|
|
1364
|
+
function F(e, t) {
|
|
1365
|
+
return {
|
|
1366
|
+
schema_version: 1,
|
|
1367
|
+
command_id: `local-${t}`,
|
|
1368
|
+
status: e,
|
|
1369
|
+
message_id: null,
|
|
1370
|
+
run_id: null,
|
|
1371
|
+
accepted_seq: null,
|
|
1372
|
+
error: null,
|
|
1373
|
+
extensions: {}
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
var dt = class {
|
|
1377
|
+
store;
|
|
1378
|
+
deps;
|
|
1379
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
1380
|
+
constructor(e) {
|
|
1381
|
+
this.deps = e, this.store = e.store || new A();
|
|
1382
|
+
}
|
|
1383
|
+
listPending(e) {
|
|
1384
|
+
return this.store.listPending(e);
|
|
1385
|
+
}
|
|
1386
|
+
setInteractionV1Enabled(e) {
|
|
1387
|
+
this.deps.interactionV1Enabled = e;
|
|
1388
|
+
}
|
|
1389
|
+
subscribe(e) {
|
|
1390
|
+
return this.store.subscribe(e);
|
|
1391
|
+
}
|
|
1392
|
+
ingest(e) {
|
|
1393
|
+
this.store.upsert(e);
|
|
1394
|
+
}
|
|
1395
|
+
ingestHistory(e) {
|
|
1396
|
+
for (let t of e) this.store.upsert(t);
|
|
1397
|
+
for (let [e] of this.inFlight) {
|
|
1398
|
+
let t = this.store.all().find((t) => this.recordKey(t) === e);
|
|
1399
|
+
t && t.status !== "pending" && t.status !== "resolving" && this.inFlight.delete(e);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
recordKey(e) {
|
|
1403
|
+
return JSON.stringify([e.sessionId, e.interactionId]);
|
|
1404
|
+
}
|
|
1405
|
+
findByInteractionId(e, t) {
|
|
1406
|
+
if (t) return this.store.get(t, e);
|
|
1407
|
+
let n = this.store.all().filter((t) => t.interactionId === e);
|
|
1408
|
+
return n.length === 1 ? n[0] : null;
|
|
1409
|
+
}
|
|
1410
|
+
async respond(e) {
|
|
1411
|
+
let t = this.findByInteractionId(e.interactionId, e.sessionId);
|
|
1412
|
+
if (!t) return F("rejected", e.interactionId);
|
|
1413
|
+
if (t.status === "resolved" || t.status === "cancelled" || t.status === "expired" || t.status === "resolving") return F("duplicate", e.interactionId);
|
|
1414
|
+
let r = this.deps.interactionV1Enabled || t.source === "interaction_v1";
|
|
1415
|
+
if (!r && t.source === "responses" && (t.kind !== "approval" || ![
|
|
1416
|
+
"approve",
|
|
1417
|
+
"reject",
|
|
1418
|
+
"cancel"
|
|
1419
|
+
].includes(e.action))) {
|
|
1420
|
+
let n = {
|
|
1421
|
+
code: "input_transport_unsupported",
|
|
1422
|
+
message: "当前运行时不支持提交此提问,请升级运行时后重试。",
|
|
1423
|
+
retryable: !1,
|
|
1424
|
+
extensions: {}
|
|
1425
|
+
};
|
|
1426
|
+
return this.store.markFailed(t.sessionId, e.interactionId, n), {
|
|
1427
|
+
...F("unsupported", e.interactionId),
|
|
1428
|
+
error: n
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
try {
|
|
1432
|
+
n(e.response);
|
|
1433
|
+
} catch {
|
|
1434
|
+
return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1435
|
+
code: "input_response_invalid",
|
|
1436
|
+
message: "答案必须是合法 JSON 值。",
|
|
1437
|
+
retryable: !0
|
|
1438
|
+
}), F("rejected", e.interactionId);
|
|
1439
|
+
}
|
|
1440
|
+
if (t.kind === "structured_input" && e.action === "submit" && t.requestSchema) try {
|
|
1441
|
+
e = {
|
|
1442
|
+
...e,
|
|
1443
|
+
response: lt(t.requestSchema, e.response)
|
|
1444
|
+
};
|
|
1445
|
+
} catch (n) {
|
|
1446
|
+
return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1447
|
+
code: "input_response_invalid",
|
|
1448
|
+
message: n instanceof Error ? n.message : "答案不符合表单约束。",
|
|
1449
|
+
retryable: !0
|
|
1450
|
+
}), F("rejected", e.interactionId);
|
|
1451
|
+
}
|
|
1452
|
+
if (t.source === "agui" && !this.deps.interactionV1Enabled && e.action !== "cancel" && e.response === null) return this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1453
|
+
code: "input_transport_unsupported",
|
|
1454
|
+
message: "当前 AG-UI 传输不能提交根 null,请使用 Interaction/v1。",
|
|
1455
|
+
retryable: !1
|
|
1456
|
+
}), F("rejected", e.interactionId);
|
|
1457
|
+
let i = e.idempotencyKey || Ve(e.interactionId, e.expectedRevision), a = t.extensions.rejected_command_id, o = a ? `${i}:retry-${a}` : i, s = this.recordKey(t), c = this.inFlight.get(s);
|
|
1458
|
+
if (c) return F(c === o ? "duplicate" : "rejected", e.interactionId);
|
|
1459
|
+
this.inFlight.set(s, o), this.store.markResolving(t.sessionId, e.interactionId);
|
|
1460
|
+
try {
|
|
1461
|
+
if (!r && t.source === "responses" && this.deps.legacyResponsesApproval) {
|
|
1462
|
+
let n = t.extensions.previous_response_id;
|
|
1463
|
+
return await this.deps.legacyResponsesApproval(e.interactionId, e.action === "approve", ...typeof n == "string" && n ? [n] : []) === !1 ? (this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1464
|
+
code: "interaction_not_dispatched",
|
|
1465
|
+
message: "交互尚未提交,请稍后重试。",
|
|
1466
|
+
retryable: !0
|
|
1467
|
+
}), F("rejected", e.interactionId)) : (this.resolveLocal(t, e, o), F("accepted", e.interactionId));
|
|
1468
|
+
}
|
|
1469
|
+
if (!r && t.source === "agui" && this.deps.legacyAguiResume) return this.deps.legacyAguiResume(String(t.extensions.interrupt_id || e.interactionId), e.action === "cancel" ? "cancelled" : "resolved", e.response) ? (this.store.recordIdempotencyKey(t.sessionId, e.interactionId, o), F("accepted", e.interactionId)) : (this.store.revertToPending(t.sessionId, e.interactionId), F("rejected", e.interactionId));
|
|
1470
|
+
let n = M(await this.deps.submitInteraction({
|
|
1471
|
+
AgentId: this.deps.agentId,
|
|
1472
|
+
SessionId: t.sessionId,
|
|
1473
|
+
RunId: t.runId || "",
|
|
1474
|
+
InteractionId: e.interactionId,
|
|
1475
|
+
ExpectedRevision: e.expectedRevision,
|
|
1476
|
+
Action: e.action,
|
|
1477
|
+
Response: e.response,
|
|
1478
|
+
IdempotencyKey: o
|
|
1479
|
+
}));
|
|
1480
|
+
return n.status === "accepted" || n.status === "duplicate" ? (this.store.recordCommand(t.sessionId, e.interactionId, n.command_id), this.store.recordIdempotencyKey(t.sessionId, e.interactionId, o)) : n.status === "queue_full" ? this.store.revertToPending(t.sessionId, e.interactionId) : this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1481
|
+
code: n.error?.code ?? String(n.status),
|
|
1482
|
+
message: n.error?.message ?? `提交未通过(${n.status})`,
|
|
1483
|
+
retryable: n.error?.retryable ?? !1
|
|
1484
|
+
}), n;
|
|
1485
|
+
} catch (n) {
|
|
1486
|
+
let r = n instanceof Error ? n.message : String(n || "交互提交失败");
|
|
1487
|
+
throw this.store.markFailed(t.sessionId, e.interactionId, {
|
|
1488
|
+
code: "interaction_submit_failed",
|
|
1489
|
+
message: r,
|
|
1490
|
+
retryable: !0
|
|
1491
|
+
}), n;
|
|
1492
|
+
} finally {
|
|
1493
|
+
this.inFlight.delete(s);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
resolveLocal(e, t, n) {
|
|
1497
|
+
let r = this.store.get(e.sessionId, t.interactionId);
|
|
1498
|
+
if (!r || k(r.status)) return;
|
|
1499
|
+
let i = t.action === "cancel" ? "cancelled" : "resolved";
|
|
1500
|
+
this.store.resolveLocally(e.sessionId, t.interactionId, {
|
|
1501
|
+
status: i,
|
|
1502
|
+
outcome: ut[t.action],
|
|
1503
|
+
actor: "user",
|
|
1504
|
+
responseSummary: e.kind === "structured_input" ? t.action === "cancel" ? "已取消" : "已提交" : He(t.action, t.response),
|
|
1505
|
+
revision: t.expectedRevision
|
|
1506
|
+
});
|
|
1507
|
+
let a = this.store.get(e.sessionId, t.interactionId);
|
|
1508
|
+
a && this.store.upsert({
|
|
1509
|
+
...a,
|
|
1510
|
+
extensions: {
|
|
1511
|
+
...a.extensions,
|
|
1512
|
+
idempotency_key: n
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
}, I = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, L = class extends Error {};
|
|
1517
|
+
function ft() {
|
|
1518
|
+
let e = 8192;
|
|
1519
|
+
return () => {
|
|
1520
|
+
if (--e < 0) throw new L();
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
function pt(e, t, n) {
|
|
1524
|
+
if (e === "#") return t;
|
|
1525
|
+
if (typeof e != "string" || !e.startsWith("#/")) throw new L();
|
|
1526
|
+
try {
|
|
1527
|
+
let r = t;
|
|
1528
|
+
for (let t of decodeURIComponent(e.slice(2)).split("/")) {
|
|
1529
|
+
n();
|
|
1530
|
+
let e = I(r) ?? (Array.isArray(r) ? r : void 0), i = t.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1531
|
+
if (!e || !Object.hasOwn(e, i)) throw new L();
|
|
1532
|
+
r = e[i];
|
|
1533
|
+
}
|
|
1534
|
+
return r;
|
|
1535
|
+
} catch {
|
|
1536
|
+
throw new L();
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
function mt(e, t, n) {
|
|
1540
|
+
let r = /* @__PURE__ */ new Set(), i = [...e];
|
|
1541
|
+
for (; i.length;) {
|
|
1542
|
+
n();
|
|
1543
|
+
let e = i.pop();
|
|
1544
|
+
if (typeof e == "boolean") continue;
|
|
1545
|
+
let a = I(e);
|
|
1546
|
+
if (!a) throw new L();
|
|
1547
|
+
if (!r.has(a)) {
|
|
1548
|
+
if (r.add(a), a !== t && Object.hasOwn(a, "$id") || Object.hasOwn(a, "$dynamicRef") || Object.hasOwn(a, "$recursiveRef")) throw new L();
|
|
1549
|
+
Object.hasOwn(a, "$ref") && i.push(pt(a.$ref, t, n));
|
|
1550
|
+
for (let e of [
|
|
1551
|
+
"allOf",
|
|
1552
|
+
"anyOf",
|
|
1553
|
+
"oneOf"
|
|
1554
|
+
]) {
|
|
1555
|
+
let t = a[e];
|
|
1556
|
+
if (t !== void 0 && !Array.isArray(t)) throw new L();
|
|
1557
|
+
Array.isArray(t) && i.push(...t);
|
|
1558
|
+
}
|
|
1559
|
+
for (let e of [
|
|
1560
|
+
"if",
|
|
1561
|
+
"then",
|
|
1562
|
+
"else"
|
|
1563
|
+
]) Object.hasOwn(a, e) && i.push(a[e]);
|
|
1564
|
+
for (let e of [I(a.dependentSchemas), I(a.dependencies)]) for (let t of Object.values(e || {})) (I(t) || typeof t == "boolean") && i.push(t);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return [...r];
|
|
1568
|
+
}
|
|
1569
|
+
var ht = (e) => e.writeOnly === !0 || e.format === "password" || e["x-sensitive"] === !0 || e["x-codex-is-secret"] === !0;
|
|
1570
|
+
function gt(e, t = e) {
|
|
1571
|
+
try {
|
|
1572
|
+
return mt([e], t, ft()).some(ht);
|
|
1573
|
+
} catch {
|
|
1574
|
+
return !0;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
function _t(e, t) {
|
|
1578
|
+
let r = ft();
|
|
1579
|
+
function i(t, n, a) {
|
|
1580
|
+
if (r(), a > 48) throw new L();
|
|
1581
|
+
let o = mt(t, e, r);
|
|
1582
|
+
return o.some(ht) ? null : Array.isArray(n) ? n.map((e, t) => {
|
|
1583
|
+
let n = [];
|
|
1584
|
+
for (let e of o) {
|
|
1585
|
+
let r = Array.isArray(e.prefixItems) ? e.prefixItems : void 0, i = Array.isArray(e.items) ? e.items : void 0;
|
|
1586
|
+
n.push(r && t < r.length ? r[t] : i ? t < i.length ? i[t] : e.additionalItems ?? {} : e.items ?? {});
|
|
1587
|
+
for (let t of ["contains", "unevaluatedItems"]) Object.hasOwn(e, t) && n.push(e[t]);
|
|
1588
|
+
}
|
|
1589
|
+
return i(n, e, a + 1);
|
|
1590
|
+
}) : typeof n != "object" || !n ? n : Object.fromEntries(Object.entries(n).map(([e, t]) => {
|
|
1591
|
+
let n = [];
|
|
1592
|
+
for (let t of o) {
|
|
1593
|
+
let r = I(t.properties), i = !!(r && Object.hasOwn(r, e));
|
|
1594
|
+
i && n.push(r[e]);
|
|
1595
|
+
for (let [r, a] of Object.entries(I(t.patternProperties) || {})) new RegExp(r).test(e) && (i = !0, n.push(a));
|
|
1596
|
+
!i && Object.hasOwn(t, "additionalProperties") && n.push(t.additionalProperties), Object.hasOwn(t, "unevaluatedProperties") && n.push(t.unevaluatedProperties);
|
|
1597
|
+
}
|
|
1598
|
+
return [e, i(n, t, a + 1)];
|
|
1599
|
+
}));
|
|
1600
|
+
}
|
|
1601
|
+
try {
|
|
1602
|
+
return n(t), i([e], t, 0);
|
|
1603
|
+
} catch {
|
|
1604
|
+
return null;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
function vt(e) {
|
|
1608
|
+
if (!(e.kind !== "structured_input" || e.status !== "resolved" || e.outcome !== "submitted" || !e.requestSchema || !Object.hasOwn(e, "response"))) try {
|
|
1609
|
+
return { value: _t(e.requestSchema, n(e.response)) };
|
|
1610
|
+
} catch {
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
//#endregion
|
|
1615
|
+
//#region src/core/interaction/adapters/session-events.ts
|
|
1616
|
+
var yt = new Set([
|
|
1617
|
+
"interaction.requested",
|
|
1618
|
+
"interaction_requested",
|
|
1619
|
+
"ksadk.interaction/v1.requested",
|
|
1620
|
+
"InteractionRequested",
|
|
1621
|
+
"approval.requested",
|
|
1622
|
+
"a2ui.interaction"
|
|
1623
|
+
]), bt = new Set([
|
|
1624
|
+
"interaction.resolved",
|
|
1625
|
+
"interaction_resolved",
|
|
1626
|
+
"ksadk.interaction/v1.resolved",
|
|
1627
|
+
"InteractionResolved",
|
|
1628
|
+
"interaction.cancelled",
|
|
1629
|
+
"interaction.cancel",
|
|
1630
|
+
"interaction.expired",
|
|
1631
|
+
"approval.resolved",
|
|
1632
|
+
"a2ui.action"
|
|
1633
|
+
]);
|
|
1634
|
+
function R(e) {
|
|
1635
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
1636
|
+
}
|
|
1637
|
+
function xt(e, t) {
|
|
1638
|
+
let n = R(e);
|
|
1639
|
+
if (!n) return null;
|
|
1640
|
+
let r = R(n.Content ?? n.content), i = R(r?.session_event ?? r?.sessionEvent), a = R(n.payload), o = i ?? (a?.family === "interaction" ? a : null) ?? (n.family === "interaction" ? n : null), s = i ?? (String(a?.event_type || "").startsWith("mcp.authorization.") ? a : null) ?? (String(r?.event_type || "").startsWith("mcp.authorization.") ? r : n);
|
|
1641
|
+
if (s && String(s?.event_type || s?.EventType || "").startsWith("mcp.authorization.")) return ze(s.payload ?? s, String(s.session_id || n.SessionId || t || ""), String(s.run_id || n.InvocationId || ""));
|
|
1642
|
+
if (o && o.family !== "interaction") return null;
|
|
1643
|
+
let c = o ?? n, l = String(c.event_type || c.EventType || "").trim();
|
|
1644
|
+
if (!l) return null;
|
|
1645
|
+
let u = R(c.payload ?? c.Content) ?? (o || {}), d = R(u.interaction) || R(u.Interaction) || R(u.interaction_request) || u, f = String(d.interaction_id || d.interactionId || d.InteractionId || d.approval_id || d.approvalId || u.interaction_id || u.interactionId || u.InteractionId || u.approval_id || u.approvalId || "");
|
|
1646
|
+
if (!f) return null;
|
|
1647
|
+
let p = String(c.session_id || c.SessionId || d.session_id || d.sessionId || t || "");
|
|
1648
|
+
if (!p) return null;
|
|
1649
|
+
if (yt.has(l)) {
|
|
1650
|
+
let e = R(d.request) || {}, t = R(d.presentation ?? e.presentation), n = {
|
|
1651
|
+
...R(d.extensions) || {},
|
|
1652
|
+
...d.detail === void 0 ? {} : { detail: d.detail },
|
|
1653
|
+
...(d.call_id ?? d.callId) === void 0 ? {} : { call_id: d.call_id ?? d.callId }
|
|
1654
|
+
};
|
|
1655
|
+
return O({
|
|
1656
|
+
interactionId: f,
|
|
1657
|
+
sessionId: p,
|
|
1658
|
+
runId: d.run_id ?? d.runId ?? c.run_id ?? c.InvocationId,
|
|
1659
|
+
kind: l === "approval.requested" ? "approval" : d.kind === "form" ? "structured_input" : d.kind ?? e.kind ?? "approval",
|
|
1660
|
+
title: d.title ?? t?.title,
|
|
1661
|
+
message: d.message ?? d.description ?? R(d.detail)?.command ?? t?.description,
|
|
1662
|
+
requestSchema: d.request_schema ?? d.requestSchema ?? d.input_schema ?? d.inputSchema ?? d.RequestSchema ?? e.request_schema,
|
|
1663
|
+
presentation: t,
|
|
1664
|
+
status: "pending",
|
|
1665
|
+
revision: d.revision ?? 1,
|
|
1666
|
+
createdAt: d.created_at ?? d.createdAt ?? c.timestamp ?? c.Timestamp,
|
|
1667
|
+
expiresAt: d.expires_at ?? e.expires_at,
|
|
1668
|
+
source: "interaction_v1",
|
|
1669
|
+
extensions: n
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
if (bt.has(l)) {
|
|
1673
|
+
let e = {
|
|
1674
|
+
...R(d.extensions) || {},
|
|
1675
|
+
...d.detail === void 0 ? {} : { detail: d.detail },
|
|
1676
|
+
...(d.call_id ?? d.callId) === void 0 ? {} : { call_id: d.call_id ?? d.callId }
|
|
1677
|
+
}, t = l === "interaction.cancelled" || l === "interaction.cancel" ? "cancelled" : l === "interaction.expired" ? "expired" : "resolved", n = String(u.outcome ?? d.outcome ?? d.status ?? "").toLowerCase(), r = String(u.action ?? d.action ?? u.name ?? d.name ?? "").toLowerCase(), i = n;
|
|
1678
|
+
i ||= r === "approve" ? "approved" : r === "reject" ? "rejected" : r === "submit" ? "submitted" : r === "cancel" || t === "cancelled" ? "cancelled" : t === "expired" ? "expired" : "submitted";
|
|
1679
|
+
let a = t === "resolved" ? "resolved" : t;
|
|
1680
|
+
return O({
|
|
1681
|
+
interactionId: f,
|
|
1682
|
+
sessionId: p,
|
|
1683
|
+
runId: d.run_id ?? d.runId ?? c.run_id ?? c.InvocationId,
|
|
1684
|
+
kind: d.kind,
|
|
1685
|
+
title: d.title,
|
|
1686
|
+
message: d.message,
|
|
1687
|
+
requestSchema: d.request_schema,
|
|
1688
|
+
presentation: d.presentation,
|
|
1689
|
+
status: a,
|
|
1690
|
+
revision: d.revision,
|
|
1691
|
+
createdAt: d.created_at ?? c.timestamp,
|
|
1692
|
+
expiresAt: d.expires_at,
|
|
1693
|
+
resolvedAt: u.resolved_at ?? u.resolvedAt ?? d.resolved_at ?? d.resolvedAt ?? c.timestamp ?? c.Timestamp,
|
|
1694
|
+
actor: u.actor ?? d.actor ?? c.actor_ref,
|
|
1695
|
+
outcome: i,
|
|
1696
|
+
responseSummary: u.response_summary ?? d.response_summary ?? (r ? `${r}` : void 0),
|
|
1697
|
+
...Object.hasOwn(d, "response") ? { response: d.response } : Object.hasOwn(u, "response") ? { response: u.response } : !o && ["a2ui.action", "interaction.resolved"].includes(l) && Object.hasOwn(d, "data") ? { response: d.data } : {},
|
|
1698
|
+
source: "interaction_v1",
|
|
1699
|
+
extensions: e
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
return null;
|
|
1703
|
+
}
|
|
1704
|
+
//#endregion
|
|
1705
|
+
//#region src/core/interaction/adapters/responses.ts
|
|
1706
|
+
function z(e) {
|
|
1707
|
+
return !e.approvalRequestId || !e.sessionId ? null : O({
|
|
1708
|
+
interactionId: e.approvalRequestId,
|
|
1709
|
+
sessionId: e.sessionId,
|
|
1710
|
+
runId: e.runId ?? null,
|
|
1711
|
+
kind: "approval",
|
|
1712
|
+
title: e.name ? `审批:${e.name}` : "人工确认",
|
|
1713
|
+
message: e.message || "本次运行需要人工审批后才能继续。",
|
|
1714
|
+
requestSchema: e.requestSchema ?? null,
|
|
1715
|
+
status: "pending",
|
|
1716
|
+
revision: 1,
|
|
1717
|
+
source: "responses",
|
|
1718
|
+
extensions: {
|
|
1719
|
+
...e.previousResponseId ? { previous_response_id: e.previousResponseId } : {},
|
|
1720
|
+
...e.approvalLevel ? { approval_level: e.approvalLevel } : {},
|
|
1721
|
+
...e.args ? { arguments: e.args } : {}
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
function St(e) {
|
|
1726
|
+
let t = {}, n = [];
|
|
1727
|
+
for (let r of e) {
|
|
1728
|
+
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) : [];
|
|
1729
|
+
t[i] = {
|
|
1730
|
+
type: "string",
|
|
1731
|
+
title: String(e.question || e.label || e.title || i),
|
|
1732
|
+
...a.length ? { enum: a } : {}
|
|
1733
|
+
}, n.push(i);
|
|
1734
|
+
}
|
|
1735
|
+
return {
|
|
1736
|
+
type: "object",
|
|
1737
|
+
properties: t,
|
|
1738
|
+
required: n,
|
|
1739
|
+
additionalProperties: !1
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
function Ct(e) {
|
|
1743
|
+
if (!e.questionId || !e.sessionId) return null;
|
|
1744
|
+
let t = Array.isArray(e.questions) ? e.questions : [];
|
|
1745
|
+
return O({
|
|
1746
|
+
interactionId: e.questionId,
|
|
1747
|
+
sessionId: e.sessionId,
|
|
1748
|
+
runId: e.runId ?? null,
|
|
1749
|
+
kind: "structured_input",
|
|
1750
|
+
title: "询问",
|
|
1751
|
+
message: "Agent 需要你的选择后才能继续。",
|
|
1752
|
+
requestSchema: St(t),
|
|
1753
|
+
status: "pending",
|
|
1754
|
+
revision: 1,
|
|
1755
|
+
source: "responses",
|
|
1756
|
+
extensions: { questions: t }
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
//#endregion
|
|
1760
|
+
//#region src/core/interaction/adapters/agui.ts
|
|
1761
|
+
function B(e) {
|
|
1762
|
+
if (!e.interruptId || !e.sessionId) return null;
|
|
1763
|
+
let t = e.requestSchema != null;
|
|
1764
|
+
return O({
|
|
1765
|
+
interactionId: e.interruptId,
|
|
1766
|
+
sessionId: e.sessionId,
|
|
1767
|
+
runId: e.runId ?? null,
|
|
1768
|
+
kind: t ? "structured_input" : "approval",
|
|
1769
|
+
title: e.name ? `${t ? "补充信息" : "确认"}:${e.name}` : t ? "补充信息" : "人工确认",
|
|
1770
|
+
message: e.message || (t ? "请填写后提交,Agent 将继续当前任务。" : "本次运行需要人工确认后才能继续。"),
|
|
1771
|
+
requestSchema: e.requestSchema ?? null,
|
|
1772
|
+
status: "pending",
|
|
1773
|
+
revision: 1,
|
|
1774
|
+
source: "agui",
|
|
1775
|
+
extensions: {
|
|
1776
|
+
interrupt_id: e.interruptId,
|
|
1777
|
+
...e.toolCallId ? { tool_call_id: e.toolCallId } : {},
|
|
1778
|
+
...e.reason ? { reason: e.reason } : {}
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
var V = {
|
|
447
1783
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
448
1784
|
$id: "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json",
|
|
449
1785
|
title: "A2UI Basic Catalog",
|
|
@@ -519,7 +1855,7 @@ var de = a()((e) => ({
|
|
|
519
1855
|
{ $ref: "#/functions/not" }
|
|
520
1856
|
] }
|
|
521
1857
|
}
|
|
522
|
-
},
|
|
1858
|
+
}, wt = {
|
|
523
1859
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
524
1860
|
$id: "https://a2ui.org/specification/v0_9/common_types.json",
|
|
525
1861
|
title: "A2UI Common Types",
|
|
@@ -712,7 +2048,7 @@ var de = a()((e) => ({
|
|
|
712
2048
|
}]
|
|
713
2049
|
}
|
|
714
2050
|
}
|
|
715
|
-
},
|
|
2051
|
+
}, Tt = {
|
|
716
2052
|
schema_version: 1,
|
|
717
2053
|
profile: "official-0.9.1",
|
|
718
2054
|
wire_versions: ["v0.9", "v0.9.1"],
|
|
@@ -790,7 +2126,7 @@ var de = a()((e) => ({
|
|
|
790
2126
|
],
|
|
791
2127
|
source: "ksadk.a2ui.models.BASIC_CATALOG; project compatibility asset"
|
|
792
2128
|
}]
|
|
793
|
-
},
|
|
2129
|
+
}, H = {
|
|
794
2130
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
795
2131
|
$id: "a2ui.org/catalogs/basic/v1.0",
|
|
796
2132
|
catalogId: "a2ui.org/catalogs/basic/v1.0",
|
|
@@ -960,24 +2296,24 @@ var de = a()((e) => ({
|
|
|
960
2296
|
}
|
|
961
2297
|
},
|
|
962
2298
|
functions: {}
|
|
963
|
-
},
|
|
964
|
-
function
|
|
965
|
-
return te(ee(new TextEncoder().encode(
|
|
2299
|
+
}, U = V, W = Tt, G = H;
|
|
2300
|
+
function K(e) {
|
|
2301
|
+
return te(ee(new TextEncoder().encode(h(n(e)))));
|
|
966
2302
|
}
|
|
967
|
-
var
|
|
2303
|
+
var q = new f({
|
|
968
2304
|
strict: !1,
|
|
969
2305
|
allErrors: !0,
|
|
970
2306
|
logger: !1
|
|
971
2307
|
});
|
|
972
|
-
|
|
973
|
-
for (let e of Object.keys(
|
|
974
|
-
...
|
|
2308
|
+
m(q), q.addSchema(wt), q.addSchema(V), q.addSchema(H);
|
|
2309
|
+
for (let e of Object.keys(Tt.schema_resolution_aliases)) q.addSchema({
|
|
2310
|
+
...V,
|
|
975
2311
|
$id: e
|
|
976
2312
|
});
|
|
977
|
-
new Map(Object.keys(
|
|
2313
|
+
new Map(Object.keys(V.components).map((e) => [e, q.getSchema(`${V.$id}#/components/${e}`)])), new Map(Object.keys(H.components).map((e) => [e, q.getSchema(`${H.$id}#/components/${e}`)]));
|
|
978
2314
|
//#endregion
|
|
979
2315
|
//#region src/core/a2ui/linking.ts
|
|
980
|
-
var
|
|
2316
|
+
var Et = new Set([
|
|
981
2317
|
"components",
|
|
982
2318
|
"functions",
|
|
983
2319
|
"$defs",
|
|
@@ -985,7 +2321,7 @@ var pe = new Set([
|
|
|
985
2321
|
"properties",
|
|
986
2322
|
"patternProperties",
|
|
987
2323
|
"dependentSchemas"
|
|
988
|
-
]),
|
|
2324
|
+
]), Dt = new Set([
|
|
989
2325
|
"theme",
|
|
990
2326
|
"items",
|
|
991
2327
|
"additionalProperties",
|
|
@@ -999,13 +2335,13 @@ var pe = new Set([
|
|
|
999
2335
|
"unevaluatedProperties",
|
|
1000
2336
|
"unevaluatedItems",
|
|
1001
2337
|
"contentSchema"
|
|
1002
|
-
]),
|
|
2338
|
+
]), Ot = new Set([
|
|
1003
2339
|
"allOf",
|
|
1004
2340
|
"anyOf",
|
|
1005
2341
|
"oneOf",
|
|
1006
2342
|
"prefixItems"
|
|
1007
|
-
]),
|
|
1008
|
-
function
|
|
2343
|
+
]), kt = "https://a2ui.org/specification/v0_9/common_types.json";
|
|
2344
|
+
function At(e, t) {
|
|
1009
2345
|
let n = String(e.$id || e.catalogId), r = /* @__PURE__ */ new Set(), i = (e, t) => t.startsWith("#") ? e.split("#")[0] + t : /^[a-z][a-z0-9+.-]*:/i.test(t) ? t : new URL(t, e).href, a = (e, o, s = !1) => {
|
|
1010
2346
|
if (!e || typeof e != "object" || Array.isArray(e)) return structuredClone(e);
|
|
1011
2347
|
let c = e, l = typeof c.$id == "string" && c.$id !== o ? i(o, c.$id) : o, u = structuredClone(c);
|
|
@@ -1015,7 +2351,7 @@ function I(e, t) {
|
|
|
1015
2351
|
let d = i(l, o), f = t(d);
|
|
1016
2352
|
if (f === void 0) throw Error("A2UI 目录包含未提供的离线 Schema 引用。");
|
|
1017
2353
|
if (d.split("#")[0] === n) u[e] = "#" + (d.split("#")[1] || "");
|
|
1018
|
-
else if (d.split("#")[0] !==
|
|
2354
|
+
else if (d.split("#")[0] !== kt) {
|
|
1019
2355
|
if (r.has(d)) throw Error("循环的外部 A2UI Schema 资产无法完成链接。");
|
|
1020
2356
|
r.add(d);
|
|
1021
2357
|
let t;
|
|
@@ -1028,32 +2364,32 @@ function I(e, t) {
|
|
|
1028
2364
|
return Object.keys(n).length ? { allOf: [t, a(n, l, s)] } : t;
|
|
1029
2365
|
}
|
|
1030
2366
|
}
|
|
1031
|
-
for (let [e, t] of Object.entries(c))
|
|
2367
|
+
for (let [e, t] of Object.entries(c)) Et.has(e) && t && typeof t == "object" && !Array.isArray(t) ? u[e] = Object.fromEntries(Object.entries(t).map(([e, t]) => [e, a(t, l, s)])) : Dt.has(e) && (typeof t == "object" || typeof t == "boolean") ? u[e] = a(t, l, s) : Ot.has(e) && Array.isArray(t) && (u[e] = t.map((e) => a(e, l, s)));
|
|
1032
2368
|
return s && (delete u.$id, delete u.$schema, delete u.$anchor), u;
|
|
1033
2369
|
};
|
|
1034
2370
|
return a(e, n);
|
|
1035
2371
|
}
|
|
1036
2372
|
//#endregion
|
|
1037
2373
|
//#region src/core/a2ui/registry.ts
|
|
1038
|
-
var
|
|
1039
|
-
schema:
|
|
2374
|
+
var jt = [{
|
|
2375
|
+
schema: U,
|
|
1040
2376
|
loadRenderer: async () => (await import("@a2ui/web_core/v0_9/basic_catalog")).basicCatalog
|
|
1041
2377
|
}, {
|
|
1042
|
-
schema:
|
|
1043
|
-
loadRenderer: async () => new
|
|
1044
|
-
}],
|
|
2378
|
+
schema: G,
|
|
2379
|
+
loadRenderer: async () => new g(G.catalogId, "0.9", [...g.fromSchema(G, "0.9").components.values()], [])
|
|
2380
|
+
}], J = class {
|
|
1045
2381
|
defaultCatalogId;
|
|
1046
2382
|
entries = /* @__PURE__ */ new Map();
|
|
1047
2383
|
validators = /* @__PURE__ */ new Map();
|
|
1048
2384
|
loaders = /* @__PURE__ */ new Map();
|
|
1049
2385
|
processorSchemas = /* @__PURE__ */ new Map();
|
|
1050
|
-
constructor(e = [], t =
|
|
1051
|
-
for (let t of [...
|
|
2386
|
+
constructor(e = [], t = W.catalog_id) {
|
|
2387
|
+
for (let t of [...jt, ...e]) {
|
|
1052
2388
|
let e = structuredClone(t.schema), n = e.catalogId;
|
|
1053
2389
|
if (typeof n != "string" || !n.trim() || !e.components || typeof e.components != "object") throw Error("A2UI 目录缺少身份或组件 Schema。");
|
|
1054
|
-
let r =
|
|
2390
|
+
let r = K(e), i = this.entries.get(n);
|
|
1055
2391
|
if (i) {
|
|
1056
|
-
if (i.digest !== r || i.loadRenderer !== t.loadRenderer || i.historyAdapter !== t.historyAdapter ||
|
|
2392
|
+
if (i.digest !== r || i.loadRenderer !== t.loadRenderer || i.historyAdapter !== t.historyAdapter || K(i.resources) !== K(t.resources || []) || K(i.inputComponents) !== K(t.inputComponents || [])) throw Error("A2UI 目录身份存在冲突。");
|
|
1057
2393
|
continue;
|
|
1058
2394
|
}
|
|
1059
2395
|
let a = structuredClone(t.resources || []);
|
|
@@ -1065,31 +2401,31 @@ var L = [{
|
|
|
1065
2401
|
inputComponents: Object.freeze([...t.inputComponents || []])
|
|
1066
2402
|
}));
|
|
1067
2403
|
}
|
|
1068
|
-
let n = new
|
|
2404
|
+
let n = new f({
|
|
1069
2405
|
strict: !1,
|
|
1070
2406
|
allErrors: !0,
|
|
1071
2407
|
logger: !1
|
|
1072
2408
|
});
|
|
1073
|
-
|
|
2409
|
+
m(n);
|
|
1074
2410
|
let r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
1075
2411
|
let t = e.$id ?? e.catalogId;
|
|
1076
2412
|
if (typeof t != "string" || !t) throw Error("离线 A2UI Schema 缺少 $id。");
|
|
1077
|
-
if (r.has(t) &&
|
|
2413
|
+
if (r.has(t) && K(r.get(t)) !== K(e)) throw Error("离线 A2UI Schema 身份存在冲突。");
|
|
1078
2414
|
r.set(t, e);
|
|
1079
2415
|
};
|
|
1080
|
-
i(
|
|
2416
|
+
i(wt);
|
|
1081
2417
|
for (let e of this.entries.values()) {
|
|
1082
2418
|
i(e.schema);
|
|
1083
2419
|
for (let t of e.resources || []) i(t);
|
|
1084
2420
|
}
|
|
1085
|
-
for (let e of Object.keys(
|
|
1086
|
-
...
|
|
2421
|
+
for (let e of Object.keys(W.schema_resolution_aliases)) i({
|
|
2422
|
+
...U,
|
|
1087
2423
|
$id: e
|
|
1088
2424
|
});
|
|
1089
2425
|
for (let [e, t] of r) n.addSchema(t, e);
|
|
1090
2426
|
for (let [e, t] of this.entries) {
|
|
1091
2427
|
let r = String(t.schema.$id || e);
|
|
1092
|
-
this.validators.set(e, new Map(Object.keys(t.schema.components).map((e) => [e, n.getSchema(`${r}#/components/${e}`)]))), this.processorSchemas.set(e,
|
|
2428
|
+
this.validators.set(e, new Map(Object.keys(t.schema.components).map((e) => [e, n.getSchema(`${r}#/components/${e}`)]))), this.processorSchemas.set(e, At(t.schema, (e) => n.getSchema(e)?.schema));
|
|
1093
2429
|
}
|
|
1094
2430
|
if (!this.entries.has(t)) throw Error("默认 A2UI 目录未注册。");
|
|
1095
2431
|
this.defaultCatalogId = t;
|
|
@@ -1119,9 +2455,9 @@ var L = [{
|
|
|
1119
2455
|
}
|
|
1120
2456
|
validateMessages(e) {
|
|
1121
2457
|
if (!e.length || e.length > 4096 || new TextEncoder().encode(JSON.stringify(e)).length > 1048576) throw Error("A2UI 消息无效或超过展示预算。");
|
|
1122
|
-
let t = new
|
|
1123
|
-
let t =
|
|
1124
|
-
return new
|
|
2458
|
+
let t = new ne([...this.processorSchemas.values()].map((e) => {
|
|
2459
|
+
let t = g.fromSchema(e, "0.9");
|
|
2460
|
+
return new g(t.id, t.protocolVersion, [...t.components.values()], [...t.functions.values()].map((e) => re(e, () => {
|
|
1125
2461
|
throw Error("校验过程不能执行 A2UI 函数。");
|
|
1126
2462
|
})), t.themeSchema, t.instructions);
|
|
1127
2463
|
}), void 0, {
|
|
@@ -1178,37 +2514,25 @@ var L = [{
|
|
|
1178
2514
|
}));
|
|
1179
2515
|
}
|
|
1180
2516
|
};
|
|
1181
|
-
function
|
|
1182
|
-
return new
|
|
1183
|
-
}
|
|
1184
|
-
var B = z(), V = r(B);
|
|
1185
|
-
function ge({ registry: e, children: t }) {
|
|
1186
|
-
return /* @__PURE__ */ o(V.Provider, {
|
|
1187
|
-
value: e,
|
|
1188
|
-
children: t
|
|
1189
|
-
});
|
|
2517
|
+
function Mt(e = [], t = {}) {
|
|
2518
|
+
return new J(e, t.defaultCatalogId);
|
|
1190
2519
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
2520
|
+
var Y = Mt(), Nt = "0.9.1";
|
|
2521
|
+
function Pt(e) {
|
|
2522
|
+
return K(e);
|
|
1193
2523
|
}
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
function ye(e) {
|
|
1198
|
-
return N(e);
|
|
1199
|
-
}
|
|
1200
|
-
function H(e, t = B) {
|
|
1201
|
-
if (!e) return U(null);
|
|
1202
|
-
if (e.wireVersion !== "0.9.1" || !e.messages || e.messages.length === 0) return U(e);
|
|
2524
|
+
function Ft(e, t = Y) {
|
|
2525
|
+
if (!e) return X(null);
|
|
2526
|
+
if (e.wireVersion !== "0.9.1" || !e.messages || e.messages.length === 0) return X(e);
|
|
1203
2527
|
try {
|
|
1204
|
-
let n = t instanceof
|
|
2528
|
+
let n = t instanceof J ? t : Y, r = new Set(e.messages.flatMap((e) => {
|
|
1205
2529
|
let t = e.createSurface;
|
|
1206
2530
|
return t?.catalogId ? [t.catalogId] : [];
|
|
1207
2531
|
}));
|
|
1208
2532
|
if (r.size !== 1) return "json-schema-form";
|
|
1209
2533
|
let i = n.get([...r][0]);
|
|
1210
2534
|
if (!i) return "json-schema-form";
|
|
1211
|
-
let a = t instanceof
|
|
2535
|
+
let a = t instanceof J ? i.digest : Pt(t), o = [...r][0] === G.catalogId && e.catalogDigest === W.catalog_digest;
|
|
1212
2536
|
if (!e.catalogDigest || e.catalogDigest !== a && !o) return "json-schema-form";
|
|
1213
2537
|
n.validateMessages(e.messages).dispose();
|
|
1214
2538
|
} catch {
|
|
@@ -1216,320 +2540,244 @@ function H(e, t = B) {
|
|
|
1216
2540
|
}
|
|
1217
2541
|
return "a2ui";
|
|
1218
2542
|
}
|
|
1219
|
-
function
|
|
1220
|
-
return e &&
|
|
2543
|
+
function X(e) {
|
|
2544
|
+
return e && It(e) ? "json-schema-form" : "basic-controls";
|
|
1221
2545
|
}
|
|
1222
|
-
function
|
|
2546
|
+
function It(e) {
|
|
1223
2547
|
return e.messages.some((e) => {
|
|
1224
2548
|
let t = e.inputSchema ?? e.input_schema ?? e.schema;
|
|
1225
2549
|
return typeof t == "object" && !!t;
|
|
1226
2550
|
});
|
|
1227
2551
|
}
|
|
1228
|
-
function
|
|
2552
|
+
function Lt(e, t = Y) {
|
|
1229
2553
|
let n = e.kind === "approval" ? e.presentation?.a2ui : null;
|
|
1230
|
-
return n &&
|
|
2554
|
+
return n && Ft(n, t) === "a2ui" ? n : null;
|
|
1231
2555
|
}
|
|
1232
2556
|
//#endregion
|
|
1233
|
-
//#region src/core/interaction/
|
|
1234
|
-
var
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
]
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
}).join(", ")})`;
|
|
1254
|
-
}
|
|
1255
|
-
var Ee = {
|
|
1256
|
-
$schema: "http://json-schema.org/draft-06/schema#",
|
|
1257
|
-
$id: "http://json-schema.org/draft-06/schema#",
|
|
1258
|
-
title: "Core schema meta-schema",
|
|
1259
|
-
definitions: {
|
|
1260
|
-
schemaArray: {
|
|
1261
|
-
type: "array",
|
|
1262
|
-
minItems: 1,
|
|
1263
|
-
items: { $ref: "#" }
|
|
1264
|
-
},
|
|
1265
|
-
nonNegativeInteger: {
|
|
1266
|
-
type: "integer",
|
|
1267
|
-
minimum: 0
|
|
1268
|
-
},
|
|
1269
|
-
nonNegativeIntegerDefault0: { allOf: [{ $ref: "#/definitions/nonNegativeInteger" }, { default: 0 }] },
|
|
1270
|
-
simpleTypes: { enum: [
|
|
1271
|
-
"array",
|
|
1272
|
-
"boolean",
|
|
1273
|
-
"integer",
|
|
1274
|
-
"null",
|
|
1275
|
-
"number",
|
|
1276
|
-
"object",
|
|
1277
|
-
"string"
|
|
1278
|
-
] },
|
|
1279
|
-
stringArray: {
|
|
1280
|
-
type: "array",
|
|
1281
|
-
items: { type: "string" },
|
|
1282
|
-
uniqueItems: !0,
|
|
1283
|
-
default: []
|
|
2557
|
+
//#region src/core/interaction/legacy-history.ts
|
|
2558
|
+
var Z = (e) => typeof e == "string" && e ? e : void 0;
|
|
2559
|
+
function Rt(e, t, n) {
|
|
2560
|
+
for (let r of n) {
|
|
2561
|
+
if (r.agentBlock && Rt(e, t, r.agentBlock.messages), r.eventType === "conversation_item_v1") continue;
|
|
2562
|
+
let n = Object.values(r.tools || {}), i = [...n];
|
|
2563
|
+
for (let e of r.blocks || []) {
|
|
2564
|
+
if (e.type !== "tool" || !Z(e.extra?.approvalRequestId)) continue;
|
|
2565
|
+
let t = e.extra || {}, r = n.find((e) => e.approvalRequestId === t.approvalRequestId);
|
|
2566
|
+
i.push({
|
|
2567
|
+
...r,
|
|
2568
|
+
name: e.toolName,
|
|
2569
|
+
args: e.args,
|
|
2570
|
+
status: e.status,
|
|
2571
|
+
approvalRequestId: Z(t.approvalRequestId),
|
|
2572
|
+
approvalStatus: Z(t.approvalStatus) || r?.approvalStatus,
|
|
2573
|
+
approvalProtocol: Z(t.approvalProtocol) || r?.approvalProtocol,
|
|
2574
|
+
approvalMessage: Z(t.approvalMessage) || r?.approvalMessage,
|
|
2575
|
+
previousResponseId: Z(t.previousResponseId) || r?.previousResponseId
|
|
2576
|
+
});
|
|
1284
2577
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1317
|
-
pattern: {
|
|
1318
|
-
type: "string",
|
|
1319
|
-
format: "regex"
|
|
1320
|
-
},
|
|
1321
|
-
additionalItems: { $ref: "#" },
|
|
1322
|
-
items: {
|
|
1323
|
-
anyOf: [{ $ref: "#" }, { $ref: "#/definitions/schemaArray" }],
|
|
1324
|
-
default: {}
|
|
1325
|
-
},
|
|
1326
|
-
maxItems: { $ref: "#/definitions/nonNegativeInteger" },
|
|
1327
|
-
minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1328
|
-
uniqueItems: {
|
|
1329
|
-
type: "boolean",
|
|
1330
|
-
default: !1
|
|
1331
|
-
},
|
|
1332
|
-
contains: { $ref: "#" },
|
|
1333
|
-
maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
|
|
1334
|
-
minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
1335
|
-
required: { $ref: "#/definitions/stringArray" },
|
|
1336
|
-
additionalProperties: { $ref: "#" },
|
|
1337
|
-
definitions: {
|
|
1338
|
-
type: "object",
|
|
1339
|
-
additionalProperties: { $ref: "#" },
|
|
1340
|
-
default: {}
|
|
1341
|
-
},
|
|
1342
|
-
properties: {
|
|
1343
|
-
type: "object",
|
|
1344
|
-
additionalProperties: { $ref: "#" },
|
|
1345
|
-
default: {}
|
|
1346
|
-
},
|
|
1347
|
-
patternProperties: {
|
|
1348
|
-
type: "object",
|
|
1349
|
-
additionalProperties: { $ref: "#" },
|
|
1350
|
-
default: {}
|
|
1351
|
-
},
|
|
1352
|
-
dependencies: {
|
|
1353
|
-
type: "object",
|
|
1354
|
-
additionalProperties: { anyOf: [{ $ref: "#" }, { $ref: "#/definitions/stringArray" }] }
|
|
1355
|
-
},
|
|
1356
|
-
propertyNames: { $ref: "#" },
|
|
1357
|
-
const: {},
|
|
1358
|
-
enum: {
|
|
1359
|
-
type: "array",
|
|
1360
|
-
minItems: 1,
|
|
1361
|
-
uniqueItems: !0
|
|
1362
|
-
},
|
|
1363
|
-
type: { anyOf: [{ $ref: "#/definitions/simpleTypes" }, {
|
|
1364
|
-
type: "array",
|
|
1365
|
-
items: { $ref: "#/definitions/simpleTypes" },
|
|
1366
|
-
minItems: 1,
|
|
1367
|
-
uniqueItems: !0
|
|
1368
|
-
}] },
|
|
1369
|
-
format: { type: "string" },
|
|
1370
|
-
allOf: { $ref: "#/definitions/schemaArray" },
|
|
1371
|
-
anyOf: { $ref: "#/definitions/schemaArray" },
|
|
1372
|
-
oneOf: { $ref: "#/definitions/schemaArray" },
|
|
1373
|
-
not: { $ref: "#" }
|
|
1374
|
-
},
|
|
1375
|
-
default: {}
|
|
1376
|
-
}, W = /* @__PURE__ */ new Map();
|
|
1377
|
-
function G(e) {
|
|
1378
|
-
n(e);
|
|
1379
|
-
let t = JSON.stringify(e), r = W.get(t);
|
|
1380
|
-
if (r) return r;
|
|
1381
|
-
let i = String(e.$schema || "https://json-schema.org/draft/2020-12/schema"), a = {
|
|
1382
|
-
strict: !1,
|
|
1383
|
-
allErrors: !0,
|
|
1384
|
-
coerceTypes: !1,
|
|
1385
|
-
useDefaults: !1,
|
|
1386
|
-
removeAdditional: !1,
|
|
1387
|
-
ownProperties: !0,
|
|
1388
|
-
logger: !1
|
|
1389
|
-
}, o = /draft-04/.test(i) ? new ie(a) : /draft-0[67]/.test(i) ? new ne(a) : /2019-09/.test(i) ? new re(a) : /2020-12/.test(i) ? new s(a) : null;
|
|
1390
|
-
if (!o) throw TypeError("Unsupported JSON Schema dialect");
|
|
1391
|
-
/draft-06/.test(i) && o.addMetaSchema(Ee), c(o);
|
|
1392
|
-
let l = o.compile(e);
|
|
1393
|
-
if ("$async" in l && l.$async) throw TypeError("Async schemas are not supported");
|
|
1394
|
-
W.size >= 128 && W.delete(W.keys().next().value);
|
|
1395
|
-
let u = typeof e.$id == "string" ? e.$id.replace(/#$/, "") : typeof e.id == "string" ? e.id.replace(/#$/, "") : "", d = {
|
|
1396
|
-
root: l,
|
|
1397
|
-
at: (e, t) => !!(e === "" ? l : o.getSchema(`${u}#${e}`))?.(t)
|
|
1398
|
-
};
|
|
1399
|
-
return W.set(t, d), d;
|
|
2578
|
+
for (let n of i) {
|
|
2579
|
+
let i = n.approvalRequestId, a = n.approvalProtocol, o = n.approvalStatus || (n.status === "paused" ? "pending" : void 0);
|
|
2580
|
+
if (!i || !o || ![
|
|
2581
|
+
"pending",
|
|
2582
|
+
"approved",
|
|
2583
|
+
"rejected",
|
|
2584
|
+
"cancelled"
|
|
2585
|
+
].includes(o) || a !== "responses" && a !== "ag-ui") continue;
|
|
2586
|
+
let s = e.get(t, i);
|
|
2587
|
+
if (s && (s.source === "interaction_v1" || k(s.status))) continue;
|
|
2588
|
+
let c = {
|
|
2589
|
+
sessionId: t,
|
|
2590
|
+
runId: r.runId || r.invocationId,
|
|
2591
|
+
name: n.name,
|
|
2592
|
+
message: n.approvalMessage,
|
|
2593
|
+
args: n.args,
|
|
2594
|
+
previousResponseId: n.previousResponseId || r.responseId
|
|
2595
|
+
}, l = a === "ag-ui" ? B({
|
|
2596
|
+
...c,
|
|
2597
|
+
interruptId: i,
|
|
2598
|
+
toolCallId: n.callId
|
|
2599
|
+
}) : z({
|
|
2600
|
+
...c,
|
|
2601
|
+
approvalRequestId: i
|
|
2602
|
+
});
|
|
2603
|
+
l && (l.revision = s?.revision || l.revision, l.createdAt = s?.createdAt || l.createdAt, l.runId = s?.runId || l.runId, l.extensions = {
|
|
2604
|
+
...l.extensions,
|
|
2605
|
+
...s?.extensions
|
|
2606
|
+
}, o !== "pending" && (l.status = o === "cancelled" ? "cancelled" : "resolved", l.outcome = o), e.upsert(l));
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
1400
2609
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
2610
|
+
//#endregion
|
|
2611
|
+
//#region src/core/interaction/adapters/legacy-runtime-events.ts
|
|
2612
|
+
function Q(e) {
|
|
2613
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
1403
2614
|
}
|
|
1404
|
-
function
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
2615
|
+
function zt(e, t) {
|
|
2616
|
+
let n = Q(e), r = Q(Q(n?.Content)?.runtime_event);
|
|
2617
|
+
if (!r || r.schema_version !== 2 || r.interaction_kind !== "approval") return null;
|
|
2618
|
+
let i = Q(r.source);
|
|
2619
|
+
if (![
|
|
2620
|
+
"langgraph",
|
|
2621
|
+
"langchain",
|
|
2622
|
+
"deepagents"
|
|
2623
|
+
].includes(String(i?.framework))) return null;
|
|
2624
|
+
let a = String(n?.SessionId || t || ""), o = typeof r.interaction_id == "string" ? r.interaction_id : "";
|
|
2625
|
+
if (!a || !o) return null;
|
|
2626
|
+
let s = Q(r.request), c = Q(s?.detail), l = Q(r.response), u = r.event_type === "interaction.requested", d = r.event_type === "interaction.resolved";
|
|
2627
|
+
if (u && (s?.request_type !== "approval" || c?.approval_request_id !== o) || !u && (!d || l?.response_type !== "approval")) return null;
|
|
2628
|
+
let f = Q((Array.isArray(c?.action_requests) ? c.action_requests : [])[0]), p = c?.arguments ?? f?.args, m = Q(i?.metadata), h = z({
|
|
2629
|
+
approvalRequestId: o,
|
|
2630
|
+
sessionId: a,
|
|
2631
|
+
runId: String(r.run_id || n?.InvocationId || "") || void 0,
|
|
2632
|
+
name: String(c?.tool_name || f?.name || "") || void 0,
|
|
2633
|
+
message: typeof c?.description == "string" ? c.description : void 0,
|
|
2634
|
+
args: p === void 0 ? void 0 : typeof p == "string" ? p : JSON.stringify(p),
|
|
2635
|
+
previousResponseId: typeof m?.response_id == "string" ? m.response_id : void 0
|
|
2636
|
+
});
|
|
2637
|
+
if (!h) return null;
|
|
2638
|
+
if (h.createdAt = String(r.timestamp ?? n?.Timestamp ?? h.createdAt), d) {
|
|
2639
|
+
let e = l?.decision;
|
|
2640
|
+
if (e !== "approved" && e !== "rejected" && e !== "canceled") return null;
|
|
2641
|
+
h.status = e === "canceled" ? "cancelled" : "resolved", h.outcome = e === "canceled" ? "cancelled" : e, h.resolvedAt = h.createdAt;
|
|
1417
2642
|
}
|
|
2643
|
+
return h;
|
|
1418
2644
|
}
|
|
1419
2645
|
//#endregion
|
|
1420
|
-
//#region src/core/interaction/
|
|
1421
|
-
var
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
2646
|
+
//#region src/core/interaction/index.ts
|
|
2647
|
+
var Bt = new Set([
|
|
2648
|
+
"completed",
|
|
2649
|
+
"failed",
|
|
2650
|
+
"error",
|
|
2651
|
+
"cancelled",
|
|
2652
|
+
"canceled",
|
|
2653
|
+
"aborted",
|
|
2654
|
+
"resume_failed"
|
|
2655
|
+
]), $ = new A();
|
|
2656
|
+
function Vt(e, t) {
|
|
2657
|
+
Rt($, t, e);
|
|
1427
2658
|
}
|
|
1428
|
-
function
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
} catch {
|
|
1441
|
-
throw new q();
|
|
2659
|
+
function Ht(e, t) {
|
|
2660
|
+
let n = xt(e, t) ?? zt(e, t);
|
|
2661
|
+
n && $.upsert(n);
|
|
2662
|
+
let r = typeof e == "object" && e ? e : null;
|
|
2663
|
+
if (r?.EventType === "control.command_rejected") {
|
|
2664
|
+
let e = r.Content;
|
|
2665
|
+
$.rejectCommand(String(r.SessionId || t || ""), String(e?.command_id || ""), String(e?.reason || "command_rejected"));
|
|
2666
|
+
}
|
|
2667
|
+
let a = r ? i(r) : null;
|
|
2668
|
+
if (a !== null && Bt.has(a)) {
|
|
2669
|
+
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 || "");
|
|
2670
|
+
$.markRunTerminal(i, a);
|
|
1442
2671
|
}
|
|
2672
|
+
return n;
|
|
1443
2673
|
}
|
|
1444
|
-
function
|
|
1445
|
-
let
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
2674
|
+
function Ut(e) {
|
|
2675
|
+
let t = e.sessionId || "";
|
|
2676
|
+
if (!t || !e.approvalRequestId) return null;
|
|
2677
|
+
let n = e.protocol === "ag-ui" ? B({
|
|
2678
|
+
interruptId: e.approvalRequestId,
|
|
2679
|
+
sessionId: t,
|
|
2680
|
+
runId: e.runId,
|
|
2681
|
+
name: e.name,
|
|
2682
|
+
message: e.message,
|
|
2683
|
+
reason: e.approvalLevel,
|
|
2684
|
+
requestSchema: e.requestSchema
|
|
2685
|
+
}) : z({
|
|
2686
|
+
approvalRequestId: e.approvalRequestId,
|
|
2687
|
+
sessionId: t,
|
|
2688
|
+
runId: e.runId,
|
|
2689
|
+
name: e.name,
|
|
2690
|
+
message: e.message,
|
|
2691
|
+
args: e.args,
|
|
2692
|
+
approvalLevel: e.approvalLevel,
|
|
2693
|
+
previousResponseId: e.previousResponseId
|
|
2694
|
+
});
|
|
2695
|
+
return n && $.upsert(n), n;
|
|
2696
|
+
}
|
|
2697
|
+
function Wt(e) {
|
|
2698
|
+
let t = e.sessionId || "";
|
|
2699
|
+
if (!t || !e.questionId) return null;
|
|
2700
|
+
let n = Ct({
|
|
2701
|
+
questionId: e.questionId,
|
|
2702
|
+
sessionId: t,
|
|
2703
|
+
runId: e.runId,
|
|
2704
|
+
questions: e.questions
|
|
2705
|
+
});
|
|
2706
|
+
return n && $.upsert(n), n;
|
|
2707
|
+
}
|
|
2708
|
+
function Gt(e) {
|
|
2709
|
+
let t = e.sessionId || "";
|
|
2710
|
+
if (!t || !e.questionId) return null;
|
|
2711
|
+
let n = $.get(t, e.questionId);
|
|
2712
|
+
if (!n) return null;
|
|
2713
|
+
let r = e.answers && typeof e.answers == "object" ? e.answers : {};
|
|
2714
|
+
return $.upsert({
|
|
2715
|
+
...n,
|
|
2716
|
+
status: "resolved",
|
|
2717
|
+
revision: e.revision ?? n.revision + 1,
|
|
2718
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2719
|
+
outcome: "submitted",
|
|
2720
|
+
responseSummary: JSON.stringify(r).slice(0, 200),
|
|
2721
|
+
extensions: {
|
|
2722
|
+
...n.extensions,
|
|
2723
|
+
answers: r
|
|
1470
2724
|
}
|
|
1471
|
-
}
|
|
1472
|
-
return [...r];
|
|
2725
|
+
}), $.get(t, e.questionId);
|
|
1473
2726
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
2727
|
+
function Kt(e) {
|
|
2728
|
+
let t = e.sessionId || "";
|
|
2729
|
+
if (!t || !e.approvalRequestId) return null;
|
|
2730
|
+
let n = $.get(t, e.approvalRequestId);
|
|
2731
|
+
return n?.source === "agui" && n.kind === "structured_input" ? k(n.status) ? n : ($.resolveLocally(t, n.interactionId, {
|
|
2732
|
+
status: e.decision === "cancelled" ? "cancelled" : "resolved",
|
|
2733
|
+
outcome: e.decision === "cancelled" ? "cancelled" : "submitted",
|
|
2734
|
+
revision: e.revision || 2,
|
|
2735
|
+
actor: "user"
|
|
2736
|
+
}), $.get(t, n.interactionId)) : Ht({
|
|
2737
|
+
EventType: "approval.resolved",
|
|
2738
|
+
Content: {
|
|
2739
|
+
approvalId: e.approvalRequestId,
|
|
2740
|
+
revision: e.revision || 2,
|
|
2741
|
+
outcome: e.decision,
|
|
2742
|
+
actor: "user",
|
|
2743
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2744
|
+
}
|
|
2745
|
+
}, t);
|
|
1481
2746
|
}
|
|
1482
|
-
function
|
|
1483
|
-
let
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
for (let e of o) {
|
|
1490
|
-
let r = Array.isArray(e.prefixItems) ? e.prefixItems : void 0, i = Array.isArray(e.items) ? e.items : void 0;
|
|
1491
|
-
n.push(r && t < r.length ? r[t] : i ? t < i.length ? i[t] : e.additionalItems ?? {} : e.items ?? {});
|
|
1492
|
-
for (let t of ["contains", "unevaluatedItems"]) Object.hasOwn(e, t) && n.push(e[t]);
|
|
1493
|
-
}
|
|
1494
|
-
return i(n, e, a + 1);
|
|
1495
|
-
}) : typeof n != "object" || !n ? n : Object.fromEntries(Object.entries(n).map(([e, t]) => {
|
|
1496
|
-
let n = [];
|
|
1497
|
-
for (let t of o) {
|
|
1498
|
-
let r = K(t.properties), i = !!(r && Object.hasOwn(r, e));
|
|
1499
|
-
i && n.push(r[e]);
|
|
1500
|
-
for (let [r, a] of Object.entries(K(t.patternProperties) || {})) new RegExp(r).test(e) && (i = !0, n.push(a));
|
|
1501
|
-
!i && Object.hasOwn(t, "additionalProperties") && n.push(t.additionalProperties), Object.hasOwn(t, "unevaluatedProperties") && n.push(t.unevaluatedProperties);
|
|
1502
|
-
}
|
|
1503
|
-
return [e, i(n, t, a + 1)];
|
|
1504
|
-
}));
|
|
1505
|
-
}
|
|
1506
|
-
try {
|
|
1507
|
-
return n(t), i([e], t, 0);
|
|
1508
|
-
} catch {
|
|
1509
|
-
return null;
|
|
1510
|
-
}
|
|
2747
|
+
function qt(e) {
|
|
2748
|
+
let t = $.get(e.sessionId || "", e.interactionId);
|
|
2749
|
+
!t || t.source !== "agui" || k(t.status) || $.markFailed(t.sessionId, t.interactionId, {
|
|
2750
|
+
code: "input_response_invalid",
|
|
2751
|
+
message: e.message,
|
|
2752
|
+
retryable: !0
|
|
2753
|
+
});
|
|
1511
2754
|
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
2755
|
+
//#endregion
|
|
2756
|
+
//#region src/core/a2ui/provider.tsx
|
|
2757
|
+
var Jt = a(Y);
|
|
2758
|
+
function Yt({ registry: e, children: t }) {
|
|
2759
|
+
return /* @__PURE__ */ c(Jt.Provider, {
|
|
2760
|
+
value: e,
|
|
2761
|
+
children: t
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
function Xt() {
|
|
2765
|
+
return o(Jt);
|
|
1518
2766
|
}
|
|
1519
2767
|
//#endregion
|
|
1520
2768
|
//#region src/core/run/a2ui.ts
|
|
1521
|
-
var
|
|
2769
|
+
var Zt = {
|
|
1522
2770
|
description: "A2UI Component Schema — available components for generating UI surfaces. Use these component names and properties when creating A2UI operations.",
|
|
1523
2771
|
value: JSON.stringify({
|
|
1524
|
-
...
|
|
1525
|
-
ksadkManifest:
|
|
2772
|
+
...U,
|
|
2773
|
+
ksadkManifest: W
|
|
1526
2774
|
})
|
|
1527
2775
|
};
|
|
1528
|
-
function
|
|
1529
|
-
if (e ===
|
|
2776
|
+
function Qt(e = Y) {
|
|
2777
|
+
if (e === Y) return Zt;
|
|
1530
2778
|
let t = e.get(e.defaultCatalogId);
|
|
1531
2779
|
return {
|
|
1532
|
-
description:
|
|
2780
|
+
description: Zt.description,
|
|
1533
2781
|
value: JSON.stringify({
|
|
1534
2782
|
...t.schema,
|
|
1535
2783
|
ksadkResources: t.resources,
|
|
@@ -1541,7 +2789,7 @@ function je(e = B) {
|
|
|
1541
2789
|
})
|
|
1542
2790
|
};
|
|
1543
2791
|
}
|
|
1544
|
-
function
|
|
2792
|
+
function $t(e) {
|
|
1545
2793
|
return e.map((e) => {
|
|
1546
2794
|
let t = e.updateComponents;
|
|
1547
2795
|
if (!t || typeof t != "object" || Array.isArray(t)) return e;
|
|
@@ -1564,7 +2812,7 @@ function Me(e) {
|
|
|
1564
2812
|
};
|
|
1565
2813
|
});
|
|
1566
2814
|
}
|
|
1567
|
-
function
|
|
2815
|
+
function en(e) {
|
|
1568
2816
|
for (let t of e) {
|
|
1569
2817
|
let e = t.updateComponents?.components;
|
|
1570
2818
|
if (!Array.isArray(e) || !e.some((e) => e.component === "Form" && e.id === "form")) continue;
|
|
@@ -1574,4 +2822,4 @@ function Ne(e) {
|
|
|
1574
2822
|
return null;
|
|
1575
2823
|
}
|
|
1576
2824
|
//#endregion
|
|
1577
|
-
export {
|
|
2825
|
+
export { se as $, $e as A, Oe as B, gt as C, rt as D, dt as E, Ve as F, C as G, be as H, k as I, me as J, Ce as K, ze as L, M, Qe as N, j as O, A as P, le as Q, Re as R, xt as S, vt as T, xe as U, Se as V, we as W, de as X, _e as Y, b as Z, Mt as _, Xt as a, B as b, qt as c, Gt as d, ae as et, Ht as f, Lt as g, Ft as h, Yt as i, Ke as j, Ge as k, Vt as l, Nt as m, en as n, Ut as o, $ as p, De as q, $t as r, Kt as s, Qt as t, Wt as u, Y as v, _t as w, z as x, G as y, T as z };
|