@ensocode/server 0.3.11 → 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.
Files changed (185) hide show
  1. package/LICENSE +679 -19
  2. package/out/phone/assets/{abnfDiagram-VCTEODGH-DeKO4j9Y.js → abnfDiagram-VCTEODGH-D-9apHOZ.js} +1 -1
  3. package/out/phone/assets/architecture-7GRP2DOG-ihVIDRRt.js +1 -0
  4. package/out/phone/assets/{architectureDiagram-5GKGNRK7-DhPgDhMQ.js → architectureDiagram-5GKGNRK7-B7ti5Yuy.js} +1 -1
  5. package/out/phone/assets/{blockDiagram-I7D4REHJ-CHjEV4S2.js → blockDiagram-I7D4REHJ-CMg6PHJB.js} +1 -1
  6. package/out/phone/assets/{c4Diagram-7LVT6UL2-C_w2ZiGg.js → c4Diagram-7LVT6UL2-YtDbC01g.js} +1 -1
  7. package/out/phone/assets/channel-BQsoblXW.js +1 -0
  8. package/out/phone/assets/{chunk-4HAMMTFA-DsFB5306.js → chunk-4HAMMTFA-Djg6ctlZ.js} +1 -1
  9. package/out/phone/assets/{chunk-75Z2AOVW-D-GYq_Mf.js → chunk-75Z2AOVW-Be2kq0FP.js} +1 -1
  10. package/out/phone/assets/{chunk-DU6HZSFF-CfnOn1uu.js → chunk-DU6HZSFF-d5JZiOMy.js} +1 -1
  11. package/out/phone/assets/{chunk-F27PBJKO-DFQr9a2N.js → chunk-F27PBJKO-DHBQ6nrV.js} +1 -1
  12. package/out/phone/assets/{chunk-GMAD6QVW--AoHkXxN.js → chunk-GMAD6QVW-BatU6uXC.js} +1 -1
  13. package/out/phone/assets/{chunk-GVQU2GXP-CzbFqhoi.js → chunk-GVQU2GXP-CiyvoRIy.js} +1 -1
  14. package/out/phone/assets/{chunk-IMKFNOWR-DT26rqUA.js → chunk-IMKFNOWR-vOQaK90i.js} +1 -1
  15. package/out/phone/assets/{chunk-L3NEJ4N5-CvadXD9U.js → chunk-L3NEJ4N5-CPykFzBy.js} +1 -1
  16. package/out/phone/assets/{chunk-OSK3NFVY-DROHZT6z.js → chunk-OSK3NFVY-q4NiGH59.js} +1 -1
  17. package/out/phone/assets/{chunk-P2QGCYS3-BcsvTFQT.js → chunk-P2QGCYS3-DUV9S_qP.js} +1 -1
  18. package/out/phone/assets/{chunk-POPQ4Y6H-Bib7YUpn.js → chunk-POPQ4Y6H-CjycswNE.js} +1 -1
  19. package/out/phone/assets/{chunk-PWAF6VOD-CrsdfQvi.js → chunk-PWAF6VOD-Dben6plA.js} +1 -1
  20. package/out/phone/assets/{chunk-SHT3W25Y-BSSsjkbn.js → chunk-SHT3W25Y-D2hK_jmb.js} +1 -1
  21. package/out/phone/assets/{chunk-SVP7TREG-BorYBfcS.js → chunk-SVP7TREG-DLtgLN89.js} +1 -1
  22. package/out/phone/assets/{chunk-TICWLB2K-DwWprz_z.js → chunk-TICWLB2K-BeBB0_0w.js} +1 -1
  23. package/out/phone/assets/classDiagram-ZZMXUADV-rwnxFDXp.js +1 -0
  24. package/out/phone/assets/classDiagram-v2-VYDZK3BY-rwnxFDXp.js +1 -0
  25. package/out/phone/assets/{cynefin-OW5HDTMX-UxW1ctBn.js → cynefin-OW5HDTMX-CsDdLZPP.js} +1 -1
  26. package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-3xyjt_Zk.js → cynefinDiagram-5FMLGOSQ-BcaPty-s.js} +1 -1
  27. package/out/phone/assets/{dagre-GXQ25YYZ-BA8g5sNo.js → dagre-GXQ25YYZ-o7dqm5ri.js} +1 -1
  28. package/out/phone/assets/desk-DNf6lCoq.js +2 -0
  29. package/out/phone/assets/{diagram-S7CK7UJ4-CqaAk0xY.js → diagram-S7CK7UJ4-B5m8q3yP.js} +1 -1
  30. package/out/phone/assets/{diagram-UQ7AKVKN-BJs2alr_.js → diagram-UQ7AKVKN-_lP617OW.js} +1 -1
  31. package/out/phone/assets/{diagram-VSXAHHWV-goFBlClH.js → diagram-VSXAHHWV-D16twHR0.js} +1 -1
  32. package/out/phone/assets/{diagram-VX7I27RA-NC_soOMz.js → diagram-VX7I27RA-BT8YSil1.js} +1 -1
  33. package/out/phone/assets/{diagram-Z3DM3KII-CPBmdhd-.js → diagram-Z3DM3KII-CiSuhrxd.js} +1 -1
  34. package/out/phone/assets/{ebnfDiagram-PWID7BFC-e_KXtWp1.js → ebnfDiagram-PWID7BFC-BbCXn4HA.js} +1 -1
  35. package/out/phone/assets/{erDiagram-RLTQ6QDP-BV3oU6Yk.js → erDiagram-RLTQ6QDP-5-xE_bP2.js} +1 -1
  36. package/out/phone/assets/eventmodeling-NTZA5JFV-BVS2RGt-.js +1 -0
  37. package/out/phone/assets/flowDiagram-HODETNUW-BSlxj9Uk.js +1 -0
  38. package/out/phone/assets/{ganttDiagram-EL5Y4UJY-DOtr1Ilh.js → ganttDiagram-EL5Y4UJY-Rqgggqg_.js} +1 -1
  39. package/out/phone/assets/{gitGraph-4MIJSDKK-D0CbVtzh.js → gitGraph-4MIJSDKK-Drt18ZKK.js} +1 -1
  40. package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-C6wXAX8a.js → gitGraphDiagram-WWUBYQGX-BQ5y4d2H.js} +1 -1
  41. package/out/phone/assets/{info-A6RAGUB7-BLbppMXJ.js → info-A6RAGUB7-CpPeSHE0.js} +1 -1
  42. package/out/phone/assets/{infoDiagram-27XIBGKW-DOlhaNYG.js → infoDiagram-27XIBGKW-D3d9S0Y6.js} +1 -1
  43. package/out/phone/assets/{ishikawaDiagram-5VMMS53U-BtaSUSnr.js → ishikawaDiagram-5VMMS53U-plFMqx62.js} +1 -1
  44. package/out/phone/assets/{journeyDiagram-3NMN7TZE-C6DElK_Y.js → journeyDiagram-3NMN7TZE-CX-n-XXx.js} +1 -1
  45. package/out/phone/assets/{kanban-definition-UXKFOSKX-WqCAwlkm.js → kanban-definition-UXKFOSKX-DrdTzKIc.js} +1 -1
  46. package/out/phone/assets/{line-CvY1fizC.js → line-CqyaArNm.js} +1 -1
  47. package/out/phone/assets/main-BGlFv7yA.js +1658 -0
  48. package/out/phone/assets/main-BS1SSCau.css +1 -0
  49. package/out/phone/assets/{mermaid-parser.core-BNyl33x8.js → mermaid-parser.core-CERMa6fg.js} +3 -3
  50. package/out/phone/assets/{mermaid.core-BnUF0ZCX.js → mermaid.core-CbGP2wFn.js} +4 -4
  51. package/out/phone/assets/{mindmap-definition-YA3MSWOX-CsORTLIm.js → mindmap-definition-YA3MSWOX-BxaIrov6.js} +1 -1
  52. package/out/phone/assets/{packet-AYTQ26CC-CoxwVVdp.js → packet-AYTQ26CC-DguFQxPm.js} +1 -1
  53. package/out/phone/assets/{pegDiagram-XKGWAZYB-BI2W6aLH.js → pegDiagram-XKGWAZYB-t3td03dz.js} +1 -1
  54. package/out/phone/assets/{pie-WAS4IAKB-CQD3JNcj.js → pie-WAS4IAKB-DoFu2rhu.js} +1 -1
  55. package/out/phone/assets/{pieDiagram-E7YTZNPT-aLnzVgco.js → pieDiagram-E7YTZNPT-DctHLSL8.js} +1 -1
  56. package/out/phone/assets/{quadrantDiagram-AXDQQJYC-Cbl0x-Id.js → quadrantDiagram-AXDQQJYC-Br7-ImNr.js} +1 -1
  57. package/out/phone/assets/{radar-RG4KPBEZ-Bu2EN1RM.js → radar-RG4KPBEZ-BDjTOHD8.js} +1 -1
  58. package/out/phone/assets/{railroad-74A4TZTK-DiiOMWSM.js → railroad-74A4TZTK-v8vsrpxb.js} +1 -1
  59. package/out/phone/assets/railroad-abnf-HS5TGJTU-CUELjEtC.js +1 -0
  60. package/out/phone/assets/railroad-ebnf-LZEXJU2U-DdIokM4i.js +1 -0
  61. package/out/phone/assets/railroad-peg-WCYAUIDC-DYyy0B-_.js +1 -0
  62. package/out/phone/assets/{railroadDiagram-O6MQD6OU-r5JJp9nP.js → railroadDiagram-O6MQD6OU-DtH4qQrr.js} +1 -1
  63. package/out/phone/assets/{requirementDiagram-BXWQKSXE-Bh86zb_w.js → requirementDiagram-BXWQKSXE-BSqejjZP.js} +1 -1
  64. package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CykRlthT.js → sankeyDiagram-P5KCCOFB-DsTWuNtL.js} +1 -1
  65. package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BPLcD6MF.js → sequenceDiagram-WJ2MYXX4-zLMvPyPC.js} +1 -1
  66. package/out/phone/assets/{stateDiagram-D77RDMKH-DWXApcUM.js → stateDiagram-D77RDMKH-DrBC05BN.js} +1 -1
  67. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-DT7BlwvF.js +1 -0
  68. package/out/phone/assets/storage-BeJvYXAx.js +36 -0
  69. package/out/phone/assets/{swimlanes-42K2YHIH-BVi6IPTq.js → swimlanes-42K2YHIH-B27-qSm5.js} +1 -1
  70. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-CWnm4v0A.js +8 -0
  71. package/out/phone/assets/{timeline-definition-24CTP7MA-xf--BXjO.js → timeline-definition-24CTP7MA-8NDkGf5U.js} +1 -1
  72. package/out/phone/assets/{treeView-Q6P3EWNA-DzJs7PRI.js → treeView-Q6P3EWNA-B9BXwCDC.js} +1 -1
  73. package/out/phone/assets/{treemap-WGGIJYW6-AXb7EeRP.js → treemap-WGGIJYW6-B0IqbwdT.js} +1 -1
  74. package/out/phone/assets/{vennDiagram-4TSXK5OY-CXDX5KG5.js → vennDiagram-4TSXK5OY-Dp-aKgNa.js} +1 -1
  75. package/out/phone/assets/{wardley-WFR3VGLG-DrSIz3RL.js → wardley-WFR3VGLG-B7FlADZf.js} +1 -1
  76. package/out/phone/assets/{wardleyDiagram-VM6X3IG4-DFL8ndUf.js → wardleyDiagram-VM6X3IG4-BVntjQNl.js} +1 -1
  77. package/out/phone/assets/{xychartDiagram-S5SC5T6Z-CZZX0maW.js → xychartDiagram-S5SC5T6Z-kgVJvkgO.js} +1 -1
  78. package/out/phone/desk.html +2 -2
  79. package/out/phone/index.html +3 -3
  80. package/out/renderer/assets/{abnfDiagram-VCTEODGH-C03tURh9.js → abnfDiagram-VCTEODGH-Bp0r3dKm.js} +1 -1
  81. package/out/renderer/assets/{arc-B9ePZBoh.js → arc-BD5HnhIt.js} +1 -1
  82. package/out/renderer/assets/{architectureDiagram-5GKGNRK7-xqG-LPqx.js → architectureDiagram-5GKGNRK7-CgJHjETB.js} +1 -1
  83. package/out/renderer/assets/{blockDiagram-I7D4REHJ-BJCB1uWW.js → blockDiagram-I7D4REHJ-5le9vk4G.js} +1 -1
  84. package/out/renderer/assets/{c4Diagram-7LVT6UL2-B8YiLE3O.js → c4Diagram-7LVT6UL2-B4DCe-qN.js} +1 -1
  85. package/out/renderer/assets/channel-D-HltTAP.js +1 -0
  86. package/out/renderer/assets/{chunk-2Q5K7J3B-BfCgzuF1.js → chunk-2Q5K7J3B-DIxWfJHE.js} +1 -1
  87. package/out/renderer/assets/{chunk-5VM5RSS4-j2RDggaS.js → chunk-5VM5RSS4-D9j4om1l.js} +1 -1
  88. package/out/renderer/assets/{chunk-F27PBJKO-D1w1G98C.js → chunk-F27PBJKO-B_tGbKyc.js} +1 -1
  89. package/out/renderer/assets/{chunk-IMKFNOWR-HX7TqjEn.js → chunk-IMKFNOWR-Cfffd1p9.js} +1 -1
  90. package/out/renderer/assets/{chunk-JWPE2WC7-Ee_2ucfe.js → chunk-JWPE2WC7-BABZOPGb.js} +1 -1
  91. package/out/renderer/assets/{chunk-POPQ4Y6H-DuxBT9GV.js → chunk-POPQ4Y6H-D-QyVpSn.js} +1 -1
  92. package/out/renderer/assets/{chunk-SVP7TREG-DFjkSsO8.js → chunk-SVP7TREG-BghyPSd6.js} +1 -1
  93. package/out/renderer/assets/{chunk-TICWLB2K-1B31w-4D.js → chunk-TICWLB2K-CQmthy6z.js} +1 -1
  94. package/out/renderer/assets/{chunk-XXDRQBXY-DZ7nGbEc.js → chunk-XXDRQBXY-CDKsbyR7.js} +1 -1
  95. package/out/renderer/assets/classDiagram-ZZMXUADV-BCWhgMul.js +1 -0
  96. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BCWhgMul.js +1 -0
  97. package/out/renderer/assets/{cose-bilkent-JH36ORCC-k2aKhVw_.js → cose-bilkent-JH36ORCC-oajViFnN.js} +1 -1
  98. package/out/renderer/assets/{cynefin-OW5HDTMX-xPUo1qjT.js → cynefin-OW5HDTMX-DMH1CUmI.js} +1 -1
  99. package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-KbWg9eRv.js → cynefinDiagram-5FMLGOSQ-DVUJf9t0.js} +1 -1
  100. package/out/renderer/assets/{cytoscape-fcose-CLBXU3_O.js → cytoscape-fcose-adTZ191M.js} +1 -1
  101. package/out/renderer/assets/{dagre-GXQ25YYZ-ilq61to2.js → dagre-GXQ25YYZ-BXRWWNje.js} +1 -1
  102. package/out/renderer/assets/{diagram-S7CK7UJ4-DsRzYvTT.js → diagram-S7CK7UJ4-Dg7f2Dan.js} +1 -1
  103. package/out/renderer/assets/{diagram-UQ7AKVKN-nE6Ly2i6.js → diagram-UQ7AKVKN-DsLRyZAt.js} +1 -1
  104. package/out/renderer/assets/{diagram-VSXAHHWV-B9Crbma_.js → diagram-VSXAHHWV-3_LoodSS.js} +1 -1
  105. package/out/renderer/assets/{diagram-VX7I27RA-Bm5JhnFh.js → diagram-VX7I27RA-DQeZp2Cz.js} +1 -1
  106. package/out/renderer/assets/{diagram-Z3DM3KII-ZD7ANoYg.js → diagram-Z3DM3KII-Dwil6g5m.js} +1 -1
  107. package/out/renderer/assets/{ebnfDiagram-PWID7BFC-CT3pW9tk.js → ebnfDiagram-PWID7BFC-DecVNxpu.js} +1 -1
  108. package/out/renderer/assets/{erDiagram-RLTQ6QDP-D0ikskdu.js → erDiagram-RLTQ6QDP-D2rmo2nP.js} +1 -1
  109. package/out/renderer/assets/{flowDiagram-HODETNUW-BOF_JMXY.js → flowDiagram-HODETNUW-_SF2dRBl.js} +1 -1
  110. package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-BCEnP39-.js → ganttDiagram-EL5Y4UJY-BoYWs5Ev.js} +1 -1
  111. package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-WpPHHkc3.js → gitGraphDiagram-WWUBYQGX-BqRbZ3V0.js} +1 -1
  112. package/out/renderer/assets/globals-BEwCf508.css +1 -0
  113. package/out/renderer/assets/{globals-DWAN16wT.js → globals-C3zxoqqH.js} +223 -223
  114. package/out/renderer/assets/index-9vqh4wxi.js +133 -0
  115. package/out/renderer/assets/{infoDiagram-27XIBGKW-nRW-sje9.js → infoDiagram-27XIBGKW-CFt6xyuD.js} +1 -1
  116. package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-CEfZo_k8.js → ishikawaDiagram-5VMMS53U-CZB8G4dD.js} +1 -1
  117. package/out/renderer/assets/{journeyDiagram-3NMN7TZE-C5hopb9Y.js → journeyDiagram-3NMN7TZE-CO2VRmpx.js} +1 -1
  118. package/out/renderer/assets/{kanban-definition-UXKFOSKX-D9XV2n-x.js → kanban-definition-UXKFOSKX-DIqEnfMM.js} +1 -1
  119. package/out/renderer/assets/{layout-t2tiRL7x.js → layout-DXRKfO_Y.js} +1 -1
  120. package/out/renderer/assets/{linear-DJLwPmUz.js → linear-Cdx1AdZJ.js} +1 -1
  121. package/out/renderer/assets/{mermaid.core-C0XHWibr.js → mermaid.core-DuIO2jsm.js} +5 -5
  122. package/out/renderer/assets/{mindmap-definition-YA3MSWOX-DD-erShR.js → mindmap-definition-YA3MSWOX-B5lvxG2M.js} +1 -1
  123. package/out/renderer/assets/{pegDiagram-XKGWAZYB-DZ0Jk0gq.js → pegDiagram-XKGWAZYB-DCwHp-K3.js} +1 -1
  124. package/out/renderer/assets/{pieDiagram-E7YTZNPT-E7wG7xIV.js → pieDiagram-E7YTZNPT-Dq048Wh7.js} +1 -1
  125. package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-iyjmw417.js → quadrantDiagram-AXDQQJYC-DwkFkAi_.js} +1 -1
  126. package/out/renderer/assets/{railroadDiagram-O6MQD6OU-vCkzrMpv.js → railroadDiagram-O6MQD6OU-2NKvwLP-.js} +1 -1
  127. package/out/renderer/assets/{requirementDiagram-BXWQKSXE-DJ7nU4ps.js → requirementDiagram-BXWQKSXE-Bp44tNQ0.js} +1 -1
  128. package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-1TKFsYjQ.js → sankeyDiagram-P5KCCOFB-C3TFp1NK.js} +1 -1
  129. package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-C3ajyWo7.js → sequenceDiagram-WJ2MYXX4-BTPoYQeW.js} +1 -1
  130. package/out/renderer/assets/settings-DlDHkOe2.js +25 -0
  131. package/out/renderer/assets/{sizeCapture-INFHLROL-BKripAfM.js → sizeCapture-INFHLROL-DvNj5TDT.js} +1 -1
  132. package/out/renderer/assets/{stateDiagram-D77RDMKH-DSqc4avN.js → stateDiagram-D77RDMKH-DC8YykNp.js} +1 -1
  133. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-B4rCEEYH.js +1 -0
  134. package/out/renderer/assets/{swimlanes-42K2YHIH-C2Jeg683.js → swimlanes-42K2YHIH-0yL1nNkg.js} +1 -1
  135. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-zQqW8MJ5.js +8 -0
  136. package/out/renderer/assets/{timeline-definition-24CTP7MA-rvOKRLqz.js → timeline-definition-24CTP7MA-Pg-2roGv.js} +1 -1
  137. package/out/renderer/assets/{vennDiagram-4TSXK5OY-Cig1eOav.js → vennDiagram-4TSXK5OY-D0af5K4E.js} +1 -1
  138. package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-C8spX5XL.js → wardleyDiagram-VM6X3IG4-CB_nIy_l.js} +1 -1
  139. package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-DHQsGiFY.js → xychartDiagram-S5SC5T6Z-A26Yld8R.js} +1 -1
  140. package/out/renderer/index.html +3 -3
  141. package/out/renderer/settings.html +4 -4
  142. package/out/renderer/web-preload.js +39 -39
  143. package/out/server/agent.js +276 -506
  144. package/out/server/chunks/{agent-BbLTL3oo.js → agent-D33nI7fP.js} +176 -195
  145. package/out/server/chunks/dispatchModel-CsfmL396.js +20 -0
  146. package/out/server/chunks/gpuBackendInstall-CRzfB150.js +237 -0
  147. package/out/server/chunks/{loadProvider-ff0h4G9y.js → loadProvider-4Y15KP7W.js} +2 -2
  148. package/out/server/chunks/{manifest-DjsZzZuh.js → manifest-wlfh-NN5.js} +2 -2
  149. package/out/server/chunks/{resources-DmaKIeBc.js → resources-DzUshg1j.js} +3 -3
  150. package/out/server/chunks/{storageScanWorker-BQ1LXUu7.js → storageScanWorker-CX8O_DlF.js} +2 -2
  151. package/out/server/chunks/{storageScanWorker-Bebego8l.js → storageScanWorker-CuttDIGS.js} +2 -2
  152. package/out/server/chunks/{workflowPresets-XbQNDJh1.js → workflowPresets-CAA0AY6f.js} +1091 -287
  153. package/out/server/index.js +2376 -3358
  154. package/out/server/plugin-host.js +2 -2
  155. package/package.json +2 -3
  156. package/out/phone/assets/architecture-7GRP2DOG-C-qor9pl.js +0 -1
  157. package/out/phone/assets/channel-X_IbcoWa.js +0 -1
  158. package/out/phone/assets/classDiagram-ZZMXUADV-BM8gYXGQ.js +0 -1
  159. package/out/phone/assets/classDiagram-v2-VYDZK3BY-BM8gYXGQ.js +0 -1
  160. package/out/phone/assets/desk-BNoyCelL.js +0 -2
  161. package/out/phone/assets/eventmodeling-NTZA5JFV-BdEBApKV.js +0 -1
  162. package/out/phone/assets/flowDiagram-HODETNUW-OPg41_ia.js +0 -1
  163. package/out/phone/assets/main-BU1pbfVw.css +0 -1
  164. package/out/phone/assets/main-ZLMPRLjZ.js +0 -1658
  165. package/out/phone/assets/railroad-abnf-HS5TGJTU-BoQXwOPL.js +0 -1
  166. package/out/phone/assets/railroad-ebnf-LZEXJU2U-1G126duh.js +0 -1
  167. package/out/phone/assets/railroad-peg-WCYAUIDC-C7pIuHge.js +0 -1
  168. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-BMZswIYt.js +0 -1
  169. package/out/phone/assets/storage-dUWOZ2xo.js +0 -36
  170. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-RYt3eASc.js +0 -8
  171. package/out/renderer/assets/channel-DwCSANyp.js +0 -1
  172. package/out/renderer/assets/classDiagram-ZZMXUADV-BT-9dtRl.js +0 -1
  173. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BT-9dtRl.js +0 -1
  174. package/out/renderer/assets/globals-DoPyZAQo.css +0 -1
  175. package/out/renderer/assets/index-DOUivox4.js +0 -133
  176. package/out/renderer/assets/settings-BmMFkVO5.js +0 -27
  177. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-JOz8ISDT.js +0 -1
  178. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-Km8IGI0J.js +0 -8
  179. package/out/server/chunks/engine-IZbRceya.js +0 -70
  180. package/out/server/chunks/engineWorker-CQxNRdLD.js +0 -6
  181. package/out/server/chunks/engineWorker-CrUIcXCt.js +0 -73
  182. package/out/server/chunks/gpuBackendInstall-COO4pT2M.js +0 -158
  183. package/out/server/chunks/hanbao-_aDjow_f.js +0 -187
  184. package/out/server/chunks/speech-CqK6_tIR.js +0 -25
  185. package/out/server/chunks/wetype-CR0YLhHP.js +0 -677
