@askexenow/exe-os 0.9.255 → 0.9.259

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 (272) hide show
  1. package/deploy/compose/.env.customer.example +13 -13
  2. package/deploy/compose/.env.example +8 -8
  3. package/deploy/compose/docker-compose.yml +18 -18
  4. package/deploy/compose/generate-env.ts +22 -18
  5. package/deploy/compose/init-db.sql +221 -20
  6. package/deploy/stack-manifests/v0.9.json +1207 -1136
  7. package/dist/{active-agent-DTZ6VJIR.js → active-agent-IGZXTTV4.js} +3 -3
  8. package/dist/{active-agent-7QNK5CJZ.js → active-agent-OYUXMTHS.js} +3 -3
  9. package/dist/{agentic-ontology-UZK33N6I.js → agentic-ontology-5WT23SLZ.js} +1 -1
  10. package/dist/{backfill-metadata-R7PNZ5TX.js → backfill-metadata-EG52U3GF.js} +4 -4
  11. package/dist/{behaviors-G6QHSQBN.js → behaviors-2TZCFJLU.js} +3 -3
  12. package/dist/bin/age-ontology-load.js +2 -2
  13. package/dist/bin/agentic-ontology-backfill.js +5 -5
  14. package/dist/bin/agentic-reflection-backfill.js +6 -6
  15. package/dist/bin/agentic-semantic-label.js +5 -5
  16. package/dist/bin/backfill-conversations.js +6 -5
  17. package/dist/bin/backfill-responses.js +6 -5
  18. package/dist/bin/backfill-vectors.js +7 -6
  19. package/dist/bin/bulk-sync-postgres.js +6 -6
  20. package/dist/bin/cleanup-stale-review-tasks.js +9 -9
  21. package/dist/bin/cli.js +17 -17
  22. package/dist/bin/deferred-daemon-restart.js +4 -1
  23. package/dist/bin/exe-agent-config.js +2 -2
  24. package/dist/bin/exe-agent.js +4 -4
  25. package/dist/bin/exe-assign.js +8 -7
  26. package/dist/bin/exe-boot.js +16 -16
  27. package/dist/bin/exe-call.js +4 -4
  28. package/dist/bin/exe-cloud.js +4 -4
  29. package/dist/bin/exe-dispatch.js +9 -9
  30. package/dist/bin/exe-doctor.js +1 -1
  31. package/dist/bin/exe-export-behaviors.js +7 -7
  32. package/dist/bin/exe-forget.js +6 -6
  33. package/dist/bin/exe-gateway.js +9 -9
  34. package/dist/bin/exe-heartbeat.js +9 -9
  35. package/dist/bin/exe-kill.js +12 -12
  36. package/dist/bin/exe-launch-agent.js +16 -16
  37. package/dist/bin/exe-new-employee.js +6 -6
  38. package/dist/bin/exe-pending-messages.js +11 -10
  39. package/dist/bin/exe-pending-notifications.js +9 -9
  40. package/dist/bin/exe-pending-reviews.js +11 -9
  41. package/dist/bin/exe-rename.js +4 -4
  42. package/dist/bin/exe-review.js +11 -11
  43. package/dist/bin/exe-search.js +5 -5
  44. package/dist/bin/exe-session-cleanup.js +14 -14
  45. package/dist/bin/exe-settings.js +4 -4
  46. package/dist/bin/exe-start-codex.js +11 -11
  47. package/dist/bin/exe-start-opencode.js +8 -8
  48. package/dist/bin/exe-status.js +10 -10
  49. package/dist/bin/exe-support.js +3 -1
  50. package/dist/bin/exe-team.js +3 -3
  51. package/dist/bin/git-sweep.js +71 -11
  52. package/dist/bin/graph-backfill.js +4 -4
  53. package/dist/bin/graph-export.js +5 -5
  54. package/dist/bin/graph-layer-benchmark.js +7 -7
  55. package/dist/bin/import-history.js +7 -7
  56. package/dist/bin/install.js +12 -9
  57. package/dist/bin/intercom-check.js +4 -4
  58. package/dist/bin/mcp-sessions.js +2 -2
  59. package/dist/bin/orchestration-metrics.js +4 -4
  60. package/dist/bin/postgres-agentic-reflection-backfill.js +7 -7
  61. package/dist/bin/postgres-agentic-semantic-backfill.js +7 -7
  62. package/dist/bin/scan-tasks.js +9 -9
  63. package/dist/bin/setup.js +1 -1
  64. package/dist/bin/shard-migrate.js +4 -4
  65. package/dist/bin/stack-update.js +20 -3
  66. package/dist/bin/vps-health-gate.js +1 -1
  67. package/dist/{capacity-monitor-QMKII67L.js → capacity-monitor-CTFWWTCR.js} +10 -10
  68. package/dist/{catchup-brief-CNISNLV7.js → catchup-brief-UML47LXI.js} +11 -11
  69. package/dist/{chunk-QP4FHME2.js → chunk-235ZCOYB.js} +18 -6
  70. package/dist/{chunk-2NEQQCRC.js → chunk-25JAXHON.js} +1 -1
  71. package/dist/{chunk-MU6ESLYL.js → chunk-2PFNATXD.js} +1 -1
  72. package/dist/chunk-2XZ6X3PJ.js +13 -0
  73. package/dist/chunk-3XX3CDKF.js +9 -0
  74. package/dist/{chunk-ZTB6E2ZL.js → chunk-4FGTT26Q.js} +1 -1
  75. package/dist/{chunk-YYSQAM4W.js → chunk-4TYAHVDI.js} +8 -8
  76. package/dist/{chunk-2QKNXGII.js → chunk-4VECWOUO.js} +2 -2
  77. package/dist/{chunk-YXMXP45V.js → chunk-57C3MZPQ.js} +2 -2
  78. package/dist/{chunk-FTNNNAMH.js → chunk-5JYCTIQD.js} +1 -1
  79. package/dist/{chunk-CS267UMH.js → chunk-5LDTCWYX.js} +79 -19
  80. package/dist/{chunk-FQVITYVF.js → chunk-6D2IZ5MB.js} +2 -2
  81. package/dist/{chunk-ZG3HADWE.js → chunk-7UJRF4WF.js} +1 -1
  82. package/dist/{chunk-JFVITKXI.js → chunk-A2UPDE3J.js} +1 -1
  83. package/dist/{chunk-KOCQAMAM.js → chunk-ANYOAZCZ.js} +238 -5
  84. package/dist/{chunk-PSQNT5DS.js → chunk-AQS2B3HC.js} +8 -8
  85. package/dist/{chunk-ABNALOLM.js → chunk-BGEXTWGR.js} +3 -3
  86. package/dist/{chunk-LPK5JPME.js → chunk-BPZL5YOM.js} +1 -1
  87. package/dist/{chunk-RLDOG7DI.js → chunk-C6SSCNOC.js} +2516 -2289
  88. package/dist/{chunk-JGEGEOVP.js → chunk-COKTAJUZ.js} +1 -1
  89. package/dist/{chunk-MRZE5IOP.js → chunk-CXOX7TRG.js} +1 -1
  90. package/dist/{chunk-6LFFIEDM.js → chunk-DU64OESH.js} +1 -1
  91. package/dist/{chunk-LYIUESG2.js → chunk-DYURFBPS.js} +10 -10
  92. package/dist/{chunk-X3SS45PO.js → chunk-FPXZY3FY.js} +1 -1
  93. package/dist/{chunk-TVTRMINO.js → chunk-FUGZF7VR.js} +1 -1
  94. package/dist/{chunk-O7SFCX5B.js → chunk-GB4FI66P.js} +2 -2
  95. package/dist/{chunk-VGWQBI76.js → chunk-GBR4MAAK.js} +1 -1
  96. package/dist/chunk-GH4LVBQM.js +371 -0
  97. package/dist/{chunk-AIXZ5O7U.js → chunk-GIHMDOSK.js} +1 -1
  98. package/dist/{chunk-RDCE652I.js → chunk-HDWVXSGO.js} +1 -1
  99. package/dist/{chunk-RF54NGPJ.js → chunk-IJ7R3MXE.js} +3 -5
  100. package/dist/{chunk-R7FBOZT5.js → chunk-ISL3NSVX.js} +1 -1
  101. package/dist/{chunk-5B2AEXVA.js → chunk-IVSRRIRG.js} +1 -1
  102. package/dist/{chunk-SD2R3SEA.js → chunk-J3YNCJ4A.js} +1 -1
  103. package/dist/{chunk-5IZYSS3M.js → chunk-JE4C74EE.js} +4 -4
  104. package/dist/{chunk-VRVHIVUE.js → chunk-KSR2PNRW.js} +2 -2
  105. package/dist/{chunk-LL2ARYTZ.js → chunk-L3PY4NFQ.js} +1 -1
  106. package/dist/{chunk-VFATLVRX.js → chunk-L5VPUOB6.js} +1 -1
  107. package/dist/{chunk-3VLFVOM7.js → chunk-LRKJGSNH.js} +2 -2
  108. package/dist/{chunk-4FT3SQAS.js → chunk-LVY74L2J.js} +2 -2
  109. package/dist/{chunk-X4T7LR2X.js → chunk-M7PZFYHE.js} +2 -2
  110. package/dist/{chunk-CIX64N7D.js → chunk-MGTVPIEZ.js} +1 -1
  111. package/dist/{chunk-MXCBORCC.js → chunk-MKTEGZ37.js} +3 -3
  112. package/dist/chunk-MMRUBN3I.js +36 -0
  113. package/dist/{chunk-4MONXPWR.js → chunk-MPXLF7TA.js} +1 -1
  114. package/dist/{chunk-6QMXKKFD.js → chunk-N27CTUFU.js} +1 -1
  115. package/dist/{chunk-YDHPC4PX.js → chunk-N4ES27RI.js} +3 -3
  116. package/dist/{chunk-WIRJ574R.js → chunk-NGQQRGLP.js} +2 -2
  117. package/dist/{chunk-AQOCHSIR.js → chunk-OCJ5GZKV.js} +4 -4
  118. package/dist/{chunk-O477L4LV.js → chunk-OSPS5N2I.js} +1 -1
  119. package/dist/{chunk-5WEH43HH.js → chunk-PQHA6X6Y.js} +1 -1
  120. package/dist/{chunk-DJYIBHN5.js → chunk-PQQTSNXS.js} +3 -3
  121. package/dist/{chunk-LGFB67MY.js → chunk-Q3GLQDZI.js} +1 -1
  122. package/dist/{chunk-7GR7VBBW.js → chunk-QUC27OCW.js} +1 -1
  123. package/dist/{chunk-5NBOFYJG.js → chunk-QYNFWFFH.js} +4 -4
  124. package/dist/{chunk-X7I6NLIA.js → chunk-T2EUNNUX.js} +5 -5
  125. package/dist/{chunk-VRWOLLKN.js → chunk-T4NFOOPB.js} +2 -2
  126. package/dist/{chunk-2YJSDJEH.js → chunk-TZPHTI5Q.js} +1 -1
  127. package/dist/{chunk-CQSFIQGN.js → chunk-UOZ5KUNN.js} +1 -1
  128. package/dist/{chunk-5R4R743Q.js → chunk-V2UVWYHO.js} +17 -15
  129. package/dist/{chunk-VKCZ3OGM.js → chunk-VD676VIC.js} +4 -4
  130. package/dist/{chunk-USLVSLQ5.js → chunk-VDCPKJUQ.js} +1 -1
  131. package/dist/{chunk-Y7NMPQXZ.js → chunk-VLX6AHTD.js} +8 -8
  132. package/dist/{chunk-ITPIBVSG.js → chunk-WMZTSHNX.js} +83 -1
  133. package/dist/{chunk-5U7WB4YG.js → chunk-WVBZ3QBR.js} +2 -2
  134. package/dist/{chunk-3EMZZZNU.js → chunk-X2RKYKTP.js} +1 -1
  135. package/dist/{chunk-XTIHYH64.js → chunk-YY2BCIAP.js} +2 -2
  136. package/dist/{chunk-Z6GHDYQI.js → chunk-Z2AEOVEZ.js} +30 -6
  137. package/dist/{chunk-PHTRZQR4.js → chunk-ZBDAFYDD.js} +4 -4
  138. package/dist/{chunk-E4CCKWZN.js → chunk-ZKFTDL4M.js} +1 -1
  139. package/dist/{co-activation-AIVMI5U2.js → co-activation-UNVL5JCP.js} +2 -2
  140. package/dist/{co-occurrence-L6QOQTJB.js → co-occurrence-ETAVWYVE.js} +2 -2
  141. package/dist/{code-context-index-DYHYVJHX.js → code-context-index-DCQYAYA2.js} +3 -2
  142. package/dist/{crdt-sync-YBMDPFNT.js → crdt-sync-AH7N6QOE.js} +1 -1
  143. package/dist/{crm-webhook-QO3ZESKR.js → crm-webhook-R6546T3Y.js} +2 -2
  144. package/dist/{cto-delegation-gate-UFPVFLIW.js → cto-delegation-gate-VB4TMZ3I.js} +8 -8
  145. package/dist/{daemon-orchestration-6XAISQ7B.js → daemon-orchestration-YAJKIL6Q.js} +12 -12
  146. package/dist/{db-backup-7UMCTS44.js → db-backup-2RG6VHT7.js} +11 -3
  147. package/dist/{dreaming-FJ75QVGZ.js → dreaming-WMBTSXGD.js} +9 -9
  148. package/dist/{exe-drift-OH3WV2ZQ.js → exe-drift-MQZGYHEN.js} +3 -3
  149. package/dist/{exe-export-UYKYNVBU.js → exe-export-E4BDIHOC.js} +5 -5
  150. package/dist/{exe-import-Q4FNSMLJ.js → exe-import-IWAD4HN6.js} +5 -5
  151. package/dist/{exe-key-22LOIIUX.js → exe-key-L2RV7XJX.js} +2 -2
  152. package/dist/{exe-snapshot-J7CL6QEL.js → exe-snapshot-IOGN4ARV.js} +12 -12
  153. package/dist/{fast-db-init-QXGL2PKQ.js → fast-db-init-GCY3F74H.js} +1 -1
  154. package/dist/gateway/index.js +8 -8
  155. package/dist/{git-staleness-YVWDCFIE.js → git-staleness-BQIFNZIU.js} +2 -2
  156. package/dist/{git-task-sweep-RRCOTTIS.js → git-task-sweep-GSKS6WKR.js} +9 -9
  157. package/dist/{global-procedures-FCGWAFES.js → global-procedures-3DJUA5OX.js} +3 -3
  158. package/dist/{graph-auto-extract-RUQC5IIS.js → graph-auto-extract-2I44WRDY.js} +2 -2
  159. package/dist/hooks/bug-report-worker.js +11 -11
  160. package/dist/hooks/codex-stop-task-finalizer.js +11 -11
  161. package/dist/hooks/commit-complete.js +11 -11
  162. package/dist/hooks/error-recall.js +6 -6
  163. package/dist/hooks/exe-heartbeat-hook.js +3 -3
  164. package/dist/hooks/ingest-worker.js +3 -2
  165. package/dist/hooks/ingest.js +6 -6
  166. package/dist/hooks/instructions-loaded.js +4 -4
  167. package/dist/hooks/manifest.json +20 -20
  168. package/dist/hooks/notification.js +4 -4
  169. package/dist/hooks/post-compact.js +10 -10
  170. package/dist/hooks/post-tool-combined.js +6 -6
  171. package/dist/hooks/pre-compact.js +14 -13
  172. package/dist/hooks/pre-tool-use.js +14 -14
  173. package/dist/hooks/prompt-submit.js +22 -22
  174. package/dist/hooks/session-end.js +19 -18
  175. package/dist/hooks/session-start.js +11 -11
  176. package/dist/hooks/stop.js +70 -17
  177. package/dist/hooks/subagent-stop.js +10 -10
  178. package/dist/hooks/summary-worker.js +17 -16
  179. package/dist/index.js +17 -17
  180. package/dist/{installer-7SMJC3SX.js → installer-6MQCAHUG.js} +5 -5
  181. package/dist/{installer-GFZVC43I.js → installer-TCMPFSSP.js} +5 -5
  182. package/dist/{installer-34DCTB5B.js → installer-ZY2BKTEO.js} +5 -5
  183. package/dist/lib/cloud-sync.js +4 -4
  184. package/dist/lib/consolidation.js +5 -5
  185. package/dist/lib/database.js +2 -2
  186. package/dist/lib/db-daemon-client.js +58 -13
  187. package/dist/lib/db.js +2 -2
  188. package/dist/lib/embedder.js +3 -2
  189. package/dist/lib/employee-templates.js +4 -4
  190. package/dist/lib/employees.js +2 -2
  191. package/dist/lib/exe-daemon-client.js +2 -1
  192. package/dist/lib/exe-daemon.js +255 -104
  193. package/dist/lib/hybrid-search.js +5 -5
  194. package/dist/lib/identity.js +2 -2
  195. package/dist/lib/messaging.js +9 -9
  196. package/dist/lib/reminders.js +3 -3
  197. package/dist/lib/schedules.js +5 -5
  198. package/dist/lib/session-registry.js +4 -4
  199. package/dist/lib/skill-learning.js +4 -4
  200. package/dist/lib/store.js +4 -4
  201. package/dist/lib/task-router.js +3 -3
  202. package/dist/lib/tasks.js +10 -10
  203. package/dist/lib/tmux-routing.js +8 -8
  204. package/dist/lib/token-spend.js +3 -3
  205. package/dist/mcp/register-tools.js +59 -56
  206. package/dist/mcp/server.js +60 -57
  207. package/dist/mcp/tools/complete-reminder.js +4 -4
  208. package/dist/mcp/tools/create-reminder.js +4 -4
  209. package/dist/mcp/tools/create-task.js +12 -12
  210. package/dist/mcp/tools/deactivate-behavior.js +5 -5
  211. package/dist/mcp/tools/list-reminders.js +4 -4
  212. package/dist/mcp/tools/list-tasks.js +12 -12
  213. package/dist/mcp/tools/send-message.js +11 -11
  214. package/dist/mcp/tools/update-task.js +11 -11
  215. package/dist/{mcp-http-config-MZMHKMJC.js → mcp-http-config-VUDZ3D5D.js} +3 -3
  216. package/dist/{memory-cards-3SFXU6IP.js → memory-cards-ZOOPC2WF.js} +2 -2
  217. package/dist/{memory-graph-extractor-T57YQQCW.js → memory-graph-extractor-RRQMUBMI.js} +3 -3
  218. package/dist/{memory-poisoning-defense-O53AHMTZ.js → memory-poisoning-defense-UQMNLG6H.js} +2 -2
  219. package/dist/{memory-queue-client-ITWQIFSD.js → memory-queue-client-TPQDAA4D.js} +3 -2
  220. package/dist/{memory-reflection-YPP2JC2S.js → memory-reflection-GSGXAGXV.js} +2 -2
  221. package/dist/{notifications-BETWD6EK.js → notifications-ZKGLZVCU.js} +8 -8
  222. package/dist/{orchestration-events-A5D52NXX.js → orchestration-events-7RMWC5SS.js} +3 -3
  223. package/dist/{orchestrator-X564XCWC.js → orchestrator-A6MX2OHA.js} +10 -10
  224. package/dist/{pipeline-router-RVHLL7UA.js → pipeline-router-6ZBYJD2U.js} +3 -3
  225. package/dist/{plan-limits-ANAVC6PM.js → plan-limits-4XH4A7IA.js} +3 -3
  226. package/dist/{project-boot-ENMCAL7G.js → project-boot-7ZEIDWUG.js} +3 -2
  227. package/dist/{projection-worker-O3HBG5QK.js → projection-worker-YKKBNQZT.js} +130 -51
  228. package/dist/{reranker-SRJL4IWB.js → reranker-DN2A3H6O.js} +1 -1
  229. package/dist/{review-polling-5JTTHHEO.js → review-polling-PK3CY4NI.js} +9 -9
  230. package/dist/runtime/index.js +11 -11
  231. package/dist/{session-events-RCSYHQQ2.js → session-events-IYU6FYHH.js} +9 -9
  232. package/dist/{session-kill-telemetry-AL3H4ELS.js → session-kill-telemetry-G2VV4CAH.js} +3 -3
  233. package/dist/{session-scope-ZB4SR3AX.js → session-scope-DHTVH3D4.js} +8 -8
  234. package/dist/{setup-wizard-HXTADFXI.js → setup-wizard-IA5ISHQ2.js} +1 -1
  235. package/dist/{skill-refinement-TT4VDYYW.js → skill-refinement-6PBAFLWP.js} +2 -2
  236. package/dist/{stack-release-7WDKQOCO.js → stack-release-NW7MV3WV.js} +41 -11
  237. package/dist/{stack-update-F4CQWMGV.js → stack-update-5SM62R3O.js} +3 -1
  238. package/dist/{steward-gate-HSV67KLF.js → steward-gate-EQV6CZKY.js} +3 -3
  239. package/dist/support-outbox-SZVLHHZG.js +295 -0
  240. package/dist/{task-enforcement-A6AZTYAN.js → task-enforcement-2LS5DOXK.js} +8 -8
  241. package/dist/{task-scope-XKNAY5S7.js → task-scope-AKF3CSWO.js} +8 -8
  242. package/dist/{tasks-crud-F732BVOE.js → tasks-crud-KOIA5SAH.js} +8 -8
  243. package/dist/{tasks-notify-LJ65U7DF.js → tasks-notify-7ZTE4ZQM.js} +9 -9
  244. package/dist/{tasks-review-Y5F4HRAR.js → tasks-review-VMMMAK2Y.js} +8 -8
  245. package/dist/{telemetry-upload-HVYO6FL3.js → telemetry-upload-YLW4NAUF.js} +15 -8
  246. package/dist/{token-budget-VODGJYKX.js → token-budget-NA4OLFNP.js} +2 -2
  247. package/dist/{tool-capability-index-PZWWVABO.js → tool-capability-index-C73KVY5O.js} +1 -1
  248. package/dist/{tool-telemetry-5BSTF3P6.js → tool-telemetry-OVI5KL4S.js} +1 -1
  249. package/dist/tui/App.js +16 -16
  250. package/dist/{tui-data-EHJWRNRZ.js → tui-data-5NT24CC5.js} +8 -8
  251. package/dist/{worker-gate-4AS4K7G4.js → worker-gate-AQLJUQ5G.js} +1 -1
  252. package/dist/{workflow-engine-BXGNFNUW.js → workflow-engine-TRGGUNIZ.js} +2 -2
  253. package/dist/{worktree-3N5BPITS.js → worktree-NK7GZNEA.js} +4 -4
  254. package/dist/worktree-sweep-5XVZCH6A.js +18 -0
  255. package/package.json +3 -2
  256. package/release-notes.json +32 -33
  257. package/stack.release.json +48 -48
  258. package/dist/prediction-log-DOEOHDHS.js +0 -120
  259. package/dist/support-outbox-KEJ73I3F.js +0 -206
  260. /package/dist/{chunk-AWVDA2FL.js → chunk-2H3FVAN3.js} +0 -0
  261. /package/dist/{chunk-VPHOOQLR.js → chunk-3GHTBVZO.js} +0 -0
  262. /package/dist/{chunk-CCPCIW4Z.js → chunk-BBPRL2MP.js} +0 -0
  263. /package/dist/{chunk-X2E6W3DB.js → chunk-BRSI3FD6.js} +0 -0
  264. /package/dist/{chunk-Y2FVN7CX.js → chunk-EYLQRPHF.js} +0 -0
  265. /package/dist/{chunk-4S5TEBXD.js → chunk-H6QJT5O5.js} +0 -0
  266. /package/dist/{chunk-FCII2MMI.js → chunk-J5CAYOJU.js} +0 -0
  267. /package/dist/{chunk-LY2DYTDL.js → chunk-RFJESVEL.js} +0 -0
  268. /package/dist/{chunk-GBHQ5TXO.js → chunk-UOOCGJUE.js} +0 -0
  269. /package/dist/{core-memory-WFP2L52F.js → core-memory-VZFTGOFE.js} +0 -0
  270. /package/dist/{entity-boost-RTYXAOWV.js → entity-boost-OAB2PZQP.js} +0 -0
  271. /package/dist/{message-queue-client-2CACBUA4.js → message-queue-client-YTKTHAYO.js} +0 -0
  272. /package/dist/{wiki-acl-MS7QLQCR.js → wiki-acl-UCPOROPR.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionScopeFilter
3
- } from "./chunk-CS267UMH.js";
3
+ } from "./chunk-5LDTCWYX.js";
4
4
 
