@askexenow/exe-os 0.9.237 → 0.9.239

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 (232) hide show
  1. package/deploy/stack-manifests/v0.9.json +105 -1
  2. package/dist/{active-agent-6WX7GZBH.js → active-agent-55C5Y3XL.js} +3 -3
  3. package/dist/{active-agent-X3GALNAR.js → active-agent-7MIVNARP.js} +3 -3
  4. package/dist/{agentic-ontology-NBU3FHEX.js → agentic-ontology-NCAQIQQI.js} +1 -1
  5. package/dist/{backfill-metadata-NG2L5GUP.js → backfill-metadata-3JP7EZ2U.js} +4 -4
  6. package/dist/{behaviors-DH7XFONJ.js → behaviors-6BGALYGW.js} +3 -3
  7. package/dist/bin/agentic-ontology-backfill.js +5 -5
  8. package/dist/bin/agentic-reflection-backfill.js +6 -6
  9. package/dist/bin/agentic-semantic-label.js +5 -5
  10. package/dist/bin/backfill-conversations.js +4 -4
  11. package/dist/bin/backfill-responses.js +4 -4
  12. package/dist/bin/backfill-vectors.js +5 -5
  13. package/dist/bin/bulk-sync-postgres.js +6 -6
  14. package/dist/bin/cleanup-stale-review-tasks.js +9 -9
  15. package/dist/bin/cli.js +14 -14
  16. package/dist/bin/exe-agent-config.js +2 -2
  17. package/dist/bin/exe-agent.js +4 -4
  18. package/dist/bin/exe-assign.js +5 -5
  19. package/dist/bin/exe-boot.js +16 -16
  20. package/dist/bin/exe-call.js +4 -4
  21. package/dist/bin/exe-cloud.js +4 -4
  22. package/dist/bin/exe-dispatch.js +9 -9
  23. package/dist/bin/exe-doctor.js +1 -1
  24. package/dist/bin/exe-export-behaviors.js +7 -7
  25. package/dist/bin/exe-forget.js +6 -6
  26. package/dist/bin/exe-gateway.js +7 -7
  27. package/dist/bin/exe-heartbeat.js +9 -9
  28. package/dist/bin/exe-kill.js +12 -12
  29. package/dist/bin/exe-launch-agent.js +16 -16
  30. package/dist/bin/exe-new-employee.js +6 -6
  31. package/dist/bin/exe-pending-messages.js +10 -10
  32. package/dist/bin/exe-pending-notifications.js +9 -9
  33. package/dist/bin/exe-pending-reviews.js +9 -9
  34. package/dist/bin/exe-rename.js +4 -4
  35. package/dist/bin/exe-review.js +11 -11
  36. package/dist/bin/exe-search.js +5 -5
  37. package/dist/bin/exe-session-cleanup.js +14 -14
  38. package/dist/bin/exe-settings.js +4 -4
  39. package/dist/bin/exe-start-codex.js +11 -11
  40. package/dist/bin/exe-start-opencode.js +8 -8
  41. package/dist/bin/exe-status.js +10 -10
  42. package/dist/bin/exe-team.js +3 -3
  43. package/dist/bin/git-sweep.js +9 -9
  44. package/dist/bin/graph-backfill.js +4 -4
  45. package/dist/bin/graph-export.js +5 -5
  46. package/dist/bin/import-history.js +7 -7
  47. package/dist/bin/install.js +6 -6
  48. package/dist/bin/intercom-check.js +4 -4
  49. package/dist/bin/mcp-sessions.js +2 -2
  50. package/dist/bin/orchestration-metrics.js +4 -4
  51. package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
  52. package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
  53. package/dist/bin/scan-tasks.js +9 -9
  54. package/dist/bin/setup.js +1 -1
  55. package/dist/bin/shard-migrate.js +4 -4
  56. package/dist/{capacity-monitor-KAKNWAA4.js → capacity-monitor-IFCZKRPG.js} +10 -10
  57. package/dist/{catchup-brief-RZF7HEYB.js → catchup-brief-PIDRWXOW.js} +11 -11
  58. package/dist/{chunk-2LYJTK47.js → chunk-2H55BIV2.js} +1 -1
  59. package/dist/{chunk-ES5JM6V2.js → chunk-2KZSKURT.js} +2 -2
  60. package/dist/{chunk-5KDROSDV.js → chunk-452XB7OZ.js} +1 -1
  61. package/dist/{chunk-WQCSGDRG.js → chunk-4SC65UBG.js} +1 -1
  62. package/dist/{chunk-T3ASODFG.js → chunk-5GG7MTRJ.js} +3 -3
  63. package/dist/{chunk-N4IJWOIS.js → chunk-5LMH4YHG.js} +2 -2
  64. package/dist/{chunk-2O5GJFYQ.js → chunk-5NJ4A4ZA.js} +1 -1
  65. package/dist/{chunk-VK5IBXXT.js → chunk-5R75ODPS.js} +5 -5
  66. package/dist/{chunk-YENDNLAD.js → chunk-5WLMF6PL.js} +1 -1
  67. package/dist/{chunk-RM6PJ34R.js → chunk-5WUTKDH6.js} +1 -1
  68. package/dist/{chunk-LUCHTCME.js → chunk-6LBCUA2A.js} +1 -1
  69. package/dist/{chunk-ENQIADYO.js → chunk-7DIDOQCX.js} +76 -76
  70. package/dist/{chunk-NCJNGQUZ.js → chunk-7F37NMKB.js} +1 -1
  71. package/dist/{chunk-COMWI7SO.js → chunk-AL4DRC5H.js} +1 -1
  72. package/dist/{chunk-CJEVAKKC.js → chunk-AURM7FOT.js} +1 -1
  73. package/dist/{chunk-KWH6H64R.js → chunk-AVM7XZE4.js} +12 -7
  74. package/dist/{chunk-NJS4GRIR.js → chunk-BZNI4OK5.js} +1 -1
  75. package/dist/{chunk-QQFZID36.js → chunk-C2YS2AA6.js} +1 -1
  76. package/dist/{chunk-7PVUUC3O.js → chunk-C7SFJO5F.js} +5 -5
  77. package/dist/{chunk-BTPXNV5W.js → chunk-DAZIV4QZ.js} +1 -1
  78. package/dist/{chunk-NS7FW3NG.js → chunk-DDPAQ4LT.js} +2 -2
  79. package/dist/{chunk-HFYCKIVJ.js → chunk-DKI5BTBC.js} +2 -2
  80. package/dist/{chunk-KRLR26L2.js → chunk-DUVO2PUJ.js} +2 -2
  81. package/dist/{chunk-AYBC6AYP.js → chunk-EJ7LOTV2.js} +8 -8
  82. package/dist/{chunk-FQJWTRCB.js → chunk-ELRRL2NC.js} +1 -1
  83. package/dist/{chunk-627ZOPZQ.js → chunk-FB5VRO5S.js} +5 -4
  84. package/dist/{chunk-YDG343II.js → chunk-FBWUJEXS.js} +2 -2
  85. package/dist/{chunk-3JVO6X4W.js → chunk-FE45RXGC.js} +1 -1
  86. package/dist/{chunk-NQU2RTCP.js → chunk-FGJUGDNM.js} +8 -8
  87. package/dist/{chunk-JLHSEBNQ.js → chunk-FKWZVO2T.js} +3 -3
  88. package/dist/{chunk-PQBANSH6.js → chunk-GN5VHPPR.js} +1 -1
  89. package/dist/{chunk-HUVSY6NF.js → chunk-GPF6X6HE.js} +2 -2
  90. package/dist/{chunk-7LIXU3TB.js → chunk-HLZSC5WK.js} +8 -8
  91. package/dist/{chunk-ENWFSMOS.js → chunk-HNLPLLE6.js} +10 -10
  92. package/dist/{chunk-WQXJIMBO.js → chunk-HX5G4AS4.js} +2 -2
  93. package/dist/{chunk-LXP6VRFH.js → chunk-IQSCZDBQ.js} +1 -1
  94. package/dist/{chunk-QXKWSRUZ.js → chunk-IQXPMK46.js} +9 -9
  95. package/dist/{chunk-Q4MZN62R.js → chunk-JDOE33C2.js} +3 -3
  96. package/dist/{chunk-4HMKJDPB.js → chunk-K525WLL7.js} +3 -3
  97. package/dist/{chunk-ZZBOV6WA.js → chunk-KVSQOG3W.js} +4 -4
  98. package/dist/{chunk-2VXHPSIJ.js → chunk-MAN5LZQ4.js} +1 -1
  99. package/dist/{chunk-YUS7IS3I.js → chunk-NJWK6J4N.js} +4 -4
  100. package/dist/{chunk-3NYRIK73.js → chunk-O6DAF2TY.js} +2 -2
  101. package/dist/{chunk-JBMZS5WO.js → chunk-OMPCFLWA.js} +1 -1
  102. package/dist/{chunk-JBUHOWIV.js → chunk-PATCHPNY.js} +1 -1
  103. package/dist/{chunk-MPG2FFQS.js → chunk-PLQAFB3Z.js} +1 -1
  104. package/dist/{chunk-XCGJPZ6H.js → chunk-PPYWQV2M.js} +2 -2
  105. package/dist/{chunk-IQNT6KAE.js → chunk-RA2RO27E.js} +1 -1
  106. package/dist/{chunk-RXGTA6YQ.js → chunk-RWFGXC35.js} +3 -3
  107. package/dist/{chunk-YUQ7GGAL.js → chunk-TOZ5NN5V.js} +1 -1
  108. package/dist/{chunk-IDCJNL7C.js → chunk-TPQVLYSV.js} +1 -1
  109. package/dist/{chunk-JHFXCYZP.js → chunk-UAFUGPKO.js} +1 -1
  110. package/dist/{chunk-UISUGXJU.js → chunk-VFQKKMKE.js} +1 -1
  111. package/dist/{chunk-GXU3XRI5.js → chunk-W7G3GY4I.js} +3 -3
  112. package/dist/{chunk-G67R75DG.js → chunk-YFE6W75D.js} +1 -1
  113. package/dist/{chunk-VEU6LVBR.js → chunk-YPYDLW75.js} +1 -1
  114. package/dist/{co-activation-OCQPRJ2I.js → co-activation-VB4CJQZB.js} +2 -2
  115. package/dist/{co-occurrence-S62AC2BR.js → co-occurrence-XZQJJIBM.js} +2 -2
  116. package/dist/{crdt-sync-VS254UOH.js → crdt-sync-KXETGV45.js} +1 -1
  117. package/dist/{crm-webhook-CST5WBNY.js → crm-webhook-JMOAHTJ6.js} +2 -2
  118. package/dist/{cto-delegation-gate-2PY563OA.js → cto-delegation-gate-IJ3KQIKF.js} +8 -8
  119. package/dist/{daemon-orchestration-P34RDHTM.js → daemon-orchestration-ZCY4GEI3.js} +11 -11
  120. package/dist/{db-backup-JEHRFLYW.js → db-backup-HLX5OLIV.js} +1 -1
  121. package/dist/dreaming-2CJML3TU.js +31 -0
  122. package/dist/{exe-drift-DOWP33NY.js → exe-drift-P5OIRNSH.js} +3 -3
  123. package/dist/{exe-export-QCB5UOXQ.js → exe-export-QQL2H322.js} +5 -5
  124. package/dist/{exe-import-JHFIXRB5.js → exe-import-V4RJCUEP.js} +5 -5
  125. package/dist/{exe-key-EAQDAUPT.js → exe-key-MENJGDD7.js} +2 -2
  126. package/dist/{exe-snapshot-RKMMV52M.js → exe-snapshot-YRARQE7F.js} +24 -6
  127. package/dist/{fast-db-init-PTUUO2IO.js → fast-db-init-HIJWWKAO.js} +1 -1
  128. package/dist/gateway/index.js +8 -8
  129. package/dist/{git-staleness-5SFBUMPC.js → git-staleness-IHTKCUMN.js} +2 -2
  130. package/dist/{git-task-sweep-XMK5IQXK.js → git-task-sweep-5ZPNQS7Y.js} +9 -9
  131. package/dist/{global-procedures-W4U257TI.js → global-procedures-XHDIZRJU.js} +3 -3
  132. package/dist/{graph-auto-extract-5ZD4AUSB.js → graph-auto-extract-5TPT67GP.js} +2 -2
  133. package/dist/hooks/bug-report-worker.js +10 -10
  134. package/dist/hooks/codex-stop-task-finalizer.js +10 -10
  135. package/dist/hooks/commit-complete.js +11 -11
  136. package/dist/hooks/error-recall.js +6 -6
  137. package/dist/hooks/exe-heartbeat-hook.js +3 -3
  138. package/dist/hooks/ingest.js +6 -6
  139. package/dist/hooks/instructions-loaded.js +4 -4
  140. package/dist/hooks/manifest.json +19 -19
  141. package/dist/hooks/notification.js +4 -4
  142. package/dist/hooks/post-compact.js +10 -10
  143. package/dist/hooks/post-tool-combined.js +5 -5
  144. package/dist/hooks/pre-compact.js +11 -11
  145. package/dist/hooks/pre-tool-use.js +14 -14
  146. package/dist/hooks/prompt-submit.js +20 -20
  147. package/dist/hooks/session-end.js +15 -15
  148. package/dist/hooks/session-start.js +10 -10
  149. package/dist/hooks/stop.js +14 -14
  150. package/dist/hooks/subagent-stop.js +10 -10
  151. package/dist/hooks/summary-worker.js +14 -14
  152. package/dist/index.js +17 -17
  153. package/dist/{installer-2HULECDJ.js → installer-AMZM4MLS.js} +5 -5
  154. package/dist/{installer-N5XZAFE4.js → installer-HW74W3IT.js} +5 -5
  155. package/dist/{installer-BCOJG2SE.js → installer-KT5FW4CN.js} +5 -5
  156. package/dist/lib/cloud-sync.js +6 -4
  157. package/dist/lib/consolidation.js +5 -5
  158. package/dist/lib/database.js +2 -2
  159. package/dist/lib/db-daemon-client.js +2 -2
  160. package/dist/lib/db.js +2 -2
  161. package/dist/lib/employee-templates.js +4 -4
  162. package/dist/lib/employees.js +2 -2
  163. package/dist/lib/exe-daemon.js +347 -69
  164. package/dist/lib/hybrid-search.js +5 -5
  165. package/dist/lib/identity.js +2 -2
  166. package/dist/lib/messaging.js +9 -9
  167. package/dist/lib/reminders.js +3 -3
  168. package/dist/lib/schedules.js +5 -5
  169. package/dist/lib/session-registry.js +4 -4
  170. package/dist/lib/skill-learning.js +4 -4
  171. package/dist/lib/store.js +4 -4
  172. package/dist/lib/task-router.js +3 -3
  173. package/dist/lib/tasks.js +9 -9
  174. package/dist/lib/tmux-routing.js +8 -8
  175. package/dist/lib/token-spend.js +3 -3
  176. package/dist/mcp/register-tools.js +50 -50
  177. package/dist/mcp/server.js +51 -51
  178. package/dist/mcp/tools/complete-reminder.js +4 -4
  179. package/dist/mcp/tools/create-reminder.js +4 -4
  180. package/dist/mcp/tools/create-task.js +11 -11
  181. package/dist/mcp/tools/deactivate-behavior.js +5 -5
  182. package/dist/mcp/tools/list-reminders.js +4 -4
  183. package/dist/mcp/tools/list-tasks.js +11 -11
  184. package/dist/mcp/tools/send-message.js +11 -11
  185. package/dist/mcp/tools/update-task.js +10 -10
  186. package/dist/{mcp-http-config-RTXPLRH5.js → mcp-http-config-BXX3RZPR.js} +3 -3
  187. package/dist/{memory-cards-3FBGRV6J.js → memory-cards-KRTP5GFM.js} +2 -2
  188. package/dist/{memory-graph-extractor-5D3FU5N5.js → memory-graph-extractor-G532PUHC.js} +3 -3
  189. package/dist/{memory-poisoning-defense-P6GL2RMF.js → memory-poisoning-defense-HJM3FQA3.js} +2 -2
  190. package/dist/{memory-reflection-5CVV2M3G.js → memory-reflection-RANRFUQL.js} +2 -2
  191. package/dist/{notifications-NV54INLG.js → notifications-4P2PVEOT.js} +8 -8
  192. package/dist/{orchestration-events-TEYCD6GO.js → orchestration-events-IYTASMSN.js} +3 -3
  193. package/dist/{orchestrator-JCNHGP6M.js → orchestrator-VKVHZ4MV.js} +10 -10
  194. package/dist/{pipeline-router-IX635D3U.js → pipeline-router-E4L5BDXN.js} +3 -3
  195. package/dist/{plan-limits-H65VL6LC.js → plan-limits-5O5QG55H.js} +3 -3
  196. package/dist/{projection-worker-JMGAPKH6.js → projection-worker-54KRNQSO.js} +1 -1
  197. package/dist/{reranker-Y2RHN7TX.js → reranker-4NTUFNYT.js} +1 -1
  198. package/dist/{review-polling-SAQ24T6L.js → review-polling-BFRJDLUA.js} +9 -9
  199. package/dist/runtime/index.js +11 -11
  200. package/dist/{session-events-JNUK47KH.js → session-events-KCZCWGE4.js} +9 -9
  201. package/dist/{session-kill-telemetry-GLCDARKV.js → session-kill-telemetry-TMNIDYWY.js} +3 -3
  202. package/dist/{session-scope-UR7OFFOB.js → session-scope-DRZBQ32Y.js} +8 -8
  203. package/dist/{setup-wizard-ZMYO7QKZ.js → setup-wizard-TQKGDAHO.js} +1 -1
  204. package/dist/{skill-refinement-WWWFGTUS.js → skill-refinement-Z5SWD3AM.js} +2 -2
  205. package/dist/{steward-gate-TAD7GEVL.js → steward-gate-7DWYS5AT.js} +3 -3
  206. package/dist/{task-enforcement-2LI5KWFE.js → task-enforcement-2VL5J6JJ.js} +8 -8
  207. package/dist/{task-scope-AYK6BVC7.js → task-scope-YHALISIB.js} +8 -8
  208. package/dist/{tasks-crud-OD75EH2G.js → tasks-crud-JXZEBZFR.js} +8 -8
  209. package/dist/{tasks-review-CC2EGWBL.js → tasks-review-PGPYJQF5.js} +8 -8
  210. package/dist/{telemetry-upload-NXRMUNSW.js → telemetry-upload-H7OJNBIF.js} +5 -5
  211. package/dist/{token-budget-6TK55BBU.js → token-budget-JJ7JQIA2.js} +2 -2
  212. package/dist/{tool-telemetry-E7NWXX5R.js → tool-telemetry-W4LFCHFT.js} +1 -1
  213. package/dist/tui/App.js +16 -16
  214. package/dist/{tui-data-ROOXTJQ5.js → tui-data-72U6N2DC.js} +8 -8
  215. package/dist/{worker-gate-MOQZ2D34.js → worker-gate-SCSN6IHI.js} +1 -1
  216. package/dist/{workflow-engine-4MQJI5F2.js → workflow-engine-OICYBE4F.js} +2 -2
  217. package/dist/{worktree-K2GDO4QX.js → worktree-JXN4RCWC.js} +4 -4
  218. package/package.json +1 -1
  219. package/release-notes.json +105 -202
  220. package/dist/dreaming-WIBDVAED.js +0 -12
  221. /package/dist/{chunk-IAPFFVYR.js → chunk-4HROS3GJ.js} +0 -0
  222. /package/dist/{chunk-A4TPCHMA.js → chunk-AU5426YP.js} +0 -0
  223. /package/dist/{chunk-CGTWFEXX.js → chunk-DHVC4RN7.js} +0 -0
  224. /package/dist/{chunk-3SVQ5REQ.js → chunk-GWYADLIW.js} +0 -0
  225. /package/dist/{chunk-P2JDWX67.js → chunk-H42LEGLB.js} +0 -0
  226. /package/dist/{chunk-YGJTKLGM.js → chunk-N2XUH2HQ.js} +0 -0
  227. /package/dist/{chunk-HFF6YG7R.js → chunk-NOLIN2YI.js} +0 -0
  228. /package/dist/{chunk-NNEYTOUS.js → chunk-WSHMBME6.js} +0 -0
  229. /package/dist/{chunk-BJOU5MBY.js → chunk-Y2L7RMGH.js} +0 -0
  230. /package/dist/{chunk-RX2KGETT.js → chunk-YFDDTHNM.js} +0 -0
  231. /package/dist/{core-memory-67AVQ3Z7.js → core-memory-VOBGGB2Q.js} +0 -0
  232. /package/dist/{wiki-acl-AR7RIMRY.js → wiki-acl-M3OR547L.js} +0 -0