@@ -1,15 +1,15 @@
1
1
  import path, { join, posix, dirname } from "node:path";
2
- 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 THINKING_LEVELS, t as SECRETARY_ID_MAX, 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-BbLTL3oo.js";
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, mkdirSync, existsSync, readFileSync, appendFileSync, unlinkSync, renameSync, rmSync, constants, realpathSync, readdirSync } from "node:fs";
5
- 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, k as killProcessTree, 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, l as isReflectionsRecordedData, m as isReflectionsConsolidatedData, o as isObservationsDroppedData, q as OM_REFLECTIONS_CONSOLIDATED, r as OM_OBSERVATIONS_DROPPED, u as OM_FOLDED, v as isMemoryDetails, w as isObservationsRecordedEntry, x as isReflectionsRecordedEntry, y as isReflectionsConsolidatedEntry, z as isObservationsDroppedEntry, B as buildObservationsRecordedData, C as buildReflectionsRecordedData, D as buildReflectionsConsolidatedData, E as buildObservationsDroppedData, F as readModelsDevCache, G as version, H as parseModelDirectorySnapshot, I as findCatalogModelById, J as findModelsDevModel, K as mergeCatalogEntry, L as resolveCustomModelCapabilities, M as closestMatchHint, N as mcpTimeoutMsOrDefault, Q as oneLine$1, R as mcpNamespaceName, S as assignMcpToolNames, T as MCP_OAUTH_REFRESH_SKEW_MS, U as mcpOAuthFingerprint, W as DEFAULT_MCP_CONNECT_TIMEOUT_MS, X as DEFAULT_MCP_CALL_TIMEOUT_MS, Y as isXaiChatModelId, Z as transcriptMessages, _ as projectMessage, $ as ensureAccountProvider, a0 as replacePersonaParagraph, a1 as takeSnapshotTail, a2 as attachBackgroundCommandHooks, a3 as ForegroundDetachedError, 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 BackgroundTaskManager, av as isDeferredMcp, aw as providerIdOfAccountKey, ax as resolveOauthCatalogModel, ay as createSshExecutor, az as partitionMcpNamespaces, aA as CodemodeHost, aB as ApprovalGate, aC as HUMAN_REQUEST_TIMEOUT_MS, aD as TodoStaleReminder, aE as CoworkerIdleReminder, aF as createUnifiedSubagentTool, aG as workflowPresetRoots, aH as withMandatoryApproval, aI as createBrowserTools, aJ as withNavigateApproval, aK as createMemoryTools, aL as withComputerApproval, aM as createComputerTool, aN as withApproval, aO as listWorkflowPresets, aP as createTaskTools, aQ as BrowserInvoker, aR as MemoryInvoker, aS as PlanController, aT as ComputerInvoker, aU as AskManager, aV as createAskTool, aW as snapshotMainConversation, aX as lastAssistantText$1, aY as positiveContextWindow, aZ as foregroundCommandTimeoutMs, a_ as buildTurnDigest, a$ as parseJsonFromAssistant, b0 as validateAgainstSchema, b1 as appendYieldJson, b2 as appendCappedLog, b3 as AGENT_COMPACTION_LOG, b4 as describeTitleModel, b5 as buildRollingTitleUserText, b6 as buildInitialTitleUserText, b7 as ROLLING_TITLE_SYSTEM_PROMPT, b8 as TITLE_SYSTEM_PROMPT, b9 as extractTitle, ba as titleRejectReason, bb as resolveChildReasoning, bc as pickChildReasoningOverride, bd as createWebTools, be as createTodoTool, bf as withPlanGate, bg as createSubmitPlanTool, bh as titleSummaryTimeoutMs, bi as splitUnattendedPrefix, bj as resolveHarnessSkillRoots, bk as approvalReviewResultExtension, bl as readHarnessRuleFiles, bm as createProjectSettingsManager, bn as CODEMODE_TOOL_NAME, bo as prepareCodemodeInput, bp as ANTIGRAVITY_PROVIDER_ID, bq as antigravityProviderConfig, br as DEVIN_PROVIDER_ID, bs as devinProviderConfig, bt as QODER_PROVIDER_ID, bu as qoderProviderConfig, bv as QODER_CN_PROVIDER_ID, bw as installCodexLinkedRefresh, bx as isHeadlessRun, by as withBackground, bz as withProtectedFloor, bA as loadWorkflowPreset, bB as cloneModelsDevOauthModel, bC as withWriteScope, bD as withWritePreflight, bE as validateApplyPatchTargets, bF as withAgentRead, bG as extractEditTargetPath, bH as buildSshShellCommand, bI as resolveSshControlPath, bJ as sshPasswordEnv, bK as getApplyPatchPaths } from "./chunks/workflowPresets-XbQNDJh1.js";
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-ff0h4G9y.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, createPowerShellToolDefinition, createBashToolDefinition, createLocalPowerShellOperations, createLocalBashOperations, stripFrontmatter, createGrepToolDefinition, createAgentSession, SessionManager, ModelRuntime, DefaultResourceLoader, createWriteToolDefinition, createReadToolDefinition, createFindToolDefinition, createLsToolDefinition, createSyntheticSourceInfo } from "@earendil-works/pi-coding-agent";
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$6(value) {
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$6(usage?.cost) ? { ...empty.cost, ...usage.cost } : empty.cost
801
+ cost: isRecord$5(usage?.cost) ? { ...empty.cost, ...usage.cost } : empty.cost
802
802
  };
