@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
@@ -5,7 +5,7 @@ import {
5
5
  inferOutcome,
6
6
  inferSemanticLabel,
7
7
  ontologyPayload
8
- } from "./chunk-Y2FVN7CX.js";
8
+ } from "./chunk-EYLQRPHF.js";
9
9
  import {
10
10
  loadConfig
11
11
  } from "./chunk-VXIMSRTO.js";
@@ -18,6 +18,7 @@ import path from "path";
18
18
  import { existsSync } from "fs";
19
19
  import { createRequire } from "module";
20
20
  import { pathToFileURL } from "url";
21
+ var GRAPH_SCHEMA = "graph";
21
22
  var prismaPromise = null;
22
23
  var ontologySchemaReady = false;
23
24
  var filteredSchemaReady = false;
@@ -167,11 +168,11 @@ async function projectMemoryGraph(prisma, payload, memoryId, timestamp) {
167
168
  const actualEntityIds = /* @__PURE__ */ new Map();
168
169
  for (const entity of graph.entities) {
169
170
  const inserted = await prisma.$queryRawUnsafe(
170
- `INSERT INTO "memory"."entities" ("id", "name", "type", "first_seen", "last_seen", "properties")
171
+ `INSERT INTO "${GRAPH_SCHEMA}"."entities" ("id", "name", "type", "first_seen", "last_seen", "properties")
171
172
  VALUES ($1, $2, $3, $4, $4, $5::jsonb)
172
173
  ON CONFLICT ("name", "type") DO UPDATE SET
173
- "last_seen" = GREATEST("memory"."entities"."last_seen", EXCLUDED."last_seen"),
174
- "properties" = "memory"."entities"."properties" || EXCLUDED."properties"
174
+ "last_seen" = GREATEST("${GRAPH_SCHEMA}"."entities"."last_seen", EXCLUDED."last_seen"),
175
+ "properties" = "${GRAPH_SCHEMA}"."entities"."properties" || EXCLUDED."properties"
175
176
  RETURNING "id"`,
176
177
  entity.id,
177
178
  entity.name,
@@ -182,7 +183,7 @@ async function projectMemoryGraph(prisma, payload, memoryId, timestamp) {
182
183
  const actualId = inserted[0]?.id ?? entity.id;
183
184
  actualEntityIds.set(entity.id, actualId);
184
185
  await prisma.$executeRawUnsafe(
185
- `INSERT INTO "memory"."entity_memories" ("entity_id", "memory_id")
186
+ `INSERT INTO "${GRAPH_SCHEMA}"."entity_memories" ("entity_id", "memory_id")
186
187
  VALUES ($1, $2)
187
188
  ON CONFLICT DO NOTHING`,
188
189
  actualId,
@@ -195,13 +196,13 @@ async function projectMemoryGraph(prisma, payload, memoryId, timestamp) {
195
196
  const targetId = actualEntityIds.get(relationship.targetId) ?? relationship.targetId;
196
197
  const relId = graphEntityId(`${sourceId}->${relationship.type}->${targetId}`, "relationship");
197
198
  await prisma.$executeRawUnsafe(
198
- `INSERT INTO "memory"."relationships" ("id", "source_entity_id", "target_entity_id", "type", "weight", "confidence", "timestamp", "properties")
199
+ `INSERT INTO "${GRAPH_SCHEMA}"."relationships" ("id", "source_entity_id", "target_entity_id", "type", "weight", "confidence", "timestamp", "properties")
199
200
  VALUES ($1, $2, $3, $4, 1.0, $5, $6, $7::jsonb)
200
201
  ON CONFLICT ("source_entity_id", "target_entity_id", "type")
201
- DO UPDATE SET "weight" = LEAST("memory"."relationships"."weight" + 0.1, 2.0),
202
- "confidence" = GREATEST("memory"."relationships"."confidence", EXCLUDED."confidence"),
203
- "timestamp" = GREATEST("memory"."relationships"."timestamp", EXCLUDED."timestamp"),
204
- "properties" = "memory"."relationships"."properties" || EXCLUDED."properties"`,
202
+ DO UPDATE SET "weight" = LEAST("${GRAPH_SCHEMA}"."relationships"."weight" + 0.1, 2.0),
203
+ "confidence" = GREATEST("${GRAPH_SCHEMA}"."relationships"."confidence", EXCLUDED."confidence"),
204
+ "timestamp" = GREATEST("${GRAPH_SCHEMA}"."relationships"."timestamp", EXCLUDED."timestamp"),
205
+ "properties" = "${GRAPH_SCHEMA}"."relationships"."properties" || EXCLUDED."properties"`,
205
206
  relId,
206
207
  sourceId,
207
208
  targetId,
@@ -217,7 +218,7 @@ async function projectMemoryGraph(prisma, payload, memoryId, timestamp) {
217
218
  async function ensurePostgresOntologySchema(prisma) {
218
219
  if (ontologySchemaReady) return;
219
220
  await prisma.$executeRawUnsafe(`
220
- CREATE TABLE IF NOT EXISTS "memory"."agent_sessions" (
221
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_sessions" (
221
222
  "id" text PRIMARY KEY,
222
223
  "agent_id" text NOT NULL,
223
224
  "project_name" text,
@@ -226,9 +227,9 @@ async function ensurePostgresOntologySchema(prisma) {
226
227
  "event_count" integer NOT NULL DEFAULT 0,
227
228
  "properties" jsonb NOT NULL DEFAULT '{}'::jsonb
228
229
  )`);
229
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_sessions_agent_time" ON "memory"."agent_sessions" ("agent_id", "started_at")`);
230
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_sessions_agent_time" ON "${GRAPH_SCHEMA}"."agent_sessions" ("agent_id", "started_at")`);
230
231
  await prisma.$executeRawUnsafe(`
231
- CREATE TABLE IF NOT EXISTS "memory"."agent_goals" (
232
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_goals" (
232
233
  "id" text PRIMARY KEY,
233
234
  "statement" text NOT NULL,
234
235
  "owner_agent_id" text,
@@ -244,9 +245,9 @@ async function ensurePostgresOntologySchema(prisma) {
244
245
  "updated_at" timestamp(3) NOT NULL,
245
246
  "source_memory_id" text
246
247
  )`);
247
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_goals_project_status" ON "memory"."agent_goals" ("project_name", "status", "priority")`);
248
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_goals_project_status" ON "${GRAPH_SCHEMA}"."agent_goals" ("project_name", "status", "priority")`);
248
249
  await prisma.$executeRawUnsafe(`
249
- CREATE TABLE IF NOT EXISTS "memory"."agent_events" (
250
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_events" (
250
251
  "id" text PRIMARY KEY,
251
252
  "event_type" text NOT NULL,
252
253
  "occurred_at" timestamp(3) NOT NULL,
@@ -265,12 +266,12 @@ async function ensurePostgresOntologySchema(prisma) {
265
266
  "payload" jsonb NOT NULL DEFAULT '{}'::jsonb,
266
267
  "created_at" timestamp(3) NOT NULL
267
268
  )`);
268
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_time" ON "memory"."agent_events" ("occurred_at", "sequence_index")`);
269
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_session_seq" ON "memory"."agent_events" ("session_id", "sequence_index")`);
270
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_goal_time" ON "memory"."agent_events" ("goal_id", "occurred_at")`);
271
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_memory" ON "memory"."agent_events" ("evidence_memory_id")`);
269
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_time" ON "${GRAPH_SCHEMA}"."agent_events" ("occurred_at", "sequence_index")`);
270
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_session_seq" ON "${GRAPH_SCHEMA}"."agent_events" ("session_id", "sequence_index")`);
271
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_goal_time" ON "${GRAPH_SCHEMA}"."agent_events" ("goal_id", "occurred_at")`);
272
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_events_memory" ON "${GRAPH_SCHEMA}"."agent_events" ("evidence_memory_id")`);
272
273
  await prisma.$executeRawUnsafe(`
273
- CREATE TABLE IF NOT EXISTS "memory"."agent_goal_links" (
274
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_goal_links" (
274
275
  "id" text PRIMARY KEY,
275
276
  "goal_id" text NOT NULL,
276
277
  "link_type" text NOT NULL,
@@ -278,9 +279,9 @@ async function ensurePostgresOntologySchema(prisma) {
278
279
  "target_type" text NOT NULL,
279
280
  "created_at" timestamp(3) NOT NULL
280
281
  )`);
281
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_goal_links_goal" ON "memory"."agent_goal_links" ("goal_id", "target_type")`);
282
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_goal_links_goal" ON "${GRAPH_SCHEMA}"."agent_goal_links" ("goal_id", "target_type")`);
282
283
  await prisma.$executeRawUnsafe(`
283
- CREATE TABLE IF NOT EXISTS "memory"."agent_semantic_labels" (
284
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_semantic_labels" (
284
285
  "id" text PRIMARY KEY,
285
286
  "source_memory_id" text NOT NULL,
286
287
  "event_id" text,
@@ -291,10 +292,10 @@ async function ensurePostgresOntologySchema(prisma) {
291
292
  "created_at" timestamp(3) NOT NULL,
292
293
  "updated_at" timestamp(3) NOT NULL
293
294
  )`);
294
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_semantic_labels_memory" ON "memory"."agent_semantic_labels" ("source_memory_id", "labeler")`);
295
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_semantic_labels_event" ON "memory"."agent_semantic_labels" ("event_id")`);
295
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_semantic_labels_memory" ON "${GRAPH_SCHEMA}"."agent_semantic_labels" ("source_memory_id", "labeler")`);
296
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_semantic_labels_event" ON "${GRAPH_SCHEMA}"."agent_semantic_labels" ("event_id")`);
296
297
  await prisma.$executeRawUnsafe(`
297
- CREATE TABLE IF NOT EXISTS "memory"."agent_reflection_checkpoints" (
298
+ CREATE TABLE IF NOT EXISTS "${GRAPH_SCHEMA}"."agent_reflection_checkpoints" (
298
299
  "id" text PRIMARY KEY,
299
300
  "project_name" text,
300
301
  "session_id" text,
@@ -312,8 +313,8 @@ async function ensurePostgresOntologySchema(prisma) {
312
313
  "confidence" double precision NOT NULL DEFAULT 0,
313
314
  "created_at" timestamp(3) NOT NULL
314
315
  )`);
315
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_reflection_project_time" ON "memory"."agent_reflection_checkpoints" ("project_name", "window_end_at")`);
316
- await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_reflection_session_time" ON "memory"."agent_reflection_checkpoints" ("session_id", "window_end_at")`);
316
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_reflection_project_time" ON "${GRAPH_SCHEMA}"."agent_reflection_checkpoints" ("project_name", "window_end_at")`);
317
+ await prisma.$executeRawUnsafe(`CREATE INDEX IF NOT EXISTS "idx_agent_reflection_session_time" ON "${GRAPH_SCHEMA}"."agent_reflection_checkpoints" ("session_id", "window_end_at")`);
317
318
  ontologySchemaReady = true;
318
319
  }
319
320
  async function ensureFilteredSchema(prisma) {
@@ -355,10 +356,77 @@ async function ensureFilteredSchema(prisma) {
355
356
  "message_type" TEXT NOT NULL DEFAULT 'text',
356
357
  "metadata" JSONB DEFAULT '{}',
357
358
  "sent_at" TIMESTAMPTZ NOT NULL DEFAULT NOW(),
358
- UNIQUE("platform", "thread_id", "sent_at")
359
+ "source_ref" TEXT
359
360
  )`);
361
+ await selfHealFilteredSchema(prisma);
360
362
  filteredSchemaReady = true;
361
363
  }
364
+ async function selfHealFilteredSchema(prisma) {
365
+ const stmts = [
366
+ // --- filtered.contacts: ensure new-generation columns ---
367
+ `ALTER TABLE "filtered"."contacts" ADD COLUMN IF NOT EXISTS "name" TEXT`,
368
+ `ALTER TABLE "filtered"."contacts" ADD COLUMN IF NOT EXISTS "platform" TEXT DEFAULT 'whatsapp'`,
369
+ `ALTER TABLE "filtered"."contacts" ADD COLUMN IF NOT EXISTS "platform_id" TEXT`,
370
+ `ALTER TABLE "filtered"."contacts" ADD COLUMN IF NOT EXISTS "first_seen" TIMESTAMPTZ DEFAULT NOW()`,
371
+ `ALTER TABLE "filtered"."contacts" ADD COLUMN IF NOT EXISTS "last_seen" TIMESTAMPTZ DEFAULT NOW()`,
372
+ // Legacy NOT NULL columns the new worker never writes — relax if present.
373
+ `DO $$ BEGIN
374
+ IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='filtered' AND table_name='contacts' AND column_name='display_name' AND is_nullable='NO') THEN
375
+ ALTER TABLE "filtered"."contacts" ALTER COLUMN "display_name" DROP NOT NULL;
376
+ END IF;
377
+ END $$`,
378
+ // Backfill new columns from legacy ones where possible, then enforce upsert key.
379
+ `DO $$ BEGIN
380
+ IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='filtered' AND table_name='contacts' AND column_name='display_name') THEN
381
+ UPDATE "filtered"."contacts" SET
382
+ "name" = COALESCE("name", "display_name"),
383
+ "platform" = COALESCE("platform", "source", 'whatsapp'),
384
+ "platform_id" = COALESCE("platform_id", "source_id", "phone"),
385
+ "first_seen" = COALESCE("first_seen", "first_seen_at", NOW()),
386
+ "last_seen" = COALESCE("last_seen", "last_seen_at", NOW())
387
+ WHERE "platform" IS NULL OR "platform_id" IS NULL;
388
+ END IF;
389
+ END $$`,
390
+ `CREATE UNIQUE INDEX IF NOT EXISTS "contacts_platform_platform_id_uq" ON "filtered"."contacts"("platform", "platform_id")`,
391
+ // --- filtered.conversations: ensure new-generation columns ---
392
+ `ALTER TABLE "filtered"."conversations" ADD COLUMN IF NOT EXISTS "thread_id" TEXT`,
393
+ `ALTER TABLE "filtered"."conversations" ADD COLUMN IF NOT EXISTS "message_type" TEXT DEFAULT 'text'`,
394
+ `ALTER TABLE "filtered"."conversations" ADD COLUMN IF NOT EXISTS "sent_at" TIMESTAMPTZ DEFAULT NOW()`,
395
+ `ALTER TABLE "filtered"."conversations" ADD COLUMN IF NOT EXISTS "source_ref" TEXT`,
396
+ `DO $$ BEGIN
397
+ IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='filtered' AND table_name='conversations' AND column_name='timestamp' AND is_nullable='NO') THEN
398
+ ALTER TABLE "filtered"."conversations" ALTER COLUMN "timestamp" DROP NOT NULL;
399
+ END IF;
400
+ END $$`,
401
+ `DO $$ BEGIN
402
+ IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='filtered' AND table_name='conversations' AND column_name='remote_jid') THEN
403
+ UPDATE "filtered"."conversations" SET
404
+ "thread_id" = COALESCE("thread_id", "remote_jid"),
405
+ "sent_at" = COALESCE("sent_at", "timestamp", NOW())
406
+ WHERE "thread_id" IS NULL OR "sent_at" IS NULL;
407
+ END IF;
408
+ END $$`,
409
+ // Retire the weak same-second dedup key; keep a plain index for queries.
410
+ `ALTER TABLE "filtered"."conversations" DROP CONSTRAINT IF EXISTS "conversations_platform_thread_id_sent_at_key"`,
411
+ `DROP INDEX IF EXISTS "filtered"."conversations_platform_thread_sent_uq"`,
412
+ `CREATE INDEX IF NOT EXISTS "conversations_platform_thread_sent_idx" ON "filtered"."conversations"("platform", "thread_id", "sent_at")`,
413
+ `CREATE UNIQUE INDEX IF NOT EXISTS "conversations_platform_source_ref_uq" ON "filtered"."conversations"("platform", "source_ref")`,
414
+ // --- raw.raw_events: retry-model columns required by the poll loop ---
415
+ `ALTER TABLE "raw"."raw_events" ADD COLUMN IF NOT EXISTS "retry_count" INTEGER NOT NULL DEFAULT 0`,
416
+ `ALTER TABLE "raw"."raw_events" ADD COLUMN IF NOT EXISTS "failed_at" TIMESTAMPTZ`,
417
+ `ALTER TABLE "raw"."raw_events" ADD COLUMN IF NOT EXISTS "error" TEXT`,
418
+ `ALTER TABLE "raw"."raw_events" ADD COLUMN IF NOT EXISTS "projections" JSONB`
419
+ ];
420
+ for (const stmt of stmts) {
421
+ try {
422
+ await prisma.$executeRawUnsafe(stmt);
423
+ } catch (err) {
424
+ console.error(
425
+ `[projection-worker] schema self-heal statement failed (continuing): ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`
426
+ );
427
+ }
428
+ }
429
+ }
362
430
  async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
363
431
  await ensurePostgresOntologySchema(prisma);
364
432
  const row = {
@@ -384,10 +452,10 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
384
452
  const outcome = inferOutcome(row);
385
453
  const now = /* @__PURE__ */ new Date();
386
454
  await prisma.$executeRawUnsafe(
387
- `INSERT INTO "memory"."agent_sessions" ("id", "agent_id", "project_name", "started_at", "last_event_at", "event_count", "properties")
455
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_sessions" ("id", "agent_id", "project_name", "started_at", "last_event_at", "event_count", "properties")
388
456
  VALUES ($1, $2, $3, $4, $4, 1, $5::jsonb)
389
- ON CONFLICT ("id") DO UPDATE SET "last_event_at" = GREATEST("memory"."agent_sessions"."last_event_at", EXCLUDED."last_event_at"),
390
- "event_count" = "memory"."agent_sessions"."event_count" + 1`,
457
+ ON CONFLICT ("id") DO UPDATE SET "last_event_at" = GREATEST("${GRAPH_SCHEMA}"."agent_sessions"."last_event_at", EXCLUDED."last_event_at"),
458
+ "event_count" = "${GRAPH_SCHEMA}"."agent_sessions"."event_count" + 1`,
391
459
  row.session_id,
392
460
  row.agent_id,
393
461
  row.project_name,
@@ -395,7 +463,7 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
395
463
  JSON.stringify({ agent_role: row.agent_role })
396
464
  );
397
465
  await prisma.$executeRawUnsafe(
398
- `INSERT INTO "memory"."agent_events"
466
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_events"
399
467
  ("id", "event_type", "occurred_at", "sequence_index", "actor_agent_id", "agent_role", "project_name",
400
468
  "session_id", "task_id", "goal_id", "parent_event_id", "intention", "outcome", "evidence_memory_id",
401
469
  "impact", "payload", "created_at")
@@ -419,7 +487,7 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
419
487
  );
420
488
  const semantic = inferSemanticLabel(row);
421
489
  await prisma.$executeRawUnsafe(
422
- `INSERT INTO "memory"."agent_semantic_labels"
490
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_semantic_labels"
423
491
  ("id", "source_memory_id", "event_id", "labeler", "schema_version", "confidence", "labels", "created_at", "updated_at")
424
492
  VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $8)
425
493
  ON CONFLICT ("id") DO UPDATE SET "confidence" = EXCLUDED."confidence",
@@ -437,7 +505,7 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
437
505
  for (const statement of extractGoalCandidates(row)) {
438
506
  const goalId = stableId(`goal:${row.project_name}:${statement.toLowerCase()}`);
439
507
  await prisma.$executeRawUnsafe(
440
- `INSERT INTO "memory"."agent_goals"
508
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_goals"
441
509
  ("id", "statement", "owner_agent_id", "project_name", "status", "priority", "created_at", "updated_at", "source_memory_id")
442
510
  VALUES ($1, $2, $3, $4, 'open', 5, $5, $5, $6)
443
511
  ON CONFLICT ("id") DO UPDATE SET "updated_at" = EXCLUDED."updated_at"`,
@@ -449,7 +517,7 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
449
517
  row.id
450
518
  );
451
519
  await prisma.$executeRawUnsafe(
452
- `INSERT INTO "memory"."agent_goal_links" ("id", "goal_id", "link_type", "target_id", "target_type", "created_at")
520
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_goal_links" ("id", "goal_id", "link_type", "target_id", "target_type", "created_at")
453
521
  VALUES ($1, $2, 'evidence', $3, 'memory', $4)
454
522
  ON CONFLICT ("id") DO NOTHING`,
455
523
  stableId(`goal_link:${goalId}:${row.id}:memory`),
@@ -458,7 +526,7 @@ async function projectAgenticOntology(prisma, payload, memoryId, timestamp) {
458
526
  now
459
527
  );
460
528
  await prisma.$executeRawUnsafe(
461
- `INSERT INTO "memory"."agent_goal_links" ("id", "goal_id", "link_type", "target_id", "target_type", "created_at")
529
+ `INSERT INTO "${GRAPH_SCHEMA}"."agent_goal_links" ("id", "goal_id", "link_type", "target_id", "target_type", "created_at")
462
530
  VALUES ($1, $2, 'event', $3, 'event', $4)
463
531
  ON CONFLICT ("id") DO NOTHING`,
464
532
  stableId(`goal_link:${goalId}:${eventId}:event`),
@@ -571,7 +639,7 @@ var projectionHandlers = {
571
639
  const targets = [];
572
640
  const payload = event.payload;
573
641
  await prisma.$executeRawUnsafe(
574
- `INSERT INTO "memory"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
642
+ `INSERT INTO "${GRAPH_SCHEMA}"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
575
643
  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
576
644
  ON CONFLICT ("id") DO NOTHING`,
577
645
  crypto.randomUUID(),
@@ -585,7 +653,7 @@ var projectionHandlers = {
585
653
  "whatsapp",
586
654
  event.event_type
587
655
  );
588
- targets.push("memory");
656
+ targets.push("graph");
589
657
  await ensureFilteredSchema(prisma);
590
658
  const senderName = payload.sender_name ?? payload.contact_name ?? null;
591
659
  const senderPhone = payload.from ?? payload.phone ?? null;
@@ -608,16 +676,18 @@ var projectionHandlers = {
608
676
  const messageContent = payload.message ?? payload.text ?? payload.body ?? JSON.stringify(payload);
609
677
  const direction = payload.direction ?? "inbound";
610
678
  if (contactId && messageContent) {
679
+ const sourceRef = event.source_id ?? event.id;
611
680
  await prisma.$executeRawUnsafe(
612
- `INSERT INTO "filtered"."conversations" ("contact_id", "platform", "thread_id", "direction", "content", "message_type", "sent_at")
613
- VALUES ($1, 'whatsapp', $2, $3, $4, $5, $6)
614
- ON CONFLICT ("platform", "thread_id", "sent_at") DO NOTHING`,
681
+ `INSERT INTO "filtered"."conversations" ("contact_id", "platform", "thread_id", "direction", "content", "message_type", "sent_at", "source_ref")
682
+ VALUES ($1::uuid, 'whatsapp', $2, $3, $4, $5, $6, $7)
683
+ ON CONFLICT ("platform", "source_ref") DO NOTHING`,
615
684
  contactId,
616
685
  threadId,
617
686
  direction,
618
687
  typeof messageContent === "string" ? messageContent : JSON.stringify(messageContent),
619
688
  payload.type ?? "text",
620
- event.timestamp
689
+ event.timestamp,
690
+ String(sourceRef)
621
691
  );
622
692
  targets.push("filtered.conversations");
623
693
  }
@@ -628,7 +698,7 @@ var projectionHandlers = {
628
698
  const targets = [];
629
699
  const payload = event.payload;
630
700
  await prisma.$executeRawUnsafe(
631
- `INSERT INTO "memory"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
701
+ `INSERT INTO "${GRAPH_SCHEMA}"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
632
702
  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
633
703
  ON CONFLICT ("id") DO NOTHING`,
634
704
  crypto.randomUUID(),
@@ -642,7 +712,7 @@ var projectionHandlers = {
642
712
  "shopify",
643
713
  event.event_type
644
714
  );
645
- targets.push("memory");
715
+ targets.push("graph");
646
716
  return { targets };
647
717
  },
648
718
  async cloud_sync(event, prisma) {
@@ -650,7 +720,7 @@ var projectionHandlers = {
650
720
  const payload = event.payload;
651
721
  const memoryId = payload.id ?? crypto.randomUUID();
652
722
  await prisma.$executeRawUnsafe(
653
- `INSERT INTO "memory"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent", "domain")
723
+ `INSERT INTO "${GRAPH_SCHEMA}"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent", "domain")
654
724
  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
655
725
  ON CONFLICT ("id") DO NOTHING`,
656
726
  memoryId,
@@ -701,7 +771,7 @@ var projectionHandlers = {
701
771
  const targets = [];
702
772
  const payload = event.payload;
703
773
  await prisma.$executeRawUnsafe(
704
- `INSERT INTO "memory"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent", "domain")
774
+ `INSERT INTO "${GRAPH_SCHEMA}"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent", "domain")
705
775
  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
706
776
  ON CONFLICT ("id") DO NOTHING`,
707
777
  crypto.randomUUID(),
@@ -716,14 +786,14 @@ var projectionHandlers = {
716
786
  event.event_type,
717
787
  payload.domain ?? null
718
788
  );
719
- targets.push("memory");
789
+ targets.push("graph");
720
790
  return { targets };
721
791
  }
722
792
  };
723
793
  var projectionHandlersForTests = projectionHandlers;
724
794
  var defaultHandler = async (event, prisma) => {
725
795
  await prisma.$executeRawUnsafe(
726
- `INSERT INTO "memory"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
796
+ `INSERT INTO "${GRAPH_SCHEMA}"."memory_records" ("id", "agent_id", "agent_role", "session_id", "tool_name", "project_name", "raw_text", "memory_type", "source_type", "intent")
727
797
  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
728
798
  ON CONFLICT ("id") DO NOTHING`,
729
799
  crypto.randomUUID(),
@@ -750,10 +820,15 @@ var pollTimer = null;
750
820
  var consecutivePollErrors = 0;
751
821
  async function processBatch() {
752
822
  const prisma = await loadPrisma();
823
+ await ensureFilteredSchema(prisma);
753
824
  const events = await prisma.$queryRawUnsafe(
754
825
  `SELECT "id", "source", "source_id", "event_type", "payload", "metadata", "timestamp"
755
826
  FROM "raw"."raw_events"
756
827
  WHERE "processed_at" IS NULL
828
+ AND ("failed_at" IS NULL OR (
829
+ "retry_count" < 5
830
+ AND "failed_at" < NOW() - make_interval(secs => POWER(2, LEAST("retry_count", 8))::int)
831
+ ))
757
832
  ORDER BY "timestamp" ASC
758
833
  LIMIT $1`,
759
834
  BATCH_SIZE
@@ -768,7 +843,7 @@ async function processBatch() {
768
843
  `UPDATE "raw"."raw_events"
769
844
  SET "processed_at" = NOW(), "projections" = $1::jsonb
770
845
  WHERE "id" = $2`,
771
- JSON.stringify({ targets: result.targets, skipped: result.skipped }),
846
+ JSON.stringify({ targets: [...new Set(result.targets)], skipped: result.skipped }),
772
847
  event.id
773
848
  );
774
849
  processed++;
@@ -780,8 +855,12 @@ async function processBatch() {
780
855
  );
781
856
  await prisma.$executeRawUnsafe(
782
857
  `UPDATE "raw"."raw_events"
783
- SET "processed_at" = NOW(), "projections" = $1::jsonb
784
- WHERE "id" = $2`,
858
+ SET "failed_at" = NOW(),
859
+ "retry_count" = COALESCE("retry_count", 0) + 1,
860
+ "error" = $1,
861
+ "projections" = $2::jsonb
862
+ WHERE "id" = $3`,
863
+ message,
785
864
  JSON.stringify({ error: message }),
786
865
  event.id
787
866
  );
@@ -5,7 +5,7 @@ import {
5
5
  rerank,
6
6
  rerankWithContext,
7
7
  rerankWithScores
8
- } from "./chunk-X2E6W3DB.js";
8
+ } from "./chunk-BRSI3FD6.js";
9
9
  import "./chunk-VXIMSRTO.js";
10
10
  import "./chunk-LYH5HE24.js";
11
11
  import "./chunk-MLKGABMK.js";
@@ -1,29 +1,29 @@
1
1
  import {
2
2
  isExeSession,
3
3
  strictSessionScopeFilter
4
- } from "./chunk-CS267UMH.js";
5
- import "./chunk-6LFFIEDM.js";
4
+ } from "./chunk-5LDTCWYX.js";
5
+ import "./chunk-DU64OESH.js";
6
6
  import "./chunk-5CHYEKMH.js";
7
7
  import "./chunk-4JERP7NT.js";
8
- import "./chunk-SD2R3SEA.js";
8
+ import "./chunk-J3YNCJ4A.js";
9
9
  import "./chunk-MVW62NIZ.js";
10
10
  import "./chunk-OYNKIAVW.js";
11
11
  import "./chunk-CX6GL3ZJ.js";
12
- import "./chunk-USLVSLQ5.js";
12
+ import "./chunk-VDCPKJUQ.js";
13
13
  import "./chunk-XJUUWHVN.js";
14
14
  import "./chunk-NGP6LSV2.js";
15
- import "./chunk-VFATLVRX.js";
15
+ import "./chunk-L5VPUOB6.js";
16
16
  import "./chunk-CVYC6DUW.js";
17
17
  import "./chunk-OPU3NYOO.js";
18
18
  import "./chunk-GJV3WDWM.js";
19
19
  import "./chunk-MP2AFCGL.js";
20
- import "./chunk-R7FBOZT5.js";
20
+ import "./chunk-ISL3NSVX.js";
21
21
  import "./chunk-HYZV25LY.js";
22
22
  import {
23
23
  DEFAULT_COORDINATOR_TEMPLATE_NAME,
24
24
  getCoordinatorName
25
- } from "./chunk-5U7WB4YG.js";
26
- import "./chunk-ITPIBVSG.js";
25
+ } from "./chunk-WVBZ3QBR.js";
26
+ import "./chunk-WMZTSHNX.js";
27
27
  import "./chunk-FXU7JOXK.js";
28
28
  import "./chunk-MOZ2YQ54.js";
29
29
  import "./chunk-VXIMSRTO.js";
@@ -102,7 +102,7 @@ function createRealDeps(getClient) {
102
102
  return result.rows;
103
103
  },
104
104
  createReviewForOrphan: async (task) => {
105
- const { createReviewForCompletedTask } = await import("./tasks-review-Y5F4HRAR.js");
105
+ const { createReviewForCompletedTask } = await import("./tasks-review-VMMMAK2Y.js");
106
106
  const cwd = process.cwd();
107
107
  await createReviewForCompletedTask(
108
108
  task,
@@ -3,10 +3,10 @@ import {
3
3
  SessionManager,
4
4
  checkGitSafety,
5
5
  targetsMainBranch
6
- } from "../chunk-5NBOFYJG.js";
6
+ } from "../chunk-QYNFWFFH.js";
7
7
  import {
8
8
  MultiAgentOrchestrator
9
- } from "../chunk-DJYIBHN5.js";
9
+ } from "../chunk-PQQTSNXS.js";
10
10
  import {
11
11
  createQuietRenderer,
12
12
  createTerminalRenderer,
@@ -56,19 +56,19 @@ import {
56
56
  composeHooks,
57
57
  createDefaultHooks
58
58
  } from "../chunk-O377P7GM.js";
59
- import "../chunk-5WEH43HH.js";
60
- import "../chunk-CS267UMH.js";
61
- import "../chunk-6LFFIEDM.js";
59
+ import "../chunk-PQHA6X6Y.js";
60
+ import "../chunk-5LDTCWYX.js";
61
+ import "../chunk-DU64OESH.js";
62
62
  import "../chunk-5CHYEKMH.js";
63
63
  import "../chunk-4JERP7NT.js";
64
- import "../chunk-SD2R3SEA.js";
64
+ import "../chunk-J3YNCJ4A.js";
65
65
  import "../chunk-MVW62NIZ.js";
66
66
  import "../chunk-OYNKIAVW.js";
67
67
  import "../chunk-CX6GL3ZJ.js";
68
- import "../chunk-USLVSLQ5.js";
68
+ import "../chunk-VDCPKJUQ.js";
69
69
  import "../chunk-XJUUWHVN.js";
70
70
  import "../chunk-NGP6LSV2.js";
71
- import "../chunk-VFATLVRX.js";
71
+ import "../chunk-L5VPUOB6.js";
72
72
  import "../chunk-CVYC6DUW.js";
73
73
  import "../chunk-OPU3NYOO.js";
74
74
  import "../chunk-GJV3WDWM.js";
@@ -76,10 +76,10 @@ import {
76
76
  StateBus,
77
77
  orgBus
78
78
  } from "../chunk-MP2AFCGL.js";
79
- import "../chunk-R7FBOZT5.js";
79
+ import "../chunk-ISL3NSVX.js";
80
80
  import "../chunk-HYZV25LY.js";
81
- import "../chunk-5U7WB4YG.js";
82
- import "../chunk-ITPIBVSG.js";
81
+ import "../chunk-WVBZ3QBR.js";
82
+ import "../chunk-WMZTSHNX.js";
83
83
  import "../chunk-FXU7JOXK.js";
84
84
  import "../chunk-MOZ2YQ54.js";
85
85
  import "../chunk-VXIMSRTO.js";
@@ -2,27 +2,27 @@ import {
2
2
  ensureSessionEventsTable,
3
3
  listRecentSessionEvents,
4
4
  recordSessionEvent
5
- } from "./chunk-JGEGEOVP.js";
6
- import "./chunk-CS267UMH.js";
7
- import "./chunk-6LFFIEDM.js";
5
+ } from "./chunk-COKTAJUZ.js";
6
+ import "./chunk-5LDTCWYX.js";
7
+ import "./chunk-DU64OESH.js";
8
8
  import "./chunk-5CHYEKMH.js";
9
9
  import "./chunk-4JERP7NT.js";
10
- import "./chunk-SD2R3SEA.js";
10
+ import "./chunk-J3YNCJ4A.js";
11
11
  import "./chunk-MVW62NIZ.js";
12
12
  import "./chunk-OYNKIAVW.js";
13
13
  import "./chunk-CX6GL3ZJ.js";
14
- import "./chunk-USLVSLQ5.js";
14
+ import "./chunk-VDCPKJUQ.js";
15
15
  import "./chunk-XJUUWHVN.js";
16
16
  import "./chunk-NGP6LSV2.js";
17
- import "./chunk-VFATLVRX.js";
17
+ import "./chunk-L5VPUOB6.js";
18
18
  import "./chunk-CVYC6DUW.js";
19
19
  import "./chunk-OPU3NYOO.js";
20
20
  import "./chunk-GJV3WDWM.js";
21
21
  import "./chunk-MP2AFCGL.js";
22
- import "./chunk-R7FBOZT5.js";
22
+ import "./chunk-ISL3NSVX.js";
23
23
  import "./chunk-HYZV25LY.js";
24
- import "./chunk-5U7WB4YG.js";
25
- import "./chunk-ITPIBVSG.js";
24
+ import "./chunk-WVBZ3QBR.js";
25
+ import "./chunk-WMZTSHNX.js";
26
26
  import "./chunk-FXU7JOXK.js";
27
27
  import "./chunk-MOZ2YQ54.js";
28
28
  import "./chunk-VXIMSRTO.js";
@@ -8,9 +8,9 @@ import {
8
8
  parseStreakState,
9
9
  recordSessionKill,
10
10
  sumTokensSavedSince
11
- } from "./chunk-6QMXKKFD.js";
12
- import "./chunk-5U7WB4YG.js";
13
- import "./chunk-ITPIBVSG.js";
11
+ } from "./chunk-N27CTUFU.js";
12
+ import "./chunk-WVBZ3QBR.js";
13
+ import "./chunk-WMZTSHNX.js";
14
14
  import "./chunk-FXU7JOXK.js";
15
15
  import "./chunk-VXIMSRTO.js";
16
16
  import "./chunk-LYH5HE24.js";
@@ -1,31 +1,31 @@
1
1
  import {
2
2
  resolveExeSession
3
- } from "./chunk-CS267UMH.js";
4
- import "./chunk-6LFFIEDM.js";
3
+ } from "./chunk-5LDTCWYX.js";
4
+ import "./chunk-DU64OESH.js";
5
5
  import "./chunk-5CHYEKMH.js";
6
6
  import "./chunk-4JERP7NT.js";
7
7
  import {
8
8
  listSessions
9
- } from "./chunk-SD2R3SEA.js";
9
+ } from "./chunk-J3YNCJ4A.js";
10
10
  import "./chunk-MVW62NIZ.js";
11
11
  import "./chunk-OYNKIAVW.js";
12
12
  import "./chunk-CX6GL3ZJ.js";
13
- import "./chunk-USLVSLQ5.js";
13
+ import "./chunk-VDCPKJUQ.js";
14
14
  import "./chunk-XJUUWHVN.js";
15
15
  import "./chunk-NGP6LSV2.js";
16
- import "./chunk-VFATLVRX.js";
16
+ import "./chunk-L5VPUOB6.js";
17
17
  import "./chunk-CVYC6DUW.js";
18
18
  import {
19
19
  getProjectName
20
20
  } from "./chunk-OPU3NYOO.js";
21
21
  import "./chunk-GJV3WDWM.js";
22
22
  import "./chunk-MP2AFCGL.js";
23
- import "./chunk-R7FBOZT5.js";
23
+ import "./chunk-ISL3NSVX.js";
24
24
  import "./chunk-HYZV25LY.js";
25
25
  import {
26
26
  isCoordinatorName
27
- } from "./chunk-5U7WB4YG.js";
28
- import "./chunk-ITPIBVSG.js";
27
+ } from "./chunk-WVBZ3QBR.js";
28
+ import "./chunk-WMZTSHNX.js";
29
29
  import "./chunk-FXU7JOXK.js";
30
30
  import "./chunk-MOZ2YQ54.js";
31
31
  import "./chunk-VXIMSRTO.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  runSetupWizard,
3
3
  validateModel
4
- } from "./chunk-GBHQ5TXO.js";
4
+ } from "./chunk-UOOCGJUE.js";
5
5
  import "./chunk-K333WOW4.js";
6
6
  import "./chunk-VXIMSRTO.js";
7
7
  import "./chunk-LYH5HE24.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getClient
3
- } from "./chunk-5U7WB4YG.js";
4
- import "./chunk-ITPIBVSG.js";
3
+ } from "./chunk-WVBZ3QBR.js";
4
+ import "./chunk-WMZTSHNX.js";
5
5
  import "./chunk-FXU7JOXK.js";
6
6
  import "./chunk-VXIMSRTO.js";
7
7
  import "./chunk-LYH5HE24.js";