@@ -17,7 +17,7 @@ import {
17
17
  findScopedDuplicate,
18
18
  governMemoryRecord,
19
19
  schedulePostWriteMemoryHygiene
20
- } from "../chunk-IAPFFVYR.js";
20
+ } from "../chunk-4HROS3GJ.js";
21
21
  import "../chunk-F7LU65PQ.js";
22
22
  import {
23
23
  logRestartEvent
@@ -544,6 +544,70 @@ async function getTmuxSessionsAsync() {
544
544
  }
545
545
  var _paneCacheMap = /* @__PURE__ */ new Map();
546
546
  var PANE_CACHE_TTL_MS = 1e4;
547
+ var _reflectionImportFailed = false;
548
+ var _intercomDedupCompleted = false;
549
+ var _sharedPaneCache = null;
550
+ var _sharedAliveSessions = null;
551
+ var _sharedAgentSessions = null;
552
+ var _sharedCacheTimestamp = 0;
553
+ var SHARED_CACHE_TTL_MS = 15e3;
554
+ async function refreshSharedOrchestrationCaches() {
555
+ const sessions = (await getTmuxSessionsAsync()).filter((s) => s.includes("-"));
556
+ const [paneCache, aliveSessions] = await Promise.all([
557
+ batchCapturePanes(sessions, 30),
558
+ batchPaneAlive(sessions)
559
+ ]);
560
+ _sharedAgentSessions = sessions;
561
+ _sharedPaneCache = paneCache;
562
+ _sharedAliveSessions = aliveSessions;
563
+ _sharedCacheTimestamp = Date.now();
564
+ return { sessions, paneCache, aliveSessions };
565
+ }
566
+ async function getSharedOrchestrationCaches() {
567
+ if (_sharedAgentSessions && _sharedPaneCache && _sharedAliveSessions && Date.now() - _sharedCacheTimestamp < SHARED_CACHE_TTL_MS) {
568
+ return {
569
+ sessions: _sharedAgentSessions,
570
+ paneCache: _sharedPaneCache,
571
+ aliveSessions: _sharedAliveSessions
572
+ };
573
+ }
574
+ return refreshSharedOrchestrationCaches();
575
+ }
576
+ var _orchestrationSteps = {
577
+ reviewPolling: null,
578
+ taskEnforcement: null,
579
+ idleKill: null,
580
+ apiWatchdog: null
581
+ };
582
+ var _orchestrationBusy = false;
583
+ var _orchestrationTickCount = 0;
584
+ async function runOrchestrationTick() {
585
+ if (_orchestrationBusy) return;
586
+ _orchestrationBusy = true;
587
+ _orchestrationTickCount++;
588
+ try {
589
+ await refreshSharedOrchestrationCaches();
590
+ await yieldToEventLoop();
591
+ if (_orchestrationSteps.reviewPolling) {
592
+ await _orchestrationSteps.reviewPolling();
593
+ await yieldToEventLoop();
594
+ }
595
+ if (_orchestrationSteps.taskEnforcement) {
596
+ await _orchestrationSteps.taskEnforcement();
597
+ await yieldToEventLoop();
598
+ }
599
+ if (_orchestrationSteps.idleKill) {
600
+ await _orchestrationSteps.idleKill();
601
+ await yieldToEventLoop();
602
+ }
603
+ if (_orchestrationSteps.apiWatchdog && _orchestrationTickCount % 2 === 0) {
604
+ await _orchestrationSteps.apiWatchdog();
605
+ await yieldToEventLoop();
606
+ }
607
+ } finally {
608
+ _orchestrationBusy = false;
609
+ }
610
+ }
547
611
  var execFileAsync = promisify(execFileNode);
548
612
  async function capturePaneAsync(session, lines = 20) {
549
613
  const cacheKey = `${session}:${lines}`;
@@ -1053,7 +1117,7 @@ async function shutdown() {
1053
1117
  }
1054
1118
  }
1055
1119
  try {
1056
- const { createBackupAsync } = await import("../db-backup-JEHRFLYW.js");
1120
+ const { createBackupAsync } = await import("../db-backup-HLX5OLIV.js");
1057
1121
  const backupPath = await createBackupAsync("pre-restart");
1058
1122
  if (backupPath) {
1059
1123
  process.stderr.write(`[exed] Pre-restart backup: ${backupPath}
@@ -1076,7 +1140,7 @@ async function shutdown() {
1076
1140
  `);
1077
1141
  }
1078
1142
  try {
1079
- const { stopProjectionWorker } = await import("../projection-worker-JMGAPKH6.js");
1143
+ const { stopProjectionWorker } = await import("../projection-worker-54KRNQSO.js");
1080
1144
  stopProjectionWorker();
1081
1145
  } catch {
1082
1146
  }
@@ -1146,7 +1210,7 @@ async function handleHealthCheck(socket, requestId) {
1146
1210
  let pipelineStatus = "unknown";
1147
1211
  if (dbConnected) {
1148
1212
  try {
1149
- await import("../pipeline-router-IX635D3U.js");
1213
+ await import("../pipeline-router-E4L5BDXN.js");
1150
1214
  pipelineStatus = "ok";
1151
1215
  } catch {
1152
1216
  pipelineStatus = "unavailable";
@@ -1453,7 +1517,7 @@ async function _writeMemoryRecordInner(entry) {
1453
1517
  const vRow = await client.execute({ sql: "SELECT version FROM memories WHERE id = ?", args: [id] });
1454
1518
  const version = Number(vRow.rows[0]?.version) || 0;
1455
1519
  try {
1456
- const { insertOntologyForMemory } = await import("../agentic-ontology-NBU3FHEX.js");
1520
+ const { insertOntologyForMemory } = await import("../agentic-ontology-NCAQIQQI.js");
1457
1521
  await insertOntologyForMemory({
1458
1522
  id,
1459
1523
  agent_id: record.agent_id,
@@ -1776,6 +1840,8 @@ async function startMcpHttpServer() {
1776
1840
  sessionLastSeen.delete(sid);
1777
1841
  sessionOwnerKeys.delete(sid);
1778
1842
  const details = sessionDetails.get(sid);
1843
+ process.stderr.write(`[exed] MCP session closed: ${sid.slice(0, 8)}\u2026 agent=${details?.agentId ?? "?"} reason=${reason} remaining=${transports.size}
1844
+ `);
1779
1845
  sessionDetails.delete(sid);
1780
1846
  const sessionMcp = sessionServers.get(sid);
1781
1847
  sessionServers.delete(sid);
@@ -1883,6 +1949,7 @@ async function startMcpHttpServer() {
1883
1949
  return;
1884
1950
  }
1885
1951
  process.stderr.write("[exed] MCP HTTP: DB ready\n");
1952
+ _storeInitialized = true;
1886
1953
  const { initLicenseGate, getCachedLicenseGate } = await import("../license-gate-XJDIL6OZ.js");
1887
1954
  const gateResult = await initLicenseGate();
1888
1955
  if (!gateResult.hasKey) {
@@ -1898,7 +1965,7 @@ async function startMcpHttpServer() {
1898
1965
  let _cachedWrapTelemetry = null;
1899
1966
  async function getWrapTelemetry() {
1900
1967
  if (!_cachedWrapTelemetry) {
1901
- const { wrapServerWithTelemetry } = await import("../tool-telemetry-E7NWXX5R.js");
1968
+ const { wrapServerWithTelemetry } = await import("../tool-telemetry-W4LFCHFT.js");
1902
1969
  _cachedWrapTelemetry = wrapServerWithTelemetry;
1903
1970
  }
1904
1971
  return _cachedWrapTelemetry;
@@ -2092,7 +2159,7 @@ async function startMcpHttpServer() {
2092
2159
  contextPct: body.context_pct
2093
2160
  });
2094
2161
  if (body.context_pct !== void 0 && body.context_pct > 70) {
2095
- void import("../orchestration-events-TEYCD6GO.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
2162
+ void import("../orchestration-events-IYTASMSN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
2096
2163
  recordOE({
2097
2164
  eventType: "context.pressure",
2098
2165
  source: "exe-daemon.heartbeat",
@@ -2315,6 +2382,8 @@ async function startMcpHttpServer() {
2315
2382
  sessionDetails.set(sid, details);
2316
2383
  sessionOwnerKeys.set(sid, mcpSessionOwnerKey2(details));
2317
2384
  sessionServers.set(sid, sessionMcp);
2385
+ process.stderr.write(`[exed] MCP session opened: ${sid.slice(0, 8)}\u2026 agent=${agentId} role=${agentRole} sessions=${transports.size}
2386
+ `);
2318
2387
  recordMcpHttpEvent({
2319
2388
  level: "info",
2320
2389
  message: "session_initialized",
@@ -2590,7 +2659,14 @@ async function ensureStoreForPolling() {
2590
2659
  const { getMasterKey } = await import("./keychain.js");
2591
2660
  const config = await loadConfig();
2592
2661
  const masterKey = await getMasterKey();
2593
- if (!masterKey) throw new Error("No encryption key");
2662
+ if (!masterKey) {
2663
+ if (process.env.DATABASE_URL && process.env.EXE_CLOUD_SYNC_TO_POSTGRES) {
2664
+ process.stderr.write("[exed] No encryption key \u2014 running in PostgreSQL-only mode (VPS)\n");
2665
+ _storeInitialized = true;
2666
+ return true;
2667
+ }
2668
+ throw new Error("No encryption key");
2669
+ }
2594
2670
  await initDatabase({ dbPath: config.dbPath, encryptionKey: masterKey.toString("hex") });
2595
2671
  }
2596
2672
  _storeInitialized = true;
@@ -2604,13 +2680,13 @@ async function ensureStoreForPolling() {
2604
2680
  }
2605
2681
  }
2606
2682
  async function startReviewPolling() {
2607
- const polling = await import("../review-polling-SAQ24T6L.js");
2683
+ const polling = await import("../review-polling-BFRJDLUA.js");
2608
2684
  const state = {
2609
2685
  lastIntercomSent: /* @__PURE__ */ new Map(),
2610
2686
  lastNudgeSent: /* @__PURE__ */ new Map(),
2611
2687
  intervalMs: REVIEW_POLL_INTERVAL_MS
2612
2688
  };
2613
- const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-P34RDHTM.js");
2689
+ const { pollReviewNudge, createReviewNudgeRealDeps, loadNudgeState } = await import("../daemon-orchestration-ZCY4GEI3.js");
2614
2690
  const nudgeState = loadNudgeState();
2615
2691
  const tick = async () => traceDaemonTimer("review_polling", async () => {
2616
2692
  fired("review_polling");
@@ -2618,6 +2694,8 @@ async function startReviewPolling() {
2618
2694
  try {
2619
2695
  const { getClient } = await import("./database.js");
2620
2696
  const deps = polling.createRealDeps(getClient);
2697
+ const { sessions: sharedSessions } = await getSharedOrchestrationCaches();
2698
+ deps.listTmuxSessions = () => sharedSessions;
2621
2699
  const sent = await polling.pollPendingReviews(deps, state);
2622
2700
  if (sent.length > 0) acted("review_polling");
2623
2701
  for (const s of sent) {
@@ -2640,9 +2718,8 @@ async function startReviewPolling() {
2640
2718
  `);
2641
2719
  }
2642
2720
  });
2643
- const timer = setInterval(() => void tick(), REVIEW_POLL_INTERVAL_MS);
2644
- timer.unref();
2645
- process.stderr.write(`[exed] Review polling started (every ${REVIEW_POLL_INTERVAL_MS / 6e4}m)
2721
+ _orchestrationSteps.reviewPolling = tick;
2722
+ process.stderr.write(`[exed] Review polling registered (orchestration tick)
2646
2723
  `);
2647
2724
  }
2648
2725
  var SESSION_TTL_INTERVAL_MS = 5 * 60 * 1e3;
@@ -2652,7 +2729,7 @@ function startSessionTTL() {
2652
2729
  if (!await ensureStoreForPolling()) return;
2653
2730
  try {
2654
2731
  const { getClient } = await import("./database.js");
2655
- const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
2732
+ const { checkSessionTTL, createSessionTTLRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
2656
2733
  const deps = createSessionTTLRealDeps(getClient);
2657
2734
  const killed = await checkSessionTTL(deps);
2658
2735
  if (killed.length > 0) acted("session_ttl");
@@ -2667,7 +2744,6 @@ function startSessionTTL() {
2667
2744
  `);
2668
2745
  }
2669
2746
  var COO_RESTART_COOLDOWN_MS = 5 * 6e4;
2670
- var IDLE_KILL_INTERVAL_MS = 30 * 1e3;
2671
2747
  var _idleTickCounts = /* @__PURE__ */ new Map();
2672
2748
  function startIdleKill() {
2673
2749
  const tick = async () => traceDaemonTimer("idle_kill", async () => {
@@ -2701,12 +2777,8 @@ function startIdleKill() {
2701
2777
  const cfg = await getCachedConfig();
2702
2778
  if (!cfg) return;
2703
2779
  const { getClient } = await import("./database.js");
2704
- const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
2705
- const liveSessions = (await getTmuxSessionsAsync()).filter((s) => s.includes("-"));
2706
- const [paneCache, aliveSessions] = await Promise.all([
2707
- batchCapturePanes(liveSessions, 5),
2708
- batchPaneAlive(liveSessions)
2709
- ]);
2780
+ const { pollIdleKill, createIdleKillRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
2781
+ const { sessions: liveSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
2710
2782
  const realDeps = createIdleKillRealDeps(
2711
2783
  getClient,
2712
2784
  cfg.sessionLifecycle.idleKillIntercomAckWindowMs
@@ -2734,9 +2806,8 @@ function startIdleKill() {
2734
2806
  `);
2735
2807
  }
2736
2808
  });
2737
- const timer = setInterval(() => void tick(), IDLE_KILL_INTERVAL_MS);
2738
- timer.unref();
2739
- process.stderr.write(`[exed] Idle kill started (every ${IDLE_KILL_INTERVAL_MS / 1e3}s)
2809
+ _orchestrationSteps.idleKill = tick;
2810
+ process.stderr.write(`[exed] Idle kill registered (orchestration tick)
2740
2811
  `);
2741
2812
  }
2742
2813
  function startConsolidation() {
@@ -2775,7 +2846,7 @@ function startConsolidation() {
2775
2846
  `);
2776
2847
  }
2777
2848
  try {
2778
- const { createBackupAsync } = await import("../db-backup-JEHRFLYW.js");
2849
+ const { createBackupAsync } = await import("../db-backup-HLX5OLIV.js");
2779
2850
  await createBackupAsync("pre-consolidation");
2780
2851
  } catch (e) {
2781
2852
  process.stderr.write("[exe-daemon] pre-consolidation backup: " + (e instanceof Error ? e.message : String(e)) + "\n");
@@ -2958,7 +3029,7 @@ function startSkillRefinement() {
2958
3029
  if (!shouldRunHeavyJob("skill_refinement")) return;
2959
3030
  try {
2960
3031
  if (!await ensureStoreForPolling()) return;
2961
- const { runSkillRefinement } = await import("../skill-refinement-WWWFGTUS.js");
3032
+ const { runSkillRefinement } = await import("../skill-refinement-Z5SWD3AM.js");
2962
3033
  const result = await runSkillRefinement();
2963
3034
  if (result.reviewed > 0) {
2964
3035
  acted("skill_refinement");
@@ -3008,6 +3079,190 @@ function startGraphExtraction() {
3008
3079
  process.stderr.write(`[exed] GraphRAG extraction started (every ${SKILL_SWEEP_INTERVAL_MS / 36e5}h)
3009
3080
  `);
3010
3081
  }
3082
+ var GRAPH_PG_SYNC_INTERVAL_MS = 5 * 60 * 1e3;
3083
+ var _graphPgSyncInFlight = false;
3084
+ var _graphPgLastSyncedEntities = "";
3085
+ var _graphPgLastSyncedRelationships = "";
3086
+ var _graphPgLastSyncedEmCount = 0;
3087
+ function startGraphPgSync() {
3088
+ if (!process.env.DATABASE_URL || !process.env.EXE_CLOUD_SYNC_TO_POSTGRES) return;
3089
+ const tick = async () => {
3090
+ if (_graphPgSyncInFlight) return;
3091
+ _graphPgSyncInFlight = true;
3092
+ try {
3093
+ let toUuid2 = function(id) {
3094
+ const hex = String(id).replace(/-/g, "");
3095
+ if (hex.length >= 32) return String(id);
3096
+ const padded = hex.padEnd(32, "0");
3097
+ return `${padded.slice(0, 8)}-${padded.slice(8, 12)}-${padded.slice(12, 16)}-${padded.slice(16, 20)}-${padded.slice(20, 32)}`;
3098
+ };
3099
+ var toUuid = toUuid2;
3100
+ if (!await ensureStoreForPolling()) {
3101
+ process.stderr.write("[exed] Graph\u2192PG sync: ensureStoreForPolling returned false, skipping\n");
3102
+ return;
3103
+ }
3104
+ const { getClient } = await import("./database.js");
3105
+ const client = getClient();
3106
+ const isFirstRun = !_graphPgLastSyncedEntities;
3107
+ const entities = _graphPgLastSyncedEntities ? (await client.execute({ sql: "SELECT id, name, type, first_seen, last_seen, properties FROM entities WHERE last_seen > ?", args: [_graphPgLastSyncedEntities] })).rows : (await client.execute("SELECT id, name, type, first_seen, last_seen, properties FROM entities")).rows;
3108
+ await yieldToEventLoop();
3109
+ const relationships = _graphPgLastSyncedRelationships ? (await client.execute({ sql: "SELECT id, source_entity_id, target_entity_id, type, confidence, properties, timestamp FROM relationships WHERE timestamp > ?", args: [_graphPgLastSyncedRelationships] })).rows : (await client.execute("SELECT id, source_entity_id, target_entity_id, type, confidence, properties, timestamp FROM relationships")).rows;
3110
+ await yieldToEventLoop();
3111
+ const emCountResult = await client.execute("SELECT COUNT(*) as cnt FROM entity_memories");
3112
+ const currentEmCount = Number(emCountResult.rows[0]?.cnt ?? 0);
3113
+ const emCountChanged = currentEmCount !== _graphPgLastSyncedEmCount;
3114
+ let entityMemories = [];
3115
+ if (emCountChanged) {
3116
+ entityMemories = (await client.execute("SELECT entity_id, memory_id FROM entity_memories")).rows;
3117
+ }
3118
+ await yieldToEventLoop();
3119
+ if (entities.length === 0 && relationships.length === 0 && !emCountChanged) {
3120
+ if (!isFirstRun) {
3121
+ }
3122
+ return;
3123
+ }
3124
+ process.stderr.write(
3125
+ `[exed] Graph\u2192PG sync: ${isFirstRun ? "FULL" : "incremental"} \u2014 ${entities.length} entities, ${relationships.length} relationships, ${entityMemories.length} entity_memories
3126
+ `
3127
+ );
3128
+ const { loadPgClient } = await import("./cloud-sync.js");
3129
+ const pgPromise = loadPgClient();
3130
+ if (!pgPromise) return;
3131
+ const pg = await pgPromise;
3132
+ const S = "graph";
3133
+ const BATCH = 500;
3134
+ let entOk = 0;
3135
+ let relOk = 0;
3136
+ let emOk = 0;
3137
+ const esc = (v) => String(v ?? "").replace(/'/g, "''");
3138
+ const ts = (v) => {
3139
+ try {
3140
+ return v ? new Date(String(v)).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
3141
+ } catch {
3142
+ return (/* @__PURE__ */ new Date()).toISOString();
3143
+ }
3144
+ };
3145
+ for (let i = 0; i < entities.length; i += BATCH) {
3146
+ const batch = entities.slice(i, i + BATCH);
3147
+ const values = batch.map(
3148
+ (e) => `('${toUuid2(e.id)}', '${esc(e.name ?? "unknown")}', '${esc(e.type ?? "unknown")}', '${ts(e.first_seen)}'::timestamptz, '${ts(e.last_seen)}'::timestamptz, '${esc(e.properties ?? "{}")}'::jsonb)`
3149
+ ).join(",\n");
3150
+ try {
3151
+ await pg.$executeRawUnsafe(`
3152
+ INSERT INTO ${S}.entities (id, name, type, first_seen, last_seen, properties) VALUES ${values}
3153
+ ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, type = EXCLUDED.type,
3154
+ last_seen = EXCLUDED.last_seen, properties = EXCLUDED.properties`);
3155
+ entOk += batch.length;
3156
+ } catch {
3157
+ for (const e of batch) {
3158
+ try {
3159
+ await pg.$executeRawUnsafe(
3160
+ `INSERT INTO ${S}.entities (id, name, type, first_seen, last_seen, properties)
3161
+ VALUES ($1::uuid, $2, $3, $4::timestamptz, $5::timestamptz, $6::jsonb)
3162
+ ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, type = EXCLUDED.type,
3163
+ last_seen = EXCLUDED.last_seen, properties = EXCLUDED.properties`,
3164
+ toUuid2(e.id),
3165
+ String(e.name ?? "unknown"),
3166
+ String(e.type ?? "unknown"),
3167
+ ts(e.first_seen),
3168
+ ts(e.last_seen),
3169
+ String(e.properties ?? "{}")
3170
+ );
3171
+ entOk++;
3172
+ } catch {
3173
+ }
3174
+ }
3175
+ }
3176
+ await yieldToEventLoop();
3177
+ }
3178
+ for (let i = 0; i < relationships.length; i += BATCH) {
3179
+ const batch = relationships.slice(i, i + BATCH);
3180
+ const values = batch.map(
3181
+ (r) => `('${toUuid2(r.id)}', '${toUuid2(r.source_entity_id)}', '${toUuid2(r.target_entity_id)}', '${esc(r.type ?? "related_to")}', ${Number(r.confidence ?? 0.8)}, '${esc(r.properties ?? "{}")}'::jsonb)`
3182
+ ).join(",\n");
3183
+ try {
3184
+ await pg.$executeRawUnsafe(`
3185
+ INSERT INTO ${S}.relationships (id, source_entity_id, target_entity_id, type, confidence, properties) VALUES ${values}
3186
+ ON CONFLICT (id) DO UPDATE SET type = EXCLUDED.type, confidence = EXCLUDED.confidence`);
3187
+ relOk += batch.length;
3188
+ } catch {
3189
+ for (const r of batch) {
3190
+ try {
3191
+ await pg.$executeRawUnsafe(
3192
+ `INSERT INTO ${S}.relationships (id, source_entity_id, target_entity_id, type, confidence, properties)
3193
+ VALUES ($1::uuid, $2::uuid, $3::uuid, $4, $5, $6::jsonb)
3194
+ ON CONFLICT (id) DO UPDATE SET type = EXCLUDED.type, confidence = EXCLUDED.confidence`,
3195
+ toUuid2(r.id),
3196
+ toUuid2(r.source_entity_id),
3197
+ toUuid2(r.target_entity_id),
3198
+ String(r.type ?? "related_to"),
3199
+ Number(r.confidence ?? 0.8),
3200
+ String(r.properties ?? "{}")
3201
+ );
3202
+ relOk++;
3203
+ } catch {
3204
+ }
3205
+ }
3206
+ }
3207
+ await yieldToEventLoop();
3208
+ }
3209
+ for (let i = 0; i < entityMemories.length; i += BATCH) {
3210
+ const batch = entityMemories.slice(i, i + BATCH);
3211
+ const values = batch.map(
3212
+ (em) => `('${toUuid2(em.entity_id)}', '${toUuid2(em.memory_id)}')`
3213
+ ).join(",\n");
3214
+ try {
3215
+ await pg.$executeRawUnsafe(`
3216
+ INSERT INTO ${S}.entity_memories (entity_id, memory_id) VALUES ${values}
3217
+ ON CONFLICT DO NOTHING`);
3218
+ emOk += batch.length;
3219
+ } catch {
3220
+ for (const em of batch) {
3221
+ try {
3222
+ await pg.$executeRawUnsafe(
3223
+ `INSERT INTO ${S}.entity_memories (entity_id, memory_id) VALUES ($1::uuid, $2::uuid) ON CONFLICT DO NOTHING`,
3224
+ toUuid2(em.entity_id),
3225
+ toUuid2(em.memory_id)
3226
+ );
3227
+ emOk++;
3228
+ } catch {
3229
+ }
3230
+ }
3231
+ }
3232
+ await yieldToEventLoop();
3233
+ }
3234
+ if (entities.length > 0) {
3235
+ const maxLastSeen = entities.reduce((max, e) => {
3236
+ const ls = String(e.last_seen ?? "");
3237
+ return ls > max ? ls : max;
3238
+ }, _graphPgLastSyncedEntities);
3239
+ _graphPgLastSyncedEntities = maxLastSeen;
3240
+ }
3241
+ if (relationships.length > 0) {
3242
+ const maxTs = relationships.reduce((max, r) => {
3243
+ const t = String(r.timestamp ?? "");
3244
+ return t > max ? t : max;
3245
+ }, _graphPgLastSyncedRelationships);
3246
+ _graphPgLastSyncedRelationships = maxTs;
3247
+ }
3248
+ _graphPgLastSyncedEmCount = currentEmCount;
3249
+ process.stderr.write(
3250
+ `[exed] Graph\u2192PG sync: ${entOk}/${entities.length} entities, ${relOk}/${relationships.length} relationships, ${emOk}/${entityMemories.length} entity_memories
3251
+ `
3252
+ );
3253
+ } catch (err) {
3254
+ process.stderr.write(`[exed] Graph\u2192PG sync error: ${err instanceof Error ? err.message : String(err)}
3255
+ `);
3256
+ } finally {
3257
+ _graphPgSyncInFlight = false;
3258
+ }
3259
+ };
3260
+ const timer = setInterval(() => void tick(), GRAPH_PG_SYNC_INTERVAL_MS);
3261
+ timer.unref();
3262
+ setTimeout(() => void tick(), 6e4);
3263
+ process.stderr.write(`[exed] Graph\u2192PG sync started (every ${GRAPH_PG_SYNC_INTERVAL_MS / 6e4}m, first tick in 60s)
3264
+ `);
3265
+ }
3011
3266
  var AGENT_STATS_INTERVAL_MS = 60 * 1e3;
3012
3267
  var AGENT_STATS_PATH = path3.join(EXE_AI_DIR, "agent-stats.json");
3013
3268
  var _agentStatsInFlight = false;
@@ -3168,6 +3423,7 @@ var REFLECTION_SWEEP_INTERVAL_MS = 6 * 60 * 60 * 1e3;
3168
3423
  function startReflectionSweep() {
3169
3424
  const tick = async () => {
3170
3425
  fired("reflection_sweep");
3426
+ if (_reflectionImportFailed) return;
3171
3427
  if (!await ensureStoreForPolling()) return;
3172
3428
  try {
3173
3429
  const { getClient } = await import("./database.js");
@@ -3175,11 +3431,19 @@ function startReflectionSweep() {
3175
3431
  const agents = await client.execute(
3176
3432
  "SELECT DISTINCT agent_id FROM memory_cards WHERE active = 1 LIMIT 50"
3177
3433
  );
3434
+ let runReflection;
3435
+ try {
3436
+ ({ runReflection } = await import("../memory-reflection-RANRFUQL.js"));
3437
+ } catch (importErr) {
3438
+ _reflectionImportFailed = true;
3439
+ process.stderr.write(`[exed] Reflection module unavailable (stale chunk hash?) \u2014 disabled until daemon restart: ${importErr instanceof Error ? importErr.message : String(importErr)}
3440
+ `);
3441
+ return;
3442
+ }
3178
3443
  let totalInsights = 0;
3179
3444
  for (const row of agents.rows) {
3180
3445
  const agentId = row.agent_id;
3181
3446
  try {
3182
- const { runReflection } = await import("../memory-reflection-5CVV2M3G.js");
3183
3447
  const result = await runReflection(agentId);
3184
3448
  totalInsights += result.contradictions + result.patterns + result.summaries;
3185
3449
  } catch (e) {
@@ -3208,7 +3472,7 @@ function startReflectionSweep() {
3208
3472
  if (memories > 100 && cards < memories * 0.1) {
3209
3473
  process.stderr.write(`[exed] Memory cards sparse (${cards} cards / ${memories} memories) \u2014 running backfill...
3210
3474
  `);
3211
- const { insertMemoryCardsForBatch } = await import("../memory-cards-3FBGRV6J.js");
3475
+ const { insertMemoryCardsForBatch } = await import("../memory-cards-KRTP5GFM.js");
3212
3476
  const batchSize = 500;
3213
3477
  let offset = 0;
3214
3478
  let totalCards = 0;
@@ -3253,7 +3517,7 @@ function startDatabaseBackup() {
3253
3517
  fired("db_backup");
3254
3518
  if (!shouldRunHeavyJob("db_backup")) return;
3255
3519
  try {
3256
- const { createBackupAsync, rotateBackups, hasBackupToday } = await import("../db-backup-JEHRFLYW.js");
3520
+ const { createBackupAsync, rotateBackups, hasBackupToday } = await import("../db-backup-HLX5OLIV.js");
3257
3521
  if (hasBackupToday("daily")) return;
3258
3522
  const backupPath = await createBackupAsync("daily");
3259
3523
  if (backupPath) {
@@ -3351,7 +3615,7 @@ function startOrphanReaper() {
3351
3615
  const tick = async () => traceDaemonTimer("orphan_reaper", async () => {
3352
3616
  fired("orphan_reaper");
3353
3617
  try {
3354
- const { reapOrphanedMcpProcesses, createOrphanReaperRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
3618
+ const { reapOrphanedMcpProcesses, createOrphanReaperRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
3355
3619
  const deps = createOrphanReaperRealDeps();
3356
3620
  const reaped = await reapOrphanedMcpProcesses(deps);
3357
3621
  if (reaped.length > 0) acted("orphan_reaper");
@@ -3375,7 +3639,7 @@ function startZombieAgentReaper() {
3375
3639
  const tick = async () => traceDaemonTimer("zombie_agent_reaper", async () => {
3376
3640
  fired("zombie_agent_reaper");
3377
3641
  try {
3378
- const { reapZombieAgentProcesses, createZombieAgentReaperRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
3642
+ const { reapZombieAgentProcesses, createZombieAgentReaperRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
3379
3643
  const deps = createZombieAgentReaperRealDeps();
3380
3644
  const reaped = reapZombieAgentProcesses(deps);
3381
3645
  if (reaped.length > 0) acted("zombie_agent_reaper");
@@ -3398,7 +3662,7 @@ function startWorktreeReaper() {
3398
3662
  const tick = async () => traceDaemonTimer("worktree_reaper", async () => {
3399
3663
  fired("worktree_reaper");
3400
3664
  try {
3401
- const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
3665
+ const { reapOrphanedWorktrees, createWorktreeReaperRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
3402
3666
  const deps = await createWorktreeReaperRealDeps();
3403
3667
  const result = await reapOrphanedWorktrees(deps);
3404
3668
  if (result.pruned.length > 0) {
@@ -3453,7 +3717,7 @@ function startStuckTaskRelease() {
3453
3717
  if (!await ensureStoreForPolling()) return;
3454
3718
  try {
3455
3719
  const { getClient } = await import("./database.js");
3456
- const { releaseStuckTasks, createStuckTaskRealDeps } = await import("../daemon-orchestration-P34RDHTM.js");
3720
+ const { releaseStuckTasks, createStuckTaskRealDeps } = await import("../daemon-orchestration-ZCY4GEI3.js");
3457
3721
  const deps = createStuckTaskRealDeps(getClient);
3458
3722
  const released = await releaseStuckTasks(deps);
3459
3723
  if (released.length > 0) {
@@ -3552,23 +3816,18 @@ function startExternalRssWatchdog() {
3552
3816
  `);
3553
3817
  }
3554
3818
  }
3555
- var TASK_ENFORCEMENT_INTERVAL_MS = 6e4;
3556
3819
  function startTaskEnforcementScanner() {
3557
3820
  const tick = async () => traceDaemonTimer("task_enforcement", async () => {
3558
3821
  fired("task_enforcement");
3559
3822
  try {
3560
- const { runTaskEnforcementTick } = await import("../task-enforcement-2LI5KWFE.js");
3823
+ const { runTaskEnforcementTick } = await import("../task-enforcement-2VL5J6JJ.js");
3561
3824
  const { getTransport } = await import("./transport.js");
3562
3825
  const { loadAgentConfig } = await import("./agent-config.js");
3563
3826
  const { getClient } = await import("./database.js");
3564
3827
  const { loadEmployeesSync } = await import("./employees.js");
3565
- const { sessionScopeFilter } = await import("../task-scope-AYK6BVC7.js");
3828
+ const { sessionScopeFilter } = await import("../task-scope-YHALISIB.js");
3566
3829
  const transport = getTransport();
3567
- const allSessions = (await getTmuxSessionsAsync()).filter((s) => s.includes("-"));
3568
- const [paneCache, aliveSessions] = await Promise.all([
3569
- batchCapturePanes(allSessions, 20),
3570
- batchPaneAlive(allSessions)
3571
- ]);
3830
+ const { sessions: allSessions, paneCache, aliveSessions } = await getSharedOrchestrationCaches();
3572
3831
  await yieldToEventLoop();
3573
3832
  const enforcementTransport = {
3574
3833
  listSessions: () => allSessions,
@@ -3594,9 +3853,8 @@ function startTaskEnforcementScanner() {
3594
3853
  );
3595
3854
  }
3596
3855
  });
3597
- const timer = setInterval(tick, TASK_ENFORCEMENT_INTERVAL_MS);
3598
- timer.unref();
3599
- process.stderr.write(`[exed] Task enforcement scanner started (${TASK_ENFORCEMENT_INTERVAL_MS / 1e3}s interval)
3856
+ _orchestrationSteps.taskEnforcement = tick;
3857
+ process.stderr.write(`[exed] Task enforcement scanner registered (orchestration tick)
3600
3858
  `);
3601
3859
  }
3602
3860
  function startRssWatchdog() {
@@ -3667,7 +3925,6 @@ function startRssWatchdog() {
3667
3925
  process.stderr.write(`[exed] RSS watchdog started (warn: ${(RSS_WARN_BYTES / 1024 ** 3).toFixed(1)} GB, restart: ${(RSS_RESTART_BYTES / 1024 ** 3).toFixed(1)} GB)
3668
3926
  `);
3669
3927
  }
3670
- var API_WATCHDOG_INTERVAL_MS = 3e4;
3671
3928
  var API_ERROR_PATTERNS = [
3672
3929
  /ConnectionRefused|ECONNREFUSED/i,
3673
3930
  /ETIMEDOUT|socket hang up/i,
@@ -3686,20 +3943,17 @@ function startApiWatchdog() {
3686
3943
  const cfg = await getCachedConfig();
3687
3944
  if (!cfg?.apiWatchdog?.enabled) return;
3688
3945
  const cooldownMs = (cfg.apiWatchdog.cooldownMinutes ?? 10) * 6e4;
3689
- const sessions = await getTmuxSessionsAsync();
3690
- if (sessions.length === 0) return;
3691
- const eligibleSessions = sessions.filter((session) => {
3692
- if (!session.includes("-")) return false;
3946
+ const { sessions: allSessions, paneCache } = await getSharedOrchestrationCaches();
3947
+ if (allSessions.length === 0) return;
3948
+ const eligibleSessions = allSessions.filter((session) => {
3693
3949
  const lastNudge = _apiWatchdogLastNudge.get(session) ?? 0;
3694
3950
  return Date.now() - lastNudge >= cooldownMs;
3695
3951
  });
3696
3952
  if (eligibleSessions.length === 0) return;
3697
- const paneResults = await Promise.allSettled(
3698
- eligibleSessions.map(async (session) => ({
3699
- session,
3700
- pane: await capturePaneAsync(session, 30)
3701
- }))
3702
- );
3953
+ const paneResults = eligibleSessions.map((session) => ({
3954
+ status: "fulfilled",
3955
+ value: { session, pane: paneCache.get(session) ?? "" }
3956
+ }));
3703
3957
  for (const result of paneResults) {
3704
3958
  if (result.status !== "fulfilled" || !result.value.pane) continue;
3705
3959
  const { session, pane } = result.value;
@@ -3750,7 +4004,7 @@ function startApiWatchdog() {
3750
4004
  }
3751
4005
  }
3752
4006
  }
3753
- const liveSessionSet = new Set(sessions);
4007
+ const liveSessionSet = new Set(allSessions);
3754
4008
  for (const key of _apiWatchdogLastNudge.keys()) {
3755
4009
  if (!liveSessionSet.has(key)) _apiWatchdogLastNudge.delete(key);
3756
4010
  }
@@ -3765,9 +4019,8 @@ function startApiWatchdog() {
3765
4019
  `);
3766
4020
  }
3767
4021
  });
3768
- const timer = setInterval(() => void tick(), API_WATCHDOG_INTERVAL_MS);
3769
- timer.unref();
3770
- process.stderr.write("[exed] API watchdog started (30s scan, 10m cooldown per session)\n");
4022
+ _orchestrationSteps.apiWatchdog = tick;
4023
+ process.stderr.write("[exed] API watchdog registered (orchestration tick)\n");
3771
4024
  }
3772
4025
  function startBackgroundJobGuardrails() {
3773
4026
  const tick = async () => traceDaemonTimer("background_job_guardrails", async () => {
@@ -4131,7 +4384,7 @@ try {
4131
4384
  const msg = `[exed] EVENT LOOP BLOCKED ${(lag / 1e3).toFixed(1)}s \u2014 MCP UNRESPONSIVE. Sessions will die.`;
4132
4385
  process.stderr.write(msg + "\n");
4133
4386
  logDaemonHealth({ event: "event_loop_blocked", pid: process.pid, message: msg, data: { lagMs: lag } });
4134
- void import("../orchestration-events-TEYCD6GO.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4387
+ void import("../orchestration-events-IYTASMSN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4135
4388
  recordOE({ eventType: "daemon.event_loop_blocked", source: "exe-daemon.lagDetector", severity: "error", durationMs: lag });
4136
4389
  }).catch(() => {
4137
4390
  });
@@ -4174,7 +4427,16 @@ try {
4174
4427
  startSessionTTL();
4175
4428
  startTaskEnforcementScanner();
4176
4429
  startApiWatchdog();
4430
+ startIdleKill();
4177
4431
  startRssWatchdog();
4432
+ setTimeout(() => {
4433
+ const orchestrationTimer = setInterval(
4434
+ () => void traceDaemonTimer("orchestration_tick", runOrchestrationTick),
4435
+ 6e4
4436
+ );
4437
+ orchestrationTimer.unref();
4438
+ process.stderr.write("[exed] Orchestration tick started (60s \u2014 review + enforcement + idle + watchdog)\n");
4439
+ }, 12e3);
4178
4440
  setTimeout(startWalCheckpoint, 5e3);
4179
4441
  setTimeout(() => void traceDaemonTimer("task_file_resync", async () => {
4180
4442
  try {
@@ -4217,7 +4479,7 @@ try {
4217
4479
  });
4218
4480
  if (Number(res.rowsAffected ?? 0) > 0) {
4219
4481
  synced++;
4220
- void import("../orchestration-events-TEYCD6GO.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4482
+ void import("../orchestration-events-IYTASMSN.js").then(({ recordOrchestrationEventBestEffort: recordOE }) => {
4221
4483
  recordOE({
4222
4484
  eventType: "task_file.resynced",
4223
4485
  source: "exe-daemon.taskFileResync",
@@ -4245,14 +4507,13 @@ try {
4245
4507
  `);
4246
4508
  }
4247
4509
  }), 8e3);
4248
- setTimeout(startIdleKill, 1e4);
4249
4510
  setTimeout(() => {
4250
4511
  const BARRIER_POLL_INTERVAL_MS = 6e4;
4251
4512
  const barrierTick = async () => traceDaemonTimer("task_group_barriers", async () => {
4252
4513
  fired("task_group_barriers");
4253
4514
  if (!await ensureStoreForPolling()) return;
4254
4515
  try {
4255
- const { pollTaskGroupBarriers } = await import("../daemon-orchestration-P34RDHTM.js");
4516
+ const { pollTaskGroupBarriers } = await import("../daemon-orchestration-ZCY4GEI3.js");
4256
4517
  const firedCount = await pollTaskGroupBarriers();
4257
4518
  if (firedCount > 0) {
4258
4519
  acted("task_group_barriers");
@@ -4274,7 +4535,7 @@ try {
4274
4535
  fired("checkpoint_gc");
4275
4536
  if (!await ensureStoreForPolling()) return;
4276
4537
  try {
4277
- const { gcStaleCheckpoints } = await import("../daemon-orchestration-P34RDHTM.js");
4538
+ const { gcStaleCheckpoints } = await import("../daemon-orchestration-ZCY4GEI3.js");
4278
4539
  const cleared = await gcStaleCheckpoints();
4279
4540
  if (cleared > 0) {
4280
4541
  acted("checkpoint_gc");
@@ -4311,6 +4572,7 @@ try {
4311
4572
  setTimeout(startSkillSweep, 9e4);
4312
4573
  setTimeout(startSkillRefinement, 18e4);
4313
4574
  setTimeout(startGraphExtraction, 27e4);
4575
+ setTimeout(startGraphPgSync, 3e4);
4314
4576
  setTimeout(startReflectionSweep, 15e4);
4315
4577
  setTimeout(startConfidenceDecay, 18e4);
4316
4578
  setTimeout(startSoftDeletePurge, 21e4);
@@ -4322,7 +4584,14 @@ try {
4322
4584
  setTimeout(startZombieAgentReaper, 25e3);
4323
4585
  setTimeout(() => void traceDaemonTimer("intercom_dedup_cleanup", async () => {
4324
4586
  fired("intercom_dedup_cleanup");
4587
+ if (_intercomDedupCompleted) return;
4325
4588
  try {
4589
+ const { existsSync: markerExists } = await import("fs");
4590
+ const markerPath = path3.join(os2.homedir(), ".exe-os", ".intercom-dedup-done");
4591
+ if (markerExists(markerPath)) {
4592
+ _intercomDedupCompleted = true;
4593
+ return;
4594
+ }
4326
4595
  if (!await ensureStoreForPolling()) return;
4327
4596
  const { getClient } = await import("./database.js");
4328
4597
  const { deduplicateIntercomMemories } = await import("./consolidation.js");
@@ -4332,6 +4601,12 @@ try {
4332
4601
  process.stderr.write(`[exed] Intercom dedup: archived ${count} duplicate intercom memories
4333
4602
  `);
4334
4603
  }
4604
+ _intercomDedupCompleted = true;
4605
+ try {
4606
+ const { writeFileSync: writeFileSync3 } = await import("fs");
4607
+ writeFileSync3(markerPath, (/* @__PURE__ */ new Date()).toISOString(), "utf8");
4608
+ } catch {
4609
+ }
4335
4610
  } catch (err) {
4336
4611
  process.stderr.write(`[exed] Intercom dedup error: ${err instanceof Error ? err.message : String(err)}
4337
4612
  `);
@@ -4358,7 +4633,7 @@ try {
4358
4633
  fired("orphan_task_cleanup");
4359
4634
  try {
4360
4635
  if (!await ensureStoreForPolling()) return;
4361
- const { cleanOrphanedTaskFiles, checkTaskFileConsistency } = await import("../tasks-crud-OD75EH2G.js");
4636
+ const { cleanOrphanedTaskFiles, checkTaskFileConsistency } = await import("../tasks-crud-JXZEBZFR.js");
4362
4637
  const count = await cleanOrphanedTaskFiles();
4363
4638
  if (count > 0) {
4364
4639
  acted("orphan_task_cleanup");
@@ -4396,7 +4671,7 @@ try {
4396
4671
  const TELEMETRY_DAILY_MS = 24 * 60 * 60 * 1e3;
4397
4672
  const telemetryDaily = async () => {
4398
4673
  try {
4399
- const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-NXRMUNSW.js");
4674
+ const { sendTelemetry, isTelemetryEnabled } = await import("../telemetry-upload-H7OJNBIF.js");
4400
4675
  if (!isTelemetryEnabled()) return;
4401
4676
  const { upstream } = await sendTelemetry(24);
4402
4677
  if (upstream.startsWith("sent")) {
@@ -4411,12 +4686,12 @@ try {
4411
4686
  setTimeout(telemetryDaily, 2 * 60 * 1e3);
4412
4687
  const dailyTimer = setInterval(telemetryDaily, TELEMETRY_DAILY_MS);
4413
4688
  dailyTimer.unref();
4414
- const { startToolTelemetryFlush } = await import("../tool-telemetry-E7NWXX5R.js");
4689
+ const { startToolTelemetryFlush } = await import("../tool-telemetry-W4LFCHFT.js");
4415
4690
  startToolTelemetryFlush();
4416
4691
  process.stderr.write("[exed] Tool telemetry started (flush every 5m)\n");
4417
4692
  setTimeout(async () => {
4418
4693
  try {
4419
- const { startProjectionWorker } = await import("../projection-worker-JMGAPKH6.js");
4694
+ const { startProjectionWorker } = await import("../projection-worker-54KRNQSO.js");
4420
4695
  startProjectionWorker();
4421
4696
  } catch {
4422
4697
  }
@@ -4435,7 +4710,10 @@ try {
4435
4710
  const { initStore } = await import("./store.js");
4436
4711
  const { sendMessage, deliverLocalMessage, setWsClientSend } = await import("./messaging.js");
4437
4712
  const { getClient } = await import("./database.js");
4438
- await initStore();
4713
+ if (!_storeInitialized) {
4714
+ await initStore();
4715
+ _storeInitialized = true;
4716
+ }
4439
4717
  const wsClient = createWsClient({
4440
4718
  endpoint: config.cloud.endpoint.replace(/^https?/, "wss") + "/ws",
4441
4719
  orgId: deriveOrgId(masterKey),