@askexenow/exe-os 0.9.302 → 0.9.310

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 (311) hide show
  1. package/deploy/compose/.env.example +8 -2
  2. package/deploy/compose/README.md +7 -3
  3. package/deploy/compose/add-routes.sh +107 -0
  4. package/deploy/compose/docker-compose.yml +91 -18
  5. package/deploy/compose/gateway-watchdog.sh +223 -0
  6. package/deploy/compose/generate-env.ts +16 -4
  7. package/deploy/compose/setup.sh +7 -8
  8. package/deploy/stack-manifests/v0.9.json +125 -4
  9. package/dist/{active-agent-ODI6GGVD.js → active-agent-ORX47ZKW.js} +4 -3
  10. package/dist/{active-agent-GGQAP4QE.js → active-agent-S5T2YMOR.js} +4 -3
  11. package/dist/{agentic-ontology-M7T72M6V.js → agentic-ontology-6KBAXLSJ.js} +1 -1
  12. package/dist/{backfill-metadata-GSZP2BEW.js → backfill-metadata-FV7GX6AS.js} +5 -4
  13. package/dist/{behaviors-JM6KFSXL.js → behaviors-47CPEKJ7.js} +6 -5
  14. package/dist/bin/agentic-ontology-backfill.js +6 -5
  15. package/dist/bin/agentic-reflection-backfill.js +7 -6
  16. package/dist/bin/agentic-semantic-label.js +6 -5
  17. package/dist/bin/backfill-conversations.js +8 -7
  18. package/dist/bin/backfill-responses.js +8 -7
  19. package/dist/bin/backfill-vectors.js +10 -9
  20. package/dist/bin/bulk-sync-postgres.js +14 -13
  21. package/dist/bin/cc-doctor.js +5 -4
  22. package/dist/bin/cleanup-stale-review-tasks.js +13 -12
  23. package/dist/bin/cli.js +20 -17
  24. package/dist/bin/deferred-daemon-restart.js +4 -4
  25. package/dist/bin/exe-agent-config.js +3 -2
  26. package/dist/bin/exe-agent.js +12 -11
  27. package/dist/bin/exe-assign.js +10 -9
  28. package/dist/bin/exe-boot.js +21 -20
  29. package/dist/bin/exe-call.js +5 -4
  30. package/dist/bin/exe-cloud.js +14 -13
  31. package/dist/bin/exe-config-dump.js +525 -0
  32. package/dist/bin/exe-dispatch.js +13 -12
  33. package/dist/bin/exe-doctor.js +2 -2
  34. package/dist/bin/exe-export-behaviors.js +8 -7
  35. package/dist/bin/exe-forget.js +7 -6
  36. package/dist/bin/exe-gateway.js +22 -11
  37. package/dist/bin/exe-healthcheck.js +7 -4
  38. package/dist/bin/exe-heartbeat.js +13 -12
  39. package/dist/bin/exe-kill.js +16 -15
  40. package/dist/bin/exe-launch-agent.js +41 -25
  41. package/dist/bin/exe-new-employee.js +9 -8
  42. package/dist/bin/exe-pending-messages.js +14 -13
  43. package/dist/bin/exe-pending-notifications.js +13 -12
  44. package/dist/bin/exe-pending-reviews.js +13 -12
  45. package/dist/bin/exe-preflight.js +108 -0
  46. package/dist/bin/exe-rename.js +5 -4
  47. package/dist/bin/exe-review.js +15 -14
  48. package/dist/bin/exe-search-quality.js +282 -0
  49. package/dist/bin/exe-search.js +6 -5
  50. package/dist/bin/exe-session-cleanup.js +18 -17
  51. package/dist/bin/exe-settings.js +15 -14
  52. package/dist/bin/exe-start-codex.js +13 -12
  53. package/dist/bin/exe-start-opencode.js +9 -8
  54. package/dist/bin/exe-status.js +14 -13
  55. package/dist/bin/exe-support.js +4 -4
  56. package/dist/bin/exe-team.js +4 -3
  57. package/dist/bin/exe-timers.js +237 -0
  58. package/dist/bin/git-sweep.js +14 -13
  59. package/dist/bin/graph-backfill.js +7 -6
  60. package/dist/bin/graph-export.js +6 -5
  61. package/dist/bin/import-history.js +10 -9
  62. package/dist/bin/install-launchd.js +5 -2
  63. package/dist/bin/install.js +16 -15
  64. package/dist/bin/intercom-check.js +4 -4
  65. package/dist/bin/mcp-sessions.js +2 -2
  66. package/dist/bin/orchestration-metrics.js +5 -4
  67. package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
  68. package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
  69. package/dist/bin/prune-orphan-chunks.js +43 -10
  70. package/dist/bin/scan-tasks.js +13 -12
  71. package/dist/bin/setup.js +1 -1
  72. package/dist/bin/shard-migrate.js +5 -4
  73. package/dist/bin/stack-update.js +30 -5
  74. package/dist/bin/vps-health-gate.js +1 -1
  75. package/dist/{capability-cards-BCTFKT4G.js → capability-cards-WQVY7WSS.js} +3 -2
  76. package/dist/{capacity-monitor-B4S3XEDO.js → capacity-monitor-BUKYPSWR.js} +14 -13
  77. package/dist/{catchup-brief-I35KHK62.js → catchup-brief-X5IVQAOH.js} +16 -15
  78. package/dist/{chunk-74TUYU5A.js → chunk-255DIG4B.js} +1 -1
  79. package/dist/{chunk-CXKR5Z5F.js → chunk-2EJ636HI.js} +4 -0
  80. package/dist/{chunk-ST3X3YMZ.js → chunk-2NGPZCWX.js} +4 -4
  81. package/dist/{chunk-LD2JKEJT.js → chunk-2NVEKSSP.js} +7 -7
  82. package/dist/{chunk-V6P7TPPA.js → chunk-2UVN2NBN.js} +148 -2
  83. package/dist/{chunk-OZRO37JW.js → chunk-3KH6GXXX.js} +2 -2
  84. package/dist/{chunk-IMJNYREY.js → chunk-43R2GILO.js} +1 -1
  85. package/dist/{chunk-6X2YNVLB.js → chunk-4BANMHJ5.js} +3 -3
  86. package/dist/{chunk-QNJPDIWY.js → chunk-4L4R6AQJ.js} +1 -1
  87. package/dist/{chunk-QWLPAEG5.js → chunk-4Q5VNQTV.js} +3 -3
  88. package/dist/{chunk-VLSYKMCJ.js → chunk-4RJJ5FJ2.js} +14 -2
  89. package/dist/{chunk-4AN6KMVG.js → chunk-5DPE7B7K.js} +1 -1
  90. package/dist/{chunk-H7ZNSQ2E.js → chunk-62UZWGFX.js} +2 -2
  91. package/dist/{chunk-ZQ2QHGWE.js → chunk-66JPZELX.js} +20 -24
  92. package/dist/{chunk-BUGMW7YF.js → chunk-6LNSZADA.js} +11 -11
  93. package/dist/{chunk-PBCRUNIK.js → chunk-6OD2RVIA.js} +492 -157
  94. package/dist/chunk-7ODTYODO.js +350 -0
  95. package/dist/{chunk-5YL4Y27D.js → chunk-7WDIGRSO.js} +1 -1
  96. package/dist/{chunk-WIL6LXNG.js → chunk-AC6DKMVS.js} +1 -1
  97. package/dist/{chunk-HZEAAKCR.js → chunk-B2J3BBJC.js} +3 -3
  98. package/dist/{chunk-LE7CDIOA.js → chunk-BUOMSIXH.js} +1 -1
  99. package/dist/{chunk-XKGNKH6V.js → chunk-DFUCFLZH.js} +1 -1
  100. package/dist/{chunk-U724Z3S3.js → chunk-DKHBMIVE.js} +100 -37
  101. package/dist/{chunk-MY36XDUK.js → chunk-DNFU56ZS.js} +1 -1
  102. package/dist/{chunk-GSWGOGP5.js → chunk-EOS7VPVT.js} +5 -5
  103. package/dist/{chunk-P33JVGSP.js → chunk-FM7XZDZI.js} +1 -1
  104. package/dist/chunk-G6EJKYK3.js +33 -0
  105. package/dist/{chunk-OMCNFTSI.js → chunk-GMZMBLHT.js} +1 -1
  106. package/dist/{chunk-4LZ54YGA.js → chunk-GSY6HL3T.js} +5 -5
  107. package/dist/{chunk-OVKNFTCL.js → chunk-HED6D5KR.js} +132 -21
  108. package/dist/{chunk-ALH6QLYF.js → chunk-HQODUV3G.js} +2 -2
  109. package/dist/{chunk-US64UR5O.js → chunk-IIHE3FNC.js} +3 -3
  110. package/dist/{chunk-H2ISTRWU.js → chunk-IRIPGGGL.js} +1 -1
  111. package/dist/{chunk-Z3EXECOX.js → chunk-ISILDO7P.js} +1 -1
  112. package/dist/{chunk-6ERZFDBS.js → chunk-IZPO6IOZ.js} +1 -1
  113. package/dist/{chunk-W65Z4SJS.js → chunk-J3QZPDNH.js} +1 -1
  114. package/dist/{chunk-3IJCP6ZH.js → chunk-JDYO76PI.js} +1 -1
  115. package/dist/{chunk-ORNKGGFX.js → chunk-JNARUXDC.js} +1 -1
  116. package/dist/{chunk-VME3UH4D.js → chunk-JV225JBX.js} +1 -1
  117. package/dist/{chunk-EI7PBUIA.js → chunk-JZW5AOWI.js} +1 -1
  118. package/dist/{chunk-TLOILHSL.js → chunk-K7KBAJQL.js} +36 -18
  119. package/dist/{chunk-RHMWSUJB.js → chunk-KAVUTP5G.js} +2 -2
  120. package/dist/{chunk-7FNELLMX.js → chunk-KPVVTHPK.js} +8 -8
  121. package/dist/{chunk-35U72CD2.js → chunk-KSMITUGY.js} +3 -3
  122. package/dist/{chunk-D6UICP3C.js → chunk-LMX7UKGX.js} +81 -3
  123. package/dist/{chunk-7ZWC5HVG.js → chunk-MTIJ2NXY.js} +1 -1
  124. package/dist/{chunk-KVHPBQV4.js → chunk-NCC3F6GM.js} +1 -1
  125. package/dist/{chunk-AYMSIV7X.js → chunk-NIZQ3CIS.js} +1 -1
  126. package/dist/{chunk-LTI2DLHY.js → chunk-OBJXZII2.js} +2 -2
  127. package/dist/{chunk-WHOT5NZ7.js → chunk-OR3TAZL3.js} +14 -2
  128. package/dist/{chunk-RQUHAXMM.js → chunk-PHFPIUWU.js} +2 -0
  129. package/dist/{chunk-N76VTMMF.js → chunk-PMEOSD6S.js} +2 -2
  130. package/dist/{chunk-TCJEFW5V.js → chunk-PPXQE7AS.js} +4 -4
  131. package/dist/{chunk-KHZQVLNZ.js → chunk-QE7UVQDP.js} +46 -0
  132. package/dist/{chunk-SXJACGQ5.js → chunk-QEGXNJGR.js} +4 -4
  133. package/dist/{chunk-W3E4VEEJ.js → chunk-RPBTYQKJ.js} +1 -1
  134. package/dist/chunk-RQ7OVXUZ.js +81 -0
  135. package/dist/{chunk-7L2EV3XX.js → chunk-RVXWGPD3.js} +39 -6
  136. package/dist/{chunk-YNALY3SX.js → chunk-RZJ6DXVE.js} +1 -1
  137. package/dist/{chunk-P3SIFDES.js → chunk-SCYWCWKY.js} +16 -4
  138. package/dist/{chunk-7I43GVER.js → chunk-SOT23KWW.js} +3 -3
  139. package/dist/{chunk-T62GAN7I.js → chunk-SPOXL7HF.js} +7 -7
  140. package/dist/{chunk-3YJMI422.js → chunk-TN2YCFQE.js} +4 -4
  141. package/dist/{chunk-YMSWCERY.js → chunk-U63BZI2B.js} +3 -3
  142. package/dist/{chunk-KA5RK5HZ.js → chunk-V42BSVX6.js} +2 -2
  143. package/dist/{chunk-PJTRAFL4.js → chunk-V4BW5HFQ.js} +3 -3
  144. package/dist/{chunk-4FG6IX7U.js → chunk-VFSYVQX4.js} +1 -1
  145. package/dist/chunk-VQRTO7IS.js +290 -0
  146. package/dist/{chunk-OR7J7TIA.js → chunk-VT6P7FV4.js} +1 -1
  147. package/dist/{chunk-BEIYF4NS.js → chunk-W2J2RF5N.js} +3 -3
  148. package/dist/{chunk-Y5ASPRP7.js → chunk-WBJXJ2R4.js} +17 -13
  149. package/dist/chunk-WCGNCH3Q.js +72 -0
  150. package/dist/{chunk-2LJDLQNO.js → chunk-WJ2PZGRV.js} +1 -1
  151. package/dist/{chunk-AAPPSMPH.js → chunk-WZBUKC5N.js} +1 -1
  152. package/dist/{chunk-RO7EXVSJ.js → chunk-X4AFBL4N.js} +1 -1
  153. package/dist/{chunk-BR74NYEF.js → chunk-XV5HRIXG.js} +5 -5
  154. package/dist/chunk-XXJRZ75E.js +43 -0
  155. package/dist/{chunk-VDHUHXFF.js → chunk-XYG722JW.js} +2 -2
  156. package/dist/{chunk-MM7SWUQ4.js → chunk-YB7U4WTY.js} +4 -4
  157. package/dist/{chunk-RMRZXPUU.js → chunk-Z6H6Y4BS.js} +1 -1
  158. package/dist/{token-budget-UMHRRDBT.js → chunk-ZOVHXTGC.js} +2 -9
  159. package/dist/{chunk-HNLBHP6P.js → chunk-ZZXADKAP.js} +3 -3
  160. package/dist/{co-activation-OKAHEMPE.js → co-activation-WN25AJOC.js} +3 -2
  161. package/dist/{co-occurrence-IHSPB53O.js → co-occurrence-YP2Q3OEA.js} +5 -4
  162. package/dist/{code-context-index-KGY4LKCA.js → code-context-index-ZWONKBKX.js} +4 -4
  163. package/dist/{conversation-entity-extractor-KXJSHRGJ.js → conversation-entity-extractor-KYOBXNID.js} +2 -2
  164. package/dist/{crdt-sync-K2G3C6XY.js → crdt-sync-ZFIFL2QM.js} +1 -1
  165. package/dist/{crm-webhook-ERZSQ3CW.js → crm-webhook-DGPHULOO.js} +2 -2
  166. package/dist/{cto-delegation-gate-ZCJ53LBQ.js → cto-delegation-gate-OF2A3TSS.js} +12 -11
  167. package/dist/daemon-auth-N6P2MZAV.js +17 -0
  168. package/dist/{daemon-orchestration-V6HALVDS.js → daemon-orchestration-G4RRTPP7.js} +16 -15
  169. package/dist/daemon-ready-signal-3L2MJT7C.js +13 -0
  170. package/dist/{db-backup-VZHSFUVA.js → db-backup-EORG4LBO.js} +1 -1
  171. package/dist/{doc-graph-extractor-LQ2IFND2.js → doc-graph-extractor-APZS3DFD.js} +5 -4
  172. package/dist/{dreaming-QAKUASYV.js → dreaming-Q4E3WBGY.js} +13 -12
  173. package/dist/{exe-drift-H3UWNFFY.js → exe-drift-CI5R6GUT.js} +4 -3
  174. package/dist/{exe-export-MN5D4JMT.js → exe-export-HQIQASIT.js} +7 -6
  175. package/dist/{exe-import-IFFMEVD7.js → exe-import-ULZK56WC.js} +7 -6
  176. package/dist/{exe-key-RSZC72QK.js → exe-key-ILNSBGRN.js} +5 -4
  177. package/dist/{exe-snapshot-I622MPLS.js → exe-snapshot-RUZTWZOF.js} +16 -15
  178. package/dist/{factory-CTFAGZUA.js → factory-YHQZ6RZZ.js} +14 -6
  179. package/dist/{fast-db-init-QEFVT7Q3.js → fast-db-init-KNJRL7T3.js} +1 -1
  180. package/dist/{founder-context-3SOKEW76.js → founder-context-QCTMEK66.js} +2 -2
  181. package/dist/gateway/index.js +12 -11
  182. package/dist/{git-staleness-E7RPQA5U.js → git-staleness-KIA5YI4H.js} +3 -2
  183. package/dist/{git-task-sweep-D3A2C5BW.js → git-task-sweep-WH6QE7HL.js} +13 -12
  184. package/dist/{global-procedures-POG4V6IK.js → global-procedures-SYZZCGDS.js} +4 -3
  185. package/dist/{graph-auto-extract-E7KALNWA.js → graph-auto-extract-J2TIWZEE.js} +5 -4
  186. package/dist/{graph-rag-3RZN7JR3.js → graph-rag-HITZZ63L.js} +2 -2
  187. package/dist/hooks/bug-report-worker.js +15 -14
  188. package/dist/hooks/codex-stop-task-finalizer.js +15 -14
  189. package/dist/hooks/commit-complete.js +15 -14
  190. package/dist/hooks/error-recall.js +8 -7
  191. package/dist/hooks/exe-heartbeat-hook.js +4 -3
  192. package/dist/hooks/ingest-worker.js +4 -4
  193. package/dist/hooks/ingest.js +8 -7
  194. package/dist/hooks/instructions-loaded.js +5 -4
  195. package/dist/hooks/manifest.json +20 -20
  196. package/dist/hooks/notification.js +5 -4
  197. package/dist/hooks/post-compact.js +14 -13
  198. package/dist/hooks/post-tool-combined.js +7 -7
  199. package/dist/hooks/pre-compact.js +19 -18
  200. package/dist/hooks/pre-tool-use.js +18 -17
  201. package/dist/hooks/prompt-submit.js +28 -27
  202. package/dist/hooks/session-end.js +24 -23
  203. package/dist/hooks/session-start.js +46 -22
  204. package/dist/hooks/stop.js +22 -21
  205. package/dist/hooks/subagent-stop.js +14 -13
  206. package/dist/hooks/summary-worker.js +22 -21
  207. package/dist/index.js +25 -23
  208. package/dist/{installer-IXUX73JN.js → installer-3NB3IBHF.js} +10 -9
  209. package/dist/{installer-RCUPPZ7Y.js → installer-IIJFCTMH.js} +10 -9
  210. package/dist/{installer-HDD6OH5Z.js → installer-PSDYMGN7.js} +7 -6
  211. package/dist/lib/cloud-sync.js +14 -13
  212. package/dist/lib/consolidation.js +8 -7
  213. package/dist/lib/database.js +3 -2
  214. package/dist/lib/db-daemon-client.js +4 -4
  215. package/dist/lib/db.js +3 -2
  216. package/dist/lib/device-registry.js +3 -1
  217. package/dist/lib/embedder.js +4 -4
  218. package/dist/lib/employee-templates.js +5 -4
  219. package/dist/lib/employees.js +3 -2
  220. package/dist/lib/exe-daemon-client.js +3 -3
  221. package/dist/lib/exe-daemon.js +256 -406
  222. package/dist/lib/hybrid-search.js +6 -5
  223. package/dist/lib/identity.js +3 -2
  224. package/dist/lib/license.js +2 -2
  225. package/dist/lib/messaging.js +13 -12
  226. package/dist/lib/reminders.js +4 -3
  227. package/dist/lib/schedules.js +6 -5
  228. package/dist/lib/session-registry.js +5 -4
  229. package/dist/lib/skill-learning.js +7 -6
  230. package/dist/lib/store.js +7 -4
  231. package/dist/lib/task-router.js +4 -3
  232. package/dist/lib/tasks.js +14 -13
  233. package/dist/lib/tmux-routing.js +16 -11
  234. package/dist/lib/token-spend.js +4 -3
  235. package/dist/{license-gate-V2UCK4KJ.js → license-gate-7SDHCJUO.js} +3 -3
  236. package/dist/mcp/register-tools.js +74 -73
  237. package/dist/mcp/server.js +97 -79
  238. package/dist/mcp/tools/complete-reminder.js +5 -4
  239. package/dist/mcp/tools/create-reminder.js +5 -4
  240. package/dist/mcp/tools/create-task.js +16 -15
  241. package/dist/mcp/tools/deactivate-behavior.js +8 -7
  242. package/dist/mcp/tools/list-reminders.js +5 -4
  243. package/dist/mcp/tools/list-tasks.js +16 -15
  244. package/dist/mcp/tools/send-message.js +15 -14
  245. package/dist/mcp/tools/update-task.js +15 -14
  246. package/dist/{mcp-http-config-7LFFPNGV.js → mcp-http-config-QSOVFXHW.js} +4 -3
  247. package/dist/mcp-tool-surface-CSPFXL3F.js +15 -0
  248. package/dist/{memory-cards-BGI6MJRN.js → memory-cards-II67WFL2.js} +3 -2
  249. package/dist/{memory-graph-extractor-DTRRNWHZ.js → memory-graph-extractor-PM4Q2KJG.js} +6 -5
  250. package/dist/{memory-poisoning-defense-MOCWJK6S.js → memory-poisoning-defense-ECXSX7HK.js} +3 -2
  251. package/dist/{memory-queue-client-DD4E5SIZ.js → memory-queue-client-HLURQEV6.js} +4 -4
  252. package/dist/{memory-reflection-UKKTGZYR.js → memory-reflection-PXF6YFDU.js} +3 -2
  253. package/dist/{notifications-AMJ2K3MM.js → notifications-UP7WQGG4.js} +12 -11
  254. package/dist/{orchestration-events-MB4QVHTD.js → orchestration-events-PZLLPCKY.js} +4 -3
  255. package/dist/orchestration-health-read-EJWVUARG.js +191 -0
  256. package/dist/{orchestrator-M7DJH6TN.js → orchestrator-PUT45J4O.js} +14 -13
  257. package/dist/{pipeline-router-4LT5YG5P.js → pipeline-router-5CRWKESM.js} +4 -3
  258. package/dist/{plan-limits-ENS7OJWP.js → plan-limits-SH2NDFNX.js} +6 -5
  259. package/dist/{project-boot-6W5JPGSB.js → project-boot-2TCPDZ4S.js} +25 -1
  260. package/dist/{projection-worker-WWXZK7QD.js → projection-worker-HWY37MNC.js} +2 -2
  261. package/dist/{prospective-memory-VNGLPMS6.js → prospective-memory-FQSVMCGG.js} +3 -2
  262. package/dist/{reranker-6XBS55FA.js → reranker-AALRMGMM.js} +1 -1
  263. package/dist/{retrieval-health-ATX5TIQ2.js → retrieval-health-PNWJSJNG.js} +1 -1
  264. package/dist/{review-polling-E4ALHTQE.js → review-polling-65JZUE3T.js} +13 -12
  265. package/dist/runtime/index.js +24 -22
  266. package/dist/{session-events-3J6APMKN.js → session-events-EJ3OSAA6.js} +13 -12
  267. package/dist/session-kill-telemetry-3HGM7SNQ.js +63 -0
  268. package/dist/{session-scope-E54VIYTJ.js → session-scope-JGDYAMJO.js} +12 -11
  269. package/dist/{setup-wizard-XV736U5D.js → setup-wizard-44LMFM2C.js} +1 -1
  270. package/dist/shared-rate-limit-store-QZPQEVE2.js +80 -0
  271. package/dist/{skill-refinement-FTURVWFN.js → skill-refinement-DUOO6B7V.js} +3 -2
  272. package/dist/{stack-release-JZVTSBJJ.js → stack-release-XYMKU7NT.js} +53 -4
  273. package/dist/{stack-update-BIK2QHOE.js → stack-update-XHQJRJEP.js} +5 -3
  274. package/dist/{steward-gate-YGU4VXPP.js → steward-gate-6NWRDLX2.js} +4 -3
  275. package/dist/{task-enforcement-GY3VTY6L.js → task-enforcement-UOULTGFB.js} +12 -11
  276. package/dist/{task-scope-PYOK7OQ6.js → task-scope-P5STKYAC.js} +12 -11
  277. package/dist/{tasks-crud-HLJEJ2UU.js → tasks-crud-24HMTULR.js} +12 -11
  278. package/dist/{tasks-notify-NGS3DWUJ.js → tasks-notify-LAIU7UUI.js} +13 -12
  279. package/dist/{tasks-review-BP5V2X34.js → tasks-review-AFJAU2DY.js} +12 -11
  280. package/dist/{telemetry-upload-AXYPFAPS.js → telemetry-upload-DWFGC2XJ.js} +8 -7
  281. package/dist/token-budget-4RFZKWGH.js +16 -0
  282. package/dist/{tool-capability-index-RHPVMMDD.js → tool-capability-index-ZEXBWKUZ.js} +1 -1
  283. package/dist/{tool-telemetry-BLSVABFJ.js → tool-telemetry-BS5JXM5M.js} +1 -1
  284. package/dist/tui/App.js +21 -20
  285. package/dist/{tui-data-EYPOFYLS.js → tui-data-UNO5B7PU.js} +12 -11
  286. package/dist/{worker-gate-SMFOBMMX.js → worker-gate-C6CTTYMD.js} +1 -1
  287. package/dist/{workflow-engine-TDJZ3TXB.js → workflow-engine-4W2KYCDV.js} +2 -2
  288. package/dist/{worktree-XISIYRM4.js → worktree-2CXY6NEB.js} +5 -4
  289. package/dist/{worktree-sweep-AS6GAR6X.js → worktree-sweep-K3CJFSUL.js} +6 -5
  290. package/package.json +9 -4
  291. package/release-notes.json +17 -88
  292. package/stack.release.json +51 -4
  293. package/dist/chunk-PHOQAVTK.js +0 -42
  294. package/dist/daemon-auth-BK7ON5ZH.js +0 -13
  295. package/dist/session-kill-telemetry-KOAHLRBT.js +0 -31
  296. package/dist/{chunk-XDE5IGBX.js → chunk-2NS3QRMJ.js} +0 -0
  297. package/dist/{chunk-JTMKRUX6.js → chunk-A2YZG4AD.js} +0 -0
  298. package/dist/{chunk-UZATXREL.js → chunk-AE74NOE6.js} +0 -0
  299. package/dist/{chunk-LUGWK6QB.js → chunk-FF5DA4XP.js} +3 -3
  300. /package/dist/{chunk-BGOMFGSW.js → chunk-GWPICNSO.js} +0 -0
  301. /package/dist/{chunk-NLHUA3YB.js → chunk-I3DPCSDG.js} +0 -0
  302. /package/dist/{chunk-YM3367VC.js → chunk-J3SR5MGG.js} +0 -0
  303. /package/dist/{chunk-FKFVNV7X.js → chunk-K4BKJJ4F.js} +0 -0
  304. /package/dist/{chunk-PTDBHQX7.js → chunk-MQCTK6EF.js} +0 -0
  305. /package/dist/{chunk-GBV5PV5T.js → chunk-QNXM2HXW.js} +0 -0
  306. /package/dist/{chunk-GZSG2ZOX.js → chunk-YUBTHJVV.js} +0 -0
  307. /package/dist/{core-memory-4OM7LR77.js → core-memory-OC5ITKKV.js} +0 -0
  308. /package/dist/{entity-boost-SFHIRXT5.js → entity-boost-NF3LE6OJ.js} +0 -0
  309. /package/dist/{message-queue-client-QTC3VHJT.js → message-queue-client-4VDU6BZY.js} +0 -0
  310. /package/dist/{oauth-server-BPN55EJM.js → oauth-server-EWUL7DMD.js} +0 -0
  311. /package/dist/{wiki-acl-45SIGG4O.js → wiki-acl-CONNF6ES.js} +0 -0