5
5
  // src/lib/git-task-sweep.ts
6
6
  import { execSync } from "child_process";
@@ -178,7 +178,7 @@ async function sweepTasks(projectName, options = {}) {
178
178
  }
179
179
  if (!dryRun) {
180
180
  try {
181
- const { updateTaskStatus } = await import("./tasks-crud-F732BVOE.js");
181
+ const { updateTaskStatus } = await import("./tasks-crud-KOIA5SAH.js");
182
182
  await updateTaskStatus({
183
183
  taskId: task.id,
184
184
  status: "needs_review",
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  sessionScopeFilter
3
- } from "./chunk-CS267UMH.js";
3
+ } from "./chunk-5LDTCWYX.js";
4
4
  import {
5
5
  getClient,
6
6
  getIdentity
7
- } from "./chunk-5U7WB4YG.js";
7
+ } from "./chunk-WVBZ3QBR.js";
8
8
 
9
9
  // src/lib/dreaming.ts
10
10
  var DreamingEngine = class {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getClient
3
- } from "./chunk-5U7WB4YG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
4
 
5
5
  // src/lib/memory-graph-extractor.ts
6
6
  function entityId(type, name) {
@@ -247,7 +247,7 @@ async function upsertMemoryGraph(result, memoryId) {
247
247
  });
248
248
  }
