@ensocode/server 0.3.13 → 0.3.14
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/out/phone/assets/{EditDiff-B3HxLrbF.js → EditDiff-7At9BpWJ.js} +1 -1
- package/out/phone/assets/{ReadFileView-BFpGH-kK.js → ReadFileView-CFkjh0Xx.js} +1 -1
- package/out/phone/assets/{abnfDiagram-VCTEODGH-BNvyPGoF.js → abnfDiagram-VCTEODGH-D4384sfe.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-vDamN_Vr.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-1bhpTEFA.js → architectureDiagram-5GKGNRK7-CjzMXFHb.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-Bo9UMudu.js → blockDiagram-I7D4REHJ-COX4_2NT.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-YS11cig2.js → c4Diagram-7LVT6UL2-C0PHCrzg.js} +1 -1
- package/out/phone/assets/channel-TsMJYH0f.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-gA-CzNGD.js → chunk-4HAMMTFA-BSqiGn28.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-BL_5b1Dw.js → chunk-75Z2AOVW-7eocu_Pa.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-BpNlAs9R.js → chunk-DU6HZSFF-DMttOQUE.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-lsKx96Nt.js → chunk-F27PBJKO-BFNRrOvq.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW-CxbljbtE.js → chunk-GMAD6QVW-DPVV1Shj.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-CTO3kTOF.js → chunk-GVQU2GXP-YataTcA_.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-Cq8XlkcB.js → chunk-IMKFNOWR-DBQKd74U.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-CvIm0JX7.js → chunk-L3NEJ4N5-DXfrfXkv.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-Cj3ilTL-.js → chunk-OSK3NFVY-DWr7pP6Q.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-B-twI_Fz.js → chunk-P2QGCYS3-C_qNKS0g.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-lPQttJ5s.js → chunk-POPQ4Y6H-BhJK3UtM.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-DjwqZuIR.js → chunk-PWAF6VOD-MmcwGVgC.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BWRVin1H.js → chunk-SHT3W25Y-BQHA3p2Q.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-CGLhvnsS.js → chunk-SVP7TREG-DbQH56Ci.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-DkFUa03q.js → chunk-TICWLB2K-pixKba1z.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-Bhtnzu97.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-Bhtnzu97.js +1 -0
- package/out/phone/assets/{codeHighlighter-jQti-W31.js → codeHighlighter-CrZcFhK_.js} +1 -1
- package/out/phone/assets/{cynefin-OW5HDTMX-L8oWVu5S.js → cynefin-OW5HDTMX-67ETi-0P.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-DH8-4p4N.js → cynefinDiagram-5FMLGOSQ-C3wqlm_-.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-HhLDmcu9.js → dagre-GXQ25YYZ-DTC1fZsc.js} +1 -1
- package/out/phone/assets/desk-B382G0e_.js +52 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-CeIbR3Ir.js → diagram-S7CK7UJ4-uqcU7OpS.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-BQ84Qnq6.js → diagram-UQ7AKVKN-BQ6K9f6g.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-aF_J57fD.js → diagram-VSXAHHWV-CDzRWkI9.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-Bg1ZqM4Y.js → diagram-VX7I27RA-CvI10CG1.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-DjTkPAqa.js → diagram-Z3DM3KII-DM8G_CIZ.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-DPsH5Eky.js → ebnfDiagram-PWID7BFC-BBbLoaIE.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-ExvY7e6T.js → erDiagram-RLTQ6QDP-Dz98FGLq.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-BGT2L4_J.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-CpTX9nm5.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-hCe06ucl.js → ganttDiagram-EL5Y4UJY-BADRjlHl.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-BuZ6lDat.js → gitGraph-4MIJSDKK-DQGKRsA2.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-D-8aVxvj.js → gitGraphDiagram-WWUBYQGX-DrLRujhH.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-CrZtdoYs.js → info-A6RAGUB7-b7IbwKqs.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-BLRFHxtO.js → infoDiagram-27XIBGKW-BNbXaMmR.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-D7SYWKoj.js → ishikawaDiagram-5VMMS53U-B3SG131F.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-BPsg7CQD.js → journeyDiagram-3NMN7TZE-BoRfNykb.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-CbPuNr-E.js → kanban-definition-UXKFOSKX-D0tKrJ8_.js} +1 -1
- package/out/phone/assets/{line-CkpKMiqK.js → line-W1HWn4B7.js} +1 -1
- package/out/phone/assets/main-Bc8DQVa6.css +2 -0
- package/out/phone/assets/main-Bez4gfKe.js +281 -0
- package/out/phone/assets/{mermaid-parser.core-RTq_mEm1.js → mermaid-parser.core-CpGE7UgS.js} +3 -3
- package/out/phone/assets/{mermaid.core-D9LtIKua.js → mermaid.core-wueTI3u_.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-8cGgRiRD.js → mindmap-definition-YA3MSWOX-BDctzErY.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-D9-eSn0v.js → packet-AYTQ26CC-C0YWsXol.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-DztU_rIE.js → pegDiagram-XKGWAZYB-C97XjNI7.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-Bk2Tqaq_.js → pie-WAS4IAKB-BxuJ1GKP.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-Dm_3mJ9_.js → pieDiagram-E7YTZNPT-SP4DeWDw.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-lKskzjzu.js → quadrantDiagram-AXDQQJYC-DDHL4rrG.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-B2z8Txd8.js → radar-RG4KPBEZ-AzVB8zoH.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-11VmdALq.js → railroad-74A4TZTK-CA2_A72l.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-CTHhRGvc.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-CS68P4fL.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-BqCcrVdf.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-Dr0NTIA6.js → railroadDiagram-O6MQD6OU-D5zpQ5kq.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-C0W6h_5I.js → requirementDiagram-BXWQKSXE-DkQKt5hJ.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CVJDathY.js → sankeyDiagram-P5KCCOFB-xeXrVMVr.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BxHQTG6x.js → sequenceDiagram-WJ2MYXX4-BOiNtyS8.js} +1 -1
- package/out/phone/assets/shellUpdate-C4yk9AaU.js +1 -0
- package/out/phone/assets/{stateDiagram-D77RDMKH-BO5MAjhs.js → stateDiagram-D77RDMKH-Bs8LX9-n.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-nBP_YibA.js +1 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-DnhDPyy6.js → swimlanes-42K2YHIH-DQVYfgSI.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BkfzXxS-.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-bLEjS7re.js → timeline-definition-24CTP7MA-BlpgdxeN.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-Ci-sA9wK.js → treeView-Q6P3EWNA-D0PiggHr.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-BXCjzK65.js → treemap-WGGIJYW6-DA07Kvo0.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-DHsj5dRx.js → vennDiagram-4TSXK5OY-BtvfF1a4.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-d8TdCu-H.js → wardley-WFR3VGLG-Db-UrSZJ.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-DQFVP9qu.js → wardleyDiagram-VM6X3IG4-CaBnqFYM.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-Dni2Y0ov.js → xychartDiagram-S5SC5T6Z-Bbzz9YwS.js} +1 -1
- package/out/phone/desk.html +3 -3
- package/out/phone/index.html +4 -4
- package/out/phone/sw.js +2 -2
- package/out/renderer/assets/{EditDiff-DxxLuCEI.js → EditDiff-C9JBUR0o.js} +1 -1
- package/out/renderer/assets/{File-Tz3MUtN6.js → File-BIf-onMm.js} +1 -1
- package/out/renderer/assets/{ReadFileView-DFoLPU04.js → ReadFileView-C5AKNlFU.js} +1 -1
- package/out/renderer/assets/{SidePanel-D0m4IYxS.css → SidePanel-DN2RL6QD.css} +1 -1
- package/out/renderer/assets/SidePanel-DkSc3og9.js +48 -0
- package/out/renderer/assets/{Virtualizer-B0uwx_XV.js → Virtualizer-tZu4hGtC.js} +1 -1
- package/out/renderer/assets/{abnfDiagram-VCTEODGH-CJ9nn9eH.js → abnfDiagram-VCTEODGH-DxBBUZxF.js} +1 -1
- package/out/renderer/assets/{arc-B8im8n0O.js → arc-DXzwxP4j.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-BRSi5FBk.js → architectureDiagram-5GKGNRK7-Bcykp-Fb.js} +1 -1
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-CQ1wirIl.js → blockDiagram-I7D4REHJ-P7zMiiL3.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-9HyLIioe.js → c4Diagram-7LVT6UL2-BVD9zEE8.js} +1 -1
- package/out/renderer/assets/channel-7bWV5QTy.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-BwC9g3bx.js → chunk-2Q5K7J3B-BXj05DaP.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-DMtgxPBL.js → chunk-5VM5RSS4-D-SpodcG.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-DSi_XV5v.js → chunk-F27PBJKO-ORLEQ9sv.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-Dctc6Apj.js → chunk-IMKFNOWR-1lhHjr20.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-I2BD5qM7.js → chunk-JWPE2WC7-BgmlC9Vl.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-k60pc4eT.js → chunk-POPQ4Y6H-DPEfkZnH.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-zCGemfqm.js → chunk-SVP7TREG-7_S5Geoi.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-CdDiHIq-.js → chunk-TICWLB2K-BKi8yvLf.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-GYVDxVfN.js → chunk-XXDRQBXY-PfB25f1D.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-mgQwYiWM.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-mgQwYiWM.js +1 -0
- package/out/renderer/assets/{cose-bilkent-JH36ORCC-BnSAtUh-.js → cose-bilkent-JH36ORCC-C246yayw.js} +1 -1
- package/out/renderer/assets/{cynefin-OW5HDTMX-DnQaS9VN.js → cynefin-OW5HDTMX-Dr9W26Pe.js} +1 -1
- package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-BNQdw0PV.js → cynefinDiagram-5FMLGOSQ-B3Jtuns2.js} +1 -1
- package/out/renderer/assets/{cytoscape-fcose-CzkrRInm.js → cytoscape-fcose-CJat50hU.js} +1 -1
- package/out/renderer/assets/{dagre-GXQ25YYZ-fG1vMsyn.js → dagre-GXQ25YYZ-Dt2pulYx.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-BcfAFVc2.js → diagram-S7CK7UJ4-Bx-0FuVR.js} +1 -1
- package/out/renderer/assets/{diagram-UQ7AKVKN-D8f3Tsx9.js → diagram-UQ7AKVKN-D-8o1p4p.js} +1 -1
- package/out/renderer/assets/{diagram-VSXAHHWV-B-U9CIWt.js → diagram-VSXAHHWV-CI0jUOHM.js} +1 -1
- package/out/renderer/assets/{diagram-VX7I27RA-CX6ifTkJ.js → diagram-VX7I27RA-Byl54mOd.js} +1 -1
- package/out/renderer/assets/{diagram-Z3DM3KII-49dS9s3L.js → diagram-Z3DM3KII-Kf_GIJ7p.js} +1 -1
- package/out/renderer/assets/{ebnfDiagram-PWID7BFC-CraGJRI7.js → ebnfDiagram-PWID7BFC-BbOdw7R1.js} +1 -1
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-CfMNvEoW.js → erDiagram-RLTQ6QDP-UjxTTQ7M.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-C8XM3p4T.js → flowDiagram-HODETNUW-BVuwOxKp.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-DlJBMKFX.js → ganttDiagram-EL5Y4UJY-BpBSO-4X.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-DvEzDsKF.js → gitGraphDiagram-WWUBYQGX-b72vZ1j2.js} +1 -1
- package/out/renderer/assets/globals-2G408HiJ.css +1 -0
- package/out/renderer/assets/globals-BqVjlAT_.js +673 -0
- package/out/renderer/assets/index-AHhNcASr.js +113 -0
- package/out/renderer/assets/{infoDiagram-27XIBGKW-CckfBO-R.js → infoDiagram-27XIBGKW-CtnN4sif.js} +1 -1
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-mUoXchkB.js → ishikawaDiagram-5VMMS53U-B2YfGNEH.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-zzLL0HFW.js → journeyDiagram-3NMN7TZE-fUfanA7T.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-BJ_9aIhB.js → kanban-definition-UXKFOSKX-DU0d3NVH.js} +1 -1
- package/out/renderer/assets/{layout-3SRMHY7n.js → layout-C0hE7llw.js} +1 -1
- package/out/renderer/assets/{linear-CWpclK_R.js → linear-BXPh0BlC.js} +1 -1
- package/out/renderer/assets/{manifest-DOzTaB8J.js → manifest-DoBt8euy.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DORpmVi3.js → mermaid.core-DlBAsGZ7.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-CYBlCqIB.js → mindmap-definition-YA3MSWOX-DUIiyta9.js} +1 -1
- package/out/renderer/assets/{pegDiagram-XKGWAZYB-DhWwLs4v.js → pegDiagram-XKGWAZYB-yP15oXPx.js} +1 -1
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-Bzpc57-A.js → pieDiagram-E7YTZNPT-DsaSjWfA.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-spKXEbds.js → quadrantDiagram-AXDQQJYC-BpWn5xT_.js} +1 -1
- package/out/renderer/assets/{railroadDiagram-O6MQD6OU-Br553px3.js → railroadDiagram-O6MQD6OU-BnXhwCom.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-CX-Dqij_.js → requirementDiagram-BXWQKSXE-CMIMPMzx.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-Bgx1W6B9.js → sankeyDiagram-P5KCCOFB-CKqneOc7.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-CKQv6pcU.js → sequenceDiagram-WJ2MYXX4-azbHkcGk.js} +1 -1
- package/out/renderer/assets/{sessionChanges-BLzNhRuv.js → sessionChanges--o0RBCJW.js} +1 -1
- package/out/renderer/assets/settings-D5R80op8.js +28 -0
- package/out/renderer/assets/{sizeCapture-INFHLROL-DtRedfRe.js → sizeCapture-INFHLROL-C3uhIZ1e.js} +1 -1
- package/out/renderer/assets/{stateDiagram-D77RDMKH-CMP5owem.js → stateDiagram-D77RDMKH-CrGab2Ck.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-k_H7O8MU.js +1 -0
- package/out/renderer/assets/{swimlanes-42K2YHIH-D30AvvmW.js → swimlanes-42K2YHIH-6aX1l7C2.js} +1 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-D2XerlPy.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-CsZAMmMZ.js → timeline-definition-24CTP7MA-DdVDUmce.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-COQ7L1f7.js → vennDiagram-4TSXK5OY-DP6DTjdX.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-dqMWLTCs.js → wardleyDiagram-VM6X3IG4-DYJsuZCs.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-DX4clIYP.js → xychartDiagram-S5SC5T6Z-CloAJCw-.js} +1 -1
- package/out/renderer/index.html +3 -3
- package/out/renderer/settings.html +7 -7
- package/out/renderer/web-preload.js +1 -51
- package/out/server/agent.js +1172 -242
- package/out/server/chunks/agentConstants-D4t7d6iS.js +9 -0
- package/out/server/chunks/builtinOccupancy-Ci-Szozb.js +93 -0
- package/out/server/chunks/dispatchModel-DJxnHup9.js +75 -0
- package/out/server/chunks/{gpuBackendInstall-jAzoFq7U.js → gpuBackendInstall-snisWLXN.js} +2 -2
- package/out/server/chunks/killTree-T-p6Lr3w.js +787 -0
- package/out/server/chunks/{loadProvider-NdOVbsHi.js → loadProvider-Uq3i7kKZ.js} +2 -2
- package/out/server/chunks/{manifest-BPXFscqI.js → manifest-CmnE8RBt.js} +4 -2
- package/out/server/chunks/menuSkills-BEtW-Is6.js +53 -0
- package/out/server/chunks/projectCode-D9lgShsp.js +112 -0
- package/out/server/chunks/{registry-BhoHPSKn.js → registry-R2KRdU8n.js} +97 -115
- package/out/server/chunks/sendImage-CCjNsa-D.js +499 -0
- package/out/server/chunks/{sendImage-BCNW9JRV.js → toolParams-DVs5d3F9.js} +25 -234
- package/out/server/chunks/web-BIJOMDlz.js +7773 -0
- package/out/server/chunks/{workflowPresets-C2T1BzA2.js → workflowPresets-DVbQh2el.js} +13603 -15626
- package/out/server/index.js +8778 -3210
- package/out/server/memory-service.js +197 -147
- package/out/server/plugin-host.js +44 -18
- package/package.json +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-Duql1LsL.js +0 -1
- package/out/phone/assets/channel-BPoIHov1.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-CIR76lHP.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-CIR76lHP.js +0 -1
- package/out/phone/assets/desk-CixRGdTk.js +0 -52
- package/out/phone/assets/eventmodeling-NTZA5JFV-DYp-zWcL.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-CIU32By5.js +0 -1
- package/out/phone/assets/main-BCnf7dVM.js +0 -264
- package/out/phone/assets/main-nqB-uD3v.css +0 -2
- package/out/phone/assets/railroad-abnf-HS5TGJTU-BkSycwye.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-BsPIU3iV.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-Cy8G7u5C.js +0 -1
- package/out/phone/assets/shellUpdate-DPSfgHG3.js +0 -36
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-B8IHc2bm.js +0 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-dmSDAN2F.js +0 -8
- package/out/renderer/assets/SidePanel-CL40W2RY.js +0 -47
- package/out/renderer/assets/channel-DjB0ww6b.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-6SiAw1np.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-6SiAw1np.js +0 -1
- package/out/renderer/assets/globals-BFf1P-Y5.js +0 -715
- package/out/renderer/assets/globals-DUBhAVpU.css +0 -1
- package/out/renderer/assets/index-L4TTIP10.js +0 -89
- package/out/renderer/assets/settings-Bsrw4ERp.js +0 -25
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-6-731AqJ.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-B8KijqIT.js +0 -8
- package/out/server/chunks/agent-BbNq8i9j.js +0 -4241
- package/out/server/chunks/dispatchModel-CsfmL396.js +0 -20
package/out/server/agent.js
CHANGED
|
@@ -1,44 +1,49 @@
|
|
|
1
1
|
import path, { join, posix, dirname } from "node:path";
|
|
2
|
-
import { A as AGENT_WORKER_CRASH_FILE,
|
|
3
|
-
import { p as parseChildSessionIdentity, a as parseSessionIdentity,
|
|
4
|
-
import "
|
|
5
|
-
import
|
|
6
|
-
import { i as isCursorModel, a as attachCursorBridgeToSession, b as indexCursorTools, l as loadCursorProvider, C as CURSOR_PROVIDER_ID, c as installPiCursorExecHook } from "./chunks/loadProvider-
|
|
2
|
+
import { A as AGENT_WORKER_CRASH_FILE, a as appendCappedLog, b as AGENT_WORKER_ABORT_LOG, i as isApprovalReviewReason, p as parseApprovalAllowThreshold, c as isProbability, e as emptyUsage, s as shellQuote, d as charsToTokens, t as toolOccupancyText, f as skillOccupancyText, C as CONTEXT_OCCUPANCY_BUCKETS, g as estimateToolTokens, h as estimateSkillTokens, j as estimateInstructionTokens, V as VIRTUAL_PROVIDER_ID, k as providerKeyFor, O as OM_OBSERVATIONS_RECORDED, l as OM_REFLECTIONS_RECORDED, m as isObservationsRecordedData, n as isReflectionsRecordedData, o as isReflectionsConsolidatedData, q as isObservationsDroppedData, r as OM_REFLECTIONS_CONSOLIDATED, u as OM_OBSERVATIONS_DROPPED, v as OM_FOLDED, w as isMemoryDetails, x as isObservationsRecordedEntry, y as isReflectionsRecordedEntry, z as isReflectionsConsolidatedEntry, B as isObservationsDroppedEntry, D as buildObservationsRecordedData, E as buildReflectionsRecordedData, F as buildReflectionsConsolidatedData, G as buildObservationsDroppedData, H as readModelsDevCache, I as version, J as parseProviderHeaders, K as parseModelDirectorySnapshot, M as MODEL_API_KINDS, L as resolvePiProviderBaseUrl, N as findCatalogModelById, P as findModelsDevModel, Q as mergeCatalogEntry, R as resolveCustomModelCapabilities, S as escapePiConfigValue, T as MODEL_REASONING_OVERRIDES, U as MODEL_THINKING_LEVEL_OVERRIDES, W as GOAL_RESULT_SCHEMA, X as parseGoalResult, Y as mcpTimeoutMsOrDefault, Z as oneLine$1, _ as mcpNamespaceName, $ as assignMcpToolNames, a0 as createStdioTransport, a1 as MCP_OAUTH_REFRESH_SKEW_MS, a2 as mcpOAuthFingerprint, a3 as DEFAULT_MCP_CONNECT_TIMEOUT_MS, a4 as DEFAULT_MCP_CALL_TIMEOUT_MS, a5 as isXaiChatModelId, a6 as transcriptMessages, a7 as projectMessage, a8 as isCodexAccountKey, a9 as classifyCodexPoolFailure, aa as ensureAccountProvider, ab as classifyProtectedCommand, ac as programTokens, ad as replacePersonaParagraph, ae as MaskReportBuilder, af as parseReminderFile, ag as REMINDER_LATE_MS, ah as ownedByRoot, ai as rootIdOfReminder, aj as REMINDER_LABEL_MAX, ak as REMINDER_MAX_PER_OWNER, al as REMINDER_MAX_CHAIN, am as REMINDER_PROMPT_MAX, an as REMINDER_MIN_DELAY_MS, ao as takeSnapshotTail, ap as childProfileShell, aq as ELEVATE_ASKPASS_ENV, ar as buildElevatedCommand, as as ELEVATE_DECLINED_MARKER, at as ELEVATE_TIMED_OUT_MARKER, au as ELEVATE_TIMEOUT_MS, av as ELEVATE_UNAVAILABLE_MARKER, aw as expandSkillCommands, ax as normalizeTaskCheck, ay as readImageView, az as resolveRoots, aA as systemImageRoots, aB as SECRETARY_OPS, aC as SECRETARY_ID_MAX, aD as SECRETARY_CONTACT_CAPTION_MAX, aE as SECRETARY_ATTACHMENT_PATH_MAX, aF as SECRETARY_SEND_MODES, aG as SECRETARY_SESSION_MESSAGE_MAX, aH as SECRETARY_ATTACHMENT_MAX, aI as TOOL_RUN_TIMEOUT_MS, aJ as SILENCE_TURN_TOOL, aK as prependTurnNote, aL as resolveWorkflowPresetArgs, aM as workspaceBranchChangedNote, aN as RESTART_CHECKPOINT_ARCHIVE, aO as takeRestartCheckpoint, aP as REMINDERS_FILE, aQ as toReminderSummary, aR as MCP_SERVER_REGISTRY_DIR, aS as DEFAULT_MAX_ACTIVE_COWORKERS, aT as DEFAULT_AUTO_RETRY_LIMIT, aU as setAppLoggingEnabled, aV as providerIdOfAccountKey, aW as resolveOauthCatalogModel, aX as STALE_SESSION_ERROR, aY as resolveCompactStrategy, aZ as createSshExecutor, a_ as DEFAULT_SSH_TIMEOUT_SECONDS, a$ as partitionMcpNamespaces, b0 as HUMAN_REQUEST_TIMEOUT_MS, b1 as sessionTempDir, b2 as workflowPresetRoots, b3 as listWorkflowPresets, b4 as isSecretaryToolAllowed, b5 as PLAN_ENTRY_TYPE, b6 as autoRetryOverrides, b7 as parseAgentSessionCustomEntry, b8 as snapshotMainConversation, b9 as positiveContextWindow, ba as classifyUpstreamError, bb as toolBatchDigest, bc as buildTurnDigest, bd as buildTurnReport, be as turnRequestedSilence, bf as turnCalledSilenceTurn, bg as parseJsonFromAssistant, bh as validateAgainstSchema, bi as appendYieldJson, bj as AGENT_COMPACTION_LOG, bk as restartGate, bl as writeRestartCheckpoint, bm as RESTART_CHECKPOINT_FILE, bn as describeTitleModel, bo as buildRollingTitleUserText, bp as buildInitialTitleUserText, bq as ROLLING_TITLE_SYSTEM_PROMPT, br as TITLE_SYSTEM_PROMPT, bs as extractTitle, bt as titleRejectReason, bu as WORKSPACE_WRITE_TOOL_ID, bv as titleSummaryTimeoutMs, bw as splitTurnNotes, bx as parsePlanMessage, by as ANTIGRAVITY_PROVIDER_ID, bz as antigravityProviderConfig, bA as DEVIN_PROVIDER_ID, bB as devinProviderConfig, bC as QODER_PROVIDER_ID, bD as qoderProviderConfig, bE as QODER_CN_PROVIDER_ID, bF as installCodexLinkedRefresh, bG as isHeadlessRun, bH as loadWorkflowPreset, bI as REMINDER_MAX_DELAY_MS, bJ as isClassifierOnlyProvider, bK as isOauthAccountPool, bL as cloneModelsDevOauthModel, bM as resolveEditMode, bN as withAgentRead, bO as buildSshShellCommand, bP as resolveSshControlPath, bQ as sshPasswordEnv, bR as EMPTY_PLAN_STATE, bS as mergeMaskReports, bT as PRIVACY_MASK_ENTRY, bU as APP_LOGGING_ENV, bV as installConsoleLog, bW as RESTART_CHECKPOINT_ENV, bX as parseAgentCommand } from "./chunks/workflowPresets-DVbQh2el.js";
|
|
3
|
+
import { p as parseChildSessionIdentity, a as parseSessionIdentity, C as CONTEXT_PART_ITEMS, i as isUuid, P as PLUGIN_MESSAGE_TYPE, b as parsePluginInjectSender, c as isChildInterceptEvent, d as CONTEXT_USAGE_BUCKETS, B as BEFORE_AGENT_START_PROMPT_MAX, e as BEFORE_AGENT_START_APPEND_MAX, A as AGENT_END_TEXT_MAX, f as isSameChildSessionIdentity, g as PLUGIN_AGENT_ARGS_MAX_CHARS, h as PLUGIN_AGENT_TEXT_MAX_CHARS, j as PLUGIN_AGENT_OUTPUT_MAX_CHARS } from "./chunks/killTree-T-p6Lr3w.js";
|
|
4
|
+
import fs, { writeFileSync, statSync, existsSync, readFileSync, mkdirSync, appendFileSync, unlinkSync, renameSync, constants, rmSync, realpathSync, readdirSync } from "node:fs";
|
|
5
|
+
import { inspect } from "node:util";
|
|
6
|
+
import { i as isCursorModel, a as attachCursorBridgeToSession, b as indexCursorTools, l as loadCursorProvider, C as CURSOR_PROVIDER_ID, c as installPiCursorExecHook } from "./chunks/loadProvider-Uq3i7kKZ.js";
|
|
7
7
|
import { setGlobalDispatcher, EnvHttpProxyAgent, Agent, Pool, FormData as FormData$1, fetch as fetch$1 } from "undici";
|
|
8
8
|
import { spawn, execFile } from "node:child_process";
|
|
9
9
|
import { createHash, randomUUID, createHmac, randomBytes } from "node:crypto";
|
|
10
10
|
import { agentLoop, Agent as Agent$1 } from "@earendil-works/pi-agent-core";
|
|
11
11
|
import { getSupportedThinkingLevels, clampThinkingLevel, createAssistantMessageEventStream, isRetryableAssistantError, getCurrentTools } from "@earendil-works/pi-ai";
|
|
12
|
-
import { estimateTokens, serializeConversation as serializeConversation$1, convertToLlm, buildSessionContext, getAgentDir, defineTool, createEditToolDefinition, VIRTUAL_MODEL_STATE_ENTRY, createLocalPowerShellOperations, createLocalBashOperations, createPowerShellToolDefinition, createBashToolDefinition, stripFrontmatter, createGrepToolDefinition, createAgentSession, SessionManager, ModelRuntime, DefaultResourceLoader, createWriteToolDefinition, createReadToolDefinition, createFindToolDefinition, createLsToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
13
|
-
import {
|
|
12
|
+
import { estimateTokens, serializeConversation as serializeConversation$1, convertToLlm, buildSessionContext, getAgentDir, defineTool, createEditToolDefinition, detectSupportedImageMimeTypeFromFile, VIRTUAL_MODEL_STATE_ENTRY, createLocalPowerShellOperations, createLocalBashOperations, createPowerShellToolDefinition, createBashToolDefinition, stripFrontmatter, createGrepToolDefinition, createAgentSession, SessionManager, ModelRuntime, DefaultResourceLoader, createWriteToolDefinition, createReadToolDefinition, createFindToolDefinition, createLsToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import { P as PatchMutationUncertainError, n as normalizeApplyPatchArguments, A as APPLY_PATCH_PROMPT_GUIDELINES, e as executeApplyPatch, c as closestMatchHint, a as attachBackgroundCommandHooks, F as ForegroundDetachedError, w as withFileBackedExec, b as withHardenedEnv, d as withDetachableExec, C as CODEMODE_FORBIDDEN_TOOLS, v as validateFetchUrl, i as isPublicAddress, t as throwUnlessAllowed, f as describeSubagentModels, g as extractWriteTargetPaths, B as BackgroundTaskManager, h as takeDetachedTasksManifest, D as DETACHED_TASKS_FILE, s as sweepOrphanRuns, j as takeInterruptedTasks, I as INTERRUPTED_TASKS_FILE, k as isDeferredMcp, l as CodemodeHost, m as ApprovalGate, o as withTempRootGuard, p as withDcgExemptions, T as TodoStaleReminder, q as CoworkerIdleReminder, r as createUnifiedSubagentTool, u as withMandatoryApproval, x as createBrowserTools, y as withNavigateApproval, z as createMemoryTools, E as withComputerApproval, G as createComputerTool, H as withApproval, J as createAskTool, K as createTaskTools, L as BrowserInvoker, M as MemoryInvoker, N as PlanController, O as ComputerInvoker, Q as AskManager, R as lastAssistantText$1, S as foregroundCommandTimeoutMs, U as awaitChecklist, V as settleChecklist, W as writeDetachedTasksManifest, X as killRunGroup, Y as appendInterruptedTasks, Z as resolveChildReasoning, _ as pickChildReasoningOverride, $ as fitChildReasoningToModel, a0 as createWebTools, a1 as createTodoTool, a2 as withPlanGate, a3 as createSubmitPlanTool, a4 as approvalReviewResultExtension, a5 as createDcgGuard, a6 as CODEMODE_TOOL_NAME, a7 as prepareCodemodeInput, a8 as withBackground, a9 as withProtectedFloor, aa as withWriteScope, ab as withWritePreflight, ac as validateApplyPatchTargets, ad as extractEditTargetPath, ae as getApplyPatchPaths } from "./chunks/web-BIJOMDlz.js";
|
|
14
|
+
import { rm, mkdtemp, readFile, access, open, stat, readdir, realpath, mkdir, lstat, unlink } from "node:fs/promises";
|
|
14
15
|
import "node:buffer";
|
|
15
16
|
import os, { tmpdir, homedir } from "node:os";
|
|
16
17
|
import { Type } from "typebox";
|
|
17
18
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
18
19
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
19
20
|
import { Text } from "@earendil-works/pi-tui";
|
|
21
|
+
import { r as resolveHarnessSkillRoots, a as readHarnessRuleFiles, c as createProjectSettingsManager } from "./chunks/projectCode-D9lgShsp.js";
|
|
20
22
|
import { extractWWWAuthenticateParams } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
21
23
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
22
24
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
23
|
-
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
24
25
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
25
26
|
import { lookup } from "node:dns/promises";
|
|
26
27
|
import { isIP, BlockList } from "node:net";
|
|
27
|
-
import { w as wrapUntrusted, S as SEND_IMAGE_CAPTION_MAX, a as SEND_IMAGE_PER_REPLY, s as sendImageItems } from "./chunks/sendImage-
|
|
28
|
+
import { w as wrapUntrusted, S as SEND_IMAGE_CAPTION_MAX, a as SEND_IMAGE_PER_REPLY, s as sendImageItems } from "./chunks/sendImage-CCjNsa-D.js";
|
|
29
|
+
import { T as THINKING_LEVELS } from "./chunks/agentConstants-D4t7d6iS.js";
|
|
28
30
|
import { createRequire } from "node:module";
|
|
29
31
|
import { QuickJS, JSException } from "quickjs-wasi";
|
|
30
32
|
import "node:zlib";
|
|
31
|
-
import "node:string_decoder";
|
|
32
|
-
import "node:util";
|
|
33
|
-
import "node:url";
|
|
34
|
-
import "@mozilla/readability";
|
|
35
|
-
import "linkedom";
|
|
36
|
-
import "turndown";
|
|
37
33
|
import "@earendil-works/pi-ai/api/transform-messages";
|
|
38
34
|
import "node:http";
|
|
35
|
+
import "node:url";
|
|
36
|
+
import "@modelcontextprotocol/sdk/client/stdio.js";
|
|
37
|
+
import "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
38
|
+
import "yaml";
|
|
39
39
|
import "node:events";
|
|
40
40
|
import "node:http2";
|
|
41
41
|
import "node:stream";
|
|
42
|
+
import "node:string_decoder";
|
|
43
|
+
import "./chunks/toolParams-DVs5d3F9.js";
|
|
44
|
+
import "@mozilla/readability";
|
|
45
|
+
import "linkedom";
|
|
46
|
+
import "turndown";
|
|
42
47
|
const PARENT_TYPES = /* @__PURE__ */ new Set(["spawn-parent", "prompt", "steer", "retry"]);
|
|
43
48
|
const CHILD_TYPES = /* @__PURE__ */ new Set(["spawn-child", "prompt", "steer", "retry"]);
|
|
44
49
|
function rejectUnparsableCommand(data) {
|
|
@@ -60,15 +65,26 @@ function rejectUnparsableCommand(data) {
|
|
|
60
65
|
...typeof instanceId === "string" && instanceId ? { instanceId } : {}
|
|
61
66
|
};
|
|
62
67
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
68
|
+
function isAbortLike(error) {
|
|
69
|
+
if (error instanceof DOMException)
|
|
70
|
+
return error.name === "AbortError" || error.name === "TimeoutError";
|
|
71
|
+
return error instanceof Error && error.name === "AbortError" && error.code === "ABORT_ERR";
|
|
72
|
+
}
|
|
73
|
+
function describeError(error) {
|
|
74
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
75
|
+
}
|
|
76
|
+
function installCrashRecord(dataDir2, options = {}) {
|
|
77
|
+
const target = options.target ?? process;
|
|
78
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
79
|
+
target.on("uncaughtExceptionMonitor", (error, origin) => {
|
|
80
|
+
if (isAbortLike(error)) return;
|
|
65
81
|
try {
|
|
66
82
|
const memory = process.memoryUsage();
|
|
67
83
|
const crash = {
|
|
68
84
|
pid: process.pid,
|
|
69
85
|
at: Date.now(),
|
|
70
86
|
origin,
|
|
71
|
-
message:
|
|
87
|
+
message: describeError(error),
|
|
72
88
|
stack: error instanceof Error ? error.stack : void 0,
|
|
73
89
|
rss: memory.rss,
|
|
74
90
|
heapUsed: memory.heapUsed
|
|
@@ -77,6 +93,20 @@ function installCrashRecord(dataDir2) {
|
|
|
77
93
|
} catch {
|
|
78
94
|
}
|
|
79
95
|
});
|
|
96
|
+
target.on("uncaughtException", (error, origin) => {
|
|
97
|
+
const text2 = `origin=${origin} ${inspect(error)}`;
|
|
98
|
+
if (isAbortLike(error)) {
|
|
99
|
+
console.warn(`[agent] swallowed escaped abort ${text2}`);
|
|
100
|
+
appendCappedLog(path.join(dataDir2, AGENT_WORKER_ABORT_LOG), `pid=${process.pid} ${text2}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
process.stderr.write(`${text2}
|
|
105
|
+
`);
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
exit(1);
|
|
109
|
+
});
|
|
80
110
|
}
|
|
81
111
|
const TIMEOUTS = { headersTimeout: 0, bodyTimeout: 0 };
|
|
82
112
|
function bootstrapWorkerProxyFromEnv() {
|
|
@@ -778,7 +808,7 @@ function decideManagedApproval(answers, model, allowThreshold) {
|
|
|
778
808
|
].join(" ");
|
|
779
809
|
return { decision: "deny", record: { verdict: "deny", ...base }, message };
|
|
780
810
|
}
|
|
781
|
-
function isRecord$
|
|
811
|
+
function isRecord$7(value) {
|
|
782
812
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
783
813
|
}
|
|
784
814
|
function num(value) {
|
|
@@ -799,17 +829,17 @@ function completeUsage(usage) {
|
|
|
799
829
|
cacheRead,
|
|
800
830
|
cacheWrite,
|
|
801
831
|
totalTokens,
|
|
802
|
-
cost: isRecord$
|
|
832
|
+
cost: isRecord$7(usage?.cost) ? { ...empty.cost, ...usage.cost } : empty.cost
|
|
803
833
|
};
|
|
804
834
|
}
|
|
805
835
|
function needsUsagePatch(usage) {
|
|
806
|
-
if (!isRecord$
|
|
807
|
-
return typeof usage.totalTokens !== "number" || !Number.isFinite(usage.totalTokens) || !isRecord$
|
|
836
|
+
if (!isRecord$7(usage)) return true;
|
|
837
|
+
return typeof usage.totalTokens !== "number" || !Number.isFinite(usage.totalTokens) || !isRecord$7(usage.cost);
|
|
808
838
|
}
|
|
809
839
|
function ensureAssistantUsage(messages) {
|
|
810
840
|
let patched = 0;
|
|
811
841
|
for (const message of messages) {
|
|
812
|
-
if (!isRecord$
|
|
842
|
+
if (!isRecord$7(message) || message.role !== "assistant") continue;
|
|
813
843
|
const assistant = message;
|
|
814
844
|
if (!needsUsagePatch(assistant.usage)) continue;
|
|
815
845
|
assistant.usage = completeUsage(assistant.usage);
|
|
@@ -1221,7 +1251,7 @@ function parseCheckpointMessage(refName, msg) {
|
|
|
1221
1251
|
const idx = get("index-tree");
|
|
1222
1252
|
const wt = get("worktree-tree");
|
|
1223
1253
|
if (!sid || !head || !idx || !wt) return null;
|
|
1224
|
-
const
|
|
1254
|
+
const parseJson2 = (key) => {
|
|
1225
1255
|
const raw = get(key);
|
|
1226
1256
|
if (!raw) return void 0;
|
|
1227
1257
|
try {
|
|
@@ -1245,9 +1275,9 @@ function parseCheckpointMessage(refName, msg) {
|
|
|
1245
1275
|
indexTreeSha: idx,
|
|
1246
1276
|
worktreeTreeSha: wt,
|
|
1247
1277
|
timestamp: created ? new Date(created).getTime() : 0,
|
|
1248
|
-
preexistingUntrackedFiles:
|
|
1249
|
-
skippedLargeFiles:
|
|
1250
|
-
skippedLargeDirs:
|
|
1278
|
+
preexistingUntrackedFiles: parseJson2("untracked"),
|
|
1279
|
+
skippedLargeFiles: parseJson2("largeFiles"),
|
|
1280
|
+
skippedLargeDirs: parseJson2("largeDirs")
|
|
1251
1281
|
};
|
|
1252
1282
|
}
|
|
1253
1283
|
async function loadAllCheckpoints(root, sessionId, host = localCheckpointHost) {
|
|
@@ -1300,6 +1330,9 @@ async function pruneStaleCheckpoints(root, maxAgeMs = 7 * 24 * 60 * 60 * 1e3, ho
|
|
|
1300
1330
|
return deleted;
|
|
1301
1331
|
}
|
|
1302
1332
|
const MUTATING_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "apply_patch", "bash", "powershell"]);
|
|
1333
|
+
const INDEX_LOCK_RETRY_MS = 300;
|
|
1334
|
+
const messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
1335
|
+
const isIndexLocked = (error) => /index\.lock/.test(messageOf(error));
|
|
1303
1336
|
class CheckpointManager {
|
|
1304
1337
|
constructor(cwd, sessionId, getTurnEntry, host = localCheckpointHost) {
|
|
1305
1338
|
this.cwd = cwd;
|
|
@@ -1337,36 +1370,59 @@ class CheckpointManager {
|
|
|
1337
1370
|
await this.turnCheckpoint;
|
|
1338
1371
|
}
|
|
1339
1372
|
async createTurnCheckpoint(toolName) {
|
|
1373
|
+
let root = null;
|
|
1340
1374
|
try {
|
|
1341
|
-
|
|
1375
|
+
root = await this.resolveRoot();
|
|
1342
1376
|
if (!root) {
|
|
1343
1377
|
this.disabled = true;
|
|
1344
1378
|
return;
|
|
1345
1379
|
}
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
{
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1380
|
+
const repo = root;
|
|
1381
|
+
const snapshot = () => {
|
|
1382
|
+
const { entryId, entryTimestamp } = this.getTurnEntry();
|
|
1383
|
+
return createCheckpoint(
|
|
1384
|
+
{
|
|
1385
|
+
root: repo,
|
|
1386
|
+
id: `tool-${this.sessionId}-${Date.now()}`,
|
|
1387
|
+
sessionId: this.sessionId,
|
|
1388
|
+
trigger: "tool",
|
|
1389
|
+
toolName,
|
|
1390
|
+
entryId,
|
|
1391
|
+
entryTimestamp
|
|
1392
|
+
},
|
|
1393
|
+
this.host
|
|
1394
|
+
);
|
|
1395
|
+
};
|
|
1396
|
+
await snapshot().catch(async (error) => {
|
|
1397
|
+
if (!isIndexLocked(error)) throw error;
|
|
1398
|
+
await new Promise((resolve) => setTimeout(resolve, INDEX_LOCK_RETRY_MS));
|
|
1399
|
+
await snapshot();
|
|
1400
|
+
});
|
|
1401
|
+
void pruneCheckpoints(repo, this.sessionId, void 0, this.host).catch(() => {
|
|
1360
1402
|
});
|
|
1361
1403
|
this.failures = 0;
|
|
1362
1404
|
} catch (error) {
|
|
1405
|
+
const tag = `[checkpoint] ${this.sessionId.slice(0, 8)}`;
|
|
1406
|
+
if (/\bunmerged\b/.test(messageOf(error))) {
|
|
1407
|
+
console.info(`${tag} snapshot skipped: unresolved merge conflicts`);
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (root && error.code === "ENOENT" && await this.rootGone(root)) {
|
|
1411
|
+
console.debug(`${tag} snapshot skipped: ${root} no longer exists`);
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1363
1414
|
if (++this.failures >= 3) this.disabled = true;
|
|
1364
1415
|
console.warn(
|
|
1365
|
-
|
|
1366
|
-
|
|
1416
|
+
`${tag} snapshot failed (${this.failures}/3${this.disabled ? ", disabled for this session" : ""}):`,
|
|
1417
|
+
messageOf(error)
|
|
1367
1418
|
);
|
|
1368
1419
|
}
|
|
1369
1420
|
}
|
|
1421
|
+
/** spawn git ENOENT 也可能是没装 git;只有工作目录确实没了(如刚删除的 worktree)才算预期 */
|
|
1422
|
+
async rootGone(root) {
|
|
1423
|
+
const stats = await this.host.statBatch(root, ["."]).catch(() => null);
|
|
1424
|
+
return stats?.get(".")?.kind === "missing";
|
|
1425
|
+
}
|
|
1370
1426
|
/**
|
|
1371
1427
|
* 把工作树还原到目标 user entry 那一轮开始前的状态。
|
|
1372
1428
|
* 匹配:entryId 精确命中 → 该轮首个写操作前;否则取 entryTimestamp ≥ 目标时间戳的
|
|
@@ -2062,6 +2118,7 @@ class ContextUsageTracker {
|
|
|
2062
2118
|
const CONTEXT_HEADROOM = 0.85;
|
|
2063
2119
|
const memberKey = (model) => `${model.provider}/${model.id}`;
|
|
2064
2120
|
const registry = /* @__PURE__ */ new Map();
|
|
2121
|
+
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || /\bRequest aborted\b/.test(error.message));
|
|
2065
2122
|
function isVirtualPiModel(model) {
|
|
2066
2123
|
return model?.api === "pi-virtual";
|
|
2067
2124
|
}
|
|
@@ -2261,7 +2318,8 @@ async function registerVirtualModel(runtime, config, resolveMember, choose, supp
|
|
|
2261
2318
|
route: async (request) => {
|
|
2262
2319
|
const typed = request;
|
|
2263
2320
|
const choice = typed.reason === "user" && choose && isNewTurn(typed.messages) ? await choose(typed, members).catch((error) => {
|
|
2264
|
-
console.
|
|
2321
|
+
if (isAbortError(error)) console.debug("[virtual-model] classifier aborted");
|
|
2322
|
+
else console.warn("[virtual-model] classifier failed:", error);
|
|
2265
2323
|
return void 0;
|
|
2266
2324
|
}) : void 0;
|
|
2267
2325
|
const route = routeVirtualRequest(typed, members, choice);
|
|
@@ -3080,7 +3138,7 @@ const ensoCompactInlineExtension = {
|
|
|
3080
3138
|
factory: createEnsoCompactFactory()
|
|
3081
3139
|
};
|
|
3082
3140
|
const CODEX_API = "openai-codex-responses";
|
|
3083
|
-
const isRecord$
|
|
3141
|
+
const isRecord$6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3084
3142
|
function extractCompactionItem(raw) {
|
|
3085
3143
|
const found = /* @__PURE__ */ new Set();
|
|
3086
3144
|
for (const block of raw.split(/\r?\n\r?\n/)) {
|
|
@@ -3092,15 +3150,15 @@ function extractCompactionItem(raw) {
|
|
|
3092
3150
|
} catch {
|
|
3093
3151
|
continue;
|
|
3094
3152
|
}
|
|
3095
|
-
if (!isRecord$
|
|
3096
|
-
const response = isRecord$
|
|
3153
|
+
if (!isRecord$6(event)) continue;
|
|
3154
|
+
const response = isRecord$6(event.response) ? event.response : void 0;
|
|
3097
3155
|
if (event.type === "error" || event.type === "response.failed") {
|
|
3098
|
-
const error = isRecord$
|
|
3156
|
+
const error = isRecord$6(event.error) ? event.error : isRecord$6(response?.error) ? response.error : event;
|
|
3099
3157
|
throw new Error(String(error.message ?? "Codex compaction failed"));
|
|
3100
3158
|
}
|
|
3101
3159
|
const items = event.type === "response.output_item.done" ? [event.item] : event.type === "response.completed" && Array.isArray(response?.output) ? response.output : [];
|
|
3102
3160
|
for (const item of items) {
|
|
3103
|
-
if (isRecord$
|
|
3161
|
+
if (isRecord$6(item) && item.type === "compaction" && typeof item.encrypted_content === "string") {
|
|
3104
3162
|
if (item.encrypted_content) found.add(item.encrypted_content);
|
|
3105
3163
|
}
|
|
3106
3164
|
}
|
|
@@ -3109,11 +3167,11 @@ function extractCompactionItem(raw) {
|
|
|
3109
3167
|
return found.size === 1 && encrypted ? { type: "compaction", encrypted_content: encrypted } : void 0;
|
|
3110
3168
|
}
|
|
3111
3169
|
function checkpointOf(entry) {
|
|
3112
|
-
if (!isRecord$
|
|
3170
|
+
if (!isRecord$6(entry) || entry.type !== "compaction" || !isRecord$6(entry.details)) return;
|
|
3113
3171
|
const checkpoint = entry.details.codexCheckpoint;
|
|
3114
|
-
if (!isRecord$
|
|
3172
|
+
if (!isRecord$6(checkpoint) || typeof checkpoint.provider !== "string") return;
|
|
3115
3173
|
const item = checkpoint.item;
|
|
3116
|
-
if (!isRecord$
|
|
3174
|
+
if (!isRecord$6(item) || item.type !== "compaction" || typeof item.encrypted_content !== "string")
|
|
3117
3175
|
return;
|
|
3118
3176
|
return { provider: checkpoint.provider, item };
|
|
3119
3177
|
}
|
|
@@ -3125,12 +3183,12 @@ function summaryText(summary) {
|
|
|
3125
3183
|
return block?.type === "text" ? block.text : void 0;
|
|
3126
3184
|
}
|
|
3127
3185
|
function soleInputText(item) {
|
|
3128
|
-
if (!isRecord$
|
|
3186
|
+
if (!isRecord$6(item) || item.role !== "user" || !Array.isArray(item.content)) return;
|
|
3129
3187
|
const [part, ...rest] = item.content;
|
|
3130
|
-
return rest.length === 0 && isRecord$
|
|
3188
|
+
return rest.length === 0 && isRecord$6(part) && part.type === "input_text" ? String(part.text) : void 0;
|
|
3131
3189
|
}
|
|
3132
3190
|
function applyCodexCheckpoints(payload, entries, provider) {
|
|
3133
|
-
if (!isRecord$
|
|
3191
|
+
if (!isRecord$6(payload) || !Array.isArray(payload.input)) return payload;
|
|
3134
3192
|
const byText = /* @__PURE__ */ new Map();
|
|
3135
3193
|
for (const entry of entries) {
|
|
3136
3194
|
const checkpoint = checkpointOf(entry);
|
|
@@ -3165,7 +3223,7 @@ async function compactPrefix(ctx, branch, keptId, signal, baseFetch) {
|
|
|
3165
3223
|
transport: "sse",
|
|
3166
3224
|
onPayload: (payload) => {
|
|
3167
3225
|
const next = applyCodexCheckpoints(payload, prefix, model.provider);
|
|
3168
|
-
if (!isRecord$
|
|
3226
|
+
if (!isRecord$6(next) || !Array.isArray(next.input)) return next;
|
|
3169
3227
|
return { ...next, input: [...next.input, { type: "compaction_trigger" }] };
|
|
3170
3228
|
},
|
|
3171
3229
|
fetch: async (input, init) => {
|
|
@@ -3309,14 +3367,14 @@ function isCompactAfterTokensMode(value) {
|
|
|
3309
3367
|
function validRatioOrUndefined(value) {
|
|
3310
3368
|
return typeof value === "number" && Number.isFinite(value) && value > 0 && value < 1 ? value : void 0;
|
|
3311
3369
|
}
|
|
3312
|
-
function isRecord$
|
|
3370
|
+
function isRecord$5(value) {
|
|
3313
3371
|
return typeof value === "object" && value !== null;
|
|
3314
3372
|
}
|
|
3315
3373
|
function nonEmptyString(value) {
|
|
3316
3374
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
3317
3375
|
}
|
|
3318
3376
|
function normalizeModel(value) {
|
|
3319
|
-
if (!isRecord$
|
|
3377
|
+
if (!isRecord$5(value)) return void 0;
|
|
3320
3378
|
const provider = nonEmptyString(value.provider);
|
|
3321
3379
|
const id2 = nonEmptyString(value.id);
|
|
3322
3380
|
if (!provider || !id2) return void 0;
|
|
@@ -3366,7 +3424,7 @@ function readNamespacedConfig(path2) {
|
|
|
3366
3424
|
try {
|
|
3367
3425
|
const raw = JSON.parse(readFileSync(path2, "utf-8"));
|
|
3368
3426
|
const nested = raw[SETTINGS_KEY];
|
|
3369
|
-
return isRecord$
|
|
3427
|
+
return isRecord$5(nested) ? normalizeSettingsConfig(nested) : {};
|
|
3370
3428
|
} catch {
|
|
3371
3429
|
return {};
|
|
3372
3430
|
}
|
|
@@ -6590,13 +6648,13 @@ function withOpenAIResponsesRouting(provider) {
|
|
|
6590
6648
|
};
|
|
6591
6649
|
}
|
|
6592
6650
|
const KEEP_USER_IMAGE_TURNS = 2;
|
|
6593
|
-
const isRecord$
|
|
6594
|
-
const isImage = (b) => isRecord$
|
|
6595
|
-
const isToolCall = (b) => isRecord$
|
|
6651
|
+
const isRecord$4 = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
6652
|
+
const isImage = (b) => isRecord$4(b) && b.type === "image";
|
|
6653
|
+
const isToolCall = (b) => isRecord$4(b) && b.type === "toolCall";
|
|
6596
6654
|
const hasImage = (m) => Array.isArray(m.content) && m.content.some(isImage);
|
|
6597
6655
|
function pathOfCall(call) {
|
|
6598
6656
|
const args = call?.arguments;
|
|
6599
|
-
if (!isRecord$
|
|
6657
|
+
if (!isRecord$4(args)) return void 0;
|
|
6600
6658
|
const path2 = args.path ?? args.file ?? args.filePath;
|
|
6601
6659
|
return typeof path2 === "string" && path2.length > 0 ? path2 : void 0;
|
|
6602
6660
|
}
|
|
@@ -6615,7 +6673,7 @@ function replaceImages(message, source) {
|
|
|
6615
6673
|
);
|
|
6616
6674
|
return { ...message, content };
|
|
6617
6675
|
}
|
|
6618
|
-
const isText = (b) => isRecord$
|
|
6676
|
+
const isText = (b) => isRecord$4(b) && b.type === "text";
|
|
6619
6677
|
function fillToolResultText(message) {
|
|
6620
6678
|
if (message.role !== "toolResult" || !Array.isArray(message.content)) return message;
|
|
6621
6679
|
let changed = false;
|
|
@@ -6698,7 +6756,7 @@ function pruneHistoricalImages(messages) {
|
|
|
6698
6756
|
}
|
|
6699
6757
|
const keepComputer = new Set(computerHits.slice(-1));
|
|
6700
6758
|
const latestGenerated = messages.findLastIndex(
|
|
6701
|
-
(message) => message.role === "toolResult" && hasImage(message) && (message.toolName === "ImageGen" || message.toolName === "codemode" && isRecord$
|
|
6759
|
+
(message) => message.role === "toolResult" && hasImage(message) && (message.toolName === "ImageGen" || message.toolName === "codemode" && isRecord$4(message.details) && Array.isArray(message.details.generatedImages) && message.details.generatedImages.length > 0)
|
|
6702
6760
|
);
|
|
6703
6761
|
let out;
|
|
6704
6762
|
for (let i = 0; i < lastUserIndex; i++) {
|
|
@@ -6736,7 +6794,7 @@ function reportRequestBodyUsage(bytes, limitBytes, stage, request) {
|
|
|
6736
6794
|
}
|
|
6737
6795
|
}
|
|
6738
6796
|
const guardedStreams = /* @__PURE__ */ new WeakSet();
|
|
6739
|
-
const isRecord$
|
|
6797
|
+
const isRecord$3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6740
6798
|
const DEFAULT_LIMITS = {
|
|
6741
6799
|
"anthropic-messages": 32 * 1024 * 1024,
|
|
6742
6800
|
"openai-completions": 512 * 1024 * 1024,
|
|
@@ -6775,7 +6833,7 @@ function seenToolImages(context) {
|
|
|
6775
6833
|
for (const block of message.content) {
|
|
6776
6834
|
if (block.type !== "toolCall") continue;
|
|
6777
6835
|
const args = block.arguments;
|
|
6778
|
-
const path2 = isRecord$
|
|
6836
|
+
const path2 = isRecord$3(args) ? args.path ?? args.file ?? args.filePath : void 0;
|
|
6779
6837
|
calls.set(block.id, { name: block.name, ...typeof path2 === "string" ? { path: path2 } : {} });
|
|
6780
6838
|
}
|
|
6781
6839
|
}
|
|
@@ -6813,17 +6871,17 @@ function fitAnthropicPayload(payload, context, limit, options) {
|
|
|
6813
6871
|
const seen = seenToolImages(context);
|
|
6814
6872
|
let changed = false;
|
|
6815
6873
|
const messages = Array.isArray(body.messages) ? body.messages.map((message) => {
|
|
6816
|
-
if (!isRecord$
|
|
6874
|
+
if (!isRecord$3(message) || message.role !== "user" || !Array.isArray(message.content))
|
|
6817
6875
|
return message;
|
|
6818
6876
|
let messageChanged = false;
|
|
6819
6877
|
const content = message.content.map((result) => {
|
|
6820
|
-
if (!isRecord$
|
|
6878
|
+
if (!isRecord$3(result) || result.type !== "tool_result" || typeof result.tool_use_id !== "string" || !Array.isArray(result.content))
|
|
6821
6879
|
return result;
|
|
6822
6880
|
const candidate = seen.get(result.tool_use_id);
|
|
6823
6881
|
if (!candidate) return result;
|
|
6824
6882
|
let resultChanged = false;
|
|
6825
6883
|
const parts = result.content.map((block) => {
|
|
6826
|
-
if (bytes <= limit || !isRecord$
|
|
6884
|
+
if (bytes <= limit || !isRecord$3(block) || block.type !== "image" || !isRecord$3(block.source))
|
|
6827
6885
|
return block;
|
|
6828
6886
|
const source = block.source;
|
|
6829
6887
|
if (source.type !== "base64" || !candidate.images.some(
|
|
@@ -6867,7 +6925,7 @@ function budgetOptions(model, context, options) {
|
|
|
6867
6925
|
const body = replacement === void 0 ? payload : replacement;
|
|
6868
6926
|
const limit = requestLimit(requestModel);
|
|
6869
6927
|
if (limit === void 0) return body;
|
|
6870
|
-
if (requestModel.api === "anthropic-messages" && isRecord$
|
|
6928
|
+
if (requestModel.api === "anthropic-messages" && isRecord$3(body))
|
|
6871
6929
|
return fitAnthropicPayload(body, context, limit, options);
|
|
6872
6930
|
const bytes = jsonBytes(body);
|
|
6873
6931
|
reportRequestBodyUsage(bytes, limit, "payload", options);
|
|
@@ -7101,58 +7159,6 @@ function providerRequestHeaders(headers) {
|
|
|
7101
7159
|
for (const [name, value] of Object.entries(user)) merged[name] = escapePiConfigValue(value);
|
|
7102
7160
|
return merged;
|
|
7103
7161
|
}
|
|
7104
|
-
function dcgDialect(tool) {
|
|
7105
|
-
if (tool === "bash") return "posix";
|
|
7106
|
-
if (tool === "powershell") return "ps";
|
|
7107
|
-
return null;
|
|
7108
|
-
}
|
|
7109
|
-
function parseDcgVerdict(exitCode, stdout) {
|
|
7110
|
-
if (exitCode !== 1) return null;
|
|
7111
|
-
try {
|
|
7112
|
-
const value = JSON.parse(stdout);
|
|
7113
|
-
if (value.decision !== "deny") return null;
|
|
7114
|
-
const { rule_id: ruleId, reason } = value;
|
|
7115
|
-
if (typeof ruleId !== "string" || !ruleId || typeof reason !== "string" || !reason) return null;
|
|
7116
|
-
return { ruleId, reason };
|
|
7117
|
-
} catch {
|
|
7118
|
-
return null;
|
|
7119
|
-
}
|
|
7120
|
-
}
|
|
7121
|
-
const MAX_OUTPUT = 64 * 1024;
|
|
7122
|
-
function createDcgGuard(binaryPath, timeoutMs = 1500) {
|
|
7123
|
-
return (tool, command2, signal) => {
|
|
7124
|
-
const dialect = dcgDialect(tool);
|
|
7125
|
-
if (!dialect || !command2.trim() || signal?.aborted) return Promise.resolve(null);
|
|
7126
|
-
return new Promise((resolve) => {
|
|
7127
|
-
let stdout = "";
|
|
7128
|
-
let settled = false;
|
|
7129
|
-
const child = spawn(binaryPath, ["--robot", "test", "--dialect", dialect, command2], {
|
|
7130
|
-
shell: false,
|
|
7131
|
-
windowsHide: true,
|
|
7132
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
7133
|
-
env: { ...process.env, DCG_ROBOT: "1" }
|
|
7134
|
-
});
|
|
7135
|
-
const finish2 = (hit) => {
|
|
7136
|
-
if (settled) return;
|
|
7137
|
-
settled = true;
|
|
7138
|
-
clearTimeout(timer);
|
|
7139
|
-
signal?.removeEventListener("abort", onAbort);
|
|
7140
|
-
resolve(hit);
|
|
7141
|
-
};
|
|
7142
|
-
const onAbort = () => {
|
|
7143
|
-
child.kill("SIGKILL");
|
|
7144
|
-
finish2(null);
|
|
7145
|
-
};
|
|
7146
|
-
const timer = setTimeout(onAbort, timeoutMs);
|
|
7147
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
7148
|
-
child.stdout.on("data", (chunk) => {
|
|
7149
|
-
stdout = (stdout + chunk.toString()).slice(0, MAX_OUTPUT);
|
|
7150
|
-
});
|
|
7151
|
-
child.on("error", () => finish2(null));
|
|
7152
|
-
child.on("close", (code) => finish2(parseDcgVerdict(code, stdout)));
|
|
7153
|
-
});
|
|
7154
|
-
};
|
|
7155
|
-
}
|
|
7156
7162
|
function omitNamedTools(tools, disabled) {
|
|
7157
7163
|
if (disabled.length === 0) return [...tools];
|
|
7158
7164
|
const off = new Set(disabled.map((name) => name.toLowerCase()));
|
|
@@ -7516,20 +7522,65 @@ class OperationGate {
|
|
|
7516
7522
|
return next;
|
|
7517
7523
|
}
|
|
7518
7524
|
}
|
|
7525
|
+
function isRecord$2(value) {
|
|
7526
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7527
|
+
}
|
|
7528
|
+
function parseJson(value) {
|
|
7529
|
+
try {
|
|
7530
|
+
return JSON.parse(value);
|
|
7531
|
+
} catch {
|
|
7532
|
+
return void 0;
|
|
7533
|
+
}
|
|
7534
|
+
}
|
|
7535
|
+
function prepareGoalComplete(raw) {
|
|
7536
|
+
const source = typeof raw === "string" ? parseJson(raw) : raw;
|
|
7537
|
+
if (!isRecord$2(source)) return raw;
|
|
7538
|
+
if (typeof source.result !== "string") return source;
|
|
7539
|
+
const result = parseJson(source.result);
|
|
7540
|
+
if (!isRecord$2(result)) return source;
|
|
7541
|
+
return { ...source, result };
|
|
7542
|
+
}
|
|
7519
7543
|
function createGoalTools(emit, verify, completionNote) {
|
|
7520
|
-
const make = (name, kind, description, noteField, noteDesc) => ({
|
|
7544
|
+
const make = (name, kind, description, noteField, noteDesc, withResult = false) => ({
|
|
7521
7545
|
name,
|
|
7522
7546
|
label: name,
|
|
7523
7547
|
description,
|
|
7524
7548
|
promptSnippet: "",
|
|
7549
|
+
...withResult ? {
|
|
7550
|
+
prepareArguments: prepareGoalComplete
|
|
7551
|
+
} : {},
|
|
7525
7552
|
parameters: {
|
|
7526
7553
|
type: "object",
|
|
7527
|
-
properties:
|
|
7554
|
+
properties: withResult ? {
|
|
7555
|
+
[noteField]: { type: "string", description: noteDesc },
|
|
7556
|
+
result: {
|
|
7557
|
+
...GOAL_RESULT_SCHEMA,
|
|
7558
|
+
description: "Optional structured outcome (pull requests, commits, checks, screenshots) for a read-only host check"
|
|
7559
|
+
}
|
|
7560
|
+
} : { [noteField]: { type: "string", description: noteDesc } },
|
|
7528
7561
|
required: [noteField]
|
|
7529
7562
|
},
|
|
7530
7563
|
async execute(_id, params, signal) {
|
|
7531
|
-
const
|
|
7564
|
+
const record = isRecord$2(params) ? params : {};
|
|
7565
|
+
const note = String(record[noteField] ?? "").trim();
|
|
7532
7566
|
if (!note) throw new Error(`${noteField} is required`);
|
|
7567
|
+
let goalResult;
|
|
7568
|
+
if (withResult && record.result !== void 0) {
|
|
7569
|
+
const parsed = parseGoalResult(record.result);
|
|
7570
|
+
if (!parsed.ok) {
|
|
7571
|
+
return {
|
|
7572
|
+
content: [
|
|
7573
|
+
{
|
|
7574
|
+
type: "text",
|
|
7575
|
+
text: `Goal NOT marked complete — result is invalid: ${parsed.error}
|
|
7576
|
+
Fix that field and call goal_complete again. Omit result for a plain summary.`
|
|
7577
|
+
}
|
|
7578
|
+
],
|
|
7579
|
+
details: void 0
|
|
7580
|
+
};
|
|
7581
|
+
}
|
|
7582
|
+
goalResult = parsed.value;
|
|
7583
|
+
}
|
|
7533
7584
|
if (kind === "complete" && verify) {
|
|
7534
7585
|
const rejection = await verify(note, signal);
|
|
7535
7586
|
if (rejection)
|
|
@@ -7544,7 +7595,8 @@ The goal is still active. Produce the missing proof with tools (run the check, s
|
|
|
7544
7595
|
details: void 0
|
|
7545
7596
|
};
|
|
7546
7597
|
}
|
|
7547
|
-
emit(kind, note);
|
|
7598
|
+
if (goalResult) emit(kind, note, goalResult);
|
|
7599
|
+
else emit(kind, note);
|
|
7548
7600
|
const extra = kind === "complete" ? completionNote?.() : void 0;
|
|
7549
7601
|
return {
|
|
7550
7602
|
content: [
|
|
@@ -7563,9 +7615,10 @@ ${extra}` : `Goal marked ${kind}.`
|
|
|
7563
7615
|
make(
|
|
7564
7616
|
"goal_complete",
|
|
7565
7617
|
"complete",
|
|
7566
|
-
"Mark the active session goal as COMPLETE. Only call when a goal is active (its text appears in your context) and the objective is genuinely done — include concrete evidence. An independent verifier checks the claim against the transcript: prove each requirement with a recent tool result (run the check and show its output); your own statements do not count as proof. While a goal runs, nobody is watching each step: do not stop at analysis or a plan; when something is ambiguous, take the most likely reading, state the assumption, and keep going.",
|
|
7618
|
+
"Mark the active session goal as COMPLETE. Only call when a goal is active (its text appears in your context) and the objective is genuinely done — include concrete evidence. An independent verifier checks the claim against the transcript: prove each requirement with a recent tool result (run the check and show its output); your own statements do not count as proof. While a goal runs, nobody is watching each step: do not stop at analysis or a plan; when something is ambiguous, take the most likely reading, state the assumption, and keep going. Optional result carries structured evidence (pull requests, commits, checks, screenshots) for a read-only host check; a plain summary still completes the goal. result.needsUser puts the card in front of the user: list only what they must decide or do by hand, one imperative sentence each; optional cleanup and suggestions go in result.followUps.",
|
|
7567
7619
|
"summary",
|
|
7568
|
-
"What was accomplished, with concrete evidence (files changed, tests passing, etc.)"
|
|
7620
|
+
"What was accomplished, with concrete evidence (files changed, tests passing, etc.)",
|
|
7621
|
+
true
|
|
7569
7622
|
),
|
|
7570
7623
|
make(
|
|
7571
7624
|
"goal_blocked",
|
|
@@ -7692,6 +7745,23 @@ function parseGoalVerdict(raw) {
|
|
|
7692
7745
|
}
|
|
7693
7746
|
return void 0;
|
|
7694
7747
|
}
|
|
7748
|
+
async function* readLocalFileChunks(file, { signal }) {
|
|
7749
|
+
const handle = await open(file, "r");
|
|
7750
|
+
try {
|
|
7751
|
+
const stats = await handle.stat();
|
|
7752
|
+
const end = stats.isFile() && stats.size > 0 ? stats.size - 1 : void 0;
|
|
7753
|
+
signal?.throwIfAborted();
|
|
7754
|
+
yield* handle.createReadStream({ end, signal, autoClose: false });
|
|
7755
|
+
} finally {
|
|
7756
|
+
await handle.close();
|
|
7757
|
+
}
|
|
7758
|
+
}
|
|
7759
|
+
const localReadOperations = {
|
|
7760
|
+
readFile: (file) => readFile(file),
|
|
7761
|
+
access: (file) => access(file, constants.R_OK),
|
|
7762
|
+
detectImageMimeType: detectSupportedImageMimeTypeFromFile,
|
|
7763
|
+
createReadStream: readLocalFileChunks
|
|
7764
|
+
};
|
|
7695
7765
|
function withLongCacheRetention(model, options, enabled) {
|
|
7696
7766
|
if (!enabled || !options?.sessionId || options.cacheRetention !== void 0) return options;
|
|
7697
7767
|
if (model.api !== "anthropic-messages") return options;
|
|
@@ -7721,24 +7791,24 @@ class OAuthAccess {
|
|
|
7721
7791
|
retired = /* @__PURE__ */ new Set();
|
|
7722
7792
|
renewing;
|
|
7723
7793
|
proactiveFailed = "";
|
|
7724
|
-
isRetired(
|
|
7725
|
-
return Boolean(
|
|
7794
|
+
isRetired(access2) {
|
|
7795
|
+
return Boolean(access2 && this.retired.has(oauthFingerprint(access2)));
|
|
7726
7796
|
}
|
|
7727
7797
|
/** Main 下发的凭据(重新授权 / 撤销):已淘汰的旧 token 忽略 */
|
|
7728
|
-
offer(
|
|
7729
|
-
if (!this.isRetired(
|
|
7798
|
+
offer(access2) {
|
|
7799
|
+
if (!this.isRetired(access2)) this.current = access2;
|
|
7730
7800
|
}
|
|
7731
7801
|
/** 发请求前取 token:临期先续期;续期失败仍用旧 token,交给服务端裁决 */
|
|
7732
7802
|
async forRequest() {
|
|
7733
|
-
const
|
|
7734
|
-
if (!
|
|
7735
|
-
return
|
|
7803
|
+
const access2 = this.current;
|
|
7804
|
+
if (!access2?.expires_at || Date.now() < access2.expires_at - MCP_OAUTH_REFRESH_SKEW_MS) {
|
|
7805
|
+
return access2;
|
|
7736
7806
|
}
|
|
7737
|
-
const fingerprint2 = oauthFingerprint(
|
|
7738
|
-
if (this.proactiveFailed === fingerprint2) return
|
|
7739
|
-
const next = await this.renew(
|
|
7807
|
+
const fingerprint2 = oauthFingerprint(access2);
|
|
7808
|
+
if (this.proactiveFailed === fingerprint2) return access2;
|
|
7809
|
+
const next = await this.renew(access2);
|
|
7740
7810
|
if (!next) this.proactiveFailed = fingerprint2;
|
|
7741
|
-
return next ??
|
|
7811
|
+
return next ?? access2;
|
|
7742
7812
|
}
|
|
7743
7813
|
/** 该 token 已不可用:别处已换过就直接用新的,否则请 Main 续期 */
|
|
7744
7814
|
renew(stale) {
|
|
@@ -7787,22 +7857,22 @@ function scopeChallengeOf(response) {
|
|
|
7787
7857
|
...resourceMetadataUrl ? { resourceMetadataUrl: resourceMetadataUrl.href } : {}
|
|
7788
7858
|
};
|
|
7789
7859
|
}
|
|
7790
|
-
const withBearer = (init,
|
|
7860
|
+
const withBearer = (init, access2) => {
|
|
7791
7861
|
const headers = new Headers(init?.headers);
|
|
7792
|
-
headers.set("Authorization", `Bearer ${
|
|
7862
|
+
headers.set("Authorization", `Bearer ${access2.access_token}`);
|
|
7793
7863
|
return { ...init, headers };
|
|
7794
7864
|
};
|
|
7795
|
-
function remoteFetch(
|
|
7865
|
+
function remoteFetch(access2, onChallenge) {
|
|
7796
7866
|
return async (input, init) => {
|
|
7797
7867
|
let response;
|
|
7798
7868
|
if (new Headers(init?.headers).has("authorization")) {
|
|
7799
7869
|
response = await fetch(input, init);
|
|
7800
7870
|
} else {
|
|
7801
7871
|
const send = (token2) => fetch(input, token2 ? withBearer(init, token2) : init);
|
|
7802
|
-
const token = await
|
|
7872
|
+
const token = await access2.forRequest();
|
|
7803
7873
|
response = await send(token);
|
|
7804
7874
|
if (response.status === 401 && token && !scopeChallengeOf(response)) {
|
|
7805
|
-
const next = await
|
|
7875
|
+
const next = await access2.renew(token);
|
|
7806
7876
|
if (next) {
|
|
7807
7877
|
await response.body?.cancel().catch(() => {
|
|
7808
7878
|
});
|
|
@@ -7830,7 +7900,7 @@ const connectionKey = (server) => JSON.stringify([
|
|
|
7830
7900
|
server.url,
|
|
7831
7901
|
...server.headers ? [server.headers] : []
|
|
7832
7902
|
]);
|
|
7833
|
-
const oauthFingerprint = (
|
|
7903
|
+
const oauthFingerprint = (access2) => access2?.access_token ? mcpOAuthFingerprint(access2.access_token) : "";
|
|
7834
7904
|
const mcpResultSchema = (structuredContent) => ({
|
|
7835
7905
|
type: "object",
|
|
7836
7906
|
properties: {
|
|
@@ -8012,25 +8082,25 @@ class McpManager {
|
|
|
8012
8082
|
}
|
|
8013
8083
|
/** 冻结配置带着已被续期淘汰的 token:换成当前 token,不回退 */
|
|
8014
8084
|
withoutRetired(key, server) {
|
|
8015
|
-
const
|
|
8016
|
-
if (!
|
|
8085
|
+
const access2 = this.oauth.get(key);
|
|
8086
|
+
if (!access2?.isRetired(server.oauth)) return server;
|
|
8017
8087
|
const { oauth: _retired, ...rest } = server;
|
|
8018
|
-
return
|
|
8088
|
+
return access2.current ? { ...rest, oauth: access2.current } : rest;
|
|
8019
8089
|
}
|
|
8020
8090
|
oauthFor(key, server) {
|
|
8021
|
-
let
|
|
8022
|
-
if (!
|
|
8091
|
+
let access2 = this.oauth.get(key);
|
|
8092
|
+
if (!access2) {
|
|
8023
8093
|
const { id: id2 } = server;
|
|
8024
8094
|
const { refreshOAuth } = this.options;
|
|
8025
8095
|
const renewer = id2 && refreshOAuth ? (rejected) => refreshOAuth(id2, rejected) : void 0;
|
|
8026
|
-
|
|
8096
|
+
access2 = new OAuthAccess(renewer, (renewed) => {
|
|
8027
8097
|
this.latestOAuth.set(key, renewed);
|
|
8028
8098
|
this.dispatched.set(key, oauthFingerprint(renewed));
|
|
8029
8099
|
this.failedUntil.delete(key);
|
|
8030
8100
|
});
|
|
8031
|
-
this.oauth.set(key,
|
|
8101
|
+
this.oauth.set(key, access2);
|
|
8032
8102
|
}
|
|
8033
|
-
return
|
|
8103
|
+
return access2;
|
|
8034
8104
|
}
|
|
8035
8105
|
connectionFor(dispatched) {
|
|
8036
8106
|
const key = connectionKey(dispatched);
|
|
@@ -8171,20 +8241,23 @@ class McpManager {
|
|
|
8171
8241
|
};
|
|
8172
8242
|
}
|
|
8173
8243
|
remoteFetchFor(server) {
|
|
8174
|
-
const
|
|
8175
|
-
|
|
8176
|
-
return remoteFetch(
|
|
8244
|
+
const access2 = this.oauthFor(connectionKey(server), server);
|
|
8245
|
+
access2.offer(server.oauth);
|
|
8246
|
+
return remoteFetch(access2, (challenge) => this.reportScopeChallenge(server, challenge));
|
|
8177
8247
|
}
|
|
8178
8248
|
createTransport(server) {
|
|
8179
8249
|
switch (server.transport) {
|
|
8180
8250
|
case "stdio": {
|
|
8181
8251
|
if (!server.command) throw new Error("stdio server missing command");
|
|
8182
|
-
return
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8252
|
+
return createStdioTransport(
|
|
8253
|
+
{
|
|
8254
|
+
command: server.command,
|
|
8255
|
+
args: server.args ?? [],
|
|
8256
|
+
// 不带 process.env 的话子进程连 PATH 都没有
|
|
8257
|
+
env: { ...process.env, ...server.env ?? {} }
|
|
8258
|
+
},
|
|
8259
|
+
this.options.processRegistryDir?.()
|
|
8260
|
+
);
|
|
8188
8261
|
}
|
|
8189
8262
|
case "http": {
|
|
8190
8263
|
if (!server.url) throw new Error("http server missing url");
|
|
@@ -9224,6 +9297,305 @@ const outputLimitRecoveryExtension = {
|
|
|
9224
9297
|
});
|
|
9225
9298
|
}
|
|
9226
9299
|
};
|
|
9300
|
+
const SHELLS$1 = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh"]);
|
|
9301
|
+
const SPLIT = /\|\|?|&&?|;|\n|\$\(|`|\)/;
|
|
9302
|
+
const GATED_PROTECTED = /* @__PURE__ */ new Set(["deploy", "payment", "external-send", "delete", "secret"]);
|
|
9303
|
+
const DISPATCH_TOOLS = /* @__PURE__ */ new Set([
|
|
9304
|
+
"session_create",
|
|
9305
|
+
"session_send",
|
|
9306
|
+
"todo_item_dispatch",
|
|
9307
|
+
"secretary_message",
|
|
9308
|
+
"session_takeover_propose",
|
|
9309
|
+
"schedule_add",
|
|
9310
|
+
"delegate",
|
|
9311
|
+
"retry_delegation",
|
|
9312
|
+
"routine_propose",
|
|
9313
|
+
"bridge_ask"
|
|
9314
|
+
]);
|
|
9315
|
+
const GH_WRITE = {
|
|
9316
|
+
pr: /* @__PURE__ */ new Set(["create", "merge", "close", "reopen", "comment", "review", "edit", "ready"]),
|
|
9317
|
+
issue: /* @__PURE__ */ new Set(["create", "close", "reopen", "comment", "edit"]),
|
|
9318
|
+
release: /* @__PURE__ */ new Set(["create", "delete", "upload", "edit"]),
|
|
9319
|
+
repo: /* @__PURE__ */ new Set(["create", "delete", "archive"])
|
|
9320
|
+
};
|
|
9321
|
+
const RELEASE_BINS = /* @__PURE__ */ new Set([
|
|
9322
|
+
"vercel",
|
|
9323
|
+
"wrangler",
|
|
9324
|
+
"firebase",
|
|
9325
|
+
"netlify",
|
|
9326
|
+
"changeset",
|
|
9327
|
+
"semantic-release"
|
|
9328
|
+
]);
|
|
9329
|
+
const RELEASE_VERBS = /* @__PURE__ */ new Set(["deploy", "publish", "upload", "release"]);
|
|
9330
|
+
const GIT_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
9331
|
+
"-C",
|
|
9332
|
+
"-c",
|
|
9333
|
+
"--git-dir",
|
|
9334
|
+
"--work-tree",
|
|
9335
|
+
"--namespace",
|
|
9336
|
+
"--super-prefix",
|
|
9337
|
+
"--config-env"
|
|
9338
|
+
]);
|
|
9339
|
+
const ZH_DENY = [
|
|
9340
|
+
"不同意",
|
|
9341
|
+
"不批准",
|
|
9342
|
+
"不允许",
|
|
9343
|
+
"不确认",
|
|
9344
|
+
"不可以",
|
|
9345
|
+
"拒绝",
|
|
9346
|
+
"取消",
|
|
9347
|
+
"不要",
|
|
9348
|
+
"不行",
|
|
9349
|
+
"禁止",
|
|
9350
|
+
"停止",
|
|
9351
|
+
"驳回"
|
|
9352
|
+
];
|
|
9353
|
+
const ZH_NEGATED_ALLOW = /(?:不|别|勿|未|没|暂不|先不|无需|不用)(?:要|能|可|准|必|再)?(?:同意|确认|批准|允许|放行|可以|行|执行|继续|推|发)/;
|
|
9354
|
+
const ZH_ALLOW = [
|
|
9355
|
+
"继续执行",
|
|
9356
|
+
"同意",
|
|
9357
|
+
"确认",
|
|
9358
|
+
"批准",
|
|
9359
|
+
"允许",
|
|
9360
|
+
"放行",
|
|
9361
|
+
"可以",
|
|
9362
|
+
"好的",
|
|
9363
|
+
"准了",
|
|
9364
|
+
"执行"
|
|
9365
|
+
];
|
|
9366
|
+
const EN_DENY = /\b(?:no|nope|deny|denied|reject|rejected|decline|declined|cancel|cancelled|canceled|abort|stop|disagree|disapprove)\b|\bdo not\b|\bnot approved\b|\bnot\b|(?:^|\s)don't(?:\s|$)/i;
|
|
9367
|
+
const EN_ALLOW = /\b(?:yes|yeah|yep|ok|okay|approve|approved|confirm|confirmed|allow|allowed|accept|accepted|proceed|lgtm)\b|\bgo ahead\b/i;
|
|
9368
|
+
function isRecord$1(value) {
|
|
9369
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9370
|
+
}
|
|
9371
|
+
function basename(token) {
|
|
9372
|
+
return token.slice(token.lastIndexOf("/") + 1);
|
|
9373
|
+
}
|
|
9374
|
+
function firstPositional(args) {
|
|
9375
|
+
return args.find((token) => token && !token.startsWith("-"));
|
|
9376
|
+
}
|
|
9377
|
+
function isOwnerConfirmationAnswer(answer) {
|
|
9378
|
+
const text2 = answer.trim();
|
|
9379
|
+
if (!text2) return false;
|
|
9380
|
+
if (ZH_DENY.some((phrase) => text2.includes(phrase))) return false;
|
|
9381
|
+
if (ZH_NEGATED_ALLOW.test(text2)) return false;
|
|
9382
|
+
if (/(?:^|[^\p{L}\p{N}])否(?:$|[^\p{L}\p{N}])/u.test(text2)) return false;
|
|
9383
|
+
if (EN_DENY.test(text2)) return false;
|
|
9384
|
+
if (ZH_ALLOW.some((phrase) => text2.includes(phrase))) return true;
|
|
9385
|
+
if (/(?:^|[^\p{L}\p{N}])行(?:$|[^\p{L}\p{N}])/u.test(text2)) return true;
|
|
9386
|
+
return EN_ALLOW.test(text2);
|
|
9387
|
+
}
|
|
9388
|
+
function gitSubcommand(args) {
|
|
9389
|
+
let index = 0;
|
|
9390
|
+
while (index < args.length) {
|
|
9391
|
+
const token = args[index];
|
|
9392
|
+
if (token === "--") {
|
|
9393
|
+
index += 1;
|
|
9394
|
+
break;
|
|
9395
|
+
}
|
|
9396
|
+
if (!token.startsWith("-")) break;
|
|
9397
|
+
if (GIT_VALUE_FLAGS.has(token)) {
|
|
9398
|
+
index += 2;
|
|
9399
|
+
continue;
|
|
9400
|
+
}
|
|
9401
|
+
if (/^(?:--git-dir|--work-tree|--namespace|--super-prefix|--config-env|-c)=/.test(token) || token.startsWith("-C") && token.length > 2) {
|
|
9402
|
+
index += 1;
|
|
9403
|
+
continue;
|
|
9404
|
+
}
|
|
9405
|
+
index += 1;
|
|
9406
|
+
}
|
|
9407
|
+
const sub = args[index];
|
|
9408
|
+
return sub && !sub.startsWith("-") ? sub : void 0;
|
|
9409
|
+
}
|
|
9410
|
+
function ghApiWrites(args) {
|
|
9411
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
9412
|
+
const token = args[index];
|
|
9413
|
+
if (/^(?:-f|-F|--field|--raw-field|--input)(?:=|$)/.test(token)) return true;
|
|
9414
|
+
if (token === "-X" || token === "--method") {
|
|
9415
|
+
const method = (args[index + 1] ?? "").toUpperCase();
|
|
9416
|
+
if (method && method !== "GET" && method !== "HEAD") return true;
|
|
9417
|
+
}
|
|
9418
|
+
const inline = /^(?:-X|--method=)([A-Za-z]+)$/.exec(token);
|
|
9419
|
+
if (inline && !/^(?:GET|HEAD)$/i.test(inline[1])) return true;
|
|
9420
|
+
}
|
|
9421
|
+
return false;
|
|
9422
|
+
}
|
|
9423
|
+
function ghAction(args) {
|
|
9424
|
+
const group = firstPositional(args);
|
|
9425
|
+
if (!group) return null;
|
|
9426
|
+
const rest = args.slice(args.indexOf(group) + 1);
|
|
9427
|
+
if (group === "workflow" && firstPositional(rest) === "run") return "gh workflow run";
|
|
9428
|
+
if (group === "api") return ghApiWrites(rest) ? "gh api" : null;
|
|
9429
|
+
const verb = firstPositional(rest);
|
|
9430
|
+
return verb && GH_WRITE[group]?.has(verb) ? `gh ${group} ${verb}` : null;
|
|
9431
|
+
}
|
|
9432
|
+
function releaseAction(program, args) {
|
|
9433
|
+
if (program === "firebase" && firstPositional(args) === "deploy") return "firebase deploy";
|
|
9434
|
+
if (program === "changeset" && firstPositional(args) === "publish") return "changeset publish";
|
|
9435
|
+
if (program === "semantic-release") return "semantic-release";
|
|
9436
|
+
const rest = program === "pnpm" && args[0] === "dlx" ? args.slice(1) : args;
|
|
9437
|
+
if (program !== "npx" && program !== "bunx" && !(program === "pnpm" && args[0] === "dlx"))
|
|
9438
|
+
return null;
|
|
9439
|
+
const binToken = firstPositional(rest);
|
|
9440
|
+
const bin = basename(binToken ?? "");
|
|
9441
|
+
if (!binToken || !RELEASE_BINS.has(bin)) return null;
|
|
9442
|
+
const verb = firstPositional(rest.slice(rest.indexOf(binToken) + 1));
|
|
9443
|
+
if (bin === "semantic-release" || bin === "changeset" || verb && RELEASE_VERBS.has(verb))
|
|
9444
|
+
return verb ? `${program} ${bin} ${verb}` : `${program} ${bin}`;
|
|
9445
|
+
return null;
|
|
9446
|
+
}
|
|
9447
|
+
function matchCommand(command2, depth) {
|
|
9448
|
+
if (depth >= 3) return null;
|
|
9449
|
+
for (const segment of command2.split(SPLIT)) {
|
|
9450
|
+
const tokens = programTokens(segment);
|
|
9451
|
+
if (tokens.length === 0) continue;
|
|
9452
|
+
const program = basename(tokens[0]);
|
|
9453
|
+
const args = tokens.slice(1);
|
|
9454
|
+
if (SHELLS$1.has(program)) {
|
|
9455
|
+
const flag = args.indexOf("-c");
|
|
9456
|
+
if (flag !== -1) {
|
|
9457
|
+
const inner = matchCommand(args.slice(flag + 1).join(" "), depth + 1);
|
|
9458
|
+
if (inner) return inner;
|
|
9459
|
+
}
|
|
9460
|
+
}
|
|
9461
|
+
if (program === "git") {
|
|
9462
|
+
const sub = gitSubcommand(args);
|
|
9463
|
+
if (sub === "push" || sub === "send-email")
|
|
9464
|
+
return { category: "command", action: `git ${sub}` };
|
|
9465
|
+
}
|
|
9466
|
+
if (program === "gh") {
|
|
9467
|
+
const action = ghAction(args);
|
|
9468
|
+
if (action) return { category: "command", action };
|
|
9469
|
+
}
|
|
9470
|
+
const release = releaseAction(program, args);
|
|
9471
|
+
if (release) return { category: "command", action: release };
|
|
9472
|
+
}
|
|
9473
|
+
return null;
|
|
9474
|
+
}
|
|
9475
|
+
function protectedAction(command2, depth = 0) {
|
|
9476
|
+
if (depth >= 3) return command2.trim();
|
|
9477
|
+
for (const segment of command2.split(SPLIT)) {
|
|
9478
|
+
if (!classifyProtectedCommand(segment)) continue;
|
|
9479
|
+
const tokens = programTokens(segment);
|
|
9480
|
+
const program = basename(tokens[0] ?? "");
|
|
9481
|
+
const args = tokens.slice(1);
|
|
9482
|
+
if (SHELLS$1.has(program)) {
|
|
9483
|
+
const flag = args.indexOf("-c");
|
|
9484
|
+
if (flag !== -1) return protectedAction(args.slice(flag + 1).join(" "), depth + 1);
|
|
9485
|
+
}
|
|
9486
|
+
const sub = firstPositional(args);
|
|
9487
|
+
if ((program === "pnpm" || program === "npm" || program === "yarn" || program === "bun") && (sub === "run" || sub === "run-script")) {
|
|
9488
|
+
const script = firstPositional(args.slice(args.indexOf(sub) + 1));
|
|
9489
|
+
return script ? `${program} run ${script}` : `${program} ${sub}`;
|
|
9490
|
+
}
|
|
9491
|
+
return sub ? `${program} ${sub}` : program || segment.trim();
|
|
9492
|
+
}
|
|
9493
|
+
return command2.trim();
|
|
9494
|
+
}
|
|
9495
|
+
function classifyOwnerGatedCommand(command2) {
|
|
9496
|
+
const direct = matchCommand(command2, 0);
|
|
9497
|
+
if (direct) return direct;
|
|
9498
|
+
const category = classifyProtectedCommand(command2);
|
|
9499
|
+
if (category && GATED_PROTECTED.has(category))
|
|
9500
|
+
return { category: "command", action: protectedAction(command2) };
|
|
9501
|
+
return null;
|
|
9502
|
+
}
|
|
9503
|
+
function classifyOwnerGatedTool(toolName, params) {
|
|
9504
|
+
if (DISPATCH_TOOLS.has(toolName) || toolName.endsWith("__bridge_ask") || toolName.endsWith("__cron_create")) {
|
|
9505
|
+
return { category: "dispatch", action: toolName };
|
|
9506
|
+
}
|
|
9507
|
+
const record = isRecord$1(params) ? params : void 0;
|
|
9508
|
+
if (toolName === "subagent") {
|
|
9509
|
+
const operation = record?.operation;
|
|
9510
|
+
return operation === "spawn" || operation === "send" || operation === "resume" ? { category: "subagent", action: `subagent ${operation}` } : null;
|
|
9511
|
+
}
|
|
9512
|
+
if (toolName === "workflow") {
|
|
9513
|
+
const stopOnly = Boolean(record?.stop) && !record?.preset && !record?.script && !record?.resume;
|
|
9514
|
+
return stopOnly ? null : { category: "subagent", action: "workflow" };
|
|
9515
|
+
}
|
|
9516
|
+
if ((toolName === "bash" || toolName === "powershell") && typeof record?.command === "string")
|
|
9517
|
+
return classifyOwnerGatedCommand(record.command);
|
|
9518
|
+
return null;
|
|
9519
|
+
}
|
|
9520
|
+
function describeTrigger(origin) {
|
|
9521
|
+
if (origin.kind !== "external") return "未知外部来源";
|
|
9522
|
+
const plugin = origin.pluginName || origin.pluginId;
|
|
9523
|
+
const who = origin.sender?.displayName || origin.sender?.userId || origin.sender?.chatId;
|
|
9524
|
+
if (plugin && who) return `插件 ${plugin},发送者 ${who}`;
|
|
9525
|
+
if (plugin) return `插件 ${plugin}`;
|
|
9526
|
+
return "未知外部来源";
|
|
9527
|
+
}
|
|
9528
|
+
function ownerGateError(gate, match) {
|
|
9529
|
+
return new Error(
|
|
9530
|
+
`需要 owner 确认(Owner confirmation required)。来源:${describeTrigger(gate.origin())}。被拦截的动作:${match.action}。请调用 ask_user 请 owner 确认(提供「同意」「拒绝」选项),或等待 owner 在会话或私聊里回复确认后再执行。未确认前禁止重试。`
|
|
9531
|
+
);
|
|
9532
|
+
}
|
|
9533
|
+
class OwnerGate {
|
|
9534
|
+
state = { kind: "owner", source: "user" };
|
|
9535
|
+
origin() {
|
|
9536
|
+
return this.state;
|
|
9537
|
+
}
|
|
9538
|
+
isOwner() {
|
|
9539
|
+
return this.state.kind === "owner";
|
|
9540
|
+
}
|
|
9541
|
+
observeMessage(message) {
|
|
9542
|
+
if (!isRecord$1(message)) return;
|
|
9543
|
+
if (message.role === "user") {
|
|
9544
|
+
this.state = { kind: "owner", source: "user" };
|
|
9545
|
+
return;
|
|
9546
|
+
}
|
|
9547
|
+
if (message.role !== "custom" || message.customType !== PLUGIN_MESSAGE_TYPE) return;
|
|
9548
|
+
const details2 = isRecord$1(message.details) ? message.details : {};
|
|
9549
|
+
const pluginId = typeof details2.pluginId === "string" ? details2.pluginId : "unknown";
|
|
9550
|
+
const pluginName = typeof details2.pluginName === "string" ? details2.pluginName : void 0;
|
|
9551
|
+
const sender = parsePluginInjectSender(details2.sender) ?? void 0;
|
|
9552
|
+
if (details2.origin === "owner") {
|
|
9553
|
+
this.state = { kind: "owner", source: details2.sender ? "plugin-owner" : "plugin-trusted" };
|
|
9554
|
+
return;
|
|
9555
|
+
}
|
|
9556
|
+
this.state = {
|
|
9557
|
+
kind: "external",
|
|
9558
|
+
pluginId,
|
|
9559
|
+
...pluginName ? { pluginName } : {},
|
|
9560
|
+
...sender ? { sender } : {}
|
|
9561
|
+
};
|
|
9562
|
+
}
|
|
9563
|
+
syncFromMessages(messages) {
|
|
9564
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
9565
|
+
const message = messages[index];
|
|
9566
|
+
if (!isRecord$1(message)) continue;
|
|
9567
|
+
const plugin = message.role === "custom" && message.customType === PLUGIN_MESSAGE_TYPE;
|
|
9568
|
+
if (message.role === "user" || plugin) {
|
|
9569
|
+
this.observeMessage(message);
|
|
9570
|
+
return;
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9573
|
+
}
|
|
9574
|
+
confirmByOwner() {
|
|
9575
|
+
this.state = { kind: "owner", source: "user-confirmed" };
|
|
9576
|
+
}
|
|
9577
|
+
handleAskUserAnswer(answer) {
|
|
9578
|
+
if (this.state.kind !== "external" || !isOwnerConfirmationAnswer(answer)) return false;
|
|
9579
|
+
this.confirmByOwner();
|
|
9580
|
+
return true;
|
|
9581
|
+
}
|
|
9582
|
+
}
|
|
9583
|
+
function applyOwnerAskResolution(gate, resolution) {
|
|
9584
|
+
if (!gate || resolution?.by !== "user" || typeof resolution.answer !== "string") return false;
|
|
9585
|
+
return gate.handleAskUserAnswer(resolution.answer);
|
|
9586
|
+
}
|
|
9587
|
+
function withOwnerGate(definition, gate) {
|
|
9588
|
+
return {
|
|
9589
|
+
...definition,
|
|
9590
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
9591
|
+
if (!gate.isOwner()) {
|
|
9592
|
+
const match = classifyOwnerGatedTool(definition.name, params);
|
|
9593
|
+
if (match) throw ownerGateError(gate, match);
|
|
9594
|
+
}
|
|
9595
|
+
return definition.execute(toolCallId, params, signal, onUpdate, ctx);
|
|
9596
|
+
}
|
|
9597
|
+
};
|
|
9598
|
+
}
|
|
9227
9599
|
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "out", "build", "coverage", "target"]);
|
|
9228
9600
|
const MAX_DIRS = 3e3;
|
|
9229
9601
|
const MAX_DEPTH = 10;
|
|
@@ -9478,7 +9850,12 @@ class PluginEventInvoker {
|
|
|
9478
9850
|
...message.images.map((image) => ({ type: "image", ...image }))
|
|
9479
9851
|
] : message.text,
|
|
9480
9852
|
display: true,
|
|
9481
|
-
details: {
|
|
9853
|
+
details: {
|
|
9854
|
+
pluginId: message.pluginId,
|
|
9855
|
+
pluginName: message.pluginName,
|
|
9856
|
+
...message.origin ? { origin: message.origin } : {},
|
|
9857
|
+
...message.sender ? { sender: message.sender } : {}
|
|
9858
|
+
}
|
|
9482
9859
|
},
|
|
9483
9860
|
{ deliverAs: message.deliverAs, triggerTurn: message.triggerTurn }
|
|
9484
9861
|
);
|
|
@@ -10723,6 +11100,329 @@ function enqueueReminder(queue, text2, limit = REMINDER_QUEUE_LIMIT) {
|
|
|
10723
11100
|
queue.unshift(overflowNotice(excess + (prior ? Number(prior[1]) : 0)));
|
|
10724
11101
|
return true;
|
|
10725
11102
|
}
|
|
11103
|
+
const REMINDER_RETRY_MS = 6e4;
|
|
11104
|
+
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
11105
|
+
class ReminderStore {
|
|
11106
|
+
constructor(file, onTick, onChange) {
|
|
11107
|
+
this.file = file;
|
|
11108
|
+
this.onTick = onTick;
|
|
11109
|
+
this.onChange = onChange;
|
|
11110
|
+
let raw;
|
|
11111
|
+
try {
|
|
11112
|
+
raw = JSON.parse(readFileSync(file, "utf8"));
|
|
11113
|
+
} catch {
|
|
11114
|
+
}
|
|
11115
|
+
this.data = parseReminderFile(raw);
|
|
11116
|
+
const loadedAt = Date.now();
|
|
11117
|
+
this.lateAtLoad = new Set(
|
|
11118
|
+
this.data.reminders.filter((item) => loadedAt - item.dueAt > REMINDER_LATE_MS).map((item) => item.id)
|
|
11119
|
+
);
|
|
11120
|
+
this.arm();
|
|
11121
|
+
}
|
|
11122
|
+
file;
|
|
11123
|
+
onTick;
|
|
11124
|
+
onChange;
|
|
11125
|
+
data;
|
|
11126
|
+
timer;
|
|
11127
|
+
retryAt;
|
|
11128
|
+
disposed = false;
|
|
11129
|
+
/** 加载时就已过点的:重启或 worker 停着期间到点 */
|
|
11130
|
+
lateAtLoad;
|
|
11131
|
+
missedWhileDown(id2) {
|
|
11132
|
+
return this.lateAtLoad.has(id2);
|
|
11133
|
+
}
|
|
11134
|
+
list(owner) {
|
|
11135
|
+
return this.data.reminders.filter((item) => item.sessionId === owner).sort((a, b) => a.dueAt - b.dueAt);
|
|
11136
|
+
}
|
|
11137
|
+
/** 根会话自己及其子会话 */
|
|
11138
|
+
forRoot(rootId) {
|
|
11139
|
+
return this.data.reminders.filter((item) => ownedByRoot(item.sessionId, rootId));
|
|
11140
|
+
}
|
|
11141
|
+
due(now) {
|
|
11142
|
+
return this.data.reminders.filter((item) => item.dueAt <= now).sort((a, b) => a.dueAt - b.dueAt);
|
|
11143
|
+
}
|
|
11144
|
+
newId() {
|
|
11145
|
+
for (; ; ) {
|
|
11146
|
+
const id2 = `r${randomBytes(4).toString("hex")}`;
|
|
11147
|
+
if (!this.data.reminders.some((item) => item.id === id2)) return id2;
|
|
11148
|
+
}
|
|
11149
|
+
}
|
|
11150
|
+
add(reminder) {
|
|
11151
|
+
this.data.reminders.push(reminder);
|
|
11152
|
+
this.commit([rootIdOfReminder(reminder.sessionId)]);
|
|
11153
|
+
}
|
|
11154
|
+
cancel(owner, id2) {
|
|
11155
|
+
const before = this.data.reminders.length;
|
|
11156
|
+
this.data.reminders = this.data.reminders.filter(
|
|
11157
|
+
(item) => !(item.sessionId === owner && item.id === id2)
|
|
11158
|
+
);
|
|
11159
|
+
if (this.data.reminders.length === before) return false;
|
|
11160
|
+
this.commit([rootIdOfReminder(owner)]);
|
|
11161
|
+
return true;
|
|
11162
|
+
}
|
|
11163
|
+
cancelAll(owner) {
|
|
11164
|
+
const before = this.data.reminders.length;
|
|
11165
|
+
this.data.reminders = this.data.reminders.filter((item) => item.sessionId !== owner);
|
|
11166
|
+
const removed = before - this.data.reminders.length;
|
|
11167
|
+
if (removed > 0) this.commit([rootIdOfReminder(owner)]);
|
|
11168
|
+
return removed;
|
|
11169
|
+
}
|
|
11170
|
+
/** 根会话及其所有子会话的提醒和链计数 */
|
|
11171
|
+
clear(rootId) {
|
|
11172
|
+
const before = this.data.reminders.length;
|
|
11173
|
+
this.data.reminders = this.data.reminders.filter(
|
|
11174
|
+
(item) => !ownedByRoot(item.sessionId, rootId)
|
|
11175
|
+
);
|
|
11176
|
+
const chains = Object.keys(this.data.chains).filter((key) => ownedByRoot(key, rootId));
|
|
11177
|
+
for (const key of chains) delete this.data.chains[key];
|
|
11178
|
+
if (this.data.reminders.length !== before || chains.length > 0) {
|
|
11179
|
+
this.commit(this.data.reminders.length !== before ? [rootId] : []);
|
|
11180
|
+
}
|
|
11181
|
+
}
|
|
11182
|
+
/** 先从存储删再交出:保证只投递一次 */
|
|
11183
|
+
take(id2) {
|
|
11184
|
+
const found = this.data.reminders.find((item) => item.id === id2);
|
|
11185
|
+
if (!found) return void 0;
|
|
11186
|
+
this.data.reminders = this.data.reminders.filter((item) => item !== found);
|
|
11187
|
+
this.commit([rootIdOfReminder(found.sessionId)]);
|
|
11188
|
+
return found;
|
|
11189
|
+
}
|
|
11190
|
+
chain(owner) {
|
|
11191
|
+
return this.data.chains[owner] ?? 0;
|
|
11192
|
+
}
|
|
11193
|
+
setChain(owner, count) {
|
|
11194
|
+
if (this.data.chains[owner] === count) return;
|
|
11195
|
+
this.data.chains[owner] = count;
|
|
11196
|
+
this.commit();
|
|
11197
|
+
}
|
|
11198
|
+
resetChain(owner) {
|
|
11199
|
+
if (this.data.chains[owner] === void 0) return;
|
|
11200
|
+
delete this.data.chains[owner];
|
|
11201
|
+
this.commit();
|
|
11202
|
+
}
|
|
11203
|
+
dispose() {
|
|
11204
|
+
this.disposed = true;
|
|
11205
|
+
clearTimeout(this.timer);
|
|
11206
|
+
this.timer = void 0;
|
|
11207
|
+
}
|
|
11208
|
+
commit(changedRootIds = []) {
|
|
11209
|
+
this.save();
|
|
11210
|
+
this.arm();
|
|
11211
|
+
if (changedRootIds.length > 0) this.onChange?.(changedRootIds);
|
|
11212
|
+
}
|
|
11213
|
+
save() {
|
|
11214
|
+
try {
|
|
11215
|
+
mkdirSync(path.dirname(this.file), { recursive: true });
|
|
11216
|
+
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
11217
|
+
writeFileSync(tmp, JSON.stringify(this.data));
|
|
11218
|
+
renameSync(tmp, this.file);
|
|
11219
|
+
} catch (error) {
|
|
11220
|
+
console.warn("[reminder] failed to persist reminders:", error);
|
|
11221
|
+
}
|
|
11222
|
+
}
|
|
11223
|
+
arm() {
|
|
11224
|
+
clearTimeout(this.timer);
|
|
11225
|
+
this.timer = void 0;
|
|
11226
|
+
if (this.disposed) return;
|
|
11227
|
+
if (this.data.reminders.length === 0) {
|
|
11228
|
+
this.retryAt = void 0;
|
|
11229
|
+
return;
|
|
11230
|
+
}
|
|
11231
|
+
const now = Date.now();
|
|
11232
|
+
let next = Number.POSITIVE_INFINITY;
|
|
11233
|
+
for (const item of this.data.reminders)
|
|
11234
|
+
next = Math.min(next, item.dueAt > now ? item.dueAt : this.retryAt ?? now);
|
|
11235
|
+
this.timer = setTimeout(() => this.tick(), Math.min(Math.max(0, next - now), MAX_TIMER_MS));
|
|
11236
|
+
this.timer.unref?.();
|
|
11237
|
+
}
|
|
11238
|
+
tick() {
|
|
11239
|
+
this.timer = void 0;
|
|
11240
|
+
this.retryAt = Date.now() + REMINDER_RETRY_MS;
|
|
11241
|
+
try {
|
|
11242
|
+
this.onTick();
|
|
11243
|
+
} finally {
|
|
11244
|
+
this.arm();
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
}
|
|
11248
|
+
const DURATION_RE = /^(\d+(?:\.\d+)?)\s*(s|sec|secs|seconds?|m|min|mins|minutes?|h|hr|hrs|hours?)?$/i;
|
|
11249
|
+
function parseReminderDelay(value) {
|
|
11250
|
+
const match = DURATION_RE.exec(value.trim());
|
|
11251
|
+
if (!match) return void 0;
|
|
11252
|
+
const amount = Number(match[1]);
|
|
11253
|
+
const unit = (match[2] ?? "s").toLowerCase()[0];
|
|
11254
|
+
const ms = amount * (unit === "h" ? 36e5 : unit === "m" ? 6e4 : 1e3);
|
|
11255
|
+
return Number.isFinite(ms) ? Math.round(ms) : void 0;
|
|
11256
|
+
}
|
|
11257
|
+
function formatReminderDuration(ms) {
|
|
11258
|
+
const seconds = Math.max(0, Math.round(ms / 1e3));
|
|
11259
|
+
if (seconds < 120) return `${seconds} seconds`;
|
|
11260
|
+
const minutes = Math.round(seconds / 60);
|
|
11261
|
+
if (minutes < 120) return `${minutes} minutes`;
|
|
11262
|
+
const hours = Math.floor(minutes / 60);
|
|
11263
|
+
const rest = minutes % 60;
|
|
11264
|
+
return rest ? `${hours} hours ${rest} minutes` : `${hours} hours`;
|
|
11265
|
+
}
|
|
11266
|
+
function localIso(ms) {
|
|
11267
|
+
const date = new Date(ms);
|
|
11268
|
+
const offset = -date.getTimezoneOffset();
|
|
11269
|
+
const pad2 = (value) => String(Math.floor(Math.abs(value))).padStart(2, "0");
|
|
11270
|
+
const local = new Date(ms + offset * 6e4).toISOString().slice(0, 19);
|
|
11271
|
+
return `${local}${offset >= 0 ? "+" : "-"}${pad2(offset / 60)}:${pad2(offset % 60)}`;
|
|
11272
|
+
}
|
|
11273
|
+
function normalizeRemindArgs(raw) {
|
|
11274
|
+
const args = raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : {};
|
|
11275
|
+
if (typeof args.in === "number") args.in = String(args.in);
|
|
11276
|
+
for (const key of ["in", "at", "label"])
|
|
11277
|
+
if (typeof args[key] === "string") args[key] = args[key].trim();
|
|
11278
|
+
if (args.ifIdle === "true") args.ifIdle = true;
|
|
11279
|
+
else if (args.ifIdle === "false") args.ifIdle = false;
|
|
11280
|
+
return args;
|
|
11281
|
+
}
|
|
11282
|
+
const text$1 = (value) => ({
|
|
11283
|
+
content: [{ type: "text", text: value }],
|
|
11284
|
+
details: void 0
|
|
11285
|
+
});
|
|
11286
|
+
function createReminderTools(store, ownerId, options) {
|
|
11287
|
+
const now = options.now ?? (() => Date.now());
|
|
11288
|
+
const maxText = formatReminderDuration(options.maxDelayMs);
|
|
11289
|
+
const limits = `Limits: at most ${REMINDER_MAX_PER_OWNER} pending reminders; between ${REMINDER_MIN_DELAY_MS / 1e3} seconds and ${maxText} away; at most ${REMINDER_MAX_CHAIN} reminders in a row set from reminder-triggered turns; prompt up to ${REMINDER_PROMPT_MAX} characters.`;
|
|
11290
|
+
const remind = {
|
|
11291
|
+
name: "remind_me",
|
|
11292
|
+
label: "Remind me",
|
|
11293
|
+
description: `Set a reminder for yourself: at the due time this session is woken with a new turn that carries your prompt. When waiting for CI, a deploy, a review or any external result, prefer remind_me and then end your turn — do not keep a background task alive just to wait (sleep N; ..., gh pr checks --watch, polling loops). Pass either \`in\` (e.g. "90s", "5m", "2h"; a bare number means seconds) or \`at\` (ISO time), not both. ${limits}`,
|
|
11294
|
+
promptSnippet: "remind_me: wake this session later with your own prompt (instead of sleep/--watch waits)",
|
|
11295
|
+
parameters: {
|
|
11296
|
+
type: "object",
|
|
11297
|
+
properties: {
|
|
11298
|
+
in: {
|
|
11299
|
+
type: "string",
|
|
11300
|
+
description: 'Delay from now, e.g. "90s", "5m", "2h"; bare number = seconds'
|
|
11301
|
+
},
|
|
11302
|
+
at: { type: "string", description: "Due time as an ISO 8601 timestamp" },
|
|
11303
|
+
prompt: {
|
|
11304
|
+
type: "string",
|
|
11305
|
+
description: "What to do when woken; write it so your future self can act on it directly"
|
|
11306
|
+
},
|
|
11307
|
+
label: { type: "string", description: `Short label (max ${REMINDER_LABEL_MAX} chars)` },
|
|
11308
|
+
ifIdle: {
|
|
11309
|
+
type: "boolean",
|
|
11310
|
+
description: "Default true: if a turn is running at the due time, wait until it ends. false: deliver into the running turn"
|
|
11311
|
+
}
|
|
11312
|
+
},
|
|
11313
|
+
required: ["prompt"]
|
|
11314
|
+
},
|
|
11315
|
+
prepareArguments: normalizeRemindArgs,
|
|
11316
|
+
async execute(_id, params) {
|
|
11317
|
+
const args = normalizeRemindArgs(params);
|
|
11318
|
+
const blocked = options.unavailable?.();
|
|
11319
|
+
if (blocked) throw new Error(blocked);
|
|
11320
|
+
const prompt = typeof args.prompt === "string" ? args.prompt.trim() : "";
|
|
11321
|
+
if (!prompt)
|
|
11322
|
+
throw new Error("prompt is required: write what to do when the reminder is due.");
|
|
11323
|
+
if (prompt.length > REMINDER_PROMPT_MAX)
|
|
11324
|
+
throw new Error(`prompt is too long (max ${REMINDER_PROMPT_MAX} characters).`);
|
|
11325
|
+
const label = args.label;
|
|
11326
|
+
if (label !== void 0 && typeof label !== "string")
|
|
11327
|
+
throw new Error("label must be a string.");
|
|
11328
|
+
if (typeof label === "string" && label.length > REMINDER_LABEL_MAX)
|
|
11329
|
+
throw new Error(`label is too long (max ${REMINDER_LABEL_MAX} characters).`);
|
|
11330
|
+
if (args.ifIdle !== void 0 && typeof args.ifIdle !== "boolean")
|
|
11331
|
+
throw new Error("ifIdle must be a boolean.");
|
|
11332
|
+
const hasIn = args.in !== void 0 && args.in !== "";
|
|
11333
|
+
const hasAt = args.at !== void 0 && args.at !== "";
|
|
11334
|
+
if (hasIn === hasAt) throw new Error("Pass exactly one of `in` or `at`.");
|
|
11335
|
+
const current = now();
|
|
11336
|
+
let delay;
|
|
11337
|
+
if (hasIn) {
|
|
11338
|
+
delay = typeof args.in === "string" ? parseReminderDelay(args.in) : void 0;
|
|
11339
|
+
if (delay === void 0)
|
|
11340
|
+
throw new Error('`in` must look like "90s", "5m" or "2h" (a bare number means seconds).');
|
|
11341
|
+
} else {
|
|
11342
|
+
const at = typeof args.at === "string" ? Date.parse(args.at) : Number.NaN;
|
|
11343
|
+
if (!Number.isFinite(at)) throw new Error("`at` must be an ISO 8601 timestamp.");
|
|
11344
|
+
delay = at - current;
|
|
11345
|
+
}
|
|
11346
|
+
if (delay < REMINDER_MIN_DELAY_MS)
|
|
11347
|
+
throw new Error(
|
|
11348
|
+
`A reminder must be at least ${REMINDER_MIN_DELAY_MS / 1e3} seconds away.`
|
|
11349
|
+
);
|
|
11350
|
+
if (delay > options.maxDelayMs)
|
|
11351
|
+
throw new Error(
|
|
11352
|
+
`A reminder can be at most ${maxText} away here.` + (ownerId.includes("::") ? " A subagent Run waits at most that long." : "")
|
|
11353
|
+
);
|
|
11354
|
+
const pending2 = store.list(ownerId).length;
|
|
11355
|
+
if (pending2 >= REMINDER_MAX_PER_OWNER)
|
|
11356
|
+
throw new Error(
|
|
11357
|
+
`You already have ${pending2} pending reminders (at most ${REMINDER_MAX_PER_OWNER}). Cancel one with reminder_cancel first.`
|
|
11358
|
+
);
|
|
11359
|
+
const chain2 = store.chain(ownerId) + 1;
|
|
11360
|
+
if (chain2 > REMINDER_MAX_CHAIN)
|
|
11361
|
+
throw new Error(
|
|
11362
|
+
`Reminders have already re-armed themselves ${REMINDER_MAX_CHAIN} times in a row without any other input. Stop waiting: report the current state instead.`
|
|
11363
|
+
);
|
|
11364
|
+
const reminder = {
|
|
11365
|
+
id: store.newId(),
|
|
11366
|
+
sessionId: ownerId,
|
|
11367
|
+
dueAt: current + delay,
|
|
11368
|
+
createdAt: current,
|
|
11369
|
+
prompt,
|
|
11370
|
+
...label ? { label } : {},
|
|
11371
|
+
ifIdle: args.ifIdle !== false,
|
|
11372
|
+
chain: chain2
|
|
11373
|
+
};
|
|
11374
|
+
store.add(reminder);
|
|
11375
|
+
return text$1(
|
|
11376
|
+
`Reminder ${reminder.id} set for ${localIso(reminder.dueAt)} (in ${formatReminderDuration(delay)}). ${pending2 + 1} pending. You will be woken with a new turn carrying your prompt; end this turn now instead of waiting.`
|
|
11377
|
+
);
|
|
11378
|
+
}
|
|
11379
|
+
};
|
|
11380
|
+
const list2 = {
|
|
11381
|
+
name: "reminder_list",
|
|
11382
|
+
label: "Reminder list",
|
|
11383
|
+
description: "List your pending reminders (set with remind_me).",
|
|
11384
|
+
promptSnippet: "reminder_list: list your pending reminders",
|
|
11385
|
+
parameters: { type: "object", properties: {} },
|
|
11386
|
+
async execute() {
|
|
11387
|
+
const items = store.list(ownerId);
|
|
11388
|
+
if (items.length === 0) return text$1("No pending reminders.");
|
|
11389
|
+
const current = now();
|
|
11390
|
+
return text$1(
|
|
11391
|
+
items.map(
|
|
11392
|
+
(item) => `- ${item.id}${item.label ? ` [${item.label}]` : ""} due ${localIso(item.dueAt)} (${item.dueAt > current ? `in ${formatReminderDuration(item.dueAt - current)}` : "due now"})${item.ifIdle ? "" : ", ifIdle=false"}`
|
|
11393
|
+
).join("\n")
|
|
11394
|
+
);
|
|
11395
|
+
}
|
|
11396
|
+
};
|
|
11397
|
+
const cancel = {
|
|
11398
|
+
name: "reminder_cancel",
|
|
11399
|
+
label: "Reminder cancel",
|
|
11400
|
+
description: 'Cancel one of your pending reminders by id, or all of them with id "all".',
|
|
11401
|
+
promptSnippet: 'reminder_cancel: cancel a pending reminder by id (or "all")',
|
|
11402
|
+
parameters: {
|
|
11403
|
+
type: "object",
|
|
11404
|
+
properties: { id: { type: "string", description: 'Reminder id, or "all"' } },
|
|
11405
|
+
required: ["id"]
|
|
11406
|
+
},
|
|
11407
|
+
async execute(_id, params) {
|
|
11408
|
+
const id2 = String(params.id ?? "").trim();
|
|
11409
|
+
if (!id2) throw new Error("id is required.");
|
|
11410
|
+
if (id2 === "all") return text$1(`Cancelled ${store.cancelAll(ownerId)} reminder(s).`);
|
|
11411
|
+
if (store.cancel(ownerId, id2)) return text$1(`Cancelled ${id2}.`);
|
|
11412
|
+
return text$1(
|
|
11413
|
+
`Reminder ${id2} not found. Pending: [${store.list(ownerId).map((item) => item.id).join(", ")}]`
|
|
11414
|
+
);
|
|
11415
|
+
}
|
|
11416
|
+
};
|
|
11417
|
+
return [remind, list2, cancel];
|
|
11418
|
+
}
|
|
11419
|
+
function reminderNotice(reminder, deliveredLateAt) {
|
|
11420
|
+
const late = deliveredLateAt === void 0 ? "" : ` It came due while EnsoCode was restarting or not running, so it is delivered late (now ${localIso(deliveredLateAt)}).`;
|
|
11421
|
+
return [
|
|
11422
|
+
`Reminder ${reminder.id}${reminder.label ? ` "${reminder.label}"` : ""} is due: you set it yourself with remind_me at ${localIso(reminder.createdAt)}, due ${localIso(reminder.dueAt)}.${late} Your note:`,
|
|
11423
|
+
reminder.prompt
|
|
11424
|
+
].join("\n");
|
|
11425
|
+
}
|
|
10726
11426
|
const SOFT_REQUEST_BUDGET = 200;
|
|
10727
11427
|
const BUDGET_STOP_GRACE_REQUESTS = 5;
|
|
10728
11428
|
function budgetStopThreshold(soft = SOFT_REQUEST_BUDGET) {
|
|
@@ -11778,6 +12478,9 @@ function selectEvictable(candidates, pinned, now, ttl = IDLE_SESSION_TTL_MS) {
|
|
|
11778
12478
|
(c) => !c.isChild && !pinned.has(c.sessionId) && c.status === "idle" && !c.hasPendingWork && !c.hasChildren && now - c.lastActivityAt >= ttl
|
|
11779
12479
|
).map((c) => c.sessionId);
|
|
11780
12480
|
}
|
|
12481
|
+
function isTurnInputEntry(entry) {
|
|
12482
|
+
return entry.type === "custom_message" ? entry.customType === PLUGIN_MESSAGE_TYPE : entry.type === "message" && entry.message?.role === "user";
|
|
12483
|
+
}
|
|
11781
12484
|
function resolveForkLeafId(branch, anchor) {
|
|
11782
12485
|
let start = -1;
|
|
11783
12486
|
if ("entryId" in anchor) {
|
|
@@ -11785,19 +12488,14 @@ function resolveForkLeafId(branch, anchor) {
|
|
|
11785
12488
|
if (start < 0) return void 0;
|
|
11786
12489
|
if (branch[start]?.type === "compaction") return branch[start].id;
|
|
11787
12490
|
} else {
|
|
11788
|
-
const
|
|
11789
|
-
|
|
11790
|
-
);
|
|
11791
|
-
|
|
11792
|
-
if (!user) return void 0;
|
|
11793
|
-
start = branch.findIndex((entry) => entry.id === user.id);
|
|
12491
|
+
const inputs = branch.filter(isTurnInputEntry);
|
|
12492
|
+
const input = inputs[inputs.length - 1 - anchor.turnIndexFromEnd];
|
|
12493
|
+
if (!input) return void 0;
|
|
12494
|
+
start = branch.indexOf(input);
|
|
11794
12495
|
}
|
|
11795
|
-
if (start < 0) return void 0;
|
|
11796
12496
|
let leaf = start;
|
|
11797
|
-
for (let i = start + 1; i < branch.length; i++) {
|
|
11798
|
-
|
|
11799
|
-
if (entry.type === "message" && entry.message?.role === "user") break;
|
|
11800
|
-
leaf = i;
|
|
12497
|
+
for (let i = start + 1; i < branch.length && !isTurnInputEntry(branch[i]); i++) {
|
|
12498
|
+
if (branch[i].type === "message" || branch[i].type === "custom_message") leaf = i;
|
|
11801
12499
|
}
|
|
11802
12500
|
return branch[leaf]?.id;
|
|
11803
12501
|
}
|
|
@@ -13644,7 +14342,7 @@ function createRoutineProposeTool(invoker) {
|
|
|
13644
14342
|
}
|
|
13645
14343
|
const MODEL_SCHEMA = {
|
|
13646
14344
|
type: "object",
|
|
13647
|
-
description:
|
|
14345
|
+
description: `Optional: an exact provider and model, checked before anything is created. For a virtual model the user configured (such as Auto), pass providerId "enso-virtual" and modelId the virtual model id. An unknown, disabled or credential-less provider or model is refused with an error that lists the usable models, virtual models included, and is never silently replaced by the default. Omit it to follow the project's default model.`,
|
|
13648
14346
|
properties: {
|
|
13649
14347
|
providerId: { type: "string", minLength: 1, maxLength: 200 },
|
|
13650
14348
|
modelId: { type: "string", minLength: 1, maxLength: 200 },
|
|
@@ -13662,6 +14360,11 @@ const SPECS = {
|
|
|
13662
14360
|
aliases: { id: "projectId", dir: "path", directory: "path", cwd: "path", sha: "contains" }
|
|
13663
14361
|
},
|
|
13664
14362
|
session_list: { keys: ["projectId", "limit"], numbers: ["limit"] },
|
|
14363
|
+
claims_list: { keys: ["prefix", "sessionId", "pluginId"] },
|
|
14364
|
+
threads_list: {
|
|
14365
|
+
keys: ["status", "sessionId", "repo", "activeOnly"],
|
|
14366
|
+
booleans: ["activeOnly"]
|
|
14367
|
+
},
|
|
13665
14368
|
session_read: {
|
|
13666
14369
|
keys: ["conversationId", "limit", "before", "index", "entryId", "offset"],
|
|
13667
14370
|
numbers: ["limit", "before", "index", "offset"],
|
|
@@ -13812,6 +14515,7 @@ const SPECS = {
|
|
|
13812
14515
|
"projectId",
|
|
13813
14516
|
"prompt",
|
|
13814
14517
|
"title",
|
|
14518
|
+
"goal",
|
|
13815
14519
|
"model",
|
|
13816
14520
|
"worktree",
|
|
13817
14521
|
"checkout",
|
|
@@ -14023,12 +14727,46 @@ const SCHEMAS = {
|
|
|
14023
14727
|
})
|
|
14024
14728
|
},
|
|
14025
14729
|
session_list: {
|
|
14026
|
-
description: "List root sessions across the projects you can see, newest first, with state and a short summary. Child sessions, archived
|
|
14730
|
+
description: "List root sessions across the projects you can see, newest first, with state and a short summary. Child sessions, sessions the user archived and other secretaries are excluded. A session you dispatched that an earlier version archived automatically when it finished is still listed, marked archived: true.",
|
|
14027
14731
|
parameters: object({
|
|
14028
14732
|
projectId: id("Optional: only sessions of this project"),
|
|
14029
14733
|
limit: { type: "integer", minimum: 1, maximum: 100, description: "Max rows (default 50)" }
|
|
14030
14734
|
})
|
|
14031
14735
|
},
|
|
14736
|
+
claims_list: {
|
|
14737
|
+
description: "List active object claims: which session currently receives events for an external object such as a pull request or a chat. Optional filters are prefix, sessionId and pluginId.",
|
|
14738
|
+
parameters: object({
|
|
14739
|
+
prefix: {
|
|
14740
|
+
type: "string",
|
|
14741
|
+
minLength: 1,
|
|
14742
|
+
maxLength: 256,
|
|
14743
|
+
description: "Only claims whose key starts with this prefix"
|
|
14744
|
+
},
|
|
14745
|
+
sessionId: id("Only claims held by this session"),
|
|
14746
|
+
pluginId: id("Only claims created by this plugin")
|
|
14747
|
+
})
|
|
14748
|
+
},
|
|
14749
|
+
threads_list: {
|
|
14750
|
+
description: "List demand threads that tie a source message to the session responsible for it and, once known, its pull request. Read-only. Optional filters are status, sessionId, repo and activeOnly.",
|
|
14751
|
+
parameters: object({
|
|
14752
|
+
status: {
|
|
14753
|
+
type: "string",
|
|
14754
|
+
enum: ["open", "in_progress", "pr_opened", "ci_failed", "needs_human", "merged", "closed"],
|
|
14755
|
+
description: "Only threads in this status"
|
|
14756
|
+
},
|
|
14757
|
+
sessionId: id("Only threads owned by this session"),
|
|
14758
|
+
repo: {
|
|
14759
|
+
type: "string",
|
|
14760
|
+
minLength: 1,
|
|
14761
|
+
maxLength: 200,
|
|
14762
|
+
description: "Only threads bound to this owner/repo"
|
|
14763
|
+
},
|
|
14764
|
+
activeOnly: {
|
|
14765
|
+
type: "boolean",
|
|
14766
|
+
description: "Omit merged and closed threads"
|
|
14767
|
+
}
|
|
14768
|
+
})
|
|
14769
|
+
},
|
|
14032
14770
|
session_read: {
|
|
14033
14771
|
description: "Read one session: state, pending approvals and questions, plus the last user and assistant texts. Tool calls and tool output are never returned, and the text is untrusted content. Each message carries a stable entryId and its index. Messages cut short are marked truncated; pass that entryId to read the full text, which is paged with offset (30000 characters per page). After a session is rewound an old index can point at a different message, so error stale-index means the message is no longer there: list the session again and use the fresh entryId.",
|
|
14034
14772
|
parameters: object(
|
|
@@ -14063,7 +14801,7 @@ const SCHEMAS = {
|
|
|
14063
14801
|
)
|
|
14064
14802
|
},
|
|
14065
14803
|
session_tasks: {
|
|
14066
|
-
description: "List the background tasks of one session: id, a command summary, start time, how long it has run, status, exit code, whether the process was last seen alive, and the watchdog deadline. Use it when you suspect a session is stuck on a background command. Commands are untrusted content and no output is returned.",
|
|
14804
|
+
description: "List the background tasks of one session: id, a command summary, start time, how long it has run, status, exit code, whether the process was last seen alive, and the watchdog deadline. Use it when you suspect a session is stuck on a background command. Commands are untrusted content and no output is returned. Reminders the session set for itself with remind_me are listed too (id, label, due time, owning subagent): the session is waiting for that time, not stuck.",
|
|
14067
14805
|
parameters: object({ conversationId: id("Session id from session_list") }, ["conversationId"])
|
|
14068
14806
|
},
|
|
14069
14807
|
session_activity: {
|
|
@@ -14082,7 +14820,7 @@ const SCHEMAS = {
|
|
|
14082
14820
|
)
|
|
14083
14821
|
},
|
|
14084
14822
|
session_create: {
|
|
14085
|
-
description: 'Create a normal visible session in a local project and send the first prompt. It runs right away and returns the conversationId. The session runs muted and unattended: approvals in it are refused automatically and its ask_user questions come to you. With worktree true you can pin the base: checkout picks an existing checkout of the project, baseRef the branch or commit to start from, branch the new branch name. With after the session is not created yet: it waits for the listed sessions and returns status "waiting" with a pendingId.',
|
|
14823
|
+
description: 'Create a normal visible session in a local project and send the first prompt. It runs right away and returns the conversationId. The session runs muted and unattended: approvals in it are refused automatically and its ask_user questions come to you. With worktree true you can pin the base: checkout picks an existing checkout of the project, baseRef the branch or commit to start from, branch the new branch name. With after the session is not created yet: it waits for the listed sessions and returns status "waiting" with a pendingId. When the dispatch limit is reached (yours, or the total across all secretaries) the call does not fail: the session is created with its worktree and branch but does not run yet, and you get status "queued" with conversationId and position. Queued sessions start automatically, first in first out, when a slot frees up; the user can also start one right away. Cancel a queued session with session_stop, which deletes it.',
|
|
14086
14824
|
parameters: object(
|
|
14087
14825
|
{
|
|
14088
14826
|
projectId: id("Target project id"),
|
|
@@ -14112,7 +14850,7 @@ const SCHEMAS = {
|
|
|
14112
14850
|
)
|
|
14113
14851
|
},
|
|
14114
14852
|
session_send: {
|
|
14115
|
-
description: 'Send a message to a session you dispatched, one the user handed over to you, or one whose project is in your takeover scope. mode "queue" (default) queues behind the current turn; mode "steer" is injected as soon as the current tool call ends, without waiting for the turn to finish, and starts a new turn when the session is idle. Refused while the session waits for the user, in both modes. A session reached through the scope starts reporting results to you only after this call. attachments forwards images instead of describing them: when the target model can see images they go in as images with the message, the same as the user pasting them, so the session does not need image_view (a model without image input gets the paths and opens them with image_view). Pass the screenshot the user sent rather than your own words about it. Pass goal when the session already reported goal-complete, was marked done by hand, never had a goal, or its goal is blocked or paused: the new goal is attached (a blocked or paused goal is replaced and audited) and the session keeps running until it is done or blocked, so the patrol watches it. Refused while its current goal is still active or waiting — a live goal is never replaced. Every send starts tracking the session again, even after it was marked done, completed, failed, was interrupted or stalled: the results of the follow-up reach you as usual.',
|
|
14853
|
+
description: 'Send a message to a session you dispatched, one the user handed over to you, or one whose project is in your takeover scope. mode "queue" (default) queues behind the current turn; mode "steer" is injected as soon as the current tool call ends, without waiting for the turn to finish, and starts a new turn when the session is idle. Refused while the session waits for the user, in both modes. Refused (session-queued) while the session is still queued behind the dispatch limit: wait for it to start or cancel it with session_stop. A session reached through the scope starts reporting results to you only after this call. attachments forwards images instead of describing them: when the target model can see images they go in as images with the message, the same as the user pasting them, so the session does not need image_view (a model without image input gets the paths and opens them with image_view). Pass the screenshot the user sent rather than your own words about it. Pass goal when the session already reported goal-complete, was marked done by hand, never had a goal, or its goal is blocked or paused: the new goal is attached (a blocked or paused goal is replaced and audited) and the session keeps running until it is done or blocked, so the patrol watches it. Refused while its current goal is still active or waiting — a live goal is never replaced. Every send starts tracking the session again, even after it was marked done, completed, failed, was interrupted or stalled: the results of the follow-up reach you as usual.',
|
|
14116
14854
|
parameters: object(
|
|
14117
14855
|
{
|
|
14118
14856
|
conversationId: id("Target session id"),
|
|
@@ -14150,7 +14888,7 @@ const SCHEMAS = {
|
|
|
14150
14888
|
)
|
|
14151
14889
|
},
|
|
14152
14890
|
session_stop: {
|
|
14153
|
-
description: 'Stop a session you dispatched, one the user handed over to you, or one whose project is in your takeover scope. The goal is paused and the session is not continued or woken again. The call waits up to 10 seconds for the worker to confirm and returns the real state: status "stopped" means it is down, status "running" means it was still running and the current turn may finish. Always trust the returned status, not the fact that you asked. Pass the pendingId of a dispatch that is waiting for dependencies as conversationId to cancel it. Queued messages are kept by default; pass clearQueue true to also drop the messages you queued, so they do not all fire the next time the session runs. Messages the user queued are never cleared. A session reached through the scope starts reporting results to you only after this call.',
|
|
14891
|
+
description: 'Stop a session you dispatched, one the user handed over to you, or one whose project is in your takeover scope. The goal is paused and the session is not continued or woken again. The call waits up to 10 seconds for the worker to confirm and returns the real state: status "stopped" means it is down, status "running" means it was still running and the current turn may finish. Always trust the returned status, not the fact that you asked. Pass the pendingId of a dispatch that is waiting for dependencies as conversationId to cancel it. Stopping a session that is still queued behind the dispatch limit cancels it: the never-started session, its worktree and branch are deleted, and it returns status "cancelled". Queued messages are kept by default; pass clearQueue true to also drop the messages you queued, so they do not all fire the next time the session runs. Messages the user queued are never cleared. A session reached through the scope starts reporting results to you only after this call.',
|
|
14154
14892
|
parameters: object(
|
|
14155
14893
|
{
|
|
14156
14894
|
conversationId: id("Target session id"),
|
|
@@ -14186,7 +14924,7 @@ const SCHEMAS = {
|
|
|
14186
14924
|
})
|
|
14187
14925
|
},
|
|
14188
14926
|
result_mark_done: {
|
|
14189
|
-
description: 'Close out a dispatch you know is finished but that still shows as in progress on the board. It is the same action as the "mark done" button on the board card: the dispatch record gets a manual goal-complete result and the session stops counting as running. A blocked or paused goal on the session is closed with it, so a later session_send with goal is not refused; result_mark_undo puts that goal back. Only sessions you dispatched or track are accepted; nothing else in the session is touched and nothing is stopped. The call is audited as a manual mark by the secretary. Use it when the session clearly finished its work but its result never arrived; if it is really still working, leave it alone.',
|
|
14927
|
+
description: 'Close out a dispatch you know is finished but that still shows as in progress on the board. It is the same action as the "mark done" button on the board card: the dispatch record gets a manual goal-complete result and the session stops counting as running. A blocked or paused goal on the session is closed with it, so a later session_send with goal is not refused; result_mark_undo puts that goal back. Only sessions you dispatched or track are accepted; nothing else in the session is touched and nothing is stopped. The call is audited as a manual mark by the secretary. Use it when the session clearly finished its work but its result never arrived; if it is really still working, leave it alone. A needsUser card you put to the user through ask_user with relatesTo clears itself once answered, so do not mark it.',
|
|
14190
14928
|
parameters: object({ conversationId: id("Session id from session_list or the board") }, [
|
|
14191
14929
|
"conversationId"
|
|
14192
14930
|
])
|
|
@@ -14339,18 +15077,29 @@ const SCHEMAS = {
|
|
|
14339
15077
|
)
|
|
14340
15078
|
},
|
|
14341
15079
|
todo_item_dispatch: {
|
|
14342
|
-
description:
|
|
15080
|
+
description: 'Turn a todo item into a dispatched session. It runs right away like session_create, with the same optional goal (defaults to the todo text), checkout / baseRef / branch to pin the base, after to wait for other sessions, and model. The first message uses the prompt you pass verbatim (with the todo text appended as background if not already included) and never injects default push or merge restrictions. Over the dispatch limit it is queued the same way as session_create (status "queued" with a position).',
|
|
14343
15081
|
parameters: object(
|
|
14344
15082
|
{
|
|
14345
15083
|
todoId: id("Todo id"),
|
|
14346
15084
|
projectId: id("Target project id"),
|
|
14347
|
-
prompt: {
|
|
15085
|
+
prompt: {
|
|
15086
|
+
type: "string",
|
|
15087
|
+
minLength: 1,
|
|
15088
|
+
maxLength: 8e3,
|
|
15089
|
+
description: "Optional first message; defaults to the todo text. When passed, it is used as-is with the todo text appended as background."
|
|
15090
|
+
},
|
|
14348
15091
|
title: {
|
|
14349
15092
|
type: "string",
|
|
14350
15093
|
minLength: 1,
|
|
14351
15094
|
maxLength: 200,
|
|
14352
15095
|
description: "Optional title; defaults to the todo text"
|
|
14353
15096
|
},
|
|
15097
|
+
goal: {
|
|
15098
|
+
type: "string",
|
|
15099
|
+
minLength: 1,
|
|
15100
|
+
maxLength: 4e3,
|
|
15101
|
+
description: "Optional goal; defaults to the todo text. The session keeps running until it is done or blocked."
|
|
15102
|
+
},
|
|
14354
15103
|
model: MODEL_SCHEMA,
|
|
14355
15104
|
worktree: {
|
|
14356
15105
|
type: "boolean",
|
|
@@ -15093,15 +15842,12 @@ function toolCalls(content) {
|
|
|
15093
15842
|
(part) => part?.type === "toolCall" && typeof part.name === "string" ? [{ name: part.name, args: part.arguments }] : []
|
|
15094
15843
|
);
|
|
15095
15844
|
}
|
|
15096
|
-
function isTrigger(entry) {
|
|
15097
|
-
return entry.type === "custom_message" ? entry.customType === PLUGIN_MESSAGE_TYPE : entry.type === "message" && entry.message?.role === "user";
|
|
15098
|
-
}
|
|
15099
15845
|
function planTurnDiscard(branch, readOnly = () => false) {
|
|
15100
15846
|
const plan = { triggers: [], run: [] };
|
|
15101
15847
|
for (let i = branch.length - 1; i >= 0; i--) {
|
|
15102
15848
|
const entry = branch[i];
|
|
15103
15849
|
if (PASSIVE.has(entry.type)) continue;
|
|
15104
|
-
if (
|
|
15850
|
+
if (isTurnInputEntry(entry)) {
|
|
15105
15851
|
plan.triggers.unshift(entry.id);
|
|
15106
15852
|
continue;
|
|
15107
15853
|
}
|
|
@@ -15142,7 +15888,7 @@ function turnDiscardEdits(plan, reason) {
|
|
|
15142
15888
|
}
|
|
15143
15889
|
function recallDiscarded(branch, id2) {
|
|
15144
15890
|
const entry = branch.find((item) => item.id === id2);
|
|
15145
|
-
const discarded = entry !== void 0 &&
|
|
15891
|
+
const discarded = entry !== void 0 && isTurnInputEntry(entry) && branch.some((item) => item.type === "context_edit" && item.targetId === id2);
|
|
15146
15892
|
if (!discarded) throw new Error(`No discarded turn input with id ${id2}.`);
|
|
15147
15893
|
const content = entry.type === "message" ? entry.message?.content : entry.content;
|
|
15148
15894
|
if (typeof content === "string") return content;
|
|
@@ -15249,6 +15995,7 @@ This session has no human watching it.
|
|
|
15249
15995
|
- Never ask a question in prose and stop, and never say you are waiting for approval. If you were about to ask, decide instead.
|
|
15250
15996
|
- Decide on the most reasonable assumption, state it in one line, and keep working.
|
|
15251
15997
|
- Stop only when a decision is irreversible and would change the user's data, account or money, or when the work cannot continue without it. Then say plainly which decision is needed and what you already did.
|
|
15998
|
+
- When you finish, call goal_complete with an optional result. Example: {"summary":"shipped","prs":[{"repo":"owner/repo","number":1,"state":"merged"}],"commits":["abc1234"]}
|
|
15252
15999
|
</unattended>`;
|
|
15253
16000
|
const UNATTENDED_ON_NOTE = `<unattended>
|
|
15254
16001
|
Unattended mode is ON: this session has no human watching it. ask_user and actions that need confirmation now fail immediately, so nothing waits for an answer.
|
|
@@ -15263,6 +16010,8 @@ This session has no human watching it. Questions you ask with ask_user go to the
|
|
|
15263
16010
|
- Use ask_user for product trade-offs or preferences, unclear requirements where a wrong guess is costly, and irreversible actions (deleting data, publishing, merging to main, deleting branches, touching accounts or money). Give 2-4 options and a default_option.
|
|
15264
16011
|
- After asking, wait for the answer; do not go ahead and do it yourself meanwhile. Never ask a question in prose and stop.
|
|
15265
16012
|
- Actions that need approval are still rejected automatically. Use an approach that needs no approval, or say in your report what was blocked.
|
|
16013
|
+
- To wait for CI, a deploy or another external result, set a reminder with remind_me and end your turn; do not keep a sleep or --watch command running just to wait.
|
|
16014
|
+
- When you finish, call goal_complete with an optional result. Example: {"summary":"shipped","prs":[{"repo":"owner/repo","number":1,"state":"merged"}],"commits":["abc1234"]}
|
|
15266
16015
|
</unattended>`;
|
|
15267
16016
|
const UNATTENDED_RELAY_ON_NOTE = `<unattended>
|
|
15268
16017
|
Unattended mode is ON: this session has no human watching it. ask_user now goes to the secretary that dispatched you; actions that need confirmation fail immediately.
|
|
@@ -16779,6 +17528,20 @@ class SessionSupervisor {
|
|
|
16779
17528
|
this.pendingNotifications = new PendingNotificationStore(
|
|
16780
17529
|
path.join(options.sessionDir, "pending-notifications")
|
|
16781
17530
|
);
|
|
17531
|
+
this.reminders = new ReminderStore(
|
|
17532
|
+
path.join(options.sessionDir, REMINDERS_FILE),
|
|
17533
|
+
() => this.onRemindersDue(),
|
|
17534
|
+
(rootIds) => {
|
|
17535
|
+
for (const rootId of rootIds) {
|
|
17536
|
+
const reminders = this.reminders.forRoot(rootId).sort((a, b) => a.dueAt - b.dueAt).map(toReminderSummary);
|
|
17537
|
+
this.options.emit({
|
|
17538
|
+
type: "session-reminders-changed",
|
|
17539
|
+
sessionId: rootId,
|
|
17540
|
+
reminders
|
|
17541
|
+
});
|
|
17542
|
+
}
|
|
17543
|
+
}
|
|
17544
|
+
);
|
|
16782
17545
|
this.bgTasks = new BackgroundTaskManager(
|
|
16783
17546
|
{
|
|
16784
17547
|
onStarted: (sessionId, task) => {
|
|
@@ -16840,7 +17603,7 @@ class SessionSupervisor {
|
|
|
16840
17603
|
} else if (child) {
|
|
16841
17604
|
child.childTaskNotices ??= [];
|
|
16842
17605
|
enqueueReminder(child.childTaskNotices, text2);
|
|
16843
|
-
}
|
|
17606
|
+
} else if (notifyOptions?.durable) this.persistUnopenedNotification(sessionId, text2);
|
|
16844
17607
|
return;
|
|
16845
17608
|
}
|
|
16846
17609
|
if (notifyOptions?.durable && !this.sessions.has(sessionId)) {
|
|
@@ -16877,6 +17640,8 @@ class SessionSupervisor {
|
|
|
16877
17640
|
sessions = /* @__PURE__ */ new Map();
|
|
16878
17641
|
/** 优雅重启:请求后每次状态变化复查;committed 后不再推进任何会话,等 Main 换进程 */
|
|
16879
17642
|
restart;
|
|
17643
|
+
/** 进程收尾中:此后中止的子代理回合不是 Run 的结局 */
|
|
17644
|
+
exiting = false;
|
|
16880
17645
|
/** 上一代 worker 的断点,按 sessionId 等对应的 spawn-parent 认领 */
|
|
16881
17646
|
restartResume = /* @__PURE__ */ new Map();
|
|
16882
17647
|
gate = new OperationGate();
|
|
@@ -16886,7 +17651,8 @@ class SessionSupervisor {
|
|
|
16886
17651
|
spawning = /* @__PURE__ */ new Map();
|
|
16887
17652
|
mcp = new McpManager({
|
|
16888
17653
|
emit: (event) => this.options.emit(event),
|
|
16889
|
-
refreshOAuth: (serverId, rejected) => this.requestMcpOAuthRefresh(serverId, rejected)
|
|
17654
|
+
refreshOAuth: (serverId, rejected) => this.requestMcpOAuthRefresh(serverId, rejected),
|
|
17655
|
+
processRegistryDir: () => this.options.dataDir && path.join(this.options.dataDir, MCP_SERVER_REGISTRY_DIR)
|
|
16890
17656
|
});
|
|
16891
17657
|
mcpOAuthPending = /* @__PURE__ */ new Map();
|
|
16892
17658
|
/** 插件经 Main 发起的宿主 MCP 调用,按 requestId 可取消 */
|
|
@@ -17000,6 +17766,9 @@ class SessionSupervisor {
|
|
|
17000
17766
|
this.deliverNotification(sessionId, text2);
|
|
17001
17767
|
});
|
|
17002
17768
|
pendingNotifications;
|
|
17769
|
+
reminders;
|
|
17770
|
+
/** 已请 Main 叫醒的根会话:同一会话在途只发一次,收到 fire/clear 或隔 60 秒才重发 */
|
|
17771
|
+
reminderDueSent = /* @__PURE__ */ new Map();
|
|
17003
17772
|
/** 已请 Main 打开、打开后要把待投递通知交给新一轮的会话 */
|
|
17004
17773
|
wakeOnOpen = /* @__PURE__ */ new Set();
|
|
17005
17774
|
/** spawn 尚未注册完就到达的内置工具开关,注册后补用 */
|
|
@@ -17096,10 +17865,70 @@ ${text2}
|
|
|
17096
17865
|
}
|
|
17097
17866
|
/** 打开的会话没在续跑上一轮:攒下的完成通知立即开一轮;在续跑的由轮末补投 */
|
|
17098
17867
|
wakeAfterOpen(managed) {
|
|
17868
|
+
this.fireDueReminders(managed);
|
|
17099
17869
|
if (!this.wakeOnOpen.delete(managed.identity.sessionId) || managed.currentTurnId !== void 0)
|
|
17100
17870
|
return;
|
|
17101
17871
|
this.flushPendingReminders(managed);
|
|
17102
17872
|
}
|
|
17873
|
+
/** 提醒定时器到点:子会话直接处理;根会话请 Main 判定后回 reminders-fire(冷会话先打开) */
|
|
17874
|
+
onRemindersDue() {
|
|
17875
|
+
const now = Date.now();
|
|
17876
|
+
const due = this.reminders.due(now);
|
|
17877
|
+
for (const owner of new Set(due.map((item) => item.sessionId))) {
|
|
17878
|
+
if (owner.includes("::")) {
|
|
17879
|
+
const child = this.sessions.get(owner);
|
|
17880
|
+
if (child) this.fireDueReminders(child);
|
|
17881
|
+
continue;
|
|
17882
|
+
}
|
|
17883
|
+
if (this.restart) continue;
|
|
17884
|
+
const managed = this.sessions.get(owner);
|
|
17885
|
+
if (managed && this.reminderBusy(managed) && due.every((item) => item.sessionId !== owner || item.ifIdle))
|
|
17886
|
+
continue;
|
|
17887
|
+
if (!managed && this.spawning.has(owner)) continue;
|
|
17888
|
+
const sent = this.reminderDueSent.get(owner);
|
|
17889
|
+
if (sent !== void 0 && now - sent < REMINDER_RETRY_MS) continue;
|
|
17890
|
+
this.reminderDueSent.set(owner, now);
|
|
17891
|
+
this.options.emit({ type: "session-reminder-due", sessionId: owner });
|
|
17892
|
+
}
|
|
17893
|
+
}
|
|
17894
|
+
reminderBusy(managed) {
|
|
17895
|
+
return managed.status === "running" || managed.roundPending === true || managed.currentTurnId !== void 0;
|
|
17896
|
+
}
|
|
17897
|
+
/**
|
|
17898
|
+
* 把该会话已到点的提醒交给它:先从存储删再投递,保证只发一次。
|
|
17899
|
+
* 正在跑且 ifIdle 的留到轮末;子代理不在 Run 里就丢弃(没人等它的结果)
|
|
17900
|
+
*/
|
|
17901
|
+
fireDueReminders(managed) {
|
|
17902
|
+
const id2 = managed.identity.sessionId;
|
|
17903
|
+
if (this.restart || this.sessions.get(id2) !== managed) return;
|
|
17904
|
+
const child = id2.includes("::");
|
|
17905
|
+
const busy = this.reminderBusy(managed);
|
|
17906
|
+
const texts = [];
|
|
17907
|
+
let chain2 = 0;
|
|
17908
|
+
for (const item of this.reminders.due(Date.now())) {
|
|
17909
|
+
if (item.sessionId !== id2) continue;
|
|
17910
|
+
if (child && !managed.agentRun) {
|
|
17911
|
+
this.reminders.take(item.id);
|
|
17912
|
+
continue;
|
|
17913
|
+
}
|
|
17914
|
+
if (busy && item.ifIdle) continue;
|
|
17915
|
+
if (!this.reminders.take(item.id)) continue;
|
|
17916
|
+
texts.push(
|
|
17917
|
+
reminderNotice(item, this.reminders.missedWhileDown(item.id) ? Date.now() : void 0)
|
|
17918
|
+
);
|
|
17919
|
+
chain2 = Math.max(chain2, item.chain);
|
|
17920
|
+
}
|
|
17921
|
+
if (texts.length === 0) return;
|
|
17922
|
+
this.reminders.setChain(id2, chain2);
|
|
17923
|
+
this.reminderDueSent.delete(id2);
|
|
17924
|
+
const text2 = texts.join("\n\n---\n\n");
|
|
17925
|
+
if (child && busy) {
|
|
17926
|
+
managed.childTaskNotices ??= [];
|
|
17927
|
+
enqueueReminder(managed.childTaskNotices, text2);
|
|
17928
|
+
return;
|
|
17929
|
+
}
|
|
17930
|
+
this.deliverNotification(id2, text2);
|
|
17931
|
+
}
|
|
17103
17932
|
restartDataDir() {
|
|
17104
17933
|
return this.options.dataDir ?? path.dirname(this.options.sessionDir);
|
|
17105
17934
|
}
|
|
@@ -17377,6 +18206,10 @@ ${text2}
|
|
|
17377
18206
|
this.longCacheRetention = command2.enabled;
|
|
17378
18207
|
return;
|
|
17379
18208
|
}
|
|
18209
|
+
if (command2.type === "set-app-logging") {
|
|
18210
|
+
setAppLoggingEnabled(command2.enabled);
|
|
18211
|
+
return;
|
|
18212
|
+
}
|
|
17380
18213
|
if (command2.type === "set-privacy-masking") {
|
|
17381
18214
|
configurePrivacyMasking(this.options.agentDir, command2.settings);
|
|
17382
18215
|
return;
|
|
@@ -17474,6 +18307,17 @@ ${text2}
|
|
|
17474
18307
|
);
|
|
17475
18308
|
return;
|
|
17476
18309
|
}
|
|
18310
|
+
if (command2.type === "reminders-fire") {
|
|
18311
|
+
this.reminderDueSent.delete(command2.sessionId);
|
|
18312
|
+
const managed = this.sessions.get(command2.sessionId);
|
|
18313
|
+
if (managed) this.fireDueReminders(managed);
|
|
18314
|
+
return;
|
|
18315
|
+
}
|
|
18316
|
+
if (command2.type === "reminders-clear") {
|
|
18317
|
+
this.reminderDueSent.delete(command2.sessionId);
|
|
18318
|
+
this.reminders.clear(command2.sessionId);
|
|
18319
|
+
return;
|
|
18320
|
+
}
|
|
17477
18321
|
const identity = command2.type === "browser-result" || command2.type === "memory-result" || command2.type === "delegation-result" || command2.type === "secretary-result" || command2.type === "computer-result" || command2.type === "plugin-tool-result" || command2.type === "plugin-tool-progress" || command2.type === "plugin-intercept-result" || command2.type === "plugin-inject" ? command2.identity : command2.type === "dismiss-child" || command2.type === "dismiss-coworker" || command2.type === "resume-coworker" ? command2.parent : command2.identity;
|
|
17478
18322
|
const scopeId = command2.type === "spawn-child" ? command2.identity.parent.sessionId : identity.sessionId;
|
|
17479
18323
|
if (this.workspaceSwitch.defer(scopeId, () => this.handleCommand(command2))) return;
|
|
@@ -17481,7 +18325,9 @@ ${text2}
|
|
|
17481
18325
|
if (touched) touched.lastActivityAt = Date.now();
|
|
17482
18326
|
if (command2.type === "abort") {
|
|
17483
18327
|
void this.execute(command2).catch((error) => {
|
|
17484
|
-
|
|
18328
|
+
const message = toErrorMessage(error);
|
|
18329
|
+
if (message.startsWith(STALE_SESSION_ERROR)) console.debug("[abort] skipped:", message);
|
|
18330
|
+
else console.error("[abort] failed:", message);
|
|
17485
18331
|
});
|
|
17486
18332
|
return;
|
|
17487
18333
|
}
|
|
@@ -17605,7 +18451,8 @@ ${text2}
|
|
|
17605
18451
|
command2.instanceId,
|
|
17606
18452
|
command2.workflowPresetFiles,
|
|
17607
18453
|
command2.secretaryTools,
|
|
17608
|
-
command2.askRelay
|
|
18454
|
+
command2.askRelay,
|
|
18455
|
+
command2.dcgExemptRules
|
|
17609
18456
|
);
|
|
17610
18457
|
return;
|
|
17611
18458
|
case "spawn-child":
|
|
@@ -17669,6 +18516,7 @@ ${text2}
|
|
|
17669
18516
|
managed.currentTurnId = command2.requestId;
|
|
17670
18517
|
this.releaseRun(managed);
|
|
17671
18518
|
if (command2.requestBudget) managed.agentRun = { id: command2.requestId };
|
|
18519
|
+
this.reminders.resetChain(managed.identity.sessionId);
|
|
17672
18520
|
managed.turnAborted = false;
|
|
17673
18521
|
if (command2.requestBudget) managed.requestBudget?.arm();
|
|
17674
18522
|
else managed.requestBudget?.disarm();
|
|
@@ -17684,6 +18532,7 @@ ${text2}
|
|
|
17684
18532
|
case "prompt": {
|
|
17685
18533
|
const managed = this.must(command2.identity);
|
|
17686
18534
|
managed.plan?.supersede();
|
|
18535
|
+
this.reminders.resetChain(managed.identity.sessionId);
|
|
17687
18536
|
const images = command2.images?.map((image) => ({ type: "image", ...image }));
|
|
17688
18537
|
if (await this.interruptRetryIfAny(managed)) {
|
|
17689
18538
|
this.promptFresh(managed, command2.text, images, command2.deliveryId, command2.resume);
|
|
@@ -17720,7 +18569,7 @@ ${text2}
|
|
|
17720
18569
|
this.promptFresh(managed, command2.text, images, command2.deliveryId);
|
|
17721
18570
|
return;
|
|
17722
18571
|
}
|
|
17723
|
-
if (managed.
|
|
18572
|
+
if (managed.status !== "running" && !managed.session.isStreaming) {
|
|
17724
18573
|
this.promptFresh(managed, command2.text, images, command2.deliveryId);
|
|
17725
18574
|
return;
|
|
17726
18575
|
}
|
|
@@ -17756,6 +18605,16 @@ ${text2}
|
|
|
17756
18605
|
editUnfinishedAssistantForResume(managed.session);
|
|
17757
18606
|
} else editLatestAssistantForRetry(managed.session);
|
|
17758
18607
|
if (agent.state.messages.at(-1)?.role === "assistant") {
|
|
18608
|
+
if (managed.childIdentity && command2.requestBudget && this.awaitsOwnTasks(managed)) {
|
|
18609
|
+
this.releaseRun(managed);
|
|
18610
|
+
const run = { id: command2.turnId ?? randomUUID() };
|
|
18611
|
+
managed.agentRun = run;
|
|
18612
|
+
managed.requestBudget?.arm(command2.requestsUsed);
|
|
18613
|
+
this.holdRun(managed, run);
|
|
18614
|
+
this.flushPendingReminders(managed);
|
|
18615
|
+
this.fireDueReminders(managed);
|
|
18616
|
+
return;
|
|
18617
|
+
}
|
|
17759
18618
|
this.emitRetrySkipped(managed, "nothing-to-retry");
|
|
17760
18619
|
return;
|
|
17761
18620
|
}
|
|
@@ -17902,9 +18761,15 @@ ${text2}
|
|
|
17902
18761
|
return;
|
|
17903
18762
|
}
|
|
17904
18763
|
case "memory-result": {
|
|
17905
|
-
const
|
|
17906
|
-
if (!
|
|
17907
|
-
|
|
18764
|
+
const memory = this.must(command2.identity).memory;
|
|
18765
|
+
if (!memory?.resolve(command2)) {
|
|
18766
|
+
if (memory?.wasCancelled(command2.requestId)) {
|
|
18767
|
+
console.debug(
|
|
18768
|
+
`[memory] dropped late result for cancelled request ${command2.requestId}`
|
|
18769
|
+
);
|
|
18770
|
+
} else {
|
|
18771
|
+
console.warn(`[memory] dropped result for unknown request ${command2.requestId}`);
|
|
18772
|
+
}
|
|
17908
18773
|
}
|
|
17909
18774
|
return;
|
|
17910
18775
|
}
|
|
@@ -17948,7 +18813,9 @@ ${text2}
|
|
|
17948
18813
|
text: command2.text,
|
|
17949
18814
|
...command2.images?.length ? { images: command2.images } : {},
|
|
17950
18815
|
deliverAs: command2.deliverAs,
|
|
17951
|
-
triggerTurn: command2.triggerTurn
|
|
18816
|
+
triggerTurn: command2.triggerTurn,
|
|
18817
|
+
...command2.origin ? { origin: command2.origin } : {},
|
|
18818
|
+
...command2.sender ? { sender: command2.sender } : {}
|
|
17952
18819
|
});
|
|
17953
18820
|
if (!delivered?.ok) {
|
|
17954
18821
|
console.warn("[plugin-inject]", delivered?.error ?? "会话未接受注入");
|
|
@@ -17993,7 +18860,7 @@ ${text2}
|
|
|
17993
18860
|
}
|
|
17994
18861
|
const entryId = resolveForkLeafId(
|
|
17995
18862
|
managed.session.sessionManager.getBranch(),
|
|
17996
|
-
command2.entryId ? { entryId: command2.entryId } : {
|
|
18863
|
+
command2.entryId ? { entryId: command2.entryId } : { turnIndexFromEnd: command2.turnIndexFromEnd ?? 0 }
|
|
17997
18864
|
);
|
|
17998
18865
|
if (!entryId) {
|
|
17999
18866
|
this.options.emit({
|
|
@@ -18149,7 +19016,7 @@ ${text2}
|
|
|
18149
19016
|
console.warn("[compact] summary model unavailable:", toErrorMessage(error));
|
|
18150
19017
|
});
|
|
18151
19018
|
}
|
|
18152
|
-
async spawn(identity, cwd, model, resumeFile, reasoningEnabled = false, thinkingLevel, loadLocalSkills = true, skillPaths = [], mcpServers = [], approvalMode = "full", approvalReviewer, agentTypes = [], disabledTools = [], instruction, subagentModels = [], remote, loadHarnessAssets = false, windowsLocalShell, exploreFoldEnabled = false, hashlineEditEnabled = false, compactStrategy = "standard", smartCompactSummaryModel, smartCompactMode, memoryLanguage, requestedEditMode, rolePrompt, systemPrompt, systemPromptAppend, systemPromptBoost, refusalRetryPrompt, rtkEnabled = true, planMode, trustedProjectCode = [], botMode = false, botGroupTasks = false, protectedActions = false, botRoutines = false, secretaryMode = false, botWriteLock, botDelegationTask = false, pluginToolDescriptors = [], pluginEvents, dcgPath, autoRejectApprovals = false, botDiscussMode = false, instanceId, workflowPresetFiles = [], secretaryToolDescriptors = [], askRelay) {
|
|
19019
|
+
async spawn(identity, cwd, model, resumeFile, reasoningEnabled = false, thinkingLevel, loadLocalSkills = true, skillPaths = [], mcpServers = [], approvalMode = "full", approvalReviewer, agentTypes = [], disabledTools = [], instruction, subagentModels = [], remote, loadHarnessAssets = false, windowsLocalShell, exploreFoldEnabled = false, hashlineEditEnabled = false, compactStrategy = "standard", smartCompactSummaryModel, smartCompactMode, memoryLanguage, requestedEditMode, rolePrompt, systemPrompt, systemPromptAppend, systemPromptBoost, refusalRetryPrompt, rtkEnabled = true, planMode, trustedProjectCode = [], botMode = false, botGroupTasks = false, protectedActions = false, botRoutines = false, secretaryMode = false, botWriteLock, botDelegationTask = false, pluginToolDescriptors = [], pluginEvents, dcgPath, autoRejectApprovals = false, botDiscussMode = false, instanceId, workflowPresetFiles = [], secretaryToolDescriptors = [], askRelay, dcgExemptRules = []) {
|
|
18153
19020
|
const sessionId = identity.sessionId;
|
|
18154
19021
|
const sessionEditMode = resolveEditMode(requestedEditMode);
|
|
18155
19022
|
const toolEnabled = (id2) => !disabledTools.includes(id2);
|
|
@@ -18295,7 +19162,10 @@ ${text2}
|
|
|
18295
19162
|
protectedFloor: botMode || protectedActions,
|
|
18296
19163
|
autoReject: autoRejectApprovals,
|
|
18297
19164
|
...botMode ? { exemptFull: true, humanTimeoutMs: HUMAN_REQUEST_TIMEOUT_MS } : {},
|
|
18298
|
-
|
|
19165
|
+
commandGuard: withTempRootGuard(
|
|
19166
|
+
dcgPath ? withDcgExemptions(createDcgGuard(dcgPath), dcgExemptRules) : void 0
|
|
19167
|
+
),
|
|
19168
|
+
sessionTempDir: remote ? null : sessionTempDir(sessionId, { cwd })
|
|
18299
19169
|
}
|
|
18300
19170
|
);
|
|
18301
19171
|
const checkpoints = new CheckpointManager(
|
|
@@ -18361,7 +19231,14 @@ ${text2}
|
|
|
18361
19231
|
),
|
|
18362
19232
|
grep: createRemoteGrepToolDefinition(cwd, sshExecutor)
|
|
18363
19233
|
} : {
|
|
18364
|
-
read: withPathHints(
|
|
19234
|
+
read: withPathHints(
|
|
19235
|
+
wrapRead(
|
|
19236
|
+
createReadToolDefinition(cwd, {
|
|
19237
|
+
operations: localReadOperations
|
|
19238
|
+
})
|
|
19239
|
+
),
|
|
19240
|
+
cwd
|
|
19241
|
+
),
|
|
18365
19242
|
grep: withPathHints(createGrepToolDefinition(cwd), cwd)
|
|
18366
19243
|
};
|
|
18367
19244
|
const read = withProtectedFloor(toolGate, "read", stock.read);
|
|
@@ -18596,7 +19473,14 @@ ${text2}
|
|
|
18596
19473
|
...!toolEnabled(WORKSPACE_WRITE_TOOL_ID) || resolved?.tools === "readonly" || agentType?.tools === "readonly" ? readOnlyTools(childGate) : [
|
|
18597
19474
|
...buildBaseTools(childGate, void 0, agentType?.writeScope, taskOwnerId),
|
|
18598
19475
|
// 子代理要能读、停、表态自己起的任务,否则常驻任务会让持有中的 Run 收不了口
|
|
18599
|
-
...taskOwnerId ?
|
|
19476
|
+
...taskOwnerId ? [
|
|
19477
|
+
...createTaskTools(this.bgTasks, taskOwnerId),
|
|
19478
|
+
// 子代理的提醒只叫醒它自己,最长不超过 Run 持有上限
|
|
19479
|
+
...createReminderTools(this.reminders, taskOwnerId, {
|
|
19480
|
+
maxDelayMs: AGENT_RUN_HOLD_LIMIT_MS,
|
|
19481
|
+
unavailable: () => this.sessions.get(taskOwnerId)?.agentRun ? void 0 : "Reminders only work while you run a subagent Run for your parent."
|
|
19482
|
+
})
|
|
19483
|
+
] : []
|
|
18600
19484
|
],
|
|
18601
19485
|
...typed ? typeMcpTools : wrapMcpTools(childGate),
|
|
18602
19486
|
...childPluginTools,
|
|
@@ -18877,7 +19761,7 @@ ${text2}
|
|
|
18877
19761
|
secretaryMode ? withMandatoryApproval(gate, "mcp", tool) : withApproval(gate, "mcp", tool)
|
|
18878
19762
|
)
|
|
18879
19763
|
) : [],
|
|
18880
|
-
...builtin("ask_user", [createAskTool(askManager)]),
|
|
19764
|
+
...builtin("ask_user", [createAskTool(askManager, { secretary: secretaryMode })]),
|
|
18881
19765
|
...builtin("subagent", [unifiedSubagentTool]),
|
|
18882
19766
|
...builtin("workflow", [
|
|
18883
19767
|
createWorkflowTool({
|
|
@@ -18905,9 +19789,12 @@ ${text2}
|
|
|
18905
19789
|
]),
|
|
18906
19790
|
...exploreFold ? createExploreFoldTools(exploreFold) : [],
|
|
18907
19791
|
...builtin("turn_discard", createTurnDiscardTools(turnDiscard)),
|
|
18908
|
-
...builtin("background_tasks",
|
|
19792
|
+
...builtin("background_tasks", [
|
|
19793
|
+
...createTaskTools(this.bgTasks, sessionId),
|
|
19794
|
+
...createReminderTools(this.reminders, sessionId, { maxDelayMs: REMINDER_MAX_DELAY_MS })
|
|
19795
|
+
]),
|
|
18909
19796
|
...toolEnabled("goal") ? createGoalTools(
|
|
18910
|
-
(kind, note) => {
|
|
19797
|
+
(kind, note, result) => {
|
|
18911
19798
|
const managed2 = managedRef ?? this.sessions.get(sessionId);
|
|
18912
19799
|
if (!managed2) return;
|
|
18913
19800
|
this.options.emit({
|
|
@@ -18915,7 +19802,8 @@ ${text2}
|
|
|
18915
19802
|
identity: managed2.identity,
|
|
18916
19803
|
seq: ++managed2.seq,
|
|
18917
19804
|
kind,
|
|
18918
|
-
note
|
|
19805
|
+
note,
|
|
19806
|
+
...result ? { result } : {}
|
|
18919
19807
|
});
|
|
18920
19808
|
},
|
|
18921
19809
|
async (summary, signal) => {
|
|
@@ -18933,12 +19821,16 @@ ${text2}
|
|
|
18933
19821
|
const readonlyAgentTypes = new Set(
|
|
18934
19822
|
agentTypes.filter((type) => type.tools === "readonly").map((type) => type.name)
|
|
18935
19823
|
);
|
|
19824
|
+
const ownerGate = new OwnerGate();
|
|
18936
19825
|
const planGated = (tools) => tools.map(
|
|
18937
|
-
(tool) =>
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
19826
|
+
(tool) => withOwnerGate(
|
|
19827
|
+
withPlanGate(tool, {
|
|
19828
|
+
host: planHost,
|
|
19829
|
+
readonlyAgentTypes,
|
|
19830
|
+
agentTypeOf: (agentId) => spawnedAgentTypes.get(agentId)
|
|
19831
|
+
}),
|
|
19832
|
+
ownerGate
|
|
19833
|
+
)
|
|
18942
19834
|
);
|
|
18943
19835
|
const secretaryExtraToolNames = /* @__PURE__ */ new Set([
|
|
18944
19836
|
...pluginToolDescriptors.map((tool) => tool.name),
|
|
@@ -18973,6 +19865,7 @@ ${text2}
|
|
|
18973
19865
|
...customTools.length > 0 ? { customTools } : {},
|
|
18974
19866
|
sessionManager: resumeFile ? SessionManager.open(resumeFile, this.options.sessionDir, cwd) : SessionManager.create(cwd, this.options.sessionDir)
|
|
18975
19867
|
});
|
|
19868
|
+
ownerGate.syncFromMessages(session.messages);
|
|
18976
19869
|
installLongCacheRetention(session.agent, this.isLongCacheRetention);
|
|
18977
19870
|
const codemodeTools = codemodeHost.activeToolNames();
|
|
18978
19871
|
const cursorBridge = isCursorModel(piModel) ? attachCursorBridgeToSession(
|
|
@@ -18992,6 +19885,7 @@ ${text2}
|
|
|
18992
19885
|
checkpoints,
|
|
18993
19886
|
runawayGuard: runaway
|
|
18994
19887
|
});
|
|
19888
|
+
managedRef.ownerGate = ownerGate;
|
|
18995
19889
|
this.rememberMcpHotplug(
|
|
18996
19890
|
sessionId,
|
|
18997
19891
|
new Set(secretaryMode ? [] : directMcp.map((server) => this.mcpServerKey(server))),
|
|
@@ -19092,6 +19986,7 @@ ${text2}
|
|
|
19092
19986
|
(requestId, resolution) => {
|
|
19093
19987
|
const managed = this.sessions.get(identity.sessionId);
|
|
19094
19988
|
if (managed && isSameGeneration(managed.identity, identity)) {
|
|
19989
|
+
applyOwnerAskResolution(managed.ownerGate, resolution);
|
|
19095
19990
|
this.options.emit({
|
|
19096
19991
|
type: "ask-resolved",
|
|
19097
19992
|
identity: managed.identity,
|
|
@@ -19099,7 +19994,9 @@ ${text2}
|
|
|
19099
19994
|
requestId,
|
|
19100
19995
|
...resolution?.by ? { by: resolution.by } : {},
|
|
19101
19996
|
...resolution?.answer ? { answer: resolution.answer } : {},
|
|
19102
|
-
...resolution?.name ? { name: resolution.name } : {}
|
|
19997
|
+
...resolution?.name ? { name: resolution.name } : {},
|
|
19998
|
+
...resolution?.relatesTo ? { relatesTo: resolution.relatesTo } : {},
|
|
19999
|
+
...resolution?.askedAt !== void 0 ? { askedAt: resolution.askedAt } : {}
|
|
19103
20000
|
});
|
|
19104
20001
|
}
|
|
19105
20002
|
},
|
|
@@ -19718,6 +20615,7 @@ ${snapshot}
|
|
|
19718
20615
|
if (managed) {
|
|
19719
20616
|
if (managed.agentRun?.holdTimer) this.stopAwaitedTasks(managed);
|
|
19720
20617
|
this.releaseRun(managed);
|
|
20618
|
+
this.reminders.cancelAll(coworkerId);
|
|
19721
20619
|
this.closeChildPlugins(managed, "dismissed");
|
|
19722
20620
|
managed.gate.cancelAll();
|
|
19723
20621
|
managed.asks.cancelAll();
|
|
@@ -19996,6 +20894,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
19996
20894
|
return;
|
|
19997
20895
|
}
|
|
19998
20896
|
case "message_start": {
|
|
20897
|
+
managed.ownerGate?.observeMessage(event.message);
|
|
19999
20898
|
const index = managed.messages.length;
|
|
20000
20899
|
const message = projectMessage(event.message);
|
|
20001
20900
|
if (message?.role === "assistant") {
|
|
@@ -20218,10 +21117,10 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20218
21117
|
return;
|
|
20219
21118
|
}
|
|
20220
21119
|
if (lastAssistant?.stopReason === "error") {
|
|
20221
|
-
const exhausted = managed.turnRetried === true && isRetryableAssistantError({
|
|
21120
|
+
const exhausted = managed.turnRetried === true && (isRetryableAssistantError({
|
|
20222
21121
|
stopReason: "error",
|
|
20223
21122
|
errorMessage: lastAssistant.errorMessage
|
|
20224
|
-
});
|
|
21123
|
+
}) || classifyUpstreamError({ error: lastAssistant.errorMessage }).kind === "transient");
|
|
20225
21124
|
this.failTurn(managed, lastAssistant.errorMessage ?? "Turn failed.", exhausted);
|
|
20226
21125
|
return;
|
|
20227
21126
|
}
|
|
@@ -20234,8 +21133,17 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20234
21133
|
return;
|
|
20235
21134
|
}
|
|
20236
21135
|
}
|
|
21136
|
+
/**
|
|
21137
|
+
* 收尾中止的是子代理 Run 的回合:照常收口(断点要它空闲),但不发回合结局,
|
|
21138
|
+
* 否则 Main 把被打断的 Run 记成已完成。Run 留在 running,Main 按 worker 退出记成被打断,重启后接着跑。
|
|
21139
|
+
*/
|
|
21140
|
+
exitingRun(managed) {
|
|
21141
|
+
return this.exiting && managed.agentRun !== void 0;
|
|
21142
|
+
}
|
|
20237
21143
|
/** 本轮成功收口。budget:子代理因请求预算被强制停止,带上标记(及补报告的错误)交回已有输出。 */
|
|
20238
21144
|
completeTurn(managed, budget) {
|
|
21145
|
+
const sessionId = managed.identity.sessionId;
|
|
21146
|
+
const quiet = this.exitingRun(managed);
|
|
20239
21147
|
const turnId = managed.currentTurnId ?? managed.abortedTurnId ?? randomUUID();
|
|
20240
21148
|
const aborted = managed.turnAborted === true;
|
|
20241
21149
|
const run = managed.agentRun;
|
|
@@ -20243,6 +21151,8 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20243
21151
|
const awaitingTasks = run !== void 0 && run.expiry !== "told" && !aborted && !budget && this.awaitsOwnTasks(managed);
|
|
20244
21152
|
if (awaitingTasks) this.holdRun(managed, run);
|
|
20245
21153
|
else this.releaseRun(managed);
|
|
21154
|
+
if (!awaitingTasks && !quiet && sessionId.includes("::")) this.reminders.cancelAll(sessionId);
|
|
21155
|
+
const awaitingReminder = !sessionId.includes("::") && this.reminders.list(sessionId).length > 0;
|
|
20246
21156
|
managed.currentTurnId = void 0;
|
|
20247
21157
|
managed.abortedTurnId = void 0;
|
|
20248
21158
|
managed.turnAborted = false;
|
|
@@ -20260,20 +21170,23 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20260
21170
|
managed.turnStartIndex = managed.messages.length;
|
|
20261
21171
|
this.workspaceClaims.release(managed.identity.sessionId);
|
|
20262
21172
|
if (!aborted && !budget) this.nudgeTaskWrapUp(managed);
|
|
20263
|
-
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
|
|
20268
|
-
|
|
20269
|
-
|
|
20270
|
-
|
|
20271
|
-
|
|
20272
|
-
|
|
20273
|
-
|
|
20274
|
-
|
|
20275
|
-
|
|
20276
|
-
|
|
21173
|
+
if (!quiet)
|
|
21174
|
+
this.options.emit({
|
|
21175
|
+
type: "turn-completed",
|
|
21176
|
+
identity: managed.identity,
|
|
21177
|
+
seq: ++managed.seq,
|
|
21178
|
+
turnId,
|
|
21179
|
+
...digest ? { digest } : {},
|
|
21180
|
+
...report ? { report } : {},
|
|
21181
|
+
...silent ? { silent: true } : {},
|
|
21182
|
+
...aborted ? { aborted: true } : {},
|
|
21183
|
+
...budget ? { requestBudgetStop: true } : {},
|
|
21184
|
+
...budget?.error ? { requestBudgetError: budget.error } : {},
|
|
21185
|
+
...continues ? { continues } : {},
|
|
21186
|
+
...awaitingTasks ? { awaitingTasks: true } : {},
|
|
21187
|
+
...awaitingReminder ? { awaitingReminder: true } : {},
|
|
21188
|
+
...managed.session.model?.provider ? { provider: managed.session.model.provider } : {}
|
|
21189
|
+
});
|
|
20277
21190
|
if (awaitingTasks) {
|
|
20278
21191
|
const fresh = this.takeUnnudged(managed);
|
|
20279
21192
|
if (fresh) this.queueReminder(managed, awaitChecklist(fresh, Date.now()));
|
|
@@ -20288,10 +21201,11 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20288
21201
|
void this.runCompaction(managed, queued.instructions);
|
|
20289
21202
|
}
|
|
20290
21203
|
this.flushPendingReminders(managed);
|
|
21204
|
+
this.fireDueReminders(managed);
|
|
20291
21205
|
}
|
|
20292
21206
|
/** 子代理还有自己起的、在跑、没表态的后台任务,或还有没交给它的完成通知 */
|
|
20293
21207
|
awaitsOwnTasks(managed) {
|
|
20294
|
-
return this.bgTasks.undeclared(managed.identity.sessionId).length > 0 || (managed.childTaskNotices?.length ?? 0) > 0 || managed.pendingTaskReminders.length > 0;
|
|
21208
|
+
return this.bgTasks.undeclared(managed.identity.sessionId).length > 0 || (managed.childTaskNotices?.length ?? 0) > 0 || managed.pendingTaskReminders.length > 0 || this.reminders.list(managed.identity.sessionId).length > 0;
|
|
20295
21209
|
}
|
|
20296
21210
|
/** 第一次持有起算时限:常驻服务、挂死的任务永远等不到完成,Run 不能跟着一直挂 */
|
|
20297
21211
|
holdRun(managed, run) {
|
|
@@ -20321,6 +21235,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20321
21235
|
stopAwaitedTasks(managed) {
|
|
20322
21236
|
for (const task of this.bgTasks.undeclared(managed.identity.sessionId))
|
|
20323
21237
|
this.bgTasks.stop(task.taskId, true);
|
|
21238
|
+
this.reminders.cancelAll(managed.identity.sessionId);
|
|
20324
21239
|
}
|
|
20325
21240
|
/** 没表态的任务里有没提醒过的:整批记为已提醒并返回,同一批任务只提醒一次 */
|
|
20326
21241
|
takeUnnudged(managed) {
|
|
@@ -20763,11 +21678,14 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20763
21678
|
});
|
|
20764
21679
|
}
|
|
20765
21680
|
failTurn(managed, error, retryExhausted = false) {
|
|
21681
|
+
const quiet = this.exitingRun(managed);
|
|
20766
21682
|
const turnId = managed.currentTurnId ?? managed.abortedTurnId ?? randomUUID();
|
|
20767
21683
|
const aborted = managed.turnAborted === true;
|
|
20768
21684
|
const run = managed.agentRun;
|
|
20769
21685
|
const continues = run && run.id !== turnId ? run.id : void 0;
|
|
20770
21686
|
this.releaseRun(managed);
|
|
21687
|
+
if (!quiet && managed.identity.sessionId.includes("::"))
|
|
21688
|
+
this.reminders.cancelAll(managed.identity.sessionId);
|
|
20771
21689
|
managed.currentTurnId = void 0;
|
|
20772
21690
|
managed.abortedTurnId = void 0;
|
|
20773
21691
|
managed.turnRetried = false;
|
|
@@ -20791,17 +21709,20 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20791
21709
|
}
|
|
20792
21710
|
this.emitStatus(managed, error);
|
|
20793
21711
|
this.workspaceClaims.release(managed.identity.sessionId);
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20802
|
-
|
|
20803
|
-
|
|
21712
|
+
if (!quiet)
|
|
21713
|
+
this.options.emit({
|
|
21714
|
+
type: "turn-failed",
|
|
21715
|
+
identity: managed.identity,
|
|
21716
|
+
seq: ++managed.seq,
|
|
21717
|
+
turnId,
|
|
21718
|
+
error,
|
|
21719
|
+
...retryExhausted ? { retryExhausted: true } : {},
|
|
21720
|
+
...aborted ? { aborted: true } : {},
|
|
21721
|
+
...continues ? { continues } : {},
|
|
21722
|
+
...managed.session.model?.provider ? { provider: managed.session.model.provider } : {}
|
|
21723
|
+
});
|
|
20804
21724
|
this.flushPendingReminders(managed);
|
|
21725
|
+
this.fireDueReminders(managed);
|
|
20805
21726
|
}
|
|
20806
21727
|
emitStatus(managed, error) {
|
|
20807
21728
|
this.flushStreamingUpsert(managed);
|
|
@@ -21067,6 +21988,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21067
21988
|
const deferred = [];
|
|
21068
21989
|
for (const sessionId of this.sessions.keys()) this.notifier.flush(sessionId);
|
|
21069
21990
|
for (const managed of this.sessions.values()) {
|
|
21991
|
+
this.bgTasks.detachBlockingWaits(managed.identity.sessionId, "restart");
|
|
21070
21992
|
const queued = managed.session.pendingMessageCount > 0;
|
|
21071
21993
|
if (queued) managed.restartHold?.();
|
|
21072
21994
|
const keep = restart.keepBackground === true;
|
|
@@ -21252,6 +22174,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21252
22174
|
}
|
|
21253
22175
|
async shutdown() {
|
|
21254
22176
|
clearInterval(this.evictionTimer);
|
|
22177
|
+
this.reminders.dispose();
|
|
21255
22178
|
this.workspaceSwitch.clear();
|
|
21256
22179
|
this.recordInterruptedTasks();
|
|
21257
22180
|
this.bgTasks.stopAll();
|
|
@@ -21259,6 +22182,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21259
22182
|
if (restartPending) await this.settleYieldedTasks(1e3);
|
|
21260
22183
|
if (restartPending)
|
|
21261
22184
|
for (const managed of this.sessions.values()) this.markRestartAbort(managed);
|
|
22185
|
+
this.exiting = true;
|
|
21262
22186
|
const aborts = [];
|
|
21263
22187
|
for (const managed of this.sessions.values()) {
|
|
21264
22188
|
cancelContinuousMemory(managed.session.sessionManager);
|
|
@@ -21288,7 +22212,10 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21288
22212
|
* 写不下就退回本代照常发完成通知(多半丢在退出路上,但不会重复)
|
|
21289
22213
|
*/
|
|
21290
22214
|
recordInterruptedTasks() {
|
|
21291
|
-
const records = this.bgTasks.interruptedOnShutdown(
|
|
22215
|
+
const records = this.bgTasks.interruptedOnShutdown(
|
|
22216
|
+
Date.now(),
|
|
22217
|
+
(sessionId) => this.restart?.committed === true && this.sessions.get(sessionId)?.agentRun !== void 0
|
|
22218
|
+
);
|
|
21292
22219
|
if (records.length === 0) return;
|
|
21293
22220
|
try {
|
|
21294
22221
|
appendInterruptedTasks(path.join(this.restartDataDir(), INTERRUPTED_TASKS_FILE), records);
|
|
@@ -22085,6 +23012,9 @@ if (!dataDir) {
|
|
|
22085
23012
|
throw new Error("ENSO_AGENT_DATA_DIR is required");
|
|
22086
23013
|
}
|
|
22087
23014
|
installCrashRecord(dataDir);
|
|
23015
|
+
setAppLoggingEnabled(process.env[APP_LOGGING_ENV] === "1");
|
|
23016
|
+
delete process.env[APP_LOGGING_ENV];
|
|
23017
|
+
installConsoleLog(path.join(dataDir, "logs", "agent.log"), "agent");
|
|
22088
23018
|
const restartCheckpointFile = process.env[RESTART_CHECKPOINT_ENV] || void 0;
|
|
22089
23019
|
delete process.env[RESTART_CHECKPOINT_ENV];
|
|
22090
23020
|
const supervisor = new SessionSupervisor({
|