@@ -1,3 +1,7 @@
1
+ import {
2
+ clearDaemonReady,
3
+ writeDaemonReady
4
+ } from "../chunk-XXJRZ75E.js";
1
5
  import {
2
6
  pushNotifyAsync
3
7
  } from "../chunk-IBDPPBFK.js";
@@ -11,14 +15,20 @@ import {
11
15
  serializeResultSet
12
16
  } from "../chunk-QGGH7LOU.js";
13
17
  import {
14
- ensureDaemonToken
15
- } from "../chunk-PHOQAVTK.js";
18
+ ensureDaemonToken,
19
+ reconcileSessionAgentIdentity,
20
+ shouldEnforceSessionIdentity
21
+ } from "../chunk-RQ7OVXUZ.js";
16
22
  import {
17
23
  findScopedDuplicate,
18
24
  governMemoryRecord,
19
25
  schedulePostWriteMemoryHygiene
20
- } from "../chunk-PTDBHQX7.js";
26
+ } from "../chunk-MQCTK6EF.js";
21
27
  import "../chunk-Y25OJWOQ.js";
28
+ import {
29
+ consumeRestartIntent,
30
+ logRestartEvent
31
+ } from "../chunk-RVXWGPD3.js";
22
32
  import {
23
33
  DAEMON_RSS_RESTART_DEBOUNCE,
24
34
  DAEMON_RSS_STARTUP_GRACE_MS,
@@ -35,13 +45,16 @@ import {
35
45
  resolveEmbedWorkerRssKillMb,
36
46
  shouldRestartForRss
37
47
  } from "../chunk-7XGDTKHX.js";
38
- import {
39
- consumeRestartIntent,
40
- logRestartEvent
41
- } from "../chunk-7L2EV3XX.js";
42
48
  import {
43
49
  resolveEmbeddingsEnabled
44
- } from "../chunk-RQUHAXMM.js";
50
+ } from "../chunk-PHFPIUWU.js";
51
+ import {
52
+ logBoot,
53
+ logCrash,
54
+ logDaemonHealth,
55
+ logHeartbeat,
56
+ logShutdown
57
+ } from "../chunk-VQRTO7IS.js";
45
58
  import {
46
59
  getEventLoopLagMs,
47
60
  isEventLoopDegraded,
@@ -60,16 +73,16 @@ import "../chunk-65DBIEM2.js";
60
73
  import "../chunk-MLKGABMK.js";
61
74
 
62
75
  // src/lib/exe-daemon.ts
63
- import os3 from "os";
76
+ import os2 from "os";
64
77
  import net from "net";
65
- import v82 from "v8";
78
+ import v8 from "v8";
66
79
  import { createServer as createHttpServer, request as httpRequest } from "http";
67
80
  import { randomUUID } from "crypto";
68
- import { writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, mkdirSync as mkdirSync3, existsSync as existsSync4, readFileSync as readFileSync3, chmodSync, readdirSync, renameSync as renameSync2, statSync as statSync2 } from "fs";
81
+ import { writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, mkdirSync as mkdirSync2, existsSync as existsSync3, readFileSync as readFileSync3, chmodSync, readdirSync, renameSync, statSync } from "fs";
69
82
  import { writeFile } from "fs/promises";
70
83
  import { execSync as execSyncNode, execFile as execFileNode } from "child_process";
71
84
  import { promisify } from "util";
72
- import path4 from "path";
85
+ import path3 from "path";
73
86
  import { fork } from "child_process";
74
87
  import { Worker } from "worker_threads";
75
88
 
@@ -256,279 +269,6 @@ function initMetrics() {
256
269
  });