249
249
  try {
250
- const { createCoOccurrenceEdges } = await import("./co-occurrence-L6QOQTJB.js");
250
+ const { createCoOccurrenceEdges } = await import("./co-occurrence-ETAVWYVE.js");
251
251
  await createCoOccurrenceEdges(result.entities, memoryId);
252
252
  } catch {
253
253
  }
@@ -2,7 +2,7 @@ import {
2
2
  connectEmbedDaemon,
3
3
  disconnectClient,
4
4
  embedViaClient
5
- } from "./chunk-Z6GHDYQI.js";
5
+ } from "./chunk-Z2AEOVEZ.js";
6
6
  import {
7
7
  EMBEDDING_DIM
8
8
  } from "./chunk-FXU7JOXK.js";
@@ -4,17 +4,17 @@ import {
4
4
  resolveExeSession,
5
5
  sendIntercom,
6
6
  strictSessionScopeFilter
7
- } from "./chunk-CS267UMH.js";
7
+ } from "./chunk-5LDTCWYX.js";
8
8
  import {
9
9
  parseMessage,
10
10
  serializeMessage
11
11
  } from "./chunk-4JERP7NT.js";
12
12
  import {
13
13
  recordOrchestrationEventBestEffort
14
- } from "./chunk-USLVSLQ5.js";
14
+ } from "./chunk-VDCPKJUQ.js";
15
15
  import {
16
16
  getClient
17
- } from "./chunk-5U7WB4YG.js";
17
+ } from "./chunk-WVBZ3QBR.js";
18
18
 