803
803
  }
804
804
  function needsUsagePatch(usage) {
805
- if (!isRecord$6(usage)) return true;
806
- return typeof usage.totalTokens !== "number" || !Number.isFinite(usage.totalTokens) || !isRecord$6(usage.cost);
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$6(message) || message.role !== "assistant") continue;
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 use the dispatch model from your settings.",
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", "patrolIntervalMinutes", "patrolIdleGoalMinutes"],
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 may need the user to confirm on a card; when it does, the call returns a proposalId instead of a conversationId. 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.',
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: "Run in an isolated worktree instead of the project checkout"
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. Same confirmation rules as session_create, and the same optional checkout / baseRef / branch to pin the base and after to wait for other sessions, plus the same optional model.",
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: { type: "boolean" },
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, model, autonomy, visible projects, takeover scope, 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.",
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 = [], pluginCommands = [], pluginHooks = [], botMode = false, botGroupTasks = false, protectedActions = false, botRoutines = false, secretaryMode = false, botWriteLock, botDelegationTask = false, pluginToolDescriptors = [], pluginEvents, dcgPath, autoRejectApprovals = false, botDiscussMode = false, instanceId, workflowPresetFiles = [], secretaryToolDescriptors = [], askRelay) {
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
- seq: 0,
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
- shutdown() {
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("/"));