@askexenow/exe-os 0.9.362 → 0.9.365

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 (450) hide show
  1. package/deploy/compose/.env.customer.example +46 -2
  2. package/deploy/compose/.env.example +49 -2
  3. package/deploy/compose/cloudflared/config.yml.example +15 -8
  4. package/deploy/compose/docker-compose.yml +240 -34
  5. package/deploy/compose/generate-env.ts +88 -2
  6. package/deploy/compose/status.sh +30 -0
  7. package/deploy/compose/uptime-check.sh +39 -2
  8. package/deploy/compose/wiki-schema-guard.sh +302 -0
  9. package/deploy/stack-manifests/v0.9.json +232 -2
  10. package/dist/.dist-verified.json +3 -3
  11. package/dist/{active-agent-BPNEBKHI.js → active-agent-C6DPH43L.js} +10 -5
  12. package/dist/{active-agent-3FV5V7SS.js → active-agent-MGF7J3HB.js} +10 -5
  13. package/dist/agent-defs-generator-X7TVMPVB.js +240 -0
  14. package/dist/{agentic-ontology-RCVCJ6WB.js → agentic-ontology-CARDCG37.js} +1 -1
  15. package/dist/artifact-backup-767STHSW.js +209 -0
  16. package/dist/artifact-provenance-C7HQ267L.js +13 -0
  17. package/dist/{backfill-gate-LRX77SUD.js → backfill-gate-VX2RZTQV.js} +2 -2
  18. package/dist/{backfill-metadata-Y3DGVCK5.js → backfill-metadata-ANCJA6LA.js} +7 -7
  19. package/dist/{background-jobs-Z6KHCWES.js → background-jobs-LTPWCMA3.js} +2 -2
  20. package/dist/{backup-verify-TZPPUCLU.js → backup-verify-F7BHVEF7.js} +27 -14
  21. package/dist/{behavior-injection-JMGGWCWG.js → behavior-injection-XQ4B7DCF.js} +13 -12
  22. package/dist/{behaviors-TT6CMEKC.js → behaviors-R2IE3PEN.js} +12 -11
  23. package/dist/bin/age-ontology-load.js +2 -2
  24. package/dist/bin/agentic-ontology-backfill.js +9 -9
  25. package/dist/bin/agentic-reflection-backfill.js +10 -10
  26. package/dist/bin/agentic-semantic-label.js +9 -9
  27. package/dist/bin/backfill-conversations.js +10 -9
  28. package/dist/bin/backfill-responses.js +10 -9
  29. package/dist/bin/backfill-vectors.js +14 -13
  30. package/dist/bin/bulk-sync-postgres.js +23 -19
  31. package/dist/bin/cc-doctor.js +11 -8
  32. package/dist/bin/cleanup-stale-review-tasks.js +26 -24
  33. package/dist/bin/cli.js +29 -102
  34. package/dist/bin/customer-readiness.js +3 -1
  35. package/dist/bin/deferred-daemon-restart.js +115 -103
  36. package/dist/bin/exe-agent-config.js +5 -5
  37. package/dist/bin/exe-agent.js +14 -14
  38. package/dist/bin/exe-assign.js +12 -11
  39. package/dist/bin/exe-boot.js +60 -51
  40. package/dist/bin/exe-call.js +7 -7
  41. package/dist/bin/exe-cloud.js +26 -22
  42. package/dist/bin/exe-config-dump.js +5 -5
  43. package/dist/bin/exe-dispatch.js +30 -24
  44. package/dist/bin/exe-doctor.js +10 -9
  45. package/dist/bin/exe-export-behaviors.js +14 -13
  46. package/dist/bin/exe-forget.js +9 -9
  47. package/dist/bin/exe-gateway.js +9 -9
  48. package/dist/bin/exe-grant.js +5 -5
  49. package/dist/bin/exe-healthcheck.js +13 -8
  50. package/dist/bin/exe-heartbeat.js +36 -29
  51. package/dist/bin/exe-kill.js +30 -28
  52. package/dist/bin/exe-launch-agent.js +41 -37
  53. package/dist/bin/exe-mcp.js +5 -5
  54. package/dist/bin/exe-memory-reads.js +7 -7
  55. package/dist/bin/exe-new-employee.js +12 -11
  56. package/dist/bin/exe-os-mcp-proxy.js +5 -5
  57. package/dist/bin/exe-pending-messages.js +27 -25
  58. package/dist/bin/exe-pending-notifications.js +26 -24
  59. package/dist/bin/exe-pending-reviews.js +27 -25
  60. package/dist/bin/exe-rename.js +7 -7
  61. package/dist/bin/exe-review.js +29 -27
  62. package/dist/bin/exe-search.js +8 -8
  63. package/dist/bin/exe-session-cleanup.js +31 -29
  64. package/dist/bin/exe-settings.js +24 -20
  65. package/dist/bin/exe-start-codex.js +36 -21
  66. package/dist/bin/exe-start-opencode.js +15 -14
  67. package/dist/bin/exe-status.js +28 -25
  68. package/dist/bin/exe-support.js +5 -4
  69. package/dist/bin/exe-team.js +12 -6
  70. package/dist/bin/exe-verify-running-images.js +145 -0
  71. package/dist/bin/exe-watchdog.js +16 -6
  72. package/dist/bin/git-sweep.js +27 -25
  73. package/dist/bin/graph-backfill.js +10 -9
  74. package/dist/bin/graph-export.js +8 -8
  75. package/dist/bin/import-history.js +13 -11
  76. package/dist/bin/install.js +119 -107
  77. package/dist/bin/intercom-check.js +5 -5
  78. package/dist/bin/mcp-sessions.js +2 -2
  79. package/dist/bin/orchestration-metrics.js +6 -6
  80. package/dist/bin/postgres-agentic-reflection-backfill.js +4 -4
  81. package/dist/bin/postgres-agentic-semantic-backfill.js +3 -3
  82. package/dist/bin/pre-publish.js +1 -1
  83. package/dist/bin/reconcile-backlog.js +2 -2
  84. package/dist/bin/registry-proxy.js +1 -1
  85. package/dist/bin/scan-tasks.js +26 -24
  86. package/dist/bin/setup.js +4 -3
  87. package/dist/bin/shard-migrate.js +8 -8
  88. package/dist/bin/stack-update.js +87 -38
  89. package/dist/bin/vps-health-gate.js +1 -1
  90. package/dist/{boot-generation-XABYKF5P.js → boot-generation-X45BSVZY.js} +5 -5
  91. package/dist/{boot-review-sections-2X5TFIGU.js → boot-review-sections-OBVRXXSF.js} +25 -23
  92. package/dist/{branch-hygiene-Z4IBWAOX.js → branch-hygiene-HFJ3HA62.js} +17 -10
  93. package/dist/{branding-7MZDHTKN.js → branding-GH43W3PU.js} +2 -2
  94. package/dist/build-manifest.json +1189 -1049
  95. package/dist/{capability-cards-O5UXDOOA.js → capability-cards-57FURUMR.js} +4 -4
  96. package/dist/{capacity-monitor-IPXM726A.js → capacity-monitor-QEL62JDO.js} +27 -25
  97. package/dist/{catchup-brief-EBIGDXOK.js → catchup-brief-PMXTCASA.js} +30 -28
  98. package/dist/{chunk-UO5QJ2RX.js → chunk-22YQBVMO.js} +4 -4
  99. package/dist/chunk-2ADYTOHQ.js +189 -0
  100. package/dist/{chunk-NO5KHKKB.js → chunk-2CWS374F.js} +1 -1
  101. package/dist/{chunk-NAHCSQWT.js → chunk-2ESB5SDP.js} +19 -7
  102. package/dist/{chunk-CY5NVDTH.js → chunk-2FYIMTQE.js} +9 -5
  103. package/dist/{chunk-SC6WDF3Q.js → chunk-2RQT7TED.js} +2 -2
  104. package/dist/{chunk-UWEFIIEG.js → chunk-3CIMDFXG.js} +1 -1
  105. package/dist/{chunk-E7PL3T2U.js → chunk-3JNVB5LG.js} +1 -1
  106. package/dist/{chunk-7SY2NOMQ.js → chunk-3THNS2T7.js} +1 -1
  107. package/dist/{chunk-XJIRUTGJ.js → chunk-45EQTS7B.js} +1 -1
  108. package/dist/{chunk-YZUHSV24.js → chunk-4LWBC7CM.js} +1 -1
  109. package/dist/{chunk-DKRDU2AX.js → chunk-4QKKLK3C.js} +14 -14
  110. package/dist/{chunk-WP2TGH5R.js → chunk-52TIQJEQ.js} +2 -2
  111. package/dist/{chunk-LG37UBBE.js → chunk-5CBGH6RA.js} +5 -5
  112. package/dist/{chunk-W3LKIQJ2.js → chunk-6GQYPJPG.js} +22 -16
  113. package/dist/{chunk-I3SF6QGV.js → chunk-6Q263OZE.js} +1 -1
  114. package/dist/{chunk-XSYQ5EPE.js → chunk-7C4FUNVO.js} +11 -11
  115. package/dist/{chunk-P7CV4SHQ.js → chunk-7Y6AQWVT.js} +21 -10
  116. package/dist/{chunk-NGDXBN3M.js → chunk-A6PDF4BO.js} +2 -2
  117. package/dist/chunk-A7XLR3K7.js +45 -0
  118. package/dist/{chunk-7H3AZNQ7.js → chunk-AGQAGOQN.js} +9 -9
  119. package/dist/{chunk-VDMFVUSY.js → chunk-ANPE3TT3.js} +3 -3
  120. package/dist/{chunk-NE4QI2GX.js → chunk-BATQKSLI.js} +2 -2
  121. package/dist/{chunk-AOMFYUPT.js → chunk-BEHLIRRJ.js} +2 -2
  122. package/dist/{chunk-6EM6USV7.js → chunk-BNHAZ65R.js} +42 -50
  123. package/dist/{chunk-HLU52KTO.js → chunk-BRLS5OLZ.js} +257 -36
  124. package/dist/{chunk-QCJT265O.js → chunk-BY7WWPRM.js} +1 -1
  125. package/dist/{chunk-Z67DIJKT.js → chunk-C3UAQ3JG.js} +1 -1
  126. package/dist/{chunk-MZYNW5OY.js → chunk-CDUB5Q6J.js} +1 -1
  127. package/dist/{chunk-5H3RHWRE.js → chunk-CKG6CVKI.js} +1 -1
  128. package/dist/{chunk-WH2VVEGD.js → chunk-CMBF5WCL.js} +56 -2
  129. package/dist/{chunk-JYKZVAS6.js → chunk-CPILYY2K.js} +1 -1
  130. package/dist/{chunk-XTGR3LMF.js → chunk-CW2UCKHS.js} +2 -2
  131. package/dist/{chunk-32FEF5BW.js → chunk-CWBFOAGM.js} +2 -2
  132. package/dist/{chunk-V5I5N7NC.js → chunk-DEFSN2FQ.js} +3 -3
  133. package/dist/{chunk-HAXCUCJC.js → chunk-DJK45U7B.js} +1 -1
  134. package/dist/{chunk-MZZN5GFC.js → chunk-DQ5KHWFD.js} +1 -1
  135. package/dist/{chunk-SLBOKYYQ.js → chunk-DWAQOEXL.js} +2 -2
  136. package/dist/{chunk-T2RZU7JA.js → chunk-DYWGIPVP.js} +7 -7
  137. package/dist/{chunk-6DTALXOA.js → chunk-E5HAY3DQ.js} +1 -1
  138. package/dist/{chunk-D5CY4E7I.js → chunk-EHHMNKOA.js} +1 -1
  139. package/dist/{chunk-54USDN5Q.js → chunk-EJ4522YM.js} +1 -1
  140. package/dist/{chunk-URNVIZXU.js → chunk-EKVTRI3N.js} +52 -6
  141. package/dist/{chunk-KID6T2A4.js → chunk-EMZHB767.js} +44 -35
  142. package/dist/{chunk-KBI4FVBZ.js → chunk-EPDNWY5P.js} +111 -22
  143. package/dist/{chunk-AQO3BT3I.js → chunk-EPNWEOOE.js} +13 -13
  144. package/dist/{chunk-5C6ZIJ7J.js → chunk-ESTR7QUP.js} +1 -1
  145. package/dist/{chunk-Q2VQNAPU.js → chunk-EVPBYX2Z.js} +2 -2
  146. package/dist/{chunk-CVYDJ2TW.js → chunk-EWCEUO65.js} +1 -1
  147. package/dist/{chunk-RNSAVQEU.js → chunk-EWZYFG5Q.js} +8 -3
  148. package/dist/{chunk-R7F6HKTH.js → chunk-EXDW3E2R.js} +3 -1
  149. package/dist/{chunk-TY4JLBFO.js → chunk-F2S3M5MB.js} +3 -3
  150. package/dist/{chunk-BT2PUK3S.js → chunk-FXPAUDCZ.js} +1 -1
  151. package/dist/{chunk-3C7NE4JE.js → chunk-G2EAYH4U.js} +1 -1
  152. package/dist/{chunk-WDA2KAV7.js → chunk-GSJLB6JI.js} +1 -1
  153. package/dist/{chunk-M67ARGXY.js → chunk-H37FSTF2.js} +1 -1
  154. package/dist/{chunk-ZR4CQBAP.js → chunk-H74466TM.js} +1 -1
  155. package/dist/{chunk-3BAGFZFN.js → chunk-HHGOCBVQ.js} +9 -9
  156. package/dist/{working-memory-BACVOAIV.js → chunk-HSFBNCNC.js} +3 -3
  157. package/dist/{chunk-PF7EQSE5.js → chunk-IIZITKBV.js} +6 -6
  158. package/dist/{chunk-2FA4PYYX.js → chunk-IM2I7OOS.js} +1 -1
  159. package/dist/{chunk-DSKEYEL2.js → chunk-IXEFO6HD.js} +3 -3
  160. package/dist/{chunk-TN2E6ZCM.js → chunk-J4U5Z7VX.js} +214 -58
  161. package/dist/{chunk-PU7UYQRC.js → chunk-J5EYOBFF.js} +1 -1
  162. package/dist/{chunk-RWKX2TK5.js → chunk-J6I7X272.js} +1 -1
  163. package/dist/{chunk-BDLRTLXY.js → chunk-JITNFE4W.js} +6 -2
  164. package/dist/{chunk-PUMH7JSB.js → chunk-JNVQGLPX.js} +3 -3
  165. package/dist/{chunk-VAOUB2TK.js → chunk-JTB5V6BV.js} +1 -1
  166. package/dist/{chunk-QYRI25IP.js → chunk-JUOZLXLH.js} +2 -2
  167. package/dist/{chunk-RYRNY6IF.js → chunk-JYFYIGYK.js} +2 -2
  168. package/dist/{chunk-2PRAXZWM.js → chunk-KOYGRP2L.js} +10 -5
  169. package/dist/{chunk-4AFD4R35.js → chunk-KRUYQFSH.js} +5 -5
  170. package/dist/chunk-L25OAFOU.js +93 -0
  171. package/dist/{chunk-FUQ2OSDV.js → chunk-L2VZBPJJ.js} +25 -8
  172. package/dist/{chunk-LCDW2HUL.js → chunk-LHOKWZKL.js} +1 -1
  173. package/dist/{chunk-BN26LSME.js → chunk-LKYGSJ2E.js} +13 -2
  174. package/dist/chunk-LNOS24GV.js +214 -0
  175. package/dist/{chunk-O32HTNRX.js → chunk-LZKYVMBY.js} +13 -4
  176. package/dist/{chunk-35FD67ZB.js → chunk-M7EES2KM.js} +3 -3
  177. package/dist/chunk-MBBFL2SP.js +45 -0
  178. package/dist/{chunk-4R2WD6T3.js → chunk-MPQXQ5IE.js} +2 -2
  179. package/dist/{chunk-QQMYD4M7.js → chunk-MXEIZUXG.js} +1 -1
  180. package/dist/{chunk-6QJXFLNN.js → chunk-MZJBUAC3.js} +5 -5
  181. package/dist/chunk-NEHOQ3P2.js +19 -0
  182. package/dist/{chunk-BRZR76TS.js → chunk-NJFJWQNN.js} +49 -14
  183. package/dist/{chunk-Q7J2SQJ6.js → chunk-NO3M2AFM.js} +100 -32
  184. package/dist/{gotrue-session-2IT7MDGW.js → chunk-NUTZJZKW.js} +7 -8
  185. package/dist/{chunk-6UZDGEGQ.js → chunk-NV6A5HDN.js} +71 -1
  186. package/dist/{chunk-ZI3HA3XW.js → chunk-O2MEBF23.js} +3 -3
  187. package/dist/{chunk-V6YLIDLK.js → chunk-ODBRU6BF.js} +577 -230
  188. package/dist/{chunk-6N3HUOV3.js → chunk-OFGFRT5J.js} +2 -2
  189. package/dist/{chunk-HKQ7UTSE.js → chunk-OPNROU5B.js} +1 -1
  190. package/dist/{chunk-SQM4ZTL2.js → chunk-ORNCMRIX.js} +60 -33
  191. package/dist/{chunk-RUUX2ZST.js → chunk-P47MPWNU.js} +1 -1
  192. package/dist/{org-key-admin-4W6LZ5KZ.js → chunk-P5XTVIEC.js} +62 -17
  193. package/dist/{chunk-OZNCAMS3.js → chunk-POPRJKAY.js} +122 -20
  194. package/dist/{chunk-SRFRUN66.js → chunk-PPGPCWRC.js} +5 -5
  195. package/dist/{chunk-B6PFGUYJ.js → chunk-PVEM537A.js} +46 -5
  196. package/dist/{chunk-QJBX3MBV.js → chunk-Q7BU5Q6I.js} +3 -3
  197. package/dist/{chunk-SXKIGBNF.js → chunk-QFIVK3G5.js} +1 -1
  198. package/dist/{chunk-BRIZ6OZ3.js → chunk-QMSEL5YS.js} +81 -23
  199. package/dist/{chunk-BJEQBKGH.js → chunk-QYJANQWC.js} +8 -8
  200. package/dist/{chunk-4U56FZ7B.js → chunk-R7RM766N.js} +3 -3
  201. package/dist/{chunk-QI25QRUP.js → chunk-RD4E5G3B.js} +2 -2
  202. package/dist/{chunk-QP53XLC5.js → chunk-RHX6MNWY.js} +1 -1
  203. package/dist/chunk-RIECV7SR.js +234 -0
  204. package/dist/{chunk-3YBJ36UX.js → chunk-RLDMUSRM.js} +2 -2
  205. package/dist/{chunk-CXQ724WH.js → chunk-RVWALVDT.js} +2 -2
  206. package/dist/{chunk-VWTUKKUF.js → chunk-RZIKSE6N.js} +10 -4
  207. package/dist/chunk-SBAU735L.js +328 -0
  208. package/dist/{chunk-XRCX6R5S.js → chunk-SBJV2PCU.js} +1 -1
  209. package/dist/chunk-SO7KTH3Q.js +27 -0
  210. package/dist/{chunk-327Q53AS.js → chunk-SP37DONS.js} +17 -6
  211. package/dist/{chunk-KA4WVDLX.js → chunk-T6S45OLV.js} +4 -4
  212. package/dist/chunk-TCTED52S.js +120 -0
  213. package/dist/{chunk-HLQ4MS42.js → chunk-TO6TB75E.js} +4 -4
  214. package/dist/{chunk-465RCKVI.js → chunk-U373MEF5.js} +6 -6
  215. package/dist/{chunk-AL4HXKDJ.js → chunk-VGE6IHZB.js} +10 -10
  216. package/dist/{chunk-WBG7XYVR.js → chunk-VHJVD3MZ.js} +8 -0
  217. package/dist/{chunk-ZZEKOI2M.js → chunk-VMJ2UH4S.js} +1 -1
  218. package/dist/{chunk-3ICF4IAZ.js → chunk-VS4LPG66.js} +1 -1
  219. package/dist/{chunk-E3YI6FVJ.js → chunk-VV5EZZNT.js} +1 -1
  220. package/dist/{chunk-OPU3NYOO.js → chunk-W2IRQJ6R.js} +12 -0
  221. package/dist/{chunk-PV5BIXT6.js → chunk-WR75WUEP.js} +1 -1
  222. package/dist/{chunk-XUB4GFPN.js → chunk-WYLFDSIE.js} +144 -99
  223. package/dist/{chunk-4L33OFU4.js → chunk-X2P43TB2.js} +6 -3
  224. package/dist/chunk-X2X3IGZU.js +215 -0
  225. package/dist/{chunk-KIKB6FY3.js → chunk-X6A2VWVJ.js} +2 -2
  226. package/dist/chunk-XMVSLLED.js +38 -0
  227. package/dist/{chunk-KDMVVHZH.js → chunk-XTWHNLGD.js} +95 -23
  228. package/dist/{chunk-QY3TM2T3.js → chunk-YMJOLEPE.js} +4 -4
  229. package/dist/{chunk-RFKRCVGW.js → chunk-YYA5LXCT.js} +1 -1
  230. package/dist/{chunk-HSKABJE6.js → chunk-ZDUO6QBH.js} +5 -10
  231. package/dist/{chunk-PDJWHL63.js → chunk-ZEKCHV43.js} +4 -4
  232. package/dist/{chunk-23KWUA7Z.js → chunk-ZNEBZCZR.js} +53 -2
  233. package/dist/chunk-ZNUJFX7L.js +135 -0
  234. package/dist/{chunk-TP7RXGMP.js → chunk-ZRKEUCUZ.js} +315 -67
  235. package/dist/{chunk-6Y3KUO7Q.js → chunk-ZSZPMUNX.js} +244 -21
  236. package/dist/{chunk-4P2BFNSB.js → chunk-ZVTKWWLV.js} +2 -2
  237. package/dist/{chunk-RCOIKTHM.js → chunk-ZZXMB5F2.js} +1 -1
  238. package/dist/{cleanup-graph-garbage-6F22Y5SD.js → cleanup-graph-garbage-CAA625RJ.js} +10 -9
  239. package/dist/cloud-sync-command-DBB7WRHL.js +96 -0
  240. package/dist/cloud-sync-db-init-V7IB23W5.js +46 -0
  241. package/dist/{cloud-sync-shutdown-FWERMZB5.js → cloud-sync-shutdown-2D3B73CJ.js} +10 -4
  242. package/dist/{cloud-sync-state-DJRZORFI.js → cloud-sync-state-5DFKLWNB.js} +1 -1
  243. package/dist/{co-activation-UEEDCM5U.js → co-activation-JVN7EBS6.js} +4 -4
  244. package/dist/{co-occurrence-W6OPFRSY.js → co-occurrence-526PTFGT.js} +8 -7
  245. package/dist/{code-context-index-DWR6HS35.js → code-context-index-XOP6TLPZ.js} +5 -4
  246. package/dist/{conversation-entity-extractor-LWUIH3UB.js → conversation-entity-extractor-JO56DB2E.js} +9 -4
  247. package/dist/{conversation-wiki-populator-5EGRW2UZ.js → conversation-wiki-populator-EBUZXYEU.js} +1 -1
  248. package/dist/{crdt-sync-NHJX3ZJD.js → crdt-sync-LIJLZKFE.js} +2 -2
  249. package/dist/{crm-webhook-OY467ATC.js → crm-webhook-55F7Y6D2.js} +2 -2
  250. package/dist/{cto-delegation-gate-XH4YSQVC.js → cto-delegation-gate-QIYV4KFO.js} +41 -24
  251. package/dist/daemon-auth-SSPY5ODS.js +46 -0
  252. package/dist/{daemon-orchestration-7425ZVNH.js → daemon-orchestration-Q3GJA2JJ.js} +46 -30
  253. package/dist/{daemon-ready-VGPSRI3Z.js → daemon-ready-MKBH4QWD.js} +1 -1
  254. package/dist/{daemon-restart-report-HZU5LWXN.js → daemon-restart-report-EIVD6WDJ.js} +1 -1
  255. package/dist/db-integrity-events-5DTASXJF.js +22 -0
  256. package/dist/{db-restore-events-TFCZ4CPM.js → db-restore-events-2FI4ZMKA.js} +1 -1
  257. package/dist/{doc-graph-extractor-RR2VSO4W.js → doc-graph-extractor-P46R4QME.js} +13 -8
  258. package/dist/{documents-TRZ4R2ZW.js → documents-7KFEREWO.js} +12 -11
  259. package/dist/{dreaming-MAMZAPYW.js → dreaming-JMUXBAPU.js} +29 -27
  260. package/dist/employee-boot-brief-HN63D2BY.js +71 -0
  261. package/dist/{exe-drift-VBWB5E6S.js → exe-drift-7J7GX7DP.js} +5 -5
  262. package/dist/{exe-export-XJJTVVT7.js → exe-export-KJ7B2OBU.js} +14 -13
  263. package/dist/{exe-import-G6O7JFNZ.js → exe-import-HPZDWKGE.js} +14 -13
  264. package/dist/{exe-key-A2WJLLTM.js → exe-key-2PREP464.js} +117 -105
  265. package/dist/{exe-org-HXF4XBB3.js → exe-org-VEIISATF.js} +88 -26
  266. package/dist/{exe-snapshot-TL3TLKLR.js → exe-snapshot-JXQFLUKA.js} +33 -40
  267. package/dist/{fast-db-init-SO2XUQ7T.js → fast-db-init-SCXJXOYX.js} +1 -1
  268. package/dist/{founder-context-IOCADC66.js → founder-context-U2SZPLYV.js} +4 -3
  269. package/dist/{founder-monitor-envelope-SMILO4BT.js → founder-monitor-envelope-5KTKNL5G.js} +4 -4
  270. package/dist/fts-integrity-LKAZEZJE.js +96 -0
  271. package/dist/gateway/index.js +19 -19
  272. package/dist/{git-staleness-I6WT7EXV.js → git-staleness-S4NDR7NX.js} +4 -4
  273. package/dist/{global-procedures-3RMO6C3C.js → global-procedures-ZOFTOXIR.js} +6 -6
  274. package/dist/gotrue-session-ODZ2ERJX.js +25 -0
  275. package/dist/{graph-auto-extract-NKTYPD2I.js → graph-auto-extract-CLVTSUSB.js} +8 -7
  276. package/dist/{graph-rag-EOGPZOYI.js → graph-rag-LSJLWGXV.js} +4 -3
  277. package/dist/{hook-integrity-RTBF2BL2.js → hook-integrity-SGTKBL6W.js} +1 -1
  278. package/dist/{hook-prefetch-V5KCGW2N.js → hook-prefetch-BDSLB6F4.js} +26 -24
  279. package/dist/hooks/bug-report-worker.js +30 -28
  280. package/dist/hooks/codex-stop-task-finalizer.js +32 -30
  281. package/dist/hooks/commit-complete.js +29 -27
  282. package/dist/hooks/error-recall.js +11 -10
  283. package/dist/hooks/exe-heartbeat-hook.js +7 -6
  284. package/dist/hooks/ingest-worker.js +10 -9
  285. package/dist/hooks/ingest.js +18 -16
  286. package/dist/hooks/instructions-loaded.js +12 -8
  287. package/dist/hooks/manifest.json +20 -20
  288. package/dist/hooks/notification.js +8 -7
  289. package/dist/hooks/post-compact.js +7 -6
  290. package/dist/hooks/post-tool-combined.js +33 -14
  291. package/dist/hooks/pre-compact.js +31 -28
  292. package/dist/hooks/pre-tool-use.js +61 -34
  293. package/dist/hooks/prompt-submit.js +45 -42
  294. package/dist/hooks/session-end.js +40 -35
  295. package/dist/hooks/session-start.js +29 -71
  296. package/dist/hooks/stop.js +42 -36
  297. package/dist/hooks/subagent-stop.js +49 -33
  298. package/dist/hooks/summary-worker.js +35 -33
  299. package/dist/index.js +40 -38
  300. package/dist/{installer-G67M3DME.js → installer-EA7T3PBD.js} +7 -7
  301. package/dist/{installer-L3ZKMOPU.js → installer-KCEM4RCG.js} +7 -7
  302. package/dist/{installer-QBWZSYDG.js → installer-RC2JCKSE.js} +9 -7
  303. package/dist/{intercom-queue-R5LSXD3V.js → intercom-queue-6DZPHHQ2.js} +25 -23
  304. package/dist/{key-backup-status-3RC6XTUX.js → key-backup-status-6L2ARCXW.js} +1 -1
  305. package/dist/lib/agent-config.js +2 -2
  306. package/dist/lib/cloud-sync.js +25 -19
  307. package/dist/lib/config.js +1 -1
  308. package/dist/lib/consolidation.js +9 -9
  309. package/dist/lib/crypto.js +3 -1
  310. package/dist/lib/database.js +18 -4
  311. package/dist/lib/db-backup.js +4 -2
  312. package/dist/lib/db-daemon-client.js +5 -4
  313. package/dist/lib/db-write-worker.js +3 -3
  314. package/dist/lib/db.js +18 -4
  315. package/dist/lib/device-registry.js +2 -2
  316. package/dist/lib/embed-worker.js +1 -1
  317. package/dist/lib/embedder.js +5 -4
  318. package/dist/lib/employee-templates.js +7 -7
  319. package/dist/lib/employees.js +4 -4
  320. package/dist/lib/exe-daemon-client.js +4 -3
  321. package/dist/lib/exe-daemon.js +473 -206
  322. package/dist/lib/hybrid-search.js +8 -8
  323. package/dist/lib/identity-templates.js +1 -1
  324. package/dist/lib/identity.js +4 -4
  325. package/dist/lib/license.js +6 -4
  326. package/dist/lib/messaging.js +26 -24
  327. package/dist/lib/post-tool-memory.js +2 -2
  328. package/dist/lib/registry-proxy.js +3 -1
  329. package/dist/lib/reminders.js +5 -5
  330. package/dist/lib/schedules.js +8 -8
  331. package/dist/lib/session-registry.js +6 -6
  332. package/dist/lib/skill-learning.js +14 -12
  333. package/dist/lib/stack-invariants.js +21 -0
  334. package/dist/lib/status-brief.js +3 -3
  335. package/dist/lib/store.js +7 -7
  336. package/dist/lib/task-router.js +5 -5
  337. package/dist/lib/tasks.js +27 -25
  338. package/dist/lib/tmux-routing.js +25 -23
  339. package/dist/lib/token-spend.js +5 -5
  340. package/dist/{license-gate-6R3F3NQR.js → license-gate-HMSMUIAU.js} +5 -4
  341. package/dist/{license-sync-VBJCXBAP.js → license-sync-FBCMPC4J.js} +4 -3
  342. package/dist/{mailbox-inbox-CP2VRBXZ.js → mailbox-inbox-4MEUOL3J.js} +2 -2
  343. package/dist/{mailbox-outbox-HXI7DYNC.js → mailbox-outbox-J6WIF3UY.js} +1 -1
  344. package/dist/mcp/register-tools.js +114 -102
  345. package/dist/mcp/server.js +120 -108
  346. package/dist/mcp/tools/complete-reminder.js +6 -6
  347. package/dist/mcp/tools/create-reminder.js +6 -6
  348. package/dist/mcp/tools/create-task.js +30 -27
  349. package/dist/mcp/tools/deactivate-behavior.js +15 -13
  350. package/dist/mcp/tools/list-reminders.js +6 -6
  351. package/dist/mcp/tools/list-tasks.js +30 -27
  352. package/dist/mcp/tools/send-message.js +29 -26
  353. package/dist/mcp/tools/update-task.js +28 -26
  354. package/dist/{mcp-http-config-BWX7AMAZ.js → mcp-http-config-YKJN52HG.js} +5 -5
  355. package/dist/{mcp-session-identity-GOBGICLI.js → mcp-session-identity-QLUVYWPR.js} +25 -23
  356. package/dist/{memory-cards-4EXX3BQS.js → memory-cards-K2OSX4AW.js} +7 -7
  357. package/dist/{memory-graph-extractor-OYVZIJ3R.js → memory-graph-extractor-YLTSKLSY.js} +9 -8
  358. package/dist/{memory-poisoning-defense-AHOD2EBX.js → memory-poisoning-defense-IPO4ADRL.js} +4 -4
  359. package/dist/{memory-pressure-watchdog-COJC3OYS.js → memory-pressure-watchdog-ZI3TH2OF.js} +26 -24
  360. package/dist/{memory-queue-4VN3DTOE.js → memory-queue-QJNWKWKG.js} +2 -2
  361. package/dist/{memory-queue-client-OI4LDT4W.js → memory-queue-client-HIHCA3W4.js} +6 -5
  362. package/dist/{memory-reflection-V2SNAUIB.js → memory-reflection-ZKVRU3NT.js} +4 -4
  363. package/dist/{monitor-grants-W3ISOLMC.js → monitor-grants-BW2WL4IU.js} +3 -3
  364. package/dist/{notification-ledger-J6Q2GAYU.js → notification-ledger-4REL6M3T.js} +27 -25
  365. package/dist/{notifications-56TP36IK.js → notifications-UXJUAP3C.js} +25 -23
  366. package/dist/{orchestration-events-CKQ756NA.js → orchestration-events-GMRGGBMN.js} +5 -5
  367. package/dist/{orchestration-phase-ZJ4XVNFO.js → orchestration-phase-UDS24CVQ.js} +2 -2
  368. package/dist/{orchestrator-ERSQ3KNT.js → orchestrator-5TV75HDJ.js} +27 -25
  369. package/dist/{org-brief-session-FSZ3QJDN.js → org-brief-session-7AZZEO3F.js} +13 -13
  370. package/dist/{org-consent-policy-BN7MKCZ2.js → org-consent-policy-XT6UZENB.js} +2 -2
  371. package/dist/{org-join-HTQ57JYH.js → org-join-BMBQDMVF.js} +10 -7
  372. package/dist/org-key-admin-SCCVVE2H.js +38 -0
  373. package/dist/{org-key-pin-OTOKAELD.js → org-key-pin-5WUSPGVN.js} +3 -3
  374. package/dist/{org-membership-SML6GCHP.js → org-membership-ESALTLLN.js} +4 -4
  375. package/dist/{org-partner-config-XQGOB7EJ.js → org-partner-config-YKHPDPZR.js} +6 -6
  376. package/dist/{org-partner-runtime-RNNUL5IN.js → org-partner-runtime-WLZAZJIY.js} +14 -14
  377. package/dist/{org-row-visibility-JZFJ3YRJ.js → org-row-visibility-A5XM4MVO.js} +1 -1
  378. package/dist/{pipeline-router-IUENNTAY.js → pipeline-router-UEVXDUHR.js} +5 -5
  379. package/dist/{plan-limits-ZUII366B.js → plan-limits-QEP32X4W.js} +8 -7
  380. package/dist/{platform-procedures-2VQGBJU7.js → platform-procedures-44NDFTB6.js} +1 -1
  381. package/dist/{postinstall-failure-A7WTAXD6.js → postinstall-failure-B2JHNFPM.js} +2 -2
  382. package/dist/{project-boot-3DFY5F35.js → project-boot-LEZSK3W7.js} +9 -1
  383. package/dist/project-name-ILJTETUE.js +14 -0
  384. package/dist/{projection-worker-MBWUPB5O.js → projection-worker-GMRC6SBH.js} +4 -4
  385. package/dist/{prospective-memory-GHE5ORN4.js → prospective-memory-QLHSAPSG.js} +4 -4
  386. package/dist/{push-notifications-PTQ5DHCD.js → push-notifications-GKRPXOGI.js} +26 -24
  387. package/dist/reproject-worktree-memories-IXYGHTGA.js +224 -0
  388. package/dist/{reranker-NUIGAPA3.js → reranker-GB4VEMUV.js} +2 -2
  389. package/dist/{retrieval-health-XHCERQPG.js → retrieval-health-QIBPBGN6.js} +5 -1
  390. package/dist/{review-polling-CYBCBHZA.js → review-polling-MU47NQ2N.js} +26 -24
  391. package/dist/runtime/index.js +37 -35
  392. package/dist/seat-benefit-VDQJYJOB.js +17 -0
  393. package/dist/{session-events-X33W4JNA.js → session-events-YMQ3VGBJ.js} +26 -24
  394. package/dist/{session-kill-telemetry-I2F5PUIW.js → session-kill-telemetry-VGPKE57M.js} +26 -24
  395. package/dist/{session-mcp-config-YKNXG5DW.js → session-mcp-config-F7KATWOF.js} +10 -1
  396. package/dist/{session-scope-WXP4F7OF.js → session-scope-P46KAHXQ.js} +26 -24
  397. package/dist/{setup-wizard-2CTVITIX.js → setup-wizard-BRNHSJ4U.js} +4 -3
  398. package/dist/{shard-manager-YEOHEOHL.js → shard-manager-UROHZE46.js} +2 -2
  399. package/dist/{skill-refinement-VDR5OT4V.js → skill-refinement-NLYDSFEH.js} +5 -5
  400. package/dist/{stack-promote-XVC7FRJW.js → stack-promote-NHFTNIM2.js} +7 -5
  401. package/dist/{stack-release-6PWAACRM.js → stack-release-AQVKZUS7.js} +7 -5
  402. package/dist/{stack-update-24VRBQ3U.js → stack-update-LLX5KT7G.js} +38 -6
  403. package/dist/{steward-gate-2ZNYDVFO.js → steward-gate-JKHYFAHA.js} +5 -5
  404. package/dist/subagent-brief-injection-VDVOHDOU.js +97 -0
  405. package/dist/subagent-spawn-ledger-USYZXU3M.js +22 -0
  406. package/dist/{support-inbox-ZHKLDETT.js → support-inbox-S6YO5YZU.js} +5 -4
  407. package/dist/{support-outbox-DSWU3IXH.js → support-outbox-HFJWG52M.js} +1 -1
  408. package/dist/{task-enforcement-GQDUTIFY.js → task-enforcement-LXW45H5Z.js} +26 -24
  409. package/dist/{task-request-inbox-BFXNUU44.js → task-request-inbox-UCSKDC3R.js} +2 -2
  410. package/dist/{task-scope-ERHPHLUM.js → task-scope-GDLFE26E.js} +25 -23
  411. package/dist/{tasks-crud-NVNF3NRA.js → tasks-crud-W7VGWRUV.js} +25 -23
  412. package/dist/{tasks-notify-DXLU5VCT.js → tasks-notify-CT7NWCS4.js} +26 -24
  413. package/dist/{tasks-review-BST6N34P.js → tasks-review-WCSKOUFW.js} +25 -23
  414. package/dist/{telemetry-upload-NY3EKOGY.js → telemetry-upload-FK5WKXVB.js} +10 -9
  415. package/dist/{token-budget-CLB3GUIX.js → token-budget-GBNGSIU3.js} +5 -5
  416. package/dist/{tool-capability-index-WZWVBI2R.js → tool-capability-index-BT2GGLLI.js} +1 -1
  417. package/dist/{tool-telemetry-PALAZUXT.js → tool-telemetry-VKMRS6MP.js} +1 -1
  418. package/dist/tui/App.js +39 -37
  419. package/dist/{tui-data-CNFSRZP7.js → tui-data-FTPV2XBQ.js} +25 -23
  420. package/dist/{update-support-ZVB3CNGY.js → update-support-J6UWPUOC.js} +18 -15
  421. package/dist/{work-state-heartbeat-O7UMB6SE.js → work-state-heartbeat-4LDF6DSM.js} +1 -1
  422. package/dist/{worker-gate-6DQQWDNB.js → worker-gate-35VZINZG.js} +2 -2
  423. package/dist/{workflow-engine-5ZULFH7O.js → workflow-engine-4DA6RSHI.js} +2 -2
  424. package/dist/working-memory-DPFRSKH3.js +18 -0
  425. package/dist/{worktree-ZWA35PKW.js → worktree-H3YFJ3NU.js} +6 -6
  426. package/dist/{worktree-sweep-5LCVT46V.js → worktree-sweep-4EDLLQ2E.js} +9 -7
  427. package/package.json +11 -5
  428. package/release-notes.json +86 -34
  429. package/src/commands/exe/call.md +6 -4
  430. package/src/commands/exe-reference.md +11 -7
  431. package/src/commands/exe.md +16 -20
  432. package/dist/chunk-HISFWAAK.js +0 -90
  433. package/dist/daemon-auth-OCHW2U6B.js +0 -20
  434. package/dist/project-name-EWG5KAZP.js +0 -10
  435. package/dist/session-summary-5EYI4XW4.js +0 -128
  436. /package/dist/{chunk-YAZ5ECEG.js → chunk-3NBWARKC.js} +0 -0
  437. /package/dist/{chunk-6C4UAKMS.js → chunk-6CAX7YH4.js} +0 -0
  438. /package/dist/{chunk-FIPUVCKC.js → chunk-7DMCAGSC.js} +0 -0
  439. /package/dist/{chunk-X7LY3IOB.js → chunk-JRPYLUXH.js} +0 -0
  440. /package/dist/{chunk-L4LPJMPV.js → chunk-QYECRPGD.js} +0 -0
  441. /package/dist/{chunk-UELGUVNL.js → chunk-UY6HRDB2.js} +0 -0
  442. /package/dist/{chunk-YWN3XMPU.js → chunk-YSDIJ3VI.js} +0 -0
  443. /package/dist/{core-memory-BZFPVS43.js → core-memory-CMPPHJN5.js} +0 -0
  444. /package/dist/{entity-boost-VXXED26D.js → entity-boost-CDFAXVYL.js} +0 -0
  445. /package/dist/{memory-isolation-3PIOWLYP.js → memory-isolation-ZB5S5HCO.js} +0 -0
  446. /package/dist/{message-queue-client-5XW7ZOK2.js → message-queue-client-PL2POQOV.js} +0 -0
  447. /package/dist/{oauth-server-KW5M437C.js → oauth-server-NP7KGF7N.js} +0 -0
  448. /package/dist/{webhook-pipe-QJRFZVKA.js → webhook-pipe-UQSEHFPO.js} +0 -0
  449. /package/dist/{wiki-acl-RXFV5OEU.js → wiki-acl-5DKOWOIH.js} +0 -0
  450. /package/dist/{wiki-client-57QWZIHQ.js → wiki-client-AXNM5FWY.js} +0 -0
