@ensocode/server 0.3.10 → 0.3.12
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/LICENSE +679 -19
- package/out/phone/assets/{abnfDiagram-VCTEODGH-DEIRKSmB.js → abnfDiagram-VCTEODGH-D-9apHOZ.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-ihVIDRRt.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-CFZiReTQ.js → architectureDiagram-5GKGNRK7-B7ti5Yuy.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-CIBal5Ke.js → blockDiagram-I7D4REHJ-CMg6PHJB.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-Ce7SCOHL.js → c4Diagram-7LVT6UL2-YtDbC01g.js} +1 -1
- package/out/phone/assets/channel-BQsoblXW.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-COlQ1_VX.js → chunk-4HAMMTFA-Djg6ctlZ.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-L2CSsdYQ.js → chunk-75Z2AOVW-Be2kq0FP.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-juQC0nTX.js → chunk-DU6HZSFF-d5JZiOMy.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-CUQNf9_G.js → chunk-F27PBJKO-DHBQ6nrV.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW-BzsNlUWy.js → chunk-GMAD6QVW-BatU6uXC.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-a7Sg14KC.js → chunk-GVQU2GXP-CiyvoRIy.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-B86isBFr.js → chunk-IMKFNOWR-vOQaK90i.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-D9GQEj7C.js → chunk-L3NEJ4N5-CPykFzBy.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-ZHLE_p8D.js → chunk-OSK3NFVY-q4NiGH59.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-CIqiw4vs.js → chunk-P2QGCYS3-DUV9S_qP.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-pTX0vZo7.js → chunk-POPQ4Y6H-CjycswNE.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-BXK9ou77.js → chunk-PWAF6VOD-Dben6plA.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BLZNPdt8.js → chunk-SHT3W25Y-D2hK_jmb.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-wR8iPcjt.js → chunk-SVP7TREG-DLtgLN89.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-CueyYenv.js → chunk-TICWLB2K-BeBB0_0w.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-rwnxFDXp.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-rwnxFDXp.js +1 -0
- package/out/phone/assets/{cynefin-OW5HDTMX-LV70kdIp.js → cynefin-OW5HDTMX-CsDdLZPP.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-jSFJ3Ff1.js → cynefinDiagram-5FMLGOSQ-BcaPty-s.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-DnmK3Igj.js → dagre-GXQ25YYZ-o7dqm5ri.js} +1 -1
- package/out/phone/assets/desk-DNf6lCoq.js +2 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-KdmyjPOb.js → diagram-S7CK7UJ4-B5m8q3yP.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-D1D-C9ty.js → diagram-UQ7AKVKN-_lP617OW.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-CO_oZjy2.js → diagram-VSXAHHWV-D16twHR0.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-VLBWCwXT.js → diagram-VX7I27RA-BT8YSil1.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-wXmAYt0S.js → diagram-Z3DM3KII-CiSuhrxd.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-COmreC4F.js → ebnfDiagram-PWID7BFC-BbCXn4HA.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-YD40E3kV.js → erDiagram-RLTQ6QDP-5-xE_bP2.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-BVS2RGt-.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-BSlxj9Uk.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-CC0eW0wn.js → ganttDiagram-EL5Y4UJY-Rqgggqg_.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-BpKZk8Hu.js → gitGraph-4MIJSDKK-Drt18ZKK.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-BCK9rLLJ.js → gitGraphDiagram-WWUBYQGX-BQ5y4d2H.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-BKUEMrSk.js → info-A6RAGUB7-CpPeSHE0.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-6kVlxml9.js → infoDiagram-27XIBGKW-D3d9S0Y6.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-36KijlM2.js → ishikawaDiagram-5VMMS53U-plFMqx62.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-B3r6-igU.js → journeyDiagram-3NMN7TZE-CX-n-XXx.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-DDJMJ3eD.js → kanban-definition-UXKFOSKX-DrdTzKIc.js} +1 -1
- package/out/phone/assets/{line-CRvTNHUs.js → line-CqyaArNm.js} +1 -1
- package/out/phone/assets/main-BGlFv7yA.js +1658 -0
- package/out/phone/assets/main-BS1SSCau.css +1 -0
- package/out/phone/assets/{mermaid-parser.core-vpmsl7OW.js → mermaid-parser.core-CERMa6fg.js} +3 -3
- package/out/phone/assets/{mermaid.core-P6wqHn79.js → mermaid.core-CbGP2wFn.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-C1Qj4NCg.js → mindmap-definition-YA3MSWOX-BxaIrov6.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-dPa_bCkN.js → packet-AYTQ26CC-DguFQxPm.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-DP29zlwD.js → pegDiagram-XKGWAZYB-t3td03dz.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-B7gaGnZC.js → pie-WAS4IAKB-DoFu2rhu.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-BIv_DaLU.js → pieDiagram-E7YTZNPT-DctHLSL8.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-BRD0SxVe.js → quadrantDiagram-AXDQQJYC-Br7-ImNr.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-DSXX0eGO.js → radar-RG4KPBEZ-BDjTOHD8.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-CyBIlVYV.js → railroad-74A4TZTK-v8vsrpxb.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-CUELjEtC.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-DdIokM4i.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-DYyy0B-_.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-DqLjIO9E.js → railroadDiagram-O6MQD6OU-DtH4qQrr.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-DXMysPAW.js → requirementDiagram-BXWQKSXE-BSqejjZP.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CvbRufzx.js → sankeyDiagram-P5KCCOFB-DsTWuNtL.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-CFMJYkK9.js → sequenceDiagram-WJ2MYXX4-zLMvPyPC.js} +1 -1
- package/out/phone/assets/{stateDiagram-D77RDMKH-C--GDYGR.js → stateDiagram-D77RDMKH-DrBC05BN.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-DT7BlwvF.js +1 -0
- package/out/phone/assets/storage-BeJvYXAx.js +36 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-C_L9ypxQ.js → swimlanes-42K2YHIH-B27-qSm5.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-CWnm4v0A.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-BEk-ED-p.js → timeline-definition-24CTP7MA-8NDkGf5U.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-rolWZTr4.js → treeView-Q6P3EWNA-B9BXwCDC.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-CPWEaY39.js → treemap-WGGIJYW6-B0IqbwdT.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-CqImR0EN.js → vennDiagram-4TSXK5OY-Dp-aKgNa.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-CvTGA92O.js → wardley-WFR3VGLG-B7FlADZf.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-D9eDqbbx.js → wardleyDiagram-VM6X3IG4-BVntjQNl.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-DSenC7kX.js → xychartDiagram-S5SC5T6Z-kgVJvkgO.js} +1 -1
- package/out/phone/desk.html +2 -2
- package/out/phone/index.html +3 -3
- package/out/renderer/assets/{abnfDiagram-VCTEODGH-D81xzDT1.js → abnfDiagram-VCTEODGH-Bp0r3dKm.js} +1 -1
- package/out/renderer/assets/{arc-ByHjKist.js → arc-BD5HnhIt.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-Bw7RgtuP.js → architectureDiagram-5GKGNRK7-CgJHjETB.js} +1 -1
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-nNM7I115.js → blockDiagram-I7D4REHJ-5le9vk4G.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-xixXJMhC.js → c4Diagram-7LVT6UL2-B4DCe-qN.js} +1 -1
- package/out/renderer/assets/channel-D-HltTAP.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-C0KzftkI.js → chunk-2Q5K7J3B-DIxWfJHE.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-CuqKTpNC.js → chunk-5VM5RSS4-D9j4om1l.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-DyZs2_AC.js → chunk-F27PBJKO-B_tGbKyc.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-C7ktAo0J.js → chunk-IMKFNOWR-Cfffd1p9.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-CZpmOwpA.js → chunk-JWPE2WC7-BABZOPGb.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-CVFNZRTi.js → chunk-POPQ4Y6H-D-QyVpSn.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-DhMMCFNi.js → chunk-SVP7TREG-BghyPSd6.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-BsceTDhj.js → chunk-TICWLB2K-CQmthy6z.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-C_grf3wS.js → chunk-XXDRQBXY-CDKsbyR7.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-BCWhgMul.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BCWhgMul.js +1 -0
- package/out/renderer/assets/{cose-bilkent-JH36ORCC-wUQVmxx_.js → cose-bilkent-JH36ORCC-oajViFnN.js} +1 -1
- package/out/renderer/assets/{cynefin-OW5HDTMX-BR546Wt2.js → cynefin-OW5HDTMX-DMH1CUmI.js} +1 -1
- package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-Dp2jJhbH.js → cynefinDiagram-5FMLGOSQ-DVUJf9t0.js} +1 -1
- package/out/renderer/assets/{cytoscape-fcose-BJkAlKB8.js → cytoscape-fcose-adTZ191M.js} +1 -1
- package/out/renderer/assets/{dagre-GXQ25YYZ-XKFl5kxK.js → dagre-GXQ25YYZ-BXRWWNje.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-BBFt2zKx.js → diagram-S7CK7UJ4-Dg7f2Dan.js} +1 -1
- package/out/renderer/assets/{diagram-UQ7AKVKN-DA2CgkM2.js → diagram-UQ7AKVKN-DsLRyZAt.js} +1 -1
- package/out/renderer/assets/{diagram-VSXAHHWV-BL96nDcT.js → diagram-VSXAHHWV-3_LoodSS.js} +1 -1
- package/out/renderer/assets/{diagram-VX7I27RA-BYbjhI9j.js → diagram-VX7I27RA-DQeZp2Cz.js} +1 -1
- package/out/renderer/assets/{diagram-Z3DM3KII-BShKaR0Y.js → diagram-Z3DM3KII-Dwil6g5m.js} +1 -1
- package/out/renderer/assets/{ebnfDiagram-PWID7BFC-CxCXjhNE.js → ebnfDiagram-PWID7BFC-DecVNxpu.js} +1 -1
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-D6a85aJz.js → erDiagram-RLTQ6QDP-D2rmo2nP.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-D7vxYWv_.js → flowDiagram-HODETNUW-_SF2dRBl.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-D4bniC42.js → ganttDiagram-EL5Y4UJY-BoYWs5Ev.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-DREOVv8G.js → gitGraphDiagram-WWUBYQGX-BqRbZ3V0.js} +1 -1
- package/out/renderer/assets/globals-BEwCf508.css +1 -0
- package/out/renderer/assets/globals-C3zxoqqH.js +2603 -0
- package/out/renderer/assets/index-9vqh4wxi.js +133 -0
- package/out/renderer/assets/{infoDiagram-27XIBGKW-iQi9WT0H.js → infoDiagram-27XIBGKW-CFt6xyuD.js} +1 -1
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-CqPXH73H.js → ishikawaDiagram-5VMMS53U-CZB8G4dD.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-DjEyHtge.js → journeyDiagram-3NMN7TZE-CO2VRmpx.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-D-bxhvRO.js → kanban-definition-UXKFOSKX-DIqEnfMM.js} +1 -1
- package/out/renderer/assets/{layout-O4Dt9JSp.js → layout-DXRKfO_Y.js} +1 -1
- package/out/renderer/assets/{linear-B3fSR3zo.js → linear-Cdx1AdZJ.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DKfKek0K.js → mermaid.core-DuIO2jsm.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-CgWelgTn.js → mindmap-definition-YA3MSWOX-B5lvxG2M.js} +1 -1
- package/out/renderer/assets/{pegDiagram-XKGWAZYB-6YROVnYK.js → pegDiagram-XKGWAZYB-DCwHp-K3.js} +1 -1
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-BboI-zql.js → pieDiagram-E7YTZNPT-Dq048Wh7.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-Ckl9-8_q.js → quadrantDiagram-AXDQQJYC-DwkFkAi_.js} +1 -1
- package/out/renderer/assets/{railroadDiagram-O6MQD6OU-CBmldUiO.js → railroadDiagram-O6MQD6OU-2NKvwLP-.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-BhCPsXeE.js → requirementDiagram-BXWQKSXE-Bp44tNQ0.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-KCriZNRW.js → sankeyDiagram-P5KCCOFB-C3TFp1NK.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-BZRpmnqw.js → sequenceDiagram-WJ2MYXX4-BTPoYQeW.js} +1 -1
- package/out/renderer/assets/settings-DlDHkOe2.js +25 -0
- package/out/renderer/assets/{sizeCapture-INFHLROL-BHJ5WHSf.js → sizeCapture-INFHLROL-DvNj5TDT.js} +1 -1
- package/out/renderer/assets/{stateDiagram-D77RDMKH-DxHudD45.js → stateDiagram-D77RDMKH-DC8YykNp.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-B4rCEEYH.js +1 -0
- package/out/renderer/assets/{swimlanes-42K2YHIH-D2ZZdZPU.js → swimlanes-42K2YHIH-0yL1nNkg.js} +1 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-zQqW8MJ5.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-D4FtI5C_.js → timeline-definition-24CTP7MA-Pg-2roGv.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-BVq6hKjH.js → vennDiagram-4TSXK5OY-D0af5K4E.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-39qPSeSF.js → wardleyDiagram-VM6X3IG4-CB_nIy_l.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-IjWUG31x.js → xychartDiagram-S5SC5T6Z-A26Yld8R.js} +1 -1
- package/out/renderer/index.html +3 -3
- package/out/renderer/settings.html +4 -4
- package/out/renderer/web-preload.js +36 -36
- package/out/server/agent.js +276 -506
- package/out/server/chunks/{agent-BbLTL3oo.js → agent-D33nI7fP.js} +176 -195
- package/out/server/chunks/dispatchModel-CsfmL396.js +20 -0
- package/out/server/chunks/gpuBackendInstall-CRzfB150.js +237 -0
- package/out/server/chunks/{loadProvider-BOW5-6B-.js → loadProvider-4Y15KP7W.js} +2 -2
- package/out/server/chunks/{manifest-DjsZzZuh.js → manifest-wlfh-NN5.js} +2 -2
- package/out/server/chunks/{resources-DmaKIeBc.js → resources-DzUshg1j.js} +3 -3
- package/out/server/chunks/{storageScanWorker-BQ1LXUu7.js → storageScanWorker-CX8O_DlF.js} +2 -2
- package/out/server/chunks/{storageScanWorker-Bebego8l.js → storageScanWorker-CuttDIGS.js} +2 -2
- package/out/server/chunks/{workflowPresets-BtFDIu9c.js → workflowPresets-CAA0AY6f.js} +1091 -287
- package/out/server/index.js +2405 -3362
- package/out/server/plugin-host.js +2 -2
- package/package.json +2 -3
- package/out/phone/assets/architecture-7GRP2DOG-BQkxfRkk.js +0 -1
- package/out/phone/assets/channel-DGPU3seL.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-DgtztyWS.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-DgtztyWS.js +0 -1
- package/out/phone/assets/desk-BLXfa62y.js +0 -2
- package/out/phone/assets/eventmodeling-NTZA5JFV-DdkbB0R7.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-B86UG3OY.js +0 -1
- package/out/phone/assets/main-BU1pbfVw.css +0 -1
- package/out/phone/assets/main-C650ZDk2.js +0 -1658
- package/out/phone/assets/railroad-abnf-HS5TGJTU-Ea30PClf.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-BAOLVW4i.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-DiLa9rTe.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-C87lzpXA.js +0 -1
- package/out/phone/assets/storage-dUWOZ2xo.js +0 -36
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-CPaJpMYE.js +0 -8
- package/out/renderer/assets/channel-C9jBFK-_.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-B_o-oRUo.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-B_o-oRUo.js +0 -1
- package/out/renderer/assets/globals-1URrQWJU.js +0 -2603
- package/out/renderer/assets/globals-DoPyZAQo.css +0 -1
- package/out/renderer/assets/index-8xDwl1RO.js +0 -133
- package/out/renderer/assets/settings-DbHps6fb.js +0 -27
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-C0JE59RO.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-DJJObg42.js +0 -8
- package/out/server/chunks/engine-IZbRceya.js +0 -70
- package/out/server/chunks/engineWorker-CQxNRdLD.js +0 -6
- package/out/server/chunks/engineWorker-CrUIcXCt.js +0 -73
- package/out/server/chunks/gpuBackendInstall-DdJZ_JTr.js +0 -158
- package/out/server/chunks/hanbao-_aDjow_f.js +0 -187
- package/out/server/chunks/speech-CqK6_tIR.js +0 -25
- package/out/server/chunks/wetype-CR0YLhHP.js +0 -677
package/out/server/agent.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import path, { join, posix, dirname } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { A as AGENT_WORKER_CRASH_FILE, P as PatchMutationUncertainError, n as normalizeApplyPatchArguments, a as APPLY_PATCH_PROMPT_GUIDELINES, e as executeApplyPatch, b as emptyUsage, s as shellQuote, c as charsToTokens, t as toolOccupancyText, d as skillOccupancyText, f as estimateToolTokens, g as estimateSkillTokens, h as estimateInstructionTokens, V as VIRTUAL_PROVIDER_ID, p as providerKeyFor, O as OM_OBSERVATIONS_RECORDED, i as OM_REFLECTIONS_RECORDED, j as isObservationsRecordedData, k as isReflectionsRecordedData, l as isReflectionsConsolidatedData, m as isObservationsDroppedData, o as OM_REFLECTIONS_CONSOLIDATED, q as OM_OBSERVATIONS_DROPPED, r as OM_FOLDED, u as isMemoryDetails, v as isObservationsRecordedEntry, w as isReflectionsRecordedEntry, x as isReflectionsConsolidatedEntry, y as isObservationsDroppedEntry, z as buildObservationsRecordedData, B as buildReflectionsRecordedData, C as buildReflectionsConsolidatedData, D as buildObservationsDroppedData, E as readModelsDevCache, F as version, G as parseModelDirectorySnapshot, H as findCatalogModelById, I as findModelsDevModel, J as mergeCatalogEntry, K as resolveCustomModelCapabilities, L as closestMatchHint, M as mcpTimeoutMsOrDefault, N as oneLine$1, Q as mcpNamespaceName, R as assignMcpToolNames, S as MCP_OAUTH_REFRESH_SKEW_MS, T as mcpOAuthFingerprint, U as DEFAULT_MCP_CONNECT_TIMEOUT_MS, W as DEFAULT_MCP_CALL_TIMEOUT_MS, X as isXaiChatModelId, Y as transcriptMessages, Z as projectMessage, _ as ensureAccountProvider, $ as replacePersonaParagraph, a0 as takeSnapshotTail, a1 as attachBackgroundCommandHooks, a2 as ForegroundDetachedError, a3 as withFileBackedExec, a4 as withHardenedEnv, a5 as withDetachableExec, a6 as ELEVATE_ASKPASS_ENV, a7 as buildElevatedCommand, a8 as ELEVATE_DECLINED_MARKER, a9 as ELEVATE_TIMED_OUT_MARKER, aa as ELEVATE_TIMEOUT_MS, ab as ELEVATE_UNAVAILABLE_MARKER, ac as expandSkillCommands, ad as CODEMODE_FORBIDDEN_TOOLS, ae as normalizeTaskCheck, af as validateFetchUrl, ag as isPublicAddress, ah as throwUnlessAllowed, ai as readImageView, aj as resolveRoots, ak as systemImageRoots, al as wrapUntrusted, am as SEND_IMAGE_CAPTION_MAX, an as SEND_IMAGE_PER_REPLY, ao as sendImageItems, ap as prependTurnNote, aq as describeSubagentModels, ar as resolveWorkflowPresetArgs, as as extractWriteTargetPaths, at as programTokens, au as RESTART_CHECKPOINT_ARCHIVE, av as takeRestartCheckpoint, aw as BackgroundTaskManager, ax as takeDetachedTasksManifest, ay as DETACHED_TASKS_FILE, az as sweepOrphanRuns, aA as isDeferredMcp, aB as providerIdOfAccountKey, aC as resolveOauthCatalogModel, aD as createSshExecutor, aE as partitionMcpNamespaces, aF as CodemodeHost, aG as ApprovalGate, aH as HUMAN_REQUEST_TIMEOUT_MS, aI as TodoStaleReminder, aJ as CoworkerIdleReminder, aK as createUnifiedSubagentTool, aL as workflowPresetRoots, aM as withMandatoryApproval, aN as createBrowserTools, aO as withNavigateApproval, aP as createMemoryTools, aQ as withComputerApproval, aR as createComputerTool, aS as withApproval, aT as listWorkflowPresets, aU as createTaskTools, aV as BrowserInvoker, aW as MemoryInvoker, aX as PlanController, aY as ComputerInvoker, aZ as AskManager, a_ as createAskTool, a$ as snapshotMainConversation, b0 as lastAssistantText$1, b1 as positiveContextWindow, b2 as foregroundCommandTimeoutMs, b3 as buildTurnDigest, b4 as buildTurnReport, b5 as parseJsonFromAssistant, b6 as validateAgainstSchema, b7 as appendYieldJson, b8 as appendCappedLog, b9 as AGENT_COMPACTION_LOG, ba as restartGate, bb as writeRestartCheckpoint, bc as RESTART_CHECKPOINT_FILE, bd as writeDetachedTasksManifest, be as killRunGroup, bf as describeTitleModel, bg as buildRollingTitleUserText, bh as buildInitialTitleUserText, bi as ROLLING_TITLE_SYSTEM_PROMPT, bj as TITLE_SYSTEM_PROMPT, bk as extractTitle, bl as titleRejectReason, bm as resolveChildReasoning, bn as pickChildReasoningOverride, bo as createWebTools, bp as createTodoTool, bq as withPlanGate, br as createSubmitPlanTool, bs as titleSummaryTimeoutMs, bt as splitUnattendedPrefix, bu as resolveHarnessSkillRoots, bv as approvalReviewResultExtension, bw as readHarnessRuleFiles, bx as createProjectSettingsManager, by as CODEMODE_TOOL_NAME, bz as prepareCodemodeInput, bA as ANTIGRAVITY_PROVIDER_ID, bB as antigravityProviderConfig, bC as DEVIN_PROVIDER_ID, bD as devinProviderConfig, bE as QODER_PROVIDER_ID, bF as qoderProviderConfig, bG as QODER_CN_PROVIDER_ID, bH as installCodexLinkedRefresh, bI as isHeadlessRun, bJ as withBackground, bK as withProtectedFloor, bL as loadWorkflowPreset, bM as cloneModelsDevOauthModel, bN as withWriteScope, bO as withWritePreflight, bP as validateApplyPatchTargets, bQ as withAgentRead, bR as extractEditTargetPath, bS as buildSshShellCommand, bT as resolveSshControlPath, bU as sshPasswordEnv, bV as getApplyPatchPaths, bW as RESTART_CHECKPOINT_ENV } from "./chunks/workflowPresets-CAA0AY6f.js";
|
|
3
|
+
import { p as parseChildSessionIdentity, a as parseSessionIdentity, i as isApprovalReviewReason, b as parseApprovalAllowThreshold, c as isProbability, C as CONTEXT_OCCUPANCY_BUCKETS, d as CONTEXT_PART_ITEMS, e as parseProviderHeaders, M as MODEL_API_KINDS, r as resolvePiProviderBaseUrl, f as escapePiConfigValue, g as MODEL_REASONING_OVERRIDES, h as MODEL_THINKING_LEVEL_OVERRIDES, j as isCodexAccountKey, k as classifyCodexPoolFailure, l as isUuid, m as isChildInterceptEvent, P as PLUGIN_MESSAGE_TYPE, n as CONTEXT_USAGE_BUCKETS, B as BEFORE_AGENT_START_PROMPT_MAX, o as BEFORE_AGENT_START_APPEND_MAX, A as AGENT_END_TEXT_MAX, q as MaskReportBuilder, s as childProfileShell, S as SECRETARY_OPS, t as SECRETARY_ID_MAX, T as THINKING_LEVELS, u as SECRETARY_CONTACT_CAPTION_MAX, v as SECRETARY_ATTACHMENT_PATH_MAX, w as SECRETARY_ATTACHMENT_MAX, x as SECRETARY_SEND_MODES, y as SECRETARY_SESSION_MESSAGE_MAX, z as TOOL_RUN_TIMEOUT_MS, D as SILENCE_TURN_TOOL, E as workspaceBranchChangedNote, F as DEFAULT_MAX_ACTIVE_COWORKERS, G as DEFAULT_AUTO_RETRY_LIMIT, H as isSameChildSessionIdentity, I as resolveCompactStrategy, J as DEFAULT_SSH_TIMEOUT_SECONDS, K as isSecretaryToolAllowed, L as PLAN_ENTRY_TYPE, N as autoRetryOverrides, O as parseAgentSessionCustomEntry, Q as PLUGIN_AGENT_ARGS_MAX_CHARS, R as PLUGIN_AGENT_TEXT_MAX_CHARS, U as toolBatchDigest, V as turnRequestedSilence, W as turnCalledSilenceTurn, X as STALE_SESSION_ERROR, Y as WORKSPACE_WRITE_TOOL_ID, Z as splitPlanPrefix, _ as parsePlanMessage, $ as PLUGIN_AGENT_OUTPUT_MAX_CHARS, a0 as isClassifierOnlyProvider, a1 as isOauthAccountPool, a2 as resolveEditMode, a3 as EMPTY_PLAN_STATE, a4 as mergeMaskReports, a5 as PRIVACY_MASK_ENTRY, a6 as parseAgentCommand } from "./chunks/agent-D33nI7fP.js";
|
|
3
4
|
import "yaml";
|
|
4
|
-
import fs, { writeFileSync, statSync,
|
|
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-BOW5-6B-.js";
|
|
5
|
+
import fs, { writeFileSync, statSync, existsSync, readFileSync, mkdirSync, appendFileSync, unlinkSync, renameSync, rmSync, constants, realpathSync, readdirSync } from "node:fs";
|
|
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-4Y15KP7W.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,
|
|
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
13
|
import { rm, mkdtemp, readFile, stat, readdir, realpath, mkdir, lstat, open, unlink } from "node:fs/promises";
|
|
14
14
|
import "node:buffer";
|
|
15
15
|
import os, { tmpdir, homedir } from "node:os";
|
|
@@ -777,7 +777,7 @@ function decideManagedApproval(answers, model, allowThreshold) {
|
|
|
777
777
|
].join(" ");
|
|
778
778
|
return { decision: "deny", record: { verdict: "deny", ...base }, message };
|
|
779
779
|
}
|
|
780
|
-
function isRecord$
|
|
780
|
+
function isRecord$5(value) {
|
|
781
781
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
782
782
|
}
|
|
783
783
|
function num(value) {
|
|
@@ -798,17 +798,17 @@ function completeUsage(usage) {
|
|
|
798
798
|
cacheRead,
|
|
799
799
|
cacheWrite,
|
|
800
800
|
totalTokens,
|
|
801
|
-
cost: isRecord$
|
|
801
|
+
cost: isRecord$5(usage?.cost) ? { ...empty.cost, ...usage.cost } : empty.cost
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
804
|
function needsUsagePatch(usage) {
|
|
805
|
-
if (!isRecord$
|
|
806
|
-
return typeof usage.totalTokens !== "number" || !Number.isFinite(usage.totalTokens) || !isRecord$
|
|
805
|
+
if (!isRecord$5(usage)) return true;
|
|
806
|
+
return typeof usage.totalTokens !== "number" || !Number.isFinite(usage.totalTokens) || !isRecord$5(usage.cost);
|
|
807
807
|
}
|
|
808
808
|
function ensureAssistantUsage(messages) {
|
|
809
809
|
let patched = 0;
|
|
810
810
|
for (const message of messages) {
|
|
811
|
-
if (!isRecord$
|
|
811
|
+
if (!isRecord$5(message) || message.role !== "assistant") continue;
|
|
812
812
|
const assistant = message;
|
|
813
813
|
if (!needsUsagePatch(assistant.usage)) continue;
|
|
814
814
|
assistant.usage = completeUsage(assistant.usage);
|
|
@@ -1511,399 +1511,6 @@ function tailSystemPromptSection(name, text2) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
};
|
|
1513
1513
|
}
|
|
1514
|
-
const TOOL_NAMES = {
|
|
1515
|
-
bash: "Bash",
|
|
1516
|
-
powershell: "PowerShell",
|
|
1517
|
-
read: "Read",
|
|
1518
|
-
edit: "Edit",
|
|
1519
|
-
apply_patch: "Edit",
|
|
1520
|
-
write: "Write",
|
|
1521
|
-
grep: "Grep",
|
|
1522
|
-
find: "Glob",
|
|
1523
|
-
ls: "LS",
|
|
1524
|
-
web_fetch: "WebFetch",
|
|
1525
|
-
web_search: "WebSearch",
|
|
1526
|
-
subagent: "Task",
|
|
1527
|
-
todo: "TodoWrite"
|
|
1528
|
-
};
|
|
1529
|
-
const PATH_TOOLS = /* @__PURE__ */ new Set(["read", "edit", "write"]);
|
|
1530
|
-
const TEXT_CONTEXT_EVENTS = /* @__PURE__ */ new Set([
|
|
1531
|
-
"SessionStart",
|
|
1532
|
-
"UserPromptSubmit",
|
|
1533
|
-
"SubagentStart"
|
|
1534
|
-
]);
|
|
1535
|
-
const MAX_STOP_CONTINUATIONS = 3;
|
|
1536
|
-
const SESSION_END_WAIT_MS = 5e3;
|
|
1537
|
-
const OUTPUT_LIMIT = 1024 * 1024;
|
|
1538
|
-
const isRecord$5 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1539
|
-
const nonEmpty = (value) => typeof value === "string" && value.trim() ? value : void 0;
|
|
1540
|
-
function matchesHook(matcher, value) {
|
|
1541
|
-
if (!matcher || matcher === "*") return true;
|
|
1542
|
-
if (/^[\w\- ,|]+$/.test(matcher))
|
|
1543
|
-
return matcher.split(/[|,]/).some((name) => name.trim() === value);
|
|
1544
|
-
try {
|
|
1545
|
-
return new RegExp(matcher).test(value);
|
|
1546
|
-
} catch {
|
|
1547
|
-
return false;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
function toClaudeToolName(name) {
|
|
1551
|
-
return TOOL_NAMES[name] ?? name;
|
|
1552
|
-
}
|
|
1553
|
-
function toClaudeToolInput(name, input) {
|
|
1554
|
-
if (!PATH_TOOLS.has(name)) return { ...input };
|
|
1555
|
-
const { path: path2, ...rest } = input;
|
|
1556
|
-
const out = path2 === void 0 ? rest : { file_path: path2, ...rest };
|
|
1557
|
-
if (name === "edit") {
|
|
1558
|
-
const edits = input.edits;
|
|
1559
|
-
const single = Array.isArray(edits) && edits.length === 1 && isRecord$5(edits[0]) ? edits[0] : input;
|
|
1560
|
-
if (single.oldText !== void 0) {
|
|
1561
|
-
out.old_string = single.oldText;
|
|
1562
|
-
out.new_string = single.newText;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
return out;
|
|
1566
|
-
}
|
|
1567
|
-
function applyUpdatedInput(name, input, updated) {
|
|
1568
|
-
for (const [key, value] of Object.entries(updated)) {
|
|
1569
|
-
if (key === "file_path" && PATH_TOOLS.has(name)) {
|
|
1570
|
-
input.path = value;
|
|
1571
|
-
} else if (name === "edit" && (key === "old_string" || key === "new_string")) {
|
|
1572
|
-
const field = key === "old_string" ? "oldText" : "newText";
|
|
1573
|
-
const edits = input.edits;
|
|
1574
|
-
if (!Array.isArray(edits)) input[field] = value;
|
|
1575
|
-
else if (edits.length === 1 && isRecord$5(edits[0])) edits[0] = { ...edits[0], [field]: value };
|
|
1576
|
-
} else {
|
|
1577
|
-
input[key] = value;
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
function parseHookOutput(result, event) {
|
|
1582
|
-
const stderr = result.stderr.trim();
|
|
1583
|
-
if (result.timedOut) return { block: false, error: "timed out" };
|
|
1584
|
-
if (result.exitCode === 2) return { block: true, reason: stderr || "Blocked by hook" };
|
|
1585
|
-
if (result.exitCode !== 0) {
|
|
1586
|
-
const status = result.exitCode === null ? "failed to run" : `failed (exit ${result.exitCode})`;
|
|
1587
|
-
return { block: false, error: stderr ? `${status}: ${stderr.slice(0, 300)}` : status };
|
|
1588
|
-
}
|
|
1589
|
-
const text2 = result.stdout.trim();
|
|
1590
|
-
let json;
|
|
1591
|
-
if (text2.startsWith("{") && text2.endsWith("}")) {
|
|
1592
|
-
try {
|
|
1593
|
-
json = JSON.parse(text2);
|
|
1594
|
-
} catch {
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
if (!isRecord$5(json)) {
|
|
1598
|
-
return event && TEXT_CONTEXT_EVENTS.has(event) && text2 ? { block: false, additionalContext: text2 } : { block: false };
|
|
1599
|
-
}
|
|
1600
|
-
const halt = json.continue === false;
|
|
1601
|
-
const decisionBlock = json.decision === "block";
|
|
1602
|
-
const out = { block: halt || decisionBlock };
|
|
1603
|
-
if (halt) out.halt = true;
|
|
1604
|
-
if (decisionBlock) out.reason = nonEmpty(json.reason) ?? "Blocked by hook";
|
|
1605
|
-
else if (halt) out.reason = nonEmpty(json.stopReason) ?? "Stopped by hook";
|
|
1606
|
-
const systemMessage = nonEmpty(json.systemMessage);
|
|
1607
|
-
if (systemMessage) out.systemMessage = systemMessage;
|
|
1608
|
-
const specific = isRecord$5(json.hookSpecificOutput) ? json.hookSpecificOutput : {};
|
|
1609
|
-
const context = nonEmpty(specific.additionalContext);
|
|
1610
|
-
if (context) out.additionalContext = context;
|
|
1611
|
-
const decision = specific.permissionDecision;
|
|
1612
|
-
if (decision === "allow" || decision === "deny" || decision === "ask")
|
|
1613
|
-
out.permissionDecision = decision;
|
|
1614
|
-
const decisionReason = nonEmpty(specific.permissionDecisionReason);
|
|
1615
|
-
if (decisionReason) out.permissionDecisionReason = decisionReason;
|
|
1616
|
-
if (isRecord$5(specific.updatedInput)) out.updatedInput = specific.updatedInput;
|
|
1617
|
-
return out;
|
|
1618
|
-
}
|
|
1619
|
-
function collector() {
|
|
1620
|
-
const chunks = [];
|
|
1621
|
-
let size = 0;
|
|
1622
|
-
return {
|
|
1623
|
-
push: (chunk) => {
|
|
1624
|
-
if (size >= OUTPUT_LIMIT) return;
|
|
1625
|
-
const part = chunk.subarray(0, OUTPUT_LIMIT - size);
|
|
1626
|
-
chunks.push(part);
|
|
1627
|
-
size += part.length;
|
|
1628
|
-
},
|
|
1629
|
-
text: () => Buffer.concat(chunks).toString("utf8")
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
function createProcessHookRunner(cwd) {
|
|
1633
|
-
return (hook, input, signal) => new Promise((resolve) => {
|
|
1634
|
-
try {
|
|
1635
|
-
mkdirSync(hook.dataDir, { recursive: true });
|
|
1636
|
-
} catch {
|
|
1637
|
-
}
|
|
1638
|
-
const env = {
|
|
1639
|
-
...process.env,
|
|
1640
|
-
CLAUDE_PROJECT_DIR: cwd,
|
|
1641
|
-
CLAUDE_PLUGIN_ROOT: hook.root,
|
|
1642
|
-
CLAUDE_PLUGIN_DATA: hook.dataDir
|
|
1643
|
-
};
|
|
1644
|
-
let child;
|
|
1645
|
-
try {
|
|
1646
|
-
child = process.platform === "win32" ? spawn(hook.command, { cwd, env, shell: true, windowsHide: true }) : spawn(existsSync("/bin/bash") ? "/bin/bash" : "/bin/sh", ["-c", hook.command], {
|
|
1647
|
-
cwd,
|
|
1648
|
-
env,
|
|
1649
|
-
detached: true
|
|
1650
|
-
});
|
|
1651
|
-
} catch (error) {
|
|
1652
|
-
resolve({ exitCode: null, stdout: "", stderr: String(error) });
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
const stdout = collector();
|
|
1656
|
-
const stderr = collector();
|
|
1657
|
-
let timedOut = false;
|
|
1658
|
-
let settled = false;
|
|
1659
|
-
const finish2 = (exitCode, extra = "") => {
|
|
1660
|
-
if (settled) return;
|
|
1661
|
-
settled = true;
|
|
1662
|
-
clearTimeout(timer);
|
|
1663
|
-
signal?.removeEventListener("abort", kill);
|
|
1664
|
-
resolve({
|
|
1665
|
-
exitCode,
|
|
1666
|
-
stdout: stdout.text(),
|
|
1667
|
-
stderr: stderr.text() + extra,
|
|
1668
|
-
...timedOut ? { timedOut } : {}
|
|
1669
|
-
});
|
|
1670
|
-
};
|
|
1671
|
-
function kill() {
|
|
1672
|
-
killProcessTree(child, "SIGKILL");
|
|
1673
|
-
setTimeout(() => finish2(null), 1e3).unref();
|
|
1674
|
-
}
|
|
1675
|
-
const timer = setTimeout(
|
|
1676
|
-
() => {
|
|
1677
|
-
timedOut = true;
|
|
1678
|
-
kill();
|
|
1679
|
-
},
|
|
1680
|
-
(hook.timeoutSec ?? 600) * 1e3
|
|
1681
|
-
);
|
|
1682
|
-
signal?.addEventListener("abort", kill, { once: true });
|
|
1683
|
-
if (signal?.aborted) kill();
|
|
1684
|
-
child.stdout?.on("data", stdout.push);
|
|
1685
|
-
child.stderr?.on("data", stderr.push);
|
|
1686
|
-
child.on("error", (error) => finish2(null, error.message));
|
|
1687
|
-
child.on("close", (code) => finish2(code));
|
|
1688
|
-
child.stdin?.on("error", () => {
|
|
1689
|
-
});
|
|
1690
|
-
child.stdin?.end(JSON.stringify(input));
|
|
1691
|
-
});
|
|
1692
|
-
}
|
|
1693
|
-
const joinBlocks = (parts) => parts.filter((part) => !!part).join("\n\n");
|
|
1694
|
-
const blockReasons = (outs) => outs.filter((out) => out.block).map((out) => out.reason).join("\n");
|
|
1695
|
-
const contexts = (outs) => joinBlocks(outs.map((out) => out.additionalContext));
|
|
1696
|
-
function createClaudeHooksExtension(options) {
|
|
1697
|
-
const { hooks, cwd, role } = options;
|
|
1698
|
-
const run = options.run ?? createProcessHookRunner(cwd);
|
|
1699
|
-
const notice = (text2) => options.onNotice?.(text2);
|
|
1700
|
-
const present = new Set(hooks.map((hook) => hook.event));
|
|
1701
|
-
const has = (event) => present.has(event);
|
|
1702
|
-
const parent = role.kind === "parent";
|
|
1703
|
-
async function dispatch(event, ctx, fields, target, signal) {
|
|
1704
|
-
const matched = hooks.filter(
|
|
1705
|
-
(hook) => hook.event === event && (target === void 0 || matchesHook(hook.matcher, target))
|
|
1706
|
-
);
|
|
1707
|
-
if (matched.length === 0) return [];
|
|
1708
|
-
const input = {
|
|
1709
|
-
session_id: ctx.sessionManager.getSessionId(),
|
|
1710
|
-
transcript_path: ctx.sessionManager.getSessionFile() ?? "",
|
|
1711
|
-
cwd,
|
|
1712
|
-
hook_event_name: event,
|
|
1713
|
-
permission_mode: "default",
|
|
1714
|
-
...fields
|
|
1715
|
-
};
|
|
1716
|
-
return Promise.all(
|
|
1717
|
-
matched.map(async (hook) => {
|
|
1718
|
-
let out;
|
|
1719
|
-
try {
|
|
1720
|
-
out = parseHookOutput(await run(hook, input, signal), event);
|
|
1721
|
-
} catch (error) {
|
|
1722
|
-
out = { block: false, error: `failed to run: ${String(error)}` };
|
|
1723
|
-
}
|
|
1724
|
-
if (out.systemMessage) notice(`[${hook.plugin}] ${out.systemMessage}`);
|
|
1725
|
-
if (out.error) notice(`[${hook.plugin}] ${event} hook ${out.error}`);
|
|
1726
|
-
return out;
|
|
1727
|
-
})
|
|
1728
|
-
);
|
|
1729
|
-
}
|
|
1730
|
-
return {
|
|
1731
|
-
name: `claude-hooks-${role.kind}`,
|
|
1732
|
-
hidden: true,
|
|
1733
|
-
factory: (pi) => {
|
|
1734
|
-
const pending2 = [];
|
|
1735
|
-
const preToolContext = /* @__PURE__ */ new Map();
|
|
1736
|
-
let stopContinuations = 0;
|
|
1737
|
-
const stopEvent = parent ? "Stop" : "SubagentStop";
|
|
1738
|
-
const agentFields = (ctx) => role.kind === "subagent" ? { agent_type: role.agentType, agent_id: ctx.sessionManager.getSessionId() } : {};
|
|
1739
|
-
const startEvent = parent ? "SessionStart" : "SubagentStart";
|
|
1740
|
-
let started = !has(startEvent);
|
|
1741
|
-
const runStart = async (ctx) => {
|
|
1742
|
-
started = true;
|
|
1743
|
-
const source = options.resumed ? "resume" : "startup";
|
|
1744
|
-
const outs = role.kind === "parent" ? await dispatch("SessionStart", ctx, { source }, source) : await dispatch("SubagentStart", ctx, agentFields(ctx), role.agentType);
|
|
1745
|
-
const context = contexts(outs);
|
|
1746
|
-
if (context) pending2.push(context);
|
|
1747
|
-
};
|
|
1748
|
-
if (parent && has("SessionStart")) {
|
|
1749
|
-
pi.on("session_compact", async (_event, ctx) => {
|
|
1750
|
-
const context = contexts(
|
|
1751
|
-
await dispatch("SessionStart", ctx, { source: "compact" }, "compact")
|
|
1752
|
-
);
|
|
1753
|
-
if (context) pending2.push(context);
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
const runsPrompt = parent && has("UserPromptSubmit");
|
|
1757
|
-
if (has(startEvent) || runsPrompt || has(stopEvent)) {
|
|
1758
|
-
pi.on("before_agent_start", async (event, ctx) => {
|
|
1759
|
-
stopContinuations = 0;
|
|
1760
|
-
if (!started) await runStart(ctx);
|
|
1761
|
-
const parts = pending2.splice(0);
|
|
1762
|
-
if (runsPrompt && event.messageType === "user") {
|
|
1763
|
-
const outs = await dispatch(
|
|
1764
|
-
"UserPromptSubmit",
|
|
1765
|
-
ctx,
|
|
1766
|
-
{ prompt: event.prompt },
|
|
1767
|
-
void 0,
|
|
1768
|
-
ctx.signal
|
|
1769
|
-
);
|
|
1770
|
-
const reason = blockReasons(outs);
|
|
1771
|
-
if (outs.some((out) => out.block)) {
|
|
1772
|
-
parts.push(
|
|
1773
|
-
`UserPromptSubmit hook blocked this prompt: ${reason}. Do not act on it; tell the user it was blocked.`
|
|
1774
|
-
);
|
|
1775
|
-
notice(`UserPromptSubmit hook blocked this prompt: ${reason}`);
|
|
1776
|
-
} else {
|
|
1777
|
-
parts.push(contexts(outs));
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
const content = joinBlocks(parts);
|
|
1781
|
-
if (content) {
|
|
1782
|
-
return { message: { customType: "claude-hook-context", content, display: false } };
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
if (has(stopEvent)) {
|
|
1787
|
-
pi.on("agent_before_settle", async (event, ctx) => {
|
|
1788
|
-
if (event.outcome !== "completed") return;
|
|
1789
|
-
const outs = await dispatch(stopEvent, ctx, {
|
|
1790
|
-
stop_hook_active: stopContinuations > 0,
|
|
1791
|
-
...agentFields(ctx)
|
|
1792
|
-
});
|
|
1793
|
-
if (outs.some((out) => out.halt)) return;
|
|
1794
|
-
if (!outs.some((out) => out.block) || stopContinuations >= MAX_STOP_CONTINUATIONS) return;
|
|
1795
|
-
stopContinuations++;
|
|
1796
|
-
return {
|
|
1797
|
-
entries: [
|
|
1798
|
-
...event.entries ?? [],
|
|
1799
|
-
{
|
|
1800
|
-
type: "custom_message",
|
|
1801
|
-
customType: "claude-hook-stop",
|
|
1802
|
-
content: blockReasons(outs),
|
|
1803
|
-
display: true
|
|
1804
|
-
}
|
|
1805
|
-
],
|
|
1806
|
-
continue: true
|
|
1807
|
-
};
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
if (parent && has("PreCompact")) {
|
|
1811
|
-
pi.on("session_before_compact", async (event, ctx) => {
|
|
1812
|
-
const trigger = event.reason === "manual" ? "manual" : "auto";
|
|
1813
|
-
await dispatch(
|
|
1814
|
-
"PreCompact",
|
|
1815
|
-
ctx,
|
|
1816
|
-
{ trigger, custom_instructions: "" },
|
|
1817
|
-
trigger,
|
|
1818
|
-
event.signal
|
|
1819
|
-
);
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
if (parent && has("SessionEnd")) {
|
|
1823
|
-
pi.on("session_shutdown", async (event, ctx) => {
|
|
1824
|
-
const controller = new AbortController();
|
|
1825
|
-
let timer;
|
|
1826
|
-
await Promise.race([
|
|
1827
|
-
dispatch(
|
|
1828
|
-
"SessionEnd",
|
|
1829
|
-
ctx,
|
|
1830
|
-
{ reason: event.reason === "quit" ? "prompt_input_exit" : "other" },
|
|
1831
|
-
void 0,
|
|
1832
|
-
controller.signal
|
|
1833
|
-
),
|
|
1834
|
-
new Promise((resolve) => {
|
|
1835
|
-
timer = setTimeout(() => {
|
|
1836
|
-
controller.abort();
|
|
1837
|
-
resolve();
|
|
1838
|
-
}, SESSION_END_WAIT_MS);
|
|
1839
|
-
})
|
|
1840
|
-
]);
|
|
1841
|
-
clearTimeout(timer);
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
if (has("PreToolUse")) {
|
|
1845
|
-
pi.on("tool_call", async (event, ctx) => {
|
|
1846
|
-
const toolName = toClaudeToolName(event.toolName);
|
|
1847
|
-
const input = event.input;
|
|
1848
|
-
const outs = await dispatch(
|
|
1849
|
-
"PreToolUse",
|
|
1850
|
-
ctx,
|
|
1851
|
-
{
|
|
1852
|
-
tool_name: toolName,
|
|
1853
|
-
tool_input: toClaudeToolInput(event.toolName, input),
|
|
1854
|
-
tool_use_id: event.toolCallId
|
|
1855
|
-
},
|
|
1856
|
-
toolName,
|
|
1857
|
-
ctx.signal
|
|
1858
|
-
);
|
|
1859
|
-
const reasons = [
|
|
1860
|
-
...outs.filter((out) => out.block).map((out) => out.reason),
|
|
1861
|
-
...outs.filter((out) => !out.block && out.permissionDecision === "deny").map((out) => out.permissionDecisionReason ?? "Denied by hook")
|
|
1862
|
-
];
|
|
1863
|
-
if (reasons.length > 0) return { block: true, reason: reasons.join("\n") };
|
|
1864
|
-
for (const out of outs) {
|
|
1865
|
-
if (out.updatedInput) applyUpdatedInput(event.toolName, input, out.updatedInput);
|
|
1866
|
-
}
|
|
1867
|
-
const context = contexts(outs);
|
|
1868
|
-
if (context) preToolContext.set(event.toolCallId, context);
|
|
1869
|
-
});
|
|
1870
|
-
}
|
|
1871
|
-
const hasPostToolUse = has("PostToolUse");
|
|
1872
|
-
if (has("PreToolUse") || hasPostToolUse) {
|
|
1873
|
-
pi.on("tool_result", async (event, ctx) => {
|
|
1874
|
-
const preContext = preToolContext.get(event.toolCallId);
|
|
1875
|
-
preToolContext.delete(event.toolCallId);
|
|
1876
|
-
const toolName = toClaudeToolName(event.toolName);
|
|
1877
|
-
const outs = hasPostToolUse ? await dispatch(
|
|
1878
|
-
"PostToolUse",
|
|
1879
|
-
ctx,
|
|
1880
|
-
{
|
|
1881
|
-
tool_name: toolName,
|
|
1882
|
-
tool_input: toClaudeToolInput(event.toolName, event.input),
|
|
1883
|
-
tool_response: {
|
|
1884
|
-
content: event.content.map((part) => part.type === "text" ? part.text : "").filter(Boolean).join("\n"),
|
|
1885
|
-
is_error: event.isError
|
|
1886
|
-
},
|
|
1887
|
-
tool_use_id: event.toolCallId
|
|
1888
|
-
},
|
|
1889
|
-
toolName,
|
|
1890
|
-
ctx.signal
|
|
1891
|
-
) : [];
|
|
1892
|
-
const feedback = joinBlocks([blockReasons(outs), contexts(outs), preContext]);
|
|
1893
|
-
if (!feedback) return;
|
|
1894
|
-
return {
|
|
1895
|
-
content: [
|
|
1896
|
-
...event.content,
|
|
1897
|
-
{ type: "text", text: `<hook feedback>
|
|
1898
|
-
${feedback}
|
|
1899
|
-
</hook feedback>` }
|
|
1900
|
-
]
|
|
1901
|
-
};
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
};
|
|
1906
|
-
}
|
|
1907
1514
|
function nestedToolCallParent(toolCallId) {
|
|
1908
1515
|
return /^(.+)\/\d+$/.exec(toolCallId)?.[1];
|
|
1909
1516
|
}
|
|
@@ -12141,7 +11748,7 @@ function createSessionCommandTool(input) {
|
|
|
12141
11748
|
remote: input.remote,
|
|
12142
11749
|
preference: input.preference
|
|
12143
11750
|
});
|
|
12144
|
-
const local = kind === "powershell" ? createLocalPowerShellOperations : createLocalBashOperations;
|
|
11751
|
+
const local = kind === "powershell" ? createLocalPowerShellOperations : (input.platform ?? process.platform) === "win32" ? createLocalBashOperations : () => withFileBackedExec(createLocalBashOperations());
|
|
12145
11752
|
const operations = input.operations ?? withHardenedEnv(local(), kind);
|
|
12146
11753
|
const options = { operations: withDetachableExec(operations) };
|
|
12147
11754
|
return kind === "powershell" ? createPowerShellToolDefinition(input.cwd, options) : createBashToolDefinition(input.cwd, options);
|
|
@@ -13964,7 +13571,7 @@ function createRoutineProposeTool(invoker) {
|
|
|
13964
13571
|
}
|
|
13965
13572
|
const MODEL_SCHEMA = {
|
|
13966
13573
|
type: "object",
|
|
13967
|
-
description: "Optional: an exact provider and model, checked before anything is created. An unknown, disabled or credential-less provider or model is refused with an error and is never silently replaced by the default. Omit it to
|
|
13574
|
+
description: "Optional: an exact provider and model, checked before anything is created. An unknown, disabled or credential-less provider or model is refused with an error and is never silently replaced by the default. Omit it to follow the project's default model.",
|
|
13968
13575
|
properties: {
|
|
13969
13576
|
providerId: { type: "string", minLength: 1, maxLength: 200 },
|
|
13970
13577
|
modelId: { type: "string", minLength: 1, maxLength: 200 },
|
|
@@ -14145,18 +13752,10 @@ const SPECS = {
|
|
|
14145
13752
|
keys: [
|
|
14146
13753
|
"name",
|
|
14147
13754
|
"avatarColor",
|
|
14148
|
-
"model",
|
|
14149
|
-
"autonomy",
|
|
14150
|
-
"autoApproveProjectIds",
|
|
14151
13755
|
"takeoverScope",
|
|
14152
13756
|
"visibleProjectIds",
|
|
14153
|
-
"dispatchModel",
|
|
14154
|
-
"dispatchWorktree",
|
|
14155
13757
|
"maxRunningDispatches",
|
|
14156
13758
|
"patrolEnabled",
|
|
14157
|
-
"patrolIntervalMinutes",
|
|
14158
|
-
"patrolIdleGoalMinutes",
|
|
14159
|
-
"orphanTaskPatrol",
|
|
14160
13759
|
"addressAs",
|
|
14161
13760
|
"replyLanguage",
|
|
14162
13761
|
"style",
|
|
@@ -14164,7 +13763,7 @@ const SPECS = {
|
|
|
14164
13763
|
"dailyBriefAt",
|
|
14165
13764
|
"persona"
|
|
14166
13765
|
],
|
|
14167
|
-
numbers: ["maxRunningDispatches"
|
|
13766
|
+
numbers: ["maxRunningDispatches"],
|
|
14168
13767
|
aliases: { displayName: "name", language: "replyLanguage", about: "persona" }
|
|
14169
13768
|
},
|
|
14170
13769
|
skill_propose: {
|
|
@@ -14367,7 +13966,7 @@ const SCHEMAS = {
|
|
|
14367
13966
|
)
|
|
14368
13967
|
},
|
|
14369
13968
|
session_create: {
|
|
14370
|
-
description: 'Create a normal visible session in a local project and send the first prompt. It
|
|
13969
|
+
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.',
|
|
14371
13970
|
parameters: object(
|
|
14372
13971
|
{
|
|
14373
13972
|
projectId: id("Target project id"),
|
|
@@ -14387,7 +13986,7 @@ const SCHEMAS = {
|
|
|
14387
13986
|
model: MODEL_SCHEMA,
|
|
14388
13987
|
worktree: {
|
|
14389
13988
|
type: "boolean",
|
|
14390
|
-
description: "
|
|
13989
|
+
description: "true when the session will change code (an isolated worktree and branch); false for read-only investigation in the project checkout. Default false."
|
|
14391
13990
|
},
|
|
14392
13991
|
...BASE_PARAMS,
|
|
14393
13992
|
after: AFTER_PARAM
|
|
@@ -14553,7 +14152,7 @@ const SCHEMAS = {
|
|
|
14553
14152
|
)
|
|
14554
14153
|
},
|
|
14555
14154
|
cleanup_list: {
|
|
14556
|
-
description: "List what dispatches left behind: local branches starting with feat/, fix/ or chore/ that are already merged into feat/secretary-agent or main, the worktrees of those branches under the session worktree root, and dispatched sessions that reached goal-complete and have been idle for more than a day. Read-only: nothing is deleted. By default it returns a compact summary you can read in full: total, a count per kind, the estimated space a cleanup frees, and the first 5 of each kind with only id, name and size, so pass those ids straight to cleanup_apply. Pass detail: true for the full rows (merged refs, paths, last activity, blocked reason), 20 per page; add page to turn pages. kind narrows it to branch, worktree or session. Items that cannot be cleaned carry a blocked code and are refused by cleanup_apply.",
|
|
14155
|
+
description: "List what dispatches left behind: local branches starting with feat/, fix/ or chore/ that are already merged into feat/secretary-agent or main (a squash-merged branch counts when a merged GitHub PR has the same head commit), the worktrees of those branches under the session worktree root, and dispatched sessions that reached goal-complete and have been idle for more than a day. Read-only: nothing is deleted. By default it returns a compact summary you can read in full: total, a count per kind, the estimated space a cleanup frees, and the first 5 of each kind with only id, name and size, so pass those ids straight to cleanup_apply. Pass detail: true for the full rows (merged refs, paths, last activity, blocked reason), 20 per page; add page to turn pages. kind narrows it to branch, worktree or session. Items that cannot be cleaned carry a blocked code and are refused by cleanup_apply. sizesPending means some sizes are still being measured in the background and show up on a later call; incomplete lists repos the scan skipped because it ran out of time; warnings explain both.",
|
|
14557
14156
|
parameters: object({
|
|
14558
14157
|
projectId: id("Optional: only this project"),
|
|
14559
14158
|
kind: {
|
|
@@ -14625,7 +14224,7 @@ const SCHEMAS = {
|
|
|
14625
14224
|
)
|
|
14626
14225
|
},
|
|
14627
14226
|
todo_item_dispatch: {
|
|
14628
|
-
description: "Turn a todo item into a dispatched session.
|
|
14227
|
+
description: "Turn a todo item into a dispatched session. It runs right away like session_create, with the same optional checkout / baseRef / branch to pin the base and after to wait for other sessions, plus the same optional model.",
|
|
14629
14228
|
parameters: object(
|
|
14630
14229
|
{
|
|
14631
14230
|
todoId: id("Todo id"),
|
|
@@ -14638,7 +14237,10 @@ const SCHEMAS = {
|
|
|
14638
14237
|
description: "Optional title; defaults to the todo text"
|
|
14639
14238
|
},
|
|
14640
14239
|
model: MODEL_SCHEMA,
|
|
14641
|
-
worktree: {
|
|
14240
|
+
worktree: {
|
|
14241
|
+
type: "boolean",
|
|
14242
|
+
description: "true when the session will change code; false for read-only investigation. Default true."
|
|
14243
|
+
},
|
|
14642
14244
|
...BASE_PARAMS,
|
|
14643
14245
|
after: AFTER_PARAM
|
|
14644
14246
|
},
|
|
@@ -14671,13 +14273,10 @@ const SCHEMAS = {
|
|
|
14671
14273
|
parameters: object({ scheduleId: id("Schedule id from schedule_list") }, ["scheduleId"])
|
|
14672
14274
|
},
|
|
14673
14275
|
secretary_profile_propose: {
|
|
14674
|
-
description: "Propose a change to your own settings (name, avatar color,
|
|
14276
|
+
description: "Propose a change to your own settings (name, avatar color, visible projects, takeover scope, running dispatch limit, patrol, style, language, notifications). It is a draft: the user confirms on a card and only then is it saved. Use it for the first setup too.",
|
|
14675
14277
|
parameters: object({
|
|
14676
14278
|
name: { type: "string", minLength: 1, maxLength: 64 },
|
|
14677
14279
|
avatarColor: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
14678
|
-
model: MODEL_SCHEMA,
|
|
14679
|
-
autonomy: { type: "string", enum: ["ask-first", "tell-after", "full"] },
|
|
14680
|
-
autoApproveProjectIds: { type: "array", items: { type: "string" }, maxItems: 200 },
|
|
14681
14280
|
takeoverScope: {
|
|
14682
14281
|
description: "Which sessions you may message and stop without asking each time: explicit (only the ones the user hands over on a card), projects (the listed project ids), or all (every project you can see).",
|
|
14683
14282
|
anyOf: [
|
|
@@ -14710,47 +14309,10 @@ const SCHEMAS = {
|
|
|
14710
14309
|
{ type: "array", items: { type: "string" }, maxItems: 200 }
|
|
14711
14310
|
]
|
|
14712
14311
|
},
|
|
14713
|
-
dispatchModel: {
|
|
14714
|
-
anyOf: [
|
|
14715
|
-
{
|
|
14716
|
-
type: "object",
|
|
14717
|
-
properties: { mode: { type: "string", enum: ["project"] } },
|
|
14718
|
-
required: ["mode"],
|
|
14719
|
-
additionalProperties: false
|
|
14720
|
-
},
|
|
14721
|
-
{
|
|
14722
|
-
type: "object",
|
|
14723
|
-
properties: { mode: { type: "string", enum: ["fixed"] }, model: MODEL_SCHEMA },
|
|
14724
|
-
required: ["mode", "model"],
|
|
14725
|
-
additionalProperties: false
|
|
14726
|
-
},
|
|
14727
|
-
{
|
|
14728
|
-
type: "object",
|
|
14729
|
-
properties: {
|
|
14730
|
-
mode: { type: "string", enum: ["choose"] },
|
|
14731
|
-
candidates: { type: "array", items: MODEL_SCHEMA, minItems: 1, maxItems: 20 }
|
|
14732
|
-
},
|
|
14733
|
-
required: ["mode", "candidates"],
|
|
14734
|
-
additionalProperties: false
|
|
14735
|
-
}
|
|
14736
|
-
]
|
|
14737
|
-
},
|
|
14738
|
-
dispatchWorktree: { type: "string", enum: ["never", "auto", "always"] },
|
|
14739
14312
|
maxRunningDispatches: { type: "integer", minimum: 1, maximum: 10 },
|
|
14740
14313
|
patrolEnabled: {
|
|
14741
14314
|
type: "boolean",
|
|
14742
|
-
description: "Watch running sessions automatically and report only anomalies. On by default."
|
|
14743
|
-
},
|
|
14744
|
-
patrolIntervalMinutes: { type: "integer", minimum: 5, maximum: 120 },
|
|
14745
|
-
patrolIdleGoalMinutes: {
|
|
14746
|
-
type: "integer",
|
|
14747
|
-
minimum: 1,
|
|
14748
|
-
maximum: 30,
|
|
14749
|
-
description: "Minutes a goal session may sit idle with no background task and an unfinished goal before the patrol reports it as stalled. Default 3."
|
|
14750
|
-
},
|
|
14751
|
-
orphanTaskPatrol: {
|
|
14752
|
-
type: "boolean",
|
|
14753
|
-
description: "Scan finished sessions hourly for background tasks still running (dead process, over 2 hours, or a service left after the session ended) and report them. Never kills anything. On by default."
|
|
14315
|
+
description: "Watch running sessions automatically and report only anomalies, including background tasks left running in finished sessions. On by default."
|
|
14754
14316
|
},
|
|
14755
14317
|
addressAs: { type: "string", minLength: 1, maxLength: 64 },
|
|
14756
14318
|
replyLanguage: { type: "string", enum: ["ui", "zh", "en"] },
|
|
@@ -16885,8 +16447,6 @@ function createSessionResourceLoader(options) {
|
|
|
16885
16447
|
const harness = options.loadHarnessAssets && !options.remoteAgentsFiles;
|
|
16886
16448
|
const skillPaths = harness ? [...options.skillPaths, ...resolveHarnessSkillRoots(options.cwd)] : options.skillPaths;
|
|
16887
16449
|
const persona = options.persona;
|
|
16888
|
-
const pluginCommands = options.pluginCommands ?? [];
|
|
16889
|
-
const pluginHooks = options.pluginHooks;
|
|
16890
16450
|
const loader = new DefaultResourceLoader({
|
|
16891
16451
|
cwd: options.cwd,
|
|
16892
16452
|
agentDir: options.agentDir,
|
|
@@ -16898,7 +16458,6 @@ function createSessionResourceLoader(options) {
|
|
|
16898
16458
|
noSkills: options.noSkills,
|
|
16899
16459
|
...options.noExtensions ? { noExtensions: true } : {},
|
|
16900
16460
|
...skillPaths.length > 0 ? { additionalSkillPaths: skillPaths } : {},
|
|
16901
|
-
...pluginCommands.length > 0 ? { promptsOverride: (base) => withPluginPrompts(base, pluginCommands) } : {},
|
|
16902
16461
|
// noExtensions 只挡磁盘上的项目/全局扩展;inline factory 不受影响,图片修剪对所有会话生效
|
|
16903
16462
|
extensionFactories: [
|
|
16904
16463
|
...options.codemode ? [options.codemode] : [],
|
|
@@ -16954,15 +16513,6 @@ function createSessionResourceLoader(options) {
|
|
|
16954
16513
|
options.compactRoute
|
|
16955
16514
|
)
|
|
16956
16515
|
] : [],
|
|
16957
|
-
...pluginHooks && pluginHooks.hooks.length > 0 ? [
|
|
16958
|
-
createClaudeHooksExtension({
|
|
16959
|
-
hooks: pluginHooks.hooks,
|
|
16960
|
-
cwd: options.cwd,
|
|
16961
|
-
role: pluginHooks.role,
|
|
16962
|
-
resumed: pluginHooks.resumed,
|
|
16963
|
-
onNotice: (text2) => console.warn(`[claude-hooks] ${text2}`)
|
|
16964
|
-
})
|
|
16965
|
-
] : [],
|
|
16966
16516
|
...options.pluginEvents ? [createPluginEventsExtension(options.pluginEvents.invoker)] : [],
|
|
16967
16517
|
skillChainExtension(() => loader.getSkills().skills),
|
|
16968
16518
|
options.silentTurnRecovery,
|
|
@@ -17002,20 +16552,6 @@ async function emitPluginSessionStart(session, reason) {
|
|
|
17002
16552
|
} catch {
|
|
17003
16553
|
}
|
|
17004
16554
|
}
|
|
17005
|
-
function withPluginPrompts(base, commands) {
|
|
17006
|
-
const names = new Set(base.prompts.map((prompt) => prompt.name));
|
|
17007
|
-
const extra = commands.filter((command2) => !names.has(command2.name)).map(
|
|
17008
|
-
(command2) => ({
|
|
17009
|
-
name: command2.name,
|
|
17010
|
-
description: command2.description,
|
|
17011
|
-
...command2.argumentHint ? { argumentHint: command2.argumentHint } : {},
|
|
17012
|
-
content: command2.content,
|
|
17013
|
-
filePath: command2.filePath,
|
|
17014
|
-
sourceInfo: createSyntheticSourceInfo(command2.filePath, { source: "claude-plugin" })
|
|
17015
|
-
})
|
|
17016
|
-
);
|
|
17017
|
-
return { prompts: [...base.prompts, ...extra], diagnostics: base.diagnostics };
|
|
17018
|
-
}
|
|
17019
16555
|
function materializeSessionFile(session) {
|
|
17020
16556
|
const hasAssistant = session.messages?.some(
|
|
17021
16557
|
(message) => message?.role === "assistant"
|
|
@@ -17076,6 +16612,13 @@ async function initializeWorkerRuntime(runtime) {
|
|
|
17076
16612
|
class SessionSupervisor {
|
|
17077
16613
|
constructor(options) {
|
|
17078
16614
|
this.options = options;
|
|
16615
|
+
const restartFile = options.restartCheckpointFile;
|
|
16616
|
+
if (restartFile) {
|
|
16617
|
+
const archive = path.join(path.dirname(restartFile), RESTART_CHECKPOINT_ARCHIVE);
|
|
16618
|
+
for (const entry of takeRestartCheckpoint(restartFile, archive)?.sessions ?? []) {
|
|
16619
|
+
this.restartResume.set(entry.sessionId, entry);
|
|
16620
|
+
}
|
|
16621
|
+
}
|
|
17079
16622
|
this.pendingNotifications = new PendingNotificationStore(
|
|
17080
16623
|
path.join(options.sessionDir, "pending-notifications")
|
|
17081
16624
|
);
|
|
@@ -17117,6 +16660,7 @@ class SessionSupervisor {
|
|
|
17117
16660
|
...exitCode !== void 0 ? { exitCode } : {}
|
|
17118
16661
|
});
|
|
17119
16662
|
}
|
|
16663
|
+
this.scheduleRestartCheck();
|
|
17120
16664
|
},
|
|
17121
16665
|
onLevel: (sessionId, tasks) => {
|
|
17122
16666
|
const managed = this.sessions.get(sessionId);
|
|
@@ -17130,17 +16674,37 @@ class SessionSupervisor {
|
|
|
17130
16674
|
}
|
|
17131
16675
|
},
|
|
17132
16676
|
// 完成通知走合并投递:多任务同时完成合并成一条,失败在 manager 文本里自带标注
|
|
17133
|
-
onCompletionNotify: (sessionId, text2) => {
|
|
16677
|
+
onCompletionNotify: (sessionId, text2, notifyOptions) => {
|
|
16678
|
+
if (notifyOptions?.durable && !this.sessions.has(sessionId)) {
|
|
16679
|
+
this.persistUnopenedNotification(sessionId, text2);
|
|
16680
|
+
this.requestWake(sessionId);
|
|
16681
|
+
return;
|
|
16682
|
+
}
|
|
17134
16683
|
this.notifier.notify(sessionId, text2);
|
|
17135
16684
|
}
|
|
17136
16685
|
},
|
|
17137
16686
|
path.join(options.agentDir, "task-logs")
|
|
17138
16687
|
);
|
|
16688
|
+
const handled = this.bgTasks.recover(
|
|
16689
|
+
takeDetachedTasksManifest(
|
|
16690
|
+
path.join(this.restartDataDir(), DETACHED_TASKS_FILE),
|
|
16691
|
+
this.bgTasks.outputDir
|
|
16692
|
+
)
|
|
16693
|
+
);
|
|
16694
|
+
sweepOrphanRuns(this.bgTasks.outputDir, handled);
|
|
16695
|
+
for (const entry of this.restartResume.values()) {
|
|
16696
|
+
if (entry.nextStep === "await-user" && this.pendingNotifications.load(entry.sessionId).length > 0)
|
|
16697
|
+
this.requestWake(entry.sessionId);
|
|
16698
|
+
}
|
|
17139
16699
|
this.evictionTimer = setInterval(() => this.evictIdleSessions(), EVICTION_SWEEP_INTERVAL_MS);
|
|
17140
16700
|
this.evictionTimer.unref?.();
|
|
17141
16701
|
}
|
|
17142
16702
|
options;
|
|
17143
16703
|
sessions = /* @__PURE__ */ new Map();
|
|
16704
|
+
/** 优雅重启:请求后每次状态变化复查;committed 后不再推进任何会话,等 Main 换进程 */
|
|
16705
|
+
restart;
|
|
16706
|
+
/** 上一代 worker 的断点,按 sessionId 等对应的 spawn-parent 认领 */
|
|
16707
|
+
restartResume = /* @__PURE__ */ new Map();
|
|
17144
16708
|
gate = new OperationGate();
|
|
17145
16709
|
workspaceSwitch = new WorkspaceSwitchGate(this.sessions);
|
|
17146
16710
|
pendingCommands = /* @__PURE__ */ new Map();
|
|
@@ -17258,6 +16822,8 @@ class SessionSupervisor {
|
|
|
17258
16822
|
this.deliverNotification(sessionId, text2);
|
|
17259
16823
|
});
|
|
17260
16824
|
pendingNotifications;
|
|
16825
|
+
/** 已请 Main 打开、打开后要把待投递通知交给新一轮的会话 */
|
|
16826
|
+
wakeOnOpen = /* @__PURE__ */ new Set();
|
|
17261
16827
|
/** spawn 尚未注册完就到达的内置工具开关,注册后补用 */
|
|
17262
16828
|
pendingBuiltinTools = /* @__PURE__ */ new Map();
|
|
17263
16829
|
completeTextAborts = /* @__PURE__ */ new Map();
|
|
@@ -17295,6 +16861,10 @@ class SessionSupervisor {
|
|
|
17295
16861
|
if (!managed) return;
|
|
17296
16862
|
if (this.workspaceSwitch.defer(sessionId, () => this.deliverNotification(sessionId, text2)))
|
|
17297
16863
|
return;
|
|
16864
|
+
if (this.restart?.committed) {
|
|
16865
|
+
this.queueReminder(managed, text2);
|
|
16866
|
+
return;
|
|
16867
|
+
}
|
|
17298
16868
|
if (managed.status !== "running") {
|
|
17299
16869
|
managed.roundPending = true;
|
|
17300
16870
|
void managed.session.prompt(`<agent-notification>
|
|
@@ -17323,6 +16893,31 @@ ${text2}
|
|
|
17323
16893
|
persistPendingReminders(managed) {
|
|
17324
16894
|
this.pendingNotifications.save(managed.identity.sessionId, managed.pendingTaskReminders);
|
|
17325
16895
|
}
|
|
16896
|
+
/** 会话还没打开(重启后认回的任务先结束):直接落盘,会话打开时随 pendingTaskReminders 恢复 */
|
|
16897
|
+
persistUnopenedNotification(sessionId, text2) {
|
|
16898
|
+
const texts = this.pendingNotifications.load(sessionId);
|
|
16899
|
+
enqueueReminder(texts, text2);
|
|
16900
|
+
this.pendingNotifications.save(sessionId, texts);
|
|
16901
|
+
}
|
|
16902
|
+
/**
|
|
16903
|
+
* 通知只落了盘、没人叫醒的空闲根会话:请 Main 按恢复清单打开,打开后交给新一轮。
|
|
16904
|
+
* 本代也在重启时只存盘(下一代再叫);子会话不随换代恢复,照旧等打开时补投
|
|
16905
|
+
*/
|
|
16906
|
+
requestWake(sessionId) {
|
|
16907
|
+
if (this.restart || sessionId.includes("::") || this.sessions.has(sessionId) || this.wakeOnOpen.has(sessionId))
|
|
16908
|
+
return;
|
|
16909
|
+
this.wakeOnOpen.add(sessionId);
|
|
16910
|
+
this.options.emit({ type: "session-wake-requested", sessionId });
|
|
16911
|
+
}
|
|
16912
|
+
/** 打开的会话没在续跑上一轮:攒下的完成通知立即开一轮;在续跑的由轮末补投 */
|
|
16913
|
+
wakeAfterOpen(managed) {
|
|
16914
|
+
if (!this.wakeOnOpen.delete(managed.identity.sessionId) || managed.currentTurnId !== void 0)
|
|
16915
|
+
return;
|
|
16916
|
+
this.flushPendingReminders(managed);
|
|
16917
|
+
}
|
|
16918
|
+
restartDataDir() {
|
|
16919
|
+
return this.options.dataDir ?? path.dirname(this.options.sessionDir);
|
|
16920
|
+
}
|
|
17326
16921
|
workflowJournalDir() {
|
|
17327
16922
|
return path.join(this.options.sessionDir, "workflows");
|
|
17328
16923
|
}
|
|
@@ -17401,6 +16996,7 @@ ${text2}
|
|
|
17401
16996
|
managed.computer?.cancelAll("Session released");
|
|
17402
16997
|
managed.pluginTools?.cancelAll("Session released");
|
|
17403
16998
|
managed.pluginEvents?.cancelAll();
|
|
16999
|
+
if (!this.restart?.committed) managed.restartHold?.();
|
|
17404
17000
|
try {
|
|
17405
17001
|
await managed.session.abort();
|
|
17406
17002
|
} catch {
|
|
@@ -17421,8 +17017,19 @@ ${text2}
|
|
|
17421
17017
|
reason,
|
|
17422
17018
|
...managed.instanceId ? { instanceId: managed.instanceId } : {}
|
|
17423
17019
|
});
|
|
17020
|
+
this.scheduleRestartCheck();
|
|
17424
17021
|
}
|
|
17425
17022
|
handleCommand(command2) {
|
|
17023
|
+
if (command2.type === "graceful-restart") {
|
|
17024
|
+
this.restart ??= { committed: false };
|
|
17025
|
+
if (command2.keepBackgroundTasks) this.restart.keepBackground = true;
|
|
17026
|
+
this.checkRestart();
|
|
17027
|
+
return;
|
|
17028
|
+
}
|
|
17029
|
+
if (command2.type === "detach-background-tasks") {
|
|
17030
|
+
this.detachBackgroundTasks();
|
|
17031
|
+
return;
|
|
17032
|
+
}
|
|
17426
17033
|
if (command2.type === "oauth-pool-result") {
|
|
17427
17034
|
this.oauthPoolPending.get(command2.requestId)?.(command2);
|
|
17428
17035
|
return;
|
|
@@ -17678,6 +17285,7 @@ ${text2}
|
|
|
17678
17285
|
const count = (this.pendingCommands.get(scopeId) ?? 1) - 1;
|
|
17679
17286
|
if (count) this.pendingCommands.set(scopeId, count);
|
|
17680
17287
|
else this.pendingCommands.delete(scopeId);
|
|
17288
|
+
this.scheduleRestartCheck();
|
|
17681
17289
|
}).catch((error) => {
|
|
17682
17290
|
const message = toErrorMessage(error);
|
|
17683
17291
|
if (command2.type === "spawn-parent") {
|
|
@@ -17767,8 +17375,6 @@ ${text2}
|
|
|
17767
17375
|
command2.rtkEnabled,
|
|
17768
17376
|
command2.planMode,
|
|
17769
17377
|
command2.trustedProjectCode,
|
|
17770
|
-
command2.pluginCommands,
|
|
17771
|
-
command2.pluginHooks,
|
|
17772
17378
|
command2.botMode,
|
|
17773
17379
|
command2.botGroupTasks,
|
|
17774
17380
|
command2.protectedActions,
|
|
@@ -18276,6 +17882,7 @@ ${text2}
|
|
|
18276
17882
|
managed.computer?.cancelAll("Computer action aborted");
|
|
18277
17883
|
managed.pluginTools?.cancelAll("Plugin tool aborted");
|
|
18278
17884
|
managed.pluginEvents?.cancelAll();
|
|
17885
|
+
if (!this.restart?.committed) managed.restartHold?.();
|
|
18279
17886
|
if (retrying) {
|
|
18280
17887
|
this.failTurn(managed, managed.lastRetryError ?? "Auto-retry cancelled.");
|
|
18281
17888
|
} else {
|
|
@@ -18300,7 +17907,7 @@ ${text2}
|
|
|
18300
17907
|
console.warn("[compact] summary model unavailable:", toErrorMessage(error));
|
|
18301
17908
|
});
|
|
18302
17909
|
}
|
|
18303
|
-
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 = [],
|
|
17910
|
+
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) {
|
|
18304
17911
|
const sessionId = identity.sessionId;
|
|
18305
17912
|
const sessionEditMode = resolveEditMode(requestedEditMode);
|
|
18306
17913
|
const toolEnabled = (id2) => !disabledTools.includes(id2);
|
|
@@ -18393,8 +18000,6 @@ ${text2}
|
|
|
18393
18000
|
...remote ? { remoteSsh: { host: remote.host } } : {},
|
|
18394
18001
|
loadHarnessAssets,
|
|
18395
18002
|
trustedProjectCode,
|
|
18396
|
-
pluginCommands,
|
|
18397
|
-
pluginHooks: { hooks: pluginHooks, role: { kind: "parent" }, resumed: Boolean(resumeFile) },
|
|
18398
18003
|
...pluginEventInvoker ? { pluginEvents: { invoker: pluginEventInvoker } } : {},
|
|
18399
18004
|
exploreFold,
|
|
18400
18005
|
turnDiscard,
|
|
@@ -18704,14 +18309,6 @@ ${text2}
|
|
|
18704
18309
|
// 类型化子代理与项目资源隔离(同 noSkills/noExtensions),不追加 harness 资源
|
|
18705
18310
|
loadHarnessAssets: resolved || agentType ? false : loadHarnessAssets,
|
|
18706
18311
|
trustedProjectCode,
|
|
18707
|
-
pluginHooks: {
|
|
18708
|
-
hooks: pluginHooks,
|
|
18709
|
-
role: {
|
|
18710
|
-
kind: "subagent",
|
|
18711
|
-
agentType: resolved?.displayName ?? agentType?.name ?? "general"
|
|
18712
|
-
},
|
|
18713
|
-
resumed: Boolean(childResume)
|
|
18714
|
-
},
|
|
18715
18312
|
...childPlugins?.events ? { pluginEvents: { invoker: childPlugins.events } } : {},
|
|
18716
18313
|
...childExploreFold ? { exploreFold: childExploreFold } : {},
|
|
18717
18314
|
reminders: childReminders,
|
|
@@ -19195,6 +18792,8 @@ ${text2}
|
|
|
19195
18792
|
sessionFile: requiredSessionFile(session),
|
|
19196
18793
|
model: settingsModelRef(model)
|
|
19197
18794
|
});
|
|
18795
|
+
this.continueAfterRestart(managedRef);
|
|
18796
|
+
this.wakeAfterOpen(managedRef);
|
|
19198
18797
|
checkpoints?.cleanupOldSessions();
|
|
19199
18798
|
}
|
|
19200
18799
|
createAskManager(identity, humanTimeoutMs) {
|
|
@@ -19237,6 +18836,7 @@ ${text2}
|
|
|
19237
18836
|
}
|
|
19238
18837
|
registerManagedSession(identity, session, gate, modelId, opts = {}) {
|
|
19239
18838
|
batchSteering(session);
|
|
18839
|
+
const restartResume = opts.resumeFile ? this.claimRestartResume(identity, opts.resumeFile) : void 0;
|
|
19240
18840
|
const customEntries = session.sessionManager.getBranch().flatMap((entry) => {
|
|
19241
18841
|
if (entry.type !== "custom" || entry.customType !== "enso-agent-session") return [];
|
|
19242
18842
|
const parsed = parseAgentSessionCustomEntry(entry.data);
|
|
@@ -19248,7 +18848,9 @@ ${text2}
|
|
|
19248
18848
|
...opts.childMetadata ? { childMetadata: opts.childMetadata } : {},
|
|
19249
18849
|
session,
|
|
19250
18850
|
status: "idle",
|
|
19251
|
-
|
|
18851
|
+
// 优雅重启接管:沿用上一代的序号,Main 与各窗口的单调守卫照常放行
|
|
18852
|
+
seq: restartResume?.seq ?? 0,
|
|
18853
|
+
...restartResume ? { restartResume } : {},
|
|
19252
18854
|
messages: [],
|
|
19253
18855
|
turnStartIndex: 0,
|
|
19254
18856
|
customEntries,
|
|
@@ -19282,7 +18884,9 @@ ${text2}
|
|
|
19282
18884
|
};
|
|
19283
18885
|
managed.unsubscribe = session.subscribe((event) => {
|
|
19284
18886
|
this.onSessionEvent(managed, event);
|
|
18887
|
+
this.scheduleRestartCheck();
|
|
19285
18888
|
});
|
|
18889
|
+
this.installRestartBoundary(managed);
|
|
19286
18890
|
this.sessions.set(identity.sessionId, managed);
|
|
19287
18891
|
const parentId = opts.childIdentity?.parent.sessionId ?? opts.parentId;
|
|
19288
18892
|
if (parentId) {
|
|
@@ -19348,6 +18952,7 @@ ${text2}
|
|
|
19348
18952
|
if (opts.resumeFile) {
|
|
19349
18953
|
const raw = this.transcript(managed);
|
|
19350
18954
|
const { immediate: immediate2, deferFull } = projectResumeTail(raw);
|
|
18955
|
+
const backgroundTasks = this.bgTasks.snapshot(identity.sessionId);
|
|
19351
18956
|
const emitResumeSnapshot = (payload, resumeFull = false) => {
|
|
19352
18957
|
this.options.emit({
|
|
19353
18958
|
type: "snapshot",
|
|
@@ -19361,7 +18966,8 @@ ${text2}
|
|
|
19361
18966
|
...payload.baseIndex > 0 ? { baseIndex: payload.baseIndex } : {},
|
|
19362
18967
|
commands: managed.commands,
|
|
19363
18968
|
...managed.childMetadata ? { child: managed.childMetadata } : {},
|
|
19364
|
-
...managed.customEntries.length > 0 ? { customEntries: managed.customEntries } : {}
|
|
18969
|
+
...managed.customEntries.length > 0 ? { customEntries: managed.customEntries } : {},
|
|
18970
|
+
...backgroundTasks.length > 0 ? { backgroundTasks } : {}
|
|
19365
18971
|
}
|
|
19366
18972
|
]
|
|
19367
18973
|
});
|
|
@@ -20174,6 +19780,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20174
19780
|
}
|
|
20175
19781
|
case "tool_execution_start": {
|
|
20176
19782
|
if (event.parentToolCallId) return;
|
|
19783
|
+
if (this.restart && !this.restart.committed) this.releaseRestartHolds();
|
|
20177
19784
|
if (!managed.toolStartAt.has(event.toolCallId)) {
|
|
20178
19785
|
const startedAt = Date.now();
|
|
20179
19786
|
managed.toolStartAt.set(event.toolCallId, startedAt);
|
|
@@ -20215,6 +19822,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20215
19822
|
if (event.parentToolCallId) return;
|
|
20216
19823
|
const start = managed.toolStartAt.get(event.toolCallId);
|
|
20217
19824
|
managed.toolStartAt.delete(event.toolCallId);
|
|
19825
|
+
managed.lastCompletedToolCallId = event.toolCallId;
|
|
20218
19826
|
if (start !== void 0) {
|
|
20219
19827
|
managed.toolDurations.set(event.toolCallId, Date.now() - start);
|
|
20220
19828
|
}
|
|
@@ -20343,6 +19951,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20343
19951
|
managed.contextUsage.setPendingSnapshot(void 0);
|
|
20344
19952
|
this.emitSessionMeta(managed);
|
|
20345
19953
|
const digest = buildTurnDigest(managed.messages, managed.turnStartIndex);
|
|
19954
|
+
const report = buildTurnReport(managed.messages, managed.turnStartIndex);
|
|
20346
19955
|
const silent = turnRequestedSilence(managed.messages, managed.turnStartIndex);
|
|
20347
19956
|
managed.turnStartIndex = managed.messages.length;
|
|
20348
19957
|
this.workspaceClaims.release(managed.identity.sessionId);
|
|
@@ -20352,6 +19961,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20352
19961
|
seq: ++managed.seq,
|
|
20353
19962
|
turnId,
|
|
20354
19963
|
...digest ? { digest } : {},
|
|
19964
|
+
...report ? { report } : {},
|
|
20355
19965
|
...silent ? { silent: true } : {},
|
|
20356
19966
|
...aborted ? { aborted: true } : {},
|
|
20357
19967
|
...budget ? { requestBudgetStop: true } : {},
|
|
@@ -20768,6 +20378,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
20768
20378
|
...managed.status === "running" && managed.currentTurnId ? { turnId: managed.currentTurnId } : {}
|
|
20769
20379
|
});
|
|
20770
20380
|
if (managed.status !== "running") this.settleRound(managed);
|
|
20381
|
+
this.scheduleRestartCheck();
|
|
20771
20382
|
}
|
|
20772
20383
|
/**
|
|
20773
20384
|
* 轮次终态收口(idle/failed/abort/销毁统一经此):coworker 记下本轮摘要供 report/wait,
|
|
@@ -21008,10 +20619,158 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21008
20619
|
return managed;
|
|
21009
20620
|
}
|
|
21010
20621
|
/** worker 退出前 fail-closed 清理挂起 capability,并断开 MCP 子进程。 */
|
|
21011
|
-
|
|
20622
|
+
/**
|
|
20623
|
+
* 优雅重启的唯一提交点:每个会话都在安全点(空闲,或父会话停在工具批之后、下一次模型请求之前),
|
|
20624
|
+
* 才把断点写到 dataDir/restart-checkpoint.json 并回 graceful-restart-ready;否则回一次推迟原因。
|
|
20625
|
+
*/
|
|
20626
|
+
checkRestart() {
|
|
20627
|
+
const restart = this.restart;
|
|
20628
|
+
if (!restart || restart.committed) return;
|
|
20629
|
+
const entries = [];
|
|
20630
|
+
const deferred = [];
|
|
20631
|
+
for (const sessionId of this.sessions.keys()) this.notifier.flush(sessionId);
|
|
20632
|
+
for (const managed of this.sessions.values()) {
|
|
20633
|
+
const queued = managed.session.pendingMessageCount > 0;
|
|
20634
|
+
if (queued) managed.restartHold?.();
|
|
20635
|
+
const keep = restart.keepBackground === true;
|
|
20636
|
+
const blockingTasks = this.bgTasks.runningYielded(managed.identity.sessionId, {
|
|
20637
|
+
exceptDetachable: keep
|
|
20638
|
+
});
|
|
20639
|
+
const toolsInFlight = [...managed.toolStartAt.keys(), ...blockingTasks];
|
|
20640
|
+
const gate = restartGate({
|
|
20641
|
+
toolsInFlight,
|
|
20642
|
+
atModelRequestBoundary: managed.restartHold !== void 0,
|
|
20643
|
+
turnActive: queued || managed.status === "running" || managed.currentTurnId !== void 0 || managed.session.isStreaming || managed.session.isRetrying || !!managed.roundPending || !!managed.compaction || !!managed.pendingCompact
|
|
20644
|
+
});
|
|
20645
|
+
if (!gate.ready) {
|
|
20646
|
+
deferred.push({
|
|
20647
|
+
identity: managed.identity,
|
|
20648
|
+
reason: gate.reason,
|
|
20649
|
+
toolsInFlight,
|
|
20650
|
+
...keep && blockingTasks.length > 0 ? { undetachableTasks: blockingTasks } : {}
|
|
20651
|
+
});
|
|
20652
|
+
continue;
|
|
20653
|
+
}
|
|
20654
|
+
const sessionFile = managed.session.sessionFile;
|
|
20655
|
+
if (!sessionFile) continue;
|
|
20656
|
+
entries.push({
|
|
20657
|
+
sessionId: managed.identity.sessionId,
|
|
20658
|
+
generation: managed.identity.generation,
|
|
20659
|
+
sessionFile,
|
|
20660
|
+
seq: managed.seq,
|
|
20661
|
+
nextStep: gate.nextStep,
|
|
20662
|
+
turnId: gate.nextStep === "model-request" ? managed.currentTurnId ?? null : null,
|
|
20663
|
+
lastCompletedToolCallId: managed.lastCompletedToolCallId ?? null,
|
|
20664
|
+
messageCount: managed.session.messages.length,
|
|
20665
|
+
toolsInFlight
|
|
20666
|
+
});
|
|
20667
|
+
}
|
|
20668
|
+
if (deferred.length > 0) {
|
|
20669
|
+
const key = JSON.stringify(deferred);
|
|
20670
|
+
if (key !== restart.deferredKey) {
|
|
20671
|
+
restart.deferredKey = key;
|
|
20672
|
+
this.options.emit({ type: "graceful-restart-deferred", sessions: deferred });
|
|
20673
|
+
}
|
|
20674
|
+
return;
|
|
20675
|
+
}
|
|
20676
|
+
if ([...this.pendingCommands.keys()].some((id2) => !this.sessions.has(id2))) return;
|
|
20677
|
+
const checkpoint = {
|
|
20678
|
+
version: 1,
|
|
20679
|
+
pid: process.pid,
|
|
20680
|
+
writtenAt: Date.now(),
|
|
20681
|
+
sessions: entries
|
|
20682
|
+
};
|
|
20683
|
+
writeRestartCheckpoint(path.join(this.restartDataDir(), RESTART_CHECKPOINT_FILE), checkpoint);
|
|
20684
|
+
restart.committed = true;
|
|
20685
|
+
this.options.emit({ type: "graceful-restart-ready", checkpoint });
|
|
20686
|
+
}
|
|
20687
|
+
/**
|
|
20688
|
+
* 退出重启前(Main 在终止 worker 之前发):把能脱离的后台命令交出去、写恢复清单,回执后 Main 才终止 worker,
|
|
20689
|
+
* shutdown 只会停掉留在本代的任务。
|
|
20690
|
+
*/
|
|
20691
|
+
detachBackgroundTasks() {
|
|
20692
|
+
const tasks = this.bgTasks.detachForRestart();
|
|
20693
|
+
const file = path.join(this.restartDataDir(), DETACHED_TASKS_FILE);
|
|
20694
|
+
try {
|
|
20695
|
+
writeDetachedTasksManifest(file, {
|
|
20696
|
+
version: 1,
|
|
20697
|
+
writtenAt: Date.now(),
|
|
20698
|
+
workerPid: process.pid,
|
|
20699
|
+
tasks
|
|
20700
|
+
});
|
|
20701
|
+
} catch (error) {
|
|
20702
|
+
console.warn("[graceful-restart] failed to write detached task manifest:", error);
|
|
20703
|
+
for (const task of tasks) killRunGroup(task.pid, "SIGKILL");
|
|
20704
|
+
}
|
|
20705
|
+
this.options.emit({ type: "background-tasks-detached", detached: tasks.length });
|
|
20706
|
+
}
|
|
20707
|
+
scheduleRestartCheck() {
|
|
20708
|
+
const restart = this.restart;
|
|
20709
|
+
if (!restart || restart.committed || restart.checkScheduled) return;
|
|
20710
|
+
restart.checkScheduled = true;
|
|
20711
|
+
queueMicrotask(() => {
|
|
20712
|
+
restart.checkScheduled = false;
|
|
20713
|
+
this.checkRestart();
|
|
20714
|
+
});
|
|
20715
|
+
}
|
|
20716
|
+
releaseRestartHolds() {
|
|
20717
|
+
for (const managed of this.sessions.values()) managed.restartHold?.();
|
|
20718
|
+
}
|
|
20719
|
+
/**
|
|
20720
|
+
* pi 在工具批全部返回、turn_end 之后,下一次模型请求(turn_start)之前调 prepareNextTurnWithContext。
|
|
20721
|
+
* 有重启请求时父会话停在这里;只在全局没有工具在跑时才停,避免停住的会话正被别的工具等着。
|
|
20722
|
+
*/
|
|
20723
|
+
installRestartBoundary(managed) {
|
|
20724
|
+
const agent = managed.session.agent;
|
|
20725
|
+
const next = agent?.prepareNextTurnWithContext;
|
|
20726
|
+
if (!agent || typeof next !== "function") return;
|
|
20727
|
+
agent.prepareNextTurnWithContext = async (turn, signal) => {
|
|
20728
|
+
await this.holdForRestart(managed);
|
|
20729
|
+
return next.call(agent, turn, signal);
|
|
20730
|
+
};
|
|
20731
|
+
}
|
|
20732
|
+
holdForRestart(managed) {
|
|
20733
|
+
const restart = this.restart;
|
|
20734
|
+
if (!restart || restart.committed || managed.childIdentity || managed.parentId || managed.session.pendingMessageCount > 0 || this.sessions.get(managed.identity.sessionId) !== managed || [...this.sessions.values()].some((session) => session.toolStartAt.size > 0))
|
|
20735
|
+
return Promise.resolve();
|
|
20736
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
20737
|
+
managed.restartHold = () => {
|
|
20738
|
+
managed.restartHold = void 0;
|
|
20739
|
+
resolve();
|
|
20740
|
+
};
|
|
20741
|
+
this.checkRestart();
|
|
20742
|
+
return promise;
|
|
20743
|
+
}
|
|
20744
|
+
/** 断点说下一步是模型请求:接着同一轮(同一个 turnId)续跑,不重放刚完成的工具 */
|
|
20745
|
+
continueAfterRestart(managed) {
|
|
20746
|
+
const entry = managed.restartResume;
|
|
20747
|
+
managed.restartResume = void 0;
|
|
20748
|
+
if (entry?.nextStep !== "model-request") return;
|
|
20749
|
+
if (managed.session.agent.state.messages.at(-1)?.role !== "toolResult") {
|
|
20750
|
+
console.warn(
|
|
20751
|
+
`[graceful-restart] ${entry.sessionId.slice(0, 8)} 会话文件不在工具结果上,不续跑,等用户下一条`
|
|
20752
|
+
);
|
|
20753
|
+
return;
|
|
20754
|
+
}
|
|
20755
|
+
managed.currentTurnId = entry.turnId ?? randomUUID();
|
|
20756
|
+
if (entry.lastCompletedToolCallId)
|
|
20757
|
+
managed.lastCompletedToolCallId = entry.lastCompletedToolCallId;
|
|
20758
|
+
void continueSessionActivity(managed.session).catch(
|
|
20759
|
+
(error) => this.failTurn(managed, toErrorMessage(error))
|
|
20760
|
+
);
|
|
20761
|
+
}
|
|
20762
|
+
claimRestartResume(identity, sessionFile) {
|
|
20763
|
+
const entry = this.restartResume.get(identity.sessionId);
|
|
20764
|
+
if (!entry || entry.generation !== identity.generation || path.resolve(entry.sessionFile) !== path.resolve(sessionFile))
|
|
20765
|
+
return void 0;
|
|
20766
|
+
this.restartResume.delete(identity.sessionId);
|
|
20767
|
+
return entry;
|
|
20768
|
+
}
|
|
20769
|
+
async shutdown() {
|
|
21012
20770
|
clearInterval(this.evictionTimer);
|
|
21013
20771
|
this.workspaceSwitch.clear();
|
|
21014
20772
|
this.bgTasks.stopAll();
|
|
20773
|
+
if (this.restart && !this.restart.committed) await this.settleYieldedTasks(1e3);
|
|
21015
20774
|
for (const managed of this.sessions.values()) {
|
|
21016
20775
|
cancelContinuousMemory(managed.session.sessionManager);
|
|
21017
20776
|
managed.browser?.cancelAll("Enso worker shutdown");
|
|
@@ -21023,11 +20782,19 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
21023
20782
|
managed.computer?.cancelAll("Enso worker shutdown");
|
|
21024
20783
|
managed.pluginTools?.cancelAll("Enso worker shutdown");
|
|
21025
20784
|
managed.pluginEvents?.cancelAll();
|
|
21026
|
-
void managed.session.abort().catch(() => {
|
|
20785
|
+
if (!this.restart?.committed) void managed.session.abort().catch(() => {
|
|
21027
20786
|
});
|
|
21028
20787
|
}
|
|
21029
20788
|
return this.mcp.closeAll();
|
|
21030
20789
|
}
|
|
20790
|
+
async settleYieldedTasks(limitMs) {
|
|
20791
|
+
const deadline = Date.now() + limitMs;
|
|
20792
|
+
const running = () => [...this.sessions.keys()].some((id2) => this.bgTasks.runningYielded(id2).length > 0);
|
|
20793
|
+
while (running() && Date.now() < deadline) {
|
|
20794
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
20795
|
+
}
|
|
20796
|
+
this.checkRestart();
|
|
20797
|
+
}
|
|
21031
20798
|
getRuntime() {
|
|
21032
20799
|
this.runtimePromise ??= (async () => {
|
|
21033
20800
|
const runtime = await ModelRuntime.create({
|
|
@@ -21779,13 +21546,16 @@ if (!dataDir) {
|
|
|
21779
21546
|
throw new Error("ENSO_AGENT_DATA_DIR is required");
|
|
21780
21547
|
}
|
|
21781
21548
|
installCrashRecord(dataDir);
|
|
21549
|
+
const restartCheckpointFile = process.env[RESTART_CHECKPOINT_ENV] || void 0;
|
|
21550
|
+
delete process.env[RESTART_CHECKPOINT_ENV];
|
|
21782
21551
|
const supervisor = new SessionSupervisor({
|
|
21783
21552
|
emit: (event) => port.postMessage(event),
|
|
21784
21553
|
agentDir: path.join(dataDir, "pi-agent"),
|
|
21785
21554
|
sessionDir: path.join(dataDir, "sessions"),
|
|
21786
21555
|
workflowDir: path.join(dataDir, "workflows"),
|
|
21787
21556
|
dataDir,
|
|
21788
|
-
userImageDirs: userImageDirsFromEnv()
|
|
21557
|
+
userImageDirs: userImageDirsFromEnv(),
|
|
21558
|
+
...restartCheckpointFile ? { restartCheckpointFile } : {}
|
|
21789
21559
|
});
|
|
21790
21560
|
function userImageDirsFromEnv() {
|
|
21791
21561
|
return (process.env.ENSO_USER_IMAGE_DIRS ?? "").split(path.delimiter).map((entry) => entry.trim()).filter((entry) => entry.startsWith("/"));
|