257
270
  }
258
271
 
259
- // src/lib/daemon-health-log.ts
260
- import { appendFileSync, mkdirSync, existsSync as existsSync2, statSync, renameSync } from "fs";
261
- import path2 from "path";
262
- import os from "os";
263
-
264
- // src/lib/process-monitor.ts
265
- import { execSync } from "child_process";
266
- import v8 from "v8";
267
- var _lastCpuUsage = null;
268
- var _lastCpuTime = 0;
269
- function getDaemonCpuPercent() {
270
- const now = Date.now();
271
- const usage = process.cpuUsage(_lastCpuUsage ?? void 0);
272
- if (_lastCpuTime === 0) {
273
- _lastCpuUsage = process.cpuUsage();
274
- _lastCpuTime = now;
275
- return 0;
276
- }
277
- const elapsedMs = now - _lastCpuTime;
278
- if (elapsedMs === 0) return 0;
279
- const cpuMs = (usage.user + usage.system) / 1e3;
280
- const percent = cpuMs / elapsedMs * 100;
281
- _lastCpuUsage = process.cpuUsage();
282
- _lastCpuTime = now;
283
- return Math.round(percent * 10) / 10;
284
- }
285
- function getProcessStats(pid) {
286
- try {
287
- const output = execSync(
288
- `ps -p ${pid} -o pid=,ppid=,%cpu=,rss=,vsz=,etime=,args= 2>/dev/null`,
289
- { encoding: "utf8", timeout: 3e3 }
290
- ).trim();
291
- if (!output) return null;
292
- return parseProcessLine(output);
293
- } catch {
294
- return null;
295
- }
296
- }
297
- function getChildProcesses(parentPid) {
298
- try {
299
- const output = execSync(
300
- `pgrep -P ${parentPid} 2>/dev/null || true`,
301
- { encoding: "utf8", timeout: 3e3 }
302
- ).trim();
303
- if (!output) return [];
304
- const childPids = output.split("\n").map(Number).filter(Boolean);
305
- const children = [];
306
- for (const pid of childPids) {
307
- const stats = getProcessStats(pid);
308
- if (stats) children.push(stats);
309
- children.push(...getChildProcesses(pid));
310
- }
311
- return children;
312
- } catch {
313
- return [];
314
- }
315
- }
316
- function getOrphanedProcesses() {
317
- const EXE_PATTERNS = [
318
- "exe-os/dist",
319
- "exe-mem/dist",
320
- "@askexenow/exe-os"
321
- ];
322
- try {
323
- const output = execSync(
324
- "ps -eo pid,ppid,%cpu,rss,vsz,etime,args 2>/dev/null",
325
- { encoding: "utf8", timeout: 5e3 }
326
- );
327
- const orphans = [];
328
- for (const line of output.split("\n").slice(1)) {
329
- const stats = parseProcessLine(line.trim());
330
- if (!stats) continue;
331
- if (stats.ppid !== 1) continue;
332
- if (stats.pid === process.pid) continue;
333
- if (!EXE_PATTERNS.some((p) => stats.command.includes(p))) continue;
334
- orphans.push(stats);
335
- }
336
- return orphans;
337
- } catch {
338
- return [];
339
- }
340
- }
341
- function parseProcessLine(line) {
342
- const match = line.match(/^\s*(\d+)\s+(\d+)\s+([\d.]+)\s+(\d+)\s+(\d+)\s+([\d:-]+)\s+(.+)$/);
343
- if (!match) return null;
344
- return {
345
- pid: parseInt(match[1], 10),
346
- ppid: parseInt(match[2], 10),
347
- cpu: parseFloat(match[3]),
348
- mem: Math.round(parseInt(match[4], 10) / 1024),
349
- // RSS KB → MB
350
- rss: Math.round(parseInt(match[4], 10) / 1024),
351
- vsz: Math.round(parseInt(match[5], 10) / 1024),
352
- elapsed: match[6],
353
- command: match[7].slice(0, 200)
354
- };
355
- }
356
- function takeProcessSnapshot() {
357
- const daemon = getProcessStats(process.pid);
358
- const children = getChildProcesses(process.pid);
359
- const orphans = getOrphanedProcesses();
360
- const allProcs = [daemon, ...children].filter(Boolean);
361
- const totalCpu = allProcs.reduce((sum, p) => sum + p.cpu, 0);
362
- const totalMemMb = allProcs.reduce((sum, p) => sum + p.rss, 0);
363
- return {
364
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
365
- daemon,
366
- children,
367
- orphans,
368
- totalCpu: Math.round(totalCpu * 10) / 10,
369
- totalMemMb
370
- };
371
- }
372
- function formatSnapshotSummary(snap) {
373
- return {
374
- daemonCpu: snap.daemon?.cpu ?? 0,
375
- daemonRssMb: snap.daemon?.rss ?? 0,
376
- childCount: snap.children.length,
377
- childTotalCpu: Math.round(snap.children.reduce((s, c) => s + c.cpu, 0) * 10) / 10,
378
- childTotalRssMb: snap.children.reduce((s, c) => s + c.rss, 0),
379
- orphanCount: snap.orphans.length,
380
- orphanPids: snap.orphans.map((o) => o.pid),
381
- totalCpu: snap.totalCpu,
382
- totalMemMb: snap.totalMemMb
383
- };
384
- }
385
- var CPU_ALERT_THRESHOLD_PCT = 80;
386
- var CPU_ALERT_SUSTAINED_SAMPLES = 3;
387
- var _highCpuSamples = 0;
388
- function checkCpuAlert(cpuPercent) {
389
- if (cpuPercent >= CPU_ALERT_THRESHOLD_PCT) {
390
- _highCpuSamples++;
391
- if (_highCpuSamples >= CPU_ALERT_SUSTAINED_SAMPLES) {
392
- return `Daemon CPU sustained at ${cpuPercent}% for ${_highCpuSamples} samples`;
393
- }
394
- } else {
395
- _highCpuSamples = 0;
396
- }
397
- return null;
398
- }
399
- var HEAP_ALERT_THRESHOLD_PCT = 80;
400
- var HEAP_ALERT_SUSTAINED_SAMPLES = 6;
401
- var _highHeapSamples = 0;
402
- var _heapSizeLimit = null;
403
- function getHeapSizeLimit() {
404
- if (_heapSizeLimit !== null) return _heapSizeLimit;
405
- try {
406
- _heapSizeLimit = v8.getHeapStatistics().heap_size_limit;
407
- } catch {
408
- _heapSizeLimit = 4 * 1024 * 1024 * 1024;
409
- }
410
- return _heapSizeLimit;
411
- }
412
- function checkHeapAlert() {
413
- const mem = process.memoryUsage();
414
- const limit = getHeapSizeLimit();
415
- const usedPct = limit > 0 ? mem.heapUsed / limit * 100 : 0;
416
- if (usedPct >= HEAP_ALERT_THRESHOLD_PCT) {
417
- _highHeapSamples++;
418
- if (_highHeapSamples >= HEAP_ALERT_SUSTAINED_SAMPLES) {
419
- return `V8 heap pressure: ${Math.round(usedPct)}% of limit (${Math.round(mem.heapUsed / 1024 / 1024)}MB / ${Math.round(limit / 1024 / 1024)}MB) for ${_highHeapSamples} samples \u2014 OOM risk`;
420
- }
421
- } else {
422
- _highHeapSamples = 0;
423
- }
424
- return null;
425
- }
426
-
427
- // src/lib/daemon-health-log.ts
428
- var LOG_DIR = path2.join(os.homedir(), ".exe-os", "logs");
429
- var LOG_FILE = path2.join(LOG_DIR, "daemon-health.log");
430
- var MAX_LOG_SIZE = 5 * 1024 * 1024;
431
- var dirChecked = false;
432
- function ensureDir() {
433
- if (dirChecked) return;
434
- if (!existsSync2(LOG_DIR)) mkdirSync(LOG_DIR, { recursive: true });
435
- dirChecked = true;
436
- }
437
- function maybeRotate() {
438
- try {
439
- if (!existsSync2(LOG_FILE)) return;
440
- const stat = statSync(LOG_FILE);
441
- if (stat.size > MAX_LOG_SIZE) {
442
- const rotated = `${LOG_FILE}.1`;
443
- try {
444
- renameSync(LOG_FILE, rotated);
445
- } catch {
446
- }
447
- }
448
- } catch {
449
- }
450
- }
451
- function logDaemonHealth(entry) {
452
- try {
453
- ensureDir();
454
- maybeRotate();
455
- const record = {
456
- ts: (/* @__PURE__ */ new Date()).toISOString(),
457
- event: entry.event,
458
- pid: entry.pid,
459
- msg: entry.message,
460
- ...entry.data && { data: entry.data },
461
- ...entry.stack && { stack: entry.stack }
462
- };
463
- appendFileSync(LOG_FILE, JSON.stringify(record) + "\n");
464
- } catch {
465
- }
466
- }
467
- function logBoot(extra) {
468
- logDaemonHealth({
469
- event: "boot",
470
- pid: process.pid,
471
- message: "Daemon starting",
472
- data: {
473
- nodeVersion: process.version,
474
- platform: process.platform,
475
- arch: process.arch,
476
- totalMem: `${Math.round(os.totalmem() / 1024 / 1024 / 1024)}GB`,
477
- freeMem: `${Math.round(os.freemem() / 1024 / 1024 / 1024)}GB`,
478
- uptime: `${Math.round(os.uptime() / 3600)}h`,
479
- ...extra
480
- }
481
- });
482
- }
483
- function logShutdown(reason, signal) {
484
- logDaemonHealth({
485
- event: signal ? "signal" : "shutdown",
486
- pid: process.pid,
487
- message: `Daemon shutting down: ${reason}`,
488
- data: { reason, ...signal && { signal } }
489
- });
490
- }
491
- function logCrash(error, event = "crash") {
492
- const err = error instanceof Error ? error : new Error(String(error));
493
- logDaemonHealth({
494
- event,
495
- pid: process.pid,
496
- message: `FATAL: ${err.message}`,
497
- stack: err.stack
498
- });
499
- }
500
- function logHeartbeat(data) {
501
- const mem = process.memoryUsage();
502
- let processData = {};
503
- try {
504
- const cpuPct = getDaemonCpuPercent();
505
- const snapshot = takeProcessSnapshot();
506
- processData = formatSnapshotSummary(snapshot);
507
- const cpuAlertMsg = checkCpuAlert(cpuPct);
508
- if (cpuAlertMsg) {
509
- logDaemonHealth({ event: "cpu_pressure", pid: process.pid, message: cpuAlertMsg, data: processData });
510
- }
511
- const heapAlertMsg = checkHeapAlert();
512
- if (heapAlertMsg) {
513
- logDaemonHealth({ event: "memory_pressure", pid: process.pid, message: heapAlertMsg, data: processData });
514
- }
515
- } catch {
516
- }
517
- logDaemonHealth({
518
- event: "heartbeat",
519
- pid: process.pid,
520
- message: "alive",
521
- data: {
522
- rss: `${Math.round(mem.rss / 1024 / 1024)}MB`,
523
- heapUsed: `${Math.round(mem.heapUsed / 1024 / 1024)}MB`,
524
- heapTotal: `${Math.round(mem.heapTotal / 1024 / 1024)}MB`,
525
- uptimeSec: Math.round(process.uptime()),
526
- ...processData,
527
- ...data
528
- }
529
- });
530
- }
531
-
532
272
  // src/lib/mcp-init-grace.ts