@@ -8,7 +8,7 @@ import {
8
8
  } from "../chunk-NOKJCF27.js";
9
9
  import {
10
10
  pushNotifyAsync
11
- } from "../chunk-Q2VQNAPU.js";
11
+ } from "../chunk-EVPBYX2Z.js";
12
12
  import {
13
13
  isDbVerifyStampFresh
14
14
  } from "../chunk-SVFNWBLF.js";
@@ -23,15 +23,15 @@ import {
23
23
  import {
24
24
  shouldScheduleDaemonRestartHandoff
25
25
  } from "../chunk-PWRC5XZO.js";
26
- import {
27
- readCloudSyncState,
28
- writeCloudSyncState
29
- } from "../chunk-FUQ2OSDV.js";
30
26
  import {
31
27
  getMcpToolFamily,
32
28
  inferMcpRuntime,
33
29
  recordMcpHttpEvent
34
- } from "../chunk-RFKRCVGW.js";
30
+ } from "../chunk-YYA5LXCT.js";
31
+ import {
32
+ readCloudSyncState,
33
+ writeCloudSyncState
34
+ } from "../chunk-L2VZBPJJ.js";
35
35
  import {
36
36
  deserializeArgs,
37
37
  serializeResultSet
@@ -43,52 +43,61 @@ import {
43
43
  findScopedDuplicate,
44
44
  governMemoryRecord,
45
45
  schedulePostWriteMemoryHygiene
46
- } from "../chunk-FIPUVCKC.js";
46
+ } from "../chunk-7DMCAGSC.js";
47
47
  import "../chunk-5MOYSU5A.js";