19
19
  // src/lib/messaging.ts
20
20
  import crypto from "crypto";
@@ -0,0 +1,36 @@
1
+ // src/lib/support-report-marker.ts
2
+ import { appendFile, readFile } from "fs/promises";
3
+ import { appendFileSync, readFileSync } from "fs";
4
+ var SUPPORT_REPORT_SENT_MARKER = "upstream_sent: true";
5
+ function isSupportReportSentStatus(status) {
6
+ return /^sent\b/.test(status.trim());
7
+ }
8
+ async function markSupportReportSent(filePath) {
9
+ try {
10
+ const content = await readFile(filePath, "utf8");
11
+ if (!content.includes(SUPPORT_REPORT_SENT_MARKER)) {
12
+ await appendFile(filePath, `
13
+ ${SUPPORT_REPORT_SENT_MARKER}
14
+ `, { encoding: "utf8" });
15
+ }
16
+ } catch {
17
+ }
18
+ }
19
+ function markSupportReportSentSync(filePath) {
20
+ try {
21
+ const content = readFileSync(filePath, "utf8");
22
+ if (!content.includes(SUPPORT_REPORT_SENT_MARKER)) {
23
+ appendFileSync(filePath, `
24
+ ${SUPPORT_REPORT_SENT_MARKER}
25
+ `, { encoding: "utf8" });
26
+ }
27
+ } catch {
28
+ }
29
+ }
30
+
31
+ export {
32
+ SUPPORT_REPORT_SENT_MARKER,
33
+ isSupportReportSentStatus,
34
+ markSupportReportSent,
35
+ markSupportReportSentSync
36
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getIdentity,
3
3
  loadEmployeesSync
4
- } from "./chunk-5U7WB4YG.js";
4
+ } from "./chunk-WVBZ3QBR.js";
5
5
 