533
273
  var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
534
274
  async function awaitPendingMcpInit(ownerKey, requestSessionId, deps, transientMatch) {
@@ -584,17 +324,17 @@ async function awaitPendingMcpInit(ownerKey, requestSessionId, deps, transientMa
584
324
  }
585
325
 
586
326
  // src/lib/daemon-restart-backoff.ts
587
- import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
327
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, unlinkSync, mkdirSync } from "fs";
588
328
  import { createHash } from "crypto";
589
- import path3 from "path";
590
- import os2 from "os";
329
+ import path2 from "path";
330
+ import os from "os";
591
331
  var BASE_DELAY_MS = 2e3;
592
332
  var MAX_DELAY_MS = 5 * 6e4;
593
333
  var FAILURE_THRESHOLD = 10;
594
334
  var HEALTHY_RESET_MS = 30 * 6e4;
595
335
  var FAST_FAILURE_MS = HEALTHY_RESET_MS;
596
- var EXE_DIR = path3.join(os2.homedir(), ".exe-os");
597
- var STATE_DIR = path3.join(EXE_DIR, "worker-backoff");
336
+ var EXE_DIR = path2.join(os.homedir(), ".exe-os");
337
+ var STATE_DIR = path2.join(EXE_DIR, "worker-backoff");
598
338
  function computeEmbedConfigFingerprint(inputs) {
599
339
  const canonical = [
600
340
  `enabled=${inputs.embeddingsEnabled ? 1 : 0}`,
@@ -625,12 +365,12 @@ function evaluateRestart(prev, uptimeMs, threshold = FAILURE_THRESHOLD, fastFail
625
365
  }
626
366
  function stateFile(workerKey) {
627
367
  const safe = workerKey.replace(/[^a-zA-Z0-9_-]/g, "_");
628
- return path3.join(STATE_DIR, `${safe}.json`);
368
+ return path2.join(STATE_DIR, `${safe}.json`);
629
369
  }
630
370
  function loadBackoffState(workerKey) {
631
371
  try {
632
372
  const f = stateFile(workerKey);
633
- if (!existsSync3(f)) return null;
373
+ if (!existsSync2(f)) return null;
634
374
  const parsed = JSON.parse(readFileSync2(f, "utf8"));
635
375
  if (typeof parsed.consecutiveFailures !== "number" || typeof parsed.lastFailureAt !== "number") {
636
376
  return null;
@@ -646,7 +386,7 @@ function loadBackoffState(workerKey) {
646
386
  }
647
387
  function saveBackoffState(workerKey, state) {
648
388
  try {
649
- if (!existsSync3(STATE_DIR)) mkdirSync2(STATE_DIR, { recursive: true });
389
+ if (!existsSync2(STATE_DIR)) mkdirSync(STATE_DIR, { recursive: true });
650
390
  writeFileSync2(stateFile(workerKey), JSON.stringify(state), { mode: 384 });
651
391
  } catch {
652
392
  }
@@ -654,7 +394,7 @@ function saveBackoffState(workerKey, state) {
654
394
  function resetBackoffState(workerKey) {
655
395
  try {
656
396
  const f = stateFile(workerKey);
657
- if (existsSync3(f)) unlinkSync(f);
397
+ if (existsSync2(f)) unlinkSync(f);
658
398
  } catch {
659
399
  }
660
400
  }
@@ -712,8 +452,8 @@ function measureSpan(prev) {
712
452
  }
713
453
 
714
454
  // src/lib/exe-daemon.ts
715
- var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path4.join(EXE_AI_DIR, "exed.sock");
716
- var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path4.join(EXE_AI_DIR, "exed.pid");
455
+ var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path3.join(EXE_AI_DIR, "exed.sock");
456
+ var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path3.join(EXE_AI_DIR, "exed.pid");
717
457
  var MODEL_FILE = resolveEmbedModelFile(MODELS_DIR);
718
458
  var SERVER_MODE = /^(1|true|yes|on)$/i.test(process.env.EXE_SERVER_MODE ?? "");
719
459
  var IDLE_TIMEOUT_MS = 0;
@@ -1007,9 +747,9 @@ function enqueue(queue, entry) {
1007
747
  }
1008
748
  queue.push(entry);
1009
749
  }
1010
- var OOM_MARKER_PATH = path4.join(os3.homedir(), ".exe-os", "embedding-oom-marker");
1011
- var EMBED_TIMEOUT_MARKER_PATH = path4.join(os3.homedir(), ".exe-os", "embedding-timeout-marker");
1012
- var EMBEDDINGS_OPT_IN_PATH = path4.join(os3.homedir(), ".exe-os", "embeddings-enabled");
750
+ var OOM_MARKER_PATH = path3.join(os2.homedir(), ".exe-os", "embedding-oom-marker");
751
+ var EMBED_TIMEOUT_MARKER_PATH = path3.join(os2.homedir(), ".exe-os", "embedding-timeout-marker");
752
+ var EMBEDDINGS_OPT_IN_PATH = path3.join(os2.homedir(), ".exe-os", "embeddings-enabled");
1013
753
  var MIN_FREE_MEM_BYTES = 2 * 1024 ** 3;
1014
754
  var EMBED_WORKER_HEAP_MB = resolveEmbedWorkerHeapMb(process.env.EXE_EMBED_WORKER_HEAP_MB);
1015
755
  var EMBED_WORKER_RSS_KILL_MB = resolveEmbedWorkerRssKillMb(
@@ -1027,10 +767,10 @@ function resolveEmbeddingsOptIn() {
1027
767
  var MAX_SMALL_TOTAL_BYTES = 16 * 1024 ** 3;
1028
768
  var OOM_MARKER_TTL_MS = 1 * 60 * 60 * 1e3;
1029
769
  var EMBED_RESPAWN_RESET_UPTIME_MS = 60 * 60 * 1e3;
1030
- var CRASH_LOOP_COUNTER_PATH = path4.join(os3.homedir(), ".exe-os", "daemon-crash-counter.json");
770
+ var CRASH_LOOP_COUNTER_PATH = path3.join(os2.homedir(), ".exe-os", "daemon-crash-counter.json");
1031
771
  var CRASH_LOOP_THRESHOLD = 3;
1032
772
  var CRASH_LOOP_WINDOW_MS = 10 * 60 * 1e3;
1033
- var CRASH_LOOP_BREAKER_PATH = path4.join(os3.homedir(), ".exe-os", "crash-loop-breaker");
773
+ var CRASH_LOOP_BREAKER_PATH = path3.join(os2.homedir(), ".exe-os", "crash-loop-breaker");
1034
774
  var CRASH_LOOP_BREAKER_TTL_MS = 30 * 60 * 1e3;
1035
775
  function recordDaemonCrash() {
1036
776
  const now = Date.now();
@@ -1064,8 +804,8 @@ function recordDaemonCrash() {
1064
804
  }
1065
805
  function isCrashLoopBreakerActive() {
1066
806
  try {
1067
- if (!existsSync4(CRASH_LOOP_BREAKER_PATH)) return false;
1068
- const ageMs = Date.now() - statSync2(CRASH_LOOP_BREAKER_PATH).mtimeMs;
807
+ if (!existsSync3(CRASH_LOOP_BREAKER_PATH)) return false;
808
+ const ageMs = Date.now() - statSync(CRASH_LOOP_BREAKER_PATH).mtimeMs;
1069
809
  if (ageMs > CRASH_LOOP_BREAKER_TTL_MS) {
1070
810
  unlinkSync2(CRASH_LOOP_BREAKER_PATH);
1071
811
  process.stderr.write(`[exed] Crash-loop breaker expired after ${Math.round(ageMs / 6e4)}min \u2014 cleared.
@@ -1105,8 +845,8 @@ function currentEmbedConfigFingerprint() {
1105
845
  }
1106
846
  function clearStaleOomMarker() {
1107
847
  try {
1108
- if (!existsSync4(OOM_MARKER_PATH)) return false;
1109
- const ageMs = Date.now() - statSync2(OOM_MARKER_PATH).mtimeMs;
848
+ if (!existsSync3(OOM_MARKER_PATH)) return false;
849
+ const ageMs = Date.now() - statSync(OOM_MARKER_PATH).mtimeMs;
1110
850
  if (ageMs < OOM_MARKER_TTL_MS) return false;
1111
851
  unlinkSync2(OOM_MARKER_PATH);
1112
852
  process.stderr.write(`[exed] Cleared stale embedding OOM marker after ${Math.round(ageMs / 36e5)}h.
@@ -1116,11 +856,23 @@ function clearStaleOomMarker() {
1116
856
  return false;
1117
857
  }
1118
858
  }
859
+ var EVENT_LOOP_BLOCKED_FRESH_MS = 1e4;
860
+ function eventLoopBlockedMarkerPath() {
861
+ return path3.join(os2.homedir(), ".exe-os", "session-cache", "event-loop-blocked.marker");
862
+ }
863
+ function isEventLoopBlockedNow(freshMs = EVENT_LOOP_BLOCKED_FRESH_MS) {
864
+ try {
865
+ const ageMs = Date.now() - statSync(eventLoopBlockedMarkerPath()).mtimeMs;
866
+ return ageMs < freshMs && ageMs > -freshMs;
867
+ } catch {
868
+ return false;
869
+ }
870
+ }
1119
871
  function checkLaunchdPlistHealth() {
1120
872
  try {
1121
873
  if (process.platform !== "darwin") return;
1122
- const plistPath = path4.join(os3.homedir(), "Library", "LaunchAgents", "com.askexe.exed.plist");
1123
- if (!existsSync4(plistPath)) return;
874
+ const plistPath = path3.join(os2.homedir(), "Library", "LaunchAgents", "com.askexe.exed.plist");
875
+ if (!existsSync3(plistPath)) return;
1124
876
  const plist = readFileSync3(plistPath, "utf8");
1125
877
  const expectedHeap = computeDaemonHeapCapMb();
1126
878
  const heapMatch = plist.match(/--max-old-space-size=(\d+)/);
@@ -1133,7 +885,7 @@ function checkLaunchdPlistHealth() {
1133
885
  }
1134
886
  const pathMatch = plist.match(/<key>PATH<\/key>\s*<string>([^<]*)<\/string>/);
1135
887
  const exportedPath = pathMatch?.[1] ?? "";
1136
- const nodeBinDir = path4.dirname(process.execPath);
888
+ const nodeBinDir = path3.dirname(process.execPath);
1137
889
  const systemDirs = /* @__PURE__ */ new Set(["/usr/local/bin", "/usr/bin", "/bin", "/opt/homebrew/bin"]);
1138
890
  if (exportedPath && !systemDirs.has(nodeBinDir) && !exportedPath.split(":").includes(nodeBinDir)) {
1139
891
  process.stderr.write(
@@ -1191,8 +943,8 @@ async function loadModel() {
1191
943
  }
1192
944
  } catch {
1193
945
  }
1194
- const modelPath = path4.join(MODELS_DIR, MODEL_FILE);
1195
- if (!existsSync4(modelPath)) {
946
+ const modelPath = path3.join(MODELS_DIR, MODEL_FILE);
947
+ if (!existsSync3(modelPath)) {
1196
948
  process.stderr.write(`[exed] No model at ${modelPath} \u2014 running without embeddings (VPS mode).
1197
949
  `);
1198
950
  _embeddingsDisabledByDesign = true;
@@ -1203,19 +955,19 @@ async function loadModel() {
1203
955
  process.stderr.write(`[exed] Embedding config changed \u2014 cleared stale embed-worker backoff (one prompt retry under new config).
1204
956
  `);
1205
957
  try {
1206
- if (existsSync4(EMBED_TIMEOUT_MARKER_PATH)) unlinkSync2(EMBED_TIMEOUT_MARKER_PATH);
958
+ if (existsSync3(EMBED_TIMEOUT_MARKER_PATH)) unlinkSync2(EMBED_TIMEOUT_MARKER_PATH);
1207
959
  } catch {
1208
960
  }
1209
961
  _embedConsecutiveTimeouts = 0;
1210
962
  }
1211
963
  clearStaleOomMarker();
1212
- if (existsSync4(OOM_MARKER_PATH)) {
964
+ if (existsSync3(OOM_MARKER_PATH)) {
1213
965
  process.stderr.write(`[exed] Skipping embeddings \u2014 OOM marker exists. Delete ${OOM_MARKER_PATH} to retry.
1214
966
  `);
1215
967
  _embeddingsDisabledByDesign = true;
1216
968
  return;
1217
969
  }
1218
- if (existsSync4(EMBED_TIMEOUT_MARKER_PATH)) {
970
+ if (existsSync3(EMBED_TIMEOUT_MARKER_PATH)) {
1219
971
  process.stderr.write(`[exed] Skipping embeddings \u2014 inference-timeout marker exists (local embeddings non-functional on this host). Set EXE_EMBEDDINGS=0 or delete ${EMBED_TIMEOUT_MARKER_PATH} to retry.
1220
972
  `);
1221
973
  _embeddingsDisabledByDesign = true;
@@ -1227,14 +979,14 @@ async function loadModel() {
1227
979
  _embeddingsDisabledByDesign = true;
1228
980
  return;
1229
981
  }
1230
- const totalMem = os3.totalmem();
982
+ const totalMem = os2.totalmem();
1231
983
  if (totalMem <= MAX_SMALL_TOTAL_BYTES) {
1232
984
  process.stderr.write(`[exed] Skipping embeddings \u2014 total RAM ${(totalMem / 1024 ** 3).toFixed(1)} GB <= 16 GB (FTS+Graph only).
1233
985
  `);
1234
986
  _embeddingsDisabledByDesign = true;
1235
987
  return;
1236
988
  }
1237
- if (os3.freemem() < MIN_FREE_MEM_BYTES) {
989
+ if (os2.freemem() < MIN_FREE_MEM_BYTES) {
1238
990
  process.stderr.write(`[exed] Skipping embeddings \u2014 free RAM < 2 GB.
1239
991
  `);
1240
992
  _embeddingsDisabledByDesign = true;
@@ -1242,8 +994,8 @@ async function loadModel() {
1242
994
  }
1243
995
  process.stderr.write("[exed] Spawning embed worker process...\n");
1244
996
  try {
1245
- const workerPath = path4.join(path4.dirname(new URL(import.meta.url).pathname), "embed-worker.js");
1246
- if (!existsSync4(workerPath)) {
997
+ const workerPath = path3.join(path3.dirname(new URL(import.meta.url).pathname), "embed-worker.js");
998
+ if (!existsSync3(workerPath)) {
1247
999
  process.stderr.write(`[exed] Embed worker not found at ${workerPath} \u2014 running without embeddings.
1248
1000
  `);
1249
1001
  return;
@@ -1328,7 +1080,7 @@ async function loadModel() {
1328
1080
  const oomShaped = code === 134 || signal === "SIGKILL" || signal === "SIGABRT";
1329
1081
  if (oomShaped) {
1330
1082
  try {
1331
- mkdirSync3(path4.dirname(OOM_MARKER_PATH), { recursive: true });
1083
+ mkdirSync2(path3.dirname(OOM_MARKER_PATH), { recursive: true });
1332
1084
  writeFileSync3(OOM_MARKER_PATH, `embed-worker OOM exit (code=${code}, signal=${signal ?? "none"}) at ${(/* @__PURE__ */ new Date()).toISOString()}
1333
1085
  `);
1334
1086
  process.stderr.write(`[exed] Embed worker OOM-shaped exit \u2014 wrote OOM marker; respawns will skip model load until it TTL-clears.
@@ -1349,7 +1101,7 @@ async function loadModel() {
1349
1101
  void (async () => {
1350
1102
  try {
1351
1103
  if (_storeInitialized) {
1352
- const { writeNotification } = await import("../notifications-AMJ2K3MM.js");
1104
+ const { writeNotification } = await import("../notifications-UP7WQGG4.js");
1353
1105
  await writeNotification({
1354
1106
  agentId: "exe",
1355
1107
  agentRole: "system",
@@ -1430,7 +1182,7 @@ function disableEmbeddingsForInferenceTimeouts() {
1430
1182
  if (_embeddingsDisabledByDesign) return;
1431
1183
  _embeddingsDisabledByDesign = true;
1432
1184
  try {
1433
- mkdirSync3(path4.dirname(EMBED_TIMEOUT_MARKER_PATH), { recursive: true });
1185
+ mkdirSync2(path3.dirname(EMBED_TIMEOUT_MARKER_PATH), { recursive: true });
1434
1186
  writeFileSync3(
1435
1187
  EMBED_TIMEOUT_MARKER_PATH,
1436
1188
  `embed inference timed out ${_embedConsecutiveTimeouts}x consecutively at ${(/* @__PURE__ */ new Date()).toISOString()}
@@ -1465,7 +1217,7 @@ function disableEmbeddingsForInferenceTimeouts() {
1465
1217
  void (async () => {
1466
1218
  try {
1467
1219
  if (_storeInitialized) {
1468
- const { writeNotification } = await import("../notifications-AMJ2K3MM.js");
1220
+ const { writeNotification } = await import("../notifications-UP7WQGG4.js");
1469
1221
  await writeNotification({
1470
1222
  agentId: "exe",
1471
1223
  agentRole: "system",
@@ -1638,6 +1390,7 @@ async function shutdown(exitCode = 0) {
1638
1390
  if (_shuttingDown) return;
1639
1391
  _shuttingDown = true;
1640
1392
  _drainingWrites = true;
1393
+ clearDaemonReady();
1641
1394
  if (exitCode !== 0) {
1642
1395
  recordDaemonCrash();
1643
1396
  }
@@ -1675,7 +1428,7 @@ async function shutdown(exitCode = 0) {
1675
1428
  }
1676
1429
  }
1677
1430
  try {
1678
- const { createBackupAsync, enforceRetention, hasRecentBackup } = await import("../db-backup-VZHSFUVA.js");
1431
+ const { createBackupAsync, enforceRetention, hasRecentBackup } = await import("../db-backup-EORG4LBO.js");
1679
1432
  const PRE_RESTART_DEDUP_MS = 2 * 60 * 1e3;
1680
1433
  if (hasRecentBackup("pre-restart", PRE_RESTART_DEDUP_MS)) {
1681
1434
  const deleted = enforceRetention("pre-restart");
@@ -1706,7 +1459,7 @@ async function shutdown(exitCode = 0) {
1706
1459
  `);
1707
1460
  }
1708
1461
  try {
1709
- const { stopProjectionWorker } = await import("../projection-worker-WWXZK7QD.js");
1462
+ const { stopProjectionWorker } = await import("../projection-worker-HWY37MNC.js");
1710
1463
  stopProjectionWorker();
1711
1464
  } catch {
1712
1465
  }
@@ -1738,7 +1491,7 @@ async function shutdown(exitCode = 0) {
1738
1491
  savedAt: Date.now()
1739
1492
  })) : [];
1740
1493
  if (sessionsToSave.length > 0) {
1741
- const sessPath = path4.join(EXE_AI_DIR, "mcp-sessions-persist.json");
1494
+ const sessPath = path3.join(EXE_AI_DIR, "mcp-sessions-persist.json");
1742
1495
  writeFileSync3(sessPath, JSON.stringify(sessionsToSave) + "\n", { mode: 384 });
1743
1496
  process.stderr.write(`[exed] Persisted ${sessionsToSave.length} MCP session(s) for next daemon.
1744
1497
  `);
@@ -1772,7 +1525,7 @@ async function handleHealthCheck(socket, requestId) {
1772
1525
  let pipelineStatus = "unknown";
1773
1526
  if (dbConnected) {
1774
1527
  try {
1775
- await import("../pipeline-router-4LT5YG5P.js");
1528
+ await import("../pipeline-router-5CRWKESM.js");
1776
1529
  pipelineStatus = "ok";
1777
1530
  } catch {
1778
1531
  pipelineStatus = "unavailable";
@@ -1942,15 +1695,15 @@ async function handleDbBatch(socket, requestId, statements, mode) {
1942
1695
  }
1943
1696
  }
1944
1697
  var _ingestCount = 0;
1945
- var INGEST_OUTBOX_DIR = path4.join(EXE_AI_DIR, "ingest-outbox");
1698
+ var INGEST_OUTBOX_DIR = path3.join(EXE_AI_DIR, "ingest-outbox");
1946
1699
  function persistIngestOutbox(req) {
1947
1700
  try {
1948
- mkdirSync3(INGEST_OUTBOX_DIR, { recursive: true });
1701
+ mkdirSync2(INGEST_OUTBOX_DIR, { recursive: true });
1949
1702
  const id = randomUUID();
1950
- const finalPath = path4.join(INGEST_OUTBOX_DIR, `${Date.now()}-${id}.json`);
1703
+ const finalPath = path3.join(INGEST_OUTBOX_DIR, `${Date.now()}-${id}.json`);
1951
1704
  const tmpPath = `${finalPath}.tmp`;
1952
1705
  writeFileSync3(tmpPath, JSON.stringify(req) + "\n", { mode: 384 });
1953
- renameSync2(tmpPath, finalPath);
1706
+ renameSync(tmpPath, finalPath);
1954
1707
  return finalPath;
1955
1708
  } catch (err) {
1956
1709
  process.stderr.write(`[exed] Ingest outbox persist failed: ${err instanceof Error ? err.message : String(err)}
@@ -1960,10 +1713,10 @@ function persistIngestOutbox(req) {
1960
1713
  }
1961
1714
  async function drainIngestOutbox() {
1962
1715
  try {
1963
- if (!existsSync4(INGEST_OUTBOX_DIR)) return;
1716
+ if (!existsSync3(INGEST_OUTBOX_DIR)) return;
1964
1717
  const files = readdirSync(INGEST_OUTBOX_DIR).filter((f) => f.endsWith(".json")).sort().slice(0, 500);
1965
1718
  for (const file of files) {
1966
- const fullPath = path4.join(INGEST_OUTBOX_DIR, file);
1719
+ const fullPath = path3.join(INGEST_OUTBOX_DIR, file);
1967
1720
  try {
1968
1721
  const req = JSON.parse(readFileSync3(fullPath, "utf8"));
1969
1722
  await handleIngest(req, fullPath);
@@ -2168,7 +1921,7 @@ async function _writeMemoryRecordInner(entry) {
2168
1921
  const vRow = await client.execute({ sql: "SELECT version FROM memories WHERE id = ?", args: [id] });
2169
1922
  const version = Number(vRow.rows[0]?.version) || 0;
2170
1923
  try {
2171
- const { insertOntologyForMemory } = await import("../agentic-ontology-M7T72M6V.js");
1924
+ const { insertOntologyForMemory } = await import("../agentic-ontology-6KBAXLSJ.js");
2172
1925
  await insertOntologyForMemory({
2173
1926
  id,
2174
1927
  agent_id: record.agent_id,
@@ -2252,7 +2005,7 @@ function startMessageQueueDrain() {
2252
2005
  fired("message_queue_drain");
2253
2006
  if (!await ensureStoreForPolling()) return;
2254
2007
  try {
2255
- const { claimMessageQueue, ackMessageQueue } = await import("../message-queue-client-QTC3VHJT.js");
2008
+ const { claimMessageQueue, ackMessageQueue } = await import("../message-queue-client-4VDU6BZY.js");
2256
2009
  const lease = claimMessageQueue();
2257
2010
  if (!lease || lease.entries.length === 0) return;
2258
2011
  acted("message_queue_drain");
@@ -2306,14 +2059,14 @@ function startMessageQueueDrain() {
2306
2059
  `);
2307
2060
  }
2308
2061
  function startServer() {
2309
- mkdirSync3(path4.dirname(SOCKET_PATH), { recursive: true });
2062
+ mkdirSync2(path3.dirname(SOCKET_PATH), { recursive: true });
2310
2063
  try {
2311
- chmodSync(path4.dirname(SOCKET_PATH), 448);
2064
+ chmodSync(path3.dirname(SOCKET_PATH), 448);
2312
2065
  } catch {
2313
2066
  }
2314
2067
  _daemonToken = ensureDaemonToken(process.env[DAEMON_TOKEN_ENV] ?? null);
2315
2068
  for (const oldFile of ["embed.sock", "embed.pid"]) {
2316
- const oldPath = path4.join(path4.dirname(SOCKET_PATH), oldFile);
2069
+ const oldPath = path3.join(path3.dirname(SOCKET_PATH), oldFile);
2317
2070
  try {
2318
2071
  if (oldFile.endsWith(".pid")) {
2319
2072
  const pid = parseInt(readFileSync3(oldPath, "utf8").trim(), 10);
@@ -2621,9 +2374,21 @@ async function startMcpHttpServer() {
2621
2374
  }, resolveMcpSessionDetails2 = function(sessionId, requestDetails) {
2622
2375
  const persisted = sessionDetails.get(sessionId);
2623
2376
  if (!persisted) return requestDetails;
2377
+ const recon = reconcileSessionAgentIdentity(
2378
+ persisted.agentId,
2379
+ requestDetails.agentId,
2380
+ shouldEnforceSessionIdentity()
2381
+ );
2382
+ if (recon.impersonationDetected) {
2383
+ process.stderr.write(
2384
+ `[exed] SECURITY: agent identity mismatch on recovered session ${sessionId.slice(0, 8)} \u2014 claimed="${recon.claimedAgentId}" bound="${recon.boundAgentId}" coerced to bound
2385
+ `
2386
+ );
2387
+ }
2624
2388
  return {
2625
- agentId: requestDetails.agentId === "default" ? persisted.agentId : requestDetails.agentId,
2626
- agentRole: requestDetails.agentRole === "employee" ? persisted.agentRole : requestDetails.agentRole,
2389
+ // Bound identity wins (data isolation). Role follows the bound agent.
2390
+ agentId: recon.effectiveAgentId,
2391
+ agentRole: recon.impersonationDetected || requestDetails.agentRole === "employee" ? persisted.agentRole : requestDetails.agentRole,
2627
2392
  runtime: requestDetails.runtime === "Unknown" ? persisted.runtime : requestDetails.runtime,
2628
2393
  sessionHint: requestDetails.sessionHint || persisted.sessionHint,
2629
2394
  transient: requestDetails.transient ?? persisted.transient
@@ -2737,8 +2502,8 @@ async function startMcpHttpServer() {
2737
2502
  _bootstrapServerRef = createHttpServer((req, res) => {
2738
2503
  try {
2739
2504
  res.setHeader("Access-Control-Allow-Origin", "http://127.0.0.1");
2740
- const path5 = (req.url || "/").split("?")[0];
2741
- if (req.method === "GET" && path5 === "/health") {
2505
+ const path4 = (req.url || "/").split("?")[0];
2506
+ if (req.method === "GET" && path4 === "/health") {
2742
2507
  res.writeHead(200, { "Content-Type": "application/json" });
2743
2508
  res.end(JSON.stringify({ status: "starting", version: PACKAGE_VERSION }));
2744
2509
  return;
@@ -2784,7 +2549,7 @@ async function startMcpHttpServer() {
2784
2549
  }
2785
2550
  process.stderr.write("[exed] MCP HTTP: DB ready\n");
2786
2551
  _storeInitialized = true;
2787
- const { initLicenseGate, getCachedLicenseGate } = await import("../license-gate-V2UCK4KJ.js");
2552
+ const { initLicenseGate, getCachedLicenseGate } = await import("../license-gate-7SDHCJUO.js");
2788
2553
  const gateResult = await initLicenseGate();
2789
2554
  if (!gateResult.hasKey) {
2790
2555
  process.stderr.write(
@@ -2799,13 +2564,13 @@ async function startMcpHttpServer() {
2799
2564
  let _cachedWrapTelemetry = null;
2800
2565
  async function getWrapTelemetry() {
2801
2566
  if (!_cachedWrapTelemetry) {
2802
- const { wrapServerWithTelemetry } = await import("../tool-telemetry-BLSVABFJ.js");
2567
+ const { wrapServerWithTelemetry } = await import("../tool-telemetry-BS5JXM5M.js");
2803
2568
  _cachedWrapTelemetry = wrapServerWithTelemetry;
2804
2569
  }
2805
2570
  return _cachedWrapTelemetry;
2806
2571
  }
2807
2572
  Promise.all([
2808
- import("../tool-capability-index-RHPVMMDD.js"),
2573
+ import("../tool-capability-index-ZEXBWKUZ.js"),
2809
2574
  import("../tool-gates-3IC7DK4R.js")
2810
2575
  ]).then(async ([{ getToolCapabilityIndex }, { TOOL_CATEGORIES }]) => {
2811
2576
  const gateState = getCachedLicenseGate();
@@ -2869,7 +2634,7 @@ async function startMcpHttpServer() {
2869
2634
  if (!token || token === header) return false;
2870
2635
  if (token === _daemonToken) return true;
2871
2636
  try {
2872
- const { verifyAccessToken } = await import("../oauth-server-BPN55EJM.js");
2637
+ const { verifyAccessToken } = await import("../oauth-server-EWUL7DMD.js");
2873
2638
  const result = verifyAccessToken(token);
2874
2639
  return result.valid;
2875
2640
  } catch {
@@ -2879,8 +2644,8 @@ async function startMcpHttpServer() {
2879
2644
  const pendingStaleSessionRecoveries = /* @__PURE__ */ new Map();
2880
2645
  _mcpSessionDetailsRef = sessionDetails;
2881
2646
  try {
2882
- const sessPath = path4.join(EXE_AI_DIR, "mcp-sessions-persist.json");
2883
- if (existsSync4(sessPath)) {
2647
+ const sessPath = path3.join(EXE_AI_DIR, "mcp-sessions-persist.json");
2648
+ if (existsSync3(sessPath)) {
2884
2649
  const raw = readFileSync3(sessPath, "utf-8");
2885
2650
  const saved = JSON.parse(raw);
2886
2651
  const MAX_AGE_MS = 5 * 60 * 1e3;
@@ -3109,7 +2874,7 @@ async function startMcpHttpServer() {
3109
2874
  return;
3110
2875
  }
3111
2876
  try {
3112
- const { handleOAuthRoute } = await import("../oauth-server-BPN55EJM.js");
2877
+ const { handleOAuthRoute } = await import("../oauth-server-EWUL7DMD.js");
3113
2878
  const handled = await handleOAuthRoute(req, res, url, MCP_HTTP_PORT);
3114
2879
  if (handled) return;
3115
2880
  } catch (err) {
@@ -3199,6 +2964,27 @@ async function startMcpHttpServer() {
3199
2964
  else res.end(JSON.stringify({ status: "ok", pid: process.pid, uptime: Math.floor(process.uptime()) }));
3200
2965
  return;
3201
2966
  }
2967
+ if (url.pathname === "/v1/ratelimit" && req.method === "POST") {
2968
+ try {
2969
+ const chunks = [];
2970
+ for await (const chunk of req) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
2971
+ const body = JSON.parse(Buffer.concat(chunks).toString("utf-8"));
2972
+ if (!body.tool) {
2973
+ res.writeHead(400, { "Content-Type": "application/json" });
2974
+ res.end(JSON.stringify({ error: "tool is required" }));
2975
+ return;
2976
+ }
2977
+ const { incrementSharedWindow } = await import("../shared-rate-limit-store-QZPQEVE2.js");
2978
+ const limit = Number.isFinite(body.limit) && body.limit > 0 ? body.limit : 100;
2979
+ const result = incrementSharedWindow(body.tool, body.agent || "unknown", limit);
2980
+ res.writeHead(200, { "Content-Type": "application/json" });
2981
+ res.end(JSON.stringify({ count: result.count, limit: result.limit, exceeded: result.exceeded }));
2982
+ } catch (e) {
2983
+ res.writeHead(500, { "Content-Type": "application/json" });
2984
+ res.end(JSON.stringify({ error: e instanceof Error ? e.message : String(e) }));
2985
+ }
2986
+ return;
2987
+ }
3202
2988
  if (url.pathname === "/v1/heartbeat" && req.method === "POST") {
3203
2989
  try {
3204
2990
  const chunks = [];
@@ -3216,7 +3002,7 @@ async function startMcpHttpServer() {
3216
3002
  contextPct: body.context_pct
3217
3003
  });
3218
3004
  if (body.context_pct !== void 0 && body.context_pct > 70) {
3219
- void import("../orchestration-events-MB4QVHTD.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
3005
+ void import("../orchestration-events-PZLLPCKY.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
3220
3006
  recordOE({
3221
3007
  eventType: "context.pressure",
3222
3008
  source: "exe-daemon.heartbeat",
@@ -3253,6 +3039,22 @@ async function startMcpHttpServer() {
3253
3039
  res.end(JSON.stringify({ error: "not_found" }));
3254
3040
  return;
3255
3041
  }
3042
+ if (isEventLoopBlockedNow()) {
3043
+ res.writeHead(503, { "Content-Type": "application/json", "Retry-After": "3" });
3044
+ res.end(JSON.stringify({
3045
+ jsonrpc: "2.0",
3046
+ error: { code: -32001, message: "Daemon event loop blocked \u2014 MCP temporarily degraded. Retry in a few seconds." },
3047
+ id: null
3048
+ }));
3049
+ recordMcpHttpEvent({
3050
+ level: "warn",
3051
+ message: "event_loop_blocked_503",
3052
+ method: req.method,
3053
+ status: 503,
3054
+ error: `path=${url.pathname}`
3055
+ });
3056
+ return;
3057
+ }
3256
3058
  const authed = await verifyHttpBearerAuth(req.headers.authorization);
3257
3059
  if (!authed) {
3258
3060
  sendJsonRpcError2(res, 401, "Unauthorized: Bearer token required", "unknown", {
@@ -3352,6 +3154,38 @@ async function startMcpHttpServer() {
3352
3154
  if (sessionId && transports.has(sessionId)) {
3353
3155
  transport = transports.get(sessionId);
3354
3156
  sessionLastSeen.set(sessionId, Date.now());
3157
+ const boundDetails = sessionDetails.get(sessionId);
3158
+ if (boundDetails) {
3159
+ const enforce = shouldEnforceSessionIdentity();
3160
+ const recon = reconcileSessionAgentIdentity(boundDetails.agentId, agentId, enforce);
3161
+ if (recon.impersonationDetected) {
3162
+ process.stderr.write(
3163
+ `[exed] SECURITY: agent identity mismatch on session ${sessionId.slice(0, 8)} \u2014 claimed="${recon.claimedAgentId}" bound="${recon.boundAgentId}" ${enforce ? "REJECTED" : "coerced to bound (warn)"}
3164
+ `
3165
+ );
3166
+ recordMcpHttpEvent({
3167
+ level: "warn",
3168
+ message: enforce ? "agent_impersonation_rejected" : "agent_impersonation_coerced",
3169
+ method: req.method,
3170
+ sessionId,
3171
+ agentId: recon.boundAgentId,
3172
+ agentRole: boundDetails.agentRole,
3173
+ runtime
3174
+ });
3175
+ if (recon.reject) {
3176
+ sendJsonRpcError2(
3177
+ res,
3178
+ 403,
3179
+ `Agent identity mismatch: session is bound to "${recon.boundAgentId}" but request claimed "${recon.claimedAgentId}".`,
3180
+ getJsonRpcId2(parsedBody),
3181
+ { sessionId, claimedAgentId: recon.claimedAgentId, boundAgentId: recon.boundAgentId }
3182
+ );
3183
+ return;
3184
+ }
3185
+ }
3186
+ agentId = recon.effectiveAgentId;
3187
+ agentRole = boundDetails.agentRole;
3188
+ }
3355
3189
  } else if (!sessionId && req.method === "POST" && isInitializeRequest(parsedBody)) {
3356
3190
  try {
3357
3191
  const { initDatabase, isInitialized, ensureSchema } = await import("./database.js");
@@ -3647,6 +3481,7 @@ async function startMcpHttpServer() {
3647
3481
  httpServer.listen(MCP_HTTP_PORT, MCP_HTTP_HOST, () => {
3648
3482
  process.stderr.write(`[exed] MCP HTTP listening on ${MCP_HTTP_HOST}:${MCP_HTTP_PORT}
3649
3483
  `);
3484
+ writeDaemonReady({ pid: process.pid, port: MCP_HTTP_PORT });
3650
3485
  void import("../mcp-port-config-AWWRZA22.js").then(({ persistMcpPortToConfig }) => persistMcpPortToConfig(String(MCP_HTTP_PORT))).catch(() => {
3651
3486
  });
3652
3487
  recordMcpHttpEvent({
@@ -3751,13 +3586,13 @@ async function ensureStoreForPolling() {
3751
3586
  }
3752
3587
  }
3753
3588
  async function startReviewPolling() {
3754
- const polling = await import("../review-polling-E4ALHTQE.js");
3589
+ const polling = await import("../review-polling-65JZUE3T.js");
3755
3590
  const state = {
3756
3591
  lastIntercomSent: /* @__PURE__ */ new Map(),
3757
3592
  lastNudgeSent: /* @__PURE__ */ new Map(),
3758
3593
  intervalMs: REVIEW_POLL_INTERVAL_MS
3759
3594
  };
3760
- const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-V6HALVDS.js");
3595
+ const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-G4RRTPP7.js");
3761
3596
  const nudgeState = loadNudgeState();
3762
3597
  const tick = async () => traceDaemonTimer("review_polling", async () => {
3763
3598
  fired("review_polling");
@@ -3801,7 +3636,7 @@ function startSessionTTL() {
3801
3636
  if (!await ensureStoreForPolling()) return;
3802
3637
  try {
3803
3638
  const { getClient } = await import("./database.js");
3804
- const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-V6HALVDS.js");
3639
+ const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-G4RRTPP7.js");
3805
3640
  const deps = createSessionTTLRealDeps(getClient);
3806
3641
  const killed = await checkSessionTTL(deps);
3807
3642
  if (killed.length > 0) acted("session_ttl");
@@ -3822,12 +3657,12 @@ function startIdleKill() {
3822
3657
  fired("idle_kill");
3823
3658
  if (!await ensureStoreForPolling()) return;
3824
3659
  try {
3825
- const signalDir = path4.join(os3.homedir(), ".exe-os", "task-signals");
3826
- if (existsSync4(signalDir)) {
3660
+ const signalDir = path3.join(os2.homedir(), ".exe-os", "task-signals");
3661
+ if (existsSync3(signalDir)) {
3827
3662
  const files = (await import("fs")).readdirSync(signalDir).filter((f) => f.endsWith(".terminate"));
3828
3663
  for (const file of files) {
3829
3664
  const agentId = file.replace(".terminate", "");
3830
- const signalPath = path4.join(signalDir, file);
3665
+ const signalPath = path3.join(signalDir, file);
3831
3666
  try {
3832
3667
  const sessions = await getTmuxSessionsAsync();
3833
3668
  const match = sessions.find((s) => s.startsWith(`${agentId}-`) || s.startsWith(`${agentId}2-`) || s.startsWith(`${agentId}3-`));
@@ -3849,7 +3684,7 @@ function startIdleKill() {
3849
3684
  const cfg = await getCachedConfig();
3850
3685
  if (!cfg) return;
3851
3686
  const { getClient } = await import("./database.js");
3852
- const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-V6HALVDS.js");
3687
+ const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-G4RRTPP7.js");
3853
3688
  const { sessions: liveSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
3854
3689
  const realDeps = createIdleKillRealDeps(
3855
3690
  getClient,
@@ -3918,7 +3753,7 @@ function startConsolidation() {
3918
3753
  `);
3919
3754
  }
3920
3755
  try {
3921
- const { createBackupAsync, enforceRetention } = await import("../db-backup-VZHSFUVA.js");
3756
+ const { createBackupAsync, enforceRetention } = await import("../db-backup-EORG4LBO.js");
3922
3757
  const p = await createBackupAsync("pre-consolidation");
3923
3758
  if (p) enforceRetention("pre-consolidation");
3924
3759
  } catch (e) {
@@ -4102,7 +3937,7 @@ function startSkillRefinement() {
4102
3937
  if (!shouldRunHeavyJob("skill_refinement")) return;
4103
3938
  try {
4104
3939
  if (!await ensureStoreForPolling()) return;
4105
- const { runSkillRefinement } = await import("../skill-refinement-FTURVWFN.js");
3940
+ const { runSkillRefinement } = await import("../skill-refinement-DUOO6B7V.js");
4106
3941
  const result = await runSkillRefinement();
4107
3942
  if (result.reviewed > 0) {
4108
3943
  acted("skill_refinement");
@@ -4128,7 +3963,7 @@ function startStaleBranchSweep() {
4128
3963
  const tick = async () => {
4129
3964
  fired("stale_branch_sweep");
4130
3965
  try {
4131
- const { discoverRepoPaths } = await import("../worktree-sweep-AS6GAR6X.js");
3966
+ const { discoverRepoPaths } = await import("../worktree-sweep-K3CJFSUL.js");
4132
3967
  const { scanUnmergedBranches } = await import("../branch-hygiene-55TKIWAZ.js");
4133
3968
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
4134
3969
  for (const k of _staleBranchAlertedToday) {
@@ -4155,7 +3990,7 @@ function startStaleBranchSweep() {
4155
3990
  if (!_storeInitialized) continue;
4156
3991
  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("; ");
4157
3992
  try {
4158
- const { writeNotification } = await import("../notifications-AMJ2K3MM.js");
3993
+ const { writeNotification } = await import("../notifications-UP7WQGG4.js");
4159
3994
  await writeNotification({
4160
3995
  agentId: "exe",
4161
3996
  agentRole: "system",
@@ -4194,7 +4029,7 @@ function startGraphExtraction() {
4194
4029
  if (!await ensureStoreForPolling()) return;
4195
4030
  const { getClient } = await import("./database.js");
4196
4031
  const client = getClient();
4197
- const { extractBatch } = await import("../graph-rag-3RZN7JR3.js");
4032
+ const { extractBatch } = await import("../graph-rag-HITZZ63L.js");
4198
4033
  const result = await extractBatch(client, 50, config.selfQueryModel);
4199
4034
  if (result.processed > 0) {
4200
4035
  acted("graph_extraction");
@@ -4420,7 +4255,7 @@ function startGraphPgSync() {
4420
4255
  `);
4421
4256
  }
4422
4257
  var AGENT_STATS_INTERVAL_MS = 60 * 1e3;
4423
- var AGENT_STATS_PATH = path4.join(EXE_AI_DIR, "agent-stats.json");
4258
+ var AGENT_STATS_PATH = path3.join(EXE_AI_DIR, "agent-stats.json");
4424
4259
  var _agentStatsInFlight = false;
4425
4260
  var _cachedAgentData = null;
4426
4261
  async function writeAgentStats() {
@@ -4608,7 +4443,7 @@ function startReflectionSweep() {
4608
4443
  );
4609
4444
  let runReflection;
4610
4445
  try {
4611
- ({ runReflection } = await import("../memory-reflection-UKKTGZYR.js"));
4446
+ ({ runReflection } = await import("../memory-reflection-PXF6YFDU.js"));
4612
4447
  } catch (importErr) {
4613
4448
  _reflectionImportFailed = true;
4614
4449
  process.stderr.write(`[exed] Reflection module unavailable (stale chunk hash?) \u2014 disabled until daemon restart: ${importErr instanceof Error ? importErr.message : String(importErr)}
@@ -4647,7 +4482,7 @@ function startReflectionSweep() {
4647
4482
  if (memories > 100 && cards < memories * 0.1) {
4648
4483
  process.stderr.write(`[exed] Memory cards sparse (${cards} cards / ${memories} memories) \u2014 running backfill...
4649
4484
  `);
4650
- const { insertMemoryCardsForBatch } = await import("../memory-cards-BGI6MJRN.js");
4485
+ const { insertMemoryCardsForBatch } = await import("../memory-cards-II67WFL2.js");
4651
4486
  const batchSize = 500;
4652
4487
  let offset = 0;
4653
4488
  let totalCards = 0;
@@ -4692,7 +4527,7 @@ function startDatabaseBackup() {
4692
4527
  fired("db_backup");
4693
4528
  if (!shouldRunHeavyJob("db_backup")) return;
4694
4529
  try {
4695
- const { createBackupAsync, enforceRetention, hasBackupToday } = await import("../db-backup-VZHSFUVA.js");
4530
+ const { createBackupAsync, enforceRetention, hasBackupToday } = await import("../db-backup-EORG4LBO.js");
4696
4531
  if (hasBackupToday("daily")) return;
4697
4532
  const backupPath = await createBackupAsync("daily");
4698
4533
  if (backupPath) {
@@ -4761,7 +4596,7 @@ function startSessionEventsRetention() {
4761
4596
  if (!await ensureStoreForPolling()) return;
4762
4597
  try {
4763
4598
  const { getClient } = await import("./database.js");
4764
- const { sweepExpiredSessionEvents, DEFAULT_SESSION_EVENTS_RETENTION_DAYS } = await import("../session-events-3J6APMKN.js");
4599
+ const { sweepExpiredSessionEvents, DEFAULT_SESSION_EVENTS_RETENTION_DAYS } = await import("../session-events-EJ3OSAA6.js");
4765
4600
  const days = SESSION_EVENTS_RETENTION_DAYS ?? DEFAULT_SESSION_EVENTS_RETENTION_DAYS;
4766
4601
  const count = await sweepExpiredSessionEvents(getClient(), days);
4767
4602
  if (count > 0) {
@@ -4829,7 +4664,7 @@ function startOrphanReaper() {
4829
4664
  const tick = async () => traceDaemonTimer("orphan_reaper", async () => {
4830
4665
  fired("orphan_reaper");
4831
4666
  try {
4832
- const { reapOrphanedMcpProcesses, createOrphanReaperRealDepsAsync } = await import("../daemon-orchestration-V6HALVDS.js");
4667
+ const { reapOrphanedMcpProcesses, createOrphanReaperRealDepsAsync } = await import("../daemon-orchestration-G4RRTPP7.js");
4833
4668
  const deps = await createOrphanReaperRealDepsAsync();
4834
4669
  const reaped = await reapOrphanedMcpProcesses(deps);
4835
4670
  if (reaped.length > 0) acted("orphan_reaper");
@@ -4854,7 +4689,7 @@ function startZombieAgentReaper() {
4854
4689
  const tick = async () => traceDaemonTimer("zombie_agent_reaper", async () => {
4855
4690
  fired("zombie_agent_reaper");
4856
4691
  try {
4857
- const { reapZombieAgentProcesses, createZombieAgentReaperRealDepsAsync } = await import("../daemon-orchestration-V6HALVDS.js");
4692
+ const { reapZombieAgentProcesses, createZombieAgentReaperRealDepsAsync } = await import("../daemon-orchestration-G4RRTPP7.js");
4858
4693
  const deps = await createZombieAgentReaperRealDepsAsync();
4859
4694
  const reaped = reapZombieAgentProcesses(deps);
4860
4695
  if (reaped.length > 0) acted("zombie_agent_reaper");
@@ -4878,7 +4713,7 @@ function startWorktreeReaper() {
4878
4713
  const tick = async () => traceDaemonTimer("worktree_reaper", async () => {
4879
4714
  fired("worktree_reaper");
4880
4715
  try {
4881
- const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-V6HALVDS.js");
4716
+ const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-G4RRTPP7.js");
4882
4717
  const deps = await createWorktreeReaperRealDeps();
4883
4718
  const result = await reapOrphanedWorktrees(deps);
4884
4719
  if (result.pruned.length > 0) {
@@ -4918,8 +4753,8 @@ function startWorktreeReaper() {
4918
4753
  }
4919
4754
  continue;
4920
4755
  }
4921
- const { cleanupAgentWorktree } = await import("../worktree-sweep-AS6GAR6X.js");
4922
- const { getMainRepoRoot } = await import("../worktree-XISIYRM4.js");
4756
+ const { cleanupAgentWorktree } = await import("../worktree-sweep-K3CJFSUL.js");
4757
+ const { getMainRepoRoot } = await import("../worktree-2CXY6NEB.js");
4923
4758
  const repoRoot = getMainRepoRoot(signal.worktreePath);
4924
4759
  if (repoRoot && signal.agentId) {
4925
4760
  const notes = cleanupAgentWorktree(repoRoot, signal.agentId);
@@ -4953,7 +4788,7 @@ function startWalCheckpoint() {
4953
4788
  try {
4954
4789
  const { getClient, runWalCheckpoint } = await import("./database.js");
4955
4790
  const client = getClient();
4956
- const { findActiveDb } = await import("../db-backup-VZHSFUVA.js");
4791
+ const { findActiveDb } = await import("../db-backup-EORG4LBO.js");
4957
4792
  const dbPath = findActiveDb();
4958
4793
  const started = Date.now();
4959
4794
  const result = await runWalCheckpoint(client, dbPath, true);
@@ -5025,7 +4860,7 @@ function startStuckTaskRelease() {
5025
4860
  if (!await ensureStoreForPolling()) return;
5026
4861
  try {
5027
4862
  const { getClient } = await import("./database.js");
5028
- const { releaseStuckTasks, createStuckTaskRealDeps } = await import("../daemon-orchestration-V6HALVDS.js");
4863
+ const { releaseStuckTasks, createStuckTaskRealDeps } = await import("../daemon-orchestration-G4RRTPP7.js");
5029
4864
  const deps = createStuckTaskRealDeps(getClient);
5030
4865
  const released = await releaseStuckTasks(deps);
5031
4866
  if (released.length > 0) {
@@ -5047,7 +4882,7 @@ var _cachedV8HeapLimitBytes = null;
5047
4882
  function getV8HeapLimitBytes() {
5048
4883
  if (_cachedV8HeapLimitBytes !== null) return _cachedV8HeapLimitBytes;
5049
4884
  try {
5050
- _cachedV8HeapLimitBytes = v82.getHeapStatistics().heap_size_limit;
4885
+ _cachedV8HeapLimitBytes = v8.getHeapStatistics().heap_size_limit;
5051
4886
  } catch {
5052
4887
  _cachedV8HeapLimitBytes = 4 * 1024 ** 3;
5053
4888
  }
@@ -5129,7 +4964,7 @@ function startExternalRssWatchdog() {
5129
4964
  restartBytes: RSS_RESTART_BYTES,
5130
4965
  checkMs: RSS_CHECK_INTERVAL_MS,
5131
4966
  markerPath: OOM_MARKER_PATH,
5132
- cwd: os3.homedir(),
4967
+ cwd: os2.homedir(),
5133
4968
  // External path can't GC the daemon → require one extra consecutive sample
5134
4969
  // beyond the in-process debounce before terminating.
5135
4970
  debounceN: DAEMON_RSS_RESTART_DEBOUNCE + 1,
@@ -5157,12 +4992,12 @@ function startTaskEnforcementScanner() {
5157
4992
  const tick = async () => traceDaemonTimer("task_enforcement", async () => {
5158
4993
  fired("task_enforcement");
5159
4994
  try {
5160
- const { runTaskEnforcementTick } = await import("../task-enforcement-GY3VTY6L.js");
4995
+ const { runTaskEnforcementTick } = await import("../task-enforcement-UOULTGFB.js");
5161
4996
  const { getTransport } = await import("./transport.js");
5162
4997
  const { loadAgentConfig } = await import("./agent-config.js");
5163
4998
  const { getClient } = await import("./database.js");
5164
4999
  const { loadEmployeesSync } = await import("./employees.js");
5165
- const { sessionScopeFilter } = await import("../task-scope-PYOK7OQ6.js");
5000
+ const { sessionScopeFilter } = await import("../task-scope-P5STKYAC.js");
5166
5001
  const transport = getTransport();
5167
5002
  const { sessions: allSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
5168
5003
  await yieldToEventLoop();
@@ -5173,10 +5008,10 @@ function startTaskEnforcementScanner() {
5173
5008
  sendKeysLiteral: transport.sendKeysLiteral?.bind(transport),
5174
5009
  isAlive: (session) => aliveSessions.has(session)
5175
5010
  };
5176
- const { checkAutoWakeGates } = await import("../daemon-orchestration-V6HALVDS.js");
5011
+ const { checkAutoWakeGates } = await import("../daemon-orchestration-G4RRTPP7.js");
5177
5012
  const { ensureEmployeeAsync, employeeSessionName } = await import("./tmux-routing.js");
5178
5013
  const { shouldAutoInstance } = await import("./employees.js");
5179
- const { recordOrchestrationEventBestEffort } = await import("../orchestration-events-MB4QVHTD.js");
5014
+ const { recordOrchestrationEventBestEffort } = await import("../orchestration-events-PZLLPCKY.js");
5180
5015
  const projectDir = process.cwd();
5181
5016
  await runTaskEnforcementTick({
5182
5017
  transport: enforcementTransport,
@@ -5300,7 +5135,7 @@ function startRssWatchdog() {
5300
5135
  `
5301
5136
  );
5302
5137
  try {
5303
- mkdirSync3(path4.dirname(OOM_MARKER_PATH), { recursive: true });
5138
+ mkdirSync2(path3.dirname(OOM_MARKER_PATH), { recursive: true });
5304
5139
  writeFileSync3(OOM_MARKER_PATH, `RSS=${(effectiveRss / 1024 / 1024).toFixed(0)}MB at ${(/* @__PURE__ */ new Date()).toISOString()}
5305
5140
  `);
5306
5141
  process.stderr.write(`[exed] Wrote OOM marker at ${OOM_MARKER_PATH}
@@ -5415,11 +5250,11 @@ function startApiWatchdog() {
5415
5250
  process.stderr.write(`[exed] API watchdog nudged ${session} (attempt ${nudgeCount}/3, matched: ${matchedPattern.source})
5416
5251
  `);
5417
5252
  try {
5418
- const { appendFileSync: appendFileSync2, mkdirSync: mkdirSync4, statSync: statSyncFs, renameSync: renameSyncFs } = await import("fs");
5253
+ const { appendFileSync, mkdirSync: mkdirSync3, statSync: statSyncFs, renameSync: renameSyncFs } = await import("fs");
5419
5254
  const { join } = await import("path");
5420
5255
  const logDir = join(process.env.EXE_OS_DIR ?? join(process.env.HOME ?? "", ".exe-os"), "logs");
5421
5256
  try {
5422
- mkdirSync4(logDir, { recursive: true });
5257
+ mkdirSync3(logDir, { recursive: true });
5423
5258
  } catch {
5424
5259
  }
5425
5260
  const watchdogLogPath = join(logDir, "api-watchdog.jsonl");
@@ -5428,7 +5263,7 @@ function startApiWatchdog() {
5428
5263
  if (wStat.size > 5 * 1024 * 1024) renameSyncFs(watchdogLogPath, watchdogLogPath + ".1");
5429
5264
  } catch {
5430
5265
  }
5431
- appendFileSync2(
5266
+ appendFileSync(
5432
5267
  watchdogLogPath,
5433
5268
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), session, pattern: matchedPattern.source }) + "\n"
5434
5269
  );
@@ -5633,7 +5468,7 @@ function killOrphanDaemons() {
5633
5468
  }
5634
5469
  function checkExistingDaemon() {
5635
5470
  try {
5636
- if (!existsSync4(PID_PATH)) {
5471
+ if (!existsSync3(PID_PATH)) {
5637
5472
  killOrphanDaemons();
5638
5473
  return false;
5639
5474
  }
@@ -5774,7 +5609,7 @@ try {
5774
5609
  } catch {
5775
5610
  }
5776
5611
  markAsDaemonProcess();
5777
- var DAEMON_BOOT_PATH = path4.join(EXE_AI_DIR, "daemon-boot-ts");
5612
+ var DAEMON_BOOT_PATH = path3.join(EXE_AI_DIR, "daemon-boot-ts");
5778
5613
  writeFileSync3(DAEMON_BOOT_PATH, (/* @__PURE__ */ new Date()).toISOString());
5779
5614
  try {
5780
5615
  chmodSync(DAEMON_BOOT_PATH, 420);
@@ -5800,8 +5635,8 @@ try {
5800
5635
  process.env.EXE_IS_DAEMON = "1";
5801
5636
  if (process.platform === "darwin") {
5802
5637
  try {
5803
- const oldPlist = path4.join(os3.homedir(), "Library", "LaunchAgents", "com.askexe.exed-keepalive.plist");
5804
- if (existsSync4(oldPlist)) {
5638
+ const oldPlist = path3.join(os2.homedir(), "Library", "LaunchAgents", "com.askexe.exed-keepalive.plist");
5639
+ if (existsSync3(oldPlist)) {
5805
5640
  try {
5806
5641
  execSyncNode(`launchctl unload "${oldPlist}" 2>/dev/null`, { timeout: 5e3 });
5807
5642
  } catch {
@@ -5815,7 +5650,7 @@ if (process.platform === "darwin") {
5815
5650
  logBoot({ socketPath: SOCKET_PATH, pidPath: PID_PATH });
5816
5651
  void (async () => {
5817
5652
  try {
5818
- const { cleanupCrashDebris } = await import("../db-backup-VZHSFUVA.js");
5653
+ const { cleanupCrashDebris } = await import("../db-backup-EORG4LBO.js");
5819
5654
  const removed = cleanupCrashDebris();
5820
5655
  if (removed > 0) {
5821
5656
  process.stderr.write(`[exed] Startup cleanup: pruned ${removed} crash-debris file(s) (backups/quarantine).
@@ -5827,8 +5662,8 @@ void (async () => {
5827
5662
  function isCpuStarved() {
5828
5663
  const ratio = parseFloat(process.env.EXE_STARVATION_LOAD_RATIO ?? "1.5");
5829
5664
  if (!isFinite(ratio) || ratio <= 0) return false;
5830
- const load1m = os3.loadavg()[0] ?? 0;
5831
- const cpuCount = os3.cpus().length || 1;
5665
+ const load1m = os2.loadavg()[0] ?? 0;
5666
+ const cpuCount = os2.cpus().length || 1;
5832
5667
  return load1m > cpuCount * ratio;
5833
5668
  }
5834
5669
  async function runSmokeTests() {
@@ -5970,7 +5805,7 @@ function startEventLoopLagDetector() {
5970
5805
  if (clockJump) {
5971
5806
  consecutiveSevereBlocks = 0;
5972
5807
  try {
5973
- unlinkSync2(path4.join(os3.homedir(), ".exe-os", "session-cache", "event-loop-blocked.marker"));
5808
+ unlinkSync2(path3.join(os2.homedir(), ".exe-os", "session-cache", "event-loop-blocked.marker"));
5974
5809
  } catch {
5975
5810
  }
5976
5811
  process.stderr.write("[exed] Event loop lag detector: wall-clock jump/sleep detected; reset without self-heal.\n");
@@ -5980,18 +5815,30 @@ function startEventLoopLagDetector() {
5980
5815
  const msg = `[exed] EVENT LOOP BLOCKED ${(lag / 1e3).toFixed(1)}s \u2014 MCP UNRESPONSIVE. Sessions will die.`;
5981
5816
  process.stderr.write(msg + "\n");
5982
5817
  logDaemonHealth({ event: "event_loop_blocked", pid: process.pid, message: msg, data: { lagMs: lag } });
5983
- void import("../orchestration-events-MB4QVHTD.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
5818
+ void import("../orchestration-events-PZLLPCKY.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
5984
5819
  recordOE({ eventType: "daemon.event_loop_blocked", source: "exe-daemon.lagDetector", severity: "error", durationMs: lag });
5985
5820
  }).catch(() => {
5986
5821
  });
5987
5822
  try {
5988
- writeFileSync3(path4.join(os3.homedir(), ".exe-os", "session-cache", "event-loop-blocked.marker"), `lag=${lag}ms at ${(/* @__PURE__ */ new Date()).toISOString()}
5823
+ writeFileSync3(path3.join(os2.homedir(), ".exe-os", "session-cache", "event-loop-blocked.marker"), `lag=${lag}ms at ${(/* @__PURE__ */ new Date()).toISOString()}
5989
5824
  `);
5990
5825
  } catch {
5991
5826
  }
5827
+ clearDaemonReady();
5828
+ try {
5829
+ const load1m = os2.loadavg()[0] ?? 0;
5830
+ const cpuCount = os2.cpus().length || 1;
5831
+ logDaemonHealth({
5832
+ event: "orchestration_health",
5833
+ pid: process.pid,
5834
+ message: `event-loop blocked ${(lag / 1e3).toFixed(1)}s \u2014 load=${load1m.toFixed(2)} loadPerCore=${(load1m / cpuCount).toFixed(2)}`,
5835
+ data: { lagMs: lag, load1m, cpuCount, loadPerCore: load1m / cpuCount }
5836
+ });
5837
+ } catch {
5838
+ }
5992
5839
  if (isCpuStarved()) {
5993
- const load1m = (os3.loadavg()[0] ?? 0).toFixed(2);
5994
- const cpuCount = os3.cpus().length || 1;
5840
+ const load1m = (os2.loadavg()[0] ?? 0).toFixed(2);
5841
+ const cpuCount = os2.cpus().length || 1;
5995
5842
  process.stderr.write(
5996
5843
  `[exed] SELF-HEAL SUPPRESSED: load=${load1m} cpus=${cpuCount} \u2014 lag is CPU starvation, not internal hang. Skipping restart.
5997
5844
  `
@@ -6030,6 +5877,7 @@ function startEventLoopLagDetector() {
6030
5877
  consecutiveSevereBlocks = 0;
6031
5878
  } else {
6032
5879
  consecutiveSevereBlocks = 0;
5880
+ writeDaemonReady({ pid: process.pid });
6033
5881
  }
6034
5882
  }, 2e3);
6035
5883
  lagTimer.unref();
@@ -6051,7 +5899,7 @@ function startTaskFileResync() {
6051
5899
  const { readdir, readFile } = await import("fs/promises");
6052
5900
  const { getClient } = await import("./database.js");
6053
5901
  const client = getClient();
6054
- const tasksRoot = path4.join(os3.homedir(), ".exe-os", "tasks");
5902
+ const tasksRoot = path3.join(os2.homedir(), ".exe-os", "tasks");
6055
5903
  let synced = 0;
6056
5904
  const walkAsync = async (dir) => {
6057
5905
  let entries;
@@ -6061,7 +5909,7 @@ function startTaskFileResync() {
6061
5909
  return;
6062
5910
  }
6063
5911
  for (const e of entries) {
6064
- const full = path4.join(dir, e.name);
5912
+ const full = path3.join(dir, e.name);
6065
5913
  if (e.isDirectory()) {
6066
5914
  await walkAsync(full);
6067
5915
  continue;
@@ -6086,7 +5934,7 @@ function startTaskFileResync() {
6086
5934
  });
6087
5935
  if (Number(res.rowsAffected ?? 0) > 0) {
6088
5936
  synced++;
6089
- void import("../orchestration-events-MB4QVHTD.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
5937
+ void import("../orchestration-events-PZLLPCKY.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
6090
5938
  recordOE({
6091
5939
  eventType: "task_file.resynced",
6092
5940
  source: "exe-daemon.taskFileResync",
@@ -6122,7 +5970,7 @@ function startTaskGroupBarriers() {
6122
5970
  fired("task_group_barriers");
6123
5971
  if (!await ensureStoreForPolling()) return;
6124
5972
  try {
6125
- const { pollTaskGroupBarriers } = await import("../daemon-orchestration-V6HALVDS.js");
5973
+ const { pollTaskGroupBarriers } = await import("../daemon-orchestration-G4RRTPP7.js");
6126
5974
  const firedCount = await pollTaskGroupBarriers();
6127
5975
  if (firedCount > 0) {
6128
5976
  acted("task_group_barriers");
@@ -6144,7 +5992,7 @@ function startCheckpointGc() {
6144
5992
  fired("checkpoint_gc");
6145
5993
  if (!await ensureStoreForPolling()) return;
6146
5994
  try {
6147
- const { gcStaleCheckpoints } = await import("../daemon-orchestration-V6HALVDS.js");
5995
+ const { gcStaleCheckpoints } = await import("../daemon-orchestration-G4RRTPP7.js");
6148
5996
  const cleared = await gcStaleCheckpoints();
6149
5997
  if (cleared > 0) {
6150
5998
  acted("checkpoint_gc");
@@ -6162,7 +6010,8 @@ function startCheckpointGc() {
6162
6010
  function startDaemonHeartbeat() {
6163
6011
  const HEALTH_HEARTBEAT_MS = 5 * 60 * 1e3;
6164
6012
  setInterval(() => {
6165
- logHeartbeat();
6013
+ void logHeartbeat().catch(() => {
6014
+ });
6166
6015
  }, HEALTH_HEARTBEAT_MS);
6167
6016
  logDaemonHealth({
6168
6017
  event: "mcp_bind",
@@ -6183,14 +6032,14 @@ function startDispatchAckCleanup() {
6183
6032
  function startProjectionWorkerDeferred() {
6184
6033
  setTimeout(async () => {
6185
6034
  try {
6186
- const { startProjectionWorker } = await import("../projection-worker-WWXZK7QD.js");
6035
+ const { startProjectionWorker } = await import("../projection-worker-HWY37MNC.js");
6187
6036
  startProjectionWorker();
6188
6037
  } catch {
6189
6038
  }
6190
6039
  }, 2e4);
6191
6040
  }
6192
6041
  async function startToolTelemetry() {
6193
- const { startToolTelemetryFlush } = await import("../tool-telemetry-BLSVABFJ.js");
6042
+ const { startToolTelemetryFlush } = await import("../tool-telemetry-BS5JXM5M.js");
6194
6043
  startToolTelemetryFlush();
6195
6044
  process.stderr.write("[exed] Tool telemetry started (flush every 5m)\n");
6196
6045
  }
@@ -6287,7 +6136,7 @@ function startLocalFirstTimers() {
6287
6136
  if (_intercomDedupCompleted) return;
6288
6137
  try {
6289
6138
  const { existsSync: markerExists } = await import("fs");
6290
- const markerPath = path4.join(os3.homedir(), ".exe-os", ".intercom-dedup-done");
6139
+ const markerPath = path3.join(os2.homedir(), ".exe-os", ".intercom-dedup-done");
6291
6140
  if (markerExists(markerPath)) {
6292
6141
  _intercomDedupCompleted = true;
6293
6142
  return;
@@ -6333,7 +6182,7 @@ function startLocalFirstTimers() {
6333
6182
  fired("orphan_task_cleanup");
6334
6183
  try {
6335
6184
  if (!await ensureStoreForPolling()) return;
6336
- const { cleanOrphanedTaskFiles } = await import("../tasks-crud-HLJEJ2UU.js");
6185
+ const { cleanOrphanedTaskFiles } = await import("../tasks-crud-24HMTULR.js");
6337
6186
  const count = await cleanOrphanedTaskFiles();
6338
6187
  if (count > 0) {
6339
6188
  acted("orphan_task_cleanup");
@@ -6349,7 +6198,7 @@ function startLocalFirstTimers() {
6349
6198
  fired("task_file_consistency");
6350
6199
  try {
6351
6200
  if (!await ensureStoreForPolling()) return;
6352
- const { checkTaskFileConsistency } = await import("../tasks-crud-HLJEJ2UU.js");
6201
+ const { checkTaskFileConsistency } = await import("../tasks-crud-24HMTULR.js");
6353
6202
  const mismatches = await checkTaskFileConsistency();
6354
6203
  if (mismatches > 0) {
6355
6204
  acted("task_file_consistency");
@@ -6368,7 +6217,7 @@ function startLocalFirstTimers() {
6368
6217
  const TELEMETRY_DAILY_MS = 24 * 60 * 60 * 1e3;
6369
6218
  const telemetryDaily = async () => {
6370
6219
  try {
6371
- const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-AXYPFAPS.js");
6220
+ const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-DWFGC2XJ.js");
6372
6221
  if (!isTelemetryEnabled()) return;
6373
6222
  const { upstream } = await sendTelemetry(24);
6374
6223
  if (upstream.startsWith("sent")) {
@@ -6524,6 +6373,7 @@ export {
6524
6373
  decidePortHolderAction,
6525
6374
  injectRegisterAllTools,
6526
6375
  isCrashLoopBreakerActive,
6376
+ isEventLoopBlockedNow,
6527
6377
  recordDaemonCrash,
6528
6378
  requiresV1BearerAuth,
6529
6379
  rerankViaWorker,