48
48
  import "../chunk-4QCFFW2H.js";
49
49
  import "../chunk-76CJBM36.js";
50
50
  import {
51
51
  BUSY_PATTERN
52
- } from "../chunk-SQM4ZTL2.js";
53
- import "../chunk-5C6ZIJ7J.js";
54
- import "../chunk-SXKIGBNF.js";
55
- import "../chunk-BT2PUK3S.js";
52
+ } from "../chunk-ORNCMRIX.js";
53
+ import "../chunk-ESTR7QUP.js";
54
+ import "../chunk-FXPAUDCZ.js";
55
+ import "../chunk-QFIVK3G5.js";
56
+ import "../chunk-WT4RI36X.js";
57
+ import "../chunk-C3UAQ3JG.js";
56
58
  import {
57
59
  recordTimerPauseMs,
58
60
  runWithTimerPauseAccounting,
59
61
  sweepPauseTotalMs
60
62
  } from "../chunk-KI5PFRG6.js";
61
- import "../chunk-WT4RI36X.js";
62
- import "../chunk-Z67DIJKT.js";
63
+ import "../chunk-EIKATSE4.js";
63
64
  import "../chunk-E23LNUWJ.js";
64
65
  import "../chunk-QAEWWYHL.js";
65
- import "../chunk-EIKATSE4.js";
66
- import "../chunk-D5CY4E7I.js";
66
+ import "../chunk-EHHMNKOA.js";
67
+ import "../chunk-GBNB4EWD.js";
67
68
  import "../chunk-UXLO7VHX.js";
68
69
  import "../chunk-DSOQUQTV.js";
69
- import "../chunk-GBNB4EWD.js";
70
- import "../chunk-PV5BIXT6.js";
70
+ import "../chunk-WR75WUEP.js";
71
71
  import "../chunk-AJIXH5JF.js";
72
- import "../chunk-KDMVVHZH.js";
72
+ import "../chunk-XTWHNLGD.js";
73
73
  import "../chunk-AM7S2TY6.js";
74
- import "../chunk-CY5NVDTH.js";
74
+ import "../chunk-2FYIMTQE.js";
75
75
  import "../chunk-CVYC6DUW.js";