6
6
  // src/lib/drift-probes.ts
7
7
  var DRIFT_THRESHOLD = 80;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getClient
3
- } from "./chunk-5U7WB4YG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
4
 
5
5
  // src/lib/session-kill-telemetry.ts
6
6
  import crypto from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  fastDbInit
3
- } from "./chunk-LY2DYTDL.js";
3
+ } from "./chunk-RFJESVEL.js";
4
4
  import {
5
5
  sessionScopeFilter
6
- } from "./chunk-CS267UMH.js";
6
+ } from "./chunk-5LDTCWYX.js";
7
7
  import {
8
8
  formatStatusAll,
9
9
  formatStatusDeep,
@@ -14,7 +14,7 @@ import {
14
14
  getClient,
15
15
  isCoordinatorRole,
16
16
  loadEmployees
17
- } from "./chunk-5U7WB4YG.js";
17
+ } from "./chunk-WVBZ3QBR.js";
18
18
  import {
19
19
  isMainModule
20
20
  } from "./chunk-6Y4B3QF6.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  storeBehavior
3
- } from "./chunk-2NEQQCRC.js";
3
+ } from "./chunk-25JAXHON.js";
4
4
  import {
5
5
  getClient
6
- } from "./chunk-5U7WB4YG.js";
6
+ } from "./chunk-WVBZ3QBR.js";
7
7
  import {
8
8
  loadConfig
9
9
  } from "./chunk-VXIMSRTO.js";
@@ -5,13 +5,13 @@ import {
5
5
  notifyParentExe,
6
6
  resolveExeSession,
7
7
  sendIntercom
8
- } from "./chunk-CS267UMH.js";
8
+ } from "./chunk-5LDTCWYX.js";
9
9
  import {
10
10
  getTransport
11
11
  } from "./chunk-MVW62NIZ.js";
12
12
  import {
13
13
  recordOrchestrationEventBestEffort
14
- } from "./chunk-USLVSLQ5.js";
14
+ } from "./chunk-VDCPKJUQ.js";
15
15
  import {
16
16
  getAgentRuntime
17
17
  } from "./chunk-XJUUWHVN.js";
@@ -22,7 +22,7 @@ import {
22
22
  isCoordinatorName,
23
23
  isMultiInstance,
24
24
  shouldAutoInstance
25
- } from "./chunk-5U7WB4YG.js";
25
+ } from "./chunk-WVBZ3QBR.js";
26
26
 
27
27
  // src/lib/tasks-notify.ts
28
28
  var VERIFY_DELAY_MS = 1e4;
@@ -68,7 +68,7 @@ async function dispatchTaskToEmployee(input) {
68
68
  let crossProject = false;
69
69
  if (input.projectName) {
70
70
  try {
71
- const { assertSessionScope } = await import("./session-scope-ZB4SR3AX.js");
71
+ const { assertSessionScope } = await import("./session-scope-DHTVH3D4.js");
72
72
  const check = assertSessionScope("dispatch_task", input.projectName);
73
73
  if (check.reason === "cross_session_denied") {
74
74
  crossProject = true;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  processCRMEvent
3
- } from "./chunk-VPHOOQLR.js";
3
+ } from "./chunk-3GHTBVZO.js";
4
4
 
5
5
  // src/gateway/adapters/crm-webhook.ts
6
6
  function parseTwentyWebhook(payload) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isCoordinatorRole
3
- } from "./chunk-5U7WB4YG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
4
 
5
5
  // src/lib/task-router.ts
6
6
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  routeTask
3
- } from "./chunk-5WEH43HH.js";
3
+ } from "./chunk-PQHA6X6Y.js";
4
4
  import {
5
5
  createTaskCore,
6
6
  employeeSessionName,
@@ -9,11 +9,11 @@ import {
9
9
  isEmployeeAlive,
10
10
  sessionScopeFilter,
11
11
  updateTaskStatus
12
- } from "./chunk-CS267UMH.js";
12
+ } from "./chunk-5LDTCWYX.js";
13
13
  import {
14
14
  DEFAULT_COORDINATOR_TEMPLATE_NAME,
15
15
  getCoordinatorName
16
- } from "./chunk-5U7WB4YG.js";
16
+ } from "./chunk-WVBZ3QBR.js";
17
17
 