76
- import "../chunk-4P2BFNSB.js";
77
- import "../chunk-MZYNW5OY.js";
78
- import "../chunk-OPU3NYOO.js";
76
+ import "../chunk-ZVTKWWLV.js";
77
+ import "../chunk-CDUB5Q6J.js";
79
78
  import {
80
79
  attributeSignalSource,
81
80
  consumeRestartIntentDetail,
82
81
  isRestartCooldownActive,
83
82
  logRestartEvent,
84
83
  noteRestartAttempt
85
- } from "../chunk-6EM6USV7.js";
84
+ } from "../chunk-BNHAZ65R.js";
86
85
  import {
86
+ AGENT_IDENTITY_TOKEN_HEADER,
87
87
  assessInitialBindIdentity,
88
88
  ensureDaemonToken,
89
+ getDaemonAgentIdentityBroker,
90
+ readAgentIdentityTokenHeader,
89
91
  reconcileSessionAgentIdentity,
92
+ shouldEnforceAgentIdentity,
90
93
  shouldEnforceSessionIdentity
91
- } from "../chunk-HISFWAAK.js";
94
+ } from "../chunk-RIECV7SR.js";
95
+ import {
96
+ killAttributionLogPath,
97
+ killIfSameProcess,
98
+ processStartedAt,
99
+ recordKillIntent
100
+ } from "../chunk-LNOS24GV.js";
92
101
  import {
93
102
  DAEMON_RSS_RESTART_DEBOUNCE,
94
103
  DAEMON_RSS_STARTUP_GRACE_MS,
@@ -105,10 +114,11 @@ import {
105
114
  resolveEmbedWorkerRssKillMb,
106
115
  shouldRestartForRss
107
116
  } from "../chunk-NLEW62VC.js";
117
+ import "../chunk-W2IRQJ6R.js";
108
118
  import "../chunk-HYZV25LY.js";
109
119
  import "../chunk-GJV3WDWM.js";
110
120
  import "../chunk-MP2AFCGL.js";
111
- import "../chunk-HLU52KTO.js";
121
+ import "../chunk-BRLS5OLZ.js";
112
122
  import "../chunk-TKDITWDN.js";
113
123
  import {
114
124
  logBoot,
@@ -118,11 +128,11 @@ import {
118
128
  logShutdown
119
129
  } from "../chunk-BBMTVAE3.js";
120
130
  import "../chunk-5YEUPUV4.js";
121
- import "../chunk-Q7J2SQJ6.js";
131
+ import "../chunk-NO3M2AFM.js";
122
132
  import {
123
133
  isPostgresBackendEnabled
124
134
  } from "../chunk-YYB5PMTK.js";
125
- import "../chunk-BRZR76TS.js";
135
+ import "../chunk-NJFJWQNN.js";
126
136
  import {
127
137
  getEventLoopLagMs,
128
138
  isEventLoopDegraded,
@@ -139,8 +149,9 @@ import {
139
149
  EMBEDDING_DIM
140
150
  } from "../chunk-FXU7JOXK.js";
141
151
  import "../chunk-WNBZJSQT.js";
142
- import "../chunk-HSKABJE6.js";
143
- import "../chunk-3ICF4IAZ.js";
152
+ import "../chunk-ZDUO6QBH.js";
153
+ import "../chunk-A7XLR3K7.js";
154
+ import "../chunk-VS4LPG66.js";
144
155
  import "../chunk-QILQ5FCG.js";
145
156
  import "../chunk-ARX6TAGN.js";
146
157
  import {
@@ -148,13 +159,13 @@ import {
148
159
  MODELS_DIR,
149
160
  loadConfigSync,
150
161
  resolveEmbedModelFile
151
- } from "../chunk-BRIZ6OZ3.js";
162
+ } from "../chunk-QMSEL5YS.js";
152
163
  import "../chunk-HSGBZSCA.js";
153
164
  import "../chunk-JKKZGDLP.js";
154
165
  import "../chunk-MLKGABMK.js";
155
166
 
156
167
  // src/lib/exe-daemon.ts
157
- import os3 from "os";
168
+ import os4 from "os";
158
169
  import net from "net";
159
170
  import v8 from "v8";
160
171
  import { createServer as createHttpServer, request as httpRequest } from "http";
@@ -691,6 +702,39 @@ function launchCloudSyncDaemonAttempt(options) {
691
702
  return true;
692
703
  }
693
704
 
705
+ // src/lib/daemon-socket-response.ts
706
+ var DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ENV = "EXE_DAEMON_SOCKET_RESPONSE_BUFFER_CAP_BYTES";
707
+ var DEFAULT_DAEMON_SOCKET_RESPONSE_BUFFER_CAP_BYTES = 96 * 1024 * 1024;
708
+ var DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ERROR = "EXE_DAEMON_SOCKET_RESPONSE_BUFFER_CAP_EXCEEDED";
709
+ function daemonSocketResponseBufferCapBytes(env = process.env) {
710
+ const raw = env[DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ENV];
711
+ const parsed = raw === void 0 || raw.trim() === "" ? NaN : Number(raw);
712
+ return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : DEFAULT_DAEMON_SOCKET_RESPONSE_BUFFER_CAP_BYTES;
713
+ }
714
+ function writeDaemonSocketResponse(socket, data) {
715
+ if (socket.destroyed) return false;
716
+ try {
717
+ const wrote = socket.write(JSON.stringify(data) + "\n");
718
+ const capBytes = daemonSocketResponseBufferCapBytes();
719
+ const bufferedBytes = socket.writableLength;
720
+ if (Number.isFinite(bufferedBytes) && bufferedBytes > capBytes) {
721
+ const error = new Error(
722
+ `${DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ERROR}: daemon client socket buffered ${bufferedBytes} bytes, exceeding cap ${capBytes} bytes while sending response id=${data.id}`
723
+ );
724
+ error.name = DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ERROR;
725
+ process.stderr.write(
726
+ `[exed] ERROR ${DAEMON_SOCKET_RESPONSE_BUFFER_CAP_ERROR}: slow/stuck client socket buffered ${bufferedBytes} bytes > cap ${capBytes} bytes after response id=${data.id}; destroying that client. Normal socket.write backpressure below this cap remains buffered.
727
+ `
728
+ );
729
+ socket.destroy(error);
730
+ return false;
731
+ }
732
+ return wrote;
733
+ } catch {
734
+ return false;
735
+ }
736
+ }
737
+
694
738
  // src/lib/mcp-init-grace.ts
695
739
  var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
696
740
  async function awaitPendingMcpInit(ownerKey, requestSessionId, deps, transientMatch) {
@@ -745,6 +789,40 @@ async function awaitPendingMcpInit(ownerKey, requestSessionId, deps, transientMa
745
789
  return null;
746
790
  }
747
791
 
792
+ // src/lib/daemon-port-claim.ts
793
+ var LIVE_DAEMON_HEALTH_STATUSES = ["ok", "degraded", "blocked"];
794
+ function isLiveDaemonHealthResponse(statusCode, body) {
795
+ if (statusCode !== 200) return false;
796
+ let parsed;
797
+ try {
798
+ parsed = JSON.parse(body);
799
+ } catch {
800
+ return false;
801
+ }
802
+ const status = parsed.status;
803
+ if (typeof status !== "string") return false;
804
+ return LIVE_DAEMON_HEALTH_STATUSES.includes(status);
805
+ }
806
+ var PORT_RELEASE_POLL_MS = 250;
807
+ var PORT_RELEASE_TIMEOUT_MS = 3e4;
808
+ async function waitForPortRelease(hasListener, opts) {
809
+ const now = opts.now ?? Date.now;
810
+ const pollMs = opts.pollMs ?? PORT_RELEASE_POLL_MS;
811
+ const timeoutMs = opts.timeoutMs ?? PORT_RELEASE_TIMEOUT_MS;
812
+ const deadline = now() + timeoutMs;
813
+ for (; ; ) {
814
+ let held;
815
+ try {
816
+ held = await hasListener();
817
+ } catch {
818
+ return "released";
819
+ }
820
+ if (!held) return "released";
821
+ if (now() >= deadline) return "timeout";
822
+ await opts.sleep(pollMs);
823
+ }
824
+ }
825
+
748
826
  // src/lib/daemon-coverage-gap.ts
749
827
  import { closeSync, existsSync as existsSync3, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync2, readSync, statSync as statSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
750
828
  import { homedir } from "os";
@@ -1186,6 +1264,19 @@ function computeBootRetryAfterSeconds(nowMs, readyEtaMs, opts = {}) {
1186
1264
  return Math.min(maxS, Math.max(minS, Math.ceil((readyEtaMs - nowMs) / 1e3)));
1187
1265
  }
1188
1266
 
1267
+ // src/lib/daemon-sweep-gate.ts
1268
+ import os3 from "os";
1269
+ function readHostLoadSignal(env = process.env) {
1270
+ return {
1271
+ load1m: os3.loadavg()[0] ?? 0,
1272
+ cpuCount: os3.cpus().length || 1,
1273
+ starvationRatio: parseFloat(env.EXE_STARVATION_LOAD_RATIO ?? "1.5")
1274
+ };
1275
+ }
1276
+ function decideSweepSkip(signal) {
1277
+ return decideOrchestrationTickSkip(signal);
1278
+ }
1279
+
1189
1280
  // src/lib/bootstrap-response.ts
1190
1281
  import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
1191
1282
  import { homedir as homedir2 } from "os";
@@ -1316,7 +1407,7 @@ function stabilizeDaemonCwd() {
1316
1407
  } catch (err) {
1317
1408
  const moduleDir = path4.dirname(fileURLToPath(import.meta.url));
1318
1409
  const packageRoot = path4.resolve(moduleDir, "../..");
1319
- const fallback = existsSync7(path4.join(packageRoot, "package.json")) ? packageRoot : os3.homedir();
1410
+ const fallback = existsSync7(path4.join(packageRoot, "package.json")) ? packageRoot : os4.homedir();
1320
1411
  try {
1321
1412
  process.chdir(fallback);
1322
1413
  process.stderr.write(
@@ -1469,6 +1560,37 @@ async function getSharedOrchestrationCaches() {
1469
1560
  }
1470
1561
  return refreshSharedOrchestrationCaches();
1471
1562
  }
1563
+ var MAINTENANCE_SWEEP_BUDGET_MS = Number(process.env.EXE_MAINTENANCE_SWEEP_BUDGET_MS) || 2e3;
1564
+ var _sweepSkipLogTs = /* @__PURE__ */ new Map();
1565
+ var SWEEP_SKIP_LOG_THROTTLE_MS = 5 * 60 * 1e3;
1566
+ function sweepStarved(name) {
1567
+ const signal = readHostLoadSignal();
1568
+ if (!decideSweepSkip(signal).skip) return false;
1569
+ const now = Date.now();
1570
+ if (now - (_sweepSkipLogTs.get(name) ?? 0) > SWEEP_SKIP_LOG_THROTTLE_MS) {
1571
+ _sweepSkipLogTs.set(name, now);
1572
+ process.stderr.write(
1573
+ `[exed] Sweep ${name} SKIPPED: load=${signal.load1m.toFixed(2)} cpus=${signal.cpuCount} \u2014 CPU starved, deferring to avoid feeding the event-loop-block spiral.
1574
+ `
1575
+ );
1576
+ logDaemonHealth({
1577
+ event: "process_stats",
1578
+ pid: process.pid,
1579
+ message: `${name} skipped \u2014 CPU starved (load=${signal.load1m.toFixed(2)} / cpus=${signal.cpuCount})`,
1580
+ data: {
1581
+ type: "sweep_skipped_starvation",
1582
+ timer: name,
1583
+ load1m: signal.load1m,
1584
+ cpuCount: signal.cpuCount,
1585
+ loadPerCore: signal.load1m / signal.cpuCount
1586
+ }
1587
+ });
1588
+ }
1589
+ return true;
1590
+ }
1591
+ function maintenanceSweepOptions(label) {
1592
+ return { label, budgetMs: MAINTENANCE_SWEEP_BUDGET_MS };
1593
+ }
1472
1594
  var _orchestrationSteps = {
1473
1595
  reviewPolling: null,
1474
1596
  taskEnforcement: null,
@@ -1482,16 +1604,16 @@ var TICK_SKIP_LOG_THROTTLE_MS = 5 * 60 * 1e3;
1482
1604
  async function runOrchestrationTick() {
1483
1605
  if (_orchestrationBusy) return;
1484
1606
  const tickSkip = decideOrchestrationTickSkip({
1485
- load1m: os3.loadavg()[0] ?? 0,
1486
- cpuCount: os3.cpus().length || 1,
1607
+ load1m: os4.loadavg()[0] ?? 0,
1608
+ cpuCount: os4.cpus().length || 1,
1487
1609
  starvationRatio: parseFloat(process.env.EXE_STARVATION_LOAD_RATIO ?? "1.5")
1488
1610
  });
1489
1611
  if (tickSkip.skip) {
1490
1612
  const now = Date.now();
1491
1613
  if (now - _lastTickSkipLogTs > TICK_SKIP_LOG_THROTTLE_MS) {
1492
1614
  _lastTickSkipLogTs = now;
1493
- const load1m = os3.loadavg()[0] ?? 0;
1494
- const cpuCount = os3.cpus().length || 1;
1615
+ const load1m = os4.loadavg()[0] ?? 0;
1616
+ const cpuCount = os4.cpus().length || 1;
1495
1617
  process.stderr.write(
1496
1618
  `[exed] Orchestration tick SKIPPED: load=${load1m.toFixed(2)} cpus=${cpuCount} \u2014 CPU starved, deferring per-session pass to avoid feeding the event-loop-block spiral.
1497
1619
  `
@@ -1783,7 +1905,7 @@ function scheduleRestartHandoff(exitCode, reason) {
1783
1905
  const daemonPath = fileURLToPath(import.meta.url);
1784
1906
  const logPath = path4.join(EXE_AI_DIR, "logs", "exed.log");
1785
1907
  const lockPath = path4.join(EXE_AI_DIR, "exed-spawn.lock");
1786
- const heapCapMb = computeDaemonHeapCapMb(os3.totalmem() / (1024 * 1024 * 1024));
1908
+ const heapCapMb = computeDaemonHeapCapMb(os4.totalmem() / (1024 * 1024 * 1024));
1787
1909
  const config = {
1788
1910
  oldPid: process.pid,
1789
1911
  daemonPath,
@@ -1980,6 +2102,13 @@ async function traceDaemonTimer(name, fn) {
1980
2102
  type: "timer_duration",
1981
2103
  timer: name,
1982
2104
  durationMs,
2105
+ // Bug 28e1e0a1: budgeted sweeps deliberately PAUSE with the event loop
2106
+ // free. durationMs is wall time and includes those pauses; busyMs is
2107
+ // the time the loop was actually held. The slow-timer leaderboard
2108
+ // prefers busyMs so a well-behaved paused sweep is not mis-ranked as
2109
+ // a blocker.
2110
+ busyMs,
2111
+ sweepPausedMs,
1983
2112
  wallMs: Math.round(span.wallMs),
1984
2113
  sleptMs: Math.round(span.sleptMs),
1985
2114
  clockJump: slept,
@@ -2004,9 +2133,9 @@ function enqueue(queue, entry) {
2004
2133
  }
2005
2134
  queue.push(entry);
2006
2135
  }
2007
- var OOM_MARKER_PATH = path4.join(os3.homedir(), ".exe-os", "embedding-oom-marker");
2008
- var EMBED_TIMEOUT_MARKER_PATH = path4.join(os3.homedir(), ".exe-os", "embedding-timeout-marker");
2009
- var EMBEDDINGS_OPT_IN_PATH = path4.join(os3.homedir(), ".exe-os", "embeddings-enabled");
2136
+ var OOM_MARKER_PATH = path4.join(os4.homedir(), ".exe-os", "embedding-oom-marker");
2137
+ var EMBED_TIMEOUT_MARKER_PATH = path4.join(os4.homedir(), ".exe-os", "embedding-timeout-marker");
2138
+ var EMBEDDINGS_OPT_IN_PATH = path4.join(os4.homedir(), ".exe-os", "embeddings-enabled");
2010
2139
  var MIN_FREE_MEM_BYTES = 2 * 1024 ** 3;
2011
2140
  var EMBED_WORKER_HEAP_MB = resolveEmbedWorkerHeapMb(process.env.EXE_EMBED_WORKER_HEAP_MB);
2012
2141
  var EMBED_WORKER_RSS_KILL_MB = resolveEmbedWorkerRssKillMb(
@@ -2024,10 +2153,10 @@ function resolveEmbeddingsOptIn() {
2024
2153
  var MAX_SMALL_TOTAL_BYTES = 16 * 1024 ** 3;
2025
2154
  var OOM_MARKER_TTL_MS = 1 * 60 * 60 * 1e3;
2026
2155
  var EMBED_RESPAWN_RESET_UPTIME_MS = 60 * 60 * 1e3;
2027
- var CRASH_LOOP_COUNTER_PATH = path4.join(os3.homedir(), ".exe-os", "daemon-crash-counter.json");
2156
+ var CRASH_LOOP_COUNTER_PATH = path4.join(os4.homedir(), ".exe-os", "daemon-crash-counter.json");
2028
2157
  var CRASH_LOOP_THRESHOLD = 3;
2029
2158
  var CRASH_LOOP_WINDOW_MS = 10 * 60 * 1e3;
2030
- var CRASH_LOOP_BREAKER_PATH = path4.join(os3.homedir(), ".exe-os", "crash-loop-breaker");
2159
+ var CRASH_LOOP_BREAKER_PATH = path4.join(os4.homedir(), ".exe-os", "crash-loop-breaker");
2031
2160
  var CRASH_LOOP_BREAKER_TTL_MS = 30 * 60 * 1e3;
2032
2161
  function recordDaemonCrash() {
2033
2162
  const now = Date.now();
@@ -2133,7 +2262,7 @@ function touchEventLoopHeartbeat() {
2133
2262
  function checkLaunchdPlistHealth() {
2134
2263
  try {
2135
2264
  if (process.platform !== "darwin") return;
2136
- const plistPath = path4.join(os3.homedir(), "Library", "LaunchAgents", "com.askexe.exed.plist");
2265
+ const plistPath = path4.join(os4.homedir(), "Library", "LaunchAgents", "com.askexe.exed.plist");
2137
2266
  if (!existsSync7(plistPath)) return;
2138
2267
  const plist = readFileSync6(plistPath, "utf8");
2139
2268
  const expectedHeap = computeDaemonHeapCapMb();
@@ -2241,14 +2370,14 @@ async function loadModel() {
2241
2370
  _embeddingsDisabledByDesign = true;
2242
2371
  return;
2243
2372
  }
2244
- const totalMem = os3.totalmem();
2373
+ const totalMem = os4.totalmem();
2245
2374
  if (totalMem <= MAX_SMALL_TOTAL_BYTES) {
2246
2375
  process.stderr.write(`[exed] Skipping embeddings \u2014 total RAM ${(totalMem / 1024 ** 3).toFixed(1)} GB <= 16 GB (FTS+Graph only).
2247
2376
  `);
2248
2377
  _embeddingsDisabledByDesign = true;
2249
2378
  return;
2250
2379
  }
2251
- if (os3.freemem() < MIN_FREE_MEM_BYTES) {
2380
+ if (os4.freemem() < MIN_FREE_MEM_BYTES) {
2252
2381
  process.stderr.write(`[exed] Skipping embeddings \u2014 free RAM < 2 GB.
2253
2382
  `);
2254
2383
  _embeddingsDisabledByDesign = true;
@@ -2259,8 +2388,8 @@ async function loadModel() {
2259
2388
  if (isCpuStarved()) {
2260
2389
  if (_embedLoadDeferrals < embedLoadMaxDefers) {
2261
2390
  _embedLoadDeferrals++;
2262
- const load1m = (os3.loadavg()[0] ?? 0).toFixed(2);
2263
- const cpuCount = os3.cpus().length || 1;
2391
+ const load1m = (os4.loadavg()[0] ?? 0).toFixed(2);
2392
+ const cpuCount = os4.cpus().length || 1;
2264
2393
  process.stderr.write(
2265
2394
  `[exed] Deferring embed model load \u2014 host CPU-starved (load=${load1m} / ${cpuCount} cpus). Loading the Metal model now would feed the starvation spiral. Retry ${_embedLoadDeferrals}/${embedLoadMaxDefers} in ${embedLoadDeferMs / 1e3}s.
2266
2395
  `
@@ -2399,7 +2528,7 @@ async function loadModel() {
2399
2528
  void (async () => {
2400
2529
  try {
2401
2530
  if (_storeInitialized) {
2402
- const { writeNotification } = await import("../notifications-56TP36IK.js");
2531
+ const { writeNotification } = await import("../notifications-UXJUAP3C.js");
2403
2532
  await writeNotification({
2404
2533
  agentId: "exe",
2405
2534
  agentRole: "system",
@@ -2518,7 +2647,7 @@ function disableEmbeddingsForInferenceTimeouts() {
2518
2647
  void (async () => {
2519
2648
  try {
2520
2649
  if (_storeInitialized) {
2521
- const { writeNotification } = await import("../notifications-56TP36IK.js");
2650
+ const { writeNotification } = await import("../notifications-UXJUAP3C.js");
2522
2651
  await writeNotification({
2523
2652
  agentId: "exe",
2524
2653
  agentRole: "system",
@@ -2658,14 +2787,7 @@ async function processQueue() {
2658
2787
  }
2659
2788
  }
2660
2789
  function sendResponse(socket, data) {
2661
- if (socket.destroyed) return;
2662
- try {
2663
- const ok = socket.write(JSON.stringify(data) + "\n");
2664
- if (!ok) {
2665
- socket.destroy(new Error("Write backpressure \u2014 client too slow"));
2666
- }
2667
- } catch {
2668
- }
2790
+ writeDaemonSocketResponse(socket, data);
2669
2791
  }
2670
2792
  function resetIdleTimer() {
2671
2793
  if (_idleTimer) {
@@ -2692,7 +2814,7 @@ async function shutdown(exitCode = 0, reason = null, restartKind) {
2692
2814
  _shuttingDown = true;
2693
2815
  _drainingWrites = true;
2694
2816
  try {
2695
- const { stopOrgPartnerRuntime } = await import("../org-partner-runtime-RNNUL5IN.js");
2817
+ const { stopOrgPartnerRuntime } = await import("../org-partner-runtime-WLZAZJIY.js");
2696
2818
  stopOrgPartnerRuntime();
2697
2819
  } catch {
2698
2820
  }
@@ -2775,7 +2897,7 @@ async function shutdown(exitCode = 0, reason = null, restartKind) {
2775
2897
  dbBytes = dbPath ? statSync4(dbPath).size : 0;
2776
2898
  } catch {
2777
2899
  }
2778
- const { getAvailableMemoryBytesSync } = await import("../memory-pressure-watchdog-COJC3OYS.js");
2900
+ const { getAvailableMemoryBytesSync } = await import("../memory-pressure-watchdog-ZI3TH2OF.js");
2779
2901
  const freeBytes = getAvailableMemoryBytesSync();
2780
2902
  if (shouldSkipBackupUnderMemoryPressure(freeBytes, dbBytes)) {
2781
2903
  memoryGateSkip = true;
@@ -2828,12 +2950,12 @@ async function shutdown(exitCode = 0, reason = null, restartKind) {
2828
2950
  `);
2829
2951
  }
2830
2952
  try {
2831
- const { stopProjectionWorker } = await import("../projection-worker-MBWUPB5O.js");
2953
+ const { stopProjectionWorker } = await import("../projection-worker-GMRC6SBH.js");
2832
2954
  stopProjectionWorker();
2833
2955
  } catch {
2834
2956
  }
2835
2957
  try {
2836
- const { disposeShards } = await import("../shard-manager-YEOHEOHL.js");
2958
+ const { disposeShards } = await import("../shard-manager-UROHZE46.js");
2837
2959
  disposeShards();
2838
2960
  } catch {
2839
2961
  }
@@ -2891,7 +3013,7 @@ async function handleHealthCheck(socket, requestId) {
2891
3013
  let pipelineStatus = "unknown";
2892
3014
  if (dbConnected) {
2893
3015
  try {
2894
- await import("../pipeline-router-IUENNTAY.js");
3016
+ await import("../pipeline-router-UEVXDUHR.js");
2895
3017
  pipelineStatus = "ok";
2896
3018
  } catch {
2897
3019
  pipelineStatus = "unavailable";
@@ -3334,7 +3456,7 @@ async function _writeMemoryRecordInner(entry, syncOnly = false) {
3334
3456
  const vRow = await client.execute({ sql: "SELECT version FROM memories WHERE id = ?", args: [id] });
3335
3457
  const version = Number(vRow.rows[0]?.version) || 0;
3336
3458
  try {
3337
- const { insertOntologyForMemory } = await import("../agentic-ontology-RCVCJ6WB.js");
3459
+ const { insertOntologyForMemory } = await import("../agentic-ontology-CARDCG37.js");
3338
3460
  await insertOntologyForMemory({
3339
3461
  id,
3340
3462
  agent_id: record.agent_id,
@@ -3364,7 +3486,7 @@ function startMemoryQueueDrain() {
3364
3486
  fired("memory_queue_drain");
3365
3487
  if (!await ensureStoreForPolling()) return;
3366
3488
  try {
3367
- const { ackQueue, claimQueue, retryQueueEntries, processQueueEntries } = await import("../memory-queue-4VN3DTOE.js");
3489
+ const { ackQueue, claimQueue, retryQueueEntries, processQueueEntries } = await import("../memory-queue-QJNWKWKG.js");
3368
3490
  const lease = claimQueue();
3369
3491
  if (!lease || lease.entries.length === 0) return;
3370
3492
  acted("memory_queue_drain");
@@ -3451,7 +3573,7 @@ function startMessageQueueDrain() {
3451
3573
  fired("message_queue_drain");
3452
3574
  if (!await ensureStoreForPolling()) return;
3453
3575
  try {
3454
- const { claimMessageQueue, ackMessageQueue } = await import("../message-queue-client-5XW7ZOK2.js");
3576
+ const { claimMessageQueue, ackMessageQueue } = await import("../message-queue-client-PL2POQOV.js");
3455
3577
  const lease = claimMessageQueue();
3456
3578
  if (!lease || lease.entries.length === 0) return;
3457
3579
  acted("message_queue_drain");
@@ -3726,12 +3848,7 @@ async function resolveAndClaimPort() {
3726
3848
  body += chunk;
3727
3849
  });
3728
3850
  res.on("end", () => {
3729
- try {
3730
- const parsed = JSON.parse(body);
3731
- resolve(res.statusCode === 200 && parsed.status === "ok");
3732
- } catch {
3733
- resolve(false);
3734
- }
3851
+ resolve(isLiveDaemonHealthResponse(res.statusCode, body));
3735
3852
  });
3736
3853
  }
3737
3854
  );
@@ -3744,9 +3861,9 @@ async function resolveAndClaimPort() {
3744
3861
  });
3745
3862
  };
3746
3863
  try {
3747
- const isHealthy = await probeHealth() || await probeHealth();
3748
- if (isHealthy) {
3749
- process.stderr.write(`[exed] Port ${targetPort} has a healthy daemon \u2014 exiting (not a duplicate)
3864
+ const isLive = await probeHealth() || await probeHealth();
3865
+ if (isLive) {
3866
+ process.stderr.write(`[exed] Port ${targetPort} has a live daemon \u2014 exiting (not a duplicate)
3750
3867
  `);
3751
3868
  recordExitBreadcrumb("clean", 0, "port-owned-by-healthy-daemon", { restartKind: "clean_stop" });
3752
3869
  process.exit(0);
@@ -3757,7 +3874,8 @@ async function resolveAndClaimPort() {
3757
3874
  const { execFileSync } = await import("child_process");
3758
3875
  const selfPid = process.pid;
3759
3876
  const parentPid = process.ppid;
3760
- const pids = execFileSync("lsof", ["-ti", `:${targetPort}`, "-sTCP:LISTEN"], { encoding: "utf8" }).trim();
3877
+ const listeners = () => execFileSync("lsof", ["-ti", `:${targetPort}`, "-sTCP:LISTEN"], { encoding: "utf8" }).trim();
3878
+ const pids = listeners();
3761
3879
  if (pids) {
3762
3880
  for (const pid of pids.split("\n").filter(Boolean)) {
3763
3881
  const numericPid = parseInt(pid, 10);
@@ -3776,12 +3894,28 @@ async function resolveAndClaimPort() {
3776
3894
  } else if (action === "kill-stale-daemon") {
3777
3895
  process.stderr.write(`[exed] Port ${targetPort} held by stale daemon PID ${pid} \u2014 SIGTERM
3778
3896
  `);
3897
+ recordKillIntent({
3898
+ targetPid: numericPid,
3899
+ signal: "SIGTERM",
3900
+ sender: "port-claim",
3901
+ reason: `stale daemon holding MCP port ${targetPort}: ${command.slice(0, 120)}`
3902
+ });
3779
3903
  process.kill(numericPid, "SIGTERM");
3780
3904
  }
3781
3905
  } catch {
3782
3906
  }
3783
3907
  }
3784
- await new Promise((r) => setTimeout(r, 500));
3908
+ const outcome = await waitForPortRelease(() => listeners().length > 0, {
3909
+ sleep: (ms) => new Promise((r) => {
3910
+ setTimeout(r, ms);
3911
+ })
3912
+ });
3913
+ if (outcome === "timeout") {
3914
+ process.stderr.write(
3915
+ `[exed] Port ${targetPort} still has a LISTEN holder after ${PORT_RELEASE_TIMEOUT_MS / 1e3}s \u2014 proceeding to bind anyway
3916
+ `
3917
+ );
3918
+ }
3785
3919
  }
3786
3920
  } catch {
3787
3921
  }
@@ -4070,8 +4204,8 @@ async function startMcpHttpServer() {
4070
4204
  }
4071
4205
  let loggedClientsWaitingBackoff = false;
4072
4206
  for (let attempt = 0; ; attempt++) {
4073
- const load1m = os3.loadavg()[0] ?? 0;
4074
- const cpuCount = os3.cpus().length || 1;
4207
+ const load1m = os4.loadavg()[0] ?? 0;
4208
+ const cpuCount = os4.cpus().length || 1;
4075
4209
  const decision = decideBootBackoff({
4076
4210
  load1m,
4077
4211
  cpuCount,
@@ -4146,7 +4280,7 @@ async function startMcpHttpServer() {
4146
4280
  clearBootstrapFailureMarker();
4147
4281
  setBootPhase("db_ready");
4148
4282
  _storeInitialized = true;
4149
- const { initLicenseGate, getCachedLicenseGate } = await import("../license-gate-6R3F3NQR.js");
4283
+ const { initLicenseGate, getCachedLicenseGate } = await import("../license-gate-HMSMUIAU.js");
4150
4284
  const gateResult = await initLicenseGate();
4151
4285
  if (!gateResult.hasKey) {
4152
4286
  process.stderr.write(
@@ -4161,13 +4295,13 @@ async function startMcpHttpServer() {
4161
4295
  let _cachedWrapTelemetry = null;
4162
4296
  async function getWrapTelemetry() {
4163
4297
  if (!_cachedWrapTelemetry) {
4164
- const { wrapServerWithTelemetry } = await import("../tool-telemetry-PALAZUXT.js");
4298
+ const { wrapServerWithTelemetry } = await import("../tool-telemetry-VKMRS6MP.js");
4165
4299
  _cachedWrapTelemetry = wrapServerWithTelemetry;
4166
4300
  }
4167
4301
  return _cachedWrapTelemetry;
4168
4302
  }
4169
4303
  Promise.all([
4170
- import("../tool-capability-index-WZWVBI2R.js"),
4304
+ import("../tool-capability-index-BT2GGLLI.js"),
4171
4305
  import("../tool-gates-3IC7DK4R.js")
4172
4306
  ]).then(async ([{ getToolCapabilityIndex }, { TOOL_CATEGORIES }]) => {
4173
4307
  const gateState = getCachedLicenseGate();
@@ -4233,7 +4367,7 @@ async function startMcpHttpServer() {
4233
4367
  const expectedBuf = Buffer.from(_daemonToken);
4234
4368
  if (tokenBuf.length === expectedBuf.length && timingSafeEqual(tokenBuf, expectedBuf)) return true;
4235
4369
  try {
4236
- const { verifyAccessToken } = await import("../oauth-server-KW5M437C.js");
4370
+ const { verifyAccessToken } = await import("../oauth-server-NP7KGF7N.js");
4237
4371
  const result = verifyAccessToken(token);
4238
4372
  return result.valid;
4239
4373
  } catch {
@@ -4436,7 +4570,7 @@ async function startMcpHttpServer() {
4436
4570
  }
4437
4571
  res.setHeader("Access-Control-Allow-Origin", "http://127.0.0.1");
4438
4572
  res.setHeader("Access-Control-Allow-Methods", "POST, GET, DELETE, OPTIONS");
4439
- res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Agent-Id, X-Agent-Role, X-Exe-Session, X-Exe-Session-Name, X-Project-Name, Mcp-Session-Id");
4573
+ res.setHeader("Access-Control-Allow-Headers", `Content-Type, Authorization, X-Agent-Id, X-Agent-Role, X-Exe-Session, X-Exe-Session-Name, ${AGENT_IDENTITY_TOKEN_HEADER}, X-Project-Name, Mcp-Session-Id`);
4440
4574
  res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id, X-Exe-Correlation-Id");
4441
4575
  const url = new URL(req.url || "/", `http://${MCP_HTTP_HOST}:${MCP_HTTP_PORT}`);
4442
4576
  if (req.method === "GET" && url.pathname === "/health") {
@@ -4486,7 +4620,7 @@ async function startMcpHttpServer() {
4486
4620
  return;
4487
4621
  }
4488
4622
  try {
4489
- const { handleOAuthRoute } = await import("../oauth-server-KW5M437C.js");
4623
+ const { handleOAuthRoute } = await import("../oauth-server-NP7KGF7N.js");
4490
4624
  const handled = await handleOAuthRoute(req, res, url, MCP_HTTP_PORT);
4491
4625
  if (handled) return;
4492
4626
  } catch (err) {
@@ -4518,7 +4652,7 @@ async function startMcpHttpServer() {
4518
4652
  for await (const chunk of req) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
4519
4653
  const rawBody = Buffer.concat(chunks);
4520
4654
  try {
4521
- const { loadWebhookConfig, verifyHmac, processWebhook } = await import("../webhook-pipe-QJRFZVKA.js");
4655
+ const { loadWebhookConfig, verifyHmac, processWebhook } = await import("../webhook-pipe-UQSEHFPO.js");
4522
4656
  const webhookConfig = await loadWebhookConfig();
4523
4657
  const serviceConfig = webhookConfig[serviceName];
4524
4658
  if (!serviceConfig) {
@@ -4614,7 +4748,7 @@ async function startMcpHttpServer() {
4614
4748
  contextPct: body.context_pct
4615
4749
  });
4616
4750
  if (body.context_pct !== void 0 && body.context_pct > 70) {
4617
- void import("../orchestration-events-CKQ756NA.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4751
+ void import("../orchestration-events-GMRGGBMN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4618
4752
  recordOE({
4619
4753
  eventType: "context.pressure",
4620
4754
  source: "exe-daemon.heartbeat",
@@ -4683,6 +4817,33 @@ async function startMcpHttpServer() {
4683
4817
  let agentRole = req.headers["x-agent-role"] || "employee";
4684
4818
  const shellMatch2 = agentRole.match(shellDefault);
4685
4819
  if (shellMatch2) agentRole = shellMatch2[1];
4820
+ {
4821
+ const enforceIdentity = shouldEnforceAgentIdentity();
4822
+ const { token: identityToken, duplicate: dupIdentityHeader } = readAgentIdentityTokenHeader(req.headers[AGENT_IDENTITY_TOKEN_HEADER.toLowerCase()]);
4823
+ const identityCheck = dupIdentityHeader ? { ok: false, reason: "duplicate-header" } : getDaemonAgentIdentityBroker().verify({
4824
+ token: identityToken,
4825
+ // Only cross-check the header claim when it is a concrete name; a
4826
+ // missing/"default" header makes no claim and defers to the token.
4827
+ claimedAgentId: agentId && agentId !== "default" ? agentId : void 0
4828
+ });
4829
+ if (identityCheck.ok) {
4830
+ agentId = identityCheck.identity.agentId;
4831
+ agentRole = identityCheck.identity.role;
4832
+ } else if (enforceIdentity) {
4833
+ process.stderr.write(
4834
+ `[exed] SECURITY: rejecting MCP request \u2014 invalid agent identity credential (reason=${identityCheck.reason}, claimed_agent=${agentId})
4835
+ `
4836
+ );
4837
+ sendJsonRpcError2(
4838
+ res,
4839
+ 403,
4840
+ `Agent identity credential verification failed: ${identityCheck.reason}. Under EXE_ENFORCE_AGENT_IDENTITY every MCP caller must present the bound credential the daemon minted at spawn (re-spawn the session via the daemon after a daemon restart).`,
4841
+ "unknown",
4842
+ { agentId, agentRole, identityReason: identityCheck.reason }
4843
+ );
4844
+ return;
4845
+ }
4846
+ }
4686
4847
  try {
4687
4848
  const { loadEmployeesSync } = await import("./employees.js");
4688
4849
  const roster = loadEmployeesSync();
@@ -4699,7 +4860,7 @@ async function startMcpHttpServer() {
4699
4860
  let sessionHint = req.headers["x-exe-session-name"] || req.headers["x-exe-session"] || "";
4700
4861
  if (sessionHint) {
4701
4862
  try {
4702
- const { sanitizeSessionHintHeader, rejectForgedSessionHint } = await import("../mcp-session-identity-GOBGICLI.js");
4863
+ const { sanitizeSessionHintHeader, rejectForgedSessionHint } = await import("../mcp-session-identity-QLUVYWPR.js");
4703
4864
  const rawHint = sessionHint;
4704
4865
  sessionHint = sanitizeSessionHintHeader(sessionHint);
4705
4866
  if (!sessionHint) {
@@ -4738,7 +4899,7 @@ async function startMcpHttpServer() {
4738
4899
  try {
4739
4900
  const liveSessions = await getTmuxSessionsAsync();
4740
4901
  const paneCommands = await getPaneCommandsAsync();
4741
- const { resolveMcpSessionHint } = await import("../mcp-session-identity-GOBGICLI.js");
4902
+ const { resolveMcpSessionHint } = await import("../mcp-session-identity-QLUVYWPR.js");
4742
4903
  let registrySessions = [];
4743
4904
  try {
4744
4905
  const { listSessions: listRegistrySessions } = await import("./session-registry.js");
@@ -4875,7 +5036,7 @@ async function startMcpHttpServer() {
4875
5036
  bindLive = await getTmuxSessionsAsync();
4876
5037
  } catch {
4877
5038
  }
4878
- const { isLauncherCorroboratedIdentity } = await import("../mcp-session-identity-GOBGICLI.js");
5039
+ const { isLauncherCorroboratedIdentity } = await import("../mcp-session-identity-QLUVYWPR.js");
4879
5040
  const corroborated = isLauncherCorroboratedIdentity({
4880
5041
  agentId,
4881
5042
  registrySessions: bindRegistry,
@@ -5118,7 +5279,7 @@ async function startMcpHttpServer() {
5118
5279
  }
5119
5280
  }
5120
5281
  try {
5121
- const { reconcileHintWithRegistryIdentity } = await import("../mcp-session-identity-GOBGICLI.js");
5282
+ const { reconcileHintWithRegistryIdentity } = await import("../mcp-session-identity-QLUVYWPR.js");
5122
5283
  const { listSessions: listRegistrySessions } = await import("./session-registry.js");
5123
5284
  const recon = reconcileHintWithRegistryIdentity({
5124
5285
  agentId,
@@ -5331,9 +5492,9 @@ async function ensureStoreForPolling() {
5331
5492
  await initDatabase({ dbPath: config.dbPath, encryptionKey: masterKey.toString("hex") });
5332
5493
  await ensureSchema();
5333
5494
  try {
5334
- const { isLedgerEnabled } = await import("../notification-ledger-J6Q2GAYU.js");
5495
+ const { isLedgerEnabled } = await import("../notification-ledger-4REL6M3T.js");
5335
5496
  if (isLedgerEnabled()) {
5336
- const { bumpBootGeneration } = await import("../boot-generation-XABYKF5P.js");
5497
+ const { bumpBootGeneration } = await import("../boot-generation-X45BSVZY.js");
5337
5498
  const { setDaemonReadyGeneration } = await import("../daemon-ready-signal-CKXPUMJ2.js");
5338
5499
  const generation = await bumpBootGeneration();
5339
5500
  setDaemonReadyGeneration(generation);
@@ -5373,13 +5534,13 @@ async function ensureStoreForPolling() {
5373
5534
  }
5374
5535
  }
5375
5536
  async function startReviewPolling() {
5376
- const polling = await import("../review-polling-CYBCBHZA.js");
5537
+ const polling = await import("../review-polling-MU47NQ2N.js");
5377
5538
  const state = {
5378
5539
  lastIntercomSent: /* @__PURE__ */ new Map(),
5379
5540
  lastNudgeSent: /* @__PURE__ */ new Map(),
5380
5541
  intervalMs: REVIEW_POLL_INTERVAL_MS
5381
5542
  };
5382
- const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-7425ZVNH.js");
5543
+ const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-Q3GJA2JJ.js");
5383
5544
  const nudgeState = loadNudgeState();
5384
5545
  const tick = async () => traceDaemonTimer("review_polling", async () => {
5385
5546
  fired("review_polling");
@@ -5387,7 +5548,7 @@ async function startReviewPolling() {
5387
5548
  try {
5388
5549
  const { getClient } = await import("./database.js");
5389
5550
  const deps = polling.createRealDeps(getClient);
5390
- const { strictSessionScopeFilter } = await import("../task-scope-ERHPHLUM.js");
5551
+ const { strictSessionScopeFilter } = await import("../task-scope-GDLFE26E.js");
5391
5552
  const { getCoordinatorName, DEFAULT_COORDINATOR_TEMPLATE_NAME } = await import("./employees.js");
5392
5553
  deps.findOrphanedDoneTasks = async (sessionScope) => {
5393
5554
  const coordinatorName = getCoordinatorName();
@@ -5407,7 +5568,7 @@ async function startReviewPolling() {
5407
5568
  deps.findTieredReviewCandidates = async (sessionScope) => {
5408
5569
  let project = null;
5409
5570
  try {
5410
- const { getProjectName } = await import("../project-name-EWG5KAZP.js");
5571
+ const { getProjectName } = await import("../project-name-ILJTETUE.js");
5411
5572
  project = getProjectName() || null;
5412
5573
  } catch {
5413
5574
  project = null;
@@ -5466,7 +5627,7 @@ function startSessionTTL() {
5466
5627
  if (!await ensureStoreForPolling()) return;
5467
5628
  if (inPostRestartDestructiveGrace("session_ttl")) return;
5468
5629
  const { getClient } = await import("./database.js");
5469
- const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-7425ZVNH.js");
5630
+ const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-Q3GJA2JJ.js");
5470
5631
  const deps = createSessionTTLRealDeps(getClient);
5471
5632
  const killed = await checkSessionTTL(deps, _wedgeObservations);
5472
5633
  if (killed.length > 0) acted("session_ttl");
@@ -5491,7 +5652,7 @@ function startIdleKill() {
5491
5652
  if (!await ensureStoreForPolling()) return;
5492
5653
  if (inPostRestartDestructiveGrace("idle_kill")) return;
5493
5654
  try {
5494
- const signalDir = path4.join(os3.homedir(), ".exe-os", "task-signals");
5655
+ const signalDir = path4.join(os4.homedir(), ".exe-os", "task-signals");
5495
5656
  try {
5496
5657
  await access(signalDir);
5497
5658
  } catch {
@@ -5526,7 +5687,7 @@ function startIdleKill() {
5526
5687
  const cfg = await getCachedConfig();
5527
5688
  if (!cfg) return;
5528
5689
  const { getClient } = await import("./database.js");
5529
- const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-7425ZVNH.js");
5690
+ const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-Q3GJA2JJ.js");
5530
5691
  const { sessions: liveSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
5531
5692
  const realDeps = createIdleKillRealDeps(
5532
5693
  getClient,
@@ -5870,7 +6031,8 @@ function startSkillSweep() {
5870
6031
  const { loadConfig: lc } = await import("./config.js");
5871
6032
  const config = await lc();
5872
6033
  if (!config.skillLearning) return;
5873
- if (!process.env.ANTHROPIC_API_KEY) return;
6034
+ const { resolveAnthropicAuth } = await import("../anthropic-auth-S7HEBGUG.js");
6035
+ if (!resolveAnthropicAuth()) return;
5874
6036
  if (!await ensureStoreForPolling()) return;
5875
6037
  const { sweepTrajectories } = await import("./skill-learning.js");
5876
6038
  const result = await sweepTrajectories(config.skillThreshold, config.skillModel);
@@ -5899,7 +6061,7 @@ function startSkillRefinement() {
5899
6061
  if (!shouldRunHeavyJob("skill_refinement")) return;
5900
6062
  try {
5901
6063
  if (!await ensureStoreForPolling()) return;
5902
- const { runSkillRefinement } = await import("../skill-refinement-VDR5OT4V.js");
6064
+ const { runSkillRefinement } = await import("../skill-refinement-NLYDSFEH.js");
5903
6065
  const result = await runSkillRefinement();
5904
6066
  if (result.reviewed > 0) {
5905
6067
  acted("skill_refinement");
@@ -5924,20 +6086,22 @@ var _staleBranchAlertedToday = /* @__PURE__ */ new Set();
5924
6086
  function startStaleBranchSweep() {
5925
6087
  const tick = async () => {
5926
6088
  fired("stale_branch_sweep");
6089
+ if (sweepStarved("stale_branch_sweep")) return;
5927
6090
  try {
5928
- const { discoverRepoPaths } = await import("../worktree-sweep-5LCVT46V.js");
5929
- const { scanUnmergedBranchesCached } = await import("../branch-hygiene-Z4IBWAOX.js");
6091
+ const { discoverRepoPathsAsync } = await import("../worktree-sweep-4EDLLQ2E.js");
6092
+ const { scanUnmergedBranchesCached } = await import("../branch-hygiene-HFJ3HA62.js");
6093
+ const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
5930
6094
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
5931
6095
  for (const k of _staleBranchAlertedToday) {
5932
6096
  if (!k.endsWith(today)) _staleBranchAlertedToday.delete(k);
5933
6097
  }
5934
6098
  let repos = [];
5935
6099
  try {
5936
- repos = discoverRepoPaths();
6100
+ repos = await discoverRepoPathsAsync();
5937
6101
  } catch {
5938
6102
  repos = [];
5939
6103
  }
5940
- for (const repo of repos) {
6104
+ await runBudgetedSweep(repos, async (repo) => {
5941
6105
  await yieldToEventLoop();
5942
6106
  let scan;
5943
6107
  try {
@@ -5947,17 +6111,17 @@ function startStaleBranchSweep() {
5947
6111
  { forceRefresh: true }
5948
6112
  );
5949
6113
  } catch {
5950
- continue;
6114
+ return;
5951
6115
  }
5952
- if (scan.staleCount <= 0) continue;
6116
+ if (scan.staleCount <= 0) return;
5953
6117
  const repoName = repo.split("/").pop() || repo;
5954
6118
  const guardKey = `${repoName}:${today}`;
5955
- if (_staleBranchAlertedToday.has(guardKey)) continue;
6119
+ if (_staleBranchAlertedToday.has(guardKey)) return;
5956
6120
  _staleBranchAlertedToday.add(guardKey);
5957
- if (!_storeInitialized) continue;
6121
+ if (!_storeInitialized) return;
5958
6122
  const stale = scan.branches.filter((b) => b.ageHours >= STALE_BRANCH_HOURS).slice(0, 5).map((b) => `${b.name} (+${b.ahead} commits, ${(b.ageHours / 24).toFixed(1)}d)`).join("; ");
5959
6123
  try {
5960
- const { writeNotification } = await import("../notifications-56TP36IK.js");
6124
+ const { writeNotification } = await import("../notifications-UXJUAP3C.js");
5961
6125
  await writeNotification({
5962
6126
  agentId: "exe",
5963
6127
  agentRole: "system",
@@ -5973,7 +6137,7 @@ function startStaleBranchSweep() {
5973
6137
  );
5974
6138
  } catch {
5975
6139
  }
5976
- }
6140
+ }, maintenanceSweepOptions("stale_branch_sweep"));
5977
6141
  } catch (err) {
5978
6142
  process.stderr.write(`[exed] Stale-branch sweep error: ${err instanceof Error ? err.message : String(err)}
5979
6143
  `);
@@ -6012,7 +6176,7 @@ function startWorkStateHeartbeat() {
6012
6176
  const { getClient } = await import("./database.js");
6013
6177
  const { listSessions } = await import("./session-registry.js");
6014
6178
  const { isCoordinatorName } = await import("./employees.js");
6015
- const { runWorkStateTick } = await import("../work-state-heartbeat-O7UMB6SE.js");
6179
+ const { runWorkStateTick } = await import("../work-state-heartbeat-4LDF6DSM.js");
6016
6180
  let liveTmux = null;
6017
6181
  const loadLiveTmux = async () => {
6018
6182
  if (!liveTmux) liveTmux = await listTmuxSessionNamesAsync();
@@ -6073,11 +6237,12 @@ function startGraphExtraction() {
6073
6237
  const { loadConfig: lc } = await import("./config.js");
6074
6238
  const config = await lc();
6075
6239
  if (config.graphRagEnabled === false) return;
6076
- if (!process.env.ANTHROPIC_API_KEY) return;
6240
+ const { resolveAnthropicAuth } = await import("../anthropic-auth-S7HEBGUG.js");
6241
+ if (!resolveAnthropicAuth()) return;
6077
6242
  if (!await ensureStoreForPolling()) return;
6078
6243
  const { getClient } = await import("./database.js");
6079
6244
  const client = getClient();
6080
- const { extractBatch } = await import("../graph-rag-EOGPZOYI.js");
6245
+ const { extractBatch } = await import("../graph-rag-LSJLWGXV.js");
6081
6246
  const result = await extractBatch(client, 50, config.selfQueryModel);
6082
6247
  if (result.processed > 0) {
6083
6248
  acted("graph_extraction");
@@ -6351,6 +6516,7 @@ var AGENT_STATS_REFRESH_INTERVAL_MS = 60 * 60 * 1e3;
6351
6516
  var _agentRefreshInFlight = false;
6352
6517
  var _lastSpendCapLevel = null;
6353
6518
  async function refreshAgentData() {
6519
+ if (sweepStarved("agent_data_refresh")) return;
6354
6520
  if (_agentRefreshInFlight) return;
6355
6521
  _agentRefreshInFlight = true;
6356
6522
  const started = Date.now();
@@ -6378,19 +6544,28 @@ async function refreshAgentData() {
6378
6544
  });
6379
6545
  }
6380
6546
  await yieldToEventLoop();
6381
- let spend24h = /* @__PURE__ */ new Map();
6382
- let spend7d = /* @__PURE__ */ new Map();
6383
- let spend30d = /* @__PURE__ */ new Map();
6547
+ let spend24h = new Map(_cachedAgentData?.spend24h ?? []);
6548
+ let spend7d = new Map(_cachedAgentData?.spend7d ?? []);
6549
+ let spend30d = new Map(_cachedAgentData?.spend30d ?? []);
6384
6550
  try {
6385
6551
  const { getAgentSpend } = await import("./token-spend.js");
6386
- const r24 = await getAgentSpend("24h");
6387
- spend24h = new Map(r24.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6388
- await yieldToEventLoop();
6389
- const r7 = await getAgentSpend("7d");
6390
- spend7d = new Map(r7.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6391
- await yieldToEventLoop();
6392
- const r30 = await getAgentSpend("30d");
6393
- spend30d = new Map(r30.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6552
+ const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
6553
+ let r24 = [];
6554
+ const windows = [
6555
+ async () => {
6556
+ r24 = await getAgentSpend("24h");
6557
+ spend24h = new Map(r24.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6558
+ },
6559
+ async () => {
6560
+ const r7 = await getAgentSpend("7d");
6561
+ spend7d = new Map(r7.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6562
+ },
6563
+ async () => {
6564
+ const r30 = await getAgentSpend("30d");
6565
+ spend30d = new Map(r30.map((s) => [s.agentId, { inputTokens: s.inputTokens, outputTokens: s.outputTokens, costUSD: s.costUSD, sessions: s.sessions }]));
6566
+ }
6567
+ ];
6568
+ await runBudgetedSweep(windows, (w) => w(), maintenanceSweepOptions("agent_data_refresh"));
6394
6569
  try {
6395
6570
  const { evaluateGlobalSpendCap, evaluateSpendCapAlert } = await import("./token-spend.js");
6396
6571
  const total24hCost = r24.reduce((sum, s) => sum + s.costUSD, 0);
@@ -6398,7 +6573,7 @@ async function refreshAgentData() {
6398
6573
  const decision = evaluateSpendCapAlert(_lastSpendCapLevel, capStatus);
6399
6574
  _lastSpendCapLevel = decision.level;
6400
6575
  if (decision.shouldAlert && decision.summary) {
6401
- const { writeNotification } = await import("../notifications-56TP36IK.js");
6576
+ const { writeNotification } = await import("../notifications-UXJUAP3C.js");
6402
6577
  await writeNotification({
6403
6578
  agentId: "system",
6404
6579
  agentRole: "system",
@@ -6520,7 +6695,7 @@ function startReflectionSweep() {
6520
6695
  );
6521
6696
  let runReflection;
6522
6697
  try {
6523
- ({ runReflection } = await import("../memory-reflection-V2SNAUIB.js"));
6698
+ ({ runReflection } = await import("../memory-reflection-ZKVRU3NT.js"));
6524
6699
  } catch (importErr) {
6525
6700
  _reflectionImportFailed = true;
6526
6701
  process.stderr.write(`[exed] Reflection module unavailable (stale chunk hash?) \u2014 disabled until daemon restart: ${importErr instanceof Error ? importErr.message : String(importErr)}
@@ -6561,7 +6736,7 @@ function startReflectionSweep() {
6561
6736
  if (memories > 100 && cards < memories * 0.1) {
6562
6737
  process.stderr.write(`[exed] Memory cards sparse (${cards} cards / ${memories} memories) \u2014 running backfill...
6563
6738
  `);
6564
- const { insertMemoryCardsForBatch } = await import("../memory-cards-4EXX3BQS.js");
6739
+ const { insertMemoryCardsForBatch } = await import("../memory-cards-K2OSX4AW.js");
6565
6740
  const batchSize = 500;
6566
6741
  let offset = 0;
6567
6742
  let totalCards = 0;
@@ -6642,7 +6817,7 @@ function startDatabaseBackup() {
6642
6817
  `
6643
6818
  );
6644
6819
  try {
6645
- const { maybeVerifyDailyBackup } = await import("../backup-verify-TZPPUCLU.js");
6820
+ const { maybeVerifyDailyBackup } = await import("../backup-verify-F7BHVEF7.js");
6646
6821
  const verdict = await maybeVerifyDailyBackup(backupPath);
6647
6822
  if (verdict && !verdict.ok) {
6648
6823
  process.stderr.write(
@@ -6718,7 +6893,7 @@ function startSessionEventsRetention() {
6718
6893
  fired("session_events_retention");
6719
6894
  if (!await ensureStoreForPolling()) return;
6720
6895
  try {
6721
- const { DEFAULT_SESSION_EVENTS_RETENTION_DAYS } = await import("../session-events-X33W4JNA.js");
6896
+ const { DEFAULT_SESSION_EVENTS_RETENTION_DAYS } = await import("../session-events-YMQ3VGBJ.js");
6722
6897
  const days = SESSION_EVENTS_RETENTION_DAYS ?? DEFAULT_SESSION_EVENTS_RETENTION_DAYS;
6723
6898
  if (!isWriteWorkerEnabled() || !isDbWriteWorkerReady()) {
6724
6899
  process.stderr.write(
@@ -6764,7 +6939,7 @@ function startIntercomQueueDrain() {
6764
6939
  const tick = async () => traceDaemonTimer("intercom_queue_drain", async () => {
6765
6940
  fired("intercom_queue_drain");
6766
6941
  try {
6767
- const { drainQueueAsync, readQueue } = await import("../intercom-queue-R5LSXD3V.js");
6942
+ const { drainQueueAsync, readQueue } = await import("../intercom-queue-6DZPHHQ2.js");
6768
6943
  const {
6769
6944
  sendIntercomAsync: centralSendIntercomAsync,
6770
6945
  countScopedPendingReviews,
@@ -6896,7 +7071,7 @@ function startLedgerDrain() {
6896
7071
  const tick = async () => traceDaemonTimer("ledger_drain", async () => {
6897
7072
  fired("ledger_drain");
6898
7073
  try {
6899
- const { isLedgerEnabled, drainLedger } = await import("../notification-ledger-J6Q2GAYU.js");
7074
+ const { isLedgerEnabled, drainLedger } = await import("../notification-ledger-4REL6M3T.js");
6900
7075
  if (!isLedgerEnabled()) return;
6901
7076
  const result = await drainLedger({
6902
7077
  // Shadow "would-deliver": idle target = would-deliver, busy = retry.
@@ -6935,7 +7110,7 @@ function startOrphanReaper() {
6935
7110
  const tick = async () => traceDaemonTimer("orphan_reaper", async () => {
6936
7111
  fired("orphan_reaper");
6937
7112
  try {
6938
- const { reapOrphanedMcpProcesses, createOrphanReaperRealDepsAsync } = await import("../daemon-orchestration-7425ZVNH.js");
7113
+ const { reapOrphanedMcpProcesses, createOrphanReaperRealDepsAsync } = await import("../daemon-orchestration-Q3GJA2JJ.js");
6939
7114
  const deps = await createOrphanReaperRealDepsAsync();
6940
7115
  const reaped = await reapOrphanedMcpProcesses(deps);
6941
7116
  if (reaped.length > 0) acted("orphan_reaper");
@@ -6960,7 +7135,7 @@ function startZombieAgentReaper() {
6960
7135
  const tick = async () => traceDaemonTimer("zombie_agent_reaper", async () => {
6961
7136
  fired("zombie_agent_reaper");
6962
7137
  try {
6963
- const { reapZombieAgentProcesses, createZombieAgentReaperRealDepsAsync } = await import("../daemon-orchestration-7425ZVNH.js");
7138
+ const { reapZombieAgentProcesses, createZombieAgentReaperRealDepsAsync } = await import("../daemon-orchestration-Q3GJA2JJ.js");
6964
7139
  const deps = await createZombieAgentReaperRealDepsAsync();
6965
7140
  const reaped = reapZombieAgentProcesses(deps);
6966
7141
  if (reaped.length > 0) acted("zombie_agent_reaper");
@@ -6984,7 +7159,7 @@ async function startDaemonMemoryPressureWatchdog() {
6984
7159
  try {
6985
7160
  const cfg = await getCachedConfig();
6986
7161
  if (!cfg) return;
6987
- const { startMemoryPressureWatchdog: startWatchdog, MEMORY_PRESSURE_WATCHDOG_DEFAULTS } = await import("../memory-pressure-watchdog-COJC3OYS.js");
7162
+ const { startMemoryPressureWatchdog: startWatchdog, MEMORY_PRESSURE_WATCHDOG_DEFAULTS } = await import("../memory-pressure-watchdog-ZI3TH2OF.js");
6988
7163
  const watchdogCfg = {
6989
7164
  ...MEMORY_PRESSURE_WATCHDOG_DEFAULTS,
6990
7165
  ...cfg.memoryPressureWatchdog ?? {}
@@ -7014,8 +7189,9 @@ async function startDaemonMemoryPressureWatchdog() {
7014
7189
  function startWorktreeReaper() {
7015
7190
  const tick = async () => traceDaemonTimer("worktree_reaper", async () => {
7016
7191
  fired("worktree_reaper");
7192
+ if (sweepStarved("worktree_reaper")) return;
7017
7193
  try {
7018
- const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-7425ZVNH.js");
7194
+ const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-Q3GJA2JJ.js");
7019
7195
  const deps = await createWorktreeReaperRealDeps();
7020
7196
  const result = await reapOrphanedWorktrees(deps);
7021
7197
  if (result.pruned.length > 0) {
@@ -7041,7 +7217,8 @@ function startWorktreeReaper() {
7041
7217
  }
7042
7218
  {
7043
7219
  const files = (await readdir(signalDir)).filter((f) => f.endsWith(".json"));
7044
- for (const file of files) {
7220
+ const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
7221
+ await runBudgetedSweep(files, async (file) => {
7045
7222
  try {
7046
7223
  const fullPath = path4.join(signalDir, file);
7047
7224
  const signal = JSON.parse(await readFile(fullPath, "utf8"));
@@ -7056,10 +7233,10 @@ function startWorktreeReaper() {
7056
7233
  `
7057
7234
  );
7058
7235
  }
7059
- continue;
7236
+ return;
7060
7237
  }
7061
- const { cleanupAgentWorktree } = await import("../worktree-sweep-5LCVT46V.js");
7062
- const { getMainRepoRootAsync } = await import("../worktree-ZWA35PKW.js");
7238
+ const { cleanupAgentWorktree } = await import("../worktree-sweep-4EDLLQ2E.js");
7239
+ const { getMainRepoRootAsync } = await import("../worktree-H3YFJ3NU.js");
7063
7240
  const repoRoot = await getMainRepoRootAsync(signal.worktreePath);
7064
7241
  if (repoRoot && signal.agentId) {
7065
7242
  const notes = await cleanupAgentWorktree(repoRoot, signal.agentId);
@@ -7073,7 +7250,7 @@ function startWorktreeReaper() {
7073
7250
  }
7074
7251
  } catch {
7075
7252
  }
7076
- }
7253
+ }, maintenanceSweepOptions("worktree_reaper_signals"));
7077
7254
  }
7078
7255
  } catch {
7079
7256
  }
@@ -7085,6 +7262,10 @@ function startWorktreeReaper() {
7085
7262
  `);
7086
7263
  }
7087
7264
  var AUTO_WAKE_INTERVAL_MS = 60 * 1e3;
7265
+ var AUTO_WAKE_SIGNALS_PER_TICK = Math.max(
7266
+ 1,
7267
+ Number(process.env.EXE_AUTO_WAKE_SIGNALS_PER_TICK) || 10
7268
+ );
7088
7269
  function startAutoWake() {
7089
7270
  const tick = async () => traceDaemonTimer("auto_wake", async () => {
7090
7271
  fired("auto_wake");
@@ -7092,7 +7273,7 @@ function startAutoWake() {
7092
7273
  if (!await ensureStoreForPolling()) return;
7093
7274
  try {
7094
7275
  const { getClient } = await import("./database.js");
7095
- const { pollOrphanedTasks, createAutoWakeRealDeps } = await import("../daemon-orchestration-7425ZVNH.js");
7276
+ const { pollOrphanedTasks, createAutoWakeRealDeps } = await import("../daemon-orchestration-Q3GJA2JJ.js");
7096
7277
  const deps = createAutoWakeRealDeps(getClient, process.cwd(), getTmuxSessionsAsync);
7097
7278
  const woken = await pollOrphanedTasks(deps);
7098
7279
  if (woken.length > 0) acted("auto_wake");
@@ -7100,8 +7281,9 @@ function startAutoWake() {
7100
7281
  process.stderr.write(`[exed] Auto-wake: spawned ${agent}
7101
7282
  `);
7102
7283
  }
7284
+ if (sweepStarved("auto_wake_signals")) return;
7103
7285
  try {
7104
- const signalBase = path4.join(os3.homedir(), ".exe-os", "task-signals");
7286
+ const signalBase = path4.join(os4.homedir(), ".exe-os", "task-signals");
7105
7287
  try {
7106
7288
  await access(signalBase);
7107
7289
  } catch {
@@ -7109,7 +7291,8 @@ function startAutoWake() {
7109
7291
  }
7110
7292
  {
7111
7293
  const { sendIntercomAsync, extractRootExe } = await import("./tmux-routing.js");
7112
- const sessionCache = path4.join(os3.homedir(), ".exe-os", "session-cache");
7294
+ const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
7295
+ const sessionCache = path4.join(os4.homedir(), ".exe-os", "session-cache");
7113
7296
  const sessions = await getTmuxSessionsAsync();
7114
7297
  const signalDirs = [];
7115
7298
  for (const entry of await readdir(signalBase, { withFileTypes: true })) {
@@ -7137,6 +7320,7 @@ function startAutoWake() {
7137
7320
  return "claude";
7138
7321
  }
7139
7322
  };
7323
+ const signalWork = [];
7140
7324
  for (const { dir, scope } of signalDirs) {
7141
7325
  let files = [];
7142
7326
  try {
@@ -7144,26 +7328,35 @@ function startAutoWake() {
7144
7328
  } catch {
7145
7329
  continue;
7146
7330
  }
7147
- for (const file of files) {
7331
+ for (const file of files) signalWork.push({ dir, scope, file });
7332
+ }
7333
+ const signalDeadline = Date.now() + MAINTENANCE_SWEEP_BUDGET_MS;
7334
+ let signalsHandled = 0;
7335
+ await runBudgetedSweep(signalWork, async ({ dir, scope, file }) => {
7336
+ if (signalsHandled >= AUTO_WAKE_SIGNALS_PER_TICK || Date.now() >= signalDeadline) {
7337
+ return false;
7338
+ }
7339
+ signalsHandled++;
7340
+ {
7148
7341
  const signalPath = path4.join(dir, file);
7149
7342
  let age;
7150
7343
  try {
7151
7344
  age = Date.now() - (await stat(signalPath)).mtimeMs;
7152
7345
  } catch {
7153
- continue;
7346
+ return;
7154
7347
  }
7155
7348
  if (age > 60 * 60 * 1e3) {
7156
7349
  try {
7157
7350
  await unlink(signalPath);
7158
- void import("../orchestration-events-CKQ756NA.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
7351
+ void import("../orchestration-events-GMRGGBMN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
7159
7352
  recordOE({ eventType: "signal.stale", source: "exe-daemon.autoWake", severity: "warn", payload: { file, ageMinutes: Math.round(age / 6e4) } });
7160
7353
  }).catch(() => {
7161
7354
  });
7162
7355
  } catch {
7163
7356
  }
7164
- continue;
7357
+ return;
7165
7358
  }
7166
- if (age > 5 * 60 * 1e3) continue;
7359
+ if (age > 5 * 60 * 1e3) return;
7167
7360
  const agentId = file.includes(".") ? file.split(".")[0] : file.replace(".pending", "");
7168
7361
  const match = sessions.find((s) => {
7169
7362
  const agentPart = s.split("-")[0] ?? s;
@@ -7172,9 +7365,9 @@ function startAutoWake() {
7172
7365
  if (!scope) return true;
7173
7366
  return s.endsWith(`-${scope}`);
7174
7367
  });
7175
- if (!match) continue;
7368
+ if (!match) return;
7176
7369
  const state = classifyPaneState(await capturePaneAsync(match, 5));
7177
- if (state !== "idle") continue;
7370
+ if (state !== "idle") return;
7178
7371
  const runtime = await runtimeFor(match);
7179
7372
  if (runtime === "codex" || runtime === "opencode" || runtime === "exe-agent") {
7180
7373
  await killTmuxSessionAsync(match);
@@ -7197,7 +7390,7 @@ function startAutoWake() {
7197
7390
  }
7198
7391
  }
7199
7392
  }
7200
- }
7393
+ }, { ...maintenanceSweepOptions("auto_wake_signals"), rescheduleDelayMs: 0 });
7201
7394
  }
7202
7395
  } catch (err) {
7203
7396
  process.stderr.write(`[exed] Signal-wake error: ${err instanceof Error ? err.message : String(err)}
@@ -7292,6 +7485,7 @@ var STUCK_TASK_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
7292
7485
  function startStuckTaskRelease() {
7293
7486
  const tick = async () => traceDaemonTimer("stuck_task_release", async () => {
7294
7487
  fired("stuck_task_release");
7488
+ if (sweepStarved("stuck_task_release")) return;
7295
7489
  if (!await ensureStoreForPolling()) return;
7296
7490
  if (inPostRestartDestructiveGrace("stuck_task_release")) return;
7297
7491
  try {
@@ -7303,28 +7497,47 @@ function startStuckTaskRelease() {
7303
7497
  createStaleClaimRealDeps,
7304
7498
  escalateStuckBlockedTasks,
7305
7499
  createStuckBlockedRealDeps
7306
- } = await import("../daemon-orchestration-7425ZVNH.js");
7307
- const deps = createStuckTaskRealDeps(getClient);
7308
- const released = await releaseStuckTasks(deps);
7309
- if (released.length > 0) {
7310
- acted("stuck_task_release");
7311
- process.stderr.write(`[exed] Stuck-release: ${released.length} task(s) moved to blocked
7500
+ } = await import("../daemon-orchestration-Q3GJA2JJ.js");
7501
+ const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
7502
+ const steps = [
7503
+ async () => {
7504
+ const deps = createStuckTaskRealDeps(getClient);
7505
+ const released = await releaseStuckTasks(deps);
7506
+ if (released.length > 0) {
7507
+ acted("stuck_task_release");
7508
+ process.stderr.write(`[exed] Stuck-release: ${released.length} task(s) moved to blocked
7312
7509
  `);
7313
- }
7314
- const claimsReleased = await releaseStaleClaims(createStaleClaimRealDeps(getClient));
7315
- if (claimsReleased.length > 0) {
7316
- acted("stuck_task_release");
7317
- process.stderr.write(`[exed] Stale-claim release: ${claimsReleased.length} dead-holder claim(s) cleared
7510
+ }
7511
+ },
7512
+ // Bugs 784ebe98 + 31a59ab2: on the same scan, clear stale claim BINDINGS
7513
+ // whose holder session is gone (e.g. a dead subagent that claimed the
7514
+ // parent's task). releaseStuckTasks routes dead-session in_progress tasks to
7515
+ // 'blocked' but never clears the claim columns, so the lock outlives the
7516
+ // holder and strands the task; this releases only that lock (status
7517
+ // untouched) so the legitimate owner can re-claim. Reuses this timer.
7518
+ async () => {
7519
+ const claimsReleased = await releaseStaleClaims(createStaleClaimRealDeps(getClient));
7520
+ if (claimsReleased.length > 0) {
7521
+ acted("stuck_task_release");
7522
+ process.stderr.write(`[exed] Stale-claim release: ${claimsReleased.length} dead-holder claim(s) cleared
7318
7523
  `);
7319
- }
7320
- const blockedResult = await escalateStuckBlockedTasks(createStuckBlockedRealDeps(getClient));
7321
- if (blockedResult.escalated.length > 0 || blockedResult.cancelled.length > 0) {
7322
- acted("stuck_task_release");
7323
- process.stderr.write(
7324
- `[exed] Stuck-blocked: escalated ${blockedResult.escalated.length}, auto-cancelled ${blockedResult.cancelled.length}
7524
+ }
7525
+ },
7526
+ // Feature 638f8611: on the same scan, escalate + auto-cancel tasks that
7527
+ // have been 'blocked' too long (intercom at >48h, auto-cancel at >72h).
7528
+ // Reuses this timer — no new always-on timer is added.
7529
+ async () => {
7530
+ const blockedResult = await escalateStuckBlockedTasks(createStuckBlockedRealDeps(getClient));
7531
+ if (blockedResult.escalated.length > 0 || blockedResult.cancelled.length > 0) {
7532
+ acted("stuck_task_release");
7533
+ process.stderr.write(
7534
+ `[exed] Stuck-blocked: escalated ${blockedResult.escalated.length}, auto-cancelled ${blockedResult.cancelled.length}
7325
7535
  `
7326
- );
7327
- }
7536
+ );
7537
+ }
7538
+ }
7539
+ ];
7540
+ await runBudgetedSweep(steps, (step) => step(), maintenanceSweepOptions("stuck_task_release"));
7328
7541
  } catch (err) {
7329
7542
  process.stderr.write(`[exed] Stuck-release error: ${err instanceof Error ? err.message : String(err)}
7330
7543
  `);
@@ -7370,8 +7583,8 @@ function startExternalRssWatchdog() {
7370
7583
  try {
7371
7584
  const workerSource = `
7372
7585
  import { workerData } from "node:worker_threads";
7373
- import { execFile } from "node:child_process";
7374
- import { mkdirSync, writeFileSync, statSync } from "node:fs";
7586
+ import { execFile, execFileSync } from "node:child_process";
7587
+ import { mkdirSync, writeFileSync, statSync, appendFileSync } from "node:fs";
7375
7588
  import { dirname } from "node:path";
7376
7589
  import { loadavg, cpus } from "node:os";
7377
7590
 
@@ -7380,6 +7593,7 @@ function startExternalRssWatchdog() {
7380
7593
  const checkMs = Number(workerData.checkMs);
7381
7594
  const markerPath = String(workerData.markerPath);
7382
7595
  const safeCwd = String(workerData.cwd || "/");
7596
+ const killLedgerPath = String(workerData.killLedgerPath || "");
7383
7597
  // Bug 9fc1e69e: debounce + startup grace so a single transient RSS spike that
7384
7598
  // GC reclaims does NOT terminate the daemon. The external watchdog cannot run
7385
7599
  // GC on the daemon, so it requires MORE consecutive over-threshold samples than
@@ -7408,6 +7622,34 @@ function startExternalRssWatchdog() {
7408
7622
  });
7409
7623
  }
7410
7624
 
7625
+ // This worker is built from a template literal and evaluated as a data: URL,
7626
+ // so it cannot import daemon-kill-attribution.ts. It appends the SAME JSON
7627
+ // line shape with the plain node:fs calls it already has; the ledger path is
7628
+ // resolved on the main thread and passed in via workerData.
7629
+ function recordKillIntent(targetPid, signal, reason) {
7630
+ if (!killLedgerPath) return;
7631
+ try { mkdirSync(dirname(killLedgerPath), { recursive: true }); } catch {}
7632
+ try {
7633
+ appendFileSync(killLedgerPath, JSON.stringify({
7634
+ ts: new Date().toISOString(),
7635
+ senderPid: pid,
7636
+ senderArgv: String(process.argv.join(" ")).slice(0, 300),
7637
+ sender: "external-watchdog",
7638
+ targetPid: targetPid,
7639
+ signal: signal,
7640
+ reason: reason,
7641
+ }) + "\\n");
7642
+ } catch {}
7643
+ }
7644
+
7645
+ // Raw \`ps -o lstart=\` string \u2014 compared verbatim, so the worker needs no
7646
+ // date parsing. Second granularity is exactly what the guard tolerates.
7647
+ function startedAtRaw(targetPid) {
7648
+ try {
7649
+ return String(execFileSync("ps", ["-o", "lstart=", "-p", String(targetPid)], { cwd: safeCwd, encoding: "utf8", timeout: 2000 })).trim() || null;
7650
+ } catch { return null; }
7651
+ }
7652
+
7411
7653
  function terminateDaemon(reason) {
7412
7654
  if (terminating) return;
7413
7655
  terminating = true;
@@ -7415,8 +7657,22 @@ function startExternalRssWatchdog() {
7415
7657
  // A wedged loop cannot run its SIGTERM handler, so escalate to SIGKILL after
7416
7658
  // a short grace (the in-process self-heal already WAL-checkpoints when it can;
7417
7659
  // this external path is the last resort precisely because the loop is stuck).
7660
+ const startedAt = startedAtRaw(pid);
7661
+ recordKillIntent(pid, "SIGTERM", reason);
7418
7662
  try { process.kill(pid, "SIGTERM"); } catch {}
7419
- setTimeout(() => { try { process.kill(pid, "SIGKILL"); } catch {} }, 5000).unref();
7663
+ setTimeout(() => {
7664
+ // Identity re-check: 5s is ample time for this PID to be recycled onto the
7665
+ // SUCCESSOR daemon that launchd just spawned. SIGKILLing that is how a
7666
+ // healthy new daemon dies at ~5s of age with no explanation.
7667
+ const now = startedAtRaw(pid);
7668
+ if (startedAt && now !== startedAt) {
7669
+ try { process.stderr.write("[exed-watchdog] REFUSING SIGKILL to PID " + pid + ": start time changed (" + startedAt + " -> " + (now || "UNREADABLE") + ") \u2014 PID was RECYCLED\\n"); } catch {}
7670
+ recordKillIntent(pid, "SIGKILL:REFUSED", "pid-identity-mismatch expected=" + startedAt + " actual=" + (now || "null"));
7671
+ return;
7672
+ }
7673
+ recordKillIntent(pid, "SIGKILL", "SIGTERM grace expired :: " + reason);
7674
+ try { process.kill(pid, "SIGKILL"); } catch {}
7675
+ }, 5000).unref();
7420
7676
  }
7421
7677
 
7422
7678
  // --- Event-loop stall watchdog (independent of RSS) ---
@@ -7469,7 +7725,9 @@ function startExternalRssWatchdog() {
7469
7725
  restartBytes: RSS_RESTART_BYTES,
7470
7726
  checkMs: RSS_CHECK_INTERVAL_MS,
7471
7727
  markerPath: OOM_MARKER_PATH,
7472
- cwd: os3.homedir(),
7728
+ cwd: os4.homedir(),
7729
+ // Resolved on the main thread — the worker cannot import config.ts.
7730
+ killLedgerPath: killAttributionLogPath(),
7473
7731
  // External path can't GC the daemon → require one extra consecutive sample
7474
7732
  // beyond the in-process debounce before terminating.
7475
7733
  debounceN: DAEMON_RSS_RESTART_DEBOUNCE + 1,
@@ -7504,12 +7762,12 @@ function startTaskEnforcementScanner() {
7504
7762
  const tick = async () => traceDaemonTimer("task_enforcement", async () => {
7505
7763
  fired("task_enforcement");
7506
7764
  try {
7507
- const { runTaskEnforcementTick } = await import("../task-enforcement-GQDUTIFY.js");
7765
+ const { runTaskEnforcementTick } = await import("../task-enforcement-LXW45H5Z.js");
7508
7766
  const { getTransport } = await import("./transport.js");
7509
7767
  const { loadAgentConfig } = await import("./agent-config.js");
7510
7768
  const { getClient } = await import("./database.js");
7511
7769
  const { loadEmployeesSync } = await import("./employees.js");
7512
- const { sessionScopeFilter } = await import("../task-scope-ERHPHLUM.js");
7770
+ const { sessionScopeFilter } = await import("../task-scope-GDLFE26E.js");
7513
7771
  const transport = getTransport();
7514
7772
  const { sessions: allSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
7515
7773
  await yieldToEventLoop();
@@ -7520,10 +7778,10 @@ function startTaskEnforcementScanner() {
7520
7778
  sendKeysLiteral: transport.sendKeysLiteral?.bind(transport),
7521
7779
  isAlive: (session) => aliveSessions.has(session)
7522
7780
  };
7523
- const { checkAutoWakeGates } = await import("../daemon-orchestration-7425ZVNH.js");
7781
+ const { checkAutoWakeGates } = await import("../daemon-orchestration-Q3GJA2JJ.js");
7524
7782
  const { ensureEmployeeAsync, employeeSessionName, sendIntercomAsync } = await import("./tmux-routing.js");
7525
7783
  const { shouldAutoInstance } = await import("./employees.js");
7526
- const { recordOrchestrationEventBestEffort } = await import("../orchestration-events-CKQ756NA.js");
7784
+ const { recordOrchestrationEventBestEffort } = await import("../orchestration-events-GMRGGBMN.js");
7527
7785
  const projectDir = process.cwd();
7528
7786
  await runTaskEnforcementTick({
7529
7787
  transport: enforcementTransport,
@@ -7814,7 +8072,7 @@ function startBackgroundJobGuardrails() {
7814
8072
  const tick = async () => traceDaemonTimer("background_job_guardrails", async () => {
7815
8073
  fired("background_job_guardrails");
7816
8074
  try {
7817
- const { enforceBackgroundJobGuardrailsAsync } = await import("../background-jobs-Z6KHCWES.js");
8075
+ const { enforceBackgroundJobGuardrailsAsync } = await import("../background-jobs-LTPWCMA3.js");
7818
8076
  const actions = await enforceBackgroundJobGuardrailsAsync();
7819
8077
  if (actions.length > 0) {
7820
8078
  acted("background_job_guardrails");
@@ -7849,7 +8107,7 @@ async function sweepExpiredTracesFromDaemonTimer() {
7849
8107
  const memoryIds = idsResult.rows.map((r) => String(r.id)).filter(Boolean);
7850
8108
  if (memoryIds.length === 0) return 0;
7851
8109
  const { getClient } = await import("./database.js");
7852
- const { cleanupGraphLinksForMemories, cleanupCardsForMemories } = await import("../graph-rag-EOGPZOYI.js");
8110
+ const { cleanupGraphLinksForMemories, cleanupCardsForMemories } = await import("../graph-rag-LSJLWGXV.js");
7853
8111
  const client = getClient();
7854
8112
  await cleanupGraphLinksForMemories(client, memoryIds);
7855
8113
  await cleanupCardsForMemories(client, memoryIds);
@@ -8159,22 +8417,31 @@ function killOrphanDaemons() {
8159
8417
  try {
8160
8418
  const pids = execSyncNode("pgrep -f 'exe-daemon\\.js' 2>/dev/null || true", { encoding: "utf8", timeout: 3e3 }).trim().split("\n").filter(Boolean).map(Number).filter((n) => !isNaN(n) && isSameDaemonInstance(n));
8161
8419
  if (pids.length === 0) return;
8420
+ const identities = /* @__PURE__ */ new Map();
8162
8421
  for (const pid of pids) {
8163
8422
  try {
8423
+ identities.set(pid, processStartedAt(pid));
8164
8424
  process.stderr.write(`[exed] Killing orphan daemon from same instance (PID ${pid})
8165
8425
  `);
8426
+ recordKillIntent({
8427
+ targetPid: pid,
8428
+ signal: "SIGTERM",
8429
+ sender: "orphan-daemon-reaper",
8430
+ reason: "orphan exe-daemon.js proven to belong to this install"
8431
+ });
8166
8432
  process.kill(pid, "SIGTERM");
8167
8433
  } catch {
8168
8434
  }
8169
8435
  }
8170
8436
  setTimeout(() => {
8171
8437
  for (const pid of pids) {
8172
- try {
8173
- process.kill(pid, 0);
8174
- process.stderr.write(`[exed] Orphan PID ${pid} survived SIGTERM \u2014 escalating to SIGKILL
8438
+ const outcome = killIfSameProcess(pid, identities.get(pid) ?? null, "SIGKILL", {
8439
+ sender: "orphan-daemon-reaper",
8440
+ reason: "orphan survived 2s SIGTERM grace"
8441
+ });
8442
+ if (outcome === "sent") {
8443
+ process.stderr.write(`[exed] Orphan PID ${pid} survived SIGTERM \u2014 escalated to SIGKILL
8175
8444
  `);
8176
- process.kill(pid, "SIGKILL");
8177
- } catch {
8178
8445
  }
8179
8446
  }
8180
8447
  }, 2e3).unref();
@@ -8357,7 +8624,7 @@ try {
8357
8624
  process.env.EXE_IS_DAEMON = "1";
8358
8625
  if (process.platform === "darwin") {
8359
8626
  try {
8360
- const oldPlist = path4.join(os3.homedir(), "Library", "LaunchAgents", "com.askexe.exed-keepalive.plist");
8627
+ const oldPlist = path4.join(os4.homedir(), "Library", "LaunchAgents", "com.askexe.exed-keepalive.plist");
8361
8628
  if (existsSync7(oldPlist)) {
8362
8629
  try {
8363
8630
  execSyncNode(`launchctl unload "${oldPlist}" 2>/dev/null`, { timeout: 5e3 });
@@ -8383,8 +8650,8 @@ void (async () => {
8383
8650
  })();
8384
8651
  function isCpuStarved() {
8385
8652
  const ratio = parseFloat(process.env.EXE_STARVATION_LOAD_RATIO ?? "1.5");
8386
- const load1m = os3.loadavg()[0] ?? 0;
8387
- const cpuCount = os3.cpus().length || 1;
8653
+ const load1m = os4.loadavg()[0] ?? 0;
8654
+ const cpuCount = os4.cpus().length || 1;
8388
8655
  return isHostCpuStarved(load1m, cpuCount, ratio);
8389
8656
  }
8390
8657
  async function runSmokeTests() {
@@ -8528,7 +8795,7 @@ function startEventLoopLagDetector() {
8528
8795
  touchEventLoopHeartbeat();
8529
8796
  const wallElapsedMs = monotonicElapsedMs(lastTick);
8530
8797
  const lag = wallElapsedMs - 2e3;
8531
- const sampledLoad1m = os3.loadavg()[0] ?? 0;
8798
+ const sampledLoad1m = os4.loadavg()[0] ?? 0;
8532
8799
  const loadWindow = updateLoadWindow(loadSamples, Date.now(), sampledLoad1m, wallElapsedMs, LOAD_SAMPLE_KEEP_MS);
8533
8800
  loadSamples = loadWindow.samples;
8534
8801
  const cpuDelta = process.cpuUsage(lastCpu);
@@ -8551,7 +8818,7 @@ function startEventLoopLagDetector() {
8551
8818
  const msg = `[exed] EVENT LOOP BLOCKED ${(lag / 1e3).toFixed(1)}s \u2014 MCP UNRESPONSIVE. Sessions will die.`;
8552
8819
  process.stderr.write(msg + "\n");
8553
8820
  logDaemonHealth({ event: "event_loop_blocked", pid: process.pid, message: msg, data: { lagMs: lag } });
8554
- void import("../orchestration-events-CKQ756NA.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
8821
+ void import("../orchestration-events-GMRGGBMN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
8555
8822
  recordOE({ eventType: "daemon.event_loop_blocked", source: "exe-daemon.lagDetector", severity: "error", durationMs: lag });
8556
8823
  }).catch(() => {
8557
8824
  });
@@ -8564,8 +8831,8 @@ function startEventLoopLagDetector() {
8564
8831
  }
8565
8832
  clearDaemonReady();
8566
8833
  try {
8567
- const load1m2 = os3.loadavg()[0] ?? 0;
8568
- const cpuCount2 = os3.cpus().length || 1;
8834
+ const load1m2 = os4.loadavg()[0] ?? 0;
8835
+ const cpuCount2 = os4.cpus().length || 1;
8569
8836
  logDaemonHealth({
8570
8837
  event: "orchestration_health",
8571
8838
  pid: process.pid,
@@ -8576,7 +8843,7 @@ function startEventLoopLagDetector() {
8576
8843
  }
8577
8844
  const load1m = sampledLoad1m;
8578
8845
  const maxLoad1mOverWindow = loadWindow.maxLoad1mOverWindow;
8579
- const cpuCount = os3.cpus().length || 1;
8846
+ const cpuCount = os4.cpus().length || 1;
8580
8847
  const starvationRatio = resolveSelfHealThresholds().starvationRatio;
8581
8848
  const catchUpActive = inBootCatchUpGrace();
8582
8849
  const decision = decideDaemonSelfHeal({
@@ -8702,7 +8969,7 @@ function startTaskFileResync() {
8702
8969
  const { getClient } = await import("./database.js");
8703
8970
  const { runBudgetedSweep } = await import("../sweep-budget-KMPJ7O5Z.js");
8704
8971
  const client = getClient();
8705
- const tasksRoot = path4.join(os3.homedir(), ".exe-os", "tasks");
8972
+ const tasksRoot = path4.join(os4.homedir(), ".exe-os", "tasks");
8706
8973
  let synced = 0;
8707
8974
  const paths = [];
8708
8975
  let fileCount = 0;
@@ -8745,7 +9012,7 @@ function startTaskFileResync() {
8745
9012
  });
8746
9013
  if (Number(res.rowsAffected ?? 0) > 0) {
8747
9014
  synced++;
8748
- void import("../orchestration-events-CKQ756NA.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
9015
+ void import("../orchestration-events-GMRGGBMN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
8749
9016
  recordOE({
8750
9017
  eventType: "task_file.resynced",
8751
9018
  source: "exe-daemon.taskFileResync",
@@ -8779,7 +9046,7 @@ function startTaskGroupBarriers() {
8779
9046
  fired("task_group_barriers");
8780
9047
  if (!await ensureStoreForPolling()) return;
8781
9048
  try {
8782
- const { pollTaskGroupBarriers } = await import("../daemon-orchestration-7425ZVNH.js");
9049
+ const { pollTaskGroupBarriers } = await import("../daemon-orchestration-Q3GJA2JJ.js");
8783
9050
  const firedCount = await pollTaskGroupBarriers();
8784
9051
  if (firedCount > 0) {
8785
9052
  acted("task_group_barriers");
@@ -8801,7 +9068,7 @@ function startCheckpointGc() {
8801
9068
  fired("checkpoint_gc");
8802
9069
  if (!await ensureStoreForPolling()) return;
8803
9070
  try {
8804
- const { gcStaleCheckpoints } = await import("../daemon-orchestration-7425ZVNH.js");
9071
+ const { gcStaleCheckpoints } = await import("../daemon-orchestration-Q3GJA2JJ.js");
8805
9072
  const cleared = await gcStaleCheckpoints();
8806
9073
  if (cleared > 0) {
8807
9074
  acted("checkpoint_gc");
@@ -8841,14 +9108,14 @@ function startDispatchAckCleanup() {
8841
9108
  function startProjectionWorkerDeferred() {
8842
9109
  setTimeout(async () => {
8843
9110
  try {
8844
- const { startProjectionWorker } = await import("../projection-worker-MBWUPB5O.js");
9111
+ const { startProjectionWorker } = await import("../projection-worker-GMRC6SBH.js");
8845
9112
  startProjectionWorker();
8846
9113
  } catch {
8847
9114
  }
8848
9115
  }, 2e4);
8849
9116
  }
8850
9117
  async function startToolTelemetry() {
8851
- const { startToolTelemetryFlush } = await import("../tool-telemetry-PALAZUXT.js");
9118
+ const { startToolTelemetryFlush } = await import("../tool-telemetry-VKMRS6MP.js");
8852
9119
  startToolTelemetryFlush();
8853
9120
  process.stderr.write("[exed] Tool telemetry started (flush every 5m)\n");
8854
9121
  }
@@ -8971,7 +9238,7 @@ function startLocalFirstTimers() {
8971
9238
  fired("intercom_dedup_cleanup");
8972
9239
  if (_intercomDedupCompleted) return;
8973
9240
  try {
8974
- const markerPath = path4.join(os3.homedir(), ".exe-os", ".intercom-dedup-done");
9241
+ const markerPath = path4.join(os4.homedir(), ".exe-os", ".intercom-dedup-done");
8975
9242
  try {
8976
9243
  await access(markerPath);
8977
9244
  _intercomDedupCompleted = true;
@@ -9016,7 +9283,7 @@ function startLocalFirstTimers() {
9016
9283
  fired("orphan_task_cleanup");
9017
9284
  try {
9018
9285
  if (!await ensureStoreForPolling()) return;
9019
- const { cleanOrphanedTaskFiles } = await import("../tasks-crud-NVNF3NRA.js");
9286
+ const { cleanOrphanedTaskFiles } = await import("../tasks-crud-W7VGWRUV.js");
9020
9287
  const count = await cleanOrphanedTaskFiles();
9021
9288
  if (count > 0) {
9022
9289
  acted("orphan_task_cleanup");
@@ -9032,7 +9299,7 @@ function startLocalFirstTimers() {
9032
9299
  fired("task_file_consistency");
9033
9300
  try {
9034
9301
  if (!await ensureStoreForPolling()) return;
9035
- const { checkTaskFileConsistency } = await import("../tasks-crud-NVNF3NRA.js");
9302
+ const { checkTaskFileConsistency } = await import("../tasks-crud-W7VGWRUV.js");
9036
9303
  const mismatches = await checkTaskFileConsistency();
9037
9304
  if (mismatches > 0) {
9038
9305
  acted("task_file_consistency");
@@ -9051,7 +9318,7 @@ function startLocalFirstTimers() {
9051
9318
  const TELEMETRY_DAILY_MS = 24 * 60 * 60 * 1e3;
9052
9319
  const telemetryDaily = async () => {
9053
9320
  try {
9054
- const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-NY3EKOGY.js");
9321
+ const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-FK5WKXVB.js");
9055
9322
  if (!isTelemetryEnabled()) return;
9056
9323
  const { upstream } = await sendTelemetry(24);
9057
9324
  if (upstream.startsWith("sent")) {
@@ -9232,7 +9499,7 @@ try {
9232
9499
  try {
9233
9500
  coverageGapNowMs = Date.now();
9234
9501
  coverageGapLastHeartbeatTs = readLastHeartbeatTsMs();
9235
- coverageGapHostBootTs = hostBootTimeMs(coverageGapNowMs, os3.uptime());
9502
+ coverageGapHostBootTs = hostBootTimeMs(coverageGapNowMs, os4.uptime());
9236
9503
  const rawThreshold = Number(process.env.EXE_COVERAGE_GAP_THRESHOLD_MS);
9237
9504
  coverageGap = assessCoverageGap({
9238
9505
  lastHeartbeatTs: coverageGapLastHeartbeatTs,
@@ -9289,7 +9556,7 @@ try {
9289
9556
  });
9290
9557
  }
9291
9558
  try {
9292
- const { initOrgPartnerRuntime } = await import("../org-partner-runtime-RNNUL5IN.js");
9559
+ const { initOrgPartnerRuntime } = await import("../org-partner-runtime-WLZAZJIY.js");
9293
9560
  await initOrgPartnerRuntime();
9294
9561
  } catch (err) {
9295
9562
  process.stderr.write(