18
18
  // src/runtime/orchestrator.ts
19
19
  var STALE_THRESHOLD_MS = 2 * 60 * 60 * 1e3;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  isClientConnected,
6
6
  sendDaemonRequest
7
- } from "./chunk-Z6GHDYQI.js";
7
+ } from "./chunk-Z2AEOVEZ.js";
8
8
 
9
9
  // src/lib/memory-queue-client.ts
10
10
  async function writeMemoryViaDaemon(entry) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writeMemoryViaDaemon
3
- } from "./chunk-LGFB67MY.js";
3
+ } from "./chunk-Q3GLQDZI.js";
4
4
 
5
5
  // src/lib/auto-checkpoint.ts
6
6
  var FILE_RE = /(?:^|\s)([\w./-]+\.(?:ts|tsx|js|jsx|json|md|yml|yaml|sql|go|py|css|scss|html|sh))(?:\b|$)/g;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MultiAgentOrchestrator
3
- } from "./chunk-DJYIBHN5.js";
3
+ } from "./chunk-PQQTSNXS.js";
4
4
  import {
5
5
  createQuietRenderer,
6
6
  createTerminalRenderer,
@@ -206,7 +206,7 @@ function createExeOSHooks(config) {
206
206
  );
207
207
  }
208
208
  try {
209
- const { listBehaviors } = await import("./behaviors-G6QHSQBN.js");
209
+ const { listBehaviors } = await import("./behaviors-2TZCFJLU.js");
210
210
  const behaviors = await listBehaviors(config.agentId, config.projectName, 12);
211
211
  if (behaviors.length > 0) {
212
212
  process.stderr.write(
@@ -327,7 +327,7 @@ function createExeOSHooks(config) {
327
327
  async onSubagentStop(_reason) {
328
328
  try {
329
329
  const { getClient } = await import("./lib/database.js");
330
- const { sessionScopeFilter } = await import("./task-scope-XKNAY5S7.js");
330
+ const { sessionScopeFilter } = await import("./task-scope-AKF3CSWO.js");
331
331
  const client = getClient();
332
332
  const ehScope = sessionScopeFilter();
333
333
  const tasks = await client.execute({
@@ -419,7 +419,7 @@ function createExeOSHooks(config) {
419
419
  try {
420
420
  const { writeMemory, flushBatch } = await import("./lib/store.js");
421
421
  const { getClient } = await import("./lib/database.js");
422
- const { sessionScopeFilter: cpScopeFilter } = await import("./task-scope-XKNAY5S7.js");
422
+ const { sessionScopeFilter: cpScopeFilter } = await import("./task-scope-AKF3CSWO.js");
423
423
  const client = getClient();
424
424
  const cpScope = cpScopeFilter();
425
425
  const tasks = await client.execute({
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  recordSessionKill
3
- } from "./chunk-6QMXKKFD.js";
3
+ } from "./chunk-N27CTUFU.js";
4
4
  import {
5
5
  sessionScopeFilter,
6
6
  verifyPaneAtCapacity,
7
7
  writeNotification
8
- } from "./chunk-CS267UMH.js";
8
+ } from "./chunk-5LDTCWYX.js";
9
9
  import {
10
10
  listSessions
11
- } from "./chunk-SD2R3SEA.js";
11
+ } from "./chunk-J3YNCJ4A.js";
12
12
  import {
13
13
  getTransport
14
14
  } from "./chunk-MVW62NIZ.js";
15
15
  import {
16
16
  recordOrchestrationEventBestEffort
17
- } from "./chunk-USLVSLQ5.js";
17
+ } from "./chunk-VDCPKJUQ.js";
18
18
  import {
19
19
  getClient,
20
20
  isCoordinatorName
21
- } from "./chunk-5U7WB4YG.js";
21
+ } from "./chunk-WVBZ3QBR.js";
22
22
 
23
23
  // src/lib/capacity-monitor.ts
24
24
  var CAPACITY_PATTERNS = [
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GNHN5HRQ.js";
4
4
  import {
5
5
  buildClaudeHttpMcpEntry
6
- } from "./chunk-MRZE5IOP.js";
6
+ } from "./chunk-CXOX7TRG.js";
7
7
  import {
8
8
  EXE_HOOKS,
9
9
  isLegacyHomeDirHookCommand,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-L3TB7CC3.js";
12
12
  import {
13
13
  ensureAllAgentSymlinks
14
- } from "./chunk-R7FBOZT5.js";
14
+ } from "./chunk-ISL3NSVX.js";
15
15
  import {
16
16
  MCP_LEGACY_KEY,
17
17
  MCP_PRIMARY_KEY
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getClient
3
- } from "./chunk-5U7WB4YG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
4
 
5
5
  // src/lib/reminders.ts
6
6
  import crypto from "crypto";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  connectEmbedDaemon,
9
9
  embedBatchViaClient
10
- } from "./chunk-Z6GHDYQI.js";
10
+ } from "./chunk-Z2AEOVEZ.js";
11
11
  import {
12
12
  EXE_AI_DIR
13
13
  } from "./chunk-VXIMSRTO.js";
@@ -2,7 +2,7 @@ import {
2
2
  dispatchTaskToEmployee,
3
3
  markTaskNotificationsRead,
4
4
  notifyTaskDone
5
- } from "./chunk-AQOCHSIR.js";
5
+ } from "./chunk-OCJ5GZKV.js";
6
6
  import {
7
7
  cleanupReviewFile,
8
8
  createTaskCore,
@@ -11,7 +11,7 @@ import {
11
11
  sessionScopeFilter,
12
12
  updateTaskStatus,
13
13
  writeNotification
14
- } from "./chunk-CS267UMH.js";
14
+ } from "./chunk-5LDTCWYX.js";
15
15
  import {
16
16
  orgBus
17
17
  } from "./chunk-MP2AFCGL.js";
@@ -19,7 +19,7 @@ import {
19
19
  getClient,
20
20
  getCoordinatorName,
21
21
  isCoordinatorName
22
- } from "./chunk-5U7WB4YG.js";
22
+ } from "./chunk-WVBZ3QBR.js";
23
23
  import {
24
24
  EXE_AI_DIR
25
25
  } from "./chunk-VXIMSRTO.js";
@@ -61,7 +61,7 @@ async function cascadeUnblock(taskId, baseDir, now) {
61
61
  }
62
62
  if (unblockedRows.rows.length > 0 && !process.env.VITEST) {
63
63
  try {
64
- const { dispatchTaskToEmployee: dispatchTaskToEmployee2 } = await import("./tasks-notify-LJ65U7DF.js");
64
+ const { dispatchTaskToEmployee: dispatchTaskToEmployee2 } = await import("./tasks-notify-7ZTE4ZQM.js");
65
65
  const dispatched = /* @__PURE__ */ new Set();
66
66
  for (const ur of unblockedRows.rows) {
67
67
  const assignee = String(ur.assigned_to);
@@ -258,20 +258,22 @@ async function updateTask(input) {
258
258
  const taskTitle = String(row.title);
259
259
  let delivered = false;
260
260
  try {
261
- const { sendIntercom, resolveExeSession } = await import("./lib/tmux-routing.js");
261
+ const { sendIntercom, resolveExeSession, employeeSessionName } = await import("./lib/tmux-routing.js");
262
262
  const exeSession = row.session_scope ? String(row.session_scope) : resolveExeSession();
263
263
  if (exeSession) {
264
- const reviewerSession = `${reviewer}-${exeSession}`;
265
- const result = sendIntercom(reviewerSession, { reason: "completion" });
266
- if (result !== "failed") {
267
- delivered = true;
268
- process.stderr.write(`[tasks] EVENT: notified reviewer "${reviewer}" via tmux for "${taskTitle}"
269
- `);
270
- } else if (isCoordinatorName(reviewer)) {
271
- const cooResult = sendIntercom(exeSession, { reason: "completion" });
264
+ if (isCoordinatorName(reviewer)) {
265
+ const cooResult = sendIntercom(exeSession, { force: true, reason: "completion" });
272
266
  if (cooResult !== "failed") {
273
267
  delivered = true;
274
- process.stderr.write(`[tasks] EVENT: notified coordinator "${reviewer}" for "${taskTitle}"
268
+ process.stderr.write(`[tasks] EVENT: notified coordinator "${reviewer}" for "${taskTitle}" (force)
269
+ `);
270
+ }
271
+ } else {
272
+ const reviewerSession = employeeSessionName(reviewer, exeSession);
273
+ const result = sendIntercom(reviewerSession, { force: true, reason: "completion" });
274
+ if (result !== "failed") {
275
+ delivered = true;
276
+ process.stderr.write(`[tasks] EVENT: notified reviewer "${reviewer}" via tmux for "${taskTitle}"
275
277
  `);
276
278
  }
277
279
  }
@@ -328,7 +330,7 @@ async function updateTask(input) {
328
330
  await markTaskNotificationsRead(taskFile);
329
331
  if (input.status === "needs_review" && !isCoordinator) {
330
332
  try {
331
- const { writeNotification: writeNotification2 } = await import("./notifications-BETWD6EK.js");
333
+ const { writeNotification: writeNotification2 } = await import("./notifications-ZKGLZVCU.js");
332
334
  await writeNotification2({
333
335
  agentId: String(row.assigned_to),
334
336
  agentRole: String(row.assigned_to),
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  deactivateBehavior
3
- } from "./chunk-2NEQQCRC.js";
3
+ } from "./chunk-25JAXHON.js";
4
4
  import {
5
5
  getActiveAgent
6
- } from "./chunk-VGWQBI76.js";
6
+ } from "./chunk-GBR4MAAK.js";
7
7
  import {
8
8
  canCoordinate,
9
9
  getClient
10
- } from "./chunk-5U7WB4YG.js";
10
+ } from "./chunk-WVBZ3QBR.js";
11
11
 
12
12
  // src/mcp/tools/deactivate-behavior.ts
13
13
  import { z } from "zod";
@@ -24,7 +24,7 @@ function registerDeactivateBehavior(server) {
24
24
  async ({ behavior_id }) => {
25
25
  const caller = getActiveAgent();
26
26
  try {
27
- const { StewardGate } = await import("./steward-gate-HSV67KLF.js");
27
+ const { StewardGate } = await import("./steward-gate-EQV6CZKY.js");
28
28
  const steward = new StewardGate();
29
29
  const gateDecision = await steward.checkAuthority(caller.agentId || "unknown", "deactivate_behavior", behavior_id);
30
30
  if (!gateDecision.allowed) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getClient
3
- } from "./chunk-5U7WB4YG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
4
 
5
5
  // src/lib/orchestration-events.ts
6
6
  import crypto from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  recordSessionKill
3
- } from "./chunk-6QMXKKFD.js";
3
+ } from "./chunk-N27CTUFU.js";
4
4
  import {
5
5
  updateTask
6
- } from "./chunk-5R4R743Q.js";
6
+ } from "./chunk-V2UVWYHO.js";
7
7
  import {
8
8
  ensureEmployee,
9
9
  extractRootExe,
@@ -14,13 +14,13 @@ import {
14
14
  sessionScopeFilter,
15
15
  strictSessionScopeFilter,
16
16
  writeNotification
17
- } from "./chunk-CS267UMH.js";
17
+ } from "./chunk-5LDTCWYX.js";
18
18
  import {
19
19
  queueIntercom
20
20
  } from "./chunk-5CHYEKMH.js";
21
21
  import {
22
22
  listSessions
23
- } from "./chunk-SD2R3SEA.js";
23
+ } from "./chunk-J3YNCJ4A.js";
24
24
  import {
25
25
  getTransport
26
26
  } from "./chunk-MVW62NIZ.js";
@@ -30,7 +30,7 @@ import {
30
30
  } from "./chunk-CX6GL3ZJ.js";
31
31
  import {
32
32
  recordOrchestrationEventBestEffort
33
- } from "./chunk-USLVSLQ5.js";
33
+ } from "./chunk-VDCPKJUQ.js";
34
34
  import {
35
35
  getAgentRuntime
36
36
  } from "./chunk-XJUUWHVN.js";
@@ -38,7 +38,7 @@ import {
38
38
  baseAgentName,
39
39
  isCoordinatorName,
40
40
  shouldAutoInstance
41
- } from "./chunk-5U7WB4YG.js";
41
+ } from "./chunk-WVBZ3QBR.js";
42
42
  import {
43
43
  loadConfigSync
44
44
  } from "./chunk-VXIMSRTO.js";
@@ -1657,7 +1657,7 @@ async function reapOrphanedWorktrees(deps, nowMs = Date.now()) {
1657
1657
  }
1658
1658
  async function createWorktreeReaperRealDeps() {
1659
1659
  const { getPaneCwdAsync } = await import("./lib/tmux-status.js");
1660
- const { getGitRoot, isWorktreeDirty: isDirty } = await import("./worktree-3N5BPITS.js");
1660
+ const { getGitRoot, isWorktreeDirty: isDirty } = await import("./worktree-NK7GZNEA.js");
1661
1661
  const { statSync: statSync2 } = await import("fs");
1662
1662
  const { basename } = await import("path");
1663
1663
  const { promisify } = await import("util");
@@ -1798,7 +1798,7 @@ async function gcStaleCheckpoints() {
1798
1798
  }
1799
1799
  async function pollTaskGroupBarriers() {
1800
1800
  try {
1801
- const { checkAndFireBarriers } = await import("./tasks-crud-F732BVOE.js");
1801
+ const { checkAndFireBarriers } = await import("./tasks-crud-KOIA5SAH.js");
1802
1802
  const firedGroupIds = await checkAndFireBarriers();
1803
1803
  if (firedGroupIds.length === 0) return 0;
1804
1804
  const { getClient } = await import("./lib/database.js");
@@ -3,12 +3,19 @@ import {
3
3
  } from "./chunk-VXIMSRTO.js";
4
4
 
5
5
  // src/lib/db-backup.ts
6
- import { existsSync, readdirSync, unlinkSync, statSync } from "fs";
6
+ import { existsSync, readdirSync, unlinkSync, statSync, statfsSync } from "fs";
7
7
  import { copyFile, mkdir, unlink } from "fs/promises";
8
8
  import path from "path";
9
9
  var BACKUP_DIR = path.join(EXE_AI_DIR, "backups");
10
10
  var DEFAULT_KEEP_DAYS = 3;
11
11
  var DB_NAMES = ["memories.db", "exe-mem.db", "exe-os.db", "exe.db"];
12
+ var REASON_COUNT_CAP = {
13
+ "pre-restart": 5,
14
+ "pre-consolidation": 5,
15
+ "pre-fix": 5,
16
+ "pre-restore": 5
17
+ };
18
+ var MIN_FREE_BYTES = 5 * 1024 * 1024 * 1024;
12
19
  function findActiveDb() {
13
20
  for (const name of DB_NAMES) {
14
21
  const p = path.join(EXE_AI_DIR, name);
@@ -23,6 +30,22 @@ async function createBackupAsync(reason = "manual") {
23
30
  const dbPath = findActiveDb();
24
31
  if (!dbPath) return null;
25
32
  await mkdir(BACKUP_DIR, { recursive: true });
33
+ try {
34
+ let dbSize = 0;
35
+ try {
36
+ dbSize = statSync(dbPath).size;
37
+ } catch {
38
+ }
39
+ const freeBytes = getFreeBytes(BACKUP_DIR);
40
+ if (!hasEnoughDiskSpace(freeBytes, dbSize)) {
41
+ process.stderr.write(
42
+ `[db-backup] DISK GUARD: skipping "${reason}" backup \u2014 ${Math.round(freeBytes / 1024 / 1024)}MB free, need >${Math.round(Math.max(MIN_FREE_BYTES, dbSize * 2) / 1024 / 1024)}MB. Disk is nearly full; refusing to make it worse.
43
+ `
44
+ );
45
+ return null;
46
+ }
47
+ } catch {
48
+ }
26
49
  const dbName = path.basename(dbPath, ".db");
27
50
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
28
51
  const backupName = `${dbName}-${reason}-${timestamp}.db`;
@@ -99,6 +122,61 @@ function rotateBackups(keepDays = DEFAULT_KEEP_DAYS) {
99
122
  }
100
123
  return deleted;
101
124
  }
125
+ function selectBackupsToDelete(backups, keep) {
126
+ if (keep < 0) keep = 0;
127
+ const sorted = [...backups].sort((a, b) => b.mtimeMs - a.mtimeMs);
128
+ return sorted.slice(keep).map((b) => b.path);
129
+ }
130
+ function hasEnoughDiskSpace(freeBytes, backupSizeBytes, minFreeBytes = MIN_FREE_BYTES) {
131
+ const required = Math.max(minFreeBytes, backupSizeBytes * 2);
132
+ return freeBytes >= required;
133
+ }
134
+ function getFreeBytes(dir) {
135
+ try {
136
+ const s = statfsSync(dir);
137
+ return s.bavail * s.bsize;
138
+ } catch {
139
+ return Number.POSITIVE_INFINITY;
140
+ }
141
+ }
142
+ function rotateBackupsByReason(reason, keep) {
143
+ if (!existsSync(BACKUP_DIR)) return 0;
144
+ let deleted = 0;
145
+ try {
146
+ const files = readdirSync(BACKUP_DIR);
147
+ const matches = [];
148
+ for (const file of files) {
149
+ if (!file.endsWith(".db")) continue;
150
+ if (!file.includes(`-${reason}-`)) continue;
151
+ const filePath = path.join(BACKUP_DIR, file);
152
+ try {
153
+ matches.push({ path: filePath, mtimeMs: statSync(filePath).mtimeMs });
154
+ } catch {
155
+ }
156
+ }
157
+ for (const target of selectBackupsToDelete(matches, keep)) {
158
+ for (const p of [target, target + "-wal", target + "-shm"]) {
159
+ try {
160
+ if (existsSync(p)) {
161
+ unlinkSync(p);
162
+ if (p === target) deleted++;
163
+ }
164
+ } catch {
165
+ }
166
+ }
167
+ }
168
+ } catch {
169
+ }
170
+ return deleted;
171
+ }
172
+ function enforceRetention(reason, keepDays = DEFAULT_KEEP_DAYS) {
173
+ let deleted = rotateBackups(keepDays);
174
+ const cap = REASON_COUNT_CAP[reason];
175
+ if (typeof cap === "number") {
176
+ deleted += rotateBackupsByReason(reason, cap);
177
+ }
178
+ return deleted;
179
+ }
102
180
  function listBackups() {
103
181
  if (!existsSync(BACKUP_DIR)) return [];
104
182
  try {
@@ -170,6 +248,10 @@ export {
170
248
  createBackup,
171
249
  createBackupAsync,
172
250
  rotateBackups,
251
+ selectBackupsToDelete,
252
+ hasEnoughDiskSpace,
253
+ rotateBackupsByReason,
254
+ enforceRetention,
173
255
  listBackups,
174
256
  hasBackupToday,
175
257
  getLatestBackup,